1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2001-2019
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 * @cd: pointer to command details structure or NULL
88 * Stop or Shutdown the embedded LLDP Agent (0x0A05)
91 ice_aq_stop_lldp(struct ice_hw *hw, bool shutdown_lldp_agent,
94 struct ice_aqc_lldp_stop *cmd;
95 struct ice_aq_desc desc;
97 cmd = &desc.params.lldp_stop;
99 ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_lldp_stop);
101 if (shutdown_lldp_agent)
102 cmd->command |= ICE_AQ_LLDP_AGENT_SHUTDOWN;
104 return ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
109 * @hw: pointer to the HW struct
110 * @cd: pointer to command details structure or NULL
112 * Start the embedded LLDP Agent on all ports. (0x0A06)
114 enum ice_status ice_aq_start_lldp(struct ice_hw *hw, struct ice_sq_cd *cd)
116 struct ice_aqc_lldp_start *cmd;
117 struct ice_aq_desc desc;
119 cmd = &desc.params.lldp_start;
121 ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_lldp_start);
123 cmd->command = ICE_AQ_LLDP_AGENT_START;
125 return ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
129 * ice_aq_set_lldp_mib - Set the LLDP MIB
130 * @hw: pointer to the HW struct
131 * @mib_type: Local, Remote or both Local and Remote MIBs
132 * @buf: pointer to the caller-supplied buffer to store the MIB block
133 * @buf_size: size of the buffer (in bytes)
134 * @cd: pointer to command details structure or NULL
136 * Set the LLDP MIB. (0x0A08)
139 ice_aq_set_lldp_mib(struct ice_hw *hw, u8 mib_type, void *buf, u16 buf_size,
140 struct ice_sq_cd *cd)
142 struct ice_aqc_lldp_set_local_mib *cmd;
143 struct ice_aq_desc desc;
145 cmd = &desc.params.lldp_set_mib;
147 if (buf_size == 0 || !buf)
148 return ICE_ERR_PARAM;
150 ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_lldp_set_local_mib);
152 desc.flags |= CPU_TO_LE16((u16)ICE_AQ_FLAG_RD);
153 desc.datalen = CPU_TO_LE16(buf_size);
155 cmd->type = mib_type;
156 cmd->length = CPU_TO_LE16(buf_size);
158 return ice_aq_send_cmd(hw, &desc, buf, buf_size, cd);
162 * ice_get_dcbx_status
163 * @hw: pointer to the HW struct
165 * Get the DCBX status from the Firmware
167 u8 ice_get_dcbx_status(struct ice_hw *hw)
171 reg = rd32(hw, PRTDCB_GENS);
172 return (u8)((reg & PRTDCB_GENS_DCBX_STATUS_M) >>
173 PRTDCB_GENS_DCBX_STATUS_S);
177 * ice_parse_ieee_ets_common_tlv
178 * @buf: Data buffer to be parsed for ETS CFG/REC data
179 * @ets_cfg: Container to store parsed data
181 * Parses the common data of IEEE 802.1Qaz ETS CFG/REC TLV
184 ice_parse_ieee_ets_common_tlv(u8 *buf, struct ice_dcb_ets_cfg *ets_cfg)
189 /* Priority Assignment Table (4 octets)
190 * Octets:| 1 | 2 | 3 | 4 |
191 * -----------------------------------------
192 * |pri0|pri1|pri2|pri3|pri4|pri5|pri6|pri7|
193 * -----------------------------------------
194 * Bits:|7 4|3 0|7 4|3 0|7 4|3 0|7 4|3 0|
195 * -----------------------------------------
197 for (i = 0; i < 4; i++) {
198 ets_cfg->prio_table[i * 2] =
199 ((buf[offset] & ICE_IEEE_ETS_PRIO_1_M) >>
200 ICE_IEEE_ETS_PRIO_1_S);
201 ets_cfg->prio_table[i * 2 + 1] =
202 ((buf[offset] & ICE_IEEE_ETS_PRIO_0_M) >>
203 ICE_IEEE_ETS_PRIO_0_S);
207 /* TC Bandwidth Table (8 octets)
208 * Octets:| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
209 * ---------------------------------
210 * |tc0|tc1|tc2|tc3|tc4|tc5|tc6|tc7|
211 * ---------------------------------
213 * TSA Assignment Table (8 octets)
214 * Octets:| 9 | 10| 11| 12| 13| 14| 15| 16|
215 * ---------------------------------
216 * |tc0|tc1|tc2|tc3|tc4|tc5|tc6|tc7|
217 * ---------------------------------
219 ice_for_each_traffic_class(i) {
220 ets_cfg->tcbwtable[i] = buf[offset];
221 ets_cfg->tsatable[i] = buf[ICE_MAX_TRAFFIC_CLASS + offset++];
226 * ice_parse_ieee_etscfg_tlv
227 * @tlv: IEEE 802.1Qaz ETS CFG TLV
228 * @dcbcfg: Local store to update ETS CFG data
230 * Parses IEEE 802.1Qaz ETS CFG TLV
233 ice_parse_ieee_etscfg_tlv(struct ice_lldp_org_tlv *tlv,
234 struct ice_dcbx_cfg *dcbcfg)
236 struct ice_dcb_ets_cfg *etscfg;
237 u8 *buf = tlv->tlvinfo;
239 /* First Octet post subtype
240 * --------------------------
241 * |will-|CBS | Re- | Max |
242 * |ing | |served| TCs |
243 * --------------------------
244 * |1bit | 1bit|3 bits|3bits|
246 etscfg = &dcbcfg->etscfg;
247 etscfg->willing = ((buf[0] & ICE_IEEE_ETS_WILLING_M) >>
248 ICE_IEEE_ETS_WILLING_S);
249 etscfg->cbs = ((buf[0] & ICE_IEEE_ETS_CBS_M) >> ICE_IEEE_ETS_CBS_S);
250 etscfg->maxtcs = ((buf[0] & ICE_IEEE_ETS_MAXTC_M) >>
251 ICE_IEEE_ETS_MAXTC_S);
253 /* Begin parsing at Priority Assignment Table (offset 1 in buf) */
254 ice_parse_ieee_ets_common_tlv(&buf[1], etscfg);
258 * ice_parse_ieee_etsrec_tlv
259 * @tlv: IEEE 802.1Qaz ETS REC TLV
260 * @dcbcfg: Local store to update ETS REC data
262 * Parses IEEE 802.1Qaz ETS REC TLV
265 ice_parse_ieee_etsrec_tlv(struct ice_lldp_org_tlv *tlv,
266 struct ice_dcbx_cfg *dcbcfg)
268 u8 *buf = tlv->tlvinfo;
270 /* Begin parsing at Priority Assignment Table (offset 1 in buf) */
271 ice_parse_ieee_ets_common_tlv(&buf[1], &dcbcfg->etsrec);
275 * ice_parse_ieee_pfccfg_tlv
276 * @tlv: IEEE 802.1Qaz PFC CFG TLV
277 * @dcbcfg: Local store to update PFC CFG data
279 * Parses IEEE 802.1Qaz PFC CFG TLV
282 ice_parse_ieee_pfccfg_tlv(struct ice_lldp_org_tlv *tlv,
283 struct ice_dcbx_cfg *dcbcfg)
285 u8 *buf = tlv->tlvinfo;
287 /* ----------------------------------------
288 * |will-|MBC | Re- | PFC | PFC Enable |
289 * |ing | |served| cap | |
290 * -----------------------------------------
291 * |1bit | 1bit|2 bits|4bits| 1 octet |
293 dcbcfg->pfc.willing = ((buf[0] & ICE_IEEE_PFC_WILLING_M) >>
294 ICE_IEEE_PFC_WILLING_S);
295 dcbcfg->pfc.mbc = ((buf[0] & ICE_IEEE_PFC_MBC_M) >> ICE_IEEE_PFC_MBC_S);
296 dcbcfg->pfc.pfccap = ((buf[0] & ICE_IEEE_PFC_CAP_M) >>
298 dcbcfg->pfc.pfcena = buf[1];
302 * ice_parse_ieee_app_tlv
303 * @tlv: IEEE 802.1Qaz APP TLV
304 * @dcbcfg: Local store to update APP PRIO data
306 * Parses IEEE 802.1Qaz APP PRIO TLV
309 ice_parse_ieee_app_tlv(struct ice_lldp_org_tlv *tlv,
310 struct ice_dcbx_cfg *dcbcfg)
318 typelen = NTOHS(tlv->typelen);
319 len = ((typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S);
322 /* Removing sizeof(ouisubtype) and reserved byte from len.
323 * Remaining len div 3 is number of APP TLVs.
325 len -= (sizeof(tlv->ouisubtype) + 1);
327 /* Move offset to App Priority Table */
330 /* Application Priority Table (3 octets)
331 * Octets:| 1 | 2 | 3 |
332 * -----------------------------------------
333 * |Priority|Rsrvd| Sel | Protocol ID |
334 * -----------------------------------------
335 * Bits:|23 21|20 19|18 16|15 0|
336 * -----------------------------------------
338 while (offset < len) {
339 dcbcfg->app[i].priority = ((buf[offset] &
340 ICE_IEEE_APP_PRIO_M) >>
341 ICE_IEEE_APP_PRIO_S);
342 dcbcfg->app[i].selector = ((buf[offset] &
343 ICE_IEEE_APP_SEL_M) >>
345 dcbcfg->app[i].prot_id = (buf[offset + 1] << 0x8) |
347 /* Move to next app */
350 if (i >= ICE_DCBX_MAX_APPS)
359 * @tlv: IEEE 802.1Qaz TLV
360 * @dcbcfg: Local store to update ETS REC data
362 * Get the TLV subtype and send it to parsing function
363 * based on the subtype value
366 ice_parse_ieee_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg)
371 ouisubtype = NTOHL(tlv->ouisubtype);
372 subtype = (u8)((ouisubtype & ICE_LLDP_TLV_SUBTYPE_M) >>
373 ICE_LLDP_TLV_SUBTYPE_S);
375 case ICE_IEEE_SUBTYPE_ETS_CFG:
376 ice_parse_ieee_etscfg_tlv(tlv, dcbcfg);
378 case ICE_IEEE_SUBTYPE_ETS_REC:
379 ice_parse_ieee_etsrec_tlv(tlv, dcbcfg);
381 case ICE_IEEE_SUBTYPE_PFC_CFG:
382 ice_parse_ieee_pfccfg_tlv(tlv, dcbcfg);
384 case ICE_IEEE_SUBTYPE_APP_PRI:
385 ice_parse_ieee_app_tlv(tlv, dcbcfg);
393 * ice_parse_cee_pgcfg_tlv
394 * @tlv: CEE DCBX PG CFG TLV
395 * @dcbcfg: Local store to update ETS CFG data
397 * Parses CEE DCBX PG CFG TLV
400 ice_parse_cee_pgcfg_tlv(struct ice_cee_feat_tlv *tlv,
401 struct ice_dcbx_cfg *dcbcfg)
403 struct ice_dcb_ets_cfg *etscfg;
404 u8 *buf = tlv->tlvinfo;
408 etscfg = &dcbcfg->etscfg;
410 if (tlv->en_will_err & ICE_CEE_FEAT_TLV_WILLING_M)
414 /* Priority Group Table (4 octets)
415 * Octets:| 1 | 2 | 3 | 4 |
416 * -----------------------------------------
417 * |pri0|pri1|pri2|pri3|pri4|pri5|pri6|pri7|
418 * -----------------------------------------
419 * Bits:|7 4|3 0|7 4|3 0|7 4|3 0|7 4|3 0|
420 * -----------------------------------------
422 for (i = 0; i < 4; i++) {
423 etscfg->prio_table[i * 2] =
424 ((buf[offset] & ICE_CEE_PGID_PRIO_1_M) >>
425 ICE_CEE_PGID_PRIO_1_S);
426 etscfg->prio_table[i * 2 + 1] =
427 ((buf[offset] & ICE_CEE_PGID_PRIO_0_M) >>
428 ICE_CEE_PGID_PRIO_0_S);
432 /* PG Percentage Table (8 octets)
433 * Octets:| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
434 * ---------------------------------
435 * |pg0|pg1|pg2|pg3|pg4|pg5|pg6|pg7|
436 * ---------------------------------
438 ice_for_each_traffic_class(i)
439 etscfg->tcbwtable[i] = buf[offset++];
441 /* Number of TCs supported (1 octet) */
442 etscfg->maxtcs = buf[offset];
446 * ice_parse_cee_pfccfg_tlv
447 * @tlv: CEE DCBX PFC CFG TLV
448 * @dcbcfg: Local store to update PFC CFG data
450 * Parses CEE DCBX PFC CFG TLV
453 ice_parse_cee_pfccfg_tlv(struct ice_cee_feat_tlv *tlv,
454 struct ice_dcbx_cfg *dcbcfg)
456 u8 *buf = tlv->tlvinfo;
458 if (tlv->en_will_err & ICE_CEE_FEAT_TLV_WILLING_M)
459 dcbcfg->pfc.willing = 1;
461 /* ------------------------
462 * | PFC Enable | PFC TCs |
463 * ------------------------
464 * | 1 octet | 1 octet |
466 dcbcfg->pfc.pfcena = buf[0];
467 dcbcfg->pfc.pfccap = buf[1];
471 * ice_parse_cee_app_tlv
472 * @tlv: CEE DCBX APP TLV
473 * @dcbcfg: Local store to update APP PRIO data
475 * Parses CEE DCBX APP PRIO TLV
478 ice_parse_cee_app_tlv(struct ice_cee_feat_tlv *tlv, struct ice_dcbx_cfg *dcbcfg)
480 u16 len, typelen, offset = 0;
481 struct ice_cee_app_prio *app;
484 typelen = NTOHS(tlv->hdr.typelen);
485 len = ((typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S);
487 dcbcfg->numapps = len / sizeof(*app);
488 if (!dcbcfg->numapps)
490 if (dcbcfg->numapps > ICE_DCBX_MAX_APPS)
491 dcbcfg->numapps = ICE_DCBX_MAX_APPS;
493 for (i = 0; i < dcbcfg->numapps; i++) {
496 app = (struct ice_cee_app_prio *)(tlv->tlvinfo + offset);
497 for (up = 0; up < ICE_MAX_USER_PRIORITY; up++)
498 if (app->prio_map & BIT(up))
501 dcbcfg->app[i].priority = up;
503 /* Get Selector from lower 2 bits, and convert to IEEE */
504 selector = (app->upper_oui_sel & ICE_CEE_APP_SELECTOR_M);
506 case ICE_CEE_APP_SEL_ETHTYPE:
507 dcbcfg->app[i].selector = ICE_APP_SEL_ETHTYPE;
509 case ICE_CEE_APP_SEL_TCPIP:
510 dcbcfg->app[i].selector = ICE_APP_SEL_TCPIP;
513 /* Keep selector as it is for unknown types */
514 dcbcfg->app[i].selector = selector;
517 dcbcfg->app[i].prot_id = NTOHS(app->protocol);
518 /* Move to next app */
519 offset += sizeof(*app);
526 * @dcbcfg: Local store to update DCBX config data
528 * Get the TLV subtype and send it to parsing function
529 * based on the subtype value
532 ice_parse_cee_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg)
534 struct ice_cee_feat_tlv *sub_tlv;
535 u8 subtype, feat_tlv_count = 0;
536 u16 len, tlvlen, typelen;
539 ouisubtype = NTOHL(tlv->ouisubtype);
540 subtype = (u8)((ouisubtype & ICE_LLDP_TLV_SUBTYPE_M) >>
541 ICE_LLDP_TLV_SUBTYPE_S);
542 /* Return if not CEE DCBX */
543 if (subtype != ICE_CEE_DCBX_TYPE)
546 typelen = NTOHS(tlv->typelen);
547 tlvlen = ((typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S);
548 len = sizeof(tlv->typelen) + sizeof(ouisubtype) +
549 sizeof(struct ice_cee_ctrl_tlv);
550 /* Return if no CEE DCBX Feature TLVs */
554 sub_tlv = (struct ice_cee_feat_tlv *)((char *)tlv + len);
555 while (feat_tlv_count < ICE_CEE_MAX_FEAT_TYPE) {
558 typelen = NTOHS(sub_tlv->hdr.typelen);
559 sublen = ((typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S);
560 subtype = (u8)((typelen & ICE_LLDP_TLV_TYPE_M) >>
561 ICE_LLDP_TLV_TYPE_S);
563 case ICE_CEE_SUBTYPE_PG_CFG:
564 ice_parse_cee_pgcfg_tlv(sub_tlv, dcbcfg);
566 case ICE_CEE_SUBTYPE_PFC_CFG:
567 ice_parse_cee_pfccfg_tlv(sub_tlv, dcbcfg);
569 case ICE_CEE_SUBTYPE_APP_PRI:
570 ice_parse_cee_app_tlv(sub_tlv, dcbcfg);
573 return; /* Invalid Sub-type return */
576 /* Move to next sub TLV */
577 sub_tlv = (struct ice_cee_feat_tlv *)
578 ((char *)sub_tlv + sizeof(sub_tlv->hdr.typelen) +
585 * @tlv: Organization specific TLV
586 * @dcbcfg: Local store to update ETS REC data
588 * Currently only IEEE 802.1Qaz TLV is supported, all others
592 ice_parse_org_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg)
597 ouisubtype = NTOHL(tlv->ouisubtype);
598 oui = ((ouisubtype & ICE_LLDP_TLV_OUI_M) >> ICE_LLDP_TLV_OUI_S);
600 case ICE_IEEE_8021QAZ_OUI:
601 ice_parse_ieee_tlv(tlv, dcbcfg);
603 case ICE_CEE_DCBX_OUI:
604 ice_parse_cee_tlv(tlv, dcbcfg);
612 * ice_lldp_to_dcb_cfg
613 * @lldpmib: LLDPDU to be parsed
614 * @dcbcfg: store for LLDPDU data
616 * Parse DCB configuration from the LLDPDU
618 enum ice_status ice_lldp_to_dcb_cfg(u8 *lldpmib, struct ice_dcbx_cfg *dcbcfg)
620 struct ice_lldp_org_tlv *tlv;
621 enum ice_status ret = ICE_SUCCESS;
627 if (!lldpmib || !dcbcfg)
628 return ICE_ERR_PARAM;
630 /* set to the start of LLDPDU */
631 lldpmib += ETH_HEADER_LEN;
632 tlv = (struct ice_lldp_org_tlv *)lldpmib;
634 typelen = NTOHS(tlv->typelen);
635 type = ((typelen & ICE_LLDP_TLV_TYPE_M) >> ICE_LLDP_TLV_TYPE_S);
636 len = ((typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S);
637 offset += sizeof(typelen) + len;
639 /* END TLV or beyond LLDPDU size */
640 if (type == ICE_TLV_TYPE_END || offset > ICE_LLDPDU_SIZE)
644 case ICE_TLV_TYPE_ORG:
645 ice_parse_org_tlv(tlv, dcbcfg);
651 /* Move to next TLV */
652 tlv = (struct ice_lldp_org_tlv *)
653 ((char *)tlv + sizeof(tlv->typelen) + len);
661 * @hw: pointer to the HW struct
662 * @mib_type: mib type for the query
663 * @bridgetype: bridge type for the query (remote)
664 * @dcbcfg: store for LLDPDU data
666 * Query DCB configuration from the firmware
669 ice_aq_get_dcb_cfg(struct ice_hw *hw, u8 mib_type, u8 bridgetype,
670 struct ice_dcbx_cfg *dcbcfg)
675 /* Allocate the LLDPDU */
676 lldpmib = (u8 *)ice_malloc(hw, ICE_LLDPDU_SIZE);
678 return ICE_ERR_NO_MEMORY;
680 ret = ice_aq_get_lldp_mib(hw, bridgetype, mib_type, (void *)lldpmib,
681 ICE_LLDPDU_SIZE, NULL, NULL, NULL);
683 if (ret == ICE_SUCCESS)
684 /* Parse LLDP MIB to get DCB configuration */
685 ret = ice_lldp_to_dcb_cfg(lldpmib, dcbcfg);
687 ice_free(hw, lldpmib);
693 * ice_aq_start_stop_dcbx - Start/Stop DCBx service in FW
694 * @hw: pointer to the HW struct
695 * @start_dcbx_agent: True if DCBx Agent needs to be started
696 * False if DCBx Agent needs to be stopped
697 * @dcbx_agent_status: FW indicates back the DCBx agent status
698 * True if DCBx Agent is active
699 * False if DCBx Agent is stopped
700 * @cd: pointer to command details structure or NULL
702 * Start/Stop the embedded dcbx Agent. In case that this wrapper function
703 * returns ICE_SUCCESS, caller will need to check if FW returns back the same
704 * value as stated in dcbx_agent_status, and react accordingly. (0x0A09)
707 ice_aq_start_stop_dcbx(struct ice_hw *hw, bool start_dcbx_agent,
708 bool *dcbx_agent_status, struct ice_sq_cd *cd)
710 struct ice_aqc_lldp_stop_start_specific_agent *cmd;
711 enum ice_status status;
712 struct ice_aq_desc desc;
715 cmd = &desc.params.lldp_agent_ctrl;
717 opcode = ice_aqc_opc_lldp_stop_start_specific_agent;
719 ice_fill_dflt_direct_cmd_desc(&desc, opcode);
721 if (start_dcbx_agent)
722 cmd->command = ICE_AQC_START_STOP_AGENT_START_DCBX;
724 status = ice_aq_send_cmd(hw, &desc, NULL, 0, cd);
726 *dcbx_agent_status = false;
728 if (status == ICE_SUCCESS &&
729 cmd->command == ICE_AQC_START_STOP_AGENT_START_DCBX)
730 *dcbx_agent_status = true;
736 * ice_aq_get_cee_dcb_cfg
737 * @hw: pointer to the HW struct
738 * @buff: response buffer that stores CEE operational configuration
739 * @cd: pointer to command details structure or NULL
741 * Get CEE DCBX mode operational configuration from firmware (0x0A07)
744 ice_aq_get_cee_dcb_cfg(struct ice_hw *hw,
745 struct ice_aqc_get_cee_dcb_cfg_resp *buff,
746 struct ice_sq_cd *cd)
748 struct ice_aq_desc desc;
750 ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_get_cee_dcb_cfg);
752 return ice_aq_send_cmd(hw, &desc, (void *)buff, sizeof(*buff), cd);
757 * @cee_cfg: pointer to CEE configuration struct
758 * @dcbcfg: DCB configuration struct
760 * Convert CEE configuration from firmware to DCB configuration
763 ice_cee_to_dcb_cfg(struct ice_aqc_get_cee_dcb_cfg_resp *cee_cfg,
764 struct ice_dcbx_cfg *dcbcfg)
766 u32 status, tlv_status = LE32_TO_CPU(cee_cfg->tlv_status);
767 u32 ice_aqc_cee_status_mask, ice_aqc_cee_status_shift;
768 u16 app_prio = LE16_TO_CPU(cee_cfg->oper_app_prio);
769 u8 i, err, sync, oper, app_index, ice_app_sel_type;
770 u16 ice_aqc_cee_app_mask, ice_aqc_cee_app_shift;
771 u16 ice_app_prot_id_type;
773 /* CEE PG data to ETS config */
774 dcbcfg->etscfg.maxtcs = cee_cfg->oper_num_tc;
776 /* Note that the FW creates the oper_prio_tc nibbles reversed
777 * from those in the CEE Priority Group sub-TLV.
779 for (i = 0; i < ICE_MAX_TRAFFIC_CLASS / 2; i++) {
780 dcbcfg->etscfg.prio_table[i * 2] =
781 ((cee_cfg->oper_prio_tc[i] & ICE_CEE_PGID_PRIO_0_M) >>
782 ICE_CEE_PGID_PRIO_0_S);
783 dcbcfg->etscfg.prio_table[i * 2 + 1] =
784 ((cee_cfg->oper_prio_tc[i] & ICE_CEE_PGID_PRIO_1_M) >>
785 ICE_CEE_PGID_PRIO_1_S);
788 ice_for_each_traffic_class(i) {
789 dcbcfg->etscfg.tcbwtable[i] = cee_cfg->oper_tc_bw[i];
791 if (dcbcfg->etscfg.prio_table[i] == ICE_CEE_PGID_STRICT) {
792 /* Map it to next empty TC */
793 dcbcfg->etscfg.prio_table[i] = cee_cfg->oper_num_tc - 1;
794 dcbcfg->etscfg.tsatable[i] = ICE_IEEE_TSA_STRICT;
796 dcbcfg->etscfg.tsatable[i] = ICE_IEEE_TSA_ETS;
800 /* CEE PFC data to ETS config */
801 dcbcfg->pfc.pfcena = cee_cfg->oper_pfc_en;
802 dcbcfg->pfc.pfccap = ICE_MAX_TRAFFIC_CLASS;
805 for (i = 0; i < 3; i++) {
808 ice_aqc_cee_status_mask = ICE_AQC_CEE_FCOE_STATUS_M;
809 ice_aqc_cee_status_shift = ICE_AQC_CEE_FCOE_STATUS_S;
810 ice_aqc_cee_app_mask = ICE_AQC_CEE_APP_FCOE_M;
811 ice_aqc_cee_app_shift = ICE_AQC_CEE_APP_FCOE_S;
812 ice_app_sel_type = ICE_APP_SEL_ETHTYPE;
813 ice_app_prot_id_type = ICE_APP_PROT_ID_FCOE;
816 ice_aqc_cee_status_mask = ICE_AQC_CEE_ISCSI_STATUS_M;
817 ice_aqc_cee_status_shift = ICE_AQC_CEE_ISCSI_STATUS_S;
818 ice_aqc_cee_app_mask = ICE_AQC_CEE_APP_ISCSI_M;
819 ice_aqc_cee_app_shift = ICE_AQC_CEE_APP_ISCSI_S;
820 ice_app_sel_type = ICE_APP_SEL_TCPIP;
821 ice_app_prot_id_type = ICE_APP_PROT_ID_ISCSI;
824 ice_aqc_cee_status_mask = ICE_AQC_CEE_FIP_STATUS_M;
825 ice_aqc_cee_status_shift = ICE_AQC_CEE_FIP_STATUS_S;
826 ice_aqc_cee_app_mask = ICE_AQC_CEE_APP_FIP_M;
827 ice_aqc_cee_app_shift = ICE_AQC_CEE_APP_FIP_S;
828 ice_app_sel_type = ICE_APP_SEL_ETHTYPE;
829 ice_app_prot_id_type = ICE_APP_PROT_ID_FIP;
832 status = (tlv_status & ice_aqc_cee_status_mask) >>
833 ice_aqc_cee_status_shift;
834 err = (status & ICE_TLV_STATUS_ERR) ? 1 : 0;
835 sync = (status & ICE_TLV_STATUS_SYNC) ? 1 : 0;
836 oper = (status & ICE_TLV_STATUS_OPER) ? 1 : 0;
837 /* Add FCoE/iSCSI/FIP APP if Error is False and
840 if (!err && sync && oper) {
841 dcbcfg->app[app_index].priority =
842 (app_prio & ice_aqc_cee_app_mask) >>
843 ice_aqc_cee_app_shift;
844 dcbcfg->app[app_index].selector = ice_app_sel_type;
845 dcbcfg->app[app_index].prot_id = ice_app_prot_id_type;
850 dcbcfg->numapps = app_index;
854 * ice_get_ieee_dcb_cfg
855 * @pi: port information structure
856 * @dcbx_mode: mode of DCBX (IEEE or CEE)
858 * Get IEEE or CEE mode DCB configuration from the Firmware
860 STATIC enum ice_status
861 ice_get_ieee_or_cee_dcb_cfg(struct ice_port_info *pi, u8 dcbx_mode)
863 struct ice_dcbx_cfg *dcbx_cfg = NULL;
867 return ICE_ERR_PARAM;
869 if (dcbx_mode == ICE_DCBX_MODE_IEEE)
870 dcbx_cfg = &pi->local_dcbx_cfg;
871 else if (dcbx_mode == ICE_DCBX_MODE_CEE)
872 dcbx_cfg = &pi->desired_dcbx_cfg;
874 /* Get Local DCB Config in case of ICE_DCBX_MODE_IEEE
875 * or get CEE DCB Desired Config in case of ICE_DCBX_MODE_CEE
877 ret = ice_aq_get_dcb_cfg(pi->hw, ICE_AQ_LLDP_MIB_LOCAL,
878 ICE_AQ_LLDP_BRID_TYPE_NEAREST_BRID, dcbx_cfg);
882 /* Get Remote DCB Config */
883 dcbx_cfg = &pi->remote_dcbx_cfg;
884 ret = ice_aq_get_dcb_cfg(pi->hw, ICE_AQ_LLDP_MIB_REMOTE,
885 ICE_AQ_LLDP_BRID_TYPE_NEAREST_BRID, dcbx_cfg);
886 /* Don't treat ENOENT as an error for Remote MIBs */
887 if (pi->hw->adminq.sq_last_status == ICE_AQ_RC_ENOENT)
896 * @pi: port information structure
898 * Get DCB configuration from the Firmware
900 enum ice_status ice_get_dcb_cfg(struct ice_port_info *pi)
902 struct ice_aqc_get_cee_dcb_cfg_resp cee_cfg;
903 struct ice_dcbx_cfg *dcbx_cfg;
907 return ICE_ERR_PARAM;
909 ret = ice_aq_get_cee_dcb_cfg(pi->hw, &cee_cfg, NULL);
910 if (ret == ICE_SUCCESS) {
912 dcbx_cfg = &pi->local_dcbx_cfg;
913 dcbx_cfg->dcbx_mode = ICE_DCBX_MODE_CEE;
914 dcbx_cfg->tlv_status = LE32_TO_CPU(cee_cfg.tlv_status);
915 ice_cee_to_dcb_cfg(&cee_cfg, dcbx_cfg);
916 ret = ice_get_ieee_or_cee_dcb_cfg(pi, ICE_DCBX_MODE_CEE);
917 } else if (pi->hw->adminq.sq_last_status == ICE_AQ_RC_ENOENT) {
918 /* CEE mode not enabled try querying IEEE data */
919 dcbx_cfg = &pi->local_dcbx_cfg;
920 dcbx_cfg->dcbx_mode = ICE_DCBX_MODE_IEEE;
921 ret = ice_get_ieee_or_cee_dcb_cfg(pi, ICE_DCBX_MODE_IEEE);
929 * @hw: pointer to the HW struct
930 * @enable_mib_change: enable MIB change event
932 * Update DCB configuration from the Firmware
934 enum ice_status ice_init_dcb(struct ice_hw *hw, bool enable_mib_change)
936 struct ice_port_info *pi = hw->port_info;
937 enum ice_status ret = ICE_SUCCESS;
939 if (!hw->func_caps.common_cap.dcb)
940 return ICE_ERR_NOT_SUPPORTED;
942 pi->is_sw_lldp = true;
944 /* Get DCBX status */
945 pi->dcbx_status = ice_get_dcbx_status(hw);
947 if (pi->dcbx_status == ICE_DCBX_STATUS_DONE ||
948 pi->dcbx_status == ICE_DCBX_STATUS_IN_PROGRESS) {
949 /* Get current DCBX configuration */
950 ret = ice_get_dcb_cfg(pi);
951 pi->is_sw_lldp = (hw->adminq.sq_last_status == ICE_AQ_RC_EPERM);
954 } else if (pi->dcbx_status == ICE_DCBX_STATUS_DIS) {
955 return ICE_ERR_NOT_READY;
958 /* Configure the LLDP MIB change event */
959 if (enable_mib_change) {
960 ret = ice_aq_cfg_lldp_mib_change(hw, true, NULL);
962 pi->is_sw_lldp = false;
969 * ice_cfg_lldp_mib_change
970 * @hw: pointer to the HW struct
971 * @ena_mib: enable/disable MIB change event
973 * Configure (disable/enable) MIB
975 enum ice_status ice_cfg_lldp_mib_change(struct ice_hw *hw, bool ena_mib)
977 struct ice_port_info *pi = hw->port_info;
980 if (!hw->func_caps.common_cap.dcb)
981 return ICE_ERR_NOT_SUPPORTED;
983 /* Get DCBX status */
984 pi->dcbx_status = ice_get_dcbx_status(hw);
986 if (pi->dcbx_status == ICE_DCBX_STATUS_DIS)
987 return ICE_ERR_NOT_READY;
989 ret = ice_aq_cfg_lldp_mib_change(hw, ena_mib, NULL);
991 pi->is_sw_lldp = !ena_mib;
997 * ice_add_ieee_ets_common_tlv
998 * @buf: Data buffer to be populated with ice_dcb_ets_cfg data
999 * @ets_cfg: Container for ice_dcb_ets_cfg data
1001 * Populate the TLV buffer with ice_dcb_ets_cfg data
1004 ice_add_ieee_ets_common_tlv(u8 *buf, struct ice_dcb_ets_cfg *ets_cfg)
1006 u8 priority0, priority1;
1010 /* Priority Assignment Table (4 octets)
1011 * Octets:| 1 | 2 | 3 | 4 |
1012 * -----------------------------------------
1013 * |pri0|pri1|pri2|pri3|pri4|pri5|pri6|pri7|
1014 * -----------------------------------------
1015 * Bits:|7 4|3 0|7 4|3 0|7 4|3 0|7 4|3 0|
1016 * -----------------------------------------
1018 for (i = 0; i < ICE_MAX_TRAFFIC_CLASS / 2; i++) {
1019 priority0 = ets_cfg->prio_table[i * 2] & 0xF;
1020 priority1 = ets_cfg->prio_table[i * 2 + 1] & 0xF;
1021 buf[offset] = (priority0 << ICE_IEEE_ETS_PRIO_1_S) | priority1;
1025 /* TC Bandwidth Table (8 octets)
1026 * Octets:| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
1027 * ---------------------------------
1028 * |tc0|tc1|tc2|tc3|tc4|tc5|tc6|tc7|
1029 * ---------------------------------
1031 * TSA Assignment Table (8 octets)
1032 * Octets:| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
1033 * ---------------------------------
1034 * |tc0|tc1|tc2|tc3|tc4|tc5|tc6|tc7|
1035 * ---------------------------------
1037 ice_for_each_traffic_class(i) {
1038 buf[offset] = ets_cfg->tcbwtable[i];
1039 buf[ICE_MAX_TRAFFIC_CLASS + offset] = ets_cfg->tsatable[i];
1045 * ice_add_ieee_ets_tlv - Prepare ETS TLV in IEEE format
1046 * @tlv: Fill the ETS config data in IEEE format
1047 * @dcbcfg: Local store which holds the DCB Config
1049 * Prepare IEEE 802.1Qaz ETS CFG TLV
1052 ice_add_ieee_ets_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg)
1054 struct ice_dcb_ets_cfg *etscfg;
1055 u8 *buf = tlv->tlvinfo;
1056 u8 maxtcwilling = 0;
1060 typelen = ((ICE_TLV_TYPE_ORG << ICE_LLDP_TLV_TYPE_S) |
1061 ICE_IEEE_ETS_TLV_LEN);
1062 tlv->typelen = HTONS(typelen);
1064 ouisubtype = ((ICE_IEEE_8021QAZ_OUI << ICE_LLDP_TLV_OUI_S) |
1065 ICE_IEEE_SUBTYPE_ETS_CFG);
1066 tlv->ouisubtype = HTONL(ouisubtype);
1068 /* First Octet post subtype
1069 * --------------------------
1070 * |will-|CBS | Re- | Max |
1071 * |ing | |served| TCs |
1072 * --------------------------
1073 * |1bit | 1bit|3 bits|3bits|
1075 etscfg = &dcbcfg->etscfg;
1076 if (etscfg->willing)
1077 maxtcwilling = BIT(ICE_IEEE_ETS_WILLING_S);
1078 maxtcwilling |= etscfg->maxtcs & ICE_IEEE_ETS_MAXTC_M;
1079 buf[0] = maxtcwilling;
1081 /* Begin adding at Priority Assignment Table (offset 1 in buf) */
1082 ice_add_ieee_ets_common_tlv(&buf[1], etscfg);
1086 * ice_add_ieee_etsrec_tlv - Prepare ETS Recommended TLV in IEEE format
1087 * @tlv: Fill ETS Recommended TLV in IEEE format
1088 * @dcbcfg: Local store which holds the DCB Config
1090 * Prepare IEEE 802.1Qaz ETS REC TLV
1093 ice_add_ieee_etsrec_tlv(struct ice_lldp_org_tlv *tlv,
1094 struct ice_dcbx_cfg *dcbcfg)
1096 struct ice_dcb_ets_cfg *etsrec;
1097 u8 *buf = tlv->tlvinfo;
1101 typelen = ((ICE_TLV_TYPE_ORG << ICE_LLDP_TLV_TYPE_S) |
1102 ICE_IEEE_ETS_TLV_LEN);
1103 tlv->typelen = HTONS(typelen);
1105 ouisubtype = ((ICE_IEEE_8021QAZ_OUI << ICE_LLDP_TLV_OUI_S) |
1106 ICE_IEEE_SUBTYPE_ETS_REC);
1107 tlv->ouisubtype = HTONL(ouisubtype);
1109 etsrec = &dcbcfg->etsrec;
1111 /* First Octet is reserved */
1112 /* Begin adding at Priority Assignment Table (offset 1 in buf) */
1113 ice_add_ieee_ets_common_tlv(&buf[1], etsrec);
1117 * ice_add_ieee_pfc_tlv - Prepare PFC TLV in IEEE format
1118 * @tlv: Fill PFC TLV in IEEE format
1119 * @dcbcfg: Local store which holds the PFC CFG data
1121 * Prepare IEEE 802.1Qaz PFC CFG TLV
1124 ice_add_ieee_pfc_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg)
1126 u8 *buf = tlv->tlvinfo;
1130 typelen = ((ICE_TLV_TYPE_ORG << ICE_LLDP_TLV_TYPE_S) |
1131 ICE_IEEE_PFC_TLV_LEN);
1132 tlv->typelen = HTONS(typelen);
1134 ouisubtype = ((ICE_IEEE_8021QAZ_OUI << ICE_LLDP_TLV_OUI_S) |
1135 ICE_IEEE_SUBTYPE_PFC_CFG);
1136 tlv->ouisubtype = HTONL(ouisubtype);
1138 /* ----------------------------------------
1139 * |will-|MBC | Re- | PFC | PFC Enable |
1140 * |ing | |served| cap | |
1141 * -----------------------------------------
1142 * |1bit | 1bit|2 bits|4bits| 1 octet |
1144 if (dcbcfg->pfc.willing)
1145 buf[0] = BIT(ICE_IEEE_PFC_WILLING_S);
1147 if (dcbcfg->pfc.mbc)
1148 buf[0] |= BIT(ICE_IEEE_PFC_MBC_S);
1150 buf[0] |= dcbcfg->pfc.pfccap & 0xF;
1151 buf[1] = dcbcfg->pfc.pfcena;
1155 * ice_add_ieee_app_pri_tlv - Prepare APP TLV in IEEE format
1156 * @tlv: Fill APP TLV in IEEE format
1157 * @dcbcfg: Local store which holds the APP CFG data
1159 * Prepare IEEE 802.1Qaz APP CFG TLV
1162 ice_add_ieee_app_pri_tlv(struct ice_lldp_org_tlv *tlv,
1163 struct ice_dcbx_cfg *dcbcfg)
1165 u16 typelen, len, offset = 0;
1166 u8 priority, selector, i = 0;
1167 u8 *buf = tlv->tlvinfo;
1170 /* No APP TLVs then just return */
1171 if (dcbcfg->numapps == 0)
1173 ouisubtype = ((ICE_IEEE_8021QAZ_OUI << ICE_LLDP_TLV_OUI_S) |
1174 ICE_IEEE_SUBTYPE_APP_PRI);
1175 tlv->ouisubtype = HTONL(ouisubtype);
1177 /* Move offset to App Priority Table */
1179 /* Application Priority Table (3 octets)
1180 * Octets:| 1 | 2 | 3 |
1181 * -----------------------------------------
1182 * |Priority|Rsrvd| Sel | Protocol ID |
1183 * -----------------------------------------
1184 * Bits:|23 21|20 19|18 16|15 0|
1185 * -----------------------------------------
1187 while (i < dcbcfg->numapps) {
1188 priority = dcbcfg->app[i].priority & 0x7;
1189 selector = dcbcfg->app[i].selector & 0x7;
1190 buf[offset] = (priority << ICE_IEEE_APP_PRIO_S) | selector;
1191 buf[offset + 1] = (dcbcfg->app[i].prot_id >> 0x8) & 0xFF;
1192 buf[offset + 2] = dcbcfg->app[i].prot_id & 0xFF;
1193 /* Move to next app */
1196 if (i >= ICE_DCBX_MAX_APPS)
1199 /* len includes size of ouisubtype + 1 reserved + 3*numapps */
1200 len = sizeof(tlv->ouisubtype) + 1 + (i * 3);
1201 typelen = ((ICE_TLV_TYPE_ORG << ICE_LLDP_TLV_TYPE_S) | (len & 0x1FF));
1202 tlv->typelen = HTONS(typelen);
1206 * ice_add_dcb_tlv - Add all IEEE TLVs
1207 * @tlv: Fill TLV data in IEEE format
1208 * @dcbcfg: Local store which holds the DCB Config
1209 * @tlvid: Type of IEEE TLV
1211 * Add tlv information
1214 ice_add_dcb_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg,
1218 case ICE_IEEE_TLV_ID_ETS_CFG:
1219 ice_add_ieee_ets_tlv(tlv, dcbcfg);
1221 case ICE_IEEE_TLV_ID_ETS_REC:
1222 ice_add_ieee_etsrec_tlv(tlv, dcbcfg);
1224 case ICE_IEEE_TLV_ID_PFC_CFG:
1225 ice_add_ieee_pfc_tlv(tlv, dcbcfg);
1227 case ICE_IEEE_TLV_ID_APP_PRI:
1228 ice_add_ieee_app_pri_tlv(tlv, dcbcfg);
1236 * ice_dcb_cfg_to_lldp - Convert DCB configuration to MIB format
1237 * @lldpmib: pointer to the HW struct
1238 * @miblen: length of LLDP mib
1239 * @dcbcfg: Local store which holds the DCB Config
1241 * Convert the DCB configuration to MIB format
1243 void ice_dcb_cfg_to_lldp(u8 *lldpmib, u16 *miblen, struct ice_dcbx_cfg *dcbcfg)
1245 u16 len, offset = 0, tlvid = ICE_TLV_ID_START;
1246 struct ice_lldp_org_tlv *tlv;
1249 tlv = (struct ice_lldp_org_tlv *)lldpmib;
1251 ice_add_dcb_tlv(tlv, dcbcfg, tlvid++);
1252 typelen = NTOHS(tlv->typelen);
1253 len = (typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S;
1256 /* END TLV or beyond LLDPDU size */
1257 if (tlvid >= ICE_TLV_ID_END_OF_LLDPPDU ||
1258 offset > ICE_LLDPDU_SIZE)
1260 /* Move to next TLV */
1262 tlv = (struct ice_lldp_org_tlv *)
1263 ((char *)tlv + sizeof(tlv->typelen) + len);
1269 * ice_set_dcb_cfg - Set the local LLDP MIB to FW
1270 * @pi: port information structure
1272 * Set DCB configuration to the Firmware
1274 enum ice_status ice_set_dcb_cfg(struct ice_port_info *pi)
1276 u8 mib_type, *lldpmib = NULL;
1277 struct ice_dcbx_cfg *dcbcfg;
1278 enum ice_status ret;
1283 return ICE_ERR_PARAM;
1287 /* update the HW local config */
1288 dcbcfg = &pi->local_dcbx_cfg;
1289 /* Allocate the LLDPDU */
1290 lldpmib = (u8 *)ice_malloc(hw, ICE_LLDPDU_SIZE);
1292 return ICE_ERR_NO_MEMORY;
1294 mib_type = SET_LOCAL_MIB_TYPE_LOCAL_MIB;
1295 if (dcbcfg->app_mode == ICE_DCBX_APPS_NON_WILLING)
1296 mib_type |= SET_LOCAL_MIB_TYPE_CEE_NON_WILLING;
1298 ice_dcb_cfg_to_lldp(lldpmib, &miblen, dcbcfg);
1299 ret = ice_aq_set_lldp_mib(hw, mib_type, (void *)lldpmib, miblen,
1302 ice_free(hw, lldpmib);
1308 * ice_aq_query_port_ets - query port ets configuration
1309 * @pi: port information structure
1310 * @buf: pointer to buffer
1311 * @buf_size: buffer size in bytes
1312 * @cd: pointer to command details structure or NULL
1314 * query current port ets configuration
1317 ice_aq_query_port_ets(struct ice_port_info *pi,
1318 struct ice_aqc_port_ets_elem *buf, u16 buf_size,
1319 struct ice_sq_cd *cd)
1321 struct ice_aqc_query_port_ets *cmd;
1322 struct ice_aq_desc desc;
1323 enum ice_status status;
1326 return ICE_ERR_PARAM;
1327 cmd = &desc.params.port_ets;
1328 ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_query_port_ets);
1329 cmd->port_teid = pi->root->info.node_teid;
1331 status = ice_aq_send_cmd(pi->hw, &desc, buf, buf_size, cd);
1336 * ice_update_port_tc_tree_cfg - update TC tree configuration
1337 * @pi: port information structure
1338 * @buf: pointer to buffer
1340 * update the SW DB with the new TC changes
1343 ice_update_port_tc_tree_cfg(struct ice_port_info *pi,
1344 struct ice_aqc_port_ets_elem *buf)
1346 struct ice_sched_node *node, *tc_node;
1347 struct ice_aqc_get_elem elem;
1348 enum ice_status status = ICE_SUCCESS;
1353 return ICE_ERR_PARAM;
1354 /* suspend the missing TC nodes */
1355 for (i = 0; i < pi->root->num_children; i++) {
1356 teid1 = LE32_TO_CPU(pi->root->children[i]->info.node_teid);
1357 ice_for_each_traffic_class(j) {
1358 teid2 = LE32_TO_CPU(buf->tc_node_teid[j]);
1362 if (j < ICE_MAX_TRAFFIC_CLASS)
1365 pi->root->children[i]->in_use = false;
1367 /* add the new TC nodes */
1368 ice_for_each_traffic_class(j) {
1369 teid2 = LE32_TO_CPU(buf->tc_node_teid[j]);
1370 if (teid2 == ICE_INVAL_TEID)
1372 /* Is it already present in the tree ? */
1373 for (i = 0; i < pi->root->num_children; i++) {
1374 tc_node = pi->root->children[i];
1377 teid1 = LE32_TO_CPU(tc_node->info.node_teid);
1378 if (teid1 == teid2) {
1379 tc_node->tc_num = j;
1380 tc_node->in_use = true;
1384 if (i < pi->root->num_children)
1387 status = ice_sched_query_elem(pi->hw, teid2, &elem);
1389 status = ice_sched_add_node(pi, 1, &elem.generic[0]);
1392 /* update the TC number */
1393 node = ice_sched_find_node_by_teid(pi->root, teid2);
1401 * ice_query_port_ets - query port ets configuration
1402 * @pi: port information structure
1403 * @buf: pointer to buffer
1404 * @buf_size: buffer size in bytes
1405 * @cd: pointer to command details structure or NULL
1407 * query current port ets configuration and update the
1408 * SW DB with the TC changes
1411 ice_query_port_ets(struct ice_port_info *pi,
1412 struct ice_aqc_port_ets_elem *buf, u16 buf_size,
1413 struct ice_sq_cd *cd)
1415 enum ice_status status;
1417 ice_acquire_lock(&pi->sched_lock);
1418 status = ice_aq_query_port_ets(pi, buf, buf_size, cd);
1420 status = ice_update_port_tc_tree_cfg(pi, buf);
1421 ice_release_lock(&pi->sched_lock);