History log of /openbsd-current/sys/dev/pci/if_aq_pci.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.28 24-May-2024 jsg

remove unneeded includes; ok miod@


# 1.27 13-May-2024 jsg

remove prototypes with no matching function
ok mpi@


Revision tags: OPENBSD_7_5_BASE
# 1.26 10-Nov-2023 bluhm

Make ifq and ifiq interface MP safe.

Rename ifq_set_maxlen() to ifq_init_maxlen(). This function neither
uses WRITE_ONCE() nor a mutex and is called before the ifq mutex
is initialized. The new name expresses that it should be used only
during interface attach when there is no concurrency.

Protect ifq_len(), ifq_empty(), ifiq_len(), and ifiq_empty() with
READ_ONCE(). They can be used without lock as they only read a
single integer.

OK dlg@


Revision tags: OPENBSD_7_4_BASE
# 1.25 01-Oct-2023 kettenis

Atlantic 2 hardware has a different layout for the TPS_DATA_TCT registers
and uses different buffer sizes. Fixes an issue where the card would
stop transmitting packets under load on the M2 Pro Mac mini.

ok jmatthew@


# 1.24 19-Sep-2023 jsg

avoid c99 for-scope variable decl
ok jmatthew@


# 1.23 15-Aug-2023 miod

Replace a bunch of (1 << 31) with (1U << 31)


# 1.22 02-May-2023 kettenis

Remove bogus newline in printf.

ok jmatthew@


# 1.21 01-May-2023 kettenis

The built-in 10G Ethernet on Apple arm64 hardware does not have a MAC
address programmed into the hardware. Get it from the device tree instead.

ok dlg@, jmatthew@


# 1.20 24-Apr-2023 jmatthew

Add initial support for Atlantic 2 hardware. Atlantic 2 has
much more complicated rx processing, and here we're doing the
bare minimum to get packets moving. RSS is not implemented yet,
vlans and multicast (among others) probably don't work yet either.

tested by kettenis@ on an M2 Mac Mini, and by me on an AQC113
card provided by Brad
ok dlg@


# 1.19 23-Apr-2023 jmatthew

Adjust some printfs in the attach code path to make more sense,
and include the mac address of the interface on the attach line.

ok dlg@


# 1.18 23-Apr-2023 jmatthew

Prepare for adding Atlantic 2 support by renaming functions and defines
specific to Atlantic 1, shuffling some of the setup code, and adding
get_mac_addr to the firmware ops struct.

ok dlg@


Revision tags: OPENBSD_7_2_BASE OPENBSD_7_3_BASE
# 1.17 25-May-2022 jmatthew

As with if_em.c r1.350, and for the same reasons (arm64 systems with non
cache coherent PCIe), map the rx and tx rings coherent.

tested by kevlo@ on rockpro64
ok dlg@


# 1.16 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.15 02-Apr-2022 jmatthew

Add dmamap syncs for rings and mbufs, fixing occasional errors seen
on a rockpro64, where dma is less coherent than on typical amd64 systems.

with and ok dlg@


# 1.14 31-Mar-2022 jmatthew

If we've created multiple queues, set up an RSS key and indirection table
to distribute received packets across the queues.

ok dlg@


# 1.13 30-Mar-2022 jmatthew

If enough MSI-X vectors are available, set up multiple tx and rx queues.
In multi-vector mode, the MSI-X vector number is the same as the irq number
on the nic, so use vector/irq 0 for link interrupts, then assign one to
each pair of rx and tx queues. We don't configure RSS yet, so packets
will only be received on the first queue, but they can be transmitted on
any queue.

ok dlg@


# 1.12 26-Mar-2022 jmatthew

Expand tx dma maps to allow packets up to the MTU limit to be transmitted.
Don't clear TPB_TX_BUF_EN when taking the interface down, as somehow that
causes transmission to fail when the interface comes up again if any large
packets had been sent.

Handle packets received into multiple rx buffers using the same approach as
ixl(4), with the addition that a receive error can be signaled on any of
the buffers rather than just the last one. Set the low water mark on the
rx ring so there are always enough buffers to receive the largest packet
supported by the interface, and fix the calculation of the data pointer
in rx buffers so there's actually MCLBYTES space available.

ok dlg@


# 1.11 20-Mar-2022 jmatthew

Enable interrupt moderation, targeting around 20k interrupts per second.
There are separate timers for rx and tx interrupts, so we can use longer
timeouts for tx since that doesn't affect packet processing latency.

ok dlg@


# 1.10 15-Mar-2022 jmatthew

Enable checksum offloads. The nic does all the work here, so we don't
need to calculate header offsets for it.

ok dlg@


# 1.9 13-Mar-2022 jmatthew

Enable vlan promisc and header stripping, and use vlan rx/tx offloads.
The vlan tx information takes up an extra slot on the tx ring, so this
affects the point at which we stop putting packets on the ring too.

ok dlg@


# 1.8 12-Mar-2022 jmatthew

Transmit segmented packets using multiple tx ring slots rather than
defragging them first.

ok dlg@


# 1.7 11-Mar-2022 jmatthew

Fix receive filter handling. Update the unicast mac address in the filter
when bringing the interface up, so it's possible to change it with
ifconfig. Rearrange multicast handling so IFF_ALLMULTI is set correctly
and multicast ranges don't trigger promisc mode. Perhaps most importantly,
set RPF_MCAST_FILTER_EN to 0 when we don't want all multicast traffic -
we use mac address filters to receive specific multicast groups, and the
multicast filter is programmed to accept all multicast traffic.

based on a diff from Brad
ok dlg@


# 1.6 10-Mar-2022 jmatthew

Invalidate the nic's rx descriptor cache when taking the interface up
or down, and turn off the global tx and rx enables when going down.
Without this, the nic can write to mbufs that were taken off the ring
when the interface was taken down, triggering mbuf cluster pool use
after free checks.

ok dlg@


# 1.5 08-Mar-2022 jmatthew

Handle rxrinfo ioctl.

ok dlg@


# 1.4 09-Oct-2021 jmatthew

No need to enable bus mastering, it's already done for us.

from Brad


Revision tags: OPENBSD_7_0_BASE
# 1.3 20-Sep-2021 jmatthew

wire up bpf correctly

ok dlg@ deraadt@


# 1.2 20-Sep-2021 jmatthew

pci_mapreg_map() will assign an address to the BAR if it doesn't have one
already, so we shouldn't refuse to attach in that case.

noticed by kevlo@ on arm64
ok dlg@ deraadt@


# 1.1 02-Sep-2021 mlarkin

aq(4) driver for Aquantia 1/2.5/5/10Gb/s PCIe ethernet adapters

Adds support for Aquantia AQC1xx family of PCIe ethernet adapters. This
driver supports 1Gbps through 10Gbps modes of operation based on the
hardware and media/switch capabilities.

The initial code was ported from NetBSD, with jmatthew@ finishing up
the Tx/Rx ring support and interrupt handler routine.

The driver only supports devices using firmware V2.

This diff enables aq(4) on riscv64 and amd64, the only platforms where
I have tested the driver, but it likely works on other architectures
as well.


# 1.27 13-May-2024 jsg

remove prototypes with no matching function
ok mpi@


Revision tags: OPENBSD_7_5_BASE
# 1.26 10-Nov-2023 bluhm

Make ifq and ifiq interface MP safe.

Rename ifq_set_maxlen() to ifq_init_maxlen(). This function neither
uses WRITE_ONCE() nor a mutex and is called before the ifq mutex
is initialized. The new name expresses that it should be used only
during interface attach when there is no concurrency.

Protect ifq_len(), ifq_empty(), ifiq_len(), and ifiq_empty() with
READ_ONCE(). They can be used without lock as they only read a
single integer.

OK dlg@


Revision tags: OPENBSD_7_4_BASE
# 1.25 01-Oct-2023 kettenis

Atlantic 2 hardware has a different layout for the TPS_DATA_TCT registers
and uses different buffer sizes. Fixes an issue where the card would
stop transmitting packets under load on the M2 Pro Mac mini.

ok jmatthew@


# 1.24 19-Sep-2023 jsg

avoid c99 for-scope variable decl
ok jmatthew@


# 1.23 15-Aug-2023 miod

Replace a bunch of (1 << 31) with (1U << 31)


# 1.22 02-May-2023 kettenis

Remove bogus newline in printf.

ok jmatthew@


# 1.21 01-May-2023 kettenis

The built-in 10G Ethernet on Apple arm64 hardware does not have a MAC
address programmed into the hardware. Get it from the device tree instead.

ok dlg@, jmatthew@


# 1.20 24-Apr-2023 jmatthew

Add initial support for Atlantic 2 hardware. Atlantic 2 has
much more complicated rx processing, and here we're doing the
bare minimum to get packets moving. RSS is not implemented yet,
vlans and multicast (among others) probably don't work yet either.

tested by kettenis@ on an M2 Mac Mini, and by me on an AQC113
card provided by Brad
ok dlg@


# 1.19 23-Apr-2023 jmatthew

Adjust some printfs in the attach code path to make more sense,
and include the mac address of the interface on the attach line.

ok dlg@


# 1.18 23-Apr-2023 jmatthew

Prepare for adding Atlantic 2 support by renaming functions and defines
specific to Atlantic 1, shuffling some of the setup code, and adding
get_mac_addr to the firmware ops struct.

ok dlg@


Revision tags: OPENBSD_7_2_BASE OPENBSD_7_3_BASE
# 1.17 25-May-2022 jmatthew

As with if_em.c r1.350, and for the same reasons (arm64 systems with non
cache coherent PCIe), map the rx and tx rings coherent.

tested by kevlo@ on rockpro64
ok dlg@


# 1.16 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.15 02-Apr-2022 jmatthew

Add dmamap syncs for rings and mbufs, fixing occasional errors seen
on a rockpro64, where dma is less coherent than on typical amd64 systems.

with and ok dlg@


# 1.14 31-Mar-2022 jmatthew

If we've created multiple queues, set up an RSS key and indirection table
to distribute received packets across the queues.

ok dlg@


# 1.13 30-Mar-2022 jmatthew

If enough MSI-X vectors are available, set up multiple tx and rx queues.
In multi-vector mode, the MSI-X vector number is the same as the irq number
on the nic, so use vector/irq 0 for link interrupts, then assign one to
each pair of rx and tx queues. We don't configure RSS yet, so packets
will only be received on the first queue, but they can be transmitted on
any queue.

ok dlg@


# 1.12 26-Mar-2022 jmatthew

Expand tx dma maps to allow packets up to the MTU limit to be transmitted.
Don't clear TPB_TX_BUF_EN when taking the interface down, as somehow that
causes transmission to fail when the interface comes up again if any large
packets had been sent.

Handle packets received into multiple rx buffers using the same approach as
ixl(4), with the addition that a receive error can be signaled on any of
the buffers rather than just the last one. Set the low water mark on the
rx ring so there are always enough buffers to receive the largest packet
supported by the interface, and fix the calculation of the data pointer
in rx buffers so there's actually MCLBYTES space available.

ok dlg@


# 1.11 20-Mar-2022 jmatthew

Enable interrupt moderation, targeting around 20k interrupts per second.
There are separate timers for rx and tx interrupts, so we can use longer
timeouts for tx since that doesn't affect packet processing latency.

ok dlg@


# 1.10 15-Mar-2022 jmatthew

Enable checksum offloads. The nic does all the work here, so we don't
need to calculate header offsets for it.

ok dlg@


# 1.9 13-Mar-2022 jmatthew

Enable vlan promisc and header stripping, and use vlan rx/tx offloads.
The vlan tx information takes up an extra slot on the tx ring, so this
affects the point at which we stop putting packets on the ring too.

ok dlg@


# 1.8 12-Mar-2022 jmatthew

Transmit segmented packets using multiple tx ring slots rather than
defragging them first.

ok dlg@


# 1.7 11-Mar-2022 jmatthew

