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 | |
| 16 | struct netdev_switch_notifier_info { |
| 17 | struct net_device *dev; |
| 18 | }; |
| 19 | |
| 20 | static inline struct net_device * |
| 21 | netdev_switch_notifier_info_to_dev(const struct netdev_switch_notifier_info *info) |
| 22 | { |
| 23 | return info->dev; |
| 24 | } |
Jiri Pirko | 007f790 | 2014-11-28 14:34:17 +0100 | [diff] [blame] | 25 | |
| 26 | #ifdef CONFIG_NET_SWITCHDEV |
| 27 | |
| 28 | int netdev_switch_parent_id_get(struct net_device *dev, |
| 29 | struct netdev_phys_item_id *psid); |
Scott Feldman | 38dcf35 | 2014-11-28 14:34:20 +0100 | [diff] [blame] | 30 | int netdev_switch_port_stp_update(struct net_device *dev, u8 state); |
Jiri Pirko | 03bf0c2 | 2015-01-15 23:49:36 +0100 | [diff] [blame^] | 31 | int register_netdev_switch_notifier(struct notifier_block *nb); |
| 32 | int unregister_netdev_switch_notifier(struct notifier_block *nb); |
| 33 | int call_netdev_switch_notifiers(unsigned long val, struct net_device *dev, |
| 34 | struct netdev_switch_notifier_info *info); |
Jiri Pirko | 007f790 | 2014-11-28 14:34:17 +0100 | [diff] [blame] | 35 | |
| 36 | #else |
| 37 | |
| 38 | static inline int netdev_switch_parent_id_get(struct net_device *dev, |
| 39 | struct netdev_phys_item_id *psid) |
| 40 | { |
| 41 | return -EOPNOTSUPP; |
| 42 | } |
| 43 | |
Scott Feldman | 38dcf35 | 2014-11-28 14:34:20 +0100 | [diff] [blame] | 44 | static inline int netdev_switch_port_stp_update(struct net_device *dev, |
| 45 | u8 state) |
| 46 | { |
| 47 | return -EOPNOTSUPP; |
| 48 | } |
| 49 | |
Jiri Pirko | 03bf0c2 | 2015-01-15 23:49:36 +0100 | [diff] [blame^] | 50 | static inline int register_netdev_switch_notifier(struct notifier_block *nb) |
| 51 | { |
| 52 | return 0; |
| 53 | } |
| 54 | |
| 55 | static inline int unregister_netdev_switch_notifier(struct notifier_block *nb) |
| 56 | { |
| 57 | return 0; |
| 58 | } |
| 59 | |
| 60 | static inline int call_netdev_switch_notifiers(unsigned long val, struct net_device *dev, |
| 61 | struct netdev_switch_notifier_info *info); |
| 62 | { |
| 63 | return NOTIFY_DONE; |
| 64 | } |
| 65 | |
Jiri Pirko | 007f790 | 2014-11-28 14:34:17 +0100 | [diff] [blame] | 66 | #endif |
| 67 | |
| 68 | #endif /* _LINUX_SWITCHDEV_H_ */ |