Blame view
include/net/switchdev.h
8.52 KB
007f790c8 net: introduce ge... |
1 2 |
/* * include/net/switchdev.h - Switch device API |
7ea6eb3f5 switchdev: introd... |
3 |
* Copyright (c) 2014-2015 Jiri Pirko <jiri@resnulli.us> |
f8f214715 switchdev: add ne... |
4 |
* Copyright (c) 2014-2015 Scott Feldman <sfeldma@gmail.com> |
007f790c8 net: introduce ge... |
5 6 7 8 9 10 11 12 13 14 |
* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. */ #ifndef _LINUX_SWITCHDEV_H_ #define _LINUX_SWITCHDEV_H_ #include <linux/netdevice.h> |
03bf0c281 switchdev: introd... |
15 |
#include <linux/notifier.h> |
7ea6eb3f5 switchdev: introd... |
16 |
#include <linux/list.h> |
850d0cbc9 switchdev: remove... |
17 |
#include <net/ip_fib.h> |
03bf0c281 switchdev: introd... |
18 |
|
3094333d9 switchdev: introd... |
19 |
#define SWITCHDEV_F_NO_RECURSE BIT(0) |
464314ea6 switchdev: skip o... |
20 |
#define SWITCHDEV_F_SKIP_EOPNOTSUPP BIT(1) |
0bc05d585 switchdev: allow ... |
21 |
#define SWITCHDEV_F_DEFER BIT(2) |
3094333d9 switchdev: introd... |
22 |
|
7ea6eb3f5 switchdev: introd... |
23 24 25 26 27 28 29 30 |
struct switchdev_trans_item { struct list_head list; void *data; void (*destructor)(const void *data); }; struct switchdev_trans { struct list_head item_list; |
f623ab7f5 switchdev: reduce... |
31 |
bool ph_prepare; |
7ea6eb3f5 switchdev: introd... |
32 |
}; |
8bdb42720 switchdev: add sw... |
33 34 |
static inline bool switchdev_trans_ph_prepare(struct switchdev_trans *trans) { |
f623ab7f5 switchdev: reduce... |
35 |
return trans && trans->ph_prepare; |
8bdb42720 switchdev: add sw... |
36 37 38 39 |
} static inline bool switchdev_trans_ph_commit(struct switchdev_trans *trans) { |
f623ab7f5 switchdev: reduce... |
40 |
return trans && !trans->ph_prepare; |
8bdb42720 switchdev: add sw... |
41 |
} |
3094333d9 switchdev: introd... |
42 |
enum switchdev_attr_id { |
1f8683987 switchdev: rename... |
43 44 45 46 |
SWITCHDEV_ATTR_ID_UNDEFINED, SWITCHDEV_ATTR_ID_PORT_PARENT_ID, SWITCHDEV_ATTR_ID_PORT_STP_STATE, SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS, |
f55ac58ae switchdev: add br... |
47 |
SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME, |
81435c33e switchdev: add br... |
48 |
SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING, |
3094333d9 switchdev: introd... |
49 50 51 |
}; struct switchdev_attr { |
6ff64f6f9 switchdev: Pass o... |
52 |
struct net_device *orig_dev; |
3094333d9 switchdev: introd... |
53 |
enum switchdev_attr_id id; |
3094333d9 switchdev: introd... |
54 |
u32 flags; |
7ceb2afbd switchdev: Adding... |
55 56 |
void *complete_priv; void (*complete)(struct net_device *dev, int err, void *priv); |
f8e20a9f8 switchdev: conver... |
57 58 |
union { struct netdev_phys_item_id ppid; /* PORT_PARENT_ID */ |
356360625 switchdev: conver... |
59 |
u8 stp_state; /* PORT_STP_STATE */ |
6004c8671 switchdev: add br... |
60 |
unsigned long brport_flags; /* PORT_BRIDGE_FLAGS */ |
eabfdda93 net: switchdev: c... |
61 |
clock_t ageing_time; /* BRIDGE_AGEING_TIME */ |
81435c33e switchdev: add br... |
62 |
bool vlan_filtering; /* BRIDGE_VLAN_FILTERING */ |
42275bd8f switchdev: don't ... |
63 |
} u; |
3094333d9 switchdev: introd... |
64 |
}; |
491d0f153 switchdev: introd... |
65 |
enum switchdev_obj_id { |
57d80838d switchdev: rename... |
66 67 |
SWITCHDEV_OBJ_ID_UNDEFINED, SWITCHDEV_OBJ_ID_PORT_VLAN, |
57d80838d switchdev: rename... |
68 |
SWITCHDEV_OBJ_ID_PORT_FDB, |
4d41e1259 switchdev: Adding... |
69 |
SWITCHDEV_OBJ_ID_PORT_MDB, |
491d0f153 switchdev: introd... |
70 |
}; |
648b4a995 switchdev: bring ... |
71 |
struct switchdev_obj { |
6ff64f6f9 switchdev: Pass o... |
72 |
struct net_device *orig_dev; |
9e8f4a548 switchdev: push o... |
73 |
enum switchdev_obj_id id; |
4d429c5dd switchdev: introd... |
74 |
u32 flags; |
7ceb2afbd switchdev: Adding... |
75 76 |
void *complete_priv; void (*complete)(struct net_device *dev, int err, void *priv); |
648b4a995 switchdev: bring ... |
77 |
}; |
57d80838d switchdev: rename... |
78 |
/* SWITCHDEV_OBJ_ID_PORT_VLAN */ |
8f24f3095 switchdev: rename... |
79 |
struct switchdev_obj_port_vlan { |
648b4a995 switchdev: bring ... |
80 |
struct switchdev_obj obj; |
44bbcf5c4 net: switchdev: e... |
81 82 83 84 |
u16 flags; u16 vid_begin; u16 vid_end; }; |
648b4a995 switchdev: bring ... |
85 86 |
#define SWITCHDEV_OBJ_PORT_VLAN(obj) \ container_of(obj, struct switchdev_obj_port_vlan, obj) |
57d80838d switchdev: rename... |
87 |
/* SWITCHDEV_OBJ_ID_PORT_FDB */ |
52ba57cfd switchdev: rename... |
88 |
struct switchdev_obj_port_fdb { |
648b4a995 switchdev: bring ... |
89 |
struct switchdev_obj obj; |
850d0cbc9 switchdev: remove... |
90 |
unsigned char addr[ETH_ALEN]; |
44bbcf5c4 net: switchdev: e... |
91 92 |
u16 vid; u16 ndm_state; |
491d0f153 switchdev: introd... |
93 |
}; |
648b4a995 switchdev: bring ... |
94 95 |
#define SWITCHDEV_OBJ_PORT_FDB(obj) \ container_of(obj, struct switchdev_obj_port_fdb, obj) |
4d41e1259 switchdev: Adding... |
96 97 98 99 100 101 102 103 104 |
/* SWITCHDEV_OBJ_ID_PORT_MDB */ struct switchdev_obj_port_mdb { struct switchdev_obj obj; unsigned char addr[ETH_ALEN]; u16 vid; }; #define SWITCHDEV_OBJ_PORT_MDB(obj) \ container_of(obj, struct switchdev_obj_port_mdb, obj) |
7ea6eb3f5 switchdev: introd... |
105 106 107 108 |
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); |
648b4a995 switchdev: bring ... |
109 |
typedef int switchdev_obj_dump_cb_t(struct switchdev_obj *obj); |
4170604fe switchdev: add sw... |
110 111 112 |
/** * struct switchdev_ops - switchdev operations * |
3094333d9 switchdev: introd... |
113 114 115 116 |
* @switchdev_port_attr_get: Get a port attribute (see switchdev_attr). * * @switchdev_port_attr_set: Set a port attribute (see switchdev_attr). * |
44bbcf5c4 net: switchdev: e... |
117 |
* @switchdev_port_obj_add: Add an object to port (see switchdev_obj_*). |
491d0f153 switchdev: introd... |
118 |
* |
44bbcf5c4 net: switchdev: e... |
119 |
* @switchdev_port_obj_del: Delete an object from port (see switchdev_obj_*). |
45d4122ca switchdev: add su... |
120 |
* |
44bbcf5c4 net: switchdev: e... |
121 |
* @switchdev_port_obj_dump: Dump port objects (see switchdev_obj_*). |
4170604fe switchdev: add sw... |
122 |
*/ |
9d47c0a2d switchdev: s/swde... |
123 |
struct switchdev_ops { |
3094333d9 switchdev: introd... |
124 125 126 |
int (*switchdev_port_attr_get)(struct net_device *dev, struct switchdev_attr *attr); int (*switchdev_port_attr_set)(struct net_device *dev, |
f7fadf304 switchdev: make s... |
127 |
const struct switchdev_attr *attr, |
7ea6eb3f5 switchdev: introd... |
128 |
struct switchdev_trans *trans); |
491d0f153 switchdev: introd... |
129 |
int (*switchdev_port_obj_add)(struct net_device *dev, |
648b4a995 switchdev: bring ... |
130 |
const struct switchdev_obj *obj, |
7ea6eb3f5 switchdev: introd... |
131 |
struct switchdev_trans *trans); |
491d0f153 switchdev: introd... |
132 |
int (*switchdev_port_obj_del)(struct net_device *dev, |
648b4a995 switchdev: bring ... |
133 |
const struct switchdev_obj *obj); |
45d4122ca switchdev: add su... |
134 |
int (*switchdev_port_obj_dump)(struct net_device *dev, |
648b4a995 switchdev: bring ... |
135 136 |
struct switchdev_obj *obj, switchdev_obj_dump_cb_t *cb); |
4170604fe switchdev: add sw... |
137 |
}; |
ebb9a03a5 switchdev: s/netd... |
138 139 140 |
enum switchdev_notifier_type { SWITCHDEV_FDB_ADD = 1, SWITCHDEV_FDB_DEL, |
3aeb66176 net: replace br_f... |
141 |
}; |
ebb9a03a5 switchdev: s/netd... |
142 |
struct switchdev_notifier_info { |
03bf0c281 switchdev: introd... |
143 144 |
struct net_device *dev; }; |
ebb9a03a5 switchdev: s/netd... |
145 146 |
struct switchdev_notifier_fdb_info { struct switchdev_notifier_info info; /* must be first */ |
3aeb66176 net: replace br_f... |
147 148 149 |
const unsigned char *addr; u16 vid; }; |
03bf0c281 switchdev: introd... |
150 |
static inline struct net_device * |
ebb9a03a5 switchdev: s/netd... |
151 |
switchdev_notifier_info_to_dev(const struct switchdev_notifier_info *info) |
03bf0c281 switchdev: introd... |
152 153 154 |
{ return info->dev; } |
007f790c8 net: introduce ge... |
155 156 |
#ifdef CONFIG_NET_SWITCHDEV |
793f40147 switchdev: introd... |
157 |
void switchdev_deferred_process(void); |
3094333d9 switchdev: introd... |
158 159 160 |
int switchdev_port_attr_get(struct net_device *dev, struct switchdev_attr *attr); int switchdev_port_attr_set(struct net_device *dev, |
f7fadf304 switchdev: make s... |
161 |
const struct switchdev_attr *attr); |
9e8f4a548 switchdev: push o... |
162 |
int switchdev_port_obj_add(struct net_device *dev, |
648b4a995 switchdev: bring ... |
163 |
const struct switchdev_obj *obj); |
9e8f4a548 switchdev: push o... |
164 |
int switchdev_port_obj_del(struct net_device *dev, |
648b4a995 switchdev: bring ... |
165 |
const struct switchdev_obj *obj); |
9e8f4a548 switchdev: push o... |
166 |
int switchdev_port_obj_dump(struct net_device *dev, struct switchdev_obj *obj, |
648b4a995 switchdev: bring ... |
167 |
switchdev_obj_dump_cb_t *cb); |
ebb9a03a5 switchdev: s/netd... |
168 169 170 171 |
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, struct switchdev_notifier_info *info); |
8793d0a66 switchdev: add ne... |
172 173 174 |
int switchdev_port_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq, struct net_device *dev, u32 filter_mask, int nlflags); |
ebb9a03a5 switchdev: s/netd... |
175 176 177 178 |
int switchdev_port_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags); int switchdev_port_bridge_dellink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags); |
45d4122ca switchdev: add su... |
179 180 181 182 183 184 185 186 |
int switchdev_port_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev, const unsigned char *addr, u16 vid, u16 nlm_flags); int switchdev_port_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev, const unsigned char *addr, u16 vid); int switchdev_port_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb, struct net_device *dev, |
d297653dd rtnetlink: fdb du... |
187 |
struct net_device *filter_dev, int *idx); |
1a3b2ec93 switchdev: add of... |
188 189 190 |
void switchdev_port_fwd_mark_set(struct net_device *dev, struct net_device *group_dev, bool joining); |
5e8d90497 switchdev: add IP... |
191 |
|
8438884d4 net/switchdev: Ex... |
192 193 |
bool switchdev_port_same_parent_id(struct net_device *a, struct net_device *b); |
007f790c8 net: introduce ge... |
194 |
#else |
793f40147 switchdev: introd... |
195 196 197 |
static inline void switchdev_deferred_process(void) { } |
3094333d9 switchdev: introd... |
198 199 200 201 202 203 204 |
static inline int switchdev_port_attr_get(struct net_device *dev, struct switchdev_attr *attr) { return -EOPNOTSUPP; } static inline int switchdev_port_attr_set(struct net_device *dev, |
f7fadf304 switchdev: make s... |
205 |
const struct switchdev_attr *attr) |
3094333d9 switchdev: introd... |
206 207 208 |
{ return -EOPNOTSUPP; } |
491d0f153 switchdev: introd... |
209 |
static inline int switchdev_port_obj_add(struct net_device *dev, |
648b4a995 switchdev: bring ... |
210 |
const struct switchdev_obj *obj) |
491d0f153 switchdev: introd... |
211 212 213 214 215 |
{ return -EOPNOTSUPP; } static inline int switchdev_port_obj_del(struct net_device *dev, |
648b4a995 switchdev: bring ... |
216 |
const struct switchdev_obj *obj) |
491d0f153 switchdev: introd... |
217 218 219 |
{ return -EOPNOTSUPP; } |
45d4122ca switchdev: add su... |
220 |
static inline int switchdev_port_obj_dump(struct net_device *dev, |
648b4a995 switchdev: bring ... |
221 222 |
const struct switchdev_obj *obj, switchdev_obj_dump_cb_t *cb) |
45d4122ca switchdev: add su... |
223 224 225 |
{ return -EOPNOTSUPP; } |
ebb9a03a5 switchdev: s/netd... |
226 |
static inline int register_switchdev_notifier(struct notifier_block *nb) |
03bf0c281 switchdev: introd... |
227 228 229 |
{ return 0; } |
ebb9a03a5 switchdev: s/netd... |
230 |
static inline int unregister_switchdev_notifier(struct notifier_block *nb) |
03bf0c281 switchdev: introd... |
231 232 233 |
{ return 0; } |
ebb9a03a5 switchdev: s/netd... |
234 235 236 |
static inline int call_switchdev_notifiers(unsigned long val, struct net_device *dev, struct switchdev_notifier_info *info) |
03bf0c281 switchdev: introd... |
237 238 239 |
{ return NOTIFY_DONE; } |
8793d0a66 switchdev: add ne... |
240 241 242 243 244 245 |
static inline int switchdev_port_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq, struct net_device *dev, u32 filter_mask, int nlflags) { return -EOPNOTSUPP; } |
ebb9a03a5 switchdev: s/netd... |
246 247 248 |
static inline int switchdev_port_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags) |
8a44dbb20 swdevice: add new... |
249 250 251 |
{ return -EOPNOTSUPP; } |
ebb9a03a5 switchdev: s/netd... |
252 253 254 |
static inline int switchdev_port_bridge_dellink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags) |
8a44dbb20 swdevice: add new... |
255 256 257 |
{ return -EOPNOTSUPP; } |
45d4122ca switchdev: add su... |
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
static inline int switchdev_port_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev, const unsigned char *addr, u16 vid, u16 nlm_flags) { return -EOPNOTSUPP; } static inline int switchdev_port_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev, const unsigned char *addr, u16 vid) { return -EOPNOTSUPP; } static inline int switchdev_port_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb, struct net_device *dev, struct net_device *filter_dev, |
d297653dd rtnetlink: fdb du... |
277 |
int *idx) |
45d4122ca switchdev: add su... |
278 |
{ |
dd19bde36 switchdev: Fix re... |
279 |
return *idx; |
45d4122ca switchdev: add su... |
280 |
} |
8438884d4 net/switchdev: Ex... |
281 282 283 284 285 |
static inline bool switchdev_port_same_parent_id(struct net_device *a, struct net_device *b) { return false; } |
007f790c8 net: introduce ge... |
286 287 288 |
#endif #endif /* _LINUX_SWITCHDEV_H_ */ |