[dpdk-dev,1/4] net/ena: fix incorrect Rx descriptors allocation

Message ID 1491562138-2178-2-git-send-email-mw@semihalf.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Marcin Wojtas April 7, 2017, 10:48 a.m. UTC
  From: Michal Krawczyk <mk@semihalf.com>

When application tried to allocate 1024 descriptors, device was not
initializing properly.

This patch solves it by avoiding allocation of all descriptors in the ring
in one attempt. At least one descriptor must remain unused in the HW ring.

Fixes: 1173fca25af9 ("ena: add polling-mode driver")

Signed-off-by: Michal Krawczyk <mk@semihalf.com>
---
 drivers/net/ena/ena_ethdev.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
  

Comments

Jakub Palider April 10, 2017, 10:10 a.m. UTC | #1
Looks good to me but please, check commnt on patch 2/4. Moving the "-1"
indexing fix from patch 2/4 into 1/4 will reflect all related changes in
one place. But this is not a functional change, so may go in current shape
as well.

Jakub

On Fri, Apr 7, 2017 at 12:48 PM, Marcin Wojtas <mw@semihalf.com> wrote:

> From: Michal Krawczyk <mk@semihalf.com>
>
> When application tried to allocate 1024 descriptors, device was not
> initializing properly.
>
> This patch solves it by avoiding allocation of all descriptors in the ring
> in one attempt. At least one descriptor must remain unused in the HW ring.
>
> Fixes: 1173fca25af9 ("ena: add polling-mode driver")
>
> Signed-off-by: Michal Krawczyk <mk@semihalf.com>
> ---
>  drivers/net/ena/ena_ethdev.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
> index b5e6db6..2345bab 100644
> --- a/drivers/net/ena/ena_ethdev.c
> +++ b/drivers/net/ena/ena_ethdev.c
> @@ -919,7 +919,7 @@ static int ena_start(struct rte_eth_dev *dev)
>
>  static int ena_queue_restart(struct ena_ring *ring)
>  {
> -       int rc;
> +       int rc, bufs_num;
>
>         ena_assert_msg(ring->configured == 1,
>                        "Trying to restart unconfigured queue\n");
> @@ -930,8 +930,9 @@ static int ena_queue_restart(struct ena_ring *ring)
>         if (ring->type == ENA_RING_TYPE_TX)
>                 return 0;
>
> -       rc = ena_populate_rx_queue(ring, ring->ring_size);
> -       if ((unsigned int)rc != ring->ring_size) {
> +       bufs_num = ring->ring_size - 1;
> +       rc = ena_populate_rx_queue(ring, bufs_num);
> +       if (rc != bufs_num) {
>                 PMD_INIT_LOG(ERR, "Failed to populate rx ring !");
>                 return (-1);
>         }
> --
> 1.8.3.1
>
>
  

Patch

diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c
index b5e6db6..2345bab 100644
--- a/drivers/net/ena/ena_ethdev.c
+++ b/drivers/net/ena/ena_ethdev.c
@@ -919,7 +919,7 @@  static int ena_start(struct rte_eth_dev *dev)
 
 static int ena_queue_restart(struct ena_ring *ring)
 {
-	int rc;
+	int rc, bufs_num;
 
 	ena_assert_msg(ring->configured == 1,
 		       "Trying to restart unconfigured queue\n");
@@ -930,8 +930,9 @@  static int ena_queue_restart(struct ena_ring *ring)
 	if (ring->type == ENA_RING_TYPE_TX)
 		return 0;
 
-	rc = ena_populate_rx_queue(ring, ring->ring_size);
-	if ((unsigned int)rc != ring->ring_size) {
+	bufs_num = ring->ring_size - 1;
+	rc = ena_populate_rx_queue(ring, bufs_num);
+	if (rc != bufs_num) {
 		PMD_INIT_LOG(ERR, "Failed to populate rx ring !");
 		return (-1);
 	}