Fix receive filter handling. Update the unicast mac address in the filter
when bringing the interface up, so it's possible to change it with
ifconfig. Rearrange multicast handling so IFF_ALLMULTI is set correctly
and multicast ranges don't trigger promisc mode. Perhaps most importantly,
set RPF_MCAST_FILTER_EN to 0 when we don't want all multicast traffic -
we use mac address filters to receive specific multicast groups, and the
multicast filter is programmed to accept all multicast traffic.

based on a diff from Brad
ok dlg@


# 1.6 10-Mar-2022 jmatthew

Invalidate the nic's rx descriptor cache when taking the interface up
or down, and turn off the global tx and rx enables when going down.
Without this, the nic can write to mbufs that were taken off the ring
when the interface was taken down, triggering mbuf cluster pool use
after free checks.

ok dlg@


# 1.5 08-Mar-2022 jmatthew

Handle rxrinfo ioctl.

ok dlg@


# 1.4 09-Oct-2021 jmatthew

No need to enable bus mastering, it's already done for us.

from Brad


Revision tags: OPENBSD_7_0_BASE
# 1.3 20-Sep-2021 jmatthew

wire up bpf correctly

ok dlg@ deraadt@


# 1.2 20-Sep-2021 jmatthew

pci_mapreg_map() will assign an address to the BAR if it doesn't have one
already, so we shouldn't refuse to attach in that case.

noticed by kevlo@ on arm64
ok dlg@ deraadt@


# 1.1 02-Sep-2021 mlarkin

aq(4) driver for Aquantia 1/2.5/5/10Gb/s PCIe ethernet adapters

Adds support for Aquantia AQC1xx family of PCIe ethernet adapters. This
driver supports 1Gbps through 10Gbps modes of operation based on the
hardware and media/switch capabilities.

The initial code was ported from NetBSD, with jmatthew@ finishing up
the Tx/Rx ring support and interrupt handler routine.

The driver only supports devices using firmware V2.

This diff enables aq(4) on riscv64 and amd64, the only platforms where
I have tested the driver, but it likely works on other architectures
as well.


# 1.26 10-Nov-2023 bluhm

Make ifq and ifiq interface MP safe.

Rename ifq_set_maxlen() to ifq_init_maxlen(). This function neither
uses WRITE_ONCE() nor a mutex and is called before the ifq mutex
is initialized. The new name expresses that it should be used only
during interface attach when there is no concurrency.

Protect ifq_len(), ifq_empty(), ifiq_len(), and ifiq_empty() with
READ_ONCE(). They can be used without lock as they only read a
single integer.

OK dlg@


Revision tags: OPENBSD_7_4_BASE
# 1.25 01-Oct-2023 kettenis

Atlantic 2 hardware has a different layout for the TPS_DATA_TCT registers
and uses different buffer sizes. Fixes an issue where the card would
stop transmitting packets under load on the M2 Pro Mac mini.

ok jmatthew@


# 1.24 19-Sep-2023 jsg

avoid c99 for-scope variable decl
ok jmatthew@


# 1.23 15-Aug-2023 miod

Replace a bunch of (1 << 31) with (1U << 31)


# 1.22 02-May-2023 kettenis

Remove bogus newline in printf.

ok jmatthew@


# 1.21 01-May-2023 kettenis

The built-in 10G Ethernet on Apple arm64 hardware does not have a MAC
address programmed into the hardware. Get it from the device tree instead.

ok dlg@, jmatthew@


# 1.20 24-Apr-2023 jmatthew

Add initial support for Atlantic 2 hardware. Atlantic 2 has
much more complicated rx processing, and here we're doing the
bare minimum to get packets moving. RSS is not implemented yet,
vlans and multicast (among others) probably don't work yet either.

tested by kettenis@ on an M2 Mac Mini, and by me on an AQC113
card provided by Brad
ok dlg@


# 1.19 23-Apr-2023 jmatthew

Adjust some printfs in the attach code path to make more sense,
and include the mac address of the interface on the attach line.

ok dlg@


# 1.18 23-Apr-2023 jmatthew

Prepare for adding Atlantic 2 support by renaming functions and defines
specific to Atlantic 1, shuffling some of the setup code, and adding
get_mac_addr to the firmware ops struct.

ok dlg@


Revision tags: OPENBSD_7_2_BASE OPENBSD_7_3_BASE
# 1.17 25-May-2022 jmatthew

As with if_em.c r1.350, and for the same reasons (arm64 systems with non
cache coherent PCIe), map the rx and tx rings coherent.

tested by kevlo@ on rockpro64
ok dlg@


# 1.16 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.15 02-Apr-2022 jmatthew

Add dmamap syncs for rings and mbufs, fixing occasional errors seen
on a rockpro64, where dma is less coherent than on typical amd64 systems.

with and ok dlg@


# 1.14 31-Mar-2022 jmatthew

If we've created multiple queues, set up an RSS key and indirection table
to distribute received packets across the queues.

ok dlg@


# 1.13 30-Mar-2022 jmatthew

If enough MSI-X vectors are available, set up multiple tx and rx queues.
In multi-vector mode, the MSI-X vector number is the same as the irq number
on the nic, so use vector/irq 0 for link interrupts, then assign one to
each pair of rx and tx queues. We don't configure RSS yet, so packets
will only be received on the first queue, but they can be transmitted on
any queue.

ok dlg@


# 1.12 26-Mar-2022 jmatthew

Expand tx dma maps to allow packets up to the MTU limit to be transmitted.
Don't clear TPB_TX_BUF_EN when taking the interface down, as somehow that
causes transmission to fail when the interface comes up again if any large
packets had been sent.

Handle packets received into multiple rx buffers using the same approach as
ixl(4), with the addition that a receive error can be signaled on any of
the buffers rather than just the last one. Set the low water mark on the
rx ring so there are always enough buffers to receive the largest packet
supported by the interface, and fix the calculation of the data pointer
in rx buffers so there's actually MCLBYTES space available.

ok dlg@


# 1.11 20-Mar-2022 jmatthew

Enable interrupt moderation, targeting around 20k interrupts per second.
There are separate timers for rx and tx interrupts, so we can use longer
timeouts for tx since that doesn't affect packet processing latency.

ok dlg@


# 1.10 15-Mar-2022 jmatthew

Enable checksum offloads. The nic does all the work here, so we don't
need to calculate header offsets for it.

ok dlg@


# 1.9 13-Mar-2022 jmatthew

Enable vlan promisc and header stripping, and use vlan rx/tx offloads.
The vlan tx information takes up an extra slot on the tx ring, so this
affects the point at which we stop putting packets on the ring too.

ok dlg@


# 1.8 12-Mar-2022 jmatthew

Transmit segmented packets using multiple tx ring slots rather than
defragging them first.

ok dlg@


# 1.7 11-Mar-2022 jmatthew

Fix receive filter handling. Update the unicast mac address in the filter
when bringing the interface up, so it's possible to change it with
ifconfig. Rearrange multicast handling so IFF_ALLMULTI is set correctly
and multicast ranges don't trigger promisc mode. Perhaps most importantly,
set RPF_MCAST_FILTER_EN to 0 when we don't want all multicast traffic -
we use mac address filters to receive specific multicast groups, and the
multicast filter is programmed to accept all multicast traffic.

based on a diff from Brad
ok dlg@


# 1.6 10-Mar-2022 jmatthew

Invalidate the nic's rx descriptor cache when taking the interface up
or down, and turn off the global tx and rx enables when going down.
Without this, the nic can write to mbufs that were taken off the ring
when the interface was taken down, triggering mbuf cluster pool use
after free checks.

ok dlg@


# 1.5 08-Mar-2022 jmatthew

Handle rxrinfo ioctl.

ok dlg@


# 1.4 09-Oct-2021 jmatthew

No need to enable bus mastering, it's already done for us.

from Brad


Revision tags: OPENBSD_7_0_BASE
# 1.3 20-Sep-2021 jmatthew

wire up bpf correctly

ok dlg@ deraadt@


# 1.2 20-Sep-2021 jmatthew

pci_mapreg_map() will assign an address to the BAR if it doesn't have one
already, so we shouldn't refuse to attach in that case.

noticed by kevlo@ on arm64
ok dlg@ deraadt@


# 1.1 02-Sep-2021 mlarkin

aq(4) driver for Aquantia 1/2.5/5/10Gb/s PCIe ethernet adapters

Adds support for Aquantia AQC1xx family of PCIe ethernet adapters. This
driver supports 1Gbps through 10Gbps modes of operation based on the
hardware and media/switch capabilities.

The initial code was ported from NetBSD, with jmatthew@ finishing up
the Tx/Rx ring support and interrupt handler routine.

The driver only supports devices using firmware V2.

This diff enables aq(4) on riscv64 and amd64, the only platforms where
I have tested the driver, but it likely works on other architectures
as well.


# 1.25 01-Oct-2023 kettenis

Atlantic 2 hardware has a different layout for the TPS_DATA_TCT registers
and uses different buffer sizes. Fixes an issue where the card would
stop transmitting packets under load on the M2 Pro Mac mini.

ok jmatthew@


# 1.24 19-Sep-2023 jsg

avoid c99 for-scope variable decl
ok jmatthew@


# 1.23 15-Aug-2023 miod

Replace a bunch of (1 << 31) with (1U << 31)


# 1.22 02-May-2023 kettenis

Remove bogus newline in printf.

ok jmatthew@


# 1.21 01-May-2023 kettenis

The built-in 10G Ethernet on Apple arm64 hardware does not have a MAC
address programmed into the hardware. Get it from the device tree instead.

ok dlg@, jmatthew@


# 1.20 24-Apr-2023 jmatthew

Add initial support for Atlantic 2 hardware. Atlantic 2 has
much more complicated rx processing, and here we're doing the
bare minimum to get packets moving. RSS is not implemented yet,
vlans and multicast (among others) probably don't work yet either.

tested by kettenis@ on an M2 Mac Mini, and by me on an AQC113
card provided by Brad
ok dlg@


# 1.19 23-Apr-2023 jmatthew

Adjust some printfs in the attach code path to make more sense,
and include the mac address of the interface on the attach line.

ok dlg@


# 1.18 23-Apr-2023 jmatthew

Prepare for adding Atlantic 2 support by renaming functions and defines
specific to Atlantic 1, shuffling some of the setup code, and adding
get_mac_addr to the firmware ops struct.

ok dlg@


Revision tags: OPENBSD_7_2_BASE OPENBSD_7_3_BASE
# 1.17 25-May-2022 jmatthew

As with if_em.c r1.350, and for the same reasons (arm64 systems with non
cache coherent PCIe), map the rx and tx rings coherent.

tested by kevlo@ on rockpro64
ok dlg@


# 1.16 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.15 02-Apr-2022 jmatthew

Add dmamap syncs for rings and mbufs, fixing occasional errors seen
on a rockpro64, where dma is less coherent than on typical amd64 systems.

with and ok dlg@


# 1.14 31-Mar-2022 jmatthew

If we've created multiple queues, set up an RSS key and indirection table
to distribute received packets across the queues.

ok dlg@


# 1.13 30-Mar-2022 jmatthew

If enough MSI-X vectors are available, set up multiple tx and rx queues.
In multi-vector mode, the MSI-X vector number is the same as the irq number
on the nic, so use vector/irq 0 for link interrupts, then assign one to
each pair of rx and tx queues. We don't configure RSS yet, so packets
will only be received on the first queue, but they can be transmitted on
any queue.

ok dlg@


# 1.12 26-Mar-2022 jmatthew

Expand tx dma maps to allow packets up to the MTU limit to be transmitted.
Don't clear TPB_TX_BUF_EN when taking the interface down, as somehow that
causes transmission to fail when the interface comes up again if any large
packets had been sent.

Handle packets received into multiple rx buffers using the same approach as
ixl(4), with the addition that a receive error can be signaled on any of
the buffers rather than just the last one. Set the low water mark on the
rx ring so there are always enough buffers to receive the largest packet
supported by the interface, and fix the calculation of the data pointer
in rx buffers so there's actually MCLBYTES space available.

