ring pmd autotest
v3 cover ring pmd autotest
Fix failures in the ring_pmd_autotest program.
Correct errors in the ring PMD documentation.
Changes in v3:
rebase to latest code.
revicse commit messages.
Changes in v2:
move doc changes to a seperate patch.
Bernard Iremonger (2):
app/test: fix failures in the ring_pmd_autotest program
doc: correct Rings-based PMD section in the NIC Drivers guides
app/test/test_pmd_ring.c | 360 +++++++++++++++++++++++++----------------- doc/guides/nics/pcap_ring.rst | 28 ++-- 2 files changed, 235 insertions(+), 153 deletions(-)
Signature · 1 line
1.9.1
PATCH v3 1/2 app/test: fix failures in the ring_pmd_autotest program
If eth_ring vdevs are created from the command line with the --vdev option, they create there own rings which are not shared by other vdevs. Some of tests in this suite require that the vdevs share rings, so some of the tests fail.
For vdevs to share rings they must be created in the test code with the rte_eth_from_rings() function using rings created with the rte_ring_create() function.
Use the command line option --vdev=eth_ring0 to create port 0. Create two rings and five ethdevs in test_pmd_ring.c for ports 1 to 5. Improve test output by adding the port number to printf statements, and adding a printf describing each test.
--- app/test/test_pmd_ring.c | 360 ++++++++++++++++++++++++++++------------------- 1 file changed, 219 insertions(+), 141 deletions(-)
app/test/test_pmd_ring.c +219 -141
@@ -1,7 +1,7 @@/*- * BSD LICENSE * -* Copyright(c) 2010-2014 Intel Corporation. All rights reserved. +* Copyright(c) 2010-2015 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without
@@ -38,108 +38,104 @@#include <rte_ethdev.h> static struct rte_mempool *mp; +static int tx_porta, rx_portb, rxtx_portc, rxtx_portd, rxtx_porte; -#define TX_PORT 0 -#define RX_PORT 1 -#define RXTX_PORT 2 -#define RXTX_PORT2 3 -#define RXTX_PORT3 4#define SOCKET0 0 -#define RING_SIZE 256 +#define NUM_RINGS 2 +#define NB_MBUF 512 -#define NB_MBUF 512static int -test_ethdev_configure (void ) +test_ethdev_configure_port (int port) {struct rte_eth_conf null_conf;struct rte_eth_link link;memset (&null_conf,0 ,sizeof (struct rte_eth_conf )); -if ((TX_PORT >=RTE_MAX_ETHPORTS ) || (RX_PORT >=RTE_MAX_ETHPORTS )\ - || (RXTX_PORT >=RTE_MAX_ETHPORTS )) { -printf (" TX/RX port exceed max eth ports\n" ); -return -1 ; - } -if (rte_eth_dev_configure (TX_PORT ,1 ,2 , &null_conf) <0 ) { -printf ("Configure failed for TX port\n" ); +if (rte_eth_dev_configure (port,1 ,2 , &null_conf) <0 ) { +printf ("Configure failed for port %d\n" , port);return -1 ; }/* Test queue release */ -if (rte_eth_dev_configure (TX_PORT ,1 ,1 , &null_conf) <0 ) { -printf ("Configure failed for TX port\n" ); -return -1 ; - } -if (rte_eth_dev_configure (RX_PORT ,1 ,1 , &null_conf) <0 ) { -printf ("Configure failed for RX port\n" ); -return -1 ; - } -if (rte_eth_dev_configure (RXTX_PORT ,1 ,1 , &null_conf) <0 ) { -printf ("Configure failed for RXTX port\n" ); +if (rte_eth_dev_configure (port,1 ,1 , &null_conf) <0 ) { +printf ("Configure failed for port %d\n" , port);return -1 ; } -if (rte_eth_tx_queue_setup (TX_PORT ,0 ,RING_SIZE ,SOCKET0 ,NULL ) <0 ) { -printf ("TX queue setup failed\n" ); -return -1 ; - } -if (rte_eth_rx_queue_setup (RX_PORT ,0 ,RING_SIZE ,SOCKET0 , -NULL , mp) <0 ) { -printf ("RX queue setup failed\n" ); -return -1 ; - } -if (rte_eth_tx_queue_setup (RXTX_PORT ,0 ,RING_SIZE ,SOCKET0 ,NULL ) <0 ) { -printf ("TX queue setup failed\n" ); +if (rte_eth_tx_queue_setup (port,0 ,RING_SIZE ,SOCKET0 ,NULL ) <0 ) { +printf ("TX queue setup failed port %d\n" , port);return -1 ; } -if (rte_eth_rx_queue_setup (RXTX_PORT ,0 ,RING_SIZE ,SOCKET0 , + +if (rte_eth_rx_queue_setup (port,0 ,RING_SIZE ,SOCKET0 ,NULL , mp) <0 ) { -printf ("RX queue setup failed\n" ); +printf ("RX queue setup failed port %d\n" , port);return -1 ; } -if (rte_eth_dev_start (TX_PORT ) <0 ) { -printf ("Error starting TX port\n" ); +if (rte_eth_dev_start (port) <0 ) { +printf ("Error starting port %d\n" , port);return -1 ; } -if (rte_eth_dev_start (RX_PORT ) <0 ) { -printf ("Error starting RX port\n" ); + +rte_eth_link_get (port, &link); + +return 0 ; +} + +static int +test_send_basic_packets (void ) +{ +struct rte_mbuf bufs[RING_SIZE ]; +struct rte_mbuf *pbufs[RING_SIZE ]; +int i; + +printf ("Testing send and receive RING_SIZE/2 packets (tx_porta -> rx_portb)\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);return -1 ; } -if (rte_eth_dev_start (RXTX_PORT ) <0 ) { -printf ("Error starting RX port\n" ); + +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);return -1 ; } -rte_eth_link_get (TX_PORT , &link); -rte_eth_link_get (RX_PORT , &link); -rte_eth_link_get (RXTX_PORT , &link); +for (i =0 ; i <RING_SIZE /2 ; i++) +if (pbufs[i] != &bufs[i]) { +printf ("Error: received data does not match that transmitted\n" ); +return -1 ; + }return 0 ; }static int -test_send_basic_packets (void ) +test_send_basic_packets_port (int port) {struct rte_mbuf bufs[RING_SIZE ];struct rte_mbuf *pbufs[RING_SIZE ];int i; -printf ("Testing ring pmd RX/TX\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]; -if (rte_eth_tx_burst (TX_PORT ,0 , pbufs,RING_SIZE /2 ) <RING_SIZE /2 ) { -printf ("Failed to transmit packet burst\n" ); +if (rte_eth_tx_burst (port,0 , pbufs,RING_SIZE /2 ) <RING_SIZE /2 ) { +printf ("Failed to transmit packet burst port %d\n" , port);return -1 ; } -if (rte_eth_rx_burst (RX_PORT ,0 , pbufs,RING_SIZE ) !=RING_SIZE /2 ) { -printf ("Failed to receive packet burst\n" ); +if (rte_eth_rx_burst (port,0 , pbufs,RING_SIZE ) !=RING_SIZE /2 ) { +printf ("Failed to receive packet burst on port %d\n" , port);return -1 ; }
@@ -152,89 +148,92 @@ test_send_basic_packets(void)return 0 ; } +static int -test_get_stats (void ) +test_get_stats (int port) {struct rte_eth_stats stats;struct rte_mbuf buf, *pbuf = &buf; -printf ("Testing ring PMD stats\n" ); +printf ("Testing ring PMD stats_get port %d\n" , port);/* check stats of RXTX port, should all be zero */ -rte_eth_stats_get (RXTX_PORT , &stats); + +rte_eth_stats_get (port, &stats);if (stats.ipackets !=0 || stats.opackets !=0 || stats.ibytes !=0 || stats.obytes !=0 || stats.ierrors !=0 || stats.oerrors !=0 ) { -printf ("Error: RXTX port stats are not zero\n" ); +printf ("Error: port %d stats are not zero\n" , port);return -1 ; }/* send and receive 1 packet and check for stats update */ -if (rte_eth_tx_burst (RXTX_PORT ,0 , &pbuf,1 ) !=1 ) { -printf ("Error sending packet to RXTX port\n" ); +if (rte_eth_tx_burst (port,0 , &pbuf,1 ) !=1 ) { +printf ("Error sending packet to port %d\n" , port);return -1 ; } -if (rte_eth_rx_burst (RXTX_PORT ,0 , &pbuf,1 ) !=1 ) { -printf ("Error receiving packet from RXTX port\n" ); + +if (rte_eth_rx_burst (port,0 , &pbuf,1 ) !=1 ) { +printf ("Error receiving packet from port %d\n" , port);return -1 ; } -rte_eth_stats_get (RXTX_PORT , &stats); +rte_eth_stats_get (port, &stats);if (stats.ipackets !=1 || 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" ); +printf ("Error: port %d stats are not as expected\n" , port);return -1 ; }return 0 ; }static int -test_stats_reset (void ) +test_stats_reset (int port) {struct rte_eth_stats stats;struct rte_mbuf buf, *pbuf = &buf; -printf ("Testing ring PMD stats reset\n" ); +printf ("Testing ring PMD stats_reset port %d\n" , port); -rte_eth_stats_reset (RXTX_PORT ); +rte_eth_stats_reset (port);/* check stats of RXTX port, should all be zero */ -rte_eth_stats_get (RXTX_PORT , &stats); +rte_eth_stats_get (port, &stats);if (stats.ipackets !=0 || stats.opackets !=0 || stats.ibytes !=0 || stats.obytes !=0 || stats.ierrors !=0 || stats.oerrors !=0 ) { -printf ("Error: RXTX port stats are not zero\n" ); +printf ("Error: port %d stats are not zero\n" , port);return -1 ; }/* send and receive 1 packet and check for stats update */ -if (rte_eth_tx_burst (RXTX_PORT ,0 , &pbuf,1 ) !=1 ) { -printf ("Error sending packet to RXTX port\n" ); +if (rte_eth_tx_burst (port,0 , &pbuf,1 ) !=1 ) { +printf ("Error sending packet to port %d\n" , port);return -1 ; } -if (rte_eth_rx_burst (RXTX_PORT ,0 , &pbuf,1 ) !=1 ) { -printf ("Error receiving packet from RXTX port\n" ); +if (rte_eth_rx_burst (port,0 , &pbuf,1 ) !=1 ) { +printf ("Error receiving packet from port %d\n" , port);return -1 ; } -rte_eth_stats_get (RXTX_PORT , &stats); +rte_eth_stats_get (port, &stats);if (stats.ipackets !=1 || 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" ); +printf ("Error: port %d stats are not as expected\n" , port);return -1 ; } -rte_eth_stats_reset (RXTX_PORT ); +rte_eth_stats_reset (port);/* check stats of RXTX port, should all be zero */ -rte_eth_stats_get (RXTX_PORT , &stats); +rte_eth_stats_get (port, &stats);if (stats.ipackets !=0 || stats.opackets !=0 || stats.ibytes !=0 || stats.obytes !=0 || stats.ierrors !=0 || stats.oerrors !=0 ) { -printf ("Error: RXTX port stats are not zero\n" ); +printf ("Error: port %d stats are not zero\n" , port);return -1 ; }
@@ -242,162 +241,182 @@ test_stats_reset(void) }static int -test_pmd_ring_pair_create_attach (void ) +test_pmd_ring_pair_create_attach (int portd,int porte) {struct rte_eth_stats stats, stats2;struct rte_mbuf buf, *pbuf = &buf;struct rte_eth_conf null_conf; -if ((RXTX_PORT2 >=RTE_MAX_ETHPORTS ) || (RXTX_PORT3 >=RTE_MAX_ETHPORTS )) { -printf (" TX/RX port exceed max eth ports\n" ); -return -1 ; - } -if ((rte_eth_dev_configure (RXTX_PORT2 ,1 ,1 , &null_conf) <0 ) - || (rte_eth_dev_configure (RXTX_PORT3 ,1 ,1 , &null_conf) <0 )) { -printf ("Configure failed for RXTX port\n" ); +if ((rte_eth_dev_configure (portd,1 ,1 , &null_conf) <0 ) + || (rte_eth_dev_configure (porte,1 ,1 , &null_conf) <0 )) { +printf ("Configure failed for port\n" );return -1 ; } -if ((rte_eth_tx_queue_setup (RXTX_PORT2 ,0 ,RING_SIZE ,SOCKET0 ,NULL ) <0 ) - || (rte_eth_tx_queue_setup (RXTX_PORT3 ,0 ,RING_SIZE ,SOCKET0 ,NULL ) <0 )) { +if ((rte_eth_tx_queue_setup (portd,0 ,RING_SIZE ,SOCKET0 ,NULL ) <0 ) + || (rte_eth_tx_queue_setup (porte,0 ,RING_SIZE ,SOCKET0 ,NULL ) <0 )) {printf ("TX queue setup failed\n" );return -1 ; } -if ((rte_eth_rx_queue_setup (RXTX_PORT2 ,0 ,RING_SIZE ,SOCKET0 ,NULL , mp) <0 ) - || (rte_eth_rx_queue_setup (RXTX_PORT3 ,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 ; } -if ((rte_eth_dev_start (RXTX_PORT2 ) <0 ) - || (rte_eth_dev_start (RXTX_PORT3 ) <0 )) { -printf ("Error starting RXTX port\n" ); +if ((rte_eth_dev_start (portd) <0 ) + || (rte_eth_dev_start (porte) <0 )) { +printf ("Error starting port\n" ); +return -1 ; + } + +rte_eth_stats_reset (portd); +/* check stats of port, should all be zero */ +rte_eth_stats_get (portd, &stats); +if (stats.ipackets !=0 || stats.opackets !=0 || + stats.ibytes !=0 || stats.obytes !=0 || + stats.ierrors !=0 || stats.oerrors !=0 ) { +printf ("Error: port %d stats are not zero\n" , portd); +return -1 ; + } + +rte_eth_stats_reset (porte); +/* check stats of port, should all be zero */ +rte_eth_stats_get (porte, &stats2); +if (stats2.ipackets !=0 || stats2.opackets !=0 || + stats2.ibytes !=0 || stats2.obytes !=0 || + stats2.ierrors !=0 || stats2.oerrors !=0 ) { +printf ("Error: port %d stats are not zero\n" , porte);return -1 ; }/* -* send and receive 1 packet (RXTX_PORT2 -> RXTX_PORT3) +* send and receive 1 packet (portd -> porte) * and check for stats update */ -if (rte_eth_tx_burst (RXTX_PORT2 ,0 , &pbuf,1 ) !=1 ) { -printf ("Error sending packet to RXTX port\n" ); +printf ("Testing send and receive 1 packet (portd -> porte)\n" ); +if (rte_eth_tx_burst (portd,0 , &pbuf,1 ) !=1 ) { +printf ("Error sending packet to port %d\n" , portd);return -1 ; } -if (rte_eth_rx_burst (RXTX_PORT3 ,0 , &pbuf,1 ) !=1 ) { -printf ("Error receiving packet from RXTX port\n" ); +if (rte_eth_rx_burst (porte,0 , &pbuf,1 ) !=1 ) { +printf ("Error receiving packet from port %d\n" , porte);return -1 ; } -rte_eth_stats_get (RXTX_PORT2 , &stats); -rte_eth_stats_get (RXTX_PORT3 , &stats2); +rte_eth_stats_get (portd, &stats); +rte_eth_stats_get (porte, &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" ); +printf ("Error: port %d stats are not as expected\n" , portd);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" ); +printf ("Error: port %d stats are not as expected\n" , porte);return -1 ; }/* -* send and receive 1 packet (RXTX_PORT3 -> RXTX_PORT2) +* send and receive 1 packet (porte -> portd) * and check for stats update */ -if (rte_eth_tx_burst (RXTX_PORT3 ,0 , &pbuf,1 ) !=1 ) { -printf ("Error sending packet to RXTX port\n" ); +printf ("Testing send and receive 1 packet (porte -> portd)\n" ); +if (rte_eth_tx_burst (porte,0 , &pbuf,1 ) !=1 ) { +printf ("Error sending packet to port %d\n" , porte);return -1 ; } -if (rte_eth_rx_burst (RXTX_PORT2 ,0 , &pbuf,1 ) !=1 ) { -printf ("Error receiving packet from RXTX port\n" ); +if (rte_eth_rx_burst (portd,0 , &pbuf,1 ) !=1 ) { +printf ("Error receiving packet from port %d\n" , portd);return -1 ; } -rte_eth_stats_get (RXTX_PORT2 , &stats); -rte_eth_stats_get (RXTX_PORT3 , &stats2); +rte_eth_stats_get (portd, &stats); +rte_eth_stats_get (porte, &stats2);if (stats.ipackets !=1 || 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" ); +printf ("Error: port %d stats are not as expected\n" , portd);return -1 ; }if (stats2.ipackets !=1 || stats2.opackets !=1 || stats2.ibytes !=0 || stats2.obytes !=0 || stats2.ierrors !=0 || stats2.oerrors !=0 ) { -printf ("Error: RXTX port stats are not as expected\n" ); +printf ("Error: port %d stats are not as expected\n" , porte);return -1 ; }/* -* send and receive 1 packet (RXTX_PORT2 -> RXTX_PORT2) +* send and receive 1 packet (portd -> portd) * and check for stats update */ -if (rte_eth_tx_burst (RXTX_PORT2 ,0 , &pbuf,1 ) !=1 ) { -printf ("Error sending packet to RXTX port\n" ); +printf ("Testing send and receive 1 packet (portd -> portd)\n" ); +if (rte_eth_tx_burst (portd,0 , &pbuf,1 ) !=1 ) { +printf ("Error sending packet to port %d\n" , portd);return -1 ; } -if (rte_eth_rx_burst (RXTX_PORT2 ,0 , &pbuf,1 ) !=1 ) { -printf ("Error receiving packet from RXTX port\n" ); +if (rte_eth_rx_burst (portd,0 , &pbuf,1 ) !=1 ) { +printf ("Error receiving packet from port %d\n" , porte);return -1 ; } -rte_eth_stats_get (RXTX_PORT2 , &stats); -rte_eth_stats_get (RXTX_PORT3 , &stats2); +rte_eth_stats_get (portd, &stats); +rte_eth_stats_get (porte, &stats2);if (stats.ipackets !=2 || stats.opackets !=2 || stats.ibytes !=0 || stats.obytes !=0 || stats.ierrors !=0 || stats.oerrors !=0 ) { -printf ("Error: RXTX port stats are not as expected\n" ); +printf ("Error: port %d stats are not as expected\n" , portd);return -1 ; }if (stats2.ipackets !=1 || stats2.opackets !=1 || stats2.ibytes !=0 || stats2.obytes !=0 || stats2.ierrors !=0 || stats2.oerrors !=0 ) { -printf ("Error: RXTX port stats are not as expected\n" ); +printf ("Error: port %d stats are not as expected\n" , porte);return -1 ; }/* -* send and receive 1 packet (RXTX_PORT3 -> RXTX_PORT3) +* send and receive 1 packet (porte -> porte) * and check for stats update */ -if (rte_eth_tx_burst (RXTX_PORT3 ,0 , &pbuf,1 ) !=1 ) { -printf ("Error sending packet to RXTX port\n" ); +printf ("Testing send and receive 1 packet (porte -> porte)\n" ); +if (rte_eth_tx_burst (porte,0 , &pbuf,1 ) !=1 ) { +printf ("Error sending packet to port %d\n" , porte);return -1 ; } -if (rte_eth_rx_burst (RXTX_PORT3 ,0 , &pbuf,1 ) !=1 ) { -printf ("Error receiving packet from RXTX port\n" ); +if (rte_eth_rx_burst (porte,0 , &pbuf,1 ) !=1 ) { +printf ("Error receiving packet from port %d\n" , porte);return -1 ; } -rte_eth_stats_get (RXTX_PORT2 , &stats); -rte_eth_stats_get (RXTX_PORT3 , &stats2); +rte_eth_stats_get (portd, &stats); +rte_eth_stats_get (porte, &stats2);if (stats.ipackets !=2 || stats.opackets !=2 || stats.ibytes !=0 || stats.obytes !=0 || stats.ierrors !=0 || stats.oerrors !=0 ) { -printf ("Error: RXTX port stats are not as expected\n" ); +printf ("Error: port %d stats are not as expected\n" , portd);return -1 ; }if (stats2.ipackets !=2 || stats2.opackets !=2 || stats2.ibytes !=0 || stats2.obytes !=0 || stats2.ierrors !=0 || stats2.oerrors !=0 ) { -printf ("Error: RXTX port stats are not as expected\n" ); +printf ("Error: port %d stats are not as expected\n" , porte);return -1 ; } -rte_eth_dev_stop (RXTX_PORT2 ); -rte_eth_dev_stop (RXTX_PORT3 ); +rte_eth_dev_stop (portd); +rte_eth_dev_stop (porte);return 0 ; }
@@ -405,36 +424,95 @@ test_pmd_ring_pair_create_attach(void)static int test_pmd_ring (void ) { +struct rte_ring *rxtx[NUM_RINGS ]; +int cmdl_port0 =0 ; +uint8_t nb_ports; + + nb_ports =rte_eth_dev_count (); +printf ("nb_ports=%d\n" , (int )nb_ports); + +/* create the rings and eth_rings in the test code. +* This does not test the rte_pmd_ring_devinit function. +* +* Test with the command line option --vdev=eth_ring0 to test rte_pmd_ring_devinit. +*/ + 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 ); +if (rxtx[1 ] ==NULL ) { +printf ("rte_ring_create R1 failed" ); +return -1 ; + } + + tx_porta =rte_eth_from_rings ("eth_ringa" , rxtx,NUM_RINGS , rxtx,NUM_RINGS ,SOCKET0 ); + rx_portb =rte_eth_from_rings ("eth_ringb" , rxtx,NUM_RINGS , rxtx,NUM_RINGS ,SOCKET0 ); + rxtx_portc =rte_eth_from_rings ("eth_ringc" , rxtx,NUM_RINGS , rxtx,NUM_RINGS ,SOCKET0 ); + rxtx_portd =rte_eth_from_rings ("eth_ringd" , rxtx,NUM_RINGS , rxtx,NUM_RINGS ,SOCKET0 ); + rxtx_porte =rte_eth_from_rings ("eth_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); + +if ((tx_porta ==-1 ) || (rx_portb ==-1 ) || (rxtx_portc ==-1 ) + || (rxtx_portd ==-1 ) || (rxtx_porte ==-1 )) { +printf ("rte_eth_from rings failed\n" ); +return -1 ; + } + mp =rte_pktmbuf_pool_create ("mbuf_pool" ,NB_MBUF ,32 ,0 ,RTE_MBUF_DEFAULT_BUF_SIZE ,rte_socket_id ());if (mp ==NULL )return -1 ; -if ((TX_PORT >=RTE_MAX_ETHPORTS ) || (RX_PORT >=RTE_MAX_ETHPORTS )\ - || (RXTX_PORT >=RTE_MAX_ETHPORTS )) { -printf (" TX/RX port exceed max eth ports\n" ); +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 )) { +printf (" port exceed max eth ports\n" );return -1 ; } -if (test_ethdev_configure () <0 ) +if (test_ethdev_configure_port (tx_porta) <0 ) +return -1 ; + +if (test_ethdev_configure_port (rx_portb) <0 ) +return -1 ; + +if (test_ethdev_configure_port (rxtx_portc) <0 )return -1 ;if (test_send_basic_packets () <0 )return -1 ; -if (test_get_stats () <0 ) +if (test_get_stats (rxtx_portc) <0 )return -1 ; -if (test_stats_reset () <0 ) +if (test_stats_reset (rxtx_portc) <0 )return -1 ; -rte_eth_dev_stop (RX_PORT ); -rte_eth_dev_stop (TX_PORT ); -rte_eth_dev_stop (RXTX_PORT ); +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 () <0 ) +if (test_pmd_ring_pair_create_attach (rxtx_portd, rxtx_porte) <0 )return -1 ; +if (nb_ports >0 ) { +/* test port 0 created with the --vdev=eth_ring0 command line option */ +if (test_ethdev_configure_port (cmdl_port0) <0 ) +return -1 ; +if (test_send_basic_packets_port (cmdl_port0) <0 ) +return -1 ; +if (test_stats_reset (cmdl_port0) <0 ) +return -1 ; +if (test_get_stats (cmdl_port0) <0 ) +return -1 ; +rte_eth_dev_stop (cmdl_port0); + }return 0 ; }
Signature · 1 line
1.9.1
Re: [PATCH v3 1/2] app/test: fix failures in the ring_pmd_autotest program
Quoted 2 lines · Bernard Iremonger
If
eth_ringvdevs are created from the command line with the --vdev option, they create there own rings which are not shared by other vdevs.
Typo: s/their/there/
Quoted 8 lines
Some of tests in this suite require that the vdevs share rings, so some of the tests fail.
For vdevs to share rings they must be created in the test code with the
rte_eth_from_rings()function using rings created with therte_ring_create()function.Use the command line option --vdev=eth_ring0 to create port 0.
As I understand it, this option is not mandatory for the tests to pass, it only allows some additional functional tests on cmd-line created rings to be run. This should perhaps still be called out in the commit message.
Quoted 1 line
Create two rings and five ethdevs in
test_pmd_ring.cfor ports 1 to 5.
"... and then use these to run the unit tests on the pmd ring functionality"
Quoted 3 lines
Improve test output by adding the port number to printf statements, and adding a printf describing each test.
/Bruce
Re: [PATCH v3 1/2] app/test: fix failures in the ring_pmd_autotest program
Hi Bruce,
<snip>
Quoted 8 lines
Subject: Re: [dpdk-dev] [PATCH v3 1/2] app/test: fix failures in the
ring_pmd_autotestprogramQuoted 2 lines · Bernard Iremonger
If
eth_ringvdevs are created from the command line with the --vdev option, they create there own rings which are not shared by other vdevs.Typo: s/their/there/
Will correct in v4.
Quoted 9 lines
Quoted 9 lines
Some of tests in this suite require that the vdevs share rings, so some of the tests fail.
For vdevs to share rings they must be created in the test code with the
rte_eth_from_rings()function using rings created with therte_ring_create()function.
Quoted 5 lines
Quoted 1 line
Use the command line option --vdev=eth_ring0 to create port 0.
As I understand it, this option is not mandatory for the tests to pass, it only allows some additional functional tests on cmd-line created rings to be run. This should perhaps still be called out in the commit message.
I will add that this option is not mandatory to the commit message.
Quoted 10 lines
Quoted 2 lines
Create two rings and five ethdevs in
test_pmd_ring.cfor ports 1 to 5."... and then use these to run the unit tests on the pmd ring functionality"
Quoted 3 lines
Improve test output by adding the port number to printf statements, and adding a printf describing each test.
/Bruce
Regards,
Bernard.
Re: [PATCH v3 1/2] app/test: fix failures in the ring_pmd_autotest program
2015-11-27 16:40, Iremonger, Bernard:
Quoted 1 line
Will correct in v4.
Bernard, please use --in-reply-to '<[email protected]>'. It will thread the v4 below the v3.
Thanks
PATCH v3 2/2 doc: correct Rings-based PMD section in the NIC Drivers guides
In reply to Bernard IremongerCorrect the sample code in the pcap_ring.rst file to match the latest rte_eth_ring.c code.
The parameters to the rte_eth_from_rings() function have changed since the documentation was written.
The API change occurred before DPDK 1.8 when the rst files were added. The original documentation on which the pcap_ring.rst file was based was not correct.
--- doc/guides/nics/pcap_ring.rst | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-)
doc/guides/nics/pcap_ring.rst +16 -12
@@ -1,5 +1,5 @@ .. BSD LICENSE - Copyright(c) 2010-2014 Intel Corporation. All rights reserved. + Copyright(c) 2010-2015 Intel Corporation. All rights reserved. All rights reserved. Redistribution and use in source and binary forms, with or without
@@ -217,7 +217,7 @@ Using the Poll Mode Driver from an Application Both drivers can provide similar APIs to allow the user to create a PMD, that is, rte_ethdev structure, instances at run-time in the end-application, for example, using rte_eth_from_rings() or rte_eth_from_pcaps() APIs. -For the rings- based PMD, this functionality could be used, for example, +For the rings-based PMD, this functionality could be used, for example, to allow data exchange between cores using rings to be done in exactly the same way as sending or receiving packets from an Ethernet device. For the libpcap-based PMD, it allows an application to open one or more pcap files
@@ -231,26 +231,30 @@ for reception on the same port (error handling omitted for clarity): .. code-block:: c - struct rte_ring *r1, *r2; - int port1, port2; + #define RING_SIZE 256 + #define NUM_RINGS 2 + #define SOCKET0 0 - r1 = rte_ring_create("R1", 256, SOCKET0,RING_F_SP_ENQ|RING_F_SC_DEQ); - r2 = rte_ring_create("R2", 256, SOCKET0, RING_F_SP_ENQ|RING_F_SC_DEQ); + struct rte_ring *ring[NUM_RINGS]; + int port0, port1; - /* create an ethdev where RX and TX are done to/from r1, and * another from r2 */ + ring[0] = rte_ring_create("R0", RING_SIZE, SOCKET0, RING_F_SP_ENQ|RING_F_SC_DEQ); + ring[1] = rte_ring_create("R1", RING_SIZE, SOCKET0, RING_F_SP_ENQ|RING_F_SC_DEQ); - port1 = rte_eth_from_rings(r1, 1, r1, 1, SOCKET0); - port2 = rte_eth_from_rings(r2, 1, r2, 1, SOCKET0); + /* create two ethdev's */ + + port0 = rte_eth_from_rings("eth_ring0", ring, NUM_RINGS, ring, NUM_RINGS, SOCKET0); + port1 = rte_eth_from_rings("eth_ring1", ring, NUM_RINGS, ring, NUM_RINGS, SOCKET0); To create two pseudo-Ethernet ports where the traffic is switched between them, -that is, traffic sent to port 1 is read back from port 2 and vice-versa, +that is, traffic sent to port 0 is read back from port 1 and vice-versa, the final two lines could be changed as below: .. code-block:: c - port1 = rte_eth_from_rings(r1, 1, r2, 1, SOCKET0); - port2 = rte_eth_from_rings(r2, 1, r1, 1, SOCKET0); + port0 = rte_eth_from_rings("eth_ring0", &ring[0], 1, &ring[1], 1, SOCKET0); + port1 = rte_eth_from_rings("eth_ring1", &ring[1], 1, &ring[0], 1, SOCKET0); This type of configuration could be useful in a pipeline model, for example, where one may want to have inter-core communication using pseudo Ethernet devices rather than raw rings,
Signature · 1 line
1.9.1
Re: [PATCH v3 2/2] doc: correct Rings-based PMD section in the NIC Drivers guides
Quoted 10 lines · Bernard Iremonger
Correct the sample code in the
pcap_ring.rstfile to match the latestrte_eth_ring.ccode.The parameters to the
rte_eth_from_rings()function have changed since the documentation was written.
The API change occurred before DPDK 1.8 when the rst files were added. The original documentation on which thepcap_ring.rstfile was based was not correct.Fixes correct the sample code in the pcap_ring.rst file.
This is not a standard fixes line. Please add the following alias to your .gitconfig and then use "git fixline <commit id>" to produce a correct fixes line identifying the commit being fixed.
[alias]
fixline = log -1 --abbrev=12 --format='Fixes: %h (\"%s\")'
/Bruce
Re: [PATCH v3 2/2] doc: correct Rings-based PMD section in the NIC Drivers guides
Hi Bruce,
<snip>
Quoted 7 lines
Quoted 2 lines
Fixes correct the sample code in the pcap_ring.rst file.This is not a standard fixes line. Please add the following alias to your .gitconfig and then use "git fixline <commit id>" to produce a correct fixes line identifying the commit being fixed.
Quoted 5 lines
[alias]
fixline = log -1 --abbrev=12 --format='Fixes: %h (\"%s\")'/Bruce
I have added the alias to my .gitconfig.
I have added correct fixes lines to the pathches.
Regards,
Bernard.
v4 cover ring pmd autotest
In reply to Bernard IremongerFix failures in the ring_pmd_autotest program.
Correct errors in the ring PMD documentation.
Changes in v4:
rebase to latest code.
update commit messages.
add Fixes: line to commit messages.
Changes in v3:
rebase to latest code.
revise commit messages.
Changes in v2:
move doc changes to a seperate patch.
Bernard Iremonger (2):
app/test: fix failures in the ring_pmd_autotest program
doc: correct Rings-based PMD section in the NIC Drivers guides
app/test/test_pmd_ring.c | 360 +++++++++++++++++++++++++----------------- doc/guides/nics/pcap_ring.rst | 28 ++-- 2 files changed, 235 insertions(+), 153 deletions(-)
Signature · 1 line
1.9.1
PATCH v4 1/2 app/test: fix failures in the ring_pmd_autotest program
If eth_ring vdevs are created from the command line with the --vdev option, they create their own rings which are not shared by other vdevs. Some of tests in this suite require that the vdevs share rings, so some of the tests fail.
For vdevs to share rings they must be created in the test code with the rte_eth_from_rings() function using rings created with the rte_ring_create() function.
Use the command line option --vdev=eth_ring0 to create port 0. This option is not mandatory for the tests to pass. It allows some additional functional tests on cmd-line created rings to be executed.
Create two rings and five ethdevs in test_pmd_ring.c for ports 1 to 5, and then use these to run the unit tests on the pmd ring functionality.
Improve test output by adding the port number to printf statements, and adding a printf describing each test.
--- app/test/test_pmd_ring.c | 360 ++++++++++++++++++++++++++++------------------- 1 file changed, 219 insertions(+), 141 deletions(-)
app/test/test_pmd_ring.c +219 -141
@@ -1,7 +1,7 @@/*- * BSD LICENSE * -* Copyright(c) 2010-2014 Intel Corporation. All rights reserved. +* Copyright(c) 2010-2015 Intel Corporation. All rights reserved. * All rights reserved. * * Redistribution and use in source and binary forms, with or without
@@ -38,108 +38,104 @@#include <rte_ethdev.h> static struct rte_mempool *mp; +static int tx_porta, rx_portb, rxtx_portc, rxtx_portd, rxtx_porte; -#define TX_PORT 0 -#define RX_PORT 1 -#define RXTX_PORT 2 -#define RXTX_PORT2 3 -#define RXTX_PORT3 4#define SOCKET0 0 -#define RING_SIZE 256 +#define NUM_RINGS 2 +#define NB_MBUF 512 -#define NB_MBUF 512static int -test_ethdev_configure (void ) +test_ethdev_configure_port (int port) {struct rte_eth_conf null_conf;struct rte_eth_link link;memset (&null_conf,0 ,sizeof (struct rte_eth_conf )); -if ((TX_PORT >=RTE_MAX_ETHPORTS ) || (RX_PORT >=RTE_MAX_ETHPORTS )\ - || (RXTX_PORT >=RTE_MAX_ETHPORTS )) { -printf (" TX/RX port exceed max eth ports\n" ); -return -1 ; - } -if (rte_eth_dev_configure (TX_PORT ,1 ,2 , &null_conf) <0 ) { -printf ("Configure failed for TX port\n" ); +if (rte_eth_dev_configure (port,1 ,2 , &null_conf) <0 ) { +printf ("Configure failed for port %d\n" , port);return -1 ; }/* Test queue release */ -if (rte_eth_dev_configure (TX_PORT ,1 ,1 , &null_conf) <0 ) { -printf ("Configure failed for TX port\n" ); -return -1 ; - } -if (rte_eth_dev_configure (RX_PORT ,1 ,1 , &null_conf) <0 ) { -printf ("Configure failed for RX port\n" ); -return -1 ; - } -if (rte_eth_dev_configure (RXTX_PORT ,1 ,1 , &null_conf) <0 ) { -printf ("Configure failed for RXTX port\n" ); +if (rte_eth_dev_configure (port,1 ,1 , &null_conf) <0 ) { +printf ("Configure failed for port %d\n" , port);return -1 ; } -if (rte_eth_tx_queue_setup (TX_PORT ,0 ,RING_SIZE ,SOCKET0 ,NULL ) <0 ) { -printf ("TX queue setup failed\n" ); -return -1 ; - } -if (rte_eth_rx_queue_setup (RX_PORT ,0 ,RING_SIZE ,SOCKET0 , -NULL , mp) <0 ) { -printf ("RX queue setup failed\n" ); -return -1 ; - } -if (rte_eth_tx_queue_setup (RXTX_PORT ,0 ,RING_SIZE ,SOCKET0 ,NULL ) <0 ) { -printf ("TX queue setup failed\n" ); +if (rte_eth_tx_queue_setup (port,0 ,RING_SIZE ,SOCKET0 ,NULL ) <0 ) { +printf ("TX queue setup failed port %d\n" , port);return -1 ; } -if (rte_eth_rx_queue_setup (RXTX_PORT ,0 ,RING_SIZE ,SOCKET0 , + +if (rte_eth_rx_queue_setup (port,0 ,RING_SIZE ,SOCKET0 ,NULL , mp) <0 ) { -printf ("RX queue setup failed\n" ); +printf ("RX queue setup failed port %d\n" , port);return -1 ; } -if (rte_eth_dev_start (TX_PORT ) <0 ) { -printf ("Error starting TX port\n" ); +if (rte_eth_dev_start (port) <0 ) { +printf ("Error starting port %d\n" , port);return -1 ; } -if (rte_eth_dev_start (RX_PORT ) <0 ) { -printf ("Error starting RX port\n" ); + +rte_eth_link_get (port, &link); + +return 0 ; +} + +static int +test_send_basic_packets (void ) +{ +struct rte_mbuf bufs[RING_SIZE ]; +struct rte_mbuf *pbufs[RING_SIZE ]; +int i; + +printf ("Testing send and receive RING_SIZE/2 packets (tx_porta -> rx_portb)\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);return -1 ; } -if (rte_eth_dev_start (RXTX_PORT ) <0 ) { -printf ("Error starting RX port\n" ); + +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);return -1 ; } -rte_eth_link_get (TX_PORT , &link); -rte_eth_link_get (RX_PORT , &link); -rte_eth_link_get (RXTX_PORT , &link); +for (i =0 ; i <RING_SIZE /2 ; i++) +if (pbufs[i] != &bufs[i]) { +printf ("Error: received data does not match that transmitted\n" ); +return -1 ; + }return 0 ; }static int -test_send_basic_packets (void ) +test_send_basic_packets_port (int port) {struct rte_mbuf bufs[RING_SIZE ];struct rte_mbuf *pbufs[RING_SIZE ];int i; -printf ("Testing ring pmd RX/TX\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]; -if (rte_eth_tx_burst (TX_PORT ,0 , pbufs,RING_SIZE /2 ) <RING_SIZE /2 ) { -printf ("Failed to transmit packet burst\n" ); +if (rte_eth_tx_burst (port,0 , pbufs,RING_SIZE /2 ) <RING_SIZE /2 ) { +printf ("Failed to transmit packet burst port %d\n" , port);return -1 ; } -if (rte_eth_rx_burst (RX_PORT ,0 , pbufs,RING_SIZE ) !=RING_SIZE /2 ) { -printf ("Failed to receive packet burst\n" ); +if (rte_eth_rx_burst (port,0 , pbufs,RING_SIZE ) !=RING_SIZE /2 ) { +printf ("Failed to receive packet burst on port %d\n" , port);return -1 ; }
@@ -152,89 +148,92 @@ test_send_basic_packets(void)return 0 ; } +static int -test_get_stats (void ) +test_get_stats (int port) {struct rte_eth_stats stats;struct rte_mbuf buf, *pbuf = &buf; -printf ("Testing ring PMD stats\n" ); +printf ("Testing ring PMD stats_get port %d\n" , port);/* check stats of RXTX port, should all be zero */ -rte_eth_stats_get (RXTX_PORT , &stats); + +rte_eth_stats_get (port, &stats);if (stats.ipackets !=0 || stats.opackets !=0 || stats.ibytes !=0 || stats.obytes !=0 || stats.ierrors !=0 || stats.oerrors !=0 ) { -printf ("Error: RXTX port stats are not zero\n" ); +printf ("Error: port %d stats are not zero\n" , port);return -1 ; }/* send and receive 1 packet and check for stats update */ -if (rte_eth_tx_burst (RXTX_PORT ,0 , &pbuf,1 ) !=1 ) { -printf ("Error sending packet to RXTX port\n" ); +if (rte_eth_tx_burst (port,0 , &pbuf,1 ) !=1 ) { +printf ("Error sending packet to port %d\n" , port);return -1 ; } -if (rte_eth_rx_burst (RXTX_PORT ,0 , &pbuf,1 ) !=1 ) { -printf ("Error receiving packet from RXTX port\n" ); + +if (rte_eth_rx_burst (port,0 , &pbuf,1 ) !=1 ) { +printf ("Error receiving packet from port %d\n" , port);return -1 ; } -rte_eth_stats_get (RXTX_PORT , &stats); +rte_eth_stats_get (port, &stats);if (stats.ipackets !=1 || 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" ); +printf ("Error: port %d stats are not as expected\n" , port);return -1 ; }return 0 ; }static int -test_stats_reset (void ) +test_stats_reset (int port) {struct rte_eth_stats stats;struct rte_mbuf buf, *pbuf = &buf; -printf ("Testing ring PMD stats reset\n" ); +printf ("Testing ring PMD stats_reset port %d\n" , port); -rte_eth_stats_reset (RXTX_PORT ); +rte_eth_stats_reset (port);/* check stats of RXTX port, should all be zero */ -rte_eth_stats_get (RXTX_PORT , &stats); +rte_eth_stats_get (port, &stats);if (stats.ipackets !=0 || stats.opackets !=0 || stats.ibytes !=0 || stats.obytes !=0 || stats.ierrors !=0 || stats.oerrors !=0 ) { -printf ("Error: RXTX port stats are not zero\n" ); +printf ("Error: port %d stats are not zero\n" , port);return -1 ; }/* send and receive 1 packet and check for stats update */ -if (rte_eth_tx_burst (RXTX_PORT ,0 , &pbuf,1 ) !=1 ) { -printf ("Error sending packet to RXTX port\n" ); +if (rte_eth_tx_burst (port,0 , &pbuf,1 ) !=1 ) { +printf ("Error sending packet to port %d\n" , port);return -1 ; } -if (rte_eth_rx_burst (RXTX_PORT ,0 , &pbuf,1 ) !=1 ) { -printf ("Error receiving packet from RXTX port\n" ); +if (rte_eth_rx_burst (port,0 , &pbuf,1 ) !=1 ) { +printf ("Error receiving packet from port %d\n" , port);return -1 ; } -rte_eth_stats_get (RXTX_PORT , &stats); +rte_eth_stats_get (port, &stats);if (stats.ipackets !=1 || 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" ); +printf ("Error: port %d stats are not as expected\n" , port);return -1 ; } -rte_eth_stats_reset (RXTX_PORT ); +rte_eth_stats_reset (port);/* check stats of RXTX port, should all be zero */ -rte_eth_stats_get (RXTX_PORT , &stats); +rte_eth_stats_get (port, &stats);if (stats.ipackets !=0 || stats.opackets !=0 || stats.ibytes !=0 || stats.obytes !=0 || stats.ierrors !=0 || stats.oerrors !=0 ) { -printf ("Error: RXTX port stats are not zero\n" ); +printf ("Error: port %d stats are not zero\n" , port);return -1 ; }
@@ -242,162 +241,182 @@ test_stats_reset(void) }static int -test_pmd_ring_pair_create_attach (void ) +test_pmd_ring_pair_create_attach (int portd,int porte) {struct rte_eth_stats stats, stats2;struct rte_mbuf buf, *pbuf = &buf;struct rte_eth_conf null_conf; -if ((RXTX_PORT2 >=RTE_MAX_ETHPORTS ) || (RXTX_PORT3 >=RTE_MAX_ETHPORTS )) { -printf (" TX/RX port exceed max eth ports\n" ); -return -1 ; - } -if ((rte_eth_dev_configure (RXTX_PORT2 ,1 ,1 , &null_conf) <0 ) - || (rte_eth_dev_configure (RXTX_PORT3 ,1 ,1 , &null_conf) <0 )) { -printf ("Configure failed for RXTX port\n" ); +if ((rte_eth_dev_configure (portd,1 ,1 , &null_conf) <0 ) + || (rte_eth_dev_configure (porte,1 ,1 , &null_conf) <0 )) { +printf ("Configure failed for port\n" );return -1 ; } -if ((rte_eth_tx_queue_setup (RXTX_PORT2 ,0 ,RING_SIZE ,SOCKET0 ,NULL ) <0 ) - || (rte_eth_tx_queue_setup (RXTX_PORT3 ,0 ,RING_SIZE ,SOCKET0 ,NULL ) <0 )) { +if ((rte_eth_tx_queue_setup (portd,0 ,RING_SIZE ,SOCKET0 ,NULL ) <0 ) + || (rte_eth_tx_queue_setup (porte,0 ,RING_SIZE ,SOCKET0 ,NULL ) <0 )) {printf ("TX queue setup failed\n" );return -1 ; } -if ((rte_eth_rx_queue_setup (RXTX_PORT2 ,0 ,RING_SIZE ,SOCKET0 ,NULL , mp) <0 ) - || (rte_eth_rx_queue_setup (RXTX_PORT3 ,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 ; } -if ((rte_eth_dev_start (RXTX_PORT2 ) <0 ) - || (rte_eth_dev_start (RXTX_PORT3 ) <0 )) { -printf ("Error starting RXTX port\n" ); +if ((rte_eth_dev_start (portd) <0 ) + || (rte_eth_dev_start (porte) <0 )) { +printf ("Error starting port\n" ); +return -1 ; + } + +rte_eth_stats_reset (portd); +/* check stats of port, should all be zero */ +rte_eth_stats_get (portd, &stats); +if (stats.ipackets !=0 || stats.opackets !=0 || + stats.ibytes !=0 || stats.obytes !=0 || + stats.ierrors !=0 || stats.oerrors !=0 ) { +printf ("Error: port %d stats are not zero\n" , portd); +return -1 ; + } + +rte_eth_stats_reset (porte); +/* check stats of port, should all be zero */ +rte_eth_stats_get (porte, &stats2); +if (stats2.ipackets !=0 || stats2.opackets !=0 || + stats2.ibytes !=0 || stats2.obytes !=0 || + stats2.ierrors !=0 || stats2.oerrors !=0 ) { +printf ("Error: port %d stats are not zero\n" , porte);return -1 ; }/* -* send and receive 1 packet (RXTX_PORT2 -> RXTX_PORT3) +* send and receive 1 packet (portd -> porte) * and check for stats update */ -if (rte_eth_tx_burst (RXTX_PORT2 ,0 , &pbuf,1 ) !=1 ) { -printf ("Error sending packet to RXTX port\n" ); +printf ("Testing send and receive 1 packet (portd -> porte)\n" ); +if (rte_eth_tx_burst (portd,0 , &pbuf,1 ) !=1 ) { +printf ("Error sending packet to port %d\n" , portd);return -1 ; } -if (rte_eth_rx_burst (RXTX_PORT3 ,0 , &pbuf,1 ) !=1 ) { -printf ("Error receiving packet from RXTX port\n" ); +if (rte_eth_rx_burst (porte,0 , &pbuf,1 ) !=1 ) { +printf ("Error receiving packet from port %d\n" , porte);return -1 ; } -rte_eth_stats_get (RXTX_PORT2 , &stats); -rte_eth_stats_get (RXTX_PORT3 , &stats2); +rte_eth_stats_get (portd, &stats); +rte_eth_stats_get (porte, &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" ); +printf ("Error: port %d stats are not as expected\n" , portd);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" ); +printf ("Error: port %d stats are not as expected\n" , porte);return -1 ; }/* -* send and receive 1 packet (RXTX_PORT3 -> RXTX_PORT2) +* send and receive 1 packet (porte -> portd) * and check for stats update */ -if (rte_eth_tx_burst (RXTX_PORT3 ,0 , &pbuf,1 ) !=1 ) { -printf ("Error sending packet to RXTX port\n" ); +printf ("Testing send and receive 1 packet (porte -> portd)\n" ); +if (rte_eth_tx_burst (porte,0 , &pbuf,1 ) !=1 ) { +printf ("Error sending packet to port %d\n" , porte);return -1 ; } -if (rte_eth_rx_burst (RXTX_PORT2 ,0 , &pbuf,1 ) !=1 ) { -printf ("Error receiving packet from RXTX port\n" ); +if (rte_eth_rx_burst (portd,0 , &pbuf,1 ) !=1 ) { +printf ("Error receiving packet from port %d\n" , portd);return -1 ; } -rte_eth_stats_get (RXTX_PORT2 , &stats); -rte_eth_stats_get (RXTX_PORT3 , &stats2); +rte_eth_stats_get (portd, &stats); +rte_eth_stats_get (porte, &stats2);if (stats.ipackets !=1 || 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" ); +printf ("Error: port %d stats are not as expected\n" , portd);return -1 ; }if (stats2.ipackets !=1 || stats2.opackets !=1 || stats2.ibytes !=0 || stats2.obytes !=0 || stats2.ierrors !=0 || stats2.oerrors !=0 ) { -printf ("Error: RXTX port stats are not as expected\n" ); +printf ("Error: port %d stats are not as expected\n" , porte);return -1 ; }/* -* send and receive 1 packet (RXTX_PORT2 -> RXTX_PORT2) +* send and receive 1 packet (portd -> portd) * and check for stats update */ -if (rte_eth_tx_burst (RXTX_PORT2 ,0 , &pbuf,1 ) !=1 ) { -printf ("Error sending packet to RXTX port\n" ); +printf ("Testing send and receive 1 packet (portd -> portd)\n" ); +if (rte_eth_tx_burst (portd,0 , &pbuf,1 ) !=1 ) { +printf ("Error sending packet to port %d\n" , portd);return -1 ; } -if (rte_eth_rx_burst (RXTX_PORT2 ,0 , &pbuf,1 ) !=1 ) { -printf ("Error receiving packet from RXTX port\n" ); +if (rte_eth_rx_burst (portd,0 , &pbuf,1 ) !=1 ) { +printf ("Error receiving packet from port %d\n" , porte);return -1 ; } -rte_eth_stats_get (RXTX_PORT2 , &stats); -rte_eth_stats_get (RXTX_PORT3 , &stats2); +rte_eth_stats_get (portd, &stats); +rte_eth_stats_get (porte, &stats2);if (stats.ipackets !=2 || stats.opackets !=2 || stats.ibytes !=0 || stats.obytes !=0 || stats.ierrors !=0 || stats.oerrors !=0 ) { -printf ("Error: RXTX port stats are not as expected\n" ); +printf ("Error: port %d stats are not as expected\n" , portd);return -1 ; }if (stats2.ipackets !=1 || stats2.opackets !=1 || stats2.ibytes !=0 || stats2.obytes !=0 || stats2.ierrors !=0 || stats2.oerrors !=0 ) { -printf ("Error: RXTX port stats are not as expected\n" ); +printf ("Error: port %d stats are not as expected\n" , porte);return -1 ; }/* -* send and receive 1 packet (RXTX_PORT3 -> RXTX_PORT3) +* send and receive 1 packet (porte -> porte) * and check for stats update */ -if (rte_eth_tx_burst (RXTX_PORT3 ,0 , &pbuf,1 ) !=1 ) { -printf ("Error sending packet to RXTX port\n" ); +printf ("Testing send and receive 1 packet (porte -> porte)\n" ); +if (rte_eth_tx_burst (porte,0 , &pbuf,1 ) !=1 ) { +printf ("Error sending packet to port %d\n" , porte);return -1 ; } -if (rte_eth_rx_burst (RXTX_PORT3 ,0 , &pbuf,1 ) !=1 ) { -printf ("Error receiving packet from RXTX port\n" ); +if (rte_eth_rx_burst (porte,0 , &pbuf,1 ) !=1 ) { +printf ("Error receiving packet from port %d\n" , porte);return -1 ; } -rte_eth_stats_get (RXTX_PORT2 , &stats); -rte_eth_stats_get (RXTX_PORT3 , &stats2); +rte_eth_stats_get (portd, &stats); +rte_eth_stats_get (porte, &stats2);if (stats.ipackets !=2 || stats.opackets !=2 || stats.ibytes !=0 || stats.obytes !=0 || stats.ierrors !=0 || stats.oerrors !=0 ) { -printf ("Error: RXTX port stats are not as expected\n" ); +printf ("Error: port %d stats are not as expected\n" , portd);return -1 ; }if (stats2.ipackets !=2 || stats2.opackets !=2 || stats2.ibytes !=0 || stats2.obytes !=0 || stats2.ierrors !=0 || stats2.oerrors !=0 ) { -printf ("Error: RXTX port stats are not as expected\n" ); +printf ("Error: port %d stats are not as expected\n" , porte);return -1 ; } -rte_eth_dev_stop (RXTX_PORT2 ); -rte_eth_dev_stop (RXTX_PORT3 ); +rte_eth_dev_stop (portd); +rte_eth_dev_stop (porte);return 0 ; }
@@ -405,36 +424,95 @@ test_pmd_ring_pair_create_attach(void)static int test_pmd_ring (void ) { +struct rte_ring *rxtx[NUM_RINGS ]; +int cmdl_port0 =0 ; +uint8_t nb_ports; + + nb_ports =rte_eth_dev_count (); +printf ("nb_ports=%d\n" , (int )nb_ports); + +/* create the rings and eth_rings in the test code. +* This does not test the rte_pmd_ring_devinit function. +* +* Test with the command line option --vdev=eth_ring0 to test rte_pmd_ring_devinit. +*/ + 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 ); +if (rxtx[1 ] ==NULL ) { +printf ("rte_ring_create R1 failed" ); +return -1 ; + } + + tx_porta =rte_eth_from_rings ("eth_ringa" , rxtx,NUM_RINGS , rxtx,NUM_RINGS ,SOCKET0 ); + rx_portb =rte_eth_from_rings ("eth_ringb" , rxtx,NUM_RINGS , rxtx,NUM_RINGS ,SOCKET0 ); + rxtx_portc =rte_eth_from_rings ("eth_ringc" , rxtx,NUM_RINGS , rxtx,NUM_RINGS ,SOCKET0 ); + rxtx_portd =rte_eth_from_rings ("eth_ringd" , rxtx,NUM_RINGS , rxtx,NUM_RINGS ,SOCKET0 ); + rxtx_porte =rte_eth_from_rings ("eth_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); + +if ((tx_porta ==-1 ) || (rx_portb ==-1 ) || (rxtx_portc ==-1 ) + || (rxtx_portd ==-1 ) || (rxtx_porte ==-1 )) { +printf ("rte_eth_from rings failed\n" ); +return -1 ; + } + mp =rte_pktmbuf_pool_create ("mbuf_pool" ,NB_MBUF ,32 ,0 ,RTE_MBUF_DEFAULT_BUF_SIZE ,rte_socket_id ());if (mp ==NULL )return -1 ; -if ((TX_PORT >=RTE_MAX_ETHPORTS ) || (RX_PORT >=RTE_MAX_ETHPORTS )\ - || (RXTX_PORT >=RTE_MAX_ETHPORTS )) { -printf (" TX/RX port exceed max eth ports\n" ); +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 )) { +printf (" port exceed max eth ports\n" );return -1 ; } -if (test_ethdev_configure () <0 ) +if (test_ethdev_configure_port (tx_porta) <0 ) +return -1 ; + +if (test_ethdev_configure_port (rx_portb) <0 ) +return -1 ; + +if (test_ethdev_configure_port (rxtx_portc) <0 )return -1 ;if (test_send_basic_packets () <0 )return -1 ; -if (test_get_stats () <0 ) +if (test_get_stats (rxtx_portc) <0 )return -1 ; -if (test_stats_reset () <0 ) +if (test_stats_reset (rxtx_portc) <0 )return -1 ; -rte_eth_dev_stop (RX_PORT ); -rte_eth_dev_stop (TX_PORT ); -rte_eth_dev_stop (RXTX_PORT ); +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 () <0 ) +if (test_pmd_ring_pair_create_attach (rxtx_portd, rxtx_porte) <0 )return -1 ; +if (nb_ports >0 ) { +/* test port 0 created with the --vdev=eth_ring0 command line option */ +if (test_ethdev_configure_port (cmdl_port0) <0 ) +return -1 ; +if (test_send_basic_packets_port (cmdl_port0) <0 ) +return -1 ; +if (test_stats_reset (cmdl_port0) <0 ) +return -1 ; +if (test_get_stats (cmdl_port0) <0 ) +return -1 ; +rte_eth_dev_stop (cmdl_port0); + }return 0 ; }
Signature · 1 line
1.9.1
PATCH v4 2/2 doc: correct Rings-based PMD section in the NIC Drivers guides
In reply to Bernard IremongerCorrect the sample code in the pcap_ring.rst file to match the latest rte_eth_ring.c code.
The parameters to the rte_eth_from_rings() function have changed since the documentation was written.
The API change occurred before DPDK 1.8 when the rst files were added. The original documentation on which the pcap_ring.rst file was based was not correct.
--- doc/guides/nics/pcap_ring.rst | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-)
doc/guides/nics/pcap_ring.rst +16 -12
@@ -1,5 +1,5 @@ .. BSD LICENSE - Copyright(c) 2010-2014 Intel Corporation. All rights reserved. + Copyright(c) 2010-2015 Intel Corporation. All rights reserved. All rights reserved. Redistribution and use in source and binary forms, with or without
@@ -217,7 +217,7 @@ Using the Poll Mode Driver from an Application Both drivers can provide similar APIs to allow the user to create a PMD, that is, rte_ethdev structure, instances at run-time in the end-application, for example, using rte_eth_from_rings() or rte_eth_from_pcaps() APIs. -For the rings- based PMD, this functionality could be used, for example, +For the rings-based PMD, this functionality could be used, for example, to allow data exchange between cores using rings to be done in exactly the same way as sending or receiving packets from an Ethernet device. For the libpcap-based PMD, it allows an application to open one or more pcap files
@@ -231,26 +231,30 @@ for reception on the same port (error handling omitted for clarity): .. code-block:: c - struct rte_ring *r1, *r2; - int port1, port2; + #define RING_SIZE 256 + #define NUM_RINGS 2 + #define SOCKET0 0 - r1 = rte_ring_create("R1", 256, SOCKET0,RING_F_SP_ENQ|RING_F_SC_DEQ); - r2 = rte_ring_create("R2", 256, SOCKET0, RING_F_SP_ENQ|RING_F_SC_DEQ); + struct rte_ring *ring[NUM_RINGS]; + int port0, port1; - /* create an ethdev where RX and TX are done to/from r1, and * another from r2 */ + ring[0] = rte_ring_create("R0", RING_SIZE, SOCKET0, RING_F_SP_ENQ|RING_F_SC_DEQ); + ring[1] = rte_ring_create("R1", RING_SIZE, SOCKET0, RING_F_SP_ENQ|RING_F_SC_DEQ); - port1 = rte_eth_from_rings(r1, 1, r1, 1, SOCKET0); - port2 = rte_eth_from_rings(r2, 1, r2, 1, SOCKET0); + /* create two ethdev's */ + + port0 = rte_eth_from_rings("eth_ring0", ring, NUM_RINGS, ring, NUM_RINGS, SOCKET0); + port1 = rte_eth_from_rings("eth_ring1", ring, NUM_RINGS, ring, NUM_RINGS, SOCKET0); To create two pseudo-Ethernet ports where the traffic is switched between them, -that is, traffic sent to port 1 is read back from port 2 and vice-versa, +that is, traffic sent to port 0 is read back from port 1 and vice-versa, the final two lines could be changed as below: .. code-block:: c - port1 = rte_eth_from_rings(r1, 1, r2, 1, SOCKET0); - port2 = rte_eth_from_rings(r2, 1, r1, 1, SOCKET0); + port0 = rte_eth_from_rings("eth_ring0", &ring[0], 1, &ring[1], 1, SOCKET0); + port1 = rte_eth_from_rings("eth_ring1", &ring[1], 1, &ring[0], 1, SOCKET0); This type of configuration could be useful in a pipeline model, for example, where one may want to have inter-core communication using pseudo Ethernet devices rather than raw rings,
Signature · 1 line
1.9.1
Re: [PATCH v4 2/2] doc: correct Rings-based PMD section in the NIC Drivers guides
Quoted 16 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Bernard Iremonger
Sent: Saturday, November 28, 2015 11:02 AM
To: [email protected]
Subject: [dpdk-dev] [PATCH v4 2/2] doc: correct Rings-based PMD section in the NIC Drivers guidesCorrect the sample code in the
pcap_ring.rstfile to match the latestrte_eth_ring.ccode.The parameters to the
rte_eth_from_rings()function have changed since the documentation was written.
The API change occurred before DPDK 1.8 when the rst files were added. The original documentation on which thepcap_ring.rstfile was based was not correct.
Quoted 4 lines
Fixes fc1f2750a3ec("doc: programmers guide")Signed-off-by Bernard Iremonger <[email protected]>Acked-by Bruce Richardson <[email protected]>
Thomas Monjalon
Applied2015-11-28 11:01, Bernard Iremonger:
Quoted 12 lines
Fix failures in the
ring_pmd_autotestprogram.
Correct errors in the ring PMD documentation.Changes in v4:
rebase to latest code.
update commit messages.
add Fixes: line to commit messages.Changes in v3:
rebase to latest code.
revise commit messages.
Quoted 6 lines
Changes in v2:
move doc changes to a seperate patch.Bernard Iremonger (2):
app/test: fix failures in thering_pmd_autotestprogram
doc: correct Rings-based PMD section in the NIC Drivers guides
Applied, thanks