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 756CE48B4D; Wed, 19 Nov 2025 12:02:41 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 94C2F40662; Wed, 19 Nov 2025 12:02:16 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) by mails.dpdk.org (Postfix) with ESMTP id D36174042C for ; Wed, 19 Nov 2025 12:02:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1763550134; x=1795086134; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=a+bNdSVO/FU4TZHtnpQX3mVntkCuPVDydRGj/Dhwxn4=; b=I57YlbWzHUMgeytapp1uoLFWPIv2qZwMXfB7Py5GLbX7BOKFhWvx71iX lmFU7GUleslTKFDOs1J8ifqbKYdspEQptY8TVRraaEef0PQTndWwkfE/Z MPPGuK5l12r/1HOG0BN3MrDyJ3VNtrHb8wsfT9GXo2FbhW72Snh9rdIhD okFdISMtys3+GxwcOdKBA119D1hlFLt0WfuAipQCyPC3Am4qUHGOFlohL qm4ViP/O8DrUEIVS4xik52ee2GZS4GISrkRfRqRaQTP4ATRpvieMc+yM1 +BVTyI+s7v0fxI1TfyOTus8pjV5AvONLFZlwXjgq/i2SMvZhWVuvSpnps g==; X-CSE-ConnectionGUID: jUVVxMkpQ962BEWcEy3QXQ== X-CSE-MsgGUID: 4zBsNc3gQGGHKpgfiu0Osg== X-IronPort-AV: E=McAfee;i="6800,10657,11617"; a="76942091" X-IronPort-AV: E=Sophos;i="6.19,315,1754982000"; d="scan'208";a="76942091" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Nov 2025 03:02:14 -0800 X-CSE-ConnectionGUID: jMG5lmfCQM+idtcNDqlvTA== X-CSE-MsgGUID: haotzuAERLWdHnnSsLn4WA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,315,1754982000"; d="scan'208";a="214409194" Received: from silpixa00401119.ir.intel.com ([10.20.224.206]) by fmviesa002.fm.intel.com with ESMTP; 19 Nov 2025 03:02:12 -0800 From: Anatoly Burakov To: dev@dpdk.org, Christian Koue Muf , Serhii Iliushyk Subject: [PATCH v4 05/17] net/ntnic: use container device assignment API Date: Wed, 19 Nov 2025 11:01:48 +0000 Message-ID: <72abaa78ce9a772c962baa30c70eee8a33545a9b.1763549736.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 The NTNIC driver uses VFIO group bind/unbind functionality for container device assignment purposes. Use the new container device assignment API instead to provide clearer semantics. Signed-off-by: Anatoly Burakov --- drivers/net/ntnic/ntnic_vfio.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/drivers/net/ntnic/ntnic_vfio.c b/drivers/net/ntnic/ntnic_vfio.c index 439468b3a2..c746b300b2 100644 --- a/drivers/net/ntnic/ntnic_vfio.c +++ b/drivers/net/ntnic/ntnic_vfio.c @@ -28,7 +28,6 @@ nt_vfio_vf_num(const struct rte_pci_device *pdev) /* Internal API */ struct vfio_dev { int container_fd; - int group_fd; int dev_fd; uint64_t iova_addr; }; @@ -50,7 +49,6 @@ nthw_vfio_setup(struct rte_pci_device *dev) { int ret; char devname[RTE_DEV_NAME_MAX_LEN] = { 0 }; - int iommu_group_num; int vf_num; struct vfio_dev *vfio; @@ -66,14 +64,9 @@ nthw_vfio_setup(struct rte_pci_device *dev) } vfio->dev_fd = -1; - vfio->group_fd = -1; vfio->iova_addr = START_VF_IOVA; rte_pci_device_name(&dev->addr, devname, RTE_DEV_NAME_MAX_LEN); - ret = rte_vfio_get_group_num(rte_pci_get_sysfs_path(), devname, &iommu_group_num); - if (ret <= 0) - return -1; - if (vf_num == 0) { /* use default container for pf0 */ vfio->container_fd = RTE_VFIO_DEFAULT_CONTAINER_FD; @@ -86,17 +79,14 @@ nthw_vfio_setup(struct rte_pci_device *dev) "VFIO device setup failed. VFIO container creation failed."); return -1; } - } + ret = rte_vfio_container_assign_device(vfio->container_fd, + rte_pci_get_sysfs_path(), devname); + if (ret < 0) { + NT_LOG(ERR, NTNIC, + "VFIO device setup failed. Assign device to container failed."); + goto err; + } - vfio->group_fd = rte_vfio_container_group_bind(vfio->container_fd, iommu_group_num); - - if (vfio->group_fd < 0) { - NT_LOG(ERR, NTNIC, - "VFIO device setup failed. VFIO container group bind failed."); - goto err; - } - - if (vf_num > 0) { if (rte_pci_map_device(dev)) { NT_LOG(ERR, NTNIC, "Map VFIO device failed. is the vfio-pci driver loaded?"); @@ -106,10 +96,8 @@ nthw_vfio_setup(struct rte_pci_device *dev) vfio->dev_fd = rte_intr_dev_fd_get(dev->intr_handle); - NT_LOG(DBG, NTNIC, - "%s: VFIO id=%d, dev_fd=%d, container_fd=%d, group_fd=%d, iommu_group_num=%d", - dev->name, vf_num, vfio->dev_fd, vfio->container_fd, vfio->group_fd, - iommu_group_num); + NT_LOG(DBG, NTNIC, "%s: VFIO id=%d, dev_fd=%d, container_fd=%d", + dev->name, vf_num, vfio->dev_fd, vfio->container_fd); return vf_num; -- 2.47.3