DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] vhost: add config change slave msg support
@ 2019-12-02 14:57 Li Feng
  2019-12-04  5:13 ` [dpdk-dev] [PATCH v2] " Li Feng
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: Li Feng @ 2019-12-02 14:57 UTC (permalink / raw)
  To: Maxime Coquelin, Tiwei Bie, Zhihong Wang; +Cc: dev, Li Feng

This msg is used to notify qemu that should get the config of backend.

For example, vhost-user-blk uses this msg to notify guest os the
compacity of backend has changed.

Signed-off-by: Li Feng <fengli@smartx.com>
---
 lib/librte_vhost/vhost_user.c | 31 +++++++++++++++++++++++++++++++
 lib/librte_vhost/vhost_user.h |  2 ++
 2 files changed, 33 insertions(+)

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 0cfb8b792..4126fa32d 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -2840,6 +2840,37 @@ vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm)
 	return 0;
 }
 
+static int
+vhost_user_slave_config_change(struct virtio_net *dev)
+{
+	int ret;
+	struct VhostUserMsg msg = {
+		.request.slave = VHOST_USER_SLAVE_CONFIG_CHANGE_MSG,
+		.flags = VHOST_USER_VERSION,
+		.size = 0,
+	};
+
+	ret = send_vhost_message(dev->slave_req_fd, &msg);
+	if (ret < 0) {
+		RTE_LOG(ERR, VHOST_CONFIG,
+				"Failed to send config change  (%d)\n",
+				ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+int
+rte_vhost_user_slave_config_change(int vid)
+{
+	struct virtio_net *dev;
+	dev = get_device(vid);
+	if (!dev)
+		return -ENODEV;
+	return vhost_user_slave_config_change(dev);
+}
+
 static int vhost_user_slave_set_vring_host_notifier(struct virtio_net *dev,
 						    int index, int fd,
 						    uint64_t offset,
diff --git a/lib/librte_vhost/vhost_user.h b/lib/librte_vhost/vhost_user.h
index 6563f7315..5c1bb2138 100644
--- a/lib/librte_vhost/vhost_user.h
+++ b/lib/librte_vhost/vhost_user.h
@@ -62,6 +62,7 @@ typedef enum 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_VRING_HOST_NOTIFIER_MSG = 3,
 	VHOST_USER_SLAVE_MAX
 } VhostUserSlaveRequest;
@@ -158,6 +159,7 @@ typedef struct VhostUserMsg {
 /* vhost_user.c */
 int vhost_user_msg_handler(int vid, int fd);
 int vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm);
+int rte_vhost_user_slave_config_change(int vid);
 
 /* socket.c */
 int read_fd_message(int sockfd, char *buf, int buflen, int *fds, int max_fds,
-- 
2.11.0


-- 
The SmartX email address is only for business purpose. Any sent message 
that is not related to the business is not authorized or permitted by 
SmartX.
本邮箱为北京志凌海纳科技有限公司(SmartX)工作邮箱. 如本邮箱发出的邮件与工作无关,该邮件未得到本公司任何的明示或默示的授权.



^ permalink raw reply	[flat|nested] 17+ messages in thread

* [dpdk-dev] [PATCH v2] vhost: add config change slave msg support
  2019-12-02 14:57 [dpdk-dev] [PATCH] vhost: add config change slave msg support Li Feng
@ 2019-12-04  5:13 ` Li Feng
  2019-12-04  9:30   ` Tiwei Bie
  2019-12-05  5:38 ` [dpdk-dev] [PATCH v3] " Li Feng
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 17+ messages in thread
From: Li Feng @ 2019-12-04  5:13 UTC (permalink / raw)
  To: Maxime Coquelin, Tiwei Bie, Zhihong Wang; +Cc: dev, Li Feng

This msg is used to notify qemu that should get the config of backend.

For example, vhost-user-blk uses this msg to notify guest os the
compacity of backend has changed.

Signed-off-by: Li Feng <fengli@smartx.com>
---
v2:
* Fix a little log typo.

 lib/librte_vhost/vhost_user.c | 31 +++++++++++++++++++++++++++++++
 lib/librte_vhost/vhost_user.h |  2 ++
 2 files changed, 33 insertions(+)

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 0cfb8b792..10f2e47d5 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -2840,6 +2840,37 @@ vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm)
 	return 0;
 }
 
