From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by dpdk.org (Postfix) with ESMTP id C231034F0 for ; Wed, 28 Mar 2018 11:11:59 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2AE5984256; Wed, 28 Mar 2018 09:11:59 +0000 (UTC) Received: from [10.36.112.44] (ovpn-112-44.ams2.redhat.com [10.36.112.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 78E7610B2B34; Wed, 28 Mar 2018 09:11:57 +0000 (UTC) To: Tomasz Kulasek , yliu@fridaylinux.org Cc: daniel.verkamp@intel.com, james.r.harris@intel.com, pawelx.wodkowski@intel.com, dev@dpdk.org, Changpeng Liu , Jianfeng Tan References: <20180327151737.6640-1-tomaszx.kulasek@intel.com> <20180327153500.10464-1-tomaszx.kulasek@intel.com> From: Maxime Coquelin Message-ID: <6c556086-bccc-1e55-d490-c21bcc8a6c4b@redhat.com> Date: Wed, 28 Mar 2018 11:11:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180327153500.10464-1-tomaszx.kulasek@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 28 Mar 2018 09:11:59 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 28 Mar 2018 09:11:59 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'maxime.coquelin@redhat.com' RCPT:'' Subject: Re: [dpdk-dev] [PATCH v2] vhost: add virtio configuration space messages X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Mar 2018 09:12:00 -0000 On 03/27/2018 05:35 PM, Tomasz Kulasek wrote: > This patch adds new vhost user messages GET_CONFIG and SET_CONFIG used > for get/set virtio device's configuration space. > > Signed-off-by: Changpeng Liu > Signed-off-by: Tomasz Kulasek > --- > Changes in v2: > - code cleanup > > lib/librte_vhost/rte_vhost.h | 4 ++++ > lib/librte_vhost/vhost_user.c | 22 ++++++++++++++++++++++ > lib/librte_vhost/vhost_user.h | 16 ++++++++++++++++ > 3 files changed, 42 insertions(+) > > diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h > index d332069..fe30518 100644 > --- a/lib/librte_vhost/rte_vhost.h > +++ b/lib/librte_vhost/rte_vhost.h > @@ -84,6 +84,10 @@ struct vhost_device_ops { > int (*new_connection)(int vid); > void (*destroy_connection)(int vid); > > + int (*get_config)(int vid, uint8_t *config, uint32_t config_len); > + int (*set_config)(int vid, uint8_t *config, uint32_t offset, > + uint32_t len, uint32_t flags); > + > void *reserved[2]; /**< Reserved for future extension */ You are breaking the ABI, as you grow the size of the ops struct. Also, I'm wondering if we shouldn't have a different ops for external backends. Here these ops are more intended to the application, we could have a specific ops struct for external backends IMHO. > }; > > diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c > index 90ed211..0ed6a5a 100644 > --- a/lib/librte_vhost/vhost_user.c > +++ b/lib/librte_vhost/vhost_user.c > @@ -50,6 +50,8 @@ static const char *vhost_message_str[VHOST_USER_MAX] = { > [VHOST_USER_NET_SET_MTU] = "VHOST_USER_NET_SET_MTU", > [VHOST_USER_SET_SLAVE_REQ_FD] = "VHOST_USER_SET_SLAVE_REQ_FD", > [VHOST_USER_IOTLB_MSG] = "VHOST_USER_IOTLB_MSG", > + [VHOST_USER_GET_CONFIG] = "VHOST_USER_GET_CONFIG", > + [VHOST_USER_SET_CONFIG] = "VHOST_USER_SET_CONFIG", > }; > > static uint64_t > @@ -1355,6 +1357,7 @@ vhost_user_msg_handler(int vid, int fd) > * would cause a dead lock. > */ > switch (msg.request.master) { > + case VHOST_USER_SET_CONFIG: It seems VHOST_USER_GET_CONFIG is missing here. > case VHOST_USER_SET_FEATURES: > case VHOST_USER_SET_PROTOCOL_FEATURES: > case VHOST_USER_SET_OWNER: > @@ -1380,6 +1383,25 @@ vhost_user_msg_handler(int vid, int fd) > } > > switch (msg.request.master) { > + case VHOST_USER_GET_CONFIG: > + if (dev->notify_ops->get_config(dev->vid, Please check ->get_config is set before calling it. > + msg.payload.config.region, > + msg.payload.config.size) != 0) { > + msg.size = sizeof(uint64_t); > + } > + send_vhost_reply(fd, &msg); > + break; > + case VHOST_USER_SET_CONFIG: > + if ((dev->notify_ops->set_config(dev->vid, Ditto. > + msg.payload.config.region, > + msg.payload.config.offset, > + msg.payload.config.size, > + msg.payload.config.flags)) != 0) { > + ret = 1; > + } else { > + ret = 0; > + } ret = dev->notify_ops->set_config instead? > + break; > case VHOST_USER_GET_FEATURES: > msg.payload.u64 = vhost_user_get_features(dev); > msg.size = sizeof(msg.payload.u64); > diff --git a/lib/librte_vhost/vhost_user.h b/lib/librte_vhost/vhost_user.h > index d4bd604..25cc026 100644 > --- a/lib/librte_vhost/vhost_user.h > +++ b/lib/librte_vhost/vhost_user.h > @@ -14,6 +14,11 @@ > > #define VHOST_MEMORY_MAX_NREGIONS 8 > > +/* > + * Maximum size of virtio device config space > + */ > +#define VHOST_USER_MAX_CONFIG_SIZE 256 > + > #define VHOST_USER_PROTOCOL_F_MQ 0 > #define VHOST_USER_PROTOCOL_F_LOG_SHMFD 1 > #define VHOST_USER_PROTOCOL_F_RARP 2 Shouldn't there be a protocol feature associated to these new messages? Else how QEMU knows the backend supports it or not? I looked at QEMU code and indeed no protocol feature associated, that's strange... > @@ -52,12 +57,15 @@ typedef enum VhostUserRequest { > VHOST_USER_NET_SET_MTU = 20, > VHOST_USER_SET_SLAVE_REQ_FD = 21, > VHOST_USER_IOTLB_MSG = 22, > + VHOST_USER_GET_CONFIG = 24, > + VHOST_USER_SET_CONFIG = 25, > VHOST_USER_MAX > } VhostUserRequest; > > typedef enum VhostUserSlaveRequest { > VHOST_USER_SLAVE_NONE = 0, > VHOST_USER_SLAVE_IOTLB_MSG = 1, > + VHOST_USER_SLAVE_CONFIG_CHANGE_MSG = 2, > VHOST_USER_SLAVE_MAX > } VhostUserSlaveRequest; > > @@ -79,6 +87,13 @@ typedef struct VhostUserLog { > uint64_t mmap_offset; > } VhostUserLog; > > +typedef struct VhostUserConfig { > + uint32_t offset; > + uint32_t size; > + uint32_t flags; > + uint8_t region[VHOST_USER_MAX_CONFIG_SIZE]; > +} VhostUserConfig; > + > typedef struct VhostUserMsg { > union { > VhostUserRequest master; > @@ -98,6 +113,7 @@ typedef struct VhostUserMsg { > struct vhost_vring_addr addr; > VhostUserMemory memory; > VhostUserLog log; > + VhostUserConfig config; > struct vhost_iotlb_msg iotlb; > } payload; > int fds[VHOST_MEMORY_MAX_NREGIONS]; >