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. const 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. }
  42. static inline int qlcnic_dcb_get_hw_capability(struct qlcnic_dcb *dcb)
  43. {
  44. if (dcb && dcb->ops->get_hw_capability)
  45. return dcb->ops->get_hw_capability(dcb);
  46. return 0;
  47. }
  48. static inline void qlcnic_dcb_free(struct qlcnic_dcb *dcb)
  49. {
  50. if (dcb && dcb->ops->free)
  51. dcb->ops->free(dcb);
  52. }
  53. static inline int qlcnic_dcb_attach(struct qlcnic_dcb *dcb)
  54. {
  55. if (dcb && dcb->ops->attach)
  56. return dcb->ops->attach(dcb);
  57. return 0;
  58. }
  59. static inline int
  60. qlcnic_dcb_query_hw_capability(struct qlcnic_dcb *dcb, char *buf)
  61. {
  62. if (dcb && dcb->ops->query_hw_capability)
  63. return dcb->ops->query_hw_capability(dcb, buf);
  64. return 0;
  65. }
  66. static inline void qlcnic_dcb_get_info(struct qlcnic_dcb *dcb)
  67. {
  68. if (dcb && dcb->ops->get_info)
  69. dcb->ops->get_info(dcb);
  70. }
  71. static inline int
  72. qlcnic_dcb_query_cee_param(struct qlcnic_dcb *dcb, char *buf, u8 type)
  73. {
  74. if (dcb && dcb->ops->query_cee_param)
  75. return dcb->ops->query_cee_param(dcb, buf, type);
  76. return 0;
  77. }
  78. static inline int qlcnic_dcb_get_cee_cfg(struct qlcnic_dcb *dcb)
  79. {
  80. if (dcb && dcb->ops->get_cee_cfg)
  81. return dcb->ops->get_cee_cfg(dcb);
  82. return 0;
  83. }
  84. static inline void qlcnic_dcb_aen_handler(struct qlcnic_dcb *dcb, void *msg)
  85. {
  86. if (dcb && dcb->ops->aen_handler)
  87. dcb->ops->aen_handler(dcb, msg);
  88. }
  89. static inline void qlcnic_dcb_init_dcbnl_ops(struct qlcnic_dcb *dcb)
  90. {
  91. if (dcb && dcb->ops->init_dcbnl_ops)
  92. dcb->ops->init_dcbnl_ops(dcb);
  93. }
  94. static inline void qlcnic_dcb_enable(struct qlcnic_dcb *dcb)
  95. {
  96. if (dcb && qlcnic_dcb_attach(dcb))
  97. qlcnic_clear_dcb_ops(dcb);
  98. }
  99. #endif