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

remove unneeded includes; ok miod@


# 1.24 21-May-2024 bluhm

Make igc(4) and ix(4) struct names unique.

In ddb show struct gets confused if the same struct name exists
twice. Add a prefix to tx_ring and rx_ring in drivers.

OK miod@ jan@


# 1.23 07-May-2024 jan

Additional check for TSO packets with 0 MSS.

Tested by bluhm

ok bluhm@


# 1.22 06-May-2024 dlg

expose hardware counters as kstats.

igc(4) counters are read to clear like em(4) counters, so this code
looks very much like em(4) but with less quirks so far.

ok bluhm@ bket@


# 1.21 04-May-2024 mbuhl

Add TSO capabilites.
Comments, suggestions and testing from bket@, jan@, and bluhm@


# 1.20 12-Apr-2024 jan

remove useless includes of ip.h and ip6.h

ok bluhm


# 1.19 25-Mar-2024 mbuhl

Add the VLAN_HWTAGGING capability. Big thanks to bket@ for testing,
rebasing, refactoring, and addressing feedback for this diff.
ok bluhm@, jan@


Revision tags: OPENBSD_7_5_BASE
# 1.18 23-Feb-2024 kevlo

- Add support for reporting flow control status.
- Add missing igc_check_for_link() call; from Masanobu SAITOH via NetBSD.

"Fine" deraadt@

ok jan@


# 1.17 14-Feb-2024 bluhm

Check IP length in ether_extract_headers().

For LRO with ix(4) it is necessary to detect ethernet padding.
Extract ip_len and ip6_plen from the mbuf and provide it to the
drivers.
Add extended sanitity checks, like IP packet is shorter than TCP
header. This prevents offloading to network hardware with bougus
packets.
Also iphlen of extracted headers contains header length for IPv4
and IPv6, to make code in drivers simpler.

OK mglocker@


# 1.16 13-Feb-2024 bluhm

Analyse header layout in ether_extract_headers().

Several drivers need IPv4 header length and TCP offset for checksum
offload, TSO and LRO. Accessing these fields directly caused crashes
on sparc64 due to misaligned access. It cannot be guaranteed that
IP and TCP header is 4 byte aligned in driver level. Also gcc 4.2.1
assumes that bit fields can be accessed with 32 bit load instructions.

Use memcpy() in ether_extract_headers() to get the bits from IPv4
and TCP header and store the header length in struct ether_extracted.
From there network drivers can esily use it without caring about
alignment and bit shift. Do some sanity checks with the length
values to prevent that invalid values from evil packets get stored
into hardware registers. If check fails, clear the pointer to the
header to hide it from the driver. Add debug prints that help to
figure out the reason for bad packets and provide information when
debugging drivers.

OK mglocker@


# 1.15 23-Jan-2024 kevlo

Change default duplex setting and simplify the setup of srrctl.BSIZEPKT.

During media selection through ifconfig one might not specify the duplex
setting through the mediaopt flag. In that case the igc(4) would default
to full-duplex. The problem with this approach is that em(4) defaults to
half-duplex. Because of that if one connects both NICs and sets media to
e.g. 100baseTX on both of them no carrier will be found.
Fix that by matching igc(4) behaviour with what em(4) does.

Adapted from FreeBSD commits 3b8d04f845b416d29a258658b8a48d1afb4a2e81 and
0eb8cd1de26849cbaefaf3bc59aa9612fa0dfa52 respectively.

ok mbuhl@


# 1.14 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.13 28-Apr-2023 bluhm

Remove error handling around mallocarray(9). I cannot fail when
called with M_WAITOK.
OK kevlo@


Revision tags: OPENBSD_7_3_BASE
# 1.12 09-Mar-2023 chris

Fix comment to reflect the disabled status of Energy Efficient Ethernet.

Intel just disabled EEE for 1Gbps and 2.5Gbps modes on both i225 and i226
chips due to bugs. We already had it this way.

ok patrick@ kevlo@


# 1.11 09-Feb-2023 naddy

consolidate mbuf header parsing on device driver layer

em(4) ok jan@, bluhm@
igc(4) tested by weerd@


# 1.10 11-Nov-2022 mbuhl

Due to checksum offloading one more element could be written to the ring
than there is space available.
ok dlg


Revision tags: OPENBSD_7_2_BASE
# 1.9 02-Jun-2022 mbuhl

Implement and enable IPv4, TCP, and UDP checksum offloading for igc.

ok kevlo@


# 1.8 11-May-2022 kevlo

Use hardware routine for PHY reset and always accept the PHY that's present.

The previously used software reset routine wasn't sufficient to reset the PHY
if the bootloader hadn't left the device in an initialized state.
From FreeBSD.

Bug reported and the fix tested by daniel@


# 1.7 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.6 09-Jan-2022 patrick

Simplify igc_rxrinfo() to improve consistency and appease Coverity.

CID 1510483

ok kevlo@


# 1.5 22-Nov-2021 jsg

avoid uninitialised variable use in igc(4)

read icr reg before testing bit in result
add missing block in rxeof from ix

ok kevlo@ patrick@


# 1.4 31-Oct-2021 patrick

Disable both TCP/UDP checksum offloading and VLAN HW tag offloading for now,
as we currently configure neither in the transmit code path.

Found by sf@


# 1.3 31-Oct-2021 patrick

Implement transmit and transmit completion path.


# 1.2 31-Oct-2021 patrick

Move the fill and the tail pointer change to a later point, to make sure
that the RDT is written, and that it is written not too early. Doing it
before writing IGC_RXDCTL definitely doesn't work.

The tail pointer needs to be set to the next empty slot, so it has to be
"last desc filled + 1".

Make sure sure that the rss mapping does not happen in the middle of the
RX checksum block, and that it happens only if nqueues > 1. Also disable
storing bad packets.

With this, igc(4) receives packets just fine.

ok kevlo@


# 1.1 31-Oct-2021 patrick

Add igc(4), a driver for the Intel 2.5Gb Ethernet controllers.

Ported by kevlo@
ok jmatthew@


# 1.24 21-May-2024 bluhm

Make igc(4) and ix(4) struct names unique.

In ddb show struct gets confused if the same struct name exists
twice. Add a prefix to tx_ring and rx_ring in drivers.

OK miod@ jan@


# 1.23 07-May-2024 jan

Additional check for TSO packets with 0 MSS.

Tested by bluhm

ok bluhm@


# 1.22 06-May-2024 dlg

expose hardware counters as kstats.

igc(4) counters are read to clear like em(4) counters, so this code
looks very much like em(4) but with less quirks so far.

ok bluhm@ bket@


# 1.21 04-May-2024 mbuhl

Add TSO capabilites.
Comments, suggestions and testing from bket@, jan@, and bluhm@


# 1.20 12-Apr-2024 jan

remove useless includes of ip.h and ip6.h

ok bluhm


# 1.19 25-Mar-2024 mbuhl

Add the VLAN_HWTAGGING capability. Big thanks to bket@ for testing,
rebasing, refactoring, and addressing feedback for this diff.
ok bluhm@, jan@


Revision tags: OPENBSD_7_5_BASE
# 1.18 23-Feb-2024 kevlo

- Add support for reporting flow control status.
- Add missing igc_check_for_link() call; from Masanobu SAITOH via NetBSD.

"Fine" deraadt@

ok jan@


# 1.17 14-Feb-2024 bluhm

Check IP length in ether_extract_headers().

For LRO with ix(4) it is necessary to detect ethernet padding.
Extract ip_len and ip6_plen from the mbuf and provide it to the
drivers.
Add extended sanitity checks, like IP packet is shorter than TCP
header. This prevents offloading to network hardware with bougus
packets.
Also iphlen of extracted headers contains header length for IPv4
and IPv6, to make code in drivers simpler.

OK mglocker@


# 1.16 13-Feb-2024 bluhm

Analyse header layout in ether_extract_headers().

Several drivers need IPv4 header length and TCP offset for checksum
offload, TSO and LRO. Accessing these fields directly caused crashes
on sparc64 due to misaligned access. It cannot be guaranteed that
IP and TCP header is 4 byte aligned in driver level. Also gcc 4.2.1
assumes that bit fields can be accessed with 32 bit load instructions.

Use memcpy() in ether_extract_headers() to get the bits from IPv4
and TCP header and store the header length in struct ether_extracted.
From there network drivers can esily use it without caring about
alignment and bit shift. Do some sanity checks with the length
values to prevent that invalid values from evil packets get stored
into hardware registers. If check fails, clear the pointer to the
header to hide it from the driver. Add debug prints that help to
figure out the reason for bad packets and provide information when
debugging drivers.

OK mglocker@


# 1.15 23-Jan-2024 kevlo

Change default duplex setting and simplify the setup of srrctl.BSIZEPKT.

During media selection through ifconfig one might not specify the duplex
setting through the mediaopt flag. In that case the igc(4) would default
to full-duplex. The problem with this approach is that em(4) defaults to
half-duplex. Because of that if one connects both NICs and sets media to
e.g. 100baseTX on both of them no carrier will be found.
Fix that by matching igc(4) behaviour with what em(4) does.

Adapted from FreeBSD commits 3b8d04f845b416d29a258658b8a48d1afb4a2e81 and
0eb8cd1de26849cbaefaf3bc59aa9612fa0dfa52 respectively.

