2 * include/net/switchdev.h - Switch device API
3 * Copyright (c) 2014 Jiri Pirko <jiri@resnulli.us>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 #ifndef _LINUX_SWITCHDEV_H_
11 #define _LINUX_SWITCHDEV_H_
13 #include <linux/netdevice.h>
14 #include <linux/notifier.h>
16 enum netdev_switch_notifier_type
{
17 NETDEV_SWITCH_FDB_ADD
= 1,
18 NETDEV_SWITCH_FDB_DEL
,
21 struct netdev_switch_notifier_info
{
22 struct net_device
*dev
;
25 struct netdev_switch_notifier_fdb_info
{
26 struct netdev_switch_notifier_info info
; /* must be first */
27 const unsigned char *addr
;
31 static inline struct net_device
*
32 netdev_switch_notifier_info_to_dev(const struct netdev_switch_notifier_info
*info
)
37 #ifdef CONFIG_NET_SWITCHDEV
39 int netdev_switch_parent_id_get(struct net_device
*dev
,
40 struct netdev_phys_item_id
*psid
);
41 int netdev_switch_port_stp_update(struct net_device
*dev
, u8 state
);
42 int register_netdev_switch_notifier(struct notifier_block
*nb
);
43 int unregister_netdev_switch_notifier(struct notifier_block
*nb
);
44 int call_netdev_switch_notifiers(unsigned long val
, struct net_device
*dev
,
45 struct netdev_switch_notifier_info
*info
);
46 int netdev_switch_port_bridge_setlink(struct net_device
*dev
,
47 struct nlmsghdr
*nlh
, u16 flags
);
48 int netdev_switch_port_bridge_dellink(struct net_device
*dev
,
49 struct nlmsghdr
*nlh
, u16 flags
);
50 int ndo_dflt_netdev_switch_port_bridge_dellink(struct net_device
*dev
,
51 struct nlmsghdr
*nlh
, u16 flags
);
52 int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device
*dev
,
53 struct nlmsghdr
*nlh
, u16 flags
);
54 int netdev_switch_fib_ipv4_add(u32 dst
, int dst_len
, struct fib_info
*fi
,
55 u8 tos
, u8 type
, u32 tb_id
);
56 int netdev_switch_fib_ipv4_del(u32 dst
, int dst_len
, struct fib_info
*fi
,
57 u8 tos
, u8 type
, u32 tb_id
);
61 static inline int netdev_switch_parent_id_get(struct net_device
*dev
,
62 struct netdev_phys_item_id
*psid
)
67 static inline int netdev_switch_port_stp_update(struct net_device
*dev
,
73 static inline int register_netdev_switch_notifier(struct notifier_block
*nb
)
78 static inline int unregister_netdev_switch_notifier(struct notifier_block
*nb
)
83 static inline int call_netdev_switch_notifiers(unsigned long val
, struct net_device
*dev
,
84 struct netdev_switch_notifier_info
*info
)
89 static inline int netdev_switch_port_bridge_setlink(struct net_device
*dev
,
96 static inline int netdev_switch_port_bridge_dellink(struct net_device
*dev
,
103 static inline int ndo_dflt_netdev_switch_port_bridge_dellink(struct net_device
*dev
,
104 struct nlmsghdr
*nlh
,
110 static inline int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device
*dev
,
111 struct nlmsghdr
*nlh
,
117 static inline int netdev_switch_fib_ipv4_add(u32 dst
, int dst_len
,
119 u8 tos
, u8 type
, u32 tb_id
)
124 static inline int netdev_switch_fib_ipv4_del(u32 dst
, int dst_len
,
126 u8 tos
, u8 type
, u32 tb_id
)
133 #endif /* _LINUX_SWITCHDEV_H_ */