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
54 #ifndef APP_LINK_MAX_HWQ_IN
55 #define APP_LINK_MAX_HWQ_IN 128
58 #ifndef APP_LINK_MAX_HWQ_OUT
59 #define APP_LINK_MAX_HWQ_OUT 128
62 struct app_mempool_params {
68 uint32_t cpu_socket_id;
71 struct app_link_params {
74 uint32_t pmd_id; /* Generated based on port mask */
75 uint32_t arp_q; /* 0 = Disabled (packets go to default queue 0) */
76 uint32_t tcp_syn_q; /* 0 = Disabled (pkts go to default queue) */
77 uint32_t ip_local_q; /* 0 = Disabled (pkts go to default queue 0) */
78 uint32_t tcp_local_q; /* 0 = Disabled (pkts go to default queue 0) */
79 uint32_t udp_local_q; /* 0 = Disabled (pkts go to default queue 0) */
80 uint32_t sctp_local_q; /* 0 = Disabled (pkts go to default queue 0) */
81 uint32_t rss_qs[APP_LINK_MAX_HWQ_IN];
83 uint64_t rss_proto_ipv4;
84 uint64_t rss_proto_ipv6;
85 uint64_t rss_proto_l2;
87 uint32_t state; /* DOWN = 0, UP = 1 */
88 uint32_t ip; /* 0 = Invalid */
89 uint32_t depth; /* Valid only when IP is valid */
90 uint64_t mac_addr; /* Read from HW */
91 char pci_bdf[APP_LINK_PCI_BDF_SIZE];
93 struct rte_eth_conf conf;
96 struct app_pktq_hwq_in_params {
99 uint32_t mempool_id; /* Position in the app->mempool_params */
103 struct rte_eth_rxconf conf;
106 struct app_pktq_hwq_out_params {
113 struct rte_eth_txconf conf;
116 struct app_pktq_swq_params {
121 uint32_t burst_write;
124 uint32_t cpu_socket_id;
130 uint32_t metadata_size;
131 uint32_t mempool_direct_id;
132 uint32_t mempool_indirect_id;
135 #ifndef APP_FILE_NAME_SIZE
136 #define APP_FILE_NAME_SIZE 256
139 #ifndef APP_MAX_SCHED_SUBPORTS
140 #define APP_MAX_SCHED_SUBPORTS 8
143 #ifndef APP_MAX_SCHED_PIPES
144 #define APP_MAX_SCHED_PIPES 4096
147 struct app_pktq_tm_params {
150 const char *file_name;
151 struct rte_sched_port_params sched_port_params;
152 struct rte_sched_subport_params
153 sched_subport_params[APP_MAX_SCHED_SUBPORTS];
154 struct rte_sched_pipe_params
155 sched_pipe_profiles[RTE_SCHED_PIPE_PROFILES_PER_PORT];
156 int sched_pipe_to_profile[APP_MAX_SCHED_SUBPORTS * APP_MAX_SCHED_PIPES];
158 uint32_t burst_write;
161 struct app_pktq_source_params {
164 uint32_t mempool_id; /* Position in the app->mempool_params array */
166 char *file_name; /* Full path of PCAP file to be copied to mbufs */
167 uint32_t n_bytes_per_pkt;
170 struct app_pktq_sink_params {
173 char *file_name; /* Full path of PCAP file to be copied to mbufs */
174 uint32_t n_pkts_to_dump;
177 struct app_msgq_params {
181 uint32_t cpu_socket_id;
184 enum app_pktq_in_type {
191 struct app_pktq_in_params {
192 enum app_pktq_in_type type;
193 uint32_t id; /* Position in the appropriate app array */
196 enum app_pktq_out_type {
203 struct app_pktq_out_params {
204 enum app_pktq_out_type type;
205 uint32_t id; /* Position in the appropriate app array */
208 #define APP_PIPELINE_TYPE_SIZE PIPELINE_TYPE_SIZE
210 #define APP_MAX_PIPELINE_PKTQ_IN PIPELINE_MAX_PORT_IN
211 #define APP_MAX_PIPELINE_PKTQ_OUT PIPELINE_MAX_PORT_OUT
212 #define APP_MAX_PIPELINE_MSGQ_IN PIPELINE_MAX_MSGQ_IN
213 #define APP_MAX_PIPELINE_MSGQ_OUT PIPELINE_MAX_MSGQ_OUT
215 #define APP_MAX_PIPELINE_ARGS PIPELINE_MAX_ARGS
217 struct app_pipeline_params {
221 char type[APP_PIPELINE_TYPE_SIZE];
225 uint32_t hyper_th_id;
227 struct app_pktq_in_params pktq_in[APP_MAX_PIPELINE_PKTQ_IN];
228 struct app_pktq_out_params pktq_out[APP_MAX_PIPELINE_PKTQ_OUT];
229 uint32_t msgq_in[APP_MAX_PIPELINE_MSGQ_IN];
230 uint32_t msgq_out[APP_MAX_PIPELINE_MSGQ_OUT];
237 uint32_t timer_period;
239 char *args_name[APP_MAX_PIPELINE_ARGS];
240 char *args_value[APP_MAX_PIPELINE_ARGS];
246 typedef void (*app_link_op)(struct app_params *app,
251 #ifndef APP_MAX_PIPELINES
252 #define APP_MAX_PIPELINES 64
255 struct app_link_data {
256 app_link_op f_link[APP_MAX_PIPELINES];
257 void *arg[APP_MAX_PIPELINES];
260 struct app_pipeline_data {
263 struct pipeline_type *ptype;
264 uint64_t timer_period;
268 struct app_thread_pipeline_data {
269 uint32_t pipeline_id;
271 pipeline_be_op_run f_run;
272 pipeline_be_op_timer f_timer;
273 uint64_t timer_period;
277 #ifndef APP_MAX_THREAD_PIPELINES
278 #define APP_MAX_THREAD_PIPELINES 64
281 #ifndef APP_THREAD_TIMER_PERIOD
282 #define APP_THREAD_TIMER_PERIOD 1
285 struct app_thread_data {
286 struct app_thread_pipeline_data regular[APP_MAX_THREAD_PIPELINES];
287 struct app_thread_pipeline_data custom[APP_MAX_THREAD_PIPELINES];
292 uint64_t timer_period;
293 uint64_t thread_req_deadline;
297 struct rte_ring *msgq_in;
298 struct rte_ring *msgq_out;
300 uint64_t headroom_time;
301 uint64_t headroom_cycles;
302 double headroom_ratio;
305 #ifndef APP_MAX_LINKS
306 #define APP_MAX_LINKS 16
309 struct app_eal_params {
310 /* Map lcore set to physical cpu set */
313 /* Core ID that is used as master */
314 uint32_t master_lcore_present;
315 uint32_t master_lcore;
317 /* Number of memory channels */
318 uint32_t channels_present;
321 /* Memory to allocate (see also --socket-mem) */
322 uint32_t memory_present;
325 /* Force number of memory ranks (don't detect) */
326 uint32_t ranks_present;
329 /* Add a PCI device in black list. */
330 char *pci_blacklist[APP_MAX_LINKS];
332 /* Add a PCI device in white list. */
333 char *pci_whitelist[APP_MAX_LINKS];
335 /* Add a virtual device. */
336 char *vdev[APP_MAX_LINKS];
338 /* Use VMware TSC map instead of native RDTSC */
339 uint32_t vmware_tsc_map_present;
342 /* Type of this process (primary|secondary|auto) */
345 /* Set syslog facility */
348 /* Set default log level */
349 uint32_t log_level_present;
352 /* Display version information on startup */
353 uint32_t version_present;
357 uint32_t help_present;
360 /* Use malloc instead of hugetlbfs */
361 uint32_t no_huge_present;
365 uint32_t no_pci_present;
369 uint32_t no_hpet_present;
372 /* No shared config (mmap'd files) */
373 uint32_t no_shconf_present;
379 /* Memory to allocate on sockets (comma separated values)*/
382 /* Directory where hugetlbfs is mounted */
385 /* Prefix for hugepage filenames */
388 /* Base virtual address */
391 /* Create /dev/uioX (usually done by hotplug) */
392 uint32_t create_uio_dev_present;
395 /* Interrupt mode for VFIO (legacy|msi|msix) */
398 /* Support running on Xen dom0 without hugetlbfs */
399 uint32_t xen_dom0_present;
405 #ifndef APP_APPNAME_SIZE
406 #define APP_APPNAME_SIZE 256
409 #ifndef APP_MAX_MEMPOOLS
410 #define APP_MAX_MEMPOOLS 8
413 #define APP_MAX_HWQ_IN (APP_MAX_LINKS * APP_LINK_MAX_HWQ_IN)
415 #define APP_MAX_HWQ_OUT (APP_MAX_LINKS * APP_LINK_MAX_HWQ_OUT)
417 #ifndef APP_MAX_PKTQ_SWQ
418 #define APP_MAX_PKTQ_SWQ 256
421 #define APP_MAX_PKTQ_TM APP_MAX_LINKS
423 #ifndef APP_MAX_PKTQ_SOURCE
424 #define APP_MAX_PKTQ_SOURCE 64
427 #ifndef APP_MAX_PKTQ_SINK
428 #define APP_MAX_PKTQ_SINK 64
432 #define APP_MAX_MSGQ 256
436 #define APP_EAL_ARGC 64
439 #ifndef APP_MAX_PIPELINE_TYPES
440 #define APP_MAX_PIPELINE_TYPES 64
443 #ifndef APP_MAX_THREADS
444 #define APP_MAX_THREADS RTE_MAX_LCORE
448 #define APP_MAX_CMDS 64
451 #ifndef APP_THREAD_HEADROOM_STATS_COLLECT
452 #define APP_THREAD_HEADROOM_STATS_COLLECT 1
457 char app_name[APP_APPNAME_SIZE];
458 const char *config_file;
459 const char *script_file;
460 const char *parser_file;
461 const char *output_file;
463 const char *preproc_args;
467 struct app_eal_params eal_params;
468 struct app_mempool_params mempool_params[APP_MAX_MEMPOOLS];
469 struct app_link_params link_params[APP_MAX_LINKS];
470 struct app_pktq_hwq_in_params hwq_in_params[APP_MAX_HWQ_IN];
471 struct app_pktq_hwq_out_params hwq_out_params[APP_MAX_HWQ_OUT];
472 struct app_pktq_swq_params swq_params[APP_MAX_PKTQ_SWQ];
473 struct app_pktq_tm_params tm_params[APP_MAX_PKTQ_TM];
474 struct app_pktq_source_params source_params[APP_MAX_PKTQ_SOURCE];
475 struct app_pktq_sink_params sink_params[APP_MAX_PKTQ_SINK];
476 struct app_msgq_params msgq_params[APP_MAX_MSGQ];
477 struct app_pipeline_params pipeline_params[APP_MAX_PIPELINES];
481 uint32_t n_pktq_hwq_in;
482 uint32_t n_pktq_hwq_out;
485 uint32_t n_pktq_source;
486 uint32_t n_pktq_sink;
488 uint32_t n_pipelines;
491 char *eal_argv[1 + APP_EAL_ARGC];
492 struct cpu_core_map *core_map;
494 struct rte_mempool *mempool[APP_MAX_MEMPOOLS];
495 struct app_link_data link_data[APP_MAX_LINKS];
496 struct rte_ring *swq[APP_MAX_PKTQ_SWQ];
497 struct rte_sched_port *tm[APP_MAX_PKTQ_TM];
498 struct rte_ring *msgq[APP_MAX_MSGQ];
499 struct pipeline_type pipeline_type[APP_MAX_PIPELINE_TYPES];
500 struct app_pipeline_data pipeline_data[APP_MAX_PIPELINES];
501 struct app_thread_data thread_data[APP_MAX_THREADS];
502 cmdline_parse_ctx_t cmds[APP_MAX_CMDS + 1];
505 uint32_t n_pipeline_types;
509 #define APP_PARAM_VALID(obj) ((obj)->name != NULL)
511 #define APP_PARAM_COUNT(obj_array, n_objs) \
516 for (i = 0; i < RTE_DIM(obj_array); i++) \
517 if (APP_PARAM_VALID(&((obj_array)[i]))) \
521 #define APP_PARAM_FIND(obj_array, key) \
524 const ssize_t obj_count = RTE_DIM(obj_array); \
526 for (obj_idx = 0; obj_idx < obj_count; obj_idx++) { \
527 if (!APP_PARAM_VALID(&((obj_array)[obj_idx]))) \
530 if (strcmp(key, (obj_array)[obj_idx].name) == 0) \
533 obj_idx < obj_count ? obj_idx : -ENOENT; \
536 #define APP_PARAM_FIND_BY_ID(obj_array, prefix, id, obj) \
538 char name[APP_PARAM_NAME_SIZE]; \
541 sprintf(name, prefix "%" PRIu32, id); \
542 pos = APP_PARAM_FIND(obj_array, name); \
543 obj = (pos < 0) ? NULL : &((obj_array)[pos]); \
546 #define APP_PARAM_GET_ID(obj, prefix, id) \
548 sscanf(obj->name, prefix "%" SCNu32, &id); \
551 #define APP_CHECK(exp, fmt, ...) \
554 fprintf(stderr, fmt "\n", ## __VA_ARGS__); \
560 APP_LOG_LEVEL_HIGH = 1,
565 #define APP_LOG(app, level, fmt, ...) \
567 if (app->log_level >= APP_LOG_LEVEL_ ## level) \
568 fprintf(stdout, "[APP] " fmt "\n", ## __VA_ARGS__); \
571 static inline uint32_t
572 app_link_get_n_rxq(struct app_params *app, struct app_link_params *link)
574 uint32_t n_rxq = 0, link_id, i;
575 uint32_t n_pktq_hwq_in = RTE_MIN(app->n_pktq_hwq_in,
576 RTE_DIM(app->hwq_in_params));
578 APP_PARAM_GET_ID(link, "LINK", link_id);
580 for (i = 0; i < n_pktq_hwq_in; i++) {
581 struct app_pktq_hwq_in_params *p = &app->hwq_in_params[i];
582 uint32_t rxq_link_id, rxq_queue_id;
584 sscanf(p->name, "RXQ%" SCNu32 ".%" SCNu32,
585 &rxq_link_id, &rxq_queue_id);
586 if (rxq_link_id == link_id)
593 static inline uint32_t
594 app_link_get_n_txq(struct app_params *app, struct app_link_params *link)
596 uint32_t n_txq = 0, link_id, i;
597 uint32_t n_pktq_hwq_out = RTE_MIN(app->n_pktq_hwq_out,
598 RTE_DIM(app->hwq_out_params));
600 APP_PARAM_GET_ID(link, "LINK", link_id);
602 for (i = 0; i < n_pktq_hwq_out; i++) {
603 struct app_pktq_hwq_out_params *p = &app->hwq_out_params[i];
604 uint32_t txq_link_id, txq_queue_id;
606 sscanf(p->name, "TXQ%" SCNu32 ".%" SCNu32,
607 &txq_link_id, &txq_queue_id);
608 if (txq_link_id == link_id)
615 static inline uint32_t
616 app_rxq_get_readers(struct app_params *app, struct app_pktq_hwq_in_params *rxq)
618 uint32_t pos = rxq - app->hwq_in_params;
619 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
620 RTE_DIM(app->pipeline_params));
621 uint32_t n_readers = 0, i;
623 for (i = 0; i < n_pipelines; i++) {
624 struct app_pipeline_params *p = &app->pipeline_params[i];
625 uint32_t n_pktq_in = RTE_MIN(p->n_pktq_in, RTE_DIM(p->pktq_in));
628 for (j = 0; j < n_pktq_in; j++) {
629 struct app_pktq_in_params *pktq = &p->pktq_in[j];
631 if ((pktq->type == APP_PKTQ_IN_HWQ) &&
640 static inline uint32_t
641 app_swq_get_readers(struct app_params *app, struct app_pktq_swq_params *swq)
643 uint32_t pos = swq - app->swq_params;
644 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
645 RTE_DIM(app->pipeline_params));
646 uint32_t n_readers = 0, i;
648 for (i = 0; i < n_pipelines; i++) {
649 struct app_pipeline_params *p = &app->pipeline_params[i];
650 uint32_t n_pktq_in = RTE_MIN(p->n_pktq_in, RTE_DIM(p->pktq_in));
653 for (j = 0; j < n_pktq_in; j++) {
654 struct app_pktq_in_params *pktq = &p->pktq_in[j];
656 if ((pktq->type == APP_PKTQ_IN_SWQ) &&
665 static inline struct app_pipeline_params *
666 app_swq_get_reader(struct app_params *app,
667 struct app_pktq_swq_params *swq,
668 uint32_t *pktq_in_id)
670 struct app_pipeline_params *reader;
671 uint32_t pos = swq - app->swq_params;
672 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
673 RTE_DIM(app->pipeline_params));
674 uint32_t n_readers = 0, id, i;
676 for (i = 0; i < n_pipelines; i++) {
677 struct app_pipeline_params *p = &app->pipeline_params[i];
678 uint32_t n_pktq_in = RTE_MIN(p->n_pktq_in, RTE_DIM(p->pktq_in));
681 for (j = 0; j < n_pktq_in; j++) {
682 struct app_pktq_in_params *pktq = &p->pktq_in[j];
684 if ((pktq->type == APP_PKTQ_IN_SWQ) &&
700 static inline uint32_t
701 app_tm_get_readers(struct app_params *app, struct app_pktq_tm_params *tm)
703 uint32_t pos = tm - app->tm_params;
704 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
705 RTE_DIM(app->pipeline_params));
706 uint32_t n_readers = 0, i;
708 for (i = 0; i < n_pipelines; i++) {
709 struct app_pipeline_params *p = &app->pipeline_params[i];
710 uint32_t n_pktq_in = RTE_MIN(p->n_pktq_in, RTE_DIM(p->pktq_in));
713 for (j = 0; j < n_pktq_in; j++) {
714 struct app_pktq_in_params *pktq = &p->pktq_in[j];
716 if ((pktq->type == APP_PKTQ_IN_TM) &&
725 static inline struct app_pipeline_params *
726 app_tm_get_reader(struct app_params *app,
727 struct app_pktq_tm_params *tm,
728 uint32_t *pktq_in_id)
730 struct app_pipeline_params *reader;
731 uint32_t pos = tm - app->tm_params;
732 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
733 RTE_DIM(app->pipeline_params));
734 uint32_t n_readers = 0, id, i;
736 for (i = 0; i < n_pipelines; i++) {
737 struct app_pipeline_params *p = &app->pipeline_params[i];
738 uint32_t n_pktq_in = RTE_MIN(p->n_pktq_in, RTE_DIM(p->pktq_in));
741 for (j = 0; j < n_pktq_in; j++) {
742 struct app_pktq_in_params *pktq = &p->pktq_in[j];
744 if ((pktq->type == APP_PKTQ_IN_TM) &&
760 static inline uint32_t
761 app_source_get_readers(struct app_params *app,
762 struct app_pktq_source_params *source)
764 uint32_t pos = source - app->source_params;
765 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
766 RTE_DIM(app->pipeline_params));
767 uint32_t n_readers = 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_in = RTE_MIN(p->n_pktq_in, RTE_DIM(p->pktq_in));
774 for (j = 0; j < n_pktq_in; j++) {
775 struct app_pktq_in_params *pktq = &p->pktq_in[j];
777 if ((pktq->type == APP_PKTQ_IN_SOURCE) &&
786 static inline uint32_t
787 app_msgq_get_readers(struct app_params *app, struct app_msgq_params *msgq)
789 uint32_t pos = msgq - app->msgq_params;
790 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
791 RTE_DIM(app->pipeline_params));
792 uint32_t n_readers = 0, i;
794 for (i = 0; i < n_pipelines; i++) {
795 struct app_pipeline_params *p = &app->pipeline_params[i];
796 uint32_t n_msgq_in = RTE_MIN(p->n_msgq_in, RTE_DIM(p->msgq_in));
799 for (j = 0; j < n_msgq_in; j++)
800 if (p->msgq_in[j] == pos)
807 static inline uint32_t
808 app_txq_get_writers(struct app_params *app, struct app_pktq_hwq_out_params *txq)
810 uint32_t pos = txq - app->hwq_out_params;
811 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
812 RTE_DIM(app->pipeline_params));
813 uint32_t n_writers = 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_out = RTE_MIN(p->n_pktq_out,
818 RTE_DIM(p->pktq_out));
821 for (j = 0; j < n_pktq_out; j++) {
822 struct app_pktq_out_params *pktq = &p->pktq_out[j];
824 if ((pktq->type == APP_PKTQ_OUT_HWQ) &&
833 static inline uint32_t
834 app_swq_get_writers(struct app_params *app, struct app_pktq_swq_params *swq)
836 uint32_t pos = swq - app->swq_params;
837 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
838 RTE_DIM(app->pipeline_params));
839 uint32_t n_writers = 0, i;
841 for (i = 0; i < n_pipelines; i++) {
842 struct app_pipeline_params *p = &app->pipeline_params[i];
843 uint32_t n_pktq_out = RTE_MIN(p->n_pktq_out,
844 RTE_DIM(p->pktq_out));
847 for (j = 0; j < n_pktq_out; j++) {
848 struct app_pktq_out_params *pktq = &p->pktq_out[j];
850 if ((pktq->type == APP_PKTQ_OUT_SWQ) &&
859 static inline struct app_pipeline_params *
860 app_swq_get_writer(struct app_params *app,
861 struct app_pktq_swq_params *swq,
862 uint32_t *pktq_out_id)
864 struct app_pipeline_params *writer;
865 uint32_t pos = swq - app->swq_params;
866 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
867 RTE_DIM(app->pipeline_params));
868 uint32_t n_writers = 0, id, i;
870 for (i = 0; i < n_pipelines; i++) {
871 struct app_pipeline_params *p = &app->pipeline_params[i];
872 uint32_t n_pktq_out = RTE_MIN(p->n_pktq_out,
873 RTE_DIM(p->pktq_out));
876 for (j = 0; j < n_pktq_out; j++) {
877 struct app_pktq_out_params *pktq = &p->pktq_out[j];
879 if ((pktq->type == APP_PKTQ_OUT_SWQ) &&
895 static inline uint32_t
896 app_tm_get_writers(struct app_params *app, struct app_pktq_tm_params *tm)
898 uint32_t pos = tm - app->tm_params;
899 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
900 RTE_DIM(app->pipeline_params));
901 uint32_t n_writers = 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_out = RTE_MIN(p->n_pktq_out,
906 RTE_DIM(p->pktq_out));
909 for (j = 0; j < n_pktq_out; j++) {
910 struct app_pktq_out_params *pktq = &p->pktq_out[j];
912 if ((pktq->type == APP_PKTQ_OUT_TM) &&
921 static inline struct app_pipeline_params *
922 app_tm_get_writer(struct app_params *app,
923 struct app_pktq_tm_params *tm,
924 uint32_t *pktq_out_id)
926 struct app_pipeline_params *writer;
927 uint32_t pos = tm - app->tm_params;
928 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
929 RTE_DIM(app->pipeline_params));
930 uint32_t n_writers = 0, id, i;
932 for (i = 0; i < n_pipelines; i++) {
933 struct app_pipeline_params *p = &app->pipeline_params[i];
934 uint32_t n_pktq_out = RTE_MIN(p->n_pktq_out,
935 RTE_DIM(p->pktq_out));
938 for (j = 0; j < n_pktq_out; j++) {
939 struct app_pktq_out_params *pktq = &p->pktq_out[j];
941 if ((pktq->type == APP_PKTQ_OUT_TM) &&
956 static inline uint32_t
957 app_sink_get_writers(struct app_params *app, struct app_pktq_sink_params *sink)
959 uint32_t pos = sink - app->sink_params;
960 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
961 RTE_DIM(app->pipeline_params));
962 uint32_t n_writers = 0, i;
964 for (i = 0; i < n_pipelines; i++) {
965 struct app_pipeline_params *p = &app->pipeline_params[i];
966 uint32_t n_pktq_out = RTE_MIN(p->n_pktq_out,
967 RTE_DIM(p->pktq_out));
970 for (j = 0; j < n_pktq_out; j++) {
971 struct app_pktq_out_params *pktq = &p->pktq_out[j];
973 if ((pktq->type == APP_PKTQ_OUT_SINK) &&
982 static inline uint32_t
983 app_msgq_get_writers(struct app_params *app, struct app_msgq_params *msgq)
985 uint32_t pos = msgq - app->msgq_params;
986 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
987 RTE_DIM(app->pipeline_params));
988 uint32_t n_writers = 0, i;
990 for (i = 0; i < n_pipelines; i++) {
991 struct app_pipeline_params *p = &app->pipeline_params[i];
992 uint32_t n_msgq_out = RTE_MIN(p->n_msgq_out,
993 RTE_DIM(p->msgq_out));
996 for (j = 0; j < n_msgq_out; j++)
997 if (p->msgq_out[j] == pos)
1004 static inline struct app_link_params *
1005 app_get_link_for_rxq(struct app_params *app, struct app_pktq_hwq_in_params *p)
1007 char link_name[APP_PARAM_NAME_SIZE];
1008 ssize_t link_param_idx;
1009 uint32_t rxq_link_id, rxq_queue_id;
1011 sscanf(p->name, "RXQ%" SCNu32 ".%" SCNu32,
1012 &rxq_link_id, &rxq_queue_id);
1013 sprintf(link_name, "LINK%" PRIu32, rxq_link_id);
1014 link_param_idx = APP_PARAM_FIND(app->link_params, link_name);
1015 APP_CHECK((link_param_idx >= 0),
1016 "Cannot find %s for %s", link_name, p->name);
1018 return &app->link_params[link_param_idx];
1021 static inline struct app_link_params *
1022 app_get_link_for_txq(struct app_params *app, struct app_pktq_hwq_out_params *p)
1024 char link_name[APP_PARAM_NAME_SIZE];
1025 ssize_t link_param_idx;
1026 uint32_t txq_link_id, txq_queue_id;
1028 sscanf(p->name, "TXQ%" SCNu32 ".%" SCNu32,
1029 &txq_link_id, &txq_queue_id);
1030 sprintf(link_name, "LINK%" PRIu32, txq_link_id);
1031 link_param_idx = APP_PARAM_FIND(app->link_params, link_name);
1032 APP_CHECK((link_param_idx >= 0),
1033 "Cannot find %s for %s", link_name, p->name);
1035 return &app->link_params[link_param_idx];
1038 static inline struct app_link_params *
1039 app_get_link_for_tm(struct app_params *app, struct app_pktq_tm_params *p_tm)
1041 char link_name[APP_PARAM_NAME_SIZE];
1043 ssize_t link_param_idx;
1045 sscanf(p_tm->name, "TM%" PRIu32, &link_id);
1046 sprintf(link_name, "LINK%" PRIu32, link_id);
1047 link_param_idx = APP_PARAM_FIND(app->link_params, link_name);
1048 APP_CHECK((link_param_idx >= 0),
1049 "Cannot find %s for %s", link_name, p_tm->name);
1051 return &app->link_params[link_param_idx];
1054 void app_pipeline_params_get(struct app_params *app,
1055 struct app_pipeline_params *p_in,
1056 struct pipeline_params *p_out);
1058 int app_config_init(struct app_params *app);
1060 int app_config_args(struct app_params *app,
1061 int argc, char **argv);
1063 int app_config_preproc(struct app_params *app);
1065 int app_config_parse(struct app_params *app,
1066 const char *file_name);
1068 int app_config_parse_tm(struct app_params *app);
1070 void app_config_save(struct app_params *app,
1071 const char *file_name);
1073 int app_config_check(struct app_params *app);
1075 int app_init(struct app_params *app);
1077 int app_post_init(struct app_params *app);
1079 int app_thread(void *arg);
1081 int app_pipeline_type_register(struct app_params *app,
1082 struct pipeline_type *ptype);
1084 struct pipeline_type *app_pipeline_type_find(struct app_params *app,
1087 void app_link_up_internal(struct app_params *app,
1088 struct app_link_params *cp);
1090 void app_link_down_internal(struct app_params *app,
1091 struct app_link_params *cp);