From patchwork Tue May 14 09:13:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniil Ushkov X-Patchwork-Id: 140052 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A8B0C4402A; Tue, 14 May 2024 11:13:44 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 75F56402E4; Tue, 14 May 2024 11:13:44 +0200 (CEST) Received: from forward103c.mail.yandex.net (forward103c.mail.yandex.net [178.154.239.214]) by mails.dpdk.org (Postfix) with ESMTP id 2F1D6402AE for ; Tue, 14 May 2024 11:13:43 +0200 (CEST) Received: from mail-nwsmtp-smtp-production-main-69.iva.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-69.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:2ca1:0:640:e017:0]) by forward103c.mail.yandex.net (Yandex) with ESMTPS id 7165160B01; Tue, 14 May 2024 12:13:42 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-69.iva.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id fDbrT669OqM0-othsPOEO; Tue, 14 May 2024 12:13:41 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1715678021; bh=e8xmkRMPoXhDeQIK2OIqpKDDrpeSHSsnGOpcmNR0oic=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=C2VfOSOXFILJwyW/9jspmvxI+OlnJ/OOABLSRabL7kS8+Prs/azRaVkye/8y7vnbI z38HZ0i2uYTrYfFoMso444ZMAhqbw9XE3BnQFcw7PM5pEMMTmuHoTH15cSAu5nvA/y Nx1VJzdLsYRSFJEGnAPjWR+bgmS8S3zD7EyhuQkQ= Authentication-Results: mail-nwsmtp-smtp-production-main-69.iva.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Daniil Ushkov To: dev@dpdk.org Cc: Daniil Ushkov , Maxime Coquelin , Chenbo Xia Subject: [PATCH v5] 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. Date: Tue, 14 May 2024 12:13:26 +0300 Message-Id: <20240514091327.441533-1-daniil.ushkov@yandex.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240417083835.164456-1-udav@mts.ru> References: <20240417083835.164456-1-udav@mts.ru> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Signed-off-by: Daniil Ushkov --- Rerun checks. 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