Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2017 Intel Corporation
3 : : */
4 : :
5 : : #include <stdio.h>
6 : : #include <stdlib.h>
7 : : #include <inttypes.h>
8 : : #include <math.h>
9 : :
10 : : #include <rte_eal.h>
11 : : #include <rte_common.h>
12 : : #include <rte_dev.h>
13 : : #include <rte_launch.h>
14 : : #include <rte_bbdev.h>
15 : : #include <rte_cycles.h>
16 : : #include <rte_lcore.h>
17 : : #include <rte_malloc.h>
18 : : #include <rte_random.h>
19 : : #include <rte_hexdump.h>
20 : : #include <rte_interrupts.h>
21 : :
22 : : #include "main.h"
23 : : #include "test_bbdev_vector.h"
24 : :
25 : : #define GET_SOCKET(socket_id) (((socket_id) == SOCKET_ID_ANY) ? 0 : (socket_id))
26 : :
27 : : #define MAX_QUEUES RTE_MAX_LCORE
28 : : #define TEST_REPETITIONS 100
29 : : #define TIME_OUT_POLL 1e9
30 : : #define WAIT_OFFLOAD_US 1000
31 : :
32 : : #ifdef RTE_BASEBAND_FPGA_LTE_FEC
33 : : #include <fpga_lte_fec.h>
34 : : #define FPGA_LTE_PF_DRIVER_NAME ("intel_fpga_lte_fec_pf")
35 : : #define FPGA_LTE_VF_DRIVER_NAME ("intel_fpga_lte_fec_vf")
36 : : #define VF_UL_4G_QUEUE_VALUE 4
37 : : #define VF_DL_4G_QUEUE_VALUE 4
38 : : #define UL_4G_BANDWIDTH 3
39 : : #define DL_4G_BANDWIDTH 3
40 : : #define UL_4G_LOAD_BALANCE 128
41 : : #define DL_4G_LOAD_BALANCE 128
42 : : #define FLR_4G_TIMEOUT 610
43 : : #endif
44 : :
45 : : #ifdef RTE_BASEBAND_FPGA_5GNR_FEC
46 : : #include <rte_pmd_fpga_5gnr_fec.h>
47 : : #define FPGA_5GNR_PF_DRIVER_NAME ("intel_fpga_5gnr_fec_pf")
48 : : #define FPGA_5GNR_VF_DRIVER_NAME ("intel_fpga_5gnr_fec_vf")
49 : : #define VF_UL_5G_QUEUE_VALUE 4
50 : : #define VF_DL_5G_QUEUE_VALUE 4
51 : : #define UL_5G_BANDWIDTH 3
52 : : #define DL_5G_BANDWIDTH 3
53 : : #define UL_5G_LOAD_BALANCE 128
54 : : #define DL_5G_LOAD_BALANCE 128
55 : : #endif
56 : :
57 : : #ifdef RTE_BASEBAND_ACC
58 : : #include <rte_acc_cfg.h>
59 : : #define ACC100PF_DRIVER_NAME ("intel_acc100_pf")
60 : : #define ACC100VF_DRIVER_NAME ("intel_acc100_vf")
61 : : #define ACC100_QMGR_NUM_AQS 16
62 : : #define ACC100_QMGR_NUM_QGS 2
63 : : #define ACC100_QMGR_AQ_DEPTH 5
64 : : #define ACC100_QMGR_INVALID_IDX -1
65 : : #define ACC100_QMGR_RR 1
66 : : #define ACC100_QOS_GBR 0
67 : : #define VRBPF_DRIVER_NAME ("intel_vran_boost_pf")
68 : : #define VRBVF_DRIVER_NAME ("intel_vran_boost_vf")
69 : : #define VRB_QMGR_NUM_AQS 16
70 : : #define VRB_QMGR_NUM_QGS 2
71 : : #define VRB_QMGR_AQ_DEPTH 5
72 : : #define VRB_QMGR_INVALID_IDX -1
73 : : #define VRB_QMGR_RR 1
74 : : #define VRB_QOS_GBR 0
75 : : #endif
76 : :
77 : : #define OPS_CACHE_SIZE 256U
78 : : #define OPS_POOL_SIZE_MIN 511U /* 0.5K per queue */
79 : :
80 : : #define SYNC_WAIT 0
81 : : #define SYNC_START 1
82 : :
83 : : #define INVALID_QUEUE_ID -1
84 : : /* Increment for next code block in external HARQ memory */
85 : : #define HARQ_INCR 32768
86 : : /* Headroom for filler LLRs insertion in HARQ buffer */
87 : : #define FILLER_HEADROOM 2048
88 : : /* Constants from K0 computation from 3GPP 38.212 Table 5.4.2.1-2 */
89 : : #define N_ZC_1 66 /* N = 66 Zc for BG 1 */
90 : : #define N_ZC_2 50 /* N = 50 Zc for BG 2 */
91 : : #define K0_1_1 17 /* K0 fraction numerator for rv 1 and BG 1 */
92 : : #define K0_1_2 13 /* K0 fraction numerator for rv 1 and BG 2 */
93 : : #define K0_2_1 33 /* K0 fraction numerator for rv 2 and BG 1 */
94 : : #define K0_2_2 25 /* K0 fraction numerator for rv 2 and BG 2 */
95 : : #define K0_3_1 56 /* K0 fraction numerator for rv 3 and BG 1 */
96 : : #define K0_3_2 43 /* K0 fraction numerator for rv 3 and BG 2 */
97 : : #define NUM_SC_PER_RB (12) /* Number of subcarriers in a RB in 3GPP. */
98 : : #define BITS_PER_LLR (8) /* Number of bits in a LLR. */
99 : :
100 : : #define HARQ_MEM_TOLERANCE 256
101 : : static struct test_bbdev_vector test_vector;
102 : :
103 : : /* Switch between PMD and Interrupt for throughput TC */
104 : : static bool intr_enabled;
105 : :
106 : : /* LLR arithmetic representation for numerical conversion */
107 : : static int ldpc_llr_decimals;
108 : : static int ldpc_llr_size;
109 : : /* Keep track of the LDPC decoder device capability flag */
110 : : static uint32_t ldpc_cap_flags;
111 : : /* FFT window width predefined on device and on vector. */
112 : : static int fft_window_width_dev;
113 : :
114 : : bool dump_ops = true;
115 : :
116 : : /* Represents tested active devices */
117 : : static struct active_device {
118 : : const char *driver_name;
119 : : uint8_t dev_id;
120 : : uint16_t supported_ops;
121 : : uint16_t queue_ids[MAX_QUEUES];
122 : : uint16_t nb_queues;
123 : : struct rte_mempool *ops_mempool;
124 : : struct rte_mempool *in_mbuf_pool;
125 : : struct rte_mempool *hard_out_mbuf_pool;
126 : : struct rte_mempool *soft_out_mbuf_pool;
127 : : struct rte_mempool *harq_in_mbuf_pool;
128 : : struct rte_mempool *harq_out_mbuf_pool;
129 : : } active_devs[RTE_BBDEV_MAX_DEVS];
130 : :
131 : : static uint8_t nb_active_devs;
132 : :
133 : : /* Data buffers used by BBDEV ops */
134 : : struct test_buffers {
135 : : struct rte_bbdev_op_data *inputs;
136 : : struct rte_bbdev_op_data *hard_outputs;
137 : : struct rte_bbdev_op_data *soft_outputs;
138 : : struct rte_bbdev_op_data *harq_inputs;
139 : : struct rte_bbdev_op_data *harq_outputs;
140 : : };
141 : :
142 : : /* Operation parameters specific for given test case */
143 : : struct test_op_params {
144 : : struct rte_mempool *mp;
145 : : struct rte_bbdev_dec_op *ref_dec_op;
146 : : struct rte_bbdev_enc_op *ref_enc_op;
147 : : struct rte_bbdev_fft_op *ref_fft_op;
148 : : struct rte_bbdev_mldts_op *ref_mldts_op;
149 : : uint16_t burst_sz;
150 : : uint16_t num_to_process;
151 : : uint16_t num_lcores;
152 : : int vector_mask;
153 : : RTE_ATOMIC(uint16_t) sync;
154 : : struct test_buffers q_bufs[RTE_MAX_NUMA_NODES][MAX_QUEUES];
155 : : };
156 : :
157 : : /* Contains per lcore params */
158 : : struct thread_params {
159 : : uint8_t dev_id;
160 : : uint16_t queue_id;
161 : : uint32_t lcore_id;
162 : : uint64_t start_time;
163 : : double ops_per_sec;
164 : : double mbps;
165 : : uint8_t iter_count;
166 : : double iter_average;
167 : : double bler;
168 : : RTE_ATOMIC(uint16_t) nb_dequeued;
169 : : RTE_ATOMIC(int16_t) processing_status;
170 : : RTE_ATOMIC(uint16_t) burst_sz;
171 : : struct test_op_params *op_params;
172 : : struct rte_bbdev_dec_op *dec_ops[MAX_BURST];
173 : : struct rte_bbdev_enc_op *enc_ops[MAX_BURST];
174 : : struct rte_bbdev_fft_op *fft_ops[MAX_BURST];
175 : : struct rte_bbdev_mldts_op *mldts_ops[MAX_BURST];
176 : : };
177 : :
178 : : /* Stores time statistics */
179 : : struct test_time_stats {
180 : : /* Stores software enqueue total working time */
181 : : uint64_t enq_sw_total_time;
182 : : /* Stores minimum value of software enqueue working time */
183 : : uint64_t enq_sw_min_time;
184 : : /* Stores maximum value of software enqueue working time */
185 : : uint64_t enq_sw_max_time;
186 : : /* Stores turbo enqueue total working time */
187 : : uint64_t enq_acc_total_time;
188 : : /* Stores minimum value of accelerator enqueue working time */
189 : : uint64_t enq_acc_min_time;
190 : : /* Stores maximum value of accelerator enqueue working time */
191 : : uint64_t enq_acc_max_time;
192 : : /* Stores dequeue total working time */
193 : : uint64_t deq_total_time;
194 : : /* Stores minimum value of dequeue working time */
195 : : uint64_t deq_min_time;
196 : : /* Stores maximum value of dequeue working time */
197 : : uint64_t deq_max_time;
198 : : };
199 : :
200 : : typedef int (test_case_function)(struct active_device *ad,
201 : : struct test_op_params *op_params);
202 : :
203 : : /* Get device status before timeout exit */
204 : : static inline void
205 : 0 : timeout_exit(uint8_t dev_id)
206 : : {
207 : : struct rte_bbdev_info info;
208 : 0 : rte_bbdev_info_get(dev_id, &info);
209 : 0 : printf("Device Status %s\n", rte_bbdev_device_status_str(info.drv.device_status));
210 : 0 : }
211 : :
212 : : static inline void
213 : : mbuf_reset(struct rte_mbuf *m)
214 : : {
215 : 0 : m->pkt_len = 0;
216 : :
217 : : do {
218 : 0 : m->data_len = 0;
219 : 0 : m = m->next;
220 : 0 : } while (m != NULL);
221 : : }
222 : :
223 : : /* Read flag value 0/1 from bitmap */
224 : : static inline bool
225 : : check_bit(uint32_t bitmap, uint32_t bitmask)
226 : : {
227 : 0 : return bitmap & bitmask;
228 : : }
229 : :
230 : : static inline void
231 : : set_avail_op(struct active_device *ad, enum rte_bbdev_op_type op_type)
232 : : {
233 : 0 : ad->supported_ops |= (1 << op_type);
234 : : }
235 : :
236 : : static inline bool
237 : : is_avail_op(struct active_device *ad, enum rte_bbdev_op_type op_type)
238 : : {
239 : 0 : return ad->supported_ops & (1 << op_type);
240 : : }
241 : :
242 : : static inline bool
243 : : flags_match(uint32_t flags_req, uint32_t flags_present)
244 : : {
245 : 0 : return (flags_req & flags_present) == flags_req;
246 : : }
247 : :
248 : : static void
249 : : clear_soft_out_cap(uint32_t *op_flags)
250 : : {
251 : 0 : *op_flags &= ~RTE_BBDEV_TURBO_SOFT_OUTPUT;
252 : : *op_flags &= ~RTE_BBDEV_TURBO_POS_LLR_1_BIT_SOFT_OUT;
253 : 0 : *op_flags &= ~RTE_BBDEV_TURBO_NEG_LLR_1_BIT_SOFT_OUT;
254 : 0 : }
255 : :
256 : : /* This API is to convert all the test vector op data entries
257 : : * to big endian format. It is used when the device supports
258 : : * the input in the big endian format.
259 : : */
260 : : static inline void
261 : 0 : convert_op_data_to_be(void)
262 : : {
263 : : struct op_data_entries *op;
264 : : enum op_data_type type;
265 : : uint8_t nb_segs, *rem_data, temp;
266 : : uint32_t *data, len;
267 : : int complete, rem, i, j;
268 : :
269 : 0 : for (type = DATA_INPUT; type < DATA_NUM_TYPES; ++type) {
270 : 0 : nb_segs = test_vector.entries[type].nb_segments;
271 : : op = &test_vector.entries[type];
272 : :
273 : : /* Invert byte endianness for all the segments */
274 : 0 : for (i = 0; i < nb_segs; ++i) {
275 : 0 : len = op->segments[i].length;
276 : 0 : data = op->segments[i].addr;
277 : :
278 : : /* Swap complete u32 bytes */
279 : 0 : complete = len / 4;
280 : 0 : for (j = 0; j < complete; j++)
281 : 0 : data[j] = rte_bswap32(data[j]);
282 : :
283 : : /* Swap any remaining bytes */
284 : 0 : rem = len % 4;
285 : 0 : rem_data = (uint8_t *)&data[j];
286 : 0 : for (j = 0; j < rem/2; j++) {
287 : 0 : temp = rem_data[j];
288 : 0 : rem_data[j] = rem_data[rem - j - 1];
289 : 0 : rem_data[rem - j - 1] = temp;
290 : : }
291 : : }
292 : : }
293 : 0 : }
294 : :
295 : : static int
296 : 0 : check_dev_cap(const struct rte_bbdev_info *dev_info)
297 : : {
298 : : unsigned int i;
299 : : unsigned int nb_inputs, nb_soft_outputs, nb_hard_outputs,
300 : : nb_harq_inputs, nb_harq_outputs;
301 : 0 : const struct rte_bbdev_op_cap *op_cap = dev_info->drv.capabilities;
302 : 0 : uint8_t dev_data_endianness = dev_info->drv.data_endianness;
303 : :
304 : 0 : nb_inputs = test_vector.entries[DATA_INPUT].nb_segments;
305 : 0 : nb_soft_outputs = test_vector.entries[DATA_SOFT_OUTPUT].nb_segments;
306 : 0 : nb_hard_outputs = test_vector.entries[DATA_HARD_OUTPUT].nb_segments;
307 : 0 : nb_harq_inputs = test_vector.entries[DATA_HARQ_INPUT].nb_segments;
308 : 0 : nb_harq_outputs = test_vector.entries[DATA_HARQ_OUTPUT].nb_segments;
309 : :
310 : 0 : for (i = 0; op_cap->type != RTE_BBDEV_OP_NONE; ++i, ++op_cap) {
311 : 0 : if (op_cap->type != test_vector.op_type)
312 : 0 : continue;
313 : :
314 : 0 : if (dev_data_endianness == RTE_BIG_ENDIAN)
315 : 0 : convert_op_data_to_be();
316 : :
317 : 0 : if (op_cap->type == RTE_BBDEV_OP_TURBO_DEC) {
318 : : const struct rte_bbdev_op_cap_turbo_dec *cap =
319 : : &op_cap->cap.turbo_dec;
320 : : /* Ignore lack of soft output capability, just skip
321 : : * checking if soft output is valid.
322 : : */
323 : 0 : if ((test_vector.turbo_dec.op_flags &
324 : 0 : RTE_BBDEV_TURBO_SOFT_OUTPUT) &&
325 : 0 : !(cap->capability_flags &
326 : : RTE_BBDEV_TURBO_SOFT_OUTPUT)) {
327 : : printf(
328 : : "INFO: Device \"%s\" does not support soft output - soft output flags will be ignored.\n",
329 : 0 : dev_info->dev_name);
330 : : clear_soft_out_cap(
331 : : &test_vector.turbo_dec.op_flags);
332 : : }
333 : :
334 : 0 : if (!flags_match(test_vector.turbo_dec.op_flags,
335 : 0 : cap->capability_flags))
336 : : return TEST_FAILED;
337 : 0 : if (nb_inputs > cap->num_buffers_src) {
338 : 0 : printf("Too many inputs defined: %u, max: %u\n",
339 : : nb_inputs, cap->num_buffers_src);
340 : 0 : return TEST_FAILED;
341 : : }
342 : 0 : if (nb_soft_outputs > cap->num_buffers_soft_out &&
343 : 0 : (test_vector.turbo_dec.op_flags &
344 : : RTE_BBDEV_TURBO_SOFT_OUTPUT)) {
345 : 0 : printf(
346 : : "Too many soft outputs defined: %u, max: %u\n",
347 : : nb_soft_outputs,
348 : : cap->num_buffers_soft_out);
349 : 0 : return TEST_FAILED;
350 : : }
351 : 0 : if (nb_hard_outputs > cap->num_buffers_hard_out) {
352 : 0 : printf(
353 : : "Too many hard outputs defined: %u, max: %u\n",
354 : : nb_hard_outputs,
355 : : cap->num_buffers_hard_out);
356 : 0 : return TEST_FAILED;
357 : : }
358 : 0 : if (intr_enabled && !(cap->capability_flags &
359 : : RTE_BBDEV_TURBO_DEC_INTERRUPTS)) {
360 : : printf(
361 : : "Dequeue interrupts are not supported!\n");
362 : 0 : return TEST_FAILED;
363 : : }
364 : :
365 : : return TEST_SUCCESS;
366 : : } else if (op_cap->type == RTE_BBDEV_OP_TURBO_ENC) {
367 : : const struct rte_bbdev_op_cap_turbo_enc *cap =
368 : : &op_cap->cap.turbo_enc;
369 : :
370 : 0 : if (!flags_match(test_vector.turbo_enc.op_flags,
371 : 0 : cap->capability_flags))
372 : : return TEST_FAILED;
373 : 0 : if (nb_inputs > cap->num_buffers_src) {
374 : 0 : printf("Too many inputs defined: %u, max: %u\n",
375 : : nb_inputs, cap->num_buffers_src);
376 : 0 : return TEST_FAILED;
377 : : }
378 : 0 : if (nb_hard_outputs > cap->num_buffers_dst) {
379 : 0 : printf(
380 : : "Too many hard outputs defined: %u, max: %u\n",
381 : : nb_hard_outputs, cap->num_buffers_dst);
382 : 0 : return TEST_FAILED;
383 : : }
384 : 0 : if (intr_enabled && !(cap->capability_flags &
385 : : RTE_BBDEV_TURBO_ENC_INTERRUPTS)) {
386 : : printf(
387 : : "Dequeue interrupts are not supported!\n");
388 : 0 : return TEST_FAILED;
389 : : }
390 : :
391 : : return TEST_SUCCESS;
392 : : } else if (op_cap->type == RTE_BBDEV_OP_LDPC_ENC) {
393 : : const struct rte_bbdev_op_cap_ldpc_enc *cap =
394 : : &op_cap->cap.ldpc_enc;
395 : :
396 : 0 : if (!flags_match(test_vector.ldpc_enc.op_flags,
397 : 0 : cap->capability_flags)){
398 : : printf("Flag Mismatch\n");
399 : 0 : return TEST_FAILED;
400 : : }
401 : 0 : if (nb_inputs > cap->num_buffers_src) {
402 : 0 : printf("Too many inputs defined: %u, max: %u\n",
403 : : nb_inputs, cap->num_buffers_src);
404 : 0 : return TEST_FAILED;
405 : : }
406 : 0 : if (nb_hard_outputs > cap->num_buffers_dst) {
407 : 0 : printf(
408 : : "Too many hard outputs defined: %u, max: %u\n",
409 : : nb_hard_outputs, cap->num_buffers_dst);
410 : 0 : return TEST_FAILED;
411 : : }
412 : 0 : if (intr_enabled && !(cap->capability_flags &
413 : : RTE_BBDEV_LDPC_ENC_INTERRUPTS)) {
414 : : printf(
415 : : "Dequeue interrupts are not supported!\n");
416 : 0 : return TEST_FAILED;
417 : : }
418 : :
419 : : return TEST_SUCCESS;
420 : : } else if (op_cap->type == RTE_BBDEV_OP_LDPC_DEC) {
421 : : const struct rte_bbdev_op_cap_ldpc_dec *cap =
422 : : &op_cap->cap.ldpc_dec;
423 : :
424 : 0 : if (!flags_match(test_vector.ldpc_dec.op_flags,
425 : 0 : cap->capability_flags)){
426 : : printf("Flag Mismatch\n");
427 : 0 : return TEST_FAILED;
428 : : }
429 : 0 : if (nb_inputs > cap->num_buffers_src) {
430 : 0 : printf("Too many inputs defined: %u, max: %u\n",
431 : : nb_inputs, cap->num_buffers_src);
432 : 0 : return TEST_FAILED;
433 : : }
434 : 0 : if (nb_hard_outputs > cap->num_buffers_hard_out) {
435 : 0 : printf(
436 : : "Too many hard outputs defined: %u, max: %u\n",
437 : : nb_hard_outputs,
438 : : cap->num_buffers_hard_out);
439 : 0 : return TEST_FAILED;
440 : : }
441 : 0 : if (nb_harq_inputs > cap->num_buffers_hard_out) {
442 : 0 : printf(
443 : : "Too many HARQ inputs defined: %u, max: %u\n",
444 : : nb_harq_inputs,
445 : : cap->num_buffers_hard_out);
446 : 0 : return TEST_FAILED;
447 : : }
448 : 0 : if (nb_harq_outputs > cap->num_buffers_hard_out) {
449 : 0 : printf(
450 : : "Too many HARQ outputs defined: %u, max: %u\n",
451 : : nb_harq_outputs,
452 : : cap->num_buffers_hard_out);
453 : 0 : return TEST_FAILED;
454 : : }
455 : 0 : if (intr_enabled && !(cap->capability_flags &
456 : : RTE_BBDEV_LDPC_DEC_INTERRUPTS)) {
457 : : printf(
458 : : "Dequeue interrupts are not supported!\n");
459 : 0 : return TEST_FAILED;
460 : : }
461 : 0 : if (intr_enabled && (test_vector.ldpc_dec.op_flags &
462 : : (RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE |
463 : : RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE |
464 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK
465 : : ))) {
466 : : printf("Skip loop-back with interrupt\n");
467 : 0 : return TEST_FAILED;
468 : : }
469 : : return TEST_SUCCESS;
470 : : } else if (op_cap->type == RTE_BBDEV_OP_FFT) {
471 : : const struct rte_bbdev_op_cap_fft *cap = &op_cap->cap.fft;
472 : :
473 : 0 : if (!flags_match(test_vector.fft.op_flags, cap->capability_flags)) {
474 : : printf("Flag Mismatch\n");
475 : 0 : return TEST_FAILED;
476 : : }
477 : 0 : if (nb_inputs > cap->num_buffers_src) {
478 : 0 : printf("Too many inputs defined: %u, max: %u\n",
479 : : nb_inputs, cap->num_buffers_src);
480 : 0 : return TEST_FAILED;
481 : : }
482 : : return TEST_SUCCESS;
483 : : } else if (op_cap->type == RTE_BBDEV_OP_MLDTS) {
484 : : const struct rte_bbdev_op_cap_mld *cap = &op_cap->cap.mld;
485 : 0 : if (!flags_match(test_vector.mldts.op_flags, cap->capability_flags)) {
486 : : printf("Flag Mismatch\n");
487 : 0 : return TEST_FAILED;
488 : : }
489 : 0 : if (nb_inputs > cap->num_buffers_src) {
490 : 0 : printf("Too many inputs defined: %u, max: %u\n",
491 : : nb_inputs, cap->num_buffers_src);
492 : 0 : return TEST_FAILED;
493 : : }
494 : : return TEST_SUCCESS;
495 : : }
496 : : }
497 : :
498 : 0 : if ((i == 0) && (test_vector.op_type == RTE_BBDEV_OP_NONE))
499 : 0 : return TEST_SUCCESS; /* Special case for NULL device */
500 : :
501 : : return TEST_FAILED;
502 : : }
503 : :
504 : : /* calculates optimal mempool size not smaller than the val */
505 : : static unsigned int
506 : : optimal_mempool_size(unsigned int val)
507 : : {
508 : : return rte_align32pow2(val + 1) - 1;
509 : : }
510 : :
511 : : /* allocates mbuf mempool for inputs and outputs */
512 : : static struct rte_mempool *
513 : 0 : create_mbuf_pool(struct op_data_entries *entries, uint8_t dev_id,
514 : : int socket_id, unsigned int mbuf_pool_size,
515 : : const char *op_type_str)
516 : : {
517 : : unsigned int i;
518 : : uint32_t max_seg_sz = 0;
519 : : char pool_name[RTE_MEMPOOL_NAMESIZE];
520 : :
521 : : /* find max input segment size */
522 : 0 : for (i = 0; i < entries->nb_segments; ++i)
523 : 0 : if (entries->segments[i].length > max_seg_sz)
524 : : max_seg_sz = entries->segments[i].length;
525 : :
526 : 0 : snprintf(pool_name, sizeof(pool_name), "%s_pool_%u", op_type_str,
527 : : dev_id);
528 : 0 : return rte_pktmbuf_pool_create(pool_name, mbuf_pool_size, 0, 0,
529 : 0 : RTE_MAX(max_seg_sz + RTE_PKTMBUF_HEADROOM
530 : : + FILLER_HEADROOM,
531 : : (unsigned int)RTE_MBUF_DEFAULT_BUF_SIZE), socket_id);
532 : : }
533 : :
534 : : static int
535 : 0 : create_mempools(struct active_device *ad, int socket_id,
536 : : enum rte_bbdev_op_type org_op_type, uint16_t num_ops)
537 : : {
538 : : struct rte_mempool *mp;
539 : : unsigned int ops_pool_size, mbuf_pool_size = 0;
540 : : char pool_name[RTE_MEMPOOL_NAMESIZE];
541 : : const char *op_type_str;
542 : : enum rte_bbdev_op_type op_type = org_op_type;
543 : :
544 : : struct op_data_entries *in = &test_vector.entries[DATA_INPUT];
545 : : struct op_data_entries *hard_out =
546 : : &test_vector.entries[DATA_HARD_OUTPUT];
547 : : struct op_data_entries *soft_out =
548 : : &test_vector.entries[DATA_SOFT_OUTPUT];
549 : : struct op_data_entries *harq_in =
550 : : &test_vector.entries[DATA_HARQ_INPUT];
551 : : struct op_data_entries *harq_out =
552 : : &test_vector.entries[DATA_HARQ_OUTPUT];
553 : :
554 : : /* allocate ops mempool */
555 : 0 : ops_pool_size = optimal_mempool_size(RTE_MAX3(
556 : : /* Ops used plus 1 reference op */
557 : : (unsigned int)(ad->nb_queues * num_ops + 1),
558 : : /* Minimal cache size plus 1 reference op */
559 : : (unsigned int)(1.5 * rte_lcore_count() * OPS_CACHE_SIZE + 1),
560 : : OPS_POOL_SIZE_MIN));
561 : :
562 : 0 : if (org_op_type == RTE_BBDEV_OP_NONE)
563 : : op_type = RTE_BBDEV_OP_TURBO_ENC;
564 : :
565 : 0 : op_type_str = rte_bbdev_op_type_str(op_type);
566 : 0 : TEST_ASSERT_NOT_NULL(op_type_str, "Invalid op type: %u", op_type);
567 : :
568 : 0 : snprintf(pool_name, sizeof(pool_name), "%s_pool_%u", op_type_str,
569 : 0 : ad->dev_id);
570 : 0 : mp = rte_bbdev_op_pool_create(pool_name, op_type,
571 : : ops_pool_size, OPS_CACHE_SIZE, socket_id);
572 : 0 : TEST_ASSERT_NOT_NULL(mp,
573 : : "ERROR Failed to create %u items ops pool for dev %u on socket %u.",
574 : : ops_pool_size,
575 : : ad->dev_id,
576 : : socket_id);
577 : 0 : ad->ops_mempool = mp;
578 : :
579 : : /* Do not create inputs and outputs mbufs for BaseBand Null Device */
580 : 0 : if (org_op_type == RTE_BBDEV_OP_NONE)
581 : : return TEST_SUCCESS;
582 : :
583 : : /* Inputs */
584 : 0 : if (in->nb_segments > 0) {
585 : 0 : mbuf_pool_size = optimal_mempool_size(ops_pool_size *
586 : : in->nb_segments);
587 : 0 : mp = create_mbuf_pool(in, ad->dev_id, socket_id,
588 : : mbuf_pool_size, "in");
589 : 0 : TEST_ASSERT_NOT_NULL(mp,
590 : : "ERROR Failed to create %u items input pktmbuf pool for dev %u on socket %u.",
591 : : mbuf_pool_size,
592 : : ad->dev_id,
593 : : socket_id);
594 : 0 : ad->in_mbuf_pool = mp;
595 : : }
596 : :
597 : : /* Hard outputs */
598 : 0 : if (hard_out->nb_segments > 0) {
599 : 0 : mbuf_pool_size = optimal_mempool_size(ops_pool_size *
600 : : hard_out->nb_segments);
601 : 0 : mp = create_mbuf_pool(hard_out, ad->dev_id, socket_id,
602 : : mbuf_pool_size,
603 : : "hard_out");
604 : 0 : TEST_ASSERT_NOT_NULL(mp,
605 : : "ERROR Failed to create %u items hard output pktmbuf pool for dev %u on socket %u.",
606 : : mbuf_pool_size,
607 : : ad->dev_id,
608 : : socket_id);
609 : 0 : ad->hard_out_mbuf_pool = mp;
610 : : }
611 : :
612 : : /* Soft outputs */
613 : 0 : if (soft_out->nb_segments > 0) {
614 : 0 : mbuf_pool_size = optimal_mempool_size(ops_pool_size *
615 : : soft_out->nb_segments);
616 : 0 : mp = create_mbuf_pool(soft_out, ad->dev_id, socket_id,
617 : : mbuf_pool_size,
618 : : "soft_out");
619 : 0 : TEST_ASSERT_NOT_NULL(mp,
620 : : "ERROR Failed to create %uB soft output pktmbuf pool for dev %u on socket %u.",
621 : : mbuf_pool_size,
622 : : ad->dev_id,
623 : : socket_id);
624 : 0 : ad->soft_out_mbuf_pool = mp;
625 : : }
626 : :
627 : : /* HARQ inputs */
628 : 0 : if (harq_in->nb_segments > 0) {
629 : 0 : mbuf_pool_size = optimal_mempool_size(ops_pool_size *
630 : : harq_in->nb_segments);
631 : 0 : mp = create_mbuf_pool(harq_in, ad->dev_id, socket_id,
632 : : mbuf_pool_size,
633 : : "harq_in");
634 : 0 : TEST_ASSERT_NOT_NULL(mp,
635 : : "ERROR Failed to create %uB harq input pktmbuf pool for dev %u on socket %u.",
636 : : mbuf_pool_size,
637 : : ad->dev_id,
638 : : socket_id);
639 : 0 : ad->harq_in_mbuf_pool = mp;
640 : : }
641 : :
642 : : /* HARQ outputs */
643 : 0 : if (harq_out->nb_segments > 0) {
644 : 0 : mbuf_pool_size = optimal_mempool_size(ops_pool_size *
645 : : harq_out->nb_segments);
646 : 0 : mp = create_mbuf_pool(harq_out, ad->dev_id, socket_id,
647 : : mbuf_pool_size,
648 : : "harq_out");
649 : 0 : TEST_ASSERT_NOT_NULL(mp,
650 : : "ERROR Failed to create %uB harq output pktmbuf pool for dev %u on socket %u.",
651 : : mbuf_pool_size,
652 : : ad->dev_id,
653 : : socket_id);
654 : 0 : ad->harq_out_mbuf_pool = mp;
655 : : }
656 : :
657 : : return TEST_SUCCESS;
658 : : }
659 : :
660 : : static int
661 : 0 : add_bbdev_dev(uint8_t dev_id, struct rte_bbdev_info *info,
662 : : struct test_bbdev_vector *vector)
663 : : {
664 : : int ret;
665 : : unsigned int queue_id;
666 : : struct rte_bbdev_queue_conf qconf;
667 : 0 : struct active_device *ad = &active_devs[nb_active_devs];
668 : : unsigned int nb_queues;
669 : 0 : enum rte_bbdev_op_type op_type = vector->op_type;
670 : :
671 : : /* Configure fpga lte fec with PF & VF values
672 : : * if '-i' flag is set and using fpga device
673 : : */
674 : : #ifdef RTE_BASEBAND_FPGA_LTE_FEC
675 : 0 : if ((get_init_device() == true) &&
676 : 0 : (!strcmp(info->drv.driver_name, FPGA_LTE_PF_DRIVER_NAME))) {
677 : : struct rte_fpga_lte_fec_conf conf;
678 : : unsigned int i;
679 : :
680 : : printf("Configure FPGA LTE FEC Driver %s with default values\n",
681 : : info->drv.driver_name);
682 : :
683 : : /* clear default configuration before initialization */
684 : : memset(&conf, 0, sizeof(struct rte_fpga_lte_fec_conf));
685 : :
686 : : /* Set PF mode :
687 : : * true if PF is used for data plane
688 : : * false for VFs
689 : : */
690 : 0 : conf.pf_mode_en = true;
691 : :
692 : 0 : for (i = 0; i < FPGA_LTE_FEC_NUM_VFS; ++i) {
693 : : /* Number of UL queues per VF (fpga supports 8 VFs) */
694 : 0 : conf.vf_ul_queues_number[i] = VF_UL_4G_QUEUE_VALUE;
695 : : /* Number of DL queues per VF (fpga supports 8 VFs) */
696 : 0 : conf.vf_dl_queues_number[i] = VF_DL_4G_QUEUE_VALUE;
697 : : }
698 : :
699 : : /* UL bandwidth. Needed for schedule algorithm */
700 : 0 : conf.ul_bandwidth = UL_4G_BANDWIDTH;
701 : : /* DL bandwidth */
702 : 0 : conf.dl_bandwidth = DL_4G_BANDWIDTH;
703 : :
704 : : /* UL & DL load Balance Factor to 64 */
705 : 0 : conf.ul_load_balance = UL_4G_LOAD_BALANCE;
706 : 0 : conf.dl_load_balance = DL_4G_LOAD_BALANCE;
707 : :
708 : : /**< FLR timeout value */
709 : 0 : conf.flr_time_out = FLR_4G_TIMEOUT;
710 : :
711 : : /* setup FPGA PF with configuration information */
712 : 0 : ret = rte_fpga_lte_fec_configure(info->dev_name, &conf);
713 : 0 : TEST_ASSERT_SUCCESS(ret,
714 : : "Failed to configure 4G FPGA PF for bbdev %s",
715 : : info->dev_name);
716 : : }
717 : : #endif
718 : : #ifdef RTE_BASEBAND_FPGA_5GNR_FEC
719 : 0 : if ((get_init_device() == true) &&
720 : 0 : (!strcmp(info->drv.driver_name, FPGA_5GNR_PF_DRIVER_NAME))) {
721 : : struct rte_fpga_5gnr_fec_conf conf;
722 : : unsigned int i;
723 : :
724 : : printf("Configure FPGA 5GNR FEC Driver %s with default values\n",
725 : : info->drv.driver_name);
726 : :
727 : : /* clear default configuration before initialization */
728 : : memset(&conf, 0, sizeof(struct rte_fpga_5gnr_fec_conf));
729 : :
730 : : /* Set PF mode :
731 : : * true if PF is used for data plane
732 : : * false for VFs
733 : : */
734 : 0 : conf.pf_mode_en = true;
735 : :
736 : 0 : for (i = 0; i < FPGA_5GNR_FEC_NUM_VFS; ++i) {
737 : : /* Number of UL queues per VF (fpga supports 8 VFs) */
738 : 0 : conf.vf_ul_queues_number[i] = VF_UL_5G_QUEUE_VALUE;
739 : : /* Number of DL queues per VF (fpga supports 8 VFs) */
740 : 0 : conf.vf_dl_queues_number[i] = VF_DL_5G_QUEUE_VALUE;
741 : : }
742 : :
743 : : /* UL bandwidth. Needed only for Vista Creek 5GNR schedule algorithm */
744 : 0 : conf.ul_bandwidth = UL_5G_BANDWIDTH;
745 : : /* DL bandwidth. Needed only for Vista Creek 5GNR schedule algorithm */
746 : 0 : conf.dl_bandwidth = DL_5G_BANDWIDTH;
747 : :
748 : : /* UL & DL load Balance Factor to 64 */
749 : 0 : conf.ul_load_balance = UL_5G_LOAD_BALANCE;
750 : 0 : conf.dl_load_balance = DL_5G_LOAD_BALANCE;
751 : :
752 : : /* setup FPGA PF with configuration information */
753 : 0 : ret = rte_fpga_5gnr_fec_configure(info->dev_name, &conf);
754 : 0 : TEST_ASSERT_SUCCESS(ret,
755 : : "Failed to configure 5G FPGA PF for bbdev %s",
756 : : info->dev_name);
757 : : }
758 : : #endif
759 : : #ifdef RTE_BASEBAND_ACC
760 : 0 : if ((get_init_device() == true) &&
761 : 0 : (!strcmp(info->drv.driver_name, ACC100PF_DRIVER_NAME))) {
762 : : struct rte_acc_conf conf;
763 : : unsigned int i;
764 : :
765 : : printf("Configure ACC100 FEC device %s with default values\n",
766 : : info->drv.driver_name);
767 : :
768 : : /* clear default configuration before initialization */
769 : : memset(&conf, 0, sizeof(struct rte_acc_conf));
770 : :
771 : : /* Always set in PF mode for built-in configuration */
772 : 0 : conf.pf_mode_en = true;
773 : 0 : for (i = 0; i < RTE_ACC_NUM_VFS; ++i) {
774 : 0 : conf.arb_dl_4g[i].gbr_threshold1 = ACC100_QOS_GBR;
775 : : conf.arb_dl_4g[i].gbr_threshold1 = ACC100_QOS_GBR;
776 : 0 : conf.arb_dl_4g[i].round_robin_weight = ACC100_QMGR_RR;
777 : 0 : conf.arb_ul_4g[i].gbr_threshold1 = ACC100_QOS_GBR;
778 : : conf.arb_ul_4g[i].gbr_threshold1 = ACC100_QOS_GBR;
779 : 0 : conf.arb_ul_4g[i].round_robin_weight = ACC100_QMGR_RR;
780 : 0 : conf.arb_dl_5g[i].gbr_threshold1 = ACC100_QOS_GBR;
781 : : conf.arb_dl_5g[i].gbr_threshold1 = ACC100_QOS_GBR;
782 : 0 : conf.arb_dl_5g[i].round_robin_weight = ACC100_QMGR_RR;
783 : 0 : conf.arb_ul_5g[i].gbr_threshold1 = ACC100_QOS_GBR;
784 : : conf.arb_ul_5g[i].gbr_threshold1 = ACC100_QOS_GBR;
785 : 0 : conf.arb_ul_5g[i].round_robin_weight = ACC100_QMGR_RR;
786 : : }
787 : :
788 : 0 : conf.input_pos_llr_1_bit = true;
789 : 0 : conf.output_pos_llr_1_bit = true;
790 : 0 : conf.num_vf_bundles = 1; /**< Number of VF bundles to setup */
791 : :
792 : 0 : conf.q_ul_4g.num_qgroups = ACC100_QMGR_NUM_QGS;
793 : 0 : conf.q_ul_4g.first_qgroup_index = ACC100_QMGR_INVALID_IDX;
794 : 0 : conf.q_ul_4g.num_aqs_per_groups = ACC100_QMGR_NUM_AQS;
795 : 0 : conf.q_ul_4g.aq_depth_log2 = ACC100_QMGR_AQ_DEPTH;
796 : 0 : conf.q_dl_4g.num_qgroups = ACC100_QMGR_NUM_QGS;
797 : 0 : conf.q_dl_4g.first_qgroup_index = ACC100_QMGR_INVALID_IDX;
798 : 0 : conf.q_dl_4g.num_aqs_per_groups = ACC100_QMGR_NUM_AQS;
799 : 0 : conf.q_dl_4g.aq_depth_log2 = ACC100_QMGR_AQ_DEPTH;
800 : 0 : conf.q_ul_5g.num_qgroups = ACC100_QMGR_NUM_QGS;
801 : 0 : conf.q_ul_5g.first_qgroup_index = ACC100_QMGR_INVALID_IDX;
802 : 0 : conf.q_ul_5g.num_aqs_per_groups = ACC100_QMGR_NUM_AQS;
803 : 0 : conf.q_ul_5g.aq_depth_log2 = ACC100_QMGR_AQ_DEPTH;
804 : 0 : conf.q_dl_5g.num_qgroups = ACC100_QMGR_NUM_QGS;
805 : 0 : conf.q_dl_5g.first_qgroup_index = ACC100_QMGR_INVALID_IDX;
806 : 0 : conf.q_dl_5g.num_aqs_per_groups = ACC100_QMGR_NUM_AQS;
807 : 0 : conf.q_dl_5g.aq_depth_log2 = ACC100_QMGR_AQ_DEPTH;
808 : :
809 : : /* setup PF with configuration information */
810 : 0 : ret = rte_acc_configure(info->dev_name, &conf);
811 : 0 : TEST_ASSERT_SUCCESS(ret,
812 : : "Failed to configure ACC100 PF for bbdev %s",
813 : : info->dev_name);
814 : : }
815 : 0 : if ((get_init_device() == true) &&
816 : 0 : (!strcmp(info->drv.driver_name, VRBPF_DRIVER_NAME))) {
817 : : struct rte_acc_conf conf;
818 : : unsigned int i;
819 : :
820 : : printf("Configure Driver %s with default values\n",
821 : : info->drv.driver_name);
822 : :
823 : : /* clear default configuration before initialization */
824 : : memset(&conf, 0, sizeof(struct rte_acc_conf));
825 : :
826 : : /* Always set in PF mode for built-in configuration */
827 : 0 : conf.pf_mode_en = true;
828 : 0 : for (i = 0; i < RTE_ACC_NUM_VFS; ++i) {
829 : 0 : conf.arb_dl_4g[i].gbr_threshold1 = VRB_QOS_GBR;
830 : : conf.arb_dl_4g[i].gbr_threshold1 = VRB_QOS_GBR;
831 : 0 : conf.arb_dl_4g[i].round_robin_weight = VRB_QMGR_RR;
832 : 0 : conf.arb_ul_4g[i].gbr_threshold1 = VRB_QOS_GBR;
833 : : conf.arb_ul_4g[i].gbr_threshold1 = VRB_QOS_GBR;
834 : 0 : conf.arb_ul_4g[i].round_robin_weight = VRB_QMGR_RR;
835 : 0 : conf.arb_dl_5g[i].gbr_threshold1 = VRB_QOS_GBR;
836 : : conf.arb_dl_5g[i].gbr_threshold1 = VRB_QOS_GBR;
837 : 0 : conf.arb_dl_5g[i].round_robin_weight = VRB_QMGR_RR;
838 : 0 : conf.arb_ul_5g[i].gbr_threshold1 = VRB_QOS_GBR;
839 : : conf.arb_ul_5g[i].gbr_threshold1 = VRB_QOS_GBR;
840 : 0 : conf.arb_ul_5g[i].round_robin_weight = VRB_QMGR_RR;
841 : 0 : conf.arb_fft[i].gbr_threshold1 = VRB_QOS_GBR;
842 : : conf.arb_fft[i].gbr_threshold1 = VRB_QOS_GBR;
843 : 0 : conf.arb_fft[i].round_robin_weight = VRB_QMGR_RR;
844 : 0 : conf.arb_mld[i].gbr_threshold1 = VRB_QOS_GBR;
845 : : conf.arb_mld[i].gbr_threshold1 = VRB_QOS_GBR;
846 : 0 : conf.arb_mld[i].round_robin_weight = VRB_QMGR_RR;
847 : : }
848 : :
849 : 0 : conf.input_pos_llr_1_bit = true;
850 : 0 : conf.output_pos_llr_1_bit = true;
851 : 0 : conf.num_vf_bundles = 1; /**< Number of VF bundles to setup */
852 : :
853 : 0 : conf.q_ul_4g.num_qgroups = VRB_QMGR_NUM_QGS;
854 : 0 : conf.q_ul_4g.first_qgroup_index = VRB_QMGR_INVALID_IDX;
855 : 0 : conf.q_ul_4g.num_aqs_per_groups = VRB_QMGR_NUM_AQS;
856 : 0 : conf.q_ul_4g.aq_depth_log2 = VRB_QMGR_AQ_DEPTH;
857 : 0 : conf.q_dl_4g.num_qgroups = VRB_QMGR_NUM_QGS;
858 : 0 : conf.q_dl_4g.first_qgroup_index = VRB_QMGR_INVALID_IDX;
859 : 0 : conf.q_dl_4g.num_aqs_per_groups = VRB_QMGR_NUM_AQS;
860 : 0 : conf.q_dl_4g.aq_depth_log2 = VRB_QMGR_AQ_DEPTH;
861 : 0 : conf.q_ul_5g.num_qgroups = VRB_QMGR_NUM_QGS;
862 : 0 : conf.q_ul_5g.first_qgroup_index = VRB_QMGR_INVALID_IDX;
863 : 0 : conf.q_ul_5g.num_aqs_per_groups = VRB_QMGR_NUM_AQS;
864 : 0 : conf.q_ul_5g.aq_depth_log2 = VRB_QMGR_AQ_DEPTH;
865 : 0 : conf.q_dl_5g.num_qgroups = VRB_QMGR_NUM_QGS;
866 : 0 : conf.q_dl_5g.first_qgroup_index = VRB_QMGR_INVALID_IDX;
867 : 0 : conf.q_dl_5g.num_aqs_per_groups = VRB_QMGR_NUM_AQS;
868 : 0 : conf.q_dl_5g.aq_depth_log2 = VRB_QMGR_AQ_DEPTH;
869 : 0 : conf.q_fft.num_qgroups = VRB_QMGR_NUM_QGS;
870 : 0 : conf.q_fft.first_qgroup_index = VRB_QMGR_INVALID_IDX;
871 : 0 : conf.q_fft.num_aqs_per_groups = VRB_QMGR_NUM_AQS;
872 : 0 : conf.q_fft.aq_depth_log2 = VRB_QMGR_AQ_DEPTH;
873 : 0 : conf.q_mld.num_qgroups = VRB_QMGR_NUM_QGS;
874 : 0 : conf.q_mld.first_qgroup_index = VRB_QMGR_INVALID_IDX;
875 : 0 : conf.q_mld.num_aqs_per_groups = VRB_QMGR_NUM_AQS;
876 : 0 : conf.q_mld.aq_depth_log2 = VRB_QMGR_AQ_DEPTH;
877 : :
878 : : /* setup PF with configuration information */
879 : 0 : ret = rte_acc_configure(info->dev_name, &conf);
880 : 0 : TEST_ASSERT_SUCCESS(ret,
881 : : "Failed to configure PF for bbdev %s",
882 : : info->dev_name);
883 : : }
884 : : #endif
885 : : /* Let's refresh this now this is configured */
886 : 0 : rte_bbdev_info_get(dev_id, info);
887 : 0 : if (info->drv.device_status == RTE_BBDEV_DEV_FATAL_ERR)
888 : 0 : printf("Device Status %s\n", rte_bbdev_device_status_str(info->drv.device_status));
889 : 0 : if (info->drv.fft_window_width != NULL)
890 : 0 : fft_window_width_dev = info->drv.fft_window_width[0];
891 : : else
892 : 0 : fft_window_width_dev = 0;
893 : 0 : if (fft_window_width_dev != 0)
894 : : printf(" FFT Window0 width %d\n", fft_window_width_dev);
895 : :
896 : 0 : nb_queues = RTE_MIN(rte_lcore_count(), info->drv.max_num_queues);
897 : 0 : nb_queues = RTE_MIN(nb_queues, (unsigned int) MAX_QUEUES);
898 : :
899 : : /* setup device */
900 : 0 : ret = rte_bbdev_setup_queues(dev_id, nb_queues, info->socket_id);
901 : 0 : if (ret < 0) {
902 : 0 : printf("rte_bbdev_setup_queues(%u, %u, %d) ret %i\n",
903 : : dev_id, nb_queues, info->socket_id, ret);
904 : 0 : return TEST_FAILED;
905 : : }
906 : :
907 : : /* configure interrupts if needed */
908 : 0 : if (intr_enabled) {
909 : 0 : ret = rte_bbdev_intr_enable(dev_id);
910 : 0 : if (ret < 0) {
911 : : printf("rte_bbdev_intr_enable(%u) ret %i\n", dev_id,
912 : : ret);
913 : 0 : return TEST_FAILED;
914 : : }
915 : : }
916 : :
917 : : /* setup device queues */
918 : 0 : qconf.socket = info->socket_id;
919 : 0 : qconf.queue_size = info->drv.default_queue_conf.queue_size;
920 : 0 : qconf.priority = 0;
921 : 0 : qconf.deferred_start = 0;
922 : 0 : qconf.op_type = op_type;
923 : :
924 : 0 : for (queue_id = 0; queue_id < nb_queues; ++queue_id) {
925 : 0 : ret = rte_bbdev_queue_configure(dev_id, queue_id, &qconf);
926 : 0 : if (ret != 0) {
927 : 0 : printf(
928 : : "Allocated all queues (id=%u) at prio%u on dev%u\n",
929 : 0 : queue_id, qconf.priority, dev_id);
930 : 0 : qconf.priority++;
931 : 0 : ret = rte_bbdev_queue_configure(ad->dev_id, queue_id, &qconf);
932 : : }
933 : 0 : if (ret != 0) {
934 : : printf("All queues on dev %u allocated: %u\n", dev_id, queue_id);
935 : : break;
936 : : }
937 : 0 : ret = rte_bbdev_queue_start(ad->dev_id, queue_id);
938 : 0 : if (ret != 0) {
939 : : printf("Failed to start queue on dev %u q_id: %u\n", dev_id, queue_id);
940 : : break;
941 : : }
942 : 0 : ad->queue_ids[queue_id] = queue_id;
943 : : }
944 : 0 : TEST_ASSERT(queue_id != 0,
945 : : "ERROR Failed to configure any queues on dev %u\n"
946 : : "\tthe device may not support the related operation capability\n"
947 : : "\tor the device may not have been configured yet", dev_id);
948 : 0 : ad->nb_queues = queue_id;
949 : :
950 : : set_avail_op(ad, op_type);
951 : :
952 : 0 : return TEST_SUCCESS;
953 : : }
954 : :
955 : : static int
956 : 0 : add_active_device(uint8_t dev_id, struct rte_bbdev_info *info,
957 : : struct test_bbdev_vector *vector)
958 : : {
959 : : int ret;
960 : :
961 : 0 : active_devs[nb_active_devs].driver_name = info->drv.driver_name;
962 : 0 : active_devs[nb_active_devs].dev_id = dev_id;
963 : :
964 : 0 : ret = add_bbdev_dev(dev_id, info, vector);
965 : 0 : if (ret == TEST_SUCCESS)
966 : 0 : ++nb_active_devs;
967 : 0 : return ret;
968 : : }
969 : :
970 : : static uint8_t
971 : 0 : populate_active_devices(void)
972 : : {
973 : : int ret;
974 : : uint8_t dev_id;
975 : : uint8_t nb_devs_added = 0;
976 : : struct rte_bbdev_info info;
977 : :
978 : 0 : RTE_BBDEV_FOREACH(dev_id) {
979 : 0 : rte_bbdev_info_get(dev_id, &info);
980 : :
981 : 0 : if (check_dev_cap(&info)) {
982 : 0 : printf(
983 : : "Device %d (%s) does not support specified capabilities\n",
984 : : dev_id, info.dev_name);
985 : 0 : continue;
986 : : }
987 : :
988 : 0 : ret = add_active_device(dev_id, &info, &test_vector);
989 : 0 : if (ret != 0) {
990 : 0 : printf("Adding active bbdev %s skipped\n",
991 : : info.dev_name);
992 : 0 : continue;
993 : : }
994 : 0 : nb_devs_added++;
995 : : }
996 : :
997 : 0 : return nb_devs_added;
998 : : }
999 : :
1000 : : static int
1001 : 0 : read_test_vector(void)
1002 : : {
1003 : : int ret;
1004 : :
1005 : : memset(&test_vector, 0, sizeof(test_vector));
1006 : 0 : printf("Test vector file = %s\n", get_vector_filename());
1007 : 0 : ret = test_bbdev_vector_read(get_vector_filename(), &test_vector);
1008 : 0 : TEST_ASSERT_SUCCESS(ret, "Failed to parse file %s\n",
1009 : : get_vector_filename());
1010 : :
1011 : : return TEST_SUCCESS;
1012 : : }
1013 : :
1014 : : static int
1015 : 0 : testsuite_setup(void)
1016 : : {
1017 : 0 : TEST_ASSERT_SUCCESS(read_test_vector(), "Test suite setup failed\n");
1018 : :
1019 : 0 : if (populate_active_devices() == 0) {
1020 : : printf("No suitable devices found!\n");
1021 : 0 : return TEST_SKIPPED;
1022 : : }
1023 : :
1024 : : return TEST_SUCCESS;
1025 : : }
1026 : :
1027 : : static int
1028 : 0 : interrupt_testsuite_setup(void)
1029 : : {
1030 : 0 : TEST_ASSERT_SUCCESS(read_test_vector(), "Test suite setup failed\n");
1031 : :
1032 : : /* Enable interrupts */
1033 : 0 : intr_enabled = true;
1034 : :
1035 : : /* Special case for NULL device (RTE_BBDEV_OP_NONE) */
1036 : 0 : if (populate_active_devices() == 0 ||
1037 : 0 : test_vector.op_type == RTE_BBDEV_OP_NONE) {
1038 : 0 : intr_enabled = false;
1039 : : printf("No suitable devices found!\n");
1040 : 0 : return TEST_SKIPPED;
1041 : : }
1042 : :
1043 : : return TEST_SUCCESS;
1044 : : }
1045 : :
1046 : : static void
1047 : 0 : testsuite_teardown(void)
1048 : : {
1049 : : uint8_t dev_id;
1050 : :
1051 : : /* Unconfigure devices */
1052 : 0 : RTE_BBDEV_FOREACH(dev_id)
1053 : 0 : rte_bbdev_close(dev_id);
1054 : :
1055 : : /* Clear active devices structs. */
1056 : : memset(active_devs, 0, sizeof(active_devs));
1057 : 0 : nb_active_devs = 0;
1058 : :
1059 : : /* Disable interrupts */
1060 : 0 : intr_enabled = false;
1061 : 0 : }
1062 : :
1063 : : static int
1064 : 0 : ut_setup(void)
1065 : : {
1066 : : uint8_t i, dev_id;
1067 : :
1068 : 0 : for (i = 0; i < nb_active_devs; i++) {
1069 : 0 : dev_id = active_devs[i].dev_id;
1070 : : /* reset bbdev stats */
1071 : 0 : TEST_ASSERT_SUCCESS(rte_bbdev_stats_reset(dev_id),
1072 : : "Failed to reset stats of bbdev %u", dev_id);
1073 : : /* start the device */
1074 : 0 : TEST_ASSERT_SUCCESS(rte_bbdev_start(dev_id),
1075 : : "Failed to start bbdev %u", dev_id);
1076 : : }
1077 : :
1078 : : return TEST_SUCCESS;
1079 : : }
1080 : :
1081 : : static void
1082 : 0 : ut_teardown(void)
1083 : : {
1084 : : uint8_t i, dev_id, ret;
1085 : : struct rte_bbdev_stats stats;
1086 : :
1087 : 0 : for (i = 0; i < nb_active_devs; i++) {
1088 : 0 : dev_id = active_devs[i].dev_id;
1089 : : /* read stats and print */
1090 : 0 : ret = rte_bbdev_stats_get(dev_id, &stats);
1091 : 0 : if (ret != 0)
1092 : : printf("Failed to get stats on bbdev %u\n", dev_id);
1093 : : /* Stop the device */
1094 : 0 : rte_bbdev_stop(dev_id);
1095 : : }
1096 : 0 : }
1097 : :
1098 : : static int
1099 : 0 : init_op_data_objs(struct rte_bbdev_op_data *bufs,
1100 : : struct op_data_entries *ref_entries,
1101 : : struct rte_mempool *mbuf_pool, const uint16_t n,
1102 : : enum op_data_type op_type, uint16_t min_alignment)
1103 : : {
1104 : : int ret;
1105 : : unsigned int i, j;
1106 : : bool large_input = false;
1107 : :
1108 : 0 : for (i = 0; i < n; ++i) {
1109 : : char *data;
1110 : 0 : struct op_data_buf *seg = &ref_entries->segments[0];
1111 : 0 : struct rte_mbuf *m_head = rte_pktmbuf_alloc(mbuf_pool);
1112 : 0 : TEST_ASSERT_NOT_NULL(m_head,
1113 : : "Not enough mbufs in %d data type mbuf pool (needed %u, available %u)",
1114 : : op_type, n * ref_entries->nb_segments,
1115 : : mbuf_pool->size);
1116 : :
1117 : 0 : if ((seg->length + RTE_PKTMBUF_HEADROOM) > RTE_BBDEV_LDPC_E_MAX_MBUF) {
1118 : : /*
1119 : : * Special case when DPDK mbuf cannot handle
1120 : : * the required input size
1121 : : */
1122 : : large_input = true;
1123 : : }
1124 : 0 : bufs[i].data = m_head;
1125 : 0 : bufs[i].offset = 0;
1126 : 0 : bufs[i].length = 0;
1127 : :
1128 : 0 : if ((op_type == DATA_INPUT) || (op_type == DATA_HARQ_INPUT)) {
1129 : 0 : if (large_input) {
1130 : : /* Allocate a fake overused mbuf */
1131 : 0 : data = rte_malloc(NULL, seg->length, 0);
1132 : 0 : TEST_ASSERT_NOT_NULL(data,
1133 : : "rte malloc failed with %u bytes",
1134 : : seg->length);
1135 : 0 : memcpy(data, seg->addr, seg->length);
1136 : 0 : m_head->buf_addr = data;
1137 : 0 : rte_mbuf_iova_set(m_head, rte_malloc_virt2iova(data));
1138 : 0 : m_head->data_off = 0;
1139 : 0 : m_head->data_len = seg->length;
1140 : : } else {
1141 : 0 : data = rte_pktmbuf_append(m_head, seg->length);
1142 : 0 : TEST_ASSERT_NOT_NULL(data,
1143 : : "Couldn't append %u bytes to mbuf from %d data type mbuf pool",
1144 : : seg->length, op_type);
1145 : :
1146 : 0 : TEST_ASSERT(data == RTE_PTR_ALIGN(
1147 : : data, min_alignment),
1148 : : "Data addr in mbuf (%p) is not aligned to device min alignment (%u)",
1149 : : data, min_alignment);
1150 : 0 : rte_memcpy(data, seg->addr, seg->length);
1151 : : }
1152 : :
1153 : 0 : bufs[i].length += seg->length;
1154 : :
1155 : 0 : for (j = 1; j < ref_entries->nb_segments; ++j) {
1156 : : struct rte_mbuf *m_tail =
1157 : 0 : rte_pktmbuf_alloc(mbuf_pool);
1158 : 0 : TEST_ASSERT_NOT_NULL(m_tail,
1159 : : "Not enough mbufs in %d data type mbuf pool (needed %u, available %u)",
1160 : : op_type,
1161 : : n * ref_entries->nb_segments,
1162 : : mbuf_pool->size);
1163 : 0 : seg += 1;
1164 : :
1165 : 0 : data = rte_pktmbuf_append(m_tail, seg->length);
1166 : 0 : TEST_ASSERT_NOT_NULL(data,
1167 : : "Couldn't append %u bytes to mbuf from %d data type mbuf pool",
1168 : : seg->length, op_type);
1169 : :
1170 : 0 : TEST_ASSERT(data == RTE_PTR_ALIGN(data,
1171 : : min_alignment),
1172 : : "Data addr in mbuf (%p) is not aligned to device min alignment (%u)",
1173 : : data, min_alignment);
1174 : 0 : rte_memcpy(data, seg->addr, seg->length);
1175 : 0 : bufs[i].length += seg->length;
1176 : :
1177 : : ret = rte_pktmbuf_chain(m_head, m_tail);
1178 : 0 : TEST_ASSERT_SUCCESS(ret,
1179 : : "Couldn't chain mbufs from %d data type mbuf pool",
1180 : : op_type);
1181 : : }
1182 : : } else {
1183 : 0 : if (((op_type == DATA_HARD_OUTPUT) || (op_type == DATA_SOFT_OUTPUT))
1184 : 0 : && ((seg->length + RTE_PKTMBUF_HEADROOM)
1185 : : > RTE_BBDEV_LDPC_E_MAX_MBUF)) {
1186 : : /* Allocate a fake overused mbuf + margin */
1187 : 0 : data = rte_malloc(NULL, seg->length + 1024, 0);
1188 : 0 : TEST_ASSERT_NOT_NULL(data,
1189 : : "rte malloc failed with %u bytes",
1190 : : seg->length + 1024);
1191 : 0 : m_head->buf_addr = data;
1192 : 0 : rte_mbuf_iova_set(m_head, rte_malloc_virt2iova(data));
1193 : 0 : m_head->data_off = 0;
1194 : 0 : m_head->data_len = seg->length;
1195 : : } else {
1196 : : /* allocate chained-mbuf for output buffer */
1197 : 0 : for (j = 1; j < ref_entries->nb_segments; ++j) {
1198 : : struct rte_mbuf *m_tail =
1199 : 0 : rte_pktmbuf_alloc(mbuf_pool);
1200 : 0 : TEST_ASSERT_NOT_NULL(m_tail,
1201 : : "Not enough mbufs in %d data type mbuf pool (needed %u, available %u)",
1202 : : op_type,
1203 : : n * ref_entries->nb_segments,
1204 : : mbuf_pool->size);
1205 : :
1206 : : ret = rte_pktmbuf_chain(m_head, m_tail);
1207 : 0 : TEST_ASSERT_SUCCESS(ret,
1208 : : "Couldn't chain mbufs from %d data type mbuf pool",
1209 : : op_type);
1210 : : }
1211 : : }
1212 : 0 : bufs[i].length += seg->length;
1213 : : }
1214 : : }
1215 : :
1216 : : return 0;
1217 : : }
1218 : :
1219 : : static int
1220 : 0 : allocate_buffers_on_socket(struct rte_bbdev_op_data **buffers, const int len,
1221 : : const int socket)
1222 : : {
1223 : : int i;
1224 : :
1225 : 0 : *buffers = rte_zmalloc_socket(NULL, len, 0, socket);
1226 : 0 : if (*buffers == NULL) {
1227 : : printf("WARNING: Failed to allocate op_data on socket %d\n",
1228 : : socket);
1229 : : /* try to allocate memory on other detected sockets */
1230 : 0 : for (i = 0; i < socket; i++) {
1231 : 0 : *buffers = rte_zmalloc_socket(NULL, len, 0, i);
1232 : 0 : if (*buffers != NULL)
1233 : : break;
1234 : : }
1235 : : }
1236 : :
1237 : 0 : return (*buffers == NULL) ? TEST_FAILED : TEST_SUCCESS;
1238 : : }
1239 : :
1240 : : static void
1241 : 0 : limit_input_llr_val_range(struct rte_bbdev_op_data *input_ops,
1242 : : const uint16_t n, const int8_t max_llr_modulus)
1243 : : {
1244 : : uint16_t i, byte_idx;
1245 : :
1246 : 0 : for (i = 0; i < n; ++i) {
1247 : 0 : struct rte_mbuf *m = input_ops[i].data;
1248 : 0 : while (m != NULL) {
1249 : 0 : int8_t *llr = rte_pktmbuf_mtod_offset(m, int8_t *,
1250 : : input_ops[i].offset);
1251 : 0 : for (byte_idx = 0; byte_idx < rte_pktmbuf_data_len(m);
1252 : 0 : ++byte_idx)
1253 : 0 : llr[byte_idx] = round((double)max_llr_modulus *
1254 : 0 : llr[byte_idx] / INT8_MAX);
1255 : :
1256 : 0 : m = m->next;
1257 : : }
1258 : : }
1259 : 0 : }
1260 : :
1261 : : /*
1262 : : * We may have to insert filler bits
1263 : : * when they are required by the HARQ assumption
1264 : : */
1265 : : static void
1266 : 0 : ldpc_add_filler(struct rte_bbdev_op_data *input_ops,
1267 : : const uint16_t n, struct test_op_params *op_params)
1268 : : {
1269 : 0 : struct rte_bbdev_op_ldpc_dec dec = op_params->ref_dec_op->ldpc_dec;
1270 : :
1271 : 0 : if (input_ops == NULL)
1272 : : return;
1273 : : /* No need to add filler if not required by device */
1274 : 0 : if (!(ldpc_cap_flags &
1275 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_FILLERS))
1276 : : return;
1277 : : /* No need to add filler for loopback operation */
1278 : 0 : if (dec.op_flags & RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK)
1279 : : return;
1280 : :
1281 : : uint16_t i, j, parity_offset;
1282 : 0 : for (i = 0; i < n; ++i) {
1283 : 0 : struct rte_mbuf *m = input_ops[i].data;
1284 : 0 : int8_t *llr = rte_pktmbuf_mtod_offset(m, int8_t *,
1285 : : input_ops[i].offset);
1286 : 0 : parity_offset = (dec.basegraph == 1 ? 20 : 8)
1287 : 0 : * dec.z_c - dec.n_filler;
1288 : 0 : uint16_t new_hin_size = input_ops[i].length + dec.n_filler;
1289 : 0 : m->data_len = new_hin_size;
1290 : 0 : input_ops[i].length = new_hin_size;
1291 : 0 : for (j = new_hin_size - 1; j >= parity_offset + dec.n_filler;
1292 : 0 : j--)
1293 : 0 : llr[j] = llr[j - dec.n_filler];
1294 : 0 : uint16_t llr_max_pre_scaling = (1 << (ldpc_llr_size - 1)) - 1;
1295 : 0 : for (j = 0; j < dec.n_filler; j++)
1296 : 0 : llr[parity_offset + j] = llr_max_pre_scaling;
1297 : : }
1298 : : }
1299 : :
1300 : : static void
1301 : 0 : ldpc_input_llr_scaling(struct rte_bbdev_op_data *input_ops,
1302 : : const uint16_t n, const int8_t llr_size,
1303 : : const int8_t llr_decimals)
1304 : : {
1305 : 0 : if (input_ops == NULL)
1306 : : return;
1307 : :
1308 : : uint16_t i, byte_idx;
1309 : :
1310 : : int16_t llr_max, llr_min, llr_tmp;
1311 : 0 : llr_max = (1 << (llr_size - 1)) - 1;
1312 : 0 : llr_min = -llr_max;
1313 : 0 : for (i = 0; i < n; ++i) {
1314 : 0 : struct rte_mbuf *m = input_ops[i].data;
1315 : 0 : while (m != NULL) {
1316 : 0 : int8_t *llr = rte_pktmbuf_mtod_offset(m, int8_t *,
1317 : : input_ops[i].offset);
1318 : 0 : for (byte_idx = 0; byte_idx < rte_pktmbuf_data_len(m);
1319 : 0 : ++byte_idx) {
1320 : :
1321 : 0 : llr_tmp = llr[byte_idx];
1322 : 0 : if (llr_decimals == 4)
1323 : 0 : llr_tmp *= 8;
1324 : 0 : else if (llr_decimals == 2)
1325 : 0 : llr_tmp *= 2;
1326 : 0 : else if (llr_decimals == 0)
1327 : 0 : llr_tmp /= 2;
1328 : 0 : llr_tmp = RTE_MIN(llr_max,
1329 : : RTE_MAX(llr_min, llr_tmp));
1330 : 0 : llr[byte_idx] = (int8_t) llr_tmp;
1331 : : }
1332 : :
1333 : 0 : m = m->next;
1334 : : }
1335 : : }
1336 : : }
1337 : :
1338 : :
1339 : :
1340 : : static int
1341 : 0 : fill_queue_buffers(struct test_op_params *op_params,
1342 : : struct rte_mempool *in_mp, struct rte_mempool *hard_out_mp,
1343 : : struct rte_mempool *soft_out_mp,
1344 : : struct rte_mempool *harq_in_mp, struct rte_mempool *harq_out_mp,
1345 : : uint16_t queue_id,
1346 : : const struct rte_bbdev_op_cap *capabilities,
1347 : : uint16_t min_alignment, const int socket_id)
1348 : : {
1349 : : int ret;
1350 : : enum op_data_type type;
1351 : 0 : const uint16_t n = op_params->num_to_process;
1352 : :
1353 : 0 : struct rte_mempool *mbuf_pools[DATA_NUM_TYPES] = {
1354 : : in_mp,
1355 : : soft_out_mp,
1356 : : hard_out_mp,
1357 : : harq_in_mp,
1358 : : harq_out_mp,
1359 : : };
1360 : :
1361 : 0 : struct rte_bbdev_op_data **queue_ops[DATA_NUM_TYPES] = {
1362 : 0 : &op_params->q_bufs[socket_id][queue_id].inputs,
1363 : 0 : &op_params->q_bufs[socket_id][queue_id].soft_outputs,
1364 : 0 : &op_params->q_bufs[socket_id][queue_id].hard_outputs,
1365 : 0 : &op_params->q_bufs[socket_id][queue_id].harq_inputs,
1366 : 0 : &op_params->q_bufs[socket_id][queue_id].harq_outputs,
1367 : : };
1368 : :
1369 : 0 : for (type = DATA_INPUT; type < DATA_NUM_TYPES; ++type) {
1370 : 0 : struct op_data_entries *ref_entries =
1371 : : &test_vector.entries[type];
1372 : 0 : if (ref_entries->nb_segments == 0)
1373 : 0 : continue;
1374 : :
1375 : 0 : ret = allocate_buffers_on_socket(queue_ops[type],
1376 : 0 : n * sizeof(struct rte_bbdev_op_data),
1377 : : socket_id);
1378 : 0 : TEST_ASSERT_SUCCESS(ret,
1379 : : "Couldn't allocate memory for rte_bbdev_op_data structs");
1380 : :
1381 : 0 : ret = init_op_data_objs(*queue_ops[type], ref_entries,
1382 : : mbuf_pools[type], n, type, min_alignment);
1383 : 0 : TEST_ASSERT_SUCCESS(ret,
1384 : : "Couldn't init rte_bbdev_op_data structs");
1385 : : }
1386 : :
1387 : 0 : if (test_vector.op_type == RTE_BBDEV_OP_TURBO_DEC)
1388 : 0 : limit_input_llr_val_range(*queue_ops[DATA_INPUT], n,
1389 : 0 : capabilities->cap.turbo_dec.max_llr_modulus);
1390 : :
1391 : 0 : if (test_vector.op_type == RTE_BBDEV_OP_LDPC_DEC) {
1392 : 0 : bool loopback = op_params->ref_dec_op->ldpc_dec.op_flags &
1393 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK;
1394 : 0 : bool llr_comp = op_params->ref_dec_op->ldpc_dec.op_flags &
1395 : : RTE_BBDEV_LDPC_LLR_COMPRESSION;
1396 : 0 : bool harq_comp = op_params->ref_dec_op->ldpc_dec.op_flags &
1397 : : RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION;
1398 : :
1399 : 0 : ldpc_llr_decimals = capabilities->cap.ldpc_dec.llr_decimals;
1400 : 0 : ldpc_llr_size = capabilities->cap.ldpc_dec.llr_size;
1401 : 0 : ldpc_cap_flags = capabilities->cap.ldpc_dec.capability_flags;
1402 : 0 : if (!loopback && !llr_comp)
1403 : 0 : ldpc_input_llr_scaling(*queue_ops[DATA_INPUT], n,
1404 : : ldpc_llr_size, ldpc_llr_decimals);
1405 : 0 : if (!loopback && !harq_comp)
1406 : 0 : ldpc_input_llr_scaling(*queue_ops[DATA_HARQ_INPUT], n,
1407 : : ldpc_llr_size, ldpc_llr_decimals);
1408 : 0 : if (!loopback)
1409 : 0 : ldpc_add_filler(*queue_ops[DATA_HARQ_INPUT], n,
1410 : : op_params);
1411 : : }
1412 : :
1413 : : return 0;
1414 : : }
1415 : :
1416 : : static void
1417 : 0 : free_buffers(struct active_device *ad, struct test_op_params *op_params)
1418 : : {
1419 : : unsigned int i, j;
1420 : :
1421 : 0 : rte_mempool_free(ad->ops_mempool);
1422 : 0 : rte_mempool_free(ad->in_mbuf_pool);
1423 : 0 : rte_mempool_free(ad->hard_out_mbuf_pool);
1424 : 0 : rte_mempool_free(ad->soft_out_mbuf_pool);
1425 : 0 : rte_mempool_free(ad->harq_in_mbuf_pool);
1426 : 0 : rte_mempool_free(ad->harq_out_mbuf_pool);
1427 : :
1428 : 0 : for (i = 0; i < rte_lcore_count(); ++i) {
1429 : 0 : for (j = 0; j < RTE_MAX_NUMA_NODES; ++j) {
1430 : 0 : rte_free(op_params->q_bufs[j][i].inputs);
1431 : 0 : rte_free(op_params->q_bufs[j][i].hard_outputs);
1432 : 0 : rte_free(op_params->q_bufs[j][i].soft_outputs);
1433 : 0 : rte_free(op_params->q_bufs[j][i].harq_inputs);
1434 : 0 : rte_free(op_params->q_bufs[j][i].harq_outputs);
1435 : : }
1436 : : }
1437 : 0 : }
1438 : :
1439 : : static void
1440 : 0 : copy_reference_dec_op(struct rte_bbdev_dec_op **ops, unsigned int n,
1441 : : unsigned int start_idx,
1442 : : struct rte_bbdev_op_data *inputs,
1443 : : struct rte_bbdev_op_data *hard_outputs,
1444 : : struct rte_bbdev_op_data *soft_outputs,
1445 : : struct rte_bbdev_dec_op *ref_op)
1446 : : {
1447 : : unsigned int i;
1448 : : struct rte_bbdev_op_turbo_dec *turbo_dec = &ref_op->turbo_dec;
1449 : :
1450 : 0 : for (i = 0; i < n; ++i) {
1451 : 0 : if (turbo_dec->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
1452 : 0 : ops[i]->turbo_dec.tb_params.ea =
1453 : 0 : turbo_dec->tb_params.ea;
1454 : 0 : ops[i]->turbo_dec.tb_params.eb =
1455 : 0 : turbo_dec->tb_params.eb;
1456 : 0 : ops[i]->turbo_dec.tb_params.k_pos =
1457 : 0 : turbo_dec->tb_params.k_pos;
1458 : 0 : ops[i]->turbo_dec.tb_params.k_neg =
1459 : 0 : turbo_dec->tb_params.k_neg;
1460 : 0 : ops[i]->turbo_dec.tb_params.c =
1461 : 0 : turbo_dec->tb_params.c;
1462 : 0 : ops[i]->turbo_dec.tb_params.c_neg =
1463 : 0 : turbo_dec->tb_params.c_neg;
1464 : 0 : ops[i]->turbo_dec.tb_params.cab =
1465 : 0 : turbo_dec->tb_params.cab;
1466 : 0 : ops[i]->turbo_dec.tb_params.r =
1467 : 0 : turbo_dec->tb_params.r;
1468 : : } else {
1469 : 0 : ops[i]->turbo_dec.cb_params.e = turbo_dec->cb_params.e;
1470 : 0 : ops[i]->turbo_dec.cb_params.k = turbo_dec->cb_params.k;
1471 : : }
1472 : :
1473 : 0 : ops[i]->turbo_dec.ext_scale = turbo_dec->ext_scale;
1474 : 0 : ops[i]->turbo_dec.iter_max = turbo_dec->iter_max;
1475 : 0 : ops[i]->turbo_dec.iter_min = turbo_dec->iter_min;
1476 : 0 : ops[i]->turbo_dec.op_flags = turbo_dec->op_flags;
1477 : 0 : ops[i]->turbo_dec.rv_index = turbo_dec->rv_index;
1478 : 0 : ops[i]->turbo_dec.num_maps = turbo_dec->num_maps;
1479 : 0 : ops[i]->turbo_dec.code_block_mode = turbo_dec->code_block_mode;
1480 : :
1481 : 0 : ops[i]->turbo_dec.hard_output = hard_outputs[start_idx + i];
1482 : 0 : ops[i]->turbo_dec.input = inputs[start_idx + i];
1483 : 0 : if (soft_outputs != NULL)
1484 : 0 : ops[i]->turbo_dec.soft_output =
1485 : 0 : soft_outputs[start_idx + i];
1486 : : }
1487 : 0 : }
1488 : :
1489 : : static void
1490 : 0 : copy_reference_enc_op(struct rte_bbdev_enc_op **ops, unsigned int n,
1491 : : unsigned int start_idx,
1492 : : struct rte_bbdev_op_data *inputs,
1493 : : struct rte_bbdev_op_data *outputs,
1494 : : struct rte_bbdev_enc_op *ref_op)
1495 : : {
1496 : : unsigned int i;
1497 : : struct rte_bbdev_op_turbo_enc *turbo_enc = &ref_op->turbo_enc;
1498 : 0 : for (i = 0; i < n; ++i) {
1499 : 0 : if (turbo_enc->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
1500 : 0 : ops[i]->turbo_enc.tb_params.ea =
1501 : 0 : turbo_enc->tb_params.ea;
1502 : 0 : ops[i]->turbo_enc.tb_params.eb =
1503 : 0 : turbo_enc->tb_params.eb;
1504 : 0 : ops[i]->turbo_enc.tb_params.k_pos =
1505 : 0 : turbo_enc->tb_params.k_pos;
1506 : 0 : ops[i]->turbo_enc.tb_params.k_neg =
1507 : 0 : turbo_enc->tb_params.k_neg;
1508 : 0 : ops[i]->turbo_enc.tb_params.c =
1509 : 0 : turbo_enc->tb_params.c;
1510 : 0 : ops[i]->turbo_enc.tb_params.c_neg =
1511 : 0 : turbo_enc->tb_params.c_neg;
1512 : 0 : ops[i]->turbo_enc.tb_params.cab =
1513 : 0 : turbo_enc->tb_params.cab;
1514 : 0 : ops[i]->turbo_enc.tb_params.ncb_pos =
1515 : 0 : turbo_enc->tb_params.ncb_pos;
1516 : 0 : ops[i]->turbo_enc.tb_params.ncb_neg =
1517 : 0 : turbo_enc->tb_params.ncb_neg;
1518 : 0 : ops[i]->turbo_enc.tb_params.r = turbo_enc->tb_params.r;
1519 : : } else {
1520 : 0 : ops[i]->turbo_enc.cb_params.e = turbo_enc->cb_params.e;
1521 : 0 : ops[i]->turbo_enc.cb_params.k = turbo_enc->cb_params.k;
1522 : 0 : ops[i]->turbo_enc.cb_params.ncb =
1523 : 0 : turbo_enc->cb_params.ncb;
1524 : : }
1525 : 0 : ops[i]->turbo_enc.rv_index = turbo_enc->rv_index;
1526 : 0 : ops[i]->turbo_enc.op_flags = turbo_enc->op_flags;
1527 : 0 : ops[i]->turbo_enc.code_block_mode = turbo_enc->code_block_mode;
1528 : :
1529 : 0 : ops[i]->turbo_enc.output = outputs[start_idx + i];
1530 : 0 : ops[i]->turbo_enc.input = inputs[start_idx + i];
1531 : : }
1532 : 0 : }
1533 : :
1534 : :
1535 : : /* Returns a random number drawn from a normal distribution
1536 : : * with mean of 0 and variance of 1
1537 : : * Marsaglia algorithm
1538 : : */
1539 : : static double
1540 : 0 : randn(int n)
1541 : : {
1542 : : double S, Z, U1, U2, u, v, fac;
1543 : :
1544 : : do {
1545 : 0 : U1 = (double)rand() / RAND_MAX;
1546 : 0 : U2 = (double)rand() / RAND_MAX;
1547 : 0 : u = 2. * U1 - 1.;
1548 : 0 : v = 2. * U2 - 1.;
1549 : 0 : S = u * u + v * v;
1550 : 0 : } while (S >= 1 || S == 0);
1551 : 0 : fac = sqrt(-2. * log(S) / S);
1552 : 0 : Z = (n % 2) ? u * fac : v * fac;
1553 : 0 : return Z;
1554 : : }
1555 : :
1556 : : static inline double
1557 : 0 : maxstar(double A, double B)
1558 : : {
1559 : 0 : if (fabs(A - B) > 5)
1560 : 0 : return RTE_MAX(A, B);
1561 : : else
1562 : 0 : return RTE_MAX(A, B) + log1p(exp(-fabs(A - B)));
1563 : : }
1564 : :
1565 : : /*
1566 : : * Generate Qm LLRS for Qm==8
1567 : : * Modulation, AWGN and LLR estimation from max log development
1568 : : */
1569 : : static void
1570 : 0 : gen_qm8_llr(int8_t *llrs, uint32_t i, double N0, double llr_max)
1571 : : {
1572 : : #define QM 8
1573 : : #define QAM 256
1574 : :
1575 : : int m, k;
1576 : : double I, Q, p0, p1, llr_, b[QM], log_syml_prob[QAM];
1577 : : /* 5.1.4 of TS38.211 */
1578 : 0 : const double symbols_I[QAM] = {
1579 : : 5, 5, 7, 7, 5, 5, 7, 7, 3, 3, 1, 1, 3, 3, 1, 1, 5,
1580 : : 5, 7, 7, 5, 5, 7, 7, 3, 3, 1, 1, 3, 3, 1, 1, 11,
1581 : : 11, 9, 9, 11, 11, 9, 9, 13, 13, 15, 15, 13, 13,
1582 : : 15, 15, 11, 11, 9, 9, 11, 11, 9, 9, 13, 13, 15,
1583 : : 15, 13, 13, 15, 15, 5, 5, 7, 7, 5, 5, 7, 7, 3, 3,
1584 : : 1, 1, 3, 3, 1, 1, 5, 5, 7, 7, 5, 5, 7, 7, 3, 3, 1,
1585 : : 1, 3, 3, 1, 1, 11, 11, 9, 9, 11, 11, 9, 9, 13, 13,
1586 : : 15, 15, 13, 13, 15, 15, 11, 11, 9, 9, 11, 11, 9, 9,
1587 : : 13, 13, 15, 15, 13, 13, 15, 15, -5, -5, -7, -7, -5,
1588 : : -5, -7, -7, -3, -3, -1, -1, -3, -3, -1, -1, -5, -5,
1589 : : -7, -7, -5, -5, -7, -7, -3, -3, -1, -1, -3, -3,
1590 : : -1, -1, -11, -11, -9, -9, -11, -11, -9, -9, -13,
1591 : : -13, -15, -15, -13, -13, -15, -15, -11, -11, -9,
1592 : : -9, -11, -11, -9, -9, -13, -13, -15, -15, -13,
1593 : : -13, -15, -15, -5, -5, -7, -7, -5, -5, -7, -7, -3,
1594 : : -3, -1, -1, -3, -3, -1, -1, -5, -5, -7, -7, -5, -5,
1595 : : -7, -7, -3, -3, -1, -1, -3, -3, -1, -1, -11, -11,
1596 : : -9, -9, -11, -11, -9, -9, -13, -13, -15, -15, -13,
1597 : : -13, -15, -15, -11, -11, -9, -9, -11, -11, -9, -9,
1598 : : -13, -13, -15, -15, -13, -13, -15, -15};
1599 : 0 : const double symbols_Q[QAM] = {
1600 : : 5, 7, 5, 7, 3, 1, 3, 1, 5, 7, 5, 7, 3, 1, 3, 1, 11,
1601 : : 9, 11, 9, 13, 15, 13, 15, 11, 9, 11, 9, 13, 15, 13,
1602 : : 15, 5, 7, 5, 7, 3, 1, 3, 1, 5, 7, 5, 7, 3, 1, 3, 1,
1603 : : 11, 9, 11, 9, 13, 15, 13, 15, 11, 9, 11, 9, 13,
1604 : : 15, 13, 15, -5, -7, -5, -7, -3, -1, -3, -1, -5,
1605 : : -7, -5, -7, -3, -1, -3, -1, -11, -9, -11, -9, -13,
1606 : : -15, -13, -15, -11, -9, -11, -9, -13, -15, -13,
1607 : : -15, -5, -7, -5, -7, -3, -1, -3, -1, -5, -7, -5,
1608 : : -7, -3, -1, -3, -1, -11, -9, -11, -9, -13, -15,
1609 : : -13, -15, -11, -9, -11, -9, -13, -15, -13, -15, 5,
1610 : : 7, 5, 7, 3, 1, 3, 1, 5, 7, 5, 7, 3, 1, 3, 1, 11,
1611 : : 9, 11, 9, 13, 15, 13, 15, 11, 9, 11, 9, 13, 15,
1612 : : 13, 15, 5, 7, 5, 7, 3, 1, 3, 1, 5, 7, 5, 7, 3, 1,
1613 : : 3, 1, 11, 9, 11, 9, 13, 15, 13, 15, 11, 9, 11, 9,
1614 : : 13, 15, 13, 15, -5, -7, -5, -7, -3, -1, -3, -1,
1615 : : -5, -7, -5, -7, -3, -1, -3, -1, -11, -9, -11, -9,
1616 : : -13, -15, -13, -15, -11, -9, -11, -9, -13, -15,
1617 : : -13, -15, -5, -7, -5, -7, -3, -1, -3, -1, -5, -7,
1618 : : -5, -7, -3, -1, -3, -1, -11, -9, -11, -9, -13, -15,
1619 : : -13, -15, -11, -9, -11, -9, -13, -15, -13, -15};
1620 : : /* Average constellation point energy */
1621 : 0 : N0 *= 170.0;
1622 : 0 : for (k = 0; k < QM; k++)
1623 : 0 : b[k] = llrs[QM * i + k] < 0 ? 1.0 : 0.0;
1624 : : /* 5.1.4 of TS38.211 */
1625 : 0 : I = (1 - 2 * b[0]) * (8 - (1 - 2 * b[2]) *
1626 : 0 : (4 - (1 - 2 * b[4]) * (2 - (1 - 2 * b[6]))));
1627 : 0 : Q = (1 - 2 * b[1]) * (8 - (1 - 2 * b[3]) *
1628 : 0 : (4 - (1 - 2 * b[5]) * (2 - (1 - 2 * b[7]))));
1629 : : /* AWGN channel */
1630 : 0 : I += sqrt(N0 / 2) * randn(0);
1631 : 0 : Q += sqrt(N0 / 2) * randn(1);
1632 : : /*
1633 : : * Calculate the log of the probability that each of
1634 : : * the constellation points was transmitted
1635 : : */
1636 : 0 : for (m = 0; m < QAM; m++)
1637 : 0 : log_syml_prob[m] = -(pow(I - symbols_I[m], 2.0)
1638 : 0 : + pow(Q - symbols_Q[m], 2.0)) / N0;
1639 : : /* Calculate an LLR for each of the k_64QAM bits in the set */
1640 : 0 : for (k = 0; k < QM; k++) {
1641 : : p0 = -999999;
1642 : : p1 = -999999;
1643 : : /* For each constellation point */
1644 : 0 : for (m = 0; m < QAM; m++) {
1645 : 0 : if ((m >> (QM - k - 1)) & 1)
1646 : 0 : p1 = maxstar(p1, log_syml_prob[m]);
1647 : : else
1648 : 0 : p0 = maxstar(p0, log_syml_prob[m]);
1649 : : }
1650 : : /* Calculate the LLR */
1651 : 0 : llr_ = p0 - p1;
1652 : 0 : llr_ *= (1 << ldpc_llr_decimals);
1653 : 0 : llr_ = round(llr_);
1654 : 0 : if (llr_ > llr_max)
1655 : : llr_ = llr_max;
1656 : 0 : if (llr_ < -llr_max)
1657 : : llr_ = -llr_max;
1658 : 0 : llrs[QM * i + k] = (int8_t) llr_;
1659 : : }
1660 : : #undef QM
1661 : : #undef QAM
1662 : 0 : }
1663 : :
1664 : :
1665 : : /*
1666 : : * Generate Qm LLRS for Qm==6
1667 : : * Modulation, AWGN and LLR estimation from max log development
1668 : : */
1669 : : static void
1670 : 0 : gen_qm6_llr(int8_t *llrs, uint32_t i, double N0, double llr_max)
1671 : : {
1672 : : #define QM 6
1673 : : #define QAM 64
1674 : :
1675 : : int m, k;
1676 : : double I, Q, p0, p1, llr_, b[QM], log_syml_prob[QAM];
1677 : : /* 5.1.4 of TS38.211 */
1678 : 0 : const double symbols_I[QAM] = {
1679 : : 3, 3, 1, 1, 3, 3, 1, 1, 5, 5, 7, 7, 5, 5, 7, 7,
1680 : : 3, 3, 1, 1, 3, 3, 1, 1, 5, 5, 7, 7, 5, 5, 7, 7,
1681 : : -3, -3, -1, -1, -3, -3, -1, -1, -5, -5, -7, -7,
1682 : : -5, -5, -7, -7, -3, -3, -1, -1, -3, -3, -1, -1,
1683 : : -5, -5, -7, -7, -5, -5, -7, -7};
1684 : 0 : const double symbols_Q[QAM] = {
1685 : : 3, 1, 3, 1, 5, 7, 5, 7, 3, 1, 3, 1, 5, 7, 5, 7,
1686 : : -3, -1, -3, -1, -5, -7, -5, -7, -3, -1, -3, -1,
1687 : : -5, -7, -5, -7, 3, 1, 3, 1, 5, 7, 5, 7, 3, 1, 3, 1,
1688 : : 5, 7, 5, 7, -3, -1, -3, -1, -5, -7, -5, -7,
1689 : : -3, -1, -3, -1, -5, -7, -5, -7};
1690 : : /* Average constellation point energy */
1691 : 0 : N0 *= 42.0;
1692 : 0 : for (k = 0; k < QM; k++)
1693 : 0 : b[k] = llrs[QM * i + k] < 0 ? 1.0 : 0.0;
1694 : : /* 5.1.4 of TS38.211 */
1695 : 0 : I = (1 - 2 * b[0])*(4 - (1 - 2 * b[2]) * (2 - (1 - 2 * b[4])));
1696 : 0 : Q = (1 - 2 * b[1])*(4 - (1 - 2 * b[3]) * (2 - (1 - 2 * b[5])));
1697 : : /* AWGN channel */
1698 : 0 : I += sqrt(N0 / 2) * randn(0);
1699 : 0 : Q += sqrt(N0 / 2) * randn(1);
1700 : : /*
1701 : : * Calculate the log of the probability that each of
1702 : : * the constellation points was transmitted
1703 : : */
1704 : 0 : for (m = 0; m < QAM; m++)
1705 : 0 : log_syml_prob[m] = -(pow(I - symbols_I[m], 2.0)
1706 : 0 : + pow(Q - symbols_Q[m], 2.0)) / N0;
1707 : : /* Calculate an LLR for each of the k_64QAM bits in the set */
1708 : 0 : for (k = 0; k < QM; k++) {
1709 : : p0 = -999999;
1710 : : p1 = -999999;
1711 : : /* For each constellation point */
1712 : 0 : for (m = 0; m < QAM; m++) {
1713 : 0 : if ((m >> (QM - k - 1)) & 1)
1714 : 0 : p1 = maxstar(p1, log_syml_prob[m]);
1715 : : else
1716 : 0 : p0 = maxstar(p0, log_syml_prob[m]);
1717 : : }
1718 : : /* Calculate the LLR */
1719 : 0 : llr_ = p0 - p1;
1720 : 0 : llr_ *= (1 << ldpc_llr_decimals);
1721 : 0 : llr_ = round(llr_);
1722 : 0 : if (llr_ > llr_max)
1723 : : llr_ = llr_max;
1724 : 0 : if (llr_ < -llr_max)
1725 : : llr_ = -llr_max;
1726 : 0 : llrs[QM * i + k] = (int8_t) llr_;
1727 : : }
1728 : : #undef QM
1729 : : #undef QAM
1730 : 0 : }
1731 : :
1732 : : /*
1733 : : * Generate Qm LLRS for Qm==4
1734 : : * Modulation, AWGN and LLR estimation from max log development
1735 : : */
1736 : : static void
1737 : 0 : gen_qm4_llr(int8_t *llrs, uint32_t i, double N0, double llr_max)
1738 : : {
1739 : : #define QM 4
1740 : : #define QAM 16
1741 : :
1742 : : int m, k;
1743 : : double I, Q, p0, p1, llr_, b[QM], log_syml_prob[QAM];
1744 : : /* 5.1.4 of TS38.211 */
1745 : 0 : const double symbols_I[QAM] = {1, 1, 3, 3, 1, 1, 3, 3,
1746 : : -1, -1, -3, -3, -1, -1, -3, -3};
1747 : 0 : const double symbols_Q[QAM] = {1, 3, 1, 3, -1, -3, -1, -3,
1748 : : 1, 3, 1, 3, -1, -3, -1, -3};
1749 : : /* Average constellation point energy */
1750 : 0 : N0 *= 10.0;
1751 : 0 : for (k = 0; k < QM; k++)
1752 : 0 : b[k] = llrs[QM * i + k] < 0 ? 1.0 : 0.0;
1753 : : /* 5.1.4 of TS38.211 */
1754 : 0 : I = (1 - 2 * b[0]) * (2 - (1 - 2 * b[2]));
1755 : 0 : Q = (1 - 2 * b[1]) * (2 - (1 - 2 * b[3]));
1756 : : /* AWGN channel */
1757 : 0 : I += sqrt(N0 / 2) * randn(0);
1758 : 0 : Q += sqrt(N0 / 2) * randn(1);
1759 : : /*
1760 : : * Calculate the log of the probability that each of
1761 : : * the constellation points was transmitted
1762 : : */
1763 : 0 : for (m = 0; m < QAM; m++)
1764 : 0 : log_syml_prob[m] = -(pow(I - symbols_I[m], 2.0)
1765 : 0 : + pow(Q - symbols_Q[m], 2.0)) / N0;
1766 : : /* Calculate an LLR for each of the k_64QAM bits in the set */
1767 : 0 : for (k = 0; k < QM; k++) {
1768 : : p0 = -999999;
1769 : : p1 = -999999;
1770 : : /* For each constellation point */
1771 : 0 : for (m = 0; m < QAM; m++) {
1772 : 0 : if ((m >> (QM - k - 1)) & 1)
1773 : 0 : p1 = maxstar(p1, log_syml_prob[m]);
1774 : : else
1775 : 0 : p0 = maxstar(p0, log_syml_prob[m]);
1776 : : }
1777 : : /* Calculate the LLR */
1778 : 0 : llr_ = p0 - p1;
1779 : 0 : llr_ *= (1 << ldpc_llr_decimals);
1780 : 0 : llr_ = round(llr_);
1781 : 0 : if (llr_ > llr_max)
1782 : : llr_ = llr_max;
1783 : 0 : if (llr_ < -llr_max)
1784 : : llr_ = -llr_max;
1785 : 0 : llrs[QM * i + k] = (int8_t) llr_;
1786 : : }
1787 : : #undef QM
1788 : : #undef QAM
1789 : 0 : }
1790 : :
1791 : : static void
1792 : 0 : gen_qm2_llr(int8_t *llrs, uint32_t j, double N0, double llr_max)
1793 : : {
1794 : : double b, b1, n;
1795 : 0 : double coeff = 2.0 * sqrt(N0);
1796 : :
1797 : : /* Ignore in vectors rare quasi null LLRs not to be saturated */
1798 : 0 : if (llrs[j] < 8 && llrs[j] > -8)
1799 : : return;
1800 : :
1801 : : /* Note don't change sign here */
1802 : 0 : n = randn(j % 2);
1803 : 0 : b1 = ((llrs[j] > 0 ? 2.0 : -2.0)
1804 : 0 : + coeff * n) / N0;
1805 : 0 : b = b1 * (1 << ldpc_llr_decimals);
1806 : 0 : b = round(b);
1807 : 0 : if (b > llr_max)
1808 : : b = llr_max;
1809 : 0 : if (b < -llr_max)
1810 : : b = -llr_max;
1811 : 0 : llrs[j] = (int8_t) b;
1812 : : }
1813 : :
1814 : : /* Simple LLR generation assuming AWGN and QPSK */
1815 : : static void
1816 : 0 : gen_turbo_llr(int8_t *llrs, uint32_t j, double N0, double llr_max)
1817 : : {
1818 : : double b, b1, n;
1819 : 0 : double coeff = 2.0 * sqrt(N0);
1820 : :
1821 : : /* Ignore in vectors null LLRs not to be saturated */
1822 : 0 : if (llrs[j] == 0)
1823 : : return;
1824 : :
1825 : : /* Note don't change sign here */
1826 : 0 : n = randn(j % 2);
1827 : 0 : b1 = ((llrs[j] > 0 ? 2.0 : -2.0)
1828 : 0 : + coeff * n) / N0;
1829 : 0 : b = b1 * (1 << 4);
1830 : 0 : b = round(b);
1831 : 0 : if (b > llr_max)
1832 : : b = llr_max;
1833 : 0 : if (b < -llr_max)
1834 : : b = -llr_max;
1835 : 0 : llrs[j] = (int8_t) b;
1836 : : }
1837 : :
1838 : : /* Generate LLR for a given SNR */
1839 : : static void
1840 : 0 : generate_llr_input(uint16_t n, struct rte_bbdev_op_data *inputs,
1841 : : struct rte_bbdev_dec_op *ref_op)
1842 : : {
1843 : : struct rte_mbuf *m;
1844 : : uint16_t qm;
1845 : : uint32_t i, j, e, range;
1846 : : double N0, llr_max;
1847 : :
1848 : 0 : e = ref_op->ldpc_dec.cb_params.e;
1849 : 0 : qm = ref_op->ldpc_dec.q_m;
1850 : 0 : llr_max = (1 << (ldpc_llr_size - 1)) - 1;
1851 : 0 : range = e / qm;
1852 : 0 : N0 = 1.0 / pow(10.0, get_snr() / 10.0);
1853 : :
1854 : 0 : for (i = 0; i < n; ++i) {
1855 : 0 : m = inputs[i].data;
1856 : 0 : int8_t *llrs = rte_pktmbuf_mtod_offset(m, int8_t *, 0);
1857 : 0 : if (qm == 8) {
1858 : 0 : for (j = 0; j < range; ++j)
1859 : 0 : gen_qm8_llr(llrs, j, N0, llr_max);
1860 : 0 : } else if (qm == 6) {
1861 : 0 : for (j = 0; j < range; ++j)
1862 : 0 : gen_qm6_llr(llrs, j, N0, llr_max);
1863 : 0 : } else if (qm == 4) {
1864 : 0 : for (j = 0; j < range; ++j)
1865 : 0 : gen_qm4_llr(llrs, j, N0, llr_max);
1866 : : } else {
1867 : 0 : for (j = 0; j < e; ++j)
1868 : 0 : gen_qm2_llr(llrs, j, N0, llr_max);
1869 : : }
1870 : : }
1871 : 0 : }
1872 : :
1873 : : /* Generate LLR for turbo decoder for a given SNR */
1874 : : static void
1875 : 0 : generate_turbo_llr_input(uint16_t n, struct rte_bbdev_op_data *inputs,
1876 : : struct rte_bbdev_dec_op *ref_op)
1877 : : {
1878 : : struct rte_mbuf *m;
1879 : : uint32_t i, j, range;
1880 : : double N0, llr_max;
1881 : :
1882 : : llr_max = 127;
1883 : 0 : range = ref_op->turbo_dec.input.length;
1884 : 0 : N0 = 1.0 / pow(10.0, get_snr() / 10.0);
1885 : :
1886 : 0 : if (range > inputs[0].data->data_len) {
1887 : 0 : printf("Warning: Limiting LLR generation to first segment (%d from %d)\n",
1888 : : inputs[0].data->data_len, range);
1889 : 0 : range = inputs[0].data->data_len;
1890 : : }
1891 : :
1892 : 0 : for (i = 0; i < n; ++i) {
1893 : 0 : m = inputs[i].data;
1894 : 0 : int8_t *llrs = rte_pktmbuf_mtod_offset(m, int8_t *, 0);
1895 : 0 : for (j = 0; j < range; ++j)
1896 : 0 : gen_turbo_llr(llrs, j, N0, llr_max);
1897 : : }
1898 : 0 : }
1899 : :
1900 : : static void
1901 : 0 : copy_reference_ldpc_dec_op(struct rte_bbdev_dec_op **ops, unsigned int n,
1902 : : unsigned int start_idx,
1903 : : struct rte_bbdev_op_data *inputs,
1904 : : struct rte_bbdev_op_data *hard_outputs,
1905 : : struct rte_bbdev_op_data *soft_outputs,
1906 : : struct rte_bbdev_op_data *harq_inputs,
1907 : : struct rte_bbdev_op_data *harq_outputs,
1908 : : struct rte_bbdev_dec_op *ref_op)
1909 : : {
1910 : : unsigned int i;
1911 : : struct rte_bbdev_op_ldpc_dec *ldpc_dec = &ref_op->ldpc_dec;
1912 : :
1913 : 0 : for (i = 0; i < n; ++i) {
1914 : 0 : if (ldpc_dec->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
1915 : 0 : ops[i]->ldpc_dec.tb_params.ea =
1916 : 0 : ldpc_dec->tb_params.ea;
1917 : 0 : ops[i]->ldpc_dec.tb_params.eb =
1918 : 0 : ldpc_dec->tb_params.eb;
1919 : 0 : ops[i]->ldpc_dec.tb_params.c =
1920 : 0 : ldpc_dec->tb_params.c;
1921 : 0 : ops[i]->ldpc_dec.tb_params.cab =
1922 : 0 : ldpc_dec->tb_params.cab;
1923 : 0 : ops[i]->ldpc_dec.tb_params.r =
1924 : 0 : ldpc_dec->tb_params.r;
1925 : : } else {
1926 : 0 : ops[i]->ldpc_dec.cb_params.e = ldpc_dec->cb_params.e;
1927 : : }
1928 : :
1929 : 0 : ops[i]->ldpc_dec.basegraph = ldpc_dec->basegraph;
1930 : 0 : ops[i]->ldpc_dec.z_c = ldpc_dec->z_c;
1931 : 0 : ops[i]->ldpc_dec.q_m = ldpc_dec->q_m;
1932 : 0 : ops[i]->ldpc_dec.n_filler = ldpc_dec->n_filler;
1933 : 0 : ops[i]->ldpc_dec.n_cb = ldpc_dec->n_cb;
1934 : 0 : ops[i]->ldpc_dec.iter_max = ldpc_dec->iter_max;
1935 : 0 : ops[i]->ldpc_dec.rv_index = ldpc_dec->rv_index;
1936 : 0 : ops[i]->ldpc_dec.k0 = ldpc_dec->k0;
1937 : 0 : ops[i]->ldpc_dec.op_flags = ldpc_dec->op_flags;
1938 : 0 : ops[i]->ldpc_dec.code_block_mode = ldpc_dec->code_block_mode;
1939 : :
1940 : 0 : if (hard_outputs != NULL)
1941 : 0 : ops[i]->ldpc_dec.hard_output =
1942 : 0 : hard_outputs[start_idx + i];
1943 : 0 : if (inputs != NULL)
1944 : 0 : ops[i]->ldpc_dec.input =
1945 : 0 : inputs[start_idx + i];
1946 : 0 : if (soft_outputs != NULL)
1947 : 0 : ops[i]->ldpc_dec.soft_output =
1948 : 0 : soft_outputs[start_idx + i];
1949 : 0 : if (harq_inputs != NULL)
1950 : 0 : ops[i]->ldpc_dec.harq_combined_input =
1951 : 0 : harq_inputs[start_idx + i];
1952 : 0 : if (harq_outputs != NULL)
1953 : 0 : ops[i]->ldpc_dec.harq_combined_output =
1954 : 0 : harq_outputs[start_idx + i];
1955 : : }
1956 : 0 : }
1957 : :
1958 : :
1959 : : static void
1960 : 0 : copy_reference_ldpc_enc_op(struct rte_bbdev_enc_op **ops, unsigned int n,
1961 : : unsigned int start_idx,
1962 : : struct rte_bbdev_op_data *inputs,
1963 : : struct rte_bbdev_op_data *outputs,
1964 : : struct rte_bbdev_enc_op *ref_op)
1965 : : {
1966 : : unsigned int i;
1967 : : struct rte_bbdev_op_ldpc_enc *ldpc_enc = &ref_op->ldpc_enc;
1968 : 0 : for (i = 0; i < n; ++i) {
1969 : 0 : if (ldpc_enc->code_block_mode == RTE_BBDEV_TRANSPORT_BLOCK) {
1970 : 0 : ops[i]->ldpc_enc.tb_params.ea = ldpc_enc->tb_params.ea;
1971 : 0 : ops[i]->ldpc_enc.tb_params.eb = ldpc_enc->tb_params.eb;
1972 : 0 : ops[i]->ldpc_enc.tb_params.cab =
1973 : 0 : ldpc_enc->tb_params.cab;
1974 : 0 : ops[i]->ldpc_enc.tb_params.c = ldpc_enc->tb_params.c;
1975 : 0 : ops[i]->ldpc_enc.tb_params.r = ldpc_enc->tb_params.r;
1976 : : } else {
1977 : 0 : ops[i]->ldpc_enc.cb_params.e = ldpc_enc->cb_params.e;
1978 : : }
1979 : 0 : ops[i]->ldpc_enc.basegraph = ldpc_enc->basegraph;
1980 : 0 : ops[i]->ldpc_enc.z_c = ldpc_enc->z_c;
1981 : 0 : ops[i]->ldpc_enc.q_m = ldpc_enc->q_m;
1982 : 0 : ops[i]->ldpc_enc.n_filler = ldpc_enc->n_filler;
1983 : 0 : ops[i]->ldpc_enc.n_cb = ldpc_enc->n_cb;
1984 : 0 : ops[i]->ldpc_enc.rv_index = ldpc_enc->rv_index;
1985 : 0 : ops[i]->ldpc_enc.op_flags = ldpc_enc->op_flags;
1986 : 0 : ops[i]->ldpc_enc.code_block_mode = ldpc_enc->code_block_mode;
1987 : 0 : ops[i]->ldpc_enc.output = outputs[start_idx + i];
1988 : 0 : ops[i]->ldpc_enc.input = inputs[start_idx + i];
1989 : : }
1990 : 0 : }
1991 : :
1992 : : static void
1993 : 0 : copy_reference_fft_op(struct rte_bbdev_fft_op **ops, unsigned int n,
1994 : : unsigned int start_idx, struct rte_bbdev_op_data *inputs,
1995 : : struct rte_bbdev_op_data *outputs, struct rte_bbdev_op_data *pwrouts,
1996 : : struct rte_bbdev_op_data *win_inputs, struct rte_bbdev_fft_op *ref_op)
1997 : : {
1998 : : unsigned int i, j;
1999 : : struct rte_bbdev_op_fft *fft = &ref_op->fft;
2000 : 0 : for (i = 0; i < n; i++) {
2001 : 0 : ops[i]->fft.input_sequence_size = fft->input_sequence_size;
2002 : 0 : ops[i]->fft.input_leading_padding = fft->input_leading_padding;
2003 : 0 : ops[i]->fft.output_sequence_size = fft->output_sequence_size;
2004 : 0 : ops[i]->fft.output_leading_depadding =
2005 : 0 : fft->output_leading_depadding;
2006 : 0 : for (j = 0; j < RTE_BBDEV_MAX_CS_2; j++)
2007 : 0 : ops[i]->fft.window_index[j] = fft->window_index[j];
2008 : 0 : for (j = 0; j < RTE_BBDEV_MAX_CS; j++) {
2009 : 0 : ops[i]->fft.cs_theta_0[j] = fft->cs_theta_0[j];
2010 : 0 : ops[i]->fft.cs_theta_d[j] = fft->cs_theta_d[j];
2011 : 0 : ops[i]->fft.time_offset[j] = fft->time_offset[j];
2012 : : }
2013 : 0 : ops[i]->fft.cs_bitmap = fft->cs_bitmap;
2014 : 0 : ops[i]->fft.num_antennas_log2 = fft->num_antennas_log2;
2015 : 0 : ops[i]->fft.idft_log2 = fft->idft_log2;
2016 : 0 : ops[i]->fft.dft_log2 = fft->dft_log2;
2017 : 0 : ops[i]->fft.cs_time_adjustment = fft->cs_time_adjustment;
2018 : 0 : ops[i]->fft.idft_shift = fft->idft_shift;
2019 : 0 : ops[i]->fft.dft_shift = fft->dft_shift;
2020 : 0 : ops[i]->fft.ncs_reciprocal = fft->ncs_reciprocal;
2021 : 0 : ops[i]->fft.power_shift = fft->power_shift;
2022 : 0 : ops[i]->fft.fp16_exp_adjust = fft->fp16_exp_adjust;
2023 : 0 : ops[i]->fft.output_depadded_size = fft->output_depadded_size;
2024 : 0 : ops[i]->fft.freq_resample_mode = fft->freq_resample_mode;
2025 : 0 : ops[i]->fft.base_output = outputs[start_idx + i];
2026 : 0 : ops[i]->fft.base_input = inputs[start_idx + i];
2027 : 0 : if (win_inputs != NULL)
2028 : 0 : ops[i]->fft.dewindowing_input = win_inputs[start_idx + i];
2029 : 0 : if (pwrouts != NULL)
2030 : 0 : ops[i]->fft.power_meas_output = pwrouts[start_idx + i];
2031 : 0 : ops[i]->fft.op_flags = fft->op_flags;
2032 : : }
2033 : 0 : }
2034 : :
2035 : : static void
2036 : 0 : copy_reference_mldts_op(struct rte_bbdev_mldts_op **ops, unsigned int n,
2037 : : unsigned int start_idx,
2038 : : struct rte_bbdev_op_data *q_inputs,
2039 : : struct rte_bbdev_op_data *r_inputs,
2040 : : struct rte_bbdev_op_data *outputs,
2041 : : struct rte_bbdev_mldts_op *ref_op)
2042 : : {
2043 : : unsigned int i, j;
2044 : : struct rte_bbdev_op_mldts *mldts = &ref_op->mldts;
2045 : 0 : for (i = 0; i < n; i++) {
2046 : 0 : ops[i]->mldts.c_rep = mldts->c_rep;
2047 : 0 : ops[i]->mldts.num_layers = mldts->num_layers;
2048 : 0 : ops[i]->mldts.num_rbs = mldts->num_rbs;
2049 : 0 : ops[i]->mldts.op_flags = mldts->op_flags;
2050 : 0 : for (j = 0; j < RTE_BBDEV_MAX_MLD_LAYERS; j++)
2051 : 0 : ops[i]->mldts.q_m[j] = mldts->q_m[j];
2052 : 0 : ops[i]->mldts.r_rep = mldts->r_rep;
2053 : 0 : ops[i]->mldts.c_rep = mldts->c_rep;
2054 : 0 : ops[i]->mldts.r_input = r_inputs[start_idx + i];
2055 : 0 : ops[i]->mldts.qhy_input = q_inputs[start_idx + i];
2056 : 0 : ops[i]->mldts.output = outputs[start_idx + i];
2057 : : }
2058 : 0 : }
2059 : :
2060 : : static int
2061 : 0 : check_dec_status_and_ordering(struct rte_bbdev_dec_op *op,
2062 : : unsigned int order_idx, const int expected_status)
2063 : : {
2064 : 0 : int status = op->status;
2065 : : /* ignore parity mismatch false alarms for long iterations */
2066 : 0 : if (get_iter_max() >= 10) {
2067 : 0 : if (!(expected_status & (1 << RTE_BBDEV_SYNDROME_ERROR)) &&
2068 : 0 : (status & (1 << RTE_BBDEV_SYNDROME_ERROR))) {
2069 : : printf("WARNING: Ignore Syndrome Check mismatch\n");
2070 : 0 : status -= (1 << RTE_BBDEV_SYNDROME_ERROR);
2071 : : }
2072 : 0 : if ((expected_status & (1 << RTE_BBDEV_SYNDROME_ERROR)) &&
2073 : 0 : !(status & (1 << RTE_BBDEV_SYNDROME_ERROR))) {
2074 : : printf("WARNING: Ignore Syndrome Check mismatch\n");
2075 : 0 : status += (1 << RTE_BBDEV_SYNDROME_ERROR);
2076 : : }
2077 : : }
2078 : :
2079 : 0 : TEST_ASSERT(status == expected_status,
2080 : : "op_status (%d) != expected_status (%d)",
2081 : : op->status, expected_status);
2082 : :
2083 : 0 : TEST_ASSERT((void *)(uintptr_t)order_idx == op->opaque_data,
2084 : : "Ordering error, expected %p, got %p",
2085 : : (void *)(uintptr_t)order_idx, op->opaque_data);
2086 : :
2087 : : return TEST_SUCCESS;
2088 : : }
2089 : :
2090 : : static int
2091 : 0 : check_enc_status_and_ordering(struct rte_bbdev_enc_op *op,
2092 : : unsigned int order_idx, const int expected_status)
2093 : : {
2094 : 0 : TEST_ASSERT(op->status == expected_status,
2095 : : "op_status (%d) != expected_status (%d)",
2096 : : op->status, expected_status);
2097 : :
2098 : 0 : TEST_ASSERT((void *)(uintptr_t)order_idx == op->opaque_data,
2099 : : "Ordering error, expected %p, got %p",
2100 : : (void *)(uintptr_t)order_idx, op->opaque_data);
2101 : :
2102 : : return TEST_SUCCESS;
2103 : : }
2104 : :
2105 : : static int
2106 : 0 : check_fft_status_and_ordering(struct rte_bbdev_fft_op *op,
2107 : : unsigned int order_idx, const int expected_status)
2108 : : {
2109 : 0 : TEST_ASSERT(op->status == expected_status,
2110 : : "op_status (%d) != expected_status (%d)",
2111 : : op->status, expected_status);
2112 : :
2113 : 0 : TEST_ASSERT((void *)(uintptr_t)order_idx == op->opaque_data,
2114 : : "Ordering error, expected %p, got %p",
2115 : : (void *)(uintptr_t)order_idx, op->opaque_data);
2116 : :
2117 : : return TEST_SUCCESS;
2118 : : }
2119 : :
2120 : : static int
2121 : 0 : check_mldts_status_and_ordering(struct rte_bbdev_mldts_op *op,
2122 : : unsigned int order_idx, const int expected_status)
2123 : : {
2124 : 0 : TEST_ASSERT(op->status == expected_status,
2125 : : "op_status (%d) != expected_status (%d)",
2126 : : op->status, expected_status);
2127 : :
2128 : 0 : TEST_ASSERT((void *)(uintptr_t)order_idx == op->opaque_data,
2129 : : "Ordering error, expected %p, got %p",
2130 : : (void *)(uintptr_t)order_idx, op->opaque_data);
2131 : :
2132 : : return TEST_SUCCESS;
2133 : : }
2134 : :
2135 : : static inline int
2136 : 0 : validate_op_chain(struct rte_bbdev_op_data *op,
2137 : : struct op_data_entries *orig_op)
2138 : : {
2139 : : uint8_t i;
2140 : 0 : struct rte_mbuf *m = op->data;
2141 : 0 : uint8_t nb_dst_segments = orig_op->nb_segments;
2142 : : uint32_t total_data_size = 0;
2143 : : bool ignore_mbuf = false; /* ignore mbuf limitations */
2144 : :
2145 : 0 : TEST_ASSERT(nb_dst_segments == m->nb_segs,
2146 : : "Number of segments differ in original (%u) and filled (%u) op",
2147 : : nb_dst_segments, m->nb_segs);
2148 : :
2149 : : /* Validate each mbuf segment length */
2150 : 0 : for (i = 0; i < nb_dst_segments; ++i) {
2151 : : /* Apply offset to the first mbuf segment */
2152 : 0 : uint16_t offset = (i == 0) ? op->offset : 0;
2153 : 0 : uint16_t data_len = rte_pktmbuf_data_len(m) - offset;
2154 : 0 : total_data_size += orig_op->segments[i].length;
2155 : :
2156 : 0 : if ((orig_op->segments[i].length + RTE_PKTMBUF_HEADROOM)
2157 : : > RTE_BBDEV_LDPC_E_MAX_MBUF)
2158 : : ignore_mbuf = true;
2159 : 0 : if (!ignore_mbuf)
2160 : 0 : TEST_ASSERT(orig_op->segments[i].length == data_len,
2161 : : "Length of segment differ in original (%u) and filled (%u) op",
2162 : : orig_op->segments[i].length, data_len);
2163 : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(orig_op->segments[i].addr,
2164 : : rte_pktmbuf_mtod_offset(m, uint32_t *, offset),
2165 : : orig_op->segments[i].length,
2166 : : "Output buffers (CB=%u) are not equal", i);
2167 : 0 : m = m->next;
2168 : : }
2169 : :
2170 : : /* Validate total mbuf pkt length */
2171 : 0 : uint32_t pkt_len = rte_pktmbuf_pkt_len(op->data) - op->offset;
2172 : 0 : if (!ignore_mbuf)
2173 : 0 : TEST_ASSERT(total_data_size == pkt_len,
2174 : : "Length of data differ in original (%u) and filled (%u) op",
2175 : : total_data_size, pkt_len);
2176 : :
2177 : : return TEST_SUCCESS;
2178 : : }
2179 : :
2180 : : /*
2181 : : * Compute K0 for a given configuration for HARQ output length computation
2182 : : * As per definition in 3GPP 38.212 Table 5.4.2.1-2
2183 : : */
2184 : : static inline uint16_t
2185 : 0 : get_k0(uint16_t n_cb, uint16_t z_c, uint8_t bg, uint8_t rv_index, uint16_t k0)
2186 : : {
2187 : 0 : if (k0 > 0)
2188 : : return k0;
2189 : 0 : if (rv_index == 0)
2190 : : return 0;
2191 : 0 : uint16_t n = (bg == 1 ? N_ZC_1 : N_ZC_2) * z_c;
2192 : 0 : if (n_cb == n) {
2193 : 0 : if (rv_index == 1)
2194 : 0 : return (bg == 1 ? K0_1_1 : K0_1_2) * z_c;
2195 : 0 : else if (rv_index == 2)
2196 : 0 : return (bg == 1 ? K0_2_1 : K0_2_2) * z_c;
2197 : : else
2198 : 0 : return (bg == 1 ? K0_3_1 : K0_3_2) * z_c;
2199 : : }
2200 : : /* LBRM case - includes a division by N */
2201 : 0 : if (rv_index == 1)
2202 : 0 : return (((bg == 1 ? K0_1_1 : K0_1_2) * n_cb)
2203 : 0 : / n) * z_c;
2204 : 0 : else if (rv_index == 2)
2205 : 0 : return (((bg == 1 ? K0_2_1 : K0_2_2) * n_cb)
2206 : 0 : / n) * z_c;
2207 : : else
2208 : 0 : return (((bg == 1 ? K0_3_1 : K0_3_2) * n_cb)
2209 : 0 : / n) * z_c;
2210 : : }
2211 : :
2212 : : /* HARQ output length including the Filler bits */
2213 : : static inline uint16_t
2214 : 0 : compute_harq_len(struct rte_bbdev_op_ldpc_dec *ops_ld)
2215 : : {
2216 : : uint16_t k0 = 0;
2217 : 0 : uint8_t max_rv = (ops_ld->rv_index == 1) ? 3 : ops_ld->rv_index;
2218 : 0 : k0 = get_k0(ops_ld->n_cb, ops_ld->z_c, ops_ld->basegraph, max_rv, ops_ld->k0);
2219 : : /* Compute RM out size and number of rows */
2220 : 0 : uint16_t parity_offset = (ops_ld->basegraph == 1 ? 20 : 8)
2221 : 0 : * ops_ld->z_c - ops_ld->n_filler;
2222 : 0 : uint16_t deRmOutSize = RTE_MIN(
2223 : : k0 + ops_ld->cb_params.e +
2224 : : ((k0 > parity_offset) ?
2225 : : 0 : ops_ld->n_filler),
2226 : : ops_ld->n_cb);
2227 : 0 : uint16_t numRows = ((deRmOutSize + ops_ld->z_c - 1)
2228 : 0 : / ops_ld->z_c);
2229 : 0 : uint16_t harq_output_len = numRows * ops_ld->z_c;
2230 : 0 : return harq_output_len;
2231 : : }
2232 : :
2233 : : static inline int
2234 : 0 : validate_op_harq_chain(struct rte_bbdev_op_data *op,
2235 : : struct op_data_entries *orig_op,
2236 : : struct rte_bbdev_op_ldpc_dec *ops_ld)
2237 : : {
2238 : : uint8_t i;
2239 : : uint32_t j, jj, k;
2240 : 0 : struct rte_mbuf *m = op->data;
2241 : 0 : uint8_t nb_dst_segments = orig_op->nb_segments;
2242 : : uint32_t total_data_size = 0;
2243 : : int8_t *harq_orig, *harq_out, abs_harq_origin;
2244 : : uint32_t byte_error = 0, cum_error = 0, error;
2245 : 0 : int16_t llr_max = (1 << (ldpc_llr_size - ldpc_llr_decimals)) - 1;
2246 : 0 : int16_t llr_max_pre_scaling = (1 << (ldpc_llr_size - 1)) - 1;
2247 : : uint16_t parity_offset;
2248 : :
2249 : 0 : TEST_ASSERT(nb_dst_segments == m->nb_segs,
2250 : : "Number of segments differ in original (%u) and filled (%u) op",
2251 : : nb_dst_segments, m->nb_segs);
2252 : :
2253 : : /* Validate each mbuf segment length */
2254 : 0 : for (i = 0; i < nb_dst_segments; ++i) {
2255 : : /* Apply offset to the first mbuf segment */
2256 : 0 : uint16_t offset = (i == 0) ? op->offset : 0;
2257 : 0 : uint16_t data_len = rte_pktmbuf_data_len(m) - offset;
2258 : 0 : total_data_size += orig_op->segments[i].length;
2259 : :
2260 : 0 : TEST_ASSERT(orig_op->segments[i].length < (uint32_t)(data_len + HARQ_MEM_TOLERANCE),
2261 : : "Length of segment differ in original (%u) and filled (%u) op",
2262 : : orig_op->segments[i].length, data_len);
2263 : 0 : harq_orig = (int8_t *) orig_op->segments[i].addr;
2264 : 0 : harq_out = rte_pktmbuf_mtod_offset(m, int8_t *, offset);
2265 : :
2266 : : /* Cannot compare HARQ output data for such cases */
2267 : 0 : if ((ldpc_llr_decimals > 1) && ((ops_ld->op_flags & RTE_BBDEV_LDPC_LLR_COMPRESSION)
2268 : : || (ops_ld->op_flags & RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION)
2269 : 0 : || (ops_ld->op_flags & RTE_BBDEV_LDPC_HARQ_4BIT_COMPRESSION)))
2270 : : break;
2271 : :
2272 : 0 : if (!(ldpc_cap_flags &
2273 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_FILLERS
2274 : 0 : ) || (ops_ld->op_flags &
2275 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK)) {
2276 : 0 : data_len -= ops_ld->z_c;
2277 : 0 : parity_offset = data_len;
2278 : : } else {
2279 : : /* Compute RM out size and number of rows */
2280 : 0 : parity_offset = (ops_ld->basegraph == 1 ? 20 : 8)
2281 : 0 : * ops_ld->z_c - ops_ld->n_filler;
2282 : 0 : uint16_t deRmOutSize = compute_harq_len(ops_ld) -
2283 : : ops_ld->n_filler;
2284 : : if (data_len > deRmOutSize)
2285 : : data_len = deRmOutSize;
2286 : : }
2287 : 0 : if (data_len > orig_op->segments[i].length)
2288 : 0 : data_len = orig_op->segments[i].length;
2289 : : /*
2290 : : * HARQ output can have minor differences
2291 : : * due to integer representation and related scaling
2292 : : */
2293 : 0 : for (j = 0, jj = 0; j < data_len; j++, jj++) {
2294 : 0 : if (j == parity_offset) {
2295 : : /* Special Handling of the filler bits */
2296 : 0 : for (k = 0; k < ops_ld->n_filler; k++) {
2297 : 0 : if (harq_out[jj] !=
2298 : : llr_max_pre_scaling) {
2299 : 0 : printf("HARQ Filler issue %d: %d %d\n",
2300 : : jj, harq_out[jj],
2301 : : llr_max);
2302 : 0 : byte_error++;
2303 : : }
2304 : 0 : jj++;
2305 : : }
2306 : : }
2307 : 0 : if (!(ops_ld->op_flags &
2308 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK)) {
2309 : 0 : if (ldpc_llr_decimals > 1)
2310 : 0 : harq_out[jj] = (harq_out[jj] + 1)
2311 : 0 : >> (ldpc_llr_decimals - 1);
2312 : : /* Saturated to S7 */
2313 : 0 : if (harq_orig[j] > llr_max)
2314 : 0 : harq_orig[j] = llr_max;
2315 : 0 : if (harq_orig[j] < -llr_max)
2316 : 0 : harq_orig[j] = -llr_max;
2317 : : }
2318 : 0 : if (harq_orig[j] != harq_out[jj]) {
2319 : : error = (harq_orig[j] > harq_out[jj]) ?
2320 : 0 : harq_orig[j] - harq_out[jj] :
2321 : 0 : harq_out[jj] - harq_orig[j];
2322 : 0 : abs_harq_origin = harq_orig[j] > 0 ?
2323 : 0 : harq_orig[j] :
2324 : : -harq_orig[j];
2325 : : /* Residual quantization error */
2326 : 0 : if ((error > 8 && (abs_harq_origin <
2327 : 0 : (llr_max - 16))) ||
2328 : : (error > 16)) {
2329 : : /*
2330 : : printf("HARQ mismatch %d: exp %d act %d => %d\n",
2331 : : j, harq_orig[j],
2332 : : harq_out[jj], error);
2333 : : */
2334 : 0 : byte_error++;
2335 : 0 : cum_error += error;
2336 : : }
2337 : : }
2338 : : }
2339 : 0 : m = m->next;
2340 : : }
2341 : :
2342 : 0 : if (byte_error)
2343 : 0 : TEST_ASSERT(byte_error <= 1,
2344 : : "HARQ output mismatch (%d) %d",
2345 : : byte_error, cum_error);
2346 : :
2347 : : /* Validate total mbuf pkt length */
2348 : 0 : uint32_t pkt_len = rte_pktmbuf_pkt_len(op->data) - op->offset;
2349 : 0 : TEST_ASSERT(total_data_size < pkt_len + HARQ_MEM_TOLERANCE,
2350 : : "Length of data differ in original (%u) and filled (%u) op",
2351 : : total_data_size, pkt_len);
2352 : :
2353 : : return TEST_SUCCESS;
2354 : : }
2355 : :
2356 : :
2357 : : static inline int
2358 : 0 : validate_op_so_chain(struct rte_bbdev_op_data *op,
2359 : : struct op_data_entries *orig_op)
2360 : : {
2361 : 0 : struct rte_mbuf *m = op->data;
2362 : 0 : uint8_t i, nb_dst_segments = orig_op->nb_segments;
2363 : : uint32_t j, jj;
2364 : : int8_t *so_orig, *so_out;
2365 : : uint32_t byte_error = 0, error, margin_error = 0;
2366 : :
2367 : 0 : TEST_ASSERT(nb_dst_segments == m->nb_segs,
2368 : : "Number of segments differ in original (%u) and filled (%u) op",
2369 : : nb_dst_segments, m->nb_segs);
2370 : :
2371 : : /* Validate each mbuf segment length. */
2372 : 0 : for (i = 0; i < nb_dst_segments; ++i) {
2373 : : /* Apply offset to the first mbuf segment. */
2374 : 0 : uint16_t offset = (i == 0) ? op->offset : 0;
2375 : 0 : uint16_t data_len = rte_pktmbuf_data_len(m) - offset;
2376 : :
2377 : 0 : TEST_ASSERT(orig_op->segments[i].length == data_len,
2378 : : "Length of segment differ in original (%u) and filled (%u) op",
2379 : : orig_op->segments[i].length, data_len);
2380 : 0 : so_orig = (int8_t *) orig_op->segments[i].addr;
2381 : 0 : so_out = rte_pktmbuf_mtod_offset(m, int8_t *, offset);
2382 : 0 : margin_error += data_len / 8; /* Allow for few % errors. */
2383 : :
2384 : : /* SO output can have minor differences due to algorithm variations. */
2385 : 0 : for (j = 0, jj = 0; j < data_len; j++, jj++) {
2386 : 0 : if (so_orig[j] != so_out[jj]) {
2387 : 0 : error = (so_orig[j] > so_out[jj]) ? so_orig[j] - so_out[jj] :
2388 : 0 : so_out[jj] - so_orig[j];
2389 : : /* Residual quantization error. */
2390 : 0 : if (error > 32) {
2391 : 0 : printf("Warning: Soft mismatch %d: exp %d act %d => %d\n",
2392 : : j, so_orig[j], so_out[jj], error);
2393 : 0 : byte_error++;
2394 : : }
2395 : : }
2396 : : }
2397 : 0 : m = m->next;
2398 : : }
2399 : :
2400 : 0 : if (byte_error > margin_error)
2401 : 0 : TEST_ASSERT(byte_error <= 1, "Soft output mismatch (%d) %d",
2402 : : byte_error, margin_error);
2403 : :
2404 : : return TEST_SUCCESS;
2405 : : }
2406 : :
2407 : : static int
2408 : 0 : validate_dec_op(struct rte_bbdev_dec_op **ops, const uint16_t n,
2409 : : struct rte_bbdev_dec_op *ref_op)
2410 : : {
2411 : : unsigned int i;
2412 : : int ret;
2413 : : struct op_data_entries *hard_data_orig =
2414 : : &test_vector.entries[DATA_HARD_OUTPUT];
2415 : : struct op_data_entries *soft_data_orig =
2416 : : &test_vector.entries[DATA_SOFT_OUTPUT];
2417 : : struct rte_bbdev_op_turbo_dec *ops_td;
2418 : : struct rte_bbdev_op_data *hard_output;
2419 : : struct rte_bbdev_op_data *soft_output;
2420 : :
2421 : 0 : for (i = 0; i < n; ++i) {
2422 : 0 : ops_td = &ops[i]->turbo_dec;
2423 : 0 : hard_output = &ops_td->hard_output;
2424 : 0 : soft_output = &ops_td->soft_output;
2425 : :
2426 : 0 : ret = check_dec_status_and_ordering(ops[i], i, ref_op->status);
2427 : 0 : TEST_ASSERT_SUCCESS(ret,
2428 : : "Checking status and ordering for decoder failed");
2429 : :
2430 : 0 : TEST_ASSERT_SUCCESS(validate_op_chain(hard_output,
2431 : : hard_data_orig),
2432 : : "Hard output buffers (CB=%u) are not equal",
2433 : : i);
2434 : :
2435 : 0 : if (ref_op->turbo_dec.op_flags & RTE_BBDEV_TURBO_SOFT_OUTPUT)
2436 : 0 : TEST_ASSERT_SUCCESS(validate_op_so_chain(soft_output,
2437 : : soft_data_orig),
2438 : : "Soft output buffers (CB=%u) are not equal",
2439 : : i);
2440 : : }
2441 : :
2442 : : return TEST_SUCCESS;
2443 : : }
2444 : :
2445 : : /* Check Number of code blocks errors */
2446 : : static int
2447 : 0 : validate_ldpc_bler(struct rte_bbdev_dec_op **ops, const uint16_t n)
2448 : : {
2449 : : unsigned int i;
2450 : : struct op_data_entries *hard_data_orig =
2451 : : &test_vector.entries[DATA_HARD_OUTPUT];
2452 : : struct rte_bbdev_op_ldpc_dec *ops_td;
2453 : : struct rte_bbdev_op_data *hard_output;
2454 : : int errors = 0;
2455 : : struct rte_mbuf *m;
2456 : :
2457 : 0 : for (i = 0; i < n; ++i) {
2458 : 0 : ops_td = &ops[i]->ldpc_dec;
2459 : : hard_output = &ops_td->hard_output;
2460 : 0 : m = hard_output->data;
2461 : 0 : if (memcmp(rte_pktmbuf_mtod_offset(m, uint32_t *, 0),
2462 : 0 : hard_data_orig->segments[0].addr,
2463 : 0 : hard_data_orig->segments[0].length))
2464 : 0 : errors++;
2465 : : }
2466 : 0 : return errors;
2467 : : }
2468 : :
2469 : : /* Check Number of code blocks errors */
2470 : : static int
2471 : 0 : validate_turbo_bler(struct rte_bbdev_dec_op **ops, const uint16_t n)
2472 : : {
2473 : : unsigned int i;
2474 : : struct op_data_entries *hard_data_orig = &test_vector.entries[DATA_HARD_OUTPUT];
2475 : : struct rte_bbdev_op_turbo_dec *ops_td;
2476 : : struct rte_bbdev_op_data *hard_output;
2477 : : int errors = 0;
2478 : : struct rte_mbuf *m;
2479 : :
2480 : 0 : for (i = 0; i < n; ++i) {
2481 : 0 : ops_td = &ops[i]->turbo_dec;
2482 : : hard_output = &ops_td->hard_output;
2483 : 0 : m = hard_output->data;
2484 : 0 : if (memcmp(rte_pktmbuf_mtod_offset(m, uint32_t *, 0),
2485 : 0 : hard_data_orig->segments[0].addr,
2486 : 0 : hard_data_orig->segments[0].length))
2487 : 0 : errors++;
2488 : : }
2489 : 0 : return errors;
2490 : : }
2491 : :
2492 : :
2493 : : static int
2494 : 0 : validate_ldpc_dec_op(struct rte_bbdev_dec_op **ops, const uint16_t n,
2495 : : struct rte_bbdev_dec_op *ref_op, const int vector_mask)
2496 : : {
2497 : : unsigned int i;
2498 : : int ret;
2499 : : struct op_data_entries *hard_data_orig =
2500 : : &test_vector.entries[DATA_HARD_OUTPUT];
2501 : : struct op_data_entries *soft_data_orig =
2502 : : &test_vector.entries[DATA_SOFT_OUTPUT];
2503 : : struct op_data_entries *harq_data_orig =
2504 : : &test_vector.entries[DATA_HARQ_OUTPUT];
2505 : : struct rte_bbdev_op_ldpc_dec *ops_td;
2506 : : struct rte_bbdev_op_data *hard_output;
2507 : : struct rte_bbdev_op_data *harq_output;
2508 : : struct rte_bbdev_op_data *soft_output;
2509 : : struct rte_bbdev_op_ldpc_dec *ref_td = &ref_op->ldpc_dec;
2510 : :
2511 : 0 : for (i = 0; i < n; ++i) {
2512 : 0 : ops_td = &ops[i]->ldpc_dec;
2513 : 0 : hard_output = &ops_td->hard_output;
2514 : 0 : harq_output = &ops_td->harq_combined_output;
2515 : 0 : soft_output = &ops_td->soft_output;
2516 : :
2517 : 0 : ret = check_dec_status_and_ordering(ops[i], i, ref_op->status);
2518 : 0 : TEST_ASSERT_SUCCESS(ret,
2519 : : "Checking status and ordering for decoder failed");
2520 : 0 : if (vector_mask & TEST_BBDEV_VF_EXPECTED_ITER_COUNT)
2521 : 0 : TEST_ASSERT(ops_td->iter_count <= ref_td->iter_count,
2522 : : "Returned iter_count (%d) > expected iter_count (%d)",
2523 : : ops_td->iter_count, ref_td->iter_count);
2524 : : /*
2525 : : * We can ignore output data when the decoding failed to
2526 : : * converge or for loop-back cases
2527 : : */
2528 : 0 : if (!check_bit(ops[i]->ldpc_dec.op_flags,
2529 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK
2530 : 0 : ) && (
2531 : 0 : ops[i]->status & (1 << RTE_BBDEV_SYNDROME_ERROR
2532 : : )) == 0)
2533 : 0 : TEST_ASSERT_SUCCESS(validate_op_chain(hard_output,
2534 : : hard_data_orig),
2535 : : "Hard output buffers (CB=%u) are not equal",
2536 : : i);
2537 : :
2538 : 0 : if (ref_op->ldpc_dec.op_flags & RTE_BBDEV_LDPC_SOFT_OUT_ENABLE)
2539 : 0 : TEST_ASSERT_SUCCESS(validate_op_so_chain(soft_output,
2540 : : soft_data_orig),
2541 : : "Soft output buffers (CB=%u) are not equal",
2542 : : i);
2543 : 0 : if (ref_op->ldpc_dec.op_flags &
2544 : : RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE) {
2545 : 0 : TEST_ASSERT_SUCCESS(validate_op_harq_chain(harq_output,
2546 : : harq_data_orig, ops_td),
2547 : : "HARQ output buffers (CB=%u) are not equal",
2548 : : i);
2549 : : }
2550 : 0 : if (ref_op->ldpc_dec.op_flags &
2551 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK)
2552 : 0 : TEST_ASSERT_SUCCESS(validate_op_harq_chain(harq_output,
2553 : : harq_data_orig, ops_td),
2554 : : "HARQ output buffers (CB=%u) are not equal",
2555 : : i);
2556 : :
2557 : : }
2558 : :
2559 : : return TEST_SUCCESS;
2560 : : }
2561 : :
2562 : :
2563 : : static int
2564 : 0 : validate_enc_op(struct rte_bbdev_enc_op **ops, const uint16_t n,
2565 : : struct rte_bbdev_enc_op *ref_op)
2566 : : {
2567 : : unsigned int i;
2568 : : int ret;
2569 : : struct op_data_entries *hard_data_orig =
2570 : : &test_vector.entries[DATA_HARD_OUTPUT];
2571 : :
2572 : 0 : for (i = 0; i < n; ++i) {
2573 : 0 : ret = check_enc_status_and_ordering(ops[i], i, ref_op->status);
2574 : 0 : TEST_ASSERT_SUCCESS(ret,
2575 : : "Checking status and ordering for encoder failed");
2576 : 0 : TEST_ASSERT_SUCCESS(validate_op_chain(
2577 : : &ops[i]->turbo_enc.output,
2578 : : hard_data_orig),
2579 : : "Output buffers (CB=%u) are not equal",
2580 : : i);
2581 : : }
2582 : :
2583 : : return TEST_SUCCESS;
2584 : : }
2585 : :
2586 : : static int
2587 : 0 : validate_ldpc_enc_op(struct rte_bbdev_enc_op **ops, const uint16_t n,
2588 : : struct rte_bbdev_enc_op *ref_op)
2589 : : {
2590 : : unsigned int i;
2591 : : int ret;
2592 : : struct op_data_entries *hard_data_orig =
2593 : : &test_vector.entries[DATA_HARD_OUTPUT];
2594 : :
2595 : 0 : for (i = 0; i < n; ++i) {
2596 : 0 : ret = check_enc_status_and_ordering(ops[i], i, ref_op->status);
2597 : 0 : TEST_ASSERT_SUCCESS(ret,
2598 : : "Checking status and ordering for encoder failed");
2599 : 0 : TEST_ASSERT_SUCCESS(validate_op_chain(
2600 : : &ops[i]->ldpc_enc.output,
2601 : : hard_data_orig),
2602 : : "Output buffers (CB=%u) are not equal",
2603 : : i);
2604 : : }
2605 : :
2606 : : return TEST_SUCCESS;
2607 : : }
2608 : :
2609 : : static inline int
2610 : 0 : validate_op_fft_chain(struct rte_bbdev_op_data *op, struct op_data_entries *orig_op,
2611 : : bool skip_validate_output)
2612 : : {
2613 : 0 : struct rte_mbuf *m = op->data;
2614 : 0 : uint8_t i, nb_dst_segments = orig_op->nb_segments;
2615 : : int16_t delt, abs_delt, thres_hold = 4;
2616 : : uint32_t j, data_len_iq, error_num;
2617 : : int16_t *ref_out, *op_out;
2618 : :
2619 : 0 : TEST_ASSERT(nb_dst_segments == m->nb_segs,
2620 : : "Number of segments differ in original (%u) and filled (%u) op fft",
2621 : : nb_dst_segments, m->nb_segs);
2622 : :
2623 : : /* Due to size limitation of mbuf, FFT doesn't use real mbuf. */
2624 : 0 : for (i = 0; i < nb_dst_segments; ++i) {
2625 : 0 : uint16_t offset = (i == 0) ? op->offset : 0;
2626 : 0 : uint32_t data_len = op->length;
2627 : :
2628 : 0 : TEST_ASSERT(orig_op->segments[i].length == data_len,
2629 : : "Length of segment differ in original (%u) and filled (%u) op fft",
2630 : : orig_op->segments[i].length, data_len);
2631 : : /* Divided by 2 to get the number of 16bits data. */
2632 : 0 : data_len_iq = data_len >> 1;
2633 : 0 : ref_out = (int16_t *)(orig_op->segments[i].addr);
2634 : 0 : op_out = rte_pktmbuf_mtod_offset(m, int16_t *, offset);
2635 : : error_num = 0;
2636 : 0 : for (j = 0; j < data_len_iq; j++) {
2637 : 0 : delt = ref_out[j] - op_out[j];
2638 : 0 : abs_delt = delt > 0 ? delt : -delt;
2639 : 0 : error_num += (abs_delt > thres_hold ? 1 : 0);
2640 : : }
2641 : 0 : if ((error_num > 0) && !skip_validate_output) {
2642 : 0 : rte_memdump(stdout, "Buffer A", ref_out, data_len);
2643 : 0 : rte_memdump(stdout, "Buffer B", op_out, data_len);
2644 : 0 : TEST_ASSERT(error_num == 0,
2645 : : "FFT Output are not matched total (%u) errors (%u)",
2646 : : data_len_iq, error_num);
2647 : : }
2648 : :
2649 : 0 : m = m->next;
2650 : : }
2651 : :
2652 : : return TEST_SUCCESS;
2653 : : }
2654 : :
2655 : : static inline int
2656 : 0 : validate_op_fft_meas_chain(struct rte_bbdev_op_data *op, struct op_data_entries *orig_op,
2657 : : bool skip_validate_output)
2658 : : {
2659 : 0 : struct rte_mbuf *m = op->data;
2660 : 0 : uint8_t i, nb_dst_segments = orig_op->nb_segments;
2661 : : double thres_hold = 1.0;
2662 : : uint32_t j, data_len_iq, error_num;
2663 : : int32_t *ref_out, *op_out;
2664 : : double estSNR, refSNR, delt, abs_delt;
2665 : :
2666 : 0 : TEST_ASSERT(nb_dst_segments == m->nb_segs,
2667 : : "Number of segments differ in original (%u) and filled (%u) op fft",
2668 : : nb_dst_segments, m->nb_segs);
2669 : :
2670 : : /* Due to size limitation of mbuf, FFT doesn't use real mbuf. */
2671 : 0 : for (i = 0; i < nb_dst_segments; ++i) {
2672 : 0 : uint16_t offset = (i == 0) ? op->offset : 0;
2673 : 0 : uint32_t data_len = op->length;
2674 : :
2675 : 0 : TEST_ASSERT(orig_op->segments[i].length == data_len,
2676 : : "Length of segment differ in original (%u) and filled (%u) op fft",
2677 : : orig_op->segments[i].length, data_len);
2678 : :
2679 : : /* Divided by 4 to get the number of 32 bits data. */
2680 : 0 : data_len_iq = data_len >> 2;
2681 : 0 : ref_out = (int32_t *)(orig_op->segments[i].addr);
2682 : 0 : op_out = rte_pktmbuf_mtod_offset(m, int32_t *, offset);
2683 : : error_num = 0;
2684 : 0 : for (j = 0; j < data_len_iq; j++) {
2685 : 0 : estSNR = 10*log10(op_out[j]);
2686 : 0 : refSNR = 10*log10(ref_out[j]);
2687 : 0 : delt = refSNR - estSNR;
2688 : 0 : abs_delt = delt > 0 ? delt : -delt;
2689 : 0 : error_num += (abs_delt > thres_hold ? 1 : 0);
2690 : : }
2691 : 0 : if ((error_num > 0) && !skip_validate_output) {
2692 : 0 : rte_memdump(stdout, "Buffer A", ref_out, data_len);
2693 : 0 : rte_memdump(stdout, "Buffer B", op_out, data_len);
2694 : 0 : TEST_ASSERT(error_num == 0,
2695 : : "FFT Output are not matched total (%u) errors (%u)",
2696 : : data_len_iq, error_num);
2697 : : }
2698 : :
2699 : 0 : m = m->next;
2700 : : }
2701 : :
2702 : : return TEST_SUCCESS;
2703 : : }
2704 : :
2705 : : static inline int
2706 : 0 : validate_op_mldts_chain(struct rte_bbdev_op_data *op,
2707 : : struct op_data_entries *orig_op)
2708 : : {
2709 : : uint8_t i;
2710 : 0 : struct rte_mbuf *m = op->data;
2711 : 0 : uint8_t nb_dst_segments = orig_op->nb_segments;
2712 : : /*the result is not bit exact*/
2713 : : int16_t thres_hold = 3;
2714 : : int16_t delt, abs_delt;
2715 : : uint32_t j, data_len_iq;
2716 : : uint32_t error_num;
2717 : : int8_t *ref_out;
2718 : : int8_t *op_out;
2719 : :
2720 : 0 : TEST_ASSERT(nb_dst_segments == m->nb_segs,
2721 : : "Number of segments differ in original (%u) and filled (%u) op mldts",
2722 : : nb_dst_segments, m->nb_segs);
2723 : :
2724 : : /* Due to size limitation of mbuf, MLDTS doesn't use real mbuf. */
2725 : 0 : for (i = 0; i < nb_dst_segments; ++i) {
2726 : 0 : uint16_t offset = (i == 0) ? op->offset : 0;
2727 : 0 : uint32_t data_len = op->length;
2728 : :
2729 : 0 : TEST_ASSERT(orig_op->segments[i].length == data_len,
2730 : : "Length of segment differ in original (%u) and filled (%u) op mldts",
2731 : : orig_op->segments[i].length, data_len);
2732 : : data_len_iq = data_len;
2733 : 0 : ref_out = (int8_t *)(orig_op->segments[i].addr);
2734 : 0 : op_out = rte_pktmbuf_mtod_offset(m, int8_t *, offset);
2735 : : error_num = 0;
2736 : 0 : for (j = 0; j < data_len_iq; j++) {
2737 : :
2738 : 0 : delt = ref_out[j] - op_out[j];
2739 : 0 : abs_delt = delt > 0 ? delt : -delt;
2740 : 0 : error_num += (abs_delt > thres_hold ? 1 : 0);
2741 : 0 : if (error_num > 0)
2742 : 0 : printf("MLD Error %d: Exp %x %d Actual %x %d Diff %d\n",
2743 : : j, ref_out[j], ref_out[j], op_out[j], op_out[j],
2744 : : delt);
2745 : : }
2746 : 0 : TEST_ASSERT(error_num == 0,
2747 : : "MLDTS Output are not matched total (%u) errors (%u)",
2748 : : data_len_iq, error_num);
2749 : :
2750 : 0 : m = m->next;
2751 : : }
2752 : :
2753 : : return TEST_SUCCESS;
2754 : : }
2755 : :
2756 : : static int
2757 : 0 : validate_fft_op(struct rte_bbdev_fft_op **ops, const uint16_t n,
2758 : : struct rte_bbdev_fft_op *ref_op)
2759 : : {
2760 : : unsigned int i;
2761 : : int ret;
2762 : : struct op_data_entries *fft_data_orig = &test_vector.entries[DATA_HARD_OUTPUT];
2763 : : struct op_data_entries *fft_pwr_orig = &test_vector.entries[DATA_SOFT_OUTPUT];
2764 : : bool skip_validate_output = false;
2765 : :
2766 : 0 : if ((test_vector.fft_window_width_vec > 0) &&
2767 : 0 : (test_vector.fft_window_width_vec != fft_window_width_dev)) {
2768 : : printf("The vector FFT width doesn't match with device - skip %d %d\n",
2769 : : test_vector.fft_window_width_vec, fft_window_width_dev);
2770 : : skip_validate_output = true;
2771 : : }
2772 : :
2773 : 0 : for (i = 0; i < n; ++i) {
2774 : 0 : ret = check_fft_status_and_ordering(ops[i], i, ref_op->status);
2775 : 0 : TEST_ASSERT_SUCCESS(ret, "Checking status and ordering for FFT failed");
2776 : 0 : TEST_ASSERT_SUCCESS(validate_op_fft_chain(
2777 : : &ops[i]->fft.base_output, fft_data_orig, skip_validate_output),
2778 : : "FFT Output buffers (op=%u) are not matched", i);
2779 : 0 : if (check_bit(ops[i]->fft.op_flags, RTE_BBDEV_FFT_POWER_MEAS))
2780 : 0 : TEST_ASSERT_SUCCESS(validate_op_fft_meas_chain(
2781 : : &ops[i]->fft.power_meas_output, fft_pwr_orig, skip_validate_output),
2782 : : "FFT Power Output buffers (op=%u) are not matched", i);
2783 : : }
2784 : :
2785 : : return TEST_SUCCESS;
2786 : : }
2787 : :
2788 : : static int
2789 : 0 : validate_mldts_op(struct rte_bbdev_mldts_op **ops, const uint16_t n,
2790 : : struct rte_bbdev_mldts_op *ref_op)
2791 : : {
2792 : : unsigned int i;
2793 : : int ret;
2794 : : struct op_data_entries *mldts_data_orig =
2795 : : &test_vector.entries[DATA_HARD_OUTPUT];
2796 : 0 : for (i = 0; i < n; ++i) {
2797 : 0 : ret = check_mldts_status_and_ordering(ops[i], i, ref_op->status);
2798 : 0 : TEST_ASSERT_SUCCESS(ret,
2799 : : "Checking status and ordering for MLDTS failed");
2800 : 0 : TEST_ASSERT_SUCCESS(validate_op_mldts_chain(
2801 : : &ops[i]->mldts.output,
2802 : : mldts_data_orig),
2803 : : "MLDTS Output buffers (op=%u) are not matched",
2804 : : i);
2805 : : }
2806 : :
2807 : : return TEST_SUCCESS;
2808 : : }
2809 : :
2810 : : static void
2811 : : create_reference_dec_op(struct rte_bbdev_dec_op *op)
2812 : : {
2813 : : unsigned int i;
2814 : : struct op_data_entries *entry;
2815 : :
2816 : 0 : op->turbo_dec = test_vector.turbo_dec;
2817 : : entry = &test_vector.entries[DATA_INPUT];
2818 : 0 : for (i = 0; i < entry->nb_segments; ++i)
2819 : 0 : op->turbo_dec.input.length +=
2820 : 0 : entry->segments[i].length;
2821 : : }
2822 : :
2823 : : static void
2824 : 0 : create_reference_ldpc_dec_op(struct rte_bbdev_dec_op *op)
2825 : : {
2826 : : unsigned int i;
2827 : : struct op_data_entries *entry;
2828 : :
2829 : 0 : op->ldpc_dec = test_vector.ldpc_dec;
2830 : : entry = &test_vector.entries[DATA_INPUT];
2831 : 0 : for (i = 0; i < entry->nb_segments; ++i)
2832 : 0 : op->ldpc_dec.input.length +=
2833 : 0 : entry->segments[i].length;
2834 : 0 : if (test_vector.ldpc_dec.op_flags &
2835 : : RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE) {
2836 : : entry = &test_vector.entries[DATA_HARQ_INPUT];
2837 : 0 : for (i = 0; i < entry->nb_segments; ++i)
2838 : 0 : op->ldpc_dec.harq_combined_input.length +=
2839 : 0 : entry->segments[i].length;
2840 : : }
2841 : 0 : }
2842 : :
2843 : : static void
2844 : 0 : create_reference_fft_op(struct rte_bbdev_fft_op *op)
2845 : : {
2846 : : unsigned int i;
2847 : : struct op_data_entries *entry;
2848 : 0 : op->fft = test_vector.fft;
2849 : : entry = &test_vector.entries[DATA_INPUT];
2850 : 0 : for (i = 0; i < entry->nb_segments; ++i)
2851 : 0 : op->fft.base_input.length += entry->segments[i].length;
2852 : : entry = &test_vector.entries[DATA_HARQ_INPUT];
2853 : 0 : for (i = 0; i < entry->nb_segments; ++i)
2854 : 0 : op->fft.dewindowing_input.length += entry->segments[i].length;
2855 : 0 : }
2856 : :
2857 : : static void
2858 : 0 : create_reference_mldts_op(struct rte_bbdev_mldts_op *op)
2859 : : {
2860 : : unsigned int i;
2861 : : struct op_data_entries *entry;
2862 : 0 : op->mldts = test_vector.mldts;
2863 : : entry = &test_vector.entries[DATA_INPUT];
2864 : 0 : for (i = 0; i < entry->nb_segments; ++i)
2865 : 0 : op->mldts.qhy_input.length += entry->segments[i].length;
2866 : : entry = &test_vector.entries[DATA_HARQ_INPUT];
2867 : 0 : for (i = 0; i < entry->nb_segments; ++i)
2868 : 0 : op->mldts.r_input.length += entry->segments[i].length;
2869 : 0 : }
2870 : :
2871 : : static void
2872 : : create_reference_enc_op(struct rte_bbdev_enc_op *op)
2873 : : {
2874 : : unsigned int i;
2875 : : struct op_data_entries *entry;
2876 : :
2877 : 0 : op->turbo_enc = test_vector.turbo_enc;
2878 : : entry = &test_vector.entries[DATA_INPUT];
2879 : 0 : for (i = 0; i < entry->nb_segments; ++i)
2880 : 0 : op->turbo_enc.input.length +=
2881 : 0 : entry->segments[i].length;
2882 : : }
2883 : :
2884 : : static void
2885 : : create_reference_ldpc_enc_op(struct rte_bbdev_enc_op *op)
2886 : : {
2887 : : unsigned int i;
2888 : : struct op_data_entries *entry;
2889 : :
2890 : 0 : op->ldpc_enc = test_vector.ldpc_enc;
2891 : : entry = &test_vector.entries[DATA_INPUT];
2892 : 0 : for (i = 0; i < entry->nb_segments; ++i)
2893 : 0 : op->ldpc_enc.input.length +=
2894 : 0 : entry->segments[i].length;
2895 : : }
2896 : :
2897 : : static uint32_t
2898 : : calc_dec_TB_size(struct rte_bbdev_dec_op *op)
2899 : : {
2900 : : uint8_t i;
2901 : : uint32_t c, r, tb_size = 0;
2902 : :
2903 : 0 : if (op->turbo_dec.code_block_mode == RTE_BBDEV_CODE_BLOCK) {
2904 : 0 : tb_size = op->turbo_dec.tb_params.k_neg;
2905 : : } else {
2906 : 0 : c = op->turbo_dec.tb_params.c;
2907 : 0 : r = op->turbo_dec.tb_params.r;
2908 : 0 : for (i = 0; i < c-r; i++)
2909 : 0 : tb_size += (r < op->turbo_dec.tb_params.c_neg) ?
2910 : 0 : op->turbo_dec.tb_params.k_neg :
2911 : 0 : op->turbo_dec.tb_params.k_pos;
2912 : : }
2913 : : return tb_size;
2914 : : }
2915 : :
2916 : : static uint32_t
2917 : : calc_ldpc_dec_TB_size(struct rte_bbdev_dec_op *op)
2918 : : {
2919 : : uint8_t num_cbs = 0;
2920 : : uint32_t tb_size = 0;
2921 : 0 : uint16_t sys_cols = (op->ldpc_dec.basegraph == 1) ? 22 : 10;
2922 : :
2923 : 0 : if (op->ldpc_dec.code_block_mode == RTE_BBDEV_CODE_BLOCK)
2924 : : num_cbs = 1;
2925 : : else
2926 : 0 : num_cbs = op->ldpc_dec.tb_params.c - op->ldpc_dec.tb_params.r;
2927 : :
2928 : 0 : tb_size = (sys_cols * op->ldpc_dec.z_c - op->ldpc_dec.n_filler) * num_cbs;
2929 : : return tb_size;
2930 : : }
2931 : :
2932 : : static uint32_t
2933 : : calc_enc_TB_size(struct rte_bbdev_enc_op *op)
2934 : : {
2935 : : uint8_t i;
2936 : : uint32_t c, r, tb_size = 0;
2937 : :
2938 : 0 : if (op->turbo_enc.code_block_mode == RTE_BBDEV_CODE_BLOCK) {
2939 : 0 : tb_size = op->turbo_enc.tb_params.k_neg;
2940 : : } else {
2941 : 0 : c = op->turbo_enc.tb_params.c;
2942 : 0 : r = op->turbo_enc.tb_params.r;
2943 : 0 : for (i = 0; i < c-r; i++)
2944 : 0 : tb_size += (r < op->turbo_enc.tb_params.c_neg) ?
2945 : 0 : op->turbo_enc.tb_params.k_neg :
2946 : 0 : op->turbo_enc.tb_params.k_pos;
2947 : : }
2948 : : return tb_size;
2949 : : }
2950 : :
2951 : : static uint32_t
2952 : : calc_ldpc_enc_TB_size(struct rte_bbdev_enc_op *op)
2953 : : {
2954 : : uint8_t num_cbs = 0;
2955 : : uint32_t tb_size = 0;
2956 : 0 : uint16_t sys_cols = (op->ldpc_enc.basegraph == 1) ? 22 : 10;
2957 : :
2958 : 0 : if (op->ldpc_enc.code_block_mode == RTE_BBDEV_CODE_BLOCK)
2959 : : num_cbs = 1;
2960 : : else
2961 : 0 : num_cbs = op->ldpc_enc.tb_params.c - op->ldpc_enc.tb_params.r;
2962 : :
2963 : 0 : tb_size = (sys_cols * op->ldpc_enc.z_c - op->ldpc_enc.n_filler) * num_cbs;
2964 : : return tb_size;
2965 : : }
2966 : :
2967 : : static uint32_t
2968 : : calc_fft_size(struct rte_bbdev_fft_op *op)
2969 : : {
2970 : : uint32_t output_size;
2971 : : int num_cs = 0, i;
2972 : 0 : for (i = 0; i < 12; i++)
2973 : 0 : if (check_bit(op->fft.cs_bitmap, 1 << i))
2974 : 0 : num_cs++;
2975 : 0 : output_size = (num_cs * op->fft.output_sequence_size * 4) << op->fft.num_antennas_log2;
2976 : : return output_size;
2977 : : }
2978 : :
2979 : : static uint32_t
2980 : : calc_mldts_size(struct rte_bbdev_mldts_op *op)
2981 : : {
2982 : : uint32_t output_size = 0;
2983 : : uint16_t i;
2984 : :
2985 : 0 : for (i = 0; i < op->mldts.num_layers; i++)
2986 : 0 : output_size += op->mldts.q_m[i];
2987 : :
2988 : 0 : output_size *= NUM_SC_PER_RB * BITS_PER_LLR * op->mldts.num_rbs * (op->mldts.c_rep + 1);
2989 : :
2990 : : return output_size;
2991 : : }
2992 : :
2993 : : static int
2994 : 0 : init_test_op_params(struct test_op_params *op_params,
2995 : : enum rte_bbdev_op_type op_type, const int expected_status,
2996 : : const int vector_mask, struct rte_mempool *ops_mp,
2997 : : uint16_t burst_sz, uint16_t num_to_process, uint16_t num_lcores)
2998 : : {
2999 : : int ret = 0;
3000 : 0 : if (op_type == RTE_BBDEV_OP_TURBO_DEC ||
3001 : 0 : op_type == RTE_BBDEV_OP_LDPC_DEC)
3002 : 0 : ret = rte_bbdev_dec_op_alloc_bulk(ops_mp,
3003 : : &op_params->ref_dec_op, 1);
3004 : 0 : else if (op_type == RTE_BBDEV_OP_FFT)
3005 : 0 : ret = rte_bbdev_fft_op_alloc_bulk(ops_mp,
3006 : : &op_params->ref_fft_op, 1);
3007 : 0 : else if (op_type == RTE_BBDEV_OP_MLDTS)
3008 : 0 : ret = rte_bbdev_mldts_op_alloc_bulk(ops_mp,
3009 : : &op_params->ref_mldts_op, 1);
3010 : : else
3011 : 0 : ret = rte_bbdev_enc_op_alloc_bulk(ops_mp,
3012 : : &op_params->ref_enc_op, 1);
3013 : :
3014 : 0 : TEST_ASSERT_SUCCESS(ret, "rte_bbdev_op_alloc_bulk() failed");
3015 : :
3016 : 0 : op_params->mp = ops_mp;
3017 : 0 : op_params->burst_sz = burst_sz;
3018 : 0 : op_params->num_to_process = num_to_process;
3019 : 0 : op_params->num_lcores = num_lcores;
3020 : 0 : op_params->vector_mask = vector_mask;
3021 : 0 : if (op_type == RTE_BBDEV_OP_TURBO_DEC ||
3022 : : op_type == RTE_BBDEV_OP_LDPC_DEC)
3023 : 0 : op_params->ref_dec_op->status = expected_status;
3024 : 0 : else if (op_type == RTE_BBDEV_OP_TURBO_ENC
3025 : 0 : || op_type == RTE_BBDEV_OP_LDPC_ENC)
3026 : 0 : op_params->ref_enc_op->status = expected_status;
3027 : 0 : else if (op_type == RTE_BBDEV_OP_FFT)
3028 : 0 : op_params->ref_fft_op->status = expected_status;
3029 : 0 : else if (op_type == RTE_BBDEV_OP_MLDTS)
3030 : 0 : op_params->ref_mldts_op->status = expected_status;
3031 : : return 0;
3032 : : }
3033 : :
3034 : : static int
3035 : 0 : run_test_case_on_device(test_case_function *test_case_func, uint8_t dev_id,
3036 : : struct test_op_params *op_params)
3037 : : {
3038 : : int t_ret, f_ret, socket_id = SOCKET_ID_ANY;
3039 : : unsigned int i;
3040 : : struct active_device *ad;
3041 : 0 : unsigned int burst_sz = get_burst_sz();
3042 : 0 : enum rte_bbdev_op_type op_type = test_vector.op_type;
3043 : : const struct rte_bbdev_op_cap *capabilities = NULL;
3044 : :
3045 : 0 : ad = &active_devs[dev_id];
3046 : :
3047 : : /* Check if device supports op_type */
3048 : 0 : if (!is_avail_op(ad, test_vector.op_type))
3049 : : return TEST_SUCCESS;
3050 : :
3051 : : struct rte_bbdev_info info;
3052 : 0 : rte_bbdev_info_get(ad->dev_id, &info);
3053 : 0 : socket_id = GET_SOCKET(info.socket_id);
3054 : :
3055 : 0 : f_ret = create_mempools(ad, socket_id, op_type,
3056 : 0 : get_num_ops());
3057 : 0 : if (f_ret != TEST_SUCCESS) {
3058 : : printf("Couldn't create mempools");
3059 : 0 : goto fail;
3060 : : }
3061 : : if (op_type == RTE_BBDEV_OP_NONE)
3062 : : op_type = RTE_BBDEV_OP_TURBO_ENC;
3063 : :
3064 : 0 : f_ret = init_test_op_params(op_params, test_vector.op_type,
3065 : : test_vector.expected_status,
3066 : : test_vector.mask,
3067 : : ad->ops_mempool,
3068 : : burst_sz,
3069 : 0 : get_num_ops(),
3070 : 0 : get_num_lcores());
3071 : 0 : if (f_ret != TEST_SUCCESS) {
3072 : : printf("Couldn't init test op params");
3073 : 0 : goto fail;
3074 : : }
3075 : :
3076 : :
3077 : : /* Find capabilities */
3078 : 0 : const struct rte_bbdev_op_cap *cap = info.drv.capabilities;
3079 : : do {
3080 : 0 : if (cap->type == test_vector.op_type) {
3081 : : capabilities = cap;
3082 : : break;
3083 : : }
3084 : 0 : cap++;
3085 : 0 : } while (cap->type != RTE_BBDEV_OP_NONE);
3086 : 0 : TEST_ASSERT_NOT_NULL(capabilities,
3087 : : "Couldn't find capabilities");
3088 : :
3089 : : if (test_vector.op_type == RTE_BBDEV_OP_TURBO_DEC) {
3090 : 0 : create_reference_dec_op(op_params->ref_dec_op);
3091 : : } else if (test_vector.op_type == RTE_BBDEV_OP_TURBO_ENC)
3092 : 0 : create_reference_enc_op(op_params->ref_enc_op);
3093 : : else if (test_vector.op_type == RTE_BBDEV_OP_LDPC_ENC)
3094 : 0 : create_reference_ldpc_enc_op(op_params->ref_enc_op);
3095 : : else if (test_vector.op_type == RTE_BBDEV_OP_LDPC_DEC)
3096 : 0 : create_reference_ldpc_dec_op(op_params->ref_dec_op);
3097 : : else if (test_vector.op_type == RTE_BBDEV_OP_FFT)
3098 : 0 : create_reference_fft_op(op_params->ref_fft_op);
3099 : : else if (test_vector.op_type == RTE_BBDEV_OP_MLDTS)
3100 : 0 : create_reference_mldts_op(op_params->ref_mldts_op);
3101 : :
3102 : 0 : for (i = 0; i < ad->nb_queues; ++i) {
3103 : 0 : f_ret = fill_queue_buffers(op_params,
3104 : : ad->in_mbuf_pool,
3105 : : ad->hard_out_mbuf_pool,
3106 : : ad->soft_out_mbuf_pool,
3107 : : ad->harq_in_mbuf_pool,
3108 : : ad->harq_out_mbuf_pool,
3109 : 0 : ad->queue_ids[i],
3110 : : capabilities,
3111 : 0 : info.drv.min_alignment,
3112 : : socket_id);
3113 : 0 : if (f_ret != TEST_SUCCESS) {
3114 : : printf("Couldn't init queue buffers");
3115 : 0 : goto fail;
3116 : : }
3117 : : }
3118 : :
3119 : : /* Run test case function */
3120 : 0 : t_ret = test_case_func(ad, op_params);
3121 : :
3122 : 0 : if (dump_ops) {
3123 : : /* Dump queue information in local file. */
3124 : : static FILE *fd;
3125 : 0 : fd = fopen("./dump_bbdev_queue_ops.txt", "w");
3126 : 0 : if (fd == NULL) {
3127 : : printf("Open dump file error.\n");
3128 : 0 : return -1;
3129 : : }
3130 : 0 : rte_bbdev_queue_ops_dump(ad->dev_id, ad->queue_ids[i], fd);
3131 : 0 : fclose(fd);
3132 : : /* Run it once only. */
3133 : 0 : dump_ops = false;
3134 : : }
3135 : :
3136 : : /* Free active device resources and return */
3137 : 0 : free_buffers(ad, op_params);
3138 : 0 : return t_ret;
3139 : :
3140 : 0 : fail:
3141 : 0 : free_buffers(ad, op_params);
3142 : 0 : return TEST_FAILED;
3143 : : }
3144 : :
3145 : : /* Run given test function per active device per supported op type
3146 : : * per burst size.
3147 : : */
3148 : : static int
3149 : 0 : run_test_case(test_case_function *test_case_func)
3150 : : {
3151 : : int ret = 0;
3152 : : uint8_t dev;
3153 : :
3154 : : /* Alloc op_params */
3155 : 0 : struct test_op_params *op_params = rte_zmalloc(NULL,
3156 : : sizeof(struct test_op_params), RTE_CACHE_LINE_SIZE);
3157 : 0 : TEST_ASSERT_NOT_NULL(op_params, "Failed to alloc %zuB for op_params",
3158 : : RTE_ALIGN(sizeof(struct test_op_params),
3159 : : RTE_CACHE_LINE_SIZE));
3160 : :
3161 : : /* For each device run test case function */
3162 : 0 : for (dev = 0; dev < nb_active_devs; ++dev)
3163 : 0 : ret |= run_test_case_on_device(test_case_func, dev, op_params);
3164 : :
3165 : 0 : rte_free(op_params);
3166 : :
3167 : 0 : return ret;
3168 : : }
3169 : :
3170 : :
3171 : : /* Push back the HARQ output from DDR to host */
3172 : : static void
3173 : 0 : retrieve_harq_ddr(uint16_t dev_id, uint16_t queue_id,
3174 : : struct rte_bbdev_dec_op **ops,
3175 : : const uint16_t n)
3176 : : {
3177 : : uint16_t j;
3178 : : int save_status, ret;
3179 : 0 : uint32_t harq_offset = (uint32_t) queue_id * HARQ_INCR * MAX_OPS;
3180 : : struct rte_bbdev_dec_op *ops_deq[MAX_BURST];
3181 : 0 : uint32_t flags = ops[0]->ldpc_dec.op_flags;
3182 : 0 : bool loopback = flags & RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK;
3183 : 0 : bool mem_out = flags & RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE;
3184 : 0 : bool hc_out = flags & RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE;
3185 : 0 : bool h_comp = flags & RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION;
3186 : 0 : for (j = 0; j < n; ++j) {
3187 : 0 : if ((loopback && mem_out) || hc_out) {
3188 : 0 : save_status = ops[j]->status;
3189 : 0 : ops[j]->ldpc_dec.op_flags =
3190 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK +
3191 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_IN_ENABLE;
3192 : 0 : if (h_comp)
3193 : 0 : ops[j]->ldpc_dec.op_flags +=
3194 : : RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION;
3195 : 0 : ops[j]->ldpc_dec.harq_combined_input.offset =
3196 : : harq_offset;
3197 : 0 : ops[j]->ldpc_dec.harq_combined_output.offset = 0;
3198 : 0 : harq_offset += HARQ_INCR;
3199 : 0 : if (!loopback)
3200 : 0 : ops[j]->ldpc_dec.harq_combined_input.length =
3201 : 0 : ops[j]->ldpc_dec.harq_combined_output.length;
3202 : 0 : rte_bbdev_enqueue_ldpc_dec_ops(dev_id, queue_id,
3203 : : &ops[j], 1);
3204 : : ret = 0;
3205 : 0 : while (ret == 0)
3206 : 0 : ret = rte_bbdev_dequeue_ldpc_dec_ops(
3207 : : dev_id, queue_id,
3208 : 0 : &ops_deq[j], 1);
3209 : 0 : ops[j]->ldpc_dec.op_flags = flags;
3210 : 0 : ops[j]->status = save_status;
3211 : : }
3212 : : }
3213 : 0 : }
3214 : :
3215 : : /*
3216 : : * Push back the HARQ output from HW DDR to Host
3217 : : * Preload HARQ memory input and adjust HARQ offset
3218 : : */
3219 : : static void
3220 : 0 : preload_harq_ddr(uint16_t dev_id, uint16_t queue_id,
3221 : : struct rte_bbdev_dec_op **ops, const uint16_t n,
3222 : : bool preload)
3223 : : {
3224 : : uint16_t j;
3225 : : int deq;
3226 : 0 : uint32_t harq_offset = (uint32_t) queue_id * HARQ_INCR * MAX_OPS;
3227 : : struct rte_bbdev_op_data save_hc_in[MAX_OPS], save_hc_out[MAX_OPS];
3228 : : struct rte_bbdev_dec_op *ops_deq[MAX_OPS];
3229 : 0 : uint32_t flags = ops[0]->ldpc_dec.op_flags;
3230 : : bool mem_in = flags & RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_IN_ENABLE;
3231 : : bool hc_in = flags & RTE_BBDEV_LDPC_HQ_COMBINE_IN_ENABLE;
3232 : : bool mem_out = flags & RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE;
3233 : : bool hc_out = flags & RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE;
3234 : 0 : bool h_comp = flags & RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION;
3235 : 0 : if ((mem_in || hc_in) && preload) {
3236 : 0 : for (j = 0; j < n; ++j) {
3237 : 0 : save_hc_in[j] = ops[j]->ldpc_dec.harq_combined_input;
3238 : 0 : save_hc_out[j] = ops[j]->ldpc_dec.harq_combined_output;
3239 : 0 : ops[j]->ldpc_dec.op_flags =
3240 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK +
3241 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE;
3242 : 0 : if (h_comp)
3243 : 0 : ops[j]->ldpc_dec.op_flags +=
3244 : : RTE_BBDEV_LDPC_HARQ_6BIT_COMPRESSION;
3245 : 0 : ops[j]->ldpc_dec.harq_combined_output.offset =
3246 : : harq_offset;
3247 : 0 : ops[j]->ldpc_dec.harq_combined_input.offset = 0;
3248 : 0 : harq_offset += HARQ_INCR;
3249 : : }
3250 : 0 : rte_bbdev_enqueue_ldpc_dec_ops(dev_id, queue_id, &ops[0], n);
3251 : : deq = 0;
3252 : 0 : while (deq != n)
3253 : 0 : deq += rte_bbdev_dequeue_ldpc_dec_ops(
3254 : : dev_id, queue_id, &ops_deq[deq],
3255 : 0 : n - deq);
3256 : : /* Restore the operations */
3257 : 0 : for (j = 0; j < n; ++j) {
3258 : 0 : ops[j]->ldpc_dec.op_flags = flags;
3259 : 0 : ops[j]->ldpc_dec.harq_combined_input = save_hc_in[j];
3260 : 0 : ops[j]->ldpc_dec.harq_combined_output = save_hc_out[j];
3261 : : }
3262 : : }
3263 : : harq_offset = (uint32_t) queue_id * HARQ_INCR * MAX_OPS;
3264 : 0 : for (j = 0; j < n; ++j) {
3265 : : /* Adjust HARQ offset when we reach external DDR */
3266 : 0 : if (mem_in || hc_in)
3267 : 0 : ops[j]->ldpc_dec.harq_combined_input.offset
3268 : 0 : = harq_offset;
3269 : 0 : if (mem_out || hc_out)
3270 : 0 : ops[j]->ldpc_dec.harq_combined_output.offset
3271 : 0 : = harq_offset;
3272 : 0 : harq_offset += HARQ_INCR;
3273 : : }
3274 : 0 : }
3275 : :
3276 : : static void
3277 : 0 : dequeue_event_callback(uint16_t dev_id,
3278 : : enum rte_bbdev_event_type event, void *cb_arg,
3279 : : void *ret_param)
3280 : : {
3281 : : int ret;
3282 : : uint16_t i;
3283 : : uint64_t total_time;
3284 : : uint16_t deq, burst_sz, num_ops;
3285 : 0 : uint16_t queue_id = *(uint16_t *) ret_param;
3286 : : struct rte_bbdev_info info;
3287 : : double tb_len_bits;
3288 : : struct thread_params *tp = cb_arg;
3289 : :
3290 : : /* Find matching thread params using queue_id */
3291 : 0 : for (i = 0; i < MAX_QUEUES; ++i, ++tp)
3292 : 0 : if (tp->queue_id == queue_id)
3293 : : break;
3294 : :
3295 : 0 : if (i == MAX_QUEUES) {
3296 : : printf("%s: Queue_id from interrupt details was not found!\n",
3297 : : __func__);
3298 : 0 : return;
3299 : : }
3300 : :
3301 : 0 : if (unlikely(event != RTE_BBDEV_EVENT_DEQUEUE)) {
3302 : 0 : rte_atomic_store_explicit(&tp->processing_status, TEST_FAILED,
3303 : : rte_memory_order_relaxed);
3304 : : printf(
3305 : : "Dequeue interrupt handler called for incorrect event!\n");
3306 : 0 : return;
3307 : : }
3308 : :
3309 : 0 : burst_sz = rte_atomic_load_explicit(&tp->burst_sz, rte_memory_order_relaxed);
3310 : 0 : num_ops = tp->op_params->num_to_process;
3311 : :
3312 : 0 : if (test_vector.op_type == RTE_BBDEV_OP_TURBO_DEC)
3313 : 0 : deq = rte_bbdev_dequeue_dec_ops(dev_id, queue_id,
3314 : : &tp->dec_ops[
3315 : 0 : rte_atomic_load_explicit(&tp->nb_dequeued,
3316 : : rte_memory_order_relaxed)],
3317 : : burst_sz);
3318 : 0 : else if (test_vector.op_type == RTE_BBDEV_OP_LDPC_DEC)
3319 : 0 : deq = rte_bbdev_dequeue_ldpc_dec_ops(dev_id, queue_id,
3320 : : &tp->dec_ops[
3321 : 0 : rte_atomic_load_explicit(&tp->nb_dequeued,
3322 : : rte_memory_order_relaxed)],
3323 : : burst_sz);
3324 : 0 : else if (test_vector.op_type == RTE_BBDEV_OP_LDPC_ENC)
3325 : 0 : deq = rte_bbdev_dequeue_ldpc_enc_ops(dev_id, queue_id,
3326 : : &tp->enc_ops[
3327 : 0 : rte_atomic_load_explicit(&tp->nb_dequeued,
3328 : : rte_memory_order_relaxed)],
3329 : : burst_sz);
3330 : 0 : else if (test_vector.op_type == RTE_BBDEV_OP_FFT)
3331 : 0 : deq = rte_bbdev_dequeue_fft_ops(dev_id, queue_id,
3332 : : &tp->fft_ops[
3333 : 0 : rte_atomic_load_explicit(&tp->nb_dequeued,
3334 : : rte_memory_order_relaxed)],
3335 : : burst_sz);
3336 : 0 : else if (test_vector.op_type == RTE_BBDEV_OP_MLDTS)
3337 : 0 : deq = rte_bbdev_dequeue_mldts_ops(dev_id, queue_id,
3338 : : &tp->mldts_ops[
3339 : 0 : rte_atomic_load_explicit(&tp->nb_dequeued,
3340 : : rte_memory_order_relaxed)],
3341 : : burst_sz);
3342 : : else /*RTE_BBDEV_OP_TURBO_ENC*/
3343 : 0 : deq = rte_bbdev_dequeue_enc_ops(dev_id, queue_id,
3344 : : &tp->enc_ops[
3345 : 0 : rte_atomic_load_explicit(&tp->nb_dequeued,
3346 : : rte_memory_order_relaxed)],
3347 : : burst_sz);
3348 : :
3349 : 0 : if (deq < burst_sz) {
3350 : 0 : printf(
3351 : : "After receiving the interrupt all operations should be dequeued. Expected: %u, got: %u\n",
3352 : : burst_sz, deq);
3353 : 0 : rte_atomic_store_explicit(&tp->processing_status, TEST_FAILED,
3354 : : rte_memory_order_relaxed);
3355 : 0 : return;
3356 : : }
3357 : :
3358 : 0 : if (rte_atomic_load_explicit(&tp->nb_dequeued, rte_memory_order_relaxed) + deq < num_ops) {
3359 : 0 : rte_atomic_fetch_add_explicit(&tp->nb_dequeued, deq, rte_memory_order_relaxed);
3360 : 0 : return;
3361 : : }
3362 : :
3363 : 0 : total_time = rte_rdtsc_precise() - tp->start_time;
3364 : :
3365 : 0 : rte_bbdev_info_get(dev_id, &info);
3366 : :
3367 : : ret = TEST_SUCCESS;
3368 : :
3369 : 0 : if (test_vector.op_type == RTE_BBDEV_OP_TURBO_DEC) {
3370 : 0 : struct rte_bbdev_dec_op *ref_op = tp->op_params->ref_dec_op;
3371 : 0 : ret = validate_dec_op(tp->dec_ops, num_ops, ref_op);
3372 : : /* get the max of iter_count for all dequeued ops */
3373 : 0 : for (i = 0; i < num_ops; ++i)
3374 : 0 : tp->iter_count = RTE_MAX(
3375 : : tp->dec_ops[i]->turbo_dec.iter_count,
3376 : : tp->iter_count);
3377 : 0 : rte_bbdev_dec_op_free_bulk(tp->dec_ops, deq);
3378 : : } else if (test_vector.op_type == RTE_BBDEV_OP_TURBO_ENC) {
3379 : 0 : struct rte_bbdev_enc_op *ref_op = tp->op_params->ref_enc_op;
3380 : 0 : ret = validate_enc_op(tp->enc_ops, num_ops, ref_op);
3381 : 0 : rte_bbdev_enc_op_free_bulk(tp->enc_ops, deq);
3382 : : } else if (test_vector.op_type == RTE_BBDEV_OP_LDPC_ENC) {
3383 : 0 : struct rte_bbdev_enc_op *ref_op = tp->op_params->ref_enc_op;
3384 : 0 : ret = validate_ldpc_enc_op(tp->enc_ops, num_ops, ref_op);
3385 : 0 : rte_bbdev_enc_op_free_bulk(tp->enc_ops, deq);
3386 : : } else if (test_vector.op_type == RTE_BBDEV_OP_FFT) {
3387 : 0 : struct rte_bbdev_fft_op *ref_op = tp->op_params->ref_fft_op;
3388 : 0 : ret = validate_fft_op(tp->fft_ops, num_ops, ref_op);
3389 : 0 : rte_bbdev_fft_op_free_bulk(tp->fft_ops, deq);
3390 : : } else if (test_vector.op_type == RTE_BBDEV_OP_MLDTS) {
3391 : 0 : struct rte_bbdev_mldts_op *ref_op = tp->op_params->ref_mldts_op;
3392 : 0 : ret = validate_mldts_op(tp->mldts_ops, num_ops, ref_op);
3393 : 0 : rte_bbdev_mldts_op_free_bulk(tp->mldts_ops, deq);
3394 : : } else if (test_vector.op_type == RTE_BBDEV_OP_LDPC_DEC) {
3395 : 0 : struct rte_bbdev_dec_op *ref_op = tp->op_params->ref_dec_op;
3396 : 0 : ret = validate_ldpc_dec_op(tp->dec_ops, num_ops, ref_op,
3397 : : tp->op_params->vector_mask);
3398 : 0 : rte_bbdev_dec_op_free_bulk(tp->dec_ops, deq);
3399 : : }
3400 : :
3401 : 0 : if (ret) {
3402 : : printf("Buffers validation failed\n");
3403 : 0 : rte_atomic_store_explicit(&tp->processing_status, TEST_FAILED,
3404 : : rte_memory_order_relaxed);
3405 : : }
3406 : :
3407 : 0 : switch (test_vector.op_type) {
3408 : 0 : case RTE_BBDEV_OP_TURBO_DEC:
3409 : 0 : tb_len_bits = calc_dec_TB_size(tp->op_params->ref_dec_op);
3410 : 0 : break;
3411 : 0 : case RTE_BBDEV_OP_TURBO_ENC:
3412 : 0 : tb_len_bits = calc_enc_TB_size(tp->op_params->ref_enc_op);
3413 : 0 : break;
3414 : 0 : case RTE_BBDEV_OP_LDPC_DEC:
3415 : 0 : tb_len_bits = calc_ldpc_dec_TB_size(tp->op_params->ref_dec_op);
3416 : 0 : break;
3417 : 0 : case RTE_BBDEV_OP_FFT:
3418 : 0 : tb_len_bits = calc_fft_size(tp->op_params->ref_fft_op);
3419 : 0 : break;
3420 : 0 : case RTE_BBDEV_OP_MLDTS:
3421 : 0 : tb_len_bits = calc_mldts_size(tp->op_params->ref_mldts_op);
3422 : 0 : break;
3423 : 0 : case RTE_BBDEV_OP_LDPC_ENC:
3424 : 0 : tb_len_bits = calc_ldpc_enc_TB_size(tp->op_params->ref_enc_op);
3425 : 0 : break;
3426 : : case RTE_BBDEV_OP_NONE:
3427 : : tb_len_bits = 0.0;
3428 : : break;
3429 : 0 : default:
3430 : : printf("Unknown op type: %d\n", test_vector.op_type);
3431 : 0 : rte_atomic_store_explicit(&tp->processing_status, TEST_FAILED,
3432 : : rte_memory_order_relaxed);
3433 : 0 : return;
3434 : : }
3435 : :
3436 : 0 : tp->ops_per_sec += ((double)num_ops) /
3437 : 0 : ((double)total_time / (double)rte_get_tsc_hz());
3438 : 0 : tp->mbps += (((double)(num_ops * tb_len_bits)) / 1000000.0) /
3439 : 0 : ((double)total_time / (double)rte_get_tsc_hz());
3440 : :
3441 : 0 : rte_atomic_fetch_add_explicit(&tp->nb_dequeued, deq, rte_memory_order_relaxed);
3442 : : }
3443 : :
3444 : : static int
3445 : 0 : throughput_intr_lcore_ldpc_dec(void *arg)
3446 : : {
3447 : : struct thread_params *tp = arg;
3448 : : unsigned int enqueued;
3449 : 0 : const uint16_t queue_id = tp->queue_id;
3450 : 0 : const uint16_t burst_sz = tp->op_params->burst_sz;
3451 : 0 : const uint16_t num_to_process = tp->op_params->num_to_process;
3452 : 0 : struct rte_bbdev_dec_op **ops = alloca(sizeof(struct rte_bbdev_dec_op *) * num_to_process);
3453 : : struct test_buffers *bufs = NULL;
3454 : : struct rte_bbdev_info info;
3455 : : int ret, i, j;
3456 : 0 : struct rte_bbdev_dec_op *ref_op = tp->op_params->ref_dec_op;
3457 : : uint16_t num_to_enq, enq;
3458 : :
3459 : 0 : bool loopback = check_bit(ref_op->ldpc_dec.op_flags,
3460 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK);
3461 : : bool hc_out = check_bit(ref_op->ldpc_dec.op_flags,
3462 : : RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE);
3463 : :
3464 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
3465 : : "BURST_SIZE should be <= %u", MAX_BURST);
3466 : :
3467 : 0 : TEST_ASSERT_SUCCESS(rte_bbdev_queue_intr_enable(tp->dev_id, queue_id),
3468 : : "Failed to enable interrupts for dev: %u, queue_id: %u",
3469 : : tp->dev_id, queue_id);
3470 : :
3471 : 0 : rte_bbdev_info_get(tp->dev_id, &info);
3472 : :
3473 : 0 : TEST_ASSERT_SUCCESS((num_to_process > info.drv.queue_size_lim),
3474 : : "NUM_OPS cannot exceed %u for this device",
3475 : : info.drv.queue_size_lim);
3476 : :
3477 : 0 : bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
3478 : :
3479 : 0 : rte_atomic_store_explicit(&tp->processing_status, 0, rte_memory_order_relaxed);
3480 : 0 : rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
3481 : :
3482 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
3483 : : rte_memory_order_relaxed);
3484 : :
3485 : 0 : ret = rte_bbdev_dec_op_alloc_bulk(tp->op_params->mp, ops,
3486 : : num_to_process);
3487 : 0 : TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops",
3488 : : num_to_process);
3489 : 0 : ref_op->ldpc_dec.iter_max = get_iter_max();
3490 : :
3491 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
3492 : 0 : copy_reference_ldpc_dec_op(ops, num_to_process, 0, bufs->inputs,
3493 : : bufs->hard_outputs, bufs->soft_outputs,
3494 : : bufs->harq_inputs, bufs->harq_outputs, ref_op);
3495 : :
3496 : : /* Set counter to validate the ordering */
3497 : 0 : for (j = 0; j < num_to_process; ++j)
3498 : 0 : ops[j]->opaque_data = (void *)(uintptr_t)j;
3499 : :
3500 : 0 : for (j = 0; j < TEST_REPETITIONS; ++j) {
3501 : 0 : for (i = 0; i < num_to_process; ++i) {
3502 : 0 : if (!loopback)
3503 : 0 : mbuf_reset(ops[i]->ldpc_dec.hard_output.data);
3504 : 0 : if (hc_out || loopback)
3505 : 0 : mbuf_reset(ops[i]->ldpc_dec.harq_combined_output.data);
3506 : 0 : if (ops[i]->ldpc_dec.soft_output.data != NULL)
3507 : : mbuf_reset(ops[i]->ldpc_dec.soft_output.data);
3508 : : }
3509 : :
3510 : 0 : tp->start_time = rte_rdtsc_precise();
3511 : 0 : for (enqueued = 0; enqueued < num_to_process;) {
3512 : : num_to_enq = burst_sz;
3513 : :
3514 : 0 : if (unlikely(num_to_process - enqueued < num_to_enq))
3515 : 0 : num_to_enq = num_to_process - enqueued;
3516 : :
3517 : : /* Write to thread burst_sz current number of enqueued
3518 : : * descriptors. It ensures that proper number of
3519 : : * descriptors will be dequeued in callback
3520 : : * function - needed for last batch in case where
3521 : : * the number of operations is not a multiple of
3522 : : * burst size.
3523 : : */
3524 : 0 : rte_atomic_store_explicit(&tp->burst_sz, num_to_enq,
3525 : : rte_memory_order_relaxed);
3526 : :
3527 : : enq = 0;
3528 : : do {
3529 : 0 : enq += rte_bbdev_enqueue_ldpc_dec_ops(
3530 : 0 : tp->dev_id,
3531 : 0 : queue_id, &ops[enqueued],
3532 : : num_to_enq);
3533 : 0 : } while (unlikely(num_to_enq != enq));
3534 : 0 : enqueued += enq;
3535 : :
3536 : : /* Wait until processing of previous batch is
3537 : : * completed
3538 : : */
3539 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->nb_dequeued, enqueued,
3540 : : rte_memory_order_relaxed);
3541 : : }
3542 : 0 : if (j != TEST_REPETITIONS - 1)
3543 : 0 : rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
3544 : : }
3545 : :
3546 : 0 : TEST_ASSERT_SUCCESS(rte_bbdev_queue_intr_disable(tp->dev_id, queue_id),
3547 : : "Failed to disable interrupts for dev: %u, queue_id: %u",
3548 : : tp->dev_id, queue_id);
3549 : :
3550 : : return TEST_SUCCESS;
3551 : : }
3552 : :
3553 : : static int
3554 : 0 : throughput_intr_lcore_dec(void *arg)
3555 : : {
3556 : : struct thread_params *tp = arg;
3557 : : unsigned int enqueued;
3558 : 0 : const uint16_t queue_id = tp->queue_id;
3559 : 0 : const uint16_t burst_sz = tp->op_params->burst_sz;
3560 : 0 : const uint16_t num_to_process = tp->op_params->num_to_process;
3561 : 0 : struct rte_bbdev_dec_op **ops = alloca(sizeof(struct rte_bbdev_dec_op *) * num_to_process);
3562 : : struct test_buffers *bufs = NULL;
3563 : : struct rte_bbdev_info info;
3564 : 0 : struct rte_bbdev_dec_op *ref_op = tp->op_params->ref_dec_op;
3565 : : int ret, i, j;
3566 : : uint16_t num_to_enq, enq;
3567 : :
3568 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
3569 : : "BURST_SIZE should be <= %u", MAX_BURST);
3570 : :
3571 : 0 : TEST_ASSERT_SUCCESS(rte_bbdev_queue_intr_enable(tp->dev_id, queue_id),
3572 : : "Failed to enable interrupts for dev: %u, queue_id: %u",
3573 : : tp->dev_id, queue_id);
3574 : :
3575 : 0 : rte_bbdev_info_get(tp->dev_id, &info);
3576 : :
3577 : 0 : TEST_ASSERT_SUCCESS((num_to_process > info.drv.queue_size_lim),
3578 : : "NUM_OPS cannot exceed %u for this device",
3579 : : info.drv.queue_size_lim);
3580 : :
3581 : 0 : bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
3582 : :
3583 : 0 : rte_atomic_store_explicit(&tp->processing_status, 0, rte_memory_order_relaxed);
3584 : 0 : rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
3585 : :
3586 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
3587 : : rte_memory_order_relaxed);
3588 : :
3589 : 0 : ret = rte_bbdev_dec_op_alloc_bulk(tp->op_params->mp, ops,
3590 : : num_to_process);
3591 : 0 : TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops", num_to_process);
3592 : 0 : ref_op->turbo_dec.iter_max = get_iter_max();
3593 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
3594 : 0 : copy_reference_dec_op(ops, num_to_process, 0, bufs->inputs,
3595 : : bufs->hard_outputs, bufs->soft_outputs,
3596 : 0 : tp->op_params->ref_dec_op);
3597 : :
3598 : : /* Set counter to validate the ordering. */
3599 : 0 : for (j = 0; j < num_to_process; ++j)
3600 : 0 : ops[j]->opaque_data = (void *)(uintptr_t)j;
3601 : :
3602 : 0 : for (j = 0; j < TEST_REPETITIONS; ++j) {
3603 : 0 : for (i = 0; i < num_to_process; ++i) {
3604 : 0 : mbuf_reset(ops[i]->turbo_dec.hard_output.data);
3605 : 0 : if (ops[i]->turbo_dec.soft_output.data != NULL)
3606 : : mbuf_reset(ops[i]->turbo_dec.soft_output.data);
3607 : : }
3608 : :
3609 : 0 : tp->start_time = rte_rdtsc_precise();
3610 : 0 : for (enqueued = 0; enqueued < num_to_process;) {
3611 : : num_to_enq = burst_sz;
3612 : :
3613 : 0 : if (unlikely(num_to_process - enqueued < num_to_enq))
3614 : 0 : num_to_enq = num_to_process - enqueued;
3615 : :
3616 : : /* Write to thread burst_sz current number of enqueued
3617 : : * descriptors. It ensures that proper number of
3618 : : * descriptors will be dequeued in callback
3619 : : * function - needed for last batch in case where
3620 : : * the number of operations is not a multiple of
3621 : : * burst size.
3622 : : */
3623 : 0 : rte_atomic_store_explicit(&tp->burst_sz, num_to_enq,
3624 : : rte_memory_order_relaxed);
3625 : :
3626 : : enq = 0;
3627 : : do {
3628 : 0 : enq += rte_bbdev_enqueue_dec_ops(tp->dev_id,
3629 : 0 : queue_id, &ops[enqueued],
3630 : : num_to_enq);
3631 : 0 : } while (unlikely(num_to_enq != enq));
3632 : 0 : enqueued += enq;
3633 : :
3634 : : /* Wait until processing of previous batch is
3635 : : * completed
3636 : : */
3637 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->nb_dequeued, enqueued,
3638 : : rte_memory_order_relaxed);
3639 : : }
3640 : 0 : if (j != TEST_REPETITIONS - 1)
3641 : 0 : rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
3642 : : }
3643 : :
3644 : 0 : TEST_ASSERT_SUCCESS(rte_bbdev_queue_intr_disable(tp->dev_id, queue_id),
3645 : : "Failed to disable interrupts for dev: %u, queue_id: %u",
3646 : : tp->dev_id, queue_id);
3647 : :
3648 : : return TEST_SUCCESS;
3649 : : }
3650 : :
3651 : : static int
3652 : 0 : throughput_intr_lcore_enc(void *arg)
3653 : : {
3654 : : struct thread_params *tp = arg;
3655 : : unsigned int enqueued;
3656 : 0 : const uint16_t queue_id = tp->queue_id;
3657 : 0 : const uint16_t burst_sz = tp->op_params->burst_sz;
3658 : 0 : const uint16_t num_to_process = tp->op_params->num_to_process;
3659 : 0 : struct rte_bbdev_enc_op **ops = alloca(sizeof(struct rte_bbdev_enc_op *) * num_to_process);
3660 : : struct test_buffers *bufs = NULL;
3661 : : struct rte_bbdev_info info;
3662 : : int ret, i, j;
3663 : : uint16_t num_to_enq, enq;
3664 : :
3665 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
3666 : : "BURST_SIZE should be <= %u", MAX_BURST);
3667 : :
3668 : 0 : TEST_ASSERT_SUCCESS(rte_bbdev_queue_intr_enable(tp->dev_id, queue_id),
3669 : : "Failed to enable interrupts for dev: %u, queue_id: %u",
3670 : : tp->dev_id, queue_id);
3671 : :
3672 : 0 : rte_bbdev_info_get(tp->dev_id, &info);
3673 : :
3674 : 0 : TEST_ASSERT_SUCCESS((num_to_process > info.drv.queue_size_lim),
3675 : : "NUM_OPS cannot exceed %u for this device",
3676 : : info.drv.queue_size_lim);
3677 : :
3678 : 0 : bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
3679 : :
3680 : 0 : rte_atomic_store_explicit(&tp->processing_status, 0, rte_memory_order_relaxed);
3681 : 0 : rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
3682 : :
3683 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
3684 : : rte_memory_order_relaxed);
3685 : :
3686 : 0 : ret = rte_bbdev_enc_op_alloc_bulk(tp->op_params->mp, ops,
3687 : : num_to_process);
3688 : 0 : TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops",
3689 : : num_to_process);
3690 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
3691 : 0 : copy_reference_enc_op(ops, num_to_process, 0, bufs->inputs,
3692 : 0 : bufs->hard_outputs, tp->op_params->ref_enc_op);
3693 : :
3694 : : /* Set counter to validate the ordering */
3695 : 0 : for (j = 0; j < num_to_process; ++j)
3696 : 0 : ops[j]->opaque_data = (void *)(uintptr_t)j;
3697 : :
3698 : 0 : for (j = 0; j < TEST_REPETITIONS; ++j) {
3699 : 0 : for (i = 0; i < num_to_process; ++i)
3700 : 0 : mbuf_reset(ops[i]->turbo_enc.output.data);
3701 : :
3702 : 0 : tp->start_time = rte_rdtsc_precise();
3703 : 0 : for (enqueued = 0; enqueued < num_to_process;) {
3704 : : num_to_enq = burst_sz;
3705 : :
3706 : 0 : if (unlikely(num_to_process - enqueued < num_to_enq))
3707 : 0 : num_to_enq = num_to_process - enqueued;
3708 : :
3709 : : /* Write to thread burst_sz current number of enqueued
3710 : : * descriptors. It ensures that proper number of
3711 : : * descriptors will be dequeued in callback
3712 : : * function - needed for last batch in case where
3713 : : * the number of operations is not a multiple of
3714 : : * burst size.
3715 : : */
3716 : 0 : rte_atomic_store_explicit(&tp->burst_sz, num_to_enq,
3717 : : rte_memory_order_relaxed);
3718 : :
3719 : : enq = 0;
3720 : : do {
3721 : 0 : enq += rte_bbdev_enqueue_enc_ops(tp->dev_id,
3722 : 0 : queue_id, &ops[enqueued],
3723 : : num_to_enq);
3724 : 0 : } while (unlikely(enq != num_to_enq));
3725 : 0 : enqueued += enq;
3726 : :
3727 : : /* Wait until processing of previous batch is
3728 : : * completed
3729 : : */
3730 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->nb_dequeued, enqueued,
3731 : : rte_memory_order_relaxed);
3732 : : }
3733 : 0 : if (j != TEST_REPETITIONS - 1)
3734 : 0 : rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
3735 : : }
3736 : :
3737 : 0 : TEST_ASSERT_SUCCESS(rte_bbdev_queue_intr_disable(tp->dev_id, queue_id),
3738 : : "Failed to disable interrupts for dev: %u, queue_id: %u",
3739 : : tp->dev_id, queue_id);
3740 : :
3741 : : return TEST_SUCCESS;
3742 : : }
3743 : :
3744 : :
3745 : : static int
3746 : 0 : throughput_intr_lcore_ldpc_enc(void *arg)
3747 : : {
3748 : : struct thread_params *tp = arg;
3749 : : unsigned int enqueued;
3750 : 0 : const uint16_t queue_id = tp->queue_id;
3751 : 0 : const uint16_t burst_sz = tp->op_params->burst_sz;
3752 : 0 : const uint16_t num_to_process = tp->op_params->num_to_process;
3753 : 0 : struct rte_bbdev_enc_op **ops = alloca(sizeof(struct rte_bbdev_enc_op *) * num_to_process);
3754 : : struct test_buffers *bufs = NULL;
3755 : : struct rte_bbdev_info info;
3756 : : int ret, i, j;
3757 : : uint16_t num_to_enq, enq;
3758 : :
3759 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
3760 : : "BURST_SIZE should be <= %u", MAX_BURST);
3761 : :
3762 : 0 : TEST_ASSERT_SUCCESS(rte_bbdev_queue_intr_enable(tp->dev_id, queue_id),
3763 : : "Failed to enable interrupts for dev: %u, queue_id: %u",
3764 : : tp->dev_id, queue_id);
3765 : :
3766 : 0 : rte_bbdev_info_get(tp->dev_id, &info);
3767 : :
3768 : 0 : TEST_ASSERT_SUCCESS((num_to_process > info.drv.queue_size_lim),
3769 : : "NUM_OPS cannot exceed %u for this device",
3770 : : info.drv.queue_size_lim);
3771 : :
3772 : 0 : bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
3773 : :
3774 : 0 : rte_atomic_store_explicit(&tp->processing_status, 0, rte_memory_order_relaxed);
3775 : 0 : rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
3776 : :
3777 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
3778 : : rte_memory_order_relaxed);
3779 : :
3780 : 0 : ret = rte_bbdev_enc_op_alloc_bulk(tp->op_params->mp, ops,
3781 : : num_to_process);
3782 : 0 : TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops",
3783 : : num_to_process);
3784 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
3785 : 0 : copy_reference_ldpc_enc_op(ops, num_to_process, 0,
3786 : : bufs->inputs, bufs->hard_outputs,
3787 : 0 : tp->op_params->ref_enc_op);
3788 : :
3789 : : /* Set counter to validate the ordering */
3790 : 0 : for (j = 0; j < num_to_process; ++j)
3791 : 0 : ops[j]->opaque_data = (void *)(uintptr_t)j;
3792 : :
3793 : 0 : for (j = 0; j < TEST_REPETITIONS; ++j) {
3794 : 0 : for (i = 0; i < num_to_process; ++i)
3795 : 0 : mbuf_reset(ops[i]->turbo_enc.output.data);
3796 : :
3797 : 0 : tp->start_time = rte_rdtsc_precise();
3798 : 0 : for (enqueued = 0; enqueued < num_to_process;) {
3799 : : num_to_enq = burst_sz;
3800 : :
3801 : 0 : if (unlikely(num_to_process - enqueued < num_to_enq))
3802 : 0 : num_to_enq = num_to_process - enqueued;
3803 : :
3804 : : /* Write to thread burst_sz current number of enqueued
3805 : : * descriptors. It ensures that proper number of
3806 : : * descriptors will be dequeued in callback
3807 : : * function - needed for last batch in case where
3808 : : * the number of operations is not a multiple of
3809 : : * burst size.
3810 : : */
3811 : 0 : rte_atomic_store_explicit(&tp->burst_sz, num_to_enq,
3812 : : rte_memory_order_relaxed);
3813 : :
3814 : : enq = 0;
3815 : : do {
3816 : 0 : enq += rte_bbdev_enqueue_ldpc_enc_ops(
3817 : 0 : tp->dev_id,
3818 : 0 : queue_id, &ops[enqueued],
3819 : : num_to_enq);
3820 : 0 : } while (unlikely(enq != num_to_enq));
3821 : 0 : enqueued += enq;
3822 : :
3823 : : /* Wait until processing of previous batch is
3824 : : * completed
3825 : : */
3826 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->nb_dequeued, enqueued,
3827 : : rte_memory_order_relaxed);
3828 : : }
3829 : 0 : if (j != TEST_REPETITIONS - 1)
3830 : 0 : rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
3831 : : }
3832 : :
3833 : 0 : TEST_ASSERT_SUCCESS(rte_bbdev_queue_intr_disable(tp->dev_id, queue_id),
3834 : : "Failed to disable interrupts for dev: %u, queue_id: %u",
3835 : : tp->dev_id, queue_id);
3836 : :
3837 : : return TEST_SUCCESS;
3838 : : }
3839 : :
3840 : :
3841 : : static int
3842 : 0 : throughput_intr_lcore_fft(void *arg)
3843 : : {
3844 : : struct thread_params *tp = arg;
3845 : : unsigned int enqueued;
3846 : 0 : const uint16_t queue_id = tp->queue_id;
3847 : 0 : const uint16_t burst_sz = tp->op_params->burst_sz;
3848 : 0 : const uint16_t num_to_process = tp->op_params->num_to_process;
3849 : 0 : struct rte_bbdev_fft_op **ops = alloca(sizeof(struct rte_bbdev_fft_op *) * num_to_process);
3850 : : struct test_buffers *bufs = NULL;
3851 : : struct rte_bbdev_info info;
3852 : : int ret, i, j;
3853 : : uint16_t num_to_enq, enq;
3854 : :
3855 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
3856 : : "BURST_SIZE should be <= %u", MAX_BURST);
3857 : :
3858 : 0 : TEST_ASSERT_SUCCESS(rte_bbdev_queue_intr_enable(tp->dev_id, queue_id),
3859 : : "Failed to enable interrupts for dev: %u, queue_id: %u",
3860 : : tp->dev_id, queue_id);
3861 : :
3862 : 0 : rte_bbdev_info_get(tp->dev_id, &info);
3863 : :
3864 : 0 : TEST_ASSERT_SUCCESS((num_to_process > info.drv.queue_size_lim),
3865 : : "NUM_OPS cannot exceed %u for this device",
3866 : : info.drv.queue_size_lim);
3867 : :
3868 : 0 : bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
3869 : :
3870 : 0 : rte_atomic_store_explicit(&tp->processing_status, 0, rte_memory_order_relaxed);
3871 : 0 : rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
3872 : :
3873 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
3874 : : rte_memory_order_relaxed);
3875 : :
3876 : 0 : ret = rte_bbdev_fft_op_alloc_bulk(tp->op_params->mp, ops,
3877 : : num_to_process);
3878 : 0 : TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops",
3879 : : num_to_process);
3880 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
3881 : 0 : copy_reference_fft_op(ops, num_to_process, 0, bufs->inputs,
3882 : : bufs->hard_outputs, bufs->soft_outputs, bufs->harq_inputs,
3883 : 0 : tp->op_params->ref_fft_op);
3884 : :
3885 : : /* Set counter to validate the ordering */
3886 : 0 : for (j = 0; j < num_to_process; ++j)
3887 : 0 : ops[j]->opaque_data = (void *)(uintptr_t)j;
3888 : :
3889 : 0 : for (j = 0; j < TEST_REPETITIONS; ++j) {
3890 : 0 : for (i = 0; i < num_to_process; ++i)
3891 : 0 : mbuf_reset(ops[i]->fft.base_output.data);
3892 : :
3893 : 0 : tp->start_time = rte_rdtsc_precise();
3894 : 0 : for (enqueued = 0; enqueued < num_to_process;) {
3895 : : num_to_enq = burst_sz;
3896 : :
3897 : 0 : if (unlikely(num_to_process - enqueued < num_to_enq))
3898 : 0 : num_to_enq = num_to_process - enqueued;
3899 : :
3900 : : /* Write to thread burst_sz current number of enqueued
3901 : : * descriptors. It ensures that proper number of
3902 : : * descriptors will be dequeued in callback
3903 : : * function - needed for last batch in case where
3904 : : * the number of operations is not a multiple of
3905 : : * burst size.
3906 : : */
3907 : 0 : rte_atomic_store_explicit(&tp->burst_sz, num_to_enq,
3908 : : rte_memory_order_relaxed);
3909 : :
3910 : : enq = 0;
3911 : : do {
3912 : 0 : enq += rte_bbdev_enqueue_fft_ops(tp->dev_id,
3913 : 0 : queue_id, &ops[enqueued],
3914 : : num_to_enq);
3915 : 0 : } while (unlikely(enq != num_to_enq));
3916 : 0 : enqueued += enq;
3917 : :
3918 : : /* Wait until processing of previous batch is
3919 : : * completed
3920 : : */
3921 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->nb_dequeued, enqueued,
3922 : : rte_memory_order_relaxed);
3923 : : }
3924 : 0 : if (j != TEST_REPETITIONS - 1)
3925 : 0 : rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
3926 : : }
3927 : :
3928 : 0 : TEST_ASSERT_SUCCESS(rte_bbdev_queue_intr_disable(tp->dev_id, queue_id),
3929 : : "Failed to disable interrupts for dev: %u, queue_id: %u",
3930 : : tp->dev_id, queue_id);
3931 : :
3932 : : return TEST_SUCCESS;
3933 : : }
3934 : :
3935 : : static int
3936 : 0 : throughput_intr_lcore_mldts(void *arg)
3937 : : {
3938 : : struct thread_params *tp = arg;
3939 : : unsigned int enqueued;
3940 : 0 : const uint16_t queue_id = tp->queue_id;
3941 : 0 : const uint16_t burst_sz = tp->op_params->burst_sz;
3942 : 0 : const uint16_t num_to_process = tp->op_params->num_to_process;
3943 : : struct rte_bbdev_mldts_op **ops =
3944 : 0 : alloca(sizeof(struct rte_bbdev_mldts_op *) * num_to_process);
3945 : : struct test_buffers *bufs = NULL;
3946 : : struct rte_bbdev_info info;
3947 : : int ret, i, j;
3948 : : uint16_t num_to_enq, enq;
3949 : :
3950 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST), "BURST_SIZE should be <= %u", MAX_BURST);
3951 : :
3952 : 0 : TEST_ASSERT_SUCCESS(rte_bbdev_queue_intr_enable(tp->dev_id, queue_id),
3953 : : "Failed to enable interrupts for dev: %u, queue_id: %u",
3954 : : tp->dev_id, queue_id);
3955 : :
3956 : 0 : rte_bbdev_info_get(tp->dev_id, &info);
3957 : :
3958 : 0 : TEST_ASSERT_SUCCESS((num_to_process > info.drv.queue_size_lim),
3959 : : "NUM_OPS cannot exceed %u for this device",
3960 : : info.drv.queue_size_lim);
3961 : :
3962 : 0 : bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
3963 : :
3964 : 0 : rte_atomic_store_explicit(&tp->processing_status, 0, rte_memory_order_relaxed);
3965 : 0 : rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
3966 : :
3967 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
3968 : : rte_memory_order_relaxed);
3969 : :
3970 : 0 : ret = rte_bbdev_mldts_op_alloc_bulk(tp->op_params->mp, ops, num_to_process);
3971 : 0 : TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops", num_to_process);
3972 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
3973 : 0 : copy_reference_mldts_op(ops, num_to_process, 0, bufs->inputs, bufs->harq_inputs,
3974 : 0 : bufs->hard_outputs, tp->op_params->ref_mldts_op);
3975 : :
3976 : : /* Set counter to validate the ordering */
3977 : 0 : for (j = 0; j < num_to_process; ++j)
3978 : 0 : ops[j]->opaque_data = (void *)(uintptr_t)j;
3979 : :
3980 : 0 : for (j = 0; j < TEST_REPETITIONS; ++j) {
3981 : 0 : for (i = 0; i < num_to_process; ++i)
3982 : 0 : mbuf_reset(ops[i]->mldts.output.data);
3983 : :
3984 : 0 : tp->start_time = rte_rdtsc_precise();
3985 : 0 : for (enqueued = 0; enqueued < num_to_process;) {
3986 : : num_to_enq = burst_sz;
3987 : :
3988 : 0 : if (unlikely(num_to_process - enqueued < num_to_enq))
3989 : 0 : num_to_enq = num_to_process - enqueued;
3990 : :
3991 : : /* Write to thread burst_sz current number of enqueued
3992 : : * descriptors. It ensures that proper number of
3993 : : * descriptors will be dequeued in callback
3994 : : * function - needed for last batch in case where
3995 : : * the number of operations is not a multiple of
3996 : : * burst size.
3997 : : */
3998 : 0 : rte_atomic_store_explicit(&tp->burst_sz, num_to_enq,
3999 : : rte_memory_order_relaxed);
4000 : :
4001 : : enq = 0;
4002 : : do {
4003 : 0 : enq += rte_bbdev_enqueue_mldts_ops(tp->dev_id,
4004 : 0 : queue_id, &ops[enqueued], num_to_enq);
4005 : 0 : } while (unlikely(enq != num_to_enq));
4006 : 0 : enqueued += enq;
4007 : :
4008 : : /* Wait until processing of previous batch is
4009 : : * completed
4010 : : */
4011 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->nb_dequeued, enqueued,
4012 : : rte_memory_order_relaxed);
4013 : : }
4014 : 0 : if (j != TEST_REPETITIONS - 1)
4015 : 0 : rte_atomic_store_explicit(&tp->nb_dequeued, 0, rte_memory_order_relaxed);
4016 : : }
4017 : :
4018 : 0 : TEST_ASSERT_SUCCESS(rte_bbdev_queue_intr_disable(tp->dev_id, queue_id),
4019 : : "Failed to disable interrupts for dev: %u, queue_id: %u",
4020 : : tp->dev_id, queue_id);
4021 : :
4022 : : return TEST_SUCCESS;
4023 : : }
4024 : :
4025 : : static int
4026 : 0 : throughput_pmd_lcore_dec(void *arg)
4027 : : {
4028 : : struct thread_params *tp = arg;
4029 : : uint16_t enq, deq;
4030 : : uint64_t total_time = 0, start_time;
4031 : 0 : const uint16_t queue_id = tp->queue_id;
4032 : 0 : const uint16_t burst_sz = tp->op_params->burst_sz;
4033 : 0 : const uint16_t num_ops = tp->op_params->num_to_process;
4034 : 0 : struct rte_bbdev_dec_op **ops_enq = alloca(sizeof(struct rte_bbdev_dec_op *) * num_ops);
4035 : 0 : struct rte_bbdev_dec_op **ops_deq = alloca(sizeof(struct rte_bbdev_dec_op *) * num_ops);
4036 : 0 : struct rte_bbdev_dec_op *ref_op = tp->op_params->ref_dec_op;
4037 : : struct test_buffers *bufs = NULL;
4038 : : int i, j, ret;
4039 : : struct rte_bbdev_info info;
4040 : : uint16_t num_to_enq;
4041 : : bool so_enable;
4042 : :
4043 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
4044 : : "BURST_SIZE should be <= %u", MAX_BURST);
4045 : :
4046 : 0 : rte_bbdev_info_get(tp->dev_id, &info);
4047 : :
4048 : 0 : TEST_ASSERT_SUCCESS((num_ops > info.drv.queue_size_lim),
4049 : : "NUM_OPS cannot exceed %u for this device",
4050 : : info.drv.queue_size_lim);
4051 : :
4052 : 0 : bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
4053 : :
4054 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
4055 : : rte_memory_order_relaxed);
4056 : :
4057 : 0 : ret = rte_bbdev_dec_op_alloc_bulk(tp->op_params->mp, ops_enq, num_ops);
4058 : 0 : TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops", num_ops);
4059 : 0 : ref_op->turbo_dec.iter_max = get_iter_max();
4060 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
4061 : 0 : copy_reference_dec_op(ops_enq, num_ops, 0, bufs->inputs,
4062 : : bufs->hard_outputs, bufs->soft_outputs, ref_op);
4063 : :
4064 : 0 : so_enable = check_bit(ops_enq[0]->turbo_dec.op_flags, RTE_BBDEV_TURBO_SOFT_OUTPUT);
4065 : :
4066 : : /* Set counter to validate the ordering */
4067 : 0 : for (j = 0; j < num_ops; ++j)
4068 : 0 : ops_enq[j]->opaque_data = (void *)(uintptr_t)j;
4069 : :
4070 : 0 : for (i = 0; i < TEST_REPETITIONS; ++i) {
4071 : : uint32_t time_out = 0;
4072 : 0 : for (j = 0; j < num_ops; ++j)
4073 : 0 : mbuf_reset(ops_enq[j]->turbo_dec.hard_output.data);
4074 : 0 : if (so_enable)
4075 : 0 : for (j = 0; j < num_ops; ++j)
4076 : 0 : mbuf_reset(ops_enq[j]->turbo_dec.soft_output.data);
4077 : :
4078 : : start_time = rte_rdtsc_precise();
4079 : :
4080 : 0 : for (enq = 0, deq = 0; enq < num_ops;) {
4081 : : num_to_enq = burst_sz;
4082 : :
4083 : 0 : if (unlikely(num_ops - enq < num_to_enq))
4084 : 0 : num_to_enq = num_ops - enq;
4085 : :
4086 : 0 : enq += rte_bbdev_enqueue_dec_ops(tp->dev_id,
4087 : 0 : queue_id, &ops_enq[enq], num_to_enq);
4088 : :
4089 : 0 : deq += rte_bbdev_dequeue_dec_ops(tp->dev_id,
4090 : 0 : queue_id, &ops_deq[deq], enq - deq);
4091 : 0 : time_out++;
4092 : 0 : if (time_out >= TIME_OUT_POLL) {
4093 : 0 : timeout_exit(tp->dev_id);
4094 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Enqueue timeout!");
4095 : : }
4096 : : }
4097 : :
4098 : : /* dequeue the remaining */
4099 : : time_out = 0;
4100 : 0 : while (deq < enq) {
4101 : 0 : deq += rte_bbdev_dequeue_dec_ops(tp->dev_id,
4102 : 0 : queue_id, &ops_deq[deq], enq - deq);
4103 : 0 : time_out++;
4104 : 0 : if (time_out >= TIME_OUT_POLL) {
4105 : 0 : timeout_exit(tp->dev_id);
4106 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Dequeue timeout!");
4107 : : }
4108 : : }
4109 : :
4110 : 0 : total_time += rte_rdtsc_precise() - start_time;
4111 : : }
4112 : :
4113 : 0 : tp->iter_count = 0;
4114 : : /* get the max of iter_count for all dequeued ops */
4115 : 0 : for (i = 0; i < num_ops; ++i) {
4116 : 0 : tp->iter_count = RTE_MAX(ops_enq[i]->turbo_dec.iter_count,
4117 : : tp->iter_count);
4118 : : }
4119 : :
4120 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE) {
4121 : 0 : ret = validate_dec_op(ops_deq, num_ops, ref_op);
4122 : 0 : TEST_ASSERT_SUCCESS(ret, "Validation failed!");
4123 : : }
4124 : :
4125 : 0 : rte_bbdev_dec_op_free_bulk(ops_enq, num_ops);
4126 : :
4127 : 0 : double tb_len_bits = calc_dec_TB_size(ref_op);
4128 : :
4129 : 0 : tp->ops_per_sec = ((double)num_ops * TEST_REPETITIONS) /
4130 : 0 : ((double)total_time / (double)rte_get_tsc_hz());
4131 : 0 : tp->mbps = (((double)(num_ops * TEST_REPETITIONS * tb_len_bits)) /
4132 : 0 : 1000000.0) / ((double)total_time /
4133 : 0 : (double)rte_get_tsc_hz());
4134 : :
4135 : 0 : return TEST_SUCCESS;
4136 : : }
4137 : :
4138 : : static int
4139 : 0 : bler_pmd_lcore_ldpc_dec(void *arg)
4140 : : {
4141 : : struct thread_params *tp = arg;
4142 : : uint16_t enq, deq;
4143 : : uint64_t total_time = 0, start_time;
4144 : 0 : const uint16_t queue_id = tp->queue_id;
4145 : 0 : const uint16_t burst_sz = tp->op_params->burst_sz;
4146 : 0 : const uint16_t num_ops = tp->op_params->num_to_process;
4147 : 0 : struct rte_bbdev_dec_op **ops_enq = alloca(sizeof(struct rte_bbdev_dec_op *) * num_ops);
4148 : 0 : struct rte_bbdev_dec_op **ops_deq = alloca(sizeof(struct rte_bbdev_dec_op *) * num_ops);
4149 : 0 : struct rte_bbdev_dec_op *ref_op = tp->op_params->ref_dec_op;
4150 : : struct test_buffers *bufs = NULL;
4151 : : int i, j, ret;
4152 : : float parity_bler = 0;
4153 : : struct rte_bbdev_info info;
4154 : : uint16_t num_to_enq;
4155 : 0 : bool extDdr = check_bit(ldpc_cap_flags,
4156 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE);
4157 : 0 : bool loopback = check_bit(ref_op->ldpc_dec.op_flags,
4158 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK);
4159 : : bool hc_out = check_bit(ref_op->ldpc_dec.op_flags,
4160 : : RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE);
4161 : :
4162 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
4163 : : "BURST_SIZE should be <= %u", MAX_BURST);
4164 : 0 : TEST_ASSERT_SUCCESS((num_ops == 0), "NUM_OPS must be greater than 0");
4165 : :
4166 : 0 : rte_bbdev_info_get(tp->dev_id, &info);
4167 : :
4168 : 0 : TEST_ASSERT_SUCCESS((num_ops > info.drv.queue_size_lim),
4169 : : "NUM_OPS cannot exceed %u for this device",
4170 : : info.drv.queue_size_lim);
4171 : :
4172 : 0 : bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
4173 : :
4174 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
4175 : : rte_memory_order_relaxed);
4176 : :
4177 : 0 : ret = rte_bbdev_dec_op_alloc_bulk(tp->op_params->mp, ops_enq, num_ops);
4178 : 0 : TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops", num_ops);
4179 : :
4180 : : /* For BLER tests we need to enable early termination */
4181 : 0 : if (!check_bit(ref_op->ldpc_dec.op_flags, RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE))
4182 : 0 : ref_op->ldpc_dec.op_flags += RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE;
4183 : :
4184 : 0 : ref_op->ldpc_dec.iter_max = get_iter_max();
4185 : :
4186 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
4187 : 0 : copy_reference_ldpc_dec_op(ops_enq, num_ops, 0, bufs->inputs,
4188 : : bufs->hard_outputs, bufs->soft_outputs,
4189 : : bufs->harq_inputs, bufs->harq_outputs, ref_op);
4190 : 0 : generate_llr_input(num_ops, bufs->inputs, ref_op);
4191 : :
4192 : : /* Set counter to validate the ordering */
4193 : 0 : for (j = 0; j < num_ops; ++j)
4194 : 0 : ops_enq[j]->opaque_data = (void *)(uintptr_t)j;
4195 : :
4196 : 0 : for (i = 0; i < 1; ++i) { /* Could add more iterations */
4197 : : uint32_t time_out = 0;
4198 : 0 : for (j = 0; j < num_ops; ++j) {
4199 : 0 : if (!loopback)
4200 : 0 : mbuf_reset(ops_enq[j]->ldpc_dec.hard_output.data);
4201 : 0 : if (hc_out || loopback)
4202 : 0 : mbuf_reset(ops_enq[j]->ldpc_dec.harq_combined_output.data);
4203 : 0 : if (ops_enq[j]->ldpc_dec.soft_output.data != NULL)
4204 : : mbuf_reset(ops_enq[j]->ldpc_dec.soft_output.data);
4205 : : }
4206 : 0 : if (extDdr)
4207 : 0 : preload_harq_ddr(tp->dev_id, queue_id, ops_enq,
4208 : : num_ops, true);
4209 : : start_time = rte_rdtsc_precise();
4210 : :
4211 : 0 : for (enq = 0, deq = 0; enq < num_ops;) {
4212 : : num_to_enq = burst_sz;
4213 : :
4214 : 0 : if (unlikely(num_ops - enq < num_to_enq))
4215 : 0 : num_to_enq = num_ops - enq;
4216 : :
4217 : 0 : enq += rte_bbdev_enqueue_ldpc_dec_ops(tp->dev_id,
4218 : 0 : queue_id, &ops_enq[enq], num_to_enq);
4219 : :
4220 : 0 : deq += rte_bbdev_dequeue_ldpc_dec_ops(tp->dev_id,
4221 : 0 : queue_id, &ops_deq[deq], enq - deq);
4222 : 0 : time_out++;
4223 : 0 : if (time_out >= TIME_OUT_POLL) {
4224 : 0 : timeout_exit(tp->dev_id);
4225 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Enqueue timeout!");
4226 : : }
4227 : : }
4228 : :
4229 : : /* dequeue the remaining */
4230 : : time_out = 0;
4231 : 0 : while (deq < enq) {
4232 : 0 : deq += rte_bbdev_dequeue_ldpc_dec_ops(tp->dev_id,
4233 : 0 : queue_id, &ops_deq[deq], enq - deq);
4234 : 0 : time_out++;
4235 : 0 : if (time_out >= TIME_OUT_POLL) {
4236 : 0 : timeout_exit(tp->dev_id);
4237 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Dequeue timeout!");
4238 : : }
4239 : : }
4240 : :
4241 : 0 : total_time += rte_rdtsc_precise() - start_time;
4242 : : }
4243 : :
4244 : 0 : tp->iter_count = 0;
4245 : 0 : tp->iter_average = 0;
4246 : : /* get the max of iter_count for all dequeued ops */
4247 : 0 : for (i = 0; i < num_ops; ++i) {
4248 : 0 : tp->iter_count = RTE_MAX(ops_enq[i]->ldpc_dec.iter_count,
4249 : : tp->iter_count);
4250 : 0 : tp->iter_average += (double) ops_enq[i]->ldpc_dec.iter_count;
4251 : 0 : if (ops_enq[i]->status & (1 << RTE_BBDEV_SYNDROME_ERROR))
4252 : 0 : parity_bler += 1.0;
4253 : : }
4254 : :
4255 : 0 : parity_bler /= num_ops; /* This one is based on SYND */
4256 : 0 : tp->iter_average /= num_ops;
4257 : 0 : tp->bler = (double) validate_ldpc_bler(ops_deq, num_ops) / num_ops;
4258 : :
4259 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE
4260 : 0 : && tp->bler == 0
4261 : 0 : && parity_bler == 0
4262 : 0 : && !hc_out) {
4263 : 0 : ret = validate_ldpc_dec_op(ops_deq, num_ops, ref_op,
4264 : 0 : tp->op_params->vector_mask);
4265 : 0 : TEST_ASSERT_SUCCESS(ret, "Validation failed!");
4266 : : }
4267 : :
4268 : 0 : rte_bbdev_dec_op_free_bulk(ops_enq, num_ops);
4269 : :
4270 : 0 : double tb_len_bits = calc_ldpc_dec_TB_size(ref_op);
4271 : 0 : tp->ops_per_sec = ((double)num_ops * 1) /
4272 : 0 : ((double)total_time / (double)rte_get_tsc_hz());
4273 : 0 : tp->mbps = (((double)(num_ops * 1 * tb_len_bits)) /
4274 : 0 : 1000000.0) / ((double)total_time /
4275 : 0 : (double)rte_get_tsc_hz());
4276 : :
4277 : 0 : return TEST_SUCCESS;
4278 : : }
4279 : :
4280 : :
4281 : : static int
4282 : 0 : bler_pmd_lcore_turbo_dec(void *arg)
4283 : : {
4284 : : struct thread_params *tp = arg;
4285 : : uint16_t enq, deq;
4286 : : uint64_t total_time = 0, start_time;
4287 : 0 : const uint16_t queue_id = tp->queue_id;
4288 : 0 : const uint16_t burst_sz = tp->op_params->burst_sz;
4289 : 0 : const uint16_t num_ops = tp->op_params->num_to_process;
4290 : 0 : struct rte_bbdev_dec_op **ops_enq = alloca(sizeof(struct rte_bbdev_dec_op *) * num_ops);
4291 : 0 : struct rte_bbdev_dec_op **ops_deq = alloca(sizeof(struct rte_bbdev_dec_op *) * num_ops);
4292 : 0 : struct rte_bbdev_dec_op *ref_op = tp->op_params->ref_dec_op;
4293 : : struct test_buffers *bufs = NULL;
4294 : : int i, j, ret;
4295 : : struct rte_bbdev_info info;
4296 : : uint16_t num_to_enq;
4297 : :
4298 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
4299 : : "BURST_SIZE should be <= %u", MAX_BURST);
4300 : 0 : TEST_ASSERT_SUCCESS((num_ops == 0), "NUM_OPS must be greater than 0");
4301 : :
4302 : 0 : rte_bbdev_info_get(tp->dev_id, &info);
4303 : :
4304 : 0 : TEST_ASSERT_SUCCESS((num_ops > info.drv.queue_size_lim),
4305 : : "NUM_OPS cannot exceed %u for this device",
4306 : : info.drv.queue_size_lim);
4307 : :
4308 : 0 : bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
4309 : :
4310 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
4311 : : rte_memory_order_relaxed);
4312 : :
4313 : 0 : ret = rte_bbdev_dec_op_alloc_bulk(tp->op_params->mp, ops_enq, num_ops);
4314 : 0 : TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops", num_ops);
4315 : :
4316 : : /* For BLER tests we need to enable early termination */
4317 : 0 : if (!check_bit(ref_op->turbo_dec.op_flags, RTE_BBDEV_TURBO_EARLY_TERMINATION))
4318 : 0 : ref_op->turbo_dec.op_flags += RTE_BBDEV_TURBO_EARLY_TERMINATION;
4319 : :
4320 : 0 : ref_op->turbo_dec.iter_max = get_iter_max();
4321 : :
4322 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
4323 : 0 : copy_reference_dec_op(ops_enq, num_ops, 0, bufs->inputs,
4324 : : bufs->hard_outputs, bufs->soft_outputs,
4325 : : ref_op);
4326 : 0 : generate_turbo_llr_input(num_ops, bufs->inputs, ref_op);
4327 : :
4328 : : /* Set counter to validate the ordering */
4329 : 0 : for (j = 0; j < num_ops; ++j)
4330 : 0 : ops_enq[j]->opaque_data = (void *)(uintptr_t)j;
4331 : :
4332 : 0 : for (i = 0; i < 1; ++i) { /* Could add more iterations */
4333 : : uint32_t time_out = 0;
4334 : 0 : for (j = 0; j < num_ops; ++j) {
4335 : 0 : mbuf_reset(
4336 : 0 : ops_enq[j]->turbo_dec.hard_output.data);
4337 : : }
4338 : :
4339 : : start_time = rte_rdtsc_precise();
4340 : :
4341 : 0 : for (enq = 0, deq = 0; enq < num_ops;) {
4342 : : num_to_enq = burst_sz;
4343 : :
4344 : 0 : if (unlikely(num_ops - enq < num_to_enq))
4345 : 0 : num_to_enq = num_ops - enq;
4346 : :
4347 : 0 : enq += rte_bbdev_enqueue_dec_ops(tp->dev_id,
4348 : 0 : queue_id, &ops_enq[enq], num_to_enq);
4349 : :
4350 : 0 : deq += rte_bbdev_dequeue_dec_ops(tp->dev_id,
4351 : 0 : queue_id, &ops_deq[deq], enq - deq);
4352 : 0 : time_out++;
4353 : 0 : if (time_out >= TIME_OUT_POLL) {
4354 : 0 : timeout_exit(tp->dev_id);
4355 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Enqueue timeout!");
4356 : : }
4357 : : }
4358 : :
4359 : : /* dequeue the remaining */
4360 : : time_out = 0;
4361 : 0 : while (deq < enq) {
4362 : 0 : deq += rte_bbdev_dequeue_dec_ops(tp->dev_id,
4363 : 0 : queue_id, &ops_deq[deq], enq - deq);
4364 : 0 : time_out++;
4365 : 0 : if (time_out >= TIME_OUT_POLL) {
4366 : 0 : timeout_exit(tp->dev_id);
4367 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Dequeue timeout!");
4368 : : }
4369 : : }
4370 : :
4371 : 0 : total_time += rte_rdtsc_precise() - start_time;
4372 : : }
4373 : :
4374 : 0 : tp->iter_count = 0;
4375 : 0 : tp->iter_average = 0;
4376 : : /* get the max of iter_count for all dequeued ops */
4377 : 0 : for (i = 0; i < num_ops; ++i) {
4378 : 0 : tp->iter_count = RTE_MAX(ops_enq[i]->turbo_dec.iter_count,
4379 : : tp->iter_count);
4380 : 0 : tp->iter_average += (double) ops_enq[i]->turbo_dec.iter_count;
4381 : : }
4382 : :
4383 : 0 : tp->iter_average /= num_ops;
4384 : 0 : tp->bler = (double) validate_turbo_bler(ops_deq, num_ops) / num_ops;
4385 : :
4386 : 0 : rte_bbdev_dec_op_free_bulk(ops_enq, num_ops);
4387 : :
4388 : 0 : double tb_len_bits = calc_dec_TB_size(ref_op);
4389 : 0 : tp->ops_per_sec = ((double)num_ops * 1) /
4390 : 0 : ((double)total_time / (double)rte_get_tsc_hz());
4391 : 0 : tp->mbps = (((double)(num_ops * 1 * tb_len_bits)) /
4392 : 0 : 1000000.0) / ((double)total_time /
4393 : 0 : (double)rte_get_tsc_hz());
4394 : 0 : printf("TBS %.0f Time %.0f\n", tb_len_bits, 1000000.0 *
4395 : 0 : ((double)total_time / (double)rte_get_tsc_hz()));
4396 : :
4397 : 0 : return TEST_SUCCESS;
4398 : : }
4399 : :
4400 : : static int
4401 : 0 : throughput_pmd_lcore_ldpc_dec(void *arg)
4402 : : {
4403 : : struct thread_params *tp = arg;
4404 : : uint16_t enq, deq;
4405 : : uint64_t total_time = 0, start_time;
4406 : 0 : const uint16_t queue_id = tp->queue_id;
4407 : 0 : const uint16_t burst_sz = tp->op_params->burst_sz;
4408 : 0 : const uint16_t num_ops = tp->op_params->num_to_process;
4409 : 0 : struct rte_bbdev_dec_op **ops_enq = alloca(sizeof(struct rte_bbdev_dec_op *) * num_ops);
4410 : 0 : struct rte_bbdev_dec_op **ops_deq = alloca(sizeof(struct rte_bbdev_dec_op *) * num_ops);
4411 : 0 : struct rte_bbdev_dec_op *ref_op = tp->op_params->ref_dec_op;
4412 : : struct test_buffers *bufs = NULL;
4413 : : int i, j, ret;
4414 : : struct rte_bbdev_info info;
4415 : : uint16_t num_to_enq;
4416 : 0 : bool extDdr = check_bit(ldpc_cap_flags,
4417 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE);
4418 : 0 : bool loopback = check_bit(ref_op->ldpc_dec.op_flags,
4419 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK);
4420 : : bool hc_out = check_bit(ref_op->ldpc_dec.op_flags,
4421 : : RTE_BBDEV_LDPC_HQ_COMBINE_OUT_ENABLE);
4422 : :
4423 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
4424 : : "BURST_SIZE should be <= %u", MAX_BURST);
4425 : :
4426 : 0 : rte_bbdev_info_get(tp->dev_id, &info);
4427 : :
4428 : 0 : TEST_ASSERT_SUCCESS((num_ops > info.drv.queue_size_lim),
4429 : : "NUM_OPS cannot exceed %u for this device",
4430 : : info.drv.queue_size_lim);
4431 : :
4432 : 0 : bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
4433 : :
4434 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
4435 : : rte_memory_order_relaxed);
4436 : :
4437 : 0 : ret = rte_bbdev_dec_op_alloc_bulk(tp->op_params->mp, ops_enq, num_ops);
4438 : 0 : TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops", num_ops);
4439 : :
4440 : : /* For throughput tests we need to disable early termination */
4441 : 0 : if (check_bit(ref_op->ldpc_dec.op_flags, RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE))
4442 : 0 : ref_op->ldpc_dec.op_flags -= RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE;
4443 : :
4444 : 0 : ref_op->ldpc_dec.iter_max = get_iter_max();
4445 : : /* Since ET is disabled, the expected iter_count is iter_max */
4446 : 0 : ref_op->ldpc_dec.iter_count = ref_op->ldpc_dec.iter_max;
4447 : :
4448 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
4449 : 0 : copy_reference_ldpc_dec_op(ops_enq, num_ops, 0, bufs->inputs,
4450 : : bufs->hard_outputs, bufs->soft_outputs,
4451 : : bufs->harq_inputs, bufs->harq_outputs, ref_op);
4452 : :
4453 : : /* Set counter to validate the ordering */
4454 : 0 : for (j = 0; j < num_ops; ++j)
4455 : 0 : ops_enq[j]->opaque_data = (void *)(uintptr_t)j;
4456 : :
4457 : 0 : for (i = 0; i < TEST_REPETITIONS; ++i) {
4458 : : uint32_t time_out = 0;
4459 : 0 : for (j = 0; j < num_ops; ++j) {
4460 : 0 : if (!loopback)
4461 : 0 : mbuf_reset(ops_enq[j]->ldpc_dec.hard_output.data);
4462 : 0 : if (hc_out || loopback)
4463 : 0 : mbuf_reset(ops_enq[j]->ldpc_dec.harq_combined_output.data);
4464 : 0 : if (ops_enq[j]->ldpc_dec.soft_output.data != NULL)
4465 : : mbuf_reset(ops_enq[j]->ldpc_dec.soft_output.data);
4466 : : }
4467 : 0 : if (extDdr)
4468 : 0 : preload_harq_ddr(tp->dev_id, queue_id, ops_enq,
4469 : : num_ops, true);
4470 : : start_time = rte_rdtsc_precise();
4471 : :
4472 : 0 : for (enq = 0, deq = 0; enq < num_ops;) {
4473 : : num_to_enq = burst_sz;
4474 : :
4475 : 0 : if (unlikely(num_ops - enq < num_to_enq))
4476 : 0 : num_to_enq = num_ops - enq;
4477 : :
4478 : 0 : enq += rte_bbdev_enqueue_ldpc_dec_ops(tp->dev_id,
4479 : 0 : queue_id, &ops_enq[enq], num_to_enq);
4480 : :
4481 : 0 : deq += rte_bbdev_dequeue_ldpc_dec_ops(tp->dev_id,
4482 : 0 : queue_id, &ops_deq[deq], enq - deq);
4483 : 0 : time_out++;
4484 : 0 : if (time_out >= TIME_OUT_POLL) {
4485 : 0 : timeout_exit(tp->dev_id);
4486 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Enqueue timeout!");
4487 : : }
4488 : : }
4489 : :
4490 : : /* dequeue the remaining */
4491 : : time_out = 0;
4492 : 0 : while (deq < enq) {
4493 : 0 : deq += rte_bbdev_dequeue_ldpc_dec_ops(tp->dev_id,
4494 : 0 : queue_id, &ops_deq[deq], enq - deq);
4495 : 0 : time_out++;
4496 : 0 : if (time_out >= TIME_OUT_POLL) {
4497 : 0 : timeout_exit(tp->dev_id);
4498 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Dequeue timeout!");
4499 : : }
4500 : : }
4501 : :
4502 : 0 : total_time += rte_rdtsc_precise() - start_time;
4503 : : }
4504 : :
4505 : 0 : tp->iter_count = 0;
4506 : : /* get the max of iter_count for all dequeued ops */
4507 : 0 : for (i = 0; i < num_ops; ++i) {
4508 : 0 : tp->iter_count = RTE_MAX(ops_enq[i]->ldpc_dec.iter_count,
4509 : : tp->iter_count);
4510 : : }
4511 : 0 : if (extDdr) {
4512 : : /* Read loopback is not thread safe */
4513 : 0 : retrieve_harq_ddr(tp->dev_id, queue_id, ops_enq, num_ops);
4514 : : }
4515 : :
4516 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE) {
4517 : 0 : ret = validate_ldpc_dec_op(ops_deq, num_ops, ref_op,
4518 : 0 : tp->op_params->vector_mask);
4519 : 0 : TEST_ASSERT_SUCCESS(ret, "Validation failed!");
4520 : : }
4521 : :
4522 : 0 : ret = rte_bbdev_queue_stop(tp->dev_id, queue_id);
4523 : 0 : if (ret != 0)
4524 : 0 : printf("Failed to stop queue on dev %u q_id: %u\n", tp->dev_id, queue_id);
4525 : 0 : rte_bbdev_dec_op_free_bulk(ops_enq, num_ops);
4526 : :
4527 : 0 : double tb_len_bits = calc_ldpc_dec_TB_size(ref_op);
4528 : :
4529 : 0 : tp->ops_per_sec = ((double)num_ops * TEST_REPETITIONS) /
4530 : 0 : ((double)total_time / (double)rte_get_tsc_hz());
4531 : 0 : tp->mbps = (((double)(num_ops * TEST_REPETITIONS * tb_len_bits)) /
4532 : 0 : 1000000.0) / ((double)total_time /
4533 : 0 : (double)rte_get_tsc_hz());
4534 : :
4535 : 0 : return TEST_SUCCESS;
4536 : : }
4537 : :
4538 : : static int
4539 : 0 : throughput_pmd_lcore_enc(void *arg)
4540 : : {
4541 : : struct thread_params *tp = arg;
4542 : : uint16_t enq, deq;
4543 : : uint64_t total_time = 0, start_time;
4544 : 0 : const uint16_t queue_id = tp->queue_id;
4545 : 0 : const uint16_t burst_sz = tp->op_params->burst_sz;
4546 : 0 : const uint16_t num_ops = tp->op_params->num_to_process;
4547 : 0 : struct rte_bbdev_enc_op **ops_enq = alloca(sizeof(struct rte_bbdev_enc_op *) * num_ops);
4548 : 0 : struct rte_bbdev_enc_op **ops_deq = alloca(sizeof(struct rte_bbdev_enc_op *) * num_ops);
4549 : 0 : struct rte_bbdev_enc_op *ref_op = tp->op_params->ref_enc_op;
4550 : : struct test_buffers *bufs = NULL;
4551 : : int i, j, ret;
4552 : : struct rte_bbdev_info info;
4553 : : uint16_t num_to_enq;
4554 : :
4555 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
4556 : : "BURST_SIZE should be <= %u", MAX_BURST);
4557 : :
4558 : 0 : rte_bbdev_info_get(tp->dev_id, &info);
4559 : :
4560 : 0 : TEST_ASSERT_SUCCESS((num_ops > info.drv.queue_size_lim),
4561 : : "NUM_OPS cannot exceed %u for this device",
4562 : : info.drv.queue_size_lim);
4563 : :
4564 : 0 : bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
4565 : :
4566 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
4567 : : rte_memory_order_relaxed);
4568 : :
4569 : 0 : ret = rte_bbdev_enc_op_alloc_bulk(tp->op_params->mp, ops_enq,
4570 : : num_ops);
4571 : 0 : TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops",
4572 : : num_ops);
4573 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
4574 : 0 : copy_reference_enc_op(ops_enq, num_ops, 0, bufs->inputs,
4575 : : bufs->hard_outputs, ref_op);
4576 : :
4577 : : /* Set counter to validate the ordering */
4578 : 0 : for (j = 0; j < num_ops; ++j)
4579 : 0 : ops_enq[j]->opaque_data = (void *)(uintptr_t)j;
4580 : :
4581 : 0 : for (i = 0; i < TEST_REPETITIONS; ++i) {
4582 : : uint32_t time_out = 0;
4583 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
4584 : 0 : for (j = 0; j < num_ops; ++j)
4585 : 0 : mbuf_reset(ops_enq[j]->turbo_enc.output.data);
4586 : :
4587 : : start_time = rte_rdtsc_precise();
4588 : :
4589 : 0 : for (enq = 0, deq = 0; enq < num_ops;) {
4590 : : num_to_enq = burst_sz;
4591 : :
4592 : 0 : if (unlikely(num_ops - enq < num_to_enq))
4593 : 0 : num_to_enq = num_ops - enq;
4594 : :
4595 : 0 : enq += rte_bbdev_enqueue_enc_ops(tp->dev_id,
4596 : 0 : queue_id, &ops_enq[enq], num_to_enq);
4597 : :
4598 : 0 : deq += rte_bbdev_dequeue_enc_ops(tp->dev_id,
4599 : 0 : queue_id, &ops_deq[deq], enq - deq);
4600 : 0 : time_out++;
4601 : 0 : if (time_out >= TIME_OUT_POLL) {
4602 : 0 : timeout_exit(tp->dev_id);
4603 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Enqueue timeout!");
4604 : : }
4605 : : }
4606 : :
4607 : : /* dequeue the remaining */
4608 : : time_out = 0;
4609 : 0 : while (deq < enq) {
4610 : 0 : deq += rte_bbdev_dequeue_enc_ops(tp->dev_id,
4611 : 0 : queue_id, &ops_deq[deq], enq - deq);
4612 : 0 : time_out++;
4613 : 0 : if (time_out >= TIME_OUT_POLL) {
4614 : 0 : timeout_exit(tp->dev_id);
4615 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Dequeue timeout!");
4616 : : }
4617 : : }
4618 : :
4619 : 0 : total_time += rte_rdtsc_precise() - start_time;
4620 : : }
4621 : :
4622 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE) {
4623 : 0 : ret = validate_enc_op(ops_deq, num_ops, ref_op);
4624 : 0 : TEST_ASSERT_SUCCESS(ret, "Validation failed!");
4625 : : }
4626 : :
4627 : 0 : rte_bbdev_enc_op_free_bulk(ops_enq, num_ops);
4628 : :
4629 : 0 : double tb_len_bits = calc_enc_TB_size(ref_op);
4630 : :
4631 : 0 : tp->ops_per_sec = ((double)num_ops * TEST_REPETITIONS) /
4632 : 0 : ((double)total_time / (double)rte_get_tsc_hz());
4633 : 0 : tp->mbps = (((double)(num_ops * TEST_REPETITIONS * tb_len_bits))
4634 : 0 : / 1000000.0) / ((double)total_time /
4635 : 0 : (double)rte_get_tsc_hz());
4636 : :
4637 : 0 : return TEST_SUCCESS;
4638 : : }
4639 : :
4640 : : static int
4641 : 0 : throughput_pmd_lcore_ldpc_enc(void *arg)
4642 : : {
4643 : : struct thread_params *tp = arg;
4644 : : uint16_t enq, deq;
4645 : : uint64_t total_time = 0, start_time;
4646 : 0 : const uint16_t queue_id = tp->queue_id;
4647 : 0 : const uint16_t burst_sz = tp->op_params->burst_sz;
4648 : 0 : const uint16_t num_ops = tp->op_params->num_to_process;
4649 : 0 : struct rte_bbdev_enc_op **ops_enq = alloca(sizeof(struct rte_bbdev_enc_op *) * num_ops);
4650 : 0 : struct rte_bbdev_enc_op **ops_deq = alloca(sizeof(struct rte_bbdev_enc_op *) * num_ops);
4651 : 0 : struct rte_bbdev_enc_op *ref_op = tp->op_params->ref_enc_op;
4652 : : struct test_buffers *bufs = NULL;
4653 : : int i, j, ret;
4654 : : struct rte_bbdev_info info;
4655 : : uint16_t num_to_enq;
4656 : :
4657 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
4658 : : "BURST_SIZE should be <= %u", MAX_BURST);
4659 : :
4660 : 0 : rte_bbdev_info_get(tp->dev_id, &info);
4661 : :
4662 : 0 : TEST_ASSERT_SUCCESS((num_ops > info.drv.queue_size_lim),
4663 : : "NUM_OPS cannot exceed %u for this device",
4664 : : info.drv.queue_size_lim);
4665 : :
4666 : 0 : bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
4667 : :
4668 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
4669 : : rte_memory_order_relaxed);
4670 : :
4671 : 0 : ret = rte_bbdev_enc_op_alloc_bulk(tp->op_params->mp, ops_enq,
4672 : : num_ops);
4673 : 0 : TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops",
4674 : : num_ops);
4675 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
4676 : 0 : copy_reference_ldpc_enc_op(ops_enq, num_ops, 0, bufs->inputs,
4677 : : bufs->hard_outputs, ref_op);
4678 : :
4679 : : /* Set counter to validate the ordering */
4680 : 0 : for (j = 0; j < num_ops; ++j)
4681 : 0 : ops_enq[j]->opaque_data = (void *)(uintptr_t)j;
4682 : :
4683 : 0 : for (i = 0; i < TEST_REPETITIONS; ++i) {
4684 : : uint32_t time_out = 0;
4685 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
4686 : 0 : for (j = 0; j < num_ops; ++j)
4687 : 0 : mbuf_reset(ops_enq[j]->turbo_enc.output.data);
4688 : :
4689 : : start_time = rte_rdtsc_precise();
4690 : :
4691 : 0 : for (enq = 0, deq = 0; enq < num_ops;) {
4692 : : num_to_enq = burst_sz;
4693 : :
4694 : 0 : if (unlikely(num_ops - enq < num_to_enq))
4695 : 0 : num_to_enq = num_ops - enq;
4696 : :
4697 : 0 : enq += rte_bbdev_enqueue_ldpc_enc_ops(tp->dev_id,
4698 : 0 : queue_id, &ops_enq[enq], num_to_enq);
4699 : :
4700 : 0 : deq += rte_bbdev_dequeue_ldpc_enc_ops(tp->dev_id,
4701 : 0 : queue_id, &ops_deq[deq], enq - deq);
4702 : 0 : time_out++;
4703 : 0 : if (time_out >= TIME_OUT_POLL) {
4704 : 0 : timeout_exit(tp->dev_id);
4705 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Enqueue timeout!");
4706 : : }
4707 : : }
4708 : :
4709 : : /* dequeue the remaining */
4710 : : time_out = 0;
4711 : 0 : while (deq < enq) {
4712 : 0 : deq += rte_bbdev_dequeue_ldpc_enc_ops(tp->dev_id,
4713 : 0 : queue_id, &ops_deq[deq], enq - deq);
4714 : 0 : time_out++;
4715 : 0 : if (time_out >= TIME_OUT_POLL) {
4716 : 0 : timeout_exit(tp->dev_id);
4717 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Dequeue timeout!");
4718 : : }
4719 : : }
4720 : :
4721 : 0 : total_time += rte_rdtsc_precise() - start_time;
4722 : : }
4723 : :
4724 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE) {
4725 : 0 : ret = validate_ldpc_enc_op(ops_deq, num_ops, ref_op);
4726 : 0 : TEST_ASSERT_SUCCESS(ret, "Validation failed!");
4727 : : }
4728 : :
4729 : 0 : rte_bbdev_enc_op_free_bulk(ops_enq, num_ops);
4730 : :
4731 : 0 : double tb_len_bits = calc_ldpc_enc_TB_size(ref_op);
4732 : :
4733 : 0 : tp->ops_per_sec = ((double)num_ops * TEST_REPETITIONS) /
4734 : 0 : ((double)total_time / (double)rte_get_tsc_hz());
4735 : 0 : tp->mbps = (((double)(num_ops * TEST_REPETITIONS * tb_len_bits))
4736 : 0 : / 1000000.0) / ((double)total_time /
4737 : 0 : (double)rte_get_tsc_hz());
4738 : :
4739 : 0 : return TEST_SUCCESS;
4740 : : }
4741 : :
4742 : : static int
4743 : 0 : throughput_pmd_lcore_fft(void *arg)
4744 : : {
4745 : : struct thread_params *tp = arg;
4746 : : uint16_t enq, deq;
4747 : : uint64_t total_time = 0, start_time;
4748 : 0 : const uint16_t queue_id = tp->queue_id;
4749 : 0 : const uint16_t burst_sz = tp->op_params->burst_sz;
4750 : 0 : const uint16_t num_ops = tp->op_params->num_to_process;
4751 : 0 : struct rte_bbdev_fft_op **ops_enq = alloca(sizeof(struct rte_bbdev_fft_op *) * num_ops);
4752 : 0 : struct rte_bbdev_fft_op **ops_deq = alloca(sizeof(struct rte_bbdev_fft_op *) * num_ops);
4753 : 0 : struct rte_bbdev_fft_op *ref_op = tp->op_params->ref_fft_op;
4754 : : struct test_buffers *bufs = NULL;
4755 : : int i, j, ret;
4756 : : struct rte_bbdev_info info;
4757 : : uint16_t num_to_enq;
4758 : :
4759 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
4760 : : "BURST_SIZE should be <= %u", MAX_BURST);
4761 : :
4762 : 0 : rte_bbdev_info_get(tp->dev_id, &info);
4763 : :
4764 : 0 : TEST_ASSERT_SUCCESS((num_ops > info.drv.queue_size_lim),
4765 : : "NUM_OPS cannot exceed %u for this device",
4766 : : info.drv.queue_size_lim);
4767 : :
4768 : 0 : bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
4769 : :
4770 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
4771 : : rte_memory_order_relaxed);
4772 : :
4773 : 0 : ret = rte_bbdev_fft_op_alloc_bulk(tp->op_params->mp, ops_enq, num_ops);
4774 : 0 : TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops", num_ops);
4775 : :
4776 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
4777 : 0 : copy_reference_fft_op(ops_enq, num_ops, 0, bufs->inputs,
4778 : : bufs->hard_outputs, bufs->soft_outputs, bufs->harq_inputs, ref_op);
4779 : :
4780 : : /* Set counter to validate the ordering */
4781 : 0 : for (j = 0; j < num_ops; ++j)
4782 : 0 : ops_enq[j]->opaque_data = (void *)(uintptr_t)j;
4783 : :
4784 : 0 : for (i = 0; i < TEST_REPETITIONS; ++i) {
4785 : : uint32_t time_out = 0;
4786 : 0 : for (j = 0; j < num_ops; ++j)
4787 : 0 : mbuf_reset(ops_enq[j]->fft.base_output.data);
4788 : :
4789 : : start_time = rte_rdtsc_precise();
4790 : :
4791 : 0 : for (enq = 0, deq = 0; enq < num_ops;) {
4792 : : num_to_enq = burst_sz;
4793 : :
4794 : 0 : if (unlikely(num_ops - enq < num_to_enq))
4795 : 0 : num_to_enq = num_ops - enq;
4796 : :
4797 : 0 : enq += rte_bbdev_enqueue_fft_ops(tp->dev_id,
4798 : 0 : queue_id, &ops_enq[enq], num_to_enq);
4799 : :
4800 : 0 : deq += rte_bbdev_dequeue_fft_ops(tp->dev_id,
4801 : 0 : queue_id, &ops_deq[deq], enq - deq);
4802 : 0 : time_out++;
4803 : 0 : if (time_out >= TIME_OUT_POLL) {
4804 : 0 : timeout_exit(tp->dev_id);
4805 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Enqueue timeout!");
4806 : : }
4807 : : }
4808 : :
4809 : : /* dequeue the remaining */
4810 : : time_out = 0;
4811 : 0 : while (deq < enq) {
4812 : 0 : deq += rte_bbdev_dequeue_fft_ops(tp->dev_id,
4813 : 0 : queue_id, &ops_deq[deq], enq - deq);
4814 : 0 : time_out++;
4815 : 0 : if (time_out >= TIME_OUT_POLL) {
4816 : 0 : timeout_exit(tp->dev_id);
4817 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Dequeue timeout!");
4818 : : }
4819 : : }
4820 : :
4821 : 0 : total_time += rte_rdtsc_precise() - start_time;
4822 : : }
4823 : :
4824 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE) {
4825 : 0 : ret = validate_fft_op(ops_deq, num_ops, ref_op);
4826 : 0 : TEST_ASSERT_SUCCESS(ret, "Validation failed!");
4827 : : }
4828 : :
4829 : 0 : rte_bbdev_fft_op_free_bulk(ops_enq, num_ops);
4830 : :
4831 : 0 : double tb_len_bits = calc_fft_size(ref_op);
4832 : :
4833 : 0 : tp->ops_per_sec = ((double)num_ops * TEST_REPETITIONS) /
4834 : 0 : ((double)total_time / (double)rte_get_tsc_hz());
4835 : 0 : tp->mbps = (((double)(num_ops * TEST_REPETITIONS * tb_len_bits)) /
4836 : 0 : 1000000.0) / ((double)total_time /
4837 : 0 : (double)rte_get_tsc_hz());
4838 : :
4839 : 0 : return TEST_SUCCESS;
4840 : : }
4841 : :
4842 : : static int
4843 : 0 : throughput_pmd_lcore_mldts(void *arg)
4844 : : {
4845 : : struct thread_params *tp = arg;
4846 : : uint16_t enq, deq;
4847 : : uint64_t total_time = 0, start_time;
4848 : 0 : const uint16_t queue_id = tp->queue_id;
4849 : 0 : const uint16_t burst_sz = tp->op_params->burst_sz;
4850 : 0 : const uint16_t num_ops = tp->op_params->num_to_process;
4851 : 0 : struct rte_bbdev_mldts_op **ops_enq = alloca(sizeof(struct rte_bbdev_mldts_op *) * num_ops);
4852 : 0 : struct rte_bbdev_mldts_op **ops_deq = alloca(sizeof(struct rte_bbdev_mldts_op *) * num_ops);
4853 : 0 : struct rte_bbdev_mldts_op *ref_op = tp->op_params->ref_mldts_op;
4854 : : struct test_buffers *bufs = NULL;
4855 : : int i, j, ret;
4856 : : struct rte_bbdev_info info;
4857 : : uint16_t num_to_enq;
4858 : :
4859 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST), "BURST_SIZE should be <= %u", MAX_BURST);
4860 : :
4861 : 0 : rte_bbdev_info_get(tp->dev_id, &info);
4862 : :
4863 : 0 : TEST_ASSERT_SUCCESS((num_ops > info.drv.queue_size_lim),
4864 : : "NUM_OPS cannot exceed %u for this device",
4865 : : info.drv.queue_size_lim);
4866 : :
4867 : 0 : bufs = &tp->op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
4868 : :
4869 : 0 : rte_wait_until_equal_16((uint16_t *)(uintptr_t)&tp->op_params->sync, SYNC_START,
4870 : : rte_memory_order_relaxed);
4871 : :
4872 : 0 : ret = rte_bbdev_mldts_op_alloc_bulk(tp->op_params->mp, ops_enq, num_ops);
4873 : 0 : TEST_ASSERT_SUCCESS(ret, "Allocation failed for %d ops", num_ops);
4874 : :
4875 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
4876 : 0 : copy_reference_mldts_op(ops_enq, num_ops, 0, bufs->inputs, bufs->harq_inputs,
4877 : : bufs->hard_outputs, ref_op);
4878 : :
4879 : : /* Set counter to validate the ordering */
4880 : 0 : for (j = 0; j < num_ops; ++j)
4881 : 0 : ops_enq[j]->opaque_data = (void *)(uintptr_t)j;
4882 : :
4883 : 0 : for (i = 0; i < TEST_REPETITIONS; ++i) {
4884 : : uint32_t time_out = 0;
4885 : 0 : for (j = 0; j < num_ops; ++j)
4886 : 0 : mbuf_reset(ops_enq[j]->mldts.output.data);
4887 : :
4888 : : start_time = rte_rdtsc_precise();
4889 : :
4890 : 0 : for (enq = 0, deq = 0; enq < num_ops;) {
4891 : : num_to_enq = burst_sz;
4892 : :
4893 : 0 : if (unlikely(num_ops - enq < num_to_enq))
4894 : 0 : num_to_enq = num_ops - enq;
4895 : :
4896 : 0 : enq += rte_bbdev_enqueue_mldts_ops(tp->dev_id,
4897 : 0 : queue_id, &ops_enq[enq], num_to_enq);
4898 : :
4899 : 0 : deq += rte_bbdev_dequeue_mldts_ops(tp->dev_id,
4900 : 0 : queue_id, &ops_deq[deq], enq - deq);
4901 : 0 : time_out++;
4902 : 0 : if (time_out >= TIME_OUT_POLL) {
4903 : 0 : timeout_exit(tp->dev_id);
4904 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Enqueue timeout!");
4905 : : }
4906 : : }
4907 : :
4908 : : /* dequeue the remaining */
4909 : : time_out = 0;
4910 : 0 : while (deq < enq) {
4911 : 0 : deq += rte_bbdev_dequeue_mldts_ops(tp->dev_id,
4912 : 0 : queue_id, &ops_deq[deq], enq - deq);
4913 : 0 : time_out++;
4914 : 0 : if (time_out >= TIME_OUT_POLL) {
4915 : 0 : timeout_exit(tp->dev_id);
4916 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Dequeue timeout!");
4917 : : }
4918 : : }
4919 : :
4920 : 0 : total_time += rte_rdtsc_precise() - start_time;
4921 : : }
4922 : :
4923 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE) {
4924 : 0 : ret = validate_mldts_op(ops_deq, num_ops, ref_op);
4925 : 0 : TEST_ASSERT_SUCCESS(ret, "Validation failed!");
4926 : : }
4927 : :
4928 : 0 : rte_bbdev_mldts_op_free_bulk(ops_enq, num_ops);
4929 : :
4930 : 0 : double tb_len_bits = calc_mldts_size(ref_op);
4931 : :
4932 : 0 : tp->ops_per_sec = ((double)num_ops * TEST_REPETITIONS) /
4933 : 0 : ((double)total_time / (double)rte_get_tsc_hz());
4934 : 0 : tp->mbps = (((double)(num_ops * TEST_REPETITIONS * tb_len_bits)) /
4935 : 0 : 1000000.0) / ((double)total_time /
4936 : 0 : (double)rte_get_tsc_hz());
4937 : :
4938 : 0 : return TEST_SUCCESS;
4939 : : }
4940 : :
4941 : : static void
4942 : 0 : print_enc_throughput(struct thread_params *t_params, unsigned int used_cores)
4943 : : {
4944 : : unsigned int iter = 0;
4945 : : double total_mops = 0, total_mbps = 0;
4946 : :
4947 : 0 : for (iter = 0; iter < used_cores; iter++) {
4948 : 0 : printf(
4949 : : "Throughput for core (%u): %.8lg Ops/s, %.8lg Mbps\n",
4950 : : t_params[iter].lcore_id, t_params[iter].ops_per_sec,
4951 : 0 : t_params[iter].mbps);
4952 : 0 : total_mops += t_params[iter].ops_per_sec;
4953 : 0 : total_mbps += t_params[iter].mbps;
4954 : : }
4955 : : printf(
4956 : : "\nTotal throughput for %u cores: %.8lg MOPS, %.8lg Mbps\n",
4957 : : used_cores, total_mops, total_mbps);
4958 : 0 : }
4959 : :
4960 : : /* Aggregate the performance results over the number of cores used */
4961 : : static void
4962 : 0 : print_dec_throughput(struct thread_params *t_params, unsigned int used_cores)
4963 : : {
4964 : : unsigned int core_idx = 0;
4965 : : double total_mops = 0, total_mbps = 0;
4966 : : uint8_t iter_count = 0;
4967 : :
4968 : 0 : for (core_idx = 0; core_idx < used_cores; core_idx++) {
4969 : 0 : printf(
4970 : : "Throughput for core (%u): %.8lg Ops/s, %.8lg Mbps @ max %u iterations\n",
4971 : : t_params[core_idx].lcore_id,
4972 : : t_params[core_idx].ops_per_sec,
4973 : : t_params[core_idx].mbps,
4974 : 0 : t_params[core_idx].iter_count);
4975 : 0 : total_mops += t_params[core_idx].ops_per_sec;
4976 : 0 : total_mbps += t_params[core_idx].mbps;
4977 : 0 : iter_count = RTE_MAX(iter_count,
4978 : : t_params[core_idx].iter_count);
4979 : : }
4980 : 0 : printf(
4981 : : "\nTotal throughput for %u cores: %.8lg MOPS, %.8lg Mbps @ max %u iterations\n",
4982 : : used_cores, total_mops, total_mbps, iter_count);
4983 : 0 : }
4984 : :
4985 : : /* Aggregate the performance results over the number of cores used */
4986 : : static void
4987 : 0 : print_dec_bler(struct thread_params *t_params, unsigned int used_cores)
4988 : : {
4989 : : unsigned int core_idx = 0;
4990 : : double total_mbps = 0, total_bler = 0, total_iter = 0;
4991 : 0 : double snr = get_snr();
4992 : :
4993 : 0 : for (core_idx = 0; core_idx < used_cores; core_idx++) {
4994 : 0 : printf("Core%u BLER %.1f %% - Iters %.1f - Tp %.1f Mbps %s\n",
4995 : : t_params[core_idx].lcore_id,
4996 : 0 : t_params[core_idx].bler * 100,
4997 : : t_params[core_idx].iter_average,
4998 : 0 : t_params[core_idx].mbps,
4999 : : get_vector_filename());
5000 : 0 : total_mbps += t_params[core_idx].mbps;
5001 : 0 : total_bler += t_params[core_idx].bler;
5002 : 0 : total_iter += t_params[core_idx].iter_average;
5003 : : }
5004 : 0 : total_bler /= used_cores;
5005 : 0 : total_iter /= used_cores;
5006 : :
5007 : 0 : printf("SNR %.2f BLER %.1f %% - Iterations %.1f %d - Tp %.3f Mbps %s\n",
5008 : : snr, total_bler * 100, total_iter, get_iter_max(),
5009 : : total_mbps, get_vector_filename());
5010 : 0 : }
5011 : :
5012 : : /*
5013 : : * Test function that determines BLER wireless performance
5014 : : */
5015 : : static int
5016 : 0 : bler_test(struct active_device *ad,
5017 : : struct test_op_params *op_params)
5018 : : {
5019 : : int ret;
5020 : : unsigned int lcore_id, used_cores = 0;
5021 : : struct thread_params *t_params;
5022 : : struct rte_bbdev_info info;
5023 : : lcore_function_t *bler_function;
5024 : : uint16_t num_lcores;
5025 : : const char *op_type_str;
5026 : :
5027 : 0 : rte_bbdev_info_get(ad->dev_id, &info);
5028 : :
5029 : 0 : op_type_str = rte_bbdev_op_type_str(test_vector.op_type);
5030 : 0 : TEST_ASSERT_NOT_NULL(op_type_str, "Invalid op type: %u",
5031 : : test_vector.op_type);
5032 : :
5033 : : printf("+ ------------------------------------------------------- +\n");
5034 : 0 : printf("== test: bler\ndev: %s, nb_queues: %u, burst size: %u, num ops: %u, num_lcores: %u, op type: %s, itr mode: %s, GHz: %lg\n",
5035 : 0 : info.dev_name, ad->nb_queues, op_params->burst_sz,
5036 : 0 : op_params->num_to_process, op_params->num_lcores,
5037 : : op_type_str,
5038 : 0 : intr_enabled ? "Interrupt mode" : "PMD mode",
5039 : 0 : (double)rte_get_tsc_hz() / 1000000000.0);
5040 : :
5041 : : /* Set number of lcores */
5042 : 0 : num_lcores = (ad->nb_queues < (op_params->num_lcores))
5043 : : ? ad->nb_queues
5044 : : : op_params->num_lcores;
5045 : :
5046 : : /* Allocate memory for thread parameters structure */
5047 : 0 : t_params = rte_zmalloc(NULL, num_lcores * sizeof(struct thread_params),
5048 : : RTE_CACHE_LINE_SIZE);
5049 : 0 : TEST_ASSERT_NOT_NULL(t_params, "Failed to alloc %zuB for t_params",
5050 : : RTE_ALIGN(sizeof(struct thread_params) * num_lcores,
5051 : : RTE_CACHE_LINE_SIZE));
5052 : :
5053 : 0 : if ((test_vector.op_type == RTE_BBDEV_OP_LDPC_DEC) &&
5054 : 0 : !check_bit(test_vector.ldpc_dec.op_flags,
5055 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_LOOPBACK)
5056 : 0 : && !check_bit(test_vector.ldpc_dec.op_flags,
5057 : : RTE_BBDEV_LDPC_LLR_COMPRESSION))
5058 : : bler_function = bler_pmd_lcore_ldpc_dec;
5059 : 0 : else if ((test_vector.op_type == RTE_BBDEV_OP_TURBO_DEC) &&
5060 : 0 : !check_bit(test_vector.turbo_dec.op_flags,
5061 : : RTE_BBDEV_TURBO_SOFT_OUTPUT))
5062 : : bler_function = bler_pmd_lcore_turbo_dec;
5063 : : else
5064 : : return TEST_SKIPPED;
5065 : :
5066 : 0 : rte_atomic_store_explicit(&op_params->sync, SYNC_WAIT, rte_memory_order_relaxed);
5067 : :
5068 : : /* Main core is set at first entry */
5069 : 0 : t_params[0].dev_id = ad->dev_id;
5070 : 0 : t_params[0].lcore_id = rte_lcore_id();
5071 : 0 : t_params[0].op_params = op_params;
5072 : 0 : t_params[0].queue_id = ad->queue_ids[used_cores++];
5073 : 0 : t_params[0].iter_count = 0;
5074 : :
5075 : 0 : RTE_LCORE_FOREACH_WORKER(lcore_id) {
5076 : 0 : if (used_cores >= num_lcores)
5077 : : break;
5078 : :
5079 : 0 : t_params[used_cores].dev_id = ad->dev_id;
5080 : 0 : t_params[used_cores].lcore_id = lcore_id;
5081 : 0 : t_params[used_cores].op_params = op_params;
5082 : 0 : t_params[used_cores].queue_id = ad->queue_ids[used_cores];
5083 : 0 : t_params[used_cores].iter_count = 0;
5084 : :
5085 : 0 : rte_eal_remote_launch(bler_function,
5086 : 0 : &t_params[used_cores++], lcore_id);
5087 : : }
5088 : :
5089 : 0 : rte_atomic_store_explicit(&op_params->sync, SYNC_START, rte_memory_order_relaxed);
5090 : 0 : ret = bler_function(&t_params[0]);
5091 : :
5092 : : /* Main core is always used */
5093 : 0 : for (used_cores = 1; used_cores < num_lcores; used_cores++)
5094 : 0 : ret |= rte_eal_wait_lcore(t_params[used_cores].lcore_id);
5095 : :
5096 : 0 : print_dec_bler(t_params, num_lcores);
5097 : :
5098 : : /* Return if test failed */
5099 : 0 : if (ret) {
5100 : 0 : rte_free(t_params);
5101 : 0 : return ret;
5102 : : }
5103 : :
5104 : : /* Function to print something here*/
5105 : 0 : rte_free(t_params);
5106 : 0 : return ret;
5107 : : }
5108 : :
5109 : : /*
5110 : : * Test function that determines how long an enqueue + dequeue of a burst
5111 : : * takes on available lcores.
5112 : : */
5113 : : static int
5114 : 0 : throughput_test(struct active_device *ad,
5115 : : struct test_op_params *op_params)
5116 : : {
5117 : : int ret;
5118 : : unsigned int lcore_id, used_cores = 0;
5119 : : struct thread_params *t_params, *tp;
5120 : : struct rte_bbdev_info info;
5121 : : lcore_function_t *throughput_function;
5122 : : uint16_t num_lcores;
5123 : : const char *op_type_str;
5124 : :
5125 : 0 : rte_bbdev_info_get(ad->dev_id, &info);
5126 : :
5127 : 0 : op_type_str = rte_bbdev_op_type_str(test_vector.op_type);
5128 : 0 : TEST_ASSERT_NOT_NULL(op_type_str, "Invalid op type: %u",
5129 : : test_vector.op_type);
5130 : :
5131 : : printf("+ ------------------------------------------------------- +\n");
5132 : 0 : printf("== test: throughput\ndev: %s, nb_queues: %u, burst size: %u, num ops: %u, num_lcores: %u, op type: %s, itr mode: %s, GHz: %lg\n",
5133 : 0 : info.dev_name, ad->nb_queues, op_params->burst_sz,
5134 : 0 : op_params->num_to_process, op_params->num_lcores,
5135 : : op_type_str,
5136 : 0 : intr_enabled ? "Interrupt mode" : "PMD mode",
5137 : 0 : (double)rte_get_tsc_hz() / 1000000000.0);
5138 : :
5139 : : /* Set number of lcores */
5140 : 0 : num_lcores = (ad->nb_queues < (op_params->num_lcores))
5141 : : ? ad->nb_queues
5142 : : : op_params->num_lcores;
5143 : :
5144 : : /* Allocate memory for thread parameters structure */
5145 : 0 : t_params = rte_zmalloc(NULL, num_lcores * sizeof(struct thread_params),
5146 : : RTE_CACHE_LINE_SIZE);
5147 : 0 : TEST_ASSERT_NOT_NULL(t_params, "Failed to alloc %zuB for t_params",
5148 : : RTE_ALIGN(sizeof(struct thread_params) * num_lcores,
5149 : : RTE_CACHE_LINE_SIZE));
5150 : :
5151 : 0 : if (intr_enabled) {
5152 : 0 : if (test_vector.op_type == RTE_BBDEV_OP_TURBO_DEC)
5153 : : throughput_function = throughput_intr_lcore_dec;
5154 : : else if (test_vector.op_type == RTE_BBDEV_OP_LDPC_DEC)
5155 : : throughput_function = throughput_intr_lcore_ldpc_dec;
5156 : : else if (test_vector.op_type == RTE_BBDEV_OP_TURBO_ENC)
5157 : : throughput_function = throughput_intr_lcore_enc;
5158 : : else if (test_vector.op_type == RTE_BBDEV_OP_LDPC_ENC)
5159 : : throughput_function = throughput_intr_lcore_ldpc_enc;
5160 : : else if (test_vector.op_type == RTE_BBDEV_OP_FFT)
5161 : : throughput_function = throughput_intr_lcore_fft;
5162 : : else if (test_vector.op_type == RTE_BBDEV_OP_MLDTS)
5163 : : throughput_function = throughput_intr_lcore_mldts;
5164 : : else
5165 : : throughput_function = throughput_intr_lcore_enc;
5166 : :
5167 : : /* Dequeue interrupt callback registration */
5168 : 0 : ret = rte_bbdev_callback_register(ad->dev_id,
5169 : : RTE_BBDEV_EVENT_DEQUEUE, dequeue_event_callback,
5170 : : t_params);
5171 : 0 : if (ret < 0) {
5172 : 0 : rte_free(t_params);
5173 : 0 : return ret;
5174 : : }
5175 : : } else {
5176 : 0 : if (test_vector.op_type == RTE_BBDEV_OP_TURBO_DEC)
5177 : : throughput_function = throughput_pmd_lcore_dec;
5178 : : else if (test_vector.op_type == RTE_BBDEV_OP_LDPC_DEC)
5179 : : throughput_function = throughput_pmd_lcore_ldpc_dec;
5180 : : else if (test_vector.op_type == RTE_BBDEV_OP_TURBO_ENC)
5181 : : throughput_function = throughput_pmd_lcore_enc;
5182 : : else if (test_vector.op_type == RTE_BBDEV_OP_LDPC_ENC)
5183 : : throughput_function = throughput_pmd_lcore_ldpc_enc;
5184 : : else if (test_vector.op_type == RTE_BBDEV_OP_FFT)
5185 : : throughput_function = throughput_pmd_lcore_fft;
5186 : : else if (test_vector.op_type == RTE_BBDEV_OP_MLDTS)
5187 : : throughput_function = throughput_pmd_lcore_mldts;
5188 : : else
5189 : : throughput_function = throughput_pmd_lcore_enc;
5190 : : }
5191 : :
5192 : 0 : rte_atomic_store_explicit(&op_params->sync, SYNC_WAIT, rte_memory_order_relaxed);
5193 : :
5194 : : /* Main core is set at first entry */
5195 : 0 : t_params[0].dev_id = ad->dev_id;
5196 : 0 : t_params[0].lcore_id = rte_lcore_id();
5197 : 0 : t_params[0].op_params = op_params;
5198 : 0 : t_params[0].queue_id = ad->queue_ids[used_cores++];
5199 : 0 : t_params[0].iter_count = 0;
5200 : :
5201 : 0 : RTE_LCORE_FOREACH_WORKER(lcore_id) {
5202 : 0 : if (used_cores >= num_lcores)
5203 : : break;
5204 : :
5205 : 0 : t_params[used_cores].dev_id = ad->dev_id;
5206 : 0 : t_params[used_cores].lcore_id = lcore_id;
5207 : 0 : t_params[used_cores].op_params = op_params;
5208 : 0 : t_params[used_cores].queue_id = ad->queue_ids[used_cores];
5209 : 0 : t_params[used_cores].iter_count = 0;
5210 : :
5211 : 0 : rte_eal_remote_launch(throughput_function,
5212 : 0 : &t_params[used_cores++], lcore_id);
5213 : : }
5214 : :
5215 : 0 : rte_atomic_store_explicit(&op_params->sync, SYNC_START, rte_memory_order_relaxed);
5216 : 0 : ret = throughput_function(&t_params[0]);
5217 : :
5218 : : /* Main core is always used */
5219 : 0 : for (used_cores = 1; used_cores < num_lcores; used_cores++)
5220 : 0 : ret |= rte_eal_wait_lcore(t_params[used_cores].lcore_id);
5221 : :
5222 : : /* Return if test failed */
5223 : 0 : if (ret) {
5224 : 0 : rte_free(t_params);
5225 : 0 : return ret;
5226 : : }
5227 : :
5228 : : /* Print throughput if interrupts are disabled and test passed */
5229 : 0 : if (!intr_enabled) {
5230 : 0 : if (test_vector.op_type == RTE_BBDEV_OP_TURBO_DEC ||
5231 : : test_vector.op_type == RTE_BBDEV_OP_LDPC_DEC)
5232 : 0 : print_dec_throughput(t_params, num_lcores);
5233 : : else
5234 : 0 : print_enc_throughput(t_params, num_lcores);
5235 : 0 : rte_free(t_params);
5236 : 0 : return ret;
5237 : : }
5238 : :
5239 : : /* In interrupt TC we need to wait for the interrupt callback to deqeue
5240 : : * all pending operations. Skip waiting for queues which reported an
5241 : : * error using processing_status variable.
5242 : : * Wait for main lcore operations.
5243 : : */
5244 : : tp = &t_params[0];
5245 : 0 : while ((rte_atomic_load_explicit(&tp->nb_dequeued, rte_memory_order_relaxed) <
5246 : 0 : op_params->num_to_process) &&
5247 : 0 : (rte_atomic_load_explicit(&tp->processing_status, rte_memory_order_relaxed) !=
5248 : : TEST_FAILED))
5249 : : rte_pause();
5250 : :
5251 : 0 : tp->ops_per_sec /= TEST_REPETITIONS;
5252 : 0 : tp->mbps /= TEST_REPETITIONS;
5253 : 0 : ret |= (int)rte_atomic_load_explicit(&tp->processing_status, rte_memory_order_relaxed);
5254 : :
5255 : : /* Wait for worker lcores operations */
5256 : 0 : for (used_cores = 1; used_cores < num_lcores; used_cores++) {
5257 : 0 : tp = &t_params[used_cores];
5258 : :
5259 : 0 : while ((rte_atomic_load_explicit(&tp->nb_dequeued, rte_memory_order_relaxed) <
5260 : 0 : op_params->num_to_process) &&
5261 : 0 : (rte_atomic_load_explicit(&tp->processing_status,
5262 : : rte_memory_order_relaxed) != TEST_FAILED))
5263 : : rte_pause();
5264 : :
5265 : 0 : tp->ops_per_sec /= TEST_REPETITIONS;
5266 : 0 : tp->mbps /= TEST_REPETITIONS;
5267 : 0 : ret |= (int)rte_atomic_load_explicit(&tp->processing_status,
5268 : : rte_memory_order_relaxed);
5269 : : }
5270 : :
5271 : : /* Print throughput if test passed */
5272 : 0 : if (!ret) {
5273 : 0 : if (test_vector.op_type == RTE_BBDEV_OP_TURBO_DEC ||
5274 : : test_vector.op_type == RTE_BBDEV_OP_LDPC_DEC)
5275 : 0 : print_dec_throughput(t_params, num_lcores);
5276 : 0 : else if (test_vector.op_type == RTE_BBDEV_OP_TURBO_ENC ||
5277 : : test_vector.op_type == RTE_BBDEV_OP_LDPC_ENC)
5278 : 0 : print_enc_throughput(t_params, num_lcores);
5279 : : }
5280 : :
5281 : 0 : rte_free(t_params);
5282 : 0 : return ret;
5283 : : }
5284 : :
5285 : : static int
5286 : 0 : latency_test_dec(struct rte_mempool *mempool,
5287 : : struct test_buffers *bufs, struct rte_bbdev_dec_op *ref_op,
5288 : : uint16_t dev_id, uint16_t queue_id,
5289 : : const uint16_t num_to_process, uint16_t burst_sz,
5290 : : uint64_t *total_time, uint64_t *min_time, uint64_t *max_time, bool disable_et)
5291 : : {
5292 : : int ret = TEST_SUCCESS;
5293 : : uint16_t i, j, dequeued;
5294 : : struct rte_bbdev_dec_op *ops_enq[MAX_BURST], *ops_deq[MAX_BURST];
5295 : : uint64_t start_time = 0, last_time = 0;
5296 : :
5297 : 0 : for (i = 0, dequeued = 0; dequeued < num_to_process; ++i) {
5298 : : uint16_t enq = 0, deq = 0;
5299 : : uint32_t time_out = 0;
5300 : : bool first_time = true;
5301 : : last_time = 0;
5302 : :
5303 : 0 : if (unlikely(num_to_process - dequeued < burst_sz))
5304 : 0 : burst_sz = num_to_process - dequeued;
5305 : :
5306 : 0 : ret = rte_bbdev_dec_op_alloc_bulk(mempool, ops_enq, burst_sz);
5307 : 0 : TEST_ASSERT_SUCCESS(ret, "rte_bbdev_dec_op_alloc_bulk() failed");
5308 : :
5309 : 0 : ref_op->turbo_dec.iter_max = get_iter_max();
5310 : : /* For validation tests we want to enable early termination */
5311 : 0 : if (!disable_et && !check_bit(ref_op->turbo_dec.op_flags,
5312 : : RTE_BBDEV_TURBO_EARLY_TERMINATION))
5313 : 0 : ref_op->turbo_dec.op_flags |= RTE_BBDEV_TURBO_EARLY_TERMINATION;
5314 : :
5315 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
5316 : 0 : copy_reference_dec_op(ops_enq, burst_sz, dequeued,
5317 : : bufs->inputs,
5318 : : bufs->hard_outputs,
5319 : : bufs->soft_outputs,
5320 : : ref_op);
5321 : :
5322 : : /* Set counter to validate the ordering */
5323 : 0 : for (j = 0; j < burst_sz; ++j)
5324 : 0 : ops_enq[j]->opaque_data = (void *)(uintptr_t)j;
5325 : :
5326 : : start_time = rte_rdtsc_precise();
5327 : :
5328 : 0 : enq = rte_bbdev_enqueue_dec_ops(dev_id, queue_id, &ops_enq[enq],
5329 : : burst_sz);
5330 : 0 : TEST_ASSERT(enq == burst_sz,
5331 : : "Error enqueueing burst, expected %u, got %u",
5332 : : burst_sz, enq);
5333 : :
5334 : : /* Dequeue */
5335 : : do {
5336 : 0 : deq += rte_bbdev_dequeue_dec_ops(dev_id, queue_id,
5337 : 0 : &ops_deq[deq], burst_sz - deq);
5338 : 0 : if (likely(first_time && (deq > 0))) {
5339 : 0 : last_time = rte_rdtsc_precise() - start_time;
5340 : : first_time = false;
5341 : : }
5342 : 0 : time_out++;
5343 : 0 : if (time_out >= TIME_OUT_POLL) {
5344 : 0 : timeout_exit(dev_id);
5345 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Dequeue timeout!");
5346 : : }
5347 : 0 : } while (unlikely(burst_sz != deq));
5348 : :
5349 : 0 : *max_time = RTE_MAX(*max_time, last_time);
5350 : 0 : *min_time = RTE_MIN(*min_time, last_time);
5351 : 0 : *total_time += last_time;
5352 : :
5353 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE) {
5354 : 0 : ret = validate_dec_op(ops_deq, burst_sz, ref_op);
5355 : 0 : TEST_ASSERT_SUCCESS(ret, "Validation failed!");
5356 : : }
5357 : :
5358 : 0 : rte_bbdev_dec_op_free_bulk(ops_enq, deq);
5359 : 0 : dequeued += deq;
5360 : : }
5361 : :
5362 : 0 : return i;
5363 : : }
5364 : :
5365 : : /* Test case for latency/validation for LDPC Decoder */
5366 : : static int
5367 : 0 : latency_test_ldpc_dec(struct rte_mempool *mempool,
5368 : : struct test_buffers *bufs, struct rte_bbdev_dec_op *ref_op,
5369 : : int vector_mask, uint16_t dev_id, uint16_t queue_id,
5370 : : const uint16_t num_to_process, uint16_t burst_sz,
5371 : : uint64_t *total_time, uint64_t *min_time, uint64_t *max_time,
5372 : : bool disable_et)
5373 : : {
5374 : : int ret = TEST_SUCCESS;
5375 : : uint16_t i, j, dequeued;
5376 : : struct rte_bbdev_dec_op *ops_enq[MAX_BURST], *ops_deq[MAX_BURST];
5377 : : uint64_t start_time = 0, last_time = 0;
5378 : 0 : bool extDdr = ldpc_cap_flags &
5379 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE;
5380 : :
5381 : 0 : for (i = 0, dequeued = 0; dequeued < num_to_process; ++i) {
5382 : : uint16_t enq = 0, deq = 0;
5383 : : uint32_t time_out = 0;
5384 : : bool first_time = true;
5385 : : last_time = 0;
5386 : :
5387 : 0 : if (unlikely(num_to_process - dequeued < burst_sz))
5388 : 0 : burst_sz = num_to_process - dequeued;
5389 : :
5390 : 0 : ret = rte_bbdev_dec_op_alloc_bulk(mempool, ops_enq, burst_sz);
5391 : 0 : TEST_ASSERT_SUCCESS(ret,
5392 : : "rte_bbdev_dec_op_alloc_bulk() failed");
5393 : :
5394 : : /* For latency tests we need to disable early termination */
5395 : 0 : if (disable_et && check_bit(ref_op->ldpc_dec.op_flags,
5396 : : RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE))
5397 : 0 : ref_op->ldpc_dec.op_flags -= RTE_BBDEV_LDPC_ITERATION_STOP_ENABLE;
5398 : :
5399 : 0 : ref_op->ldpc_dec.iter_max = get_iter_max();
5400 : : /* When ET is disabled, the expected iter_count is iter_max */
5401 : 0 : if (disable_et)
5402 : 0 : ref_op->ldpc_dec.iter_count = ref_op->ldpc_dec.iter_max;
5403 : :
5404 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
5405 : 0 : copy_reference_ldpc_dec_op(ops_enq, burst_sz, dequeued,
5406 : : bufs->inputs,
5407 : : bufs->hard_outputs,
5408 : : bufs->soft_outputs,
5409 : : bufs->harq_inputs,
5410 : : bufs->harq_outputs,
5411 : : ref_op);
5412 : :
5413 : 0 : if (extDdr)
5414 : 0 : preload_harq_ddr(dev_id, queue_id, ops_enq,
5415 : : burst_sz, true);
5416 : :
5417 : : /* Set counter to validate the ordering */
5418 : 0 : for (j = 0; j < burst_sz; ++j)
5419 : 0 : ops_enq[j]->opaque_data = (void *)(uintptr_t)j;
5420 : :
5421 : : start_time = rte_rdtsc_precise();
5422 : :
5423 : 0 : enq = rte_bbdev_enqueue_ldpc_dec_ops(dev_id, queue_id,
5424 : : &ops_enq[enq], burst_sz);
5425 : 0 : TEST_ASSERT(enq == burst_sz,
5426 : : "Error enqueueing burst, expected %u, got %u",
5427 : : burst_sz, enq);
5428 : :
5429 : : /* Dequeue */
5430 : : do {
5431 : 0 : deq += rte_bbdev_dequeue_ldpc_dec_ops(dev_id, queue_id,
5432 : 0 : &ops_deq[deq], burst_sz - deq);
5433 : 0 : if (likely(first_time && (deq > 0))) {
5434 : 0 : last_time = rte_rdtsc_precise() - start_time;
5435 : : first_time = false;
5436 : : }
5437 : 0 : time_out++;
5438 : 0 : if (time_out >= TIME_OUT_POLL) {
5439 : 0 : timeout_exit(dev_id);
5440 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Dequeue timeout!");
5441 : : }
5442 : 0 : } while (unlikely(burst_sz != deq));
5443 : :
5444 : 0 : *max_time = RTE_MAX(*max_time, last_time);
5445 : 0 : *min_time = RTE_MIN(*min_time, last_time);
5446 : 0 : *total_time += last_time;
5447 : :
5448 : 0 : if (extDdr)
5449 : 0 : retrieve_harq_ddr(dev_id, queue_id, ops_enq, burst_sz);
5450 : :
5451 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE) {
5452 : 0 : ret = validate_ldpc_dec_op(ops_deq, burst_sz, ref_op, vector_mask);
5453 : 0 : TEST_ASSERT_SUCCESS(ret, "Validation failed!");
5454 : : }
5455 : :
5456 : 0 : rte_bbdev_dec_op_free_bulk(ops_enq, deq);
5457 : 0 : dequeued += deq;
5458 : : }
5459 : 0 : return i;
5460 : : }
5461 : :
5462 : : static int
5463 : 0 : latency_test_enc(struct rte_mempool *mempool,
5464 : : struct test_buffers *bufs, struct rte_bbdev_enc_op *ref_op,
5465 : : uint16_t dev_id, uint16_t queue_id,
5466 : : const uint16_t num_to_process, uint16_t burst_sz,
5467 : : uint64_t *total_time, uint64_t *min_time, uint64_t *max_time)
5468 : : {
5469 : : int ret = TEST_SUCCESS;
5470 : : uint16_t i, j, dequeued;
5471 : : struct rte_bbdev_enc_op *ops_enq[MAX_BURST], *ops_deq[MAX_BURST];
5472 : : uint64_t start_time = 0, last_time = 0;
5473 : :
5474 : 0 : for (i = 0, dequeued = 0; dequeued < num_to_process; ++i) {
5475 : : uint16_t enq = 0, deq = 0;
5476 : : uint32_t time_out = 0;
5477 : : bool first_time = true;
5478 : : last_time = 0;
5479 : :
5480 : 0 : if (unlikely(num_to_process - dequeued < burst_sz))
5481 : 0 : burst_sz = num_to_process - dequeued;
5482 : :
5483 : 0 : ret = rte_bbdev_enc_op_alloc_bulk(mempool, ops_enq, burst_sz);
5484 : 0 : TEST_ASSERT_SUCCESS(ret,
5485 : : "rte_bbdev_enc_op_alloc_bulk() failed");
5486 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
5487 : 0 : copy_reference_enc_op(ops_enq, burst_sz, dequeued,
5488 : : bufs->inputs,
5489 : : bufs->hard_outputs,
5490 : : ref_op);
5491 : :
5492 : : /* Set counter to validate the ordering */
5493 : 0 : for (j = 0; j < burst_sz; ++j)
5494 : 0 : ops_enq[j]->opaque_data = (void *)(uintptr_t)j;
5495 : :
5496 : : start_time = rte_rdtsc_precise();
5497 : :
5498 : 0 : enq = rte_bbdev_enqueue_enc_ops(dev_id, queue_id, &ops_enq[enq],
5499 : : burst_sz);
5500 : 0 : TEST_ASSERT(enq == burst_sz,
5501 : : "Error enqueueing burst, expected %u, got %u",
5502 : : burst_sz, enq);
5503 : :
5504 : : /* Dequeue */
5505 : : do {
5506 : 0 : deq += rte_bbdev_dequeue_enc_ops(dev_id, queue_id,
5507 : 0 : &ops_deq[deq], burst_sz - deq);
5508 : 0 : if (likely(first_time && (deq > 0))) {
5509 : 0 : last_time += rte_rdtsc_precise() - start_time;
5510 : : first_time = false;
5511 : : }
5512 : 0 : time_out++;
5513 : 0 : if (time_out >= TIME_OUT_POLL) {
5514 : 0 : timeout_exit(dev_id);
5515 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Dequeue timeout!");
5516 : : }
5517 : 0 : } while (unlikely(burst_sz != deq));
5518 : :
5519 : 0 : *max_time = RTE_MAX(*max_time, last_time);
5520 : 0 : *min_time = RTE_MIN(*min_time, last_time);
5521 : 0 : *total_time += last_time;
5522 : :
5523 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE) {
5524 : 0 : ret = validate_enc_op(ops_deq, burst_sz, ref_op);
5525 : 0 : TEST_ASSERT_SUCCESS(ret, "Validation failed!");
5526 : : }
5527 : :
5528 : 0 : rte_bbdev_enc_op_free_bulk(ops_enq, deq);
5529 : 0 : dequeued += deq;
5530 : : }
5531 : :
5532 : 0 : return i;
5533 : : }
5534 : :
5535 : : static int
5536 : 0 : latency_test_ldpc_enc(struct rte_mempool *mempool,
5537 : : struct test_buffers *bufs, struct rte_bbdev_enc_op *ref_op,
5538 : : uint16_t dev_id, uint16_t queue_id,
5539 : : const uint16_t num_to_process, uint16_t burst_sz,
5540 : : uint64_t *total_time, uint64_t *min_time, uint64_t *max_time)
5541 : : {
5542 : : int ret = TEST_SUCCESS;
5543 : : uint16_t i, j, dequeued;
5544 : : struct rte_bbdev_enc_op *ops_enq[MAX_BURST], *ops_deq[MAX_BURST];
5545 : : uint64_t start_time = 0, last_time = 0;
5546 : :
5547 : 0 : for (i = 0, dequeued = 0; dequeued < num_to_process; ++i) {
5548 : : uint16_t enq = 0, deq = 0;
5549 : : uint32_t time_out = 0;
5550 : : bool first_time = true;
5551 : : last_time = 0;
5552 : :
5553 : 0 : if (unlikely(num_to_process - dequeued < burst_sz))
5554 : 0 : burst_sz = num_to_process - dequeued;
5555 : :
5556 : 0 : ret = rte_bbdev_enc_op_alloc_bulk(mempool, ops_enq, burst_sz);
5557 : 0 : TEST_ASSERT_SUCCESS(ret,
5558 : : "rte_bbdev_enc_op_alloc_bulk() failed");
5559 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
5560 : 0 : copy_reference_ldpc_enc_op(ops_enq, burst_sz, dequeued,
5561 : : bufs->inputs,
5562 : : bufs->hard_outputs,
5563 : : ref_op);
5564 : :
5565 : : /* Set counter to validate the ordering */
5566 : 0 : for (j = 0; j < burst_sz; ++j)
5567 : 0 : ops_enq[j]->opaque_data = (void *)(uintptr_t)j;
5568 : :
5569 : : start_time = rte_rdtsc_precise();
5570 : :
5571 : 0 : enq = rte_bbdev_enqueue_ldpc_enc_ops(dev_id, queue_id,
5572 : : &ops_enq[enq], burst_sz);
5573 : 0 : TEST_ASSERT(enq == burst_sz,
5574 : : "Error enqueueing burst, expected %u, got %u",
5575 : : burst_sz, enq);
5576 : :
5577 : : /* Dequeue */
5578 : : do {
5579 : 0 : deq += rte_bbdev_dequeue_ldpc_enc_ops(dev_id, queue_id,
5580 : 0 : &ops_deq[deq], burst_sz - deq);
5581 : 0 : if (likely(first_time && (deq > 0))) {
5582 : 0 : last_time += rte_rdtsc_precise() - start_time;
5583 : : first_time = false;
5584 : : }
5585 : 0 : time_out++;
5586 : 0 : if (time_out >= TIME_OUT_POLL) {
5587 : 0 : timeout_exit(dev_id);
5588 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Dequeue timeout!");
5589 : : }
5590 : 0 : } while (unlikely(burst_sz != deq));
5591 : :
5592 : 0 : *max_time = RTE_MAX(*max_time, last_time);
5593 : 0 : *min_time = RTE_MIN(*min_time, last_time);
5594 : 0 : *total_time += last_time;
5595 : :
5596 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE) {
5597 : 0 : ret = validate_enc_op(ops_deq, burst_sz, ref_op);
5598 : 0 : TEST_ASSERT_SUCCESS(ret, "Validation failed!");
5599 : : }
5600 : :
5601 : 0 : rte_bbdev_enc_op_free_bulk(ops_enq, deq);
5602 : 0 : dequeued += deq;
5603 : : }
5604 : :
5605 : 0 : return i;
5606 : : }
5607 : :
5608 : :
5609 : : static int
5610 : 0 : latency_test_fft(struct rte_mempool *mempool,
5611 : : struct test_buffers *bufs, struct rte_bbdev_fft_op *ref_op,
5612 : : uint16_t dev_id, uint16_t queue_id,
5613 : : const uint16_t num_to_process, uint16_t burst_sz,
5614 : : uint64_t *total_time, uint64_t *min_time, uint64_t *max_time)
5615 : : {
5616 : : int ret = TEST_SUCCESS;
5617 : : uint16_t i, j, dequeued;
5618 : : struct rte_bbdev_fft_op *ops_enq[MAX_BURST], *ops_deq[MAX_BURST];
5619 : : uint64_t start_time = 0, last_time = 0;
5620 : :
5621 : 0 : for (i = 0, dequeued = 0; dequeued < num_to_process; ++i) {
5622 : : uint16_t enq = 0, deq = 0;
5623 : : uint32_t time_out = 0;
5624 : : bool first_time = true;
5625 : : last_time = 0;
5626 : :
5627 : 0 : if (unlikely(num_to_process - dequeued < burst_sz))
5628 : 0 : burst_sz = num_to_process - dequeued;
5629 : :
5630 : 0 : ret = rte_bbdev_fft_op_alloc_bulk(mempool, ops_enq, burst_sz);
5631 : 0 : TEST_ASSERT_SUCCESS(ret,
5632 : : "rte_bbdev_fft_op_alloc_bulk() failed");
5633 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
5634 : 0 : copy_reference_fft_op(ops_enq, burst_sz, dequeued,
5635 : : bufs->inputs,
5636 : : bufs->hard_outputs, bufs->soft_outputs, bufs->harq_inputs,
5637 : : ref_op);
5638 : :
5639 : : /* Set counter to validate the ordering */
5640 : 0 : for (j = 0; j < burst_sz; ++j)
5641 : 0 : ops_enq[j]->opaque_data = (void *)(uintptr_t)j;
5642 : :
5643 : : start_time = rte_rdtsc_precise();
5644 : :
5645 : 0 : enq = rte_bbdev_enqueue_fft_ops(dev_id, queue_id,
5646 : : &ops_enq[enq], burst_sz);
5647 : 0 : TEST_ASSERT(enq == burst_sz,
5648 : : "Error enqueueing burst, expected %u, got %u",
5649 : : burst_sz, enq);
5650 : :
5651 : : /* Dequeue */
5652 : : do {
5653 : 0 : deq += rte_bbdev_dequeue_fft_ops(dev_id, queue_id,
5654 : 0 : &ops_deq[deq], burst_sz - deq);
5655 : 0 : if (likely(first_time && (deq > 0))) {
5656 : 0 : last_time += rte_rdtsc_precise() - start_time;
5657 : : first_time = false;
5658 : : }
5659 : 0 : time_out++;
5660 : 0 : if (time_out >= TIME_OUT_POLL) {
5661 : 0 : timeout_exit(dev_id);
5662 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Dequeue timeout!");
5663 : : }
5664 : 0 : } while (unlikely(burst_sz != deq));
5665 : :
5666 : 0 : *max_time = RTE_MAX(*max_time, last_time);
5667 : 0 : *min_time = RTE_MIN(*min_time, last_time);
5668 : 0 : *total_time += last_time;
5669 : :
5670 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE) {
5671 : 0 : ret = validate_fft_op(ops_deq, burst_sz, ref_op);
5672 : 0 : TEST_ASSERT_SUCCESS(ret, "Validation failed!");
5673 : : }
5674 : :
5675 : 0 : rte_bbdev_fft_op_free_bulk(ops_enq, deq);
5676 : 0 : dequeued += deq;
5677 : : }
5678 : :
5679 : 0 : return i;
5680 : : }
5681 : :
5682 : : static int
5683 : 0 : latency_test_mldts(struct rte_mempool *mempool,
5684 : : struct test_buffers *bufs, struct rte_bbdev_mldts_op *ref_op,
5685 : : uint16_t dev_id, uint16_t queue_id,
5686 : : const uint16_t num_to_process, uint16_t burst_sz,
5687 : : uint64_t *total_time, uint64_t *min_time, uint64_t *max_time)
5688 : : {
5689 : : int ret = TEST_SUCCESS;
5690 : : uint16_t i, j, dequeued;
5691 : : struct rte_bbdev_mldts_op *ops_enq[MAX_BURST], *ops_deq[MAX_BURST];
5692 : : uint64_t start_time = 0, last_time = 0;
5693 : :
5694 : 0 : for (i = 0, dequeued = 0; dequeued < num_to_process; ++i) {
5695 : : uint16_t enq = 0, deq = 0;
5696 : : uint32_t time_out = 0;
5697 : : bool first_time = true;
5698 : : last_time = 0;
5699 : :
5700 : 0 : if (unlikely(num_to_process - dequeued < burst_sz))
5701 : 0 : burst_sz = num_to_process - dequeued;
5702 : :
5703 : 0 : ret = rte_bbdev_mldts_op_alloc_bulk(mempool, ops_enq, burst_sz);
5704 : 0 : TEST_ASSERT_SUCCESS(ret, "rte_bbdev_mldts_op_alloc_bulk() failed");
5705 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
5706 : 0 : copy_reference_mldts_op(ops_enq, burst_sz, dequeued,
5707 : : bufs->inputs, bufs->harq_inputs,
5708 : : bufs->hard_outputs,
5709 : : ref_op);
5710 : :
5711 : : /* Set counter to validate the ordering */
5712 : 0 : for (j = 0; j < burst_sz; ++j)
5713 : 0 : ops_enq[j]->opaque_data = (void *)(uintptr_t)j;
5714 : :
5715 : : start_time = rte_rdtsc_precise();
5716 : :
5717 : 0 : enq = rte_bbdev_enqueue_mldts_ops(dev_id, queue_id, &ops_enq[enq], burst_sz);
5718 : 0 : TEST_ASSERT(enq == burst_sz,
5719 : : "Error enqueueing burst, expected %u, got %u",
5720 : : burst_sz, enq);
5721 : :
5722 : : /* Dequeue */
5723 : : do {
5724 : 0 : deq += rte_bbdev_dequeue_mldts_ops(dev_id, queue_id,
5725 : 0 : &ops_deq[deq], burst_sz - deq);
5726 : 0 : if (likely(first_time && (deq > 0))) {
5727 : 0 : last_time += rte_rdtsc_precise() - start_time;
5728 : : first_time = false;
5729 : : }
5730 : 0 : time_out++;
5731 : 0 : if (time_out >= TIME_OUT_POLL) {
5732 : 0 : timeout_exit(dev_id);
5733 : 0 : TEST_ASSERT_SUCCESS(TEST_FAILED, "Dequeue timeout!");
5734 : : }
5735 : 0 : } while (unlikely(burst_sz != deq));
5736 : :
5737 : 0 : *max_time = RTE_MAX(*max_time, last_time);
5738 : 0 : *min_time = RTE_MIN(*min_time, last_time);
5739 : 0 : *total_time += last_time;
5740 : :
5741 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE) {
5742 : 0 : ret = validate_mldts_op(ops_deq, burst_sz, ref_op);
5743 : 0 : TEST_ASSERT_SUCCESS(ret, "Validation failed!");
5744 : : }
5745 : :
5746 : 0 : rte_bbdev_mldts_op_free_bulk(ops_enq, deq);
5747 : 0 : dequeued += deq;
5748 : : }
5749 : :
5750 : 0 : return i;
5751 : : }
5752 : :
5753 : : /* Common function for running validation and latency test cases */
5754 : : static int
5755 : 0 : validation_latency_test(struct active_device *ad,
5756 : : struct test_op_params *op_params, bool latency_flag)
5757 : : {
5758 : : int iter;
5759 : 0 : uint16_t burst_sz = op_params->burst_sz;
5760 : 0 : const uint16_t num_to_process = op_params->num_to_process;
5761 : 0 : const enum rte_bbdev_op_type op_type = test_vector.op_type;
5762 : 0 : const uint16_t queue_id = ad->queue_ids[0];
5763 : : struct test_buffers *bufs = NULL;
5764 : : struct rte_bbdev_info info;
5765 : : uint64_t total_time, min_time, max_time;
5766 : : const char *op_type_str;
5767 : :
5768 : 0 : total_time = max_time = 0;
5769 : 0 : min_time = UINT64_MAX;
5770 : :
5771 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
5772 : : "BURST_SIZE should be <= %u", MAX_BURST);
5773 : :
5774 : 0 : rte_bbdev_info_get(ad->dev_id, &info);
5775 : 0 : bufs = &op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
5776 : :
5777 : 0 : op_type_str = rte_bbdev_op_type_str(op_type);
5778 : 0 : TEST_ASSERT_NOT_NULL(op_type_str, "Invalid op type: %u", op_type);
5779 : :
5780 : : printf("+ ------------------------------------------------------- +\n");
5781 : 0 : if (latency_flag)
5782 : : printf("== test: latency\ndev:");
5783 : : else
5784 : : printf("== test: validation\ndev:");
5785 : 0 : printf("%s, burst size: %u, num ops: %u, op type: %s\n",
5786 : : info.dev_name, burst_sz, num_to_process, op_type_str);
5787 : :
5788 : 0 : if (op_type == RTE_BBDEV_OP_TURBO_DEC)
5789 : 0 : iter = latency_test_dec(op_params->mp, bufs,
5790 : 0 : op_params->ref_dec_op, ad->dev_id, queue_id,
5791 : : num_to_process, burst_sz, &total_time,
5792 : : &min_time, &max_time, latency_flag);
5793 : 0 : else if (op_type == RTE_BBDEV_OP_LDPC_ENC)
5794 : 0 : iter = latency_test_ldpc_enc(op_params->mp, bufs,
5795 : 0 : op_params->ref_enc_op, ad->dev_id, queue_id,
5796 : : num_to_process, burst_sz, &total_time,
5797 : : &min_time, &max_time);
5798 : 0 : else if (op_type == RTE_BBDEV_OP_LDPC_DEC)
5799 : 0 : iter = latency_test_ldpc_dec(op_params->mp, bufs,
5800 : : op_params->ref_dec_op, op_params->vector_mask,
5801 : 0 : ad->dev_id, queue_id, num_to_process,
5802 : : burst_sz, &total_time, &min_time, &max_time,
5803 : : latency_flag);
5804 : 0 : else if (op_type == RTE_BBDEV_OP_FFT)
5805 : 0 : iter = latency_test_fft(op_params->mp, bufs,
5806 : : op_params->ref_fft_op,
5807 : 0 : ad->dev_id, queue_id,
5808 : : num_to_process, burst_sz, &total_time,
5809 : : &min_time, &max_time);
5810 : 0 : else if (op_type == RTE_BBDEV_OP_MLDTS)
5811 : 0 : iter = latency_test_mldts(op_params->mp, bufs,
5812 : : op_params->ref_mldts_op,
5813 : 0 : ad->dev_id, queue_id,
5814 : : num_to_process, burst_sz, &total_time,
5815 : : &min_time, &max_time);
5816 : : else /* RTE_BBDEV_OP_TURBO_ENC */
5817 : 0 : iter = latency_test_enc(op_params->mp, bufs,
5818 : : op_params->ref_enc_op,
5819 : 0 : ad->dev_id, queue_id,
5820 : : num_to_process, burst_sz, &total_time,
5821 : : &min_time, &max_time);
5822 : :
5823 : 0 : if (iter <= 0)
5824 : : return TEST_FAILED;
5825 : :
5826 : 0 : printf("Operation latency:\n"
5827 : : "\tavg: %lg cycles, %lg us\n"
5828 : : "\tmin: %lg cycles, %lg us\n"
5829 : : "\tmax: %lg cycles, %lg us\n",
5830 : 0 : (double)total_time / (double)iter,
5831 : 0 : (double)(total_time * 1000000) / (double)iter /
5832 : 0 : (double)rte_get_tsc_hz(), (double)min_time,
5833 : 0 : (double)(min_time * 1000000) / (double)rte_get_tsc_hz(),
5834 : 0 : (double)max_time, (double)(max_time * 1000000) /
5835 : 0 : (double)rte_get_tsc_hz());
5836 : :
5837 : 0 : return TEST_SUCCESS;
5838 : : }
5839 : :
5840 : : static int
5841 : 0 : latency_test(struct active_device *ad, struct test_op_params *op_params)
5842 : : {
5843 : 0 : return validation_latency_test(ad, op_params, true);
5844 : : }
5845 : :
5846 : : static int
5847 : 0 : validation_test(struct active_device *ad, struct test_op_params *op_params)
5848 : : {
5849 : 0 : return validation_latency_test(ad, op_params, false);
5850 : : }
5851 : :
5852 : : static int
5853 : 0 : get_bbdev_queue_stats(uint16_t dev_id, uint16_t queue_id,
5854 : : struct rte_bbdev_stats *stats)
5855 : : {
5856 : 0 : struct rte_bbdev *dev = &rte_bbdev_devices[dev_id];
5857 : : struct rte_bbdev_stats *q_stats;
5858 : :
5859 : 0 : if (queue_id >= dev->data->num_queues)
5860 : : return -1;
5861 : :
5862 : 0 : q_stats = &dev->data->queues[queue_id].queue_stats;
5863 : :
5864 : 0 : stats->enqueued_count = q_stats->enqueued_count;
5865 : 0 : stats->dequeued_count = q_stats->dequeued_count;
5866 : 0 : stats->enqueue_err_count = q_stats->enqueue_err_count;
5867 : 0 : stats->dequeue_err_count = q_stats->dequeue_err_count;
5868 : 0 : stats->enqueue_warn_count = q_stats->enqueue_warn_count;
5869 : 0 : stats->dequeue_warn_count = q_stats->dequeue_warn_count;
5870 : 0 : stats->acc_offload_cycles = q_stats->acc_offload_cycles;
5871 : 0 : stats->enqueue_depth_avail = q_stats->enqueue_depth_avail;
5872 : :
5873 : 0 : return 0;
5874 : : }
5875 : :
5876 : : static int
5877 : 0 : offload_latency_test_fft(struct rte_mempool *mempool, struct test_buffers *bufs,
5878 : : struct rte_bbdev_fft_op *ref_op, uint16_t dev_id,
5879 : : uint16_t queue_id, const uint16_t num_to_process,
5880 : : uint16_t burst_sz, struct test_time_stats *time_st)
5881 : : {
5882 : : int i, dequeued, ret;
5883 : : struct rte_bbdev_fft_op *ops_enq[MAX_BURST], *ops_deq[MAX_BURST];
5884 : : uint64_t enq_start_time, deq_start_time;
5885 : : uint64_t enq_sw_last_time, deq_last_time;
5886 : : struct rte_bbdev_stats stats;
5887 : :
5888 : 0 : for (i = 0, dequeued = 0; dequeued < num_to_process; ++i) {
5889 : : uint16_t enq = 0, deq = 0;
5890 : :
5891 : 0 : if (unlikely(num_to_process - dequeued < burst_sz))
5892 : 0 : burst_sz = num_to_process - dequeued;
5893 : :
5894 : 0 : ret = rte_bbdev_fft_op_alloc_bulk(mempool, ops_enq, burst_sz);
5895 : 0 : TEST_ASSERT_SUCCESS(ret, "rte_bbdev_fft_op_alloc_bulk() failed");
5896 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
5897 : 0 : copy_reference_fft_op(ops_enq, burst_sz, dequeued,
5898 : : bufs->inputs,
5899 : : bufs->hard_outputs, bufs->soft_outputs, bufs->harq_inputs,
5900 : : ref_op);
5901 : :
5902 : : /* Start time meas for enqueue function offload latency */
5903 : : enq_start_time = rte_rdtsc_precise();
5904 : : do {
5905 : 0 : enq += rte_bbdev_enqueue_fft_ops(dev_id, queue_id,
5906 : 0 : &ops_enq[enq], burst_sz - enq);
5907 : 0 : } while (unlikely(burst_sz != enq));
5908 : :
5909 : 0 : ret = get_bbdev_queue_stats(dev_id, queue_id, &stats);
5910 : 0 : TEST_ASSERT_SUCCESS(ret,
5911 : : "Failed to get stats for queue (%u) of device (%u)",
5912 : : queue_id, dev_id);
5913 : :
5914 : 0 : enq_sw_last_time = rte_rdtsc_precise() - enq_start_time -
5915 : 0 : stats.acc_offload_cycles;
5916 : 0 : time_st->enq_sw_max_time = RTE_MAX(time_st->enq_sw_max_time,
5917 : : enq_sw_last_time);
5918 : 0 : time_st->enq_sw_min_time = RTE_MIN(time_st->enq_sw_min_time,
5919 : : enq_sw_last_time);
5920 : 0 : time_st->enq_sw_total_time += enq_sw_last_time;
5921 : :
5922 : 0 : time_st->enq_acc_max_time = RTE_MAX(time_st->enq_acc_max_time,
5923 : : stats.acc_offload_cycles);
5924 : 0 : time_st->enq_acc_min_time = RTE_MIN(time_st->enq_acc_min_time,
5925 : : stats.acc_offload_cycles);
5926 : 0 : time_st->enq_acc_total_time += stats.acc_offload_cycles;
5927 : :
5928 : : /* give time for device to process ops */
5929 : 0 : rte_delay_us(WAIT_OFFLOAD_US);
5930 : :
5931 : : /* Start time meas for dequeue function offload latency */
5932 : : deq_start_time = rte_rdtsc_precise();
5933 : : /* Dequeue one operation */
5934 : : do {
5935 : 0 : deq += rte_bbdev_dequeue_fft_ops(dev_id, queue_id,
5936 : 0 : &ops_deq[deq], enq);
5937 : 0 : } while (unlikely(deq == 0));
5938 : :
5939 : 0 : deq_last_time = rte_rdtsc_precise() - deq_start_time;
5940 : 0 : time_st->deq_max_time = RTE_MAX(time_st->deq_max_time,
5941 : : deq_last_time);
5942 : 0 : time_st->deq_min_time = RTE_MIN(time_st->deq_min_time,
5943 : : deq_last_time);
5944 : 0 : time_st->deq_total_time += deq_last_time;
5945 : :
5946 : : /* Dequeue remaining operations if needed*/
5947 : 0 : while (burst_sz != deq)
5948 : 0 : deq += rte_bbdev_dequeue_fft_ops(dev_id, queue_id,
5949 : 0 : &ops_deq[deq], burst_sz - deq);
5950 : :
5951 : 0 : rte_bbdev_fft_op_free_bulk(ops_enq, deq);
5952 : 0 : dequeued += deq;
5953 : : }
5954 : :
5955 : : return i;
5956 : : }
5957 : :
5958 : : static int
5959 : 0 : offload_latency_test_mldts(struct rte_mempool *mempool, struct test_buffers *bufs,
5960 : : struct rte_bbdev_mldts_op *ref_op, uint16_t dev_id,
5961 : : uint16_t queue_id, const uint16_t num_to_process,
5962 : : uint16_t burst_sz, struct test_time_stats *time_st)
5963 : : {
5964 : : int i, dequeued, ret;
5965 : : struct rte_bbdev_mldts_op *ops_enq[MAX_BURST], *ops_deq[MAX_BURST];
5966 : : uint64_t enq_start_time, deq_start_time;
5967 : : uint64_t enq_sw_last_time, deq_last_time;
5968 : : struct rte_bbdev_stats stats;
5969 : :
5970 : 0 : for (i = 0, dequeued = 0; dequeued < num_to_process; ++i) {
5971 : : uint16_t enq = 0, deq = 0;
5972 : :
5973 : 0 : if (unlikely(num_to_process - dequeued < burst_sz))
5974 : 0 : burst_sz = num_to_process - dequeued;
5975 : :
5976 : 0 : ret = rte_bbdev_mldts_op_alloc_bulk(mempool, ops_enq, burst_sz);
5977 : 0 : TEST_ASSERT_SUCCESS(ret, "rte_bbdev_mldts_op_alloc_bulk() failed");
5978 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
5979 : 0 : copy_reference_mldts_op(ops_enq, burst_sz, dequeued,
5980 : : bufs->inputs, bufs->harq_inputs,
5981 : : bufs->hard_outputs,
5982 : : ref_op);
5983 : :
5984 : : /* Start time meas for enqueue function offload latency */
5985 : : enq_start_time = rte_rdtsc_precise();
5986 : : do {
5987 : 0 : enq += rte_bbdev_enqueue_mldts_ops(dev_id, queue_id,
5988 : 0 : &ops_enq[enq], burst_sz - enq);
5989 : 0 : } while (unlikely(burst_sz != enq));
5990 : :
5991 : 0 : ret = get_bbdev_queue_stats(dev_id, queue_id, &stats);
5992 : 0 : TEST_ASSERT_SUCCESS(ret,
5993 : : "Failed to get stats for queue (%u) of device (%u)",
5994 : : queue_id, dev_id);
5995 : :
5996 : 0 : enq_sw_last_time = rte_rdtsc_precise() - enq_start_time -
5997 : 0 : stats.acc_offload_cycles;
5998 : 0 : time_st->enq_sw_max_time = RTE_MAX(time_st->enq_sw_max_time,
5999 : : enq_sw_last_time);
6000 : 0 : time_st->enq_sw_min_time = RTE_MIN(time_st->enq_sw_min_time,
6001 : : enq_sw_last_time);
6002 : 0 : time_st->enq_sw_total_time += enq_sw_last_time;
6003 : :
6004 : 0 : time_st->enq_acc_max_time = RTE_MAX(time_st->enq_acc_max_time,
6005 : : stats.acc_offload_cycles);
6006 : 0 : time_st->enq_acc_min_time = RTE_MIN(time_st->enq_acc_min_time,
6007 : : stats.acc_offload_cycles);
6008 : 0 : time_st->enq_acc_total_time += stats.acc_offload_cycles;
6009 : :
6010 : : /* give time for device to process ops */
6011 : 0 : rte_delay_us(WAIT_OFFLOAD_US);
6012 : :
6013 : : /* Start time meas for dequeue function offload latency */
6014 : : deq_start_time = rte_rdtsc_precise();
6015 : : /* Dequeue one operation */
6016 : : do {
6017 : 0 : deq += rte_bbdev_dequeue_mldts_ops(dev_id, queue_id, &ops_deq[deq], enq);
6018 : 0 : } while (unlikely(deq == 0));
6019 : :
6020 : 0 : deq_last_time = rte_rdtsc_precise() - deq_start_time;
6021 : 0 : time_st->deq_max_time = RTE_MAX(time_st->deq_max_time, deq_last_time);
6022 : 0 : time_st->deq_min_time = RTE_MIN(time_st->deq_min_time, deq_last_time);
6023 : 0 : time_st->deq_total_time += deq_last_time;
6024 : :
6025 : : /* Dequeue remaining operations if needed*/
6026 : 0 : while (burst_sz != deq)
6027 : 0 : deq += rte_bbdev_dequeue_mldts_ops(dev_id, queue_id,
6028 : 0 : &ops_deq[deq], burst_sz - deq);
6029 : :
6030 : 0 : rte_bbdev_mldts_op_free_bulk(ops_enq, deq);
6031 : 0 : dequeued += deq;
6032 : : }
6033 : :
6034 : : return i;
6035 : : }
6036 : :
6037 : : static int
6038 : 0 : offload_latency_test_dec(struct rte_mempool *mempool, struct test_buffers *bufs,
6039 : : struct rte_bbdev_dec_op *ref_op, uint16_t dev_id,
6040 : : uint16_t queue_id, const uint16_t num_to_process,
6041 : : uint16_t burst_sz, struct test_time_stats *time_st)
6042 : : {
6043 : : int i, dequeued, ret;
6044 : : struct rte_bbdev_dec_op *ops_enq[MAX_BURST], *ops_deq[MAX_BURST];
6045 : : uint64_t enq_start_time, deq_start_time;
6046 : : uint64_t enq_sw_last_time, deq_last_time;
6047 : : struct rte_bbdev_stats stats;
6048 : :
6049 : 0 : for (i = 0, dequeued = 0; dequeued < num_to_process; ++i) {
6050 : : uint16_t enq = 0, deq = 0;
6051 : :
6052 : 0 : if (unlikely(num_to_process - dequeued < burst_sz))
6053 : 0 : burst_sz = num_to_process - dequeued;
6054 : :
6055 : 0 : ret = rte_bbdev_dec_op_alloc_bulk(mempool, ops_enq, burst_sz);
6056 : 0 : TEST_ASSERT_SUCCESS(ret, "rte_bbdev_dec_op_alloc_bulk() failed");
6057 : 0 : ref_op->turbo_dec.iter_max = get_iter_max();
6058 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
6059 : 0 : copy_reference_dec_op(ops_enq, burst_sz, dequeued,
6060 : : bufs->inputs,
6061 : : bufs->hard_outputs,
6062 : : bufs->soft_outputs,
6063 : : ref_op);
6064 : :
6065 : : /* Start time meas for enqueue function offload latency */
6066 : : enq_start_time = rte_rdtsc_precise();
6067 : : do {
6068 : 0 : enq += rte_bbdev_enqueue_dec_ops(dev_id, queue_id,
6069 : 0 : &ops_enq[enq], burst_sz - enq);
6070 : 0 : } while (unlikely(burst_sz != enq));
6071 : :
6072 : 0 : ret = get_bbdev_queue_stats(dev_id, queue_id, &stats);
6073 : 0 : TEST_ASSERT_SUCCESS(ret,
6074 : : "Failed to get stats for queue (%u) of device (%u)",
6075 : : queue_id, dev_id);
6076 : :
6077 : 0 : enq_sw_last_time = rte_rdtsc_precise() - enq_start_time -
6078 : 0 : stats.acc_offload_cycles;
6079 : 0 : time_st->enq_sw_max_time = RTE_MAX(time_st->enq_sw_max_time,
6080 : : enq_sw_last_time);
6081 : 0 : time_st->enq_sw_min_time = RTE_MIN(time_st->enq_sw_min_time,
6082 : : enq_sw_last_time);
6083 : 0 : time_st->enq_sw_total_time += enq_sw_last_time;
6084 : :
6085 : 0 : time_st->enq_acc_max_time = RTE_MAX(time_st->enq_acc_max_time,
6086 : : stats.acc_offload_cycles);
6087 : 0 : time_st->enq_acc_min_time = RTE_MIN(time_st->enq_acc_min_time,
6088 : : stats.acc_offload_cycles);
6089 : 0 : time_st->enq_acc_total_time += stats.acc_offload_cycles;
6090 : :
6091 : : /* give time for device to process ops */
6092 : 0 : rte_delay_us(WAIT_OFFLOAD_US);
6093 : :
6094 : : /* Start time meas for dequeue function offload latency */
6095 : : deq_start_time = rte_rdtsc_precise();
6096 : : /* Dequeue one operation */
6097 : : do {
6098 : 0 : deq += rte_bbdev_dequeue_dec_ops(dev_id, queue_id,
6099 : 0 : &ops_deq[deq], enq);
6100 : 0 : } while (unlikely(deq == 0));
6101 : :
6102 : 0 : deq_last_time = rte_rdtsc_precise() - deq_start_time;
6103 : 0 : time_st->deq_max_time = RTE_MAX(time_st->deq_max_time,
6104 : : deq_last_time);
6105 : 0 : time_st->deq_min_time = RTE_MIN(time_st->deq_min_time,
6106 : : deq_last_time);
6107 : 0 : time_st->deq_total_time += deq_last_time;
6108 : :
6109 : : /* Dequeue remaining operations if needed*/
6110 : 0 : while (burst_sz != deq)
6111 : 0 : deq += rte_bbdev_dequeue_dec_ops(dev_id, queue_id,
6112 : 0 : &ops_deq[deq], burst_sz - deq);
6113 : :
6114 : 0 : rte_bbdev_dec_op_free_bulk(ops_enq, deq);
6115 : 0 : dequeued += deq;
6116 : : }
6117 : :
6118 : : return i;
6119 : : }
6120 : :
6121 : : static int
6122 : 0 : offload_latency_test_ldpc_dec(struct rte_mempool *mempool,
6123 : : struct test_buffers *bufs,
6124 : : struct rte_bbdev_dec_op *ref_op, uint16_t dev_id,
6125 : : uint16_t queue_id, const uint16_t num_to_process,
6126 : : uint16_t burst_sz, struct test_time_stats *time_st)
6127 : : {
6128 : : int i, dequeued, ret;
6129 : : struct rte_bbdev_dec_op *ops_enq[MAX_BURST], *ops_deq[MAX_BURST];
6130 : : uint64_t enq_start_time, deq_start_time;
6131 : : uint64_t enq_sw_last_time, deq_last_time;
6132 : : struct rte_bbdev_stats stats;
6133 : 0 : bool extDdr = ldpc_cap_flags &
6134 : : RTE_BBDEV_LDPC_INTERNAL_HARQ_MEMORY_OUT_ENABLE;
6135 : :
6136 : 0 : for (i = 0, dequeued = 0; dequeued < num_to_process; ++i) {
6137 : : uint16_t enq = 0, deq = 0;
6138 : :
6139 : 0 : if (unlikely(num_to_process - dequeued < burst_sz))
6140 : 0 : burst_sz = num_to_process - dequeued;
6141 : :
6142 : 0 : ret = rte_bbdev_dec_op_alloc_bulk(mempool, ops_enq, burst_sz);
6143 : 0 : TEST_ASSERT_SUCCESS(ret, "rte_bbdev_dec_op_alloc_bulk() failed");
6144 : 0 : ref_op->ldpc_dec.iter_max = get_iter_max();
6145 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
6146 : 0 : copy_reference_ldpc_dec_op(ops_enq, burst_sz, dequeued,
6147 : : bufs->inputs,
6148 : : bufs->hard_outputs,
6149 : : bufs->soft_outputs,
6150 : : bufs->harq_inputs,
6151 : : bufs->harq_outputs,
6152 : : ref_op);
6153 : :
6154 : 0 : if (extDdr)
6155 : 0 : preload_harq_ddr(dev_id, queue_id, ops_enq,
6156 : : burst_sz, true);
6157 : :
6158 : : /* Start time meas for enqueue function offload latency */
6159 : : enq_start_time = rte_rdtsc_precise();
6160 : : do {
6161 : 0 : enq += rte_bbdev_enqueue_ldpc_dec_ops(dev_id, queue_id,
6162 : 0 : &ops_enq[enq], burst_sz - enq);
6163 : 0 : } while (unlikely(burst_sz != enq));
6164 : :
6165 : 0 : enq_sw_last_time = rte_rdtsc_precise() - enq_start_time;
6166 : 0 : ret = get_bbdev_queue_stats(dev_id, queue_id, &stats);
6167 : 0 : TEST_ASSERT_SUCCESS(ret,
6168 : : "Failed to get stats for queue (%u) of device (%u)",
6169 : : queue_id, dev_id);
6170 : :
6171 : 0 : enq_sw_last_time -= stats.acc_offload_cycles;
6172 : 0 : time_st->enq_sw_max_time = RTE_MAX(time_st->enq_sw_max_time,
6173 : : enq_sw_last_time);
6174 : 0 : time_st->enq_sw_min_time = RTE_MIN(time_st->enq_sw_min_time,
6175 : : enq_sw_last_time);
6176 : 0 : time_st->enq_sw_total_time += enq_sw_last_time;
6177 : :
6178 : 0 : time_st->enq_acc_max_time = RTE_MAX(time_st->enq_acc_max_time,
6179 : : stats.acc_offload_cycles);
6180 : 0 : time_st->enq_acc_min_time = RTE_MIN(time_st->enq_acc_min_time,
6181 : : stats.acc_offload_cycles);
6182 : 0 : time_st->enq_acc_total_time += stats.acc_offload_cycles;
6183 : :
6184 : : /* give time for device to process ops */
6185 : 0 : rte_delay_us(WAIT_OFFLOAD_US);
6186 : :
6187 : : /* Start time meas for dequeue function offload latency */
6188 : : deq_start_time = rte_rdtsc_precise();
6189 : : /* Dequeue one operation */
6190 : : do {
6191 : 0 : deq += rte_bbdev_dequeue_ldpc_dec_ops(dev_id, queue_id,
6192 : 0 : &ops_deq[deq], enq);
6193 : 0 : } while (unlikely(deq == 0));
6194 : :
6195 : 0 : deq_last_time = rte_rdtsc_precise() - deq_start_time;
6196 : 0 : time_st->deq_max_time = RTE_MAX(time_st->deq_max_time,
6197 : : deq_last_time);
6198 : 0 : time_st->deq_min_time = RTE_MIN(time_st->deq_min_time,
6199 : : deq_last_time);
6200 : 0 : time_st->deq_total_time += deq_last_time;
6201 : :
6202 : : /* Dequeue remaining operations if needed*/
6203 : 0 : while (burst_sz != deq)
6204 : 0 : deq += rte_bbdev_dequeue_ldpc_dec_ops(dev_id, queue_id,
6205 : 0 : &ops_deq[deq], burst_sz - deq);
6206 : :
6207 : 0 : if (extDdr) {
6208 : : /* Read loopback is not thread safe */
6209 : 0 : retrieve_harq_ddr(dev_id, queue_id, ops_enq, burst_sz);
6210 : : }
6211 : :
6212 : 0 : rte_bbdev_dec_op_free_bulk(ops_enq, deq);
6213 : 0 : dequeued += deq;
6214 : : }
6215 : :
6216 : : return i;
6217 : : }
6218 : :
6219 : : static int
6220 : 0 : offload_latency_test_enc(struct rte_mempool *mempool, struct test_buffers *bufs,
6221 : : struct rte_bbdev_enc_op *ref_op, uint16_t dev_id,
6222 : : uint16_t queue_id, const uint16_t num_to_process,
6223 : : uint16_t burst_sz, struct test_time_stats *time_st)
6224 : : {
6225 : : int i, dequeued, ret;
6226 : : struct rte_bbdev_enc_op *ops_enq[MAX_BURST], *ops_deq[MAX_BURST];
6227 : : uint64_t enq_start_time, deq_start_time;
6228 : : uint64_t enq_sw_last_time, deq_last_time;
6229 : : struct rte_bbdev_stats stats;
6230 : :
6231 : 0 : for (i = 0, dequeued = 0; dequeued < num_to_process; ++i) {
6232 : : uint16_t enq = 0, deq = 0;
6233 : :
6234 : 0 : if (unlikely(num_to_process - dequeued < burst_sz))
6235 : 0 : burst_sz = num_to_process - dequeued;
6236 : :
6237 : 0 : ret = rte_bbdev_enc_op_alloc_bulk(mempool, ops_enq, burst_sz);
6238 : 0 : TEST_ASSERT_SUCCESS(ret, "rte_bbdev_enc_op_alloc_bulk() failed");
6239 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
6240 : 0 : copy_reference_enc_op(ops_enq, burst_sz, dequeued,
6241 : : bufs->inputs,
6242 : : bufs->hard_outputs,
6243 : : ref_op);
6244 : :
6245 : : /* Start time meas for enqueue function offload latency */
6246 : : enq_start_time = rte_rdtsc_precise();
6247 : : do {
6248 : 0 : enq += rte_bbdev_enqueue_enc_ops(dev_id, queue_id,
6249 : 0 : &ops_enq[enq], burst_sz - enq);
6250 : 0 : } while (unlikely(burst_sz != enq));
6251 : :
6252 : 0 : enq_sw_last_time = rte_rdtsc_precise() - enq_start_time;
6253 : :
6254 : 0 : ret = get_bbdev_queue_stats(dev_id, queue_id, &stats);
6255 : 0 : TEST_ASSERT_SUCCESS(ret,
6256 : : "Failed to get stats for queue (%u) of device (%u)",
6257 : : queue_id, dev_id);
6258 : 0 : enq_sw_last_time -= stats.acc_offload_cycles;
6259 : 0 : time_st->enq_sw_max_time = RTE_MAX(time_st->enq_sw_max_time,
6260 : : enq_sw_last_time);
6261 : 0 : time_st->enq_sw_min_time = RTE_MIN(time_st->enq_sw_min_time,
6262 : : enq_sw_last_time);
6263 : 0 : time_st->enq_sw_total_time += enq_sw_last_time;
6264 : :
6265 : 0 : time_st->enq_acc_max_time = RTE_MAX(time_st->enq_acc_max_time,
6266 : : stats.acc_offload_cycles);
6267 : 0 : time_st->enq_acc_min_time = RTE_MIN(time_st->enq_acc_min_time,
6268 : : stats.acc_offload_cycles);
6269 : 0 : time_st->enq_acc_total_time += stats.acc_offload_cycles;
6270 : :
6271 : : /* give time for device to process ops */
6272 : 0 : rte_delay_us(WAIT_OFFLOAD_US);
6273 : :
6274 : : /* Start time meas for dequeue function offload latency */
6275 : : deq_start_time = rte_rdtsc_precise();
6276 : : /* Dequeue one operation */
6277 : : do {
6278 : 0 : deq += rte_bbdev_dequeue_enc_ops(dev_id, queue_id,
6279 : 0 : &ops_deq[deq], enq);
6280 : 0 : } while (unlikely(deq == 0));
6281 : :
6282 : 0 : deq_last_time = rte_rdtsc_precise() - deq_start_time;
6283 : 0 : time_st->deq_max_time = RTE_MAX(time_st->deq_max_time,
6284 : : deq_last_time);
6285 : 0 : time_st->deq_min_time = RTE_MIN(time_st->deq_min_time,
6286 : : deq_last_time);
6287 : 0 : time_st->deq_total_time += deq_last_time;
6288 : :
6289 : 0 : while (burst_sz != deq)
6290 : 0 : deq += rte_bbdev_dequeue_enc_ops(dev_id, queue_id,
6291 : 0 : &ops_deq[deq], burst_sz - deq);
6292 : :
6293 : 0 : rte_bbdev_enc_op_free_bulk(ops_enq, deq);
6294 : 0 : dequeued += deq;
6295 : : }
6296 : :
6297 : : return i;
6298 : : }
6299 : :
6300 : : static int
6301 : 0 : offload_latency_test_ldpc_enc(struct rte_mempool *mempool,
6302 : : struct test_buffers *bufs,
6303 : : struct rte_bbdev_enc_op *ref_op, uint16_t dev_id,
6304 : : uint16_t queue_id, const uint16_t num_to_process,
6305 : : uint16_t burst_sz, struct test_time_stats *time_st)
6306 : : {
6307 : : int i, dequeued, ret;
6308 : : struct rte_bbdev_enc_op *ops_enq[MAX_BURST], *ops_deq[MAX_BURST];
6309 : : uint64_t enq_start_time, deq_start_time;
6310 : : uint64_t enq_sw_last_time, deq_last_time;
6311 : : struct rte_bbdev_stats stats;
6312 : :
6313 : 0 : for (i = 0, dequeued = 0; dequeued < num_to_process; ++i) {
6314 : : uint16_t enq = 0, deq = 0;
6315 : :
6316 : 0 : if (unlikely(num_to_process - dequeued < burst_sz))
6317 : 0 : burst_sz = num_to_process - dequeued;
6318 : :
6319 : 0 : ret = rte_bbdev_enc_op_alloc_bulk(mempool, ops_enq, burst_sz);
6320 : 0 : TEST_ASSERT_SUCCESS(ret, "rte_bbdev_enc_op_alloc_bulk() failed");
6321 : 0 : if (test_vector.op_type != RTE_BBDEV_OP_NONE)
6322 : 0 : copy_reference_ldpc_enc_op(ops_enq, burst_sz, dequeued,
6323 : : bufs->inputs,
6324 : : bufs->hard_outputs,
6325 : : ref_op);
6326 : :
6327 : : /* Start time meas for enqueue function offload latency */
6328 : : enq_start_time = rte_rdtsc_precise();
6329 : : do {
6330 : 0 : enq += rte_bbdev_enqueue_ldpc_enc_ops(dev_id, queue_id,
6331 : 0 : &ops_enq[enq], burst_sz - enq);
6332 : 0 : } while (unlikely(burst_sz != enq));
6333 : :
6334 : 0 : enq_sw_last_time = rte_rdtsc_precise() - enq_start_time;
6335 : 0 : ret = get_bbdev_queue_stats(dev_id, queue_id, &stats);
6336 : 0 : TEST_ASSERT_SUCCESS(ret,
6337 : : "Failed to get stats for queue (%u) of device (%u)",
6338 : : queue_id, dev_id);
6339 : :
6340 : 0 : enq_sw_last_time -= stats.acc_offload_cycles;
6341 : 0 : time_st->enq_sw_max_time = RTE_MAX(time_st->enq_sw_max_time,
6342 : : enq_sw_last_time);
6343 : 0 : time_st->enq_sw_min_time = RTE_MIN(time_st->enq_sw_min_time,
6344 : : enq_sw_last_time);
6345 : 0 : time_st->enq_sw_total_time += enq_sw_last_time;
6346 : :
6347 : 0 : time_st->enq_acc_max_time = RTE_MAX(time_st->enq_acc_max_time,
6348 : : stats.acc_offload_cycles);
6349 : 0 : time_st->enq_acc_min_time = RTE_MIN(time_st->enq_acc_min_time,
6350 : : stats.acc_offload_cycles);
6351 : 0 : time_st->enq_acc_total_time += stats.acc_offload_cycles;
6352 : :
6353 : : /* give time for device to process ops */
6354 : 0 : rte_delay_us(WAIT_OFFLOAD_US);
6355 : :
6356 : : /* Start time meas for dequeue function offload latency */
6357 : : deq_start_time = rte_rdtsc_precise();
6358 : : /* Dequeue one operation */
6359 : : do {
6360 : 0 : deq += rte_bbdev_dequeue_ldpc_enc_ops(dev_id, queue_id,
6361 : 0 : &ops_deq[deq], enq);
6362 : 0 : } while (unlikely(deq == 0));
6363 : :
6364 : 0 : deq_last_time = rte_rdtsc_precise() - deq_start_time;
6365 : 0 : time_st->deq_max_time = RTE_MAX(time_st->deq_max_time,
6366 : : deq_last_time);
6367 : 0 : time_st->deq_min_time = RTE_MIN(time_st->deq_min_time,
6368 : : deq_last_time);
6369 : 0 : time_st->deq_total_time += deq_last_time;
6370 : :
6371 : 0 : while (burst_sz != deq)
6372 : 0 : deq += rte_bbdev_dequeue_ldpc_enc_ops(dev_id, queue_id,
6373 : 0 : &ops_deq[deq], burst_sz - deq);
6374 : :
6375 : 0 : rte_bbdev_enc_op_free_bulk(ops_enq, deq);
6376 : 0 : dequeued += deq;
6377 : : }
6378 : :
6379 : : return i;
6380 : : }
6381 : :
6382 : : static int
6383 : 0 : offload_cost_test(struct active_device *ad,
6384 : : struct test_op_params *op_params)
6385 : : {
6386 : : int iter, ret;
6387 : 0 : uint16_t burst_sz = op_params->burst_sz;
6388 : 0 : const uint16_t num_to_process = op_params->num_to_process;
6389 : 0 : const enum rte_bbdev_op_type op_type = test_vector.op_type;
6390 : 0 : const uint16_t queue_id = ad->queue_ids[0];
6391 : : struct test_buffers *bufs = NULL;
6392 : : struct rte_bbdev_info info;
6393 : : const char *op_type_str;
6394 : : struct test_time_stats time_st;
6395 : :
6396 : : memset(&time_st, 0, sizeof(struct test_time_stats));
6397 : 0 : time_st.enq_sw_min_time = UINT64_MAX;
6398 : 0 : time_st.enq_acc_min_time = UINT64_MAX;
6399 : 0 : time_st.deq_min_time = UINT64_MAX;
6400 : :
6401 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
6402 : : "BURST_SIZE should be <= %u", MAX_BURST);
6403 : :
6404 : 0 : rte_bbdev_info_get(ad->dev_id, &info);
6405 : 0 : bufs = &op_params->q_bufs[GET_SOCKET(info.socket_id)][queue_id];
6406 : :
6407 : 0 : op_type_str = rte_bbdev_op_type_str(op_type);
6408 : 0 : TEST_ASSERT_NOT_NULL(op_type_str, "Invalid op type: %u", op_type);
6409 : :
6410 : : printf("+ ------------------------------------------------------- +\n");
6411 : 0 : printf("== test: offload latency test\ndev: %s, burst size: %u, num ops: %u, op type: %s\n",
6412 : : info.dev_name, burst_sz, num_to_process, op_type_str);
6413 : :
6414 : 0 : if (op_type == RTE_BBDEV_OP_TURBO_DEC)
6415 : 0 : iter = offload_latency_test_dec(op_params->mp, bufs,
6416 : 0 : op_params->ref_dec_op, ad->dev_id, queue_id,
6417 : : num_to_process, burst_sz, &time_st);
6418 : : else if (op_type == RTE_BBDEV_OP_TURBO_ENC)
6419 : 0 : iter = offload_latency_test_enc(op_params->mp, bufs,
6420 : 0 : op_params->ref_enc_op, ad->dev_id, queue_id,
6421 : : num_to_process, burst_sz, &time_st);
6422 : : else if (op_type == RTE_BBDEV_OP_LDPC_ENC)
6423 : 0 : iter = offload_latency_test_ldpc_enc(op_params->mp, bufs,
6424 : 0 : op_params->ref_enc_op, ad->dev_id, queue_id,
6425 : : num_to_process, burst_sz, &time_st);
6426 : : else if (op_type == RTE_BBDEV_OP_LDPC_DEC)
6427 : 0 : iter = offload_latency_test_ldpc_dec(op_params->mp, bufs,
6428 : 0 : op_params->ref_dec_op, ad->dev_id, queue_id,
6429 : : num_to_process, burst_sz, &time_st);
6430 : : else if (op_type == RTE_BBDEV_OP_FFT)
6431 : 0 : iter = offload_latency_test_fft(op_params->mp, bufs,
6432 : 0 : op_params->ref_fft_op, ad->dev_id, queue_id,
6433 : : num_to_process, burst_sz, &time_st);
6434 : : else if (op_type == RTE_BBDEV_OP_MLDTS)
6435 : 0 : iter = offload_latency_test_mldts(op_params->mp, bufs,
6436 : 0 : op_params->ref_mldts_op, ad->dev_id, queue_id,
6437 : : num_to_process, burst_sz, &time_st);
6438 : : else
6439 : 0 : iter = offload_latency_test_enc(op_params->mp, bufs,
6440 : 0 : op_params->ref_enc_op, ad->dev_id, queue_id,
6441 : : num_to_process, burst_sz, &time_st);
6442 : :
6443 : 0 : if (iter <= 0)
6444 : : return TEST_FAILED;
6445 : :
6446 : 0 : printf("Enqueue driver offload cost latency:\n"
6447 : : "\tavg: %lg cycles, %lg us\n"
6448 : : "\tmin: %lg cycles, %lg us\n"
6449 : : "\tmax: %lg cycles, %lg us\n"
6450 : : "Enqueue accelerator offload cost latency:\n"
6451 : : "\tavg: %lg cycles, %lg us\n"
6452 : : "\tmin: %lg cycles, %lg us\n"
6453 : : "\tmax: %lg cycles, %lg us\n",
6454 : 0 : (double)time_st.enq_sw_total_time / (double)iter,
6455 : 0 : (double)(time_st.enq_sw_total_time * 1000000) /
6456 : 0 : (double)iter / (double)rte_get_tsc_hz(),
6457 : 0 : (double)time_st.enq_sw_min_time,
6458 : 0 : (double)(time_st.enq_sw_min_time * 1000000) /
6459 : 0 : rte_get_tsc_hz(), (double)time_st.enq_sw_max_time,
6460 : 0 : (double)(time_st.enq_sw_max_time * 1000000) /
6461 : 0 : rte_get_tsc_hz(), (double)time_st.enq_acc_total_time /
6462 : : (double)iter,
6463 : 0 : (double)(time_st.enq_acc_total_time * 1000000) /
6464 : 0 : (double)iter / (double)rte_get_tsc_hz(),
6465 : 0 : (double)time_st.enq_acc_min_time,
6466 : 0 : (double)(time_st.enq_acc_min_time * 1000000) /
6467 : 0 : rte_get_tsc_hz(), (double)time_st.enq_acc_max_time,
6468 : 0 : (double)(time_st.enq_acc_max_time * 1000000) /
6469 : 0 : rte_get_tsc_hz());
6470 : :
6471 : 0 : printf("Dequeue offload cost latency - one op:\n"
6472 : : "\tavg: %lg cycles, %lg us\n"
6473 : : "\tmin: %lg cycles, %lg us\n"
6474 : : "\tmax: %lg cycles, %lg us\n",
6475 : 0 : (double)time_st.deq_total_time / (double)iter,
6476 : 0 : (double)(time_st.deq_total_time * 1000000) /
6477 : 0 : (double)iter / (double)rte_get_tsc_hz(),
6478 : 0 : (double)time_st.deq_min_time,
6479 : 0 : (double)(time_st.deq_min_time * 1000000) /
6480 : 0 : rte_get_tsc_hz(), (double)time_st.deq_max_time,
6481 : 0 : (double)(time_st.deq_max_time * 1000000) /
6482 : 0 : rte_get_tsc_hz());
6483 : :
6484 : 0 : struct rte_bbdev_stats stats = {0};
6485 : 0 : ret = get_bbdev_queue_stats(ad->dev_id, queue_id, &stats);
6486 : 0 : TEST_ASSERT_SUCCESS(ret,
6487 : : "Failed to get stats for queue (%u) of device (%u)",
6488 : : queue_id, ad->dev_id);
6489 : 0 : if (stats.enqueue_warn_count > 0)
6490 : : printf("Warning reported on the queue : %10"PRIu64"\n",
6491 : : stats.enqueue_warn_count);
6492 : 0 : if (op_type != RTE_BBDEV_OP_LDPC_DEC) {
6493 : 0 : TEST_ASSERT_SUCCESS(stats.enqueued_count != num_to_process,
6494 : : "Mismatch in enqueue count %10"PRIu64" %d",
6495 : : stats.enqueued_count, num_to_process);
6496 : 0 : TEST_ASSERT_SUCCESS(stats.dequeued_count != num_to_process,
6497 : : "Mismatch in dequeue count %10"PRIu64" %d",
6498 : : stats.dequeued_count, num_to_process);
6499 : : }
6500 : 0 : TEST_ASSERT_SUCCESS(stats.enqueue_err_count != 0,
6501 : : "Enqueue count Error %10"PRIu64"",
6502 : : stats.enqueue_err_count);
6503 : 0 : TEST_ASSERT_SUCCESS(stats.dequeue_err_count != 0,
6504 : : "Dequeue count Error (%10"PRIu64"",
6505 : : stats.dequeue_err_count);
6506 : :
6507 : : return TEST_SUCCESS;
6508 : : }
6509 : :
6510 : : static int
6511 : 0 : offload_latency_empty_q_test_dec(uint16_t dev_id, uint16_t queue_id,
6512 : : const uint16_t num_to_process, uint16_t burst_sz,
6513 : : uint64_t *deq_total_time, uint64_t *deq_min_time,
6514 : : uint64_t *deq_max_time, const enum rte_bbdev_op_type op_type)
6515 : : {
6516 : : int i, deq_total;
6517 : : struct rte_bbdev_dec_op *ops[MAX_BURST];
6518 : : uint64_t deq_start_time, deq_last_time;
6519 : :
6520 : : /* Test deq offload latency from an empty queue */
6521 : :
6522 : 0 : for (i = 0, deq_total = 0; deq_total < num_to_process;
6523 : 0 : ++i, deq_total += burst_sz) {
6524 : : deq_start_time = rte_rdtsc_precise();
6525 : :
6526 : 0 : if (unlikely(num_to_process - deq_total < burst_sz))
6527 : 0 : burst_sz = num_to_process - deq_total;
6528 : 0 : if (op_type == RTE_BBDEV_OP_LDPC_DEC)
6529 : 0 : rte_bbdev_dequeue_ldpc_dec_ops(dev_id, queue_id, ops,
6530 : : burst_sz);
6531 : : else
6532 : 0 : rte_bbdev_dequeue_dec_ops(dev_id, queue_id, ops,
6533 : : burst_sz);
6534 : :
6535 : 0 : deq_last_time = rte_rdtsc_precise() - deq_start_time;
6536 : 0 : *deq_max_time = RTE_MAX(*deq_max_time, deq_last_time);
6537 : 0 : *deq_min_time = RTE_MIN(*deq_min_time, deq_last_time);
6538 : 0 : *deq_total_time += deq_last_time;
6539 : : }
6540 : :
6541 : 0 : return i;
6542 : : }
6543 : :
6544 : : static int
6545 : 0 : offload_latency_empty_q_test_enc(uint16_t dev_id, uint16_t queue_id,
6546 : : const uint16_t num_to_process, uint16_t burst_sz,
6547 : : uint64_t *deq_total_time, uint64_t *deq_min_time,
6548 : : uint64_t *deq_max_time, const enum rte_bbdev_op_type op_type)
6549 : : {
6550 : : int i, deq_total;
6551 : : struct rte_bbdev_enc_op *ops[MAX_BURST];
6552 : : uint64_t deq_start_time, deq_last_time;
6553 : :
6554 : : /* Test deq offload latency from an empty queue */
6555 : 0 : for (i = 0, deq_total = 0; deq_total < num_to_process;
6556 : 0 : ++i, deq_total += burst_sz) {
6557 : : deq_start_time = rte_rdtsc_precise();
6558 : :
6559 : 0 : if (unlikely(num_to_process - deq_total < burst_sz))
6560 : 0 : burst_sz = num_to_process - deq_total;
6561 : 0 : if (op_type == RTE_BBDEV_OP_LDPC_ENC)
6562 : 0 : rte_bbdev_dequeue_ldpc_enc_ops(dev_id, queue_id, ops,
6563 : : burst_sz);
6564 : : else
6565 : 0 : rte_bbdev_dequeue_enc_ops(dev_id, queue_id, ops,
6566 : : burst_sz);
6567 : :
6568 : 0 : deq_last_time = rte_rdtsc_precise() - deq_start_time;
6569 : 0 : *deq_max_time = RTE_MAX(*deq_max_time, deq_last_time);
6570 : 0 : *deq_min_time = RTE_MIN(*deq_min_time, deq_last_time);
6571 : 0 : *deq_total_time += deq_last_time;
6572 : : }
6573 : :
6574 : 0 : return i;
6575 : : }
6576 : :
6577 : : static int
6578 : 0 : offload_latency_empty_q_test(struct active_device *ad,
6579 : : struct test_op_params *op_params)
6580 : : {
6581 : : int iter;
6582 : : uint64_t deq_total_time, deq_min_time, deq_max_time;
6583 : 0 : uint16_t burst_sz = op_params->burst_sz;
6584 : 0 : const uint16_t num_to_process = op_params->num_to_process;
6585 : 0 : const enum rte_bbdev_op_type op_type = test_vector.op_type;
6586 : 0 : const uint16_t queue_id = ad->queue_ids[0];
6587 : : struct rte_bbdev_info info;
6588 : : const char *op_type_str;
6589 : :
6590 : 0 : deq_total_time = deq_max_time = 0;
6591 : 0 : deq_min_time = UINT64_MAX;
6592 : :
6593 : 0 : TEST_ASSERT_SUCCESS((burst_sz > MAX_BURST),
6594 : : "BURST_SIZE should be <= %u", MAX_BURST);
6595 : :
6596 : 0 : rte_bbdev_info_get(ad->dev_id, &info);
6597 : :
6598 : 0 : op_type_str = rte_bbdev_op_type_str(op_type);
6599 : 0 : TEST_ASSERT_NOT_NULL(op_type_str, "Invalid op type: %u", op_type);
6600 : :
6601 : : printf("+ ------------------------------------------------------- +\n");
6602 : 0 : printf("== test: offload latency empty dequeue\ndev: %s, burst size: %u, num ops: %u, op type: %s\n",
6603 : : info.dev_name, burst_sz, num_to_process, op_type_str);
6604 : :
6605 : 0 : if (op_type == RTE_BBDEV_OP_TURBO_DEC ||
6606 : 0 : op_type == RTE_BBDEV_OP_LDPC_DEC)
6607 : 0 : iter = offload_latency_empty_q_test_dec(ad->dev_id, queue_id,
6608 : : num_to_process, burst_sz, &deq_total_time,
6609 : : &deq_min_time, &deq_max_time, op_type);
6610 : : else
6611 : 0 : iter = offload_latency_empty_q_test_enc(ad->dev_id, queue_id,
6612 : : num_to_process, burst_sz, &deq_total_time,
6613 : : &deq_min_time, &deq_max_time, op_type);
6614 : :
6615 : 0 : if (iter <= 0)
6616 : : return TEST_FAILED;
6617 : :
6618 : 0 : printf("Empty dequeue offload:\n"
6619 : : "\tavg: %lg cycles, %lg us\n"
6620 : : "\tmin: %lg cycles, %lg us\n"
6621 : : "\tmax: %lg cycles, %lg us\n",
6622 : 0 : (double)deq_total_time / (double)iter,
6623 : 0 : (double)(deq_total_time * 1000000) / (double)iter /
6624 : 0 : (double)rte_get_tsc_hz(), (double)deq_min_time,
6625 : 0 : (double)(deq_min_time * 1000000) / rte_get_tsc_hz(),
6626 : 0 : (double)deq_max_time, (double)(deq_max_time * 1000000) /
6627 : 0 : rte_get_tsc_hz());
6628 : :
6629 : 0 : return TEST_SUCCESS;
6630 : : }
6631 : :
6632 : : static int
6633 : 0 : bler_tc(void)
6634 : : {
6635 : 0 : return run_test_case(bler_test);
6636 : : }
6637 : :
6638 : : static int
6639 : 0 : throughput_tc(void)
6640 : : {
6641 : 0 : return run_test_case(throughput_test);
6642 : : }
6643 : :
6644 : : static int
6645 : 0 : offload_cost_tc(void)
6646 : : {
6647 : 0 : return run_test_case(offload_cost_test);
6648 : : }
6649 : :
6650 : : static int
6651 : 0 : offload_latency_empty_q_tc(void)
6652 : : {
6653 : 0 : return run_test_case(offload_latency_empty_q_test);
6654 : : }
6655 : :
6656 : : static int
6657 : 0 : latency_tc(void)
6658 : : {
6659 : 0 : return run_test_case(latency_test);
6660 : : }
6661 : :
6662 : : static int
6663 : 0 : validation_tc(void)
6664 : : {
6665 : 0 : return run_test_case(validation_test);
6666 : : }
6667 : :
6668 : : static int
6669 : 0 : interrupt_tc(void)
6670 : : {
6671 : 0 : return run_test_case(throughput_test);
6672 : : }
6673 : :
6674 : : static struct unit_test_suite bbdev_bler_testsuite = {
6675 : : .suite_name = "BBdev BLER Tests",
6676 : : .setup = testsuite_setup,
6677 : : .teardown = testsuite_teardown,
6678 : : .unit_test_cases = {
6679 : : TEST_CASE_ST(ut_setup, ut_teardown, bler_tc),
6680 : : TEST_CASES_END() /**< NULL terminate unit test array */
6681 : : }
6682 : : };
6683 : :
6684 : : static struct unit_test_suite bbdev_throughput_testsuite = {
6685 : : .suite_name = "BBdev Throughput Tests",
6686 : : .setup = testsuite_setup,
6687 : : .teardown = testsuite_teardown,
6688 : : .unit_test_cases = {
6689 : : TEST_CASE_ST(ut_setup, ut_teardown, throughput_tc),
6690 : : TEST_CASES_END() /**< NULL terminate unit test array */
6691 : : }
6692 : : };
6693 : :
6694 : : static struct unit_test_suite bbdev_validation_testsuite = {
6695 : : .suite_name = "BBdev Validation Tests",
6696 : : .setup = testsuite_setup,
6697 : : .teardown = testsuite_teardown,
6698 : : .unit_test_cases = {
6699 : : TEST_CASE_ST(ut_setup, ut_teardown, validation_tc),
6700 : : TEST_CASES_END() /**< NULL terminate unit test array */
6701 : : }
6702 : : };
6703 : :
6704 : : static struct unit_test_suite bbdev_latency_testsuite = {
6705 : : .suite_name = "BBdev Latency Tests",
6706 : : .setup = testsuite_setup,
6707 : : .teardown = testsuite_teardown,
6708 : : .unit_test_cases = {
6709 : : TEST_CASE_ST(ut_setup, ut_teardown, latency_tc),
6710 : : TEST_CASES_END() /**< NULL terminate unit test array */
6711 : : }
6712 : : };
6713 : :
6714 : : static struct unit_test_suite bbdev_offload_cost_testsuite = {
6715 : : .suite_name = "BBdev Offload Cost Tests",
6716 : : .setup = testsuite_setup,
6717 : : .teardown = testsuite_teardown,
6718 : : .unit_test_cases = {
6719 : : TEST_CASE_ST(ut_setup, ut_teardown, offload_cost_tc),
6720 : : TEST_CASE_ST(ut_setup, ut_teardown, offload_latency_empty_q_tc),
6721 : : TEST_CASES_END() /**< NULL terminate unit test array */
6722 : : }
6723 : : };
6724 : :
6725 : : static struct unit_test_suite bbdev_interrupt_testsuite = {
6726 : : .suite_name = "BBdev Interrupt Tests",
6727 : : .setup = interrupt_testsuite_setup,
6728 : : .teardown = testsuite_teardown,
6729 : : .unit_test_cases = {
6730 : : TEST_CASE_ST(ut_setup, ut_teardown, interrupt_tc),
6731 : : TEST_CASES_END() /**< NULL terminate unit test array */
6732 : : }
6733 : : };
6734 : :
6735 : 0 : REGISTER_TEST_COMMAND(bler, bbdev_bler_testsuite);
6736 : 0 : REGISTER_TEST_COMMAND(throughput, bbdev_throughput_testsuite);
6737 : 0 : REGISTER_TEST_COMMAND(validation, bbdev_validation_testsuite);
6738 : 0 : REGISTER_TEST_COMMAND(latency, bbdev_latency_testsuite);
6739 : 0 : REGISTER_TEST_COMMAND(offload, bbdev_offload_cost_testsuite);
6740 : 0 : REGISTER_TEST_COMMAND(interrupt, bbdev_interrupt_testsuite);
|