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>
51 #include "cpu_core_map.h"
54 #define APP_PARAM_NAME_SIZE PIPELINE_NAME_SIZE
55 #define APP_LINK_PCI_BDF_SIZE 16
57 #ifndef APP_LINK_MAX_HWQ_IN
58 #define APP_LINK_MAX_HWQ_IN 128
61 #ifndef APP_LINK_MAX_HWQ_OUT
62 #define APP_LINK_MAX_HWQ_OUT 128
65 struct app_mempool_params {
71 uint32_t cpu_socket_id;
74 struct app_link_params {
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];
86 uint64_t rss_proto_ipv4;
87 uint64_t rss_proto_ipv6;
88 uint64_t rss_proto_l2;
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];
96 struct rte_eth_conf conf;
99 struct app_pktq_hwq_in_params {
102 uint32_t mempool_id; /* Position in the app->mempool_params */
106 struct rte_eth_rxconf conf;
109 struct app_pktq_hwq_out_params {
116 struct rte_eth_txconf conf;
119 struct app_pktq_swq_params {
124 uint32_t burst_write;
127 uint32_t cpu_socket_id;
133 uint32_t metadata_size;
134 uint32_t mempool_direct_id;
135 uint32_t mempool_indirect_id;
138 struct app_pktq_kni_params {
144 uint32_t hyper_th_id;
147 uint32_t mempool_id; /* Position in the app->mempool_params */
149 uint32_t burst_write;
154 #ifndef APP_FILE_NAME_SIZE
155 #define APP_FILE_NAME_SIZE 256
158 #ifndef APP_MAX_SCHED_SUBPORTS
159 #define APP_MAX_SCHED_SUBPORTS 8
162 #ifndef APP_MAX_SCHED_PIPES
163 #define APP_MAX_SCHED_PIPES 4096
166 struct app_pktq_tm_params {
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];
177 uint32_t burst_write;
180 struct app_pktq_tap_params {
184 uint32_t burst_write;
187 uint32_t mempool_id; /* Position in the app->mempool_params */
190 struct app_pktq_source_params {
193 uint32_t mempool_id; /* Position in the app->mempool_params array */
195 const char *file_name; /* Full path of PCAP file to be copied to mbufs */
196 uint32_t n_bytes_per_pkt;
199 struct app_pktq_sink_params {
202 const char *file_name; /* Full path of PCAP file to be copied to mbufs */
203 uint32_t n_pkts_to_dump;
206 struct app_msgq_params {
210 uint32_t cpu_socket_id;
213 enum app_pktq_in_type {
222 struct app_pktq_in_params {
223 enum app_pktq_in_type type;
224 uint32_t id; /* Position in the appropriate app array */
227 enum app_pktq_out_type {
236 struct app_pktq_out_params {
237 enum app_pktq_out_type type;
238 uint32_t id; /* Position in the appropriate app array */
241 #define APP_PIPELINE_TYPE_SIZE PIPELINE_TYPE_SIZE
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
248 #define APP_MAX_PIPELINE_ARGS PIPELINE_MAX_ARGS
250 struct app_pipeline_params {
254 char type[APP_PIPELINE_TYPE_SIZE];
258 uint32_t hyper_th_id;
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];
270 uint32_t timer_period;
272 char *args_name[APP_MAX_PIPELINE_ARGS];
273 char *args_value[APP_MAX_PIPELINE_ARGS];
279 typedef void (*app_link_op)(struct app_params *app,
284 #ifndef APP_MAX_PIPELINES
285 #define APP_MAX_PIPELINES 64
288 struct app_link_data {
289 app_link_op f_link[APP_MAX_PIPELINES];
290 void *arg[APP_MAX_PIPELINES];
293 struct app_pipeline_data {
296 struct pipeline_type *ptype;
297 uint64_t timer_period;
301 struct app_thread_pipeline_data {
302 uint32_t pipeline_id;
304 pipeline_be_op_run f_run;
305 pipeline_be_op_timer f_timer;
306 uint64_t timer_period;
310 #ifndef APP_MAX_THREAD_PIPELINES
311 #define APP_MAX_THREAD_PIPELINES 64
314 #ifndef APP_THREAD_TIMER_PERIOD
315 #define APP_THREAD_TIMER_PERIOD 1
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];
325 uint64_t timer_period;
326 uint64_t thread_req_deadline;
330 struct rte_ring *msgq_in;
331 struct rte_ring *msgq_out;
333 uint64_t headroom_time;
334 uint64_t headroom_cycles;
335 double headroom_ratio;
336 } __rte_cache_aligned;
338 #ifndef APP_MAX_LINKS
339 #define APP_MAX_LINKS 16
342 struct app_eal_params {
343 /* Map lcore set to physical cpu set */
346 /* Core ID that is used as master */
347 uint32_t master_lcore_present;
348 uint32_t master_lcore;
350 /* Number of memory channels */
351 uint32_t channels_present;
354 /* Memory to allocate (see also --socket-mem) */
355 uint32_t memory_present;
358 /* Force number of memory ranks (don't detect) */
359 uint32_t ranks_present;
362 /* Add a PCI device in black list. */
363 char *pci_blacklist[APP_MAX_LINKS];
365 /* Add a PCI device in white list. */
366 char *pci_whitelist[APP_MAX_LINKS];
368 /* Add a virtual device. */
369 char *vdev[APP_MAX_LINKS];
371 /* Use VMware TSC map instead of native RDTSC */
372 uint32_t vmware_tsc_map_present;
375 /* Type of this process (primary|secondary|auto) */
378 /* Set syslog facility */
381 /* Set default log level */
382 uint32_t log_level_present;
385 /* Display version information on startup */
386 uint32_t version_present;
390 uint32_t help_present;
393 /* Use malloc instead of hugetlbfs */
394 uint32_t no_huge_present;
398 uint32_t no_pci_present;
402 uint32_t no_hpet_present;
405 /* No shared config (mmap'd files) */
406 uint32_t no_shconf_present;
412 /* Memory to allocate on sockets (comma separated values)*/
415 /* Directory where hugetlbfs is mounted */
418 /* Prefix for hugepage filenames */
421 /* Base virtual address */
424 /* Create /dev/uioX (usually done by hotplug) */
425 uint32_t create_uio_dev_present;
428 /* Interrupt mode for VFIO (legacy|msi|msix) */
431 /* Support running on Xen dom0 without hugetlbfs */
432 uint32_t xen_dom0_present;
438 #ifndef APP_APPNAME_SIZE
439 #define APP_APPNAME_SIZE 256
442 #ifndef APP_MAX_MEMPOOLS
443 #define APP_MAX_MEMPOOLS 8
446 #define APP_MAX_HWQ_IN (APP_MAX_LINKS * APP_LINK_MAX_HWQ_IN)
448 #define APP_MAX_HWQ_OUT (APP_MAX_LINKS * APP_LINK_MAX_HWQ_OUT)
450 #ifndef APP_MAX_PKTQ_SWQ
451 #define APP_MAX_PKTQ_SWQ 256
454 #define APP_MAX_PKTQ_TM APP_MAX_LINKS
456 #ifndef APP_MAX_PKTQ_TAP
457 #define APP_MAX_PKTQ_TAP APP_MAX_LINKS
460 #define APP_MAX_PKTQ_KNI APP_MAX_LINKS
462 #ifndef APP_MAX_PKTQ_SOURCE
463 #define APP_MAX_PKTQ_SOURCE 64
466 #ifndef APP_MAX_PKTQ_SINK
467 #define APP_MAX_PKTQ_SINK 64
471 #define APP_MAX_MSGQ 256
475 #define APP_EAL_ARGC 64
478 #ifndef APP_MAX_PIPELINE_TYPES
479 #define APP_MAX_PIPELINE_TYPES 64
482 #ifndef APP_MAX_THREADS
483 #define APP_MAX_THREADS RTE_MAX_LCORE
487 #define APP_MAX_CMDS 64
490 #ifndef APP_THREAD_HEADROOM_STATS_COLLECT
491 #define APP_THREAD_HEADROOM_STATS_COLLECT 1
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;
502 const char *preproc_args;
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];
522 uint32_t n_pktq_hwq_in;
523 uint32_t n_pktq_hwq_out;
528 uint32_t n_pktq_source;
529 uint32_t n_pktq_sink;
531 uint32_t n_pipelines;
534 char *eal_argv[1 + APP_EAL_ARGC];
535 struct cpu_core_map *core_map;
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];
552 uint32_t n_pipeline_types;
556 #define APP_PARAM_VALID(obj) ((obj)->name != NULL)
558 #define APP_PARAM_COUNT(obj_array, n_objs) \
563 for (i = 0; i < RTE_DIM(obj_array); i++) \
564 if (APP_PARAM_VALID(&((obj_array)[i]))) \
568 #define APP_PARAM_FIND(obj_array, key) \
571 const ssize_t obj_count = RTE_DIM(obj_array); \
573 for (obj_idx = 0; obj_idx < obj_count; obj_idx++) { \
574 if (!APP_PARAM_VALID(&((obj_array)[obj_idx]))) \
577 if (strcmp(key, (obj_array)[obj_idx].name) == 0) \
580 obj_idx < obj_count ? obj_idx : -ENOENT; \
583 #define APP_PARAM_FIND_BY_ID(obj_array, prefix, id, obj) \
585 char name[APP_PARAM_NAME_SIZE]; \
588 sprintf(name, prefix "%" PRIu32, id); \
589 pos = APP_PARAM_FIND(obj_array, name); \
590 obj = (pos < 0) ? NULL : &((obj_array)[pos]); \
593 #define APP_PARAM_GET_ID(obj, prefix, id) \
595 sscanf(obj->name, prefix "%" SCNu32, &id); \
598 #define APP_CHECK(exp, fmt, ...) \
601 fprintf(stderr, fmt "\n", ## __VA_ARGS__); \
607 APP_LOG_LEVEL_HIGH = 1,
612 #define APP_LOG(app, level, fmt, ...) \
614 if (app->log_level >= APP_LOG_LEVEL_ ## level) \
615 fprintf(stdout, "[APP] " fmt "\n", ## __VA_ARGS__); \
618 static inline uint32_t
619 app_link_get_n_rxq(struct app_params *app, struct app_link_params *link)
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));
625 APP_PARAM_GET_ID(link, "LINK", link_id);
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;
631 sscanf(p->name, "RXQ%" SCNu32 ".%" SCNu32,
632 &rxq_link_id, &rxq_queue_id);
633 if (rxq_link_id == link_id)
640 static inline uint32_t
641 app_link_get_n_txq(struct app_params *app, struct app_link_params *link)
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));
647 APP_PARAM_GET_ID(link, "LINK", link_id);
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;
653 sscanf(p->name, "TXQ%" SCNu32 ".%" SCNu32,
654 &txq_link_id, &txq_queue_id);
655 if (txq_link_id == link_id)
662 static inline uint32_t
663 app_rxq_get_readers(struct app_params *app, struct app_pktq_hwq_in_params *rxq)
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;
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));
675 for (j = 0; j < n_pktq_in; j++) {
676 struct app_pktq_in_params *pktq = &p->pktq_in[j];
678 if ((pktq->type == APP_PKTQ_IN_HWQ) &&
687 static inline uint32_t
688 app_swq_get_readers(struct app_params *app, struct app_pktq_swq_params *swq)
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;
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));
700 for (j = 0; j < n_pktq_in; j++) {
701 struct app_pktq_in_params *pktq = &p->pktq_in[j];
703 if ((pktq->type == APP_PKTQ_IN_SWQ) &&
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)
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;
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));
728 for (j = 0; j < n_pktq_in; j++) {
729 struct app_pktq_in_params *pktq = &p->pktq_in[j];
731 if ((pktq->type == APP_PKTQ_IN_SWQ) &&
747 static inline uint32_t
748 app_tm_get_readers(struct app_params *app, struct app_pktq_tm_params *tm)
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;
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));
760 for (j = 0; j < n_pktq_in; j++) {
761 struct app_pktq_in_params *pktq = &p->pktq_in[j];
763 if ((pktq->type == APP_PKTQ_IN_TM) &&
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)
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;
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));
788 for (j = 0; j < n_pktq_in; j++) {
789 struct app_pktq_in_params *pktq = &p->pktq_in[j];
791 if ((pktq->type == APP_PKTQ_IN_TM) &&
807 static inline uint32_t
808 app_tap_get_readers(struct app_params *app, struct app_pktq_tap_params *tap)
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;
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));
820 for (j = 0; j < n_pktq_in; j++) {
821 struct app_pktq_in_params *pktq = &p->pktq_in[j];
823 if ((pktq->type == APP_PKTQ_IN_TAP) &&
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)
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;
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));
848 for (j = 0; j < n_pktq_in; j++) {
849 struct app_pktq_in_params *pktq = &p->pktq_in[j];
851 if ((pktq->type == APP_PKTQ_IN_TAP) &&
867 static inline uint32_t
868 app_kni_get_readers(struct app_params *app, struct app_pktq_kni_params *kni)
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;
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));
880 for (j = 0; j < n_pktq_in; j++) {
881 struct app_pktq_in_params *pktq = &p->pktq_in[j];
883 if ((pktq->type == APP_PKTQ_IN_KNI) &&
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)
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;
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));
908 for (j = 0; j < n_pktq_in; j++) {
909 struct app_pktq_in_params *pktq = &p->pktq_in[j];
911 if ((pktq->type == APP_PKTQ_IN_KNI) &&
927 static inline uint32_t
928 app_source_get_readers(struct app_params *app,
929 struct app_pktq_source_params *source)
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;
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));
941 for (j = 0; j < n_pktq_in; j++) {
942 struct app_pktq_in_params *pktq = &p->pktq_in[j];
944 if ((pktq->type == APP_PKTQ_IN_SOURCE) &&
953 static inline uint32_t
954 app_msgq_get_readers(struct app_params *app, struct app_msgq_params *msgq)
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;
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));
966 for (j = 0; j < n_msgq_in; j++)
967 if (p->msgq_in[j] == pos)
974 static inline uint32_t
975 app_txq_get_writers(struct app_params *app, struct app_pktq_hwq_out_params *txq)
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;
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));
988 for (j = 0; j < n_pktq_out; j++) {
989 struct app_pktq_out_params *pktq = &p->pktq_out[j];
991 if ((pktq->type == APP_PKTQ_OUT_HWQ) &&
1000 static inline uint32_t
1001 app_swq_get_writers(struct app_params *app, struct app_pktq_swq_params *swq)
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;
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));
1014 for (j = 0; j < n_pktq_out; j++) {
1015 struct app_pktq_out_params *pktq = &p->pktq_out[j];
1017 if ((pktq->type == APP_PKTQ_OUT_SWQ) &&
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)
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;
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));
1043 for (j = 0; j < n_pktq_out; j++) {
1044 struct app_pktq_out_params *pktq = &p->pktq_out[j];
1046 if ((pktq->type == APP_PKTQ_OUT_SWQ) &&
1047 (pktq->id == pos)) {
1062 static inline uint32_t
1063 app_tm_get_writers(struct app_params *app, struct app_pktq_tm_params *tm)
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;
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));
1076 for (j = 0; j < n_pktq_out; j++) {
1077 struct app_pktq_out_params *pktq = &p->pktq_out[j];
1079 if ((pktq->type == APP_PKTQ_OUT_TM) &&
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)
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;
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));
1105 for (j = 0; j < n_pktq_out; j++) {
1106 struct app_pktq_out_params *pktq = &p->pktq_out[j];
1108 if ((pktq->type == APP_PKTQ_OUT_TM) &&
1109 (pktq->id == pos)) {
1124 static inline uint32_t
1125 app_tap_get_writers(struct app_params *app, struct app_pktq_tap_params *tap)
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;
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));
1138 for (j = 0; j < n_pktq_out; j++) {
1139 struct app_pktq_out_params *pktq = &p->pktq_out[j];
1141 if ((pktq->type == APP_PKTQ_OUT_TAP) &&
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)
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;
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));
1167 for (j = 0; j < n_pktq_out; j++) {
1168 struct app_pktq_out_params *pktq = &p->pktq_out[j];
1170 if ((pktq->type == APP_PKTQ_OUT_TAP) &&
1171 (pktq->id == pos)) {
1186 static inline uint32_t
1187 app_kni_get_writers(struct app_params *app, struct app_pktq_kni_params *kni)
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;
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));
1200 for (j = 0; j < n_pktq_out; j++) {
1201 struct app_pktq_out_params *pktq = &p->pktq_out[j];
1203 if ((pktq->type == APP_PKTQ_OUT_KNI) &&
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)
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;
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));
1229 for (j = 0; j < n_pktq_out; j++) {
1230 struct app_pktq_out_params *pktq = &p->pktq_out[j];
1232 if ((pktq->type == APP_PKTQ_OUT_KNI) &&
1233 (pktq->id == pos)) {
1248 static inline uint32_t
1249 app_sink_get_writers(struct app_params *app, struct app_pktq_sink_params *sink)
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;
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));
1262 for (j = 0; j < n_pktq_out; j++) {
1263 struct app_pktq_out_params *pktq = &p->pktq_out[j];
1265 if ((pktq->type == APP_PKTQ_OUT_SINK) &&
1274 static inline uint32_t
1275 app_msgq_get_writers(struct app_params *app, struct app_msgq_params *msgq)
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;
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));
1288 for (j = 0; j < n_msgq_out; j++)
1289 if (p->msgq_out[j] == pos)
1296 static inline struct app_link_params *
1297 app_get_link_for_rxq(struct app_params *app, struct app_pktq_hwq_in_params *p)
1299 char link_name[APP_PARAM_NAME_SIZE];
1300 ssize_t link_param_idx;
1301 uint32_t rxq_link_id, rxq_queue_id;
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);
1310 return &app->link_params[link_param_idx];
1313 static inline struct app_link_params *
1314 app_get_link_for_txq(struct app_params *app, struct app_pktq_hwq_out_params *p)
1316 char link_name[APP_PARAM_NAME_SIZE];
1317 ssize_t link_param_idx;
1318 uint32_t txq_link_id, txq_queue_id;
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);
1327 return &app->link_params[link_param_idx];
1330 static inline struct app_link_params *
1331 app_get_link_for_tm(struct app_params *app, struct app_pktq_tm_params *p_tm)
1333 char link_name[APP_PARAM_NAME_SIZE];
1335 ssize_t link_param_idx;
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);
1343 return &app->link_params[link_param_idx];
1346 static inline struct app_link_params *
1347 app_get_link_for_kni(struct app_params *app, struct app_pktq_kni_params *p_kni)
1349 char link_name[APP_PARAM_NAME_SIZE];
1351 ssize_t link_param_idx;
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);
1359 return &app->link_params[link_param_idx];
1362 void app_pipeline_params_get(struct app_params *app,
1363 struct app_pipeline_params *p_in,
1364 struct pipeline_params *p_out);
1366 int app_config_init(struct app_params *app);
1368 int app_config_args(struct app_params *app,
1369 int argc, char **argv);
1371 int app_config_preproc(struct app_params *app);
1373 int app_config_parse(struct app_params *app,
1374 const char *file_name);
1376 int app_config_parse_tm(struct app_params *app);
1378 void app_config_save(struct app_params *app,
1379 const char *file_name);
1381 int app_config_check(struct app_params *app);
1383 int app_init(struct app_params *app);
1385 int app_post_init(struct app_params *app);
1387 int app_thread(void *arg);
1389 int app_pipeline_type_register(struct app_params *app,
1390 struct pipeline_type *ptype);
1392 struct pipeline_type *app_pipeline_type_find(struct app_params *app,
1395 void app_link_up_internal(struct app_params *app,
1396 struct app_link_params *cp);
1398 void app_link_down_internal(struct app_params *app,
1399 struct app_link_params *cp);