fm10k: release mbuf for vector Rx
authorChen Jing D(Mark) <jing.d.chen@intel.com>
Fri, 30 Oct 2015 08:03:01 +0000 (16:03 +0800)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Mon, 2 Nov 2015 09:00:02 +0000 (10:00 +0100)
Since Vector RX use different variables to trace RX HW ring, it
leads to need different func to release mbuf properly.

Signed-off-by: Chen Jing D(Mark) <jing.d.chen@intel.com>
Acked-by: Cunming Liang <cunming.liang@intel.com>
drivers/net/fm10k/fm10k.h
drivers/net/fm10k/fm10k_ethdev.c
drivers/net/fm10k/fm10k_rxtx_vec.c

index 71f11cf..adcd044 100644 (file)
@@ -334,6 +334,7 @@ uint16_t fm10k_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 
 int fm10k_rxq_vec_setup(struct fm10k_rx_queue *rxq);
 int fm10k_rx_vec_condition_check(struct rte_eth_dev *);
+void fm10k_rx_queue_release_mbufs_vec(struct fm10k_rx_queue *rxq);
 uint16_t fm10k_recv_pkts_vec(void *, struct rte_mbuf **, uint16_t);
 uint16_t fm10k_recv_scattered_pkts_vec(void *, struct rte_mbuf **,
                                        uint16_t);
index c99f577..247edd5 100644 (file)
@@ -143,6 +143,12 @@ rx_queue_clean(struct fm10k_rx_queue *q)
        for (i = 0; i < q->nb_desc; ++i)
                q->hw_ring[i] = zero;
 
+       /* vPMD driver has a different way of releasing mbufs. */
+       if (q->rx_using_sse) {
+               fm10k_rx_queue_release_mbufs_vec(q);
+               return;
+       }
+
        /* free software buffers */
        for (i = 0; i < q->nb_desc; ++i) {
                if (q->sw_ring[i]) {
index ffd022a..4d90d6a 100644 (file)
@@ -321,6 +321,24 @@ fm10k_rxq_rearm(struct fm10k_rx_queue *rxq)
        FM10K_PCI_REG_WRITE(rxq->tail_ptr, rx_id);
 }
 
+void __attribute__((cold))
+fm10k_rx_queue_release_mbufs_vec(struct fm10k_rx_queue *rxq)
+{
+       const unsigned mask = rxq->nb_desc - 1;
+       unsigned i;
+
+       if (rxq->sw_ring == NULL || rxq->rxrearm_nb >= rxq->nb_desc)
+               return;
+
+       /* free all mbufs that are valid in the ring */
+       for (i = rxq->next_dd; i != rxq->rxrearm_start; i = (i + 1) & mask)
+               rte_pktmbuf_free_seg(rxq->sw_ring[i]);
+       rxq->rxrearm_nb = rxq->nb_desc;
+
+       /* set all entries to NULL */
+       memset(rxq->sw_ring, 0, sizeof(rxq->sw_ring[0]) * rxq->nb_desc);
+}
+
 static inline uint16_t
 fm10k_recv_raw_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
                uint16_t nb_pkts, uint8_t *split_packet)