+static int
+vhost_user_slave_config_change(struct virtio_net *dev)
+{
+	int ret;
+	struct VhostUserMsg msg = {
+		.request.slave = VHOST_USER_SLAVE_CONFIG_CHANGE_MSG,
+		.flags = VHOST_USER_VERSION,
+		.size = 0,
+	};
+
+	ret = send_vhost_message(dev->slave_req_fd, &msg);
+	if (ret < 0) {
+		RTE_LOG(ERR, VHOST_CONFIG,
+				"Failed to send config change (%d)\n",
+				ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+int
+rte_vhost_user_slave_config_change(int vid)
+{
+	struct virtio_net *dev;
+	dev = get_device(vid);
+	if (!dev)
+		return -ENODEV;
+	return vhost_user_slave_config_change(dev);
+}
+
 static int vhost_user_slave_set_vring_host_notifier(struct virtio_net *dev,
 						    int index, int fd,
 						    uint64_t offset,
diff --git a/lib/librte_vhost/vhost_user.h b/lib/librte_vhost/vhost_user.h
index 6563f7315..5c1bb2138 100644
--- a/lib/librte_vhost/vhost_user.h
+++ b/lib/librte_vhost/vhost_user.h
@@ -62,6 +62,7 @@ typedef enum 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_VRING_HOST_NOTIFIER_MSG = 3,
 	VHOST_USER_SLAVE_MAX
 } VhostUserSlaveRequest;
@@ -158,6 +159,7 @@ typedef struct VhostUserMsg {
 /* vhost_user.c */
 int vhost_user_msg_handler(int vid, int fd);
 int vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm);
+int rte_vhost_user_slave_config_change(int vid);
 
 /* socket.c */
 int read_fd_message(int sockfd, char *buf, int buflen, int *fds, int max_fds,
-- 
2.11.0


-- 
The SmartX email address is only for business purpose. Any sent message 
that is not related to the business is not authorized or permitted by 
SmartX.
本邮箱为北京志凌海纳科技有限公司(SmartX)工作邮箱. 如本邮箱发出的邮件与工作无关,该邮件未得到本公司任何的明示或默示的授权.



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-dev] [PATCH v2] vhost: add config change slave msg support
  2019-12-04  5:13 ` [dpdk-dev] [PATCH v2] " Li Feng
@ 2019-12-04  9:30   ` Tiwei Bie
  2019-12-04  9:43     ` Li Feng
  0 siblings, 1 reply; 17+ messages in thread
From: Tiwei Bie @ 2019-12-04  9:30 UTC (permalink / raw)
  To: Li Feng; +Cc: Maxime Coquelin, Zhihong Wang, dev

On Wed, Dec 04, 2019 at 01:13:20PM +0800, Li Feng wrote:
> This msg is used to notify qemu that should get the config of backend.
> 
> For example, vhost-user-blk uses this msg to notify guest os the
> compacity of backend has changed.
> 
> Signed-off-by: Li Feng <fengli@smartx.com>
> ---
> v2:
> * Fix a little log typo.
> 
>  lib/librte_vhost/vhost_user.c | 31 +++++++++++++++++++++++++++++++
>  lib/librte_vhost/vhost_user.h |  2 ++
>  2 files changed, 33 insertions(+)
> 
> diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> index 0cfb8b792..10f2e47d5 100644
> --- a/lib/librte_vhost/vhost_user.c
> +++ b/lib/librte_vhost/vhost_user.c
> @@ -2840,6 +2840,37 @@ vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm)
>  	return 0;
>  }
>  
> +static int
> +vhost_user_slave_config_change(struct virtio_net *dev)
> +{
> +	int ret;
> +	struct VhostUserMsg msg = {
> +		.request.slave = VHOST_USER_SLAVE_CONFIG_CHANGE_MSG,
> +		.flags = VHOST_USER_VERSION,
> +		.size = 0,
> +	};
> +
> +	ret = send_vhost_message(dev->slave_req_fd, &msg);
> +	if (ret < 0) {
> +		RTE_LOG(ERR, VHOST_CONFIG,
> +				"Failed to send config change (%d)\n",
> +				ret);
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +
> +int
> +rte_vhost_user_slave_config_change(int vid)
> +{
> +	struct virtio_net *dev;
> +	dev = get_device(vid);
> +	if (!dev)
> +		return -ENODEV;
> +	return vhost_user_slave_config_change(dev);
> +}
> +
>  static int vhost_user_slave_set_vring_host_notifier(struct virtio_net *dev,
>  						    int index, int fd,
>  						    uint64_t offset,
> diff --git a/lib/librte_vhost/vhost_user.h b/lib/librte_vhost/vhost_user.h
> index 6563f7315..5c1bb2138 100644
> --- a/lib/librte_vhost/vhost_user.h
> +++ b/lib/librte_vhost/vhost_user.h
> @@ -62,6 +62,7 @@ typedef enum 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_VRING_HOST_NOTIFIER_MSG = 3,
>  	VHOST_USER_SLAVE_MAX
>  } VhostUserSlaveRequest;
> @@ -158,6 +159,7 @@ typedef struct VhostUserMsg {
>  /* vhost_user.c */
>  int vhost_user_msg_handler(int vid, int fd);
>  int vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm);
> +int rte_vhost_user_slave_config_change(int vid);

This is supposed to be an API for external backends?

Thanks,
Tiwei

>  
>  /* socket.c */
>  int read_fd_message(int sockfd, char *buf, int buflen, int *fds, int max_fds,
> -- 
> 2.11.0
> 
> 
> -- 
> The SmartX email address is only for business purpose. Any sent message 
> that is not related to the business is not authorized or permitted by 
> SmartX.
> 本邮箱为北京志凌海纳科技有限公司(SmartX)工作邮箱. 如本邮箱发出的邮件与工作无关,该邮件未得到本公司任何的明示或默示的授权.
> 
> 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-dev] [PATCH v2] vhost: add config change slave msg support
  2019-12-04  9:30   ` Tiwei Bie
@ 2019-12-04  9:43     ` Li Feng
  2019-12-05  2:07       ` Tiwei Bie
  0 siblings, 1 reply; 17+ messages in thread
From: Li Feng @ 2019-12-04  9:43 UTC (permalink / raw)
  To: Tiwei Bie; +Cc: Maxime Coquelin, Zhihong Wang, dev

Hi Tiwei,
Thanks for your reply.
Yes, this new API currently is for vhost-user-blk in the SPDK project.

There is a patch in SPDK to use this API.

Thanks,

Feng Li

Tiwei Bie <tiwei.bie@intel.com> 于2019年12月4日周三 下午5:30写道:
>
> On Wed, Dec 04, 2019 at 01:13:20PM +0800, Li Feng wrote:
> > This msg is used to notify qemu that should get the config of backend.
> >
> > For example, vhost-user-blk uses this msg to notify guest os the
> > compacity of backend has changed.
> >
> > Signed-off-by: Li Feng <fengli@smartx.com>
> > ---
> > v2:
> > * Fix a little log typo.
> >
> >  lib/librte_vhost/vhost_user.c | 31 +++++++++++++++++++++++++++++++
> >  lib/librte_vhost/vhost_user.h |  2 ++
> >  2 files changed, 33 insertions(+)
> >
> > diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> > index 0cfb8b792..10f2e47d5 100644
> > --- a/lib/librte_vhost/vhost_user.c
> > +++ b/lib/librte_vhost/vhost_user.c
> > @@ -2840,6 +2840,37 @@ vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm)
> >       return 0;
> >  }
> >
> > +static int
> > +vhost_user_slave_config_change(struct virtio_net *dev)
> > +{
> > +     int ret;
> > +     struct VhostUserMsg msg = {
> > +             .request.slave = VHOST_USER_SLAVE_CONFIG_CHANGE_MSG,
> > +             .flags = VHOST_USER_VERSION,
> > +             .size = 0,
> > +     };
> > +
> > +     ret = send_vhost_message(dev->slave_req_fd, &msg);
> > +     if (ret < 0) {
> > +             RTE_LOG(ERR, VHOST_CONFIG,
> > +                             "Failed to send config change (%d)\n",
> > +                             ret);
> > +             return ret;
> > +     }
> > +
> > +     return 0;
> > +}
> > +
> > +int
> > +rte_vhost_user_slave_config_change(int vid)
> > +{
> > +     struct virtio_net *dev;
> > +     dev = get_device(vid);
> > +     if (!dev)
> > +             return -ENODEV;
> > +     return vhost_user_slave_config_change(dev);
> > +}
> > +
> >  static int vhost_user_slave_set_vring_host_notifier(struct virtio_net *dev,
> >                                                   int index, int fd,
> >                                                   uint64_t offset,
> > diff --git a/lib/librte_vhost/vhost_user.h b/lib/librte_vhost/vhost_user.h
> > index 6563f7315..5c1bb2138 100644
> > --- a/lib/librte_vhost/vhost_user.h
> > +++ b/lib/librte_vhost/vhost_user.h
> > @@ -62,6 +62,7 @@ typedef enum 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_VRING_HOST_NOTIFIER_MSG = 3,
> >       VHOST_USER_SLAVE_MAX
> >  } VhostUserSlaveRequest;
> > @@ -158,6 +159,7 @@ typedef struct VhostUserMsg {
> >  /* vhost_user.c */
> >  int vhost_user_msg_handler(int vid, int fd);
> >  int vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm);
> > +int rte_vhost_user_slave_config_change(int vid);
>
> This is supposed to be an API for external backends?
>
> Thanks,
> Tiwei
>
> >
> >  /* socket.c */
> >  int read_fd_message(int sockfd, char *buf, int buflen, int *fds, int max_fds,
> > --
> > 2.11.0
> >
> >
> > --
> > The SmartX email address is only for business purpose. Any sent message
> > that is not related to the business is not authorized or permitted by
> > SmartX.
> > 本邮箱为北京志凌海纳科技有限公司(SmartX)工作邮箱. 如本邮箱发出的邮件与工作无关,该邮件未得到本公司任何的明示或默示的授权.
> >
> >

-- 
The SmartX email address is only for business purpose. Any sent message 
that is not related to the business is not authorized or permitted by 
SmartX.
本邮箱为北京志凌海纳科技有限公司(SmartX)工作邮箱. 如本邮箱发出的邮件与工作无关,该邮件未得到本公司任何的明示或默示的授权.



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-dev] [PATCH v2] vhost: add config change slave msg support
  2019-12-04  9:43     ` Li Feng
@ 2019-12-05  2:07       ` Tiwei Bie
  2019-12-05  4:01         ` Li Feng
  0 siblings, 1 reply; 17+ messages in thread
From: Tiwei Bie @ 2019-12-05  2:07 UTC (permalink / raw)
  To: Li Feng; +Cc: Maxime Coquelin, Zhihong Wang, dev

On Wed, Dec 04, 2019 at 05:43:50PM +0800, Li Feng wrote:
> Hi Tiwei,
> Thanks for your reply.
> Yes, this new API currently is for vhost-user-blk in the SPDK project.

I see. Thanks for the clarification.
In this case, it should be declared in rte_vhost.h instead
of vhost_user.h which is an internal header. And the symbol
should be added to rte_vhost_version.map as well.

> 
> There is a patch in SPDK to use this API.

Could you share the link to the SPDK patch?

Thanks,
Tiwei

> 
> Thanks,
> 
> Feng Li
> 
> Tiwei Bie <tiwei.bie@intel.com> 于2019年12月4日周三 下午5:30写道:
> >
> > On Wed, Dec 04, 2019 at 01:13:20PM +0800, Li Feng wrote:
> > > This msg is used to notify qemu that should get the config of backend.
> > >
> > > For example, vhost-user-blk uses this msg to notify guest os the
> > > compacity of backend has changed.
> > >
> > > Signed-off-by: Li Feng <fengli@smartx.com>
> > > ---
> > > v2:
> > > * Fix a little log typo.
> > >
> > >  lib/librte_vhost/vhost_user.c | 31 +++++++++++++++++++++++++++++++
> > >  lib/librte_vhost/vhost_user.h |  2 ++
> > >  2 files changed, 33 insertions(+)
> > >
> > > diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> > > index 0cfb8b792..10f2e47d5 100644
> > > --- a/lib/librte_vhost/vhost_user.c
> > > +++ b/lib/librte_vhost/vhost_user.c
> > > @@ -2840,6 +2840,37 @@ vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm)
> > >       return 0;
> > >  }
> > >
> > > +static int
> > > +vhost_user_slave_config_change(struct virtio_net *dev)
> > > +{
> > > +     int ret;
> > > +     struct VhostUserMsg msg = {
> > > +             .request.slave = VHOST_USER_SLAVE_CONFIG_CHANGE_MSG,
> > > +             .flags = VHOST_USER_VERSION,
> > > +             .size = 0,
> > > +     };
> > > +
> > > +     ret = send_vhost_message(dev->slave_req_fd, &msg);
> > > +     if (ret < 0) {
> > > +             RTE_LOG(ERR, VHOST_CONFIG,
> > > +                             "Failed to send config change (%d)\n",
> > > +                             ret);
> > > +             return ret;
> > > +     }
> > > +
> > > +     return 0;
> > > +}
> > > +
> > > +int
> > > +rte_vhost_user_slave_config_change(int vid)
> > > +{
> > > +     struct virtio_net *dev;
> > > +     dev = get_device(vid);
> > > +     if (!dev)
> > > +             return -ENODEV;
> > > +     return vhost_user_slave_config_change(dev);
> > > +}
> > > +
> > >  static int vhost_user_slave_set_vring_host_notifier(struct virtio_net *dev,
> > >                                                   int index, int fd,
> > >                                                   uint64_t offset,
> > > diff --git a/lib/librte_vhost/vhost_user.h b/lib/librte_vhost/vhost_user.h
> > > index 6563f7315..5c1bb2138 100644
> > > --- a/lib/librte_vhost/vhost_user.h
> > > +++ b/lib/librte_vhost/vhost_user.h
> > > @@ -62,6 +62,7 @@ typedef enum 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_VRING_HOST_NOTIFIER_MSG = 3,
> > >       VHOST_USER_SLAVE_MAX
> > >  } VhostUserSlaveRequest;
> > > @@ -158,6 +159,7 @@ typedef struct VhostUserMsg {
> > >  /* vhost_user.c */
> > >  int vhost_user_msg_handler(int vid, int fd);
> > >  int vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm);
> > > +int rte_vhost_user_slave_config_change(int vid);
> >
> > This is supposed to be an API for external backends?
> >
> > Thanks,
> > Tiwei
> >
> > >
> > >  /* socket.c */
> > >  int read_fd_message(int sockfd, char *buf, int buflen, int *fds, int max_fds,
> > > --
> > > 2.11.0
> > >
> > >
> > > --
> > > The SmartX email address is only for business purpose. Any sent message
> > > that is not related to the business is not authorized or permitted by
> > > SmartX.
> > > 本邮箱为北京志凌海纳科技有限公司(SmartX)工作邮箱. 如本邮箱发出的邮件与工作无关,该邮件未得到本公司任何的明示或默示的授权.
> > >
> > >
> 
> -- 
> The SmartX email address is only for business purpose. Any sent message 
> that is not related to the business is not authorized or permitted by 
> SmartX.
> 本邮箱为北京志凌海纳科技有限公司(SmartX)工作邮箱. 如本邮箱发出的邮件与工作无关,该邮件未得到本公司任何的明示或默示的授权.
> 
> 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-dev] [PATCH v2] vhost: add config change slave msg support
  2019-12-05  2:07       ` Tiwei Bie
@ 2019-12-05  4:01         ` Li Feng
  2019-12-05  4:57           ` Tiwei Bie
  0 siblings, 1 reply; 17+ messages in thread
From: Li Feng @ 2019-12-05  4:01 UTC (permalink / raw)
  To: Tiwei Bie; +Cc: Maxime Coquelin, Zhihong Wang, dev

Tiwei Bie <tiwei.bie@intel.com> 于2019年12月5日周四 上午10:06写道:
>
> On Wed, Dec 04, 2019 at 05:43:50PM +0800, Li Feng wrote:
> > Hi Tiwei,
> > Thanks for your reply.
> > Yes, this new API currently is for vhost-user-blk in the SPDK project.
>
> I see. Thanks for the clarification.
> In this case, it should be declared in rte_vhost.h instead
> of vhost_user.h which is an internal header. And the symbol
> should be added to rte_vhost_version.map as well.
>
OK,  one more question, should I add `__rte_experimental` tag before
the declare?

> >
> > There is a patch in SPDK to use this API.
>
> Could you share the link to the SPDK patch?
>
The patch is here:
https://review.gerrithub.io/c/spdk/spdk/+/476704

Thanks.
Feng Li

> Thanks,
> Tiwei
>
> >
> > Thanks,
> >
> > Feng Li
> >
> > Tiwei Bie <tiwei.bie@intel.com> 于2019年12月4日周三 下午5:30写道:
> > >
> > > On Wed, Dec 04, 2019 at 01:13:20PM +0800, Li Feng wrote:
> > > > This msg is used to notify qemu that should get the config of backend.
> > > >
> > > > For example, vhost-user-blk uses this msg to notify guest os the
> > > > compacity of backend has changed.
> > > >
> > > > Signed-off-by: Li Feng <fengli@smartx.com>
> > > > ---
> > > > v2:
> > > > * Fix a little log typo.
> > > >
> > > >  lib/librte_vhost/vhost_user.c | 31 +++++++++++++++++++++++++++++++
> > > >  lib/librte_vhost/vhost_user.h |  2 ++
> > > >  2 files changed, 33 insertions(+)
> > > >
> > > > diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> > > > index 0cfb8b792..10f2e47d5 100644
> > > > --- a/lib/librte_vhost/vhost_user.c
> > > > +++ b/lib/librte_vhost/vhost_user.c
> > > > @@ -2840,6 +2840,37 @@ vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm)
> > > >       return 0;
> > > >  }
> > > >
> > > > +static int
> > > > +vhost_user_slave_config_change(struct virtio_net *dev)
> > > > +{
> > > > +     int ret;
> > > > +     struct VhostUserMsg msg = {
> > > > +             .request.slave = VHOST_USER_SLAVE_CONFIG_CHANGE_MSG,
> > > > +             .flags = VHOST_USER_VERSION,
> > > > +             .size = 0,
> > > > +     };
> > > > +
> > > > +     ret = send_vhost_message(dev->slave_req_fd, &msg);
> > > > +     if (ret < 0) {
> > > > +             RTE_LOG(ERR, VHOST_CONFIG,
> > > > +                             "Failed to send config change (%d)\n",
> > > > +                             ret);
> > > > +             return ret;
> > > > +     }
> > > > +
> > > > +     return 0;
> > > > +}
> > > > +
> > > > +int
> > > > +rte_vhost_user_slave_config_change(int vid)
> > > > +{
> > > > +     struct virtio_net *dev;
> > > > +     dev = get_device(vid);
> > > > +     if (!dev)
> > > > +             return -ENODEV;
> > > > +     return vhost_user_slave_config_change(dev);
> > > > +}
> > > > +
> > > >  static int vhost_user_slave_set_vring_host_notifier(struct virtio_net *dev,
> > > >                                                   int index, int fd,
> > > >                                                   uint64_t offset,
> > > > diff --git a/lib/librte_vhost/vhost_user.h b/lib/librte_vhost/vhost_user.h
> > > > index 6563f7315..5c1bb2138 100644
> > > > --- a/lib/librte_vhost/vhost_user.h
> > > > +++ b/lib/librte_vhost/vhost_user.h
> > > > @@ -62,6 +62,7 @@ typedef enum 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_VRING_HOST_NOTIFIER_MSG = 3,
> > > >       VHOST_USER_SLAVE_MAX
> > > >  } VhostUserSlaveRequest;
> > > > @@ -158,6 +159,7 @@ typedef struct VhostUserMsg {
> > > >  /* vhost_user.c */
> > > >  int vhost_user_msg_handler(int vid, int fd);
> > > >  int vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm);
> > > > +int rte_vhost_user_slave_config_change(int vid);
> > >
> > > This is supposed to be an API for external backends?
> > >
> > > Thanks,
> > > Tiwei
> > >
> > > >
> > > >  /* socket.c */
> > > >  int read_fd_message(int sockfd, char *buf, int buflen, int *fds, int max_fds,
> > > > --
> > > > 2.11.0
> > > >
> > > >
> > > > --
> > > > The SmartX email address is only for business purpose. Any sent message
> > > > that is not related to the business is not authorized or permitted by
> > > > SmartX.
> > > > 本邮箱为北京志凌海纳科技有限公司(SmartX)工作邮箱. 如本邮箱发出的邮件与工作无关,该邮件未得到本公司任何的明示或默示的授权.
> > > >
> > > >
> >
> > --
> > The SmartX email address is only for business purpose. Any sent message
> > that is not related to the business is not authorized or permitted by
> > SmartX.
> > 本邮箱为北京志凌海纳科技有限公司(SmartX)工作邮箱. 如本邮箱发出的邮件与工作无关,该邮件未得到本公司任何的明示或默示的授权.
> >
> >

-- 
The SmartX email address is only for business purpose. Any sent message 
that is not related to the business is not authorized or permitted by 
SmartX.
本邮箱为北京志凌海纳科技有限公司(SmartX)工作邮箱. 如本邮箱发出的邮件与工作无关,该邮件未得到本公司任何的明示或默示的授权.



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-dev] [PATCH v2] vhost: add config change slave msg support
  2019-12-05  4:01         ` Li Feng
@ 2019-12-05  4:57           ` Tiwei Bie
  0 siblings, 0 replies; 17+ messages in thread