ok dlg@


# 1.11 20-Mar-2022 jmatthew

Enable interrupt moderation, targeting around 20k interrupts per second.
There are separate timers for rx and tx interrupts, so we can use longer
timeouts for tx since that doesn't affect packet processing latency.

ok dlg@


# 1.10 15-Mar-2022 jmatthew

Enable checksum offloads. The nic does all the work here, so we don't
need to calculate header offsets for it.

ok dlg@


# 1.9 13-Mar-2022 jmatthew

Enable vlan promisc and header stripping, and use vlan rx/tx offloads.
The vlan tx information takes up an extra slot on the tx ring, so this
affects the point at which we stop putting packets on the ring too.

ok dlg@


# 1.8 12-Mar-2022 jmatthew

Transmit segmented packets using multiple tx ring slots rather than
defragging them first.

ok dlg@


# 1.7 11-Mar-2022 jmatthew

Fix receive filter handling. Update the unicast mac address in the filter
when bringing the interface up, so it's possible to change it with
ifconfig. Rearrange multicast handling so IFF_ALLMULTI is set correctly
and multicast ranges don't trigger promisc mode. Perhaps most importantly,
set RPF_MCAST_FILTER_EN to 0 when we don't want all multicast traffic -
we use mac address filters to receive specific multicast groups, and the
multicast filter is programmed to accept all multicast traffic.

based on a diff from Brad
ok dlg@


# 1.6 10-Mar-2022 jmatthew

Invalidate the nic's rx descriptor cache when taking the interface up
or down, and turn off the global tx and rx enables when going down.
Without this, the nic can write to mbufs that were taken off the ring
when the interface was taken down, triggering mbuf cluster pool use
after free checks.

ok dlg@


# 1.5 08-Mar-2022 jmatthew

Handle rxrinfo ioctl.

ok dlg@


# 1.4 09-Oct-2021 jmatthew

No need to enable bus mastering, it's already done for us.

from Brad


Revision tags: OPENBSD_7_0_BASE
# 1.3 20-Sep-2021 jmatthew

wire up bpf correctly

ok dlg@ deraadt@


# 1.2 20-Sep-2021 jmatthew

pci_mapreg_map() will assign an address to the BAR if it doesn't have one
already, so we shouldn't refuse to attach in that case.

noticed by kevlo@ on arm64
ok dlg@ deraadt@


# 1.1 02-Sep-2021 mlarkin

aq(4) driver for Aquantia 1/2.5/5/10Gb/s PCIe ethernet adapters

Adds support for Aquantia AQC1xx family of PCIe ethernet adapters. This
driver supports 1Gbps through 10Gbps modes of operation based on the
hardware and media/switch capabilities.

The initial code was ported from NetBSD, with jmatthew@ finishing up
the Tx/Rx ring support and interrupt handler routine.

The driver only supports devices using firmware V2.

This diff enables aq(4) on riscv64 and amd64, the only platforms where
I have tested the driver, but it likely works on other architectures
as well.


# 1.24 19-Sep-2023 jsg

avoid c99 for-scope variable decl
ok jmatthew@


# 1.23 15-Aug-2023 miod

Replace a bunch of (1 << 31) with (1U << 31)


# 1.22 02-May-2023 kettenis

Remove bogus newline in printf.

ok jmatthew@


# 1.21 01-May-2023 kettenis

The built-in 10G Ethernet on Apple arm64 hardware does not have a MAC
address programmed into the hardware. Get it from the device tree instead.

ok dlg@, jmatthew@


# 1.20 24-Apr-2023 jmatthew

Add initial support for Atlantic 2 hardware. Atlantic 2 has
much more complicated rx processing, and here we're doing the
bare minimum to get packets moving. RSS is not implemented yet,
vlans and multicast (among others) probably don't work yet either.

tested by kettenis@ on an M2 Mac Mini, and by me on an AQC113
card provided by Brad
ok dlg@


# 1.19 23-Apr-2023 jmatthew

Adjust some printfs in the attach code path to make more sense,
and include the mac address of the interface on the attach line.

ok dlg@


# 1.18 23-Apr-2023 jmatthew

Prepare for adding Atlantic 2 support by renaming functions and defines
specific to Atlantic 1, shuffling some of the setup code, and adding
get_mac_addr to the firmware ops struct.

ok dlg@


Revision tags: OPENBSD_7_2_BASE OPENBSD_7_3_BASE
# 1.17 25-May-2022 jmatthew

As with if_em.c r1.350, and for the same reasons (arm64 systems with non
cache coherent PCIe), map the rx and tx rings coherent.

tested by kevlo@ on rockpro64
ok dlg@


# 1.16 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.15 02-Apr-2022 jmatthew

Add dmamap syncs for rings and mbufs, fixing occasional errors seen
on a rockpro64, where dma is less coherent than on typical amd64 systems.

with and ok dlg@


# 1.14 31-Mar-2022 jmatthew

If we've created multiple queues, set up an RSS key and indirection table
to distribute received packets across the queues.

ok dlg@


# 1.13 30-Mar-2022 jmatthew

If enough MSI-X vectors are available, set up multiple tx and rx queues.
In multi-vector mode, the MSI-X vector number is the same as the irq number
on the nic, so use vector/irq 0 for link interrupts, then assign one to
each pair of rx and tx queues. We don't configure RSS yet, so packets
will only be received on the first queue, but they can be transmitted on
any queue.

ok dlg@


# 1.12 26-Mar-2022 jmatthew

Expand tx dma maps to allow packets up to the MTU limit to be transmitted.
Don't clear TPB_TX_BUF_EN when taking the interface down, as somehow that
causes transmission to fail when the interface comes up again if any large
packets had been sent.

Handle packets received into multiple rx buffers using the same approach as
ixl(4), with the addition that a receive error can be signaled on any of
the buffers rather than just the last one. Set the low water mark on the
rx ring so there are always enough buffers to receive the largest packet
supported by the interface, and fix the calculation of the data pointer
in rx buffers so there's actually MCLBYTES space available.

ok dlg@


# 1.11 20-Mar-2022 jmatthew

Enable interrupt moderation, targeting around 20k interrupts per second.
There are separate timers for rx and tx interrupts, so we can use longer
timeouts for tx since that doesn't affect packet processing latency.

ok dlg@


# 1.10 15-Mar-2022 jmatthew

Enable checksum offloads. The nic does all the work here, so we don't
need to calculate header offsets for it.

ok dlg@


# 1.9 13-Mar-2022 jmatthew

Enable vlan promisc and header stripping, and use vlan rx/tx offloads.
The vlan tx information takes up an extra slot on the tx ring, so this
affects the point at which we stop putting packets on the ring too.

ok dlg@


# 1.8 12-Mar-2022 jmatthew

Transmit segmented packets using multiple tx ring slots rather than
defragging them first.

ok dlg@


# 1.7 11-Mar-2022 jmatthew

Fix receive filter handling. Update the unicast mac address in the filter
when bringing the interface up, so it's possible to change it with
ifconfig. Rearrange multicast handling so IFF_ALLMULTI is set correctly
and multicast ranges don't trigger promisc mode. Perhaps most importantly,
set RPF_MCAST_FILTER_EN to 0 when we don't want all multicast traffic -
we use mac address filters to receive specific multicast groups, and the
multicast filter is programmed to accept all multicast traffic.

based on a diff from Brad
ok dlg@


# 1.6 10-Mar-2022 jmatthew

Invalidate the nic's rx descriptor cache when taking the interface up
or down, and turn off the global tx and rx enables when going down.
Without this, the nic can write to mbufs that were taken off the ring
when the interface was taken down, triggering mbuf cluster pool use
after free checks.

ok dlg@


# 1.5 08-Mar-2022 jmatthew

Handle rxrinfo ioctl.

ok dlg@


# 1.4 09-Oct-2021 jmatthew

No need to enable bus mastering, it's already done for us.

from Brad


Revision tags: OPENBSD_7_0_BASE
# 1.3 20-Sep-2021 jmatthew

wire up bpf correctly

ok dlg@ deraadt@


# 1.2 20-Sep-2021 jmatthew

pci_mapreg_map() will assign an address to the BAR if it doesn't have one
already, so we shouldn't refuse to attach in that case.

noticed by kevlo@ on arm64
ok dlg@ deraadt@


# 1.1 02-Sep-2021 mlarkin

aq(4) driver for Aquantia 1/2.5/5/10Gb/s PCIe ethernet adapters

Adds support for Aquantia AQC1xx family of PCIe ethernet adapters. This
driver supports 1Gbps through 10Gbps modes of operation based on the
hardware and media/switch capabilities.

The initial code was ported from NetBSD, with jmatthew@ finishing up
the Tx/Rx ring support and interrupt handler routine.

The driver only supports devices using firmware V2.

This diff enables aq(4) on riscv64 and amd64, the only platforms where
I have tested the driver, but it likely works on other architectures
as well.


# 1.23 15-Aug-2023 miod

Replace a bunch of (1 << 31) with (1U << 31)


# 1.22 02-May-2023 kettenis

Remove bogus newline in printf.

ok jmatthew@


# 1.21 01-May-2023 kettenis

The built-in 10G Ethernet on Apple arm64 hardware does not have a MAC
address programmed into the hardware. Get it from the device tree instead.

ok dlg@, jmatthew@


# 1.20 24-Apr-2023 jmatthew

Add initial support for Atlantic 2 hardware. Atlantic 2 has
much more complicated rx processing, and here we're doing the
bare minimum to get packets moving. RSS is not implemented yet,
vlans and multicast (among others) probably don't work yet either.

tested by kettenis@ on an M2 Mac Mini, and by me on an AQC113
card provided by Brad
ok dlg@


# 1.19 23-Apr-2023 jmatthew

Adjust some printfs in the attach code path to make more sense,
and include the mac address of the interface on the attach line.

ok dlg@


# 1.18 23-Apr-2023 jmatthew

Prepare for adding Atlantic 2 support by renaming functions and defines
specific to Atlantic 1, shuffling some of the setup code, and adding
get_mac_addr to the firmware ops struct.

ok dlg@


Revision tags: OPENBSD_7_2_BASE OPENBSD_7_3_BASE
# 1.17 25-May-2022 jmatthew

As with if_em.c r1.350, and for the same reasons (arm64 systems with non
cache coherent PCIe), map the rx and tx rings coherent.

tested by kevlo@ on rockpro64
ok dlg@


# 1.16 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.15 02-Apr-2022 jmatthew

Add dmamap syncs for rings and mbufs, fixing occasional errors seen
on a rockpro64, where dma is less coherent than on typical amd64 systems.

with and ok dlg@


# 1.14 31-Mar-2022 jmatthew

If we've created multiple queues, set up an RSS key and indirection table
to distribute received packets across the queues.

ok dlg@


# 1.13 30-Mar-2022 jmatthew

If enough MSI-X vectors are available, set up multiple tx and rx queues.
In multi-vector mode, the MSI-X vector number is the same as the irq number
on the nic, so use vector/irq 0 for link interrupts, then assign one to
each pair of rx and tx queues. We don't configure RSS yet, so packets
will only be received on the first queue, but they can be transmitted on
any queue.

ok dlg@


# 1.12 26-Mar-2022 jmatthew

Expand tx dma maps to allow packets up to the MTU limit to be transmitted.
Don't clear TPB_TX_BUF_EN when taking the interface down, as somehow that
causes transmission to fail when the interface comes up again if any large
packets had been sent.

Handle packets received into multiple rx buffers using the same approach as
ixl(4), with the addition that a receive error can be signaled on any of
the buffers rather than just the last one. Set the low water mark on the
rx ring so there are always enough buffers to receive the largest packet
supported by the interface, and fix the calculation of the data pointer
in rx buffers so there's actually MCLBYTES space available.

ok dlg@


# 1.11 20-Mar-2022 jmatthew

Enable interrupt moderation, targeting around 20k interrupts per second.
There are separate timers for rx and tx interrupts, so we can use longer
timeouts for tx since that doesn't affect packet processing latency.

