From nobody Sun Feb 8 02:20:07 2026 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E71832253ED for ; Fri, 20 Dec 2024 19:17:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734722241; cv=none; b=HvcZfFwvW4sb06mDpikSGNHaM4pmRiuluvU2i87Q2VfAFsa7URWXNLtsMBZZG0OXOeQc0Vgyows356hpqjUvVosE+dYnTOvs9o7j5PqAhbt2FLacOtoQMeq0mHoyen9qzScUngu16xm36eDw6k8N7hstgVkkk98A+mBiJnns73A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734722241; c=relaxed/simple; bh=3owT/KMCvF5XwxfrBAfaiky6eGpIYrzcz95ija8sMWg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=G6GTGbz/VsstzJE4Rmrct7ABlLrk4NpS6T3aVlRg1IWSkg9kQuN0/i4ckAKGyQBDq/b9lKAYrULaaeLK8hsZqkQb0SflOuOoiREFpEpo/6NWEWdpTmKmhEEEiMOM8sC/eS3WqLgSIe8vGlO4ZA8InixySv4ef0zg0wNK7ker8lU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=h49gztQW; arc=none smtp.client-ip=209.85.208.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="h49gztQW" Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-5d3d479b1e6so2913522a12.2 for ; Fri, 20 Dec 2024 11:17:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734722236; x=1735327036; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=vBR/gsOu5StkcyNL8p43Oyx52bSqF/t8CsaHctvuxX4=; b=h49gztQWoAh9Ae5RpDe/nkxfQDL6oPqjeFZeN+RXRSt6QaoT2Yr01PYZPb6/auh6Qy e3uok0CXIVUUT4NJPk+ElAy1DKAOQgycNX9Pc4HeWTpNPPAGNJOHHtBoY7ui40AmZ1Mv 0HLHj8rXK4j4knGt6iGZEPjhgtFFu0EZ9DFBLCoquSYjZdqh6ZkUbwIn14PXajKPF4B8 0kTmX6zy56OJ/8V/ZVrbPq22BAT/ss6AAURC/J1gt273iYMhg9nYynEkgTpBRjq78Aa1 5EgsBAQUwtbIBHGzZ6NstFn5Xxh2pcALzMAxlmZxB6FncbjV54a60Ut8hd57K2o1g/mg Ciug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734722236; x=1735327036; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vBR/gsOu5StkcyNL8p43Oyx52bSqF/t8CsaHctvuxX4=; b=hEJV/S58zMrMHbtLE9DUEsj0LlqYgETszXCDQWuVVmHPMft99uAZqOub43Bl8jz/Vj dj4EBZs21OcxdzEOVeHh9wgGzpHbEio4k2DjT5OpMtGZIUxTNfCncHjS1lX2BczDkTK/ eNKXHd2yCB22USLl57i9yoOTu2gjOF9uy+uQ09ViNUPkXAwAsPOqO2tvp9IMCocxxJ4r mW96zS++gtDPzlBRx7FLFOtkJcP2tvpgNEwBogDTf0plFxTdKEaGv3qMvnSqO9T3PNwL RFrcmAAdV8WnS3JvQYOJdMHE8qYiuURNGqV0zjl7/K1a+6LM/l20GbBq5HznSYa8lrZO y5dQ== X-Forwarded-Encrypted: i=1; AJvYcCWKtLqUe9eZo7OcNQ3+BZXgDrbJY6b5qSlpCsEBs3HZwnwOdS7TbfAvKT79ppk2DRor3C7uRA9p79b9w68=@vger.kernel.org X-Gm-Message-State: AOJu0YwVYWjmzrQjr7TCDivbk+q5aYx6aopU6DlAZhluij/ySKrX3YtW LTxvnEppMflxHD/UBvn9IpuBzC9Am0kpGjvVR5OK4GK11/rvN69Nnm+7FAbHcq0= X-Gm-Gg: ASbGncvJoTq9RVobKJiIg0ozzBB9yRyFm4j383Csp/0LYHgSDJx/a5g0puG0u+OY6j8 kfOv69a9gQLZXJa5GuQXVlf3xNPVbrC5fwhuWtpNaPFv3LArr5TQxh9Qm20QPQWp18PJBSGreBT Y/kvdBz8N6/y3Pxd3Ne/n5JnOly0R1BhybXPOcpC91YJ3W+47TxOs3/9Lh66cSYNoMOayByejP+ SetHhw8QEodQ9eBio9vHH9ynbuTG+WjfK3F5UFk7uFPyY8WA6NVLplD57c4a3idH1I= X-Google-Smtp-Source: AGHT+IFmLyPE9OMUVuB/6IZRMr2eptvA+ua1OuRWCkVTNnTDUTn6N/1kmxMoQ8Owur8tJ0XN93MY3g== X-Received: by 2002:a05:6402:1d53:b0:5d0:bf5e:eb8 with SMTP id 4fb4d7f45d1cf-5d81de06611mr7849152a12.23.1734722236189; Fri, 20 Dec 2024 11:17:16 -0800 (PST) Received: from [192.168.1.140] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d80679f11dsm1988727a12.46.2024.12.20.11.17.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 11:17:15 -0800 (PST) From: Linus Walleij Date: Fri, 20 Dec 2024 20:17:06 +0100 Subject: [PATCH 1/2] dt-bindings: net: ethernet-controller: Add mac offset option Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241220-net-mac-nvmem-offset-v1-1-e9d1da2c1681@linaro.org> References: <20241220-net-mac-nvmem-offset-v1-0-e9d1da2c1681@linaro.org> In-Reply-To: <20241220-net-mac-nvmem-offset-v1-0-e9d1da2c1681@linaro.org> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Andrew Lunn , Heiner Kallweit , Russell King , Simon Horman Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.14.2 In practice (as found in the OpenWrt project) many devices with multiple ethernet interfaces just store a base MAC address in NVMEM and increase the lowermost byte with one for each interface, so as to occupy less NVMEM. Support this with a per-interface offset so we can encode this in a predictable way for each interface sharing the same NVMEM cell. Signed-off-by: Linus Walleij --- .../devicetree/bindings/net/ethernet-controller.yaml | 12 ++++++++= ++++ 1 file changed, 12 insertions(+) diff --git a/Documentation/devicetree/bindings/net/ethernet-controller.yaml= b/Documentation/devicetree/bindings/net/ethernet-controller.yaml index 45819b2358002bc75e876eddb4b2ca18017c04bd..608f89359ca844e5325e3cc81bd= 2677b0eccb08a 100644 --- a/Documentation/devicetree/bindings/net/ethernet-controller.yaml +++ b/Documentation/devicetree/bindings/net/ethernet-controller.yaml @@ -53,6 +53,18 @@ properties: nvmem-cell-names: const: mac-address =20 + nvmem-mac-minor-offset: + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 1 + maximum: 255 + description: + When a MAC address for a device with multiple ethernet interface + is stored in non-volatile memory, the address is often offsetted + for different interfaces by increasing the lowermost byte for each + interface subsequent to the first in order to save space in NVMEM. + This property can be used to add that offset when several + interfaces refer to the same NVMEM cell. + phy-connection-type: description: Specifies interface type between the Ethernet device and a physical --=20 2.47.1 From nobody Sun Feb 8 02:20:07 2026 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89C3222579D for ; Fri, 20 Dec 2024 19:17:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734722241; cv=none; b=q+IDmiRKT5RxWJcsZto8ih08htUAsruKv7Hi8RzLIee5fnodGLoLgIASlm0Y5/LumGAKmHiFrQYIwqwID8bZ9ZT8tuBxlqKvofbFLwTjqC/aY5saV7xzHIo7pIWMR9Ld+1tNw97slrOGaTd9drsSO7c7uDgHmFG8REqrZIotapE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734722241; c=relaxed/simple; bh=mGhlxfT6eF+jcZlW7jmmh2wdkJ3HDICoSvZsMZwFbd0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fsH5/tnXNWi/BaNQxKPMY1AE+o5VsVYEj2sQ8XBjc0+Fx6dOiFbj1oz4MtX8QKSn/jSrpeIalsYRO/0vv0yWKQdGfkfRBQKUyRl+EOvdHxUqJfy5xLmlVf7O2O9oZAe8b4nVI/kIz4rOtGFeEhhHjZmThhTMkLscBR2Eod6bQxg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=cKkSBBs8; arc=none smtp.client-ip=209.85.208.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="cKkSBBs8" Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-5d414b8af7bso4141540a12.0 for ; Fri, 20 Dec 2024 11:17:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734722238; x=1735327038; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Yb2OFBg5699Qjzh1WbbstXrxCP9eQxyz8l9GfCLKz0E=; b=cKkSBBs8fD6LoZVHsUE1MXMQyp8M6hjeJhlJiJ5Zm6/eYs7CLl4fK1LCkm0yZm6Fqd /s2fNQ4+caNBJlaQzS8TYel0yCm43CiV/qpcYgw/VwwIbtFG0Fa17iFlXPXICLlnrwSM xnah4zpGzWBE45YDn9p8Z+hr7EAmp4HyVTJHLthE/MM0a8DGonXnIO3eImnHot61FzOn N3d3j6gYXfGQO0/0FtnFARDgfHP7YZVEpfGPWsBBploN1dwk6b0oYaQ9MZXeQ3U1uPSj LFxGWNWGDs4A6oq2jSyq2GAEQUKTQyVqGnVGUTuIZchx181ERzkPwFeOb/HZArUYdiCA vn8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734722238; x=1735327038; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Yb2OFBg5699Qjzh1WbbstXrxCP9eQxyz8l9GfCLKz0E=; b=j0Vq92Fin3UBPxVU/6LZpUA3IXaww3sqopITa5OWLYkEDcfak7qc9MJjFoy4noHqfO 38vs8czKo9GU89u/Vf0vRwBxw8CNmYIq0eE3cP8X5Bb0ZsGY6PjVRiNUTafIZmTwwzQs revkU32J62bWb7SqiOYSSCWKbv8dOKSAXXoBDPROE9nMeFrSldjSXaylS0wApmDpkpQp 1BOgiUL1o8VnM+eXuBEcBTsKFhdBYSnfnYQKoCnPEN5Fp8Q1uqfECTBt+HCPm7oVnZhI rx3QxKVbUIMlsGVBaUWwl02uLgtGswJ9lQoYMJJoBrI7/zeD9iiTRVNcxPVQPGiMgNRG lkyg== X-Forwarded-Encrypted: i=1; AJvYcCXkZBwC+Eb+NdArGNaJkqzHWfp0tGCNYitnLY2gRI4IcSkvRi9HZFGUIL5d/Kq0uRP/tt+TATjAEwMkktk=@vger.kernel.org X-Gm-Message-State: AOJu0YzloG7XL6EsJiO7ZuQdoQEIAl46b+4OB0kQH1ejlgEMq+YawjGV 3ZZRp9JereEe7D/8Qt7lPy2lQflDkkTPoDMEJvc1/LwXfysYRppZyyeKDWvG4lo= X-Gm-Gg: ASbGnctGaa/s/ciDaYZe5exjV55zahSCMWsTxsDFAM2ocfALbGxyLxOs2YBZp3MebjQ sRaU4zX/sFqXFGHDLrOXjio7pnacdlepkszmCO7WwYmr6MpHHEt5ts+Lv58lquKu1SMWihPuPFq eX7lmNM0OnQg2SHabQWPTmZ9sXhPmi781fZoeDda7TE31giEWGAd84q7ind19eiCiIXFOMSWTJV rHtKZU1y1hB4GVmuasJ4uk9jhFcoNei8Lgq6+IT18+bDnWOUpsbtgIuhTVB8ccidpM= X-Google-Smtp-Source: AGHT+IFAISrFUYFuhFqTWUFjIqqCBrlHPHO2EfxocbLtuEGjlne/qNFOwZx94YXCbT5K77LTeZrxpA== X-Received: by 2002:a05:6402:4402:b0:5d2:60d9:a2a0 with SMTP id 4fb4d7f45d1cf-5d81de5d896mr3637217a12.33.1734722237695; Fri, 20 Dec 2024 11:17:17 -0800 (PST) Received: from [192.168.1.140] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d80679f11dsm1988727a12.46.2024.12.20.11.17.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2024 11:17:16 -0800 (PST) From: Linus Walleij Date: Fri, 20 Dec 2024 20:17:07 +0100 Subject: [PATCH 2/2] net: of: Support adding offset to nvmem MAC addresses Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241220-net-mac-nvmem-offset-v1-2-e9d1da2c1681@linaro.org> References: <20241220-net-mac-nvmem-offset-v1-0-e9d1da2c1681@linaro.org> In-Reply-To: <20241220-net-mac-nvmem-offset-v1-0-e9d1da2c1681@linaro.org> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Andrew Lunn , Heiner Kallweit , Russell King , Simon Horman Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.14.2 If a lower-byte MAC address offset is encoded into the device tree, make sure to add this to the returned address when looking up a MAC address from NVMEM. Signed-off-by: Linus Walleij --- net/core/of_net.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/net/core/of_net.c b/net/core/of_net.c index 93ea425b9248a23f4f95a336e9cdbf0053248e32..c98000ec13377ea4b541e182a66= be8b1010edc40 100644 --- a/net/core/of_net.c +++ b/net/core/of_net.c @@ -64,6 +64,7 @@ int of_get_mac_address_nvmem(struct device_node *np, u8 *= addr) struct nvmem_cell *cell; const void *mac; size_t len; + u32 offset; int ret; =20 /* Try lookup by device first, there might be a nvmem_cell_lookup @@ -72,7 +73,7 @@ int of_get_mac_address_nvmem(struct device_node *np, u8 *= addr) if (pdev) { ret =3D nvmem_get_mac_address(&pdev->dev, addr); put_device(&pdev->dev); - return ret; + goto add_offset_exit; } =20 cell =3D of_nvmem_cell_get(np, "mac-address"); @@ -92,8 +93,13 @@ int of_get_mac_address_nvmem(struct device_node *np, u8 = *addr) =20 memcpy(addr, mac, ETH_ALEN); kfree(mac); + ret =3D 0; =20 - return 0; +add_offset_exit: + if (!ret && !of_property_read_u32(np, "nvmem-mac-minor-offset", &offset)) + addr[ETH_ALEN - 1] +=3D offset; + + return ret; } EXPORT_SYMBOL(of_get_mac_address_nvmem); =20 --=20 2.47.1