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_MAX_PFC_PRIORITIES 8
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)(pri_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) ==
32 DCBX_APP_SF_ETHTYPE) ? true : false;
35 static bool ecore_dcbx_app_port(u32 app_info_bitmap)
37 return (ECORE_MFW_GET_FIELD(app_info_bitmap, DCBX_APP_SF) ==
38 DCBX_APP_SF_PORT) ? true : false;
41 static bool ecore_dcbx_default_tlv(u32 app_info_bitmap, u16 proto_id)
43 return (ecore_dcbx_app_ethtype(app_info_bitmap) &&
44 proto_id == ECORE_ETH_TYPE_DEFAULT) ? true : false;
47 static bool ecore_dcbx_enabled(u32 dcbx_cfg_bitmap)
49 return (ECORE_MFW_GET_FIELD(dcbx_cfg_bitmap, DCBX_CONFIG_VERSION) ==
50 DCBX_CONFIG_VERSION_DISABLED) ? false : true;
53 static bool ecore_dcbx_cee(u32 dcbx_cfg_bitmap)
55 return (ECORE_MFW_GET_FIELD(dcbx_cfg_bitmap, DCBX_CONFIG_VERSION) ==
56 DCBX_CONFIG_VERSION_CEE) ? true : false;
59 static bool ecore_dcbx_ieee(u32 dcbx_cfg_bitmap)
61 return (ECORE_MFW_GET_FIELD(dcbx_cfg_bitmap, DCBX_CONFIG_VERSION) ==
62 DCBX_CONFIG_VERSION_IEEE) ? true : false;
65 /* @@@TBD A0 Eagle workaround */
66 void ecore_dcbx_eagle_workaround(struct ecore_hwfn *p_hwfn,
67 struct ecore_ptt *p_ptt, bool set_to_pfc)
69 if (!ENABLE_EAGLE_ENG1_WORKAROUND(p_hwfn))
72 ecore_wr(p_hwfn, p_ptt,
73 YSEM_REG_FAST_MEMORY + 0x20000 /* RAM in FASTMEM */ +
74 YSTORM_FLOW_CONTROL_MODE_OFFSET,
75 set_to_pfc ? flow_ctrl_pfc : flow_ctrl_pause);
76 ecore_wr(p_hwfn, p_ptt, NIG_REG_FLOWCTRL_MODE,
77 EAGLE_ENG1_WORKAROUND_NIG_FLOWCTRL_MODE);
81 ecore_dcbx_dp_protocol(struct ecore_hwfn *p_hwfn,
82 struct ecore_dcbx_results *p_data)
84 struct ecore_hw_info *p_info = &p_hwfn->hw_info;
85 enum dcbx_protocol_type id;
88 const char *name; /* @DPDK */
91 size = OSAL_ARRAY_SIZE(ecore_dcbx_app_update);
93 DP_INFO(p_hwfn, "DCBX negotiated: %d\n", p_data->dcbx_enabled);
95 for (i = 0; i < size; i++) {
96 id = ecore_dcbx_app_update[i].id;
97 name = ecore_dcbx_app_update[i].name;
99 enable = p_data->arr[id].enable;
100 update = p_data->arr[id].update;
101 tc = p_data->arr[id].tc;
102 prio = p_data->arr[id].priority;
105 "%s info: update %d, enable %d, prio %d, tc %d, num_tc %d\n",
106 name, update, enable, prio, tc, p_info->num_tc);
111 ecore_dcbx_set_pf_tcs(struct ecore_hw_info *p_info,
112 u8 tc, enum ecore_pci_personality personality)
115 if (p_info->personality == personality) {
116 if (personality == ECORE_PCI_ETH)
117 p_info->non_offload_tc = tc;
119 p_info->offload_tc = tc;
124 ecore_dcbx_set_params(struct ecore_dcbx_results *p_data,
125 struct ecore_hw_info *p_info,
126 bool enable, bool update, u8 prio, u8 tc,
127 enum dcbx_protocol_type type,
128 enum ecore_pci_personality personality)
130 /* PF update ramrod data */
131 p_data->arr[type].update = update;
132 p_data->arr[type].enable = enable;
133 p_data->arr[type].priority = prio;
134 p_data->arr[type].tc = tc;
136 ecore_dcbx_set_pf_tcs(p_info, tc, personality);
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 struct ecore_hw_info *p_info = &p_hwfn->hw_info;
147 enum ecore_pci_personality personality;
148 enum dcbx_protocol_type id;
149 const char *name; /* @DPDK */
153 size = OSAL_ARRAY_SIZE(ecore_dcbx_app_update);
155 for (i = 0; i < size; i++) {
156 id = ecore_dcbx_app_update[i].id;
161 personality = ecore_dcbx_app_update[i].personality;
162 name = ecore_dcbx_app_update[i].name;
164 ecore_dcbx_set_params(p_data, p_info, enable, update,
165 prio, tc, type, personality);
169 static enum _ecore_status_t
170 ecore_dcbx_get_app_priority(u8 pri_bitmap, u8 *priority)
172 u32 pri_mask, pri = ECORE_MAX_PFC_PRIORITIES;
173 u32 index = ECORE_MAX_PFC_PRIORITIES - 1;
174 enum _ecore_status_t rc = ECORE_SUCCESS;
176 /* Bitmap 1 corresponds to priority 0, return priority 0 */
177 if (pri_bitmap == 1) {
182 /* Choose the highest priority */
183 while ((pri == ECORE_MAX_PFC_PRIORITIES) && index) {
184 pri_mask = 1 << index;
185 if (pri_bitmap & pri_mask)
190 if (pri < ECORE_MAX_PFC_PRIORITIES)
199 ecore_dcbx_get_app_protocol_type(struct ecore_hwfn *p_hwfn,
200 u32 app_prio_bitmap, u16 id, int *type)
204 if (ecore_dcbx_default_tlv(app_prio_bitmap, id)) {
205 *type = DCBX_PROTOCOL_ETH;
208 DP_ERR(p_hwfn, "Unsupported protocol %d\n", id);
214 /* Parse app TLV's to update TC information in hw_info structure for
215 * reconfiguring QM. Get protocol specific data for PF update ramrod command.
217 static enum _ecore_status_t
218 ecore_dcbx_process_tlv(struct ecore_hwfn *p_hwfn,
219 struct ecore_dcbx_results *p_data,
220 struct dcbx_app_priority_entry *p_tbl, u32 pri_tc_tbl,
221 int count, bool dcbx_enabled)
223 enum _ecore_status_t rc = ECORE_SUCCESS;
224 u8 tc, priority, priority_map;
229 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB, "Num APP entries = %d\n", count);
232 for (i = 0; i < count; i++) {
233 protocol_id = ECORE_MFW_GET_FIELD(p_tbl[i].entry,
234 DCBX_APP_PROTOCOL_ID);
235 priority_map = ECORE_MFW_GET_FIELD(p_tbl[i].entry,
237 rc = ecore_dcbx_get_app_priority(priority_map, &priority);
238 if (rc == ECORE_INVAL) {
239 DP_ERR(p_hwfn, "Invalid priority\n");
243 tc = ECORE_DCBX_PRIO2TC(pri_tc_tbl, priority);
244 if (ecore_dcbx_get_app_protocol_type(p_hwfn, p_tbl[i].entry,
245 protocol_id, &type)) {
246 /* ETH always have the enable bit reset, as it gets
247 * vlan information per packet. For other protocols,
248 * should be set according to the dcbx_enabled
249 * indication, but we only got here if there was an
250 * app tlv for the protocol, so dcbx must be enabled.
252 enable = (type == DCBX_PROTOCOL_ETH ? false : true);
254 ecore_dcbx_update_app_info(p_data, p_hwfn, enable, true,
258 /* Update ramrod protocol data and hw_info fields
259 * with default info when corresponding APP TLV's are not detected.
260 * The enabled field has a different logic for ethernet as only for
261 * ethernet dcb should disabled by default, as the information arrives
262 * from the OS (unless an explicit app tlv was present).
264 tc = p_data->arr[DCBX_PROTOCOL_ETH].tc;
265 priority = p_data->arr[DCBX_PROTOCOL_ETH].priority;
266 for (type = 0; type < DCBX_MAX_PROTOCOL_TYPE; type++) {
267 if (p_data->arr[type].update)
270 enable = (type == DCBX_PROTOCOL_ETH) ? false : dcbx_enabled;
271 ecore_dcbx_update_app_info(p_data, p_hwfn, enable, true,
275 return ECORE_SUCCESS;
278 /* Parse app TLV's to update TC information in hw_info structure for
279 * reconfiguring QM. Get protocol specific data for PF update ramrod command.
281 static enum _ecore_status_t
282 ecore_dcbx_process_mib_info(struct ecore_hwfn *p_hwfn)
284 struct dcbx_app_priority_feature *p_app;
285 enum _ecore_status_t rc = ECORE_SUCCESS;
286 struct ecore_dcbx_results data = { 0 };
287 struct dcbx_app_priority_entry *p_tbl;
288 struct dcbx_ets_feature *p_ets;
289 struct ecore_hw_info *p_info;
290 u32 pri_tc_tbl, flags;
294 /* If DCBx version is non zero, then negotiation was
295 * successfuly performed
297 flags = p_hwfn->p_dcbx_info->operational.flags;
298 dcbx_enabled = ECORE_MFW_GET_FIELD(flags, DCBX_CONFIG_VERSION) != 0;
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_enabled);
311 if (rc != ECORE_SUCCESS)
314 p_info->num_tc = ECORE_MFW_GET_FIELD(p_ets->flags, DCBX_ETS_MAX_TCS);
315 data.pf_id = p_hwfn->rel_pf_id;
316 data.dcbx_enabled = dcbx_enabled;
318 ecore_dcbx_dp_protocol(p_hwfn, &data);
320 OSAL_MEMCPY(&p_hwfn->p_dcbx_info->results, &data,
321 sizeof(struct ecore_dcbx_results));
323 return ECORE_SUCCESS;
326 static enum _ecore_status_t
327 ecore_dcbx_copy_mib(struct ecore_hwfn *p_hwfn,
328 struct ecore_ptt *p_ptt,
329 struct ecore_dcbx_mib_meta_data *p_data,
330 enum ecore_mib_read_type type)
332 enum _ecore_status_t rc = ECORE_SUCCESS;
333 u32 prefix_seq_num, suffix_seq_num;
337 if (type == ECORE_DCBX_REMOTE_LLDP_MIB) {
338 ecore_memcpy_from(p_hwfn, p_ptt, p_data->lldp_remote,
339 p_data->addr, p_data->size);
340 prefix_seq_num = p_data->lldp_remote->prefix_seq_num;
341 suffix_seq_num = p_data->lldp_remote->suffix_seq_num;
343 ecore_memcpy_from(p_hwfn, p_ptt, p_data->mib,
344 p_data->addr, p_data->size);
345 prefix_seq_num = p_data->mib->prefix_seq_num;
346 suffix_seq_num = p_data->mib->suffix_seq_num;
350 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
351 "mib type = %d, try count = %d prefix seq num ="
352 " %d suffix seq num = %d\n",
353 type, read_count, prefix_seq_num, suffix_seq_num);
354 } while ((prefix_seq_num != suffix_seq_num) &&
355 (read_count < ECORE_DCBX_MAX_MIB_READ_TRY));
357 if (read_count >= ECORE_DCBX_MAX_MIB_READ_TRY) {
359 "MIB read err, mib type = %d, try count ="
360 " %d prefix seq num = %d suffix seq num = %d\n",
361 type, read_count, prefix_seq_num, suffix_seq_num);
368 static enum _ecore_status_t
369 ecore_dcbx_get_priority_info(struct ecore_hwfn *p_hwfn,
370 struct ecore_dcbx_app_prio *p_prio,
371 struct ecore_dcbx_results *p_results)
373 enum _ecore_status_t rc = ECORE_SUCCESS;
375 if (p_results->arr[DCBX_PROTOCOL_ETH].update &&
376 p_results->arr[DCBX_PROTOCOL_ETH].enable) {
377 p_prio->eth = p_results->arr[DCBX_PROTOCOL_ETH].priority;
378 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
379 "Priority: eth %d\n", p_prio->eth);
386 ecore_dcbx_get_app_data(struct ecore_hwfn *p_hwfn,
387 struct dcbx_app_priority_feature *p_app,
388 struct dcbx_app_priority_entry *p_tbl,
389 struct ecore_dcbx_params *p_params)
393 p_params->app_willing = ECORE_MFW_GET_FIELD(p_app->flags,
395 p_params->app_valid = ECORE_MFW_GET_FIELD(p_app->flags,
397 p_params->num_app_entries = ECORE_MFW_GET_FIELD(p_app->flags,
399 for (i = 0; i < DCBX_MAX_APP_PROTOCOL; i++)
400 p_params->app_bitmap[i] = p_tbl[i].entry;
402 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
403 "APP params: willing %d, valid %d\n",
404 p_params->app_willing, p_params->app_valid);
408 ecore_dcbx_get_pfc_data(struct ecore_hwfn *p_hwfn,
409 u32 pfc, struct ecore_dcbx_params *p_params)
411 p_params->pfc_willing = ECORE_MFW_GET_FIELD(pfc, DCBX_PFC_WILLING);
412 p_params->max_pfc_tc = ECORE_MFW_GET_FIELD(pfc, DCBX_PFC_CAPS);
413 p_params->pfc_enabled = ECORE_MFW_GET_FIELD(pfc, DCBX_PFC_ENABLED);
414 p_params->pfc_bitmap = pfc;
416 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
417 "PFC params: willing %d, pfc_bitmap %d\n",
418 p_params->pfc_willing, p_params->pfc_bitmap);
422 ecore_dcbx_get_ets_data(struct ecore_hwfn *p_hwfn,
423 struct dcbx_ets_feature *p_ets,
424 struct ecore_dcbx_params *p_params)
428 p_params->ets_willing = ECORE_MFW_GET_FIELD(p_ets->flags,
430 p_params->ets_enabled = ECORE_MFW_GET_FIELD(p_ets->flags,
432 p_params->max_ets_tc = ECORE_MFW_GET_FIELD(p_ets->flags,
434 p_params->ets_pri_tc_tbl[0] = p_ets->pri_tc_tbl[0];
436 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
437 "ETS params: willing %d, pri_tc_tbl_0 %x max_ets_tc %d\n",
438 p_params->ets_willing, p_params->ets_pri_tc_tbl[0],
439 p_params->max_ets_tc);
441 /* 8 bit tsa and bw data corresponding to each of the 8 TC's are
442 * encoded in a type u32 array of size 2.
444 for (i = 0; i < 2; i++) {
445 p_params->ets_tc_tsa_tbl[i] = p_ets->tc_tsa_tbl[i];
446 p_params->ets_tc_bw_tbl[i] = p_ets->tc_bw_tbl[i];
448 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
449 "elem %d bw_tbl %x tsa_tbl %x\n",
450 i, p_params->ets_tc_bw_tbl[i],
451 p_params->ets_tc_tsa_tbl[i]);
455 static enum _ecore_status_t
456 ecore_dcbx_get_common_params(struct ecore_hwfn *p_hwfn,
457 struct dcbx_app_priority_feature *p_app,
458 struct dcbx_app_priority_entry *p_tbl,
459 struct dcbx_ets_feature *p_ets,
460 u32 pfc, struct ecore_dcbx_params *p_params)
462 ecore_dcbx_get_app_data(p_hwfn, p_app, p_tbl, p_params);
463 ecore_dcbx_get_ets_data(p_hwfn, p_ets, p_params);
464 ecore_dcbx_get_pfc_data(p_hwfn, pfc, p_params);
466 return ECORE_SUCCESS;
469 static enum _ecore_status_t
470 ecore_dcbx_get_local_params(struct ecore_hwfn *p_hwfn,
471 struct ecore_ptt *p_ptt,
472 struct ecore_dcbx_get *params)
474 struct ecore_dcbx_admin_params *p_local;
475 struct dcbx_app_priority_feature *p_app;
476 struct dcbx_app_priority_entry *p_tbl;
477 struct ecore_dcbx_params *p_data;
478 struct dcbx_ets_feature *p_ets;
481 p_local = ¶ms->local;
482 p_data = &p_local->params;
483 p_app = &p_hwfn->p_dcbx_info->local_admin.features.app;
484 p_tbl = p_app->app_pri_tbl;
485 p_ets = &p_hwfn->p_dcbx_info->local_admin.features.ets;
486 pfc = p_hwfn->p_dcbx_info->local_admin.features.pfc;
488 ecore_dcbx_get_common_params(p_hwfn, p_app, p_tbl, p_ets, pfc, p_data);
489 p_local->valid = true;
491 return ECORE_SUCCESS;
494 static enum _ecore_status_t
495 ecore_dcbx_get_remote_params(struct ecore_hwfn *p_hwfn,
496 struct ecore_ptt *p_ptt,
497 struct ecore_dcbx_get *params)
499 struct ecore_dcbx_remote_params *p_remote;
500 struct dcbx_app_priority_feature *p_app;
501 struct dcbx_app_priority_entry *p_tbl;
502 struct ecore_dcbx_params *p_data;
503 struct dcbx_ets_feature *p_ets;
506 p_remote = ¶ms->remote;
507 p_data = &p_remote->params;
508 p_app = &p_hwfn->p_dcbx_info->remote.features.app;
509 p_tbl = p_app->app_pri_tbl;
510 p_ets = &p_hwfn->p_dcbx_info->remote.features.ets;
511 pfc = p_hwfn->p_dcbx_info->remote.features.pfc;
513 ecore_dcbx_get_common_params(p_hwfn, p_app, p_tbl, p_ets, pfc, p_data);
514 p_remote->valid = true;
516 return ECORE_SUCCESS;
519 static enum _ecore_status_t
520 ecore_dcbx_get_operational_params(struct ecore_hwfn *p_hwfn,
521 struct ecore_ptt *p_ptt,
522 struct ecore_dcbx_get *params)
524 struct ecore_dcbx_operational_params *p_operational;
525 enum _ecore_status_t rc = ECORE_SUCCESS;
526 struct dcbx_app_priority_feature *p_app;
527 struct dcbx_app_priority_entry *p_tbl;
528 struct ecore_dcbx_results *p_results;
529 struct ecore_dcbx_params *p_data;
530 struct dcbx_ets_feature *p_ets;
534 flags = p_hwfn->p_dcbx_info->operational.flags;
536 /* If DCBx version is non zero, then negotiation
537 * was successfuly performed
539 p_operational = ¶ms->operational;
540 enabled = ecore_dcbx_enabled(flags);
542 p_operational->enabled = enabled;
543 p_operational->valid = false;
547 p_data = &p_operational->params;
548 p_results = &p_hwfn->p_dcbx_info->results;
549 p_app = &p_hwfn->p_dcbx_info->operational.features.app;
550 p_tbl = p_app->app_pri_tbl;
551 p_ets = &p_hwfn->p_dcbx_info->operational.features.ets;
552 pfc = p_hwfn->p_dcbx_info->operational.features.pfc;
554 p_operational->ieee = ecore_dcbx_ieee(flags);
555 p_operational->cee = ecore_dcbx_cee(flags);
557 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
558 "Version support: ieee %d, cee %d\n",
559 p_operational->ieee, p_operational->cee);
561 ecore_dcbx_get_common_params(p_hwfn, p_app, p_tbl, p_ets, pfc, p_data);
562 ecore_dcbx_get_priority_info(p_hwfn, &p_operational->app_prio,
564 err = ECORE_MFW_GET_FIELD(p_app->flags, DCBX_APP_ERROR);
565 p_operational->err = err;
566 p_operational->enabled = enabled;
567 p_operational->valid = true;
572 static enum _ecore_status_t
573 ecore_dcbx_get_local_lldp_params(struct ecore_hwfn *p_hwfn,
574 struct ecore_ptt *p_ptt,
575 struct ecore_dcbx_get *params)
577 struct ecore_dcbx_lldp_local *p_local;
581 p_local = ¶ms->lldp_local;
583 size = OSAL_ARRAY_SIZE(p_local->local_chassis_id);
584 dest = p_hwfn->p_dcbx_info->get.lldp_local.local_chassis_id;
585 OSAL_MEMCPY(dest, p_local->local_chassis_id, size);
587 size = OSAL_ARRAY_SIZE(p_local->local_port_id);
588 dest = p_hwfn->p_dcbx_info->get.lldp_local.local_port_id;
589 OSAL_MEMCPY(dest, p_local->local_port_id, size);
591 return ECORE_SUCCESS;
594 static enum _ecore_status_t
595 ecore_dcbx_get_remote_lldp_params(struct ecore_hwfn *p_hwfn,
596 struct ecore_ptt *p_ptt,
597 struct ecore_dcbx_get *params)
599 struct ecore_dcbx_lldp_remote *p_remote;
603 p_remote = ¶ms->lldp_remote;
605 size = OSAL_ARRAY_SIZE(p_remote->peer_chassis_id);
606 dest = p_hwfn->p_dcbx_info->get.lldp_remote.peer_chassis_id;
607 OSAL_MEMCPY(dest, p_remote->peer_chassis_id, size);
609 size = OSAL_ARRAY_SIZE(p_remote->peer_port_id);
610 dest = p_hwfn->p_dcbx_info->get.lldp_remote.peer_port_id;
611 OSAL_MEMCPY(dest, p_remote->peer_port_id, size);
613 return ECORE_SUCCESS;
616 static enum _ecore_status_t
617 ecore_dcbx_get_params(struct ecore_hwfn *p_hwfn,
618 struct ecore_ptt *p_ptt, enum ecore_mib_read_type type)
620 enum _ecore_status_t rc = ECORE_SUCCESS;
621 struct ecore_dcbx_get *p_params;
623 p_params = &p_hwfn->p_dcbx_info->get;
626 case ECORE_DCBX_REMOTE_MIB:
627 ecore_dcbx_get_remote_params(p_hwfn, p_ptt, p_params);
629 case ECORE_DCBX_LOCAL_MIB:
630 ecore_dcbx_get_local_params(p_hwfn, p_ptt, p_params);
632 case ECORE_DCBX_OPERATIONAL_MIB:
633 ecore_dcbx_get_operational_params(p_hwfn, p_ptt, p_params);
635 case ECORE_DCBX_REMOTE_LLDP_MIB:
636 rc = ecore_dcbx_get_remote_lldp_params(p_hwfn, p_ptt, p_params);
638 case ECORE_DCBX_LOCAL_LLDP_MIB:
639 rc = ecore_dcbx_get_local_lldp_params(p_hwfn, p_ptt, p_params);
642 DP_ERR(p_hwfn, "MIB read err, unknown mib type %d\n", type);
649 static enum _ecore_status_t
650 ecore_dcbx_read_local_lldp_mib(struct ecore_hwfn *p_hwfn,
651 struct ecore_ptt *p_ptt)
653 enum _ecore_status_t rc = ECORE_SUCCESS;
654 struct ecore_dcbx_mib_meta_data data;
656 data.addr = p_hwfn->mcp_info->port_addr + offsetof(struct public_port,
658 data.lldp_local = p_hwfn->p_dcbx_info->lldp_local;
659 data.size = sizeof(struct lldp_config_params_s);
660 ecore_memcpy_from(p_hwfn, p_ptt, data.lldp_local, data.addr, data.size);
665 static enum _ecore_status_t
666 ecore_dcbx_read_remote_lldp_mib(struct ecore_hwfn *p_hwfn,
667 struct ecore_ptt *p_ptt,
668 enum ecore_mib_read_type type)
670 enum _ecore_status_t rc = ECORE_SUCCESS;
671 struct ecore_dcbx_mib_meta_data data;
673 data.addr = p_hwfn->mcp_info->port_addr + offsetof(struct public_port,
675 data.lldp_remote = p_hwfn->p_dcbx_info->lldp_remote;
676 data.size = sizeof(struct lldp_status_params_s);
677 rc = ecore_dcbx_copy_mib(p_hwfn, p_ptt, &data, type);
682 static enum _ecore_status_t
683 ecore_dcbx_read_operational_mib(struct ecore_hwfn *p_hwfn,
684 struct ecore_ptt *p_ptt,
685 enum ecore_mib_read_type type)
687 struct ecore_dcbx_mib_meta_data data;
688 enum _ecore_status_t rc = ECORE_SUCCESS;
690 data.addr = p_hwfn->mcp_info->port_addr +
691 offsetof(struct public_port, operational_dcbx_mib);
692 data.mib = &p_hwfn->p_dcbx_info->operational;
693 data.size = sizeof(struct dcbx_mib);
694 rc = ecore_dcbx_copy_mib(p_hwfn, p_ptt, &data, type);
699 static enum _ecore_status_t
700 ecore_dcbx_read_remote_mib(struct ecore_hwfn *p_hwfn,
701 struct ecore_ptt *p_ptt,
702 enum ecore_mib_read_type type)
704 struct ecore_dcbx_mib_meta_data data;
705 enum _ecore_status_t rc = ECORE_SUCCESS;
707 data.addr = p_hwfn->mcp_info->port_addr +
708 offsetof(struct public_port, remote_dcbx_mib);
709 data.mib = &p_hwfn->p_dcbx_info->remote;
710 data.size = sizeof(struct dcbx_mib);
711 rc = ecore_dcbx_copy_mib(p_hwfn, p_ptt, &data, type);
716 static enum _ecore_status_t
717 ecore_dcbx_read_local_mib(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt)
719 struct ecore_dcbx_mib_meta_data data;
720 enum _ecore_status_t rc = ECORE_SUCCESS;
722 data.addr = p_hwfn->mcp_info->port_addr +
723 offsetof(struct public_port, local_admin_dcbx_mib);
724 data.local_admin = &p_hwfn->p_dcbx_info->local_admin;
725 data.size = sizeof(struct dcbx_local_params);
726 ecore_memcpy_from(p_hwfn, p_ptt, data.local_admin,
727 data.addr, data.size);
732 static enum _ecore_status_t ecore_dcbx_read_mib(struct ecore_hwfn *p_hwfn,
733 struct ecore_ptt *p_ptt,
734 enum ecore_mib_read_type type)
736 enum _ecore_status_t rc = ECORE_SUCCESS;
739 case ECORE_DCBX_OPERATIONAL_MIB:
740 rc = ecore_dcbx_read_operational_mib(p_hwfn, p_ptt, type);
742 case ECORE_DCBX_REMOTE_MIB:
743 rc = ecore_dcbx_read_remote_mib(p_hwfn, p_ptt, type);
745 case ECORE_DCBX_LOCAL_MIB:
746 rc = ecore_dcbx_read_local_mib(p_hwfn, p_ptt);
748 case ECORE_DCBX_REMOTE_LLDP_MIB:
749 rc = ecore_dcbx_read_remote_lldp_mib(p_hwfn, p_ptt, type);
751 case ECORE_DCBX_LOCAL_LLDP_MIB:
752 rc = ecore_dcbx_read_local_lldp_mib(p_hwfn, p_ptt);
755 DP_ERR(p_hwfn, "MIB read err, unknown mib type %d\n", type);
764 * Reconfigure QM and invoke PF update ramrod command if operational MIB
765 * change is detected.
768 ecore_dcbx_mib_update_event(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
769 enum ecore_mib_read_type type)
771 enum _ecore_status_t rc = ECORE_SUCCESS;
773 rc = ecore_dcbx_read_mib(p_hwfn, p_ptt, type);
777 if (type == ECORE_DCBX_OPERATIONAL_MIB) {
778 rc = ecore_dcbx_process_mib_info(p_hwfn);
782 /* reconfigure tcs of QM queues according
783 * to negotiation results
785 ecore_qm_reconf(p_hwfn, p_ptt);
787 /* update storm FW with negotiation results */
788 ecore_sp_pf_update(p_hwfn);
790 /* set eagle enigne 1 flow control workaround
791 * according to negotiation results
793 enabled = p_hwfn->p_dcbx_info->results.dcbx_enabled;
794 ecore_dcbx_eagle_workaround(p_hwfn, p_ptt, enabled);
797 ecore_dcbx_get_params(p_hwfn, p_ptt, type);
798 OSAL_DCBX_AEN(p_hwfn, type);
803 enum _ecore_status_t ecore_dcbx_info_alloc(struct ecore_hwfn *p_hwfn)
805 enum _ecore_status_t rc = ECORE_SUCCESS;
807 p_hwfn->p_dcbx_info = OSAL_ZALLOC(p_hwfn->p_dev, GFP_KERNEL,
808 sizeof(struct ecore_dcbx_info));
809 if (!p_hwfn->p_dcbx_info) {
810 DP_NOTICE(p_hwfn, true,
811 "Failed to allocate `struct ecore_dcbx_info'");
818 void ecore_dcbx_info_free(struct ecore_hwfn *p_hwfn,
819 struct ecore_dcbx_info *p_dcbx_info)
821 OSAL_FREE(p_hwfn->p_dev, p_hwfn->p_dcbx_info);
824 static void ecore_dcbx_update_protocol_data(struct protocol_dcb_data *p_data,
825 struct ecore_dcbx_results *p_src,
826 enum dcbx_protocol_type type)
828 p_data->dcb_enable_flag = p_src->arr[type].enable;
829 p_data->dcb_priority = p_src->arr[type].priority;
830 p_data->dcb_tc = p_src->arr[type].tc;
833 /* Set pf update ramrod command params */
834 void ecore_dcbx_set_pf_update_params(struct ecore_dcbx_results *p_src,
835 struct pf_update_ramrod_data *p_dest)
837 struct protocol_dcb_data *p_dcb_data;
840 p_dest->pf_id = p_src->pf_id;
842 update_flag = p_src->arr[DCBX_PROTOCOL_ETH].update;
843 p_dest->update_eth_dcb_data_flag = update_flag;
845 p_dcb_data = &p_dest->eth_dcb_data;
846 ecore_dcbx_update_protocol_data(p_dcb_data, p_src, DCBX_PROTOCOL_ETH);
850 enum _ecore_status_t ecore_dcbx_query(struct ecore_hwfn *p_hwfn,
851 enum ecore_mib_read_type type)
853 struct ecore_ptt *p_ptt;
854 enum _ecore_status_t rc;
856 p_ptt = ecore_ptt_acquire(p_hwfn);
859 DP_ERR(p_hwfn, "rc = %d\n", rc);
863 rc = ecore_dcbx_read_mib(p_hwfn, p_ptt, type);
864 if (rc != ECORE_SUCCESS)
867 rc = ecore_dcbx_get_params(p_hwfn, p_ptt, type);
870 ecore_ptt_release(p_hwfn, p_ptt);
874 enum _ecore_status_t ecore_dcbx_query_params(struct ecore_hwfn *p_hwfn,
875 struct ecore_dcbx_get *p_get,
876 enum ecore_mib_read_type type)
878 enum _ecore_status_t rc;
880 rc = ecore_dcbx_query(p_hwfn, type);
884 if (p_get != OSAL_NULL)
885 OSAL_MEMCPY(p_get, &p_hwfn->p_dcbx_info->get,
886 sizeof(struct ecore_dcbx_get));