DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [RFC PATCH 00/11] net/virtio: packed ring layout
@ 2017-05-05 13:57 Jens Freimann
  2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 01/11] net/virtio: vring init for 1.1 Jens Freimann
                   ` (11 more replies)
  0 siblings, 12 replies; 18+ messages in thread
From: Jens Freimann @ 2017-05-05 13:57 UTC (permalink / raw)
  To: yuanhan.liu; +Cc: dev

Hi Yuanhan,

I rebased your patches on next-virtio/for-testing to current master,
made sure every patch compiles and still works. 
I'm implementing the receive path now to eventually get some benchmark
results for that as well (Patches not included yet)

Any comments to the existing patches are welcome, I will change them accordingly.

regards,
Jens  



Yuanhan Liu (11):
  net/virtio: vring init for 1.1
  net/virtio: implement 1.1 guest Tx
  net/virtio-user: add option to enable 1.1
  vhost: enable 1.1 for testing
  vhost: set desc addr for 1.1
  vhost: implement virtio 1.1 dequeue path
  vhost: mark desc being used
  xxx: batch the desc_hw update?
  xxx: virtio: remove overheads
  vhost: prefetch desc
  add virtio 1.1 test guide

 README-virtio-1.1                                |  50 ++++++
 drivers/net/virtio/Makefile                      |   1 +
 drivers/net/virtio/virtio-1.1.h                  |  19 +++
 drivers/net/virtio/virtio_ethdev.c               |  44 +++--
 drivers/net/virtio/virtio_ethdev.h               |   3 +
 drivers/net/virtio/virtio_pci.h                  |   7 +
 drivers/net/virtio/virtio_ring.h                 |  15 +-
 drivers/net/virtio/virtio_rxtx.c                 | 191 ++-------------------
 drivers/net/virtio/virtio_rxtx_1.1.c             | 161 ++++++++++++++++++
 drivers/net/virtio/virtio_user/virtio_user_dev.c |   9 +-
 drivers/net/virtio/virtio_user/virtio_user_dev.h |   3 +-
 drivers/net/virtio/virtio_user_ethdev.c          |  14 +-
 drivers/net/virtio/virtqueue.h                   |  10 ++
 lib/librte_vhost/vhost.h                         |   5 +
 lib/librte_vhost/vhost_user.c                    |   1 +
 lib/librte_vhost/virtio-1.1.h                    |  23 +++
 lib/librte_vhost/virtio_net.c                    | 208 +++++++++++++++++++++++
 17 files changed, 567 insertions(+), 197 deletions(-)
 create mode 100644 README-virtio-1.1
 create mode 100644 drivers/net/virtio/virtio-1.1.h
 create mode 100644 drivers/net/virtio/virtio_rxtx_1.1.c
 create mode 100644 lib/librte_vhost/virtio-1.1.h

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [dpdk-dev] [RFC PATCH 01/11] net/virtio: vring init for 1.1
  2017-05-05 13:57 [dpdk-dev] [RFC PATCH 00/11] net/virtio: packed ring layout Jens Freimann
@ 2017-05-05 13:57 ` Jens Freimann
  2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 02/11] net/virtio: implement 1.1 guest Tx Jens Freimann
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Jens Freimann @ 2017-05-05 13:57 UTC (permalink / raw)
  To: yuanhan.liu; +Cc: dev

From: Yuanhan Liu <yuanhan.liu@linux.intel.com>

Add and initialize descriptor data structures.

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
[rename desc_1_1 to vring_desc_1_1, refactor desc init code]
Signed-off-by: Jens Freimann <jfreiman@redhat.com>
---
 drivers/net/virtio/virtio-1.1.h    | 19 +++++++++++++++++++
 drivers/net/virtio/virtio_ethdev.c | 22 ++++++++++++----------
 drivers/net/virtio/virtio_pci.h    |  7 +++++++
 drivers/net/virtio/virtio_ring.h   | 15 +++++++++++++--
 drivers/net/virtio/virtqueue.h     | 10 ++++++++++
 5 files changed, 61 insertions(+), 12 deletions(-)
 create mode 100644 drivers/net/virtio/virtio-1.1.h

diff --git a/drivers/net/virtio/virtio-1.1.h b/drivers/net/virtio/virtio-1.1.h
new file mode 100644
index 0000000..48cbb18
--- /dev/null
+++ b/drivers/net/virtio/virtio-1.1.h
@@ -0,0 +1,19 @@
+#ifndef __VIRTIO_1_1_H
+#define __VIRTIO_1_1_H
+
+#define VRING_DESC_F_NEXT	1
+#define VRING_DESC_F_WRITE	2
+#define VRING_DESC_F_INDIRECT	4
+
+#define BATCH_NOT_FIRST 0x0010
+#define BATCH_NOT_LAST  0x0020
+#define DESC_HW		0x0080
+
+struct vring_desc_1_1 {
+        uint64_t addr;
+        uint32_t len;
+        uint16_t index;
+        uint16_t flags;
+};
+
+#endif /* __VIRTIO_1_1_H */
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index b23f4c2..a5db503 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -320,19 +320,21 @@ struct rte_virtio_xstats_name_off {
 
 	PMD_INIT_FUNC_TRACE();
 
-	/*
-	 * Reinitialise since virtio port might have been stopped and restarted
-	 */
 	memset(ring_mem, 0, vq->vq_ring_size);
-	vring_init(vr, size, ring_mem, VIRTIO_PCI_VRING_ALIGN);
-	vq->vq_used_cons_idx = 0;
-	vq->vq_desc_head_idx = 0;
-	vq->vq_avail_idx = 0;
-	vq->vq_desc_tail_idx = (uint16_t)(vq->vq_nentries - 1);
+	vring_init(vq->hw, vr, size, ring_mem, VIRTIO_PCI_VRING_ALIGN);
+
 	vq->vq_free_cnt = vq->vq_nentries;
 	memset(vq->vq_descx, 0, sizeof(struct vq_desc_extra) * vq->vq_nentries);
+	vq->vq_used_cons_idx = 0;
+	vq->vq_avail_idx     = 0;
+	if (vtpci_version_1_1(vq->hw)) {
+		vring_desc_init_1_1(vr, size);
+	} else {
+		vq->vq_desc_head_idx = 0;
+		vq->vq_desc_tail_idx = (uint16_t)(vq->vq_nentries - 1);
 
-	vring_desc_init(vr->desc, size);
+		vring_desc_init(vr->desc, size);
+	}
 
 	/*
 	 * Disable device(host) interrupting guest
@@ -407,7 +409,7 @@ struct rte_virtio_xstats_name_off {
 	/*
 	 * Reserve a memzone for vring elements
 	 */
-	size = vring_size(vq_size, VIRTIO_PCI_VRING_ALIGN);
+	size = vring_size(hw, vq_size, VIRTIO_PCI_VRING_ALIGN);
 	vq->vq_ring_size = RTE_ALIGN_CEIL(size, VIRTIO_PCI_VRING_ALIGN);
 	PMD_INIT_LOG(DEBUG, "vring_size: %d, rounded_vring_size: %d",
 		     size, vq->vq_ring_size);
diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h
index 18caebd..ec74009 100644
--- a/drivers/net/virtio/virtio_pci.h
+++ b/drivers/net/virtio/virtio_pci.h
@@ -140,6 +140,7 @@
 
 #define VIRTIO_F_VERSION_1		32
 #define VIRTIO_F_IOMMU_PLATFORM	33
+#define VIRTIO_F_VERSION_1_1		34
 
 /*
  * Some VirtIO feature bits (currently bits 28 through 31) are
@@ -318,6 +319,12 @@ struct virtio_net_config {
 	return (hw->guest_features & (1ULL << bit)) != 0;
 }
 
+static inline int
+vtpci_version_1_1(struct virtio_hw *hw)
+{
+	return vtpci_with_feature(hw, VIRTIO_F_VERSION_1_1);
+}
+
 /*
  * Function declaration from virtio_pci.c
  */
diff --git a/drivers/net/virtio/virtio_ring.h b/drivers/net/virtio/virtio_ring.h
index fcecc16..a991092 100644
--- a/drivers/net/virtio/virtio_ring.h
+++ b/drivers/net/virtio/virtio_ring.h
@@ -38,6 +38,8 @@
 
 #include <rte_common.h>
 
+#include "virtio-1.1.h"
+
 /* This marks a buffer as continuing via the next field. */
 #define VRING_DESC_F_NEXT       1
 /* This marks a buffer as write-only (otherwise read-only). */
@@ -88,6 +90,7 @@ struct vring {
 	struct vring_desc  *desc;
 	struct vring_avail *avail;
 	struct vring_used  *used;
+	struct vring_desc_1_1 *desc_1_1;
 };
 
 /* The standard layout for the ring is a continuous chunk of memory which
@@ -124,10 +127,13 @@ struct vring {
 #define vring_avail_event(vr) (*(uint16_t *)&(vr)->used->ring[(vr)->num])
 
 static inline size_t
-vring_size(unsigned int num, unsigned long align)
+vring_size(struct virtio_hw *hw, unsigned int num, unsigned long align)
 {
 	size_t size;
 
+	if (vtpci_version_1_1(hw))
+		return num * sizeof(struct vring_desc_1_1);
+
 	size = num * sizeof(struct vring_desc);
 	size += sizeof(struct vring_avail) + (num * sizeof(uint16_t));
 	size = RTE_ALIGN_CEIL(size, align);
@@ -137,10 +143,15 @@ struct vring {
 }
 
 static inline void
-vring_init(struct vring *vr, unsigned int num, uint8_t *p,
+vring_init(struct virtio_hw *hw, struct vring *vr, unsigned int num, uint8_t *p,
 	unsigned long align)
 {
 	vr->num = num;
+	if (vtpci_version_1_1(hw)) {
+		vr->desc_1_1 = (struct vring_desc_1_1 *)p;
+		return;
+	}
+
 	vr->desc = (struct vring_desc *) p;
 	vr->avail = (struct vring_avail *) (p +
 		num * sizeof(struct vring_desc));
diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h
index 2e12086..91d2db7 100644
--- a/drivers/net/virtio/virtqueue.h
+++ b/drivers/net/virtio/virtqueue.h
@@ -266,6 +266,16 @@ struct virtio_tx_region {
 			   __attribute__((__aligned__(16)));
 };
 
+static inline void
+vring_desc_init_1_1(struct vring *vr, int n)
+{
+	int i;
+	for (i = 0; i < n; i++) {
+		struct vring_desc_1_1 *desc = &vr->desc_1_1[i];
+		desc->index = i;
+	}
+}
+
 /* Chain all the descriptors in the ring with an END */
 static inline void
 vring_desc_init(struct vring_desc *dp, uint16_t n)
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [dpdk-dev] [RFC PATCH 02/11] net/virtio: implement 1.1 guest Tx
  2017-05-05 13:57 [dpdk-dev] [RFC PATCH 00/11] net/virtio: packed ring layout Jens Freimann
  2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 01/11] net/virtio: vring init for 1.1 Jens Freimann
