[dpdk-dev] [PATCH 2/5] examples/kni: add optional parameter to enable LRO

Rasesh Mody rasesh.mody at cavium.com
Fri Nov 24 21:35:42 CET 2017


From: Harish Patil <harish.patil at cavium.com>

Add an optional cmdline parameter to enable LRO. This is useful to test
LRO feature by being able to run linux utils like iperf over KNI interface
which generates consistent packet aggregations.

Signed-off-by: Harish Patil <harish.patil at cavium.com>
---
 examples/kni/main.c |   15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/examples/kni/main.c b/examples/kni/main.c
index 3f17385..1cedaff 100644
--- a/examples/kni/main.c
+++ b/examples/kni/main.c
@@ -143,6 +143,9 @@ struct kni_port_params {
 /* Ports set in promiscuous mode off by default. */
 static int promiscuous_on = 0;
 
+/* Enable LRO offload, off by default. */
+static int enable_lro = 0;
+
 /* Structure type for recording kni interface specific stats */
 struct kni_interface_stats {
 	/* number of pkts received from NIC, and sent to KNI */
@@ -360,11 +363,12 @@ struct kni_interface_stats {
 static void
 print_usage(const char *prgname)
 {
-	RTE_LOG(INFO, APP, "\nUsage: %s [EAL options] -- -p PORTMASK -P "
+	RTE_LOG(INFO, APP, "\nUsage: %s [EAL options] -- -p PORTMASK -P -l "
 		   "[--config (port,lcore_rx,lcore_tx,lcore_kthread...)"
 		   "[,(port,lcore_rx,lcore_tx,lcore_kthread...)]]\n"
 		   "    -p PORTMASK: hex bitmask of ports to use\n"
 		   "    -P : enable promiscuous mode\n"
+		   "    -l : enable LRO\n"
 		   "    --config (port,lcore_rx,lcore_tx,lcore_kthread...): "
 		   "port and lcore configurations\n",
 	           prgname);
@@ -545,7 +549,7 @@ struct kni_interface_stats {
 	opterr = 0;
 
 	/* Parse command line */
-	while ((opt = getopt_long(argc, argv, "p:P", longopts,
+	while ((opt = getopt_long(argc, argv, "p:Pl", longopts,
 						&longindex)) != EOF) {
 		switch (opt) {
 		case 'p':
@@ -554,6 +558,9 @@ struct kni_interface_stats {
 		case 'P':
 			promiscuous_on = 1;
 			break;
+		case 'l':
+			enable_lro = 1;
+			break;
 		case 0:
 			if (!strncmp(longopts[longindex].name,
 				     CMDLINE_OPT_CONFIG,
@@ -611,6 +618,10 @@ struct kni_interface_stats {
 	/* Initialise device and RX/TX queues */
 	RTE_LOG(INFO, APP, "Initialising port %u ...\n", (unsigned)port);
 	fflush(stdout);
+
+	if (enable_lro)
+		port_conf.rxmode.enable_lro = 1;
+
 	ret = rte_eth_dev_configure(port, 1, 1, &port_conf);
 	if (ret < 0)
 		rte_exit(EXIT_FAILURE, "Could not configure port%u (%d)\n",
-- 
1.7.10.3



More information about the dev mailing list