From: Jakub Kicinski <kuba@kernel.org>
To: wei.fang@nxp.com
Cc: Jakub Kicinski <kuba@kernel.org>,
claudiu.manoil@nxp.com, vladimir.oltean@nxp.com,
xiaoning.wang@nxp.com, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, pabeni@redhat.com,
robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
f.fainelli@gmail.com, frank.li@nxp.com, chleroy@kernel.org,
horms@kernel.org, linux@armlinux.org.uk, andrew@lunn.ch,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev
Subject: Re: [PATCH v4 net-next 09/14] net: dsa: add NETC switch tag support
Date: Thu, 2 Apr 2026 18:17:36 -0700 [thread overview]
Message-ID: <20260403011736.1795610-1-kuba@kernel.org> (raw)
In-Reply-To: <20260331113025.1566878-10-wei.fang@nxp.com>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
---
net: dsa: add NETC switch tag support
Adds support for the proprietary NXP NETC switch tag used in NXP NETC
switches version 4.3 or later. The tag has 3 types (Forward, To_Port,
To_Host) and supports a varying length between 6 and 14 bytes.
> diff --git a/net/dsa/tag_netc.c b/net/dsa/tag_netc.c
> new file mode 100644
> index 000000000000..addd41f7f1b6
> --- /dev/null
> +++ b/net/dsa/tag_netc.c
[ ... ]
> +static void *netc_fill_common_tp_tag(struct sk_buff *skb,
> + struct net_device *ndev,
> + u8 subtype, int tag_len)
> +{
> + struct dsa_port *dp = dsa_user_to_port(ndev);
> + u16 queue = skb_get_queue_mapping(skb);
> + u8 ipv = netdev_txq_to_tc(ndev, queue);
What happens here if the interface doesn't have traffic classes configured?
By default, netdev_txq_to_tc() returns -1. Because ipv is an unsigned 8-bit
integer, this casts to 255.
When this is later passed to FIELD_PREP(NETC_TAG_IPV, ipv) in
netc_fill_common_tag(), the macro blindly masks the variable, silently
forcing the IPV field to 7 (the maximum priority) for all default,
unconfigured traffic. Valid TC values greater than 7 would also be silently
truncated.
Does this code bypass the intended QoS mechanisms?
> + void *tag;
> +
> + skb_push(skb, tag_len);
> + dsa_alloc_etype_header(skb, tag_len);
> +
> + tag = dsa_etype_header_pos_tx(skb);
> + memset(tag + NETC_TAG_CMN_LEN, 0, tag_len - NETC_TAG_CMN_LEN);
> + netc_fill_common_tag(tag, NETC_TAG_TO_PORT, subtype,
> + dp->ds->index, dp->index, ipv);
Will this break communication for standard single-switch setups?
The driver passes dp->ds->index as the hardware switch ID here, which
defaults to 0 for the first switch in a DSA tree. However, on the receive
path, frames stamped with switch ID 0 are rejected.
If the physical switch hardware uses an ID greater than 0, frames will fail
the lookup in dsa_conduit_find_user() on receive because the software index
is 0.
> +
> + return tag;
> +}
[ ... ]
> +static struct sk_buff *netc_rcv(struct sk_buff *skb,
> + struct net_device *ndev)
> +{
> + struct netc_tag_cmn *tag_cmn;
> + int tag_len, sw_id, port;
[ ... ]
> + if (tag_cmn->qos & NETC_TAG_QV)
> + skb->priority = FIELD_GET(NETC_TAG_IPV, tag_cmn->qos);
> +
> + sw_id = NETC_TAG_SWITCH & tag_cmn->switch_port;
This isn't a bug, but is there a reason to use a raw bitwise AND for sw_id
instead of using FIELD_GET(NETC_TAG_SWITCH, ...) to match how the port
field is extracted just below this?
> + /* ENETC VEPA switch ID (0) is not supported yet */
> + if (!sw_id) {
> + dev_warn_ratelimited(&ndev->dev,
> + "VEPA switch ID is not supported yet\n");
> +
> + return NULL;
> + }
> +
> + port = FIELD_GET(NETC_TAG_PORT, tag_cmn->switch_port);
> + skb->dev = dsa_conduit_find_user(ndev, sw_id, port);
[ ... ]
next prev parent reply other threads:[~2026-04-03 1:17 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-31 11:30 [PATCH v4 net-next 00/14] Add preliminary NETC switch support for i.MX94 Wei Fang
2026-03-31 11:30 ` [PATCH v4 net-next 01/14] dt-bindings: net: dsa: update the description of 'dsa,member' property Wei Fang
2026-03-31 11:30 ` [PATCH v4 net-next 02/14] dt-bindings: net: dsa: add NETC switch Wei Fang
2026-03-31 11:30 ` [PATCH v4 net-next 03/14] net: enetc: add pre-boot initialization for i.MX94 switch Wei Fang
2026-04-03 1:17 ` Jakub Kicinski
2026-03-31 11:30 ` [PATCH v4 net-next 04/14] net: enetc: add basic operations to the FDB table Wei Fang
2026-04-03 1:17 ` Jakub Kicinski
2026-03-31 11:30 ` [PATCH v4 net-next 05/14] net: enetc: add support for the "Add" operation to VLAN filter table Wei Fang
2026-04-03 1:17 ` Jakub Kicinski
2026-03-31 11:30 ` [PATCH v4 net-next 06/14] net: enetc: add support for the "Update" operation to buffer pool table Wei Fang
2026-04-03 1:17 ` Jakub Kicinski
2026-03-31 11:30 ` [PATCH v4 net-next 07/14] net: enetc: add support for "Add" and "Delete" operations to IPFT Wei Fang
2026-04-03 1:17 ` Jakub Kicinski
2026-03-31 11:30 ` [PATCH v4 net-next 08/14] net: enetc: add multiple command BD rings support Wei Fang
2026-03-31 11:30 ` [PATCH v4 net-next 09/14] net: dsa: add NETC switch tag support Wei Fang
2026-04-03 1:17 ` Jakub Kicinski [this message]
2026-03-31 11:30 ` [PATCH v4 net-next 10/14] net: dsa: netc: introduce NXP NETC switch driver for i.MX94 Wei Fang
2026-04-03 1:17 ` Jakub Kicinski
2026-03-31 11:30 ` [PATCH v4 net-next 11/14] net: dsa: netc: add phylink MAC operations Wei Fang
2026-04-03 1:17 ` Jakub Kicinski
2026-03-31 11:30 ` [PATCH v4 net-next 12/14] net: dsa: netc: add more basic functions support Wei Fang
2026-04-03 1:17 ` Jakub Kicinski
2026-03-31 11:30 ` [PATCH v4 net-next 13/14] net: dsa: netc: initialize buffer bool table and implement flow-control Wei Fang
2026-04-03 1:17 ` Jakub Kicinski
2026-03-31 11:30 ` [PATCH v4 net-next 14/14] net: dsa: netc: add support for the standardized counters Wei Fang
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=20260403011736.1795610-1-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=chleroy@kernel.org \
--cc=claudiu.manoil@nxp.com \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=frank.li@nxp.com \
--cc=horms@kernel.org \
--cc=imx@lists.linux.dev \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=robh@kernel.org \
--cc=vladimir.oltean@nxp.com \
--cc=wei.fang@nxp.com \
--cc=xiaoning.wang@nxp.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