qlcnic_dcb.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. void (*aen_handler) (struct qlcnic_dcb *, void *);
  24. int (*get_cee_cfg) (struct qlcnic_dcb *);
  25. void (*get_info) (struct qlcnic_dcb *);
  26. int (*attach) (struct qlcnic_dcb *);
  27. void (*free) (struct qlcnic_dcb *);
  28. };
  29. struct qlcnic_dcb {
  30. struct qlcnic_dcb_mbx_params *param;
  31. struct qlcnic_adapter *adapter;
  32. struct delayed_work aen_work;
  33. struct workqueue_struct *wq;
  34. struct qlcnic_dcb_ops *ops;
  35. struct qlcnic_dcb_cfg *cfg;
  36. unsigned long state;
  37. };
  38. static inline void qlcnic_clear_dcb_ops(struct qlcnic_dcb *dcb)
  39. {
  40. kfree(dcb);
  41. dcb = NULL;
  42. }
  43. static inline int qlcnic_dcb_get_hw_capability(struct qlcnic_dcb *dcb)
  44. {
  45. if (dcb && dcb->ops->get_hw_capability)
  46. return dcb->ops->get_hw_capability(dcb);
  47. return 0;
  48. }
  49. static inline void qlcnic_dcb_free(struct qlcnic_dcb *dcb)
  50. {
  51. if (dcb && dcb->ops->free)
  52. dcb->ops->free(dcb);
  53. }
  54. static inline int qlcnic_dcb_attach(struct qlcnic_dcb *dcb)
  55. {
  56. if (dcb && dcb->ops->attach)
  57. return dcb->ops->attach(dcb);
  58. return 0;
  59. }
  60. static inline int
  61. qlcnic_dcb_query_hw_capability(struct qlcnic_dcb *dcb, char *buf)
  62. {
  63. if (dcb && dcb->ops->query_hw_capability)
  64. return dcb->ops->query_hw_capability(dcb, buf);
  65. return 0;
  66. }
  67. static inline void qlcnic_dcb_get_info(struct qlcnic_dcb *dcb)
  68. {
  69. if (dcb && dcb->ops->get_info)
  70. dcb->ops->get_info(dcb);
  71. }
  72. static inline int
  73. qlcnic_dcb_query_cee_param(struct qlcnic_dcb *dcb, char *buf, u8 type)
  74. {
  75. if (dcb && dcb->ops->query_cee_param)
  76. return dcb->ops->query_cee_param(dcb, buf, type);
  77. return 0;
  78. }
  79. static inline int qlcnic_dcb_get_cee_cfg(struct qlcnic_dcb *dcb)
  80. {
  81. if (dcb && dcb->ops->get_cee_cfg)
  82. return dcb->ops->get_cee_cfg(dcb);
  83. return 0;
  84. }
  85. static inline void qlcnic_dcb_aen_handler(struct qlcnic_dcb *dcb, void *msg)
  86. {
  87. if (dcb && dcb->ops->aen_handler)
  88. dcb->ops->aen_handler(dcb, msg);
  89. }
  90. static inline void qlcnic_dcb_init_dcbnl_ops(struct qlcnic_dcb *dcb)
  91. {
  92. if (dcb && dcb->ops->init_dcbnl_ops)
  93. dcb->ops->init_dcbnl_ops(dcb);
  94. }
  95. static inline void qlcnic_dcb_enable(struct qlcnic_dcb *dcb)
  96. {
  97. if (dcb && qlcnic_dcb_attach(dcb))
  98. qlcnic_clear_dcb_ops(dcb);
  99. }
  100. #endif