app/regex: measure performance per queue pair
[dpdk.git] / app / test-regex / main.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2020 Mellanox Technologies, Ltd
3  */
4
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
8 #include <stdint.h>
9 #include <stdbool.h>
10 #include <stdarg.h>
11 #include <ctype.h>
12 #include <errno.h>
13 #include <getopt.h>
14 #include <signal.h>
15
16 #include <rte_eal.h>
17 #include <rte_common.h>
18 #include <rte_malloc.h>
19 #include <rte_mempool.h>
20 #include <rte_mbuf.h>
21 #include <rte_cycles.h>
22 #include <rte_regexdev.h>
23
24 #define MAX_FILE_NAME 255
25 #define MBUF_CACHE_SIZE 256
26 #define MBUF_SIZE (1 << 8)
27 #define START_BURST_SIZE 32u
28
29 enum app_args {
30         ARG_HELP,
31         ARG_RULES_FILE_NAME,
32         ARG_DATA_FILE_NAME,
33         ARG_NUM_OF_JOBS,
34         ARG_PERF_MODE,
35         ARG_NUM_OF_ITERATIONS,
36         ARG_NUM_OF_QPS,
37         ARG_NUM_OF_LCORES,
38 };
39
40 struct job_ctx {
41         struct rte_mbuf *mbuf;
42 };
43
44 struct qp_params {
45         uint32_t total_enqueue;
46         uint32_t total_dequeue;
47         uint32_t total_matches;
48         struct rte_regex_ops **ops;
49         struct job_ctx *jobs_ctx;
50         char *buf;
51         time_t start;
52         time_t end;
53 };
54
55 struct qps_per_lcore {
56         unsigned int lcore_id;
57         int socket;
58         uint16_t qp_id_base;
59         uint16_t nb_qps;
60 };
61
62 struct regex_conf {
63         uint32_t nb_jobs;
64         bool perf_mode;
65         uint32_t nb_iterations;
66         char *data_file;
67         uint8_t nb_max_matches;
68         uint32_t nb_qps;
69         uint16_t qp_id_base;
70         char *data_buf;
71         long data_len;
72         long job_len;
73 };
74
75 static void
76 usage(const char *prog_name)
77 {
78         printf("%s [EAL options] --\n"
79                 " --rules NAME: precompiled rules file\n"
80                 " --data NAME: data file to use\n"
81                 " --nb_jobs: number of jobs to use\n"
82                 " --perf N: only outputs the performance data\n"
83                 " --nb_iter N: number of iteration to run\n"
84                 " --nb_qps N: number of queues to use\n"
85                 " --nb_lcores N: number of lcores to use\n",
86                 prog_name);
87 }
88
89 static void
90 args_parse(int argc, char **argv, char *rules_file, char *data_file,
91            uint32_t *nb_jobs, bool *perf_mode, uint32_t *nb_iterations,
92            uint32_t *nb_qps, uint32_t *nb_lcores)
93 {
94         char **argvopt;
95         int opt;
96         int opt_idx;
97         size_t len;
98         static struct option lgopts[] = {
99                 { "help",  0, 0, ARG_HELP},
100                 /* Rules database file to load. */
101                 { "rules",  1, 0, ARG_RULES_FILE_NAME},
102                 /* Data file to load. */
103                 { "data",  1, 0, ARG_DATA_FILE_NAME},
104                 /* Number of jobs to create. */
105                 { "nb_jobs",  1, 0, ARG_NUM_OF_JOBS},
106                 /* Perf test only */
107                 { "perf", 0, 0, ARG_PERF_MODE},
108                 /* Number of iterations to run with perf test */
109                 { "nb_iter", 1, 0, ARG_NUM_OF_ITERATIONS},
110                 /* Number of QPs. */
111                 { "nb_qps", 1, 0, ARG_NUM_OF_QPS},
112                 /* Number of lcores. */
113                 { "nb_lcores", 1, 0, ARG_NUM_OF_LCORES},
114                 /* End of options */
115                 { 0, 0, 0, 0 }
116         };
117
118         argvopt = argv;
119         while ((opt = getopt_long(argc, argvopt, "",
120                                 lgopts, &opt_idx)) != EOF) {
121                 switch (opt) {
122                 case ARG_RULES_FILE_NAME:
123                         len = strnlen(optarg, MAX_FILE_NAME - 1);
124                         if (len == MAX_FILE_NAME)
125                                 rte_exit(EXIT_FAILURE,
126                                          "Rule file name to long max %d\n",
127                                          MAX_FILE_NAME - 1);
128                         strncpy(rules_file, optarg, MAX_FILE_NAME - 1);
129                         break;
130                 case ARG_DATA_FILE_NAME:
131                         len = strnlen(optarg, MAX_FILE_NAME - 1);
132                         if (len == MAX_FILE_NAME)
133                                 rte_exit(EXIT_FAILURE,
134                                          "Data file name to long max %d\n",
135                                          MAX_FILE_NAME - 1);
136                         strncpy(data_file, optarg, MAX_FILE_NAME - 1);
137                         break;
138                 case ARG_NUM_OF_JOBS:
139                         *nb_jobs = atoi(optarg);
140                         break;
141                 case ARG_PERF_MODE:
142                         *perf_mode = true;
143                         break;
144                 case ARG_NUM_OF_ITERATIONS:
145                         *nb_iterations = atoi(optarg);
146                         break;
147                 case ARG_NUM_OF_QPS:
148                         *nb_qps = atoi(optarg);
149                         break;
150                 case ARG_NUM_OF_LCORES:
151                         *nb_lcores = atoi(optarg);
152                         break;
153                 case ARG_HELP:
154                         usage("RegEx test app");
155                         break;
156                 default:
157                         fprintf(stderr, "Invalid option: %s\n", argv[optind]);
158                         usage("RegEx test app");
159                         rte_exit(EXIT_FAILURE, "Invalid option\n");
160                         break;
161                 }
162         }
163
164         if (!perf_mode)
165                 *nb_iterations = 1;
166 }
167
168 static long
169 read_file(char *file, char **buf)
170 {
171         FILE *fp;
172         long buf_len = 0;
173         size_t read_len;
174         int res = 0;
175
176         fp = fopen(file, "r");
177         if (!fp)
178                 return -EIO;
179         if (fseek(fp, 0L, SEEK_END) == 0) {
180                 buf_len = ftell(fp);
181                 if (buf_len == -1) {
182                         res = EIO;
183                         goto error;
184                 }
185                 *buf = rte_malloc(NULL, sizeof(char) * (buf_len + 1), 4096);
186                 if (!*buf) {
187                         res = ENOMEM;
188                         goto error;
189                 }
190                 if (fseek(fp, 0L, SEEK_SET) != 0) {
191                         res = EIO;
192                         goto error;
193                 }
194                 read_len = fread(*buf, sizeof(char), buf_len, fp);
195                 if (read_len != (unsigned long)buf_len) {
196                         res = EIO;
197                         goto error;
198                 }
199         }
200         fclose(fp);
201         return buf_len;
202 error:
203         printf("Error, can't open file %s\n, err = %d", file, res);
204         if (fp)
205                 fclose(fp);
206         if (*buf)
207                 rte_free(*buf);
208         return -res;
209 }
210
211 static int
212 clone_buf(char *data_buf, char **buf, long data_len)
213 {
214         char *dest_buf;
215         dest_buf =
216                 rte_malloc(NULL, sizeof(char) * (data_len + 1), 4096);
217         if (!dest_buf)
218                 return -ENOMEM;
219         memcpy(dest_buf, data_buf, data_len + 1);
220         *buf = dest_buf;
221         return 0;
222 }
223
224 static int
225 init_port(uint16_t *nb_max_payload, char *rules_file, uint8_t *nb_max_matches,
226           uint32_t nb_qps)
227 {
228         uint16_t id;
229         uint16_t qp_id;
230         uint16_t num_devs;
231         char *rules = NULL;
232         long rules_len;
233         struct rte_regexdev_info info;
234         struct rte_regexdev_config dev_conf = {
235                 .nb_queue_pairs = nb_qps,
236                 .nb_groups = 1,
237         };
238         struct rte_regexdev_qp_conf qp_conf = {
239                 .nb_desc = 1024,
240                 .qp_conf_flags = 0,
241         };
242         int res = 0;
243
244         num_devs = rte_regexdev_count();
245         if (num_devs == 0) {
246                 printf("Error, no devices detected.\n");
247                 return -EINVAL;
248         }
249
250         rules_len = read_file(rules_file, &rules);
251         if (rules_len < 0) {
252                 printf("Error, can't read rules files.\n");
253                 res = -EIO;
254                 goto error;
255         }
256
257         for (id = 0; id < num_devs; id++) {
258                 res = rte_regexdev_info_get(id, &info);
259                 if (res != 0) {
260                         printf("Error, can't get device info.\n");
261                         goto error;
262                 }
263                 printf(":: initializing dev: %d\n", id);
264                 *nb_max_matches = info.max_matches;
265                 *nb_max_payload = info.max_payload_size;
266                 if (info.regexdev_capa & RTE_REGEXDEV_SUPP_MATCH_AS_END_F)
267                         dev_conf.dev_cfg_flags |=
268                         RTE_REGEXDEV_CFG_MATCH_AS_END_F;
269                 dev_conf.nb_max_matches = info.max_matches;
270                 dev_conf.nb_rules_per_group = info.max_rules_per_group;
271                 dev_conf.rule_db_len = rules_len;
272                 dev_conf.rule_db = rules;
273                 res = rte_regexdev_configure(id, &dev_conf);
274                 if (res < 0) {
275                         printf("Error, can't configure device %d.\n", id);
276                         goto error;
277                 }
278                 if (info.regexdev_capa & RTE_REGEXDEV_CAPA_QUEUE_PAIR_OOS_F)
279                         qp_conf.qp_conf_flags |=
280                         RTE_REGEX_QUEUE_PAIR_CFG_OOS_F;
281                 for (qp_id = 0; qp_id < nb_qps; qp_id++) {
282                         res = rte_regexdev_queue_pair_setup(id, qp_id,
283                                                             &qp_conf);
284                         if (res < 0) {
285                                 printf("Error, can't setup queue pair %u for "
286                                        "device %d.\n", qp_id, id);
287                                 goto error;
288                         }
289                 }
290                 printf(":: initializing device: %d done\n", id);
291         }
292         rte_free(rules);
293         return 0;
294 error:
295         if (rules)
296                 rte_free(rules);
297         return res;
298 }
299
300 static void
301 extbuf_free_cb(void *addr __rte_unused, void *fcb_opaque __rte_unused)
302 {
303 }
304
305 static int
306 run_regex(void *args)
307 {
308         struct regex_conf *rgxc = args;
309         uint32_t nb_jobs = rgxc->nb_jobs;
310         uint32_t nb_iterations = rgxc->nb_iterations;
311         uint8_t nb_max_matches = rgxc->nb_max_matches;
312         uint32_t nb_qps = rgxc->nb_qps;
313         uint16_t qp_id_base  = rgxc->qp_id_base;
314         char *data_buf = rgxc->data_buf;
315         long data_len = rgxc->data_len;
316         long job_len = rgxc->job_len;
317
318         char *buf = NULL;
319         uint32_t actual_jobs = 0;
320         uint32_t i;
321         uint16_t qp_id;
322         uint16_t dev_id = 0;
323         uint8_t nb_matches;
324         struct rte_regexdev_match *match;
325         long pos;
326         unsigned long d_ind = 0;
327         struct rte_mbuf_ext_shared_info shinfo;
328         int res = 0;
329         double time;
330         struct rte_mempool *mbuf_mp;
331         struct qp_params *qp;
332         struct qp_params *qps = NULL;
333         bool update;
334         uint16_t qps_used = 0;
335         char mbuf_pool[16];
336
337         shinfo.free_cb = extbuf_free_cb;
338         snprintf(mbuf_pool,
339                  sizeof(mbuf_pool),
340                  "mbuf_pool_%2u", qp_id_base);
341         mbuf_mp = rte_pktmbuf_pool_create(mbuf_pool, nb_jobs * nb_qps, 0,
342                         0, MBUF_SIZE, rte_socket_id());
343         if (mbuf_mp == NULL) {
344                 printf("Error, can't create memory pool\n");
345                 return -ENOMEM;
346         }
347
348         qps = rte_malloc(NULL, sizeof(*qps) * nb_qps, 0);
349         if (!qps) {
350                 printf("Error, can't allocate memory for QPs\n");
351                 res = -ENOMEM;
352                 goto end;
353         }
354
355         for (qp_id = 0; qp_id < nb_qps; qp_id++) {
356                 struct rte_regex_ops **ops;
357                 struct job_ctx *jobs_ctx;
358
359                 qps_used++;
360                 qp = &qps[qp_id];
361                 qp->jobs_ctx = NULL;
362                 qp->buf = NULL;
363                 qp->ops = ops = rte_malloc(NULL, sizeof(*ops) * nb_jobs, 0);
364                 if (!ops) {
365                         printf("Error, can't allocate memory for ops.\n");
366                         res = -ENOMEM;
367                         goto end;
368                 }
369
370                 qp->jobs_ctx = jobs_ctx =
371                         rte_malloc(NULL, sizeof(*jobs_ctx) * nb_jobs, 0);
372                 if (!jobs_ctx) {
373                         printf("Error, can't allocate memory for jobs_ctx.\n");
374                         res = -ENOMEM;
375                         goto end;
376                 }
377
378                 /* Allocate the jobs and assign each job with an mbuf. */
379                 for (i = 0; i < nb_jobs; i++) {
380                         ops[i] = rte_malloc(NULL, sizeof(*ops[0]) +
381                                         nb_max_matches *
382                                         sizeof(struct rte_regexdev_match), 0);
383                         if (!ops[i]) {
384                                 printf("Error, can't allocate "
385                                        "memory for op.\n");
386                                 res = -ENOMEM;
387                                 goto end;
388                         }
389                         ops[i]->mbuf = rte_pktmbuf_alloc(mbuf_mp);
390                         if (!ops[i]->mbuf) {
391                                 printf("Error, can't attach mbuf.\n");
392                                 res = -ENOMEM;
393                                 goto end;
394                         }
395                 }
396
397                 if (clone_buf(data_buf, &buf, data_len)) {
398                         printf("Error, can't clone buf.\n");
399                         res = -EXIT_FAILURE;
400                         goto end;
401                 }
402
403                 /* Assign each mbuf with the data to handle. */
404                 actual_jobs = 0;
405                 pos = 0;
406                 for (i = 0; (pos < data_len) && (i < nb_jobs) ; i++) {
407                         long act_job_len = RTE_MIN(job_len, data_len - pos);
408                         rte_pktmbuf_attach_extbuf(ops[i]->mbuf, &buf[pos], 0,
409                                         act_job_len, &shinfo);
410                         jobs_ctx[i].mbuf = ops[i]->mbuf;
411                         ops[i]->mbuf->data_len = job_len;
412                         ops[i]->mbuf->pkt_len = act_job_len;
413                         ops[i]->user_id = i;
414                         ops[i]->group_id0 = 1;
415                         pos += act_job_len;
416                         actual_jobs++;
417                 }
418
419                 qp->buf = buf;
420                 qp->total_matches = 0;
421                 qp->start = 0;
422                 qp->end = 0;
423         }
424
425         for (i = 0; i < nb_iterations; i++) {
426                 for (qp_id = 0; qp_id < nb_qps; qp_id++) {
427                         qp = &qps[qp_id];
428                         qp->total_enqueue = 0;
429                         qp->total_dequeue = 0;
430                 }
431                 do {
432                         update = false;
433                         for (qp_id = 0; qp_id < nb_qps; qp_id++) {
434                                 qp = &qps[qp_id];
435                                 if (!qp->start)
436                                         qp->start = clock();
437                                 if (qp->total_dequeue < actual_jobs) {
438                                         struct rte_regex_ops **
439                                                 cur_ops_to_enqueue = qp->ops +
440                                                 qp->total_enqueue;
441
442                                         if (actual_jobs - qp->total_enqueue)
443                                                 qp->total_enqueue +=
444                                                 rte_regexdev_enqueue_burst
445                                                         (dev_id,
446                                                         qp_id_base + qp_id,
447                                                         cur_ops_to_enqueue,
448                                                         actual_jobs -
449                                                         qp->total_enqueue);
450                                 }
451                         }
452                         for (qp_id = 0; qp_id < nb_qps; qp_id++) {
453                                 qp = &qps[qp_id];
454                                 if (qp->total_dequeue < actual_jobs) {
455                                         struct rte_regex_ops **
456                                                 cur_ops_to_dequeue = qp->ops +
457                                                 qp->total_dequeue;
458
459                                         qp->total_dequeue +=
460                                                 rte_regexdev_dequeue_burst
461                                                         (dev_id,
462                                                         qp_id_base + qp_id,
463                                                         cur_ops_to_dequeue,
464                                                         qp->total_enqueue -
465                                                         qp->total_dequeue);
466                                         update = true;
467                                 } else {
468                                         if (!qp->end)
469                                                 qp->end = clock();
470                                 }
471
472                         }
473                 } while (update);
474         }
475         for (qp_id = 0; qp_id < nb_qps; qp_id++) {
476                 qp = &qps[qp_id];
477                 time = ((double)qp->end - qp->start) / CLOCKS_PER_SEC;
478                 printf("Core=%u QP=%u\n", rte_lcore_id(), qp_id + qp_id_base);
479                 printf("Job len = %ld Bytes\n",  job_len);
480                 printf("Time = %lf sec\n",  time);
481                 printf("Perf = %lf Gbps\n\n",
482                                 (((double)actual_jobs * job_len *
483                                 nb_iterations * 8) / time) /
484                                 1000000000.0);
485         }
486
487         if (rgxc->perf_mode)
488                 goto end;
489         for (qp_id = 0; qp_id < nb_qps; qp_id++) {
490                 printf("\n############ Core=%u QP=%u ############\n",
491                        rte_lcore_id(), qp_id + qp_id_base);
492                 qp = &qps[qp_id];
493                 /* Log results per job. */
494                 for (d_ind = 0; d_ind < qp->total_dequeue; d_ind++) {
495                         nb_matches = qp->ops[d_ind % actual_jobs]->nb_matches;
496                         printf("Job id %"PRIu64" number of matches = %d\n",
497                                         qp->ops[d_ind]->user_id, nb_matches);
498                         qp->total_matches += nb_matches;
499                         match = qp->ops[d_ind % actual_jobs]->matches;
500                         for (i = 0; i < nb_matches; i++) {
501                                 printf("match %d, rule = %d, "
502                                        "start = %d,len = %d\n",
503                                        i, match->rule_id, match->start_offset,
504                                        match->len);
505                                 match++;
506                         }
507                 }
508                 printf("Total matches = %d\n", qp->total_matches);
509                 printf("All Matches:\n");
510                 /* Log absolute results. */
511                 for (d_ind = 0; d_ind < qp->total_dequeue; d_ind++) {
512                         nb_matches = qp->ops[d_ind % actual_jobs]->nb_matches;
513                         qp->total_matches += nb_matches;
514                         match = qp->ops[d_ind % actual_jobs]->matches;
515                         for (i = 0; i < nb_matches; i++) {
516                                 printf("start = %ld, len = %d, rule = %d\n",
517                                                 match->start_offset +
518                                                 d_ind * job_len,
519                                                 match->len, match->rule_id);
520                                 match++;
521                         }
522                 }
523         }
524 end:
525         for (qp_id = 0; qp_id < qps_used; qp_id++) {
526                 qp = &qps[qp_id];
527                 for (i = 0; i < actual_jobs && qp->ops; i++)
528                         rte_free(qp->ops[i]);
529                 rte_free(qp->ops);
530                 qp->ops = NULL;
531                 for (i = 0; i < actual_jobs && qp->jobs_ctx; i++)
532                         rte_pktmbuf_free(qp->jobs_ctx[i].mbuf);
533                 rte_free(qp->jobs_ctx);
534                 qp->jobs_ctx = NULL;
535                 rte_free(qp->buf);
536                 qp->buf = NULL;
537         }
538         if (mbuf_mp)
539                 rte_mempool_free(mbuf_mp);
540         rte_free(qps);
541         return res;
542 }
543
544 static int
545 distribute_qps_to_lcores(uint32_t nb_cores, uint32_t nb_qps,
546                          struct qps_per_lcore **qpl)
547 {
548         int socket;
549         unsigned lcore_id;
550         uint32_t i;
551         uint16_t min_qp_id;
552         uint16_t max_qp_id;
553         struct qps_per_lcore *qps_per_lcore;
554         uint32_t detected_lcores;
555
556         if (nb_qps < nb_cores) {
557                 nb_cores = nb_qps;
558                 printf("Reducing number of cores to number of QPs (%u)\n",
559                        nb_cores);
560         }
561         /* Allocate qps_per_lcore array */
562         qps_per_lcore =
563                 rte_malloc(NULL, sizeof(*qps_per_lcore) * nb_cores, 0);
564         if (!qps_per_lcore)
565                 rte_exit(EXIT_FAILURE, "Failed to create qps_per_lcore array\n");
566         *qpl = qps_per_lcore;
567         detected_lcores = 0;
568         min_qp_id = 0;
569
570         RTE_LCORE_FOREACH_WORKER(lcore_id) {
571                 if (detected_lcores >= nb_cores)
572                         break;
573                 qps_per_lcore[detected_lcores].lcore_id = lcore_id;
574                 socket = rte_lcore_to_socket_id(lcore_id);
575                 if (socket == SOCKET_ID_ANY)
576                         socket = 0;
577                 qps_per_lcore[detected_lcores].socket = socket;
578                 qps_per_lcore[detected_lcores].qp_id_base = min_qp_id;
579                 max_qp_id = min_qp_id + nb_qps / nb_cores - 1;
580                 if (nb_qps % nb_cores > detected_lcores)
581                         max_qp_id++;
582                 qps_per_lcore[detected_lcores].nb_qps = max_qp_id -
583                                                         min_qp_id + 1;
584                 min_qp_id = max_qp_id + 1;
585                 detected_lcores++;
586         }
587         if (detected_lcores != nb_cores)
588                 return -1;
589
590         for (i = 0; i < detected_lcores; i++) {
591                 printf("===> Core %d: allocated queues: ",
592                        qps_per_lcore[i].lcore_id);
593                 min_qp_id = qps_per_lcore[i].qp_id_base;
594                 max_qp_id =
595                         qps_per_lcore[i].qp_id_base + qps_per_lcore[i].nb_qps;
596                 while (min_qp_id < max_qp_id) {
597                         printf("%u ", min_qp_id);
598                         min_qp_id++;
599                 }
600                 printf("\n");
601         }
602         return 0;
603 }
604
605 int
606 main(int argc, char **argv)
607 {
608         char rules_file[MAX_FILE_NAME];
609         char data_file[MAX_FILE_NAME];
610         uint32_t nb_jobs = 0;
611         bool perf_mode = 0;
612         uint32_t nb_iterations = 0;
613         int ret;
614         uint16_t nb_max_payload = 0;
615         uint8_t nb_max_matches = 0;
616         uint32_t nb_qps = 1;
617         char *data_buf;
618         long data_len;
619         long job_len;
620         uint32_t nb_lcores = 1;
621         struct regex_conf *rgxc;
622         uint32_t i;
623         struct qps_per_lcore *qps_per_lcore;
624
625         /* Init EAL. */
626         ret = rte_eal_init(argc, argv);
627         if (ret < 0)
628                 rte_exit(EXIT_FAILURE, "EAL init failed\n");
629         argc -= ret;
630         argv += ret;
631         if (argc > 1)
632                 args_parse(argc, argv, rules_file, data_file, &nb_jobs,
633                                 &perf_mode, &nb_iterations, &nb_qps,
634                                 &nb_lcores);
635
636         if (nb_qps == 0)
637                 rte_exit(EXIT_FAILURE, "Number of QPs must be greater than 0\n");
638         if (nb_lcores == 0)
639                 rte_exit(EXIT_FAILURE, "Number of lcores must be greater than 0\n");
640         if (distribute_qps_to_lcores(nb_lcores, nb_qps, &qps_per_lcore) < 0)
641                 rte_exit(EXIT_FAILURE, "Failed to distribute queues to lcores!\n");
642         ret = init_port(&nb_max_payload, rules_file,
643                         &nb_max_matches, nb_qps);
644         if (ret < 0)
645                 rte_exit(EXIT_FAILURE, "init port failed\n");
646
647         data_len = read_file(data_file, &data_buf);
648         if (data_len <= 0)
649                 rte_exit(EXIT_FAILURE, "Error, can't read file, or file is empty.\n");
650
651         job_len = data_len / nb_jobs;
652         if (job_len == 0)
653                 rte_exit(EXIT_FAILURE, "Error, To many jobs, for the given input.\n");
654
655         if (job_len > nb_max_payload)
656                 rte_exit(EXIT_FAILURE, "Error, not enough jobs to cover input.\n");
657
658         rgxc = rte_malloc(NULL, sizeof(*rgxc) * nb_lcores, 0);
659         if (!rgxc)
660                 rte_exit(EXIT_FAILURE, "Failed to create Regex Conf\n");
661         for (i = 0; i < nb_lcores; i++) {
662                 rgxc[i] = (struct regex_conf){
663                         .nb_jobs = nb_jobs,
664                         .perf_mode = perf_mode,
665                         .nb_iterations = nb_iterations,
666                         .nb_max_matches = nb_max_matches,
667                         .nb_qps = qps_per_lcore[i].nb_qps,
668                         .qp_id_base = qps_per_lcore[i].qp_id_base,
669                         .data_buf = data_buf,
670                         .data_len = data_len,
671                         .job_len = job_len,
672                 };
673                 rte_eal_remote_launch(run_regex, &rgxc[i],
674                                       qps_per_lcore[i].lcore_id);
675         }
676         rte_eal_mp_wait_lcore();
677         rte_free(data_buf);
678         rte_free(rgxc);
679         rte_free(qps_per_lcore);
680         return EXIT_SUCCESS;
681 }