summaryrefslogtreecommitdiff
path: root/drivers/net/dsa/qca8k.c
diff options
context:
space:
mode:
authorVladimir Oltean <vladimir.oltean@nxp.com>2022-02-23 16:00:47 +0200
committerJakub Kicinski <kuba@kernel.org>2022-02-24 21:31:42 -0800
commit3d4a0a2a46ab8ff8897dfd6324edee5e8184d2c5 (patch)
tree51c6dcc08ff233c5ceec4f7b391925f99a5f6957 /drivers/net/dsa/qca8k.c
parent066ce9779c7a92a3113cc392dd1f47c83f483903 (diff)
net: dsa: make LAG IDs one-based
The DSA LAG API will be changed to become more similar with the bridge data structures, where struct dsa_bridge holds an unsigned int num, which is generated by DSA and is one-based. We have a similar thing going with the DSA LAG, except that isn't stored anywhere, it is calculated dynamically by dsa_lag_id() by iterating through dst->lags. The idea of encoding an invalid (or not requested) LAG ID as zero for the purpose of simplifying checks in drivers means that the LAG IDs passed by DSA to drivers need to be one-based too. So back-and-forth conversion is needed when indexing the dst->lags array, as well as in drivers which assume a zero-based index. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/net/dsa/qca8k.c')
-rw-r--r--drivers/net/dsa/qca8k.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c
index 5691d193aa71..ed55e9357c2b 100644
--- a/drivers/net/dsa/qca8k.c
+++ b/drivers/net/dsa/qca8k.c
@@ -2654,7 +2654,7 @@ qca8k_lag_can_offload(struct dsa_switch *ds,
int id, members = 0;
id = dsa_lag_id(ds->dst, lag_dev);
- if (id < 0 || id >= ds->num_lag_ids)
+ if (id <= 0 || id > ds->num_lag_ids)
return false;
dsa_lag_foreach_port(dp, ds->dst, lag_dev)
@@ -2732,7 +2732,8 @@ qca8k_lag_refresh_portmap(struct dsa_switch *ds, int port,
int ret, id, i;
u32 val;
- id = dsa_lag_id(ds->dst, lag_dev);
+ /* DSA LAG IDs are one-based, hardware is zero-based */
+ id = dsa_lag_id(ds->dst, lag_dev) - 1;
/* Read current port member */
ret = regmap_read(priv->regmap, QCA8K_REG_GOL_TRUNK_CTRL0, &val);