netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Vladimir Oltean <olteanv@gmail.com>
Cc: David Miller <davem@davemloft.net>,
	netdev <netdev@vger.kernel.org>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Vladimir Oltean <vladimir.oltean@nxp.com>,
	Jiri Pirko <jiri@nvidia.com>, Jakub Kicinski <kuba@kernel.org>
Subject: Re: [PATCH net-next v2 3/7] net: dsa: Register devlink ports before calling DSA driver setup()
Date: Sun, 27 Sep 2020 02:45:14 +0200	[thread overview]
Message-ID: <20200927004514.GC3889809@lunn.ch> (raw)
In-Reply-To: <20200926233725.fagc4znatjpufu6q@skbuf>

> > +static int dsa_port_devlink_setup(struct dsa_port *dp)
> >  {
> >  	struct devlink_port *dlp = &dp->devlink_port;
> > +	struct dsa_switch_tree *dst = dp->ds->dst;
> > +	struct devlink_port_attrs attrs = {};
> > +	struct devlink *dl = dp->ds->devlink;
> > +	const unsigned char *id;
> > +	unsigned char len;
> > +	int err;
> > +
> > +	id = (const unsigned char *)&dst->index;
> > +	len = sizeof(dst->index);
> > +
> > +	attrs.phys.port_number = dp->index;
> > +	memcpy(attrs.switch_id.id, id, len);
> > +	attrs.switch_id.id_len = len;
> > +
> > +	if (dp->setup)
> > +		return 0;
> >  
> 
> I wonder what this is protecting against? I ran on a multi-switch tree
> without these 2 lines and I didn't get anything like multiple
> registration or things like that. What is the call path that would call
> dsa_port_devlink_setup twice?

I made a duplicate copy of dsa_port_setup() and trimmed out what was
not needed to give the new dsa_port_setup() and
dsa_port_devlink_setup(). I did not trim enough...

> 
> > +	switch (dp->type) {
> > +	case DSA_PORT_TYPE_UNUSED:
> > +		memset(dlp, 0, sizeof(*dlp));
> > +		attrs.flavour = DEVLINK_PORT_FLAVOUR_UNUSED;
> 
> > +		devlink_port_attrs_set(dlp, &attrs);
> > +		err = devlink_port_register(dl, dlp, dp->index);
> 
> These 2 lines are common everywhere. Could you move them out of the
> switch-case statement?

Yes, that makes sense. Too much blind copy/paste without actually
reviewing the code afterwards.

	  Andrew

  reply	other threads:[~2020-09-27  0:45 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-26 21:06 [PATCH net-next v2 0/7] mv88e6xxx: Add per port devlink regions Andrew Lunn
2020-09-26 21:06 ` [PATCH net-next v2 1/7] net: devlink: Add unused port flavour Andrew Lunn
2020-09-26 21:51   ` Vladimir Oltean
2020-09-26 22:00   ` Vladimir Oltean
2020-09-27  0:33     ` Andrew Lunn
2020-09-28 21:31   ` Jakub Kicinski
2020-09-28 22:05     ` Vladimir Oltean
2020-09-28 22:07       ` Andrew Lunn
2020-09-28 22:35         ` Jakub Kicinski
2020-09-28 22:36           ` Florian Fainelli
2020-09-28 23:39             ` Jakub Kicinski
2020-09-29  1:46               ` Florian Fainelli
2020-09-29 11:03                 ` Vladimir Oltean
2020-09-29 13:07                   ` Jiri Pirko
2020-09-29 13:48                     ` Vladimir Oltean
2020-09-29 15:12                       ` Jiri Pirko
2020-09-29 13:57                     ` Andrew Lunn
2020-09-30  6:56                       ` Jiri Pirko
2020-09-30 13:57                         ` Andrew Lunn
2020-09-30 14:34                           ` Jiri Pirko
2020-09-30 14:53                             ` Andrew Lunn
2020-10-01  7:39                               ` Jiri Pirko
2020-09-26 21:06 ` [PATCH net-next v2 2/7] net: dsa: Make use of devlink port flavour unused Andrew Lunn
2020-09-26 22:51   ` Vladimir Oltean
2020-09-26 21:06 ` [PATCH net-next v2 3/7] net: dsa: Register devlink ports before calling DSA driver setup() Andrew Lunn
2020-09-26 23:37   ` Vladimir Oltean
2020-09-27  0:45     ` Andrew Lunn [this message]
2020-09-26 21:06 ` [PATCH net-next v2 4/7] net: devlink: Add support for port regions Andrew Lunn
2020-09-26 21:06 ` [PATCH net-next v2 5/7] net: dsa: Add devlink port regions support to DSA Andrew Lunn
2020-09-26 23:42   ` Vladimir Oltean
2020-09-26 21:06 ` [PATCH net-next v2 6/7] net: dsa: Add helper for converting devlink port to ds and port Andrew Lunn
2020-09-26 21:06 ` [PATCH net-next v2 7/7] net: dsa: mv88e6xxx: Add per port devlink regions Andrew Lunn
2020-09-26 23:52   ` Vladimir Oltean
2020-09-27  1:03     ` Andrew Lunn
2020-09-27  1:11       ` Vladimir Oltean
2020-09-26 22:02 ` [PATCH net-next v2 0/7] " Marek Behun
2020-09-26 22:11   ` Vladimir Oltean

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=20200927004514.GC3889809@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=jiri@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.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).