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"
17 #define ECORE_DCBX_MAX_MIB_READ_TRY (100)
18 #define ECORE_ETH_TYPE_DEFAULT (0)
20 #define ECORE_DCBX_INVALID_PRIORITY 0xFF
22 /* Get Traffic Class from priority traffic class table, 4 bits represent
23 * the traffic class corresponding to the priority.
25 #define ECORE_DCBX_PRIO2TC(prio_tc_tbl, prio) \
26 ((u32)(prio_tc_tbl >> ((7 - prio) * 4)) & 0x7)
28 static bool ecore_dcbx_app_ethtype(u32 app_info_bitmap)
30 return (ECORE_MFW_GET_FIELD(app_info_bitmap, DCBX_APP_SF) ==
31 DCBX_APP_SF_ETHTYPE) ? true : false;
34 static bool ecore_dcbx_app_port(u32 app_info_bitmap)
36 return (ECORE_MFW_GET_FIELD(app_info_bitmap, DCBX_APP_SF) ==
37 DCBX_APP_SF_PORT) ? true : false;
40 static bool ecore_dcbx_ieee_app_port(u32 app_info_bitmap, u8 type)
42 u8 mfw_val = ECORE_MFW_GET_FIELD(app_info_bitmap, DCBX_APP_SF_IEEE);
45 if (mfw_val == DCBX_APP_SF_IEEE_RESERVED)
46 return ecore_dcbx_app_port(app_info_bitmap);
48 return (mfw_val == type || mfw_val == DCBX_APP_SF_IEEE_TCP_UDP_PORT) ?
52 static bool ecore_dcbx_default_tlv(u32 app_info_bitmap, u16 proto_id)
54 return (ecore_dcbx_app_ethtype(app_info_bitmap) &&
55 proto_id == ECORE_ETH_TYPE_DEFAULT) ? true : false;
58 static bool ecore_dcbx_enabled(u32 dcbx_cfg_bitmap)
60 return (ECORE_MFW_GET_FIELD(dcbx_cfg_bitmap, DCBX_CONFIG_VERSION) ==
61 DCBX_CONFIG_VERSION_DISABLED) ? false : true;
64 static bool ecore_dcbx_cee(u32 dcbx_cfg_bitmap)
66 return (ECORE_MFW_GET_FIELD(dcbx_cfg_bitmap, DCBX_CONFIG_VERSION) ==
67 DCBX_CONFIG_VERSION_CEE) ? true : false;
70 static bool ecore_dcbx_ieee(u32 dcbx_cfg_bitmap)
72 return (ECORE_MFW_GET_FIELD(dcbx_cfg_bitmap, DCBX_CONFIG_VERSION) ==
73 DCBX_CONFIG_VERSION_IEEE) ? true : false;
76 static bool ecore_dcbx_local(u32 dcbx_cfg_bitmap)
78 return (ECORE_MFW_GET_FIELD(dcbx_cfg_bitmap, DCBX_CONFIG_VERSION) ==
79 DCBX_CONFIG_VERSION_STATIC) ? true : false;
82 /* @@@TBD A0 Eagle workaround */
83 void ecore_dcbx_eagle_workaround(struct ecore_hwfn *p_hwfn,
84 struct ecore_ptt *p_ptt, bool set_to_pfc)
86 if (!ENABLE_EAGLE_ENG1_WORKAROUND(p_hwfn))
89 ecore_wr(p_hwfn, p_ptt,
90 YSEM_REG_FAST_MEMORY + 0x20000 /* RAM in FASTMEM */ +
91 YSTORM_FLOW_CONTROL_MODE_OFFSET,
92 set_to_pfc ? flow_ctrl_pfc : flow_ctrl_pause);
93 ecore_wr(p_hwfn, p_ptt, NIG_REG_FLOWCTRL_MODE,
94 EAGLE_ENG1_WORKAROUND_NIG_FLOWCTRL_MODE);
98 ecore_dcbx_dp_protocol(struct ecore_hwfn *p_hwfn,
99 struct ecore_dcbx_results *p_data)
101 struct ecore_hw_info *p_info = &p_hwfn->hw_info;
102 enum dcbx_protocol_type id;
103 u8 prio, tc, size, update;
105 const char *name; /* @DPDK */
108 size = OSAL_ARRAY_SIZE(ecore_dcbx_app_update);
110 DP_INFO(p_hwfn, "DCBX negotiated: %d\n", p_data->dcbx_enabled);
112 for (i = 0; i < size; i++) {
113 id = ecore_dcbx_app_update[i].id;
114 name = ecore_dcbx_app_update[i].name;
116 enable = p_data->arr[id].enable;
117 update = p_data->arr[id].update;
118 tc = p_data->arr[id].tc;
119 prio = p_data->arr[id].priority;
122 "%s info: update %d, enable %d, prio %d, tc %d,"
123 " num_active_tc %d dscp_enable = %d dscp_val = %d\n",
124 name, update, enable, prio, tc, p_info->num_active_tc,
125 p_data->arr[id].dscp_enable, p_data->arr[id].dscp_val);
130 ecore_dcbx_set_pf_tcs(struct ecore_hw_info *p_info,
131 u8 tc, enum ecore_pci_personality personality)
134 if (p_info->personality == personality)
135 p_info->offload_tc = tc;
139 ecore_dcbx_set_params(struct ecore_dcbx_results *p_data,
140 struct ecore_hwfn *p_hwfn,
141 bool enable, bool update, u8 prio, u8 tc,
142 enum dcbx_protocol_type type,
143 enum ecore_pci_personality personality)
145 struct ecore_dcbx_dscp_params *dscp = &p_hwfn->p_dcbx_info->get.dscp;
147 /* PF update ramrod data */
148 p_data->arr[type].enable = enable;
149 p_data->arr[type].priority = prio;
150 p_data->arr[type].tc = tc;
151 p_data->arr[type].dscp_enable = dscp->enabled;
152 if (p_data->arr[type].dscp_enable) {
155 for (i = 0; i < ECORE_DCBX_DSCP_SIZE; i++)
156 if (prio == dscp->dscp_pri_map[i]) {
157 p_data->arr[type].dscp_val = i;
162 if (enable && p_data->arr[type].dscp_enable)
163 p_data->arr[type].update = UPDATE_DCB_DSCP;
165 p_data->arr[type].update = UPDATE_DCB;
167 p_data->arr[type].update = DONT_UPDATE_DCB_DHCP;
169 ecore_dcbx_set_pf_tcs(&p_hwfn->hw_info, tc, personality);
172 /* Update app protocol data and hw_info fields with the TLV info */
174 ecore_dcbx_update_app_info(struct ecore_dcbx_results *p_data,
175 struct ecore_hwfn *p_hwfn,
176 bool enable, bool update, u8 prio, u8 tc,
177 enum dcbx_protocol_type type)
179 enum ecore_pci_personality personality;
180 enum dcbx_protocol_type id;
181 const char *name; /* @DPDK */
185 size = OSAL_ARRAY_SIZE(ecore_dcbx_app_update);
187 for (i = 0; i < size; i++) {
188 id = ecore_dcbx_app_update[i].id;
193 personality = ecore_dcbx_app_update[i].personality;
194 name = ecore_dcbx_app_update[i].name;
196 ecore_dcbx_set_params(p_data, p_hwfn, enable, update,
197 prio, tc, type, personality);
201 static enum _ecore_status_t
202 ecore_dcbx_get_app_priority(u8 pri_bitmap, u8 *priority)
204 u32 pri_mask, pri = ECORE_MAX_PFC_PRIORITIES;
205 u32 index = ECORE_MAX_PFC_PRIORITIES - 1;
206 enum _ecore_status_t rc = ECORE_SUCCESS;
208 /* Bitmap 1 corresponds to priority 0, return priority 0 */
209 if (pri_bitmap == 1) {
214 /* Choose the highest priority */
215 while ((pri == ECORE_MAX_PFC_PRIORITIES) && index) {
216 pri_mask = 1 << index;
217 if (pri_bitmap & pri_mask)
222 if (pri < ECORE_MAX_PFC_PRIORITIES)
231 ecore_dcbx_get_app_protocol_type(struct ecore_hwfn *p_hwfn,
232 u32 app_prio_bitmap, u16 id,
233 enum dcbx_protocol_type *type, bool ieee)
237 if (ecore_dcbx_default_tlv(app_prio_bitmap, id)) {
238 *type = DCBX_PROTOCOL_ETH;
241 *type = DCBX_MAX_PROTOCOL_TYPE;
243 "No action required, App TLV id = 0x%x"
244 " app_prio_bitmap = 0x%x\n",
245 id, app_prio_bitmap);
251 /* Parse app TLV's to update TC information in hw_info structure for
252 * reconfiguring QM. Get protocol specific data for PF update ramrod command.
254 static enum _ecore_status_t
255 ecore_dcbx_process_tlv(struct ecore_hwfn *p_hwfn,
256 struct ecore_dcbx_results *p_data,
257 struct dcbx_app_priority_entry *p_tbl, u32 pri_tc_tbl,
258 int count, u8 dcbx_version)
260 enum _ecore_status_t rc = ECORE_SUCCESS;
261 u8 tc, priority, priority_map;
262 enum dcbx_protocol_type type;
267 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB, "Num APP entries = %d\n", count);
269 ieee = (dcbx_version == DCBX_CONFIG_VERSION_IEEE);
271 for (i = 0; i < count; i++) {
272 protocol_id = ECORE_MFW_GET_FIELD(p_tbl[i].entry,
273 DCBX_APP_PROTOCOL_ID);
274 priority_map = ECORE_MFW_GET_FIELD(p_tbl[i].entry,
276 rc = ecore_dcbx_get_app_priority(priority_map, &priority);
277 if (rc == ECORE_INVAL) {
278 DP_ERR(p_hwfn, "Invalid priority\n");
282 tc = ECORE_DCBX_PRIO2TC(pri_tc_tbl, priority);
283 if (ecore_dcbx_get_app_protocol_type(p_hwfn, p_tbl[i].entry,
286 /* ETH always have the enable bit reset, as it gets
287 * vlan information per packet. For other protocols,
288 * should be set according to the dcbx_enabled
289 * indication, but we only got here if there was an
290 * app tlv for the protocol, so dcbx must be enabled.
292 enable = (type == DCBX_PROTOCOL_ETH ? false : true);
294 ecore_dcbx_update_app_info(p_data, p_hwfn, enable, true,
298 /* Update ramrod protocol data and hw_info fields
299 * with default info when corresponding APP TLV's are not detected.
300 * The enabled field has a different logic for ethernet as only for
301 * ethernet dcb should disabled by default, as the information arrives
302 * from the OS (unless an explicit app tlv was present).
304 tc = p_data->arr[DCBX_PROTOCOL_ETH].tc;
305 priority = p_data->arr[DCBX_PROTOCOL_ETH].priority;
306 for (type = 0; type < DCBX_MAX_PROTOCOL_TYPE; type++) {
307 if (p_data->arr[type].update)
310 enable = (type == DCBX_PROTOCOL_ETH) ? false : !!dcbx_version;
311 ecore_dcbx_update_app_info(p_data, p_hwfn, enable, true,
315 return ECORE_SUCCESS;
318 /* Parse app TLV's to update TC information in hw_info structure for
319 * reconfiguring QM. Get protocol specific data for PF update ramrod command.
321 static enum _ecore_status_t
322 ecore_dcbx_process_mib_info(struct ecore_hwfn *p_hwfn)
324 struct dcbx_app_priority_feature *p_app;
325 enum _ecore_status_t rc = ECORE_SUCCESS;
326 struct ecore_dcbx_results data = { 0 };
327 struct dcbx_app_priority_entry *p_tbl;
328 struct dcbx_ets_feature *p_ets;
329 struct ecore_hw_info *p_info;
330 u32 pri_tc_tbl, flags;
334 flags = p_hwfn->p_dcbx_info->operational.flags;
335 dcbx_version = ECORE_MFW_GET_FIELD(flags, DCBX_CONFIG_VERSION);
337 p_app = &p_hwfn->p_dcbx_info->operational.features.app;
338 p_tbl = p_app->app_pri_tbl;
340 p_ets = &p_hwfn->p_dcbx_info->operational.features.ets;
341 pri_tc_tbl = p_ets->pri_tc_tbl[0];
343 p_info = &p_hwfn->hw_info;
344 num_entries = ECORE_MFW_GET_FIELD(p_app->flags, DCBX_APP_NUM_ENTRIES);
346 rc = ecore_dcbx_process_tlv(p_hwfn, &data, p_tbl, pri_tc_tbl,
347 num_entries, dcbx_version);
348 if (rc != ECORE_SUCCESS)
351 p_info->num_active_tc = ECORE_MFW_GET_FIELD(p_ets->flags,
353 data.pf_id = p_hwfn->rel_pf_id;
354 data.dcbx_enabled = !!dcbx_version;
356 ecore_dcbx_dp_protocol(p_hwfn, &data);
358 OSAL_MEMCPY(&p_hwfn->p_dcbx_info->results, &data,
359 sizeof(struct ecore_dcbx_results));
361 return ECORE_SUCCESS;
364 static enum _ecore_status_t
365 ecore_dcbx_copy_mib(struct ecore_hwfn *p_hwfn,
366 struct ecore_ptt *p_ptt,
367 struct ecore_dcbx_mib_meta_data *p_data,
368 enum ecore_mib_read_type type)
370 enum _ecore_status_t rc = ECORE_SUCCESS;
371 u32 prefix_seq_num, suffix_seq_num;
375 if (type == ECORE_DCBX_REMOTE_LLDP_MIB) {
376 ecore_memcpy_from(p_hwfn, p_ptt, p_data->lldp_remote,
377 p_data->addr, p_data->size);
378 prefix_seq_num = p_data->lldp_remote->prefix_seq_num;
379 suffix_seq_num = p_data->lldp_remote->suffix_seq_num;
381 ecore_memcpy_from(p_hwfn, p_ptt, p_data->mib,
382 p_data->addr, p_data->size);
383 prefix_seq_num = p_data->mib->prefix_seq_num;
384 suffix_seq_num = p_data->mib->suffix_seq_num;
388 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
389 "mib type = %d, try count = %d prefix seq num ="
390 " %d suffix seq num = %d\n",
391 type, read_count, prefix_seq_num, suffix_seq_num);
392 } while ((prefix_seq_num != suffix_seq_num) &&
393 (read_count < ECORE_DCBX_MAX_MIB_READ_TRY));
395 if (read_count >= ECORE_DCBX_MAX_MIB_READ_TRY) {
397 "MIB read err, mib type = %d, try count ="
398 " %d prefix seq num = %d suffix seq num = %d\n",
399 type, read_count, prefix_seq_num, suffix_seq_num);
406 static enum _ecore_status_t
407 ecore_dcbx_get_priority_info(struct ecore_hwfn *p_hwfn,
408 struct ecore_dcbx_app_prio *p_prio,
409 struct ecore_dcbx_results *p_results)
411 enum _ecore_status_t rc = ECORE_SUCCESS;
413 if (p_results->arr[DCBX_PROTOCOL_ETH].update &&
414 p_results->arr[DCBX_PROTOCOL_ETH].enable) {
415 p_prio->eth = p_results->arr[DCBX_PROTOCOL_ETH].priority;
416 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
417 "Priority: eth %d\n", p_prio->eth);
424 ecore_dcbx_get_app_data(struct ecore_hwfn *p_hwfn,
425 struct dcbx_app_priority_feature *p_app,
426 struct dcbx_app_priority_entry *p_tbl,
427 struct ecore_dcbx_params *p_params, bool ieee)
429 struct ecore_app_entry *entry;
433 p_params->app_willing = ECORE_MFW_GET_FIELD(p_app->flags,
435 p_params->app_valid = ECORE_MFW_GET_FIELD(p_app->flags,
437 p_params->app_error = ECORE_MFW_GET_FIELD(p_app->flags, DCBX_APP_ERROR);
438 p_params->num_app_entries = ECORE_MFW_GET_FIELD(p_app->flags,
439 DCBX_APP_NUM_ENTRIES);
440 for (i = 0; i < p_params->num_app_entries; i++) {
441 entry = &p_params->app_entry[i];
446 sf_ieee = ECORE_MFW_GET_FIELD(p_tbl[i].entry,
449 case DCBX_APP_SF_IEEE_RESERVED:
451 val = ECORE_MFW_GET_FIELD(p_tbl[i].entry,
453 entry->sf_ieee = val ?
454 ECORE_DCBX_SF_IEEE_TCP_UDP_PORT :
455 ECORE_DCBX_SF_IEEE_ETHTYPE;
457 case DCBX_APP_SF_IEEE_ETHTYPE:
458 entry->sf_ieee = ECORE_DCBX_SF_IEEE_ETHTYPE;
460 case DCBX_APP_SF_IEEE_TCP_PORT:
461 entry->sf_ieee = ECORE_DCBX_SF_IEEE_TCP_PORT;
463 case DCBX_APP_SF_IEEE_UDP_PORT:
464 entry->sf_ieee = ECORE_DCBX_SF_IEEE_UDP_PORT;
466 case DCBX_APP_SF_IEEE_TCP_UDP_PORT:
468 ECORE_DCBX_SF_IEEE_TCP_UDP_PORT;
472 entry->ethtype = !(ECORE_MFW_GET_FIELD(p_tbl[i].entry,
476 pri_map = ECORE_MFW_GET_FIELD(p_tbl[i].entry, DCBX_APP_PRI_MAP);
477 ecore_dcbx_get_app_priority(pri_map, &entry->prio);
478 entry->proto_id = ECORE_MFW_GET_FIELD(p_tbl[i].entry,
479 DCBX_APP_PROTOCOL_ID);
480 ecore_dcbx_get_app_protocol_type(p_hwfn, p_tbl[i].entry,
482 &entry->proto_type, ieee);
485 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
486 "APP params: willing %d, valid %d error = %d\n",
487 p_params->app_willing, p_params->app_valid,
488 p_params->app_error);
492 ecore_dcbx_get_pfc_data(struct ecore_hwfn *p_hwfn,
493 u32 pfc, struct ecore_dcbx_params *p_params)
497 p_params->pfc.willing = ECORE_MFW_GET_FIELD(pfc, DCBX_PFC_WILLING);
498 p_params->pfc.max_tc = ECORE_MFW_GET_FIELD(pfc, DCBX_PFC_CAPS);
499 p_params->pfc.enabled = ECORE_MFW_GET_FIELD(pfc, DCBX_PFC_ENABLED);
500 pfc_map = ECORE_MFW_GET_FIELD(pfc, DCBX_PFC_PRI_EN_BITMAP);
501 p_params->pfc.prio[0] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_0);
502 p_params->pfc.prio[1] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_1);
503 p_params->pfc.prio[2] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_2);
504 p_params->pfc.prio[3] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_3);
505 p_params->pfc.prio[4] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_4);
506 p_params->pfc.prio[5] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_5);
507 p_params->pfc.prio[6] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_6);
508 p_params->pfc.prio[7] = !!(pfc_map & DCBX_PFC_PRI_EN_BITMAP_PRI_7);
510 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
511 "PFC params: willing %d, pfc_bitmap %d\n",
512 p_params->pfc.willing, pfc_map);
516 ecore_dcbx_get_ets_data(struct ecore_hwfn *p_hwfn,
517 struct dcbx_ets_feature *p_ets,
518 struct ecore_dcbx_params *p_params)
520 u32 bw_map[2], tsa_map[2], pri_map;
523 p_params->ets_willing = ECORE_MFW_GET_FIELD(p_ets->flags,
525 p_params->ets_enabled = ECORE_MFW_GET_FIELD(p_ets->flags,
527 p_params->ets_cbs = ECORE_MFW_GET_FIELD(p_ets->flags, DCBX_ETS_CBS);
528 p_params->max_ets_tc = ECORE_MFW_GET_FIELD(p_ets->flags,
530 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
531 "ETS params: willing %d, ets_cbs %d pri_tc_tbl_0 %x"
533 p_params->ets_willing, p_params->ets_cbs,
534 p_ets->pri_tc_tbl[0], p_params->max_ets_tc);
536 /* 8 bit tsa and bw data corresponding to each of the 8 TC's are
537 * encoded in a type u32 array of size 2.
539 bw_map[0] = OSAL_BE32_TO_CPU(p_ets->tc_bw_tbl[0]);
540 bw_map[1] = OSAL_BE32_TO_CPU(p_ets->tc_bw_tbl[1]);
541 tsa_map[0] = OSAL_BE32_TO_CPU(p_ets->tc_tsa_tbl[0]);
542 tsa_map[1] = OSAL_BE32_TO_CPU(p_ets->tc_tsa_tbl[1]);
543 pri_map = OSAL_BE32_TO_CPU(p_ets->pri_tc_tbl[0]);
544 for (i = 0; i < ECORE_MAX_PFC_PRIORITIES; i++) {
545 p_params->ets_tc_bw_tbl[i] = ((u8 *)bw_map)[i];
546 p_params->ets_tc_tsa_tbl[i] = ((u8 *)tsa_map)[i];
547 p_params->ets_pri_tc_tbl[i] = ECORE_DCBX_PRIO2TC(pri_map, i);
548 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
549 "elem %d bw_tbl %x tsa_tbl %x\n",
550 i, p_params->ets_tc_bw_tbl[i],
551 p_params->ets_tc_tsa_tbl[i]);
555 static enum _ecore_status_t
556 ecore_dcbx_get_common_params(struct ecore_hwfn *p_hwfn,
557 struct dcbx_app_priority_feature *p_app,
558 struct dcbx_app_priority_entry *p_tbl,
559 struct dcbx_ets_feature *p_ets,
560 u32 pfc, struct ecore_dcbx_params *p_params,
563 ecore_dcbx_get_app_data(p_hwfn, p_app, p_tbl, p_params, ieee);
564 ecore_dcbx_get_ets_data(p_hwfn, p_ets, p_params);
565 ecore_dcbx_get_pfc_data(p_hwfn, pfc, p_params);
567 return ECORE_SUCCESS;
570 static enum _ecore_status_t
571 ecore_dcbx_get_local_params(struct ecore_hwfn *p_hwfn,
572 struct ecore_ptt *p_ptt,
573 struct ecore_dcbx_get *params)
575 struct ecore_dcbx_admin_params *p_local;
576 struct dcbx_app_priority_feature *p_app;
577 struct dcbx_app_priority_entry *p_tbl;
578 struct ecore_dcbx_params *p_data;
579 struct dcbx_ets_feature *p_ets;
582 p_local = ¶ms->local;
583 p_data = &p_local->params;
584 p_app = &p_hwfn->p_dcbx_info->local_admin.features.app;
585 p_tbl = p_app->app_pri_tbl;
586 p_ets = &p_hwfn->p_dcbx_info->local_admin.features.ets;
587 pfc = p_hwfn->p_dcbx_info->local_admin.features.pfc;
589 ecore_dcbx_get_common_params(p_hwfn, p_app, p_tbl, p_ets, pfc, p_data,
591 p_local->valid = true;
593 return ECORE_SUCCESS;
596 static enum _ecore_status_t
597 ecore_dcbx_get_remote_params(struct ecore_hwfn *p_hwfn,
598 struct ecore_ptt *p_ptt,
599 struct ecore_dcbx_get *params)
601 struct ecore_dcbx_remote_params *p_remote;
602 struct dcbx_app_priority_feature *p_app;
603 struct dcbx_app_priority_entry *p_tbl;
604 struct ecore_dcbx_params *p_data;
605 struct dcbx_ets_feature *p_ets;
608 p_remote = ¶ms->remote;
609 p_data = &p_remote->params;
610 p_app = &p_hwfn->p_dcbx_info->remote.features.app;
611 p_tbl = p_app->app_pri_tbl;
612 p_ets = &p_hwfn->p_dcbx_info->remote.features.ets;
613 pfc = p_hwfn->p_dcbx_info->remote.features.pfc;
615 ecore_dcbx_get_common_params(p_hwfn, p_app, p_tbl, p_ets, pfc, p_data,
617 p_remote->valid = true;
619 return ECORE_SUCCESS;
623 ecore_dcbx_get_operational_params(struct ecore_hwfn *p_hwfn,
624 struct ecore_ptt *p_ptt,
625 struct ecore_dcbx_get *params)
627 struct ecore_dcbx_operational_params *p_operational;
628 enum _ecore_status_t rc = ECORE_SUCCESS;
629 struct dcbx_app_priority_feature *p_app;
630 struct dcbx_app_priority_entry *p_tbl;
631 struct ecore_dcbx_results *p_results;
632 struct ecore_dcbx_params *p_data;
633 struct dcbx_ets_feature *p_ets;
637 flags = p_hwfn->p_dcbx_info->operational.flags;
639 /* If DCBx version is non zero, then negotiation
640 * was successfuly performed
642 p_operational = ¶ms->operational;
643 enabled = ecore_dcbx_enabled(flags);
645 p_operational->enabled = enabled;
646 p_operational->valid = false;
650 p_data = &p_operational->params;
651 p_results = &p_hwfn->p_dcbx_info->results;
652 p_app = &p_hwfn->p_dcbx_info->operational.features.app;
653 p_tbl = p_app->app_pri_tbl;
654 p_ets = &p_hwfn->p_dcbx_info->operational.features.ets;
655 pfc = p_hwfn->p_dcbx_info->operational.features.pfc;
657 p_operational->ieee = ecore_dcbx_ieee(flags);
658 p_operational->cee = ecore_dcbx_cee(flags);
659 p_operational->local = ecore_dcbx_local(flags);
661 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
662 "Version support: ieee %d, cee %d, static %d\n",
663 p_operational->ieee, p_operational->cee,
664 p_operational->local);
666 ecore_dcbx_get_common_params(p_hwfn, p_app, p_tbl, p_ets, pfc, p_data,
667 p_operational->ieee);
668 ecore_dcbx_get_priority_info(p_hwfn, &p_operational->app_prio,
670 err = ECORE_MFW_GET_FIELD(p_app->flags, DCBX_APP_ERROR);
671 p_operational->err = err;
672 p_operational->enabled = enabled;
673 p_operational->valid = true;
676 static enum _ecore_status_t
677 ecore_dcbx_get_dscp_params(struct ecore_hwfn *p_hwfn,
678 struct ecore_ptt *p_ptt,
679 struct ecore_dcbx_get *params)
681 struct ecore_dcbx_dscp_params *p_dscp;
682 struct dcb_dscp_map *p_dscp_map;
686 p_dscp = ¶ms->dscp;
687 p_dscp_map = &p_hwfn->p_dcbx_info->dscp_map;
688 p_dscp->enabled = ECORE_MFW_GET_FIELD(p_dscp_map->flags,
690 /* MFW encodes 64 dscp entries into 8 element array of u32 entries,
691 * where each entry holds the 4bit priority map for 8 dscp entries.
693 for (i = 0, entry = 0; i < ECORE_DCBX_DSCP_SIZE / 8; i++) {
694 pri_map = OSAL_BE32_TO_CPU(p_dscp_map->dscp_pri_map[i]);
695 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB, "elem %d pri_map 0x%x\n",
697 for (j = 0; j < ECORE_DCBX_DSCP_SIZE / 8; j++, entry++)
698 p_dscp->dscp_pri_map[entry] = (u32)(pri_map >>
702 return ECORE_SUCCESS;
705 static enum _ecore_status_t
706 ecore_dcbx_get_local_lldp_params(struct ecore_hwfn *p_hwfn,
707 struct ecore_ptt *p_ptt,
708 struct ecore_dcbx_get *params)
710 struct ecore_dcbx_lldp_local *p_local;
714 p_local = ¶ms->lldp_local;
716 size = OSAL_ARRAY_SIZE(p_local->local_chassis_id);
717 dest = p_hwfn->p_dcbx_info->get.lldp_local.local_chassis_id;
718 OSAL_MEMCPY(dest, p_local->local_chassis_id, size);
720 size = OSAL_ARRAY_SIZE(p_local->local_port_id);
721 dest = p_hwfn->p_dcbx_info->get.lldp_local.local_port_id;
722 OSAL_MEMCPY(dest, p_local->local_port_id, size);
724 return ECORE_SUCCESS;
727 static enum _ecore_status_t
728 ecore_dcbx_get_remote_lldp_params(struct ecore_hwfn *p_hwfn,
729 struct ecore_ptt *p_ptt,
730 struct ecore_dcbx_get *params)
732 struct ecore_dcbx_lldp_remote *p_remote;
736 p_remote = ¶ms->lldp_remote;
738 size = OSAL_ARRAY_SIZE(p_remote->peer_chassis_id);
739 dest = p_hwfn->p_dcbx_info->get.lldp_remote.peer_chassis_id;
740 OSAL_MEMCPY(dest, p_remote->peer_chassis_id, size);
742 size = OSAL_ARRAY_SIZE(p_remote->peer_port_id);
743 dest = p_hwfn->p_dcbx_info->get.lldp_remote.peer_port_id;
744 OSAL_MEMCPY(dest, p_remote->peer_port_id, size);
746 return ECORE_SUCCESS;
749 static enum _ecore_status_t
750 ecore_dcbx_get_params(struct ecore_hwfn *p_hwfn,
751 struct ecore_ptt *p_ptt, enum ecore_mib_read_type type)
753 enum _ecore_status_t rc = ECORE_SUCCESS;
754 struct ecore_dcbx_get *p_params;
756 p_params = &p_hwfn->p_dcbx_info->get;
759 case ECORE_DCBX_REMOTE_MIB:
760 ecore_dcbx_get_remote_params(p_hwfn, p_ptt, p_params);
762 case ECORE_DCBX_LOCAL_MIB:
763 ecore_dcbx_get_local_params(p_hwfn, p_ptt, p_params);
765 case ECORE_DCBX_OPERATIONAL_MIB:
766 ecore_dcbx_get_operational_params(p_hwfn, p_ptt, p_params);
768 case ECORE_DCBX_REMOTE_LLDP_MIB:
769 rc = ecore_dcbx_get_remote_lldp_params(p_hwfn, p_ptt, p_params);
771 case ECORE_DCBX_LOCAL_LLDP_MIB:
772 rc = ecore_dcbx_get_local_lldp_params(p_hwfn, p_ptt, p_params);
775 DP_ERR(p_hwfn, "MIB read err, unknown mib type %d\n", type);
782 static enum _ecore_status_t
783 ecore_dcbx_read_local_lldp_mib(struct ecore_hwfn *p_hwfn,
784 struct ecore_ptt *p_ptt)
786 enum _ecore_status_t rc = ECORE_SUCCESS;
787 struct ecore_dcbx_mib_meta_data data;
789 data.addr = p_hwfn->mcp_info->port_addr + offsetof(struct public_port,
791 data.lldp_local = p_hwfn->p_dcbx_info->lldp_local;
792 data.size = sizeof(struct lldp_config_params_s);
793 ecore_memcpy_from(p_hwfn, p_ptt, data.lldp_local, data.addr, data.size);
798 static enum _ecore_status_t
799 ecore_dcbx_read_remote_lldp_mib(struct ecore_hwfn *p_hwfn,
800 struct ecore_ptt *p_ptt,
801 enum ecore_mib_read_type type)
803 enum _ecore_status_t rc = ECORE_SUCCESS;
804 struct ecore_dcbx_mib_meta_data data;
806 OSAL_MEM_ZERO(&data, sizeof(data));
807 data.addr = p_hwfn->mcp_info->port_addr + offsetof(struct public_port,
809 data.lldp_remote = p_hwfn->p_dcbx_info->lldp_remote;
810 data.size = sizeof(struct lldp_status_params_s);
811 rc = ecore_dcbx_copy_mib(p_hwfn, p_ptt, &data, type);
816 static enum _ecore_status_t
817 ecore_dcbx_read_operational_mib(struct ecore_hwfn *p_hwfn,
818 struct ecore_ptt *p_ptt,
819 enum ecore_mib_read_type type)
821 struct ecore_dcbx_mib_meta_data data;
822 enum _ecore_status_t rc = ECORE_SUCCESS;
824 OSAL_MEM_ZERO(&data, sizeof(data));
825 data.addr = p_hwfn->mcp_info->port_addr +
826 offsetof(struct public_port, operational_dcbx_mib);
827 data.mib = &p_hwfn->p_dcbx_info->operational;
828 data.size = sizeof(struct dcbx_mib);
829 rc = ecore_dcbx_copy_mib(p_hwfn, p_ptt, &data, type);
834 static enum _ecore_status_t
835 ecore_dcbx_read_remote_mib(struct ecore_hwfn *p_hwfn,
836 struct ecore_ptt *p_ptt,
837 enum ecore_mib_read_type type)
839 struct ecore_dcbx_mib_meta_data data;
840 enum _ecore_status_t rc = ECORE_SUCCESS;
842 OSAL_MEM_ZERO(&data, sizeof(data));
843 data.addr = p_hwfn->mcp_info->port_addr +
844 offsetof(struct public_port, remote_dcbx_mib);
845 data.mib = &p_hwfn->p_dcbx_info->remote;
846 data.size = sizeof(struct dcbx_mib);
847 rc = ecore_dcbx_copy_mib(p_hwfn, p_ptt, &data, type);
852 static enum _ecore_status_t
853 ecore_dcbx_read_local_mib(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt)
855 struct ecore_dcbx_mib_meta_data data;
856 enum _ecore_status_t rc = ECORE_SUCCESS;
858 data.addr = p_hwfn->mcp_info->port_addr +
859 offsetof(struct public_port, local_admin_dcbx_mib);
860 data.local_admin = &p_hwfn->p_dcbx_info->local_admin;
861 data.size = sizeof(struct dcbx_local_params);
862 ecore_memcpy_from(p_hwfn, p_ptt, data.local_admin,
863 data.addr, data.size);
869 ecore_dcbx_read_dscp_mib(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt)
871 struct ecore_dcbx_mib_meta_data data;
873 data.addr = p_hwfn->mcp_info->port_addr +
874 offsetof(struct public_port, dcb_dscp_map);
875 data.dscp_map = &p_hwfn->p_dcbx_info->dscp_map;
876 data.size = sizeof(struct dcb_dscp_map);
877 ecore_memcpy_from(p_hwfn, p_ptt, data.dscp_map, data.addr, data.size);
880 static enum _ecore_status_t ecore_dcbx_read_mib(struct ecore_hwfn *p_hwfn,
881 struct ecore_ptt *p_ptt,
882 enum ecore_mib_read_type type)
884 enum _ecore_status_t rc = ECORE_SUCCESS;
887 case ECORE_DCBX_OPERATIONAL_MIB:
888 ecore_dcbx_read_dscp_mib(p_hwfn, p_ptt);
889 rc = ecore_dcbx_read_operational_mib(p_hwfn, p_ptt, type);
891 case ECORE_DCBX_REMOTE_MIB:
892 rc = ecore_dcbx_read_remote_mib(p_hwfn, p_ptt, type);
894 case ECORE_DCBX_LOCAL_MIB:
895 rc = ecore_dcbx_read_local_mib(p_hwfn, p_ptt);
897 case ECORE_DCBX_REMOTE_LLDP_MIB:
898 rc = ecore_dcbx_read_remote_lldp_mib(p_hwfn, p_ptt, type);
900 case ECORE_DCBX_LOCAL_LLDP_MIB:
901 rc = ecore_dcbx_read_local_lldp_mib(p_hwfn, p_ptt);
904 DP_ERR(p_hwfn, "MIB read err, unknown mib type %d\n", type);
913 * Reconfigure QM and invoke PF update ramrod command if operational MIB
914 * change is detected.
917 ecore_dcbx_mib_update_event(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
918 enum ecore_mib_read_type type)
920 enum _ecore_status_t rc = ECORE_SUCCESS;
922 rc = ecore_dcbx_read_mib(p_hwfn, p_ptt, type);
926 if (type == ECORE_DCBX_OPERATIONAL_MIB) {
927 ecore_dcbx_get_dscp_params(p_hwfn, p_ptt,
928 &p_hwfn->p_dcbx_info->get);
930 rc = ecore_dcbx_process_mib_info(p_hwfn);
934 /* reconfigure tcs of QM queues according
935 * to negotiation results
937 ecore_qm_reconf(p_hwfn, p_ptt);
939 /* update storm FW with negotiation results */
940 ecore_sp_pf_update(p_hwfn);
942 /* set eagle enigne 1 flow control workaround
943 * according to negotiation results
945 enabled = p_hwfn->p_dcbx_info->results.dcbx_enabled;
946 ecore_dcbx_eagle_workaround(p_hwfn, p_ptt, enabled);
949 ecore_dcbx_get_params(p_hwfn, p_ptt, type);
951 /* Update the DSCP to TC mapping bit if required */
952 if ((type == ECORE_DCBX_OPERATIONAL_MIB) &&
953 p_hwfn->p_dcbx_info->dscp_nig_update) {
954 ecore_wr(p_hwfn, p_ptt, NIG_REG_DSCP_TO_TC_MAP_ENABLE, 0x1);
955 p_hwfn->p_dcbx_info->dscp_nig_update = false;
958 OSAL_DCBX_AEN(p_hwfn, type);
963 enum _ecore_status_t ecore_dcbx_info_alloc(struct ecore_hwfn *p_hwfn)
965 enum _ecore_status_t rc = ECORE_SUCCESS;
967 p_hwfn->p_dcbx_info = OSAL_ZALLOC(p_hwfn->p_dev, GFP_KERNEL,
968 sizeof(struct ecore_dcbx_info));
969 if (!p_hwfn->p_dcbx_info) {
970 DP_NOTICE(p_hwfn, true,
971 "Failed to allocate `struct ecore_dcbx_info'");
978 void ecore_dcbx_info_free(struct ecore_hwfn *p_hwfn,
979 struct ecore_dcbx_info *p_dcbx_info)
981 OSAL_FREE(p_hwfn->p_dev, p_hwfn->p_dcbx_info);
984 static void ecore_dcbx_update_protocol_data(struct protocol_dcb_data *p_data,
985 struct ecore_dcbx_results *p_src,
986 enum dcbx_protocol_type type)
988 p_data->dcb_enable_flag = p_src->arr[type].enable;
989 p_data->dcb_priority = p_src->arr[type].priority;
990 p_data->dcb_tc = p_src->arr[type].tc;
991 p_data->dscp_enable_flag = p_src->arr[type].dscp_enable;
992 p_data->dscp_val = p_src->arr[type].dscp_val;
995 /* Set pf update ramrod command params */
996 void ecore_dcbx_set_pf_update_params(struct ecore_dcbx_results *p_src,
997 struct pf_update_ramrod_data *p_dest)
999 struct protocol_dcb_data *p_dcb_data;
1000 bool update_flag = false;
1002 p_dest->pf_id = p_src->pf_id;
1004 update_flag = p_src->arr[DCBX_PROTOCOL_ETH].update;
1005 p_dest->update_eth_dcb_data_flag = update_flag;
1007 p_dcb_data = &p_dest->eth_dcb_data;
1008 ecore_dcbx_update_protocol_data(p_dcb_data, p_src, DCBX_PROTOCOL_ETH);
1012 enum _ecore_status_t ecore_dcbx_query(struct ecore_hwfn *p_hwfn,
1013 enum ecore_mib_read_type type)
1015 struct ecore_ptt *p_ptt;
1016 enum _ecore_status_t rc;
1018 p_ptt = ecore_ptt_acquire(p_hwfn);
1021 DP_ERR(p_hwfn, "rc = %d\n", rc);
1025 rc = ecore_dcbx_read_mib(p_hwfn, p_ptt, type);
1026 if (rc != ECORE_SUCCESS)
1029 rc = ecore_dcbx_get_params(p_hwfn, p_ptt, type);
1032 ecore_ptt_release(p_hwfn, p_ptt);
1036 enum _ecore_status_t ecore_dcbx_query_params(struct ecore_hwfn *p_hwfn,
1037 struct ecore_dcbx_get *p_get,
1038 enum ecore_mib_read_type type)
1040 enum _ecore_status_t rc;
1042 rc = ecore_dcbx_query(p_hwfn, type);
1046 if (p_get != OSAL_NULL)
1047 OSAL_MEMCPY(p_get, &p_hwfn->p_dcbx_info->get,
1048 sizeof(struct ecore_dcbx_get));
1054 ecore_dcbx_set_pfc_data(struct ecore_hwfn *p_hwfn,
1055 u32 *pfc, struct ecore_dcbx_params *p_params)
1060 if (p_params->pfc.willing)
1061 *pfc |= DCBX_PFC_WILLING_MASK;
1063 *pfc &= ~DCBX_PFC_WILLING_MASK;
1065 if (p_params->pfc.enabled)
1066 *pfc |= DCBX_PFC_ENABLED_MASK;
1068 *pfc &= ~DCBX_PFC_ENABLED_MASK;
1070 *pfc &= ~DCBX_PFC_CAPS_MASK;
1071 *pfc |= (u32)p_params->pfc.max_tc << DCBX_PFC_CAPS_SHIFT;
1073 for (i = 0; i < ECORE_MAX_PFC_PRIORITIES; i++)
1074 if (p_params->pfc.prio[i])
1075 pfc_map |= (0x1 << i);
1077 *pfc |= (pfc_map << DCBX_PFC_PRI_EN_BITMAP_SHIFT);
1079 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB, "pfc = 0x%x\n", *pfc);
1083 ecore_dcbx_set_ets_data(struct ecore_hwfn *p_hwfn,
1084 struct dcbx_ets_feature *p_ets,
1085 struct ecore_dcbx_params *p_params)
1087 u8 *bw_map, *tsa_map;
1090 if (p_params->ets_willing)
1091 p_ets->flags |= DCBX_ETS_WILLING_MASK;
1093 p_ets->flags &= ~DCBX_ETS_WILLING_MASK;
1095 if (p_params->ets_cbs)
1096 p_ets->flags |= DCBX_ETS_CBS_MASK;
1098 p_ets->flags &= ~DCBX_ETS_CBS_MASK;
1100 if (p_params->ets_enabled)
1101 p_ets->flags |= DCBX_ETS_ENABLED_MASK;
1103 p_ets->flags &= ~DCBX_ETS_ENABLED_MASK;
1105 p_ets->flags &= ~DCBX_ETS_MAX_TCS_MASK;
1106 p_ets->flags |= (u32)p_params->max_ets_tc << DCBX_ETS_MAX_TCS_SHIFT;
1108 bw_map = (u8 *)&p_ets->tc_bw_tbl[0];
1109 tsa_map = (u8 *)&p_ets->tc_tsa_tbl[0];
1110 p_ets->pri_tc_tbl[0] = 0;
1111 for (i = 0; i < ECORE_MAX_PFC_PRIORITIES; i++) {
1112 bw_map[i] = p_params->ets_tc_bw_tbl[i];
1113 tsa_map[i] = p_params->ets_tc_tsa_tbl[i];
1114 p_ets->pri_tc_tbl[0] |= (((u32)p_params->ets_pri_tc_tbl[i]) <<
1117 p_ets->pri_tc_tbl[0] = OSAL_CPU_TO_BE32(p_ets->pri_tc_tbl[0]);
1118 for (i = 0; i < 2; i++) {
1119 p_ets->tc_bw_tbl[i] = OSAL_CPU_TO_BE32(p_ets->tc_bw_tbl[i]);
1120 p_ets->tc_tsa_tbl[i] = OSAL_CPU_TO_BE32(p_ets->tc_tsa_tbl[i]);
1125 ecore_dcbx_set_app_data(struct ecore_hwfn *p_hwfn,
1126 struct dcbx_app_priority_feature *p_app,
1127 struct ecore_dcbx_params *p_params, bool ieee)
1132 if (p_params->app_willing)
1133 p_app->flags |= DCBX_APP_WILLING_MASK;
1135 p_app->flags &= ~DCBX_APP_WILLING_MASK;
1137 if (p_params->app_valid)
1138 p_app->flags |= DCBX_APP_ENABLED_MASK;
1140 p_app->flags &= ~DCBX_APP_ENABLED_MASK;
1142 p_app->flags &= ~DCBX_APP_NUM_ENTRIES_MASK;
1143 p_app->flags |= (u32)p_params->num_app_entries <<
1144 DCBX_APP_NUM_ENTRIES_SHIFT;
1146 for (i = 0; i < p_params->num_app_entries; i++) {
1147 entry = &p_app->app_pri_tbl[i].entry;
1149 *entry &= ~DCBX_APP_SF_IEEE_MASK;
1150 switch (p_params->app_entry[i].sf_ieee) {
1151 case ECORE_DCBX_SF_IEEE_ETHTYPE:
1152 *entry |= ((u32)DCBX_APP_SF_IEEE_ETHTYPE <<
1153 DCBX_APP_SF_IEEE_SHIFT);
1155 case ECORE_DCBX_SF_IEEE_TCP_PORT:
1156 *entry |= ((u32)DCBX_APP_SF_IEEE_TCP_PORT <<
1157 DCBX_APP_SF_IEEE_SHIFT);
1159 case ECORE_DCBX_SF_IEEE_UDP_PORT:
1160 *entry |= ((u32)DCBX_APP_SF_IEEE_UDP_PORT <<
1161 DCBX_APP_SF_IEEE_SHIFT);
1163 case ECORE_DCBX_SF_IEEE_TCP_UDP_PORT:
1164 *entry |= (u32)DCBX_APP_SF_IEEE_TCP_UDP_PORT <<
1165 DCBX_APP_SF_IEEE_SHIFT;
1169 *entry &= ~DCBX_APP_SF_MASK;
1170 if (p_params->app_entry[i].ethtype)
1171 *entry |= ((u32)DCBX_APP_SF_ETHTYPE <<
1174 *entry |= ((u32)DCBX_APP_SF_PORT <<
1177 *entry &= ~DCBX_APP_PROTOCOL_ID_MASK;
1178 *entry |= ((u32)p_params->app_entry[i].proto_id <<
1179 DCBX_APP_PROTOCOL_ID_SHIFT);
1180 *entry &= ~DCBX_APP_PRI_MAP_MASK;
1181 *entry |= ((u32)(p_params->app_entry[i].prio) <<
1182 DCBX_APP_PRI_MAP_SHIFT);
1186 static enum _ecore_status_t
1187 ecore_dcbx_set_local_params(struct ecore_hwfn *p_hwfn,
1188 struct dcbx_local_params *local_admin,
1189 struct ecore_dcbx_set *params)
1193 local_admin->flags = 0;
1194 OSAL_MEMCPY(&local_admin->features,
1195 &p_hwfn->p_dcbx_info->operational.features,
1196 sizeof(struct dcbx_features));
1198 if (params->enabled) {
1199 local_admin->config = params->ver_num;
1200 ieee = !!(params->ver_num & DCBX_CONFIG_VERSION_IEEE);
1202 local_admin->config = DCBX_CONFIG_VERSION_DISABLED;
1205 if (params->override_flags & ECORE_DCBX_OVERRIDE_PFC_CFG)
1206 ecore_dcbx_set_pfc_data(p_hwfn, &local_admin->features.pfc,
1207 ¶ms->config.params);
1209 if (params->override_flags & ECORE_DCBX_OVERRIDE_ETS_CFG)
1210 ecore_dcbx_set_ets_data(p_hwfn, &local_admin->features.ets,
1211 ¶ms->config.params);
1213 if (params->override_flags & ECORE_DCBX_OVERRIDE_APP_CFG)
1214 ecore_dcbx_set_app_data(p_hwfn, &local_admin->features.app,
1215 ¶ms->config.params, ieee);
1217 return ECORE_SUCCESS;
1220 static enum _ecore_status_t
1221 ecore_dcbx_set_dscp_params(struct ecore_hwfn *p_hwfn,
1222 struct dcb_dscp_map *p_dscp_map,
1223 struct ecore_dcbx_set *p_params)
1228 OSAL_MEMCPY(p_dscp_map, &p_hwfn->p_dcbx_info->dscp_map,
1229 sizeof(*p_dscp_map));
1231 if (p_params->dscp.enabled)
1232 p_dscp_map->flags |= DCB_DSCP_ENABLE_MASK;
1234 p_dscp_map->flags &= ~DCB_DSCP_ENABLE_MASK;
1236 for (i = 0, entry = 0; i < 8; i++) {
1238 for (j = 0; j < 8; j++, entry++)
1239 val |= (((u32)p_params->dscp.dscp_pri_map[entry]) <<
1242 p_dscp_map->dscp_pri_map[i] = OSAL_CPU_TO_BE32(val);
1245 p_hwfn->p_dcbx_info->dscp_nig_update = true;
1247 return ECORE_SUCCESS;
1250 enum _ecore_status_t ecore_dcbx_config_params(struct ecore_hwfn *p_hwfn,
1251 struct ecore_ptt *p_ptt,
1252 struct ecore_dcbx_set *params,
1255 enum _ecore_status_t rc = ECORE_SUCCESS;
1256 struct ecore_dcbx_mib_meta_data data;
1257 struct dcbx_local_params local_admin;
1258 struct dcb_dscp_map dscp_map;
1259 u32 resp = 0, param = 0;
1262 OSAL_MEMCPY(&p_hwfn->p_dcbx_info->set, params,
1263 sizeof(struct ecore_dcbx_set));
1264 return ECORE_SUCCESS;
1267 /* clear set-parmas cache */
1268 OSAL_MEMSET(&p_hwfn->p_dcbx_info->set, 0,
1269 sizeof(struct ecore_dcbx_set));
1271 OSAL_MEMSET(&local_admin, 0, sizeof(local_admin));
1272 ecore_dcbx_set_local_params(p_hwfn, &local_admin, params);
1274 data.addr = p_hwfn->mcp_info->port_addr +
1275 offsetof(struct public_port, local_admin_dcbx_mib);
1276 data.local_admin = &local_admin;
1277 data.size = sizeof(struct dcbx_local_params);
1278 ecore_memcpy_to(p_hwfn, p_ptt, data.addr, data.local_admin, data.size);
1280 if (params->override_flags & ECORE_DCBX_OVERRIDE_DSCP_CFG) {
1281 OSAL_MEMSET(&dscp_map, 0, sizeof(dscp_map));
1282 ecore_dcbx_set_dscp_params(p_hwfn, &dscp_map, params);
1284 data.addr = p_hwfn->mcp_info->port_addr +
1285 offsetof(struct public_port, dcb_dscp_map);
1286 data.dscp_map = &dscp_map;
1287 data.size = sizeof(struct dcb_dscp_map);
1288 ecore_memcpy_to(p_hwfn, p_ptt, data.addr, data.dscp_map,
1292 rc = ecore_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_SET_DCBX,
1293 1 << DRV_MB_PARAM_LLDP_SEND_SHIFT, &resp, ¶m);
1294 if (rc != ECORE_SUCCESS) {
1295 DP_NOTICE(p_hwfn, false,
1296 "Failed to send DCBX update request\n");
1303 enum _ecore_status_t ecore_dcbx_get_config_params(struct ecore_hwfn *p_hwfn,
1304 struct ecore_dcbx_set *params)
1306 struct ecore_dcbx_get *dcbx_info;
1309 if (p_hwfn->p_dcbx_info->set.config.valid) {
1310 OSAL_MEMCPY(params, &p_hwfn->p_dcbx_info->set,
1311 sizeof(struct ecore_dcbx_set));
1312 return ECORE_SUCCESS;
1315 dcbx_info = OSAL_ALLOC(p_hwfn->p_dev, GFP_KERNEL,
1316 sizeof(struct ecore_dcbx_get));
1318 DP_ERR(p_hwfn, "Failed to allocate struct ecore_dcbx_info\n");
1322 rc = ecore_dcbx_query_params(p_hwfn, dcbx_info,
1323 ECORE_DCBX_OPERATIONAL_MIB);
1325 OSAL_FREE(p_hwfn->p_dev, dcbx_info);
1328 p_hwfn->p_dcbx_info->set.override_flags = 0;
1330 p_hwfn->p_dcbx_info->set.ver_num = DCBX_CONFIG_VERSION_DISABLED;
1331 if (dcbx_info->operational.cee)
1332 p_hwfn->p_dcbx_info->set.ver_num |= DCBX_CONFIG_VERSION_CEE;
1333 if (dcbx_info->operational.ieee)
1334 p_hwfn->p_dcbx_info->set.ver_num |= DCBX_CONFIG_VERSION_IEEE;
1335 if (dcbx_info->operational.local)
1336 p_hwfn->p_dcbx_info->set.ver_num |= DCBX_CONFIG_VERSION_STATIC;
1338 p_hwfn->p_dcbx_info->set.enabled = dcbx_info->operational.enabled;
1339 OSAL_MEMCPY(&p_hwfn->p_dcbx_info->set.config.params,
1340 &dcbx_info->operational.params,
1341 sizeof(p_hwfn->p_dcbx_info->set.config.params));
1342 p_hwfn->p_dcbx_info->set.config.valid = true;
1344 OSAL_MEMCPY(params, &p_hwfn->p_dcbx_info->set,
1345 sizeof(struct ecore_dcbx_set));
1347 OSAL_FREE(p_hwfn->p_dev, dcbx_info);
1349 return ECORE_SUCCESS;