4 * Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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
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.
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.
34 #ifndef __INCLUDE_APP_H__
35 #define __INCLUDE_APP_H__
40 #include <rte_common.h>
41 #include <rte_mempool.h>
43 #include <rte_sched.h>
44 #include <cmdline_parse.h>
46 #include <rte_ethdev.h>
48 #include "cpu_core_map.h"
51 #define APP_PARAM_NAME_SIZE PIPELINE_NAME_SIZE
52 #define APP_LINK_PCI_BDF_SIZE 16
53 struct app_mempool_params {
59 uint32_t cpu_socket_id;
62 struct app_link_params {
65 uint32_t pmd_id; /* Generated based on port mask */
66 uint32_t arp_q; /* 0 = Disabled (packets go to default queue 0) */
67 uint32_t tcp_syn_q; /* 0 = Disabled (pkts go to default queue) */
68 uint32_t ip_local_q; /* 0 = Disabled (pkts go to default queue 0) */
69 uint32_t tcp_local_q; /* 0 = Disabled (pkts go to default queue 0) */
70 uint32_t udp_local_q; /* 0 = Disabled (pkts go to default queue 0) */
71 uint32_t sctp_local_q; /* 0 = Disabled (pkts go to default queue 0) */
72 uint32_t state; /* DOWN = 0, UP = 1 */
73 uint32_t ip; /* 0 = Invalid */
74 uint32_t depth; /* Valid only when IP is valid */
75 uint64_t mac_addr; /* Read from HW */
76 char pci_bdf[APP_LINK_PCI_BDF_SIZE];
78 struct rte_eth_conf conf;
82 struct app_pktq_hwq_in_params {
85 uint32_t mempool_id; /* Position in the app->mempool_params */
89 struct rte_eth_rxconf conf;
92 struct app_pktq_hwq_out_params {
99 struct rte_eth_txconf conf;
102 struct app_pktq_swq_params {
107 uint32_t burst_write;
110 uint32_t cpu_socket_id;
116 uint32_t metadata_size;
117 uint32_t mempool_direct_id;
118 uint32_t mempool_indirect_id;
121 #ifndef APP_FILE_NAME_SIZE
122 #define APP_FILE_NAME_SIZE 256
125 #ifndef APP_MAX_SCHED_SUBPORTS
126 #define APP_MAX_SCHED_SUBPORTS 8
129 #ifndef APP_MAX_SCHED_PIPES
130 #define APP_MAX_SCHED_PIPES 4096
133 struct app_pktq_tm_params {
136 const char *file_name;
137 struct rte_sched_port_params sched_port_params;
138 struct rte_sched_subport_params
139 sched_subport_params[APP_MAX_SCHED_SUBPORTS];
140 struct rte_sched_pipe_params
141 sched_pipe_profiles[RTE_SCHED_PIPE_PROFILES_PER_PORT];
142 int sched_pipe_to_profile[APP_MAX_SCHED_SUBPORTS * APP_MAX_SCHED_PIPES];
144 uint32_t burst_write;
147 struct app_pktq_source_params {
150 uint32_t mempool_id; /* Position in the app->mempool_params array */
152 char *file_name; /* Full path of PCAP file to be copied to mbufs */
153 uint32_t n_bytes_per_pkt;
156 struct app_pktq_sink_params {
161 struct app_msgq_params {
165 uint32_t cpu_socket_id;
168 enum app_pktq_in_type {
175 struct app_pktq_in_params {
176 enum app_pktq_in_type type;
177 uint32_t id; /* Position in the appropriate app array */
180 enum app_pktq_out_type {
187 struct app_pktq_out_params {
188 enum app_pktq_out_type type;
189 uint32_t id; /* Position in the appropriate app array */
192 #ifndef APP_PIPELINE_TYPE_SIZE
193 #define APP_PIPELINE_TYPE_SIZE 64
196 #define APP_MAX_PIPELINE_PKTQ_IN PIPELINE_MAX_PORT_IN
197 #define APP_MAX_PIPELINE_PKTQ_OUT PIPELINE_MAX_PORT_OUT
198 #define APP_MAX_PIPELINE_MSGQ_IN PIPELINE_MAX_MSGQ_IN
199 #define APP_MAX_PIPELINE_MSGQ_OUT PIPELINE_MAX_MSGQ_OUT
201 #define APP_MAX_PIPELINE_ARGS PIPELINE_MAX_ARGS
203 struct app_pipeline_params {
207 char type[APP_PIPELINE_TYPE_SIZE];
211 uint32_t hyper_th_id;
213 struct app_pktq_in_params pktq_in[APP_MAX_PIPELINE_PKTQ_IN];
214 struct app_pktq_out_params pktq_out[APP_MAX_PIPELINE_PKTQ_OUT];
215 uint32_t msgq_in[APP_MAX_PIPELINE_MSGQ_IN];
216 uint32_t msgq_out[APP_MAX_PIPELINE_MSGQ_OUT];
223 uint32_t timer_period;
225 char *args_name[APP_MAX_PIPELINE_ARGS];
226 char *args_value[APP_MAX_PIPELINE_ARGS];
230 struct app_pipeline_data {
233 struct pipeline_type *ptype;
234 uint64_t timer_period;
238 struct app_thread_pipeline_data {
239 uint32_t pipeline_id;
241 pipeline_be_op_run f_run;
242 pipeline_be_op_timer f_timer;
243 uint64_t timer_period;
247 #ifndef APP_MAX_THREAD_PIPELINES
248 #define APP_MAX_THREAD_PIPELINES 16
251 #ifndef APP_THREAD_TIMER_PERIOD
252 #define APP_THREAD_TIMER_PERIOD 1
255 struct app_thread_data {
256 struct app_thread_pipeline_data regular[APP_MAX_THREAD_PIPELINES];
257 struct app_thread_pipeline_data custom[APP_MAX_THREAD_PIPELINES];
262 uint64_t timer_period;
263 uint64_t thread_req_deadline;
267 struct rte_ring *msgq_in;
268 struct rte_ring *msgq_out;
270 uint64_t headroom_time;
271 uint64_t headroom_cycles;
272 double headroom_ratio;
275 #ifndef APP_MAX_LINKS
276 #define APP_MAX_LINKS 16
279 struct app_eal_params {
280 /* Map lcore set to physical cpu set */
283 /* Core ID that is used as master */
284 uint32_t master_lcore_present;
285 uint32_t master_lcore;
287 /* Number of memory channels */
288 uint32_t channels_present;
291 /* Memory to allocate (see also --socket-mem) */
292 uint32_t memory_present;
295 /* Force number of memory ranks (don't detect) */
296 uint32_t ranks_present;
299 /* Add a PCI device in black list. */
300 char *pci_blacklist[APP_MAX_LINKS];
302 /* Add a PCI device in white list. */
303 char *pci_whitelist[APP_MAX_LINKS];
305 /* Add a virtual device. */
306 char *vdev[APP_MAX_LINKS];
308 /* Use VMware TSC map instead of native RDTSC */
309 uint32_t vmware_tsc_map_present;
312 /* Type of this process (primary|secondary|auto) */
315 /* Set syslog facility */
318 /* Set default log level */
319 uint32_t log_level_present;
322 /* Display version information on startup */
323 uint32_t version_present;
327 uint32_t help_present;
330 /* Use malloc instead of hugetlbfs */
331 uint32_t no_huge_present;
335 uint32_t no_pci_present;
339 uint32_t no_hpet_present;
342 /* No shared config (mmap'd files) */
343 uint32_t no_shconf_present;
349 /* Memory to allocate on sockets (comma separated values)*/
352 /* Directory where hugetlbfs is mounted */
355 /* Prefix for hugepage filenames */
358 /* Base virtual address */
361 /* Create /dev/uioX (usually done by hotplug) */
362 uint32_t create_uio_dev_present;
365 /* Interrupt mode for VFIO (legacy|msi|msix) */
368 /* Support running on Xen dom0 without hugetlbfs */
369 uint32_t xen_dom0_present;
373 #ifndef APP_APPNAME_SIZE
374 #define APP_APPNAME_SIZE 256
377 #ifndef APP_MAX_MEMPOOLS
378 #define APP_MAX_MEMPOOLS 8
381 #ifndef APP_LINK_MAX_HWQ_IN
382 #define APP_LINK_MAX_HWQ_IN 64
385 #ifndef APP_LINK_MAX_HWQ_OUT
386 #define APP_LINK_MAX_HWQ_OUT 64
389 #define APP_MAX_HWQ_IN (APP_MAX_LINKS * APP_LINK_MAX_HWQ_IN)
391 #define APP_MAX_HWQ_OUT (APP_MAX_LINKS * APP_LINK_MAX_HWQ_OUT)
393 #ifndef APP_MAX_PKTQ_SWQ
394 #define APP_MAX_PKTQ_SWQ 256
397 #define APP_MAX_PKTQ_TM APP_MAX_LINKS
399 #ifndef APP_MAX_PKTQ_SOURCE
400 #define APP_MAX_PKTQ_SOURCE 16
403 #ifndef APP_MAX_PKTQ_SINK
404 #define APP_MAX_PKTQ_SINK 16
408 #define APP_MAX_MSGQ 64
411 #ifndef APP_MAX_PIPELINES
412 #define APP_MAX_PIPELINES 64
416 #define APP_EAL_ARGC 32
419 #ifndef APP_MAX_PIPELINE_TYPES
420 #define APP_MAX_PIPELINE_TYPES 64
423 #ifndef APP_MAX_THREADS
424 #define APP_MAX_THREADS RTE_MAX_LCORE
428 #define APP_MAX_CMDS 64
431 #ifndef APP_THREAD_HEADROOM_STATS_COLLECT
432 #define APP_THREAD_HEADROOM_STATS_COLLECT 1
437 char app_name[APP_APPNAME_SIZE];
438 const char *config_file;
439 const char *script_file;
440 const char *parser_file;
441 const char *output_file;
443 const char *preproc_args;
447 struct app_eal_params eal_params;
448 struct app_mempool_params mempool_params[APP_MAX_MEMPOOLS];
449 struct app_link_params link_params[APP_MAX_LINKS];
450 struct app_pktq_hwq_in_params hwq_in_params[APP_MAX_HWQ_IN];
451 struct app_pktq_hwq_out_params hwq_out_params[APP_MAX_HWQ_OUT];
452 struct app_pktq_swq_params swq_params[APP_MAX_PKTQ_SWQ];
453 struct app_pktq_tm_params tm_params[APP_MAX_PKTQ_TM];
454 struct app_pktq_source_params source_params[APP_MAX_PKTQ_SOURCE];
455 struct app_pktq_sink_params sink_params[APP_MAX_PKTQ_SINK];
456 struct app_msgq_params msgq_params[APP_MAX_MSGQ];
457 struct app_pipeline_params pipeline_params[APP_MAX_PIPELINES];
461 uint32_t n_pktq_hwq_in;
462 uint32_t n_pktq_hwq_out;
465 uint32_t n_pktq_source;
466 uint32_t n_pktq_sink;
468 uint32_t n_pipelines;
471 char *eal_argv[1 + APP_EAL_ARGC];
472 struct cpu_core_map *core_map;
474 struct rte_mempool *mempool[APP_MAX_MEMPOOLS];
475 struct rte_ring *swq[APP_MAX_PKTQ_SWQ];
476 struct rte_sched_port *tm[APP_MAX_PKTQ_TM];
477 struct rte_ring *msgq[APP_MAX_MSGQ];
478 struct pipeline_type pipeline_type[APP_MAX_PIPELINE_TYPES];
479 struct app_pipeline_data pipeline_data[APP_MAX_PIPELINES];
480 struct app_thread_data thread_data[APP_MAX_THREADS];
481 cmdline_parse_ctx_t cmds[APP_MAX_CMDS + 1];
484 uint32_t n_pipeline_types;
488 #define APP_PARAM_VALID(obj) ((obj)->name != NULL)
490 #define APP_PARAM_COUNT(obj_array, n_objs) \
495 for (i = 0; i < RTE_DIM(obj_array); i++) \
496 if (APP_PARAM_VALID(&((obj_array)[i]))) \
500 #define APP_PARAM_FIND(obj_array, key) \
503 const ssize_t obj_count = RTE_DIM(obj_array); \
505 for (obj_idx = 0; obj_idx < obj_count; obj_idx++) { \
506 if (!APP_PARAM_VALID(&((obj_array)[obj_idx]))) \
509 if (strcmp(key, (obj_array)[obj_idx].name) == 0) \
512 obj_idx < obj_count ? obj_idx : -ENOENT; \
515 #define APP_PARAM_FIND_BY_ID(obj_array, prefix, id, obj) \
517 char name[APP_PARAM_NAME_SIZE]; \
520 sprintf(name, prefix "%" PRIu32, id); \
521 pos = APP_PARAM_FIND(obj_array, name); \
522 obj = (pos < 0) ? NULL : &((obj_array)[pos]); \
525 #define APP_PARAM_GET_ID(obj, prefix, id) \
527 sscanf(obj->name, prefix "%" SCNu32, &id); \
530 #define APP_PARAM_ADD(obj_array, obj_name) \
533 const ssize_t obj_count = RTE_DIM(obj_array); \
535 obj_idx = APP_PARAM_FIND(obj_array, obj_name); \
537 for (obj_idx = 0; obj_idx < obj_count; obj_idx++) { \
538 if (!APP_PARAM_VALID(&((obj_array)[obj_idx]))) \
542 if (obj_idx < obj_count) { \
543 (obj_array)[obj_idx].name = strdup(obj_name); \
544 if ((obj_array)[obj_idx].name == NULL) \
552 #define APP_CHECK(exp, fmt, ...) \
555 fprintf(stderr, fmt "\n", ## __VA_ARGS__); \
561 APP_LOG_LEVEL_HIGH = 1,
566 #define APP_LOG(app, level, fmt, ...) \
568 if (app->log_level >= APP_LOG_LEVEL_ ## level) \
569 fprintf(stdout, "[APP] " fmt "\n", ## __VA_ARGS__); \
572 static inline uint32_t
573 app_link_get_n_rxq(struct app_params *app, struct app_link_params *link)
575 uint32_t n_rxq = 0, link_id, i;
576 uint32_t n_pktq_hwq_in = RTE_MIN(app->n_pktq_hwq_in,
577 RTE_DIM(app->hwq_in_params));
579 APP_PARAM_GET_ID(link, "LINK", link_id);
581 for (i = 0; i < n_pktq_hwq_in; i++) {
582 struct app_pktq_hwq_in_params *p = &app->hwq_in_params[i];
583 uint32_t rxq_link_id, rxq_queue_id;
585 sscanf(p->name, "RXQ%" SCNu32 ".%" SCNu32,
586 &rxq_link_id, &rxq_queue_id);
587 if (rxq_link_id == link_id)
594 static inline uint32_t
595 app_link_get_n_txq(struct app_params *app, struct app_link_params *link)
597 uint32_t n_txq = 0, link_id, i;
598 uint32_t n_pktq_hwq_out = RTE_MIN(app->n_pktq_hwq_out,
599 RTE_DIM(app->hwq_out_params));
601 APP_PARAM_GET_ID(link, "LINK", link_id);
603 for (i = 0; i < n_pktq_hwq_out; i++) {
604 struct app_pktq_hwq_out_params *p = &app->hwq_out_params[i];
605 uint32_t txq_link_id, txq_queue_id;
607 sscanf(p->name, "TXQ%" SCNu32 ".%" SCNu32,
608 &txq_link_id, &txq_queue_id);
609 if (txq_link_id == link_id)
616 static inline uint32_t
617 app_rxq_get_readers(struct app_params *app, struct app_pktq_hwq_in_params *rxq)
619 uint32_t pos = rxq - app->hwq_in_params;
620 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
621 RTE_DIM(app->pipeline_params));
622 uint32_t n_readers = 0, i;
624 for (i = 0; i < n_pipelines; i++) {
625 struct app_pipeline_params *p = &app->pipeline_params[i];
626 uint32_t n_pktq_in = RTE_MIN(p->n_pktq_in, RTE_DIM(p->pktq_in));
629 for (j = 0; j < n_pktq_in; j++) {
630 struct app_pktq_in_params *pktq = &p->pktq_in[j];
632 if ((pktq->type == APP_PKTQ_IN_HWQ) &&
641 static inline uint32_t
642 app_swq_get_readers(struct app_params *app, struct app_pktq_swq_params *swq)
644 uint32_t pos = swq - app->swq_params;
645 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
646 RTE_DIM(app->pipeline_params));
647 uint32_t n_readers = 0, i;
649 for (i = 0; i < n_pipelines; i++) {
650 struct app_pipeline_params *p = &app->pipeline_params[i];
651 uint32_t n_pktq_in = RTE_MIN(p->n_pktq_in, RTE_DIM(p->pktq_in));
654 for (j = 0; j < n_pktq_in; j++) {
655 struct app_pktq_in_params *pktq = &p->pktq_in[j];
657 if ((pktq->type == APP_PKTQ_IN_SWQ) &&
666 static inline uint32_t
667 app_tm_get_readers(struct app_params *app, struct app_pktq_tm_params *tm)
669 uint32_t pos = tm - app->tm_params;
670 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
671 RTE_DIM(app->pipeline_params));
672 uint32_t n_readers = 0, i;
674 for (i = 0; i < n_pipelines; i++) {
675 struct app_pipeline_params *p = &app->pipeline_params[i];
676 uint32_t n_pktq_in = RTE_MIN(p->n_pktq_in, RTE_DIM(p->pktq_in));
679 for (j = 0; j < n_pktq_in; j++) {
680 struct app_pktq_in_params *pktq = &p->pktq_in[j];
682 if ((pktq->type == APP_PKTQ_IN_TM) &&
691 static inline uint32_t
692 app_source_get_readers(struct app_params *app,
693 struct app_pktq_source_params *source)
695 uint32_t pos = source - app->source_params;
696 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
697 RTE_DIM(app->pipeline_params));
698 uint32_t n_readers = 0, i;
700 for (i = 0; i < n_pipelines; i++) {
701 struct app_pipeline_params *p = &app->pipeline_params[i];
702 uint32_t n_pktq_in = RTE_MIN(p->n_pktq_in, RTE_DIM(p->pktq_in));
705 for (j = 0; j < n_pktq_in; j++) {
706 struct app_pktq_in_params *pktq = &p->pktq_in[j];
708 if ((pktq->type == APP_PKTQ_IN_SOURCE) &&
717 static inline uint32_t
718 app_msgq_get_readers(struct app_params *app, struct app_msgq_params *msgq)
720 uint32_t pos = msgq - app->msgq_params;
721 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
722 RTE_DIM(app->pipeline_params));
723 uint32_t n_readers = 0, i;
725 for (i = 0; i < n_pipelines; i++) {
726 struct app_pipeline_params *p = &app->pipeline_params[i];
727 uint32_t n_msgq_in = RTE_MIN(p->n_msgq_in, RTE_DIM(p->msgq_in));
730 for (j = 0; j < n_msgq_in; j++)
731 if (p->msgq_in[j] == pos)
738 static inline uint32_t
739 app_txq_get_writers(struct app_params *app, struct app_pktq_hwq_out_params *txq)
741 uint32_t pos = txq - app->hwq_out_params;
742 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
743 RTE_DIM(app->pipeline_params));
744 uint32_t n_writers = 0, i;
746 for (i = 0; i < n_pipelines; i++) {
747 struct app_pipeline_params *p = &app->pipeline_params[i];
748 uint32_t n_pktq_out = RTE_MIN(p->n_pktq_out,
749 RTE_DIM(p->pktq_out));
752 for (j = 0; j < n_pktq_out; j++) {
753 struct app_pktq_out_params *pktq = &p->pktq_out[j];
755 if ((pktq->type == APP_PKTQ_OUT_HWQ) &&
764 static inline uint32_t
765 app_swq_get_writers(struct app_params *app, struct app_pktq_swq_params *swq)
767 uint32_t pos = swq - app->swq_params;
768 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
769 RTE_DIM(app->pipeline_params));
770 uint32_t n_writers = 0, i;
772 for (i = 0; i < n_pipelines; i++) {
773 struct app_pipeline_params *p = &app->pipeline_params[i];
774 uint32_t n_pktq_out = RTE_MIN(p->n_pktq_out,
775 RTE_DIM(p->pktq_out));
778 for (j = 0; j < n_pktq_out; j++) {
779 struct app_pktq_out_params *pktq = &p->pktq_out[j];
781 if ((pktq->type == APP_PKTQ_OUT_SWQ) &&
790 static inline uint32_t
791 app_tm_get_writers(struct app_params *app, struct app_pktq_tm_params *tm)
793 uint32_t pos = tm - app->tm_params;
794 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
795 RTE_DIM(app->pipeline_params));
796 uint32_t n_writers = 0, i;
798 for (i = 0; i < n_pipelines; i++) {
799 struct app_pipeline_params *p = &app->pipeline_params[i];
800 uint32_t n_pktq_out = RTE_MIN(p->n_pktq_out,
801 RTE_DIM(p->pktq_out));
804 for (j = 0; j < n_pktq_out; j++) {
805 struct app_pktq_out_params *pktq = &p->pktq_out[j];
807 if ((pktq->type == APP_PKTQ_OUT_TM) &&
816 static inline uint32_t
817 app_sink_get_writers(struct app_params *app, struct app_pktq_sink_params *sink)
819 uint32_t pos = sink - app->sink_params;
820 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
821 RTE_DIM(app->pipeline_params));
822 uint32_t n_writers = 0, i;
824 for (i = 0; i < n_pipelines; i++) {
825 struct app_pipeline_params *p = &app->pipeline_params[i];
826 uint32_t n_pktq_out = RTE_MIN(p->n_pktq_out,
827 RTE_DIM(p->pktq_out));
830 for (j = 0; j < n_pktq_out; j++) {
831 struct app_pktq_out_params *pktq = &p->pktq_out[j];
833 if ((pktq->type == APP_PKTQ_OUT_SINK) &&
842 static inline uint32_t
843 app_msgq_get_writers(struct app_params *app, struct app_msgq_params *msgq)
845 uint32_t pos = msgq - app->msgq_params;
846 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
847 RTE_DIM(app->pipeline_params));
848 uint32_t n_writers = 0, i;
850 for (i = 0; i < n_pipelines; i++) {
851 struct app_pipeline_params *p = &app->pipeline_params[i];
852 uint32_t n_msgq_out = RTE_MIN(p->n_msgq_out,
853 RTE_DIM(p->msgq_out));
856 for (j = 0; j < n_msgq_out; j++)
857 if (p->msgq_out[j] == pos)
864 static inline struct app_link_params *
865 app_get_link_for_rxq(struct app_params *app, struct app_pktq_hwq_in_params *p)
867 char link_name[APP_PARAM_NAME_SIZE];
868 ssize_t link_param_idx;
869 uint32_t rxq_link_id, rxq_queue_id;
871 sscanf(p->name, "RXQ%" SCNu32 ".%" SCNu32,
872 &rxq_link_id, &rxq_queue_id);
873 sprintf(link_name, "LINK%" PRIu32, rxq_link_id);
874 link_param_idx = APP_PARAM_FIND(app->link_params, link_name);
875 APP_CHECK((link_param_idx >= 0),
876 "Cannot find %s for %s", link_name, p->name);
878 return &app->link_params[link_param_idx];
881 static inline struct app_link_params *
882 app_get_link_for_txq(struct app_params *app, struct app_pktq_hwq_out_params *p)
884 char link_name[APP_PARAM_NAME_SIZE];
885 ssize_t link_param_idx;
886 uint32_t txq_link_id, txq_queue_id;
888 sscanf(p->name, "TXQ%" SCNu32 ".%" SCNu32,
889 &txq_link_id, &txq_queue_id);
890 sprintf(link_name, "LINK%" PRIu32, txq_link_id);
891 link_param_idx = APP_PARAM_FIND(app->link_params, link_name);
892 APP_CHECK((link_param_idx >= 0),
893 "Cannot find %s for %s", link_name, p->name);
895 return &app->link_params[link_param_idx];
898 static inline struct app_link_params *
899 app_get_link_for_tm(struct app_params *app, struct app_pktq_tm_params *p_tm)
901 char link_name[APP_PARAM_NAME_SIZE];
903 ssize_t link_param_idx;
905 sscanf(p_tm->name, "TM%" PRIu32, &link_id);
906 sprintf(link_name, "LINK%" PRIu32, link_id);
907 link_param_idx = APP_PARAM_FIND(app->link_params, link_name);
908 APP_CHECK((link_param_idx >= 0),
909 "Cannot find %s for %s", link_name, p_tm->name);
911 return &app->link_params[link_param_idx];
914 int app_config_init(struct app_params *app);
916 int app_config_args(struct app_params *app,
917 int argc, char **argv);
919 int app_config_preproc(struct app_params *app);
921 int app_config_parse(struct app_params *app,
922 const char *file_name);
924 int app_config_parse_tm(struct app_params *app);
926 void app_config_save(struct app_params *app,
927 const char *file_name);
929 int app_config_check(struct app_params *app);
931 int app_init(struct app_params *app);
933 int app_thread(void *arg);
935 int app_pipeline_type_register(struct app_params *app,
936 struct pipeline_type *ptype);
938 struct pipeline_type *app_pipeline_type_find(struct app_params *app,
941 void app_link_up_internal(struct app_params *app,
942 struct app_link_params *cp);
944 void app_link_down_internal(struct app_params *app,
945 struct app_link_params *cp);