From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.151 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796204238; b=qGDWa3Y3Ym2Gq3CPSw6qN31Bs/Fa1TU9qVVkTD8EOha5E5ihgseP5602lSN4OJMT//bM BGf8T/X3Hm/seohV7Yp9vbKUNO4oOfBGLRoGXXnWhQIQU0E/yYsjRGHSWv/es0T8BP0gP Zxwxzij2RKGfdutegk8NZ5rRA9uTWGHgx5TFVjgl6cbal3+7ufHJSqlK5ldCjHSTqPX3j Ql21Nni99tSGyBMusKWEVdGrqCExUT2NOx5QumqiLJkRTEjf6BuCM0JpyG6MekE7Cw+wP KvNz5kRc2DSyjL40egdcMvABvFeckKbVz6VOmpPfquf6C6m3ssZ2xdnJ8/1K8Lx1yKg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796204238; 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=O1oQ9z0ve4lOK44OF6qE0saBAxoCzMfRpVZ68wE0CxQ=; b=C48CNADk/0xU3YBWV1aXfqV/Y6DtLv4dJIPR8zZHvuRhiEHlDGjkgMw78FNrZXmiiTrn xpqF135drGEtrXZdnpbsG950MFY2lH9HI9p141GfQ1dViCP0XT9XqH23w8snlKYRGIUG/ /8WxLS8Fl2Mtj3HeoIRtH5xQt88LK1ckwnJYZtv8KamYPd5yZiMNTyXY2jpNU7XBlXaES ZXLs+IO8CWB7FlRVz5uVnsVOA4zEEZOonf1MWoIBRnArwtQ+AOVFrDRK6Ugni5EractJB NrXcSuVbzgTONeXMf1kExxyYav4jBOh411A9WYmz0/LY3zH/E/J64RSp08oe5hz0Lng== 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=oHVceB+w; arc=none smtp.remote-ip=91.218.175.151 Received: from mta0.migadu.com (out-151.mta0.migadu.com [91.218.175.151]) (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 8D407606A323 for ; Wed, 2 Dec 2026 09:37:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8D407606A323 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev 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=oHVceB+w X-Envelope-To: devicetree@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=s7d0OR3QyKR5Hc4LhyYZreQyDOjiEzQZrK8GQX5cWMM=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796204235; v=1; x=1796809035; b=oHVceB+wxOTHUfv+Ie8hDzQ9pHgWuvUtd1+gRZ9qpm5UlioMXoVKCabxD4OM6fnaI3qxJVZH 9b3ehzjHq5Al2dixPWJXSAYIV5cK4p/HYGqlKXhCCmynVblOsxPWYBc9r5ltYDWvKx6zOQmzCKZ 0lUTTs7o40qyfVlCi/imXGkQ= X-Envelope-To: devicetree@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id dfed160ce2106957; Wed, 02 Dec 2026 09:37:15 +0000 X-Mizu-Trace-ID: dfed160ce2106957 X-Migadu-Flow: FLOW_OUT Message-ID: Date: Wed, 2 Dec 2026 10:37:13 +0100 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next v6 13/15] net: dsa: rzn1-a5psw: Get register layout from OF data To: Prabhakar , Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heiner Kallweit , Russell King , Willem de Bruijn , Simon Horman , Philipp Zabel , Geert Uytterhoeven , Magnus Damm Cc: linux-renesas-soc@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, Prabhakar , Biju Das , Fabrizio Castro , Lad Prabhakar References: <20261202093357.15693-1-prabhakar.mahadev-lad.rj@bp.renesas.com> <20261202093357.15693-14-prabhakar.mahadev-lad.rj@bp.renesas.com> Content-Language: en-US From: Clement Leger In-Reply-To: <20261202093357.15693-14-prabhakar.mahadev-lad.rj@bp.renesas.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 12/2/26 10:33, Prabhakar wrote: > From: Lad Prabhakar > > RZ/T2H and RZ/N2H differ from RZ/N1 in the RX pattern matcher register > offsets, VLAN_RES field layout and lookup table size. Move these > properties into per-SoC OF match data and use them when accessing the > pattern matcher, VLAN entries and lookup table. > > Keep the existing RZ/N1 values in its match data. > > Signed-off-by: Lad Prabhakar > --- > v6: > - Squashed patches #18, #19 and #20 from v5 to limit the number > of patches > - Updated the commit message > - Dropped reviewed-by tag as patches were squashed and patch #20 wasnt > reviewed > v5: https://lore.kernel.org/all/20261120002549.1908299-16-prabhakar.mahadev-lad.rj@bp.renesas.com/ > https://lore.kernel.org/all/20261120002549.1908299-20-prabhakar.mahadev-lad.rj@bp.renesas.com/ > https://lore.kernel.org/all/20261120002549.1908299-21-prabhakar.mahadev-lad.rj@bp.renesas.com/ > - New patch > --- > drivers/net/dsa/rzn1_a5psw.c | 29 ++++++++++++++++++++--------- > drivers/net/dsa/rzn1_a5psw.h | 18 ++++++++++++------ > 2 files changed, 32 insertions(+), 15 deletions(-) > > diff --git a/drivers/net/dsa/rzn1_a5psw.c b/drivers/net/dsa/rzn1_a5psw.c > index 05753538c5ed..03d7f928e3e6 100644 > --- a/drivers/net/dsa/rzn1_a5psw.c > +++ b/drivers/net/dsa/rzn1_a5psw.c > @@ -112,7 +112,9 @@ static void a5psw_port_pattern_set(struct a5psw *a5psw, int port, int pattern, > if (enable) > rx_match |= A5PSW_RXMATCH_CONFIG_PATTERN(pattern); > > - a5psw_reg_rmw(a5psw, A5PSW_RXMATCH_CONFIG(port), > + a5psw_reg_rmw(a5psw, > + A5PSW_RXMATCH_CONFIG(a5psw->of_data->rxmatch_config_base, > + port), > A5PSW_RXMATCH_CONFIG_PATTERN(pattern), rx_match); > } > > @@ -315,18 +317,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); > > @@ -515,7 +518,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; > } > @@ -636,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, ®); > @@ -689,7 +692,7 @@ static int a5psw_find_vlan_entry(struct a5psw *a5psw, u16 vid) > /* Find vlan for this port */ > for (i = 0; i < A5PSW_VLAN_COUNT; i++) { > vlan_res = a5psw_reg_readl(a5psw, A5PSW_VLAN_RES(i)); > - if (FIELD_GET(A5PSW_VLAN_RES_VLANID, vlan_res) == vid) > + if (field_get(a5psw->of_data->vlan_res_vlanid, vlan_res) == vid) > return i; > } > > @@ -704,8 +707,9 @@ static int a5psw_new_vlan_res_entry(struct a5psw *a5psw, u16 newvid) > /* Find a free VLAN entry */ > for (i = 0; i < A5PSW_VLAN_COUNT; i++) { > vlan_res = a5psw_reg_readl(a5psw, A5PSW_VLAN_RES(i)); > - if (!(FIELD_GET(A5PSW_VLAN_RES_PORTMASK, vlan_res))) { > - vlan_res = FIELD_PREP(A5PSW_VLAN_RES_VLANID, newvid); > + if (!field_get(a5psw->of_data->vlan_res_portmask, vlan_res)) { > + vlan_res = field_prep(a5psw->of_data->vlan_res_vlanid, > + newvid); > a5psw_reg_writel(a5psw, A5PSW_VLAN_RES(i), vlan_res); > return i; > } > @@ -953,7 +957,9 @@ static int a5psw_setup(struct dsa_switch *ds) > a5psw_reg_writel(a5psw, A5PSW_MGMT_CFG, reg); > > /* Set pattern 0 to forward all frame to mgmt port */ > - a5psw_reg_writel(a5psw, A5PSW_PATTERN_CTRL(A5PSW_PATTERN_MGMTFWD), > + a5psw_reg_writel(a5psw, > + A5PSW_PATTERN_CTRL(a5psw->of_data->pattern_ctrl_base, > + A5PSW_PATTERN_MGMTFWD), > A5PSW_PATTERN_CTRL_MGMTFWD); > > /* Enable port tagging */ > @@ -1346,6 +1352,11 @@ static const struct a5psw_of_data rzn1_of_data = { > .npcs = 4, > .cpu_port = 4, > .tag_proto = DSA_TAG_PROTO_RZN1_A5PSW, > + .rxmatch_config_base = 0x3e80, > + .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 942931cbc402..fd523fe7bf47 100644 > --- a/drivers/net/dsa/rzn1_a5psw.h > +++ b/drivers/net/dsa/rzn1_a5psw.h > @@ -71,13 +71,11 @@ > #define A5PSW_VLAN_RES_WR_PORTMASK BIT(30) > #define A5PSW_VLAN_RES_WR_TAGMASK BIT(29) > #define A5PSW_VLAN_RES_RD_TAGMASK BIT(28) > -#define A5PSW_VLAN_RES_VLANID GENMASK(16, 5) > -#define A5PSW_VLAN_RES_PORTMASK GENMASK(4, 0) > > -#define A5PSW_RXMATCH_CONFIG(port) (0x3e80 + 4 * (port)) > +#define A5PSW_RXMATCH_CONFIG(base, port) ((base) + 4 * (port)) > #define A5PSW_RXMATCH_CONFIG_PATTERN(p) BIT(p) > > -#define A5PSW_PATTERN_CTRL(p) (0x3eb0 + 4 * (p)) > +#define A5PSW_PATTERN_CTRL(base, p) ((base) + 4 * (p)) > #define A5PSW_PATTERN_CTRL_MGMTFWD BIT(1) > > #define A5PSW_LK_CTRL 0x400 > @@ -95,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 > @@ -212,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]; > @@ -239,6 +235,11 @@ union lk_data { > * @tag_proto: DSA tag protocol used by the switch > * @management_port_fixed_frame_len: Fixed frame length for the management > * port to account for the HW issue. > + * @rxmatch_config_base: Offset of the RXMATCH_CONFIG register of port 0 > + * @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; > @@ -246,6 +247,11 @@ struct a5psw_of_data { > unsigned int cpu_port; > enum dsa_tag_protocol tag_proto; > unsigned int management_port_fixed_frame_len; > + u16 rxmatch_config_base; > + u16 pattern_ctrl_base; > + u32 vlan_res_vlanid; > + u32 vlan_res_portmask; > + unsigned int lk_table_entries; > }; > > /** LGTM, Reviewed-by: Clément Léger Thanks, Clément