ok dlg@


# 1.10 15-Mar-2022 jmatthew

Enable checksum offloads. The nic does all the work here, so we don't
need to calculate header offsets for it.

ok dlg@


# 1.9 13-Mar-2022 jmatthew

Enable vlan promisc and header stripping, and use vlan rx/tx offloads.
The vlan tx information takes up an extra slot on the tx ring, so this
affects the point at which we stop putting packets on the ring too.

ok dlg@


# 1.8 12-Mar-2022 jmatthew

Transmit segmented packets using multiple tx ring slots rather than
defragging them first.

ok dlg@


# 1.7 11-Mar-2022 jmatthew

Fix receive filter handling. Update the unicast mac address in the filter
when bringing the interface up, so it's possible to change it with
ifconfig. Rearrange multicast handling so IFF_ALLMULTI is set correctly
and multicast ranges don't trigger promisc mode. Perhaps most importantly,
set RPF_MCAST_FILTER_EN to 0 when we don't want all multicast traffic -
we use mac address filters to receive specific multicast groups, and the
multicast filter is programmed to accept all multicast traffic.

based on a diff from Brad
ok dlg@


# 1.6 10-Mar-2022 jmatthew

Invalidate the nic's rx descriptor cache when taking the interface up
or down, and turn off the global tx and rx enables when going down.
Without this, the nic can write to mbufs that were taken off the ring
when the interface was taken down, triggering mbuf cluster pool use
after free checks.

ok dlg@


# 1.5 08-Mar-2022 jmatthew

Handle rxrinfo ioctl.

ok dlg@


# 1.4 09-Oct-2021 jmatthew

No need to enable bus mastering, it's already done for us.

from Brad


Revision tags: OPENBSD_7_0_BASE
# 1.3 20-Sep-2021 jmatthew

wire up bpf correctly

ok dlg@ deraadt@


# 1.2 20-Sep-2021 jmatthew

pci_mapreg_map() will assign an address to the BAR if it doesn't have one
already, so we shouldn't refuse to attach in that case.

noticed by kevlo@ on arm64
ok dlg@ deraadt@


# 1.1 02-Sep-2021 mlarkin

aq(4) driver for Aquantia 1/2.5/5/10Gb/s PCIe ethernet adapters

Adds support for Aquantia AQC1xx family of PCIe ethernet adapters. This
driver supports 1Gbps through 10Gbps modes of operation based on the
hardware and media/switch capabilities.

The initial code was ported from NetBSD, with jmatthew@ finishing up
the Tx/Rx ring support and interrupt handler routine.

The driver only supports devices using firmware V2.

This diff enables aq(4) on riscv64 and amd64, the only platforms where
I have tested the driver, but it likely works on other architectures
as well.


# 1.22 02-May-2023 kettenis

Remove bogus newline in printf.

ok jmatthew@


# 1.21 01-May-2023 kettenis

The built-in 10G Ethernet on Apple arm64 hardware does not have a MAC
address programmed into the hardware. Get it from the device tree instead.

ok dlg@, jmatthew@


# 1.20 24-Apr-2023 jmatthew

Add initial support for Atlantic 2 hardware. Atlantic 2 has
much more complicated rx processing, and here we're doing the
bare minimum to get packets moving. RSS is not implemented yet,
vlans and multicast (among others) probably don't work yet either.

tested by kettenis@ on an M2 Mac Mini, and by me on an AQC113
card provided by Brad
ok dlg@


# 1.19 23-Apr-2023 jmatthew

Adjust some printfs in the attach code path to make more sense,
and include the mac address of the interface on the attach line.

ok dlg@


# 1.18 23-Apr-2023 jmatthew

Prepare for adding Atlantic 2 support by renaming functions and defines
specific to Atlantic 1, shuffling some of the setup code, and adding
get_mac_addr to the firmware ops struct.

ok dlg@


Revision tags: OPENBSD_7_2_BASE OPENBSD_7_3_BASE
# 1.17 25-May-2022 jmatthew

As with if_em.c r1.350, and for the same reasons (arm64 systems with non
cache coherent PCIe), map the rx and tx rings coherent.

tested by kevlo@ on rockpro64
ok dlg@


# 1.16 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.15 02-Apr-2022 jmatthew

Add dmamap syncs for rings and mbufs, fixing occasional errors seen
on a rockpro64, where dma is less coherent than on typical amd64 systems.

with and ok dlg@


# 1.14 31-Mar-2022 jmatthew

If we've created multiple queues, set up an RSS key and indirection table
to distribute received packets across the queues.

ok dlg@


# 1.13 30-Mar-2022 jmatthew

If enough MSI-X vectors are available, set up multiple tx and rx queues.
In multi-vector mode, the MSI-X vector number is the same as the irq number
on the nic, so use vector/irq 0 for link interrupts, then assign one to
each pair of rx and tx queues. We don't configure RSS yet, so packets
will only be received on the first queue, but they can be transmitted on
any queue.

ok dlg@


# 1.12 26-Mar-2022 jmatthew

Expand tx dma maps to allow packets up to the MTU limit to be transmitted.
Don't clear TPB_TX_BUF_EN when taking the interface down, as somehow that
causes transmission to fail when the interface comes up again if any large
packets had been sent.

Handle packets received into multiple rx buffers using the same approach as
ixl(4), with the addition that a receive error can be signaled on any of
the buffers rather than just the last one. Set the low water mark on the
rx ring so there are always enough buffers to receive the largest packet
supported by the interface, and fix the calculation of the data pointer
in rx buffers so there's actually MCLBYTES space available.

ok dlg@


# 1.11 20-Mar-2022 jmatthew

Enable interrupt moderation, targeting around 20k interrupts per second.
There are separate timers for rx and tx interrupts, so we can use longer
timeouts for tx since that doesn't affect packet processing latency.

ok dlg@


# 1.10 15-Mar-2022 jmatthew

Enable checksum offloads. The nic does all the work here, so we don't
need to calculate header offsets for it.

ok dlg@


# 1.9 13-Mar-2022 jmatthew

Enable vlan promisc and header stripping, and use vlan rx/tx offloads.
The vlan tx information takes up an extra slot on the tx ring, so this
affects the point at which we stop putting packets on the ring too.

ok dlg@


# 1.8 12-Mar-2022 jmatthew

Transmit segmented packets using multiple tx ring slots rather than
defragging them first.

ok dlg@


# 1.7 11-Mar-2022 jmatthew

Fix receive filter handling. Update the unicast mac address in the filter
when bringing the interface up, so it's possible to change it with
ifconfig. Rearrange multicast handling so IFF_ALLMULTI is set correctly
and multicast ranges don't trigger promisc mode. Perhaps most importantly,
set RPF_MCAST_FILTER_EN to 0 when we don't want all multicast traffic -
we use mac address filters to receive specific multicast groups, and the
multicast filter is programmed to accept all multicast traffic.

based on a diff from Brad
ok dlg@


# 1.6 10-Mar-2022 jmatthew

Invalidate the nic's rx descriptor cache when taking the interface up
or down, and turn off the global tx and rx enables when going down.
Without this, the nic can write to mbufs that were taken off the ring
when the interface was taken down, triggering mbuf cluster pool use
after free checks.

ok dlg@


# 1.5 08-Mar-2022 jmatthew

Handle rxrinfo ioctl.

ok dlg@


# 1.4 09-Oct-2021 jmatthew

No need to enable bus mastering, it's already done for us.

from Brad


Revision tags: OPENBSD_7_0_BASE
# 1.3 20-Sep-2021 jmatthew

wire up bpf correctly

ok dlg@ deraadt@


# 1.2 20-Sep-2021 jmatthew

pci_mapreg_map() will assign an address to the BAR if it doesn't have one
already, so we shouldn't refuse to attach in that case.

noticed by kevlo@ on arm64
ok dlg@ deraadt@


# 1.1 02-Sep-2021 mlarkin

aq(4) driver for Aquantia 1/2.5/5/10Gb/s PCIe ethernet adapters

Adds support for Aquantia AQC1xx family of PCIe ethernet adapters. This
driver supports 1Gbps through 10Gbps modes of operation based on the
hardware and media/switch capabilities.

The initial code was ported from NetBSD, with jmatthew@ finishing up
the Tx/Rx ring support and interrupt handler routine.

The driver only supports devices using firmware V2.

This diff enables aq(4) on riscv64 and amd64, the only platforms where
I have tested the driver, but it likely works on other architectures
as well.


# 1.22 02-May-2023 kettenis

Remove bogus newline in printf.

ok jmatthew@


# 1.21 01-May-2023 kettenis

The built-in 10G Ethernet on Apple arm64 hardware does not have a MAC
address programmed into the hardware. Get it from the device tree instead.

ok dlg@, jmatthew@


# 1.20 24-Apr-2023 jmatthew

Add initial support for Atlantic 2 hardware. Atlantic 2 has
much more complicated rx processing, and here we're doing the
bare minimum to get packets moving. RSS is not implemented yet,
vlans and multicast (among others) probably don't work yet either.

tested by kettenis@ on an M2 Mac Mini, and by me on an AQC113
card provided by Brad
ok dlg@


# 1.19 23-Apr-2023 jmatthew

Adjust some printfs in the attach code path to make more sense,
and include the mac address of the interface on the attach line.

ok dlg@


# 1.18 23-Apr-2023 jmatthew

Prepare for adding Atlantic 2 support by renaming functions and defines
specific to Atlantic 1, shuffling some of the setup code, and adding
get_mac_addr to the firmware ops struct.

ok dlg@


Revision tags: OPENBSD_7_2_BASE OPENBSD_7_3_BASE
# 1.17 25-May-2022 jmatthew

As with if_em.c r1.350, and for the same reasons (arm64 systems with non
cache coherent PCIe), map the rx and tx rings coherent.

tested by kevlo@ on rockpro64
ok dlg@


# 1.16 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.15 02-Apr-2022 jmatthew

Add dmamap syncs for rings and mbufs, fixing occasional errors seen
on a rockpro64, where dma is less coherent than on typical amd64 systems.

with and ok dlg@


# 1.14 31-Mar-2022 jmatthew

If we've created multiple queues, set up an RSS key and indirection table
to distribute received packets across the queues.

ok dlg@


# 1.13 30-Mar-2022 jmatthew

If enough MSI-X vectors are available, set up multiple tx and rx queues.
In multi-vector mode, the MSI-X vector number is the same as the irq number
on the nic, so use vector/irq 0 for link interrupts, then assign one to
each pair of rx and tx queues. We don't configure RSS yet, so packets
will only be received on the first queue, but they can be transmitted on
any queue.

ok dlg@


# 1.12 26-Mar-2022 jmatthew

Expand tx dma maps to allow packets up to the MTU limit to be transmitted.
Don't clear TPB_TX_BUF_EN when taking the interface down, as somehow that
causes transmission to fail when the interface comes up again if any large
packets had been sent.

Handle packets received into multiple rx buffers using the same approach as
ixl(4), with the addition that a receive error can be signaled on any of
the buffers rather than just the last one. Set the low water mark on the
rx ring so there are always enough buffers to receive the largest packet
supported by the interface, and fix the calculation of the data pointer
in rx buffers so there's actually MCLBYTES space available.

ok dlg@


# 1.11 20-Mar-2022 jmatthew

Enable interrupt moderation, targeting around 20k interrupts per second.
There are separate timers for rx and tx interrupts, so we can use longer
timeouts for tx since that doesn't affect packet processing latency.

ok dlg@


# 1.10 15-Mar-2022 jmatthew

Enable checksum offloads. The nic does all the work here, so we don't
need to calculate header offsets for it.

ok dlg@


# 1.9 13-Mar-2022 jmatthew

Enable vlan promisc and header stripping, and use vlan rx/tx offloads.
The vlan tx information takes up an extra slot on the tx ring, so this
affects the point at which we stop putting packets on the ring too.

ok dlg@


