Home | History | Annotate | Download | only in pci
History log of /src/sys/dev/pci/if_aq.c
RevisionDateAuthorComments
 1.50  26-Feb-2025  andvar Fix typos in comments, mainly s/calcurate/calculate/.
 1.49  05-Jul-2024  rin sys: Drop redundant NULL check before m_freem(9)

m_freem(9) safely has accepted NULL argument at least since 4.2BSD:
https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/sys/uipc_mbuf.c

Compile-tested on amd64/ALL.

Suggested by knakahara@
 1.48  29-Jun-2024  riastradh if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377
 1.47  09-Mar-2024  mrg aq(4): always poll for link status

some devices don't have working link status and rather than have
a likely incomplete list of issues, always poll as well as use
the interrupt if possible.

fixes link status on this device:

aq0 at pci5 dev 0 function 0: Aquantia AQC107 10 Gigabit Network Adapter (rev. 0x02)
aq0: Atlantic revision B1, F/W version 3.1.88

(was otherwise functional, just didn't report status, which likely
meant eg, dhcpcd would be upset?)

idea via mlelstv@ from linux.

remove sc_detect_linkstat and rename sc_poll_linkstat to
sc_no_link_intr, as the meaning has changed. simplify the signature
for aq_setup_msix() and aq_establish_msix_intr(), removing forward
decls that aren't required. obsolete AQ_FORCE_POLL_LINKSTAT.
 1.46  07-Feb-2024  msaitoh Remove ryo@'s mail addresses.
 1.45  29-May-2023  rin aq(4): if_transmit: Invoke softint_schedule(9) with kpreempt disabled.

XXX
Pull up to netbsd-10 and netbsd-9.
 1.44  26-Jan-2023  ryo - Don't discard a packet even if the TX descriptor is temporarily not enough,
and error messages are not output.
- The argument to aq_encap_txring() need not be an mbuf reference, pass an entity.

pointed out by nisimura@. thanks
 1.43  14-Jan-2023  ryo Added support for the Aquantia (Marvell) AQC113 10G Network Adapter and the variants, to aq(4)
 1.42  14-Jan-2023  ryo fix indentation
 1.41  14-Jan-2023  ryo - avoid panic when failing during attach or detach with modload/drvctl.
- free workqueue resources when detaching.
- remove debug message.
 1.40  14-Jan-2023  ryo fix build error in sys/module/if_aq/

avoid error of "comparison of integer expressions of different signedness" and -Werror=sign-compare
 1.39  02-Nov-2022  andvar branches: 1.39.2;
fix various typos in comments and messages.
 1.38  21-Oct-2022  riastradh aq(4): Remove incorrect ASSERT_SLEEPABLE introduced in 1.33.

It is true that aq_stop must be sleepable, and that aq_stop_locked
may sleep, but aq_stop_locked will release sc->sc_mutex when it
sleeps, which ASSERT_SLEEPABLE doesn't know about. Since that is a
spin lock, ASSERT_SLEEPABLE trips over it and crashes.

This is not quite right: aq_stop should really only take the lock
over specific things that need the lock to synchronize with other
threads, like mii_down; aq_init and aq_stop are already serialized by
IFNET_LOCK. sc->sc_mutex is used for too much and should have its
scope narrowed like I did recently in usbnet(9). But this small
change will at least remove a source of crashes for now.
 1.37  17-Oct-2022  riastradh aq(4): Annotate boolean parameters with names for legibility.

No functional change intended.
 1.36  17-Oct-2022  riastradh aq(4): Unconditionally halt callout in aq_stop.

Fixes panic with callout still running on detach after we destroy the
lock, reported by andvar@:

