[v2] lib/vhost: add flag for async connection in client mode

Message ID 20240417091250.187218-1-udav@mts.ru (mailing list archive)
State Superseded
Delegated to: Maxime Coquelin
Headers
Series [v2] lib/vhost: add flag for async connection in client mode |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-compile-arm64-testing success Testing PASS

Commit Message

Ушков Даниил April 17, 2024, 9:15 a.m. UTC
  This patch introduces a new flag RTE_VHOST_USER_ASYNC_CONNECT,
which in combination with the flag RTE_VHOST_USER_CLIENT makes
rte_vhost_driver_start connect asynchronously to the vhost server.

Signed-off-by: Ушков Даниил <udav@mts.ru>
---
Fixes:
1. Fix warning about the name in signature.
2. Fix warning about coding style.

P.S.
Is it ok that name is not in ascii?
Sorry, it could be hard to change it now.

 lib/vhost/rte_vhost.h |  1 +
 lib/vhost/socket.c    | 28 ++++++++++++++++------------
 2 files changed, 17 insertions(+), 12 deletions(-)

-- 
2.34.1
  

Comments

Maxime Coquelin April 25, 2024, 1:47 p.m. UTC | #1
On 4/17/24 11:15, Ушков Даниил wrote:
> This patch introduces a new flag RTE_VHOST_USER_ASYNC_CONNECT,
> which in combination with the flag RTE_VHOST_USER_CLIENT makes
> rte_vhost_driver_start connect asynchronously to the vhost server.
> 
> Signed-off-by: Ушков Даниил <udav@mts.ru>
> ---
> Fixes:
> 1. Fix warning about the name in signature.
> 2. Fix warning about coding style.
> 
> P.S.
> Is it ok that name is not in ascii?

I think it has to be, Thomas do you confirm?

