From patchwork Wed Jan 3 16:36:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Hayes X-Patchwork-Id: 10142601 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C7BB860594 for ; Wed, 3 Jan 2018 16:36:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2E3B29087 for ; Wed, 3 Jan 2018 16:36:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7C3C29105; Wed, 3 Jan 2018 16:36:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51D9329087 for ; Wed, 3 Jan 2018 16:36:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751397AbeACQgz (ORCPT ); Wed, 3 Jan 2018 11:36:55 -0500 Received: from mail-oi0-f67.google.com ([209.85.218.67]:34080 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750912AbeACQgv (ORCPT ); Wed, 3 Jan 2018 11:36:51 -0500 Received: by mail-oi0-f67.google.com with SMTP id u193so1308277oie.1 for ; Wed, 03 Jan 2018 08:36:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=zWYpcXFlpoYO9SW9eu49fZeGaU53pzehxIp771+lHc0=; b=YO2l7yj5HrGzHIBBWfXF7AzmZqkAeMetT0VNRNttIjIoW3LuP916gLpaWG6EIn4aix SpmUz4+6urmb2FAqn5gRK88hdozrJx30sfSmVpXPhlVWmwYW4ulX34yBxKVITT6Ej+4M Vk+K6DeI1AZUtj7RBOWEztmC7bdUjFWYxl3WRxOV5sLDxiO9TMKIz7gBOeMz4Dmhui57 7ZZK5llJG4gxneVNhh4nsLszQxQMWcsAUxGbWRKeEJ41UXbtJnecXPGhRjkxBlUHFN3R 8H74etHnwsssHFtd9D6Cdzj3AfwnhuqC5jsO/ehOietta0Y7a8pRrVuTpv3GhxdH2pJv D7cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=zWYpcXFlpoYO9SW9eu49fZeGaU53pzehxIp771+lHc0=; b=rAFYqjmDI99FtsWNTwL4bkLz4iJaRuQfmop6ooYrkKqRKdk8DwlIdeRznDzF1MiAeC u/zh7mcg/3OTERoNhxSsE24lDX+0XduWf6G7PESpFJLq4QQLNHt4fdfey/UsBXVN0PF5 OTDo0U2F0wsO4fTbmsnJDhfDmnhpdaJdpHaZAp8OP79f58VBTV5TDk3zGhooj5yKtUDI 5J9VaUeK5SswV3xY86KpteYUxI7knPb4lA6KM40DB9XXTGtBB4FG0dUtC40BdetHP7p1 M0o2F3/6/qNnVXhPky0XoopNRZlGQYONTMatSh10wgJEuFLWetunUxnXwTLKzZMHl5cU 8AAA== X-Gm-Message-State: AKGB3mLUfkVNNi9/I5xmJmwLfyNwSLxpgZlkAoq2bcHzo1ooDlCdwzSk P1IQW16+6mU2/br9KZAPJFqxyclW X-Google-Smtp-Source: ACJfBotr6ijroO7S0e4mXsNzaTouda8lz7MTTjslDOKkF0efB30LoX74FxgVl7EJ36PD7eckxbmOwg== X-Received: by 10.202.196.144 with SMTP id u138mr1068048oif.128.1514997409578; Wed, 03 Jan 2018 08:36:49 -0800 (PST) Received: from [192.168.0.2] (cpe-24-27-59-32.austin.res.rr.com. [24.27.59.32]) by smtp.gmail.com with ESMTPSA id q7sm443132oif.20.2018.01.03.08.36.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Jan 2018 08:36:48 -0800 (PST) From: Stuart Hayes Subject: [PATCH] PCI, sysfs: show ari_enabled in sysfs To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org Message-ID: <3cfc87ab-755a-680a-d06f-ee7cc38d2195@gmail.com> Date: Wed, 3 Jan 2018 10:36:46 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 Content-Language: en-US X-Antivirus: Avast (VPS 180103-0, 01/03/2018), Outbound message X-Antivirus-Status: Clean Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some multifunction PCI devices with more than 8 functions use "alternative routing-ID interpretation" (ARI), which means the 8-bit device/function number field will be interpreted as 8 bits specifying the function number (the device number is 0 implicitly), rather than the upper 5 bits specifying the device number and the lower 3 bits specifying the function number. The kernel can enable and use this. Expose in a sysfs attribute whether the kernel has enabled ARI, so that a program in userspace won't have to parse PCI devices and PCI configuration space to figure out if it is enabled. This will allow better predictable network naming using PCI function numbers without using PCI bus or device numbers, which is desirable because bus and device numbers can change with system configuration but function numbers will not. Signed-off-by: Stuart Hayes --- --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus --- linux-4.15-rc6/drivers/pci/pci-sysfs.c.orig 2017-12-31 17:47:43.000000000 -0500 +++ linux-4.15-rc6/drivers/pci/pci-sysfs.c 2018-01-02 13:58:23.372928377 -0500 @@ -278,6 +278,16 @@ static ssize_t subordinate_bus_number_sh } static DEVICE_ATTR_RO(subordinate_bus_number); +static ssize_t ari_enabled_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct pci_dev *pci_dev = to_pci_dev(dev); + + return sprintf(buf, "%u\n", pci_ari_enabled(pci_dev->bus)); +} +static DEVICE_ATTR_RO(ari_enabled); + static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -786,6 +796,7 @@ static struct attribute *pci_dev_attrs[] &dev_attr_devspec.attr, #endif &dev_attr_driver_override.attr, + &dev_attr_ari_enabled.attr, NULL, };