]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: dsa: move n_counters into config structure
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Tue, 17 Feb 2026 17:52:49 +0000 (18:52 +0100)
committerHauke Mehrtens <hauke@hauke-m.de>
Sat, 21 Feb 2026 19:33:28 +0000 (20:33 +0100)
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>
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.c
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.h
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl839x.c
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl930x.c
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl931x.c

index 7b03831a82a15aae59f5cbd9b0c6cc9daf518098..dd1efcb2b684aed16825763bf50882da16f16335 100644 (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;
        }
 
index 3a594db0587dccf94df6c64f5a1fea5246922b49..5bc564659c459f28262d6a1ebb2c46059e11cfce 100644 (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,
index 4435d5758d2137004e9ff0ea3d437e248b730643..12abe423f234896d136a4a552b80062efbda156e 100644 (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;
index a78c981c215b355bd282788a198eed6f0da9eed6..46bc3212d0950319d26795aa4d1c91c7ac01f3d0 100644 (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,
index 308fdfd0001f55acc7014f178583997a6f5354a0..d07b93b7b27b2ee65dbf82ea3eb0423e2be0f626 100644 (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,
index 74d1b613f0320f92286f772eb1610e15389b1756..6637926fcb329cdf4f2712f2e7bdd8651a704aaf 100644 (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,