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];
244 struct app_pipeline_data {
247 struct pipeline_type *ptype;
248 uint64_t timer_period;
252 struct app_thread_pipeline_data {
253 uint32_t pipeline_id;
255 pipeline_be_op_run f_run;
256 pipeline_be_op_timer f_timer;
257 uint64_t timer_period;
261 #ifndef APP_MAX_THREAD_PIPELINES
262 #define APP_MAX_THREAD_PIPELINES 64
265 #ifndef APP_THREAD_TIMER_PERIOD
266 #define APP_THREAD_TIMER_PERIOD 1
269 struct app_thread_data {
270 struct app_thread_pipeline_data regular[APP_MAX_THREAD_PIPELINES];
271 struct app_thread_pipeline_data custom[APP_MAX_THREAD_PIPELINES];
276 uint64_t timer_period;
277 uint64_t thread_req_deadline;
281 struct rte_ring *msgq_in;
282 struct rte_ring *msgq_out;
284 uint64_t headroom_time;
285 uint64_t headroom_cycles;
286 double headroom_ratio;
289 #ifndef APP_MAX_LINKS
290 #define APP_MAX_LINKS 16
293 struct app_eal_params {
294 /* Map lcore set to physical cpu set */
297 /* Core ID that is used as master */
298 uint32_t master_lcore_present;
299 uint32_t master_lcore;
301 /* Number of memory channels */
302 uint32_t channels_present;
305 /* Memory to allocate (see also --socket-mem) */
306 uint32_t memory_present;
309 /* Force number of memory ranks (don't detect) */
310 uint32_t ranks_present;
313 /* Add a PCI device in black list. */
314 char *pci_blacklist[APP_MAX_LINKS];
316 /* Add a PCI device in white list. */
317 char *pci_whitelist[APP_MAX_LINKS];
319 /* Add a virtual device. */
320 char *vdev[APP_MAX_LINKS];
322 /* Use VMware TSC map instead of native RDTSC */
323 uint32_t vmware_tsc_map_present;
326 /* Type of this process (primary|secondary|auto) */
329 /* Set syslog facility */
332 /* Set default log level */
333 uint32_t log_level_present;
336 /* Display version information on startup */
337 uint32_t version_present;
341 uint32_t help_present;
344 /* Use malloc instead of hugetlbfs */
345 uint32_t no_huge_present;
349 uint32_t no_pci_present;
353 uint32_t no_hpet_present;
356 /* No shared config (mmap'd files) */
357 uint32_t no_shconf_present;
363 /* Memory to allocate on sockets (comma separated values)*/
366 /* Directory where hugetlbfs is mounted */
369 /* Prefix for hugepage filenames */
372 /* Base virtual address */
375 /* Create /dev/uioX (usually done by hotplug) */
376 uint32_t create_uio_dev_present;
379 /* Interrupt mode for VFIO (legacy|msi|msix) */
382 /* Support running on Xen dom0 without hugetlbfs */
383 uint32_t xen_dom0_present;
389 #ifndef APP_APPNAME_SIZE
390 #define APP_APPNAME_SIZE 256
393 #ifndef APP_MAX_MEMPOOLS
394 #define APP_MAX_MEMPOOLS 8
397 #define APP_MAX_HWQ_IN (APP_MAX_LINKS * APP_LINK_MAX_HWQ_IN)
399 #define APP_MAX_HWQ_OUT (APP_MAX_LINKS * APP_LINK_MAX_HWQ_OUT)
401 #ifndef APP_MAX_PKTQ_SWQ
402 #define APP_MAX_PKTQ_SWQ 256
405 #define APP_MAX_PKTQ_TM APP_MAX_LINKS
407 #ifndef APP_MAX_PKTQ_SOURCE
408 #define APP_MAX_PKTQ_SOURCE 64
411 #ifndef APP_MAX_PKTQ_SINK
412 #define APP_MAX_PKTQ_SINK 64
416 #define APP_MAX_MSGQ 256
419 #ifndef APP_MAX_PIPELINES
420 #define APP_MAX_PIPELINES 64
424 #define APP_EAL_ARGC 64
427 #ifndef APP_MAX_PIPELINE_TYPES
428 #define APP_MAX_PIPELINE_TYPES 64
431 #ifndef APP_MAX_THREADS
432 #define APP_MAX_THREADS RTE_MAX_LCORE
436 #define APP_MAX_CMDS 64
439 #ifndef APP_THREAD_HEADROOM_STATS_COLLECT
440 #define APP_THREAD_HEADROOM_STATS_COLLECT 1
445 char app_name[APP_APPNAME_SIZE];
446 const char *config_file;
447 const char *script_file;
448 const char *parser_file;
449 const char *output_file;
451 const char *preproc_args;
455 struct app_eal_params eal_params;
456 struct app_mempool_params mempool_params[APP_MAX_MEMPOOLS];
457 struct app_link_params link_params[APP_MAX_LINKS];
458 struct app_pktq_hwq_in_params hwq_in_params[APP_MAX_HWQ_IN];
459 struct app_pktq_hwq_out_params hwq_out_params[APP_MAX_HWQ_OUT];
460 struct app_pktq_swq_params swq_params[APP_MAX_PKTQ_SWQ];
461 struct app_pktq_tm_params tm_params[APP_MAX_PKTQ_TM];
462 struct app_pktq_source_params source_params[APP_MAX_PKTQ_SOURCE];
463 struct app_pktq_sink_params sink_params[APP_MAX_PKTQ_SINK];
464 struct app_msgq_params msgq_params[APP_MAX_MSGQ];
465 struct app_pipeline_params pipeline_params[APP_MAX_PIPELINES];
469 uint32_t n_pktq_hwq_in;
470 uint32_t n_pktq_hwq_out;
473 uint32_t n_pktq_source;
474 uint32_t n_pktq_sink;
476 uint32_t n_pipelines;
479 char *eal_argv[1 + APP_EAL_ARGC];
480 struct cpu_core_map *core_map;
482 struct rte_mempool *mempool[APP_MAX_MEMPOOLS];
483 struct rte_ring *swq[APP_MAX_PKTQ_SWQ];
484 struct rte_sched_port *tm[APP_MAX_PKTQ_TM];
485 struct rte_ring *msgq[APP_MAX_MSGQ];
486 struct pipeline_type pipeline_type[APP_MAX_PIPELINE_TYPES];
487 struct app_pipeline_data pipeline_data[APP_MAX_PIPELINES];
488 struct app_thread_data thread_data[APP_MAX_THREADS];
489 cmdline_parse_ctx_t cmds[APP_MAX_CMDS + 1];
492 uint32_t n_pipeline_types;
496 #define APP_PARAM_VALID(obj) ((obj)->name != NULL)
498 #define APP_PARAM_COUNT(obj_array, n_objs) \
503 for (i = 0; i < RTE_DIM(obj_array); i++) \
504 if (APP_PARAM_VALID(&((obj_array)[i]))) \
508 #define APP_PARAM_FIND(obj_array, key) \
511 const ssize_t obj_count = RTE_DIM(obj_array); \
513 for (obj_idx = 0; obj_idx < obj_count; obj_idx++) { \
514 if (!APP_PARAM_VALID(&((obj_array)[obj_idx]))) \
517 if (strcmp(key, (obj_array)[obj_idx].name) == 0) \
520 obj_idx < obj_count ? obj_idx : -ENOENT; \
523 #define APP_PARAM_FIND_BY_ID(obj_array, prefix, id, obj) \
525 char name[APP_PARAM_NAME_SIZE]; \
528 sprintf(name, prefix "%" PRIu32, id); \
529 pos = APP_PARAM_FIND(obj_array, name); \
530 obj = (pos < 0) ? NULL : &((obj_array)[pos]); \
533 #define APP_PARAM_GET_ID(obj, prefix, id) \
535 sscanf(obj->name, prefix "%" SCNu32, &id); \
538 #define APP_CHECK(exp, fmt, ...) \
541 fprintf(stderr, fmt "\n", ## __VA_ARGS__); \
547 APP_LOG_LEVEL_HIGH = 1,
552 #define APP_LOG(app, level, fmt, ...) \
554 if (app->log_level >= APP_LOG_LEVEL_ ## level) \
555 fprintf(stdout, "[APP] " fmt "\n", ## __VA_ARGS__); \
558 static inline uint32_t
559 app_link_get_n_rxq(struct app_params *app, struct app_link_params *link)
561 uint32_t n_rxq = 0, link_id, i;
562 uint32_t n_pktq_hwq_in = RTE_MIN(app->n_pktq_hwq_in,
563 RTE_DIM(app->hwq_in_params));
565 APP_PARAM_GET_ID(link, "LINK", link_id);
567 for (i = 0; i < n_pktq_hwq_in; i++) {
568 struct app_pktq_hwq_in_params *p = &app->hwq_in_params[i];
569 uint32_t rxq_link_id, rxq_queue_id;
571 sscanf(p->name, "RXQ%" SCNu32 ".%" SCNu32,
572 &rxq_link_id, &rxq_queue_id);
573 if (rxq_link_id == link_id)
580 static inline uint32_t
581 app_link_get_n_txq(struct app_params *app, struct app_link_params *link)
583 uint32_t n_txq = 0, link_id, i;
584 uint32_t n_pktq_hwq_out = RTE_MIN(app->n_pktq_hwq_out,
585 RTE_DIM(app->hwq_out_params));
587 APP_PARAM_GET_ID(link, "LINK", link_id);
589 for (i = 0; i < n_pktq_hwq_out; i++) {
590 struct app_pktq_hwq_out_params *p = &app->hwq_out_params[i];
591 uint32_t txq_link_id, txq_queue_id;
593 sscanf(p->name, "TXQ%" SCNu32 ".%" SCNu32,
594 &txq_link_id, &txq_queue_id);
595 if (txq_link_id == link_id)
602 static inline uint32_t
603 app_rxq_get_readers(struct app_params *app, struct app_pktq_hwq_in_params *rxq)
605 uint32_t pos = rxq - app->hwq_in_params;
606 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
607 RTE_DIM(app->pipeline_params));
608 uint32_t n_readers = 0, i;
610 for (i = 0; i < n_pipelines; i++) {
611 struct app_pipeline_params *p = &app->pipeline_params[i];
612 uint32_t n_pktq_in = RTE_MIN(p->n_pktq_in, RTE_DIM(p->pktq_in));
615 for (j = 0; j < n_pktq_in; j++) {
616 struct app_pktq_in_params *pktq = &p->pktq_in[j];
618 if ((pktq->type == APP_PKTQ_IN_HWQ) &&
627 static inline uint32_t
628 app_swq_get_readers(struct app_params *app, struct app_pktq_swq_params *swq)
630 uint32_t pos = swq - app->swq_params;
631 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
632 RTE_DIM(app->pipeline_params));
633 uint32_t n_readers = 0, i;
635 for (i = 0; i < n_pipelines; i++) {
636 struct app_pipeline_params *p = &app->pipeline_params[i];
637 uint32_t n_pktq_in = RTE_MIN(p->n_pktq_in, RTE_DIM(p->pktq_in));
640 for (j = 0; j < n_pktq_in; j++) {
641 struct app_pktq_in_params *pktq = &p->pktq_in[j];
643 if ((pktq->type == APP_PKTQ_IN_SWQ) &&
652 static inline struct app_pipeline_params *
653 app_swq_get_reader(struct app_params *app,
654 struct app_pktq_swq_params *swq,
655 uint32_t *pktq_in_id)
657 struct app_pipeline_params *reader;
658 uint32_t pos = swq - app->swq_params;
659 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
660 RTE_DIM(app->pipeline_params));
661 uint32_t n_readers = 0, id, i;
663 for (i = 0; i < n_pipelines; i++) {
664 struct app_pipeline_params *p = &app->pipeline_params[i];
665 uint32_t n_pktq_in = RTE_MIN(p->n_pktq_in, RTE_DIM(p->pktq_in));
668 for (j = 0; j < n_pktq_in; j++) {
669 struct app_pktq_in_params *pktq = &p->pktq_in[j];
671 if ((pktq->type == APP_PKTQ_IN_SWQ) &&
687 static inline uint32_t
688 app_tm_get_readers(struct app_params *app, struct app_pktq_tm_params *tm)
690 uint32_t pos = tm - app->tm_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_TM) &&
712 static inline struct app_pipeline_params *
713 app_tm_get_reader(struct app_params *app,
714 struct app_pktq_tm_params *tm,
715 uint32_t *pktq_in_id)
717 struct app_pipeline_params *reader;
718 uint32_t pos = tm - app->tm_params;
719 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
720 RTE_DIM(app->pipeline_params));
721 uint32_t n_readers = 0, id, 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_TM) &&
747 static inline uint32_t
748 app_source_get_readers(struct app_params *app,
749 struct app_pktq_source_params *source)
751 uint32_t pos = source - app->source_params;
752 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
753 RTE_DIM(app->pipeline_params));
754 uint32_t n_readers = 0, i;
756 for (i = 0; i < n_pipelines; i++) {
757 struct app_pipeline_params *p = &app->pipeline_params[i];
758 uint32_t n_pktq_in = RTE_MIN(p->n_pktq_in, RTE_DIM(p->pktq_in));
761 for (j = 0; j < n_pktq_in; j++) {
762 struct app_pktq_in_params *pktq = &p->pktq_in[j];
764 if ((pktq->type == APP_PKTQ_IN_SOURCE) &&
773 static inline uint32_t
774 app_msgq_get_readers(struct app_params *app, struct app_msgq_params *msgq)
776 uint32_t pos = msgq - app->msgq_params;
777 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
778 RTE_DIM(app->pipeline_params));
779 uint32_t n_readers = 0, i;
781 for (i = 0; i < n_pipelines; i++) {
782 struct app_pipeline_params *p = &app->pipeline_params[i];
783 uint32_t n_msgq_in = RTE_MIN(p->n_msgq_in, RTE_DIM(p->msgq_in));
786 for (j = 0; j < n_msgq_in; j++)
787 if (p->msgq_in[j] == pos)
794 static inline uint32_t
795 app_txq_get_writers(struct app_params *app, struct app_pktq_hwq_out_params *txq)
797 uint32_t pos = txq - app->hwq_out_params;
798 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
799 RTE_DIM(app->pipeline_params));
800 uint32_t n_writers = 0, i;
802 for (i = 0; i < n_pipelines; i++) {
803 struct app_pipeline_params *p = &app->pipeline_params[i];
804 uint32_t n_pktq_out = RTE_MIN(p->n_pktq_out,
805 RTE_DIM(p->pktq_out));
808 for (j = 0; j < n_pktq_out; j++) {
809 struct app_pktq_out_params *pktq = &p->pktq_out[j];
811 if ((pktq->type == APP_PKTQ_OUT_HWQ) &&
820 static inline uint32_t
821 app_swq_get_writers(struct app_params *app, struct app_pktq_swq_params *swq)
823 uint32_t pos = swq - app->swq_params;
824 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
825 RTE_DIM(app->pipeline_params));
826 uint32_t n_writers = 0, i;
828 for (i = 0; i < n_pipelines; i++) {
829 struct app_pipeline_params *p = &app->pipeline_params[i];
830 uint32_t n_pktq_out = RTE_MIN(p->n_pktq_out,
831 RTE_DIM(p->pktq_out));
834 for (j = 0; j < n_pktq_out; j++) {
835 struct app_pktq_out_params *pktq = &p->pktq_out[j];
837 if ((pktq->type == APP_PKTQ_OUT_SWQ) &&
846 static inline struct app_pipeline_params *
847 app_swq_get_writer(struct app_params *app,
848 struct app_pktq_swq_params *swq,
849 uint32_t *pktq_out_id)
851 struct app_pipeline_params *writer;
852 uint32_t pos = swq - app->swq_params;
853 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
854 RTE_DIM(app->pipeline_params));
855 uint32_t n_writers = 0, id, i;
857 for (i = 0; i < n_pipelines; i++) {
858 struct app_pipeline_params *p = &app->pipeline_params[i];
859 uint32_t n_pktq_out = RTE_MIN(p->n_pktq_out,
860 RTE_DIM(p->pktq_out));
863 for (j = 0; j < n_pktq_out; j++) {
864 struct app_pktq_out_params *pktq = &p->pktq_out[j];
866 if ((pktq->type == APP_PKTQ_OUT_SWQ) &&
882 static inline uint32_t
883 app_tm_get_writers(struct app_params *app, struct app_pktq_tm_params *tm)
885 uint32_t pos = tm - app->tm_params;
886 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
887 RTE_DIM(app->pipeline_params));
888 uint32_t n_writers = 0, i;
890 for (i = 0; i < n_pipelines; i++) {
891 struct app_pipeline_params *p = &app->pipeline_params[i];
892 uint32_t n_pktq_out = RTE_MIN(p->n_pktq_out,
893 RTE_DIM(p->pktq_out));
896 for (j = 0; j < n_pktq_out; j++) {
897 struct app_pktq_out_params *pktq = &p->pktq_out[j];
899 if ((pktq->type == APP_PKTQ_OUT_TM) &&
908 static inline struct app_pipeline_params *
909 app_tm_get_writer(struct app_params *app,
910 struct app_pktq_tm_params *tm,
911 uint32_t *pktq_out_id)
913 struct app_pipeline_params *writer;
914 uint32_t pos = tm - app->tm_params;
915 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
916 RTE_DIM(app->pipeline_params));
917 uint32_t n_writers = 0, id, i;
919 for (i = 0; i < n_pipelines; i++) {
920 struct app_pipeline_params *p = &app->pipeline_params[i];
921 uint32_t n_pktq_out = RTE_MIN(p->n_pktq_out,
922 RTE_DIM(p->pktq_out));
925 for (j = 0; j < n_pktq_out; j++) {
926 struct app_pktq_out_params *pktq = &p->pktq_out[j];
928 if ((pktq->type == APP_PKTQ_OUT_TM) &&
943 static inline uint32_t
944 app_sink_get_writers(struct app_params *app, struct app_pktq_sink_params *sink)
946 uint32_t pos = sink - app->sink_params;
947 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
948 RTE_DIM(app->pipeline_params));
949 uint32_t n_writers = 0, i;
951 for (i = 0; i < n_pipelines; i++) {
952 struct app_pipeline_params *p = &app->pipeline_params[i];
953 uint32_t n_pktq_out = RTE_MIN(p->n_pktq_out,
954 RTE_DIM(p->pktq_out));
957 for (j = 0; j < n_pktq_out; j++) {
958 struct app_pktq_out_params *pktq = &p->pktq_out[j];
960 if ((pktq->type == APP_PKTQ_OUT_SINK) &&
969 static inline uint32_t
970 app_msgq_get_writers(struct app_params *app, struct app_msgq_params *msgq)
972 uint32_t pos = msgq - app->msgq_params;
973 uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
974 RTE_DIM(app->pipeline_params));
975 uint32_t n_writers = 0, i;
977 for (i = 0; i < n_pipelines; i++) {
978 struct app_pipeline_params *p = &app->pipeline_params[i];
979 uint32_t n_msgq_out = RTE_MIN(p->n_msgq_out,
980 RTE_DIM(p->msgq_out));
983 for (j = 0; j < n_msgq_out; j++)
984 if (p->msgq_out[j] == pos)
991 static inline struct app_link_params *
992 app_get_link_for_rxq(struct app_params *app, struct app_pktq_hwq_in_params *p)
994 char link_name[APP_PARAM_NAME_SIZE];
995 ssize_t link_param_idx;
996 uint32_t rxq_link_id, rxq_queue_id;
998 sscanf(p->name, "RXQ%" SCNu32 ".%" SCNu32,
999 &rxq_link_id, &rxq_queue_id);
1000 sprintf(link_name, "LINK%" PRIu32, rxq_link_id);
1001 link_param_idx = APP_PARAM_FIND(app->link_params, link_name);
1002 APP_CHECK((link_param_idx >= 0),
1003 "Cannot find %s for %s", link_name, p->name);
1005 return &app->link_params[link_param_idx];
1008 static inline struct app_link_params *
1009 app_get_link_for_txq(struct app_params *app, struct app_pktq_hwq_out_params *p)
1011 char link_name[APP_PARAM_NAME_SIZE];
1012 ssize_t link_param_idx;
1013 uint32_t txq_link_id, txq_queue_id;
1015 sscanf(p->name, "TXQ%" SCNu32 ".%" SCNu32,
1016 &txq_link_id, &txq_queue_id);
1017 sprintf(link_name, "LINK%" PRIu32, txq_link_id);
1018 link_param_idx = APP_PARAM_FIND(app->link_params, link_name);
1019 APP_CHECK((link_param_idx >= 0),
1020 "Cannot find %s for %s", link_name, p->name);
1022 return &app->link_params[link_param_idx];
1025 static inline struct app_link_params *
1026 app_get_link_for_tm(struct app_params *app, struct app_pktq_tm_params *p_tm)
1028 char link_name[APP_PARAM_NAME_SIZE];
1030 ssize_t link_param_idx;
1032 sscanf(p_tm->name, "TM%" PRIu32, &link_id);
1033 sprintf(link_name, "LINK%" PRIu32, link_id);
1034 link_param_idx = APP_PARAM_FIND(app->link_params, link_name);
1035 APP_CHECK((link_param_idx >= 0),
1036 "Cannot find %s for %s", link_name, p_tm->name);
1038 return &app->link_params[link_param_idx];
1041 void app_pipeline_params_get(struct app_params *app,
1042 struct app_pipeline_params *p_in,
1043 struct pipeline_params *p_out);
1045 int app_config_init(struct app_params *app);
1047 int app_config_args(struct app_params *app,
1048 int argc, char **argv);
1050 int app_config_preproc(struct app_params *app);
1052 int app_config_parse(struct app_params *app,
1053 const char *file_name);
1055 int app_config_parse_tm(struct app_params *app);
1057 void app_config_save(struct app_params *app,
1058 const char *file_name);
1060 int app_config_check(struct app_params *app);
1062 int app_init(struct app_params *app);
1064 int app_post_init(struct app_params *app);
1066 int app_thread(void *arg);
1068 int app_pipeline_type_register(struct app_params *app,
1069 struct pipeline_type *ptype);
1071 struct pipeline_type *app_pipeline_type_find(struct app_params *app,
1074 void app_link_up_internal(struct app_params *app,
1075 struct app_link_params *cp);
1077 void app_link_down_internal(struct app_params *app,
1078 struct app_link_params *cp);