DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jijiang Liu <jijiang.liu@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 4/8] driver/virtio:enqueue TSO offload
Date: Thu, 17 Sep 2015 01:10:34 +0800	[thread overview]
Message-ID: <1442423438-10578-5-git-send-email-jijiang.liu@intel.com> (raw)
In-Reply-To: <1442423438-10578-1-git-send-email-jijiang.liu@intel.com>

Enqueue host TSO4/6 offload in guest side.

Signed-off-by: Jijiang Liu <jijiang.liu@intel.com>
---
 drivers/net/virtio/virtio_rxtx.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index c5b53bb..68b293e 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -198,6 +198,31 @@ virtqueue_enqueue_recv_refill(struct virtqueue *vq, struct rte_mbuf *cookie)
 	return 0;
 }
 
+static int
+virtqueue_enqueue_offload(struct virtqueue *txvq, struct rte_mbuf *m,
+			uint16_t idx, uint16_t hdr_sz)
+{
+	struct virtio_net_hdr *hdr = (struct virtio_net_hdr *)(uintptr_t)
+				(txvq->virtio_net_hdr_addr + idx * hdr_sz);
+
+	if (m->tso_segsz != 0 && m->ol_flags & PKT_TX_TCP_SEG) {
+		if (m->ol_flags & PKT_TX_IPV4) {
+			if (!vtpci_with_feature(txvq->hw,
+				VIRTIO_NET_F_HOST_TSO4))
+				return -1;
+			hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
+		} else if (m->ol_flags & PKT_TX_IPV6) {
+			if (!vtpci_with_feature(txvq->hw,
+				VIRTIO_NET_F_HOST_TSO6))
+				return -1;
+			hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
+		}
+		hdr->gso_size = m->tso_segsz;
+		hdr->hdr_len = m->l2_len + m->l3_len + m->l4_len;
+	}
+	return 0;
+}
+
 static int
 virtqueue_enqueue_xmit(struct virtqueue *txvq, struct rte_mbuf *cookie)
 {
@@ -221,6 +246,9 @@ virtqueue_enqueue_xmit(struct virtqueue *txvq, struct rte_mbuf *cookie)
 	dxp->cookie = (void *)cookie;
 	dxp->ndescs = needed;
 
+	if (virtqueue_enqueue_offload(txvq, cookie, idx, head_size) < 0)
+		return -EPERM;
+
 	start_dp = txvq->vq_ring.desc;
 	start_dp[idx].addr =
 		txvq->virtio_net_hdr_mem + idx * head_size;
-- 
1.7.7.6

  parent reply	other threads:[~2015-09-16 17:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-16 17:10 [dpdk-dev] [PATCH 0/8] add vhost TSO capability Jijiang Liu
2015-09-16 17:10 ` [dpdk-dev] [PATCH 1/8] driver/virtio:add vhost TSO support capability Jijiang Liu
2015-09-16 17:10 ` [dpdk-dev] [PATCH 2/8] driver/virtio:add virtual addr for virtio net header Jijiang Liu
2015-09-16 17:10 ` [dpdk-dev] [PATCH 3/8] driver/virtio: record virtual address of " Jijiang Liu
2015-09-16 17:10 ` Jijiang Liu [this message]
2015-09-16 17:10 ` [dpdk-dev] [PATCH 5/8] lib/librte_vhost:dequeue vhost TSO offload Jijiang Liu
2015-09-16 17:10 ` [dpdk-dev] [PATCH 6/8] lib/librte_vhost:extend supported vhost features Jijiang Liu
2015-09-16 17:10 ` [dpdk-dev] [PATCH 7/8] examples/vhost:support TSO in vhost sample Jijiang Liu
2015-09-16 17:10 ` [dpdk-dev] [PATCH 8/8] app/testpmd: modify the mac of csum forwarding Jijiang Liu
2015-10-26  7:09 ` [dpdk-dev] [PATCH 0/8] add vhost TSO capability Tan, Jianfeng

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=1442423438-10578-5-git-send-email-jijiang.liu@intel.com \
    --to=jijiang.liu@intel.com \
    --cc=dev@dpdk.org \
    /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).