From: Tiwei Bie @ 2019-12-05  4:57 UTC (permalink / raw)
  To: Li Feng; +Cc: Maxime Coquelin, Zhihong Wang, dev

On Thu, Dec 05, 2019 at 12:01:55PM +0800, Li Feng wrote:
> Tiwei Bie <tiwei.bie@intel.com> 于2019年12月5日周四 上午10:06写道:
> > On Wed, Dec 04, 2019 at 05:43:50PM +0800, Li Feng wrote:
> > > Hi Tiwei,
> > > Thanks for your reply.
> > > Yes, this new API currently is for vhost-user-blk in the SPDK project.
> >
> > I see. Thanks for the clarification.
> > In this case, it should be declared in rte_vhost.h instead
> > of vhost_user.h which is an internal header. And the symbol
> > should be added to rte_vhost_version.map as well.
> >
> OK,  one more question, should I add `__rte_experimental` tag before
> the declare?

Yeah.

> 
> > >
> > > There is a patch in SPDK to use this API.
> >
> > Could you share the link to the SPDK patch?
> >
> The patch is here:
> https://review.gerrithub.io/c/spdk/spdk/+/476704

Thanks for the link. Will take a closer look.

Thanks,
Tiwei

> 
> Thanks.
> Feng Li
> 
> > Thanks,
> > Tiwei
> >
> > >
> > > Thanks,
> > >
> > > Feng Li
> > >
> > > Tiwei Bie <tiwei.bie@intel.com> 于2019年12月4日周三 下午5:30写道:
> > > >
> > > > On Wed, Dec 04, 2019 at 01:13:20PM +0800, Li Feng wrote:
> > > > > This msg is used to notify qemu that should get the config of backend.
> > > > >
> > > > > For example, vhost-user-blk uses this msg to notify guest os the
> > > > > compacity of backend has changed.
> > > > >
> > > > > Signed-off-by: Li Feng <fengli@smartx.com>
> > > > > ---
> > > > > v2:
> > > > > * Fix a little log typo.
> > > > >
> > > > >  lib/librte_vhost/vhost_user.c | 31 +++++++++++++++++++++++++++++++
> > > > >  lib/librte_vhost/vhost_user.h |  2 ++
> > > > >  2 files changed, 33 insertions(+)
> > > > >
> > > > > diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> > > > > index 0cfb8b792..10f2e47d5 100644
> > > > > --- a/lib/librte_vhost/vhost_user.c
> > > > > +++ b/lib/librte_vhost/vhost_user.c
> > > > > @@ -2840,6 +2840,37 @@ vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm)
> > > > >       return 0;
> > > > >  }
> > > > >
> > > > > +static int
> > > > > +vhost_user_slave_config_change(struct virtio_net *dev)
> > > > > +{
> > > > > +     int ret;
> > > > > +     struct VhostUserMsg msg = {
> > > > > +             .request.slave = VHOST_USER_SLAVE_CONFIG_CHANGE_MSG,
> > > > > +             .flags = VHOST_USER_VERSION,
> > > > > +             .size = 0,
> > > > > +     };
> > > > > +
> > > > > +     ret = send_vhost_message(dev->slave_req_fd, &msg);
> > > > > +     if (ret < 0) {
> > > > > +             RTE_LOG(ERR, VHOST_CONFIG,
> > > > > +                             "Failed to send config change (%d)\n",
> > > > > +                             ret);
> > > > > +             return ret;
> > > > > +     }
> > > > > +
> > > > > +     return 0;
> > > > > +}
> > > > > +
> > > > > +int
> > > > > +rte_vhost_user_slave_config_change(int vid)
> > > > > +{
> > > > > +     struct virtio_net *dev;
> > > > > +     dev = get_device(vid);
> > > > > +     if (!dev)
> > > > > +             return -ENODEV;
> > > > > +     return vhost_user_slave_config_change(dev);
> > > > > +}
> > > > > +
> > > > >  static int vhost_user_slave_set_vring_host_notifier(struct virtio_net *dev,
> > > > >                                                   int index, int fd,
> > > > >                                                   uint64_t offset,
> > > > > diff --git a/lib/librte_vhost/vhost_user.h b/lib/librte_vhost/vhost_user.h
> > > > > index 6563f7315..5c1bb2138 100644
> > > > > --- a/lib/librte_vhost/vhost_user.h
> > > > > +++ b/lib/librte_vhost/vhost_user.h
> > > > > @@ -62,6 +62,7 @@ typedef enum 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_VRING_HOST_NOTIFIER_MSG = 3,
> > > > >       VHOST_USER_SLAVE_MAX
> > > > >  } VhostUserSlaveRequest;
> > > > > @@ -158,6 +159,7 @@ typedef struct VhostUserMsg {
> > > > >  /* vhost_user.c */
> > > > >  int vhost_user_msg_handler(int vid, int fd);
> > > > >  int vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm);
> > > > > +int rte_vhost_user_slave_config_change(int vid);
> > > >
> > > > This is supposed to be an API for external backends?
> > > >
> > > > Thanks,
> > > > Tiwei
> > > >
> > > > >
> > > > >  /* socket.c */
> > > > >  int read_fd_message(int sockfd, char *buf, int buflen, int *fds, int max_fds,
> > > > > --
> > > > > 2.11.0
> > > > >
> > > > >
> > > > > --
> > > > > The SmartX email address is only for business purpose. Any sent message
> > > > > that is not related to the business is not authorized or permitted by
> > > > > SmartX.
> > > > > 本邮箱为北京志凌海纳科技有限公司(SmartX)工作邮箱. 如本邮箱发出的邮件与工作无关,该邮件未得到本公司任何的明示或默示的授权.
> > > > >
> > > > >
> > >
> > > --
> > > The SmartX email address is only for business purpose. Any sent message
> > > that is not related to the business is not authorized or permitted by
> > > SmartX.
> > > 本邮箱为北京志凌海纳科技有限公司(SmartX)工作邮箱. 如本邮箱发出的邮件与工作无关,该邮件未得到本公司任何的明示或默示的授权.
> > >
> > >
> 
> -- 
> The SmartX email address is only for business purpose. Any sent message 
> that is not related to the business is not authorized or permitted by 
> SmartX.
> 本邮箱为北京志凌海纳科技有限公司(SmartX)工作邮箱. 如本邮箱发出的邮件与工作无关,该邮件未得到本公司任何的明示或默示的授权.
> 
> 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [dpdk-dev] [PATCH v3] vhost: add config change slave msg support
  2019-12-02 14:57 [dpdk-dev] [PATCH] vhost: add config change slave msg support Li Feng
  2019-12-04  5:13 ` [dpdk-dev] [PATCH v2] " Li Feng
@ 2019-12-05  5:38 ` Li Feng
  2019-12-11  2:58   ` Li Feng
  2019-12-16  5:06   ` Tiwei Bie
  2019-12-19  8:54 ` [dpdk-dev] [PATCH v4] " Li Feng
  2019-12-20  8:22 ` [dpdk-dev] [PATCH v5] " Li Feng
  3 siblings, 2 replies; 17+ messages in thread
From: Li Feng @ 2019-12-05  5:38 UTC (permalink / raw)
  To: Maxime Coquelin, Tiwei Bie, Zhihong Wang; +Cc: dev, Li Feng

This msg is used to notify qemu that should get the config of backend.

For example, vhost-user-blk uses this msg to notify guest os the
compacity of backend has changed.

Signed-off-by: Li Feng <fengli@smartx.com>
---
v3:
* Move the declare to rte_vhost.h
* Add the symbol in rte_vhost_version.map

v2:
* Fix a little log typo.

 lib/librte_vhost/rte_vhost.h           | 12 ++++++++++++
 lib/librte_vhost/rte_vhost_version.map |  1 +
 lib/librte_vhost/vhost_user.c          | 31 +++++++++++++++++++++++++++++++
 lib/librte_vhost/vhost_user.h          |  1 +
 4 files changed, 45 insertions(+)

diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h
index 7b5dc87c2..fc28da264 100644
--- a/lib/librte_vhost/rte_vhost.h
+++ b/lib/librte_vhost/rte_vhost.h
@@ -977,6 +977,18 @@ __rte_experimental
 int
 rte_vhost_get_vdpa_device_id(int vid);
 
+/**
+ * Notify the guest that should get config from backend.
+ *
+ * @param vid
+ *  vhost device ID
+ * @return
+ *  0 on success, < 0 on failure
+ */
+__rte_experimental
+int
+rte_vhost_user_slave_config_change(int vid);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_vhost/rte_vhost_version.map b/lib/librte_vhost/rte_vhost_version.map
index c512377fe..acf013d6d 100644
--- a/lib/librte_vhost/rte_vhost_version.map
+++ b/lib/librte_vhost/rte_vhost_version.map
@@ -65,4 +65,5 @@ EXPERIMENTAL {
 	rte_vhost_clr_inflight_desc_packed;
 	rte_vhost_get_vhost_ring_inflight;
 	rte_vhost_get_vring_base_from_inflight;
+	rte_vhost_user_slave_config_change;
 };
diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 0cfb8b792..10f2e47d5 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -2840,6 +2840,37 @@ vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm)
 	return 0;
 }
 
