From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 1DA2D235 for ; Tue, 17 Jul 2018 12:22:33 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Jul 2018 03:22:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,365,1526367600"; d="scan'208";a="73014628" Received: from aburakov-mobl.ger.corp.intel.com (HELO [10.237.220.102]) ([10.237.220.102]) by fmsmga001.fm.intel.com with ESMTP; 17 Jul 2018 03:22:24 -0700 To: Jananee Parthasarathy , dev@dpdk.org Cc: remy.horton@intel.com, reshma.pattan@intel.com, Chaitanya Babu Talluri References: <1531756833-947-1-git-send-email-jananeex.m.parthasarathy@intel.com> <1531821650-5506-1-git-send-email-jananeex.m.parthasarathy@intel.com> From: "Burakov, Anatoly" Message-ID: <10b20449-0f25-a9ae-7cff-9e3be1c51838@intel.com> Date: Tue, 17 Jul 2018 11:22:23 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <1531821650-5506-1-git-send-email-jananeex.m.parthasarathy@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v4] test: add sample functions for packet forwarding X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Jul 2018 10:22:34 -0000 On 17-Jul-18 11:00 AM, Jananee Parthasarathy wrote: > Add sample test functions for packet forwarding. > These can be used for unit test cases for > LatencyStats and BitrateStats libraries. > > Signed-off-by: Chaitanya Babu Talluri > Reviewed-by: Reshma Pattan > Acked-by: Reshma Pattan > --- > v4: Updated return value as TEST_FAILED instead of -1 > v3: Used same port for tx,rx and removed extra line > v2: SOCKET0 is removed and NUM_QUEUES is used accordingly > --- > test/test/Makefile | 1 + > test/test/sample_packet_forward.c | 71 +++++++++++++++++++++++++++++++++++++++ > test/test/sample_packet_forward.h | 21 ++++++++++++ > 3 files changed, 93 insertions(+) > create mode 100644 test/test/sample_packet_forward.c > create mode 100644 test/test/sample_packet_forward.h > > diff --git a/test/test/Makefile b/test/test/Makefile > index e6967bab6..8032ce53b 100644 > --- a/test/test/Makefile > +++ b/test/test/Makefile > @@ -135,6 +135,7 @@ SRCS-y += test_version.c > SRCS-y += test_func_reentrancy.c > > SRCS-y += test_service_cores.c > +SRCS-y += sample_packet_forward.c > > SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline.c > SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += test_cmdline_num.c > diff --git a/test/test/sample_packet_forward.c b/test/test/sample_packet_forward.c > new file mode 100644 > index 000000000..4a13d5001 > --- /dev/null > +++ b/test/test/sample_packet_forward.c > @@ -0,0 +1,71 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2018 Intel Corporation > + */ > + > +#include > +#include > +#include > + > +#include > +#include > +#include > +#include > + > +#include "sample_packet_forward.h" > +#include "test.h" > +#include > + > +#define NB_MBUF 512 > + > +static struct rte_mempool *mp; > +uint16_t portid; > + > +/* Sample test to create virtual rings and tx,rx portid from rings */ > +int > +test_ring_setup(void) > +{ > + uint16_t socket_id = rte_socket_id(); > + struct rte_ring *rxtx[NUM_RINGS]; > + rxtx[0] = rte_ring_create("R0", RING_SIZE, socket_id, > + RING_F_SP_ENQ|RING_F_SC_DEQ); > + if (rxtx[0] == NULL) { > + printf("%s() line %u: rte_ring_create R0 failed", > + __func__, __LINE__); > + return TEST_FAILED; > + } > + portid = rte_eth_from_rings("net_ringa", rxtx, NUM_QUEUES, rxtx, > + NUM_QUEUES, socket_id); > + > + return TEST_SUCCESS; I am probably missing something, but 1) Why are there 256 rings maximum, but only one is used? 2) You're creating these rings - where are you destroying them? 3) Some more comments on why this would be needed would be great as well. Right now, it looks like it's ripped out of the middle of a patchset - i don't see it being used anywhere. > +} > + > +/* Sample test to forward packets using virtual portids */ > +int > +test_packet_forward(void) > +{ > + struct rte_mbuf *pbuf[NUM_PACKETS]; > + > + mp = rte_pktmbuf_pool_create("mbuf_pool", NB_MBUF, 32, 0, > + RTE_MBUF_DEFAULT_BUF_SIZE, rte_socket_id()); > + if (mp == NULL) > + return TEST_FAILED; > + if (rte_pktmbuf_alloc_bulk(mp, pbuf, NUM_PACKETS) != 0) > + printf("%s() line %u: rte_pktmbuf_alloc_bulk failed" > + , __func__, __LINE__); > + /* send and receive packet and check for stats update */ > + if (rte_eth_tx_burst(portid, 0, pbuf, NUM_PACKETS) != > + NUM_PACKETS) { > + printf("%s() line %u: Error sending packet to" > + " port %d\n", __func__, __LINE__, > + portid); > + return TEST_FAILED; > + } > + if (rte_eth_rx_burst(portid, 0, pbuf, NUM_PACKETS) != > + NUM_PACKETS) { > + printf("%s() line %u: Error receiving packet from" > + " port %d\n", __func__, __LINE__, > + portid); > + return TEST_FAILED; > + } > + return TEST_SUCCESS; Same as above. > +} > diff --git a/test/test/sample_packet_forward.h b/test/test/sample_packet_forward.h > new file mode 100644 > index 000000000..a4880316f > --- /dev/null > +++ b/test/test/sample_packet_forward.h > @@ -0,0 +1,21 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2018 Intel Corporation > + */ > + > +#ifndef _SAMPLE_PACKET_FORWARD_H_ > +#define _SAMPLE_PACKET_FORWARD_H_ > + > +/* MACROS to support virtual ring creation */ > +#define RING_SIZE 256 > +#define NUM_RINGS 1 > +#define NUM_QUEUES 1 > + > +#define NUM_PACKETS 10 > + > +/* Sample test to create virtual rings and tx,rx portid from rings */ > +int test_ring_setup(void); > + > +/* Sample test to forward packet using virtual port id */ > +int test_packet_forward(void); > + > +#endif /* _SAMPLE_PACKET_FORWARD_H_ */ > -- Thanks, Anatoly