xref: /dpdk/examples/qos_sched/init.c (revision 624148d2b11f52228075d0a65f9840e7c47fac70)
1de3cfa2cSIntel /*-
2de3cfa2cSIntel  *   BSD LICENSE
3de3cfa2cSIntel  *
4de3cfa2cSIntel  *   Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
5de3cfa2cSIntel  *   All rights reserved.
6de3cfa2cSIntel  *
7de3cfa2cSIntel  *   Redistribution and use in source and binary forms, with or without
8de3cfa2cSIntel  *   modification, are permitted provided that the following conditions
9de3cfa2cSIntel  *   are met:
10de3cfa2cSIntel  *
11de3cfa2cSIntel  *     * Redistributions of source code must retain the above copyright
12de3cfa2cSIntel  *       notice, this list of conditions and the following disclaimer.
13de3cfa2cSIntel  *     * Redistributions in binary form must reproduce the above copyright
14de3cfa2cSIntel  *       notice, this list of conditions and the following disclaimer in
15de3cfa2cSIntel  *       the documentation and/or other materials provided with the
16de3cfa2cSIntel  *       distribution.
17de3cfa2cSIntel  *     * Neither the name of Intel Corporation nor the names of its
18de3cfa2cSIntel  *       contributors may be used to endorse or promote products derived
19de3cfa2cSIntel  *       from this software without specific prior written permission.
20de3cfa2cSIntel  *
21de3cfa2cSIntel  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22de3cfa2cSIntel  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23de3cfa2cSIntel  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24de3cfa2cSIntel  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25de3cfa2cSIntel  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26de3cfa2cSIntel  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27de3cfa2cSIntel  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28de3cfa2cSIntel  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29de3cfa2cSIntel  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30de3cfa2cSIntel  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31de3cfa2cSIntel  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32de3cfa2cSIntel  *
33de3cfa2cSIntel  */
34de3cfa2cSIntel 
35de3cfa2cSIntel #include <stdint.h>
36de3cfa2cSIntel #include <memory.h>
37de3cfa2cSIntel 
38de3cfa2cSIntel #include <rte_log.h>
39de3cfa2cSIntel #include <rte_mbuf.h>
40de3cfa2cSIntel #include <rte_debug.h>
41de3cfa2cSIntel #include <rte_ethdev.h>
42de3cfa2cSIntel #include <rte_mempool.h>
43de3cfa2cSIntel #include <rte_sched.h>
44de3cfa2cSIntel #include <rte_cycles.h>
45de3cfa2cSIntel #include <rte_string_fns.h>
46de3cfa2cSIntel 
47de3cfa2cSIntel #include "main.h"
48de3cfa2cSIntel #include "cfg_file.h"
49de3cfa2cSIntel 
50de3cfa2cSIntel uint32_t app_numa_mask = 0;
51de3cfa2cSIntel static uint32_t app_inited_port_mask = 0;
52de3cfa2cSIntel 
53de3cfa2cSIntel int app_pipe_to_profile[MAX_SCHED_SUBPORTS][MAX_SCHED_PIPES];
54de3cfa2cSIntel 
55de3cfa2cSIntel #define MAX_NAME_LEN 32
56de3cfa2cSIntel 
57de3cfa2cSIntel struct ring_conf ring_conf = {
58de3cfa2cSIntel 	.rx_size   = APP_RX_DESC_DEFAULT,
59de3cfa2cSIntel 	.ring_size = APP_RING_SIZE,
60de3cfa2cSIntel 	.tx_size   = APP_TX_DESC_DEFAULT,
61de3cfa2cSIntel };
62de3cfa2cSIntel 
63de3cfa2cSIntel struct burst_conf burst_conf = {
64de3cfa2cSIntel 	.rx_burst    = MAX_PKT_RX_BURST,
65de3cfa2cSIntel 	.ring_burst  = PKT_ENQUEUE,
66de3cfa2cSIntel 	.qos_dequeue = PKT_DEQUEUE,
67de3cfa2cSIntel 	.tx_burst    = MAX_PKT_TX_BURST,
68de3cfa2cSIntel };
69de3cfa2cSIntel 
70de3cfa2cSIntel struct ring_thresh rx_thresh = {
71de3cfa2cSIntel 	.pthresh = RX_PTHRESH,
72de3cfa2cSIntel 	.hthresh = RX_HTHRESH,
73de3cfa2cSIntel 	.wthresh = RX_WTHRESH,
74de3cfa2cSIntel };
75de3cfa2cSIntel 
76de3cfa2cSIntel struct ring_thresh tx_thresh = {
77de3cfa2cSIntel 	.pthresh = TX_PTHRESH,
78de3cfa2cSIntel 	.hthresh = TX_HTHRESH,
79de3cfa2cSIntel 	.wthresh = TX_WTHRESH,
80de3cfa2cSIntel };
81de3cfa2cSIntel 
82de3cfa2cSIntel uint32_t nb_pfc;
83de3cfa2cSIntel const char *cfg_profile = NULL;
84e93b24a3SIntel int mp_size = NB_MBUF;
85de3cfa2cSIntel struct flow_conf qos_conf[MAX_DATA_STREAMS];
86de3cfa2cSIntel 
87de3cfa2cSIntel static const struct rte_eth_conf port_conf = {
88de3cfa2cSIntel 	.rxmode = {
89de3cfa2cSIntel 		.max_rx_pkt_len = ETHER_MAX_LEN,
90de3cfa2cSIntel 		.split_hdr_size = 0,
91de3cfa2cSIntel 		.header_split   = 0, /**< Header Split disabled */
92de3cfa2cSIntel 		.hw_ip_checksum = 0, /**< IP checksum offload disabled */
93de3cfa2cSIntel 		.hw_vlan_filter = 0, /**< VLAN filtering disabled */
94de3cfa2cSIntel 		.jumbo_frame    = 0, /**< Jumbo Frame Support disabled */
95de3cfa2cSIntel 		.hw_strip_crc   = 0, /**< CRC stripped by hardware */
96de3cfa2cSIntel 	},
97de3cfa2cSIntel 	.txmode = {
98de3cfa2cSIntel 		.mq_mode = ETH_DCB_NONE,
99de3cfa2cSIntel 	},
100de3cfa2cSIntel };
101de3cfa2cSIntel 
102de3cfa2cSIntel static int
103de3cfa2cSIntel app_init_port(uint8_t portid, struct rte_mempool *mp)
104de3cfa2cSIntel {
105de3cfa2cSIntel 	int ret;
106de3cfa2cSIntel 	struct rte_eth_link link;
107de3cfa2cSIntel 	struct rte_eth_rxconf rx_conf;
108de3cfa2cSIntel 	struct rte_eth_txconf tx_conf;
109de3cfa2cSIntel 
110de3cfa2cSIntel 	/* check if port already initialized (multistream configuration) */
111de3cfa2cSIntel 	if (app_inited_port_mask & (1u << portid))
112de3cfa2cSIntel 		return 0;
113de3cfa2cSIntel 
114de3cfa2cSIntel 	rx_conf.rx_thresh.pthresh = rx_thresh.pthresh;
115de3cfa2cSIntel 	rx_conf.rx_thresh.hthresh = rx_thresh.hthresh;
116de3cfa2cSIntel 	rx_conf.rx_thresh.wthresh = rx_thresh.wthresh;
117de3cfa2cSIntel 	rx_conf.rx_free_thresh = 32;
118de3cfa2cSIntel 	rx_conf.rx_drop_en = 0;
119de3cfa2cSIntel 
120de3cfa2cSIntel 	tx_conf.tx_thresh.pthresh = tx_thresh.pthresh;
121de3cfa2cSIntel 	tx_conf.tx_thresh.hthresh = tx_thresh.hthresh;
122de3cfa2cSIntel 	tx_conf.tx_thresh.wthresh = tx_thresh.wthresh;
123de3cfa2cSIntel 	tx_conf.tx_free_thresh = 0;
124de3cfa2cSIntel 	tx_conf.tx_rs_thresh = 0;
125de3cfa2cSIntel 	tx_conf.txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS | ETH_TXQ_FLAGS_NOOFFLOADS;
126de3cfa2cSIntel 
127de3cfa2cSIntel 	/* init port */
128de3cfa2cSIntel 	RTE_LOG(INFO, APP, "Initializing port %hu... ", portid);
129de3cfa2cSIntel 	fflush(stdout);
130de3cfa2cSIntel 	ret = rte_eth_dev_configure(portid, 1, 1, &port_conf);
131de3cfa2cSIntel 	if (ret < 0)
132de3cfa2cSIntel 		rte_exit(EXIT_FAILURE, "Cannot configure device: err=%d, port=%hu\n",
133de3cfa2cSIntel 		ret, portid);
134de3cfa2cSIntel 
135de3cfa2cSIntel 	/* init one RX queue */
136de3cfa2cSIntel 	fflush(stdout);
137de3cfa2cSIntel 	ret = rte_eth_rx_queue_setup(portid, 0, (uint16_t)ring_conf.rx_size,
138de3cfa2cSIntel 		rte_eth_dev_socket_id(portid), &rx_conf, mp);
139de3cfa2cSIntel 	if (ret < 0)
140de3cfa2cSIntel 		rte_exit(EXIT_FAILURE, "rte_eth_tx_queue_setup: err=%d, port=%hu\n",
141de3cfa2cSIntel 		ret, portid);
142de3cfa2cSIntel 
143de3cfa2cSIntel 	/* init one TX queue */
144de3cfa2cSIntel 	fflush(stdout);
145de3cfa2cSIntel 	ret = rte_eth_tx_queue_setup(portid, 0,
146de3cfa2cSIntel 		(uint16_t)ring_conf.tx_size, rte_eth_dev_socket_id(portid), &tx_conf);
147de3cfa2cSIntel 	if (ret < 0)
148de3cfa2cSIntel 		rte_exit(EXIT_FAILURE, "rte_eth_tx_queue_setup: err=%d, "
149de3cfa2cSIntel 		"port=%hu queue=%d\n",
150de3cfa2cSIntel 		ret, portid, 0);
151de3cfa2cSIntel 
152de3cfa2cSIntel 	/* Start device */
153de3cfa2cSIntel 	ret = rte_eth_dev_start(portid);
154de3cfa2cSIntel 	if (ret < 0)
155de3cfa2cSIntel 		rte_exit(EXIT_FAILURE, "rte_pmd_port_start: err=%d, port=%hu\n",
156de3cfa2cSIntel 		ret, portid);
157de3cfa2cSIntel 
158de3cfa2cSIntel 	printf("done: ");
159de3cfa2cSIntel 
160de3cfa2cSIntel 	/* get link status */
161de3cfa2cSIntel 	rte_eth_link_get(portid, &link);
162de3cfa2cSIntel 	if (link.link_status) {
163de3cfa2cSIntel 		printf(" Link Up - speed %u Mbps - %s\n",
164de3cfa2cSIntel 			(uint32_t) link.link_speed,
165de3cfa2cSIntel 			(link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
166de3cfa2cSIntel 			("full-duplex") : ("half-duplex\n"));
167de3cfa2cSIntel 	} else {
168de3cfa2cSIntel 		printf(" Link Down\n");
169de3cfa2cSIntel 	}
170de3cfa2cSIntel 	rte_eth_promiscuous_enable(portid);
171de3cfa2cSIntel 
172de3cfa2cSIntel 	/* mark port as initialized */
173de3cfa2cSIntel 	app_inited_port_mask |= 1u << portid;
174de3cfa2cSIntel 
175de3cfa2cSIntel 	return 0;
176de3cfa2cSIntel }
177de3cfa2cSIntel 
178de3cfa2cSIntel static struct rte_sched_subport_params subport_params[MAX_SCHED_SUBPORTS] = {
179de3cfa2cSIntel 	{
180de3cfa2cSIntel 		.tb_rate = 1250000000,
181de3cfa2cSIntel 		.tb_size = 1000000,
182de3cfa2cSIntel 
183de3cfa2cSIntel 		.tc_rate = {1250000000, 1250000000, 1250000000, 1250000000},
184de3cfa2cSIntel 		.tc_period = 10,
185de3cfa2cSIntel 	},
186de3cfa2cSIntel };
187de3cfa2cSIntel 
188de3cfa2cSIntel static struct rte_sched_pipe_params pipe_profiles[RTE_SCHED_PIPE_PROFILES_PER_PORT] = {
189de3cfa2cSIntel 	{ /* Profile #0 */
190de3cfa2cSIntel 		.tb_rate = 305175,
191de3cfa2cSIntel 		.tb_size = 1000000,
192de3cfa2cSIntel 
193de3cfa2cSIntel 		.tc_rate = {305175, 305175, 305175, 305175},
194de3cfa2cSIntel 		.tc_period = 40,
195de3cfa2cSIntel #ifdef RTE_SCHED_SUBPORT_TC_OV
196835c5409SIntel 		.tc_ov_weight = 1,
197de3cfa2cSIntel #endif
198de3cfa2cSIntel 
199de3cfa2cSIntel 		.wrr_weights = {1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1,  1, 1, 1, 1},
200de3cfa2cSIntel 	},
201de3cfa2cSIntel };
202de3cfa2cSIntel 
203de3cfa2cSIntel struct rte_sched_port_params port_params = {
204*624148d2SIntel 	.name = "port_scheduler_0",
205de3cfa2cSIntel 	.socket = 0, /* computed */
206de3cfa2cSIntel 	.rate = 0, /* computed */
207a91c3cadSIntel 	.mtu = 6 + 6 + 4 + 4 + 2 + 1500,
208de3cfa2cSIntel 	.frame_overhead = RTE_SCHED_FRAME_OVERHEAD_DEFAULT,
209de3cfa2cSIntel 	.n_subports_per_port = 1,
210de3cfa2cSIntel 	.n_pipes_per_subport = 4096,
211de3cfa2cSIntel 	.qsize = {64, 64, 64, 64},
212de3cfa2cSIntel 	.pipe_profiles = pipe_profiles,
213*624148d2SIntel 	.n_pipe_profiles = sizeof(pipe_profiles) / sizeof(struct rte_sched_pipe_params),
214de3cfa2cSIntel 
215de3cfa2cSIntel #ifdef RTE_SCHED_RED
216de3cfa2cSIntel 	.red_params = {
217de3cfa2cSIntel 		/* Traffic Class 0 Colors Green / Yellow / Red */
218de3cfa2cSIntel 		[0][0] = {.min_th = 48, .max_th = 64, .maxp_inv = 10, .wq_log2 = 9},
219de3cfa2cSIntel 		[0][1] = {.min_th = 40, .max_th = 64, .maxp_inv = 10, .wq_log2 = 9},
220de3cfa2cSIntel 		[0][2] = {.min_th = 32, .max_th = 64, .maxp_inv = 10, .wq_log2 = 9},
221de3cfa2cSIntel 
222de3cfa2cSIntel 		/* Traffic Class 1 - Colors Green / Yellow / Red */
223de3cfa2cSIntel 		[1][0] = {.min_th = 48, .max_th = 64, .maxp_inv = 10, .wq_log2 = 9},
224de3cfa2cSIntel 		[1][1] = {.min_th = 40, .max_th = 64, .maxp_inv = 10, .wq_log2 = 9},
225de3cfa2cSIntel 		[1][2] = {.min_th = 32, .max_th = 64, .maxp_inv = 10, .wq_log2 = 9},
226de3cfa2cSIntel 
227de3cfa2cSIntel 		/* Traffic Class 2 - Colors Green / Yellow / Red */
228de3cfa2cSIntel 		[2][0] = {.min_th = 48, .max_th = 64, .maxp_inv = 10, .wq_log2 = 9},
229de3cfa2cSIntel 		[2][1] = {.min_th = 40, .max_th = 64, .maxp_inv = 10, .wq_log2 = 9},
230de3cfa2cSIntel 		[2][2] = {.min_th = 32, .max_th = 64, .maxp_inv = 10, .wq_log2 = 9},
231de3cfa2cSIntel 
232de3cfa2cSIntel 		/* Traffic Class 3 - Colors Green / Yellow / Red */
233de3cfa2cSIntel 		[3][0] = {.min_th = 48, .max_th = 64, .maxp_inv = 10, .wq_log2 = 9},
234de3cfa2cSIntel 		[3][1] = {.min_th = 40, .max_th = 64, .maxp_inv = 10, .wq_log2 = 9},
235de3cfa2cSIntel 		[3][2] = {.min_th = 32, .max_th = 64, .maxp_inv = 10, .wq_log2 = 9}
236de3cfa2cSIntel 	}
237de3cfa2cSIntel #endif /* RTE_SCHED_RED */
238de3cfa2cSIntel };
239de3cfa2cSIntel 
240de3cfa2cSIntel static struct rte_sched_port *
241de3cfa2cSIntel app_init_sched_port(uint32_t portid, uint32_t socketid)
242de3cfa2cSIntel {
243de3cfa2cSIntel 	static char port_name[32]; /* static as referenced from global port_params*/
244de3cfa2cSIntel 	struct rte_eth_link link;
245de3cfa2cSIntel 	struct rte_sched_port *port = NULL;
246de3cfa2cSIntel 	uint32_t pipe, subport;
247de3cfa2cSIntel 	int err;
248de3cfa2cSIntel 
249de3cfa2cSIntel 	rte_eth_link_get((uint8_t)portid, &link);
250de3cfa2cSIntel 
251de3cfa2cSIntel 	port_params.socket = socketid;
252de3cfa2cSIntel 	port_params.rate = (uint64_t) link.link_speed * 1000 * 1000 / 8;
253de3cfa2cSIntel 	rte_snprintf(port_name, sizeof(port_name), "port_%d", portid);
254de3cfa2cSIntel 	port_params.name = port_name;
255de3cfa2cSIntel 
256de3cfa2cSIntel 	port = rte_sched_port_config(&port_params);
257de3cfa2cSIntel 	if (port == NULL){
258de3cfa2cSIntel 		rte_exit(EXIT_FAILURE, "Unable to config sched port\n");
259de3cfa2cSIntel 	}
260de3cfa2cSIntel 
261de3cfa2cSIntel 	for (subport = 0; subport < port_params.n_subports_per_port; subport ++) {
262de3cfa2cSIntel 		err = rte_sched_subport_config(port, subport, &subport_params[subport]);
263de3cfa2cSIntel 		if (err) {
264de3cfa2cSIntel 			rte_exit(EXIT_FAILURE, "Unable to config sched subport %u, err=%d\n",
265de3cfa2cSIntel 					subport, err);
266de3cfa2cSIntel 		}
267de3cfa2cSIntel 
268de3cfa2cSIntel 		for (pipe = 0; pipe < port_params.n_pipes_per_subport; pipe ++) {
269de3cfa2cSIntel 			if (app_pipe_to_profile[subport][pipe] != -1) {
270de3cfa2cSIntel 				err = rte_sched_pipe_config(port, subport, pipe,
271de3cfa2cSIntel 						app_pipe_to_profile[subport][pipe]);
272de3cfa2cSIntel 				if (err) {
273de3cfa2cSIntel 					rte_exit(EXIT_FAILURE, "Unable to config sched pipe %u "
274de3cfa2cSIntel 							"for profile %d, err=%d\n", pipe,
275de3cfa2cSIntel 							app_pipe_to_profile[subport][pipe], err);
276de3cfa2cSIntel 				}
277de3cfa2cSIntel 			}
278de3cfa2cSIntel 		}
279de3cfa2cSIntel 	}
280de3cfa2cSIntel 
281de3cfa2cSIntel 	return port;
282de3cfa2cSIntel }
283de3cfa2cSIntel 
284de3cfa2cSIntel static int
285de3cfa2cSIntel app_load_cfg_profile(const char *profile)
286de3cfa2cSIntel {
287de3cfa2cSIntel 	if (profile == NULL)
288de3cfa2cSIntel 		return 0;
289de3cfa2cSIntel 
290de3cfa2cSIntel 	struct cfg_file *cfg_file = cfg_load(profile, 0);
291de3cfa2cSIntel 	if (cfg_file == NULL)
292de3cfa2cSIntel 		rte_exit(EXIT_FAILURE, "Cannot load configuration profile %s\n", profile);
293de3cfa2cSIntel 
294de3cfa2cSIntel 	cfg_load_port(cfg_file, &port_params);
295de3cfa2cSIntel 	cfg_load_subport(cfg_file, subport_params);
296de3cfa2cSIntel 	cfg_load_pipe(cfg_file, pipe_profiles);
297de3cfa2cSIntel 
298de3cfa2cSIntel 	cfg_close(cfg_file);
299de3cfa2cSIntel 
300de3cfa2cSIntel 	return 0;
301de3cfa2cSIntel }
302de3cfa2cSIntel 
303de3cfa2cSIntel int app_init(void)
304de3cfa2cSIntel {
305de3cfa2cSIntel 	uint32_t i;
306de3cfa2cSIntel 	char ring_name[MAX_NAME_LEN];
307de3cfa2cSIntel 	char pool_name[MAX_NAME_LEN];
308de3cfa2cSIntel 
309de3cfa2cSIntel 	/* init driver(s) */
310de3cfa2cSIntel 	if (rte_pmd_init_all() < 0)
311de3cfa2cSIntel 		rte_exit(EXIT_FAILURE, "Cannot init PMD\n");
312de3cfa2cSIntel 
313de3cfa2cSIntel 	if (rte_eal_pci_probe() < 0)
314de3cfa2cSIntel 		rte_exit(EXIT_FAILURE, "Cannot probe PCI\n");
315de3cfa2cSIntel 
316de3cfa2cSIntel 	if (rte_eth_dev_count() == 0)
317de3cfa2cSIntel 		rte_exit(EXIT_FAILURE, "No Ethernet port - bye\n");
318de3cfa2cSIntel 
319de3cfa2cSIntel 	/* load configuration profile */
320de3cfa2cSIntel 	if (app_load_cfg_profile(cfg_profile) != 0)
321de3cfa2cSIntel 		rte_exit(EXIT_FAILURE, "Invalid configuration profile\n");
322de3cfa2cSIntel 
323de3cfa2cSIntel 	/* Initialize each active flow */
324de3cfa2cSIntel 	for(i = 0; i < nb_pfc; i++) {
325de3cfa2cSIntel 		uint32_t socket = rte_lcore_to_socket_id(qos_conf[i].rx_core);
326de3cfa2cSIntel 		struct rte_ring *ring;
327de3cfa2cSIntel 
328de3cfa2cSIntel 		rte_snprintf(ring_name, MAX_NAME_LEN, "ring-%u-%u", i, qos_conf[i].rx_core);
329de3cfa2cSIntel 		ring = rte_ring_lookup(ring_name);
330de3cfa2cSIntel 		if (ring == NULL)
331de3cfa2cSIntel 			qos_conf[i].rx_ring = rte_ring_create(ring_name, ring_conf.ring_size,
332de3cfa2cSIntel 			 	socket, RING_F_SP_ENQ | RING_F_SC_DEQ);
333de3cfa2cSIntel 		else
334de3cfa2cSIntel 			qos_conf[i].rx_ring = ring;
335de3cfa2cSIntel 
336de3cfa2cSIntel 		rte_snprintf(ring_name, MAX_NAME_LEN, "ring-%u-%u", i, qos_conf[i].tx_core);
337de3cfa2cSIntel 		ring = rte_ring_lookup(ring_name);
338de3cfa2cSIntel 		if (ring == NULL)
339de3cfa2cSIntel 			qos_conf[i].tx_ring = rte_ring_create(ring_name, ring_conf.ring_size,
340de3cfa2cSIntel 				socket, RING_F_SP_ENQ | RING_F_SC_DEQ);
341de3cfa2cSIntel 		else
342de3cfa2cSIntel 			qos_conf[i].tx_ring = ring;
343de3cfa2cSIntel 
344de3cfa2cSIntel 
345de3cfa2cSIntel 		/* create the mbuf pools for each RX Port */
346de3cfa2cSIntel 		rte_snprintf(pool_name, MAX_NAME_LEN, "mbuf_pool%u", i);
347e93b24a3SIntel 		qos_conf[i].mbuf_pool = rte_mempool_create(pool_name, mp_size, MBUF_SIZE,
348de3cfa2cSIntel 						burst_conf.rx_burst * 4,
349de3cfa2cSIntel 						sizeof(struct rte_pktmbuf_pool_private),
350de3cfa2cSIntel 						rte_pktmbuf_pool_init, NULL,
351de3cfa2cSIntel 						rte_pktmbuf_init, NULL,
352de3cfa2cSIntel 						rte_eth_dev_socket_id(qos_conf[i].rx_port),
353de3cfa2cSIntel 						0);
354de3cfa2cSIntel 		if (qos_conf[i].mbuf_pool == NULL)
355de3cfa2cSIntel 			rte_exit(EXIT_FAILURE, "Cannot init mbuf pool for socket %u\n", i);
356de3cfa2cSIntel 
357de3cfa2cSIntel 		app_init_port(qos_conf[i].rx_port, qos_conf[i].mbuf_pool);
358de3cfa2cSIntel 		app_init_port(qos_conf[i].tx_port, qos_conf[i].mbuf_pool);
359de3cfa2cSIntel 
360de3cfa2cSIntel 		qos_conf[i].sched_port = app_init_sched_port(qos_conf[i].rx_port, socket);
361de3cfa2cSIntel 	}
362de3cfa2cSIntel 
363de3cfa2cSIntel 	RTE_LOG(INFO, APP, "time stamp clock running at %" PRIu64 " Hz\n",
364de3cfa2cSIntel 			 rte_get_timer_hz());
365de3cfa2cSIntel 
366de3cfa2cSIntel 	RTE_LOG(INFO, APP, "Ring sizes: NIC RX = %u, Mempool = %d SW queue = %u,"
367e93b24a3SIntel 			 "NIC TX = %u\n", ring_conf.rx_size, mp_size, ring_conf.ring_size,
368de3cfa2cSIntel 			 ring_conf.tx_size);
369de3cfa2cSIntel 
370de3cfa2cSIntel 	RTE_LOG(INFO, APP, "Burst sizes: RX read = %hu, RX write = %hu,\n"
371de3cfa2cSIntel 						  "             Worker read/QoS enqueue = %hu,\n"
372de3cfa2cSIntel 						  "             QoS dequeue = %hu, Worker write = %hu\n",
373de3cfa2cSIntel 		burst_conf.rx_burst, burst_conf.ring_burst, burst_conf.ring_burst,
374de3cfa2cSIntel 		burst_conf.qos_dequeue, burst_conf.tx_burst);
375de3cfa2cSIntel 
376de3cfa2cSIntel 	RTE_LOG(INFO, APP, "NIC thresholds RX (p = %hhu, h = %hhu, w = %hhu),"
377de3cfa2cSIntel 				 "TX (p = %hhu, h = %hhu, w = %hhu)\n",
378de3cfa2cSIntel 		rx_thresh.pthresh, rx_thresh.hthresh, rx_thresh.wthresh,
379de3cfa2cSIntel 		tx_thresh.pthresh, tx_thresh.hthresh, tx_thresh.wthresh);
380de3cfa2cSIntel 
381de3cfa2cSIntel 	return 0;
382de3cfa2cSIntel }
383