Jiri Pirko | 007f790 | 2014-11-28 14:34:17 +0100 | [diff] [blame] | 1 | /* |
| 2 | * include/net/switchdev.h - Switch device API |
| 3 | * Copyright (c) 2014 Jiri Pirko <jiri@resnulli.us> |
Scott Feldman | f8f2147 | 2015-03-09 13:59:09 -0700 | [diff] [blame^] | 4 | * Copyright (c) 2014-2015 Scott Feldman <sfeldma@gmail.com> |
Jiri Pirko | 007f790 | 2014-11-28 14:34:17 +0100 | [diff] [blame] | 5 | * |
| 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. |
| 10 | */ |
| 11 | #ifndef _LINUX_SWITCHDEV_H_ |
| 12 | #define _LINUX_SWITCHDEV_H_ |
| 13 | |
| 14 | #include <linux/netdevice.h> |
Jiri Pirko | 03bf0c2 | 2015-01-15 23:49:36 +0100 | [diff] [blame] | 15 | #include <linux/notifier.h> |
| 16 | |
Jiri Pirko | 3aeb661 | 2015-01-15 23:49:37 +0100 | [diff] [blame] | 17 | enum netdev_switch_notifier_type { |
| 18 | NETDEV_SWITCH_FDB_ADD = 1, |
| 19 | NETDEV_SWITCH_FDB_DEL, |
| 20 | }; |
| 21 | |
Jiri Pirko | 03bf0c2 | 2015-01-15 23:49:36 +0100 | [diff] [blame] | 22 | struct netdev_switch_notifier_info { |
| 23 | struct net_device *dev; |
| 24 | }; |
| 25 | |
Jiri Pirko | 3aeb661 | 2015-01-15 23:49:37 +0100 | [diff] [blame] | 26 | struct netdev_switch_notifier_fdb_info { |
| 27 | struct netdev_switch_notifier_info info; /* must be first */ |
| 28 | const unsigned char *addr; |
| 29 | u16 vid; |
| 30 | }; |
| 31 | |
Jiri Pirko | 03bf0c2 | 2015-01-15 23:49:36 +0100 | [diff] [blame] | 32 | static inline struct net_device * |
| 33 | netdev_switch_notifier_info_to_dev(const struct netdev_switch_notifier_info *info) |
| 34 | { |
| 35 | return info->dev; |
| 36 | } |
Jiri Pirko | 007f790 | 2014-11-28 14:34:17 +0100 | [diff] [blame] | 37 | |
| 38 | #ifdef CONFIG_NET_SWITCHDEV |
| 39 | |
| 40 | int netdev_switch_parent_id_get(struct net_device *dev, |
| 41 | struct netdev_phys_item_id *psid); |
Scott Feldman | 38dcf35 | 2014-11-28 14:34:20 +0100 | [diff] [blame] | 42 | int netdev_switch_port_stp_update(struct net_device *dev, u8 state); |
Jiri Pirko | 03bf0c2 | 2015-01-15 23:49:36 +0100 | [diff] [blame] | 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); |
Roopa Prabhu | 8a44dbb | 2015-01-29 22:40:13 -0800 | [diff] [blame] | 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); |
Scott Feldman | 5e8d904 | 2015-03-05 21:21:15 -0800 | [diff] [blame] | 55 | int netdev_switch_fib_ipv4_add(u32 dst, int dst_len, struct fib_info *fi, |
Scott Feldman | f8f2147 | 2015-03-09 13:59:09 -0700 | [diff] [blame^] | 56 | u8 tos, u8 type, u32 nlflags, u32 tb_id); |
Scott Feldman | 5e8d904 | 2015-03-05 21:21:15 -0800 | [diff] [blame] | 57 | int netdev_switch_fib_ipv4_del(u32 dst, int dst_len, struct fib_info *fi, |
| 58 | u8 tos, u8 type, u32 tb_id); |
Scott Feldman | 8e05fd7 | 2015-03-05 21:21:19 -0800 | [diff] [blame] | 59 | void netdev_switch_fib_ipv4_abort(struct fib_info *fi); |
Scott Feldman | 5e8d904 | 2015-03-05 21:21:15 -0800 | [diff] [blame] | 60 | |
Jiri Pirko | 007f790 | 2014-11-28 14:34:17 +0100 | [diff] [blame] | 61 | #else |
| 62 | |
| 63 | static inline int netdev_switch_parent_id_get(struct net_device *dev, |
| 64 | struct netdev_phys_item_id *psid) |
| 65 | { |
| 66 | return -EOPNOTSUPP; |
| 67 | } |
| 68 | |
Scott Feldman | 38dcf35 | 2014-11-28 14:34:20 +0100 | [diff] [blame] | 69 | static inline int netdev_switch_port_stp_update(struct net_device *dev, |
| 70 | u8 state) |
| 71 | { |
| 72 | return -EOPNOTSUPP; |
| 73 | } |
| 74 | |
Jiri Pirko | 03bf0c2 | 2015-01-15 23:49:36 +0100 | [diff] [blame] | 75 | static inline int register_netdev_switch_notifier(struct notifier_block *nb) |
| 76 | { |
| 77 | return 0; |
| 78 | } |
| 79 | |
| 80 | static inline int unregister_netdev_switch_notifier(struct notifier_block *nb) |
| 81 | { |
| 82 | return 0; |
| 83 | } |
| 84 | |
| 85 | static inline int call_netdev_switch_notifiers(unsigned long val, struct net_device *dev, |
Jiri Pirko | 27c0013 | 2015-01-18 10:25:56 +0100 | [diff] [blame] | 86 | struct netdev_switch_notifier_info *info) |
Jiri Pirko | 03bf0c2 | 2015-01-15 23:49:36 +0100 | [diff] [blame] | 87 | { |
| 88 | return NOTIFY_DONE; |
| 89 | } |
| 90 | |
Roopa Prabhu | 8a44dbb | 2015-01-29 22:40:13 -0800 | [diff] [blame] | 91 | static inline int netdev_switch_port_bridge_setlink(struct net_device *dev, |
| 92 | struct nlmsghdr *nlh, |
| 93 | u16 flags) |
| 94 | { |
| 95 | return -EOPNOTSUPP; |
| 96 | } |
| 97 | |
| 98 | static inline int netdev_switch_port_bridge_dellink(struct net_device *dev, |
| 99 | struct nlmsghdr *nlh, |
| 100 | u16 flags) |
| 101 | { |
| 102 | return -EOPNOTSUPP; |
| 103 | } |
| 104 | |
| 105 | static inline int ndo_dflt_netdev_switch_port_bridge_dellink(struct net_device *dev, |
| 106 | struct nlmsghdr *nlh, |
| 107 | u16 flags) |
| 108 | { |
| 109 | return 0; |
| 110 | } |
| 111 | |
| 112 | static inline int ndo_dflt_netdev_switch_port_bridge_setlink(struct net_device *dev, |
| 113 | struct nlmsghdr *nlh, |
| 114 | u16 flags) |
| 115 | { |
| 116 | return 0; |
| 117 | } |
| 118 | |
Scott Feldman | 5e8d904 | 2015-03-05 21:21:15 -0800 | [diff] [blame] | 119 | static inline int netdev_switch_fib_ipv4_add(u32 dst, int dst_len, |
| 120 | struct fib_info *fi, |
Scott Feldman | f8f2147 | 2015-03-09 13:59:09 -0700 | [diff] [blame^] | 121 | u8 tos, u8 type, |
| 122 | u32 nlflags, u32 tb_id) |
Scott Feldman | 5e8d904 | 2015-03-05 21:21:15 -0800 | [diff] [blame] | 123 | { |
| 124 | return 0; |
| 125 | } |
| 126 | |
| 127 | static inline int netdev_switch_fib_ipv4_del(u32 dst, int dst_len, |
| 128 | struct fib_info *fi, |
| 129 | u8 tos, u8 type, u32 tb_id) |
| 130 | { |
| 131 | return 0; |
| 132 | } |
| 133 | |
Willem de Bruijn | 89650ad | 2015-03-06 11:44:28 -0500 | [diff] [blame] | 134 | static inline void netdev_switch_fib_ipv4_abort(struct fib_info *fi) |
Scott Feldman | 8e05fd7 | 2015-03-05 21:21:19 -0800 | [diff] [blame] | 135 | { |
| 136 | } |
| 137 | |
Jiri Pirko | 007f790 | 2014-11-28 14:34:17 +0100 | [diff] [blame] | 138 | #endif |
| 139 | |
| 140 | #endif /* _LINUX_SWITCHDEV_H_ */ |