realtek: dsa: move n_counters into config structure

Place it where it belongs.

Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/22068
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
This commit is contained in:
Markus Stockhausen
2026-02-17 18:52:49 +01:00
committed by Hauke Mehrtens
parent b74e261d56
commit 42a311bac9
6 changed files with 8 additions and 8 deletions

View File

@@ -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;
}

View File

@@ -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,

View File

@@ -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;

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,