From: Markus Stockhausen Date: Tue, 17 Feb 2026 17:52:49 +0000 (+0100) Subject: realtek: dsa: move n_counters into config structure X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=42a311bac9dd48c01b72173a0387177a2f05a446;p=thirdparty%2Fopenwrt.git realtek: dsa: move n_counters into config structure Place it where it belongs. Signed-off-by: Markus Stockhausen Link: https://github.com/openwrt/openwrt/pull/22068 Signed-off-by: Hauke Mehrtens --- diff --git a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c index 7b03831a82a..dd1efcb2b68 100644 --- a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c +++ b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c @@ -473,7 +473,7 @@ int rtl83xx_lag_del(struct dsa_switch *ds, int group, int port) // mutex_lock(&priv->reg_mutex); // idx = find_first_zero_bit(priv->octet_cntr_use_bm, MAX_COUNTERS); -// if (idx >= priv->n_counters) { +// if (idx >= priv->r->n_counters) { // mutex_unlock(&priv->reg_mutex); // return -1; // } @@ -499,9 +499,9 @@ int rtl83xx_packet_cntr_alloc(struct rtl838x_switch_priv *priv) * a 0-bit means the counter is already allocated (for octets) */ idx = find_first_bit(priv->packet_cntr_use_bm, MAX_COUNTERS * 2); - if (idx >= priv->n_counters * 2) { + if (idx >= priv->r->n_counters * 2) { j = find_first_zero_bit(priv->octet_cntr_use_bm, MAX_COUNTERS); - if (j >= priv->n_counters) { + if (j >= priv->r->n_counters) { mutex_unlock(&priv->reg_mutex); return -1; } @@ -1418,7 +1418,6 @@ static int rtl83xx_sw_probe(struct platform_device *pdev) priv->l2_bucket_size = 4; priv->n_mst = 64; priv->n_pie_blocks = 12; - priv->n_counters = 128; break; case RTL8390_FAMILY_ID: priv->ds->ops = &rtldsa_83xx_switch_ops; @@ -1432,7 +1431,6 @@ static int rtl83xx_sw_probe(struct platform_device *pdev) priv->l2_bucket_size = 4; priv->n_mst = 256; priv->n_pie_blocks = 18; - priv->n_counters = 1024; break; case RTL9300_FAMILY_ID: priv->ds->ops = &rtldsa_93xx_switch_ops; @@ -1447,7 +1445,6 @@ static int rtl83xx_sw_probe(struct platform_device *pdev) priv->l2_bucket_size = 8; priv->n_mst = 64; priv->n_pie_blocks = 16; - priv->n_counters = 2048; break; case RTL9310_FAMILY_ID: priv->ds->ops = &rtldsa_93xx_switch_ops; @@ -1462,7 +1459,6 @@ static int rtl83xx_sw_probe(struct platform_device *pdev) priv->l2_bucket_size = 8; priv->n_mst = 128; priv->n_pie_blocks = 16; - priv->n_counters = 2048; break; } diff --git a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.c b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.c index 3a594db0587..5bc564659c4 100644 --- a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.c +++ b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.c @@ -1700,6 +1700,7 @@ const struct rtldsa_config rtldsa_838x_cfg = { .isr_port_link_sts_chg = RTL838X_ISR_PORT_LINK_STS_CHG, .imr_port_link_sts_chg = RTL838X_IMR_PORT_LINK_STS_CHG, .imr_glb = RTL838X_IMR_GLB, + .n_counters = 128, .port_ignore = 0x1f, .vlan_tables_read = rtl838x_vlan_tables_read, .vlan_set_tagged = rtl838x_vlan_set_tagged, diff --git a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.h b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.h index 4435d5758d2..12abe423f23 100644 --- a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.h +++ b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.h @@ -1273,6 +1273,7 @@ struct rtldsa_config { int isr_port_link_sts_chg; int imr_port_link_sts_chg; int imr_glb; + int n_counters; u8 port_ignore; void (*vlan_tables_read)(u32 vlan, struct rtl838x_vlan_info *info); void (*vlan_set_tagged)(u32 vlan, struct rtl838x_vlan_info *info); @@ -1391,7 +1392,6 @@ struct rtl838x_switch_priv { int n_pie_blocks; struct rhashtable tc_ht; unsigned long pie_use_bm[MAX_PIE_ENTRIES >> 5]; - int n_counters; unsigned long octet_cntr_use_bm[MAX_COUNTERS >> 5]; unsigned long packet_cntr_use_bm[MAX_COUNTERS >> 4]; struct rhltable routes; diff --git a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl839x.c b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl839x.c index a78c981c215..46bc3212d09 100644 --- a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl839x.c +++ b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl839x.c @@ -1640,6 +1640,7 @@ const struct rtldsa_config rtldsa_839x_cfg = { .isr_port_link_sts_chg = RTL839X_ISR_PORT_LINK_STS_CHG, .imr_port_link_sts_chg = RTL839X_IMR_PORT_LINK_STS_CHG, .imr_glb = RTL839X_IMR_GLB, + .n_counters = 1024, .port_ignore = 0x3f, .vlan_tables_read = rtl839x_vlan_tables_read, .vlan_set_tagged = rtl839x_vlan_set_tagged, diff --git a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl930x.c b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl930x.c index 308fdfd0001..d07b93b7b27 100644 --- a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl930x.c +++ b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl930x.c @@ -2645,6 +2645,7 @@ const struct rtldsa_config rtldsa_930x_cfg = { .isr_port_link_sts_chg = RTL930X_ISR_PORT_LINK_STS_CHG, .imr_port_link_sts_chg = RTL930X_IMR_PORT_LINK_STS_CHG, .imr_glb = RTL930X_IMR_GLB, + .n_counters = 2048, .port_ignore = 0x3f, .vlan_tables_read = rtl930x_vlan_tables_read, .vlan_set_tagged = rtl930x_vlan_set_tagged, diff --git a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl931x.c b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl931x.c index 74d1b613f03..6637926fcb3 100644 --- a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl931x.c +++ b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl931x.c @@ -1801,6 +1801,7 @@ const struct rtldsa_config rtldsa_931x_cfg = { .isr_port_link_sts_chg = RTL931X_ISR_PORT_LINK_STS_CHG, .imr_port_link_sts_chg = RTL931X_IMR_PORT_LINK_STS_CHG, /* imr_glb does not exist on RTL931X */ + .n_counters = 2048, .port_ignore = 0x3f, .vlan_tables_read = rtl931x_vlan_tables_read, .vlan_set_tagged = rtl931x_vlan_set_tagged,