From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 44A4245AD6; Mon, 7 Oct 2024 17:04:51 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9E0EB427E9; Mon, 7 Oct 2024 17:04:43 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 4125E427E6 for ; Mon, 7 Oct 2024 17:04:42 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4978d7ow022179; Mon, 7 Oct 2024 08:04:41 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=U WbtJt9+l76A8BmO8yahwWUtBU5S7ICMHkoJmdq5XYA=; b=dzKsasAM6QX5rznpd o+6CiPy0e6RYNyK9QD2XSbjjbj/7WlhjfGzfsPxlizqBWJdiGHa0iTXcHjPSiWjJ eV3S+RCrpJpFAdaxQTtMzlItKTq54SPkok3PHuZeX7nP9jDcyWZE0afTLLFdGJZS 0eHRKEqtuoWhNdgrSMQ093PdUdO1BzQMdMsf0TCj7vtfy+MTo/0gzVAtTMOhTHbO KRSCajFYBo6YMc00JwTJuAYCi4cVYhj25uOfzgo/r7tkSJxYyE7dtqClIMyo5GE5 Lwk+qMvg6kkfmOZql7GIypLn83oB3oVm0ATPq4SbkzzoMbZR5LgwUTtos79FNue/ GPpKQ== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 424caf0q0j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 07 Oct 2024 08:04:41 -0700 (PDT) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 7 Oct 2024 08:04:39 -0700 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Mon, 7 Oct 2024 08:04:39 -0700 Received: from localhost.localdomain (unknown [10.28.36.14]) by maili.marvell.com (Postfix) with ESMTP id A86E35E686A; Mon, 7 Oct 2024 08:04:37 -0700 (PDT) From: To: Maxime Coquelin , Chenbo Xia CC: , Satha Rao Subject: [PATCH 5/5] net/virtio-user: support vDPA configuration callback Date: Mon, 7 Oct 2024 20:34:03 +0530 Message-ID: <20241007150403.1680983-5-skoteshwar@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241007150403.1680983-1-skoteshwar@marvell.com> References: <20241007150403.1680983-1-skoteshwar@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: KEQWPJkY0f8MSSu9ghsbQ09dPVCKe278 X-Proofpoint-ORIG-GUID: KEQWPJkY0f8MSSu9ghsbQ09dPVCKe278 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 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 From: Satha Rao Extended the vhost_vdpa_get_intr_fd API to create an event and register for configuration callbacks with the vDPA backend. This enhancement allows the virtio-user driver to handle configuration changes more effectively. Signed-off-by: Satha Rao --- drivers/net/virtio/virtio_user/vhost_vdpa.c | 18 ++++++++++-- .../net/virtio/virtio_user/virtio_user_dev.c | 29 +++++++++++++++++++ .../net/virtio/virtio_user/virtio_user_dev.h | 2 ++ 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/drivers/net/virtio/virtio_user/vhost_vdpa.c b/drivers/net/virtio/virtio_user/vhost_vdpa.c index e8aea54000..c9eaffce16 100644 --- a/drivers/net/virtio/virtio_user/vhost_vdpa.c +++ b/drivers/net/virtio/virtio_user/vhost_vdpa.c @@ -9,6 +9,7 @@ #include #include #include +#include #include @@ -634,10 +635,21 @@ vhost_vdpa_update_link_state(struct virtio_user_dev *dev) } static int -vhost_vdpa_get_intr_fd(struct virtio_user_dev *dev __rte_unused) +vhost_vdpa_get_intr_fd(struct virtio_user_dev *dev) { - /* No link state interrupt with Vhost-vDPA */ - return -1; + int fd; + + if (dev->cfg_epfd) + return dev->cfg_epfd; + + fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); + if (fd < 0) { + PMD_DRV_LOG(ERR, "failed to create fd error, %s", strerror(errno)); + fd = -1; + } + dev->cfg_epfd = fd; + + return fd; } static int diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index 91ad1312f7..ea00eb50f5 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -487,6 +487,21 @@ virtio_user_dev_get_speed_duplex_config(struct virtio_user_dev *dev, void *dst, return ret; } +int +virtio_user_dev_set_config_call(struct virtio_user_dev *dev, int fd) +{ + int ret = 0; + + if (!dev->ops->set_config_call) + return -ENOTSUP; + + ret = dev->ops->set_config_call(dev, fd); + if (ret) + PMD_DRV_LOG(ERR, "(%s) Failed to set config call in device", dev->path); + + return ret; +} + static int virtio_user_dev_init_notify(struct virtio_user_dev *dev) { @@ -769,6 +784,7 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, uint16_t queues, dev->unsupported_features = 0; dev->backend_type = backend_type; dev->ifname = *ifname; + dev->cfg_epfd = 0; if (virtio_user_dev_setup(dev) < 0) { PMD_INIT_LOG(ERR, "(%s) backend set up fails", dev->path); @@ -863,6 +879,15 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, uint16_t queues, } } + /* vhost vdpa register valid fd to handle config callback */ + if (dev->cfg_epfd) { + struct rte_eth_dev *eth_dev = &rte_eth_devices[dev->hw.port_id]; + + if (rte_intr_efd_counter_size_set(eth_dev->intr_handle, 8)) + return -rte_errno; + virtio_user_dev_set_config_call(dev, dev->cfg_epfd); + } + *ifname = NULL; return 0; @@ -892,6 +917,10 @@ virtio_user_dev_uninit(struct virtio_user_dev *dev) virtio_user_free_vrings(dev); + if (dev->cfg_epfd) { + close(dev->cfg_epfd); + dev->cfg_epfd = 0; + } free(dev->ifname); if (dev->is_server) diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h b/drivers/net/virtio/virtio_user/virtio_user_dev.h index 57d75d1c53..1ad93521e3 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.h +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h @@ -31,6 +31,7 @@ struct virtio_user_dev { int *callfds; int *kickfds; + int cfg_epfd; /* config callback interrupt */ int mac_specified; uint16_t max_queue_pairs; uint16_t queue_pairs; @@ -89,6 +90,7 @@ int virtio_user_dev_get_rss_config(struct virtio_user_dev *dev, void *dst, size_ int length); int virtio_user_dev_get_speed_duplex_config(struct virtio_user_dev *dev, void *dst, size_t offset, int length); +int virtio_user_dev_set_config_call(struct virtio_user_dev *dev, int fd); void virtio_user_dev_delayed_disconnect_handler(void *param); int virtio_user_dev_server_reconnect(struct virtio_user_dev *dev); extern const char * const virtio_user_backend_strings[]; -- 2.25.1