Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2010-2017 Intel Corporation
3 : : */
4 : :
5 : : #include <rte_malloc.h>
6 : :
7 : : #include "ixgbe_ethdev.h"
8 : :
9 : : static int ixgbe_tm_capabilities_get(struct rte_eth_dev *dev,
10 : : struct rte_tm_capabilities *cap,
11 : : struct rte_tm_error *error);
12 : : static int ixgbe_shaper_profile_add(struct rte_eth_dev *dev,
13 : : uint32_t shaper_profile_id,
14 : : const struct rte_tm_shaper_params *profile,
15 : : struct rte_tm_error *error);
16 : : static int ixgbe_shaper_profile_del(struct rte_eth_dev *dev,
17 : : uint32_t shaper_profile_id,
18 : : struct rte_tm_error *error);
19 : : static int ixgbe_node_add(struct rte_eth_dev *dev, uint32_t node_id,
20 : : uint32_t parent_node_id, uint32_t priority,
21 : : uint32_t weight, uint32_t level_id,
22 : : const struct rte_tm_node_params *params,
23 : : struct rte_tm_error *error);
24 : : static int ixgbe_node_delete(struct rte_eth_dev *dev, uint32_t node_id,
25 : : struct rte_tm_error *error);
26 : : static int ixgbe_node_type_get(struct rte_eth_dev *dev, uint32_t node_id,
27 : : int *is_leaf, struct rte_tm_error *error);
28 : : static int ixgbe_level_capabilities_get(struct rte_eth_dev *dev,
29 : : uint32_t level_id,
30 : : struct rte_tm_level_capabilities *cap,
31 : : struct rte_tm_error *error);
32 : : static int ixgbe_node_capabilities_get(struct rte_eth_dev *dev,
33 : : uint32_t node_id,
34 : : struct rte_tm_node_capabilities *cap,
35 : : struct rte_tm_error *error);
36 : : static int ixgbe_hierarchy_commit(struct rte_eth_dev *dev,
37 : : int clear_on_fail,
38 : : struct rte_tm_error *error);
39 : :
40 : : const struct rte_tm_ops ixgbe_tm_ops = {
41 : : .capabilities_get = ixgbe_tm_capabilities_get,
42 : : .shaper_profile_add = ixgbe_shaper_profile_add,
43 : : .shaper_profile_delete = ixgbe_shaper_profile_del,
44 : : .node_add = ixgbe_node_add,
45 : : .node_delete = ixgbe_node_delete,
46 : : .node_type_get = ixgbe_node_type_get,
47 : : .level_capabilities_get = ixgbe_level_capabilities_get,
48 : : .node_capabilities_get = ixgbe_node_capabilities_get,
49 : : .hierarchy_commit = ixgbe_hierarchy_commit,
50 : : };
51 : :
52 : : int
53 : 0 : ixgbe_tm_ops_get(struct rte_eth_dev *dev __rte_unused,
54 : : void *arg)
55 : : {
56 [ # # ]: 0 : if (!arg)
57 : : return -EINVAL;
58 : :
59 : 0 : *(const void **)arg = &ixgbe_tm_ops;
60 : :
61 : 0 : return 0;
62 : : }
63 : :
64 : : void
65 : 0 : ixgbe_tm_conf_init(struct rte_eth_dev *dev)
66 : : {
67 : : struct ixgbe_tm_conf *tm_conf =
68 : 0 : IXGBE_DEV_PRIVATE_TO_TM_CONF(dev->data->dev_private);
69 : :
70 : : /* initialize shaper profile list */
71 : 0 : TAILQ_INIT(&tm_conf->shaper_profile_list);
72 : :
73 : : /* initialize node configuration */
74 : 0 : tm_conf->root = NULL;
75 : 0 : TAILQ_INIT(&tm_conf->queue_list);
76 : 0 : TAILQ_INIT(&tm_conf->tc_list);
77 : 0 : tm_conf->nb_tc_node = 0;
78 : 0 : tm_conf->nb_queue_node = 0;
79 : 0 : tm_conf->committed = false;
80 : 0 : }
81 : :
82 : : void
83 : 0 : ixgbe_tm_conf_uninit(struct rte_eth_dev *dev)
84 : : {
85 : : struct ixgbe_tm_conf *tm_conf =
86 : 0 : IXGBE_DEV_PRIVATE_TO_TM_CONF(dev->data->dev_private);
87 : : struct ixgbe_tm_shaper_profile *shaper_profile;
88 : : struct ixgbe_tm_node *tm_node;
89 : :
90 : : /* clear node configuration */
91 [ # # ]: 0 : while ((tm_node = TAILQ_FIRST(&tm_conf->queue_list))) {
92 [ # # ]: 0 : TAILQ_REMOVE(&tm_conf->queue_list, tm_node, node);
93 : 0 : rte_free(tm_node);
94 : : }
95 : 0 : tm_conf->nb_queue_node = 0;
96 [ # # ]: 0 : while ((tm_node = TAILQ_FIRST(&tm_conf->tc_list))) {
97 [ # # ]: 0 : TAILQ_REMOVE(&tm_conf->tc_list, tm_node, node);
98 : 0 : rte_free(tm_node);
99 : : }
100 : 0 : tm_conf->nb_tc_node = 0;
101 [ # # ]: 0 : if (tm_conf->root) {
102 : 0 : rte_free(tm_conf->root);
103 : 0 : tm_conf->root = NULL;
104 : : }
105 : :
106 : : /* Remove all shaper profiles */
107 [ # # ]: 0 : while ((shaper_profile =
108 : : TAILQ_FIRST(&tm_conf->shaper_profile_list))) {
109 [ # # ]: 0 : TAILQ_REMOVE(&tm_conf->shaper_profile_list,
110 : : shaper_profile, node);
111 : 0 : rte_free(shaper_profile);
112 : : }
113 : 0 : }
114 : :
115 : : static inline uint8_t
116 : : ixgbe_tc_nb_get(struct rte_eth_dev *dev)
117 : : {
118 : : struct rte_eth_conf *eth_conf;
119 : : uint8_t nb_tcs = 0;
120 : :
121 : 0 : eth_conf = &dev->data->dev_conf;
122 [ # # ]: 0 : if (eth_conf->txmode.mq_mode == RTE_ETH_MQ_TX_DCB) {
123 : 0 : nb_tcs = eth_conf->tx_adv_conf.dcb_tx_conf.nb_tcs;
124 [ # # # # : 0 : } else if (eth_conf->txmode.mq_mode == RTE_ETH_MQ_TX_VMDQ_DCB) {
# # ]
125 [ # # # # : 0 : if (eth_conf->tx_adv_conf.vmdq_dcb_tx_conf.nb_queue_pools ==
# # ]
126 : : RTE_ETH_32_POOLS)
127 : : nb_tcs = RTE_ETH_4_TCS;
128 : : else
129 : : nb_tcs = RTE_ETH_8_TCS;
130 : : } else {
131 : : nb_tcs = 1;
132 : : }
133 : :
134 : : return nb_tcs;
135 : : }
136 : :
137 : : static int
138 : 0 : ixgbe_tm_capabilities_get(struct rte_eth_dev *dev,
139 : : struct rte_tm_capabilities *cap,
140 : : struct rte_tm_error *error)
141 : : {
142 [ # # ]: 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
143 : : uint8_t tc_nb = ixgbe_tc_nb_get(dev);
144 : :
145 [ # # ]: 0 : if (!cap || !error)
146 : : return -EINVAL;
147 : :
148 [ # # ]: 0 : if (tc_nb > hw->mac.max_tx_queues)
149 : : return -EINVAL;
150 : :
151 : 0 : error->type = RTE_TM_ERROR_TYPE_NONE;
152 : :
153 : : /* set all the parameters to 0 first. */
154 : : memset(cap, 0, sizeof(struct rte_tm_capabilities));
155 : :
156 : : /**
157 : : * here is the max capability not the current configuration.
158 : : */
159 : : /* port + TCs + queues */
160 : 0 : cap->n_nodes_max = 1 + IXGBE_DCB_MAX_TRAFFIC_CLASS +
161 : 0 : hw->mac.max_tx_queues;
162 : 0 : cap->n_levels_max = 3;
163 : 0 : cap->non_leaf_nodes_identical = 1;
164 : 0 : cap->leaf_nodes_identical = 1;
165 : 0 : cap->shaper_n_max = cap->n_nodes_max;
166 : 0 : cap->shaper_private_n_max = cap->n_nodes_max;
167 : : cap->shaper_private_dual_rate_n_max = 0;
168 : : cap->shaper_private_rate_min = 0;
169 : : /* 10Gbps -> 1.25GBps */
170 : 0 : cap->shaper_private_rate_max = 1250000000ull;
171 : : cap->shaper_private_packet_mode_supported = 0;
172 : 0 : cap->shaper_private_byte_mode_supported = 1;
173 : : cap->shaper_shared_n_max = 0;
174 : : cap->shaper_shared_n_nodes_per_shaper_max = 0;
175 : : cap->shaper_shared_n_shapers_per_node_max = 0;
176 : : cap->shaper_shared_dual_rate_n_max = 0;
177 : : cap->shaper_shared_rate_min = 0;
178 : : cap->shaper_shared_rate_max = 0;
179 : : cap->shaper_shared_packet_mode_supported = 0;
180 : : cap->shaper_shared_byte_mode_supported = 0;
181 : 0 : cap->sched_n_children_max = hw->mac.max_tx_queues;
182 : : /**
183 : : * HW supports SP. But no plan to support it now.
184 : : * So, all the nodes should have the same priority.
185 : : */
186 : 0 : cap->sched_sp_n_priorities_max = 1;
187 : : cap->sched_wfq_n_children_per_group_max = 0;
188 : : cap->sched_wfq_n_groups_max = 0;
189 : : cap->sched_wfq_packet_mode_supported = 0;
190 : : cap->sched_wfq_byte_mode_supported = 0;
191 : : /**
192 : : * SW only supports fair round robin now.
193 : : * So, all the nodes should have the same weight.
194 : : */
195 : 0 : cap->sched_wfq_weight_max = 1;
196 : : cap->cman_head_drop_supported = 0;
197 : : cap->dynamic_update_mask = 0;
198 : 0 : cap->shaper_pkt_length_adjust_min = RTE_TM_ETH_FRAMING_OVERHEAD;
199 : 0 : cap->shaper_pkt_length_adjust_max = RTE_TM_ETH_FRAMING_OVERHEAD_FCS;
200 : : cap->cman_wred_context_n_max = 0;
201 : : cap->cman_wred_context_private_n_max = 0;
202 : : cap->cman_wred_context_shared_n_max = 0;
203 : : cap->cman_wred_context_shared_n_nodes_per_context_max = 0;
204 : : cap->cman_wred_context_shared_n_contexts_per_node_max = 0;
205 : : cap->stats_mask = 0;
206 : :
207 : 0 : return 0;
208 : : }
209 : :
210 : : static inline struct ixgbe_tm_shaper_profile *
211 : : ixgbe_shaper_profile_search(struct rte_eth_dev *dev,
212 : : uint32_t shaper_profile_id)
213 : : {
214 : : struct ixgbe_tm_conf *tm_conf =
215 : : IXGBE_DEV_PRIVATE_TO_TM_CONF(dev->data->dev_private);
216 : : struct ixgbe_shaper_profile_list *shaper_profile_list =
217 : : &tm_conf->shaper_profile_list;
218 : : struct ixgbe_tm_shaper_profile *shaper_profile;
219 : :
220 [ # # # # : 0 : TAILQ_FOREACH(shaper_profile, shaper_profile_list, node) {
# # ]
221 [ # # # # : 0 : if (shaper_profile_id == shaper_profile->shaper_profile_id)
# # ]
222 : : return shaper_profile;
223 : : }
224 : :
225 : : return NULL;
226 : : }
227 : :
228 : : static int
229 : : ixgbe_shaper_profile_param_check(const struct rte_tm_shaper_params *profile,
230 : : struct rte_tm_error *error)
231 : : {
232 : : /* min rate not supported */
233 [ # # ]: 0 : if (profile->committed.rate) {
234 : 0 : error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_RATE;
235 : 0 : error->message = "committed rate not supported";
236 : : return -EINVAL;
237 : : }
238 : : /* min bucket size not supported */
239 [ # # ]: 0 : if (profile->committed.size) {
240 : 0 : error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_SIZE;
241 : 0 : error->message = "committed bucket size not supported";
242 : : return -EINVAL;
243 : : }
244 : : /* max bucket size not supported */
245 [ # # ]: 0 : if (profile->peak.size) {
246 : 0 : error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE;
247 : 0 : error->message = "peak bucket size not supported";
248 : : return -EINVAL;
249 : : }
250 : : /* length adjustment not supported */
251 [ # # ]: 0 : if (profile->pkt_length_adjust) {
252 : 0 : error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PKT_ADJUST_LEN;
253 : 0 : error->message = "packet length adjustment not supported";
254 : : return -EINVAL;
255 : : }
256 : :
257 : : return 0;
258 : : }
259 : :
260 : : static int
261 : 0 : ixgbe_shaper_profile_add(struct rte_eth_dev *dev,
262 : : uint32_t shaper_profile_id,
263 : : const struct rte_tm_shaper_params *profile,
264 : : struct rte_tm_error *error)
265 : : {
266 : : struct ixgbe_tm_conf *tm_conf =
267 : 0 : IXGBE_DEV_PRIVATE_TO_TM_CONF(dev->data->dev_private);
268 : : struct ixgbe_tm_shaper_profile *shaper_profile;
269 : : int ret;
270 : :
271 [ # # ]: 0 : if (!profile || !error)
272 : : return -EINVAL;
273 : :
274 : : ret = ixgbe_shaper_profile_param_check(profile, error);
275 : : if (ret)
276 : 0 : return ret;
277 : :
278 : : shaper_profile = ixgbe_shaper_profile_search(dev, shaper_profile_id);
279 : :
280 [ # # ]: 0 : if (shaper_profile) {
281 : 0 : error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID;
282 : 0 : error->message = "profile ID exist";
283 : 0 : return -EINVAL;
284 : : }
285 : :
286 : 0 : shaper_profile = rte_zmalloc("ixgbe_tm_shaper_profile",
287 : : sizeof(struct ixgbe_tm_shaper_profile),
288 : : 0);
289 [ # # ]: 0 : if (!shaper_profile)
290 : : return -ENOMEM;
291 : 0 : shaper_profile->shaper_profile_id = shaper_profile_id;
292 : 0 : memcpy(&shaper_profile->profile, profile,
293 : : sizeof(struct rte_tm_shaper_params));
294 : 0 : TAILQ_INSERT_TAIL(&tm_conf->shaper_profile_list,
295 : : shaper_profile, node);
296 : :
297 : 0 : return 0;
298 : : }
299 : :
300 : : static int
301 : 0 : ixgbe_shaper_profile_del(struct rte_eth_dev *dev,
302 : : uint32_t shaper_profile_id,
303 : : struct rte_tm_error *error)
304 : : {
305 : : struct ixgbe_tm_conf *tm_conf =
306 : 0 : IXGBE_DEV_PRIVATE_TO_TM_CONF(dev->data->dev_private);
307 : : struct ixgbe_tm_shaper_profile *shaper_profile;
308 : :
309 [ # # ]: 0 : if (!error)
310 : : return -EINVAL;
311 : :
312 : : shaper_profile = ixgbe_shaper_profile_search(dev, shaper_profile_id);
313 : :
314 [ # # ]: 0 : if (!shaper_profile) {
315 : 0 : error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID;
316 : 0 : error->message = "profile ID not exist";
317 : 0 : return -EINVAL;
318 : : }
319 : :
320 : : /* don't delete a profile if it's used by one or several nodes */
321 [ # # ]: 0 : if (shaper_profile->reference_count) {
322 : 0 : error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE;
323 : 0 : error->message = "profile in use";
324 : 0 : return -EINVAL;
325 : : }
326 : :
327 [ # # ]: 0 : TAILQ_REMOVE(&tm_conf->shaper_profile_list, shaper_profile, node);
328 : 0 : rte_free(shaper_profile);
329 : :
330 : 0 : return 0;
331 : : }
332 : :
333 : : static inline struct ixgbe_tm_node *
334 : 0 : ixgbe_tm_node_search(struct rte_eth_dev *dev, uint32_t node_id,
335 : : enum ixgbe_tm_node_type *node_type)
336 : : {
337 : : struct ixgbe_tm_conf *tm_conf =
338 : 0 : IXGBE_DEV_PRIVATE_TO_TM_CONF(dev->data->dev_private);
339 : : struct ixgbe_tm_node *tm_node;
340 : :
341 [ # # # # ]: 0 : if (tm_conf->root && tm_conf->root->id == node_id) {
342 : 0 : *node_type = IXGBE_TM_NODE_TYPE_PORT;
343 : 0 : return tm_conf->root;
344 : : }
345 : :
346 [ # # ]: 0 : TAILQ_FOREACH(tm_node, &tm_conf->tc_list, node) {
347 [ # # ]: 0 : if (tm_node->id == node_id) {
348 : 0 : *node_type = IXGBE_TM_NODE_TYPE_TC;
349 : 0 : return tm_node;
350 : : }
351 : : }
352 : :
353 [ # # ]: 0 : TAILQ_FOREACH(tm_node, &tm_conf->queue_list, node) {
354 [ # # ]: 0 : if (tm_node->id == node_id) {
355 : 0 : *node_type = IXGBE_TM_NODE_TYPE_QUEUE;
356 : 0 : return tm_node;
357 : : }
358 : : }
359 : :
360 : : return NULL;
361 : : }
362 : :
363 : : static void
364 [ # # ]: 0 : ixgbe_queue_base_nb_get(struct rte_eth_dev *dev, uint16_t tc_node_no,
365 : : uint16_t *base, uint16_t *nb)
366 : : {
367 : : uint8_t nb_tcs = ixgbe_tc_nb_get(dev);
368 : 0 : struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
369 : 0 : uint16_t vf_num = pci_dev->max_vfs;
370 : :
371 : 0 : *base = 0;
372 : 0 : *nb = 0;
373 : :
374 : : /* VT on */
375 [ # # ]: 0 : if (vf_num) {
376 : : /* no DCB */
377 [ # # ]: 0 : if (nb_tcs == 1) {
378 [ # # ]: 0 : if (vf_num >= RTE_ETH_32_POOLS) {
379 : 0 : *nb = 2;
380 : 0 : *base = vf_num * 2;
381 [ # # ]: 0 : } else if (vf_num >= RTE_ETH_16_POOLS) {
382 : 0 : *nb = 4;
383 : 0 : *base = vf_num * 4;
384 : : } else {
385 : 0 : *nb = 8;
386 : 0 : *base = vf_num * 8;
387 : : }
388 : : } else {
389 : : /* DCB */
390 : 0 : *nb = 1;
391 : 0 : *base = vf_num * nb_tcs + tc_node_no;
392 : : }
393 : : } else {
394 : : /* VT off */
395 [ # # ]: 0 : if (nb_tcs == RTE_ETH_8_TCS) {
396 [ # # # # : 0 : switch (tc_node_no) {
# # # #
# ]
397 : 0 : case 0:
398 : : *base = 0;
399 : 0 : *nb = 32;
400 : 0 : break;
401 : 0 : case 1:
402 : 0 : *base = 32;
403 : 0 : *nb = 32;
404 : 0 : break;
405 : 0 : case 2:
406 : 0 : *base = 64;
407 : 0 : *nb = 16;
408 : 0 : break;
409 : 0 : case 3:
410 : 0 : *base = 80;
411 : 0 : *nb = 16;
412 : 0 : break;
413 : 0 : case 4:
414 : 0 : *base = 96;
415 : 0 : *nb = 8;
416 : 0 : break;
417 : 0 : case 5:
418 : 0 : *base = 104;
419 : 0 : *nb = 8;
420 : 0 : break;
421 : 0 : case 6:
422 : 0 : *base = 112;
423 : 0 : *nb = 8;
424 : 0 : break;
425 : 0 : case 7:
426 : 0 : *base = 120;
427 : 0 : *nb = 8;
428 : 0 : break;
429 : : default:
430 : : return;
431 : : }
432 : : } else {
433 [ # # # # : 0 : switch (tc_node_no) {
# ]
434 : : /**
435 : : * If no VF and no DCB, only 64 queues can be used.
436 : : * This case also be covered by this "case 0".
437 : : */
438 : 0 : case 0:
439 : : *base = 0;
440 : 0 : *nb = 64;
441 : 0 : break;
442 : 0 : case 1:
443 : 0 : *base = 64;
444 : 0 : *nb = 32;
445 : 0 : break;
446 : 0 : case 2:
447 : 0 : *base = 96;
448 : 0 : *nb = 16;
449 : 0 : break;
450 : 0 : case 3:
451 : 0 : *base = 112;
452 : 0 : *nb = 16;
453 : 0 : break;
454 : : default:
455 : : return;
456 : : }
457 : : }
458 : : }
459 : : }
460 : :
461 : : static int
462 : 0 : ixgbe_node_param_check(struct rte_eth_dev *dev, uint32_t node_id,
463 : : uint32_t priority, uint32_t weight,
464 : : const struct rte_tm_node_params *params,
465 : : struct rte_tm_error *error)
466 : : {
467 [ # # ]: 0 : if (node_id == RTE_TM_NODE_ID_NULL) {
468 : 0 : error->type = RTE_TM_ERROR_TYPE_NODE_ID;
469 : 0 : error->message = "invalid node id";
470 : 0 : return -EINVAL;
471 : : }
472 : :
473 [ # # ]: 0 : if (priority) {
474 : 0 : error->type = RTE_TM_ERROR_TYPE_NODE_PRIORITY;
475 : 0 : error->message = "priority should be 0";
476 : 0 : return -EINVAL;
477 : : }
478 : :
479 [ # # ]: 0 : if (weight != 1) {
480 : 0 : error->type = RTE_TM_ERROR_TYPE_NODE_WEIGHT;
481 : 0 : error->message = "weight must be 1";
482 : 0 : return -EINVAL;
483 : : }
484 : :
485 : : /* not support shared shaper */
486 [ # # ]: 0 : if (params->shared_shaper_id) {
487 : 0 : error->type = RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_SHAPER_ID;
488 : 0 : error->message = "shared shaper not supported";
489 : 0 : return -EINVAL;
490 : : }
491 [ # # ]: 0 : if (params->n_shared_shapers) {
492 : 0 : error->type = RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_SHAPERS;
493 : 0 : error->message = "shared shaper not supported";
494 : 0 : return -EINVAL;
495 : : }
496 : :
497 : : /* for non-leaf node */
498 [ # # ]: 0 : if (node_id >= dev->data->nb_tx_queues) {
499 : : /* check the unsupported parameters */
500 [ # # ]: 0 : if (params->nonleaf.wfq_weight_mode) {
501 : 0 : error->type =
502 : : RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE;
503 : 0 : error->message = "WFQ not supported";
504 : 0 : return -EINVAL;
505 : : }
506 [ # # ]: 0 : if (params->nonleaf.n_sp_priorities != 1) {
507 : 0 : error->type =
508 : : RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SP_PRIORITIES;
509 : 0 : error->message = "SP priority not supported";
510 : 0 : return -EINVAL;
511 : : }
512 : :
513 : : return 0;
514 : : }
515 : :
516 : : /* for leaf node */
517 : : /* check the unsupported parameters */
518 [ # # ]: 0 : if (params->leaf.cman) {
519 : 0 : error->type = RTE_TM_ERROR_TYPE_NODE_PARAMS_CMAN;
520 : 0 : error->message = "Congestion management not supported";
521 : 0 : return -EINVAL;
522 : : }
523 [ # # ]: 0 : if (params->leaf.wred.wred_profile_id !=
524 : : RTE_TM_WRED_PROFILE_ID_NONE) {
525 : 0 : error->type =
526 : : RTE_TM_ERROR_TYPE_NODE_PARAMS_WRED_PROFILE_ID;
527 : 0 : error->message = "WRED not supported";
528 : 0 : return -EINVAL;
529 : : }
530 [ # # ]: 0 : if (params->leaf.wred.shared_wred_context_id) {
531 : 0 : error->type =
532 : : RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_WRED_CONTEXT_ID;
533 : 0 : error->message = "WRED not supported";
534 : 0 : return -EINVAL;
535 : : }
536 [ # # ]: 0 : if (params->leaf.wred.n_shared_wred_contexts) {
537 : 0 : error->type =
538 : : RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_WRED_CONTEXTS;
539 : 0 : error->message = "WRED not supported";
540 : 0 : return -EINVAL;
541 : : }
542 : :
543 : : return 0;
544 : : }
545 : :
546 : : /**
547 : : * Now the TC and queue configuration is controlled by DCB.
548 : : * We need check if the node configuration follows the DCB configuration.
549 : : * In the future, we may use TM to cover DCB.
550 : : */
551 : : static int
552 : 0 : ixgbe_node_add(struct rte_eth_dev *dev, uint32_t node_id,
553 : : uint32_t parent_node_id, uint32_t priority,
554 : : uint32_t weight, uint32_t level_id,
555 : : const struct rte_tm_node_params *params,
556 : : struct rte_tm_error *error)
557 : : {
558 : : struct ixgbe_tm_conf *tm_conf =
559 : 0 : IXGBE_DEV_PRIVATE_TO_TM_CONF(dev->data->dev_private);
560 : 0 : enum ixgbe_tm_node_type node_type = IXGBE_TM_NODE_TYPE_MAX;
561 : 0 : enum ixgbe_tm_node_type parent_node_type = IXGBE_TM_NODE_TYPE_MAX;
562 : : struct ixgbe_tm_shaper_profile *shaper_profile = NULL;
563 : : struct ixgbe_tm_node *tm_node;
564 : : struct ixgbe_tm_node *parent_node;
565 : : uint8_t nb_tcs;
566 : 0 : uint16_t q_base = 0;
567 : 0 : uint16_t q_nb = 0;
568 : : int ret;
569 : :
570 [ # # ]: 0 : if (!params || !error)
571 : : return -EINVAL;
572 : :
573 : : /* if already committed */
574 [ # # ]: 0 : if (tm_conf->committed) {
575 : 0 : error->type = RTE_TM_ERROR_TYPE_UNSPECIFIED;
576 : 0 : error->message = "already committed";
577 : 0 : return -EINVAL;
578 : : }
579 : :
580 : 0 : ret = ixgbe_node_param_check(dev, node_id, priority, weight,
581 : : params, error);
582 [ # # ]: 0 : if (ret)
583 : : return ret;
584 : :
585 : : /* check if the node ID is already used */
586 [ # # ]: 0 : if (ixgbe_tm_node_search(dev, node_id, &node_type)) {
587 : 0 : error->type = RTE_TM_ERROR_TYPE_NODE_ID;
588 : 0 : error->message = "node id already used";
589 : 0 : return -EINVAL;
590 : : }
591 : :
592 : : /* check the shaper profile id */
593 [ # # ]: 0 : if (params->shaper_profile_id != RTE_TM_SHAPER_PROFILE_ID_NONE) {
594 : : shaper_profile = ixgbe_shaper_profile_search(
595 : : dev, params->shaper_profile_id);
596 [ # # ]: 0 : if (!shaper_profile) {
597 : 0 : error->type =
598 : : RTE_TM_ERROR_TYPE_NODE_PARAMS_SHAPER_PROFILE_ID;
599 : 0 : error->message = "shaper profile not exist";
600 : 0 : return -EINVAL;
601 : : }
602 : : }
603 : :
604 : : /* root node if not have a parent */
605 [ # # ]: 0 : if (parent_node_id == RTE_TM_NODE_ID_NULL) {
606 : : /* check level */
607 [ # # ]: 0 : if (level_id != RTE_TM_NODE_LEVEL_ID_ANY &&
608 : : level_id > IXGBE_TM_NODE_TYPE_PORT) {
609 : 0 : error->type = RTE_TM_ERROR_TYPE_NODE_PARAMS;
610 : 0 : error->message = "Wrong level";
611 : 0 : return -EINVAL;
612 : : }
613 : :
614 : : /* obviously no more than one root */
615 [ # # ]: 0 : if (tm_conf->root) {
616 : 0 : error->type = RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID;
617 : 0 : error->message = "already have a root";
618 : 0 : return -EINVAL;
619 : : }
620 : :
621 : : /* add the root node */
622 : 0 : tm_node = rte_zmalloc("ixgbe_tm_node",
623 : : sizeof(struct ixgbe_tm_node),
624 : : 0);
625 [ # # ]: 0 : if (!tm_node)
626 : : return -ENOMEM;
627 : 0 : tm_node->id = node_id;
628 : 0 : tm_node->priority = priority;
629 : 0 : tm_node->weight = weight;
630 : 0 : tm_node->reference_count = 0;
631 : 0 : tm_node->no = 0;
632 : 0 : tm_node->parent = NULL;
633 : 0 : tm_node->shaper_profile = shaper_profile;
634 [ # # ]: 0 : memcpy(&tm_node->params, params,
635 : : sizeof(struct rte_tm_node_params));
636 : 0 : tm_conf->root = tm_node;
637 : :
638 : : /* increase the reference counter of the shaper profile */
639 [ # # ]: 0 : if (shaper_profile)
640 : 0 : shaper_profile->reference_count++;
641 : :
642 : 0 : return 0;
643 : : }
644 : :
645 : : /* TC or queue node */
646 : : /* check the parent node */
647 : 0 : parent_node = ixgbe_tm_node_search(dev, parent_node_id,
648 : : &parent_node_type);
649 [ # # ]: 0 : if (!parent_node) {
650 : 0 : error->type = RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID;
651 : 0 : error->message = "parent not exist";
652 : 0 : return -EINVAL;
653 : : }
654 [ # # ]: 0 : if (parent_node_type != IXGBE_TM_NODE_TYPE_PORT &&
655 : : parent_node_type != IXGBE_TM_NODE_TYPE_TC) {
656 : 0 : error->type = RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID;
657 : 0 : error->message = "parent is not port or TC";
658 : 0 : return -EINVAL;
659 : : }
660 : : /* check level */
661 [ # # ]: 0 : if (level_id != RTE_TM_NODE_LEVEL_ID_ANY &&
662 [ # # ]: 0 : level_id != (uint32_t)parent_node_type + 1) {
663 : 0 : error->type = RTE_TM_ERROR_TYPE_NODE_PARAMS;
664 : 0 : error->message = "Wrong level";
665 : 0 : return -EINVAL;
666 : : }
667 : :
668 : : /* check the node number */
669 [ # # ]: 0 : if (parent_node_type == IXGBE_TM_NODE_TYPE_PORT) {
670 : : /* check TC number */
671 : : nb_tcs = ixgbe_tc_nb_get(dev);
672 [ # # ]: 0 : if (tm_conf->nb_tc_node >= nb_tcs) {
673 : 0 : error->type = RTE_TM_ERROR_TYPE_NODE_ID;
674 : 0 : error->message = "too many TCs";
675 : 0 : return -EINVAL;
676 : : }
677 : : } else {
678 : : /* check queue number */
679 [ # # ]: 0 : if (tm_conf->nb_queue_node >= dev->data->nb_tx_queues) {
680 : 0 : error->type = RTE_TM_ERROR_TYPE_NODE_ID;
681 : 0 : error->message = "too many queues";
682 : 0 : return -EINVAL;
683 : : }
684 : :
685 : 0 : ixgbe_queue_base_nb_get(dev, parent_node->no, &q_base, &q_nb);
686 [ # # ]: 0 : if (parent_node->reference_count >= q_nb) {
687 : 0 : error->type = RTE_TM_ERROR_TYPE_NODE_ID;
688 : 0 : error->message = "too many queues than TC supported";
689 : 0 : return -EINVAL;
690 : : }
691 : :
692 : : /**
693 : : * check the node id.
694 : : * For queue, the node id means queue id.
695 : : */
696 [ # # ]: 0 : if (node_id >= dev->data->nb_tx_queues) {
697 : 0 : error->type = RTE_TM_ERROR_TYPE_NODE_ID;
698 : 0 : error->message = "too large queue id";
699 : 0 : return -EINVAL;
700 : : }
701 : : }
702 : :
703 : : /* add the TC or queue node */
704 : 0 : tm_node = rte_zmalloc("ixgbe_tm_node",
705 : : sizeof(struct ixgbe_tm_node),
706 : : 0);
707 [ # # ]: 0 : if (!tm_node)
708 : : return -ENOMEM;
709 : 0 : tm_node->id = node_id;
710 : 0 : tm_node->priority = priority;
711 : 0 : tm_node->weight = weight;
712 : 0 : tm_node->reference_count = 0;
713 : 0 : tm_node->parent = parent_node;
714 : 0 : tm_node->shaper_profile = shaper_profile;
715 [ # # ]: 0 : memcpy(&tm_node->params, params,
716 : : sizeof(struct rte_tm_node_params));
717 [ # # ]: 0 : if (parent_node_type == IXGBE_TM_NODE_TYPE_PORT) {
718 : 0 : tm_node->no = parent_node->reference_count;
719 : 0 : TAILQ_INSERT_TAIL(&tm_conf->tc_list,
720 : : tm_node, node);
721 : 0 : tm_conf->nb_tc_node++;
722 : : } else {
723 : 0 : tm_node->no = q_base + parent_node->reference_count;
724 : 0 : TAILQ_INSERT_TAIL(&tm_conf->queue_list,
725 : : tm_node, node);
726 : 0 : tm_conf->nb_queue_node++;
727 : : }
728 : 0 : tm_node->parent->reference_count++;
729 : :
730 : : /* increase the reference counter of the shaper profile */
731 [ # # ]: 0 : if (shaper_profile)
732 : 0 : shaper_profile->reference_count++;
733 : :
734 : : return 0;
735 : : }
736 : :
737 : : static int
738 : 0 : ixgbe_node_delete(struct rte_eth_dev *dev, uint32_t node_id,
739 : : struct rte_tm_error *error)
740 : : {
741 : : struct ixgbe_tm_conf *tm_conf =
742 : 0 : IXGBE_DEV_PRIVATE_TO_TM_CONF(dev->data->dev_private);
743 : 0 : enum ixgbe_tm_node_type node_type = IXGBE_TM_NODE_TYPE_MAX;
744 : : struct ixgbe_tm_node *tm_node;
745 : :
746 [ # # ]: 0 : if (!error)
747 : : return -EINVAL;
748 : :
749 : : /* if already committed */
750 [ # # ]: 0 : if (tm_conf->committed) {
751 : 0 : error->type = RTE_TM_ERROR_TYPE_UNSPECIFIED;
752 : 0 : error->message = "already committed";
753 : 0 : return -EINVAL;
754 : : }
755 : :
756 [ # # ]: 0 : if (node_id == RTE_TM_NODE_ID_NULL) {
757 : 0 : error->type = RTE_TM_ERROR_TYPE_NODE_ID;
758 : 0 : error->message = "invalid node id";
759 : 0 : return -EINVAL;
760 : : }
761 : :
762 : : /* check the if the node id exists */
763 : 0 : tm_node = ixgbe_tm_node_search(dev, node_id, &node_type);
764 [ # # ]: 0 : if (!tm_node) {
765 : 0 : error->type = RTE_TM_ERROR_TYPE_NODE_ID;
766 : 0 : error->message = "no such node";
767 : 0 : return -EINVAL;
768 : : }
769 : :
770 : : /* the node should have no child */
771 [ # # ]: 0 : if (tm_node->reference_count) {
772 : 0 : error->type = RTE_TM_ERROR_TYPE_NODE_ID;
773 : 0 : error->message =
774 : : "cannot delete a node which has children";
775 : 0 : return -EINVAL;
776 : : }
777 : :
778 : : /* root node */
779 [ # # ]: 0 : if (node_type == IXGBE_TM_NODE_TYPE_PORT) {
780 [ # # ]: 0 : if (tm_node->shaper_profile)
781 : 0 : tm_node->shaper_profile->reference_count--;
782 : 0 : rte_free(tm_node);
783 : 0 : tm_conf->root = NULL;
784 : 0 : return 0;
785 : : }
786 : :
787 : : /* TC or queue node */
788 [ # # ]: 0 : if (tm_node->shaper_profile)
789 : 0 : tm_node->shaper_profile->reference_count--;
790 : 0 : tm_node->parent->reference_count--;
791 [ # # ]: 0 : if (node_type == IXGBE_TM_NODE_TYPE_TC) {
792 [ # # ]: 0 : TAILQ_REMOVE(&tm_conf->tc_list, tm_node, node);
793 : 0 : tm_conf->nb_tc_node--;
794 : : } else {
795 [ # # ]: 0 : TAILQ_REMOVE(&tm_conf->queue_list, tm_node, node);
796 : 0 : tm_conf->nb_queue_node--;
797 : : }
798 : 0 : rte_free(tm_node);
799 : :
800 : 0 : return 0;
801 : : }
802 : :
803 : : static int
804 : 0 : ixgbe_node_type_get(struct rte_eth_dev *dev, uint32_t node_id,
805 : : int *is_leaf, struct rte_tm_error *error)
806 : : {
807 : 0 : enum ixgbe_tm_node_type node_type = IXGBE_TM_NODE_TYPE_MAX;
808 : : struct ixgbe_tm_node *tm_node;
809 : :
810 [ # # ]: 0 : if (!is_leaf || !error)
811 : : return -EINVAL;
812 : :
813 [ # # ]: 0 : if (node_id == RTE_TM_NODE_ID_NULL) {
814 : 0 : error->type = RTE_TM_ERROR_TYPE_NODE_ID;
815 : 0 : error->message = "invalid node id";
816 : 0 : return -EINVAL;
817 : : }
818 : :
819 : : /* check if the node id exists */
820 : 0 : tm_node = ixgbe_tm_node_search(dev, node_id, &node_type);
821 [ # # ]: 0 : if (!tm_node) {
822 : 0 : error->type = RTE_TM_ERROR_TYPE_NODE_ID;
823 : 0 : error->message = "no such node";
824 : 0 : return -EINVAL;
825 : : }
826 : :
827 [ # # ]: 0 : if (node_type == IXGBE_TM_NODE_TYPE_QUEUE)
828 : 0 : *is_leaf = true;
829 : : else
830 : 0 : *is_leaf = false;
831 : :
832 : : return 0;
833 : : }
834 : :
835 : : static int
836 : 0 : ixgbe_level_capabilities_get(struct rte_eth_dev *dev,
837 : : uint32_t level_id,
838 : : struct rte_tm_level_capabilities *cap,
839 : : struct rte_tm_error *error)
840 : : {
841 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
842 : :
843 [ # # ]: 0 : if (!cap || !error)
844 : : return -EINVAL;
845 : :
846 [ # # ]: 0 : if (level_id >= IXGBE_TM_NODE_TYPE_MAX) {
847 : 0 : error->type = RTE_TM_ERROR_TYPE_LEVEL_ID;
848 : 0 : error->message = "too deep level";
849 : 0 : return -EINVAL;
850 : : }
851 : :
852 : : /* root node */
853 [ # # ]: 0 : if (level_id == IXGBE_TM_NODE_TYPE_PORT) {
854 : 0 : cap->n_nodes_max = 1;
855 : 0 : cap->n_nodes_nonleaf_max = 1;
856 : 0 : cap->n_nodes_leaf_max = 0;
857 [ # # ]: 0 : } else if (level_id == IXGBE_TM_NODE_TYPE_TC) {
858 : : /* TC */
859 : 0 : cap->n_nodes_max = IXGBE_DCB_MAX_TRAFFIC_CLASS;
860 : 0 : cap->n_nodes_nonleaf_max = IXGBE_DCB_MAX_TRAFFIC_CLASS;
861 : 0 : cap->n_nodes_leaf_max = 0;
862 : : } else {
863 : : /* queue */
864 : 0 : cap->n_nodes_max = hw->mac.max_tx_queues;
865 : 0 : cap->n_nodes_nonleaf_max = 0;
866 : 0 : cap->n_nodes_leaf_max = hw->mac.max_tx_queues;
867 : : }
868 : :
869 : 0 : cap->non_leaf_nodes_identical = true;
870 : 0 : cap->leaf_nodes_identical = true;
871 : :
872 [ # # ]: 0 : if (level_id != IXGBE_TM_NODE_TYPE_QUEUE) {
873 : 0 : cap->nonleaf.shaper_private_supported = true;
874 : 0 : cap->nonleaf.shaper_private_dual_rate_supported = false;
875 : 0 : cap->nonleaf.shaper_private_rate_min = 0;
876 : : /* 10Gbps -> 1.25GBps */
877 : 0 : cap->nonleaf.shaper_private_rate_max = 1250000000ull;
878 : 0 : cap->nonleaf.shaper_private_packet_mode_supported = 0;
879 : 0 : cap->nonleaf.shaper_private_byte_mode_supported = 1;
880 : 0 : cap->nonleaf.shaper_shared_n_max = 0;
881 : 0 : cap->nonleaf.shaper_shared_packet_mode_supported = 0;
882 : 0 : cap->nonleaf.shaper_shared_byte_mode_supported = 0;
883 [ # # ]: 0 : if (level_id == IXGBE_TM_NODE_TYPE_PORT)
884 : 0 : cap->nonleaf.sched_n_children_max =
885 : : IXGBE_DCB_MAX_TRAFFIC_CLASS;
886 : : else
887 : 0 : cap->nonleaf.sched_n_children_max =
888 : 0 : hw->mac.max_tx_queues;
889 : 0 : cap->nonleaf.sched_sp_n_priorities_max = 1;
890 : 0 : cap->nonleaf.sched_wfq_n_children_per_group_max = 0;
891 : 0 : cap->nonleaf.sched_wfq_n_groups_max = 0;
892 : 0 : cap->nonleaf.sched_wfq_weight_max = 1;
893 : 0 : cap->nonleaf.sched_wfq_packet_mode_supported = 0;
894 : 0 : cap->nonleaf.sched_wfq_byte_mode_supported = 0;
895 : 0 : cap->nonleaf.stats_mask = 0;
896 : :
897 : 0 : return 0;
898 : : }
899 : :
900 : : /* queue node */
901 : 0 : cap->leaf.shaper_private_supported = true;
902 : 0 : cap->leaf.shaper_private_dual_rate_supported = false;
903 : 0 : cap->leaf.shaper_private_rate_min = 0;
904 : : /* 10Gbps -> 1.25GBps */
905 : 0 : cap->leaf.shaper_private_rate_max = 1250000000ull;
906 : 0 : cap->leaf.shaper_private_packet_mode_supported = 0;
907 : 0 : cap->leaf.shaper_private_byte_mode_supported = 1;
908 : 0 : cap->leaf.shaper_shared_n_max = 0;
909 : 0 : cap->leaf.shaper_shared_packet_mode_supported = 0;
910 : 0 : cap->leaf.shaper_shared_byte_mode_supported = 0;
911 : 0 : cap->leaf.cman_head_drop_supported = false;
912 : 0 : cap->leaf.cman_wred_context_private_supported = true;
913 : 0 : cap->leaf.cman_wred_context_shared_n_max = 0;
914 : 0 : cap->leaf.stats_mask = 0;
915 : :
916 : 0 : return 0;
917 : : }
918 : :
919 : : static int
920 : 0 : ixgbe_node_capabilities_get(struct rte_eth_dev *dev,
921 : : uint32_t node_id,
922 : : struct rte_tm_node_capabilities *cap,
923 : : struct rte_tm_error *error)
924 : : {
925 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
926 : 0 : enum ixgbe_tm_node_type node_type = IXGBE_TM_NODE_TYPE_MAX;
927 : : struct ixgbe_tm_node *tm_node;
928 : :
929 [ # # ]: 0 : if (!cap || !error)
930 : : return -EINVAL;
931 : :
932 [ # # ]: 0 : if (node_id == RTE_TM_NODE_ID_NULL) {
933 : 0 : error->type = RTE_TM_ERROR_TYPE_NODE_ID;
934 : 0 : error->message = "invalid node id";
935 : 0 : return -EINVAL;
936 : : }
937 : :
938 : : /* check if the node id exists */
939 : 0 : tm_node = ixgbe_tm_node_search(dev, node_id, &node_type);
940 [ # # ]: 0 : if (!tm_node) {
941 : 0 : error->type = RTE_TM_ERROR_TYPE_NODE_ID;
942 : 0 : error->message = "no such node";
943 : 0 : return -EINVAL;
944 : : }
945 : :
946 : 0 : cap->shaper_private_supported = true;
947 : 0 : cap->shaper_private_dual_rate_supported = false;
948 : 0 : cap->shaper_private_rate_min = 0;
949 : : /* 10Gbps -> 1.25GBps */
950 : 0 : cap->shaper_private_rate_max = 1250000000ull;
951 : 0 : cap->shaper_private_packet_mode_supported = 0;
952 : 0 : cap->shaper_private_byte_mode_supported = 1;
953 : 0 : cap->shaper_shared_n_max = 0;
954 : 0 : cap->shaper_shared_packet_mode_supported = 0;
955 : 0 : cap->shaper_shared_byte_mode_supported = 0;
956 : :
957 [ # # ]: 0 : if (node_type == IXGBE_TM_NODE_TYPE_QUEUE) {
958 : 0 : cap->leaf.cman_head_drop_supported = false;
959 : 0 : cap->leaf.cman_wred_context_private_supported = true;
960 : 0 : cap->leaf.cman_wred_context_shared_n_max = 0;
961 : : } else {
962 [ # # ]: 0 : if (node_type == IXGBE_TM_NODE_TYPE_PORT)
963 : 0 : cap->nonleaf.sched_n_children_max =
964 : : IXGBE_DCB_MAX_TRAFFIC_CLASS;
965 : : else
966 : 0 : cap->nonleaf.sched_n_children_max =
967 : 0 : hw->mac.max_tx_queues;
968 : 0 : cap->nonleaf.sched_sp_n_priorities_max = 1;
969 : 0 : cap->nonleaf.sched_wfq_n_children_per_group_max = 0;
970 : 0 : cap->nonleaf.sched_wfq_n_groups_max = 0;
971 : 0 : cap->nonleaf.sched_wfq_weight_max = 1;
972 : 0 : cap->nonleaf.sched_wfq_packet_mode_supported = 0;
973 : 0 : cap->nonleaf.sched_wfq_byte_mode_supported = 0;
974 : : }
975 : :
976 : 0 : cap->stats_mask = 0;
977 : :
978 : 0 : return 0;
979 : : }
980 : :
981 : : static int
982 : 0 : ixgbe_hierarchy_commit(struct rte_eth_dev *dev,
983 : : int clear_on_fail,
984 : : struct rte_tm_error *error)
985 : : {
986 : : struct ixgbe_tm_conf *tm_conf =
987 : 0 : IXGBE_DEV_PRIVATE_TO_TM_CONF(dev->data->dev_private);
988 : : struct ixgbe_tm_node *tm_node;
989 : : uint64_t bw;
990 : : int ret;
991 : :
992 [ # # ]: 0 : if (!error)
993 : : return -EINVAL;
994 : :
995 : : /* check the setting */
996 [ # # ]: 0 : if (!tm_conf->root)
997 : 0 : goto done;
998 : :
999 : : /* not support port max bandwidth yet */
1000 [ # # ]: 0 : if (tm_conf->root->shaper_profile &&
1001 [ # # ]: 0 : tm_conf->root->shaper_profile->profile.peak.rate) {
1002 : 0 : error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE;
1003 : 0 : error->message = "no port max bandwidth";
1004 : 0 : goto fail_clear;
1005 : : }
1006 : :
1007 : : /* HW not support TC max bandwidth */
1008 [ # # ]: 0 : TAILQ_FOREACH(tm_node, &tm_conf->tc_list, node) {
1009 [ # # ]: 0 : if (tm_node->shaper_profile &&
1010 [ # # ]: 0 : tm_node->shaper_profile->profile.peak.rate) {
1011 : 0 : error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE;
1012 : 0 : error->message = "no TC max bandwidth";
1013 : 0 : goto fail_clear;
1014 : : }
1015 : : }
1016 : :
1017 : : /* queue max bandwidth */
1018 [ # # ]: 0 : TAILQ_FOREACH(tm_node, &tm_conf->queue_list, node) {
1019 [ # # ]: 0 : if (tm_node->shaper_profile)
1020 : 0 : bw = tm_node->shaper_profile->profile.peak.rate;
1021 : : else
1022 : : bw = 0;
1023 [ # # ]: 0 : if (bw) {
1024 : : /* interpret Bps to Mbps */
1025 : 0 : bw = bw * 8 / 1000 / 1000;
1026 : 0 : ret = ixgbe_set_queue_rate_limit(dev, tm_node->no, bw);
1027 [ # # ]: 0 : if (ret) {
1028 : 0 : error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE;
1029 : 0 : error->message =
1030 : : "failed to set queue max bandwidth";
1031 : 0 : goto fail_clear;
1032 : : }
1033 : : }
1034 : : }
1035 : :
1036 : 0 : done:
1037 : 0 : tm_conf->committed = true;
1038 : 0 : return 0;
1039 : :
1040 : 0 : fail_clear:
1041 : : /* clear all the traffic manager configuration */
1042 [ # # ]: 0 : if (clear_on_fail) {
1043 : 0 : ixgbe_tm_conf_uninit(dev);
1044 : 0 : ixgbe_tm_conf_init(dev);
1045 : : }
1046 : : return -EINVAL;
1047 : : }
|