๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #19726

Re: [PATCH net-next v5 20/24] net: dsa: rzn1-a5psw: Get lookup table size from OF data

#19726
From: Clement Leger
Date: Fri, 20 Nov 2026 09:44
122 lines
12932 bytes

On 11/20/26 01:25, Prabhakar wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> 
> The RZ/N1 A5PSW has 8192 lookup table entries, whereas the RZ/T2H
> and RZ/N2H ETHSW have only 4096 entries.
> 
> Add the lookup table size to struct a5psw_of_data, derive the address
> mask from it and use it in the FDB and ageing code.
> 
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> ---
> v4->v5:
> - New patch
> ---
>   drivers/net/dsa/rzn1_a5psw.c | 10 ++++++----
>   drivers/net/dsa/rzn1_a5psw.h |  4 ++--
>   2 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/dsa/rzn1_a5psw.c b/drivers/net/dsa/rzn1_a5psw.c
> index 7e9bc252d92a..c0c1f45852da 100644
> --- a/drivers/net/dsa/rzn1_a5psw.c
> +++ b/drivers/net/dsa/rzn1_a5psw.c
> @@ -311,18 +311,19 @@ static void a5psw_phylink_mac_link_up(struct phylink_config *config,
>   static int a5psw_set_ageing_time(struct dsa_switch *ds, unsigned int msecs)
>   {
>   	struct a5psw *a5psw = ds->priv;
> +	unsigned int entries = a5psw->of_data->lk_table_entries;
>   	unsigned long rate;
>   	u64 max, tmp;
>   	u32 agetime;
>   
>   	rate = clk_get_rate(a5psw->clk);
> -	max = div64_ul(((u64)A5PSW_LK_AGETIME_MASK * A5PSW_TABLE_ENTRIES * 1024),
> +	max = div64_ul(((u64)A5PSW_LK_AGETIME_MASK * entries * 1024),
>   		       rate) * 1000;
>   	if (msecs > max)
>   		return -EINVAL;
>   
>   	tmp = div_u64(rate, MSEC_PER_SEC);
> -	agetime = div_u64(msecs * tmp, 1024 * A5PSW_TABLE_ENTRIES);
> +	agetime = div_u64(msecs * tmp, 1024 * entries);
>   
>   	a5psw_reg_writel(a5psw, A5PSW_LK_AGETIME, agetime);
>   
> @@ -511,7 +512,7 @@ static int a5psw_lk_execute_lookup(struct a5psw *a5psw, union lk_data *lk_data,
>   	if (ret)
>   		return ret;
>   
> -	*entry = ctrl & A5PSW_LK_ADDR_CTRL_ADDRESS;
> +	*entry = ctrl & (a5psw->of_data->lk_table_entries - 1);
>   
>   	return 0;
>   }
> @@ -638,7 +639,7 @@ static int a5psw_port_fdb_dump(struct dsa_switch *ds, int port,
>   
>   	mutex_lock(&a5psw->lk_lock);
>   
> -	for (i = 0; i < A5PSW_TABLE_ENTRIES; i++) {
> +	for (i = 0; i < a5psw->of_data->lk_table_entries; i++) {
>   		reg = A5PSW_LK_ADDR_CTRL_READ | A5PSW_LK_ADDR_CTRL_WAIT | i;
>   
>   		ret = a5psw_lk_execute_ctrl(a5psw, &reg);
> @@ -1357,6 +1358,7 @@ static const struct a5psw_of_data rzn1_of_data = {
>   	.pattern_ctrl_base = 0x3eb0,
>   	.vlan_res_vlanid = GENMASK(16, 5),
>   	.vlan_res_portmask = GENMASK(4, 0),
> +	.lk_table_entries = 8192,
>   };
>   
>   static const struct of_device_id a5psw_of_mtable[] = {
> diff --git a/drivers/net/dsa/rzn1_a5psw.h b/drivers/net/dsa/rzn1_a5psw.h
> index 29d205e2331d..fd523fe7bf47 100644
> --- a/drivers/net/dsa/rzn1_a5psw.h
> +++ b/drivers/net/dsa/rzn1_a5psw.h
> @@ -93,7 +93,6 @@
>   #define A5PSW_LK_ADDR_CTRL_WAIT		BIT(27)
>   #define A5PSW_LK_ADDR_CTRL_READ		BIT(26)
>   #define A5PSW_LK_ADDR_CTRL_WRITE	BIT(25)
> -#define A5PSW_LK_ADDR_CTRL_ADDRESS	GENMASK(12, 0)
>   
>   #define A5PSW_LK_DATA_LO		0x40C
>   #define A5PSW_LK_DATA_HI		0x410
> @@ -210,7 +209,6 @@
>   
>   #define A5PSW_LK_BUSY_USEC_POLL		10
>   #define A5PSW_CTRL_TIMEOUT		1000
> -#define A5PSW_TABLE_ENTRIES		8192
>   
>   struct fdb_entry {
>   	u8 mac[ETH_ALEN];
> @@ -241,6 +239,7 @@ union lk_data {
>    * @pattern_ctrl_base: Offset of the PATTERN_CTRL register of pattern 0
>    * @vlan_res_vlanid: VLANID field mask of the VLAN_RES registers
>    * @vlan_res_portmask: PORTMASK field mask of the VLAN_RES registers
> + * @lk_table_entries: Number of entries in the lookup table (power of 2)
>    */
>   struct a5psw_of_data {
>   	unsigned int nports;
> @@ -252,6 +251,7 @@ struct a5psw_of_data {
>   	u16 pattern_ctrl_base;
>   	u32 vlan_res_vlanid;
>   	u32 vlan_res_portmask;
> +	unsigned int lk_table_entries;
>   };
>   
>   /**

Hi Prabhakar,

It would probably be better to fold all these commits that adds data 
into bits of data in oa5psw_of_data into two commits: a first one that 
prepares support for RZ/N2 and then a second one that add RZ/N2 support 
itself. I'm not the net maintainer but your series is already quite 
large just for this change so folding the commits make sense rather than 
commitmaxxing.

Thanks,

Clรฉment
Technical Details
Message-ID: <99974c5f-c1c0-427c-ab10-a6559789f258@linux.dev>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367826-linux-kernel-netdev=dewy.ru
References: <20261120002549.1908299-1-prabhakar.mahadev-lad.rj@bp.renesas.com> <20261120002549.1908299-21-prabhakar.mahadev-lad.rj@bp.renesas.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367826-linux-kernel-netdev=dewy.ru
From: clement.leger@linux.dev (Clement Leger)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v5 20/24] net: dsa: rzn1-a5psw: Get lookup table
 size from OF data
Date: Fri, 20 Nov 2026 10:44:15 +0100
Organization: Usenet Network
Message-ID: <99974c5f-c1c0-427c-ab10-a6559789f258@linux.dev>
References: <20261120002549.1908299-1-prabhakar.mahadev-lad.rj@bp.renesas.com>
 <20261120002549.1908299-21-prabhakar.mahadev-lad.rj@bp.renesas.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3123243"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:vqefyS0a73XLhNbuNKV+OwL8ttU= sha256:lqbXm5sI/dGzIk+/sEjhkzTmV3GUwTd7ZzgsQJrPZlU=
	sha1:3pxGgXsQwsEo5TDkdsyh0NAuqU8= sha256:gAFbXt6Bt5XV95v4AV6PWU354FVgrb9T1+5BTCvzNmo=
Content-Language: en-US
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 4BD23115932; Fri, 20 Nov 2026 12:44:40 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=linux.dev
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 7IIMCTPZHC6c;
	Fri, 20 Nov 2026 12:44:36 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-367826-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 2FAA71158B3; Fri, 20 Nov 2026 12:44:27 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id A828DE0FF1; Fri, 20 Nov 2026 09:44:23 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795167861;
	b=G3nya3Nq7tBUQfv2HdcCCDrx97NimqRTPtIzQElyskkpjdc44tn+EUGx2Rs7tS7dgsSe
	 AZrTOkSYhW+JaI8GOXkP5oK6DD3WSDSgclhA0XVzIffgqpUWS8kfSkP4CF3QJ7/mS9Uqe
	 RxmAsek6/k0Bas7BgWXHTPuxUuqcSqvG4s2IpTI7D8nr3DIl2qevC+ErnIHIEf+gbIieA
	 RHinp3b+EUHglkzO8HUzSEr2RsKg903ogkqfKXKVYbolP9sPiG1UjSMJCRSorombr5qjn
	 7n01OJI6E7xnlLSXlqwhFCHXc3nj4SZGM66hN6ckjIHj6VeW9TY1I0BJKjG7DYpQfMg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795167861;
	h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature:
	 X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:User-Agent:
	 Subject:To:Cc:References:Content-Language:From:In-Reply-To:
	 Content-Type:Content-Transfer-Encoding;
	bh=oFjhW+7eKqQT97kIliJ3yMumyK6wp8D8hexPVbCu+yo=;
	b=5pzgL120FJWzKL3U9gbOVQqnLUGBwbWxxlNRCL1NLDmsvFDYaXJl2HqbqDzHWULMW+dH
	 xvBjMs7IJ8WLPlqKV7V5giNX5fALAx3sTXaWB7SPu3GkZLcJxImTN6CWO7rPXrHqKr4ly
	 oez2ULX9bIXsqyBLNAWjhxvSu82Df+CV5L97UobwFPSIMMJmIvRfdNdKXbensnkAIo+sP
	 1ERnXinTEQRLSuzNMzyvpnaBbLxrYTPLx7RTA+WA06iNmdDS7QXe+et7wgAgrr0euK1zS
	 sxFfaY9pNbGgRTgIrB554Ofovgoq16Jlsq/2nYYvxDpGgf/9m6MnYjtvcFgDP9c0lLQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=DjXhq2vT;
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id CB512606A33E;
	Fri, 20 Nov 2026 09:44:21 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=DjXhq2vT
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.175
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795167861;
	b=P6Scz6/ScZgj6ffUq0dUmJAiMqAV4j8HZoTGAVWMOjEEuM2m+HwDOH8iR/NOk0g95NjK
	 CK6nqqAFxWnGoWz7mMq6GKJwe+qbCJdC6ce+3jYLTboTiNKjoqhGkKpZWGH6UymX/tUBb
	 tFXMaUkzVfWs408LkGFFYBY2Nzz7lwq9kQVl6ANtF3eozgr1zjblFalgFwDs7wasjR0jF
	 eS0X9S82GUafGG4QKhP0Dlcl2O/KBlKrSFsf0ZoIDz+LrmbKPBRzLSVqHCyATcUMixjqZ
	 na1WZuNCY9oT71GwFfKVl7jlCWZ2BvoB49C+s/uL21UOlbAeLNSKlEYLLX/lTbXGmbQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795167861;
	h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received:
	 X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent:
	 Subject:To:Cc:References:Content-Language:From:In-Reply-To:
	 Content-Type:Content-Transfer-Encoding;
	bh=oFjhW+7eKqQT97kIliJ3yMumyK6wp8D8hexPVbCu+yo=;
	b=2mndVAkVt+gCa6p9RX3HbMCfgI3y2hoUjGR0tB4YCj5CrX/muoqbJmkP8MVcjLVFaSjm
	 ni9S4c0mwRFpesbg1citf+n8DFmWwQ8cMyh5lTPPZhe2V8NmbZmjo03Nc0mcR6n3AoIbn
	 lvfa/ZsAa1JxtsXMziaxI6ZXZWYYKegTRXQD7FBOfUBPJ0wdf8Joi0CsumHnsu8cqiGV/
	 iVhAQEk34njkOnZHmZwyxYMVJKmhPeGlI+JqdBpmx7JSkUWSMNv1tpnmE8ISlyM4+eorA
	 v2kNzUhda6RCWxk5vbBwj/5nBdUw+3EjlNiknT7+qjAD9CXQb9ULImkTTKYuD4TWlYQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=DjXhq2vT;
	arc=none smtp.remote-ip=91.218.175.175
X-Received: from mta0.migadu.com (out-175.mta0.migadu.com [91.218.175.175])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8296C606A320
	for <netdev@vger.kernel.org>; Fri, 20 Nov 2026 09:44:19 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8296C606A320
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev
X-Envelope-To: netdev@vger.kernel.org
X-DKIM-Signature: a=rsa-sha256; bh=oQYnZu7+wRteiPN1ghqb+fRHNCk2pIXgXlUOMBMX+4A=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1795167857; v=1; x=1795772657;
 b=DjXhq2vTkD4/KuyM57OwBvaPgvVetN0WTti8yr/3rahHAnmo1+kOdcniJENRHezJ2Qj1l7e6
 eBcNkYAKfLStx7asOt0YV4NlrmHy636KBcOVEEqycCj/KqH5SA88Afr2o2CqujmMec2F0rppkQC
 jM7j+5oSZD8ONhRqfx+trteQ=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by smtp.migadu.com with ESMTPS id 7ed50c03f98480e6;
	Fri, 20 Nov 2026 09:44:17 +0000
X-Mizu-Trace-ID: 7ed50c03f98480e6
X-Migadu-Flow: FLOW_OUT
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-User-Agent: Mozilla Thunderbird
X-Cc: Florian Fainelli <f.fainelli@gmail.com>,
 Ralph Siemsen <ralph.siemsen@linaro.org>, linux-renesas-soc@vger.kernel.org,
 netdev@vger.kernel.org, devicetree@vger.kernel.org,
 Prabhakar <prabhakar.csengg+renesas@gmail.com>,
 Biju Das <biju.das.jz@bp.renesas.com>,
 Fabrizio Castro <fabrizio.castro.jz@renesas.com>,
 Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
X-In-Reply-To: <20261120002549.1908299-21-prabhakar.mahadev-lad.rj@bp.renesas.com>