[dpdk-dev] [PATCH v6 6/7] virtio-user: add new virtual pci driver for virtio

2016-06-06 Thread Tan, Jianfeng
Hi Yuanhan,


On 6/6/2016 4:01 PM, Yuanhan Liu wrote:
> On Thu, Jun 02, 2016 at 09:54:36AM +, Jianfeng Tan wrote:
>> +
>> +desc_addr = (uint64_t)vq->mz->addr;
>> +avail_addr = desc_addr + vq->vq_nentries * sizeof(struct vring_desc);
>> +used_addr = RTE_ALIGN_CEIL(avail_addr + offsetof(struct vring_avail,
>> + ring[vq->vq_nentries]),
>> +   VIRTIO_PCI_VRING_ALIGN);
>> +
>> +dev->vrings[queue_idx].num = vq->vq_nentries;
>> +dev->vrings[queue_idx].desc = (void *)desc_addr;
>> +dev->vrings[queue_idx].avail = (void *)avail_addr;
>> +dev->vrings[queue_idx].used = (void *)used_addr;
> That would break 32 bit build. please also do more build and function
> test, with and without CONFIG_RTE_VIRTIO_VDEV enabled, to make sure
> we will not break anything. I'm sure you will meet build error without
> that option enabled.

Yes, thanks for pointing this out.

>
> BTW, let's be consistent with using VIRTIO_USER_DEV instead of VDEV
> or VIRTIO_VDEV?

OK.

>
> Another thing that might be a bit late to ask is that how about
> removing the vhost-net support? I mean, it's DPDK; if user stick
> to using DPDK virtio-user, he will stick to using DPDK vhost-user
> as well, but not the vhost-net. So, let's keep it being simple
> first. And if there is really a need for vhost-net, we can add it
> back later, easily. Makes sense?

Yes, it makes sense, because from an initial test, I see low 
performance. Or anyone who are willing to use it can comment?

Thanks,
Jianfeng
>
> I also would suggest you do a rebase based on my latest tree.

No problem.

Thanks,
Jianfeng

>
>   --yliu



[dpdk-dev] [PATCH v6 6/7] virtio-user: add new virtual pci driver for virtio

2016-06-06 Thread Yuanhan Liu
On Thu, Jun 02, 2016 at 09:54:36AM +, Jianfeng Tan wrote:
> +
> + desc_addr = (uint64_t)vq->mz->addr;
> + avail_addr = desc_addr + vq->vq_nentries * sizeof(struct vring_desc);
> + used_addr = RTE_ALIGN_CEIL(avail_addr + offsetof(struct vring_avail,
> +  ring[vq->vq_nentries]),
> +VIRTIO_PCI_VRING_ALIGN);
> +
> + dev->vrings[queue_idx].num = vq->vq_nentries;
> + dev->vrings[queue_idx].desc = (void *)desc_addr;
> + dev->vrings[queue_idx].avail = (void *)avail_addr;
> + dev->vrings[queue_idx].used = (void *)used_addr;

That would break 32 bit build. please also do more build and function
test, with and without CONFIG_RTE_VIRTIO_VDEV enabled, to make sure
we will not break anything. I'm sure you will meet build error without
that option enabled.

BTW, let's be consistent with using VIRTIO_USER_DEV instead of VDEV
or VIRTIO_VDEV?

Another thing that might be a bit late to ask is that how about
removing the vhost-net support? I mean, it's DPDK; if user stick
to using DPDK virtio-user, he will stick to using DPDK vhost-user
as well, but not the vhost-net. So, let's keep it being simple
first. And if there is really a need for vhost-net, we can add it
back later, easily. Makes sense?

I also would suggest you do a rebase based on my latest tree.

--yliu


[dpdk-dev] [PATCH v6 6/7] virtio-user: add new virtual pci driver for virtio

2016-06-02 Thread Jianfeng Tan
This patch implements another new instance of struct virtio_pci_ops to
drive the virtio-user virtual device. Instead of rd/wr ioport or PCI
configuration space, this virtual pci driver will rd/wr the virtual
device struct virtio_user_hw, and when necessary, invokes APIs provided
by device emulation later to start/stop the device.

  --
  | -- |
  | | virtio driver  | |> (virtio_user_ethdev.c)
  | -- |
  | |  |
  | -- | -->  virtio-user PMD
  | | device emulate | |
  | || |
  | | vhost adapter  | |
  | -- |
  --
|
|
|
   --
   | vhost backend  |
   --

Signed-off-by: Huawei Xie 
Signed-off-by: Jianfeng Tan 
Acked-by: Neil Horman 
---
 drivers/net/virtio/Makefile |   1 +
 drivers/net/virtio/virtio_pci.h |   1 +
 drivers/net/virtio/virtio_user_ethdev.c | 218 
 3 files changed, 220 insertions(+)
 create mode 100644 drivers/net/virtio/virtio_user_ethdev.c

diff --git a/drivers/net/virtio/Makefile b/drivers/net/virtio/Makefile
index 68068bd..d913df0 100644
--- a/drivers/net/virtio/Makefile
+++ b/drivers/net/virtio/Makefile
@@ -60,6 +60,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_user/vhost.c
 SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_user/vhost_user.c
 SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_user/vhost_kernel.c
 SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_user/virtio_user_dev.c
+SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_user_ethdev.c
 endif

 # this lib depends upon:
diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h
index a76daf7..d10d013 100644
--- a/drivers/net/virtio/virtio_pci.h
+++ b/drivers/net/virtio/virtio_pci.h
@@ -260,6 +260,7 @@ struct virtio_hw {
struct virtio_pci_common_cfg *common_cfg;
struct virtio_net_config *dev_cfg;
const struct virtio_pci_ops *vtpci_ops;
+   void*virtio_user_dev;
 };

 /*
diff --git a/drivers/net/virtio/virtio_user_ethdev.c 
b/drivers/net/virtio/virtio_user_ethdev.c
new file mode 100644
index 000..0ea3f23
--- /dev/null
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -0,0 +1,218 @@
+/*-
+ *   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 
+#include 
+#include 
+
+#include "virtio_logs.h"
+#include "virtio_pci.h"
+#include "virtqueue.h"
+#include "virtio_user/virtio_user_dev.h"
+
+#define virtio_user_get_dev(hw) \
+   ((struct virtio_user_dev *)(hw)->virtio_user_dev);
+
+static void
+virtio_user_read_dev_config(struct virtio_hw *hw, uint64_t offset,
+void *dst, int length)
+{
+   int i;
+   struct virtio_user_dev *dev = virtio_user_get_dev(hw);
+
+   if (offset == offsetof(struct virtio_net_config, mac) &&
+   length == ETHER_ADDR_LEN) {
+   for (i = 0; i < ETHER_ADDR_LEN; ++i)
+   ((uint8_t *)dst)[i] = dev->mac_addr[i];
+   return;
+   }
+
+   if (offset == offsetof(struct virtio_net_config, status))
+   *(uint16_t *)dst = dev->status;
+
+   if (offset == offsetof(struct virtio_net_config, max_virtqueue_pairs))
+   *(uint16_t *)dst =