Dear tech@,
the following diff should implement vlan hwtagging for igc.
I would appreciate feedback from further testing.
OK?
mbuhl
Index: sys/dev/pci/if_igc.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/if_igc.c,v
retrieving revision 1.9
diff -u -p -r1.9 if_igc.c
--- sys/dev/pci/if_igc.c 2 Jun 2022 07:41:17 -0000 1.9
+++ sys/dev/pci/if_igc.c 2 Jun 2022 12:18:14 -0000
@@ -790,11 +790,9 @@ igc_setup_interface(struct igc_softc *sc
ifp->if_capabilities = IFCAP_VLAN_MTU;
-#ifdef notyet
#if NVLAN > 0
ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING;
#endif
-#endif
ifp->if_capabilities |= IFCAP_CSUM_IPv4;
ifp->if_capabilities |= IFCAP_CSUM_TCPv4 | IFCAP_CSUM_UDPv4;
@@ -1007,17 +1005,19 @@ igc_start(struct ifqueue *ifq)
prod &= mask;
}
+ cmd_type_len = IGC_ADVTXD_DCMD_IFCS | IGC_ADVTXD_DTYP_DATA |
+ IGC_ADVTXD_DCMD_DEXT;
+
+ if (ISSET(m->m_flags, M_VLANTAG))
+ cmd_type_len |= IGC_ADVTXD_DCMD_VLE;
+
for (i = 0; i < map->dm_nsegs; i++) {
txdesc = &txr->tx_base[prod];
- cmd_type_len = IGC_ADVTXD_DCMD_IFCS |
IGC_ADVTXD_DTYP_DATA |
- IGC_ADVTXD_DCMD_DEXT | map->dm_segs[i].ds_len;
- if (i == map->dm_nsegs - 1)
- cmd_type_len |= IGC_ADVTXD_DCMD_EOP |
- IGC_ADVTXD_DCMD_RS;
-
htolem64(&txdesc->read.buffer_addr,
map->dm_segs[i].ds_addr);
- htolem32(&txdesc->read.cmd_type_len, cmd_type_len);
+ htolem32(&txdesc->read.cmd_type_len, cmd_type_len |
+ map->dm_segs[i].ds_len | ((i == map->dm_nsegs - 1)?
+ IGC_ADVTXD_DCMD_EOP | IGC_ADVTXD_DCMD_RS : 0));
htolem32(&txdesc->read.olinfo_status, olinfo_status);
last = prod;
@@ -2006,10 +2006,10 @@ igc_tx_ctx_setup(struct tx_ring *txr, st
struct mbuf *m;
uint32_t type_tucmd_mlhl = 0;
uint32_t vlan_macip_lens = 0;
- uint32_t iphlen;
+ uint32_t iphlen = 0;
int hoff;
int off = 0;
- uint8_t ipproto;
+ uint8_t ipproto = 0;
vlan_macip_lens |= (sizeof(*eh) << IGC_ADVTXD_MACLEN_SHIFT);
@@ -2018,7 +2018,6 @@ igc_tx_ctx_setup(struct tx_ring *txr, st
* be placed into the context descriptor. Hence
* we need to make one even if not doing offloads.
*/
-#ifdef notyet
#if NVLAN > 0
if (ISSET(mp->m_flags, M_VLANTAG)) {
uint32_t vtag = mp->m_pkthdr.ether_vtag;
@@ -2026,7 +2025,6 @@ igc_tx_ctx_setup(struct tx_ring *txr, st
off = 1;
}
#endif
-#endif
switch (ntohs(eh->ether_type)) {
case ETHERTYPE_IP: {
@@ -2062,8 +2060,6 @@ igc_tx_ctx_setup(struct tx_ring *txr, st
break;
}
#endif
- default:
- return 0;
}
vlan_macip_lens |= iphlen;