mirror of
https://git.openwrt.org/openwrt/openwrt.git
synced 2026-05-05 01:46:11 +02:00
realtek: dsa: move n_mst/l2_bucket_size out of family check
Another two variables that are not part of the runtime but the configuration structure. Move them around. Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de> Link: https://github.com/openwrt/openwrt/pull/22749 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
This commit is contained in:
parent
e7738904d8
commit
e745ee3f13
@ -726,7 +726,7 @@ static int rtl83xx_l2_nexthop_add(struct rtl838x_switch_priv *priv, struct rtl83
|
||||
e.port = nh->port;
|
||||
|
||||
/* Loop over all entries in the hash-bucket and over the second block on 93xx SoCs */
|
||||
for (int i = 0; i < priv->l2_bucket_size; i++) {
|
||||
for (int i = 0; i < priv->r->l2_bucket_size; i++) {
|
||||
entry = priv->r->read_l2_entry_using_hash(key, i, &e);
|
||||
|
||||
if (!e.valid || ((entry & 0x0fffffffffffffffULL) == seed)) {
|
||||
@ -1611,23 +1611,11 @@ static int rtl83xx_sw_probe(struct platform_device *pdev)
|
||||
priv->family_id = soc_info.family;
|
||||
priv->id = soc_info.id;
|
||||
switch (soc_info.family) {
|
||||
case RTL8380_FAMILY_ID:
|
||||
priv->l2_bucket_size = 4;
|
||||
priv->n_mst = 64;
|
||||
break;
|
||||
case RTL8390_FAMILY_ID:
|
||||
priv->l2_bucket_size = 4;
|
||||
priv->n_mst = 256;
|
||||
break;
|
||||
case RTL9300_FAMILY_ID:
|
||||
sw_w32(0, RTL930X_ST_CTRL);
|
||||
priv->l2_bucket_size = 8;
|
||||
priv->n_mst = 64;
|
||||
break;
|
||||
case RTL9310_FAMILY_ID:
|
||||
sw_w32(0, RTL931x_ST_CTRL);
|
||||
priv->l2_bucket_size = 8;
|
||||
priv->n_mst = 128;
|
||||
break;
|
||||
}
|
||||
priv->ds->num_ports = priv->r->cpu_port + 1;
|
||||
@ -1642,7 +1630,7 @@ static int rtl83xx_sw_probe(struct platform_device *pdev)
|
||||
}
|
||||
|
||||
priv->msts = devm_kcalloc(priv->dev,
|
||||
priv->n_mst - 1, sizeof(struct rtldsa_mst),
|
||||
priv->r->n_mst - 1, sizeof(struct rtldsa_mst),
|
||||
GFP_KERNEL);
|
||||
if (!priv->msts)
|
||||
return -ENOMEM;
|
||||
|
||||
@ -1191,7 +1191,7 @@ static int rtldsa_mst_find(struct rtl838x_switch_priv *priv, u16 msti)
|
||||
return -EINVAL;
|
||||
|
||||
/* search for existing entry */
|
||||
for (i = 0; i < priv->n_mst - 1; i++) {
|
||||
for (i = 0; i < priv->r->n_mst - 1; i++) {
|
||||
if (priv->msts[i].msti != msti)
|
||||
continue;
|
||||
|
||||
@ -1233,7 +1233,7 @@ static int rtldsa_mst_get(struct rtl838x_switch_priv *priv, u16 msti)
|
||||
return ret;
|
||||
|
||||
/* search for free slot */
|
||||
for (i = 0; i < priv->n_mst - 1; i++) {
|
||||
for (i = 0; i < priv->r->n_mst - 1; i++) {
|
||||
if (priv->msts[i].msti != 0)
|
||||
continue;
|
||||
|
||||
@ -1279,7 +1279,7 @@ static int rtldsa_mst_recycle_slot(struct rtl838x_switch_priv *priv, u16 msti, u
|
||||
if (msti > 4095)
|
||||
return -EINVAL;
|
||||
|
||||
if (old_mst_slot >= priv->n_mst)
|
||||
if (old_mst_slot >= priv->r->n_mst)
|
||||
return -EINVAL;
|
||||
|
||||
index = old_mst_slot - 1;
|
||||
@ -1320,7 +1320,7 @@ static bool rtldsa_mst_put_slot(struct rtl838x_switch_priv *priv, u16 mst_slot)
|
||||
if (mst_slot == 0)
|
||||
return 0;
|
||||
|
||||
if (mst_slot >= priv->n_mst)
|
||||
if (mst_slot >= priv->r->n_mst)
|
||||
return 0;
|
||||
|
||||
index = mst_slot - 1;
|
||||
@ -1419,7 +1419,7 @@ static int rtldsa_port_bridge_join(struct dsa_switch *ds, int port, struct dsa_b
|
||||
priv->r->set_static_move_action(port, false);
|
||||
|
||||
/* Set to disabled in all MSTs, common code will take care of CIST */
|
||||
for (i = 1; i < priv->n_mst; i++)
|
||||
for (i = 1; i < priv->r->n_mst; i++)
|
||||
rtldsa_port_xstp_state_set(priv, port, BR_STATE_DISABLED, i);
|
||||
|
||||
mutex_unlock(&priv->reg_mutex);
|
||||
@ -1442,7 +1442,7 @@ static void rtldsa_port_bridge_leave(struct dsa_switch *ds, int port, struct dsa
|
||||
priv->r->set_static_move_action(port, true);
|
||||
|
||||
/* Set to forwarding in all MSTs, common code will take care of CIST */
|
||||
for (i = 1; i < priv->n_mst; i++)
|
||||
for (i = 1; i < priv->r->n_mst; i++)
|
||||
rtldsa_port_xstp_state_set(priv, port, BR_STATE_FORWARDING, i);
|
||||
|
||||
mutex_unlock(&priv->reg_mutex);
|
||||
@ -1513,7 +1513,7 @@ void rtldsa_port_stp_state_set(struct dsa_switch *ds, int port, u8 state)
|
||||
goto unlock;
|
||||
|
||||
/* for unbridged ports, also force the same state to the MSTIs */
|
||||
for (i = 1; i < priv->n_mst; i++)
|
||||
for (i = 1; i < priv->r->n_mst; i++)
|
||||
rtldsa_port_xstp_state_set(priv, port, state, i);
|
||||
|
||||
unlock:
|
||||
@ -1828,7 +1828,7 @@ static int rtldsa_find_l2_hash_entry(struct rtl838x_switch_priv *priv, u64 seed,
|
||||
|
||||
pr_debug("%s: using key %x, for seed %016llx\n", __func__, key, seed);
|
||||
/* Loop over all entries in the hash-bucket and over the second block on 93xx SoCs */
|
||||
for (int i = 0; i < priv->l2_bucket_size; i++) {
|
||||
for (int i = 0; i < priv->r->l2_bucket_size; i++) {
|
||||
entry = priv->r->read_l2_entry_using_hash(key, i, e);
|
||||
pr_debug("valid %d, mac %016llx\n", e->valid, ether_addr_to_u64(&e->mac[0]));
|
||||
if (must_exist && !e->valid)
|
||||
|
||||
@ -1809,6 +1809,8 @@ int rtldsa_83xx_lag_setup_algomask(struct rtl838x_switch_priv *priv, int group,
|
||||
const struct rtldsa_config rtldsa_838x_cfg = {
|
||||
.switch_ops = &rtldsa_83xx_switch_ops,
|
||||
.phylink_mac_ops = &rtldsa_83xx_phylink_mac_ops,
|
||||
.l2_bucket_size = 4,
|
||||
.n_mst = 64,
|
||||
.num_lag_ids = 8,
|
||||
.cpu_port = RTL838X_CPU_PORT,
|
||||
.fib_entries = 8192,
|
||||
|
||||
@ -1417,6 +1417,8 @@ struct rtldsa_config {
|
||||
u8 num_lag_ids;
|
||||
u8 cpu_port;
|
||||
u8 port_ignore;
|
||||
u8 l2_bucket_size;
|
||||
u16 n_mst;
|
||||
u32 fib_entries;
|
||||
int trk_ctrl;
|
||||
int trk_hash_ctrl;
|
||||
@ -1521,8 +1523,6 @@ struct rtl838x_switch_priv {
|
||||
struct mii_bus *parent_bus;
|
||||
const struct rtldsa_config *r;
|
||||
u64 irq_mask;
|
||||
int l2_bucket_size;
|
||||
u16 n_mst;
|
||||
struct dentry *dbgfs_dir;
|
||||
|
||||
/** @lags_port_members: Port (bit) is part of a specific LAG */
|
||||
|
||||
@ -1724,6 +1724,8 @@ int rtldsa_83xx_lag_setup_algomask(struct rtl838x_switch_priv *priv, int group,
|
||||
const struct rtldsa_config rtldsa_839x_cfg = {
|
||||
.switch_ops = &rtldsa_83xx_switch_ops,
|
||||
.phylink_mac_ops = &rtldsa_83xx_phylink_mac_ops,
|
||||
.l2_bucket_size = 4,
|
||||
.n_mst = 256,
|
||||
.num_lag_ids = 16,
|
||||
.cpu_port = RTL839X_CPU_PORT,
|
||||
.fib_entries = 16384,
|
||||
|
||||
@ -2795,6 +2795,8 @@ static void rtldsa_930x_qos_init(struct rtl838x_switch_priv *priv)
|
||||
const struct rtldsa_config rtldsa_930x_cfg = {
|
||||
.switch_ops = &rtldsa_93xx_switch_ops,
|
||||
.phylink_mac_ops = &rtldsa_93xx_phylink_mac_ops,
|
||||
.l2_bucket_size = 8,
|
||||
.n_mst = 64,
|
||||
.num_lag_ids = 16,
|
||||
.cpu_port = RTL930X_CPU_PORT,
|
||||
.fib_entries = 16384,
|
||||
|
||||
@ -1936,6 +1936,8 @@ static void rtldsa_931x_qos_init(struct rtl838x_switch_priv *priv)
|
||||
const struct rtldsa_config rtldsa_931x_cfg = {
|
||||
.switch_ops = &rtldsa_93xx_switch_ops,
|
||||
.phylink_mac_ops = &rtldsa_93xx_phylink_mac_ops,
|
||||
.l2_bucket_size = 8,
|
||||
.n_mst = 128,
|
||||
.num_lag_ids = 16,
|
||||
.cpu_port = RTL931X_CPU_PORT,
|
||||
.fib_entries = 16384, /* TODO: has 32K but code cannot handle that */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user