From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 1E1A4CFBC for ; Tue, 28 Mar 2017 17:20:22 +0200 (CEST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP; 28 Mar 2017 08:20:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,236,1486454400"; d="scan'208";a="241265382" Received: from irsmsx102.ger.corp.intel.com ([163.33.3.155]) by fmsmga004.fm.intel.com with ESMTP; 28 Mar 2017 08:20:20 -0700 Received: from irsmsx109.ger.corp.intel.com ([169.254.13.12]) by IRSMSX102.ger.corp.intel.com ([169.254.2.153]) with mapi id 14.03.0319.002; Tue, 28 Mar 2017 16:20:20 +0100 From: "Burakov, Anatoly" To: "Van Haaren, Harry" , "dev@dpdk.org" CC: "jerin.jacob@caviumnetworks.com" , "Van Haaren, Harry" , "Richardson, Bruce" , "Hunt, David" Thread-Topic: [dpdk-dev] [PATCH v5 14/20] test/eventdev: add SW test infrastructure Thread-Index: AQHSpL+euEZRd5D2fEqCjUdxfsF7IqGqZAcA Date: Tue, 28 Mar 2017 15:20:19 +0000 Message-ID: References: <489175012-101439-1-git-send-email-harry.van.haaren@intel.com> <1490374395-149320-1-git-send-email-harry.van.haaren@intel.com> <1490374395-149320-15-git-send-email-harry.van.haaren@intel.com> In-Reply-To: <1490374395-149320-15-git-send-email-harry.van.haaren@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZWExMzQ3OGYtYmZjNi00OTBlLThlMzItZmQyZTQyOTg5NjQ5IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6IkprSU1aMHJPZHpcL2NaZ2hWdSs3YzBrdGlQN3g5Wks3dlgzcDVsN2tXSmpRPSJ9 x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v5 14/20] test/eventdev: add SW test infrastructure 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, 28 Mar 2017 15:20:24 -0000 > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Harry van Haaren > Sent: Friday, March 24, 2017 4:53 PM > To: dev@dpdk.org > Cc: jerin.jacob@caviumnetworks.com; Van Haaren, Harry > ; Richardson, Bruce > ; Hunt, David > Subject: [dpdk-dev] [PATCH v5 14/20] test/eventdev: add SW test > infrastructure >=20 > Add the test infrastructure, create and destroy the test instance. >=20 > Signed-off-by: Bruce Richardson > Signed-off-by: David Hunt > Signed-off-by: Harry van Haaren > --- > test/test/Makefile | 5 +- > test/test/autotest_data.py | 26 ++++ > test/test/test_eventdev_sw.c | 358 > +++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 388 insertions(+), 1 deletion(-) create mode 100644 > test/test/test_eventdev_sw.c >=20 > diff --git a/test/test/Makefile b/test/test/Makefile index a426548..dc92d= 9c > 100644 > --- a/test/test/Makefile > +++ b/test/test/Makefile > @@ -197,7 +197,10 @@ SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) +=3D > test_cryptodev_blockcipher.c > SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) +=3D test_cryptodev_perf.c > SRCS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) +=3D test_cryptodev.c >=20 > -SRCS-$(CONFIG_RTE_LIBRTE_EVENTDEV) +=3D test_eventdev.c > +ifeq ($(CONFIG_RTE_LIBRTE_EVENTDEV),y) > +SRCS-y +=3D test_eventdev.c > +SRCS-$(CONFIG_RTE_LIBRTE_PMD_SW_EVENTDEV) +=3D > test_eventdev_sw.c endif >=20 > SRCS-$(CONFIG_RTE_LIBRTE_KVARGS) +=3D test_kvargs.c >=20 > diff --git a/test/test/autotest_data.py b/test/test/autotest_data.py inde= x > 0cd598b..165ed6c 100644 > --- a/test/test/autotest_data.py > +++ b/test/test/autotest_data.py > @@ -346,6 +346,32 @@ def per_sockets(num): > non_parallel_test_group_list =3D [ >=20 > { > + "Prefix": "eventdev", > + "Memory": "512", > + "Tests": > + [ > + { > + "Name": "Eventdev common autotest", > + "Command": "eventdev_common_autotest", > + "Func": default_autotest, > + "Report": None, > + }, > + ] > + }, > + { > + "Prefix": "eventdev_sw", > + "Memory": "512", > + "Tests": > + [ > + { > + "Name": "Eventdev sw autotest", > + "Command": "eventdev_sw_autotest", > + "Func": default_autotest, > + "Report": None, > + }, > + ] > + }, > + { > "Prefix": "kni", > "Memory": "512", > "Tests": > diff --git a/test/test/test_eventdev_sw.c b/test/test/test_eventdev_sw.c > new file mode 100644 index 0000000..808b7b3 > --- /dev/null > +++ b/test/test/test_eventdev_sw.c > @@ -0,0 +1,358 @@ > +/*- > + * BSD LICENSE > + * > + * Copyright(c) 2016-2017 Intel Corporation. All rights reserved. > + * All rights reserved. > + * > + * Redistribution and use in source and binary forms, with or without > + * modification, are permitted provided that the following conditions > + * are met: > + * > + * * Redistributions of source code must retain the above copyright > + * notice, this list of conditions and the following disclaimer. > + * * Redistributions in binary form must reproduce the above copyrig= ht > + * notice, this list of conditions and the following disclaimer in > + * the documentation and/or other materials provided with the > + * distribution. > + * * Neither the name of Intel Corporation nor the names of its > + * contributors may be used to endorse or promote products derived > + * from this software without specific prior written permission. > + * > + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND > CONTRIBUTORS > + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT > NOT > + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND > FITNESS FOR > + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE > COPYRIGHT > + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, > INCIDENTAL, > + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT > NOT > + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS > OF USE, > + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED > AND ON ANY > + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR > TORT > + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF > THE USE > + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH > DAMAGE. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include "test.h" > + > +#define MAX_PORTS 16 > +#define MAX_QIDS 16 > +#define NUM_PACKETS (1<<18) > + > +static int evdev; > + > +struct test { > + struct rte_mempool *mbuf_pool; > + uint8_t port[MAX_PORTS]; > + uint8_t qid[MAX_QIDS]; > + int nb_qids; > +}; > + > +static inline struct rte_mbuf * > +rte_gen_arp(int portid, struct rte_mempool *mp) { > + /* > + * len =3D 14 + 46 > + * ARP, Request who-has 10.0.0.1 tell 10.0.0.2, length 46 > + */ > + static const uint8_t arp_request[] =3D { > + /*0x0000:*/ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xec, 0xa8, > + 0x6b, 0xfd, 0x02, 0x29, 0x08, 0x06, 0x00, 0x01, > + /*0x0010:*/ 0x08, 0x00, 0x06, 0x04, 0x00, 0x01, 0xec, 0xa8, > + 0x6b, 0xfd, 0x02, 0x29, 0x0a, 0x00, 0x00, 0x01, > + /*0x0020:*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, > + 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, > + /*0x0030:*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, > + 0x00, 0x00, 0x00, 0x00 > + }; > + struct rte_mbuf *m; > + int pkt_len =3D sizeof(arp_request) - 1; > + > + m =3D rte_pktmbuf_alloc(mp); > + if (!m) > + return 0; > + > + memcpy((void *)((uintptr_t)m->buf_addr + m->data_off), > + arp_request, pkt_len); > + rte_pktmbuf_pkt_len(m) =3D pkt_len; > + rte_pktmbuf_data_len(m) =3D pkt_len; > + > + RTE_SET_USED(portid); > + > + return m; > +} > + > +/* initialization and config */ > +static inline int > +init(struct test *t, int nb_queues, int nb_ports) { > + struct rte_event_dev_config config =3D { > + .nb_event_queues =3D nb_queues, > + .nb_event_ports =3D nb_ports, > + .nb_event_queue_flows =3D 1024, > + .nb_events_limit =3D 4096, > + .nb_event_port_dequeue_depth =3D 128, > + .nb_event_port_enqueue_depth =3D 128, > + }; > + int ret; > + > + void *temp =3D t->mbuf_pool; /* save and restore mbuf pool */ > + > + memset(t, 0, sizeof(*t)); > + t->mbuf_pool =3D temp; > + > + ret =3D rte_event_dev_configure(evdev, &config); > + if (ret < 0) > + printf("%d: Error configuring device\n", __LINE__); > + return ret; > +}; > + > +static inline int > +create_ports(struct test *t, int num_ports) { > + int i; > + static const struct rte_event_port_conf conf =3D { > + .new_event_threshold =3D 1024, > + .dequeue_depth =3D 32, > + .enqueue_depth =3D 64, > + }; > + if (num_ports > MAX_PORTS) > + return -1; > + > + for (i =3D 0; i < num_ports; i++) { > + if (rte_event_port_setup(evdev, i, &conf) < 0) { > + printf("Error setting up port %d\n", i); > + return -1; > + } > + t->port[i] =3D i; > + } > + > + return 0; > +} > + > +static inline int > +create_lb_qids(struct test *t, int num_qids, uint32_t flags) { > + int i; > + > + /* Q creation */ > + const struct rte_event_queue_conf conf =3D { > + .event_queue_cfg =3D flags, > + .priority =3D RTE_EVENT_DEV_PRIORITY_NORMAL, > + .nb_atomic_flows =3D 1024, > + .nb_atomic_order_sequences =3D 1024, > + }; > + > + for (i =3D t->nb_qids; i < t->nb_qids + num_qids; i++) { > + if (rte_event_queue_setup(evdev, i, &conf) < 0) { > + printf("%d: error creating qid %d\n", __LINE__, i); > + return -1; > + } > + t->qid[i] =3D i; > + } > + t->nb_qids +=3D num_qids; > + if (t->nb_qids > MAX_QIDS) > + return -1; > + > + return 0; > +} > + > +static inline int > +create_atomic_qids(struct test *t, int num_qids) { > + return create_lb_qids(t, num_qids, > RTE_EVENT_QUEUE_CFG_ATOMIC_ONLY); } > + > +static inline int > +create_ordered_qids(struct test *t, int num_qids) { > + return create_lb_qids(t, num_qids, > RTE_EVENT_QUEUE_CFG_ORDERED_ONLY); > +} > + > + > +static inline int > +create_unordered_qids(struct test *t, int num_qids) { > + return create_lb_qids(t, num_qids, > RTE_EVENT_QUEUE_CFG_PARALLEL_ONLY); > +} > + > +static inline int > +create_directed_qids(struct test *t, int num_qids, const uint8_t > +ports[]) { > + int i; > + > + /* Q creation */ > + static const struct rte_event_queue_conf conf =3D { > + .priority =3D RTE_EVENT_DEV_PRIORITY_NORMAL, > + .event_queue_cfg =3D > RTE_EVENT_QUEUE_CFG_SINGLE_LINK, > + .nb_atomic_flows =3D 1024, > + .nb_atomic_order_sequences =3D 1024, > + }; > + > + for (i =3D t->nb_qids; i < t->nb_qids + num_qids; i++) { > + if (rte_event_queue_setup(evdev, i, &conf) < 0) { > + printf("%d: error creating qid %d\n", __LINE__, i); > + return -1; > + } > + t->qid[i] =3D i; > + > + if (rte_event_port_link(evdev, ports[i - t->nb_qids], > + &t->qid[i], NULL, 1) !=3D 1) { > + printf("%d: error creating link for qid %d\n", > + __LINE__, i); > + return -1; > + } > + } > + t->nb_qids +=3D num_qids; > + if (t->nb_qids > MAX_QIDS) > + return -1; > + > + return 0; > +} > + > +/* destruction */ > +static inline int > +cleanup(struct test *t __rte_unused) > +{ > + rte_event_dev_stop(evdev); > + rte_event_dev_close(evdev); > + return 0; > +}; > + > +struct test_event_dev_stats { > + uint64_t rx_pkts; /**< Total packets received */ > + uint64_t rx_dropped; /**< Total packets dropped (Eg Invalid QID) > */ > + uint64_t tx_pkts; /**< Total packets transmitted */ > + > + /** Packets received on this port */ > + uint64_t port_rx_pkts[MAX_PORTS]; > + /** Packets dropped on this port */ > + uint64_t port_rx_dropped[MAX_PORTS]; > + /** Packets inflight on this port */ > + uint64_t port_inflight[MAX_PORTS]; > + /** Packets transmitted on this port */ > + uint64_t port_tx_pkts[MAX_PORTS]; > + /** Packets received on this qid */ > + uint64_t qid_rx_pkts[MAX_QIDS]; > + /** Packets dropped on this qid */ > + uint64_t qid_rx_dropped[MAX_QIDS]; > + /** Packets transmitted on this qid */ > + uint64_t qid_tx_pkts[MAX_QIDS]; > +}; > + > +static inline int > +test_event_dev_stats_get(int dev_id, struct test_event_dev_stats > +*stats) { > + static uint32_t i; > + static uint32_t total_ids[3]; /* rx, tx and drop */ > + static uint32_t port_rx_pkts_ids[MAX_PORTS]; > + static uint32_t port_rx_dropped_ids[MAX_PORTS]; > + static uint32_t port_inflight_ids[MAX_PORTS]; > + static uint32_t port_tx_pkts_ids[MAX_PORTS]; > + static uint32_t qid_rx_pkts_ids[MAX_QIDS]; > + static uint32_t qid_rx_dropped_ids[MAX_QIDS]; > + static uint32_t qid_tx_pkts_ids[MAX_QIDS]; > + > + > + stats->rx_pkts =3D rte_event_dev_xstats_by_name_get(dev_id, > + "dev_rx", &total_ids[0]); > + stats->rx_dropped =3D rte_event_dev_xstats_by_name_get(dev_id, > + "dev_drop", &total_ids[1]); > + stats->tx_pkts =3D rte_event_dev_xstats_by_name_get(dev_id, > + "dev_tx", &total_ids[2]); > + for (i =3D 0; i < MAX_PORTS; i++) { > + char name[32]; > + snprintf(name, sizeof(name), "port_%u_rx", i); > + stats->port_rx_pkts[i] =3D > rte_event_dev_xstats_by_name_get( > + dev_id, name, &port_rx_pkts_ids[i]); > + snprintf(name, sizeof(name), "port_%u_drop", i); > + stats->port_rx_dropped[i] =3D > rte_event_dev_xstats_by_name_get( > + dev_id, name, &port_rx_dropped_ids[i]); > + snprintf(name, sizeof(name), "port_%u_inflight", i); > + stats->port_inflight[i] =3D > rte_event_dev_xstats_by_name_get( > + dev_id, name, &port_inflight_ids[i]); > + snprintf(name, sizeof(name), "port_%u_tx", i); > + stats->port_tx_pkts[i] =3D > rte_event_dev_xstats_by_name_get( > + dev_id, name, &port_tx_pkts_ids[i]); > + } > + for (i =3D 0; i < MAX_QIDS; i++) { > + char name[32]; > + snprintf(name, sizeof(name), "qid_%u_rx", i); > + stats->qid_rx_pkts[i] =3D > rte_event_dev_xstats_by_name_get( > + dev_id, name, &qid_rx_pkts_ids[i]); > + snprintf(name, sizeof(name), "qid_%u_drop", i); > + stats->qid_rx_dropped[i] =3D > rte_event_dev_xstats_by_name_get( > + dev_id, name, &qid_rx_dropped_ids[i]); > + snprintf(name, sizeof(name), "qid_%u_tx", i); > + stats->qid_tx_pkts[i] =3D > rte_event_dev_xstats_by_name_get( > + dev_id, name, &qid_tx_pkts_ids[i]); > + } > + > + return 0; > +} > + > +static struct rte_mempool *eventdev_func_mempool; > + > +static int > +test_sw_eventdev(void) > +{ > + struct test *t =3D malloc(sizeof(struct test)); > + > + const char *eventdev_name =3D "event_sw0"; > + evdev =3D rte_event_dev_get_dev_id(eventdev_name); > + if (evdev < 0) { > + printf("%d: Eventdev %s not found - creating.\n", > + __LINE__, eventdev_name); > + if (rte_eal_vdev_init(eventdev_name, NULL) < 0) { > + printf("Error creating eventdev\n"); > + return -1; > + } > + evdev =3D rte_event_dev_get_dev_id(eventdev_name); > + if (evdev < 0) { > + printf("Error finding newly created eventdev\n"); > + return -1; > + } > + } > + > + /* Only create mbuf pool once, reuse for each test run */ > + if (!eventdev_func_mempool) { > + eventdev_func_mempool =3D rte_pktmbuf_pool_create( > + "EVENTDEV_SW_SA_MBUF_POOL", > + (1<<12), /* 4k buffers */ > + 32 /*MBUF_CACHE_SIZE*/, > + 0, > + 512, /* use very small mbufs */ > + rte_socket_id()); > + if (!eventdev_func_mempool) { > + printf("ERROR creating mempool\n"); > + return -1; > + } > + } > + t->mbuf_pool =3D eventdev_func_mempool; > + > + /* > + * Free test instance, leaving mempool initialized, and a pointer to it > + * in static eventdev_func_mempool, as it is re-used on re-runs > + */ > + free(t); > + > + return 0; > +} > + > +REGISTER_TEST_COMMAND(eventdev_sw_autotest, test_sw_eventdev); > -- > 2.7.4 Acked-by: Anatoly Burakov