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 54 #ifndef APP_COLLECT_STAT 55 #define APP_COLLECT_STAT 1 56 #endif 57 58 #if APP_COLLECT_STAT 59 #define APP_STATS_ADD(stat,val) (stat) += (val) 60 #else 61 #define APP_STATS_ADD(stat,val) do {(void) (val);} while (0) 62 #endif 63 64 #define APP_QAVG_NTIMES 10 65 #define APP_QAVG_PERIOD 100 66 67 struct thread_stat 68 { 69 uint64_t nb_rx; 70 uint64_t nb_drop; 71 }; 72 73 74 struct thread_conf 75 { 76 uint32_t counter; 77 uint32_t n_mbufs; 78 struct rte_mbuf **m_table; 79 80 uint16_t rx_port; 81 uint16_t tx_port; 82 uint16_t rx_queue; 83 uint16_t tx_queue; 84 struct rte_ring *rx_ring; 85 struct rte_ring *tx_ring; 86 struct rte_sched_port *sched_port; 87 88 #if APP_COLLECT_STAT 89 struct thread_stat stat; 90 #endif 91 } __rte_cache_aligned; 92 93 94 struct flow_conf 95 { 96 uint32_t rx_core; 97 uint32_t wt_core; 98 uint32_t tx_core; 99 uint16_t rx_port; 100 uint16_t tx_port; 101 uint16_t rx_queue; 102 uint16_t tx_queue; 103 struct rte_ring *rx_ring; 104 struct rte_ring *tx_ring; 105 struct rte_sched_port *sched_port; 106 struct rte_mempool *mbuf_pool; 107 108 struct thread_conf rx_thread; 109 struct thread_conf wt_thread; 110 struct thread_conf tx_thread; 111 }; 112 113 114 struct ring_conf 115 { 116 uint32_t rx_size; 117 uint32_t ring_size; 118 uint32_t tx_size; 119 }; 120 121 struct burst_conf 122 { 123 uint16_t rx_burst; 124 uint16_t ring_burst; 125 uint16_t qos_dequeue; 126 uint16_t tx_burst; 127 }; 128 129 struct ring_thresh 130 { 131 uint8_t pthresh; /**< Ring prefetch threshold. */ 132 uint8_t hthresh; /**< Ring host threshold. */ 133 uint8_t wthresh; /**< Ring writeback threshold. */ 134 }; 135 136 extern uint8_t interactive; 137 extern uint32_t qavg_period; 138 extern uint32_t qavg_ntimes; 139 extern uint32_t nb_pfc; 140 extern const char *cfg_profile; 141 extern int mp_size; 142 extern struct flow_conf qos_conf[]; 143 extern int app_pipe_to_profile[MAX_SCHED_SUBPORTS][MAX_SCHED_PIPES]; 144 145 extern struct ring_conf ring_conf; 146 extern struct burst_conf burst_conf; 147 extern struct ring_thresh rx_thresh; 148 extern struct ring_thresh tx_thresh; 149 150 extern struct rte_sched_port_params port_params; 151 152 int app_parse_args(int argc, char **argv); 153 int app_init(void); 154 155 void prompt(void); 156 void app_rx_thread(struct thread_conf **qconf); 157 void app_tx_thread(struct thread_conf **qconf); 158 void app_worker_thread(struct thread_conf **qconf); 159 void app_mixed_thread(struct thread_conf **qconf); 160 161 void app_stat(void); 162 int subport_stat(uint16_t port_id, uint32_t subport_id); 163 int pipe_stat(uint16_t port_id, uint32_t subport_id, uint32_t pipe_id); 164 int qavg_q(uint16_t port_id, uint32_t subport_id, uint32_t pipe_id, 165 uint8_t tc, uint8_t q); 166 int qavg_tcpipe(uint16_t port_id, uint32_t subport_id, uint32_t pipe_id, 167 uint8_t tc); 168 int qavg_pipe(uint16_t port_id, uint32_t subport_id, uint32_t pipe_id); 169 int qavg_tcsubport(uint16_t port_id, uint32_t subport_id, uint8_t tc); 170 int qavg_subport(uint16_t port_id, uint32_t subport_id); 171 172 #ifdef __cplusplus 173 } 174 #endif 175 176 #endif /* _MAIN_H_ */ 177