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