]> git.proxmox.com Git - ceph.git/blob - ceph/src/dpdk/examples/ip_pipeline/app.h
bump version to 12.2.12-pve1
[ceph.git] / ceph / src / dpdk / examples / ip_pipeline / app.h
1 /*-
2 * BSD LICENSE
3 *
4 * Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 #ifndef __INCLUDE_APP_H__
35 #define __INCLUDE_APP_H__
36
37 #include <stdint.h>
38 #include <string.h>
39
40 #include <rte_common.h>
41 #include <rte_mempool.h>
42 #include <rte_ring.h>
43 #include <rte_sched.h>
44 #include <cmdline_parse.h>
45
46 #include <rte_ethdev.h>
47 #ifdef RTE_LIBRTE_KNI
48 #include <rte_kni.h>
49 #endif
50
51 #include "cpu_core_map.h"
52 #include "pipeline.h"
53
54 #define APP_PARAM_NAME_SIZE PIPELINE_NAME_SIZE
55 #define APP_LINK_PCI_BDF_SIZE 16
56
57 #ifndef APP_LINK_MAX_HWQ_IN
58 #define APP_LINK_MAX_HWQ_IN 128
59 #endif
60
61 #ifndef APP_LINK_MAX_HWQ_OUT
62 #define APP_LINK_MAX_HWQ_OUT 128
63 #endif
64
65 struct app_mempool_params {
66 char *name;
67 uint32_t parsed;
68 uint32_t buffer_size;
69 uint32_t pool_size;
70 uint32_t cache_size;
71 uint32_t cpu_socket_id;
72 };
73
74 struct app_link_params {
75 char *name;
76 uint32_t parsed;
77 uint32_t pmd_id; /* Generated based on port mask */
78 uint32_t arp_q; /* 0 = Disabled (packets go to default queue 0) */
79 uint32_t tcp_syn_q; /* 0 = Disabled (pkts go to default queue) */
80 uint32_t ip_local_q; /* 0 = Disabled (pkts go to default queue 0) */
81 uint32_t tcp_local_q; /* 0 = Disabled (pkts go to default queue 0) */
82 uint32_t udp_local_q; /* 0 = Disabled (pkts go to default queue 0) */
83 uint32_t sctp_local_q; /* 0 = Disabled (pkts go to default queue 0) */
84 uint32_t rss_qs[APP_LINK_MAX_HWQ_IN];
85 uint32_t n_rss_qs;
86 uint64_t rss_proto_ipv4;
87 uint64_t rss_proto_ipv6;
88 uint64_t rss_proto_l2;
89 uint32_t promisc;
90 uint32_t state; /* DOWN = 0, UP = 1 */
91 uint32_t ip; /* 0 = Invalid */
92 uint32_t depth; /* Valid only when IP is valid */
93 uint64_t mac_addr; /* Read from HW */
94 char pci_bdf[APP_LINK_PCI_BDF_SIZE];
95
96 struct rte_eth_conf conf;
97 };
98
99 struct app_pktq_hwq_in_params {
100 char *name;
101 uint32_t parsed;
102 uint32_t mempool_id; /* Position in the app->mempool_params */
103 uint32_t size;
104 uint32_t burst;
105
106 struct rte_eth_rxconf conf;
107 };
108
109 struct app_pktq_hwq_out_params {
110 char *name;
111 uint32_t parsed;
112 uint32_t size;
113 uint32_t burst;
114 uint32_t dropless;
115 uint64_t n_retries;
116 struct rte_eth_txconf conf;
117 };
118
119 struct app_pktq_swq_params {
120 char *name;
121 uint32_t parsed;
122 uint32_t size;
123 uint32_t burst_read;
124 uint32_t burst_write;
125 uint32_t dropless;
126 uint64_t n_retries;
127 uint32_t cpu_socket_id;
128 uint32_t ipv4_frag;
129 uint32_t ipv6_frag;
130 uint32_t ipv4_ras;
131 uint32_t ipv6_ras;
132 uint32_t mtu;
133 uint32_t metadata_size;
134 uint32_t mempool_direct_id;
135 uint32_t mempool_indirect_id;
136 };
137
138 struct app_pktq_kni_params {
139 char *name;
140 uint32_t parsed;
141
142 uint32_t socket_id;
143 uint32_t core_id;
144 uint32_t hyper_th_id;
145 uint32_t force_bind;
146
147 uint32_t mempool_id; /* Position in the app->mempool_params */
148 uint32_t burst_read;
149 uint32_t burst_write;
150 uint32_t dropless;
151 uint64_t n_retries;
152 };
153
154 #ifndef APP_FILE_NAME_SIZE
155 #define APP_FILE_NAME_SIZE 256
156 #endif
157
158 #ifndef APP_MAX_SCHED_SUBPORTS
159 #define APP_MAX_SCHED_SUBPORTS 8
160 #endif
161
162 #ifndef APP_MAX_SCHED_PIPES
163 #define APP_MAX_SCHED_PIPES 4096
164 #endif
165
166 struct app_pktq_tm_params {
167 char *name;
168 uint32_t parsed;
169 const char *file_name;
170 struct rte_sched_port_params sched_port_params;
171 struct rte_sched_subport_params
172 sched_subport_params[APP_MAX_SCHED_SUBPORTS];
173 struct rte_sched_pipe_params
174 sched_pipe_profiles[RTE_SCHED_PIPE_PROFILES_PER_PORT];
175 int sched_pipe_to_profile[APP_MAX_SCHED_SUBPORTS * APP_MAX_SCHED_PIPES];
176 uint32_t burst_read;
177 uint32_t burst_write;
178 };
179
180 struct app_pktq_tap_params {
181 char *name;
182 uint32_t parsed;
183 uint32_t burst_read;
184 uint32_t burst_write;
185 uint32_t dropless;
186 uint64_t n_retries;
187 uint32_t mempool_id; /* Position in the app->mempool_params */
188 };
189
190 struct app_pktq_source_params {
191 char *name;
192 uint32_t parsed;
193 uint32_t mempool_id; /* Position in the app->mempool_params array */
194 uint32_t burst;
195 const char *file_name; /* Full path of PCAP file to be copied to mbufs */
196 uint32_t n_bytes_per_pkt;
197 };
198
199 struct app_pktq_sink_params {
200 char *name;
201 uint8_t parsed;
202 const char *file_name; /* Full path of PCAP file to be copied to mbufs */
203 uint32_t n_pkts_to_dump;
204 };
205
206 struct app_msgq_params {
207 char *name;
208 uint32_t parsed;
209 uint32_t size;
210 uint32_t cpu_socket_id;
211 };
212
213 enum app_pktq_in_type {
214 APP_PKTQ_IN_HWQ,
215 APP_PKTQ_IN_SWQ,
216 APP_PKTQ_IN_TM,
217 APP_PKTQ_IN_TAP,
218 APP_PKTQ_IN_KNI,
219 APP_PKTQ_IN_SOURCE,
220 };
221
222 struct app_pktq_in_params {
223 enum app_pktq_in_type type;
224 uint32_t id; /* Position in the appropriate app array */
225 };
226
227 enum app_pktq_out_type {
228 APP_PKTQ_OUT_HWQ,
229 APP_PKTQ_OUT_SWQ,
230 APP_PKTQ_OUT_TM,
231 APP_PKTQ_OUT_TAP,
232 APP_PKTQ_OUT_KNI,
233 APP_PKTQ_OUT_SINK,
234 };
235
236 struct app_pktq_out_params {
237 enum app_pktq_out_type type;
238 uint32_t id; /* Position in the appropriate app array */
239 };
240
241 #define APP_PIPELINE_TYPE_SIZE PIPELINE_TYPE_SIZE
242
243 #define APP_MAX_PIPELINE_PKTQ_IN PIPELINE_MAX_PORT_IN
244 #define APP_MAX_PIPELINE_PKTQ_OUT PIPELINE_MAX_PORT_OUT
245 #define APP_MAX_PIPELINE_MSGQ_IN PIPELINE_MAX_MSGQ_IN
246 #define APP_MAX_PIPELINE_MSGQ_OUT PIPELINE_MAX_MSGQ_OUT
247
248 #define APP_MAX_PIPELINE_ARGS PIPELINE_MAX_ARGS
249
250 struct app_pipeline_params {
251 char *name;
252 uint8_t parsed;
253
254 char type[APP_PIPELINE_TYPE_SIZE];
255
256 uint32_t socket_id;
257 uint32_t core_id;
258 uint32_t hyper_th_id;
259
260 struct app_pktq_in_params pktq_in[APP_MAX_PIPELINE_PKTQ_IN];
261 struct app_pktq_out_params pktq_out[APP_MAX_PIPELINE_PKTQ_OUT];
262 uint32_t msgq_in[APP_MAX_PIPELINE_MSGQ_IN];
263 uint32_t msgq_out[APP_MAX_PIPELINE_MSGQ_OUT];
264
265 uint32_t n_pktq_in;
266 uint32_t n_pktq_out;
267 uint32_t n_msgq_in;
268 uint32_t n_msgq_out;
269
270 uint32_t timer_period;
271
272 char *args_name[APP_MAX_PIPELINE_ARGS];
273 char *args_value[APP_MAX_PIPELINE_ARGS];
274 uint32_t n_args;
275 };
276
277 struct app_params;
278
279 typedef void (*app_link_op)(struct app_params *app,
280 uint32_t link_id,
281 uint32_t up,
282 void *arg);
283
284 #ifndef APP_MAX_PIPELINES
285 #define APP_MAX_PIPELINES 64
286 #endif
287
288 struct app_link_data {
289 app_link_op f_link[APP_MAX_PIPELINES];
290 void *arg[APP_MAX_PIPELINES];
291 };
292
293 struct app_pipeline_data {
294 void *be;
295 void *fe;
296 struct pipeline_type *ptype;
297 uint64_t timer_period;
298 uint32_t enabled;
299 };
300
301 struct app_thread_pipeline_data {
302 uint32_t pipeline_id;
303 void *be;
304 pipeline_be_op_run f_run;
305 pipeline_be_op_timer f_timer;
306 uint64_t timer_period;
307 uint64_t deadline;
308 };
309
310 #ifndef APP_MAX_THREAD_PIPELINES
311 #define APP_MAX_THREAD_PIPELINES 64
312 #endif
313
314 #ifndef APP_THREAD_TIMER_PERIOD
315 #define APP_THREAD_TIMER_PERIOD 1
316 #endif
317
318 struct app_thread_data {
319 struct app_thread_pipeline_data regular[APP_MAX_THREAD_PIPELINES];
320 struct app_thread_pipeline_data custom[APP_MAX_THREAD_PIPELINES];
321
322 uint32_t n_regular;
323 uint32_t n_custom;
324
325 uint64_t timer_period;
326 uint64_t thread_req_deadline;
327
328 uint64_t deadline;
329
330 struct rte_ring *msgq_in;
331 struct rte_ring *msgq_out;
332
333 uint64_t headroom_time;
334 uint64_t headroom_cycles;
335 double headroom_ratio;
336 } __rte_cache_aligned;
337
338 #ifndef APP_MAX_LINKS
339 #define APP_MAX_LINKS 16
340 #endif
341
342 struct app_eal_params {
343 /* Map lcore set to physical cpu set */
344 char *coremap;
345
346 /* Core ID that is used as master */
347 uint32_t master_lcore_present;
348 uint32_t master_lcore;
349
350 /* Number of memory channels */
351 uint32_t channels_present;
352 uint32_t channels;
353
354 /* Memory to allocate (see also --socket-mem) */
355 uint32_t memory_present;
356 uint32_t memory;
357
358 /* Force number of memory ranks (don't detect) */
359 uint32_t ranks_present;
360 uint32_t ranks;
361
362 /* Add a PCI device in black list. */
363 char *pci_blacklist[APP_MAX_LINKS];
364
365 /* Add a PCI device in white list. */
366 char *pci_whitelist[APP_MAX_LINKS];
367
368 /* Add a virtual device. */
369 char *vdev[APP_MAX_LINKS];
370
371 /* Use VMware TSC map instead of native RDTSC */
372 uint32_t vmware_tsc_map_present;
373 int vmware_tsc_map;
374
375 /* Type of this process (primary|secondary|auto) */
376 char *proc_type;
377
378 /* Set syslog facility */
379 char *syslog;
380
381 /* Set default log level */
382 uint32_t log_level_present;
383 uint32_t log_level;
384
385 /* Display version information on startup */
386 uint32_t version_present;
387 int version;
388
389 /* This help */
390 uint32_t help_present;
391 int help;
392
393 /* Use malloc instead of hugetlbfs */
394 uint32_t no_huge_present;
395 int no_huge;
396
397 /* Disable PCI */
398 uint32_t no_pci_present;
399 int no_pci;
400
401 /* Disable HPET */
402 uint32_t no_hpet_present;
403 int no_hpet;
404
405 /* No shared config (mmap'd files) */
406 uint32_t no_shconf_present;
407 int no_shconf;
408
409 /* Add driver */
410 char *add_driver;
411
412 /* Memory to allocate on sockets (comma separated values)*/
413 char *socket_mem;
414
415 /* Directory where hugetlbfs is mounted */
416 char *huge_dir;
417
418 /* Prefix for hugepage filenames */
419 char *file_prefix;
420
421 /* Base virtual address */
422 char *base_virtaddr;
423
424 /* Create /dev/uioX (usually done by hotplug) */
425 uint32_t create_uio_dev_present;
426 int create_uio_dev;
427
428 /* Interrupt mode for VFIO (legacy|msi|msix) */
429 char *vfio_intr;
430
431 /* Support running on Xen dom0 without hugetlbfs */
432 uint32_t xen_dom0_present;
433 int xen_dom0;
434
435 uint32_t parsed;
436 };
437
438 #ifndef APP_APPNAME_SIZE
439 #define APP_APPNAME_SIZE 256
440 #endif
441
442 #ifndef APP_MAX_MEMPOOLS
443 #define APP_MAX_MEMPOOLS 8
444 #endif
445
446 #define APP_MAX_HWQ_IN (APP_MAX_LINKS * APP_LINK_MAX_HWQ_IN)
447
448 #define APP_MAX_HWQ_OUT (APP_MAX_LINKS * APP_LINK_MAX_HWQ_OUT)
449
450 #ifndef APP_MAX_PKTQ_SWQ
451 #define APP_MAX_PKTQ_SWQ 256
452 #endif
453
454 #define APP_MAX_PKTQ_TM APP_MAX_LINKS
455
456 #ifndef APP_MAX_PKTQ_TAP
457 #define APP_MAX_PKTQ_TAP APP_MAX_LINKS
458 #endif
459
460 #define APP_MAX_PKTQ_KNI APP_MAX_LINKS
461
462 #ifndef APP_MAX_PKTQ_SOURCE
463 #define APP_MAX_PKTQ_SOURCE 64
464 #endif
465
466 #ifndef APP_MAX_PKTQ_SINK
467 #define APP_MAX_PKTQ_SINK 64
468 #endif
469
470 #ifndef APP_MAX_MSGQ
471 #define APP_MAX_MSGQ 256
472 #endif
473
474 #ifndef APP_EAL_ARGC
475 #define APP_EAL_ARGC 64
476 #endif
477
478 #ifndef APP_MAX_PIPELINE_TYPES
479 #define APP_MAX_PIPELINE_TYPES 64
480 #endif
481
482 #ifndef APP_MAX_THREADS
483 #define APP_MAX_THREADS RTE_MAX_LCORE
484 #endif
485
486 #ifndef APP_MAX_CMDS
487 #define APP_MAX_CMDS 64
488 #endif
489
490 #ifndef APP_THREAD_HEADROOM_STATS_COLLECT
491 #define APP_THREAD_HEADROOM_STATS_COLLECT 1
492 #endif
493
494 struct app_params {
495 /* Config */
496 char app_name[APP_APPNAME_SIZE];
497 const char *config_file;
498 const char *script_file;
499 const char *parser_file;
500 const char *output_file;
501 const char *preproc;
502 const char *preproc_args;
503 uint64_t port_mask;
504 uint32_t log_level;
505
506 struct app_eal_params eal_params;
507 struct app_mempool_params mempool_params[APP_MAX_MEMPOOLS];
508 struct app_link_params link_params[APP_MAX_LINKS];
509 struct app_pktq_hwq_in_params hwq_in_params[APP_MAX_HWQ_IN];
510 struct app_pktq_hwq_out_params hwq_out_params[APP_MAX_HWQ_OUT];
511 struct app_pktq_swq_params swq_params[APP_MAX_PKTQ_SWQ];
512 struct app_pktq_tm_params tm_params[APP_MAX_PKTQ_TM];
513 struct app_pktq_tap_params tap_params[APP_MAX_PKTQ_TAP];
514 struct app_pktq_kni_params kni_params[APP_MAX_PKTQ_KNI];
515 struct app_pktq_source_params source_params[APP_MAX_PKTQ_SOURCE];
516 struct app_pktq_sink_params sink_params[APP_MAX_PKTQ_SINK];
517 struct app_msgq_params msgq_params[APP_MAX_MSGQ];
518 struct app_pipeline_params pipeline_params[APP_MAX_PIPELINES];
519
520 uint32_t n_mempools;
521 uint32_t n_links;
522 uint32_t n_pktq_hwq_in;
523 uint32_t n_pktq_hwq_out;
524 uint32_t n_pktq_swq;
525 uint32_t n_pktq_tm;
526 uint32_t n_pktq_tap;
527 uint32_t n_pktq_kni;
528 uint32_t n_pktq_source;
529 uint32_t n_pktq_sink;
530 uint32_t n_msgq;
531 uint32_t n_pipelines;
532
533 /* Init */
534 char *eal_argv[1 + APP_EAL_ARGC];
535 struct cpu_core_map *core_map;
536 uint64_t core_mask;
537 struct rte_mempool *mempool[APP_MAX_MEMPOOLS];
538 struct app_link_data link_data[APP_MAX_LINKS];
539 struct rte_ring *swq[APP_MAX_PKTQ_SWQ];
540 struct rte_sched_port *tm[APP_MAX_PKTQ_TM];
541 int tap[APP_MAX_PKTQ_TAP];
542 #ifdef RTE_LIBRTE_KNI
543 struct rte_kni *kni[APP_MAX_PKTQ_KNI];
544 #endif /* RTE_LIBRTE_KNI */
545 struct rte_ring *msgq[APP_MAX_MSGQ];
546 struct pipeline_type pipeline_type[APP_MAX_PIPELINE_TYPES];
547 struct app_pipeline_data pipeline_data[APP_MAX_PIPELINES];
548 struct app_thread_data thread_data[APP_MAX_THREADS];
549 cmdline_parse_ctx_t cmds[APP_MAX_CMDS + 1];
550
551 int eal_argc;
552 uint32_t n_pipeline_types;
553 uint32_t n_cmds;
554 };
555
556 #define APP_PARAM_VALID(obj) ((obj)->name != NULL)
557
558 #define APP_PARAM_COUNT(obj_array, n_objs) \
559 { \
560 size_t i; \
561 \
562 n_objs = 0; \
563 for (i = 0; i < RTE_DIM(obj_array); i++) \
564 if (APP_PARAM_VALID(&((obj_array)[i]))) \
565 n_objs++; \
566 }
567
568 #define APP_PARAM_FIND(obj_array, key) \
569 ({ \
570 ssize_t obj_idx; \
571 const ssize_t obj_count = RTE_DIM(obj_array); \
572 \
573 for (obj_idx = 0; obj_idx < obj_count; obj_idx++) { \
574 if (!APP_PARAM_VALID(&((obj_array)[obj_idx]))) \
575 continue; \
576 \
577 if (strcmp(key, (obj_array)[obj_idx].name) == 0) \
578 break; \
579 } \
580 obj_idx < obj_count ? obj_idx : -ENOENT; \
581 })
582
583 #define APP_PARAM_FIND_BY_ID(obj_array, prefix, id, obj) \
584 do { \
585 char name[APP_PARAM_NAME_SIZE]; \
586 ssize_t pos; \
587 \
588 sprintf(name, prefix "%" PRIu32, id); \
589 pos = APP_PARAM_FIND(obj_array, name); \
590 obj = (pos < 0) ? NULL : &((obj_array)[pos]); \
591 } while (0)
592
593 #define APP_PARAM_GET_ID(obj, prefix, id) \
594 do \
595 sscanf(obj->name, prefix "%" SCNu32, &id); \
596 while (0) \
597
598 #define APP_CHECK(exp, fmt, ...) \
599 do { \
600 if (!(exp)) { \
601 fprintf(stderr, fmt "\n", ## __VA_ARGS__); \
602 abort(); \
603 } \
604 } while (0)
605
606 enum app_log_level {
607 APP_LOG_LEVEL_HIGH = 1,
608 APP_LOG_LEVEL_LOW,
609 APP_LOG_LEVELS
610 };
611
612 #define APP_LOG(app, level, fmt, ...) \
613 do { \
614 if (app->log_level >= APP_LOG_LEVEL_ ## level) \
615 fprintf(stdout, "[APP] " fmt "\n", ## __VA_ARGS__); \
616 } while (0)
617
618 static inline uint32_t
619 app_link_get_n_rxq(struct app_params *app, struct app_link_params *link)
620 {
621 uint32_t n_rxq = 0, link_id, i;
622 uint32_t n_pktq_hwq_in = RTE_MIN(app->n_pktq_hwq_in,
623 RTE_DIM(app->hwq_in_params));
624
625 APP_PARAM_GET_ID(link, "LINK", link_id);
626
627 for (i = 0; i < n_pktq_hwq_in; i++) {
628 struct app_pktq_hwq_in_params *p = &app->hwq_in_params[i];
629 uint32_t rxq_link_id, rxq_queue_id;
630
631 sscanf(p->name, "RXQ%" SCNu32 ".%" SCNu32,
632 &rxq_link_id, &rxq_queue_id);
633 if (rxq_link_id == link_id)
634 n_rxq++;
635 }
636
637 return n_rxq;
638 }
639
640 static inline uint32_t
641 app_link_get_n_txq(struct app_params *app, struct app_link_params *link)
642 {
643 uint32_t n_txq = 0, link_id, i;
644 uint32_t n_pktq_hwq_out = RTE_MIN(app->n_pktq_hwq_out,
645 RTE_DIM(app->hwq_out_params));
646
647 APP_PARAM_GET_ID(link, "LINK", link_id);
648
649 for (i = 0; i < n_pktq_hwq_out; i++) {
650 struct app_pktq_hwq_out_params *p = &app->hwq_out_params[i];
651 uint32_t txq_link_id, txq_queue_id;
652
653 sscanf(p->name, "TXQ%" SCNu32 ".%" SCNu32,
654 &txq_link_id, &txq_queue_id);
655 if (txq_link_id == link_id)
656 n_txq++;
657 }
658
659 return n_txq;
660 }
661
662 static inline uint32_t
663 app_rxq_get_readers(struct app_params *app, struct app_pktq_hwq_in_params *rxq)
664 {
665 uint32_t pos = rxq - app->hwq_in_params;
666 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
667 RTE_DIM(app->pipeline_params));
668 uint32_t n_readers = 0, i;
669
670 for (i = 0; i < n_pipelines; i++) {
671 struct app_pipeline_params *p = &app->pipeline_params[i];
672 uint32_t n_pktq_in = RTE_MIN(p->n_pktq_in, RTE_DIM(p->pktq_in));
673 uint32_t j;
674
675 for (j = 0; j < n_pktq_in; j++) {
676 struct app_pktq_in_params *pktq = &p->pktq_in[j];
677
678 if ((pktq->type == APP_PKTQ_IN_HWQ) &&
679 (pktq->id == pos))
680 n_readers++;
681 }
682 }
683
684 return n_readers;
685 }
686
687 static inline uint32_t
688 app_swq_get_readers(struct app_params *app, struct app_pktq_swq_params *swq)
689 {
690 uint32_t pos = swq - app->swq_params;
691 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
692 RTE_DIM(app->pipeline_params));
693 uint32_t n_readers = 0, i;
694
695 for (i = 0; i < n_pipelines; i++) {
696 struct app_pipeline_params *p = &app->pipeline_params[i];
697 uint32_t n_pktq_in = RTE_MIN(p->n_pktq_in, RTE_DIM(p->pktq_in));
698 uint32_t j;
699
700 for (j = 0; j < n_pktq_in; j++) {
701 struct app_pktq_in_params *pktq = &p->pktq_in[j];
702
703 if ((pktq->type == APP_PKTQ_IN_SWQ) &&
704 (pktq->id == pos))
705 n_readers++;
706 }
707 }
708
709 return n_readers;
710 }
711
712 static inline struct app_pipeline_params *
713 app_swq_get_reader(struct app_params *app,
714 struct app_pktq_swq_params *swq,
715 uint32_t *pktq_in_id)
716 {
717 struct app_pipeline_params *reader = NULL;
718 uint32_t pos = swq - app->swq_params;
719 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
720 RTE_DIM(app->pipeline_params));
721 uint32_t n_readers = 0, id = 0, i;
722
723 for (i = 0; i < n_pipelines; i++) {
724 struct app_pipeline_params *p = &app->pipeline_params[i];
725 uint32_t n_pktq_in = RTE_MIN(p->n_pktq_in, RTE_DIM(p->pktq_in));
726 uint32_t j;
727
728 for (j = 0; j < n_pktq_in; j++) {
729 struct app_pktq_in_params *pktq = &p->pktq_in[j];
730
731 if ((pktq->type == APP_PKTQ_IN_SWQ) &&
732 (pktq->id == pos)) {
733 n_readers++;
734 reader = p;
735 id = j;
736 }
737 }
738 }
739
740 if (n_readers != 1)
741 return NULL;
742
743 *pktq_in_id = id;
744 return reader;
745 }
746
747 static inline uint32_t
748 app_tm_get_readers(struct app_params *app, struct app_pktq_tm_params *tm)
749 {
750 uint32_t pos = tm - app->tm_params;
751 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
752 RTE_DIM(app->pipeline_params));
753 uint32_t n_readers = 0, i;
754
755 for (i = 0; i < n_pipelines; i++) {
756 struct app_pipeline_params *p = &app->pipeline_params[i];
757 uint32_t n_pktq_in = RTE_MIN(p->n_pktq_in, RTE_DIM(p->pktq_in));
758 uint32_t j;
759
760 for (j = 0; j < n_pktq_in; j++) {
761 struct app_pktq_in_params *pktq = &p->pktq_in[j];
762
763 if ((pktq->type == APP_PKTQ_IN_TM) &&
764 (pktq->id == pos))
765 n_readers++;
766 }
767 }
768
769 return n_readers;
770 }
771
772 static inline struct app_pipeline_params *
773 app_tm_get_reader(struct app_params *app,
774 struct app_pktq_tm_params *tm,
775 uint32_t *pktq_in_id)
776 {
777 struct app_pipeline_params *reader = NULL;
778 uint32_t pos = tm - app->tm_params;
779 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
780 RTE_DIM(app->pipeline_params));
781 uint32_t n_readers = 0, id = 0, i;
782
783 for (i = 0; i < n_pipelines; i++) {
784 struct app_pipeline_params *p = &app->pipeline_params[i];
785 uint32_t n_pktq_in = RTE_MIN(p->n_pktq_in, RTE_DIM(p->pktq_in));
786 uint32_t j;
787
788 for (j = 0; j < n_pktq_in; j++) {
789 struct app_pktq_in_params *pktq = &p->pktq_in[j];
790
791 if ((pktq->type == APP_PKTQ_IN_TM) &&
792 (pktq->id == pos)) {
793 n_readers++;
794 reader = p;
795 id = j;
796 }
797 }
798 }
799
800 if (n_readers != 1)
801 return NULL;
802
803 *pktq_in_id = id;
804 return reader;
805 }
806
807 static inline uint32_t
808 app_tap_get_readers(struct app_params *app, struct app_pktq_tap_params *tap)
809 {
810 uint32_t pos = tap - app->tap_params;
811 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
812 RTE_DIM(app->pipeline_params));
813 uint32_t n_readers = 0, i;
814
815 for (i = 0; i < n_pipelines; i++) {
816 struct app_pipeline_params *p = &app->pipeline_params[i];
817 uint32_t n_pktq_in = RTE_MIN(p->n_pktq_in, RTE_DIM(p->pktq_in));
818 uint32_t j;
819
820 for (j = 0; j < n_pktq_in; j++) {
821 struct app_pktq_in_params *pktq = &p->pktq_in[j];
822
823 if ((pktq->type == APP_PKTQ_IN_TAP) &&
824 (pktq->id == pos))
825 n_readers++;
826 }
827 }
828
829 return n_readers;
830 }
831
832 static inline struct app_pipeline_params *
833 app_tap_get_reader(struct app_params *app,
834 struct app_pktq_tap_params *tap,
835 uint32_t *pktq_in_id)
836 {
837 struct app_pipeline_params *reader = NULL;
838 uint32_t pos = tap - app->tap_params;
839 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
840 RTE_DIM(app->pipeline_params));
841 uint32_t n_readers = 0, id = 0, i;
842
843 for (i = 0; i < n_pipelines; i++) {
844 struct app_pipeline_params *p = &app->pipeline_params[i];
845 uint32_t n_pktq_in = RTE_MIN(p->n_pktq_in, RTE_DIM(p->pktq_in));
846 uint32_t j;
847
848 for (j = 0; j < n_pktq_in; j++) {
849 struct app_pktq_in_params *pktq = &p->pktq_in[j];
850
851 if ((pktq->type == APP_PKTQ_IN_TAP) &&
852 (pktq->id == pos)) {
853 n_readers++;
854 reader = p;
855 id = j;
856 }
857 }
858 }
859
860 if (n_readers != 1)
861 return NULL;
862
863 *pktq_in_id = id;
864 return reader;
865 }
866
867 static inline uint32_t
868 app_kni_get_readers(struct app_params *app, struct app_pktq_kni_params *kni)
869 {
870 uint32_t pos = kni - app->kni_params;
871 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
872 RTE_DIM(app->pipeline_params));
873 uint32_t n_readers = 0, i;
874
875 for (i = 0; i < n_pipelines; i++) {
876 struct app_pipeline_params *p = &app->pipeline_params[i];
877 uint32_t n_pktq_in = RTE_MIN(p->n_pktq_in, RTE_DIM(p->pktq_in));
878 uint32_t j;
879
880 for (j = 0; j < n_pktq_in; j++) {
881 struct app_pktq_in_params *pktq = &p->pktq_in[j];
882
883 if ((pktq->type == APP_PKTQ_IN_KNI) &&
884 (pktq->id == pos))
885 n_readers++;
886 }
887 }
888
889 return n_readers;
890 }
891
892 static inline struct app_pipeline_params *
893 app_kni_get_reader(struct app_params *app,
894 struct app_pktq_kni_params *kni,
895 uint32_t *pktq_in_id)
896 {
897 struct app_pipeline_params *reader = NULL;
898 uint32_t pos = kni - app->kni_params;
899 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
900 RTE_DIM(app->pipeline_params));
901 uint32_t n_readers = 0, id = 0, i;
902
903 for (i = 0; i < n_pipelines; i++) {
904 struct app_pipeline_params *p = &app->pipeline_params[i];
905 uint32_t n_pktq_in = RTE_MIN(p->n_pktq_in, RTE_DIM(p->pktq_in));
906 uint32_t j;
907
908 for (j = 0; j < n_pktq_in; j++) {
909 struct app_pktq_in_params *pktq = &p->pktq_in[j];
910
911 if ((pktq->type == APP_PKTQ_IN_KNI) &&
912 (pktq->id == pos)) {
913 n_readers++;
914 reader = p;
915 id = j;
916 }
917 }
918 }
919
920 if (n_readers != 1)
921 return NULL;
922
923 *pktq_in_id = id;
924 return reader;
925 }
926
927 static inline uint32_t
928 app_source_get_readers(struct app_params *app,
929 struct app_pktq_source_params *source)
930 {
931 uint32_t pos = source - app->source_params;
932 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
933 RTE_DIM(app->pipeline_params));
934 uint32_t n_readers = 0, i;
935
936 for (i = 0; i < n_pipelines; i++) {
937 struct app_pipeline_params *p = &app->pipeline_params[i];
938 uint32_t n_pktq_in = RTE_MIN(p->n_pktq_in, RTE_DIM(p->pktq_in));
939 uint32_t j;
940
941 for (j = 0; j < n_pktq_in; j++) {
942 struct app_pktq_in_params *pktq = &p->pktq_in[j];
943
944 if ((pktq->type == APP_PKTQ_IN_SOURCE) &&
945 (pktq->id == pos))
946 n_readers++;
947 }
948 }
949
950 return n_readers;
951 }
952
953 static inline uint32_t
954 app_msgq_get_readers(struct app_params *app, struct app_msgq_params *msgq)
955 {
956 uint32_t pos = msgq - app->msgq_params;
957 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
958 RTE_DIM(app->pipeline_params));
959 uint32_t n_readers = 0, i;
960
961 for (i = 0; i < n_pipelines; i++) {
962 struct app_pipeline_params *p = &app->pipeline_params[i];
963 uint32_t n_msgq_in = RTE_MIN(p->n_msgq_in, RTE_DIM(p->msgq_in));
964 uint32_t j;
965
966 for (j = 0; j < n_msgq_in; j++)
967 if (p->msgq_in[j] == pos)
968 n_readers++;
969 }
970
971 return n_readers;
972 }
973
974 static inline uint32_t
975 app_txq_get_writers(struct app_params *app, struct app_pktq_hwq_out_params *txq)
976 {
977 uint32_t pos = txq - app->hwq_out_params;
978 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
979 RTE_DIM(app->pipeline_params));
980 uint32_t n_writers = 0, i;
981
982 for (i = 0; i < n_pipelines; i++) {
983 struct app_pipeline_params *p = &app->pipeline_params[i];
984 uint32_t n_pktq_out = RTE_MIN(p->n_pktq_out,
985 RTE_DIM(p->pktq_out));
986 uint32_t j;
987
988 for (j = 0; j < n_pktq_out; j++) {
989 struct app_pktq_out_params *pktq = &p->pktq_out[j];
990
991 if ((pktq->type == APP_PKTQ_OUT_HWQ) &&
992 (pktq->id == pos))
993 n_writers++;
994 }
995 }
996
997 return n_writers;
998 }
999
1000 static inline uint32_t
1001 app_swq_get_writers(struct app_params *app, struct app_pktq_swq_params *swq)
1002 {
1003 uint32_t pos = swq - app->swq_params;
1004 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
1005 RTE_DIM(app->pipeline_params));
1006 uint32_t n_writers = 0, i;
1007
1008 for (i = 0; i < n_pipelines; i++) {
1009 struct app_pipeline_params *p = &app->pipeline_params[i];
1010 uint32_t n_pktq_out = RTE_MIN(p->n_pktq_out,
1011 RTE_DIM(p->pktq_out));
1012 uint32_t j;
1013
1014 for (j = 0; j < n_pktq_out; j++) {
1015 struct app_pktq_out_params *pktq = &p->pktq_out[j];
1016
1017 if ((pktq->type == APP_PKTQ_OUT_SWQ) &&
1018 (pktq->id == pos))
1019 n_writers++;
1020 }
1021 }
1022
1023 return n_writers;
1024 }
1025
1026 static inline struct app_pipeline_params *
1027 app_swq_get_writer(struct app_params *app,
1028 struct app_pktq_swq_params *swq,
1029 uint32_t *pktq_out_id)
1030 {
1031 struct app_pipeline_params *writer = NULL;
1032 uint32_t pos = swq - app->swq_params;
1033 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
1034 RTE_DIM(app->pipeline_params));
1035 uint32_t n_writers = 0, id = 0, i;
1036
1037 for (i = 0; i < n_pipelines; i++) {
1038 struct app_pipeline_params *p = &app->pipeline_params[i];
1039 uint32_t n_pktq_out = RTE_MIN(p->n_pktq_out,
1040 RTE_DIM(p->pktq_out));
1041 uint32_t j;
1042
1043 for (j = 0; j < n_pktq_out; j++) {
1044 struct app_pktq_out_params *pktq = &p->pktq_out[j];
1045
1046 if ((pktq->type == APP_PKTQ_OUT_SWQ) &&
1047 (pktq->id == pos)) {
1048 n_writers++;
1049 writer = p;
1050 id = j;
1051 }
1052 }
1053 }
1054
1055 if (n_writers != 1)
1056 return NULL;
1057
1058 *pktq_out_id = id;
1059 return writer;
1060 }
1061
1062 static inline uint32_t
1063 app_tm_get_writers(struct app_params *app, struct app_pktq_tm_params *tm)
1064 {
1065 uint32_t pos = tm - app->tm_params;
1066 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
1067 RTE_DIM(app->pipeline_params));
1068 uint32_t n_writers = 0, i;
1069
1070 for (i = 0; i < n_pipelines; i++) {
1071 struct app_pipeline_params *p = &app->pipeline_params[i];
1072 uint32_t n_pktq_out = RTE_MIN(p->n_pktq_out,
1073 RTE_DIM(p->pktq_out));
1074 uint32_t j;
1075
1076 for (j = 0; j < n_pktq_out; j++) {
1077 struct app_pktq_out_params *pktq = &p->pktq_out[j];
1078
1079 if ((pktq->type == APP_PKTQ_OUT_TM) &&
1080 (pktq->id == pos))
1081 n_writers++;
1082 }
1083 }
1084
1085 return n_writers;
1086 }
1087
1088 static inline struct app_pipeline_params *
1089 app_tm_get_writer(struct app_params *app,
1090 struct app_pktq_tm_params *tm,
1091 uint32_t *pktq_out_id)
1092 {
1093 struct app_pipeline_params *writer = NULL;
1094 uint32_t pos = tm - app->tm_params;
1095 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
1096 RTE_DIM(app->pipeline_params));
1097 uint32_t n_writers = 0, id = 0, i;
1098
1099 for (i = 0; i < n_pipelines; i++) {
1100 struct app_pipeline_params *p = &app->pipeline_params[i];
1101 uint32_t n_pktq_out = RTE_MIN(p->n_pktq_out,
1102 RTE_DIM(p->pktq_out));
1103 uint32_t j;
1104
1105 for (j = 0; j < n_pktq_out; j++) {
1106 struct app_pktq_out_params *pktq = &p->pktq_out[j];
1107
1108 if ((pktq->type == APP_PKTQ_OUT_TM) &&
1109 (pktq->id == pos)) {
1110 n_writers++;
1111 writer = p;
1112 id = j;
1113 }
1114 }
1115 }
1116
1117 if (n_writers != 1)
1118 return NULL;
1119
1120 *pktq_out_id = id;
1121 return writer;
1122 }
1123
1124 static inline uint32_t
1125 app_tap_get_writers(struct app_params *app, struct app_pktq_tap_params *tap)
1126 {
1127 uint32_t pos = tap - app->tap_params;
1128 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
1129 RTE_DIM(app->pipeline_params));
1130 uint32_t n_writers = 0, i;
1131
1132 for (i = 0; i < n_pipelines; i++) {
1133 struct app_pipeline_params *p = &app->pipeline_params[i];
1134 uint32_t n_pktq_out = RTE_MIN(p->n_pktq_out,
1135 RTE_DIM(p->pktq_out));
1136 uint32_t j;
1137
1138 for (j = 0; j < n_pktq_out; j++) {
1139 struct app_pktq_out_params *pktq = &p->pktq_out[j];
1140
1141 if ((pktq->type == APP_PKTQ_OUT_TAP) &&
1142 (pktq->id == pos))
1143 n_writers++;
1144 }
1145 }
1146
1147 return n_writers;
1148 }
1149
1150 static inline struct app_pipeline_params *
1151 app_tap_get_writer(struct app_params *app,
1152 struct app_pktq_tap_params *tap,
1153 uint32_t *pktq_out_id)
1154 {
1155 struct app_pipeline_params *writer = NULL;
1156 uint32_t pos = tap - app->tap_params;
1157 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
1158 RTE_DIM(app->pipeline_params));
1159 uint32_t n_writers = 0, id = 0, i;
1160
1161 for (i = 0; i < n_pipelines; i++) {
1162 struct app_pipeline_params *p = &app->pipeline_params[i];
1163 uint32_t n_pktq_out = RTE_MIN(p->n_pktq_out,
1164 RTE_DIM(p->pktq_out));
1165 uint32_t j;
1166
1167 for (j = 0; j < n_pktq_out; j++) {
1168 struct app_pktq_out_params *pktq = &p->pktq_out[j];
1169
1170 if ((pktq->type == APP_PKTQ_OUT_TAP) &&
1171 (pktq->id == pos)) {
1172 n_writers++;
1173 writer = p;
1174 id = j;
1175 }
1176 }
1177 }
1178
1179 if (n_writers != 1)
1180 return NULL;
1181
1182 *pktq_out_id = id;
1183 return writer;
1184 }
1185
1186 static inline uint32_t
1187 app_kni_get_writers(struct app_params *app, struct app_pktq_kni_params *kni)
1188 {
1189 uint32_t pos = kni - app->kni_params;
1190 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
1191 RTE_DIM(app->pipeline_params));
1192 uint32_t n_writers = 0, i;
1193
1194 for (i = 0; i < n_pipelines; i++) {
1195 struct app_pipeline_params *p = &app->pipeline_params[i];
1196 uint32_t n_pktq_out = RTE_MIN(p->n_pktq_out,
1197 RTE_DIM(p->pktq_out));
1198 uint32_t j;
1199
1200 for (j = 0; j < n_pktq_out; j++) {
1201 struct app_pktq_out_params *pktq = &p->pktq_out[j];
1202
1203 if ((pktq->type == APP_PKTQ_OUT_KNI) &&
1204 (pktq->id == pos))
1205 n_writers++;
1206 }
1207 }
1208
1209 return n_writers;
1210 }
1211
1212 static inline struct app_pipeline_params *
1213 app_kni_get_writer(struct app_params *app,
1214 struct app_pktq_kni_params *kni,
1215 uint32_t *pktq_out_id)
1216 {
1217 struct app_pipeline_params *writer = NULL;
1218 uint32_t pos = kni - app->kni_params;
1219 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
1220 RTE_DIM(app->pipeline_params));
1221 uint32_t n_writers = 0, id = 0, i;
1222
1223 for (i = 0; i < n_pipelines; i++) {
1224 struct app_pipeline_params *p = &app->pipeline_params[i];
1225 uint32_t n_pktq_out = RTE_MIN(p->n_pktq_out,
1226 RTE_DIM(p->pktq_out));
1227 uint32_t j;
1228
1229 for (j = 0; j < n_pktq_out; j++) {
1230 struct app_pktq_out_params *pktq = &p->pktq_out[j];
1231
1232 if ((pktq->type == APP_PKTQ_OUT_KNI) &&
1233 (pktq->id == pos)) {
1234 n_writers++;
1235 writer = p;
1236 id = j;
1237 }
1238 }
1239 }
1240
1241 if (n_writers != 1)
1242 return NULL;
1243
1244 *pktq_out_id = id;
1245 return writer;
1246 }
1247
1248 static inline uint32_t
1249 app_sink_get_writers(struct app_params *app, struct app_pktq_sink_params *sink)
1250 {
1251 uint32_t pos = sink - app->sink_params;
1252 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
1253 RTE_DIM(app->pipeline_params));
1254 uint32_t n_writers = 0, i;
1255
1256 for (i = 0; i < n_pipelines; i++) {
1257 struct app_pipeline_params *p = &app->pipeline_params[i];
1258 uint32_t n_pktq_out = RTE_MIN(p->n_pktq_out,
1259 RTE_DIM(p->pktq_out));
1260 uint32_t j;
1261
1262 for (j = 0; j < n_pktq_out; j++) {
1263 struct app_pktq_out_params *pktq = &p->pktq_out[j];
1264
1265 if ((pktq->type == APP_PKTQ_OUT_SINK) &&
1266 (pktq->id == pos))
1267 n_writers++;
1268 }
1269 }
1270
1271 return n_writers;
1272 }
1273
1274 static inline uint32_t
1275 app_msgq_get_writers(struct app_params *app, struct app_msgq_params *msgq)
1276 {
1277 uint32_t pos = msgq - app->msgq_params;
1278 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
1279 RTE_DIM(app->pipeline_params));
1280 uint32_t n_writers = 0, i;
1281
1282 for (i = 0; i < n_pipelines; i++) {
1283 struct app_pipeline_params *p = &app->pipeline_params[i];
1284 uint32_t n_msgq_out = RTE_MIN(p->n_msgq_out,
1285 RTE_DIM(p->msgq_out));
1286 uint32_t j;
1287
1288 for (j = 0; j < n_msgq_out; j++)
1289 if (p->msgq_out[j] == pos)
1290 n_writers++;
1291 }
1292
1293 return n_writers;
1294 }
1295
1296 static inline struct app_link_params *
1297 app_get_link_for_rxq(struct app_params *app, struct app_pktq_hwq_in_params *p)
1298 {
1299 char link_name[APP_PARAM_NAME_SIZE];
1300 ssize_t link_param_idx;
1301 uint32_t rxq_link_id, rxq_queue_id;
1302
1303 sscanf(p->name, "RXQ%" SCNu32 ".%" SCNu32,
1304 &rxq_link_id, &rxq_queue_id);
1305 sprintf(link_name, "LINK%" PRIu32, rxq_link_id);
1306 link_param_idx = APP_PARAM_FIND(app->link_params, link_name);
1307 APP_CHECK((link_param_idx >= 0),
1308 "Cannot find %s for %s", link_name, p->name);
1309
1310 return &app->link_params[link_param_idx];
1311 }
1312
1313 static inline struct app_link_params *
1314 app_get_link_for_txq(struct app_params *app, struct app_pktq_hwq_out_params *p)
1315 {
1316 char link_name[APP_PARAM_NAME_SIZE];
1317 ssize_t link_param_idx;
1318 uint32_t txq_link_id, txq_queue_id;
1319
1320 sscanf(p->name, "TXQ%" SCNu32 ".%" SCNu32,
1321 &txq_link_id, &txq_queue_id);
1322 sprintf(link_name, "LINK%" PRIu32, txq_link_id);
1323 link_param_idx = APP_PARAM_FIND(app->link_params, link_name);
1324 APP_CHECK((link_param_idx >= 0),
1325 "Cannot find %s for %s", link_name, p->name);
1326
1327 return &app->link_params[link_param_idx];
1328 }
1329
1330 static inline struct app_link_params *
1331 app_get_link_for_tm(struct app_params *app, struct app_pktq_tm_params *p_tm)
1332 {
1333 char link_name[APP_PARAM_NAME_SIZE];
1334 uint32_t link_id;
1335 ssize_t link_param_idx;
1336
1337 sscanf(p_tm->name, "TM%" PRIu32, &link_id);
1338 sprintf(link_name, "LINK%" PRIu32, link_id);
1339 link_param_idx = APP_PARAM_FIND(app->link_params, link_name);
1340 APP_CHECK((link_param_idx >= 0),
1341 "Cannot find %s for %s", link_name, p_tm->name);
1342
1343 return &app->link_params[link_param_idx];
1344 }
1345
1346 static inline struct app_link_params *
1347 app_get_link_for_kni(struct app_params *app, struct app_pktq_kni_params *p_kni)
1348 {
1349 char link_name[APP_PARAM_NAME_SIZE];
1350 uint32_t link_id;
1351 ssize_t link_param_idx;
1352
1353 sscanf(p_kni->name, "KNI%" PRIu32, &link_id);
1354 sprintf(link_name, "LINK%" PRIu32, link_id);
1355 link_param_idx = APP_PARAM_FIND(app->link_params, link_name);
1356 APP_CHECK((link_param_idx >= 0),
1357 "Cannot find %s for %s", link_name, p_kni->name);
1358
1359 return &app->link_params[link_param_idx];
1360 }
1361
1362 void app_pipeline_params_get(struct app_params *app,
1363 struct app_pipeline_params *p_in,
1364 struct pipeline_params *p_out);
1365
1366 int app_config_init(struct app_params *app);
1367
1368 int app_config_args(struct app_params *app,
1369 int argc, char **argv);
1370
1371 int app_config_preproc(struct app_params *app);
1372
1373 int app_config_parse(struct app_params *app,
1374 const char *file_name);
1375
1376 int app_config_parse_tm(struct app_params *app);
1377
1378 void app_config_save(struct app_params *app,
1379 const char *file_name);
1380
1381 int app_config_check(struct app_params *app);
1382
1383 int app_init(struct app_params *app);
1384
1385 int app_post_init(struct app_params *app);
1386
1387 int app_thread(void *arg);
1388
1389 int app_pipeline_type_register(struct app_params *app,
1390 struct pipeline_type *ptype);
1391
1392 struct pipeline_type *app_pipeline_type_find(struct app_params *app,
1393 char *name);
1394
1395 void app_link_up_internal(struct app_params *app,
1396 struct app_link_params *cp);
1397
1398 void app_link_down_internal(struct app_params *app,
1399 struct app_link_params *cp);
1400
1401 #endif