RE: [PATCH v3 3/4] of_net: add mac-address-increment support

From: ansuelsmth
Date: Fri Sep 25 2020 - 14:39:38 EST




> -----Original Message-----
> From: Rob Herring <robh+dt@xxxxxxxxxx>
> Sent: Friday, September 25, 2020 8:24 PM
> To: Ansuel Smith <ansuelsmth@xxxxxxxxx>
> Cc: Miquel Raynal <miquel.raynal@xxxxxxxxxxx>; Richard Weinberger
> <richard@xxxxxx>; Vignesh Raghavendra <vigneshr@xxxxxx>; David S.
> Miller <davem@xxxxxxxxxxxxx>; Jakub Kicinski <kuba@xxxxxxxxxx>;
> Andrew Lunn <andrew@xxxxxxx>; Heiner Kallweit
> <hkallweit1@xxxxxxxxx>; Russell King <linux@xxxxxxxxxxxxxxx>; Frank
> Rowand <frowand.list@xxxxxxxxx>; Boris Brezillon
> <bbrezillon@xxxxxxxxxx>; MTD Maling List <linux-mtd@xxxxxxxxxxxxxxxxxxx>;
> devicetree@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; netdev
> <netdev@xxxxxxxxxxxxxxx>
> Subject: Re: [PATCH v3 3/4] of_net: add mac-address-increment support
>
> On Sun, Sep 20, 2020 at 3:57 AM Ansuel Smith <ansuelsmth@xxxxxxxxx>
> wrote:
> >
> > Lots of embedded devices use the mac-address of other interface
> > extracted from nvmem cells and increments it by one or two. Add two
> > bindings to integrate this and directly use the right mac-address for
> > the interface. Some example are some routers that use the gmac
> > mac-address stored in the art partition and increments it by one for the
> > wifi. mac-address-increment-byte bindings is used to tell what byte of
> > the mac-address has to be increased (if not defined the last byte is
> > increased) and mac-address-increment tells how much the byte decided
> > early has to be increased.
>
> I'm inclined to say if there's a platform specific way to transform
> MAC addresses, then there should be platform specific code to do that
> which then stuffs the DT using standard properties. Otherwise, we have
> a never ending stream of 'generic' properties to try to handle
> different platforms' cases.
>
> Rob

I agree about the 'never ending stream'... But I think the increment feature
is not that platform specific. I will quote some number by another patch
that tried to implement the same feature in a different way, [1]

* mtd-mac-address used 497 times in 357 device tree files
* mtd-mac-address-increment used 74 times in 58 device tree files
* mtd-mac-address-increment-byte used 1 time in 1 device tree file

The mtd-mac-address is what this patchset is trying to fix with the nvmem
support. The increment is much more than 74 times since it doesn't count
SoC that have wifi integrated (it's common practice for SoC with integrated
wifi to take the switch mac and use it to set the wifi mac)
Actually what is really specific is the increment-byte that can be dropped
if we really want to.
I still think the increment feature would be very useful to add full support
for mac-address extracted from nvmem cell.

[1] https://patchwork.ozlabs.org/project/netdev/patch/1555445100-30936-1-git-send-email-ynezz@xxxxxxx/