Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Nguyen <anthony.l.nguyen@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH S45 13/15] ice: Fix transmit for all software offloaded VLANs
Date: Fri, 15 May 2020 17:51:19 -0700	[thread overview]
Message-ID: <20200516005121.4963-13-anthony.l.nguyen@intel.com> (raw)
In-Reply-To: <20200516005121.4963-1-anthony.l.nguyen@intel.com>

From: Brett Creeley <brett.creeley@intel.com>

Currently the driver does not recognize when there is an 802.1AD VLAN
tag right after the dmac/smac (outermost VLAN tag). If any DCB map is
applied and/or DCB is enabled this is causing the hardware to insert a
VLAN 0 tag after the 802.1AD VLAN tag that is already in the packet.
Fix this by preventing VLAN tag 0 from being added when any VLAN is
already present after dmac/smac (software offloaded) or skb (hardware
offloaded).

Signed-off-by: Brett Creeley <brett.creeley@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 28 +++++-------
 drivers/net/ethernet/intel/ice/ice_dcb_lib.h |  2 +-
 drivers/net/ethernet/intel/ice/ice_txrx.c    | 45 +++++---------------
 3 files changed, 21 insertions(+), 54 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_dcb_lib.c b/drivers/net/ethernet/intel/ice/ice_dcb_lib.c
index d5055d9e3fd2..663d29c0f4a4 100644
--- a/drivers/net/ethernet/intel/ice/ice_dcb_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_dcb_lib.c
@@ -828,39 +828,31 @@ void ice_update_dcb_stats(struct ice_pf *pf)
  * ice_tx_prepare_vlan_flags_dcb - prepare VLAN tagging for DCB
  * @tx_ring: ring to send buffer on
  * @first: pointer to struct ice_tx_buf
+ *
+ * This should not be called if the outer VLAN is software offloaded as the VLAN
+ * tag will already be configured with the correct ID and priority bits
  */
