Netdev List
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: michael.dege@renesas.com
Cc: Jakub Kicinski <kuba@kernel.org>,
	yoshihiro.shimoda.uh@renesas.com, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@google.com, pabeni@redhat.com,
	niklas.soderlund@ragnatech.se, paul@pbarker.dev,
	richardcochran@gmail.com, netdev@vger.kernel.org,
	linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v5 06/14] net: renesas: rswitch: add forwarding rules for gwca
Date: Mon, 25 May 2026 13:41:12 -0700	[thread overview]
Message-ID: <20260525204112.2471322-1-kuba@kernel.org> (raw)
In-Reply-To: <20260522-rswitch_add_vlans-v5-6-53589d944a9f@renesas.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.
---
Subject: net: renesas: rswitch: add forwarding rules for gwca
    
This commit adds rules to forward packets from the Ethernet ports to the
CPU port (GWCA) using L2 forwarding. It introduces a new function to
configure GWCA forwarding rules and integrates it into the L2 offload
updates.

> Add rules to forward packets from the Ethernet ports to the CPU port (GWCA)
> using L2 forwarding instead of port forwarding.

[Severity: Medium]
The commit message mentions using L2 forwarding instead of port forwarding,
but is the existing port forwarding code actually removed or disabled?

If rswitch_fwd_init() still configures FWPBFC to unconditionally forward all
packets to the GWCA port, does having both L2 forwarding and port-based
forwarding active simultaneously lead to duplicated packets and unnecessary
CPU overhead?

> diff --git a/drivers/net/ethernet/renesas/rswitch_l2.c b/drivers/net/ethernet/renesas/rswitch_l2.c
> index 709524c8a5c4d..3cc0ce8762f3c 100644
> --- a/drivers/net/ethernet/renesas/rswitch_l2.c
> +++ b/drivers/net/ethernet/renesas/rswitch_l2.c

[ ... ]

> @@ -93,10 +93,32 @@ static void rswitch_update_l2_hw_forwarding(struct rswitch_private *priv)
>  	}
>  }
>  
> +static void rswitch_update_l2_hw_forwarding_gwca(struct rswitch_private *priv)
> +{
> +	struct rswitch_device *rdev;
> +	u32 fwpc0_set, fwpc0_clr, fwpc2_set, fwpc2_clr;
> +
> +	fwpc0_clr = FWPC0_MACSSA | FWPC0_MACDSA | FWPC0_MACRUDA;
> +	fwpc0_set = fwpc0_clr;
> +	fwpc2_clr = FIELD_PREP(FWPC2_LTWFW, BIT(AGENT_INDEX_GWCA));
> +	fwpc2_set = fwpc2_clr;
> +
> +	(priv->offload_brdev) ? (fwpc0_clr = 0, fwpc2_set = 0)
> +			      : (fwpc0_set = 0, fwpc2_clr = 0);
> +
> +	rswitch_modify(priv->addr, FWPC0(AGENT_INDEX_GWCA), fwpc0_clr, fwpc0_set);
> +
> +	rswitch_for_all_ports(priv, rdev) {
> +		rswitch_modify(priv->addr, FWPC2(rdev->etha->index),
> +			       fwpc2_clr, fwpc2_set);
> +	}
> +}
> +
>  void rswitch_update_l2_offload(struct rswitch_private *priv)
>  {
>  	rswitch_update_l2_hw_learning(priv);
>  	rswitch_update_l2_hw_forwarding(priv);
> +	rswitch_update_l2_hw_forwarding_gwca(priv);

[Severity: Medium]
Do non-atomic updates to FWPC2 momentarily disable forwarding to the CPU port?

In rswitch_update_l2_hw_forwarding(), iowrite32() is used to overwrite
FWPC2, which unconditionally sets the GWCA bit to 1, disabling hardware L2
forwarding to the CPU port.

Immediately after, rswitch_update_l2_hw_forwarding_gwca() uses
rswitch_modify() to clear the GWCA bit back to 0.

Does this consecutive write sequence create a microsecond window where L2
forwarding to the CPU is incorrectly denied, risking packet drops for
hardware packets destined for the CPU?

>  }

[Severity: High]
This is a pre-existing issue, but I noticed a potential kernel panic in
rswitch_update_offload_brdev() when logging is enabled:

drivers/net/ethernet/renesas/rswitch_l2.c:rswitch_update_offload_brdev() {
    ...
    if (offload_brdev == priv->offload_brdev)
        dev_dbg(&priv->pdev->dev,
            "changing l2 offload from %s to %s\n",
            netdev_name(priv->offload_brdev),
            netdev_name(offload_brdev));
    ...
}

If a single port is added to a bridge, the loop searching for a shared
bridge exits early, leaving offload_brdev as NULL.