fatal page fault in supervisor mode
trap type 6 code 0 rip 0xffffffff80dfafec cs 0x8 rflags 0x10286 cr2 0xfffffffffffffff0 ilevel 0x2 rsp 0xffffcd085b291ee0
Skipping crash dump on recursive panic
panic: trap
cpu0: Begin traceback...
vpanic() at netbsd:vpanic+0x183
panic() at netbsd:panic+0x3c
trap() at netbsd:trap+0xb27
--- trap (number 6) ---
mutex_oncpu() at netbsd:mutex_oncpu+0x1e
mutex_vector_enter() at netbsd:mutex_vector_enter+0xb7
aq_tick() at netbsd:aq_tick+0x23
callout_softclock() at netbsd:callout_softclock+0xbd
softint_dispatch() at netbsd:softint_dispatch+0xf9
DDB lost frame for netbsd:Xsoftintr+0x4c, trying 0xffffcd085b2920f0
Xsoftintr() at netbsd:Xsoftintr+0x4c
--- interrupt ---
fa0b2181724b21c1:
cpu0: End traceback...
 1.35  22-Sep-2022  skrll Take and release IFNET_LOCK around aq_stop in aq_detach. Also, call with
the disable flag set so that interrupts and the callout are halted.
 1.34  22-Sep-2022  riastradh aq(4): Don't schedule tick callout on interrupt if stopping.

Make sure to take the lock around access to sc_detect_linkstat too.
 1.33  16-Sep-2022  skrll Some MP improvements

- Remove use of IFF_OACTIVE

- Remove use of if_timer and provide an MP safe multiqueue watchdog

- Sprinkle some lock assertions.

Tested by ryo@. Thanks.
 1.32  08-Sep-2022  skrll Sprinkle const. Same binary before and after.
 1.31  13-Nov-2021  ryo firmware ver1 doesn't seem to work with linkstat interrupt, so in this case also set it to polling mode.

- Make the version acquisition (aq_fw_reset) timing earlier.
- Unmap registers when terminating with attach after failing to set interrupt
 1.30  11-Nov-2021  ryo Fixed a panic problem at attach with aq(4) F/W version 1.

- Don't use cprng(9) when attaching, since it's not available yet.
- Wait up to 10 seconds because delay is not enough.
- Even if the delay is not enough, it will fail attach without panic.
- Checked on the actual card D107 (F/W version 1.5.58)
 1.29  11-Oct-2021  msaitoh Add pmf_device_register().
 1.28  05-Oct-2021  ryo fix a panic "m_verify_packet: inconsistent mbuf length" on aq(4).

- If mbuf cannot be allocated or some errors occur when receiving a jumboframe,
it is necessary to free mbuf chains of the packet being received, and ignore
the subsequent segments that make up the packet.
- Even if aq_rx_intr() is completed in the middle of the jumboframe
reception process, it will resume normally at the next aq_rx_intr().
 1.27  16-Jun-2021  riastradh if_attach and if_initialize cannot fail, don't test return value

These were originally made failable back in 2017 when if_initialize
allocated a softint in every interface for link state changes, so
that it could fail gracefully instead of panicking:

https://mail-index.NetBSD.org/source-changes/2017/10/23/msg089053.html

However, this spawned many seldom- or never-tested error branches,
which are risky to have around. And that softint in every interface
has since been replaced by a single global workqueue, because link
state changes require thread context but not low latency or high
throughput:

https://mail-index.NetBSD.org/source-changes/2020/02/06/msg113759.html

So there is no longer any reason for if_initialize to fail. (The
subroutine if_stats_init can't fail because percpu_alloc can't fail
either.)

There is a snag: the softint_establish in if_percpuq_create could
fail, potentially leading to bad consequences later on trying to use
the softint. This change doesn't introduce any new bugs because of
the snag -- if_percpuq_attach was already broken. However, the snag
can be better addressed without spawning error branches, either by
using a single softint or making softints less scarce.

(Separate commit will change the signatures of if_attach and
if_initialize to return void, scheduled to ride whatever is the next
convenient kernel bump.)

Patch and testing on amd64 and evbmips64-eb by maya@; commit message
soliloquy, and compile-testing on evbppc/i386/earmv7hf, by me.
 1.26  13-Jun-2021  mlelstv Don't ignore errors of sysmon_envsys_register().
 1.25  16-Apr-2021  ryo branches: 1.25.2;
fix typo
 1.24  16-Apr-2021  ryo when the packet size was just n*MCLBYTES, there was an inconsistency in the length of mbuf.
 1.23  15-Apr-2021  ryo mtu for revision B0 and B1 is supported up to 16338 bytes
 1.22  15-Apr-2021  ryo fixed the problem of instability when changing mtu in IFF_UP state
 1.21  15-Apr-2021  ryo add support hardware tcp/udp rx checksum offloading
 1.20  18-Feb-2021  ryo branches: 1.20.2;
