From patchwork Wed Apr 3 07:18:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tiwei Bie X-Patchwork-Id: 52142 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0D21A5689; Wed, 3 Apr 2019 09:19:27 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 943294F9A for ; Wed, 3 Apr 2019 09:19:24 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Apr 2019 00:19:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,303,1549958400"; d="scan'208";a="128206231" Received: from dpdk-tbie.sh.intel.com ([10.67.104.173]) by orsmga007.jf.intel.com with ESMTP; 03 Apr 2019 00:19:22 -0700 From: Tiwei Bie To: dev@dpdk.org Cc: cunming.liang@intel.com, bruce.richardson@intel.com, alejandro.lucero@netronome.com Date: Wed, 3 Apr 2019 15:18:41 +0800 Message-Id: <20190403071844.21126-1-tiwei.bie@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [RFC 0/3] Add mdev (Mediated device) support in DPDK X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi everyone, This is a draft implementation of the mdev (Mediated device [1]) bus support in DPDK. Mdev is a way to virtualize devices in Linux kernel. Based on the device-api (mdev_type/device_api), there could be different types of mdev devices (e.g. vfio-pci). In this RFC, one mdev bus is introduced to scan the mdev devices in the system and do the probe based on the device-api. Take the mdev devices whose device-api is "vfio-pci" as an example, in this RFC, these devices will be probed by a mdev driver provided by PCI bus, which will plug them to the PCI bus. And they will be probed with the drivers registered on the PCI bus based on VendorID/ DeviceID/... then. +----------+ | mdev bus | +----+-----+ | +----------------+----+------+------+ | | | | mdev_vfio_pci ...... (device-api: vfio-pci) There are also other ways to add mdev device support in DPDK (e.g. let PCI bus scan /sys/bus/mdev/devices directly). Comments would be appreciated! [1] https://github.com/torvalds/linux/blob/master/Documentation/vfio-mediated-device.txt Thanks, Tiwei Tiwei Bie (3): eal: add a helper for reading string from sysfs bus/mdev: add mdev bus support bus/pci: add mdev support config/common_base | 5 + config/common_linux | 1 + drivers/bus/Makefile | 1 + drivers/bus/mdev/Makefile | 41 +++ drivers/bus/mdev/linux/Makefile | 6 + drivers/bus/mdev/linux/mdev.c | 117 ++++++++ drivers/bus/mdev/mdev.c | 310 ++++++++++++++++++++++ drivers/bus/mdev/meson.build | 15 ++ drivers/bus/mdev/private.h | 90 +++++++ drivers/bus/mdev/rte_bus_mdev.h | 141 ++++++++++ drivers/bus/mdev/rte_bus_mdev_version.map | 12 + drivers/bus/meson.build | 2 +- drivers/bus/pci/Makefile | 3 + drivers/bus/pci/linux/Makefile | 4 + drivers/bus/pci/linux/pci_vfio.c | 35 ++- drivers/bus/pci/linux/pci_vfio_mdev.c | 305 +++++++++++++++++++++ drivers/bus/pci/meson.build | 4 +- drivers/bus/pci/pci_common.c | 17 +- drivers/bus/pci/private.h | 9 + drivers/bus/pci/rte_bus_pci.h | 11 +- lib/librte_eal/common/eal_filesystem.h | 7 + lib/librte_eal/freebsd/eal/eal.c | 22 ++ lib/librte_eal/linux/eal/eal.c | 22 ++ lib/librte_eal/rte_eal_version.map | 1 + mk/rte.app.mk | 1 + 25 files changed, 1163 insertions(+), 19 deletions(-) create mode 100644 drivers/bus/mdev/Makefile create mode 100644 drivers/bus/mdev/linux/Makefile create mode 100644 drivers/bus/mdev/linux/mdev.c create mode 100644 drivers/bus/mdev/mdev.c create mode 100644 drivers/bus/mdev/meson.build create mode 100644 drivers/bus/mdev/private.h create mode 100644 drivers/bus/mdev/rte_bus_mdev.h create mode 100644 drivers/bus/mdev/rte_bus_mdev_version.map create mode 100644 drivers/bus/pci/linux/pci_vfio_mdev.c