From patchwork Fri Dec 1 22:39:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13476557 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="X3WluVq7" Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [IPv6:2607:f8b0:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB752AD for ; Fri, 1 Dec 2023 14:39:59 -0800 (PST) Received: by mail-oi1-x22c.google.com with SMTP id 5614622812f47-3b837d974ecso751485b6e.2 for ; Fri, 01 Dec 2023 14:39:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1701470399; x=1702075199; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=4yiwMsA8+UUMeDOCdekRJ3Fxueivu0rDI11CiMc87iw=; b=X3WluVq7LmgsIxxFSwWOdVnUht7UhGS5KjB8Vw0TnUqPf7a2tn2lXnminHFsON9wF8 jw+ccz4dLAJaU8EN6yaW6yN14SQjHU4QfbNMQl5GrSP0xSILQZdl6lBVFLwGrVjWiMre 4vTR/TrOjZSCrQOzkhTEBq1uiAPEfbv3ccivE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701470399; x=1702075199; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4yiwMsA8+UUMeDOCdekRJ3Fxueivu0rDI11CiMc87iw=; b=RJMWhYupP/U+NZkiJ2taZpO1rdlKCiPrnCbRj0xeHTHwz0/DMWss5AVhAglfZvz/5g BbF9gUMK8UlQ3cFLsZRRzJpCg9yeZrJ1WodrGuHkLB35f0cnlS1dHeg1qOFoX6NAPUaY pu3Sf3w+X27HReGUVC8Q/VMql/lOSDF5X20Y31kH3FWC4JZFJhHnaKQ78/qA21HXQ2H3 vEkRqsvuDN3g0zZCs/8u92qhopzNxysve4C4NfYYtvYkJ5KU1Ea9BdGf8FT0HhYV/Mzr /enlbdZi4g5VPS19PCnQlqlNwHuvEMprCQR70if0PRAZoKVDdeZs5BKaZNtP3tu7VTPM ImWQ== X-Gm-Message-State: AOJu0Yx6qhWOLRvyQyKhQy0ZQ13iuiJ74R1uKO4Bvyc4g+DxSmD1F3Ec 8hMc6IDyIJu0l71B1+l+Jj6s/w== X-Google-Smtp-Source: AGHT+IHme3sfXC3bk1JsNMYxLxymJ1StnwS0wjw+SrzguU/xV+UZuHlM9gxtPm4fLLUdFrFoukFc3g== X-Received: by 2002:a05:6808:14c6:b0:3b8:b063:adf1 with SMTP id f6-20020a05680814c600b003b8b063adf1mr319848oiw.78.1701470399116; Fri, 01 Dec 2023 14:39:59 -0800 (PST) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id i14-20020ac8488e000000b004199c98f87dsm1878715qtq.74.2023.12.01.14.39.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Dec 2023 14:39:58 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, gospo@broadcom.com, Pavan Chebbi Subject: [PATCH net-next 08/15] bnxt_en: Refactor RX VLAN acceleration logic. Date: Fri, 1 Dec 2023 14:39:17 -0800 Message-Id: <20231201223924.26955-9-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20231201223924.26955-1-michael.chan@broadcom.com> References: <20231201223924.26955-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org 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 Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 44 ++++++++++++++++------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index b38c17a27903..9aca38b6f196 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -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);