- use if_initialize() and if_register() instead of if_attach()
- add IFEF_MPSAFE to if_extflags

pointed out by msaitoh@, thanks
 1.19  24-Sep-2020  ryo branches: 1.19.2;
add __aligned() to all __packed structures.

suppress warnings, and allow to compiler to generate more efficent code.
 1.18  24-Sep-2020  ryo no need to swap 32bit-packed macaddr on big endian
 1.17  14-May-2020  msaitoh branches: 1.17.2;
Remove extra semicolon.
 1.16  24-Apr-2020  ryo fix typo
 1.15  24-Apr-2020  ryo add support AQC100S and D100.
not tested, but they are probably the same as the AQC100.
 1.14  23-Apr-2020  ryo sort product table, and tabify
 1.13  23-Apr-2020  ryo On FIBRE devices, there are times when linkstat interrupt doesn't occur?
reported from Andrius V. thanks.

- use polling instead of linkstat interrupt when FIBRE
- add AQ_FORCE_POLL_LINKSTAT options (not by default)
 1.12  22-Apr-2020  christos Add AQUANTIA AQC100 from Andrius V.
 1.11  15-Feb-2020  ryo branches: 1.11.4; 1.11.6;
return the ifmedia active status correctly even while the link is not up after attach.

pointed out by msaitoh@. thanks.
 1.10  10-Feb-2020  ryo add support VLAN HW filter
 1.9  10-Feb-2020  ryo fix descriptions of register map in comment
 1.8  08-Feb-2020  maxv constify
 1.7  04-Feb-2020  thorpej Use ifmedia_fini().
 1.6  31-Jan-2020  thorpej Adopt <net/if_stats.h>.
 1.5  25-Jan-2020  msaitoh Found by kUBSan:

- Use unsigned to avoid undefined behavior in aq_hw_init().
- Cast to unsigned to avoid undefined behavior in aq_set_mac_addr().
 1.4  17-Jan-2020  ryo support internal PHY temperature sensor
 1.3  17-Jan-2020  ryo make counters per queue
 1.2  17-Jan-2020  ryo set/clear IFF_OACTIVE flag only on txring 0
 1.1  01-Jan-2020  ryo branches: 1.1.2;
add support Aquantia AQC seriese 10G network adapters.