ok mbuhl@


# 1.14 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.13 28-Apr-2023 bluhm

Remove error handling around mallocarray(9). I cannot fail when
called with M_WAITOK.
OK kevlo@


Revision tags: OPENBSD_7_3_BASE
# 1.12 09-Mar-2023 chris

Fix comment to reflect the disabled status of Energy Efficient Ethernet.

Intel just disabled EEE for 1Gbps and 2.5Gbps modes on both i225 and i226
chips due to bugs. We already had it this way.

ok patrick@ kevlo@


# 1.11 09-Feb-2023 naddy

consolidate mbuf header parsing on device driver layer

em(4) ok jan@, bluhm@
igc(4) tested by weerd@


# 1.10 11-Nov-2022 mbuhl

Due to checksum offloading one more element could be written to the ring
than there is space available.
ok dlg


Revision tags: OPENBSD_7_2_BASE
# 1.9 02-Jun-2022 mbuhl

Implement and enable IPv4, TCP, and UDP checksum offloading for igc.

ok kevlo@


# 1.8 11-May-2022 kevlo

Use hardware routine for PHY reset and always accept the PHY that's present.

The previously used software reset routine wasn't sufficient to reset the PHY
if the bootloader hadn't left the device in an initialized state.
From FreeBSD.

Bug reported and the fix tested by daniel@


# 1.7 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.6 09-Jan-2022 patrick

Simplify igc_rxrinfo() to improve consistency and appease Coverity.

CID 1510483

ok kevlo@


# 1.5 22-Nov-2021 jsg

avoid uninitialised variable use in igc(4)

read icr reg before testing bit in result
add missing block in rxeof from ix

ok kevlo@ patrick@


# 1.4 31-Oct-2021 patrick

Disable both TCP/UDP checksum offloading and VLAN HW tag offloading for now,
as we currently configure neither in the transmit code path.

Found by sf@


# 1.3 31-Oct-2021 patrick

Implement transmit and transmit completion path.


# 1.2 31-Oct-2021 patrick

Move the fill and the tail pointer change to a later point, to make sure
that the RDT is written, and that it is written not too early. Doing it
before writing IGC_RXDCTL definitely doesn't work.

The tail pointer needs to be set to the next empty slot, so it has to be
"last desc filled + 1".

Make sure sure that the rss mapping does not happen in the middle of the
RX checksum block, and that it happens only if nqueues > 1. Also disable
storing bad packets.

With this, igc(4) receives packets just fine.

ok kevlo@


# 1.1 31-Oct-2021 patrick

Add igc(4), a driver for the Intel 2.5Gb Ethernet controllers.

Ported by kevlo@
ok jmatthew@


# 1.23 07-May-2024 jan

Additional check for TSO packets with 0 MSS.

Tested by bluhm

ok bluhm@


# 1.22 06-May-2024 dlg

expose hardware counters as kstats.

igc(4) counters are read to clear like em(4) counters, so this code
looks very much like em(4) but with less quirks so far.

ok bluhm@ bket@


# 1.21 04-May-2024 mbuhl

Add TSO capabilites.
Comments, suggestions and testing from bket@, jan@, and bluhm@


# 1.20 12-Apr-2024 jan

remove useless includes of ip.h and ip6.h

ok bluhm


# 1.19 25-Mar-2024 mbuhl

Add the VLAN_HWTAGGING capability. Big thanks to bket@ for testing,
rebasing, refactoring, and addressing feedback for this diff.
ok bluhm@, jan@


Revision tags: OPENBSD_7_5_BASE
# 1.18 23-Feb-2024 kevlo

- Add support for reporting flow control status.
- Add missing igc_check_for_link() call; from Masanobu SAITOH via NetBSD.

"Fine" deraadt@

ok jan@


# 1.17 14-Feb-2024 bluhm

Check IP length in ether_extract_headers().

For LRO with ix(4) it is necessary to detect ethernet padding.
Extract ip_len and ip6_plen from the mbuf and provide it to the
drivers.
Add extended sanitity checks, like IP packet is shorter than TCP
header. This prevents offloading to network hardware with bougus
packets.
Also iphlen of extracted headers contains header length for IPv4
and IPv6, to make code in drivers simpler.

OK mglocker@


# 1.16 13-Feb-2024 bluhm

Analyse header layout in ether_extract_headers().

Several drivers need IPv4 header length and TCP offset for checksum
offload, TSO and LRO. Accessing these fields directly caused crashes
on sparc64 due to misaligned access. It cannot be guaranteed that
IP and TCP header is 4 byte aligned in driver level. Also gcc 4.2.1
assumes that bit fields can be accessed with 32 bit load instructions.

Use memcpy() in ether_extract_headers() to get the bits from IPv4
and TCP header and store the header length in struct ether_extracted.
From there network drivers can esily use it without caring about
alignment and bit shift. Do some sanity checks with the length
values to prevent that invalid values from evil packets get stored
into hardware registers. If check fails, clear the pointer to the
header to hide it from the driver. Add debug prints that help to
figure out the reason for bad packets and provide information when
debugging drivers.

OK mglocker@


# 1.15 23-Jan-2024 kevlo

Change default duplex setting and simplify the setup of srrctl.BSIZEPKT.

During media selection through ifconfig one might not specify the duplex
setting through the mediaopt flag. In that case the igc(4) would default
to full-duplex. The problem with this approach is that em(4) defaults to
half-duplex. Because of that if one connects both NICs and sets media to
e.g. 100baseTX on both of them no carrier will be found.
Fix that by matching igc(4) behaviour with what em(4) does.

Adapted from FreeBSD commits 3b8d04f845b416d29a258658b8a48d1afb4a2e81 and
0eb8cd1de26849cbaefaf3bc59aa9612fa0dfa52 respectively.

ok mbuhl@


# 1.14 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.13 28-Apr-2023 bluhm

Remove error handling around mallocarray(9). I cannot fail when
called with M_WAITOK.
OK kevlo@


Revision tags: OPENBSD_7_3_BASE
# 1.12 09-Mar-2023 chris

Fix comment to reflect the disabled status of Energy Efficient Ethernet.

Intel just disabled EEE for 1Gbps and 2.5Gbps modes on both i225 and i226
chips due to bugs. We already had it this way.

ok patrick@ kevlo@


# 1.11 09-Feb-2023 naddy

consolidate mbuf header parsing on device driver layer

em(4) ok jan@, bluhm@
igc(4) tested by weerd@


# 1.10 11-Nov-2022 mbuhl

Due to checksum offloading one more element could be written to the ring
than there is space available.
ok dlg


Revision tags: OPENBSD_7_2_BASE
# 1.9 02-Jun-2022 mbuhl

Implement and enable IPv4, TCP, and UDP checksum offloading for igc.

ok kevlo@


# 1.8 11-May-2022 kevlo

Use hardware routine for PHY reset and always accept the PHY that's present.

The previously used software reset routine wasn't sufficient to reset the PHY
if the bootloader hadn't left the device in an initialized state.
From FreeBSD.

Bug reported and the fix tested by daniel@


# 1.7 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.6 09-Jan-2022 patrick

Simplify igc_rxrinfo() to improve consistency and appease Coverity.

CID 1510483

ok kevlo@


# 1.5 22-Nov-2021 jsg

avoid uninitialised variable use in igc(4)

read icr reg before testing bit in result
add missing block in rxeof from ix

ok kevlo@ patrick@


# 1.4 31-Oct-2021 patrick

Disable both TCP/UDP checksum offloading and VLAN HW tag offloading for now,
as we currently configure neither in the transmit code path.

Found by sf@


# 1.3 31-Oct-2021 patrick

Implement transmit and transmit completion path.


# 1.2 31-Oct-2021 patrick

Move the fill and the tail pointer change to a later point, to make sure
that the RDT is written, and that it is written not too early. Doing it
before writing IGC_RXDCTL definitely doesn't work.

The tail pointer needs to be set to the next empty slot, so it has to be
"last desc filled + 1".

Make sure sure that the rss mapping does not happen in the middle of the
RX checksum block, and that it happens only if nqueues > 1. Also disable
storing bad packets.

With this, igc(4) receives packets just fine.

ok kevlo@


# 1.1 31-Oct-2021 patrick

Add igc(4), a driver for the Intel 2.5Gb Ethernet controllers.

Ported by kevlo@
ok jmatthew@


# 1.23 07-May-2024 jan

Additional check for TSO packets with 0 MSS.

Tested by bluhm

ok bluhm@


# 1.22 06-May-2024 dlg

expose hardware counters as kstats.

igc(4) counters are read to clear like em(4) counters, so this code
looks very much like em(4) but with less quirks so far.

ok bluhm@ bket@


# 1.21 04-May-2024 mbuhl

Add TSO capabilites.
Comments, suggestions and testing from bket@, jan@, and bluhm@


# 1.20 12-Apr-2024 jan

remove useless includes of ip.h and ip6.h

ok bluhm


# 1.19 25-Mar-2024 mbuhl

Add the VLAN_HWTAGGING capability. Big thanks to bket@ for testing,
rebasing, refactoring, and addressing feedback for this diff.
ok bluhm@, jan@


Revision tags: OPENBSD_7_5_BASE
# 1.18 23-Feb-2024 kevlo

