From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
andrew+netdev@lunn.ch, horms@kernel.org,
michael.chan@broadcom.com, pavan.chebbi@broadcom.com,
przemyslaw.kitszel@intel.com, Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next v3 07/10] eth: bnxt: extract VLAN info early on
Date: Wed, 5 Mar 2025 14:52:12 -0800 [thread overview]
Message-ID: <20250305225215.1567043-8-kuba@kernel.org> (raw)
In-Reply-To: <20250305225215.1567043-1-kuba@kernel.org>
Michael would like the SW stats to include VLAN bytes, perhaps
uniquely among ethernet drivers. To do this we need to extract
the VLAN info before we call XDP, so before skb is allocated.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 42 ++++++++++-------------
1 file changed, 18 insertions(+), 24 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index dba4779f0925..b0a9e3c6b377 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -1966,45 +1966,36 @@ static bool bnxt_rx_ts_valid(struct bnxt *bp, u32 flags,
return true;
}
-static struct sk_buff *bnxt_rx_vlan(struct sk_buff *skb, u8 cmp_type,
- struct rx_cmp *rxcmp,
- struct rx_cmp_ext *rxcmp1)
+static u32
+bnxt_rx_vlan(u8 cmp_type, struct rx_cmp *rxcmp, struct rx_cmp_ext *rxcmp1)
{
- __be16 vlan_proto;
- u16 vtag;
+ u16 vlan_proto = 0, vtag = 0;
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;
+ return 0;
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;
+ vlan_proto = meta_data >> RX_CMP_FLAGS2_METADATA_TPID_SFT;
} else if (cmp_type == CMP_TYPE_RX_L2_V3_CMP) {
if (RX_CMP_VLAN_VALID(rxcmp)) {
u32 tpid_sel = RX_CMP_VLAN_TPID_SEL(rxcmp);
if (tpid_sel == RX_CMP_METADATA1_TPID_8021Q)
- vlan_proto = htons(ETH_P_8021Q);
+ vlan_proto = ETH_P_8021Q;
else if (tpid_sel == RX_CMP_METADATA1_TPID_8021AD)
- vlan_proto = htons(ETH_P_8021AD);
+ vlan_proto = ETH_P_8021AD;
else
- goto vlan_err;
+ vlan_proto = 0xffff;
vtag = RX_CMP_METADATA0_TCI(rxcmp1);
- __vlan_hwaccel_put_tag(skb, vlan_proto, vtag);
}
}
- return skb;
-vlan_err:
- dev_kfree_skb(skb);
- return NULL;
+
+ return (u32)vlan_proto << 16 | vtag;
}
static enum pkt_hash_types bnxt_rss_ext_op(struct bnxt *bp,
@@ -2049,6 +2040,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
struct sk_buff *skb;
struct xdp_buff xdp;
u32 flags, misc;
+ u32 vlan_info;
u32 cmpl_ts;
void *data;
int rc = 0;
@@ -2163,6 +2155,10 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
if (cmp_type == CMP_TYPE_RX_L2_CMP)
dev = bnxt_get_pkt_dev(bp, RX_CMP_CFA_CODE(rxcmp1));
+ vlan_info = bnxt_rx_vlan(cmp_type, rxcmp, rxcmp1);
+ if (vlan_info && !eth_type_vlan(htons(vlan_info >> 16)))
+ goto next_rx;
+
if (bnxt_xdp_attached(bp, rxr)) {
bnxt_xdp_buff_init(bp, rxr, cons, data_ptr, len, &xdp);
if (agg_bufs) {
@@ -2246,11 +2242,9 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
skb->protocol = eth_type_trans(skb, dev);
- if (skb->dev->features & BNXT_HW_FEATURE_VLAN_ALL_RX) {
- skb = bnxt_rx_vlan(skb, cmp_type, rxcmp, rxcmp1);
- if (!skb)
- goto next_rx;
- }
+ if (vlan_info && skb->dev->features & BNXT_HW_FEATURE_VLAN_ALL_RX)
+ __vlan_hwaccel_put_tag(skb, htons(vlan_info >> 16),
+ vlan_info & 0xffff);
skb_checksum_none_assert(skb);
if (RX_CMP_L4_CS_OK(rxcmp1)) {
--
2.48.1
next prev parent reply other threads:[~2025-03-05 22:52 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-05 22:52 [PATCH net-next v3 00/10] eth: bnxt: maintain basic pkt/byte counters in SW Jakub Kicinski
2025-03-05 22:52 ` [PATCH net-next v3 01/10] eth: bnxt: use napi_consume_skb() Jakub Kicinski
2025-03-05 22:52 ` [PATCH net-next v3 02/10] eth: bnxt: don't run xdp programs on fallback traffic Jakub Kicinski
2025-03-05 22:52 ` [PATCH net-next v3 03/10] eth: bnxt: rename ring_err_stats -> ring_drv_stats Jakub Kicinski
2025-03-05 22:52 ` [PATCH net-next v3 04/10] eth: bnxt: snapshot driver stats Jakub Kicinski
2025-03-05 22:52 ` [PATCH net-next v3 05/10] eth: bnxt: don't use ifdef to check for CONFIG_INET in GRO Jakub Kicinski
2025-03-05 22:52 ` [PATCH net-next v3 06/10] eth: bnxt: consolidate the GRO-but-not-really paths in bnxt_gro_skb() Jakub Kicinski
2025-03-05 22:52 ` Jakub Kicinski [this message]
2025-03-05 22:52 ` [PATCH net-next v3 08/10] eth: bnxt: maintain rx pkt/byte stats in SW Jakub Kicinski
2025-03-05 22:52 ` [PATCH net-next v3 09/10] eth: bnxt: maintain tx " Jakub Kicinski
2025-03-09 8:25 ` Michael Chan
2025-03-05 22:52 ` [PATCH net-next v3 10/10] eth: bnxt: count xdp xmit packets Jakub Kicinski
2025-03-06 10:54 ` [PATCH net-next v3 00/10] eth: bnxt: maintain basic pkt/byte counters in SW Taehee Yoo
2025-03-06 15:24 ` Jakub Kicinski
2025-03-06 19:25 ` Michael Chan
2025-03-07 5:25 ` Taehee Yoo
2025-03-07 5:30 ` Michael Chan
2025-03-07 16:43 ` Jakub Kicinski
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=20250305225215.1567043-8-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=michael.chan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pavan.chebbi@broadcom.com \
--cc=przemyslaw.kitszel@intel.com \
/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;
as well as URLs for NNTP newsgroup(s).