From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: "Xia, Chenbo" <chenbo.xia@intel.com>,
"dev@dpdk.org" <dev@dpdk.org>,
"Fu, Patrick" <patrick.fu@intel.com>,
"amorenoz@redhat.com" <amorenoz@redhat.com>
Subject: Re: [dpdk-dev] [PATCH 7/7] net/virtio: introduce Vhost-vDPA backend
Date: Thu, 24 Sep 2020 10:07:09 +0200 [thread overview]
Message-ID: <4706c872-5e7c-4815-f7b1-f99aac967f65@redhat.com> (raw)
In-Reply-To: <MN2PR11MB40637BDE1AD9796618DAA3E99C390@MN2PR11MB4063.namprd11.prod.outlook.com>
On 9/24/20 7:25 AM, Xia, Chenbo wrote:
> Hi Maxime,
>
>> -----Original Message-----
>> From: dev <dev-bounces@dpdk.org> On Behalf Of Maxime Coquelin
>> Sent: Friday, September 11, 2020 11:08 PM
>> To: dev@dpdk.org; Fu, Patrick <patrick.fu@intel.com>; amorenoz@redhat.com
>> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
>> Subject: [dpdk-dev] [PATCH 7/7] net/virtio: introduce Vhost-vDPA backend
>>
>> vhost-vDPA is a new virtio backend type introduced by vDPA kernel
>> framework, which provides abstruction to the vDPA devices and
>> exposes an unified control interface through a char dev.
>>
>> This patch adds support to the vhost-vDPA backend. As similar to
>> the existing vhost kernel backend, a set of virtio_user ops were
>> introduced for vhost-vDPA backend to handle device specific operations
>> such as:
>> - device setup
>> - ioctl message handling
>> - queue pair enabling
>> - dma map/unmap
>> vDPA relevant ioctl codes and data structures are also defined in
>> this patch.
>>
>> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
>> ---
>> drivers/net/virtio/meson.build | 1 +
>> drivers/net/virtio/virtio_user/vhost.h | 1 +
>> drivers/net/virtio/virtio_user/vhost_vdpa.c | 310 ++++++++++++++++++
>> .../net/virtio/virtio_user/virtio_user_dev.c | 9 +-
>> 4 files changed, 320 insertions(+), 1 deletion(-)
>> create mode 100644 drivers/net/virtio/virtio_user/vhost_vdpa.c
>>
>> diff --git a/drivers/net/virtio/meson.build
>> b/drivers/net/virtio/meson.build
>> index 3fd6051f4b..eaed46373d 100644
>> --- a/drivers/net/virtio/meson.build
>> +++ b/drivers/net/virtio/meson.build
>> @@ -42,6 +42,7 @@ if is_linux
>
> [snip]
>
>> +static int
>> +vhost_vdpa_ioctl(struct virtio_user_dev *dev,
>> + enum vhost_user_request req,
>> + void *arg)
>> +{
>> + int ret = -1;
>> + uint64_t req_vdpa;
>> + struct vhost_memory_vdpa *vm = NULL;
>> +
>> + PMD_DRV_LOG(INFO, "%s", vhost_msg_strings[req]);
>> +
>> + req_vdpa = vhost_req_user_to_vdpa[req];
>> +
>> + if (req_vdpa == VHOST_SET_MEM_TABLE)
>> + return vhost_vdpa_dma_map_all(dev);
>> +
>> + if (req_vdpa == VHOST_SET_FEATURES) {
>> + /* WORKAROUND */
>> + *(uint64_t *)arg |= 1ULL << VIRTIO_F_IOMMU_PLATFORM;
>> +
>> + /* Multiqueue not supported for now */
>> + *(uint64_t *)arg &= ~(1ULL << VIRTIO_NET_F_MQ);
>> + }
>> +
>> + switch (req_vdpa) {
>> + case VHOST_SET_VRING_NUM:
>> + case VHOST_SET_VRING_ADDR:
>> + case VHOST_SET_VRING_BASE:
>> + case VHOST_GET_VRING_BASE:
>> + case VHOST_SET_VRING_KICK:
>> + case VHOST_SET_VRING_CALL:
>> + *(unsigned int *)arg = *(unsigned int *)arg;
>
> Above line should be deleted?
Yes!
>> + PMD_DRV_LOG(DEBUG, "vhostfd=%d, index=%u",
>> + dev->vhostfd, *(unsigned int *)arg);
>> + break;
>> + default:
>> + break;
>> + }
>> +
>> + ret = ioctl(dev->vhostfd, req_vdpa, arg);
>> +
>> + if (vm)
>> + free(vm);
>
> I think 'vm' is never changed after it's init-ed as NULL. Maybe it
> should be deleted? If it's not needed, the definition of struct
> vhost_memory_vdpa should also be deleted.
Correct, will remove in v2.
>> +
>> + if (ret < 0)
>> + PMD_DRV_LOG(ERR, "%s failed: %s",
>> + vhost_msg_strings[req], strerror(errno));
>> +
>> + return ret;
>> +}
>> +
>> +/**
>> + * Set up environment to talk with a vhost vdpa backend.
>> + *
>> + * @return
>> + * - (-1) if fail to set up;
>> + * - (>=0) if successful.
>> + */
>> +static int
>> +vhost_vdpa_setup(struct virtio_user_dev *dev)
>> +{
>> + uint32_t did = (uint32_t)-1;
>
> I see in kernel, 'did' should be u8:
>
> static long vhost_vdpa_get_device_id(struct vhost_vdpa *v, u8 __user *argp)
>
> So I think here did should be uint8_t?
>
> Besides, there are two coding style issues:
> CHECK:SPACING: spaces preferred around that '*' (ctx:WxV)
> #236: FILE: drivers/net/virtio/virtio_user/vhost_vdpa.c:112:
> +vhost_vdpa_dma_unmap(struct virtio_user_dev *dev, void __rte_unused *addr,
Not sure about this one.
^
>
> CHECK:OPEN_ENDED_LINE: Lines should not end with a '('
> #298: FILE: drivers/net/virtio/virtio_user/vhost_vdpa.c:174:
> + int ret = rte_memseg_contig_walk_thread_unsafe(
Same here.
> Thanks!
> Chenbo
prev parent reply other threads:[~2020-09-24 8:07 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-11 15:07 [dpdk-dev] [PATCH 0/7]virtio-user: introduce vhost-vdpa backend Maxime Coquelin
2020-09-11 15:07 ` [dpdk-dev] [PATCH 1/7] bus/vdev: add DMA mapping ops Maxime Coquelin
2020-09-24 5:25 ` Xia, Chenbo
2020-09-24 7:40 ` Maxime Coquelin
2020-09-11 15:08 ` [dpdk-dev] [PATCH 2/7] net/virtio: introduce DMA ops Maxime Coquelin
2020-09-11 15:08 ` [dpdk-dev] [PATCH 3/7] net/virtio: introduce Vhost-vDPA backend type Maxime Coquelin
2020-09-11 15:08 ` [dpdk-dev] [PATCH 4/7] net/virtio: adapt Virtio-user status size Maxime Coquelin
2020-09-24 5:25 ` Xia, Chenbo
2020-09-24 8:05 ` Maxime Coquelin
2020-09-11 15:08 ` [dpdk-dev] [PATCH 5/7] net/virtio: check protocol feature in user backend Maxime Coquelin
2020-09-11 15:08 ` [dpdk-dev] [PATCH 6/7] net/virtio: split virtio-user start Maxime Coquelin
2020-09-11 15:08 ` [dpdk-dev] [PATCH 7/7] net/virtio: introduce Vhost-vDPA backend Maxime Coquelin
2020-09-24 5:25 ` Xia, Chenbo
2020-09-24 5:43 ` Fu, Patrick
2020-09-24 5:52 ` Xia, Chenbo
2020-09-24 8:07 ` Maxime Coquelin [this message]
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=4706c872-5e7c-4815-f7b1-f99aac967f65@redhat.com \
--to=maxime.coquelin@redhat.com \
--cc=amorenoz@redhat.com \
--cc=chenbo.xia@intel.com \
--cc=dev@dpdk.org \
--cc=patrick.fu@intel.com \
/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).