2 // Copyright (c) 2017 Intel Corporation
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 #ifndef __INCLUDE_APP_H__
18 #define __INCLUDE_APP_H__
23 #include <rte_common.h>
24 #include <rte_mempool.h>
26 #include <rte_sched.h>
27 #include <rte_timer.h>
28 #include <cmdline_parse.h>
30 #include <rte_ethdev.h>
32 #include "cpu_core_map.h"
35 #define APP_PARAM_NAME_SIZE PIPELINE_NAME_SIZE
36 #define APP_LINK_PCI_BDF_SIZE 32
37 struct app_link_params *fdir_p_link;
38 struct app_mempool_params {
44 uint32_t cpu_socket_id;
47 struct app_link_params {
50 uint32_t pmd_id; /* Generated based on port mask */
51 uint32_t arp_q; /* 0 = Disabled (packets go to default queue 0) */
52 uint32_t tcp_syn_q; /* 0 = Disabled (pkts go to default queue) */
53 uint32_t ip_local_q; /* 0 = Disabled (pkts go to default queue 0) */
54 uint32_t tcp_local_q; /* 0 = Disabled (pkts go to default queue 0) */
55 uint32_t udp_local_q; /* 0 = Disabled (pkts go to default queue 0) */
56 uint32_t sctp_local_q; /* 0 = Disabled (pkts go to default queue 0) */
57 uint32_t state; /* DOWN = 0, UP = 1 */
58 uint32_t ip; /* 0 = Invalid */
60 uint32_t depth; /* Valid only when IP is valid */
62 uint64_t mac_addr; /* Read from HW */
63 char pci_bdf[APP_LINK_PCI_BDF_SIZE];
65 struct rte_eth_conf conf;
69 struct app_pktq_hwq_in_params {
72 uint32_t mempool_id; /* Position in the app->mempool_params */
76 struct rte_eth_rxconf conf;
79 struct app_pktq_hwq_out_params {
86 struct rte_eth_txconf conf;
89 struct app_pktq_swq_params {
97 uint32_t cpu_socket_id;
103 uint32_t metadata_size;
104 uint32_t mempool_direct_id;
105 uint32_t mempool_indirect_id;
108 #ifndef APP_FILE_NAME_SIZE
109 #define APP_FILE_NAME_SIZE 256
112 #ifndef APP_MAX_SCHED_SUBPORTS
113 #define APP_MAX_SCHED_SUBPORTS 8
116 #ifndef APP_MAX_SCHED_PIPES
117 #define APP_MAX_SCHED_PIPES 4096
120 struct app_pktq_tm_params {
123 const char *file_name;
124 struct rte_sched_port_params sched_port_params;
125 struct rte_sched_subport_params
126 sched_subport_params[APP_MAX_SCHED_SUBPORTS];
127 struct rte_sched_pipe_params
128 sched_pipe_profiles[RTE_SCHED_PIPE_PROFILES_PER_PORT];
129 int sched_pipe_to_profile[APP_MAX_SCHED_SUBPORTS * APP_MAX_SCHED_PIPES];
131 uint32_t burst_write;
134 struct app_pktq_source_params {
137 uint32_t mempool_id; /* Position in the app->mempool_params array */
139 char *file_name; /* Full path of PCAP file to be copied to mbufs */
140 uint32_t n_bytes_per_pkt;
143 struct app_pktq_sink_params {
146 char *file_name; /* Full path of PCAP file to be copied to mbufs */
147 uint32_t n_pkts_to_dump;
150 struct app_msgq_params {
154 uint32_t cpu_socket_id;
157 enum app_pktq_in_type {
164 struct app_pktq_in_params {
165 enum app_pktq_in_type type;
166 uint32_t id; /* Position in the appropriate app array */
169 enum app_pktq_out_type {
176 struct app_pktq_out_params {
177 enum app_pktq_out_type type;
178 uint32_t id; /* Position in the appropriate app array */
181 #ifndef APP_PIPELINE_TYPE_SIZE
182 #define APP_PIPELINE_TYPE_SIZE 64
185 #define APP_MAX_PIPELINE_PKTQ_IN PIPELINE_MAX_PORT_IN
186 #define APP_MAX_PIPELINE_PKTQ_OUT PIPELINE_MAX_PORT_OUT
187 #define APP_MAX_PIPELINE_MSGQ_IN PIPELINE_MAX_MSGQ_IN
188 #define APP_MAX_PIPELINE_MSGQ_OUT PIPELINE_MAX_MSGQ_OUT
190 #define APP_MAX_PIPELINE_ARGS PIPELINE_MAX_ARGS
192 struct app_pipeline_params {
196 char type[APP_PIPELINE_TYPE_SIZE];
200 uint32_t hyper_th_id;
202 struct app_pktq_in_params pktq_in[APP_MAX_PIPELINE_PKTQ_IN];
203 struct app_pktq_out_params pktq_out[APP_MAX_PIPELINE_PKTQ_OUT];
204 uint32_t msgq_in[APP_MAX_PIPELINE_MSGQ_IN];
205 uint32_t msgq_out[APP_MAX_PIPELINE_MSGQ_OUT];
212 uint32_t timer_period;
214 char *args_name[APP_MAX_PIPELINE_ARGS];
215 char *args_value[APP_MAX_PIPELINE_ARGS];
219 struct app_pipeline_data {
222 struct pipeline_type *ptype;
223 uint64_t timer_period;
227 struct app_thread_pipeline_data {
228 uint32_t pipeline_id;
230 pipeline_be_op_run f_run;
231 pipeline_be_op_timer f_timer;
232 uint64_t timer_period;
236 #ifndef APP_MAX_THREAD_PIPELINES
237 #define APP_MAX_THREAD_PIPELINES 32
240 #ifndef APP_THREAD_TIMER_PERIOD
241 #define APP_THREAD_TIMER_PERIOD 1
244 struct app_thread_data {
245 struct app_thread_pipeline_data regular[APP_MAX_THREAD_PIPELINES];
246 struct app_thread_pipeline_data custom[APP_MAX_THREAD_PIPELINES];
251 uint64_t timer_period;
252 uint64_t thread_req_deadline;
256 struct rte_ring *msgq_in;
257 struct rte_ring *msgq_out;
259 uint64_t headroom_time;
260 uint64_t headroom_cycles;
261 double headroom_ratio;
264 #ifndef APP_MAX_LINKS
265 #define APP_MAX_LINKS 32
268 struct app_eal_params {
269 /* Map lcore set to physical cpu set */
272 /* Core ID that is used as master */
273 uint32_t master_lcore_present;
274 uint32_t master_lcore;
276 /* Number of memory channels */
277 uint32_t channels_present;
280 /* Memory to allocate (see also --socket-mem) */
281 uint32_t memory_present;
284 /* Force number of memory ranks (don't detect) */
285 uint32_t ranks_present;
288 /* Add a PCI device in black list. */
289 char *pci_blacklist[APP_MAX_LINKS];
291 /* Add a PCI device in white list. */
292 char *pci_whitelist[APP_MAX_LINKS];
294 /* Add a virtual device. */
295 char *vdev[APP_MAX_LINKS];
297 /* Use VMware TSC map instead of native RDTSC */
298 uint32_t vmware_tsc_map_present;
301 /* Type of this process (primary|secondary|auto) */
304 /* Set syslog facility */
307 /* Set default log level */
308 uint32_t log_level_present;
311 /* Display version information on startup */
312 uint32_t version_present;
316 uint32_t help_present;
319 /* Use malloc instead of hugetlbfs */
320 uint32_t no_huge_present;
324 uint32_t no_pci_present;
328 uint32_t no_hpet_present;
331 /* No shared config (mmap'd files) */
332 uint32_t no_shconf_present;
338 /* Memory to allocate on sockets (comma separated values)*/
341 /* Directory where hugetlbfs is mounted */
344 /* Prefix for hugepage filenames */
347 /* Base virtual address */
350 /* Create /dev/uioX (usually done by hotplug) */
351 uint32_t create_uio_dev_present;
354 /* Interrupt mode for VFIO (legacy|msi|msix) */
357 /* Support running on Xen dom0 without hugetlbfs */
358 uint32_t xen_dom0_present;
362 #ifndef APP_APPNAME_SIZE
363 #define APP_APPNAME_SIZE 256
366 #ifndef APP_MAX_MEMPOOLS
367 #define APP_MAX_MEMPOOLS 8
370 #ifndef APP_LINK_MAX_HWQ_IN
371 #define APP_LINK_MAX_HWQ_IN 64
374 #ifndef APP_LINK_MAX_HWQ_OUT
375 #define APP_LINK_MAX_HWQ_OUT 64
378 #define APP_MAX_HWQ_IN (APP_MAX_LINKS * APP_LINK_MAX_HWQ_IN)
380 #define APP_MAX_HWQ_OUT (APP_MAX_LINKS * APP_LINK_MAX_HWQ_OUT)
382 #ifndef APP_MAX_PKTQ_SWQ
383 #define APP_MAX_PKTQ_SWQ 256
386 #define APP_MAX_PKTQ_TM APP_MAX_LINKS
388 #ifndef APP_MAX_PKTQ_SOURCE
389 #define APP_MAX_PKTQ_SOURCE 32
392 #ifndef APP_MAX_PKTQ_SINK
393 #define APP_MAX_PKTQ_SINK 32
397 #define APP_MAX_MSGQ 128
400 #ifndef APP_MAX_PIPELINES
401 #define APP_MAX_PIPELINES 64
405 #define APP_EAL_ARGC 32
408 #ifndef APP_MAX_PIPELINE_TYPES
409 #define APP_MAX_PIPELINE_TYPES 64
412 #ifndef APP_MAX_THREADS
413 #define APP_MAX_THREADS RTE_MAX_LCORE
417 #define APP_MAX_CMDS 128
420 #ifndef APP_THREAD_HEADROOM_STATS_COLLECT
421 #define APP_THREAD_HEADROOM_STATS_COLLECT 1
425 uint8_t enable_flow_dir;
427 #define APP_CORE_MASK_SIZE \
428 (RTE_MAX_LCORE / 64 + ((RTE_MAX_LCORE % 64) ? 1 : 0))
432 char app_name[APP_APPNAME_SIZE];
433 const char *config_file;
434 const char *script_file;
435 const char *parser_file;
436 const char *output_file;
438 const char *preproc_args;
442 struct app_eal_params eal_params;
443 struct app_mempool_params mempool_params[APP_MAX_MEMPOOLS];
444 struct app_link_params link_params[APP_MAX_LINKS];
445 struct app_pktq_hwq_in_params hwq_in_params[APP_MAX_HWQ_IN];
446 struct app_pktq_hwq_out_params hwq_out_params[APP_MAX_HWQ_OUT];
447 struct app_pktq_swq_params swq_params[APP_MAX_PKTQ_SWQ];
448 struct app_pktq_tm_params tm_params[APP_MAX_PKTQ_TM];
449 struct app_pktq_source_params source_params[APP_MAX_PKTQ_SOURCE];
450 struct app_pktq_sink_params sink_params[APP_MAX_PKTQ_SINK];
451 struct app_msgq_params msgq_params[APP_MAX_MSGQ];
452 struct app_pipeline_params pipeline_params[APP_MAX_PIPELINES];
456 uint32_t n_pktq_hwq_in;
457 uint32_t n_pktq_hwq_out;
460 uint32_t n_pktq_source;
461 uint32_t n_pktq_sink;
463 uint32_t n_pipelines;
465 uint32_t header_csum_req;
468 char *eal_argv[1 + APP_EAL_ARGC];
469 struct cpu_core_map *core_map;
470 uint64_t core_mask[APP_CORE_MASK_SIZE];
471 struct rte_mempool *mempool[APP_MAX_MEMPOOLS];
472 struct rte_ring *swq[APP_MAX_PKTQ_SWQ];
473 struct rte_sched_port *tm[APP_MAX_PKTQ_TM];
474 struct rte_ring *msgq[APP_MAX_MSGQ];
475 struct pipeline_type pipeline_type[APP_MAX_PIPELINE_TYPES];
476 struct app_pipeline_data pipeline_data[APP_MAX_PIPELINES];
477 struct app_thread_data thread_data[APP_MAX_THREADS];
478 cmdline_parse_ctx_t cmds[APP_MAX_CMDS + 1];
481 uint32_t n_pipeline_types;
485 #define APP_PARAM_VALID(obj) ((obj)->name != NULL)
487 #define APP_PARAM_COUNT(obj_array, n_objs) \
492 for (i = 0; i < RTE_DIM(obj_array); i++) \
493 if (APP_PARAM_VALID(&((obj_array)[i]))) \
497 #define APP_PARAM_FIND(obj_array, key) \
500 const ssize_t obj_count = RTE_DIM(obj_array); \
502 for (obj_idx = 0; obj_idx < obj_count; obj_idx++) { \
503 if (!APP_PARAM_VALID(&((obj_array)[obj_idx]))) \
506 if (strcmp(key, (obj_array)[obj_idx].name) == 0) \
509 obj_idx < obj_count ? obj_idx : -ENOENT; \
512 #define APP_PARAM_FIND_BY_ID(obj_array, prefix, id, obj) \
514 char name[APP_PARAM_NAME_SIZE]; \
517 sprintf(name, prefix "%" PRIu32, id); \
518 pos = APP_PARAM_FIND(obj_array, name); \
519 obj = (pos < 0) ? NULL : &((obj_array)[pos]); \
522 #define APP_PARAM_GET_ID(obj, prefix, id) \
524 sscanf(obj->name, prefix "%" SCNu32, &id); \
527 #define APP_PARAM_ADD(obj_array, obj_name) \
530 const ssize_t obj_count = RTE_DIM(obj_array); \
532 obj_idx = APP_PARAM_FIND(obj_array, obj_name); \
534 for (obj_idx = 0; obj_idx < obj_count; obj_idx++) { \
535 if (!APP_PARAM_VALID(&((obj_array)[obj_idx]))) \
539 if (obj_idx < obj_count) { \
540 (obj_array)[obj_idx].name = strdup(obj_name); \
541 if ((obj_array)[obj_idx].name == NULL) \
549 #define APP_CHECK(exp, fmt, ...) \
552 fprintf(stderr, fmt "\n", ## __VA_ARGS__); \
558 APP_LOG_LEVEL_HIGH = 1,
563 #define APP_LOG(app, level, fmt, ...) \
565 if (app->log_level >= APP_LOG_LEVEL_ ## level) \
566 fprintf(stdout, "[APP] " fmt "\n", ## __VA_ARGS__); \
569 static inline uint32_t
570 app_link_get_n_rxq(struct app_params *app, struct app_link_params *link)
572 uint32_t n_rxq = 0, link_id, i;
573 uint32_t n_pktq_hwq_in = RTE_MIN(app->n_pktq_hwq_in,
574 RTE_DIM(app->hwq_in_params));
576 APP_PARAM_GET_ID(link, "LINK", link_id);
578 for (i = 0; i < n_pktq_hwq_in; i++) {
579 struct app_pktq_hwq_in_params *p = &app->hwq_in_params[i];
580 uint32_t rxq_link_id, rxq_queue_id;
582 sscanf(p->name, "RXQ%" SCNu32 ".%" SCNu32,
583 &rxq_link_id, &rxq_queue_id);
584 if (rxq_link_id == link_id)
591 static inline uint32_t
592 app_link_get_n_txq(struct app_params *app, struct app_link_params *link)
594 uint32_t n_txq = 0, link_id, i;
595 uint32_t n_pktq_hwq_out = RTE_MIN(app->n_pktq_hwq_out,
596 RTE_DIM(app->hwq_out_params));
598 APP_PARAM_GET_ID(link, "LINK", link_id);
600 for (i = 0; i < n_pktq_hwq_out; i++) {
601 struct app_pktq_hwq_out_params *p = &app->hwq_out_params[i];
602 uint32_t txq_link_id, txq_queue_id;
604 sscanf(p->name, "TXQ%" SCNu32 ".%" SCNu32,
605 &txq_link_id, &txq_queue_id);
606 if (txq_link_id == link_id)
613 static inline uint32_t
614 app_rxq_get_readers(struct app_params *app, struct app_pktq_hwq_in_params *rxq)
616 uint32_t pos = rxq - app->hwq_in_params;
617 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
618 RTE_DIM(app->pipeline_params));
619 uint32_t n_readers = 0, i;
621 for (i = 0; i < n_pipelines; i++) {
622 struct app_pipeline_params *p = &app->pipeline_params[i];
623 uint32_t n_pktq_in = RTE_MIN(p->n_pktq_in, RTE_DIM(p->pktq_in));
626 for (j = 0; j < n_pktq_in; j++) {
627 struct app_pktq_in_params *pktq = &p->pktq_in[j];
629 if ((pktq->type == APP_PKTQ_IN_HWQ) &&
638 static inline uint32_t
639 app_swq_get_readers(struct app_params *app, struct app_pktq_swq_params *swq)
641 uint32_t pos = swq - app->swq_params;
642 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
643 RTE_DIM(app->pipeline_params));
644 uint32_t n_readers = 0, i;
646 for (i = 0; i < n_pipelines; i++) {
647 struct app_pipeline_params *p = &app->pipeline_params[i];
648 uint32_t n_pktq_in = RTE_MIN(p->n_pktq_in, RTE_DIM(p->pktq_in));
651 for (j = 0; j < n_pktq_in; j++) {
652 struct app_pktq_in_params *pktq = &p->pktq_in[j];
654 if ((pktq->type == APP_PKTQ_IN_SWQ) &&
663 static inline uint32_t
664 app_tm_get_readers(struct app_params *app, struct app_pktq_tm_params *tm)
666 uint32_t pos = tm - app->tm_params;
667 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
668 RTE_DIM(app->pipeline_params));
669 uint32_t n_readers = 0, i;
671 for (i = 0; i < n_pipelines; i++) {
672 struct app_pipeline_params *p = &app->pipeline_params[i];
673 uint32_t n_pktq_in = RTE_MIN(p->n_pktq_in, RTE_DIM(p->pktq_in));
676 for (j = 0; j < n_pktq_in; j++) {
677 struct app_pktq_in_params *pktq = &p->pktq_in[j];
679 if ((pktq->type == APP_PKTQ_IN_TM) &&
688 static inline uint32_t
689 app_source_get_readers(struct app_params *app,
690 struct app_pktq_source_params *source)
692 uint32_t pos = source - app->source_params;
693 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
694 RTE_DIM(app->pipeline_params));
695 uint32_t n_readers = 0, i;
697 for (i = 0; i < n_pipelines; i++) {
698 struct app_pipeline_params *p = &app->pipeline_params[i];
699 uint32_t n_pktq_in = RTE_MIN(p->n_pktq_in, RTE_DIM(p->pktq_in));
702 for (j = 0; j < n_pktq_in; j++) {
703 struct app_pktq_in_params *pktq = &p->pktq_in[j];
705 if ((pktq->type == APP_PKTQ_IN_SOURCE) &&
714 static inline uint32_t
715 app_msgq_get_readers(struct app_params *app, struct app_msgq_params *msgq)
717 uint32_t pos = msgq - app->msgq_params;
718 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
719 RTE_DIM(app->pipeline_params));
720 uint32_t n_readers = 0, i;
722 for (i = 0; i < n_pipelines; i++) {
723 struct app_pipeline_params *p = &app->pipeline_params[i];
724 uint32_t n_msgq_in = RTE_MIN(p->n_msgq_in, RTE_DIM(p->msgq_in));
727 for (j = 0; j < n_msgq_in; j++)
728 if (p->msgq_in[j] == pos)
735 static inline uint32_t
736 app_txq_get_writers(struct app_params *app, struct app_pktq_hwq_out_params *txq)
738 uint32_t pos = txq - app->hwq_out_params;
739 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
740 RTE_DIM(app->pipeline_params));
741 uint32_t n_writers = 0, i;
743 for (i = 0; i < n_pipelines; i++) {
744 struct app_pipeline_params *p = &app->pipeline_params[i];
745 uint32_t n_pktq_out = RTE_MIN(p->n_pktq_out,
746 RTE_DIM(p->pktq_out));
749 for (j = 0; j < n_pktq_out; j++) {
750 struct app_pktq_out_params *pktq = &p->pktq_out[j];
752 if ((pktq->type == APP_PKTQ_OUT_HWQ) &&
761 static inline uint32_t
762 app_swq_get_writers(struct app_params *app, struct app_pktq_swq_params *swq)
764 uint32_t pos = swq - app->swq_params;
765 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
766 RTE_DIM(app->pipeline_params));
767 uint32_t n_writers = 0, i;
769 for (i = 0; i < n_pipelines; i++) {
770 struct app_pipeline_params *p = &app->pipeline_params[i];
771 uint32_t n_pktq_out = RTE_MIN(p->n_pktq_out,
772 RTE_DIM(p->pktq_out));
775 for (j = 0; j < n_pktq_out; j++) {
776 struct app_pktq_out_params *pktq = &p->pktq_out[j];
778 if ((pktq->type == APP_PKTQ_OUT_SWQ) &&
787 static inline uint32_t
788 app_tm_get_writers(struct app_params *app, struct app_pktq_tm_params *tm)
790 uint32_t pos = tm - app->tm_params;
791 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
792 RTE_DIM(app->pipeline_params));
793 uint32_t n_writers = 0, i;
795 for (i = 0; i < n_pipelines; i++) {
796 struct app_pipeline_params *p = &app->pipeline_params[i];
797 uint32_t n_pktq_out = RTE_MIN(p->n_pktq_out,
798 RTE_DIM(p->pktq_out));
801 for (j = 0; j < n_pktq_out; j++) {
802 struct app_pktq_out_params *pktq = &p->pktq_out[j];
804 if ((pktq->type == APP_PKTQ_OUT_TM) &&
813 static inline uint32_t
814 app_sink_get_writers(struct app_params *app, struct app_pktq_sink_params *sink)
816 uint32_t pos = sink - app->sink_params;
817 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
818 RTE_DIM(app->pipeline_params));
819 uint32_t n_writers = 0, i;
821 for (i = 0; i < n_pipelines; i++) {
822 struct app_pipeline_params *p = &app->pipeline_params[i];
823 uint32_t n_pktq_out = RTE_MIN(p->n_pktq_out,
824 RTE_DIM(p->pktq_out));
827 for (j = 0; j < n_pktq_out; j++) {
828 struct app_pktq_out_params *pktq = &p->pktq_out[j];
830 if ((pktq->type == APP_PKTQ_OUT_SINK) &&
839 static inline uint32_t
840 app_core_is_enabled(struct app_params *app, uint32_t lcore_id) {
841 return(app->core_mask[lcore_id / 64] &
842 (1LLU << (lcore_id % 64)));
846 app_core_enable_in_core_mask(struct app_params *app, int lcore_id) {
847 app->core_mask[lcore_id / 64] |= 1LLU << (lcore_id % 64);
852 app_core_build_core_mask_string(struct app_params *app, char
856 mask_buffer[0] = '\0';
857 for (i = (int)RTE_DIM(app->core_mask); i > 0; i--) {
858 /* For Hex representation of bits in uint64_t */
859 char buffer[(64 / 8) * 2 + 1];
860 memset(buffer, 0, sizeof(buffer));
861 snprintf(buffer, sizeof(buffer), "%016" PRIx64,
862 app->core_mask[i-1]);
863 strcat(mask_buffer, buffer);
867 static inline uint32_t
868 app_msgq_get_writers(struct app_params *app, struct app_msgq_params *msgq)
870 uint32_t pos = msgq - app->msgq_params;
871 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
872 RTE_DIM(app->pipeline_params));
873 uint32_t n_writers = 0, i;
875 for (i = 0; i < n_pipelines; i++) {
876 struct app_pipeline_params *p = &app->pipeline_params[i];
877 uint32_t n_msgq_out = RTE_MIN(p->n_msgq_out,
878 RTE_DIM(p->msgq_out));
881 for (j = 0; j < n_msgq_out; j++)
882 if (p->msgq_out[j] == pos)
889 static inline struct app_link_params *
890 app_get_link_for_rxq(struct app_params *app, struct app_pktq_hwq_in_params *p)
892 char link_name[APP_PARAM_NAME_SIZE];
893 ssize_t link_param_idx;
894 uint32_t rxq_link_id, rxq_queue_id;
896 sscanf(p->name, "RXQ%" SCNu32 ".%" SCNu32,
897 &rxq_link_id, &rxq_queue_id);
898 sprintf(link_name, "LINK%" PRIu32, rxq_link_id);
899 link_param_idx = APP_PARAM_FIND(app->link_params, link_name);
900 APP_CHECK((link_param_idx >= 0),
901 "Cannot find %s for %s", link_name, p->name);
903 return &app->link_params[link_param_idx];
906 static inline struct app_link_params *
907 app_get_link_for_txq(struct app_params *app, struct app_pktq_hwq_out_params *p)
909 char link_name[APP_PARAM_NAME_SIZE];
910 ssize_t link_param_idx;
911 uint32_t txq_link_id, txq_queue_id;
913 sscanf(p->name, "TXQ%" SCNu32 ".%" SCNu32,
914 &txq_link_id, &txq_queue_id);
915 sprintf(link_name, "LINK%" PRIu32, txq_link_id);
916 link_param_idx = APP_PARAM_FIND(app->link_params, link_name);
917 APP_CHECK((link_param_idx >= 0),
918 "Cannot find %s for %s", link_name, p->name);
920 return &app->link_params[link_param_idx];
923 static inline struct app_link_params *
924 app_get_link_for_tm(struct app_params *app, struct app_pktq_tm_params *p_tm)
926 char link_name[APP_PARAM_NAME_SIZE];
928 ssize_t link_param_idx;
930 sscanf(p_tm->name, "TM%" PRIu32, &link_id);
931 sprintf(link_name, "LINK%" PRIu32, link_id);
932 link_param_idx = APP_PARAM_FIND(app->link_params, link_name);
933 APP_CHECK((link_param_idx >= 0),
934 "Cannot find %s for %s", link_name, p_tm->name);
936 return &app->link_params[link_param_idx];
939 int app_config_init(struct app_params *app);
941 int app_config_args(struct app_params *app,
942 int argc, char **argv);
944 int app_config_preproc(struct app_params *app);
946 int app_config_parse(struct app_params *app,
947 const char *file_name);
949 int app_config_parse_tm(struct app_params *app);
951 void app_config_save(struct app_params *app,
952 const char *file_name);
954 int app_config_check(struct app_params *app);
956 int app_init(struct app_params *app);
958 int app_thread(void *arg);
960 int app_pipeline_type_register(struct app_params *app,
961 struct pipeline_type *ptype);
963 struct pipeline_type *app_pipeline_type_find(struct app_params *app,
966 void app_link_up_internal(struct app_params *app,
967 struct app_link_params *cp);
969 void app_link_down_internal(struct app_params *app,
970 struct app_link_params *cp);