Netdev List
 help / color / mirror / Atom feed
From: Benjamin Larsson <benjamin.larsson@genexis.eu>
To: Lorenzo Bianconi <lorenzo@kernel.org>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>
Cc: Christian Marangi <ansuelsmth@gmail.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org, netdev@vger.kernel.org,
	devicetree@vger.kernel.org,
	Madhur Agrawal <madhur.agrawal@airoha.com>
Subject: Re: [PATCH net-next v6 11/12] net: airoha: Support multiple LAN/WAN interfaces for hw MAC address configuration
Date: Tue, 12 May 2026 19:49:42 +0200	[thread overview]
Message-ID: <f4a11830-8a3f-4cc3-ab82-e6f02ca34ae8@genexis.eu> (raw)
In-Reply-To: <20260511-airoha-eth-multi-serdes-v6-11-c899462c4f75@kernel.org>

Hi.

On 11/05/2026 12:49, Lorenzo Bianconi wrote:
> The EN7581 and AN7583 SoCs provide registers to configure hardware LAN/WAN
> MAC addresses, used to determine whether received traffic is destined for
> this host or should be forwarded to another device.
> The SoC hardware design assumes all interfaces configured as LAN (or WAN)
> share a common upper MAC address, which is programmed into the
> REG_FE_{LAN,WAN}_MAC_H register. The lower bytes of 'local' addresses can
> be expressed as a range via the REG_FE_MAC_LMIN and REG_FE_MAC_LMAX
> registers.
> Previously, only a single interface was considered when programming these
> registers. Extend the logic to derive the correct minimum and maximum
> values for REG_FE_MAC_LMIN/REG_FE_MAC_LMAX when two or more interfaces are
> configured as LAN or WAN.
>
> Tested-by: Madhur Agrawal <madhur.agrawal@airoha.com>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
>   drivers/net/ethernet/airoha/airoha_eth.c | 75 +++++++++++++++++++++++++++-----
>   drivers/net/ethernet/airoha/airoha_eth.h |  2 +-
>   drivers/net/ethernet/airoha/airoha_ppe.c |  4 +-
>   3 files changed, 66 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/net/ethernet/airoha/airoha_eth.c b/drivers/net/ethernet/airoha/airoha_eth.c
> index 16c0ff9999da..533ffe20f833 100644
> --- a/drivers/net/ethernet/airoha/airoha_eth.c
> +++ b/drivers/net/ethernet/airoha/airoha_eth.c
> @@ -71,20 +71,67 @@ 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)
>   {
>   	struct airoha_eth *eth = dev->eth;
> -	u32 val, reg;
> +	u8 ref_addr[ETH_ALEN] = {};
> +	u32 reg, val, lmin, lmax;
> +	int i;
> +
> +	lmin = (addr[3] << 16) | (addr[4] << 8) | addr[5];
> +	lmax = lmin;
> +
> +	for (i = 0; i < ARRAY_SIZE(eth->ports); i++) {
> +		struct airoha_gdm_port *port = eth->ports[i];
> +		int j;
> +
> +		if (!port)
> +			continue;
> +
> +		for (j = 0; j < ARRAY_SIZE(port->devs); j++) {
> +			struct airoha_gdm_dev *iter_dev;
> +			struct net_device *netdev;
> +
> +			iter_dev = port->devs[j];
> +			if (!iter_dev || iter_dev == dev)
> +				continue;
> +
> +			if (airoha_is_lan_gdm_dev(iter_dev) !=
> +			    airoha_is_lan_gdm_dev(dev))
> +				continue;
> +
> +			netdev = iter_dev->dev;
> +			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)) {
> +		/* According to the HW design, hw mac address MS bits
> +		 * must be the same for each net_device with the same
> +		 * LAN/WAN configuration.
> +		 */
> +		return -EINVAL;
> +	}

Maybe this information should be relayed to the user somehow?

MvH

Benjamin Larsson


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

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-11 10:49 [PATCH net-next v6 00/12] net: airoha: Support multiple net_devices connected to the same GDM port Lorenzo Bianconi
2026-05-11 10:49 ` [PATCH net-next v6 01/12] dt-bindings: net: airoha: Add EN7581 ethernet-ports properties Lorenzo Bianconi
2026-05-11 10:49 ` [PATCH net-next v6 02/12] net: airoha: Reserve RX headroom to avoid skb reallocation Lorenzo Bianconi
2026-05-11 10:49 ` [PATCH net-next v6 03/12] net: airoha: Introduce airoha_gdm_dev struct Lorenzo Bianconi
2026-05-11 10:49 ` [PATCH net-next v6 04/12] net: airoha: Move airoha_qdma pointer in " Lorenzo Bianconi
2026-05-11 10:49 ` [PATCH net-next v6 05/12] net: airoha: Rely on airoha_gdm_dev pointer in airhoa_is_lan_gdm_port() Lorenzo Bianconi
2026-05-11 10:49 ` [PATCH net-next v6 06/12] net: airoha: Move qos_sq_bmap in airoha_gdm_dev struct Lorenzo Bianconi
2026-05-11 10:49 ` [PATCH net-next v6 07/12] net: airoha: Move {cpu,fwd}_tx_packets " Lorenzo Bianconi
2026-05-11 10:49 ` [PATCH net-next v6 08/12] net: airoha: Support multiple net_devices for a single FE GDM port Lorenzo Bianconi
2026-05-11 10:49 ` [PATCH net-next v6 09/12] net: airoha: Do not stop GDM port if it is shared Lorenzo Bianconi
2026-05-11 10:49 ` [PATCH net-next v6 10/12] net: airoha: Introduce WAN device flag Lorenzo Bianconi
2026-05-11 10:49 ` [PATCH net-next v6 11/12] net: airoha: Support multiple LAN/WAN interfaces for hw MAC address configuration Lorenzo Bianconi
2026-05-12 17:49   ` Benjamin Larsson [this message]
2026-05-11 10:49 ` [PATCH net-next v6 12/12] net: airoha: Better handle MIB for GDM with multiple port attached Lorenzo Bianconi

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=f4a11830-8a3f-4cc3-ab82-e6f02ca34ae8@genexis.eu \
    --to=benjamin.larsson@genexis.eu \
    --cc=andrew+netdev@lunn.ch \
    --cc=ansuelsmth@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=lorenzo@kernel.org \
    --cc=madhur.agrawal@airoha.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=robh@kernel.org \
    /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