From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2AF2C43381 for ; Fri, 29 Mar 2019 16:04:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9849C218A2 for ; Fri, 29 Mar 2019 16:04:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WPT6GVZ+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729860AbfC2QEv (ORCPT ); Fri, 29 Mar 2019 12:04:51 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:39945 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729622AbfC2QEr (ORCPT ); Fri, 29 Mar 2019 12:04:47 -0400 Received: by mail-pf1-f194.google.com with SMTP id c207so1267941pfc.7; Fri, 29 Mar 2019 09:04:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JSl5oABSBhR0d5oyKM/uoNbyBv6XJ60CVTC/Rds0eDY=; b=WPT6GVZ+RJf3gNOzGgi0am9L3FuxXU8DP9AwLFEJWeTl8UFn0UOv3EJgxAiW/87KoU 3r+vGPCSpHFAVOsqZKFgSCIm8x+Mo2QJd1Iz271agPpnHbecdWiHJYQypf8FcFANqbAn SQqzzSdmXh3yH8YRfyVGr3tZR9PwwMGxC/vsYuGWLcesPyq29d5+NlboOvAe2GWeZ6wQ ExO86lvJ7YDOiptl6AiNSq8PDCe3FGs6gCHV3cmFHKAYAdtRXjdxwgz2kQ+3thWfhG1K /Z9SU2cDH1eYE8/OFZypYqvTYBZmBdvX4hzrlJeGuWG3y/kSBcSjQFCYa5XEkcpJqauc jXHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JSl5oABSBhR0d5oyKM/uoNbyBv6XJ60CVTC/Rds0eDY=; b=kSwgPZNKBsDTZbg3A4XkycNEChZHPpWdtxTFy45LC160aLr5N8eWxeHCWKTmOjbMqD 6YW2rUlyo5kxzrpigjxGl6slIViPAziwezsjExH6Ho6BKikXPt8lnLvISreJfGXc9dJ/ +WyaoILjiq4wb/0TgLlWvK8c1NLFIt1ZNuozVkV+Eqt9tW59ap8Dr4gajhs5uOYqMh9D Sp1OInBBbvw4Pz9zEUXdq9l0Fz2pdhlDIpcIDzx97x3r6yti9rI2h3ZN3tJuffc6+bmo vMRqDeVnjwKT6jZBzJOBtRGm98wGmYZoXsHYbXRRdRRj3VMaYH8t7i15CO2NV4Cg+lzQ 19Rg== X-Gm-Message-State: APjAAAXrUKE+6ThvGaNcAiIVcufokKhuW3iI3J9zw1/UT5DOGdz3GgN0 brXdkRC44ZWTqFTmct7uYPE= X-Google-Smtp-Source: APXvYqwapek7u4KUcAnqI4YoQCgCSreHL6XAVG9HYJPeG6E/yUl2qRplu4UI8/wKWyuLlB0CecSnWw== X-Received: by 2002:aa7:938b:: with SMTP id t11mr40654496pfe.67.1553875487065; Fri, 29 Mar 2019 09:04:47 -0700 (PDT) Received: from localhost.localdomain ([104.238.181.70]) by smtp.gmail.com with ESMTPSA id i1sm9484285pgc.63.2019.03.29.09.04.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Mar 2019 09:04:46 -0700 (PDT) From: Changbin Du To: Jonathan Corbet Cc: Bjorn Helgaas , linux-pci@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Changbin Du Subject: [PATCH 04/12] pci doc: convert PCI/pci-iov-howto.txt to rst format Date: Sat, 30 Mar 2019 00:04:05 +0800 Message-Id: <20190329160413.4293-5-changbin.du@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190329160413.4293-1-changbin.du@gmail.com> References: <20190329160413.4293-1-changbin.du@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This converts the plain text documentation to reStructuredText format and add it to Sphinx TOC tree. No essential content change. Signed-off-by: Changbin Du --- Documentation/PCI/index.rst | 1 + .../{pci-iov-howto.txt => pci-iov-howto.rst} | 144 ++++++++++-------- 2 files changed, 85 insertions(+), 60 deletions(-) rename Documentation/PCI/{pci-iov-howto.txt => pci-iov-howto.rst} (65%) diff --git a/Documentation/PCI/index.rst b/Documentation/PCI/index.rst index 58ce08f14f33..751cd8f23c62 100644 --- a/Documentation/PCI/index.rst +++ b/Documentation/PCI/index.rst @@ -9,3 +9,4 @@ Linux PCI Bus Subsystem pci PCIEBUS-HOWTO + pci-iov-howto diff --git a/Documentation/PCI/pci-iov-howto.txt b/Documentation/PCI/pci-iov-howto.rst similarity index 65% rename from Documentation/PCI/pci-iov-howto.txt rename to Documentation/PCI/pci-iov-howto.rst index d2a84151e99c..068e2c93e828 100644 --- a/Documentation/PCI/pci-iov-howto.txt +++ b/Documentation/PCI/pci-iov-howto.rst @@ -1,14 +1,20 @@ - PCI Express I/O Virtualization Howto - Copyright (C) 2009 Intel Corporation - Yu Zhao +.. SPDX-License-Identifier: GPL-2.0 +.. include:: - Update: November 2012 - -- sysfs-based SRIOV enable-/disable-ment - Donald Dutile +==================================== +PCI Express I/O Virtualization Howto +==================================== + +:Copyright: |copy| 2009 Intel Corporation +:Authors: - Yu Zhao + - Update: November 2012, sysfs-based SRIOV enable-/disable-ment, + Donald Dutile 1. Overview +=========== 1.1 What is SR-IOV +------------------ Single Root I/O Virtualization (SR-IOV) is a PCI Express Extended capability which makes one physical device appear as multiple virtual @@ -24,8 +30,10 @@ operates on the register set so it can be functional and appear as a real existing PCI device. 2. User Guide +============= 2.1 How can I enable SR-IOV capability +-------------------------------------- Multiple methods are available for SR-IOV enablement. In the first method, the device driver (PF driver) will control the @@ -44,104 +52,120 @@ numvfs <= totalvfs. The second method is the recommended method for new/future VF devices. 2.2 How can I use the Virtual Functions +--------------------------------------- The VF is treated as hot-plugged PCI devices in the kernel, so they should be able to work in the same way as real PCI devices. The VF requires device driver that is same as a normal PCI device's. 3. Developer Guide +================== 3.1 SR-IOV API +-------------- To enable SR-IOV capability: -(a) For the first method, in the driver: +(a) For the first method, in the driver:: + int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn); - 'nr_virtfn' is number of VFs to be enabled. -(b) For the second method, from sysfs: + +'nr_virtfn' is number of VFs to be enabled. + +(b) For the second method, from sysfs:: + echo 'nr_virtfn' > \ /sys/bus/pci/devices//sriov_numvfs To disable SR-IOV capability: -(a) For the first method, in the driver: +(a) For the first method, in the driver:: + void pci_disable_sriov(struct pci_dev *dev); -(b) For the second method, from sysfs: + +(b) For the second method, from sysfs:: + echo 0 > \ /sys/bus/pci/devices//sriov_numvfs To enable auto probing VFs by a compatible driver on the host, run command below before enabling SR-IOV capabilities. This is the default behavior. +:: + echo 1 > \ /sys/bus/pci/devices//sriov_drivers_autoprobe To disable auto probing VFs by a compatible driver on the host, run command below before enabling SR-IOV capabilities. Updating this entry will not affect VFs which are already probed. +:: + echo 0 > \ /sys/bus/pci/devices//sriov_drivers_autoprobe 3.2 Usage example +----------------- Following piece of code illustrates the usage of the SR-IOV API. +:: -static int dev_probe(struct pci_dev *dev, const struct pci_device_id *id) -{ - pci_enable_sriov(dev, NR_VIRTFN); + static int dev_probe(struct pci_dev *dev, const struct pci_device_id *id) + { + pci_enable_sriov(dev, NR_VIRTFN); - ... - - return 0; -} + ... -static void dev_remove(struct pci_dev *dev) -{ - pci_disable_sriov(dev); + return 0; + } - ... -} + static void dev_remove(struct pci_dev *dev) + { + pci_disable_sriov(dev); -static int dev_suspend(struct pci_dev *dev, pm_message_t state) -{ - ... + ... + } - return 0; -} + static int dev_suspend(struct pci_dev *dev, pm_message_t state) + { + ... -static int dev_resume(struct pci_dev *dev) -{ - ... + return 0; + } - return 0; -} + static int dev_resume(struct pci_dev *dev) + { + ... -static void dev_shutdown(struct pci_dev *dev) -{ - ... -} + return 0; + } -static int dev_sriov_configure(struct pci_dev *dev, int numvfs) -{ - if (numvfs > 0) { - ... - pci_enable_sriov(dev, numvfs); + static void dev_shutdown(struct pci_dev *dev) + { ... - return numvfs; } - if (numvfs == 0) { - .... - pci_disable_sriov(dev); - ... - return 0; + + static int dev_sriov_configure(struct pci_dev *dev, int numvfs) + { + if (numvfs > 0) { + ... + pci_enable_sriov(dev, numvfs); + ... + return numvfs; + } + if (numvfs == 0) { + .... + pci_disable_sriov(dev); + ... + return 0; + } } -} - -static struct pci_driver dev_driver = { - .name = "SR-IOV Physical Function driver", - .id_table = dev_id_table, - .probe = dev_probe, - .remove = dev_remove, - .suspend = dev_suspend, - .resume = dev_resume, - .shutdown = dev_shutdown, - .sriov_configure = dev_sriov_configure, -}; + + static struct pci_driver dev_driver = { + .name = "SR-IOV Physical Function driver", + .id_table = dev_id_table, + .probe = dev_probe, + .remove = dev_remove, + .suspend = dev_suspend, + .resume = dev_resume, + .shutdown = dev_shutdown, + .sriov_configure = dev_sriov_configure, + }; -- 2.20.1