ncsi.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __NET_NCSI_H
  3. #define __NET_NCSI_H
  4. #include <linux/types.h>
  5. /*
  6. * The NCSI device states seen from external. More NCSI device states are
  7. * only visible internally (in net/ncsi/internal.h). When the NCSI device
  8. * is registered, it's in ncsi_dev_state_registered state. The state
  9. * ncsi_dev_state_start is used to drive to choose active package and
  10. * channel. After that, its state is changed to ncsi_dev_state_functional.
  11. *
  12. * The state ncsi_dev_state_stop helps to shut down the currently active
  13. * package and channel while ncsi_dev_state_config helps to reconfigure
  14. * them.
  15. */
  16. enum {
  17. ncsi_dev_state_registered = 0x0000,
  18. ncsi_dev_state_functional = 0x0100,
  19. ncsi_dev_state_probe = 0x0200,
  20. ncsi_dev_state_config = 0x0300,
  21. ncsi_dev_state_suspend = 0x0400,
  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. #ifdef CONFIG_NET_NCSI
  30. int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid);
  31. int ncsi_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, u16 vid);
  32. struct ncsi_dev *ncsi_register_dev(struct net_device *dev,
  33. void (*notifier)(struct ncsi_dev *nd));
  34. int ncsi_start_dev(struct ncsi_dev *nd);
  35. void ncsi_stop_dev(struct ncsi_dev *nd);
  36. void ncsi_unregister_dev(struct ncsi_dev *nd);
  37. #else /* !CONFIG_NET_NCSI */
  38. static inline int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid)
  39. {
  40. return -EINVAL;
  41. }
  42. static inline int ncsi_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, u16 vid)
  43. {
  44. return -EINVAL;
  45. }
  46. static inline struct ncsi_dev *ncsi_register_dev(struct net_device *dev,
  47. void (*notifier)(struct ncsi_dev *nd))
  48. {
  49. return NULL;
  50. }
  51. static inline int ncsi_start_dev(struct ncsi_dev *nd)
  52. {
  53. return -ENOTTY;
  54. }
  55. static void ncsi_stop_dev(struct ncsi_dev *nd)
  56. {
  57. }
  58. static inline void ncsi_unregister_dev(struct ncsi_dev *nd)
  59. {
  60. }
  61. #endif /* CONFIG_NET_NCSI */
  62. #endif /* __NET_NCSI_H */