From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id F1FE7A0A02; Fri, 15 Jan 2021 11:12:31 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 741A4140EB2; Fri, 15 Jan 2021 11:12:31 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mails.dpdk.org (Postfix) with ESMTP id 6EE27140EB0 for ; Fri, 15 Jan 2021 11:12:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610705548; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x0hWD6//SXQDgZXLVHHuFKv9aVSJqaPnEH/2TsywKyY=; b=JQN8Otq/E6ORffMPz8wj/jfl1GFLmCXTTcmkSh7DX4Hk0cIuIuf+8FaVkZwvKobpYBC3ZZ +EQK3iVtpAan9vMJNGBDS9+4Jki0q6UswJNYNzZXktp7LieGClf58jKTUS2tTRc7SALShd WtjAM55aXGHB52xiYg2FTLgo+xJcEF4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-315-5cgvD-isNNaa6-WQiRBY9Q-1; Fri, 15 Jan 2021 05:12:27 -0500 X-MC-Unique: 5cgvD-isNNaa6-WQiRBY9Q-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0453A15726; Fri, 15 Jan 2021 10:12:26 +0000 (UTC) Received: from [10.36.110.24] (unknown [10.36.110.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6C2B85C1A3; Fri, 15 Jan 2021 10:12:21 +0000 (UTC) To: "Xia, Chenbo" , "dev@dpdk.org" , "olivier.matz@6wind.com" , "amorenoz@redhat.com" , "david.marchand@redhat.com" References: <20201220211405.313012-1-maxime.coquelin@redhat.com> <20201220211405.313012-29-maxime.coquelin@redhat.com> From: Maxime Coquelin Message-ID: <9b0ae40e-eefa-6b7d-c25f-6d4a21fd0bac@redhat.com> Date: Fri, 15 Jan 2021 11:12:19 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH 28/40] net/virtio: add Virtio-user vring setting ops X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 1/6/21 1:01 PM, Xia, Chenbo wrote: > Hi Maxime, > >> -----Original Message----- >> From: Maxime Coquelin >> Sent: Monday, December 21, 2020 5:14 AM >> To: dev@dpdk.org; Xia, Chenbo ; olivier.matz@6wind.com; >> amorenoz@redhat.com; david.marchand@redhat.com >> Cc: Maxime Coquelin >> Subject: [PATCH 28/40] net/virtio: add Virtio-user vring setting ops >> >> This patch introduces new callbacks for setting >> and getting vring state. >> >> Signed-off-by: Maxime Coquelin >> --- >> drivers/net/virtio/virtio_user/vhost.h | 4 + >> drivers/net/virtio/virtio_user/vhost_kernel.c | 49 +++++++- >> drivers/net/virtio/virtio_user/vhost_user.c | 114 +++++++++++++----- >> drivers/net/virtio/virtio_user/vhost_vdpa.c | 40 ++++-- >> .../net/virtio/virtio_user/virtio_user_dev.c | 9 +- >> 5 files changed, 168 insertions(+), 48 deletions(-) >> >> diff --git a/drivers/net/virtio/virtio_user/vhost.h >> b/drivers/net/virtio/virtio_user/vhost.h >> index 0a582a6844..1385c1563b 100644 >> --- a/drivers/net/virtio/virtio_user/vhost.h >> +++ b/drivers/net/virtio/virtio_user/vhost.h >> @@ -107,6 +107,10 @@ struct virtio_user_backend_ops { >> int (*get_protocol_features)(struct virtio_user_dev *dev, uint64_t >> *features); >> int (*set_protocol_features)(struct virtio_user_dev *dev, uint64_t >> features); >> int (*set_memory_table)(struct virtio_user_dev *dev); >> + int (*set_vring_enable)(struct virtio_user_dev *dev, struct >> vhost_vring_state *state); >> + 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 (*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 2d30f572b6..2f1b4840ee 100644 >> --- a/drivers/net/virtio/virtio_user/vhost_kernel.c >> +++ b/drivers/net/virtio/virtio_user/vhost_kernel.c >> @@ -219,12 +219,49 @@ vhost_kernel_set_memory_table(struct virtio_user_dev >> *dev) >> return -1; >> } >> >> +static int >> +vhost_kernel_set_vring(struct virtio_user_dev *dev, uint64_t req, struct >> vhost_vring_state *state) >> +{ >> + int ret, fd; >> + uint32_t index = state->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_state. Agree. >> + >> + /* Convert from queue index to queue-pair & offset */ >> + fd = dev->vhostfds[state->index / 2]; >> + state->index %= 2; >> + >> + ret = vhost_kernel_ioctl(fd, req, state); >> + if (ret < 0) { >> + PMD_DRV_LOG(ERR, "Failed to set vring (request %lu)", req); > > Seems David has also noticed here: better use PRIu64 here instead of %lu ? Yes, already fixed. Thanks, Maxime > Thanks, > Chenbo > >> + return -1; >> + } >> + >