# 1.8 12-Mar-2022 jmatthew

Transmit segmented packets using multiple tx ring slots rather than
defragging them first.

ok dlg@


# 1.7 11-Mar-2022 jmatthew

Fix receive filter handling. Update the unicast mac address in the filter
when bringing the interface up, so it's possible to change it with
ifconfig. Rearrange multicast handling so IFF_ALLMULTI is set correctly
and multicast ranges don't trigger promisc mode. Perhaps most importantly,
set RPF_MCAST_FILTER_EN to 0 when we don't want all multicast traffic -
we use mac address filters to receive specific multicast groups, and the
multicast filter is programmed to accept all multicast traffic.

based on a diff from Brad
ok dlg@


# 1.6 10-Mar-2022 jmatthew

Invalidate the nic's rx descriptor cache when taking the interface up
or down, and turn off the global tx and rx enables when going down.
Without this, the nic can write to mbufs that were taken off the ring
when the interface was taken down, triggering mbuf cluster pool use
after free checks.

ok dlg@


# 1.5 08-Mar-2022 jmatthew

Handle rxrinfo ioctl.

ok dlg@


# 1.4 09-Oct-2021 jmatthew

No need to enable bus mastering, it's already done for us.

from Brad


Revision tags: OPENBSD_7_0_BASE
# 1.3 20-Sep-2021 jmatthew

wire up bpf correctly

ok dlg@ deraadt@


# 1.2 20-Sep-2021 jmatthew

pci_mapreg_map() will assign an address to the BAR if it doesn't have one
already, so we shouldn't refuse to attach in that case.

noticed by kevlo@ on arm64
ok dlg@ deraadt@


# 1.1 02-Sep-2021 mlarkin

aq(4) driver for Aquantia 1/2.5/5/10Gb/s PCIe ethernet adapters

Adds support for Aquantia AQC1xx family of PCIe ethernet adapters. This
driver supports 1Gbps through 10Gbps modes of operation based on the
hardware and media/switch capabilities.

The initial code was ported from NetBSD, with jmatthew@ finishing up
the Tx/Rx ring support and interrupt handler routine.

The driver only supports devices using firmware V2.

This diff enables aq(4) on riscv64 and amd64, the only platforms where
I have tested the driver, but it likely works on other architectures
as well.


# 1.20 24-Apr-2023 jmatthew

Add initial support for Atlantic 2 hardware. Atlantic 2 has
much more complicated rx processing, and here we're doing the
bare minimum to get packets moving. RSS is not implemented yet,
vlans and multicast (among others) probably don't work yet either.

tested by kettenis@ on an M2 Mac Mini, and by me on an AQC113
card provided by Brad
ok dlg@


# 1.19 23-Apr-2023 jmatthew

Adjust some printfs in the attach code path to make more sense,
and include the mac address of the interface on the attach line.

ok dlg@


# 1.18 23-Apr-2023 jmatthew

Prepare for adding Atlantic 2 support by renaming functions and defines
specific to Atlantic 1, shuffling some of the setup code, and adding
get_mac_addr to the firmware ops struct.

ok dlg@


Revision tags: OPENBSD_7_2_BASE OPENBSD_7_3_BASE
# 1.17 25-May-2022 jmatthew

As with if_em.c r1.350, and for the same reasons (arm64 systems with non
cache coherent PCIe), map the rx and tx rings coherent.

tested by kevlo@ on rockpro64
ok dlg@


# 1.16 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.15 02-Apr-2022 jmatthew

Add dmamap syncs for rings and mbufs, fixing occasional errors seen
on a rockpro64, where dma is less coherent than on typical amd64 systems.

with and ok dlg@


# 1.14 31-Mar-2022 jmatthew

If we've created multiple queues, set up an RSS key and indirection table
to distribute received packets across the queues.

ok dlg@


# 1.13 30-Mar-2022 jmatthew

If enough MSI-X vectors are available, set up multiple tx and rx queues.
In multi-vector mode, the MSI-X vector number is the same as the irq number
on the nic, so use vector/irq 0 for link interrupts, then assign one to
each pair of rx and tx queues. We don't configure RSS yet, so packets
will only be received on the first queue, but they can be transmitted on
any queue.

ok dlg@


# 1.12 26-Mar-2022 jmatthew

Expand tx dma maps to allow packets up to the MTU limit to be transmitted.
Don't clear TPB_TX_BUF_EN when taking the interface down, as somehow that
causes transmission to fail when the interface comes up again if any large
packets had been sent.

Handle packets received into multiple rx buffers using the same approach as
ixl(4), with the addition that a receive error can be signaled on any of
the buffers rather than just the last one. Set the low water mark on the
rx ring so there are always enough buffers to receive the largest packet
supported by the interface, and fix the calculation of the data pointer
in rx buffers so there's actually MCLBYTES space available.

ok dlg@


# 1.11 20-Mar-2022 jmatthew

Enable interrupt moderation, targeting around 20k interrupts per second.
There are separate timers for rx and tx interrupts, so we can use longer
timeouts for tx since that doesn't affect packet processing latency.

ok dlg@


# 1.10 15-Mar-2022 jmatthew

Enable checksum offloads. The nic does all the work here, so we don't
need to calculate header offsets for it.

ok dlg@


# 1.9 13-Mar-2022 jmatthew

Enable vlan promisc and header stripping, and use vlan rx/tx offloads.
The vlan tx information takes up an extra slot on the tx ring, so this
affects the point at which we stop putting packets on the ring too.

ok dlg@


# 1.8 12-Mar-2022 jmatthew

Transmit segmented packets using multiple tx ring slots rather than
defragging them first.

ok dlg@


# 1.7 11-Mar-2022 jmatthew

Fix receive filter handling. Update the unicast mac address in the filter
when bringing the interface up, so it's possible to change it with
ifconfig. Rearrange multicast handling so IFF_ALLMULTI is set correctly
and multicast ranges don't trigger promisc mode. Perhaps most importantly,
set RPF_MCAST_FILTER_EN to 0 when we don't want all multicast traffic -
we use mac address filters to receive specific multicast groups, and the
multicast filter is programmed to accept all multicast traffic.

based on a diff from Brad
ok dlg@


# 1.6 10-Mar-2022 jmatthew

Invalidate the nic's rx descriptor cache when taking the interface up
or down, and turn off the global tx and rx enables when going down.
Without this, the nic can write to mbufs that were taken off the ring
when the interface was taken down, triggering mbuf cluster pool use
after free checks.

ok dlg@


# 1.5 08-Mar-2022 jmatthew

Handle rxrinfo ioctl.

ok dlg@


# 1.4 09-Oct-2021 jmatthew

No need to enable bus mastering, it's already done for us.

from Brad


Revision tags: OPENBSD_7_0_BASE
# 1.3 20-Sep-2021 jmatthew

wire up bpf correctly

ok dlg@ deraadt@


# 1.2 20-Sep-2021 jmatthew

pci_mapreg_map() will assign an address to the BAR if it doesn't have one
already, so we shouldn't refuse to attach in that case.

noticed by kevlo@ on arm64
ok dlg@ deraadt@


# 1.1 02-Sep-2021 mlarkin

aq(4) driver for Aquantia 1/2.5/5/10Gb/s PCIe ethernet adapters

Adds support for Aquantia AQC1xx family of PCIe ethernet adapters. This
driver supports 1Gbps through 10Gbps modes of operation based on the
hardware and media/switch capabilities.

The initial code was ported from NetBSD, with jmatthew@ finishing up
the Tx/Rx ring support and interrupt handler routine.

The driver only supports devices using firmware V2.

This diff enables aq(4) on riscv64 and amd64, the only platforms where
I have tested the driver, but it likely works on other architectures
as well.


# 1.17 25-May-2022 jmatthew

As with if_em.c r1.350, and for the same reasons (arm64 systems with non
cache coherent PCIe), map the rx and tx rings coherent.

tested by kevlo@ on rockpro64
ok dlg@


# 1.16 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.15 02-Apr-2022 jmatthew

Add dmamap syncs for rings and mbufs, fixing occasional errors seen
on a rockpro64, where dma is less coherent than on typical amd64 systems.

with and ok dlg@


# 1.14 31-Mar-2022 jmatthew

If we've created multiple queues, set up an RSS key and indirection table
to distribute received packets across the queues.

ok dlg@


# 1.13 30-Mar-2022 jmatthew

If enough MSI-X vectors are available, set up multiple tx and rx queues.
In multi-vector mode, the MSI-X vector number is the same as the irq number
on the nic, so use vector/irq 0 for link interrupts, then assign one to
each pair of rx and tx queues. We don't configure RSS yet, so packets
will only be received on the first queue, but they can be transmitted on
any queue.

ok dlg@


# 1.12 26-Mar-2022 jmatthew

Expand tx dma maps to allow packets up to the MTU limit to be transmitted.
Don't clear TPB_TX_BUF_EN when taking the interface down, as somehow that
causes transmission to fail when the interface comes up again if any large
packets had been sent.

Handle packets received into multiple rx buffers using the same approach as
ixl(4), with the addition that a receive error can be signaled on any of
the buffers rather than just the last one. Set the low water mark on the
rx ring so there are always enough buffers to receive the largest packet
supported by the interface, and fix the calculation of the data pointer
in rx buffers so there's actually MCLBYTES space available.

ok dlg@


# 1.11 20-Mar-2022 jmatthew

Enable interrupt moderation, targeting around 20k interrupts per second.
There are separate timers for rx and tx interrupts, so we can use longer
timeouts for tx since that doesn't affect packet processing latency.

ok dlg@


# 1.10 15-Mar-2022 jmatthew

Enable checksum offloads. The nic does all the work here, so we don't
need to calculate header offsets for it.

ok dlg@


# 1.9 13-Mar-2022 jmatthew

Enable vlan promisc and header stripping, and use vlan rx/tx offloads.
The vlan tx information takes up an extra slot on the tx ring, so this
affects the point at which we stop putting packets on the ring too.

ok dlg@


# 1.8 12-Mar-2022 jmatthew

Transmit segmented packets using multiple tx ring slots rather than
defragging them first.

ok dlg@


# 1.7 11-Mar-2022 jmatthew

Fix receive filter handling. Update the unicast mac address in the filter
when bringing the interface up, so it's possible to change it with
ifconfig. Rearrange multicast handling so IFF_ALLMULTI is set correctly
and multicast ranges don't trigger promisc mode. Perhaps most importantly,
set RPF_MCAST_FILTER_EN to 0 when we don't want all multicast traffic -
we use mac address filters to receive specific multicast groups, and the
multicast filter is programmed to accept all multicast traffic.

based on a diff from Brad
ok dlg@


# 1.6 10-Mar-2022 jmatthew

Invalidate the nic's rx descriptor cache when taking the interface up
or down, and turn off the global tx and rx enables when going down.
Without this, the nic can write to mbufs that were taken off the ring
when the interface was taken down, triggering mbuf cluster pool use
after free checks.

ok dlg@


# 1.5 08-Mar-2022 jmatthew

Handle rxrinfo ioctl.

ok dlg@


# 1.4 09-Oct-2021 jmatthew

No need to enable bus mastering, it's already done for us.

from Brad


Revision tags: OPENBSD_7_0_BASE
# 1.3 20-Sep-2021 jmatthew

wire up bpf correctly

ok dlg@ deraadt@


# 1.2 20-Sep-2021 jmatthew

pci_mapreg_map() will assign an address to the BAR if it doesn't have one
already, so we shouldn't refuse to attach in that case.

noticed by kevlo@ on arm64
ok dlg@ deraadt@


# 1.1 02-Sep-2021 mlarkin

aq(4) driver for Aquantia 1/2.5/5/10Gb/s PCIe ethernet adapters

Adds support for Aquantia AQC1xx family of PCIe ethernet adapters. This
driver supports 1Gbps through 10Gbps modes of operation based on the
hardware and media/switch capabilities.

The initial code was ported from NetBSD, with jmatthew@ finishing up
the Tx/Rx ring support and interrupt handler routine.

