diff options
author | Sucheta Chakraborty <sucheta.chakraborty@qlogic.com> | 2013-10-18 12:22:33 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-10-18 13:42:19 -0400 |
commit | 1de899d3815fd945b0c2285a4e07fea8eaedf2aa (patch) | |
tree | 2225789308642674306b1ce032040d1c8b48d999 /drivers | |
parent | 4c776aad7453b6795d6d26200706e07ef261b8c9 (diff) |
qlcnic: dcb code cleanup and refactoring.
o Move dcb specific function definitions to dcb files.
o Move dcb specific variables to qlcnic_dcb structure.
Signed-off-by: Sucheta Chakraborty <sucheta.chakraborty@qlogic.com>
Signed-off-by: Himanshu Madhani <himanshu.madhani@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/ethernet/qlogic/qlcnic/qlcnic.h | 96 | ||||
-rw-r--r-- | drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c | 2 | ||||
-rw-r--r-- | drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c | 9 | ||||
-rw-r--r-- | drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.c | 184 | ||||
-rw-r--r-- | drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.h | 109 | ||||
-rw-r--r-- | drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c | 2 | ||||
-rw-r--r-- | drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 24 | ||||
-rw-r--r-- | drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c | 9 |
8 files changed, 207 insertions, 228 deletions
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h index a3c4379d78f8..728bb8888d76 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic.h | |||
@@ -961,8 +961,6 @@ struct qlcnic_ipaddr { | |||
961 | #define __QLCNIC_SRIOV_CAPABLE 11 | 961 | #define __QLCNIC_SRIOV_CAPABLE 11 |
962 | #define __QLCNIC_MBX_POLL_ENABLE 12 | 962 | #define __QLCNIC_MBX_POLL_ENABLE 12 |
963 | #define __QLCNIC_DIAG_MODE 13 | 963 | #define __QLCNIC_DIAG_MODE 13 |
964 | #define __QLCNIC_DCB_STATE 14 | ||
965 | #define __QLCNIC_DCB_IN_AEN 15 | ||
966 | 964 | ||
967 | #define QLCNIC_INTERRUPT_TEST 1 | 965 | #define QLCNIC_INTERRUPT_TEST 1 |
968 | #define QLCNIC_LOOPBACK_TEST 2 | 966 | #define QLCNIC_LOOPBACK_TEST 2 |
@@ -2116,98 +2114,4 @@ static inline bool qlcnic_sriov_vf_check(struct qlcnic_adapter *adapter) | |||
2116 | 2114 | ||
2117 | return status; | 2115 | return status; |
2118 | } | 2116 | } |
2119 | |||
2120 | static inline int qlcnic_dcb_get_hw_capability(struct qlcnic_adapter *adapter) | ||
2121 | { | ||
2122 | struct qlcnic_dcb *dcb = adapter->dcb; | ||
2123 | |||
2124 | if (dcb && dcb->ops->get_hw_capability) | ||
2125 | return dcb->ops->get_hw_capability(adapter); | ||
2126 | |||
2127 | return 0; | ||
2128 | } | ||
2129 | |||
2130 | static inline void qlcnic_dcb_free(struct qlcnic_adapter *adapter) | ||
2131 | { | ||
2132 | struct qlcnic_dcb *dcb = adapter->dcb; | ||
2133 | |||
2134 | if (dcb && dcb->ops->free) | ||
2135 | dcb->ops->free(adapter); | ||
2136 | } | ||
2137 | |||
2138 | static inline int qlcnic_dcb_attach(struct qlcnic_adapter *adapter) | ||
2139 | { | ||
2140 | struct qlcnic_dcb *dcb = adapter->dcb; | ||
2141 | |||
2142 | if (dcb && dcb->ops->attach) | ||
2143 | return dcb->ops->attach(adapter); | ||
2144 | |||
2145 | return 0; | ||
2146 | } | ||
2147 | |||
2148 | static inline int | ||
2149 | qlcnic_dcb_query_hw_capability(struct qlcnic_adapter *adapter, char *buf) | ||
2150 | { | ||
2151 | struct qlcnic_dcb *dcb = adapter->dcb; | ||
2152 | |||
2153 | if (dcb && dcb->ops->query_hw_capability) | ||
2154 | return dcb->ops->query_hw_capability(adapter, buf); | ||
2155 | |||
2156 | return 0; | ||
2157 | } | ||
2158 | |||
2159 | static inline void qlcnic_dcb_get_info(struct qlcnic_adapter *adapter) | ||
2160 | { | ||
2161 | struct qlcnic_dcb *dcb = adapter->dcb; | ||
2162 | |||
2163 | if (dcb && dcb->ops->get_info) | ||
2164 | dcb->ops->get_info(adapter); | ||
2165 | } | ||
2166 | |||
2167 | static inline int | ||
2168 | qlcnic_dcb_query_cee_param(struct qlcnic_adapter *adapter, char *buf, u8 type) | ||
2169 | { | ||
2170 | struct qlcnic_dcb *dcb = adapter->dcb; | ||
2171 | |||
2172 | if (dcb && dcb->ops->query_cee_param) | ||
2173 | return dcb->ops->query_cee_param(adapter, buf, type); | ||
2174 | |||
2175 | return 0; | ||
2176 | } | ||
2177 | |||
2178 | static inline int qlcnic_dcb_get_cee_cfg(struct qlcnic_adapter *adapter) | ||
2179 | { | ||
2180 | struct qlcnic_dcb *dcb = adapter->dcb; | ||
2181 | |||
2182 | if (dcb && dcb->ops->get_cee_cfg) | ||
2183 | return dcb->ops->get_cee_cfg(adapter); | ||
2184 | |||
2185 | return 0; | ||
2186 | } | ||
2187 | |||
2188 | static inline void | ||
2189 | qlcnic_dcb_register_aen(struct qlcnic_adapter *adapter, u8 flag) | ||
2190 | { | ||
2191 | struct qlcnic_dcb *dcb = adapter->dcb; | ||
2192 | |||
2193 | if (dcb && dcb->ops->register_aen) | ||
2194 | dcb->ops->register_aen(adapter, flag); | ||
2195 | } | ||
2196 | |||
2197 | static inline void qlcnic_dcb_handle_aen(struct qlcnic_adapter *adapter, | ||
2198 | void *msg) | ||
2199 | { | ||
2200 | struct qlcnic_dcb *dcb = adapter->dcb; | ||
2201 | |||
2202 | if (dcb && dcb->ops->handle_aen) | ||
2203 | dcb->ops->handle_aen(adapter, msg); | ||
2204 | } | ||
2205 | |||
2206 | static inline void qlcnic_dcb_init_dcbnl_ops(struct qlcnic_adapter *adapter) | ||
2207 | { | ||
2208 | struct qlcnic_dcb *dcb = adapter->dcb; | ||
2209 | |||
2210 | if (dcb && dcb->ops->init_dcbnl_ops) | ||
2211 | dcb->ops->init_dcbnl_ops(adapter); | ||
2212 | } | ||
2213 | #endif /* __QLCNIC_H_ */ | 2117 | #endif /* __QLCNIC_H_ */ |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c index 268fda6f256e..a126bdf27952 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c | |||
@@ -902,7 +902,7 @@ void __qlcnic_83xx_process_aen(struct qlcnic_adapter *adapter) | |||
902 | QLCNIC_MBX_RSP(event[0])); | 902 | QLCNIC_MBX_RSP(event[0])); |
903 | break; | 903 | break; |
904 | case QLCNIC_MBX_DCBX_CONFIG_CHANGE_EVENT: | 904 | case QLCNIC_MBX_DCBX_CONFIG_CHANGE_EVENT: |
905 | qlcnic_dcb_handle_aen(adapter, (void *)&event[1]); | 905 | qlcnic_dcb_aen_handler(adapter->dcb, (void *)&event[1]); |
906 | break; | 906 | break; |
907 | default: | 907 | default: |
908 | dev_dbg(&adapter->pdev->dev, "Unsupported AEN:0x%x.\n", | 908 | dev_dbg(&adapter->pdev->dev, "Unsupported AEN:0x%x.\n", |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c index d303fab5394d..e2cd48417041 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c | |||
@@ -636,7 +636,7 @@ int qlcnic_83xx_idc_reattach_driver(struct qlcnic_adapter *adapter) | |||
636 | if (adapter->portnum == 0) | 636 | if (adapter->portnum == 0) |
637 | qlcnic_set_drv_version(adapter); | 637 | qlcnic_set_drv_version(adapter); |
638 | 638 | ||
639 | qlcnic_dcb_get_info(adapter); | 639 | qlcnic_dcb_get_info(adapter->dcb); |
640 | qlcnic_83xx_idc_attach_driver(adapter); | 640 | qlcnic_83xx_idc_attach_driver(adapter); |
641 | 641 | ||
642 | return 0; | 642 | return 0; |
@@ -2174,6 +2174,7 @@ static int qlcnic_83xx_get_fw_info(struct qlcnic_adapter *adapter) | |||
2174 | int qlcnic_83xx_init(struct qlcnic_adapter *adapter, int pci_using_dac) | 2174 | int qlcnic_83xx_init(struct qlcnic_adapter *adapter, int pci_using_dac) |
2175 | { | 2175 | { |
2176 | struct qlcnic_hardware_context *ahw = adapter->ahw; | 2176 | struct qlcnic_hardware_context *ahw = adapter->ahw; |
2177 | struct qlcnic_dcb *dcb; | ||
2177 | int err = 0; | 2178 | int err = 0; |
2178 | 2179 | ||
2179 | ahw->msix_supported = !!qlcnic_use_msi_x; | 2180 | ahw->msix_supported = !!qlcnic_use_msi_x; |
@@ -2231,8 +2232,10 @@ int qlcnic_83xx_init(struct qlcnic_adapter *adapter, int pci_using_dac) | |||
2231 | if (err) | 2232 | if (err) |
2232 | goto disable_mbx_intr; | 2233 | goto disable_mbx_intr; |
2233 | 2234 | ||
2234 | if (adapter->dcb && qlcnic_dcb_attach(adapter)) | 2235 | dcb = adapter->dcb; |
2235 | qlcnic_clear_dcb_ops(adapter); | 2236 | |
2237 | if (dcb && qlcnic_dcb_attach(dcb)) | ||
2238 | qlcnic_clear_dcb_ops(dcb); | ||
2236 | 2239 | ||
2237 | /* Periodically monitor device status */ | 2240 | /* Periodically monitor device status */ |
2238 | qlcnic_83xx_idc_poll_dev_state(&adapter->fw_work.work); | 2241 | qlcnic_83xx_idc_poll_dev_state(&adapter->fw_work.work); |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.c index d62d5ce432ec..86bca7c14f99 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.c | |||
@@ -57,22 +57,22 @@ static const struct dcbnl_rtnl_ops qlcnic_dcbnl_ops; | |||
57 | static void qlcnic_dcb_aen_work(struct work_struct *); | 57 | static void qlcnic_dcb_aen_work(struct work_struct *); |
58 | static void qlcnic_dcb_data_cee_param_map(struct qlcnic_adapter *); | 58 | static void qlcnic_dcb_data_cee_param_map(struct qlcnic_adapter *); |
59 | 59 | ||
60 | static inline void __qlcnic_init_dcbnl_ops(struct qlcnic_adapter *); | 60 | static inline void __qlcnic_init_dcbnl_ops(struct qlcnic_dcb *); |
61 | static void __qlcnic_dcb_free(struct qlcnic_adapter *); | 61 | static void __qlcnic_dcb_free(struct qlcnic_dcb *); |
62 | static int __qlcnic_dcb_attach(struct qlcnic_adapter *); | 62 | static int __qlcnic_dcb_attach(struct qlcnic_dcb *); |
63 | static int __qlcnic_dcb_query_hw_capability(struct qlcnic_adapter *, char *); | 63 | static int __qlcnic_dcb_query_hw_capability(struct qlcnic_dcb *, char *); |
64 | static void __qlcnic_dcb_get_info(struct qlcnic_adapter *); | 64 | static void __qlcnic_dcb_get_info(struct qlcnic_dcb *); |
65 | 65 | ||
66 | static int qlcnic_82xx_dcb_get_hw_capability(struct qlcnic_adapter *); | 66 | static int qlcnic_82xx_dcb_get_hw_capability(struct qlcnic_dcb *); |
67 | static int qlcnic_82xx_dcb_query_cee_param(struct qlcnic_adapter *, char *, u8); | 67 | static int qlcnic_82xx_dcb_query_cee_param(struct qlcnic_dcb *, char *, u8); |
68 | static int qlcnic_82xx_dcb_get_cee_cfg(struct qlcnic_adapter *); | 68 | static int qlcnic_82xx_dcb_get_cee_cfg(struct qlcnic_dcb *); |
69 | static void qlcnic_82xx_dcb_handle_aen(struct qlcnic_adapter *, void *); | 69 | static void qlcnic_82xx_dcb_aen_handler(struct qlcnic_dcb *, void *); |
70 | 70 | ||
71 | static int qlcnic_83xx_dcb_get_hw_capability(struct qlcnic_adapter *); | 71 | static int qlcnic_83xx_dcb_get_hw_capability(struct qlcnic_dcb *); |
72 | static int qlcnic_83xx_dcb_query_cee_param(struct qlcnic_adapter *, char *, u8); | 72 | static int qlcnic_83xx_dcb_query_cee_param(struct qlcnic_dcb *, char *, u8); |
73 | static int qlcnic_83xx_dcb_get_cee_cfg(struct qlcnic_adapter *); | 73 | static int qlcnic_83xx_dcb_get_cee_cfg(struct qlcnic_dcb *); |
74 | static int qlcnic_83xx_dcb_register_aen(struct qlcnic_adapter *, bool); | 74 | static int qlcnic_83xx_dcb_register_aen(struct qlcnic_dcb *, bool); |
75 | static void qlcnic_83xx_dcb_handle_aen(struct qlcnic_adapter *, void *); | 75 | static void qlcnic_83xx_dcb_aen_handler(struct qlcnic_dcb *, void *); |
76 | 76 | ||
77 | struct qlcnic_dcb_capability { | 77 | struct qlcnic_dcb_capability { |
78 | bool tsa_capability; | 78 | bool tsa_capability; |
@@ -180,7 +180,7 @@ static struct qlcnic_dcb_ops qlcnic_83xx_dcb_ops = { | |||
180 | .query_cee_param = qlcnic_83xx_dcb_query_cee_param, | 180 | .query_cee_param = qlcnic_83xx_dcb_query_cee_param, |
181 | .get_cee_cfg = qlcnic_83xx_dcb_get_cee_cfg, | 181 | .get_cee_cfg = qlcnic_83xx_dcb_get_cee_cfg, |
182 | .register_aen = qlcnic_83xx_dcb_register_aen, | 182 | .register_aen = qlcnic_83xx_dcb_register_aen, |
183 | .handle_aen = qlcnic_83xx_dcb_handle_aen, | 183 | .aen_handler = qlcnic_83xx_dcb_aen_handler, |
184 | }; | 184 | }; |
185 | 185 | ||
186 | static struct qlcnic_dcb_ops qlcnic_82xx_dcb_ops = { | 186 | static struct qlcnic_dcb_ops qlcnic_82xx_dcb_ops = { |
@@ -193,7 +193,7 @@ static struct qlcnic_dcb_ops qlcnic_82xx_dcb_ops = { | |||
193 | .get_hw_capability = qlcnic_82xx_dcb_get_hw_capability, | 193 | .get_hw_capability = qlcnic_82xx_dcb_get_hw_capability, |
194 | .query_cee_param = qlcnic_82xx_dcb_query_cee_param, | 194 | .query_cee_param = qlcnic_82xx_dcb_query_cee_param, |
195 | .get_cee_cfg = qlcnic_82xx_dcb_get_cee_cfg, | 195 | .get_cee_cfg = qlcnic_82xx_dcb_get_cee_cfg, |
196 | .handle_aen = qlcnic_82xx_dcb_handle_aen, | 196 | .aen_handler = qlcnic_82xx_dcb_aen_handler, |
197 | }; | 197 | }; |
198 | 198 | ||
199 | static u8 qlcnic_dcb_get_num_app(struct qlcnic_adapter *adapter, u32 val) | 199 | static u8 qlcnic_dcb_get_num_app(struct qlcnic_adapter *adapter, u32 val) |
@@ -242,10 +242,10 @@ static int qlcnic_dcb_prio_count(u8 up_tc_map) | |||
242 | return j; | 242 | return j; |
243 | } | 243 | } |
244 | 244 | ||
245 | static inline void __qlcnic_init_dcbnl_ops(struct qlcnic_adapter *adapter) | 245 | static inline void __qlcnic_init_dcbnl_ops(struct qlcnic_dcb *dcb) |
246 | { | 246 | { |
247 | if (test_bit(__QLCNIC_DCB_STATE, &adapter->state)) | 247 | if (test_bit(QLCNIC_DCB_STATE, &dcb->state)) |
248 | adapter->netdev->dcbnl_ops = &qlcnic_dcbnl_ops; | 248 | dcb->adapter->netdev->dcbnl_ops = &qlcnic_dcbnl_ops; |
249 | } | 249 | } |
250 | 250 | ||
251 | static void qlcnic_set_dcb_ops(struct qlcnic_adapter *adapter) | 251 | static void qlcnic_set_dcb_ops(struct qlcnic_adapter *adapter) |
@@ -256,7 +256,7 @@ static void qlcnic_set_dcb_ops(struct qlcnic_adapter *adapter) | |||
256 | adapter->dcb->ops = &qlcnic_83xx_dcb_ops; | 256 | adapter->dcb->ops = &qlcnic_83xx_dcb_ops; |
257 | } | 257 | } |
258 | 258 | ||
259 | int __qlcnic_register_dcb(struct qlcnic_adapter *adapter) | 259 | int qlcnic_register_dcb(struct qlcnic_adapter *adapter) |
260 | { | 260 | { |
261 | struct qlcnic_dcb *dcb; | 261 | struct qlcnic_dcb *dcb; |
262 | 262 | ||
@@ -267,20 +267,22 @@ int __qlcnic_register_dcb(struct qlcnic_adapter *adapter) | |||
267 | adapter->dcb = dcb; | 267 | adapter->dcb = dcb; |
268 | dcb->adapter = adapter; | 268 | dcb->adapter = adapter; |
269 | qlcnic_set_dcb_ops(adapter); | 269 | qlcnic_set_dcb_ops(adapter); |
270 | dcb->state = 0; | ||
270 | 271 | ||
271 | return 0; | 272 | return 0; |
272 | } | 273 | } |
273 | 274 | ||
274 | static void __qlcnic_dcb_free(struct qlcnic_adapter *adapter) | 275 | static void __qlcnic_dcb_free(struct qlcnic_dcb *dcb) |
275 | { | 276 | { |
276 | struct qlcnic_dcb *dcb = adapter->dcb; | 277 | struct qlcnic_adapter *adapter; |
277 | 278 | ||
278 | if (!dcb) | 279 | if (!dcb) |
279 | return; | 280 | return; |
280 | 281 | ||
281 | qlcnic_dcb_register_aen(adapter, 0); | 282 | adapter = dcb->adapter; |
283 | qlcnic_dcb_register_aen(dcb, 0); | ||
282 | 284 | ||
283 | while (test_bit(__QLCNIC_DCB_IN_AEN, &adapter->state)) | 285 | while (test_bit(QLCNIC_DCB_AEN_MODE, &dcb->state)) |
284 | usleep_range(10000, 11000); | 286 | usleep_range(10000, 11000); |
285 | 287 | ||
286 | cancel_delayed_work_sync(&dcb->aen_work); | 288 | cancel_delayed_work_sync(&dcb->aen_work); |
@@ -298,23 +300,22 @@ static void __qlcnic_dcb_free(struct qlcnic_adapter *adapter) | |||
298 | adapter->dcb = NULL; | 300 | adapter->dcb = NULL; |
299 | } | 301 | } |
300 | 302 | ||
301 | static void __qlcnic_dcb_get_info(struct qlcnic_adapter *adapter) | 303 | static void __qlcnic_dcb_get_info(struct qlcnic_dcb *dcb) |
302 | { | 304 | { |
303 | qlcnic_dcb_get_hw_capability(adapter); | 305 | qlcnic_dcb_get_hw_capability(dcb); |
304 | qlcnic_dcb_get_cee_cfg(adapter); | 306 | qlcnic_dcb_get_cee_cfg(dcb); |
305 | qlcnic_dcb_register_aen(adapter, 1); | 307 | qlcnic_dcb_register_aen(dcb, 1); |
306 | } | 308 | } |
307 | 309 | ||
308 | static int __qlcnic_dcb_attach(struct qlcnic_adapter *adapter) | 310 | static int __qlcnic_dcb_attach(struct qlcnic_dcb *dcb) |
309 | { | 311 | { |
310 | struct qlcnic_dcb *dcb = adapter->dcb; | ||
311 | int err = 0; | 312 | int err = 0; |
312 | 313 | ||
313 | INIT_DELAYED_WORK(&dcb->aen_work, qlcnic_dcb_aen_work); | 314 | INIT_DELAYED_WORK(&dcb->aen_work, qlcnic_dcb_aen_work); |
314 | 315 | ||
315 | dcb->wq = create_singlethread_workqueue("qlcnic-dcb"); | 316 | dcb->wq = create_singlethread_workqueue("qlcnic-dcb"); |
316 | if (!dcb->wq) { | 317 | if (!dcb->wq) { |
317 | dev_err(&adapter->pdev->dev, | 318 | dev_err(&dcb->adapter->pdev->dev, |
318 | "DCB workqueue allocation failed. DCB will be disabled\n"); | 319 | "DCB workqueue allocation failed. DCB will be disabled\n"); |
319 | return -1; | 320 | return -1; |
320 | } | 321 | } |
@@ -331,7 +332,7 @@ static int __qlcnic_dcb_attach(struct qlcnic_adapter *adapter) | |||
331 | goto out_free_cfg; | 332 | goto out_free_cfg; |
332 | } | 333 | } |
333 | 334 | ||
334 | qlcnic_dcb_get_info(adapter); | 335 | qlcnic_dcb_get_info(dcb); |
335 | 336 | ||
336 | return 0; | 337 | return 0; |
337 | out_free_cfg: | 338 | out_free_cfg: |
@@ -345,9 +346,9 @@ out_free_wq: | |||
345 | return err; | 346 | return err; |
346 | } | 347 | } |
347 | 348 | ||
348 | static int __qlcnic_dcb_query_hw_capability(struct qlcnic_adapter *adapter, | 349 | static int __qlcnic_dcb_query_hw_capability(struct qlcnic_dcb *dcb, char *buf) |
349 | char *buf) | ||
350 | { | 350 | { |
351 | struct qlcnic_adapter *adapter = dcb->adapter; | ||
351 | struct qlcnic_cmd_args cmd; | 352 | struct qlcnic_cmd_args cmd; |
352 | u32 mbx_out; | 353 | u32 mbx_out; |
353 | int err; | 354 | int err; |
@@ -371,15 +372,15 @@ static int __qlcnic_dcb_query_hw_capability(struct qlcnic_adapter *adapter, | |||
371 | return err; | 372 | return err; |
372 | } | 373 | } |
373 | 374 | ||
374 | static int __qlcnic_dcb_get_capability(struct qlcnic_adapter *adapter, u32 *val) | 375 | static int __qlcnic_dcb_get_capability(struct qlcnic_dcb *dcb, u32 *val) |
375 | { | 376 | { |
376 | struct qlcnic_dcb_capability *cap = &adapter->dcb->cfg->capability; | 377 | struct qlcnic_dcb_capability *cap = &dcb->cfg->capability; |
377 | u32 mbx_out; | 378 | u32 mbx_out; |
378 | int err; | 379 | int err; |
379 | 380 | ||
380 | memset(cap, 0, sizeof(struct qlcnic_dcb_capability)); | 381 | memset(cap, 0, sizeof(struct qlcnic_dcb_capability)); |
381 | 382 | ||
382 | err = qlcnic_dcb_query_hw_capability(adapter, (char *)val); | 383 | err = qlcnic_dcb_query_hw_capability(dcb, (char *)val); |
383 | if (err) | 384 | if (err) |
384 | return err; | 385 | return err; |
385 | 386 | ||
@@ -397,21 +398,21 @@ static int __qlcnic_dcb_get_capability(struct qlcnic_adapter *adapter, u32 *val) | |||
397 | if (cap->max_num_tc > QLC_DCB_MAX_TC || | 398 | if (cap->max_num_tc > QLC_DCB_MAX_TC || |
398 | cap->max_ets_tc > cap->max_num_tc || | 399 | cap->max_ets_tc > cap->max_num_tc || |
399 | cap->max_pfc_tc > cap->max_num_tc) { | 400 | cap->max_pfc_tc > cap->max_num_tc) { |
400 | dev_err(&adapter->pdev->dev, "Invalid DCB configuration\n"); | 401 | dev_err(&dcb->adapter->pdev->dev, "Invalid DCB configuration\n"); |
401 | return -EINVAL; | 402 | return -EINVAL; |
402 | } | 403 | } |
403 | 404 | ||
404 | return err; | 405 | return err; |
405 | } | 406 | } |
406 | 407 | ||
407 | static int qlcnic_82xx_dcb_get_hw_capability(struct qlcnic_adapter *adapter) | 408 | static int qlcnic_82xx_dcb_get_hw_capability(struct qlcnic_dcb *dcb) |
408 | { | 409 | { |
409 | struct qlcnic_dcb_cfg *cfg = adapter->dcb->cfg; | 410 | struct qlcnic_dcb_cfg *cfg = dcb->cfg; |
410 | struct qlcnic_dcb_capability *cap; | 411 | struct qlcnic_dcb_capability *cap; |
411 | u32 mbx_out; | 412 | u32 mbx_out; |
412 | int err; | 413 | int err; |
413 | 414 | ||
414 | err = __qlcnic_dcb_get_capability(adapter, &mbx_out); | 415 | err = __qlcnic_dcb_get_capability(dcb, &mbx_out); |
415 | if (err) | 416 | if (err) |
416 | return err; | 417 | return err; |
417 | 418 | ||
@@ -419,15 +420,16 @@ static int qlcnic_82xx_dcb_get_hw_capability(struct qlcnic_adapter *adapter) | |||
419 | cap->dcb_capability = DCB_CAP_DCBX_VER_CEE | DCB_CAP_DCBX_LLD_MANAGED; | 420 | cap->dcb_capability = DCB_CAP_DCBX_VER_CEE | DCB_CAP_DCBX_LLD_MANAGED; |
420 | 421 | ||
421 | if (cap->dcb_capability && cap->tsa_capability && cap->ets_capability) | 422 | if (cap->dcb_capability && cap->tsa_capability && cap->ets_capability) |
422 | set_bit(__QLCNIC_DCB_STATE, &adapter->state); | 423 | set_bit(QLCNIC_DCB_STATE, &dcb->state); |
423 | 424 | ||
424 | return err; | 425 | return err; |
425 | } | 426 | } |
426 | 427 | ||
427 | static int qlcnic_82xx_dcb_query_cee_param(struct qlcnic_adapter *adapter, | 428 | static int qlcnic_82xx_dcb_query_cee_param(struct qlcnic_dcb *dcb, |
428 | char *buf, u8 type) | 429 | char *buf, u8 type) |
429 | { | 430 | { |
430 | u16 size = sizeof(struct qlcnic_82xx_dcb_param_mbx_le); | 431 | u16 size = sizeof(struct qlcnic_82xx_dcb_param_mbx_le); |
432 | struct qlcnic_adapter *adapter = dcb->adapter; | ||
431 | struct qlcnic_82xx_dcb_param_mbx_le *prsp_le; | 433 | struct qlcnic_82xx_dcb_param_mbx_le *prsp_le; |
432 | struct device *dev = &adapter->pdev->dev; | 434 | struct device *dev = &adapter->pdev->dev; |
433 | dma_addr_t cardrsp_phys_addr; | 435 | dma_addr_t cardrsp_phys_addr; |
@@ -447,8 +449,7 @@ static int qlcnic_82xx_dcb_query_cee_param(struct qlcnic_adapter *adapter, | |||
447 | return -EINVAL; | 449 | return -EINVAL; |
448 | } | 450 | } |
449 | 451 | ||
450 | addr = dma_alloc_coherent(&adapter->pdev->dev, size, &cardrsp_phys_addr, | 452 | addr = dma_alloc_coherent(dev, size, &cardrsp_phys_addr, GFP_KERNEL); |
451 | GFP_KERNEL); | ||
452 | if (addr == NULL) | 453 | if (addr == NULL) |
453 | return -ENOMEM; | 454 | return -ENOMEM; |
454 | 455 | ||
@@ -488,72 +489,67 @@ out: | |||
488 | qlcnic_free_mbx_args(&cmd); | 489 | qlcnic_free_mbx_args(&cmd); |
489 | 490 | ||
490 | out_free_rsp: | 491 | out_free_rsp: |
491 | dma_free_coherent(&adapter->pdev->dev, size, addr, cardrsp_phys_addr); | 492 | dma_free_coherent(dev, size, addr, cardrsp_phys_addr); |
492 | 493 | ||
493 | return err; | 494 | return err; |
494 | } | 495 | } |
495 | 496 | ||
496 | static int qlcnic_82xx_dcb_get_cee_cfg(struct qlcnic_adapter *adapter) | 497 | static int qlcnic_82xx_dcb_get_cee_cfg(struct qlcnic_dcb *dcb) |
497 | { | 498 | { |
498 | struct qlcnic_dcb_mbx_params *mbx; | 499 | struct qlcnic_dcb_mbx_params *mbx; |
499 | int err; | 500 | int err; |
500 | 501 | ||
501 | mbx = adapter->dcb->param; | 502 | mbx = dcb->param; |
502 | if (!mbx) | 503 | if (!mbx) |
503 | return 0; | 504 | return 0; |
504 | 505 | ||
505 | err = qlcnic_dcb_query_cee_param(adapter, (char *)&mbx->type[0], | 506 | err = qlcnic_dcb_query_cee_param(dcb, (char *)&mbx->type[0], |
506 | QLC_DCB_LOCAL_PARAM_FWID); | 507 | QLC_DCB_LOCAL_PARAM_FWID); |
507 | if (err) | 508 | if (err) |
508 | return err; | 509 | return err; |
509 | 510 | ||
510 | err = qlcnic_dcb_query_cee_param(adapter, (char *)&mbx->type[1], | 511 | err = qlcnic_dcb_query_cee_param(dcb, (char *)&mbx->type[1], |
511 | QLC_DCB_OPER_PARAM_FWID); | 512 | QLC_DCB_OPER_PARAM_FWID); |
512 | if (err) | 513 | if (err) |
513 | return err; | 514 | return err; |
514 | 515 | ||
515 | err = qlcnic_dcb_query_cee_param(adapter, (char *)&mbx->type[2], | 516 | err = qlcnic_dcb_query_cee_param(dcb, (char *)&mbx->type[2], |
516 | QLC_DCB_PEER_PARAM_FWID); | 517 | QLC_DCB_PEER_PARAM_FWID); |
517 | if (err) | 518 | if (err) |
518 | return err; | 519 | return err; |
519 | 520 | ||
520 | mbx->prio_tc_map = QLC_82XX_DCB_PRIO_TC_MAP; | 521 | mbx->prio_tc_map = QLC_82XX_DCB_PRIO_TC_MAP; |
521 | 522 | ||
522 | qlcnic_dcb_data_cee_param_map(adapter); | 523 | qlcnic_dcb_data_cee_param_map(dcb->adapter); |
523 | 524 | ||
524 | return err; | 525 | return err; |
525 | } | 526 | } |
526 | 527 | ||
527 | static void qlcnic_dcb_aen_work(struct work_struct *work) | 528 | static void qlcnic_dcb_aen_work(struct work_struct *work) |
528 | { | 529 | { |
529 | struct qlcnic_adapter *adapter; | ||
530 | struct qlcnic_dcb *dcb; | 530 | struct qlcnic_dcb *dcb; |
531 | 531 | ||
532 | dcb = container_of(work, struct qlcnic_dcb, aen_work.work); | 532 | dcb = container_of(work, struct qlcnic_dcb, aen_work.work); |
533 | adapter = dcb->adapter; | ||
534 | 533 | ||
535 | qlcnic_dcb_get_cee_cfg(adapter); | 534 | qlcnic_dcb_get_cee_cfg(dcb); |
536 | clear_bit(__QLCNIC_DCB_IN_AEN, &adapter->state); | 535 | clear_bit(QLCNIC_DCB_AEN_MODE, &dcb->state); |
537 | } | 536 | } |
538 | 537 | ||
539 | static void qlcnic_82xx_dcb_handle_aen(struct qlcnic_adapter *adapter, | 538 | static void qlcnic_82xx_dcb_aen_handler(struct qlcnic_dcb *dcb, void *data) |
540 | void *data) | ||
541 | { | 539 | { |
542 | struct qlcnic_dcb *dcb = adapter->dcb; | 540 | if (test_and_set_bit(QLCNIC_DCB_AEN_MODE, &dcb->state)) |
543 | |||
544 | if (test_and_set_bit(__QLCNIC_DCB_IN_AEN, &adapter->state)) | ||
545 | return; | 541 | return; |
546 | 542 | ||
547 | queue_delayed_work(dcb->wq, &dcb->aen_work, 0); | 543 | queue_delayed_work(dcb->wq, &dcb->aen_work, 0); |
548 | } | 544 | } |
549 | 545 | ||
550 | static int qlcnic_83xx_dcb_get_hw_capability(struct qlcnic_adapter *adapter) | 546 | static int qlcnic_83xx_dcb_get_hw_capability(struct qlcnic_dcb *dcb) |
551 | { | 547 | { |
552 | struct qlcnic_dcb_capability *cap = &adapter->dcb->cfg->capability; | 548 | struct qlcnic_dcb_capability *cap = &dcb->cfg->capability; |
553 | u32 mbx_out; | 549 | u32 mbx_out; |
554 | int err; | 550 | int err; |
555 | 551 | ||
556 | err = __qlcnic_dcb_get_capability(adapter, &mbx_out); | 552 | err = __qlcnic_dcb_get_capability(dcb, &mbx_out); |
557 | if (err) | 553 | if (err) |
558 | return err; | 554 | return err; |
559 | 555 | ||
@@ -565,14 +561,15 @@ static int qlcnic_83xx_dcb_get_hw_capability(struct qlcnic_adapter *adapter) | |||
565 | cap->dcb_capability |= DCB_CAP_DCBX_LLD_MANAGED; | 561 | cap->dcb_capability |= DCB_CAP_DCBX_LLD_MANAGED; |
566 | 562 | ||
567 | if (cap->dcb_capability && cap->tsa_capability && cap->ets_capability) | 563 | if (cap->dcb_capability && cap->tsa_capability && cap->ets_capability) |
568 | set_bit(__QLCNIC_DCB_STATE, &adapter->state); | 564 | set_bit(QLCNIC_DCB_STATE, &dcb->state); |
569 | 565 | ||
570 | return err; | 566 | return err; |
571 | } | 567 | } |
572 | 568 | ||
573 | static int qlcnic_83xx_dcb_query_cee_param(struct qlcnic_adapter *adapter, | 569 | static int qlcnic_83xx_dcb_query_cee_param(struct qlcnic_dcb *dcb, |
574 | char *buf, u8 idx) | 570 | char *buf, u8 idx) |
575 | { | 571 | { |
572 | struct qlcnic_adapter *adapter = dcb->adapter; | ||
576 | struct qlcnic_dcb_mbx_params mbx_out; | 573 | struct qlcnic_dcb_mbx_params mbx_out; |
577 | int err, i, j, k, max_app, size; | 574 | int err, i, j, k, max_app, size; |
578 | struct qlcnic_dcb_param *each; | 575 | struct qlcnic_dcb_param *each; |
@@ -632,24 +629,23 @@ out: | |||
632 | return err; | 629 | return err; |
633 | } | 630 | } |
634 | 631 | ||
635 | static int qlcnic_83xx_dcb_get_cee_cfg(struct qlcnic_adapter *adapter) | 632 | static int qlcnic_83xx_dcb_get_cee_cfg(struct qlcnic_dcb *dcb) |
636 | { | 633 | { |
637 | struct qlcnic_dcb *dcb = adapter->dcb; | ||
638 | int err; | 634 | int err; |
639 | 635 | ||
640 | err = qlcnic_dcb_query_cee_param(adapter, (char *)dcb->param, 0); | 636 | err = qlcnic_dcb_query_cee_param(dcb, (char *)dcb->param, 0); |
641 | if (err) | 637 | if (err) |
642 | return err; | 638 | return err; |
643 | 639 | ||
644 | qlcnic_dcb_data_cee_param_map(adapter); | 640 | qlcnic_dcb_data_cee_param_map(dcb->adapter); |
645 | 641 | ||
646 | return err; | 642 | return err; |
647 | } | 643 | } |
648 | 644 | ||
649 | static int qlcnic_83xx_dcb_register_aen(struct qlcnic_adapter *adapter, | 645 | static int qlcnic_83xx_dcb_register_aen(struct qlcnic_dcb *dcb, bool flag) |
650 | bool flag) | ||
651 | { | 646 | { |
652 | u8 val = (flag ? QLCNIC_CMD_INIT_NIC_FUNC : QLCNIC_CMD_STOP_NIC_FUNC); | 647 | u8 val = (flag ? QLCNIC_CMD_INIT_NIC_FUNC : QLCNIC_CMD_STOP_NIC_FUNC); |
648 | struct qlcnic_adapter *adapter = dcb->adapter; | ||
653 | struct qlcnic_cmd_args cmd; | 649 | struct qlcnic_cmd_args cmd; |
654 | int err; | 650 | int err; |
655 | 651 | ||
@@ -669,19 +665,17 @@ static int qlcnic_83xx_dcb_register_aen(struct qlcnic_adapter *adapter, | |||
669 | return err; | 665 | return err; |
670 | } | 666 | } |
671 | 667 | ||
672 | static void qlcnic_83xx_dcb_handle_aen(struct qlcnic_adapter *adapter, | 668 | static void qlcnic_83xx_dcb_aen_handler(struct qlcnic_dcb *dcb, void *data) |
673 | void *data) | ||
674 | { | 669 | { |
675 | struct qlcnic_dcb *dcb = adapter->dcb; | ||
676 | u32 *val = data; | 670 | u32 *val = data; |
677 | 671 | ||
678 | if (test_and_set_bit(__QLCNIC_DCB_IN_AEN, &adapter->state)) | 672 | if (test_and_set_bit(QLCNIC_DCB_AEN_MODE, &dcb->state)) |
679 | return; | 673 | return; |
680 | 674 | ||
681 | if (*val & BIT_8) | 675 | if (*val & BIT_8) |
682 | set_bit(__QLCNIC_DCB_STATE, &adapter->state); | 676 | set_bit(QLCNIC_DCB_STATE, &dcb->state); |
683 | else | 677 | else |
684 | clear_bit(__QLCNIC_DCB_STATE, &adapter->state); | 678 | clear_bit(QLCNIC_DCB_STATE, &dcb->state); |
685 | 679 | ||
686 | queue_delayed_work(dcb->wq, &dcb->aen_work, 0); | 680 | queue_delayed_work(dcb->wq, &dcb->aen_work, 0); |
687 | } | 681 | } |
@@ -814,12 +808,12 @@ static u8 qlcnic_dcb_get_state(struct net_device *netdev) | |||
814 | { | 808 | { |
815 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | 809 | struct qlcnic_adapter *adapter = netdev_priv(netdev); |
816 | 810 | ||
817 | return test_bit(__QLCNIC_DCB_STATE, &adapter->state); | 811 | return test_bit(QLCNIC_DCB_STATE, &adapter->dcb->state); |
818 | } | 812 | } |
819 | 813 | ||
820 | static void qlcnic_dcb_get_perm_hw_addr(struct net_device *netdev, u8 *addr) | 814 | static void qlcnic_dcb_get_perm_hw_addr(struct net_device *netdev, u8 *addr) |
821 | { | 815 | { |
822 | memcpy(addr, netdev->dev_addr, netdev->addr_len); | 816 | memcpy(addr, netdev->perm_addr, netdev->addr_len); |
823 | } | 817 | } |
824 | 818 | ||
825 | static void | 819 | static void |
@@ -834,7 +828,7 @@ qlcnic_dcb_get_pg_tc_cfg_tx(struct net_device *netdev, int tc, u8 *prio, | |||
834 | type = &adapter->dcb->cfg->type[QLC_DCB_OPER_IDX]; | 828 | type = &adapter->dcb->cfg->type[QLC_DCB_OPER_IDX]; |
835 | *prio = *pgid = *bw_per = *up_tc_map = 0; | 829 | *prio = *pgid = *bw_per = *up_tc_map = 0; |
836 | 830 | ||
837 | if (!test_bit(__QLCNIC_DCB_STATE, &adapter->state) || | 831 | if (!test_bit(QLCNIC_DCB_STATE, &adapter->dcb->state) || |
838 | !type->tc_param_valid) | 832 | !type->tc_param_valid) |
839 | return; | 833 | return; |
840 | 834 | ||
@@ -870,7 +864,7 @@ static void qlcnic_dcb_get_pg_bwg_cfg_tx(struct net_device *netdev, int pgid, | |||
870 | *bw_pct = 0; | 864 | *bw_pct = 0; |
871 | type = &adapter->dcb->cfg->type[QLC_DCB_OPER_IDX]; | 865 | type = &adapter->dcb->cfg->type[QLC_DCB_OPER_IDX]; |
872 | 866 | ||
873 | if (!test_bit(__QLCNIC_DCB_STATE, &adapter->state) || | 867 | if (!test_bit(QLCNIC_DCB_STATE, &adapter->dcb->state) || |
874 | !type->tc_param_valid) | 868 | !type->tc_param_valid) |
875 | return; | 869 | return; |
876 | 870 | ||
@@ -896,7 +890,7 @@ static void qlcnic_dcb_get_pfc_cfg(struct net_device *netdev, int prio, | |||
896 | *setting = 0; | 890 | *setting = 0; |
897 | type = &adapter->dcb->cfg->type[QLC_DCB_OPER_IDX]; | 891 | type = &adapter->dcb->cfg->type[QLC_DCB_OPER_IDX]; |
898 | 892 | ||
899 | if (!test_bit(__QLCNIC_DCB_STATE, &adapter->state) || | 893 | if (!test_bit(QLCNIC_DCB_STATE, &adapter->dcb->state) || |
900 | !type->pfc_mode_enable) | 894 | !type->pfc_mode_enable) |
901 | return; | 895 | return; |
902 | 896 | ||
@@ -915,7 +909,7 @@ static u8 qlcnic_dcb_get_capability(struct net_device *netdev, int capid, | |||
915 | { | 909 | { |
916 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | 910 | struct qlcnic_adapter *adapter = netdev_priv(netdev); |
917 | 911 | ||
918 | if (!test_bit(__QLCNIC_DCB_STATE, &adapter->state)) | 912 | if (!test_bit(QLCNIC_DCB_STATE, &adapter->dcb->state)) |
919 | return 0; | 913 | return 0; |
920 | 914 | ||
921 | switch (capid) { | 915 | switch (capid) { |
@@ -944,7 +938,7 @@ static int qlcnic_dcb_get_num_tcs(struct net_device *netdev, int attr, u8 *num) | |||
944 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | 938 | struct qlcnic_adapter *adapter = netdev_priv(netdev); |
945 | struct qlcnic_dcb_cfg *cfg = adapter->dcb->cfg; | 939 | struct qlcnic_dcb_cfg *cfg = adapter->dcb->cfg; |
946 | 940 | ||
947 | if (!test_bit(__QLCNIC_DCB_STATE, &adapter->state)) | 941 | if (!test_bit(QLCNIC_DCB_STATE, &adapter->dcb->state)) |
948 | return -EINVAL; | 942 | return -EINVAL; |
949 | 943 | ||
950 | switch (attr) { | 944 | switch (attr) { |
@@ -967,7 +961,7 @@ static u8 qlcnic_dcb_get_app(struct net_device *netdev, u8 idtype, u16 id) | |||
967 | .protocol = id, | 961 | .protocol = id, |
968 | }; | 962 | }; |
969 | 963 | ||
970 | if (!test_bit(__QLCNIC_DCB_STATE, &adapter->state)) | 964 | if (!test_bit(QLCNIC_DCB_STATE, &adapter->dcb->state)) |
971 | return 0; | 965 | return 0; |
972 | 966 | ||
973 | return dcb_getapp(netdev, &app); | 967 | return dcb_getapp(netdev, &app); |
@@ -978,7 +972,7 @@ static u8 qlcnic_dcb_get_pfc_state(struct net_device *netdev) | |||
978 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | 972 | struct qlcnic_adapter *adapter = netdev_priv(netdev); |
979 | struct qlcnic_dcb *dcb = adapter->dcb; | 973 | struct qlcnic_dcb *dcb = adapter->dcb; |
980 | 974 | ||
981 | if (!test_bit(__QLCNIC_DCB_STATE, &adapter->state)) | 975 | if (!test_bit(QLCNIC_DCB_STATE, &dcb->state)) |
982 | return 0; | 976 | return 0; |
983 | 977 | ||
984 | return dcb->cfg->type[QLC_DCB_OPER_IDX].pfc_mode_enable; | 978 | return dcb->cfg->type[QLC_DCB_OPER_IDX].pfc_mode_enable; |
@@ -989,7 +983,7 @@ static u8 qlcnic_dcb_get_dcbx(struct net_device *netdev) | |||
989 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | 983 | struct qlcnic_adapter *adapter = netdev_priv(netdev); |
990 | struct qlcnic_dcb_cfg *cfg = adapter->dcb->cfg; | 984 | struct qlcnic_dcb_cfg *cfg = adapter->dcb->cfg; |
991 | 985 | ||
992 | if (!test_bit(__QLCNIC_DCB_STATE, &adapter->state)) | 986 | if (!test_bit(QLCNIC_DCB_STATE, &adapter->dcb->state)) |
993 | return 0; | 987 | return 0; |
994 | 988 | ||
995 | return cfg->capability.dcb_capability; | 989 | return cfg->capability.dcb_capability; |
@@ -1000,7 +994,7 @@ static u8 qlcnic_dcb_get_feat_cfg(struct net_device *netdev, int fid, u8 *flag) | |||
1000 | struct qlcnic_adapter *adapter = netdev_priv(netdev); | 994 | struct qlcnic_adapter *adapter = netdev_priv(netdev); |
1001 | struct qlcnic_dcb_cee *type; | 995 | struct qlcnic_dcb_cee *type; |
1002 | 996 | ||
1003 | if (!test_bit(__QLCNIC_DCB_STATE, &adapter->state)) | 997 | if (!test_bit(QLCNIC_DCB_STATE, &adapter->dcb->state)) |
1004 | return 1; | 998 | return 1; |
1005 | 999 | ||
1006 | type = &adapter->dcb->cfg->type[QLC_DCB_OPER_IDX]; | 1000 | type = &adapter->dcb->cfg->type[QLC_DCB_OPER_IDX]; |
@@ -1055,7 +1049,7 @@ static int qlcnic_dcb_peer_app_info(struct net_device *netdev, | |||
1055 | 1049 | ||
1056 | *app_count = 0; | 1050 | *app_count = 0; |
1057 | 1051 | ||
1058 | if (!test_bit(__QLCNIC_DCB_STATE, &adapter->state)) | 1052 | if (!test_bit(QLCNIC_DCB_STATE, &adapter->dcb->state)) |
1059 | return 0; | 1053 | return 0; |
1060 | 1054 | ||
1061 | peer = &adapter->dcb->cfg->type[QLC_DCB_PEER_IDX]; | 1055 | peer = &adapter->dcb->cfg->type[QLC_DCB_PEER_IDX]; |
@@ -1076,7 +1070,7 @@ static int qlcnic_dcb_peer_app_table(struct net_device *netdev, | |||
1076 | struct qlcnic_dcb_app *app; | 1070 | struct qlcnic_dcb_app *app; |
1077 | int i, j; | 1071 | int i, j; |
1078 | 1072 | ||
1079 | if (!test_bit(__QLCNIC_DCB_STATE, &adapter->state)) | 1073 | if (!test_bit(QLCNIC_DCB_STATE, &adapter->dcb->state)) |
1080 | return 0; | 1074 | return 0; |
1081 | 1075 | ||
1082 | peer = &adapter->dcb->cfg->type[QLC_DCB_PEER_IDX]; | 1076 | peer = &adapter->dcb->cfg->type[QLC_DCB_PEER_IDX]; |
@@ -1101,7 +1095,7 @@ static int qlcnic_dcb_cee_peer_get_pg(struct net_device *netdev, | |||
1101 | struct qlcnic_dcb_cee *peer; | 1095 | struct qlcnic_dcb_cee *peer; |
1102 | u8 i, j, k, map; | 1096 | u8 i, j, k, map; |
1103 | 1097 | ||
1104 | if (!test_bit(__QLCNIC_DCB_STATE, &adapter->state)) | 1098 | if (!test_bit(QLCNIC_DCB_STATE, &adapter->dcb->state)) |
1105 | return 0; | 1099 | return 0; |
1106 | 1100 | ||
1107 | peer = &adapter->dcb->cfg->type[QLC_DCB_PEER_IDX]; | 1101 | peer = &adapter->dcb->cfg->type[QLC_DCB_PEER_IDX]; |
@@ -1136,7 +1130,7 @@ static int qlcnic_dcb_cee_peer_get_pfc(struct net_device *netdev, | |||
1136 | 1130 | ||
1137 | pfc->pfc_en = 0; | 1131 | pfc->pfc_en = 0; |
1138 | 1132 | ||
1139 | if (!test_bit(__QLCNIC_DCB_STATE, &adapter->state)) | 1133 | if (!test_bit(QLCNIC_DCB_STATE, &adapter->dcb->state)) |
1140 | return 0; | 1134 | return 0; |
1141 | 1135 | ||
1142 | peer = &cfg->type[QLC_DCB_PEER_IDX]; | 1136 | peer = &cfg->type[QLC_DCB_PEER_IDX]; |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.h b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.h index b87ce9fb503e..c04ae0cdc108 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.h +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.h | |||
@@ -8,26 +8,29 @@ | |||
8 | #ifndef __QLCNIC_DCBX_H | 8 | #ifndef __QLCNIC_DCBX_H |
9 | #define __QLCNIC_DCBX_H | 9 | #define __QLCNIC_DCBX_H |
10 | 10 | ||
11 | void qlcnic_clear_dcb_ops(struct qlcnic_adapter *); | 11 | #define QLCNIC_DCB_STATE 0 |
12 | #define QLCNIC_DCB_AEN_MODE 1 | ||
12 | 13 | ||
13 | #ifdef CONFIG_QLCNIC_DCB | 14 | #ifdef CONFIG_QLCNIC_DCB |
14 | int __qlcnic_register_dcb(struct qlcnic_adapter *); | 15 | int qlcnic_register_dcb(struct qlcnic_adapter *); |
15 | #else | 16 | #else |
16 | static inline int __qlcnic_register_dcb(struct qlcnic_adapter *adapter) | 17 | static inline int qlcnic_register_dcb(struct qlcnic_adapter *adapter) |
17 | { return 0; } | 18 | { return 0; } |
18 | #endif | 19 | #endif |
19 | 20 | ||
21 | struct qlcnic_dcb; | ||
22 | |||
20 | struct qlcnic_dcb_ops { | 23 | struct qlcnic_dcb_ops { |
21 | void (*init_dcbnl_ops) (struct qlcnic_adapter *); | 24 | int (*query_hw_capability) (struct qlcnic_dcb *, char *); |
22 | void (*free) (struct qlcnic_adapter *); | 25 | int (*get_hw_capability) (struct qlcnic_dcb *); |
23 | int (*attach) (struct qlcnic_adapter *); | 26 | int (*query_cee_param) (struct qlcnic_dcb *, char *, u8); |
24 | int (*query_hw_capability) (struct qlcnic_adapter *, char *); | 27 | void (*init_dcbnl_ops) (struct qlcnic_dcb *); |
25 | int (*get_hw_capability) (struct qlcnic_adapter *); | 28 | int (*register_aen) (struct qlcnic_dcb *, bool); |
26 | void (*get_info) (struct qlcnic_adapter *); | 29 | void (*aen_handler) (struct qlcnic_dcb *, void *); |
27 | int (*query_cee_param) (struct qlcnic_adapter *, char *, u8); | 30 | int (*get_cee_cfg) (struct qlcnic_dcb *); |
28 | int (*get_cee_cfg) (struct qlcnic_adapter *); | 31 | void (*get_info) (struct qlcnic_dcb *); |
29 | int (*register_aen) (struct qlcnic_adapter *, bool); | 32 | int (*attach) (struct qlcnic_dcb *); |
30 | void (*handle_aen) (struct qlcnic_adapter *, void *); | 33 | void (*free) (struct qlcnic_dcb *); |
31 | }; | 34 | }; |
32 | 35 | ||
33 | struct qlcnic_dcb { | 36 | struct qlcnic_dcb { |
@@ -37,5 +40,85 @@ struct qlcnic_dcb { | |||
37 | struct workqueue_struct *wq; | 40 | struct workqueue_struct *wq; |
38 | struct qlcnic_dcb_ops *ops; | 41 | struct qlcnic_dcb_ops *ops; |
39 | struct qlcnic_dcb_cfg *cfg; | 42 | struct qlcnic_dcb_cfg *cfg; |
43 | unsigned long state; | ||
40 | }; | 44 | }; |
45 | |||
46 | static inline void qlcnic_clear_dcb_ops(struct qlcnic_dcb *dcb) | ||
47 | { | ||
48 | kfree(dcb); | ||
49 | dcb = NULL; | ||
50 | } | ||
51 | |||
52 | static inline int qlcnic_dcb_get_hw_capability(struct qlcnic_dcb *dcb) | ||
53 | { | ||
54 | if (dcb && dcb->ops->get_hw_capability) | ||
55 | return dcb->ops->get_hw_capability(dcb); | ||
56 | |||
57 | return 0; | ||
58 | } | ||
59 | |||
60 | static inline void qlcnic_dcb_free(struct qlcnic_dcb *dcb) | ||
61 | { | ||
62 | if (dcb && dcb->ops->free) | ||
63 | dcb->ops->free(dcb); | ||
64 | } | ||
65 | |||
66 | static inline int qlcnic_dcb_attach(struct qlcnic_dcb *dcb) | ||
67 | { | ||
68 | if (dcb && dcb->ops->attach) | ||
69 | return dcb->ops->attach(dcb); | ||
70 | |||
71 | return 0; | ||
72 | } | ||
73 | |||
74 | static inline int | ||
75 | qlcnic_dcb_query_hw_capability(struct qlcnic_dcb *dcb, char *buf) | ||
76 | { | ||
77 | if (dcb && dcb->ops->query_hw_capability) | ||
78 | return dcb->ops->query_hw_capability(dcb, buf); | ||
79 | |||
80 | return 0; | ||
81 | } | ||
82 | |||
83 | static inline void qlcnic_dcb_get_info(struct qlcnic_dcb *dcb) | ||
84 | { | ||
85 | if (dcb && dcb->ops->get_info) | ||
86 | dcb->ops->get_info(dcb); | ||
87 | } | ||
88 | |||
89 | static inline int | ||
90 | qlcnic_dcb_query_cee_param(struct qlcnic_dcb *dcb, char *buf, u8 type) | ||
91 | { | ||
92 | if (dcb && dcb->ops->query_cee_param) | ||
93 | return dcb->ops->query_cee_param(dcb, buf, type); | ||
94 | |||
95 | return 0; | ||
96 | } | ||
97 | |||
98 | static inline int qlcnic_dcb_get_cee_cfg(struct qlcnic_dcb *dcb) | ||
99 | { | ||
100 | if (dcb && dcb->ops->get_cee_cfg) | ||
101 | return dcb->ops->get_cee_cfg(dcb); | ||
102 | |||
103 | return 0; | ||
104 | } | ||
105 | |||
106 | static inline void | ||
107 | qlcnic_dcb_register_aen(struct qlcnic_dcb *dcb, u8 flag) | ||
108 | { | ||
109 | if (dcb && dcb->ops->register_aen) | ||
110 | dcb->ops->register_aen(dcb, flag); | ||
111 | } | ||
112 | |||
113 | static inline void qlcnic_dcb_aen_handler(struct qlcnic_dcb *dcb, void *msg) | ||
114 | { | ||
115 | if (dcb && dcb->ops->aen_handler) | ||
116 | dcb->ops->aen_handler(dcb, msg); | ||
117 | } | ||
118 | |||
119 | static inline void qlcnic_dcb_init_dcbnl_ops(struct qlcnic_dcb *dcb) | ||
120 | { | ||
121 | if (dcb && dcb->ops->init_dcbnl_ops) | ||
122 | dcb->ops->init_dcbnl_ops(dcb); | ||
123 | } | ||
41 | #endif | 124 | #endif |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c index 11b4bb83b930..897627dd1d04 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c | |||
@@ -1011,7 +1011,7 @@ static void qlcnic_handle_fw_message(int desc_cnt, int index, | |||
1011 | } | 1011 | } |
1012 | break; | 1012 | break; |
1013 | case QLCNIC_C2H_OPCODE_GET_DCB_AEN: | 1013 | case QLCNIC_C2H_OPCODE_GET_DCB_AEN: |
1014 | qlcnic_dcb_handle_aen(adapter, (void *)&msg); | 1014 | qlcnic_dcb_aen_handler(adapter->dcb, (void *)&msg); |
1015 | break; | 1015 | break; |
1016 | default: | 1016 | default: |
1017 | break; | 1017 | break; |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c index 725d76fab0a4..027483292932 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | |||
@@ -2071,7 +2071,7 @@ qlcnic_setup_netdev(struct qlcnic_adapter *adapter, struct net_device *netdev, | |||
2071 | return err; | 2071 | return err; |
2072 | } | 2072 | } |
2073 | 2073 | ||
2074 | qlcnic_dcb_init_dcbnl_ops(adapter); | 2074 | qlcnic_dcb_init_dcbnl_ops(adapter->dcb); |
2075 | 2075 | ||
2076 | return 0; | 2076 | return 0; |
2077 | } | 2077 | } |
@@ -2166,17 +2166,6 @@ void qlcnic_set_drv_version(struct qlcnic_adapter *adapter) | |||
2166 | qlcnic_fw_cmd_set_drv_version(adapter, fw_cmd); | 2166 | qlcnic_fw_cmd_set_drv_version(adapter, fw_cmd); |
2167 | } | 2167 | } |
2168 | 2168 | ||
2169 | static int qlcnic_register_dcb(struct qlcnic_adapter *adapter) | ||
2170 | { | ||
2171 | return __qlcnic_register_dcb(adapter); | ||
2172 | } | ||
2173 | |||
2174 | void qlcnic_clear_dcb_ops(struct qlcnic_adapter *adapter) | ||
2175 | { | ||
2176 | kfree(adapter->dcb); | ||
2177 | adapter->dcb = NULL; | ||
2178 | } | ||
2179 | |||
2180 | static int | 2169 | static int |
2181 | qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | 2170 | qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) |
2182 | { | 2171 | { |
@@ -2185,6 +2174,7 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2185 | struct qlcnic_hardware_context *ahw; | 2174 | struct qlcnic_hardware_context *ahw; |
2186 | int err, pci_using_dac = -1; | 2175 | int err, pci_using_dac = -1; |
2187 | char board_name[QLCNIC_MAX_BOARD_NAME_LEN + 19]; /* MAC + ": " + name */ | 2176 | char board_name[QLCNIC_MAX_BOARD_NAME_LEN + 19]; /* MAC + ": " + name */ |
2177 | struct qlcnic_dcb *dcb; | ||
2188 | 2178 | ||
2189 | if (pdev->is_virtfn) | 2179 | if (pdev->is_virtfn) |
2190 | return -ENODEV; | 2180 | return -ENODEV; |
@@ -2305,8 +2295,10 @@ qlcnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
2305 | 2295 | ||
2306 | adapter->flags |= QLCNIC_NEED_FLR; | 2296 | adapter->flags |= QLCNIC_NEED_FLR; |
2307 | 2297 | ||
2308 | if (adapter->dcb && qlcnic_dcb_attach(adapter)) | 2298 | dcb = adapter->dcb; |
2309 | qlcnic_clear_dcb_ops(adapter); | 2299 | |
2300 | if (dcb && qlcnic_dcb_attach(dcb)) | ||
2301 | qlcnic_clear_dcb_ops(dcb); | ||
2310 | 2302 | ||
2311 | } else if (qlcnic_83xx_check(adapter)) { | 2303 | } else if (qlcnic_83xx_check(adapter)) { |
2312 | adapter->max_drv_tx_rings = 1; | 2304 | adapter->max_drv_tx_rings = 1; |
@@ -2451,7 +2443,7 @@ static void qlcnic_remove(struct pci_dev *pdev) | |||
2451 | qlcnic_cancel_idc_work(adapter); | 2443 | qlcnic_cancel_idc_work(adapter); |
2452 | ahw = adapter->ahw; | 2444 | ahw = adapter->ahw; |
2453 | 2445 | ||
2454 | qlcnic_dcb_free(adapter); | 2446 | qlcnic_dcb_free(adapter->dcb); |
2455 | 2447 | ||
2456 | unregister_netdev(netdev); | 2448 | unregister_netdev(netdev); |
2457 | qlcnic_sriov_cleanup(adapter); | 2449 | qlcnic_sriov_cleanup(adapter); |
@@ -3329,7 +3321,7 @@ qlcnic_attach_work(struct work_struct *work) | |||
3329 | return; | 3321 | return; |
3330 | } | 3322 | } |
3331 | attach: | 3323 | attach: |
3332 | qlcnic_dcb_get_info(adapter); | 3324 | qlcnic_dcb_get_info(adapter->dcb); |
3333 | 3325 | ||
3334 | if (netif_running(netdev)) { | 3326 | if (netif_running(netdev)) { |
3335 | if (qlcnic_up(adapter, netdev)) | 3327 | if (qlcnic_up(adapter, netdev)) |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c index 392b9bd12b4f..8b96e29df30f 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c | |||
@@ -500,6 +500,7 @@ static int qlcnic_sriov_vf_init_driver(struct qlcnic_adapter *adapter) | |||
500 | static int qlcnic_sriov_setup_vf(struct qlcnic_adapter *adapter, | 500 | static int qlcnic_sriov_setup_vf(struct qlcnic_adapter *adapter, |
501 | int pci_using_dac) | 501 | int pci_using_dac) |
502 | { | 502 | { |
503 | struct qlcnic_dcb *dcb; | ||
503 | int err; | 504 | int err; |
504 | 505 | ||
505 | INIT_LIST_HEAD(&adapter->vf_mc_list); | 506 | INIT_LIST_HEAD(&adapter->vf_mc_list); |
@@ -533,8 +534,10 @@ static int qlcnic_sriov_setup_vf(struct qlcnic_adapter *adapter, | |||
533 | if (err) | 534 | if (err) |
534 | goto err_out_send_channel_term; | 535 | goto err_out_send_channel_term; |
535 | 536 | ||
536 | if (adapter->dcb && qlcnic_dcb_attach(adapter)) | 537 | dcb = adapter->dcb; |
537 | qlcnic_clear_dcb_ops(adapter); | 538 | |
539 | if (dcb && qlcnic_dcb_attach(dcb)) | ||
540 | qlcnic_clear_dcb_ops(dcb); | ||
538 | 541 | ||
539 | err = qlcnic_setup_netdev(adapter, adapter->netdev, pci_using_dac); | 542 | err = qlcnic_setup_netdev(adapter, adapter->netdev, pci_using_dac); |
540 | if (err) | 543 | if (err) |
@@ -1577,7 +1580,7 @@ static int qlcnic_sriov_vf_reinit_driver(struct qlcnic_adapter *adapter) | |||
1577 | if (err) | 1580 | if (err) |
1578 | goto err_out_term_channel; | 1581 | goto err_out_term_channel; |
1579 | 1582 | ||
1580 | qlcnic_dcb_get_info(adapter); | 1583 | qlcnic_dcb_get_info(adapter->dcb); |
1581 | 1584 | ||
1582 | return 0; | 1585 | return 0; |
1583 | 1586 | ||