virtio: optimize Tx enqueue
authorStephen Hemminger <stephen@networkplumber.org>
Fri, 4 Mar 2016 18:19:21 +0000 (10:19 -0800)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Wed, 16 Mar 2016 18:05:35 +0000 (19:05 +0100)
All the error checks in virtqueue_enqueue_xmit are already done
by the caller. Therefore they can be removed to improve performance.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Huawei Xie <huawei.xie@intel.com>
drivers/net/virtio/virtio_rxtx.c

index 69f4423..b4017be 100644 (file)
@@ -208,7 +208,7 @@ virtqueue_enqueue_recv_refill(struct virtqueue *vq, struct rte_mbuf *cookie)
        return 0;
 }
 
-static int
+static inline void
 virtqueue_enqueue_xmit(struct virtqueue *txvq, struct rte_mbuf *cookie,
                       uint16_t needed, int use_indirect, int can_push)
 {
@@ -219,14 +219,7 @@ virtqueue_enqueue_xmit(struct virtqueue *txvq, struct rte_mbuf *cookie,
        uint16_t head_size = txvq->hw->vtnet_hdr_size;
        unsigned long offs;
 
-       if (unlikely(txvq->vq_free_cnt == 0))
-               return -ENOSPC;
-       if (unlikely(txvq->vq_free_cnt < needed))
-               return -EMSGSIZE;
        head_idx = txvq->vq_desc_head_idx;
-       if (unlikely(head_idx >= txvq->vq_nentries))
-               return -EFAULT;
-
        idx = head_idx;
        dxp = &txvq->vq_descx[idx];
        dxp->cookie = (void *)cookie;
@@ -288,8 +281,6 @@ virtqueue_enqueue_xmit(struct virtqueue *txvq, struct rte_mbuf *cookie,
                txvq->vq_desc_tail_idx = idx;
        txvq->vq_free_cnt = (uint16_t)(txvq->vq_free_cnt - needed);
        vq_update_avail_ring(txvq, head_idx);
-
-       return 0;
 }
 
 static inline struct rte_mbuf *
@@ -934,17 +925,7 @@ virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
                }
 
                /* Enqueue Packet buffers */
-               error = virtqueue_enqueue_xmit(txvq, txm, slots,
-                                              use_indirect, can_push);
-               if (unlikely(error)) {
-                       if (error == ENOSPC)
-                               PMD_TX_LOG(ERR, "virtqueue_enqueue Free count = 0");
-                       else if (error == EMSGSIZE)
-                               PMD_TX_LOG(ERR, "virtqueue_enqueue Free count < 1");
-                       else
-                               PMD_TX_LOG(ERR, "virtqueue_enqueue error: %d", error);
-                       break;
-               }
+               virtqueue_enqueue_xmit(txvq, txm, slots, use_indirect, can_push);
 
                txvq->bytes += txm->pkt_len;
                virtio_update_packet_stats(txvq, txm);