- Add support for reporting flow control status.
- Add missing igc_check_for_link() call; from Masanobu SAITOH via NetBSD.

"Fine" deraadt@

ok jan@


# 1.17 14-Feb-2024 bluhm

Check IP length in ether_extract_headers().

For LRO with ix(4) it is necessary to detect ethernet padding.
Extract ip_len and ip6_plen from the mbuf and provide it to the
drivers.
Add extended sanitity checks, like IP packet is shorter than TCP
header. This prevents offloading to network hardware with bougus
packets.
Also iphlen of extracted headers contains header length for IPv4
and IPv6, to make code in drivers simpler.

OK mglocker@


# 1.16 13-Feb-2024 bluhm

Analyse header layout in ether_extract_headers().

Several drivers need IPv4 header length and TCP offset for checksum
offload, TSO and LRO. Accessing these fields directly caused crashes
on sparc64 due to misaligned access. It cannot be guaranteed that
IP and TCP header is 4 byte aligned in driver level. Also gcc 4.2.1
assumes that bit fields can be accessed with 32 bit load instructions.

Use memcpy() in ether_extract_headers() to get the bits from IPv4
and TCP header and store the header length in struct ether_extracted.
From there network drivers can esily use it without caring about
alignment and bit shift. Do some sanity checks with the length
values to prevent that invalid values from evil packets get stored
into hardware registers. If check fails, clear the pointer to the
header to hide it from the driver. Add debug prints that help to
figure out the reason for bad packets and provide information when
debugging drivers.

OK mglocker@


# 1.15 23-Jan-2024 kevlo

Change default duplex setting and simplify the setup of srrctl.BSIZEPKT.

During media selection through ifconfig one might not specify the duplex
setting through the mediaopt flag. In that case the igc(4) would default
to full-duplex. The problem with this approach is that em(4) defaults to
half-duplex. Because of that if one connects both NICs and sets media to
e.g. 100baseTX on both of them no carrier will be found.
Fix that by matching igc(4) behaviour with what em(4) does.

Adapted from FreeBSD commits 3b8d04f845b416d29a258658b8a48d1afb4a2e81 and
0eb8cd1de26849cbaefaf3bc59aa9612fa0dfa52 respectively.

ok mbuhl@


# 1.14 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.13 28-Apr-2023 bluhm

Remove error handling around mallocarray(9). I cannot fail when
called with M_WAITOK.
OK kevlo@


Revision tags: OPENBSD_7_3_BASE
# 1.12 09-Mar-2023 chris

Fix comment to reflect the disabled status of Energy Efficient Ethernet.

Intel just disabled EEE for 1Gbps and 2.5Gbps modes on both i225 and i226
chips due to bugs. We already had it this way.

ok patrick@ kevlo@


# 1.11 09-Feb-2023 naddy

consolidate mbuf header parsing on device driver layer

em(4) ok jan@, bluhm@
igc(4) tested by weerd@


# 1.10 11-Nov-2022 mbuhl

Due to checksum offloading one more element could be written to the ring
than there is space available.
ok dlg


Revision tags: OPENBSD_7_2_BASE
# 1.9 02-Jun-2022 mbuhl

Implement and enable IPv4, TCP, and UDP checksum offloading for igc.

ok kevlo@


# 1.8 11-May-2022 kevlo

Use hardware routine for PHY reset and always accept the PHY that's present.

The previously used software reset routine wasn't sufficient to reset the PHY
if the bootloader hadn't left the device in an initialized state.
From FreeBSD.

Bug reported and the fix tested by daniel@


# 1.7 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.6 09-Jan-2022 patrick

Simplify igc_rxrinfo() to improve consistency and appease Coverity.

CID 1510483

ok kevlo@


# 1.5 22-Nov-2021 jsg

avoid uninitialised variable use in igc(4)

read icr reg before testing bit in result
add missing block in rxeof from ix

ok kevlo@ patrick@


# 1.4 31-Oct-2021 patrick

Disable both TCP/UDP checksum offloading and VLAN HW tag offloading for now,
as we currently configure neither in the transmit code path.

Found by sf@


# 1.3 31-Oct-2021 patrick

Implement transmit and transmit completion path.


# 1.2 31-Oct-2021 patrick

Move the fill and the tail pointer change to a later point, to make sure
that the RDT is written, and that it is written not too early. Doing it
before writing IGC_RXDCTL definitely doesn't work.

The tail pointer needs to be set to the next empty slot, so it has to be
"last desc filled + 1".

Make sure sure that the rss mapping does not happen in the middle of the
RX checksum block, and that it happens only if nqueues > 1. Also disable
storing bad packets.

With this, igc(4) receives packets just fine.

ok kevlo@


# 1.1 31-Oct-2021 patrick

Add igc(4), a driver for the Intel 2.5Gb Ethernet controllers.

Ported by kevlo@
ok jmatthew@


# 1.21 04-May-2024 mbuhl

Add TSO capabilites.
Comments, suggestions and testing from bket@, jan@, and bluhm@


# 1.20 12-Apr-2024 jan

remove useless includes of ip.h and ip6.h

ok bluhm


# 1.19 25-Mar-2024 mbuhl

Add the VLAN_HWTAGGING capability. Big thanks to bket@ for testing,
rebasing, refactoring, and addressing feedback for this diff.
ok bluhm@, jan@


Revision tags: OPENBSD_7_5_BASE
# 1.18 23-Feb-2024 kevlo

- Add support for reporting flow control status.
- Add missing igc_check_for_link() call; from Masanobu SAITOH via NetBSD.

"Fine" deraadt@

ok jan@


# 1.17 14-Feb-2024 bluhm

Check IP length in ether_extract_headers().

For LRO with ix(4) it is necessary to detect ethernet padding.
Extract ip_len and ip6_plen from the mbuf and provide it to the
drivers.
Add extended sanitity checks, like IP packet is shorter than TCP
header. This prevents offloading to network hardware with bougus
packets.
Also iphlen of extracted headers contains header length for IPv4
and IPv6, to make code in drivers simpler.

OK mglocker@


# 1.16 13-Feb-2024 bluhm

Analyse header layout in ether_extract_headers().

Several drivers need IPv4 header length and TCP offset for checksum
offload, TSO and LRO. Accessing these fields directly caused crashes
on sparc64 due to misaligned access. It cannot be guaranteed that
IP and TCP header is 4 byte aligned in driver level. Also gcc 4.2.1
assumes that bit fields can be accessed with 32 bit load instructions.

Use memcpy() in ether_extract_headers() to get the bits from IPv4
and TCP header and store the header length in struct ether_extracted.
From there network drivers can esily use it without caring about
alignment and bit shift. Do some sanity checks with the length
values to prevent that invalid values from evil packets get stored
into hardware registers. If check fails, clear the pointer to the
header to hide it from the driver. Add debug prints that help to
figure out the reason for bad packets and provide information when
debugging drivers.

OK mglocker@


# 1.15 23-Jan-2024 kevlo

Change default duplex setting and simplify the setup of srrctl.BSIZEPKT.

During media selection through ifconfig one might not specify the duplex
setting through the mediaopt flag. In that case the igc(4) would default
to full-duplex. The problem with this approach is that em(4) defaults to
half-duplex. Because of that if one connects both NICs and sets media to
e.g. 100baseTX on both of them no carrier will be found.
Fix that by matching igc(4) behaviour with what em(4) does.

Adapted from FreeBSD commits 3b8d04f845b416d29a258658b8a48d1afb4a2e81 and
0eb8cd1de26849cbaefaf3bc59aa9612fa0dfa52 respectively.

ok mbuhl@


# 1.14 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.13 28-Apr-2023 bluhm

Remove error handling around mallocarray(9). I cannot fail when
called with M_WAITOK.
OK kevlo@


Revision tags: OPENBSD_7_3_BASE
# 1.12 09-Mar-2023 chris

Fix comment to reflect the disabled status of Energy Efficient Ethernet.

Intel just disabled EEE for 1Gbps and 2.5Gbps modes on both i225 and i226
chips due to bugs. We already had it this way.

ok patrick@ kevlo@


# 1.11 09-Feb-2023 naddy

consolidate mbuf header parsing on device driver layer

em(4) ok jan@, bluhm@
igc(4) tested by weerd@


# 1.10 11-Nov-2022 mbuhl

Due to checksum offloading one more element could be written to the ring
than there is space available.
ok dlg


Revision tags: OPENBSD_7_2_BASE
# 1.9 02-Jun-2022 mbuhl

Implement and enable IPv4, TCP, and UDP checksum offloading for igc.

ok kevlo@


# 1.8 11-May-2022 kevlo

Use hardware routine for PHY reset and always accept the PHY that's present.

The previously used software reset routine wasn't sufficient to reset the PHY
if the bootloader hadn't left the device in an initialized state.
From FreeBSD.

Bug reported and the fix tested by daniel@


# 1.7 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.6 09-Jan-2022 patrick

Simplify igc_rxrinfo() to improve consistency and appease Coverity.

CID 1510483

ok kevlo@


# 1.5 22-Nov-2021 jsg

avoid uninitialised variable use in igc(4)

read icr reg before testing bit in result
add missing block in rxeof from ix

ok kevlo@ patrick@


# 1.4 31-Oct-2021 patrick

