ncsi.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __NET_NCSI_H
  3. #define __NET_NCSI_H
  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. struct ncsi_dev {
  23. int state;
  24. int link_up;
  25. struct net_device *dev;
  26. void (*handler)(struct ncsi_dev *ndev);
  27. };
  28. #ifdef CONFIG_NET_NCSI
  29. int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid);
  30. int ncsi_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, u16 vid);
  31. struct ncsi_dev *ncsi_register_dev(struct net_device *dev,
  32. void (*notifier)(struct ncsi_dev *nd));
  33. int ncsi_start_dev(struct ncsi_dev *nd);
  34. void ncsi_stop_dev(struct ncsi_dev *nd);
  35. void ncsi_unregister_dev(struct ncsi_dev *nd);
  36. #else /* !CONFIG_NET_NCSI */
  37. static inline int ncsi_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid)
  38. {
  39. return -EINVAL;
  40. }
  41. static inline int ncsi_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, u16 vid)
  42. {
  43. return -EINVAL;
  44. }
  45. static inline struct ncsi_dev *ncsi_register_dev(struct net_device *dev,
  46. void (*notifier)(struct ncsi_dev *nd))
  47. {
  48. return NULL;
  49. }
  50. static inline int ncsi_start_dev(struct ncsi_dev *nd)
  51. {
  52. return -ENOTTY;
  53. }
  54. static void ncsi_stop_dev(struct ncsi_dev *nd)
  55. {
  56. }
  57. static inline void ncsi_unregister_dev(struct ncsi_dev *nd)
  58. {
  59. }
  60. #endif /* CONFIG_NET_NCSI */
  61. #endif /* __NET_NCSI_H */