From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 2DE937E62 for ; Fri, 26 Sep 2014 11:40:43 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP; 26 Sep 2014 02:44:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,603,1406617200"; d="scan'208";a="609002718" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga002.jf.intel.com with ESMTP; 26 Sep 2014 02:46:58 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id s8Q9kuJG007107; Fri, 26 Sep 2014 17:46:56 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id s8Q9ksox027593; Fri, 26 Sep 2014 17:46:56 +0800 Received: (from hxie5@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id s8Q9ksjg027589; Fri, 26 Sep 2014 17:46:54 +0800 From: Huawei Xie To: dev@dpdk.org Date: Fri, 26 Sep 2014 17:45:57 +0800 Message-Id: <1411724758-27488-11-git-send-email-huawei.xie@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1411724758-27488-1-git-send-email-huawei.xie@intel.com> References: <1411724758-27488-1-git-send-email-huawei.xie@intel.com> Subject: [dpdk-dev] [PATCH v5 10/11] examples/vhost: merge oliver's mbuf changes to vhost example 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, 26 Sep 2014 09:40:48 -0000 The mbuf changes include: 1. flattened structure vlan_macip 2. removed rte_pktmbuf structure. 3. mbuf data pointer replaced by an offset Other changes include: 1. fix sg mbuf xmit in virtio_tx_route 2. rename RTE_MBUF_SCATTER_GATHER to RTE_MBUF_REFCNT 3. add one TODO and FIXME Signed-off-by: Huawei Xie --- examples/vhost/main.c | 57 ++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/examples/vhost/main.c b/examples/vhost/main.c index 3834af4..6569188 100644 --- a/examples/vhost/main.c +++ b/examples/vhost/main.c @@ -716,10 +716,10 @@ us_vhost_parse_args(int argc, char **argv) zero_copy = ret; if (zero_copy) { -#ifdef RTE_MBUF_SCATTER_GATHER +#ifdef RTE_MBUF_REFCNT RTE_LOG(ERR, VHOST_CONFIG, "Before running " "zero copy vhost APP, please " - "disable RTE_MBUF_SCATTER_GATHER\n" + "disable RTE_MBUF_REFCNT\n" "in config file and then rebuild DPDK " "core lib!\n" "Otherwise please disable zero copy " @@ -906,7 +906,7 @@ link_vmdq(struct vhost_dev *vdev, struct rte_mbuf *m) int i, ret; /* Learn MAC address of guest device from packet */ - pkt_hdr = (struct ether_hdr *)m->pkt.data; + pkt_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *); dev_ll = ll_root_used; @@ -995,7 +995,7 @@ virtio_tx_local(struct vhost_dev *vdev, struct rte_mbuf *m) struct virtio_net *dev = vdev->dev; struct virtio_net *tdev; /* destination virito device */ - pkt_hdr = (struct ether_hdr *)m->pkt.data; + pkt_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *); /*get the used devices list*/ dev_ll = ll_root_used; @@ -1052,7 +1052,7 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, struct rte_mempool * unsigned len, ret, offset = 0; const uint16_t lcore_id = rte_lcore_id(); struct virtio_net_data_ll *dev_ll = ll_root_used; - struct ether_hdr *pkt_hdr = (struct ether_hdr *)m->pkt.data; + struct ether_hdr *pkt_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *); struct virtio_net *dev = vdev->dev; /*heck if destination is local VM*/ @@ -1104,8 +1104,8 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, struct rte_mempool * m->ol_flags = PKT_TX_VLAN_PKT; /*FIXME: offset*/ - m->pkt.data_len += offset; - m->pkt.vlan_macip.f.vlan_tci = vlan_tag; + m->data_len += offset; + m->vlan_tci = vlan_tag; tx_q->m_table[len] = m; len++; @@ -1449,9 +1449,9 @@ attach_rxmbuf_zcp(struct virtio_net *dev) } mbuf->buf_addr = (void *)(uintptr_t)(buff_addr - RTE_PKTMBUF_HEADROOM); - mbuf->pkt.data = (void *)(uintptr_t)(buff_addr); + mbuf->data_off = RTE_PKTMBUF_HEADROOM; mbuf->buf_physaddr = phys_addr - RTE_PKTMBUF_HEADROOM; - mbuf->pkt.data_len = desc->len; + mbuf->data_len = desc->len; MBUF_HEADROOM_UINT32(mbuf) = (uint32_t)desc_idx; LOG_DEBUG(VHOST_DATA, @@ -1486,9 +1486,9 @@ static inline void pktmbuf_detach_zcp(struct rte_mbuf *m) buf_ofs = (RTE_PKTMBUF_HEADROOM <= m->buf_len) ? RTE_PKTMBUF_HEADROOM : m->buf_len; - m->pkt.data = (char *) m->buf_addr + buf_ofs; + m->data_off = buf_ofs; - m->pkt.data_len = 0; + m->data_len = 0; } /* @@ -1720,7 +1720,7 @@ virtio_tx_route_zcp(struct virtio_net *dev, struct rte_mbuf *m, unsigned len, ret, offset = 0; struct vpool *vpool; struct virtio_net_data_ll *dev_ll = ll_root_used; - struct ether_hdr *pkt_hdr = (struct ether_hdr *)m->pkt.data; + struct ether_hdr *pkt_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *); uint16_t vlan_tag = (uint16_t)vlan_tags[(uint16_t)dev->device_fh]; uint16_t vmdq_rx_q = ((struct vhost_dev *)dev->priv)->vmdq_rx_q; @@ -1792,24 +1792,25 @@ virtio_tx_route_zcp(struct virtio_net *dev, struct rte_mbuf *m, } } - mbuf->pkt.nb_segs = m->pkt.nb_segs; - mbuf->pkt.next = m->pkt.next; - mbuf->pkt.data_len = m->pkt.data_len + offset; - mbuf->pkt.pkt_len = mbuf->pkt.data_len; + mbuf->nb_segs = m->nb_segs; + mbuf->next = m->next; + mbuf->data_len = m->data_len + offset; + mbuf->pkt_len = mbuf->data_len; if (unlikely(need_copy)) { /* Copy the packet contents to the mbuf. */ - rte_memcpy((void *)((uint8_t *)mbuf->pkt.data), - (const void *) ((uint8_t *)m->pkt.data), - m->pkt.data_len); + rte_memcpy(rte_pktmbuf_mtod(mbuf, void *), + rte_pktmbuf_mtod(m, const void *), + m->data_len); } else { - mbuf->pkt.data = m->pkt.data; + /* TODO verification */ + mbuf->data_off = m->data_off; mbuf->buf_physaddr = m->buf_physaddr; mbuf->buf_addr = m->buf_addr; } mbuf->ol_flags = PKT_TX_VLAN_PKT; - mbuf->pkt.vlan_macip.f.vlan_tci = vlan_tag; - mbuf->pkt.vlan_macip.f.l2_len = sizeof(struct ether_hdr); - mbuf->pkt.vlan_macip.f.l3_len = sizeof(struct ipv4_hdr); + mbuf->vlan_tci = vlan_tag; + mbuf->l2_len = sizeof(struct ether_hdr); + mbuf->l3_len = sizeof(struct ipv4_hdr); MBUF_HEADROOM_UINT32(mbuf) = (uint32_t)desc_idx; tx_q->m_table[len] = mbuf; @@ -1934,11 +1935,11 @@ virtio_dev_tx_zcp(struct virtio_net *dev) * Setup dummy mbuf. This is copied to a real mbuf if * transmitted out the physical port. */ - m.pkt.data_len = desc->len; - m.pkt.nb_segs = 1; - m.pkt.next = NULL; - m.pkt.data = (void *)(uintptr_t)buff_addr; - m.buf_addr = m.pkt.data; + m.data_len = desc->len; + m.nb_segs = 1; + m.next = NULL; + m.data_off = 0; + m.buf_addr = (void *)(uintptr_t)buff_addr; m.buf_physaddr = phys_addr; /* -- 1.8.1.4