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 at 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

Reply via email to