Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp9313pxb; Fri, 29 Oct 2021 04:55:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwH5iVrZgCarqh1Slf3auRpYmctevlxjxUaUcMI78B/b85F4oBsESnlk0MM54ywGXKYKCkb X-Received: by 2002:a63:91c2:: with SMTP id l185mr7813014pge.360.1635508507609; Fri, 29 Oct 2021 04:55:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635508507; cv=none; d=google.com; s=arc-20160816; b=q8OZzkUcovcLohIgPlGvmKV2PHy4dyX4m+WePQAQsDIf1Cv9ASQZXuxwqx+pH8935c RTfj/yFrIjfPtCSbce3n3R9SKwRuoUkLmPNwu9gCNNVd2jFMM7Ks0Z36BmubK3bBJHsE QAmMp9damrkOAZOnuLcTcoJJSPkRZYCfW84Ujsr/l5DUVJHEP9XNW9xxlDAey21zMb4h PkVKcFscn/DiV43UOhWTChR2sDs9++ASscc/OatWxT+eW2Cnf7zEQd1HEYyt5q81cWLd kMxEMhPDj9Ssoo4ai+Cy1C6eG+yremz33soXMkZUKlAzbHLO0DcR69L3/STScfliaspw XBYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=tvw4l4wc3Fx0tfPHTbn3ehtcdJUjPQcZqllpfYHL3lE=; b=ykywC2s9wWKj5B79RJ3UCdMWFihiuUpLtUoMeuNBzxKpuFNFQxE3VaSKJ9QJCx8RXY lGG5YWakRE/iW8wZQWvdb0VNUdsZlV3addAjdti7ZgBSGDpi179WBzed3XxcGsBmqYrM smL6S8dUq3AZDAgdtESRr7PCIHtItQlsuVECOk/1ker1YsZQ/raBbz76y+FND/BI98cw se7/mJbT+rOYlYLdSFTEuckuhWEfEM3ZuvAsaypLETwF/P+FT8W05XwrTSDt/RmdL1Sv SvnV4tjIkz1cyQGTznk5NSSPEgjilUn8IwAK59Q7Lj/kE2uKu/ZZ8qupSuVuS3bCFkJn jouw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 72si7722123pgb.441.2021.10.29.04.54.54; Fri, 29 Oct 2021 04:55:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230362AbhJ2L4T convert rfc822-to-8bit (ORCPT + 99 others); Fri, 29 Oct 2021 07:56:19 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:40107 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229692AbhJ2L4R (ORCPT ); Fri, 29 Oct 2021 07:56:17 -0400 Received: (Authenticated sender: clement.leger@bootlin.com) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 4CB03240008; Fri, 29 Oct 2021 11:53:46 +0000 (UTC) Date: Fri, 29 Oct 2021 13:53:45 +0200 From: =?UTF-8?B?Q2zDqW1lbnQgTMOpZ2Vy?= To: Vladimir Oltean Cc: "David S. Miller" , Jakub Kicinski , Rob Herring , Claudiu Manoil , Alexandre Belloni , "UNGLinuxDriver@microchip.com" , Andrew Lunn , "netdev@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 1/3] net: ocelot: add support to get mac from device-tree Message-ID: <20211029135345.3b86b05a@fixe.home> In-Reply-To: <20211029113543.nhqwatylx4nrviei@skbuf> References: <20211028134932.658167-1-clement.leger@bootlin.com> <20211028134932.658167-2-clement.leger@bootlin.com> <20211028140611.m7whuwrzqxp2t53f@skbuf> <20211028161522.6b711bb2@xps-bootlin> <20211028142254.mbm7gczhhb4h5g3n@skbuf> <20211028163825.7ccb1dea@xps-bootlin> <20211028145142.xjgd3u2xz7kpijtl@skbuf> <20211029080937.152f1876@fixe.home> <20211029113543.nhqwatylx4nrviei@skbuf> Organization: Bootlin X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le Fri, 29 Oct 2021 11:35:43 +0000, Vladimir Oltean a écrit : > On Fri, Oct 29, 2021 at 08:09:37AM +0200, Clément Léger wrote: > > Le Thu, 28 Oct 2021 14:51:43 +0000, > > Vladimir Oltean 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 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 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 > > > > > > > > --- > > > > > > > > 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? > > > > BTW, this is actually done on sparx5 switch driver. > > Highly inconsistent, but true. I'm saying that because > Documentation/devicetree/bindings/net/microchip,sparx5-switch.yaml > says that "mac-address" should be under "switch", but then proceeds > to put it under "port@64" in the example. Agreed, additionally the driver uses the "mac-adress" property from the switch node to initialize the base mac. Anyway, I changed my patch to use mac-adress for each port and modified the yaml bindings to include ethernet-controller.yaml and use a "mac-address" property per port. > > Most likely not caught during review, I'm not sure if this could be > considered good practice. > > > > > > > > > + if (ret) > > > > > > > > + eth_random_addr(ocelot->base_mac); > > > > > > > > + > > > > > > > > ocelot->base_mac[5] &= 0xf0; > > > > > > > > > > > > > > > > return 0; > > > > > > > > -- > > > > > > > > 2.33.0 > > > > > > > > > > > > > > > > > > > > > > > -- > > Clément Léger, > > Embedded Linux and Kernel engineer at Bootlin > > https://bootlin.com -- Clément Léger, Embedded Linux and Kernel engineer at Bootlin https://bootlin.com