diff options
author | Vivien Didelot <vivien.didelot@savoirfairelinux.com> | 2015-09-29 19:07:16 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-09-30 07:31:59 +0300 |
commit | 25f07adc473f05f850efc9414b9da3374563015f (patch) | |
tree | ff62d9a8e9c63c48abd034b61156c55c6437a36e /net/dsa | |
parent | 03d5fb18626aff95426a380aef0d1c6904cac7c9 (diff) | |
download | linux-25f07adc473f05f850efc9414b9da3374563015f.tar.xz |
net: switchdev: pass callback to dump operation
Similar to the notifier_call callback of a notifier_block, change the
function signature of switchdev dump operation to:
int switchdev_port_obj_dump(struct net_device *dev,
enum switchdev_obj_id id, void *obj,
int (*cb)(void *obj));
This allows the caller to pass and expect back a specific
switchdev_obj_* structure instead of the generic switchdev_obj one.
Drivers implementation of dump operation can now expect this specific
structure and call the callback with it. Drivers have been changed
accordingly.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa')
-rw-r--r-- | net/dsa/slave.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 0b47647961e8..c3b868c3373b 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -300,9 +300,9 @@ static int dsa_slave_port_vlan_del(struct net_device *dev, } static int dsa_slave_port_vlan_dump(struct net_device *dev, - struct switchdev_obj *obj) + struct switchdev_obj_vlan *vlan, + int (*cb)(void *obj)) { - struct switchdev_obj_vlan *vlan = &obj->u.vlan; struct dsa_slave_priv *p = netdev_priv(dev); struct dsa_switch *ds = p->parent; DECLARE_BITMAP(members, DSA_MAX_PORTS); @@ -334,7 +334,7 @@ static int dsa_slave_port_vlan_dump(struct net_device *dev, if (test_bit(p->port, untagged)) vlan->flags |= BRIDGE_VLAN_INFO_UNTAGGED; - err = obj->cb(obj); + err = cb(vlan); if (err) break; } @@ -374,7 +374,8 @@ static int dsa_slave_port_fdb_del(struct net_device *dev, } static int dsa_slave_port_fdb_dump(struct net_device *dev, - struct switchdev_obj *obj) + struct switchdev_obj_fdb *fdb, + int (*cb)(void *obj)) { struct dsa_slave_priv *p = netdev_priv(dev); struct dsa_switch *ds = p->parent; @@ -393,11 +394,11 @@ static int dsa_slave_port_fdb_dump(struct net_device *dev, if (ret < 0) break; - obj->u.fdb.addr = addr; - obj->u.fdb.vid = vid; - obj->u.fdb.ndm_state = is_static ? NUD_NOARP : NUD_REACHABLE; + fdb->addr = addr; + fdb->vid = vid; + fdb->ndm_state = is_static ? NUD_NOARP : NUD_REACHABLE; - ret = obj->cb(obj); + ret = cb(fdb); if (ret < 0) break; } @@ -518,16 +519,17 @@ static int dsa_slave_port_obj_del(struct net_device *dev, } static int dsa_slave_port_obj_dump(struct net_device *dev, - struct switchdev_obj *obj) + enum switchdev_obj_id id, void *obj, + int (*cb)(void *obj)) { int err; - switch (obj->id) { + switch (id) { case SWITCHDEV_OBJ_PORT_FDB: - err = dsa_slave_port_fdb_dump(dev, obj); + err = dsa_slave_port_fdb_dump(dev, obj, cb); break; case SWITCHDEV_OBJ_PORT_VLAN: - err = dsa_slave_port_vlan_dump(dev, obj); + err = dsa_slave_port_vlan_dump(dev, obj, cb); break; default: err = -EOPNOTSUPP; |