dpdk_netperf: enable use of multiple RX/TX queues
@@ -67,6 +67,7 @@ static int seconds;
static size_t payload_len;
static unsigned int client_port;
static unsigned int server_port;
+static unsigned int num_queues = 1;
struct ether_addr zero_mac = {
.addr_bytes = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
};
@@ -115,6 +116,8 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool, unsigned int n_queues)
struct rte_eth_dev_info dev_info;
struct rte_eth_txconf *txconf;
+ printf("initializing with %u queues\n", n_queues);
+
if (port >= rte_eth_dev_count())
return -1;
@@ -440,7 +443,7 @@ do_server(void *arg)
struct rte_mbuf *rx_bufs[BURST_SIZE];
struct rte_mbuf *tx_bufs[BURST_SIZE];
struct rte_mbuf *buf;
- uint16_t nb_rx, n_to_tx, nb_tx, i, j;
+ uint16_t nb_rx, n_to_tx, nb_tx, i, j, q;
struct ether_hdr *ptr_mac_hdr;
struct ether_addr src_addr;
struct ipv4_hdr *ptr_ipv4_hdr;
@@ -466,8 +469,10 @@ do_server(void *arg)
/* Run until the application is quit or killed. */
for (;;) {
+ for (q = 0; q < num_queues; q++) {
+
/* receive packets */
- nb_rx = rte_eth_rx_burst(port, queue, rx_bufs, BURST_SIZE);
+ nb_rx = rte_eth_rx_burst(port, q, rx_bufs, BURST_SIZE);
if (nb_rx == 0)
continue;
@@ -546,12 +551,13 @@ do_server(void *arg)
}
/* transmit packets */
- nb_tx = rte_eth_tx_burst(port, queue, tx_bufs, n_to_tx);
+ nb_tx = rte_eth_tx_burst(port, q, tx_bufs, n_to_tx);
if (nb_tx != n_to_tx)
printf("error: could not transmit all packets: %d %d\n",
n_to_tx, nb_tx);
}
+ }
return 0;
}
@@ -619,9 +625,14 @@ static int parse_netperf_args(int argc, char *argv[])
seconds = tmp;
str_to_long(argv[7], &tmp);
payload_len = tmp;
- } else if (!strcmp(argv[1], "UDP_SERVER"))
+ } else if (!strcmp(argv[1], "UDP_SERVER")) {
mode = MODE_UDP_SERVER;
- else {
+ argc -= 3;
+ if (argc >= 1) {
+ if (sscanf(argv[3], "%u", &num_queues) != 1)
+ return -EINVAL;
+ }
+ } else {
printf("invalid mode '%s'\n", argv[1]);
return -EINVAL;
}
@@ -652,7 +663,7 @@ main(int argc, char *argv[])
/* initialize port */
if (mode == MODE_UDP_CLIENT && rte_lcore_count() > 1)
printf("\nWARNING: Too many lcores enabled. Only 1 used.\n");
- if (port_init(dpdk_port, rx_mbuf_pool, rte_lcore_count()) != 0)
+ if (port_init(dpdk_port, rx_mbuf_pool, num_queues) != 0)
rte_exit(EXIT_FAILURE, "Cannot init port %"PRIu8 "\n", dpdk_port);
if (mode == MODE_UDP_CLIENT)
