test/pmd_ring_perf: release ring resources after test
PATCH 1/2 test/pmd_ring_perf: 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.
--- test/test/test_pmd_ring_perf.c | 8 ++++++++ 1 file changed, 8 insertions(+)
test/test/test_pmd_ring_perf.c +8 -0
@@ -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 ; }
Signature · 1 line
2.7.4
PATCH 2/2 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.
--- test/test/test_pmd_ring.c | 100 ++++++++++++++++++++++++++++------------------ 1 file changed, 62 insertions(+), 38 deletions(-)
test/test/test_pmd_ring.c +62 -38
@@ -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 ; }
Signature · 1 line
2.7.4
PATCH v2 1/1 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.
--- test/test/test_pmd_ring.c | 100 ++++++++++++++++++++++++++++------------------ 1 file changed, 62 insertions(+), 38 deletions(-)
test/test/test_pmd_ring.c +62 -38
@@ -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 ; }
Signature · 1 line
2.7.4
Re: [PATCH v2] test/pmd_ring: release ring resources after test
Hi,
The commit 6e20a08 ("test/pmd_ring: restructure and cleanup") has already fixed this issue. Abandon this one.
Thanks,
Phil Yang
Quoted 247 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Phil Yang
Sent: Friday, October 19, 2018 7:12 PM
To: [email protected]
Cc: nd <[email protected]>
Subject: [dpdk-dev] [PATCH v2] test/pmd_ring: release ring resources after testNeed 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 <[email protected]>Reviewed-by Gavin Hu <[email protected]>--- test/test/test_pmd_ring.c | 100 ++++++++++++++++++++++++++++---------------- -- 1 file changed, 62 insertions(+), 38 deletions(-)test/test/test_pmd_ring.c index renamed from test/test/test_pmd_ring.c +0
-019d7d20..f332df9 100644
test/test/test_pmd_ring.c +12
-9@@ -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++)test/test/test_pmd_ring.c +4
-2pbufs[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" );test/test/test_pmd_ring.c +1
-3return -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/test/test_pmd_ring.c +0
-0* * Test with the command line option --vdev=net_ring0 to test
rte_pmd_ring_devinit.test/test/test_pmd_ring.c +0
-1*/ - rxtx[0] = rte_ring_create("R0", RING_SIZE, SOCKET0,RING_F_SP_ENQ|RING_F_SC_DEQ);
test/test/test_pmd_ring.c +2
-1+ 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);
test/test/test_pmd_ring.c +2
-1+ 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);test/test/test_pmd_ring.c +0
-1- rx_portb = rte_eth_from_rings("net_ringb", rxtx, NUM_RINGS, rxtx,
NUM_RINGS, SOCKET0);test/test/test_pmd_ring.c +0
-1- rxtx_portc = rte_eth_from_rings("net_ringc", rxtx, NUM_RINGS, rxtx,
NUM_RINGS, SOCKET0);test/test/test_pmd_ring.c +0
-1- rxtx_portd = rte_eth_from_rings("net_ringd", rxtx, NUM_RINGS, rxtx,
NUM_RINGS, SOCKET0);test/test/test_pmd_ring.c +0
-1- rxtx_porte = rte_eth_from_rings("net_ringe", rxtx, NUM_RINGS, rxtx,
NUM_RINGS, SOCKET0);test/test/test_pmd_ring.c +10
-1+ 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=%drxtx_porte=%d\n",
test/test/test_pmd_ring.c +1
-1- tx_porta, rx_portb, rxtx_portc, rxtx_portd, rxtx_porte); + printf("ports[0]=%d ports[1]=%d ports[2]=%d ports[3]=%dports[4]=%d\n",
test/test/test_pmd_ring.c +14
-15+ 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 ;test/test/test_pmd_ring.c +16
-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
Thomas Monjalon
Applied19/10/2018 13:00, Phil Yang:
Quoted 7 lines
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 <[email protected]>Reviewed-by Gavin Hu <[email protected]>
This patch was out of the radar because patch 2 was superseded.
Applied, thanks
Hi Thomas,
Quoted 13 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Monday, November 19, 2018 6:21 AM
To: Phil Yang (Arm Technology China) <[email protected]>
Cc: [email protected]; nd <[email protected]>; Gavin Hu (Arm Technology China) <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 1/2] test/pmd_ring_perf: release ring resources after test19/10/2018 13:00, Phil Yang:
Quoted 3 lines
Need to release the port and the ring resources after test. Otherwise, it will cause failure to allocate memory when reentry the test.
Quoted 7 lines
Quoted 4 lines
Fixes ea764af ("app/test: add performance test for ring driver")Signed-off-by Phil Yang <[email protected]>Reviewed-by Gavin Hu <[email protected]>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.
Quoted 2 lines
Applied, thanks
Thanks,
Phil