From: Ido Schimmel <idosch@nvidia.com>
To: Vladimir Oltean <vladimir.oltean@nxp.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"davem@davemloft.net" <davem@davemloft.net>,
"kuba@kernel.org" <kuba@kernel.org>,
"pabeni@redhat.com" <pabeni@redhat.com>,
"edumazet@google.com" <edumazet@google.com>,
"jiri@resnulli.us" <jiri@resnulli.us>,
"netdev@kapio-technology.com" <netdev@kapio-technology.com>,
"mlxsw@nvidia.com" <mlxsw@nvidia.com>
Subject: Re: [PATCH net-next] rocker: Explicitly mark learned FDB entries as offloaded
Date: Mon, 31 Oct 2022 13:53:44 +0200 [thread overview]
Message-ID: <Y1+3SP1I3+HZSMG1@shredder> (raw)
In-Reply-To: <20221031090822.q4zux45vrqr2wqi5@skbuf>
On Mon, Oct 31, 2022 at 09:08:23AM +0000, Vladimir Oltean wrote:
> On Mon, Oct 31, 2022 at 10:32:04AM +0200, Ido Schimmel wrote:
> > On Mon, Oct 31, 2022 at 09:59:22AM +0200, Ido Schimmel wrote:
> > > diff --git a/drivers/net/ethernet/rocker/rocker_ofdpa.c b/drivers/net/ethernet/rocker/rocker_ofdpa.c
> > > index 58cf7cc54f40..f5880d0053da 100644
> > > --- a/drivers/net/ethernet/rocker/rocker_ofdpa.c
> > > +++ b/drivers/net/ethernet/rocker/rocker_ofdpa.c
> > > @@ -1828,12 +1828,14 @@ static void ofdpa_port_fdb_learn_work(struct work_struct *work)
> > > info.vid = lw->vid;
> > >
> > > rtnl_lock();
> > > - if (learned && removing)
> > > + if (learned && removing) {
> > > call_switchdev_notifiers(SWITCHDEV_FDB_DEL_TO_BRIDGE,
> > > lw->ofdpa_port->dev, &info.info, NULL);
> > > - else if (learned && !removing)
> > > + } else if (learned && !removing) {
> > > + info.offloaded = true;
> > > call_switchdev_notifiers(SWITCHDEV_FDB_ADD_TO_BRIDGE,
> > > lw->ofdpa_port->dev, &info.info, NULL);
> > > + }
> > > rtnl_unlock();
> > >
> > > kfree(work);
> >
> > Looking at it again, this is better:
> >
> > diff --git a/drivers/net/ethernet/rocker/rocker_ofdpa.c b/drivers/net/ethernet/rocker/rocker_ofdpa.c
> > index 58cf7cc54f40..4d17ae18ea61 100644
> > --- a/drivers/net/ethernet/rocker/rocker_ofdpa.c
> > +++ b/drivers/net/ethernet/rocker/rocker_ofdpa.c
> > @@ -1826,6 +1826,7 @@ static void ofdpa_port_fdb_learn_work(struct work_struct *work)
> >
> > info.addr = lw->addr;
> > info.vid = lw->vid;
> > + info.offloaded = learned && !removing;
> >
> > rtnl_lock();
> > if (learned && removing)
> >
> > Will send another version tomorrow assuming no other comments.
>
> It may also be an opportunity to not take rtnl_lock() if (!learned), and
> this will in turn simplify the condition to just "info.offloaded = !removing"?
>
> Actually this elimination of useless work should be done at the level of
> ofdpa_port_fdb_learn(), if "flags" does not contain OFDPA_OP_FLAG_LEARNED.
OK, I have this as the first patch:
diff --git a/drivers/net/ethernet/rocker/rocker_ofdpa.c b/drivers/net/ethernet/rocker/rocker_ofdpa.c
index 58cf7cc54f40..77ad09ad8304 100644
--- a/drivers/net/ethernet/rocker/rocker_ofdpa.c
+++ b/drivers/net/ethernet/rocker/rocker_ofdpa.c
@@ -1821,19 +1821,16 @@ static void ofdpa_port_fdb_learn_work(struct work_struct *work)
const struct ofdpa_fdb_learn_work *lw =
container_of(work, struct ofdpa_fdb_learn_work, work);
bool removing = (lw->flags & OFDPA_OP_FLAG_REMOVE);
- bool learned = (lw->flags & OFDPA_OP_FLAG_LEARNED);
struct switchdev_notifier_fdb_info info = {};
+ enum switchdev_notifier_type event;
info.addr = lw->addr;
info.vid = lw->vid;
+ event = removing ? SWITCHDEV_FDB_DEL_TO_BRIDGE :
+ SWITCHDEV_FDB_ADD_TO_BRIDGE;
rtnl_lock();
- if (learned && removing)
- call_switchdev_notifiers(SWITCHDEV_FDB_DEL_TO_BRIDGE,
- lw->ofdpa_port->dev, &info.info, NULL);
- else if (learned && !removing)
- call_switchdev_notifiers(SWITCHDEV_FDB_ADD_TO_BRIDGE,
- lw->ofdpa_port->dev, &info.info, NULL);
+ call_switchdev_notifiers(event, lw->ofdpa_port->dev, &info.info, NULL);
rtnl_unlock();
kfree(work);
@@ -1865,6 +1862,9 @@ static int ofdpa_port_fdb_learn(struct ofdpa_port *ofdpa_port,
if (!ofdpa_port_is_bridged(ofdpa_port))
return 0;
+ if (!(flags & OFDPA_OP_FLAG_LEARNED))
+ return 0;
+
lw = kzalloc(sizeof(*lw), GFP_ATOMIC);
if (!lw)
return -ENOMEM;
prev parent reply other threads:[~2022-10-31 11:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-31 7:59 [PATCH net-next] rocker: Explicitly mark learned FDB entries as offloaded Ido Schimmel
2022-10-31 8:32 ` Ido Schimmel
2022-10-31 9:08 ` Vladimir Oltean
2022-10-31 11:53 ` Ido Schimmel [this message]
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=Y1+3SP1I3+HZSMG1@shredder \
--to=idosch@nvidia.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=mlxsw@nvidia.com \
--cc=netdev@kapio-technology.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vladimir.oltean@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;
as well as URLs for NNTP newsgroup(s).