Thread (5 messages) 5 messages, 4 authors, 2015-10-01

Re: [patch net-next] switchdev: bring back switchdev_obj and use it as a generic object param

From: Jiri Pirko <jiri@resnulli.us>
Date: 2015-10-01 06:24:54

Wed, Sep 30, 2015 at 08:00:40PM CEST, vivien.didelot@savoirfairelinux.com wrote:

<snip>
quoted
diff --git a/include/net/switchdev.h b/include/net/switchdev.h
index e11425e..a79a7f0 100644
--- a/include/net/switchdev.h
+++ b/include/net/switchdev.h
@@ -64,15 +64,23 @@ enum switchdev_obj_id {
 	SWITCHDEV_OBJ_PORT_FDB,
 };
 
+struct switchdev_obj {
+};
+
 /* SWITCHDEV_OBJ_PORT_VLAN */
 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;
@@ -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)
Isn't there a collision to have a SWITCHDEV_OBJ_IPV4_FIB enum and a
SWITCHDEV_OBJ_IPV4_FIB macro?

Maybe switchdev will support not only port-objects, but also switch chip
objects, so would it be good to make the distinction between them? e.g.:

* struct switchdev_obj_port_vlan
* SWITCHDEV_OBJ_ID_PORT_VLAN
* SWITCHDEV_OBJ_PORT_VLAN(obj)
* ...

What do you think?
Sounds good. Will make adjustments.

Thanks
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help