Disable both TCP/UDP checksum offloading and VLAN HW tag offloading for now,
as we currently configure neither in the transmit code path.

Found by sf@


# 1.3 31-Oct-2021 patrick

Implement transmit and transmit completion path.


# 1.2 31-Oct-2021 patrick

Move the fill and the tail pointer change to a later point, to make sure
that the RDT is written, and that it is written not too early. Doing it
before writing IGC_RXDCTL definitely doesn't work.

The tail pointer needs to be set to the next empty slot, so it has to be
"last desc filled + 1".

Make sure sure that the rss mapping does not happen in the middle of the
RX checksum block, and that it happens only if nqueues > 1. Also disable
storing bad packets.

With this, igc(4) receives packets just fine.

ok kevlo@


# 1.1 31-Oct-2021 patrick

Add igc(4), a driver for the Intel 2.5Gb Ethernet controllers.

Ported by kevlo@
ok jmatthew@


# 1.20 12-Apr-2024 jan

remove useless includes of ip.h and ip6.h

ok bluhm


# 1.19 25-Mar-2024 mbuhl

Add the VLAN_HWTAGGING capability. Big thanks to bket@ for testing,
rebasing, refactoring, and addressing feedback for this diff.
ok bluhm@, jan@


Revision tags: OPENBSD_7_5_BASE
# 1.18 23-Feb-2024 kevlo

- Add support for reporting flow control status.
- Add missing igc_check_for_link() call; from Masanobu SAITOH via NetBSD.

"Fine" deraadt@

ok jan@


# 1.17 14-Feb-2024 bluhm

Check IP length in ether_extract_headers().

For LRO with ix(4) it is necessary to detect ethernet padding.
Extract ip_len and ip6_plen from the mbuf and provide it to the
drivers.
Add extended sanitity checks, like IP packet is shorter than TCP
header. This prevents offloading to network hardware with bougus
packets.
Also iphlen of extracted headers contains header length for IPv4
and IPv6, to make code in drivers simpler.

OK mglocker@


# 1.16 13-Feb-2024 bluhm

Analyse header layout in ether_extract_headers().

Several drivers need IPv4 header length and TCP offset for checksum
offload, TSO and LRO. Accessing these fields directly caused crashes
on sparc64 due to misaligned access. It cannot be guaranteed that
IP and TCP header is 4 byte aligned in driver level. Also gcc 4.2.1
assumes that bit fields can be accessed with 32 bit load instructions.

Use memcpy() in ether_extract_headers() to get the bits from IPv4
and TCP header and store the header length in struct ether_extracted.
From there network drivers can esily use it without caring about
alignment and bit shift. Do some sanity checks with the length
values to prevent that invalid values from evil packets get stored
into hardware registers. If check fails, clear the pointer to the
header to hide it from the driver. Add debug prints that help to
figure out the reason for bad packets and provide information when
debugging drivers.

OK mglocker@


# 1.15 23-Jan-2024 kevlo

Change default duplex setting and simplify the setup of srrctl.BSIZEPKT.

During media selection through ifconfig one might not specify the duplex
setting through the mediaopt flag. In that case the igc(4) would default
to full-duplex. The problem with this approach is that em(4) defaults to
half-duplex. Because of that if one connects both NICs and sets media to
e.g. 100baseTX on both of them no carrier will be found.
Fix that by matching igc(4) behaviour with what em(4) does.

Adapted from FreeBSD commits 3b8d04f845b416d29a258658b8a48d1afb4a2e81 and
0eb8cd1de26849cbaefaf3bc59aa9612fa0dfa52 respectively.

ok mbuhl@


# 1.14 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.13 28-Apr-2023 bluhm

Remove error handling around mallocarray(9). I cannot fail when
called with M_WAITOK.
OK kevlo@


Revision tags: OPENBSD_7_3_BASE
# 1.12 09-Mar-2023 chris

Fix comment to reflect the disabled status of Energy Efficient Ethernet.

Intel just disabled EEE for 1Gbps and 2.5Gbps modes on both i225 and i226
chips due to bugs. We already had it this way.

ok patrick@ kevlo@


# 1.11 09-Feb-2023 naddy

consolidate mbuf header parsing on device driver layer

em(4) ok jan@, bluhm@
igc(4) tested by weerd@


# 1.10 11-Nov-2022 mbuhl

Due to checksum offloading one more element could be written to the ring
than there is space available.
ok dlg


Revision tags: OPENBSD_7_2_BASE
# 1.9 02-Jun-2022 mbuhl

Implement and enable IPv4, TCP, and UDP checksum offloading for igc.

ok kevlo@


# 1.8 11-May-2022 kevlo

Use hardware routine for PHY reset and always accept the PHY that's present.

The previously used software reset routine wasn't sufficient to reset the PHY
if the bootloader hadn't left the device in an initialized state.
From FreeBSD.

Bug reported and the fix tested by daniel@


# 1.7 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.6 09-Jan-2022 patrick

Simplify igc_rxrinfo() to improve consistency and appease Coverity.

CID 1510483

ok kevlo@


# 1.5 22-Nov-2021 jsg

avoid uninitialised variable use in igc(4)

read icr reg before testing bit in result
add missing block in rxeof from ix

ok kevlo@ patrick@


# 1.4 31-Oct-2021 patrick

Disable both TCP/UDP checksum offloading and VLAN HW tag offloading for now,
as we currently configure neither in the transmit code path.

Found by sf@


# 1.3 31-Oct-2021 patrick

Implement transmit and transmit completion path.


# 1.2 31-Oct-2021 patrick

Move the fill and the tail pointer change to a later point, to make sure
that the RDT is written, and that it is written not too early. Doing it
before writing IGC_RXDCTL definitely doesn't work.

The tail pointer needs to be set to the next empty slot, so it has to be
"last desc filled + 1".

Make sure sure that the rss mapping does not happen in the middle of the
RX checksum block, and that it happens only if nqueues > 1. Also disable
storing bad packets.

With this, igc(4) receives packets just fine.

ok kevlo@


# 1.1 31-Oct-2021 patrick

Add igc(4), a driver for the Intel 2.5Gb Ethernet controllers.

Ported by kevlo@
ok jmatthew@


# 1.19 25-Mar-2024 mbuhl

Add the VLAN_HWTAGGING capability. Big thanks to bket@ for testing,
rebasing, refactoring, and addressing feedback for this diff.
ok bluhm@, jan@


Revision tags: OPENBSD_7_5_BASE
# 1.18 23-Feb-2024 kevlo

- Add support for reporting flow control status.
- Add missing igc_check_for_link() call; from Masanobu SAITOH via NetBSD.

"Fine" deraadt@

ok jan@


# 1.17 14-Feb-2024 bluhm

Check IP length in ether_extract_headers().

For LRO with ix(4) it is necessary to detect ethernet padding.
Extract ip_len and ip6_plen from the mbuf and provide it to the
drivers.
Add extended sanitity checks, like IP packet is shorter than TCP
header. This prevents offloading to network hardware with bougus
packets.
Also iphlen of extracted headers contains header length for IPv4
and IPv6, to make code in drivers simpler.

OK mglocker@


# 1.16 13-Feb-2024 bluhm

Analyse header layout in ether_extract_headers().

Several drivers need IPv4 header length and TCP offset for checksum
offload, TSO and LRO. Accessing these fields directly caused crashes
on sparc64 due to misaligned access. It cannot be guaranteed that
IP and TCP header is 4 byte aligned in driver level. Also gcc 4.2.1
assumes that bit fields can be accessed with 32 bit load instructions.

Use memcpy() in ether_extract_headers() to get the bits from IPv4
and TCP header and store the header length in struct ether_extracted.
From there network drivers can esily use it without caring about
alignment and bit shift. Do some sanity checks with the length
values to prevent that invalid values from evil packets get stored
into hardware registers. If check fails, clear the pointer to the
header to hide it from the driver. Add debug prints that help to
figure out the reason for bad packets and provide information when
debugging drivers.

OK mglocker@


# 1.15 23-Jan-2024 kevlo

Change default duplex setting and simplify the setup of srrctl.BSIZEPKT.

During media selection through ifconfig one might not specify the duplex
setting through the mediaopt flag. In that case the igc(4) would default
to full-duplex. The problem with this approach is that em(4) defaults to
half-duplex. Because of that if one connects both NICs and sets media to
e.g. 100baseTX on both of them no carrier will be found.
Fix that by matching igc(4) behaviour with what em(4) does.

Adapted from FreeBSD commits 3b8d04f845b416d29a258658b8a48d1afb4a2e81 and
0eb8cd1de26849cbaefaf3bc59aa9612fa0dfa52 respectively.

ok mbuhl@


# 1.14 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.13 28-Apr-2023 bluhm

Remove error handling around mallocarray(9). I cannot fail when
called with M_WAITOK.
OK kevlo@


Revision tags: OPENBSD_7_3_BASE
# 1.12 09-Mar-2023 chris

Fix comment to reflect the disabled status of Energy Efficient Ethernet.

Intel just disabled EEE for 1Gbps and 2.5Gbps modes on both i225 and i226
chips due to bugs. We already had it this way.

ok patrick@ kevlo@


# 1.11 09-Feb-2023 naddy

consolidate mbuf header parsing on device driver layer

