* [dpdk-dev] [PATCH 1/2] test/pmd_ring_perf: release ring resources after test @ 2018-10-19 11:00 Phil Yang 2018-10-19 11:00 ` [dpdk-dev] [PATCH 2/2] test/pmd_ring: " Phil Yang 2018-11-18 22:21 ` [dpdk-dev] [PATCH 1/2] test/pmd_ring_perf: " Thomas Monjalon 0 siblings, 2 replies; 6+ messages in thread From: Phil Yang @ 2018-10-19 11:00 UTC (permalink / raw) To: dev; +Cc: nd Need to release the port and the ring resources after test. Otherwise, it will cause failure to allocate memory when reentry the test. Fixes: ea764af ("app/test: add performance test for ring driver") Signed-off-by: Phil Yang <phil.yang@arm.com> Reviewed-by: Gavin Hu <gavin.hu@arm.com> --- test/test/test_pmd_ring_perf.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/test/test_pmd_ring_perf.c b/test/test/test_pmd_ring_perf.c index ad5004a..6318da1 100644 --- a/test/test/test_pmd_ring_perf.c +++ b/test/test/test_pmd_ring_perf.c @@ -10,6 +10,7 @@ #include <rte_launch.h> #include <rte_ethdev.h> #include <rte_eth_ring.h> +#include <rte_bus_vdev.h> #include "test.h" @@ -135,6 +136,8 @@ test_bulk_enqueue_dequeue(void) static int test_ring_pmd_perf(void) { + char name[RTE_ETH_NAME_MAX_LEN]; + r = rte_ring_create(RING_NAME, RING_SIZE, rte_socket_id(), RING_F_SP_ENQ|RING_F_SC_DEQ); if (r == NULL && (r = rte_ring_lookup(RING_NAME)) == NULL) @@ -151,6 +154,11 @@ test_ring_pmd_perf(void) printf("\n### Testing using a single lcore ###\n"); test_bulk_enqueue_dequeue(); + /* release port and ring resources */ + rte_eth_dev_stop(ring_ethdev_port); + rte_eth_dev_get_name_by_port(ring_ethdev_port, name); + rte_vdev_uninit(name); + rte_ring_free(r); return 0; } -- 2.7.4 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [dpdk-dev] [PATCH 2/2] test/pmd_ring: release ring resources after test 2018-10-19 11:00 [dpdk-dev] [PATCH 1/2] test/pmd_ring_perf: release ring resources after test Phil Yang @ 2018-10-19 11:00 ` Phil Yang 2018-10-19 11:12 ` [dpdk-dev] [PATCH v2] " Phil Yang 2018-11-18 22:21 ` [dpdk-dev] [PATCH 1/2] test/pmd_ring_perf: " Thomas Monjalon 1 sibling, 1 reply; 6+ messages in thread From: Phil Yang @ 2018-10-19 11:00 UTC (permalink / raw) To: dev; +Cc: nd Need to release the port and the ring resources after test. Otherwise, it will cause failure to allocate memory when reentry the test. Fixes: 4ea3801 ("app/test: fix ring unit test") Signed-off-by: Phil Yang <phil.yang@arm.com> Reviewed-by: Gavin Hu <gavin.hu@arm.com> --- test/test/test_pmd_ring.c | 100 ++++++++++++++++++++++++++++------------------ 1 file changed, 62 insertions(+), 38 deletions(-) diff --git a/test/test/test_pmd_ring.c b/test/test/test_pmd_ring.c index 19d7d20..3d0eeee 100644 --- a/test/test/test_pmd_ring.c +++ b/test/test/test_pmd_ring.c @@ -7,15 +7,16 @@ #include <rte_eth_ring.h> #include <rte_ethdev.h> - -static struct rte_mempool *mp; -static int tx_porta, rx_portb, rxtx_portc, rxtx_portd, rxtx_porte; +#include <rte_bus_vdev.h> #define SOCKET0 0 #define RING_SIZE 256 #define NUM_RINGS 2 #define NB_MBUF 512 +#define NUM_PORTS 5 +static struct rte_mempool *mp; +static int ports[NUM_PORTS]; static int test_ethdev_configure_port(int port) @@ -64,18 +65,19 @@ test_send_basic_packets(void) struct rte_mbuf *pbufs[RING_SIZE]; int i; - printf("Testing send and receive RING_SIZE/2 packets (tx_porta -> rx_portb)\n"); + printf("Testing send and receive RING_SIZE/2 " + "packets (ports[0] -> ports[1])\n"); for (i = 0; i < RING_SIZE/2; i++) pbufs[i] = &bufs[i]; - if (rte_eth_tx_burst(tx_porta, 0, pbufs, RING_SIZE/2) < RING_SIZE/2) { - printf("Failed to transmit packet burst port %d\n", tx_porta); + if (rte_eth_tx_burst(ports[0], 0, pbufs, RING_SIZE/2) < RING_SIZE/2) { + printf("Failed to transmit packet burst port %d\n", ports[0]); return -1; } - if (rte_eth_rx_burst(rx_portb, 0, pbufs, RING_SIZE) != RING_SIZE/2) { - printf("Failed to receive packet burst on port %d\n", rx_portb); + if (rte_eth_rx_burst(ports[1], 0, pbufs, RING_SIZE) != RING_SIZE/2) { + printf("Failed to receive packet burst on port %d\n", ports[1]); return -1; } @@ -95,7 +97,8 @@ test_send_basic_packets_port(int port) struct rte_mbuf *pbufs[RING_SIZE]; int i; - printf("Testing send and receive RING_SIZE/2 packets (cmdl_port0 -> cmdl_port0)\n"); + printf("Testing send and receive RING_SIZE/2 packets \ + (cmdl_port0 -> cmdl_port0)\n"); for (i = 0; i < RING_SIZE/2; i++) pbufs[i] = &bufs[i]; @@ -232,8 +235,10 @@ test_pmd_ring_pair_create_attach(int portd, int porte) return -1; } - if ((rte_eth_rx_queue_setup(portd, 0, RING_SIZE, SOCKET0, NULL, mp) < 0) - || (rte_eth_rx_queue_setup(porte, 0, RING_SIZE, SOCKET0, NULL, mp) < 0)) { + if ((rte_eth_rx_queue_setup(portd, 0, RING_SIZE, + SOCKET0, NULL, mp) < 0) + || (rte_eth_rx_queue_setup(porte, 0, RING_SIZE, + SOCKET0, NULL, mp) < 0)) { printf("RX queue setup failed\n"); return -1; } @@ -388,9 +393,6 @@ test_pmd_ring_pair_create_attach(int portd, int porte) return -1; } - rte_eth_dev_stop(portd); - rte_eth_dev_stop(porte); - return 0; } @@ -400,6 +402,7 @@ test_pmd_ring(void) struct rte_ring *rxtx[NUM_RINGS]; int port, cmdl_port0 = -1; uint8_t nb_ports; + char port_name[RTE_ETH_NAME_MAX_LEN]; nb_ports = rte_eth_dev_count_avail(); printf("nb_ports=%d\n", (int)nb_ports); @@ -409,29 +412,36 @@ test_pmd_ring(void) * * Test with the command line option --vdev=net_ring0 to test rte_pmd_ring_devinit. */ - rxtx[0] = rte_ring_create("R0", RING_SIZE, SOCKET0, RING_F_SP_ENQ|RING_F_SC_DEQ); + rxtx[0] = rte_ring_create("R0", RING_SIZE, SOCKET0, + RING_F_SP_ENQ|RING_F_SC_DEQ); if (rxtx[0] == NULL) { printf("rte_ring_create R0 failed"); return -1; } - rxtx[1] = rte_ring_create("R1", RING_SIZE, SOCKET0, RING_F_SP_ENQ|RING_F_SC_DEQ); + rxtx[1] = rte_ring_create("R1", RING_SIZE, SOCKET0, + RING_F_SP_ENQ|RING_F_SC_DEQ); if (rxtx[1] == NULL) { printf("rte_ring_create R1 failed"); return -1; } - tx_porta = rte_eth_from_rings("net_ringa", rxtx, NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); - rx_portb = rte_eth_from_rings("net_ringb", rxtx, NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); - rxtx_portc = rte_eth_from_rings("net_ringc", rxtx, NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); - rxtx_portd = rte_eth_from_rings("net_ringd", rxtx, NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); - rxtx_porte = rte_eth_from_rings("net_ringe", rxtx, NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); + ports[0] = rte_eth_from_rings("net_ringa", rxtx, + NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); + ports[1] = rte_eth_from_rings("net_ringb", rxtx, + NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); + ports[2] = rte_eth_from_rings("net_ringc", rxtx, + NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); + ports[3] = rte_eth_from_rings("net_ringd", rxtx, + NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); + ports[4] = rte_eth_from_rings("net_ringe", rxtx, + NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); - printf("tx_porta=%d rx_portb=%d rxtx_portc=%d rxtx_portd=%d rxtx_porte=%d\n", - tx_porta, rx_portb, rxtx_portc, rxtx_portd, rxtx_porte); + printf("ports[0]=%d ports[1]=%d ports[2]=%d ports[3]=%d ports[4]=%d\n", + ports[0], ports[1], ports[2], ports[3], ports[4]); - if ((tx_porta == -1) || (rx_portb == -1) || (rxtx_portc == -1) - || (rxtx_portd == -1) || (rxtx_porte == -1)) { + if ((ports[0] == -1) || (ports[1] == -1) || (ports[2] == -1) + || (ports[3] == -1) || (ports[4] == -1)) { printf("rte_eth_from rings failed\n"); return -1; } @@ -441,37 +451,35 @@ test_pmd_ring(void) if (mp == NULL) return -1; - if ((tx_porta >= RTE_MAX_ETHPORTS) || (rx_portb >= RTE_MAX_ETHPORTS) - || (rxtx_portc >= RTE_MAX_ETHPORTS) - || (rxtx_portd >= RTE_MAX_ETHPORTS) - || (rxtx_porte >= RTE_MAX_ETHPORTS)) { + if ((ports[0] >= RTE_MAX_ETHPORTS) + || (ports[1] >= RTE_MAX_ETHPORTS) + || (ports[2] >= RTE_MAX_ETHPORTS) + || (ports[3] >= RTE_MAX_ETHPORTS) + || (ports[4] >= RTE_MAX_ETHPORTS)) { printf(" port exceed max eth ports\n"); return -1; } - if (test_ethdev_configure_port(tx_porta) < 0) + if (test_ethdev_configure_port(ports[0]) < 0) return -1; - if (test_ethdev_configure_port(rx_portb) < 0) + if (test_ethdev_configure_port(ports[1]) < 0) return -1; - if (test_ethdev_configure_port(rxtx_portc) < 0) + if (test_ethdev_configure_port(ports[2]) < 0) return -1; if (test_send_basic_packets() < 0) return -1; - if (test_get_stats(rxtx_portc) < 0) + if (test_get_stats(ports[2]) < 0) return -1; - if (test_stats_reset(rxtx_portc) < 0) + if (test_stats_reset(ports[2]) < 0) return -1; - rte_eth_dev_stop(tx_porta); - rte_eth_dev_stop(rx_portb); - rte_eth_dev_stop(rxtx_portc); - if (test_pmd_ring_pair_create_attach(rxtx_portd, rxtx_porte) < 0) + if (test_pmd_ring_pair_create_attach(ports[3], ports[4]) < 0) return -1; /* find a port created with the --vdev=net_ring0 command line option */ @@ -495,7 +503,23 @@ test_pmd_ring(void) if (test_get_stats(cmdl_port0) < 0) return -1; rte_eth_dev_stop(cmdl_port0); + rte_eth_dev_get_name_by_port(cmdl_port0, port_name); + rte_vdev_uninit(port_name); } + + /* release ports and rings resources */ + if (mp != NULL) + rte_mempool_free(mp); + + for (int i = 0; i < NUM_PORTS; i++) { + rte_eth_dev_stop(ports[i]); + rte_eth_dev_get_name_by_port(ports[i], port_name); + rte_vdev_uninit(port_name); + } + + for (int i = 0; i < NUM_RINGS; i++) + rte_ring_free(rxtx[i]); + return 0; } -- 2.7.4 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [dpdk-dev] [PATCH v2] test/pmd_ring: release ring resources after test 2018-10-19 11:00 ` [dpdk-dev] [PATCH 2/2] test/pmd_ring: " Phil Yang @ 2018-10-19 11:12 ` Phil Yang 2018-10-30 0:42 ` Phil Yang (Arm Technology China) 0 siblings, 1 reply; 6+ messages in thread From: Phil Yang @ 2018-10-19 11:12 UTC (permalink / raw) To: dev; +Cc: nd Need to release the port and the ring resources after test. Otherwise, it will cause failure to allocate memory when reentry the test. Fixes: 4ea3801 ("app/test: fix ring unit test") Signed-off-by: Phil Yang <phil.yang@arm.com> Reviewed-by: Gavin Hu <gavin.hu@arm.com> --- test/test/test_pmd_ring.c | 100 ++++++++++++++++++++++++++++------------------ 1 file changed, 62 insertions(+), 38 deletions(-) diff --git a/test/test/test_pmd_ring.c b/test/test/test_pmd_ring.c index 19d7d20..f332df9 100644 --- a/test/test/test_pmd_ring.c +++ b/test/test/test_pmd_ring.c @@ -7,15 +7,16 @@ #include <rte_eth_ring.h> #include <rte_ethdev.h> - -static struct rte_mempool *mp; -static int tx_porta, rx_portb, rxtx_portc, rxtx_portd, rxtx_porte; +#include <rte_bus_vdev.h> #define SOCKET0 0 #define RING_SIZE 256 #define NUM_RINGS 2 #define NB_MBUF 512 +#define NUM_PORTS 5 +static struct rte_mempool *mp; +static int ports[NUM_PORTS]; static int test_ethdev_configure_port(int port) @@ -64,18 +65,19 @@ test_send_basic_packets(void) struct rte_mbuf *pbufs[RING_SIZE]; int i; - printf("Testing send and receive RING_SIZE/2 packets (tx_porta -> rx_portb)\n"); + printf("Testing send and receive RING_SIZE/2 " + "packets (ports[0] -> ports[1])\n"); for (i = 0; i < RING_SIZE/2; i++) pbufs[i] = &bufs[i]; - if (rte_eth_tx_burst(tx_porta, 0, pbufs, RING_SIZE/2) < RING_SIZE/2) { - printf("Failed to transmit packet burst port %d\n", tx_porta); + if (rte_eth_tx_burst(ports[0], 0, pbufs, RING_SIZE/2) < RING_SIZE/2) { + printf("Failed to transmit packet burst port %d\n", ports[0]); return -1; } - if (rte_eth_rx_burst(rx_portb, 0, pbufs, RING_SIZE) != RING_SIZE/2) { - printf("Failed to receive packet burst on port %d\n", rx_portb); + if (rte_eth_rx_burst(ports[1], 0, pbufs, RING_SIZE) != RING_SIZE/2) { + printf("Failed to receive packet burst on port %d\n", ports[1]); return -1; } @@ -95,7 +97,8 @@ test_send_basic_packets_port(int port) struct rte_mbuf *pbufs[RING_SIZE]; int i; - printf("Testing send and receive RING_SIZE/2 packets (cmdl_port0 -> cmdl_port0)\n"); + printf("Testing send and receive RING_SIZE/2 packets" + "(cmdl_port0 -> cmdl_port0)\n"); for (i = 0; i < RING_SIZE/2; i++) pbufs[i] = &bufs[i]; @@ -232,8 +235,10 @@ test_pmd_ring_pair_create_attach(int portd, int porte) return -1; } - if ((rte_eth_rx_queue_setup(portd, 0, RING_SIZE, SOCKET0, NULL, mp) < 0) - || (rte_eth_rx_queue_setup(porte, 0, RING_SIZE, SOCKET0, NULL, mp) < 0)) { + if ((rte_eth_rx_queue_setup(portd, 0, RING_SIZE, + SOCKET0, NULL, mp) < 0) + || (rte_eth_rx_queue_setup(porte, 0, RING_SIZE, + SOCKET0, NULL, mp) < 0)) { printf("RX queue setup failed\n"); return -1; } @@ -388,9 +393,6 @@ test_pmd_ring_pair_create_attach(int portd, int porte) return -1; } - rte_eth_dev_stop(portd); - rte_eth_dev_stop(porte); - return 0; } @@ -400,6 +402,7 @@ test_pmd_ring(void) struct rte_ring *rxtx[NUM_RINGS]; int port, cmdl_port0 = -1; uint8_t nb_ports; + char port_name[RTE_ETH_NAME_MAX_LEN]; nb_ports = rte_eth_dev_count_avail(); printf("nb_ports=%d\n", (int)nb_ports); @@ -409,29 +412,36 @@ test_pmd_ring(void) * * Test with the command line option --vdev=net_ring0 to test rte_pmd_ring_devinit. */ - rxtx[0] = rte_ring_create("R0", RING_SIZE, SOCKET0, RING_F_SP_ENQ|RING_F_SC_DEQ); + rxtx[0] = rte_ring_create("R0", RING_SIZE, SOCKET0, + RING_F_SP_ENQ|RING_F_SC_DEQ); if (rxtx[0] == NULL) { printf("rte_ring_create R0 failed"); return -1; } - rxtx[1] = rte_ring_create("R1", RING_SIZE, SOCKET0, RING_F_SP_ENQ|RING_F_SC_DEQ); + rxtx[1] = rte_ring_create("R1", RING_SIZE, SOCKET0, + RING_F_SP_ENQ|RING_F_SC_DEQ); if (rxtx[1] == NULL) { printf("rte_ring_create R1 failed"); return -1; } - tx_porta = rte_eth_from_rings("net_ringa", rxtx, NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); - rx_portb = rte_eth_from_rings("net_ringb", rxtx, NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); - rxtx_portc = rte_eth_from_rings("net_ringc", rxtx, NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); - rxtx_portd = rte_eth_from_rings("net_ringd", rxtx, NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); - rxtx_porte = rte_eth_from_rings("net_ringe", rxtx, NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); + ports[0] = rte_eth_from_rings("net_ringa", rxtx, + NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); + ports[1] = rte_eth_from_rings("net_ringb", rxtx, + NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); + ports[2] = rte_eth_from_rings("net_ringc", rxtx, + NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); + ports[3] = rte_eth_from_rings("net_ringd", rxtx, + NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); + ports[4] = rte_eth_from_rings("net_ringe", rxtx, + NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); - printf("tx_porta=%d rx_portb=%d rxtx_portc=%d rxtx_portd=%d rxtx_porte=%d\n", - tx_porta, rx_portb, rxtx_portc, rxtx_portd, rxtx_porte); + printf("ports[0]=%d ports[1]=%d ports[2]=%d ports[3]=%d ports[4]=%d\n", + ports[0], ports[1], ports[2], ports[3], ports[4]); - if ((tx_porta == -1) || (rx_portb == -1) || (rxtx_portc == -1) - || (rxtx_portd == -1) || (rxtx_porte == -1)) { + if ((ports[0] == -1) || (ports[1] == -1) || (ports[2] == -1) + || (ports[3] == -1) || (ports[4] == -1)) { printf("rte_eth_from rings failed\n"); return -1; } @@ -441,37 +451,35 @@ test_pmd_ring(void) if (mp == NULL) return -1; - if ((tx_porta >= RTE_MAX_ETHPORTS) || (rx_portb >= RTE_MAX_ETHPORTS) - || (rxtx_portc >= RTE_MAX_ETHPORTS) - || (rxtx_portd >= RTE_MAX_ETHPORTS) - || (rxtx_porte >= RTE_MAX_ETHPORTS)) { + if ((ports[0] >= RTE_MAX_ETHPORTS) + || (ports[1] >= RTE_MAX_ETHPORTS) + || (ports[2] >= RTE_MAX_ETHPORTS) + || (ports[3] >= RTE_MAX_ETHPORTS) + || (ports[4] >= RTE_MAX_ETHPORTS)) { printf(" port exceed max eth ports\n"); return -1; } - if (test_ethdev_configure_port(tx_porta) < 0) + if (test_ethdev_configure_port(ports[0]) < 0) return -1; - if (test_ethdev_configure_port(rx_portb) < 0) + if (test_ethdev_configure_port(ports[1]) < 0) return -1; - if (test_ethdev_configure_port(rxtx_portc) < 0) + if (test_ethdev_configure_port(ports[2]) < 0) return -1; if (test_send_basic_packets() < 0) return -1; - if (test_get_stats(rxtx_portc) < 0) + if (test_get_stats(ports[2]) < 0) return -1; - if (test_stats_reset(rxtx_portc) < 0) + if (test_stats_reset(ports[2]) < 0) return -1; - rte_eth_dev_stop(tx_porta); - rte_eth_dev_stop(rx_portb); - rte_eth_dev_stop(rxtx_portc); - if (test_pmd_ring_pair_create_attach(rxtx_portd, rxtx_porte) < 0) + if (test_pmd_ring_pair_create_attach(ports[3], ports[4]) < 0) return -1; /* find a port created with the --vdev=net_ring0 command line option */ @@ -495,7 +503,23 @@ test_pmd_ring(void) if (test_get_stats(cmdl_port0) < 0) return -1; rte_eth_dev_stop(cmdl_port0); + rte_eth_dev_get_name_by_port(cmdl_port0, port_name); + rte_vdev_uninit(port_name); } + + /* release ports and rings resources */ + if (mp != NULL) + rte_mempool_free(mp); + + for (int i = 0; i < NUM_PORTS; i++) { + rte_eth_dev_stop(ports[i]); + rte_eth_dev_get_name_by_port(ports[i], port_name); + rte_vdev_uninit(port_name); + } + + for (int i = 0; i < NUM_RINGS; i++) + rte_ring_free(rxtx[i]); + return 0; } -- 2.7.4 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH v2] test/pmd_ring: release ring resources after test 2018-10-19 11:12 ` [dpdk-dev] [PATCH v2] " Phil Yang @ 2018-10-30 0:42 ` Phil Yang (Arm Technology China) 0 siblings, 0 replies; 6+ messages in thread From: Phil Yang (Arm Technology China) @ 2018-10-30 0:42 UTC (permalink / raw) To: Phil Yang (Arm Technology China), dev; +Cc: nd Hi, The commit 6e20a08 ("test/pmd_ring: restructure and cleanup") has already fixed this issue. Abandon this one. Thanks, Phil Yang > -----Original Message----- > From: dev <dev-bounces@dpdk.org> On Behalf Of Phil Yang > Sent: Friday, October 19, 2018 7:12 PM > To: dev@dpdk.org > Cc: nd <nd@arm.com> > Subject: [dpdk-dev] [PATCH v2] test/pmd_ring: release ring resources after test > > Need to release the port and the ring resources after test. Otherwise, it will > cause failure to allocate memory when reentry the test. > > Fixes: 4ea3801 ("app/test: fix ring unit test") > > Signed-off-by: Phil Yang <phil.yang@arm.com> > Reviewed-by: Gavin Hu <gavin.hu@arm.com> > --- > test/test/test_pmd_ring.c | 100 ++++++++++++++++++++++++++++---------------- > -- > 1 file changed, 62 insertions(+), 38 deletions(-) > > diff --git a/test/test/test_pmd_ring.c b/test/test/test_pmd_ring.c index > 19d7d20..f332df9 100644 > --- a/test/test/test_pmd_ring.c > +++ b/test/test/test_pmd_ring.c > @@ -7,15 +7,16 @@ > > #include <rte_eth_ring.h> > #include <rte_ethdev.h> > - > -static struct rte_mempool *mp; > -static int tx_porta, rx_portb, rxtx_portc, rxtx_portd, rxtx_porte; > +#include <rte_bus_vdev.h> > > #define SOCKET0 0 > #define RING_SIZE 256 > #define NUM_RINGS 2 > #define NB_MBUF 512 > +#define NUM_PORTS 5 > > +static struct rte_mempool *mp; > +static int ports[NUM_PORTS]; > > static int > test_ethdev_configure_port(int port) > @@ -64,18 +65,19 @@ test_send_basic_packets(void) > struct rte_mbuf *pbufs[RING_SIZE]; > int i; > > - printf("Testing send and receive RING_SIZE/2 packets (tx_porta -> > rx_portb)\n"); > + printf("Testing send and receive RING_SIZE/2 " > + "packets (ports[0] -> ports[1])\n"); > > for (i = 0; i < RING_SIZE/2; i++) > pbufs[i] = &bufs[i]; > > - if (rte_eth_tx_burst(tx_porta, 0, pbufs, RING_SIZE/2) < RING_SIZE/2) { > - printf("Failed to transmit packet burst port %d\n", tx_porta); > + if (rte_eth_tx_burst(ports[0], 0, pbufs, RING_SIZE/2) < RING_SIZE/2) { > + printf("Failed to transmit packet burst port %d\n", ports[0]); > return -1; > } > > - if (rte_eth_rx_burst(rx_portb, 0, pbufs, RING_SIZE) != RING_SIZE/2) { > - printf("Failed to receive packet burst on port %d\n", rx_portb); > + if (rte_eth_rx_burst(ports[1], 0, pbufs, RING_SIZE) != RING_SIZE/2) { > + printf("Failed to receive packet burst on port %d\n", ports[1]); > return -1; > } > > @@ -95,7 +97,8 @@ test_send_basic_packets_port(int port) > struct rte_mbuf *pbufs[RING_SIZE]; > int i; > > - printf("Testing send and receive RING_SIZE/2 packets (cmdl_port0 -> > cmdl_port0)\n"); > + printf("Testing send and receive RING_SIZE/2 packets" > + "(cmdl_port0 -> cmdl_port0)\n"); > > for (i = 0; i < RING_SIZE/2; i++) > pbufs[i] = &bufs[i]; > @@ -232,8 +235,10 @@ test_pmd_ring_pair_create_attach(int portd, int porte) > return -1; > } > > - if ((rte_eth_rx_queue_setup(portd, 0, RING_SIZE, SOCKET0, NULL, mp) < > 0) > - || (rte_eth_rx_queue_setup(porte, 0, RING_SIZE, SOCKET0, > NULL, mp) < 0)) { > + if ((rte_eth_rx_queue_setup(portd, 0, RING_SIZE, > + SOCKET0, NULL, mp) < 0) > + || (rte_eth_rx_queue_setup(porte, 0, RING_SIZE, > + SOCKET0, NULL, mp) < 0)) { > printf("RX queue setup failed\n"); > return -1; > } > @@ -388,9 +393,6 @@ test_pmd_ring_pair_create_attach(int portd, int porte) > return -1; > } > > - rte_eth_dev_stop(portd); > - rte_eth_dev_stop(porte); > - > return 0; > } > > @@ -400,6 +402,7 @@ test_pmd_ring(void) > struct rte_ring *rxtx[NUM_RINGS]; > int port, cmdl_port0 = -1; > uint8_t nb_ports; > + char port_name[RTE_ETH_NAME_MAX_LEN]; > > nb_ports = rte_eth_dev_count_avail(); > printf("nb_ports=%d\n", (int)nb_ports); @@ -409,29 +412,36 @@ > test_pmd_ring(void) > * > * Test with the command line option --vdev=net_ring0 to test > rte_pmd_ring_devinit. > */ > - rxtx[0] = rte_ring_create("R0", RING_SIZE, SOCKET0, > RING_F_SP_ENQ|RING_F_SC_DEQ); > + rxtx[0] = rte_ring_create("R0", RING_SIZE, SOCKET0, > + RING_F_SP_ENQ|RING_F_SC_DEQ); > if (rxtx[0] == NULL) { > printf("rte_ring_create R0 failed"); > return -1; > } > > - rxtx[1] = rte_ring_create("R1", RING_SIZE, SOCKET0, > RING_F_SP_ENQ|RING_F_SC_DEQ); > + rxtx[1] = rte_ring_create("R1", RING_SIZE, SOCKET0, > + RING_F_SP_ENQ|RING_F_SC_DEQ); > if (rxtx[1] == NULL) { > printf("rte_ring_create R1 failed"); > return -1; > } > > - tx_porta = rte_eth_from_rings("net_ringa", rxtx, NUM_RINGS, rxtx, > NUM_RINGS, SOCKET0); > - rx_portb = rte_eth_from_rings("net_ringb", rxtx, NUM_RINGS, rxtx, > NUM_RINGS, SOCKET0); > - rxtx_portc = rte_eth_from_rings("net_ringc", rxtx, NUM_RINGS, rxtx, > NUM_RINGS, SOCKET0); > - rxtx_portd = rte_eth_from_rings("net_ringd", rxtx, NUM_RINGS, rxtx, > NUM_RINGS, SOCKET0); > - rxtx_porte = rte_eth_from_rings("net_ringe", rxtx, NUM_RINGS, rxtx, > NUM_RINGS, SOCKET0); > + ports[0] = rte_eth_from_rings("net_ringa", rxtx, > + NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); > + ports[1] = rte_eth_from_rings("net_ringb", rxtx, > + NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); > + ports[2] = rte_eth_from_rings("net_ringc", rxtx, > + NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); > + ports[3] = rte_eth_from_rings("net_ringd", rxtx, > + NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); > + ports[4] = rte_eth_from_rings("net_ringe", rxtx, > + NUM_RINGS, rxtx, NUM_RINGS, SOCKET0); > > - printf("tx_porta=%d rx_portb=%d rxtx_portc=%d rxtx_portd=%d > rxtx_porte=%d\n", > - tx_porta, rx_portb, rxtx_portc, rxtx_portd, rxtx_porte); > + printf("ports[0]=%d ports[1]=%d ports[2]=%d ports[3]=%d > ports[4]=%d\n", > + ports[0], ports[1], ports[2], ports[3], ports[4]); > > - if ((tx_porta == -1) || (rx_portb == -1) || (rxtx_portc == -1) > - || (rxtx_portd == -1) || (rxtx_porte == -1)) { > + if ((ports[0] == -1) || (ports[1] == -1) || (ports[2] == -1) > + || (ports[3] == -1) || (ports[4] == -1)) { > printf("rte_eth_from rings failed\n"); > return -1; > } > @@ -441,37 +451,35 @@ test_pmd_ring(void) > if (mp == NULL) > return -1; > > - if ((tx_porta >= RTE_MAX_ETHPORTS) || (rx_portb >= > RTE_MAX_ETHPORTS) > - || (rxtx_portc >= RTE_MAX_ETHPORTS) > - || (rxtx_portd >= RTE_MAX_ETHPORTS) > - || (rxtx_porte >= RTE_MAX_ETHPORTS)) { > + if ((ports[0] >= RTE_MAX_ETHPORTS) > + || (ports[1] >= RTE_MAX_ETHPORTS) > + || (ports[2] >= RTE_MAX_ETHPORTS) > + || (ports[3] >= RTE_MAX_ETHPORTS) > + || (ports[4] >= RTE_MAX_ETHPORTS)) { > printf(" port exceed max eth ports\n"); > return -1; > } > > - if (test_ethdev_configure_port(tx_porta) < 0) > + if (test_ethdev_configure_port(ports[0]) < 0) > return -1; > > - if (test_ethdev_configure_port(rx_portb) < 0) > + if (test_ethdev_configure_port(ports[1]) < 0) > return -1; > > - if (test_ethdev_configure_port(rxtx_portc) < 0) > + if (test_ethdev_configure_port(ports[2]) < 0) > return -1; > > if (test_send_basic_packets() < 0) > return -1; > > - if (test_get_stats(rxtx_portc) < 0) > + if (test_get_stats(ports[2]) < 0) > return -1; > > - if (test_stats_reset(rxtx_portc) < 0) > + if (test_stats_reset(ports[2]) < 0) > return -1; > > - rte_eth_dev_stop(tx_porta); > - rte_eth_dev_stop(rx_portb); > - rte_eth_dev_stop(rxtx_portc); > > - if (test_pmd_ring_pair_create_attach(rxtx_portd, rxtx_porte) < 0) > + if (test_pmd_ring_pair_create_attach(ports[3], ports[4]) < 0) > return -1; > > /* find a port created with the --vdev=net_ring0 command line option */ > @@ -495,7 +503,23 @@ test_pmd_ring(void) > if (test_get_stats(cmdl_port0) < 0) > return -1; > rte_eth_dev_stop(cmdl_port0); > + rte_eth_dev_get_name_by_port(cmdl_port0, port_name); > + rte_vdev_uninit(port_name); > } > + > + /* release ports and rings resources */ > + if (mp != NULL) > + rte_mempool_free(mp); > + > + for (int i = 0; i < NUM_PORTS; i++) { > + rte_eth_dev_stop(ports[i]); > + rte_eth_dev_get_name_by_port(ports[i], port_name); > + rte_vdev_uninit(port_name); > + } > + > + for (int i = 0; i < NUM_RINGS; i++) > + rte_ring_free(rxtx[i]); > + > return 0; > } > > -- > 2.7.4 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH 1/2] test/pmd_ring_perf: release ring resources after test 2018-10-19 11:00 [dpdk-dev] [PATCH 1/2] test/pmd_ring_perf: release ring resources after test Phil Yang 2018-10-19 11:00 ` [dpdk-dev] [PATCH 2/2] test/pmd_ring: " Phil Yang @ 2018-11-18 22:21 ` Thomas Monjalon 2018-11-19 1:42 ` Phil Yang (Arm Technology China) 1 sibling, 1 reply; 6+ messages in thread From: Thomas Monjalon @ 2018-11-18 22:21 UTC (permalink / raw) To: Phil Yang; +Cc: dev, nd, gavin.hu 19/10/2018 13:00, Phil Yang: > Need to release the port and the ring resources after test. Otherwise, > it will cause failure to allocate memory when reentry the test. > > Fixes: ea764af ("app/test: add performance test for ring driver") > > Signed-off-by: Phil Yang <phil.yang@arm.com> > Reviewed-by: Gavin Hu <gavin.hu@arm.com> This patch was out of the radar because patch 2 was superseded. Applied, thanks ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [PATCH 1/2] test/pmd_ring_perf: release ring resources after test 2018-11-18 22:21 ` [dpdk-dev] [PATCH 1/2] test/pmd_ring_perf: " Thomas Monjalon @ 2018-11-19 1:42 ` Phil Yang (Arm Technology China) 0 siblings, 0 replies; 6+ messages in thread From: Phil Yang (Arm Technology China) @ 2018-11-19 1:42 UTC (permalink / raw) To: Thomas Monjalon; +Cc: dev, nd, Gavin Hu (Arm Technology China) Hi Thomas, > -----Original Message----- > From: Thomas Monjalon <thomas@monjalon.net> > Sent: Monday, November 19, 2018 6:21 AM > To: Phil Yang (Arm Technology China) <Phil.Yang@arm.com> > Cc: dev@dpdk.org; nd <nd@arm.com>; Gavin Hu (Arm Technology China) > <Gavin.Hu@arm.com> > Subject: Re: [dpdk-dev] [PATCH 1/2] test/pmd_ring_perf: release ring resources > after test > > 19/10/2018 13:00, Phil Yang: > > Need to release the port and the ring resources after test. Otherwise, > > it will cause failure to allocate memory when reentry the test. > > > > Fixes: ea764af ("app/test: add performance test for ring driver") > > > > Signed-off-by: Phil Yang <phil.yang@arm.com> > > Reviewed-by: Gavin Hu <gavin.hu@arm.com> > > This patch was out of the radar because patch 2 was superseded. > Patch 2 has been abandoned because another commit has already fixed that issue. Thanks. > Applied, thanks > Thanks, Phil ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-11-19 1:42 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-10-19 11:00 [dpdk-dev] [PATCH 1/2] test/pmd_ring_perf: release ring resources after test Phil Yang 2018-10-19 11:00 ` [dpdk-dev] [PATCH 2/2] test/pmd_ring: " Phil Yang 2018-10-19 11:12 ` [dpdk-dev] [PATCH v2] " Phil Yang 2018-10-30 0:42 ` Phil Yang (Arm Technology China) 2018-11-18 22:21 ` [dpdk-dev] [PATCH 1/2] test/pmd_ring_perf: " Thomas Monjalon 2018-11-19 1:42 ` Phil Yang (Arm Technology China)
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).