net: switchdev: abstract object in add/del ops

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>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Vivien Didelot 2015-09-29 12:07:17 -04:00 committed by David S. Miller
parent 25f07adc47
commit ab06900230
6 changed files with 99 additions and 117 deletions

View file

@ -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;
}