From nobody Thu Jan 27 22:39:43 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id E6F8A198E4FC; Thu, 27 Jan 2022 22:39:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JlFrw2Ygjz3kRF; Thu, 27 Jan 2022 22:39:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643323184; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=FWmbXUOGlWVrDHDUV5I8mBeHdLr1DJyE4N3KY46InVQ=; b=nQQTgIFqXiCy85Eszj1s+0YertqX0OhQ26U0xSOqTKLYeEAgHLaETiIE6c3HP+zwtIBoZx VErRPdIteR0t+tEBxQwzpGkIbvA0+XsTxOxYH0XQBE4GbZxUkY8Wd1Kaw8shAZ73vzG+Ua nNw1e7bqC5sh3nxi7ys/2Sv+5IaHkSEgDPwzWN+UXVrfNayjCOOFA6QrWligTD4+/S/sjL RrpzonReDa6Z5fN0LsRwrbDwA2PPDX6JjusDVMUgTCnQE/9IetxrnK4bKgIZ7R9vgmz1PZ Fv2vKQgxZDjxwz/UDOHFKnbiM1coJnIBw+vvPrvqKyRSmdCuxtIqLJFaEgtl7A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 687181F19D; Thu, 27 Jan 2022 22:39:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20RMdhWX098372; Thu, 27 Jan 2022 22:39:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20RMdhcE098371; Thu, 27 Jan 2022 22:39:43 GMT (envelope-from git) Date: Thu, 27 Jan 2022 22:39:43 GMT Message-Id: <202201272239.20RMdhcE098371@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vincenzo Maffione Subject: git: cf101bd5ceeb - stable/12 - net: iflib: fix vlan processing in the drivers List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vmaffione X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: cf101bd5ceebe2b2d229faa949dbf3e146d04382 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643323184; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=FWmbXUOGlWVrDHDUV5I8mBeHdLr1DJyE4N3KY46InVQ=; b=rAUZjULzq2oaMGaEuVYiNvR/lAKa5nkFla1+AUdP8qywxGOqKEAlrkhvm42p3gT502kSEi nYBm5C5GPUPJNdEtdACOGv3ej8tYK6Nfd6y+iHtr42q+xIxhmfVbNUHsQZ9uIgmskBIrC5 spY0cWs4oYrj1VsjnYfKc/hkTUozWj/EaByhCoyVK1d1kir+CY0Wgij9pUwoGYmepAS0gq Vlth+fPt3c3aZGYtEAJsECPC+UswlEzNr5TVCl1ND8Xs0oF5Qn2M+3VQz2Ebv9D6xW0HCb fjtPI27FbZT2cSxvKhNasr0vFLZxmxtM0U44gdkyYv0grwxCPHJtD2aOBo+rQQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1643323184; a=rsa-sha256; cv=none; b=e8B8m2vx3jKhPrSBvdqWi+LE5jIJ47OFYvGoW7Pui9TPeOPP8Ld8ZrYb00tTbvJ9WQGPde f6jFDdZkkPStYAB47Fxavuya3fp2lUzdjS65OIxvlu9eBRCVedIuefhU4/lDGsOerCpxb4 qtvfiXMKMebtdOI4EMZ+hxpbWT/h13grrT2jnHtcNCAFNYi6T3dTtsKDS7MMumq9b6cE04 HRdB/M1Y9NeTbEArRriFgB7pmCUEtyBEh9lcLDjfzzDsOTN9qOWglyRDW3wMBCDqKN6e7v 0d5C+TrMZ2W8uxOPO4zD7KO+PkTVmt9FTh1RzMNLl5YnPZ/htQrxKwje24KlVg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by vmaffione: URL: https://cgit.FreeBSD.org/src/commit/?id=cf101bd5ceebe2b2d229faa949dbf3e146d04382 commit cf101bd5ceebe2b2d229faa949dbf3e146d04382 Author: Vincenzo Maffione AuthorDate: 2021-12-28 11:05:31 +0000 Commit: Vincenzo Maffione CommitDate: 2022-01-27 22:32:58 +0000 net: iflib: fix vlan processing in the drivers The logic that sets iri_vtag and M_VLANTAG does not handle the case where the 802.11q VLAN tag is 0. Fix this issue across the iflib drivers. While there, also improve and align the VLAN tag check extraction, by moving it outside the RX descriptor loop, eliminating a local variable and additional checks. PR: 260068 Reviewed by: kbowling, gallatin Reported by: erj MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D33156 (cherry picked from commit f7926a6d0c1029c8da265769e7c57b4065faa2df) --- sys/dev/e1000/em_txrx.c | 11 ++++------- sys/dev/e1000/igb_txrx.c | 21 +++++++++------------ sys/dev/ice/ice_iflib_txrx.c | 13 +++++-------- sys/dev/igc/igc_txrx.c | 8 +++----- sys/dev/ixgbe/ix_txrx.c | 15 +++++---------- sys/dev/ixl/ixl_txrx.c | 13 +++++-------- 6 files changed, 31 insertions(+), 50 deletions(-) diff --git a/sys/dev/e1000/em_txrx.c b/sys/dev/e1000/em_txrx.c index 58f9345ea19d..aebafca73cca 100644 --- a/sys/dev/e1000/em_txrx.c +++ b/sys/dev/e1000/em_txrx.c @@ -671,9 +671,9 @@ em_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri) 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_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri) 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 index 548ceee8ab46..1c1500e78d19 100644 --- a/sys/dev/e1000/igb_txrx.c +++ b/sys/dev/e1000/igb_txrx.c @@ -436,12 +436,12 @@ igb_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri) 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 @@ igb_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri) 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++; @@ -495,9 +488,13 @@ igb_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri) if ((scctx->isc_capenable & 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/ice/ice_iflib_txrx.c b/sys/dev/ice/ice_iflib_txrx.c index 7d89c51ddec0..0ce59d96c0ed 100644 --- a/sys/dev/ice/ice_iflib_txrx.c +++ b/sys/dev/ice/ice_iflib_txrx.c @@ -285,7 +285,7 @@ ice_ift_rxd_pkt_get(void *arg, if_rxd_info_t ri) if_softc_ctx_t scctx = sc->scctx; 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; @@ -310,10 +310,6 @@ ice_ift_rxd_pkt_get(void *arg, if_rxd_info_t ri) 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. @@ -340,10 +336,11 @@ ice_ift_rxd_pkt_get(void *arg, if_rxd_info_t ri) &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 index ee4d5a5c0c6b..4f8234c855f6 100644 --- a/sys/dev/igc/igc_txrx.c +++ b/sys/dev/igc/igc_txrx.c @@ -461,12 +461,12 @@ igc_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri) 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 @@ igc_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri) 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++; @@ -517,7 +515,7 @@ igc_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri) if ((scctx->isc_capenable & 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 index 7c87b0ec10fc..589f4c72c9ce 100644 --- a/sys/dev/ixgbe/ix_txrx.c +++ b/sys/dev/ixgbe/ix_txrx.c @@ -399,7 +399,6 @@ ixgbe_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri) 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 @@ ixgbe_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri) 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 @@ ixgbe_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri) 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 index ac3840362d80..16d46d128316 100644 --- a/sys/dev/ixl/ixl_txrx.c +++ b/sys/dev/ixl/ixl_txrx.c @@ -663,7 +663,7 @@ ixl_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri) 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; @@ -694,10 +694,6 @@ ixl_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri) 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, @@ -724,10 +720,11 @@ ixl_isc_rxd_pkt_get(void *arg, if_rxd_info_t ri) 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); }