Commit 726816a1 authored by Vladimir Oltean's avatar Vladimir Oltean Committed by David S. Miller

net: dsa: make cross-chip notifiers more efficient for host events

To determine whether a given port should react to the port targeted by
the notifier, dsa_port_host_vlan_match() and dsa_port_host_address_match()
look at the positioning of the switch port currently executing the
notifier relative to the switch port for which the notifier was emitted.

To maintain stylistic compatibility with the other match functions from
switch.c, the host address and host VLAN match functions take the
notifier information about targeted port, switch and tree indices as
argument. However, these functions only use that information to retrieve
the struct dsa_port *targeted_dp, which is an invariant for the outer
loop that calls them. So it makes more sense to calculate the targeted
dp only once, and pass it to them as argument.

But furthermore, the targeted dp is actually known at the time the call
to dsa_port_notify() is made. It is just that we decide to only save the
indices of the port, switch and tree in the notifier structure, just to
retrace our steps and find the dp again using dsa_switch_find() and
dsa_to_port().

But both the above functions are relatively expensive, since they need
to iterate through lists. It appears more straightforward to make all
notifiers just pass the targeted dp inside their info structure, and
have the code that needs the indices to look at info->dp->index instead
of info->port, or info->dp->ds->index instead of info->sw_index, or
info->dp->ds->dst->index instead of info->tree_index.

