From patchwork Fri Aug 4 07:09:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saurabh Singh Sengar X-Patchwork-Id: 13123 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:44a:b0:3f2:4152:657d with SMTP id ez10csp88558vqb; Fri, 4 Aug 2023 00:31:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF95UTgmNJqji2ERxpZiWZpZMkzH+mNEOn4mP9VCvwdvKgFw8j0ebg+sLFAzJe+4gzgZZ5p X-Received: by 2002:a05:6a20:3206:b0:138:2fb8:6a14 with SMTP id hl6-20020a056a20320600b001382fb86a14mr866824pzc.3.1691134280686; Fri, 04 Aug 2023 00:31:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691134280; cv=none; d=google.com; s=arc-20160816; b=N1FZ3j9hbSB8+y9V0+jZ71JMZfZ0+1ITbV1GiplTTA0f5eV7ji4TogwqUqH0RqQ10t qKPb92E1Nr5is7z2fPnysw3HVFzi5EWzAABZLhGj4IbFNe+brd07X7TonmKSWl0njx4Q kCd+7RJ+MySSyPboExcvZai1sonXPfxFAOdTW5iQjEwN7phQEEerzGe5NF8IpvQDWrgV SGBXLQeNUAH+VrgZDGu5MgrUx+jdffvsNPe3hgH6+QN/GMYDpR2wGa8hJfALI+cUCkL7 egilPEXM5QM/eNqLZTKPtLHV7qheKjvJktPOumuGiTRdwyDD0PL+7vo/b050CXAJgGr6 NM1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:to:from:dkim-signature :dkim-filter; bh=H3kqU/firIHr0S+sRVsFVo5ha4Q/UyDjIzEmNKSv7DA=; fh=ahkjrYVgnZMRmK+J626CGhBdW9goONUEh6WYVopVVOA=; b=Db4Xz3cK7wFCuU3AfMeI8/uoILk2NqPtw4SdOOR/jdQ0jxuCEZu7GipGxK1ZegWzAB vJCvqo8xQLwEYNKJ7JS9n4FG341tqz3/zixrDZ5UMpIhZp8zlSF7+2t/IdUXBwckJLKY B5NFEG1fR2C+l33zo7on9+jQ67syipM0i/nVssGyem/mE8gHY7BIJlswtS5SCav/QOqW X6YVb1Yqs1dXjnafl+RD12PhQe28+X63L11dSsCQnCuvMOYzJJlEsQbP+3P2rN2dKmwt cW8MLSIP/czEXibFJ4PN6tblKFG8DBaaKGMbhOTvorGB67xLURi7vfq3BrkyficGSISz /krA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=QpGMobgt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n15-20020a654ccf000000b0055ba896f567si1352011pgt.585.2023.08.04.00.31.07; Fri, 04 Aug 2023 00:31:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=QpGMobgt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234096AbjHDHKI (ORCPT + 99 others); Fri, 4 Aug 2023 03:10:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234038AbjHDHKD (ORCPT ); Fri, 4 Aug 2023 03:10:03 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8BE9E30DD; Fri, 4 Aug 2023 00:10:00 -0700 (PDT) Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id D2531207F5BB; Fri, 4 Aug 2023 00:09:59 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com D2531207F5BB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1691132999; bh=H3kqU/firIHr0S+sRVsFVo5ha4Q/UyDjIzEmNKSv7DA=; h=From:To:Subject:Date:From; b=QpGMobgtGYz5xyM1/7pPxicy9Nt9W3V+4PG2f1YX6hoH0HT1FOTHWWJ0MZZc9G6i4 xneqmhYByZKs4LQ0tM83mI0OkCpB7OuohCSmyZXqVjijizcbpEXwSvwRJEhqLXf7Ad O5WQptarMMLP0lCz0H3cNYcbmJlvt/6UrhyivrAs= From: Saurabh Sengar To: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, mikelley@microsoft.com, gregkh@linuxfoundation.org, corbet@lwn.net, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v4 0/3] UIO driver for low speed Hyper-V devices Date: Fri, 4 Aug 2023 00:09:53 -0700 Message-Id: <1691132996-11706-1-git-send-email-ssengar@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 X-Spam-Status: No, score=-17.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773282819021950909 X-GMAIL-MSGID: 1773282819021950909 Hyper-V is adding multiple low speed "speciality" synthetic devices. Instead of writing a new kernel-level VMBus driver for each device, make the devices accessible to user space through a UIO-based hv_vmbus_client driver. Each device can then be supported by a user space driver. This approach optimizes the development process and provides flexibility to user space applications to control the key interactions with the VMBus ring buffer. The new synthetic devices are low speed devices that don't support VMBus monitor bits, and so they must use vmbus_setevent() to notify the host of ring buffer updates. The new driver provides this functionality along with a configurable ring buffer size. Moreover, this series of patches incorporates an update to the fcopy application, enabling it to seamlessly utilize the new interface. The older fcopy driver and application will be phased out gradually. Development of other similar userspace drivers is still underway. Moreover, this patch series adds a new implementation of the fcopy application that uses the new UIO driver. The older fcopy driver and application will be phased out gradually. Development of other similar userspace drivers is still underway. [V4] - Modify comment to remove RingDataStartOffset mention - Change downward ALIGN macro to upward ALIGN - Add error check for setting ring_size value in sysfs entry - Add error handling in fcopy_get_instance_id for instance id not found case [V3] - Removed ringbuffer sysfs entry and used uio framework for mmap - Remove ".id_table = NULL" - kasprintf -> devm_kasprintf - Change global variable ring_size to per device - More checks on value which can be set for ring_size - Remove driverctl, and used echo command instead for driver documentation - Remove unnecessary one time use macros - Change kernel version and date for sysfs documentation - Update documentation. - Made ring buffer data offset depend on page size - remove rte_smp_rwmb macro and reused rte_compiler_barrier instead - Added legal counsel sign-off - simplify mmap - Removed "Link:" tag - Improve cover letter and commit messages - Improve debug prints - Instead of hardcoded instance id, query from class id sysfs - Set the ring_size value from application - new application compilation dependent on x86 - Not removing the old driver and application for backward compatibility [V2] - Update driver info in Documentation/driver-api/uio-howto.rst - Update ring_size sysfs info in Documentation/ABI/stable/sysfs-bus-vmbus - Remove DRIVER_VERSION - Remove refcnt - scnprintf -> sysfs_emit - sysfs_create_file -> ATTRIBUTE_GROUPS + ".driver.groups"; - sysfs_create_bin_file -> device_create_bin_file - dev_notice -> dev_err - remove MODULE_VERSION - simpler sysfs path, less parsing Saurabh Sengar (3): uio: Add hv_vmbus_client driver tools: hv: Add vmbus_bufring tools: hv: Add new fcopy application based on uio driver Documentation/ABI/stable/sysfs-bus-vmbus | 10 + Documentation/driver-api/uio-howto.rst | 54 +++ drivers/uio/Kconfig | 12 + drivers/uio/Makefile | 1 + drivers/uio/uio_hv_vmbus_client.c | 218 +++++++++ tools/hv/Build | 2 + tools/hv/Makefile | 21 +- tools/hv/hv_fcopy_uio_daemon.c | 587 +++++++++++++++++++++++ tools/hv/vmbus_bufring.c | 297 ++++++++++++ tools/hv/vmbus_bufring.h | 154 ++++++ 10 files changed, 1355 insertions(+), 1 deletion(-) create mode 100644 drivers/uio/uio_hv_vmbus_client.c create mode 100644 tools/hv/hv_fcopy_uio_daemon.c create mode 100644 tools/hv/vmbus_bufring.c create mode 100644 tools/hv/vmbus_bufring.h