diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2015-11-23 03:04:05 -0500 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2015-11-23 03:04:05 -0500 |
commit | 92907cbbef8625bb3998d1eb385fc88f23c97a3f (patch) | |
tree | 15626ff9287e37c3cb81c7286d6db5a7fd77c854 /include/net/switchdev.h | |
parent | 15fbfccfe92c62ae8d1ecc647c44157ed01ac02e (diff) | |
parent | 1ec218373b8ebda821aec00bb156a9c94fad9cd4 (diff) |
Merge tag 'v4.4-rc2' into drm-intel-next-queued
Linux 4.4-rc2
Backmerge to get at
commit 1b0e3a049efe471c399674fd954500ce97438d30
Author: Imre Deak <imre.deak@intel.com>
Date: Thu Nov 5 23:04:11 2015 +0200
drm/i915/skl: disable display side power well support for now
so that we can proplery re-eanble skl power wells in -next.
Conflicts are just adjacent lines changed, except for intel_fbdev.c
where we need to interleave the changs. Nothing nefarious.
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Diffstat (limited to 'include/net/switchdev.h')
-rw-r--r-- | include/net/switchdev.h | 163 |
1 files changed, 107 insertions, 56 deletions
diff --git a/include/net/switchdev.h b/include/net/switchdev.h index 319baab3b48e..1d22ce9f352e 100644 --- a/include/net/switchdev.h +++ b/include/net/switchdev.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * include/net/switchdev.h - Switch device API | 2 | * include/net/switchdev.h - Switch device API |
3 | * Copyright (c) 2014 Jiri Pirko <jiri@resnulli.us> | 3 | * Copyright (c) 2014-2015 Jiri Pirko <jiri@resnulli.us> |
4 | * Copyright (c) 2014-2015 Scott Feldman <sfeldma@gmail.com> | 4 | * Copyright (c) 2014-2015 Scott Feldman <sfeldma@gmail.com> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
@@ -13,70 +13,109 @@ | |||
13 | 13 | ||
14 | #include <linux/netdevice.h> | 14 | #include <linux/netdevice.h> |
15 | #include <linux/notifier.h> | 15 | #include <linux/notifier.h> |
16 | #include <linux/list.h> | ||
17 | #include <net/ip_fib.h> | ||
16 | 18 | ||
17 | #define SWITCHDEV_F_NO_RECURSE BIT(0) | 19 | #define SWITCHDEV_F_NO_RECURSE BIT(0) |
20 | #define SWITCHDEV_F_SKIP_EOPNOTSUPP BIT(1) | ||
21 | #define SWITCHDEV_F_DEFER BIT(2) | ||
18 | 22 | ||
19 | enum switchdev_trans { | 23 | struct switchdev_trans_item { |
20 | SWITCHDEV_TRANS_NONE, | 24 | struct list_head list; |
21 | SWITCHDEV_TRANS_PREPARE, | 25 | void *data; |
22 | SWITCHDEV_TRANS_ABORT, | 26 | void (*destructor)(const void *data); |
23 | SWITCHDEV_TRANS_COMMIT, | ||
24 | }; | 27 | }; |
25 | 28 | ||
29 | struct switchdev_trans { | ||
30 | struct list_head item_list; | ||
31 | bool ph_prepare; | ||
32 | }; | ||
33 | |||
34 | static inline bool switchdev_trans_ph_prepare(struct switchdev_trans *trans) | ||
35 | { | ||
36 | return trans && trans->ph_prepare; | ||
37 | } | ||
38 | |||
39 | static inline bool switchdev_trans_ph_commit(struct switchdev_trans *trans) | ||
40 | { | ||
41 | return trans && !trans->ph_prepare; | ||
42 | } | ||
43 | |||
26 | enum switchdev_attr_id { | 44 | enum switchdev_attr_id { |
27 | SWITCHDEV_ATTR_UNDEFINED, | 45 | SWITCHDEV_ATTR_ID_UNDEFINED, |
28 | SWITCHDEV_ATTR_PORT_PARENT_ID, | 46 | SWITCHDEV_ATTR_ID_PORT_PARENT_ID, |
29 | SWITCHDEV_ATTR_PORT_STP_STATE, | 47 | SWITCHDEV_ATTR_ID_PORT_STP_STATE, |
30 | SWITCHDEV_ATTR_PORT_BRIDGE_FLAGS, | 48 | SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS, |
49 | SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME, | ||
31 | }; | 50 | }; |
32 | 51 | ||
33 | struct switchdev_attr { | 52 | struct switchdev_attr { |
34 | enum switchdev_attr_id id; | 53 | enum switchdev_attr_id id; |
35 | enum switchdev_trans trans; | ||
36 | u32 flags; | 54 | u32 flags; |
37 | union { | 55 | union { |
38 | struct netdev_phys_item_id ppid; /* PORT_PARENT_ID */ | 56 | struct netdev_phys_item_id ppid; /* PORT_PARENT_ID */ |
39 | u8 stp_state; /* PORT_STP_STATE */ | 57 | u8 stp_state; /* PORT_STP_STATE */ |
40 | unsigned long brport_flags; /* PORT_BRIDGE_FLAGS */ | 58 | unsigned long brport_flags; /* PORT_BRIDGE_FLAGS */ |
59 | u32 ageing_time; /* BRIDGE_AGEING_TIME */ | ||
41 | } u; | 60 | } u; |
42 | }; | 61 | }; |
43 | 62 | ||
44 | struct fib_info; | ||
45 | |||
46 | enum switchdev_obj_id { | 63 | enum switchdev_obj_id { |
47 | SWITCHDEV_OBJ_UNDEFINED, | 64 | SWITCHDEV_OBJ_ID_UNDEFINED, |
48 | SWITCHDEV_OBJ_PORT_VLAN, | 65 | SWITCHDEV_OBJ_ID_PORT_VLAN, |
49 | SWITCHDEV_OBJ_IPV4_FIB, | 66 | SWITCHDEV_OBJ_ID_IPV4_FIB, |
50 | SWITCHDEV_OBJ_PORT_FDB, | 67 | SWITCHDEV_OBJ_ID_PORT_FDB, |
51 | }; | 68 | }; |
52 | 69 | ||
53 | struct switchdev_obj { | 70 | struct switchdev_obj { |
54 | enum switchdev_obj_id id; | 71 | enum switchdev_obj_id id; |
55 | enum switchdev_trans trans; | 72 | u32 flags; |
56 | int (*cb)(struct net_device *dev, struct switchdev_obj *obj); | 73 | }; |
57 | union { | 74 | |
58 | struct switchdev_obj_vlan { /* PORT_VLAN */ | 75 | /* SWITCHDEV_OBJ_ID_PORT_VLAN */ |
59 | u16 flags; | 76 | struct switchdev_obj_port_vlan { |
60 | u16 vid_begin; | 77 | struct switchdev_obj obj; |
61 | u16 vid_end; | 78 | u16 flags; |
62 | } vlan; | 79 | u16 vid_begin; |
63 | struct switchdev_obj_ipv4_fib { /* IPV4_FIB */ | 80 | u16 vid_end; |
64 | u32 dst; | 81 | }; |
65 | int dst_len; | 82 | |
66 | struct fib_info *fi; | 83 | #define SWITCHDEV_OBJ_PORT_VLAN(obj) \ |
67 | u8 tos; | 84 | container_of(obj, struct switchdev_obj_port_vlan, obj) |
68 | u8 type; | 85 | |
69 | u32 nlflags; | 86 | /* SWITCHDEV_OBJ_ID_IPV4_FIB */ |
70 | u32 tb_id; | 87 | struct switchdev_obj_ipv4_fib { |
71 | } ipv4_fib; | 88 | struct switchdev_obj obj; |
72 | struct switchdev_obj_fdb { /* PORT_FDB */ | 89 | u32 dst; |
73 | const unsigned char *addr; | 90 | int dst_len; |
74 | u16 vid; | 91 | struct fib_info fi; |
75 | u16 ndm_state; | 92 | u8 tos; |
76 | } fdb; | 93 | u8 type; |
77 | } u; | 94 | u32 nlflags; |
95 | u32 tb_id; | ||
96 | }; | ||
97 | |||
98 | #define SWITCHDEV_OBJ_IPV4_FIB(obj) \ | ||
99 | container_of(obj, struct switchdev_obj_ipv4_fib, obj) | ||
100 | |||
101 | /* SWITCHDEV_OBJ_ID_PORT_FDB */ | ||
102 | struct switchdev_obj_port_fdb { | ||
103 | struct switchdev_obj obj; | ||
104 | unsigned char addr[ETH_ALEN]; | ||
105 | u16 vid; | ||
106 | u16 ndm_state; | ||
78 | }; | 107 | }; |
79 | 108 | ||
109 | #define SWITCHDEV_OBJ_PORT_FDB(obj) \ | ||
110 | container_of(obj, struct switchdev_obj_port_fdb, obj) | ||
111 | |||
112 | void switchdev_trans_item_enqueue(struct switchdev_trans *trans, | ||
113 | void *data, void (*destructor)(void const *), | ||
114 | struct switchdev_trans_item *tritem); | ||
115 | void *switchdev_trans_item_dequeue(struct switchdev_trans *trans); | ||
116 | |||
117 | typedef int switchdev_obj_dump_cb_t(struct switchdev_obj *obj); | ||
118 | |||
80 | /** | 119 | /** |
81 | * struct switchdev_ops - switchdev operations | 120 | * struct switchdev_ops - switchdev operations |
82 | * | 121 | * |
@@ -84,23 +123,26 @@ struct switchdev_obj { | |||
84 | * | 123 | * |
85 | * @switchdev_port_attr_set: Set a port attribute (see switchdev_attr). | 124 | * @switchdev_port_attr_set: Set a port attribute (see switchdev_attr). |
86 | * | 125 | * |
87 | * @switchdev_port_obj_add: Add an object to port (see switchdev_obj). | 126 | * @switchdev_port_obj_add: Add an object to port (see switchdev_obj_*). |
88 | * | 127 | * |
89 | * @switchdev_port_obj_del: Delete an object from port (see switchdev_obj). | 128 | * @switchdev_port_obj_del: Delete an object from port (see switchdev_obj_*). |
90 | * | 129 | * |
91 | * @switchdev_port_obj_dump: Dump port objects (see switchdev_obj). | 130 | * @switchdev_port_obj_dump: Dump port objects (see switchdev_obj_*). |
92 | */ | 131 | */ |
93 | struct switchdev_ops { | 132 | struct switchdev_ops { |
94 | int (*switchdev_port_attr_get)(struct net_device *dev, | 133 | int (*switchdev_port_attr_get)(struct net_device *dev, |
95 | struct switchdev_attr *attr); | 134 | struct switchdev_attr *attr); |
96 | int (*switchdev_port_attr_set)(struct net_device *dev, | 135 | int (*switchdev_port_attr_set)(struct net_device *dev, |
97 | struct switchdev_attr *attr); | 136 | const struct switchdev_attr *attr, |
137 | struct switchdev_trans *trans); | ||
98 | int (*switchdev_port_obj_add)(struct net_device *dev, | 138 | int (*switchdev_port_obj_add)(struct net_device *dev, |
99 | struct switchdev_obj *obj); | 139 | const struct switchdev_obj *obj, |
140 | struct switchdev_trans *trans); | ||
100 | int (*switchdev_port_obj_del)(struct net_device *dev, | 141 | int (*switchdev_port_obj_del)(struct net_device *dev, |
101 | struct switchdev_obj *obj); | 142 | const struct switchdev_obj *obj); |
102 | int (*switchdev_port_obj_dump)(struct net_device *dev, | 143 | int (*switchdev_port_obj_dump)(struct net_device *dev, |
103 | struct switchdev_obj *obj); | 144 | struct switchdev_obj *obj, |
145 | switchdev_obj_dump_cb_t *cb); | ||
104 | }; | 146 | }; |
105 | 147 | ||
106 | enum switchdev_notifier_type { | 148 | enum switchdev_notifier_type { |
@@ -126,13 +168,17 @@ switchdev_notifier_info_to_dev(const struct switchdev_notifier_info *info) | |||
126 | 168 | ||
127 | #ifdef CONFIG_NET_SWITCHDEV | 169 | #ifdef CONFIG_NET_SWITCHDEV |
128 | 170 | ||
171 | void switchdev_deferred_process(void); | ||
129 | int switchdev_port_attr_get(struct net_device *dev, | 172 | int switchdev_port_attr_get(struct net_device *dev, |
130 | struct switchdev_attr *attr); | 173 | struct switchdev_attr *attr); |
131 | int switchdev_port_attr_set(struct net_device *dev, | 174 | int switchdev_port_attr_set(struct net_device *dev, |
132 | struct switchdev_attr *attr); | 175 | const struct switchdev_attr *attr); |
133 | int switchdev_port_obj_add(struct net_device *dev, struct switchdev_obj *obj); | 176 | int switchdev_port_obj_add(struct net_device *dev, |
134 | int switchdev_port_obj_del(struct net_device *dev, struct switchdev_obj *obj); | 177 | const struct switchdev_obj *obj); |
135 | int switchdev_port_obj_dump(struct net_device *dev, struct switchdev_obj *obj); | 178 | int switchdev_port_obj_del(struct net_device *dev, |
179 | const struct switchdev_obj *obj); | ||
180 | int switchdev_port_obj_dump(struct net_device *dev, struct switchdev_obj *obj, | ||
181 | switchdev_obj_dump_cb_t *cb); | ||
136 | int register_switchdev_notifier(struct notifier_block *nb); | 182 | int register_switchdev_notifier(struct notifier_block *nb); |
137 | int unregister_switchdev_notifier(struct notifier_block *nb); | 183 | int unregister_switchdev_notifier(struct notifier_block *nb); |
138 | int call_switchdev_notifiers(unsigned long val, struct net_device *dev, | 184 | int call_switchdev_notifiers(unsigned long val, struct net_device *dev, |
@@ -164,6 +210,10 @@ void switchdev_port_fwd_mark_set(struct net_device *dev, | |||
164 | 210 | ||
165 | #else | 211 | #else |
166 | 212 | ||
213 | static inline void switchdev_deferred_process(void) | ||
214 | { | ||
215 | } | ||
216 | |||
167 | static inline int switchdev_port_attr_get(struct net_device *dev, | 217 | static inline int switchdev_port_attr_get(struct net_device *dev, |
168 | struct switchdev_attr *attr) | 218 | struct switchdev_attr *attr) |
169 | { | 219 | { |
@@ -171,25 +221,26 @@ static inline int switchdev_port_attr_get(struct net_device *dev, | |||
171 | } | 221 | } |
172 | 222 | ||
173 | static inline int switchdev_port_attr_set(struct net_device *dev, | 223 | static inline int switchdev_port_attr_set(struct net_device *dev, |
174 | struct switchdev_attr *attr) | 224 | const struct switchdev_attr *attr) |
175 | { | 225 | { |
176 | return -EOPNOTSUPP; | 226 | return -EOPNOTSUPP; |
177 | } | 227 | } |
178 | 228 | ||
179 | static inline int switchdev_port_obj_add(struct net_device *dev, | 229 | static inline int switchdev_port_obj_add(struct net_device *dev, |
180 | struct switchdev_obj *obj) | 230 | const struct switchdev_obj *obj) |
181 | { | 231 | { |
182 | return -EOPNOTSUPP; | 232 | return -EOPNOTSUPP; |
183 | } | 233 | } |
184 | 234 | ||
185 | static inline int switchdev_port_obj_del(struct net_device *dev, | 235 | static inline int switchdev_port_obj_del(struct net_device *dev, |
186 | struct switchdev_obj *obj) | 236 | const struct switchdev_obj *obj) |
187 | { | 237 | { |
188 | return -EOPNOTSUPP; | 238 | return -EOPNOTSUPP; |
189 | } | 239 | } |
190 | 240 | ||
191 | static inline int switchdev_port_obj_dump(struct net_device *dev, | 241 | static inline int switchdev_port_obj_dump(struct net_device *dev, |
192 | struct switchdev_obj *obj) | 242 | const struct switchdev_obj *obj, |
243 | switchdev_obj_dump_cb_t *cb) | ||
193 | { | 244 | { |
194 | return -EOPNOTSUPP; | 245 | return -EOPNOTSUPP; |
195 | } | 246 | } |
@@ -272,7 +323,7 @@ static inline int switchdev_port_fdb_dump(struct sk_buff *skb, | |||
272 | struct net_device *filter_dev, | 323 | struct net_device *filter_dev, |
273 | int idx) | 324 | int idx) |
274 | { | 325 | { |
275 | return -EOPNOTSUPP; | 326 | return idx; |
276 | } | 327 | } |
277 | 328 | ||
278 | static inline void switchdev_port_fwd_mark_set(struct net_device *dev, | 329 | static inline void switchdev_port_fwd_mark_set(struct net_device *dev, |