Netdev List
 help / color / mirror / Atom feed
From: Lorenzo Bianconi <lorenzo@kernel.org>
To: sashiko-reviews@lists.linux.dev
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org,
	netdev@vger.kernel.org
Subject: Re: [PATCH net-next v8 10/10] net: airoha: Support multiple LAN/WAN interfaces for hw MAC address configuration
Date: Wed, 20 May 2026 14:49:37 +0200	[thread overview]
Message-ID: <ag2t4eVe4DcfU2yZ@lore-desk> (raw)
In-Reply-To: <20260520085934.54AD01F00894@smtp.kernel.org>

[-- Attachment #1: Type: text/plain, Size: 3601 bytes --]

> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> - [High] Driver probe fails on systems where MAC addresses are randomly generated.
> - [High] Configuration deadlock prevents users from changing the MAC address OUI.
> --
> 
> commit dbc4f298ffd475d67c32eeea98f201059b73194a
> Author: Lorenzo Bianconi <lorenzo@kernel.org>
> 
> net: airoha: Support multiple LAN/WAN interfaces for hw MAC address configuration
> 
> The EN7581 and AN7583 SoCs provide registers to configure hardware LAN/WAN
> MAC addresses. The hardware design assumes all interfaces configured as LAN
> (or WAN) share a common upper MAC address. This patch extends the logic to
> derive the correct minimum and maximum values when two or more interfaces
> are configured.
> 
> > diff --git a/drivers/net/ethernet/airoha/airoha_eth.c b/drivers/net/ethernet/airoha/airoha_eth.c
> > index 328f94fef2e28..9ae1ba4333097 100644
> > --- a/drivers/net/ethernet/airoha/airoha_eth.c
> > +++ b/drivers/net/ethernet/airoha/airoha_eth.c
> > @@ -71,20 +71,69 @@ static void airoha_qdma_irq_disable(struct airoha_irq_bank *irq_bank,
> >  	airoha_qdma_set_irqmask(irq_bank, index, mask, 0);
> >  }
> >  
> > -static void airoha_set_macaddr(struct airoha_gdm_dev *dev, const u8 *addr)
> > +static int airoha_set_macaddr(struct airoha_gdm_dev *dev, const u8 *addr)
> >  {
> 
> [ ... ]
> 
> > +			if (netdev->reg_state != NETREG_REGISTERED)
> > +				continue;
> > +
> > +			ether_addr_copy(ref_addr, netdev->dev_addr);
> > +			val = (netdev->dev_addr[3] << 16) |
> > +			      (netdev->dev_addr[4] << 8) | netdev->dev_addr[5];
> > +			if (val < lmin)
> > +				lmin = val;
> > +			if (val > lmax)
> > +				lmax = val;
> > +		}
> > +	}
> > +
> > +	if (!is_zero_ether_addr(ref_addr) && memcmp(ref_addr, addr, 3)) {
> 
> Does this strict OUI validation cause the driver probe to fail when MAC addresses
> are randomly generated?
> 
> If a MAC address is not provided in the device tree, the driver generates a random
> one via eth_hw_addr_random(). For multi-port configurations, each port receives an
> independently generated random MAC address.
> 
> Since the upper 3 bytes of these random addresses will almost certainly differ,
> when register_netdev() is called for the second port, its ndo_init callback
> (airoha_dev_init) will invoke airoha_set_macaddr() and hit this check. Returning
> -EINVAL will fail register_netdev() and abort the entire driver probe, leaving
> the system without networking.
> 
> Does this also prevent users from changing the MAC address OUI?
> 
> When an administrator attempts to change the MAC address via standard userspace
> tools, only one interface can be modified at a time. The driver will compare the
> new MAC against the existing MAC of the other port.
> 
> If the MSBs differ, the change is rejected. This makes it impossible to atomically
> change the OUI of both interfaces simultaneously, locking the MAC address OUI
> to its initial probe-time value.

As pointed out before, this is a hw design requirement when multiple
net_devices are configured as LAN.

Regards,
Lorenzo

> 
> > +		/* According to the HW design, hw mac address MS bits
> > +		 * must be the same for each net_device with the same
> > +		 * LAN/WAN configuration.
> > +		 */
> > +		netdev_err(dev->dev, "wrong mac addr for shared GDM port\n");
> > +		return -EINVAL;
> > +	}
> 
> -- 
> Sashiko AI review · https://sashiko.dev/#/patchset/20260519-airoha-eth-multi-serdes-v8-0-6bd70e329df6@kernel.org?part=10

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

      parent reply	other threads:[~2026-05-20 12:49 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-19  8:57 [PATCH net-next v8 00/10] net: airoha: Support multiple net_devices connected to the same GDM port Lorenzo Bianconi
2026-05-19  8:57 ` [PATCH net-next v8 01/10] dt-bindings: net: airoha: Add GDM port ethernet child node Lorenzo Bianconi
2026-05-19  8:57 ` [PATCH net-next v8 02/10] net: airoha: Introduce airoha_gdm_dev struct Lorenzo Bianconi
     [not found]   ` <20260520085932.9473C1F000E9@smtp.kernel.org>
2026-05-20 12:25     ` Lorenzo Bianconi
2026-05-19  8:57 ` [PATCH net-next v8 03/10] net: airoha: Move airoha_qdma pointer in " Lorenzo Bianconi
2026-05-19  8:57 ` [PATCH net-next v8 04/10] net: airoha: Rely on airoha_gdm_dev pointer in airoha_is_lan_gdm_port() Lorenzo Bianconi
2026-05-19  8:57 ` [PATCH net-next v8 05/10] net: airoha: Move qos_sq_bmap in airoha_gdm_dev struct Lorenzo Bianconi
     [not found]   ` <20260520085926.97A481F000E9@smtp.kernel.org>
2026-05-20 12:24     ` Lorenzo Bianconi
2026-05-19  8:57 ` [PATCH net-next v8 06/10] net: airoha: Move {cpu,fwd}_tx_packets " Lorenzo Bianconi
2026-05-19  8:57 ` [PATCH net-next v8 07/10] net: airoha: Support multiple net_devices for a single FE GDM port Lorenzo Bianconi
     [not found]   ` <20260520085933.35D171F00897@smtp.kernel.org>
2026-05-20 12:28     ` Lorenzo Bianconi
2026-05-20 12:33     ` Lorenzo Bianconi
2026-05-19  8:57 ` [PATCH net-next v8 08/10] net: airoha: Do not stop GDM port if it is shared Lorenzo Bianconi
2026-05-19  8:57 ` [PATCH net-next v8 09/10] net: airoha: Introduce WAN device flag Lorenzo Bianconi
     [not found]   ` <20260520085933.C009F1F00893@smtp.kernel.org>
2026-05-20 12:46     ` Lorenzo Bianconi
2026-05-19  8:57 ` [PATCH net-next v8 10/10] net: airoha: Support multiple LAN/WAN interfaces for hw MAC address configuration Lorenzo Bianconi
     [not found]   ` <20260520085934.54AD01F00894@smtp.kernel.org>
2026-05-20 12:49     ` Lorenzo Bianconi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ag2t4eVe4DcfU2yZ@lore-desk \
    --to=lorenzo@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox