Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright 2020 Mellanox Technologies, Ltd
3 : : */
4 : :
5 : : #include <stdint.h>
6 : : #include <rte_malloc.h>
7 : : #include <mlx5_malloc.h>
8 : : #include <rte_ring.h>
9 : : #include <mlx5_devx_cmds.h>
10 : : #include <rte_cycles.h>
11 : : #include <rte_eal_paging.h>
12 : : #include <rte_thread.h>
13 : :
14 : : #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H)
15 : :
16 : : #include "mlx5_utils.h"
17 : : #include "mlx5_hws_cnt.h"
18 : :
19 : : #define HWS_CNT_CACHE_SZ_DEFAULT 511
20 : : #define HWS_CNT_CACHE_PRELOAD_DEFAULT 254
21 : : #define HWS_CNT_CACHE_FETCH_DEFAULT 254
22 : : #define HWS_CNT_CACHE_THRESHOLD_DEFAULT 254
23 : : #define HWS_CNT_ALLOC_FACTOR_DEFAULT 20
24 : :
25 : : static int
26 [ # # ]: 0 : __hws_cnt_id_load(struct mlx5_hws_cnt_pool *cpool)
27 : : {
28 : : uint32_t cnt_num = mlx5_hws_cnt_pool_get_size(cpool);
29 : : uint32_t iidx;
30 : : cnt_id_t *cnt_arr = NULL;
31 : :
32 : 0 : cnt_arr = mlx5_malloc(MLX5_MEM_ANY | MLX5_MEM_ZERO,
33 : : cnt_num * sizeof(cnt_id_t), 0, SOCKET_ID_ANY);
34 [ # # ]: 0 : if (cnt_arr == NULL) {
35 : 0 : DRV_LOG(ERR, "Failed to allocate counter ID array: %zu bytes.",
36 : : cnt_num * sizeof(cnt_id_t));
37 : 0 : return -ENOMEM;
38 : : }
39 : : /*
40 : : * Counter ID order is important for tracking the max number of in used
41 : : * counter for querying, which means counter internal index order must
42 : : * be from zero to the number user configured, i.e: 0 - 8000000.
43 : : * Need to load counter ID in this order into the cache firstly,
44 : : * and then the global free list.
45 : : * In the end, user fetch the counter from minimal to the maximum.
46 : : */
47 [ # # ]: 0 : for (iidx = 0; iidx < cnt_num; iidx++) {
48 : : cnt_id_t cnt_id = mlx5_hws_cnt_id_gen(cpool, iidx);
49 : 0 : cnt_arr[iidx] = cnt_id;
50 : : }
51 [ # # # # : 0 : rte_ring_enqueue_bulk_elem(cpool->free_list, cnt_arr,
# ]
52 : : sizeof(cnt_id_t), cnt_num, NULL);
53 : 0 : mlx5_free(cnt_arr);
54 : 0 : return 0;
55 : : }
56 : :
57 : : static void
58 : 0 : __mlx5_hws_cnt_svc(struct mlx5_dev_ctx_shared *sh,
59 : : struct mlx5_hws_cnt_pool *cpool)
60 : : {
61 : 0 : struct rte_ring *reset_list = cpool->wait_reset_list;
62 : 0 : struct rte_ring *reuse_list = cpool->reuse_list;
63 : : uint32_t reset_cnt_num;
64 : : struct rte_ring_zc_data zcdr = {0};
65 : : struct rte_ring_zc_data zcdu = {0};
66 : : uint32_t ret __rte_unused;
67 : :
68 : : reset_cnt_num = rte_ring_count(reset_list);
69 : 0 : mlx5_aso_cnt_query(sh, cpool);
70 [ # # # ]: 0 : rte_atomic_fetch_add_explicit(&cpool->query_gen, 1, rte_memory_order_release);
71 : : zcdr.n1 = 0;
72 : : zcdu.n1 = 0;
73 : : ret = rte_ring_enqueue_zc_burst_elem_start(reuse_list,
74 : : sizeof(cnt_id_t),
75 : : reset_cnt_num, &zcdu,
76 : : NULL);
77 : : MLX5_ASSERT(ret == reset_cnt_num);
78 : : ret = rte_ring_dequeue_zc_burst_elem_start(reset_list,
79 : : sizeof(cnt_id_t),
80 : : reset_cnt_num, &zcdr,
81 : : NULL);
82 : : MLX5_ASSERT(ret == reset_cnt_num);
83 : : __hws_cnt_r2rcpy(&zcdu, &zcdr, reset_cnt_num);
84 : : rte_ring_dequeue_zc_elem_finish(reset_list, reset_cnt_num);
85 : : rte_ring_enqueue_zc_elem_finish(reuse_list, reset_cnt_num);
86 : :
87 [ # # ]: 0 : if (rte_log_can_log(mlx5_logtype, RTE_LOG_DEBUG)) {
88 : : reset_cnt_num = rte_ring_count(reset_list);
89 : 0 : DRV_LOG(DEBUG, "ibdev %s cpool %p wait_reset_cnt=%" PRIu32,
90 : : sh->ibdev_name, (void *)cpool, reset_cnt_num);
91 : : }
92 : 0 : }
93 : :
94 : : /**
95 : : * Release AGE parameter.
96 : : *
97 : : * @param priv
98 : : * Pointer to the port private data structure.
99 : : * @param own_cnt_index
100 : : * Counter ID to created only for this AGE to release.
101 : : * Zero means there is no such counter.
102 : : * @param age_ipool
103 : : * Pointer to AGE parameter indexed pool.
104 : : * @param idx
105 : : * Index of AGE parameter in the indexed pool.
106 : : */
107 : : static void
108 : 0 : mlx5_hws_age_param_free(struct mlx5_priv *priv, cnt_id_t own_cnt_index,
109 : : struct mlx5_indexed_pool *age_ipool, uint32_t idx)
110 : : {
111 [ # # ]: 0 : if (own_cnt_index) {
112 [ # # ]: 0 : struct mlx5_hws_cnt_pool *cpool = priv->hws_cpool;
113 : :
114 : : MLX5_ASSERT(mlx5_hws_cnt_is_shared(cpool, own_cnt_index));
115 : : mlx5_hws_cnt_shared_put(cpool, &own_cnt_index);
116 : : }
117 : 0 : mlx5_ipool_free(age_ipool, idx);
118 : 0 : }
119 : :
120 : : /**
121 : : * Check and callback event for new aged flow in the HWS counter pool.
122 : : *
123 : : * @param[in] priv
124 : : * Pointer to port private object.
125 : : * @param[in] cpool
126 : : * Pointer to current counter pool.
127 : : */
128 : : static void
129 : 0 : mlx5_hws_aging_check(struct mlx5_priv *priv, struct mlx5_hws_cnt_pool *cpool)
130 : : {
131 : 0 : struct mlx5_age_info *age_info = GET_PORT_AGE_INFO(priv);
132 : 0 : struct flow_counter_stats *stats = cpool->raw_mng->raw;
133 : : struct mlx5_hws_age_param *param;
134 : : struct rte_ring *r;
135 : 0 : const uint64_t curr_time = MLX5_CURR_TIME_SEC;
136 [ # # ]: 0 : const uint32_t time_delta = curr_time - cpool->time_of_last_age_check;
137 : : uint32_t nb_alloc_cnts = mlx5_hws_cnt_pool_get_size(cpool);
138 : : uint16_t expected1 = HWS_AGE_CANDIDATE;
139 : : uint16_t expected2 = HWS_AGE_CANDIDATE_INSIDE_RING;
140 : : uint32_t i, age_idx, in_use;
141 : :
142 : 0 : cpool->time_of_last_age_check = curr_time;
143 [ # # ]: 0 : for (i = 0; i < nb_alloc_cnts; ++i) {
144 : : uint64_t hits;
145 : :
146 [ # # ]: 0 : mlx5_hws_cnt_get_all(&cpool->pool[i], &in_use, NULL, &age_idx);
147 [ # # # # ]: 0 : if (!in_use || age_idx == 0)
148 : 0 : continue;
149 : 0 : param = mlx5_ipool_get(age_info->ages_ipool, age_idx);
150 [ # # ]: 0 : if (unlikely(param == NULL)) {
151 : : /*
152 : : * When AGE which used indirect counter it is user
153 : : * responsibility not using this indirect counter
154 : : * without this AGE.
155 : : * If this counter is used after the AGE was freed, the
156 : : * AGE index is invalid and using it here will cause a
157 : : * segmentation fault.
158 : : */
159 : 0 : DRV_LOG(WARNING,
160 : : "Counter %u is lost his AGE, it is unused.", i);
161 : 0 : continue;
162 : : }
163 [ # # ]: 0 : if (param->timeout == 0)
164 : 0 : continue;
165 [ # # # # ]: 0 : switch (rte_atomic_load_explicit(¶m->state, rte_memory_order_relaxed)) {
166 : 0 : case HWS_AGE_AGED_OUT_NOT_REPORTED:
167 : : case HWS_AGE_AGED_OUT_REPORTED:
168 : : /* Already aged-out, no action is needed. */
169 : 0 : continue;
170 : : case HWS_AGE_CANDIDATE:
171 : : case HWS_AGE_CANDIDATE_INSIDE_RING:
172 : : /* This AGE candidate to be aged-out, go to checking. */
173 : : break;
174 : 0 : case HWS_AGE_FREE:
175 : : /*
176 : : * Since this check is async, we may reach a race condition
177 : : * where the age and counter are used in the same rule,
178 : : * using the same counter index,
179 : : * age was freed first, and counter was not freed yet.
180 : : * Aging check can be safely ignored in that case.
181 : : */
182 : 0 : continue;
183 : 0 : default:
184 : : MLX5_ASSERT(0);
185 : 0 : continue;
186 : : }
187 [ # # ]: 0 : hits = rte_be_to_cpu_64(stats[i].hits);
188 [ # # ]: 0 : if (param->nb_cnts == 1) {
189 [ # # ]: 0 : if (hits != param->accumulator_last_hits) {
190 : 0 : rte_atomic_store_explicit(¶m->sec_since_last_hit, 0,
191 : : rte_memory_order_relaxed);
192 : 0 : param->accumulator_last_hits = hits;
193 : 0 : continue;
194 : : }
195 : : } else {
196 : 0 : param->accumulator_hits += hits;
197 : 0 : param->accumulator_cnt++;
198 [ # # ]: 0 : if (param->accumulator_cnt < param->nb_cnts)
199 : 0 : continue;
200 : 0 : param->accumulator_cnt = 0;
201 [ # # ]: 0 : if (param->accumulator_last_hits !=
202 : : param->accumulator_hits) {
203 : 0 : rte_atomic_store_explicit(¶m->sec_since_last_hit,
204 : : 0, rte_memory_order_relaxed);
205 : 0 : param->accumulator_last_hits =
206 : 0 : param->accumulator_hits;
207 : 0 : param->accumulator_hits = 0;
208 : 0 : continue;
209 : : }
210 : 0 : param->accumulator_hits = 0;
211 : : }
212 : 0 : if (rte_atomic_fetch_add_explicit(¶m->sec_since_last_hit, time_delta,
213 : 0 : rte_memory_order_relaxed) + time_delta <=
214 [ # # ]: 0 : rte_atomic_load_explicit(¶m->timeout, rte_memory_order_relaxed))
215 : 0 : continue;
216 : : /* Prepare the relevant ring for this AGE parameter */
217 [ # # ]: 0 : if (priv->hws_strict_queue)
218 : 0 : r = age_info->hw_q_age->aged_lists[param->queue_id];
219 : : else
220 : 0 : r = age_info->hw_age.aged_list;
221 : : /* Changing the state atomically and insert it into the ring. */
222 [ # # ]: 0 : if (rte_atomic_compare_exchange_strong_explicit(¶m->state, &expected1,
223 : : HWS_AGE_AGED_OUT_NOT_REPORTED,
224 : : rte_memory_order_relaxed,
225 : : rte_memory_order_relaxed)) {
226 : : int ret = rte_ring_enqueue_burst_elem(r, &age_idx,
227 : : sizeof(uint32_t),
228 : : 1, NULL);
229 : :
230 : : /*
231 : : * The ring doesn't have enough room for this entry,
232 : : * it replace back the state for the next second.
233 : : *
234 : : * FIXME: if until next sec it get traffic, we are going
235 : : * to lose this "aged out", will be fixed later
236 : : * when optimise it to fill ring in bulks.
237 : : */
238 : : expected2 = HWS_AGE_AGED_OUT_NOT_REPORTED;
239 [ # # # # ]: 0 : if (ret == 0 &&
240 : 0 : !rte_atomic_compare_exchange_strong_explicit(¶m->state,
241 : : &expected2, expected1,
242 : : rte_memory_order_relaxed,
243 [ # # ]: 0 : rte_memory_order_relaxed) &&
244 : : expected2 == HWS_AGE_FREE)
245 : 0 : mlx5_hws_age_param_free(priv,
246 : : param->own_cnt_index,
247 : : age_info->ages_ipool,
248 : : age_idx);
249 : : /* The event is irrelevant in strict queue mode. */
250 [ # # ]: 0 : if (!priv->hws_strict_queue)
251 : 0 : MLX5_AGE_SET(age_info, MLX5_AGE_EVENT_NEW);
252 : : } else {
253 : 0 : rte_atomic_compare_exchange_strong_explicit(¶m->state, &expected2,
254 : : HWS_AGE_AGED_OUT_NOT_REPORTED,
255 : : rte_memory_order_relaxed,
256 : : rte_memory_order_relaxed);
257 : : }
258 : : }
259 : : /* The event is irrelevant in strict queue mode. */
260 [ # # ]: 0 : if (!priv->hws_strict_queue)
261 : 0 : mlx5_age_event_prepare(priv->sh);
262 : 0 : }
263 : :
264 : : static void
265 : 0 : mlx5_hws_cnt_raw_data_free(struct mlx5_hws_cnt_raw_data_mng *mng)
266 : : {
267 [ # # ]: 0 : if (mng == NULL)
268 : : return;
269 : 0 : mlx5_os_dereg_mr(&mng->mr);
270 : 0 : mlx5_free(mng->raw);
271 : 0 : mlx5_free(mng);
272 : : }
273 : :
274 : : __rte_unused
275 : : static struct mlx5_hws_cnt_raw_data_mng *
276 : 0 : mlx5_hws_cnt_raw_data_alloc(struct mlx5_dev_ctx_shared *sh, uint32_t n,
277 : : struct rte_flow_error *error)
278 : : {
279 : : struct mlx5_hws_cnt_raw_data_mng *mng = NULL;
280 : : int ret;
281 : 0 : size_t sz = n * sizeof(struct flow_counter_stats);
282 : 0 : size_t pgsz = rte_mem_page_size();
283 : :
284 : : MLX5_ASSERT(pgsz > 0);
285 : 0 : mng = mlx5_malloc(MLX5_MEM_ANY | MLX5_MEM_ZERO, sizeof(*mng), 0,
286 : : SOCKET_ID_ANY);
287 [ # # ]: 0 : if (mng == NULL) {
288 : 0 : rte_flow_error_set(error, ENOMEM,
289 : : RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
290 : : NULL, "failed to allocate counters memory manager");
291 : 0 : goto error;
292 : : }
293 : 0 : mng->raw = mlx5_malloc(MLX5_MEM_ANY | MLX5_MEM_ZERO, sz, pgsz,
294 : : SOCKET_ID_ANY);
295 [ # # ]: 0 : if (mng->raw == NULL) {
296 : 0 : DRV_LOG(ERR, "Failed to allocate raw counter memory: %zu bytes.",
297 : : sz);
298 : 0 : rte_flow_error_set(error, ENOMEM,
299 : : RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
300 : : NULL, "failed to allocate raw counters memory");
301 : 0 : goto error;
302 : : }
303 : 0 : ret = mlx5_os_reg_mr(sh->cdev->pd, mng->raw, sz, &mng->mr);
304 [ # # ]: 0 : if (ret) {
305 : 0 : rte_flow_error_set(error, errno,
306 : : RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
307 : : NULL, "failed to register counters memory region");
308 : 0 : goto error;
309 : : }
310 : : return mng;
311 : 0 : error:
312 : 0 : mlx5_hws_cnt_raw_data_free(mng);
313 : 0 : return NULL;
314 : : }
315 : :
316 : : static uint32_t
317 : 0 : mlx5_hws_cnt_svc(void *opaque)
318 : : {
319 : : struct mlx5_dev_ctx_shared *sh =
320 : : (struct mlx5_dev_ctx_shared *)opaque;
321 : 0 : uint64_t interval =
322 : 0 : (uint64_t)sh->cnt_svc->query_interval * (US_PER_S / MS_PER_S);
323 : : struct mlx5_hws_cnt_pool *hws_cpool;
324 : : uint64_t start_cycle, query_cycle = 0;
325 : : uint64_t query_us;
326 : : uint64_t sleep_us;
327 : :
328 [ # # ]: 0 : while (sh->cnt_svc->svc_running != 0) {
329 [ # # ]: 0 : if (rte_spinlock_trylock(&sh->cpool_lock) == 0)
330 : 0 : continue;
331 : : start_cycle = rte_rdtsc();
332 : : /* 200ms for 16M counters. */
333 [ # # ]: 0 : LIST_FOREACH(hws_cpool, &sh->hws_cpool_list, next) {
334 : 0 : struct mlx5_priv *opriv = hws_cpool->priv;
335 : :
336 : 0 : __mlx5_hws_cnt_svc(sh, hws_cpool);
337 [ # # ]: 0 : if (opriv->hws_age_req)
338 : 0 : mlx5_hws_aging_check(opriv, hws_cpool);
339 : : }
340 : 0 : query_cycle = rte_rdtsc() - start_cycle;
341 : : rte_spinlock_unlock(&sh->cpool_lock);
342 : 0 : query_us = query_cycle / (rte_get_timer_hz() / US_PER_S);
343 : 0 : sleep_us = interval - query_us;
344 [ # # ]: 0 : DRV_LOG(DEBUG, "ibdev %s counter service thread: "
345 : : "interval_us=%" PRIu64 " query_us=%" PRIu64 " "
346 : : "sleep_us=%" PRIu64,
347 : : sh->ibdev_name, interval, query_us,
348 : : interval > query_us ? sleep_us : 0);
349 [ # # ]: 0 : if (interval > query_us)
350 : 0 : rte_delay_us_sleep(sleep_us);
351 : : }
352 : 0 : return 0;
353 : : }
354 : :
355 : : static void
356 : 0 : mlx5_hws_cnt_pool_deinit(struct mlx5_hws_cnt_pool * const cntp)
357 : : {
358 : : uint32_t qidx = 0;
359 [ # # ]: 0 : if (cntp == NULL)
360 : : return;
361 : 0 : rte_ring_free(cntp->free_list);
362 : 0 : rte_ring_free(cntp->wait_reset_list);
363 : 0 : rte_ring_free(cntp->reuse_list);
364 [ # # ]: 0 : if (cntp->cache) {
365 [ # # ]: 0 : for (qidx = 0; qidx < cntp->cache->q_num; qidx++)
366 : 0 : rte_ring_free(cntp->cache->qcache[qidx]);
367 : : }
368 : 0 : mlx5_free(cntp->cache);
369 : 0 : mlx5_free(cntp->raw_mng);
370 : 0 : mlx5_free(cntp->pool);
371 : 0 : mlx5_free(cntp);
372 : : }
373 : :
374 : : static bool
375 : : mlx5_hws_cnt_should_enable_cache(const struct mlx5_hws_cnt_pool_cfg *pcfg,
376 : : const struct mlx5_hws_cache_param *ccfg)
377 : : {
378 : : /*
379 : : * Enable cache if and only if there are enough counters requested
380 : : * to populate all of the caches.
381 : : */
382 : 0 : return pcfg->request_num >= ccfg->q_num * ccfg->size;
383 : : }
384 : :
385 : : static struct mlx5_hws_cnt_pool_caches *
386 : 0 : mlx5_hws_cnt_cache_init(const struct mlx5_hws_cnt_pool_cfg *pcfg,
387 : : const struct mlx5_hws_cache_param *ccfg)
388 : : {
389 : : struct mlx5_hws_cnt_pool_caches *cache;
390 : : char mz_name[RTE_MEMZONE_NAMESIZE];
391 : : uint32_t qidx;
392 : :
393 : : /* If counter pool is big enough, setup the counter pool cache. */
394 : 0 : cache = mlx5_malloc(MLX5_MEM_ANY | MLX5_MEM_ZERO,
395 : 0 : sizeof(*cache) +
396 : : sizeof(((struct mlx5_hws_cnt_pool_caches *)0)->qcache[0])
397 : 0 : * ccfg->q_num, 0, SOCKET_ID_ANY);
398 [ # # ]: 0 : if (cache == NULL)
399 : : return NULL;
400 : : /* Store the necessary cache parameters. */
401 : 0 : cache->fetch_sz = ccfg->fetch_sz;
402 : 0 : cache->preload_sz = ccfg->preload_sz;
403 : 0 : cache->threshold = ccfg->threshold;
404 : 0 : cache->q_num = ccfg->q_num;
405 [ # # ]: 0 : for (qidx = 0; qidx < ccfg->q_num; qidx++) {
406 : 0 : snprintf(mz_name, sizeof(mz_name), "%s_qc/%x", pcfg->name, qidx);
407 : 0 : cache->qcache[qidx] = rte_ring_create(mz_name, ccfg->size,
408 : : SOCKET_ID_ANY,
409 : : RING_F_SP_ENQ | RING_F_SC_DEQ |
410 : : RING_F_EXACT_SZ);
411 [ # # ]: 0 : if (cache->qcache[qidx] == NULL)
412 : 0 : goto error;
413 : : }
414 : : return cache;
415 : :
416 : : error:
417 [ # # ]: 0 : while (qidx--)
418 : 0 : rte_ring_free(cache->qcache[qidx]);
419 : 0 : mlx5_free(cache);
420 : 0 : return NULL;
421 : : }
422 : :
423 : : static struct mlx5_hws_cnt_pool *
424 : 0 : mlx5_hws_cnt_pool_init(struct mlx5_dev_ctx_shared *sh,
425 : : const struct mlx5_hws_cnt_pool_cfg *pcfg,
426 : : const struct mlx5_hws_cache_param *ccfg,
427 : : struct rte_flow_error *error)
428 : : {
429 : : char mz_name[RTE_MEMZONE_NAMESIZE];
430 : : struct mlx5_hws_cnt_pool *cntp;
431 : : uint64_t cnt_num = 0;
432 : :
433 : : MLX5_ASSERT(pcfg);
434 : : MLX5_ASSERT(ccfg);
435 : 0 : cntp = mlx5_malloc(MLX5_MEM_ANY | MLX5_MEM_ZERO, sizeof(*cntp), 0,
436 : : SOCKET_ID_ANY);
437 [ # # ]: 0 : if (cntp == NULL) {
438 : 0 : rte_flow_error_set(error, ENOMEM,
439 : : RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
440 : : "failed to allocate counter pool context");
441 : 0 : return NULL;
442 : : }
443 : :
444 : 0 : cntp->cfg = *pcfg;
445 : 0 : DRV_LOG(DEBUG, "ibdev %s counter and age action %s supported on group 0",
446 : : sh->ibdev_name,
447 : : mlx5dr_action_counter_root_is_supported() ? "is" : "is not");
448 [ # # ]: 0 : if (cntp->cfg.host_cpool)
449 : : return cntp;
450 [ # # ]: 0 : if (pcfg->request_num > sh->hws_max_nb_counters) {
451 : 0 : DRV_LOG(ERR, "Counter number %u "
452 : : "is greater than the maximum supported (%u).",
453 : : pcfg->request_num, sh->hws_max_nb_counters);
454 : 0 : rte_flow_error_set(error, EINVAL,
455 : : RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
456 : : "requested counters number exceeds supported capacity");
457 : 0 : goto error;
458 : : }
459 : 0 : cnt_num = pcfg->request_num * (100 + pcfg->alloc_factor) / 100;
460 : : if (cnt_num > UINT32_MAX) {
461 : : DRV_LOG(ERR, "counter number %"PRIu64" is out of 32bit range",
462 : : cnt_num);
463 : : rte_flow_error_set(error, EINVAL,
464 : : RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
465 : : "counters number must fit in 32 bits");
466 : : goto error;
467 : : }
468 : : /*
469 : : * When counter request number is supported, but the factor takes it
470 : : * out of size, the factor is reduced.
471 : : */
472 : 0 : cnt_num = RTE_MIN((uint32_t)cnt_num, sh->hws_max_nb_counters);
473 : 0 : cntp->pool = mlx5_malloc(MLX5_MEM_ANY | MLX5_MEM_ZERO,
474 : : sizeof(struct mlx5_hws_cnt) * cnt_num,
475 : : 0, SOCKET_ID_ANY);
476 [ # # ]: 0 : if (cntp->pool == NULL) {
477 : 0 : DRV_LOG(ERR,
478 : : "Failed to allocate counter pool: %zu bytes for %" PRIu64 " counters.",
479 : : sizeof(struct mlx5_hws_cnt) * (size_t)cnt_num, cnt_num);
480 : 0 : rte_flow_error_set(error, ENOMEM,
481 : : RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
482 : : "failed to allocate counter pool context");
483 : 0 : goto error;
484 : : }
485 : 0 : snprintf(mz_name, sizeof(mz_name), "%s_F_RING", pcfg->name);
486 : 0 : cntp->free_list = rte_ring_create_elem(mz_name, sizeof(cnt_id_t),
487 : : (uint32_t)cnt_num, SOCKET_ID_ANY,
488 : : RING_F_MP_HTS_ENQ | RING_F_MC_HTS_DEQ |
489 : : RING_F_EXACT_SZ);
490 [ # # ]: 0 : if (cntp->free_list == NULL) {
491 : 0 : rte_flow_error_set(error, ENOMEM,
492 : : RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
493 : : "failed to allocate free counters ring");
494 : 0 : goto error;
495 : : }
496 : : snprintf(mz_name, sizeof(mz_name), "%s_R_RING", pcfg->name);
497 : 0 : cntp->wait_reset_list = rte_ring_create_elem(mz_name, sizeof(cnt_id_t),
498 : : (uint32_t)cnt_num, SOCKET_ID_ANY,
499 : : RING_F_MP_HTS_ENQ | RING_F_SC_DEQ | RING_F_EXACT_SZ);
500 [ # # ]: 0 : if (cntp->wait_reset_list == NULL) {
501 : 0 : rte_flow_error_set(error, ENOMEM,
502 : : RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
503 : : "failed to allocate counters wait reset ring");
504 : 0 : goto error;
505 : : }
506 : : snprintf(mz_name, sizeof(mz_name), "%s_U_RING", pcfg->name);
507 : 0 : cntp->reuse_list = rte_ring_create_elem(mz_name, sizeof(cnt_id_t),
508 : : (uint32_t)cnt_num, SOCKET_ID_ANY,
509 : : RING_F_MP_HTS_ENQ | RING_F_MC_HTS_DEQ | RING_F_EXACT_SZ);
510 [ # # ]: 0 : if (cntp->reuse_list == NULL) {
511 : 0 : rte_flow_error_set(error, ENOMEM,
512 : : RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
513 : : "failed to allocate counters reuse ring");
514 : 0 : goto error;
515 : : }
516 : : /* Allocate counter cache only if needed. */
517 [ # # ]: 0 : if (mlx5_hws_cnt_should_enable_cache(pcfg, ccfg)) {
518 : 0 : cntp->cache = mlx5_hws_cnt_cache_init(pcfg, ccfg);
519 [ # # ]: 0 : if (cntp->cache == NULL) {
520 : 0 : rte_flow_error_set(error, ENOMEM,
521 : : RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
522 : : "failed to allocate counters cache");
523 : 0 : goto error;
524 : : }
525 : : }
526 : : /* Initialize the time for aging-out calculation. */
527 : 0 : cntp->time_of_last_age_check = MLX5_CURR_TIME_SEC;
528 : 0 : return cntp;
529 : 0 : error:
530 : 0 : mlx5_hws_cnt_pool_deinit(cntp);
531 : 0 : return NULL;
532 : : }
533 : :
534 : : int
535 : 0 : mlx5_hws_cnt_service_thread_create(struct mlx5_dev_ctx_shared *sh)
536 : : {
537 : : char name[RTE_THREAD_INTERNAL_NAME_SIZE];
538 : : rte_thread_attr_t attr;
539 : : int ret;
540 : 0 : uint32_t service_core = sh->cnt_svc->service_core;
541 : :
542 : 0 : ret = rte_thread_attr_init(&attr);
543 [ # # ]: 0 : if (ret != 0)
544 : 0 : goto error;
545 [ # # ]: 0 : CPU_SET(service_core, &attr.cpuset);
546 : 0 : sh->cnt_svc->svc_running = 1;
547 : 0 : ret = rte_thread_create(&sh->cnt_svc->service_thread,
548 : : &attr, mlx5_hws_cnt_svc, sh);
549 [ # # ]: 0 : if (ret != 0)
550 : 0 : goto error;
551 : : snprintf(name, sizeof(name), "mlx5-cn%d", service_core);
552 : 0 : rte_thread_set_prefixed_name(sh->cnt_svc->service_thread, name);
553 : :
554 : 0 : return 0;
555 : 0 : error:
556 : 0 : DRV_LOG(ERR, "Failed to create HW steering's counter service thread.");
557 : 0 : return ret;
558 : : }
559 : :
560 : : void
561 : 0 : mlx5_hws_cnt_service_thread_destroy(struct mlx5_dev_ctx_shared *sh)
562 : : {
563 [ # # ]: 0 : if (sh->cnt_svc->service_thread.opaque_id == 0)
564 : : return;
565 : 0 : sh->cnt_svc->svc_running = 0;
566 : 0 : rte_thread_join(sh->cnt_svc->service_thread, NULL);
567 : 0 : sh->cnt_svc->service_thread.opaque_id = 0;
568 : : }
569 : :
570 : : static int
571 : 0 : mlx5_hws_cnt_pool_dcs_alloc(struct mlx5_dev_ctx_shared *sh,
572 : : struct mlx5_hws_cnt_pool *cpool,
573 : : struct rte_flow_error *error)
574 : : {
575 : 0 : struct mlx5_hca_attr *hca_attr = &sh->cdev->config.hca_attr;
576 [ # # ]: 0 : uint32_t max_log_bulk_sz = sh->hws_max_log_bulk_sz;
577 : : uint32_t log_bulk_sz;
578 : : uint32_t idx, alloc_candidate, alloced = 0;
579 : : unsigned int cnt_num = mlx5_hws_cnt_pool_get_size(cpool);
580 : 0 : struct mlx5_devx_counter_attr attr = {0};
581 : : struct mlx5_devx_obj *dcs;
582 : :
583 : : MLX5_ASSERT(cpool->cfg.host_cpool == NULL);
584 [ # # ]: 0 : if (hca_attr->flow_counter_bulk_log_max_alloc == 0)
585 : 0 : return rte_flow_error_set(error, ENOTSUP,
586 : : RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
587 : : NULL, "FW doesn't support bulk log max alloc");
588 [ # # ]: 0 : cnt_num = RTE_ALIGN_CEIL(cnt_num, 4); /* minimal 4 counter in bulk. */
589 : 0 : log_bulk_sz = RTE_MIN(max_log_bulk_sz, rte_log2_u32(cnt_num));
590 : 0 : attr.pd = sh->cdev->pdn;
591 : 0 : attr.pd_valid = 1;
592 : 0 : attr.bulk_log_max_alloc = 1;
593 : 0 : attr.flow_counter_bulk_log_size = log_bulk_sz;
594 : : idx = 0;
595 : 0 : dcs = mlx5_devx_cmd_flow_counter_alloc_general(sh->cdev->ctx, &attr);
596 [ # # ]: 0 : if (dcs == NULL) {
597 : 0 : rte_flow_error_set(error, rte_errno,
598 : : RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
599 : : NULL, "FW failed to allocate counters");
600 : 0 : goto error;
601 : : }
602 : 0 : cpool->dcs_mng.dcs[idx].obj = dcs;
603 : 0 : cpool->dcs_mng.dcs[idx].batch_sz = (1 << log_bulk_sz);
604 : 0 : cpool->dcs_mng.batch_total++;
605 : : idx++;
606 : 0 : cpool->dcs_mng.dcs[0].iidx = 0;
607 : : alloced = cpool->dcs_mng.dcs[0].batch_sz;
608 [ # # ]: 0 : if (cnt_num > cpool->dcs_mng.dcs[0].batch_sz) {
609 [ # # ]: 0 : while (idx < MLX5_HWS_CNT_DCS_NUM) {
610 : 0 : attr.flow_counter_bulk_log_size = --max_log_bulk_sz;
611 : 0 : alloc_candidate = RTE_BIT32(max_log_bulk_sz);
612 [ # # ]: 0 : if (alloced + alloc_candidate > sh->hws_max_nb_counters)
613 : 0 : continue;
614 : 0 : dcs = mlx5_devx_cmd_flow_counter_alloc_general
615 : 0 : (sh->cdev->ctx, &attr);
616 [ # # ]: 0 : if (dcs == NULL) {
617 : 0 : rte_flow_error_set(error, rte_errno,
618 : : RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
619 : : NULL, "FW failed to allocate counters");
620 : 0 : goto error;
621 : : }
622 : 0 : cpool->dcs_mng.dcs[idx].obj = dcs;
623 : 0 : cpool->dcs_mng.dcs[idx].batch_sz = alloc_candidate;
624 : 0 : cpool->dcs_mng.dcs[idx].iidx = alloced;
625 : : alloced += cpool->dcs_mng.dcs[idx].batch_sz;
626 : 0 : cpool->dcs_mng.batch_total++;
627 [ # # ]: 0 : if (alloced >= cnt_num)
628 : : break;
629 : 0 : idx++;
630 : : }
631 : : }
632 : : return 0;
633 : 0 : error:
634 : 0 : DRV_LOG(DEBUG,
635 : : "Cannot alloc device counter, allocated[%" PRIu32 "] request[%" PRIu32 "]",
636 : : alloced, cnt_num);
637 [ # # ]: 0 : for (idx = 0; idx < cpool->dcs_mng.batch_total; idx++) {
638 : 0 : mlx5_devx_cmd_destroy(cpool->dcs_mng.dcs[idx].obj);
639 : 0 : cpool->dcs_mng.dcs[idx].obj = NULL;
640 : 0 : cpool->dcs_mng.dcs[idx].batch_sz = 0;
641 : 0 : cpool->dcs_mng.dcs[idx].iidx = 0;
642 : : }
643 : 0 : cpool->dcs_mng.batch_total = 0;
644 : 0 : return -1;
645 : : }
646 : :
647 : : static void
648 : 0 : mlx5_hws_cnt_pool_dcs_free(struct mlx5_hws_cnt_pool *cpool)
649 : : {
650 : : uint32_t idx;
651 : :
652 [ # # ]: 0 : if (cpool == NULL)
653 : : return;
654 [ # # ]: 0 : for (idx = 0; idx < MLX5_HWS_CNT_DCS_NUM; idx++)
655 : 0 : mlx5_devx_cmd_destroy(cpool->dcs_mng.dcs[idx].obj);
656 [ # # ]: 0 : if (cpool->raw_mng) {
657 : 0 : mlx5_hws_cnt_raw_data_free(cpool->raw_mng);
658 : 0 : cpool->raw_mng = NULL;
659 : : }
660 : : }
661 : :
662 : : static void
663 : 0 : mlx5_hws_cnt_pool_action_destroy(struct mlx5_hws_cnt_pool *cpool)
664 : : {
665 : : uint32_t idx;
666 : :
667 [ # # ]: 0 : for (idx = 0; idx < cpool->dcs_mng.batch_total; idx++) {
668 : : struct mlx5_hws_cnt_dcs *dcs = &cpool->dcs_mng.dcs[idx];
669 : :
670 [ # # ]: 0 : if (dcs->root_action != NULL) {
671 : 0 : mlx5dr_action_destroy(dcs->root_action);
672 : 0 : dcs->root_action = NULL;
673 : : }
674 [ # # ]: 0 : if (dcs->hws_action != NULL) {
675 : 0 : mlx5dr_action_destroy(dcs->hws_action);
676 : 0 : dcs->hws_action = NULL;
677 : : }
678 : : }
679 : 0 : }
680 : :
681 : : static int
682 [ # # ]: 0 : mlx5_hws_cnt_pool_action_create(struct mlx5_priv *priv,
683 : : struct mlx5_hws_cnt_pool *cpool)
684 : : {
685 : : struct mlx5_hws_cnt_pool *hpool = mlx5_hws_cnt_host_pool(cpool);
686 : : uint32_t idx;
687 : : int ret = 0;
688 : : uint32_t root_flags;
689 : : uint32_t hws_flags;
690 : :
691 : : root_flags = MLX5DR_ACTION_FLAG_ROOT_RX | MLX5DR_ACTION_FLAG_ROOT_TX;
692 : : hws_flags = MLX5DR_ACTION_FLAG_HWS_RX | MLX5DR_ACTION_FLAG_HWS_TX;
693 [ # # # # ]: 0 : if (priv->sh->config.dv_esw_en && priv->master) {
694 : : root_flags |= MLX5DR_ACTION_FLAG_ROOT_FDB;
695 : 0 : hws_flags |= (is_unified_fdb(priv) ?
696 : : (MLX5DR_ACTION_FLAG_HWS_FDB_RX |
697 : : MLX5DR_ACTION_FLAG_HWS_FDB_TX |
698 [ # # ]: 0 : MLX5DR_ACTION_FLAG_HWS_FDB_UNIFIED) :
699 : : MLX5DR_ACTION_FLAG_HWS_FDB);
700 : : }
701 [ # # ]: 0 : for (idx = 0; idx < hpool->dcs_mng.batch_total; idx++) {
702 : : struct mlx5_hws_cnt_dcs *hdcs = &hpool->dcs_mng.dcs[idx];
703 : : struct mlx5_hws_cnt_dcs *dcs = &cpool->dcs_mng.dcs[idx];
704 : :
705 : 0 : dcs->hws_action = mlx5dr_action_create_counter(priv->dr_ctx,
706 : 0 : (struct mlx5dr_devx_obj *)hdcs->obj,
707 : : hws_flags);
708 [ # # ]: 0 : if (dcs->hws_action == NULL) {
709 : 0 : mlx5_hws_cnt_pool_action_destroy(cpool);
710 : : ret = -ENOSYS;
711 : 0 : break;
712 : : }
713 : :
714 : 0 : if (!mlx5dr_action_counter_root_is_supported()) {
715 : 0 : dcs->root_action = NULL;
716 : : continue;
717 : : }
718 : :
719 : : dcs->root_action = mlx5dr_action_create_counter(priv->dr_ctx,
720 : : (struct mlx5dr_devx_obj *)hdcs->obj,
721 : : root_flags);
722 : : if (dcs->root_action == NULL) {
723 : : mlx5_hws_cnt_pool_action_destroy(cpool);
724 : : ret = -ENOSYS;
725 : : break;
726 : : }
727 : : }
728 : 0 : return ret;
729 : : }
730 : :
731 : : int
732 : 0 : mlx5_hws_cnt_pool_create(struct rte_eth_dev *dev,
733 : : uint32_t nb_counters, uint16_t nb_queue,
734 : : struct mlx5_hws_cnt_pool *chost,
735 : : struct rte_flow_error *error)
736 : : {
737 : : struct mlx5_hws_cnt_pool *cpool = NULL;
738 : 0 : struct mlx5_priv *priv = dev->data->dev_private;
739 : 0 : struct mlx5_hws_cache_param cparam = {0};
740 : 0 : struct mlx5_hws_cnt_pool_cfg pcfg = {0};
741 : : int ret = 0;
742 : : size_t sz;
743 : :
744 : 0 : snprintf(pcfg.name, sizeof(pcfg.name), "MLX5_HWS_CNT_P_%x",
745 [ # # ]: 0 : dev->data->port_id);
746 : 0 : pcfg.request_num = nb_counters;
747 : 0 : pcfg.alloc_factor = HWS_CNT_ALLOC_FACTOR_DEFAULT;
748 [ # # ]: 0 : if (chost) {
749 : 0 : pcfg.host_cpool = chost;
750 : 0 : cpool = mlx5_hws_cnt_pool_init(priv->sh, &pcfg, &cparam, error);
751 [ # # ]: 0 : if (cpool == NULL) {
752 : 0 : ret = -rte_errno;
753 : 0 : goto error;
754 : : }
755 : 0 : ret = mlx5_hws_cnt_pool_action_create(priv, cpool);
756 [ # # ]: 0 : if (ret != 0) {
757 : 0 : rte_flow_error_set(error, -ret,
758 : : RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
759 : : NULL, "failed to allocate counter actions on guest port");
760 : 0 : goto error;
761 : : }
762 : 0 : goto success;
763 : : }
764 : 0 : cparam.fetch_sz = HWS_CNT_CACHE_FETCH_DEFAULT;
765 : 0 : cparam.preload_sz = HWS_CNT_CACHE_PRELOAD_DEFAULT;
766 : 0 : cparam.q_num = nb_queue;
767 : 0 : cparam.threshold = HWS_CNT_CACHE_THRESHOLD_DEFAULT;
768 : 0 : cparam.size = HWS_CNT_CACHE_SZ_DEFAULT;
769 : 0 : cpool = mlx5_hws_cnt_pool_init(priv->sh, &pcfg, &cparam, error);
770 [ # # ]: 0 : if (cpool == NULL) {
771 : 0 : ret = -rte_errno;
772 : 0 : goto error;
773 : : }
774 : 0 : ret = mlx5_hws_cnt_pool_dcs_alloc(priv->sh, cpool, error);
775 [ # # ]: 0 : if (ret != 0)
776 : 0 : goto error;
777 : 0 : sz = RTE_ALIGN_CEIL(mlx5_hws_cnt_pool_get_size(cpool), 4);
778 : 0 : cpool->raw_mng = mlx5_hws_cnt_raw_data_alloc(priv->sh, sz, error);
779 [ # # ]: 0 : if (cpool->raw_mng == NULL) {
780 : 0 : ret = -rte_errno;
781 : 0 : goto error;
782 : : }
783 : 0 : ret = __hws_cnt_id_load(cpool);
784 [ # # ]: 0 : if (ret != 0) {
785 : 0 : rte_flow_error_set(error, ENOMEM,
786 : : RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
787 : : "failed to allocate counter ID array");
788 : 0 : goto error;
789 : : }
790 : : /*
791 : : * Bump query gen right after pool create so the
792 : : * pre-loaded counters can be used directly
793 : : * because they already have init value no need
794 : : * to wait for query.
795 : : */
796 : 0 : rte_atomic_store_explicit(&cpool->query_gen, 1, rte_memory_order_relaxed);
797 : 0 : ret = mlx5_hws_cnt_pool_action_create(priv, cpool);
798 [ # # ]: 0 : if (ret != 0) {
799 : 0 : rte_flow_error_set(error, -ret,
800 : : RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
801 : : NULL, "failed to allocate counter actions");
802 : 0 : goto error;
803 : : }
804 : : /* init cnt service if not. */
805 [ # # ]: 0 : if (priv->sh->cnt_svc == NULL) {
806 : 0 : ret = mlx5_hws_cnt_svc_init(priv->sh, error);
807 [ # # ]: 0 : if (ret)
808 : 0 : goto error;
809 : : }
810 : 0 : priv->sh->cnt_svc->refcnt++;
811 : 0 : cpool->priv = priv;
812 : 0 : rte_spinlock_lock(&priv->sh->cpool_lock);
813 [ # # ]: 0 : LIST_INSERT_HEAD(&priv->sh->hws_cpool_list, cpool, next);
814 : 0 : rte_spinlock_unlock(&priv->sh->cpool_lock);
815 : 0 : success:
816 : 0 : priv->hws_cpool = cpool;
817 : 0 : return 0;
818 : 0 : error:
819 : : MLX5_ASSERT(ret);
820 [ # # # # ]: 0 : DRV_LOG(ERR, "Port %u failed to create counter pool for %u counters: %s",
821 : : dev->data->port_id, nb_counters,
822 : : (error != NULL && error->message != NULL) ?
823 : : error->message : "unspecified error");
824 : 0 : mlx5_hws_cnt_pool_destroy(priv->sh, cpool);
825 : 0 : priv->hws_cpool = NULL;
826 : 0 : return ret;
827 : : }
828 : :
829 : : void
830 : 0 : mlx5_hws_cnt_pool_destroy(struct mlx5_dev_ctx_shared *sh,
831 : : struct mlx5_hws_cnt_pool *cpool)
832 : : {
833 [ # # ]: 0 : if (cpool == NULL)
834 : : return;
835 : : /*
836 : : * 16M counter consumes 200ms to finish the query.
837 : : * Maybe blocked for at most 200ms here.
838 : : */
839 : 0 : rte_spinlock_lock(&sh->cpool_lock);
840 : : /* Try to remove cpool before it was added to list caused segfault. */
841 [ # # # # ]: 0 : if (!LIST_EMPTY(&sh->hws_cpool_list) && cpool->next.le_prev)
842 [ # # ]: 0 : LIST_REMOVE(cpool, next);
843 : : rte_spinlock_unlock(&sh->cpool_lock);
844 [ # # ]: 0 : if (cpool->cfg.host_cpool == NULL) {
845 [ # # # # ]: 0 : if (sh->cnt_svc && --sh->cnt_svc->refcnt == 0)
846 : 0 : mlx5_hws_cnt_svc_deinit(sh);
847 : : }
848 : 0 : mlx5_hws_cnt_pool_action_destroy(cpool);
849 [ # # ]: 0 : if (cpool->cfg.host_cpool == NULL) {
850 : 0 : mlx5_hws_cnt_pool_dcs_free(cpool);
851 : 0 : mlx5_hws_cnt_raw_data_free(cpool->raw_mng);
852 : : }
853 : 0 : mlx5_hws_cnt_pool_deinit(cpool);
854 : : }
855 : :
856 : : int
857 : 0 : mlx5_hws_cnt_svc_init(struct mlx5_dev_ctx_shared *sh,
858 : : struct rte_flow_error *error)
859 : : {
860 : : int ret;
861 : :
862 : 0 : sh->cnt_svc = mlx5_malloc(MLX5_MEM_ANY | MLX5_MEM_ZERO,
863 : : sizeof(*sh->cnt_svc), 0, SOCKET_ID_ANY);
864 [ # # ]: 0 : if (sh->cnt_svc == NULL)
865 : 0 : goto err;
866 : 0 : sh->cnt_svc->query_interval = sh->config.cnt_svc.cycle_time;
867 : 0 : sh->cnt_svc->service_core = sh->config.cnt_svc.service_core;
868 : 0 : ret = mlx5_aso_cnt_queue_init(sh);
869 [ # # ]: 0 : if (ret != 0) {
870 : 0 : mlx5_free(sh->cnt_svc);
871 : 0 : sh->cnt_svc = NULL;
872 : 0 : goto err;
873 : : }
874 : 0 : ret = mlx5_hws_cnt_service_thread_create(sh);
875 [ # # ]: 0 : if (ret != 0) {
876 : 0 : mlx5_aso_cnt_queue_uninit(sh);
877 : 0 : mlx5_free(sh->cnt_svc);
878 : 0 : sh->cnt_svc = NULL;
879 : : }
880 : : return 0;
881 : 0 : err:
882 : 0 : return rte_flow_error_set(error, ENOMEM,
883 : : RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
884 : : NULL, "failed to init counters service");
885 : :
886 : : }
887 : :
888 : : void
889 : 0 : mlx5_hws_cnt_svc_deinit(struct mlx5_dev_ctx_shared *sh)
890 : : {
891 [ # # ]: 0 : if (sh->cnt_svc == NULL)
892 : : return;
893 : 0 : mlx5_hws_cnt_service_thread_destroy(sh);
894 : 0 : mlx5_aso_cnt_queue_uninit(sh);
895 : 0 : mlx5_free(sh->cnt_svc);
896 : 0 : sh->cnt_svc = NULL;
897 : : }
898 : :
899 : : /**
900 : : * Destroy AGE action.
901 : : *
902 : : * @param priv
903 : : * Pointer to the port private data structure.
904 : : * @param idx
905 : : * Index of AGE parameter.
906 : : * @param error
907 : : * Pointer to error structure.
908 : : *
909 : : * @return
910 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
911 : : */
912 : : int
913 : 0 : mlx5_hws_age_action_destroy(struct mlx5_priv *priv, uint32_t idx,
914 : : struct rte_flow_error *error)
915 : : {
916 : 0 : struct mlx5_age_info *age_info = GET_PORT_AGE_INFO(priv);
917 : 0 : struct mlx5_indexed_pool *ipool = age_info->ages_ipool;
918 : 0 : struct mlx5_hws_age_param *param = mlx5_ipool_get(ipool, idx);
919 : :
920 [ # # ]: 0 : if (param == NULL)
921 : 0 : return rte_flow_error_set(error, EINVAL,
922 : : RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
923 : : "invalid AGE parameter index");
924 [ # # # ]: 0 : switch (rte_atomic_exchange_explicit(¶m->state, HWS_AGE_FREE,
925 : : rte_memory_order_relaxed)) {
926 : 0 : case HWS_AGE_CANDIDATE:
927 : : case HWS_AGE_AGED_OUT_REPORTED:
928 : 0 : mlx5_hws_age_param_free(priv, param->own_cnt_index, ipool, idx);
929 : 0 : break;
930 : : case HWS_AGE_AGED_OUT_NOT_REPORTED:
931 : : case HWS_AGE_CANDIDATE_INSIDE_RING:
932 : : /*
933 : : * In both cases AGE is inside the ring. Change the state here
934 : : * and destroy it later when it is taken out of ring.
935 : : */
936 : : break;
937 : 0 : case HWS_AGE_FREE:
938 : : /*
939 : : * If index is valid and state is FREE, it says this AGE has
940 : : * been freed for the user but not for the PMD since it is
941 : : * inside the ring.
942 : : */
943 : 0 : return rte_flow_error_set(error, EINVAL,
944 : : RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
945 : : "this AGE has already been released");
946 : : default:
947 : : MLX5_ASSERT(0);
948 : : break;
949 : : }
950 : : return 0;
951 : : }
952 : :
953 : : /**
954 : : * Create AGE action parameter.
955 : : *
956 : : * @param[in] priv
957 : : * Pointer to the port private data structure.
958 : : * @param[in] queue_id
959 : : * Which HWS queue to be used.
960 : : * @param[in] shared
961 : : * Whether it indirect AGE action.
962 : : * @param[in] flow_idx
963 : : * Flow index from indexed pool.
964 : : * For indirect AGE action it doesn't affect.
965 : : * @param[in] age
966 : : * Pointer to the aging action configuration.
967 : : * @param[out] error
968 : : * Pointer to error structure.
969 : : *
970 : : * @return
971 : : * Index to AGE action parameter on success, 0 otherwise.
972 : : */
973 : : uint32_t
974 : 0 : mlx5_hws_age_action_create(struct mlx5_priv *priv, uint32_t queue_id,
975 : : bool shared, const struct rte_flow_action_age *age,
976 : : uint32_t flow_idx, struct rte_flow_error *error)
977 : : {
978 : 0 : struct mlx5_age_info *age_info = GET_PORT_AGE_INFO(priv);
979 : 0 : struct mlx5_indexed_pool *ipool = age_info->ages_ipool;
980 : : struct mlx5_hws_age_param *param;
981 : : uint32_t age_idx;
982 : :
983 : 0 : param = mlx5_ipool_malloc(ipool, &age_idx);
984 [ # # ]: 0 : if (param == NULL) {
985 : 0 : rte_flow_error_set(error, ENOMEM,
986 : : RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
987 : : "cannot allocate AGE parameter");
988 : 0 : return 0;
989 : : }
990 : : MLX5_ASSERT(rte_atomic_load_explicit(¶m->state,
991 : : rte_memory_order_relaxed) == HWS_AGE_FREE);
992 [ # # ]: 0 : if (shared) {
993 : 0 : param->nb_cnts = 0;
994 : 0 : param->accumulator_hits = 0;
995 : 0 : param->accumulator_cnt = 0;
996 : 0 : flow_idx = age_idx;
997 : : } else {
998 : 0 : param->nb_cnts = 1;
999 : : }
1000 [ # # ]: 0 : param->context = age->context ? age->context :
1001 : 0 : (void *)(uintptr_t)flow_idx;
1002 : 0 : param->timeout = age->timeout;
1003 : 0 : param->queue_id = queue_id;
1004 : 0 : param->accumulator_last_hits = 0;
1005 : 0 : param->own_cnt_index = 0;
1006 : 0 : param->sec_since_last_hit = 0;
1007 : 0 : param->state = HWS_AGE_CANDIDATE;
1008 : 0 : return age_idx;
1009 : : }
1010 : :
1011 : : /**
1012 : : * Update indirect AGE action parameter.
1013 : : *
1014 : : * @param[in] priv
1015 : : * Pointer to the port private data structure.
1016 : : * @param[in] idx
1017 : : * Index of AGE parameter.
1018 : : * @param[in] update
1019 : : * Update value.
1020 : : * @param[out] error
1021 : : * Pointer to error structure.
1022 : : *
1023 : : * @return
1024 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
1025 : : */
1026 : : int
1027 : 0 : mlx5_hws_age_action_update(struct mlx5_priv *priv, uint32_t idx,
1028 : : const void *update, struct rte_flow_error *error)
1029 : : {
1030 : : const struct rte_flow_update_age *update_ade = update;
1031 : 0 : struct mlx5_age_info *age_info = GET_PORT_AGE_INFO(priv);
1032 : 0 : struct mlx5_indexed_pool *ipool = age_info->ages_ipool;
1033 : 0 : struct mlx5_hws_age_param *param = mlx5_ipool_get(ipool, idx);
1034 : : bool sec_since_last_hit_reset = false;
1035 : : bool state_update = false;
1036 : :
1037 [ # # ]: 0 : if (param == NULL)
1038 : 0 : return rte_flow_error_set(error, EINVAL,
1039 : : RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
1040 : : "invalid AGE parameter index");
1041 [ # # ]: 0 : if (update_ade->timeout_valid) {
1042 : 0 : uint32_t old_timeout = rte_atomic_exchange_explicit(¶m->timeout,
1043 : : update_ade->timeout,
1044 : : rte_memory_order_relaxed);
1045 : :
1046 [ # # ]: 0 : if (old_timeout == 0)
1047 : : sec_since_last_hit_reset = true;
1048 [ # # ]: 0 : else if (old_timeout < update_ade->timeout ||
1049 [ # # ]: 0 : update_ade->timeout == 0)
1050 : : /*
1051 : : * When timeout is increased, aged-out flows might be
1052 : : * active again and state should be updated accordingly.
1053 : : * When new timeout is 0, we update the state for not
1054 : : * reporting aged-out stopped.
1055 : : */
1056 : : state_update = true;
1057 : : }
1058 [ # # ]: 0 : if (update_ade->touch) {
1059 : : sec_since_last_hit_reset = true;
1060 : : state_update = true;
1061 : : }
1062 [ # # ]: 0 : if (sec_since_last_hit_reset)
1063 : 0 : rte_atomic_store_explicit(¶m->sec_since_last_hit, 0,
1064 : : rte_memory_order_relaxed);
1065 [ # # ]: 0 : if (state_update) {
1066 : : uint16_t expected = HWS_AGE_AGED_OUT_NOT_REPORTED;
1067 : :
1068 : : /*
1069 : : * Change states of aged-out flows to active:
1070 : : * - AGED_OUT_NOT_REPORTED -> CANDIDATE_INSIDE_RING
1071 : : * - AGED_OUT_REPORTED -> CANDIDATE
1072 : : */
1073 [ # # ]: 0 : if (!rte_atomic_compare_exchange_strong_explicit(¶m->state, &expected,
1074 : : HWS_AGE_CANDIDATE_INSIDE_RING,
1075 : : rte_memory_order_relaxed,
1076 [ # # ]: 0 : rte_memory_order_relaxed) &&
1077 : : expected == HWS_AGE_AGED_OUT_REPORTED)
1078 : 0 : rte_atomic_store_explicit(¶m->state, HWS_AGE_CANDIDATE,
1079 : : rte_memory_order_relaxed);
1080 : : }
1081 : : return 0;
1082 : : }
1083 : :
1084 : : /**
1085 : : * Get the AGE context if the aged-out index is still valid.
1086 : : *
1087 : : * @param priv
1088 : : * Pointer to the port private data structure.
1089 : : * @param idx
1090 : : * Index of AGE parameter.
1091 : : *
1092 : : * @return
1093 : : * AGE context if the index is still aged-out, NULL otherwise.
1094 : : */
1095 : : void *
1096 : 0 : mlx5_hws_age_context_get(struct mlx5_priv *priv, uint32_t idx)
1097 : : {
1098 : 0 : struct mlx5_age_info *age_info = GET_PORT_AGE_INFO(priv);
1099 : 0 : struct mlx5_indexed_pool *ipool = age_info->ages_ipool;
1100 : 0 : struct mlx5_hws_age_param *param = mlx5_ipool_get(ipool, idx);
1101 : : uint16_t expected = HWS_AGE_AGED_OUT_NOT_REPORTED;
1102 : :
1103 : : MLX5_ASSERT(param != NULL);
1104 [ # # ]: 0 : if (rte_atomic_compare_exchange_strong_explicit(¶m->state, &expected,
1105 : : HWS_AGE_AGED_OUT_REPORTED,
1106 : : rte_memory_order_relaxed, rte_memory_order_relaxed))
1107 : 0 : return param->context;
1108 [ # # # ]: 0 : switch (expected) {
1109 : 0 : case HWS_AGE_FREE:
1110 : : /*
1111 : : * This AGE couldn't have been destroyed since it was inside
1112 : : * the ring. Its state has updated, and now it is actually
1113 : : * destroyed.
1114 : : */
1115 : 0 : mlx5_hws_age_param_free(priv, param->own_cnt_index, ipool, idx);
1116 : 0 : break;
1117 : 0 : case HWS_AGE_CANDIDATE_INSIDE_RING:
1118 : 0 : rte_atomic_store_explicit(¶m->state, HWS_AGE_CANDIDATE,
1119 : : rte_memory_order_relaxed);
1120 : 0 : break;
1121 : : case HWS_AGE_CANDIDATE:
1122 : : /*
1123 : : * Only BG thread pushes to ring and it never pushes this state.
1124 : : * When AGE inside the ring becomes candidate, it has a special
1125 : : * state called HWS_AGE_CANDIDATE_INSIDE_RING.
1126 : : * Fall-through.
1127 : : */
1128 : : case HWS_AGE_AGED_OUT_REPORTED:
1129 : : /*
1130 : : * Only this thread (doing query) may write this state, and it
1131 : : * happens only after the query thread takes it out of the ring.
1132 : : * Fall-through.
1133 : : */
1134 : : case HWS_AGE_AGED_OUT_NOT_REPORTED:
1135 : : /*
1136 : : * In this case the compare return true and function return
1137 : : * the context immediately.
1138 : : * Fall-through.
1139 : : */
1140 : : default:
1141 : : MLX5_ASSERT(0);
1142 : : break;
1143 : : }
1144 : : return NULL;
1145 : : }
1146 : :
1147 : : #ifdef RTE_ARCH_64
1148 : : #define MLX5_HWS_AGED_OUT_RING_SIZE_MAX UINT32_MAX
1149 : : #else
1150 : : #define MLX5_HWS_AGED_OUT_RING_SIZE_MAX RTE_BIT32(8)
1151 : : #endif
1152 : :
1153 : : /**
1154 : : * Get the size of aged out ring list for each queue.
1155 : : *
1156 : : * The size is one percent of nb_counters divided by nb_queues.
1157 : : * The ring size must be power of 2, so it align up to power of 2.
1158 : : * In 32 bit systems, the size is limited by 256.
1159 : : *
1160 : : * This function is called when RTE_FLOW_PORT_FLAG_STRICT_QUEUE is on.
1161 : : *
1162 : : * @param nb_counters
1163 : : * Final number of allocated counter in the pool.
1164 : : * @param nb_queues
1165 : : * Number of HWS queues in this port.
1166 : : *
1167 : : * @return
1168 : : * Size of aged out ring per queue.
1169 : : */
1170 : : static __rte_always_inline uint32_t
1171 : : mlx5_hws_aged_out_q_ring_size_get(uint32_t nb_counters, uint32_t nb_queues)
1172 : : {
1173 : 0 : uint32_t size = rte_align32pow2((nb_counters / 100) / nb_queues);
1174 : : uint32_t max_size = MLX5_HWS_AGED_OUT_RING_SIZE_MAX;
1175 : :
1176 : : return RTE_MIN(size, max_size);
1177 : : }
1178 : :
1179 : : /**
1180 : : * Get the size of the aged out ring list.
1181 : : *
1182 : : * The size is one percent of nb_counters.
1183 : : * The ring size must be power of 2, so it align up to power of 2.
1184 : : * In 32 bit systems, the size is limited by 256.
1185 : : *
1186 : : * This function is called when RTE_FLOW_PORT_FLAG_STRICT_QUEUE is off.
1187 : : *
1188 : : * @param nb_counters
1189 : : * Final number of allocated counter in the pool.
1190 : : *
1191 : : * @return
1192 : : * Size of the aged out ring list.
1193 : : */
1194 : : static __rte_always_inline uint32_t
1195 : : mlx5_hws_aged_out_ring_size_get(uint32_t nb_counters)
1196 : : {
1197 : 0 : uint32_t size = rte_align32pow2(nb_counters / 100);
1198 : : uint32_t max_size = MLX5_HWS_AGED_OUT_RING_SIZE_MAX;
1199 : :
1200 : : return RTE_MIN(size, max_size);
1201 : : }
1202 : :
1203 : : /**
1204 : : * Initialize the shared aging list information per port.
1205 : : *
1206 : : * @param dev
1207 : : * Pointer to the rte_eth_dev structure.
1208 : : * @param nb_queues
1209 : : * Number of HWS queues.
1210 : : * @param strict_queue
1211 : : * Indicator whether is strict_queue mode.
1212 : : * @param ring_size
1213 : : * Size of aged-out ring for creation.
1214 : : *
1215 : : * @return
1216 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
1217 : : */
1218 : : static int
1219 : 0 : mlx5_hws_age_info_init(struct rte_eth_dev *dev, uint16_t nb_queues,
1220 : : bool strict_queue, uint32_t ring_size)
1221 : : {
1222 : 0 : struct mlx5_priv *priv = dev->data->dev_private;
1223 : 0 : struct mlx5_age_info *age_info = GET_PORT_AGE_INFO(priv);
1224 : : uint32_t flags = RING_F_SP_ENQ | RING_F_SC_DEQ | RING_F_EXACT_SZ;
1225 : : char mz_name[RTE_MEMZONE_NAMESIZE];
1226 : : struct rte_ring *r = NULL;
1227 : : uint32_t qidx;
1228 : :
1229 : 0 : age_info->flags = 0;
1230 [ # # ]: 0 : if (strict_queue) {
1231 : 0 : size_t size = sizeof(*age_info->hw_q_age) +
1232 : : sizeof(struct rte_ring *) * nb_queues;
1233 : :
1234 : 0 : age_info->hw_q_age = mlx5_malloc(MLX5_MEM_ANY | MLX5_MEM_ZERO,
1235 : : size, 0, SOCKET_ID_ANY);
1236 [ # # ]: 0 : if (age_info->hw_q_age == NULL)
1237 : : return -ENOMEM;
1238 [ # # ]: 0 : for (qidx = 0; qidx < nb_queues; ++qidx) {
1239 : 0 : snprintf(mz_name, sizeof(mz_name),
1240 : : "port_%u_queue_%u_aged_out_ring",
1241 : 0 : dev->data->port_id, qidx);
1242 : 0 : r = rte_ring_create(mz_name, ring_size, SOCKET_ID_ANY,
1243 : : flags);
1244 [ # # ]: 0 : if (r == NULL) {
1245 : 0 : DRV_LOG(ERR, "\"%s\" creation failed: %s",
1246 : : mz_name, rte_strerror(rte_errno));
1247 : 0 : goto error;
1248 : : }
1249 : 0 : age_info->hw_q_age->aged_lists[qidx] = r;
1250 : 0 : DRV_LOG(DEBUG,
1251 : : "\"%s\" is successfully created (size=%u).",
1252 : : mz_name, ring_size);
1253 : : }
1254 : 0 : age_info->hw_q_age->nb_rings = nb_queues;
1255 : : } else {
1256 : 0 : snprintf(mz_name, sizeof(mz_name), "port_%u_aged_out_ring",
1257 : 0 : dev->data->port_id);
1258 : 0 : r = rte_ring_create(mz_name, ring_size, SOCKET_ID_ANY, flags);
1259 [ # # ]: 0 : if (r == NULL) {
1260 : 0 : DRV_LOG(ERR, "\"%s\" creation failed: %s", mz_name,
1261 : : rte_strerror(rte_errno));
1262 : 0 : return -rte_errno;
1263 : : }
1264 : 0 : age_info->hw_age.aged_list = r;
1265 : 0 : DRV_LOG(DEBUG, "\"%s\" is successfully created (size=%u).",
1266 : : mz_name, ring_size);
1267 : : /* In non "strict_queue" mode, initialize the event. */
1268 : 0 : MLX5_AGE_SET(age_info, MLX5_AGE_TRIGGER);
1269 : : }
1270 : : return 0;
1271 : : error:
1272 : : MLX5_ASSERT(strict_queue);
1273 [ # # ]: 0 : while (qidx--)
1274 : 0 : rte_ring_free(age_info->hw_q_age->aged_lists[qidx]);
1275 : 0 : mlx5_free(age_info->hw_q_age);
1276 : 0 : return -1;
1277 : : }
1278 : :
1279 : : /**
1280 : : * Cleanup aged-out ring before destroying.
1281 : : *
1282 : : * @param priv
1283 : : * Pointer to port private object.
1284 : : * @param r
1285 : : * Pointer to aged-out ring object.
1286 : : */
1287 : : static void
1288 : 0 : mlx5_hws_aged_out_ring_cleanup(struct mlx5_priv *priv, struct rte_ring *r)
1289 : : {
1290 : 0 : int ring_size = rte_ring_count(r);
1291 : :
1292 [ # # ]: 0 : while (ring_size > 0) {
1293 [ # # # # : 0 : uint32_t age_idx = 0;
# ]
1294 : :
1295 : : if (rte_ring_dequeue_elem(r, &age_idx, sizeof(uint32_t)) < 0)
1296 : : break;
1297 : : /* get the AGE context if the aged-out index is still valid. */
1298 : 0 : mlx5_hws_age_context_get(priv, age_idx);
1299 : 0 : ring_size--;
1300 : : }
1301 : 0 : rte_ring_free(r);
1302 : 0 : }
1303 : :
1304 : : /**
1305 : : * Destroy the shared aging list information per port.
1306 : : *
1307 : : * @param priv
1308 : : * Pointer to port private object.
1309 : : */
1310 : : static void
1311 : 0 : mlx5_hws_age_info_destroy(struct mlx5_priv *priv)
1312 : : {
1313 : 0 : struct mlx5_age_info *age_info = GET_PORT_AGE_INFO(priv);
1314 : 0 : uint16_t nb_queues = age_info->hw_q_age->nb_rings;
1315 : : struct rte_ring *r;
1316 : :
1317 [ # # ]: 0 : if (priv->hws_strict_queue) {
1318 : : uint32_t qidx;
1319 : :
1320 [ # # ]: 0 : for (qidx = 0; qidx < nb_queues; ++qidx) {
1321 : 0 : r = age_info->hw_q_age->aged_lists[qidx];
1322 : 0 : mlx5_hws_aged_out_ring_cleanup(priv, r);
1323 : : }
1324 : 0 : mlx5_free(age_info->hw_q_age);
1325 : : } else {
1326 : : r = age_info->hw_age.aged_list;
1327 : 0 : mlx5_hws_aged_out_ring_cleanup(priv, r);
1328 : : }
1329 : 0 : }
1330 : :
1331 : : /**
1332 : : * Initialize the aging mechanism per port.
1333 : : *
1334 : : * @param dev
1335 : : * Pointer to the rte_eth_dev structure.
1336 : : * @param attr
1337 : : * Port configuration attributes.
1338 : : * @param nb_queues
1339 : : * Number of HWS queues.
1340 : : *
1341 : : * @return
1342 : : * 0 on success, a negative errno value otherwise and rte_errno is set.
1343 : : */
1344 : : int
1345 : 0 : mlx5_hws_age_pool_init(struct rte_eth_dev *dev,
1346 : : uint32_t nb_aging_objects,
1347 : : uint16_t nb_queues,
1348 : : bool strict_queue)
1349 : : {
1350 : 0 : struct mlx5_priv *priv = dev->data->dev_private;
1351 : 0 : struct mlx5_age_info *age_info = GET_PORT_AGE_INFO(priv);
1352 : 0 : struct mlx5_indexed_pool_config cfg = {
1353 : : .size =
1354 : : RTE_CACHE_LINE_ROUNDUP(sizeof(struct mlx5_hws_age_param)),
1355 : : .trunk_size = 1 << 12,
1356 : : .per_core_cache = 1 << 13,
1357 : : .need_lock = 1,
1358 : 0 : .release_mem_en = !!priv->sh->config.reclaim_mode,
1359 : : .malloc = mlx5_malloc,
1360 : : .free = mlx5_free,
1361 : : .type = "mlx5_hws_age_pool",
1362 : : };
1363 : : uint32_t nb_alloc_cnts;
1364 : : uint32_t rsize;
1365 : : uint32_t nb_ages_updated;
1366 : : int ret;
1367 : :
1368 : : MLX5_ASSERT(priv->hws_cpool);
1369 [ # # ]: 0 : nb_alloc_cnts = mlx5_hws_cnt_pool_get_size(priv->hws_cpool);
1370 [ # # ]: 0 : if (strict_queue) {
1371 : 0 : rsize = mlx5_hws_aged_out_q_ring_size_get(nb_alloc_cnts,
1372 : : nb_queues);
1373 : 0 : nb_ages_updated = rsize * nb_queues + nb_aging_objects;
1374 : : } else {
1375 : : rsize = mlx5_hws_aged_out_ring_size_get(nb_alloc_cnts);
1376 : 0 : nb_ages_updated = rsize + nb_aging_objects;
1377 : : }
1378 : 0 : ret = mlx5_hws_age_info_init(dev, nb_queues, strict_queue, rsize);
1379 [ # # ]: 0 : if (ret < 0)
1380 : : return ret;
1381 : 0 : cfg.max_idx = rte_align32pow2(nb_ages_updated);
1382 [ # # ]: 0 : if (cfg.max_idx <= cfg.trunk_size) {
1383 : 0 : cfg.per_core_cache = 0;
1384 : 0 : cfg.trunk_size = cfg.max_idx;
1385 [ # # ]: 0 : } else if (cfg.max_idx <= MLX5_HW_IPOOL_SIZE_THRESHOLD) {
1386 : 0 : cfg.per_core_cache = MLX5_HW_IPOOL_CACHE_MIN;
1387 : : }
1388 : 0 : age_info->ages_ipool = mlx5_ipool_create(&cfg);
1389 [ # # ]: 0 : if (age_info->ages_ipool == NULL) {
1390 : 0 : mlx5_hws_age_info_destroy(priv);
1391 : 0 : rte_errno = ENOMEM;
1392 : 0 : return -rte_errno;
1393 : : }
1394 : 0 : priv->hws_age_req = 1;
1395 : 0 : return 0;
1396 : : }
1397 : :
1398 : : /**
1399 : : * Cleanup all aging resources per port.
1400 : : *
1401 : : * @param priv
1402 : : * Pointer to port private object.
1403 : : */
1404 : : void
1405 : 0 : mlx5_hws_age_pool_destroy(struct mlx5_priv *priv)
1406 : : {
1407 : 0 : struct mlx5_age_info *age_info = GET_PORT_AGE_INFO(priv);
1408 : :
1409 : 0 : rte_spinlock_lock(&priv->sh->cpool_lock);
1410 : : MLX5_ASSERT(priv->hws_age_req);
1411 : 0 : mlx5_hws_age_info_destroy(priv);
1412 : 0 : mlx5_ipool_destroy(age_info->ages_ipool);
1413 : 0 : age_info->ages_ipool = NULL;
1414 : 0 : priv->hws_age_req = 0;
1415 : 0 : rte_spinlock_unlock(&priv->sh->cpool_lock);
1416 : 0 : }
1417 : :
1418 : : #endif
|