[dpdk-dev] [PATCH 1/1] app/test: create ring and ethdevs in pmd_ring_autotest

2015-11-24 Thread Richardson, Bruce


> -Original Message-
> From: Iremonger, Bernard
> Sent: Tuesday, November 24, 2015 4:29 PM
> To: Richardson, Bruce 
> Cc: dev at dpdk.org
> Subject: RE: [dpdk-dev] [PATCH 1/1] app/test: create ring and ethdevs in
> pmd_ring_autotest
> 
> Hi Bruce,
> 
> > -Original Message-
> > From: Richardson, Bruce
> > Sent: Tuesday, November 24, 2015 4:14 PM
> > To: Iremonger, Bernard 
> > Cc: dev at dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH 1/1] app/test: create ring and ethdevs
> > in pmd_ring_autotest
> >
> > On Mon, Nov 23, 2015 at 03:20:46PM +, Bernard Iremonger wrote:
> > > Use command line option --vdev=eth_ring0 to create port 0.
> > > Create two rings and five ethdevs in test_pmd_ring for ports 1 to 5.
> > > Improve test output by adding the port number to printf statements,
> > > and adding a printf describing each test.
> > >
> > > revise ring-based PMD doc to match latest ring PMD code.
> > >
> > > Signed-off-by: Bernard Iremonger 
> >
> > The doc changes are not relevant to the unit test fixes, so should be
> > in a separate patch. The test changes themselves are good though, and
> > actually makes the test runable without having to find a very specific
> > command-line incantation to make things work right.
> >
> > Subject to this being split into two:
> > Acked-by: Bruce Richardson 
> 
> Will I keep your ack on both patches when I split them?
> 
> Regards,
> 
> Bernard.
> 
Sure, feel free to.

/Bruce


[dpdk-dev] [PATCH 1/1] app/test: create ring and ethdevs in pmd_ring_autotest

2015-11-24 Thread Iremonger, Bernard
Hi Bruce,

> -Original Message-
> From: Richardson, Bruce
> Sent: Tuesday, November 24, 2015 4:14 PM
> To: Iremonger, Bernard 
> Cc: dev at dpdk.org
> Subject: Re: [dpdk-dev] [PATCH 1/1] app/test: create ring and ethdevs in
> pmd_ring_autotest
> 
> On Mon, Nov 23, 2015 at 03:20:46PM +, Bernard Iremonger wrote:
> > Use command line option --vdev=eth_ring0 to create port 0.
> > Create two rings and five ethdevs in test_pmd_ring for ports 1 to 5.
> > Improve test output by adding the port number to printf statements,
> > and adding a printf describing each test.
> >
> > revise ring-based PMD doc to match latest ring PMD code.
> >
> > Signed-off-by: Bernard Iremonger 
> 
> The doc changes are not relevant to the unit test fixes, so should be in a
> separate patch. The test changes themselves are good though, and actually
> makes the test runable without having to find a very specific command-line
> incantation to make things work right.
> 
> Subject to this being split into two:
> Acked-by: Bruce Richardson 

Will I keep your ack on both patches when I split them?

Regards,

Bernard.






[dpdk-dev] [PATCH 1/1] app/test: create ring and ethdevs in pmd_ring_autotest

2015-11-24 Thread Bruce Richardson
On Mon, Nov 23, 2015 at 03:20:46PM +, Bernard Iremonger wrote:
> Use command line option --vdev=eth_ring0 to create port 0.
> Create two rings and five ethdevs in test_pmd_ring for ports 1 to 5.
> Improve test output by adding the port number to printf statements,
> and adding a printf describing each test.
> 
> revise ring-based PMD doc to match latest ring PMD code.
> 
> Signed-off-by: Bernard Iremonger 

The doc changes are not relevant to the unit test fixes, so should be in a 
separate patch. The test changes themselves are good though, and actually makes
the test runable without having to find a very specific command-line incantation
to make things work right.

