Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright 2020-2026 NXP
3 : : */
4 : :
5 : : #include <rte_ethdev.h>
6 : : #include <rte_malloc.h>
7 : : #include <rte_tm_driver.h>
8 : :
9 : : #include "dpaa2_ethdev.h"
10 : : #include "dpaa2_pmd_logs.h"
11 : : #include <dpaa2_hw_dpio.h>
12 : :
13 : : #define DPAA2_SHAPER_MIN_RATE 0
14 : : #define DPAA2_SHAPER_MAX_RATE 107374182400ull
15 : : #define DPAA2_WEIGHT_MAX 24701
16 : : #define DPAA2_PKT_ADJUST_LEN_MIN 0
17 : : #define DPAA2_PKT_ADJUST_LEN_MAX 0x7ff
18 : :
19 : : static inline uint32_t dpaa2_get_burst_max(struct dpaa2_dev_priv *priv)
20 : : {
21 [ # # ]: 0 : if (dpaa2_dev_cmp_dpni_ver(priv, 8, 7) >= 0)
22 [ # # # # ]: 0 : return (dpaa2_svr_family == SVR_LX2160A) ? 229375 : 0xF7FF;
23 : :
24 : : return 0xF7FF;
25 : : }
26 : :
27 : : int
28 : 0 : dpaa2_tm_init(struct rte_eth_dev *dev)
29 : : {
30 : 0 : struct dpaa2_dev_priv *priv = dev->data->dev_private;
31 : :
32 : 0 : LIST_INIT(&priv->shaper_profiles);
33 : 0 : LIST_INIT(&priv->nodes);
34 : :
35 : 0 : return 0;
36 : : }
37 : :
38 : 0 : void dpaa2_tm_deinit(struct rte_eth_dev *dev)
39 : : {
40 : 0 : struct dpaa2_dev_priv *priv = dev->data->dev_private;
41 : 0 : struct dpaa2_tm_shaper_profile *profile =
42 : : LIST_FIRST(&priv->shaper_profiles);
43 : 0 : struct dpaa2_tm_node *node = LIST_FIRST(&priv->nodes);
44 : :
45 [ # # ]: 0 : while (profile) {
46 : 0 : struct dpaa2_tm_shaper_profile *next = LIST_NEXT(profile, next);
47 : :
48 [ # # ]: 0 : LIST_REMOVE(profile, next);
49 : 0 : rte_free(profile);
50 : : profile = next;
51 : : }
52 : :
53 [ # # ]: 0 : while (node) {
54 : 0 : struct dpaa2_tm_node *next = LIST_NEXT(node, next);
55 : :
56 [ # # ]: 0 : LIST_REMOVE(node, next);
57 : 0 : rte_free(node);
58 : : node = next;
59 : : }
60 : 0 : }
61 : :
62 : : static struct dpaa2_tm_node *
63 : : dpaa2_node_from_id(struct dpaa2_dev_priv *priv, uint32_t node_id)
64 : : {
65 : : struct dpaa2_tm_node *node;
66 : :
67 [ # # # # : 0 : LIST_FOREACH(node, &priv->nodes, next)
# # # # #
# # # ]
68 [ # # # # : 0 : if (node->id == node_id)
# # # # #
# # # ]
69 : : return node;
70 : :
71 : : return NULL;
72 : : }
73 : :
74 : : static int
75 : 0 : dpaa2_capabilities_get(struct rte_eth_dev *dev,
76 : : struct rte_tm_capabilities *cap,
77 : : struct rte_tm_error *error)
78 : : {
79 : 0 : struct dpaa2_dev_priv *priv = dev->data->dev_private;
80 : :
81 [ # # ]: 0 : if (!cap)
82 : 0 : return -rte_tm_error_set(error, EINVAL,
83 : : RTE_TM_ERROR_TYPE_UNSPECIFIED,
84 : : NULL, "Capabilities are NULL\n");
85 : :
86 : : memset(cap, 0, sizeof(*cap));
87 : :
88 : : /* root node(port) + channels + txqs number, assuming each TX
89 : : * Queue is mapped to each TC
90 : : */
91 : 0 : cap->n_nodes_max = 1 + priv->num_channels + dev->data->nb_tx_queues;
92 : 0 : cap->n_levels_max = MAX_LEVEL;
93 : 0 : cap->non_leaf_nodes_identical = 1;
94 : 0 : cap->leaf_nodes_identical = 1;
95 : :
96 : 0 : cap->shaper_n_max = 1 + priv->num_channels; /* LNI + channels */
97 : 0 : cap->shaper_private_n_max = 1 + priv->num_channels;
98 : 0 : cap->shaper_private_dual_rate_n_max = 1 + priv->num_channels;
99 : : cap->shaper_private_rate_min = DPAA2_SHAPER_MIN_RATE;
100 : 0 : cap->shaper_private_rate_max = DPAA2_SHAPER_MAX_RATE;
101 : : cap->shaper_pkt_length_adjust_min = DPAA2_PKT_ADJUST_LEN_MIN;
102 : 0 : cap->shaper_pkt_length_adjust_max = DPAA2_PKT_ADJUST_LEN_MAX;
103 : :
104 [ # # ]: 0 : if (priv->num_channels > DPNI_MAX_TC)
105 : 0 : cap->sched_n_children_max = priv->num_channels;
106 : : else
107 : 0 : cap->sched_n_children_max = DPNI_MAX_TC;
108 : :
109 : 0 : cap->sched_sp_n_priorities_max = DPNI_MAX_TC;
110 : 0 : cap->sched_wfq_n_children_per_group_max = DPNI_MAX_TC;
111 : 0 : cap->sched_wfq_n_groups_max = 2;
112 : 0 : cap->sched_wfq_weight_max = DPAA2_WEIGHT_MAX / 100;
113 : 0 : cap->stats_mask = RTE_TM_STATS_N_PKTS | RTE_TM_STATS_N_BYTES;
114 : :
115 : 0 : return 0;
116 : : }
117 : :
118 : : static int
119 : 0 : dpaa2_level_capabilities_get(struct rte_eth_dev *dev,
120 : : uint32_t level_id,
121 : : struct rte_tm_level_capabilities *cap,
122 : : struct rte_tm_error *error)
123 : : {
124 : 0 : struct dpaa2_dev_priv *priv = dev->data->dev_private;
125 : :
126 [ # # ]: 0 : if (!cap)
127 : 0 : return -rte_tm_error_set(error, EINVAL,
128 : : RTE_TM_ERROR_TYPE_UNSPECIFIED,
129 : : NULL, NULL);
130 : :
131 : : memset(cap, 0, sizeof(*cap));
132 : :
133 [ # # ]: 0 : if (level_id > QUEUE_LEVEL)
134 : 0 : return -rte_tm_error_set(error, EINVAL,
135 : : RTE_TM_ERROR_TYPE_LEVEL_ID,
136 : : NULL, "Wrong level id\n");
137 : :
138 [ # # ]: 0 : if (level_id == LNI_LEVEL) { /* Root node (LNI) */
139 : 0 : cap->n_nodes_max = 1;
140 : 0 : cap->n_nodes_nonleaf_max = 1;
141 : 0 : cap->non_leaf_nodes_identical = 1;
142 : :
143 : 0 : cap->nonleaf.shaper_private_supported = 1;
144 : 0 : cap->nonleaf.shaper_private_dual_rate_supported = 1;
145 : : cap->nonleaf.shaper_private_rate_min = DPAA2_SHAPER_MIN_RATE;
146 : 0 : cap->nonleaf.shaper_private_rate_max = DPAA2_SHAPER_MAX_RATE;
147 : :
148 : 0 : cap->nonleaf.sched_n_children_max = priv->num_channels; /* no. of channels */
149 : 0 : cap->nonleaf.sched_sp_n_priorities_max = 1;
150 : 0 : cap->nonleaf.sched_wfq_n_children_per_group_max = 1;
151 : 0 : cap->nonleaf.sched_wfq_n_groups_max = 1;
152 : 0 : cap->nonleaf.sched_wfq_weight_max = 1;
153 : 0 : cap->nonleaf.stats_mask = RTE_TM_STATS_N_PKTS |
154 : : RTE_TM_STATS_N_BYTES;
155 [ # # ]: 0 : } else if (level_id == CHANNEL_LEVEL) { /* channels */
156 : 0 : cap->n_nodes_max = priv->num_channels;
157 : 0 : cap->n_nodes_nonleaf_max = priv->num_channels;
158 : : cap->n_nodes_leaf_max = 0;
159 : 0 : cap->non_leaf_nodes_identical = 1;
160 : :
161 : 0 : cap->nonleaf.shaper_private_supported = 1;
162 : 0 : cap->nonleaf.shaper_private_dual_rate_supported = 1;
163 : : cap->nonleaf.shaper_private_rate_min = DPAA2_SHAPER_MIN_RATE;
164 : 0 : cap->nonleaf.shaper_private_rate_max = DPAA2_SHAPER_MAX_RATE;
165 : :
166 : : /* no. of class queues per channel */
167 : 0 : cap->nonleaf.sched_n_children_max = priv->num_tx_tc;
168 : 0 : cap->nonleaf.sched_sp_n_priorities_max = priv->num_tx_tc;
169 : 0 : cap->nonleaf.sched_wfq_n_children_per_group_max = priv->num_tx_tc;
170 : 0 : cap->nonleaf.sched_wfq_n_groups_max = 2;
171 : 0 : cap->nonleaf.sched_wfq_weight_max = DPAA2_WEIGHT_MAX / 100;
172 : : } else { /* leaf nodes */
173 : : /* queues per channels * channel */
174 : 0 : cap->n_nodes_max = priv->num_tx_tc * priv->num_channels;
175 : 0 : cap->n_nodes_leaf_max = priv->num_tx_tc * priv->num_channels;
176 : 0 : cap->leaf_nodes_identical = 1;
177 : :
178 : : cap->leaf.shaper_private_supported = 0;
179 : 0 : cap->leaf.stats_mask = RTE_TM_STATS_N_PKTS |
180 : : RTE_TM_STATS_N_BYTES;
181 : : }
182 : :
183 : : return 0;
184 : : }
185 : :
186 : : static int
187 : 0 : dpaa2_node_capabilities_get(struct rte_eth_dev *dev, uint32_t node_id,
188 : : struct rte_tm_node_capabilities *cap,
189 : : struct rte_tm_error *error)
190 : : {
191 : : struct dpaa2_tm_node *node;
192 : 0 : struct dpaa2_dev_priv *priv = dev->data->dev_private;
193 : :
194 [ # # ]: 0 : if (!cap)
195 : 0 : return -rte_tm_error_set(error, EINVAL,
196 : : RTE_TM_ERROR_TYPE_UNSPECIFIED,
197 : : NULL, NULL);
198 : :
199 : : memset(cap, 0, sizeof(*cap));
200 : :
201 : : node = dpaa2_node_from_id(priv, node_id);
202 [ # # ]: 0 : if (!node)
203 : 0 : return -rte_tm_error_set(error, ENODEV,
204 : : RTE_TM_ERROR_TYPE_NODE_ID,
205 : : NULL, "Node id does not exist\n");
206 : :
207 [ # # ]: 0 : if (node->level_id == LNI_LEVEL) {
208 : 0 : cap->shaper_private_supported = 1;
209 : 0 : cap->shaper_private_dual_rate_supported = 1;
210 : : cap->shaper_private_rate_min = DPAA2_SHAPER_MIN_RATE;
211 : 0 : cap->shaper_private_rate_max = DPAA2_SHAPER_MAX_RATE;
212 : :
213 : 0 : cap->nonleaf.sched_n_children_max = priv->num_channels;
214 : 0 : cap->nonleaf.sched_sp_n_priorities_max = 1;
215 : 0 : cap->nonleaf.sched_wfq_n_children_per_group_max = 1;
216 : 0 : cap->nonleaf.sched_wfq_n_groups_max = 1;
217 : 0 : cap->nonleaf.sched_wfq_weight_max = 1;
218 : 0 : cap->stats_mask = RTE_TM_STATS_N_PKTS |
219 : : RTE_TM_STATS_N_BYTES;
220 [ # # ]: 0 : } else if (node->level_id == CHANNEL_LEVEL) {
221 : 0 : cap->shaper_private_supported = 1;
222 : 0 : cap->shaper_private_dual_rate_supported = 1;
223 : : cap->shaper_private_rate_min = DPAA2_SHAPER_MIN_RATE;
224 : 0 : cap->shaper_private_rate_max = DPAA2_SHAPER_MAX_RATE;
225 : :
226 : 0 : cap->nonleaf.sched_n_children_max = priv->num_tx_tc;
227 : 0 : cap->nonleaf.sched_sp_n_priorities_max = priv->num_tx_tc;
228 : 0 : cap->nonleaf.sched_wfq_n_children_per_group_max = priv->num_tx_tc;
229 : 0 : cap->nonleaf.sched_wfq_n_groups_max = 2;
230 : 0 : cap->nonleaf.sched_wfq_weight_max = DPAA2_WEIGHT_MAX / 100;
231 : : } else {
232 : 0 : cap->stats_mask = RTE_TM_STATS_N_PKTS |
233 : : RTE_TM_STATS_N_BYTES;
234 : : }
235 : :
236 : : return 0;
237 : : }
238 : :
239 : : static int
240 : 0 : dpaa2_node_type_get(struct rte_eth_dev *dev, uint32_t node_id, int *is_leaf,
241 : : struct rte_tm_error *error)
242 : : {
243 : 0 : struct dpaa2_dev_priv *priv = dev->data->dev_private;
244 : : struct dpaa2_tm_node *node;
245 : :
246 [ # # ]: 0 : if (!is_leaf)
247 : 0 : return -rte_tm_error_set(error, EINVAL,
248 : : RTE_TM_ERROR_TYPE_UNSPECIFIED,
249 : : NULL, NULL);
250 : :
251 : : node = dpaa2_node_from_id(priv, node_id);
252 [ # # ]: 0 : if (!node)
253 : 0 : return -rte_tm_error_set(error, ENODEV,
254 : : RTE_TM_ERROR_TYPE_NODE_ID,
255 : : NULL, "Node id does not exist\n");
256 : :
257 : 0 : *is_leaf = node->type == LEAF_NODE ? 1 : 0;
258 : :
259 : 0 : return 0;
260 : : }
261 : :
262 : : static struct dpaa2_tm_shaper_profile *
263 : : dpaa2_shaper_profile_from_id(struct dpaa2_dev_priv *priv,
264 : : uint32_t shaper_profile_id)
265 : : {
266 : : struct dpaa2_tm_shaper_profile *profile;
267 : :
268 [ # # # # : 0 : LIST_FOREACH(profile, &priv->shaper_profiles, next)
# # ]
269 [ # # # # : 0 : if (profile->id == shaper_profile_id)
# # ]
270 : : return profile;
271 : :
272 : : return NULL;
273 : : }
274 : :
275 : : static int
276 : 0 : dpaa2_shaper_profile_add(struct rte_eth_dev *dev, uint32_t shaper_profile_id,
277 : : const struct rte_tm_shaper_params *params,
278 : : struct rte_tm_error *error)
279 : : {
280 : 0 : struct dpaa2_dev_priv *priv = dev->data->dev_private;
281 : : struct dpaa2_tm_shaper_profile *profile;
282 : :
283 [ # # ]: 0 : if (!params)
284 : 0 : return -rte_tm_error_set(error, EINVAL,
285 : : RTE_TM_ERROR_TYPE_UNSPECIFIED,
286 : : NULL, NULL);
287 [ # # ]: 0 : if (params->committed.rate > DPAA2_SHAPER_MAX_RATE)
288 : 0 : return -rte_tm_error_set(error, EINVAL,
289 : : RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE,
290 : : NULL, "committed rate is out of range\n");
291 : :
292 [ # # # # ]: 0 : if (params->committed.size > dpaa2_get_burst_max(priv))
293 : 0 : return -rte_tm_error_set(error, EINVAL,
294 : : RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE,
295 : : NULL, "committed size is out of range\n");
296 : :
297 [ # # ]: 0 : if (params->peak.rate > DPAA2_SHAPER_MAX_RATE)
298 : 0 : return -rte_tm_error_set(error, EINVAL,
299 : : RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE,
300 : : NULL, "Peak rate is out of range\n");
301 : :
302 [ # # # # ]: 0 : if (params->peak.size > dpaa2_get_burst_max(priv))
303 : 0 : return -rte_tm_error_set(error, EINVAL,
304 : : RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE,
305 : : NULL, "Peak size is out of range\n");
306 : :
307 [ # # ]: 0 : if (shaper_profile_id == RTE_TM_SHAPER_PROFILE_ID_NONE)
308 : 0 : return -rte_tm_error_set(error, EINVAL,
309 : : RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID,
310 : : NULL, "Wrong shaper profile id\n");
311 : :
312 [ # # ]: 0 : if (params->pkt_length_adjust > DPAA2_PKT_ADJUST_LEN_MAX ||
313 : : params->pkt_length_adjust < DPAA2_PKT_ADJUST_LEN_MIN)
314 : 0 : return -rte_tm_error_set(error, EINVAL,
315 : : RTE_TM_ERROR_TYPE_CAPABILITIES,
316 : : NULL,
317 : : "Not supported pkt adjust length\n");
318 : :
319 : : profile = dpaa2_shaper_profile_from_id(priv, shaper_profile_id);
320 [ # # ]: 0 : if (profile)
321 : 0 : return -rte_tm_error_set(error, EEXIST,
322 : : RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID,
323 : : NULL, "Profile id already exists\n");
324 : :
325 : 0 : profile = rte_zmalloc_socket(NULL, sizeof(*profile), 0,
326 : 0 : rte_socket_id());
327 [ # # ]: 0 : if (!profile)
328 : 0 : return -rte_tm_error_set(error, ENOMEM,
329 : : RTE_TM_ERROR_TYPE_UNSPECIFIED,
330 : : NULL, NULL);
331 : :
332 [ # # ]: 0 : profile->id = shaper_profile_id;
333 : : rte_memcpy(&profile->params, params, sizeof(profile->params));
334 : :
335 [ # # ]: 0 : LIST_INSERT_HEAD(&priv->shaper_profiles, profile, next);
336 : :
337 : 0 : return 0;
338 : : }
339 : :
340 : : static int
341 : 0 : dpaa2_shaper_profile_delete(struct rte_eth_dev *dev, uint32_t shaper_profile_id,
342 : : struct rte_tm_error *error)
343 : : {
344 : 0 : struct dpaa2_dev_priv *priv = dev->data->dev_private;
345 : : struct dpaa2_tm_shaper_profile *profile;
346 : :
347 : : profile = dpaa2_shaper_profile_from_id(priv, shaper_profile_id);
348 [ # # ]: 0 : if (!profile)
349 : 0 : return -rte_tm_error_set(error, ENODEV,
350 : : RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID,
351 : : NULL, "Profile id does not exist\n");
352 : :
353 [ # # ]: 0 : if (profile->refcnt)
354 : 0 : return -rte_tm_error_set(error, EPERM,
355 : : RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID,
356 : : NULL, "Profile is used\n");
357 : :
358 [ # # ]: 0 : LIST_REMOVE(profile, next);
359 : 0 : rte_free(profile);
360 : :
361 : 0 : return 0;
362 : : }
363 : :
364 : : static int
365 : 0 : dpaa2_node_check_params(struct rte_eth_dev *dev, uint32_t node_id,
366 : : __rte_unused uint32_t priority, uint32_t weight,
367 : : uint32_t level_id,
368 : : const struct rte_tm_node_params *params,
369 : : struct rte_tm_error *error)
370 : : {
371 [ # # ]: 0 : if (node_id == RTE_TM_NODE_ID_NULL)
372 : 0 : return -rte_tm_error_set(error, EINVAL, RTE_TM_NODE_ID_NULL,
373 : : NULL, "Node id is invalid\n");
374 : :
375 [ # # ]: 0 : if (weight > DPAA2_WEIGHT_MAX)
376 : 0 : return -rte_tm_error_set(error, EINVAL,
377 : : RTE_TM_ERROR_TYPE_NODE_WEIGHT,
378 : : NULL, "Weight is out of range\n");
379 : :
380 [ # # ]: 0 : if (level_id > QUEUE_LEVEL)
381 : 0 : return -rte_tm_error_set(error, EINVAL,
382 : : RTE_TM_ERROR_TYPE_LEVEL_ID,
383 : : NULL, "Wrong level id\n");
384 : :
385 [ # # ]: 0 : if (!params)
386 : 0 : return -rte_tm_error_set(error, EINVAL,
387 : : RTE_TM_ERROR_TYPE_UNSPECIFIED,
388 : : NULL, NULL);
389 : :
390 [ # # ]: 0 : if (params->shared_shaper_id)
391 : 0 : return -rte_tm_error_set(error, EINVAL,
392 : : RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_SHAPER_ID,
393 : : NULL, "Shared shaper is not supported\n");
394 : :
395 [ # # ]: 0 : if (params->n_shared_shapers)
396 : 0 : return -rte_tm_error_set(error, EINVAL,
397 : : RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_SHAPERS,
398 : : NULL, "Shared shaper is not supported\n");
399 : :
400 : : /* verify non leaf nodes settings */
401 [ # # ]: 0 : if (node_id >= dev->data->nb_tx_queues) {
402 [ # # ]: 0 : if (params->nonleaf.wfq_weight_mode)
403 : 0 : return -rte_tm_error_set(error, EINVAL,
404 : : RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE,
405 : : NULL, "WFQ weight mode is not supported\n");
406 : : } else {
407 [ # # ]: 0 : if (params->shaper_profile_id != RTE_TM_SHAPER_PROFILE_ID_NONE)
408 : 0 : return -rte_tm_error_set(error, EINVAL,
409 : : RTE_TM_ERROR_TYPE_NODE_PARAMS_SHAPER_PROFILE_ID,
410 : : NULL, "Private shaper not supported on leaf\n");
411 : : }
412 : :
413 : : /* check leaf node */
414 [ # # ]: 0 : if (level_id == QUEUE_LEVEL) {
415 [ # # ]: 0 : if (params->leaf.cman != RTE_TM_CMAN_TAIL_DROP)
416 : 0 : return -rte_tm_error_set(error, ENODEV,
417 : : RTE_TM_ERROR_TYPE_NODE_PARAMS_CMAN,
418 : : NULL, "Only taildrop is supported\n");
419 [ # # ]: 0 : if (params->stats_mask & ~(RTE_TM_STATS_N_PKTS |
420 : : RTE_TM_STATS_N_BYTES))
421 : 0 : return -rte_tm_error_set(error, EINVAL,
422 : : RTE_TM_ERROR_TYPE_NODE_PARAMS_STATS,
423 : : NULL,
424 : : "Requested port stats are not supported\n");
425 [ # # ]: 0 : } else if (level_id == LNI_LEVEL) {
426 [ # # ]: 0 : if (params->stats_mask & ~(RTE_TM_STATS_N_PKTS |
427 : : RTE_TM_STATS_N_BYTES))
428 : 0 : return -rte_tm_error_set(error, EINVAL,
429 : : RTE_TM_ERROR_TYPE_NODE_PARAMS_STATS,
430 : : NULL,
431 : : "Requested port stats are not supported\n");
432 : : }
433 : :
434 : : return 0;
435 : : }
436 : :
437 : : static int
438 : 0 : dpaa2_node_add(struct rte_eth_dev *dev, uint32_t node_id,
439 : : uint32_t parent_node_id, uint32_t priority, uint32_t weight,
440 : : uint32_t level_id, const struct rte_tm_node_params *params,
441 : : struct rte_tm_error *error)
442 : : {
443 : 0 : struct dpaa2_dev_priv *priv = dev->data->dev_private;
444 : : struct dpaa2_tm_shaper_profile *profile = NULL;
445 : : struct dpaa2_tm_node *node, *parent = NULL;
446 : : int ret;
447 : :
448 : : if (0/* If device is started*/)
449 : : return -rte_tm_error_set(error, EPERM,
450 : : RTE_TM_ERROR_TYPE_UNSPECIFIED,
451 : : NULL, "Port is already started\n");
452 : :
453 : 0 : ret = dpaa2_node_check_params(dev, node_id, priority, weight, level_id,
454 : : params, error);
455 [ # # ]: 0 : if (ret)
456 : : return ret;
457 : :
458 [ # # ]: 0 : if (params->shaper_profile_id != RTE_TM_SHAPER_PROFILE_ID_NONE) {
459 : : profile = dpaa2_shaper_profile_from_id(priv,
460 : : params->shaper_profile_id);
461 [ # # ]: 0 : if (!profile)
462 : 0 : return -rte_tm_error_set(error, ENODEV,
463 : : RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID,
464 : : NULL, "Shaper id does not exist\n");
465 : : }
466 [ # # ]: 0 : if (parent_node_id == RTE_TM_NODE_ID_NULL) {
467 [ # # ]: 0 : LIST_FOREACH(node, &priv->nodes, next) {
468 [ # # ]: 0 : if (node->level_id != LNI_LEVEL)
469 : : continue;
470 : :
471 : 0 : return -rte_tm_error_set(error, EINVAL,
472 : : RTE_TM_ERROR_TYPE_UNSPECIFIED,
473 : : NULL, "Root node exists\n");
474 : : }
475 : : } else {
476 : : parent = dpaa2_node_from_id(priv, parent_node_id);
477 [ # # ]: 0 : if (!parent)
478 : 0 : return -rte_tm_error_set(error, EINVAL,
479 : : RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID,
480 : : NULL, "Parent node id not exist\n");
481 : : }
482 : :
483 : : node = dpaa2_node_from_id(priv, node_id);
484 [ # # ]: 0 : if (node)
485 : 0 : return -rte_tm_error_set(error, ENODEV,
486 : : RTE_TM_ERROR_TYPE_NODE_ID,
487 : : NULL, "Node id already exists\n");
488 : :
489 : 0 : node = rte_zmalloc_socket(NULL, sizeof(*node), 0, rte_socket_id());
490 [ # # ]: 0 : if (!node)
491 : 0 : return -rte_tm_error_set(error, ENOMEM,
492 : : RTE_TM_ERROR_TYPE_UNSPECIFIED,
493 : : NULL, NULL);
494 : :
495 : 0 : node->id = node_id;
496 : :
497 [ # # ]: 0 : if (node_id > dev->data->nb_tx_queues)
498 : 0 : node->type = NON_LEAF_NODE;
499 : : else
500 : 0 : node->type = LEAF_NODE;
501 : :
502 : 0 : node->level_id = level_id;
503 [ # # ]: 0 : if (node->level_id == CHANNEL_LEVEL) {
504 [ # # ]: 0 : if (priv->channel_inuse < priv->num_channels) {
505 : 0 : node->channel_id = priv->channel_inuse;
506 : 0 : priv->channel_inuse++;
507 : : } else {
508 : 0 : DPAA2_PMD_ERR("error no channel id available");
509 : : }
510 : : }
511 : :
512 [ # # ]: 0 : if (parent) {
513 : 0 : node->parent = parent;
514 : 0 : parent->refcnt++;
515 : : }
516 : :
517 : : /* TODO: add check if refcnt is more than supported children */
518 : :
519 [ # # ]: 0 : if (profile) {
520 : 0 : node->profile = profile;
521 : 0 : profile->refcnt++;
522 : : }
523 : :
524 : 0 : node->weight = weight;
525 : 0 : node->priority = priority;
526 : 0 : node->stats_mask = params->stats_mask;
527 : :
528 [ # # ]: 0 : LIST_INSERT_HEAD(&priv->nodes, node, next);
529 : :
530 : 0 : return 0;
531 : : }
532 : :
533 : : static int
534 : 0 : dpaa2_node_delete(struct rte_eth_dev *dev, uint32_t node_id,
535 : : struct rte_tm_error *error)
536 : : {
537 : 0 : struct dpaa2_dev_priv *priv = dev->data->dev_private;
538 : : struct dpaa2_tm_node *node;
539 : :
540 : : /* XXX: update it */
541 : : if (0) {
542 : : return -rte_tm_error_set(error, EPERM,
543 : : RTE_TM_ERROR_TYPE_UNSPECIFIED,
544 : : NULL, "Port is already started\n");
545 : : }
546 : :
547 : : node = dpaa2_node_from_id(priv, node_id);
548 [ # # ]: 0 : if (!node)
549 : 0 : return -rte_tm_error_set(error, ENODEV,
550 : : RTE_TM_ERROR_TYPE_NODE_ID,
551 : : NULL, "Node id does not exist\n");
552 : :
553 [ # # ]: 0 : if (node->refcnt)
554 : 0 : return -rte_tm_error_set(error, EPERM,
555 : : RTE_TM_ERROR_TYPE_NODE_ID,
556 : : NULL, "Node id is used\n");
557 : :
558 [ # # ]: 0 : if (node->parent)
559 : 0 : node->parent->refcnt--;
560 : :
561 [ # # ]: 0 : if (node->profile)
562 : 0 : node->profile->refcnt--;
563 : :
564 [ # # ]: 0 : LIST_REMOVE(node, next);
565 : 0 : rte_free(node);
566 : :
567 : 0 : return 0;
568 : : }
569 : :
570 : : static int
571 : 0 : dpaa2_tm_configure_queue(struct rte_eth_dev *dev, struct dpaa2_tm_node *node)
572 : : {
573 : : int ret = 0;
574 : : uint32_t tc_id;
575 : : uint8_t flow_id, options = 0;
576 : : struct dpni_queue tx_flow_cfg;
577 : : struct dpni_queue_id qid;
578 : 0 : struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
579 [ # # ]: 0 : struct dpaa2_dev_priv *priv = dev->data->dev_private;
580 : : struct dpaa2_queue *dpaa2_q;
581 : : uint64_t iova;
582 : :
583 : : memset(&tx_flow_cfg, 0, sizeof(struct dpni_queue));
584 : 0 : dpaa2_q = (struct dpaa2_queue *)dev->data->tx_queues[node->id];
585 : 0 : tc_id = node->parent->tc_id;
586 : 0 : node->parent->tc_id++;
587 : : flow_id = 0;
588 : :
589 [ # # ]: 0 : if (!dpaa2_q) {
590 : 0 : DPAA2_PMD_ERR("Queue is not configured for node = %d",
591 : : node->id);
592 : 0 : return -ENOMEM;
593 : : }
594 : :
595 : 0 : DPAA2_PMD_DEBUG("tc_id = %d, channel = %d", tc_id,
596 : : node->parent->channel_id);
597 : 0 : ret = dpni_set_queue(dpni, CMD_PRI_LOW, priv->token, DPNI_QUEUE_TX,
598 : 0 : ((node->parent->channel_id << 8) | tc_id),
599 : : flow_id, options, &tx_flow_cfg);
600 [ # # ]: 0 : if (ret) {
601 : 0 : DPAA2_PMD_ERR("Set the TC[%d].ch[%d].TX flow[%d] (err=%d)",
602 : : tc_id, node->parent->channel_id, flow_id,
603 : : ret);
604 : 0 : return ret;
605 : : }
606 : :
607 : 0 : dpaa2_q->flow_id = flow_id;
608 : 0 : dpaa2_q->tc_index = tc_id;
609 : :
610 : 0 : ret = dpni_get_queue(dpni, CMD_PRI_LOW, priv->token,
611 : : DPNI_QUEUE_TX,
612 : 0 : ((node->parent->channel_id << 8) | dpaa2_q->tc_index),
613 : : dpaa2_q->flow_id, &tx_flow_cfg, &qid);
614 [ # # ]: 0 : if (ret) {
615 : 0 : DPAA2_PMD_ERR("Error in getting LFQID err=%d", ret);
616 : 0 : return ret;
617 : : }
618 : 0 : dpaa2_q->fqid = qid.fqid;
619 : :
620 : : /* setting taildrop through congestion notification */
621 : 0 : struct dpni_congestion_notification_cfg cong_notif_cfg = {0};
622 : :
623 : 0 : cong_notif_cfg.units = DPNI_CONGESTION_UNIT_FRAMES;
624 : 0 : cong_notif_cfg.threshold_entry = dpaa2_q->nb_desc;
625 : : /* Notify that the queue is not congested when the data in
626 : : * the queue is below this thershold.(90% of value)
627 : : */
628 : 0 : cong_notif_cfg.threshold_exit = (dpaa2_q->nb_desc * 9) / 10;
629 : : cong_notif_cfg.message_ctx = 0;
630 : :
631 : 0 : iova = DPAA2_VADDR_TO_IOVA_AND_CHECK(dpaa2_q->cscn,
632 : : sizeof(struct qbman_result));
633 [ # # ]: 0 : if (iova == RTE_BAD_IOVA) {
634 : 0 : DPAA2_PMD_ERR("No IOMMU map for cscn(%p)", dpaa2_q->cscn);
635 : 0 : return -ENOBUFS;
636 : : }
637 : 0 : cong_notif_cfg.message_iova = iova;
638 : 0 : cong_notif_cfg.dest_cfg.dest_type = DPNI_DEST_NONE;
639 : 0 : cong_notif_cfg.notification_mode =
640 : : DPNI_CONG_OPT_WRITE_MEM_ON_ENTER |
641 : : DPNI_CONG_OPT_WRITE_MEM_ON_EXIT |
642 : : DPNI_CONG_OPT_COHERENT_WRITE;
643 : 0 : cong_notif_cfg.cg_point = DPNI_CP_QUEUE;
644 : :
645 : 0 : ret = dpni_set_congestion_notification(dpni, CMD_PRI_LOW,
646 : 0 : priv->token, DPNI_QUEUE_TX,
647 : 0 : ((node->parent->channel_id << 8) | tc_id),
648 : : &cong_notif_cfg);
649 [ # # ]: 0 : if (ret) {
650 : 0 : DPAA2_PMD_ERR("Error in setting tx congestion notification: "
651 : : "err=%d", ret);
652 : 0 : return -ret;
653 : : }
654 : 0 : dpaa2_q->tm_sw_td = true;
655 : :
656 : 0 : return 0;
657 : : }
658 : :
659 : : static void
660 : 0 : dpaa2_tm_sort_and_configure(struct rte_eth_dev *dev,
661 : : struct dpaa2_tm_node **nodes, int n)
662 : : {
663 : : struct dpaa2_tm_node *temp_node;
664 : : int i;
665 : :
666 [ # # ]: 0 : if (n == 1) {
667 : 0 : DPAA2_PMD_DEBUG("node id = %d, priority = %d, index = %d",
668 : : nodes[n - 1]->id, nodes[n - 1]->priority,
669 : : n - 1);
670 : 0 : dpaa2_tm_configure_queue(dev, nodes[n - 1]);
671 : 0 : return;
672 : : }
673 : :
674 [ # # ]: 0 : for (i = 0; i < n - 1; i++) {
675 [ # # ]: 0 : if (nodes[i]->priority > nodes[i + 1]->priority) {
676 : : temp_node = nodes[i];
677 : 0 : nodes[i] = nodes[i + 1];
678 : 0 : nodes[i + 1] = temp_node;
679 : : }
680 : : }
681 : 0 : dpaa2_tm_sort_and_configure(dev, nodes, n - 1);
682 : :
683 : 0 : DPAA2_PMD_DEBUG("node id = %d, priority = %d, index = %d",
684 : : nodes[n - 1]->id, nodes[n - 1]->priority,
685 : : n - 1);
686 : 0 : dpaa2_tm_configure_queue(dev, nodes[n - 1]);
687 : : }
688 : :
689 : : static int
690 : 0 : dpaa2_hierarchy_commit(struct rte_eth_dev *dev, int clear_on_fail,
691 : : struct rte_tm_error *error)
692 : : {
693 : 0 : struct dpaa2_dev_priv *priv = dev->data->dev_private;
694 : : struct dpaa2_tm_node *node;
695 : : struct dpaa2_tm_node *leaf_node, *temp_leaf_node, *channel_node;
696 : 0 : struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
697 : : int ret, t;
698 : : bool conf_schedule = false;
699 : :
700 : : /* Populate TCs */
701 [ # # ]: 0 : LIST_FOREACH(channel_node, &priv->nodes, next) {
702 : : struct dpaa2_tm_node *nodes[DPNI_MAX_TC];
703 : : int i = 0;
704 : :
705 [ # # ]: 0 : if (channel_node->level_id != CHANNEL_LEVEL)
706 : 0 : continue;
707 : :
708 [ # # ]: 0 : LIST_FOREACH(leaf_node, &priv->nodes, next) {
709 [ # # ]: 0 : if (leaf_node->level_id == LNI_LEVEL ||
710 : : leaf_node->level_id == CHANNEL_LEVEL)
711 : 0 : continue;
712 : :
713 [ # # ]: 0 : if (leaf_node->parent == channel_node) {
714 [ # # ]: 0 : if (i >= DPNI_MAX_TC) {
715 : : ret = -rte_tm_error_set(error, EINVAL,
716 : : RTE_TM_ERROR_TYPE_UNSPECIFIED, NULL,
717 : : "More children than supported\n");
718 : 0 : goto out;
719 : : }
720 : 0 : nodes[i++] = leaf_node;
721 : : }
722 : : }
723 [ # # ]: 0 : if (i > 0) {
724 : 0 : DPAA2_PMD_DEBUG("Configure queues");
725 : 0 : dpaa2_tm_sort_and_configure(dev, nodes, i);
726 : : }
727 : : }
728 : :
729 : : /* Shaping */
730 [ # # ]: 0 : LIST_FOREACH(node, &priv->nodes, next) {
731 [ # # ]: 0 : if (node->type == NON_LEAF_NODE) {
732 [ # # ]: 0 : if (!node->profile)
733 : 0 : continue;
734 : : struct dpni_tx_shaping_cfg tx_cr_shaper, tx_er_shaper;
735 : : uint32_t param = 0;
736 : :
737 : 0 : tx_cr_shaper.max_burst_size =
738 : 0 : node->profile->params.committed.size;
739 : 0 : tx_cr_shaper.rate_limit =
740 : 0 : (node->profile->params.committed.rate /
741 : : (1024 * 1024)) * 8;
742 : 0 : tx_er_shaper.max_burst_size =
743 : 0 : node->profile->params.peak.size;
744 : 0 : tx_er_shaper.rate_limit =
745 : 0 : (node->profile->params.peak.rate / (1024 * 1024)) * 8;
746 : : /* root node */
747 [ # # ]: 0 : if (node->parent == NULL) {
748 : 0 : DPAA2_PMD_DEBUG("LNI S.rate = %u, burst =%u",
749 : : tx_cr_shaper.rate_limit,
750 : : tx_cr_shaper.max_burst_size);
751 : : param = 0x2;
752 : 0 : param |= node->profile->params.pkt_length_adjust << 16;
753 : : } else {
754 : 0 : DPAA2_PMD_DEBUG("Channel = %d S.rate = %u",
755 : : node->channel_id,
756 : : tx_cr_shaper.rate_limit);
757 : 0 : param = (node->channel_id << 8);
758 : : }
759 : 0 : ret = dpni_set_tx_shaping(dpni, 0, priv->token,
760 : : &tx_cr_shaper, &tx_er_shaper, param);
761 [ # # ]: 0 : if (ret) {
762 : : ret = -rte_tm_error_set(error, EINVAL,
763 : : RTE_TM_ERROR_TYPE_SHAPER_PROFILE, NULL,
764 : : "Error in setting Shaping\n");
765 : 0 : goto out;
766 : : }
767 : 0 : continue;
768 : : }
769 : : }
770 : :
771 [ # # ]: 0 : LIST_FOREACH(channel_node, &priv->nodes, next) {
772 [ # # ]: 0 : int wfq_grp = 0, is_wfq_grp = 0, conf[priv->nb_tx_queues];
773 : : struct dpni_tx_priorities_cfg prio_cfg;
774 : :
775 : : memset(&prio_cfg, 0, sizeof(prio_cfg));
776 : : memset(conf, 0, sizeof(conf));
777 : :
778 : : /* Process for each channel */
779 [ # # ]: 0 : if (channel_node->level_id != CHANNEL_LEVEL)
780 : 0 : continue;
781 : :
782 : : conf_schedule = false;
783 [ # # ]: 0 : LIST_FOREACH(leaf_node, &priv->nodes, next) {
784 : : struct dpaa2_queue *leaf_dpaa2_q;
785 : : uint8_t leaf_tc_id;
786 : :
787 [ # # ]: 0 : if (leaf_node->level_id == LNI_LEVEL ||
788 : : leaf_node->level_id == CHANNEL_LEVEL)
789 : 0 : continue;
790 : :
791 : : /* level 2, all leaf nodes */
792 [ # # ]: 0 : if (leaf_node->id >= dev->data->nb_tx_queues) {
793 : : ret = -rte_tm_error_set(error, EINVAL,
794 : : RTE_TM_ERROR_TYPE_NODE_ID, NULL,
795 : : "Not enough txqs configured\n");
796 : 0 : goto out;
797 : : }
798 : :
799 [ # # ]: 0 : if (conf[leaf_node->id])
800 : 0 : continue;
801 : :
802 [ # # ]: 0 : if (leaf_node->parent != channel_node)
803 : 0 : continue;
804 : :
805 : : conf_schedule = true;
806 : 0 : leaf_dpaa2_q = (struct dpaa2_queue *)dev->data->tx_queues[leaf_node->id];
807 : 0 : leaf_tc_id = leaf_dpaa2_q->tc_index;
808 : : /* Process sibling leaf nodes */
809 [ # # ]: 0 : LIST_FOREACH(temp_leaf_node, &priv->nodes, next) {
810 [ # # ]: 0 : if (temp_leaf_node->id == leaf_node->id ||
811 [ # # # # ]: 0 : temp_leaf_node->level_id == LNI_LEVEL ||
812 : : temp_leaf_node->level_id == CHANNEL_LEVEL)
813 : 0 : continue;
814 : :
815 [ # # ]: 0 : if (temp_leaf_node->parent != channel_node)
816 : 0 : continue;
817 : :
818 [ # # ]: 0 : if (conf[temp_leaf_node->id])
819 : 0 : continue;
820 : :
821 [ # # ]: 0 : if (leaf_node->priority == temp_leaf_node->priority) {
822 : : struct dpaa2_queue *temp_leaf_dpaa2_q;
823 : : uint8_t temp_leaf_tc_id;
824 : :
825 : 0 : temp_leaf_dpaa2_q = (struct dpaa2_queue *)
826 : 0 : dev->data->tx_queues[temp_leaf_node->id];
827 : 0 : temp_leaf_tc_id = temp_leaf_dpaa2_q->tc_index;
828 [ # # ]: 0 : if (wfq_grp == 0) {
829 : 0 : prio_cfg.tc_sched[temp_leaf_tc_id].mode =
830 : : DPNI_TX_SCHED_WEIGHTED_A;
831 : : /* DPAA2 support weight in multiple of 100 */
832 : 0 : prio_cfg.tc_sched[temp_leaf_tc_id].delta_bandwidth =
833 : 0 : temp_leaf_node->weight * 100;
834 [ # # ]: 0 : } else if (wfq_grp == 1) {
835 : 0 : prio_cfg.tc_sched[temp_leaf_tc_id].mode =
836 : : DPNI_TX_SCHED_WEIGHTED_B;
837 : 0 : prio_cfg.tc_sched[temp_leaf_tc_id].delta_bandwidth =
838 : 0 : temp_leaf_node->weight * 100;
839 : : } else {
840 : : ret = -rte_tm_error_set(error, EINVAL,
841 : : RTE_TM_ERROR_TYPE_UNSPECIFIED, NULL,
842 : : "Only 2 WFQ Groups are supported\n");
843 : 0 : goto out;
844 : : }
845 : : is_wfq_grp = 1;
846 : : }
847 : 0 : conf[temp_leaf_node->id] = 1;
848 : : }
849 [ # # ]: 0 : if (is_wfq_grp) {
850 [ # # ]: 0 : if (wfq_grp == 0) {
851 : 0 : prio_cfg.tc_sched[leaf_tc_id].mode =
852 : : DPNI_TX_SCHED_WEIGHTED_A;
853 : 0 : prio_cfg.tc_sched[leaf_tc_id].delta_bandwidth =
854 : 0 : leaf_node->weight * 100;
855 : 0 : prio_cfg.prio_group_A = leaf_node->priority;
856 [ # # ]: 0 : } else if (wfq_grp == 1) {
857 : 0 : prio_cfg.tc_sched[leaf_tc_id].mode =
858 : : DPNI_TX_SCHED_WEIGHTED_B;
859 : 0 : prio_cfg.tc_sched[leaf_tc_id].delta_bandwidth =
860 : 0 : leaf_node->weight * 100;
861 : 0 : prio_cfg.prio_group_B = leaf_node->priority;
862 : : }
863 : 0 : wfq_grp++;
864 : : is_wfq_grp = 0;
865 : : }
866 : 0 : conf[leaf_node->id] = 1;
867 : : }
868 [ # # ]: 0 : if (!conf_schedule)
869 : 0 : continue;
870 : :
871 [ # # ]: 0 : if (wfq_grp > 1) {
872 : 0 : prio_cfg.separate_groups = 1;
873 [ # # ]: 0 : if (prio_cfg.prio_group_B < prio_cfg.prio_group_A) {
874 : : prio_cfg.prio_group_A = 0;
875 : 0 : prio_cfg.prio_group_B = 1;
876 : : } else {
877 : : prio_cfg.prio_group_A = 1;
878 : 0 : prio_cfg.prio_group_B = 0;
879 : : }
880 : : }
881 : :
882 : 0 : prio_cfg.prio_group_A = 1;
883 : 0 : prio_cfg.channel_idx = channel_node->channel_id;
884 : 0 : DPAA2_PMD_DEBUG("########################################");
885 : 0 : DPAA2_PMD_DEBUG("Channel idx = %d", prio_cfg.channel_idx);
886 [ # # ]: 0 : for (t = 0; t < DPNI_MAX_TC; t++)
887 : 0 : DPAA2_PMD_DEBUG("tc = %d mode = %d, delta = %d", t,
888 : : prio_cfg.tc_sched[t].mode,
889 : : prio_cfg.tc_sched[t].delta_bandwidth);
890 : :
891 : 0 : DPAA2_PMD_DEBUG("prioritya = %d, priorityb = %d, separate grps"
892 : : " = %d", prio_cfg.prio_group_A,
893 : : prio_cfg.prio_group_B, prio_cfg.separate_groups);
894 : 0 : ret = dpni_set_tx_priorities(dpni, 0, priv->token, &prio_cfg);
895 [ # # ]: 0 : if (ret) {
896 : : ret = -rte_tm_error_set(error, EINVAL,
897 : : RTE_TM_ERROR_TYPE_UNSPECIFIED, NULL,
898 : : "Scheduling Failed\n");
899 : 0 : goto out;
900 : : }
901 : : }
902 : : return 0;
903 : :
904 : 0 : out:
905 [ # # ]: 0 : if (clear_on_fail) {
906 : 0 : dpaa2_tm_deinit(dev);
907 : 0 : dpaa2_tm_init(dev);
908 : : }
909 : :
910 : : return ret;
911 : : }
912 : :
913 : : static int
914 : 0 : dpaa2_node_stats_read(struct rte_eth_dev *dev, uint32_t node_id,
915 : : struct rte_tm_node_stats *stats, uint64_t *stats_mask,
916 : : int clear, struct rte_tm_error *error)
917 : : {
918 : 0 : struct dpaa2_dev_priv *priv = dev->data->dev_private;
919 : : struct dpaa2_tm_node *node;
920 : 0 : struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
921 : : union dpni_statistics value;
922 : : int ret = 0;
923 : :
924 : : node = dpaa2_node_from_id(priv, node_id);
925 [ # # ]: 0 : if (!node)
926 : 0 : return -rte_tm_error_set(error, ENODEV,
927 : : RTE_TM_ERROR_TYPE_NODE_ID,
928 : : NULL, "Node id does not exist\n");
929 : :
930 [ # # ]: 0 : if (stats_mask)
931 : 0 : *stats_mask = node->stats_mask;
932 : :
933 [ # # ]: 0 : if (!stats)
934 : : return 0;
935 : :
936 : : memset(stats, 0, sizeof(*stats));
937 : : memset(&value, 0, sizeof(union dpni_statistics));
938 : :
939 [ # # ]: 0 : if (node->level_id == LNI_LEVEL) {
940 : : uint8_t page1 = 1;
941 : :
942 : 0 : ret = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
943 : : page1, 0, &value);
944 [ # # ]: 0 : if (ret)
945 [ # # ]: 0 : return -rte_tm_error_set(error, -ret,
946 : : RTE_TM_ERROR_TYPE_UNSPECIFIED, NULL,
947 : : "Failed to read port statistics\n");
948 : :
949 [ # # ]: 0 : if (node->stats_mask & RTE_TM_STATS_N_PKTS)
950 : 0 : stats->n_pkts = value.page_1.egress_all_frames;
951 : :
952 [ # # ]: 0 : if (node->stats_mask & RTE_TM_STATS_N_BYTES)
953 : 0 : stats->n_bytes = value.page_1.egress_all_bytes;
954 : :
955 [ # # ]: 0 : if (clear) {
956 : 0 : ret = dpni_reset_statistics(dpni, CMD_PRI_LOW, priv->token);
957 [ # # ]: 0 : return -rte_tm_error_set(error, -ret,
958 : : RTE_TM_ERROR_TYPE_UNSPECIFIED, NULL,
959 : : "Failed to reset port statistics\n");
960 : : }
961 [ # # ]: 0 : } else if (node->level_id == QUEUE_LEVEL) {
962 : : uint8_t page3 = 3;
963 : : struct dpaa2_queue *dpaa2_q;
964 : 0 : dpaa2_q = (struct dpaa2_queue *)dev->data->tx_queues[node->id];
965 : :
966 : 0 : ret = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
967 : : page3,
968 : 0 : (node->parent->channel_id << 8 |
969 : 0 : dpaa2_q->tc_index), &value);
970 [ # # ]: 0 : if (ret)
971 [ # # ]: 0 : return -rte_tm_error_set(error, -ret,
972 : : RTE_TM_ERROR_TYPE_UNSPECIFIED, NULL,
973 : : "Failed to read queue statistics\n");
974 : :
975 [ # # ]: 0 : if (node->stats_mask & RTE_TM_STATS_N_PKTS)
976 : 0 : stats->n_pkts = value.page_3.ceetm_dequeue_frames;
977 [ # # ]: 0 : if (node->stats_mask & RTE_TM_STATS_N_BYTES)
978 : 0 : stats->n_bytes = value.page_3.ceetm_dequeue_bytes;
979 : : } else {
980 : 0 : return -rte_tm_error_set(error, -1,
981 : : RTE_TM_ERROR_TYPE_UNSPECIFIED, NULL,
982 : : "Failed to read channel statistics\n");
983 : : }
984 : :
985 : : return 0;
986 : : }
987 : :
988 : : const struct rte_tm_ops dpaa2_tm_ops = {
989 : : .node_type_get = dpaa2_node_type_get,
990 : : .capabilities_get = dpaa2_capabilities_get,
991 : : .level_capabilities_get = dpaa2_level_capabilities_get,
992 : : .node_capabilities_get = dpaa2_node_capabilities_get,
993 : : .shaper_profile_add = dpaa2_shaper_profile_add,
994 : : .shaper_profile_delete = dpaa2_shaper_profile_delete,
995 : : .node_add = dpaa2_node_add,
996 : : .node_delete = dpaa2_node_delete,
997 : : .hierarchy_commit = dpaa2_hierarchy_commit,
998 : : .node_stats_read = dpaa2_node_stats_read,
999 : : };
|