From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 8BFD07E75 for ; Fri, 24 Oct 2014 10:02:11 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 24 Oct 2014 01:10:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,779,1406617200"; d="scan'208";a="619683184" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga002.fm.intel.com with ESMTP; 24 Oct 2014 01:10:22 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id s9O8AKqM004329; Fri, 24 Oct 2014 16:10:20 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id s9O8AHoU024486; Fri, 24 Oct 2014 16:10:20 +0800 Received: (from couyang@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id s9O8AHsV024482; Fri, 24 Oct 2014 16:10:17 +0800 From: Ouyang Changchun To: dev@dpdk.org Date: Fri, 24 Oct 2014 16:10:09 +0800 Message-Id: <1414138209-24431-4-git-send-email-changchun.ouyang@intel.com> X-Mailer: git-send-email 1.7.12.2 In-Reply-To: <1414138209-24431-1-git-send-email-changchun.ouyang@intel.com> References: <1414138209-24431-1-git-send-email-changchun.ouyang@intel.com> Subject: [dpdk-dev] [PATCH 3/3] vhost: Removes dependency on REFCNT for zero copy X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Oct 2014 08:02:12 -0000 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 --- 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