The driver only supports devices using firmware V2.

This diff enables aq(4) on riscv64 and amd64, the only platforms where
I have tested the driver, but it likely works on other architectures
as well.


# 1.16 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.15 02-Apr-2022 jmatthew

Add dmamap syncs for rings and mbufs, fixing occasional errors seen
on a rockpro64, where dma is less coherent than on typical amd64 systems.

with and ok dlg@


# 1.14 31-Mar-2022 jmatthew

If we've created multiple queues, set up an RSS key and indirection table
to distribute received packets across the queues.

ok dlg@


# 1.13 30-Mar-2022 jmatthew

If enough MSI-X vectors are available, set up multiple tx and rx queues.
In multi-vector mode, the MSI-X vector number is the same as the irq number
on the nic, so use vector/irq 0 for link interrupts, then assign one to
each pair of rx and tx queues. We don't configure RSS yet, so packets
will only be received on the first queue, but they can be transmitted on
any queue.

ok dlg@


# 1.12 26-Mar-2022 jmatthew

Expand tx dma maps to allow packets up to the MTU limit to be transmitted.
Don't clear TPB_TX_BUF_EN when taking the interface down, as somehow that
causes transmission to fail when the interface comes up again if any large
packets had been sent.

Handle packets received into multiple rx buffers using the same approach as
ixl(4), with the addition that a receive error can be signaled on any of
the buffers rather than just the last one. Set the low water mark on the
rx ring so there are always enough buffers to receive the largest packet
supported by the interface, and fix the calculation of the data pointer
in rx buffers so there's actually MCLBYTES space available.

ok dlg@


# 1.11 20-Mar-2022 jmatthew

Enable interrupt moderation, targeting around 20k interrupts per second.
There are separate timers for rx and tx interrupts, so we can use longer
timeouts for tx since that doesn't affect packet processing latency.

ok dlg@


# 1.10 15-Mar-2022 jmatthew

Enable checksum offloads. The nic does all the work here, so we don't
need to calculate header offsets for it.

ok dlg@


# 1.9 13-Mar-2022 jmatthew

Enable vlan promisc and header stripping, and use vlan rx/tx offloads.
The vlan tx information takes up an extra slot on the tx ring, so this
affects the point at which we stop putting packets on the ring too.

ok dlg@


# 1.8 12-Mar-2022 jmatthew

Transmit segmented packets using multiple tx ring slots rather than
defragging them first.

ok dlg@


# 1.7 11-Mar-2022 jmatthew

Fix receive filter handling. Update the unicast mac address in the filter
when bringing the interface up, so it's possible to change it with
ifconfig. Rearrange multicast handling so IFF_ALLMULTI is set correctly
and multicast ranges don't trigger promisc mode. Perhaps most importantly,
set RPF_MCAST_FILTER_EN to 0 when we don't want all multicast traffic -
we use mac address filters to receive specific multicast groups, and the
multicast filter is programmed to accept all multicast traffic.

based on a diff from Brad
ok dlg@


# 1.6 10-Mar-2022 jmatthew

Invalidate the nic's rx descriptor cache when taking the interface up
or down, and turn off the global tx and rx enables when going down.
Without this, the nic can write to mbufs that were taken off the ring
when the interface was taken down, triggering mbuf cluster pool use
after free checks.

ok dlg@


# 1.5 08-Mar-2022 jmatthew

Handle rxrinfo ioctl.

ok dlg@


# 1.4 09-Oct-2021 jmatthew

No need to enable bus mastering, it's already done for us.

from Brad


Revision tags: OPENBSD_7_0_BASE
# 1.3 20-Sep-2021 jmatthew

wire up bpf correctly

ok dlg@ deraadt@


# 1.2 20-Sep-2021 jmatthew

pci_mapreg_map() will assign an address to the BAR if it doesn't have one
already, so we shouldn't refuse to attach in that case.

noticed by kevlo@ on arm64
ok dlg@ deraadt@


# 1.1 02-Sep-2021 mlarkin

aq(4) driver for Aquantia 1/2.5/5/10Gb/s PCIe ethernet adapters

Adds support for Aquantia AQC1xx family of PCIe ethernet adapters. This
driver supports 1Gbps through 10Gbps modes of operation based on the
hardware and media/switch capabilities.

The initial code was ported from NetBSD, with jmatthew@ finishing up
the Tx/Rx ring support and interrupt handler routine.

The driver only supports devices using firmware V2.

This diff enables aq(4) on riscv64 and amd64, the only platforms where
I have tested the driver, but it likely works on other architectures
as well.


# 1.15 02-Apr-2022 jmatthew

Add dmamap syncs for rings and mbufs, fixing occasional errors seen
on a rockpro64, where dma is less coherent than on typical amd64 systems.

with and ok dlg@


# 1.14 31-Mar-2022 jmatthew

If we've created multiple queues, set up an RSS key and indirection table
to distribute received packets across the queues.

ok dlg@


# 1.13 30-Mar-2022 jmatthew

If enough MSI-X vectors are available, set up multiple tx and rx queues.
In multi-vector mode, the MSI-X vector number is the same as the irq number
on the nic, so use vector/irq 0 for link interrupts, then assign one to
each pair of rx and tx queues. We don't configure RSS yet, so packets
will only be received on the first queue, but they can be transmitted on
any queue.

ok dlg@


# 1.12 26-Mar-2022 jmatthew

Expand tx dma maps to allow packets up to the MTU limit to be transmitted.
Don't clear TPB_TX_BUF_EN when taking the interface down, as somehow that
causes transmission to fail when the interface comes up again if any large
packets had been sent.

Handle packets received into multiple rx buffers using the same approach as
ixl(4), with the addition that a receive error can be signaled on any of
the buffers rather than just the last one. Set the low water mark on the
rx ring so there are always enough buffers to receive the largest packet
supported by the interface, and fix the calculation of the data pointer
in rx buffers so there's actually MCLBYTES space available.

ok dlg@


# 1.11 20-Mar-2022 jmatthew

Enable interrupt moderation, targeting around 20k interrupts per second.
There are separate timers for rx and tx interrupts, so we can use longer
timeouts for tx since that doesn't affect packet processing latency.

ok dlg@


# 1.10 15-Mar-2022 jmatthew

Enable checksum offloads. The nic does all the work here, so we don't
need to calculate header offsets for it.

ok dlg@


# 1.9 13-Mar-2022 jmatthew

Enable vlan promisc and header stripping, and use vlan rx/tx offloads.
The vlan tx information takes up an extra slot on the tx ring, so this
affects the point at which we stop putting packets on the ring too.

ok dlg@


# 1.8 12-Mar-2022 jmatthew

Transmit segmented packets using multiple tx ring slots rather than
defragging them first.

ok dlg@


# 1.7 11-Mar-2022 jmatthew

Fix receive filter handling. Update the unicast mac address in the filter
when bringing the interface up, so it's possible to change it with
ifconfig. Rearrange multicast handling so IFF_ALLMULTI is set correctly
and multicast ranges don't trigger promisc mode. Perhaps most importantly,
set RPF_MCAST_FILTER_EN to 0 when we don't want all multicast traffic -
we use mac address filters to receive specific multicast groups, and the
multicast filter is programmed to accept all multicast traffic.

based on a diff from Brad
ok dlg@


# 1.6 10-Mar-2022 jmatthew

Invalidate the nic's rx descriptor cache when taking the interface up
or down, and turn off the global tx and rx enables when going down.
Without this, the nic can write to mbufs that were taken off the ring
when the interface was taken down, triggering mbuf cluster pool use
after free checks.

ok dlg@


# 1.5 08-Mar-2022 jmatthew

Handle rxrinfo ioctl.

ok dlg@


# 1.4 09-Oct-2021 jmatthew

No need to enable bus mastering, it's already done for us.

from Brad


Revision tags: OPENBSD_7_0_BASE
# 1.3 20-Sep-2021 jmatthew

wire up bpf correctly

ok dlg@ deraadt@


# 1.2 20-Sep-2021 jmatthew

pci_mapreg_map() will assign an address to the BAR if it doesn't have one
already, so we shouldn't refuse to attach in that case.

noticed by kevlo@ on arm64
ok dlg@ deraadt@


# 1.1 02-Sep-2021 mlarkin

aq(4) driver for Aquantia 1/2.5/5/10Gb/s PCIe ethernet adapters

Adds support for Aquantia AQC1xx family of PCIe ethernet adapters. This
driver supports 1Gbps through 10Gbps modes of operation based on the
hardware and media/switch capabilities.

The initial code was ported from NetBSD, with jmatthew@ finishing up
the Tx/Rx ring support and interrupt handler routine.

The driver only supports devices using firmware V2.

This diff enables aq(4) on riscv64 and amd64, the only platforms where
I have tested the driver, but it likely works on other architectures
as well.


# 1.14 31-Mar-2022 jmatthew

If we've created multiple queues, set up an RSS key and indirection table
to distribute received packets across the queues.

ok dlg@


# 1.13 30-Mar-2022 jmatthew

If enough MSI-X vectors are available, set up multiple tx and rx queues.
In multi-vector mode, the MSI-X vector number is the same as the irq number
on the nic, so use vector/irq 0 for link interrupts, then assign one to
each pair of rx and tx queues. We don't configure RSS yet, so packets
will only be received on the first queue, but they can be transmitted on
any queue.

ok dlg@


# 1.12 26-Mar-2022 jmatthew

Expand tx dma maps to allow packets up to the MTU limit to be transmitted.
Don't clear TPB_TX_BUF_EN when taking the interface down, as somehow that
causes transmission to fail when the interface comes up again if any large
packets had been sent.

Handle packets received into multiple rx buffers using the same approach as
ixl(4), with the addition that a receive error can be signaled on any of
the buffers rather than just the last one. Set the low water mark on the
rx ring so there are always enough buffers to receive the largest packet
supported by the interface, and fix the calculation of the data pointer
in rx buffers so there's actually MCLBYTES space available.

ok dlg@


# 1.11 20-Mar-2022 jmatthew

Enable interrupt moderation, targeting around 20k interrupts per second.
There are separate timers for rx and tx interrupts, so we can use longer
timeouts for tx since that doesn't affect packet processing latency.

ok dlg@


# 1.10 15-Mar-2022 jmatthew

Enable checksum offloads. The nic does all the work here, so we don't
need to calculate header offsets for it.

ok dlg@


# 1.9 13-Mar-2022 jmatthew

Enable vlan promisc and header stripping, and use vlan rx/tx offloads.
The vlan tx information takes up an extra slot on the tx ring, so this
affects the point at which we stop putting packets on the ring too.

ok dlg@


# 1.8 12-Mar-2022 jmatthew

Transmit segmented packets using multiple tx ring slots rather than
defragging them first.

ok dlg@


# 1.7 11-Mar-2022 jmatthew

Fix receive filter handling. Update the unicast mac address in the filter
when bringing the interface up, so it's possible to change it with
ifconfig. Rearrange multicast handling so IFF_ALLMULTI is set correctly
and multicast ranges don't trigger promisc mode. Perhaps most importantly,
set RPF_MCAST_FILTER_EN to 0 when we don't want all multicast traffic -
we use mac address filters to receive specific multicast groups, and the
multicast filter is programmed to accept all multicast traffic.

based on a diff from Brad
ok dlg@


# 1.6 10-Mar-2022 jmatthew

Invalidate the nic's rx descriptor cache when taking the interface up
or down, and turn off the global tx and rx enables when going down.
Without this, the nic can write to mbufs that were taken off the ring
when the interface was taken down, triggering mbuf cluster pool use
after free checks.

ok dlg@


# 1.5 08-Mar-2022 jmatthew

Handle rxrinfo ioctl.

ok dlg@


# 1.4 09-Oct-2021 jmatthew

No need to enable bus mastering, it's already done for us.

from Brad


Revision tags: OPENBSD_7_0_BASE
# 1.3 20-Sep-2021 jmatthew

