qed: Use ieee mfw-mask to get ethtype in ieee-dcbx mode.
[cascardo/linux.git] / drivers / net / ethernet / qlogic / qed / qed_dcbx.c
1 /* QLogic qed NIC Driver
2  * Copyright (c) 2015 QLogic Corporation
3  *
4  * This software is available under the terms of the GNU General Public License
5  * (GPL) Version 2, available from the file COPYING in the main directory of
6  * this source tree.
7  */
8
9 #include <linux/types.h>
10 #include <asm/byteorder.h>
11 #include <linux/bitops.h>
12 #include <linux/dcbnl.h>
13 #include <linux/errno.h>
14 #include <linux/kernel.h>
15 #include <linux/slab.h>
16 #include <linux/string.h>
17 #include "qed.h"
18 #include "qed_cxt.h"
19 #include "qed_dcbx.h"
20 #include "qed_hsi.h"
21 #include "qed_sp.h"
22 #ifdef CONFIG_DCB
23 #include <linux/qed/qed_eth_if.h>
24 #endif
25
26 #define QED_DCBX_MAX_MIB_READ_TRY       (100)
27 #define QED_ETH_TYPE_DEFAULT            (0)
28 #define QED_ETH_TYPE_ROCE               (0x8915)
29 #define QED_UDP_PORT_TYPE_ROCE_V2       (0x12B7)
30 #define QED_ETH_TYPE_FCOE               (0x8906)
31 #define QED_TCP_PORT_ISCSI              (0xCBC)
32
33 #define QED_DCBX_INVALID_PRIORITY       0xFF
34
35 /* Get Traffic Class from priority traffic class table, 4 bits represent
36  * the traffic class corresponding to the priority.
37  */
38 #define QED_DCBX_PRIO2TC(prio_tc_tbl, prio) \
39         ((u32)(prio_tc_tbl >> ((7 - prio) * 4)) & 0x7)
40
41 static const struct qed_dcbx_app_metadata qed_dcbx_app_update[] = {
42         {DCBX_PROTOCOL_ISCSI, "ISCSI", QED_PCI_DEFAULT},
43         {DCBX_PROTOCOL_FCOE, "FCOE", QED_PCI_DEFAULT},
44         {DCBX_PROTOCOL_ROCE, "ROCE", QED_PCI_DEFAULT},
45         {DCBX_PROTOCOL_ROCE_V2, "ROCE_V2", QED_PCI_DEFAULT},
46         {DCBX_PROTOCOL_ETH, "ETH", QED_PCI_ETH}
47 };
48
49 static bool qed_dcbx_app_ethtype(u32 app_info_bitmap)
50 {
51         return !!(QED_MFW_GET_FIELD(app_info_bitmap, DCBX_APP_SF) ==
52                   DCBX_APP_SF_ETHTYPE);
53 }
54
55 static bool qed_dcbx_ieee_app_ethtype(u32 app_info_bitmap)
56 {
57         u8 mfw_val = QED_MFW_GET_FIELD(app_info_bitmap, DCBX_APP_SF_IEEE);
58
59         /* Old MFW */
60         if (mfw_val == DCBX_APP_SF_IEEE_RESERVED)
61                 return qed_dcbx_app_ethtype(app_info_bitmap);
62
63         return !!(mfw_val == DCBX_APP_SF_IEEE_ETHTYPE);
64 }
65
66 static bool qed_dcbx_app_port(u32 app_info_bitmap)
67 {
68         return !!(QED_MFW_GET_FIELD(app_info_bitmap, DCBX_APP_SF) ==
69                   DCBX_APP_SF_PORT);
70 }
71
72 static bool qed_dcbx_default_tlv(u32 app_info_bitmap, u16 proto_id, bool ieee)
73 {
74         bool ethtype;
75
76         if (ieee)
77                 ethtype = qed_dcbx_ieee_app_ethtype(app_info_bitmap);
78         else
79                 ethtype = qed_dcbx_app_ethtype(app_info_bitmap);
80
81         return !!(ethtype && (proto_id == QED_ETH_TYPE_DEFAULT));
82 }
83
84 static bool qed_dcbx_iscsi_tlv(u32 app_info_bitmap, u16 proto_id)
85 {
86         return !!(qed_dcbx_app_port(app_info_bitmap) &&
87                   proto_id == QED_TCP_PORT_ISCSI);
88 }
89
90 static bool qed_dcbx_fcoe_tlv(u32 app_info_bitmap, u16 proto_id, bool ieee)
91 {
92         bool ethtype;
93
94         if (ieee)
95                 ethtype = qed_dcbx_ieee_app_ethtype(app_info_bitmap);
96         else
97                 ethtype = qed_dcbx_app_ethtype(app_info_bitmap);
98
99         return !!(ethtype && (proto_id == QED_ETH_TYPE_FCOE));
100 }
101
102 static bool qed_dcbx_roce_tlv(u32 app_info_bitmap, u16 proto_id, bool ieee)
103 {
104         bool ethtype;
105
106         if (ieee)
107                 ethtype = qed_dcbx_ieee_app_ethtype(app_info_bitmap);
108         else
109                 ethtype = qed_dcbx_app_ethtype(app_info_bitmap);
110
111         return !!(ethtype && (proto_id == QED_ETH_TYPE_ROCE));
112 }
113
114 static bool qed_dcbx_roce_v2_tlv(u32 app_info_bitmap, u16 proto_id)
115 {
116         return !!(qed_dcbx_app_port(app_info_bitmap) &&
117                   proto_id == QED_UDP_PORT_TYPE_ROCE_V2);
118 }
119
120 static void
121 qed_dcbx_dp_protocol(struct qed_hwfn *p_hwfn, struct qed_dcbx_results *p_data)
122 {
123         enum dcbx_protocol_type id;
124         int i;
125
126         DP_VERBOSE(p_hwfn, QED_MSG_DCB, "DCBX negotiated: %d\n",
127                    p_data->dcbx_enabled);
128
129         for (i = 0; i < ARRAY_SIZE(qed_dcbx_app_update); i++) {
130                 id = qed_dcbx_app_update[i].id;
131
132                 DP_VERBOSE(p_hwfn, QED_MSG_DCB,
133                            "%s info: update %d, enable %d, prio %d, tc %d, num_tc %d\n",
134                            qed_dcbx_app_update[i].name, p_data->arr[id].update,
135                            p_data->arr[id].enable, p_data->arr[id].priority,
136                            p_data->arr[id].tc, p_hwfn->hw_info.num_tc);
137         }
138 }
139
140 static void
141 qed_dcbx_set_params(struct qed_dcbx_results *p_data,
142                     struct qed_hw_info *p_info,
143                     bool enable,
144                     bool update,
145                     u8 prio,
146                     u8 tc,
147                     enum dcbx_protocol_type type,
148                     enum qed_pci_personality personality)
149 {
150         /* PF update ramrod data */
151         p_data->arr[type].update = update;
152         p_data->arr[type].enable = enable;
153         p_data->arr[type].priority = prio;
154         p_data->arr[type].tc = tc;
155
156         /* QM reconf data */
157         if (p_info->personality == personality) {
158                 if (personality == QED_PCI_ETH)
159                         p_info->non_offload_tc = tc;
160                 else
161                         p_info->offload_tc = tc;
162         }
163 }
164
165 /* Update app protocol data and hw_info fields with the TLV info */
166 static void
167 qed_dcbx_update_app_info(struct qed_dcbx_results *p_data,
168                          struct qed_hwfn *p_hwfn,
169                          bool enable,
170                          bool update,
171                          u8 prio, u8 tc, enum dcbx_protocol_type type)
172 {
173         struct qed_hw_info *p_info = &p_hwfn->hw_info;
174         enum qed_pci_personality personality;
175         enum dcbx_protocol_type id;
176         char *name;
177         int i;
178
179         for (i = 0; i < ARRAY_SIZE(qed_dcbx_app_update); i++) {
180                 id = qed_dcbx_app_update[i].id;
181
182                 if (type != id)
183                         continue;
184
185                 personality = qed_dcbx_app_update[i].personality;
186                 name = qed_dcbx_app_update[i].name;
187
188                 qed_dcbx_set_params(p_data, p_info, enable, update,
189                                     prio, tc, type, personality);
190         }
191 }
192
193 static bool
194 qed_dcbx_get_app_protocol_type(struct qed_hwfn *p_hwfn,
195                                u32 app_prio_bitmap,
196                                u16 id, enum dcbx_protocol_type *type, bool ieee)
197 {
198         if (qed_dcbx_fcoe_tlv(app_prio_bitmap, id, ieee)) {
199                 *type = DCBX_PROTOCOL_FCOE;
200         } else if (qed_dcbx_roce_tlv(app_prio_bitmap, id, ieee)) {
201                 *type = DCBX_PROTOCOL_ROCE;
202         } else if (qed_dcbx_iscsi_tlv(app_prio_bitmap, id)) {
203                 *type = DCBX_PROTOCOL_ISCSI;
204         } else if (qed_dcbx_default_tlv(app_prio_bitmap, id, ieee)) {
205                 *type = DCBX_PROTOCOL_ETH;
206         } else if (qed_dcbx_roce_v2_tlv(app_prio_bitmap, id)) {
207                 *type = DCBX_PROTOCOL_ROCE_V2;
208         } else {
209                 *type = DCBX_MAX_PROTOCOL_TYPE;
210                 DP_ERR(p_hwfn,
211                        "No action required, App TLV id = 0x%x app_prio_bitmap = 0x%x\n",
212                        id, app_prio_bitmap);
213                 return false;
214         }
215
216         return true;
217 }
218
219 /* Parse app TLV's to update TC information in hw_info structure for
220  * reconfiguring QM. Get protocol specific data for PF update ramrod command.
221  */
222 static int
223 qed_dcbx_process_tlv(struct qed_hwfn *p_hwfn,
224                      struct qed_dcbx_results *p_data,
225                      struct dcbx_app_priority_entry *p_tbl,
226                      u32 pri_tc_tbl, int count, u8 dcbx_version)
227 {
228         u8 tc, priority_map;
229         enum dcbx_protocol_type type;
230         bool enable, ieee;
231         u16 protocol_id;
232         int priority;
233         int i;
234
235         DP_VERBOSE(p_hwfn, QED_MSG_DCB, "Num APP entries = %d\n", count);
236
237         ieee = (dcbx_version == DCBX_CONFIG_VERSION_IEEE);
238         /* Parse APP TLV */
239         for (i = 0; i < count; i++) {
240                 protocol_id = QED_MFW_GET_FIELD(p_tbl[i].entry,
241                                                 DCBX_APP_PROTOCOL_ID);
242                 priority_map = QED_MFW_GET_FIELD(p_tbl[i].entry,
243                                                  DCBX_APP_PRI_MAP);
244                 priority = ffs(priority_map) - 1;
245                 if (priority < 0) {
246                         DP_ERR(p_hwfn, "Invalid priority\n");
247                         return -EINVAL;
248                 }
249
250                 tc = QED_DCBX_PRIO2TC(pri_tc_tbl, priority);
251                 if (qed_dcbx_get_app_protocol_type(p_hwfn, p_tbl[i].entry,
252                                                    protocol_id, &type, ieee)) {
253                         /* ETH always have the enable bit reset, as it gets
254                          * vlan information per packet. For other protocols,
255                          * should be set according to the dcbx_enabled
256                          * indication, but we only got here if there was an
257                          * app tlv for the protocol, so dcbx must be enabled.
258                          */
259                         enable = !(type == DCBX_PROTOCOL_ETH);
260
261                         qed_dcbx_update_app_info(p_data, p_hwfn, enable, true,
262                                                  priority, tc, type);
263                 }
264         }
265
266         /* If RoCE-V2 TLV is not detected, driver need to use RoCE app
267          * data for RoCE-v2 not the default app data.
268          */
269         if (!p_data->arr[DCBX_PROTOCOL_ROCE_V2].update &&
270             p_data->arr[DCBX_PROTOCOL_ROCE].update) {
271                 tc = p_data->arr[DCBX_PROTOCOL_ROCE].tc;
272                 priority = p_data->arr[DCBX_PROTOCOL_ROCE].priority;
273                 qed_dcbx_update_app_info(p_data, p_hwfn, true, true,
274                                          priority, tc, DCBX_PROTOCOL_ROCE_V2);
275         }
276
277         /* Update ramrod protocol data and hw_info fields
278          * with default info when corresponding APP TLV's are not detected.
279          * The enabled field has a different logic for ethernet as only for
280          * ethernet dcb should disabled by default, as the information arrives
281          * from the OS (unless an explicit app tlv was present).
282          */
283         tc = p_data->arr[DCBX_PROTOCOL_ETH].tc;
284         priority = p_data->arr[DCBX_PROTOCOL_ETH].priority;
285         for (type = 0; type < DCBX_MAX_PROTOCOL_TYPE; type++) {
286                 if (p_data->arr[type].update)
287                         continue;
288
289                 enable = !(type == DCBX_PROTOCOL_ETH);
290                 qed_dcbx_update_app_info(p_data, p_hwfn, enable, true,
291                                          priority, tc, type);
292         }
293
294         return 0;
295 }
296
297 /* Parse app TLV's to update TC information in hw_info structure for
298  * reconfiguring QM. Get protocol specific data for PF update ramrod command.
299  */
300 static int qed_dcbx_process_mib_info(struct qed_hwfn *p_hwfn)
301 {
302         struct dcbx_app_priority_feature *p_app;
303         struct dcbx_app_priority_entry *p_tbl;
304         struct qed_dcbx_results data = { 0 };
305         struct dcbx_ets_feature *p_ets;
306         struct qed_hw_info *p_info;
307         u32 pri_tc_tbl, flags;
308         u8 dcbx_version;
309         int num_entries;
310         int rc = 0;
311
312         flags = p_hwfn->p_dcbx_info->operational.flags;
313         dcbx_version = QED_MFW_GET_FIELD(flags, DCBX_CONFIG_VERSION);
314
315         p_app = &p_hwfn->p_dcbx_info->operational.features.app;
316         p_tbl = p_app->app_pri_tbl;
317
318         p_ets = &p_hwfn->p_dcbx_info->operational.features.ets;
319         pri_tc_tbl = p_ets->pri_tc_tbl[0];
320
321         p_info = &p_hwfn->hw_info;
322         num_entries = QED_MFW_GET_FIELD(p_app->flags, DCBX_APP_NUM_ENTRIES);
323
324         rc = qed_dcbx_process_tlv(p_hwfn, &data, p_tbl, pri_tc_tbl,
325                                   num_entries, dcbx_version);
326         if (rc)
327                 return rc;
328
329         p_info->num_tc = QED_MFW_GET_FIELD(p_ets->flags, DCBX_ETS_MAX_TCS);
330         data.pf_id = p_hwfn->rel_pf_id;
331         data.dcbx_enabled = !!dcbx_version;
332
333         qed_dcbx_dp_protocol(p_hwfn, &data);
334
335         memcpy(&p_hwfn->p_dcbx_info->results, &data,
336                sizeof(struct qed_dcbx_results));
337
338         return 0;
339 }
340
341 static int
342 qed_dcbx_copy_mib(struct qed_hwfn *p_hwfn,
343                   struct qed_ptt *p_ptt,
344                   struct qed_dcbx_mib_meta_data *p_data,
345                   enum qed_mib_read_type type)
346 {
347         u32 prefix_seq_num, suffix_seq_num;
348         int read_count = 0;
349         int rc = 0;
350
351         /* The data is considered to be valid only if both sequence numbers are
352          * the same.
353          */
354         do {
355                 if (type == QED_DCBX_REMOTE_LLDP_MIB) {
356                         qed_memcpy_from(p_hwfn, p_ptt, p_data->lldp_remote,
357                                         p_data->addr, p_data->size);
358                         prefix_seq_num = p_data->lldp_remote->prefix_seq_num;
359                         suffix_seq_num = p_data->lldp_remote->suffix_seq_num;
360                 } else {
361                         qed_memcpy_from(p_hwfn, p_ptt, p_data->mib,
362                                         p_data->addr, p_data->size);
363                         prefix_seq_num = p_data->mib->prefix_seq_num;
364                         suffix_seq_num = p_data->mib->suffix_seq_num;
365                 }
366                 read_count++;
367
368                 DP_VERBOSE(p_hwfn,
369                            QED_MSG_DCB,
370                            "mib type = %d, try count = %d prefix seq num  = %d suffix seq num = %d\n",
371                            type, read_count, prefix_seq_num, suffix_seq_num);
372         } while ((prefix_seq_num != suffix_seq_num) &&
373                  (read_count < QED_DCBX_MAX_MIB_READ_TRY));
374
375         if (read_count >= QED_DCBX_MAX_MIB_READ_TRY) {
376                 DP_ERR(p_hwfn,
377                        "MIB read err, mib type = %d, try count = %d prefix seq num = %d suffix seq num = %d\n",
378                        type, read_count, prefix_seq_num, suffix_seq_num);
379                 rc = -EIO;
380         }
381
382         return rc;
383 }
384
385 #ifdef CONFIG_DCB
386 static void
387 qed_dcbx_get_priority_info(struct qed_hwfn *p_hwfn,
388                            struct qed_dcbx_app_prio *p_prio,
389                            struct qed_dcbx_results *p_results)
390 {
391         u8 val;
392
393         p_prio->roce = QED_DCBX_INVALID_PRIORITY;
394         p_prio->roce_v2 = QED_DCBX_INVALID_PRIORITY;
395         p_prio->iscsi = QED_DCBX_INVALID_PRIORITY;
396         p_prio->fcoe = QED_DCBX_INVALID_PRIORITY;
397
398         if (p_results->arr[DCBX_PROTOCOL_ROCE].update &&
399             p_results->arr[DCBX_PROTOCOL_ROCE].enable)
400                 p_prio->roce = p_results->arr[DCBX_PROTOCOL_ROCE].priority;
401
402         if (p_results->arr[DCBX_PROTOCOL_ROCE_V2].update &&
403             p_results->arr[DCBX_PROTOCOL_ROCE_V2].enable) {
404                 val = p_results->arr[DCBX_PROTOCOL_ROCE_V2].priority;
405                 p_prio->roce_v2 = val;
406         }
407
408         if (p_results->arr[DCBX_PROTOCOL_ISCSI].update &&
409             p_results->arr[DCBX_PROTOCOL_ISCSI].enable)
410                 p_prio->iscsi = p_results->arr[DCBX_PROTOCOL_ISCSI].priority;
411
412         if (p_results->arr[DCBX_PROTOCOL_FCOE].update &&
413             p_results->arr[DCBX_PROTOCOL_FCOE].enable)
414                 p_prio->fcoe = p_results->arr[DCBX_PROTOCOL_FCOE].priority;
415
416         if (p_results->arr[DCBX_PROTOCOL_ETH].update &&
417             p_results->arr[DCBX_PROTOCOL_ETH].enable)
418                 p_prio->eth = p_results->arr[DCBX_PROTOCOL_ETH].priority;
419
420         DP_VERBOSE(p_hwfn, QED_MSG_DCB,
421                    "Priorities: iscsi %d, roce %d, roce v2 %d, fcoe %d, eth %d\n",
422                    p_prio->iscsi, p_prio->roce, p_prio->roce_v2, p_prio->fcoe,
423                    p_prio->eth);
424 }
425
426 static void
427 qed_dcbx_get_app_data(struct qed_hwfn *p_hwfn,
428                       struct dcbx_app_priority_feature *p_app,
429                       struct dcbx_app_priority_entry *p_tbl,
430                       struct qed_dcbx_params *p_params, bool ieee)
431 {
432         struct qed_app_entry *entry;
433         u8 pri_map;
434         int i;
435
436         p_params->app_willing = QED_MFW_GET_FIELD(p_app->flags,
437                                                   DCBX_APP_WILLING);
438         p_params->app_valid = QED_MFW_GET_FIELD(p_app->flags, DCBX_APP_ENABLED);
439         p_params->app_error = QED_MFW_GET_FIELD(p_app->flags, DCBX_APP_ERROR);
440         p_params->num_app_entries = QED_MFW_GET_FIELD(p_app->flags,
441                                                       DCBX_APP_NUM_ENTRIES);
442         for (i = 0; i < DCBX_MAX_APP_PROTOCOL; i++) {
443                 entry = &p_params->app_entry[i];
444                 entry->ethtype = !(QED_MFW_GET_FIELD(p_tbl[i].entry,
445                                                      DCBX_APP_SF));
446                 pri_map = QED_MFW_GET_FIELD(p_tbl[i].entry, DCBX_APP_PRI_MAP);
447                 entry->prio = ffs(pri_map) - 1;
448                 entry->proto_id = QED_MFW_GET_FIELD(p_tbl[i].entry,
449                                                     DCBX_APP_PROTOCOL_ID);
450                 qed_dcbx_get_app_protocol_type(p_hwfn, p_tbl[i].entry,
451                                                entry->proto_id,
452                                                &entry->proto_type, ieee);
453         }
454
455         DP_VERBOSE(p_hwfn, QED_MSG_DCB,
456                    "APP params: willing %d, valid %d error = %d\n",
457                    p_params->app_willing, p_params->app_valid,
458                    p_params->app_error);
459 }
460
461 static void
462 qed_dcbx_get_pfc_data(struct qed_hwfn *p_hwfn,
463                       u32 pfc, struct qed_dcbx_params *p_params)
464 {
465         u8 pfc_map;
466
467         p_params->pfc.willing = QED_MFW_GET_FIELD(pfc, DCBX_PFC_WILLING);
468         p_params->pfc.max_tc = QED_MFW_GET_FIELD(pfc, DCBX_PFC_CAPS);
469         p_params->pfc.enabled = QED_MFW_GET_FIELD(pfc, DCBX_PFC_ENABLED);
470         pfc_map = QED_MFW_GET_FIELD(pfc, DCBX_PFC_PRI_EN_BITMAP);
471         p_params->pfc.prio[0] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_0);
472         p_params->pfc.prio[1] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_1);
473         p_params->pfc.prio[2] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_2);
474         p_params->pfc.prio[3] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_3);
475         p_params->pfc.prio[4] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_4);
476         p_params->pfc.prio[5] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_5);
477         p_params->pfc.prio[6] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_6);
478         p_params->pfc.prio[7] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_7);
479
480         DP_VERBOSE(p_hwfn, QED_MSG_DCB,
481                    "PFC params: willing %d, pfc_bitmap %d\n",
482                    p_params->pfc.willing, pfc_map);
483 }
484
485 static void
486 qed_dcbx_get_ets_data(struct qed_hwfn *p_hwfn,
487                       struct dcbx_ets_feature *p_ets,
488                       struct qed_dcbx_params *p_params)
489 {
490         u32 bw_map[2], tsa_map[2], pri_map;
491         int i;
492
493         p_params->ets_willing = QED_MFW_GET_FIELD(p_ets->flags,
494                                                   DCBX_ETS_WILLING);
495         p_params->ets_enabled = QED_MFW_GET_FIELD(p_ets->flags,
496                                                   DCBX_ETS_ENABLED);
497         p_params->ets_cbs = QED_MFW_GET_FIELD(p_ets->flags, DCBX_ETS_CBS);
498         p_params->max_ets_tc = QED_MFW_GET_FIELD(p_ets->flags,
499                                                  DCBX_ETS_MAX_TCS);
500         DP_VERBOSE(p_hwfn, QED_MSG_DCB,
501                    "ETS params: willing %d, ets_cbs %d pri_tc_tbl_0 %x max_ets_tc %d\n",
502                    p_params->ets_willing,
503                    p_params->ets_cbs,
504                    p_ets->pri_tc_tbl[0], p_params->max_ets_tc);
505
506         /* 8 bit tsa and bw data corresponding to each of the 8 TC's are
507          * encoded in a type u32 array of size 2.
508          */
509         bw_map[0] = be32_to_cpu(p_ets->tc_bw_tbl[0]);
510         bw_map[1] = be32_to_cpu(p_ets->tc_bw_tbl[1]);
511         tsa_map[0] = be32_to_cpu(p_ets->tc_tsa_tbl[0]);
512         tsa_map[1] = be32_to_cpu(p_ets->tc_tsa_tbl[1]);
513         pri_map = p_ets->pri_tc_tbl[0];
514         for (i = 0; i < QED_MAX_PFC_PRIORITIES; i++) {
515                 p_params->ets_tc_bw_tbl[i] = ((u8 *)bw_map)[i];
516                 p_params->ets_tc_tsa_tbl[i] = ((u8 *)tsa_map)[i];
517                 p_params->ets_pri_tc_tbl[i] = QED_DCBX_PRIO2TC(pri_map, i);
518                 DP_VERBOSE(p_hwfn, QED_MSG_DCB,
519                            "elem %d  bw_tbl %x tsa_tbl %x\n",
520                            i, p_params->ets_tc_bw_tbl[i],
521                            p_params->ets_tc_tsa_tbl[i]);
522         }
523 }
524
525 static void
526 qed_dcbx_get_common_params(struct qed_hwfn *p_hwfn,
527                            struct dcbx_app_priority_feature *p_app,
528                            struct dcbx_app_priority_entry *p_tbl,
529                            struct dcbx_ets_feature *p_ets,
530                            u32 pfc, struct qed_dcbx_params *p_params, bool ieee)
531 {
532         qed_dcbx_get_app_data(p_hwfn, p_app, p_tbl, p_params, ieee);
533         qed_dcbx_get_ets_data(p_hwfn, p_ets, p_params);
534         qed_dcbx_get_pfc_data(p_hwfn, pfc, p_params);
535 }
536
537 static void
538 qed_dcbx_get_local_params(struct qed_hwfn *p_hwfn,
539                           struct qed_ptt *p_ptt, struct qed_dcbx_get *params)
540 {
541         struct dcbx_features *p_feat;
542
543         p_feat = &p_hwfn->p_dcbx_info->local_admin.features;
544         qed_dcbx_get_common_params(p_hwfn, &p_feat->app,
545                                    p_feat->app.app_pri_tbl, &p_feat->ets,
546                                    p_feat->pfc, &params->local.params, false);
547         params->local.valid = true;
548 }
549
550 static void
551 qed_dcbx_get_remote_params(struct qed_hwfn *p_hwfn,
552                            struct qed_ptt *p_ptt, struct qed_dcbx_get *params)
553 {
554         struct dcbx_features *p_feat;
555
556         p_feat = &p_hwfn->p_dcbx_info->remote.features;
557         qed_dcbx_get_common_params(p_hwfn, &p_feat->app,
558                                    p_feat->app.app_pri_tbl, &p_feat->ets,
559                                    p_feat->pfc, &params->remote.params, false);
560         params->remote.valid = true;
561 }
562
563 static void
564 qed_dcbx_get_operational_params(struct qed_hwfn *p_hwfn,
565                                 struct qed_ptt *p_ptt,
566                                 struct qed_dcbx_get *params)
567 {
568         struct qed_dcbx_operational_params *p_operational;
569         struct qed_dcbx_results *p_results;
570         struct dcbx_features *p_feat;
571         bool enabled, err;
572         u32 flags;
573         bool val;
574
575         flags = p_hwfn->p_dcbx_info->operational.flags;
576
577         /* If DCBx version is non zero, then negotiation
578          * was successfuly performed
579          */
580         p_operational = &params->operational;
581         enabled = !!(QED_MFW_GET_FIELD(flags, DCBX_CONFIG_VERSION) !=
582                      DCBX_CONFIG_VERSION_DISABLED);
583         if (!enabled) {
584                 p_operational->enabled = enabled;
585                 p_operational->valid = false;
586                 return;
587         }
588
589         p_feat = &p_hwfn->p_dcbx_info->operational.features;
590         p_results = &p_hwfn->p_dcbx_info->results;
591
592         val = !!(QED_MFW_GET_FIELD(flags, DCBX_CONFIG_VERSION) ==
593                  DCBX_CONFIG_VERSION_IEEE);
594         p_operational->ieee = val;
595         val = !!(QED_MFW_GET_FIELD(flags, DCBX_CONFIG_VERSION) ==
596                  DCBX_CONFIG_VERSION_CEE);
597         p_operational->cee = val;
598
599         DP_VERBOSE(p_hwfn, QED_MSG_DCB, "Version support: ieee %d, cee %d\n",
600                    p_operational->ieee, p_operational->cee);
601
602         qed_dcbx_get_common_params(p_hwfn, &p_feat->app,
603                                    p_feat->app.app_pri_tbl, &p_feat->ets,
604                                    p_feat->pfc, &params->operational.params,
605                                    p_operational->ieee);
606         qed_dcbx_get_priority_info(p_hwfn, &p_operational->app_prio, p_results);
607         err = QED_MFW_GET_FIELD(p_feat->app.flags, DCBX_APP_ERROR);
608         p_operational->err = err;
609         p_operational->enabled = enabled;
610         p_operational->valid = true;
611 }
612
613 static void
614 qed_dcbx_get_local_lldp_params(struct qed_hwfn *p_hwfn,
615                                struct qed_ptt *p_ptt,
616                                struct qed_dcbx_get *params)
617 {
618         struct lldp_config_params_s *p_local;
619
620         p_local = &p_hwfn->p_dcbx_info->lldp_local[LLDP_NEAREST_BRIDGE];
621
622         memcpy(params->lldp_local.local_chassis_id, p_local->local_chassis_id,
623                ARRAY_SIZE(p_local->local_chassis_id));
624         memcpy(params->lldp_local.local_port_id, p_local->local_port_id,
625                ARRAY_SIZE(p_local->local_port_id));
626 }
627
628 static void
629 qed_dcbx_get_remote_lldp_params(struct qed_hwfn *p_hwfn,
630                                 struct qed_ptt *p_ptt,
631                                 struct qed_dcbx_get *params)
632 {
633         struct lldp_status_params_s *p_remote;
634
635         p_remote = &p_hwfn->p_dcbx_info->lldp_remote[LLDP_NEAREST_BRIDGE];
636
637         memcpy(params->lldp_remote.peer_chassis_id, p_remote->peer_chassis_id,
638                ARRAY_SIZE(p_remote->peer_chassis_id));
639         memcpy(params->lldp_remote.peer_port_id, p_remote->peer_port_id,
640                ARRAY_SIZE(p_remote->peer_port_id));
641 }
642
643 static int
644 qed_dcbx_get_params(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
645                     struct qed_dcbx_get *p_params,
646                     enum qed_mib_read_type type)
647 {
648         switch (type) {
649         case QED_DCBX_REMOTE_MIB:
650                 qed_dcbx_get_remote_params(p_hwfn, p_ptt, p_params);
651                 break;
652         case QED_DCBX_LOCAL_MIB:
653                 qed_dcbx_get_local_params(p_hwfn, p_ptt, p_params);
654                 break;
655         case QED_DCBX_OPERATIONAL_MIB:
656                 qed_dcbx_get_operational_params(p_hwfn, p_ptt, p_params);
657                 break;
658         case QED_DCBX_REMOTE_LLDP_MIB:
659                 qed_dcbx_get_remote_lldp_params(p_hwfn, p_ptt, p_params);
660                 break;
661         case QED_DCBX_LOCAL_LLDP_MIB:
662                 qed_dcbx_get_local_lldp_params(p_hwfn, p_ptt, p_params);
663                 break;
664         default:
665                 DP_ERR(p_hwfn, "MIB read err, unknown mib type %d\n", type);
666                 return -EINVAL;
667         }
668
669         return 0;
670 }
671 #endif
672
673 static int
674 qed_dcbx_read_local_lldp_mib(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
675 {
676         struct qed_dcbx_mib_meta_data data;
677         int rc = 0;
678
679         memset(&data, 0, sizeof(data));
680         data.addr = p_hwfn->mcp_info->port_addr + offsetof(struct public_port,
681                                                            lldp_config_params);
682         data.lldp_local = p_hwfn->p_dcbx_info->lldp_local;
683         data.size = sizeof(struct lldp_config_params_s);
684         qed_memcpy_from(p_hwfn, p_ptt, data.lldp_local, data.addr, data.size);
685
686         return rc;
687 }
688
689 static int
690 qed_dcbx_read_remote_lldp_mib(struct qed_hwfn *p_hwfn,
691                               struct qed_ptt *p_ptt,
692                               enum qed_mib_read_type type)
693 {
694         struct qed_dcbx_mib_meta_data data;
695         int rc = 0;
696
697         memset(&data, 0, sizeof(data));
698         data.addr = p_hwfn->mcp_info->port_addr + offsetof(struct public_port,
699                                                            lldp_status_params);
700         data.lldp_remote = p_hwfn->p_dcbx_info->lldp_remote;
701         data.size = sizeof(struct lldp_status_params_s);
702         rc = qed_dcbx_copy_mib(p_hwfn, p_ptt, &data, type);
703
704         return rc;
705 }
706
707 static int
708 qed_dcbx_read_operational_mib(struct qed_hwfn *p_hwfn,
709                               struct qed_ptt *p_ptt,
710                               enum qed_mib_read_type type)
711 {
712         struct qed_dcbx_mib_meta_data data;
713         int rc = 0;
714
715         memset(&data, 0, sizeof(data));
716         data.addr = p_hwfn->mcp_info->port_addr +
717                     offsetof(struct public_port, operational_dcbx_mib);
718         data.mib = &p_hwfn->p_dcbx_info->operational;
719         data.size = sizeof(struct dcbx_mib);
720         rc = qed_dcbx_copy_mib(p_hwfn, p_ptt, &data, type);
721
722         return rc;
723 }
724
725 static int
726 qed_dcbx_read_remote_mib(struct qed_hwfn *p_hwfn,
727                          struct qed_ptt *p_ptt, enum qed_mib_read_type type)
728 {
729         struct qed_dcbx_mib_meta_data data;
730         int rc = 0;
731
732         memset(&data, 0, sizeof(data));
733         data.addr = p_hwfn->mcp_info->port_addr +
734                     offsetof(struct public_port, remote_dcbx_mib);
735         data.mib = &p_hwfn->p_dcbx_info->remote;
736         data.size = sizeof(struct dcbx_mib);
737         rc = qed_dcbx_copy_mib(p_hwfn, p_ptt, &data, type);
738
739         return rc;
740 }
741
742 static int
743 qed_dcbx_read_local_mib(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
744 {
745         struct qed_dcbx_mib_meta_data data;
746         int rc = 0;
747
748         memset(&data, 0, sizeof(data));
749         data.addr = p_hwfn->mcp_info->port_addr +
750                     offsetof(struct public_port, local_admin_dcbx_mib);
751         data.local_admin = &p_hwfn->p_dcbx_info->local_admin;
752         data.size = sizeof(struct dcbx_local_params);
753         qed_memcpy_from(p_hwfn, p_ptt, data.local_admin, data.addr, data.size);
754
755         return rc;
756 }
757
758 static int qed_dcbx_read_mib(struct qed_hwfn *p_hwfn,
759                              struct qed_ptt *p_ptt, enum qed_mib_read_type type)
760 {
761         int rc = -EINVAL;
762
763         switch (type) {
764         case QED_DCBX_OPERATIONAL_MIB:
765                 rc = qed_dcbx_read_operational_mib(p_hwfn, p_ptt, type);
766                 break;
767         case QED_DCBX_REMOTE_MIB:
768                 rc = qed_dcbx_read_remote_mib(p_hwfn, p_ptt, type);
769                 break;
770         case QED_DCBX_LOCAL_MIB:
771                 rc = qed_dcbx_read_local_mib(p_hwfn, p_ptt);
772                 break;
773         case QED_DCBX_REMOTE_LLDP_MIB:
774                 rc = qed_dcbx_read_remote_lldp_mib(p_hwfn, p_ptt, type);
775                 break;
776         case QED_DCBX_LOCAL_LLDP_MIB:
777                 rc = qed_dcbx_read_local_lldp_mib(p_hwfn, p_ptt);
778                 break;
779         default:
780                 DP_ERR(p_hwfn, "MIB read err, unknown mib type %d\n", type);
781         }
782
783         return rc;
784 }
785
786 /* Read updated MIB.
787  * Reconfigure QM and invoke PF update ramrod command if operational MIB
788  * change is detected.
789  */
790 int
791 qed_dcbx_mib_update_event(struct qed_hwfn *p_hwfn,
792                           struct qed_ptt *p_ptt, enum qed_mib_read_type type)
793 {
794         int rc = 0;
795
796         rc = qed_dcbx_read_mib(p_hwfn, p_ptt, type);
797         if (rc)
798                 return rc;
799
800         if (type == QED_DCBX_OPERATIONAL_MIB) {
801                 rc = qed_dcbx_process_mib_info(p_hwfn);
802                 if (!rc) {
803                         /* reconfigure tcs of QM queues according
804                          * to negotiation results
805                          */
806                         qed_qm_reconf(p_hwfn, p_ptt);
807
808                         /* update storm FW with negotiation results */
809                         qed_sp_pf_update(p_hwfn);
810                 }
811         }
812
813         return rc;
814 }
815
816 int qed_dcbx_info_alloc(struct qed_hwfn *p_hwfn)
817 {
818         int rc = 0;
819
820         p_hwfn->p_dcbx_info = kzalloc(sizeof(*p_hwfn->p_dcbx_info), GFP_KERNEL);
821         if (!p_hwfn->p_dcbx_info) {
822                 DP_NOTICE(p_hwfn,
823                           "Failed to allocate 'struct qed_dcbx_info'\n");
824                 rc = -ENOMEM;
825         }
826
827         return rc;
828 }
829
830 void qed_dcbx_info_free(struct qed_hwfn *p_hwfn,
831                         struct qed_dcbx_info *p_dcbx_info)
832 {
833         kfree(p_hwfn->p_dcbx_info);
834 }
835
836 static void qed_dcbx_update_protocol_data(struct protocol_dcb_data *p_data,
837                                           struct qed_dcbx_results *p_src,
838                                           enum dcbx_protocol_type type)
839 {
840         p_data->dcb_enable_flag = p_src->arr[type].enable;
841         p_data->dcb_priority = p_src->arr[type].priority;
842         p_data->dcb_tc = p_src->arr[type].tc;
843 }
844
845 /* Set pf update ramrod command params */
846 void qed_dcbx_set_pf_update_params(struct qed_dcbx_results *p_src,
847                                    struct pf_update_ramrod_data *p_dest)
848 {
849         struct protocol_dcb_data *p_dcb_data;
850         bool update_flag = false;
851
852         p_dest->pf_id = p_src->pf_id;
853
854         update_flag = p_src->arr[DCBX_PROTOCOL_FCOE].update;
855         p_dest->update_fcoe_dcb_data_flag = update_flag;
856
857         update_flag = p_src->arr[DCBX_PROTOCOL_ROCE].update;
858         p_dest->update_roce_dcb_data_flag = update_flag;
859         update_flag = p_src->arr[DCBX_PROTOCOL_ROCE_V2].update;
860         p_dest->update_roce_dcb_data_flag = update_flag;
861
862         update_flag = p_src->arr[DCBX_PROTOCOL_ISCSI].update;
863         p_dest->update_iscsi_dcb_data_flag = update_flag;
864         update_flag = p_src->arr[DCBX_PROTOCOL_ETH].update;
865         p_dest->update_eth_dcb_data_flag = update_flag;
866
867         p_dcb_data = &p_dest->fcoe_dcb_data;
868         qed_dcbx_update_protocol_data(p_dcb_data, p_src, DCBX_PROTOCOL_FCOE);
869         p_dcb_data = &p_dest->roce_dcb_data;
870
871         if (p_src->arr[DCBX_PROTOCOL_ROCE].update)
872                 qed_dcbx_update_protocol_data(p_dcb_data, p_src,
873                                               DCBX_PROTOCOL_ROCE);
874         if (p_src->arr[DCBX_PROTOCOL_ROCE_V2].update)
875                 qed_dcbx_update_protocol_data(p_dcb_data, p_src,
876                                               DCBX_PROTOCOL_ROCE_V2);
877
878         p_dcb_data = &p_dest->iscsi_dcb_data;
879         qed_dcbx_update_protocol_data(p_dcb_data, p_src, DCBX_PROTOCOL_ISCSI);
880         p_dcb_data = &p_dest->eth_dcb_data;
881         qed_dcbx_update_protocol_data(p_dcb_data, p_src, DCBX_PROTOCOL_ETH);
882 }
883
884 #ifdef CONFIG_DCB
885 static int qed_dcbx_query_params(struct qed_hwfn *p_hwfn,
886                                  struct qed_dcbx_get *p_get,
887                                  enum qed_mib_read_type type)
888 {
889         struct qed_ptt *p_ptt;
890         int rc;
891
892         p_ptt = qed_ptt_acquire(p_hwfn);
893         if (!p_ptt)
894                 return -EBUSY;
895
896         rc = qed_dcbx_read_mib(p_hwfn, p_ptt, type);
897         if (rc)
898                 goto out;
899
900         rc = qed_dcbx_get_params(p_hwfn, p_ptt, p_get, type);
901
902 out:
903         qed_ptt_release(p_hwfn, p_ptt);
904         return rc;
905 }
906
907 static void
908 qed_dcbx_set_pfc_data(struct qed_hwfn *p_hwfn,
909                       u32 *pfc, struct qed_dcbx_params *p_params)
910 {
911         u8 pfc_map = 0;
912         int i;
913
914         if (p_params->pfc.willing)
915                 *pfc |= DCBX_PFC_WILLING_MASK;
916         else
917                 *pfc &= ~DCBX_PFC_WILLING_MASK;
918
919         if (p_params->pfc.enabled)
920                 *pfc |= DCBX_PFC_ENABLED_MASK;
921         else
922                 *pfc &= ~DCBX_PFC_ENABLED_MASK;
923
924         *pfc &= ~DCBX_PFC_CAPS_MASK;
925         *pfc |= (u32)p_params->pfc.max_tc << DCBX_PFC_CAPS_SHIFT;
926
927         for (i = 0; i < QED_MAX_PFC_PRIORITIES; i++)
928                 if (p_params->pfc.prio[i])
929                         pfc_map |= BIT(i);
930
931         *pfc |= (pfc_map << DCBX_PFC_PRI_EN_BITMAP_SHIFT);
932
933         DP_VERBOSE(p_hwfn, QED_MSG_DCB, "pfc = 0x%x\n", *pfc);
934 }
935
936 static void
937 qed_dcbx_set_ets_data(struct qed_hwfn *p_hwfn,
938                       struct dcbx_ets_feature *p_ets,
939                       struct qed_dcbx_params *p_params)
940 {
941         u8 *bw_map, *tsa_map;
942         u32 val;
943         int i;
944
945         if (p_params->ets_willing)
946                 p_ets->flags |= DCBX_ETS_WILLING_MASK;
947         else
948                 p_ets->flags &= ~DCBX_ETS_WILLING_MASK;
949
950         if (p_params->ets_cbs)
951                 p_ets->flags |= DCBX_ETS_CBS_MASK;
952         else
953                 p_ets->flags &= ~DCBX_ETS_CBS_MASK;
954
955         if (p_params->ets_enabled)
956                 p_ets->flags |= DCBX_ETS_ENABLED_MASK;
957         else
958                 p_ets->flags &= ~DCBX_ETS_ENABLED_MASK;
959
960         p_ets->flags &= ~DCBX_ETS_MAX_TCS_MASK;
961         p_ets->flags |= (u32)p_params->max_ets_tc << DCBX_ETS_MAX_TCS_SHIFT;
962
963         bw_map = (u8 *)&p_ets->tc_bw_tbl[0];
964         tsa_map = (u8 *)&p_ets->tc_tsa_tbl[0];
965         p_ets->pri_tc_tbl[0] = 0;
966         for (i = 0; i < QED_MAX_PFC_PRIORITIES; i++) {
967                 bw_map[i] = p_params->ets_tc_bw_tbl[i];
968                 tsa_map[i] = p_params->ets_tc_tsa_tbl[i];
969                 /* Copy the priority value to the corresponding 4 bits in the
970                  * traffic class table.
971                  */
972                 val = (((u32)p_params->ets_pri_tc_tbl[i]) << ((7 - i) * 4));
973                 p_ets->pri_tc_tbl[0] |= val;
974         }
975         for (i = 0; i < 2; i++) {
976                 p_ets->tc_bw_tbl[i] = cpu_to_be32(p_ets->tc_bw_tbl[i]);
977                 p_ets->tc_tsa_tbl[i] = cpu_to_be32(p_ets->tc_tsa_tbl[i]);
978         }
979 }
980
981 static void
982 qed_dcbx_set_app_data(struct qed_hwfn *p_hwfn,
983                       struct dcbx_app_priority_feature *p_app,
984                       struct qed_dcbx_params *p_params)
985 {
986         u32 *entry;
987         int i;
988
989         if (p_params->app_willing)
990                 p_app->flags |= DCBX_APP_WILLING_MASK;
991         else
992                 p_app->flags &= ~DCBX_APP_WILLING_MASK;
993
994         if (p_params->app_valid)
995                 p_app->flags |= DCBX_APP_ENABLED_MASK;
996         else
997                 p_app->flags &= ~DCBX_APP_ENABLED_MASK;
998
999         p_app->flags &= ~DCBX_APP_NUM_ENTRIES_MASK;
1000         p_app->flags |= (u32)p_params->num_app_entries <<
1001             DCBX_APP_NUM_ENTRIES_SHIFT;
1002
1003         for (i = 0; i < DCBX_MAX_APP_PROTOCOL; i++) {
1004                 entry = &p_app->app_pri_tbl[i].entry;
1005                 *entry &= ~DCBX_APP_SF_MASK;
1006                 if (p_params->app_entry[i].ethtype)
1007                         *entry |= ((u32)DCBX_APP_SF_ETHTYPE <<
1008                                    DCBX_APP_SF_SHIFT);
1009                 else
1010                         *entry |= ((u32)DCBX_APP_SF_PORT << DCBX_APP_SF_SHIFT);
1011                 *entry &= ~DCBX_APP_PROTOCOL_ID_MASK;
1012                 *entry |= ((u32)p_params->app_entry[i].proto_id <<
1013                            DCBX_APP_PROTOCOL_ID_SHIFT);
1014                 *entry &= ~DCBX_APP_PRI_MAP_MASK;
1015                 *entry |= ((u32)(p_params->app_entry[i].prio) <<
1016                            DCBX_APP_PRI_MAP_SHIFT);
1017         }
1018 }
1019
1020 static void
1021 qed_dcbx_set_local_params(struct qed_hwfn *p_hwfn,
1022                           struct dcbx_local_params *local_admin,
1023                           struct qed_dcbx_set *params)
1024 {
1025         local_admin->flags = 0;
1026         memcpy(&local_admin->features,
1027                &p_hwfn->p_dcbx_info->operational.features,
1028                sizeof(local_admin->features));
1029
1030         if (params->enabled)
1031                 local_admin->config = params->ver_num;
1032         else
1033                 local_admin->config = DCBX_CONFIG_VERSION_DISABLED;
1034
1035         if (params->override_flags & QED_DCBX_OVERRIDE_PFC_CFG)
1036                 qed_dcbx_set_pfc_data(p_hwfn, &local_admin->features.pfc,
1037                                       &params->config.params);
1038
1039         if (params->override_flags & QED_DCBX_OVERRIDE_ETS_CFG)
1040                 qed_dcbx_set_ets_data(p_hwfn, &local_admin->features.ets,
1041                                       &params->config.params);
1042
1043         if (params->override_flags & QED_DCBX_OVERRIDE_APP_CFG)
1044                 qed_dcbx_set_app_data(p_hwfn, &local_admin->features.app,
1045                                       &params->config.params);
1046 }
1047
1048 int qed_dcbx_config_params(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
1049                            struct qed_dcbx_set *params, bool hw_commit)
1050 {
1051         struct dcbx_local_params local_admin;
1052         struct qed_dcbx_mib_meta_data data;
1053         u32 resp = 0, param = 0;
1054         int rc = 0;
1055
1056         if (!hw_commit) {
1057                 memcpy(&p_hwfn->p_dcbx_info->set, params,
1058                        sizeof(struct qed_dcbx_set));
1059                 return 0;
1060         }
1061
1062         /* clear set-parmas cache */
1063         memset(&p_hwfn->p_dcbx_info->set, 0, sizeof(p_hwfn->p_dcbx_info->set));
1064
1065         memset(&local_admin, 0, sizeof(local_admin));
1066         qed_dcbx_set_local_params(p_hwfn, &local_admin, params);
1067
1068         data.addr = p_hwfn->mcp_info->port_addr +
1069             offsetof(struct public_port, local_admin_dcbx_mib);
1070         data.local_admin = &local_admin;
1071         data.size = sizeof(struct dcbx_local_params);
1072         qed_memcpy_to(p_hwfn, p_ptt, data.addr, data.local_admin, data.size);
1073
1074         rc = qed_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_SET_DCBX,
1075                          1 << DRV_MB_PARAM_LLDP_SEND_SHIFT, &resp, &param);
1076         if (rc)
1077                 DP_NOTICE(p_hwfn, "Failed to send DCBX update request\n");
1078
1079         return rc;
1080 }
1081
1082 int qed_dcbx_get_config_params(struct qed_hwfn *p_hwfn,
1083                                struct qed_dcbx_set *params)
1084 {
1085         struct qed_dcbx_get *dcbx_info;
1086         int rc;
1087
1088         if (p_hwfn->p_dcbx_info->set.config.valid) {
1089                 memcpy(params, &p_hwfn->p_dcbx_info->set,
1090                        sizeof(struct qed_dcbx_set));
1091                 return 0;
1092         }
1093
1094         dcbx_info = kmalloc(sizeof(*dcbx_info), GFP_KERNEL);
1095         if (!dcbx_info) {
1096                 DP_ERR(p_hwfn, "Failed to allocate struct qed_dcbx_info\n");
1097                 return -ENOMEM;
1098         }
1099
1100         rc = qed_dcbx_query_params(p_hwfn, dcbx_info, QED_DCBX_OPERATIONAL_MIB);
1101         if (rc) {
1102                 kfree(dcbx_info);
1103                 return rc;
1104         }
1105
1106         p_hwfn->p_dcbx_info->set.override_flags = 0;
1107         p_hwfn->p_dcbx_info->set.ver_num = DCBX_CONFIG_VERSION_DISABLED;
1108         if (dcbx_info->operational.cee)
1109                 p_hwfn->p_dcbx_info->set.ver_num |= DCBX_CONFIG_VERSION_CEE;
1110         if (dcbx_info->operational.ieee)
1111                 p_hwfn->p_dcbx_info->set.ver_num |= DCBX_CONFIG_VERSION_IEEE;
1112
1113         p_hwfn->p_dcbx_info->set.enabled = dcbx_info->operational.enabled;
1114         memcpy(&p_hwfn->p_dcbx_info->set.config.params,
1115                &dcbx_info->operational.params,
1116                sizeof(struct qed_dcbx_admin_params));
1117         p_hwfn->p_dcbx_info->set.config.valid = true;
1118
1119         memcpy(params, &p_hwfn->p_dcbx_info->set, sizeof(struct qed_dcbx_set));
1120
1121         kfree(dcbx_info);
1122
1123         return 0;
1124 }
1125
1126 static struct qed_dcbx_get *qed_dcbnl_get_dcbx(struct qed_hwfn *hwfn,
1127                                                enum qed_mib_read_type type)
1128 {
1129         struct qed_dcbx_get *dcbx_info;
1130
1131         dcbx_info = kmalloc(sizeof(*dcbx_info), GFP_KERNEL);
1132         if (!dcbx_info) {
1133                 DP_ERR(hwfn->cdev, "Failed to allocate memory for dcbx_info\n");
1134                 return NULL;
1135         }
1136
1137         if (qed_dcbx_query_params(hwfn, dcbx_info, type)) {
1138                 kfree(dcbx_info);
1139                 return NULL;
1140         }
1141
1142         if ((type == QED_DCBX_OPERATIONAL_MIB) &&
1143             !dcbx_info->operational.enabled) {
1144                 DP_INFO(hwfn, "DCBX is not enabled/operational\n");
1145                 kfree(dcbx_info);
1146                 return NULL;
1147         }
1148
1149         return dcbx_info;
1150 }
1151
1152 static u8 qed_dcbnl_getstate(struct qed_dev *cdev)
1153 {
1154         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
1155         struct qed_dcbx_get *dcbx_info;
1156         bool enabled;
1157
1158         dcbx_info = qed_dcbnl_get_dcbx(hwfn, QED_DCBX_OPERATIONAL_MIB);
1159         if (!dcbx_info)
1160                 return 0;
1161
1162         enabled = dcbx_info->operational.enabled;
1163         DP_VERBOSE(hwfn, QED_MSG_DCB, "DCB state = %d\n", enabled);
1164         kfree(dcbx_info);
1165
1166         return enabled;
1167 }
1168
1169 static u8 qed_dcbnl_setstate(struct qed_dev *cdev, u8 state)
1170 {
1171         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
1172         struct qed_dcbx_set dcbx_set;
1173         struct qed_ptt *ptt;
1174         int rc;
1175
1176         DP_VERBOSE(hwfn, QED_MSG_DCB, "DCB state = %d\n", state);
1177
1178         memset(&dcbx_set, 0, sizeof(dcbx_set));
1179         rc = qed_dcbx_get_config_params(hwfn, &dcbx_set);
1180         if (rc)
1181                 return 1;
1182
1183         dcbx_set.enabled = !!state;
1184
1185         ptt = qed_ptt_acquire(hwfn);
1186         if (!ptt)
1187                 return 1;
1188
1189         rc = qed_dcbx_config_params(hwfn, ptt, &dcbx_set, 0);
1190
1191         qed_ptt_release(hwfn, ptt);
1192
1193         return rc ? 1 : 0;
1194 }
1195
1196 static void qed_dcbnl_getpgtccfgtx(struct qed_dev *cdev, int tc, u8 *prio_type,
1197                                    u8 *pgid, u8 *bw_pct, u8 *up_map)
1198 {
1199         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
1200         struct qed_dcbx_get *dcbx_info;
1201
1202         DP_VERBOSE(hwfn, QED_MSG_DCB, "tc = %d\n", tc);
1203         *prio_type = *pgid = *bw_pct = *up_map = 0;
1204         if (tc < 0 || tc >= QED_MAX_PFC_PRIORITIES) {
1205                 DP_INFO(hwfn, "Invalid tc %d\n", tc);
1206                 return;
1207         }
1208
1209         dcbx_info = qed_dcbnl_get_dcbx(hwfn, QED_DCBX_OPERATIONAL_MIB);
1210         if (!dcbx_info)
1211                 return;
1212
1213         *pgid = dcbx_info->operational.params.ets_pri_tc_tbl[tc];
1214         kfree(dcbx_info);
1215 }
1216
1217 static void qed_dcbnl_getpgbwgcfgtx(struct qed_dev *cdev, int pgid, u8 *bw_pct)
1218 {
1219         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
1220         struct qed_dcbx_get *dcbx_info;
1221
1222         *bw_pct = 0;
1223         DP_VERBOSE(hwfn, QED_MSG_DCB, "pgid = %d\n", pgid);
1224         if (pgid < 0 || pgid >= QED_MAX_PFC_PRIORITIES) {
1225                 DP_INFO(hwfn, "Invalid pgid %d\n", pgid);
1226                 return;
1227         }
1228
1229         dcbx_info = qed_dcbnl_get_dcbx(hwfn, QED_DCBX_OPERATIONAL_MIB);
1230         if (!dcbx_info)
1231                 return;
1232
1233         *bw_pct = dcbx_info->operational.params.ets_tc_bw_tbl[pgid];
1234         DP_VERBOSE(hwfn, QED_MSG_DCB, "bw_pct = %d\n", *bw_pct);
1235         kfree(dcbx_info);
1236 }
1237
1238 static void qed_dcbnl_getpgtccfgrx(struct qed_dev *cdev, int tc, u8 *prio,
1239                                    u8 *bwg_id, u8 *bw_pct, u8 *up_map)
1240 {
1241         DP_INFO(QED_LEADING_HWFN(cdev), "Rx ETS is not supported\n");
1242         *prio = *bwg_id = *bw_pct = *up_map = 0;
1243 }
1244
1245 static void qed_dcbnl_getpgbwgcfgrx(struct qed_dev *cdev,
1246                                     int bwg_id, u8 *bw_pct)
1247 {
1248         DP_INFO(QED_LEADING_HWFN(cdev), "Rx ETS is not supported\n");
1249         *bw_pct = 0;
1250 }
1251
1252 static void qed_dcbnl_getpfccfg(struct qed_dev *cdev,
1253                                 int priority, u8 *setting)
1254 {
1255         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
1256         struct qed_dcbx_get *dcbx_info;
1257
1258         DP_VERBOSE(hwfn, QED_MSG_DCB, "priority = %d\n", priority);
1259         if (priority < 0 || priority >= QED_MAX_PFC_PRIORITIES) {
1260                 DP_INFO(hwfn, "Invalid priority %d\n", priority);
1261                 return;
1262         }
1263
1264         dcbx_info = qed_dcbnl_get_dcbx(hwfn, QED_DCBX_OPERATIONAL_MIB);
1265         if (!dcbx_info)
1266                 return;
1267
1268         *setting = dcbx_info->operational.params.pfc.prio[priority];
1269         DP_VERBOSE(hwfn, QED_MSG_DCB, "setting = %d\n", *setting);
1270         kfree(dcbx_info);
1271 }
1272
1273 static void qed_dcbnl_setpfccfg(struct qed_dev *cdev, int priority, u8 setting)
1274 {
1275         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
1276         struct qed_dcbx_set dcbx_set;
1277         struct qed_ptt *ptt;
1278         int rc;
1279
1280         DP_VERBOSE(hwfn, QED_MSG_DCB, "priority = %d setting = %d\n",
1281                    priority, setting);
1282         if (priority < 0 || priority >= QED_MAX_PFC_PRIORITIES) {
1283                 DP_INFO(hwfn, "Invalid priority %d\n", priority);
1284                 return;
1285         }
1286
1287         memset(&dcbx_set, 0, sizeof(dcbx_set));
1288         rc = qed_dcbx_get_config_params(hwfn, &dcbx_set);
1289         if (rc)
1290                 return;
1291
1292         dcbx_set.override_flags |= QED_DCBX_OVERRIDE_PFC_CFG;
1293         dcbx_set.config.params.pfc.prio[priority] = !!setting;
1294
1295         ptt = qed_ptt_acquire(hwfn);
1296         if (!ptt)
1297                 return;
1298
1299         rc = qed_dcbx_config_params(hwfn, ptt, &dcbx_set, 0);
1300
1301         qed_ptt_release(hwfn, ptt);
1302 }
1303
1304 static u8 qed_dcbnl_getcap(struct qed_dev *cdev, int capid, u8 *cap)
1305 {
1306         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
1307         struct qed_dcbx_get *dcbx_info;
1308         int rc = 0;
1309
1310         DP_VERBOSE(hwfn, QED_MSG_DCB, "capid = %d\n", capid);
1311         dcbx_info = qed_dcbnl_get_dcbx(hwfn, QED_DCBX_OPERATIONAL_MIB);
1312         if (!dcbx_info)
1313                 return 1;
1314
1315         switch (capid) {
1316         case DCB_CAP_ATTR_PG:
1317         case DCB_CAP_ATTR_PFC:
1318         case DCB_CAP_ATTR_UP2TC:
1319         case DCB_CAP_ATTR_GSP:
1320                 *cap = true;
1321                 break;
1322         case DCB_CAP_ATTR_PG_TCS:
1323         case DCB_CAP_ATTR_PFC_TCS:
1324                 *cap = 0x80;
1325                 break;
1326         case DCB_CAP_ATTR_DCBX:
1327                 *cap = (DCB_CAP_DCBX_LLD_MANAGED | DCB_CAP_DCBX_VER_CEE |
1328                         DCB_CAP_DCBX_VER_IEEE);
1329                 break;
1330         default:
1331                 *cap = false;
1332                 rc = 1;
1333         }
1334
1335         DP_VERBOSE(hwfn, QED_MSG_DCB, "id = %d caps = %d\n", capid, *cap);
1336         kfree(dcbx_info);
1337
1338         return rc;
1339 }
1340
1341 static int qed_dcbnl_getnumtcs(struct qed_dev *cdev, int tcid, u8 *num)
1342 {
1343         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
1344         struct qed_dcbx_get *dcbx_info;
1345         int rc = 0;
1346
1347         DP_VERBOSE(hwfn, QED_MSG_DCB, "tcid = %d\n", tcid);
1348         dcbx_info = qed_dcbnl_get_dcbx(hwfn, QED_DCBX_OPERATIONAL_MIB);
1349         if (!dcbx_info)
1350                 return -EINVAL;
1351
1352         switch (tcid) {
1353         case DCB_NUMTCS_ATTR_PG:
1354                 *num = dcbx_info->operational.params.max_ets_tc;
1355                 break;
1356         case DCB_NUMTCS_ATTR_PFC:
1357                 *num = dcbx_info->operational.params.pfc.max_tc;
1358                 break;
1359         default:
1360                 rc = -EINVAL;
1361         }
1362
1363         kfree(dcbx_info);
1364         DP_VERBOSE(hwfn, QED_MSG_DCB, "numtcs = %d\n", *num);
1365
1366         return rc;
1367 }
1368
1369 static u8 qed_dcbnl_getpfcstate(struct qed_dev *cdev)
1370 {
1371         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
1372         struct qed_dcbx_get *dcbx_info;
1373         bool enabled;
1374
1375         dcbx_info = qed_dcbnl_get_dcbx(hwfn, QED_DCBX_OPERATIONAL_MIB);
1376         if (!dcbx_info)
1377                 return 0;
1378
1379         enabled = dcbx_info->operational.params.pfc.enabled;
1380         DP_VERBOSE(hwfn, QED_MSG_DCB, "pfc state = %d\n", enabled);
1381         kfree(dcbx_info);
1382
1383         return enabled;
1384 }
1385
1386 static u8 qed_dcbnl_getdcbx(struct qed_dev *cdev)
1387 {
1388         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
1389         struct qed_dcbx_get *dcbx_info;
1390         u8 mode = 0;
1391
1392         dcbx_info = qed_dcbnl_get_dcbx(hwfn, QED_DCBX_OPERATIONAL_MIB);
1393         if (!dcbx_info)
1394                 return 0;
1395
1396         if (dcbx_info->operational.enabled)
1397                 mode |= DCB_CAP_DCBX_LLD_MANAGED;
1398         if (dcbx_info->operational.ieee)
1399                 mode |= DCB_CAP_DCBX_VER_IEEE;
1400         if (dcbx_info->operational.cee)
1401                 mode |= DCB_CAP_DCBX_VER_CEE;
1402
1403         DP_VERBOSE(hwfn, QED_MSG_DCB, "dcb mode = %d\n", mode);
1404         kfree(dcbx_info);
1405
1406         return mode;
1407 }
1408
1409 static void qed_dcbnl_setpgtccfgtx(struct qed_dev *cdev,
1410                                    int tc,
1411                                    u8 pri_type, u8 pgid, u8 bw_pct, u8 up_map)
1412 {
1413         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
1414         struct qed_dcbx_set dcbx_set;
1415         struct qed_ptt *ptt;
1416         int rc;
1417
1418         DP_VERBOSE(hwfn, QED_MSG_DCB,
1419                    "tc = %d pri_type = %d pgid = %d bw_pct = %d up_map = %d\n",
1420                    tc, pri_type, pgid, bw_pct, up_map);
1421
1422         if (tc < 0 || tc >= QED_MAX_PFC_PRIORITIES) {
1423                 DP_INFO(hwfn, "Invalid tc %d\n", tc);
1424                 return;
1425         }
1426
1427         memset(&dcbx_set, 0, sizeof(dcbx_set));
1428         rc = qed_dcbx_get_config_params(hwfn, &dcbx_set);
1429         if (rc)
1430                 return;
1431
1432         dcbx_set.override_flags |= QED_DCBX_OVERRIDE_ETS_CFG;
1433         dcbx_set.config.params.ets_pri_tc_tbl[tc] = pgid;
1434
1435         ptt = qed_ptt_acquire(hwfn);
1436         if (!ptt)
1437                 return;
1438
1439         rc = qed_dcbx_config_params(hwfn, ptt, &dcbx_set, 0);
1440
1441         qed_ptt_release(hwfn, ptt);
1442 }
1443
1444 static void qed_dcbnl_setpgtccfgrx(struct qed_dev *cdev, int prio,
1445                                    u8 pri_type, u8 pgid, u8 bw_pct, u8 up_map)
1446 {
1447         DP_INFO(QED_LEADING_HWFN(cdev), "Rx ETS is not supported\n");
1448 }
1449
1450 static void qed_dcbnl_setpgbwgcfgtx(struct qed_dev *cdev, int pgid, u8 bw_pct)
1451 {
1452         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
1453         struct qed_dcbx_set dcbx_set;
1454         struct qed_ptt *ptt;
1455         int rc;
1456
1457         DP_VERBOSE(hwfn, QED_MSG_DCB, "pgid = %d bw_pct = %d\n", pgid, bw_pct);
1458         if (pgid < 0 || pgid >= QED_MAX_PFC_PRIORITIES) {
1459                 DP_INFO(hwfn, "Invalid pgid %d\n", pgid);
1460                 return;
1461         }
1462
1463         memset(&dcbx_set, 0, sizeof(dcbx_set));
1464         rc = qed_dcbx_get_config_params(hwfn, &dcbx_set);
1465         if (rc)
1466                 return;
1467
1468         dcbx_set.override_flags |= QED_DCBX_OVERRIDE_ETS_CFG;
1469         dcbx_set.config.params.ets_tc_bw_tbl[pgid] = bw_pct;
1470
1471         ptt = qed_ptt_acquire(hwfn);
1472         if (!ptt)
1473                 return;
1474
1475         rc = qed_dcbx_config_params(hwfn, ptt, &dcbx_set, 0);
1476
1477         qed_ptt_release(hwfn, ptt);
1478 }
1479
1480 static void qed_dcbnl_setpgbwgcfgrx(struct qed_dev *cdev, int pgid, u8 bw_pct)
1481 {
1482         DP_INFO(QED_LEADING_HWFN(cdev), "Rx ETS is not supported\n");
1483 }
1484
1485 static u8 qed_dcbnl_setall(struct qed_dev *cdev)
1486 {
1487         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
1488         struct qed_dcbx_set dcbx_set;
1489         struct qed_ptt *ptt;
1490         int rc;
1491
1492         memset(&dcbx_set, 0, sizeof(dcbx_set));
1493         rc = qed_dcbx_get_config_params(hwfn, &dcbx_set);
1494         if (rc)
1495                 return 1;
1496
1497         ptt = qed_ptt_acquire(hwfn);
1498         if (!ptt)
1499                 return 1;
1500
1501         rc = qed_dcbx_config_params(hwfn, ptt, &dcbx_set, 1);
1502
1503         qed_ptt_release(hwfn, ptt);
1504
1505         return rc;
1506 }
1507
1508 static int qed_dcbnl_setnumtcs(struct qed_dev *cdev, int tcid, u8 num)
1509 {
1510         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
1511         struct qed_dcbx_set dcbx_set;
1512         struct qed_ptt *ptt;
1513         int rc;
1514
1515         DP_VERBOSE(hwfn, QED_MSG_DCB, "tcid = %d num = %d\n", tcid, num);
1516         memset(&dcbx_set, 0, sizeof(dcbx_set));
1517         rc = qed_dcbx_get_config_params(hwfn, &dcbx_set);
1518         if (rc)
1519                 return 1;
1520
1521         switch (tcid) {
1522         case DCB_NUMTCS_ATTR_PG:
1523                 dcbx_set.override_flags |= QED_DCBX_OVERRIDE_ETS_CFG;
1524                 dcbx_set.config.params.max_ets_tc = num;
1525                 break;
1526         case DCB_NUMTCS_ATTR_PFC:
1527                 dcbx_set.override_flags |= QED_DCBX_OVERRIDE_PFC_CFG;
1528                 dcbx_set.config.params.pfc.max_tc = num;
1529                 break;
1530         default:
1531                 DP_INFO(hwfn, "Invalid tcid %d\n", tcid);
1532                 return -EINVAL;
1533         }
1534
1535         ptt = qed_ptt_acquire(hwfn);
1536         if (!ptt)
1537                 return -EINVAL;
1538
1539         rc = qed_dcbx_config_params(hwfn, ptt, &dcbx_set, 0);
1540
1541         qed_ptt_release(hwfn, ptt);
1542
1543         return 0;
1544 }
1545
1546 static void qed_dcbnl_setpfcstate(struct qed_dev *cdev, u8 state)
1547 {
1548         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
1549         struct qed_dcbx_set dcbx_set;
1550         struct qed_ptt *ptt;
1551         int rc;
1552
1553         DP_VERBOSE(hwfn, QED_MSG_DCB, "new state = %d\n", state);
1554
1555         memset(&dcbx_set, 0, sizeof(dcbx_set));
1556         rc = qed_dcbx_get_config_params(hwfn, &dcbx_set);
1557         if (rc)
1558                 return;
1559
1560         dcbx_set.override_flags |= QED_DCBX_OVERRIDE_PFC_CFG;
1561         dcbx_set.config.params.pfc.enabled = !!state;
1562
1563         ptt = qed_ptt_acquire(hwfn);
1564         if (!ptt)
1565                 return;
1566
1567         rc = qed_dcbx_config_params(hwfn, ptt, &dcbx_set, 0);
1568
1569         qed_ptt_release(hwfn, ptt);
1570 }
1571
1572 static int qed_dcbnl_getapp(struct qed_dev *cdev, u8 idtype, u16 idval)
1573 {
1574         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
1575         struct qed_dcbx_get *dcbx_info;
1576         struct qed_app_entry *entry;
1577         bool ethtype;
1578         u8 prio = 0;
1579         int i;
1580
1581         dcbx_info = qed_dcbnl_get_dcbx(hwfn, QED_DCBX_OPERATIONAL_MIB);
1582         if (!dcbx_info)
1583                 return -EINVAL;
1584
1585         ethtype = !!(idtype == DCB_APP_IDTYPE_ETHTYPE);
1586         for (i = 0; i < QED_DCBX_MAX_APP_PROTOCOL; i++) {
1587                 entry = &dcbx_info->operational.params.app_entry[i];
1588                 if ((entry->ethtype == ethtype) && (entry->proto_id == idval)) {
1589                         prio = entry->prio;
1590                         break;
1591                 }
1592         }
1593
1594         if (i == QED_DCBX_MAX_APP_PROTOCOL) {
1595                 DP_ERR(cdev, "App entry (%d, %d) not found\n", idtype, idval);
1596                 kfree(dcbx_info);
1597                 return -EINVAL;
1598         }
1599
1600         kfree(dcbx_info);
1601
1602         return prio;
1603 }
1604
1605 static int qed_dcbnl_setapp(struct qed_dev *cdev,
1606                             u8 idtype, u16 idval, u8 pri_map)
1607 {
1608         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
1609         struct qed_dcbx_set dcbx_set;
1610         struct qed_app_entry *entry;
1611         struct qed_ptt *ptt;
1612         bool ethtype;
1613         int rc, i;
1614
1615         memset(&dcbx_set, 0, sizeof(dcbx_set));
1616         rc = qed_dcbx_get_config_params(hwfn, &dcbx_set);
1617         if (rc)
1618                 return -EINVAL;
1619
1620         ethtype = !!(idtype == DCB_APP_IDTYPE_ETHTYPE);
1621         for (i = 0; i < QED_DCBX_MAX_APP_PROTOCOL; i++) {
1622                 entry = &dcbx_set.config.params.app_entry[i];
1623                 if ((entry->ethtype == ethtype) && (entry->proto_id == idval))
1624                         break;
1625                 /* First empty slot */
1626                 if (!entry->proto_id)
1627                         break;
1628         }
1629
1630         if (i == QED_DCBX_MAX_APP_PROTOCOL) {
1631                 DP_ERR(cdev, "App table is full\n");
1632                 return -EBUSY;
1633         }
1634
1635         dcbx_set.override_flags |= QED_DCBX_OVERRIDE_APP_CFG;
1636         dcbx_set.config.params.app_entry[i].ethtype = ethtype;
1637         dcbx_set.config.params.app_entry[i].proto_id = idval;
1638         dcbx_set.config.params.app_entry[i].prio = pri_map;
1639
1640         ptt = qed_ptt_acquire(hwfn);
1641         if (!ptt)
1642                 return -EBUSY;
1643
1644         rc = qed_dcbx_config_params(hwfn, ptt, &dcbx_set, 0);
1645
1646         qed_ptt_release(hwfn, ptt);
1647
1648         return rc;
1649 }
1650
1651 static u8 qed_dcbnl_setdcbx(struct qed_dev *cdev, u8 mode)
1652 {
1653         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
1654         struct qed_dcbx_set dcbx_set;
1655         struct qed_ptt *ptt;
1656         int rc;
1657
1658         DP_VERBOSE(hwfn, QED_MSG_DCB, "new mode = %x\n", mode);
1659
1660         if (!(mode & DCB_CAP_DCBX_VER_IEEE) && !(mode & DCB_CAP_DCBX_VER_CEE)) {
1661                 DP_INFO(hwfn, "Allowed mode is cee, ieee or both\n");
1662                 return 1;
1663         }
1664
1665         memset(&dcbx_set, 0, sizeof(dcbx_set));
1666         rc = qed_dcbx_get_config_params(hwfn, &dcbx_set);
1667         if (rc)
1668                 return 1;
1669
1670         dcbx_set.ver_num = 0;
1671         if (mode & DCB_CAP_DCBX_VER_CEE) {
1672                 dcbx_set.ver_num |= DCBX_CONFIG_VERSION_CEE;
1673                 dcbx_set.enabled = true;
1674         }
1675
1676         if (mode & DCB_CAP_DCBX_VER_IEEE) {
1677                 dcbx_set.ver_num |= DCBX_CONFIG_VERSION_IEEE;
1678                 dcbx_set.enabled = true;
1679         }
1680
1681         ptt = qed_ptt_acquire(hwfn);
1682         if (!ptt)
1683                 return 1;
1684
1685         rc = qed_dcbx_config_params(hwfn, ptt, &dcbx_set, 0);
1686
1687         qed_ptt_release(hwfn, ptt);
1688
1689         return 0;
1690 }
1691
1692 static u8 qed_dcbnl_getfeatcfg(struct qed_dev *cdev, int featid, u8 *flags)
1693 {
1694         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
1695         struct qed_dcbx_get *dcbx_info;
1696
1697         DP_VERBOSE(hwfn, QED_MSG_DCB, "Feature id  = %d\n", featid);
1698         dcbx_info = qed_dcbnl_get_dcbx(hwfn, QED_DCBX_OPERATIONAL_MIB);
1699         if (!dcbx_info)
1700                 return 1;
1701
1702         *flags = 0;
1703         switch (featid) {
1704         case DCB_FEATCFG_ATTR_PG:
1705                 if (dcbx_info->operational.params.ets_enabled)
1706                         *flags = DCB_FEATCFG_ENABLE;
1707                 else
1708                         *flags = DCB_FEATCFG_ERROR;
1709                 break;
1710         case DCB_FEATCFG_ATTR_PFC:
1711                 if (dcbx_info->operational.params.pfc.enabled)
1712                         *flags = DCB_FEATCFG_ENABLE;
1713                 else
1714                         *flags = DCB_FEATCFG_ERROR;
1715                 break;
1716         case DCB_FEATCFG_ATTR_APP:
1717                 if (dcbx_info->operational.params.app_valid)
1718                         *flags = DCB_FEATCFG_ENABLE;
1719                 else
1720                         *flags = DCB_FEATCFG_ERROR;
1721                 break;
1722         default:
1723                 DP_INFO(hwfn, "Invalid feature-ID %d\n", featid);
1724                 kfree(dcbx_info);
1725                 return 1;
1726         }
1727
1728         DP_VERBOSE(hwfn, QED_MSG_DCB, "flags = %d\n", *flags);
1729         kfree(dcbx_info);
1730
1731         return 0;
1732 }
1733
1734 static u8 qed_dcbnl_setfeatcfg(struct qed_dev *cdev, int featid, u8 flags)
1735 {
1736         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
1737         struct qed_dcbx_set dcbx_set;
1738         bool enabled, willing;
1739         struct qed_ptt *ptt;
1740         int rc;
1741
1742         DP_VERBOSE(hwfn, QED_MSG_DCB, "featid = %d flags = %d\n",
1743                    featid, flags);
1744         memset(&dcbx_set, 0, sizeof(dcbx_set));
1745         rc = qed_dcbx_get_config_params(hwfn, &dcbx_set);
1746         if (rc)
1747                 return 1;
1748
1749         enabled = !!(flags & DCB_FEATCFG_ENABLE);
1750         willing = !!(flags & DCB_FEATCFG_WILLING);
1751         switch (featid) {
1752         case DCB_FEATCFG_ATTR_PG:
1753                 dcbx_set.override_flags |= QED_DCBX_OVERRIDE_ETS_CFG;
1754                 dcbx_set.config.params.ets_enabled = enabled;
1755                 dcbx_set.config.params.ets_willing = willing;
1756                 break;
1757         case DCB_FEATCFG_ATTR_PFC:
1758                 dcbx_set.override_flags |= QED_DCBX_OVERRIDE_PFC_CFG;
1759                 dcbx_set.config.params.pfc.enabled = enabled;
1760                 dcbx_set.config.params.pfc.willing = willing;
1761                 break;
1762         case DCB_FEATCFG_ATTR_APP:
1763                 dcbx_set.override_flags |= QED_DCBX_OVERRIDE_APP_CFG;
1764                 dcbx_set.config.params.app_willing = willing;
1765                 break;
1766         default:
1767                 DP_INFO(hwfn, "Invalid feature-ID %d\n", featid);
1768                 return 1;
1769         }
1770
1771         ptt = qed_ptt_acquire(hwfn);
1772         if (!ptt)
1773                 return 1;
1774
1775         rc = qed_dcbx_config_params(hwfn, ptt, &dcbx_set, 0);
1776
1777         qed_ptt_release(hwfn, ptt);
1778
1779         return 0;
1780 }
1781
1782 static int qed_dcbnl_peer_getappinfo(struct qed_dev *cdev,
1783                                      struct dcb_peer_app_info *info,
1784                                      u16 *app_count)
1785 {
1786         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
1787         struct qed_dcbx_get *dcbx_info;
1788
1789         dcbx_info = qed_dcbnl_get_dcbx(hwfn, QED_DCBX_REMOTE_MIB);
1790         if (!dcbx_info)
1791                 return -EINVAL;
1792
1793         info->willing = dcbx_info->remote.params.app_willing;
1794         info->error = dcbx_info->remote.params.app_error;
1795         *app_count = dcbx_info->remote.params.num_app_entries;
1796         kfree(dcbx_info);
1797
1798         return 0;
1799 }
1800
1801 static int qed_dcbnl_peer_getapptable(struct qed_dev *cdev,
1802                                       struct dcb_app *table)
1803 {
1804         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
1805         struct qed_dcbx_get *dcbx_info;
1806         int i;
1807
1808         dcbx_info = qed_dcbnl_get_dcbx(hwfn, QED_DCBX_REMOTE_MIB);
1809         if (!dcbx_info)
1810                 return -EINVAL;
1811
1812         for (i = 0; i < dcbx_info->remote.params.num_app_entries; i++) {
1813                 if (dcbx_info->remote.params.app_entry[i].ethtype)
1814                         table[i].selector = DCB_APP_IDTYPE_ETHTYPE;
1815                 else
1816                         table[i].selector = DCB_APP_IDTYPE_PORTNUM;
1817                 table[i].priority = dcbx_info->remote.params.app_entry[i].prio;
1818                 table[i].protocol =
1819                     dcbx_info->remote.params.app_entry[i].proto_id;
1820         }
1821
1822         kfree(dcbx_info);
1823
1824         return 0;
1825 }
1826
1827 static int qed_dcbnl_cee_peer_getpfc(struct qed_dev *cdev, struct cee_pfc *pfc)
1828 {
1829         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
1830         struct qed_dcbx_get *dcbx_info;
1831         int i;
1832
1833         dcbx_info = qed_dcbnl_get_dcbx(hwfn, QED_DCBX_REMOTE_MIB);
1834         if (!dcbx_info)
1835                 return -EINVAL;
1836
1837         for (i = 0; i < QED_MAX_PFC_PRIORITIES; i++)
1838                 if (dcbx_info->remote.params.pfc.prio[i])
1839                         pfc->pfc_en |= BIT(i);
1840
1841         pfc->tcs_supported = dcbx_info->remote.params.pfc.max_tc;
1842         DP_VERBOSE(hwfn, QED_MSG_DCB, "pfc state = %d tcs_supported = %d\n",
1843                    pfc->pfc_en, pfc->tcs_supported);
1844         kfree(dcbx_info);
1845
1846         return 0;
1847 }
1848
1849 static int qed_dcbnl_cee_peer_getpg(struct qed_dev *cdev, struct cee_pg *pg)
1850 {
1851         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
1852         struct qed_dcbx_get *dcbx_info;
1853         int i;
1854
1855         dcbx_info = qed_dcbnl_get_dcbx(hwfn, QED_DCBX_REMOTE_MIB);
1856         if (!dcbx_info)
1857                 return -EINVAL;
1858
1859         pg->willing = dcbx_info->remote.params.ets_willing;
1860         for (i = 0; i < QED_MAX_PFC_PRIORITIES; i++) {
1861                 pg->pg_bw[i] = dcbx_info->remote.params.ets_tc_bw_tbl[i];
1862                 pg->prio_pg[i] = dcbx_info->remote.params.ets_pri_tc_tbl[i];
1863         }
1864
1865         DP_VERBOSE(hwfn, QED_MSG_DCB, "willing = %d", pg->willing);
1866         kfree(dcbx_info);
1867
1868         return 0;
1869 }
1870
1871 static int qed_dcbnl_get_ieee_pfc(struct qed_dev *cdev,
1872                                   struct ieee_pfc *pfc, bool remote)
1873 {
1874         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
1875         struct qed_dcbx_params *params;
1876         struct qed_dcbx_get *dcbx_info;
1877         int rc, i;
1878
1879         dcbx_info = qed_dcbnl_get_dcbx(hwfn, QED_DCBX_OPERATIONAL_MIB);
1880         if (!dcbx_info)
1881                 return -EINVAL;
1882
1883         if (!dcbx_info->operational.ieee) {
1884                 DP_INFO(hwfn, "DCBX is not enabled/operational in IEEE mode\n");
1885                 return -EINVAL;
1886         }
1887
1888         if (remote) {
1889                 memset(dcbx_info, 0, sizeof(*dcbx_info));
1890                 rc = qed_dcbx_query_params(hwfn, dcbx_info,
1891                                            QED_DCBX_REMOTE_MIB);
1892                 if (rc) {
1893                         kfree(dcbx_info);
1894                         return -EINVAL;
1895                 }
1896
1897                 params = &dcbx_info->remote.params;
1898         } else {
1899                 params = &dcbx_info->operational.params;
1900         }
1901
1902         pfc->pfc_cap = params->pfc.max_tc;
1903         pfc->pfc_en = 0;
1904         for (i = 0; i < QED_MAX_PFC_PRIORITIES; i++)
1905                 if (params->pfc.prio[i])
1906                         pfc->pfc_en |= BIT(i);
1907
1908         kfree(dcbx_info);
1909
1910         return 0;
1911 }
1912
1913 static int qed_dcbnl_ieee_getpfc(struct qed_dev *cdev, struct ieee_pfc *pfc)
1914 {
1915         return qed_dcbnl_get_ieee_pfc(cdev, pfc, false);
1916 }
1917
1918 static int qed_dcbnl_ieee_setpfc(struct qed_dev *cdev, struct ieee_pfc *pfc)
1919 {
1920         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
1921         struct qed_dcbx_get *dcbx_info;
1922         struct qed_dcbx_set dcbx_set;
1923         struct qed_ptt *ptt;
1924         int rc, i;
1925
1926         dcbx_info = qed_dcbnl_get_dcbx(hwfn, QED_DCBX_OPERATIONAL_MIB);
1927         if (!dcbx_info)
1928                 return -EINVAL;
1929
1930         if (!dcbx_info->operational.ieee) {
1931                 DP_INFO(hwfn, "DCBX is not enabled/operational in IEEE mode\n");
1932                 kfree(dcbx_info);
1933                 return -EINVAL;
1934         }
1935
1936         kfree(dcbx_info);
1937
1938         memset(&dcbx_set, 0, sizeof(dcbx_set));
1939         rc = qed_dcbx_get_config_params(hwfn, &dcbx_set);
1940         if (rc)
1941                 return -EINVAL;
1942
1943         dcbx_set.override_flags |= QED_DCBX_OVERRIDE_PFC_CFG;
1944         for (i = 0; i < QED_MAX_PFC_PRIORITIES; i++)
1945                 dcbx_set.config.params.pfc.prio[i] = !!(pfc->pfc_en & BIT(i));
1946
1947         ptt = qed_ptt_acquire(hwfn);
1948         if (!ptt)
1949                 return -EINVAL;
1950
1951         rc = qed_dcbx_config_params(hwfn, ptt, &dcbx_set, 0);
1952
1953         qed_ptt_release(hwfn, ptt);
1954
1955         return rc;
1956 }
1957
1958 static int qed_dcbnl_get_ieee_ets(struct qed_dev *cdev,
1959                                   struct ieee_ets *ets, bool remote)
1960 {
1961         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
1962         struct qed_dcbx_get *dcbx_info;
1963         struct qed_dcbx_params *params;
1964         int rc;
1965
1966         dcbx_info = qed_dcbnl_get_dcbx(hwfn, QED_DCBX_OPERATIONAL_MIB);
1967         if (!dcbx_info)
1968                 return -EINVAL;
1969
1970         if (!dcbx_info->operational.ieee) {
1971                 DP_INFO(hwfn, "DCBX is not enabled/operational in IEEE mode\n");
1972                 kfree(dcbx_info);
1973                 return -EINVAL;
1974         }
1975
1976         if (remote) {
1977                 memset(dcbx_info, 0, sizeof(*dcbx_info));
1978                 rc = qed_dcbx_query_params(hwfn, dcbx_info,
1979                                            QED_DCBX_REMOTE_MIB);
1980                 if (rc) {
1981                         kfree(dcbx_info);
1982                         return -EINVAL;
1983                 }
1984
1985                 params = &dcbx_info->remote.params;
1986         } else {
1987                 params = &dcbx_info->operational.params;
1988         }
1989
1990         ets->ets_cap = params->max_ets_tc;
1991         ets->willing = params->ets_willing;
1992         ets->cbs = params->ets_cbs;
1993         memcpy(ets->tc_tx_bw, params->ets_tc_bw_tbl, sizeof(ets->tc_tx_bw));
1994         memcpy(ets->tc_tsa, params->ets_tc_tsa_tbl, sizeof(ets->tc_tsa));
1995         memcpy(ets->prio_tc, params->ets_pri_tc_tbl, sizeof(ets->prio_tc));
1996         kfree(dcbx_info);
1997
1998         return 0;
1999 }
2000
2001 static int qed_dcbnl_ieee_getets(struct qed_dev *cdev, struct ieee_ets *ets)
2002 {
2003         return qed_dcbnl_get_ieee_ets(cdev, ets, false);
2004 }
2005
2006 static int qed_dcbnl_ieee_setets(struct qed_dev *cdev, struct ieee_ets *ets)
2007 {
2008         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
2009         struct qed_dcbx_get *dcbx_info;
2010         struct qed_dcbx_set dcbx_set;
2011         struct qed_ptt *ptt;
2012         int rc;
2013
2014         dcbx_info = qed_dcbnl_get_dcbx(hwfn, QED_DCBX_OPERATIONAL_MIB);
2015         if (!dcbx_info)
2016                 return -EINVAL;
2017
2018         if (!dcbx_info->operational.ieee) {
2019                 DP_INFO(hwfn, "DCBX is not enabled/operational in IEEE mode\n");
2020                 kfree(dcbx_info);
2021                 return -EINVAL;
2022         }
2023
2024         kfree(dcbx_info);
2025
2026         memset(&dcbx_set, 0, sizeof(dcbx_set));
2027         rc = qed_dcbx_get_config_params(hwfn, &dcbx_set);
2028         if (rc)
2029                 return -EINVAL;
2030
2031         dcbx_set.override_flags |= QED_DCBX_OVERRIDE_ETS_CFG;
2032         dcbx_set.config.params.max_ets_tc = ets->ets_cap;
2033         dcbx_set.config.params.ets_willing = ets->willing;
2034         dcbx_set.config.params.ets_cbs = ets->cbs;
2035         memcpy(dcbx_set.config.params.ets_tc_bw_tbl, ets->tc_tx_bw,
2036                sizeof(ets->tc_tx_bw));
2037         memcpy(dcbx_set.config.params.ets_tc_tsa_tbl, ets->tc_tsa,
2038                sizeof(ets->tc_tsa));
2039         memcpy(dcbx_set.config.params.ets_pri_tc_tbl, ets->prio_tc,
2040                sizeof(ets->prio_tc));
2041
2042         ptt = qed_ptt_acquire(hwfn);
2043         if (!ptt)
2044                 return -EINVAL;
2045
2046         rc = qed_dcbx_config_params(hwfn, ptt, &dcbx_set, 0);
2047
2048         qed_ptt_release(hwfn, ptt);
2049
2050         return rc;
2051 }
2052
2053 int qed_dcbnl_ieee_peer_getets(struct qed_dev *cdev, struct ieee_ets *ets)
2054 {
2055         return qed_dcbnl_get_ieee_ets(cdev, ets, true);
2056 }
2057
2058 int qed_dcbnl_ieee_peer_getpfc(struct qed_dev *cdev, struct ieee_pfc *pfc)
2059 {
2060         return qed_dcbnl_get_ieee_pfc(cdev, pfc, true);
2061 }
2062
2063 int qed_dcbnl_ieee_getapp(struct qed_dev *cdev, struct dcb_app *app)
2064 {
2065         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
2066         struct qed_dcbx_get *dcbx_info;
2067         struct qed_app_entry *entry;
2068         bool ethtype;
2069         u8 prio = 0;
2070         int i;
2071
2072         dcbx_info = qed_dcbnl_get_dcbx(hwfn, QED_DCBX_OPERATIONAL_MIB);
2073         if (!dcbx_info)
2074                 return -EINVAL;
2075
2076         if (!dcbx_info->operational.ieee) {
2077                 DP_INFO(hwfn, "DCBX is not enabled/operational in IEEE mode\n");
2078                 kfree(dcbx_info);
2079                 return -EINVAL;
2080         }
2081
2082         /* ieee defines the selector field value for ethertype to be 1 */
2083         ethtype = !!((app->selector - 1) == DCB_APP_IDTYPE_ETHTYPE);
2084         for (i = 0; i < QED_DCBX_MAX_APP_PROTOCOL; i++) {
2085                 entry = &dcbx_info->operational.params.app_entry[i];
2086                 if ((entry->ethtype == ethtype) &&
2087                     (entry->proto_id == app->protocol)) {
2088                         prio = entry->prio;
2089                         break;
2090                 }
2091         }
2092
2093         if (i == QED_DCBX_MAX_APP_PROTOCOL) {
2094                 DP_ERR(cdev, "App entry (%d, %d) not found\n", app->selector,
2095                        app->protocol);
2096                 kfree(dcbx_info);
2097                 return -EINVAL;
2098         }
2099
2100         app->priority = ffs(prio) - 1;
2101
2102         kfree(dcbx_info);
2103
2104         return 0;
2105 }
2106
2107 int qed_dcbnl_ieee_setapp(struct qed_dev *cdev, struct dcb_app *app)
2108 {
2109         struct qed_hwfn *hwfn = QED_LEADING_HWFN(cdev);
2110         struct qed_dcbx_get *dcbx_info;
2111         struct qed_dcbx_set dcbx_set;
2112         struct qed_app_entry *entry;
2113         struct qed_ptt *ptt;
2114         bool ethtype;
2115         int rc, i;
2116
2117         if (app->priority < 0 || app->priority >= QED_MAX_PFC_PRIORITIES) {
2118                 DP_INFO(hwfn, "Invalid priority %d\n", app->priority);
2119                 return -EINVAL;
2120         }
2121
2122         dcbx_info = qed_dcbnl_get_dcbx(hwfn, QED_DCBX_OPERATIONAL_MIB);
2123         if (!dcbx_info)
2124                 return -EINVAL;
2125
2126         if (!dcbx_info->operational.ieee) {
2127                 DP_INFO(hwfn, "DCBX is not enabled/operational in IEEE mode\n");
2128                 kfree(dcbx_info);
2129                 return -EINVAL;
2130         }
2131
2132         kfree(dcbx_info);
2133
2134         memset(&dcbx_set, 0, sizeof(dcbx_set));
2135         rc = qed_dcbx_get_config_params(hwfn, &dcbx_set);
2136         if (rc)
2137                 return -EINVAL;
2138
2139         /* ieee defines the selector field value for ethertype to be 1 */
2140         ethtype = !!((app->selector - 1) == DCB_APP_IDTYPE_ETHTYPE);
2141         for (i = 0; i < QED_DCBX_MAX_APP_PROTOCOL; i++) {
2142                 entry = &dcbx_set.config.params.app_entry[i];
2143                 if ((entry->ethtype == ethtype) &&
2144                     (entry->proto_id == app->protocol))
2145                         break;
2146                 /* First empty slot */
2147                 if (!entry->proto_id)
2148                         break;
2149         }
2150
2151         if (i == QED_DCBX_MAX_APP_PROTOCOL) {
2152                 DP_ERR(cdev, "App table is full\n");
2153                 return -EBUSY;
2154         }
2155
2156         dcbx_set.override_flags |= QED_DCBX_OVERRIDE_APP_CFG;
2157         dcbx_set.config.params.app_entry[i].ethtype = ethtype;
2158         dcbx_set.config.params.app_entry[i].proto_id = app->protocol;
2159         dcbx_set.config.params.app_entry[i].prio = BIT(app->priority);
2160
2161         ptt = qed_ptt_acquire(hwfn);
2162         if (!ptt)
2163                 return -EBUSY;
2164
2165         rc = qed_dcbx_config_params(hwfn, ptt, &dcbx_set, 0);
2166
2167         qed_ptt_release(hwfn, ptt);
2168
2169         return rc;
2170 }
2171
2172 const struct qed_eth_dcbnl_ops qed_dcbnl_ops_pass = {
2173         .getstate = qed_dcbnl_getstate,
2174         .setstate = qed_dcbnl_setstate,
2175         .getpgtccfgtx = qed_dcbnl_getpgtccfgtx,
2176         .getpgbwgcfgtx = qed_dcbnl_getpgbwgcfgtx,
2177         .getpgtccfgrx = qed_dcbnl_getpgtccfgrx,
2178         .getpgbwgcfgrx = qed_dcbnl_getpgbwgcfgrx,
2179         .getpfccfg = qed_dcbnl_getpfccfg,
2180         .setpfccfg = qed_dcbnl_setpfccfg,
2181         .getcap = qed_dcbnl_getcap,
2182         .getnumtcs = qed_dcbnl_getnumtcs,
2183         .getpfcstate = qed_dcbnl_getpfcstate,
2184         .getdcbx = qed_dcbnl_getdcbx,
2185         .setpgtccfgtx = qed_dcbnl_setpgtccfgtx,
2186         .setpgtccfgrx = qed_dcbnl_setpgtccfgrx,
2187         .setpgbwgcfgtx = qed_dcbnl_setpgbwgcfgtx,
2188         .setpgbwgcfgrx = qed_dcbnl_setpgbwgcfgrx,
2189         .setall = qed_dcbnl_setall,
2190         .setnumtcs = qed_dcbnl_setnumtcs,
2191         .setpfcstate = qed_dcbnl_setpfcstate,
2192         .setapp = qed_dcbnl_setapp,
2193         .setdcbx = qed_dcbnl_setdcbx,
2194         .setfeatcfg = qed_dcbnl_setfeatcfg,
2195         .getfeatcfg = qed_dcbnl_getfeatcfg,
2196         .getapp = qed_dcbnl_getapp,
2197         .peer_getappinfo = qed_dcbnl_peer_getappinfo,
2198         .peer_getapptable = qed_dcbnl_peer_getapptable,
2199         .cee_peer_getpfc = qed_dcbnl_cee_peer_getpfc,
2200         .cee_peer_getpg = qed_dcbnl_cee_peer_getpg,
2201         .ieee_getpfc = qed_dcbnl_ieee_getpfc,
2202         .ieee_setpfc = qed_dcbnl_ieee_setpfc,
2203         .ieee_getets = qed_dcbnl_ieee_getets,
2204         .ieee_setets = qed_dcbnl_ieee_setets,
2205         .ieee_peer_getpfc = qed_dcbnl_ieee_peer_getpfc,
2206         .ieee_peer_getets = qed_dcbnl_ieee_peer_getets,
2207         .ieee_getapp = qed_dcbnl_ieee_getapp,
2208         .ieee_setapp = qed_dcbnl_ieee_setapp,
2209 };
2210
2211 #endif