From patchwork Wed Oct 19 14:09:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 13011849 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF17DC4332F for ; Wed, 19 Oct 2022 14:27:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233074AbiJSO1v (ORCPT ); Wed, 19 Oct 2022 10:27:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230519AbiJSO13 (ORCPT ); Wed, 19 Oct 2022 10:27:29 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20706.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e88::706]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BB6B192DB0 for ; Wed, 19 Oct 2022 07:12:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R0yEXQDZoab2kL7QX9AXizRHp73T1MKP+zAdt/JCCJ1csIvTytT6Wnj79rMK0Jgi0tiDQ9mtM9mpYHg8DWaM0tkYzu0DHlbHoq1GG0/B0do+nklUqoL9UkeUbwdTe3wHxHCida+1mE0qDzLmFbFr6C7zU9OsQDDjpfCJtinKfnJ3JgdBsekES7z1xkoTRseMBEu/4F+me/cLg0BTmB2h/hl8jjoSR3AJzTQVG08Za47lxaG2IaJLVOm7+wbU6aeLJO4Z8Q30J6jEjmKamZrDppISZOFcTZ9xYoEofm5lQpPCv8rV3Hmk0NduYoiaYP2utgq3le87TYWY2pmdE7svLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nxSDEVf06/ovcEqcGaJ3dBu6yC//3IwCFMt2ir6y1xw=; b=K4f+/IYLHV43evQgbX6iFoQi/zv4W7kQXEh3BClhrvZ1j4PfqhfPoMQPTvNrSXxn3LecQtUl6Y7RWv+DhWmbB5yErHUZ+ser9uwa/T9YPMyFuDlaEdZ6zB3cXPI2Rat+OoxIVq3s3CZYeeYKjWImreI+SBG1S80ha6uHfGJaWdwZ58suHLkzo1fKZ1vXFefAF3hHFU7MDBq/ihArkZmAjWzUsWW1ozfhOschEPj3N+pImbYLQDQ3SAKePAU1pLb7tubU7FgkbYyPgzHze2swJKHDvlY5X4igW9cFaaJPKClbjeih6F8UC83jcJgFWKcMrYA0H/7xLseFc2VvVEeHFQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nxSDEVf06/ovcEqcGaJ3dBu6yC//3IwCFMt2ir6y1xw=; b=nlpg40V21MhO+pMixjaaWlvq0J4ifyhTMbhjQ9euAR1Zc3EkmfpT91Nhr27kMY9CvH/WxMc9OH0Vk3dNITwBW9/mt4g4s4MfDc1bOvQTo8rWjdRHe+V4RdsgrdxaEw6JY0jSzsL6svo47dFBoWW+IgGshep9Y5EoCXyxhiTTxcQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by BL0PR13MB4404.namprd13.prod.outlook.com (2603:10b6:208:1c9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.20; Wed, 19 Oct 2022 14:10:21 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::3a35:112e:34eb:6161]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::3a35:112e:34eb:6161%6]) with mapi id 15.20.5746.016; Wed, 19 Oct 2022 14:10:21 +0000 From: Simon Horman To: David Miller , Jakub Kicinski , Paolo Abeni Cc: Michael Chan , Andy Gospodarek , Gal Pressman , Saeed Mahameed , Jesse Brandeburg , Tony Nguyen , Edward Cree , Vladimir Oltean , Andrew Lunn , Peng Zhang , netdev@vger.kernel.org, oss-drivers@corigine.com Subject: [PATCH net-next 1/3] nfp: support VF multi-queues configuration Date: Wed, 19 Oct 2022 16:09:41 +0200 Message-Id: <20221019140943.18851-2-simon.horman@corigine.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221019140943.18851-1-simon.horman@corigine.com> References: <20221019140943.18851-1-simon.horman@corigine.com> X-ClientProxiedBy: AS4P250CA0008.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:5df::9) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR13MB4842:EE_|BL0PR13MB4404:EE_ X-MS-Office365-Filtering-Correlation-Id: 9dc92b1a-4747-4f5e-1c16-08dab1dba889 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ocfp2+ozfPI1rHRxAPdv4wzNdh3FcSo0pJ0qxee+ASB8iqjPPHaT1g5O1pPHCMyvSsN3VZucWekzy3KY0qsF65Kd98JicEqbWOjXwJpIK1jMPvaHAJ5FPi9uUxFWQj0FEOicKHKz4UBzBu1vb4nGEF0tWPu9SDxsbWlnu/598QwyVZWTimExwcHhee53UY8HZMQkvmMipC+4NqK6Ja+gv0LcHyaPRmIRRe0HN7/R07zH6QwZ+FbF8b+5O3+Gk0UVmiPV4vjNwJaivR/RyQh71NKe2HzXkDKp3kW2MItFR6HfhsP1KIT3V3qCvx/ytOvs1B75KweHrL+HGMBVE1Uw7ipnxmiKz/PVMZ8DqpNFC67EJzbFQYx8YycWbXltv6Ll2eTCYJdgBmPVpJJdbDgSeh8D828sai8/pfhFsF4cJSNKNbioMGI2Tth/u713b8KVFAILpnplwR0KgYMjiAoiEcrnF0RQZQVwUjWdGuLqgT4g2bjD5TTSpo67UEpdPN+xWzqc435w2x3s2xHS2UF2DU/3m8+ssR9Ttq3nDMQxA6KSji+S8ppSAYXe1+aziyIlZVNnAsUNL1n+cts8Wj63W4aF08cAgeUTM24OWaG2ou8e3MJ66bnF9rbn0RmK/megojo2ZdsxRYDdMHEVEENH250qL+m5wAzWSiCIqArniZP+bIUwk4TqALWF4DI0R2ccwVkQLEl5LBDYk8i5SMVqolTEQ7F6PUL31KMZDCEpw0IO1dXeBxdFZKpRRutBaNp3 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR13MB4842.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(136003)(39830400003)(366004)(346002)(376002)(396003)(451199015)(1076003)(4326008)(66556008)(41300700001)(66476007)(7416002)(5660300002)(6506007)(2906002)(8936002)(52116002)(2616005)(6512007)(6666004)(107886003)(186003)(44832011)(86362001)(36756003)(8676002)(66946007)(6486002)(478600001)(110136005)(38100700002)(83380400001)(54906003)(316002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3VBLh1t++EA41+EWDSqDmeKSnfOOyjk2IXvXQ4swJWA24GdsYhDxuRgvoElsxhyx5qTR+T4NCyejejoWgHF5g3RQOHdDc5L2/co+ukOjJMvIX8FLpKCLdmG6pQcLh7rmEjatn6lahyDRXEOLSQ/DaEJZzZuSenIspOnM8H31bWToKtu+aKi5x3XUiLPClsnrjHpItEnCbYBwdZnh6R5+HYPwINxyAXbIbq0u/JRJMB+9DHglD5oyAlYd6Rr5pbBTzbW3Rfa8lQ3UV+GWCKrP/f2EcuvavarGtTecCFjR5Dwmy56Twl7JrG+yxNQ/Hrs23u6GtClx0yfHu93jC9GFK514D1yzNRSBbawLUSaXr4/mu4vWZ5yHuOs0trz0yMvRVsRwpsgoG+3ft5AVcy9pdXCalqObIo+rkgBwkOztGCkLIZgsw3M64JgBKqePlPkui+kKFD67MK5n7+T5ZHcoTr4RTcT4/2sdnno34EPnS0O8dRlPZmLhAxr5eHpzHVBb6ysDKVEwGEv4MZQQh5paia3heb3GTUImF63G75IMRxYek5p2U9CROf0vw/y6nz/EQ5RBj/yFljcOacXMi9XwfmC9Rq8kkgqH5zvNvNaaGe+DgqZZLD8WSoNO/9posd17idR4S0DkBZSW4YZZuwvWul5JYgSI2z+I2WYtLzos4vRDlx2AhE3/m/rTe/LC6Wxi11ZR5C5p18GAu5dbzzXggXTcKqWsSXVkV3VifLvSdWH8XYkbULSMovylqnMNbAraqw69zswSkpjH50zxold8bmhu3LRGehUVL2DsN17fZIfQ6SJAUU6WTtSh9nfMa2VgDfkHhZTZjWsQkZtLUCUs9dHo3aNaknrfvl9KtRZi36tgSt8b9WxjQhKHTz85chiJ0VDKGV7adiTLv6RMtNcviDML2qkMWccPM1qFPhl/TI9ZiU7nIMJzrymmrmHziL/Gco7mdiomV8uqx/H0nRQw3F/vW13yWKV30vVOVYKkTETwofYJiamnLdKaHhbnGnKTKKQAF8+/1m/sAk8gwNIVqK7pVkcoTDO4OkVzLKgYiwljv1ZrYTO6f1nPqpwWXXdKb30D10YscCID3MBT7fbXY0yC9tiEfg8QlTzKdYs871ZwFN5M8IlhVQHmeBG0rpiKdhjUubtqWBAZnQ1F+P2LSAejuaWC/F3bEU8oyPOY0JBVPaupyCrZOu4D58YZtrnNBtKTQc02SOT7HvFkkU1rNdYFtz0pM6pHdDYFlCkYVQPDVFw1VKfHt0TK4QHD2eMi1P8PeeaAXC+yKpyGGr/9agQeHdH1Vgl+gu/2BZffJlYbwqdHWc2L6ooQ66e08HCon0QJMGppr/sgGLvvRQSaGxhYvwe9SKL2SVSPZoujRS8nm89VFrZ7LXYqFBa/VeRLxtjfTSH3E6RwEK6C6tOkrwzzjXjqIiz44V421DYvz8+GYSZhatQZNQ6EUqaUIjyDZUrRrL/lrcomkeuaMAr4f43qEJmaOt9odbyjw55/9H5C3UQKEYpmBMZtFzh/1GPI9gSisN1tv0/xACEERFf0oNI8ca2o1GV0L+7artPBFmX929QOTsal+MC6fYsxJ5ZotW/FBdoQuiHptMdODr+zHEJJ8aZSeNLWyYxgkgstBqohBTt0kHrNzJap2gkkIUzJ8rI7roPuvYze2PoKkOHf9Q== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9dc92b1a-4747-4f5e-1c16-08dab1dba889 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2022 14:10:21.1265 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7Sy2X+Qt6nmAfjEp8TkVFk8hY4VJ2+ZG5ibNaRy0Q0qwjYf2f0ctUu2PpZjaezt5Pqkrigw/+mLT4YbsXw99HqDr3GhBmknWuOMXlX8xaRg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR13MB4404 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Diana Wang Add VF setting multi-queue feature. It is to configure the max queue number for each VF, user can still modify the queue number in use by ethtool -l The number set of configuring queues for every vf is {16 8 4 2 1} and total number of configuring queues is not allowed bigger than vf queues resource. If quantity of created VF exceeds expectation, it will check VF number validity based on the queues not used. The condition is that quantity of the rest queues must not smaller than redundant VFs' number. If it meets the condition, it will set one queue per extra VF. If not configured(default mode), the created VFs will divide the total vf-queues equally and it rounds down power of 2. Signed-off-by: Diana Wang Signed-off-by: Simon Horman --- drivers/net/ethernet/netronome/nfp/nfp_main.c | 6 ++ drivers/net/ethernet/netronome/nfp/nfp_main.h | 13 +++ drivers/net/ethernet/netronome/nfp/nfp_net.h | 1 + .../net/ethernet/netronome/nfp/nfp_net_main.c | 3 + .../ethernet/netronome/nfp/nfp_net_sriov.c | 101 ++++++++++++++++++ .../ethernet/netronome/nfp/nfp_net_sriov.h | 3 + 6 files changed, 127 insertions(+) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_main.c b/drivers/net/ethernet/netronome/nfp/nfp_main.c index e66e548919d4..f0e197067e08 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_main.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_main.c @@ -29,6 +29,7 @@ #include "nfp_app.h" #include "nfp_main.h" #include "nfp_net.h" +#include "nfp_net_sriov.h" static const char nfp_driver_name[] = "nfp"; @@ -252,6 +253,10 @@ static int nfp_pcie_sriov_enable(struct pci_dev *pdev, int num_vfs) return -EINVAL; } + err = nfp_vf_queues_config(pf, num_vfs); + if (err) + return err; + err = pci_enable_sriov(pdev, num_vfs); if (err) { dev_warn(&pdev->dev, "Failed to enable PCI SR-IOV: %d\n", err); @@ -847,6 +852,7 @@ static int nfp_pci_probe(struct pci_dev *pdev, if (err) goto err_fw_unload; + pf->default_config_vfs_queue = true; pf->num_vfs = pci_num_vf(pdev); if (pf->num_vfs > pf->limit_vfs) { dev_err(&pdev->dev, diff --git a/drivers/net/ethernet/netronome/nfp/nfp_main.h b/drivers/net/ethernet/netronome/nfp/nfp_main.h index afd3edfa2428..c24f990bcdbb 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_main.h +++ b/drivers/net/ethernet/netronome/nfp/nfp_main.h @@ -17,6 +17,12 @@ #include #include + /* Define how many types of max-q-number is supported to + * configure, currently we support 16, 8, 4, 2, 1. + */ +#define NFP_NET_CFG_QUEUE_TYPE 5 +#define NFP_NET_CFG_MAX_Q(type) (1 << (NFP_NET_CFG_QUEUE_TYPE - (type) - 1)) + struct dentry; struct device; struct pci_dev; @@ -63,6 +69,10 @@ struct nfp_dumpspec { * @irq_entries: Array of MSI-X entries for all vNICs * @limit_vfs: Number of VFs supported by firmware (~0 for PCI limit) * @num_vfs: Number of SR-IOV VFs enabled + * @max_vf_queues: number of queues can be allocated to VFs + * @config_vfs_queue: Array to indicate VF number of each max-queue-num type + * The quantity of distributable queues is {16, 8, 4, 2, 1} + * @default_config_vfs_queue: Is the method of allocating queues to VFS evenly distributed * @fw_loaded: Is the firmware loaded? * @unload_fw_on_remove:Do we need to unload firmware on driver removal? * @ctrl_vnic: Pointer to the control vNIC if available @@ -111,6 +121,9 @@ struct nfp_pf { unsigned int limit_vfs; unsigned int num_vfs; + unsigned int max_vf_queues; + u8 config_vfs_queue[NFP_NET_CFG_QUEUE_TYPE]; + bool default_config_vfs_queue; bool fw_loaded; bool unload_fw_on_remove; diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net.h b/drivers/net/ethernet/netronome/nfp/nfp_net.h index a101ff30a1ae..5deeae87b684 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net.h +++ b/drivers/net/ethernet/netronome/nfp/nfp_net.h @@ -78,6 +78,7 @@ /* Queue/Ring definitions */ #define NFP_NET_MAX_TX_RINGS 64 /* Max. # of Tx rings per device */ #define NFP_NET_MAX_RX_RINGS 64 /* Max. # of Rx rings per device */ +#define NFP_NET_CTRL_RINGS 1 /* Max. # of Ctrl rings per device */ #define NFP_NET_MAX_R_VECS (NFP_NET_MAX_TX_RINGS > NFP_NET_MAX_RX_RINGS ? \ NFP_NET_MAX_TX_RINGS : NFP_NET_MAX_RX_RINGS) #define NFP_NET_MAX_IRQS (NFP_NET_NON_Q_VECTORS + NFP_NET_MAX_R_VECS) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_main.c b/drivers/net/ethernet/netronome/nfp/nfp_net_main.c index 3bae92dc899e..3c2e49813655 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_main.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_main.c @@ -289,6 +289,7 @@ static int nfp_net_pf_init_vnics(struct nfp_pf *pf) if (err) goto err_prev_deinit; + pf->max_vf_queues -= nn->max_r_vecs; id++; } @@ -754,6 +755,8 @@ int nfp_net_pci_probe(struct nfp_pf *pf) } } + pf->max_vf_queues = NFP_NET_MAX_R_VECS - NFP_NET_CTRL_RINGS; + err = nfp_net_pf_app_init(pf, qc_bar, stride); if (err) goto err_unmap; diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_sriov.c b/drivers/net/ethernet/netronome/nfp/nfp_net_sriov.c index 6eeeb0fda91f..eca6e65089f4 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_sriov.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_sriov.c @@ -29,6 +29,9 @@ nfp_net_sriov_check(struct nfp_app *app, int vf, u16 cap, const char *msg, bool return -EOPNOTSUPP; } + if (cap == NFP_NET_VF_CFG_MB_CAP_QUEUE_CONFIG) + return 0; + if (vf < 0 || vf >= app->pf->num_vfs) { if (warn) nfp_warn(app->pf->cpp, "invalid VF id %d\n", vf); @@ -309,3 +312,101 @@ int nfp_app_get_vf_config(struct net_device *netdev, int vf, return 0; } + +static int nfp_set_vf_queue_config(struct nfp_pf *pf, int num_vfs) +{ + unsigned char config_content[sizeof(u32)] = {0}; + unsigned int i, j, k, cfg_vf_count, offset; + struct nfp_net *nn; + u32 raw; + int err; + + raw = 0; k = 0; cfg_vf_count = 0; + offset = NFP_NET_VF_CFG_MB_SZ + pf->limit_vfs * NFP_NET_VF_CFG_SZ; + + for (i = 0; i < NFP_NET_CFG_QUEUE_TYPE; i++) { + for (j = 0; j < pf->config_vfs_queue[i]; j++) { + config_content[k++] = NFP_NET_CFG_MAX_Q(i); + cfg_vf_count++; + if (k == sizeof(raw) || cfg_vf_count == num_vfs) { + raw = config_content[0] | + (config_content[1] << BITS_PER_BYTE) | + (config_content[2] << (2 * BITS_PER_BYTE)) | + (config_content[3] << (3 * BITS_PER_BYTE)); + writel(raw, pf->vfcfg_tbl2 + offset); + offset += sizeof(raw); + memset(config_content, 0, sizeof(u32)); + k = 0; + } + } + } + + writew(NFP_NET_VF_CFG_MB_UPD_QUEUE_CONFIG, pf->vfcfg_tbl2 + NFP_NET_VF_CFG_MB_UPD); + + nn = list_first_entry(&pf->vnics, struct nfp_net, vnic_list); + err = nfp_net_reconfig(nn, NFP_NET_CFG_UPDATE_VF); + if (err) { + nfp_warn(pf->cpp, + "FW reconfig VF config queue failed: %d\n", err); + return -EINVAL; + } + + err = readw(pf->vfcfg_tbl2 + NFP_NET_VF_CFG_MB_RET); + if (err) { + nfp_warn(pf->cpp, + "FW refused VF config queue update with errno: %d\n", err); + return -EINVAL; + } + + return 0; +} + +int nfp_vf_queues_config(struct nfp_pf *pf, int num_vfs) +{ + unsigned int i, j, cfg_num_queues = 0, cfg_num_vfs; + + if (nfp_net_sriov_check(pf->app, 0, NFP_NET_VF_CFG_MB_CAP_QUEUE_CONFIG, "max_queue", true)) + return 0; + + /* In default mode, the created VFs divide all the VF queues equally, + * and round down to power of 2 + */ + if (pf->default_config_vfs_queue) { + memset(pf->config_vfs_queue, 0, NFP_NET_CFG_QUEUE_TYPE); + j = pf->max_vf_queues / num_vfs; + for (i = 0; i < NFP_NET_CFG_QUEUE_TYPE; i++) { + if (j >= NFP_NET_CFG_MAX_Q(i)) { + pf->config_vfs_queue[i] = num_vfs; + break; + } + } + return nfp_set_vf_queue_config(pf, num_vfs); + } + + for (i = 0, cfg_num_vfs = 0; i < NFP_NET_CFG_QUEUE_TYPE; i++) { + cfg_num_queues += NFP_NET_CFG_MAX_Q(i) * pf->config_vfs_queue[i]; + cfg_num_vfs += pf->config_vfs_queue[i]; + } + + if (cfg_num_queues > pf->max_vf_queues) { + dev_warn(&pf->pdev->dev, + "Number of queues from configuration is bigger than total queues number.\n"); + return -EINVAL; + } + + cfg_num_queues = pf->max_vf_queues - cfg_num_queues; + + if (num_vfs > cfg_num_vfs) { + cfg_num_vfs = num_vfs - cfg_num_vfs; + if (cfg_num_queues < cfg_num_vfs) { + dev_warn(&pf->pdev->dev, + "Remaining queues are not enough to be allocated.\n"); + return -EINVAL; + } + dev_info(&pf->pdev->dev, + "The extra created VFs are allocated with single queue.\n"); + pf->config_vfs_queue[NFP_NET_CFG_QUEUE_TYPE - 1] += cfg_num_vfs; + } + + return nfp_set_vf_queue_config(pf, num_vfs); +} diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_sriov.h b/drivers/net/ethernet/netronome/nfp/nfp_net_sriov.h index 2d445fa199dc..36df29fdaf0e 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_sriov.h +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_sriov.h @@ -21,6 +21,7 @@ #define NFP_NET_VF_CFG_MB_CAP_TRUST (0x1 << 4) #define NFP_NET_VF_CFG_MB_CAP_VLAN_PROTO (0x1 << 5) #define NFP_NET_VF_CFG_MB_CAP_RATE (0x1 << 6) +#define NFP_NET_VF_CFG_MB_CAP_QUEUE_CONFIG (0x1 << 7) #define NFP_NET_VF_CFG_MB_RET 0x2 #define NFP_NET_VF_CFG_MB_UPD 0x4 #define NFP_NET_VF_CFG_MB_UPD_MAC (0x1 << 0) @@ -30,6 +31,7 @@ #define NFP_NET_VF_CFG_MB_UPD_TRUST (0x1 << 4) #define NFP_NET_VF_CFG_MB_UPD_VLAN_PROTO (0x1 << 5) #define NFP_NET_VF_CFG_MB_UPD_RATE (0x1 << 6) +#define NFP_NET_VF_CFG_MB_UPD_QUEUE_CONFIG (0x1 << 7) #define NFP_NET_VF_CFG_MB_VF_NUM 0x7 /* VF config entry @@ -67,5 +69,6 @@ int nfp_app_set_vf_link_state(struct net_device *netdev, int vf, int link_state); int nfp_app_get_vf_config(struct net_device *netdev, int vf, struct ifla_vf_info *ivi); +int nfp_vf_queues_config(struct nfp_pf *pf, int num_vfs); #endif /* _NFP_NET_SRIOV_H_ */ From patchwork Wed Oct 19 14:09:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 13011850 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29C8FC433FE for ; Wed, 19 Oct 2022 14:28:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231819AbiJSO2Z (ORCPT ); Wed, 19 Oct 2022 10:28:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229674AbiJSO1o (ORCPT ); Wed, 19 Oct 2022 10:27:44 -0400 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2123.outbound.protection.outlook.com [40.107.102.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B27801AC1E2 for ; Wed, 19 Oct 2022 07:12:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eHftQzNmb5yyOsGha6UDE9nk1ZEeiR+FFrny629/VfQrs2ZnuiTFhnLt0qEVNX8va3rJqw3wEStizKOBzSzS6RuTKvfLgCuhJa0bwZwhQVo/u/Gfz8DZt8BqU1MTC6w1oaIvznSQHof1A7SBUT6FsIFWZ9SUSKm9KZ5qOxhGnSuXfTfn+9m1duwEfgCgd0wkgk0mBZEvcT+sq2p/OJVfAFez49OYLvMLTA1khzKvUov35hzyNQmTiypsda0SU40+CybHnCI7j+mXbV98u+rdYTuSAhuMcGwNE20JfiJJ0tZpDsJVvPOP1B2NaS7sIyFyXIJcbyCpk3suvm91oXdoqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XtdTkOcn07wNifQrtn2HyLqFwuO76ir+nc0aZr6IXFw=; b=ZSI0yqUbHwXtY7TWeCJwt6IL/Y28GEjruB6G6Cv5SSUO+FEhJBpsFz62yM2CaqUzqB4028mb51yAtQSWZpgaZopYS3j7pUU6To/SA9zf/OsY6EZq4M1kcy4hhluFIZEhHGpt/TayAHwC61xiQjlzaIxtEylKK8Qsr/Ss+CIMg3/BxBmmm8tock0caFLuDhqF2ZQ+FNj06iCwnZazWIbsgMzsOKpOnJYXbjLlK04LJ26FzFh7dm0UaBJg1yGdbKdowFOAXJPcSsuwZ6lr8vNN+9ybyVm4tbDGqCCD9okOvg9y1HMACvLBBbjYw++R05ECLCYrdDOkf92JcJBFqA8fNg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XtdTkOcn07wNifQrtn2HyLqFwuO76ir+nc0aZr6IXFw=; b=i0THCvXFlojgGovm89flpcUN3mHeF+WZptd2/rZiewJeoSH7zOGhg5p0XGBUmw918JZ30ksHjnnPmicqqAKmH3Tn7niKdH0f58ru9FC8AuUxj5d+xfyY3hzEnPvSTw9H7uGn3fXaJo1hlUTHestLIV3+9N+MzdX9etirwS7mx14= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by BL0PR13MB4404.namprd13.prod.outlook.com (2603:10b6:208:1c9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.20; Wed, 19 Oct 2022 14:10:23 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::3a35:112e:34eb:6161]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::3a35:112e:34eb:6161%6]) with mapi id 15.20.5746.016; Wed, 19 Oct 2022 14:10:23 +0000 From: Simon Horman To: David Miller , Jakub Kicinski , Paolo Abeni Cc: Michael Chan , Andy Gospodarek , Gal Pressman , Saeed Mahameed , Jesse Brandeburg , Tony Nguyen , Edward Cree , Vladimir Oltean , Andrew Lunn , Peng Zhang , netdev@vger.kernel.org, oss-drivers@corigine.com Subject: [PATCH net-next 2/3] devlink: Add new "max_vf_queue" generic device param Date: Wed, 19 Oct 2022 16:09:42 +0200 Message-Id: <20221019140943.18851-3-simon.horman@corigine.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221019140943.18851-1-simon.horman@corigine.com> References: <20221019140943.18851-1-simon.horman@corigine.com> X-ClientProxiedBy: AS4P250CA0008.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:5df::9) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR13MB4842:EE_|BL0PR13MB4404:EE_ X-MS-Office365-Filtering-Correlation-Id: 559d8ce1-eded-4ba1-ace3-08dab1dbaa1c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u+n+Qo06WafnK8mgT4LmtJPAAWhDxCdDVARETE+cDvtVH/TVbOE4oTEVkeTpkO4gTPHL2jdBXWq1KowhcRSDpbRwIt593J/gPTPpZJ1REBsk8bHej9s0TD4L/v9OFMI1m39jKGsVA6q7hGo9FxqT6vjt7jmHoYA+eaPdaQ0ZVfPrOIeki7K6xoSNhC6kLBNYLgsZ/38evI5LkVRwugRxs2XOLi7uEEVIFzTdQxoNq2LRH+3aEvsYnBbeFk/PCllZdDJmPTy70Njd+Ff4VLATa/grxeeFpoNX8+BwKcuWrg7JubwPkMxYxbJvzvJHGFKpymr+6zluK8tzmmLNiLvefFls4fZlhvMf6lvCjHO6dMmOvCSz5DiGXF0ClqxeTJPrWuea8GU+O/1BuPCXZQB3f12k5IULAIQ2/uxeXwBScpS7qX3C2hUcYMw86aAgExt71jbLTZCwBwqfObnFoFwVxgzr5FXIuqcQTFtXRD4ptVNNdRyxGUDFkP1g2K0i0xOu/KJtHcYwW+mz21ZQSJEEC6o9gLUpRZZ+HFds7l9o3SLFT6gnakWF2J0KrzzxqOwnQjd7xLD/DA9sCgsLhEIj/EHntZX9X7wrBOww6BwBtUxPK/YxnRaQOlgfV+8/AzUdVpG2sJoH5mt9YJjVcGZODEpv9yLqFcSfgXNwAQ6pQY9skDbaISWdhxu9ZtLqCAfSyJp47HkHO3VrENdtSMfzWeEK6OBEUGlBZtglAgVFbJKuIuCpNyRsCKdf25SQtz/PnbGo8k0LMfIXNNOx6YZtB8wYZQFDFHSQZs0FJ0F/Vew= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR13MB4842.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(136003)(39830400003)(366004)(346002)(376002)(396003)(451199015)(1076003)(4326008)(66556008)(41300700001)(66476007)(7416002)(5660300002)(6506007)(2906002)(8936002)(52116002)(2616005)(6512007)(6666004)(107886003)(186003)(44832011)(86362001)(36756003)(8676002)(66946007)(6486002)(478600001)(110136005)(38100700002)(83380400001)(54906003)(316002)(41533002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1tLQs7349uEmFyACeWBLqwaSlzqncjnv8t3zE5kqPKBnCL4Gu7L/6jo+oOqwIkE4KX6RxK69VLSpXG7sFIfwidX/FvmtjCpe2eX9JnRIa+tKpSDapXfMvXes5JlPoAfuxOGqC9LOyjNsQ24h3+adVb72LDccSfNpjOzRNPfsiw7w8fMUYEfboBWs465bcssrhs2RR4I5sMUc2yDAknPD2yXvmqLFCN4z1aR/kScGKDxG7r9BzP9ULuWuM8ZobFX8yafAN2wgcYgiC38p1CFec0Wcm6NmoOPzs8N0aqg1wXg1AUNxyqwNAHfr3ZEMXmRJ4ieaTgXeYFPMEOJmlHu63E10uMIPczeOnEESYkWSfEZ/g3FPelmZMCR+oLAcVt5GR/EWMHmw9MxVkltg7/CFyR+cqMcldAHygLpIgQyH75OXfrljErV533LQ1u/HBYp6sFqk3iLtN6ysXNfnL8pQefvkB0oa/UbMSZtpDaPw6JmxApW4iT6GxWzRlOUsQPhxOZdMiGCthoDx3ojtm6fgmUvSyRO6cwliu0JcJ585+P9GTFZWsf45BqEpwWpXXXHq0ZbgztFI7f0XJNnFFW3GNW3HQ/pX1e0sxvuro9dlLv01WxtLP3N7dykJOLMeY9sgxrali7UV3vid6wMlhqFvqrQHaJot8MNJtixbtxN3bcoiODR6viw8KlBTnSERe2d3IL0VGLe6m1M15nMx+udhJ0TADneIP8BcVgv8a0gUloNLHiV6H20d7s7r++6n1i+z/DVMW7GODe649Kk3vLfXRgQuj6TxihcVCkvck/Crnn5SAV9qjobgpe3sjc75F+gX1iV6Ykgol0QRjAgpJhwqw3tI3fkUC7Jr1Cl6RmjKa35pex/86feKiE3IF5uEPQjF4TpP7nT1zWVxQNqgraFtkpRRcW0eraXgAePdaRxuWUXDPfNQSAIaBI50jy7HaNpH4zETVGjAOa2hLZ1N/NdQCwqqcGgbCxNw3wTfoIOqvPapidoTw/dZy1LyW5rZxgQvjXqElQndyDO44DqpCoy+SpB9JV0yCsjW5H1q0didRKeBxcQd0dRyAEqjSh+FqrFzyjmiwqUGpfD+Vqct81/MWIxgj9g+Ifk70gdtJRylYF+QTz/IXaOoOUD9eCCTdbNmHs2F1Ol463mnpojNDM49URzV3gZzzFjbACyDd530eXs0eH48M6SNFFqszcQEQScirOB2ejuBTwI6qjVi3CObRezCTNEeBpI/CJ1hE/V5acKh9i+jYrFFPb4ougSoL7l+aR7i68q3Pod06uPKyxMxsNpHXLC++aYsMojxI4euNxWQJlB4zxv5o7vKmWmPvYJasrLicwHU4hXGtT5sOz7sGlvkiGgKDYVVSce/9p5lUW9QgTetFxGBGt2rpmGZ8dwsa0oQp+XKOobDLdYJ5y8rkzoSw3m0+5ko4w9i2n6M3HiwN/NjtaST1ee/amvKMpKLxI3bxA9YTcrncIKUQiY4LY+ndvWr7MPDb895eREqDrYnRGj2Coo2KzA6+udbCTrkAklVRkjJw9byR5TUpW2FF9P/UwYza5QaWoRC+b/JaVUwiJq+KnBFHVn9k6STsfhOIVGDKLNC/+ELGMZsGPUzk5hPXtcUagkMWfVewUFzZXfMZRLnUTu7JtYlqzOMkv9VMVznSUM+GqEXZ4/DYydCjQ== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 559d8ce1-eded-4ba1-ace3-08dab1dbaa1c X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2022 14:10:23.7556 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Ul6CC7GFOB2GaatCn+I0IbVmcV7geJMosuKCOPtomoE2wZAuqLUqqHxFAxYhNS00khNCi0jkcEUrCYfalDnQ44cBtR6+x7ANSDT8zBOyLo4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR13MB4404 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Peng Zhang VF max-queue-number is the MAX num of queues which the VF has. Add new device generic parameter to configure the max-queue-number of the each VF to be generated dynamically. The string format is decided ad vendor specific. The suggested format is ...-V-W-X-Y-Z, the V represents generating V VFs that have 16 queues, the W represents generating W VFs that have 8 queues, and so on, the Z represents generating Z VFs that have 1 queue. For example, to configure * 1x VF with 128 queues * 1x VF with 64 queues * 0x VF with 32 queues * 0x VF with 16 queues * 12x VF with 8 queues * 2x VF with 4 queues * 2x VF with 2 queues * 0x VF with 1 queue, execute: $ devlink dev param set pci/0000:01:00.0 \ name max_vf_queue value \ "1-1-0-0-12-2-2-0" cmode runtime When created VF number is bigger than that is configured by this parameter, the extra VFs' max-queue-number is decided as vendor specific. If the config doesn't be set, the VFs' max-queue-number is decided as vendor specific. Signed-off-by: Peng Zhang Signed-off-by: Simon Horman --- Documentation/networking/devlink/devlink-params.rst | 5 +++++ include/net/devlink.h | 4 ++++ net/core/devlink.c | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/Documentation/networking/devlink/devlink-params.rst b/Documentation/networking/devlink/devlink-params.rst index 4e01dc32bc08..4b415b1acc9d 100644 --- a/Documentation/networking/devlink/devlink-params.rst +++ b/Documentation/networking/devlink/devlink-params.rst @@ -137,3 +137,8 @@ own name. * - ``event_eq_size`` - u32 - Control the size of asynchronous control events EQ. + * - ``max_vf_queue`` + - String + - Configure the queue of the each VF to be generated dynamically. When + created VF number is bigger than that is configured by this parameter, + the extra VFs' max-queue-number is decided as vendor specific. diff --git a/include/net/devlink.h b/include/net/devlink.h index ba6b8b094943..8cedc33c5992 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -498,6 +498,7 @@ enum devlink_param_generic_id { DEVLINK_PARAM_GENERIC_ID_ENABLE_IWARP, DEVLINK_PARAM_GENERIC_ID_IO_EQ_SIZE, DEVLINK_PARAM_GENERIC_ID_EVENT_EQ_SIZE, + DEVLINK_PARAM_GENERIC_ID_MAX_VF_QUEUE, /* add new param generic ids above here*/ __DEVLINK_PARAM_GENERIC_ID_MAX, @@ -556,6 +557,9 @@ enum devlink_param_generic_id { #define DEVLINK_PARAM_GENERIC_EVENT_EQ_SIZE_NAME "event_eq_size" #define DEVLINK_PARAM_GENERIC_EVENT_EQ_SIZE_TYPE DEVLINK_PARAM_TYPE_U32 +#define DEVLINK_PARAM_GENERIC_MAX_VF_QUEUE_NAME "max_vf_queue" +#define DEVLINK_PARAM_GENERIC_MAX_VF_QUEUE_TYPE DEVLINK_PARAM_TYPE_STRING + #define DEVLINK_PARAM_GENERIC(_id, _cmodes, _get, _set, _validate) \ { \ .id = DEVLINK_PARAM_GENERIC_ID_##_id, \ diff --git a/net/core/devlink.c b/net/core/devlink.c index 89baa7c0938b..c33f9040c570 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -5152,6 +5152,11 @@ static const struct devlink_param devlink_param_generic[] = { .name = DEVLINK_PARAM_GENERIC_EVENT_EQ_SIZE_NAME, .type = DEVLINK_PARAM_GENERIC_EVENT_EQ_SIZE_TYPE, }, + { + .id = DEVLINK_PARAM_GENERIC_ID_MAX_VF_QUEUE, + .name = DEVLINK_PARAM_GENERIC_MAX_VF_QUEUE_NAME, + .type = DEVLINK_PARAM_GENERIC_MAX_VF_QUEUE_TYPE, + }, }; static int devlink_param_generic_verify(const struct devlink_param *param) From patchwork Wed Oct 19 14:09:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 13011848 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DA6DC433FE for ; Wed, 19 Oct 2022 14:27:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233563AbiJSO11 (ORCPT ); Wed, 19 Oct 2022 10:27:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233519AbiJSO06 (ORCPT ); Wed, 19 Oct 2022 10:26:58 -0400 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on20714.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8b::714]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11E0919DD9C for ; Wed, 19 Oct 2022 07:11:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z9M8rs7R89+D82D3HZd6ArgSDquSfbVurIN0wVnanf1jkF+3E79b8s1wC/a8BQg3zaHiAQv/JkO3ELT5eMTBCbSPEuCKg2Iog4ng6YRT7di9ic8lwEzSI0VJrsTA77YUgz993EBdiYAy7dUiH9I2TOK7T+q0EVgbW1aTa63fCyabzKWAeNSE9Dc5RP06ONnf6RDJoR+wUgl2bCFUkcxDet8HCNeRs7j0xeOBAOZDr+3Ta3NA2U8/9KNtwCRnYNPaW97ylaxAIVaYcAeBS6XdXu92qQJocUjOedOVp6ZQKJ+/cucGBhnVQchiPpa+5zTiTV9I5jevN9hf78dmMP7i0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=OPgrCWy1q7HucHuJ2Z6IoxoYadQVFdFA4pZVBWPxGv4=; b=Ne67i/vVyOMTCduG1zjT0FtTyrRsSdxXjKwQVhXKF9aoYXR3rophj9izQ3fyHuw0CZkhovZvIm4qyV9mbKs3uQY45uCHPhTmzkbh3JIHwr+HpKXen1+8Umq6m7DMVddGadi5O839UH1qEczIiCwpBgxJdw9aFkGcqXMc9o189J8Hz2YHcpCoEpMK+dyTuZVPApDnlphILbXOylX0Et4LE7gZ/UOBgensOtmR1v6XA+lsYa+ty7A5cAIJcSAWC7lpaQA0nnIOcl8U7NyEHWuqMZgU6i3phi4uDZQI9iw+rGIGird7fmjo53aQ1MwT1mteebgH5PVwZYYopYFdxeD/9w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OPgrCWy1q7HucHuJ2Z6IoxoYadQVFdFA4pZVBWPxGv4=; b=qj1EmiOdaP7oxEjIHMi+KTysYEPepm11OwSfIeX63GrW3mmidCzKvPIZ0FO5uDFK4HpgCLg4XGvTMx9zuKyZzMa68WN1oDQJ1KwN4M2FkI7KHQH1Ypnrk7Jc8OEDE+GaNejA0gGmejTONkdD15WXMO2aCqmDkw2gqrjYBgZxB08= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by BL0PR13MB4404.namprd13.prod.outlook.com (2603:10b6:208:1c9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.20; Wed, 19 Oct 2022 14:10:26 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::3a35:112e:34eb:6161]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::3a35:112e:34eb:6161%6]) with mapi id 15.20.5746.016; Wed, 19 Oct 2022 14:10:26 +0000 From: Simon Horman To: David Miller , Jakub Kicinski , Paolo Abeni Cc: Michael Chan , Andy Gospodarek , Gal Pressman , Saeed Mahameed , Jesse Brandeburg , Tony Nguyen , Edward Cree , Vladimir Oltean , Andrew Lunn , Peng Zhang , netdev@vger.kernel.org, oss-drivers@corigine.com Subject: [PATCH net-next 3/3] nfp: devlink: add the devlink parameter "max_vf_queue" support Date: Wed, 19 Oct 2022 16:09:43 +0200 Message-Id: <20221019140943.18851-4-simon.horman@corigine.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221019140943.18851-1-simon.horman@corigine.com> References: <20221019140943.18851-1-simon.horman@corigine.com> X-ClientProxiedBy: AS4P250CA0008.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:5df::9) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR13MB4842:EE_|BL0PR13MB4404:EE_ X-MS-Office365-Filtering-Correlation-Id: 1bddb674-f16b-405f-21b7-08dab1dbabb2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kyELyFwIjQJ6fURWbZ3T2rI+DgrDKv5uYrqTZ7ErOxFL/gawop20F0hlhcq/5zjsdmWePhOzKQ4TCkWkYUK4AWO0+SpLf2Q0kELLIis9A6qro2ubPG0G11iQ9c+XmAFdbdMjCE2laDylxFbgjPnfIB/ULXrRP2UE1GeDbNPS7CJp1a6uCA+mp81sW980p98MCvjgshPctJ6yHi9F9R0V9oQc05u+j2ASTy5NdAju/RErQMQrR/CCJTRxN91dn9kE0fh8nrICGMORJtzVvTzQiUB20tf0IE02Nr2tiaE4rVg+r2l7kySdc1mBAMQDVit5uBajpD2A73pwdAp2qvj11IexyCPTVADm4CDQK1OuIFk+oLucahEFpjkUh8PRW45/eJh325hndkNSjA5YHOaN/WWq2RRzg1L6AogN9MjgLQjkZ55q4ndn1qhrr89qiJVWP5TYsNSssLbBDPLcfuOGHhxY2lkkE5Ckejsqa9Gc9di/nS8LHuhhrhFYVd5BWqcvtCgs3YzZCdlFZunVzivmEI/SEJ+icx79F0Iqd8oeGmRKVLLe+7iANHbyVYiKNlEZJuPtlfw59KmBGdolvSihE8Zs+AthRptpQdyqWp5OL6DgOP9yKI+CSNNHl9zs6KPLTWcVNqd0DosERN9Navzsow6AjF/xgC3QKAtLHjYw3ydJ49tBSNES4auMa7fMXWtxub5F/TfjvOWoN8NCxH/kW7caS45M8ae3WbYE6GFsEGyAi+O6wzIDRCXi/PVIZL/a X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR13MB4842.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(136003)(39830400003)(366004)(346002)(376002)(396003)(451199015)(1076003)(4326008)(66556008)(41300700001)(66476007)(7416002)(5660300002)(6506007)(2906002)(8936002)(52116002)(2616005)(6512007)(6666004)(107886003)(186003)(44832011)(86362001)(36756003)(8676002)(66946007)(6486002)(478600001)(110136005)(38100700002)(83380400001)(54906003)(316002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xm/EGz6/gcP5h4HUrrvB2swAxc/wsH5kRzIIpMa2PuKz7KZyTVAXtOrKp3y4TWEiAZj/Kv/F8SBFDJXWc7uqBxmk6gpasNQ5qHqWAgPU78zgNwJp/Dl4o3GsGgyeoJhuxEzUXi8/M25wlQejEUHAgMtAj81903QEYbxmEqGIebxW25RB+d5gXchU+ApDi9O8GFDS4NiPuFSx7T2JpnVU51YjvZgFoREBGBFYchzI2cacGbYwjILes43wueUYCc9eviL4OlTNSkZkWde4eD34YhqBMxe6iwklUmA9ulYS/U4thXRHVjelUEIXvbaRKbora7cBp/0j87taE2unX8BvrzYlPRm7NlfavWRguCI3E0qOMt29dWdjHRB10SsY4BQZ/+4q6er2jVYqgXmxz6kdS+fiQazqihXnIR6bQeYANBphb70NSa0S5P56+8ZsTvMA5yW2QZObuv5ppqNDcrhfwTJHL3bWHQLylLNhOJXc/PB4J8yl3nGrd1U8ofzU5dxCpaabMVA+/5H7X+nsn82lCZwo72y3z5P1u4vaz+g97ghn2zE4bPewg4q8/Oogt4GMSuMPxLWLkL2BJO2ctQK9Rn0qaf+mf7mIJDfuE5OIqMoaKnftH+EIM9FtXnoTrGV1K7QNgdQR45dkvTp6x6LaUu1ppXdllywug3KIvj0P2NdB2BBCHxjALr4jNt6uxRqzciyGeDwa4rrSDw3lgwwwNvq2YMb3BR2uvtC50IFeNbR+CcPhiP3GJqKirvt/iAjFJvM8vaqLxLLpkxscTVgN8Ne1Q5lO3bH6VyHGgO61AR3O6ShRLq2pl4xtOXdpC3rxRdDLgzQbNUkEYSGfKnXfnvDqytNDf0WdNvqLwnoUsm0+z4qVDbgtkMdB7u3NmYHY6k6pqY4V3V3n10IzvwDM+dxqSkZVVlfTZ0MYE9O3lZR4KtzOmjgwscRKwwlQPHVp5ziU3ovc70rxI+vuk2hrPdwizU58j6ryc33ANhR9+wWNTR8w0+FWmlivn4+T4Pb0MChUvbugW4S0SyY27ma4/VCHt3ueJ0v58BCQUsogOfUDWZaCYTXJhZJ4NeEjowKM670H/yS0oeNWIi6ilSecIhGlakTMGuVgS6XAmwPZ5CrHcoTzzSLd9MayO/OyzJ8e7T6N1F1n4yXdOQyPK6u56b0ih8cKuQ40/hGijU9eTfLwOySQg/POQpI3fXh6CpXImFlmSsgxGQGyZVmXY4IjxmVpNGza4/GGdv+K654/7MdkFOJRaQHey/rDt0izzGfaTy/qLSzrPl6Xp2dVVsuSga+oTn9vXRLGyMPlYvw5LeicJn+ti8ms8VecLnIt/mSi8kgCIj/CEbRqM9Pjh6t4dQwu6JFB9C9iN0xBaRccpiJ/0hycpPZJSMKNE6mxjKnv4LcF5hmlHe2uWbjN+HzIGkhKnJu1kbfkn8/mD/dA0idzzt4H8qGLy+v+ldsRcKVjYUHNOMueP+2NBJR2moUpBGLmrh3BuGFsbozXgmK0GiqDwcjD5g4uCtj7qGoi910/VJCx5/YKVaybw2zPNKmtmT4+gjZiXQ8RkbiOkTVXtJV3qMwxHRq8hcGKFFeJpXwFC0AES9fN1iP1+sRUzzLZ/WuabyBURc/ZQEzBTbStqT8VHd8HT3ByN4T8ZQt1w5rYBXun4d7ei6cMeKLLSQbYlg== X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1bddb674-f16b-405f-21b7-08dab1dbabb2 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2022 14:10:26.4283 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: BGoIdWLKqvZFQog9lUeGOGuwqMzRAdbIDKdooouwboN1WdRDfHd62kSYWsgbawL6yTx4c29r+qdrmEdYm9Pf54fzn+YNQsWUF6vxNusAOtw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR13MB4404 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Peng Zhang VF max-queue-number is the MAX num of queues which the VF has. Currently, different users need that the number of VF max-queue-number is different. Configuring the VF max-queue-number dynamically can better match users. Hence, it is necessary to allow user to configure the number of the VF max-queue-number. The string format is V-W-X-Y-Z, the V represents generating V VFs that have 16 queues, the W represents generating W VFs that have 8 queues, and so on, the z represents generating Z VF that has 1 queues. As far, it supports the VF max-queue-number is 16. For example, to configure * 1x VF with 16 queue * 1x VF with 8 queues * 2x VF with 4 queues * 2x VF with 2 queues * 0x VF with 1 queue, execute: $ devlink dev param set pci/0000:01:00.0 \ name max_vf_queue value "1-1-2-2-0" cmode runtime The nfp also support the variable-length argument, Y-Z, X-Y-Z, W-X-Y-Z and Z, it also is right format and represents that the VFs which aren't configured are all zero. For example, execute: $ devlink dev param set pci/0000:01:00.0 \ name max_vf_queue value "1-1" cmode runtime It represent configure the queue is as follows: * 0x VF with 16 queue * 0x VF with 8 queues * 0x VF with 4 queues * 1x VF with 2 queues * 1x VF with 1 queue When created VF number is bigger than that is configured by this parameter, the extra VFs' max-queue-number is 1. If the config doesn't be set, the nfp vf max-queue-number is 2^n which is round_down the average of the total queue / VF nums. If setting the config is "0-0-0-0-0", it also is as the default way to generate VF. Signed-off-by: Peng Zhang Signed-off-by: Simon Horman --- Documentation/networking/devlink/nfp.rst | 2 + .../ethernet/netronome/nfp/devlink_param.c | 114 ++++++++++++++++++ 2 files changed, 116 insertions(+) diff --git a/Documentation/networking/devlink/nfp.rst b/Documentation/networking/devlink/nfp.rst index a1717db0dfcc..1936cee16dbe 100644 --- a/Documentation/networking/devlink/nfp.rst +++ b/Documentation/networking/devlink/nfp.rst @@ -18,6 +18,8 @@ Parameters - permanent * - ``reset_dev_on_drv_probe`` - permanent + * - ``vf_max_queue`` + - runtime Info versions ============= diff --git a/drivers/net/ethernet/netronome/nfp/devlink_param.c b/drivers/net/ethernet/netronome/nfp/devlink_param.c index db297ee4d7ad..5856b45601f7 100644 --- a/drivers/net/ethernet/netronome/nfp/devlink_param.c +++ b/drivers/net/ethernet/netronome/nfp/devlink_param.c @@ -6,6 +6,7 @@ #include "nfpcore/nfp.h" #include "nfpcore/nfp_nsp.h" #include "nfp_main.h" +#include "nfp_net.h" /** * struct nfp_devlink_param_u8_arg - Devlink u8 parameter get/set arguments @@ -191,7 +192,120 @@ nfp_devlink_param_u8_validate(struct devlink *devlink, u32 id, return 0; } +static int +nfp_devlink_vq_config_get(struct devlink *devlink, u32 id, + struct devlink_param_gset_ctx *ctx) +{ + struct nfp_pf *pf = devlink_priv(devlink); + char config[4 * NFP_NET_CFG_QUEUE_TYPE]; + int i, len; + + if (!pf) + return -ENODEV; + + for (i = 0, len = 0; i < NFP_NET_CFG_QUEUE_TYPE; i++) + len += snprintf(config + len, sizeof(config), "%03d-", pf->config_vfs_queue[i]); + config[len - 1] = '\0'; + + strscpy(ctx->val.vstr, config, sizeof(ctx->val.vstr)); + + return 0; +} + +static int +nfp_devlink_vq_config_set(struct devlink *devlink, u32 id, + struct devlink_param_gset_ctx *ctx) +{ + int config_vfs_queue[NFP_NET_CFG_QUEUE_TYPE]; + char vq[__DEVLINK_PARAM_MAX_STRING_VALUE]; + struct nfp_pf *pf = devlink_priv(devlink); + char *num_vf, *value; + u8 config = 0; + int i; + + if (!pf) + return -ENODEV; + + strscpy(vq, ctx->val.vstr, sizeof(vq)); + value = vq; + memset(config_vfs_queue, 0, sizeof(config_vfs_queue)); + + num_vf = strsep(&value, "-"); + while (num_vf) { + if (kstrtouint(num_vf, 10, &config_vfs_queue[config++])) + return -EINVAL; + num_vf = strsep(&value, "-"); + } + + pf->default_config_vfs_queue = true; + memset(pf->config_vfs_queue, 0, sizeof(pf->config_vfs_queue)); + + for (i = NFP_NET_CFG_QUEUE_TYPE - 1; i >= 0; i--) { + if (config >= 1) { + pf->config_vfs_queue[i] = config_vfs_queue[--config]; + if (pf->config_vfs_queue[i] && pf->default_config_vfs_queue) + pf->default_config_vfs_queue = false; + } + } + + return 0; +} + +static int +nfp_devlink_vq_config_validate(struct devlink *devlink, u32 id, + union devlink_param_value val, + struct netlink_ext_ack *extack) +{ + int config_vfs_queue[NFP_NET_CFG_QUEUE_TYPE]; + char vq[__DEVLINK_PARAM_MAX_STRING_VALUE]; + struct nfp_pf *pf = devlink_priv(devlink); + char *num_vf, *value; + u32 total_q_num = 0; + u32 config = 0; + int i; + + if (!pf) { + NL_SET_ERR_MSG_MOD(extack, "Can't find the device."); + return -ENODEV; + } + + strscpy(vq, val.vstr, sizeof(vq)); + value = vq; + memset(config_vfs_queue, 0, sizeof(config_vfs_queue)); + + num_vf = strsep(&value, "-"); + while (num_vf) { + if (kstrtouint(num_vf, 10, &config_vfs_queue[config++])) { + NL_SET_ERR_MSG_MOD(extack, + "The input format is error, expected format: %d-%d-%d-%d-%d."); + return -EINVAL; + } + + if (config > NFP_NET_CFG_QUEUE_TYPE) { + NL_SET_ERR_MSG_MOD(extack, + "The config queue type is more than the max_cfg_queue_type."); + return -EINVAL; + } + num_vf = strsep(&value, "-"); + } + + for (i = NFP_NET_CFG_QUEUE_TYPE - 1; i >= 0 && config; i--) + total_q_num += config_vfs_queue[--config] * NFP_NET_CFG_MAX_Q(i); + + if (total_q_num > pf->max_vf_queues) { + NL_SET_ERR_MSG_MOD(extack, "The set queue is more than the MAX queue."); + return -EINVAL; + } + + return 0; +} + static const struct devlink_param nfp_devlink_params[] = { + DEVLINK_PARAM_GENERIC(MAX_VF_QUEUE, + BIT(DEVLINK_PARAM_CMODE_RUNTIME), + nfp_devlink_vq_config_get, + nfp_devlink_vq_config_set, + nfp_devlink_vq_config_validate), DEVLINK_PARAM_GENERIC(FW_LOAD_POLICY, BIT(DEVLINK_PARAM_CMODE_PERMANENT), nfp_devlink_param_u8_get,