diff options
author | Jiri Pirko <jiri@mellanox.com> | 2015-09-24 10:02:41 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-09-24 22:59:21 -0700 |
commit | 7ea6eb3f56f45cf4babae8b9a7421868e5005f17 (patch) | |
tree | e5e4d816edc8e6254f35ffc689678b9cd59185db /include/net | |
parent | 69f5df491e0becb75d2d795add7481a35218d657 (diff) |
switchdev: introduce transaction item queue for attr_set and obj_add
Now, the memory allocation in prepare/commit state is done separatelly
in each driver (rocker). Introduce the similar mechanism in generic
switchdev code, in form of queue. That can be used not only for memory
allocations, but also for different items. Abort item destruction
is handled as well.
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r-- | include/net/switchdev.h | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/include/net/switchdev.h b/include/net/switchdev.h index 494f51097dc6..1e394f1176b6 100644 --- a/include/net/switchdev.h +++ b/include/net/switchdev.h @@ -1,6 +1,6 @@ /* * include/net/switchdev.h - Switch device API - * Copyright (c) 2014 Jiri Pirko <jiri@resnulli.us> + * Copyright (c) 2014-2015 Jiri Pirko <jiri@resnulli.us> * Copyright (c) 2014-2015 Scott Feldman <sfeldma@gmail.com> * * This program is free software; you can redistribute it and/or modify @@ -13,6 +13,7 @@ #include <linux/netdevice.h> #include <linux/notifier.h> +#include <linux/list.h> #define SWITCHDEV_F_NO_RECURSE BIT(0) @@ -23,6 +24,16 @@ enum switchdev_trans_ph { SWITCHDEV_TRANS_COMMIT, }; +struct switchdev_trans_item { + struct list_head list; + void *data; + void (*destructor)(const void *data); +}; + +struct switchdev_trans { + struct list_head item_list; +}; + enum switchdev_attr_id { SWITCHDEV_ATTR_UNDEFINED, SWITCHDEV_ATTR_PORT_PARENT_ID, @@ -77,6 +88,11 @@ struct switchdev_obj { } u; }; +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); + /** * struct switchdev_ops - switchdev operations * @@ -94,9 +110,11 @@ struct switchdev_ops { 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); + struct switchdev_attr *attr, + struct switchdev_trans *trans); int (*switchdev_port_obj_add)(struct net_device *dev, - struct switchdev_obj *obj); + 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, |