Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp827238ybn; Tue, 24 Sep 2019 10:06:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqwgXkuHsHycGUJC/zR7zdY7A/cxIXGSmYPJcMxn7mfN5A5xxR0iqEVJ4g6hhgUxzeMwi9WB X-Received: by 2002:a05:6000:160a:: with SMTP id u10mr3631039wrb.235.1569344761387; Tue, 24 Sep 2019 10:06:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569344761; cv=none; d=google.com; s=arc-20160816; b=qWwqgyx2HI8rn05rUlbqYB/z1D3Z+j/x/4+56mZwg+EM6ax4xs1At4Y4sC72Nq3uza 8MlKLrM3X1/EHvX9BJMhKQVdTEDjASzK2bFSSG3dvn/Hw1NzGbWPbrEd3k7espFBq3Ah f9Saipk9zcB7tY5xJ5q4XTIYEPzz9kr5iBJBcdLY6+/fRQo0YeviWscpZUaFv45N5Ash DepAJD6SRdahiyxLxMkIyEGov1W/A6jB2B/XGagG3Br5Ptv8p7fhNZYVMzC2Yr8j1uAY 0RhOX+N5fC30kktyEHKFk05b5gPmXrP6Fvh53TulNHvp33Wev16gtr7sNQv1J0CcNIob 9e3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=As41xPJbzwa6FRWM+W0wj4dCQ7DOLwVWDoRP1N6bmps=; b=oe1S+CYqD02r5ztS7awQfPBe1ZN2JoAEB2+d5x+1MvbX71kIaXVztngvelwkK4WSoN J9l2Fw7sT5zTX/kRtLFKPoi/pFkp9R7xlaHRNQi+/WmkoAHUkZ1iLgSV0ryFo+S3ET51 7gHZuKgQ/8afpqADbgphlGsnnW9vmGxFg2NzyA+moRXQccCQLEFMMVEIi4sZFu8txI45 Q8AoWbp/K8vn00ggy6T/2RJu0O57Li+kQeV7iavJHpMevFyGCmPh/DCQwqE6JLm2UVXd o3yRZO8yzDQ30nzFc6cUeGGt3aomQNl+lNR7CDlkTtKvPqi8WEB/rHiBCIqPBIhr9nQM 71wA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c26si1598496edx.353.2019.09.24.10.05.37; Tue, 24 Sep 2019 10:06:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395059AbfIWND6 (ORCPT + 99 others); Mon, 23 Sep 2019 09:03:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55096 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390719AbfIWND5 (ORCPT ); Mon, 23 Sep 2019 09:03:57 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 91A0310DCC84; Mon, 23 Sep 2019 13:03:56 +0000 (UTC) Received: from jason-ThinkPad-X1-Carbon-6th.redhat.com (ovpn-12-93.pek2.redhat.com [10.72.12.93]) by smtp.corp.redhat.com (Postfix) with ESMTP id B17CD10013D9; Mon, 23 Sep 2019 13:03:33 +0000 (UTC) From: Jason Wang To: kvm@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, kwankhede@nvidia.com, alex.williamson@redhat.com, mst@redhat.com, tiwei.bie@intel.com Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, cohuck@redhat.com, maxime.coquelin@redhat.com, cunming.liang@intel.com, zhihong.wang@intel.com, rob.miller@broadcom.com, xiao.w.wang@intel.com, haotian.wang@sifive.com, zhenyuw@linux.intel.com, zhi.a.wang@intel.com, jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, airlied@linux.ie, daniel@ffwll.ch, farman@linux.ibm.com, pasic@linux.ibm.com, sebott@linux.ibm.com, oberpar@linux.ibm.com, heiko.carstens@de.ibm.com, gor@linux.ibm.com, borntraeger@de.ibm.com, akrowiak@linux.ibm.com, freude@linux.ibm.com, lingshan.zhu@intel.com, idos@mellanox.com, eperezma@redhat.com, lulu@redhat.com, parav@mellanox.com, Jason Wang Subject: [PATCH 0/6] mdev based hardware virtio offloading support Date: Mon, 23 Sep 2019 21:03:25 +0800 Message-Id: <20190923130331.29324-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.64]); Mon, 23 Sep 2019 13:03:57 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi all: There are hardware that can do virtio datapath offloading while having its own control path. This path tries to implement a mdev based unified API to support using kernel virtio driver to drive those devices. This is done by introducing a new mdev transport for virtio (virtio_mdev) and register itself as a new kind of mdev driver. Then it provides a unified way for kernel virtio driver to talk with mdev device implementation. Though the series only contains kernel driver support, the goal is to make the transport generic enough to support userspace drivers. This means vhost-mdev[1] could be built on top as well by resuing the transport. A sample driver is also implemented which simulate a virito-net loopback ethernet device on top of vringh + workqueue. This could be used as a reference implementation for real hardware driver. Consider mdev framework only support VFIO device and driver right now, this series also extend it to support other types. This is done through introducing class id to the device and pairing it with id_talbe claimed by the driver. On top, this seris also decouple device specific parents ops out of the common ones. Pktgen test was done with virito-net + mvnet loop back device. Please review. [1] https://lkml.org/lkml/2019/9/16/869 Changes from RFC-V2: - silent compile warnings on some specific configuration - use u16 instead u8 for class id - reseve MDEV_ID_VHOST for future vhost-mdev work - introduce "virtio" type for mvnet and make "vhost" type for future work - add entries in MAINTAINER - tweak and typos fixes in commit log Changes from RFC-V1: - rename device id to class id - add docs for class id and device specific ops (device_ops) - split device_ops into seperate headers - drop the mdev_set_dma_ops() - use device_ops to implement the transport API, then it's not a part of UAPI any more - use GFP_ATOMIC in mvnet sample device and other tweaks - set_vring_base/get_vring_base support for mvnet device Jason Wang (6): mdev: class id support mdev: introduce device specific ops mdev: introduce virtio device and its device ops virtio: introduce a mdev based transport vringh: fix copy direction of vringh_iov_push_kern() docs: sample driver to demonstrate how to implement virtio-mdev framework .../driver-api/vfio-mediated-device.rst | 11 +- MAINTAINERS | 3 + drivers/gpu/drm/i915/gvt/kvmgt.c | 17 +- drivers/s390/cio/vfio_ccw_ops.c | 17 +- drivers/s390/crypto/vfio_ap_ops.c | 14 +- drivers/vfio/mdev/Kconfig | 7 + drivers/vfio/mdev/Makefile | 1 + drivers/vfio/mdev/mdev_core.c | 21 +- drivers/vfio/mdev/mdev_driver.c | 14 + drivers/vfio/mdev/mdev_private.h | 1 + drivers/vfio/mdev/vfio_mdev.c | 37 +- drivers/vfio/mdev/virtio_mdev.c | 416 +++++++++++ drivers/vhost/vringh.c | 8 +- include/linux/mdev.h | 47 +- include/linux/mod_devicetable.h | 8 + include/linux/vfio_mdev.h | 53 ++ include/linux/virtio_mdev.h | 144 ++++ samples/Kconfig | 7 + samples/vfio-mdev/Makefile | 1 + samples/vfio-mdev/mbochs.c | 19 +- samples/vfio-mdev/mdpy.c | 19 +- samples/vfio-mdev/mtty.c | 17 +- samples/vfio-mdev/mvnet.c | 688 ++++++++++++++++++ 23 files changed, 1481 insertions(+), 89 deletions(-) create mode 100644 drivers/vfio/mdev/virtio_mdev.c create mode 100644 include/linux/vfio_mdev.h create mode 100644 include/linux/virtio_mdev.h create mode 100644 samples/vfio-mdev/mvnet.c -- 2.19.1