bnxt_en: Refactor RX VLAN acceleration logic.
authorMichael Chan <michael.chan@broadcom.com>
Fri, 1 Dec 2023 22:39:17 +0000 (14:39 -0800)
committerJakub Kicinski <kuba@kernel.org>
Mon, 4 Dec 2023 23:12:48 +0000 (15:12 -0800)
Refactor the logic in the RX path that checks for the accelerated VLAN
tag by adding a new function.  This will make it easier to support
the new receive logic on P7 chips.

Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Link: https://lore.kernel.org/r/20231201223924.26955-9-michael.chan@broadcom.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/broadcom/bnxt/bnxt.c

index b38c17a27903d0695e22f7f48843f8ea895f454b..9aca38b6f196c5a7ee5feebaf96a1a0a9dd0fb36 100644 (file)
@@ -1783,6 +1783,34 @@ static void bnxt_deliver_skb(struct bnxt *bp, struct bnxt_napi *bnapi,
        napi_gro_receive(&bnapi->napi, skb);
 }
 
+static struct sk_buff *bnxt_rx_vlan(struct sk_buff *skb, u8 cmp_type,
+                                   struct rx_cmp *rxcmp,
+                                   struct rx_cmp_ext *rxcmp1)
+{
+       __be16 vlan_proto;
+       u16 vtag;
+
+       if (cmp_type == CMP_TYPE_RX_L2_CMP) {
+               __le32 flags2 = rxcmp1->rx_cmp_flags2;
+               u32 meta_data;
+
+               if (!(flags2 & cpu_to_le32(RX_CMP_FLAGS2_META_FORMAT_VLAN)))
+                       return skb;
+
+               meta_data = le32_to_cpu(rxcmp1->rx_cmp_meta_data);
+               vtag = meta_data & RX_CMP_FLAGS2_METADATA_TCI_MASK;
+               vlan_proto = htons(meta_data >> RX_CMP_FLAGS2_METADATA_TPID_SFT);
+               if (eth_type_vlan(vlan_proto))
+                       __vlan_hwaccel_put_tag(skb, vlan_proto, vtag);
+               else
+                       goto vlan_err;
+       }
+       return skb;
+vlan_err:
+       dev_kfree_skb(skb);
+       return NULL;
+}
+
 /* returns the following:
  * 1       - 1 packet successfully received
  * 0       - successful TPA_START, packet not completed yet
@@ -2001,20 +2029,10 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
        cfa_code = RX_CMP_CFA_CODE(rxcmp1);
        skb->protocol = eth_type_trans(skb, bnxt_get_pkt_dev(bp, cfa_code));
 
-       if ((rxcmp1->rx_cmp_flags2 &
-            cpu_to_le32(RX_CMP_FLAGS2_META_FORMAT_VLAN)) &&
-           (skb->dev->features & BNXT_HW_FEATURE_VLAN_ALL_RX)) {
-               u32 meta_data = le32_to_cpu(rxcmp1->rx_cmp_meta_data);
-               u16 vtag = meta_data & RX_CMP_FLAGS2_METADATA_TCI_MASK;
-               __be16 vlan_proto = htons(meta_data >>
-                                         RX_CMP_FLAGS2_METADATA_TPID_SFT);
-
-               if (eth_type_vlan(vlan_proto)) {
-                       __vlan_hwaccel_put_tag(skb, vlan_proto, vtag);
-               } else {
-                       dev_kfree_skb(skb);
+       if (skb->dev->features & BNXT_HW_FEATURE_VLAN_ALL_RX) {
+               skb = bnxt_rx_vlan(skb, cmp_type, rxcmp, rxcmp1);
+               if (!skb)
                        goto next_rx;
-               }
        }
 
        skb_checksum_none_assert(skb);