From patchwork Thu Nov 24 11:15:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 13054850 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5B450C43219 for ; Thu, 24 Nov 2022 11:19:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YjvN/cEM9M83nUtMjkLP6arC0o+VlkuWwVSN9By5P8w=; b=e16XdMuOgWUzME paHXYBFgVKJRWLMCP30V2uKSZdiG0oLF7hAdmaMMGozlWPBBAH0IaDmaaL9JEsS2HZybNVNGFgXUe F6f/hT4L0LIwrpePzNZMlxtDBa2LXbG++QlhDkXc+zk8d2rt6zwLs4nL0vfBdHi0WwxU0RryPX1Kl Kj9PxtYlGYzX9eZLqUEvraGH/4zc80tmwpAJVrudY9wCQJiqMdv/AqM5TfAq03MQ1+GShw7wOCiXk C2pQ9VQkA7p4uiC0OhfkLD7f/UjPbwQWztvM1VXTpC8OlBhgH9iXVjEoY15HoscXkUFABGqLRbCy7 yhwwh0KwjFO7o77knhJQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oyAFF-007zP3-IX; Thu, 24 Nov 2022 11:18:17 +0000 Received: from relay5-d.mail.gandi.net ([217.70.183.197]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oyADO-007yX1-5N for linux-arm-kernel@lists.infradead.org; Thu, 24 Nov 2022 11:16:24 +0000 Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id BB3351C0019; Thu, 24 Nov 2022 11:16:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1669288580; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s42uM41w9ysmCNZE9IaonrxU6NJPatbC7hYnvHselLY=; b=HCXhEKvsJrrzmpZ6OKhK9SABZxwycYvZjnfneAz5D7wWn4u74NVgS6KdAXFKxJbpDp2/z7 r65VnNGRgNSxE5YVkr8TvbkzUBcoHyLc0+xtGQGfHNIE8INTy3fKN+7VDEBb8Ugmf0OaHY /NFcd5FDP4v8zxfCoMxMaOEkWfs2E6PUUUUQseKALeXpwSq1JjYnFN1uy3Qg+OogXpJH7w 8lIJsNRNci3dc11gMMqiitnnrVp4V43sRQTMi41gkAnAAy6voQeUvLOafpB2Fm4QPaFSn5 yeRUm/AhHBjeBMx2vY9bV1PHXtlYId5m0LZqQoczoTIRPQnTeKg+csxB3042uQ== From: Miquel Raynal To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , netdev@vger.kernel.org Cc: Rob Herring , Krzysztof Kozlowski , devicetree@vger.kernel.org, Robert Marko , Luka Perkov , Thomas Petazzoni , Michael Walle , Marcin Wojtas , , , Vadym Kochan , Miquel Raynal Subject: [PATCH net-next v2 7/7] net: mvpp2: Consider NVMEM cells as possible MAC address source Date: Thu, 24 Nov 2022 12:15:56 +0100 Message-Id: <20221124111556.264647-8-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221124111556.264647-1-miquel.raynal@bootlin.com> References: <20221124111556.264647-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221124_031622_512865_7B70E881 X-CRM114-Status: GOOD ( 12.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The ONIE standard describes the organization of tlv (type-length-value) arrays commonly stored within NVMEM devices on common networking hardware. Several drivers already make use of NVMEM cells for purposes like retrieving a default MAC address provided by the manufacturer. What made ONIE tables unusable so far was the fact that the information where "dynamically" located within the table depending on the manufacturer wishes, while Linux NVMEM support only allowed statically defined NVMEM cells. Fortunately, this limitation was eventually tackled with the introduction of discoverable cells through the use of NVMEM layouts, making it possible to extract and consistently use the content of tables like ONIE's tlv arrays. Parsing this table at runtime in order to get various information is now possible. So, because many Marvell networking switches already follow this standard, let's consider using NVMEM cells as a new valid source of information when looking for a base MAC address, which is one of the primary uses of these new fields. Indeed, manufacturers following the ONIE standard are encouraged to provide a default MAC address there, so let's eventually use it if no other MAC address has been found using the existing methods. Link: https://opencomputeproject.github.io/onie/design-spec/hw_requirements.html Signed-off-by: Miquel Raynal --- drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c index eb0fb8128096..12f0b5ad8cee 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c @@ -6104,6 +6104,13 @@ static void mvpp2_port_copy_mac_addr(struct net_device *dev, struct mvpp2 *priv, } } + /* Only valid on OF enabled platforms */ + if (!of_get_mac_address_nvmem(to_of_node(fwnode), fw_mac_addr)) { + *mac_from = "nvmem cell"; + eth_hw_addr_set(dev, fw_mac_addr); + return; + } + *mac_from = "random"; eth_hw_addr_random(dev); }