@ 2017-05-05 13:57 ` Jens Freimann
  2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 03/11] net/virtio-user: add option to enable 1.1 Jens Freimann
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Jens Freimann @ 2017-05-05 13:57 UTC (permalink / raw)
  To: yuanhan.liu; +Cc: dev

From: Yuanhan Liu <yuanhan.liu@linux.intel.com>

build only so far

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
---
 drivers/net/virtio/Makefile          |   1 +
 drivers/net/virtio/virtio_ethdev.c   |  24 ++++--
 drivers/net/virtio/virtio_ethdev.h   |   3 +
 drivers/net/virtio/virtio_rxtx.c     |   3 +
 drivers/net/virtio/virtio_rxtx_1.1.c | 159 +++++++++++++++++++++++++++++++++++
 5 files changed, 183 insertions(+), 7 deletions(-)
 create mode 100644 drivers/net/virtio/virtio_rxtx_1.1.c

diff --git a/drivers/net/virtio/Makefile b/drivers/net/virtio/Makefile
index b21b878..4c4ff42 100644
--- a/drivers/net/virtio/Makefile
+++ b/drivers/net/virtio/Makefile
@@ -49,6 +49,7 @@ LIBABIVER := 1
 SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtqueue.c
 SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_pci.c
 SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_rxtx.c
+SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_rxtx_1.1.c
 SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_ethdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_rxtx_simple.c
 
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index a5db503..553c27a 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -334,12 +334,12 @@ struct rte_virtio_xstats_name_off {
 		vq->vq_desc_tail_idx = (uint16_t)(vq->vq_nentries - 1);
 
 		vring_desc_init(vr->desc, size);
-	}
 
-	/*
-	 * Disable device(host) interrupting guest
-	 */
-	virtqueue_disable_intr(vq);
+		/*
+		 * Disable device(host) interrupting guest
+		 */
+		virtqueue_disable_intr(vq);
+	}
 }
 
 static int
@@ -625,7 +625,8 @@ struct rte_virtio_xstats_name_off {
 	}
 
 	vtpci_reset(hw);
-	virtio_dev_free_mbufs(dev);
+	if (!vtpci_version_1_1(hw))
+		virtio_dev_free_mbufs(dev);
 	virtio_free_queues(hw);
 }
 
@@ -1534,7 +1535,6 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev,
 	RTE_BUILD_BUG_ON(RTE_PKTMBUF_HEADROOM < sizeof(struct virtio_net_hdr_mrg_rxbuf));
 
 	eth_dev->dev_ops = &virtio_eth_dev_ops;
-	eth_dev->tx_pkt_burst = &virtio_xmit_pkts;
 
 	if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
 		if (!hw->virtio_user_dev) {
@@ -1578,6 +1578,12 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev,
 	if (ret < 0)
 		return ret;
 
+	/* FIXME: as second process? */
+	if (vtpci_version_1_1(hw))
+		eth_dev->tx_pkt_burst = &virtio_xmit_pkts_1_1;
+	else
+		eth_dev->tx_pkt_burst = &virtio_xmit_pkts;
+
 	/* Setup interrupt callback  */
 	if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
 		rte_intr_callback_register(eth_dev->intr_handle,
@@ -1749,6 +1755,10 @@ static int eth_virtio_pci_remove(struct rte_pci_device *pci_dev)
 		}
 	}
 
+	/*no rx support for virtio 1.1 yet*/
+	if (vtpci_version_1_1(hw))
+		return 0;
+
 	/*Notify the backend
 	 *Otherwise the tap backend might already stop its queue due to fullness.
 	 *vhost backend will have no chance to be waked up
diff --git a/drivers/net/virtio/virtio_ethdev.h b/drivers/net/virtio/virtio_ethdev.h
index c3413c6..deed34e 100644
--- a/drivers/net/virtio/virtio_ethdev.h
+++ b/drivers/net/virtio/virtio_ethdev.h
@@ -69,6 +69,7 @@
 	 1u << VIRTIO_NET_F_MTU	| \
 	 1u << VIRTIO_RING_F_INDIRECT_DESC |    \
 	 1ULL << VIRTIO_F_VERSION_1       |	\
+	 1ULL << VIRTIO_F_VERSION_1_1     |	\
 	 1ULL << VIRTIO_F_IOMMU_PLATFORM)
 
 #define VIRTIO_PMD_SUPPORTED_GUEST_FEATURES	\
@@ -104,6 +105,8 @@ uint16_t virtio_recv_mergeable_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 
 uint16_t virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 		uint16_t nb_pkts);
+uint16_t virtio_xmit_pkts_1_1(void *tx_queue, struct rte_mbuf **tx_pkts,
+		uint16_t nb_pkts);
 
 uint16_t virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
 		uint16_t nb_pkts);
diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index fbc96df..e697192 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -427,6 +427,9 @@
 
 	PMD_INIT_FUNC_TRACE();
 
+	if (vtpci_version_1_1(hw))
+		return 0;
+
 	if (nb_desc == 0 || nb_desc > vq->vq_nentries)
 		nb_desc = vq->vq_nentries;
 	vq->vq_free_cnt = RTE_MIN(vq->vq_free_cnt, nb_desc);
diff --git a/drivers/net/virtio/virtio_rxtx_1.1.c b/drivers/net/virtio/virtio_rxtx_1.1.c
new file mode 100644
index 0000000..e47a346
--- /dev/null
+++ b/drivers/net/virtio/virtio_rxtx_1.1.c
@@ -0,0 +1,159 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ *     * Neither the name of Intel Corporation nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include <rte_cycles.h>
+#include <rte_memory.h>
+#include <rte_memzone.h>
+#include <rte_branch_prediction.h>
+#include <rte_mempool.h>
+#include <rte_malloc.h>
+#include <rte_mbuf.h>
+#include <rte_ether.h>
+#include <rte_ethdev.h>
+#include <rte_prefetch.h>
+#include <rte_string_fns.h>
+#include <rte_errno.h>
+#include <rte_byteorder.h>
+#include <rte_cpuflags.h>
+#include <rte_net.h>
+#include <rte_ip.h>
+#include <rte_udp.h>
+#include <rte_tcp.h>
+
+#include "virtio_logs.h"
+#include "virtio_ethdev.h"
+#include "virtio_pci.h"
+#include "virtqueue.h"
+#include "virtio_rxtx.h"
+
+/* Cleanup from completed transmits. */
+static void
+virtio_xmit_cleanup(struct virtqueue *vq)
+{
+	uint16_t idx;
+	uint16_t size = vq->vq_nentries;
+	struct vring_desc_1_1 *desc = vq->vq_ring.desc_1_1;
+
+	idx = vq->vq_used_cons_idx & (size - 1);
+	while ((desc[idx].flags & DESC_HW) == 0) {
+		struct vq_desc_extra *dxp;
+
+		dxp = &vq->vq_descx[idx];
+		if (dxp->cookie != NULL) {
+			rte_pktmbuf_free(dxp->cookie);
+			dxp->cookie = NULL;
+		}
+
+		idx = (++vq->vq_used_cons_idx) & (size - 1);
+		vq->vq_free_cnt++;
+
+		if (vq->vq_free_cnt >= size)
+			break;
+	}
+}
+
+static inline void
+virtio_xmit(struct virtnet_tx *txvq, struct rte_mbuf *mbuf)
+{
+	struct virtio_tx_region *txr = txvq->virtio_net_hdr_mz->addr;
+	struct virtqueue *vq = txvq->vq;
+	struct vring_desc_1_1 *desc = vq->vq_ring.desc_1_1;
+	uint16_t idx;
+	uint16_t head_idx = (vq->vq_avail_idx++) & (vq->vq_nentries - 1);
+
+	idx = head_idx;
+	vq->vq_free_cnt -= mbuf->nb_segs + 1;
+	vq->vq_descx[idx].cookie = mbuf;
+
+	desc[idx].addr  = txvq->virtio_net_hdr_mem +
+			  RTE_PTR_DIFF(&txr[idx].tx_hdr, txr);
+	desc[idx].len   = vq->hw->vtnet_hdr_size;
+	desc[idx].flags = VRING_DESC_F_NEXT;
+
+	do {
+		idx = (vq->vq_avail_idx++) & (vq->vq_nentries - 1);
+		desc[idx].addr  = VIRTIO_MBUF_DATA_DMA_ADDR(mbuf, vq);
+		desc[idx].len   = mbuf->data_len;
+		desc[idx].flags = DESC_HW | VRING_DESC_F_NEXT;
+	} while ((mbuf = mbuf->next) != NULL);
+
+	desc[idx].flags &= ~VRING_DESC_F_NEXT;
+
+	/*
+	 * update the head last, so that when the host saw such flag
+	 * is set, it means all others in the same chain is also set
+	 */
+	rte_smp_wmb();
+	desc[head_idx].flags |= DESC_HW;
+}
+
+uint16_t
+virtio_xmit_pkts_1_1(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
+{
+	struct virtnet_tx *txvq = tx_queue;
+	struct virtqueue *vq = txvq->vq;
+	uint16_t i;
+
+	if (unlikely(nb_pkts < 1))
+		return nb_pkts;
+
+	PMD_TX_LOG(DEBUG, "%d packets to xmit", nb_pkts);
+
+	for (i = 0; i < nb_pkts; i++) {
+		struct rte_mbuf *txm = tx_pkts[i];
+
+		if (unlikely(txm->nb_segs + 1 > vq->vq_free_cnt)) {
+			virtio_xmit_cleanup(vq);
+
+			if (unlikely(txm->nb_segs + 1 > vq->vq_free_cnt)) {
+				PMD_TX_LOG(ERR,
+					   "No free tx descriptors to transmit");
+				break;
+			}
+		}
+
+		virtio_xmit(txvq, txm);
+		txvq->stats.bytes += txm->pkt_len;
+	}
+
+	txvq->stats.packets += i;
+	txvq->stats.errors  += nb_pkts - i;
+
+	return i;
+}
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [dpdk-dev] [RFC PATCH 03/11] net/virtio-user: add option to enable 1.1
  2017-05-05 13:57 [dpdk-dev] [RFC PATCH 00/11] net/virtio: packed ring layout Jens Freimann
  2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 01/11] net/virtio: vring init for 1.1 Jens Freimann
  2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 02/11] net/virtio: implement 1.1 guest Tx Jens Freimann
@ 2017-05-05 13:57 ` Jens Freimann
  2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 04/11] vhost: enable 1.1 for testing Jens Freimann
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Jens Freimann @ 2017-05-05 13:57 UTC (permalink / raw)
  To: yuanhan.liu; +Cc: dev

