DPDK patches and discussions
 help / color / mirror / Atom feed
From: Huawei Xie <huawei.xie@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v5 10/11] examples/vhost: merge oliver's mbuf changes to vhost example
Date: Fri, 26 Sep 2014 17:45:57 +0800	[thread overview]
Message-ID: <1411724758-27488-11-git-send-email-huawei.xie@intel.com> (raw)
In-Reply-To: <1411724758-27488-1-git-send-email-huawei.xie@intel.com>

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 <huawei.xie@intel.com>
---
 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

  parent reply	other threads:[~2014-09-26  9:40 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-26  9:45 [dpdk-dev] [PATCH v5 00/11] user space vhost library and " Huawei Xie
2014-09-26  9:45 ` [dpdk-dev] [PATCH v5 01/11] lib/librte_vhost: move src files in vhost example to vhost lib directory Huawei Xie
2014-09-29 19:41   ` Thomas Monjalon
2014-09-30  2:07     ` Xie, Huawei
2014-09-30  4:35       ` Thomas Monjalon
2014-09-26  9:45 ` [dpdk-dev] [PATCH v5 02/11] lib/librte_vhost: refactor vhost lib for subsequent transform Huawei Xie
2014-09-29 19:55   ` Thomas Monjalon
2014-09-29 20:00     ` Thomas Monjalon
2014-09-26  9:45 ` [dpdk-dev] [PATCH v5 03/11] lib/librte_vhost: vhost lib transform Huawei Xie
2014-09-29 19:51   ` Thomas Monjalon
2014-09-26  9:45 ` [dpdk-dev] [PATCH v5 04/11] lib/librte_vhost: merge vhost merge-able rx. merge vhost tx fix Huawei Xie
2014-09-26  9:45 ` [dpdk-dev] [PATCH v5 05/11] lib/librte_vhost: merge Oliver's mbuf change Huawei Xie
2014-09-29 19:44   ` Thomas Monjalon
     [not found]     ` <C37D651A908B024F974696C65296B57B0F2AF2C0@SHSMSX101.ccr.corp.intel.com>
2014-09-30  3:41       ` Ouyang, Changchun
2014-09-30  4:46       ` Thomas Monjalon
2014-09-30  6:43         ` Xie, Huawei
2014-09-30  8:06           ` Thomas Monjalon
2014-09-26  9:45 ` [dpdk-dev] [PATCH v5 06/11] lib/librte_vhost: fixes serious coding style issues Huawei Xie
2014-09-26  9:45 ` [dpdk-dev] [PATCH v5 07/11] lib/librte_vhost: add vhost support in DPDK makefile Huawei Xie
2014-09-26  9:45 ` [dpdk-dev] [PATCH v5 08/11] examples/vhost: copy old vhost example src file Huawei Xie
2014-09-26  9:45 ` [dpdk-dev] [PATCH v5 09/11] examples/vhost: vhost example based on vhost lib API Huawei Xie
2014-09-26  9:45 ` Huawei Xie [this message]
2014-09-26  9:45 ` [dpdk-dev] [PATCH v5 11/11] examples/vhost: add vhost example Makefile Huawei Xie

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=1411724758-27488-11-git-send-email-huawei.xie@intel.com \
    --to=huawei.xie@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).