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 = %d suffix seq num = %d\n",
352 type, read_count, prefix_seq_num, suffix_seq_num);
353 } while ((prefix_seq_num != suffix_seq_num) &&
354 (read_count < ECORE_DCBX_MAX_MIB_READ_TRY));
356 if (read_count >= ECORE_DCBX_MAX_MIB_READ_TRY) {
358 "MIB read err, mib type = %d, try count = %d prefix seq num = %d suffix seq num = %d\n",
359 type, read_count, prefix_seq_num, suffix_seq_num);
366 static enum _ecore_status_t
367 ecore_dcbx_get_priority_info(struct ecore_hwfn *p_hwfn,
368 struct ecore_dcbx_app_prio *p_prio,
369 struct ecore_dcbx_results *p_results)
371 enum _ecore_status_t rc = ECORE_SUCCESS;
373 if (p_results->arr[DCBX_PROTOCOL_ETH].update &&
374 p_results->arr[DCBX_PROTOCOL_ETH].enable) {
375 p_prio->eth = p_results->arr[DCBX_PROTOCOL_ETH].priority;
376 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
377 "Priority: eth %d\n", p_prio->eth);
384 ecore_dcbx_get_app_data(struct ecore_hwfn *p_hwfn,
385 struct dcbx_app_priority_feature *p_app,
386 struct dcbx_app_priority_entry *p_tbl,
387 struct ecore_dcbx_params *p_params)
391 p_params->app_willing = ECORE_MFW_GET_FIELD(p_app->flags,
393 p_params->app_valid = ECORE_MFW_GET_FIELD(p_app->flags,
395 p_params->num_app_entries = ECORE_MFW_GET_FIELD(p_app->flags,
397 for (i = 0; i < DCBX_MAX_APP_PROTOCOL; i++)
398 p_params->app_bitmap[i] = p_tbl[i].entry;
400 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
401 "APP params: willing %d, valid %d\n",
402 p_params->app_willing, p_params->app_valid);
406 ecore_dcbx_get_pfc_data(struct ecore_hwfn *p_hwfn,
407 u32 pfc, struct ecore_dcbx_params *p_params)
409 p_params->pfc_willing = ECORE_MFW_GET_FIELD(pfc, DCBX_PFC_WILLING);
410 p_params->max_pfc_tc = ECORE_MFW_GET_FIELD(pfc, DCBX_PFC_CAPS);
411 p_params->pfc_enabled = ECORE_MFW_GET_FIELD(pfc, DCBX_PFC_ENABLED);
412 p_params->pfc_bitmap = pfc;
414 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
415 "PFC params: willing %d, pfc_bitmap %d\n",
416 p_params->pfc_willing, p_params->pfc_bitmap);
420 ecore_dcbx_get_ets_data(struct ecore_hwfn *p_hwfn,
421 struct dcbx_ets_feature *p_ets,
422 struct ecore_dcbx_params *p_params)
426 p_params->ets_willing = ECORE_MFW_GET_FIELD(p_ets->flags,
428 p_params->ets_enabled = ECORE_MFW_GET_FIELD(p_ets->flags,
430 p_params->max_ets_tc = ECORE_MFW_GET_FIELD(p_ets->flags,
432 p_params->ets_pri_tc_tbl[0] = p_ets->pri_tc_tbl[0];
434 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
435 "ETS params: willing %d, pri_tc_tbl_0 %x max_ets_tc %d\n",
436 p_params->ets_willing, p_params->ets_pri_tc_tbl[0],
437 p_params->max_ets_tc);
439 /* 8 bit tsa and bw data corresponding to each of the 8 TC's are
440 * encoded in a type u32 array of size 2.
442 for (i = 0; i < 2; i++) {
443 p_params->ets_tc_tsa_tbl[i] = p_ets->tc_tsa_tbl[i];
444 p_params->ets_tc_bw_tbl[i] = p_ets->tc_bw_tbl[i];
446 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
447 "elem %d bw_tbl %x tsa_tbl %x\n",
448 i, p_params->ets_tc_bw_tbl[i],
449 p_params->ets_tc_tsa_tbl[i]);
453 static enum _ecore_status_t
454 ecore_dcbx_get_common_params(struct ecore_hwfn *p_hwfn,
455 struct dcbx_app_priority_feature *p_app,
456 struct dcbx_app_priority_entry *p_tbl,
457 struct dcbx_ets_feature *p_ets,
458 u32 pfc, struct ecore_dcbx_params *p_params)
460 ecore_dcbx_get_app_data(p_hwfn, p_app, p_tbl, p_params);
461 ecore_dcbx_get_ets_data(p_hwfn, p_ets, p_params);
462 ecore_dcbx_get_pfc_data(p_hwfn, pfc, p_params);
464 return ECORE_SUCCESS;
467 static enum _ecore_status_t
468 ecore_dcbx_get_local_params(struct ecore_hwfn *p_hwfn,
469 struct ecore_ptt *p_ptt,
470 struct ecore_dcbx_get *params)
472 struct ecore_dcbx_admin_params *p_local;
473 struct dcbx_app_priority_feature *p_app;
474 struct dcbx_app_priority_entry *p_tbl;
475 struct ecore_dcbx_params *p_data;
476 struct dcbx_ets_feature *p_ets;
479 p_local = ¶ms->local;
480 p_data = &p_local->params;
481 p_app = &p_hwfn->p_dcbx_info->local_admin.features.app;
482 p_tbl = p_app->app_pri_tbl;
483 p_ets = &p_hwfn->p_dcbx_info->local_admin.features.ets;
484 pfc = p_hwfn->p_dcbx_info->local_admin.features.pfc;
486 ecore_dcbx_get_common_params(p_hwfn, p_app, p_tbl, p_ets, pfc, p_data);
487 p_local->valid = true;
489 return ECORE_SUCCESS;
492 static enum _ecore_status_t
493 ecore_dcbx_get_remote_params(struct ecore_hwfn *p_hwfn,
494 struct ecore_ptt *p_ptt,
495 struct ecore_dcbx_get *params)
497 struct ecore_dcbx_remote_params *p_remote;
498 struct dcbx_app_priority_feature *p_app;
499 struct dcbx_app_priority_entry *p_tbl;
500 struct ecore_dcbx_params *p_data;
501 struct dcbx_ets_feature *p_ets;
504 p_remote = ¶ms->remote;
505 p_data = &p_remote->params;
506 p_app = &p_hwfn->p_dcbx_info->remote.features.app;
507 p_tbl = p_app->app_pri_tbl;
508 p_ets = &p_hwfn->p_dcbx_info->remote.features.ets;
509 pfc = p_hwfn->p_dcbx_info->remote.features.pfc;
511 ecore_dcbx_get_common_params(p_hwfn, p_app, p_tbl, p_ets, pfc, p_data);
512 p_remote->valid = true;
514 return ECORE_SUCCESS;
517 static enum _ecore_status_t
518 ecore_dcbx_get_operational_params(struct ecore_hwfn *p_hwfn,
519 struct ecore_ptt *p_ptt,
520 struct ecore_dcbx_get *params)
522 struct ecore_dcbx_operational_params *p_operational;
523 enum _ecore_status_t rc = ECORE_SUCCESS;
524 struct dcbx_app_priority_feature *p_app;
525 struct dcbx_app_priority_entry *p_tbl;
526 struct ecore_dcbx_results *p_results;
527 struct ecore_dcbx_params *p_data;
528 struct dcbx_ets_feature *p_ets;
532 flags = p_hwfn->p_dcbx_info->operational.flags;
534 /* If DCBx version is non zero, then negotiation
535 * was successfuly performed
537 p_operational = ¶ms->operational;
538 enabled = ecore_dcbx_enabled(flags);
540 p_operational->enabled = enabled;
541 p_operational->valid = false;
545 p_data = &p_operational->params;
546 p_results = &p_hwfn->p_dcbx_info->results;
547 p_app = &p_hwfn->p_dcbx_info->operational.features.app;
548 p_tbl = p_app->app_pri_tbl;
549 p_ets = &p_hwfn->p_dcbx_info->operational.features.ets;
550 pfc = p_hwfn->p_dcbx_info->operational.features.pfc;
552 p_operational->ieee = ecore_dcbx_ieee(flags);
553 p_operational->cee = ecore_dcbx_cee(flags);
555 DP_VERBOSE(p_hwfn, ECORE_MSG_DCB,
556 "Version support: ieee %d, cee %d\n",
557 p_operational->ieee, p_operational->cee);
559 ecore_dcbx_get_common_params(p_hwfn, p_app, p_tbl, p_ets, pfc, p_data);
560 ecore_dcbx_get_priority_info(p_hwfn, &p_operational->app_prio,
562 err = ECORE_MFW_GET_FIELD(p_app->flags, DCBX_APP_ERROR);
563 p_operational->err = err;
564 p_operational->enabled = enabled;
565 p_operational->valid = true;
570 static enum _ecore_status_t
571 ecore_dcbx_get_local_lldp_params(struct ecore_hwfn *p_hwfn,
572 struct ecore_ptt *p_ptt,
573 struct ecore_dcbx_get *params)
575 struct ecore_dcbx_lldp_local *p_local;
579 p_local = ¶ms->lldp_local;
581 size = OSAL_ARRAY_SIZE(p_local->local_chassis_id);
582 dest = p_hwfn->p_dcbx_info->get.lldp_local.local_chassis_id;
583 OSAL_MEMCPY(dest, p_local->local_chassis_id, size);
585 size = OSAL_ARRAY_SIZE(p_local->local_port_id);
586 dest = p_hwfn->p_dcbx_info->get.lldp_local.local_port_id;
587 OSAL_MEMCPY(dest, p_local->local_port_id, size);
589 return ECORE_SUCCESS;
592 static enum _ecore_status_t
593 ecore_dcbx_get_remote_lldp_params(struct ecore_hwfn *p_hwfn,
594 struct ecore_ptt *p_ptt,
595 struct ecore_dcbx_get *params)
597 struct ecore_dcbx_lldp_remote *p_remote;
601 p_remote = ¶ms->lldp_remote;
603 size = OSAL_ARRAY_SIZE(p_remote->peer_chassis_id);
604 dest = p_hwfn->p_dcbx_info->get.lldp_remote.peer_chassis_id;
605 OSAL_MEMCPY(dest, p_remote->peer_chassis_id, size);
607 size = OSAL_ARRAY_SIZE(p_remote->peer_port_id);
608 dest = p_hwfn->p_dcbx_info->get.lldp_remote.peer_port_id;
609 OSAL_MEMCPY(dest, p_remote->peer_port_id, size);
611 return ECORE_SUCCESS;
614 static enum _ecore_status_t
615 ecore_dcbx_get_params(struct ecore_hwfn *p_hwfn,
616 struct ecore_ptt *p_ptt, enum ecore_mib_read_type type)
618 enum _ecore_status_t rc = ECORE_SUCCESS;
619 struct ecore_dcbx_get *p_params;
621 p_params = &p_hwfn->p_dcbx_info->get;
624 case ECORE_DCBX_REMOTE_MIB:
625 ecore_dcbx_get_remote_params(p_hwfn, p_ptt, p_params);
627 case ECORE_DCBX_LOCAL_MIB:
628 ecore_dcbx_get_local_params(p_hwfn, p_ptt, p_params);
630 case ECORE_DCBX_OPERATIONAL_MIB:
631 ecore_dcbx_get_operational_params(p_hwfn, p_ptt, p_params);
633 case ECORE_DCBX_REMOTE_LLDP_MIB:
634 rc = ecore_dcbx_get_remote_lldp_params(p_hwfn, p_ptt, p_params);
636 case ECORE_DCBX_LOCAL_LLDP_MIB:
637 rc = ecore_dcbx_get_local_lldp_params(p_hwfn, p_ptt, p_params);
640 DP_ERR(p_hwfn, "MIB read err, unknown mib type %d\n", type);
647 static enum _ecore_status_t
648 ecore_dcbx_read_local_lldp_mib(struct ecore_hwfn *p_hwfn,
649 struct ecore_ptt *p_ptt)
651 enum _ecore_status_t rc = ECORE_SUCCESS;
652 struct ecore_dcbx_mib_meta_data data;
654 data.addr = p_hwfn->mcp_info->port_addr + offsetof(struct public_port,
656 data.lldp_local = p_hwfn->p_dcbx_info->lldp_local;
657 data.size = sizeof(struct lldp_config_params_s);
658 ecore_memcpy_from(p_hwfn, p_ptt, data.lldp_local, data.addr, data.size);
663 static enum _ecore_status_t
664 ecore_dcbx_read_remote_lldp_mib(struct ecore_hwfn *p_hwfn,
665 struct ecore_ptt *p_ptt,
666 enum ecore_mib_read_type type)
668 enum _ecore_status_t rc = ECORE_SUCCESS;
669 struct ecore_dcbx_mib_meta_data data;
671 data.addr = p_hwfn->mcp_info->port_addr + offsetof(struct public_port,
673 data.lldp_remote = p_hwfn->p_dcbx_info->lldp_remote;
674 data.size = sizeof(struct lldp_status_params_s);
675 rc = ecore_dcbx_copy_mib(p_hwfn, p_ptt, &data, type);
680 static enum _ecore_status_t
681 ecore_dcbx_read_operational_mib(struct ecore_hwfn *p_hwfn,
682 struct ecore_ptt *p_ptt,
683 enum ecore_mib_read_type type)
685 struct ecore_dcbx_mib_meta_data data;
686 enum _ecore_status_t rc = ECORE_SUCCESS;
688 data.addr = p_hwfn->mcp_info->port_addr +
689 offsetof(struct public_port, operational_dcbx_mib);
690 data.mib = &p_hwfn->p_dcbx_info->operational;
691 data.size = sizeof(struct dcbx_mib);
692 rc = ecore_dcbx_copy_mib(p_hwfn, p_ptt, &data, type);
697 static enum _ecore_status_t
698 ecore_dcbx_read_remote_mib(struct ecore_hwfn *p_hwfn,
699 struct ecore_ptt *p_ptt,
700 enum ecore_mib_read_type type)
702 struct ecore_dcbx_mib_meta_data data;
703 enum _ecore_status_t rc = ECORE_SUCCESS;
705 data.addr = p_hwfn->mcp_info->port_addr +
706 offsetof(struct public_port, remote_dcbx_mib);
707 data.mib = &p_hwfn->p_dcbx_info->remote;
708 data.size = sizeof(struct dcbx_mib);
709 rc = ecore_dcbx_copy_mib(p_hwfn, p_ptt, &data, type);
714 static enum _ecore_status_t
715 ecore_dcbx_read_local_mib(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt)
717 struct ecore_dcbx_mib_meta_data data;
718 enum _ecore_status_t rc = ECORE_SUCCESS;
720 data.addr = p_hwfn->mcp_info->port_addr +
721 offsetof(struct public_port, local_admin_dcbx_mib);
722 data.local_admin = &p_hwfn->p_dcbx_info->local_admin;
723 data.size = sizeof(struct dcbx_local_params);
724 ecore_memcpy_from(p_hwfn, p_ptt, data.local_admin,
725 data.addr, data.size);
730 static enum _ecore_status_t ecore_dcbx_read_mib(struct ecore_hwfn *p_hwfn,
731 struct ecore_ptt *p_ptt,
732 enum ecore_mib_read_type type)
734 enum _ecore_status_t rc = ECORE_SUCCESS;
737 case ECORE_DCBX_OPERATIONAL_MIB:
738 rc = ecore_dcbx_read_operational_mib(p_hwfn, p_ptt, type);
740 case ECORE_DCBX_REMOTE_MIB:
741 rc = ecore_dcbx_read_remote_mib(p_hwfn, p_ptt, type);
743 case ECORE_DCBX_LOCAL_MIB:
744 rc = ecore_dcbx_read_local_mib(p_hwfn, p_ptt);
746 case ECORE_DCBX_REMOTE_LLDP_MIB:
747 rc = ecore_dcbx_read_remote_lldp_mib(p_hwfn, p_ptt, type);
749 case ECORE_DCBX_LOCAL_LLDP_MIB:
750 rc = ecore_dcbx_read_local_lldp_mib(p_hwfn, p_ptt);
753 DP_ERR(p_hwfn, "MIB read err, unknown mib type %d\n", type);
762 * Reconfigure QM and invoke PF update ramrod command if operational MIB
763 * change is detected.
766 ecore_dcbx_mib_update_event(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
767 enum ecore_mib_read_type type)
769 enum _ecore_status_t rc = ECORE_SUCCESS;
771 rc = ecore_dcbx_read_mib(p_hwfn, p_ptt, type);
775 if (type == ECORE_DCBX_OPERATIONAL_MIB) {
776 rc = ecore_dcbx_process_mib_info(p_hwfn);
780 /* reconfigure tcs of QM queues according
781 * to negotiation results
783 ecore_qm_reconf(p_hwfn, p_ptt);
785 /* update storm FW with negotiation results */
786 ecore_sp_pf_update(p_hwfn);
788 /* set eagle enigne 1 flow control workaround
789 * according to negotiation results
791 enabled = p_hwfn->p_dcbx_info->results.dcbx_enabled;
792 ecore_dcbx_eagle_workaround(p_hwfn, p_ptt, enabled);
795 ecore_dcbx_get_params(p_hwfn, p_ptt, type);
796 OSAL_DCBX_AEN(p_hwfn, type);
801 enum _ecore_status_t ecore_dcbx_info_alloc(struct ecore_hwfn *p_hwfn)
803 enum _ecore_status_t rc = ECORE_SUCCESS;
805 p_hwfn->p_dcbx_info = OSAL_ZALLOC(p_hwfn->p_dev, GFP_KERNEL,
806 sizeof(struct ecore_dcbx_info));
807 if (!p_hwfn->p_dcbx_info) {
808 DP_NOTICE(p_hwfn, true,
809 "Failed to allocate `struct ecore_dcbx_info'");
816 void ecore_dcbx_info_free(struct ecore_hwfn *p_hwfn,
817 struct ecore_dcbx_info *p_dcbx_info)
819 OSAL_FREE(p_hwfn->p_dev, p_hwfn->p_dcbx_info);
822 static void ecore_dcbx_update_protocol_data(struct protocol_dcb_data *p_data,
823 struct ecore_dcbx_results *p_src,
824 enum dcbx_protocol_type type)
826 p_data->dcb_enable_flag = p_src->arr[type].enable;
827 p_data->dcb_priority = p_src->arr[type].priority;
828 p_data->dcb_tc = p_src->arr[type].tc;
831 /* Set pf update ramrod command params */
832 void ecore_dcbx_set_pf_update_params(struct ecore_dcbx_results *p_src,
833 struct pf_update_ramrod_data *p_dest)
835 struct protocol_dcb_data *p_dcb_data;
838 p_dest->pf_id = p_src->pf_id;
840 update_flag = p_src->arr[DCBX_PROTOCOL_ETH].update;
841 p_dest->update_eth_dcb_data_flag = update_flag;
843 p_dcb_data = &p_dest->eth_dcb_data;
844 ecore_dcbx_update_protocol_data(p_dcb_data, p_src, DCBX_PROTOCOL_ETH);
848 enum _ecore_status_t ecore_dcbx_query(struct ecore_hwfn *p_hwfn,
849 enum ecore_mib_read_type type)
851 struct ecore_ptt *p_ptt;
852 enum _ecore_status_t rc;
854 p_ptt = ecore_ptt_acquire(p_hwfn);
857 DP_ERR(p_hwfn, "rc = %d\n", rc);
861 rc = ecore_dcbx_read_mib(p_hwfn, p_ptt, type);
862 if (rc != ECORE_SUCCESS)
865 rc = ecore_dcbx_get_params(p_hwfn, p_ptt, type);
868 ecore_ptt_release(p_hwfn, p_ptt);
872 enum _ecore_status_t ecore_dcbx_query_params(struct ecore_hwfn *p_hwfn,
873 struct ecore_dcbx_get *p_get,
874 enum ecore_mib_read_type type)
876 enum _ecore_status_t rc;
878 rc = ecore_dcbx_query(p_hwfn, type);
882 if (p_get != OSAL_NULL)
883 OSAL_MEMCPY(p_get, &p_hwfn->p_dcbx_info->get,
884 sizeof(struct ecore_dcbx_get));