net/ena: fix Rx descriptors allocation
authorMichal Krawczyk <mk@semihalf.com>
Mon, 10 Apr 2017 14:28:08 +0000 (16:28 +0200)
committerFerruh Yigit <ferruh.yigit@intel.com>
Wed, 19 Apr 2017 13:37:37 +0000 (15:37 +0200)
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")
Cc: stable@dpdk.org
Signed-off-by: Michal Krawczyk <mk@semihalf.com>
Reviewed-by: Jakub Palider <jpalider@gmail.com>
Acked-by: Jan Medala <jan.medala@outlook.com>
drivers/net/ena/ena_ethdev.c

index f5f748f..6367ad4 100644 (file)
@@ -920,7 +920,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");
@@ -931,8 +931,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);
        }
@@ -1144,7 +1145,7 @@ static int ena_populate_rx_queue(struct ena_ring *rxq, unsigned int count)
                return 0;
 
        in_use = rxq->next_to_use - rxq->next_to_clean;
-       ena_assert_msg(((in_use + count) <= ring_size), "bad ring state");
+       ena_assert_msg(((in_use + count) < ring_size), "bad ring state");
 
        count = RTE_MIN(count,
                        (uint16_t)(ring_size - (next_to_use & ring_mask)));
@@ -1575,6 +1576,7 @@ static uint16_t eth_ena_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
                recv_idx++;
        }
 
+       desc_in_use += 1;
        /* Burst refill to save doorbells, memory barriers, const interval */
        if (ring_size - desc_in_use > ENA_RING_DESCS_RATIO(ring_size))
                ena_populate_rx_queue(rx_ring, ring_size - desc_in_use);