+static int
+vhost_user_slave_config_change(struct virtio_net *dev)
+{
+	int ret;
+	struct VhostUserMsg msg = {
+		.request.slave = VHOST_USER_SLAVE_CONFIG_CHANGE_MSG,
+		.flags = VHOST_USER_VERSION,
+		.size = 0,
+	};
+
+	ret = send_vhost_message(dev->slave_req_fd, &msg);
+	if (ret < 0) {
+		RTE_LOG(ERR, VHOST_CONFIG,
+				"Failed to send config change (%d)\n",
+				ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+int
+rte_vhost_user_slave_config_change(int vid)
+{
+	struct virtio_net *dev;
+	dev = get_device(vid);
+	if (!dev)
+		return -ENODEV;
+	return vhost_user_slave_config_change(dev);
+}
+
 static int vhost_user_slave_set_vring_host_notifier(struct virtio_net *dev,
 						    int index, int fd,
 						    uint64_t offset,
diff --git a/lib/librte_vhost/vhost_user.h b/lib/librte_vhost/vhost_user.h
index 6563f7315..86c364a93 100644
--- a/lib/librte_vhost/vhost_user.h
+++ b/lib/librte_vhost/vhost_user.h
@@ -62,6 +62,7 @@ typedef enum 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_VRING_HOST_NOTIFIER_MSG = 3,
 	VHOST_USER_SLAVE_MAX
 } VhostUserSlaveRequest;
-- 
2.11.0


-- 
The SmartX email address is only for business purpose. Any sent message 
that is not related to the business is not authorized or permitted by 
SmartX.
本邮箱为北京志凌海纳科技有限公司(SmartX)工作邮箱. 如本邮箱发出的邮件与工作无关,该邮件未得到本公司任何的明示或默示的授权.



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-dev] [PATCH v3] vhost: add config change slave msg support
  2019-12-05  5:38 ` [dpdk-dev] [PATCH v3] " Li Feng
@ 2019-12-11  2:58   ` Li Feng
  2019-12-16  5:06   ` Tiwei Bie
  1 sibling, 0 replies; 17+ messages in thread
From: Li Feng @ 2019-12-11  2:58 UTC (permalink / raw)
  To: Maxime Coquelin, Tiwei Bie, Zhihong Wang; +Cc: dev

ping, any update about this?

Thanks,

Feng Li

Li Feng <fengli@smartx.com> 于2019年12月5日周四 下午1:38写道:
>
> This msg is used to notify qemu that should get the config of backend.
>
> For example, vhost-user-blk uses this msg to notify guest os the
> compacity of backend has changed.
>
> Signed-off-by: Li Feng <fengli@smartx.com>
> ---
> v3:
> * Move the declare to rte_vhost.h
> * Add the symbol in rte_vhost_version.map
>
> v2:
> * Fix a little log typo.
>
>  lib/librte_vhost/rte_vhost.h           | 12 ++++++++++++
>  lib/librte_vhost/rte_vhost_version.map |  1 +
>  lib/librte_vhost/vhost_user.c          | 31 +++++++++++++++++++++++++++++++
>  lib/librte_vhost/vhost_user.h          |  1 +
>  4 files changed, 45 insertions(+)
>
> diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h
> index 7b5dc87c2..fc28da264 100644
> --- a/lib/librte_vhost/rte_vhost.h
> +++ b/lib/librte_vhost/rte_vhost.h
> @@ -977,6 +977,18 @@ __rte_experimental
>  int
>  rte_vhost_get_vdpa_device_id(int vid);
>
> +/**
> + * Notify the guest that should get config from backend.
> + *
> + * @param vid
> + *  vhost device ID
> + * @return
> + *  0 on success, < 0 on failure
> + */
> +__rte_experimental
> +int
> +rte_vhost_user_slave_config_change(int vid);
> +
>  #ifdef __cplusplus
>  }
>  #endif
> diff --git a/lib/librte_vhost/rte_vhost_version.map b/lib/librte_vhost/rte_vhost_version.map
> index c512377fe..acf013d6d 100644
> --- a/lib/librte_vhost/rte_vhost_version.map
> +++ b/lib/librte_vhost/rte_vhost_version.map
> @@ -65,4 +65,5 @@ EXPERIMENTAL {
>         rte_vhost_clr_inflight_desc_packed;
>         rte_vhost_get_vhost_ring_inflight;
>         rte_vhost_get_vring_base_from_inflight;
> +       rte_vhost_user_slave_config_change;
>  };
> diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> index 0cfb8b792..10f2e47d5 100644
> --- a/lib/librte_vhost/vhost_user.c
> +++ b/lib/librte_vhost/vhost_user.c
> @@ -2840,6 +2840,37 @@ vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm)
>         return 0;
>  }
>
> +static int
> +vhost_user_slave_config_change(struct virtio_net *dev)
> +{
> +       int ret;
> +       struct VhostUserMsg msg = {
> +               .request.slave = VHOST_USER_SLAVE_CONFIG_CHANGE_MSG,
> +               .flags = VHOST_USER_VERSION,
> +               .size = 0,
> +       };
> +
> +       ret = send_vhost_message(dev->slave_req_fd, &msg);
> +       if (ret < 0) {
> +               RTE_LOG(ERR, VHOST_CONFIG,
> +                               "Failed to send config change (%d)\n",
> +                               ret);
> +               return ret;
> +       }
> +
> +       return 0;
> +}
> +
> +int
> +rte_vhost_user_slave_config_change(int vid)
> +{
> +       struct virtio_net *dev;
> +       dev = get_device(vid);
> +       if (!dev)
> +               return -ENODEV;
> +       return vhost_user_slave_config_change(dev);
> +}
> +
>  static int vhost_user_slave_set_vring_host_notifier(struct virtio_net *dev,
>                                                     int index, int fd,
>                                                     uint64_t offset,
> diff --git a/lib/librte_vhost/vhost_user.h b/lib/librte_vhost/vhost_user.h
> index 6563f7315..86c364a93 100644
> --- a/lib/librte_vhost/vhost_user.h
> +++ b/lib/librte_vhost/vhost_user.h
> @@ -62,6 +62,7 @@ typedef enum 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_VRING_HOST_NOTIFIER_MSG = 3,
>         VHOST_USER_SLAVE_MAX
>  } VhostUserSlaveRequest;
> --
> 2.11.0
>

-- 
The SmartX email address is only for business purpose. Any sent message 
that is not related to the business is not authorized or permitted by 
SmartX.
本邮箱为北京志凌海纳科技有限公司(SmartX)工作邮箱. 如本邮箱发出的邮件与工作无关,该邮件未得到本公司任何的明示或默示的授权.



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-dev] [PATCH v3] vhost: add config change slave msg support
  2019-12-05  5:38 ` [dpdk-dev] [PATCH v3] " Li Feng
  2019-12-11  2:58   ` Li Feng
@ 2019-12-16  5:06   ` Tiwei Bie
  2019-12-18  6:34     ` Li Feng
  1 sibling, 1 reply; 17+ messages in thread
From: Tiwei Bie @ 2019-12-16  5:06 UTC (permalink / raw)
  To: Li Feng; +Cc: Maxime Coquelin, Zhihong Wang, dev

On Thu, Dec 05, 2019 at 01:38:33PM +0800, Li Feng wrote:
> This msg is used to notify qemu that should get the config of backend.
> 
> For example, vhost-user-blk uses this msg to notify guest os the
> compacity of backend has changed.

capacity?

> 
> Signed-off-by: Li Feng <fengli@smartx.com>
> ---
> v3:
> * Move the declare to rte_vhost.h
> * Add the symbol in rte_vhost_version.map
> 
> v2:
> * Fix a little log typo.
> 
>  lib/librte_vhost/rte_vhost.h           | 12 ++++++++++++
>  lib/librte_vhost/rte_vhost_version.map |  1 +
>  lib/librte_vhost/vhost_user.c          | 31 +++++++++++++++++++++++++++++++
>  lib/librte_vhost/vhost_user.h          |  1 +
>  4 files changed, 45 insertions(+)
> 
> diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h
> index 7b5dc87c2..fc28da264 100644
> --- a/lib/librte_vhost/rte_vhost.h
> +++ b/lib/librte_vhost/rte_vhost.h
> @@ -977,6 +977,18 @@ __rte_experimental
>  int
>  rte_vhost_get_vdpa_device_id(int vid);
>  
> +/**
> + * Notify the guest that should get config from backend.
> + *
> + * @param vid
> + *  vhost device ID
> + * @return
> + *  0 on success, < 0 on failure
> + */
> +__rte_experimental
> +int
> +rte_vhost_user_slave_config_change(int vid);

Normally the prefix in vhost API is rte_vhost_
not rte_vhost_user_

> +
>  #ifdef __cplusplus
>  }
>  #endif
> diff --git a/lib/librte_vhost/rte_vhost_version.map b/lib/librte_vhost/rte_vhost_version.map
> index c512377fe..acf013d6d 100644
> --- a/lib/librte_vhost/rte_vhost_version.map
> +++ b/lib/librte_vhost/rte_vhost_version.map
> @@ -65,4 +65,5 @@ EXPERIMENTAL {
>  	rte_vhost_clr_inflight_desc_packed;
>  	rte_vhost_get_vhost_ring_inflight;
>  	rte_vhost_get_vring_base_from_inflight;
> +	rte_vhost_user_slave_config_change;
>  };
> diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> index 0cfb8b792..10f2e47d5 100644
> --- a/lib/librte_vhost/vhost_user.c
> +++ b/lib/librte_vhost/vhost_user.c
> @@ -2840,6 +2840,37 @@ vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm)
>  	return 0;
>  }
>  
> +static int
> +vhost_user_slave_config_change(struct virtio_net *dev)
> +{
> +	int ret;
> +	struct VhostUserMsg msg = {
> +		.request.slave = VHOST_USER_SLAVE_CONFIG_CHANGE_MSG,
> +		.flags = VHOST_USER_VERSION,

Will it be better to also set VHOST_USER_NEED_REPLY?

> +		.size = 0,
> +	};
> +
> +	ret = send_vhost_message(dev->slave_req_fd, &msg);
> +	if (ret < 0) {
> +		RTE_LOG(ERR, VHOST_CONFIG,
> +				"Failed to send config change (%d)\n",
> +				ret);

Looks better to indent the code by 3 tabs.

> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +
> +int
> +rte_vhost_user_slave_config_change(int vid)
> +{
> +	struct virtio_net *dev;
> +	dev = get_device(vid);
> +	if (!dev)
> +		return -ENODEV;
> +	return vhost_user_slave_config_change(dev);
> +}

I'm wondering will it be better to provide a generic API
to allow external backends to send any slave messages?

> +
>  static int vhost_user_slave_set_vring_host_notifier(struct virtio_net *dev,
>  						    int index, int fd,
>  						    uint64_t offset,
> diff --git a/lib/librte_vhost/vhost_user.h b/lib/librte_vhost/vhost_user.h
> index 6563f7315..86c364a93 100644
> --- a/lib/librte_vhost/vhost_user.h
> +++ b/lib/librte_vhost/vhost_user.h
> @@ -62,6 +62,7 @@ typedef enum 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_VRING_HOST_NOTIFIER_MSG = 3,
>  	VHOST_USER_SLAVE_MAX
>  } VhostUserSlaveRequest;
> -- 
> 2.11.0
> 
> 
> -- 
> The SmartX email address is only for business purpose. Any sent message 
> that is not related to the business is not authorized or permitted by 
> SmartX.
> 本邮箱为北京志凌海纳科技有限公司(SmartX)工作邮箱. 如本邮箱发出的邮件与工作无关,该邮件未得到本公司任何的明示或默示的授权.
> 
> 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-dev] [PATCH v3] vhost: add config change slave msg support
  2019-12-16  5:06   ` Tiwei Bie
@ 2019-12-18  6:34     ` Li Feng
  0 siblings, 0 replies; 17+ messages in thread
From: Li Feng @ 2019-12-18  6:34 UTC (permalink / raw)
  To: Tiwei Bie; +Cc: Maxime Coquelin, Zhihong Wang, dev, Kyle Zhang

Thanks.

Tiwei Bie <tiwei.bie@intel.com> 于2019年12月16日周一 下午1:05写道:
>
> On Thu, Dec 05, 2019 at 01:38:33PM +0800, Li Feng wrote:
> > This msg is used to notify qemu that should get the config of backend.
> >
> > For example, vhost-user-blk uses this msg to notify guest os the
> > compacity of backend has changed.
>
> capacity?
>
> >
> > Signed-off-by: Li Feng <fengli@smartx.com>
> > ---
> > v3:
> > * Move the declare to rte_vhost.h
> > * Add the symbol in rte_vhost_version.map
> >
> > v2:
> > * Fix a little log typo.
> >
> >  lib/librte_vhost/rte_vhost.h           | 12 ++++++++++++
> >  lib/librte_vhost/rte_vhost_version.map |  1 +
> >  lib/librte_vhost/vhost_user.c          | 31 +++++++++++++++++++++++++++++++
> >  lib/librte_vhost/vhost_user.h          |  1 +
> >  4 files changed, 45 insertions(+)
> >
> > diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h
> > index 7b5dc87c2..fc28da264 100644
> > --- a/lib/librte_vhost/rte_vhost.h
> > +++ b/lib/librte_vhost/rte_vhost.h
> > @@ -977,6 +977,18 @@ __rte_experimental
> >  int
> >  rte_vhost_get_vdpa_device_id(int vid);
> >
> > +/**
> > + * Notify the guest that should get config from backend.
> > + *
> > + * @param vid
> > + *  vhost device ID
> > + * @return
> > + *  0 on success, < 0 on failure
> > + */
> > +__rte_experimental
> > +int
> > +rte_vhost_user_slave_config_change(int vid);
>
> Normally the prefix in vhost API is rte_vhost_
> not rte_vhost_user_
>
> > +
> >  #ifdef __cplusplus
> >  }
> >  #endif
> > diff --git a/lib/librte_vhost/rte_vhost_version.map b/lib/librte_vhost/rte_vhost_version.map
> > index c512377fe..acf013d6d 100644
> > --- a/lib/librte_vhost/rte_vhost_version.map
> > +++ b/lib/librte_vhost/rte_vhost_version.map
> > @@ -65,4 +65,5 @@ EXPERIMENTAL {
> >       rte_vhost_clr_inflight_desc_packed;
> >       rte_vhost_get_vhost_ring_inflight;
> >       rte_vhost_get_vring_base_from_inflight;
> > +     rte_vhost_user_slave_config_change;
> >  };
> > diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> > index 0cfb8b792..10f2e47d5 100644
> > --- a/lib/librte_vhost/vhost_user.c
> > +++ b/lib/librte_vhost/vhost_user.c
> > @@ -2840,6 +2840,37 @@ vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm)
> >       return 0;
> >  }
> >
> > +static int
> > +vhost_user_slave_config_change(struct virtio_net *dev)
> > +{
> > +     int ret;
> > +     struct VhostUserMsg msg = {
> > +             .request.slave = VHOST_USER_SLAVE_CONFIG_CHANGE_MSG,
> > +             .flags = VHOST_USER_VERSION,
>
> Will it be better to also set VHOST_USER_NEED_REPLY?
This feature could not be supported because the vhost thread will
block at the read slave fd,
but qemu have sent a get_config message, and wait for the vhost thread
response, the stack like this:

#2  0x0000555555b435d2 in tcp_chr_recv (chr=chr@entry=0x555556b12c80,
buf=buf@entry=0x7fffffffd7c0 "\030", len=len@entry=12) at
chardev/char-socket.c:332
#3  0x0000555555b44611 in tcp_chr_sync_read (chr=0x555556b12c80,
buf=0x7fffffffd7c0 "\030", len=12) at chardev/char-socket.c:543
#4  0x0000555555b3f5e1 in qemu_chr_fe_read_all
(be=be@entry=0x555557e82310, buf=buf@entry=0x7fffffffd7c0 "\030",
len=len@entry=12) at chardev/char-fe.c:72
#5  0x0000555555884b7b in vhost_user_read_header (dev=0x555557e82310,
msg=0x7fffffffd7c0) at
/usr/src/debug/qemu-4.1.0/hw/virtio/vhost-user.c:236
#6  vhost_user_read (msg=msg@entry=0x7fffffffd7c0, dev=0x555557e82398)
at /usr/src/debug/qemu-4.1.0/hw/virtio/vhost-user.c:261
#7  0x00005555558850ff in vhost_user_get_config (dev=0x555557e82398,
config=0x7fffffffda80 "\340(6WUU", config_len=60)
    at /usr/src/debug/qemu-4.1.0/hw/virtio/vhost-user.c:1636
#8  0x0000555555842880 in vhost_user_blk_handle_config_change
(dev=0x555557e82398) at
/usr/src/debug/qemu-4.1.0/hw/block/vhost-user-blk.c:85
#9  0x0000555555886df1 in vhost_user_slave_handle_config_change
(dev=0x555557e82398) at
/usr/src/debug/qemu-4.1.0/hw/virtio/vhost-user.c:912
#10 slave_read (opaque=0x555557e82398) at
/usr/src/debug/qemu-4.1.0/hw/virtio/vhost-user.c:1050

>
> > +             .size = 0,
> > +     };
> > +
> > +     ret = send_vhost_message(dev->slave_req_fd, &msg);
> > +     if (ret < 0) {
> > +             RTE_LOG(ERR, VHOST_CONFIG,
> > +                             "Failed to send config change (%d)\n",
> > +                             ret);
>
> Looks better to indent the code by 3 tabs.
>
> > +             return ret;
> > +     }
> > +
> > +     return 0;
> > +}
> > +
> > +int
> > +rte_vhost_user_slave_config_change(int vid)
> > +{
> > +     struct virtio_net *dev;
> > +     dev = get_device(vid);
> > +     if (!dev)
> > +             return -ENODEV;
> > +     return vhost_user_slave_config_change(dev);
> > +}
>
> I'm wondering will it be better to provide a generic API
> to allow external backends to send any slave messages?
I have thought about this before, and I don't choose external backend because:
1. Sending slave message is more like an API, and external backend
acts like a hooker that receives messages from master;
If adding a new slave message type, we should also need to add type
definition in the dpdk librte_vhost header.
2. There is only three slave message type;


>
> > +
> >  static int vhost_user_slave_set_vring_host_notifier(struct virtio_net *dev,
> >                                                   int index, int fd,
> >                                                   uint64_t offset,
> > diff --git a/lib/librte_vhost/vhost_user.h b/lib/librte_vhost/vhost_user.h
> > index 6563f7315..86c364a93 100644
> > --- a/lib/librte_vhost/vhost_user.h
> > +++ b/lib/librte_vhost/vhost_user.h
> > @@ -62,6 +62,7 @@ typedef enum 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_VRING_HOST_NOTIFIER_MSG = 3,
> >       VHOST_USER_SLAVE_MAX
> >  } VhostUserSlaveRequest;
> > --
> > 2.11.0
> >
> >
> > --
> > The SmartX email address is only for business purpose. Any sent message
> > that is not related to the business is not authorized or permitted by
> > SmartX.
> > 本邮箱为北京志凌海纳科技有限公司(SmartX)工作邮箱. 如本邮箱发出的邮件与工作无关,该邮件未得到本公司任何的明示或默示的授权.
> >
> >

-- 
The SmartX email address is only for business purpose. Any sent message 
that is not related to the business is not authorized or permitted by 
SmartX.
本邮箱为北京志凌海纳科技有限公司(SmartX)工作邮箱. 如本邮箱发出的邮件与工作无关,该邮件未得到本公司任何的明示或默示的授权.



^ permalink raw reply	[flat|nested] 17+ messages in thread

* [dpdk-dev] [PATCH v4] vhost: add config change slave msg support
  2019-12-02 14:57 [dpdk-dev] [PATCH] vhost: add config change slave msg support Li Feng
  2019-12-04  5:13 ` [dpdk-dev] [PATCH v2] " Li Feng
  2019-12-05  5:38 ` [dpdk-dev] [PATCH v3] " Li Feng
@ 2019-12-19  8:54 ` Li Feng
  2019-12-20  8:04   ` Tiwei Bie
  2019-12-20  8:22 ` [dpdk-dev] [PATCH v5] " Li Feng
  3 siblings, 1 reply; 17+ messages in thread
From: Li Feng @ 2019-12-19  8:54 UTC (permalink / raw)
  To: Maxime Coquelin, Tiwei Bie, Zhihong Wang; +Cc: dev, kyle, Li Feng

This msg is used to notify qemu that should get the config of backend.

For example, vhost-user-blk uses this msg to notify guest os the
capacity of backend has changed.

The need_reply flag is not mandatory because it will block the sender
thread and master process will send get_config message to fetch the
configuration, this need an extra thread to process the vhost message.

Signed-off-by: Li Feng <fengli@smartx.com>
---
v4:
* Fix type and code style.
* Add need_reply support.

v3:
* Move the declare to rte_vhost.h
* Add the symbol in rte_vhost_version.map

v2:
* Fix a little log typo.

 lib/librte_vhost/rte_vhost.h           | 15 +++++++++++++++
 lib/librte_vhost/rte_vhost_version.map |  1 +
 lib/librte_vhost/vhost_user.c          | 35 ++++++++++++++++++++++++++++++++++
 lib/librte_vhost/vhost_user.h          |  1 +
 4 files changed, 52 insertions(+)

diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h
index 7b5dc87c2..c7b619ae0 100644
--- a/lib/librte_vhost/rte_vhost.h
+++ b/lib/librte_vhost/rte_vhost.h
@@ -10,6 +10,7 @@
  * Interface to vhost-user
  */
 
+#include <stdbool.h>
 #include <stdint.h>
 #include <sys/eventfd.h>
 
@@ -977,6 +978,20 @@ __rte_experimental
 int
 rte_vhost_get_vdpa_device_id(int vid);
 
+/**
+ * Notify the guest that should get virtio configuration space from backend.
+ *
+ * @param vid
+ *  vhost device ID
+ * @param need_reply
+ *  wait for the master response the status of this operation
+ * @return
+ *  0 on success, < 0 on failure
+ */
+__rte_experimental
+int
+rte_vhost_slave_config_change(int vid, bool need_reply);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_vhost/rte_vhost_version.map b/lib/librte_vhost/rte_vhost_version.map
index c512377fe..051d08c12 100644
--- a/lib/librte_vhost/rte_vhost_version.map
+++ b/lib/librte_vhost/rte_vhost_version.map
@@ -65,4 +65,5 @@ EXPERIMENTAL {
 	rte_vhost_clr_inflight_desc_packed;
 	rte_vhost_get_vhost_ring_inflight;
 	rte_vhost_get_vring_base_from_inflight;
+	rte_vhost_slave_config_change;
 };
diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 0cfb8b792..aed1210b1 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -2840,6 +2840,41 @@ vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm)
 	return 0;
 }
 
