From patchwork Fri Oct 28 09:23:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 12173 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp718705wru; Fri, 28 Oct 2022 02:26:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6VifGS6MZaq6n1YTqveOW3UZWQNlJ88pNRxn6vb41iMG1e2s4G4Vp0/O4XdDH3kIAEN+KG X-Received: by 2002:a65:6e81:0:b0:460:7b7a:af13 with SMTP id bm1-20020a656e81000000b004607b7aaf13mr45125977pgb.364.1666949203939; Fri, 28 Oct 2022 02:26:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666949203; cv=none; d=google.com; s=arc-20160816; b=HAaLE9wVnLoMyVw5zOZRoWI72TfIrtgZTjeasrc5fmyPCtwsjol2ioSwrJP82IKvzO YEmwwxJ9KfBhgVucHuVfwGSd8xuXdcPrNBj26+WqNbS2OpUhkLgL3hT2ivIXUtjw2OW0 4tih2ORdSkehDFtaHFWMGdZX38HzQK8Dh96nimSYjt0tHTRJILH7G7+2WiI8W+M2gOQp CtmbiRMzdZ2Ov/u1Hobiz3K53AzoqRCGe2iNXRkRa8R1pvKTFSWZ+YwGZn4dfEdx58KG Egn31w+TSKwFu6fIqutjUs+5WqxJUHOazeqjBSEDg/skG0hl8F0ro7GbrGaFazHEQ18V vsQg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yUTicOKbv8RLfweIGmVZD1Tj8qID+/JKOtCLRTZ7HEw=; b=Uqon0PB3A5Mse3Z/6VW7/yHKy6KSiSon0s64HqWaXlKRhO4p/8gQNpC24Nzqkoomdy mFQ6BiWCnsNRAnOO2JTjAXJL5irANUqYm03aYc+Hu6ODFO0r03zpM3gRl3ATTFmjMVX7 DHYZ9rrQ3b38SDPjIFUfyaKkMUOXtsHoQyHGt40VfTNrGS1J/NizuPi9qfXf0yOwqe9Y tkFWEqMQMpyAHJOQo0Ly0QAmJ0xFSpRCXN7HMpueIUvaWhW8N29sdaraiPllQLovoJ1J 6AHzK+1UqwViUSs6mmXuyiFpcjRm65Hj3eJBX7Rnma+MfoVLITPSdY2xTE0Io8ckaiQe HAbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="GgLB/cY0"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q145-20020a632a97000000b00430b25c0134si5183963pgq.670.2022.10.28.02.26.30; Fri, 28 Oct 2022 02:26:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="GgLB/cY0"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229955AbiJ1JXt (ORCPT + 99 others); Fri, 28 Oct 2022 05:23:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229730AbiJ1JXp (ORCPT ); Fri, 28 Oct 2022 05:23:45 -0400 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD7AF1C6BE2; Fri, 28 Oct 2022 02:23:43 -0700 (PDT) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 5CDF2100004; Fri, 28 Oct 2022 09:23:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1666949022; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yUTicOKbv8RLfweIGmVZD1Tj8qID+/JKOtCLRTZ7HEw=; b=GgLB/cY0PTTTpDraZEpGuHtzKP09501pylMj5lbIDeb4S2DiIuv28h/SJGwaaYV/f3MdE3 xRC6d20K9gUgEk/NMw2ad+5IP7bOJ2IF4ilUMYnNhswVDAhrmDwsaQ9EiQkGKn16nBifN8 V4FGhr5VzLLPQ5+ct5fIBPo/y/kR9wWOPzipZJHEEoF9VKaYKyfkOhj5im+qnz9NzA6UzY h05VUASaLn8LxzCF3A1+v20MNdXLqiAdN2Ddw/pl5X7zDNW/UxtmACDnEkJ9xzXZQj/M1j PRhklCb2J2YuXQLzu/1IEYXxBoUybzxl/VIx6MkTl3/ACotgnObmqKOh+Go3Sw== From: Miquel Raynal To: Srinivas Kandagatla , , Rob Herring , Krzysztof Kozlowski , devicetree@vger.kernel.org Cc: Marcin Wojtas , Russell King , Maxime Chevallier , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , netdev@vger.kernel.org, Robert Marko , Thomas Petazzoni , Michael Walle , Miquel Raynal Subject: [PATCH 1/5] dt-bindings: vendor-prefixes: Add ONIE Date: Fri, 28 Oct 2022 11:23:33 +0200 Message-Id: <20221028092337.822840-2-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028092337.822840-1-miquel.raynal@bootlin.com> References: <20221028092337.822840-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747922928053267782?= X-GMAIL-MSGID: =?utf-8?q?1747922928053267782?= As described on their website (see link below), "The Open Network Install Environment (ONIE) is an open source initiative that defines an open “install environment” for modern networking hardware." It is not a proper corporation per-se but rather more a group which tries to spread the use of open source standards in the networking hardware world. Link: https://opencomputeproject.github.io/onie/ Signed-off-by: Miquel Raynal Acked-by: Rob Herring --- Please note ONIE is not a "company" but rather more an open source group. I don't know if there will be other uses of this prefix but I figured out it would be best to describe it to avoid warnings, but I'm open to other solutions otherwise. Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml index 6e323a380294..65a74026cf2b 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml @@ -927,6 +927,8 @@ patternProperties: description: One Laptop Per Child "^oneplus,.*": description: OnePlus Technology (Shenzhen) Co., Ltd. + "^onie,.*": + description: Open Network Install Environment group "^onion,.*": description: Onion Corporation "^onnn,.*": From patchwork Fri Oct 28 09:23:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 12174 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp718737wru; Fri, 28 Oct 2022 02:26:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4aUIudawDvIABvdIyAqkRy8P5a0HidoTMiKk82LAkodSWMzM1nHDAGSqGsX6R4NJzIJsIw X-Received: by 2002:a63:1923:0:b0:441:2c12:f704 with SMTP id z35-20020a631923000000b004412c12f704mr47009414pgl.398.1666949208185; Fri, 28 Oct 2022 02:26:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666949208; cv=none; d=google.com; s=arc-20160816; b=rYT8CSqOOTNNGMIMoxU7sMWdpGco2vtW8pyabVDRNKsMYtawmPhhA9cijqW3mkGoq9 5H4mDSj/+mMVhoBJt99HN2OgaWW6sa1ZsAwu+vJ3awiANvMqSOCiwbro38HldDV6Cyx/ ASyutIOmbi/2fErdtkWrMwQ1xvyGWZMmgyQH2coPYjkNLHEDXbUZp5/sXLY+I+R3yNk6 elafjyMY4c6QbTlnPsD0uDAfTrUiCOOqZRdvIA9h55in7ocnNNibiIcrWE6pIxfkDkwQ +HsHtsI9ZxYZ8VaA8MfcnIorXS8zJjT07273AqXOJwebIGK7xqY3IN65gFeRKt/z1dyA C6JA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MZ/yZgTa81hnw0HFvxGrTGClMz2ZbHdXcriFnwHnOiY=; b=aOKR6H0JKHMaKXO9R65ikmEBdU3zJPddzMlgI9MmCQTv45yen3KKqHBjzuu65cYUlf l2LTfl6RHg6KS9Y14vGGTEveIc7k4b6vnnz0mI+L3UBthAX0db07KpyDxN7SdICEUz5u HehBkfyttbMnHgu7yv4ndE3G92jRpLQZTvwV87Q5V5onypt85cZHJWKs3IacEBdlxfz1 oCH60hIYISDGpm7+O6isndiORkn4+2ytxMT8k7TDZNsvHsNUbtC172zfEmM/zC+TxdQE fotOXW2LzShbeR9YJxwhOQjDlCxjCXKayFeoQjprxAFqKYZt2zGepV3Ey69pGCM3KiXq lfCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=i7ZnyCOs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g14-20020a63fa4e000000b0046004f18c6csi5170520pgk.456.2022.10.28.02.26.35; Fri, 28 Oct 2022 02:26:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=i7ZnyCOs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229980AbiJ1JXw (ORCPT + 99 others); Fri, 28 Oct 2022 05:23:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229880AbiJ1JXq (ORCPT ); Fri, 28 Oct 2022 05:23:46 -0400 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5ECBF1C5A44; Fri, 28 Oct 2022 02:23:45 -0700 (PDT) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 74CD610000F; Fri, 28 Oct 2022 09:23:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1666949024; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MZ/yZgTa81hnw0HFvxGrTGClMz2ZbHdXcriFnwHnOiY=; b=i7ZnyCOsiLCqD552SFIgCXU24QxcRIL4DmvTxIl6B/HkA02h0XOVyxFfcPBq/APLZfoUEz Wbk6GJ5S5jGHO3UcOiPn+o1V2OLbeSrc52eJdlCeaOTdU3wWlRFwDqINCy0g8Xdt/Gn80B IC8RfqRL//NKLDfBQc537fZGIoTd2G4beS64yzSpstN+qekRe4FXnyES01qmeNw1dBZz8i iCTrkTKt6+jHVhbNg5XF+fNgB4CRBK1ujxPDr4lVI2Xx5ffCQESPqyDQBn2ovUPylDor09 HxTk4LNhiwaaaGM9+aI8pf+WDPuJsDZbAWgI8M/jnv2qjbiZuIVwrzLfU9Zigw== From: Miquel Raynal To: Srinivas Kandagatla , , Rob Herring , Krzysztof Kozlowski , devicetree@vger.kernel.org Cc: Marcin Wojtas , Russell King , Maxime Chevallier , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , netdev@vger.kernel.org, Robert Marko , Thomas Petazzoni , Michael Walle , Miquel Raynal Subject: [PATCH 2/5] dt-bindings: nvmem: add YAML schema for the ONIE tlv layout Date: Fri, 28 Oct 2022 11:23:34 +0200 Message-Id: <20221028092337.822840-3-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028092337.822840-1-miquel.raynal@bootlin.com> References: <20221028092337.822840-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747922933037327282?= X-GMAIL-MSGID: =?utf-8?q?1747922933037327282?= Add a schema for the ONIE tlv NVMEM layout that can be found on any ONIE compatible networking device. Signed-off-by: Miquel Raynal --- .../nvmem/layouts/onie,tlv-layout.yaml | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 Documentation/devicetree/bindings/nvmem/layouts/onie,tlv-layout.yaml diff --git a/Documentation/devicetree/bindings/nvmem/layouts/onie,tlv-layout.yaml b/Documentation/devicetree/bindings/nvmem/layouts/onie,tlv-layout.yaml new file mode 100644 index 000000000000..388547d46646 --- /dev/null +++ b/Documentation/devicetree/bindings/nvmem/layouts/onie,tlv-layout.yaml @@ -0,0 +1,96 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/nvmem/layouts/onie,tlv-layout.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NVMEM layout of the ONIE tlv table + +maintainers: + - Miquel Raynal + +description: + Modern networking hardware implementing the Open Compute Project ONIE + infrastructure shall provide a non-volatile memory with a table whose the + content is well specified and gives many information about the manufacturer + (name, country of manufacture, etc) as well as device caracteristics (serial + number, hardware version, mac addresses, etc). The underlaying device type + (flash, EEPROM,...) is not specified. The exact location of each value is also + dynamic and should be discovered at run time because it depends on the + parameters the manufacturer decided to embed. + +allOf: + - $ref: "../nvmem.yaml#" + +select: + properties: + compatible: + contains: + const: onie,tlv-layout + required: + - compatible + +properties: + compatible: true + + product-name: true + + part-number: true + + serial-number: true + + mac-address: + type: object + description: + Base MAC address for all on-module network interfaces. The first + argument of the phandle will be treated as an offset. + + properties: + "#nvmem-cell-cells": + const: 1 + + additionalProperties: false + + manufacture-date: true + + device-version: true + + label-revision: true + + platforn-name: true + + onie-version: true + + num-macs: true + + manufacturer: true + + country-code: true + + vendor: true + + diag-version: true + + service-tag: true + + vendor-extension: true + +required: + - compatible + +additionalProperties: false + +examples: + - | + onie { + compatible = "onie,tlv-layout", "vendor,device"; + + serial_number: serial-number { + }; + + mac_address: mac-address { + #nvmem-cell-cells = <1>; + }; + }; + +... From patchwork Fri Oct 28 09:23:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 12172 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp718442wru; Fri, 28 Oct 2022 02:26:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4siZZ+L2qtTSE+wOjqyirO3ZAMDfygDEDTg0FpT6AnWk4iRvCau0uCFnAuGI7V7EBUAMCN X-Received: by 2002:a17:90b:3c0e:b0:213:5ce5:e60c with SMTP id pb14-20020a17090b3c0e00b002135ce5e60cmr13281425pjb.157.1666949162712; Fri, 28 Oct 2022 02:26:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666949162; cv=none; d=google.com; s=arc-20160816; b=Fj+cT1J9/dTnzEBypAJznLOHWZS/nMs76lzWyd82h2lnZbW95KJSebx4MVwbCDt3h+ oCHW90hJV1c4GmexhdnfWac5oqeakACGVRlBNgo947QY/ZzLZVVW3EltRZPhGsI61e8u BLLHeun6ga1d1Fdx6qztmNMSexOZ3hp5eSrgQzrxZamH7+/l3ipQxFutqxVXsjs0kIeB vC+InV2SKwWH4NG6A2LCP/i/kHyfvpSzmVEh0rA1BMcAyuleJMvbKiQ1vn+gy+600eCj /eHSh2Fn9yfYjLIpPRmUqGpi5sJhiAGwP7sowDmiApQ4AbaUfGfiBJuxBAUFnyIQ2iZb TcsQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KVCo+qJ107g74qlxH0135gqiKeQVlluCp/a9Jyn0PmE=; b=L0KUpEK7W/cW7ZVOd+Hl27feqOQmkkbf9IbldttCvA7PUD1hfUiX77MfMOvglMHN24 AFTmvt5HBYbOrqo8wB8XxgffKtwbE3ZZbP6Xpor0/eXEVbEzHnAuYZvSPeaGtjLuxydN hfunbwBgWDJlZ8Wp6bItO/ljYhLpD/n1x+ur0TZEgnePoIL75JcEvrzrXV+XyPgAeysX zoRxCeaRJlsrRl1OMaTVD0Vd16iWzanodxXtduQ5A+znGisnX/LwaJNxfzDRo2u5Q7JN RpyH83d58JPuDKLsJlYomo14XmrMtpJTNIZV3WF0/AXNVGNVAnyfNsps/2AP7kc2ktsv PxrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=HpD8XyUu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020a170902b94b00b0017f8290fcf0si4551671pls.272.2022.10.28.02.25.48; Fri, 28 Oct 2022 02:26:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=HpD8XyUu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229458AbiJ1JYG (ORCPT + 99 others); Fri, 28 Oct 2022 05:24:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229930AbiJ1JXs (ORCPT ); Fri, 28 Oct 2022 05:23:48 -0400 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 267AE1C7101; Fri, 28 Oct 2022 02:23:46 -0700 (PDT) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 2B0CD100010; Fri, 28 Oct 2022 09:23:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1666949025; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KVCo+qJ107g74qlxH0135gqiKeQVlluCp/a9Jyn0PmE=; b=HpD8XyUuZK+FJhasdTq2lPAygD8pMLYGMJSv3/vWKQ4EpIXi2YbEy/M+C5dN5qrkCmjVV1 eM4LbHMvR2ltEHpAWrO1SQUoGrQE2Hf6hnM2h+VGkRIKaa+ouRlrX2YNSRZbuYRvXZLpnH CkDbmKh0pw8WajKbGEA1pNBmKR6JUe+wEexmP3AB229AlBWG6bq7XpwJYQYExnKlvvYxmZ 6GAkXVRGBLCSIFib8GZ1vplSmvZniZP5L+5n+p9qPzmh068jWS6euQ+1VsmTcMf3Bb62tj TFO2oSra5W6BtlQaGgx41kQDaSt2I8pq2sOjjKpZRZ8wgdoaLuYf7zyIvdlulQ== From: Miquel Raynal To: Srinivas Kandagatla , , Rob Herring , Krzysztof Kozlowski , devicetree@vger.kernel.org Cc: Marcin Wojtas , Russell King , Maxime Chevallier , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , netdev@vger.kernel.org, Robert Marko , Thomas Petazzoni , Michael Walle , Miquel Raynal Subject: [PATCH 3/5] nvmem: layouts: Add ONIE tlv layout driver Date: Fri, 28 Oct 2022 11:23:35 +0200 Message-Id: <20221028092337.822840-4-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028092337.822840-1-miquel.raynal@bootlin.com> References: <20221028092337.822840-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747922885275044866?= X-GMAIL-MSGID: =?utf-8?q?1747922885275044866?= This layout applies no top of any non volatile storage device containing an ONIE table factory flashed. This table follows the tlv (type-length-value) organization described in the link below. We cannot afford using regular parsers because the content of these tables is manufacturer specific and must be dynamically discovered. Link: https://opencomputeproject.github.io/onie/design-spec/hw_requirements.html Signed-off-by: Miquel Raynal --- drivers/nvmem/layouts/Kconfig | 9 ++ drivers/nvmem/layouts/Makefile | 1 + drivers/nvmem/layouts/onie-tlv.c | 240 +++++++++++++++++++++++++++++++ 3 files changed, 250 insertions(+) create mode 100644 drivers/nvmem/layouts/onie-tlv.c diff --git a/drivers/nvmem/layouts/Kconfig b/drivers/nvmem/layouts/Kconfig index 3db0c139a8b7..ff346f9f9273 100644 --- a/drivers/nvmem/layouts/Kconfig +++ b/drivers/nvmem/layouts/Kconfig @@ -19,4 +19,13 @@ config NVMEM_LAYOUT_U_BOOT_ENV If unsure, say N. +config NVMEM_LAYOUT_ONIE_TLV + bool "ONIE tlv support" + select CRC32 + help + Say Y here if you want to support the Open Compute Project ONIE + Type-Length-Value standard table. + + If unsure, say N. + endmenu diff --git a/drivers/nvmem/layouts/Makefile b/drivers/nvmem/layouts/Makefile index dae93fff2b85..0ec076cf541d 100644 --- a/drivers/nvmem/layouts/Makefile +++ b/drivers/nvmem/layouts/Makefile @@ -5,3 +5,4 @@ obj-$(CONFIG_NVMEM_LAYOUT_SL28_VPD) += sl28vpd.o obj-$(CONFIG_NVMEM_LAYOUT_U_BOOT_ENV) += u-boot-env.o +obj-$(CONFIG_NVMEM_LAYOUT_ONIE_TLV) += onie-tlv.o diff --git a/drivers/nvmem/layouts/onie-tlv.c b/drivers/nvmem/layouts/onie-tlv.c new file mode 100644 index 000000000000..5b33f283d8dc --- /dev/null +++ b/drivers/nvmem/layouts/onie-tlv.c @@ -0,0 +1,240 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * ONIE tlv NVMEM cells provider + * + * Copyright (C) 2022 Open Compute Group ONIE + * Author: Miquel Raynal + * Based on the nvmem driver written by: Vadym Kochan + * Inspired by the first layout written by: Rafał Miłecki + */ + +#include +#include +#include +#include +#include + +#define ONIE_TLV_MAX_LEN 2048 +#define ONIE_TLV_CRC_FIELD_SZ 6 +#define ONIE_TLV_CRC_SZ 4 +#define ONIE_TLV_HDR_ID "TlvInfo" + +struct onie_tlv_hdr { + u8 id[8]; + u8 version; + __be16 data_len; +} __packed; + +struct onie_tlv { + u8 type; + u8 len; +} __packed; + +static const char *onie_tlv_cell_name(u8 type) +{ + switch (type) { + case 0x21: + return "product-name"; + case 0x22: + return "part-number"; + case 0x23: + return "serial-number"; + case 0x24: + return "mac-address"; + case 0x25: + return "manufacture-date"; + case 0x26: + return "device-version"; + case 0x27: + return "label-revision"; + case 0x28: + return "platforn-name"; + case 0x29: + return "onie-version"; + case 0x2A: + return "num-macs"; + case 0x2B: + return "manufacturer"; + case 0x2C: + return "country-code"; + case 0x2D: + return "vendor"; + case 0x2E: + return "diag-version"; + case 0x2F: + return "service-tag"; + case 0xFD: + return "vendor-extension"; + case 0xFE: + return "crc32"; + default: + break; + } + + return NULL; +} + +static int onie_tlv_mac_read_cb(const char *id, int index, + unsigned int offset, void *buf, + size_t bytes) +{ + eth_addr_add(buf, index); + + return 0; +} + +static nvmem_cell_post_process_t onie_tlv_read_cb(u8 type, u8 *buf) +{ + switch (type) { + case 0x24: + return &onie_tlv_mac_read_cb; + default: + break; + } + + return NULL; +} + +static int onie_tlv_add_cells(struct device *dev, struct nvmem_device *nvmem, + size_t data_len, u8 *data) +{ + struct nvmem_cell_info cell = {}; + struct onie_tlv tlv; + unsigned int hdr_len = sizeof(struct onie_tlv_hdr); + unsigned int offset = 0; + int ret; + + while (offset < data_len) { + memcpy(&tlv, data + offset, sizeof(tlv)); + if (offset + tlv.len >= data_len) { + dev_err(dev, "Out of bounds field (0x%x bytes at 0x%x)\n", + tlv.len, hdr_len + offset); + break; + } + + cell.name = onie_tlv_cell_name(tlv.type); + if (!cell.name) + continue; + + cell.offset = hdr_len + offset + sizeof(tlv.type) + sizeof(tlv.len); + cell.bytes = tlv.len; + cell.np = of_get_child_by_name(dev->of_node, cell.name); + cell.read_post_process = onie_tlv_read_cb(tlv.type, data + offset + sizeof(tlv)); + + ret = nvmem_add_one_cell(nvmem, &cell); + if (ret) + return ret; + + offset += sizeof(tlv) + tlv.len; + } + + return 0; +} + +static bool onie_tlv_hdr_is_valid(struct device *dev, struct onie_tlv_hdr *hdr) +{ + if (memcmp(hdr->id, ONIE_TLV_HDR_ID, sizeof(hdr->id))) { + dev_err(dev, "Invalid header\n"); + return false; + } + + if (hdr->version != 0x1) { + dev_err(dev, "Invalid version number\n"); + return false; + } + + return true; +} + +static bool onie_tlv_crc_is_valid(struct device *dev, size_t table_len, u8 *table) +{ + struct onie_tlv crc_hdr; + u32 read_crc, calc_crc; + __be32 crc_be; + + memcpy(&crc_hdr, table + table_len - ONIE_TLV_CRC_FIELD_SZ, sizeof(crc_hdr)); + if (crc_hdr.type != 0xfe || crc_hdr.len != ONIE_TLV_CRC_SZ) { + dev_err(dev, "Invalid CRC field\n"); + return false; + } + + /* The table contains a JAMCRC, which is XOR'ed compared to the original + * CRC32 implementation as known in the Ethernet world. + */ + memcpy(&crc_be, table + table_len - ONIE_TLV_CRC_SZ, ONIE_TLV_CRC_SZ); + read_crc = be32_to_cpu(crc_be); + calc_crc = crc32(~0, table, table_len - ONIE_TLV_CRC_SZ) ^ 0xFFFFFFFF; + if (read_crc != calc_crc) { + dev_err(dev, "Invalid CRC read: 0x%08x, expected: 0x%08x\n", + read_crc, calc_crc); + return false; + } + + return true; +} + +static int onie_tlv_parse_table(struct device *dev, struct nvmem_device *nvmem, + struct nvmem_layout *layout) +{ + struct onie_tlv_hdr hdr; + size_t table_len, data_len, hdr_len; + u8 *table, *data; + int ret; + + ret = nvmem_device_read(nvmem, 0, sizeof(hdr), &hdr); + if (ret < 0) + return ret; + + if (!onie_tlv_hdr_is_valid(dev, &hdr)) { + dev_err(dev, "Invalid ONIE TLV header\n"); + return -EINVAL; + } + + hdr_len = sizeof(hdr.id) + sizeof(hdr.version) + sizeof(hdr.data_len); + data_len = be16_to_cpu(hdr.data_len); + table_len = hdr_len + data_len; + if (table_len > ONIE_TLV_MAX_LEN) { + dev_err(dev, "Invalid ONIE TLV data length\n"); + return -EINVAL; + } + + table = devm_kmalloc(dev, table_len, GFP_KERNEL); + if (!table) + return -ENOMEM; + + ret = nvmem_device_read(nvmem, 0, table_len, table); + if (ret != table_len) + goto free_data_buf; + + if (!onie_tlv_crc_is_valid(dev, table_len, table)) { + ret = -EINVAL; + goto free_data_buf; + } + + data = table + hdr_len; + ret = onie_tlv_add_cells(dev, nvmem, data_len, data); + if (ret) + goto free_data_buf; + +free_data_buf: + kfree(table); + + return ret; +} + +static const struct of_device_id onie_tlv_of_match_table[] = { + { .compatible = "onie,tlv-layout", }, + {}, +}; + +static struct nvmem_layout onie_tlv_layout = { + .name = "ONIE tlv layout", + .of_match_table = onie_tlv_of_match_table, + .add_cells = onie_tlv_parse_table, +}; + +static int __init onie_tlv_init(void) +{ + return nvmem_layout_register(&onie_tlv_layout); +} +subsys_initcall(onie_tlv_init); From patchwork Fri Oct 28 09:23:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 12170 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp718392wru; Fri, 28 Oct 2022 02:25:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5jCDiqcZdFzQODkgmgk3iCI6wwMCW3RlbOM8gccF6X75wa9oOw0AZeYs3OUOnaMyiohflE X-Received: by 2002:a63:516:0:b0:46e:d2ea:22cb with SMTP id 22-20020a630516000000b0046ed2ea22cbmr29380370pgf.144.1666949155105; Fri, 28 Oct 2022 02:25:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666949155; cv=none; d=google.com; s=arc-20160816; b=GTwbUAxgrIzRC8CI86janhED5ch7Fegnh9C7t6OECpfGPQJ3N74QA2rw95jnG4+pPb 3wrse+7d+poWqeokscrugc7ofD8Ny2VfKLP85V5ADWwSTpofKZsrfzz+IOy0+MVropEN yHetYtt7sQ+odjF0l7O/VSY9N0vrILJZHpfPLAZ0Pq/JiUVATW4HZNJNVZkATsAnVzKr WyEbxfwhCSGAUnnm+PUjFD/u8hP9FmU4YtgoSJudPFGdCfHTKJQzm1g4Tu4bYcZglPjj QdG9pgK+oMGnl045x/KYqAZdqYMZd7ReP1uTmAwO0VSNKqttIWfWVvcamaMLB+Pa6y3t t65A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hnsjqzi8KC7wPXREpxdV4ZozmypOaFOW6/aX9+fhJ/c=; b=kxz6oDDE3dXKArdEGlRw4KPB/yxkgU5EfyNX2DpK4CW8UCNTbqnmIU2fzCtjBurubZ UVmDDxaR5T6IsYbHhy0FLY3k+44rQC3+hXLNYRCEpDAN11N8kcfU0I7BqUvP8ZQ1yDLI Pi2zVUl0svgpIoZCPcYEamaMjvhN7OlWz7nFnj0HJdhDsgoJ83pK6nWSJQmh3+ouAMmg O8mqT85CKZ9RxwzH2vwe6cABsADnQur8Fw5elXx2FT26vcUA06IeGFlEewQsSqlXGDJZ PWY+ZYBjKS/aYyY2lDdfwjXa9qW2H6N4Gfeul4edG8hIYt3H/FBMnCu3ZdALAJ3o1TD/ 8a9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Th3FHfeU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x12-20020a63db4c000000b0045c59e9a8a9si4993570pgi.322.2022.10.28.02.25.42; Fri, 28 Oct 2022 02:25:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Th3FHfeU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230013AbiJ1JYK (ORCPT + 99 others); Fri, 28 Oct 2022 05:24:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbiJ1JXu (ORCPT ); Fri, 28 Oct 2022 05:23:50 -0400 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5BE81C711A; Fri, 28 Oct 2022 02:23:48 -0700 (PDT) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id D3E0010000C; Fri, 28 Oct 2022 09:23:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1666949027; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hnsjqzi8KC7wPXREpxdV4ZozmypOaFOW6/aX9+fhJ/c=; b=Th3FHfeUS6KLMutykD5aqNnWB3NNqAYB0hg4/0NOklEZ6u0sXvf/DRxsWxllfYM8w7EAKO W+Deldf/LK56yXld4P96HAGuO+hcP+ts8RmbHHgvZ/jokDR9NGEVt+4MfuiQqMTvx4psJd /sI58uIT0bhr/XwqOdXtat7mha2aSxM2L+RLYg+CcAfXtmxIjoht1cZaeh9fsdtMteBych 3j438HCMuexxV8pWp25bFDPXBdOAoq2G8sENguuv6g2A+ofRUdfWqBxBrOPtM5azHzgt/e SETZUpvNHsiXllnuPZN2l7xQl0agRoSeg9Q8qZRc/s5C6/duX8dHwQ94ltDHkA== From: Miquel Raynal To: Srinivas Kandagatla , , Rob Herring , Krzysztof Kozlowski , devicetree@vger.kernel.org Cc: Marcin Wojtas , Russell King , Maxime Chevallier , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , netdev@vger.kernel.org, Robert Marko , Thomas Petazzoni , Michael Walle , Miquel Raynal Subject: [PATCH 4/5] MAINTAINERS: Add myself as ONIE tlv NVMEM layout maintainer Date: Fri, 28 Oct 2022 11:23:36 +0200 Message-Id: <20221028092337.822840-5-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028092337.822840-1-miquel.raynal@bootlin.com> References: <20221028092337.822840-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747922877122099390?= X-GMAIL-MSGID: =?utf-8?q?1747922877122099390?= Following the introduction of the bindings for this NVMEM parser and the layout driver, add myself as maintainer. Signed-off-by: Miquel Raynal --- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index cf0f18502372..be387e7e33a1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -15328,6 +15328,12 @@ S: Maintained F: drivers/mtd/nand/onenand/ F: include/linux/mtd/onenand*.h +ONIE TLV NVMEM LAYOUT DRIVER +M: Miquel Raynal +S: Maintained +F: Documentation/devicetree/bindings/nvmem/layouts/onie,tlv-layout.yaml +F: drivers/nvmem/layouts/onie-tlv.c + ONION OMEGA2+ BOARD M: Harvey Hunt L: linux-mips@vger.kernel.org From patchwork Fri Oct 28 09:23:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 12171 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp718416wru; Fri, 28 Oct 2022 02:25:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6KGxVnZcwnY/5vU8yVZt9M4UcRj7fN8htRKZSFDEIuaBhIHvCF7+PyRau57de9gableg7p X-Received: by 2002:a17:90a:5e04:b0:20b:1f20:5069 with SMTP id w4-20020a17090a5e0400b0020b1f205069mr14965557pjf.126.1666949158897; Fri, 28 Oct 2022 02:25:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666949158; cv=none; d=google.com; s=arc-20160816; b=cbw24cRBlAxH+HT4DPH+H93QUSRbdX2LRwAVHv1EuUPuCPyVdXiEHYxne/FX4RkfKR pIwSa8Ki052zgcBkwXlUAo8/AQuPQwwG98Xz4Cjrc5nGb7WgtikpKzlvMwLCkhwBERra Z00bXS1yvcDh3R/UGEPCL5pVYwlK4QWz4CIiv5h8IUZVXVtsTV+A6aXPG/o44DCOABwH VlSSg1iHe1QkzFo/xQcwUg/MX/EFiAYVJuwPzkzs9TI4sZy/PRpHiY4njkCbo9rsTI7T BiBMkfECvj4EKs7Q+c1vPYBYlRYc8EM85ImxRWpvwZHiqc4lwjeqHdRj0uKTtdtkZADM +brw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=N0LdsNh6jfmS3zzQ/1xHfQe2PU60JuVsRUd6fVEbmxM=; b=KkY34HoFq7BT5vmA/90NwxZPJoNMQtoJhJacGzw6h15B8cXf2VdyUcjsDq59n1Aa9x CCE8U7C8JnUUMY26VBQS8UA/Dy/0FkNDUxXTeV10TpT29lcJ0PrFVyJxDygglm0HuKrB IBNKS7KwKguNnV6Pybv2N5FnRxEJdhUKCVbjhNUwXlybGKQ7H+SVeJI30PqxgYk6frOG V3AgjzOtegK68OAOAmN84knQBtBdbFgFR7aBR9Ogdw0yBIn2d5wdE+t8YSfQmoPqo64/ mJiAR3Fvbjvtm+Q7DcPjsDN5JdUUMOe2kVP8vbesN3V+pzwbVCGq2M6yLxtiHCCwcFgK RqEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=D0y+uY9C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z24-20020a63b918000000b004347b49d045si4915537pge.631.2022.10.28.02.25.45; Fri, 28 Oct 2022 02:25:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=D0y+uY9C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229871AbiJ1JYM (ORCPT + 99 others); Fri, 28 Oct 2022 05:24:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229682AbiJ1JYG (ORCPT ); Fri, 28 Oct 2022 05:24:06 -0400 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A56B1C7135; Fri, 28 Oct 2022 02:23:51 -0700 (PDT) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id B14E4100006; Fri, 28 Oct 2022 09:23:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1666949029; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N0LdsNh6jfmS3zzQ/1xHfQe2PU60JuVsRUd6fVEbmxM=; b=D0y+uY9CbRgJcHkbTj4anF+Q3fpTaD1HgKcDQBeSwkB2QpkCnKJdxmTwn/aPVfzqSOp0fA GaKLWZmlNl3NA/sAgOWwCZcMLvCeGvmGWB8KicS7ABa9Bh3NQRNeuf30uCKPPfgue61JZY MmhuiPHYjxEHJWiNPWWWOUoKCAR8Rvd4wkxQ2lynjAszgraXCjXjQe8QSyuRmu0pp+QHcD yK82vRThI3NONBYV/s3x+7YVvm1e0MSjYZMGQzUMp12frGfWwjQv/Jdb4WXKGh/P4Wk9qi Ymu0Ob9EMIapvE9wI9NQo+/LYxkSJKfpBuDlDyKEcn7lpYSPRxiDle+NB9wGrw== From: Miquel Raynal To: Srinivas Kandagatla , , Rob Herring , Krzysztof Kozlowski , devicetree@vger.kernel.org Cc: Marcin Wojtas , Russell King , Maxime Chevallier , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , netdev@vger.kernel.org, Robert Marko , Thomas Petazzoni , Michael Walle , Miquel Raynal Subject: [PATCH 5/5] net: mvpp2: Consider NVMEM cells as possible MAC address source Date: Fri, 28 Oct 2022 11:23:37 +0200 Message-Id: <20221028092337.822840-6-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221028092337.822840-1-miquel.raynal@bootlin.com> References: <20221028092337.822840-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747922881066703061?= X-GMAIL-MSGID: =?utf-8?q?1747922881066703061?= 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 --- Hello, I suppose my change is safe but I don't want to break existing setups so a review on this would be welcome! drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c index eb0fb8128096..7c8c323f4411 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c @@ -6104,6 +6104,12 @@ static void mvpp2_port_copy_mac_addr(struct net_device *dev, struct mvpp2 *priv, } } + if (!of_get_mac_address(to_of_node(fwnode), hw_mac_addr)) { + *mac_from = "nvmem cell"; + eth_hw_addr_set(dev, hw_mac_addr); + return; + } + *mac_from = "random"; eth_hw_addr_random(dev); }