0001
0002
0003
0004
0005
0006
0007 #ifndef __QLCNIC_DCBX_H
0008 #define __QLCNIC_DCBX_H
0009
0010 #define QLCNIC_DCB_STATE 0
0011 #define QLCNIC_DCB_AEN_MODE 1
0012
0013 #ifdef CONFIG_QLCNIC_DCB
0014 int qlcnic_register_dcb(struct qlcnic_adapter *);
0015 #else
0016 static inline int qlcnic_register_dcb(struct qlcnic_adapter *adapter)
0017 { return 0; }
0018 #endif
0019
0020 struct qlcnic_dcb;
0021
0022 struct qlcnic_dcb_ops {
0023 int (*query_hw_capability) (struct qlcnic_dcb *, char *);
0024 int (*get_hw_capability) (struct qlcnic_dcb *);
0025 int (*query_cee_param) (struct qlcnic_dcb *, char *, u8);
0026 void (*init_dcbnl_ops) (struct qlcnic_dcb *);
0027 void (*aen_handler) (struct qlcnic_dcb *, void *);
0028 int (*get_cee_cfg) (struct qlcnic_dcb *);
0029 void (*get_info) (struct qlcnic_dcb *);
0030 int (*attach) (struct qlcnic_dcb *);
0031 void (*free) (struct qlcnic_dcb *);
0032 };
0033
0034 struct qlcnic_dcb {
0035 struct qlcnic_dcb_mbx_params *param;
0036 struct qlcnic_adapter *adapter;
0037 struct delayed_work aen_work;
0038 struct workqueue_struct *wq;
0039 const struct qlcnic_dcb_ops *ops;
0040 struct qlcnic_dcb_cfg *cfg;
0041 unsigned long state;
0042 };
0043
0044 static inline void qlcnic_clear_dcb_ops(struct qlcnic_dcb *dcb)
0045 {
0046 kfree(dcb);
0047 }
0048
0049 static inline int qlcnic_dcb_get_hw_capability(struct qlcnic_dcb *dcb)
0050 {
0051 if (dcb && dcb->ops->get_hw_capability)
0052 return dcb->ops->get_hw_capability(dcb);
0053
0054 return -EOPNOTSUPP;
0055 }
0056
0057 static inline void qlcnic_dcb_free(struct qlcnic_dcb *dcb)
0058 {
0059 if (dcb && dcb->ops->free)
0060 dcb->ops->free(dcb);
0061 }
0062
0063 static inline int qlcnic_dcb_attach(struct qlcnic_dcb *dcb)
0064 {
0065 if (dcb && dcb->ops->attach)
0066 return dcb->ops->attach(dcb);
0067
0068 return -EOPNOTSUPP;
0069 }
0070
0071 static inline int
0072 qlcnic_dcb_query_hw_capability(struct qlcnic_dcb *dcb, char *buf)
0073 {
0074 if (dcb && dcb->ops->query_hw_capability)
0075 return dcb->ops->query_hw_capability(dcb, buf);
0076
0077 return -EOPNOTSUPP;
0078 }
0079
0080 static inline void qlcnic_dcb_get_info(struct qlcnic_dcb *dcb)
0081 {
0082 if (dcb && dcb->ops->get_info)
0083 dcb->ops->get_info(dcb);
0084 }
0085
0086 static inline int
0087 qlcnic_dcb_query_cee_param(struct qlcnic_dcb *dcb, char *buf, u8 type)
0088 {
0089 if (dcb && dcb->ops->query_cee_param)
0090 return dcb->ops->query_cee_param(dcb, buf, type);
0091
0092 return -EOPNOTSUPP;
0093 }
0094
0095 static inline int qlcnic_dcb_get_cee_cfg(struct qlcnic_dcb *dcb)
0096 {
0097 if (dcb && dcb->ops->get_cee_cfg)
0098 return dcb->ops->get_cee_cfg(dcb);
0099
0100 return -EOPNOTSUPP;
0101 }
0102
0103 static inline void qlcnic_dcb_aen_handler(struct qlcnic_dcb *dcb, void *msg)
0104 {
0105 if (dcb && dcb->ops->aen_handler)
0106 dcb->ops->aen_handler(dcb, msg);
0107 }
0108
0109 static inline void qlcnic_dcb_init_dcbnl_ops(struct qlcnic_dcb *dcb)
0110 {
0111 if (dcb && dcb->ops->init_dcbnl_ops)
0112 dcb->ops->init_dcbnl_ops(dcb);
0113 }
0114
0115 static inline void qlcnic_dcb_enable(struct qlcnic_dcb *dcb)
0116 {
0117 if (dcb && qlcnic_dcb_attach(dcb))
0118 qlcnic_clear_dcb_ops(dcb);
0119 }
0120 #endif