Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2017 Cavium, Inc
3 : : */
4 : :
5 : : #include <stdio.h>
6 : : #include <stdlib.h>
7 : : #include <string.h>
8 : : #include <inttypes.h>
9 : : #include <getopt.h>
10 : :
11 : : #include <rte_string_fns.h>
12 : : #include <rte_common.h>
13 : : #include <rte_eventdev.h>
14 : : #include <rte_lcore.h>
15 : :
16 : : #include "evt_options.h"
17 : : #include "evt_test.h"
18 : : #include "parser.h"
19 : :
20 : : void
21 : 0 : evt_options_default(struct evt_options *opt)
22 : : {
23 : : memset(opt, 0, sizeof(*opt));
24 : 0 : opt->verbose_level = 1; /* Enable minimal prints */
25 : : opt->dev_id = 0;
26 : 0 : strncpy(opt->test_name, "order_queue", EVT_TEST_NAME_MAX_LEN);
27 : 0 : opt->nb_flows = 1024;
28 : 0 : opt->socket_id = SOCKET_ID_ANY;
29 : 0 : opt->pool_sz = 16 * 1024;
30 : : opt->prod_enq_burst_sz = 0;
31 : 0 : opt->wkr_deq_dep = 16;
32 : 0 : opt->nb_pkts = (1ULL << 26); /* do ~64M packets */
33 : 0 : opt->nb_timers = 1E8;
34 : 0 : opt->nb_timer_adptrs = 1;
35 : 0 : opt->timer_tick_nsec = 1E3; /* 1000ns ~ 1us */
36 : 0 : opt->max_tmo_nsec = 1E5; /* 100000ns ~100us */
37 : 0 : opt->expiry_nsec = 1E4; /* 10000ns ~10us */
38 : 0 : opt->prod_type = EVT_PROD_TYPE_SYNT;
39 : 0 : opt->eth_queues = 1;
40 : 0 : opt->vector_size = 64;
41 : 0 : opt->vector_tmo_nsec = 100E3;
42 : 0 : opt->crypto_op_type = RTE_CRYPTO_OP_TYPE_SYMMETRIC;
43 : 0 : opt->crypto_cipher_alg = RTE_CRYPTO_CIPHER_NULL;
44 : : opt->crypto_cipher_key_sz = 0;
45 : 0 : }
46 : :
47 : : typedef int (*option_parser_t)(struct evt_options *opt,
48 : : const char *arg);
49 : :
50 : : struct long_opt_parser {
51 : : const char *lgopt_name;
52 : : option_parser_t parser_fn;
53 : : };
54 : :
55 : : static int
56 : 0 : evt_parse_nb_flows(struct evt_options *opt, const char *arg)
57 : : {
58 : : int ret;
59 : :
60 : 0 : ret = parser_read_uint32(&(opt->nb_flows), arg);
61 : :
62 : 0 : return ret;
63 : : }
64 : :
65 : : static int
66 : 0 : evt_parse_dev_id(struct evt_options *opt, const char *arg)
67 : : {
68 : : int ret;
69 : :
70 : 0 : ret = parser_read_uint8(&(opt->dev_id), arg);
71 : :
72 : 0 : return ret;
73 : : }
74 : :
75 : : static int
76 : 0 : evt_parse_verbose(struct evt_options *opt, const char *arg __rte_unused)
77 : : {
78 : 0 : opt->verbose_level = atoi(arg);
79 : 0 : return 0;
80 : : }
81 : :
82 : : static int
83 : 0 : evt_parse_fwd_latency(struct evt_options *opt, const char *arg __rte_unused)
84 : : {
85 : 0 : opt->fwd_latency = 1;
86 : 0 : return 0;
87 : : }
88 : :
89 : : static int
90 : 0 : evt_parse_queue_priority(struct evt_options *opt, const char *arg __rte_unused)
91 : : {
92 : 0 : opt->q_priority = 1;
93 : 0 : return 0;
94 : : }
95 : :
96 : : static int
97 : 0 : evt_parse_deq_tmo_nsec(struct evt_options *opt, const char *arg)
98 : : {
99 : : int ret;
100 : :
101 : 0 : ret = parser_read_uint32(&(opt->deq_tmo_nsec), arg);
102 : :
103 : 0 : return ret;
104 : : }
105 : :
106 : : static int
107 : 0 : evt_parse_eth_prod_type(struct evt_options *opt, const char *arg __rte_unused)
108 : : {
109 : 0 : opt->prod_type = EVT_PROD_TYPE_ETH_RX_ADPTR;
110 : 0 : return 0;
111 : : }
112 : :
113 : : static int
114 : 0 : evt_parse_tx_first(struct evt_options *opt, const char *arg __rte_unused)
115 : : {
116 : : int ret;
117 : :
118 : 0 : ret = parser_read_uint32(&(opt->tx_first), arg);
119 : :
120 : 0 : return ret;
121 : : }
122 : :
123 : : static int
124 : 0 : evt_parse_tx_pkt_sz(struct evt_options *opt, const char *arg __rte_unused)
125 : : {
126 : : int ret;
127 : :
128 : 0 : ret = parser_read_uint16(&(opt->tx_pkt_sz), arg);
129 : :
130 : 0 : return ret;
131 : : }
132 : :
133 : : static int
134 : 0 : evt_parse_preschedule(struct evt_options *opt, const char *arg __rte_unused)
135 : : {
136 : : int ret;
137 : :
138 : 0 : ret = parser_read_uint8(&(opt->preschedule), arg);
139 : 0 : opt->preschedule_opted = 1;
140 : :
141 : 0 : return ret;
142 : : }
143 : :
144 : : static int
145 : 0 : evt_parse_timer_prod_type(struct evt_options *opt, const char *arg __rte_unused)
146 : : {
147 : 0 : opt->prod_type = EVT_PROD_TYPE_EVENT_TIMER_ADPTR;
148 : 0 : return 0;
149 : : }
150 : :
151 : : static int
152 : 0 : evt_parse_timer_prod_type_burst(struct evt_options *opt,
153 : : const char *arg __rte_unused)
154 : : {
155 : 0 : opt->prod_type = EVT_PROD_TYPE_EVENT_TIMER_ADPTR;
156 : 0 : opt->timdev_use_burst = 1;
157 : 0 : return 0;
158 : : }
159 : :
160 : : static int
161 : 0 : evt_parse_dma_prod_type(struct evt_options *opt,
162 : : const char *arg __rte_unused)
163 : : {
164 : 0 : opt->prod_type = EVT_PROD_TYPE_EVENT_DMA_ADPTR;
165 : :
166 : : /* Only Forward mode is supported for DMA adapter. */
167 : 0 : opt->dma_adptr_mode = RTE_EVENT_DMA_ADAPTER_OP_FORWARD;
168 : :
169 : 0 : return 0;
170 : : }
171 : :
172 : : static int
173 : 0 : evt_parse_dma_adptr_mode(struct evt_options *opt, const char *arg)
174 : : {
175 : : uint8_t mode;
176 : : int ret;
177 : :
178 : 0 : ret = parser_read_uint8(&mode, arg);
179 : 0 : if (mode != RTE_EVENT_DMA_ADAPTER_OP_FORWARD) {
180 : 0 : RTE_LOG(ERR, USER1, "DMA adapter is supported in forward mode only\n");
181 : 0 : return -EINVAL;
182 : : }
183 : :
184 : 0 : opt->dma_adptr_mode = RTE_EVENT_DMA_ADAPTER_OP_FORWARD;
185 : :
186 : 0 : return ret;
187 : : }
188 : :
189 : : static int
190 : 0 : evt_parse_vector_prod_type(struct evt_options *opt,
191 : : const char *arg __rte_unused)
192 : : {
193 : 0 : opt->prod_type = EVT_PROD_TYPE_EVENT_VECTOR_ADPTR;
194 : 0 : return 0;
195 : : }
196 : :
197 : : static int
198 : 0 : evt_parse_crypto_prod_type(struct evt_options *opt,
199 : : const char *arg __rte_unused)
200 : : {
201 : 0 : opt->prod_type = EVT_PROD_TYPE_EVENT_CRYPTO_ADPTR;
202 : 0 : return 0;
203 : : }
204 : :
205 : : static int
206 : 0 : evt_parse_crypto_adptr_mode(struct evt_options *opt, const char *arg)
207 : : {
208 : : uint8_t mode;
209 : : int ret;
210 : :
211 : 0 : ret = parser_read_uint8(&mode, arg);
212 : 0 : opt->crypto_adptr_mode = mode ? RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD :
213 : : RTE_EVENT_CRYPTO_ADAPTER_OP_NEW;
214 : 0 : return ret;
215 : : }
216 : :
217 : : static int
218 : 0 : evt_parse_crypto_op_type(struct evt_options *opt, const char *arg)
219 : : {
220 : : uint8_t op_type;
221 : : int ret;
222 : :
223 : 0 : ret = parser_read_uint8(&op_type, arg);
224 : 0 : opt->crypto_op_type = op_type ? RTE_CRYPTO_OP_TYPE_ASYMMETRIC :
225 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC;
226 : 0 : return ret;
227 : : }
228 : :
229 : : static bool
230 : : cipher_alg_is_bit_mode(enum rte_crypto_cipher_algorithm alg)
231 : : {
232 : : return (alg == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
233 : 0 : alg == RTE_CRYPTO_CIPHER_ZUC_EEA3 ||
234 : : alg == RTE_CRYPTO_CIPHER_KASUMI_F8);
235 : : }
236 : :
237 : : static int
238 : 0 : evt_parse_crypto_cipher_alg(struct evt_options *opt, const char *arg)
239 : : {
240 : : enum rte_crypto_cipher_algorithm cipher_alg;
241 : :
242 : 0 : if (rte_cryptodev_get_cipher_algo_enum(&cipher_alg, arg) < 0) {
243 : 0 : RTE_LOG(ERR, USER1, "Invalid cipher algorithm specified\n");
244 : 0 : return -1;
245 : : }
246 : :
247 : 0 : opt->crypto_cipher_alg = cipher_alg;
248 : 0 : opt->crypto_cipher_bit_mode = cipher_alg_is_bit_mode(cipher_alg);
249 : :
250 : 0 : return 0;
251 : : }
252 : :
253 : : static int
254 : 0 : evt_parse_crypto_cipher_key(struct evt_options *opt, const char *arg)
255 : : {
256 : 0 : opt->crypto_cipher_key_sz = EVT_CRYPTO_MAX_KEY_SIZE;
257 : 0 : if (parse_hex_string(arg, opt->crypto_cipher_key,
258 : : (uint32_t *)&opt->crypto_cipher_key_sz)) {
259 : 0 : RTE_LOG(ERR, USER1, "Invalid cipher key specified\n");
260 : 0 : return -1;
261 : : }
262 : :
263 : : return 0;
264 : : }
265 : :
266 : : static int
267 : 0 : evt_parse_crypto_cipher_iv_sz(struct evt_options *opt, const char *arg)
268 : : {
269 : : uint16_t iv_sz;
270 : : int ret;
271 : :
272 : 0 : ret = parser_read_uint16(&(iv_sz), arg);
273 : 0 : if (iv_sz > EVT_CRYPTO_MAX_IV_SIZE) {
274 : 0 : RTE_LOG(ERR, USER1,
275 : : "Unsupported cipher IV length [%d] specified\n",
276 : : iv_sz);
277 : 0 : return -1;
278 : : }
279 : :
280 : 0 : opt->crypto_cipher_iv_sz = iv_sz;
281 : 0 : return ret;
282 : : }
283 : :
284 : : static int
285 : 0 : evt_parse_test_name(struct evt_options *opt, const char *arg)
286 : : {
287 : 0 : strlcpy(opt->test_name, arg, EVT_TEST_NAME_MAX_LEN);
288 : 0 : return 0;
289 : : }
290 : :
291 : : static int
292 : 0 : evt_parse_socket_id(struct evt_options *opt, const char *arg)
293 : : {
294 : 0 : opt->socket_id = atoi(arg);
295 : 0 : return 0;
296 : : }
297 : :
298 : : static int
299 : 0 : evt_parse_wkr_deq_dep(struct evt_options *opt, const char *arg)
300 : : {
301 : : int ret;
302 : :
303 : 0 : ret = parser_read_uint16(&(opt->wkr_deq_dep), arg);
304 : 0 : return ret;
305 : : }
306 : :
307 : : static int
308 : 0 : evt_parse_nb_pkts(struct evt_options *opt, const char *arg)
309 : : {
310 : : int ret;
311 : :
312 : 0 : ret = parser_read_uint64(&(opt->nb_pkts), arg);
313 : :
314 : 0 : return ret;
315 : : }
316 : :
317 : : static int
318 : 0 : evt_parse_nb_timers(struct evt_options *opt, const char *arg)
319 : : {
320 : : int ret;
321 : :
322 : 0 : ret = parser_read_uint64(&(opt->nb_timers), arg);
323 : :
324 : 0 : return ret;
325 : : }
326 : :
327 : : static int
328 : 0 : evt_parse_timer_tick_nsec(struct evt_options *opt, const char *arg)
329 : : {
330 : : int ret;
331 : :
332 : 0 : ret = parser_read_uint64(&(opt->timer_tick_nsec), arg);
333 : :
334 : 0 : return ret;
335 : : }
336 : :
337 : : static int
338 : 0 : evt_parse_max_tmo_nsec(struct evt_options *opt, const char *arg)
339 : : {
340 : : int ret;
341 : :
342 : 0 : ret = parser_read_uint64(&(opt->max_tmo_nsec), arg);
343 : :
344 : 0 : return ret;
345 : : }
346 : :
347 : : static int
348 : 0 : evt_parse_expiry_nsec(struct evt_options *opt, const char *arg)
349 : : {
350 : : int ret;
351 : :
352 : 0 : ret = parser_read_uint64(&(opt->expiry_nsec), arg);
353 : :
354 : 0 : return ret;
355 : : }
356 : :
357 : : static int
358 : 0 : evt_parse_nb_timer_adptrs(struct evt_options *opt, const char *arg)
359 : : {
360 : : int ret;
361 : :
362 : 0 : ret = parser_read_uint8(&(opt->nb_timer_adptrs), arg);
363 : 0 : if (opt->nb_timer_adptrs <= 0) {
364 : 0 : evt_err("Number of timer adapters cannot be <= 0");
365 : 0 : return -EINVAL;
366 : : }
367 : :
368 : : return ret;
369 : : }
370 : :
371 : : static int
372 : 0 : evt_parse_pool_sz(struct evt_options *opt, const char *arg)
373 : : {
374 : 0 : opt->pool_sz = atoi(arg);
375 : :
376 : 0 : return 0;
377 : : }
378 : :
379 : : static int
380 : 0 : evt_parse_plcores(struct evt_options *opt, const char *corelist)
381 : : {
382 : : int ret;
383 : :
384 : 0 : ret = parse_lcores_list(opt->plcores, RTE_MAX_LCORE, corelist);
385 : 0 : if (ret == -E2BIG)
386 : 0 : evt_err("duplicate lcores in plcores");
387 : :
388 : 0 : return ret;
389 : : }
390 : :
391 : : static int
392 : 0 : evt_parse_work_lcores(struct evt_options *opt, const char *corelist)
393 : : {
394 : : int ret;
395 : :
396 : 0 : ret = parse_lcores_list(opt->wlcores, RTE_MAX_LCORE, corelist);
397 : 0 : if (ret == -E2BIG)
398 : 0 : evt_err("duplicate lcores in wlcores");
399 : :
400 : 0 : return ret;
401 : : }
402 : :
403 : : static int
404 : 0 : evt_parse_mbuf_sz(struct evt_options *opt, const char *arg)
405 : : {
406 : : int ret;
407 : :
408 : 0 : ret = parser_read_uint16(&(opt->mbuf_sz), arg);
409 : :
410 : 0 : return ret;
411 : : }
412 : :
413 : : static int
414 : 0 : evt_parse_max_pkt_sz(struct evt_options *opt, const char *arg)
415 : : {
416 : : int ret;
417 : :
418 : 0 : ret = parser_read_uint32(&(opt->max_pkt_sz), arg);
419 : :
420 : 0 : return ret;
421 : : }
422 : :
423 : : static int
424 : 0 : evt_parse_ena_vector(struct evt_options *opt, const char *arg __rte_unused)
425 : : {
426 : 0 : opt->ena_vector = 1;
427 : 0 : return 0;
428 : : }
429 : :
430 : : static int
431 : 0 : evt_parse_vector_size(struct evt_options *opt, const char *arg)
432 : : {
433 : : int ret;
434 : :
435 : 0 : ret = parser_read_uint16(&(opt->vector_size), arg);
436 : :
437 : 0 : return ret;
438 : : }
439 : :
440 : : static int
441 : 0 : evt_parse_vector_tmo_ns(struct evt_options *opt, const char *arg)
442 : : {
443 : : int ret;
444 : :
445 : 0 : ret = parser_read_uint64(&(opt->vector_tmo_nsec), arg);
446 : :
447 : 0 : return ret;
448 : : }
449 : :
450 : : static int
451 : 0 : evt_parse_eth_queues(struct evt_options *opt, const char *arg)
452 : : {
453 : : int ret;
454 : :
455 : 0 : ret = parser_read_uint16(&(opt->eth_queues), arg);
456 : :
457 : 0 : return ret;
458 : : }
459 : :
460 : : static int
461 : 0 : evt_parse_per_port_pool(struct evt_options *opt, const char *arg __rte_unused)
462 : : {
463 : 0 : opt->per_port_pool = 1;
464 : 0 : return 0;
465 : : }
466 : :
467 : : static int
468 : 0 : evt_parse_prod_enq_burst_sz(struct evt_options *opt, const char *arg)
469 : : {
470 : : int ret;
471 : :
472 : 0 : ret = parser_read_uint32(&(opt->prod_enq_burst_sz), arg);
473 : :
474 : 0 : return ret;
475 : : }
476 : :
477 : : static void
478 : 0 : usage(char *program)
479 : : {
480 : : printf("usage : %s [EAL options] -- [application options]\n", program);
481 : : printf("application options:\n");
482 : : printf("\t--verbose : verbose level\n"
483 : : "\t--dev : device id of the event device\n"
484 : : "\t--test : name of the test application to run\n"
485 : : "\t--socket_id : socket_id of application resources\n"
486 : : "\t--pool_sz : pool size of the mempool\n"
487 : : "\t--plcores : list of lcore ids for producers\n"
488 : : "\t--wlcores : list of lcore ids for workers\n"
489 : : "\t--stlist : list of scheduled types of the stages\n"
490 : : "\t--nb_flows : number of flows to produce\n"
491 : : "\t--nb_pkts : number of packets to produce\n"
492 : : "\t--worker_deq_depth : dequeue depth of the worker\n"
493 : : "\t--fwd_latency : perform fwd_latency measurement\n"
494 : : "\t--queue_priority : enable queue priority\n"
495 : : "\t--deq_tmo_nsec : global dequeue timeout\n"
496 : : "\t--prod_type_ethdev : use ethernet device as producer.\n"
497 : : "\t--prod_type_dmadev : use dma device as producer.\n"
498 : : "\t--prod_type_cryptodev : use crypto device as producer.\n"
499 : : "\t--prod_type_timerdev : use event timer device as producer.\n"
500 : : "\t expiry_nsec would be the timeout\n"
501 : : "\t in ns.\n"
502 : : "\t--prod_type_timerdev_burst : use timer device as producer\n"
503 : : "\t burst mode.\n"
504 : : "\t--prod_type_vector : use vector adapter as producer.\n"
505 : : "\t--nb_timers : number of timers to arm.\n"
506 : : "\t--nb_timer_adptrs : number of timer adapters to use.\n"
507 : : "\t--timer_tick_nsec : timer tick interval in ns.\n"
508 : : "\t--max_tmo_nsec : max timeout interval in ns.\n"
509 : : "\t--expiry_nsec : event timer expiry ns.\n"
510 : : "\t--dma_adptr_mode : 1 for OP_FORWARD mode (default).\n"
511 : : "\t--crypto_adptr_mode : 0 for OP_NEW mode (default) and\n"
512 : : "\t 1 for OP_FORWARD mode.\n"
513 : : "\t--crypto_op_type : 0 for SYM ops (default) and\n"
514 : : "\t 1 for ASYM ops.\n"
515 : : "\t--crypto_cipher_alg : cipher algorithm to be used\n"
516 : : "\t default algorithm is NULL.\n"
517 : : "\t--crypto_cipher_key : key for the cipher algorithm selected\n"
518 : : "\t--crypto_cipher_iv_sz : IV size for the cipher algorithm\n"
519 : : "\t selected\n"
520 : : "\t--mbuf_sz : packet mbuf size.\n"
521 : : "\t--max_pkt_sz : max packet size.\n"
522 : : "\t--prod_enq_burst_sz : producer enqueue burst size.\n"
523 : : "\t--nb_eth_queues : number of ethernet Rx queues.\n"
524 : : "\t--enable_vector : enable event vectorization.\n"
525 : : "\t--vector_size : Max vector size.\n"
526 : : "\t--vector_tmo_ns : Max vector timeout in nanoseconds\n"
527 : : "\t--per_port_pool : Configure unique pool per ethdev port\n"
528 : : "\t--tx_first : Transmit given number of packets\n"
529 : : " across all the ethernet devices before\n"
530 : : " event workers start.\n"
531 : : "\t--tx_pkt_sz : Packet size to use with Tx first."
532 : : "\t--preschedule : Pre-schedule type to use.\n"
533 : : " 0 - disable pre-schedule\n"
534 : : " 1 - pre-schedule\n"
535 : : " 2 - pre-schedule adaptive (Default)\n"
536 : : );
537 : : printf("available tests:\n");
538 : 0 : evt_test_dump_names();
539 : 0 : }
540 : :
541 : : static int
542 : 0 : evt_parse_sched_type_list(struct evt_options *opt, const char *arg)
543 : : {
544 : : char c;
545 : : int i = 0, j = -1;
546 : :
547 : 0 : for (i = 0; i < EVT_MAX_STAGES; i++)
548 : 0 : opt->sched_type_list[i] = (uint8_t)-1;
549 : :
550 : : i = 0;
551 : :
552 : : do {
553 : 0 : c = arg[++j];
554 : :
555 : 0 : switch (c) {
556 : 0 : case 'o':
557 : : case 'O':
558 : 0 : opt->sched_type_list[i++] = RTE_SCHED_TYPE_ORDERED;
559 : 0 : break;
560 : 0 : case 'a':
561 : : case 'A':
562 : 0 : opt->sched_type_list[i++] = RTE_SCHED_TYPE_ATOMIC;
563 : 0 : break;
564 : 0 : case 'p':
565 : : case 'P':
566 : 0 : opt->sched_type_list[i++] = RTE_SCHED_TYPE_PARALLEL;
567 : 0 : break;
568 : : case ',':
569 : : break;
570 : 0 : default:
571 : 0 : if (c != '\0') {
572 : 0 : evt_err("invalid sched_type %c", c);
573 : 0 : return -EINVAL;
574 : : }
575 : : }
576 : 0 : } while (c != '\0');
577 : :
578 : 0 : opt->nb_stages = i;
579 : 0 : return 0;
580 : : }
581 : :
582 : : static struct option lgopts[] = {
583 : : { EVT_NB_FLOWS, 1, 0, 0 },
584 : : { EVT_DEVICE, 1, 0, 0 },
585 : : { EVT_VERBOSE, 1, 0, 0 },
586 : : { EVT_TEST, 1, 0, 0 },
587 : : { EVT_PROD_LCORES, 1, 0, 0 },
588 : : { EVT_WORK_LCORES, 1, 0, 0 },
589 : : { EVT_SOCKET_ID, 1, 0, 0 },
590 : : { EVT_POOL_SZ, 1, 0, 0 },
591 : : { EVT_NB_PKTS, 1, 0, 0 },
592 : : { EVT_WKR_DEQ_DEP, 1, 0, 0 },
593 : : { EVT_SCHED_TYPE_LIST, 1, 0, 0 },
594 : : { EVT_FWD_LATENCY, 0, 0, 0 },
595 : : { EVT_QUEUE_PRIORITY, 0, 0, 0 },
596 : : { EVT_DEQ_TMO_NSEC, 1, 0, 0 },
597 : : { EVT_PROD_ETHDEV, 0, 0, 0 },
598 : : { EVT_PROD_DMADEV, 0, 0, 0 },
599 : : { EVT_PROD_CRYPTODEV, 0, 0, 0 },
600 : : { EVT_PROD_TIMERDEV, 0, 0, 0 },
601 : : { EVT_PROD_TIMERDEV_BURST, 0, 0, 0 },
602 : : { EVT_PROD_VECTOR, 0, 0, 0 },
603 : : { EVT_DMA_ADPTR_MODE, 1, 0, 0 },
604 : : { EVT_CRYPTO_ADPTR_MODE, 1, 0, 0 },
605 : : { EVT_CRYPTO_OP_TYPE, 1, 0, 0 },
606 : : { EVT_CRYPTO_CIPHER_ALG, 1, 0, 0 },
607 : : { EVT_CRYPTO_CIPHER_KEY, 1, 0, 0 },
608 : : { EVT_CRYPTO_CIPHER_IV_SZ, 1, 0, 0 },
609 : : { EVT_NB_TIMERS, 1, 0, 0 },
610 : : { EVT_NB_TIMER_ADPTRS, 1, 0, 0 },
611 : : { EVT_TIMER_TICK_NSEC, 1, 0, 0 },
612 : : { EVT_MAX_TMO_NSEC, 1, 0, 0 },
613 : : { EVT_EXPIRY_NSEC, 1, 0, 0 },
614 : : { EVT_MBUF_SZ, 1, 0, 0 },
615 : : { EVT_MAX_PKT_SZ, 1, 0, 0 },
616 : : { EVT_PROD_ENQ_BURST_SZ, 1, 0, 0 },
617 : : { EVT_NB_ETH_QUEUES, 1, 0, 0 },
618 : : { EVT_ENA_VECTOR, 0, 0, 0 },
619 : : { EVT_VECTOR_SZ, 1, 0, 0 },
620 : : { EVT_VECTOR_TMO, 1, 0, 0 },
621 : : { EVT_PER_PORT_POOL, 0, 0, 0 },
622 : : { EVT_HELP, 0, 0, 0 },
623 : : { EVT_TX_FIRST, 1, 0, 0 },
624 : : { EVT_TX_PKT_SZ, 1, 0, 0 },
625 : : { EVT_PRESCHEDULE, 1, 0, 0 },
626 : : { NULL, 0, 0, 0 }
627 : : };
628 : :
629 : : static int
630 : 0 : evt_opts_parse_long(int opt_idx, struct evt_options *opt)
631 : : {
632 : : unsigned int i;
633 : :
634 : 0 : struct long_opt_parser parsermap[] = {
635 : : { EVT_NB_FLOWS, evt_parse_nb_flows},
636 : : { EVT_DEVICE, evt_parse_dev_id},
637 : : { EVT_VERBOSE, evt_parse_verbose},
638 : : { EVT_TEST, evt_parse_test_name},
639 : : { EVT_PROD_LCORES, evt_parse_plcores},
640 : : { EVT_WORK_LCORES, evt_parse_work_lcores},
641 : : { EVT_SOCKET_ID, evt_parse_socket_id},
642 : : { EVT_POOL_SZ, evt_parse_pool_sz},
643 : : { EVT_NB_PKTS, evt_parse_nb_pkts},
644 : : { EVT_WKR_DEQ_DEP, evt_parse_wkr_deq_dep},
645 : : { EVT_SCHED_TYPE_LIST, evt_parse_sched_type_list},
646 : : { EVT_FWD_LATENCY, evt_parse_fwd_latency},
647 : : { EVT_QUEUE_PRIORITY, evt_parse_queue_priority},
648 : : { EVT_DEQ_TMO_NSEC, evt_parse_deq_tmo_nsec},
649 : : { EVT_PROD_ETHDEV, evt_parse_eth_prod_type},
650 : : { EVT_PROD_CRYPTODEV, evt_parse_crypto_prod_type},
651 : : { EVT_PROD_DMADEV, evt_parse_dma_prod_type},
652 : : { EVT_PROD_TIMERDEV, evt_parse_timer_prod_type},
653 : : { EVT_PROD_TIMERDEV_BURST, evt_parse_timer_prod_type_burst},
654 : : { EVT_PROD_VECTOR, evt_parse_vector_prod_type },
655 : : { EVT_DMA_ADPTR_MODE, evt_parse_dma_adptr_mode},
656 : : { EVT_CRYPTO_ADPTR_MODE, evt_parse_crypto_adptr_mode},
657 : : { EVT_CRYPTO_OP_TYPE, evt_parse_crypto_op_type},
658 : : { EVT_CRYPTO_CIPHER_ALG, evt_parse_crypto_cipher_alg},
659 : : { EVT_CRYPTO_CIPHER_KEY, evt_parse_crypto_cipher_key},
660 : : { EVT_CRYPTO_CIPHER_IV_SZ, evt_parse_crypto_cipher_iv_sz},
661 : : { EVT_NB_TIMERS, evt_parse_nb_timers},
662 : : { EVT_NB_TIMER_ADPTRS, evt_parse_nb_timer_adptrs},
663 : : { EVT_TIMER_TICK_NSEC, evt_parse_timer_tick_nsec},
664 : : { EVT_MAX_TMO_NSEC, evt_parse_max_tmo_nsec},
665 : : { EVT_EXPIRY_NSEC, evt_parse_expiry_nsec},
666 : : { EVT_MBUF_SZ, evt_parse_mbuf_sz},
667 : : { EVT_MAX_PKT_SZ, evt_parse_max_pkt_sz},
668 : : { EVT_PROD_ENQ_BURST_SZ, evt_parse_prod_enq_burst_sz},
669 : : { EVT_NB_ETH_QUEUES, evt_parse_eth_queues},
670 : : { EVT_ENA_VECTOR, evt_parse_ena_vector},
671 : : { EVT_VECTOR_SZ, evt_parse_vector_size},
672 : : { EVT_VECTOR_TMO, evt_parse_vector_tmo_ns},
673 : : { EVT_PER_PORT_POOL, evt_parse_per_port_pool},
674 : : { EVT_TX_FIRST, evt_parse_tx_first},
675 : : { EVT_TX_PKT_SZ, evt_parse_tx_pkt_sz},
676 : : { EVT_PRESCHEDULE, evt_parse_preschedule},
677 : : };
678 : :
679 : 0 : for (i = 0; i < RTE_DIM(parsermap); i++) {
680 : 0 : if (strncmp(lgopts[opt_idx].name, parsermap[i].lgopt_name,
681 : : strlen(lgopts[opt_idx].name)) == 0)
682 : 0 : return parsermap[i].parser_fn(opt, optarg);
683 : : }
684 : :
685 : : return -EINVAL;
686 : : }
687 : :
688 : : int
689 : 0 : evt_options_parse(struct evt_options *opt, int argc, char **argv)
690 : : {
691 : : int opts, retval, opt_idx;
692 : :
693 : 0 : while ((opts = getopt_long(argc, argv, "", lgopts, &opt_idx)) != EOF) {
694 : 0 : switch (opts) {
695 : 0 : case 0: /* long options */
696 : 0 : if (!strcmp(lgopts[opt_idx].name, "help")) {
697 : 0 : usage(argv[0]);
698 : 0 : exit(EXIT_SUCCESS);
699 : : }
700 : :
701 : 0 : retval = evt_opts_parse_long(opt_idx, opt);
702 : 0 : if (retval != 0)
703 : 0 : return retval;
704 : : break;
705 : : default:
706 : : return -EINVAL;
707 : : }
708 : : }
709 : : return 0;
710 : : }
711 : :
712 : : void
713 : 0 : evt_options_dump(struct evt_options *opt)
714 : : {
715 : : int lcore_id;
716 : : struct rte_event_dev_info dev_info;
717 : :
718 : 0 : rte_event_dev_info_get(opt->dev_id, &dev_info);
719 : 0 : evt_dump("driver", "%s", dev_info.driver_name);
720 : 0 : evt_dump("test", "%s", opt->test_name);
721 : 0 : evt_dump("dev", "%d", opt->dev_id);
722 : 0 : evt_dump("verbose_level", "%d", opt->verbose_level);
723 : 0 : evt_dump("socket_id", "%d", opt->socket_id);
724 : 0 : evt_dump("pool_sz", "%d", opt->pool_sz);
725 : 0 : evt_dump("main lcore", "%d", rte_get_main_lcore());
726 : 0 : evt_dump("nb_pkts", "%"PRIu64, opt->nb_pkts);
727 : 0 : evt_dump("nb_timers", "%"PRIu64, opt->nb_timers);
728 : : evt_dump_begin("available lcores");
729 : 0 : RTE_LCORE_FOREACH(lcore_id)
730 : : printf("%d ", lcore_id);
731 : : evt_dump_end;
732 : : evt_dump_nb_flows(opt);
733 : : evt_dump_worker_dequeue_depth(opt);
734 : 0 : if (opt->ena_vector || opt->prod_type == EVT_PROD_TYPE_EVENT_VECTOR_ADPTR) {
735 : 0 : evt_dump("vector_sz", "%d", opt->vector_size);
736 : 0 : evt_dump("vector_tmo_ns", "%"PRIu64, opt->vector_tmo_nsec);
737 : : }
738 : 0 : }
|