From: Yuanhan Liu <yuanhan.liu@linux.intel.com>

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
---
 drivers/net/virtio/virtio_user/virtio_user_dev.c |  9 ++++++++-
 drivers/net/virtio/virtio_user/virtio_user_dev.h |  3 ++-
 drivers/net/virtio/virtio_user_ethdev.c          | 14 +++++++++++++-
 3 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 450404b..3ff6a05 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -337,7 +337,8 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
 
 int
 virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
-		     int cq, int queue_size, const char *mac, char **ifname)
+		     int cq, int queue_size, const char *mac, char **ifname,
+		     int version_1_1)
 {
 	snprintf(dev->path, PATH_MAX, "%s", path);
 	dev->max_queue_pairs = queues;
@@ -365,6 +366,12 @@ int virtio_user_stop_device(struct virtio_user_dev *dev)
 		PMD_INIT_LOG(ERR, "get_features failed: %s", strerror(errno));
 		return -1;
 	}
+
+	if (version_1_1)
+		dev->features |= (1ull << VIRTIO_F_VERSION_1_1);
+	else
+		dev->features &= ~(1ull << VIRTIO_F_VERSION_1_1);
+
 	if (dev->mac_specified)
 		dev->device_features |= (1ull << VIRTIO_NET_F_MAC);
 
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h b/drivers/net/virtio/virtio_user/virtio_user_dev.h
index 8361b6b..76fa17f 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.h
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h
@@ -71,7 +71,8 @@ struct virtio_user_dev {
 int virtio_user_start_device(struct virtio_user_dev *dev);
 int virtio_user_stop_device(struct virtio_user_dev *dev);
 int virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
-			 int cq, int queue_size, const char *mac, char **ifname);
+			 int cq, int queue_size, const char *mac, char **ifname,
+			 int version_1_1);
 void virtio_user_dev_uninit(struct virtio_user_dev *dev);
 void virtio_user_handle_cq(struct virtio_user_dev *dev, uint16_t queue_idx);
 #endif
diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c
index 1894310..141c761 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -300,6 +300,8 @@
 	VIRTIO_USER_ARG_QUEUE_SIZE,
 #define VIRTIO_USER_ARG_INTERFACE_NAME "iface"
 	VIRTIO_USER_ARG_INTERFACE_NAME,
+#define VIRTIO_USER_ARG_VERSION_1_1     "version_1_1"
+	VIRTIO_USER_ARG_VERSION_1_1,
 	NULL
 };
 
@@ -404,6 +406,7 @@
 	char *ifname = NULL;
 	char *mac_addr = NULL;
 	int ret = -1;
+	uint64_t version_1_1 = 0;
 
 	kvlist = rte_kvargs_parse(rte_vdev_device_args(dev), valid_args);
 	if (!kvlist) {
@@ -478,6 +481,15 @@
 		cq = 1;
 	}
 
+	if (rte_kvargs_count(kvlist, VIRTIO_USER_ARG_VERSION_1_1) == 1) {
+		if (rte_kvargs_process(kvlist, VIRTIO_USER_ARG_VERSION_1_1,
+				       &get_integer_arg, &version_1_1) < 0) {
+			PMD_INIT_LOG(ERR, "error to parse %s",
+				     VIRTIO_USER_ARG_VERSION_1_1);
+			goto end;
+		}
+	}
+
 	if (queues > 1 && cq == 0) {
 		PMD_INIT_LOG(ERR, "multi-q requires ctrl-q");
 		goto end;
@@ -499,7 +511,7 @@
 
 		hw = eth_dev->data->dev_private;
 		if (virtio_user_dev_init(hw->virtio_user_dev, path, queues, cq,
-				 queue_size, mac_addr, &ifname) < 0) {
+				 queue_size, mac_addr, &ifname, version_1_1) < 0) {
 			PMD_INIT_LOG(ERR, "virtio_user_dev_init fails");
 			virtio_user_eth_dev_free(eth_dev);
 			goto end;
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [dpdk-dev] [RFC PATCH 04/11] vhost: enable 1.1 for testing
  2017-05-05 13:57 [dpdk-dev] [RFC PATCH 00/11] net/virtio: packed ring layout Jens Freimann
                   ` (2 preceding siblings ...)
  2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 03/11] net/virtio-user: add option to enable 1.1 Jens Freimann
@ 2017-05-05 13:57 ` Jens Freimann
  2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 05/11] vhost: set desc addr for 1.1 Jens Freimann
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Jens Freimann @ 2017-05-05 13:57 UTC (permalink / raw)
  To: yuanhan.liu; +Cc: dev

From: Yuanhan Liu <yuanhan.liu@linux.intel.com>

Just set the features on, no actual work has been done. Just
make sure the virtio PMD could have this feature been enabled,
for testing only.

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
---
 lib/librte_vhost/vhost.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
index ddd8a9c..208b2eb 100644
--- a/lib/librte_vhost/vhost.h
+++ b/lib/librte_vhost/vhost.h
@@ -138,6 +138,9 @@ struct vhost_virtqueue {
 #ifndef VIRTIO_F_VERSION_1
  #define VIRTIO_F_VERSION_1 32
 #endif
+#ifndef VIRTIO_F_VERSION_1_1
+ #define VIRTIO_F_VERSION_1_1 34
+#endif
 
 #define VHOST_USER_F_PROTOCOL_FEATURES	30
 
@@ -148,6 +151,7 @@ struct vhost_virtqueue {
 				(1ULL << VIRTIO_NET_F_GUEST_ANNOUNCE) | \
 				(1ULL << VIRTIO_NET_F_MQ)      | \
 				(1ULL << VIRTIO_F_VERSION_1)   | \
+				(1ULL << VIRTIO_F_VERSION_1_1) | \
 				(1ULL << VHOST_F_LOG_ALL)      | \
 				(1ULL << VHOST_USER_F_PROTOCOL_FEATURES) | \
 				(1ULL << VIRTIO_NET_F_HOST_TSO4) | \
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [dpdk-dev] [RFC PATCH 05/11] vhost: set desc addr for 1.1
  2017-05-05 13:57 [dpdk-dev] [RFC PATCH 00/11] net/virtio: packed ring layout Jens Freimann
                   ` (3 preceding siblings ...)
  2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 04/11] vhost: enable 1.1 for testing Jens Freimann
@ 2017-05-05 13:57 ` Jens Freimann
  2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 06/11] vhost: implement virtio 1.1 dequeue path Jens Freimann
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Jens Freimann @ 2017-05-05 13:57 UTC (permalink / raw)
  To: yuanhan.liu; +Cc: dev

From: Yuanhan Liu <yuanhan.liu@linux.intel.com>

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
---
 lib/librte_vhost/vhost.h      | 1 +
 lib/librte_vhost/vhost_user.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
index 208b2eb..f3b7ad5 100644
--- a/lib/librte_vhost/vhost.h
+++ b/lib/librte_vhost/vhost.h
@@ -86,6 +86,7 @@ struct zcopy_mbuf {
  */
 struct vhost_virtqueue {
 	struct vring_desc	*desc;
+	struct vring_desc_1_1   *desc_1_1;
 	struct vring_avail	*avail;
 	struct vring_used	*used;
 	uint32_t		size;
diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 5c8058b..3b05355 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -349,6 +349,7 @@
 			dev->vid);
 		return -1;
 	}
+	vq->desc_1_1 = (struct vring_desc_1_1 *)vq->desc_1_1;
 
 	dev = numa_realloc(dev, addr->index);
 	vq = dev->virtqueue[addr->index];
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [dpdk-dev] [RFC PATCH 06/11] vhost: implement virtio 1.1 dequeue path
  2017-05-05 13:57 [dpdk-dev] [RFC PATCH 00/11] net/virtio: packed ring layout Jens Freimann
                   ` (4 preceding siblings ...)
  2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 05/11] vhost: set desc addr for 1.1 Jens Freimann
@ 2017-05-05 13:57 ` Jens Freimann
  2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 07/11] vhost: mark desc being used Jens Freimann
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Jens Freimann @ 2017-05-05 13:57 UTC (permalink / raw)
  To: yuanhan.liu; +Cc: dev

