switchdev.h (62137364e3e8afcc745846c5c67cacf943149073) switchdev.h (4c08c586ff29bda47e3db14da096331d84933f48)
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * include/net/switchdev.h - Switch device API
4 * Copyright (c) 2014-2015 Jiri Pirko <jiri@resnulli.us>
5 * Copyright (c) 2014-2015 Scott Feldman <sfeldma@gmail.com>
6 */
7#ifndef _LINUX_SWITCHDEV_H_
8#define _LINUX_SWITCHDEV_H_
9
10#include <linux/netdevice.h>
11#include <linux/notifier.h>
12#include <linux/list.h>
13#include <net/ip_fib.h>
14
15#define SWITCHDEV_F_NO_RECURSE BIT(0)
16#define SWITCHDEV_F_SKIP_EOPNOTSUPP BIT(1)
17#define SWITCHDEV_F_DEFER BIT(2)
18
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * include/net/switchdev.h - Switch device API
4 * Copyright (c) 2014-2015 Jiri Pirko <jiri@resnulli.us>
5 * Copyright (c) 2014-2015 Scott Feldman <sfeldma@gmail.com>
6 */
7#ifndef _LINUX_SWITCHDEV_H_
8#define _LINUX_SWITCHDEV_H_
9
10#include <linux/netdevice.h>
11#include <linux/notifier.h>
12#include <linux/list.h>
13#include <net/ip_fib.h>
14
15#define SWITCHDEV_F_NO_RECURSE BIT(0)
16#define SWITCHDEV_F_SKIP_EOPNOTSUPP BIT(1)
17#define SWITCHDEV_F_DEFER BIT(2)
18
19struct switchdev_trans {
20 bool ph_prepare;
21};
22
23static inline bool switchdev_trans_ph_prepare(struct switchdev_trans *trans)
24{
25 return trans && trans->ph_prepare;
26}
27
28static inline bool switchdev_trans_ph_commit(struct switchdev_trans *trans)
29{
30 return trans && !trans->ph_prepare;
31}
32
33enum switchdev_attr_id {
34 SWITCHDEV_ATTR_ID_UNDEFINED,
35 SWITCHDEV_ATTR_ID_PORT_STP_STATE,
36 SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS,
37 SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS,
38 SWITCHDEV_ATTR_ID_PORT_MROUTER,
39 SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME,
40 SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING,

--- 49 unchanged lines hidden (view full) ---

90 void *complete_priv;
91 void (*complete)(struct net_device *dev, int err, void *priv);
92};
93
94/* SWITCHDEV_OBJ_ID_PORT_VLAN */
95struct switchdev_obj_port_vlan {
96 struct switchdev_obj obj;
97 u16 flags;
19enum switchdev_attr_id {
20 SWITCHDEV_ATTR_ID_UNDEFINED,
21 SWITCHDEV_ATTR_ID_PORT_STP_STATE,
22 SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS,
23 SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS,
24 SWITCHDEV_ATTR_ID_PORT_MROUTER,
25 SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME,
26 SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING,

--- 49 unchanged lines hidden (view full) ---

76 void *complete_priv;
77 void (*complete)(struct net_device *dev, int err, void *priv);
78};
79
80/* SWITCHDEV_OBJ_ID_PORT_VLAN */
81struct switchdev_obj_port_vlan {
82 struct switchdev_obj obj;
83 u16 flags;
98 u16 vid_begin;
99 u16 vid_end;
84 u16 vid;
100};
101
102#define SWITCHDEV_OBJ_PORT_VLAN(OBJ) \
103 container_of((OBJ), struct switchdev_obj_port_vlan, obj)
104
105/* SWITCHDEV_OBJ_ID_PORT_MDB */
106struct switchdev_obj_port_mdb {
107 struct switchdev_obj obj;

--- 119 unchanged lines hidden (view full) ---

227 u16 vid;
228 u8 added_by_user:1,
229 offloaded:1;
230};
231
232struct switchdev_notifier_port_obj_info {
233 struct switchdev_notifier_info info; /* must be first */
234 const struct switchdev_obj *obj;
85};
86
87#define SWITCHDEV_OBJ_PORT_VLAN(OBJ) \
88 container_of((OBJ), struct switchdev_obj_port_vlan, obj)
89
90/* SWITCHDEV_OBJ_ID_PORT_MDB */
91struct switchdev_obj_port_mdb {
92 struct switchdev_obj obj;

--- 119 unchanged lines hidden (view full) ---

212 u16 vid;
213 u8 added_by_user:1,
214 offloaded:1;
215};
216
217struct switchdev_notifier_port_obj_info {
218 struct switchdev_notifier_info info; /* must be first */
219 const struct switchdev_obj *obj;
235 struct switchdev_trans *trans;
236 bool handled;
237};
238
239struct switchdev_notifier_port_attr_info {
240 struct switchdev_notifier_info info; /* must be first */
241 const struct switchdev_attr *attr;
220 bool handled;
221};
222
223struct switchdev_notifier_port_attr_info {
224 struct switchdev_notifier_info info; /* must be first */
225 const struct switchdev_attr *attr;
242 struct switchdev_trans *trans;
243 bool handled;
244};
245
246static inline struct net_device *
247switchdev_notifier_info_to_dev(const struct switchdev_notifier_info *info)
248{
249 return info->dev;
250}

--- 31 unchanged lines hidden (view full) ---

282 struct net_device *group_dev,
283 bool joining);
284
285int switchdev_handle_port_obj_add(struct net_device *dev,
286 struct switchdev_notifier_port_obj_info *port_obj_info,
287 bool (*check_cb)(const struct net_device *dev),
288 int (*add_cb)(struct net_device *dev,
289 const struct switchdev_obj *obj,
226 bool handled;
227};
228
229static inline struct net_device *
230switchdev_notifier_info_to_dev(const struct switchdev_notifier_info *info)
231{
232 return info->dev;
233}

--- 31 unchanged lines hidden (view full) ---

265 struct net_device *group_dev,
266 bool joining);
267
268int switchdev_handle_port_obj_add(struct net_device *dev,
269 struct switchdev_notifier_port_obj_info *port_obj_info,
270 bool (*check_cb)(const struct net_device *dev),
271 int (*add_cb)(struct net_device *dev,
272 const struct switchdev_obj *obj,
290 struct switchdev_trans *trans,
291 struct netlink_ext_ack *extack));
292int switchdev_handle_port_obj_del(struct net_device *dev,
293 struct switchdev_notifier_port_obj_info *port_obj_info,
294 bool (*check_cb)(const struct net_device *dev),
295 int (*del_cb)(struct net_device *dev,
296 const struct switchdev_obj *obj));
297
298int switchdev_handle_port_attr_set(struct net_device *dev,
299 struct switchdev_notifier_port_attr_info *port_attr_info,
300 bool (*check_cb)(const struct net_device *dev),
301 int (*set_cb)(struct net_device *dev,
302 const struct switchdev_attr *attr,
273 struct netlink_ext_ack *extack));
274int switchdev_handle_port_obj_del(struct net_device *dev,
275 struct switchdev_notifier_port_obj_info *port_obj_info,
276 bool (*check_cb)(const struct net_device *dev),
277 int (*del_cb)(struct net_device *dev,
278 const struct switchdev_obj *obj));
279
280int switchdev_handle_port_attr_set(struct net_device *dev,
281 struct switchdev_notifier_port_attr_info *port_attr_info,
282 bool (*check_cb)(const struct net_device *dev),
283 int (*set_cb)(struct net_device *dev,
284 const struct switchdev_attr *attr,
303 struct switchdev_trans *trans));
285 struct netlink_ext_ack *extack));
304#else
305
306static inline void switchdev_deferred_process(void)
307{
308}
309
310static inline int switchdev_port_attr_set(struct net_device *dev,
311 const struct switchdev_attr *attr)

--- 54 unchanged lines hidden (view full) ---

366}
367
368static inline int
369switchdev_handle_port_obj_add(struct net_device *dev,
370 struct switchdev_notifier_port_obj_info *port_obj_info,
371 bool (*check_cb)(const struct net_device *dev),
372 int (*add_cb)(struct net_device *dev,
373 const struct switchdev_obj *obj,
286#else
287
288static inline void switchdev_deferred_process(void)
289{
290}
291
292static inline int switchdev_port_attr_set(struct net_device *dev,
293 const struct switchdev_attr *attr)

--- 54 unchanged lines hidden (view full) ---

348}
349
350static inline int
351switchdev_handle_port_obj_add(struct net_device *dev,
352 struct switchdev_notifier_port_obj_info *port_obj_info,
353 bool (*check_cb)(const struct net_device *dev),
354 int (*add_cb)(struct net_device *dev,
355 const struct switchdev_obj *obj,
374 struct switchdev_trans *trans,
375 struct netlink_ext_ack *extack))
376{
377 return 0;
378}
379
380static inline int
381switchdev_handle_port_obj_del(struct net_device *dev,
382 struct switchdev_notifier_port_obj_info *port_obj_info,

--- 5 unchanged lines hidden (view full) ---

388}
389
390static inline int
391switchdev_handle_port_attr_set(struct net_device *dev,
392 struct switchdev_notifier_port_attr_info *port_attr_info,
393 bool (*check_cb)(const struct net_device *dev),
394 int (*set_cb)(struct net_device *dev,
395 const struct switchdev_attr *attr,
356 struct netlink_ext_ack *extack))
357{
358 return 0;
359}
360
361static inline int
362switchdev_handle_port_obj_del(struct net_device *dev,
363 struct switchdev_notifier_port_obj_info *port_obj_info,

--- 5 unchanged lines hidden (view full) ---

369}
370
371static inline int
372switchdev_handle_port_attr_set(struct net_device *dev,
373 struct switchdev_notifier_port_attr_info *port_attr_info,
374 bool (*check_cb)(const struct net_device *dev),
375 int (*set_cb)(struct net_device *dev,
376 const struct switchdev_attr *attr,
396 struct switchdev_trans *trans))
377 struct netlink_ext_ack *extack))
397{
398 return 0;
399}
400#endif
401
402#endif /* _LINUX_SWITCHDEV_H_ */
378{
379 return 0;
380}
381#endif
382
383#endif /* _LINUX_SWITCHDEV_H_ */