From: Ido Schimmel <idosch@idosch.org>
To: Shannon Nelson <snelson@pensando.io>
Cc: Jakub Kicinski <kuba@kernel.org>,
netdev@vger.kernel.org, olteanv@gmail.com, andrew@lunn.ch,
f.fainelli@gmail.com, vkochan@marvell.com, tchornyi@marvell.com
Subject: Re: [RFC net-next 3/6] ethernet: prestera: use eth_hw_addr_set_port()
Date: Mon, 18 Oct 2021 22:15:44 +0300 [thread overview]
Message-ID: <YW3H4GhRWEjaHF+U@shredder> (raw)
In-Reply-To: <443e4671-bc84-b4a9-7198-7de301a03d52@pensando.io>
On Mon, Oct 18, 2021 at 10:54:56AM -0700, Shannon Nelson wrote:
> On 10/18/21 10:33 AM, Ido Schimmel wrote:
> > On Mon, Oct 18, 2021 at 09:26:21AM -0700, Shannon Nelson wrote:
> > > On 10/18/21 7:19 AM, Jakub Kicinski wrote:
> > > > On Sat, 16 Oct 2021 14:19:18 -0700 Shannon Nelson wrote:
> > > > > As a potential consumer of these helpers, I'd rather do my own mac
> > > > > address byte twiddling and then use eth_hw_addr_set() to put it into place.
> > > > This is disproved by many upstream drivers, I only converted the ones
> > > > that jumped out at me on Friday, but I'm sure there is more. If your
> > > > driver is _really_ doing something questionable^W I mean "special"
> > > > nothing is stopping you from open coding it. For others the helper will
> > > > be useful.
> > > >
> > > > IOW I don't understand your comment.
> > > To try to answer your RFC more clearly: I feel that this particular helper
> > > obfuscates the operation more than it helps.
> > FWIW, it at least helped me realize that we are going to have a bug with
> > Spectrum-4. Currently we have:
> >
> > ether_addr_copy(addr, mlxsw_sp->base_mac);
> > addr[ETH_ALEN - 1] += mlxsw_sp_port->local_port;
> >
> > As a preparation for Spectrum-4 we are promoting 'local_port' to u16
> > since at least 257 and 258 are valid local port values.
> >
> > With the current code, the netdev corresponding to local port 1 will
> > have the same MAC as the netdev corresponding to local port 257.
> >
> > After Jakub's conversion and changing the 'id' argument to 'unsigned
> > int' [1], it should work correctly.
> >
> > [1] https://lore.kernel.org/netdev/20211018070845.68ba815d@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com/
>
> I would think that it might be clearer to do something like
>
> u64 addr64;
>
> addr64 = ether_addr_to_64(mlxsw_sp->base_mac);
> addr64 += mlxsw_sp_port->local_port;
> u64_to_ether_addr(addr64, addr);
> eth_hw_addr_set(dev, addr);
This is basically what Jakub's helper is doing...
I don't know how to argue with "clearer", but the fact is that we are
not doing what you suggested right now (hindsight is always 20/20) and
that it would have taken me time to debug it.
The suggested helper already helped to avoid one bug and it's not even
merged yet, so it's safe to assume it will help to avoid more bugs in
the future.
next prev parent reply other threads:[~2021-10-18 19:15 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-15 19:38 [RFC net-next 0/6] ethernet: add eth_hw_addr_set_port() Jakub Kicinski
2021-10-15 19:38 ` [RFC net-next 1/6] ethernet: add a helper for assigning port addresses Jakub Kicinski
2021-10-15 21:36 ` Shannon Nelson
2021-10-15 22:30 ` Jakub Kicinski
2021-10-15 22:50 ` Vladimir Oltean
2021-10-17 15:06 ` Ido Schimmel
2021-10-18 14:08 ` Jakub Kicinski
2021-10-15 19:38 ` [RFC net-next 2/6] ethernet: ocelot: use eth_hw_addr_set_port() Jakub Kicinski
2021-10-15 19:38 ` [RFC net-next 3/6] ethernet: prestera: " Jakub Kicinski
2021-10-15 23:51 ` Vladimir Oltean
2021-10-16 0:17 ` Jakub Kicinski
2021-10-16 0:27 ` Vladimir Oltean
2021-10-18 16:54 ` Taras Chornyi [C]
2021-10-18 17:01 ` Jakub Kicinski
2021-10-18 18:20 ` Taras Chornyi
2021-10-16 21:19 ` Shannon Nelson
2021-10-18 14:19 ` Jakub Kicinski
2021-10-18 16:26 ` Shannon Nelson
2021-10-18 17:33 ` Ido Schimmel
2021-10-18 17:54 ` Shannon Nelson
2021-10-18 19:15 ` Ido Schimmel [this message]
2021-10-15 19:38 ` [RFC net-next 4/6] ethernet: fec: " Jakub Kicinski
2021-10-15 19:38 ` [RFC net-next 5/6] ethernet: mlxsw: " Jakub Kicinski
2021-10-15 19:38 ` [RFC net-next 6/6] ethernet: sparx5: " 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=YW3H4GhRWEjaHF+U@shredder \
--to=idosch@idosch.org \
--cc=andrew@lunn.ch \
--cc=f.fainelli@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=snelson@pensando.io \
--cc=tchornyi@marvell.com \
--cc=vkochan@marvell.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).