Subject to this being split into two:
Acked-by: Bruce Richardson 


> ---
>  app/test/test_pmd_ring.c  | 360 
> +-
>  doc/guides/nics/pcap_ring.rst |  28 ++--
>  2 files changed, 235 insertions(+), 153 deletions(-)
> 
> diff --git a/app/test/test_pmd_ring.c b/app/test/test_pmd_ring.c
> index a555db8..5568759 100644
> --- a/app/test/test_pmd_ring.c
> +++ b/app/test/test_pmd_ring.c
> @@ -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 
>  
>  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   512
>  
>  static int
> -test_ethdev_configure(void)
> +test_ethdev_configure_port(int port)
>  {
>   struct rte_eth_conf null_conf;
>   struct rte_eth_link link;
>  
>   memset(_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, _conf) < 0) {
> - printf("Configure failed for TX port\n");
> + if (rte_eth_dev_configure(port, 1, 2, _conf) < 0) {
> + printf("Configure failed for port %d\n", port);
>   return -1;
>   }
>  
>   /* Test queue release */
> - if (rte_eth_dev_configure(TX_PORT, 1, 1, _conf) < 0) {
> - printf("Configure failed for TX port\n");
> - return -1;
> - }
> - if (rte_eth_dev_configure(RX_PORT, 1, 1, _conf) < 0) {
> - printf("Configure failed for RX port\n");
> - return -1;
> - }
> - if (rte_eth_dev_configure(RXTX_PORT, 1, 1, _conf) < 0) {
> - printf("Configure failed for RXTX port\n");
> + if (rte_eth_dev_configure(port, 1, 1, _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, );
> +
> + 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] = [i];
> +
> + if (rte_eth_tx_burst(tx_porta, 0, pbufs, RING_SIZE/2) < 

[dpdk-dev] [PATCH 1/1] app/test: create ring and ethdevs in pmd_ring_autotest

2015-11-23 Thread Bernard Iremonger
Use command line option --vdev=eth_ring0 to create port 0.
Create two rings and five ethdevs in test_pmd_ring for ports 1 to 5.
Improve test output by adding the port number to printf statements,
and adding a printf describing each test.

revise ring-based PMD doc to match latest ring PMD code.

Signed-off-by: Bernard Iremonger 
---
 app/test/test_pmd_ring.c  | 360 +-
 doc/guides/nics/pcap_ring.rst |  28 ++--
 2 files changed, 235 insertions(+), 153 deletions(-)

diff --git a/app/test/test_pmd_ring.c b/app/test/test_pmd_ring.c
index a555db8..5568759 100644
--- a/app/test/test_pmd_ring.c
+++ b/app/test/test_pmd_ring.c
@@ -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 

 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   512

 static int
-test_ethdev_configure(void)
+test_ethdev_configure_port(int port)
 {
struct rte_eth_conf null_conf;
struct rte_eth_link link;

memset(_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, _conf) < 0) {
-   printf("Configure failed for TX port\n");
+   if (rte_eth_dev_configure(port, 1, 2, _conf) < 0) {
+   printf("Configure failed for port %d\n", port);
return -1;
}

/* Test queue release */
-   if (rte_eth_dev_configure(TX_PORT, 1, 1, _conf) < 0) {
-   printf("Configure failed for TX port\n");
-   return -1;
-   }
-   if (rte_eth_dev_configure(RX_PORT, 1, 1, _conf) < 0) {
-   printf("Configure failed for RX port\n");
-   return -1;
-   }
-   if (rte_eth_dev_configure(RXTX_PORT, 1, 1, _conf) < 0) {
-   printf("Configure failed for RXTX port\n");
+   if (rte_eth_dev_configure(port, 1, 1, _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, );
+
+   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] = [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, );
-   rte_eth_link_get(RX_PORT, );
-   rte_eth_link_get(RXTX_PORT, );
+