Jan Klemkow:

> > igc(4) has very similar code, but I don't have access to a machine
> > with that hardware.
> 
> Send me an ssh-key and I give you access to this machine:

Alternatively, here's the diff, so other people can test it.

diff a0c537a1c9d84e98322b55d8f71438a147aaa7c4 
7d976644b87094d08f478fb087be35b91d2e38a7
commit - a0c537a1c9d84e98322b55d8f71438a147aaa7c4
commit + 7d976644b87094d08f478fb087be35b91d2e38a7
blob - a904d43c66b767b162b7602f2ef35fa5dc6dae4f
blob + c172c137bf82cea95f6f7c0524cd7e72ced18018
--- sys/dev/pci/if_igc.c
+++ sys/dev/pci/if_igc.c
@@ -2002,17 +2002,14 @@ igc_tx_ctx_setup(struct tx_ring *txr, struct mbuf *mp,
 igc_tx_ctx_setup(struct tx_ring *txr, struct mbuf *mp, int prod,
     uint32_t *olinfo_status)
 {
+       struct ether_extracted ext;
        struct igc_adv_tx_context_desc *txdesc;
-       struct ether_header *eh = mtod(mp, struct ether_header *);
-       struct mbuf *m;
        uint32_t type_tucmd_mlhl = 0;
        uint32_t vlan_macip_lens = 0;
        uint32_t iphlen;
-       int hoff;
        int off = 0;
-       uint8_t ipproto;
 
-       vlan_macip_lens |= (sizeof(*eh) << IGC_ADVTXD_MACLEN_SHIFT);
+       vlan_macip_lens |= (sizeof(*ext.eh) << IGC_ADVTXD_MACLEN_SHIFT);
 
        /*
         * In advanced descriptors the vlan tag must
@@ -2029,62 +2026,41 @@ igc_tx_ctx_setup(struct tx_ring *txr, struct mbuf *mp,
 #endif
 #endif
 
-       switch (ntohs(eh->ether_type)) {
-       case ETHERTYPE_IP: {
-               struct ip *ip;
+       ether_extract_headers(mp, &ext);
 
-               m = m_getptr(mp, sizeof(*eh), &hoff);
-               KASSERT(m != NULL && m->m_len - hoff >= sizeof(*ip));
-               ip = (struct ip *)(mtod(m, caddr_t) + hoff);
+       if (ext.ip4) {
+               iphlen = ext.ip4->ip_hl << 2;
 
-               iphlen = ip->ip_hl << 2;
-               ipproto = ip->ip_p;
-
                type_tucmd_mlhl |= IGC_ADVTXD_TUCMD_IPV4;
                if (ISSET(mp->m_pkthdr.csum_flags, M_IPV4_CSUM_OUT)) {
                        *olinfo_status |= IGC_TXD_POPTS_IXSM << 8;
                        off = 1;
                }
-
-               break;
-       }
 #ifdef INET6
-       case ETHERTYPE_IPV6: {
-               struct ip6_hdr *ip6;
+       } else if (ext.ip6) {
+               iphlen = sizeof(*ext.ip6);
 
-               m = m_getptr(mp, sizeof(*eh), &hoff);
-               KASSERT(m != NULL && m->m_len - hoff >= sizeof(*ip6));
-               ip6 = (struct ip6_hdr *)(mtod(m, caddr_t) + hoff);
-
-               iphlen = sizeof(*ip6);
-               ipproto = ip6->ip6_nxt;
-
                type_tucmd_mlhl |= IGC_ADVTXD_TUCMD_IPV6;
-               break;
-       }
 #endif
-       default:
+       } else {
                return 0;
        }
 
        vlan_macip_lens |= iphlen;
        type_tucmd_mlhl |= IGC_ADVTXD_DCMD_DEXT | IGC_ADVTXD_DTYP_CTXT;
 
-       switch (ipproto) {
-       case IPPROTO_TCP:
+       if (ext.tcp) {
                type_tucmd_mlhl |= IGC_ADVTXD_TUCMD_L4T_TCP;
                if (ISSET(mp->m_pkthdr.csum_flags, M_TCP_CSUM_OUT)) {
                        *olinfo_status |= IGC_TXD_POPTS_TXSM << 8;
                        off = 1;
                }
-               break;
-       case IPPROTO_UDP:
+       } else if (ext.udp) {
                type_tucmd_mlhl |= IGC_ADVTXD_TUCMD_L4T_UDP;
                if (ISSET(mp->m_pkthdr.csum_flags, M_UDP_CSUM_OUT)) {
                        *olinfo_status |= IGC_TXD_POPTS_TXSM << 8;
                        off = 1;
                }
-               break;
        }
 
        if (off == 0)

-- 
Christian "naddy" Weisgerber                          na...@mips.inka.de

Reply via email to