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>
20 * struct switchdev_ops - switchdev operations
22 * @swdev_parent_id_get: Called to get an ID of the switch chip this port
23 * is part of. If driver implements this, it indicates that it
24 * represents a port of a switch chip.
26 * @swdev_port_stp_update: Called to notify switch device port of bridge
27 * port STP state change.
29 * @swdev_fib_ipv4_add: Called to add/modify IPv4 route to switch device.
31 * @swdev_fib_ipv4_del: Called to delete IPv4 route from switch device.
34 int (*swdev_parent_id_get
)(struct net_device
*dev
,
35 struct netdev_phys_item_id
*psid
);
36 int (*swdev_port_stp_update
)(struct net_device
*dev
, u8 state
);
37 int (*swdev_fib_ipv4_add
)(struct net_device
*dev
, __be32 dst
,
38 int dst_len
, struct fib_info
*fi
,
39 u8 tos
, u8 type
, u32 nlflags
,
41 int (*swdev_fib_ipv4_del
)(struct net_device
*dev
, __be32 dst
,
42 int dst_len
, struct fib_info
*fi
,
43 u8 tos
, u8 type
, u32 tb_id
);
46 enum netdev_switch_notifier_type
{
47 NETDEV_SWITCH_FDB_ADD
= 1,
48 NETDEV_SWITCH_FDB_DEL
,
51 struct netdev_switch_notifier_info
{
52 struct net_device
*dev
;
55 struct netdev_switch_notifier_fdb_info
{
56 struct netdev_switch_notifier_info info
; /* must be first */
57 const unsigned char *addr
;
61 static inline struct net_device
*
62 netdev_switch_notifier_info_to_dev(const struct netdev_switch_notifier_info
*info
)
67 #ifdef CONFIG_NET_SWITCHDEV
69 int netdev_switch_parent_id_get(struct net_device
*dev
,
70 struct netdev_phys_item_id
*psid
);
71 int netdev_switch_port_stp_update(struct net_device
*dev
, u8 state
);
72 int register_netdev_switch_notifier(struct notifier_block
*nb
);
73 int unregister_netdev_switch_notifier(struct notifier_block
*nb
);
74 int call_netdev_switch_notifiers(unsigned long val
, struct net_device
*dev
,
75 struct netdev_switch_notifier_info
*info
);
76 int netdev_switch_port_bridge_setlink(struct net_device
*dev
,
77 struct nlmsghdr
*nlh
, u16 flags
);
78 int netdev_switch_port_bridge_dellink(struct net_device
*dev
,
79 struct nlmsghdr
*nlh
, u16 flags
);
80 int ndo_dflt_netdev_switch_port_bridge_dellink(struct net_device
*dev
,
81 struct nlmsghdr
*nlh
, u16 flags
);
82 int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device
*dev
,
83 struct nlmsghdr
*nlh
, u16 flags
);
84 int netdev_switch_fib_ipv4_add(u32 dst
, int dst_len
, struct fib_info
*fi
,
85 u8 tos
, u8 type
, u32 nlflags
, u32 tb_id
);
86 int netdev_switch_fib_ipv4_del(u32 dst
, int dst_len
, struct fib_info
*fi
,
87 u8 tos
, u8 type
, u32 tb_id
);
88 void netdev_switch_fib_ipv4_abort(struct fib_info
*fi
);
92 static inline int netdev_switch_parent_id_get(struct net_device
*dev
,
93 struct netdev_phys_item_id
*psid
)
98 static inline int netdev_switch_port_stp_update(struct net_device
*dev
,
104 static inline int register_netdev_switch_notifier(struct notifier_block
*nb
)
109 static inline int unregister_netdev_switch_notifier(struct notifier_block
*nb
)
114 static inline int call_netdev_switch_notifiers(unsigned long val
, struct net_device
*dev
,
115 struct netdev_switch_notifier_info
*info
)
120 static inline int netdev_switch_port_bridge_setlink(struct net_device
*dev
,
121 struct nlmsghdr
*nlh
,
127 static inline int netdev_switch_port_bridge_dellink(struct net_device
*dev
,
128 struct nlmsghdr
*nlh
,
134 static inline int ndo_dflt_netdev_switch_port_bridge_dellink(struct net_device
*dev
,
135 struct nlmsghdr
*nlh
,
141 static inline int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device
*dev
,
142 struct nlmsghdr
*nlh
,
148 static inline int netdev_switch_fib_ipv4_add(u32 dst
, int dst_len
,
151 u32 nlflags
, u32 tb_id
)
156 static inline int netdev_switch_fib_ipv4_del(u32 dst
, int dst_len
,
158 u8 tos
, u8 type
, u32 tb_id
)
163 static inline void netdev_switch_fib_ipv4_abort(struct fib_info
*fi
)
169 #endif /* _LINUX_SWITCHDEV_H_ */