From: Tiwei Bie <tiwei.bie@intel.com>
To: dev@dpdk.org, jfreiman@redhat.com
Subject: [dpdk-dev] [RFC 3/6] net/virtio: optimize the tx path
Date: Tue, 18 Jul 2017 23:40:18 +0800 [thread overview]
Message-ID: <1500392421-76672-4-git-send-email-tiwei.bie@intel.com> (raw)
In-Reply-To: <1500392421-76672-1-git-send-email-tiwei.bie@intel.com>
Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
---
drivers/net/virtio/virtio_rxtx_1.1.c | 65 ++++++++++++++++--------------------
1 file changed, 28 insertions(+), 37 deletions(-)
diff --git a/drivers/net/virtio/virtio_rxtx_1.1.c b/drivers/net/virtio/virtio_rxtx_1.1.c
index 4602e6d..883a027 100644
--- a/drivers/net/virtio/virtio_rxtx_1.1.c
+++ b/drivers/net/virtio/virtio_rxtx_1.1.c
@@ -80,42 +80,6 @@ virtio_xmit_cleanup(struct virtqueue *vq)
}
}
-static inline void
-virtio_xmit(struct virtnet_tx *txvq, struct rte_mbuf *mbuf, int first_mbuf)
-{
- struct virtio_tx_region *txr = txvq->virtio_net_hdr_mz->addr;
- struct virtqueue *vq = txvq->vq;
- struct vring_desc_1_1 *desc = vq->vq_ring.desc_1_1;
- uint16_t idx;
- uint16_t head_idx = (vq->vq_avail_idx++) & (vq->vq_nentries - 1);
- struct vq_desc_extra *dxp;
-
- idx = head_idx;
- vq->vq_free_cnt -= mbuf->nb_segs + 1;
-
- dxp = &vq->vq_descx[idx];
- if (dxp->cookie != NULL)
- rte_pktmbuf_free(dxp->cookie);
- dxp->cookie = mbuf;
-
- desc[idx].addr = txvq->virtio_net_hdr_mem +
- RTE_PTR_DIFF(&txr[idx].tx_hdr, txr);
- desc[idx].len = vq->hw->vtnet_hdr_size;
- desc[idx].flags = VRING_DESC_F_NEXT;
- if (!first_mbuf)
- desc[idx].flags |= DESC_HW;
-
- do {
- idx = (vq->vq_avail_idx++) & (vq->vq_nentries - 1);
- desc[idx].addr = VIRTIO_MBUF_DATA_DMA_ADDR(mbuf, vq);
- desc[idx].len = mbuf->data_len;
- desc[idx].flags = DESC_HW | VRING_DESC_F_NEXT;
- } while ((mbuf = mbuf->next) != NULL);
-
- desc[idx].flags &= ~VRING_DESC_F_NEXT;
-
-}
-
uint16_t
virtio_xmit_pkts_1_1(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
{
@@ -123,6 +87,9 @@ virtio_xmit_pkts_1_1(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts
struct virtqueue *vq = txvq->vq;
uint16_t i;
uint16_t head_idx = vq->vq_avail_idx;
+ struct vring_desc_1_1 *desc = vq->vq_ring.desc_1_1;
+ uint16_t idx;
+ struct vq_desc_extra *dxp;
if (unlikely(nb_pkts < 1))
return nb_pkts;
@@ -134,6 +101,7 @@ virtio_xmit_pkts_1_1(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts
for (i = 0; i < nb_pkts; i++) {
struct rte_mbuf *txm = tx_pkts[i];
+ struct virtio_tx_region *txr = txvq->virtio_net_hdr_mz->addr;
if (unlikely(txm->nb_segs + 1 > vq->vq_free_cnt)) {
virtio_xmit_cleanup(vq);
@@ -145,8 +113,31 @@ virtio_xmit_pkts_1_1(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts
}
}
- virtio_xmit(txvq, txm, i == 0);
txvq->stats.bytes += txm->pkt_len;
+
+ vq->vq_free_cnt -= txm->nb_segs + 1;
+
+ idx = (vq->vq_avail_idx++) & (vq->vq_nentries - 1);
+ dxp = &vq->vq_descx[idx];
+ if (dxp->cookie != NULL)
+ rte_pktmbuf_free(dxp->cookie);
+ dxp->cookie = txm;
+
+ desc[idx].addr = txvq->virtio_net_hdr_mem +
+ RTE_PTR_DIFF(&txr[idx].tx_hdr, txr);
+ desc[idx].len = vq->hw->vtnet_hdr_size;
+ desc[idx].flags = VRING_DESC_F_NEXT;
+ if (i != 0)
+ desc[idx].flags |= DESC_HW;
+
+ do {
+ idx = (vq->vq_avail_idx++) & (vq->vq_nentries - 1);
+ desc[idx].addr = VIRTIO_MBUF_DATA_DMA_ADDR(txm, vq);
+ desc[idx].len = txm->data_len;
+ desc[idx].flags = DESC_HW | VRING_DESC_F_NEXT;
+ } while ((txm = txm->next) != NULL);
+
+ desc[idx].flags &= ~VRING_DESC_F_NEXT;
}
if (likely(i)) {
--
2.7.4
next prev parent reply other threads:[~2017-07-18 15:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-18 15:40 [dpdk-dev] [RFC 0/6] virtio1.1 prototype updates Tiwei Bie
2017-07-18 15:40 ` [dpdk-dev] [RFC 1/6] net/virtio: optimize the rx path Tiwei Bie
2017-07-18 15:40 ` [dpdk-dev] [RFC 2/6] vhost: optimize enqueue path Tiwei Bie
2017-07-18 15:40 ` Tiwei Bie [this message]
2017-07-18 15:40 ` [dpdk-dev] [RFC 4/6] net/virtio: revert the changes in 18dc1b1ac Tiwei Bie
2017-07-18 15:40 ` [dpdk-dev] [RFC 5/6] vhost: minor refinement Tiwei Bie
2017-07-18 15:40 ` [dpdk-dev] [RFC 6/6] virtio1.1: introduce the DESC_WB flag Tiwei Bie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1500392421-76672-4-git-send-email-tiwei.bie@intel.com \
--to=tiwei.bie@intel.com \
--cc=dev@dpdk.org \
--cc=jfreiman@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).