Gavin Shan | 2d283bd | 2016-07-19 11:54:16 +1000 | [diff] [blame] | 1 | #ifndef __NET_NCSI_H |
| 2 | #define __NET_NCSI_H |
| 3 | |
| 4 | /* |
| 5 | * The NCSI device states seen from external. More NCSI device states are |
| 6 | * only visible internally (in net/ncsi/internal.h). When the NCSI device |
| 7 | * is registered, it's in ncsi_dev_state_registered state. The state |
| 8 | * ncsi_dev_state_start is used to drive to choose active package and |
| 9 | * channel. After that, its state is changed to ncsi_dev_state_functional. |
| 10 | * |
| 11 | * The state ncsi_dev_state_stop helps to shut down the currently active |
| 12 | * package and channel while ncsi_dev_state_config helps to reconfigure |
| 13 | * them. |
| 14 | */ |
| 15 | enum { |
| 16 | ncsi_dev_state_registered = 0x0000, |
| 17 | ncsi_dev_state_functional = 0x0100, |
| 18 | ncsi_dev_state_probe = 0x0200, |
| 19 | ncsi_dev_state_config = 0x0300, |
| 20 | ncsi_dev_state_suspend = 0x0400, |
| 21 | }; |
| 22 | |
| 23 | struct ncsi_dev { |
| 24 | int state; |
| 25 | int link_up; |
| 26 | struct net_device *dev; |
| 27 | void (*handler)(struct ncsi_dev *ndev); |
| 28 | }; |
| 29 | |
| 30 | #ifdef CONFIG_NET_NCSI |
Samuel Mendoza-Jonas | 21acf63 | 2017-08-28 16:18:42 +1000 | [diff] [blame] | 31 | int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid); |
| 32 | int ncsi_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, u16 vid); |
Gavin Shan | 2d283bd | 2016-07-19 11:54:16 +1000 | [diff] [blame] | 33 | struct ncsi_dev *ncsi_register_dev(struct net_device *dev, |
| 34 | void (*notifier)(struct ncsi_dev *nd)); |
Gavin Shan | e6f44ed | 2016-07-19 11:54:19 +1000 | [diff] [blame] | 35 | int ncsi_start_dev(struct ncsi_dev *nd); |
Gavin Shan | c0cd1ba | 2016-10-04 11:25:53 +1100 | [diff] [blame] | 36 | void ncsi_stop_dev(struct ncsi_dev *nd); |
Gavin Shan | 2d283bd | 2016-07-19 11:54:16 +1000 | [diff] [blame] | 37 | void ncsi_unregister_dev(struct ncsi_dev *nd); |
| 38 | #else /* !CONFIG_NET_NCSI */ |
Arnd Bergmann | fd0c88b | 2017-09-05 10:05:47 +0200 | [diff] [blame] | 39 | static inline int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid) |
| 40 | { |
| 41 | return -EINVAL; |
| 42 | } |
| 43 | |
| 44 | static inline int ncsi_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, u16 vid) |
| 45 | { |
| 46 | return -EINVAL; |
| 47 | } |
| 48 | |
Gavin Shan | 2d283bd | 2016-07-19 11:54:16 +1000 | [diff] [blame] | 49 | static inline struct ncsi_dev *ncsi_register_dev(struct net_device *dev, |
| 50 | void (*notifier)(struct ncsi_dev *nd)) |
| 51 | { |
| 52 | return NULL; |
| 53 | } |
| 54 | |
Gavin Shan | e6f44ed | 2016-07-19 11:54:19 +1000 | [diff] [blame] | 55 | static inline int ncsi_start_dev(struct ncsi_dev *nd) |
| 56 | { |
| 57 | return -ENOTTY; |
| 58 | } |
| 59 | |
Gavin Shan | c0cd1ba | 2016-10-04 11:25:53 +1100 | [diff] [blame] | 60 | static void ncsi_stop_dev(struct ncsi_dev *nd) |
| 61 | { |
| 62 | } |
| 63 | |
Gavin Shan | 2d283bd | 2016-07-19 11:54:16 +1000 | [diff] [blame] | 64 | static inline void ncsi_unregister_dev(struct ncsi_dev *nd) |
| 65 | { |
| 66 | } |
| 67 | #endif /* CONFIG_NET_NCSI */ |
| 68 | |
| 69 | #endif /* __NET_NCSI_H */ |