blob: 8d2ac663325a191b02aa2bd601e226933270063a [file] [log] [blame]
Jiri Pirko007f7902014-11-28 14:34:17 +01001/*
2 * include/net/switchdev.h - Switch device API
3 * Copyright (c) 2014 Jiri Pirko <jiri@resnulli.us>
4 *
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.
9 */
10#ifndef _LINUX_SWITCHDEV_H_
11#define _LINUX_SWITCHDEV_H_
12
13#include <linux/netdevice.h>
Jiri Pirko03bf0c22015-01-15 23:49:36 +010014#include <linux/notifier.h>
15
Jiri Pirko3aeb6612015-01-15 23:49:37 +010016enum netdev_switch_notifier_type {
17 NETDEV_SWITCH_FDB_ADD = 1,
18 NETDEV_SWITCH_FDB_DEL,
19};
20
Jiri Pirko03bf0c22015-01-15 23:49:36 +010021struct netdev_switch_notifier_info {
22 struct net_device *dev;
23};
24
Jiri Pirko3aeb6612015-01-15 23:49:37 +010025struct netdev_switch_notifier_fdb_info {
26 struct netdev_switch_notifier_info info; /* must be first */
27 const unsigned char *addr;
28 u16 vid;
29};
30
Jiri Pirko03bf0c22015-01-15 23:49:36 +010031static inline struct net_device *
32netdev_switch_notifier_info_to_dev(const struct netdev_switch_notifier_info *info)
33{
34 return info->dev;
35}
Jiri Pirko007f7902014-11-28 14:34:17 +010036
37#ifdef CONFIG_NET_SWITCHDEV
38
39int netdev_switch_parent_id_get(struct net_device *dev,
40 struct netdev_phys_item_id *psid);
Scott Feldman38dcf352014-11-28 14:34:20 +010041int netdev_switch_port_stp_update(struct net_device *dev, u8 state);
Jiri Pirko03bf0c22015-01-15 23:49:36 +010042int register_netdev_switch_notifier(struct notifier_block *nb);
43int unregister_netdev_switch_notifier(struct notifier_block *nb);
44int call_netdev_switch_notifiers(unsigned long val, struct net_device *dev,
45 struct netdev_switch_notifier_info *info);
Roopa Prabhu8a44dbb2015-01-29 22:40:13 -080046int netdev_switch_port_bridge_setlink(struct net_device *dev,
47 struct nlmsghdr *nlh, u16 flags);
48int netdev_switch_port_bridge_dellink(struct net_device *dev,
49 struct nlmsghdr *nlh, u16 flags);
50int ndo_dflt_netdev_switch_port_bridge_dellink(struct net_device *dev,
51 struct nlmsghdr *nlh, u16 flags);
52int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device *dev,
53 struct nlmsghdr *nlh, u16 flags);
Scott Feldman5e8d9042015-03-05 21:21:15 -080054int netdev_switch_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi,
55 u8 tos, u8 type, u32 tb_id);
56int netdev_switch_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi,
57 u8 tos, u8 type, u32 tb_id);
58
Jiri Pirko007f7902014-11-28 14:34:17 +010059#else
60
61static inline int netdev_switch_parent_id_get(struct net_device *dev,
62 struct netdev_phys_item_id *psid)
63{
64 return -EOPNOTSUPP;
65}
66
Scott Feldman38dcf352014-11-28 14:34:20 +010067static inline int netdev_switch_port_stp_update(struct net_device *dev,
68 u8 state)
69{
70 return -EOPNOTSUPP;
71}
72
Jiri Pirko03bf0c22015-01-15 23:49:36 +010073static inline int register_netdev_switch_notifier(struct notifier_block *nb)
74{
75 return 0;
76}
77
78static inline int unregister_netdev_switch_notifier(struct notifier_block *nb)
79{
80 return 0;
81}
82
83static inline int call_netdev_switch_notifiers(unsigned long val, struct net_device *dev,
Jiri Pirko27c00132015-01-18 10:25:56 +010084 struct netdev_switch_notifier_info *info)
Jiri Pirko03bf0c22015-01-15 23:49:36 +010085{
86 return NOTIFY_DONE;
87}
88
Roopa Prabhu8a44dbb2015-01-29 22:40:13 -080089static inline int netdev_switch_port_bridge_setlink(struct net_device *dev,
90 struct nlmsghdr *nlh,
91 u16 flags)
92{
93 return -EOPNOTSUPP;
94}
95
96static inline int netdev_switch_port_bridge_dellink(struct net_device *dev,
97 struct nlmsghdr *nlh,
98 u16 flags)
99{
100 return -EOPNOTSUPP;
101}
102
103static inline int ndo_dflt_netdev_switch_port_bridge_dellink(struct net_device *dev,
104 struct nlmsghdr *nlh,
105 u16 flags)
106{
107 return 0;
108}
109
110static inline int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device *dev,
111 struct nlmsghdr *nlh,
112 u16 flags)
113{
114 return 0;
115}
116
Scott Feldman5e8d9042015-03-05 21:21:15 -0800117static inline int netdev_switch_fib_ipv4_add(u32 dst, int dst_len,
118 struct fib_info *fi,
119 u8 tos, u8 type, u32 tb_id)
120{
121 return 0;
122}
123
124static inline int netdev_switch_fib_ipv4_del(u32 dst, int dst_len,
125 struct fib_info *fi,
126 u8 tos, u8 type, u32 tb_id)
127{
128 return 0;
129}
130
Jiri Pirko007f7902014-11-28 14:34:17 +0100131#endif
132
133#endif /* _LINUX_SWITCHDEV_H_ */