1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2001-2021 Intel Corporation
5 #include "ice_common.h"
11 * @hw: pointer to the HW struct
12 * @bridge_type: type of bridge requested
13 * @mib_type: Local, Remote or both Local and Remote MIBs
14 * @buf: pointer to the caller-supplied buffer to store the MIB block
15 * @buf_size: size of the buffer (in bytes)
16 * @local_len: length of the returned Local LLDP MIB
17 * @remote_len: length of the returned Remote LLDP MIB
18 * @cd: pointer to command details structure or NULL
20 * Requests the complete LLDP MIB (entire packet). (0x0A00)
23 ice_aq_get_lldp_mib(struct ice_hw *hw, u8 bridge_type, u8 mib_type, void *buf,
24 u16 buf_size, u16 *local_len, u16 *remote_len,
27 struct ice_aqc_lldp_get_mib *cmd;
28 struct ice_aq_desc desc;
29 enum ice_status status;
31 cmd = &desc.params.lldp_get_mib;
33 if (buf_size == 0 || !buf)
36 ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_lldp_get_mib);
38 cmd->type = mib_type & ICE_AQ_LLDP_MIB_TYPE_M;
39 cmd->type |= (bridge_type << ICE_AQ_LLDP_BRID_TYPE_S) &
40 ICE_AQ_LLDP_BRID_TYPE_M;
42 desc.datalen = CPU_TO_LE16(buf_size);
44 status = ice_aq_send_cmd(hw, &desc, buf, buf_size, cd);
47 *local_len = LE16_TO_CPU(cmd->local_len);
49 *remote_len = LE16_TO_CPU(cmd->remote_len);
56 * ice_aq_cfg_lldp_mib_change
57 * @hw: pointer to the HW struct
58 * @ena_update: Enable or Disable event posting
59 * @cd: pointer to command details structure or NULL
61 * Enable or Disable posting of an event on ARQ when LLDP MIB
62 * associated with the interface changes (0x0A01)
65 ice_aq_cfg_lldp_mib_change(struct ice_hw *hw, bool ena_update,
68 struct ice_aqc_lldp_set_mib_change *cmd;
69 struct ice_aq_desc desc;
71 cmd = &desc.params.lldp_set_event;
73 ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_lldp_set_mib_change);
76 cmd->command |= ICE_AQ_LLDP_MIB_UPDATE_DIS;
78 return ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
83 * @hw: pointer to the HW struct
84 * @shutdown_lldp_agent: True if LLDP Agent needs to be Shutdown
85 * False if LLDP Agent needs to be Stopped
86 * @persist: True if Stop/Shutdown of LLDP Agent needs to be persistent across
88 * @cd: pointer to command details structure or NULL
90 * Stop or Shutdown the embedded LLDP Agent (0x0A05)
93 ice_aq_stop_lldp(struct ice_hw *hw, bool shutdown_lldp_agent, bool persist,
96 struct ice_aqc_lldp_stop *cmd;
97 struct ice_aq_desc desc;
99 cmd = &desc.params.lldp_stop;
101 ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_lldp_stop);
103 if (shutdown_lldp_agent)
104 cmd->command |= ICE_AQ_LLDP_AGENT_SHUTDOWN;
107 cmd->command |= ICE_AQ_LLDP_AGENT_PERSIST_DIS;
109 return ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
114 * @hw: pointer to the HW struct
115 * @persist: True if Start of LLDP Agent needs to be persistent across reboots
116 * @cd: pointer to command details structure or NULL
118 * Start the embedded LLDP Agent on all ports. (0x0A06)
121 ice_aq_start_lldp(struct ice_hw *hw, bool persist, struct ice_sq_cd *cd)
123 struct ice_aqc_lldp_start *cmd;
124 struct ice_aq_desc desc;
126 cmd = &desc.params.lldp_start;
128 ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_lldp_start);
130 cmd->command = ICE_AQ_LLDP_AGENT_START;
133 cmd->command |= ICE_AQ_LLDP_AGENT_PERSIST_ENA;
135 return ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
139 * ice_get_dcbx_status
140 * @hw: pointer to the HW struct
142 * Get the DCBX status from the Firmware
144 u8 ice_get_dcbx_status(struct ice_hw *hw)
148 reg = rd32(hw, PRTDCB_GENS);
149 return (u8)((reg & PRTDCB_GENS_DCBX_STATUS_M) >>
150 PRTDCB_GENS_DCBX_STATUS_S);
154 * ice_parse_ieee_ets_common_tlv
155 * @buf: Data buffer to be parsed for ETS CFG/REC data
156 * @ets_cfg: Container to store parsed data
158 * Parses the common data of IEEE 802.1Qaz ETS CFG/REC TLV
161 ice_parse_ieee_ets_common_tlv(u8 *buf, struct ice_dcb_ets_cfg *ets_cfg)
166 /* Priority Assignment Table (4 octets)
167 * Octets:| 1 | 2 | 3 | 4 |
168 * -----------------------------------------
169 * |pri0|pri1|pri2|pri3|pri4|pri5|pri6|pri7|
170 * -----------------------------------------
171 * Bits:|7 4|3 0|7 4|3 0|7 4|3 0|7 4|3 0|
172 * -----------------------------------------
174 for (i = 0; i < 4; i++) {
175 ets_cfg->prio_table[i * 2] =
176 ((buf[offset] & ICE_IEEE_ETS_PRIO_1_M) >>
177 ICE_IEEE_ETS_PRIO_1_S);
178 ets_cfg->prio_table[i * 2 + 1] =
179 ((buf[offset] & ICE_IEEE_ETS_PRIO_0_M) >>
180 ICE_IEEE_ETS_PRIO_0_S);
184 /* TC Bandwidth Table (8 octets)
185 * Octets:| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
186 * ---------------------------------
187 * |tc0|tc1|tc2|tc3|tc4|tc5|tc6|tc7|
188 * ---------------------------------
190 * TSA Assignment Table (8 octets)
191 * Octets:| 9 | 10| 11| 12| 13| 14| 15| 16|
192 * ---------------------------------
193 * |tc0|tc1|tc2|tc3|tc4|tc5|tc6|tc7|
194 * ---------------------------------
196 ice_for_each_traffic_class(i) {
197 ets_cfg->tcbwtable[i] = buf[offset];
198 ets_cfg->tsatable[i] = buf[ICE_MAX_TRAFFIC_CLASS + offset++];
203 * ice_parse_ieee_etscfg_tlv
204 * @tlv: IEEE 802.1Qaz ETS CFG TLV
205 * @dcbcfg: Local store to update ETS CFG data
207 * Parses IEEE 802.1Qaz ETS CFG TLV
210 ice_parse_ieee_etscfg_tlv(struct ice_lldp_org_tlv *tlv,
211 struct ice_dcbx_cfg *dcbcfg)
213 struct ice_dcb_ets_cfg *etscfg;
214 u8 *buf = tlv->tlvinfo;
216 /* First Octet post subtype
217 * --------------------------
218 * |will-|CBS | Re- | Max |
219 * |ing | |served| TCs |
220 * --------------------------
221 * |1bit | 1bit|3 bits|3bits|
223 etscfg = &dcbcfg->etscfg;
224 etscfg->willing = ((buf[0] & ICE_IEEE_ETS_WILLING_M) >>
225 ICE_IEEE_ETS_WILLING_S);
226 etscfg->cbs = ((buf[0] & ICE_IEEE_ETS_CBS_M) >> ICE_IEEE_ETS_CBS_S);
227 etscfg->maxtcs = ((buf[0] & ICE_IEEE_ETS_MAXTC_M) >>
228 ICE_IEEE_ETS_MAXTC_S);
230 /* Begin parsing at Priority Assignment Table (offset 1 in buf) */
231 ice_parse_ieee_ets_common_tlv(&buf[1], etscfg);
235 * ice_parse_ieee_etsrec_tlv
236 * @tlv: IEEE 802.1Qaz ETS REC TLV
237 * @dcbcfg: Local store to update ETS REC data
239 * Parses IEEE 802.1Qaz ETS REC TLV
242 ice_parse_ieee_etsrec_tlv(struct ice_lldp_org_tlv *tlv,
243 struct ice_dcbx_cfg *dcbcfg)
245 u8 *buf = tlv->tlvinfo;
247 /* Begin parsing at Priority Assignment Table (offset 1 in buf) */
248 ice_parse_ieee_ets_common_tlv(&buf[1], &dcbcfg->etsrec);
252 * ice_parse_ieee_pfccfg_tlv
253 * @tlv: IEEE 802.1Qaz PFC CFG TLV
254 * @dcbcfg: Local store to update PFC CFG data
256 * Parses IEEE 802.1Qaz PFC CFG TLV
259 ice_parse_ieee_pfccfg_tlv(struct ice_lldp_org_tlv *tlv,
260 struct ice_dcbx_cfg *dcbcfg)
262 u8 *buf = tlv->tlvinfo;
264 /* ----------------------------------------
265 * |will-|MBC | Re- | PFC | PFC Enable |
266 * |ing | |served| cap | |
267 * -----------------------------------------
268 * |1bit | 1bit|2 bits|4bits| 1 octet |
270 dcbcfg->pfc.willing = ((buf[0] & ICE_IEEE_PFC_WILLING_M) >>
271 ICE_IEEE_PFC_WILLING_S);
272 dcbcfg->pfc.mbc = ((buf[0] & ICE_IEEE_PFC_MBC_M) >> ICE_IEEE_PFC_MBC_S);
273 dcbcfg->pfc.pfccap = ((buf[0] & ICE_IEEE_PFC_CAP_M) >>
275 dcbcfg->pfc.pfcena = buf[1];
279 * ice_parse_ieee_app_tlv
280 * @tlv: IEEE 802.1Qaz APP TLV
281 * @dcbcfg: Local store to update APP PRIO data
283 * Parses IEEE 802.1Qaz APP PRIO TLV
286 ice_parse_ieee_app_tlv(struct ice_lldp_org_tlv *tlv,
287 struct ice_dcbx_cfg *dcbcfg)
295 typelen = NTOHS(tlv->typelen);
296 len = ((typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S);
299 /* Removing sizeof(ouisubtype) and reserved byte from len.
300 * Remaining len div 3 is number of APP TLVs.
302 len -= (sizeof(tlv->ouisubtype) + 1);
304 /* Move offset to App Priority Table */
307 /* Application Priority Table (3 octets)
308 * Octets:| 1 | 2 | 3 |
309 * -----------------------------------------
310 * |Priority|Rsrvd| Sel | Protocol ID |
311 * -----------------------------------------
312 * Bits:|23 21|20 19|18 16|15 0|
313 * -----------------------------------------
315 while (offset < len) {
316 dcbcfg->app[i].priority = ((buf[offset] &
317 ICE_IEEE_APP_PRIO_M) >>
318 ICE_IEEE_APP_PRIO_S);
319 dcbcfg->app[i].selector = ((buf[offset] &
320 ICE_IEEE_APP_SEL_M) >>
322 dcbcfg->app[i].prot_id = (buf[offset + 1] << 0x8) |
324 /* Move to next app */
327 if (i >= ICE_DCBX_MAX_APPS)
336 * @tlv: IEEE 802.1Qaz TLV
337 * @dcbcfg: Local store to update ETS REC data
339 * Get the TLV subtype and send it to parsing function
340 * based on the subtype value
343 ice_parse_ieee_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg)
348 ouisubtype = NTOHL(tlv->ouisubtype);
349 subtype = (u8)((ouisubtype & ICE_LLDP_TLV_SUBTYPE_M) >>
350 ICE_LLDP_TLV_SUBTYPE_S);
352 case ICE_IEEE_SUBTYPE_ETS_CFG:
353 ice_parse_ieee_etscfg_tlv(tlv, dcbcfg);
355 case ICE_IEEE_SUBTYPE_ETS_REC:
356 ice_parse_ieee_etsrec_tlv(tlv, dcbcfg);
358 case ICE_IEEE_SUBTYPE_PFC_CFG:
359 ice_parse_ieee_pfccfg_tlv(tlv, dcbcfg);
361 case ICE_IEEE_SUBTYPE_APP_PRI:
362 ice_parse_ieee_app_tlv(tlv, dcbcfg);
370 * ice_parse_cee_pgcfg_tlv
371 * @tlv: CEE DCBX PG CFG TLV
372 * @dcbcfg: Local store to update ETS CFG data
374 * Parses CEE DCBX PG CFG TLV
377 ice_parse_cee_pgcfg_tlv(struct ice_cee_feat_tlv *tlv,
378 struct ice_dcbx_cfg *dcbcfg)
380 struct ice_dcb_ets_cfg *etscfg;
381 u8 *buf = tlv->tlvinfo;
385 etscfg = &dcbcfg->etscfg;
387 if (tlv->en_will_err & ICE_CEE_FEAT_TLV_WILLING_M)
391 /* Priority Group Table (4 octets)
392 * Octets:| 1 | 2 | 3 | 4 |
393 * -----------------------------------------
394 * |pri0|pri1|pri2|pri3|pri4|pri5|pri6|pri7|
395 * -----------------------------------------
396 * Bits:|7 4|3 0|7 4|3 0|7 4|3 0|7 4|3 0|
397 * -----------------------------------------
399 for (i = 0; i < 4; i++) {
400 etscfg->prio_table[i * 2] =
401 ((buf[offset] & ICE_CEE_PGID_PRIO_1_M) >>
402 ICE_CEE_PGID_PRIO_1_S);
403 etscfg->prio_table[i * 2 + 1] =
404 ((buf[offset] & ICE_CEE_PGID_PRIO_0_M) >>
405 ICE_CEE_PGID_PRIO_0_S);
409 /* PG Percentage Table (8 octets)
410 * Octets:| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
411 * ---------------------------------
412 * |pg0|pg1|pg2|pg3|pg4|pg5|pg6|pg7|
413 * ---------------------------------
415 ice_for_each_traffic_class(i) {
416 etscfg->tcbwtable[i] = buf[offset++];
418 if (etscfg->prio_table[i] == ICE_CEE_PGID_STRICT)
419 dcbcfg->etscfg.tsatable[i] = ICE_IEEE_TSA_STRICT;
421 dcbcfg->etscfg.tsatable[i] = ICE_IEEE_TSA_ETS;
424 /* Number of TCs supported (1 octet) */
425 etscfg->maxtcs = buf[offset];
429 * ice_parse_cee_pfccfg_tlv
430 * @tlv: CEE DCBX PFC CFG TLV
431 * @dcbcfg: Local store to update PFC CFG data
433 * Parses CEE DCBX PFC CFG TLV
436 ice_parse_cee_pfccfg_tlv(struct ice_cee_feat_tlv *tlv,
437 struct ice_dcbx_cfg *dcbcfg)
439 u8 *buf = tlv->tlvinfo;
441 if (tlv->en_will_err & ICE_CEE_FEAT_TLV_WILLING_M)
442 dcbcfg->pfc.willing = 1;
444 /* ------------------------
445 * | PFC Enable | PFC TCs |
446 * ------------------------
447 * | 1 octet | 1 octet |
449 dcbcfg->pfc.pfcena = buf[0];
450 dcbcfg->pfc.pfccap = buf[1];
454 * ice_parse_cee_app_tlv
455 * @tlv: CEE DCBX APP TLV
456 * @dcbcfg: Local store to update APP PRIO data
458 * Parses CEE DCBX APP PRIO TLV
461 ice_parse_cee_app_tlv(struct ice_cee_feat_tlv *tlv, struct ice_dcbx_cfg *dcbcfg)
463 u16 len, typelen, offset = 0;
464 struct ice_cee_app_prio *app;
467 typelen = NTOHS(tlv->hdr.typelen);
468 len = ((typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S);
470 dcbcfg->numapps = len / sizeof(*app);
471 if (!dcbcfg->numapps)
473 if (dcbcfg->numapps > ICE_DCBX_MAX_APPS)
474 dcbcfg->numapps = ICE_DCBX_MAX_APPS;
476 for (i = 0; i < dcbcfg->numapps; i++) {
479 app = (struct ice_cee_app_prio *)(tlv->tlvinfo + offset);
480 for (up = 0; up < ICE_MAX_USER_PRIORITY; up++)
481 if (app->prio_map & BIT(up))
484 dcbcfg->app[i].priority = up;
486 /* Get Selector from lower 2 bits, and convert to IEEE */
487 selector = (app->upper_oui_sel & ICE_CEE_APP_SELECTOR_M);
489 case ICE_CEE_APP_SEL_ETHTYPE:
490 dcbcfg->app[i].selector = ICE_APP_SEL_ETHTYPE;
492 case ICE_CEE_APP_SEL_TCPIP:
493 dcbcfg->app[i].selector = ICE_APP_SEL_TCPIP;
496 /* Keep selector as it is for unknown types */
497 dcbcfg->app[i].selector = selector;
500 dcbcfg->app[i].prot_id = NTOHS(app->protocol);
501 /* Move to next app */
502 offset += sizeof(*app);
509 * @dcbcfg: Local store to update DCBX config data
511 * Get the TLV subtype and send it to parsing function
512 * based on the subtype value
515 ice_parse_cee_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg)
517 struct ice_cee_feat_tlv *sub_tlv;
518 u8 subtype, feat_tlv_count = 0;
519 u16 len, tlvlen, typelen;
522 ouisubtype = NTOHL(tlv->ouisubtype);
523 subtype = (u8)((ouisubtype & ICE_LLDP_TLV_SUBTYPE_M) >>
524 ICE_LLDP_TLV_SUBTYPE_S);
525 /* Return if not CEE DCBX */
526 if (subtype != ICE_CEE_DCBX_TYPE)
529 typelen = NTOHS(tlv->typelen);
530 tlvlen = ((typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S);
531 len = sizeof(tlv->typelen) + sizeof(ouisubtype) +
532 sizeof(struct ice_cee_ctrl_tlv);
533 /* Return if no CEE DCBX Feature TLVs */
537 sub_tlv = (struct ice_cee_feat_tlv *)((char *)tlv + len);
538 while (feat_tlv_count < ICE_CEE_MAX_FEAT_TYPE) {
541 typelen = NTOHS(sub_tlv->hdr.typelen);
542 sublen = ((typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S);
543 subtype = (u8)((typelen & ICE_LLDP_TLV_TYPE_M) >>
544 ICE_LLDP_TLV_TYPE_S);
546 case ICE_CEE_SUBTYPE_PG_CFG:
547 ice_parse_cee_pgcfg_tlv(sub_tlv, dcbcfg);
549 case ICE_CEE_SUBTYPE_PFC_CFG:
550 ice_parse_cee_pfccfg_tlv(sub_tlv, dcbcfg);
552 case ICE_CEE_SUBTYPE_APP_PRI:
553 ice_parse_cee_app_tlv(sub_tlv, dcbcfg);
556 return; /* Invalid Sub-type return */
559 /* Move to next sub TLV */
560 sub_tlv = (struct ice_cee_feat_tlv *)
561 ((char *)sub_tlv + sizeof(sub_tlv->hdr.typelen) +
568 * @tlv: Organization specific TLV
569 * @dcbcfg: Local store to update ETS REC data
571 * Currently only IEEE 802.1Qaz TLV is supported, all others
575 ice_parse_org_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg)
580 ouisubtype = NTOHL(tlv->ouisubtype);
581 oui = ((ouisubtype & ICE_LLDP_TLV_OUI_M) >> ICE_LLDP_TLV_OUI_S);
583 case ICE_IEEE_8021QAZ_OUI:
584 ice_parse_ieee_tlv(tlv, dcbcfg);
586 case ICE_CEE_DCBX_OUI:
587 ice_parse_cee_tlv(tlv, dcbcfg);
595 * ice_lldp_to_dcb_cfg
596 * @lldpmib: LLDPDU to be parsed
597 * @dcbcfg: store for LLDPDU data
599 * Parse DCB configuration from the LLDPDU
601 enum ice_status ice_lldp_to_dcb_cfg(u8 *lldpmib, struct ice_dcbx_cfg *dcbcfg)
603 struct ice_lldp_org_tlv *tlv;
604 enum ice_status ret = ICE_SUCCESS;
610 if (!lldpmib || !dcbcfg)
611 return ICE_ERR_PARAM;
613 /* set to the start of LLDPDU */
614 lldpmib += ETH_HEADER_LEN;
615 tlv = (struct ice_lldp_org_tlv *)lldpmib;
617 typelen = NTOHS(tlv->typelen);
618 type = ((typelen & ICE_LLDP_TLV_TYPE_M) >> ICE_LLDP_TLV_TYPE_S);
619 len = ((typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S);
620 offset += sizeof(typelen) + len;
622 /* END TLV or beyond LLDPDU size */
623 if (type == ICE_TLV_TYPE_END || offset > ICE_LLDPDU_SIZE)
627 case ICE_TLV_TYPE_ORG:
628 ice_parse_org_tlv(tlv, dcbcfg);
634 /* Move to next TLV */
635 tlv = (struct ice_lldp_org_tlv *)
636 ((char *)tlv + sizeof(tlv->typelen) + len);
644 * @hw: pointer to the HW struct
645 * @mib_type: MIB type for the query
646 * @bridgetype: bridge type for the query (remote)
647 * @dcbcfg: store for LLDPDU data
649 * Query DCB configuration from the firmware
652 ice_aq_get_dcb_cfg(struct ice_hw *hw, u8 mib_type, u8 bridgetype,
653 struct ice_dcbx_cfg *dcbcfg)
658 /* Allocate the LLDPDU */
659 lldpmib = (u8 *)ice_malloc(hw, ICE_LLDPDU_SIZE);
661 return ICE_ERR_NO_MEMORY;
663 ret = ice_aq_get_lldp_mib(hw, bridgetype, mib_type, (void *)lldpmib,
664 ICE_LLDPDU_SIZE, NULL, NULL, NULL);
666 if (ret == ICE_SUCCESS)
667 /* Parse LLDP MIB to get DCB configuration */
668 ret = ice_lldp_to_dcb_cfg(lldpmib, dcbcfg);
670 ice_free(hw, lldpmib);
676 * ice_aq_start_stop_dcbx - Start/Stop DCBX service in FW
677 * @hw: pointer to the HW struct
678 * @start_dcbx_agent: True if DCBX Agent needs to be started
679 * False if DCBX Agent needs to be stopped
680 * @dcbx_agent_status: FW indicates back the DCBX agent status
681 * True if DCBX Agent is active
682 * False if DCBX Agent is stopped
683 * @cd: pointer to command details structure or NULL
685 * Start/Stop the embedded dcbx Agent. In case that this wrapper function
686 * returns ICE_SUCCESS, caller will need to check if FW returns back the same
687 * value as stated in dcbx_agent_status, and react accordingly. (0x0A09)
690 ice_aq_start_stop_dcbx(struct ice_hw *hw, bool start_dcbx_agent,
691 bool *dcbx_agent_status, struct ice_sq_cd *cd)
693 struct ice_aqc_lldp_stop_start_specific_agent *cmd;
694 enum ice_status status;
695 struct ice_aq_desc desc;
698 cmd = &desc.params.lldp_agent_ctrl;
700 opcode = ice_aqc_opc_lldp_stop_start_specific_agent;
702 ice_fill_dflt_direct_cmd_desc(&desc, opcode);
704 if (start_dcbx_agent)
705 cmd->command = ICE_AQC_START_STOP_AGENT_START_DCBX;
707 status = ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
709 *dcbx_agent_status = false;
711 if (status == ICE_SUCCESS &&
712 cmd->command == ICE_AQC_START_STOP_AGENT_START_DCBX)
713 *dcbx_agent_status = true;
719 * ice_aq_get_cee_dcb_cfg
720 * @hw: pointer to the HW struct
721 * @buff: response buffer that stores CEE operational configuration
722 * @cd: pointer to command details structure or NULL
724 * Get CEE DCBX mode operational configuration from firmware (0x0A07)
727 ice_aq_get_cee_dcb_cfg(struct ice_hw *hw,
728 struct ice_aqc_get_cee_dcb_cfg_resp *buff,
729 struct ice_sq_cd *cd)
731 struct ice_aq_desc desc;
733 ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_get_cee_dcb_cfg);
735 return ice_aq_send_cmd(hw, &desc, (void *)buff, sizeof(*buff), cd);
740 * @cee_cfg: pointer to CEE configuration struct
741 * @pi: port information structure
743 * Convert CEE configuration from firmware to DCB configuration
746 ice_cee_to_dcb_cfg(struct ice_aqc_get_cee_dcb_cfg_resp *cee_cfg,
747 struct ice_port_info *pi)
749 u32 status, tlv_status = LE32_TO_CPU(cee_cfg->tlv_status);
750 u32 ice_aqc_cee_status_mask, ice_aqc_cee_status_shift;
751 u8 i, j, err, sync, oper, app_index, ice_app_sel_type;
752 u16 app_prio = LE16_TO_CPU(cee_cfg->oper_app_prio);
753 u16 ice_aqc_cee_app_mask, ice_aqc_cee_app_shift;
754 struct ice_dcbx_cfg *cmp_dcbcfg, *dcbcfg;
755 u16 ice_app_prot_id_type;
757 dcbcfg = &pi->qos_cfg.local_dcbx_cfg;
758 dcbcfg->dcbx_mode = ICE_DCBX_MODE_CEE;
759 dcbcfg->tlv_status = tlv_status;
762 dcbcfg->etscfg.maxtcs = cee_cfg->oper_num_tc;
764 /* Note that the FW creates the oper_prio_tc nibbles reversed
765 * from those in the CEE Priority Group sub-TLV.
767 for (i = 0; i < ICE_MAX_TRAFFIC_CLASS / 2; i++) {
768 dcbcfg->etscfg.prio_table[i * 2] =
769 ((cee_cfg->oper_prio_tc[i] & ICE_CEE_PGID_PRIO_0_M) >>
770 ICE_CEE_PGID_PRIO_0_S);
771 dcbcfg->etscfg.prio_table[i * 2 + 1] =
772 ((cee_cfg->oper_prio_tc[i] & ICE_CEE_PGID_PRIO_1_M) >>
773 ICE_CEE_PGID_PRIO_1_S);
776 ice_for_each_traffic_class(i) {
777 dcbcfg->etscfg.tcbwtable[i] = cee_cfg->oper_tc_bw[i];
779 if (dcbcfg->etscfg.prio_table[i] == ICE_CEE_PGID_STRICT) {
780 /* Map it to next empty TC */
781 dcbcfg->etscfg.prio_table[i] = cee_cfg->oper_num_tc - 1;
782 dcbcfg->etscfg.tsatable[i] = ICE_IEEE_TSA_STRICT;
784 dcbcfg->etscfg.tsatable[i] = ICE_IEEE_TSA_ETS;
789 dcbcfg->pfc.pfcena = cee_cfg->oper_pfc_en;
790 dcbcfg->pfc.pfccap = ICE_MAX_TRAFFIC_CLASS;
792 /* CEE APP TLV data */
793 if (dcbcfg->app_mode == ICE_DCBX_APPS_NON_WILLING)
794 cmp_dcbcfg = &pi->qos_cfg.desired_dcbx_cfg;
796 cmp_dcbcfg = &pi->qos_cfg.remote_dcbx_cfg;
799 for (i = 0; i < 3; i++) {
802 ice_aqc_cee_status_mask = ICE_AQC_CEE_FCOE_STATUS_M;
803 ice_aqc_cee_status_shift = ICE_AQC_CEE_FCOE_STATUS_S;
804 ice_aqc_cee_app_mask = ICE_AQC_CEE_APP_FCOE_M;
805 ice_aqc_cee_app_shift = ICE_AQC_CEE_APP_FCOE_S;
806 ice_app_sel_type = ICE_APP_SEL_ETHTYPE;
807 ice_app_prot_id_type = ICE_APP_PROT_ID_FCOE;
810 ice_aqc_cee_status_mask = ICE_AQC_CEE_ISCSI_STATUS_M;
811 ice_aqc_cee_status_shift = ICE_AQC_CEE_ISCSI_STATUS_S;
812 ice_aqc_cee_app_mask = ICE_AQC_CEE_APP_ISCSI_M;
813 ice_aqc_cee_app_shift = ICE_AQC_CEE_APP_ISCSI_S;
814 ice_app_sel_type = ICE_APP_SEL_TCPIP;
815 ice_app_prot_id_type = ICE_APP_PROT_ID_ISCSI;
817 for (j = 0; j < cmp_dcbcfg->numapps; j++) {
818 u16 prot_id = cmp_dcbcfg->app[j].prot_id;
819 u8 sel = cmp_dcbcfg->app[j].selector;
821 if (sel == ICE_APP_SEL_TCPIP &&
822 (prot_id == ICE_APP_PROT_ID_ISCSI ||
823 prot_id == ICE_APP_PROT_ID_ISCSI_860)) {
824 ice_app_prot_id_type = prot_id;
830 ice_aqc_cee_status_mask = ICE_AQC_CEE_FIP_STATUS_M;
831 ice_aqc_cee_status_shift = ICE_AQC_CEE_FIP_STATUS_S;
832 ice_aqc_cee_app_mask = ICE_AQC_CEE_APP_FIP_M;
833 ice_aqc_cee_app_shift = ICE_AQC_CEE_APP_FIP_S;
834 ice_app_sel_type = ICE_APP_SEL_ETHTYPE;
835 ice_app_prot_id_type = ICE_APP_PROT_ID_FIP;
838 status = (tlv_status & ice_aqc_cee_status_mask) >>
839 ice_aqc_cee_status_shift;
840 err = (status & ICE_TLV_STATUS_ERR) ? 1 : 0;
841 sync = (status & ICE_TLV_STATUS_SYNC) ? 1 : 0;
842 oper = (status & ICE_TLV_STATUS_OPER) ? 1 : 0;
843 /* Add FCoE/iSCSI/FIP APP if Error is False and
846 if (!err && sync && oper) {
847 dcbcfg->app[app_index].priority =
848 (app_prio & ice_aqc_cee_app_mask) >>
849 ice_aqc_cee_app_shift;
850 dcbcfg->app[app_index].selector = ice_app_sel_type;
851 dcbcfg->app[app_index].prot_id = ice_app_prot_id_type;
856 dcbcfg->numapps = app_index;
860 * ice_get_ieee_dcb_cfg
861 * @pi: port information structure
862 * @dcbx_mode: mode of DCBX (IEEE or CEE)
864 * Get IEEE or CEE mode DCB configuration from the Firmware
866 STATIC enum ice_status
867 ice_get_ieee_or_cee_dcb_cfg(struct ice_port_info *pi, u8 dcbx_mode)
869 struct ice_dcbx_cfg *dcbx_cfg = NULL;
873 return ICE_ERR_PARAM;
875 if (dcbx_mode == ICE_DCBX_MODE_IEEE)
876 dcbx_cfg = &pi->qos_cfg.local_dcbx_cfg;
877 else if (dcbx_mode == ICE_DCBX_MODE_CEE)
878 dcbx_cfg = &pi->qos_cfg.desired_dcbx_cfg;
880 /* Get Local DCB Config in case of ICE_DCBX_MODE_IEEE
881 * or get CEE DCB Desired Config in case of ICE_DCBX_MODE_CEE
883 ret = ice_aq_get_dcb_cfg(pi->hw, ICE_AQ_LLDP_MIB_LOCAL,
884 ICE_AQ_LLDP_BRID_TYPE_NEAREST_BRID, dcbx_cfg);
888 /* Get Remote DCB Config */
889 dcbx_cfg = &pi->qos_cfg.remote_dcbx_cfg;
890 ret = ice_aq_get_dcb_cfg(pi->hw, ICE_AQ_LLDP_MIB_REMOTE,
891 ICE_AQ_LLDP_BRID_TYPE_NEAREST_BRID, dcbx_cfg);
892 /* Don't treat ENOENT as an error for Remote MIBs */
893 if (pi->hw->adminq.sq_last_status == ICE_AQ_RC_ENOENT)
902 * @pi: port information structure
904 * Get DCB configuration from the Firmware
906 enum ice_status ice_get_dcb_cfg(struct ice_port_info *pi)
908 struct ice_aqc_get_cee_dcb_cfg_resp cee_cfg;
909 struct ice_dcbx_cfg *dcbx_cfg;
913 return ICE_ERR_PARAM;
915 ret = ice_aq_get_cee_dcb_cfg(pi->hw, &cee_cfg, NULL);
916 if (ret == ICE_SUCCESS) {
918 ret = ice_get_ieee_or_cee_dcb_cfg(pi, ICE_DCBX_MODE_CEE);
919 ice_cee_to_dcb_cfg(&cee_cfg, pi);
920 } else if (pi->hw->adminq.sq_last_status == ICE_AQ_RC_ENOENT) {
921 /* CEE mode not enabled try querying IEEE data */
922 dcbx_cfg = &pi->qos_cfg.local_dcbx_cfg;
923 dcbx_cfg->dcbx_mode = ICE_DCBX_MODE_IEEE;
924 ret = ice_get_ieee_or_cee_dcb_cfg(pi, ICE_DCBX_MODE_IEEE);
932 * @hw: pointer to the HW struct
933 * @enable_mib_change: enable MIB change event
935 * Update DCB configuration from the Firmware
937 enum ice_status ice_init_dcb(struct ice_hw *hw, bool enable_mib_change)
939 struct ice_qos_cfg *qos_cfg = &hw->port_info->qos_cfg;
940 enum ice_status ret = ICE_SUCCESS;
942 if (!hw->func_caps.common_cap.dcb)
943 return ICE_ERR_NOT_SUPPORTED;
945 qos_cfg->is_sw_lldp = true;
947 /* Get DCBX status */
948 qos_cfg->dcbx_status = ice_get_dcbx_status(hw);
950 if (qos_cfg->dcbx_status == ICE_DCBX_STATUS_DONE ||
951 qos_cfg->dcbx_status == ICE_DCBX_STATUS_IN_PROGRESS ||
952 qos_cfg->dcbx_status == ICE_DCBX_STATUS_NOT_STARTED) {
953 /* Get current DCBX configuration */
954 ret = ice_get_dcb_cfg(hw->port_info);
957 qos_cfg->is_sw_lldp = false;
958 } else if (qos_cfg->dcbx_status == ICE_DCBX_STATUS_DIS) {
959 return ICE_ERR_NOT_READY;
962 /* Configure the LLDP MIB change event */
963 if (enable_mib_change) {
964 ret = ice_aq_cfg_lldp_mib_change(hw, true, NULL);
966 qos_cfg->is_sw_lldp = true;
973 * ice_cfg_lldp_mib_change
974 * @hw: pointer to the HW struct
975 * @ena_mib: enable/disable MIB change event
977 * Configure (disable/enable) MIB
979 enum ice_status ice_cfg_lldp_mib_change(struct ice_hw *hw, bool ena_mib)
981 struct ice_qos_cfg *qos_cfg = &hw->port_info->qos_cfg;
984 if (!hw->func_caps.common_cap.dcb)
985 return ICE_ERR_NOT_SUPPORTED;
987 /* Get DCBX status */
988 qos_cfg->dcbx_status = ice_get_dcbx_status(hw);
990 if (qos_cfg->dcbx_status == ICE_DCBX_STATUS_DIS)
991 return ICE_ERR_NOT_READY;
993 ret = ice_aq_cfg_lldp_mib_change(hw, ena_mib, NULL);
995 qos_cfg->is_sw_lldp = !ena_mib;
1001 * ice_add_ieee_ets_common_tlv
1002 * @buf: Data buffer to be populated with ice_dcb_ets_cfg data
1003 * @ets_cfg: Container for ice_dcb_ets_cfg data
1005 * Populate the TLV buffer with ice_dcb_ets_cfg data
1008 ice_add_ieee_ets_common_tlv(u8 *buf, struct ice_dcb_ets_cfg *ets_cfg)
1010 u8 priority0, priority1;
1014 /* Priority Assignment Table (4 octets)
1015 * Octets:| 1 | 2 | 3 | 4 |
1016 * -----------------------------------------
1017 * |pri0|pri1|pri2|pri3|pri4|pri5|pri6|pri7|
1018 * -----------------------------------------
1019 * Bits:|7 4|3 0|7 4|3 0|7 4|3 0|7 4|3 0|
1020 * -----------------------------------------
1022 for (i = 0; i < ICE_MAX_TRAFFIC_CLASS / 2; i++) {
1023 priority0 = ets_cfg->prio_table[i * 2] & 0xF;
1024 priority1 = ets_cfg->prio_table[i * 2 + 1] & 0xF;
1025 buf[offset] = (priority0 << ICE_IEEE_ETS_PRIO_1_S) | priority1;
1029 /* TC Bandwidth Table (8 octets)
1030 * Octets:| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
1031 * ---------------------------------
1032 * |tc0|tc1|tc2|tc3|tc4|tc5|tc6|tc7|
1033 * ---------------------------------
1035 * TSA Assignment Table (8 octets)
1036 * Octets:| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
1037 * ---------------------------------
1038 * |tc0|tc1|tc2|tc3|tc4|tc5|tc6|tc7|
1039 * ---------------------------------
1041 ice_for_each_traffic_class(i) {
1042 buf[offset] = ets_cfg->tcbwtable[i];
1043 buf[ICE_MAX_TRAFFIC_CLASS + offset] = ets_cfg->tsatable[i];
1049 * ice_add_ieee_ets_tlv - Prepare ETS TLV in IEEE format
1050 * @tlv: Fill the ETS config data in IEEE format
1051 * @dcbcfg: Local store which holds the DCB Config
1053 * Prepare IEEE 802.1Qaz ETS CFG TLV
1056 ice_add_ieee_ets_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg)
1058 struct ice_dcb_ets_cfg *etscfg;
1059 u8 *buf = tlv->tlvinfo;
1060 u8 maxtcwilling = 0;
1064 typelen = ((ICE_TLV_TYPE_ORG << ICE_LLDP_TLV_TYPE_S) |
1065 ICE_IEEE_ETS_TLV_LEN);
1066 tlv->typelen = HTONS(typelen);
1068 ouisubtype = ((ICE_IEEE_8021QAZ_OUI << ICE_LLDP_TLV_OUI_S) |
1069 ICE_IEEE_SUBTYPE_ETS_CFG);
1070 tlv->ouisubtype = HTONL(ouisubtype);
1072 /* First Octet post subtype
1073 * --------------------------
1074 * |will-|CBS | Re- | Max |
1075 * |ing | |served| TCs |
1076 * --------------------------
1077 * |1bit | 1bit|3 bits|3bits|
1079 etscfg = &dcbcfg->etscfg;
1080 if (etscfg->willing)
1081 maxtcwilling = BIT(ICE_IEEE_ETS_WILLING_S);
1082 maxtcwilling |= etscfg->maxtcs & ICE_IEEE_ETS_MAXTC_M;
1083 buf[0] = maxtcwilling;
1085 /* Begin adding at Priority Assignment Table (offset 1 in buf) */
1086 ice_add_ieee_ets_common_tlv(&buf[1], etscfg);
1090 * ice_add_ieee_etsrec_tlv - Prepare ETS Recommended TLV in IEEE format
1091 * @tlv: Fill ETS Recommended TLV in IEEE format
1092 * @dcbcfg: Local store which holds the DCB Config
1094 * Prepare IEEE 802.1Qaz ETS REC TLV
1097 ice_add_ieee_etsrec_tlv(struct ice_lldp_org_tlv *tlv,
1098 struct ice_dcbx_cfg *dcbcfg)
1100 struct ice_dcb_ets_cfg *etsrec;
1101 u8 *buf = tlv->tlvinfo;
1105 typelen = ((ICE_TLV_TYPE_ORG << ICE_LLDP_TLV_TYPE_S) |
1106 ICE_IEEE_ETS_TLV_LEN);
1107 tlv->typelen = HTONS(typelen);
1109 ouisubtype = ((ICE_IEEE_8021QAZ_OUI << ICE_LLDP_TLV_OUI_S) |
1110 ICE_IEEE_SUBTYPE_ETS_REC);
1111 tlv->ouisubtype = HTONL(ouisubtype);
1113 etsrec = &dcbcfg->etsrec;
1115 /* First Octet is reserved */
1116 /* Begin adding at Priority Assignment Table (offset 1 in buf) */
1117 ice_add_ieee_ets_common_tlv(&buf[1], etsrec);
1121 * ice_add_ieee_pfc_tlv - Prepare PFC TLV in IEEE format
1122 * @tlv: Fill PFC TLV in IEEE format
1123 * @dcbcfg: Local store which holds the PFC CFG data
1125 * Prepare IEEE 802.1Qaz PFC CFG TLV
1128 ice_add_ieee_pfc_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg)
1130 u8 *buf = tlv->tlvinfo;
1134 typelen = ((ICE_TLV_TYPE_ORG << ICE_LLDP_TLV_TYPE_S) |
1135 ICE_IEEE_PFC_TLV_LEN);
1136 tlv->typelen = HTONS(typelen);
1138 ouisubtype = ((ICE_IEEE_8021QAZ_OUI << ICE_LLDP_TLV_OUI_S) |
1139 ICE_IEEE_SUBTYPE_PFC_CFG);
1140 tlv->ouisubtype = HTONL(ouisubtype);
1142 /* ----------------------------------------
1143 * |will-|MBC | Re- | PFC | PFC Enable |
1144 * |ing | |served| cap | |
1145 * -----------------------------------------
1146 * |1bit | 1bit|2 bits|4bits| 1 octet |
1148 if (dcbcfg->pfc.willing)
1149 buf[0] = BIT(ICE_IEEE_PFC_WILLING_S);
1151 if (dcbcfg->pfc.mbc)
1152 buf[0] |= BIT(ICE_IEEE_PFC_MBC_S);
1154 buf[0] |= dcbcfg->pfc.pfccap & 0xF;
1155 buf[1] = dcbcfg->pfc.pfcena;
1159 * ice_add_ieee_app_pri_tlv - Prepare APP TLV in IEEE format
1160 * @tlv: Fill APP TLV in IEEE format
1161 * @dcbcfg: Local store which holds the APP CFG data
1163 * Prepare IEEE 802.1Qaz APP CFG TLV
1166 ice_add_ieee_app_pri_tlv(struct ice_lldp_org_tlv *tlv,
1167 struct ice_dcbx_cfg *dcbcfg)
1169 u16 typelen, len, offset = 0;
1170 u8 priority, selector, i = 0;
1171 u8 *buf = tlv->tlvinfo;
1174 /* No APP TLVs then just return */
1175 if (dcbcfg->numapps == 0)
1177 ouisubtype = ((ICE_IEEE_8021QAZ_OUI << ICE_LLDP_TLV_OUI_S) |
1178 ICE_IEEE_SUBTYPE_APP_PRI);
1179 tlv->ouisubtype = HTONL(ouisubtype);
1181 /* Move offset to App Priority Table */
1183 /* Application Priority Table (3 octets)
1184 * Octets:| 1 | 2 | 3 |
1185 * -----------------------------------------
1186 * |Priority|Rsrvd| Sel | Protocol ID |
1187 * -----------------------------------------
1188 * Bits:|23 21|20 19|18 16|15 0|
1189 * -----------------------------------------
1191 while (i < dcbcfg->numapps) {
1192 priority = dcbcfg->app[i].priority & 0x7;
1193 selector = dcbcfg->app[i].selector & 0x7;
1194 buf[offset] = (priority << ICE_IEEE_APP_PRIO_S) | selector;
1195 buf[offset + 1] = (dcbcfg->app[i].prot_id >> 0x8) & 0xFF;
1196 buf[offset + 2] = dcbcfg->app[i].prot_id & 0xFF;
1197 /* Move to next app */
1200 if (i >= ICE_DCBX_MAX_APPS)
1203 /* len includes size of ouisubtype + 1 reserved + 3*numapps */
1204 len = sizeof(tlv->ouisubtype) + 1 + (i * 3);
1205 typelen = ((ICE_TLV_TYPE_ORG << ICE_LLDP_TLV_TYPE_S) | (len & 0x1FF));
1206 tlv->typelen = HTONS(typelen);
1210 * ice_add_dcb_tlv - Add all IEEE TLVs
1211 * @tlv: Fill TLV data in IEEE format
1212 * @dcbcfg: Local store which holds the DCB Config
1213 * @tlvid: Type of IEEE TLV
1215 * Add tlv information
1218 ice_add_dcb_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg,
1222 case ICE_IEEE_TLV_ID_ETS_CFG:
1223 ice_add_ieee_ets_tlv(tlv, dcbcfg);
1225 case ICE_IEEE_TLV_ID_ETS_REC:
1226 ice_add_ieee_etsrec_tlv(tlv, dcbcfg);
1228 case ICE_IEEE_TLV_ID_PFC_CFG:
1229 ice_add_ieee_pfc_tlv(tlv, dcbcfg);
1231 case ICE_IEEE_TLV_ID_APP_PRI:
1232 ice_add_ieee_app_pri_tlv(tlv, dcbcfg);
1240 * ice_dcb_cfg_to_lldp - Convert DCB configuration to MIB format
1241 * @lldpmib: pointer to the HW struct
1242 * @miblen: length of LLDP MIB
1243 * @dcbcfg: Local store which holds the DCB Config
1245 * Convert the DCB configuration to MIB format
1247 void ice_dcb_cfg_to_lldp(u8 *lldpmib, u16 *miblen, struct ice_dcbx_cfg *dcbcfg)
1249 u16 len, offset = 0, tlvid = ICE_TLV_ID_START;
1250 struct ice_lldp_org_tlv *tlv;
1253 tlv = (struct ice_lldp_org_tlv *)lldpmib;
1255 ice_add_dcb_tlv(tlv, dcbcfg, tlvid++);
1256 typelen = NTOHS(tlv->typelen);
1257 len = (typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S;
1260 /* END TLV or beyond LLDPDU size */
1261 if (tlvid >= ICE_TLV_ID_END_OF_LLDPPDU ||
1262 offset > ICE_LLDPDU_SIZE)
1264 /* Move to next TLV */
1266 tlv = (struct ice_lldp_org_tlv *)
1267 ((char *)tlv + sizeof(tlv->typelen) + len);
1273 * ice_set_dcb_cfg - Set the local LLDP MIB to FW
1274 * @pi: port information structure
1276 * Set DCB configuration to the Firmware
1278 enum ice_status ice_set_dcb_cfg(struct ice_port_info *pi)
1280 u8 mib_type, *lldpmib = NULL;
1281 struct ice_dcbx_cfg *dcbcfg;
1282 enum ice_status ret;
1287 return ICE_ERR_PARAM;
1291 /* update the HW local config */
1292 dcbcfg = &pi->qos_cfg.local_dcbx_cfg;
1293 /* Allocate the LLDPDU */
1294 lldpmib = (u8 *)ice_malloc(hw, ICE_LLDPDU_SIZE);
1296 return ICE_ERR_NO_MEMORY;
1298 mib_type = SET_LOCAL_MIB_TYPE_LOCAL_MIB;
1299 if (dcbcfg->app_mode == ICE_DCBX_APPS_NON_WILLING)
1300 mib_type |= SET_LOCAL_MIB_TYPE_CEE_NON_WILLING;
1302 ice_dcb_cfg_to_lldp(lldpmib, &miblen, dcbcfg);
1303 ret = ice_aq_set_lldp_mib(hw, mib_type, (void *)lldpmib, miblen,
1306 ice_free(hw, lldpmib);
1312 * ice_aq_query_port_ets - query port ETS configuration
1313 * @pi: port information structure
1314 * @buf: pointer to buffer
1315 * @buf_size: buffer size in bytes
1316 * @cd: pointer to command details structure or NULL
1318 * query current port ETS configuration
1321 ice_aq_query_port_ets(struct ice_port_info *pi,
1322 struct ice_aqc_port_ets_elem *buf, u16 buf_size,
1323 struct ice_sq_cd *cd)
1325 struct ice_aqc_query_port_ets *cmd;
1326 struct ice_aq_desc desc;
1327 enum ice_status status;
1330 return ICE_ERR_PARAM;
1331 cmd = &desc.params.port_ets;
1332 ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_query_port_ets);
1333 cmd->port_teid = pi->root->info.node_teid;
1335 status = ice_aq_send_cmd(pi->hw, &desc, buf, buf_size, cd);
1340 * ice_update_port_tc_tree_cfg - update TC tree configuration
1341 * @pi: port information structure
1342 * @buf: pointer to buffer
1344 * update the SW DB with the new TC changes
1347 ice_update_port_tc_tree_cfg(struct ice_port_info *pi,
1348 struct ice_aqc_port_ets_elem *buf)
1350 struct ice_sched_node *node, *tc_node;
1351 struct ice_aqc_txsched_elem_data elem;
1352 enum ice_status status = ICE_SUCCESS;
1357 return ICE_ERR_PARAM;
1358 /* suspend the missing TC nodes */
1359 for (i = 0; i < pi->root->num_children; i++) {
1360 teid1 = LE32_TO_CPU(pi->root->children[i]->info.node_teid);
1361 ice_for_each_traffic_class(j) {
1362 teid2 = LE32_TO_CPU(buf->tc_node_teid[j]);
1366 if (j < ICE_MAX_TRAFFIC_CLASS)
1369 pi->root->children[i]->in_use = false;
1371 /* add the new TC nodes */
1372 ice_for_each_traffic_class(j) {
1373 teid2 = LE32_TO_CPU(buf->tc_node_teid[j]);
1374 if (teid2 == ICE_INVAL_TEID)
1376 /* Is it already present in the tree ? */
1377 for (i = 0; i < pi->root->num_children; i++) {
1378 tc_node = pi->root->children[i];
1381 teid1 = LE32_TO_CPU(tc_node->info.node_teid);
1382 if (teid1 == teid2) {
1383 tc_node->tc_num = j;
1384 tc_node->in_use = true;
1388 if (i < pi->root->num_children)
1391 status = ice_sched_query_elem(pi->hw, teid2, &elem);
1393 status = ice_sched_add_node(pi, 1, &elem);
1396 /* update the TC number */
1397 node = ice_sched_find_node_by_teid(pi->root, teid2);
1405 * ice_query_port_ets - query port ETS configuration
1406 * @pi: port information structure
1407 * @buf: pointer to buffer
1408 * @buf_size: buffer size in bytes
1409 * @cd: pointer to command details structure or NULL
1411 * query current port ETS configuration and update the
1412 * SW DB with the TC changes
1415 ice_query_port_ets(struct ice_port_info *pi,
1416 struct ice_aqc_port_ets_elem *buf, u16 buf_size,
1417 struct ice_sq_cd *cd)
1419 enum ice_status status;
1421 ice_acquire_lock(&pi->sched_lock);
1422 status = ice_aq_query_port_ets(pi, buf, buf_size, cd);
1424 status = ice_update_port_tc_tree_cfg(pi, buf);
1425 ice_release_lock(&pi->sched_lock);