summaryrefslogtreecommitdiff
path: root/include/net/switchdev.h
diff options
context:
space:
mode:
authorJiri Pirko <jiri@mellanox.com>2015-10-01 12:03:45 +0300
committerDavid S. Miller <davem@davemloft.net>2015-10-03 14:49:39 +0300
commit648b4a995a057187ddd77cdb181e6a0b24ab2959 (patch)
tree28535b6300765d1411c7a7e4a30015de227cb947 /include/net/switchdev.h
parent52ba57cfdc4c90da3bf996dfbe0c5feb731eb477 (diff)
downloadlinux-648b4a995a057187ddd77cdb181e6a0b24ab2959.tar.xz
switchdev: bring back switchdev_obj and use it as a generic object param
Replace "void *obj" with a generic structure. Introduce couple of helpers along that. Signed-off-by: Jiri Pirko <jiri@mellanox.com> Acked-by: Scott Feldman <sfeldma@gmail.com> Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/switchdev.h')
-rw-r--r--include/net/switchdev.h42
1 files changed, 31 insertions, 11 deletions
diff --git a/include/net/switchdev.h b/include/net/switchdev.h
index 8d71fdbaa7a6..3e1bd14cc0ab 100644
--- a/include/net/switchdev.h
+++ b/include/net/switchdev.h
@@ -64,15 +64,23 @@ enum switchdev_obj_id {
SWITCHDEV_OBJ_ID_PORT_FDB,
};
+struct switchdev_obj {
+};
+
/* SWITCHDEV_OBJ_ID_PORT_VLAN */
struct switchdev_obj_port_vlan {
+ struct switchdev_obj obj;
u16 flags;
u16 vid_begin;
u16 vid_end;
};
+#define SWITCHDEV_OBJ_PORT_VLAN(obj) \
+ container_of(obj, struct switchdev_obj_port_vlan, obj)
+
/* SWITCHDEV_OBJ_ID_IPV4_FIB */
struct switchdev_obj_ipv4_fib {
+ struct switchdev_obj obj;
u32 dst;
int dst_len;
struct fib_info *fi;
@@ -82,18 +90,27 @@ struct switchdev_obj_ipv4_fib {
u32 tb_id;
};
+#define SWITCHDEV_OBJ_IPV4_FIB(obj) \
+ container_of(obj, struct switchdev_obj_ipv4_fib, obj)
+
/* SWITCHDEV_OBJ_ID_PORT_FDB */
struct switchdev_obj_port_fdb {
+ struct switchdev_obj obj;
const unsigned char *addr;
u16 vid;
u16 ndm_state;
};
+#define SWITCHDEV_OBJ_PORT_FDB(obj) \
+ container_of(obj, struct switchdev_obj_port_fdb, obj)
+
void switchdev_trans_item_enqueue(struct switchdev_trans *trans,
void *data, void (*destructor)(void const *),
struct switchdev_trans_item *tritem);
void *switchdev_trans_item_dequeue(struct switchdev_trans *trans);
+typedef int switchdev_obj_dump_cb_t(struct switchdev_obj *obj);
+
/**
* struct switchdev_ops - switchdev operations
*
@@ -115,14 +132,15 @@ struct switchdev_ops {
struct switchdev_trans *trans);
int (*switchdev_port_obj_add)(struct net_device *dev,
enum switchdev_obj_id id,
- const void *obj,
+ const struct switchdev_obj *obj,
struct switchdev_trans *trans);
int (*switchdev_port_obj_del)(struct net_device *dev,
enum switchdev_obj_id id,
- const void *obj);
+ const struct switchdev_obj *obj);
int (*switchdev_port_obj_dump)(struct net_device *dev,
- enum switchdev_obj_id id, void *obj,
- int (*cb)(void *obj));
+ enum switchdev_obj_id id,
+ struct switchdev_obj *obj,
+ switchdev_obj_dump_cb_t *cb);
};
enum switchdev_notifier_type {
@@ -153,11 +171,12 @@ int switchdev_port_attr_get(struct net_device *dev,
int switchdev_port_attr_set(struct net_device *dev,
struct switchdev_attr *attr);
int switchdev_port_obj_add(struct net_device *dev, enum switchdev_obj_id id,
- const void *obj);
+ const struct switchdev_obj *obj);
int switchdev_port_obj_del(struct net_device *dev, enum switchdev_obj_id id,
- const void *obj);
+ const struct switchdev_obj *obj);
int switchdev_port_obj_dump(struct net_device *dev, enum switchdev_obj_id id,
- void *obj, int (*cb)(void *obj));
+ struct switchdev_obj *obj,
+ switchdev_obj_dump_cb_t *cb);
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,
@@ -203,21 +222,22 @@ static inline int switchdev_port_attr_set(struct net_device *dev,
static inline int switchdev_port_obj_add(struct net_device *dev,
enum switchdev_obj_id id,
- const void *obj)
+ const struct switchdev_obj *obj)
{
return -EOPNOTSUPP;
}
static inline int switchdev_port_obj_del(struct net_device *dev,
enum switchdev_obj_id id,
- const void *obj)
+ const struct switchdev_obj *obj)
{
return -EOPNOTSUPP;
}
static inline int switchdev_port_obj_dump(struct net_device *dev,
- enum switchdev_obj_id id, void *obj,
- int (*cb)(void *obj))
+ enum switchdev_obj_id id,
+ const struct switchdev_obj *obj,
+ switchdev_obj_dump_cb_t *cb)
{
return -EOPNOTSUPP;
}