net/sfc: remove EvQ info array to simplify reconfigure
[dpdk.git] / drivers / net / sfc / sfc_rx.c
index 56e48ab..d8cd228 100644 (file)
@@ -95,17 +95,23 @@ sfc_efx_rx_qrefill(struct sfc_efx_rxq *rxq)
                return;
 
        bulks = free_space / RTE_DIM(objs);
+       /* refill_threshold guarantees that bulks is positive */
+       SFC_ASSERT(bulks > 0);
 
        id = added & rxq->ptr_mask;
-       while (bulks-- > 0) {
-               if (rte_mempool_get_bulk(rxq->refill_mb_pool, objs,
-                                        RTE_DIM(objs)) < 0) {
+       do {
+               if (unlikely(rte_mempool_get_bulk(rxq->refill_mb_pool, objs,
+                                                 RTE_DIM(objs)) < 0)) {
                        /*
                         * It is hardly a safe way to increment counter
                         * from different contexts, but all PMDs do it.
                         */
                        rxq->evq->sa->eth_dev->data->rx_mbuf_alloc_failed +=
                                RTE_DIM(objs);
+                       /* Return if we have posted nothing yet */
+                       if (added == rxq->added)
+                               return;
+                       /* Push posted */
                        break;
                }
 
@@ -128,13 +134,11 @@ sfc_efx_rx_qrefill(struct sfc_efx_rxq *rxq)
                efx_rx_qpost(rxq->common, addr, rxq->buf_size,
                             RTE_DIM(objs), rxq->completed, added);
                added += RTE_DIM(objs);
-       }
+       } while (--bulks > 0);
 
-       /* Push doorbell if something is posted */
-       if (rxq->added != added) {
-               rxq->added = added;
-               efx_rx_qpush(rxq->common, added, &rxq->pushed);
-       }
+       SFC_ASSERT(added != rxq->added);
+       rxq->added = added;
+       efx_rx_qpush(rxq->common, added, &rxq->pushed);
 }
 
 static uint64_t
@@ -278,8 +282,7 @@ sfc_efx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 
                if (scatter_pkt != NULL) {
                        if (rte_pktmbuf_chain(scatter_pkt, m) != 0) {
-                               rte_mempool_put(rxq->refill_mb_pool,
-                                               scatter_pkt);
+                               rte_pktmbuf_free(scatter_pkt);
                                goto discard;
                        }
                        /* The packet to deliver */
@@ -639,7 +642,7 @@ sfc_rx_qstart(struct sfc_adapter *sa, unsigned int sw_index)
 
        evq = rxq->evq;
 
-       rc = sfc_ev_qstart(sa, evq->evq_index);
+       rc = sfc_ev_qstart(evq, sfc_evq_index_by_rxq_sw_index(sa, sw_index));
        if (rc != 0)
                goto fail_ev_qstart;
 
@@ -677,7 +680,7 @@ fail_dp_qstart:
        sfc_rx_qflush(sa, sw_index);
 
 fail_rx_qcreate:
-       sfc_ev_qstop(sa, evq->evq_index);
+       sfc_ev_qstop(evq);
 
 fail_ev_qstart:
        return rc;
@@ -715,7 +718,7 @@ sfc_rx_qstop(struct sfc_adapter *sa, unsigned int sw_index)
 
        efx_rx_qdestroy(rxq->common);
 
-       sfc_ev_qstop(sa, rxq->evq->evq_index);
+       sfc_ev_qstop(rxq->evq);
 }
 
 static int
@@ -858,7 +861,6 @@ sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
        int rc;
        uint16_t buf_size;
        struct sfc_rxq_info *rxq_info;
-       unsigned int evq_index;
        struct sfc_evq *evq;
        struct sfc_rxq *rxq;
        struct sfc_dp_rx_qcreate_info info;
@@ -896,14 +898,11 @@ sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
                sa->eth_dev->data->dev_conf.rxmode.enable_scatter ?
                EFX_RXQ_TYPE_SCATTER : EFX_RXQ_TYPE_DEFAULT;
 
-       evq_index = sfc_evq_index_by_rxq_sw_index(sa, sw_index);
-
-       rc = sfc_ev_qinit(sa, evq_index, rxq_info->entries, socket_id);
+       rc = sfc_ev_qinit(sa, SFC_EVQ_TYPE_RX, sw_index,
+                         rxq_info->entries, socket_id, &evq);
        if (rc != 0)
                goto fail_ev_qinit;
 
-       evq = sa->evq_info[evq_index].evq;
-
        rc = ENOMEM;
        rxq = rte_zmalloc_socket("sfc-rxq", sizeof(*rxq), RTE_CACHE_LINE_SIZE,
                                 socket_id);
@@ -914,7 +913,8 @@ sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 
        rxq->evq = evq;
        rxq->hw_index = sw_index;
-       rxq->refill_threshold = rx_conf->rx_free_thresh;
+       rxq->refill_threshold =
+               RTE_MAX(rx_conf->rx_free_thresh, SFC_RX_REFILL_BULK);
        rxq->refill_mb_pool = mb_pool;
 
        rc = sfc_dma_alloc(sa, "rxq", sw_index, EFX_RXQ_SIZE(rxq_info->entries),
@@ -935,6 +935,11 @@ sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 #endif
 
        info.rxq_entries = rxq_info->entries;
+       info.rxq_hw_ring = rxq->mem.esm_base;
+       info.evq_entries = rxq_info->entries;
+       info.evq_hw_ring = evq->mem.esm_base;
+       info.hw_index = rxq->hw_index;
+       info.mem_bar = sa->mem_bar.esb_base;
 
        rc = sa->dp_rx->qcreate(sa->eth_dev->data->port_id, sw_index,
                                &SFC_DEV_TO_PCI(sa->eth_dev)->addr,
@@ -958,7 +963,7 @@ fail_dma_alloc:
        rte_free(rxq);
 
 fail_rxq_alloc:
-       sfc_ev_qfini(sa, evq_index);
+       sfc_ev_qfini(evq);
 
 fail_ev_qinit:
        rxq_info->entries = 0;
@@ -988,6 +993,10 @@ sfc_rx_qfini(struct sfc_adapter *sa, unsigned int sw_index)
        rxq_info->entries = 0;
 
        sfc_dma_free(sa, &rxq->mem);
+
+       sfc_ev_qfini(rxq->evq);
+       rxq->evq = NULL;
+
        rte_free(rxq);
 }