4 * Copyright(c) 2010-2017 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include <rte_malloc.h>
36 #include "base/i40e_prototype.h"
37 #include "i40e_ethdev.h"
39 static int i40e_tm_capabilities_get(struct rte_eth_dev *dev,
40 struct rte_tm_capabilities *cap,
41 struct rte_tm_error *error);
42 static int i40e_shaper_profile_add(struct rte_eth_dev *dev,
43 uint32_t shaper_profile_id,
44 struct rte_tm_shaper_params *profile,
45 struct rte_tm_error *error);
46 static int i40e_shaper_profile_del(struct rte_eth_dev *dev,
47 uint32_t shaper_profile_id,
48 struct rte_tm_error *error);
49 static int i40e_node_add(struct rte_eth_dev *dev, uint32_t node_id,
50 uint32_t parent_node_id, uint32_t priority,
51 uint32_t weight, uint32_t level_id,
52 struct rte_tm_node_params *params,
53 struct rte_tm_error *error);
54 static int i40e_node_delete(struct rte_eth_dev *dev, uint32_t node_id,
55 struct rte_tm_error *error);
56 static int i40e_node_type_get(struct rte_eth_dev *dev, uint32_t node_id,
57 int *is_leaf, struct rte_tm_error *error);
58 static int i40e_level_capabilities_get(struct rte_eth_dev *dev,
60 struct rte_tm_level_capabilities *cap,
61 struct rte_tm_error *error);
62 static int i40e_node_capabilities_get(struct rte_eth_dev *dev,
64 struct rte_tm_node_capabilities *cap,
65 struct rte_tm_error *error);
67 const struct rte_tm_ops i40e_tm_ops = {
68 .capabilities_get = i40e_tm_capabilities_get,
69 .shaper_profile_add = i40e_shaper_profile_add,
70 .shaper_profile_delete = i40e_shaper_profile_del,
71 .node_add = i40e_node_add,
72 .node_delete = i40e_node_delete,
73 .node_type_get = i40e_node_type_get,
74 .level_capabilities_get = i40e_level_capabilities_get,
75 .node_capabilities_get = i40e_node_capabilities_get,
79 i40e_tm_ops_get(struct rte_eth_dev *dev __rte_unused,
85 *(const void **)arg = &i40e_tm_ops;
91 i40e_tm_conf_init(struct rte_eth_dev *dev)
93 struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
95 /* initialize shaper profile list */
96 TAILQ_INIT(&pf->tm_conf.shaper_profile_list);
98 /* initialize node configuration */
99 pf->tm_conf.root = NULL;
100 TAILQ_INIT(&pf->tm_conf.tc_list);
101 TAILQ_INIT(&pf->tm_conf.queue_list);
102 pf->tm_conf.nb_tc_node = 0;
103 pf->tm_conf.nb_queue_node = 0;
104 pf->tm_conf.committed = false;
108 i40e_tm_conf_uninit(struct rte_eth_dev *dev)
110 struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
111 struct i40e_tm_shaper_profile *shaper_profile;
112 struct i40e_tm_node *tm_node;
114 /* clear node configuration */
115 while ((tm_node = TAILQ_FIRST(&pf->tm_conf.queue_list))) {
116 TAILQ_REMOVE(&pf->tm_conf.queue_list, tm_node, node);
119 pf->tm_conf.nb_queue_node = 0;
120 while ((tm_node = TAILQ_FIRST(&pf->tm_conf.tc_list))) {
121 TAILQ_REMOVE(&pf->tm_conf.tc_list, tm_node, node);
124 pf->tm_conf.nb_tc_node = 0;
125 if (pf->tm_conf.root) {
126 rte_free(pf->tm_conf.root);
127 pf->tm_conf.root = NULL;
130 /* Remove all shaper profiles */
131 while ((shaper_profile =
132 TAILQ_FIRST(&pf->tm_conf.shaper_profile_list))) {
133 TAILQ_REMOVE(&pf->tm_conf.shaper_profile_list,
134 shaper_profile, node);
135 rte_free(shaper_profile);
139 static inline uint16_t
140 i40e_tc_nb_get(struct rte_eth_dev *dev)
142 struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
143 struct i40e_vsi *main_vsi = pf->main_vsi;
147 for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
148 if (main_vsi->enabled_tc & BIT_ULL(i))
156 i40e_tm_capabilities_get(struct rte_eth_dev *dev,
157 struct rte_tm_capabilities *cap,
158 struct rte_tm_error *error)
160 struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
161 uint16_t tc_nb = i40e_tc_nb_get(dev);
166 if (tc_nb > hw->func_caps.num_tx_qp)
169 error->type = RTE_TM_ERROR_TYPE_NONE;
171 /* set all the parameters to 0 first. */
172 memset(cap, 0, sizeof(struct rte_tm_capabilities));
175 * support port + TCs + queues
176 * here shows the max capability not the current configuration.
178 cap->n_nodes_max = 1 + I40E_MAX_TRAFFIC_CLASS + hw->func_caps.num_tx_qp;
179 cap->n_levels_max = 3; /* port, TC, queue */
180 cap->non_leaf_nodes_identical = 1;
181 cap->leaf_nodes_identical = 1;
182 cap->shaper_n_max = cap->n_nodes_max;
183 cap->shaper_private_n_max = cap->n_nodes_max;
184 cap->shaper_private_dual_rate_n_max = 0;
185 cap->shaper_private_rate_min = 0;
186 /* 40Gbps -> 5GBps */
187 cap->shaper_private_rate_max = 5000000000ull;
188 cap->shaper_shared_n_max = 0;
189 cap->shaper_shared_n_nodes_per_shaper_max = 0;
190 cap->shaper_shared_n_shapers_per_node_max = 0;
191 cap->shaper_shared_dual_rate_n_max = 0;
192 cap->shaper_shared_rate_min = 0;
193 cap->shaper_shared_rate_max = 0;
194 cap->sched_n_children_max = hw->func_caps.num_tx_qp;
196 * HW supports SP. But no plan to support it now.
197 * So, all the nodes should have the same priority.
199 cap->sched_sp_n_priorities_max = 1;
200 cap->sched_wfq_n_children_per_group_max = 0;
201 cap->sched_wfq_n_groups_max = 0;
203 * SW only supports fair round robin now.
204 * So, all the nodes should have the same weight.
206 cap->sched_wfq_weight_max = 1;
207 cap->cman_head_drop_supported = 0;
208 cap->dynamic_update_mask = 0;
209 cap->shaper_pkt_length_adjust_min = RTE_TM_ETH_FRAMING_OVERHEAD;
210 cap->shaper_pkt_length_adjust_max = RTE_TM_ETH_FRAMING_OVERHEAD_FCS;
211 cap->cman_wred_context_n_max = 0;
212 cap->cman_wred_context_private_n_max = 0;
213 cap->cman_wred_context_shared_n_max = 0;
214 cap->cman_wred_context_shared_n_nodes_per_context_max = 0;
215 cap->cman_wred_context_shared_n_contexts_per_node_max = 0;
221 static inline struct i40e_tm_shaper_profile *
222 i40e_shaper_profile_search(struct rte_eth_dev *dev,
223 uint32_t shaper_profile_id)
225 struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
226 struct i40e_shaper_profile_list *shaper_profile_list =
227 &pf->tm_conf.shaper_profile_list;
228 struct i40e_tm_shaper_profile *shaper_profile;
230 TAILQ_FOREACH(shaper_profile, shaper_profile_list, node) {
231 if (shaper_profile_id == shaper_profile->shaper_profile_id)
232 return shaper_profile;
239 i40e_shaper_profile_param_check(struct rte_tm_shaper_params *profile,
240 struct rte_tm_error *error)
242 /* min rate not supported */
243 if (profile->committed.rate) {
244 error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_RATE;
245 error->message = "committed rate not supported";
248 /* min bucket size not supported */
249 if (profile->committed.size) {
250 error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_SIZE;
251 error->message = "committed bucket size not supported";
254 /* max bucket size not supported */
255 if (profile->peak.size) {
256 error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE;
257 error->message = "peak bucket size not supported";
260 /* length adjustment not supported */
261 if (profile->pkt_length_adjust) {
262 error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PKT_ADJUST_LEN;
263 error->message = "packet length adjustment not supported";
271 i40e_shaper_profile_add(struct rte_eth_dev *dev,
272 uint32_t shaper_profile_id,
273 struct rte_tm_shaper_params *profile,
274 struct rte_tm_error *error)
276 struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
277 struct i40e_tm_shaper_profile *shaper_profile;
280 if (!profile || !error)
283 ret = i40e_shaper_profile_param_check(profile, error);
287 shaper_profile = i40e_shaper_profile_search(dev, shaper_profile_id);
289 if (shaper_profile) {
290 error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID;
291 error->message = "profile ID exist";
295 shaper_profile = rte_zmalloc("i40e_tm_shaper_profile",
296 sizeof(struct i40e_tm_shaper_profile),
300 shaper_profile->shaper_profile_id = shaper_profile_id;
301 (void)rte_memcpy(&shaper_profile->profile, profile,
302 sizeof(struct rte_tm_shaper_params));
303 TAILQ_INSERT_TAIL(&pf->tm_conf.shaper_profile_list,
304 shaper_profile, node);
310 i40e_shaper_profile_del(struct rte_eth_dev *dev,
311 uint32_t shaper_profile_id,
312 struct rte_tm_error *error)
314 struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
315 struct i40e_tm_shaper_profile *shaper_profile;
320 shaper_profile = i40e_shaper_profile_search(dev, shaper_profile_id);
322 if (!shaper_profile) {
323 error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID;
324 error->message = "profile ID not exist";
328 /* don't delete a profile if it's used by one or several nodes */
329 if (shaper_profile->reference_count) {
330 error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE;
331 error->message = "profile in use";
335 TAILQ_REMOVE(&pf->tm_conf.shaper_profile_list, shaper_profile, node);
336 rte_free(shaper_profile);
341 static inline struct i40e_tm_node *
342 i40e_tm_node_search(struct rte_eth_dev *dev,
343 uint32_t node_id, enum i40e_tm_node_type *node_type)
345 struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
346 struct i40e_tm_node_list *queue_list = &pf->tm_conf.queue_list;
347 struct i40e_tm_node_list *tc_list = &pf->tm_conf.tc_list;
348 struct i40e_tm_node *tm_node;
350 if (pf->tm_conf.root && pf->tm_conf.root->id == node_id) {
351 *node_type = I40E_TM_NODE_TYPE_PORT;
352 return pf->tm_conf.root;
355 TAILQ_FOREACH(tm_node, tc_list, node) {
356 if (tm_node->id == node_id) {
357 *node_type = I40E_TM_NODE_TYPE_TC;
362 TAILQ_FOREACH(tm_node, queue_list, node) {
363 if (tm_node->id == node_id) {
364 *node_type = I40E_TM_NODE_TYPE_QUEUE;
373 i40e_node_param_check(uint32_t node_id, uint32_t parent_node_id,
374 uint32_t priority, uint32_t weight,
375 struct rte_tm_node_params *params,
376 struct rte_tm_error *error)
378 if (node_id == RTE_TM_NODE_ID_NULL) {
379 error->type = RTE_TM_ERROR_TYPE_NODE_ID;
380 error->message = "invalid node id";
385 error->type = RTE_TM_ERROR_TYPE_NODE_PRIORITY;
386 error->message = "priority should be 0";
391 error->type = RTE_TM_ERROR_TYPE_NODE_WEIGHT;
392 error->message = "weight must be 1";
396 /* not support shared shaper */
397 if (params->shared_shaper_id) {
398 error->type = RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_SHAPER_ID;
399 error->message = "shared shaper not supported";
402 if (params->n_shared_shapers) {
403 error->type = RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_SHAPERS;
404 error->message = "shared shaper not supported";
409 if (parent_node_id == RTE_TM_NODE_ID_NULL) {
410 if (params->nonleaf.wfq_weight_mode) {
412 RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE;
413 error->message = "WFQ not supported";
416 if (params->nonleaf.n_sp_priorities != 1) {
418 RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SP_PRIORITIES;
419 error->message = "SP priority not supported";
421 } else if (params->nonleaf.wfq_weight_mode &&
422 !(*params->nonleaf.wfq_weight_mode)) {
424 RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE;
425 error->message = "WFP should be byte mode";
432 /* for TC or queue node */
433 if (params->leaf.cman) {
434 error->type = RTE_TM_ERROR_TYPE_NODE_PARAMS_CMAN;
435 error->message = "Congestion management not supported";
438 if (params->leaf.wred.wred_profile_id !=
439 RTE_TM_WRED_PROFILE_ID_NONE) {
441 RTE_TM_ERROR_TYPE_NODE_PARAMS_WRED_PROFILE_ID;
442 error->message = "WRED not supported";
445 if (params->leaf.wred.shared_wred_context_id) {
447 RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_WRED_CONTEXT_ID;
448 error->message = "WRED not supported";
451 if (params->leaf.wred.n_shared_wred_contexts) {
453 RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_WRED_CONTEXTS;
454 error->message = "WRED not supported";
462 * Now the TC and queue configuration is controlled by DCB.
463 * We need check if the node configuration follows the DCB configuration.
464 * In the future, we may use TM to cover DCB.
467 i40e_node_add(struct rte_eth_dev *dev, uint32_t node_id,
468 uint32_t parent_node_id, uint32_t priority,
469 uint32_t weight, uint32_t level_id,
470 struct rte_tm_node_params *params,
471 struct rte_tm_error *error)
473 struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
474 struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
475 enum i40e_tm_node_type node_type = I40E_TM_NODE_TYPE_MAX;
476 enum i40e_tm_node_type parent_node_type = I40E_TM_NODE_TYPE_MAX;
477 struct i40e_tm_shaper_profile *shaper_profile;
478 struct i40e_tm_node *tm_node;
479 struct i40e_tm_node *parent_node;
483 if (!params || !error)
486 /* if already committed */
487 if (pf->tm_conf.committed) {
488 error->type = RTE_TM_ERROR_TYPE_UNSPECIFIED;
489 error->message = "already committed";
493 ret = i40e_node_param_check(node_id, parent_node_id, priority, weight,
498 /* check if the node ID is already used */
499 if (i40e_tm_node_search(dev, node_id, &node_type)) {
500 error->type = RTE_TM_ERROR_TYPE_NODE_ID;
501 error->message = "node id already used";
505 /* check the shaper profile id */
506 shaper_profile = i40e_shaper_profile_search(dev,
507 params->shaper_profile_id);
508 if (!shaper_profile) {
509 error->type = RTE_TM_ERROR_TYPE_NODE_PARAMS_SHAPER_PROFILE_ID;
510 error->message = "shaper profile not exist";
514 /* root node if not have a parent */
515 if (parent_node_id == RTE_TM_NODE_ID_NULL) {
517 if (level_id != RTE_TM_NODE_LEVEL_ID_ANY &&
518 level_id > I40E_TM_NODE_TYPE_PORT) {
519 error->type = RTE_TM_ERROR_TYPE_NODE_PARAMS;
520 error->message = "Wrong level";
524 /* obviously no more than one root */
525 if (pf->tm_conf.root) {
526 error->type = RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID;
527 error->message = "already have a root";
531 /* add the root node */
532 tm_node = rte_zmalloc("i40e_tm_node",
533 sizeof(struct i40e_tm_node),
537 tm_node->id = node_id;
538 tm_node->priority = priority;
539 tm_node->weight = weight;
540 tm_node->reference_count = 0;
541 tm_node->parent = NULL;
542 tm_node->shaper_profile = shaper_profile;
543 (void)rte_memcpy(&tm_node->params, params,
544 sizeof(struct rte_tm_node_params));
545 pf->tm_conf.root = tm_node;
547 /* increase the reference counter of the shaper profile */
548 shaper_profile->reference_count++;
553 /* TC or queue node */
554 /* check the parent node */
555 parent_node = i40e_tm_node_search(dev, parent_node_id,
558 error->type = RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID;
559 error->message = "parent not exist";
562 if (parent_node_type != I40E_TM_NODE_TYPE_PORT &&
563 parent_node_type != I40E_TM_NODE_TYPE_TC) {
564 error->type = RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID;
565 error->message = "parent is not port or TC";
569 if (level_id != RTE_TM_NODE_LEVEL_ID_ANY &&
570 level_id != parent_node_type + 1) {
571 error->type = RTE_TM_ERROR_TYPE_NODE_PARAMS;
572 error->message = "Wrong level";
576 /* check the node number */
577 if (parent_node_type == I40E_TM_NODE_TYPE_PORT) {
578 /* check the TC number */
579 tc_nb = i40e_tc_nb_get(dev);
580 if (pf->tm_conf.nb_tc_node >= tc_nb) {
581 error->type = RTE_TM_ERROR_TYPE_NODE_ID;
582 error->message = "too many TCs";
586 /* check the queue number */
587 if (pf->tm_conf.nb_queue_node >= hw->func_caps.num_tx_qp) {
588 error->type = RTE_TM_ERROR_TYPE_NODE_ID;
589 error->message = "too many queues";
595 * For queue, the node id means queue id.
597 if (node_id >= hw->func_caps.num_tx_qp) {
598 error->type = RTE_TM_ERROR_TYPE_NODE_ID;
599 error->message = "too large queue id";
604 /* add the TC or queue node */
605 tm_node = rte_zmalloc("i40e_tm_node",
606 sizeof(struct i40e_tm_node),
610 tm_node->id = node_id;
611 tm_node->priority = priority;
612 tm_node->weight = weight;
613 tm_node->reference_count = 0;
614 tm_node->parent = pf->tm_conf.root;
615 tm_node->shaper_profile = shaper_profile;
616 (void)rte_memcpy(&tm_node->params, params,
617 sizeof(struct rte_tm_node_params));
618 if (parent_node_type == I40E_TM_NODE_TYPE_PORT) {
619 TAILQ_INSERT_TAIL(&pf->tm_conf.tc_list,
621 pf->tm_conf.nb_tc_node++;
623 TAILQ_INSERT_TAIL(&pf->tm_conf.queue_list,
625 pf->tm_conf.nb_queue_node++;
627 tm_node->parent->reference_count++;
629 /* increase the reference counter of the shaper profile */
630 shaper_profile->reference_count++;
636 i40e_node_delete(struct rte_eth_dev *dev, uint32_t node_id,
637 struct rte_tm_error *error)
639 struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
640 enum i40e_tm_node_type node_type = I40E_TM_NODE_TYPE_MAX;
641 struct i40e_tm_node *tm_node;
646 /* if already committed */
647 if (pf->tm_conf.committed) {
648 error->type = RTE_TM_ERROR_TYPE_UNSPECIFIED;
649 error->message = "already committed";
653 if (node_id == RTE_TM_NODE_ID_NULL) {
654 error->type = RTE_TM_ERROR_TYPE_NODE_ID;
655 error->message = "invalid node id";
659 /* check if the node id exists */
660 tm_node = i40e_tm_node_search(dev, node_id, &node_type);
662 error->type = RTE_TM_ERROR_TYPE_NODE_ID;
663 error->message = "no such node";
667 /* the node should have no child */
668 if (tm_node->reference_count) {
669 error->type = RTE_TM_ERROR_TYPE_NODE_ID;
671 "cannot delete a node which has children";
676 if (node_type == I40E_TM_NODE_TYPE_PORT) {
677 tm_node->shaper_profile->reference_count--;
679 pf->tm_conf.root = NULL;
683 /* TC or queue node */
684 tm_node->shaper_profile->reference_count--;
685 tm_node->parent->reference_count--;
686 if (node_type == I40E_TM_NODE_TYPE_TC) {
687 TAILQ_REMOVE(&pf->tm_conf.tc_list, tm_node, node);
688 pf->tm_conf.nb_tc_node--;
690 TAILQ_REMOVE(&pf->tm_conf.queue_list, tm_node, node);
691 pf->tm_conf.nb_queue_node--;
699 i40e_node_type_get(struct rte_eth_dev *dev, uint32_t node_id,
700 int *is_leaf, struct rte_tm_error *error)
702 enum i40e_tm_node_type node_type = I40E_TM_NODE_TYPE_MAX;
703 struct i40e_tm_node *tm_node;
705 if (!is_leaf || !error)
708 if (node_id == RTE_TM_NODE_ID_NULL) {
709 error->type = RTE_TM_ERROR_TYPE_NODE_ID;
710 error->message = "invalid node id";
714 /* check if the node id exists */
715 tm_node = i40e_tm_node_search(dev, node_id, &node_type);
717 error->type = RTE_TM_ERROR_TYPE_NODE_ID;
718 error->message = "no such node";
722 if (node_type == I40E_TM_NODE_TYPE_QUEUE)
731 i40e_level_capabilities_get(struct rte_eth_dev *dev,
733 struct rte_tm_level_capabilities *cap,
734 struct rte_tm_error *error)
736 struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
741 if (level_id >= I40E_TM_NODE_TYPE_MAX) {
742 error->type = RTE_TM_ERROR_TYPE_LEVEL_ID;
743 error->message = "too deep level";
748 if (level_id == I40E_TM_NODE_TYPE_PORT) {
749 cap->n_nodes_max = 1;
750 cap->n_nodes_nonleaf_max = 1;
751 cap->n_nodes_leaf_max = 0;
752 cap->non_leaf_nodes_identical = true;
753 cap->leaf_nodes_identical = true;
754 cap->nonleaf.shaper_private_supported = true;
755 cap->nonleaf.shaper_private_dual_rate_supported = false;
756 cap->nonleaf.shaper_private_rate_min = 0;
757 /* 40Gbps -> 5GBps */
758 cap->nonleaf.shaper_private_rate_max = 5000000000ull;
759 cap->nonleaf.shaper_shared_n_max = 0;
760 cap->nonleaf.sched_n_children_max = I40E_MAX_TRAFFIC_CLASS;
761 cap->nonleaf.sched_sp_n_priorities_max = 1;
762 cap->nonleaf.sched_wfq_n_children_per_group_max = 0;
763 cap->nonleaf.sched_wfq_n_groups_max = 0;
764 cap->nonleaf.sched_wfq_weight_max = 1;
765 cap->nonleaf.stats_mask = 0;
770 /* TC or queue node */
771 if (level_id == I40E_TM_NODE_TYPE_TC) {
773 cap->n_nodes_max = I40E_MAX_TRAFFIC_CLASS;
774 cap->n_nodes_nonleaf_max = I40E_MAX_TRAFFIC_CLASS;
775 cap->n_nodes_leaf_max = 0;
776 cap->non_leaf_nodes_identical = true;
779 cap->n_nodes_max = hw->func_caps.num_tx_qp;
780 cap->n_nodes_nonleaf_max = 0;
781 cap->n_nodes_leaf_max = hw->func_caps.num_tx_qp;
782 cap->non_leaf_nodes_identical = true;
784 cap->leaf_nodes_identical = true;
785 cap->leaf.shaper_private_supported = true;
786 cap->leaf.shaper_private_dual_rate_supported = false;
787 cap->leaf.shaper_private_rate_min = 0;
788 /* 40Gbps -> 5GBps */
789 cap->leaf.shaper_private_rate_max = 5000000000ull;
790 cap->leaf.shaper_shared_n_max = 0;
791 cap->leaf.cman_head_drop_supported = false;
792 cap->leaf.cman_wred_context_private_supported = true;
793 cap->leaf.cman_wred_context_shared_n_max = 0;
794 cap->leaf.stats_mask = 0;
800 i40e_node_capabilities_get(struct rte_eth_dev *dev,
802 struct rte_tm_node_capabilities *cap,
803 struct rte_tm_error *error)
805 struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
806 enum i40e_tm_node_type node_type;
807 struct i40e_tm_node *tm_node;
812 if (node_id == RTE_TM_NODE_ID_NULL) {
813 error->type = RTE_TM_ERROR_TYPE_NODE_ID;
814 error->message = "invalid node id";
818 /* check if the node id exists */
819 tm_node = i40e_tm_node_search(dev, node_id, &node_type);
821 error->type = RTE_TM_ERROR_TYPE_NODE_ID;
822 error->message = "no such node";
826 cap->shaper_private_supported = true;
827 cap->shaper_private_dual_rate_supported = false;
828 cap->shaper_private_rate_min = 0;
829 /* 40Gbps -> 5GBps */
830 cap->shaper_private_rate_max = 5000000000ull;
831 cap->shaper_shared_n_max = 0;
833 if (node_type == I40E_TM_NODE_TYPE_QUEUE) {
834 cap->leaf.cman_head_drop_supported = false;
835 cap->leaf.cman_wred_context_private_supported = true;
836 cap->leaf.cman_wred_context_shared_n_max = 0;
838 if (node_type == I40E_TM_NODE_TYPE_PORT)
839 cap->nonleaf.sched_n_children_max =
840 I40E_MAX_TRAFFIC_CLASS;
842 cap->nonleaf.sched_n_children_max =
843 hw->func_caps.num_tx_qp;
844 cap->nonleaf.sched_sp_n_priorities_max = 1;
845 cap->nonleaf.sched_wfq_n_children_per_group_max = 0;
846 cap->nonleaf.sched_wfq_n_groups_max = 0;
847 cap->nonleaf.sched_wfq_weight_max = 1;