For the sake of consistency, all cross-chip notifiers are converted to
pass the "dp" directly.
Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8e9e678e
...@@ -54,18 +54,15 @@ struct dsa_notifier_ageing_time_info { ...@@ -54,18 +54,15 @@ struct dsa_notifier_ageing_time_info {
/* DSA_NOTIFIER_BRIDGE_* */ /* DSA_NOTIFIER_BRIDGE_* */
struct dsa_notifier_bridge_info { struct dsa_notifier_bridge_info {
const struct dsa_port *dp;
struct dsa_bridge bridge; struct dsa_bridge bridge;
int tree_index;
int sw_index;
int port;
bool tx_fwd_offload; bool tx_fwd_offload;
struct netlink_ext_ack *extack; struct netlink_ext_ack *extack;
}; };
/* DSA_NOTIFIER_FDB_* */ /* DSA_NOTIFIER_FDB_* */
struct dsa_notifier_fdb_info { struct dsa_notifier_fdb_info {
int sw_index; const struct dsa_port *dp;
int port;
const unsigned char *addr; const unsigned char *addr;
u16 vid; u16 vid;
struct dsa_db db; struct dsa_db db;
...@@ -81,34 +78,29 @@ struct dsa_notifier_lag_fdb_info { ...@@ -81,34 +78,29 @@ struct dsa_notifier_lag_fdb_info {
/* DSA_NOTIFIER_MDB_* */ /* DSA_NOTIFIER_MDB_* */
struct dsa_notifier_mdb_info { struct dsa_notifier_mdb_info {
const struct dsa_port *dp;
const struct switchdev_obj_port_mdb *mdb; const struct switchdev_obj_port_mdb *mdb;
int sw_index;
int port;
struct dsa_db db; struct dsa_db db;
}; };
/* DSA_NOTIFIER_LAG_* */ /* DSA_NOTIFIER_LAG_* */
struct dsa_notifier_lag_info { struct dsa_notifier_lag_info {
const struct dsa_port *dp;
struct dsa_lag lag; struct dsa_lag lag;
int sw_index;
int port;
struct netdev_lag_upper_info *info; struct netdev_lag_upper_info *info;
}; };
/* DSA_NOTIFIER_VLAN_* */ /* DSA_NOTIFIER_VLAN_* */
struct dsa_notifier_vlan_info { struct dsa_notifier_vlan_info {
const struct dsa_port *dp;
const struct switchdev_obj_port_vlan *vlan; const struct switchdev_obj_port_vlan *vlan;
int sw_index;
int port;
struct netlink_ext_ack *extack; struct netlink_ext_ack *extack;
}; };
/* DSA_NOTIFIER_MTU */ /* DSA_NOTIFIER_MTU */
struct dsa_notifier_mtu_info { struct dsa_notifier_mtu_info {
const struct dsa_port *dp;
bool targeted_match; bool targeted_match;
int sw_index;
int port;
int mtu; int mtu;
}; };
...@@ -119,9 +111,7 @@ struct dsa_notifier_tag_proto_info { ...@@ -119,9 +111,7 @@ struct dsa_notifier_tag_proto_info {
/* DSA_NOTIFIER_TAG_8021Q_VLAN_* */ /* DSA_NOTIFIER_TAG_8021Q_VLAN_* */
struct dsa_notifier_tag_8021q_vlan_info { struct dsa_notifier_tag_8021q_vlan_info {
int tree_index; const struct dsa_port *dp;
int sw_index;
int port;
u16 vid; u16 vid;
}; };
......
...@@ -459,9 +459,7 @@ int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br, ...@@ -459,9 +459,7 @@ int dsa_port_bridge_join(struct dsa_port *dp, struct net_device *br,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct dsa_notifier_bridge_info info = { struct dsa_notifier_bridge_info info = {
.tree_index = dp->ds->dst->index, .dp = dp,
.sw_index = dp->ds->index,
.port = dp->index,
.extack = extack, .extack = extack,
}; };
struct net_device *dev = dp->slave; struct net_device *dev = dp->slave;
...@@ -530,9 +528,7 @@ void dsa_port_pre_bridge_leave(struct dsa_port *dp, struct net_device *br) ...@@ -530,9 +528,7 @@ void dsa_port_pre_bridge_leave(struct dsa_port *dp, struct net_device *br)
void dsa_port_bridge_leave(struct dsa_port *dp, struct net_device *br) void dsa_port_bridge_leave(struct dsa_port *dp, struct net_device *br)
{ {
struct dsa_notifier_bridge_info info = { struct dsa_notifier_bridge_info info = {
.tree_index = dp->ds->dst->index, .dp = dp,
.sw_index = dp->ds->index,
.port = dp->index,
}; };
int err; int err;
...@@ -562,8 +558,7 @@ int dsa_port_lag_change(struct dsa_port *dp, ...@@ -562,8 +558,7 @@ int dsa_port_lag_change(struct dsa_port *dp,
struct netdev_lag_lower_state_info *linfo) struct netdev_lag_lower_state_info *linfo)
{ {
struct dsa_notifier_lag_info info = { struct dsa_notifier_lag_info info = {
.sw_index = dp->ds->index, .dp = dp,
.port = dp->index,
}; };
bool tx_enabled; bool tx_enabled;
...@@ -632,8 +627,7 @@ int dsa_port_lag_join(struct dsa_port *dp, struct net_device *lag_dev, ...@@ -632,8 +627,7 @@ int dsa_port_lag_join(struct dsa_port *dp, struct net_device *lag_dev,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct dsa_notifier_lag_info info = { struct dsa_notifier_lag_info info = {
.sw_index = dp->ds->index, .dp = dp,
.port = dp->index,
.info = uinfo, .info = uinfo,
}; };
struct net_device *bridge_dev; struct net_device *bridge_dev;
...@@ -678,8 +672,7 @@ void dsa_port_lag_leave(struct dsa_port *dp, struct net_device *lag_dev) ...@@ -678,8 +672,7 @@ void dsa_port_lag_leave(struct dsa_port *dp, struct net_device *lag_dev)
{ {
struct net_device *br = dsa_port_bridge_dev_get(dp); struct net_device *br = dsa_port_bridge_dev_get(dp);
struct dsa_notifier_lag_info info = { struct dsa_notifier_lag_info info = {
.sw_index = dp->ds->index, .dp = dp,
.port = dp->index,
}; };
int err; int err;
...@@ -941,9 +934,8 @@ int dsa_port_mtu_change(struct dsa_port *dp, int new_mtu, ...@@ -941,9 +934,8 @@ int dsa_port_mtu_change(struct dsa_port *dp, int new_mtu,
bool targeted_match) bool targeted_match)
{ {
struct dsa_notifier_mtu_info info = { struct dsa_notifier_mtu_info info = {
.sw_index = dp->ds->index, .dp = dp,
.targeted_match = targeted_match, .targeted_match = targeted_match,
.port = dp->index,
.mtu = new_mtu, .mtu = new_mtu,
}; };
...@@ -954,8 +946,7 @@ int dsa_port_fdb_add(struct dsa_port *dp, const unsigned char *addr, ...@@ -954,8 +946,7 @@ int dsa_port_fdb_add(struct dsa_port *dp, const unsigned char *addr,
u16 vid) u16 vid)
{ {
struct dsa_notifier_fdb_info info = { struct dsa_notifier_fdb_info info = {
.sw_index = dp->ds->index, .dp = dp,
.port = dp->index,
.addr = addr, .addr = addr,
.vid = vid, .vid = vid,
.db = { .db = {
...@@ -978,8 +969,7 @@ int dsa_port_fdb_del(struct dsa_port *dp, const unsigned char *addr, ...@@ -978,8 +969,7 @@ int dsa_port_fdb_del(struct dsa_port *dp, const unsigned char *addr,
u16 vid) u16 vid)
{ {
struct dsa_notifier_fdb_info info = { struct dsa_notifier_fdb_info info = {
.sw_index = dp->ds->index, .dp = dp,
.port = dp->index,
.addr = addr, .addr = addr,
.vid = vid, .vid = vid,
.db = { .db = {
...@@ -999,8 +989,7 @@ static int dsa_port_host_fdb_add(struct dsa_port *dp, ...@@ -999,8 +989,7 @@ static int dsa_port_host_fdb_add(struct dsa_port *dp,
struct dsa_db db) struct dsa_db db)
{ {
struct dsa_notifier_fdb_info info = { struct dsa_notifier_fdb_info info = {
.sw_index = dp->ds->index, .dp = dp,
.port = dp->index,
.addr = addr, .addr = addr,
.vid = vid, .vid = vid,
.db = db, .db = db,
...@@ -1051,8 +1040,7 @@ static int dsa_port_host_fdb_del(struct dsa_port *dp, ...@@ -1051,8 +1040,7 @@ static int dsa_port_host_fdb_del(struct dsa_port *dp,
struct dsa_db db) struct dsa_db db)
{ {
struct dsa_notifier_fdb_info info = { struct dsa_notifier_fdb_info info = {
.sw_index = dp->ds->index, .dp = dp,
.port = dp->index,
.addr = addr, .addr = addr,
.vid = vid, .vid = vid,
.db = db, .db = db,
...@@ -1147,8 +1135,7 @@ int dsa_port_mdb_add(const struct dsa_port *dp, ...@@ -1147,8 +1135,7 @@ int dsa_port_mdb_add(const struct dsa_port *dp,
const struct switchdev_obj_port_mdb *mdb) const struct switchdev_obj_port_mdb *mdb)
{ {
struct dsa_notifier_mdb_info info = { struct dsa_notifier_mdb_info info = {
.sw_index = dp->ds->index, .dp = dp,
.port = dp->index,
.mdb = mdb, .mdb = mdb,
.db = { .db = {
.type = DSA_DB_BRIDGE, .type = DSA_DB_BRIDGE,
...@@ -1166,8 +1153,7 @@ int dsa_port_mdb_del(const struct dsa_port *dp, ...@@ -1166,8 +1153,7 @@ int dsa_port_mdb_del(const struct dsa_port *dp,
const struct switchdev_obj_port_mdb *mdb) const struct switchdev_obj_port_mdb *mdb)
{ {
struct dsa_notifier_mdb_info info = { struct dsa_notifier_mdb_info info = {
.sw_index = dp->ds->index, .dp = dp,
.port = dp->index,
.mdb = mdb, .mdb = mdb,
.db = { .db = {
.type = DSA_DB_BRIDGE, .type = DSA_DB_BRIDGE,
...@@ -1186,8 +1172,7 @@ static int dsa_port_host_mdb_add(const struct dsa_port *dp, ...@@ -1186,8 +1172,7 @@ static int dsa_port_host_mdb_add(const struct dsa_port *dp,
struct dsa_db db) struct dsa_db db)
{ {
struct dsa_notifier_mdb_info info = { struct dsa_notifier_mdb_info info = {
.sw_index = dp->ds->index, .dp = dp,
.port = dp->index,
.mdb = mdb, .mdb = mdb,
.db = db, .db = db,
}; };
...@@ -1231,8 +1216,7 @@ static int dsa_port_host_mdb_del(const struct dsa_port *dp, ...@@ -1231,8 +1216,7 @@ static int dsa_port_host_mdb_del(const struct dsa_port *dp,
struct dsa_db db) struct dsa_db db)
{ {
struct dsa_notifier_mdb_info info = { struct dsa_notifier_mdb_info info = {
.sw_index = dp->ds->index, .dp = dp,
.port = dp->index,
.mdb = mdb, .mdb = mdb,
.db = db, .db = db,
}; };
...@@ -1276,8 +1260,7 @@ int dsa_port_vlan_add(struct dsa_port *dp, ...@@ -1276,8 +1260,7 @@ int dsa_port_vlan_add(struct dsa_port *dp,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct dsa_notifier_vlan_info info = { struct dsa_notifier_vlan_info info = {
.sw_index = dp->ds->index, .dp = dp,
.port = dp->index,
.vlan = vlan, .vlan = vlan,
.extack = extack, .extack = extack,
}; };
...@@ -1289,8 +1272,7 @@ int dsa_port_vlan_del(struct dsa_port *dp, ...@@ -1289,8 +1272,7 @@ int dsa_port_vlan_del(struct dsa_port *dp,
const struct switchdev_obj_port_vlan *vlan) const struct switchdev_obj_port_vlan *vlan)
{ {
struct dsa_notifier_vlan_info info = { struct dsa_notifier_vlan_info info = {
.sw_index = dp->ds->index, .dp = dp,
.port = dp->index,
.vlan = vlan, .vlan = vlan,
}; };
...@@ -1302,8 +1284,7 @@ int dsa_port_host_vlan_add(struct dsa_port *dp, ...@@ -1302,8 +1284,7 @@ int dsa_port_host_vlan_add(struct dsa_port *dp,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct dsa_notifier_vlan_info info = { struct dsa_notifier_vlan_info info = {
.sw_index = dp->ds->index, .dp = dp,
.port = dp->index,
.vlan = vlan, .vlan = vlan,
.extack = extack, .extack = extack,
}; };
...@@ -1323,8 +1304,7 @@ int dsa_port_host_vlan_del(struct dsa_port *dp, ...@@ -1323,8 +1304,7 @@ int dsa_port_host_vlan_del(struct dsa_port *dp,
const struct switchdev_obj_port_vlan *vlan) const struct switchdev_obj_port_vlan *vlan)
{ {
struct dsa_notifier_vlan_info info = { struct dsa_notifier_vlan_info info = {
.sw_index = dp->ds->index, .dp = dp,
.port = dp->index,
.vlan = vlan, .vlan = vlan,
}; };
struct dsa_port *cpu_dp = dp->cpu_dp; struct dsa_port *cpu_dp = dp->cpu_dp;
...@@ -1743,9 +1723,7 @@ void dsa_port_hsr_leave(struct dsa_port *dp, struct net_device *hsr) ...@@ -1743,9 +1723,7 @@ void dsa_port_hsr_leave(struct dsa_port *dp, struct net_device *hsr)
int dsa_port_tag_8021q_vlan_add(struct dsa_port *dp, u16 vid, bool broadcast) int dsa_port_tag_8021q_vlan_add(struct dsa_port *dp, u16 vid, bool broadcast)
{ {
struct dsa_notifier_tag_8021q_vlan_info info = { struct dsa_notifier_tag_8021q_vlan_info info = {
.tree_index = dp->ds->dst->index, .dp = dp,
.sw_index = dp->ds->index,
.port = dp->index,
.vid = vid, .vid = vid,
}; };
...@@ -1758,9 +1736,7 @@ int dsa_port_tag_8021q_vlan_add(struct dsa_port *dp, u16 vid, bool broadcast) ...@@ -1758,9 +1736,7 @@ int dsa_port_tag_8021q_vlan_add(struct dsa_port *dp, u16 vid, bool broadcast)
void dsa_port_tag_8021q_vlan_del(struct dsa_port *dp, u16 vid, bool broadcast) void dsa_port_tag_8021q_vlan_del(struct dsa_port *dp, u16 vid, bool broadcast)
{ {
struct dsa_notifier_tag_8021q_vlan_info info = { struct dsa_notifier_tag_8021q_vlan_info info = {
.tree_index = dp->ds->dst->index, .dp = dp,
.sw_index = dp->ds->index,
.port = dp->index,
.vid = vid, .vid = vid,
}; };
int err; int err;
......
...@@ -49,7 +49,7 @@ static int dsa_switch_ageing_time(struct dsa_switch *ds, ...@@ -49,7 +49,7 @@ static int dsa_switch_ageing_time(struct dsa_switch *ds,
static bool dsa_port_mtu_match(struct dsa_port *dp, static bool dsa_port_mtu_match(struct dsa_port *dp,
struct dsa_notifier_mtu_info *info) struct dsa_notifier_mtu_info *info)
{ {
if (dp->ds->index == info->sw_index && dp->index == info->port) if (dp == info->dp)
return true; return true;
/* Do not propagate to other switches in the tree if the notifier was /* Do not propagate to other switches in the tree if the notifier was
...@@ -88,25 +88,26 @@ static int dsa_switch_mtu(struct dsa_switch *ds, ...@@ -88,25 +88,26 @@ static int dsa_switch_mtu(struct dsa_switch *ds,
static int dsa_switch_bridge_join(struct dsa_switch *ds, static int dsa_switch_bridge_join(struct dsa_switch *ds,
struct dsa_notifier_bridge_info *info) struct dsa_notifier_bridge_info *info)
{ {
struct dsa_switch_tree *dst = ds->dst;
int err; int err;
if (dst->index == info->tree_index && ds->index == info->sw_index) { if (info->dp->ds == ds) {
if (!ds->ops->port_bridge_join) if (!ds->ops->port_bridge_join)
return -EOPNOTSUPP; return -EOPNOTSUPP;
err = ds->ops->port_bridge_join(ds, info->port, info->bridge, err = ds->ops->port_bridge_join(ds, info->dp->index,
info->bridge,
&info->tx_fwd_offload, &info->tx_fwd_offload,
info->extack); info->extack);
if (err) if (err)
return err; return err;
} }
if ((dst->index != info->tree_index || ds->index != info->sw_index) && if (info->dp->ds != ds && ds->ops->crosschip_bridge_join) {
ds->ops->crosschip_bridge_join) { err = ds->ops->crosschip_bridge_join(ds,
err = ds->ops->crosschip_bridge_join(ds, info->tree_index, info->dp->ds->dst->index,
info->sw_index, info->dp->ds->index,
info->port, info->bridge, info->dp->index,
info->bridge,
info->extack); info->extack);
if (err) if (err)
return err; return err;
...@@ -118,16 +119,13 @@ static int dsa_switch_bridge_join(struct dsa_switch *ds, ...@@ -118,16 +119,13 @@ static int dsa_switch_bridge_join(struct dsa_switch *ds,
static int dsa_switch_bridge_leave(struct dsa_switch *ds, static int dsa_switch_bridge_leave(struct dsa_switch *ds,
struct dsa_notifier_bridge_info *info) struct dsa_notifier_bridge_info *info)
{ {
struct dsa_switch_tree *dst = ds->dst; if (info->dp->ds == ds && ds->ops->port_bridge_leave)
ds->ops->port_bridge_leave(ds, info->dp->index, info->bridge);
if (dst->index == info->tree_index && ds->index == info->sw_index && if (info->dp->ds != ds && ds->ops->crosschip_bridge_leave)
ds->ops->port_bridge_leave) ds->ops->crosschip_bridge_leave(ds, info->dp->ds->dst->index,
ds->ops->port_bridge_leave(ds, info->port, info->bridge); info->dp->ds->index,
info->dp->index,
if ((dst->index != info->tree_index || ds->index != info->sw_index) &&
ds->ops->crosschip_bridge_leave)
ds->ops->crosschip_bridge_leave(ds, info->tree_index,
info->sw_index, info->port,
info->bridge); info->bridge);
return 0; return 0;
...@@ -138,16 +136,11 @@ static int dsa_switch_bridge_leave(struct dsa_switch *ds, ...@@ -138,16 +136,11 @@ static int dsa_switch_bridge_leave(struct dsa_switch *ds,
* emitted and its dedicated CPU port. * emitted and its dedicated CPU port.
*/ */
static bool dsa_port_host_address_match(struct dsa_port *dp, static bool dsa_port_host_address_match(struct dsa_port *dp,
int info_sw_index, int info_port) const struct dsa_port *targeted_dp)
{ {
struct dsa_port *targeted_dp, *cpu_dp; struct dsa_port *cpu_dp = targeted_dp->cpu_dp;
struct dsa_switch *targeted_ds;
targeted_ds = dsa_switch_find(dp->ds->dst->index, info_sw_index);
targeted_dp = dsa_to_port(targeted_ds, info_port);
cpu_dp = targeted_dp->cpu_dp;
if (dsa_switch_is_upstream_of(dp->ds, targeted_ds)) if (dsa_switch_is_upstream_of(dp->ds, targeted_dp->ds))
return dp->index == dsa_towards_port(dp->ds, cpu_dp->ds->index, return dp->index == dsa_towards_port(dp->ds, cpu_dp->ds->index,
cpu_dp->index); cpu_dp->index);
...@@ -415,8 +408,7 @@ static int dsa_switch_host_fdb_add(struct dsa_switch *ds, ...@@ -415,8 +408,7 @@ static int dsa_switch_host_fdb_add(struct dsa_switch *ds,
return -EOPNOTSUPP; return -EOPNOTSUPP;
dsa_switch_for_each_port(dp, ds) { dsa_switch_for_each_port(dp, ds) {
if (dsa_port_host_address_match(dp, info->sw_index, if (dsa_port_host_address_match(dp, info->dp)) {
info->port)) {
err = dsa_port_do_fdb_add(dp, info->addr, info->vid, err = dsa_port_do_fdb_add(dp, info->addr, info->vid,
info->db); info->db);
if (err) if (err)
...@@ -437,8 +429,7 @@ static int dsa_switch_host_fdb_del(struct dsa_switch *ds, ...@@ -437,8 +429,7 @@ static int dsa_switch_host_fdb_del(struct dsa_switch *ds,
return -EOPNOTSUPP; return -EOPNOTSUPP;
dsa_switch_for_each_port(dp, ds) { dsa_switch_for_each_port(dp, ds) {
if (dsa_port_host_address_match(dp, info->sw_index, if (dsa_port_host_address_match(dp, info->dp)) {
info->port)) {
err = dsa_port_do_fdb_del(dp, info->addr, info->vid, err = dsa_port_do_fdb_del(dp, info->addr, info->vid,
info->db); info->db);
if (err) if (err)
...@@ -452,7 +443,7 @@ static int dsa_switch_host_fdb_del(struct dsa_switch *ds, ...@@ -452,7 +443,7 @@ static int dsa_switch_host_fdb_del(struct dsa_switch *ds,
static int dsa_switch_fdb_add(struct dsa_switch *ds, static int dsa_switch_fdb_add(struct dsa_switch *ds,
struct dsa_notifier_fdb_info *info) struct dsa_notifier_fdb_info *info)
{ {
int port = dsa_towards_port(ds, info->sw_index, info->port); int port = dsa_towards_port(ds, info->dp->ds->index, info->dp->index);
struct dsa_port *dp = dsa_to_port(ds, port); struct dsa_port *dp = dsa_to_port(ds, port);
if (!ds->ops->port_fdb_add) if (!ds->ops->port_fdb_add)
...@@ -464,7 +455,7 @@ static int dsa_switch_fdb_add(struct dsa_switch *ds, ...@@ -464,7 +455,7 @@ static int dsa_switch_fdb_add(struct dsa_switch *ds,
static int dsa_switch_fdb_del(struct dsa_switch *ds, static int dsa_switch_fdb_del(struct dsa_switch *ds,
struct dsa_notifier_fdb_info *info) struct dsa_notifier_fdb_info *info)
{ {
int port = dsa_towards_port(ds, info->sw_index, info->port); int port = dsa_towards_port(ds, info->dp->ds->index, info->dp->index);
struct dsa_port *dp = dsa_to_port(ds, port); struct dsa_port *dp = dsa_to_port(ds, port);
if (!ds->ops->port_fdb_del) if (!ds->ops->port_fdb_del)
...@@ -512,12 +503,12 @@ static int dsa_switch_lag_fdb_del(struct dsa_switch *ds, ...@@ -512,12 +503,12 @@ static int dsa_switch_lag_fdb_del(struct dsa_switch *ds,
static int dsa_switch_lag_change(struct dsa_switch *ds, static int dsa_switch_lag_change(struct dsa_switch *ds,
struct dsa_notifier_lag_info *info) struct dsa_notifier_lag_info *info)
{ {
if (ds->index == info->sw_index && ds->ops->port_lag_change) if (info->dp->ds == ds && ds->ops->port_lag_change)
return ds->ops->port_lag_change(ds, info->port); return ds->ops->port_lag_change(ds, info->dp->index);
if (ds->index != info->sw_index && ds->ops->crosschip_lag_change) if (info->dp->ds != ds && ds->ops->crosschip_lag_change)
return ds->ops->crosschip_lag_change(ds, info->sw_index, return ds->ops->crosschip_lag_change(ds, info->dp->ds->index,
info->port); info->dp->index);
return 0; return 0;
} }
...@@ -525,13 +516,13 @@ static int dsa_switch_lag_change(struct dsa_switch *ds, ...@@ -525,13 +516,13 @@ static int dsa_switch_lag_change(struct dsa_switch *ds,
static int dsa_switch_lag_join(struct dsa_switch *ds, static int dsa_switch_lag_join(struct dsa_switch *ds,
struct dsa_notifier_lag_info *info) struct dsa_notifier_lag_info *info)
{ {
if (ds->index == info->sw_index && ds->ops->port_lag_join) if (info->dp->ds == ds && ds->ops->port_lag_join)
return ds->ops->port_lag_join(ds, info->port, info->lag, return ds->ops->port_lag_join(ds, info->dp->index, info->lag,
info->info); info->info);
if (ds->index != info->sw_index && ds->ops->crosschip_lag_join) if (info->dp->ds != ds && ds->ops->crosschip_lag_join)
return ds->ops->crosschip_lag_join(ds, info->sw_index, return ds->ops->crosschip_lag_join(ds, info->dp->ds->index,
info->port, info->lag, info->dp->index, info->lag,
info->info); info->info);
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -540,12 +531,12 @@ static int dsa_switch_lag_join(struct dsa_switch *ds, ...@@ -540,12 +531,12 @@ static int dsa_switch_lag_join(struct dsa_switch *ds,
static int dsa_switch_lag_leave(struct dsa_switch *ds, static int dsa_switch_lag_leave(struct dsa_switch *ds,
struct dsa_notifier_lag_info *info) struct dsa_notifier_lag_info *info)
{ {
if (ds->index == info->sw_index && ds->ops->port_lag_leave) if (info->dp->ds == ds && ds->ops->port_lag_leave)
return ds->ops->port_lag_leave(ds, info->port, info->lag); return ds->ops->port_lag_leave(ds, info->dp->index, info->lag);
if (ds->index != info->sw_index && ds->ops->crosschip_lag_leave) if (info->dp->ds != ds && ds->ops->crosschip_lag_leave)
return ds->ops->crosschip_lag_leave(ds, info->sw_index, return ds->ops->crosschip_lag_leave(ds, info->dp->ds->index,
info->port, info->lag); info->dp->index, info->lag);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -553,7 +544,7 @@ static int dsa_switch_lag_leave(struct dsa_switch *ds, ...@@ -553,7 +544,7 @@ static int dsa_switch_lag_leave(struct dsa_switch *ds,
static int dsa_switch_mdb_add(struct dsa_switch *ds, static int dsa_switch_mdb_add(struct dsa_switch *ds,
struct dsa_notifier_mdb_info *info) struct dsa_notifier_mdb_info *info)
{ {
int port = dsa_towards_port(ds, info->sw_index, info->port); int port = dsa_towards_port(ds, info->dp->ds->index, info->dp->index);
struct dsa_port *dp = dsa_to_port(ds, port); struct dsa_port *dp = dsa_to_port(ds, port);
if (!ds->ops->port_mdb_add) if (!ds->ops->port_mdb_add)
...@@ -565,7 +556,7 @@ static int dsa_switch_mdb_add(struct dsa_switch *ds, ...@@ -565,7 +556,7 @@ static int dsa_switch_mdb_add(struct dsa_switch *ds,
static int dsa_switch_mdb_del(struct dsa_switch *ds, static int dsa_switch_mdb_del(struct dsa_switch *ds,
struct dsa_notifier_mdb_info *info) struct dsa_notifier_mdb_info *info)
{ {
int port = dsa_towards_port(ds, info->sw_index, info->port); int port = dsa_towards_port(ds, info->dp->ds->index, info->dp->index);
struct dsa_port *dp = dsa_to_port(ds, port); struct dsa_port *dp = dsa_to_port(ds, port);
if (!ds->ops->port_mdb_del) if (!ds->ops->port_mdb_del)
...@@ -584,8 +575,7 @@ static int dsa_switch_host_mdb_add(struct dsa_switch *ds, ...@@ -584,8 +575,7 @@ static int dsa_switch_host_mdb_add(struct dsa_switch *ds,
return -EOPNOTSUPP; return -EOPNOTSUPP;
dsa_switch_for_each_port(dp, ds) { dsa_switch_for_each_port(dp, ds) {
if (dsa_port_host_address_match(dp, info->sw_index, if (dsa_port_host_address_match(dp, info->dp)) {
info->port)) {
err = dsa_port_do_mdb_add(dp, info->mdb, info->db); err = dsa_port_do_mdb_add(dp, info->mdb, info->db);
if (err) if (err)
break; break;
...@@ -605,8 +595,7 @@ static int dsa_switch_host_mdb_del(struct dsa_switch *ds, ...@@ -605,8 +595,7 @@ static int dsa_switch_host_mdb_del(struct dsa_switch *ds,
return -EOPNOTSUPP; return -EOPNOTSUPP;
dsa_switch_for_each_port(dp, ds) { dsa_switch_for_each_port(dp, ds) {
if (dsa_port_host_address_match(dp, info->sw_index, if (dsa_port_host_address_match(dp, info->dp)) {
info->port)) {
err = dsa_port_do_mdb_del(dp, info->mdb, info->db); err = dsa_port_do_mdb_del(dp, info->mdb, info->db);
if (err) if (err)
break; break;
...@@ -620,29 +609,18 @@ static int dsa_switch_host_mdb_del(struct dsa_switch *ds, ...@@ -620,29 +609,18 @@ static int dsa_switch_host_mdb_del(struct dsa_switch *ds,
static bool dsa_port_vlan_match(struct dsa_port *dp, static bool dsa_port_vlan_match(struct dsa_port *dp,
struct dsa_notifier_vlan_info *info) struct dsa_notifier_vlan_info *info)
{ {
if (dp->ds->index == info->sw_index && dp->index == info->port) return dsa_port_is_dsa(dp) || dp == info->dp;
return true;
if (dsa_port_is_dsa(dp))
return true;
return false;
} }
/* Host VLANs match on the targeted port's CPU port, and on all DSA ports /* Host VLANs match on the targeted port's CPU port, and on all DSA ports
* (upstream and downstream) of that switch and its upstream switches. * (upstream and downstream) of that switch and its upstream switches.
*/ */
static bool dsa_port_host_vlan_match(struct dsa_port *dp, static bool dsa_port_host_vlan_match(struct dsa_port *dp,
struct dsa_notifier_vlan_info *info) const struct dsa_port *targeted_dp)
{ {
struct dsa_port *targeted_dp, *cpu_dp; struct dsa_port *cpu_dp = targeted_dp->cpu_dp;
struct dsa_switch *targeted_ds;
targeted_ds = dsa_switch_find(dp->ds->dst->index, info->sw_index);
targeted_dp = dsa_to_port(targeted_ds, info->port);
cpu_dp = targeted_dp->cpu_dp;
if (dsa_switch_is_upstream_of(dp->ds, targeted_ds)) if (dsa_switch_is_upstream_of(dp->ds, targeted_dp->ds))
return dsa_port_is_dsa(dp) || dp == cpu_dp; return dsa_port_is_dsa(dp) || dp == cpu_dp;
return false; return false;
...@@ -800,7 +778,7 @@ static int dsa_switch_host_vlan_add(struct dsa_switch *ds, ...@@ -800,7 +778,7 @@ static int dsa_switch_host_vlan_add(struct dsa_switch *ds,
return -EOPNOTSUPP; return -EOPNOTSUPP;
dsa_switch_for_each_port(dp, ds) { dsa_switch_for_each_port(dp, ds) {
if (dsa_port_host_vlan_match(dp, info)) { if (dsa_port_host_vlan_match(dp, info->dp)) {
err = dsa_port_do_vlan_add(dp, info->vlan, err = dsa_port_do_vlan_add(dp, info->vlan,
info->extack); info->extack);
if (err) if (err)
...@@ -821,7 +799,7 @@ static int dsa_switch_host_vlan_del(struct dsa_switch *ds, ...@@ -821,7 +799,7 @@ static int dsa_switch_host_vlan_del(struct dsa_switch *ds,
return -EOPNOTSUPP; return -EOPNOTSUPP;
dsa_switch_for_each_port(dp, ds) { dsa_switch_for_each_port(dp, ds) {
if (dsa_port_host_vlan_match(dp, info)) { if (dsa_port_host_vlan_match(dp, info->dp)) {
err = dsa_port_do_vlan_del(dp, info->vlan); err = dsa_port_do_vlan_del(dp, info->vlan);
if (err) if (err)
return err; return err;
......
...@@ -196,15 +196,7 @@ static bool ...@@ -196,15 +196,7 @@ static bool
dsa_port_tag_8021q_vlan_match(struct dsa_port *dp, dsa_port_tag_8021q_vlan_match(struct dsa_port *dp,
struct dsa_notifier_tag_8021q_vlan_info *info) struct dsa_notifier_tag_8021q_vlan_info *info)
{ {
struct dsa_switch *ds = dp->ds; return dsa_port_is_dsa(dp) || dsa_port_is_cpu(dp) || dp == info->dp;
if (dsa_port_is_dsa(dp) || dsa_port_is_cpu(dp))
return true;
if (ds->dst->index == info->tree_index && ds->index == info->sw_index)
return dp->index == info->port;
return false;
} }
int dsa_switch_tag_8021q_vlan_add(struct dsa_switch *ds, int dsa_switch_tag_8021q_vlan_add(struct dsa_switch *ds,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment