2 * include/net/switchdev.h - Switch device API
3 * Copyright (c) 2014 Jiri Pirko <jiri@resnulli.us>
4 * Copyright (c) 2014-2015 Scott Feldman <sfeldma@gmail.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 #ifndef _LINUX_SWITCHDEV_H_
12 #define _LINUX_SWITCHDEV_H_
14 #include <linux/netdevice.h>
15 #include <linux/notifier.h>
17 enum netdev_switch_notifier_type
{
18 NETDEV_SWITCH_FDB_ADD
= 1,
19 NETDEV_SWITCH_FDB_DEL
,
22 struct netdev_switch_notifier_info
{
23 struct net_device
*dev
;
26 struct netdev_switch_notifier_fdb_info
{
27 struct netdev_switch_notifier_info info
; /* must be first */
28 const unsigned char *addr
;
32 static inline struct net_device
*
33 netdev_switch_notifier_info_to_dev(const struct netdev_switch_notifier_info
*info
)
38 #ifdef CONFIG_NET_SWITCHDEV
40 int netdev_switch_parent_id_get(struct net_device
*dev
,
41 struct netdev_phys_item_id
*psid
);
42 int netdev_switch_port_stp_update(struct net_device
*dev
, u8 state
);
43 int register_netdev_switch_notifier(struct notifier_block
*nb
);
44 int unregister_netdev_switch_notifier(struct notifier_block
*nb
);
45 int call_netdev_switch_notifiers(unsigned long val
, struct net_device
*dev
,
46 struct netdev_switch_notifier_info
*info
);
47 int netdev_switch_port_bridge_setlink(struct net_device
*dev
,
48 struct nlmsghdr
*nlh
, u16 flags
);
49 int netdev_switch_port_bridge_dellink(struct net_device
*dev
,
50 struct nlmsghdr
*nlh
, u16 flags
);
51 int ndo_dflt_netdev_switch_port_bridge_dellink(struct net_device
*dev
,
52 struct nlmsghdr
*nlh
, u16 flags
);
53 int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device
*dev
,
54 struct nlmsghdr
*nlh
, u16 flags
);
55 int netdev_switch_fib_ipv4_add(u32 dst
, int dst_len
, struct fib_info
*fi
,
56 u8 tos
, u8 type
, u32 nlflags
, u32 tb_id
);
57 int netdev_switch_fib_ipv4_del(u32 dst
, int dst_len
, struct fib_info
*fi
,
58 u8 tos
, u8 type
, u32 tb_id
);
59 void netdev_switch_fib_ipv4_abort(struct fib_info
*fi
);
63 static inline int netdev_switch_parent_id_get(struct net_device
*dev
,
64 struct netdev_phys_item_id
*psid
)
69 static inline int netdev_switch_port_stp_update(struct net_device
*dev
,
75 static inline int register_netdev_switch_notifier(struct notifier_block
*nb
)
80 static inline int unregister_netdev_switch_notifier(struct notifier_block
*nb
)
85 static inline int call_netdev_switch_notifiers(unsigned long val
, struct net_device
*dev
,
86 struct netdev_switch_notifier_info
*info
)
91 static inline int netdev_switch_port_bridge_setlink(struct net_device
*dev
,
98 static inline int netdev_switch_port_bridge_dellink(struct net_device
*dev
,
105 static inline int ndo_dflt_netdev_switch_port_bridge_dellink(struct net_device
*dev
,
106 struct nlmsghdr
*nlh
,
112 static inline int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device
*dev
,
113 struct nlmsghdr
*nlh
,
119 static inline int netdev_switch_fib_ipv4_add(u32 dst
, int dst_len
,
122 u32 nlflags
, u32 tb_id
)
127 static inline int netdev_switch_fib_ipv4_del(u32 dst
, int dst_len
,
129 u8 tos
, u8 type
, u32 tb_id
)
134 static inline void netdev_switch_fib_ipv4_abort(struct fib_info
*fi
)
140 #endif /* _LINUX_SWITCHDEV_H_ */