Commit 3fdb023b authored by Vivien Didelot's avatar Vivien Didelot Committed by David S. Miller

net: dsa: change scope of FDB handlers

Change the scope of the switchdev FDB object handlers from the DSA slave
device to the generic DSA port, so that the future port-wide API can
also be used for other port types, such as CPU and DSA links.
Signed-off-by: default avatarVivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 17d7802b
...@@ -299,47 +299,44 @@ static int dsa_slave_port_vlan_dump(struct net_device *dev, ...@@ -299,47 +299,44 @@ static int dsa_slave_port_vlan_dump(struct net_device *dev,
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
static int dsa_slave_port_fdb_add(struct net_device *dev, static int dsa_port_fdb_add(struct dsa_port *dp,
const struct switchdev_obj_port_fdb *fdb, const struct switchdev_obj_port_fdb *fdb,
struct switchdev_trans *trans) struct switchdev_trans *trans)
{ {
struct dsa_slave_priv *p = netdev_priv(dev); struct dsa_switch *ds = dp->ds;
struct dsa_switch *ds = p->dp->ds;
if (switchdev_trans_ph_prepare(trans)) { if (switchdev_trans_ph_prepare(trans)) {
if (!ds->ops->port_fdb_prepare || !ds->ops->port_fdb_add) if (!ds->ops->port_fdb_prepare || !ds->ops->port_fdb_add)
return -EOPNOTSUPP; return -EOPNOTSUPP;
return ds->ops->port_fdb_prepare(ds, p->dp->index, fdb, trans); return ds->ops->port_fdb_prepare(ds, dp->index, fdb, trans);
} }
ds->ops->port_fdb_add(ds, p->dp->index, fdb, trans); ds->ops->port_fdb_add(ds, dp->index, fdb, trans);
return 0; return 0;
} }
static int dsa_slave_port_fdb_del(struct net_device *dev, static int dsa_port_fdb_del(struct dsa_port *dp,
const struct switchdev_obj_port_fdb *fdb) const struct switchdev_obj_port_fdb *fdb)
{ {
struct dsa_slave_priv *p = netdev_priv(dev); struct dsa_switch *ds = dp->ds;
struct dsa_switch *ds = p->dp->ds;
int ret = -EOPNOTSUPP; int ret = -EOPNOTSUPP;
if (ds->ops->port_fdb_del) if (ds->ops->port_fdb_del)
ret = ds->ops->port_fdb_del(ds, p->dp->index, fdb); ret = ds->ops->port_fdb_del(ds, dp->index, fdb);
return ret; return ret;
} }
static int dsa_slave_port_fdb_dump(struct net_device *dev, static int dsa_port_fdb_dump(struct dsa_port *dp,
struct switchdev_obj_port_fdb *fdb, struct switchdev_obj_port_fdb *fdb,
switchdev_obj_dump_cb_t *cb) switchdev_obj_dump_cb_t *cb)
{ {
struct dsa_slave_priv *p = netdev_priv(dev); struct dsa_switch *ds = dp->ds;
struct dsa_switch *ds = p->dp->ds;
if (ds->ops->port_fdb_dump) if (ds->ops->port_fdb_dump)
return ds->ops->port_fdb_dump(ds, p->dp->index, fdb, cb); return ds->ops->port_fdb_dump(ds, dp->index, fdb, cb);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -488,6 +485,8 @@ static int dsa_slave_port_obj_add(struct net_device *dev, ...@@ -488,6 +485,8 @@ static int dsa_slave_port_obj_add(struct net_device *dev,
const struct switchdev_obj *obj, const struct switchdev_obj *obj,
struct switchdev_trans *trans) struct switchdev_trans *trans)
{ {
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_port *dp = p->dp;
int err; int err;
/* For the prepare phase, ensure the full set of changes is feasable in /* For the prepare phase, ensure the full set of changes is feasable in
...@@ -497,9 +496,7 @@ static int dsa_slave_port_obj_add(struct net_device *dev, ...@@ -497,9 +496,7 @@ static int dsa_slave_port_obj_add(struct net_device *dev,
switch (obj->id) { switch (obj->id) {
case SWITCHDEV_OBJ_ID_PORT_FDB: case SWITCHDEV_OBJ_ID_PORT_FDB:
err = dsa_slave_port_fdb_add(dev, err = dsa_port_fdb_add(dp, SWITCHDEV_OBJ_PORT_FDB(obj), trans);
SWITCHDEV_OBJ_PORT_FDB(obj),
trans);
break; break;
case SWITCHDEV_OBJ_ID_PORT_MDB: case SWITCHDEV_OBJ_ID_PORT_MDB:
err = dsa_slave_port_mdb_add(dev, SWITCHDEV_OBJ_PORT_MDB(obj), err = dsa_slave_port_mdb_add(dev, SWITCHDEV_OBJ_PORT_MDB(obj),
...@@ -521,12 +518,13 @@ static int dsa_slave_port_obj_add(struct net_device *dev, ...@@ -521,12 +518,13 @@ static int dsa_slave_port_obj_add(struct net_device *dev,
static int dsa_slave_port_obj_del(struct net_device *dev, static int dsa_slave_port_obj_del(struct net_device *dev,
const struct switchdev_obj *obj) const struct switchdev_obj *obj)
{ {
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_port *dp = p->dp;
int err; int err;
switch (obj->id) { switch (obj->id) {
case SWITCHDEV_OBJ_ID_PORT_FDB: case SWITCHDEV_OBJ_ID_PORT_FDB:
err = dsa_slave_port_fdb_del(dev, err = dsa_port_fdb_del(dp, SWITCHDEV_OBJ_PORT_FDB(obj));
SWITCHDEV_OBJ_PORT_FDB(obj));
break; break;
case SWITCHDEV_OBJ_ID_PORT_MDB: case SWITCHDEV_OBJ_ID_PORT_MDB:
err = dsa_slave_port_mdb_del(dev, SWITCHDEV_OBJ_PORT_MDB(obj)); err = dsa_slave_port_mdb_del(dev, SWITCHDEV_OBJ_PORT_MDB(obj));
...@@ -547,13 +545,13 @@ static int dsa_slave_port_obj_dump(struct net_device *dev, ...@@ -547,13 +545,13 @@ static int dsa_slave_port_obj_dump(struct net_device *dev,
struct switchdev_obj *obj, struct switchdev_obj *obj,
switchdev_obj_dump_cb_t *cb) switchdev_obj_dump_cb_t *cb)
{ {
struct dsa_slave_priv *p = netdev_priv(dev);
struct dsa_port *dp = p->dp;
int err; int err;
switch (obj->id) { switch (obj->id) {
case SWITCHDEV_OBJ_ID_PORT_FDB: case SWITCHDEV_OBJ_ID_PORT_FDB:
err = dsa_slave_port_fdb_dump(dev, err = dsa_port_fdb_dump(dp, SWITCHDEV_OBJ_PORT_FDB(obj), cb);
SWITCHDEV_OBJ_PORT_FDB(obj),
cb);
break; break;
case SWITCHDEV_OBJ_ID_PORT_MDB: case SWITCHDEV_OBJ_ID_PORT_MDB:
err = dsa_slave_port_mdb_dump(dev, SWITCHDEV_OBJ_PORT_MDB(obj), err = dsa_slave_port_mdb_dump(dev, SWITCHDEV_OBJ_PORT_MDB(obj),
......
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