diff --git a/sys/dev/e1000/em_txrx.c b/sys/dev/e1000/em_txrx.c --- a/sys/dev/e1000/em_txrx.c +++ b/sys/dev/e1000/em_txrx.c @@ -671,9 +671,9 @@ u32 pkt_info; u32 staterr = 0; bool eop; - int i, cidx, vtag; + int i, cidx; - i = vtag = 0; + i = 0; cidx = ri->iri_cidx; do { @@ -710,12 +710,9 @@ em_receive_checksum(staterr, staterr >> 24, ri); if (staterr & E1000_RXD_STAT_VP) { - vtag = le16toh(rxd->wb.upper.vlan); - } - - ri->iri_vtag = vtag; - if (vtag) + ri->iri_vtag = le16toh(rxd->wb.upper.vlan); ri->iri_flags |= M_VLANTAG; + } ri->iri_flowid = le32toh(rxd->wb.lower.hi_dword.rss); ri->iri_rsstype = em_determine_rsstype(pkt_info); diff --git a/sys/dev/e1000/igb_txrx.c b/sys/dev/e1000/igb_txrx.c --- a/sys/dev/e1000/igb_txrx.c +++ b/sys/dev/e1000/igb_txrx.c @@ -436,12 +436,12 @@ struct rx_ring *rxr = &que->rxr; union e1000_adv_rx_desc *rxd; - uint16_t pkt_info, len, vtag; + uint16_t pkt_info, len; uint32_t ptype, staterr; int i, cidx; bool eop; - staterr = i = vtag = 0; + staterr = i = 0; cidx = ri->iri_cidx; do { @@ -460,13 +460,6 @@ rxd->wb.upper.status_error = 0; eop = ((staterr & E1000_RXD_STAT_EOP) == E1000_RXD_STAT_EOP); - if (((sc->hw.mac.type == e1000_i350) || - (sc->hw.mac.type == e1000_i354)) && - (staterr & E1000_RXDEXT_STATERR_LB)) - vtag = be16toh(rxd->wb.upper.vlan); - else - vtag = le16toh(rxd->wb.upper.vlan); - /* Make sure bad packets are discarded */ if (eop && ((staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK) != 0)) { sc->dropped_pkts++; @@ -492,12 +485,16 @@ rxr->rx_packets++; - if ((scctx->isc_capenable & IFCAP_RXCSUM) != 0) + if ((if_getcapenable(ri->iri_ifp) & IFCAP_RXCSUM) != 0) igb_rx_checksum(staterr, ri, ptype); - if ((scctx->isc_capenable & IFCAP_VLAN_HWTAGGING) != 0 && - (staterr & E1000_RXD_STAT_VP) != 0) { - ri->iri_vtag = vtag; + if (staterr & E1000_RXD_STAT_VP) { + if (((sc->hw.mac.type == e1000_i350) || + (sc->hw.mac.type == e1000_i354)) && + (staterr & E1000_RXDEXT_STATERR_LB)) + ri->iri_vtag = be16toh(rxd->wb.upper.vlan); + else + ri->iri_vtag = le16toh(rxd->wb.upper.vlan); ri->iri_flags |= M_VLANTAG; } diff --git a/sys/dev/iavf/iavf_txrx_iflib.c b/sys/dev/iavf/iavf_txrx_iflib.c --- a/sys/dev/iavf/iavf_txrx_iflib.c +++ b/sys/dev/iavf/iavf_txrx_iflib.c @@ -669,7 +669,7 @@ struct rx_ring *rxr = &que->rxr; union iavf_rx_desc *cur; u32 status, error; - u16 plen, vtag; + u16 plen; u64 qword; u8 ptype; bool eop; @@ -700,10 +700,6 @@ cur->wb.qword1.status_error_len = 0; eop = (status & (1 << IAVF_RX_DESC_STATUS_EOF_SHIFT)); - if (status & (1 << IAVF_RX_DESC_STATUS_L2TAG1P_SHIFT)) - vtag = le16toh(cur->wb.qword0.lo_dword.l2tag1); - else - vtag = 0; /* ** Make sure bad packets are discarded, @@ -730,10 +726,11 @@ iavf_rx_checksum(ri, status, error, ptype); ri->iri_flowid = le32toh(cur->wb.qword0.hi_dword.rss); ri->iri_rsstype = iavf_ptype_to_hash(ptype); - ri->iri_vtag = vtag; - ri->iri_nfrags = i; - if (vtag) + if (status & (1 << IAVF_RX_DESC_STATUS_L2TAG1P_SHIFT)) { + ri->iri_vtag = le16toh(cur->wb.qword0.lo_dword.l2tag1); ri->iri_flags |= M_VLANTAG; + } + ri->iri_nfrags = i; return (0); } diff --git a/sys/dev/ice/ice_iflib_txrx.c b/sys/dev/ice/ice_iflib_txrx.c --- a/sys/dev/ice/ice_iflib_txrx.c +++ b/sys/dev/ice/ice_iflib_txrx.c @@ -284,7 +284,7 @@ struct ice_softc *sc = (struct ice_softc *)arg; struct ice_rx_queue *rxq = &sc->pf_vsi.rx_queues[ri->iri_qsidx]; union ice_32b_rx_flex_desc *cur; - u16 status0, plen, vtag, ptype; + u16 status0, plen, ptype; bool eop; size_t cidx; int i; @@ -309,10 +309,6 @@ cur->wb.status_error0 = 0; eop = (status0 & BIT(ICE_RX_FLEX_DESC_STATUS0_EOF_S)); - if (status0 & BIT(ICE_RX_FLEX_DESC_STATUS0_L2TAG1P_S)) - vtag = le16toh(cur->wb.l2tag1); - else - vtag = 0; /* * Make sure packets with bad L2 values are discarded. @@ -339,10 +335,11 @@ &ri->iri_csum_data, status0, ptype); ri->iri_flowid = le32toh(RX_FLEX_NIC(&cur->wb, rss_hash)); ri->iri_rsstype = ice_ptype_to_hash(ptype); - ri->iri_vtag = vtag; - ri->iri_nfrags = i; - if (vtag) + if (status0 & BIT(ICE_RX_FLEX_DESC_STATUS0_L2TAG1P_S)) { + ri->iri_vtag = le16toh(cur->wb.l2tag1); ri->iri_flags |= M_VLANTAG; + } + ri->iri_nfrags = i; return (0); } diff --git a/sys/dev/igc/igc_txrx.c b/sys/dev/igc/igc_txrx.c --- a/sys/dev/igc/igc_txrx.c +++ b/sys/dev/igc/igc_txrx.c @@ -461,12 +461,12 @@ struct rx_ring *rxr = &que->rxr; union igc_adv_rx_desc *rxd; - uint16_t pkt_info, len, vtag; + uint16_t pkt_info, len; uint32_t ptype, staterr; int i, cidx; bool eop; - staterr = i = vtag = 0; + staterr = i = 0; cidx = ri->iri_cidx; do { @@ -485,8 +485,6 @@ rxd->wb.upper.status_error = 0; eop = ((staterr & IGC_RXD_STAT_EOP) == IGC_RXD_STAT_EOP); - vtag = le16toh(rxd->wb.upper.vlan); - /* Make sure bad packets are discarded */ if (eop && ((staterr & IGC_RXDEXT_STATERR_RXE) != 0)) { adapter->dropped_pkts++; @@ -512,12 +510,12 @@ rxr->rx_packets++; - if ((scctx->isc_capenable & IFCAP_RXCSUM) != 0) + if ((if_getcapenable(ri->iri_ifp) & IFCAP_RXCSUM) != 0) igc_rx_checksum(staterr, ri, ptype); - if ((scctx->isc_capenable & IFCAP_VLAN_HWTAGGING) != 0 && + if ((if_getcapenable(ri->iri_ifp) & IFCAP_VLAN_HWTAGGING) != 0 && (staterr & IGC_RXD_STAT_VP) != 0) { - ri->iri_vtag = vtag; + ri->iri_vtag = le16toh(rxd->wb.upper.vlan); ri->iri_flags |= M_VLANTAG; } diff --git a/sys/dev/ixgbe/ix_txrx.c b/sys/dev/ixgbe/ix_txrx.c --- a/sys/dev/ixgbe/ix_txrx.c +++ b/sys/dev/ixgbe/ix_txrx.c @@ -399,7 +399,6 @@ union ixgbe_adv_rx_desc *rxd; uint16_t pkt_info, len, cidx, i; - uint16_t vtag = 0; uint32_t ptype; uint32_t staterr = 0; bool eop; @@ -424,12 +423,6 @@ rxd->wb.upper.status_error = 0; eop = ((staterr & IXGBE_RXD_STAT_EOP) != 0); - if ( (rxr->vtag_strip) && (staterr & IXGBE_RXD_STAT_VP) ) { - vtag = le16toh(rxd->wb.upper.vlan); - } else { - vtag = 0; - } - /* Make sure bad packets are discarded */ if (eop && (staterr & IXGBE_RXDADV_ERR_FRAME_ERR_MASK) != 0) { if (sc->feat_en & IXGBE_FEATURE_VF) @@ -463,10 +456,12 @@ else ri->iri_rsstype = M_HASHTYPE_OPAQUE_HASH; } - ri->iri_vtag = vtag; - ri->iri_nfrags = i; - if (vtag) + if ((rxr->vtag_strip) && (staterr & IXGBE_RXD_STAT_VP)) { + ri->iri_vtag = le16toh(rxd->wb.upper.vlan); ri->iri_flags |= M_VLANTAG; + } + + ri->iri_nfrags = i; return (0); } /* ixgbe_isc_rxd_pkt_get */ diff --git a/sys/dev/ixl/ixl_txrx.c b/sys/dev/ixl/ixl_txrx.c --- a/sys/dev/ixl/ixl_txrx.c +++ b/sys/dev/ixl/ixl_txrx.c @@ -662,7 +662,7 @@ struct rx_ring *rxr = &que->rxr; union i40e_rx_desc *cur; u32 status, error; - u16 plen, vtag; + u16 plen; u64 qword; u8 ptype; bool eop; @@ -693,10 +693,6 @@ cur->wb.qword1.status_error_len = 0; eop = (status & (1 << I40E_RX_DESC_STATUS_EOF_SHIFT)); - if (status & (1 << I40E_RX_DESC_STATUS_L2TAG1P_SHIFT)) - vtag = le16toh(cur->wb.qword0.lo_dword.l2tag1); - else - vtag = 0; /* ** Make sure bad packets are discarded, @@ -723,10 +719,11 @@ rxr->csum_errs += ixl_rx_checksum(ri, status, error, ptype); ri->iri_flowid = le32toh(cur->wb.qword0.hi_dword.rss); ri->iri_rsstype = ixl_ptype_to_hash(ptype); - ri->iri_vtag = vtag; - ri->iri_nfrags = i; - if (vtag) + if (status & (1 << I40E_RX_DESC_STATUS_L2TAG1P_SHIFT)) { + ri->iri_vtag = le16toh(cur->wb.qword0.lo_dword.l2tag1); ri->iri_flags |= M_VLANTAG; + } + ri->iri_nfrags = i; return (0); }