[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220818154911.2973417-11-vladimir.oltean@nxp.com>
Date: Thu, 18 Aug 2022 18:49:11 +0300
From: Vladimir Oltean <vladimir.oltean@....com>
To: netdev@...r.kernel.org
Cc: Andrew Lunn <andrew@...n.ch>,
Vivien Didelot <vivien.didelot@...il.com>,
Florian Fainelli <f.fainelli@...il.com>,
Vladimir Oltean <olteanv@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Kevin Hilman <khilman@...nel.org>,
Ulf Hansson <ulf.hansson@...aro.org>,
Len Brown <len.brown@...el.com>, Pavel Machek <pavel@....cz>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Subject: [RFC PATCH net-next 10/10] net: dsa: make _del variants of functions return void
Now that we suppress return codes from the cross-chip notifier layer
where we don't have anything sane to do, we can propagate the prototype
chain to void one layer higher, which is to the netdev notifiers and
switchdev notifiers.
Signed-off-by: Vladimir Oltean <vladimir.oltean@....com>
---
net/dsa/dsa_priv.h | 44 ++++++++++----------
net/dsa/port.c | 101 +++++++++++++++++----------------------------
net/dsa/slave.c | 74 ++++++++++++---------------------
3 files changed, 86 insertions(+), 133 deletions(-)
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index 263a07152b07..75aa1bcc432b 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -235,33 +235,33 @@ void dsa_port_mtu_change(struct dsa_port *dp, int new_mtu);
int dsa_port_mtu_change_robust(struct dsa_port *dp, int new_mtu, int old_mtu);
int dsa_port_fdb_add(struct dsa_port *dp, const unsigned char *addr,
u16 vid);
-int dsa_port_fdb_del(struct dsa_port *dp, const unsigned char *addr,
- u16 vid);
+void dsa_port_fdb_del(struct dsa_port *dp, const unsigned char *addr,
+ u16 vid);
int dsa_port_standalone_host_fdb_add(struct dsa_port *dp,
const unsigned char *addr, u16 vid);
-int dsa_port_standalone_host_fdb_del(struct dsa_port *dp,
- const unsigned char *addr, u16 vid);
+void dsa_port_standalone_host_fdb_del(struct dsa_port *dp,
+ const unsigned char *addr, u16 vid);
int dsa_port_bridge_host_fdb_add(struct dsa_port *dp, const unsigned char *addr,
u16 vid);
-int dsa_port_bridge_host_fdb_del(struct dsa_port *dp, const unsigned char *addr,
- u16 vid);
+void dsa_port_bridge_host_fdb_del(struct dsa_port *dp, const unsigned char *addr,
+ u16 vid);
int dsa_port_lag_fdb_add(struct dsa_port *dp, const unsigned char *addr,
u16 vid);
-int dsa_port_lag_fdb_del(struct dsa_port *dp, const unsigned char *addr,
- u16 vid);
+void dsa_port_lag_fdb_del(struct dsa_port *dp, const unsigned char *addr,
+ u16 vid);
int dsa_port_fdb_dump(struct dsa_port *dp, dsa_fdb_dump_cb_t *cb, void *data);
int dsa_port_mdb_add(const struct dsa_port *dp,
const struct switchdev_obj_port_mdb *mdb);
-int dsa_port_mdb_del(const struct dsa_port *dp,
- const struct switchdev_obj_port_mdb *mdb);
+void dsa_port_mdb_del(const struct dsa_port *dp,
+ const struct switchdev_obj_port_mdb *mdb);
int dsa_port_standalone_host_mdb_add(const struct dsa_port *dp,
const struct switchdev_obj_port_mdb *mdb);
-int dsa_port_standalone_host_mdb_del(const struct dsa_port *dp,
- const struct switchdev_obj_port_mdb *mdb);
+void dsa_port_standalone_host_mdb_del(const struct dsa_port *dp,
+ const struct switchdev_obj_port_mdb *mdb);
int dsa_port_bridge_host_mdb_add(const struct dsa_port *dp,
const struct switchdev_obj_port_mdb *mdb);
-int dsa_port_bridge_host_mdb_del(const struct dsa_port *dp,
- const struct switchdev_obj_port_mdb *mdb);
+void dsa_port_bridge_host_mdb_del(const struct dsa_port *dp,
+ const struct switchdev_obj_port_mdb *mdb);
int dsa_port_pre_bridge_flags(const struct dsa_port *dp,
struct switchdev_brport_flags flags,
struct netlink_ext_ack *extack);
@@ -271,21 +271,21 @@ int dsa_port_bridge_flags(struct dsa_port *dp,
int dsa_port_vlan_add(struct dsa_port *dp,
const struct switchdev_obj_port_vlan *vlan,
struct netlink_ext_ack *extack);
-int dsa_port_vlan_del(struct dsa_port *dp,
- const struct switchdev_obj_port_vlan *vlan);
+void dsa_port_vlan_del(struct dsa_port *dp,
+ const struct switchdev_obj_port_vlan *vlan);
int dsa_port_host_vlan_add(struct dsa_port *dp,
const struct switchdev_obj_port_vlan *vlan,
struct netlink_ext_ack *extack);
-int dsa_port_host_vlan_del(struct dsa_port *dp,
- const struct switchdev_obj_port_vlan *vlan);
+void dsa_port_host_vlan_del(struct dsa_port *dp,
+ const struct switchdev_obj_port_vlan *vlan);
int dsa_port_mrp_add(const struct dsa_port *dp,
const struct switchdev_obj_mrp *mrp);
-int dsa_port_mrp_del(const struct dsa_port *dp,
- const struct switchdev_obj_mrp *mrp);
+void dsa_port_mrp_del(const struct dsa_port *dp,
+ const struct switchdev_obj_mrp *mrp);
int dsa_port_mrp_add_ring_role(const struct dsa_port *dp,
const struct switchdev_obj_ring_role_mrp *mrp);
-int dsa_port_mrp_del_ring_role(const struct dsa_port *dp,
- const struct switchdev_obj_ring_role_mrp *mrp);
+void dsa_port_mrp_del_ring_role(const struct dsa_port *dp,
+ const struct switchdev_obj_ring_role_mrp *mrp);
int dsa_port_phylink_create(struct dsa_port *dp);
int dsa_port_link_register_of(struct dsa_port *dp);
void dsa_port_link_unregister_of(struct dsa_port *dp);
diff --git a/net/dsa/port.c b/net/dsa/port.c
index 1452f818263a..8ad9261a074e 100644
--- a/net/dsa/port.c
+++ b/net/dsa/port.c
@@ -1003,8 +1003,8 @@ int dsa_port_fdb_add(struct dsa_port *dp, const unsigned char *addr,
DSA_NOTIFIER_FDB_DEL, &info);
}
-int dsa_port_fdb_del(struct dsa_port *dp, const unsigned char *addr,
- u16 vid)
+void dsa_port_fdb_del(struct dsa_port *dp, const unsigned char *addr,
+ u16 vid)
{
struct dsa_notifier_fdb_info info = {
.dp = dp,
@@ -1020,8 +1020,6 @@ int dsa_port_fdb_del(struct dsa_port *dp, const unsigned char *addr,
info.db.bridge.num = 0;
dsa_port_notify(dp, DSA_NOTIFIER_FDB_DEL, &info);
-
- return 0;
}
static int dsa_port_host_fdb_add(struct dsa_port *dp,
@@ -1076,9 +1074,9 @@ int dsa_port_bridge_host_fdb_add(struct dsa_port *dp,
return dsa_port_host_fdb_add(dp, addr, vid, db);
}
-static int dsa_port_host_fdb_del(struct dsa_port *dp,
- const unsigned char *addr, u16 vid,
- struct dsa_db db)
+static void dsa_port_host_fdb_del(struct dsa_port *dp,
+ const unsigned char *addr, u16 vid,
+ struct dsa_db db)
{
struct dsa_notifier_fdb_info info = {
.dp = dp,
@@ -1091,38 +1089,32 @@ static int dsa_port_host_fdb_del(struct dsa_port *dp,
info.db.bridge.num = 0;
dsa_port_notify(dp, DSA_NOTIFIER_HOST_FDB_DEL, &info);
-
- return 0;
}
-int dsa_port_standalone_host_fdb_del(struct dsa_port *dp,
- const unsigned char *addr, u16 vid)
+void dsa_port_standalone_host_fdb_del(struct dsa_port *dp,
+ const unsigned char *addr, u16 vid)
{
struct dsa_db db = {
.type = DSA_DB_PORT,
.dp = dp,
};
- return dsa_port_host_fdb_del(dp, addr, vid, db);
+ dsa_port_host_fdb_del(dp, addr, vid, db);
}
-int dsa_port_bridge_host_fdb_del(struct dsa_port *dp,
- const unsigned char *addr, u16 vid)
+void dsa_port_bridge_host_fdb_del(struct dsa_port *dp,
+ const unsigned char *addr, u16 vid)
{
struct dsa_port *cpu_dp = dp->cpu_dp;
struct dsa_db db = {
.type = DSA_DB_BRIDGE,
.bridge = *dp->bridge,
};
- int err;
- if (cpu_dp->master->priv_flags & IFF_UNICAST_FLT) {
- err = dev_uc_del(cpu_dp->master, addr);
- if (err)
- return err;
- }
+ if (cpu_dp->master->priv_flags & IFF_UNICAST_FLT)
+ dev_uc_del(cpu_dp->master, addr);
- return dsa_port_host_fdb_del(dp, addr, vid, db);
+ dsa_port_host_fdb_del(dp, addr, vid, db);
}
int dsa_port_lag_fdb_add(struct dsa_port *dp, const unsigned char *addr,
@@ -1145,8 +1137,8 @@ int dsa_port_lag_fdb_add(struct dsa_port *dp, const unsigned char *addr,
DSA_NOTIFIER_LAG_FDB_DEL, &info);
}
-int dsa_port_lag_fdb_del(struct dsa_port *dp, const unsigned char *addr,
- u16 vid)
+void dsa_port_lag_fdb_del(struct dsa_port *dp, const unsigned char *addr,
+ u16 vid)
{
struct dsa_notifier_lag_fdb_info info = {
.lag = dp->lag,
@@ -1162,8 +1154,6 @@ int dsa_port_lag_fdb_del(struct dsa_port *dp, const unsigned char *addr,
info.db.bridge.num = 0;
dsa_port_notify(dp, DSA_NOTIFIER_LAG_FDB_DEL, &info);
-
- return 0;
}
int dsa_port_fdb_dump(struct dsa_port *dp, dsa_fdb_dump_cb_t *cb, void *data)
@@ -1196,8 +1186,8 @@ int dsa_port_mdb_add(const struct dsa_port *dp,
DSA_NOTIFIER_MDB_DEL, &info);
}
-int dsa_port_mdb_del(const struct dsa_port *dp,
- const struct switchdev_obj_port_mdb *mdb)
+void dsa_port_mdb_del(const struct dsa_port *dp,
+ const struct switchdev_obj_port_mdb *mdb)
{
struct dsa_notifier_mdb_info info = {
.dp = dp,
@@ -1212,8 +1202,6 @@ int dsa_port_mdb_del(const struct dsa_port *dp,
info.db.bridge.num = 0;
dsa_port_notify(dp, DSA_NOTIFIER_MDB_DEL, &info);
-
- return 0;
}
static int dsa_port_host_mdb_add(const struct dsa_port *dp,
@@ -1261,9 +1249,9 @@ int dsa_port_bridge_host_mdb_add(const struct dsa_port *dp,
return dsa_port_host_mdb_add(dp, mdb, db);
}
-static int dsa_port_host_mdb_del(const struct dsa_port *dp,
- const struct switchdev_obj_port_mdb *mdb,
- struct dsa_db db)
+static void dsa_port_host_mdb_del(const struct dsa_port *dp,
+ const struct switchdev_obj_port_mdb *mdb,
+ struct dsa_db db)
{
struct dsa_notifier_mdb_info info = {
.dp = dp,
@@ -1275,36 +1263,31 @@ static int dsa_port_host_mdb_del(const struct dsa_port *dp,
info.db.bridge.num = 0;
dsa_port_notify(dp, DSA_NOTIFIER_HOST_MDB_DEL, &info);
-
- return 0;
}
-int dsa_port_standalone_host_mdb_del(const struct dsa_port *dp,
- const struct switchdev_obj_port_mdb *mdb)
+void dsa_port_standalone_host_mdb_del(const struct dsa_port *dp,
+ const struct switchdev_obj_port_mdb *mdb)
{
struct dsa_db db = {
.type = DSA_DB_PORT,
.dp = dp,
};
- return dsa_port_host_mdb_del(dp, mdb, db);
+ dsa_port_host_mdb_del(dp, mdb, db);
}
-int dsa_port_bridge_host_mdb_del(const struct dsa_port *dp,
- const struct switchdev_obj_port_mdb *mdb)
+void dsa_port_bridge_host_mdb_del(const struct dsa_port *dp,
+ const struct switchdev_obj_port_mdb *mdb)
{
struct dsa_port *cpu_dp = dp->cpu_dp;
struct dsa_db db = {
.type = DSA_DB_BRIDGE,
.bridge = *dp->bridge,
};
- int err;
- err = dev_mc_del(cpu_dp->master, mdb->addr);
- if (err)
- return err;
+ dev_mc_del(cpu_dp->master, mdb->addr);
- return dsa_port_host_mdb_del(dp, mdb, db);
+ dsa_port_host_mdb_del(dp, mdb, db);
}
int dsa_port_vlan_add(struct dsa_port *dp,
@@ -1321,8 +1304,8 @@ int dsa_port_vlan_add(struct dsa_port *dp,
DSA_NOTIFIER_VLAN_DEL, &info);
}
-int dsa_port_vlan_del(struct dsa_port *dp,
- const struct switchdev_obj_port_vlan *vlan)
+void dsa_port_vlan_del(struct dsa_port *dp,
+ const struct switchdev_obj_port_vlan *vlan)
{
struct dsa_notifier_vlan_info info = {
.dp = dp,
@@ -1330,8 +1313,6 @@ int dsa_port_vlan_del(struct dsa_port *dp,
};
dsa_port_notify(dp, DSA_NOTIFIER_VLAN_DEL, &info);
-
- return 0;
}
int dsa_port_host_vlan_add(struct dsa_port *dp,
@@ -1356,8 +1337,8 @@ int dsa_port_host_vlan_add(struct dsa_port *dp,
return err;
}
-int dsa_port_host_vlan_del(struct dsa_port *dp,
- const struct switchdev_obj_port_vlan *vlan)
+void dsa_port_host_vlan_del(struct dsa_port *dp,
+ const struct switchdev_obj_port_vlan *vlan)
{
struct dsa_notifier_vlan_info info = {
.dp = dp,
@@ -1368,8 +1349,6 @@ int dsa_port_host_vlan_del(struct dsa_port *dp,
dsa_port_notify(dp, DSA_NOTIFIER_HOST_VLAN_DEL, &info);
vlan_vid_del(cpu_dp->master, htons(ETH_P_8021Q), vlan->vid);
-
- return 0;
}
int dsa_port_mrp_add(const struct dsa_port *dp,
@@ -1383,15 +1362,13 @@ int dsa_port_mrp_add(const struct dsa_port *dp,
return ds->ops->port_mrp_add(ds, dp->index, mrp);
}
-int dsa_port_mrp_del(const struct dsa_port *dp,
- const struct switchdev_obj_mrp *mrp)
+void dsa_port_mrp_del(const struct dsa_port *dp,
+ const struct switchdev_obj_mrp *mrp)
{
struct dsa_switch *ds = dp->ds;
- if (!ds->ops->port_mrp_del)
- return -EOPNOTSUPP;
-
- return ds->ops->port_mrp_del(ds, dp->index, mrp);
+ if (ds->ops->port_mrp_del)
+ ds->ops->port_mrp_del(ds, dp->index, mrp);
}
int dsa_port_mrp_add_ring_role(const struct dsa_port *dp,
@@ -1405,15 +1382,13 @@ int dsa_port_mrp_add_ring_role(const struct dsa_port *dp,
return ds->ops->port_mrp_add_ring_role(ds, dp->index, mrp);
}
-int dsa_port_mrp_del_ring_role(const struct dsa_port *dp,
- const struct switchdev_obj_ring_role_mrp *mrp)
+void dsa_port_mrp_del_ring_role(const struct dsa_port *dp,
+ const struct switchdev_obj_ring_role_mrp *mrp)
{
struct dsa_switch *ds = dp->ds;
if (!ds->ops->port_mrp_del_ring_role)
- return -EOPNOTSUPP;
-
- return ds->ops->port_mrp_del_ring_role(ds, dp->index, mrp);
+ ds->ops->port_mrp_del_ring_role(ds, dp->index, mrp);
}
void dsa_port_set_tag_protocol(struct dsa_port *cpu_dp,
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 02cc1774888a..776c58a1795b 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -48,14 +48,9 @@ static void dsa_slave_standalone_event_work(struct work_struct *work)
break;
case DSA_UC_DEL:
- err = dsa_port_standalone_host_fdb_del(dp, addr, vid);
- if (err) {
- dev_err(ds->dev,
- "port %d failed to delete %pM vid %d from fdb: %d\n",
- dp->index, addr, vid, err);
- }
-
+ dsa_port_standalone_host_fdb_del(dp, addr, vid);
break;
+
case DSA_MC_ADD:
ether_addr_copy(mdb.addr, addr);
mdb.vid = vid;
@@ -72,13 +67,7 @@ static void dsa_slave_standalone_event_work(struct work_struct *work)
ether_addr_copy(mdb.addr, addr);
mdb.vid = vid;
- err = dsa_port_standalone_host_mdb_del(dp, &mdb);
- if (err) {
- dev_err(ds->dev,
- "port %d failed to delete %pM vid %d from mdb: %d\n",
- dp->index, addr, vid, err);
- }
-
+ dsa_port_standalone_host_mdb_del(dp, &mdb);
break;
}
@@ -636,43 +625,42 @@ static int dsa_slave_port_obj_add(struct net_device *dev, const void *ctx,
return err;
}
-static int dsa_slave_vlan_del(struct net_device *dev,
- const struct switchdev_obj *obj)
+static void dsa_slave_vlan_del(struct net_device *dev,
+ const struct switchdev_obj *obj)
{
struct dsa_port *dp = dsa_slave_to_port(dev);
struct switchdev_obj_port_vlan *vlan;
if (dsa_port_skip_vlan_configuration(dp))
- return 0;
+ return;
vlan = SWITCHDEV_OBJ_PORT_VLAN(obj);
- return dsa_port_vlan_del(dp, vlan);
+ dsa_port_vlan_del(dp, vlan);
}
-static int dsa_slave_host_vlan_del(struct net_device *dev,
- const struct switchdev_obj *obj)
+static void dsa_slave_host_vlan_del(struct net_device *dev,
+ const struct switchdev_obj *obj)
{
struct dsa_port *dp = dsa_slave_to_port(dev);
struct switchdev_obj_port_vlan *vlan;
/* Do nothing if this is a software bridge */
if (!dp->bridge)
- return -EOPNOTSUPP;
+ return;
if (dsa_port_skip_vlan_configuration(dp))
- return 0;
+ return;
vlan = SWITCHDEV_OBJ_PORT_VLAN(obj);
- return dsa_port_host_vlan_del(dp, vlan);
+ dsa_port_host_vlan_del(dp, vlan);
}
static int dsa_slave_port_obj_del(struct net_device *dev, const void *ctx,
const struct switchdev_obj *obj)
{
struct dsa_port *dp = dsa_slave_to_port(dev);
- int err;
if (ctx && ctx != dp)
return 0;
@@ -682,39 +670,37 @@ static int dsa_slave_port_obj_del(struct net_device *dev, const void *ctx,
if (!dsa_port_offloads_bridge_port(dp, obj->orig_dev))
return -EOPNOTSUPP;
- err = dsa_port_mdb_del(dp, SWITCHDEV_OBJ_PORT_MDB(obj));
+ dsa_port_mdb_del(dp, SWITCHDEV_OBJ_PORT_MDB(obj));
break;
case SWITCHDEV_OBJ_ID_HOST_MDB:
if (!dsa_port_offloads_bridge_dev(dp, obj->orig_dev))
return -EOPNOTSUPP;
- err = dsa_port_bridge_host_mdb_del(dp, SWITCHDEV_OBJ_PORT_MDB(obj));
+ dsa_port_bridge_host_mdb_del(dp, SWITCHDEV_OBJ_PORT_MDB(obj));
break;
case SWITCHDEV_OBJ_ID_PORT_VLAN:
if (dsa_port_offloads_bridge_port(dp, obj->orig_dev))
- err = dsa_slave_vlan_del(dev, obj);
+ dsa_slave_vlan_del(dev, obj);
else
- err = dsa_slave_host_vlan_del(dev, obj);
+ dsa_slave_host_vlan_del(dev, obj);
break;
case SWITCHDEV_OBJ_ID_MRP:
if (!dsa_port_offloads_bridge_dev(dp, obj->orig_dev))
return -EOPNOTSUPP;
- err = dsa_port_mrp_del(dp, SWITCHDEV_OBJ_MRP(obj));
+ dsa_port_mrp_del(dp, SWITCHDEV_OBJ_MRP(obj));
break;
case SWITCHDEV_OBJ_ID_RING_ROLE_MRP:
if (!dsa_port_offloads_bridge_dev(dp, obj->orig_dev))
return -EOPNOTSUPP;
- err = dsa_port_mrp_del_ring_role(dp,
- SWITCHDEV_OBJ_RING_ROLE_MRP(obj));
+ dsa_port_mrp_del_ring_role(dp, SWITCHDEV_OBJ_RING_ROLE_MRP(obj));
break;
default:
- err = -EOPNOTSUPP;
- break;
+ return -EOPNOTSUPP;
}
- return err;
+ return 0;
}
static inline netdev_tx_t dsa_slave_netpoll_send_skb(struct net_device *dev,
@@ -1611,13 +1597,11 @@ static int dsa_slave_vlan_rx_kill_vid(struct net_device *dev, __be16 proto,
/* This API only allows programming tagged, non-PVID VIDs */
.flags = 0,
};
- int err;
- err = dsa_port_vlan_del(dp, &vlan);
- if (err)
- return err;
+ dsa_port_vlan_del(dp, &vlan);
+ dsa_port_host_vlan_del(dp, &vlan);
- return dsa_port_host_vlan_del(dp, &vlan);
+ return 0;
}
static int dsa_slave_restore_vlan(struct net_device *vdev, int vid, void *arg)
@@ -2837,17 +2821,11 @@ static void dsa_slave_switchdev_event_work(struct work_struct *work)
case SWITCHDEV_FDB_DEL_TO_DEVICE:
if (switchdev_work->host_addr)
- err = dsa_port_bridge_host_fdb_del(dp, addr, vid);
+ dsa_port_bridge_host_fdb_del(dp, addr, vid);
else if (dp->lag)
- err = dsa_port_lag_fdb_del(dp, addr, vid);
+ dsa_port_lag_fdb_del(dp, addr, vid);
else
- err = dsa_port_fdb_del(dp, addr, vid);
- if (err) {
- dev_err(ds->dev,
- "port %d failed to delete %pM vid %d from fdb: %d\n",
- dp->index, addr, vid, err);
- }
-
+ dsa_port_fdb_del(dp, addr, vid);
break;
}
--
2.34.1
Powered by blists - more mailing lists