em(4) ok jan@, bluhm@
igc(4) tested by weerd@


# 1.10 11-Nov-2022 mbuhl

Due to checksum offloading one more element could be written to the ring
than there is space available.
ok dlg


Revision tags: OPENBSD_7_2_BASE
# 1.9 02-Jun-2022 mbuhl

Implement and enable IPv4, TCP, and UDP checksum offloading for igc.

ok kevlo@


# 1.8 11-May-2022 kevlo

Use hardware routine for PHY reset and always accept the PHY that's present.

The previously used software reset routine wasn't sufficient to reset the PHY
if the bootloader hadn't left the device in an initialized state.
From FreeBSD.

Bug reported and the fix tested by daniel@


# 1.7 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.6 09-Jan-2022 patrick

Simplify igc_rxrinfo() to improve consistency and appease Coverity.

CID 1510483

ok kevlo@


# 1.5 22-Nov-2021 jsg

avoid uninitialised variable use in igc(4)

read icr reg before testing bit in result
add missing block in rxeof from ix

ok kevlo@ patrick@


# 1.4 31-Oct-2021 patrick

Disable both TCP/UDP checksum offloading and VLAN HW tag offloading for now,
as we currently configure neither in the transmit code path.

Found by sf@


# 1.3 31-Oct-2021 patrick

Implement transmit and transmit completion path.


# 1.2 31-Oct-2021 patrick

Move the fill and the tail pointer change to a later point, to make sure
that the RDT is written, and that it is written not too early. Doing it
before writing IGC_RXDCTL definitely doesn't work.

The tail pointer needs to be set to the next empty slot, so it has to be
"last desc filled + 1".

Make sure sure that the rss mapping does not happen in the middle of the
RX checksum block, and that it happens only if nqueues > 1. Also disable
storing bad packets.

With this, igc(4) receives packets just fine.

ok kevlo@


# 1.1 31-Oct-2021 patrick

Add igc(4), a driver for the Intel 2.5Gb Ethernet controllers.

Ported by kevlo@
ok jmatthew@


# 1.18 23-Feb-2024 kevlo

- Add support for reporting flow control status.
- Add missing igc_check_for_link() call; from Masanobu SAITOH via NetBSD.

"Fine" deraadt@

ok jan@


# 1.17 14-Feb-2024 bluhm

Check IP length in ether_extract_headers().

For LRO with ix(4) it is necessary to detect ethernet padding.
Extract ip_len and ip6_plen from the mbuf and provide it to the
drivers.
Add extended sanitity checks, like IP packet is shorter than TCP
header. This prevents offloading to network hardware with bougus
packets.
Also iphlen of extracted headers contains header length for IPv4
and IPv6, to make code in drivers simpler.

OK mglocker@


# 1.16 13-Feb-2024 bluhm

Analyse header layout in ether_extract_headers().

Several drivers need IPv4 header length and TCP offset for checksum
offload, TSO and LRO. Accessing these fields directly caused crashes
on sparc64 due to misaligned access. It cannot be guaranteed that
IP and TCP header is 4 byte aligned in driver level. Also gcc 4.2.1
assumes that bit fields can be accessed with 32 bit load instructions.

Use memcpy() in ether_extract_headers() to get the bits from IPv4
and TCP header and store the header length in struct ether_extracted.
From there network drivers can esily use it without caring about
alignment and bit shift. Do some sanity checks with the length
values to prevent that invalid values from evil packets get stored
into hardware registers. If check fails, clear the pointer to the
header to hide it from the driver. Add debug prints that help to
figure out the reason for bad packets and provide information when
debugging drivers.

OK mglocker@


# 1.15 23-Jan-2024 kevlo

Change default duplex setting and simplify the setup of srrctl.BSIZEPKT.

During media selection through ifconfig one might not specify the duplex
setting through the mediaopt flag. In that case the igc(4) would default
to full-duplex. The problem with this approach is that em(4) defaults to
half-duplex. Because of that if one connects both NICs and sets media to
e.g. 100baseTX on both of them no carrier will be found.
Fix that by matching igc(4) behaviour with what em(4) does.

Adapted from FreeBSD commits 3b8d04f845b416d29a258658b8a48d1afb4a2e81 and
0eb8cd1de26849cbaefaf3bc59aa9612fa0dfa52 respectively.

ok mbuhl@


# 1.14 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.13 28-Apr-2023 bluhm

Remove error handling around mallocarray(9). I cannot fail when
called with M_WAITOK.
OK kevlo@


Revision tags: OPENBSD_7_3_BASE
# 1.12 09-Mar-2023 chris

Fix comment to reflect the disabled status of Energy Efficient Ethernet.

Intel just disabled EEE for 1Gbps and 2.5Gbps modes on both i225 and i226
chips due to bugs. We already had it this way.

ok patrick@ kevlo@


# 1.11 09-Feb-2023 naddy

consolidate mbuf header parsing on device driver layer

em(4) ok jan@, bluhm@
igc(4) tested by weerd@


# 1.10 11-Nov-2022 mbuhl

Due to checksum offloading one more element could be written to the ring
than there is space available.
ok dlg


Revision tags: OPENBSD_7_2_BASE
# 1.9 02-Jun-2022 mbuhl

Implement and enable IPv4, TCP, and UDP checksum offloading for igc.

ok kevlo@


# 1.8 11-May-2022 kevlo

Use hardware routine for PHY reset and always accept the PHY that's present.

The previously used software reset routine wasn't sufficient to reset the PHY
if the bootloader hadn't left the device in an initialized state.
From FreeBSD.

Bug reported and the fix tested by daniel@


# 1.7 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.6 09-Jan-2022 patrick

Simplify igc_rxrinfo() to improve consistency and appease Coverity.

CID 1510483

ok kevlo@


# 1.5 22-Nov-2021 jsg

avoid uninitialised variable use in igc(4)

read icr reg before testing bit in result
add missing block in rxeof from ix

ok kevlo@ patrick@


# 1.4 31-Oct-2021 patrick

Disable both TCP/UDP checksum offloading and VLAN HW tag offloading for now,
as we currently configure neither in the transmit code path.

Found by sf@


# 1.3 31-Oct-2021 patrick

Implement transmit and transmit completion path.


# 1.2 31-Oct-2021 patrick

Move the fill and the tail pointer change to a later point, to make sure
that the RDT is written, and that it is written not too early. Doing it
before writing IGC_RXDCTL definitely doesn't work.

The tail pointer needs to be set to the next empty slot, so it has to be
"last desc filled + 1".

Make sure sure that the rss mapping does not happen in the middle of the
RX checksum block, and that it happens only if nqueues > 1. Also disable
storing bad packets.

With this, igc(4) receives packets just fine.

ok kevlo@


# 1.1 31-Oct-2021 patrick

Add igc(4), a driver for the Intel 2.5Gb Ethernet controllers.

Ported by kevlo@
ok jmatthew@


# 1.17 14-Feb-2024 bluhm

Check IP length in ether_extract_headers().

For LRO with ix(4) it is necessary to detect ethernet padding.
Extract ip_len and ip6_plen from the mbuf and provide it to the
drivers.
Add extended sanitity checks, like IP packet is shorter than TCP
header. This prevents offloading to network hardware with bougus
packets.
Also iphlen of extracted headers contains header length for IPv4
and IPv6, to make code in drivers simpler.

OK mglocker@


# 1.16 13-Feb-2024 bluhm

Analyse header layout in ether_extract_headers().

Several drivers need IPv4 header length and TCP offset for checksum
offload, TSO and LRO. Accessing these fields directly caused crashes
on sparc64 due to misaligned access. It cannot be guaranteed that
IP and TCP header is 4 byte aligned in driver level. Also gcc 4.2.1
assumes that bit fields can be accessed with 32 bit load instructions.

Use memcpy() in ether_extract_headers() to get the bits from IPv4
and TCP header and store the header length in struct ether_extracted.
From there network drivers can esily use it without caring about
alignment and bit shift. Do some sanity checks with the length
values to prevent that invalid values from evil packets get stored
into hardware registers. If check fails, clear the pointer to the
header to hide it from the driver. Add debug prints that help to
figure out the reason for bad packets and provide information when
debugging drivers.

OK mglocker@


# 1.15 23-Jan-2024 kevlo

Change default duplex setting and simplify the setup of srrctl.BSIZEPKT.

During media selection through ifconfig one might not specify the duplex
setting through the mediaopt flag. In that case the igc(4) would default
to full-duplex. The problem with this approach is that em(4) defaults to
half-duplex. Because of that if one connects both NICs and sets media to
e.g. 100baseTX on both of them no carrier will be found.
Fix that by matching igc(4) behaviour with what em(4) does.

Adapted from FreeBSD commits 3b8d04f845b416d29a258658b8a48d1afb4a2e81 and
0eb8cd1de26849cbaefaf3bc59aa9612fa0dfa52 respectively.

ok mbuhl@


# 1.14 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.13 28-Apr-2023 bluhm

Remove error handling around mallocarray(9). I cannot fail when
called with M_WAITOK.
OK kevlo@


Revision tags: OPENBSD_7_3_BASE
# 1.12 09-Mar-2023 chris

Fix comment to reflect the disabled status of Energy Efficient Ethernet.

Intel just disabled EEE for 1Gbps and 2.5Gbps modes on both i225 and i226
chips due to bugs. We already had it this way.

ok patrick@ kevlo@


# 1.11 09-Feb-2023 naddy

consolidate mbuf header parsing on device driver layer

em(4) ok jan@, bluhm@
igc(4) tested by weerd@


# 1.10 11-Nov-2022 mbuhl

Due to checksum offloading one more element could be written to the ring
than there is space available.
ok dlg


Revision tags: OPENBSD_7_2_BASE
# 1.9 02-Jun-2022 mbuhl

Implement and enable IPv4, TCP, and UDP checksum offloading for igc.

ok kevlo@


# 1.8 11-May-2022 kevlo

Use hardware routine for PHY reset and always accept the PHY that's present.

The previously used software reset routine wasn't sufficient to reset the PHY
if the bootloader hadn't left the device in an initialized state.
From FreeBSD.

Bug reported and the fix tested by daniel@


# 1.7 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.6 09-Jan-2022 patrick

Simplify igc_rxrinfo() to improve consistency and appease Coverity.

CID 1510483

ok kevlo@


# 1.5 22-Nov-2021 jsg

avoid uninitialised variable use in igc(4)

read icr reg before testing bit in result
add missing block in rxeof from ix

ok kevlo@ patrick@


# 1.4 31-Oct-2021 patrick

Disable both TCP/UDP checksum offloading and VLAN HW tag offloading for now,
as we currently configure neither in the transmit code path.

Found by sf@


# 1.3 31-Oct-2021 patrick

Implement transmit and transmit completion path.


# 1.2 31-Oct-2021 patrick

Move the fill and the tail pointer change to a later point, to make sure
that the RDT is written, and that it is written not too early. Doing it
before writing IGC_RXDCTL definitely doesn't work.

The tail pointer needs to be set to the next empty slot, so it has to be
"last desc filled + 1".

Make sure sure that the rss mapping does not happen in the middle of the
RX checksum block, and that it happens only if nqueues > 1. Also disable
storing bad packets.

With this, igc(4) receives packets just fine.

ok kevlo@


# 1.1 31-Oct-2021 patrick

Add igc(4), a driver for the Intel 2.5Gb Ethernet controllers.

Ported by kevlo@
ok jmatthew@


# 1.17 14-Feb-2024 bluhm

Check IP length in ether_extract_headers().

For LRO with ix(4) it is necessary to detect ethernet padding.
Extract ip_len and ip6_plen from the mbuf and provide it to the
drivers.
Add extended sanitity checks, like IP packet is shorter than TCP
header. This prevents offloading to network hardware with bougus
packets.
Also iphlen of extracted headers contains header length for IPv4
and IPv6, to make code in drivers simpler.

OK mglocker@


# 1.16 13-Feb-2024 bluhm

Analyse header layout in ether_extract_headers().

Several drivers need IPv4 header length and TCP offset for checksum
offload, TSO and LRO. Accessing these fields directly caused crashes
on sparc64 due to misaligned access. It cannot be guaranteed that
IP and TCP header is 4 byte aligned in driver level. Also gcc 4.2.1
assumes that bit fields can be accessed with 32 bit load instructions.

Use memcpy() in ether_extract_headers() to get the bits from IPv4
and TCP header and store the header length in struct ether_extracted.
From there network drivers can esily use it without caring about
alignment and bit shift. Do some sanity checks with the length
values to prevent that invalid values from evil packets get stored
into hardware registers. If check fails, clear the pointer to the
header to hide it from the driver. Add debug prints that help to
figure out the reason for bad packets and provide information when
debugging drivers.

OK mglocker@


# 1.15 23-Jan-2024 kevlo

Change default duplex setting and simplify the setup of srrctl.BSIZEPKT.

During media selection through ifconfig one might not specify the duplex
setting through the mediaopt flag. In that case the igc(4) would default
to full-duplex. The problem with this approach is that em(4) defaults to
half-duplex. Because of that if one connects both NICs and sets media to
e.g. 100baseTX on both of them no carrier will be found.
Fix that by matching igc(4) behaviour with what em(4) does.

Adapted from FreeBSD commits 3b8d04f845b416d29a258658b8a48d1afb4a2e81 and
0eb8cd1de26849cbaefaf3bc59aa9612fa0dfa52 respectively.

ok mbuhl@


# 1.14 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.13 28-Apr-2023 bluhm

Remove error handling around mallocarray(9). I cannot fail when
called with M_WAITOK.
OK kevlo@


Revision tags: OPENBSD_7_3_BASE
# 1.12 09-Mar-2023 chris

Fix comment to reflect the disabled status of Energy Efficient Ethernet.

Intel just disabled EEE for 1Gbps and 2.5Gbps modes on both i225 and i226
chips due to bugs. We already had it this way.

ok patrick@ kevlo@


# 1.11 09-Feb-2023 naddy

consolidate mbuf header parsing on device driver layer

em(4) ok jan@, bluhm@
igc(4) tested by weerd@


# 1.10 11-Nov-2022 mbuhl

Due to checksum offloading one more element could be written to the ring
than there is space available.
ok dlg


Revision tags: OPENBSD_7_2_BASE
# 1.9 02-Jun-2022 mbuhl

Implement and enable IPv4, TCP, and UDP checksum offloading for igc.

ok kevlo@


# 1.8 11-May-2022 kevlo

Use hardware routine for PHY reset and always accept the PHY that's present.

The previously used software reset routine wasn't sufficient to reset the PHY
if the bootloader hadn't left the device in an initialized state.
From FreeBSD.

Bug reported and the fix tested by daniel@


# 1.7 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.6 09-Jan-2022 patrick

Simplify igc_rxrinfo() to improve consistency and appease Coverity.

CID 1510483

ok kevlo@


# 1.5 22-Nov-2021 jsg

avoid uninitialised variable use in igc(4)

read icr reg before testing bit in result
add missing block in rxeof from ix

ok kevlo@ patrick@


# 1.4 31-Oct-2021 patrick

Disable both TCP/UDP checksum offloading and VLAN HW tag offloading for now,
as we currently configure neither in the transmit code path.

Found by sf@


# 1.3 31-Oct-2021 patrick

Implement transmit and transmit completion path.


# 1.2 31-Oct-2021 patrick

Move the fill and the tail pointer change to a later point, to make sure
that the RDT is written, and that it is written not too early. Doing it
before writing IGC_RXDCTL definitely doesn't work.

The tail pointer needs to be set to the next empty slot, so it has to be
"last desc filled + 1".

Make sure sure that the rss mapping does not happen in the middle of the
RX checksum block, and that it happens only if nqueues > 1. Also disable
storing bad packets.

With this, igc(4) receives packets just fine.

ok kevlo@


# 1.1 31-Oct-2021 patrick

Add igc(4), a driver for the Intel 2.5Gb Ethernet controllers.

Ported by kevlo@
ok jmatthew@


# 1.15 23-Jan-2024 kevlo

Change default duplex setting and simplify the setup of srrctl.BSIZEPKT.

During media selection through ifconfig one might not specify the duplex
setting through the mediaopt flag. In that case the igc(4) would default
to full-duplex. The problem with this approach is that em(4) defaults to
half-duplex. Because of that if one connects both NICs and sets media to
e.g. 100baseTX on both of them no carrier will be found.
Fix that by matching igc(4) behaviour with what em(4) does.

Adapted from FreeBSD commits 3b8d04f845b416d29a258658b8a48d1afb4a2e81 and
0eb8cd1de26849cbaefaf3bc59aa9612fa0dfa52 respectively.

ok mbuhl@


# 1.14 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.13 28-Apr-2023 bluhm

Remove error handling around mallocarray(9). I cannot fail when
called with M_WAITOK.
OK kevlo@


Revision tags: OPENBSD_7_3_BASE
# 1.12 09-Mar-2023 chris

Fix comment to reflect the disabled status of Energy Efficient Ethernet.

Intel just disabled EEE for 1Gbps and 2.5Gbps modes on both i225 and i226
chips due to bugs. We already had it this way.

ok patrick@ kevlo@


# 1.11 09-Feb-2023 naddy

consolidate mbuf header parsing on device driver layer

em(4) ok jan@, bluhm@
igc(4) tested by weerd@


# 1.10 11-Nov-2022 mbuhl

Due to checksum offloading one more element could be written to the ring
than there is space available.
ok dlg


Revision tags: OPENBSD_7_2_BASE
# 1.9 02-Jun-2022 mbuhl

Implement and enable IPv4, TCP, and UDP checksum offloading for igc.

ok kevlo@


# 1.8 11-May-2022 kevlo

Use hardware routine for PHY reset and always accept the PHY that's present.

The previously used software reset routine wasn't sufficient to reset the PHY
if the bootloader hadn't left the device in an initialized state.
From FreeBSD.

Bug reported and the fix tested by daniel@


# 1.7 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.6 09-Jan-2022 patrick

Simplify igc_rxrinfo() to improve consistency and appease Coverity.

CID 1510483

ok kevlo@


# 1.5 22-Nov-2021 jsg

avoid uninitialised variable use in igc(4)

read icr reg before testing bit in result
add missing block in rxeof from ix

ok kevlo@ patrick@


# 1.4 31-Oct-2021 patrick

Disable both TCP/UDP checksum offloading and VLAN HW tag offloading for now,
as we currently configure neither in the transmit code path.

Found by sf@


# 1.3 31-Oct-2021 patrick

Implement transmit and transmit completion path.


# 1.2 31-Oct-2021 patrick

Move the fill and the tail pointer change to a later point, to make sure
that the RDT is written, and that it is written not too early. Doing it
before writing IGC_RXDCTL definitely doesn't work.

The tail pointer needs to be set to the next empty slot, so it has to be
"last desc filled + 1".

Make sure sure that the rss mapping does not happen in the middle of the
RX checksum block, and that it happens only if nqueues > 1. Also disable
storing bad packets.

With this, igc(4) receives packets just fine.

ok kevlo@


# 1.1 31-Oct-2021 patrick

Add igc(4), a driver for the Intel 2.5Gb Ethernet controllers.

Ported by kevlo@
ok jmatthew@


# 1.14 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.13 28-Apr-2023 bluhm

Remove error handling around mallocarray(9). I cannot fail when
called with M_WAITOK.
OK kevlo@


Revision tags: OPENBSD_7_3_BASE
# 1.12 09-Mar-2023 chris

Fix comment to reflect the disabled status of Energy Efficient Ethernet.

Intel just disabled EEE for 1Gbps and 2.5Gbps modes on both i225 and i226
chips due to bugs. We already had it this way.

ok patrick@ kevlo@


# 1.11 09-Feb-2023 naddy

consolidate mbuf header parsing on device driver layer

em(4) ok jan@, bluhm@
igc(4) tested by weerd@


# 1.10 11-Nov-2022 mbuhl

Due to checksum offloading one more element could be written to the ring
than there is space available.
ok dlg


Revision tags: OPENBSD_7_2_BASE
# 1.9 02-Jun-2022 mbuhl

Implement and enable IPv4, TCP, and UDP checksum offloading for igc.

ok kevlo@


# 1.8 11-May-2022 kevlo

Use hardware routine for PHY reset and always accept the PHY that's present.

The previously used software reset routine wasn't sufficient to reset the PHY
if the bootloader hadn't left the device in an initialized state.
From FreeBSD.

Bug reported and the fix tested by daniel@


# 1.7 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.6 09-Jan-2022 patrick

Simplify igc_rxrinfo() to improve consistency and appease Coverity.

CID 1510483

ok kevlo@


# 1.5 22-Nov-2021 jsg

avoid uninitialised variable use in igc(4)

read icr reg before testing bit in result
add missing block in rxeof from ix

ok kevlo@ patrick@


# 1.4 31-Oct-2021 patrick

Disable both TCP/UDP checksum offloading and VLAN HW tag offloading for now,
as we currently configure neither in the transmit code path.

Found by sf@


# 1.3 31-Oct-2021 patrick

Implement transmit and transmit completion path.


# 1.2 31-Oct-2021 patrick

Move the fill and the tail pointer change to a later point, to make sure
that the RDT is written, and that it is written not too early. Doing it
before writing IGC_RXDCTL definitely doesn't work.

The tail pointer needs to be set to the next empty slot, so it has to be
"last desc filled + 1".

Make sure sure that the rss mapping does not happen in the middle of the
RX checksum block, and that it happens only if nqueues > 1. Also disable
storing bad packets.

With this, igc(4) receives packets just fine.

ok kevlo@


# 1.1 31-Oct-2021 patrick

Add igc(4), a driver for the Intel 2.5Gb Ethernet controllers.

Ported by kevlo@
ok jmatthew@


# 1.13 28-Apr-2023 bluhm

Remove error handling around mallocarray(9). I cannot fail when
called with M_WAITOK.
OK kevlo@


Revision tags: OPENBSD_7_3_BASE
# 1.12 09-Mar-2023 chris

Fix comment to reflect the disabled status of Energy Efficient Ethernet.

Intel just disabled EEE for 1Gbps and 2.5Gbps modes on both i225 and i226
chips due to bugs. We already had it this way.

ok patrick@ kevlo@


# 1.11 09-Feb-2023 naddy

consolidate mbuf header parsing on device driver layer

em(4) ok jan@, bluhm@
igc(4) tested by weerd@


# 1.10 11-Nov-2022 mbuhl

Due to checksum offloading one more element could be written to the ring
than there is space available.
ok dlg


Revision tags: OPENBSD_7_2_BASE
# 1.9 02-Jun-2022 mbuhl

Implement and enable IPv4, TCP, and UDP checksum offloading for igc.

ok kevlo@


# 1.8 11-May-2022 kevlo

Use hardware routine for PHY reset and always accept the PHY that's present.

The previously used software reset routine wasn't sufficient to reset the PHY
if the bootloader hadn't left the device in an initialized state.
From FreeBSD.

Bug reported and the fix tested by daniel@


# 1.7 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.6 09-Jan-2022 patrick

Simplify igc_rxrinfo() to improve consistency and appease Coverity.

CID 1510483

ok kevlo@


# 1.5 22-Nov-2021 jsg

avoid uninitialised variable use in igc(4)

read icr reg before testing bit in result
add missing block in rxeof from ix

ok kevlo@ patrick@


# 1.4 31-Oct-2021 patrick

Disable both TCP/UDP checksum offloading and VLAN HW tag offloading for now,
as we currently configure neither in the transmit code path.

Found by sf@


# 1.3 31-Oct-2021 patrick

Implement transmit and transmit completion path.


# 1.2 31-Oct-2021 patrick

Move the fill and the tail pointer change to a later point, to make sure
that the RDT is written, and that it is written not too early. Doing it
before writing IGC_RXDCTL definitely doesn't work.

The tail pointer needs to be set to the next empty slot, so it has to be
"last desc filled + 1".

Make sure sure that the rss mapping does not happen in the middle of the
RX checksum block, and that it happens only if nqueues > 1. Also disable
storing bad packets.

With this, igc(4) receives packets just fine.

ok kevlo@


# 1.1 31-Oct-2021 patrick

Add igc(4), a driver for the Intel 2.5Gb Ethernet controllers.

Ported by kevlo@
ok jmatthew@


# 1.12 09-Mar-2023 chris

Fix comment to reflect the disabled status of Energy Efficient Ethernet.

Intel just disabled EEE for 1Gbps and 2.5Gbps modes on both i225 and i226
chips due to bugs. We already had it this way.

ok patrick@ kevlo@


# 1.11 09-Feb-2023 naddy

consolidate mbuf header parsing on device driver layer

em(4) ok jan@, bluhm@
igc(4) tested by weerd@


# 1.10 11-Nov-2022 mbuhl

Due to checksum offloading one more element could be written to the ring
than there is space available.
ok dlg


Revision tags: OPENBSD_7_2_BASE
# 1.9 02-Jun-2022 mbuhl

Implement and enable IPv4, TCP, and UDP checksum offloading for igc.

ok kevlo@


# 1.8 11-May-2022 kevlo

Use hardware routine for PHY reset and always accept the PHY that's present.

The previously used software reset routine wasn't sufficient to reset the PHY
if the bootloader hadn't left the device in an initialized state.
From FreeBSD.

Bug reported and the fix tested by daniel@


# 1.7 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.6 09-Jan-2022 patrick

Simplify igc_rxrinfo() to improve consistency and appease Coverity.

CID 1510483

ok kevlo@


# 1.5 22-Nov-2021 jsg

avoid uninitialised variable use in igc(4)

read icr reg before testing bit in result
add missing block in rxeof from ix

ok kevlo@ patrick@


# 1.4 31-Oct-2021 patrick

Disable both TCP/UDP checksum offloading and VLAN HW tag offloading for now,
as we currently configure neither in the transmit code path.

Found by sf@


# 1.3 31-Oct-2021 patrick

Implement transmit and transmit completion path.


# 1.2 31-Oct-2021 patrick

Move the fill and the tail pointer change to a later point, to make sure
that the RDT is written, and that it is written not too early. Doing it
before writing IGC_RXDCTL definitely doesn't work.

The tail pointer needs to be set to the next empty slot, so it has to be
"last desc filled + 1".

Make sure sure that the rss mapping does not happen in the middle of the
RX checksum block, and that it happens only if nqueues > 1. Also disable
storing bad packets.

With this, igc(4) receives packets just fine.

ok kevlo@


# 1.1 31-Oct-2021 patrick

Add igc(4), a driver for the Intel 2.5Gb Ethernet controllers.

Ported by kevlo@
ok jmatthew@


# 1.11 09-Feb-2023 naddy

consolidate mbuf header parsing on device driver layer

em(4) ok jan@, bluhm@
igc(4) tested by weerd@


# 1.10 11-Nov-2022 mbuhl

Due to checksum offloading one more element could be written to the ring
than there is space available.
ok dlg


Revision tags: OPENBSD_7_2_BASE
# 1.9 02-Jun-2022 mbuhl

Implement and enable IPv4, TCP, and UDP checksum offloading for igc.

ok kevlo@


# 1.8 11-May-2022 kevlo

Use hardware routine for PHY reset and always accept the PHY that's present.

The previously used software reset routine wasn't sufficient to reset the PHY
if the bootloader hadn't left the device in an initialized state.
From FreeBSD.

Bug reported and the fix tested by daniel@


# 1.7 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.6 09-Jan-2022 patrick