From: Yuanhan Liu <yuanhan.liu@linux.intel.com>

Build test only; haven't tested it yet

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Signed-off-by: Jens Freimann <jfreiman@redhat.com>
---
 lib/librte_vhost/virtio-1.1.h |  23 ++++++
 lib/librte_vhost/virtio_net.c | 181 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 204 insertions(+)
 create mode 100644 lib/librte_vhost/virtio-1.1.h

diff --git a/lib/librte_vhost/virtio-1.1.h b/lib/librte_vhost/virtio-1.1.h
new file mode 100644
index 0000000..4241d0a
--- /dev/null
+++ b/lib/librte_vhost/virtio-1.1.h
@@ -0,0 +1,23 @@
+#ifndef __VIRTIO_1_1_H
+#define __VIRTIO_1_1_H
+
+#define __le64	uint64_t
+#define __le32	uint32_t
+#define __le16	uint16_t
+
+#define VRING_DESC_F_NEXT	1
+#define VRING_DESC_F_WRITE	2
+#define VRING_DESC_F_INDIRECT	4
+
+#define BATCH_NOT_FIRST 0x0010
+#define BATCH_NOT_LAST  0x0020
+#define DESC_HW		0x0080
+
+struct vring_desc_1_1 {
+        __le64 addr;
+        __le32 len;
+        __le16 index;
+        __le16 flags;
+};
+
+#endif /* __VIRTIO_1_1_H */
diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index 48219e0..fd6f200 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -46,6 +46,7 @@
 #include <rte_arp.h>
 
 #include "vhost.h"
+#include "virtio-1.1.h"
 
 #define MAX_PKT_BURST 32
 
@@ -973,6 +974,183 @@ static inline bool __attribute__((always_inline))
 	return true;
 }
 
+static inline uint16_t
+dequeue_desc(struct virtio_net *dev, struct vhost_virtqueue *vq,
+	     struct rte_mempool *mbuf_pool, struct rte_mbuf *m,
+	     struct vring_desc_1_1 *descs)
+{
+	struct vring_desc_1_1 *desc;
+	uint64_t desc_addr;
+	uint32_t desc_avail, desc_offset;
+	uint32_t mbuf_avail, mbuf_offset;
+	uint32_t cpy_len;
+	struct rte_mbuf *cur = m, *prev = m;
+	struct virtio_net_hdr *hdr = NULL;
+	uint16_t head_idx = vq->last_used_idx;
+
+	desc = &descs[(head_idx++) & (vq->size - 1)];
+	if (unlikely((desc->len < dev->vhost_hlen)) ||
+			(desc->flags & VRING_DESC_F_INDIRECT))
+		return -1;
+
+	desc_addr = rte_vhost_gpa_to_vva(dev->mem, desc->addr);
+	if (unlikely(!desc_addr))
+		return -1;
+
+	if (virtio_net_with_host_offload(dev)) {
+		hdr = (struct virtio_net_hdr *)((uintptr_t)desc_addr);
+		rte_prefetch0(hdr);
+	}
+
+	/*
+	 * A virtio driver normally uses at least 2 desc buffers
+	 * for Tx: the first for storing the header, and others
+	 * for storing the data.
+	 */
+	if (likely((desc->len == dev->vhost_hlen) &&
+		   (desc->flags & VRING_DESC_F_NEXT) != 0)) {
+		desc->flags = 0;
+
+		desc = &descs[(head_idx++) & (vq->size - 1)];
+		if (unlikely(desc->flags & VRING_DESC_F_INDIRECT))
+			return -1;
+
+		desc_addr = rte_vhost_gpa_to_vva(dev->mem, desc->addr);
+		if (unlikely(!desc_addr))
+			return -1;
+
+		desc_offset = 0;
+		desc_avail  = desc->len;
+	} else {
+		desc_avail  = desc->len - dev->vhost_hlen;
+		desc_offset = dev->vhost_hlen;
+	}
+
+	rte_prefetch0((void *)(uintptr_t)(desc_addr + desc_offset));
+
+	PRINT_PACKET(dev, (uintptr_t)(desc_addr + desc_offset), desc_avail, 0);
+
+	mbuf_offset = 0;
+	mbuf_avail  = m->buf_len - RTE_PKTMBUF_HEADROOM;
+	while (1) {
+		uint64_t hpa;
+
+		cpy_len = RTE_MIN(desc_avail, mbuf_avail);
+
+		/*
+		 * A desc buf might across two host physical pages that are
+		 * not continuous. In such case (gpa_to_hpa returns 0), data
+		 * will be copied even though zero copy is enabled.
+		 */
+		if (unlikely(dev->dequeue_zero_copy && (hpa = gpa_to_hpa(dev,
+					desc->addr + desc_offset, cpy_len)))) {
+			cur->data_len = cpy_len;
+			cur->data_off = 0;
+			cur->buf_addr = (void *)(uintptr_t)desc_addr;
+			cur->buf_physaddr = hpa;
+
+			/*
+			 * In zero copy mode, one mbuf can only reference data
+			 * for one or partial of one desc buff.
+			 */
+			mbuf_avail = cpy_len;
+		} else {
+			rte_memcpy(rte_pktmbuf_mtod_offset(cur, void *,
+							   mbuf_offset),
+				(void *)((uintptr_t)(desc_addr + desc_offset)),
+				cpy_len);
+		}
+
+		mbuf_avail  -= cpy_len;
+		mbuf_offset += cpy_len;
+		desc_avail  -= cpy_len;
+		desc_offset += cpy_len;
+
+		/* This desc reaches to its end, get the next one */
+		if (desc_avail == 0) {
+			desc->flags = 0;
+
+			if ((desc->flags & VRING_DESC_F_NEXT) == 0)
+				break;
+
+			desc = &descs[(head_idx++) & (vq->size - 1)];
+			if (unlikely(desc->flags & VRING_DESC_F_INDIRECT))
+				return -1;
+
+			desc_addr = rte_vhost_gpa_to_vva(dev->mem, desc->addr);
+			if (unlikely(!desc_addr))
+				return -1;
+
+			rte_prefetch0((void *)(uintptr_t)desc_addr);
+
+			desc_offset = 0;
+			desc_avail  = desc->len;
+
+			PRINT_PACKET(dev, (uintptr_t)desc_addr, desc->len, 0);
+		}
+
+		/*
+		 * This mbuf reaches to its end, get a new one
+		 * to hold more data.
+		 */
+		if (mbuf_avail == 0) {
+			cur = rte_pktmbuf_alloc(mbuf_pool);
+			if (unlikely(cur == NULL)) {
+				RTE_LOG(ERR, VHOST_DATA, "Failed to "
+					"allocate memory for mbuf.\n");
+				return -1;
+			}
+
+			prev->next = cur;
+			prev->data_len = mbuf_offset;
+			m->nb_segs += 1;
+			m->pkt_len += mbuf_offset;
+			prev = cur;
+
+			mbuf_offset = 0;
+			mbuf_avail  = cur->buf_len - RTE_PKTMBUF_HEADROOM;
+		}
+	}
+	desc->flags = 0;
+
+	prev->data_len = mbuf_offset;
+	m->pkt_len    += mbuf_offset;
+
+	if (hdr)
+		vhost_dequeue_offload(hdr, m);
+
+	vq->last_used_idx = head_idx;
+
+	return 0;
+}
+
+static inline uint16_t
+vhost_dequeue_burst_1_1(struct virtio_net *dev, struct vhost_virtqueue *vq,
+			struct rte_mempool *mbuf_pool, struct rte_mbuf **pkts,
+			uint16_t count)
+{
+	uint16_t i;
+	uint16_t idx;
+	struct vring_desc_1_1 *desc = vq->desc_1_1;
+
+	for (i = 0; i < count; i++) {
+		idx = vq->last_used_idx & (vq->size - 1);
+		if (!(desc[idx].flags & DESC_HW))
+			break;
+
+		pkts[i] = rte_pktmbuf_alloc(mbuf_pool);
+		if (unlikely(pkts[i] == NULL)) {
+			RTE_LOG(ERR, VHOST_DATA,
+				"Failed to allocate memory for mbuf.\n");
+			break;
+		}
+
+		dequeue_desc(dev, vq, mbuf_pool, pkts[i], desc);
+	}
+
+	return i;
+}
+
 uint16_t
 rte_vhost_dequeue_burst(int vid, uint16_t queue_id,
 	struct rte_mempool *mbuf_pool, struct rte_mbuf **pkts, uint16_t count)
@@ -1000,6 +1178,9 @@ static inline bool __attribute__((always_inline))
 	if (unlikely(vq->enabled == 0))
 		return 0;
 