this driver is based on the FreeBSD version https://github.com/Aquantia/aqtion-freebsd ,
but drastically rewritten for NetBSD.
 1.1.2.3  29-Feb-2020  ad Sync with head.
 1.1.2.2  25-Jan-2020  ad Sync with head.
 1.1.2.1  17-Jan-2020  ad Sync with head.
 1.11.6.1  25-Apr-2020  bouyer Sync with bouyer-xenpvh-base2 (HEAD)
 1.11.4.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.11.4.1  15-Feb-2020  martin file if_aq.c was added on branch phil-wifi on 2020-04-08 14:08:09 +0000
 1.17.2.4  03-Jun-2023  martin Pull up following revision(s) (requested by rin in ticket #1637):

sys/dev/pci/if_aq.c: revision 1.45

aq(4): if_transmit: Invoke softint_schedule(9) with kpreempt disabled.
 1.17.2.3  07-Jul-2020  martin Also pull up more cosmetic revisions to minimize diffs with HEAD, requested
by jmcneill in ticket #980:

sys/dev/pci/if_aq.c 1.8,1.17

constify, remove duplicate ;
 1.17.2.2  07-Jul-2020  martin Pull up following revision(s) (requested by jmcneill in ticket #980):

sys/dev/pci/if_aq.c: revision 1.4
sys/dev/pci/if_aq.c: revision 1.5
sys/arch/amd64/conf/GENERIC: revision 1.553
sys/dev/pci/files.pci: revision 1.419
sys/arch/amd64/conf/XEN3_DOM0: revision 1.170
sys/dev/pci/if_aq.c: revision 1.9
share/man/man4/Makefile: revision 1.693
sys/dev/pci/pcidevs: revision 1.1411
share/man/man4/aq.4: revision 1.1
share/man/man4/aq.4: revision 1.3
sys/arch/i386/conf/ALL: revision 1.479
share/man/man4/aq.4: revision 1.4
sys/dev/pci/if_aq.c: revision 1.10
sys/dev/pci/files.pci: revision 1.421
sys/dev/pci/if_aq.c: revision 1.11
sys/dev/pci/if_aq.c: revision 1.12
sys/dev/pci/if_aq.c: revision 1.13
sys/dev/pci/if_aq.c: revision 1.14
sys/dev/pci/if_aq.c: revision 1.15
sys/dev/pci/if_aq.c: revision 1.16
sys/dev/pci/pcidevs: revision 1.1408
sys/arch/amd64/conf/ALL: revision 1.135
sys/net/ethertypes.h: revision 1.19
sys/arch/i386/conf/GENERIC: revision 1.1218
distrib/sets/lists/man/mi: revision 1.1668
sys/dev/pci/if_aq.c: revision 1.1
sys/dev/pci/if_aq.c: revision 1.2
sys/dev/pci/pcidevs: revision 1.1395
sys/dev/pci/if_aq.c: revision 1.3
sys/arch/evbarm/conf/GENERIC64: revision 1.125

Add the ETHERTYPE_QINQ for 802.1ad VLAN stacking

add Aquantia AQC 10G network adapters
add support Aquantia AQC seriese 10G network adapters.

this driver is based on the FreeBSD version https://github.com/Aquantia/aqtion-freebsd ,
but drastically rewritten for NetBSD.

add aq(4)

Add Aquantia AQC100, AQC100S and D100.

add support VLAN HW filter

set/clear IFF_OACTIVE flag only on txring 0

make counters per queue

support internal PHY temperature sensor

Found by kUBSan:
- Use unsigned to avoid undefined behavior in aq_hw_init().
- Cast to unsigned to avoid undefined behavior in aq_set_mac_addr().

fix descriptions of register map in comment

return the ifmedia active status correctly even while the link is not up after attach.
pointed out by msaitoh@. thanks.

On FIBRE devices, there are times when linkstat interrupt doesn't occur?
reported from Andrius V. thanks.
- use polling instead of linkstat interrupt when FIBRE
- add AQ_FORCE_POLL_LINKSTAT options (not by default)

sort product table, and tabify

add support AQC100S and D100.
not tested, but they are probably the same as the AQC100.
 1.17.2.1  14-May-2020  martin file if_aq.c was added on branch netbsd-9 on 2020-07-07 10:29:05 +0000
 1.19.2.1  03-Apr-2021  thorpej Sync with HEAD.
 1.20.2.1  17-Apr-2021  thorpej Sync with HEAD.
 1.25.2.1  17-Jun-2021  thorpej Sync w/ HEAD.
 1.39.2.2  03-Jun-2023  martin Pull up following revision(s) (requested by rin in ticket #187):

sys/dev/pci/if_aq.c: revision 1.45

aq(4): if_transmit: Invoke softint_schedule(9) with kpreempt disabled.
 1.39.2.1  30-Jan-2023  martin Pull up following revision(s) (requested by ryo in ticket #60):

sys/dev/pci/if_aq.c: revision 1.40
sys/dev/pci/if_aq.c: revision 1.41
sys/dev/pci/if_aq.c: revision 1.42
sys/dev/pci/if_aq.c: revision 1.43
sys/dev/pci/if_aq.c: revision 1.44
share/man/man4/aq.4: revision 1.5

fix build error in sys/module/if_aq/

avoid error of "comparison of integer expressions of different signedness" and -Werror=sign-compare
- avoid panic when failing during attach or detach with modload/drvctl.
- free workqueue resources when detaching.
- remove debug message.

fix indentation

Added support for the Aquantia (Marvell) AQC113 10G Network Adapter and the variants, to aq(4)
- add AQC113 and the variants
- fix first appeared version to 9.1. it was backported.
- Don't discard a packet even if the TX descriptor is temporarily not enough,
and error messages are not output.
- The argument to aq_encap_txring() need not be an mbuf reference, pass an entity.
pointed out by nisimura@. thanks

RSS XML Feed