> Sorry, it could be hard to change it now.
> 
>   lib/vhost/rte_vhost.h |  1 +
>   lib/vhost/socket.c    | 28 ++++++++++++++++------------
>   2 files changed, 17 insertions(+), 12 deletions(-)
> 
> diff --git a/lib/vhost/rte_vhost.h b/lib/vhost/rte_vhost.h
> index db92f05344..b0434c4b8d 100644
> --- a/lib/vhost/rte_vhost.h
> +++ b/lib/vhost/rte_vhost.h
> @@ -41,6 +41,7 @@ extern "C" {
>   #define RTE_VHOST_USER_ASYNC_COPY	(1ULL << 7)
>   #define RTE_VHOST_USER_NET_COMPLIANT_OL_FLAGS	(1ULL << 8)
>   #define RTE_VHOST_USER_NET_STATS_ENABLE	(1ULL << 9)
> +#define RTE_VHOST_USER_ASYNC_CONNECT	(1ULL << 10)
>   
>   /* Features. */
>   #ifndef VIRTIO_NET_F_GUEST_ANNOUNCE
> diff --git a/lib/vhost/socket.c b/lib/vhost/socket.c
> index 96b3ab5595..c681d53abb 100644
> --- a/lib/vhost/socket.c
> +++ b/lib/vhost/socket.c
> @@ -45,6 +45,7 @@ struct vhost_user_socket {
>   	bool async_copy;
>   	bool net_compliant_ol_flags;
>   	bool stats_enabled;
> +	bool async_connect;
>   
>   	/*
>   	 * The "supported_features" indicates the feature bits the
> @@ -533,21 +534,23 @@ vhost_user_start_client(struct vhost_user_socket *vsocket)
>   	const char *path = vsocket->path;
>   	struct vhost_user_reconnect *reconn;
>   
> -	ret = vhost_user_connect_nonblock(vsocket->path, fd, (struct sockaddr *)&vsocket->un,
> -					  sizeof(vsocket->un));
> -	if (ret == 0) {
> -		vhost_user_add_connection(fd, vsocket);
> -		return 0;
> -	}
> +	if (!vsocket->async_connect || !vsocket->reconnect) {
> +		ret = vhost_user_connect_nonblock(vsocket->path, fd,
> +			(struct sockaddr *)&vsocket->un, sizeof(vsocket->un));
> +		if (ret == 0) {
> +			vhost_user_add_connection(fd, vsocket);
> +			return 0;
> +		}
>   
> -	VHOST_CONFIG_LOG(path, WARNING, "failed to connect: %s", strerror(errno));
> +		VHOST_CONFIG_LOG(path, WARNING, "failed to connect: %s", strerror(errno));
>   
> -	if (ret == -2 || !vsocket->reconnect) {
> -		close(fd);
> -		return -1;
> -	}
> +		if (ret == -2 || !vsocket->reconnect) {
> +			close(fd);
> +			return -1;
> +		}
>   
> -	VHOST_CONFIG_LOG(path, INFO, "reconnecting...");
> +		VHOST_CONFIG_LOG(path, INFO, "reconnecting...");
> +	}
>   	reconn = malloc(sizeof(*reconn));
>   	if (reconn == NULL) {
>   		VHOST_CONFIG_LOG(path, ERR, "failed to allocate memory for reconnect");
> @@ -930,6 +933,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
>   	vsocket->async_copy = flags & RTE_VHOST_USER_ASYNC_COPY;
>   	vsocket->net_compliant_ol_flags = flags & RTE_VHOST_USER_NET_COMPLIANT_OL_FLAGS;
>   	vsocket->stats_enabled = flags & RTE_VHOST_USER_NET_STATS_ENABLE;
> +	vsocket->async_connect = flags & RTE_VHOST_USER_ASYNC_CONNECT;
>   	if (vsocket->is_vduse)
>   		vsocket->iommu_support = true;
>   	else
  
Morten Brørup April 25, 2024, 2:04 p.m. UTC | #2
> From: Maxime Coquelin [mailto:maxime.coquelin@redhat.com]
> Sent: Thursday, 25 April 2024 15.48
> 
> On 4/17/24 11:15, Ушков Даниил wrote:
> >
> > Signed-off-by: Ушков Даниил <udav@mts.ru>
> > ---
> > Fixes:
> > 1. Fix warning about the name in signature.
> > 2. Fix warning about coding style.
> >
> > P.S.
> > Is it ok that name is not in ascii?
> 
> I think it has to be, Thomas do you confirm?

Stephen, do you know the Linux Kernel requirements regarding contributor sign-off names... perhaps we can seek inspiration there.

Are special letters in the Western European alphabet (such as ö, ø, ñ and ß) allowed?

How about the Cyrillic alphabet, like the name being asked about for this patch?

And how about Chinese and Japanese characters?
  
Thomas Monjalon April 29, 2024, 7:43 p.m. UTC | #3
25/04/2024 16:04, Morten Brørup:
> > From: Maxime Coquelin [mailto:maxime.coquelin@redhat.com]
> > Sent: Thursday, 25 April 2024 15.48
> > 
> > On 4/17/24 11:15, Ушков Даниил wrote:
> > >
> > > Signed-off-by: Ушков Даниил <udav@mts.ru>
> > > ---
> > > Fixes:
> > > 1. Fix warning about the name in signature.
> > > 2. Fix warning about coding style.
> > >
> > > P.S.
> > > Is it ok that name is not in ascii?
> > 
> > I think it has to be, Thomas do you confirm?

In general, names are "converted" to ascii with few accents.
But there is no clear rule, and I don't want to force my alphabet over others.


> Stephen, do you know the Linux Kernel requirements regarding contributor sign-off names... perhaps we can seek inspiration there.
> 
> Are special letters in the Western European alphabet (such as ö, ø, ñ and ß) allowed?
> 
> How about the Cyrillic alphabet, like the name being asked about for this patch?
> 
> And how about Chinese and Japanese characters?

Would be interesting to have more opinions about what is common in tech communities.
  

Patch

diff --git a/lib/vhost/rte_vhost.h b/lib/vhost/rte_vhost.h
index db92f05344..b0434c4b8d 100644
--- a/lib/vhost/rte_vhost.h
+++ b/lib/vhost/rte_vhost.h
@@ -41,6 +41,7 @@  extern "C" {
 #define RTE_VHOST_USER_ASYNC_COPY	(1ULL << 7)
 #define RTE_VHOST_USER_NET_COMPLIANT_OL_FLAGS	(1ULL << 8)
 #define RTE_VHOST_USER_NET_STATS_ENABLE	(1ULL << 9)
+#define RTE_VHOST_USER_ASYNC_CONNECT	(1ULL << 10)
 
 /* Features. */
 #ifndef VIRTIO_NET_F_GUEST_ANNOUNCE
diff --git a/lib/vhost/socket.c b/lib/vhost/socket.c
index 96b3ab5595..c681d53abb 100644
--- a/lib/vhost/socket.c
+++ b/lib/vhost/socket.c
@@ -45,6 +45,7 @@  struct vhost_user_socket {
 	bool async_copy;
 	bool net_compliant_ol_flags;
 	bool stats_enabled;
+	bool async_connect;
 
 	/*
 	 * The "supported_features" indicates the feature bits the
@@ -533,21 +534,23 @@  vhost_user_start_client(struct vhost_user_socket *vsocket)
 	const char *path = vsocket->path;
 	struct vhost_user_reconnect *reconn;
 
-	ret = vhost_user_connect_nonblock(vsocket->path, fd, (struct sockaddr *)&vsocket->un,
-					  sizeof(vsocket->un));
-	if (ret == 0) {
-		vhost_user_add_connection(fd, vsocket);
-		return 0;
-	}
+	if (!vsocket->async_connect || !vsocket->reconnect) {
+		ret = vhost_user_connect_nonblock(vsocket->path, fd,
+			(struct sockaddr *)&vsocket->un, sizeof(vsocket->un));
+		if (ret == 0) {
+			vhost_user_add_connection(fd, vsocket);
+			return 0;
+		}
 
-	VHOST_CONFIG_LOG(path, WARNING, "failed to connect: %s", strerror(errno));
+		VHOST_CONFIG_LOG(path, WARNING, "failed to connect: %s", strerror(errno));
 
-	if (ret == -2 || !vsocket->reconnect) {
-		close(fd);
-		return -1;
-	}
+		if (ret == -2 || !vsocket->reconnect) {
+			close(fd);
+			return -1;
+		}
 
-	VHOST_CONFIG_LOG(path, INFO, "reconnecting...");
+		VHOST_CONFIG_LOG(path, INFO, "reconnecting...");
+	}
 	reconn = malloc(sizeof(*reconn));
 	if (reconn == NULL) {
 		VHOST_CONFIG_LOG(path, ERR, "failed to allocate memory for reconnect");
@@ -930,6 +933,7 @@  rte_vhost_driver_register(const char *path, uint64_t flags)
 	vsocket->async_copy = flags & RTE_VHOST_USER_ASYNC_COPY;
 	vsocket->net_compliant_ol_flags = flags & RTE_VHOST_USER_NET_COMPLIANT_OL_FLAGS;
 	vsocket->stats_enabled = flags & RTE_VHOST_USER_NET_STATS_ENABLE;
+	vsocket->async_connect = flags & RTE_VHOST_USER_ASYNC_CONNECT;
 	if (vsocket->is_vduse)
 		vsocket->iommu_support = true;
 	else