+	if (dev->features & (1ULL << VIRTIO_F_VERSION_1_1))
+		return vhost_dequeue_burst_1_1(dev, vq, mbuf_pool, pkts, count);
+
 	if (unlikely(dev->dequeue_zero_copy)) {
 		struct zcopy_mbuf *zmbuf, *next;
 		int nr_updated = 0;
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [dpdk-dev] [RFC PATCH 07/11] vhost: mark desc being used
  2017-05-05 13:57 [dpdk-dev] [RFC PATCH 00/11] net/virtio: packed ring layout Jens Freimann
                   ` (5 preceding siblings ...)
  2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 06/11] vhost: implement virtio 1.1 dequeue path Jens Freimann
@ 2017-05-05 13:57 ` Jens Freimann
  2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 08/11] xxx: batch the desc_hw update? Jens Freimann
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Jens Freimann @ 2017-05-05 13:57 UTC (permalink / raw)
  To: yuanhan.liu; +Cc: dev

From: Yuanhan Liu <yuanhan.liu@linux.intel.com>

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
---
 lib/librte_vhost/virtio_net.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index fd6f200..df88e31 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -1009,6 +1009,7 @@ static inline bool __attribute__((always_inline))
 	 */
 	if (likely((desc->len == dev->vhost_hlen) &&
 		   (desc->flags & VRING_DESC_F_NEXT) != 0)) {
+		rte_smp_wmb();
 		desc->flags = 0;
 
 		desc = &descs[(head_idx++) & (vq->size - 1)];
@@ -1068,11 +1069,11 @@ static inline bool __attribute__((always_inline))
 
 		/* This desc reaches to its end, get the next one */
 		if (desc_avail == 0) {
-			desc->flags = 0;
-
 			if ((desc->flags & VRING_DESC_F_NEXT) == 0)
 				break;
 
+			rte_smp_wmb();
+			desc->flags = 0;
 			desc = &descs[(head_idx++) & (vq->size - 1)];
 			if (unlikely(desc->flags & VRING_DESC_F_INDIRECT))
 				return -1;
@@ -1111,6 +1112,7 @@ static inline bool __attribute__((always_inline))
 			mbuf_avail  = cur->buf_len - RTE_PKTMBUF_HEADROOM;
 		}
 	}
+	rte_smp_wmb();
 	desc->flags = 0;
 
 	prev->data_len = mbuf_offset;
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [dpdk-dev] [RFC PATCH 08/11] xxx: batch the desc_hw update?
  2017-05-05 13:57 [dpdk-dev] [RFC PATCH 00/11] net/virtio: packed ring layout Jens Freimann
                   ` (6 preceding siblings ...)
  2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 07/11] vhost: mark desc being used Jens Freimann
@ 2017-05-05 13:57 ` Jens Freimann
  2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 09/11] xxx: virtio: remove overheads Jens Freimann
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Jens Freimann @ 2017-05-05 13:57 UTC (permalink / raw)
  To: yuanhan.liu; +Cc: dev

From: Yuanhan Liu <yuanhan.liu@linux.intel.com>

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>

Conflicts:
	lib/librte_vhost/virtio_net.c
---
 drivers/net/virtio/virtio_rxtx_1.1.c | 18 ++++++++++--------
 lib/librte_vhost/virtio_net.c        | 17 ++++++++++-------
 2 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/drivers/net/virtio/virtio_rxtx_1.1.c b/drivers/net/virtio/virtio_rxtx_1.1.c
index e47a346..05f9dc7 100644
--- a/drivers/net/virtio/virtio_rxtx_1.1.c
+++ b/drivers/net/virtio/virtio_rxtx_1.1.c
@@ -89,7 +89,7 @@
 }
 
 static inline void
-virtio_xmit(struct virtnet_tx *txvq, struct rte_mbuf *mbuf)
+virtio_xmit(struct virtnet_tx *txvq, struct rte_mbuf *mbuf, int first_mbuf)
 {
 	struct virtio_tx_region *txr = txvq->virtio_net_hdr_mz->addr;
 	struct virtqueue *vq = txvq->vq;
@@ -105,6 +105,8 @@
 			  RTE_PTR_DIFF(&txr[idx].tx_hdr, txr);
 	desc[idx].len   = vq->hw->vtnet_hdr_size;
 	desc[idx].flags = VRING_DESC_F_NEXT;
+	if (!first_mbuf)
+		desc[idx].flags |= DESC_HW;
 
 	do {
 		idx = (vq->vq_avail_idx++) & (vq->vq_nentries - 1);
@@ -115,12 +117,6 @@
 
 	desc[idx].flags &= ~VRING_DESC_F_NEXT;
 
-	/*
-	 * update the head last, so that when the host saw such flag
-	 * is set, it means all others in the same chain is also set
-	 */
-	rte_smp_wmb();
-	desc[head_idx].flags |= DESC_HW;
 }
 
 uint16_t
@@ -129,6 +125,7 @@
 	struct virtnet_tx *txvq = tx_queue;
 	struct virtqueue *vq = txvq->vq;
 	uint16_t i;
+	uint16_t head_idx = vq->vq_avail_idx;
 
 	if (unlikely(nb_pkts < 1))
 		return nb_pkts;
@@ -148,10 +145,15 @@
 			}
 		}
 
-		virtio_xmit(txvq, txm);
+		virtio_xmit(txvq, txm, i == 0);
 		txvq->stats.bytes += txm->pkt_len;
 	}
 
+	if (likely(i)) {
+		rte_smp_wmb();
+		vq->vq_ring.desc_1_1[head_idx & (vq->vq_nentries - 1)].flags |= DESC_HW;
+	}
+
 	txvq->stats.packets += i;
 	txvq->stats.errors  += nb_pkts - i;
 
diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index df88e31..c9e466f 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -1009,9 +1009,6 @@ static inline bool __attribute__((always_inline))
 	 */
 	if (likely((desc->len == dev->vhost_hlen) &&
 		   (desc->flags & VRING_DESC_F_NEXT) != 0)) {
-		rte_smp_wmb();
-		desc->flags = 0;
-
 		desc = &descs[(head_idx++) & (vq->size - 1)];
 		if (unlikely(desc->flags & VRING_DESC_F_INDIRECT))
 			return -1;
@@ -1072,8 +1069,6 @@ static inline bool __attribute__((always_inline))
 			if ((desc->flags & VRING_DESC_F_NEXT) == 0)
 				break;
 
-			rte_smp_wmb();
-			desc->flags = 0;
 			desc = &descs[(head_idx++) & (vq->size - 1)];
 			if (unlikely(desc->flags & VRING_DESC_F_INDIRECT))
 				return -1;
@@ -1112,8 +1107,6 @@ static inline bool __attribute__((always_inline))
 			mbuf_avail  = cur->buf_len - RTE_PKTMBUF_HEADROOM;
 		}
 	}
-	rte_smp_wmb();
-	desc->flags = 0;
 
 	prev->data_len = mbuf_offset;
 	m->pkt_len    += mbuf_offset;
@@ -1134,7 +1127,9 @@ static inline bool __attribute__((always_inline))
 	uint16_t i;
 	uint16_t idx;
 	struct vring_desc_1_1 *desc = vq->desc_1_1;
+	uint16_t head_idx = vq->last_used_idx;
 
+	count = RTE_MIN(MAX_PKT_BURST, count);
 	for (i = 0; i < count; i++) {
 		idx = vq->last_used_idx & (vq->size - 1);
 		if (!(desc[idx].flags & DESC_HW))
@@ -1150,6 +1145,14 @@ static inline bool __attribute__((always_inline))
 		dequeue_desc(dev, vq, mbuf_pool, pkts[i], desc);
 	}
 
+	if (likely(i)) {
+		for (idx = 1; idx < (uint16_t)(vq->last_used_idx - head_idx); idx++) {
+			desc[(idx + head_idx) & (vq->size - 1)].flags = 0;
+		}
+		rte_smp_wmb();
+		desc[head_idx & (vq->size - 1)].flags = 0;
+	}
+
 	return i;
 }
 
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [dpdk-dev] [RFC PATCH 09/11] xxx: virtio: remove overheads
  2017-05-05 13:57 [dpdk-dev] [RFC PATCH 00/11] net/virtio: packed ring layout Jens Freimann
                   ` (7 preceding siblings ...)
  2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 08/11] xxx: batch the desc_hw update? Jens Freimann
@ 2017-05-05 13:57 ` Jens Freimann
  2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 10/11] vhost: prefetch desc Jens Freimann
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Jens Freimann @ 2017-05-05 13:57 UTC (permalink / raw)
  To: yuanhan.liu; +Cc: dev

From: Yuanhan Liu <yuanhan.liu@linux.intel.com>

for better performance comparing

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
---
 drivers/net/virtio/virtio_rxtx.c | 188 +++------------------------------------
 1 file changed, 12 insertions(+), 176 deletions(-)

diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index e697192..c49ac0d 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -218,76 +218,16 @@
 	return 0;
 }
 