wire up bpf correctly

ok dlg@ deraadt@


# 1.2 20-Sep-2021 jmatthew

pci_mapreg_map() will assign an address to the BAR if it doesn't have one
already, so we shouldn't refuse to attach in that case.

noticed by kevlo@ on arm64
ok dlg@ deraadt@


# 1.1 02-Sep-2021 mlarkin

aq(4) driver for Aquantia 1/2.5/5/10Gb/s PCIe ethernet adapters

Adds support for Aquantia AQC1xx family of PCIe ethernet adapters. This
driver supports 1Gbps through 10Gbps modes of operation based on the
hardware and media/switch capabilities.

The initial code was ported from NetBSD, with jmatthew@ finishing up
the Tx/Rx ring support and interrupt handler routine.

The driver only supports devices using firmware V2.

This diff enables aq(4) on riscv64 and amd64, the only platforms where
I have tested the driver, but it likely works on other architectures
as well.


# 1.13 30-Mar-2022 jmatthew

If enough MSI-X vectors are available, set up multiple tx and rx queues.
In multi-vector mode, the MSI-X vector number is the same as the irq number
on the nic, so use vector/irq 0 for link interrupts, then assign one to
each pair of rx and tx queues. We don't configure RSS yet, so packets
will only be received on the first queue, but they can be transmitted on
any queue.

ok dlg@


# 1.12 26-Mar-2022 jmatthew

Expand tx dma maps to allow packets up to the MTU limit to be transmitted.
Don't clear TPB_TX_BUF_EN when taking the interface down, as somehow that
causes transmission to fail when the interface comes up again if any large
packets had been sent.

Handle packets received into multiple rx buffers using the same approach as
ixl(4), with the addition that a receive error can be signaled on any of
the buffers rather than just the last one. Set the low water mark on the
rx ring so there are always enough buffers to receive the largest packet
supported by the interface, and fix the calculation of the data pointer
in rx buffers so there's actually MCLBYTES space available.

ok dlg@


# 1.11 20-Mar-2022 jmatthew

Enable interrupt moderation, targeting around 20k interrupts per second.
There are separate timers for rx and tx interrupts, so we can use longer
timeouts for tx since that doesn't affect packet processing latency.

ok dlg@


# 1.10 15-Mar-2022 jmatthew

Enable checksum offloads. The nic does all the work here, so we don't
need to calculate header offsets for it.

ok dlg@


# 1.9 13-Mar-2022 jmatthew

Enable vlan promisc and header stripping, and use vlan rx/tx offloads.
The vlan tx information takes up an extra slot on the tx ring, so this
affects the point at which we stop putting packets on the ring too.

ok dlg@


# 1.8 12-Mar-2022 jmatthew

Transmit segmented packets using multiple tx ring slots rather than
defragging them first.

ok dlg@


# 1.7 11-Mar-2022 jmatthew

Fix receive filter handling. Update the unicast mac address in the filter
when bringing the interface up, so it's possible to change it with
ifconfig. Rearrange multicast handling so IFF_ALLMULTI is set correctly
and multicast ranges don't trigger promisc mode. Perhaps most importantly,
set RPF_MCAST_FILTER_EN to 0 when we don't want all multicast traffic -
we use mac address filters to receive specific multicast groups, and the
multicast filter is programmed to accept all multicast traffic.

based on a diff from Brad
ok dlg@


# 1.6 10-Mar-2022 jmatthew

Invalidate the nic's rx descriptor cache when taking the interface up
or down, and turn off the global tx and rx enables when going down.
Without this, the nic can write to mbufs that were taken off the ring
when the interface was taken down, triggering mbuf cluster pool use
after free checks.

ok dlg@


# 1.5 08-Mar-2022 jmatthew

Handle rxrinfo ioctl.

ok dlg@


# 1.4 09-Oct-2021 jmatthew

No need to enable bus mastering, it's already done for us.

from Brad


Revision tags: OPENBSD_7_0_BASE
# 1.3 20-Sep-2021 jmatthew

wire up bpf correctly

ok dlg@ deraadt@


# 1.2 20-Sep-2021 jmatthew

pci_mapreg_map() will assign an address to the BAR if it doesn't have one
already, so we shouldn't refuse to attach in that case.

noticed by kevlo@ on arm64
ok dlg@ deraadt@


# 1.1 02-Sep-2021 mlarkin

aq(4) driver for Aquantia 1/2.5/5/10Gb/s PCIe ethernet adapters

Adds support for Aquantia AQC1xx family of PCIe ethernet adapters. This
driver supports 1Gbps through 10Gbps modes of operation based on the
hardware and media/switch capabilities.

The initial code was ported from NetBSD, with jmatthew@ finishing up
the Tx/Rx ring support and interrupt handler routine.

The driver only supports devices using firmware V2.

This diff enables aq(4) on riscv64 and amd64, the only platforms where
I have tested the driver, but it likely works on other architectures
as well.


# 1.12 26-Mar-2022 jmatthew

Expand tx dma maps to allow packets up to the MTU limit to be transmitted.
Don't clear TPB_TX_BUF_EN when taking the interface down, as somehow that
causes transmission to fail when the interface comes up again if any large
packets had been sent.

Handle packets received into multiple rx buffers using the same approach as
ixl(4), with the addition that a receive error can be signaled on any of
the buffers rather than just the last one. Set the low water mark on the
rx ring so there are always enough buffers to receive the largest packet
supported by the interface, and fix the calculation of the data pointer
in rx buffers so there's actually MCLBYTES space available.

ok dlg@


# 1.11 20-Mar-2022 jmatthew

Enable interrupt moderation, targeting around 20k interrupts per second.
There are separate timers for rx and tx interrupts, so we can use longer
timeouts for tx since that doesn't affect packet processing latency.

ok dlg@


# 1.10 15-Mar-2022 jmatthew

Enable checksum offloads. The nic does all the work here, so we don't
need to calculate header offsets for it.

ok dlg@


# 1.9 13-Mar-2022 jmatthew

Enable vlan promisc and header stripping, and use vlan rx/tx offloads.
The vlan tx information takes up an extra slot on the tx ring, so this
affects the point at which we stop putting packets on the ring too.

ok dlg@


# 1.8 12-Mar-2022 jmatthew

Transmit segmented packets using multiple tx ring slots rather than
defragging them first.

ok dlg@


# 1.7 11-Mar-2022 jmatthew

Fix receive filter handling. Update the unicast mac address in the filter
when bringing the interface up, so it's possible to change it with
ifconfig. Rearrange multicast handling so IFF_ALLMULTI is set correctly
and multicast ranges don't trigger promisc mode. Perhaps most importantly,
set RPF_MCAST_FILTER_EN to 0 when we don't want all multicast traffic -
we use mac address filters to receive specific multicast groups, and the
multicast filter is programmed to accept all multicast traffic.

based on a diff from Brad
ok dlg@


# 1.6 10-Mar-2022 jmatthew

Invalidate the nic's rx descriptor cache when taking the interface up
or down, and turn off the global tx and rx enables when going down.
Without this, the nic can write to mbufs that were taken off the ring
when the interface was taken down, triggering mbuf cluster pool use
after free checks.

ok dlg@


# 1.5 08-Mar-2022 jmatthew

Handle rxrinfo ioctl.

ok dlg@


# 1.4 09-Oct-2021 jmatthew

No need to enable bus mastering, it's already done for us.

from Brad


Revision tags: OPENBSD_7_0_BASE
# 1.3 20-Sep-2021 jmatthew

wire up bpf correctly

ok dlg@ deraadt@


# 1.2 20-Sep-2021 jmatthew

pci_mapreg_map() will assign an address to the BAR if it doesn't have one
already, so we shouldn't refuse to attach in that case.

noticed by kevlo@ on arm64
ok dlg@ deraadt@


# 1.1 02-Sep-2021 mlarkin

aq(4) driver for Aquantia 1/2.5/5/10Gb/s PCIe ethernet adapters

Adds support for Aquantia AQC1xx family of PCIe ethernet adapters. This
driver supports 1Gbps through 10Gbps modes of operation based on the
hardware and media/switch capabilities.

The initial code was ported from NetBSD, with jmatthew@ finishing up
the Tx/Rx ring support and interrupt handler routine.

The driver only supports devices using firmware V2.

This diff enables aq(4) on riscv64 and amd64, the only platforms where
I have tested the driver, but it likely works on other architectures
as well.


# 1.11 20-Mar-2022 jmatthew

Enable interrupt moderation, targeting around 20k interrupts per second.
There are separate timers for rx and tx interrupts, so we can use longer
timeouts for tx since that doesn't affect packet processing latency.

ok dlg@


# 1.10 15-Mar-2022 jmatthew

Enable checksum offloads. The nic does all the work here, so we don't
need to calculate header offsets for it.

ok dlg@


# 1.9 13-Mar-2022 jmatthew

Enable vlan promisc and header stripping, and use vlan rx/tx offloads.
The vlan tx information takes up an extra slot on the tx ring, so this
affects the point at which we stop putting packets on the ring too.

ok dlg@


# 1.8 12-Mar-2022 jmatthew

Transmit segmented packets using multiple tx ring slots rather than
defragging them first.

ok dlg@


# 1.7 11-Mar-2022 jmatthew

Fix receive filter handling. Update the unicast mac address in the filter
when bringing the interface up, so it's possible to change it with
ifconfig. Rearrange multicast handling so IFF_ALLMULTI is set correctly
and multicast ranges don't trigger promisc mode. Perhaps most importantly,
set RPF_MCAST_FILTER_EN to 0 when we don't want all multicast traffic -
we use mac address filters to receive specific multicast groups, and the
multicast filter is programmed to accept all multicast traffic.

based on a diff from Brad
ok dlg@


# 1.6 10-Mar-2022 jmatthew

Invalidate the nic's rx descriptor cache when taking the interface up
or down, and turn off the global tx and rx enables when going down.
Without this, the nic can write to mbufs that were taken off the ring
when the interface was taken down, triggering mbuf cluster pool use
after free checks.

ok dlg@


# 1.5 08-Mar-2022 jmatthew

Handle rxrinfo ioctl.

ok dlg@


# 1.4 09-Oct-2021 jmatthew

No need to enable bus mastering, it's already done for us.

from Brad


Revision tags: OPENBSD_7_0_BASE
# 1.3 20-Sep-2021 jmatthew

wire up bpf correctly

ok dlg@ deraadt@


# 1.2 20-Sep-2021 jmatthew

pci_mapreg_map() will assign an address to the BAR if it doesn't have one
already, so we shouldn't refuse to attach in that case.

noticed by kevlo@ on arm64
ok dlg@ deraadt@


# 1.1 02-Sep-2021 mlarkin

aq(4) driver for Aquantia 1/2.5/5/10Gb/s PCIe ethernet adapters

Adds support for Aquantia AQC1xx family of PCIe ethernet adapters. This
driver supports 1Gbps through 10Gbps modes of operation based on the
hardware and media/switch capabilities.

The initial code was ported from NetBSD, with jmatthew@ finishing up
the Tx/Rx ring support and interrupt handler routine.

The driver only supports devices using firmware V2.

This diff enables aq(4) on riscv64 and amd64, the only platforms where
I have tested the driver, but it likely works on other architectures
as well.


# 1.10 15-Mar-2022 jmatthew

Enable checksum offloads. The nic does all the work here, so we don't
need to calculate header offsets for it.

ok dlg@


# 1.9 13-Mar-2022 jmatthew

Enable vlan promisc and header stripping, and use vlan rx/tx offloads.
The vlan tx information takes up an extra slot on the tx ring, so this
affects the point at which we stop putting packets on the ring too.

ok dlg@


# 1.8 12-Mar-2022 jmatthew

Transmit segmented packets using multiple tx ring slots rather than
defragging them first.

ok dlg@


# 1.7 11-Mar-2022 jmatthew

