Thread View: linux.kernel.netdev
3 messages
3 total messages
Started by Andrew Lunn
Wed, 25 Nov 2026 14:21
Re: [PATCH v4 3/5] nvmem: rockchip-otp: Derive MAC addresses from the CPU ID
Author: Andrew Lunn
Date: Wed, 25 Nov 2026 14:21
Date: Wed, 25 Nov 2026 14:21
19 lines
9623 bytes
9623 bytes
> > +static int rockchip_otp_cpuid_pp(void *priv, const char *id, int index,
> > + unsigned int offset, void *buf, size_t bytes)
> > +{
> > + char cpuid[ROCKCHIP_CPUID_LEN * 2];
> > + u8 digest[SHA256_DIGEST_SIZE];
> > + u8 *mac = buf;
> > +
> > + if (!id || strcmp(id, "mac-address"))
> > + return 0;
I don't know OTP drivers. But to me, a function called
rockchip_otp_cpuid_pp() which does not actually return the CPU ID is
architecturally wrong.
I would probably not mangle the CPU ID in the OTP driver, but in the
MAC driver. The MAC driver should ask for the CPU ID and then hash it.
Andrew
Re: [PATCH v4 3/5] nvmem: rockchip-otp: Derive MAC addresses from the CPU ID
Author: Andrew Lunn
Date: Wed, 25 Nov 2026 15:23
Date: Wed, 25 Nov 2026 15:23
50 lines
11377 bytes
11377 bytes
On Wed, Nov 25, 2026 at 06:41:42PM +0400, Alexey Charkov wrote:
> On Wed, Nov 25, 2026 at 6:21 PM Andrew Lunn <andrew@lunn.ch> wrote:
> >
> > > > +static int rockchip_otp_cpuid_pp(void *priv, const char *id, int index,
> > > > + unsigned int offset, void *buf, size_t bytes)
> > > > +{
> > > > + char cpuid[ROCKCHIP_CPUID_LEN * 2];
> > > > + u8 digest[SHA256_DIGEST_SIZE];
> > > > + u8 *mac = buf;
> > > > +
> > > > + if (!id || strcmp(id, "mac-address"))
> > > > + return 0;
> >
> > I don't know OTP drivers. But to me, a function called
> > rockchip_otp_cpuid_pp() which does not actually return the CPU ID is
> > architecturally wrong.
>
> There is precedent for this at least in IMX [1], [2]. To me the
> interpretation is "Rockchip CPU ID used as a MAC address base with
> offset X", which is exactly what the derivation does. IMO, this is
> less clunky than the alternatives (e.g., a custom NVMEM layout which I
> used in v1-v2; a "virtual" NVMEM driver referencing the real cell and
> returning the processed one, which Ryan proposed in v2 discussion, or
> caller-side processing).
>
> [1] https://elixir.bootlin.com/linux/v7.4-rc1/source/drivers/nvmem/imx-ocotp.c#L224-L238
I would say this one is different. The cell specifically contains the
MAC address. But its endianness is wrong. Nothing about CPU ID here.
> [2] https://elixir.bootlin.com/linux/v7.4-rc1/source/drivers/nvmem/imx-ocotp-ele.c#L115-L129
And this seems to be the same.
As i said, i don't like the concept that a function called
rockchip_otp_cpuid_pp() returns something which is not a CPU ID. The
two examples you give ask for a MAC address, and they get a MAC
address.
Does nvmem support aliases? Can you put two different names on the
same cell? If you access the cell via the name cpu-id, it calls a
function _cpu_id_, it gives you the CPU ID. If you access the cell via
the name mac-address, it calls a function called _mac_address_, and it
gives you a MAC address.
That way of_get_mac_address_nvmem() just works, so the MAC driver just
needs to call of_get_mac_address() or of_get_ethdev_address().
Andrew
Re: [PATCH v4 3/5] nvmem: rockchip-otp: Derive MAC addresses from the CPU ID
Author: Andrew Lunn
Date: Wed, 25 Nov 2026 16:41
Date: Wed, 25 Nov 2026 16:41
25 lines
10168 bytes
10168 bytes
> > That way of_get_mac_address_nvmem() just works, so the MAC driver just > > needs to call of_get_mac_address() or of_get_ethdev_address(). > > They still need to relax the size check as done by patch 2/5 in this > series, because the CPUID cell is 16 bytes long. Srinivas rejected a > prior version of this series that attempted to return cell contents of > different sizes depending on the use case. Currently any cell size != > ETH_ALEN gets rejected by the net core, not just < ETH_ALEN. Ah! I had not looked at the whole series. Having to change the core like this is an argument for doing it in the MAC driver. It asked for a MAC address. What it got back is not a MAC address if it does not have 6 octets. Please throw this all away and do it in the MAC driver. If there are multiple RealTek MAC drivers involved, you can put it into a little library and share it across the drivers. It is actually an interesting idea. Maybe it should be placed in of_net.c, so other drivers can use it. How generic is it having a CPU ID in the OTP? Are there other vendors doing it? Andrew
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads