Re: [dpdk-dev] [PATCH] test/tun: add new test for tun

2018-05-22 Thread Ferruh Yigit
On 4/19/2018 4:39 AM, Varghese, Vipin wrote:
> Hi Ferruh,
> 
> 
> 
>> Hi Vipin,
>>
>> Thanks for providing unit test for the feature you have added. *I believe we
>> need more unit test in DPDK.*
>>
>> Only a few questions:
>> 1- Should this be part of auto test?
> 
> It would be really nice to do so, but only constrain is ping command requires 
> least 5 seconds to get back command prompt. 
> 
>> 2- Second running of the tun_autotest is failing, exit test and re-run works,
>> any idea?
>>
> 
> I am not sure, I will check and update.

Patch pushed to next release, patchwork status updated as deferred.

> 
>>
>> Overall I am for merging this unit test if there is no objection.
>>
>>
>> Thanks,
>> ferruh
>>
> 



Re: [dpdk-dev] [PATCH] test/tun: add new test for tun

2018-04-18 Thread Varghese, Vipin
Hi Ferruh,



> Hi Vipin,
> 
> Thanks for providing unit test for the feature you have added. *I believe we
> need more unit test in DPDK.*
> 
> Only a few questions:
> 1- Should this be part of auto test?

It would be really nice to do so, but only constrain is ping command requires 
least 5 seconds to get back command prompt. 

> 2- Second running of the tun_autotest is failing, exit test and re-run works,
> any idea?
> 

I am not sure, I will check and update.

> 
> Overall I am for merging this unit test if there is no objection.
> 
> 
> Thanks,
> ferruh
> 



Re: [dpdk-dev] [PATCH] test/tun: add new test for tun

