realtek: dsa: move fib_entries to config structure

The fib_entries attribute is a device specific constant.
Therefore move it into the configuration structure. Add
a comment why someone used 16K fib_entries for RTL931x
instead of the possible 32K.

Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/22438
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
This commit is contained in:
Markus Stockhausen 2026-03-15 19:43:08 +01:00 committed by Hauke Mehrtens
parent 85961cc798
commit 59f146c581
8 changed files with 7 additions and 7 deletions

View File

@ -1610,7 +1610,6 @@ static int rtl83xx_sw_probe(struct platform_device *pdev)
case RTL8380_FAMILY_ID:
priv->ds->ops = &rtldsa_83xx_switch_ops;
priv->ds->phylink_mac_ops = &rtldsa_83xx_phylink_mac_ops;
priv->fib_entries = 8192;
priv->ds->num_lag_ids = 8;
priv->l2_bucket_size = 4;
priv->n_mst = 64;
@ -1618,7 +1617,6 @@ static int rtl83xx_sw_probe(struct platform_device *pdev)
case RTL8390_FAMILY_ID:
priv->ds->ops = &rtldsa_83xx_switch_ops;
priv->ds->phylink_mac_ops = &rtldsa_83xx_phylink_mac_ops;
priv->fib_entries = 16384;
priv->ds->num_lag_ids = 16;
priv->l2_bucket_size = 4;
priv->n_mst = 256;
@ -1626,7 +1624,6 @@ static int rtl83xx_sw_probe(struct platform_device *pdev)
case RTL9300_FAMILY_ID:
priv->ds->ops = &rtldsa_93xx_switch_ops;
priv->ds->phylink_mac_ops = &rtldsa_93xx_phylink_mac_ops;
priv->fib_entries = 16384;
priv->ds->num_lag_ids = 16;
sw_w32(0, RTL930X_ST_CTRL);
priv->l2_bucket_size = 8;
@ -1635,7 +1632,6 @@ static int rtl83xx_sw_probe(struct platform_device *pdev)
case RTL9310_FAMILY_ID:
priv->ds->ops = &rtldsa_93xx_switch_ops;
priv->ds->phylink_mac_ops = &rtldsa_93xx_phylink_mac_ops;
priv->fib_entries = 16384;
priv->ds->num_lag_ids = 16;
sw_w32(0, RTL931x_ST_CTRL);
priv->l2_bucket_size = 8;

View File

@ -324,7 +324,7 @@ static int l2_table_show(struct seq_file *m, void *v)
mutex_lock(&priv->reg_mutex);
for (int i = 0; i < priv->fib_entries; i++) {
for (int i = 0; i < priv->r->fib_entries; i++) {
bucket = i >> 2;
index = i & 0x3;
priv->r->read_l2_entry_using_hash(bucket, index, &e);

View File

@ -2002,7 +2002,7 @@ static int rtldsa_port_fdb_dump(struct dsa_switch *ds, int port,
mutex_lock(&priv->reg_mutex);
for (int i = 0; i < priv->fib_entries; i++) {
for (int i = 0; i < priv->r->fib_entries; i++) {
priv->r->read_l2_entry_using_hash(i >> 2, i & 0x3, &e);
if (!e.valid)

View File

@ -1808,6 +1808,7 @@ int rtldsa_83xx_lag_setup_algomask(struct rtl838x_switch_priv *priv, int group,
const struct rtldsa_config rtldsa_838x_cfg = {
.cpu_port = RTL838X_CPU_PORT,
.fib_entries = 8192,
.mask_port_reg_be = rtl838x_mask_port_reg,
.set_port_reg_be = rtl838x_set_port_reg,
.get_port_reg_be = rtl838x_get_port_reg,

View File

@ -1414,6 +1414,7 @@ struct rtldsa_config {
int n_pie_blocks;
u8 cpu_port;
u8 port_ignore;
u32 fib_entries;
int trk_ctrl;
int trk_hash_ctrl;
void (*vlan_tables_read)(u32 vlan, struct rtl838x_vlan_info *info);
@ -1517,7 +1518,6 @@ struct rtl838x_switch_priv {
struct mii_bus *parent_bus;
const struct rtldsa_config *r;
u64 irq_mask;
u32 fib_entries;
int l2_bucket_size;
u16 n_mst;
struct dentry *dbgfs_dir;

View File

@ -1723,6 +1723,7 @@ int rtldsa_83xx_lag_setup_algomask(struct rtl838x_switch_priv *priv, int group,
const struct rtldsa_config rtldsa_839x_cfg = {
.cpu_port = RTL839X_CPU_PORT,
.fib_entries = 16384,
.mask_port_reg_be = rtl839x_mask_port_reg_be,
.set_port_reg_be = rtl839x_set_port_reg_be,
.get_port_reg_be = rtl839x_get_port_reg_be,

View File

@ -2794,6 +2794,7 @@ static void rtldsa_930x_qos_init(struct rtl838x_switch_priv *priv)
const struct rtldsa_config rtldsa_930x_cfg = {
.cpu_port = RTL930X_CPU_PORT,
.fib_entries = 16384,
.mask_port_reg_be = rtl838x_mask_port_reg,
.set_port_reg_be = rtl838x_set_port_reg,
.get_port_reg_be = rtl838x_get_port_reg,

View File

@ -1935,6 +1935,7 @@ static void rtldsa_931x_qos_init(struct rtl838x_switch_priv *priv)
const struct rtldsa_config rtldsa_931x_cfg = {
.cpu_port = RTL931X_CPU_PORT,
.fib_entries = 16384, /* TODO: has 32K but code cannot handle that */
.mask_port_reg_be = rtl839x_mask_port_reg_be,
.set_port_reg_be = rtl839x_set_port_reg_be,
.get_port_reg_be = rtl839x_get_port_reg_be,