2 * Copyright (c) 2016 QLogic Corporation.
6 * See LICENSE.qede_pmd for copyright and licensing details.
11 #include "ecore_sp_commands.h"
12 #include "ecore_dcbx.h"
13 #include "ecore_cxt.h"
14 #include "ecore_gtt_reg_addr.h"
15 #include "ecore_iro.h"
16 #include "ecore_iov_api.h"
18 #define ECORE_DCBX_MAX_MIB_READ_TRY (100)
19 #define ECORE_ETH_TYPE_DEFAULT (0)
21 #define ECORE_DCBX_INVALID_PRIORITY 0xFF
23 /* Get Traffic Class from priority traffic class table, 4 bits represent
24 * the traffic class corresponding to the priority.
26 #define ECORE_DCBX_PRIO2TC(prio_tc_tbl, prio) \
27 ((u32)(prio_tc_tbl >> ((7 - prio) * 4)) & 0x7)
29 static bool ecore_dcbx_app_ethtype(u32 app_info_bitmap)
31 return !!(ECORE_MFW_GET_FIELD(app_info_bitmap, DCBX_APP_SF) ==
35 static bool ecore_dcbx_ieee_app_ethtype(u32 app_info_bitmap)
37 u8 mfw_val = ECORE_MFW_GET_FIELD(app_info_bitmap, DCBX_APP_SF_IEEE);
40 if (mfw_val == DCBX_APP_SF_IEEE_RESERVED)
41 return ecore_dcbx_app_ethtype(app_info_bitmap);
43 return !!(mfw_val == DCBX_APP_SF_IEEE_ETHTYPE);
46 static bool ecore_dcbx_app_port(u32 app_info_bitmap)
48 return !!(ECORE_MFW_GET_FIELD(app_info_bitmap, DCBX_APP_SF) ==
52 static bool ecore_dcbx_ieee_app_port(u32 app_info_bitmap, u8 type)
54 u8 mfw_val = ECORE_MFW_GET_FIELD(app_info_bitmap, DCBX_APP_SF_IEEE);
57 if (mfw_val == DCBX_APP_SF_IEEE_RESERVED)
58 return ecore_dcbx_app_port(app_info_bitmap);
60 return !!(mfw_val == type || mfw_val == DCBX_APP_SF_IEEE_TCP_UDP_PORT);
63 static bool ecore_dcbx_default_tlv(u32 app_info_bitmap, u16 proto_id, bool ieee)
68 ethtype = ecore_dcbx_ieee_app_ethtype(app_info_bitmap);
70 ethtype = ecore_dcbx_app_ethtype(app_info_bitmap);
72 return !!(ethtype && (proto_id == ECORE_ETH_TYPE_DEFAULT));
76 ecore_dcbx_dp_protocol(struct ecore_hwfn *p_hwfn,
77 struct ecore_dcbx_results *p_data)
79 enum dcbx_protocol_type id;
82 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB, "DCBX negotiated: %d\n",
83 p_data->dcbx_enabled);
85 for (i = 0; i < OSAL_ARRAY_SIZE(ecore_dcbx_app_update); i++) {
86 id = ecore_dcbx_app_update[i].id;
88 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
89 "%s info: update %d, enable %d, prio %d, tc %d,"
90 " num_active_tc %d dscp_enable = %d dscp_val = %d\n",
91 ecore_dcbx_app_update[i].name,
92 p_data->arr[id].update,
93 p_data->arr[id].enable, p_data->arr[id].priority,
94 p_data->arr[id].tc, p_hwfn->hw_info.num_active_tc,
95 p_data->arr[id].dscp_enable,
96 p_data->arr[id].dscp_val);
101 ecore_dcbx_set_params(struct ecore_dcbx_results *p_data,
102 struct ecore_hwfn *p_hwfn,
103 bool enable, bool update, u8 prio, u8 tc,
104 enum dcbx_protocol_type type,
105 enum ecore_pci_personality personality)
107 struct ecore_dcbx_dscp_params *dscp = &p_hwfn->p_dcbx_info->get.dscp;
109 /* PF update ramrod data */
110 p_data->arr[type].enable = enable;
111 p_data->arr[type].priority = prio;
112 p_data->arr[type].tc = tc;
113 p_data->arr[type].dscp_enable = dscp->enabled;
114 if (p_data->arr[type].dscp_enable) {
117 for (i = 0; i < ECORE_DCBX_DSCP_SIZE; i++)
118 if (prio == dscp->dscp_pri_map[i]) {
119 p_data->arr[type].dscp_val = i;
124 if (enable && p_data->arr[type].dscp_enable)
125 p_data->arr[type].update = UPDATE_DCB_DSCP;
127 p_data->arr[type].update = UPDATE_DCB;
129 p_data->arr[type].update = DONT_UPDATE_DCB_DHCP;
132 if (p_hwfn->hw_info.personality == personality) {
133 p_hwfn->hw_info.offload_tc = tc;
134 if (personality == ECORE_PCI_ISCSI)
135 p_hwfn->hw_info.ooo_tc = DCBX_ISCSI_OOO_TC;
139 /* Update app protocol data and hw_info fields with the TLV info */
141 ecore_dcbx_update_app_info(struct ecore_dcbx_results *p_data,
142 struct ecore_hwfn *p_hwfn,
143 bool enable, bool update, u8 prio, u8 tc,
144 enum dcbx_protocol_type type)
146 enum ecore_pci_personality personality;
147 enum dcbx_protocol_type id;
148 const char *name; /* @DPDK */
151 for (i = 0; i < OSAL_ARRAY_SIZE(ecore_dcbx_app_update); i++) {
152 id = ecore_dcbx_app_update[i].id;
157 personality = ecore_dcbx_app_update[i].personality;
158 name = ecore_dcbx_app_update[i].name;
160 ecore_dcbx_set_params(p_data, p_hwfn, enable, update,
161 prio, tc, type, personality);
165 static enum _ecore_status_t
166 ecore_dcbx_get_app_priority(u8 pri_bitmap, u8 *priority)
168 u32 pri_mask, pri = ECORE_MAX_PFC_PRIORITIES;
169 u32 index = ECORE_MAX_PFC_PRIORITIES - 1;
170 enum _ecore_status_t rc = ECORE_SUCCESS;
172 /* Bitmap 1 corresponds to priority 0, return priority 0 */
173 if (pri_bitmap == 1) {
178 /* Choose the highest priority */
179 while ((pri == ECORE_MAX_PFC_PRIORITIES) && index) {
180 pri_mask = 1 << index;
181 if (pri_bitmap & pri_mask)
186 if (pri < ECORE_MAX_PFC_PRIORITIES)
195 ecore_dcbx_get_app_protocol_type(struct ecore_hwfn *p_hwfn,
196 u32 app_prio_bitmap, u16 id,
197 enum dcbx_protocol_type *type, bool ieee)
199 if (ecore_dcbx_default_tlv(app_prio_bitmap, id, ieee)) {
200 *type = DCBX_PROTOCOL_ETH;
202 *type = DCBX_MAX_PROTOCOL_TYPE;
204 "No action required, App TLV id = 0x%x"
205 " app_prio_bitmap = 0x%x\n",
206 id, app_prio_bitmap);
213 /* Parse app TLV's to update TC information in hw_info structure for
214 * reconfiguring QM. Get protocol specific data for PF update ramrod command.
216 static enum _ecore_status_t
217 ecore_dcbx_process_tlv(struct ecore_hwfn *p_hwfn,
218 struct ecore_dcbx_results *p_data,
219 struct dcbx_app_priority_entry *p_tbl, u32 pri_tc_tbl,
220 int count, u8 dcbx_version)
222 enum dcbx_protocol_type type;
227 enum _ecore_status_t rc = ECORE_SUCCESS;
230 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB, "Num APP entries = %d\n", count);
232 ieee = (dcbx_version == DCBX_CONFIG_VERSION_IEEE);
234 for (i = 0; i < count; i++) {
235 protocol_id = ECORE_MFW_GET_FIELD(p_tbl[i].entry,
236 DCBX_APP_PROTOCOL_ID);
237 priority_map = ECORE_MFW_GET_FIELD(p_tbl[i].entry,
239 rc = ecore_dcbx_get_app_priority(priority_map, &priority);
240 if (rc == ECORE_INVAL) {
241 DP_ERR(p_hwfn, "Invalid priority\n");
245 tc = ECORE_DCBX_PRIO2TC(pri_tc_tbl, priority);
246 if (ecore_dcbx_get_app_protocol_type(p_hwfn, p_tbl[i].entry,
249 /* ETH always have the enable bit reset, as it gets
250 * vlan information per packet. For other protocols,
251 * should be set according to the dcbx_enabled
252 * indication, but we only got here if there was an
253 * app tlv for the protocol, so dcbx must be enabled.
255 enable = !(type == DCBX_PROTOCOL_ETH);
257 ecore_dcbx_update_app_info(p_data, p_hwfn, enable, true,
261 /* Update ramrod protocol data and hw_info fields
262 * with default info when corresponding APP TLV's are not detected.
263 * The enabled field has a different logic for ethernet as only for
264 * ethernet dcb should disabled by default, as the information arrives
265 * from the OS (unless an explicit app tlv was present).
267 tc = p_data->arr[DCBX_PROTOCOL_ETH].tc;
268 priority = p_data->arr[DCBX_PROTOCOL_ETH].priority;
269 for (type = 0; type < DCBX_MAX_PROTOCOL_TYPE; type++) {
270 if (p_data->arr[type].update)
273 enable = (type == DCBX_PROTOCOL_ETH) ? false : !!dcbx_version;
274 ecore_dcbx_update_app_info(p_data, p_hwfn, enable, true,
278 return ECORE_SUCCESS;
281 /* Parse app TLV's to update TC information in hw_info structure for
282 * reconfiguring QM. Get protocol specific data for PF update ramrod command.
284 static enum _ecore_status_t
285 ecore_dcbx_process_mib_info(struct ecore_hwfn *p_hwfn)
287 struct dcbx_app_priority_feature *p_app;
288 enum _ecore_status_t rc = ECORE_SUCCESS;
289 struct ecore_dcbx_results data = { 0 };
290 struct dcbx_app_priority_entry *p_tbl;
291 struct dcbx_ets_feature *p_ets;
292 struct ecore_hw_info *p_info;
293 u32 pri_tc_tbl, flags;
297 flags = p_hwfn->p_dcbx_info->operational.flags;
298 dcbx_version = ECORE_MFW_GET_FIELD(flags, DCBX_CONFIG_VERSION);
300 p_app = &p_hwfn->p_dcbx_info->operational.features.app;
301 p_tbl = p_app->app_pri_tbl;
303 p_ets = &p_hwfn->p_dcbx_info->operational.features.ets;
304 pri_tc_tbl = p_ets->pri_tc_tbl[0];
306 p_info = &p_hwfn->hw_info;
307 num_entries = ECORE_MFW_GET_FIELD(p_app->flags, DCBX_APP_NUM_ENTRIES);
309 rc = ecore_dcbx_process_tlv(p_hwfn, &data, p_tbl, pri_tc_tbl,
310 num_entries, dcbx_version);
311 if (rc != ECORE_SUCCESS)
314 p_info->num_active_tc = ECORE_MFW_GET_FIELD(p_ets->flags,
316 data.pf_id = p_hwfn->rel_pf_id;
317 data.dcbx_enabled = !!dcbx_version;
319 ecore_dcbx_dp_protocol(p_hwfn, &data);
321 OSAL_MEMCPY(&p_hwfn->p_dcbx_info->results, &data,
322 sizeof(struct ecore_dcbx_results));
324 return ECORE_SUCCESS;
327 static enum _ecore_status_t
328 ecore_dcbx_copy_mib(struct ecore_hwfn *p_hwfn,
329 struct ecore_ptt *p_ptt,
330 struct ecore_dcbx_mib_meta_data *p_data,
331 enum ecore_mib_read_type type)
333 enum _ecore_status_t rc = ECORE_SUCCESS;
334 u32 prefix_seq_num, suffix_seq_num;
337 /* The data is considered to be valid only if both sequence numbers are
341 if (type == ECORE_DCBX_REMOTE_LLDP_MIB) {
342 ecore_memcpy_from(p_hwfn, p_ptt, p_data->lldp_remote,
343 p_data->addr, p_data->size);
344 prefix_seq_num = p_data->lldp_remote->prefix_seq_num;
345 suffix_seq_num = p_data->lldp_remote->suffix_seq_num;
347 ecore_memcpy_from(p_hwfn, p_ptt, p_data->mib,
348 p_data->addr, p_data->size);
349 prefix_seq_num = p_data->mib->prefix_seq_num;
350 suffix_seq_num = p_data->mib->suffix_seq_num;
354 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
355 "mib type = %d, try count = %d prefix seq num ="
356 " %d suffix seq num = %d\n",
357 type, read_count, prefix_seq_num, suffix_seq_num);
358 } while ((prefix_seq_num != suffix_seq_num) &&
359 (read_count < ECORE_DCBX_MAX_MIB_READ_TRY));
361 if (read_count >= ECORE_DCBX_MAX_MIB_READ_TRY) {
363 "MIB read err, mib type = %d, try count ="
364 " %d prefix seq num = %d suffix seq num = %d\n",
365 type, read_count, prefix_seq_num, suffix_seq_num);
373 ecore_dcbx_get_priority_info(struct ecore_hwfn *p_hwfn,
374 struct ecore_dcbx_app_prio *p_prio,
375 struct ecore_dcbx_results *p_results)
379 if (p_results->arr[DCBX_PROTOCOL_ETH].update &&
380 p_results->arr[DCBX_PROTOCOL_ETH].enable)
381 p_prio->eth = p_results->arr[DCBX_PROTOCOL_ETH].priority;
383 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
384 "Priorities: eth %d\n",
389 ecore_dcbx_get_app_data(struct ecore_hwfn *p_hwfn,
390 struct dcbx_app_priority_feature *p_app,
391 struct dcbx_app_priority_entry *p_tbl,
392 struct ecore_dcbx_params *p_params, bool ieee)
394 struct ecore_app_entry *entry;
398 p_params->app_willing = ECORE_MFW_GET_FIELD(p_app->flags,
400 p_params->app_valid = ECORE_MFW_GET_FIELD(p_app->flags,
402 p_params->app_error = ECORE_MFW_GET_FIELD(p_app->flags, DCBX_APP_ERROR);
403 p_params->num_app_entries = ECORE_MFW_GET_FIELD(p_app->flags,
404 DCBX_APP_NUM_ENTRIES);
405 for (i = 0; i < DCBX_MAX_APP_PROTOCOL; i++) {
406 entry = &p_params->app_entry[i];
411 sf_ieee = ECORE_MFW_GET_FIELD(p_tbl[i].entry,
414 case DCBX_APP_SF_IEEE_RESERVED:
416 val = ECORE_MFW_GET_FIELD(p_tbl[i].entry,
418 entry->sf_ieee = val ?
419 ECORE_DCBX_SF_IEEE_TCP_UDP_PORT :
420 ECORE_DCBX_SF_IEEE_ETHTYPE;
422 case DCBX_APP_SF_IEEE_ETHTYPE:
423 entry->sf_ieee = ECORE_DCBX_SF_IEEE_ETHTYPE;
425 case DCBX_APP_SF_IEEE_TCP_PORT:
426 entry->sf_ieee = ECORE_DCBX_SF_IEEE_TCP_PORT;
428 case DCBX_APP_SF_IEEE_UDP_PORT:
429 entry->sf_ieee = ECORE_DCBX_SF_IEEE_UDP_PORT;
431 case DCBX_APP_SF_IEEE_TCP_UDP_PORT:
433 ECORE_DCBX_SF_IEEE_TCP_UDP_PORT;
437 entry->ethtype = !(ECORE_MFW_GET_FIELD(p_tbl[i].entry,
441 pri_map = ECORE_MFW_GET_FIELD(p_tbl[i].entry, DCBX_APP_PRI_MAP);
442 ecore_dcbx_get_app_priority(pri_map, &entry->prio);
443 entry->proto_id = ECORE_MFW_GET_FIELD(p_tbl[i].entry,
444 DCBX_APP_PROTOCOL_ID);
445 ecore_dcbx_get_app_protocol_type(p_hwfn, p_tbl[i].entry,
447 &entry->proto_type, ieee);
450 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
451 "APP params: willing %d, valid %d error = %d\n",
452 p_params->app_willing, p_params->app_valid,
453 p_params->app_error);
457 ecore_dcbx_get_pfc_data(struct ecore_hwfn *p_hwfn,
458 u32 pfc, struct ecore_dcbx_params *p_params)
462 p_params->pfc.willing = ECORE_MFW_GET_FIELD(pfc, DCBX_PFC_WILLING);
463 p_params->pfc.max_tc = ECORE_MFW_GET_FIELD(pfc, DCBX_PFC_CAPS);
464 p_params->pfc.enabled = ECORE_MFW_GET_FIELD(pfc, DCBX_PFC_ENABLED);
465 pfc_map = ECORE_MFW_GET_FIELD(pfc, DCBX_PFC_PRI_EN_BITMAP);
466 p_params->pfc.prio[0] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_0);
467 p_params->pfc.prio[1] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_1);
468 p_params->pfc.prio[2] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_2);
469 p_params->pfc.prio[3] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_3);
470 p_params->pfc.prio[4] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_4);
471 p_params->pfc.prio[5] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_5);
472 p_params->pfc.prio[6] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_6);
473 p_params->pfc.prio[7] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_7);
475 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
476 "PFC params: willing %d, pfc_bitmap %d\n",
477 p_params->pfc.willing, pfc_map);
481 ecore_dcbx_get_ets_data(struct ecore_hwfn *p_hwfn,
482 struct dcbx_ets_feature *p_ets,
483 struct ecore_dcbx_params *p_params)
485 u32 bw_map[2], tsa_map[2], pri_map;
488 p_params->ets_willing = ECORE_MFW_GET_FIELD(p_ets->flags,
490 p_params->ets_enabled = ECORE_MFW_GET_FIELD(p_ets->flags,
492 p_params->ets_cbs = ECORE_MFW_GET_FIELD(p_ets->flags, DCBX_ETS_CBS);
493 p_params->max_ets_tc = ECORE_MFW_GET_FIELD(p_ets->flags,
495 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
496 "ETS params: willing %d, ets_cbs %d pri_tc_tbl_0 %x"
498 p_params->ets_willing, p_params->ets_cbs,
499 p_ets->pri_tc_tbl[0], p_params->max_ets_tc);
501 /* 8 bit tsa and bw data corresponding to each of the 8 TC's are
502 * encoded in a type u32 array of size 2.
504 bw_map[0] = OSAL_BE32_TO_CPU(p_ets->tc_bw_tbl[0]);
505 bw_map[1] = OSAL_BE32_TO_CPU(p_ets->tc_bw_tbl[1]);
506 tsa_map[0] = OSAL_BE32_TO_CPU(p_ets->tc_tsa_tbl[0]);
507 tsa_map[1] = OSAL_BE32_TO_CPU(p_ets->tc_tsa_tbl[1]);
508 pri_map = p_ets->pri_tc_tbl[0];
509 for (i = 0; i < ECORE_MAX_PFC_PRIORITIES; i++) {
510 p_params->ets_tc_bw_tbl[i] = ((u8 *)bw_map)[i];
511 p_params->ets_tc_tsa_tbl[i] = ((u8 *)tsa_map)[i];
512 p_params->ets_pri_tc_tbl[i] = ECORE_DCBX_PRIO2TC(pri_map, i);
513 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
514 "elem %d bw_tbl %x tsa_tbl %x\n",
515 i, p_params->ets_tc_bw_tbl[i],
516 p_params->ets_tc_tsa_tbl[i]);
521 ecore_dcbx_get_common_params(struct ecore_hwfn *p_hwfn,
522 struct dcbx_app_priority_feature *p_app,
523 struct dcbx_app_priority_entry *p_tbl,
524 struct dcbx_ets_feature *p_ets,
525 u32 pfc, struct ecore_dcbx_params *p_params,
528 ecore_dcbx_get_app_data(p_hwfn, p_app, p_tbl, p_params, ieee);
529 ecore_dcbx_get_ets_data(p_hwfn, p_ets, p_params);
530 ecore_dcbx_get_pfc_data(p_hwfn, pfc, p_params);
534 ecore_dcbx_get_local_params(struct ecore_hwfn *p_hwfn,
535 struct ecore_ptt *p_ptt,
536 struct ecore_dcbx_get *params)
538 struct dcbx_features *p_feat;
540 p_feat = &p_hwfn->p_dcbx_info->local_admin.features;
541 ecore_dcbx_get_common_params(p_hwfn, &p_feat->app,
542 p_feat->app.app_pri_tbl, &p_feat->ets,
543 p_feat->pfc, ¶ms->local.params, false);
544 params->local.valid = true;
548 ecore_dcbx_get_remote_params(struct ecore_hwfn *p_hwfn,
549 struct ecore_ptt *p_ptt,
550 struct ecore_dcbx_get *params)
552 struct dcbx_features *p_feat;
554 p_feat = &p_hwfn->p_dcbx_info->remote.features;
555 ecore_dcbx_get_common_params(p_hwfn, &p_feat->app,
556 p_feat->app.app_pri_tbl, &p_feat->ets,
557 p_feat->pfc, ¶ms->remote.params,
559 params->remote.valid = true;
562 static enum _ecore_status_t
563 ecore_dcbx_get_operational_params(struct ecore_hwfn *p_hwfn,
564 struct ecore_ptt *p_ptt,
565 struct ecore_dcbx_get *params)
567 struct ecore_dcbx_operational_params *p_operational;
568 struct ecore_dcbx_results *p_results;
569 struct dcbx_features *p_feat;
574 flags = p_hwfn->p_dcbx_info->operational.flags;
576 /* If DCBx version is non zero, then negotiation
577 * was successfuly performed
579 p_operational = ¶ms->operational;
580 enabled = !!(ECORE_MFW_GET_FIELD(flags, DCBX_CONFIG_VERSION) !=
581 DCBX_CONFIG_VERSION_DISABLED);
583 p_operational->enabled = enabled;
584 p_operational->valid = false;
588 p_feat = &p_hwfn->p_dcbx_info->operational.features;
589 p_results = &p_hwfn->p_dcbx_info->results;
591 val = !!(ECORE_MFW_GET_FIELD(flags, DCBX_CONFIG_VERSION) ==
592 DCBX_CONFIG_VERSION_IEEE);
593 p_operational->ieee = val;
595 val = !!(ECORE_MFW_GET_FIELD(flags, DCBX_CONFIG_VERSION) ==
596 DCBX_CONFIG_VERSION_CEE);
597 p_operational->cee = val;
599 val = !!(ECORE_MFW_GET_FIELD(flags, DCBX_CONFIG_VERSION) ==
600 DCBX_CONFIG_VERSION_STATIC);
601 p_operational->local = val;
603 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
604 "Version support: ieee %d, cee %d, static %d\n",
605 p_operational->ieee, p_operational->cee,
606 p_operational->local);
608 ecore_dcbx_get_common_params(p_hwfn, &p_feat->app,
609 p_feat->app.app_pri_tbl, &p_feat->ets,
610 p_feat->pfc, ¶ms->operational.params,
611 p_operational->ieee);
612 ecore_dcbx_get_priority_info(p_hwfn, &p_operational->app_prio,
614 err = ECORE_MFW_GET_FIELD(p_feat->app.flags, DCBX_APP_ERROR);
615 p_operational->err = err;
616 p_operational->enabled = enabled;
617 p_operational->valid = true;
619 return ECORE_SUCCESS;
623 ecore_dcbx_get_dscp_params(struct ecore_hwfn *p_hwfn,
624 struct ecore_ptt *p_ptt,
625 struct ecore_dcbx_get *params)
627 struct ecore_dcbx_dscp_params *p_dscp;
628 struct dcb_dscp_map *p_dscp_map;
632 p_dscp = ¶ms->dscp;
633 p_dscp_map = &p_hwfn->p_dcbx_info->dscp_map;
634 p_dscp->enabled = ECORE_MFW_GET_FIELD(p_dscp_map->flags,
636 /* MFW encodes 64 dscp entries into 8 element array of u32 entries,
637 * where each entry holds the 4bit priority map for 8 dscp entries.
639 for (i = 0, entry = 0; i < ECORE_DCBX_DSCP_SIZE / 8; i++) {
640 pri_map = OSAL_BE32_TO_CPU(p_dscp_map->dscp_pri_map[i]);
641 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB, "elem %d pri_map 0x%x\n",
643 for (j = 0; j < ECORE_DCBX_DSCP_SIZE / 8; j++, entry++)
644 p_dscp->dscp_pri_map[entry] = (u32)(pri_map >>
650 ecore_dcbx_get_local_lldp_params(struct ecore_hwfn *p_hwfn,
651 struct ecore_ptt *p_ptt,
652 struct ecore_dcbx_get *params)
654 struct lldp_config_params_s *p_local;
656 p_local = &p_hwfn->p_dcbx_info->lldp_local[LLDP_NEAREST_BRIDGE];
658 OSAL_MEMCPY(params->lldp_local.local_chassis_id,
659 p_local->local_chassis_id,
660 OSAL_ARRAY_SIZE(p_local->local_chassis_id));
661 OSAL_MEMCPY(params->lldp_local.local_port_id, p_local->local_port_id,
662 OSAL_ARRAY_SIZE(p_local->local_port_id));
666 ecore_dcbx_get_remote_lldp_params(struct ecore_hwfn *p_hwfn,
667 struct ecore_ptt *p_ptt,
668 struct ecore_dcbx_get *params)
670 struct lldp_status_params_s *p_remote;
672 p_remote = &p_hwfn->p_dcbx_info->lldp_remote[LLDP_NEAREST_BRIDGE];
674 OSAL_MEMCPY(params->lldp_remote.peer_chassis_id,
675 p_remote->peer_chassis_id,
676 OSAL_ARRAY_SIZE(p_remote->peer_chassis_id));
677 OSAL_MEMCPY(params->lldp_remote.peer_port_id, p_remote->peer_port_id,
678 OSAL_ARRAY_SIZE(p_remote->peer_port_id));
681 static enum _ecore_status_t
682 ecore_dcbx_get_params(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
683 struct ecore_dcbx_get *p_params,
684 enum ecore_mib_read_type type)
686 enum _ecore_status_t rc = ECORE_SUCCESS;
689 case ECORE_DCBX_REMOTE_MIB:
690 ecore_dcbx_get_remote_params(p_hwfn, p_ptt, p_params);
692 case ECORE_DCBX_LOCAL_MIB:
693 ecore_dcbx_get_local_params(p_hwfn, p_ptt, p_params);
695 case ECORE_DCBX_OPERATIONAL_MIB:
696 ecore_dcbx_get_operational_params(p_hwfn, p_ptt, p_params);
698 case ECORE_DCBX_REMOTE_LLDP_MIB:
699 ecore_dcbx_get_remote_lldp_params(p_hwfn, p_ptt, p_params);
701 case ECORE_DCBX_LOCAL_LLDP_MIB:
702 ecore_dcbx_get_local_lldp_params(p_hwfn, p_ptt, p_params);
705 DP_ERR(p_hwfn, "MIB read err, unknown mib type %d\n", type);
712 static enum _ecore_status_t
713 ecore_dcbx_read_local_lldp_mib(struct ecore_hwfn *p_hwfn,
714 struct ecore_ptt *p_ptt)
716 struct ecore_dcbx_mib_meta_data data;
717 enum _ecore_status_t rc = ECORE_SUCCESS;
719 OSAL_MEM_ZERO(&data, sizeof(data));
720 data.addr = p_hwfn->mcp_info->port_addr + offsetof(struct public_port,
722 data.lldp_local = p_hwfn->p_dcbx_info->lldp_local;
723 data.size = sizeof(struct lldp_config_params_s);
724 ecore_memcpy_from(p_hwfn, p_ptt, data.lldp_local, data.addr, data.size);
729 static enum _ecore_status_t
730 ecore_dcbx_read_remote_lldp_mib(struct ecore_hwfn *p_hwfn,
731 struct ecore_ptt *p_ptt,
732 enum ecore_mib_read_type type)
734 struct ecore_dcbx_mib_meta_data data;
735 enum _ecore_status_t rc = ECORE_SUCCESS;
737 OSAL_MEM_ZERO(&data, sizeof(data));
738 data.addr = p_hwfn->mcp_info->port_addr + offsetof(struct public_port,
740 data.lldp_remote = p_hwfn->p_dcbx_info->lldp_remote;
741 data.size = sizeof(struct lldp_status_params_s);
742 rc = ecore_dcbx_copy_mib(p_hwfn, p_ptt, &data, type);
747 static enum _ecore_status_t
748 ecore_dcbx_read_operational_mib(struct ecore_hwfn *p_hwfn,
749 struct ecore_ptt *p_ptt,
750 enum ecore_mib_read_type type)
752 struct ecore_dcbx_mib_meta_data data;
753 enum _ecore_status_t rc = ECORE_SUCCESS;
755 OSAL_MEM_ZERO(&data, sizeof(data));
756 data.addr = p_hwfn->mcp_info->port_addr +
757 offsetof(struct public_port, operational_dcbx_mib);
758 data.mib = &p_hwfn->p_dcbx_info->operational;
759 data.size = sizeof(struct dcbx_mib);
760 rc = ecore_dcbx_copy_mib(p_hwfn, p_ptt, &data, type);
765 static enum _ecore_status_t
766 ecore_dcbx_read_remote_mib(struct ecore_hwfn *p_hwfn,
767 struct ecore_ptt *p_ptt,
768 enum ecore_mib_read_type type)
770 struct ecore_dcbx_mib_meta_data data;
771 enum _ecore_status_t rc = ECORE_SUCCESS;
773 OSAL_MEM_ZERO(&data, sizeof(data));
774 data.addr = p_hwfn->mcp_info->port_addr +
775 offsetof(struct public_port, remote_dcbx_mib);
776 data.mib = &p_hwfn->p_dcbx_info->remote;
777 data.size = sizeof(struct dcbx_mib);
778 rc = ecore_dcbx_copy_mib(p_hwfn, p_ptt, &data, type);
783 static enum _ecore_status_t
784 ecore_dcbx_read_local_mib(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt)
786 struct ecore_dcbx_mib_meta_data data;
787 enum _ecore_status_t rc = ECORE_SUCCESS;
789 OSAL_MEM_ZERO(&data, sizeof(data));
790 data.addr = p_hwfn->mcp_info->port_addr +
791 offsetof(struct public_port, local_admin_dcbx_mib);
792 data.local_admin = &p_hwfn->p_dcbx_info->local_admin;
793 data.size = sizeof(struct dcbx_local_params);
794 ecore_memcpy_from(p_hwfn, p_ptt, data.local_admin,
795 data.addr, data.size);
801 ecore_dcbx_read_dscp_mib(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt)
803 struct ecore_dcbx_mib_meta_data data;
805 data.addr = p_hwfn->mcp_info->port_addr +
806 offsetof(struct public_port, dcb_dscp_map);
807 data.dscp_map = &p_hwfn->p_dcbx_info->dscp_map;
808 data.size = sizeof(struct dcb_dscp_map);
809 ecore_memcpy_from(p_hwfn, p_ptt, data.dscp_map, data.addr, data.size);
812 static enum _ecore_status_t ecore_dcbx_read_mib(struct ecore_hwfn *p_hwfn,
813 struct ecore_ptt *p_ptt,
814 enum ecore_mib_read_type type)
816 enum _ecore_status_t rc = ECORE_INVAL;
819 case ECORE_DCBX_OPERATIONAL_MIB:
820 ecore_dcbx_read_dscp_mib(p_hwfn, p_ptt);
821 rc = ecore_dcbx_read_operational_mib(p_hwfn, p_ptt, type);
823 case ECORE_DCBX_REMOTE_MIB:
824 rc = ecore_dcbx_read_remote_mib(p_hwfn, p_ptt, type);
826 case ECORE_DCBX_LOCAL_MIB:
827 rc = ecore_dcbx_read_local_mib(p_hwfn, p_ptt);
829 case ECORE_DCBX_REMOTE_LLDP_MIB:
830 rc = ecore_dcbx_read_remote_lldp_mib(p_hwfn, p_ptt, type);
832 case ECORE_DCBX_LOCAL_LLDP_MIB:
833 rc = ecore_dcbx_read_local_lldp_mib(p_hwfn, p_ptt);
836 DP_ERR(p_hwfn, "MIB read err, unknown mib type %d\n", type);
844 * Reconfigure QM and invoke PF update ramrod command if operational MIB
845 * change is detected.
848 ecore_dcbx_mib_update_event(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
849 enum ecore_mib_read_type type)
851 enum _ecore_status_t rc = ECORE_SUCCESS;
853 rc = ecore_dcbx_read_mib(p_hwfn, p_ptt, type);
857 if (type == ECORE_DCBX_OPERATIONAL_MIB) {
858 ecore_dcbx_get_dscp_params(p_hwfn, p_ptt,
859 &p_hwfn->p_dcbx_info->get);
861 rc = ecore_dcbx_process_mib_info(p_hwfn);
865 /* reconfigure tcs of QM queues according
866 * to negotiation results
868 ecore_qm_reconf(p_hwfn, p_ptt);
870 /* update storm FW with negotiation results */
871 ecore_sp_pf_update(p_hwfn);
873 /* set eagle enigne 1 flow control workaround
874 * according to negotiation results
876 enabled = p_hwfn->p_dcbx_info->results.dcbx_enabled;
879 ecore_dcbx_get_params(p_hwfn, p_ptt, &p_hwfn->p_dcbx_info->get, type);
881 /* Update the DSCP to TC mapping bit if required */
882 if ((type == ECORE_DCBX_OPERATIONAL_MIB) &&
883 p_hwfn->p_dcbx_info->dscp_nig_update) {
884 ecore_wr(p_hwfn, p_ptt, NIG_REG_DSCP_TO_TC_MAP_ENABLE, 0x1);
885 p_hwfn->p_dcbx_info->dscp_nig_update = false;
888 OSAL_DCBX_AEN(p_hwfn, type);
893 enum _ecore_status_t ecore_dcbx_info_alloc(struct ecore_hwfn *p_hwfn)
895 enum _ecore_status_t rc = ECORE_SUCCESS;
897 p_hwfn->p_dcbx_info = OSAL_ZALLOC(p_hwfn->p_dev, GFP_KERNEL,
898 sizeof(*p_hwfn->p_dcbx_info));
899 if (!p_hwfn->p_dcbx_info) {
900 DP_NOTICE(p_hwfn, true,
901 "Failed to allocate `struct ecore_dcbx_info'");
908 void ecore_dcbx_info_free(struct ecore_hwfn *p_hwfn,
909 struct ecore_dcbx_info *p_dcbx_info)
911 OSAL_FREE(p_hwfn->p_dev, p_hwfn->p_dcbx_info);
914 static void ecore_dcbx_update_protocol_data(struct protocol_dcb_data *p_data,
915 struct ecore_dcbx_results *p_src,
916 enum dcbx_protocol_type type)
918 p_data->dcb_enable_flag = p_src->arr[type].enable;
919 p_data->dcb_priority = p_src->arr[type].priority;
920 p_data->dcb_tc = p_src->arr[type].tc;
921 p_data->dscp_enable_flag = p_src->arr[type].dscp_enable;
922 p_data->dscp_val = p_src->arr[type].dscp_val;
925 /* Set pf update ramrod command params */
926 void ecore_dcbx_set_pf_update_params(struct ecore_dcbx_results *p_src,
927 struct pf_update_ramrod_data *p_dest)
929 struct protocol_dcb_data *p_dcb_data;
930 bool update_flag = false;
932 p_dest->pf_id = p_src->pf_id;
934 update_flag = p_src->arr[DCBX_PROTOCOL_ETH].update;
935 p_dest->update_eth_dcb_data_flag = update_flag;
937 p_dcb_data = &p_dest->eth_dcb_data;
938 ecore_dcbx_update_protocol_data(p_dcb_data, p_src, DCBX_PROTOCOL_ETH);
941 enum _ecore_status_t ecore_dcbx_query_params(struct ecore_hwfn *p_hwfn,
942 struct ecore_dcbx_get *p_get,
943 enum ecore_mib_read_type type)
945 struct ecore_ptt *p_ptt;
946 enum _ecore_status_t rc;
948 if (IS_VF(p_hwfn->p_dev))
951 p_ptt = ecore_ptt_acquire(p_hwfn);
954 DP_ERR(p_hwfn, "rc = %d\n", rc);
958 rc = ecore_dcbx_read_mib(p_hwfn, p_ptt, type);
959 if (rc != ECORE_SUCCESS)
962 rc = ecore_dcbx_get_params(p_hwfn, p_ptt, p_get, type);
965 ecore_ptt_release(p_hwfn, p_ptt);
970 ecore_dcbx_set_pfc_data(struct ecore_hwfn *p_hwfn,
971 u32 *pfc, struct ecore_dcbx_params *p_params)
976 if (p_params->pfc.willing)
977 *pfc |= DCBX_PFC_WILLING_MASK;
979 *pfc &= ~DCBX_PFC_WILLING_MASK;
981 if (p_params->pfc.enabled)
982 *pfc |= DCBX_PFC_ENABLED_MASK;
984 *pfc &= ~DCBX_PFC_ENABLED_MASK;
986 *pfc &= ~DCBX_PFC_CAPS_MASK;
987 *pfc |= (u32)p_params->pfc.max_tc << DCBX_PFC_CAPS_SHIFT;
989 for (i = 0; i < ECORE_MAX_PFC_PRIORITIES; i++)
990 if (p_params->pfc.prio[i])
992 *pfc &= ~DCBX_PFC_PRI_EN_BITMAP_MASK;
993 *pfc |= (pfc_map << DCBX_PFC_PRI_EN_BITMAP_SHIFT);
995 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB, "pfc = 0x%x\n", *pfc);
999 ecore_dcbx_set_ets_data(struct ecore_hwfn *p_hwfn,
1000 struct dcbx_ets_feature *p_ets,
1001 struct ecore_dcbx_params *p_params)
1003 u8 *bw_map, *tsa_map;
1007 if (p_params->ets_willing)
1008 p_ets->flags |= DCBX_ETS_WILLING_MASK;
1010 p_ets->flags &= ~DCBX_ETS_WILLING_MASK;
1012 if (p_params->ets_cbs)
1013 p_ets->flags |= DCBX_ETS_CBS_MASK;
1015 p_ets->flags &= ~DCBX_ETS_CBS_MASK;
1017 if (p_params->ets_enabled)
1018 p_ets->flags |= DCBX_ETS_ENABLED_MASK;
1020 p_ets->flags &= ~DCBX_ETS_ENABLED_MASK;
1022 p_ets->flags &= ~DCBX_ETS_MAX_TCS_MASK;
1023 p_ets->flags |= (u32)p_params->max_ets_tc << DCBX_ETS_MAX_TCS_SHIFT;
1025 bw_map = (u8 *)&p_ets->tc_bw_tbl[0];
1026 tsa_map = (u8 *)&p_ets->tc_tsa_tbl[0];
1027 p_ets->pri_tc_tbl[0] = 0;
1028 for (i = 0; i < ECORE_MAX_PFC_PRIORITIES; i++) {
1029 bw_map[i] = p_params->ets_tc_bw_tbl[i];
1030 tsa_map[i] = p_params->ets_tc_tsa_tbl[i];
1031 /* Copy the priority value to the corresponding 4 bits in the
1032 * traffic class table.
1034 val = (((u32)p_params->ets_pri_tc_tbl[i]) << ((7 - i) * 4));
1035 p_ets->pri_tc_tbl[0] |= val;
1037 for (i = 0; i < 2; i++) {
1038 p_ets->tc_bw_tbl[i] = OSAL_CPU_TO_BE32(p_ets->tc_bw_tbl[i]);
1039 p_ets->tc_tsa_tbl[i] = OSAL_CPU_TO_BE32(p_ets->tc_tsa_tbl[i]);
1044 ecore_dcbx_set_app_data(struct ecore_hwfn *p_hwfn,
1045 struct dcbx_app_priority_feature *p_app,
1046 struct ecore_dcbx_params *p_params, bool ieee)
1051 if (p_params->app_willing)
1052 p_app->flags |= DCBX_APP_WILLING_MASK;
1054 p_app->flags &= ~DCBX_APP_WILLING_MASK;
1056 if (p_params->app_valid)
1057 p_app->flags |= DCBX_APP_ENABLED_MASK;
1059 p_app->flags &= ~DCBX_APP_ENABLED_MASK;
1061 p_app->flags &= ~DCBX_APP_NUM_ENTRIES_MASK;
1062 p_app->flags |= (u32)p_params->num_app_entries <<
1063 DCBX_APP_NUM_ENTRIES_SHIFT;
1065 for (i = 0; i < DCBX_MAX_APP_PROTOCOL; i++) {
1066 entry = &p_app->app_pri_tbl[i].entry;
1069 *entry &= ~(DCBX_APP_SF_IEEE_MASK | DCBX_APP_SF_MASK);
1070 switch (p_params->app_entry[i].sf_ieee) {
1071 case ECORE_DCBX_SF_IEEE_ETHTYPE:
1072 *entry |= ((u32)DCBX_APP_SF_IEEE_ETHTYPE <<
1073 DCBX_APP_SF_IEEE_SHIFT);
1074 *entry |= ((u32)DCBX_APP_SF_ETHTYPE <<
1077 case ECORE_DCBX_SF_IEEE_TCP_PORT:
1078 *entry |= ((u32)DCBX_APP_SF_IEEE_TCP_PORT <<
1079 DCBX_APP_SF_IEEE_SHIFT);
1080 *entry |= ((u32)DCBX_APP_SF_PORT <<
1083 case ECORE_DCBX_SF_IEEE_UDP_PORT:
1084 *entry |= ((u32)DCBX_APP_SF_IEEE_UDP_PORT <<
1085 DCBX_APP_SF_IEEE_SHIFT);
1086 *entry |= ((u32)DCBX_APP_SF_PORT <<
1089 case ECORE_DCBX_SF_IEEE_TCP_UDP_PORT:
1090 *entry |= (u32)DCBX_APP_SF_IEEE_TCP_UDP_PORT <<
1091 DCBX_APP_SF_IEEE_SHIFT;
1092 *entry |= ((u32)DCBX_APP_SF_PORT <<
1097 *entry &= ~DCBX_APP_SF_MASK;
1098 if (p_params->app_entry[i].ethtype)
1099 *entry |= ((u32)DCBX_APP_SF_ETHTYPE <<
1102 *entry |= ((u32)DCBX_APP_SF_PORT <<
1105 *entry &= ~DCBX_APP_PROTOCOL_ID_MASK;
1106 *entry |= ((u32)p_params->app_entry[i].proto_id <<
1107 DCBX_APP_PROTOCOL_ID_SHIFT);
1108 *entry &= ~DCBX_APP_PRI_MAP_MASK;
1109 *entry |= ((u32)(p_params->app_entry[i].prio) <<
1110 DCBX_APP_PRI_MAP_SHIFT);
1114 static enum _ecore_status_t
1115 ecore_dcbx_set_local_params(struct ecore_hwfn *p_hwfn,
1116 struct dcbx_local_params *local_admin,
1117 struct ecore_dcbx_set *params)
1121 local_admin->flags = 0;
1122 OSAL_MEMCPY(&local_admin->features,
1123 &p_hwfn->p_dcbx_info->operational.features,
1124 sizeof(local_admin->features));
1126 if (params->enabled) {
1127 local_admin->config = params->ver_num;
1128 ieee = !!(params->ver_num & DCBX_CONFIG_VERSION_IEEE);
1130 local_admin->config = DCBX_CONFIG_VERSION_DISABLED;
1133 if (params->override_flags & ECORE_DCBX_OVERRIDE_PFC_CFG)
1134 ecore_dcbx_set_pfc_data(p_hwfn, &local_admin->features.pfc,
1135 ¶ms->config.params);
1137 if (params->override_flags & ECORE_DCBX_OVERRIDE_ETS_CFG)
1138 ecore_dcbx_set_ets_data(p_hwfn, &local_admin->features.ets,
1139 ¶ms->config.params);
1141 if (params->override_flags & ECORE_DCBX_OVERRIDE_APP_CFG)
1142 ecore_dcbx_set_app_data(p_hwfn, &local_admin->features.app,
1143 ¶ms->config.params, ieee);
1145 return ECORE_SUCCESS;
1148 static enum _ecore_status_t
1149 ecore_dcbx_set_dscp_params(struct ecore_hwfn *p_hwfn,
1150 struct dcb_dscp_map *p_dscp_map,
1151 struct ecore_dcbx_set *p_params)
1156 OSAL_MEMCPY(p_dscp_map, &p_hwfn->p_dcbx_info->dscp_map,
1157 sizeof(*p_dscp_map));
1159 p_dscp_map->flags &= ~DCB_DSCP_ENABLE_MASK;
1160 if (p_params->dscp.enabled)
1161 p_dscp_map->flags |= DCB_DSCP_ENABLE_MASK;
1163 for (i = 0, entry = 0; i < 8; i++) {
1165 for (j = 0; j < 8; j++, entry++)
1166 val |= (((u32)p_params->dscp.dscp_pri_map[entry]) <<
1169 p_dscp_map->dscp_pri_map[i] = OSAL_CPU_TO_BE32(val);
1172 p_hwfn->p_dcbx_info->dscp_nig_update = true;
1174 return ECORE_SUCCESS;
1177 enum _ecore_status_t ecore_dcbx_config_params(struct ecore_hwfn *p_hwfn,
1178 struct ecore_ptt *p_ptt,
1179 struct ecore_dcbx_set *params,
1182 struct dcbx_local_params local_admin;
1183 struct ecore_dcbx_mib_meta_data data;
1184 struct dcb_dscp_map dscp_map;
1185 u32 resp = 0, param = 0;
1186 enum _ecore_status_t rc = ECORE_SUCCESS;
1189 OSAL_MEMCPY(&p_hwfn->p_dcbx_info->set, params,
1190 sizeof(p_hwfn->p_dcbx_info->set));
1191 return ECORE_SUCCESS;
1194 /* clear set-parmas cache */
1195 OSAL_MEMSET(&p_hwfn->p_dcbx_info->set, 0,
1196 sizeof(struct ecore_dcbx_set));
1198 OSAL_MEMSET(&local_admin, 0, sizeof(local_admin));
1199 ecore_dcbx_set_local_params(p_hwfn, &local_admin, params);
1201 data.addr = p_hwfn->mcp_info->port_addr +
1202 offsetof(struct public_port, local_admin_dcbx_mib);
1203 data.local_admin = &local_admin;
1204 data.size = sizeof(struct dcbx_local_params);
1205 ecore_memcpy_to(p_hwfn, p_ptt, data.addr, data.local_admin, data.size);
1207 if (params->override_flags & ECORE_DCBX_OVERRIDE_DSCP_CFG) {
1208 OSAL_MEMSET(&dscp_map, 0, sizeof(dscp_map));
1209 ecore_dcbx_set_dscp_params(p_hwfn, &dscp_map, params);
1211 data.addr = p_hwfn->mcp_info->port_addr +
1212 offsetof(struct public_port, dcb_dscp_map);
1213 data.dscp_map = &dscp_map;
1214 data.size = sizeof(struct dcb_dscp_map);
1215 ecore_memcpy_to(p_hwfn, p_ptt, data.addr, data.dscp_map,
1219 rc = ecore_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_SET_DCBX,
1220 1 << DRV_MB_PARAM_LLDP_SEND_SHIFT, &resp, ¶m);
1221 if (rc != ECORE_SUCCESS) {
1222 DP_NOTICE(p_hwfn, false,
1223 "Failed to send DCBX update request\n");
1230 enum _ecore_status_t ecore_dcbx_get_config_params(struct ecore_hwfn *p_hwfn,
1231 struct ecore_dcbx_set *params)
1233 struct ecore_dcbx_get *dcbx_info;
1236 if (p_hwfn->p_dcbx_info->set.config.valid) {
1237 OSAL_MEMCPY(params, &p_hwfn->p_dcbx_info->set,
1238 sizeof(struct ecore_dcbx_set));
1239 return ECORE_SUCCESS;
1242 dcbx_info = OSAL_ALLOC(p_hwfn->p_dev, GFP_KERNEL,
1243 sizeof(*dcbx_info));
1245 DP_ERR(p_hwfn, "Failed to allocate struct ecore_dcbx_info\n");
1249 OSAL_MEMSET(dcbx_info, 0, sizeof(*dcbx_info));
1250 rc = ecore_dcbx_query_params(p_hwfn, dcbx_info,
1251 ECORE_DCBX_OPERATIONAL_MIB);
1253 OSAL_FREE(p_hwfn->p_dev, dcbx_info);
1256 p_hwfn->p_dcbx_info->set.override_flags = 0;
1258 p_hwfn->p_dcbx_info->set.ver_num = DCBX_CONFIG_VERSION_DISABLED;
1259 if (dcbx_info->operational.cee)
1260 p_hwfn->p_dcbx_info->set.ver_num |= DCBX_CONFIG_VERSION_CEE;
1261 if (dcbx_info->operational.ieee)
1262 p_hwfn->p_dcbx_info->set.ver_num |= DCBX_CONFIG_VERSION_IEEE;
1263 if (dcbx_info->operational.local)
1264 p_hwfn->p_dcbx_info->set.ver_num |= DCBX_CONFIG_VERSION_STATIC;
1266 p_hwfn->p_dcbx_info->set.enabled = dcbx_info->operational.enabled;
1267 OSAL_MEMCPY(&p_hwfn->p_dcbx_info->set.config.params,
1268 &dcbx_info->operational.params,
1269 sizeof(struct ecore_dcbx_admin_params));
1270 p_hwfn->p_dcbx_info->set.config.valid = true;
1272 OSAL_MEMCPY(params, &p_hwfn->p_dcbx_info->set,
1273 sizeof(struct ecore_dcbx_set));
1275 OSAL_FREE(p_hwfn->p_dev, dcbx_info);
1277 return ECORE_SUCCESS;