From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 5C0E05922 for ; Fri, 27 Jun 2014 16:46:27 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 27 Jun 2014 07:41:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,560,1400050800"; d="scan'208";a="535089852" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga001.jf.intel.com with ESMTP; 27 Jun 2014 07:46:41 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id s5REkeJh007095; Fri, 27 Jun 2014 15:46:40 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id s5REke1Q016821; Fri, 27 Jun 2014 15:46:40 +0100 Received: (from pdelarax@localhost) by sivswdev02.ir.intel.com with id s5REken4016816; Fri, 27 Jun 2014 15:46:40 +0100 From: Pablo de Lara To: dev@dpdk.org Date: Fri, 27 Jun 2014 15:46:39 +0100 Message-Id: <1403880399-16777-1-git-send-email-pablox.de.lara.guarch@intel.com> X-Mailer: git-send-email 1.7.0.7 Subject: [dpdk-dev] [PATCH] test: Ring PMD unit test rollback X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Jun 2014 14:46:29 -0000 From: Pablo de Lara New ring PMD unit test requires extra EAL option (vdev), in order to pass, which I believe is incorrect, as this test should be focused on testing the API, without needing to pass any argument. Added again all functions that create all the ring devices necessary for the test, and remove the last two tests (test_pmd_ring_pair_create and test_pmd_ring_pair_attach), as they call functions that are deprecated. Signed-off-by: Pablo de Lara --- app/test/test_pmd_ring.c | 217 +++++++++++++++------------------------------- 1 files changed, 72 insertions(+), 145 deletions(-) diff --git a/app/test/test_pmd_ring.c b/app/test/test_pmd_ring.c index 0d3d95c..6988277 100644 --- a/app/test/test_pmd_ring.c +++ b/app/test/test_pmd_ring.c @@ -42,6 +42,7 @@ /* two test rings, r1 is used by two ports, r2 just by one */ static struct rte_ring *r1[2], *r2; +static struct rte_ring *nullring = NULL; static struct rte_mempool *mp; static uint8_t start_idx; /* will store the port id of the first of our new ports */ @@ -49,8 +50,6 @@ static uint8_t start_idx; /* will store the port id of the first of our new port #define RX_PORT (uint8_t)(start_idx + 2) #define RXTX_PORT (uint8_t)(start_idx + 3) #define RXTX_PORT2 (uint8_t)(start_idx + 4) -#define RXTX_PORT4 (uint8_t)(start_idx + 6) -#define RXTX_PORT5 (uint8_t)(start_idx + 7) #define SOCKET0 0 #define RING_SIZE 256 @@ -58,6 +57,58 @@ static uint8_t start_idx; /* will store the port id of the first of our new port #define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM) #define NB_MBUF 512 + +static int +test_ring_ethdev_create(void) +{ + int retval; + printf("Testing ring pmd create\n"); + + retval = rte_eth_from_rings(NULL, 0, NULL, 0, SOCKET0); + if (retval < 0) { + printf("Failure, failed to create zero-sized RXTX ring pmd\n"); + return -1; + } + + retval = rte_eth_from_rings(NULL, 0, NULL, 0, RTE_MAX_NUMA_NODES); + if (retval >= 0) { + printf("Failure, can create ring pmd on socket %d\n", RTE_MAX_NUMA_NODES); + return -1; + } + + retval = rte_eth_from_rings(NULL, 1, &r2, 1, SOCKET0); + if (retval >= 0) { + printf("Failure, can create pmd with null rx rings\n"); + return -1; + } + + retval = rte_eth_from_rings(r1, 1, NULL, 1, SOCKET0); + if (retval >= 0) { + printf("Failure, can create pmd with null tx rings\n"); + return -1; + } + + retval = rte_eth_from_rings(&nullring, 1, r1, 2, SOCKET0); + if (retval < 0) { + printf("Failure, failed to create TX-only ring pmd\n"); + return -1; + } + + retval = rte_eth_from_rings(r1, 1, &nullring, 1, SOCKET0); + if (retval < 0) { + printf("Failure, failed to create RX-only ring pmd\n"); + return -1; + } + + retval = rte_eth_from_rings(&r2, 1, &r2, 1, SOCKET0); + if (retval < 0) { + printf("Failure, failed to create RXTX ring pmd\n"); + return -1; + } + + return 0; +} + static int test_ethdev_configure(void) { @@ -252,12 +303,26 @@ test_stats_reset(void) static int test_pmd_ring_init(void) { + const char * name1 = "R3"; + const char * name2 = "R4"; + const char * params_null = NULL; + const char * params = "PARAMS"; struct rte_eth_stats stats; struct rte_mbuf buf, *pbuf = &buf; struct rte_eth_conf null_conf; printf("Testing ring pmd init\n"); + if (rte_pmd_ring_devinit(name1, params_null) < 0) { + printf("Testing ring pmd init fail\n"); + return -1; + } + + if (rte_pmd_ring_devinit(name2, params) < 0) { + printf("Testing ring pmd init fail\n"); + return -1; + } + if (RXTX_PORT2 >= RTE_MAX_ETHPORTS) { printf(" TX/RX port exceed max eth ports\n"); return -1; @@ -304,144 +369,8 @@ test_pmd_ring_init(void) rte_eth_dev_stop(RXTX_PORT2); - return 0; -} - -static int -test_pmd_ring_pair_create(void) -{ - struct rte_eth_stats stats, stats2; - struct rte_mbuf buf, *pbuf = &buf; - struct rte_eth_conf null_conf; - - if ((RXTX_PORT4 >= RTE_MAX_ETHPORTS) || (RXTX_PORT5 >= RTE_MAX_ETHPORTS)) { - printf(" TX/RX port exceed max eth ports\n"); - return -1; - } - if ((rte_eth_dev_configure(RXTX_PORT4, 1, 1, &null_conf) < 0) - || (rte_eth_dev_configure(RXTX_PORT5, 1, 1, &null_conf) < 0)) { - printf("Configure failed for RXTX port\n"); - return -1; - } - - if ((rte_eth_tx_queue_setup(RXTX_PORT4, 0, RING_SIZE, SOCKET0, NULL) < 0) - || (rte_eth_tx_queue_setup(RXTX_PORT5, 0, RING_SIZE, SOCKET0, NULL) < 0)) { - printf("TX queue setup failed\n"); - return -1; - } - - if ((rte_eth_rx_queue_setup(RXTX_PORT4, 0, RING_SIZE, SOCKET0, NULL, mp) < 0) - || (rte_eth_rx_queue_setup(RXTX_PORT5, 0, RING_SIZE, SOCKET0, NULL, mp) < 0)) { - printf("RX queue setup failed\n"); - return -1; - } - - if ((rte_eth_dev_start(RXTX_PORT4) < 0) - || (rte_eth_dev_start(RXTX_PORT5) < 0)) { - printf("Error starting RXTX port\n"); - return -1; - } - - /* send and receive 1 packet and check for stats update */ - if (rte_eth_tx_burst(RXTX_PORT4, 0, &pbuf, 1) != 1) { - printf("Error sending packet to RXTX port\n"); - return -1; - } - - if (rte_eth_rx_burst(RXTX_PORT5, 0, &pbuf, 1) != 1) { - printf("Error receiving packet from RXTX port\n"); - return -1; - } - - rte_eth_stats_get(RXTX_PORT4, &stats); - rte_eth_stats_get(RXTX_PORT5, &stats2); - if (stats.ipackets != 0 || stats.opackets != 1 || - stats.ibytes != 0 || stats.obytes != 0 || - stats.ierrors != 0 || stats.oerrors != 0) { - printf("Error: RXTX port stats are not as expected\n"); - return -1; - } - - if (stats2.ipackets != 1 || stats2.opackets != 0 || - stats2.ibytes != 0 || stats2.obytes != 0 || - stats2.ierrors != 0 || stats2.oerrors != 0) { - printf("Error: RXTX port stats are not as expected\n"); - return -1; - } - - rte_eth_dev_stop(RXTX_PORT4); - rte_eth_dev_stop(RXTX_PORT5); - - return 0; -} - -static int -test_pmd_ring_pair_attach(void) -{ - struct rte_eth_stats stats, stats2; - struct rte_mbuf buf, *pbuf = &buf; - struct rte_eth_conf null_conf; - - if ((RXTX_PORT4 >= RTE_MAX_ETHPORTS) || (RXTX_PORT5 >= RTE_MAX_ETHPORTS)) { - printf(" TX/RX port exceed max eth ports\n"); - return -1; - } - if ((rte_eth_dev_configure(RXTX_PORT4, 1, 1, &null_conf) < 0) - || (rte_eth_dev_configure(RXTX_PORT5, 1, 1, &null_conf) < 0)) { - printf("Configure failed for RXTX port\n"); - return -1; - } - - if ((rte_eth_tx_queue_setup(RXTX_PORT4, 0, RING_SIZE, SOCKET0, NULL) < 0) - || (rte_eth_tx_queue_setup(RXTX_PORT5, 0, RING_SIZE, SOCKET0, NULL) < 0)) { - printf("TX queue setup failed\n"); - return -1; - } - - if ((rte_eth_rx_queue_setup(RXTX_PORT4, 0, RING_SIZE, SOCKET0, NULL, mp) < 0) - || (rte_eth_rx_queue_setup(RXTX_PORT5, 0, RING_SIZE, SOCKET0, NULL, mp) < 0)) { - printf("RX queue setup failed\n"); - return -1; - } - - if ((rte_eth_dev_start(RXTX_PORT4) < 0) - || (rte_eth_dev_start(RXTX_PORT5) < 0)) { - printf("Error starting RXTX port\n"); - return -1; - } - - rte_eth_stats_reset(RXTX_PORT4); - rte_eth_stats_reset(RXTX_PORT5); - - /* send and receive 1 packet and check for stats update */ - if (rte_eth_tx_burst(RXTX_PORT4, 0, &pbuf, 1) != 1) { - printf("Error sending packet to RXTX port\n"); - return -1; - } - if (rte_eth_rx_burst(RXTX_PORT5, 0, &pbuf, 1) != 1) { - printf("Error receiving packet from RXTX port\n"); - return -1; - } - - rte_eth_stats_get(RXTX_PORT4, &stats); - rte_eth_stats_get(RXTX_PORT5, &stats2); - if (stats.ipackets != 0 || stats.opackets != 1 || - stats.ibytes != 0 || stats.obytes != 0 || - stats.ierrors != 0 || stats.oerrors != 0) { - printf("Error: RXTX port stats are not as expected\n"); - return -1; - } - - if (stats2.ipackets != 1 || stats2.opackets != 0 || - stats2.ibytes != 0 || stats2.obytes != 0 || - stats2.ierrors != 0 || stats2.oerrors != 0) { - printf("Error: RXTX port stats are not as expected\n"); - return -1; - } - - rte_eth_dev_stop(RXTX_PORT4); - rte_eth_dev_stop(RXTX_PORT5); - + /* Test init same name pmd ring */ + rte_pmd_ring_devinit(name1, params_null); return 0; } @@ -476,6 +405,9 @@ test_pmd_ring(void) return -1; } + if (test_ring_ethdev_create() < 0) + return -1; + if (test_ethdev_configure() < 0) return -1; @@ -495,11 +427,6 @@ test_pmd_ring(void) if (test_pmd_ring_init() < 0) return -1; - if (test_pmd_ring_pair_create() < 0) - return -1; - - if (test_pmd_ring_pair_attach() < 0) - return -1; return 0; } -- 1.7.0.7