From patchwork Sun Feb 19 19:58:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 729650 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3vRHdB0M49z9s7s for ; Mon, 20 Feb 2017 06:58:38 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="pYuemlyr"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751842AbdBST6c (ORCPT ); Sun, 19 Feb 2017 14:58:32 -0500 Received: from mail-pg0-f48.google.com ([74.125.83.48]:32812 "EHLO mail-pg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751723AbdBST60 (ORCPT ); Sun, 19 Feb 2017 14:58:26 -0500 Received: by mail-pg0-f48.google.com with SMTP id a123so8125474pgc.0 for ; Sun, 19 Feb 2017 11:58:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=03Lbgby+bfeelD9jVCLfq7EEa1T3vLCyMf89Y5s6ic8=; b=pYuemlyrx9UA7w/fL9y3kLr1FiEBQg0CDwiLoevjTIRwWfnDtndUtpzP2zdG8OboY1 Qty9nEalWRiY6Ol5q5A+gY4OUZ3rLUaYVvA4IlXjP2FtSoWHaijfjVtpKiC+UTxIbt/6 ULS72dugcvDPhmDRIK6mKMA28FOI4VF6ZtiUXWNe5qPLJKI85zHYtaBIDbiFmGERBuqz sFFi7+8IyHcuGnDHDIDG2cYDxuJeKTsDFyg88JGDVvMZKHsiyi0anT7BsjL6mLVl63cd o7dURHIdUbrtqOPW7h0UbCNcFsr5m4GRPdr4lpvbXV8y+h8I8VaewRfJ0o98th8dY3Xg s5ow== 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; bh=03Lbgby+bfeelD9jVCLfq7EEa1T3vLCyMf89Y5s6ic8=; b=NJDJyNfXD/ZF2zLtviWjGW1rXDs69q/fgsEgh3B+bpzTwcbkbbqzZ7M7J/UcIvd1R/ jH03IbZj/z2UQYTv8ewoo2Thoqu00P9yA/TdkPSm3Kv3F8P3fClce05fCtHLK19rZlQm fCevQNw699vVP7ORP6U3YCclcthdD+aapXMKA/plGYQSBSnrqnBCM092NesZqqZmCRS5 aOykuO9/byLbQptXVZlYsJ7XdaijKFgOs08MFQn840yaqLlfyvBu//eutfFcjVnB6aFC mdzCc6vTTIZwYAnxhzvt8/48Py0mAEVpN7yX+izJADGuKFJHY4xZorsUyZMvIwB55Rw+ CUQQ== X-Gm-Message-State: AMke39mWCco+XN+uLiEqPRpZ7jM9XbKZK5InKav12pptPxMH5lClSf7r7uZS+7o6Mt0U2IE5 X-Received: by 10.99.142.193 with SMTP id k184mr9084086pge.209.1487534305369; Sun, 19 Feb 2017 11:58:25 -0800 (PST) Received: from jkicinski-Precision-T1700.netronome.com ([75.53.12.129]) by smtp.gmail.com with ESMTPSA id w18sm30653741pfa.127.2017.02.19.11.58.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 19 Feb 2017 11:58:24 -0800 (PST) From: Jakub Kicinski To: netdev@vger.kernel.org Cc: oss-drivers@netronome.com, dinan.gunawardena@netronome.com, kubakici@wp.pl, Jakub Kicinski , Yuval Mintz Subject: [PATCH net-next v2 7/7] nfp: allow application firmware to limit number of SR-IOV VFs Date: Sun, 19 Feb 2017 11:58:14 -0800 Message-Id: <20170219195814.40471-8-jakub.kicinski@netronome.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170219195814.40471-1-jakub.kicinski@netronome.com> References: <20170219195814.40471-1-jakub.kicinski@netronome.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Some application firmware projects may choose to limit the number of VFs available below what is specified in PCI capability to be able to reuse the PCIe interface resources. There may also be projects which use cases don't require SR-IOV support at all and therefore don't want to spend time implementing/testing it. Check nfd_vf_cfg_max_vfs firmware symbol to see if application firmware is reporting how many VFs it supports. This mechanism is an opt-in, if symbol is not present we will only look at the PCI capability values. Signed-off-by: Jakub Kicinski --- CC: Yuval Mintz drivers/net/ethernet/netronome/nfp/nfp_main.c | 25 +++++++++++++++++++++++++ drivers/net/ethernet/netronome/nfp/nfp_main.h | 2 ++ 2 files changed, 27 insertions(+) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_main.c b/drivers/net/ethernet/netronome/nfp/nfp_main.c index 8cda6b0e7e32..dedac720fb29 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_main.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_main.c @@ -47,6 +47,7 @@ #include "nfpcore/nfp.h" #include "nfpcore/nfp_cpp.h" +#include "nfpcore/nfp_nffw.h" #include "nfpcore/nfp_nsp_eth.h" #include "nfpcore/nfp6000_pcie.h" @@ -70,12 +71,34 @@ static const struct pci_device_id nfp_pci_device_ids[] = { }; MODULE_DEVICE_TABLE(pci, nfp_pci_device_ids); +static void nfp_pcie_sriov_read_nfd_limit(struct nfp_pf *pf) +{ +#ifdef CONFIG_PCI_IOV + int err; + + pf->limit_vfs = nfp_rtsym_read_le(pf->cpp, "nfd_vf_cfg_max_vfs", &err); + if (!err) + return; + + pf->limit_vfs = ~0; + /* Allow any setting for backwards compatibility if symbol not found */ + if (err != -ENOENT) + nfp_warn(pf->cpp, "Warning: VF limit read failed: %d\n", err); +#endif +} + static int nfp_pcie_sriov_enable(struct pci_dev *pdev, int num_vfs) { #ifdef CONFIG_PCI_IOV struct nfp_pf *pf = pci_get_drvdata(pdev); int err; + if (num_vfs > pf->limit_vfs) { + nfp_info(pf->cpp, "Firmware limits number of VFs to %u\n", + pf->limit_vfs); + return -EINVAL; + } + err = pci_enable_sriov(pdev, num_vfs); if (err) { dev_warn(&pdev->dev, "Failed to enable PCI sriov: %d\n", err); @@ -333,6 +356,8 @@ static int nfp_pci_probe(struct pci_dev *pdev, if (err) goto err_cpp_free; + nfp_pcie_sriov_read_nfd_limit(pf); + err = nfp_net_pci_probe(pf); if (err) goto err_fw_unload; diff --git a/drivers/net/ethernet/netronome/nfp/nfp_main.h b/drivers/net/ethernet/netronome/nfp/nfp_main.h index 6c40fa322da3..39105d0435e9 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_main.h +++ b/drivers/net/ethernet/netronome/nfp/nfp_main.h @@ -59,6 +59,7 @@ struct nfp_eth_table; * @tx_area: Pointer to the CPP area for the TX queues * @rx_area: Pointer to the CPP area for the FL/RX queues * @irq_entries: Array of MSI-X entries for all ports + * @limit_vfs: Number of VFs supported by firmware (~0 for PCI limit) * @num_vfs: Number of SR-IOV VFs enabled * @fw_loaded: Is the firmware loaded? * @eth_tbl: NSP ETH table @@ -77,6 +78,7 @@ struct nfp_pf { struct msix_entry *irq_entries; + unsigned int limit_vfs; unsigned int num_vfs; bool fw_loaded;