-int
+void
 ice_tx_prepare_vlan_flags_dcb(struct ice_ring *tx_ring,
 			      struct ice_tx_buf *first)
 {
 	struct sk_buff *skb = first->skb;
 
 	if (!test_bit(ICE_FLAG_DCB_ENA, tx_ring->vsi->back->flags))
-		return 0;
+		return;
 
 	/* Insert 802.1p priority into VLAN header */
-	if ((first->tx_flags & (ICE_TX_FLAGS_HW_VLAN | ICE_TX_FLAGS_SW_VLAN)) ||
+	if ((first->tx_flags & ICE_TX_FLAGS_HW_VLAN) ||
 	    skb->priority != TC_PRIO_CONTROL) {
 		first->tx_flags &= ~ICE_TX_FLAGS_VLAN_PR_M;
 		/* Mask the lower 3 bits to set the 802.1p priority */
 		first->tx_flags |= (skb->priority & 0x7) <<
 				   ICE_TX_FLAGS_VLAN_PR_S;
-		if (first->tx_flags & ICE_TX_FLAGS_SW_VLAN) {
-			struct vlan_ethhdr *vhdr;
-			int rc;
-
-			rc = skb_cow_head(skb, 0);
-			if (rc < 0)
-				return rc;
-			vhdr = (struct vlan_ethhdr *)skb->data;
-			vhdr->h_vlan_TCI = htons(first->tx_flags >>
-						 ICE_TX_FLAGS_VLAN_S);
-		} else {
-			first->tx_flags |= ICE_TX_FLAGS_HW_VLAN;
-		}
+		/* if this is not already set it means a VLAN 0 + priority needs
+		 * to be offloaded
+		 */
+		first->tx_flags |= ICE_TX_FLAGS_HW_VLAN;
 	}
-
-	return 0;
 }
 
 /**
diff --git a/drivers/net/ethernet/intel/ice/ice_dcb_lib.h b/drivers/net/ethernet/intel/ice/ice_dcb_lib.h
index a7a5d9833a93..c76cca3e489e 100644
--- a/drivers/net/ethernet/intel/ice/ice_dcb_lib.h
+++ b/drivers/net/ethernet/intel/ice/ice_dcb_lib.h
@@ -27,7 +27,7 @@ void ice_pf_dcb_recfg(struct ice_pf *pf);
 void ice_vsi_cfg_dcb_rings(struct ice_vsi *vsi);
 int ice_init_pf_dcb(struct ice_pf *pf, bool locked);
 void ice_update_dcb_stats(struct ice_pf *pf);
-int
+void
 ice_tx_prepare_vlan_flags_dcb(struct ice_ring *tx_ring,
 			      struct ice_tx_buf *first);
 void
diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c b/drivers/net/ethernet/intel/ice/ice_txrx.c
index 4b1a7ab147f8..4d08e4756f50 100644
--- a/drivers/net/ethernet/intel/ice/ice_txrx.c
+++ b/drivers/net/ethernet/intel/ice/ice_txrx.c
@@ -2037,49 +2037,25 @@ int ice_tx_csum(struct ice_tx_buf *first, struct ice_tx_offload_params *off)
  *
  * Checks the skb and set up correspondingly several generic transmit flags
  * related to VLAN tagging for the HW, such as VLAN, DCB, etc.
- *
- * Returns error code indicate the frame should be dropped upon error and the
- * otherwise returns 0 to indicate the flags has been set properly.
  */
-static int
+static void
 ice_tx_prepare_vlan_flags(struct ice_ring *tx_ring, struct ice_tx_buf *first)
 {
 	struct sk_buff *skb = first->skb;
-	__be16 protocol = skb->protocol;
-
-	if (protocol == htons(ETH_P_8021Q) &&
-	    !(tx_ring->netdev->features & NETIF_F_HW_VLAN_CTAG_TX)) {
-		/* when HW VLAN acceleration is turned off by the user the
-		 * stack sets the protocol to 8021q so that the driver
-		 * can take any steps required to support the SW only
-		 * VLAN handling. In our case the driver doesn't need
-		 * to take any further steps so just set the protocol
-		 * to the encapsulated ethertype.
-		 */
-		skb->protocol = vlan_get_protocol(skb);
-		return 0;
-	}
 
-	/* if we have a HW VLAN tag being added, default to the HW one */
+	/* nothing left to do, software offloaded VLAN */
+	if (!skb_vlan_tag_present(skb) && eth_type_vlan(skb->protocol))
+		return;
+
+	/* currently, we always assume 802.1Q for VLAN insertion as VLAN
+	 * insertion for 802.1AD is not supported
+	 */
 	if (skb_vlan_tag_present(skb)) {
 		first->tx_flags |= skb_vlan_tag_get(skb) << ICE_TX_FLAGS_VLAN_S;
 		first->tx_flags |= ICE_TX_FLAGS_HW_VLAN;
-	} else if (protocol == htons(ETH_P_8021Q)) {
-		struct vlan_hdr *vhdr, _vhdr;
-
-		/* for SW VLAN, check the next protocol and store the tag */
-		vhdr = (struct vlan_hdr *)skb_header_pointer(skb, ETH_HLEN,
-							     sizeof(_vhdr),
-							     &_vhdr);
-		if (!vhdr)
-			return -EINVAL;
-
-		first->tx_flags |= ntohs(vhdr->h_vlan_TCI) <<
-				   ICE_TX_FLAGS_VLAN_S;
-		first->tx_flags |= ICE_TX_FLAGS_SW_VLAN;
 	}
 
-	return ice_tx_prepare_vlan_flags_dcb(tx_ring, first);
+	ice_tx_prepare_vlan_flags_dcb(tx_ring, first);
 }
 
 /**
@@ -2387,8 +2363,7 @@ ice_xmit_frame_ring(struct sk_buff *skb, struct ice_ring *tx_ring)
 	first->tx_flags = 0;
 
 	/* prepare the VLAN tagging flags for Tx */
-	if (ice_tx_prepare_vlan_flags(tx_ring, first))
-		goto out_drop;
+	ice_tx_prepare_vlan_flags(tx_ring, first);
 
 	/* set up TSO offload */
 	tso = ice_tso(first, &offload);
-- 
2.20.1


  parent reply	other threads:[~2020-05-16  0:51 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-16  0:51 [Intel-wired-lan] [PATCH S45 01/15] ice: Refactor ice_ena_vf_mappings to split MSIX and queue mappings Tony Nguyen
2020-05-16  0:51 ` [Intel-wired-lan] [PATCH S45 02/15] ice: Simplify ice_sriov_configure Tony Nguyen
2020-05-28 21:39   ` Bowers, AndrewX
2020-05-16  0:51 ` [Intel-wired-lan] [PATCH S45 03/15] ice: Add helper function for clearing VPGEN_VFRTRIG Tony Nguyen
2020-05-28 21:39   ` Bowers, AndrewX
2020-05-16  0:51 ` [Intel-wired-lan] [PATCH S45 04/15] ice: Separate VF VSI initialization/creation from reset flow Tony Nguyen
2020-05-28 21:40   ` Bowers, AndrewX
2020-05-16  0:51 ` [Intel-wired-lan] [PATCH S45 05/15] ice: Renaming and simplification in VF init path Tony Nguyen
2020-05-28 21:40   ` Bowers, AndrewX
2020-05-16  0:51 ` [Intel-wired-lan] [PATCH S45 06/15] ice: Add function to set trust mode bit on reset Tony Nguyen
2020-05-28 21:41   ` Bowers, AndrewX
2020-05-16  0:51 ` [Intel-wired-lan] [PATCH S45 07/15] ice: Add functions to rebuild host VLAN/MAC config for a VF Tony Nguyen
2020-05-28 21:41   ` Bowers, AndrewX
2020-05-16  0:51 ` [Intel-wired-lan] [PATCH S45 08/15] ice: remove VM/VF disable command on CORER/GLOBR reset Tony Nguyen
2020-05-28 21:41   ` Bowers, AndrewX
2020-05-16  0:51 ` [Intel-wired-lan] [PATCH S45 09/15] ice: Refactor VF reset Tony Nguyen
2020-05-28 21:42   ` Bowers, AndrewX
2020-05-16  0:51 ` [Intel-wired-lan] [PATCH S45 10/15] ice: Refactor VF VSI release and setup functions Tony Nguyen
2020-05-28 21:42   ` Bowers, AndrewX
2020-05-16  0:51 ` [Intel-wired-lan] [PATCH S45 11/15] ice: allow host to clear administratively set VF MAC Tony Nguyen
2020-05-28 21:43   ` Bowers, AndrewX
2020-05-16  0:51 ` [Intel-wired-lan] [PATCH S45 12/15] ice: support adding 16 unicast/multicast filter on untrusted VF Tony Nguyen
2020-05-28 21:43   ` Bowers, AndrewX
2020-05-16  0:51 ` Tony Nguyen [this message]
2020-05-28 21:44   ` [Intel-wired-lan] [PATCH S45 13/15] ice: Fix transmit for all software offloaded VLANs Bowers, AndrewX
2020-05-16  0:51 ` [Intel-wired-lan] [PATCH S45 14/15] ice: Increase timeout after PFR Tony Nguyen
2020-05-28 21:44   ` Bowers, AndrewX
2020-05-16  0:51 ` [Intel-wired-lan] [PATCH S45 15/15] ice: Update ICE_PHY_TYPE_HIGH_MAX_INDEX value Tony Nguyen
2020-05-28 21:44   ` Bowers, AndrewX
2020-05-28 21:38 ` [Intel-wired-lan] [PATCH S45 01/15] ice: Refactor ice_ena_vf_mappings to split MSIX and queue mappings Bowers, AndrewX

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200516005121.4963-13-anthony.l.nguyen@intel.com \
    --to=anthony.l.nguyen@intel.com \
    --cc=intel-wired-lan@osuosl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox