net/enic: use mbuf pointer array for inflight Tx packets
authorHyong Youb Kim <hyonkim@cisco.com>
Fri, 29 Jun 2018 09:29:37 +0000 (02:29 -0700)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 2 Jul 2018 23:54:19 +0000 (01:54 +0200)
WQ is currently using vnic_wq_buf to store mbuf pointers for Tx
packets. But, it contains an unused mempool pointer and mbuf is
unnecessarily cast to void pointer. Remove vnic_wq_buf entirely and
use an mbuf pointer array instead.

Signed-off-by: Hyong Youb Kim <hyonkim@cisco.com>
Reviewed-by: John Daley <johndale@cisco.com>
drivers/net/enic/base/vnic_wq.c
drivers/net/enic/base/vnic_wq.h
drivers/net/enic/enic_main.c
drivers/net/enic/enic_rxtx.c

index d61c4c6..a4c08a7 100644 (file)
@@ -32,8 +32,8 @@ static int vnic_wq_alloc_bufs(struct vnic_wq *wq)
 {
        unsigned int count = wq->ring.desc_count;
        /* Allocate the mbuf ring */
-       wq->bufs = (struct vnic_wq_buf *)rte_zmalloc_socket("wq->bufs",
-                   sizeof(struct vnic_wq_buf) * count,
+       wq->bufs = (struct rte_mbuf **)rte_zmalloc_socket("wq->bufs",
+                   sizeof(struct rte_mbuf *) * count,
                    RTE_CACHE_LINE_SIZE, wq->socket_id);
        wq->head_idx = 0;
        wq->tail_idx = 0;
@@ -145,9 +145,9 @@ int vnic_wq_disable(struct vnic_wq *wq)
 }
 
 void vnic_wq_clean(struct vnic_wq *wq,
-                  void (*buf_clean)(struct vnic_wq_buf *buf))
+                  void (*buf_clean)(struct rte_mbuf **buf))
 {
-       struct vnic_wq_buf *buf;
+       struct rte_mbuf **buf;
        unsigned int  to_clean = wq->tail_idx;
 
        buf = &wq->bufs[to_clean];
index 0135bff..86ac10e 100644 (file)
@@ -36,19 +36,13 @@ struct vnic_wq_ctrl {
        u32 pad9;
 };
 
-/* 16 bytes */
-struct vnic_wq_buf {
-       struct rte_mempool *pool;
-       void *mb;
-};
-
 struct vnic_wq {
        unsigned int index;
        uint64_t tx_offload_notsup_mask;
        struct vnic_dev *vdev;
        struct vnic_wq_ctrl __iomem *ctrl;              /* memory-mapped */
        struct vnic_dev_ring ring;
-       struct vnic_wq_buf *bufs;
+       struct rte_mbuf **bufs;
        unsigned int head_idx;
        unsigned int tail_idx;
        unsigned int socket_id;
@@ -164,5 +158,5 @@ unsigned int vnic_wq_error_status(struct vnic_wq *wq);
 void vnic_wq_enable(struct vnic_wq *wq);
 int vnic_wq_disable(struct vnic_wq *wq);
 void vnic_wq_clean(struct vnic_wq *wq,
-                  void (*buf_clean)(struct vnic_wq_buf *buf));
+                  void (*buf_clean)(struct rte_mbuf **buf));
 #endif /* _VNIC_WQ_H_ */
index e202569..c03ec24 100644 (file)
@@ -69,12 +69,12 @@ enic_rxmbuf_queue_release(__rte_unused struct enic *enic, struct vnic_rq *rq)
        }
 }
 
-static void enic_free_wq_buf(struct vnic_wq_buf *buf)
+static void enic_free_wq_buf(struct rte_mbuf **buf)
 {
-       struct rte_mbuf *mbuf = (struct rte_mbuf *)buf->mb;
+       struct rte_mbuf *mbuf = *buf;
 
        rte_pktmbuf_free_seg(mbuf);
-       buf->mb = NULL;
+       *buf = NULL;
 }
 
 static void enic_log_q_error(struct enic *enic)
index bbb0444..549288c 100644 (file)
@@ -473,7 +473,7 @@ enic_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 
 static inline void enic_free_wq_bufs(struct vnic_wq *wq, u16 completed_index)
 {
-       struct vnic_wq_buf *buf;
+       struct rte_mbuf *buf;
        struct rte_mbuf *m, *free[ENIC_MAX_WQ_DESCS];
        unsigned int nb_to_free, nb_free = 0, i;
        struct rte_mempool *pool;
@@ -483,13 +483,10 @@ static inline void enic_free_wq_bufs(struct vnic_wq *wq, u16 completed_index)
        nb_to_free = enic_ring_sub(desc_count, wq->tail_idx, completed_index)
                                   + 1;
        tail_idx = wq->tail_idx;
-       buf = &wq->bufs[tail_idx];
-       pool = ((struct rte_mbuf *)buf->mb)->pool;
+       pool = wq->bufs[tail_idx]->pool;
        for (i = 0; i < nb_to_free; i++) {
-               buf = &wq->bufs[tail_idx];
-               m = rte_pktmbuf_prefree_seg((struct rte_mbuf *)(buf->mb));
-               buf->mb = NULL;
-
+               buf = wq->bufs[tail_idx];
+               m = rte_pktmbuf_prefree_seg(buf);
                if (unlikely(m == NULL)) {
                        tail_idx = enic_ring_incr(desc_count, tail_idx);
                        continue;
@@ -574,7 +571,6 @@ uint16_t enic_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
        uint64_t ol_flags_mask;
        unsigned int wq_desc_avail;
        int head_idx;
-       struct vnic_wq_buf *buf;
        unsigned int desc_count;
        struct wq_enet_desc *descs, *desc_p, desc_tmp;
        uint16_t mss;
@@ -669,8 +665,7 @@ uint16_t enic_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
                                 vlan_id, 0);
 
                *desc_p = desc_tmp;
-               buf = &wq->bufs[head_idx];
-               buf->mb = (void *)tx_pkt;
+               wq->bufs[head_idx] = tx_pkt;
                head_idx = enic_ring_incr(desc_count, head_idx);
                wq_desc_avail--;
 
@@ -691,8 +686,7 @@ uint16_t enic_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
                                                 0);
 
                                *desc_p = desc_tmp;
-                               buf = &wq->bufs[head_idx];
-                               buf->mb = (void *)tx_pkt;
+                               wq->bufs[head_idx] = tx_pkt;
                                head_idx = enic_ring_incr(desc_count, head_idx);
                                wq_desc_avail--;
                        }