diff options
author | Vladimir Oltean <vladimir.oltean@nxp.com> | 2022-02-23 16:00:47 +0200 |
---|---|---|
committer | Vladimir Oltean <vladimir.oltean@nxp.com> | 2022-05-04 15:24:55 +0200 |
commit | c8e470513251eadd6c68284c79d92560a5ce85f9 (patch) | |
tree | 29e94c3744e22ce5ea4200eb513db3ec7c45a60b /net/dsa | |
parent | 6354ec321615867e66dbb880ca9de4c9123852ec (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>
(cherry picked from commit 3d4a0a2a46ab8ff8897dfd6324edee5e8184d2c5)
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Diffstat (limited to 'net/dsa')
-rw-r--r-- | net/dsa/dsa2.c | 8 | ||||
-rw-r--r-- | net/dsa/tag_dsa.c | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index dd3fedd8d185..a9d41d55ca18 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -85,13 +85,13 @@ void dsa_lag_map(struct dsa_switch_tree *dst, struct net_device *lag_dev) { unsigned int id; - if (dsa_lag_id(dst, lag_dev) >= 0) + if (dsa_lag_id(dst, lag_dev) > 0) /* Already mapped */ return; - for (id = 0; id < dst->lags_len; id++) { + for (id = 1; id <= dst->lags_len; id++) { if (!dsa_lag_dev(dst, id)) { - dst->lags[id] = lag_dev; + dst->lags[id - 1] = lag_dev; return; } } @@ -123,7 +123,7 @@ void dsa_lag_unmap(struct dsa_switch_tree *dst, struct net_device *lag_dev) dsa_lags_foreach_id(id, dst) { if (dsa_lag_dev(dst, id) == lag_dev) { - dst->lags[id] = NULL; + dst->lags[id - 1] = NULL; break; } } diff --git a/net/dsa/tag_dsa.c b/net/dsa/tag_dsa.c index 8abf39dcac64..26435bc4a098 100644 --- a/net/dsa/tag_dsa.c +++ b/net/dsa/tag_dsa.c @@ -251,7 +251,7 @@ static struct sk_buff *dsa_rcv_ll(struct sk_buff *skb, struct net_device *dev, * so we inject the frame directly on the upper * team/bond. */ - skb->dev = dsa_lag_dev(cpu_dp->dst, source_port); + skb->dev = dsa_lag_dev(cpu_dp->dst, source_port + 1); } else { skb->dev = dsa_master_find_slave(dev, source_device, source_port); |