patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] test: fix forwarding packets through not-ready port
@ 2021-10-26 11:19 Konstantin Ananyev
  2021-10-26 15:39 ` David Marchand
  0 siblings, 1 reply; 3+ messages in thread
From: Konstantin Ananyev @ 2021-10-26 11:19 UTC (permalink / raw)
  To: dev; +Cc: david.marchand, reshma.pattan, Konstantin Ananyev, stable

(bitratestats_autotest|latencystats_autotest|pdump_autotest) tests
generate a log of error messages like that:

test_packet_forward() line 104: Error sending packet to port 0
Send pkts Failed

These tests use of app/test/sample_packet_forward.* code.
This code creates a portid from a ring, but doesn't properly
configure/start it.
The fix adds code to configure/start given port before usage.

Fixes: 7a0935239b9e ("ethdev: make fast-path functions to use new flat array")
Fixes: a52966cd48fd ("test: add helpers using ring PMD Rx/Tx")
Cc: stable@dpdk.org

Reported-by: David Marchand <david.marchand@redhat.com>
Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
 app/test/sample_packet_forward.c | 29 +++++++++++++++++++++++++++++
 app/test/sample_packet_forward.h |  3 +++
 app/test/test_bitratestats.c     | 12 +++++++++++-
 app/test/test_latencystats.c     | 12 +++++++++++-
 app/test/test_pdump.c            | 12 ++++++++++--
 5 files changed, 64 insertions(+), 4 deletions(-)

diff --git a/app/test/sample_packet_forward.c b/app/test/sample_packet_forward.c
index 61384b3d9b..aa897274d8 100644
--- a/app/test/sample_packet_forward.c
+++ b/app/test/sample_packet_forward.c
@@ -15,6 +15,35 @@
 
 #include "sample_packet_forward.h"
 
+/*
+ * heper function: configure and start test device
+ */
+int
+test_dev_start(uint16_t port, struct rte_mempool *mp)
+{
+	int32_t rc;
+	struct rte_eth_conf pconf;
+
+	memset(&pconf, 0, sizeof(pconf));
+
+	rc =  rte_eth_dev_configure(port, NUM_QUEUES, NUM_QUEUES, &pconf);
+	if (rc != 0)
+		return rc;
+
+	rc = rte_eth_rx_queue_setup(port, 0, RING_SIZE, SOCKET_ID_ANY,
+		NULL, mp);
+	if (rc != 0)
+		return rc;
+
+	rc = rte_eth_tx_queue_setup(port, 0, RING_SIZE, SOCKET_ID_ANY,
+		NULL);
+	if (rc != 0)
+		return rc;
+
+	rc = rte_eth_dev_start(port);
+	return rc;
+}
+
 /* Sample test to create virtual rings and tx,rx portid from rings */
 int
 test_ring_setup(struct rte_ring **ring, uint16_t *portid)
diff --git a/app/test/sample_packet_forward.h b/app/test/sample_packet_forward.h
index 6789217de3..af0b1d9924 100644
--- a/app/test/sample_packet_forward.h
+++ b/app/test/sample_packet_forward.h
@@ -21,6 +21,9 @@ struct rte_ring;
 /* Sample test to create virtual rings and tx,rx portid from rings */
 int test_ring_setup(struct rte_ring **ring, uint16_t *portid);
 
+/* configure and start device created by test_ring_setup */
+int test_dev_start(uint16_t port, struct rte_mempool *mp);
+
 /* Sample test to free the virtual rings */
 void test_ring_free(struct rte_ring *rxtx);
 
diff --git a/app/test/test_bitratestats.c b/app/test/test_bitratestats.c
index f4a92c9be6..1ff540f4c4 100644
--- a/app/test/test_bitratestats.c
+++ b/app/test/test_bitratestats.c
@@ -11,6 +11,7 @@
 #include <rte_memzone.h>
 #include <rte_metrics.h>
 #include <rte_bitrate.h>
+#include <rte_ethdev.h>
 
 #include "sample_packet_forward.h"
 #include "test.h"
@@ -159,12 +160,21 @@ test_bit_packet_forward(void)
 		printf("allocate mbuf pool Failed\n");
 		return TEST_FAILED;
 	}
+	ret = test_dev_start(portid, mp);
+	if (ret < 0) {
+		printf("test_dev_start(%hu, %p) failed, error code: %d\n",
+			portid, mp, ret);
+		return TEST_FAILED;
+	}
+
 	ret = test_packet_forward(pbuf, portid, QUEUE_ID);
 	if (ret < 0)
 		printf("send pkts Failed\n");
+
+	rte_eth_dev_stop(portid);
 	test_put_mbuf_to_pool(mp, pbuf);
 
-	return TEST_SUCCESS;
+	return (ret >= 0) ? TEST_SUCCESS : TEST_FAILED;
 }
 
 static int
diff --git a/app/test/test_latencystats.c b/app/test/test_latencystats.c
index 724acbc315..db06c7d5c7 100644
--- a/app/test/test_latencystats.c
+++ b/app/test/test_latencystats.c
@@ -6,6 +6,7 @@
 #include <stdint.h>
 #include <string.h>
 
+#include <rte_ethdev.h>
 #include <rte_latencystats.h>
 #include "rte_lcore.h"
 #include "rte_metrics.h"
@@ -158,12 +159,21 @@ static int test_latency_packet_forward(void)
 		printf("allocate mbuf pool Failed\n");
 		return TEST_FAILED;
 	}
+	ret = test_dev_start(portid, mp);
+	if (ret < 0) {
+		printf("test_dev_start(%hu, %p) failed, error code: %d\n",
+			portid, mp, ret);
+		return TEST_FAILED;
+	}
+
 	ret = test_packet_forward(pbuf, portid, QUEUE_ID);
 	if (ret < 0)
 		printf("send pkts Failed\n");
+
+	rte_eth_dev_stop(portid);
 	test_put_mbuf_to_pool(mp, pbuf);
 
-	return TEST_SUCCESS;
+	return (ret >= 0) ? TEST_SUCCESS : TEST_FAILED;
 }
 
 static struct
diff --git a/app/test/test_pdump.c b/app/test/test_pdump.c
index b49fcfb3f1..ea03056b47 100644
--- a/app/test/test_pdump.c
+++ b/app/test/test_pdump.c
@@ -147,11 +147,19 @@ send_pkts(void *empty)
 	ret = test_get_mbuf_from_pool(&mp, pbuf, poolname);
 	if (ret < 0)
 		printf("get_mbuf_from_pool failed\n");
-	do {
+
+	ret = test_dev_start(portid, mp);
+	if (ret < 0)
+		printf("test_dev_start(%hu, %p) failed, error code: %d\n",
+			portid, mp, ret);
+
+	while (ret >= 0 && flag_for_send_pkts) {
 		ret = test_packet_forward(pbuf, portid, QUEUE_ID);
 		if (ret < 0)
 			printf("send pkts Failed\n");
-	} while (flag_for_send_pkts);
+	};
+
+	rte_eth_dev_stop(portid);
 	test_put_mbuf_to_pool(mp, pbuf);
 	return empty;
 }
-- 
2.26.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-stable] [PATCH] test: fix forwarding packets through not-ready port
  2021-10-26 11:19 [dpdk-stable] [PATCH] test: fix forwarding packets through not-ready port Konstantin Ananyev
@ 2021-10-26 15:39 ` David Marchand
  2021-10-26 17:57   ` David Marchand
  0 siblings, 1 reply; 3+ messages in thread
From: David Marchand @ 2021-10-26 15:39 UTC (permalink / raw)
  To: Konstantin Ananyev; +Cc: dev, Pattan, Reshma, dpdk stable

On Tue, Oct 26, 2021 at 1:20 PM Konstantin Ananyev
<konstantin.ananyev@intel.com> wrote:
>
> (bitratestats_autotest|latencystats_autotest|pdump_autotest) tests
> generate a log of error messages like that:
>
> test_packet_forward() line 104: Error sending packet to port 0
> Send pkts Failed
>
> These tests use of app/test/sample_packet_forward.* code.
> This code creates a portid from a ring, but doesn't properly
> configure/start it.
> The fix adds code to configure/start given port before usage.
>
> Fixes: 7a0935239b9e ("ethdev: make fast-path functions to use new flat array")
> Fixes: a52966cd48fd ("test: add helpers using ring PMD Rx/Tx")
> Cc: stable@dpdk.org
>
> Reported-by: David Marchand <david.marchand@redhat.com>
> Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Tested-by: David Marchand <david.marchand@redhat.com>

Thanks for the fix.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-stable] [PATCH] test: fix forwarding packets through not-ready port
  2021-10-26 15:39 ` David Marchand
