Skip to content

Commit

Permalink
net: dsa: Remove switchdev dependency from DSA switch notifier chain
Browse files Browse the repository at this point in the history
Currently, the switchdev objects are embedded inside the DSA notifier
info. This patch removes this dependency. This is done as a preparation
stage before adding support for learning FDB through the switchdev
notification chain.

Signed-off-by: Arkadi Sharshevsky <arkadis@mellanox.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Arkadi Sharshevsky authored and davem330 committed Aug 7, 2017
1 parent 1b6dd55 commit 2acf4e6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 20 deletions.
11 changes: 6 additions & 5 deletions net/dsa/dsa_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ struct dsa_notifier_bridge_info {

/* DSA_NOTIFIER_FDB_* */
struct dsa_notifier_fdb_info {
const struct switchdev_obj_port_fdb *fdb;
int sw_index;
int port;
const unsigned char *addr;
u16 vid;
};

/* DSA_NOTIFIER_MDB_* */
Expand Down Expand Up @@ -120,10 +121,10 @@ int dsa_port_vlan_filtering(struct dsa_port *dp, bool vlan_filtering,
struct switchdev_trans *trans);
int dsa_port_ageing_time(struct dsa_port *dp, clock_t ageing_clock,
struct switchdev_trans *trans);
int dsa_port_fdb_add(struct dsa_port *dp,
const struct switchdev_obj_port_fdb *fdb);
int dsa_port_fdb_del(struct dsa_port *dp,
const struct switchdev_obj_port_fdb *fdb);
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);
int dsa_port_fdb_dump(struct dsa_port *dp, struct switchdev_obj_port_fdb *fdb,
switchdev_obj_dump_cb_t *cb);
int dsa_port_mdb_add(struct dsa_port *dp,
Expand Down
15 changes: 9 additions & 6 deletions net/dsa/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,25 +146,28 @@ int dsa_port_ageing_time(struct dsa_port *dp, clock_t ageing_clock,
return dsa_port_notify(dp, DSA_NOTIFIER_AGEING_TIME, &info);
}

int dsa_port_fdb_add(struct dsa_port *dp,
const struct switchdev_obj_port_fdb *fdb)
int dsa_port_fdb_add(struct dsa_port *dp, const unsigned char *addr,
u16 vid)
{
struct dsa_notifier_fdb_info info = {
.sw_index = dp->ds->index,
.port = dp->index,
.fdb = fdb,
.addr = addr,
.vid = vid,
};

return dsa_port_notify(dp, DSA_NOTIFIER_FDB_ADD, &info);
}

int dsa_port_fdb_del(struct dsa_port *dp,
const struct switchdev_obj_port_fdb *fdb)
int dsa_port_fdb_del(struct dsa_port *dp, const unsigned char *addr,
u16 vid)
{
struct dsa_notifier_fdb_info info = {
.sw_index = dp->ds->index,
.port = dp->index,
.fdb = fdb,
.addr = addr,
.vid = vid,

};

return dsa_port_notify(dp, DSA_NOTIFIER_FDB_DEL, &info);
Expand Down
6 changes: 4 additions & 2 deletions net/dsa/slave.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ static int dsa_slave_port_obj_add(struct net_device *dev,
case SWITCHDEV_OBJ_ID_PORT_FDB:
if (switchdev_trans_ph_prepare(trans))
return 0;
err = dsa_port_fdb_add(dp, SWITCHDEV_OBJ_PORT_FDB(obj));
err = dsa_port_fdb_add(dp, SWITCHDEV_OBJ_PORT_FDB(obj)->addr,
SWITCHDEV_OBJ_PORT_FDB(obj)->vid);
break;
case SWITCHDEV_OBJ_ID_PORT_MDB:
err = dsa_port_mdb_add(dp, SWITCHDEV_OBJ_PORT_MDB(obj), trans);
Expand All @@ -279,7 +280,8 @@ static int dsa_slave_port_obj_del(struct net_device *dev,

switch (obj->id) {
case SWITCHDEV_OBJ_ID_PORT_FDB:
err = dsa_port_fdb_del(dp, SWITCHDEV_OBJ_PORT_FDB(obj));
err = dsa_port_fdb_del(dp, SWITCHDEV_OBJ_PORT_FDB(obj)->addr,
SWITCHDEV_OBJ_PORT_FDB(obj)->vid);
break;
case SWITCHDEV_OBJ_ID_PORT_MDB:
err = dsa_port_mdb_del(dp, SWITCHDEV_OBJ_PORT_MDB(obj));
Expand Down
11 changes: 4 additions & 7 deletions net/dsa/switch.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,32 +83,29 @@ static int dsa_switch_bridge_leave(struct dsa_switch *ds,
static int dsa_switch_fdb_add(struct dsa_switch *ds,
struct dsa_notifier_fdb_info *info)
{
const struct switchdev_obj_port_fdb *fdb = info->fdb;

/* Do not care yet about other switch chips of the fabric */
if (ds->index != info->sw_index)
return 0;

if (!ds->ops->port_fdb_add)
return -EOPNOTSUPP;

return ds->ops->port_fdb_add(ds, info->port, fdb->addr, fdb->vid);
return ds->ops->port_fdb_add(ds, info->port, info->addr,
info->vid);
}

static int dsa_switch_fdb_del(struct dsa_switch *ds,
struct dsa_notifier_fdb_info *info)
{
const struct switchdev_obj_port_fdb *fdb = info->fdb;

/* Do not care yet about other switch chips of the fabric */
if (ds->index != info->sw_index)
return 0;

if (!ds->ops->port_fdb_del)
return -EOPNOTSUPP;

return ds->ops->port_fdb_del(ds, info->port, fdb->addr,
fdb->vid);
return ds->ops->port_fdb_del(ds, info->port, info->addr,
info->vid);
}

static int dsa_switch_mdb_add(struct dsa_switch *ds,
Expand Down

0 comments on commit 2acf4e6

Please sign in to comment.