]>
git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/dpdk/test/test-pipeline/init.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
11 #include <sys/queue.h>
16 #include <rte_common.h>
17 #include <rte_byteorder.h>
19 #include <rte_memory.h>
20 #include <rte_memcpy.h>
22 #include <rte_per_lcore.h>
23 #include <rte_launch.h>
24 #include <rte_atomic.h>
25 #include <rte_cycles.h>
26 #include <rte_prefetch.h>
27 #include <rte_lcore.h>
28 #include <rte_branch_prediction.h>
29 #include <rte_interrupts.h>
31 #include <rte_random.h>
32 #include <rte_debug.h>
33 #include <rte_ether.h>
34 #include <rte_ethdev.h>
36 #include <rte_mempool.h>
38 #include <rte_string_fns.h>
46 struct app_params app
= {
48 .n_ports
= APP_MAX_PORTS
,
49 .port_rx_ring_size
= 128,
50 .port_tx_ring_size
= 512,
57 .pool_buffer_size
= 2048 + RTE_PKTMBUF_HEADROOM
,
58 .pool_size
= 32 * 1024,
59 .pool_cache_size
= 256,
62 .burst_size_rx_read
= 64,
63 .burst_size_rx_write
= 64,
64 .burst_size_worker_read
= 64,
65 .burst_size_worker_write
= 64,
66 .burst_size_tx_read
= 64,
67 .burst_size_tx_write
= 64,
70 static struct rte_eth_conf port_conf
= {
73 .offloads
= DEV_RX_OFFLOAD_CHECKSUM
| DEV_RX_OFFLOAD_CRC_STRIP
,
82 .mq_mode
= ETH_MQ_TX_NONE
,
86 static struct rte_eth_rxconf rx_conf
= {
96 static struct rte_eth_txconf tx_conf
= {
107 app_init_mbuf_pools(void)
109 /* Init the buffer pool */
110 RTE_LOG(INFO
, USER1
, "Creating the mbuf pool ...\n");
111 app
.pool
= rte_pktmbuf_pool_create("mempool", app
.pool_size
,
112 app
.pool_cache_size
, 0, app
.pool_buffer_size
, rte_socket_id());
113 if (app
.pool
== NULL
)
114 rte_panic("Cannot create mbuf pool\n");
122 for (i
= 0; i
< app
.n_ports
; i
++) {
125 snprintf(name
, sizeof(name
), "app_ring_rx_%u", i
);
127 app
.rings_rx
[i
] = rte_ring_create(
131 RING_F_SP_ENQ
| RING_F_SC_DEQ
);
133 if (app
.rings_rx
[i
] == NULL
)
134 rte_panic("Cannot create RX ring %u\n", i
);
137 for (i
= 0; i
< app
.n_ports
; i
++) {
140 snprintf(name
, sizeof(name
), "app_ring_tx_%u", i
);
142 app
.rings_tx
[i
] = rte_ring_create(
146 RING_F_SP_ENQ
| RING_F_SC_DEQ
);
148 if (app
.rings_tx
[i
] == NULL
)
149 rte_panic("Cannot create TX ring %u\n", i
);
155 app_ports_check_link(void)
157 uint32_t all_ports_up
, i
;
161 for (i
= 0; i
< app
.n_ports
; i
++) {
162 struct rte_eth_link link
;
166 memset(&link
, 0, sizeof(link
));
167 rte_eth_link_get_nowait(port
, &link
);
168 RTE_LOG(INFO
, USER1
, "Port %u (%u Gbps) %s\n",
170 link
.link_speed
/ 1000,
171 link
.link_status
? "UP" : "DOWN");
173 if (link
.link_status
== ETH_LINK_DOWN
)
177 if (all_ports_up
== 0)
178 rte_panic("Some NIC ports are DOWN\n");
186 /* Init NIC ports, then start the ports */
187 for (i
= 0; i
< app
.n_ports
; i
++) {
192 RTE_LOG(INFO
, USER1
, "Initializing NIC port %u ...\n", port
);
195 ret
= rte_eth_dev_configure(
201 rte_panic("Cannot init NIC port %u (%d)\n", port
, ret
);
203 rte_eth_promiscuous_enable(port
);
206 ret
= rte_eth_rx_queue_setup(
209 app
.port_rx_ring_size
,
210 rte_eth_dev_socket_id(port
),
214 rte_panic("Cannot init RX for port %u (%d)\n",
215 (uint32_t) port
, ret
);
218 ret
= rte_eth_tx_queue_setup(
221 app
.port_tx_ring_size
,
222 rte_eth_dev_socket_id(port
),
225 rte_panic("Cannot init TX for port %u (%d)\n",
226 (uint32_t) port
, ret
);
229 ret
= rte_eth_dev_start(port
);
231 rte_panic("Cannot start port %u (%d)\n", port
, ret
);
234 app_ports_check_link();
240 app_init_mbuf_pools();
244 RTE_LOG(INFO
, USER1
, "Initialization completed\n");