DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ouyang Changchun <changchun.ouyang@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 3/3] vhost: Removes dependency on REFCNT for zero copy
Date: Fri, 24 Oct 2014 16:10:09 +0800	[thread overview]
Message-ID: <1414138209-24431-4-git-send-email-changchun.ouyang@intel.com> (raw)
In-Reply-To: <1414138209-24431-1-git-send-email-changchun.ouyang@intel.com>

Vhost zero copy removes the dependency on macro REFCNT
by using EXTERNAL_MBUF flag in mbuf.ol_flags to indicate
it is an external buffer from guest.

Signed-off-by: Changchun Ouyang <changchun.ouyang@intel.com>
---
 examples/vhost/main.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index fa0ad0c..e3b1884 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -713,19 +713,6 @@ us_vhost_parse_args(int argc, char **argv)
 					return -1;
 				} else
 					zero_copy = ret;
-
-				if (zero_copy) {
-#ifdef RTE_MBUF_REFCNT
-					RTE_LOG(ERR, VHOST_CONFIG, "Before running "
-					"zero copy vhost APP, please "
-					"disable RTE_MBUF_REFCNT\n"
-					"in config file and then rebuild DPDK "
-					"core lib!\n"
-					"Otherwise please disable zero copy "
-					"flag in command line!\n");
-					return -1;
-#endif
-				}
 			}
 
 			/* Specify the descriptor number on RX. */
@@ -1453,6 +1440,7 @@ attach_rxmbuf_zcp(struct virtio_net *dev)
 	mbuf->buf_physaddr = phys_addr - RTE_PKTMBUF_HEADROOM;
 	mbuf->data_len = desc->len;
 	MBUF_HEADROOM_UINT32(mbuf) = (uint32_t)desc_idx;
+	mbuf->ol_flags |= EXTERNAL_MBUF;
 
 	LOG_DEBUG(VHOST_DATA,
 		"(%"PRIu64") in attach_rxmbuf_zcp: res base idx:%d, "
@@ -1489,6 +1477,8 @@ static inline void pktmbuf_detach_zcp(struct rte_mbuf *m)
 	m->data_off = buf_ofs;
 
 	m->data_len = 0;
+
+	m->ol_flags &= ~EXTERNAL_MBUF;
 }
 
 /*
@@ -1805,8 +1795,9 @@ virtio_tx_route_zcp(struct virtio_net *dev, struct rte_mbuf *m,
 		mbuf->data_off = m->data_off;
 		mbuf->buf_physaddr = m->buf_physaddr;
 		mbuf->buf_addr = m->buf_addr;
+		mbuf->ol_flags |= EXTERNAL_MBUF;
 	}
-	mbuf->ol_flags = PKT_TX_VLAN_PKT;
+	mbuf->ol_flags |= PKT_TX_VLAN_PKT;
 	mbuf->vlan_tci = vlan_tag;
 	mbuf->l2_len = sizeof(struct ether_hdr);
 	mbuf->l3_len = sizeof(struct ipv4_hdr);
-- 
1.8.4.2

  parent reply	other threads:[~2014-10-24  8:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-24  8:10 [dpdk-dev] [PATCH 0/3] Vhost app removes dependency of REFCNT Ouyang Changchun
2014-10-24  8:10 ` [dpdk-dev] [PATCH 1/3] mbuf: Use EXTERNAL_MBUF to indicate external buffer Ouyang Changchun
2014-10-24  8:10 ` [dpdk-dev] [PATCH 2/3] pmd: RX function need keep EXTERNAL_MBUF flag Ouyang Changchun
2014-10-24 10:46   ` Ananyev, Konstantin
2014-10-24 12:34     ` Bruce Richardson
2014-10-24 15:43       ` Bruce Richardson
2014-10-24 15:58         ` Ananyev, Konstantin
2014-10-25  2:08           ` Ouyang, Changchun
2014-10-24  8:10 ` Ouyang Changchun [this message]
2014-10-24  9:47 ` [dpdk-dev] [PATCH 0/3] Vhost app removes dependency of REFCNT Thomas Monjalon
2014-10-24 10:47   ` Bruce Richardson
2014-10-25  1:01   ` Ouyang, Changchun

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=1414138209-24431-4-git-send-email-changchun.ouyang@intel.com \
    --to=changchun.ouyang@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).