1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2016 - 2018 Cavium Inc.
9 #include "ecore_sp_commands.h"
10 #include "ecore_dcbx.h"
11 #include "ecore_cxt.h"
12 #include "ecore_gtt_reg_addr.h"
13 #include "ecore_iro.h"
14 #include "ecore_iov_api.h"
16 #define ECORE_DCBX_MAX_MIB_READ_TRY (100)
17 #define ECORE_ETH_TYPE_DEFAULT (0)
19 #define ECORE_DCBX_INVALID_PRIORITY 0xFF
21 /* Get Traffic Class from priority traffic class table, 4 bits represent
22 * the traffic class corresponding to the priority.
24 #define ECORE_DCBX_PRIO2TC(prio_tc_tbl, prio) \
25 ((u32)(prio_tc_tbl >> ((7 - prio) * 4)) & 0x7)
27 static bool ecore_dcbx_app_ethtype(u32 app_info_bitmap
)
29 return !!(GET_MFW_FIELD(app_info_bitmap
, DCBX_APP_SF
) ==
33 static bool ecore_dcbx_ieee_app_ethtype(u32 app_info_bitmap
)
35 u8 mfw_val
= GET_MFW_FIELD(app_info_bitmap
, DCBX_APP_SF_IEEE
);
38 if (mfw_val
== DCBX_APP_SF_IEEE_RESERVED
)
39 return ecore_dcbx_app_ethtype(app_info_bitmap
);
41 return !!(mfw_val
== DCBX_APP_SF_IEEE_ETHTYPE
);
44 static bool ecore_dcbx_app_port(u32 app_info_bitmap
)
46 return !!(GET_MFW_FIELD(app_info_bitmap
, DCBX_APP_SF
) ==
50 static bool ecore_dcbx_ieee_app_port(u32 app_info_bitmap
, u8 type
)
52 u8 mfw_val
= GET_MFW_FIELD(app_info_bitmap
, DCBX_APP_SF_IEEE
);
55 if (mfw_val
== DCBX_APP_SF_IEEE_RESERVED
)
56 return ecore_dcbx_app_port(app_info_bitmap
);
58 return !!(mfw_val
== type
|| mfw_val
== DCBX_APP_SF_IEEE_TCP_UDP_PORT
);
61 static bool ecore_dcbx_default_tlv(u32 app_info_bitmap
, u16 proto_id
, bool ieee
)
66 ethtype
= ecore_dcbx_ieee_app_ethtype(app_info_bitmap
);
68 ethtype
= ecore_dcbx_app_ethtype(app_info_bitmap
);
70 return !!(ethtype
&& (proto_id
== ECORE_ETH_TYPE_DEFAULT
));
73 static bool ecore_dcbx_iwarp_tlv(struct ecore_hwfn
*p_hwfn
, u32 app_info_bitmap
,
74 u16 proto_id
, bool ieee
)
78 if (!p_hwfn
->p_dcbx_info
->iwarp_port
)
82 port
= ecore_dcbx_ieee_app_port(app_info_bitmap
,
83 DCBX_APP_SF_IEEE_TCP_PORT
);
85 port
= ecore_dcbx_app_port(app_info_bitmap
);
87 return !!(port
&& (proto_id
== p_hwfn
->p_dcbx_info
->iwarp_port
));
91 ecore_dcbx_dp_protocol(struct ecore_hwfn
*p_hwfn
,
92 struct ecore_dcbx_results
*p_data
)
94 enum dcbx_protocol_type id
;
97 DP_VERBOSE(p_hwfn
, ECORE_MSG_DCB
, "DCBX negotiated: %d\n",
98 p_data
->dcbx_enabled
);
100 for (i
= 0; i
< OSAL_ARRAY_SIZE(ecore_dcbx_app_update
); i
++) {
101 id
= ecore_dcbx_app_update
[i
].id
;
103 DP_VERBOSE(p_hwfn
, ECORE_MSG_DCB
,
104 "%s info: update %d, enable %d, prio %d, tc %d,"
105 " num_active_tc %d dscp_enable = %d dscp_val = %d\n",
106 ecore_dcbx_app_update
[i
].name
,
107 p_data
->arr
[id
].update
,
108 p_data
->arr
[id
].enable
, p_data
->arr
[id
].priority
,
109 p_data
->arr
[id
].tc
, p_hwfn
->hw_info
.num_active_tc
,
110 p_data
->arr
[id
].dscp_enable
,
111 p_data
->arr
[id
].dscp_val
);
115 u8
ecore_dcbx_get_dscp_value(struct ecore_hwfn
*p_hwfn
, u8 pri
)
117 struct ecore_dcbx_dscp_params
*dscp
= &p_hwfn
->p_dcbx_info
->get
.dscp
;
121 return ECORE_DCBX_DSCP_DISABLED
;
123 for (i
= 0; i
< ECORE_DCBX_DSCP_SIZE
; i
++)
124 if (pri
== dscp
->dscp_pri_map
[i
])
127 return ECORE_DCBX_DSCP_DISABLED
;
131 ecore_dcbx_set_params(struct ecore_dcbx_results
*p_data
,
132 struct ecore_hwfn
*p_hwfn
, struct ecore_ptt
*p_ptt
,
133 bool enable
, u8 prio
, u8 tc
,
134 enum dcbx_protocol_type type
,
135 enum ecore_pci_personality personality
)
137 /* PF update ramrod data */
138 p_data
->arr
[type
].enable
= enable
;
139 p_data
->arr
[type
].priority
= prio
;
140 p_data
->arr
[type
].tc
= tc
;
141 p_data
->arr
[type
].dscp_val
= ecore_dcbx_get_dscp_value(p_hwfn
, prio
);
142 if (p_data
->arr
[type
].dscp_val
== ECORE_DCBX_DSCP_DISABLED
) {
143 p_data
->arr
[type
].dscp_enable
= false;
144 p_data
->arr
[type
].dscp_val
= 0;
146 p_data
->arr
[type
].dscp_enable
= true;
148 p_data
->arr
[type
].update
= UPDATE_DCB_DSCP
;
150 /* Do not add valn tag 0 when DCB is enabled and port is in UFP mode */
151 if (OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC
, &p_hwfn
->p_dev
->mf_bits
))
152 p_data
->arr
[type
].dont_add_vlan0
= true;
155 if (p_hwfn
->hw_info
.personality
== personality
)
156 p_hwfn
->hw_info
.offload_tc
= tc
;
158 /* Configure dcbx vlan priority in doorbell block for roce EDPM */
159 if (OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC
, &p_hwfn
->p_dev
->mf_bits
) &&
160 (type
== DCBX_PROTOCOL_ROCE
)) {
161 ecore_wr(p_hwfn
, p_ptt
, DORQ_REG_TAG1_OVRD_MODE
, 1);
162 ecore_wr(p_hwfn
, p_ptt
, DORQ_REG_PF_PCP
, prio
<< 1);
166 /* Update app protocol data and hw_info fields with the TLV info */
168 ecore_dcbx_update_app_info(struct ecore_dcbx_results
*p_data
,
169 struct ecore_hwfn
*p_hwfn
, struct ecore_ptt
*p_ptt
,
170 bool enable
, u8 prio
, u8 tc
,
171 enum dcbx_protocol_type type
)
173 enum ecore_pci_personality personality
;
174 enum dcbx_protocol_type id
;
177 for (i
= 0; i
< OSAL_ARRAY_SIZE(ecore_dcbx_app_update
); i
++) {
178 id
= ecore_dcbx_app_update
[i
].id
;
183 personality
= ecore_dcbx_app_update
[i
].personality
;
185 ecore_dcbx_set_params(p_data
, p_hwfn
, p_ptt
, enable
,
186 prio
, tc
, type
, personality
);
190 static enum _ecore_status_t
191 ecore_dcbx_get_app_priority(u8 pri_bitmap
, u8
*priority
)
193 u32 pri_mask
, pri
= ECORE_MAX_PFC_PRIORITIES
;
194 u32 index
= ECORE_MAX_PFC_PRIORITIES
- 1;
195 enum _ecore_status_t rc
= ECORE_SUCCESS
;
197 /* Bitmap 1 corresponds to priority 0, return priority 0 */
198 if (pri_bitmap
== 1) {
203 /* Choose the highest priority */
204 while ((pri
== ECORE_MAX_PFC_PRIORITIES
) && index
) {
205 pri_mask
= 1 << index
;
206 if (pri_bitmap
& pri_mask
)
211 if (pri
< ECORE_MAX_PFC_PRIORITIES
)
220 ecore_dcbx_get_app_protocol_type(struct ecore_hwfn
*p_hwfn
,
221 u32 app_prio_bitmap
, u16 id
,
222 enum dcbx_protocol_type
*type
, bool ieee
)
224 if (ecore_dcbx_default_tlv(app_prio_bitmap
, id
, ieee
)) {
225 *type
= DCBX_PROTOCOL_ETH
;
227 *type
= DCBX_MAX_PROTOCOL_TYPE
;
228 DP_VERBOSE(p_hwfn
, ECORE_MSG_DCB
,
229 "No action required, App TLV entry = 0x%x\n",
237 /* Parse app TLV's to update TC information in hw_info structure for
238 * reconfiguring QM. Get protocol specific data for PF update ramrod command.
240 static enum _ecore_status_t
241 ecore_dcbx_process_tlv(struct ecore_hwfn
*p_hwfn
, struct ecore_ptt
*p_ptt
,
242 struct ecore_dcbx_results
*p_data
,
243 struct dcbx_app_priority_entry
*p_tbl
, u32 pri_tc_tbl
,
244 int count
, u8 dcbx_version
)
246 enum dcbx_protocol_type type
;
247 bool enable
, ieee
, eth_tlv
;
251 enum _ecore_status_t rc
= ECORE_SUCCESS
;
254 DP_VERBOSE(p_hwfn
, ECORE_MSG_DCB
,
255 "Num APP entries = %d pri_tc_tbl = 0x%x dcbx_version = %u\n",
256 count
, pri_tc_tbl
, dcbx_version
);
258 ieee
= (dcbx_version
== DCBX_CONFIG_VERSION_IEEE
);
261 for (i
= 0; i
< count
; i
++) {
262 protocol_id
= GET_MFW_FIELD(p_tbl
[i
].entry
,
263 DCBX_APP_PROTOCOL_ID
);
264 priority_map
= GET_MFW_FIELD(p_tbl
[i
].entry
, DCBX_APP_PRI_MAP
);
265 DP_VERBOSE(p_hwfn
, ECORE_MSG_DCB
, "Id = 0x%x pri_map = %u\n",
266 protocol_id
, priority_map
);
267 rc
= ecore_dcbx_get_app_priority(priority_map
, &priority
);
268 if (rc
== ECORE_INVAL
) {
269 DP_ERR(p_hwfn
, "Invalid priority\n");
273 tc
= ECORE_DCBX_PRIO2TC(pri_tc_tbl
, priority
);
274 if (ecore_dcbx_get_app_protocol_type(p_hwfn
, p_tbl
[i
].entry
,
277 /* ETH always have the enable bit reset, as it gets
278 * vlan information per packet. For other protocols,
279 * should be set according to the dcbx_enabled
280 * indication, but we only got here if there was an
281 * app tlv for the protocol, so dcbx must be enabled.
283 if (type
== DCBX_PROTOCOL_ETH
) {
290 ecore_dcbx_update_app_info(p_data
, p_hwfn
, p_ptt
,
291 enable
, priority
, tc
, type
);
295 /* If Eth TLV is not detected, use UFP TC as default TC */
296 if (OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC
,
297 &p_hwfn
->p_dev
->mf_bits
) && !eth_tlv
)
298 p_data
->arr
[DCBX_PROTOCOL_ETH
].tc
= p_hwfn
->ufp_info
.tc
;
300 /* Update ramrod protocol data and hw_info fields
301 * with default info when corresponding APP TLV's are not detected.
302 * The enabled field has a different logic for ethernet as only for
303 * ethernet dcb should disabled by default, as the information arrives
304 * from the OS (unless an explicit app tlv was present).
306 tc
= p_data
->arr
[DCBX_PROTOCOL_ETH
].tc
;
307 priority
= p_data
->arr
[DCBX_PROTOCOL_ETH
].priority
;
308 for (type
= 0; type
< DCBX_MAX_PROTOCOL_TYPE
; type
++) {
309 if (p_data
->arr
[type
].update
)
312 /* if no app tlv was present, don't override in FW */
313 ecore_dcbx_update_app_info(p_data
, p_hwfn
, p_ptt
,
314 p_data
->arr
[DCBX_PROTOCOL_ETH
].enable
,
318 return ECORE_SUCCESS
;
321 /* Parse app TLV's to update TC information in hw_info structure for
322 * reconfiguring QM. Get protocol specific data for PF update ramrod command.
324 static enum _ecore_status_t
325 ecore_dcbx_process_mib_info(struct ecore_hwfn
*p_hwfn
, struct ecore_ptt
*p_ptt
)
327 struct dcbx_app_priority_feature
*p_app
;
328 struct dcbx_app_priority_entry
*p_tbl
;
329 struct ecore_dcbx_results data
;
330 struct dcbx_ets_feature
*p_ets
;
331 struct ecore_hw_info
*p_info
;
332 u32 pri_tc_tbl
, flags
;
335 enum _ecore_status_t rc
= ECORE_SUCCESS
;
337 flags
= p_hwfn
->p_dcbx_info
->operational
.flags
;
338 dcbx_version
= GET_MFW_FIELD(flags
, DCBX_CONFIG_VERSION
);
340 p_app
= &p_hwfn
->p_dcbx_info
->operational
.features
.app
;
341 p_tbl
= p_app
->app_pri_tbl
;
343 p_ets
= &p_hwfn
->p_dcbx_info
->operational
.features
.ets
;
344 pri_tc_tbl
= p_ets
->pri_tc_tbl
[0];
346 p_info
= &p_hwfn
->hw_info
;
347 num_entries
= GET_MFW_FIELD(p_app
->flags
, DCBX_APP_NUM_ENTRIES
);
349 OSAL_MEMSET(&data
, 0, sizeof(struct ecore_dcbx_results
));
350 rc
= ecore_dcbx_process_tlv(p_hwfn
, p_ptt
, &data
, p_tbl
, pri_tc_tbl
,
351 num_entries
, dcbx_version
);
352 if (rc
!= ECORE_SUCCESS
)
355 p_info
->num_active_tc
= GET_MFW_FIELD(p_ets
->flags
, DCBX_ETS_MAX_TCS
);
356 p_hwfn
->qm_info
.ooo_tc
= GET_MFW_FIELD(p_ets
->flags
, DCBX_OOO_TC
);
357 data
.pf_id
= p_hwfn
->rel_pf_id
;
358 data
.dcbx_enabled
= !!dcbx_version
;
360 ecore_dcbx_dp_protocol(p_hwfn
, &data
);
362 OSAL_MEMCPY(&p_hwfn
->p_dcbx_info
->results
, &data
,
363 sizeof(struct ecore_dcbx_results
));
365 return ECORE_SUCCESS
;
368 static enum _ecore_status_t
369 ecore_dcbx_copy_mib(struct ecore_hwfn
*p_hwfn
,
370 struct ecore_ptt
*p_ptt
,
371 struct ecore_dcbx_mib_meta_data
*p_data
,
372 enum ecore_mib_read_type type
)
374 u32 prefix_seq_num
, suffix_seq_num
;
376 enum _ecore_status_t rc
= ECORE_SUCCESS
;
378 /* The data is considered to be valid only if both sequence numbers are
382 if (type
== ECORE_DCBX_REMOTE_LLDP_MIB
) {
383 ecore_memcpy_from(p_hwfn
, p_ptt
, p_data
->lldp_remote
,
384 p_data
->addr
, p_data
->size
);
385 prefix_seq_num
= p_data
->lldp_remote
->prefix_seq_num
;
386 suffix_seq_num
= p_data
->lldp_remote
->suffix_seq_num
;
387 } else if (type
== ECORE_DCBX_LLDP_TLVS
) {
388 ecore_memcpy_from(p_hwfn
, p_ptt
, p_data
->lldp_tlvs
,
389 p_data
->addr
, p_data
->size
);
390 prefix_seq_num
= p_data
->lldp_tlvs
->prefix_seq_num
;
391 suffix_seq_num
= p_data
->lldp_tlvs
->suffix_seq_num
;
394 ecore_memcpy_from(p_hwfn
, p_ptt
, p_data
->mib
,
395 p_data
->addr
, p_data
->size
);
396 prefix_seq_num
= p_data
->mib
->prefix_seq_num
;
397 suffix_seq_num
= p_data
->mib
->suffix_seq_num
;
401 DP_VERBOSE(p_hwfn
, ECORE_MSG_DCB
,
402 "mib type = %d, try count = %d prefix seq num ="
403 " %d suffix seq num = %d\n",
404 type
, read_count
, prefix_seq_num
, suffix_seq_num
);
405 } while ((prefix_seq_num
!= suffix_seq_num
) &&
406 (read_count
< ECORE_DCBX_MAX_MIB_READ_TRY
));
408 if (read_count
>= ECORE_DCBX_MAX_MIB_READ_TRY
) {
410 "MIB read err, mib type = %d, try count ="
411 " %d prefix seq num = %d suffix seq num = %d\n",
412 type
, read_count
, prefix_seq_num
, suffix_seq_num
);
420 ecore_dcbx_get_priority_info(struct ecore_hwfn
*p_hwfn
,
421 struct ecore_dcbx_app_prio
*p_prio
,
422 struct ecore_dcbx_results
*p_results
)
426 if (p_results
->arr
[DCBX_PROTOCOL_ETH
].update
&&
427 p_results
->arr
[DCBX_PROTOCOL_ETH
].enable
)
428 p_prio
->eth
= p_results
->arr
[DCBX_PROTOCOL_ETH
].priority
;
430 DP_VERBOSE(p_hwfn
, ECORE_MSG_DCB
,
431 "Priorities: eth %d\n",
436 ecore_dcbx_get_app_data(struct ecore_hwfn
*p_hwfn
,
437 struct dcbx_app_priority_feature
*p_app
,
438 struct dcbx_app_priority_entry
*p_tbl
,
439 struct ecore_dcbx_params
*p_params
, bool ieee
)
441 struct ecore_app_entry
*entry
;
445 p_params
->app_willing
= GET_MFW_FIELD(p_app
->flags
, DCBX_APP_WILLING
);
446 p_params
->app_valid
= GET_MFW_FIELD(p_app
->flags
, DCBX_APP_ENABLED
);
447 p_params
->app_error
= GET_MFW_FIELD(p_app
->flags
, DCBX_APP_ERROR
);
448 p_params
->num_app_entries
= GET_MFW_FIELD(p_app
->flags
,
449 DCBX_APP_NUM_ENTRIES
);
450 for (i
= 0; i
< p_params
->num_app_entries
; i
++) {
451 entry
= &p_params
->app_entry
[i
];
456 sf_ieee
= GET_MFW_FIELD(p_tbl
[i
].entry
,
459 case DCBX_APP_SF_IEEE_RESERVED
:
461 val
= GET_MFW_FIELD(p_tbl
[i
].entry
,
463 entry
->sf_ieee
= val
?
464 ECORE_DCBX_SF_IEEE_TCP_UDP_PORT
:
465 ECORE_DCBX_SF_IEEE_ETHTYPE
;
467 case DCBX_APP_SF_IEEE_ETHTYPE
:
468 entry
->sf_ieee
= ECORE_DCBX_SF_IEEE_ETHTYPE
;
470 case DCBX_APP_SF_IEEE_TCP_PORT
:
471 entry
->sf_ieee
= ECORE_DCBX_SF_IEEE_TCP_PORT
;
473 case DCBX_APP_SF_IEEE_UDP_PORT
:
474 entry
->sf_ieee
= ECORE_DCBX_SF_IEEE_UDP_PORT
;
476 case DCBX_APP_SF_IEEE_TCP_UDP_PORT
:
478 ECORE_DCBX_SF_IEEE_TCP_UDP_PORT
;
482 entry
->ethtype
= !(GET_MFW_FIELD(p_tbl
[i
].entry
,
486 pri_map
= GET_MFW_FIELD(p_tbl
[i
].entry
, DCBX_APP_PRI_MAP
);
487 ecore_dcbx_get_app_priority(pri_map
, &entry
->prio
);
488 entry
->proto_id
= GET_MFW_FIELD(p_tbl
[i
].entry
,
489 DCBX_APP_PROTOCOL_ID
);
490 ecore_dcbx_get_app_protocol_type(p_hwfn
, p_tbl
[i
].entry
,
492 &entry
->proto_type
, ieee
);
495 DP_VERBOSE(p_hwfn
, ECORE_MSG_DCB
,
496 "APP params: willing %d, valid %d error = %d\n",
497 p_params
->app_willing
, p_params
->app_valid
,
498 p_params
->app_error
);
502 ecore_dcbx_get_pfc_data(struct ecore_hwfn
*p_hwfn
,
503 u32 pfc
, struct ecore_dcbx_params
*p_params
)
507 p_params
->pfc
.willing
= GET_MFW_FIELD(pfc
, DCBX_PFC_WILLING
);
508 p_params
->pfc
.max_tc
= GET_MFW_FIELD(pfc
, DCBX_PFC_CAPS
);
509 p_params
->pfc
.enabled
= GET_MFW_FIELD(pfc
, DCBX_PFC_ENABLED
);
510 pfc_map
= GET_MFW_FIELD(pfc
, DCBX_PFC_PRI_EN_BITMAP
);
511 p_params
->pfc
.prio
[0] = !!(pfc_map
& DCBX_PFC_PRI_EN_BITMAP_PRI_0
);
512 p_params
->pfc
.prio
[1] = !!(pfc_map
& DCBX_PFC_PRI_EN_BITMAP_PRI_1
);
513 p_params
->pfc
.prio
[2] = !!(pfc_map
& DCBX_PFC_PRI_EN_BITMAP_PRI_2
);
514 p_params
->pfc
.prio
[3] = !!(pfc_map
& DCBX_PFC_PRI_EN_BITMAP_PRI_3
);
515 p_params
->pfc
.prio
[4] = !!(pfc_map
& DCBX_PFC_PRI_EN_BITMAP_PRI_4
);
516 p_params
->pfc
.prio
[5] = !!(pfc_map
& DCBX_PFC_PRI_EN_BITMAP_PRI_5
);
517 p_params
->pfc
.prio
[6] = !!(pfc_map
& DCBX_PFC_PRI_EN_BITMAP_PRI_6
);
518 p_params
->pfc
.prio
[7] = !!(pfc_map
& DCBX_PFC_PRI_EN_BITMAP_PRI_7
);
520 DP_VERBOSE(p_hwfn
, ECORE_MSG_DCB
,
521 "PFC params: willing %d, pfc_bitmap %u max_tc = %u enabled = %d\n",
522 p_params
->pfc
.willing
, pfc_map
, p_params
->pfc
.max_tc
,
523 p_params
->pfc
.enabled
);
527 ecore_dcbx_get_ets_data(struct ecore_hwfn
*p_hwfn
,
528 struct dcbx_ets_feature
*p_ets
,
529 struct ecore_dcbx_params
*p_params
)
531 u32 bw_map
[2], tsa_map
[2], pri_map
;
534 p_params
->ets_willing
= GET_MFW_FIELD(p_ets
->flags
, DCBX_ETS_WILLING
);
535 p_params
->ets_enabled
= GET_MFW_FIELD(p_ets
->flags
, DCBX_ETS_ENABLED
);
536 p_params
->ets_cbs
= GET_MFW_FIELD(p_ets
->flags
, DCBX_ETS_CBS
);
537 p_params
->max_ets_tc
= GET_MFW_FIELD(p_ets
->flags
, DCBX_ETS_MAX_TCS
);
538 DP_VERBOSE(p_hwfn
, ECORE_MSG_DCB
,
539 "ETS params: willing %d, enabled = %d ets_cbs %d pri_tc_tbl_0 %x max_ets_tc %d\n",
540 p_params
->ets_willing
, p_params
->ets_enabled
,
541 p_params
->ets_cbs
, p_ets
->pri_tc_tbl
[0],
542 p_params
->max_ets_tc
);
544 /* 8 bit tsa and bw data corresponding to each of the 8 TC's are
545 * encoded in a type u32 array of size 2.
547 bw_map
[0] = OSAL_BE32_TO_CPU(p_ets
->tc_bw_tbl
[0]);
548 bw_map
[1] = OSAL_BE32_TO_CPU(p_ets
->tc_bw_tbl
[1]);
549 tsa_map
[0] = OSAL_BE32_TO_CPU(p_ets
->tc_tsa_tbl
[0]);
550 tsa_map
[1] = OSAL_BE32_TO_CPU(p_ets
->tc_tsa_tbl
[1]);
551 pri_map
= p_ets
->pri_tc_tbl
[0];
552 for (i
= 0; i
< ECORE_MAX_PFC_PRIORITIES
; i
++) {
553 p_params
->ets_tc_bw_tbl
[i
] = ((u8
*)bw_map
)[i
];
554 p_params
->ets_tc_tsa_tbl
[i
] = ((u8
*)tsa_map
)[i
];
555 p_params
->ets_pri_tc_tbl
[i
] = ECORE_DCBX_PRIO2TC(pri_map
, i
);
556 DP_VERBOSE(p_hwfn
, ECORE_MSG_DCB
,
557 "elem %d bw_tbl %x tsa_tbl %x\n",
558 i
, p_params
->ets_tc_bw_tbl
[i
],
559 p_params
->ets_tc_tsa_tbl
[i
]);
564 ecore_dcbx_get_common_params(struct ecore_hwfn
*p_hwfn
,
565 struct dcbx_app_priority_feature
*p_app
,
566 struct dcbx_app_priority_entry
*p_tbl
,
567 struct dcbx_ets_feature
*p_ets
,
568 u32 pfc
, struct ecore_dcbx_params
*p_params
,
571 ecore_dcbx_get_app_data(p_hwfn
, p_app
, p_tbl
, p_params
, ieee
);
572 ecore_dcbx_get_ets_data(p_hwfn
, p_ets
, p_params
);
573 ecore_dcbx_get_pfc_data(p_hwfn
, pfc
, p_params
);
577 ecore_dcbx_get_local_params(struct ecore_hwfn
*p_hwfn
,
578 struct ecore_dcbx_get
*params
)
580 struct dcbx_features
*p_feat
;
582 p_feat
= &p_hwfn
->p_dcbx_info
->local_admin
.features
;
583 ecore_dcbx_get_common_params(p_hwfn
, &p_feat
->app
,
584 p_feat
->app
.app_pri_tbl
, &p_feat
->ets
,
585 p_feat
->pfc
, ¶ms
->local
.params
, false);
586 params
->local
.valid
= true;
590 ecore_dcbx_get_remote_params(struct ecore_hwfn
*p_hwfn
,
591 struct ecore_dcbx_get
*params
)
593 struct dcbx_features
*p_feat
;
595 p_feat
= &p_hwfn
->p_dcbx_info
->remote
.features
;
596 ecore_dcbx_get_common_params(p_hwfn
, &p_feat
->app
,
597 p_feat
->app
.app_pri_tbl
, &p_feat
->ets
,
598 p_feat
->pfc
, ¶ms
->remote
.params
,
600 params
->remote
.valid
= true;
603 static void ecore_dcbx_get_dscp_params(struct ecore_hwfn
*p_hwfn
,
604 struct ecore_dcbx_get
*params
)
606 struct ecore_dcbx_dscp_params
*p_dscp
;
607 struct dcb_dscp_map
*p_dscp_map
;
611 p_dscp
= ¶ms
->dscp
;
612 p_dscp_map
= &p_hwfn
->p_dcbx_info
->dscp_map
;
613 p_dscp
->enabled
= GET_MFW_FIELD(p_dscp_map
->flags
, DCB_DSCP_ENABLE
);
615 /* MFW encodes 64 dscp entries into 8 element array of u32 entries,
616 * where each entry holds the 4bit priority map for 8 dscp entries.
618 for (i
= 0, entry
= 0; i
< ECORE_DCBX_DSCP_SIZE
/ 8; i
++) {
619 pri_map
= OSAL_BE32_TO_CPU(p_dscp_map
->dscp_pri_map
[i
]);
620 DP_VERBOSE(p_hwfn
, ECORE_MSG_DCB
, "elem %d pri_map 0x%x\n",
622 for (j
= 0; j
< ECORE_DCBX_DSCP_SIZE
/ 8; j
++, entry
++)
623 p_dscp
->dscp_pri_map
[entry
] = (u32
)(pri_map
>>
629 ecore_dcbx_get_operational_params(struct ecore_hwfn
*p_hwfn
,
630 struct ecore_dcbx_get
*params
)
632 struct ecore_dcbx_operational_params
*p_operational
;
633 struct ecore_dcbx_results
*p_results
;
634 struct dcbx_features
*p_feat
;
639 flags
= p_hwfn
->p_dcbx_info
->operational
.flags
;
641 /* If DCBx version is non zero, then negotiation
642 * was successfuly performed
644 p_operational
= ¶ms
->operational
;
645 enabled
= !!(GET_MFW_FIELD(flags
, DCBX_CONFIG_VERSION
) !=
646 DCBX_CONFIG_VERSION_DISABLED
);
648 p_operational
->enabled
= enabled
;
649 p_operational
->valid
= false;
650 DP_VERBOSE(p_hwfn
, ECORE_MSG_DCB
, "Dcbx is disabled\n");
654 p_feat
= &p_hwfn
->p_dcbx_info
->operational
.features
;
655 p_results
= &p_hwfn
->p_dcbx_info
->results
;
657 val
= !!(GET_MFW_FIELD(flags
, DCBX_CONFIG_VERSION
) ==
658 DCBX_CONFIG_VERSION_IEEE
);
659 p_operational
->ieee
= val
;
661 val
= !!(GET_MFW_FIELD(flags
, DCBX_CONFIG_VERSION
) ==
662 DCBX_CONFIG_VERSION_CEE
);
663 p_operational
->cee
= val
;
665 val
= !!(GET_MFW_FIELD(flags
, DCBX_CONFIG_VERSION
) ==
666 DCBX_CONFIG_VERSION_STATIC
);
667 p_operational
->local
= val
;
669 DP_VERBOSE(p_hwfn
, ECORE_MSG_DCB
,
670 "Version support: ieee %d, cee %d, static %d\n",
671 p_operational
->ieee
, p_operational
->cee
,
672 p_operational
->local
);
674 ecore_dcbx_get_common_params(p_hwfn
, &p_feat
->app
,
675 p_feat
->app
.app_pri_tbl
, &p_feat
->ets
,
676 p_feat
->pfc
, ¶ms
->operational
.params
,
677 p_operational
->ieee
);
678 ecore_dcbx_get_priority_info(p_hwfn
, &p_operational
->app_prio
,
680 err
= GET_MFW_FIELD(p_feat
->app
.flags
, DCBX_APP_ERROR
);
681 p_operational
->err
= err
;
682 p_operational
->enabled
= enabled
;
683 p_operational
->valid
= true;
686 static void ecore_dcbx_get_local_lldp_params(struct ecore_hwfn
*p_hwfn
,
687 struct ecore_dcbx_get
*params
)
689 struct lldp_config_params_s
*p_local
;
691 p_local
= &p_hwfn
->p_dcbx_info
->lldp_local
[LLDP_NEAREST_BRIDGE
];
693 OSAL_MEMCPY(params
->lldp_local
.local_chassis_id
,
694 p_local
->local_chassis_id
,
695 sizeof(params
->lldp_local
.local_chassis_id
));
696 OSAL_MEMCPY(params
->lldp_local
.local_port_id
, p_local
->local_port_id
,
697 sizeof(params
->lldp_local
.local_port_id
));
700 static void ecore_dcbx_get_remote_lldp_params(struct ecore_hwfn
*p_hwfn
,
701 struct ecore_dcbx_get
*params
)
703 struct lldp_status_params_s
*p_remote
;
705 p_remote
= &p_hwfn
->p_dcbx_info
->lldp_remote
[LLDP_NEAREST_BRIDGE
];
707 OSAL_MEMCPY(params
->lldp_remote
.peer_chassis_id
,
708 p_remote
->peer_chassis_id
,
709 sizeof(params
->lldp_remote
.peer_chassis_id
));
710 OSAL_MEMCPY(params
->lldp_remote
.peer_port_id
, p_remote
->peer_port_id
,
711 sizeof(params
->lldp_remote
.peer_port_id
));
714 static enum _ecore_status_t
715 ecore_dcbx_get_params(struct ecore_hwfn
*p_hwfn
,
716 struct ecore_dcbx_get
*p_params
,
717 enum ecore_mib_read_type type
)
720 case ECORE_DCBX_REMOTE_MIB
:
721 ecore_dcbx_get_remote_params(p_hwfn
, p_params
);
723 case ECORE_DCBX_LOCAL_MIB
:
724 ecore_dcbx_get_local_params(p_hwfn
, p_params
);
726 case ECORE_DCBX_OPERATIONAL_MIB
:
727 ecore_dcbx_get_operational_params(p_hwfn
, p_params
);
729 case ECORE_DCBX_REMOTE_LLDP_MIB
:
730 ecore_dcbx_get_remote_lldp_params(p_hwfn
, p_params
);
732 case ECORE_DCBX_LOCAL_LLDP_MIB
:
733 ecore_dcbx_get_local_lldp_params(p_hwfn
, p_params
);
736 DP_ERR(p_hwfn
, "MIB read err, unknown mib type %d\n", type
);
740 return ECORE_SUCCESS
;
743 static enum _ecore_status_t
744 ecore_dcbx_read_local_lldp_mib(struct ecore_hwfn
*p_hwfn
,
745 struct ecore_ptt
*p_ptt
)
747 struct ecore_dcbx_mib_meta_data data
;
748 enum _ecore_status_t rc
= ECORE_SUCCESS
;
750 OSAL_MEM_ZERO(&data
, sizeof(data
));
751 data
.addr
= p_hwfn
->mcp_info
->port_addr
+ offsetof(struct public_port
,
753 data
.lldp_local
= p_hwfn
->p_dcbx_info
->lldp_local
;
754 data
.size
= sizeof(struct lldp_config_params_s
);
755 ecore_memcpy_from(p_hwfn
, p_ptt
, data
.lldp_local
, data
.addr
, data
.size
);
760 static enum _ecore_status_t
761 ecore_dcbx_read_remote_lldp_mib(struct ecore_hwfn
*p_hwfn
,
762 struct ecore_ptt
*p_ptt
,
763 enum ecore_mib_read_type type
)
765 struct ecore_dcbx_mib_meta_data data
;
766 enum _ecore_status_t rc
= ECORE_SUCCESS
;
768 OSAL_MEM_ZERO(&data
, sizeof(data
));
769 data
.addr
= p_hwfn
->mcp_info
->port_addr
+ offsetof(struct public_port
,
771 data
.lldp_remote
= p_hwfn
->p_dcbx_info
->lldp_remote
;
772 data
.size
= sizeof(struct lldp_status_params_s
);
773 rc
= ecore_dcbx_copy_mib(p_hwfn
, p_ptt
, &data
, type
);
778 static enum _ecore_status_t
779 ecore_dcbx_read_operational_mib(struct ecore_hwfn
*p_hwfn
,
780 struct ecore_ptt
*p_ptt
,
781 enum ecore_mib_read_type type
)
783 struct ecore_dcbx_mib_meta_data data
;
784 enum _ecore_status_t rc
= ECORE_SUCCESS
;
786 OSAL_MEM_ZERO(&data
, sizeof(data
));
787 data
.addr
= p_hwfn
->mcp_info
->port_addr
+
788 offsetof(struct public_port
, operational_dcbx_mib
);
789 data
.mib
= &p_hwfn
->p_dcbx_info
->operational
;
790 data
.size
= sizeof(struct dcbx_mib
);
791 rc
= ecore_dcbx_copy_mib(p_hwfn
, p_ptt
, &data
, type
);
796 static enum _ecore_status_t
797 ecore_dcbx_read_remote_mib(struct ecore_hwfn
*p_hwfn
,
798 struct ecore_ptt
*p_ptt
,
799 enum ecore_mib_read_type type
)
801 struct ecore_dcbx_mib_meta_data data
;
802 enum _ecore_status_t rc
= ECORE_SUCCESS
;
804 OSAL_MEM_ZERO(&data
, sizeof(data
));
805 data
.addr
= p_hwfn
->mcp_info
->port_addr
+
806 offsetof(struct public_port
, remote_dcbx_mib
);
807 data
.mib
= &p_hwfn
->p_dcbx_info
->remote
;
808 data
.size
= sizeof(struct dcbx_mib
);
809 rc
= ecore_dcbx_copy_mib(p_hwfn
, p_ptt
, &data
, type
);
814 static enum _ecore_status_t
815 ecore_dcbx_read_local_mib(struct ecore_hwfn
*p_hwfn
, struct ecore_ptt
*p_ptt
)
817 struct ecore_dcbx_mib_meta_data data
;
818 enum _ecore_status_t rc
= ECORE_SUCCESS
;
820 OSAL_MEM_ZERO(&data
, sizeof(data
));
821 data
.addr
= p_hwfn
->mcp_info
->port_addr
+
822 offsetof(struct public_port
, local_admin_dcbx_mib
);
823 data
.local_admin
= &p_hwfn
->p_dcbx_info
->local_admin
;
824 data
.size
= sizeof(struct dcbx_local_params
);
825 ecore_memcpy_from(p_hwfn
, p_ptt
, data
.local_admin
,
826 data
.addr
, data
.size
);
832 ecore_dcbx_read_dscp_mib(struct ecore_hwfn
*p_hwfn
, struct ecore_ptt
*p_ptt
)
834 struct ecore_dcbx_mib_meta_data data
;
836 data
.addr
= p_hwfn
->mcp_info
->port_addr
+
837 offsetof(struct public_port
, dcb_dscp_map
);
838 data
.dscp_map
= &p_hwfn
->p_dcbx_info
->dscp_map
;
839 data
.size
= sizeof(struct dcb_dscp_map
);
840 ecore_memcpy_from(p_hwfn
, p_ptt
, data
.dscp_map
, data
.addr
, data
.size
);
843 static enum _ecore_status_t
ecore_dcbx_read_mib(struct ecore_hwfn
*p_hwfn
,
844 struct ecore_ptt
*p_ptt
,
845 enum ecore_mib_read_type type
)
847 enum _ecore_status_t rc
= ECORE_INVAL
;
850 case ECORE_DCBX_OPERATIONAL_MIB
:
851 ecore_dcbx_read_dscp_mib(p_hwfn
, p_ptt
);
852 rc
= ecore_dcbx_read_operational_mib(p_hwfn
, p_ptt
, type
);
854 case ECORE_DCBX_REMOTE_MIB
:
855 rc
= ecore_dcbx_read_remote_mib(p_hwfn
, p_ptt
, type
);
857 case ECORE_DCBX_LOCAL_MIB
:
858 rc
= ecore_dcbx_read_local_mib(p_hwfn
, p_ptt
);
860 case ECORE_DCBX_REMOTE_LLDP_MIB
:
861 rc
= ecore_dcbx_read_remote_lldp_mib(p_hwfn
, p_ptt
, type
);
863 case ECORE_DCBX_LOCAL_LLDP_MIB
:
864 rc
= ecore_dcbx_read_local_lldp_mib(p_hwfn
, p_ptt
);
867 DP_ERR(p_hwfn
, "MIB read err, unknown mib type %d\n", type
);
870 return ECORE_SUCCESS
;
875 * Reconfigure QM and invoke PF update ramrod command if operational MIB
876 * change is detected.
879 ecore_dcbx_mib_update_event(struct ecore_hwfn
*p_hwfn
, struct ecore_ptt
*p_ptt
,
880 enum ecore_mib_read_type type
)
882 enum _ecore_status_t rc
= ECORE_SUCCESS
;
884 rc
= ecore_dcbx_read_mib(p_hwfn
, p_ptt
, type
);
888 if (type
== ECORE_DCBX_OPERATIONAL_MIB
) {
889 ecore_dcbx_get_dscp_params(p_hwfn
, &p_hwfn
->p_dcbx_info
->get
);
891 rc
= ecore_dcbx_process_mib_info(p_hwfn
, p_ptt
);
893 /* reconfigure tcs of QM queues according
894 * to negotiation results
896 ecore_qm_reconf(p_hwfn
, p_ptt
);
898 /* update storm FW with negotiation results */
899 ecore_sp_pf_update_dcbx(p_hwfn
);
903 ecore_dcbx_get_params(p_hwfn
, &p_hwfn
->p_dcbx_info
->get
, type
);
905 /* Update the DSCP to TC mapping enable bit if required */
906 if ((type
== ECORE_DCBX_OPERATIONAL_MIB
) &&
907 p_hwfn
->p_dcbx_info
->dscp_nig_update
) {
908 u8 val
= !!p_hwfn
->p_dcbx_info
->get
.dscp
.enabled
;
909 u32 addr
= NIG_REG_DSCP_TO_TC_MAP_ENABLE
;
911 rc
= ecore_all_ppfids_wr(p_hwfn
, p_ptt
, addr
, val
);
912 if (rc
!= ECORE_SUCCESS
) {
913 DP_NOTICE(p_hwfn
, false,
914 "Failed to update the DSCP to TC mapping enable bit\n");
918 p_hwfn
->p_dcbx_info
->dscp_nig_update
= false;
921 OSAL_DCBX_AEN(p_hwfn
, type
);
926 enum _ecore_status_t
ecore_dcbx_info_alloc(struct ecore_hwfn
*p_hwfn
)
928 p_hwfn
->p_dcbx_info
= OSAL_ZALLOC(p_hwfn
->p_dev
, GFP_KERNEL
,
929 sizeof(*p_hwfn
->p_dcbx_info
));
930 if (!p_hwfn
->p_dcbx_info
) {
931 DP_NOTICE(p_hwfn
, false,
932 "Failed to allocate `struct ecore_dcbx_info'");
936 p_hwfn
->p_dcbx_info
->iwarp_port
=
937 p_hwfn
->pf_params
.rdma_pf_params
.iwarp_port
;
939 return ECORE_SUCCESS
;
942 void ecore_dcbx_info_free(struct ecore_hwfn
*p_hwfn
)
944 OSAL_FREE(p_hwfn
->p_dev
, p_hwfn
->p_dcbx_info
);
947 static void ecore_dcbx_update_protocol_data(struct protocol_dcb_data
*p_data
,
948 struct ecore_dcbx_results
*p_src
,
949 enum dcbx_protocol_type type
)
951 p_data
->dcb_enable_flag
= p_src
->arr
[type
].enable
;
952 p_data
->dcb_priority
= p_src
->arr
[type
].priority
;
953 p_data
->dcb_tc
= p_src
->arr
[type
].tc
;
954 p_data
->dscp_enable_flag
= p_src
->arr
[type
].dscp_enable
;
955 p_data
->dscp_val
= p_src
->arr
[type
].dscp_val
;
956 p_data
->dcb_dont_add_vlan0
= p_src
->arr
[type
].dont_add_vlan0
;
959 /* Set pf update ramrod command params */
960 void ecore_dcbx_set_pf_update_params(struct ecore_dcbx_results
*p_src
,
961 struct pf_update_ramrod_data
*p_dest
)
963 struct protocol_dcb_data
*p_dcb_data
;
966 update_flag
= p_src
->arr
[DCBX_PROTOCOL_ETH
].update
;
967 p_dest
->update_eth_dcb_data_mode
= update_flag
;
968 update_flag
= p_src
->arr
[DCBX_PROTOCOL_IWARP
].update
;
969 p_dest
->update_iwarp_dcb_data_mode
= update_flag
;
971 p_dcb_data
= &p_dest
->eth_dcb_data
;
972 ecore_dcbx_update_protocol_data(p_dcb_data
, p_src
, DCBX_PROTOCOL_ETH
);
973 p_dcb_data
= &p_dest
->iwarp_dcb_data
;
974 ecore_dcbx_update_protocol_data(p_dcb_data
, p_src
, DCBX_PROTOCOL_IWARP
);
977 enum _ecore_status_t
ecore_dcbx_query_params(struct ecore_hwfn
*p_hwfn
,
978 struct ecore_dcbx_get
*p_get
,
979 enum ecore_mib_read_type type
)
981 struct ecore_ptt
*p_ptt
;
982 enum _ecore_status_t rc
;
984 if (IS_VF(p_hwfn
->p_dev
))
987 p_ptt
= ecore_ptt_acquire(p_hwfn
);
989 return ECORE_TIMEOUT
;
991 rc
= ecore_dcbx_read_mib(p_hwfn
, p_ptt
, type
);
992 if (rc
!= ECORE_SUCCESS
)
995 ecore_dcbx_get_dscp_params(p_hwfn
, p_get
);
997 rc
= ecore_dcbx_get_params(p_hwfn
, p_get
, type
);
1000 ecore_ptt_release(p_hwfn
, p_ptt
);
1005 ecore_dcbx_set_pfc_data(struct ecore_hwfn
*p_hwfn
,
1006 u32
*pfc
, struct ecore_dcbx_params
*p_params
)
1011 if (p_params
->pfc
.willing
)
1012 *pfc
|= DCBX_PFC_WILLING_MASK
;
1014 *pfc
&= ~DCBX_PFC_WILLING_MASK
;
1016 if (p_params
->pfc
.enabled
)
1017 *pfc
|= DCBX_PFC_ENABLED_MASK
;
1019 *pfc
&= ~DCBX_PFC_ENABLED_MASK
;
1021 *pfc
&= ~DCBX_PFC_CAPS_MASK
;
1022 *pfc
|= (u32
)p_params
->pfc
.max_tc
<< DCBX_PFC_CAPS_OFFSET
;
1024 for (i
= 0; i
< ECORE_MAX_PFC_PRIORITIES
; i
++)
1025 if (p_params
->pfc
.prio
[i
])
1026 pfc_map
|= (1 << i
);
1027 *pfc
&= ~DCBX_PFC_PRI_EN_BITMAP_MASK
;
1028 *pfc
|= (pfc_map
<< DCBX_PFC_PRI_EN_BITMAP_OFFSET
);
1030 DP_VERBOSE(p_hwfn
, ECORE_MSG_DCB
, "pfc = 0x%x\n", *pfc
);
1034 ecore_dcbx_set_ets_data(struct ecore_hwfn
*p_hwfn
,
1035 struct dcbx_ets_feature
*p_ets
,
1036 struct ecore_dcbx_params
*p_params
)
1038 u8
*bw_map
, *tsa_map
;
1042 if (p_params
->ets_willing
)
1043 p_ets
->flags
|= DCBX_ETS_WILLING_MASK
;
1045 p_ets
->flags
&= ~DCBX_ETS_WILLING_MASK
;
1047 if (p_params
->ets_cbs
)
1048 p_ets
->flags
|= DCBX_ETS_CBS_MASK
;
1050 p_ets
->flags
&= ~DCBX_ETS_CBS_MASK
;
1052 if (p_params
->ets_enabled
)
1053 p_ets
->flags
|= DCBX_ETS_ENABLED_MASK
;
1055 p_ets
->flags
&= ~DCBX_ETS_ENABLED_MASK
;
1057 p_ets
->flags
&= ~DCBX_ETS_MAX_TCS_MASK
;
1058 p_ets
->flags
|= (u32
)p_params
->max_ets_tc
<< DCBX_ETS_MAX_TCS_OFFSET
;
1060 bw_map
= (u8
*)&p_ets
->tc_bw_tbl
[0];
1061 tsa_map
= (u8
*)&p_ets
->tc_tsa_tbl
[0];
1062 p_ets
->pri_tc_tbl
[0] = 0;
1063 for (i
= 0; i
< ECORE_MAX_PFC_PRIORITIES
; i
++) {
1064 bw_map
[i
] = p_params
->ets_tc_bw_tbl
[i
];
1065 tsa_map
[i
] = p_params
->ets_tc_tsa_tbl
[i
];
1066 /* Copy the priority value to the corresponding 4 bits in the
1067 * traffic class table.
1069 val
= (((u32
)p_params
->ets_pri_tc_tbl
[i
]) << ((7 - i
) * 4));
1070 p_ets
->pri_tc_tbl
[0] |= val
;
1072 for (i
= 0; i
< 2; i
++) {
1073 p_ets
->tc_bw_tbl
[i
] = OSAL_CPU_TO_BE32(p_ets
->tc_bw_tbl
[i
]);
1074 p_ets
->tc_tsa_tbl
[i
] = OSAL_CPU_TO_BE32(p_ets
->tc_tsa_tbl
[i
]);
1077 DP_VERBOSE(p_hwfn
, ECORE_MSG_DCB
,
1078 "flags = 0x%x pri_tc = 0x%x tc_bwl[] = {0x%x, 0x%x} tc_tsa = {0x%x, 0x%x}\n",
1079 p_ets
->flags
, p_ets
->pri_tc_tbl
[0], p_ets
->tc_bw_tbl
[0],
1080 p_ets
->tc_bw_tbl
[1], p_ets
->tc_tsa_tbl
[0],
1081 p_ets
->tc_tsa_tbl
[1]);
1085 ecore_dcbx_set_app_data(struct ecore_hwfn
*p_hwfn
,
1086 struct dcbx_app_priority_feature
*p_app
,
1087 struct ecore_dcbx_params
*p_params
, bool ieee
)
1092 if (p_params
->app_willing
)
1093 p_app
->flags
|= DCBX_APP_WILLING_MASK
;
1095 p_app
->flags
&= ~DCBX_APP_WILLING_MASK
;
1097 if (p_params
->app_valid
)
1098 p_app
->flags
|= DCBX_APP_ENABLED_MASK
;
1100 p_app
->flags
&= ~DCBX_APP_ENABLED_MASK
;
1102 p_app
->flags
&= ~DCBX_APP_NUM_ENTRIES_MASK
;
1103 p_app
->flags
|= (u32
)p_params
->num_app_entries
<<
1104 DCBX_APP_NUM_ENTRIES_OFFSET
;
1106 for (i
= 0; i
< p_params
->num_app_entries
; i
++) {
1107 entry
= &p_app
->app_pri_tbl
[i
].entry
;
1110 *entry
&= ~(DCBX_APP_SF_IEEE_MASK
| DCBX_APP_SF_MASK
);
1111 switch (p_params
->app_entry
[i
].sf_ieee
) {
1112 case ECORE_DCBX_SF_IEEE_ETHTYPE
:
1113 *entry
|= ((u32
)DCBX_APP_SF_IEEE_ETHTYPE
<<
1114 DCBX_APP_SF_IEEE_OFFSET
);
1115 *entry
|= ((u32
)DCBX_APP_SF_ETHTYPE
<<
1116 DCBX_APP_SF_OFFSET
);
1118 case ECORE_DCBX_SF_IEEE_TCP_PORT
:
1119 *entry
|= ((u32
)DCBX_APP_SF_IEEE_TCP_PORT
<<
1120 DCBX_APP_SF_IEEE_OFFSET
);
1121 *entry
|= ((u32
)DCBX_APP_SF_PORT
<<
1122 DCBX_APP_SF_OFFSET
);
1124 case ECORE_DCBX_SF_IEEE_UDP_PORT
:
1125 *entry
|= ((u32
)DCBX_APP_SF_IEEE_UDP_PORT
<<
1126 DCBX_APP_SF_IEEE_OFFSET
);
1127 *entry
|= ((u32
)DCBX_APP_SF_PORT
<<
1128 DCBX_APP_SF_OFFSET
);
1130 case ECORE_DCBX_SF_IEEE_TCP_UDP_PORT
:
1131 *entry
|= (u32
)DCBX_APP_SF_IEEE_TCP_UDP_PORT
<<
1132 DCBX_APP_SF_IEEE_OFFSET
;
1133 *entry
|= ((u32
)DCBX_APP_SF_PORT
<<
1134 DCBX_APP_SF_OFFSET
);
1138 *entry
&= ~DCBX_APP_SF_MASK
;
1139 if (p_params
->app_entry
[i
].ethtype
)
1140 *entry
|= ((u32
)DCBX_APP_SF_ETHTYPE
<<
1141 DCBX_APP_SF_OFFSET
);
1143 *entry
|= ((u32
)DCBX_APP_SF_PORT
<<
1144 DCBX_APP_SF_OFFSET
);
1146 *entry
&= ~DCBX_APP_PROTOCOL_ID_MASK
;
1147 *entry
|= ((u32
)p_params
->app_entry
[i
].proto_id
<<
1148 DCBX_APP_PROTOCOL_ID_OFFSET
);
1149 *entry
&= ~DCBX_APP_PRI_MAP_MASK
;
1150 *entry
|= ((u32
)(p_params
->app_entry
[i
].prio
) <<
1151 DCBX_APP_PRI_MAP_OFFSET
);
1154 DP_VERBOSE(p_hwfn
, ECORE_MSG_DCB
, "flags = 0x%x\n", p_app
->flags
);
1158 ecore_dcbx_set_local_params(struct ecore_hwfn
*p_hwfn
,
1159 struct dcbx_local_params
*local_admin
,
1160 struct ecore_dcbx_set
*params
)
1164 local_admin
->flags
= 0;
1165 OSAL_MEMCPY(&local_admin
->features
,
1166 &p_hwfn
->p_dcbx_info
->operational
.features
,
1167 sizeof(local_admin
->features
));
1169 if (params
->enabled
) {
1170 local_admin
->config
= params
->ver_num
;
1171 ieee
= !!(params
->ver_num
& DCBX_CONFIG_VERSION_IEEE
);
1173 local_admin
->config
= DCBX_CONFIG_VERSION_DISABLED
;
1176 DP_VERBOSE(p_hwfn
, ECORE_MSG_DCB
, "Dcbx version = %d\n",
1177 local_admin
->config
);
1179 if (params
->override_flags
& ECORE_DCBX_OVERRIDE_PFC_CFG
)
1180 ecore_dcbx_set_pfc_data(p_hwfn
, &local_admin
->features
.pfc
,
1181 ¶ms
->config
.params
);
1183 if (params
->override_flags
& ECORE_DCBX_OVERRIDE_ETS_CFG
)
1184 ecore_dcbx_set_ets_data(p_hwfn
, &local_admin
->features
.ets
,
1185 ¶ms
->config
.params
);
1187 if (params
->override_flags
& ECORE_DCBX_OVERRIDE_APP_CFG
)
1188 ecore_dcbx_set_app_data(p_hwfn
, &local_admin
->features
.app
,
1189 ¶ms
->config
.params
, ieee
);
1192 static enum _ecore_status_t
1193 ecore_dcbx_set_dscp_params(struct ecore_hwfn
*p_hwfn
,
1194 struct dcb_dscp_map
*p_dscp_map
,
1195 struct ecore_dcbx_set
*p_params
)
1200 OSAL_MEMCPY(p_dscp_map
, &p_hwfn
->p_dcbx_info
->dscp_map
,
1201 sizeof(*p_dscp_map
));
1203 p_dscp_map
->flags
&= ~DCB_DSCP_ENABLE_MASK
;
1204 if (p_params
->dscp
.enabled
)
1205 p_dscp_map
->flags
|= DCB_DSCP_ENABLE_MASK
;
1207 for (i
= 0, entry
= 0; i
< 8; i
++) {
1209 for (j
= 0; j
< 8; j
++, entry
++)
1210 val
|= (((u32
)p_params
->dscp
.dscp_pri_map
[entry
]) <<
1213 p_dscp_map
->dscp_pri_map
[i
] = OSAL_CPU_TO_BE32(val
);
1216 p_hwfn
->p_dcbx_info
->dscp_nig_update
= true;
1218 DP_VERBOSE(p_hwfn
, ECORE_MSG_DCB
, "flags = 0x%x\n", p_dscp_map
->flags
);
1219 DP_VERBOSE(p_hwfn
, ECORE_MSG_DCB
,
1220 "pri_map[] = 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
1221 p_dscp_map
->dscp_pri_map
[0], p_dscp_map
->dscp_pri_map
[1],
1222 p_dscp_map
->dscp_pri_map
[2], p_dscp_map
->dscp_pri_map
[3],
1223 p_dscp_map
->dscp_pri_map
[4], p_dscp_map
->dscp_pri_map
[5],
1224 p_dscp_map
->dscp_pri_map
[6], p_dscp_map
->dscp_pri_map
[7]);
1226 return ECORE_SUCCESS
;
1229 enum _ecore_status_t
ecore_dcbx_config_params(struct ecore_hwfn
*p_hwfn
,
1230 struct ecore_ptt
*p_ptt
,
1231 struct ecore_dcbx_set
*params
,
1234 struct dcbx_local_params local_admin
;
1235 struct ecore_dcbx_mib_meta_data data
;
1236 struct dcb_dscp_map dscp_map
;
1237 u32 resp
= 0, param
= 0;
1238 enum _ecore_status_t rc
= ECORE_SUCCESS
;
1240 OSAL_MEMCPY(&p_hwfn
->p_dcbx_info
->set
, params
,
1241 sizeof(p_hwfn
->p_dcbx_info
->set
));
1243 return ECORE_SUCCESS
;
1245 OSAL_MEMSET(&local_admin
, 0, sizeof(local_admin
));
1246 ecore_dcbx_set_local_params(p_hwfn
, &local_admin
, params
);
1248 data
.addr
= p_hwfn
->mcp_info
->port_addr
+
1249 offsetof(struct public_port
, local_admin_dcbx_mib
);
1250 data
.local_admin
= &local_admin
;
1251 data
.size
= sizeof(struct dcbx_local_params
);
1252 ecore_memcpy_to(p_hwfn
, p_ptt
, data
.addr
, data
.local_admin
, data
.size
);
1254 if (params
->override_flags
& ECORE_DCBX_OVERRIDE_DSCP_CFG
) {
1255 OSAL_MEMSET(&dscp_map
, 0, sizeof(dscp_map
));
1256 ecore_dcbx_set_dscp_params(p_hwfn
, &dscp_map
, params
);
1258 data
.addr
= p_hwfn
->mcp_info
->port_addr
+
1259 offsetof(struct public_port
, dcb_dscp_map
);
1260 data
.dscp_map
= &dscp_map
;
1261 data
.size
= sizeof(struct dcb_dscp_map
);
1262 ecore_memcpy_to(p_hwfn
, p_ptt
, data
.addr
, data
.dscp_map
,
1266 rc
= ecore_mcp_cmd(p_hwfn
, p_ptt
, DRV_MSG_CODE_SET_DCBX
,
1267 1 << DRV_MB_PARAM_LLDP_SEND_OFFSET
, &resp
, ¶m
);
1268 if (rc
!= ECORE_SUCCESS
)
1269 DP_NOTICE(p_hwfn
, false,
1270 "Failed to send DCBX update request\n");
1275 enum _ecore_status_t
ecore_dcbx_get_config_params(struct ecore_hwfn
*p_hwfn
,
1276 struct ecore_dcbx_set
*params
)
1278 struct ecore_dcbx_get
*dcbx_info
;
1281 if (p_hwfn
->p_dcbx_info
->set
.config
.valid
) {
1282 OSAL_MEMCPY(params
, &p_hwfn
->p_dcbx_info
->set
,
1283 sizeof(struct ecore_dcbx_set
));
1284 return ECORE_SUCCESS
;
1287 dcbx_info
= OSAL_ALLOC(p_hwfn
->p_dev
, GFP_KERNEL
,
1288 sizeof(*dcbx_info
));
1292 OSAL_MEMSET(dcbx_info
, 0, sizeof(*dcbx_info
));
1293 rc
= ecore_dcbx_query_params(p_hwfn
, dcbx_info
,
1294 ECORE_DCBX_OPERATIONAL_MIB
);
1296 OSAL_FREE(p_hwfn
->p_dev
, dcbx_info
);
1299 p_hwfn
->p_dcbx_info
->set
.override_flags
= 0;
1301 p_hwfn
->p_dcbx_info
->set
.ver_num
= DCBX_CONFIG_VERSION_DISABLED
;
1302 if (dcbx_info
->operational
.cee
)
1303 p_hwfn
->p_dcbx_info
->set
.ver_num
|= DCBX_CONFIG_VERSION_CEE
;
1304 if (dcbx_info
->operational
.ieee
)
1305 p_hwfn
->p_dcbx_info
->set
.ver_num
|= DCBX_CONFIG_VERSION_IEEE
;
1306 if (dcbx_info
->operational
.local
)
1307 p_hwfn
->p_dcbx_info
->set
.ver_num
|= DCBX_CONFIG_VERSION_STATIC
;
1309 p_hwfn
->p_dcbx_info
->set
.enabled
= dcbx_info
->operational
.enabled
;
1310 OSAL_MEMCPY(&p_hwfn
->p_dcbx_info
->set
.dscp
,
1311 &p_hwfn
->p_dcbx_info
->get
.dscp
,
1312 sizeof(struct ecore_dcbx_dscp_params
));
1313 OSAL_MEMCPY(&p_hwfn
->p_dcbx_info
->set
.config
.params
,
1314 &dcbx_info
->operational
.params
,
1315 sizeof(p_hwfn
->p_dcbx_info
->set
.config
.params
));
1316 p_hwfn
->p_dcbx_info
->set
.config
.valid
= true;
1318 OSAL_MEMCPY(params
, &p_hwfn
->p_dcbx_info
->set
,
1319 sizeof(struct ecore_dcbx_set
));
1321 OSAL_FREE(p_hwfn
->p_dev
, dcbx_info
);
1323 return ECORE_SUCCESS
;
1326 enum _ecore_status_t
ecore_lldp_register_tlv(struct ecore_hwfn
*p_hwfn
,
1327 struct ecore_ptt
*p_ptt
,
1328 enum ecore_lldp_agent agent
,
1331 u32 mb_param
= 0, mcp_resp
= 0, mcp_param
= 0, val
= 0;
1332 enum _ecore_status_t rc
= ECORE_SUCCESS
;
1335 case ECORE_LLDP_NEAREST_BRIDGE
:
1336 val
= LLDP_NEAREST_BRIDGE
;
1338 case ECORE_LLDP_NEAREST_NON_TPMR_BRIDGE
:
1339 val
= LLDP_NEAREST_NON_TPMR_BRIDGE
;
1341 case ECORE_LLDP_NEAREST_CUSTOMER_BRIDGE
:
1342 val
= LLDP_NEAREST_CUSTOMER_BRIDGE
;
1345 DP_ERR(p_hwfn
, "Invalid agent type %d\n", agent
);
1349 SET_MFW_FIELD(mb_param
, DRV_MB_PARAM_LLDP_AGENT
, val
);
1350 SET_MFW_FIELD(mb_param
, DRV_MB_PARAM_LLDP_TLV_RX_TYPE
, tlv_type
);
1352 rc
= ecore_mcp_cmd(p_hwfn
, p_ptt
, DRV_MSG_CODE_REGISTER_LLDP_TLVS_RX
,
1353 mb_param
, &mcp_resp
, &mcp_param
);
1354 if (rc
!= ECORE_SUCCESS
)
1355 DP_NOTICE(p_hwfn
, false, "Failed to register TLV\n");
1360 enum _ecore_status_t
1361 ecore_lldp_mib_update_event(struct ecore_hwfn
*p_hwfn
, struct ecore_ptt
*p_ptt
)
1363 struct ecore_dcbx_mib_meta_data data
;
1364 enum _ecore_status_t rc
= ECORE_SUCCESS
;
1365 struct lldp_received_tlvs_s tlvs
;
1368 for (i
= 0; i
< LLDP_MAX_LLDP_AGENTS
; i
++) {
1369 OSAL_MEM_ZERO(&data
, sizeof(data
));
1370 data
.addr
= p_hwfn
->mcp_info
->port_addr
+
1371 offsetof(struct public_port
, lldp_received_tlvs
[i
]);
1372 data
.lldp_tlvs
= &tlvs
;
1373 data
.size
= sizeof(tlvs
);
1374 rc
= ecore_dcbx_copy_mib(p_hwfn
, p_ptt
, &data
,
1375 ECORE_DCBX_LLDP_TLVS
);
1376 if (rc
!= ECORE_SUCCESS
) {
1377 DP_NOTICE(p_hwfn
, false, "Failed to read lldp TLVs\n");
1384 for (i
= 0; i
< MAX_TLV_BUFFER
; i
++)
1385 tlvs
.tlvs_buffer
[i
] =
1386 OSAL_CPU_TO_BE32(tlvs
.tlvs_buffer
[i
]);
1388 OSAL_LLDP_RX_TLVS(p_hwfn
, tlvs
.tlvs_buffer
, tlvs
.length
);
1394 enum _ecore_status_t
1395 ecore_lldp_get_params(struct ecore_hwfn
*p_hwfn
, struct ecore_ptt
*p_ptt
,
1396 struct ecore_lldp_config_params
*p_params
)
1398 struct lldp_config_params_s lldp_params
;
1402 switch (p_params
->agent
) {
1403 case ECORE_LLDP_NEAREST_BRIDGE
:
1404 val
= LLDP_NEAREST_BRIDGE
;
1406 case ECORE_LLDP_NEAREST_NON_TPMR_BRIDGE
:
1407 val
= LLDP_NEAREST_NON_TPMR_BRIDGE
;
1409 case ECORE_LLDP_NEAREST_CUSTOMER_BRIDGE
:
1410 val
= LLDP_NEAREST_CUSTOMER_BRIDGE
;
1413 DP_ERR(p_hwfn
, "Invalid agent type %d\n", p_params
->agent
);
1417 addr
= p_hwfn
->mcp_info
->port_addr
+
1418 offsetof(struct public_port
, lldp_config_params
[val
]);
1420 ecore_memcpy_from(p_hwfn
, p_ptt
, &lldp_params
, addr
,
1421 sizeof(lldp_params
));
1423 p_params
->tx_interval
= GET_MFW_FIELD(lldp_params
.config
,
1424 LLDP_CONFIG_TX_INTERVAL
);
1425 p_params
->tx_hold
= GET_MFW_FIELD(lldp_params
.config
, LLDP_CONFIG_HOLD
);
1426 p_params
->tx_credit
= GET_MFW_FIELD(lldp_params
.config
,
1427 LLDP_CONFIG_MAX_CREDIT
);
1428 p_params
->rx_enable
= GET_MFW_FIELD(lldp_params
.config
,
1429 LLDP_CONFIG_ENABLE_RX
);
1430 p_params
->tx_enable
= GET_MFW_FIELD(lldp_params
.config
,
1431 LLDP_CONFIG_ENABLE_TX
);
1433 OSAL_MEMCPY(p_params
->chassis_id_tlv
, lldp_params
.local_chassis_id
,
1434 sizeof(p_params
->chassis_id_tlv
));
1435 for (i
= 0; i
< ECORE_LLDP_CHASSIS_ID_STAT_LEN
; i
++)
1436 p_params
->chassis_id_tlv
[i
] =
1437 OSAL_BE32_TO_CPU(p_params
->chassis_id_tlv
[i
]);
1439 OSAL_MEMCPY(p_params
->port_id_tlv
, lldp_params
.local_port_id
,
1440 sizeof(p_params
->port_id_tlv
));
1441 for (i
= 0; i
< ECORE_LLDP_PORT_ID_STAT_LEN
; i
++)
1442 p_params
->port_id_tlv
[i
] =
1443 OSAL_BE32_TO_CPU(p_params
->port_id_tlv
[i
]);
1445 return ECORE_SUCCESS
;
1448 enum _ecore_status_t
1449 ecore_lldp_set_params(struct ecore_hwfn
*p_hwfn
, struct ecore_ptt
*p_ptt
,
1450 struct ecore_lldp_config_params
*p_params
)
1452 u32 mb_param
= 0, mcp_resp
= 0, mcp_param
= 0;
1453 struct lldp_config_params_s lldp_params
;
1454 enum _ecore_status_t rc
= ECORE_SUCCESS
;
1458 switch (p_params
->agent
) {
1459 case ECORE_LLDP_NEAREST_BRIDGE
:
1460 val
= LLDP_NEAREST_BRIDGE
;
1462 case ECORE_LLDP_NEAREST_NON_TPMR_BRIDGE
:
1463 val
= LLDP_NEAREST_NON_TPMR_BRIDGE
;
1465 case ECORE_LLDP_NEAREST_CUSTOMER_BRIDGE
:
1466 val
= LLDP_NEAREST_CUSTOMER_BRIDGE
;
1469 DP_ERR(p_hwfn
, "Invalid agent type %d\n", p_params
->agent
);
1473 SET_MFW_FIELD(mb_param
, DRV_MB_PARAM_LLDP_AGENT
, val
);
1474 addr
= p_hwfn
->mcp_info
->port_addr
+
1475 offsetof(struct public_port
, lldp_config_params
[val
]);
1477 OSAL_MEMSET(&lldp_params
, 0, sizeof(lldp_params
));
1478 SET_MFW_FIELD(lldp_params
.config
, LLDP_CONFIG_TX_INTERVAL
,
1479 p_params
->tx_interval
);
1480 SET_MFW_FIELD(lldp_params
.config
, LLDP_CONFIG_HOLD
, p_params
->tx_hold
);
1481 SET_MFW_FIELD(lldp_params
.config
, LLDP_CONFIG_MAX_CREDIT
,
1482 p_params
->tx_credit
);
1483 SET_MFW_FIELD(lldp_params
.config
, LLDP_CONFIG_ENABLE_RX
,
1484 !!p_params
->rx_enable
);
1485 SET_MFW_FIELD(lldp_params
.config
, LLDP_CONFIG_ENABLE_TX
,
1486 !!p_params
->tx_enable
);
1488 for (i
= 0; i
< ECORE_LLDP_CHASSIS_ID_STAT_LEN
; i
++)
1489 p_params
->chassis_id_tlv
[i
] =
1490 OSAL_CPU_TO_BE32(p_params
->chassis_id_tlv
[i
]);
1491 OSAL_MEMCPY(lldp_params
.local_chassis_id
, p_params
->chassis_id_tlv
,
1492 sizeof(lldp_params
.local_chassis_id
));
1494 for (i
= 0; i
< ECORE_LLDP_PORT_ID_STAT_LEN
; i
++)
1495 p_params
->port_id_tlv
[i
] =
1496 OSAL_CPU_TO_BE32(p_params
->port_id_tlv
[i
]);
1497 OSAL_MEMCPY(lldp_params
.local_port_id
, p_params
->port_id_tlv
,
1498 sizeof(lldp_params
.local_port_id
));
1500 ecore_memcpy_to(p_hwfn
, p_ptt
, addr
, &lldp_params
, sizeof(lldp_params
));
1502 rc
= ecore_mcp_cmd(p_hwfn
, p_ptt
, DRV_MSG_CODE_SET_LLDP
,
1503 mb_param
, &mcp_resp
, &mcp_param
);
1504 if (rc
!= ECORE_SUCCESS
)
1505 DP_NOTICE(p_hwfn
, false, "SET_LLDP failed, error = %d\n", rc
);
1510 enum _ecore_status_t
1511 ecore_lldp_set_system_tlvs(struct ecore_hwfn
*p_hwfn
, struct ecore_ptt
*p_ptt
,
1512 struct ecore_lldp_sys_tlvs
*p_params
)
1514 u32 mb_param
= 0, mcp_resp
= 0, mcp_param
= 0;
1515 enum _ecore_status_t rc
= ECORE_SUCCESS
;
1516 struct lldp_system_tlvs_buffer_s lld_tlv_buf
;
1521 p_val
= (u32
*)p_params
->buf
;
1522 for (i
= 0; i
< ECORE_LLDP_SYS_TLV_SIZE
/ 4; i
++)
1523 p_val
[i
] = OSAL_CPU_TO_BE32(p_val
[i
]);
1525 OSAL_MEMSET(&lld_tlv_buf
, 0, sizeof(lld_tlv_buf
));
1526 SET_MFW_FIELD(lld_tlv_buf
.flags
, LLDP_SYSTEM_TLV_VALID
, 1);
1527 SET_MFW_FIELD(lld_tlv_buf
.flags
, LLDP_SYSTEM_TLV_MANDATORY
,
1528 !!p_params
->discard_mandatory_tlv
);
1529 SET_MFW_FIELD(lld_tlv_buf
.flags
, LLDP_SYSTEM_TLV_LENGTH
,
1530 p_params
->buf_size
);
1531 len
= ECORE_LLDP_SYS_TLV_SIZE
/ 2;
1532 OSAL_MEMCPY(lld_tlv_buf
.data
, p_params
->buf
, len
);
1534 addr
= p_hwfn
->mcp_info
->port_addr
+
1535 offsetof(struct public_port
, system_lldp_tlvs_buf
);
1536 ecore_memcpy_to(p_hwfn
, p_ptt
, addr
, &lld_tlv_buf
, sizeof(lld_tlv_buf
));
1538 if (p_params
->buf_size
> len
) {
1539 addr
= p_hwfn
->mcp_info
->port_addr
+
1540 offsetof(struct public_port
, system_lldp_tlvs_buf2
);
1541 ecore_memcpy_to(p_hwfn
, p_ptt
, addr
, &p_params
->buf
[len
],
1542 ECORE_LLDP_SYS_TLV_SIZE
/ 2);
1545 rc
= ecore_mcp_cmd(p_hwfn
, p_ptt
, DRV_MSG_CODE_SET_LLDP
,
1546 mb_param
, &mcp_resp
, &mcp_param
);
1547 if (rc
!= ECORE_SUCCESS
)
1548 DP_NOTICE(p_hwfn
, false, "SET_LLDP failed, error = %d\n", rc
);
1553 enum _ecore_status_t
1554 ecore_dcbx_get_dscp_priority(struct ecore_hwfn
*p_hwfn
,
1555 u8 dscp_index
, u8
*p_dscp_pri
)
1557 struct ecore_dcbx_get
*p_dcbx_info
;
1558 enum _ecore_status_t rc
;
1560 if (dscp_index
>= ECORE_DCBX_DSCP_SIZE
) {
1561 DP_ERR(p_hwfn
, "Invalid dscp index %d\n", dscp_index
);
1565 p_dcbx_info
= OSAL_ALLOC(p_hwfn
->p_dev
, GFP_KERNEL
,
1566 sizeof(*p_dcbx_info
));
1570 OSAL_MEMSET(p_dcbx_info
, 0, sizeof(*p_dcbx_info
));
1571 rc
= ecore_dcbx_query_params(p_hwfn
, p_dcbx_info
,
1572 ECORE_DCBX_OPERATIONAL_MIB
);
1574 OSAL_FREE(p_hwfn
->p_dev
, p_dcbx_info
);
1578 *p_dscp_pri
= p_dcbx_info
->dscp
.dscp_pri_map
[dscp_index
];
1579 OSAL_FREE(p_hwfn
->p_dev
, p_dcbx_info
);
1581 return ECORE_SUCCESS
;
1584 enum _ecore_status_t
1585 ecore_dcbx_set_dscp_priority(struct ecore_hwfn
*p_hwfn
, struct ecore_ptt
*p_ptt
,
1586 u8 dscp_index
, u8 pri_val
)
1588 struct ecore_dcbx_set dcbx_set
;
1589 enum _ecore_status_t rc
;
1591 if (dscp_index
>= ECORE_DCBX_DSCP_SIZE
||
1592 pri_val
>= ECORE_MAX_PFC_PRIORITIES
) {
1593 DP_ERR(p_hwfn
, "Invalid dscp params: index = %d pri = %d\n",
1594 dscp_index
, pri_val
);
1598 OSAL_MEMSET(&dcbx_set
, 0, sizeof(dcbx_set
));
1599 rc
= ecore_dcbx_get_config_params(p_hwfn
, &dcbx_set
);
1603 dcbx_set
.override_flags
= ECORE_DCBX_OVERRIDE_DSCP_CFG
;
1604 dcbx_set
.dscp
.dscp_pri_map
[dscp_index
] = pri_val
;
1606 return ecore_dcbx_config_params(p_hwfn
, p_ptt
, &dcbx_set
, 1);