Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5497708ybe; Tue, 10 Sep 2019 04:47:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqxTRi9AL4iKbeJUhBAUZgdaIhxk2QS7EW0eNAO4B44CZLvHwUbYUdEggp55piPhhSRDuauu X-Received: by 2002:a17:906:b211:: with SMTP id p17mr24083571ejz.11.1568116068142; Tue, 10 Sep 2019 04:47:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568116068; cv=none; d=google.com; s=arc-20160816; b=FtqR8E0aPymAGJKKt0g/ZwvjkTVwuIdBWL4Dqr8yF6ncvMclc657qns3D1RW7upLES pEhXqpVsvB8lXbFbEl6/GA+QYAkZC8/eR8I0My4YFstxSuhtDTU0KH0i4+WmJc4VMbTk WDEzO+kuUlv2/fSj1pnkkCHIiGMfmCBSuPZyeNhwpUgTziHi6jrN3LYssZhjkMzWXPWE /THIqYOi5N7SLhAHtC6xOo1lQqLUJbmExJiSMhLpj305L28UU3C9g5SKesji+F2Rb29s djYJt25MYVYu0zRhjLeUwTdMKqeKSpNyc6VYTKPpdd0QX1fAb5W111jEqzt9VBOcH4+A jXSA== 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=1zMFqOsbbSRWPhsPjIBPjKFy6IUkWh6n1eXzuPReZyo=; b=p5te7WFAXYXwdYHKx1l8IHBOx6gjSlHWY3U/vzXnqf5UcEMOkE6cFjA7wILLU6ThAe oY/e1PoM/eA40kXxMQ1dqSnf1SWM1MTb2EENdggnvXXQCJnHAd9nu0WDcjdhwSh1UugX +VN3DMiiMOdWupdA1vJUl3o6TY4oDMemi2q2xpzpirAh1P7BnsVMoSMJru/PgyuCU+YG dluHZ4AWhFP9mXw3hKEt+2hMQ7djs5m58c7KZyONkYA8W0n3AwKkehj91l01vHXPZhKC iv8+VZzgPdnrzzW0p+xG9uu9Bc43oey0Bl7T5mxY8wXNy6D4ausS8lg8USbvztqb6lQU sQNA== 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 b9si7194182eju.125.2019.09.10.04.47.23; Tue, 10 Sep 2019 04:47:48 -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 S2406742AbfIJIUE (ORCPT + 99 others); Tue, 10 Sep 2019 04:20:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54330 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731155AbfIJIUE (ORCPT ); Tue, 10 Sep 2019 04:20:04 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 026D55859E; Tue, 10 Sep 2019 08:20:03 +0000 (UTC) Received: from jason-ThinkPad-X1-Carbon-6th.redhat.com (ovpn-12-188.pek2.redhat.com [10.72.12.188]) by smtp.corp.redhat.com (Postfix) with ESMTP id 449B56092F; Tue, 10 Sep 2019 08:19:49 +0000 (UTC) From: Jason Wang To: mst@redhat.com, jasowang@redhat.com, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kwankhede@nvidia.com, alex.williamson@redhat.com, cohuck@redhat.com, tiwei.bie@intel.com, maxime.coquelin@redhat.com, cunming.liang@intel.com, zhihong.wang@intel.com, rob.miller@broadcom.com, idos@mellanox.com, xiao.w.wang@intel.com, haotian.wang@sifive.com Subject: [RFC PATCH 0/4] mdev based hardware virtio offloading support Date: Tue, 10 Sep 2019 16:19:31 +0800 Message-Id: <20190910081935.30516-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 10 Sep 2019 08:20:03 +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 contain 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. Notes: - Some of the key transport command for vhost-mdev(userspace driver) is not introduced. This includes: 1) set/get virtqueue state (idx etc), this could be simply done by introducing new transport command 2) dirty pages tracking, could be simply done by introducing new transport command 3) set/get device internal state, this requires more thought, of course we can introduce device specific transport command, but it would be better to have a unified API - Current mdev_parent_ops assumes all pointers are userspace pointer, this block the kernel driver, this series just abuse those as kernel pointer and this could be addressed by inventing new parent_ops. - For quick POC, mdev transport was just derived from virtio-MMIO, I'm pretty sure it has lots of space to be optimized, please share your thought. Please review. [1] https://lkml.org/lkml/2019/8/28/35 Jason Wang (4): vringh: fix copy direction of vringh_iov_push_kern() mdev: introduce helper to set per device dma ops virtio: introudce a mdev based transport docs: Sample driver to demonstrate how to implement virtio-mdev framework drivers/vfio/mdev/Kconfig | 7 + drivers/vfio/mdev/Makefile | 1 + drivers/vfio/mdev/mdev_core.c | 7 + drivers/vfio/mdev/virtio_mdev.c | 500 ++++++++++++++++++++ drivers/vhost/vringh.c | 8 +- include/linux/mdev.h | 2 + include/uapi/linux/virtio_mdev.h | 131 ++++++ samples/Kconfig | 7 + samples/vfio-mdev/Makefile | 1 + samples/vfio-mdev/mvnet.c | 766 +++++++++++++++++++++++++++++++ 10 files changed, 1429 insertions(+), 1 deletion(-) create mode 100644 drivers/vfio/mdev/virtio_mdev.c create mode 100644 include/uapi/linux/virtio_mdev.h create mode 100644 samples/vfio-mdev/mvnet.c -- 2.19.1