RE: R: [PATCH v2 4/4] dt-bindings: net: Document use of mac-address-increment

2020-09-20 Thread ansuelsmth
> On Sun, Sep 20, 2020 at 02:39:39AM +0200, ansuels...@gmail.com
> wrote:
> >
> >
> > > -Messaggio originale-
> > > Da: Andrew Lunn 
> > > Inviato: domenica 20 settembre 2020 02:31
> > > A: Ansuel Smith 
> > > Cc: Miquel Raynal ; Richard Weinberger
> > > ; Vignesh Raghavendra ; Rob
> Herring
> > > ; David S. Miller ; Jakub
> > > Kicinski ; Heiner Kallweit ;
> > > Russell King ; Frank Rowand
> > > ; Boris Brezillon ;
> linux-
> > > m...@lists.infradead.org; devicet...@vger.kernel.org; linux-
> > > ker...@vger.kernel.org; net...@vger.kernel.org
> > > Oggetto: Re: [PATCH v2 4/4] dt-bindings: net: Document use of mac-
> > > address-increment
> > >
> > > > +  mac-address-increment:
> > > > +description:
> > > > +  The MAC address can optionally be increased (or decreased
using
> > > > +  negative values) from the original value readed (from a nvmem
> > cell
> > >
> > > Read is irregular, there is no readed, just read.
> > >
> > > > +  for example). This can be used if the mac is readed from a
> > dedicated
> > > > +  partition and must be increased based on the number of device
> > > > +  present in the system.
> > >
> > > You should probably add there is no underflow/overflow to other bytes
> > > of the MAC address. 00:01:02:03:04:ff + 1 == 00:01:02:03:04:00.
> > >
> > > > +minimum: -255
> > > > +maximum: 255
> > > > +
> > > > +  mac-address-increment-byte:
> > > > +description:
> > > > +  If 'mac-address-increment' is defined, this will tell what
byte
> > of
> > > > +  the mac-address will be increased. If 'mac-address-increment'
is
> > > > +  not defined, this option will do nothing.
> > > > +default: 5
> > > > +minimum: 0
> > > > +maximum: 5
> > >
> > > Is there a real need for this? A value of 0 seems like a bad idea,
> > > since a unicast address could easily become a multicast address, which
> > > is not valid for an interface address. It also does not seem like a
> > > good idea to allow the OUI to be changed. So i think only bytes 3-5
> > > should be allowed, but even then, i don't think this is needed, unless
> > > you do have a clear use case.
> > >
> > > Andrew
> >
> > Honestly the mac-address-increment-byte is added to give user some
> control
> > but I
> > don't really have a use case for it. Should I limit it to 3 or just
remove
> > the function?
> 
> If you have no use case, just remove it and document that last byte
> will be incremented. I somebody does need it, it can be added in a
> backwards compatible way.
> 
>  Andrew

I just rechecked mac-address-increment-byte and we have one device that
use it and would benefits from this.  I will change the Documentation to
min 3 and leave it.



Re: R: [PATCH v2 4/4] dt-bindings: net: Document use of mac-address-increment

2020-09-19 Thread Andrew Lunn
On Sun, Sep 20, 2020 at 02:39:39AM +0200, ansuels...@gmail.com wrote:
> 
> 
> > -Messaggio originale-
> > Da: Andrew Lunn 
> > Inviato: domenica 20 settembre 2020 02:31
> > A: Ansuel Smith 
> > Cc: Miquel Raynal ; Richard Weinberger
> > ; Vignesh Raghavendra ; Rob Herring
> > ; David S. Miller ; Jakub
> > Kicinski ; Heiner Kallweit ;
> > Russell King ; Frank Rowand
> > ; Boris Brezillon ; linux-
> > m...@lists.infradead.org; devicet...@vger.kernel.org; linux-
> > ker...@vger.kernel.org; net...@vger.kernel.org
> > Oggetto: Re: [PATCH v2 4/4] dt-bindings: net: Document use of mac-
> > address-increment
> > 
> > > +  mac-address-increment:
> > > +description:
> > > +  The MAC address can optionally be increased (or decreased using
> > > +  negative values) from the original value readed (from a nvmem
> cell
> > 
> > Read is irregular, there is no readed, just read.
> > 
> > > +  for example). This can be used if the mac is readed from a
> dedicated
> > > +  partition and must be increased based on the number of device
> > > +  present in the system.
> > 
> > You should probably add there is no underflow/overflow to other bytes
> > of the MAC address. 00:01:02:03:04:ff + 1 == 00:01:02:03:04:00.
> > 
> > > +minimum: -255
> > > +maximum: 255
> > > +
> > > +  mac-address-increment-byte:
> > > +description:
> > > +  If 'mac-address-increment' is defined, this will tell what byte
> of
> > > +  the mac-address will be increased. If 'mac-address-increment' is
> > > +  not defined, this option will do nothing.
> > > +default: 5
> > > +minimum: 0
> > > +maximum: 5
> > 
> > Is there a real need for this? A value of 0 seems like a bad idea,
> > since a unicast address could easily become a multicast address, which
> > is not valid for an interface address. It also does not seem like a
> > good idea to allow the OUI to be changed. So i think only bytes 3-5
> > should be allowed, but even then, i don't think this is needed, unless
> > you do have a clear use case.
> > 
> > Andrew
> 
> Honestly the mac-address-increment-byte is added to give user some control
> but I
> don't really have a use case for it. Should I limit it to 3 or just remove
> the function?