2018-04-17 Thread Ferruh Yigit
On 4/5/2018 9:31 AM, Vipin Varghese wrote:
> Add TUN PMD validation for create, port setup, tx, rx and stats functions.
> 
> Signed-off-by: Vipin Varghese 
> ---
>  test/test/Makefile |   4 +
>  test/test/autotest_data.py |  13 ++
>  test/test/meson.build  |   4 +
>  test/test/test_tun.c   | 333 
> +
>  4 files changed, 354 insertions(+)
>  create mode 100644 test/test/test_tun.c
> 
> diff --git a/test/test/Makefile b/test/test/Makefile
> index a88cc38..e5d8200 100644
> --- a/test/test/Makefile
> +++ b/test/test/Makefile
> @@ -193,6 +193,10 @@ endif
>  
>  SRCS-$(CONFIG_RTE_LIBRTE_KVARGS) += test_kvargs.c
>  
> +ifeq ($(CONFIG_RTE_LIBRTE_PMD_TAP),y)
> +SRCS-y += test_tun.c
> +endif
> +
>  CFLAGS += -DALLOW_EXPERIMENTAL_API
>  
>  CFLAGS += -O3
> diff --git a/test/test/autotest_data.py b/test/test/autotest_data.py
> index aacfe0a..35f3aab 100644
> --- a/test/test/autotest_data.py
> +++ b/test/test/autotest_data.py
> @@ -357,6 +357,19 @@ def per_sockets(num):
>  ]
>  },
>  {
> +"Prefix":"tun",
> +"Memory":"512",
> +"Tests":
> +[
> +{
> +"Name":"TUN autotest",
> +"Command": "tun_autotest",
> +"Func":default_autotest,
> +"Report":  None,
> +},
> +]
> +},
> +{

Hi Vipin,

Thanks for providing unit test for the feature you have added. *I believe we
need more unit test in DPDK.*

Only a few questions:
1- Should this be part of auto test?
2- Second running of the tun_autotest is failing, exit test and re-run works,
any idea?


Overall I am for merging this unit test if there is no objection.


Thanks,
ferruh




[dpdk-dev] [PATCH] test/tun: add new test for tun

2018-04-05 Thread Vipin Varghese
Add TUN PMD validation for create, port setup, tx, rx and stats functions.

Signed-off-by: Vipin Varghese 
---
 test/test/Makefile |   4 +
 test/test/autotest_data.py |  13 ++
 test/test/meson.build  |   4 +
 test/test/test_tun.c   | 333 +
 4 files changed, 354 insertions(+)
 create mode 100644 test/test/test_tun.c

diff --git a/test/test/Makefile b/test/test/Makefile
index a88cc38..e5d8200 100644
--- a/test/test/Makefile
+++ b/test/test/Makefile
@@ -193,6 +193,10 @@ endif
 
 SRCS-$(CONFIG_RTE_LIBRTE_KVARGS) += test_kvargs.c
 
+ifeq ($(CONFIG_RTE_LIBRTE_PMD_TAP),y)
+SRCS-y += test_tun.c
+endif
+
 CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 CFLAGS += -O3
diff --git a/test/test/autotest_data.py b/test/test/autotest_data.py
index aacfe0a..35f3aab 100644
--- a/test/test/autotest_data.py
+++ b/test/test/autotest_data.py
@@ -357,6 +357,19 @@ def per_sockets(num):
 ]
 },
 {
+"Prefix":"tun",
+"Memory":"512",
+"Tests":
+[
+{
+"Name":"TUN autotest",
+"Command": "tun_autotest",
+"Func":default_autotest,
+"Report":  None,
+},
+]
+},
+{
 "Prefix":"mempool_perf",
 "Memory":per_sockets(256),
 "Tests":
diff --git a/test/test/meson.build b/test/test/meson.build
index eb3d87a..fbb4cf7 100644
--- a/test/test/meson.build
+++ b/test/test/meson.build
@@ -93,6 +93,7 @@ test_sources = files('commands.c',
'test_timer.c',
'test_timer_perf.c',
'test_timer_racecond.c',
+   'test_tun.c',
'test_version.c',
'virtual_pmd.c'
 )
@@ -227,6 +228,9 @@ endif
 if dpdk_conf.has('RTE_LIBRTE_RING_PMD')
test_deps += 'pmd_ring'
 endif
+if dpdk_conf.has('RTE_LIBRTE_TAP_PMD')
+   test_deps += 'pmd_tap'
+endif
 if dpdk_conf.has('RTE_LIBRTE_POWER')
test_deps += 'power'
 endif
diff --git a/test/test/test_tun.c b/test/test/test_tun.c
new file mode 100644
index 000..c165a94
--- /dev/null
+++ b/test/test/test_tun.c
@@ -0,0 +1,333 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2014 Intel Corporation
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define NB_MBUF  8192
+#define MAX_PACKET_SZ2048
+#define MBUF_DATA_SZ (MAX_PACKET_SZ + RTE_PKTMBUF_HEADROOM)
+#define PKT_BURST_SZ 32
+#define MEMPOOL_CACHE_SZ PKT_BURST_SZ
+#define SOCKET   0
+#define NB_RXD   1024
+#define NB_TXD   1024
+#define MAX_PKT_BURST32
+#define IFCONFIG "/sbin/ifconfig "
+#define PING "/bin/ping -qr -c 10 -i 0.2 15.0.0.1 -I "
+
+static int tun_id;
+static int socket_id;
+static uint16_t nb_ports, port_id;
+
+static struct rte_eth_dev_info info;
+static struct rte_eth_stats stats;
+static struct rte_mempool *mp;
+static struct rte_mbuf *mbuf;
+
+static char tun_drv_name[20] = "net_tun";
+static char tun_intf_name[20] = "atest";
+static char tun_intf_cmd[20] = "\0";
+static char portname[25] = "\0";
+static char cmd_exec[70] = "\0";
+
+static const struct rte_eth_rxconf rx_conf = {
+   .rx_thresh = {
+   .pthresh = 8,
+   .hthresh = 8,
+   .wthresh = 4,
+   },
+   .rx_free_thresh = 0,
+};
+
+static const struct rte_eth_txconf tx_conf = {
+   .tx_thresh = {
+   .pthresh = 36,
+   .hthresh = 0,
+   .wthresh = 0,
+   },
+   .tx_free_thresh = 0,
+   .tx_rs_thresh = 0,
+};
+
+static const struct rte_eth_conf port_conf = {
+   .rxmode = {
+   .header_split = 0,
+   .hw_ip_checksum = 0,
+   .hw_vlan_filter = 0,
+   .jumbo_frame = 0,
+   .hw_strip_crc = 0,
+   },
+   .txmode = {
+   .mq_mode = ETH_MQ_TX_NONE | ETH_DCB_NONE,
+   },
+};
+
+static void
+send_ping(void *param)
+{
+   char *tun_intf_name = (char *) param;
+
+   sprintf(cmd_exec, "%s %s &", PING, tun_intf_name);
+   if (system(cmd_exec) != 0)
+   printf("fail to execute (%s)!\n", cmd_exec);
+
+   fflush(stdout);
+}
+
+static int
+tun_port_setup(uint16_t port_id)
+{
+   int ret = rte_eth_dev_configure(port_id, 1, 1, &port_conf);
+   if (ret < 0) {
+   printf("fail to configure port %d\n", port_id);
+   return -1;
+   }
+
+   ret = rte_eth_rx_queue_setup(port_id, 0, NB_RXD, socket_id,
+   &rx_conf, mp);
+   if (ret < 0) {
+   printf("fail to setup rx queue for port %d\n", port_id);
+   return -1;
+   }
+
+   ret = rte_eth_tx_queue_setup(port_id, 0, NB_TXD, socket_id,
+   &tx_conf);
+   if (ret < 0) {
+   printf("fail to setup tx queue for port %d\n