+static int
+vhost_user_slave_config_change(struct virtio_net *dev, bool need_reply)
+{
+	int ret;
+	uint32_t flags = VHOST_USER_VERSION;
+	if (need_reply)
+		flags |= VHOST_USER_NEED_REPLY;
+	struct VhostUserMsg msg = {
+		.request.slave = VHOST_USER_SLAVE_CONFIG_CHANGE_MSG,
+		.flags = flags,
+		.size = 0,
+	};
+
+	ret = send_vhost_slave_message(dev, &msg);
+	if (ret < 0) {
+		RTE_LOG(ERR, VHOST_CONFIG,
+			"Failed to send config change (%d)\n",
+			ret);
+		return ret;
+	}
+	if (need_reply)
+		return process_slave_message_reply(dev, &msg);
+	return 0;
+}
+
+int
+rte_vhost_slave_config_change(int vid, bool need_reply)
+{
+	struct virtio_net *dev;
+	dev = get_device(vid);
+	if (!dev)
+		return -ENODEV;
+	return vhost_user_slave_config_change(dev, need_reply);
+}
+
 static int vhost_user_slave_set_vring_host_notifier(struct virtio_net *dev,
 						    int index, int fd,
 						    uint64_t offset,
diff --git a/lib/librte_vhost/vhost_user.h b/lib/librte_vhost/vhost_user.h
index 6563f7315..86c364a93 100644
--- a/lib/librte_vhost/vhost_user.h
+++ b/lib/librte_vhost/vhost_user.h
@@ -62,6 +62,7 @@ typedef enum 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_VRING_HOST_NOTIFIER_MSG = 3,
 	VHOST_USER_SLAVE_MAX
 } VhostUserSlaveRequest;
-- 
2.11.0


-- 
The SmartX email address is only for business purpose. Any sent message 
that is not related to the business is not authorized or permitted by 
SmartX.
本邮箱为北京志凌海纳科技有限公司(SmartX)工作邮箱. 如本邮箱发出的邮件与工作无关,该邮件未得到本公司任何的明示或默示的授权.



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-dev] [PATCH v4] vhost: add config change slave msg support
  2019-12-19  8:54 ` [dpdk-dev] [PATCH v4] " Li Feng
@ 2019-12-20  8:04   ` Tiwei Bie
  0 siblings, 0 replies; 17+ messages in thread
From: Tiwei Bie @ 2019-12-20  8:04 UTC (permalink / raw)
  To: Li Feng; +Cc: Maxime Coquelin, Zhihong Wang, dev, kyle

On Thu, Dec 19, 2019 at 04:54:06PM +0800, Li Feng wrote:
> This msg is used to notify qemu that should get the config of backend.
> 
> For example, vhost-user-blk uses this msg to notify guest os the
> capacity of backend has changed.
> 
> The need_reply flag is not mandatory because it will block the sender
> thread and master process will send get_config message to fetch the
> configuration, this need an extra thread to process the vhost message.
> 
> Signed-off-by: Li Feng <fengli@smartx.com>
> ---
> v4:
> * Fix type and code style.
> * Add need_reply support.
> 
> v3:
> * Move the declare to rte_vhost.h
> * Add the symbol in rte_vhost_version.map
> 
> v2:
> * Fix a little log typo.
> 
>  lib/librte_vhost/rte_vhost.h           | 15 +++++++++++++++
>  lib/librte_vhost/rte_vhost_version.map |  1 +
>  lib/librte_vhost/vhost_user.c          | 35 ++++++++++++++++++++++++++++++++++
>  lib/librte_vhost/vhost_user.h          |  1 +
>  4 files changed, 52 insertions(+)
> 
> diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h
> index 7b5dc87c2..c7b619ae0 100644
> --- a/lib/librte_vhost/rte_vhost.h
> +++ b/lib/librte_vhost/rte_vhost.h
> @@ -10,6 +10,7 @@
>   * Interface to vhost-user
>   */
>  
> +#include <stdbool.h>
>  #include <stdint.h>
>  #include <sys/eventfd.h>
>  
> @@ -977,6 +978,20 @@ __rte_experimental
>  int
>  rte_vhost_get_vdpa_device_id(int vid);
>  
> +/**
> + * Notify the guest that should get virtio configuration space from backend.
> + *
> + * @param vid
> + *  vhost device ID
> + * @param need_reply
> + *  wait for the master response the status of this operation
> + * @return
> + *  0 on success, < 0 on failure
> + */
> +__rte_experimental
> +int
> +rte_vhost_slave_config_change(int vid, bool need_reply);
> +
>  #ifdef __cplusplus
>  }
>  #endif
> diff --git a/lib/librte_vhost/rte_vhost_version.map b/lib/librte_vhost/rte_vhost_version.map
> index c512377fe..051d08c12 100644
> --- a/lib/librte_vhost/rte_vhost_version.map
> +++ b/lib/librte_vhost/rte_vhost_version.map
> @@ -65,4 +65,5 @@ EXPERIMENTAL {
>  	rte_vhost_clr_inflight_desc_packed;
>  	rte_vhost_get_vhost_ring_inflight;
>  	rte_vhost_get_vring_base_from_inflight;
> +	rte_vhost_slave_config_change;
>  };
> diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> index 0cfb8b792..aed1210b1 100644
> --- a/lib/librte_vhost/vhost_user.c
> +++ b/lib/librte_vhost/vhost_user.c
> @@ -2840,6 +2840,41 @@ vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm)
>  	return 0;
>  }
>  
> +static int
> +vhost_user_slave_config_change(struct virtio_net *dev, bool need_reply)
> +{
> +	int ret;
> +	uint32_t flags = VHOST_USER_VERSION;
> +	if (need_reply)
> +		flags |= VHOST_USER_NEED_REPLY;
> +	struct VhostUserMsg msg = {
> +		.request.slave = VHOST_USER_SLAVE_CONFIG_CHANGE_MSG,
> +		.flags = flags,
> +		.size = 0,
> +	};

Normally, we don't mix the declarations and code.
Something like this looks better to me:

	struct VhostUserMsg msg = {
		.request.slave = VHOST_USER_SLAVE_CONFIG_CHANGE_MSG,
		.flags = VHOST_USER_VERSION,
	};

	if (need_reply)
		msg.flags |= VHOST_USER_NEED_REPLY;

> +
> +	ret = send_vhost_slave_message(dev, &msg);
> +	if (ret < 0) {
> +		RTE_LOG(ERR, VHOST_CONFIG,
> +			"Failed to send config change (%d)\n",
> +			ret);
> +		return ret;
> +	}
> +	if (need_reply)
> +		return process_slave_message_reply(dev, &msg);

We can call process_slave_message_reply() unconditionally.
https://github.com/DPDK/dpdk/blob/f26c2b39b271/lib/librte_vhost/vhost_user.c#L2794-L2795

> +	return 0;
> +}
> +
> +int
> +rte_vhost_slave_config_change(int vid, bool need_reply)
> +{
> +	struct virtio_net *dev;

Looks better to add an empty line here.

> +	dev = get_device(vid);
> +	if (!dev)
> +		return -ENODEV;
> +	return vhost_user_slave_config_change(dev, need_reply);
> +}
> +
>  static int vhost_user_slave_set_vring_host_notifier(struct virtio_net *dev,
>  						    int index, int fd,
>  						    uint64_t offset,
> diff --git a/lib/librte_vhost/vhost_user.h b/lib/librte_vhost/vhost_user.h
> index 6563f7315..86c364a93 100644
> --- a/lib/librte_vhost/vhost_user.h
> +++ b/lib/librte_vhost/vhost_user.h
> @@ -62,6 +62,7 @@ typedef enum 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_VRING_HOST_NOTIFIER_MSG = 3,
>  	VHOST_USER_SLAVE_MAX
>  } VhostUserSlaveRequest;
> -- 
> 2.11.0
> 
> 
> -- 
> The SmartX email address is only for business purpose. Any sent message 
> that is not related to the business is not authorized or permitted by 
> SmartX.
> 本邮箱为北京志凌海纳科技有限公司(SmartX)工作邮箱. 如本邮箱发出的邮件与工作无关,该邮件未得到本公司任何的明示或默示的授权.
> 
> 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [dpdk-dev] [PATCH v5] vhost: add config change slave msg support
  2019-12-02 14:57 [dpdk-dev] [PATCH] vhost: add config change slave msg support Li Feng
                   ` (2 preceding siblings ...)
  2019-12-19  8:54 ` [dpdk-dev] [PATCH v4] " Li Feng
@ 2019-12-20  8:22 ` Li Feng
  2020-01-14 14:57   ` Maxime Coquelin
  2020-01-15 11:18   ` Maxime Coquelin
  3 siblings, 2 replies; 17+ messages in thread
From: Li Feng @ 2019-12-20  8:22 UTC (permalink / raw)
  To: Maxime Coquelin, Tiwei Bie, Zhihong Wang; +Cc: dev, kyle, Li Feng

This msg is used to notify qemu that should get the config of backend.

For example, vhost-user-blk uses this msg to notify guest os the
capacity of backend has changed.

The need_reply flag is not mandatory because it will block the sender
thread and master process will send get_config message to fetch the
configuration, this need an extra thread to process the vhost message.

Signed-off-by: Li Feng <fengli@smartx.com>
---
v5:
* Fix code style.

v4:
* Fix type and code style.
* Add need_reply support.

v3:
* Move the declare to rte_vhost.h
* Add the symbol in rte_vhost_version.map

v2:
* Fix a little log typo.

 lib/librte_vhost/rte_vhost.h           | 15 ++++++++++++++
 lib/librte_vhost/rte_vhost_version.map |  1 +
 lib/librte_vhost/vhost_user.c          | 36 ++++++++++++++++++++++++++++++++++
 lib/librte_vhost/vhost_user.h          |  1 +
 4 files changed, 53 insertions(+)

diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h
index 7b5dc87c2..c7b619ae0 100644
--- a/lib/librte_vhost/rte_vhost.h
+++ b/lib/librte_vhost/rte_vhost.h
@@ -10,6 +10,7 @@
  * Interface to vhost-user
  */
 
+#include <stdbool.h>
 #include <stdint.h>
 #include <sys/eventfd.h>
 
@@ -977,6 +978,20 @@ __rte_experimental
 int
 rte_vhost_get_vdpa_device_id(int vid);
 
+/**
+ * Notify the guest that should get virtio configuration space from backend.
+ *
+ * @param vid
+ *  vhost device ID
+ * @param need_reply
+ *  wait for the master response the status of this operation
+ * @return
+ *  0 on success, < 0 on failure
+ */
+__rte_experimental
+int
+rte_vhost_slave_config_change(int vid, bool need_reply);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_vhost/rte_vhost_version.map b/lib/librte_vhost/rte_vhost_version.map
index c512377fe..051d08c12 100644
--- a/lib/librte_vhost/rte_vhost_version.map
+++ b/lib/librte_vhost/rte_vhost_version.map
@@ -65,4 +65,5 @@ EXPERIMENTAL {
 	rte_vhost_clr_inflight_desc_packed;
 	rte_vhost_get_vhost_ring_inflight;
 	rte_vhost_get_vring_base_from_inflight;
+	rte_vhost_slave_config_change;
 };
diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 0cfb8b792..defd82a19 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -2840,6 +2840,42 @@ vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm)
 	return 0;
 }
 
+static int
+vhost_user_slave_config_change(struct virtio_net *dev, bool need_reply)
+{
+	int ret;
+	struct VhostUserMsg msg = {
+		.request.slave = VHOST_USER_SLAVE_CONFIG_CHANGE_MSG,
+		.flags = VHOST_USER_VERSION,
+		.size = 0,
+	};
+
+	if (need_reply)
+		msg.flags |= VHOST_USER_NEED_REPLY;
+
+	ret = send_vhost_slave_message(dev, &msg);
+	if (ret < 0) {
+		RTE_LOG(ERR, VHOST_CONFIG,
+			"Failed to send config change (%d)\n",
+			ret);
+		return ret;
+	}
+
+	return process_slave_message_reply(dev, &msg);
+}
+
+int
+rte_vhost_slave_config_change(int vid, bool need_reply)
+{
+	struct virtio_net *dev;
+
+	dev = get_device(vid);
+	if (!dev)
+		return -ENODEV;
+
+	return vhost_user_slave_config_change(dev, need_reply);
+}
+
 static int vhost_user_slave_set_vring_host_notifier(struct virtio_net *dev,
 						    int index, int fd,
 						    uint64_t offset,
diff --git a/lib/librte_vhost/vhost_user.h b/lib/librte_vhost/vhost_user.h
index 6563f7315..86c364a93 100644
--- a/lib/librte_vhost/vhost_user.h
+++ b/lib/librte_vhost/vhost_user.h
@@ -62,6 +62,7 @@ typedef enum 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_VRING_HOST_NOTIFIER_MSG = 3,
 	VHOST_USER_SLAVE_MAX
 } VhostUserSlaveRequest;
-- 
2.11.0


-- 
The SmartX email address is only for business purpose. Any sent message 
that is not related to the business is not authorized or permitted by 
SmartX.
本邮箱为北京志凌海纳科技有限公司(SmartX)工作邮箱. 如本邮箱发出的邮件与工作无关,该邮件未得到本公司任何的明示或默示的授权.



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-dev] [PATCH v5] vhost: add config change slave msg support
  2019-12-20  8:22 ` [dpdk-dev] [PATCH v5] " Li Feng
@ 2020-01-14 14:57   ` Maxime Coquelin
  2020-01-15 11:18   ` Maxime Coquelin
  1 sibling, 0 replies; 17+ messages in thread
From: Maxime Coquelin @ 2020-01-14 14:57 UTC (permalink / raw)
  To: Li Feng, Tiwei Bie, Zhihong Wang; +Cc: dev, kyle



On 12/20/19 9:22 AM, Li Feng wrote:
> This msg is used to notify qemu that should get the config of backend.
> 
> For example, vhost-user-blk uses this msg to notify guest os the
> capacity of backend has changed.
> 
> The need_reply flag is not mandatory because it will block the sender
> thread and master process will send get_config message to fetch the
> configuration, this need an extra thread to process the vhost message.
> 
> Signed-off-by: Li Feng <fengli@smartx.com>
> ---
> v5:
> * Fix code style.
> 
> v4:
> * Fix type and code style.
> * Add need_reply support.
> 
> v3:
> * Move the declare to rte_vhost.h
> * Add the symbol in rte_vhost_version.map
> 
> v2:
> * Fix a little log typo.
> 
>  lib/librte_vhost/rte_vhost.h           | 15 ++++++++++++++
>  lib/librte_vhost/rte_vhost_version.map |  1 +
>  lib/librte_vhost/vhost_user.c          | 36 ++++++++++++++++++++++++++++++++++
>  lib/librte_vhost/vhost_user.h          |  1 +
>  4 files changed, 53 insertions(+)
> 


Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [dpdk-dev] [PATCH v5] vhost: add config change slave msg support
  2019-12-20  8:22 ` [dpdk-dev] [PATCH v5] " Li Feng
  2020-01-14 14:57   ` Maxime Coquelin
@ 2020-01-15 11:18   ` Maxime Coquelin
  1 sibling, 0 replies; 17+ messages in thread
From: Maxime Coquelin @ 2020-01-15 11:18 UTC (permalink / raw)
  To: Li Feng, Tiwei Bie, Zhihong Wang; +Cc: dev, kyle



On 12/20/19 9:22 AM, Li Feng wrote:
> This msg is used to notify qemu that should get the config of backend.
> 
> For example, vhost-user-blk uses this msg to notify guest os the
> capacity of backend has changed.
> 
> The need_reply flag is not mandatory because it will block the sender
> thread and master process will send get_config message to fetch the
> configuration, this need an extra thread to process the vhost message.
> 
> Signed-off-by: Li Feng <fengli@smartx.com>
> ---
> v5:
> * Fix code style.
> 
> v4:
> * Fix type and code style.
> * Add need_reply support.
> 
> v3:
> * Move the declare to rte_vhost.h
> * Add the symbol in rte_vhost_version.map
> 
> v2:
> * Fix a little log typo.
> 
>  lib/librte_vhost/rte_vhost.h           | 15 ++++++++++++++
>  lib/librte_vhost/rte_vhost_version.map |  1 +
>  lib/librte_vhost/vhost_user.c          | 36 ++++++++++++++++++++++++++++++++++
>  lib/librte_vhost/vhost_user.h          |  1 +
>  4 files changed, 53 insertions(+)

Applied to dpdk-next-virtio/master

Thanks,
Maxime


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [dpdk-dev] [PATCH v2] vhost: add config change slave msg support
@ 2019-12-04  5:01 Li Feng
  0 siblings, 0 replies; 17+ messages in thread
From: Li Feng @ 2019-12-04  5:01 UTC (permalink / raw)
  To: Maxime Coquelin, Tiwei Bie, Zhihong Wang; +Cc: dev, Li Feng

This msg is used to notify qemu that should get the config of backend.

For example, vhost-user-blk uses this msg to notify guest os the
compacity of backend has changed.

Signed-off-by: Li Feng <fengli@smartx.com>
---
v2:
* Fix a little log typo.

 lib/librte_vhost/vhost_user.c | 31 +++++++++++++++++++++++++++++++
 lib/librte_vhost/vhost_user.h |  2 ++
 2 files changed, 33 insertions(+)

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 0cfb8b792..10f2e47d5 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -2840,6 +2840,37 @@ vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm)
 	return 0;
 }
 
+static int
+vhost_user_slave_config_change(struct virtio_net *dev)
+{
+	int ret;
+	struct VhostUserMsg msg = {
+		.request.slave = VHOST_USER_SLAVE_CONFIG_CHANGE_MSG,
+		.flags = VHOST_USER_VERSION,
+		.size = 0,
+	};
+
+	ret = send_vhost_message(dev->slave_req_fd, &msg);
+	if (ret < 0) {
+		RTE_LOG(ERR, VHOST_CONFIG,
+				"Failed to send config change (%d)\n",
+				ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+int
+rte_vhost_user_slave_config_change(int vid)
+{
+	struct virtio_net *dev;
+	dev = get_device(vid);
+	if (!dev)
+		return -ENODEV;
+	return vhost_user_slave_config_change(dev);
+}
+
 static int vhost_user_slave_set_vring_host_notifier(struct virtio_net *dev,
 						    int index, int fd,
 						    uint64_t offset,
diff --git a/lib/librte_vhost/vhost_user.h b/lib/librte_vhost/vhost_user.h
index 6563f7315..5c1bb2138 100644
--- a/lib/librte_vhost/vhost_user.h
+++ b/lib/librte_vhost/vhost_user.h
@@ -62,6 +62,7 @@ typedef enum 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_VRING_HOST_NOTIFIER_MSG = 3,
 	VHOST_USER_SLAVE_MAX
 } VhostUserSlaveRequest;
@@ -158,6 +159,7 @@ typedef struct VhostUserMsg {
 /* vhost_user.c */
 int vhost_user_msg_handler(int vid, int fd);
 int vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm);
+int rte_vhost_user_slave_config_change(int vid);
 
 /* socket.c */
 int read_fd_message(int sockfd, char *buf, int buflen, int *fds, int max_fds,
-- 
2.11.0


-- 
The SmartX email address is only for business purpose. Any sent message 
that is not related to the business is not authorized or permitted by 
SmartX.
本邮箱为北京志凌海纳科技有限公司(SmartX)工作邮箱. 如本邮箱发出的邮件与工作无关,该邮件未得到本公司任何的明示或默示的授权.



^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2020-01-15 11:18 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-02 14:57 [dpdk-dev] [PATCH] vhost: add config change slave msg support Li Feng
2019-12-04  5:13 ` [dpdk-dev] [PATCH v2] " Li Feng
2019-12-04  9:30   ` Tiwei Bie
2019-12-04  9:43     ` Li Feng
2019-12-05  2:07       ` Tiwei Bie
2019-12-05  4:01         ` Li Feng
2019-12-05  4:57           ` Tiwei Bie
2019-12-05  5:38 ` [dpdk-dev] [PATCH v3] " Li Feng
2019-12-11  2:58   ` Li Feng
2019-12-16  5:06   ` Tiwei Bie
2019-12-18  6:34     ` Li Feng
2019-12-19  8:54 ` [dpdk-dev] [PATCH v4] " Li Feng
2019-12-20  8:04   ` Tiwei Bie
2019-12-20  8:22 ` [dpdk-dev] [PATCH v5] " Li Feng
2020-01-14 14:57   ` Maxime Coquelin
2020-01-15 11:18   ` Maxime Coquelin
2019-12-04  5:01 [dpdk-dev] [PATCH v2] " Li Feng

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).