If you have no use case, just remove it and document that last byte
will be incremented. I somebody does need it, it can be added in a
backwards compatible way.

 Andrew


R: [PATCH v2 4/4] dt-bindings: net: Document use of mac-address-increment

2020-09-19 Thread ansuelsmth



> -Messaggio originale-
> Da: Andrew Lunn 
> Inviato: domenica 20 settembre 2020 02:31
> A: Ansuel Smith 
> Cc: Miquel Raynal ; Richard Weinberger
> ; Vignesh Raghavendra ; Rob Herring
> ; David S. Miller ; Jakub
> Kicinski ; Heiner Kallweit ;
> Russell King ; Frank Rowand
> ; Boris Brezillon ; linux-
> m...@lists.infradead.org; devicet...@vger.kernel.org; linux-
> ker...@vger.kernel.org; net...@vger.kernel.org
> Oggetto: Re: [PATCH v2 4/4] dt-bindings: net: Document use of mac-
> address-increment
> 
> > +  mac-address-increment:
> > +description:
> > +  The MAC address can optionally be increased (or decreased using
> > +  negative values) from the original value readed (from a nvmem
cell
> 
> Read is irregular, there is no readed, just read.
> 
> > +  for example). This can be used if the mac is readed from a
dedicated
> > +  partition and must be increased based on the number of device
> > +  present in the system.
> 
> You should probably add there is no underflow/overflow to other bytes
> of the MAC address. 00:01:02:03:04:ff + 1 == 00:01:02:03:04:00.
> 
> > +minimum: -255
> > +maximum: 255
> > +
> > +  mac-address-increment-byte:
> > +description:
> > +  If 'mac-address-increment' is defined, this will tell what byte
of
> > +  the mac-address will be increased. If 'mac-address-increment' is
> > +  not defined, this option will do nothing.
> > +default: 5
> > +minimum: 0
> > +maximum: 5
> 
> Is there a real need for this? A value of 0 seems like a bad idea,
> since a unicast address could easily become a multicast address, which
> is not valid for an interface address. It also does not seem like a
> good idea to allow the OUI to be changed. So i think only bytes 3-5
> should be allowed, but even then, i don't think this is needed, unless
> you do have a clear use case.
> 
> Andrew

Honestly the mac-address-increment-byte is added to give user some control
but I
don't really have a use case for it. Should I limit it to 3 or just remove
the function?
Will address the other 2 comment in v3.
Thx for review.



Re: [PATCH v2 4/4] dt-bindings: net: Document use of mac-address-increment

2020-09-19 Thread Andrew Lunn
> +  mac-address-increment:
> +description:
> +  The MAC address can optionally be increased (or decreased using
> +  negative values) from the original value readed (from a nvmem cell

Read is irregular, there is no readed, just read.

> +  for example). This can be used if the mac is readed from a dedicated
> +  partition and must be increased based on the number of device
> +  present in the system.

You should probably add there is no underflow/overflow to other bytes
of the MAC address. 00:01:02:03:04:ff + 1 == 00:01:02:03:04:00.

> +minimum: -255
> +maximum: 255
> +
> +  mac-address-increment-byte:
> +description:
> +  If 'mac-address-increment' is defined, this will tell what byte of
> +  the mac-address will be increased. If 'mac-address-increment' is
> +  not defined, this option will do nothing.
> +default: 5
> +minimum: 0
> +maximum: 5

Is there a real need for this? A value of 0 seems like a bad idea,
since a unicast address could easily become a multicast address, which
is not valid for an interface address. It also does not seem like a
good idea to allow the OUI to be changed. So i think only bytes 3-5
should be allowed, but even then, i don't think this is needed, unless
you do have a clear use case.

Andrew


[PATCH v2 4/4] dt-bindings: net: Document use of mac-address-increment

2020-09-19 Thread Ansuel Smith
Two new bindings are now supported by the of_net driver to increase (or
decrease) a mac-address. This can be very useful in case where the
system extract the mac-address for the device from a dedicated partition
and have a generic mac-address that needs to be incremented based on the
device number.
- mac-address-increment-byte is used to tell what byte must be
  incremented (if not set the last byte is increased)
- mac-address-increment is used to tell how much to increment of the
  extracted mac-address decided byte.

Signed-off-by: Ansuel Smith 
---
 .../bindings/net/ethernet-controller.yaml | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/ethernet-controller.yaml 
b/Documentation/devicetree/bindings/net/ethernet-controller.yaml
index fa2baca8c726..43f2f21faf41 100644
--- a/Documentation/devicetree/bindings/net/ethernet-controller.yaml
+++ b/Documentation/devicetree/bindings/net/ethernet-controller.yaml
@@ -32,6 +32,25 @@ properties:
   - minItems: 6
 maxItems: 6
 
+  mac-address-increment:
+description:
+  The MAC address can optionally be increased (or decreased using
+  negative values) from the original value readed (from a nvmem cell
+  for example). This can be used if the mac is readed from a dedicated
+  partition and must be increased based on the number of device
+  present in the system.
+minimum: -255
+maximum: 255
+
+  mac-address-increment-byte:
+description:
+  If 'mac-address-increment' is defined, this will tell what byte of
+  the mac-address will be increased. If 'mac-address-increment' is
+  not defined, this option will do nothing.
+default: 5
+minimum: 0
+maximum: 5
+
   max-frame-size:
 $ref: /schemas/types.yaml#definitions/uint32
 description:
-- 
2.27.0