Simplify igc_rxrinfo() to improve consistency and appease Coverity.

CID 1510483

ok kevlo@


# 1.5 22-Nov-2021 jsg

avoid uninitialised variable use in igc(4)

read icr reg before testing bit in result
add missing block in rxeof from ix

ok kevlo@ patrick@


# 1.4 31-Oct-2021 patrick

Disable both TCP/UDP checksum offloading and VLAN HW tag offloading for now,
as we currently configure neither in the transmit code path.

Found by sf@


# 1.3 31-Oct-2021 patrick

Implement transmit and transmit completion path.


# 1.2 31-Oct-2021 patrick

Move the fill and the tail pointer change to a later point, to make sure
that the RDT is written, and that it is written not too early. Doing it
before writing IGC_RXDCTL definitely doesn't work.

The tail pointer needs to be set to the next empty slot, so it has to be
"last desc filled + 1".

Make sure sure that the rss mapping does not happen in the middle of the
RX checksum block, and that it happens only if nqueues > 1. Also disable
storing bad packets.

With this, igc(4) receives packets just fine.

ok kevlo@


# 1.1 31-Oct-2021 patrick

Add igc(4), a driver for the Intel 2.5Gb Ethernet controllers.

Ported by kevlo@
ok jmatthew@


# 1.10 11-Nov-2022 mbuhl

Due to checksum offloading one more element could be written to the ring
than there is space available.
ok dlg


Revision tags: OPENBSD_7_2_BASE
# 1.9 02-Jun-2022 mbuhl

Implement and enable IPv4, TCP, and UDP checksum offloading for igc.

ok kevlo@


# 1.8 11-May-2022 kevlo

Use hardware routine for PHY reset and always accept the PHY that's present.

The previously used software reset routine wasn't sufficient to reset the PHY
if the bootloader hadn't left the device in an initialized state.
From FreeBSD.

Bug reported and the fix tested by daniel@


# 1.7 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.6 09-Jan-2022 patrick

Simplify igc_rxrinfo() to improve consistency and appease Coverity.

CID 1510483

ok kevlo@


# 1.5 22-Nov-2021 jsg

avoid uninitialised variable use in igc(4)

read icr reg before testing bit in result
add missing block in rxeof from ix

ok kevlo@ patrick@


# 1.4 31-Oct-2021 patrick

Disable both TCP/UDP checksum offloading and VLAN HW tag offloading for now,
as we currently configure neither in the transmit code path.

Found by sf@


# 1.3 31-Oct-2021 patrick

Implement transmit and transmit completion path.


# 1.2 31-Oct-2021 patrick

Move the fill and the tail pointer change to a later point, to make sure
that the RDT is written, and that it is written not too early. Doing it
before writing IGC_RXDCTL definitely doesn't work.

The tail pointer needs to be set to the next empty slot, so it has to be
"last desc filled + 1".

Make sure sure that the rss mapping does not happen in the middle of the
RX checksum block, and that it happens only if nqueues > 1. Also disable
storing bad packets.

With this, igc(4) receives packets just fine.

ok kevlo@


# 1.1 31-Oct-2021 patrick

Add igc(4), a driver for the Intel 2.5Gb Ethernet controllers.

Ported by kevlo@
ok jmatthew@


# 1.9 02-Jun-2022 mbuhl

Implement and enable IPv4, TCP, and UDP checksum offloading for igc.

ok kevlo@


# 1.8 11-May-2022 kevlo

Use hardware routine for PHY reset and always accept the PHY that's present.

The previously used software reset routine wasn't sufficient to reset the PHY
if the bootloader hadn't left the device in an initialized state.
From FreeBSD.

Bug reported and the fix tested by daniel@


# 1.7 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.6 09-Jan-2022 patrick

Simplify igc_rxrinfo() to improve consistency and appease Coverity.

CID 1510483

ok kevlo@


# 1.5 22-Nov-2021 jsg

avoid uninitialised variable use in igc(4)

read icr reg before testing bit in result
add missing block in rxeof from ix

ok kevlo@ patrick@


# 1.4 31-Oct-2021 patrick

Disable both TCP/UDP checksum offloading and VLAN HW tag offloading for now,
as we currently configure neither in the transmit code path.

Found by sf@


# 1.3 31-Oct-2021 patrick

Implement transmit and transmit completion path.


# 1.2 31-Oct-2021 patrick

Move the fill and the tail pointer change to a later point, to make sure
that the RDT is written, and that it is written not too early. Doing it
before writing IGC_RXDCTL definitely doesn't work.

The tail pointer needs to be set to the next empty slot, so it has to be
"last desc filled + 1".

Make sure sure that the rss mapping does not happen in the middle of the
RX checksum block, and that it happens only if nqueues > 1. Also disable
storing bad packets.

With this, igc(4) receives packets just fine.

ok kevlo@


# 1.1 31-Oct-2021 patrick

Add igc(4), a driver for the Intel 2.5Gb Ethernet controllers.

Ported by kevlo@
ok jmatthew@


# 1.8 11-May-2022 kevlo

Use hardware routine for PHY reset and always accept the PHY that's present.

The previously used software reset routine wasn't sufficient to reset the PHY
if the bootloader hadn't left the device in an initialized state.
From FreeBSD.

Bug reported and the fix tested by daniel@


# 1.7 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.6 09-Jan-2022 patrick

Simplify igc_rxrinfo() to improve consistency and appease Coverity.

CID 1510483

ok kevlo@


# 1.5 22-Nov-2021 jsg

avoid uninitialised variable use in igc(4)

read icr reg before testing bit in result
add missing block in rxeof from ix

ok kevlo@ patrick@


# 1.4 31-Oct-2021 patrick

Disable both TCP/UDP checksum offloading and VLAN HW tag offloading for now,
as we currently configure neither in the transmit code path.

Found by sf@


# 1.3 31-Oct-2021 patrick

Implement transmit and transmit completion path.


# 1.2 31-Oct-2021 patrick

Move the fill and the tail pointer change to a later point, to make sure
that the RDT is written, and that it is written not too early. Doing it
before writing IGC_RXDCTL definitely doesn't work.

The tail pointer needs to be set to the next empty slot, so it has to be
"last desc filled + 1".

Make sure sure that the rss mapping does not happen in the middle of the
RX checksum block, and that it happens only if nqueues > 1. Also disable
storing bad packets.

With this, igc(4) receives packets just fine.

ok kevlo@


# 1.1 31-Oct-2021 patrick

Add igc(4), a driver for the Intel 2.5Gb Ethernet controllers.

Ported by kevlo@
ok jmatthew@


# 1.7 06-Apr-2022 naddy

constify struct cfattach


Revision tags: OPENBSD_7_1_BASE
# 1.6 09-Jan-2022 patrick

Simplify igc_rxrinfo() to improve consistency and appease Coverity.

CID 1510483

ok kevlo@


# 1.5 22-Nov-2021 jsg

avoid uninitialised variable use in igc(4)

read icr reg before testing bit in result
add missing block in rxeof from ix

ok kevlo@ patrick@


# 1.4 31-Oct-2021 patrick

Disable both TCP/UDP checksum offloading and VLAN HW tag offloading for now,
as we currently configure neither in the transmit code path.

Found by sf@


# 1.3 31-Oct-2021 patrick

Implement transmit and transmit completion path.


# 1.2 31-Oct-2021 patrick

Move the fill and the tail pointer change to a later point, to make sure
that the RDT is written, and that it is written not too early. Doing it
before writing IGC_RXDCTL definitely doesn't work.

The tail pointer needs to be set to the next empty slot, so it has to be
"last desc filled + 1".

Make sure sure that the rss mapping does not happen in the middle of the
RX checksum block, and that it happens only if nqueues > 1. Also disable
storing bad packets.

With this, igc(4) receives packets just fine.

ok kevlo@


# 1.1 31-Oct-2021 patrick

Add igc(4), a driver for the Intel 2.5Gb Ethernet controllers.

Ported by kevlo@
ok jmatthew@


# 1.6 09-Jan-2022 patrick

Simplify igc_rxrinfo() to improve consistency and appease Coverity.

CID 1510483

ok kevlo@


# 1.5 22-Nov-2021 jsg

avoid uninitialised variable use in igc(4)

read icr reg before testing bit in result
add missing block in rxeof from ix

ok kevlo@ patrick@


# 1.4 31-Oct-2021 patrick

Disable both TCP/UDP checksum offloading and VLAN HW tag offloading for now,
as we currently configure neither in the transmit code path.

Found by sf@


# 1.3 31-Oct-2021 patrick

Implement transmit and transmit completion path.


# 1.2 31-Oct-2021 patrick

Move the fill and the tail pointer change to a later point, to make sure
that the RDT is written, and that it is written not too early. Doing it
before writing IGC_RXDCTL definitely doesn't work.

The tail pointer needs to be set to the next empty slot, so it has to be
"last desc filled + 1".

Make sure sure that the rss mapping does not happen in the middle of the
RX checksum block, and that it happens only if nqueues > 1. Also disable
storing bad packets.

With this, igc(4) receives packets just fine.

ok kevlo@


# 1.1 31-Oct-2021 patrick

Add igc(4), a driver for the Intel 2.5Gb Ethernet controllers.

Ported by kevlo@
ok jmatthew@