From: sashiko-bot@kernel.org
To: "Florian Fainelli" <florian.fainelli@broadcom.com>
Cc: "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS"
<devicetree@vger.kernel.org>,
robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH net-next 5/9] net: dsa: add Broadcom FA metadata and IPv4 exception paths
Date: Tue, 17 Nov 2026 22:33:59 +0000 [thread overview]
Message-ID: <sashiko-outbox-219753@kernel.org> (raw)
In-Reply-To: <20261116222519.1416501-6-florian.fainelli@broadcom.com>
Thank you for your contribution! Sashiko AI review found 7 potential
issues to consider:
- [Medium] net: dsa: b53: broken guard error handling in
b53_fa_netdev_event()
- [Medium] net: dsa: b53: unrecorded standalone port on b53_fa_port()
failure
- [Medium] net: dsa: b53: missing CPU port 5 in non-default VLANs in
b53_vlan_add()
- [Medium] net: dsa: b53: active fa_netdev_nb during teardown and
b53_switch_shutdown()
- [Medium] net: dsa: tag_brcm: brcm_tag_rcv_ll() reads prepended tag as
MAC DA
- [Low] net: dsa: b53: duplicate CFP rule programming in b53_fa_setup()
- [Low] net: dsa: b53: unlocked fa_guards_ready access in
b53_switch_register()
--
commit 5efa0c79a851eb8221145c59826df5a46728bb31
Author: Florian Fainelli <florian.fainelli@broadcom.com>
net: dsa: add Broadcom FA metadata and IPv4 exception paths
This commit adds a brcm-fa DSA tag driver for the Broadcom Northstar flow
accelerator on port 8 and configures B53 CFP rules to redirect IPv4
exception traffic and router-MAC guard misses to auxiliary CPU port 5.
> diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
> index b7aff5e238e85..3e8c9679836d3 100644
> --- a/drivers/net/dsa/b53/b53_common.c
> +++ b/drivers/net/dsa/b53/b53_common.c
[ ... ]
> +static int b53_fa_rule(struct b53_device *dev, unsigned int index,
> + const u32 data[8], const u32 mask[8], bool trap)
> +{
> + unsigned int i;
> + int err;
> +
> + for (i = 0; i < 8; i++) {
> + err = b53_write32(dev, B53_CFP_TCAM_PAGE, B53_CFP_DATA(i), data[i]);
> + if (!err)
> + err = b53_write32(dev, B53_CFP_TCAM_PAGE, B53_CFP_MASK(i), mask[i]);
> + if (err)
> + return err;
> + }
> + err = b53_write32(dev, B53_CFP_TCAM_PAGE, B53_CFP_ACTION(0),
> + trap ? CFP_ACT0_FWD_MAP_REPLACE | CFP_ACT0_DST_PORT5 |
> + CFP_ACT0_REASON_TERMINATION : 0);
> + if (!err)
> + err = b53_write32(dev, B53_CFP_TCAM_PAGE, B53_CFP_ACTION(1),
> + trap ? CFP_ACT1_CLASS_ID(1) | CFP_ACT1_FWD_MAP_REPLACE |
> + CFP_ACT1_DST_PORT5 : 0);
> + if (!err)
> + err = b53_fa_cfp_write(dev, index, CFP_ACC_ACTION);
> + if (!err)
> + err = b53_write32(dev, B53_CFP_TCAM_PAGE, B53_CFP_METER, 0);
> + if (!err)
> + err = b53_write32(dev, B53_CFP_TCAM_PAGE, B53_CFP_METER + 4, 0);
> + if (!err)
> + err = b53_fa_cfp_write(dev, index, CFP_ACC_METER);
> + return err ?: b53_fa_cfp_write(dev, index, CFP_ACC_TCAM);
> +}
[ ... ]
> +static int b53_fa_setup(struct b53_device *dev)
> +{
[ ... ]
> + for (rule = 0; rule < 3; rule++) {
> + memset(data, 0, sizeof(data));
> + memset(mask, 0, sizeof(mask));
> + data[0] = CFP_TCAM0_VALID | CFP_TCAM0_SLICE1 | CFP_TCAM0_UDF0_FLAG(rule);
> + /* Slice 1; FIN, SYN or RST. */
> + mask[0] = CFP_TCAM0_VALID | CFP_TCAM0_SLICE_MASK | CFP_TCAM0_UDF0_FLAG(rule);
> + data[5] = CFP_TCAM5_UDF_VALID(0); /* UDF A0 valid. */
> + mask[5] = CFP_TCAM5_UDF_VALID(0);
> + data[6] = FIELD_PREP(CFP_TCAM6_IP_PROTOCOL, IPPROTO_TCP);
> + mask[6] = CFP_TCAM6_L3_FRAMING | CFP_TCAM6_IP_PROTOCOL | CFP_TCAM6_IP_FRAGMENT;
> + for (i = 0; i < ARRAY_SIZE(data); i++) {
> + err = b53_write32(dev, B53_CFP_TCAM_PAGE, B53_CFP_DATA(i), data[i]);
> + if (!err)
> + err = b53_write32(dev, B53_CFP_TCAM_PAGE, B53_CFP_MASK(i), mask[i]);
> + if (err)
> + return err;
> + }
> + /* Both meter outcomes redirect to IMP5, with class 1 and a
> + * termination reason. Preserve VLAN, EAP and STP filtering.
> + */
> + err = b53_write32(dev, B53_CFP_TCAM_PAGE, B53_CFP_ACTION(0),
> + CFP_ACT0_FWD_MAP_REPLACE | CFP_ACT0_DST_PORT5 |
> + CFP_ACT0_REASON_TERMINATION);
> + if (!err)
> + err = b53_write32(dev, B53_CFP_TCAM_PAGE, B53_CFP_ACTION(1),
> + CFP_ACT1_CLASS_ID(1) | CFP_ACT1_FWD_MAP_REPLACE |
> + CFP_ACT1_DST_PORT5);
> + if (!err)
> + err = b53_fa_cfp_write(dev, rule, CFP_ACC_ACTION);
> + if (!err)
> + err = b53_write32(dev, B53_CFP_TCAM_PAGE, B53_CFP_METER, 0);
> + if (!err)
> + err = b53_write32(dev, B53_CFP_TCAM_PAGE, B53_CFP_METER + 4, 0);
> + if (!err)
> + err = b53_fa_cfp_write(dev, rule, CFP_ACC_METER);
> + if (!err)
> + err = b53_fa_cfp_write(dev, rule, CFP_ACC_TCAM);
> + if (err)
> + return err;
> + }
[Severity: Low]
This isn't a bug, but this loop open-codes b53_fa_rule(dev, rule, data,
mask, true).
[ ... ]
> +static int b53_fa_port(struct b53_device *dev, int port, bool standalone)
> +{
> + struct dsa_port *control = dsa_to_port(dev->ds, 5);
> + bool ready;
> + u16 ports;
> + int err;
> +
> + if (!dev->fa_cfp_enabled)
> + return 0;
> + ports = dev->fa_cfp_ports & ~BIT(port);
> + if (standalone)
> + ports |= BIT(port);
> + ready = b53_fa_ready(dev, dsa_port_conduit_is_operational(control));
> + err = b53_write16(dev, B53_CFP_PAGE, B53_CFP_CTRL,
> + ready ? ports : 0);
> + if (!err)
> + dev->fa_cfp_ports = ports;
> + return err;
> +}
[ ... ]
> +static int b53_fa_netdev_event(struct notifier_block *nb, unsigned long event, void *ptr)
> +{
> + struct b53_device *dev = container_of(nb, struct b53_device, fa_netdev_nb);
> + struct net_device *netdev = netdev_notifier_info_to_dev(ptr);
> + struct dsa_port *dp, *control, *data_cpu;
> + u32 data[8] = {}, mask[8] = {};
> + unsigned int i;
> + int err;
> +
> + if (dev->fa_stopping || !dsa_user_dev_check(netdev) ||
> + (event != NETDEV_REGISTER && event != NETDEV_UP &&
> + event != NETDEV_PRE_CHANGEADDR && event != NETDEV_CHANGEADDR))
> + return NOTIFY_DONE;
> + dp = dsa_port_from_netdev(netdev);
> + if (dp->ds != dev->ds || dp->index >= 8)
> + return NOTIFY_DONE;
> + control = dsa_to_port(dev->ds, 5);
> + data_cpu = dsa_to_port(dev->ds, 8);
> + brcm_fa_control_set_ready(data_cpu->conduit, false);
> + if (event != NETDEV_PRE_CHANGEADDR) {
> + data[0] = CFP_TCAM0_VALID | CFP_TCAM0_SLICE1;
> + mask[0] = CFP_TCAM0_VALID | CFP_TCAM0_SLICE_MASK;
> + mask[6] = CFP_TCAM6_L3_FRAMING;
> + data[7] = BIT(dp->index);
> + mask[7] = CFP_TCAM7_SOURCE_PORTS;
> + for (i = 0; i < 3; i++)
> + b53_fa_udf(data, mask, 3 + i, get_unaligned_be16(netdev->dev_addr + 2 * i),
> + 0xffff);
> + }
> + err = b53_fa_rule(dev, B53_FA_ALLOW_BASE + dp->index, data, mask, false);
> + if (err) {
> + dev->fa_guards_failed = true;
> + dev_err(dev->dev, "failed to update FA ingress guard: %d\n", err);
> + } else if (event != NETDEV_PRE_CHANGEADDR) {
> + b53_fa_conduit_state_change(dev->ds, control->conduit,
> + dsa_port_conduit_is_operational(control));
> + }
> + return NOTIFY_DONE;
> +}
[Severity: Medium]
What restores the port's allow rule at B53_FA_ALLOW_BASE + dp->index if
netif_set_mac_address() fails after NETDEV_PRE_CHANGEADDR?
netif_set_mac_address() emits NETDEV_PRE_CHANGEADDR before calling
ops->ndo_set_mac_address(). If a subsequent notifier or
dsa_user_set_mac_address() rejects the address (for example when
!is_valid_ether_addr()), NETDEV_CHANGEADDR is never sent. The port's
hardware allow rule remains zeroed out and all IPv4 traffic on that port
hits B53_FA_DEFAULT_RULE and traps to CPU port 5, even after another port
event re-enables FA via b53_fa_conduit_state_change().
Also, when b53_fa_rule() fails here, dev->fa_guards_failed is set to true,
but skipping b53_fa_conduit_state_change() leaves B53_CFP_CTRL enabled in
hardware.
[ ... ]
> @@ -2439,6 +2775,10 @@ void b53_br_leave(struct dsa_switch *ds, int port, struct dsa_bridge bridge)
> vl->members |= BIT(port);
> b53_set_vlan_entry(dev, pvid, vl);
> }
> + if (b53_fa_port(dev, port, true)) {
> + dev_err(ds->dev, "failed to restore FA classification on port %d\n", port);
> + b53_disable_port(ds, port);
> + }
> }
[Severity: Medium]
If b53_fa_port(dev, port, true) fails in b53_br_leave(), can a subsequent
ndo_open re-enable the standalone port without CFP classification?
When b53_write16() fails in b53_fa_port(), BIT(port) is not recorded in
dev->fa_cfp_ports and dev->fa_guards_failed is not set. Bringing the port
up later via dsa_user_open() -> b53_enable_port() re-enables Rx/Tx without
setting BIT(5) in B53_PVLAN_PORT_MASK(port), and the following NETDEV_UP
event in b53_fa_netdev_event() writes dev->fa_cfp_ports (still missing
BIT(port)) to B53_CFP_CTRL and re-enables FA admission.
[ ... ]
> +static struct dsa_port *b53_preferred_cpu_port(struct dsa_switch *ds)
> +{
> + struct b53_device *dev = ds->priv;
> +
> + if (is5301x(dev) && dsa_is_cpu_port(ds, B53_CPU_PORT) && b53_uses_fa_tag(ds, B53_CPU_PORT))
> + return dsa_to_port(ds, B53_CPU_PORT);
> + return NULL;
> +}
[Severity: Medium]
When dev->vlan_filtering is enabled, will hardware VLAN filtering drop
VLAN-tagged IPv4 frames that CFP redirects to CPU port 5?
CFP trap rules redirect frames to port 5 without bypassing VLAN filtering,
and on B53 ds->vlan_filtering_is_global is true, so enabling VLAN filtering
on any bridge enforces VLAN table membership across all ports. Because
b53_preferred_cpu_port() assigns port 8 as dp->cpu_dp for all user ports,
DSA host VLAN programming only calls b53_vlan_add() for the user port and
port 8, leaving BIT(5) unset in dev->vlans[vid].members for any non-default
VID.
[ ... ]
> @@ -3385,7 +3773,32 @@ int b53_switch_register(struct b53_device *dev)
> dev_info(dev->dev, "found switch: %s, rev %i\n",
> dev->name, dev->core_rev);
>
> - return dsa_register_switch(dev->ds);
> + ret = dsa_register_switch(dev->ds);
> + if (ret || !dev->fa_cfp_enabled)
> + return ret;
> + /* Registration replays existing user devices, after their MACs and
> + * DSA private data are initialized. Keep lookup gated until it finishes.
> + */
> + dev->fa_netdev_nb.notifier_call = b53_fa_netdev_event;
> + ret = register_netdevice_notifier(&dev->fa_netdev_nb);
> + if (ret)
> + goto unregister_switch;
> + ret = devm_add_action_or_reset(dev->dev, b53_fa_unregister_notifier, dev);
> + if (ret)
> + goto unregister_switch;
[Severity: Medium]
Can b53_fa_netdev_event() run while the switch is being torn down or after
b53_switch_shutdown()?
Deferring b53_fa_unregister_notifier() to devres keeps dev->fa_netdev_nb
registered with dev->fa_stopping == false throughout
dsa_tree_teardown_conduit() and dsa_tree_teardown_ports(), because
b53_teardown() only runs later in dsa_tree_teardown_switches(). During
system shutdown, b53_switch_shutdown() -> dsa_switch_shutdown() drops the
netdev_put() references on each CPU port's conduit without calling
b53_teardown() or running devres actions, so any later user port netdevice
event will dereference the unreferenced control->conduit and
data_cpu->conduit pointers.
> + dev->fa_guards_ready = true;
> + if (!dev->fa_guards_failed) {
> + struct dsa_port *control = dsa_to_port(dev->ds, 5);
> +
> + rtnl_lock();
> + b53_fa_conduit_state_change(dev->ds, control->conduit,
> + dsa_port_conduit_is_operational(control));
> + rtnl_unlock();
> + }
[Severity: Low]
Should dev->fa_guards_ready and dev->fa_guards_failed be accessed under
rtnl_lock() here? register_netdevice_notifier() has already dropped
rtnl_lock(), so a concurrent netdevice event can run b53_fa_netdev_event()
or b53_fa_port() on another CPU while these booleans are updated and read.
> diff --git a/net/dsa/tag_brcm.c b/net/dsa/tag_brcm.c
> index b7c49822ca888..8d13a3c7de5e3 100644
> --- a/net/dsa/tag_brcm.c
> +++ b/net/dsa/tag_brcm.c
[ ... ]
> @@ -146,9 +150,10 @@ static struct sk_buff *brcm_tag_xmit_ll(struct sk_buff *skb,
> */
> static struct sk_buff *brcm_tag_rcv_ll(struct sk_buff *skb,
> struct net_device *dev,
> - unsigned int offset)
> + unsigned int offset, bool fa)
> {
[ ... ]
> @@ -407,7 +416,100 @@ DSA_TAG_DRIVER(brcm_prepend_netdev_ops);
[ ... ]
> +static struct sk_buff *brcm_fa_tag_rcv(struct sk_buff *skb, struct net_device *dev)
> +{
> + struct dsa_port *cpu = dev->dsa_ptr;
> + struct brcm_fa_control *control;
> + struct dsa_port *data_cpu;
> + unsigned int port;
> + u8 reason;
> +
> + if (cpu->index != 5)
> + return brcm_tag_rcv_ll(skb, dev, ETH_HLEN, true);
[Severity: Medium]
On the cpu->index != 5 path, does brcm_tag_rcv_ll() inspect the 4-byte
prepended FA tag instead of the destination MAC when checking
is_link_local_ether_addr(eth_hdr(skb)->h_dest)?
net/dsa/tag_brcm.c:brcm_tag_rcv_ll() {
...
/* Remove Broadcom tag and update checksum */
skb_pull_rcsum(skb, BRCM_TAG_LEN);
if (likely(!is_link_local_ether_addr(eth_hdr(skb)->h_dest)))
dsa_default_offload_fwd_mark(skb);
...
}
eth_type_trans() on the conduit sets skb->mac_header to the start of the
prepended tag, and skb_pull_rcsum(skb, BRCM_TAG_LEN) only advances
skb->data; skb->mac_header is not updated until dsa_switch_rcv() runs after
cpu_dp->rcv() returns. Because byte 0 of the prepended tag does not have
bit 0 set, is_link_local_ether_addr() returns false and link-local control
frames (01:80:c2:00:00:xx) on bridged ports get skb->offload_fwd_mark set,
preventing the software bridge from forwarding them when STP is disabled or
group_fwd_mask is configured.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261116222519.1416501-1-florian.fainelli@broadcom.com?part=5
next prev parent reply other threads:[~2026-11-17 22:33 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 22:25 [PATCH net-next 0/9] net: bgmac: add Northstar IPv4 TCP/UDP NAT flowtable offload Florian Fainelli
2026-11-16 22:25 ` [PATCH net-next 1/9] net: ethernet: bgmac: validate RX length against the DMA packet capacity Florian Fainelli
2026-11-16 22:25 ` [PATCH net-next 2/9] netfilter: flowtable: reject non-host IPv4 packets before lookup Florian Fainelli
2026-11-17 22:33 ` sashiko-bot
2026-11-16 22:25 ` [PATCH net-next 3/9] netfilter: flowtable: retain offload ownership until deletion completes Florian Fainelli
2026-11-17 22:33 ` sashiko-bot
2026-11-16 22:25 ` [PATCH net-next 4/9] dt-bindings: net: describe the Northstar flow accelerator Florian Fainelli
2026-11-16 22:25 ` [PATCH net-next 5/9] net: dsa: add Broadcom FA metadata and IPv4 exception paths Florian Fainelli
2026-11-17 22:33 ` sashiko-bot [this message]
2026-11-16 22:25 ` [PATCH net-next 6/9] net: flow_offload: allow drivers to validate and invalidate cached paths Florian Fainelli
2026-11-16 22:25 ` [PATCH net-next 7/9] net: bgmac: add Northstar IPv4 TCP/UDP NAT flowtable offload Florian Fainelli
2026-11-17 22:33 ` sashiko-bot
2026-11-16 22:25 ` [PATCH net-next 8/9] net: add KUnit coverage for FA and flowtable path validation Florian Fainelli
2026-11-17 22:34 ` sashiko-bot
2026-11-16 22:25 ` [PATCH net-next 9/9] docs: net: document Northstar FA setup and NAT qualification Florian Fainelli
2026-11-16 22:38 ` [PATCH net-next 0/9] net: bgmac: add Northstar IPv4 TCP/UDP NAT flowtable offload netdev-bot+sinfo
2026-11-16 22:45 ` Florian Fainelli
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=sashiko-outbox-219753@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=florian.fainelli@broadcom.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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