-/* When doing TSO, the IP length is not included in the pseudo header
- * checksum of the packet given to the PMD, but for virtio it is
- * expected.
- */
-static void
-virtio_tso_fix_cksum(struct rte_mbuf *m)
-{
-	/* common case: header is not fragmented */
-	if (likely(rte_pktmbuf_data_len(m) >= m->l2_len + m->l3_len +
-			m->l4_len)) {
-		struct ipv4_hdr *iph;
-		struct ipv6_hdr *ip6h;
-		struct tcp_hdr *th;
-		uint16_t prev_cksum, new_cksum, ip_len, ip_paylen;
-		uint32_t tmp;
-
-		iph = rte_pktmbuf_mtod_offset(m, struct ipv4_hdr *, m->l2_len);
-		th = RTE_PTR_ADD(iph, m->l3_len);
-		if ((iph->version_ihl >> 4) == 4) {
-			iph->hdr_checksum = 0;
-			iph->hdr_checksum = rte_ipv4_cksum(iph);
-			ip_len = iph->total_length;
-			ip_paylen = rte_cpu_to_be_16(rte_be_to_cpu_16(ip_len) -
-				m->l3_len);
-		} else {
-			ip6h = (struct ipv6_hdr *)iph;
-			ip_paylen = ip6h->payload_len;
-		}
-
-		/* calculate the new phdr checksum not including ip_paylen */
-		prev_cksum = th->cksum;
-		tmp = prev_cksum;
-		tmp += ip_paylen;
-		tmp = (tmp & 0xffff) + (tmp >> 16);
-		new_cksum = tmp;
-
-		/* replace it in the packet */
-		th->cksum = new_cksum;
-	}
-}
-
-static inline int
-tx_offload_enabled(struct virtio_hw *hw)
-{
-	return vtpci_with_feature(hw, VIRTIO_NET_F_CSUM) ||
-		vtpci_with_feature(hw, VIRTIO_NET_F_HOST_TSO4) ||
-		vtpci_with_feature(hw, VIRTIO_NET_F_HOST_TSO6);
-}
-
-/* avoid write operation when necessary, to lessen cache issues */
-#define ASSIGN_UNLESS_EQUAL(var, val) do {	\
-	if ((var) != (val))			\
-		(var) = (val);			\
-} while (0)
-
 static inline void
 virtqueue_enqueue_xmit(struct virtnet_tx *txvq, struct rte_mbuf *cookie,
-		       uint16_t needed, int use_indirect, int can_push)
+		       uint16_t needed)
 {
 	struct virtio_tx_region *txr = txvq->virtio_net_hdr_mz->addr;
 	struct vq_desc_extra *dxp;
 	struct virtqueue *vq = txvq->vq;
 	struct vring_desc *start_dp;
-	uint16_t seg_num = cookie->nb_segs;
 	uint16_t head_idx, idx;
-	uint16_t head_size = vq->hw->vtnet_hdr_size;
-	struct virtio_net_hdr *hdr;
-	int offload;
 
-	offload = tx_offload_enabled(vq->hw);
 	head_idx = vq->vq_desc_head_idx;
 	idx = head_idx;
 	dxp = &vq->vq_descx[idx];
@@ -296,91 +236,15 @@
 
 	start_dp = vq->vq_ring.desc;
 
-	if (can_push) {
-		/* prepend cannot fail, checked by caller */
-		hdr = (struct virtio_net_hdr *)
-			rte_pktmbuf_prepend(cookie, head_size);
-		/* if offload disabled, it is not zeroed below, do it now */
-		if (offload == 0) {
-			ASSIGN_UNLESS_EQUAL(hdr->csum_start, 0);
-			ASSIGN_UNLESS_EQUAL(hdr->csum_offset, 0);
-			ASSIGN_UNLESS_EQUAL(hdr->flags, 0);
-			ASSIGN_UNLESS_EQUAL(hdr->gso_type, 0);
-			ASSIGN_UNLESS_EQUAL(hdr->gso_size, 0);
-			ASSIGN_UNLESS_EQUAL(hdr->hdr_len, 0);
-		}
-	} else if (use_indirect) {
-		/* setup tx ring slot to point to indirect
-		 * descriptor list stored in reserved region.
-		 *
-		 * the first slot in indirect ring is already preset
-		 * to point to the header in reserved region
-		 */
-		start_dp[idx].addr  = txvq->virtio_net_hdr_mem +
-			RTE_PTR_DIFF(&txr[idx].tx_indir, txr);
-		start_dp[idx].len   = (seg_num + 1) * sizeof(struct vring_desc);
-		start_dp[idx].flags = VRING_DESC_F_INDIRECT;
-		hdr = (struct virtio_net_hdr *)&txr[idx].tx_hdr;
-
-		/* loop below will fill in rest of the indirect elements */
-		start_dp = txr[idx].tx_indir;
-		idx = 1;
-	} else {
-		/* setup first tx ring slot to point to header
-		 * stored in reserved region.
-		 */
-		start_dp[idx].addr  = txvq->virtio_net_hdr_mem +
-			RTE_PTR_DIFF(&txr[idx].tx_hdr, txr);
-		start_dp[idx].len   = vq->hw->vtnet_hdr_size;
-		start_dp[idx].flags = VRING_DESC_F_NEXT;
-		hdr = (struct virtio_net_hdr *)&txr[idx].tx_hdr;
-
-		idx = start_dp[idx].next;
-	}
-
-	/* Checksum Offload / TSO */
-	if (offload) {
-		if (cookie->ol_flags & PKT_TX_TCP_SEG)
-			cookie->ol_flags |= PKT_TX_TCP_CKSUM;
-
-		switch (cookie->ol_flags & PKT_TX_L4_MASK) {
-		case PKT_TX_UDP_CKSUM:
-			hdr->csum_start = cookie->l2_len + cookie->l3_len;
-			hdr->csum_offset = offsetof(struct udp_hdr,
-				dgram_cksum);
-			hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
-			break;
-
-		case PKT_TX_TCP_CKSUM:
-			hdr->csum_start = cookie->l2_len + cookie->l3_len;
-			hdr->csum_offset = offsetof(struct tcp_hdr, cksum);
-			hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
-			break;
+       /* setup first tx ring slot to point to header
+        * stored in reserved region.
+        */
+       start_dp[idx].addr  = txvq->virtio_net_hdr_mem +
+       	RTE_PTR_DIFF(&txr[idx].tx_hdr, txr);
+       start_dp[idx].len   = vq->hw->vtnet_hdr_size;
+       start_dp[idx].flags = VRING_DESC_F_NEXT;
 
-		default:
-			ASSIGN_UNLESS_EQUAL(hdr->csum_start, 0);
-			ASSIGN_UNLESS_EQUAL(hdr->csum_offset, 0);
-			ASSIGN_UNLESS_EQUAL(hdr->flags, 0);
-			break;
-		}
-
-		/* TCP Segmentation Offload */
-		if (cookie->ol_flags & PKT_TX_TCP_SEG) {
-			virtio_tso_fix_cksum(cookie);
-			hdr->gso_type = (cookie->ol_flags & PKT_TX_IPV6) ?
-				VIRTIO_NET_HDR_GSO_TCPV6 :
-				VIRTIO_NET_HDR_GSO_TCPV4;
-			hdr->gso_size = cookie->tso_segsz;
-			hdr->hdr_len =
-				cookie->l2_len +
-				cookie->l3_len +
-				cookie->l4_len;
-		} else {
-			ASSIGN_UNLESS_EQUAL(hdr->gso_type, 0);
-			ASSIGN_UNLESS_EQUAL(hdr->gso_size, 0);
-			ASSIGN_UNLESS_EQUAL(hdr->hdr_len, 0);
-		}
-	}
+       idx = start_dp[idx].next;
 
 	do {
 		start_dp[idx].addr  = VIRTIO_MBUF_DATA_DMA_ADDR(cookie, vq);
@@ -389,9 +253,6 @@
 		idx = start_dp[idx].next;
 	} while ((cookie = cookie->next) != NULL);
 
-	if (use_indirect)
-		idx = vq->vq_ring.desc[head_idx].next;
-
 	vq->vq_desc_head_idx = idx;
 	if (vq->vq_desc_head_idx == VQ_RING_DESC_CHAIN_END)
 		vq->vq_desc_tail_idx = idx;
@@ -1011,9 +872,7 @@
 	struct virtnet_tx *txvq = tx_queue;
 	struct virtqueue *vq = txvq->vq;
 	struct virtio_hw *hw = vq->hw;
-	uint16_t hdr_size = hw->vtnet_hdr_size;
 	uint16_t nb_used, nb_tx = 0;
-	int error;
 
 	if (unlikely(hw->started == 0))
 		return nb_tx;
@@ -1030,37 +889,14 @@
 
 	for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
 		struct rte_mbuf *txm = tx_pkts[nb_tx];
-		int can_push = 0, use_indirect = 0, slots, need;
-
-		/* Do VLAN tag insertion */
-		if (unlikely(txm->ol_flags & PKT_TX_VLAN_PKT)) {
-			error = rte_vlan_insert(&txm);
-			if (unlikely(error)) {
-				rte_pktmbuf_free(txm);
-				continue;
-			}
-		}
-
-		/* optimize ring usage */
-		if ((vtpci_with_feature(hw, VIRTIO_F_ANY_LAYOUT) ||
-		      vtpci_with_feature(hw, VIRTIO_F_VERSION_1)) &&
-		    rte_mbuf_refcnt_read(txm) == 1 &&
-		    RTE_MBUF_DIRECT(txm) &&
-		    txm->nb_segs == 1 &&
-		    rte_pktmbuf_headroom(txm) >= hdr_size &&
-		    rte_is_aligned(rte_pktmbuf_mtod(txm, char *),
-				   __alignof__(struct virtio_net_hdr_mrg_rxbuf)))
-			can_push = 1;
-		else if (vtpci_with_feature(hw, VIRTIO_RING_F_INDIRECT_DESC) &&
-			 txm->nb_segs < VIRTIO_MAX_TX_INDIRECT)
-			use_indirect = 1;
+		int slots, need;
 
 		/* How many main ring entries are needed to this Tx?
 		 * any_layout => number of segments
 		 * indirect   => 1
 		 * default    => number of segments + 1
 		 */
-		slots = use_indirect ? 1 : (txm->nb_segs + !can_push);
+		slots =txm->nb_segs + 1;
 		need = slots - vq->vq_free_cnt;
 
 		/* Positive value indicates it need free vring descriptors */
@@ -1079,7 +915,7 @@
 		}
 
 		/* Enqueue Packet buffers */
