qlcnic_dcb.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * QLogic qlcnic NIC Driver
  3. * Copyright (c) 2009-2013 QLogic Corporation
  4. *
  5. * See LICENSE.qlcnic for copyright and licensing details.
  6. */
  7. #ifndef __QLCNIC_DCBX_H
  8. #define __QLCNIC_DCBX_H
  9. #define QLCNIC_DCB_STATE 0
  10. #define QLCNIC_DCB_AEN_MODE 1
  11. #ifdef CONFIG_QLCNIC_DCB
  12. int qlcnic_register_dcb(struct qlcnic_adapter *);
  13. #else
  14. static inline int qlcnic_register_dcb(struct qlcnic_adapter *adapter)
  15. { return 0; }
  16. #endif
  17. struct qlcnic_dcb;
  18. struct qlcnic_dcb_ops {
  19. int (*query_hw_capability) (struct qlcnic_dcb *, char *);
  20. int (*get_hw_capability) (struct qlcnic_dcb *);
  21. int (*query_cee_param) (struct qlcnic_dcb *, char *, u8);
  22. void (*init_dcbnl_ops) (struct qlcnic_dcb *);
  23. int (*register_aen) (struct qlcnic_dcb *, bool);
  24. void (*aen_handler) (struct qlcnic_dcb *, void *);
  25. int (*get_cee_cfg) (struct qlcnic_dcb *);
  26. void (*get_info) (struct qlcnic_dcb *);
  27. int (*attach) (struct qlcnic_dcb *);
  28. void (*free) (struct qlcnic_dcb *);
  29. };
  30. struct qlcnic_dcb {
  31. struct qlcnic_dcb_mbx_params *param;
  32. struct qlcnic_adapter *adapter;
  33. struct delayed_work aen_work;
  34. struct workqueue_struct *wq;
  35. struct qlcnic_dcb_ops *ops;
  36. struct qlcnic_dcb_cfg *cfg;
  37. unsigned long state;
  38. };
  39. static inline void qlcnic_clear_dcb_ops(struct qlcnic_dcb *dcb)
  40. {
  41. kfree(dcb);
  42. dcb = NULL;
  43. }
  44. static inline int qlcnic_dcb_get_hw_capability(struct qlcnic_dcb *dcb)
  45. {
  46. if (dcb && dcb->ops->get_hw_capability)
  47. return dcb->ops->get_hw_capability(dcb);
  48. return 0;
  49. }
  50. static inline void qlcnic_dcb_free(struct qlcnic_dcb *dcb)
  51. {
  52. if (dcb && dcb->ops->free)
  53. dcb->ops->free(dcb);
  54. }
  55. static inline int qlcnic_dcb_attach(struct qlcnic_dcb *dcb)
  56. {
  57. if (dcb && dcb->ops->attach)
  58. return dcb->ops->attach(dcb);
  59. return 0;
  60. }
  61. static inline int
  62. qlcnic_dcb_query_hw_capability(struct qlcnic_dcb *dcb, char *buf)
  63. {
  64. if (dcb && dcb->ops->query_hw_capability)
  65. return dcb->ops->query_hw_capability(dcb, buf);
  66. return 0;
  67. }
  68. static inline void qlcnic_dcb_get_info(struct qlcnic_dcb *dcb)
  69. {
  70. if (dcb && dcb->ops->get_info)
  71. dcb->ops->get_info(dcb);
  72. }
  73. static inline int
  74. qlcnic_dcb_query_cee_param(struct qlcnic_dcb *dcb, char *buf, u8 type)
  75. {
  76. if (dcb && dcb->ops->query_cee_param)
  77. return dcb->ops->query_cee_param(dcb, buf, type);
  78. return 0;
  79. }
  80. static inline int qlcnic_dcb_get_cee_cfg(struct qlcnic_dcb *dcb)
  81. {
  82. if (dcb && dcb->ops->get_cee_cfg)
  83. return dcb->ops->get_cee_cfg(dcb);
  84. return 0;
  85. }
  86. static inline void
  87. qlcnic_dcb_register_aen(struct qlcnic_dcb *dcb, u8 flag)
  88. {
  89. if (dcb && dcb->ops->register_aen)
  90. dcb->ops->register_aen(dcb, flag);
  91. }
  92. static inline void qlcnic_dcb_aen_handler(struct qlcnic_dcb *dcb, void *msg)
  93. {
  94. if (dcb && dcb->ops->aen_handler)
  95. dcb->ops->aen_handler(dcb, msg);
  96. }
  97. static inline void qlcnic_dcb_init_dcbnl_ops(struct qlcnic_dcb *dcb)
  98. {
  99. if (dcb && dcb->ops->init_dcbnl_ops)
  100. dcb->ops->init_dcbnl_ops(dcb);
  101. }
  102. #endif