devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Clément Léger" <clement.leger@bootlin.com>
To: Vladimir Oltean <vladimir.oltean@nxp.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Claudiu Manoil <claudiu.manoil@nxp.com>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	"UNGLinuxDriver@microchip.com" <UNGLinuxDriver@microchip.com>,
	Andrew Lunn <andrew@lunn.ch>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/3] net: ocelot: add support to get mac from device-tree
Date: Thu, 28 Oct 2021 17:28:55 +0200	[thread overview]
Message-ID: <20211028172855.0f646cc7@xps-bootlin> (raw)
In-Reply-To: <20211028145142.xjgd3u2xz7kpijtl@skbuf>

Le Thu, 28 Oct 2021 14:51:43 +0000,
Vladimir Oltean <vladimir.oltean@nxp.com> a écrit :

> On Thu, Oct 28, 2021 at 04:38:25PM +0200, Clément Léger wrote:
> > Le Thu, 28 Oct 2021 14:22:55 +0000,
> > Vladimir Oltean <vladimir.oltean@nxp.com> a écrit :
> >   
> > > On Thu, Oct 28, 2021 at 04:15:22PM +0200, Clément Léger wrote:  
> > > > Le Thu, 28 Oct 2021 14:06:12 +0000,
> > > > Vladimir Oltean <vladimir.oltean@nxp.com> a écrit :
> > > >     
> > > > > On Thu, Oct 28, 2021 at 03:49:30PM +0200, Clément Léger
> > > > > wrote:    
> > > > > > Add support to get mac from device-tree using
> > > > > > of_get_mac_address.
> > > > > > 
> > > > > > Signed-off-by: Clément Léger <clement.leger@bootlin.com>
> > > > > > ---
> > > > > >  drivers/net/ethernet/mscc/ocelot_vsc7514.c | 5 ++++-
> > > > > >  1 file changed, 4 insertions(+), 1 deletion(-)
> > > > > > 
> > > > > > diff --git a/drivers/net/ethernet/mscc/ocelot_vsc7514.c
> > > > > > b/drivers/net/ethernet/mscc/ocelot_vsc7514.c index
> > > > > > d51f799e4e86..c39118e5b3ee 100644 ---
> > > > > > a/drivers/net/ethernet/mscc/ocelot_vsc7514.c +++
> > > > > > b/drivers/net/ethernet/mscc/ocelot_vsc7514.c @@ -526,7
> > > > > > +526,10 @@ static int ocelot_chip_init(struct ocelot
> > > > > > *ocelot, const struct ocelot_ops *ops)
> > > > > > ocelot_pll5_init(ocelot); 
> > > > > > -	eth_random_addr(ocelot->base_mac);
> > > > > > +	ret = of_get_mac_address(ocelot->dev->of_node,
> > > > > > ocelot->base_mac);      
> > > > > 
> > > > > Why not per port? This is pretty strange, I think.    
> > > > 
> > > > Hi Vladimir,
> > > > 
> > > > Currently, all ports share the same base mac address (5 first
> > > > bytes). The final mac address per port is computed in
> > > > ocelot_probe_port by adding the port number as the last byte of
> > > > the mac_address provided.
> > > > 
> > > > Clément    
> > > 
> > > Yes, I know that, but that's not my point.
> > > Every switch port should be pretty much compliant with
> > > ethernet-controller.yaml, if it could inherit that it would be
> > > even better. And since mac-address is an ethernet-controller.yaml
> > > property, it is pretty much non-obvious at all that you put the
> > > mac-address property directly under the switch, and manually add
> > > 0, 1, 2, 3 etc to it. My request was to parse the mac-address
> > > property of each port. Like this:
> > > 
> > > base_mac = random;
> > > 
> > > for_each_port() {
> > > 	err = of_get_mac_address(port_dn, &port_mac);
> > > 	if (err)
> > > 		port_mac = base_mac + port;
> > > }  
> > 
> > Ok indeed. So I will parse each port for a mac-address property. Do
> > you also want a fallback to use the switch base mac if not
> > specified in port or should I keep the use of a default random mac
> > as the base address anyway ?  
> 
> Isn't the pseudocode I posted above explicit enough? Sorry...
> Keep doing what the driver is doing right now, with an optional
> mac-address override per port.
> Why would we read the mac-address property of the switch? Which other
> switch driver does that? Are there device trees in circulation where
> this is being done?

Sorry, guess I'm a bit tired and missed out the base_mac = random...
Acked for the whole modification requested.

> 
> > > > > > +	if (ret)
> > > > > > +		eth_random_addr(ocelot->base_mac);
> > > > > > +
> > > > > >  	ocelot->base_mac[5] &= 0xf0;
> > > > > >  
> > > > > >  	return 0;
> > > > > > -- 
> > > > > > 2.33.0    
> > > > >       
> > >     
>   


  reply	other threads:[~2021-10-28 15:29 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-28 13:49 [PATCH 0/3] Add FDMA support on ocelot switch driver Clément Léger
2021-10-28 13:49 ` [PATCH 1/3] net: ocelot: add support to get mac from device-tree Clément Léger
2021-10-28 14:06   ` Vladimir Oltean
2021-10-28 14:15     ` Clément Léger
2021-10-28 14:22       ` Vladimir Oltean
2021-10-28 14:38         ` Clément Léger
2021-10-28 14:51           ` Vladimir Oltean
2021-10-28 15:28             ` Clément Léger [this message]
2021-10-29  6:09             ` Clément Léger
2021-10-29 11:35               ` Vladimir Oltean
2021-10-29 11:53                 ` Clément Léger
2021-10-28 13:49 ` [PATCH 2/3] dt-bindings: net: convert mscc,vsc7514-switch bindings to yaml Clément Léger
2021-10-28 13:49 ` [PATCH 3/3] net: ocelot: add FDMA support Clément Léger
2021-10-28 14:12   ` Vladimir Oltean
2021-10-28 14:31     ` Clément Léger
2021-10-28 14:54       ` Vladimir Oltean
2021-10-28 14:07 ` [PATCH 0/3] Add FDMA support on ocelot switch driver Vladimir Oltean
2021-10-28 14:23   ` Clément Léger

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=20211028172855.0f646cc7@xps-bootlin \
    --to=clement.leger@bootlin.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andrew@lunn.ch \
    --cc=claudiu.manoil@nxp.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --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).