1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2017 Intel Corporation
4 #include <rte_tm_driver.h>
6 #include "base/ice_sched.h"
7 #include "ice_dcf_ethdev.h"
9 static int ice_dcf_hierarchy_commit(struct rte_eth_dev *dev,
10 __rte_unused int clear_on_fail,
11 __rte_unused struct rte_tm_error *error);
12 static int ice_dcf_node_add(struct rte_eth_dev *dev, uint32_t node_id,
13 uint32_t parent_node_id, uint32_t priority,
14 uint32_t weight, uint32_t level_id,
15 struct rte_tm_node_params *params,
16 struct rte_tm_error *error);
17 static int ice_dcf_node_delete(struct rte_eth_dev *dev, uint32_t node_id,
18 struct rte_tm_error *error);
19 static int ice_dcf_shaper_profile_add(struct rte_eth_dev *dev,
20 uint32_t shaper_profile_id,
21 struct rte_tm_shaper_params *profile,
22 struct rte_tm_error *error);
23 static int ice_dcf_shaper_profile_del(struct rte_eth_dev *dev,
24 uint32_t shaper_profile_id,
25 struct rte_tm_error *error);
27 const struct rte_tm_ops ice_dcf_tm_ops = {
28 .shaper_profile_add = ice_dcf_shaper_profile_add,
29 .shaper_profile_delete = ice_dcf_shaper_profile_del,
30 .hierarchy_commit = ice_dcf_hierarchy_commit,
31 .node_add = ice_dcf_node_add,
32 .node_delete = ice_dcf_node_delete,
36 ice_dcf_tm_conf_init(struct rte_eth_dev *dev)
38 struct ice_dcf_adapter *adapter = dev->data->dev_private;
39 struct ice_dcf_hw *hw = &adapter->real_hw;
41 /* initialize shaper profile list */
42 TAILQ_INIT(&hw->tm_conf.shaper_profile_list);
44 /* initialize node configuration */
45 hw->tm_conf.root = NULL;
46 TAILQ_INIT(&hw->tm_conf.tc_list);
47 TAILQ_INIT(&hw->tm_conf.vsi_list);
48 hw->tm_conf.nb_tc_node = 0;
49 hw->tm_conf.nb_vsi_node = 0;
50 hw->tm_conf.committed = false;
54 ice_dcf_tm_conf_uninit(struct rte_eth_dev *dev)
56 struct ice_dcf_adapter *adapter = dev->data->dev_private;
57 struct ice_dcf_hw *hw = &adapter->real_hw;
58 struct ice_dcf_tm_shaper_profile *shaper_profile;
59 struct ice_dcf_tm_node *tm_node;
61 /* clear node configuration */
62 while ((tm_node = TAILQ_FIRST(&hw->tm_conf.vsi_list))) {
63 TAILQ_REMOVE(&hw->tm_conf.vsi_list, tm_node, node);
66 hw->tm_conf.nb_vsi_node = 0;
67 while ((tm_node = TAILQ_FIRST(&hw->tm_conf.tc_list))) {
68 TAILQ_REMOVE(&hw->tm_conf.tc_list, tm_node, node);
71 hw->tm_conf.nb_tc_node = 0;
72 if (hw->tm_conf.root) {
73 rte_free(hw->tm_conf.root);
74 hw->tm_conf.root = NULL;
77 /* Remove all shaper profiles */
78 while ((shaper_profile =
79 TAILQ_FIRST(&hw->tm_conf.shaper_profile_list))) {
80 TAILQ_REMOVE(&hw->tm_conf.shaper_profile_list,
81 shaper_profile, node);
82 rte_free(shaper_profile);
86 static inline struct ice_dcf_tm_node *
87 ice_dcf_tm_node_search(struct rte_eth_dev *dev,
88 uint32_t node_id, enum ice_dcf_tm_node_type *node_type)
90 struct ice_dcf_adapter *adapter = dev->data->dev_private;
91 struct ice_dcf_hw *hw = &adapter->real_hw;
92 struct ice_dcf_tm_node_list *vsi_list = &hw->tm_conf.vsi_list;
93 struct ice_dcf_tm_node_list *tc_list = &hw->tm_conf.tc_list;
94 struct ice_dcf_tm_node *tm_node;
96 if (hw->tm_conf.root && hw->tm_conf.root->id == node_id) {
97 *node_type = ICE_DCF_TM_NODE_TYPE_PORT;
98 return hw->tm_conf.root;
101 TAILQ_FOREACH(tm_node, tc_list, node) {
102 if (tm_node->id == node_id) {
103 *node_type = ICE_DCF_TM_NODE_TYPE_TC;
108 TAILQ_FOREACH(tm_node, vsi_list, node) {
109 if (tm_node->id == node_id) {
110 *node_type = ICE_DCF_TM_NODE_TYPE_VSI;
118 static inline struct ice_dcf_tm_shaper_profile *
119 ice_dcf_shaper_profile_search(struct rte_eth_dev *dev,
120 uint32_t shaper_profile_id)
122 struct ice_dcf_adapter *adapter = dev->data->dev_private;
123 struct ice_dcf_hw *hw = &adapter->real_hw;
124 struct ice_dcf_shaper_profile_list *shaper_profile_list =
125 &hw->tm_conf.shaper_profile_list;
126 struct ice_dcf_tm_shaper_profile *shaper_profile;
128 TAILQ_FOREACH(shaper_profile, shaper_profile_list, node) {
129 if (shaper_profile_id == shaper_profile->shaper_profile_id)
130 return shaper_profile;
137 ice_dcf_node_param_check(struct ice_dcf_hw *hw, uint32_t node_id,
138 uint32_t priority, uint32_t weight,
139 struct rte_tm_node_params *params,
140 struct rte_tm_error *error)
142 /* checked all the unsupported parameter */
143 if (node_id == RTE_TM_NODE_ID_NULL) {
144 error->type = RTE_TM_ERROR_TYPE_NODE_ID;
145 error->message = "invalid node id";
150 error->type = RTE_TM_ERROR_TYPE_NODE_PRIORITY;
151 error->message = "priority should be 0";
156 error->type = RTE_TM_ERROR_TYPE_NODE_WEIGHT;
157 error->message = "weight must be 1";
161 /* not support shared shaper */
162 if (params->shared_shaper_id) {
163 error->type = RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_SHAPER_ID;
164 error->message = "shared shaper not supported";
167 if (params->n_shared_shapers) {
168 error->type = RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_SHAPERS;
169 error->message = "shared shaper not supported";
173 /* for non-leaf node */
174 if (node_id >= 8 * hw->num_vfs) {
175 if (params->nonleaf.wfq_weight_mode) {
177 RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE;
178 error->message = "WFQ not supported";
181 if (params->nonleaf.n_sp_priorities != 1) {
183 RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SP_PRIORITIES;
184 error->message = "SP priority not supported";
186 } else if (params->nonleaf.wfq_weight_mode &&
187 !(*params->nonleaf.wfq_weight_mode)) {
189 RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE;
190 error->message = "WFP should be byte mode";
198 if (params->leaf.cman) {
199 error->type = RTE_TM_ERROR_TYPE_NODE_PARAMS_CMAN;
200 error->message = "Congestion management not supported";
203 if (params->leaf.wred.wred_profile_id !=
204 RTE_TM_WRED_PROFILE_ID_NONE) {
206 RTE_TM_ERROR_TYPE_NODE_PARAMS_WRED_PROFILE_ID;
207 error->message = "WRED not supported";
210 if (params->leaf.wred.shared_wred_context_id) {
212 RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_WRED_CONTEXT_ID;
213 error->message = "WRED not supported";
216 if (params->leaf.wred.n_shared_wred_contexts) {
218 RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_WRED_CONTEXTS;
219 error->message = "WRED not supported";
227 ice_dcf_node_add(struct rte_eth_dev *dev, uint32_t node_id,
228 uint32_t parent_node_id, uint32_t priority,
229 uint32_t weight, uint32_t level_id,
230 struct rte_tm_node_params *params,
231 struct rte_tm_error *error)
233 enum ice_dcf_tm_node_type parent_node_type = ICE_DCF_TM_NODE_TYPE_MAX;
234 enum ice_dcf_tm_node_type node_type = ICE_DCF_TM_NODE_TYPE_MAX;
235 struct ice_dcf_tm_shaper_profile *shaper_profile = NULL;
236 struct ice_dcf_adapter *adapter = dev->data->dev_private;
237 struct ice_dcf_hw *hw = &adapter->real_hw;
238 struct ice_dcf_tm_node *parent_node;
239 struct ice_dcf_tm_node *tm_node;
243 if (!params || !error)
246 /* if already committed */
247 if (hw->tm_conf.committed) {
248 error->type = RTE_TM_ERROR_TYPE_UNSPECIFIED;
249 error->message = "already committed";
253 ret = ice_dcf_node_param_check(hw, node_id, priority, weight,
258 for (i = 1; i < ICE_MAX_TRAFFIC_CLASS; i++) {
259 if (hw->ets_config->tc_valid_bits & (1 << i))
263 /* check if the node is already existed */
264 if (ice_dcf_tm_node_search(dev, node_id, &node_type)) {
265 error->type = RTE_TM_ERROR_TYPE_NODE_ID;
266 error->message = "node id already used";
270 /* check the shaper profile id */
271 if (params->shaper_profile_id != RTE_TM_SHAPER_PROFILE_ID_NONE) {
272 shaper_profile = ice_dcf_shaper_profile_search(dev,
273 params->shaper_profile_id);
274 if (!shaper_profile) {
276 RTE_TM_ERROR_TYPE_NODE_PARAMS_SHAPER_PROFILE_ID;
277 error->message = "shaper profile not exist";
282 /* add root node if not have a parent */
283 if (parent_node_id == RTE_TM_NODE_ID_NULL) {
285 if (level_id != ICE_DCF_TM_NODE_TYPE_PORT) {
286 error->type = RTE_TM_ERROR_TYPE_NODE_PARAMS;
287 error->message = "Wrong level";
291 /* obviously no more than one root */
292 if (hw->tm_conf.root) {
293 error->type = RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID;
294 error->message = "already have a root";
298 /* add the root node */
299 tm_node = rte_zmalloc("ice_dcf_tm_node",
300 sizeof(struct ice_dcf_tm_node),
304 tm_node->id = node_id;
305 tm_node->parent = NULL;
306 tm_node->reference_count = 0;
307 rte_memcpy(&tm_node->params, params,
308 sizeof(struct rte_tm_node_params));
309 hw->tm_conf.root = tm_node;
315 /* check the parent node */
316 parent_node = ice_dcf_tm_node_search(dev, parent_node_id,
319 error->type = RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID;
320 error->message = "parent not exist";
323 if (parent_node_type != ICE_DCF_TM_NODE_TYPE_PORT &&
324 parent_node_type != ICE_DCF_TM_NODE_TYPE_TC) {
325 error->type = RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID;
326 error->message = "parent is not port or TC";
330 if (level_id != RTE_TM_NODE_LEVEL_ID_ANY &&
331 level_id != (uint32_t)(parent_node_type + 1)) {
332 error->type = RTE_TM_ERROR_TYPE_NODE_PARAMS;
333 error->message = "Wrong level";
337 /* check the TC node number */
338 if (parent_node_type == ICE_DCF_TM_NODE_TYPE_PORT) {
339 /* check the TC number */
340 if (hw->tm_conf.nb_tc_node >= tc_nb) {
341 error->type = RTE_TM_ERROR_TYPE_NODE_ID;
342 error->message = "too many TCs";
346 /* check the vsi node number */
347 if (parent_node->reference_count >= hw->num_vfs) {
348 error->type = RTE_TM_ERROR_TYPE_NODE_ID;
349 error->message = "too many VSI for one TC";
352 /* check the vsi node id */
353 if (node_id > (uint32_t)(tc_nb * hw->num_vfs)) {
354 error->type = RTE_TM_ERROR_TYPE_NODE_ID;
355 error->message = "too large VSI id";
360 /* add the TC or vsi node */
361 tm_node = rte_zmalloc("ice_dcf_tm_node",
362 sizeof(struct ice_dcf_tm_node),
366 tm_node->id = node_id;
367 tm_node->priority = priority;
368 tm_node->weight = weight;
369 tm_node->shaper_profile = shaper_profile;
370 tm_node->reference_count = 0;
371 tm_node->parent = parent_node;
372 rte_memcpy(&tm_node->params, params,
373 sizeof(struct rte_tm_node_params));
374 if (parent_node_type == ICE_DCF_TM_NODE_TYPE_PORT) {
375 TAILQ_INSERT_TAIL(&hw->tm_conf.tc_list,
377 tm_node->tc = hw->tm_conf.nb_tc_node;
378 hw->tm_conf.nb_tc_node++;
380 TAILQ_INSERT_TAIL(&hw->tm_conf.vsi_list,
382 tm_node->tc = parent_node->tc;
383 hw->tm_conf.nb_vsi_node++;
385 tm_node->parent->reference_count++;
387 /* increase the reference counter of the shaper profile */
389 shaper_profile->reference_count++;
395 ice_dcf_node_delete(struct rte_eth_dev *dev, uint32_t node_id,
396 struct rte_tm_error *error)
398 enum ice_dcf_tm_node_type node_type = ICE_DCF_TM_NODE_TYPE_MAX;
399 struct ice_dcf_adapter *adapter = dev->data->dev_private;
400 struct ice_dcf_hw *hw = &adapter->real_hw;
401 struct ice_dcf_tm_node *tm_node;
406 /* if already committed */
407 if (hw->tm_conf.committed) {
408 error->type = RTE_TM_ERROR_TYPE_UNSPECIFIED;
409 error->message = "already committed";
413 if (node_id == RTE_TM_NODE_ID_NULL) {
414 error->type = RTE_TM_ERROR_TYPE_NODE_ID;
415 error->message = "invalid node id";
419 /* check if the node id exists */
420 tm_node = ice_dcf_tm_node_search(dev, node_id, &node_type);
422 error->type = RTE_TM_ERROR_TYPE_NODE_ID;
423 error->message = "no such node";
427 /* the node should have no child */
428 if (tm_node->reference_count) {
429 error->type = RTE_TM_ERROR_TYPE_NODE_ID;
431 "cannot delete a node which has children";
436 if (node_type == ICE_DCF_TM_NODE_TYPE_PORT) {
437 if (tm_node->shaper_profile)
438 tm_node->shaper_profile->reference_count--;
440 hw->tm_conf.root = NULL;
445 if (tm_node->shaper_profile)
446 tm_node->shaper_profile->reference_count--;
447 tm_node->parent->reference_count--;
448 if (node_type == ICE_DCF_TM_NODE_TYPE_TC) {
449 TAILQ_REMOVE(&hw->tm_conf.tc_list, tm_node, node);
450 hw->tm_conf.nb_tc_node--;
452 TAILQ_REMOVE(&hw->tm_conf.vsi_list, tm_node, node);
453 hw->tm_conf.nb_vsi_node--;
461 ice_dcf_shaper_profile_param_check(struct rte_tm_shaper_params *profile,
462 struct rte_tm_error *error)
464 /* min bucket size not supported */
465 if (profile->committed.size) {
466 error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_SIZE;
467 error->message = "committed bucket size not supported";
470 /* max bucket size not supported */
471 if (profile->peak.size) {
472 error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE;
473 error->message = "peak bucket size not supported";
476 /* length adjustment not supported */
477 if (profile->pkt_length_adjust) {
478 error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PKT_ADJUST_LEN;
479 error->message = "packet length adjustment not supported";
487 ice_dcf_shaper_profile_add(struct rte_eth_dev *dev,
488 uint32_t shaper_profile_id,
489 struct rte_tm_shaper_params *profile,
490 struct rte_tm_error *error)
492 struct ice_dcf_adapter *adapter = dev->data->dev_private;
493 struct ice_dcf_hw *hw = &adapter->real_hw;
494 struct ice_dcf_tm_shaper_profile *shaper_profile;
497 if (!profile || !error)
500 ret = ice_dcf_shaper_profile_param_check(profile, error);
504 shaper_profile = ice_dcf_shaper_profile_search(dev, shaper_profile_id);
506 if (shaper_profile) {
507 error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID;
508 error->message = "profile ID exist";
512 shaper_profile = rte_zmalloc("ice_dcf_tm_shaper_profile",
513 sizeof(struct ice_dcf_tm_shaper_profile),
517 shaper_profile->shaper_profile_id = shaper_profile_id;
518 rte_memcpy(&shaper_profile->profile, profile,
519 sizeof(struct rte_tm_shaper_params));
520 TAILQ_INSERT_TAIL(&hw->tm_conf.shaper_profile_list,
521 shaper_profile, node);
527 ice_dcf_shaper_profile_del(struct rte_eth_dev *dev,
528 uint32_t shaper_profile_id,
529 struct rte_tm_error *error)
531 struct ice_dcf_adapter *adapter = dev->data->dev_private;
532 struct ice_dcf_hw *hw = &adapter->real_hw;
533 struct ice_dcf_tm_shaper_profile *shaper_profile;
538 shaper_profile = ice_dcf_shaper_profile_search(dev, shaper_profile_id);
540 if (!shaper_profile) {
541 error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID;
542 error->message = "profile ID not exist";
546 /* don't delete a profile if it's used by one or several nodes */
547 if (shaper_profile->reference_count) {
548 error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE;
549 error->message = "profile in use";
553 TAILQ_REMOVE(&hw->tm_conf.shaper_profile_list, shaper_profile, node);
554 rte_free(shaper_profile);
560 ice_dcf_set_vf_bw(struct ice_dcf_hw *hw,
561 struct virtchnl_dcf_bw_cfg_list *vf_bw,
564 struct dcf_virtchnl_cmd args;
567 memset(&args, 0, sizeof(args));
568 args.v_op = VIRTCHNL_OP_DCF_CONFIG_BW;
569 args.req_msg = (uint8_t *)vf_bw;
570 args.req_msglen = len;
571 err = ice_dcf_execute_virtchnl_cmd(hw, &args);
573 PMD_DRV_LOG(ERR, "fail to execute command %s",
574 "VIRTCHNL_OP_DCF_CONFIG_BW");
579 ice_dcf_validate_tc_bw(struct virtchnl_dcf_bw_cfg_list *tc_bw,
582 struct virtchnl_dcf_bw_cfg *cfg;
583 bool lowest_cir_mark = false;
584 u32 total_peak, rest_peak;
589 for (i = 0; i < tc_bw->num_elem; i++)
590 total_peak += tc_bw->cfg[i].shaper.peak;
592 for (i = 0; i < tc_bw->num_elem; i++) {
593 cfg = &tc_bw->cfg[i];
594 peak = cfg->shaper.peak;
595 committed = cfg->shaper.committed;
596 rest_peak = total_peak - peak;
598 if (lowest_cir_mark && peak == 0) {
599 PMD_DRV_LOG(ERR, "Max bandwidth must be configured for TC%u",
604 if (!lowest_cir_mark && committed)
605 lowest_cir_mark = true;
607 if (committed && committed + rest_peak > port_bw) {
608 PMD_DRV_LOG(ERR, "Total value of TC%u min bandwidth and other TCs' max bandwidth %ukbps should be less than port link speed %ukbps",
609 cfg->tc_num, committed + rest_peak, port_bw);
613 if (committed && committed < ICE_SCHED_MIN_BW) {
614 PMD_DRV_LOG(ERR, "If TC%u min Tx bandwidth is set, it cannot be less than 500Kbps",
619 if (peak && committed > peak) {
620 PMD_DRV_LOG(ERR, "TC%u Min Tx bandwidth cannot be greater than max Tx bandwidth",
625 if (peak > port_bw) {
626 PMD_DRV_LOG(ERR, "TC%u max Tx bandwidth %uKbps is greater than current link speed %uKbps",
627 cfg->tc_num, peak, port_bw);
635 static int ice_dcf_commit_check(struct ice_dcf_hw *hw)
637 struct ice_dcf_tm_node_list *tc_list = &hw->tm_conf.tc_list;
638 struct ice_dcf_tm_node_list *vsi_list = &hw->tm_conf.vsi_list;
639 struct ice_dcf_tm_node *tm_node;
641 if (!(hw->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_QOS)) {
642 PMD_DRV_LOG(ERR, "Configure VF bandwidth is not supported");
643 return ICE_ERR_NOT_SUPPORTED;
646 /* check if all TC nodes are set */
647 if (BIT(hw->tm_conf.nb_tc_node) & hw->ets_config->tc_valid_bits) {
648 PMD_DRV_LOG(ERR, "Not all enabled TC nodes are set");
649 return ICE_ERR_PARAM;
652 /* check if all VF vsi nodes are binded to all TCs */
653 TAILQ_FOREACH(tm_node, tc_list, node) {
654 if (tm_node->reference_count != hw->num_vfs) {
655 PMD_DRV_LOG(ERR, "Not all VFs are binded to TC%u",
657 return ICE_ERR_PARAM;
661 /* check if VF vsi node id start with 0 */
662 tm_node = TAILQ_FIRST(vsi_list);
663 if (tm_node->id != 0) {
664 PMD_DRV_LOG(ERR, "VF vsi node id must start with 0");
665 return ICE_ERR_PARAM;
671 static int ice_dcf_hierarchy_commit(struct rte_eth_dev *dev,
673 __rte_unused struct rte_tm_error *error)
675 struct ice_dcf_adapter *adapter = dev->data->dev_private;
676 struct ice_dcf_hw *hw = &adapter->real_hw;
677 struct virtchnl_dcf_bw_cfg_list *vf_bw;
678 struct virtchnl_dcf_bw_cfg_list *tc_bw;
679 struct ice_dcf_tm_node_list *vsi_list = &hw->tm_conf.vsi_list;
680 struct rte_tm_shaper_params *profile;
681 struct ice_dcf_tm_node *tm_node;
682 uint32_t port_bw, cir_total;
683 uint16_t size, vf_id;
684 uint8_t num_elem = 0;
687 ret_val = ice_dcf_commit_check(hw);
691 size = sizeof(struct virtchnl_dcf_bw_cfg_list) +
692 sizeof(struct virtchnl_dcf_bw_cfg) *
693 (hw->tm_conf.nb_tc_node - 1);
694 vf_bw = rte_zmalloc("vf_bw", size, 0);
696 ret_val = ICE_ERR_NO_MEMORY;
699 tc_bw = rte_zmalloc("tc_bw", size, 0);
701 ret_val = ICE_ERR_NO_MEMORY;
705 /* port bandwidth (Kbps) */
706 port_bw = hw->link_speed * 1000;
709 /* init tc bw configuration */
710 #define ICE_DCF_SCHED_TC_NODE 0xffff
711 tc_bw->vf_id = ICE_DCF_SCHED_TC_NODE;
712 tc_bw->node_type = VIRTCHNL_DCF_TARGET_TC_BW;
713 tc_bw->num_elem = hw->tm_conf.nb_tc_node;
714 for (i = 0; i < tc_bw->num_elem; i++) {
715 tc_bw->cfg[i].tc_num = i;
716 tc_bw->cfg[i].type = VIRTCHNL_BW_SHAPER;
717 tc_bw->cfg[i].bw_type |=
718 VIRTCHNL_DCF_BW_PIR | VIRTCHNL_DCF_BW_CIR;
721 /* start with VF1, skip VF0 since DCF does not need to configure
722 * bandwidth for itself
724 for (vf_id = 1; vf_id < hw->num_vfs; vf_id++) {
726 vf_bw->vf_id = vf_id;
727 vf_bw->node_type = VIRTCHNL_DCF_TARGET_VF_BW;
728 TAILQ_FOREACH(tm_node, vsi_list, node) {
729 /* scan the nodes belong to one VSI */
730 if (tm_node->id - hw->num_vfs * tm_node->tc != vf_id)
732 vf_bw->cfg[num_elem].tc_num = tm_node->tc;
733 vf_bw->cfg[num_elem].type = VIRTCHNL_BW_SHAPER;
734 if (tm_node->shaper_profile) {
735 /* Transfer from Byte per seconds to Kbps */
736 profile = &tm_node->shaper_profile->profile;
737 vf_bw->cfg[num_elem].shaper.peak =
738 profile->peak.rate / 1000 * BITS_PER_BYTE;
739 vf_bw->cfg[num_elem].shaper.committed =
740 profile->committed.rate / 1000 * BITS_PER_BYTE;
741 vf_bw->cfg[num_elem].bw_type |=
742 VIRTCHNL_DCF_BW_PIR |
746 /* update tc node bw configuration */
747 tc_bw->cfg[tm_node->tc].shaper.peak +=
748 vf_bw->cfg[num_elem].shaper.peak;
749 tc_bw->cfg[tm_node->tc].shaper.committed +=
750 vf_bw->cfg[num_elem].shaper.committed;
752 cir_total += vf_bw->cfg[num_elem].shaper.committed;
756 vf_bw->num_elem = num_elem;
757 ret_val = ice_dcf_set_vf_bw(hw, vf_bw, size);
760 memset(vf_bw, 0, size);
763 /* check if total CIR is larger than port bandwidth */
764 if (cir_total > port_bw) {
765 PMD_DRV_LOG(ERR, "Total CIR of all VFs is larger than port bandwidth");
766 ret_val = ICE_ERR_PARAM;
770 /* check and commit tc node bw configuration */
771 ret_val = ice_dcf_validate_tc_bw(tc_bw, port_bw);
774 ret_val = ice_dcf_set_vf_bw(hw, tc_bw, size);
778 hw->tm_conf.committed = true;
782 /* clear all the traffic manager configuration */
784 ice_dcf_tm_conf_uninit(dev);
785 ice_dcf_tm_conf_init(dev);