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, 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, 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,
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,
231 "Num APP entries = %d pri_tc_tbl = 0x%x dcbx_version = %u\n",
232 count, pri_tc_tbl, dcbx_version);
234 ieee = (dcbx_version == DCBX_CONFIG_VERSION_IEEE);
236 for (i = 0; i < count; i++) {
237 protocol_id = ECORE_MFW_GET_FIELD(p_tbl[i].entry,
238 DCBX_APP_PROTOCOL_ID);
239 priority_map = ECORE_MFW_GET_FIELD(p_tbl[i].entry,
241 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB, "Id = 0x%x pri_map = %u\n",
242 protocol_id, priority_map);
243 rc = ecore_dcbx_get_app_priority(priority_map, &priority);
244 if (rc == ECORE_INVAL) {
245 DP_ERR(p_hwfn, "Invalid priority\n");
249 tc = ECORE_DCBX_PRIO2TC(pri_tc_tbl, priority);
250 if (ecore_dcbx_get_app_protocol_type(p_hwfn, p_tbl[i].entry,
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.
259 enable = !(type == DCBX_PROTOCOL_ETH);
261 ecore_dcbx_update_app_info(p_data, p_hwfn, enable,
265 /* Update ramrod protocol data and hw_info fields
266 * with default info when corresponding APP TLV's are not detected.
267 * The enabled field has a different logic for ethernet as only for
268 * ethernet dcb should disabled by default, as the information arrives
269 * from the OS (unless an explicit app tlv was present).
271 tc = p_data->arr[DCBX_PROTOCOL_ETH].tc;
272 priority = p_data->arr[DCBX_PROTOCOL_ETH].priority;
273 for (type = 0; type < DCBX_MAX_PROTOCOL_TYPE; type++) {
274 if (p_data->arr[type].update)
277 enable = (type == DCBX_PROTOCOL_ETH) ? false : !!dcbx_version;
278 ecore_dcbx_update_app_info(p_data, p_hwfn, enable,
282 return ECORE_SUCCESS;
285 /* Parse app TLV's to update TC information in hw_info structure for
286 * reconfiguring QM. Get protocol specific data for PF update ramrod command.
288 static enum _ecore_status_t
289 ecore_dcbx_process_mib_info(struct ecore_hwfn *p_hwfn)
291 struct dcbx_app_priority_feature *p_app;
292 enum _ecore_status_t rc = ECORE_SUCCESS;
293 struct ecore_dcbx_results data = { 0 };
294 struct dcbx_app_priority_entry *p_tbl;
295 struct dcbx_ets_feature *p_ets;
296 struct ecore_hw_info *p_info;
297 u32 pri_tc_tbl, flags;
301 flags = p_hwfn->p_dcbx_info->operational.flags;
302 dcbx_version = ECORE_MFW_GET_FIELD(flags, DCBX_CONFIG_VERSION);
304 p_app = &p_hwfn->p_dcbx_info->operational.features.app;
305 p_tbl = p_app->app_pri_tbl;
307 p_ets = &p_hwfn->p_dcbx_info->operational.features.ets;
308 pri_tc_tbl = p_ets->pri_tc_tbl[0];
310 p_info = &p_hwfn->hw_info;
311 num_entries = ECORE_MFW_GET_FIELD(p_app->flags, DCBX_APP_NUM_ENTRIES);
313 rc = ecore_dcbx_process_tlv(p_hwfn, &data, p_tbl, pri_tc_tbl,
314 num_entries, dcbx_version);
315 if (rc != ECORE_SUCCESS)
318 p_info->num_active_tc = ECORE_MFW_GET_FIELD(p_ets->flags,
320 data.pf_id = p_hwfn->rel_pf_id;
321 data.dcbx_enabled = !!dcbx_version;
323 ecore_dcbx_dp_protocol(p_hwfn, &data);
325 OSAL_MEMCPY(&p_hwfn->p_dcbx_info->results, &data,
326 sizeof(struct ecore_dcbx_results));
328 return ECORE_SUCCESS;
331 static enum _ecore_status_t
332 ecore_dcbx_copy_mib(struct ecore_hwfn *p_hwfn,
333 struct ecore_ptt *p_ptt,
334 struct ecore_dcbx_mib_meta_data *p_data,
335 enum ecore_mib_read_type type)
337 enum _ecore_status_t rc = ECORE_SUCCESS;
338 u32 prefix_seq_num, suffix_seq_num;
341 /* The data is considered to be valid only if both sequence numbers are
345 if (type == ECORE_DCBX_REMOTE_LLDP_MIB) {
346 ecore_memcpy_from(p_hwfn, p_ptt, p_data->lldp_remote,
347 p_data->addr, p_data->size);
348 prefix_seq_num = p_data->lldp_remote->prefix_seq_num;
349 suffix_seq_num = p_data->lldp_remote->suffix_seq_num;
351 ecore_memcpy_from(p_hwfn, p_ptt, p_data->mib,
352 p_data->addr, p_data->size);
353 prefix_seq_num = p_data->mib->prefix_seq_num;
354 suffix_seq_num = p_data->mib->suffix_seq_num;
358 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
359 "mib type = %d, try count = %d prefix seq num ="
360 " %d suffix seq num = %d\n",
361 type, read_count, prefix_seq_num, suffix_seq_num);
362 } while ((prefix_seq_num != suffix_seq_num) &&
363 (read_count < ECORE_DCBX_MAX_MIB_READ_TRY));
365 if (read_count >= ECORE_DCBX_MAX_MIB_READ_TRY) {
367 "MIB read err, mib type = %d, try count ="
368 " %d prefix seq num = %d suffix seq num = %d\n",
369 type, read_count, prefix_seq_num, suffix_seq_num);
377 ecore_dcbx_get_priority_info(struct ecore_hwfn *p_hwfn,
378 struct ecore_dcbx_app_prio *p_prio,
379 struct ecore_dcbx_results *p_results)
383 if (p_results->arr[DCBX_PROTOCOL_ETH].update &&
384 p_results->arr[DCBX_PROTOCOL_ETH].enable)
385 p_prio->eth = p_results->arr[DCBX_PROTOCOL_ETH].priority;
387 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
388 "Priorities: eth %d\n",
393 ecore_dcbx_get_app_data(struct ecore_hwfn *p_hwfn,
394 struct dcbx_app_priority_feature *p_app,
395 struct dcbx_app_priority_entry *p_tbl,
396 struct ecore_dcbx_params *p_params, bool ieee)
398 struct ecore_app_entry *entry;
402 p_params->app_willing = ECORE_MFW_GET_FIELD(p_app->flags,
404 p_params->app_valid = ECORE_MFW_GET_FIELD(p_app->flags,
406 p_params->app_error = ECORE_MFW_GET_FIELD(p_app->flags, DCBX_APP_ERROR);
407 p_params->num_app_entries = ECORE_MFW_GET_FIELD(p_app->flags,
408 DCBX_APP_NUM_ENTRIES);
409 for (i = 0; i < DCBX_MAX_APP_PROTOCOL; i++) {
410 entry = &p_params->app_entry[i];
415 sf_ieee = ECORE_MFW_GET_FIELD(p_tbl[i].entry,
418 case DCBX_APP_SF_IEEE_RESERVED:
420 val = ECORE_MFW_GET_FIELD(p_tbl[i].entry,
422 entry->sf_ieee = val ?
423 ECORE_DCBX_SF_IEEE_TCP_UDP_PORT :
424 ECORE_DCBX_SF_IEEE_ETHTYPE;
426 case DCBX_APP_SF_IEEE_ETHTYPE:
427 entry->sf_ieee = ECORE_DCBX_SF_IEEE_ETHTYPE;
429 case DCBX_APP_SF_IEEE_TCP_PORT:
430 entry->sf_ieee = ECORE_DCBX_SF_IEEE_TCP_PORT;
432 case DCBX_APP_SF_IEEE_UDP_PORT:
433 entry->sf_ieee = ECORE_DCBX_SF_IEEE_UDP_PORT;
435 case DCBX_APP_SF_IEEE_TCP_UDP_PORT:
437 ECORE_DCBX_SF_IEEE_TCP_UDP_PORT;
441 entry->ethtype = !(ECORE_MFW_GET_FIELD(p_tbl[i].entry,
445 pri_map = ECORE_MFW_GET_FIELD(p_tbl[i].entry, DCBX_APP_PRI_MAP);
446 ecore_dcbx_get_app_priority(pri_map, &entry->prio);
447 entry->proto_id = ECORE_MFW_GET_FIELD(p_tbl[i].entry,
448 DCBX_APP_PROTOCOL_ID);
449 ecore_dcbx_get_app_protocol_type(p_hwfn, p_tbl[i].entry,
451 &entry->proto_type, ieee);
454 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
455 "APP params: willing %d, valid %d error = %d\n",
456 p_params->app_willing, p_params->app_valid,
457 p_params->app_error);
461 ecore_dcbx_get_pfc_data(struct ecore_hwfn *p_hwfn,
462 u32 pfc, struct ecore_dcbx_params *p_params)
466 p_params->pfc.willing = ECORE_MFW_GET_FIELD(pfc, DCBX_PFC_WILLING);
467 p_params->pfc.max_tc = ECORE_MFW_GET_FIELD(pfc, DCBX_PFC_CAPS);
468 p_params->pfc.enabled = ECORE_MFW_GET_FIELD(pfc, DCBX_PFC_ENABLED);
469 pfc_map = ECORE_MFW_GET_FIELD(pfc, DCBX_PFC_PRI_EN_BITMAP);
470 p_params->pfc.prio[0] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_0);
471 p_params->pfc.prio[1] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_1);
472 p_params->pfc.prio[2] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_2);
473 p_params->pfc.prio[3] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_3);
474 p_params->pfc.prio[4] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_4);
475 p_params->pfc.prio[5] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_5);
476 p_params->pfc.prio[6] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_6);
477 p_params->pfc.prio[7] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_7);
479 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
480 "PFC params: willing %d, pfc_bitmap %u max_tc = %u enabled = %d\n",
481 p_params->pfc.willing, pfc_map, p_params->pfc.max_tc,
482 p_params->pfc.enabled);
486 ecore_dcbx_get_ets_data(struct ecore_hwfn *p_hwfn,
487 struct dcbx_ets_feature *p_ets,
488 struct ecore_dcbx_params *p_params)
490 u32 bw_map[2], tsa_map[2], pri_map;
493 p_params->ets_willing = ECORE_MFW_GET_FIELD(p_ets->flags,
495 p_params->ets_enabled = ECORE_MFW_GET_FIELD(p_ets->flags,
497 p_params->ets_cbs = ECORE_MFW_GET_FIELD(p_ets->flags, DCBX_ETS_CBS);
498 p_params->max_ets_tc = ECORE_MFW_GET_FIELD(p_ets->flags,
500 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
501 "ETS params: willing %d, enabled = %d ets_cbs %d pri_tc_tbl_0 %x max_ets_tc %d\n",
502 p_params->ets_willing, p_params->ets_enabled,
503 p_params->ets_cbs, p_ets->pri_tc_tbl[0],
504 p_params->max_ets_tc);
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.
509 bw_map[0] = OSAL_BE32_TO_CPU(p_ets->tc_bw_tbl[0]);
510 bw_map[1] = OSAL_BE32_TO_CPU(p_ets->tc_bw_tbl[1]);
511 tsa_map[0] = OSAL_BE32_TO_CPU(p_ets->tc_tsa_tbl[0]);
512 tsa_map[1] = OSAL_BE32_TO_CPU(p_ets->tc_tsa_tbl[1]);
513 pri_map = p_ets->pri_tc_tbl[0];
514 for (i = 0; i < ECORE_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] = ECORE_DCBX_PRIO2TC(pri_map, i);
518 DP_VERBOSE(p_hwfn, ECORE_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]);
526 ecore_dcbx_get_common_params(struct ecore_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 ecore_dcbx_params *p_params,
533 ecore_dcbx_get_app_data(p_hwfn, p_app, p_tbl, p_params, ieee);
534 ecore_dcbx_get_ets_data(p_hwfn, p_ets, p_params);
535 ecore_dcbx_get_pfc_data(p_hwfn, pfc, p_params);
539 ecore_dcbx_get_local_params(struct ecore_hwfn *p_hwfn,
540 struct ecore_ptt *p_ptt,
541 struct ecore_dcbx_get *params)
543 struct dcbx_features *p_feat;
545 p_feat = &p_hwfn->p_dcbx_info->local_admin.features;
546 ecore_dcbx_get_common_params(p_hwfn, &p_feat->app,
547 p_feat->app.app_pri_tbl, &p_feat->ets,
548 p_feat->pfc, ¶ms->local.params, false);
549 params->local.valid = true;
553 ecore_dcbx_get_remote_params(struct ecore_hwfn *p_hwfn,
554 struct ecore_ptt *p_ptt,
555 struct ecore_dcbx_get *params)
557 struct dcbx_features *p_feat;
559 p_feat = &p_hwfn->p_dcbx_info->remote.features;
560 ecore_dcbx_get_common_params(p_hwfn, &p_feat->app,
561 p_feat->app.app_pri_tbl, &p_feat->ets,
562 p_feat->pfc, ¶ms->remote.params,
564 params->remote.valid = true;
567 static enum _ecore_status_t
568 ecore_dcbx_get_operational_params(struct ecore_hwfn *p_hwfn,
569 struct ecore_ptt *p_ptt,
570 struct ecore_dcbx_get *params)
572 struct ecore_dcbx_operational_params *p_operational;
573 struct ecore_dcbx_results *p_results;
574 struct dcbx_features *p_feat;
579 flags = p_hwfn->p_dcbx_info->operational.flags;
581 /* If DCBx version is non zero, then negotiation
582 * was successfuly performed
584 p_operational = ¶ms->operational;
585 enabled = !!(ECORE_MFW_GET_FIELD(flags, DCBX_CONFIG_VERSION) !=
586 DCBX_CONFIG_VERSION_DISABLED);
588 p_operational->enabled = enabled;
589 p_operational->valid = false;
590 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB, "Dcbx is disabled\n");
594 p_feat = &p_hwfn->p_dcbx_info->operational.features;
595 p_results = &p_hwfn->p_dcbx_info->results;
597 val = !!(ECORE_MFW_GET_FIELD(flags, DCBX_CONFIG_VERSION) ==
598 DCBX_CONFIG_VERSION_IEEE);
599 p_operational->ieee = val;
601 val = !!(ECORE_MFW_GET_FIELD(flags, DCBX_CONFIG_VERSION) ==
602 DCBX_CONFIG_VERSION_CEE);
603 p_operational->cee = val;
605 val = !!(ECORE_MFW_GET_FIELD(flags, DCBX_CONFIG_VERSION) ==
606 DCBX_CONFIG_VERSION_STATIC);
607 p_operational->local = val;
609 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
610 "Version support: ieee %d, cee %d, static %d\n",
611 p_operational->ieee, p_operational->cee,
612 p_operational->local);
614 ecore_dcbx_get_common_params(p_hwfn, &p_feat->app,
615 p_feat->app.app_pri_tbl, &p_feat->ets,
616 p_feat->pfc, ¶ms->operational.params,
617 p_operational->ieee);
618 ecore_dcbx_get_priority_info(p_hwfn, &p_operational->app_prio,
620 err = ECORE_MFW_GET_FIELD(p_feat->app.flags, DCBX_APP_ERROR);
621 p_operational->err = err;
622 p_operational->enabled = enabled;
623 p_operational->valid = true;
625 return ECORE_SUCCESS;
629 ecore_dcbx_get_dscp_params(struct ecore_hwfn *p_hwfn,
630 struct ecore_ptt *p_ptt,
631 struct ecore_dcbx_get *params)
633 struct ecore_dcbx_dscp_params *p_dscp;
634 struct dcb_dscp_map *p_dscp_map;
638 p_dscp = ¶ms->dscp;
639 p_dscp_map = &p_hwfn->p_dcbx_info->dscp_map;
640 p_dscp->enabled = ECORE_MFW_GET_FIELD(p_dscp_map->flags,
642 /* MFW encodes 64 dscp entries into 8 element array of u32 entries,
643 * where each entry holds the 4bit priority map for 8 dscp entries.
645 for (i = 0, entry = 0; i < ECORE_DCBX_DSCP_SIZE / 8; i++) {
646 pri_map = OSAL_BE32_TO_CPU(p_dscp_map->dscp_pri_map[i]);
647 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB, "elem %d pri_map 0x%x\n",
649 for (j = 0; j < ECORE_DCBX_DSCP_SIZE / 8; j++, entry++)
650 p_dscp->dscp_pri_map[entry] = (u32)(pri_map >>
656 ecore_dcbx_get_local_lldp_params(struct ecore_hwfn *p_hwfn,
657 struct ecore_ptt *p_ptt,
658 struct ecore_dcbx_get *params)
660 struct lldp_config_params_s *p_local;
662 p_local = &p_hwfn->p_dcbx_info->lldp_local[LLDP_NEAREST_BRIDGE];
664 OSAL_MEMCPY(params->lldp_local.local_chassis_id,
665 p_local->local_chassis_id,
666 OSAL_ARRAY_SIZE(p_local->local_chassis_id));
667 OSAL_MEMCPY(params->lldp_local.local_port_id, p_local->local_port_id,
668 OSAL_ARRAY_SIZE(p_local->local_port_id));
672 ecore_dcbx_get_remote_lldp_params(struct ecore_hwfn *p_hwfn,
673 struct ecore_ptt *p_ptt,
674 struct ecore_dcbx_get *params)
676 struct lldp_status_params_s *p_remote;
678 p_remote = &p_hwfn->p_dcbx_info->lldp_remote[LLDP_NEAREST_BRIDGE];
680 OSAL_MEMCPY(params->lldp_remote.peer_chassis_id,
681 p_remote->peer_chassis_id,
682 OSAL_ARRAY_SIZE(p_remote->peer_chassis_id));
683 OSAL_MEMCPY(params->lldp_remote.peer_port_id, p_remote->peer_port_id,
684 OSAL_ARRAY_SIZE(p_remote->peer_port_id));
687 static enum _ecore_status_t
688 ecore_dcbx_get_params(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
689 struct ecore_dcbx_get *p_params,
690 enum ecore_mib_read_type type)
692 enum _ecore_status_t rc = ECORE_SUCCESS;
695 case ECORE_DCBX_REMOTE_MIB:
696 ecore_dcbx_get_remote_params(p_hwfn, p_ptt, p_params);
698 case ECORE_DCBX_LOCAL_MIB:
699 ecore_dcbx_get_local_params(p_hwfn, p_ptt, p_params);
701 case ECORE_DCBX_OPERATIONAL_MIB:
702 ecore_dcbx_get_operational_params(p_hwfn, p_ptt, p_params);
704 case ECORE_DCBX_REMOTE_LLDP_MIB:
705 ecore_dcbx_get_remote_lldp_params(p_hwfn, p_ptt, p_params);
707 case ECORE_DCBX_LOCAL_LLDP_MIB:
708 ecore_dcbx_get_local_lldp_params(p_hwfn, p_ptt, p_params);
711 DP_ERR(p_hwfn, "MIB read err, unknown mib type %d\n", type);
718 static enum _ecore_status_t
719 ecore_dcbx_read_local_lldp_mib(struct ecore_hwfn *p_hwfn,
720 struct ecore_ptt *p_ptt)
722 struct ecore_dcbx_mib_meta_data data;
723 enum _ecore_status_t rc = ECORE_SUCCESS;
725 OSAL_MEM_ZERO(&data, sizeof(data));
726 data.addr = p_hwfn->mcp_info->port_addr + offsetof(struct public_port,
728 data.lldp_local = p_hwfn->p_dcbx_info->lldp_local;
729 data.size = sizeof(struct lldp_config_params_s);
730 ecore_memcpy_from(p_hwfn, p_ptt, data.lldp_local, data.addr, data.size);
735 static enum _ecore_status_t
736 ecore_dcbx_read_remote_lldp_mib(struct ecore_hwfn *p_hwfn,
737 struct ecore_ptt *p_ptt,
738 enum ecore_mib_read_type type)
740 struct ecore_dcbx_mib_meta_data data;
741 enum _ecore_status_t rc = ECORE_SUCCESS;
743 OSAL_MEM_ZERO(&data, sizeof(data));
744 data.addr = p_hwfn->mcp_info->port_addr + offsetof(struct public_port,
746 data.lldp_remote = p_hwfn->p_dcbx_info->lldp_remote;
747 data.size = sizeof(struct lldp_status_params_s);
748 rc = ecore_dcbx_copy_mib(p_hwfn, p_ptt, &data, type);
753 static enum _ecore_status_t
754 ecore_dcbx_read_operational_mib(struct ecore_hwfn *p_hwfn,
755 struct ecore_ptt *p_ptt,
756 enum ecore_mib_read_type type)
758 struct ecore_dcbx_mib_meta_data data;
759 enum _ecore_status_t rc = ECORE_SUCCESS;
761 OSAL_MEM_ZERO(&data, sizeof(data));
762 data.addr = p_hwfn->mcp_info->port_addr +
763 offsetof(struct public_port, operational_dcbx_mib);
764 data.mib = &p_hwfn->p_dcbx_info->operational;
765 data.size = sizeof(struct dcbx_mib);
766 rc = ecore_dcbx_copy_mib(p_hwfn, p_ptt, &data, type);
771 static enum _ecore_status_t
772 ecore_dcbx_read_remote_mib(struct ecore_hwfn *p_hwfn,
773 struct ecore_ptt *p_ptt,
774 enum ecore_mib_read_type type)
776 struct ecore_dcbx_mib_meta_data data;
777 enum _ecore_status_t rc = ECORE_SUCCESS;
779 OSAL_MEM_ZERO(&data, sizeof(data));
780 data.addr = p_hwfn->mcp_info->port_addr +
781 offsetof(struct public_port, remote_dcbx_mib);
782 data.mib = &p_hwfn->p_dcbx_info->remote;
783 data.size = sizeof(struct dcbx_mib);
784 rc = ecore_dcbx_copy_mib(p_hwfn, p_ptt, &data, type);
789 static enum _ecore_status_t
790 ecore_dcbx_read_local_mib(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt)
792 struct ecore_dcbx_mib_meta_data data;
793 enum _ecore_status_t rc = ECORE_SUCCESS;
795 OSAL_MEM_ZERO(&data, sizeof(data));
796 data.addr = p_hwfn->mcp_info->port_addr +
797 offsetof(struct public_port, local_admin_dcbx_mib);
798 data.local_admin = &p_hwfn->p_dcbx_info->local_admin;
799 data.size = sizeof(struct dcbx_local_params);
800 ecore_memcpy_from(p_hwfn, p_ptt, data.local_admin,
801 data.addr, data.size);
807 ecore_dcbx_read_dscp_mib(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt)
809 struct ecore_dcbx_mib_meta_data data;
811 data.addr = p_hwfn->mcp_info->port_addr +
812 offsetof(struct public_port, dcb_dscp_map);
813 data.dscp_map = &p_hwfn->p_dcbx_info->dscp_map;
814 data.size = sizeof(struct dcb_dscp_map);
815 ecore_memcpy_from(p_hwfn, p_ptt, data.dscp_map, data.addr, data.size);
818 static enum _ecore_status_t ecore_dcbx_read_mib(struct ecore_hwfn *p_hwfn,
819 struct ecore_ptt *p_ptt,
820 enum ecore_mib_read_type type)
822 enum _ecore_status_t rc = ECORE_INVAL;
825 case ECORE_DCBX_OPERATIONAL_MIB:
826 ecore_dcbx_read_dscp_mib(p_hwfn, p_ptt);
827 rc = ecore_dcbx_read_operational_mib(p_hwfn, p_ptt, type);
829 case ECORE_DCBX_REMOTE_MIB:
830 rc = ecore_dcbx_read_remote_mib(p_hwfn, p_ptt, type);
832 case ECORE_DCBX_LOCAL_MIB:
833 rc = ecore_dcbx_read_local_mib(p_hwfn, p_ptt);
835 case ECORE_DCBX_REMOTE_LLDP_MIB:
836 rc = ecore_dcbx_read_remote_lldp_mib(p_hwfn, p_ptt, type);
838 case ECORE_DCBX_LOCAL_LLDP_MIB:
839 rc = ecore_dcbx_read_local_lldp_mib(p_hwfn, p_ptt);
842 DP_ERR(p_hwfn, "MIB read err, unknown mib type %d\n", type);
850 * Reconfigure QM and invoke PF update ramrod command if operational MIB
851 * change is detected.
854 ecore_dcbx_mib_update_event(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
855 enum ecore_mib_read_type type)
857 enum _ecore_status_t rc = ECORE_SUCCESS;
859 rc = ecore_dcbx_read_mib(p_hwfn, p_ptt, type);
863 if (type == ECORE_DCBX_OPERATIONAL_MIB) {
864 ecore_dcbx_get_dscp_params(p_hwfn, p_ptt,
865 &p_hwfn->p_dcbx_info->get);
867 rc = ecore_dcbx_process_mib_info(p_hwfn);
871 /* reconfigure tcs of QM queues according
872 * to negotiation results
874 ecore_qm_reconf(p_hwfn, p_ptt);
876 /* update storm FW with negotiation results */
877 ecore_sp_pf_update(p_hwfn);
879 /* set eagle enigne 1 flow control workaround
880 * according to negotiation results
882 enabled = p_hwfn->p_dcbx_info->results.dcbx_enabled;
885 ecore_dcbx_get_params(p_hwfn, p_ptt, &p_hwfn->p_dcbx_info->get, type);
887 /* Update the DSCP to TC mapping bit if required */
888 if ((type == ECORE_DCBX_OPERATIONAL_MIB) &&
889 p_hwfn->p_dcbx_info->dscp_nig_update) {
890 ecore_wr(p_hwfn, p_ptt, NIG_REG_DSCP_TO_TC_MAP_ENABLE, 0x1);
891 p_hwfn->p_dcbx_info->dscp_nig_update = false;
894 OSAL_DCBX_AEN(p_hwfn, type);
899 enum _ecore_status_t ecore_dcbx_info_alloc(struct ecore_hwfn *p_hwfn)
901 enum _ecore_status_t rc = ECORE_SUCCESS;
903 p_hwfn->p_dcbx_info = OSAL_ZALLOC(p_hwfn->p_dev, GFP_KERNEL,
904 sizeof(*p_hwfn->p_dcbx_info));
905 if (!p_hwfn->p_dcbx_info) {
906 DP_NOTICE(p_hwfn, true,
907 "Failed to allocate `struct ecore_dcbx_info'");
914 void ecore_dcbx_info_free(struct ecore_hwfn *p_hwfn,
915 struct ecore_dcbx_info *p_dcbx_info)
917 OSAL_FREE(p_hwfn->p_dev, p_hwfn->p_dcbx_info);
920 static void ecore_dcbx_update_protocol_data(struct protocol_dcb_data *p_data,
921 struct ecore_dcbx_results *p_src,
922 enum dcbx_protocol_type type)
924 p_data->dcb_enable_flag = p_src->arr[type].enable;
925 p_data->dcb_priority = p_src->arr[type].priority;
926 p_data->dcb_tc = p_src->arr[type].tc;
927 p_data->dscp_enable_flag = p_src->arr[type].dscp_enable;
928 p_data->dscp_val = p_src->arr[type].dscp_val;
931 /* Set pf update ramrod command params */
932 void ecore_dcbx_set_pf_update_params(struct ecore_dcbx_results *p_src,
933 struct pf_update_ramrod_data *p_dest)
935 struct protocol_dcb_data *p_dcb_data;
938 p_dest->pf_id = p_src->pf_id;
940 update_flag = p_src->arr[DCBX_PROTOCOL_ETH].update;
941 p_dest->update_eth_dcb_data_flag = update_flag;
943 p_dcb_data = &p_dest->eth_dcb_data;
944 ecore_dcbx_update_protocol_data(p_dcb_data, p_src, DCBX_PROTOCOL_ETH);
947 enum _ecore_status_t ecore_dcbx_query_params(struct ecore_hwfn *p_hwfn,
948 struct ecore_dcbx_get *p_get,
949 enum ecore_mib_read_type type)
951 struct ecore_ptt *p_ptt;
952 enum _ecore_status_t rc;
954 if (IS_VF(p_hwfn->p_dev))
957 p_ptt = ecore_ptt_acquire(p_hwfn);
960 DP_ERR(p_hwfn, "rc = %d\n", rc);
964 rc = ecore_dcbx_read_mib(p_hwfn, p_ptt, type);
965 if (rc != ECORE_SUCCESS)
968 rc = ecore_dcbx_get_params(p_hwfn, p_ptt, p_get, type);
971 ecore_ptt_release(p_hwfn, p_ptt);
976 ecore_dcbx_set_pfc_data(struct ecore_hwfn *p_hwfn,
977 u32 *pfc, struct ecore_dcbx_params *p_params)
982 if (p_params->pfc.willing)
983 *pfc |= DCBX_PFC_WILLING_MASK;
985 *pfc &= ~DCBX_PFC_WILLING_MASK;
987 if (p_params->pfc.enabled)
988 *pfc |= DCBX_PFC_ENABLED_MASK;
990 *pfc &= ~DCBX_PFC_ENABLED_MASK;
992 *pfc &= ~DCBX_PFC_CAPS_MASK;
993 *pfc |= (u32)p_params->pfc.max_tc << DCBX_PFC_CAPS_SHIFT;
995 for (i = 0; i < ECORE_MAX_PFC_PRIORITIES; i++)
996 if (p_params->pfc.prio[i])
998 *pfc &= ~DCBX_PFC_PRI_EN_BITMAP_MASK;
999 *pfc |= (pfc_map << DCBX_PFC_PRI_EN_BITMAP_SHIFT);
1001 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB, "pfc = 0x%x\n", *pfc);
1005 ecore_dcbx_set_ets_data(struct ecore_hwfn *p_hwfn,
1006 struct dcbx_ets_feature *p_ets,
1007 struct ecore_dcbx_params *p_params)
1009 u8 *bw_map, *tsa_map;
1013 if (p_params->ets_willing)
1014 p_ets->flags |= DCBX_ETS_WILLING_MASK;
1016 p_ets->flags &= ~DCBX_ETS_WILLING_MASK;
1018 if (p_params->ets_cbs)
1019 p_ets->flags |= DCBX_ETS_CBS_MASK;
1021 p_ets->flags &= ~DCBX_ETS_CBS_MASK;
1023 if (p_params->ets_enabled)
1024 p_ets->flags |= DCBX_ETS_ENABLED_MASK;
1026 p_ets->flags &= ~DCBX_ETS_ENABLED_MASK;
1028 p_ets->flags &= ~DCBX_ETS_MAX_TCS_MASK;
1029 p_ets->flags |= (u32)p_params->max_ets_tc << DCBX_ETS_MAX_TCS_SHIFT;
1031 bw_map = (u8 *)&p_ets->tc_bw_tbl[0];
1032 tsa_map = (u8 *)&p_ets->tc_tsa_tbl[0];
1033 p_ets->pri_tc_tbl[0] = 0;
1034 for (i = 0; i < ECORE_MAX_PFC_PRIORITIES; i++) {
1035 bw_map[i] = p_params->ets_tc_bw_tbl[i];
1036 tsa_map[i] = p_params->ets_tc_tsa_tbl[i];
1037 /* Copy the priority value to the corresponding 4 bits in the
1038 * traffic class table.
1040 val = (((u32)p_params->ets_pri_tc_tbl[i]) << ((7 - i) * 4));
1041 p_ets->pri_tc_tbl[0] |= val;
1043 for (i = 0; i < 2; i++) {
1044 p_ets->tc_bw_tbl[i] = OSAL_CPU_TO_BE32(p_ets->tc_bw_tbl[i]);
1045 p_ets->tc_tsa_tbl[i] = OSAL_CPU_TO_BE32(p_ets->tc_tsa_tbl[i]);
1048 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
1049 "flags = 0x%x pri_tc = 0x%x tc_bwl[] = {0x%x, 0x%x} tc_tsa = {0x%x, 0x%x}\n",
1050 p_ets->flags, p_ets->pri_tc_tbl[0], p_ets->tc_bw_tbl[0],
1051 p_ets->tc_bw_tbl[1], p_ets->tc_tsa_tbl[0],
1052 p_ets->tc_tsa_tbl[1]);
1056 ecore_dcbx_set_app_data(struct ecore_hwfn *p_hwfn,
1057 struct dcbx_app_priority_feature *p_app,
1058 struct ecore_dcbx_params *p_params, bool ieee)
1063 if (p_params->app_willing)
1064 p_app->flags |= DCBX_APP_WILLING_MASK;
1066 p_app->flags &= ~DCBX_APP_WILLING_MASK;
1068 if (p_params->app_valid)
1069 p_app->flags |= DCBX_APP_ENABLED_MASK;
1071 p_app->flags &= ~DCBX_APP_ENABLED_MASK;
1073 p_app->flags &= ~DCBX_APP_NUM_ENTRIES_MASK;
1074 p_app->flags |= (u32)p_params->num_app_entries <<
1075 DCBX_APP_NUM_ENTRIES_SHIFT;
1077 for (i = 0; i < DCBX_MAX_APP_PROTOCOL; i++) {
1078 entry = &p_app->app_pri_tbl[i].entry;
1081 *entry &= ~(DCBX_APP_SF_IEEE_MASK | DCBX_APP_SF_MASK);
1082 switch (p_params->app_entry[i].sf_ieee) {
1083 case ECORE_DCBX_SF_IEEE_ETHTYPE:
1084 *entry |= ((u32)DCBX_APP_SF_IEEE_ETHTYPE <<
1085 DCBX_APP_SF_IEEE_SHIFT);
1086 *entry |= ((u32)DCBX_APP_SF_ETHTYPE <<
1089 case ECORE_DCBX_SF_IEEE_TCP_PORT:
1090 *entry |= ((u32)DCBX_APP_SF_IEEE_TCP_PORT <<
1091 DCBX_APP_SF_IEEE_SHIFT);
1092 *entry |= ((u32)DCBX_APP_SF_PORT <<
1095 case ECORE_DCBX_SF_IEEE_UDP_PORT:
1096 *entry |= ((u32)DCBX_APP_SF_IEEE_UDP_PORT <<
1097 DCBX_APP_SF_IEEE_SHIFT);
1098 *entry |= ((u32)DCBX_APP_SF_PORT <<
1101 case ECORE_DCBX_SF_IEEE_TCP_UDP_PORT:
1102 *entry |= (u32)DCBX_APP_SF_IEEE_TCP_UDP_PORT <<
1103 DCBX_APP_SF_IEEE_SHIFT;
1104 *entry |= ((u32)DCBX_APP_SF_PORT <<
1109 *entry &= ~DCBX_APP_SF_MASK;
1110 if (p_params->app_entry[i].ethtype)
1111 *entry |= ((u32)DCBX_APP_SF_ETHTYPE <<
1114 *entry |= ((u32)DCBX_APP_SF_PORT <<
1117 *entry &= ~DCBX_APP_PROTOCOL_ID_MASK;
1118 *entry |= ((u32)p_params->app_entry[i].proto_id <<
1119 DCBX_APP_PROTOCOL_ID_SHIFT);
1120 *entry &= ~DCBX_APP_PRI_MAP_MASK;
1121 *entry |= ((u32)(p_params->app_entry[i].prio) <<
1122 DCBX_APP_PRI_MAP_SHIFT);
1125 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB, "flags = 0x%x\n", p_app->flags);
1128 static enum _ecore_status_t
1129 ecore_dcbx_set_local_params(struct ecore_hwfn *p_hwfn,
1130 struct dcbx_local_params *local_admin,
1131 struct ecore_dcbx_set *params)
1135 local_admin->flags = 0;
1136 OSAL_MEMCPY(&local_admin->features,
1137 &p_hwfn->p_dcbx_info->operational.features,
1138 sizeof(local_admin->features));
1140 if (params->enabled) {
1141 local_admin->config = params->ver_num;
1142 ieee = !!(params->ver_num & DCBX_CONFIG_VERSION_IEEE);
1144 local_admin->config = DCBX_CONFIG_VERSION_DISABLED;
1147 if (params->override_flags & ECORE_DCBX_OVERRIDE_PFC_CFG)
1148 ecore_dcbx_set_pfc_data(p_hwfn, &local_admin->features.pfc,
1149 ¶ms->config.params);
1151 if (params->override_flags & ECORE_DCBX_OVERRIDE_ETS_CFG)
1152 ecore_dcbx_set_ets_data(p_hwfn, &local_admin->features.ets,
1153 ¶ms->config.params);
1155 if (params->override_flags & ECORE_DCBX_OVERRIDE_APP_CFG)
1156 ecore_dcbx_set_app_data(p_hwfn, &local_admin->features.app,
1157 ¶ms->config.params, ieee);
1159 return ECORE_SUCCESS;
1162 static enum _ecore_status_t
1163 ecore_dcbx_set_dscp_params(struct ecore_hwfn *p_hwfn,
1164 struct dcb_dscp_map *p_dscp_map,
1165 struct ecore_dcbx_set *p_params)
1170 OSAL_MEMCPY(p_dscp_map, &p_hwfn->p_dcbx_info->dscp_map,
1171 sizeof(*p_dscp_map));
1173 p_dscp_map->flags &= ~DCB_DSCP_ENABLE_MASK;
1174 if (p_params->dscp.enabled)
1175 p_dscp_map->flags |= DCB_DSCP_ENABLE_MASK;
1177 for (i = 0, entry = 0; i < 8; i++) {
1179 for (j = 0; j < 8; j++, entry++)
1180 val |= (((u32)p_params->dscp.dscp_pri_map[entry]) <<
1183 p_dscp_map->dscp_pri_map[i] = OSAL_CPU_TO_BE32(val);
1186 p_hwfn->p_dcbx_info->dscp_nig_update = true;
1188 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB, "flags = 0x%x\n", p_dscp_map->flags);
1190 return ECORE_SUCCESS;
1193 enum _ecore_status_t ecore_dcbx_config_params(struct ecore_hwfn *p_hwfn,
1194 struct ecore_ptt *p_ptt,
1195 struct ecore_dcbx_set *params,
1198 struct dcbx_local_params local_admin;
1199 struct ecore_dcbx_mib_meta_data data;
1200 struct dcb_dscp_map dscp_map;
1201 u32 resp = 0, param = 0;
1202 enum _ecore_status_t rc = ECORE_SUCCESS;
1205 OSAL_MEMCPY(&p_hwfn->p_dcbx_info->set, params,
1206 sizeof(p_hwfn->p_dcbx_info->set));
1207 return ECORE_SUCCESS;
1210 /* clear set-parmas cache */
1211 OSAL_MEMSET(&p_hwfn->p_dcbx_info->set, 0,
1212 sizeof(struct ecore_dcbx_set));
1214 OSAL_MEMSET(&local_admin, 0, sizeof(local_admin));
1215 ecore_dcbx_set_local_params(p_hwfn, &local_admin, params);
1217 data.addr = p_hwfn->mcp_info->port_addr +
1218 offsetof(struct public_port, local_admin_dcbx_mib);
1219 data.local_admin = &local_admin;
1220 data.size = sizeof(struct dcbx_local_params);
1221 ecore_memcpy_to(p_hwfn, p_ptt, data.addr, data.local_admin, data.size);
1223 if (params->override_flags & ECORE_DCBX_OVERRIDE_DSCP_CFG) {
1224 OSAL_MEMSET(&dscp_map, 0, sizeof(dscp_map));
1225 ecore_dcbx_set_dscp_params(p_hwfn, &dscp_map, params);
1227 data.addr = p_hwfn->mcp_info->port_addr +
1228 offsetof(struct public_port, dcb_dscp_map);
1229 data.dscp_map = &dscp_map;
1230 data.size = sizeof(struct dcb_dscp_map);
1231 ecore_memcpy_to(p_hwfn, p_ptt, data.addr, data.dscp_map,
1235 rc = ecore_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_SET_DCBX,
1236 1 << DRV_MB_PARAM_LLDP_SEND_SHIFT, &resp, ¶m);
1237 if (rc != ECORE_SUCCESS) {
1238 DP_NOTICE(p_hwfn, false,
1239 "Failed to send DCBX update request\n");
1246 enum _ecore_status_t ecore_dcbx_get_config_params(struct ecore_hwfn *p_hwfn,
1247 struct ecore_dcbx_set *params)
1249 struct ecore_dcbx_get *dcbx_info;
1252 if (p_hwfn->p_dcbx_info->set.config.valid) {
1253 OSAL_MEMCPY(params, &p_hwfn->p_dcbx_info->set,
1254 sizeof(struct ecore_dcbx_set));
1255 return ECORE_SUCCESS;
1258 dcbx_info = OSAL_ALLOC(p_hwfn->p_dev, GFP_KERNEL,
1259 sizeof(*dcbx_info));
1261 DP_ERR(p_hwfn, "Failed to allocate struct ecore_dcbx_info\n");
1265 OSAL_MEMSET(dcbx_info, 0, sizeof(*dcbx_info));
1266 rc = ecore_dcbx_query_params(p_hwfn, dcbx_info,
1267 ECORE_DCBX_OPERATIONAL_MIB);
1269 OSAL_FREE(p_hwfn->p_dev, dcbx_info);
1272 p_hwfn->p_dcbx_info->set.override_flags = 0;
1274 p_hwfn->p_dcbx_info->set.ver_num = DCBX_CONFIG_VERSION_DISABLED;
1275 if (dcbx_info->operational.cee)
1276 p_hwfn->p_dcbx_info->set.ver_num |= DCBX_CONFIG_VERSION_CEE;
1277 if (dcbx_info->operational.ieee)
1278 p_hwfn->p_dcbx_info->set.ver_num |= DCBX_CONFIG_VERSION_IEEE;
1279 if (dcbx_info->operational.local)
1280 p_hwfn->p_dcbx_info->set.ver_num |= DCBX_CONFIG_VERSION_STATIC;
1282 p_hwfn->p_dcbx_info->set.enabled = dcbx_info->operational.enabled;
1283 OSAL_MEMCPY(&p_hwfn->p_dcbx_info->set.config.params,
1284 &dcbx_info->operational.params,
1285 sizeof(struct ecore_dcbx_admin_params));
1286 p_hwfn->p_dcbx_info->set.config.valid = true;
1288 OSAL_MEMCPY(params, &p_hwfn->p_dcbx_info->set,
1289 sizeof(struct ecore_dcbx_set));
1291 OSAL_FREE(p_hwfn->p_dev, dcbx_info);
1293 return ECORE_SUCCESS;