On 1/6/21 1:04 PM, Xia, Chenbo wrote:
> Hi Maxime,
> 
>> -----Original Message-----
>> From: Maxime Coquelin <maxime.coque...@redhat.com>
>> Sent: Monday, December 21, 2020 5:14 AM
>> To: dev@dpdk.org; Xia, Chenbo <chenbo....@intel.com>; olivier.m...@6wind.com;
>> amore...@redhat.com; david.march...@redhat.com
>> Cc: Maxime Coquelin <maxime.coque...@redhat.com>
>> Subject: [PATCH 29/40] net/virtio: add Virtio-user vring file ops
>>
>> This patch introduces new callbacks for setting
>> vring files (kick and call).
>>
>> Signed-off-by: Maxime Coquelin <maxime.coque...@redhat.com>
>> ---
>>  drivers/net/virtio/virtio_user/vhost.h        |  2 +
>>  drivers/net/virtio/virtio_user/vhost_kernel.c | 41 +++++++++++++++--
>>  drivers/net/virtio/virtio_user/vhost_user.c   | 46 +++++++++++++++++--
>>  drivers/net/virtio/virtio_user/vhost_vdpa.c   | 18 ++++++--
>>  .../net/virtio/virtio_user/virtio_user_dev.c  |  4 +-
>>  5 files changed, 97 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/net/virtio/virtio_user/vhost.h
>> b/drivers/net/virtio/virtio_user/vhost.h
>> index 1385c1563b..b296ee215d 100644
>> --- a/drivers/net/virtio/virtio_user/vhost.h
>> +++ b/drivers/net/virtio/virtio_user/vhost.h
>> @@ -111,6 +111,8 @@ struct virtio_user_backend_ops {
>>      int (*set_vring_num)(struct virtio_user_dev *dev, struct
>> vhost_vring_state *state);
>>      int (*set_vring_base)(struct virtio_user_dev *dev, struct
>> vhost_vring_state *state);
>>      int (*get_vring_base)(struct virtio_user_dev *dev, struct
>> vhost_vring_state *state);
>> +    int (*set_vring_call)(struct virtio_user_dev *dev, struct
>> vhost_vring_file *file);
>> +    int (*set_vring_kick)(struct virtio_user_dev *dev, struct
>> vhost_vring_file *file);
>>      int (*send_request)(struct virtio_user_dev *dev,
>>                          enum vhost_user_request req,
>>                          void *arg);
>> diff --git a/drivers/net/virtio/virtio_user/vhost_kernel.c
>> b/drivers/net/virtio/virtio_user/vhost_kernel.c
>> index 2f1b4840ee..1805aee7f7 100644
>> --- a/drivers/net/virtio/virtio_user/vhost_kernel.c
>> +++ b/drivers/net/virtio/virtio_user/vhost_kernel.c
>> @@ -259,11 +259,44 @@ vhost_kernel_get_vring_base(struct virtio_user_dev 
>> *dev,
>> struct vhost_vring_stat
>>      return vhost_kernel_set_vring(dev, VHOST_GET_VRING_BASE, state);
>>  }
>>
>> +static int
>> +vhost_kernel_set_vring_file(struct virtio_user_dev *dev, uint64_t req,
>> +            struct vhost_vring_file *file)
>> +{
>> +    int ret, fd;
>> +    uint32_t index = file->index;
> 
> Better use 'unsigned int index' here? It can hardly cause problem but I think 
> it's
> better to use the type in struct vhost_vring_file.

Fixed.

>> +
>> +    /* Convert from queue index to queue-pair & offset */
>> +    fd = dev->vhostfds[file->index / 2];
>> +    file->index %= 2;
>> +
>> +    ret = vhost_kernel_ioctl(fd, req, file);
>> +    if (ret < 0) {
>> +            PMD_DRV_LOG(ERR, "Failed to set vring file (request %lu)", req);
> 
> Seems David has also noticed: better use PRIu64 here instead of %lu ?

Yes.
Thanks,
Maxime

> Thanks,
> Chenbo
> 

Reply via email to