From patchwork Sun Jan 24 13:11:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 370497 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=-14.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, 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 B501DC433E9 for ; Sun, 24 Jan 2021 13:12:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 84FD022ADC for ; Sun, 24 Jan 2021 13:12:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726868AbhAXNMI (ORCPT ); Sun, 24 Jan 2021 08:12:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:42118 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726709AbhAXNMF (ORCPT ); Sun, 24 Jan 2021 08:12:05 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8B7A722B43; Sun, 24 Jan 2021 13:11:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611493884; bh=IEsyjDY7zSbJ5Aj9oqIKtFHISGfnLynAX6NdFWS/8IQ=; h=From:To:Cc:Subject:Date:From; b=Tg27ss96WJMdUDNQZjAWlaTnzH3q6uFFdoeQlJkgKNmEcMcPtOrOf3vrTx7b5E8UN 15Na8sqE5WvGdP7PR2llUXxLFxWRQ5oxb4D5L6wn94UQkJbSqJpQtjdTvuyxRU2RRc E4DpsDjlQmYN8W12Nf37Y6u15ZVnErkoHRhoYUJm/+1qj5J1TxW1inJuvQBHTd3lwY xDUR4L/OkjmWInEB/E7ljbo7V00u8BoiOb7rd1bPb3Nh/mXLH5eGAzgP6ay2HnqT0Q lykK9E4t2ARHravS0jJork3amZ9ibBVY17WmBmjT2udVXlNMygB5UTomsIROyKjdNV DmHn+Fn/Gkbmw== From: Leon Romanovsky To: Bjorn Helgaas , Saeed Mahameed Cc: Leon Romanovsky , Jason Gunthorpe , Alexander Duyck , Jakub Kicinski , linux-pci@vger.kernel.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, Don Dutile , Alex Williamson , "David S . Miller" Subject: [PATCH mlx5-next v4 0/4] Dynamically assign MSI-X vectors count Date: Sun, 24 Jan 2021 15:11:15 +0200 Message-Id: <20210124131119.558563-1-leon@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Leon Romanovsky Changelog v4: * Used sysfs_emit() instead of sprintf() in new sysfs entries. * Changed EXPORT_SYMBOL to be EXPORT_SYMBOL_GPL for pci_iov_virtfn_devfn(). * Rewrote sysfs registration code to be driven by PF that wants to enable VF overlay instead of creating to all SR-IOV devices. * Grouped all such functionality under new "vfs_overlay" folder. * Combined two PCI patches into one. v3: https://lore.kernel.org/linux-pci/20210117081548.1278992-1-leon@kernel.org * Renamed pci_set_msix_vec_count to be pci_vf_set_msix_vec_count. * Added VF msix_cap check to hide sysfs entry if device doesn't support msix. * Changed "-" to be ":" in the mlx5 patch to silence CI warnings about missing kdoc description. * Split differently error print in mlx5 driver to avoid checkpatch warning. v2: https://lore.kernel.org/linux-pci/20210114103140.866141-1-leon@kernel.org * Patch 1: * Renamed vf_msix_vec sysfs knob to be sriov_vf_msix_count * Added PF and VF device locks during set MSI-X call to protect from parallel driver bind/unbind operations. * Removed extra checks when reading sriov_vf_msix, because users will be able to distinguish between supported/not supported by looking on sriov_vf_total_msix count. * Changed all occurrences of "numb" to be "count" * Changed returned error from EOPNOTSUPP to be EBUSY if user tries to set MSI-X count after driver already bound to the VF. * Added extra comment in pci_set_msix_vec_count() to emphasize that driver should not be bound. * Patch 2: * Changed vf_total_msix from int to be u32 and updated function signatures accordingly. * Improved patch title v1: https://lore.kernel.org/linux-pci/20210110150727.1965295-1-leon@kernel.org * Improved wording and commit messages of first PCI patch * Added extra PCI patch to provide total number of MSI-X vectors * Prohibited read of vf_msix_vec sysfs file if driver doesn't support write * Removed extra function definition in pci.h v0: https://lore.kernel.org/linux-pci/20210103082440.34994-1-leon@kernel.org -------------------------------------------------------------------- Hi, The number of MSI-X vectors is PCI property visible through lspci, that field is read-only and configured by the device. The static assignment of an amount of MSI-X vectors doesn't allow utilize the newly created VF because it is not known to the device the future load and configuration where that VF will be used. The VFs are created on the hypervisor and forwarded to the VMs that have different properties (for example number of CPUs). To overcome the inefficiency in the spread of such MSI-X vectors, we allow the kernel to instruct the device with the needed number of such vectors, before VF is initialized and bounded to the driver. Before this series: [root@server ~]# lspci -vs 0000:08:00.2 08:00.2 Ethernet controller: Mellanox Technologies MT27800 Family [ConnectX-5 Virtual Function] .... Capabilities: [9c] MSI-X: Enable- Count=12 Masked- Configuration script: 1. Start fresh echo 0 > /sys/bus/pci/devices/0000\:08\:00.0/sriov_numvfs modprobe -q -r mlx5_ib mlx5_core 2. Ensure that driver doesn't run and it is safe to change MSI-X echo 0 > /sys/bus/pci/devices/0000\:08\:00.0/sriov_drivers_autoprobe 3. Load driver for the PF modprobe mlx5_core 4. Configure one of the VFs with new number echo 2 > /sys/bus/pci/devices/0000\:08\:00.0/sriov_numvfs echo 21 > /sys/bus/pci/devices/0000\:08\:00.2/vfs_overlay/sriov_vf_msix_count After this series: [root@server ~]# lspci -vs 0000:08:00.2 08:00.2 Ethernet controller: Mellanox Technologies MT27800 Family [ConnectX-5 Virtual Function] .... Capabilities: [9c] MSI-X: Enable- Count=21 Masked- Thanks Leon Romanovsky (4): PCI: Add sysfs callback to allow MSI-X table size change of SR-IOV VFs net/mlx5: Add dynamic MSI-X capabilities bits net/mlx5: Dynamically assign MSI-X vectors count net/mlx5: Allow to the users to configure number of MSI-X vectors Documentation/ABI/testing/sysfs-bus-pci | 32 ++++ .../net/ethernet/mellanox/mlx5/core/main.c | 16 ++ .../ethernet/mellanox/mlx5/core/mlx5_core.h | 6 + .../net/ethernet/mellanox/mlx5/core/pci_irq.c | 72 +++++++ .../net/ethernet/mellanox/mlx5/core/sriov.c | 59 +++++- drivers/pci/iov.c | 180 ++++++++++++++++++ drivers/pci/msi.c | 47 +++++ drivers/pci/pci.h | 4 + include/linux/mlx5/mlx5_ifc.h | 11 +- include/linux/pci.h | 10 + 10 files changed, 434 insertions(+), 3 deletions(-) --- 2.29.2