* [PATCH v2 net-next 0/6] net: switchdev: use specific switchdev_obj_*
@ 2015-09-29 16:07 Vivien Didelot
2015-09-29 16:07 ` [PATCH v2 net-next 1/6] net: switchdev: remove dev in port_vlan_dump_put Vivien Didelot
` (7 more replies)
0 siblings, 8 replies; 13+ messages in thread
From: Vivien Didelot @ 2015-09-29 16:07 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Scott Feldman, Jiri Pirko,
Florian Fainelli, Andrew Lunn, Vivien Didelot
This patchset changes switchdev add, del, dump operations from this:
int (*switchdev_port_obj_add)(struct net_device *dev,
struct switchdev_obj *obj,
struct switchdev_trans *trans);
int (*switchdev_port_obj_del)(struct net_device *dev,
struct switchdev_obj *obj);
int (*switchdev_port_obj_dump)(struct net_device *dev,
struct switchdev_obj *obj);
to something similar to the notifier_call callback of a notifier_block:
int (*switchdev_port_obj_add)(struct net_device *dev,
enum switchdev_obj_id id,
const void *obj,
struct switchdev_trans *trans);
int (*switchdev_port_obj_del)(struct net_device *dev,
enum switchdev_obj_id id,
const void *obj);
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 (e.g. switchdev_obj_fdb) instead of the generic switchdev_obj one.
This will simplify pushing the callback function down to the drivers.
The first 3 patches get rid of the dev parameter of the dump callback, since it
is not always neeeded (e.g. vlan_dump) and some drivers (such as DSA drivers)
may not have easy access to it.
Patches 4 and 5 implement the change in the switchdev operations and its users.
Patch 6 extracts the inner switchdev_obj_* structures from switchdev_obj and
removes this last one.
v2: fix error spotted by kbuild (extra ';' inline switchdev_port_obj_dump).
Vivien Didelot (6):
net: switchdev: remove dev in port_vlan_dump_put
net: switchdev: move dev in switchdev_fdb_dump
net: switchdev: remove dev from switchdev_obj cb
net: switchdev: pass callback to dump operation
net: switchdev: abstract object in add/del ops
net: switchdev: extract struct switchdev_obj_*
drivers/net/ethernet/rocker/rocker.c | 42 ++++----
include/net/switchdev.h | 80 ++++++++-------
net/bridge/br_fdb.c | 11 +--
net/bridge/br_vlan.c | 24 ++---
net/dsa/slave.c | 46 +++++----
net/switchdev/switchdev.c | 184 ++++++++++++++++-------------------
6 files changed, 186 insertions(+), 201 deletions(-)
--
2.6.0
^ permalink raw reply [flat|nested] 13+ messages in thread* [PATCH v2 net-next 1/6] net: switchdev: remove dev in port_vlan_dump_put 2015-09-29 16:07 [PATCH v2 net-next 0/6] net: switchdev: use specific switchdev_obj_* Vivien Didelot @ 2015-09-29 16:07 ` Vivien Didelot 2015-09-29 16:07 ` [PATCH v2 net-next 2/6] net: switchdev: move dev in switchdev_fdb_dump Vivien Didelot ` (6 subsequent siblings) 7 siblings, 0 replies; 13+ messages in thread From: Vivien Didelot @ 2015-09-29 16:07 UTC (permalink / raw) To: netdev Cc: linux-kernel, kernel, David S. Miller, Scott Feldman, Jiri Pirko, Florian Fainelli, Andrew Lunn, Vivien Didelot The static switchdev_port_vlan_dump_put function does not need the net_device parameter, so remove it. Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> --- net/switchdev/switchdev.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c index 00ee547..56d34ed 100644 --- a/net/switchdev/switchdev.c +++ b/net/switchdev/switchdev.c @@ -484,8 +484,7 @@ struct switchdev_vlan_dump { u16 end; }; -static int switchdev_port_vlan_dump_put(struct net_device *dev, - struct switchdev_vlan_dump *dump) +static int switchdev_port_vlan_dump_put(struct switchdev_vlan_dump *dump) { struct bridge_vlan_info vinfo; @@ -531,7 +530,7 @@ static int switchdev_port_vlan_dump_cb(struct net_device *dev, for (dump->begin = dump->end = vlan->vid_begin; dump->begin <= vlan->vid_end; dump->begin++, dump->end++) { - err = switchdev_port_vlan_dump_put(dev, dump); + err = switchdev_port_vlan_dump_put(dump); if (err) return err; } @@ -543,7 +542,7 @@ static int switchdev_port_vlan_dump_cb(struct net_device *dev, /* prepend */ dump->begin = vlan->vid_begin; } else { - err = switchdev_port_vlan_dump_put(dev, dump); + err = switchdev_port_vlan_dump_put(dump); dump->flags = vlan->flags; dump->begin = vlan->vid_begin; dump->end = vlan->vid_end; @@ -555,7 +554,7 @@ static int switchdev_port_vlan_dump_cb(struct net_device *dev, /* append */ dump->end = vlan->vid_end; } else { - err = switchdev_port_vlan_dump_put(dev, dump); + err = switchdev_port_vlan_dump_put(dump); dump->flags = vlan->flags; dump->begin = vlan->vid_begin; dump->end = vlan->vid_end; @@ -588,7 +587,7 @@ static int switchdev_port_vlan_fill(struct sk_buff *skb, struct net_device *dev, goto err_out; if (filter_mask & RTEXT_FILTER_BRVLAN_COMPRESSED) /* last one */ - err = switchdev_port_vlan_dump_put(dev, &dump); + err = switchdev_port_vlan_dump_put(&dump); } err_out: -- 2.6.0 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 net-next 2/6] net: switchdev: move dev in switchdev_fdb_dump 2015-09-29 16:07 [PATCH v2 net-next 0/6] net: switchdev: use specific switchdev_obj_* Vivien Didelot 2015-09-29 16:07 ` [PATCH v2 net-next 1/6] net: switchdev: remove dev in port_vlan_dump_put Vivien Didelot @ 2015-09-29 16:07 ` Vivien Didelot 2015-09-29 16:07 ` [PATCH v2 net-next 3/6] net: switchdev: remove dev from switchdev_obj cb Vivien Didelot ` (5 subsequent siblings) 7 siblings, 0 replies; 13+ messages in thread From: Vivien Didelot @ 2015-09-29 16:07 UTC (permalink / raw) To: netdev Cc: linux-kernel, kernel, David S. Miller, Scott Feldman, Jiri Pirko, Florian Fainelli, Andrew Lunn, Vivien Didelot The FDB dump callback requires the related net_device so move it to the struct switchdev_fdb_dump superset instead of using a callback param. With this done, it'll be simpler to change the dump function signature. Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> --- net/switchdev/switchdev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c index 56d34ed..c0e2047 100644 --- a/net/switchdev/switchdev.c +++ b/net/switchdev/switchdev.c @@ -858,6 +858,7 @@ EXPORT_SYMBOL_GPL(switchdev_port_fdb_del); struct switchdev_fdb_dump { struct switchdev_obj obj; + struct net_device *dev; struct sk_buff *skb; struct netlink_callback *cb; int idx; @@ -887,7 +888,7 @@ static int switchdev_port_fdb_dump_cb(struct net_device *dev, ndm->ndm_pad2 = 0; ndm->ndm_flags = NTF_SELF; ndm->ndm_type = 0; - ndm->ndm_ifindex = dev->ifindex; + ndm->ndm_ifindex = dump->dev->ifindex; ndm->ndm_state = obj->u.fdb.ndm_state; if (nla_put(dump->skb, NDA_LLADDR, ETH_ALEN, obj->u.fdb.addr)) @@ -927,6 +928,7 @@ int switchdev_port_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb, .id = SWITCHDEV_OBJ_PORT_FDB, .cb = switchdev_port_fdb_dump_cb, }, + .dev = dev, .skb = skb, .cb = cb, .idx = idx, -- 2.6.0 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 net-next 3/6] net: switchdev: remove dev from switchdev_obj cb 2015-09-29 16:07 [PATCH v2 net-next 0/6] net: switchdev: use specific switchdev_obj_* Vivien Didelot 2015-09-29 16:07 ` [PATCH v2 net-next 1/6] net: switchdev: remove dev in port_vlan_dump_put Vivien Didelot 2015-09-29 16:07 ` [PATCH v2 net-next 2/6] net: switchdev: move dev in switchdev_fdb_dump Vivien Didelot @ 2015-09-29 16:07 ` Vivien Didelot 2015-09-29 16:07 ` [PATCH v2 net-next 4/6] net: switchdev: pass callback to dump operation Vivien Didelot ` (4 subsequent siblings) 7 siblings, 0 replies; 13+ messages in thread From: Vivien Didelot @ 2015-09-29 16:07 UTC (permalink / raw) To: netdev Cc: linux-kernel, kernel, David S. Miller, Scott Feldman, Jiri Pirko, Florian Fainelli, Andrew Lunn, Vivien Didelot The net_device associated to a dump operation does not have to be passed to the callback. switchdev stores it in a superset struct, if needed. Also some drivers (such as DSA drivers) may not have easy access to it. This will simplify pushing the callback function down to the drivers. Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> --- drivers/net/ethernet/rocker/rocker.c | 4 ++-- include/net/switchdev.h | 2 +- net/dsa/slave.c | 4 ++-- net/switchdev/switchdev.c | 6 ++---- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/rocker/rocker.c b/drivers/net/ethernet/rocker/rocker.c index d3f6632..78fd443 100644 --- a/drivers/net/ethernet/rocker/rocker.c +++ b/drivers/net/ethernet/rocker/rocker.c @@ -4556,7 +4556,7 @@ static int rocker_port_fdb_dump(const struct rocker_port *rocker_port, fdb->ndm_state = NUD_REACHABLE; fdb->vid = rocker_port_vlan_to_vid(rocker_port, found->key.vlan_id); - err = obj->cb(rocker_port->dev, obj); + err = obj->cb(obj); if (err) break; } @@ -4579,7 +4579,7 @@ static int rocker_port_vlan_dump(const struct rocker_port *rocker_port, if (rocker_vlan_id_is_internal(htons(vid))) vlan->flags |= BRIDGE_VLAN_INFO_PVID; vlan->vid_begin = vlan->vid_end = vid; - err = obj->cb(rocker_port->dev, obj); + err = obj->cb(obj); if (err) break; } diff --git a/include/net/switchdev.h b/include/net/switchdev.h index 1820787..9ef7c56 100644 --- a/include/net/switchdev.h +++ b/include/net/switchdev.h @@ -66,7 +66,7 @@ enum switchdev_obj_id { struct switchdev_obj { enum switchdev_obj_id id; - int (*cb)(struct net_device *dev, struct switchdev_obj *obj); + int (*cb)(struct switchdev_obj *obj); union { struct switchdev_obj_vlan { /* PORT_VLAN */ u16 flags; diff --git a/net/dsa/slave.c b/net/dsa/slave.c index f18cae5..0b47647 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -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(dev, obj); + err = obj->cb(obj); if (err) break; } @@ -397,7 +397,7 @@ static int dsa_slave_port_fdb_dump(struct net_device *dev, obj->u.fdb.vid = vid; obj->u.fdb.ndm_state = is_static ? NUD_NOARP : NUD_REACHABLE; - ret = obj->cb(dev, obj); + ret = obj->cb(obj); if (ret < 0) break; } diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c index c0e2047..93f4971 100644 --- a/net/switchdev/switchdev.c +++ b/net/switchdev/switchdev.c @@ -514,8 +514,7 @@ static int switchdev_port_vlan_dump_put(struct switchdev_vlan_dump *dump) return 0; } -static int switchdev_port_vlan_dump_cb(struct net_device *dev, - struct switchdev_obj *obj) +static int switchdev_port_vlan_dump_cb(struct switchdev_obj *obj) { struct switchdev_vlan_dump *dump = container_of(obj, struct switchdev_vlan_dump, obj); @@ -864,8 +863,7 @@ struct switchdev_fdb_dump { int idx; }; -static int switchdev_port_fdb_dump_cb(struct net_device *dev, - struct switchdev_obj *obj) +static int switchdev_port_fdb_dump_cb(struct switchdev_obj *obj) { struct switchdev_fdb_dump *dump = container_of(obj, struct switchdev_fdb_dump, obj); -- 2.6.0 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 net-next 4/6] net: switchdev: pass callback to dump operation 2015-09-29 16:07 [PATCH v2 net-next 0/6] net: switchdev: use specific switchdev_obj_* Vivien Didelot ` (2 preceding siblings ...) 2015-09-29 16:07 ` [PATCH v2 net-next 3/6] net: switchdev: remove dev from switchdev_obj cb Vivien Didelot @ 2015-09-29 16:07 ` Vivien Didelot 2015-09-30 10:41 ` Jiri Pirko 2015-09-29 16:07 ` [PATCH v2 net-next 5/6] net: switchdev: abstract object in add/del ops Vivien Didelot ` (3 subsequent siblings) 7 siblings, 1 reply; 13+ messages in thread From: Vivien Didelot @ 2015-09-29 16:07 UTC (permalink / raw) To: netdev Cc: linux-kernel, kernel, David S. Miller, Scott Feldman, Jiri Pirko, Florian Fainelli, Andrew Lunn, Vivien Didelot 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> --- drivers/net/ethernet/rocker/rocker.c | 21 +++++++++-------- include/net/switchdev.h | 9 +++++--- net/dsa/slave.c | 26 +++++++++++---------- net/switchdev/switchdev.c | 45 ++++++++++++++++++------------------ 4 files changed, 53 insertions(+), 48 deletions(-) diff --git a/drivers/net/ethernet/rocker/rocker.c b/drivers/net/ethernet/rocker/rocker.c index 78fd443..107adb6 100644 --- a/drivers/net/ethernet/rocker/rocker.c +++ b/drivers/net/ethernet/rocker/rocker.c @@ -4538,10 +4538,10 @@ static int rocker_port_obj_del(struct net_device *dev, } static int rocker_port_fdb_dump(const struct rocker_port *rocker_port, - struct switchdev_obj *obj) + struct switchdev_obj_fdb *fdb, + int (*cb)(void *obj)) { struct rocker *rocker = rocker_port->rocker; - struct switchdev_obj_fdb *fdb = &obj->u.fdb; struct rocker_fdb_tbl_entry *found; struct hlist_node *tmp; unsigned long lock_flags; @@ -4556,7 +4556,7 @@ static int rocker_port_fdb_dump(const struct rocker_port *rocker_port, fdb->ndm_state = NUD_REACHABLE; fdb->vid = rocker_port_vlan_to_vid(rocker_port, found->key.vlan_id); - err = obj->cb(obj); + err = cb(fdb); if (err) break; } @@ -4566,9 +4566,9 @@ static int rocker_port_fdb_dump(const struct rocker_port *rocker_port, } static int rocker_port_vlan_dump(const struct rocker_port *rocker_port, - struct switchdev_obj *obj) + struct switchdev_obj_vlan *vlan, + int (*cb)(void *obj)) { - struct switchdev_obj_vlan *vlan = &obj->u.vlan; u16 vid; int err = 0; @@ -4579,7 +4579,7 @@ static int rocker_port_vlan_dump(const struct rocker_port *rocker_port, if (rocker_vlan_id_is_internal(htons(vid))) vlan->flags |= BRIDGE_VLAN_INFO_PVID; vlan->vid_begin = vlan->vid_end = vid; - err = obj->cb(obj); + err = cb(vlan); if (err) break; } @@ -4588,17 +4588,18 @@ static int rocker_port_vlan_dump(const struct rocker_port *rocker_port, } static int rocker_port_obj_dump(struct net_device *dev, - struct switchdev_obj *obj) + enum switchdev_obj_id id, void *obj, + int (*cb)(void *obj)) { const struct rocker_port *rocker_port = netdev_priv(dev); int err = 0; - switch (obj->id) { + switch (id) { case SWITCHDEV_OBJ_PORT_FDB: - err = rocker_port_fdb_dump(rocker_port, obj); + err = rocker_port_fdb_dump(rocker_port, obj, cb); break; case SWITCHDEV_OBJ_PORT_VLAN: - err = rocker_port_vlan_dump(rocker_port, obj); + err = rocker_port_vlan_dump(rocker_port, obj, cb); break; default: err = -EOPNOTSUPP; diff --git a/include/net/switchdev.h b/include/net/switchdev.h index 9ef7c56..a2f57fb 100644 --- a/include/net/switchdev.h +++ b/include/net/switchdev.h @@ -120,7 +120,8 @@ struct switchdev_ops { int (*switchdev_port_obj_del)(struct net_device *dev, struct switchdev_obj *obj); int (*switchdev_port_obj_dump)(struct net_device *dev, - struct switchdev_obj *obj); + enum switchdev_obj_id id, void *obj, + int (*cb)(void *obj)); }; enum switchdev_notifier_type { @@ -152,7 +153,8 @@ int switchdev_port_attr_set(struct net_device *dev, struct switchdev_attr *attr); int switchdev_port_obj_add(struct net_device *dev, struct switchdev_obj *obj); int switchdev_port_obj_del(struct net_device *dev, struct switchdev_obj *obj); -int switchdev_port_obj_dump(struct net_device *dev, struct switchdev_obj *obj); +int switchdev_port_obj_dump(struct net_device *dev, enum switchdev_obj_id id, + void *obj, int (*cb)(void *obj)); int register_switchdev_notifier(struct notifier_block *nb); int unregister_switchdev_notifier(struct notifier_block *nb); int call_switchdev_notifiers(unsigned long val, struct net_device *dev, @@ -209,7 +211,8 @@ static inline int switchdev_port_obj_del(struct net_device *dev, } static inline int switchdev_port_obj_dump(struct net_device *dev, - struct switchdev_obj *obj) + enum switchdev_obj_id id, void *obj, + int (*cb)(void *obj)) { return -EOPNOTSUPP; } diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 0b47647..c3b868c 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; diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c index 93f4971..2ef863c 100644 --- a/net/switchdev/switchdev.c +++ b/net/switchdev/switchdev.c @@ -386,9 +386,12 @@ EXPORT_SYMBOL_GPL(switchdev_port_obj_del); * switchdev_port_obj_dump - Dump port objects * * @dev: port device + * @id: object ID * @obj: object to dump + * @cb: function to call with a filled object */ -int switchdev_port_obj_dump(struct net_device *dev, struct switchdev_obj *obj) +int switchdev_port_obj_dump(struct net_device *dev, enum switchdev_obj_id id, + void *obj, int (*cb)(void *obj)) { const struct switchdev_ops *ops = dev->switchdev_ops; struct net_device *lower_dev; @@ -396,7 +399,7 @@ int switchdev_port_obj_dump(struct net_device *dev, struct switchdev_obj *obj) int err = -EOPNOTSUPP; if (ops && ops->switchdev_port_obj_dump) - return ops->switchdev_port_obj_dump(dev, obj); + return ops->switchdev_port_obj_dump(dev, id, obj, cb); /* Switch device port(s) may be stacked under * bond/team/vlan dev, so recurse down to dump objects on @@ -404,7 +407,7 @@ int switchdev_port_obj_dump(struct net_device *dev, struct switchdev_obj *obj) */ netdev_for_each_lower_dev(dev, lower_dev, iter) { - err = switchdev_port_obj_dump(lower_dev, obj); + err = switchdev_port_obj_dump(lower_dev, id, obj, cb); break; } @@ -476,7 +479,7 @@ int call_switchdev_notifiers(unsigned long val, struct net_device *dev, EXPORT_SYMBOL_GPL(call_switchdev_notifiers); struct switchdev_vlan_dump { - struct switchdev_obj obj; + struct switchdev_obj_vlan vlan; struct sk_buff *skb; u32 filter_mask; u16 flags; @@ -514,11 +517,11 @@ static int switchdev_port_vlan_dump_put(struct switchdev_vlan_dump *dump) return 0; } -static int switchdev_port_vlan_dump_cb(struct switchdev_obj *obj) +static int switchdev_port_vlan_dump_cb(void *obj) { + struct switchdev_obj_vlan *vlan = obj; struct switchdev_vlan_dump *dump = - container_of(obj, struct switchdev_vlan_dump, obj); - struct switchdev_obj_vlan *vlan = &dump->obj.u.vlan; + container_of(vlan, struct switchdev_vlan_dump, vlan); int err = 0; if (vlan->vid_begin > vlan->vid_end) @@ -570,10 +573,6 @@ static int switchdev_port_vlan_fill(struct sk_buff *skb, struct net_device *dev, u32 filter_mask) { struct switchdev_vlan_dump dump = { - .obj = { - .id = SWITCHDEV_OBJ_PORT_VLAN, - .cb = switchdev_port_vlan_dump_cb, - }, .skb = skb, .filter_mask = filter_mask, }; @@ -581,7 +580,9 @@ static int switchdev_port_vlan_fill(struct sk_buff *skb, struct net_device *dev, if ((filter_mask & RTEXT_FILTER_BRVLAN) || (filter_mask & RTEXT_FILTER_BRVLAN_COMPRESSED)) { - err = switchdev_port_obj_dump(dev, &dump.obj); + err = switchdev_port_obj_dump(dev, SWITCHDEV_OBJ_PORT_VLAN, + &dump.vlan, + switchdev_port_vlan_dump_cb); if (err) goto err_out; if (filter_mask & RTEXT_FILTER_BRVLAN_COMPRESSED) @@ -856,17 +857,18 @@ int switchdev_port_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], EXPORT_SYMBOL_GPL(switchdev_port_fdb_del); struct switchdev_fdb_dump { - struct switchdev_obj obj; + struct switchdev_obj_fdb fdb; struct net_device *dev; struct sk_buff *skb; struct netlink_callback *cb; int idx; }; -static int switchdev_port_fdb_dump_cb(struct switchdev_obj *obj) +static int switchdev_port_fdb_dump_cb(void *obj) { + struct switchdev_obj_fdb *fdb = obj; struct switchdev_fdb_dump *dump = - container_of(obj, struct switchdev_fdb_dump, obj); + container_of(fdb, struct switchdev_fdb_dump, fdb); u32 portid = NETLINK_CB(dump->cb->skb).portid; u32 seq = dump->cb->nlh->nlmsg_seq; struct nlmsghdr *nlh; @@ -887,12 +889,12 @@ static int switchdev_port_fdb_dump_cb(struct switchdev_obj *obj) ndm->ndm_flags = NTF_SELF; ndm->ndm_type = 0; ndm->ndm_ifindex = dump->dev->ifindex; - ndm->ndm_state = obj->u.fdb.ndm_state; + ndm->ndm_state = fdb->ndm_state; - if (nla_put(dump->skb, NDA_LLADDR, ETH_ALEN, obj->u.fdb.addr)) + if (nla_put(dump->skb, NDA_LLADDR, ETH_ALEN, fdb->addr)) goto nla_put_failure; - if (obj->u.fdb.vid && nla_put_u16(dump->skb, NDA_VLAN, obj->u.fdb.vid)) + if (fdb->vid && nla_put_u16(dump->skb, NDA_VLAN, fdb->vid)) goto nla_put_failure; nlmsg_end(dump->skb, nlh); @@ -922,17 +924,14 @@ int switchdev_port_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb, struct net_device *filter_dev, int idx) { struct switchdev_fdb_dump dump = { - .obj = { - .id = SWITCHDEV_OBJ_PORT_FDB, - .cb = switchdev_port_fdb_dump_cb, - }, .dev = dev, .skb = skb, .cb = cb, .idx = idx, }; - switchdev_port_obj_dump(dev, &dump.obj); + switchdev_port_obj_dump(dev, SWITCHDEV_OBJ_PORT_FDB, &dump.fdb, + switchdev_port_fdb_dump_cb); return dump.idx; } EXPORT_SYMBOL_GPL(switchdev_port_fdb_dump); -- 2.6.0 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v2 net-next 4/6] net: switchdev: pass callback to dump operation 2015-09-29 16:07 ` [PATCH v2 net-next 4/6] net: switchdev: pass callback to dump operation Vivien Didelot @ 2015-09-30 10:41 ` Jiri Pirko 0 siblings, 0 replies; 13+ messages in thread From: Jiri Pirko @ 2015-09-30 10:41 UTC (permalink / raw) To: Vivien Didelot Cc: netdev, linux-kernel, kernel, David S. Miller, Scott Feldman, Florian Fainelli, Andrew Lunn Tue, Sep 29, 2015 at 06:07:16PM CEST, vivien.didelot@savoirfairelinux.com wrote: >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> >--- > drivers/net/ethernet/rocker/rocker.c | 21 +++++++++-------- > include/net/switchdev.h | 9 +++++--- > net/dsa/slave.c | 26 +++++++++++---------- > net/switchdev/switchdev.c | 45 ++++++++++++++++++------------------ > 4 files changed, 53 insertions(+), 48 deletions(-) > >diff --git a/drivers/net/ethernet/rocker/rocker.c b/drivers/net/ethernet/rocker/rocker.c >index 78fd443..107adb6 100644 >--- a/drivers/net/ethernet/rocker/rocker.c >+++ b/drivers/net/ethernet/rocker/rocker.c >@@ -4538,10 +4538,10 @@ static int rocker_port_obj_del(struct net_device *dev, > } > > static int rocker_port_fdb_dump(const struct rocker_port *rocker_port, >- struct switchdev_obj *obj) >+ struct switchdev_obj_fdb *fdb, >+ int (*cb)(void *obj)) ^^^^^^^^^^^^^^^^^^^^ we should have some typedef for this. ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 net-next 5/6] net: switchdev: abstract object in add/del ops 2015-09-29 16:07 [PATCH v2 net-next 0/6] net: switchdev: use specific switchdev_obj_* Vivien Didelot ` (3 preceding siblings ...) 2015-09-29 16:07 ` [PATCH v2 net-next 4/6] net: switchdev: pass callback to dump operation Vivien Didelot @ 2015-09-29 16:07 ` Vivien Didelot 2015-09-29 16:07 ` [PATCH v2 net-next 6/6] net: switchdev: extract struct switchdev_obj_* Vivien Didelot ` (2 subsequent siblings) 7 siblings, 0 replies; 13+ messages in thread From: Vivien Didelot @ 2015-09-29 16:07 UTC (permalink / raw) To: netdev Cc: linux-kernel, kernel, David S. Miller, Scott Feldman, Jiri Pirko, Florian Fainelli, Andrew Lunn, Vivien Didelot Similar to the notifier_call callback of a notifier_block, change the function signature of switchdev add and del operations to: int switchdev_port_obj_add/del(struct net_device *dev, enum switchdev_obj_id id, void *obj); This allows the caller to pass a specific switchdev_obj_* structure instead of the generic switchdev_obj one. Drivers implementation of these operations and switchdev have been changed accordingly. Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> --- drivers/net/ethernet/rocker/rocker.c | 21 +++--- include/net/switchdev.h | 18 ++++-- net/bridge/br_fdb.c | 11 ++-- net/bridge/br_vlan.c | 24 +++---- net/dsa/slave.c | 20 +++--- net/switchdev/switchdev.c | 122 ++++++++++++++++------------------- 6 files changed, 99 insertions(+), 117 deletions(-) diff --git a/drivers/net/ethernet/rocker/rocker.c b/drivers/net/ethernet/rocker/rocker.c index 107adb6..9773f5b 100644 --- a/drivers/net/ethernet/rocker/rocker.c +++ b/drivers/net/ethernet/rocker/rocker.c @@ -4437,26 +4437,25 @@ static int rocker_port_fdb_add(struct rocker_port *rocker_port, } static int rocker_port_obj_add(struct net_device *dev, - struct switchdev_obj *obj, + enum switchdev_obj_id id, const void *obj, struct switchdev_trans *trans) { struct rocker_port *rocker_port = netdev_priv(dev); const struct switchdev_obj_ipv4_fib *fib4; int err = 0; - switch (obj->id) { + switch (id) { case SWITCHDEV_OBJ_PORT_VLAN: - err = rocker_port_vlans_add(rocker_port, trans, - &obj->u.vlan); + err = rocker_port_vlans_add(rocker_port, trans, obj); break; case SWITCHDEV_OBJ_IPV4_FIB: - fib4 = &obj->u.ipv4_fib; + fib4 = obj; err = rocker_port_fib_ipv4(rocker_port, trans, htonl(fib4->dst), fib4->dst_len, fib4->fi, fib4->tb_id, 0); break; case SWITCHDEV_OBJ_PORT_FDB: - err = rocker_port_fdb_add(rocker_port, trans, &obj->u.fdb); + err = rocker_port_fdb_add(rocker_port, trans, obj); break; default: err = -EOPNOTSUPP; @@ -4509,25 +4508,25 @@ static int rocker_port_fdb_del(struct rocker_port *rocker_port, } static int rocker_port_obj_del(struct net_device *dev, - struct switchdev_obj *obj) + enum switchdev_obj_id id, const void *obj) { struct rocker_port *rocker_port = netdev_priv(dev); const struct switchdev_obj_ipv4_fib *fib4; int err = 0; - switch (obj->id) { + switch (id) { case SWITCHDEV_OBJ_PORT_VLAN: - err = rocker_port_vlans_del(rocker_port, &obj->u.vlan); + err = rocker_port_vlans_del(rocker_port, obj); break; case SWITCHDEV_OBJ_IPV4_FIB: - fib4 = &obj->u.ipv4_fib; + fib4 = obj; err = rocker_port_fib_ipv4(rocker_port, NULL, htonl(fib4->dst), fib4->dst_len, fib4->fi, fib4->tb_id, ROCKER_OP_FLAG_REMOVE); break; case SWITCHDEV_OBJ_PORT_FDB: - err = rocker_port_fdb_del(rocker_port, NULL, &obj->u.fdb); + err = rocker_port_fdb_del(rocker_port, NULL, obj); break; default: err = -EOPNOTSUPP; diff --git a/include/net/switchdev.h b/include/net/switchdev.h index a2f57fb..bcadac3 100644 --- a/include/net/switchdev.h +++ b/include/net/switchdev.h @@ -115,10 +115,12 @@ struct switchdev_ops { struct switchdev_attr *attr, struct switchdev_trans *trans); int (*switchdev_port_obj_add)(struct net_device *dev, - struct switchdev_obj *obj, + enum switchdev_obj_id id, + const void *obj, struct switchdev_trans *trans); int (*switchdev_port_obj_del)(struct net_device *dev, - struct switchdev_obj *obj); + enum switchdev_obj_id id, + const void *obj); int (*switchdev_port_obj_dump)(struct net_device *dev, enum switchdev_obj_id id, void *obj, int (*cb)(void *obj)); @@ -151,8 +153,10 @@ int switchdev_port_attr_get(struct net_device *dev, struct switchdev_attr *attr); int switchdev_port_attr_set(struct net_device *dev, struct switchdev_attr *attr); -int switchdev_port_obj_add(struct net_device *dev, struct switchdev_obj *obj); -int switchdev_port_obj_del(struct net_device *dev, struct switchdev_obj *obj); +int switchdev_port_obj_add(struct net_device *dev, enum switchdev_obj_id id, + const void *obj); +int switchdev_port_obj_del(struct net_device *dev, enum switchdev_obj_id id, + const void *obj); int switchdev_port_obj_dump(struct net_device *dev, enum switchdev_obj_id id, void *obj, int (*cb)(void *obj)); int register_switchdev_notifier(struct notifier_block *nb); @@ -199,13 +203,15 @@ static inline int switchdev_port_attr_set(struct net_device *dev, } static inline int switchdev_port_obj_add(struct net_device *dev, - struct switchdev_obj *obj) + enum switchdev_obj_id id, + const void *obj) { return -EOPNOTSUPP; } static inline int switchdev_port_obj_del(struct net_device *dev, - struct switchdev_obj *obj) + enum switchdev_obj_id id, + const void *obj) { return -EOPNOTSUPP; } diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c index 6663cc0..cd593b3 100644 --- a/net/bridge/br_fdb.c +++ b/net/bridge/br_fdb.c @@ -133,15 +133,12 @@ static void fdb_del_hw_addr(struct net_bridge *br, const unsigned char *addr) static void fdb_del_external_learn(struct net_bridge_fdb_entry *f) { - struct switchdev_obj obj = { - .id = SWITCHDEV_OBJ_PORT_FDB, - .u.fdb = { - .addr = f->addr.addr, - .vid = f->vlan_id, - }, + struct switchdev_obj_fdb fdb = { + .addr = f->addr.addr, + .vid = f->vlan_id, }; - switchdev_port_obj_del(f->dst->dev, &obj); + switchdev_port_obj_del(f->dst->dev, SWITCHDEV_OBJ_PORT_FDB, &fdb); } static void fdb_delete(struct net_bridge *br, struct net_bridge_fdb_entry *f) diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c index 5f5a02b..c9aac0a 100644 --- a/net/bridge/br_vlan.c +++ b/net/bridge/br_vlan.c @@ -50,16 +50,13 @@ static int __vlan_vid_add(struct net_device *dev, struct net_bridge *br, if (ops->ndo_vlan_rx_add_vid) { err = vlan_vid_add(dev, br->vlan_proto, vid); } else { - struct switchdev_obj vlan_obj = { - .id = SWITCHDEV_OBJ_PORT_VLAN, - .u.vlan = { - .flags = flags, - .vid_begin = vid, - .vid_end = vid, - }, + struct switchdev_obj_vlan v = { + .flags = flags, + .vid_begin = vid, + .vid_end = vid, }; - err = switchdev_port_obj_add(dev, &vlan_obj); + err = switchdev_port_obj_add(dev, SWITCHDEV_OBJ_PORT_VLAN, &v); if (err == -EOPNOTSUPP) err = 0; } @@ -130,15 +127,12 @@ static int __vlan_vid_del(struct net_device *dev, struct net_bridge *br, if (ops->ndo_vlan_rx_kill_vid) { vlan_vid_del(dev, br->vlan_proto, vid); } else { - struct switchdev_obj vlan_obj = { - .id = SWITCHDEV_OBJ_PORT_VLAN, - .u.vlan = { - .vid_begin = vid, - .vid_end = vid, - }, + struct switchdev_obj_vlan v = { + .vid_begin = vid, + .vid_end = vid, }; - err = switchdev_port_obj_del(dev, &vlan_obj); + err = switchdev_port_obj_del(dev, SWITCHDEV_OBJ_PORT_VLAN, &v); if (err == -EOPNOTSUPP) err = 0; } diff --git a/net/dsa/slave.c b/net/dsa/slave.c index c3b868c..04f0153 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -242,10 +242,9 @@ static int dsa_bridge_check_vlan_range(struct dsa_switch *ds, } static int dsa_slave_port_vlan_add(struct net_device *dev, - struct switchdev_obj *obj, + const struct switchdev_obj_vlan *vlan, struct switchdev_trans *trans) { - struct switchdev_obj_vlan *vlan = &obj->u.vlan; struct dsa_slave_priv *p = netdev_priv(dev); struct dsa_switch *ds = p->parent; u16 vid; @@ -279,9 +278,8 @@ static int dsa_slave_port_vlan_add(struct net_device *dev, } static int dsa_slave_port_vlan_del(struct net_device *dev, - struct switchdev_obj *obj) + const struct switchdev_obj_vlan *vlan) { - struct switchdev_obj_vlan *vlan = &obj->u.vlan; struct dsa_slave_priv *p = netdev_priv(dev); struct dsa_switch *ds = p->parent; u16 vid; @@ -343,10 +341,9 @@ static int dsa_slave_port_vlan_dump(struct net_device *dev, } static int dsa_slave_port_fdb_add(struct net_device *dev, - struct switchdev_obj *obj, + const struct switchdev_obj_fdb *fdb, struct switchdev_trans *trans) { - struct switchdev_obj_fdb *fdb = &obj->u.fdb; struct dsa_slave_priv *p = netdev_priv(dev); struct dsa_switch *ds = p->parent; int ret = -EOPNOTSUPP; @@ -360,9 +357,8 @@ static int dsa_slave_port_fdb_add(struct net_device *dev, } static int dsa_slave_port_fdb_del(struct net_device *dev, - struct switchdev_obj *obj) + const struct switchdev_obj_fdb *fdb) { - struct switchdev_obj_fdb *fdb = &obj->u.fdb; struct dsa_slave_priv *p = netdev_priv(dev); struct dsa_switch *ds = p->parent; int ret = -EOPNOTSUPP; @@ -473,7 +469,7 @@ static int dsa_slave_port_attr_set(struct net_device *dev, } static int dsa_slave_port_obj_add(struct net_device *dev, - struct switchdev_obj *obj, + enum switchdev_obj_id id, const void *obj, struct switchdev_trans *trans) { int err; @@ -483,7 +479,7 @@ static int dsa_slave_port_obj_add(struct net_device *dev, * supported, return -EOPNOTSUPP. */ - switch (obj->id) { + switch (id) { case SWITCHDEV_OBJ_PORT_FDB: err = dsa_slave_port_fdb_add(dev, obj, trans); break; @@ -499,11 +495,11 @@ static int dsa_slave_port_obj_add(struct net_device *dev, } static int dsa_slave_port_obj_del(struct net_device *dev, - struct switchdev_obj *obj) + enum switchdev_obj_id id, const void *obj) { int err; - switch (obj->id) { + switch (id) { case SWITCHDEV_OBJ_PORT_FDB: err = dsa_slave_port_fdb_del(dev, obj); break; diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c index 2ef863c..fe82fab 100644 --- a/net/switchdev/switchdev.c +++ b/net/switchdev/switchdev.c @@ -270,7 +270,7 @@ int switchdev_port_attr_set(struct net_device *dev, struct switchdev_attr *attr) EXPORT_SYMBOL_GPL(switchdev_port_attr_set); static int __switchdev_port_obj_add(struct net_device *dev, - struct switchdev_obj *obj, + enum switchdev_obj_id id, const void *obj, struct switchdev_trans *trans) { const struct switchdev_ops *ops = dev->switchdev_ops; @@ -279,7 +279,7 @@ static int __switchdev_port_obj_add(struct net_device *dev, int err = -EOPNOTSUPP; if (ops && ops->switchdev_port_obj_add) - return ops->switchdev_port_obj_add(dev, obj, trans); + return ops->switchdev_port_obj_add(dev, id, obj, trans); /* Switch device port(s) may be stacked under * bond/team/vlan dev, so recurse down to add object on @@ -287,7 +287,7 @@ static int __switchdev_port_obj_add(struct net_device *dev, */ netdev_for_each_lower_dev(dev, lower_dev, iter) { - err = __switchdev_port_obj_add(lower_dev, obj, trans); + err = __switchdev_port_obj_add(lower_dev, id, obj, trans); if (err) break; } @@ -299,6 +299,7 @@ static int __switchdev_port_obj_add(struct net_device *dev, * switchdev_port_obj_add - Add port object * * @dev: port device + * @id: object ID * @obj: object to add * * Use a 2-phase prepare-commit transaction model to ensure @@ -307,7 +308,8 @@ static int __switchdev_port_obj_add(struct net_device *dev, * * rtnl_lock must be held. */ -int switchdev_port_obj_add(struct net_device *dev, struct switchdev_obj *obj) +int switchdev_port_obj_add(struct net_device *dev, enum switchdev_obj_id id, + const void *obj) { struct switchdev_trans trans; int err; @@ -324,7 +326,7 @@ int switchdev_port_obj_add(struct net_device *dev, struct switchdev_obj *obj) */ trans.ph_prepare = true; - err = __switchdev_port_obj_add(dev, obj, &trans); + err = __switchdev_port_obj_add(dev, id, obj, &trans); if (err) { /* Prepare phase failed: abort the transaction. Any * resources reserved in the prepare phase are @@ -343,8 +345,8 @@ int switchdev_port_obj_add(struct net_device *dev, struct switchdev_obj *obj) */ trans.ph_prepare = false; - err = __switchdev_port_obj_add(dev, obj, &trans); - WARN(err, "%s: Commit of object (id=%d) failed.\n", dev->name, obj->id); + err = __switchdev_port_obj_add(dev, id, obj, &trans); + WARN(err, "%s: Commit of object (id=%d) failed.\n", dev->name, id); switchdev_trans_items_warn_destroy(dev, &trans); return err; @@ -355,9 +357,11 @@ EXPORT_SYMBOL_GPL(switchdev_port_obj_add); * switchdev_port_obj_del - Delete port object * * @dev: port device + * @id: object ID * @obj: object to delete */ -int switchdev_port_obj_del(struct net_device *dev, struct switchdev_obj *obj) +int switchdev_port_obj_del(struct net_device *dev, enum switchdev_obj_id id, + const void *obj) { const struct switchdev_ops *ops = dev->switchdev_ops; struct net_device *lower_dev; @@ -365,7 +369,7 @@ int switchdev_port_obj_del(struct net_device *dev, struct switchdev_obj *obj) int err = -EOPNOTSUPP; if (ops && ops->switchdev_port_obj_del) - return ops->switchdev_port_obj_del(dev, obj); + return ops->switchdev_port_obj_del(dev, id, obj); /* Switch device port(s) may be stacked under * bond/team/vlan dev, so recurse down to delete object on @@ -373,7 +377,7 @@ int switchdev_port_obj_del(struct net_device *dev, struct switchdev_obj *obj) */ netdev_for_each_lower_dev(dev, lower_dev, iter) { - err = switchdev_port_obj_del(lower_dev, obj); + err = switchdev_port_obj_del(lower_dev, id, obj); if (err) break; } @@ -695,14 +699,12 @@ static int switchdev_port_br_setlink_protinfo(struct net_device *dev, static int switchdev_port_br_afspec(struct net_device *dev, struct nlattr *afspec, int (*f)(struct net_device *dev, - struct switchdev_obj *obj)) + enum switchdev_obj_id id, + const void *obj)) { struct nlattr *attr; struct bridge_vlan_info *vinfo; - struct switchdev_obj obj = { - .id = SWITCHDEV_OBJ_PORT_VLAN, - }; - struct switchdev_obj_vlan *vlan = &obj.u.vlan; + struct switchdev_obj_vlan vlan = { 0 }; int rem; int err; @@ -712,30 +714,30 @@ static int switchdev_port_br_afspec(struct net_device *dev, if (nla_len(attr) != sizeof(struct bridge_vlan_info)) return -EINVAL; vinfo = nla_data(attr); - vlan->flags = vinfo->flags; + vlan.flags = vinfo->flags; if (vinfo->flags & BRIDGE_VLAN_INFO_RANGE_BEGIN) { - if (vlan->vid_begin) + if (vlan.vid_begin) return -EINVAL; - vlan->vid_begin = vinfo->vid; + vlan.vid_begin = vinfo->vid; } else if (vinfo->flags & BRIDGE_VLAN_INFO_RANGE_END) { - if (!vlan->vid_begin) + if (!vlan.vid_begin) return -EINVAL; - vlan->vid_end = vinfo->vid; - if (vlan->vid_end <= vlan->vid_begin) + vlan.vid_end = vinfo->vid; + if (vlan.vid_end <= vlan.vid_begin) return -EINVAL; - err = f(dev, &obj); + err = f(dev, SWITCHDEV_OBJ_PORT_VLAN, &vlan); if (err) return err; - memset(vlan, 0, sizeof(*vlan)); + memset(&vlan, 0, sizeof(vlan)); } else { - if (vlan->vid_begin) + if (vlan.vid_begin) return -EINVAL; - vlan->vid_begin = vinfo->vid; - vlan->vid_end = vinfo->vid; - err = f(dev, &obj); + vlan.vid_begin = vinfo->vid; + vlan.vid_end = vinfo->vid; + err = f(dev, SWITCHDEV_OBJ_PORT_VLAN, &vlan); if (err) return err; - memset(vlan, 0, sizeof(*vlan)); + memset(&vlan, 0, sizeof(vlan)); } } @@ -817,15 +819,12 @@ int switchdev_port_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev, const unsigned char *addr, u16 vid, u16 nlm_flags) { - struct switchdev_obj obj = { - .id = SWITCHDEV_OBJ_PORT_FDB, - .u.fdb = { - .addr = addr, - .vid = vid, - }, + struct switchdev_obj_fdb fdb = { + .addr = addr, + .vid = vid, }; - return switchdev_port_obj_add(dev, &obj); + return switchdev_port_obj_add(dev, SWITCHDEV_OBJ_PORT_FDB, &fdb); } EXPORT_SYMBOL_GPL(switchdev_port_fdb_add); @@ -844,15 +843,12 @@ int switchdev_port_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev, const unsigned char *addr, u16 vid) { - struct switchdev_obj obj = { - .id = SWITCHDEV_OBJ_PORT_FDB, - .u.fdb = { - .addr = addr, - .vid = vid, - }, + struct switchdev_obj_fdb fdb = { + .addr = addr, + .vid = vid, }; - return switchdev_port_obj_del(dev, &obj); + return switchdev_port_obj_del(dev, SWITCHDEV_OBJ_PORT_FDB, &fdb); } EXPORT_SYMBOL_GPL(switchdev_port_fdb_del); @@ -1009,17 +1005,14 @@ static struct net_device *switchdev_get_dev_by_nhs(struct fib_info *fi) int switchdev_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi, u8 tos, u8 type, u32 nlflags, u32 tb_id) { - struct switchdev_obj fib_obj = { - .id = SWITCHDEV_OBJ_IPV4_FIB, - .u.ipv4_fib = { - .dst = dst, - .dst_len = dst_len, - .fi = fi, - .tos = tos, - .type = type, - .nlflags = nlflags, - .tb_id = tb_id, - }, + struct switchdev_obj_ipv4_fib ipv4_fib = { + .dst = dst, + .dst_len = dst_len, + .fi = fi, + .tos = tos, + .type = type, + .nlflags = nlflags, + .tb_id = tb_id, }; struct net_device *dev; int err = 0; @@ -1040,7 +1033,7 @@ int switchdev_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi, if (!dev) return 0; - err = switchdev_port_obj_add(dev, &fib_obj); + err = switchdev_port_obj_add(dev, SWITCHDEV_OBJ_IPV4_FIB, &ipv4_fib); if (!err) fi->fib_flags |= RTNH_F_OFFLOAD; @@ -1063,17 +1056,14 @@ EXPORT_SYMBOL_GPL(switchdev_fib_ipv4_add); int switchdev_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi, u8 tos, u8 type, u32 tb_id) { - struct switchdev_obj fib_obj = { - .id = SWITCHDEV_OBJ_IPV4_FIB, - .u.ipv4_fib = { - .dst = dst, - .dst_len = dst_len, - .fi = fi, - .tos = tos, - .type = type, - .nlflags = 0, - .tb_id = tb_id, - }, + struct switchdev_obj_ipv4_fib ipv4_fib = { + .dst = dst, + .dst_len = dst_len, + .fi = fi, + .tos = tos, + .type = type, + .nlflags = 0, + .tb_id = tb_id, }; struct net_device *dev; int err = 0; @@ -1085,7 +1075,7 @@ int switchdev_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi, if (!dev) return 0; - err = switchdev_port_obj_del(dev, &fib_obj); + err = switchdev_port_obj_del(dev, SWITCHDEV_OBJ_IPV4_FIB, &ipv4_fib); if (!err) fi->fib_flags &= ~RTNH_F_OFFLOAD; -- 2.6.0 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 net-next 6/6] net: switchdev: extract struct switchdev_obj_* 2015-09-29 16:07 [PATCH v2 net-next 0/6] net: switchdev: use specific switchdev_obj_* Vivien Didelot ` (4 preceding siblings ...) 2015-09-29 16:07 ` [PATCH v2 net-next 5/6] net: switchdev: abstract object in add/del ops Vivien Didelot @ 2015-09-29 16:07 ` Vivien Didelot 2015-09-30 10:36 ` Jiri Pirko 2015-09-30 4:32 ` [PATCH v2 net-next 0/6] net: switchdev: use specific switchdev_obj_* David Miller 2015-09-30 10:45 ` Jiri Pirko 7 siblings, 1 reply; 13+ messages in thread From: Vivien Didelot @ 2015-09-29 16:07 UTC (permalink / raw) To: netdev Cc: linux-kernel, kernel, David S. Miller, Scott Feldman, Jiri Pirko, Florian Fainelli, Andrew Lunn, Vivien Didelot Now that switchdev and its drivers directly use specific switchdev_obj_* structures, move them out of the switchdev_obj union and get rif of this outer structure. Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> --- include/net/switchdev.h | 53 ++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/include/net/switchdev.h b/include/net/switchdev.h index bcadac3..e11425e 100644 --- a/include/net/switchdev.h +++ b/include/net/switchdev.h @@ -64,30 +64,29 @@ enum switchdev_obj_id { SWITCHDEV_OBJ_PORT_FDB, }; -struct switchdev_obj { - enum switchdev_obj_id id; - int (*cb)(struct switchdev_obj *obj); - union { - struct switchdev_obj_vlan { /* PORT_VLAN */ - u16 flags; - u16 vid_begin; - u16 vid_end; - } vlan; - struct switchdev_obj_ipv4_fib { /* IPV4_FIB */ - u32 dst; - int dst_len; - struct fib_info *fi; - u8 tos; - u8 type; - u32 nlflags; - u32 tb_id; - } ipv4_fib; - struct switchdev_obj_fdb { /* PORT_FDB */ - const unsigned char *addr; - u16 vid; - u16 ndm_state; - } fdb; - } u; +/* SWITCHDEV_OBJ_PORT_VLAN */ +struct switchdev_obj_vlan { + u16 flags; + u16 vid_begin; + u16 vid_end; +}; + +/* SWITCHDEV_OBJ_IPV4_FIB */ +struct switchdev_obj_ipv4_fib { + u32 dst; + int dst_len; + struct fib_info *fi; + u8 tos; + u8 type; + u32 nlflags; + u32 tb_id; +}; + +/* SWITCHDEV_OBJ_PORT_FDB */ +struct switchdev_obj_fdb { + const unsigned char *addr; + u16 vid; + u16 ndm_state; }; void switchdev_trans_item_enqueue(struct switchdev_trans *trans, @@ -102,11 +101,11 @@ void *switchdev_trans_item_dequeue(struct switchdev_trans *trans); * * @switchdev_port_attr_set: Set a port attribute (see switchdev_attr). * - * @switchdev_port_obj_add: Add an object to port (see switchdev_obj). + * @switchdev_port_obj_add: Add an object to port (see switchdev_obj_*). * - * @switchdev_port_obj_del: Delete an object from port (see switchdev_obj). + * @switchdev_port_obj_del: Delete an object from port (see switchdev_obj_*). * - * @switchdev_port_obj_dump: Dump port objects (see switchdev_obj). + * @switchdev_port_obj_dump: Dump port objects (see switchdev_obj_*). */ struct switchdev_ops { int (*switchdev_port_attr_get)(struct net_device *dev, -- 2.6.0 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v2 net-next 6/6] net: switchdev: extract struct switchdev_obj_* 2015-09-29 16:07 ` [PATCH v2 net-next 6/6] net: switchdev: extract struct switchdev_obj_* Vivien Didelot @ 2015-09-30 10:36 ` Jiri Pirko 2015-09-30 14:58 ` Scott Feldman 0 siblings, 1 reply; 13+ messages in thread From: Jiri Pirko @ 2015-09-30 10:36 UTC (permalink / raw) To: Vivien Didelot Cc: netdev, linux-kernel, kernel, David S. Miller, Scott Feldman, Florian Fainelli, Andrew Lunn Tue, Sep 29, 2015 at 06:07:18PM CEST, vivien.didelot@savoirfairelinux.com wrote: >Now that switchdev and its drivers directly use specific switchdev_obj_* >structures, move them out of the switchdev_obj union and get rif of this >outer structure. > >Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> >--- > include/net/switchdev.h | 53 ++++++++++++++++++++++++------------------------- > 1 file changed, 26 insertions(+), 27 deletions(-) > >diff --git a/include/net/switchdev.h b/include/net/switchdev.h >index bcadac3..e11425e 100644 >--- a/include/net/switchdev.h >+++ b/include/net/switchdev.h >@@ -64,30 +64,29 @@ enum switchdev_obj_id { > SWITCHDEV_OBJ_PORT_FDB, > }; > >-struct switchdev_obj { >- enum switchdev_obj_id id; >- int (*cb)(struct switchdev_obj *obj); >- union { >- struct switchdev_obj_vlan { /* PORT_VLAN */ >- u16 flags; >- u16 vid_begin; >- u16 vid_end; >- } vlan; >- struct switchdev_obj_ipv4_fib { /* IPV4_FIB */ >- u32 dst; >- int dst_len; >- struct fib_info *fi; >- u8 tos; >- u8 type; >- u32 nlflags; >- u32 tb_id; >- } ipv4_fib; >- struct switchdev_obj_fdb { /* PORT_FDB */ >- const unsigned char *addr; >- u16 vid; >- u16 ndm_state; >- } fdb; >- } u; >+/* SWITCHDEV_OBJ_PORT_VLAN */ >+struct switchdev_obj_vlan { >+ u16 flags; >+ u16 vid_begin; >+ u16 vid_end; >+}; >+ >+/* SWITCHDEV_OBJ_IPV4_FIB */ >+struct switchdev_obj_ipv4_fib { >+ u32 dst; >+ int dst_len; >+ struct fib_info *fi; >+ u8 tos; >+ u8 type; >+ u32 nlflags; >+ u32 tb_id; >+}; >+ >+/* SWITCHDEV_OBJ_PORT_FDB */ >+struct switchdev_obj_fdb { >+ const unsigned char *addr; >+ u16 vid; >+ u16 ndm_state; > }; I don't like these structs being passed down as a "void *". I think that we should have some "common" struct for these objects, event if it would be empty and pass it down. "void *" does not look good at all, does not tell the reader what that param is about. How about: struct switchdev_obj { }; struct switchdev_obj_vlan { struct switchdev_obj obj; u16 flags; u16 vid_begin; u16 vid_end; }; #define SWITCHDEV_OBJ_VLAN(obj) \ container_of(obj, struct switchdev_obj_vlan, obj) /* SWITCHDEV_OBJ_IPV4_FIB */ struct switchdev_obj_ipv4_fib { struct switchdev_obj obj; u32 dst; int dst_len; struct fib_info *fi; u8 tos; u8 type; u32 nlflags; u32 tb_id; }; #define SWITCHDEV_OBJ_IPV4_FIB(obj) \ container_of(obj, struct switchdev_obj_ipv4_fib, obj) /* SWITCHDEV_OBJ_PORT_FDB */ struct switchdev_obj_fdb { struct switchdev_obj obj; const unsigned char *addr; u16 vid; u16 ndm_state; }; #define SWITCHDEV_OBJ_FDB(obj) \ container_of(obj, struct switchdev_obj_fdb, obj) then pass struct switchdev_obj *obj down to drivers and in driver, get original object by SWITCHDEV_OBJ_* ? ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 net-next 6/6] net: switchdev: extract struct switchdev_obj_* 2015-09-30 10:36 ` Jiri Pirko @ 2015-09-30 14:58 ` Scott Feldman 2015-09-30 15:00 ` Jiri Pirko 0 siblings, 1 reply; 13+ messages in thread From: Scott Feldman @ 2015-09-30 14:58 UTC (permalink / raw) To: Jiri Pirko Cc: Vivien Didelot, Netdev, linux-kernel@vger.kernel.org, kernel, David S. Miller, Florian Fainelli, Andrew Lunn On Wed, Sep 30, 2015 at 3:36 AM, Jiri Pirko <jiri@resnulli.us> wrote: > Tue, Sep 29, 2015 at 06:07:18PM CEST, vivien.didelot@savoirfairelinux.com wrote: >>Now that switchdev and its drivers directly use specific switchdev_obj_* >>structures, move them out of the switchdev_obj union and get rif of this >>outer structure. >> >>Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> >>--- >> include/net/switchdev.h | 53 ++++++++++++++++++++++++------------------------- >> 1 file changed, 26 insertions(+), 27 deletions(-) >> >>diff --git a/include/net/switchdev.h b/include/net/switchdev.h >>index bcadac3..e11425e 100644 >>--- a/include/net/switchdev.h >>+++ b/include/net/switchdev.h >>@@ -64,30 +64,29 @@ enum switchdev_obj_id { >> SWITCHDEV_OBJ_PORT_FDB, >> }; >> >>-struct switchdev_obj { >>- enum switchdev_obj_id id; >>- int (*cb)(struct switchdev_obj *obj); >>- union { >>- struct switchdev_obj_vlan { /* PORT_VLAN */ >>- u16 flags; >>- u16 vid_begin; >>- u16 vid_end; >>- } vlan; >>- struct switchdev_obj_ipv4_fib { /* IPV4_FIB */ >>- u32 dst; >>- int dst_len; >>- struct fib_info *fi; >>- u8 tos; >>- u8 type; >>- u32 nlflags; >>- u32 tb_id; >>- } ipv4_fib; >>- struct switchdev_obj_fdb { /* PORT_FDB */ >>- const unsigned char *addr; >>- u16 vid; >>- u16 ndm_state; >>- } fdb; >>- } u; >>+/* SWITCHDEV_OBJ_PORT_VLAN */ >>+struct switchdev_obj_vlan { >>+ u16 flags; >>+ u16 vid_begin; >>+ u16 vid_end; >>+}; >>+ >>+/* SWITCHDEV_OBJ_IPV4_FIB */ >>+struct switchdev_obj_ipv4_fib { >>+ u32 dst; >>+ int dst_len; >>+ struct fib_info *fi; >>+ u8 tos; >>+ u8 type; >>+ u32 nlflags; >>+ u32 tb_id; >>+}; >>+ >>+/* SWITCHDEV_OBJ_PORT_FDB */ >>+struct switchdev_obj_fdb { >>+ const unsigned char *addr; >>+ u16 vid; >>+ u16 ndm_state; >> }; > > > I don't like these structs being passed down as a "void *". I think that > we should have some "common" struct for these objects, event if it would > be empty and pass it down. "void *" does not look good at all, does not > tell the reader what that param is about. How about: > > struct switchdev_obj { > }; > > struct switchdev_obj_vlan { > struct switchdev_obj obj; > u16 flags; > u16 vid_begin; > u16 vid_end; > }; > #define SWITCHDEV_OBJ_VLAN(obj) \ > container_of(obj, struct switchdev_obj_vlan, obj) > > /* SWITCHDEV_OBJ_IPV4_FIB */ > struct switchdev_obj_ipv4_fib { > struct switchdev_obj obj; > u32 dst; > int dst_len; > struct fib_info *fi; > u8 tos; > u8 type; > u32 nlflags; > u32 tb_id; > }; > #define SWITCHDEV_OBJ_IPV4_FIB(obj) \ > container_of(obj, struct switchdev_obj_ipv4_fib, obj) > > /* SWITCHDEV_OBJ_PORT_FDB */ > struct switchdev_obj_fdb { > struct switchdev_obj obj; > const unsigned char *addr; > u16 vid; > u16 ndm_state; > }; > #define SWITCHDEV_OBJ_FDB(obj) \ > container_of(obj, struct switchdev_obj_fdb, obj) > > > then pass struct switchdev_obj *obj down to drivers and in driver, get > original object by SWITCHDEV_OBJ_* ? Yes, I agree with Jiri, keep the struct switchdev_obj, use it within each specific struct, and pass struct switchdev * in core funcs rather than void *. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 net-next 6/6] net: switchdev: extract struct switchdev_obj_* 2015-09-30 14:58 ` Scott Feldman @ 2015-09-30 15:00 ` Jiri Pirko 0 siblings, 0 replies; 13+ messages in thread From: Jiri Pirko @ 2015-09-30 15:00 UTC (permalink / raw) To: Scott Feldman Cc: Vivien Didelot, Netdev, linux-kernel@vger.kernel.org, kernel, David S. Miller, Florian Fainelli, Andrew Lunn Wed, Sep 30, 2015 at 04:58:38PM CEST, sfeldma@gmail.com wrote: >On Wed, Sep 30, 2015 at 3:36 AM, Jiri Pirko <jiri@resnulli.us> wrote: >> Tue, Sep 29, 2015 at 06:07:18PM CEST, vivien.didelot@savoirfairelinux.com wrote: >>>Now that switchdev and its drivers directly use specific switchdev_obj_* >>>structures, move them out of the switchdev_obj union and get rif of this >>>outer structure. >>> >>>Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> >>>--- >>> include/net/switchdev.h | 53 ++++++++++++++++++++++++------------------------- >>> 1 file changed, 26 insertions(+), 27 deletions(-) >>> >>>diff --git a/include/net/switchdev.h b/include/net/switchdev.h >>>index bcadac3..e11425e 100644 >>>--- a/include/net/switchdev.h >>>+++ b/include/net/switchdev.h >>>@@ -64,30 +64,29 @@ enum switchdev_obj_id { >>> SWITCHDEV_OBJ_PORT_FDB, >>> }; >>> >>>-struct switchdev_obj { >>>- enum switchdev_obj_id id; >>>- int (*cb)(struct switchdev_obj *obj); >>>- union { >>>- struct switchdev_obj_vlan { /* PORT_VLAN */ >>>- u16 flags; >>>- u16 vid_begin; >>>- u16 vid_end; >>>- } vlan; >>>- struct switchdev_obj_ipv4_fib { /* IPV4_FIB */ >>>- u32 dst; >>>- int dst_len; >>>- struct fib_info *fi; >>>- u8 tos; >>>- u8 type; >>>- u32 nlflags; >>>- u32 tb_id; >>>- } ipv4_fib; >>>- struct switchdev_obj_fdb { /* PORT_FDB */ >>>- const unsigned char *addr; >>>- u16 vid; >>>- u16 ndm_state; >>>- } fdb; >>>- } u; >>>+/* SWITCHDEV_OBJ_PORT_VLAN */ >>>+struct switchdev_obj_vlan { >>>+ u16 flags; >>>+ u16 vid_begin; >>>+ u16 vid_end; >>>+}; >>>+ >>>+/* SWITCHDEV_OBJ_IPV4_FIB */ >>>+struct switchdev_obj_ipv4_fib { >>>+ u32 dst; >>>+ int dst_len; >>>+ struct fib_info *fi; >>>+ u8 tos; >>>+ u8 type; >>>+ u32 nlflags; >>>+ u32 tb_id; >>>+}; >>>+ >>>+/* SWITCHDEV_OBJ_PORT_FDB */ >>>+struct switchdev_obj_fdb { >>>+ const unsigned char *addr; >>>+ u16 vid; >>>+ u16 ndm_state; >>> }; >> >> >> I don't like these structs being passed down as a "void *". I think that >> we should have some "common" struct for these objects, event if it would >> be empty and pass it down. "void *" does not look good at all, does not >> tell the reader what that param is about. How about: >> >> struct switchdev_obj { >> }; >> >> struct switchdev_obj_vlan { >> struct switchdev_obj obj; >> u16 flags; >> u16 vid_begin; >> u16 vid_end; >> }; >> #define SWITCHDEV_OBJ_VLAN(obj) \ >> container_of(obj, struct switchdev_obj_vlan, obj) >> >> /* SWITCHDEV_OBJ_IPV4_FIB */ >> struct switchdev_obj_ipv4_fib { >> struct switchdev_obj obj; >> u32 dst; >> int dst_len; >> struct fib_info *fi; >> u8 tos; >> u8 type; >> u32 nlflags; >> u32 tb_id; >> }; >> #define SWITCHDEV_OBJ_IPV4_FIB(obj) \ >> container_of(obj, struct switchdev_obj_ipv4_fib, obj) >> >> /* SWITCHDEV_OBJ_PORT_FDB */ >> struct switchdev_obj_fdb { >> struct switchdev_obj obj; >> const unsigned char *addr; >> u16 vid; >> u16 ndm_state; >> }; >> #define SWITCHDEV_OBJ_FDB(obj) \ >> container_of(obj, struct switchdev_obj_fdb, obj) >> >> >> then pass struct switchdev_obj *obj down to drivers and in driver, get >> original object by SWITCHDEV_OBJ_* ? > > >Yes, I agree with Jiri, keep the struct switchdev_obj, use it within >each specific struct, and pass struct switchdev * in core funcs rather >than void *. I will cook-up a patch then. Thanks. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 net-next 0/6] net: switchdev: use specific switchdev_obj_* 2015-09-29 16:07 [PATCH v2 net-next 0/6] net: switchdev: use specific switchdev_obj_* Vivien Didelot ` (5 preceding siblings ...) 2015-09-29 16:07 ` [PATCH v2 net-next 6/6] net: switchdev: extract struct switchdev_obj_* Vivien Didelot @ 2015-09-30 4:32 ` David Miller 2015-09-30 10:45 ` Jiri Pirko 7 siblings, 0 replies; 13+ messages in thread From: David Miller @ 2015-09-30 4:32 UTC (permalink / raw) To: vivien.didelot Cc: netdev, linux-kernel, kernel, sfeldma, jiri, f.fainelli, andrew From: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Date: Tue, 29 Sep 2015 12:07:12 -0400 > This patchset changes switchdev add, del, dump operations from this: ... > to something similar to the notifier_call callback of a notifier_block: ... > This allows the caller to pass and expect back a specific switchdev_obj_* > structure (e.g. switchdev_obj_fdb) instead of the generic switchdev_obj one. > > This will simplify pushing the callback function down to the drivers. > > The first 3 patches get rid of the dev parameter of the dump callback, since it > is not always neeeded (e.g. vlan_dump) and some drivers (such as DSA drivers) > may not have easy access to it. > > Patches 4 and 5 implement the change in the switchdev operations and its users. > > Patch 6 extracts the inner switchdev_obj_* structures from switchdev_obj and > removes this last one. > > v2: fix error spotted by kbuild (extra ';' inline switchdev_port_obj_dump). Series applied, thanks Vivien. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 net-next 0/6] net: switchdev: use specific switchdev_obj_* 2015-09-29 16:07 [PATCH v2 net-next 0/6] net: switchdev: use specific switchdev_obj_* Vivien Didelot ` (6 preceding siblings ...) 2015-09-30 4:32 ` [PATCH v2 net-next 0/6] net: switchdev: use specific switchdev_obj_* David Miller @ 2015-09-30 10:45 ` Jiri Pirko 7 siblings, 0 replies; 13+ messages in thread From: Jiri Pirko @ 2015-09-30 10:45 UTC (permalink / raw) To: Vivien Didelot Cc: netdev, linux-kernel, kernel, David S. Miller, Scott Feldman, Florian Fainelli, Andrew Lunn Tue, Sep 29, 2015 at 06:07:12PM CEST, vivien.didelot@savoirfairelinux.com wrote: >This patchset changes switchdev add, del, dump operations from this: > > int (*switchdev_port_obj_add)(struct net_device *dev, > struct switchdev_obj *obj, > struct switchdev_trans *trans); > int (*switchdev_port_obj_del)(struct net_device *dev, > struct switchdev_obj *obj); > int (*switchdev_port_obj_dump)(struct net_device *dev, > struct switchdev_obj *obj); > >to something similar to the notifier_call callback of a notifier_block: > > int (*switchdev_port_obj_add)(struct net_device *dev, > enum switchdev_obj_id id, > const void *obj, > struct switchdev_trans *trans); > int (*switchdev_port_obj_del)(struct net_device *dev, > enum switchdev_obj_id id, > const void *obj); > 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 (e.g. switchdev_obj_fdb) instead of the generic switchdev_obj one. > >This will simplify pushing the callback function down to the drivers. > >The first 3 patches get rid of the dev parameter of the dump callback, since it >is not always neeeded (e.g. vlan_dump) and some drivers (such as DSA drivers) >may not have easy access to it. > >Patches 4 and 5 implement the change in the switchdev operations and its users. > >Patch 6 extracts the inner switchdev_obj_* structures from switchdev_obj and >removes this last one. How about attrs? We should keep objs and attrs api consistent. ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2015-09-30 15:00 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-09-29 16:07 [PATCH v2 net-next 0/6] net: switchdev: use specific switchdev_obj_* Vivien Didelot 2015-09-29 16:07 ` [PATCH v2 net-next 1/6] net: switchdev: remove dev in port_vlan_dump_put Vivien Didelot 2015-09-29 16:07 ` [PATCH v2 net-next 2/6] net: switchdev: move dev in switchdev_fdb_dump Vivien Didelot 2015-09-29 16:07 ` [PATCH v2 net-next 3/6] net: switchdev: remove dev from switchdev_obj cb Vivien Didelot 2015-09-29 16:07 ` [PATCH v2 net-next 4/6] net: switchdev: pass callback to dump operation Vivien Didelot 2015-09-30 10:41 ` Jiri Pirko 2015-09-29 16:07 ` [PATCH v2 net-next 5/6] net: switchdev: abstract object in add/del ops Vivien Didelot 2015-09-29 16:07 ` [PATCH v2 net-next 6/6] net: switchdev: extract struct switchdev_obj_* Vivien Didelot 2015-09-30 10:36 ` Jiri Pirko 2015-09-30 14:58 ` Scott Feldman 2015-09-30 15:00 ` Jiri Pirko 2015-09-30 4:32 ` [PATCH v2 net-next 0/6] net: switchdev: use specific switchdev_obj_* David Miller 2015-09-30 10:45 ` Jiri Pirko
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox