Skip to contentSkip to conversation

vhost: support host notifier

PATCH Applied Tiwei Bie 3 participants 6 messages Jun 8, 2018 – Jun 15, 2018 Network drivers

lore
Share & tools
lore

Tiwei Bie

author
#0 lore raw

v3 cover vhost: support host notifier

The host notifier support in vhost-user has been merged into QEMU. This patch set enables the support for host notifier in DPDK vhost-user and ifcvf driver.

The original subject is:
Extend vhost to support VFIO based accelerator

v3:
- Address the changes in QEMU
- Minor fixes and refinements

Tiwei Bie (2):
vhost: support host notifier
net/ifcvf: enable the host notifier support

 drivers/net/ifc/ifcvf_vdpa.c  |   3 +
 lib/librte_vhost/rte_vhost.h  |   8 ++
 lib/librte_vhost/vhost.c      |   3 +
 lib/librte_vhost/vhost.h      |   1 +
 lib/librte_vhost/vhost_user.c | 146 ++++++++++++++++++++++++++++++++++
 lib/librte_vhost/vhost_user.h |  13 ++-
 6 files changed, 173 insertions(+), 1 deletion(-)
Signature · 1 line
2.17.0
author
#1 lore raw

PATCH v3 1/2 vhost: support host notifier

When a vDPA device is attached, vhost user will try to register host notifiers to QEMU to allow notifications to be delivered between the driver in the guest and the vDPA device in the host directly.

---
 lib/librte_vhost/rte_vhost.h  |   8 ++
 lib/librte_vhost/vhost.c      |   3 +
 lib/librte_vhost/vhost.h      |   1 +
 lib/librte_vhost/vhost_user.c | 146 ++++++++++++++++++++++++++++++++++
 lib/librte_vhost/vhost_user.h |  13 ++-
 5 files changed, 170 insertions(+), 1 deletion(-)
lib/librte_vhost/rte_vhost.h +8 -0
index 7f0cb9bc8..b02673d4a 100644
@@ -58,6 +58,14 @@ extern "C" {
 #define VHOST_USER_PROTOCOL_F_CRYPTO_SESSION 7
 #endif
 
+#ifndef VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD
+#define VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD 10
+#endif
+
+#ifndef VHOST_USER_PROTOCOL_F_HOST_NOTIFIER
+#define VHOST_USER_PROTOCOL_F_HOST_NOTIFIER 11
+#endif
+
 /** Indicate whether protocol features negotiation is supported. */
 #ifndef VHOST_USER_F_PROTOCOL_FEATURES
 #define VHOST_USER_F_PROTOCOL_FEATURES	30
lib/librte_vhost/vhost.c +3 -0
index afded4952..6ca5beb13 100644
@@ -291,6 +291,7 @@ vhost_new_device(void)
 	dev->flags = VIRTIO_DEV_BUILTIN_VIRTIO_NET;
 	dev->slave_req_fd = -1;
 	dev->vdpa_dev_id = -1;
+	rte_spinlock_init(&dev->slave_req_lock);
 
 	return i;
 }
@@ -346,6 +347,8 @@ vhost_detach_vdpa_device(int vid)
 	if (dev == NULL)
 		return;
 
+	vhost_user_host_notifier_ctrl(vid, false);
+
 	dev->vdpa_dev_id = -1;
 }
 
lib/librte_vhost/vhost.h +1 -0
index 58c425a5c..b10ac124b 100644
@@ -301,6 +301,7 @@ struct virtio_net {
 	struct guest_page       *guest_pages;
 
 	int			slave_req_fd;
+	rte_spinlock_t		slave_req_lock;
 
 	/*
 	 * Device id to identify a specific backend device.
lib/librte_vhost/vhost_user.c +146 -0

166 lines not on this page · raw message

lib/librte_vhost/vhost_user.h +12 -1
index 1ad5cf467..42166adf2 100644
@@ -20,7 +20,9 @@
 					 (1ULL << VHOST_USER_PROTOCOL_F_REPLY_ACK) | \
 					 (1ULL << VHOST_USER_PROTOCOL_F_NET_MTU) | \
 					 (1ULL << VHOST_USER_PROTOCOL_F_SLAVE_REQ) | \
-					 (1ULL << VHOST_USER_PROTOCOL_F_CRYPTO_SESSION))
+					 (1ULL << VHOST_USER_PROTOCOL_F_CRYPTO_SESSION) | \
+					 (1ULL << VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD) | \
+					 (1ULL << VHOST_USER_PROTOCOL_F_HOST_NOTIFIER))
 
 typedef enum VhostUserRequest {
 	VHOST_USER_NONE = 0,
@@ -54,6 +56,7 @@ typedef enum VhostUserRequest {
 typedef enum VhostUserSlaveRequest {
 	VHOST_USER_SLAVE_NONE = 0,
 	VHOST_USER_SLAVE_IOTLB_MSG = 1,
+	VHOST_USER_SLAVE_VRING_HOST_NOTIFIER_MSG = 3,
 	VHOST_USER_SLAVE_MAX
 } VhostUserSlaveRequest;
 
@@ -99,6 +102,12 @@ typedef struct VhostUserCryptoSessionParam {
 	uint8_t auth_key_buf[VHOST_USER_CRYPTO_MAX_HMAC_KEY_LENGTH];
 } VhostUserCryptoSessionParam;
 
+typedef struct VhostUserVringArea {
+	uint64_t u64;
+	uint64_t size;
+	uint64_t offset;
+} VhostUserVringArea;
+
 typedef struct VhostUserMsg {
 	union {
 		uint32_t master; /* a VhostUserRequest value */
@@ -120,6 +129,7 @@ typedef struct VhostUserMsg {
 		VhostUserLog    log;
 		struct vhost_iotlb_msg iotlb;
 		VhostUserCryptoSessionParam crypto_session;
+		VhostUserVringArea area;
 	} payload;
 	int fds[VHOST_MEMORY_MAX_NREGIONS];
 } __attribute((packed)) VhostUserMsg;
@@ -133,6 +143,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 vhost_user_host_notifier_ctrl(int vid, bool enable);
 
 /* socket.c */
 int read_fd_message(int sockfd, char *buf, int buflen, int *fds, int fd_num);
Signature · 1 line
2.17.0
author
#2 lore raw

PATCH v3 2/2 net/ifcvf: enable the host notifier support

In reply to Tiwei Bie

The necessary vDPA ops have already been implemented in ifcvf driver. So just need to announce the necessary protocol features to enable the host notifier support.

---
 drivers/net/ifc/ifcvf_vdpa.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/ifc/ifcvf_vdpa.c +3 -0
index c6627c23a..b8e22daf3 100644
@@ -646,6 +646,9 @@ ifcvf_get_vdpa_features(int did, uint64_t *features)
 
 #define VDPA_SUPPORTED_PROTOCOL_FEATURES \
 		(1ULL << VHOST_USER_PROTOCOL_F_REPLY_ACK | \
+		 1ULL << VHOST_USER_PROTOCOL_F_SLAVE_REQ | \
+		 1ULL << VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD | \
+		 1ULL << VHOST_USER_PROTOCOL_F_HOST_NOTIFIER | \
 		 1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD)
 static int
 ifcvf_get_protocol_features(int did __rte_unused, uint64_t *features)
Signature · 1 line
2.17.0
Acked-by on v3 2/2
#3 lore raw

Re: [PATCH v3 2/2] net/ifcvf: enable the host notifier support

Hi,

Quoted 31 lines

-----Original Message-----
From: Bie, Tiwei
Sent: Friday, June 8, 2018 11:22 AM
To: [email protected]; [email protected]
Cc: Wang, Xiao W <[email protected]>
Subject: [PATCH v3 2/2] net/ifcvf: enable the host notifier support

The necessary vDPA ops have already been implemented in ifcvf driver. So just need to announce the necessary protocol features to enable the host notifier support.

---
 drivers/net/ifc/ifcvf_vdpa.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/ifc/ifcvf_vdpa.c +3 -1
index c6627c23a..b8e22daf3 100644
@@ -646,6 +646,9 @@ ifcvf_get_vdpa_features(int did, uint64_t *features)
 
 #define VDPA_SUPPORTED_PROTOCOL_FEATURES \
 		(1ULL << VHOST_USER_PROTOCOL_F_REPLY_ACK | \
+		 1ULL << VHOST_USER_PROTOCOL_F_SLAVE_REQ | \
+		 1ULL << VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD | \
+		 1ULL << VHOST_USER_PROTOCOL_F_HOST_NOTIFIER | \
 		 1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD)
 static int
 ifcvf_get_protocol_features(int did __rte_unused, uint64_t *features)
--
Quoted 1 line

2.17.0

BRs,
Xiao

Reviewed-by on the v3 series
#4 lore raw
In reply to Tiwei Bie
Quoted 15 lines · Tiwei Bie

The host notifier support in vhost-user has been merged into QEMU. This patch set enables the support for host notifier in DPDK vhost-user and ifcvf driver.

The original subject is:
Extend vhost to support VFIO based accelerator

v3:
- Address the changes in QEMU
- Minor fixes and refinements

Tiwei Bie (2):
vhost: support host notifier
net/ifcvf: enable the host notifier support

Quoted 8 lines
  drivers/net/ifc/ifcvf_vdpa.c  |   3 +
  lib/librte_vhost/rte_vhost.h  |   8 ++
  lib/librte_vhost/vhost.c      |   3 +
  lib/librte_vhost/vhost.h      |   1 +
  lib/librte_vhost/vhost_user.c | 146 ++++++++++++++++++++++++++++++++++
  lib/librte_vhost/vhost_user.h |  13 ++-
  6 files changed, 173 insertions(+), 1 deletion(-)

For the series:

Thanks!
Maxime

#5 lore raw
In reply to Tiwei Bie
Quoted 15 lines · Tiwei Bie

The host notifier support in vhost-user has been merged into QEMU. This patch set enables the support for host notifier in DPDK vhost-user and ifcvf driver.

The original subject is:
Extend vhost to support VFIO based accelerator

v3:
- Address the changes in QEMU
- Minor fixes and refinements

Tiwei Bie (2):
vhost: support host notifier
net/ifcvf: enable the host notifier support

Quoted 8 lines
  drivers/net/ifc/ifcvf_vdpa.c  |   3 +
  lib/librte_vhost/rte_vhost.h  |   8 ++
  lib/librte_vhost/vhost.c      |   3 +
  lib/librte_vhost/vhost.h      |   1 +
  lib/librte_vhost/vhost_user.c | 146 ++++++++++++++++++++++++++++++++++
  lib/librte_vhost/vhost_user.h |  13 ++-
  6 files changed, 173 insertions(+), 1 deletion(-)

Applied to dpdk-next-virtio/master

Thanks,
Maxime