Fix receive filter handling. Update the unicast mac address in the filter
when bringing the interface up, so it's possible to change it with
ifconfig. Rearrange multicast handling so IFF_ALLMULTI is set correctly
and multicast ranges don't trigger promisc mode. Perhaps most importantly,
set RPF_MCAST_FILTER_EN to 0 when we don't want all multicast traffic -
we use mac address filters to receive specific multicast groups, and the
multicast filter is programmed to accept all multicast traffic.

based on a diff from Brad
ok dlg@


# 1.6 10-Mar-2022 jmatthew

Invalidate the nic's rx descriptor cache when taking the interface up
or down, and turn off the global tx and rx enables when going down.
Without this, the nic can write to mbufs that were taken off the ring
when the interface was taken down, triggering mbuf cluster pool use
after free checks.

ok dlg@


# 1.5 08-Mar-2022 jmatthew

Handle rxrinfo ioctl.

ok dlg@


# 1.4 09-Oct-2021 jmatthew

No need to enable bus mastering, it's already done for us.

from Brad


Revision tags: OPENBSD_7_0_BASE
# 1.3 20-Sep-2021 jmatthew

wire up bpf correctly

ok dlg@ deraadt@


# 1.2 20-Sep-2021 jmatthew

pci_mapreg_map() will assign an address to the BAR if it doesn't have one
already, so we shouldn't refuse to attach in that case.

noticed by kevlo@ on arm64
ok dlg@ deraadt@


# 1.1 02-Sep-2021 mlarkin

aq(4) driver for Aquantia 1/2.5/5/10Gb/s PCIe ethernet adapters

Adds support for Aquantia AQC1xx family of PCIe ethernet adapters. This
driver supports 1Gbps through 10Gbps modes of operation based on the
hardware and media/switch capabilities.

The initial code was ported from NetBSD, with jmatthew@ finishing up
the Tx/Rx ring support and interrupt handler routine.

The driver only supports devices using firmware V2.

This diff enables aq(4) on riscv64 and amd64, the only platforms where
I have tested the driver, but it likely works on other architectures
as well.


# 1.9 13-Mar-2022 jmatthew

Enable vlan promisc and header stripping, and use vlan rx/tx offloads.
The vlan tx information takes up an extra slot on the tx ring, so this
affects the point at which we stop putting packets on the ring too.

ok dlg@


# 1.8 12-Mar-2022 jmatthew

Transmit segmented packets using multiple tx ring slots rather than
defragging them first.

ok dlg@


# 1.7 11-Mar-2022 jmatthew

Fix receive filter handling. Update the unicast mac address in the filter
when bringing the interface up, so it's possible to change it with
ifconfig. Rearrange multicast handling so IFF_ALLMULTI is set correctly
and multicast ranges don't trigger promisc mode. Perhaps most importantly,
set RPF_MCAST_FILTER_EN to 0 when we don't want all multicast traffic -
we use mac address filters to receive specific multicast groups, and the
multicast filter is programmed to accept all multicast traffic.

based on a diff from Brad
ok dlg@


# 1.6 10-Mar-2022 jmatthew

Invalidate the nic's rx descriptor cache when taking the interface up
or down, and turn off the global tx and rx enables when going down.
Without this, the nic can write to mbufs that were taken off the ring
when the interface was taken down, triggering mbuf cluster pool use
after free checks.

ok dlg@


# 1.5 08-Mar-2022 jmatthew

Handle rxrinfo ioctl.

ok dlg@


# 1.4 09-Oct-2021 jmatthew

No need to enable bus mastering, it's already done for us.

from Brad


Revision tags: OPENBSD_7_0_BASE
# 1.3 20-Sep-2021 jmatthew

wire up bpf correctly

ok dlg@ deraadt@


# 1.2 20-Sep-2021 jmatthew

pci_mapreg_map() will assign an address to the BAR if it doesn't have one
already, so we shouldn't refuse to attach in that case.

noticed by kevlo@ on arm64
ok dlg@ deraadt@


# 1.1 02-Sep-2021 mlarkin

aq(4) driver for Aquantia 1/2.5/5/10Gb/s PCIe ethernet adapters

Adds support for Aquantia AQC1xx family of PCIe ethernet adapters. This
driver supports 1Gbps through 10Gbps modes of operation based on the
hardware and media/switch capabilities.

The initial code was ported from NetBSD, with jmatthew@ finishing up
the Tx/Rx ring support and interrupt handler routine.

The driver only supports devices using firmware V2.

This diff enables aq(4) on riscv64 and amd64, the only platforms where
I have tested the driver, but it likely works on other architectures
as well.


# 1.7 11-Mar-2022 jmatthew

Fix receive filter handling. Update the unicast mac address in the filter
when bringing the interface up, so it's possible to change it with
ifconfig. Rearrange multicast handling so IFF_ALLMULTI is set correctly
and multicast ranges don't trigger promisc mode. Perhaps most importantly,
set RPF_MCAST_FILTER_EN to 0 when we don't want all multicast traffic -
we use mac address filters to receive specific multicast groups, and the
multicast filter is programmed to accept all multicast traffic.

based on a diff from Brad
ok dlg@


# 1.6 10-Mar-2022 jmatthew

Invalidate the nic's rx descriptor cache when taking the interface up
or down, and turn off the global tx and rx enables when going down.
Without this, the nic can write to mbufs that were taken off the ring
when the interface was taken down, triggering mbuf cluster pool use
after free checks.

ok dlg@


# 1.5 08-Mar-2022 jmatthew

Handle rxrinfo ioctl.

ok dlg@


# 1.4 09-Oct-2021 jmatthew

No need to enable bus mastering, it's already done for us.

from Brad


Revision tags: OPENBSD_7_0_BASE
# 1.3 20-Sep-2021 jmatthew

wire up bpf correctly

ok dlg@ deraadt@


# 1.2 20-Sep-2021 jmatthew

pci_mapreg_map() will assign an address to the BAR if it doesn't have one
already, so we shouldn't refuse to attach in that case.

noticed by kevlo@ on arm64
ok dlg@ deraadt@


# 1.1 02-Sep-2021 mlarkin

aq(4) driver for Aquantia 1/2.5/5/10Gb/s PCIe ethernet adapters

Adds support for Aquantia AQC1xx family of PCIe ethernet adapters. This
driver supports 1Gbps through 10Gbps modes of operation based on the
hardware and media/switch capabilities.

The initial code was ported from NetBSD, with jmatthew@ finishing up
the Tx/Rx ring support and interrupt handler routine.

The driver only supports devices using firmware V2.

This diff enables aq(4) on riscv64 and amd64, the only platforms where
I have tested the driver, but it likely works on other architectures
as well.


# 1.6 10-Mar-2022 jmatthew

Invalidate the nic's rx descriptor cache when taking the interface up
or down, and turn off the global tx and rx enables when going down.
Without this, the nic can write to mbufs that were taken off the ring
when the interface was taken down, triggering mbuf cluster pool use
after free checks.

ok dlg@


# 1.5 08-Mar-2022 jmatthew

Handle rxrinfo ioctl.

ok dlg@


# 1.4 09-Oct-2021 jmatthew

No need to enable bus mastering, it's already done for us.

from Brad


Revision tags: OPENBSD_7_0_BASE
# 1.3 20-Sep-2021 jmatthew

wire up bpf correctly

ok dlg@ deraadt@


# 1.2 20-Sep-2021 jmatthew

pci_mapreg_map() will assign an address to the BAR if it doesn't have one
already, so we shouldn't refuse to attach in that case.

noticed by kevlo@ on arm64
ok dlg@ deraadt@


# 1.1 02-Sep-2021 mlarkin

aq(4) driver for Aquantia 1/2.5/5/10Gb/s PCIe ethernet adapters

Adds support for Aquantia AQC1xx family of PCIe ethernet adapters. This
driver supports 1Gbps through 10Gbps modes of operation based on the
hardware and media/switch capabilities.

The initial code was ported from NetBSD, with jmatthew@ finishing up
the Tx/Rx ring support and interrupt handler routine.

The driver only supports devices using firmware V2.

This diff enables aq(4) on riscv64 and amd64, the only platforms where
I have tested the driver, but it likely works on other architectures
as well.


# 1.5 08-Mar-2022 jmatthew

Handle rxrinfo ioctl.

ok dlg@


# 1.4 09-Oct-2021 jmatthew

No need to enable bus mastering, it's already done for us.

from Brad


Revision tags: OPENBSD_7_0_BASE
# 1.3 20-Sep-2021 jmatthew

wire up bpf correctly

ok dlg@ deraadt@


# 1.2 20-Sep-2021 jmatthew

pci_mapreg_map() will assign an address to the BAR if it doesn't have one
already, so we shouldn't refuse to attach in that case.

noticed by kevlo@ on arm64
ok dlg@ deraadt@


# 1.1 02-Sep-2021 mlarkin

aq(4) driver for Aquantia 1/2.5/5/10Gb/s PCIe ethernet adapters

Adds support for Aquantia AQC1xx family of PCIe ethernet adapters. This
driver supports 1Gbps through 10Gbps modes of operation based on the
hardware and media/switch capabilities.

The initial code was ported from NetBSD, with jmatthew@ finishing up
the Tx/Rx ring support and interrupt handler routine.

The driver only supports devices using firmware V2.

This diff enables aq(4) on riscv64 and amd64, the only platforms where
I have tested the driver, but it likely works on other architectures
as well.


# 1.4 09-Oct-2021 jmatthew

No need to enable bus mastering, it's already done for us.

from Brad


Revision tags: OPENBSD_7_0_BASE
# 1.3 20-Sep-2021 jmatthew

wire up bpf correctly

ok dlg@ deraadt@


# 1.2 20-Sep-2021 jmatthew

pci_mapreg_map() will assign an address to the BAR if it doesn't have one
already, so we shouldn't refuse to attach in that case.

noticed by kevlo@ on arm64
ok dlg@ deraadt@


# 1.1 02-Sep-2021 mlarkin

aq(4) driver for Aquantia 1/2.5/5/10Gb/s PCIe ethernet adapters

Adds support for Aquantia AQC1xx family of PCIe ethernet adapters. This
driver supports 1Gbps through 10Gbps modes of operation based on the
hardware and media/switch capabilities.

The initial code was ported from NetBSD, with jmatthew@ finishing up
the Tx/Rx ring support and interrupt handler routine.

The driver only supports devices using firmware V2.

This diff enables aq(4) on riscv64 and amd64, the only platforms where
I have tested the driver, but it likely works on other architectures
as well.


# 1.3 20-Sep-2021 jmatthew

wire up bpf correctly

ok dlg@ deraadt@


# 1.2 20-Sep-2021 jmatthew

pci_mapreg_map() will assign an address to the BAR if it doesn't have one
already, so we shouldn't refuse to attach in that case.

noticed by kevlo@ on arm64
ok dlg@ deraadt@


# 1.1 02-Sep-2021 mlarkin

aq(4) driver for Aquantia 1/2.5/5/10Gb/s PCIe ethernet adapters

Adds support for Aquantia AQC1xx family of PCIe ethernet adapters. This
driver supports 1Gbps through 10Gbps modes of operation based on the
hardware and media/switch capabilities.

The initial code was ported from NetBSD, with jmatthew@ finishing up
the Tx/Rx ring support and interrupt handler routine.

The driver only supports devices using firmware V2.

This diff enables aq(4) on riscv64 and amd64, the only platforms where
I have tested the driver, but it likely works on other architectures
as well.


# 1.1 02-Sep-2021 mlarkin

aq(4) driver for Aquantia 1/2.5/5/10Gb/s PCIe ethernet adapters

Adds support for Aquantia AQC1xx family of PCIe ethernet adapters. This
driver supports 1Gbps through 10Gbps modes of operation based on the
hardware and media/switch capabilities.

The initial code was ported from NetBSD, with jmatthew@ finishing up
the Tx/Rx ring support and interrupt handler routine.

The driver only supports devices using firmware V2.

This diff enables aq(4) on riscv64 and amd64, the only platforms where
I have tested the driver, but it likely works on other architectures
as well.