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
< DCBX_MAX_APP_PROTOCOL
; 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
;
622 static enum _ecore_status_t
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;
678 static enum _ecore_status_t
679 ecore_dcbx_get_dscp_params(struct ecore_hwfn
*p_hwfn
,
680 struct ecore_ptt
*p_ptt
,
681 struct ecore_dcbx_get
*params
)
683 struct ecore_dcbx_dscp_params
*p_dscp
;
684 struct dcb_dscp_map
*p_dscp_map
;
688 p_dscp
= ¶ms
->dscp
;
689 p_dscp_map
= &p_hwfn
->p_dcbx_info
->dscp_map
;
690 p_dscp
->enabled
= ECORE_MFW_GET_FIELD(p_dscp_map
->flags
,
692 /* MFW encodes 64 dscp entries into 8 element array of u32 entries,
693 * where each entry holds the 4bit priority map for 8 dscp entries.
695 for (i
= 0, entry
= 0; i
< ECORE_DCBX_DSCP_SIZE
/ 8; i
++) {
696 pri_map
= OSAL_BE32_TO_CPU(p_dscp_map
->dscp_pri_map
[i
]);
697 DP_VERBOSE(p_hwfn
, ECORE_MSG_DCB
, "elem %d pri_map 0x%x\n",
699 for (j
= 0; j
< ECORE_DCBX_DSCP_SIZE
/ 8; j
++, entry
++)
700 p_dscp
->dscp_pri_map
[entry
] = (u32
)(pri_map
>>
704 return ECORE_SUCCESS
;
707 static enum _ecore_status_t
708 ecore_dcbx_get_local_lldp_params(struct ecore_hwfn
*p_hwfn
,
709 struct ecore_ptt
*p_ptt
,
710 struct ecore_dcbx_get
*params
)
712 struct ecore_dcbx_lldp_local
*p_local
;
716 p_local
= ¶ms
->lldp_local
;
718 size
= OSAL_ARRAY_SIZE(p_local
->local_chassis_id
);
719 dest
= p_hwfn
->p_dcbx_info
->get
.lldp_local
.local_chassis_id
;
720 OSAL_MEMCPY(dest
, p_local
->local_chassis_id
, size
);
722 size
= OSAL_ARRAY_SIZE(p_local
->local_port_id
);
723 dest
= p_hwfn
->p_dcbx_info
->get
.lldp_local
.local_port_id
;
724 OSAL_MEMCPY(dest
, p_local
->local_port_id
, size
);
726 return ECORE_SUCCESS
;
729 static enum _ecore_status_t
730 ecore_dcbx_get_remote_lldp_params(struct ecore_hwfn
*p_hwfn
,
731 struct ecore_ptt
*p_ptt
,
732 struct ecore_dcbx_get
*params
)
734 struct ecore_dcbx_lldp_remote
*p_remote
;
738 p_remote
= ¶ms
->lldp_remote
;
740 size
= OSAL_ARRAY_SIZE(p_remote
->peer_chassis_id
);
741 dest
= p_hwfn
->p_dcbx_info
->get
.lldp_remote
.peer_chassis_id
;
742 OSAL_MEMCPY(dest
, p_remote
->peer_chassis_id
, size
);
744 size
= OSAL_ARRAY_SIZE(p_remote
->peer_port_id
);
745 dest
= p_hwfn
->p_dcbx_info
->get
.lldp_remote
.peer_port_id
;
746 OSAL_MEMCPY(dest
, p_remote
->peer_port_id
, size
);
748 return ECORE_SUCCESS
;
751 static enum _ecore_status_t
752 ecore_dcbx_get_params(struct ecore_hwfn
*p_hwfn
,
753 struct ecore_ptt
*p_ptt
, enum ecore_mib_read_type type
)
755 enum _ecore_status_t rc
= ECORE_SUCCESS
;
756 struct ecore_dcbx_get
*p_params
;
758 p_params
= &p_hwfn
->p_dcbx_info
->get
;
761 case ECORE_DCBX_REMOTE_MIB
:
762 ecore_dcbx_get_remote_params(p_hwfn
, p_ptt
, p_params
);
764 case ECORE_DCBX_LOCAL_MIB
:
765 ecore_dcbx_get_local_params(p_hwfn
, p_ptt
, p_params
);
767 case ECORE_DCBX_OPERATIONAL_MIB
:
768 ecore_dcbx_get_operational_params(p_hwfn
, p_ptt
, p_params
);
770 case ECORE_DCBX_REMOTE_LLDP_MIB
:
771 rc
= ecore_dcbx_get_remote_lldp_params(p_hwfn
, p_ptt
, p_params
);
773 case ECORE_DCBX_LOCAL_LLDP_MIB
:
774 rc
= ecore_dcbx_get_local_lldp_params(p_hwfn
, p_ptt
, p_params
);
777 DP_ERR(p_hwfn
, "MIB read err, unknown mib type %d\n", type
);
784 static enum _ecore_status_t
785 ecore_dcbx_read_local_lldp_mib(struct ecore_hwfn
*p_hwfn
,
786 struct ecore_ptt
*p_ptt
)
788 enum _ecore_status_t rc
= ECORE_SUCCESS
;
789 struct ecore_dcbx_mib_meta_data data
;
791 data
.addr
= p_hwfn
->mcp_info
->port_addr
+ offsetof(struct public_port
,
793 data
.lldp_local
= p_hwfn
->p_dcbx_info
->lldp_local
;
794 data
.size
= sizeof(struct lldp_config_params_s
);
795 ecore_memcpy_from(p_hwfn
, p_ptt
, data
.lldp_local
, data
.addr
, data
.size
);
800 static enum _ecore_status_t
801 ecore_dcbx_read_remote_lldp_mib(struct ecore_hwfn
*p_hwfn
,
802 struct ecore_ptt
*p_ptt
,
803 enum ecore_mib_read_type type
)
805 enum _ecore_status_t rc
= ECORE_SUCCESS
;
806 struct ecore_dcbx_mib_meta_data data
;
808 OSAL_MEM_ZERO(&data
, sizeof(data
));
809 data
.addr
= p_hwfn
->mcp_info
->port_addr
+ offsetof(struct public_port
,
811 data
.lldp_remote
= p_hwfn
->p_dcbx_info
->lldp_remote
;
812 data
.size
= sizeof(struct lldp_status_params_s
);
813 rc
= ecore_dcbx_copy_mib(p_hwfn
, p_ptt
, &data
, type
);
818 static enum _ecore_status_t
819 ecore_dcbx_read_operational_mib(struct ecore_hwfn
*p_hwfn
,
820 struct ecore_ptt
*p_ptt
,
821 enum ecore_mib_read_type type
)
823 struct ecore_dcbx_mib_meta_data data
;
824 enum _ecore_status_t rc
= ECORE_SUCCESS
;
826 OSAL_MEM_ZERO(&data
, sizeof(data
));
827 data
.addr
= p_hwfn
->mcp_info
->port_addr
+
828 offsetof(struct public_port
, operational_dcbx_mib
);
829 data
.mib
= &p_hwfn
->p_dcbx_info
->operational
;
830 data
.size
= sizeof(struct dcbx_mib
);
831 rc
= ecore_dcbx_copy_mib(p_hwfn
, p_ptt
, &data
, type
);
836 static enum _ecore_status_t
837 ecore_dcbx_read_remote_mib(struct ecore_hwfn
*p_hwfn
,
838 struct ecore_ptt
*p_ptt
,
839 enum ecore_mib_read_type type
)
841 struct ecore_dcbx_mib_meta_data data
;
842 enum _ecore_status_t rc
= ECORE_SUCCESS
;
844 OSAL_MEM_ZERO(&data
, sizeof(data
));
845 data
.addr
= p_hwfn
->mcp_info
->port_addr
+
846 offsetof(struct public_port
, remote_dcbx_mib
);
847 data
.mib
= &p_hwfn
->p_dcbx_info
->remote
;
848 data
.size
= sizeof(struct dcbx_mib
);
849 rc
= ecore_dcbx_copy_mib(p_hwfn
, p_ptt
, &data
, type
);
854 static enum _ecore_status_t
855 ecore_dcbx_read_local_mib(struct ecore_hwfn
*p_hwfn
, struct ecore_ptt
*p_ptt
)
857 struct ecore_dcbx_mib_meta_data data
;
858 enum _ecore_status_t rc
= ECORE_SUCCESS
;
860 data
.addr
= p_hwfn
->mcp_info
->port_addr
+
861 offsetof(struct public_port
, local_admin_dcbx_mib
);
862 data
.local_admin
= &p_hwfn
->p_dcbx_info
->local_admin
;
863 data
.size
= sizeof(struct dcbx_local_params
);
864 ecore_memcpy_from(p_hwfn
, p_ptt
, data
.local_admin
,
865 data
.addr
, data
.size
);
871 ecore_dcbx_read_dscp_mib(struct ecore_hwfn
*p_hwfn
, struct ecore_ptt
*p_ptt
)
873 struct ecore_dcbx_mib_meta_data data
;
875 data
.addr
= p_hwfn
->mcp_info
->port_addr
+
876 offsetof(struct public_port
, dcb_dscp_map
);
877 data
.dscp_map
= &p_hwfn
->p_dcbx_info
->dscp_map
;
878 data
.size
= sizeof(struct dcb_dscp_map
);
879 ecore_memcpy_from(p_hwfn
, p_ptt
, data
.dscp_map
, data
.addr
, data
.size
);
882 static enum _ecore_status_t
ecore_dcbx_read_mib(struct ecore_hwfn
*p_hwfn
,
883 struct ecore_ptt
*p_ptt
,
884 enum ecore_mib_read_type type
)
886 enum _ecore_status_t rc
= ECORE_SUCCESS
;
889 case ECORE_DCBX_OPERATIONAL_MIB
:
890 ecore_dcbx_read_dscp_mib(p_hwfn
, p_ptt
);
891 rc
= ecore_dcbx_read_operational_mib(p_hwfn
, p_ptt
, type
);
893 case ECORE_DCBX_REMOTE_MIB
:
894 rc
= ecore_dcbx_read_remote_mib(p_hwfn
, p_ptt
, type
);
896 case ECORE_DCBX_LOCAL_MIB
:
897 rc
= ecore_dcbx_read_local_mib(p_hwfn
, p_ptt
);
899 case ECORE_DCBX_REMOTE_LLDP_MIB
:
900 rc
= ecore_dcbx_read_remote_lldp_mib(p_hwfn
, p_ptt
, type
);
902 case ECORE_DCBX_LOCAL_LLDP_MIB
:
903 rc
= ecore_dcbx_read_local_lldp_mib(p_hwfn
, p_ptt
);
906 DP_ERR(p_hwfn
, "MIB read err, unknown mib type %d\n", type
);
915 * Reconfigure QM and invoke PF update ramrod command if operational MIB
916 * change is detected.
919 ecore_dcbx_mib_update_event(struct ecore_hwfn
*p_hwfn
, struct ecore_ptt
*p_ptt
,
920 enum ecore_mib_read_type type
)
922 enum _ecore_status_t rc
= ECORE_SUCCESS
;
924 rc
= ecore_dcbx_read_mib(p_hwfn
, p_ptt
, type
);
928 if (type
== ECORE_DCBX_OPERATIONAL_MIB
) {
929 ecore_dcbx_get_dscp_params(p_hwfn
, p_ptt
,
930 &p_hwfn
->p_dcbx_info
->get
);
932 rc
= ecore_dcbx_process_mib_info(p_hwfn
);
936 /* reconfigure tcs of QM queues according
937 * to negotiation results
939 ecore_qm_reconf(p_hwfn
, p_ptt
);
941 /* update storm FW with negotiation results */
942 ecore_sp_pf_update(p_hwfn
);
944 /* set eagle enigne 1 flow control workaround
945 * according to negotiation results
947 enabled
= p_hwfn
->p_dcbx_info
->results
.dcbx_enabled
;
948 ecore_dcbx_eagle_workaround(p_hwfn
, p_ptt
, enabled
);
951 ecore_dcbx_get_params(p_hwfn
, p_ptt
, type
);
953 /* Update the DSCP to TC mapping bit if required */
954 if ((type
== ECORE_DCBX_OPERATIONAL_MIB
) &&
955 p_hwfn
->p_dcbx_info
->dscp_nig_update
) {
956 ecore_wr(p_hwfn
, p_ptt
, NIG_REG_DSCP_TO_TC_MAP_ENABLE
, 0x1);
957 p_hwfn
->p_dcbx_info
->dscp_nig_update
= false;
960 OSAL_DCBX_AEN(p_hwfn
, type
);
965 enum _ecore_status_t
ecore_dcbx_info_alloc(struct ecore_hwfn
*p_hwfn
)
967 enum _ecore_status_t rc
= ECORE_SUCCESS
;
969 p_hwfn
->p_dcbx_info
= OSAL_ZALLOC(p_hwfn
->p_dev
, GFP_KERNEL
,
970 sizeof(struct ecore_dcbx_info
));
971 if (!p_hwfn
->p_dcbx_info
) {
972 DP_NOTICE(p_hwfn
, true,
973 "Failed to allocate `struct ecore_dcbx_info'");
980 void ecore_dcbx_info_free(struct ecore_hwfn
*p_hwfn
,
981 struct ecore_dcbx_info
*p_dcbx_info
)
983 OSAL_FREE(p_hwfn
->p_dev
, p_hwfn
->p_dcbx_info
);
986 static void ecore_dcbx_update_protocol_data(struct protocol_dcb_data
*p_data
,
987 struct ecore_dcbx_results
*p_src
,
988 enum dcbx_protocol_type type
)
990 p_data
->dcb_enable_flag
= p_src
->arr
[type
].enable
;
991 p_data
->dcb_priority
= p_src
->arr
[type
].priority
;
992 p_data
->dcb_tc
= p_src
->arr
[type
].tc
;
993 p_data
->dscp_enable_flag
= p_src
->arr
[type
].dscp_enable
;
994 p_data
->dscp_val
= p_src
->arr
[type
].dscp_val
;
997 /* Set pf update ramrod command params */
998 void ecore_dcbx_set_pf_update_params(struct ecore_dcbx_results
*p_src
,
999 struct pf_update_ramrod_data
*p_dest
)
1001 struct protocol_dcb_data
*p_dcb_data
;
1002 bool update_flag
= false;
1004 p_dest
->pf_id
= p_src
->pf_id
;
1006 update_flag
= p_src
->arr
[DCBX_PROTOCOL_ETH
].update
;
1007 p_dest
->update_eth_dcb_data_flag
= update_flag
;
1009 p_dcb_data
= &p_dest
->eth_dcb_data
;
1010 ecore_dcbx_update_protocol_data(p_dcb_data
, p_src
, DCBX_PROTOCOL_ETH
);
1014 enum _ecore_status_t
ecore_dcbx_query(struct ecore_hwfn
*p_hwfn
,
1015 enum ecore_mib_read_type type
)
1017 struct ecore_ptt
*p_ptt
;
1018 enum _ecore_status_t rc
;
1020 p_ptt
= ecore_ptt_acquire(p_hwfn
);
1023 DP_ERR(p_hwfn
, "rc = %d\n", rc
);
1027 rc
= ecore_dcbx_read_mib(p_hwfn
, p_ptt
, type
);
1028 if (rc
!= ECORE_SUCCESS
)
1031 rc
= ecore_dcbx_get_params(p_hwfn
, p_ptt
, type
);
1034 ecore_ptt_release(p_hwfn
, p_ptt
);
1038 enum _ecore_status_t
ecore_dcbx_query_params(struct ecore_hwfn
*p_hwfn
,
1039 struct ecore_dcbx_get
*p_get
,
1040 enum ecore_mib_read_type type
)
1042 enum _ecore_status_t rc
;
1044 rc
= ecore_dcbx_query(p_hwfn
, type
);
1048 if (p_get
!= OSAL_NULL
)
1049 OSAL_MEMCPY(p_get
, &p_hwfn
->p_dcbx_info
->get
,
1050 sizeof(struct ecore_dcbx_get
));
1056 ecore_dcbx_set_pfc_data(struct ecore_hwfn
*p_hwfn
,
1057 u32
*pfc
, struct ecore_dcbx_params
*p_params
)
1062 if (p_params
->pfc
.willing
)
1063 *pfc
|= DCBX_PFC_WILLING_MASK
;
1065 *pfc
&= ~DCBX_PFC_WILLING_MASK
;
1067 if (p_params
->pfc
.enabled
)
1068 *pfc
|= DCBX_PFC_ENABLED_MASK
;
1070 *pfc
&= ~DCBX_PFC_ENABLED_MASK
;
1072 *pfc
&= ~DCBX_PFC_CAPS_MASK
;
1073 *pfc
|= (u32
)p_params
->pfc
.max_tc
<< DCBX_PFC_CAPS_SHIFT
;
1075 for (i
= 0; i
< ECORE_MAX_PFC_PRIORITIES
; i
++)
1076 if (p_params
->pfc
.prio
[i
])
1077 pfc_map
|= (0x1 << i
);
1079 *pfc
|= (pfc_map
<< DCBX_PFC_PRI_EN_BITMAP_SHIFT
);
1081 DP_VERBOSE(p_hwfn
, ECORE_MSG_DCB
, "pfc = 0x%x\n", *pfc
);
1085 ecore_dcbx_set_ets_data(struct ecore_hwfn
*p_hwfn
,
1086 struct dcbx_ets_feature
*p_ets
,
1087 struct ecore_dcbx_params
*p_params
)
1089 u8
*bw_map
, *tsa_map
;
1092 if (p_params
->ets_willing
)
1093 p_ets
->flags
|= DCBX_ETS_WILLING_MASK
;
1095 p_ets
->flags
&= ~DCBX_ETS_WILLING_MASK
;
1097 if (p_params
->ets_cbs
)
1098 p_ets
->flags
|= DCBX_ETS_CBS_MASK
;
1100 p_ets
->flags
&= ~DCBX_ETS_CBS_MASK
;
1102 if (p_params
->ets_enabled
)
1103 p_ets
->flags
|= DCBX_ETS_ENABLED_MASK
;
1105 p_ets
->flags
&= ~DCBX_ETS_ENABLED_MASK
;
1107 p_ets
->flags
&= ~DCBX_ETS_MAX_TCS_MASK
;
1108 p_ets
->flags
|= (u32
)p_params
->max_ets_tc
<< DCBX_ETS_MAX_TCS_SHIFT
;
1110 bw_map
= (u8
*)&p_ets
->tc_bw_tbl
[0];
1111 tsa_map
= (u8
*)&p_ets
->tc_tsa_tbl
[0];
1112 p_ets
->pri_tc_tbl
[0] = 0;
1113 for (i
= 0; i
< ECORE_MAX_PFC_PRIORITIES
; i
++) {
1114 bw_map
[i
] = p_params
->ets_tc_bw_tbl
[i
];
1115 tsa_map
[i
] = p_params
->ets_tc_tsa_tbl
[i
];
1116 p_ets
->pri_tc_tbl
[0] |= (((u32
)p_params
->ets_pri_tc_tbl
[i
]) <<
1119 p_ets
->pri_tc_tbl
[0] = OSAL_CPU_TO_BE32(p_ets
->pri_tc_tbl
[0]);
1120 for (i
= 0; i
< 2; i
++) {
1121 p_ets
->tc_bw_tbl
[i
] = OSAL_CPU_TO_BE32(p_ets
->tc_bw_tbl
[i
]);
1122 p_ets
->tc_tsa_tbl
[i
] = OSAL_CPU_TO_BE32(p_ets
->tc_tsa_tbl
[i
]);
1127 ecore_dcbx_set_app_data(struct ecore_hwfn
*p_hwfn
,
1128 struct dcbx_app_priority_feature
*p_app
,
1129 struct ecore_dcbx_params
*p_params
, bool ieee
)
1134 if (p_params
->app_willing
)
1135 p_app
->flags
|= DCBX_APP_WILLING_MASK
;
1137 p_app
->flags
&= ~DCBX_APP_WILLING_MASK
;
1139 if (p_params
->app_valid
)
1140 p_app
->flags
|= DCBX_APP_ENABLED_MASK
;
1142 p_app
->flags
&= ~DCBX_APP_ENABLED_MASK
;
1144 p_app
->flags
&= ~DCBX_APP_NUM_ENTRIES_MASK
;
1145 p_app
->flags
|= (u32
)p_params
->num_app_entries
<<
1146 DCBX_APP_NUM_ENTRIES_SHIFT
;
1148 for (i
= 0; i
< DCBX_MAX_APP_PROTOCOL
; i
++) {
1149 entry
= &p_app
->app_pri_tbl
[i
].entry
;
1151 *entry
&= ~DCBX_APP_SF_IEEE_MASK
;
1152 switch (p_params
->app_entry
[i
].sf_ieee
) {
1153 case ECORE_DCBX_SF_IEEE_ETHTYPE
:
1154 *entry
|= ((u32
)DCBX_APP_SF_IEEE_ETHTYPE
<<
1155 DCBX_APP_SF_IEEE_SHIFT
);
1157 case ECORE_DCBX_SF_IEEE_TCP_PORT
:
1158 *entry
|= ((u32
)DCBX_APP_SF_IEEE_TCP_PORT
<<
1159 DCBX_APP_SF_IEEE_SHIFT
);
1161 case ECORE_DCBX_SF_IEEE_UDP_PORT
:
1162 *entry
|= ((u32
)DCBX_APP_SF_IEEE_UDP_PORT
<<
1163 DCBX_APP_SF_IEEE_SHIFT
);
1165 case ECORE_DCBX_SF_IEEE_TCP_UDP_PORT
:
1166 *entry
|= (u32
)DCBX_APP_SF_IEEE_TCP_UDP_PORT
<<
1167 DCBX_APP_SF_IEEE_SHIFT
;
1171 *entry
&= ~DCBX_APP_SF_MASK
;
1172 if (p_params
->app_entry
[i
].ethtype
)
1173 *entry
|= ((u32
)DCBX_APP_SF_ETHTYPE
<<
1176 *entry
|= ((u32
)DCBX_APP_SF_PORT
<<
1179 *entry
&= ~DCBX_APP_PROTOCOL_ID_MASK
;
1180 *entry
|= ((u32
)p_params
->app_entry
[i
].proto_id
<<
1181 DCBX_APP_PROTOCOL_ID_SHIFT
);
1182 *entry
&= ~DCBX_APP_PRI_MAP_MASK
;
1183 *entry
|= ((u32
)(p_params
->app_entry
[i
].prio
) <<
1184 DCBX_APP_PRI_MAP_SHIFT
);
1188 static enum _ecore_status_t
1189 ecore_dcbx_set_local_params(struct ecore_hwfn
*p_hwfn
,
1190 struct dcbx_local_params
*local_admin
,
1191 struct ecore_dcbx_set
*params
)
1195 local_admin
->flags
= 0;
1196 OSAL_MEMCPY(&local_admin
->features
,
1197 &p_hwfn
->p_dcbx_info
->operational
.features
,
1198 sizeof(struct dcbx_features
));
1200 if (params
->enabled
) {
1201 local_admin
->config
= params
->ver_num
;
1202 ieee
= !!(params
->ver_num
& DCBX_CONFIG_VERSION_IEEE
);
1204 local_admin
->config
= DCBX_CONFIG_VERSION_DISABLED
;
1207 if (params
->override_flags
& ECORE_DCBX_OVERRIDE_PFC_CFG
)
1208 ecore_dcbx_set_pfc_data(p_hwfn
, &local_admin
->features
.pfc
,
1209 ¶ms
->config
.params
);
1211 if (params
->override_flags
& ECORE_DCBX_OVERRIDE_ETS_CFG
)
1212 ecore_dcbx_set_ets_data(p_hwfn
, &local_admin
->features
.ets
,
1213 ¶ms
->config
.params
);
1215 if (params
->override_flags
& ECORE_DCBX_OVERRIDE_APP_CFG
)
1216 ecore_dcbx_set_app_data(p_hwfn
, &local_admin
->features
.app
,
1217 ¶ms
->config
.params
, ieee
);
1219 return ECORE_SUCCESS
;
1222 static enum _ecore_status_t
1223 ecore_dcbx_set_dscp_params(struct ecore_hwfn
*p_hwfn
,
1224 struct dcb_dscp_map
*p_dscp_map
,
1225 struct ecore_dcbx_set
*p_params
)
1230 OSAL_MEMCPY(p_dscp_map
, &p_hwfn
->p_dcbx_info
->dscp_map
,
1231 sizeof(*p_dscp_map
));
1233 if (p_params
->dscp
.enabled
)
1234 p_dscp_map
->flags
|= DCB_DSCP_ENABLE_MASK
;
1236 p_dscp_map
->flags
&= ~DCB_DSCP_ENABLE_MASK
;
1238 for (i
= 0, entry
= 0; i
< 8; i
++) {
1240 for (j
= 0; j
< 8; j
++, entry
++)
1241 val
|= (((u32
)p_params
->dscp
.dscp_pri_map
[entry
]) <<
1244 p_dscp_map
->dscp_pri_map
[i
] = OSAL_CPU_TO_BE32(val
);
1247 p_hwfn
->p_dcbx_info
->dscp_nig_update
= true;
1249 return ECORE_SUCCESS
;
1252 enum _ecore_status_t
ecore_dcbx_config_params(struct ecore_hwfn
*p_hwfn
,
1253 struct ecore_ptt
*p_ptt
,
1254 struct ecore_dcbx_set
*params
,
1257 enum _ecore_status_t rc
= ECORE_SUCCESS
;
1258 struct ecore_dcbx_mib_meta_data data
;
1259 struct dcbx_local_params local_admin
;
1260 struct dcb_dscp_map dscp_map
;
1261 u32 resp
= 0, param
= 0;
1264 OSAL_MEMCPY(&p_hwfn
->p_dcbx_info
->set
, params
,
1265 sizeof(struct ecore_dcbx_set
));
1266 return ECORE_SUCCESS
;
1269 /* clear set-parmas cache */
1270 OSAL_MEMSET(&p_hwfn
->p_dcbx_info
->set
, 0,
1271 sizeof(struct ecore_dcbx_set
));
1273 OSAL_MEMSET(&local_admin
, 0, sizeof(local_admin
));
1274 ecore_dcbx_set_local_params(p_hwfn
, &local_admin
, params
);
1276 data
.addr
= p_hwfn
->mcp_info
->port_addr
+
1277 offsetof(struct public_port
, local_admin_dcbx_mib
);
1278 data
.local_admin
= &local_admin
;
1279 data
.size
= sizeof(struct dcbx_local_params
);
1280 ecore_memcpy_to(p_hwfn
, p_ptt
, data
.addr
, data
.local_admin
, data
.size
);
1282 if (params
->override_flags
& ECORE_DCBX_OVERRIDE_DSCP_CFG
) {
1283 OSAL_MEMSET(&dscp_map
, 0, sizeof(dscp_map
));
1284 ecore_dcbx_set_dscp_params(p_hwfn
, &dscp_map
, params
);
1286 data
.addr
= p_hwfn
->mcp_info
->port_addr
+
1287 offsetof(struct public_port
, dcb_dscp_map
);
1288 data
.dscp_map
= &dscp_map
;
1289 data
.size
= sizeof(struct dcb_dscp_map
);
1290 ecore_memcpy_to(p_hwfn
, p_ptt
, data
.addr
, data
.dscp_map
,
1294 rc
= ecore_mcp_cmd(p_hwfn
, p_ptt
, DRV_MSG_CODE_SET_DCBX
,
1295 1 << DRV_MB_PARAM_LLDP_SEND_SHIFT
, &resp
, ¶m
);
1296 if (rc
!= ECORE_SUCCESS
) {
1297 DP_NOTICE(p_hwfn
, false,
1298 "Failed to send DCBX update request\n");
1305 enum _ecore_status_t
ecore_dcbx_get_config_params(struct ecore_hwfn
*p_hwfn
,
1306 struct ecore_dcbx_set
*params
)
1308 struct ecore_dcbx_get
*dcbx_info
;
1311 if (p_hwfn
->p_dcbx_info
->set
.config
.valid
) {
1312 OSAL_MEMCPY(params
, &p_hwfn
->p_dcbx_info
->set
,
1313 sizeof(struct ecore_dcbx_set
));
1314 return ECORE_SUCCESS
;
1317 dcbx_info
= OSAL_ALLOC(p_hwfn
->p_dev
, GFP_KERNEL
,
1318 sizeof(struct ecore_dcbx_get
));
1320 DP_ERR(p_hwfn
, "Failed to allocate struct ecore_dcbx_info\n");
1324 rc
= ecore_dcbx_query_params(p_hwfn
, dcbx_info
,
1325 ECORE_DCBX_OPERATIONAL_MIB
);
1327 OSAL_FREE(p_hwfn
->p_dev
, dcbx_info
);
1330 p_hwfn
->p_dcbx_info
->set
.override_flags
= 0;
1332 p_hwfn
->p_dcbx_info
->set
.ver_num
= DCBX_CONFIG_VERSION_DISABLED
;
1333 if (dcbx_info
->operational
.cee
)
1334 p_hwfn
->p_dcbx_info
->set
.ver_num
|= DCBX_CONFIG_VERSION_CEE
;
1335 if (dcbx_info
->operational
.ieee
)
1336 p_hwfn
->p_dcbx_info
->set
.ver_num
|= DCBX_CONFIG_VERSION_IEEE
;
1337 if (dcbx_info
->operational
.local
)
1338 p_hwfn
->p_dcbx_info
->set
.ver_num
|= DCBX_CONFIG_VERSION_STATIC
;
1340 p_hwfn
->p_dcbx_info
->set
.enabled
= dcbx_info
->operational
.enabled
;
1341 OSAL_MEMCPY(&p_hwfn
->p_dcbx_info
->set
.config
.params
,
1342 &dcbx_info
->operational
.params
,
1343 sizeof(struct ecore_dcbx_admin_params
));
1344 p_hwfn
->p_dcbx_info
->set
.config
.valid
= true;
1346 OSAL_MEMCPY(params
, &p_hwfn
->p_dcbx_info
->set
,
1347 sizeof(struct ecore_dcbx_set
));
1349 OSAL_FREE(p_hwfn
->p_dev
, dcbx_info
);
1351 return ECORE_SUCCESS
;