-		virtqueue_enqueue_xmit(txvq, txm, slots, use_indirect, can_push);
+		virtqueue_enqueue_xmit(txvq, txm, slots);
 
 		txvq->stats.bytes += txm->pkt_len;
 		virtio_update_packet_stats(&txvq->stats, txm);
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [dpdk-dev] [RFC PATCH 10/11] vhost: prefetch desc
  2017-05-05 13:57 [dpdk-dev] [RFC PATCH 00/11] net/virtio: packed ring layout Jens Freimann
                   ` (8 preceding siblings ...)
  2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 09/11] xxx: virtio: remove overheads Jens Freimann
@ 2017-05-05 13:57 ` Jens Freimann
  2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 11/11] add virtio 1.1 test guide Jens Freimann
  2017-05-08  5:02 ` [dpdk-dev] [RFC PATCH 00/11] net/virtio: packed ring layout Yuanhan Liu
  11 siblings, 0 replies; 18+ messages in thread
From: Jens Freimann @ 2017-05-05 13:57 UTC (permalink / raw)
  To: yuanhan.liu; +Cc: dev

From: Yuanhan Liu <yuanhan.liu@linux.intel.com>

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
---
 lib/librte_vhost/virtio_net.c | 36 +++++++++++++++++++++++++++++-------
 1 file changed, 29 insertions(+), 7 deletions(-)

diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index c9e466f..b4d9031 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -974,10 +974,10 @@ static inline bool __attribute__((always_inline))
 	return true;
 }
 
-static inline uint16_t
+static inline uint16_t __attribute__((always_inline))
 dequeue_desc(struct virtio_net *dev, struct vhost_virtqueue *vq,
 	     struct rte_mempool *mbuf_pool, struct rte_mbuf *m,
-	     struct vring_desc_1_1 *descs)
+	     struct vring_desc_1_1 *descs, uint16_t *desc_idx)
 {
 	struct vring_desc_1_1 *desc;
 	uint64_t desc_addr;
@@ -986,7 +986,7 @@ static inline bool __attribute__((always_inline))
 	uint32_t cpy_len;
 	struct rte_mbuf *cur = m, *prev = m;
 	struct virtio_net_hdr *hdr = NULL;
-	uint16_t head_idx = vq->last_used_idx;
+	uint16_t head_idx = *desc_idx;
 
 	desc = &descs[(head_idx++) & (vq->size - 1)];
 	if (unlikely((desc->len < dev->vhost_hlen)) ||
@@ -1114,7 +1114,7 @@ static inline bool __attribute__((always_inline))
 	if (hdr)
 		vhost_dequeue_offload(hdr, m);
 
-	vq->last_used_idx = head_idx;
+	*desc_idx = head_idx;
 
 	return 0;
 }
@@ -1128,11 +1128,32 @@ static inline bool __attribute__((always_inline))
 	uint16_t idx;
 	struct vring_desc_1_1 *desc = vq->desc_1_1;
 	uint16_t head_idx = vq->last_used_idx;
+	struct vring_desc_1_1 desc_cached[64];
+	uint16_t desc_idx = 0;
+
+	idx = vq->last_used_idx & (vq->size - 1);
+	if (!(desc[idx].flags & DESC_HW))
+		return 0;
 
 	count = RTE_MIN(MAX_PKT_BURST, count);
+
+	{
+		uint16_t size = vq->size - idx;
+		if (size >= 64)
+			rte_memcpy(&desc_cached[0],    &desc[idx], 64 * sizeof(struct vring_desc_1_1));
+		else {
+			rte_memcpy(&desc_cached[0],    &desc[idx], size * sizeof(struct vring_desc_1_1));
+			rte_memcpy(&desc_cached[size], &desc[0],   (64 - size) * sizeof(struct vring_desc_1_1));
+		}
+	}
+
+	//for (i = 0; i < 64; i++) {
+	//	idx = (vq->last_used_idx + i) & (vq->size - 1);
+	//	desc_cached[i] = desc[idx];
+	//}
+
 	for (i = 0; i < count; i++) {
-		idx = vq->last_used_idx & (vq->size - 1);
-		if (!(desc[idx].flags & DESC_HW))
+		if (!(desc_cached[desc_idx].flags & DESC_HW))
 			break;
 
 		pkts[i] = rte_pktmbuf_alloc(mbuf_pool);
@@ -1142,9 +1163,10 @@ static inline bool __attribute__((always_inline))
 			break;
 		}
 
-		dequeue_desc(dev, vq, mbuf_pool, pkts[i], desc);
+		dequeue_desc(dev, vq, mbuf_pool, pkts[i], desc_cached, &desc_idx);
 	}
 
+	vq->last_used_idx += desc_idx;
 	if (likely(i)) {
 		for (idx = 1; idx < (uint16_t)(vq->last_used_idx - head_idx); idx++) {
 			desc[(idx + head_idx) & (vq->size - 1)].flags = 0;
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [dpdk-dev] [RFC PATCH 11/11] add virtio 1.1 test guide
  2017-05-05 13:57 [dpdk-dev] [RFC PATCH 00/11] net/virtio: packed ring layout Jens Freimann
                   ` (9 preceding siblings ...)
  2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 10/11] vhost: prefetch desc Jens Freimann
@ 2017-05-05 13:57 ` Jens Freimann
  2017-05-08  5:02 ` [dpdk-dev] [RFC PATCH 00/11] net/virtio: packed ring layout Yuanhan Liu
  11 siblings, 0 replies; 18+ messages in thread
From: Jens Freimann @ 2017-05-05 13:57 UTC (permalink / raw)
  To: yuanhan.liu; +Cc: dev

From: Yuanhan Liu <yuanhan.liu@linux.intel.com>

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
---
 README-virtio-1.1 | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 README-virtio-1.1

diff --git a/README-virtio-1.1 b/README-virtio-1.1
new file mode 100644
index 0000000..8af3eb3
--- /dev/null
+++ b/README-virtio-1.1
@@ -0,0 +1,50 @@
+This branch implements a very rough virtio 1.1 prototpye: only the Tx path has
+been implemented. And below are the test scripts and guidelines for testing:
+
+- build DPDK
+
+  $ export RTE_SDK=/path/to/dpdk/src
+  $ export RTE_TARGET=x86_64-native-linuxapp-gcc
+  $ make install T=$RTE_TARGET
+
+- run host.sh
+
+- run virtio-user.sh
+  execute 'start' inside the pmd
+  execute 'show port stats all' (2 or more times) to see the throughtput.
+
+Note: both scripts should run on the same machine.
+
+You could also set "version_1_1=0" at virtio-user.sh to test
+the difference between virtio 1.1 and virtio 0.95/1.0.
+
+---
+[yliu@yliu-dev ~]$ cat /tmp/host.sh
+#!/bin/bash
+
+[ "$gdb" ] && gdb="gdb --args"
+
+rm -f vhost-net
+
+sudo $gdb $RTE_SDK/x86_64-native-linuxapp-gcc/app/testpmd \
+        -c 0x5 -n 4 --socket-mem 2048,0 \
+        --no-pci --file-prefix=vhost            \
+        --vdev 'net_vhost0,iface=/tmp/vhost-net' \
+        -- \
+        --forward-mode=rxonly \
+        #-i
+
+
+[yliu@yliu-dev ~]$ cat /tmp/virtio-user.sh
+#!/bin/bash
+
+[ "$gdb" ] && gdb="gdb --args"
+
+sudo $gdb $RTE_SDK/x86_64-native-linuxapp-gcc/app/testpmd       \
+        -c 0x9 -n 4 --socket-mem 2048,0 \
+        --no-pci --file-prefix=virtio           \
+        --vdev=net_virtio_user0,mac=52:54:00:00:00:15,path=/tmp/vhost-net,version_1_1=1 \
+        -- \
+        --forward-mode=txonly \
+        --disable-hw-vlan --no-flush-rx \
+        -i
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [dpdk-dev] [RFC PATCH 00/11] net/virtio: packed ring layout
  2017-05-05 13:57 [dpdk-dev] [RFC PATCH 00/11] net/virtio: packed ring layout Jens Freimann
                   ` (10 preceding siblings ...)
  2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 11/11] add virtio 1.1 test guide Jens Freimann
@ 2017-05-08  5:02 ` Yuanhan Liu
  2017-05-08  7:36   ` Jens Freimann
  2017-05-17 11:30   ` Jens Freimann
  11 siblings, 2 replies; 18+ messages in thread
From: Yuanhan Liu @ 2017-05-08  5:02 UTC (permalink / raw)
  To: Jens Freimann; +Cc: dev

On Fri, May 05, 2017 at 09:57:11AM -0400, Jens Freimann wrote:
> Hi Yuanhan,
> 
> I rebased your patches on next-virtio/for-testing to current master,
> made sure every patch compiles and still works. 

Thanks for that.

> I'm implementing the receive path now to eventually get some benchmark
> results for that as well (Patches not included yet)

Good to know. Any progress? I'm asking because that was also my plan for
this week: make Rx work. I haven't started it though.

	--yliu

