1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2010-2014 Intel Corporation 3 */ 4 5 #ifndef _MAIN_H_ 6 #define _MAIN_H_ 7 8 #ifdef __cplusplus 9 extern "C" { 10 #endif 11 12 #include <rte_sched.h> 13 14 #define RTE_LOGTYPE_APP RTE_LOGTYPE_USER1 15 16 /* 17 * Configurable number of RX/TX ring descriptors 18 */ 19 #define APP_INTERACTIVE_DEFAULT 0 20 21 #define APP_RX_DESC_DEFAULT 1024 22 #define APP_TX_DESC_DEFAULT 1024 23 24 #define APP_RING_SIZE (8*1024) 25 #define NB_MBUF (2*1024*1024) 26 27 #define MAX_PKT_RX_BURST 64 28 #define PKT_ENQUEUE 64 29 #define PKT_DEQUEUE 32 30 #define MAX_PKT_TX_BURST 64 31 32 #define RX_PTHRESH 8 /**< Default values of RX prefetch threshold reg. */ 33 #define RX_HTHRESH 8 /**< Default values of RX host threshold reg. */ 34 #define RX_WTHRESH 4 /**< Default values of RX write-back threshold reg. */ 35 36 #define TX_PTHRESH 36 /**< Default values of TX prefetch threshold reg. */ 37 #define TX_HTHRESH 0 /**< Default values of TX host threshold reg. */ 38 #define TX_WTHRESH 0 /**< Default values of TX write-back threshold reg. */ 39 40 #define BURST_TX_DRAIN_US 100 41 42 #ifndef APP_MAX_LCORE 43 #if (RTE_MAX_LCORE > 64) 44 #define APP_MAX_LCORE 64 45 #else 46 #define APP_MAX_LCORE RTE_MAX_LCORE 47 #endif 48 #endif 49 50 #define MAX_DATA_STREAMS (APP_MAX_LCORE/2) 51 #define MAX_SCHED_SUBPORTS 8 52 #define MAX_SCHED_PIPES 4096 53 #define MAX_SCHED_PIPE_PROFILES 256 54 55 #ifndef APP_COLLECT_STAT 56 #define APP_COLLECT_STAT 1 57 #endif 58 59 #if APP_COLLECT_STAT 60 #define APP_STATS_ADD(stat,val) (stat) += (val) 61 #else 62 #define APP_STATS_ADD(stat,val) do {(void) (val);} while (0) 63 #endif 64 65 #define APP_QAVG_NTIMES 10 66 #define APP_QAVG_PERIOD 100 67 68 struct thread_stat 69 { 70 uint64_t nb_rx; 71 uint64_t nb_drop; 72 }; 73 74 75 struct thread_conf 76 { 77 uint32_t counter; 78 uint32_t n_mbufs; 79 struct rte_mbuf **m_table; 80 81 uint16_t rx_port; 82 uint16_t tx_port; 83 uint16_t rx_queue; 84 uint16_t tx_queue; 85 struct rte_ring *rx_ring; 86 struct rte_ring *tx_ring; 87 struct rte_sched_port *sched_port; 88 89 #if APP_COLLECT_STAT 90 struct thread_stat stat; 91 #endif 92 } __rte_cache_aligned; 93 94 95 struct flow_conf 96 { 97 uint32_t rx_core; 98 uint32_t wt_core; 99 uint32_t tx_core; 100 uint16_t rx_port; 101 uint16_t tx_port; 102 uint16_t rx_queue; 103 uint16_t tx_queue; 104 struct rte_ring *rx_ring; 105 struct rte_ring *tx_ring; 106 struct rte_sched_port *sched_port; 107 struct rte_mempool *mbuf_pool; 108 109 struct thread_conf rx_thread; 110 struct thread_conf wt_thread; 111 struct thread_conf tx_thread; 112 }; 113 114 115 struct ring_conf 116 { 117 uint32_t rx_size; 118 uint32_t ring_size; 119 uint32_t tx_size; 120 }; 121 122 struct burst_conf 123 { 124 uint16_t rx_burst; 125 uint16_t ring_burst; 126 uint16_t qos_dequeue; 127 uint16_t tx_burst; 128 }; 129 130 struct ring_thresh 131 { 132 uint8_t pthresh; /**< Ring prefetch threshold. */ 133 uint8_t hthresh; /**< Ring host threshold. */ 134 uint8_t wthresh; /**< Ring writeback threshold. */ 135 }; 136 137 extern uint8_t interactive; 138 extern uint32_t qavg_period; 139 extern uint32_t qavg_ntimes; 140 extern uint32_t nb_pfc; 141 extern const char *cfg_profile; 142 extern int mp_size; 143 extern struct flow_conf qos_conf[]; 144 extern int app_pipe_to_profile[MAX_SCHED_SUBPORTS][MAX_SCHED_PIPES]; 145 146 extern struct ring_conf ring_conf; 147 extern struct burst_conf burst_conf; 148 extern struct ring_thresh rx_thresh; 149 extern struct ring_thresh tx_thresh; 150 151 extern uint32_t active_queues[RTE_SCHED_QUEUES_PER_PIPE]; 152 extern uint32_t n_active_queues; 153 154 extern struct rte_sched_port_params port_params; 155 extern struct rte_sched_subport_params subport_params[MAX_SCHED_SUBPORTS]; 156 157 int app_parse_args(int argc, char **argv); 158 int app_init(void); 159 160 void prompt(void); 161 void app_rx_thread(struct thread_conf **qconf); 162 void app_tx_thread(struct thread_conf **qconf); 163 void app_worker_thread(struct thread_conf **qconf); 164 void app_mixed_thread(struct thread_conf **qconf); 165 166 void app_stat(void); 167 int subport_stat(uint16_t port_id, uint32_t subport_id); 168 int pipe_stat(uint16_t port_id, uint32_t subport_id, uint32_t pipe_id); 169 int qavg_q(uint16_t port_id, uint32_t subport_id, uint32_t pipe_id, 170 uint8_t tc, uint8_t q); 171 int qavg_tcpipe(uint16_t port_id, uint32_t subport_id, uint32_t pipe_id, 172 uint8_t tc); 173 int qavg_pipe(uint16_t port_id, uint32_t subport_id, uint32_t pipe_id); 174 int qavg_tcsubport(uint16_t port_id, uint32_t subport_id, uint8_t tc); 175 int qavg_subport(uint16_t port_id, uint32_t subport_id); 176 177 #ifdef __cplusplus 178 } 179 #endif 180 181 #endif /* _MAIN_H_ */ 182