@ 2021-10-26 17:57   ` David Marchand
  0 siblings, 0 replies; 3+ messages in thread
From: David Marchand @ 2021-10-26 17:57 UTC (permalink / raw)
  To: Konstantin Ananyev; +Cc: dev, Pattan, Reshma, dpdk stable

On Tue, Oct 26, 2021 at 5:39 PM David Marchand
<david.marchand@redhat.com> wrote:
>
> On Tue, Oct 26, 2021 at 1:20 PM Konstantin Ananyev
> <konstantin.ananyev@intel.com> wrote:
> >
> > (bitratestats_autotest|latencystats_autotest|pdump_autotest) tests
> > generate a log of error messages like that:
> >
> > test_packet_forward() line 104: Error sending packet to port 0
> > Send pkts Failed
> >
> > These tests use of app/test/sample_packet_forward.* code.
> > This code creates a portid from a ring, but doesn't properly
> > configure/start it.
> > The fix adds code to configure/start given port before usage.
> >
> > Fixes: 7a0935239b9e ("ethdev: make fast-path functions to use new flat array")
> > Fixes: a52966cd48fd ("test: add helpers using ring PMD Rx/Tx")
> > Cc: stable@dpdk.org
> >
> > Reported-by: David Marchand <david.marchand@redhat.com>
> > Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> Tested-by: David Marchand <david.marchand@redhat.com>

Applied, thanks.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-26 17:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-26 11:19 [dpdk-stable] [PATCH] test: fix forwarding packets through not-ready port Konstantin Ananyev
2021-10-26 15:39 ` David Marchand
2021-10-26 17:57   ` David Marchand

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).