From patchwork Mon May 15 06:46:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Miao" X-Patchwork-Id: 126844 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 E101642B0E; Mon, 15 May 2023 08:47:21 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BD35B40687; Mon, 15 May 2023 08:47:21 +0200 (CEST) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id C228240395 for ; Mon, 15 May 2023 08:47:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684133240; x=1715669240; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NjeaE0TtYzmbMPPEjfnDYppylsxAYX99PrfQlFgSY0E=; b=kcPFPCdLYZKk17QGtdtbLXCNky1vx1EOkgOKRDd/HFNFEikO2ZEOB2NO q1ZCCcayU33eZenWEcbSCyOHYymSWV4v5D623sQgbHJK4iRoXx75pN24c FAF+DlQW5W53hWGd71cI1Dj37JBKGyf6TyxIigX83UmxkdFqb4ZE0+Uub W1xemBnkzEDnp9x5eYQcWSKP50PNtykVkPY/5GOlQvReHQVYDCUSUtdau B2FvX1NXGB5NWXwLgw9abVZYK8t3l6fWWaWR2wzDHQxeFRBKugZi77go5 x+oXNoQaUwoX0w0bUCpMlvOUn5uIYhlqdjZh6njlLtAT/mKvOMHFkvDzV Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10710"; a="414520095" X-IronPort-AV: E=Sophos;i="5.99,275,1677571200"; d="scan'208";a="414520095" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 May 2023 23:47:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10710"; a="651306323" X-IronPort-AV: E=Sophos;i="5.99,275,1677571200"; d="scan'208";a="651306323" Received: from dpdk-limiao-icelake.sh.intel.com ([10.67.111.26]) by orsmga003.jf.intel.com with ESMTP; 14 May 2023 23:47:16 -0700 From: Miao Li To: dev@dpdk.org Cc: skori@marvell.com, thomas@monjalon.net, david.marchand@redhat.com, ferruh.yigit@amd.com, chenbo.xia@intel.com, yahui.cao@intel.com Subject: [PATCH v1 0/4] Support VFIO sparse mmap in PCI bus Date: Mon, 15 May 2023 06:46:56 +0000 Message-Id: <20230515064700.624054-1-miao.li@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230418053012.10667-1-chenbo.xia@intel.com> References: <20230418053012.10667-1-chenbo.xia@intel.com> 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 This series introduces a VFIO standard capability, called sparse mmap to PCI bus. In linux kernel, it's defined as VFIO_REGION_INFO_CAP_SPARSE_MMAP. Sparse mmap means instead of mmap whole BAR region into DPDK process, only mmap part of the BAR region after getting sparse mmap information from kernel. For the rest of BAR region that is not mmap-ed, DPDK process can use pread/pwrite system calls to access. Sparse mmap is useful when kernel does not want userspace to mmap whole BAR region, or kernel wants to control over access to specific BAR region. Vendors can choose to enable this feature or not for their devices in their specific kernel modules. In this patchset: Patch 1-3 is mainly for introducing BAR access APIs so that driver could use them to access specific BAR using pread/pwrite system calls when part of the BAR is not mmap-able. Patch 4 adds the VFIO sparse mmap support finally. Chenbo Xia (3): bus/pci: introduce an internal representation of PCI device bus/pci: avoid depending on private value in kernel source bus/pci: introduce helper for MMIO read and write Miao Li (1): bus/pci: add VFIO sparse mmap support drivers/bus/pci/bsd/pci.c | 35 +++- drivers/bus/pci/linux/pci.c | 78 +++++-- drivers/bus/pci/linux/pci_init.h | 14 +- drivers/bus/pci/linux/pci_uio.c | 22 ++ drivers/bus/pci/linux/pci_vfio.c | 335 +++++++++++++++++++++++++------ drivers/bus/pci/pci_common.c | 12 +- drivers/bus/pci/private.h | 25 ++- drivers/bus/pci/rte_bus_pci.h | 48 +++++ drivers/bus/pci/version.map | 3 + lib/eal/include/rte_vfio.h | 1 - 10 files changed, 482 insertions(+), 91 deletions(-)