All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Michael Dege <michael.dege@renesas.com>
Cc: "Yoshihiro Shimoda" <yoshihiro.shimoda.uh@renesas.com>,
	"Niklas Söderlund" <niklas.soderlund@ragnatech.se>,
	"Paul Barker" <paul@pbarker.dev>,
	"Andrew Lunn" <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-renesas-soc@vger.kernel.org"
	<linux-renesas-soc@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Nikita Yushchenko" <nikita.yoush@cogentembedded.com>
Subject: Re: [PATCH v2 3/4] net: renesas: rswitch: add offloading for L2 switching
Date: Fri, 11 Jul 2025 11:57:21 +0100	[thread overview]
Message-ID: <20250711105721.GU721198@horms.kernel.org> (raw)
In-Reply-To: <TY4PR01MB142826BE20FB23122B72A96348248A@TY4PR01MB14282.jpnprd01.prod.outlook.com>

On Thu, Jul 10, 2025 at 12:36:10PM +0000, Michael Dege wrote:
> Hello Simon,
> 
> > -----Original Message-----
> > From: Simon Horman <horms@kernel.org>
> > Sent: Tuesday, July 8, 2025 12:48 PM
> > To: Michael Dege <michael.dege@renesas.com>
> > Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>; Niklas Söderlund
> > <niklas.soderlund@ragnatech.se>; Paul Barker <paul@pbarker.dev>; Andrew Lunn <andrew+netdev@lunn.ch>;
> > David S. Miller <davem@davemloft.net>; Eric Dumazet <edumazet@google.com>; Jakub Kicinski
> > <kuba@kernel.org>; Paolo Abeni <pabeni@redhat.com>; netdev@vger.kernel.org; linux-renesas-
> > soc@vger.kernel.org; linux-kernel@vger.kernel.org; Nikita Yushchenko <nikita.yoush@cogentembedded.com>
> > Subject: Re: [PATCH v2 3/4] net: renesas: rswitch: add offloading for L2 switching
> >
> > On Tue, Jul 08, 2025 at 11:27:39AM +0200, Michael Dege wrote:
> > > This commit adds hardware offloading for L2 switching on R-Car S4.
> > >
> > > On S4 brdev is limited to one per-device (not per port). Reasoning is
> > > that hw L2 forwarding support lacks any sort of source port based
> > > filtering, which makes it unusable to offload more than one bridge
> > > device. Either you allow hardware to forward destination MAC to a
> > > port, or you have to send it to CPU. You can't make it forward only if
> > > src and dst ports are in the same brdev.
> > >
> > > Signed-off-by: Michael Dege <michael.dege@renesas.com>
> > > Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
> >
> > ...
> >
> > > diff --git a/drivers/net/ethernet/renesas/rswitch_l2.c
> > > b/drivers/net/ethernet/renesas/rswitch_l2.c
> >
> > ...
> >
> > > +static void rswitch_update_offload_brdev(struct rswitch_private *priv,
> > > +                                    bool force_update_l2_offload)
> > > +{
> > > +   struct net_device *offload_brdev = NULL;
> > > +   struct rswitch_device *rdev, *rdev2;
> > > +
> > > +   rswitch_for_all_ports(priv, rdev) {
> > > +           if (!rdev->brdev)
> > > +                   continue;
> > > +           rswitch_for_all_ports(priv, rdev2) {
> > > +                   if (rdev2 == rdev)
> > > +                           break;
> > > +                   if (rdev2->brdev == rdev->brdev) {
> > > +                           offload_brdev = rdev->brdev;
> > > +                           break;
> > > +                   }
> > > +           }
> > > +           if (offload_brdev)
> > > +                   break;
> > > +   }
> > > +
> > > +   if (offload_brdev == priv->offload_brdev) {
> > > +           if (offload_brdev && force_update_l2_offload)
> > > +                   rswitch_update_l2_offload(priv);
> > > +           return;
> > > +   }
> > > +
> > > +   if (offload_brdev && !priv->offload_brdev)
> > > +           dev_dbg(&priv->pdev->dev, "starting l2 offload for %s\n",
> > > +                   netdev_name(offload_brdev));
> > > +   else if (!offload_brdev && priv->offload_brdev)
> > > +           dev_dbg(&priv->pdev->dev, "stopping l2 offload for %s\n",
> > > +                   netdev_name(priv->offload_brdev));
> > > +   else
> > > +           dev_dbg(&priv->pdev->dev,
> > > +                   "changing l2 offload from %s to %s\n",
> > > +                   netdev_name(priv->offload_brdev),
> > > +                   netdev_name(offload_brdev));
> >
> > Smatch flags a false-positive about possible NULL references by the
> > netdev_name() calls on the line above.
> >
> > Due to the previous if statement it seems to me that cannot occur.
> > But it did take me a few moments to convince myself of that.
> >
> > So while I don't think we should write our code to static analysis tooling.
> > I did play around a bit to see if I could come up with something that is both easier on the eyes and
> > keeps Smatch happy.
> >
> > Perhaps it isn't easier on the eyes, but rather I'm just more familiar with the code now. But in any
> > case, I'm sharing what I came up with in case it is useful. (Compile tested only!).
> >
> >
> >         if (!offload_brdev && !priv->offload_brdev)
> >                 return;
> >
> >         if (!priv->offload_brdev)
> >                 dev_dbg(&priv->pdev->dev, "starting l2 offload for %s\n",
> >                         netdev_name(offload_brdev));
> >         else if (!offload_brdev)
> >                 dev_dbg(&priv->pdev->dev, "stopping l2 offload for %s\n",
> >                         netdev_name(priv->offload_brdev));
> >         else 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));
> >         else if (!force_update_l2_offload)
> >                 return;
> >
> 
> I updated the code, I hope it is OK, because I had to do it differently from your suggestion, because
> not all cases worked as expected.
> 
> The reworked code is tested.

Thanks. FWIIW, Smatch still complains.

But if your code is correct and tested, then I think we should not
update it a 2nd time to make the tooling happy.

  reply	other threads:[~2025-07-11 10:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-08  9:27 [PATCH v2 0/4] net: renesas: rswitch: R-Car S4 add HW offloading for layer 2 switching Michael Dege
2025-07-08  9:27 ` [PATCH v2 1/4] net: renesas: rswitch: rename rswitch.c to rswitch_main.c Michael Dege
2025-07-08 21:55   ` Andrew Lunn
2025-07-09  4:51     ` Michael Dege
2025-07-08  9:27 ` [PATCH v2 2/4] net: renesas: rswitch: configure default ageing time Michael Dege
2025-07-08 21:56   ` Andrew Lunn
2025-07-08  9:27 ` [PATCH v2 3/4] net: renesas: rswitch: add offloading for L2 switching Michael Dege
2025-07-08 10:47   ` Simon Horman
2025-07-08 12:32     ` Michael Dege
2025-07-10 12:36     ` Michael Dege
2025-07-11 10:57       ` Simon Horman [this message]
2025-07-08 21:52   ` Andrew Lunn
2025-07-10 12:37     ` Michael Dege
2025-07-08 22:23   ` Andrew Lunn
2025-07-08  9:27 ` [PATCH v2 4/4] net: renesas: rswitch: add modifiable ageing time Michael Dege

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=20250711105721.GU721198@horms.kernel.org \
    --to=horms@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=michael.dege@renesas.com \
    --cc=netdev@vger.kernel.org \
    --cc=nikita.yoush@cogentembedded.com \
    --cc=niklas.soderlund@ragnatech.se \
    --cc=pabeni@redhat.com \
    --cc=paul@pbarker.dev \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.