4 * Copyright(c) 2010-2014 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.
41 #include <rte_sched.h>
43 #ifdef RTE_EXEC_ENV_BAREMETAL
44 #error "Baremetal is not supported"
49 #define RTE_LOGTYPE_APP RTE_LOGTYPE_USER1
52 * Configurable number of RX/TX ring descriptors
54 #define APP_INTERACTIVE_DEFAULT 0
56 #define APP_RX_DESC_DEFAULT 128
57 #define APP_TX_DESC_DEFAULT 256
59 #define MBUF_SIZE (1528 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM)
60 #define APP_RING_SIZE (8*1024)
61 #define NB_MBUF (2*1024*1024)
63 #define MAX_PKT_RX_BURST 64
64 #define PKT_ENQUEUE 64
65 #define PKT_DEQUEUE 32
66 #define MAX_PKT_TX_BURST 64
68 #define RX_PTHRESH 8 /**< Default values of RX prefetch threshold reg. */
69 #define RX_HTHRESH 8 /**< Default values of RX host threshold reg. */
70 #define RX_WTHRESH 4 /**< Default values of RX write-back threshold reg. */
72 #define TX_PTHRESH 36 /**< Default values of TX prefetch threshold reg. */
73 #define TX_HTHRESH 0 /**< Default values of TX host threshold reg. */
74 #define TX_WTHRESH 0 /**< Default values of TX write-back threshold reg. */
76 #define BURST_TX_DRAIN_US 100
78 #define MAX_DATA_STREAMS (RTE_MAX_LCORE/2)
79 #define MAX_SCHED_SUBPORTS 8
80 #define MAX_SCHED_PIPES 4096
82 #ifndef APP_COLLECT_STAT
83 #define APP_COLLECT_STAT 1
87 #define APP_STATS_ADD(stat,val) (stat) += (val)
89 #define APP_STATS_ADD(stat,val) do {(void) (val);} while (0)
92 #define APP_QAVG_NTIMES 10
93 #define APP_QAVG_PERIOD 100
106 struct rte_mbuf **m_table;
112 struct rte_ring *rx_ring;
113 struct rte_ring *tx_ring;
114 struct rte_sched_port *sched_port;
117 struct thread_stat stat;
119 } __rte_cache_aligned;
131 struct rte_ring *rx_ring;
132 struct rte_ring *tx_ring;
133 struct rte_sched_port *sched_port;
134 struct rte_mempool *mbuf_pool;
136 struct thread_conf rx_thread;
137 struct thread_conf wt_thread;
138 struct thread_conf tx_thread;
153 uint16_t qos_dequeue;
159 uint8_t pthresh; /**< Ring prefetch threshold. */
160 uint8_t hthresh; /**< Ring host threshold. */
161 uint8_t wthresh; /**< Ring writeback threshold. */
164 extern uint8_t interactive;
165 extern uint32_t qavg_period;
166 extern uint32_t qavg_ntimes;
167 extern uint32_t nb_pfc;
168 extern const char *cfg_profile;
170 extern struct flow_conf qos_conf[];
171 extern int app_pipe_to_profile[MAX_SCHED_SUBPORTS][MAX_SCHED_PIPES];
173 extern struct ring_conf ring_conf;
174 extern struct burst_conf burst_conf;
175 extern struct ring_thresh rx_thresh;
176 extern struct ring_thresh tx_thresh;
178 extern struct rte_sched_port_params port_params;
180 int MAIN(int argc, char **argv);
181 int app_parse_args(int argc, char **argv);
185 void app_rx_thread(struct thread_conf **qconf);
186 void app_tx_thread(struct thread_conf **qconf);
187 void app_worker_thread(struct thread_conf **qconf);
188 void app_mixed_thread(struct thread_conf **qconf);
191 int subport_stat(uint8_t port_id, uint32_t subport_id);
192 int pipe_stat(uint8_t port_id, uint32_t subport_id, uint32_t pipe_id);
193 int qavg_q(uint8_t port_id, uint32_t subport_id, uint32_t pipe_id, uint8_t tc, uint8_t q);
194 int qavg_tcpipe(uint8_t port_id, uint32_t subport_id, uint32_t pipe_id, uint8_t tc);
195 int qavg_pipe(uint8_t port_id, uint32_t subport_id, uint32_t pipe_id);
196 int qavg_tcsubport(uint8_t port_id, uint32_t subport_id, uint8_t tc);
197 int qavg_subport(uint8_t port_id, uint32_t subport_id);
203 #endif /* _MAIN_H_ */