If priv->offload_brdev is also NULL (the initial state), the condition
offload_brdev == priv->offload_brdev evaluates to true.

Will this cause a kernel panic when dynamic debugging is active, since
netdev_name(NULL) unconditionally dereferences its argument?

[Severity: High]
This is a pre-existing issue, but do concurrent transmissions cause lost
writes to the shared GWTRC register?

In rswitch_start_xmit(), transmission is triggered by modifying the GWTRC
register:

drivers/net/ethernet/renesas/rswitch_main.c:rswitch_start_xmit() {
    ...
    rswitch_modify(priv->addr, GWTRC, ...);
    ...
}

Because rswitch_modify() performs a lockless read-modify-write:

drivers/net/ethernet/renesas/rswitch_main.c:rswitch_modify() {
    iowrite32((ioread32(addr + reg) & ~clear) | set, addr + reg);
}

Will concurrent ndo_start_xmit calls from different CPUs on different
ports race and overwrite each other's modifications, resulting in lost
transmit triggers and stalled TX queues?

[Severity: High]
This is a pre-existing issue, but does the driver fail to set
skb->offload_fwd_mark for hardware-forwarded L2 packets?

The driver supports hardware L2 forwarding but does not appear to set
skb->offload_fwd_mark = 1 before passing received packets to the network
stack.

Without this flag, the software bridge is unaware that the hardware has
already flooded the packet to other ports.

Will this cause the bridge to re-flood broadcast and multicast packets,
leading to packet duplication and potential network storms?

  reply	other threads:[~2026-05-25 20:41 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-22 12:12 [net-next PATCH v5 00/14] net: renesas: rswitch: R-Car S4 add VLAN aware switching Michael Dege
2026-05-22 12:12 ` [PATCH net-next v5 01/14] net: renesas: rswitch: improve port change mode functions Michael Dege
2026-05-25 20:41   ` Jakub Kicinski
2026-05-22 12:12 ` [PATCH net-next v5 02/14] net: renesas: rswitch: use device instead of net_device Michael Dege
2026-05-25 20:41   ` Jakub Kicinski
2026-05-22 12:12 ` [PATCH net-next v5 03/14] net: renesas: rswitch: fix FWPC2 register access macros Michael Dege
2026-05-22 12:12 ` [PATCH net-next v5 04/14] net: renesas: rswitch: add register definitions for vlan support Michael Dege
2026-05-22 12:12 ` [PATCH net-next v5 05/14] net: renesas: rswitch: add exception path for packets with unknown dst MAC Michael Dege
2026-05-25 20:41   ` Jakub Kicinski
2026-05-22 12:12 ` [PATCH net-next v5 06/14] net: renesas: rswitch: add forwarding rules for gwca Michael Dege
2026-05-25 20:41   ` Jakub Kicinski [this message]
2026-05-22 12:12 ` [PATCH net-next v5 07/14] net: renesas: rswitch: make helper functions available to whole driver Michael Dege
2026-05-25 20:41   ` Jakub Kicinski
2026-05-22 12:12 ` [PATCH net-next v5 08/14] net: renesas: rswitch: add locking for agent clock control Michael Dege
2026-05-25 20:41   ` Jakub Kicinski
2026-05-22 12:12 ` [PATCH net-next v5 09/14] net: renesas: rswitch: add basic vlan init to rswitch_fwd_init Michael Dege
2026-05-22 12:12 ` [PATCH net-next v5 10/14] net: renesas: rswitch: update port HW init Michael Dege
2026-05-25 20:41   ` Jakub Kicinski
2026-05-22 12:12 ` [PATCH net-next v5 11/14] net: renesas: rswitch: clean up is_rdev rswitch_device checking Michael Dege
2026-05-25 20:41   ` Jakub Kicinski
2026-05-22 12:12 ` [PATCH net-next v5 12/14] net: renesas: rswitch: add passing of rswitch_private into notifiers Michael Dege
2026-05-25 20:41   ` Jakub Kicinski
2026-05-22 12:12 ` [PATCH net-next v5 13/14] net: renesas: rswitch: add handler for FDB notification Michael Dege
2026-05-25 20:40   ` Jakub Kicinski
2026-05-25 20:41   ` Jakub Kicinski
2026-05-22 12:12 ` [PATCH net-next v5 14/14] net: renesas: rswitch: add vlan aware switching Michael Dege
2026-05-25 20:41   ` 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=20260525204112.2471322-1-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=michael.dege@renesas.com \
    --cc=netdev@vger.kernel.org \
    --cc=niklas.soderlund@ragnatech.se \
    --cc=pabeni@redhat.com \
    --cc=paul@pbarker.dev \
    --cc=richardcochran@gmail.com \
    --cc=yoshihiro.shimoda.uh@renesas.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