> Any comments to the existing patches are welcome, I will change them accordingly.
> 
> regards,
> Jens  
> 
> 
> 
> Yuanhan Liu (11):
>   net/virtio: vring init for 1.1
>   net/virtio: implement 1.1 guest Tx
>   net/virtio-user: add option to enable 1.1
>   vhost: enable 1.1 for testing
>   vhost: set desc addr for 1.1
>   vhost: implement virtio 1.1 dequeue path
>   vhost: mark desc being used
>   xxx: batch the desc_hw update?
>   xxx: virtio: remove overheads
>   vhost: prefetch desc
>   add virtio 1.1 test guide
> 
>  README-virtio-1.1                                |  50 ++++++
>  drivers/net/virtio/Makefile                      |   1 +
>  drivers/net/virtio/virtio-1.1.h                  |  19 +++
>  drivers/net/virtio/virtio_ethdev.c               |  44 +++--
>  drivers/net/virtio/virtio_ethdev.h               |   3 +
>  drivers/net/virtio/virtio_pci.h                  |   7 +
>  drivers/net/virtio/virtio_ring.h                 |  15 +-
>  drivers/net/virtio/virtio_rxtx.c                 | 191 ++-------------------
>  drivers/net/virtio/virtio_rxtx_1.1.c             | 161 ++++++++++++++++++
>  drivers/net/virtio/virtio_user/virtio_user_dev.c |   9 +-
>  drivers/net/virtio/virtio_user/virtio_user_dev.h |   3 +-
>  drivers/net/virtio/virtio_user_ethdev.c          |  14 +-
>  drivers/net/virtio/virtqueue.h                   |  10 ++
>  lib/librte_vhost/vhost.h                         |   5 +
>  lib/librte_vhost/vhost_user.c                    |   1 +
>  lib/librte_vhost/virtio-1.1.h                    |  23 +++
>  lib/librte_vhost/virtio_net.c                    | 208 +++++++++++++++++++++++
>  17 files changed, 567 insertions(+), 197 deletions(-)
>  create mode 100644 README-virtio-1.1
>  create mode 100644 drivers/net/virtio/virtio-1.1.h
>  create mode 100644 drivers/net/virtio/virtio_rxtx_1.1.c
>  create mode 100644 lib/librte_vhost/virtio-1.1.h
> 
> -- 
> 1.8.3.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [dpdk-dev] [RFC PATCH 00/11] net/virtio: packed ring layout
  2017-05-08  5:02 ` [dpdk-dev] [RFC PATCH 00/11] net/virtio: packed ring layout Yuanhan Liu
@ 2017-05-08  7:36   ` Jens Freimann
  2017-05-17 11:30   ` Jens Freimann
  1 sibling, 0 replies; 18+ messages in thread
From: Jens Freimann @ 2017-05-08  7:36 UTC (permalink / raw)
  To: Yuanhan Liu; +Cc: dev

On Mon, May 08, 2017 at 01:02:57PM +0800, Yuanhan Liu wrote:
> On Fri, May 05, 2017 at 09:57:11AM -0400, Jens Freimann wrote:
> > Hi Yuanhan,
> > 
> > I rebased your patches on next-virtio/for-testing to current master,
> > made sure every patch compiles and still works. 
> 
> Thanks for that.
> 
> > I'm implementing the receive path now to eventually get some benchmark
> > results for that as well (Patches not included yet)
> 
> Good to know. Any progress? I'm asking because that was also my plan for
> this week: make Rx work. I haven't started it though.

Nothing worth showing yet, I'm still figuring things out and will
most likely need a few more days before I have a first prototype.

regards,
Jens 

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [dpdk-dev] [RFC PATCH 00/11] net/virtio: packed ring layout
  2017-05-08  5:02 ` [dpdk-dev] [RFC PATCH 00/11] net/virtio: packed ring layout Yuanhan Liu
  2017-05-08  7:36   ` Jens Freimann
@ 2017-05-17 11:30   ` Jens Freimann
  2017-05-18 14:24     ` Yuanhan Liu
  1 sibling, 1 reply; 18+ messages in thread
From: Jens Freimann @ 2017-05-17 11:30 UTC (permalink / raw)
  To: Yuanhan Liu; +Cc: dev

Hi Yuanhan,

On Mon, May 08, 2017 at 01:02:57PM +0800, Yuanhan Liu wrote:
> On Fri, May 05, 2017 at 09:57:11AM -0400, Jens Freimann wrote:
> > I'm implementing the receive path now to eventually get some benchmark
> > results for that as well (Patches not included yet)
> 
> Good to know. Any progress? I'm asking because that was also my plan for
> this week: make Rx work. I haven't started it though.

just curious if you already had a chance to work on this? 

regards,
Jens 

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [dpdk-dev] [RFC PATCH 00/11] net/virtio: packed ring layout
  2017-05-17 11:30   ` Jens Freimann
@ 2017-05-18 14:24     ` Yuanhan Liu
  2017-05-22  9:14       ` Yuanhan Liu
  0 siblings, 1 reply; 18+ messages in thread
From: Yuanhan Liu @ 2017-05-18 14:24 UTC (permalink / raw)
  To: Jens Freimann; +Cc: dev

On Wed, May 17, 2017 at 01:30:21PM +0200, Jens Freimann wrote:
> Hi Yuanhan,
> 
> On Mon, May 08, 2017 at 01:02:57PM +0800, Yuanhan Liu wrote:
> > On Fri, May 05, 2017 at 09:57:11AM -0400, Jens Freimann wrote:
> > > I'm implementing the receive path now to eventually get some benchmark
> > > results for that as well (Patches not included yet)
> > 
> > Good to know. Any progress? I'm asking because that was also my plan for
> > this week: make Rx work. I haven't started it though.
> 
> just curious if you already had a chance to work on this? 

Yes, I made it work this Tue. I will try to share it tomorrow. I was on
vacation though.

	--yliu

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [dpdk-dev] [RFC PATCH 00/11] net/virtio: packed ring layout
  2017-05-18 14:24     ` Yuanhan Liu
@ 2017-05-22  9:14       ` Yuanhan Liu
  2017-05-22  9:23         ` Jens Freimann
  0 siblings, 1 reply; 18+ messages in thread
From: Yuanhan Liu @ 2017-05-22  9:14 UTC (permalink / raw)
  To: Jens Freimann; +Cc: Maxime Coquelin, dev

On Thu, May 18, 2017 at 10:24:07PM +0800, Yuanhan Liu wrote:
> On Wed, May 17, 2017 at 01:30:21PM +0200, Jens Freimann wrote:
> > Hi Yuanhan,
> > 
> > On Mon, May 08, 2017 at 01:02:57PM +0800, Yuanhan Liu wrote:
> > > On Fri, May 05, 2017 at 09:57:11AM -0400, Jens Freimann wrote:
> > > > I'm implementing the receive path now to eventually get some benchmark
> > > > results for that as well (Patches not included yet)
> > > 
> > > Good to know. Any progress? I'm asking because that was also my plan for
> > > this week: make Rx work. I haven't started it though.
> > 
> > just curious if you already had a chance to work on this? 
> 
> Yes, I made it work this Tue. I will try to share it tomorrow. I was on
> vacation though.

I have pushed it to the "for-testing" branch at dpdk-next-virtio tree.

	--yliu

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [dpdk-dev] [RFC PATCH 00/11] net/virtio: packed ring layout
  2017-05-22  9:14       ` Yuanhan Liu
@ 2017-05-22  9:23         ` Jens Freimann
  0 siblings, 0 replies; 18+ messages in thread
From: Jens Freimann @ 2017-05-22  9:23 UTC (permalink / raw)
  To: Yuanhan Liu; +Cc: Maxime Coquelin, dev

On Mon, May 22, 2017 at 05:14:54PM +0800, Yuanhan Liu wrote:
> On Thu, May 18, 2017 at 10:24:07PM +0800, Yuanhan Liu wrote:
> > On Wed, May 17, 2017 at 01:30:21PM +0200, Jens Freimann wrote:
> > > Hi Yuanhan,
> > > 
> > > On Mon, May 08, 2017 at 01:02:57PM +0800, Yuanhan Liu wrote:
> > > > On Fri, May 05, 2017 at 09:57:11AM -0400, Jens Freimann wrote:
> > > > > I'm implementing the receive path now to eventually get some benchmark
> > > > > results for that as well (Patches not included yet)
> > > > 
> > > > Good to know. Any progress? I'm asking because that was also my plan for
> > > > this week: make Rx work. I haven't started it though.
> > > 
> > > just curious if you already had a chance to work on this? 
> > 
> > Yes, I made it work this Tue. I will try to share it tomorrow. I was on
> > vacation though.
> 
> I have pushed it to the "for-testing" branch at dpdk-next-virtio tree.

Thanks! I'll take a look.

regards,
Jens

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2017-05-22  9:23 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-05 13:57 [dpdk-dev] [RFC PATCH 00/11] net/virtio: packed ring layout Jens Freimann
2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 01/11] net/virtio: vring init for 1.1 Jens Freimann
2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 02/11] net/virtio: implement 1.1 guest Tx Jens Freimann
2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 03/11] net/virtio-user: add option to enable 1.1 Jens Freimann
2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 04/11] vhost: enable 1.1 for testing Jens Freimann
2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 05/11] vhost: set desc addr for 1.1 Jens Freimann
2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 06/11] vhost: implement virtio 1.1 dequeue path Jens Freimann
2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 07/11] vhost: mark desc being used Jens Freimann
2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 08/11] xxx: batch the desc_hw update? Jens Freimann
2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 09/11] xxx: virtio: remove overheads Jens Freimann
2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 10/11] vhost: prefetch desc Jens Freimann
2017-05-05 13:57 ` [dpdk-dev] [RFC PATCH 11/11] add virtio 1.1 test guide Jens Freimann
2017-05-08  5:02 ` [dpdk-dev] [RFC PATCH 00/11] net/virtio: packed ring layout Yuanhan Liu
2017-05-08  7:36   ` Jens Freimann
2017-05-17 11:30   ` Jens Freimann
2017-05-18 14:24     ` Yuanhan Liu
2017-05-22  9:14       ` Yuanhan Liu
2017-05-22  9:23         ` Jens Freimann

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).