Loading...
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * QLogic qlcnic NIC Driver
4 * Copyright (c) 2009-2013 QLogic Corporation
5 */
6
7#ifndef __QLCNIC_DCBX_H
8#define __QLCNIC_DCBX_H
9
10#define QLCNIC_DCB_STATE 0
11#define QLCNIC_DCB_AEN_MODE 1
12
13#ifdef CONFIG_QLCNIC_DCB
14int qlcnic_register_dcb(struct qlcnic_adapter *);
15#else
16static inline int qlcnic_register_dcb(struct qlcnic_adapter *adapter)
17{ return 0; }
18#endif
19
20struct qlcnic_dcb;
21
22struct qlcnic_dcb_ops {
23 int (*query_hw_capability) (struct qlcnic_dcb *, char *);
24 int (*get_hw_capability) (struct qlcnic_dcb *);
25 int (*query_cee_param) (struct qlcnic_dcb *, char *, u8);
26 void (*init_dcbnl_ops) (struct qlcnic_dcb *);
27 void (*aen_handler) (struct qlcnic_dcb *, void *);
28 int (*get_cee_cfg) (struct qlcnic_dcb *);
29 void (*get_info) (struct qlcnic_dcb *);
30 int (*attach) (struct qlcnic_dcb *);
31 void (*free) (struct qlcnic_dcb *);
32};
33
34struct qlcnic_dcb {
35 struct qlcnic_dcb_mbx_params *param;
36 struct qlcnic_adapter *adapter;
37 struct delayed_work aen_work;
38 struct workqueue_struct *wq;
39 const struct qlcnic_dcb_ops *ops;
40 struct qlcnic_dcb_cfg *cfg;
41 unsigned long state;
42};
43
44static 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
49 return -EOPNOTSUPP;
50}
51
52static inline void qlcnic_dcb_free(struct qlcnic_dcb *dcb)
53{
54 if (dcb && dcb->ops->free)
55 dcb->ops->free(dcb);
56}
57
58static inline int qlcnic_dcb_attach(struct qlcnic_dcb *dcb)
59{
60 if (dcb && dcb->ops->attach)
61 return dcb->ops->attach(dcb);
62
63 return -EOPNOTSUPP;
64}
65
66static inline int
67qlcnic_dcb_query_hw_capability(struct qlcnic_dcb *dcb, char *buf)
68{
69 if (dcb && dcb->ops->query_hw_capability)
70 return dcb->ops->query_hw_capability(dcb, buf);
71
72 return -EOPNOTSUPP;
73}
74
75static inline void qlcnic_dcb_get_info(struct qlcnic_dcb *dcb)
76{
77 if (dcb && dcb->ops->get_info)
78 dcb->ops->get_info(dcb);
79}
80
81static inline int
82qlcnic_dcb_query_cee_param(struct qlcnic_dcb *dcb, char *buf, u8 type)
83{
84 if (dcb && dcb->ops->query_cee_param)
85 return dcb->ops->query_cee_param(dcb, buf, type);
86
87 return -EOPNOTSUPP;
88}
89
90static inline int qlcnic_dcb_get_cee_cfg(struct qlcnic_dcb *dcb)
91{
92 if (dcb && dcb->ops->get_cee_cfg)
93 return dcb->ops->get_cee_cfg(dcb);
94
95 return -EOPNOTSUPP;
96}
97
98static inline void qlcnic_dcb_aen_handler(struct qlcnic_dcb *dcb, void *msg)
99{
100 if (dcb && dcb->ops->aen_handler)
101 dcb->ops->aen_handler(dcb, msg);
102}
103
104static inline void qlcnic_dcb_init_dcbnl_ops(struct qlcnic_dcb *dcb)
105{
106 if (dcb && dcb->ops->init_dcbnl_ops)
107 dcb->ops->init_dcbnl_ops(dcb);
108}
109
110static inline int qlcnic_dcb_enable(struct qlcnic_dcb *dcb)
111{
112 return dcb ? qlcnic_dcb_attach(dcb) : 0;
113}
114#endif
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
8#ifndef __QLCNIC_DCBX_H
9#define __QLCNIC_DCBX_H
10
11#define QLCNIC_DCB_STATE 0
12#define QLCNIC_DCB_AEN_MODE 1
13
14#ifdef CONFIG_QLCNIC_DCB
15int qlcnic_register_dcb(struct qlcnic_adapter *);
16#else
17static inline int qlcnic_register_dcb(struct qlcnic_adapter *adapter)
18{ return 0; }
19#endif
20
21struct qlcnic_dcb;
22
23struct qlcnic_dcb_ops {
24 int (*query_hw_capability) (struct qlcnic_dcb *, char *);
25 int (*get_hw_capability) (struct qlcnic_dcb *);
26 int (*query_cee_param) (struct qlcnic_dcb *, char *, u8);
27 void (*init_dcbnl_ops) (struct qlcnic_dcb *);
28 void (*aen_handler) (struct qlcnic_dcb *, void *);
29 int (*get_cee_cfg) (struct qlcnic_dcb *);
30 void (*get_info) (struct qlcnic_dcb *);
31 int (*attach) (struct qlcnic_dcb *);
32 void (*free) (struct qlcnic_dcb *);
33};
34
35struct qlcnic_dcb {
36 struct qlcnic_dcb_mbx_params *param;
37 struct qlcnic_adapter *adapter;
38 struct delayed_work aen_work;
39 struct workqueue_struct *wq;
40 const struct qlcnic_dcb_ops *ops;
41 struct qlcnic_dcb_cfg *cfg;
42 unsigned long state;
43};
44
45static inline void qlcnic_clear_dcb_ops(struct qlcnic_dcb *dcb)
46{
47 kfree(dcb);
48 dcb = NULL;
49}
50
51static inline int qlcnic_dcb_get_hw_capability(struct qlcnic_dcb *dcb)
52{
53 if (dcb && dcb->ops->get_hw_capability)
54 return dcb->ops->get_hw_capability(dcb);
55
56 return 0;
57}
58
59static inline void qlcnic_dcb_free(struct qlcnic_dcb *dcb)
60{
61 if (dcb && dcb->ops->free)
62 dcb->ops->free(dcb);
63}
64
65static inline int qlcnic_dcb_attach(struct qlcnic_dcb *dcb)
66{
67 if (dcb && dcb->ops->attach)
68 return dcb->ops->attach(dcb);
69
70 return 0;
71}
72
73static inline int
74qlcnic_dcb_query_hw_capability(struct qlcnic_dcb *dcb, char *buf)
75{
76 if (dcb && dcb->ops->query_hw_capability)
77 return dcb->ops->query_hw_capability(dcb, buf);
78
79 return 0;
80}
81
82static inline void qlcnic_dcb_get_info(struct qlcnic_dcb *dcb)
83{
84 if (dcb && dcb->ops->get_info)
85 dcb->ops->get_info(dcb);
86}
87
88static inline int
89qlcnic_dcb_query_cee_param(struct qlcnic_dcb *dcb, char *buf, u8 type)
90{
91 if (dcb && dcb->ops->query_cee_param)
92 return dcb->ops->query_cee_param(dcb, buf, type);
93
94 return 0;
95}
96
97static inline int qlcnic_dcb_get_cee_cfg(struct qlcnic_dcb *dcb)
98{
99 if (dcb && dcb->ops->get_cee_cfg)
100 return dcb->ops->get_cee_cfg(dcb);
101
102 return 0;
103}
104
105static inline void qlcnic_dcb_aen_handler(struct qlcnic_dcb *dcb, void *msg)
106{
107 if (dcb && dcb->ops->aen_handler)
108 dcb->ops->aen_handler(dcb, msg);
109}
110
111static inline void qlcnic_dcb_init_dcbnl_ops(struct qlcnic_dcb *dcb)
112{
113 if (dcb && dcb->ops->init_dcbnl_ops)
114 dcb->ops->init_dcbnl_ops(dcb);
115}
116
117static inline void qlcnic_dcb_enable(struct qlcnic_dcb *dcb)
118{
119 if (dcb && qlcnic_dcb_attach(dcb))
120 qlcnic_clear_dcb_ops(dcb);
121}
122#endif