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