From patchwork Mon Jul 24 09:48:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Peens X-Patchwork-Id: 13323882 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A45F7482 for ; Mon, 24 Jul 2023 09:50:30 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2071d.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe59::71d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDFEB4EC3 for ; Mon, 24 Jul 2023 02:50:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V5vmb4218M0Prhi0yUPPjRQo1Lgzn5TX4O9a8QS1zba1clDi62QmUIm71qiMmLhR9/ntG+/WxIsIDvr8CK8a72Fbv27oZBKcCKjqEXkvgrUn/j0YEUBtUcxc4+GWVojlLXBtEM5qtdoAZngFRtao//HWZyp/jdkHANVF1Ep4F06Ib63H8k6GRQHOv6OeAO+Jjbv8kakI3n1eOQh1lrGr7xhNLgcu/mEe29FCr2STTimsX1pxVPtShncxryFZohDaSYJxJQOE9mDXsvkwGxfPrNa07wVJDYZJpXw6DuyUwRaHRPC4bim8WIV7rTxDhWG4Xay0ahDAQ4kTxL23ys7/sQ== 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=q8MxMY83xTcM28F2igMdsKW3tVxvw1ogvn7+Caroqqg=; b=enc2gQNoyKw0O58vXvrRfMVzaKRc4NfcnCHuCneUyC9FplRtKLdZQdb2N0J9XBc9Z2+smjKPYWllmrBEtBZ+QL+aSQWax1323gHWb0Eqj6foHohRLPlCIiP0oMj0ZfDUY8BBk0fbRLU9JW7EPIo1JIP0ybKHBIL8ogwsoXu6l1wuctJF+IIFynArVMl7MLJ2cM9uCj/2CwDsIGoA61UB1dQA8osYg1KrYgoCBO2JiSWVAT1M5eLlkwhEgpaNKqaP3BssV+kT6x6CC6xAwTi2sLjkBCL4BJxpRbxD9onWE7cQfLZyKoh1X+DouP18Alui3zx6SlS/FvnbTDZBJJTqdA== 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=q8MxMY83xTcM28F2igMdsKW3tVxvw1ogvn7+Caroqqg=; b=tk3+EkjJImyfAZWs5YtgD2obI9mvDNqAg2Rc1k6OmW4Ri9YmQjEVg9NWFLqiTMZjHFlk7Ijw+8OlVPqFlMjmlRRyfi1xCaCchGhiLGq9fZWGMA7RMGI4rWWxIYm9KMrV0b+Otq8ZlVCuCU8v1WEFYrCSyrm39RVC9S1rhCVuOvc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from DM6PR13MB4249.namprd13.prod.outlook.com (2603:10b6:5:7b::25) by PH0PR13MB6020.namprd13.prod.outlook.com (2603:10b6:510:fd::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 09:48:53 +0000 Received: from DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::c131:407c:3679:b781]) by DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::c131:407c:3679:b781%5]) with mapi id 15.20.6609.026; Mon, 24 Jul 2023 09:48:53 +0000 From: Louis Peens To: David Miller , Jakub Kicinski , Paolo Abeni Cc: Simon Horman , Yinjun Zhang , Tianyu Yuan , netdev@vger.kernel.org, oss-drivers@corigine.com Subject: [PATCH net-next 01/12] nsp: generate nsp command with variable nsp major version Date: Mon, 24 Jul 2023 11:48:10 +0200 Message-Id: <20230724094821.14295-2-louis.peens@corigine.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230724094821.14295-1-louis.peens@corigine.com> References: <20230724094821.14295-1-louis.peens@corigine.com> X-ClientProxiedBy: JNAP275CA0020.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:4d::20) To DM6PR13MB4249.namprd13.prod.outlook.com (2603:10b6:5:7b::25) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR13MB4249:EE_|PH0PR13MB6020:EE_ X-MS-Office365-Filtering-Correlation-Id: 61b8a594-d378-4029-a0b2-08db8c2b30f9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bNaAaCH3YRoSc2XUBTPtPlDZAgjDw89sHiTdE4R3HSChcoSpPw9hHGFZ4bU7KSN3XQEg9lpu7v7Bn7HRiOD7j//i6tIdUl3YNs5RrtiHyoGVWcQB6RAs1L1M7xjTk3xKXsfIni2iW62Bj/vYrdM5PkGntuA1KBdXp8JNs3h728YN1HDH1gaMtT7xJIVMzzRgR6C2Sn22V8DAF1Yqrrrqwn5HsJMb1oMqJc0AJWgASAOwTLR6YwULuwTI+M6Ya+Mk6BVxtjcnK3O0zXGPB8oOTUtzwwHDlzNV3ufy+W7JZOc5/7xYYfxS+/KUTExo1HAN3F7QMumW+KEYlogRWE4+CMoJnidJF59QiRU5cKGsmB9Q5uhbeqAhY0PAGLpFT6zwZNy+2HPxyTxEP0HjBGcl0xmba3xlrEC3qYK2IqWcuiHlmxa0/XaG8fCyu0jeFqwoB/yj3TqgVopjklzJ33+/V7GaE0VrbBw5Fbqyj4cwbVsHmL1vUgE9wliSWyGohEEQVHRTi5qOuHn+g/bFfhOGZ/LXVXSTLNLp45qoLF2aoUI85o2khVb911vyGbOYB3Nnt+wbR6MJQaAU4I1wW2gXo6q1WHwkPBLhe2sdatZnz44rYCiMD7XrEUvrd5KUp0zu/TRKBdoGb8im445ycwONR82Qm3BW1XRBGzAa+gMtKVI= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR13MB4249.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(396003)(366004)(39840400004)(136003)(346002)(451199021)(1076003)(26005)(8936002)(8676002)(316002)(6486002)(52116002)(6666004)(86362001)(54906003)(107886003)(36756003)(38350700002)(38100700002)(186003)(6506007)(5660300002)(6512007)(41300700001)(66556008)(66476007)(66946007)(4326008)(110136005)(44832011)(2616005)(66574015)(2906002)(83380400001)(478600001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?MBM05o94EnKlGjJGdOxGmce8e24E?= =?utf-8?q?rWz/peIarAcQNq1kWM3FdIlx5pC7hKA6+6rqDUm9VIIPh9gffi9DBD0PceAW0E3W2?= =?utf-8?q?CLaW89C1MgKs5wufFQgQRH9l5fPckDMHpx+uxas7Y63bgzSmXiwkNj9T6okb+89QK?= =?utf-8?q?AIXmnOVm2EGPi+HX2GI5R8U7jKCFmow64TJGcYBnqvF6UB07lh6mvHuFz5lvqgBj2?= =?utf-8?q?/CU2SZtysqG1k8+UBjisRdInO0TeHqLUHJpZySa59MTVoK+1Dj/Dj+eO0m2mGoaWs?= =?utf-8?q?072+zEOuVcHwgEfS44aociB3JeOnzd6XyDycBxy17kPL0rrtRFXalhFTAvxU3p6D+?= =?utf-8?q?QdCdF6miFVsXNVezCddMzLCjiGQ81nX+mj8xaI+GLPl6aD8yt2dugdDz1DpMqF6Wb?= =?utf-8?q?QgxW7ogTsQPnnRCQkWUUFvGlPf/uBXnP2ToM6m5Ld6W0EE7O3EWiEOpgFgw0FVj1M?= =?utf-8?q?3ed0J/N2+B3ecu0Cd1cz4xRo6QFuyEAdWqm0yFFSnx3gOedCfoTshSJFTv1xQUw36?= =?utf-8?q?uiki3KSoqXqwuPTBdbX4DxlsTkWSDq4XEw9kOuQxYxvU+zI+sGeSO5z2ejlaW8VCH?= =?utf-8?q?pBB7QXMn6nDjTdeTdw/6ahvZ1EriOrBx0jm2pZH1nMt9k/fA2ueLNJPu3Jy8biv8q?= =?utf-8?q?qdloWJnLeTanykyYlBYppOAOC9nQXn1J1t9jJHsEHFwo8wk3TbycnRPXs60sp+sbV?= =?utf-8?q?UF5PLueMyPh/LyEu7mc4fh8868J6DBxhbGOV3z+lHm6jyW6ifgxf3tRS7yTc0Yxpx?= =?utf-8?q?kmHl1Ew7yeDPKHpyhFzY4Nu4/OetfrBedSXrSACTrcoW/DMwlN4Tnpf1brChVXVBS?= =?utf-8?q?VoKjDGcZFzNLiNsmo/gcXYMYnznTNU79xrwUqCimmurlvd8OqX+GBa4aFW3SwvHop?= =?utf-8?q?RpN3cNOvXC64671O4I1Lrj2RCAmWLUiU/162R0s/VhrWQ8ZeRWA26e+AuW0re30f0?= =?utf-8?q?J1Pkk05TOhYxudmvvAlBnre8v+uvfQ2QPQqImMKjuawKbAO0QsiZnPTxt+2Yidl9B?= =?utf-8?q?J/0RMS5Aiyqcx/Y1Ef9b0uGKFP30a76bousDpYRqS99onkfnZleA1N/w3AXwuuJSO?= =?utf-8?q?bCCM/vqp1lopVuXGcapntwHlHe/5KSqOWBTxJ5p3Luuvcok9ZNW0jI4EL04p5oQ/l?= =?utf-8?q?n+0kP4NpXWut8qk5+DJMDbUjCX1jIUyYE9pKDGnQ8n9GFCqsDbgWY5ckQ8Qx2bkTA?= =?utf-8?q?2XXwGZzpW/x5DnPQb2b+Gf6vACS6erV9STF0OR5HsWfeX4mCn8CyC3emzysQ+oy9E?= =?utf-8?q?ujpEw76qPFyHc3QIpelc6twxVQ3baqEbq0773sfLFn7GZDiKMekYjNoI8c4ahnIw0?= =?utf-8?q?OLtiO+MyTk0C/wIPF+nCdc+p52ZBLx+40P/DiB1MMgFQmhyCYt4cqplYIaraMROKs?= =?utf-8?q?M4XdTqxpUerpHsTC5hiBgzHMncRL/r7XKJZSqPrMniEW0THdwjNUSYzfjdVnYguUS?= =?utf-8?q?wlKTe0eMPsLrDqnEY+hGthgHkKBGYD7ZLD2msGh5yUou40XJ08eQrZTRQateEAc9S?= =?utf-8?q?bVK1WHmK4iPu79Re5QEfk5j/9HcLIVBFkQ=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 61b8a594-d378-4029-a0b2-08db8c2b30f9 X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB4249.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 09:48:53.7210 (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: l5KzMn90bD0vGiNJ99EPwd/LockjwhjYP/Z5kUqQ3ttDSjDtECi9qGcaySMQwd+dPVOH5oJkO6wuBhwoOVbpm79MO+Q094uA4EPtPm/NH0k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB6020 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Tianyu Yuan The most significant 4 bits of nsp command code should carry the ABI major version so that nsp command can be responded correctly. It is working well since current major version is 0. However management firmware is going to bump the major version to support multi-PF feature. So change the code to explicitly contain the major version into nsp command code. Signed-off-by: Tianyu Yuan Reviewed-by: Niklas Söderlund Acked-by: Simon Horman Signed-off-by: Louis Peens --- drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c index 7136bc48530b..ee934663c6d9 100644 --- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c +++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c @@ -37,7 +37,8 @@ #define NSP_COMMAND 0x08 #define NSP_COMMAND_OPTION GENMASK_ULL(63, 32) -#define NSP_COMMAND_CODE GENMASK_ULL(31, 16) +#define NSP_COMMAND_CODE_MJ_VER GENMASK_ULL(31, 28) +#define NSP_COMMAND_CODE GENMASK_ULL(27, 16) #define NSP_COMMAND_DMA_BUF BIT_ULL(1) #define NSP_COMMAND_START BIT_ULL(0) @@ -380,6 +381,7 @@ __nfp_nsp_command(struct nfp_nsp *state, const struct nfp_nsp_command_arg *arg) err = nfp_cpp_writeq(cpp, nsp_cpp, nsp_command, FIELD_PREP(NSP_COMMAND_OPTION, arg->option) | + FIELD_PREP(NSP_COMMAND_CODE_MJ_VER, state->ver.major) | FIELD_PREP(NSP_COMMAND_CODE, arg->code) | FIELD_PREP(NSP_COMMAND_DMA_BUF, arg->dma) | FIELD_PREP(NSP_COMMAND_START, 1)); From patchwork Mon Jul 24 09:48:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Peens X-Patchwork-Id: 13323884 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B34DFD308 for ; Mon, 24 Jul 2023 09:50:37 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2122.outbound.protection.outlook.com [40.107.243.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3BDC10F0 for ; Mon, 24 Jul 2023 02:50:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PXtqH3+J9ARcC+rcozfelrpSYyyNifyP0qd31mx+yxIP74wO2amqWQE7CiQEYOzUa1Lx2tCFxJ3jKgGIijqhCr6DCp2auRgDNGEOO/ZTr7PvAwuiy2OInT/3yuC6Q8pdQ2yNabdGwvU4IPS+pp1zIOQ3E/UIJOuEfG03FbIheaejeu5DR6ILhxZzoTvsT/iXeXquzPJlKfkQT+eDJVMAe5eUXVJoqjw1ZESDdmVISM2A5d+pupfPZlPLl44a1beLa8a4hE2o5mzUEtecfxVsaFV8u6gn8IaHdxZ+QvmHgcTA7Iojqln0s3duYQ9hRH/FCUzUkMkws+hU3tudqqA2iQ== 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=Hky2hlzBaIrna72eQV+HsK0TOoTlRixOijN6JZRYRs4=; b=G/g3TKIwJlubsYBxr0Y4ZqVbmoc4xCXDy/dNG+Qa1CeT3tvAGPz2SJYCsz4+hjKcQ95ZRJiJoYJ10kynhQ0qrcLStgx72jhkAGRouIsQAY5J5Jd2xRt8YqF+xnpiFIkwMPx972uOUM+4/N6Tse8yw/yd8+t1cUZzE+/IehdH3y0EifblbyJfF2LGmB93f3ylHbvUk0v2NGIlH78ye7dJibcyyq6h0CZs+VF8cLxW9QMSu54JXhMJfIYgcuSp3cmU0jYsggU59pSeaK8pSZv4DU0ZabYnz1NwI+Zy2Kj2FW3LDHvdahhmAj+PbK5N2fWCSXbVgrsd4soNkV2fETYznA== 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=Hky2hlzBaIrna72eQV+HsK0TOoTlRixOijN6JZRYRs4=; b=oRcWxPD5zxawPTBuFzor0nebur1z8z/ZOzWidiSO8DSNnV/bfRREFD/BvttmRMvBDE6BBqztx2q8LV6FvfPt8cOcBW4HF1kzLweibSJe/KFbfp9+4Wdqw5VRQRNhHz6/iv4sX5vkGm0o2wcCh8iA87GOjVu34YbR+BMzEuZf68U= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from DM6PR13MB4249.namprd13.prod.outlook.com (2603:10b6:5:7b::25) by PH0PR13MB6020.namprd13.prod.outlook.com (2603:10b6:510:fd::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 09:48:57 +0000 Received: from DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::c131:407c:3679:b781]) by DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::c131:407c:3679:b781%5]) with mapi id 15.20.6609.026; Mon, 24 Jul 2023 09:48:57 +0000 From: Louis Peens To: David Miller , Jakub Kicinski , Paolo Abeni Cc: Simon Horman , Yinjun Zhang , Tianyu Yuan , netdev@vger.kernel.org, oss-drivers@corigine.com Subject: [PATCH net-next 02/12] nfp: bump the nsp major version to support multi-PF Date: Mon, 24 Jul 2023 11:48:11 +0200 Message-Id: <20230724094821.14295-3-louis.peens@corigine.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230724094821.14295-1-louis.peens@corigine.com> References: <20230724094821.14295-1-louis.peens@corigine.com> X-ClientProxiedBy: JNAP275CA0020.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:4d::20) To DM6PR13MB4249.namprd13.prod.outlook.com (2603:10b6:5:7b::25) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR13MB4249:EE_|PH0PR13MB6020:EE_ X-MS-Office365-Filtering-Correlation-Id: c9b7a1f7-f616-4d8e-7fe2-08db8c2b3308 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4OaOp9O3It9eEwT29OkzNhhHZp3jGgrjhgQ17QATuM0vK+7/ICwJjPU+pUXMGu88vVB8w6ms7xlph+JdKnuBz3lzasFi1q1H6CjcbCOdeqP37AprTJ66ELPU/ALGmqyJFgjD1v6yDh72qpIYSVLtBt6U6wCn2mC/flOaX1l7J1wLvNSV1kjo+SGElS9f8iB9OLMLYOibXEQVHuYCTd2b0+L04QLQ+0Ek+0kwSo4OGjEwCbbhoa1r+6726K6Knq6cLGR9g2iEfi58be7DjUzyJWRTUXHTQQH8xMSJWXkkMjZ8JhSIbJarWPUJM61jwO1VEzUiB8NG305sgzabpedtteokl0LXuHste1BZFHGvgi/Z/QLQ1wZDoAb9BRIcWTeXPewQ+FO5DoaWsctXnGvsdBVYMZBMncIKgaOyj/PAqAbxAxmQ0tVZvJn+8cRkelMdmQLySMOYBH5RxL3XiLfqDInbhMlffvZMi9ey21zBEbWAnJZdghjSCPbOyIqZy1YG3ShYz9B+pQik6DGOVM1ZCTvVjHne9jc3MzE6r7Q8GKF4tpKcMAW5geVKE876P3Bzyv0ZY6YC5KzlvCBF7+5a5yVxzdFYUf4/QVs08PO4GKGlOLNiuNa0FZUyageahHyRDU3syXIbOHpC2Yn850dDmpjaaPldz7j212R3ILT/x8g= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR13MB4249.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(396003)(366004)(39840400004)(136003)(346002)(451199021)(1076003)(26005)(8936002)(8676002)(316002)(6486002)(52116002)(6666004)(86362001)(54906003)(107886003)(36756003)(38350700002)(38100700002)(186003)(6506007)(5660300002)(6512007)(41300700001)(66556008)(66476007)(66946007)(4326008)(110136005)(44832011)(2616005)(66574015)(2906002)(83380400001)(478600001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?jlKRDDGg2Z3le5kBW6gbhz/2ScjP?= =?utf-8?q?RCx4EePM3FlBRDF+PyVaiCuu8zcl86qOamYw8UwHhVIYqUyFbpXlRVul6GK0EcCf+?= =?utf-8?q?nXbkYAvr5gFXJxcOSDonZeYL3C0vVxCUWj83yOhI0MJSI1rwtfAnaCrVg9LiAUSRl?= =?utf-8?q?CO5DEQpPfQdJTXc2UAAvPjXKV7ZDtnkOR4eKWIzP0Y+vBYI18DbCjzm8isWbBYiUt?= =?utf-8?q?jzk5wC6oRulh/Bfx5M4D+hANQo4NeA5Se/3AotZqbjBJ9wqKWWRq12geL2Ts460lA?= =?utf-8?q?pNUiY67nfUeJPuW77Vt8NQzii399Rid4qoWPAa7xrDJsmQCY842CKxRpXLDGY+png?= =?utf-8?q?yOrVsjyFpmvpTQop/xvvpnqUY38ueQcsYr7d3cTRkiRs2KFzpj4IvnBuAQ5Tr82Vu?= =?utf-8?q?POXDNMvQOESr0yIUKK72wS6TZohs5Hsf7VoDEzy90Hge6MbcXGZ9UGZqOdOEqhOZL?= =?utf-8?q?o8dVEcfjXjk8gpWEqeWpq43B1vggYV2BLCylQ4RVtkwwu/+BwTcnH1CFXLqUKz9Mg?= =?utf-8?q?hogLrjCTr9onEIJ+poLCO29JVyriy3As+MYTEZ9A/A51uwmHfQBvj13Se5HkXnC3p?= =?utf-8?q?NwVNPUrW2hPffDWa21xcZSrp25CDcJsNt9gvk1y/LwLQkplfqFx8DFW1ngZe/v2Un?= =?utf-8?q?/8PCUGrjRbdYhkMyHKGIN8C/FOjZ29eBg1Mk6jHYNb08WzhhoKvx8JlUZ++RaT2zZ?= =?utf-8?q?fOXRE+ZzaUOSG1OvvykZh98NWlpzA0VyPRidyvzSS+NyvAoHidwe2MwHI9eE/Pvw7?= =?utf-8?q?AS7rjOv3fofR/HB8RnH1x8zB2+nU+ORQ+7sJ2f/TBI4wGEFwO9hJ70IgETopKfKFw?= =?utf-8?q?3k73aXK80XqsPVI5s2BedSZ+GC8EWLgGLy+7KxpZ263gdgOy5t5T2dmYYJBQ1sb6/?= =?utf-8?q?V8PLpsrAF5VbAYG6dyK2ahfiAjE89OSrbltAEZX1DSU8QLsiSPrS5BXNh6ANx+eQo?= =?utf-8?q?usT8wgVrACSk1Dezxm36H+NE5XZqwnSqMdnhH3YKSbETn4iI+pFmv3XCWLCDTc2l/?= =?utf-8?q?Q3PjqPMzBPQm4SRpsuPiX6RZR3a4XlI2gkAaJ4VGnZe0ME3mwGmlrqYgMUelTcOWR?= =?utf-8?q?W4UjhnHWpxsx84LYMD/ERE/KI9gU7H3Uu2V6zPuAH7dHD7JmuUsgNajBEGFleoYt+?= =?utf-8?q?Yo4FrfzWOJOJommWvA8mteCm2baTi0lQChG/JlsnJlFNwpReMWAKeKGzoI8xhsiin?= =?utf-8?q?W/EN1Dfir6oUVkVKTkVRfm5ArgPFMpUeTTTgbosfZhtmBKlX+PqHWqmUJec6HlvD/?= =?utf-8?q?f8Q9G/SRH7VEWgaYvHalaoRih+krfYD8TuK0kVPNOyfCwLLjML6o9lCuwkdq9ZWfn?= =?utf-8?q?9zNMi5Jj5JM9jpIldgcB5ErbBFW2ZadqcmtvHM6n4Xsb4wWjYWGdVmB2t8sTuF3fr?= =?utf-8?q?a3CZ02+1vTRngmhepGSWQ4Gral/fPSD+Xmh4cAeoftERnCc3pjokzwj8GFgznm2dp?= =?utf-8?q?Vu1YQrb5nPmtsPCJPJS/Vo5lJLa5yO8gTV6mm+I8u0n3UheiyCWRk0fntu2jgCh84?= =?utf-8?q?PFcMGcduCAiBVdWQWGXx5tB3uJdcRsnF0w=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: c9b7a1f7-f616-4d8e-7fe2-08db8c2b3308 X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB4249.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 09:48:57.4082 (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: YRTe0AZNk7BrR0DUr1CBq6ExrNsLIIVKJXmd2z2i1It4kqkKAK10pssAWQnfde7m3JD8mJ8dZ64f7k4XTTkxBgcfBfGrhquJ4+N0fKK0qqc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB6020 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Tianyu Yuan Currently NFP NICs implement single PF with multiple ports instantiated. While NFP3800 can support multiple PFs and one port per PF is more up-to-date, the management firmware will start to support multi-PF. Since it's incompatible with current implementation, the ABI major version is bumped. A new flag is also introduced to indicate whether it's multi-PF setup or single-PF setup. Signed-off-by: Tianyu Yuan Reviewed-by: Niklas Söderlund Acked-by: Simon Horman Signed-off-by: Louis Peens --- drivers/net/ethernet/netronome/nfp/nfp_main.c | 3 +++ drivers/net/ethernet/netronome/nfp/nfp_main.h | 6 ++++++ .../net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c | 14 ++++++++++---- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_main.c b/drivers/net/ethernet/netronome/nfp/nfp_main.c index 71301dbd8fb5..39c1327625fa 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_main.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_main.c @@ -625,6 +625,9 @@ static int nfp_nsp_init(struct pci_dev *pdev, struct nfp_pf *pf) return err; } + pf->multi_pf.en = pdev->multifunction; + dev_info(&pdev->dev, "%s-PF detected\n", pf->multi_pf.en ? "Multi" : "Single"); + err = nfp_nsp_wait(nsp); if (err < 0) goto exit_close_nsp; diff --git a/drivers/net/ethernet/netronome/nfp/nfp_main.h b/drivers/net/ethernet/netronome/nfp/nfp_main.h index 14a751bfe1fe..72ea3b83d313 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_main.h +++ b/drivers/net/ethernet/netronome/nfp/nfp_main.h @@ -84,6 +84,8 @@ struct nfp_dumpspec { * @port_refresh_work: Work entry for taking netdevs out * @shared_bufs: Array of shared buffer structures if FW has any SBs * @num_shared_bufs: Number of elements in @shared_bufs + * @multi_pf: Used in multi-PF setup + * @multi_pf.en: True if it's a NIC with multiple PFs * * Fields which may change after proble are protected by devlink instance lock. */ @@ -141,6 +143,10 @@ struct nfp_pf { struct nfp_shared_buf *shared_bufs; unsigned int num_shared_bufs; + + struct { + bool en; + } multi_pf; }; extern struct pci_driver nfp_netvf_pci_driver; diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c index ee934663c6d9..3098a9e52138 100644 --- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c +++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.c @@ -59,7 +59,13 @@ #define NFP_CAP_CMD_DMA_SG 0x28 #define NSP_MAGIC 0xab10 -#define NSP_MAJOR 0 +/* ABI major version is bumped separately without resetting minor + * version when the change in NSP is not compatible to old driver. + */ +#define NSP_MAJOR 1 +/* ABI minor version is bumped when new feature is introduced + * while old driver can still work without this new feature. + */ #define NSP_MINOR 8 #define NSP_CODE_MAJOR GENMASK(15, 12) @@ -248,14 +254,14 @@ static int nfp_nsp_check(struct nfp_nsp *state) state->ver.major = FIELD_GET(NSP_STATUS_MAJOR, reg); state->ver.minor = FIELD_GET(NSP_STATUS_MINOR, reg); - if (state->ver.major != NSP_MAJOR) { + if (state->ver.major > NSP_MAJOR) { nfp_err(cpp, "Unsupported ABI %hu.%hu\n", state->ver.major, state->ver.minor); return -EINVAL; } if (state->ver.minor < NSP_MINOR) { - nfp_err(cpp, "ABI too old to support NIC operation (%u.%hu < %u.%u), please update the management FW on the flash\n", - NSP_MAJOR, state->ver.minor, NSP_MAJOR, NSP_MINOR); + nfp_err(cpp, "ABI too old to support NIC operation (x.%u < x.%u), please update the management FW on the flash\n", + state->ver.minor, NSP_MINOR); return -EINVAL; } From patchwork Mon Jul 24 09:48:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Peens X-Patchwork-Id: 13323879 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AEBCD8BEC for ; Mon, 24 Jul 2023 09:50:16 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2124.outbound.protection.outlook.com [40.107.243.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30F074C1E for ; Mon, 24 Jul 2023 02:49:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=niMDcHl35wfPvLsOGaZheTzxWkVdYUP/f9yksYJdZnrKgylmN3QHdQVmuhykU/cl2/0dzEkmHr/4ZL8/yPj23+DJnOdAGbg7IZlXX3ubmx4ARcabb4zGi+AhMYJ71mvlCc0jDRD6+rmOoRsaV7wFO9ZsLEOm6VrtfKlRR1l5YYH5SqIzqfLMYsoXgJYq18GAPWas7qNb+SKTSGXsQZ2RX+2n/hJpswJ5Gjes2jF6+JVbXG95Lb79/kuKe2mkvoMTntcgSzB7gyAJ9zZ9lzipiH+cdotIVGjgJrCnv5RlKynUW6iXxbZ7rrurwYALlyPIzMTIqJ7lz2FJPAfSii4V7Q== 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=7FZVL/j4FDj/1aP7aR7UQG9bAUo5CX//evLuUIhhCyI=; b=l912HaU7vvBFb4NIDYRmX8INvZvVYfUfDO+u4XDsXBx0usndbkeKs6twwuBo6N6z57TTkZgVuVESftDBJAOvLkr0C854D7EcDbw0bmpYqQkeDj1Tzzy0GdZsVHvq6OElStBvl/mQoNRH+6kjeniC7N9/vTR4eoK5VcbvlsOvCrZNqCyt6K3fNwHQIzZznpVX1ErXKnnQARrNiMfXFcxV2bEzSlbZ5ovjc7NF/nO4IA2vY2CTJu/aHJEjfYqAmf9kBS5FS28zY//hhFcFqCsfWjdq3+gbuUYlNZLqL2QK/9wERNZQWO12ChoxH/20HeR+aotJC0poxzWb/ct9oDabxA== 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=7FZVL/j4FDj/1aP7aR7UQG9bAUo5CX//evLuUIhhCyI=; b=OoIv/0PITsYU9v85SMBGS12DBW40roUdNOedY2oOALTlj5wJkza2akkls5ItX4QeManpJFP2T6T7Vk8I1b0JWrpF9W5Q/mZVDNZF7D00by/0SrSEcoGskzE2Glhl/VutL2MMH+gjz/aEUw1/h4vhEXPc8CiwU24HkxIR+5gCjyU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from DM6PR13MB4249.namprd13.prod.outlook.com (2603:10b6:5:7b::25) by PH0PR13MB6020.namprd13.prod.outlook.com (2603:10b6:510:fd::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 09:49:01 +0000 Received: from DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::c131:407c:3679:b781]) by DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::c131:407c:3679:b781%5]) with mapi id 15.20.6609.026; Mon, 24 Jul 2023 09:49:01 +0000 From: Louis Peens To: David Miller , Jakub Kicinski , Paolo Abeni Cc: Simon Horman , Yinjun Zhang , Tianyu Yuan , netdev@vger.kernel.org, oss-drivers@corigine.com Subject: [PATCH net-next 03/12] nfp: change application firmware loading flow in multi-PF setup Date: Mon, 24 Jul 2023 11:48:12 +0200 Message-Id: <20230724094821.14295-4-louis.peens@corigine.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230724094821.14295-1-louis.peens@corigine.com> References: <20230724094821.14295-1-louis.peens@corigine.com> X-ClientProxiedBy: JNAP275CA0020.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:4d::20) To DM6PR13MB4249.namprd13.prod.outlook.com (2603:10b6:5:7b::25) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR13MB4249:EE_|PH0PR13MB6020:EE_ X-MS-Office365-Filtering-Correlation-Id: 9bd6115b-4860-4371-363a-08db8c2b352f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yR0qyq40KzfbuXzRF/SrQZ6CGb49xDRD/m/dHCqBswdeTCm+umU7maCQTyhQtyfjJ0heMT6eTB3B6u5e0sV8Fj9MO6mCEKWEb094XBR4INoMXCTcQ14Tq/iie5s0R7oTU78RovkPMLVIKtEOfaFb/G/usyPeZWQxGG5OjDnLmX1MRV0Lmy9iaZAvfBEsODFsx+5H6iU/SaDtn743PBRwhKkdJSf94LRYpZwbE55tUU4sPM8rLkDT42RyCoAWV4spBEx8VX0wqBSGWOEyriKWhm9vLgHQznoqM0Wq/5lN/t+Mpqz0j/qpgxbQJhnrFgpnSshwxGDS9U/Hq/nbz38DO6AvwP6NjY7+UAl43oMKTNzys3vM77k27ISt7rsj6Rn86WQQkzbBauCLR9rLgLXvDHkdVjO9PAScCAPXOeBgutHl0sg2+n3gMZVyeGllxYesCfePw0GDtx8GeHIPgnYIUbwWO1cxpjR9ntcLZE4ki0/KTCx3skRE9kL/BZguVXIYf0s5S1il6KgyLrfApwMeUi7DJuKJ2wFWlrDwirlMhyIHUOd4hkDllRtHjYdWGzkzLrAOOD1AysAJmqo9/k1pfAQK66dYwG3Y9X3AwDKZv3Ib/cGtBHra+0W1Mla+7mdtGY9ibNjNq8qOY/9FimlJybORXM6hhg2cjjuC0fd34Qg= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR13MB4249.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(396003)(366004)(39840400004)(136003)(346002)(451199021)(1076003)(26005)(8936002)(8676002)(316002)(6486002)(52116002)(6666004)(86362001)(54906003)(107886003)(36756003)(38350700002)(38100700002)(186003)(6506007)(5660300002)(6512007)(41300700001)(66556008)(66476007)(66946007)(4326008)(110136005)(44832011)(2616005)(66574015)(2906002)(83380400001)(478600001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?l2giTLlUKnOQ0UpGCI6l8ABSt4/F?= =?utf-8?q?2Fh7hsOayOfm7Xw2Urz8mqmL6Y6bKW6gdThaz2uyWWIzqgt3Lej/o2xyKF1l3SEKU?= =?utf-8?q?4NmlhApKA+7d3WQ2smPw0kMCT8mmTL2e6XouTHqR15LvXBiWBlcnvnKEIlOyP9pch?= =?utf-8?q?5lsJVIlq9gmw/vFd8g/epOKBk9FqCYZmSQPivkzQ0y8ChFWxBdG1743/X1gQnZsUi?= =?utf-8?q?5+Ab29jmPaYA4ykm2kkssJ/JbsVUSnd+AXM4oZMS08+SIBHy2aICHUrEmI0Fwxu0l?= =?utf-8?q?vBq5c8vHQDKwN0xTimSzpasjfBXyalrYLoh8+Weo8akoA9ZZ0CRGoefcPUZitZhD/?= =?utf-8?q?dp4mxi8gHjwG9GRn8wwDVYzEqrPGn47nU+tHZZB1zRWVWG0Sbpgc3U44Zmd3zI1Ia?= =?utf-8?q?Slmw9xDUMuHD2dHAnFzFti2gT0XFnHU2ZQp1eGgFEuLqYNAItKhD44SFW5RQZKwJ+?= =?utf-8?q?SGbBeeu0rnPC7kYc7ERDjtb8JF1UCgD+S5gx2oRixfjVRr4A25ePqcSSwCBYqp02L?= =?utf-8?q?UJ7m8QDB6uW7QwYZky94RwNUg7djXXkXXyy/0jOtlxM5XZz/00c7ma5NIlB+wpTK1?= =?utf-8?q?WoLz0n/MJ+islC6MeSRBvOEUVahv0A+PGzI0fb8IRmFUKYOIEDcBev0sB7P6D/KJX?= =?utf-8?q?kQZIcmKSW/dGH2uBJiX08vjuFzd/IFzrnWPGXd40mw6BoFCsqGCBXWohqqrksCJmu?= =?utf-8?q?ysGewi9C5Dz/0lnUc+Bt3Pwg6YLorqQ2bjLOnv9iMmL9gI8i9ORLoXSreV/wOoJUJ?= =?utf-8?q?vhFx0QdMilYCYfsfStoo+GXm77gMuoLnxeJCNsCdwAkA1v+VGzLnQu3UW5XRQpfWU?= =?utf-8?q?dv9opDeczwkrmtCX9FnvqNR5clPIJeje/Pqg8cnONU3UXL9vlaZJw9KNocHpnpqi0?= =?utf-8?q?DVP5IfFb3qPjBj021XgbJv+8/fZUuCGQ4keBZaPdPW81pSqsyZxImgpIPcBGI/fRY?= =?utf-8?q?6Eg2UQ6mgEy+2G5Q2dAOXv9MvJJT0j2NqHTXTQp/jydGrhGY6px5OkbA15zUZFGLB?= =?utf-8?q?K0t7+LYaCzYXI73IoPJI1NJ1Aar3Vo7tNgi1D96MB4H1xTmk9G/3OdpFBc3m7Ubu0?= =?utf-8?q?utB1Xwa76GYWI7QIE7BUt52R5VgGvDZwvBuY3t0SE9C/KIxN7vCzpCiJAByd9w6Gw?= =?utf-8?q?UmggL5pw79lIWykP0bnrsHfq3LDTI6iIf2umhMo/6A0qUqMoAJJ5M3RrJWXpUBLCd?= =?utf-8?q?Ok7IZL8GNO2tF2sksS/VklIKb9N5SH2nbTluLJlTnd1WN4lR8GeO21ixZtZXHoFWa?= =?utf-8?q?whrs2ES+VlidFgYMD3GGpb+PA9vsApD6jB5py/p+oVuyIZ0ZykCXhh8IqPfx054nv?= =?utf-8?q?PZXXiRhqHRNy/SPl3dJhxIvrNNm9qWCJwvCbP7Uzt8gLqHGgfxv9CrZGeqLIok0TL?= =?utf-8?q?/2DQZPM8JLC+9I6PAUBvnuvVSnbbBRPKsWPzVhEIr0EmPsmuHO5u6pFqz5pYyzLoC?= =?utf-8?q?O2nmBwJTElWueJnwVukGg5ngMFJGQJKBdVr9ZDacvB8pQzIvl7zpQVcBiAzYEr7fj?= =?utf-8?q?WGmoj/8Xr2oJ6Wm8L2ALxme1HHoPciIGUg=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9bd6115b-4860-4371-363a-08db8c2b352f X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB4249.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 09:49:01.0430 (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: bJlcYUUr+gRH9KVR9EarUsrllbmtAXg/fszkQASDVpCnq07OBOmA9ECYizmuiidwwD4b8SrMxtJjO6T6olGZl/kqaFwZ3lS8B8196BViPfM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB6020 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Yinjun Zhang In multi-PF setup, all PFs share the single application firmware. Each PF is treated equally, and first-come-first-served. So the first step is to check firmware is loaded or not. And also loading firmware from disk and flash are treated consistently, both propagating the failure and setting `fw_loaded` flag. At last, firmware shouldn't be unloaded in this setup. The following commit will introduce a keepalive mechanism to let management firmware manage unloading. The flow is not changed in non-multi-PF setup. Signed-off-by: Yinjun Zhang Reviewed-by: Niklas Söderlund Acked-by: Simon Horman Signed-off-by: Louis Peens --- drivers/net/ethernet/netronome/nfp/nfp_main.c | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_main.c b/drivers/net/ethernet/netronome/nfp/nfp_main.c index 39c1327625fa..c81784a626a6 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_main.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_main.c @@ -528,6 +528,10 @@ nfp_fw_load(struct pci_dev *pdev, struct nfp_pf *pf, struct nfp_nsp *nsp) if (err) return err; + /* Skip firmware loading in multi-PF setup if firmware is loaded. */ + if (pf->multi_pf.en && nfp_nsp_fw_loaded(nsp)) + return 1; + fw = nfp_net_fw_find(pdev, pf); do_reset = reset == NFP_NSP_DRV_RESET_ALWAYS || (fw && reset == NFP_NSP_DRV_RESET_DISK); @@ -556,16 +560,30 @@ nfp_fw_load(struct pci_dev *pdev, struct nfp_pf *pf, struct nfp_nsp *nsp) fw_loaded = true; } else if (policy != NFP_NSP_APP_FW_LOAD_DISK && nfp_nsp_has_stored_fw_load(nsp)) { + err = nfp_nsp_load_stored_fw(nsp); - /* Don't propagate this error to stick with legacy driver + /* For single-PF setup: + * Don't propagate this error to stick with legacy driver * behavior, failure will be detected later during init. + * Don't flag the fw_loaded in this case since other devices + * may reuse the firmware when configured this way. + * + * For multi-PF setup: + * We only reach here when firmware is freshly loaded from + * flash, so need propagate the error and flow the fw_loaded + * as it does when loading firmware from disk. */ - if (!nfp_nsp_load_stored_fw(nsp)) + if (!err) { dev_info(&pdev->dev, "Finished loading stored FW image\n"); - /* Don't flag the fw_loaded in this case since other devices - * may reuse the firmware when configured this way - */ + if (pf->multi_pf.en) + fw_loaded = true; + } else { + if (pf->multi_pf.en) + dev_err(&pdev->dev, "Stored FW loading failed: %d\n", err); + else + err = 0; + } } else { dev_warn(&pdev->dev, "Didn't load firmware, please update flash or reconfigure card\n"); } @@ -575,9 +593,10 @@ nfp_fw_load(struct pci_dev *pdev, struct nfp_pf *pf, struct nfp_nsp *nsp) /* We don't want to unload firmware when other devices may still be * dependent on it, which could be the case if there are multiple - * devices that could load firmware. + * devices that could load firmware or the case multiple PFs are + * running. */ - if (fw_loaded && ifcs == 1) + if (fw_loaded && ifcs == 1 && !pf->multi_pf.en) pf->unload_fw_on_remove = true; return err < 0 ? err : fw_loaded; From patchwork Mon Jul 24 09:48:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Peens X-Patchwork-Id: 13323883 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47193D308 for ; Mon, 24 Jul 2023 09:50:34 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2124.outbound.protection.outlook.com [40.107.243.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F2B44C1E for ; Mon, 24 Jul 2023 02:50:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EnrpsPv9/pTr61u9SuzPvlqGdYR4pec6S1TpOSzBDcfV1LwhTWuMvW/yBHy3HBxTjWtUgFlJTrv0znuC6I2varE1eO1efl2c/Mj/yWC21LxMH+zGLu/fr1ij2RuVaEcsS1igsYkmxtQLYDCqL4HLMjWgJ2ZSu/iBwAOXKHI7tVw21CEmI77KiDut35qrg8FRIieInqxwyN26m/1Hcqa9nLOlbs+1wB7QNXyciRyx9mj795a1TBRJ7sLvbF2/sZm50ezocB92vDv1nULCAn/Yz37AKKULNwUWksL+Vqaf/dN3aP9jbH1Elp1KvYKG2y4ryI5oMehK2FeENyBI+RdQtw== 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=LBUXZqRJXAmBgNMsYWTMWNsnJkPQFbIT8w2pC32UAzw=; b=fPUvn58qjdC7dZGIMs8p34qgSEWPQaUMIzCojpRLDIqDvfXstgnUceTUWsxSYM1ZAjM9vFrfo6lVtogDjsgvmv+dJsCB3kTvo7G5D7pkpW/uvCPH4ndiiDW9VinoK3Tkk45t7RXPlN4IgKDe4XZvTvtMPspN/AX/5b4f4NE9jUqEroilPjk39qKa0IL983fVYTBz0wc7WG4H0aN0xGT3m9fPggqJoNezBpK+uurhzIiOkL1swF1fTh7w4YaM+oFC2MxzEjWgdj1XcliY3KMg2QvsNdDBJh5gkNipQsEpXV0xAp+/o2YIrr/6gPSv5OuHhLc1pbx1dDTwJd6CitwPyw== 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=LBUXZqRJXAmBgNMsYWTMWNsnJkPQFbIT8w2pC32UAzw=; b=MG8JPbxww6VJBBgRocDZBRd5wq4FI4GvymrnnXTmlQHqyZcxR1r5WgLmG5JY5qpzgLUJW2V/MgE9OqYPnJ1ZFHP0w8GmMhxvaQ2MDJ3U5kJTaLNZkDSLyaXmLHGmE5UwzlnKAIRrSWQYW5ic2ddgjg3zWBiAHhRh6k/Ne9opsHA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from DM6PR13MB4249.namprd13.prod.outlook.com (2603:10b6:5:7b::25) by PH0PR13MB6020.namprd13.prod.outlook.com (2603:10b6:510:fd::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 09:49:04 +0000 Received: from DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::c131:407c:3679:b781]) by DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::c131:407c:3679:b781%5]) with mapi id 15.20.6609.026; Mon, 24 Jul 2023 09:49:04 +0000 From: Louis Peens To: David Miller , Jakub Kicinski , Paolo Abeni Cc: Simon Horman , Yinjun Zhang , Tianyu Yuan , netdev@vger.kernel.org, oss-drivers@corigine.com Subject: [PATCH net-next 04/12] nfp: don't skip firmware loading when it's pxe firmware in running Date: Mon, 24 Jul 2023 11:48:13 +0200 Message-Id: <20230724094821.14295-5-louis.peens@corigine.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230724094821.14295-1-louis.peens@corigine.com> References: <20230724094821.14295-1-louis.peens@corigine.com> X-ClientProxiedBy: JNAP275CA0020.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:4d::20) To DM6PR13MB4249.namprd13.prod.outlook.com (2603:10b6:5:7b::25) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR13MB4249:EE_|PH0PR13MB6020:EE_ X-MS-Office365-Filtering-Correlation-Id: 273cbaf0-8905-444d-3872-08db8c2b3783 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NJFmEOvJGzQXLVA3lY9LWh5YmriAUDFdmu+UtYElFRO29BuuIN9Je3LSaavCP4Inf4uhryu2ewcMAanLlJ5h9dnkTIZr86p0G4LwHo4PaUkHEzNaSwvcvIRztpAqC2VDO1j/MVaCQp6o6jjvemwZeHyQRMzMQLkodlCubfvVudzQd9xtireemd9Ic0AZPvwCwkVLkfsLx2oaZQcdsUYmZ+fdAGQHX9ktlQQCunXE0InnMVFYduOZcpk3IdgMiQmNWmXrfWv/svQK3M/ffgfjC5TOdEwXIzXW/jBg8jbDVII0Fckugt5zlQkp2WB8/Oj9nq1w5ezro8SpMCs90Amidkk4YIeAcPPYNwGhY913hjJB2wDq0jg0uFow6VM7KwTxQlWp9VopJ4jqHbvAh1l1alSuZPWOI5gh1zhQnPF85r5PyNXiA7D6PCuGVvzvmm+gDhfnrDgzXwh4fIOC0EfyoReNDOXPyKFD9cMj46iKODPZBdwtPuDjFTCf94PvnGOus2uoa8D/0D+l4FIF2/5dc1Bl16XRRGYfQDPZJLxyhSgjLXa853INZ4HalXhYEfMjMuxpPzlK0i9HVGloAHgAi2b3rloaQ7mY9o0U0/thkGJzmX7U5wi6TfJvGbUmw+1P+FKX2iaEauZpktbgMFTAsK1rZC6i2V7QLUU0XdwBG2bS1pz0sKq8a6LUlQWt3ZEY X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR13MB4249.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(396003)(366004)(39840400004)(136003)(346002)(451199021)(1076003)(26005)(8936002)(8676002)(316002)(6486002)(52116002)(6666004)(86362001)(54906003)(107886003)(36756003)(38350700002)(38100700002)(186003)(6506007)(5660300002)(6512007)(41300700001)(66556008)(66476007)(66946007)(4326008)(110136005)(44832011)(2616005)(66574015)(2906002)(83380400001)(478600001)(309714004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?1hzFHDqrO32hRVhVgSQgd/DgBvYU?= =?utf-8?q?9LdPAb1h/HzpNmreiX2Bbj5lS7nkVKA/LuXQTsfZZkQOAyPc2z+ulx2l/sUZOFyBT?= =?utf-8?q?ot8KYXpnhjxFcWm2SpUYgMFHjl6EUTa1U7QuBL8s85kOoCzZlmopLNWO/21xQDWpd?= =?utf-8?q?WKR8iPver63o0BDi6BimGYP1VhoUPHHXeek/m+ipQj/YZbn3oisyM1OaE+wh5SSQP?= =?utf-8?q?c9XEfL0ZKnA032fQrKh4u/3Tk9G7N3FrIWP8jIXKSRyZeKyW2snzFxQroesbEKyvI?= =?utf-8?q?MiWOdQRT0qjJT7Q0HulRs1BKc50WhcVInPtArFvFROrBAPKrgrxjU+rRSHwgO1eJB?= =?utf-8?q?kDVo/FC4hX7tNH7ZOZhuAsnK1XQVtwUDVaYSkOQMeunexbmewrLMidQ0BcdqflllP?= =?utf-8?q?/uCCpPUv9N9pCy1/fdp8bbqvaQ2rJKEfQrNqRJuMPAcshfxe+4d41sQVuvZisTRR9?= =?utf-8?q?YLvv2aFJA1d6Mu5S1fJO/Wu5/C1LYABmT8urU9SiziXGrl06e4SH2llALUKCG+msG?= =?utf-8?q?GvFyz/ETSChh9q7fR25RCCvmQ5JHeoAm/OaDU8pWVmt/Gmz5PiHu2ZIH8IaQSCOfF?= =?utf-8?q?ZwNuCQYm/HNxJQ4RHMykYKbenVxf0sS85Ie2D54qgST7gNSIN4Jcv1gT4unpq8xip?= =?utf-8?q?ax6fKTbUkW+HI98koGRjrB40a+93NcKOWuQFiC6IVzrTyMSleT8+6l2quGaDC1b16?= =?utf-8?q?Zp5rnPCYjYH+aE5ugCbvKZcO+lr2RFymPcW81WEboXkr/gnY3Ja5EKhcn3mNnvreW?= =?utf-8?q?mve5KYNuzxsPIWrSs1pGuhns71YWKGEfsjanYNoTNK7vkLC4xYAFI428ocOCzy918?= =?utf-8?q?ZlnLWmF73wTRecifIRgJWLzRHmilNleOE4cxCMcM5+s7aYKOf1OLxh2MxQuFLbjsX?= =?utf-8?q?DKKr2qczwveKy0C4A21v9iG13EKQ8MEdK7Iqp5fpjlfgA2b640OeUI+EwMOuAzTdH?= =?utf-8?q?MIwjldVaXTWv0xqkFyfpqasR7KHH9kWPewknK1qbXoLRbliqW/U7URFSV9CLrmNWD?= =?utf-8?q?LzYZXev9h9smJ8WLkRncuslxq4DccQBDpHQS9WEo//YBFQFNJf102MvTpUqV8m3tQ?= =?utf-8?q?YJFvksLVfGfESmZvunN1dstznlXDPee4WFPNsdPfCZcm6Q/IGs864PjdV0j9kRn9H?= =?utf-8?q?CsW4vDCazwgfvkyXsfcs7tg23zdRB3cGCxy8Rk1CUs1/zC3vaLJTR/OxKpnKh01vP?= =?utf-8?q?OwJsyZgUyM7fojEFDwqVYPUa9uPN8bgK7TTR4TXLc8rpIlFuflZj9nW1qEXd2gvzv?= =?utf-8?q?dLOF6RbdBNildAHHd9pqHjTvK/tpCPwtNsyEX6hIpgZjRCfqBxZc84zujr0J2J/xF?= =?utf-8?q?xih8H0/RZ/EVNJ2eTx2ZM0wtfAjemVmURu1Esyls84z4PdiE6w4QaJl/3ekYglkR/?= =?utf-8?q?W70vLs9Z3aiUK1O/EVaa743iJ0RYszaasVIpA4+wI0n+UBhZsZly0ErPEnnyHzsDs?= =?utf-8?q?WcX1K16tqy75zqNqMi9Rm3U3tEEwfDHmauWVawOnywRmH/OMU9qsQz9wV5i98mXto?= =?utf-8?q?JX4a/ZGo+7+xDXAMHUaWpqyf2OzmisTOIA=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 273cbaf0-8905-444d-3872-08db8c2b3783 X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB4249.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 09:49:04.6819 (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: 9YAuYFneOU8zKzowE9FwzavDXuQeCu1sa6THZAsduAAq4NdziUbr1V6SujOAVspUjtfabUXoCOX6Rj8XnefdPqTyQup/IzgSPuophhJ5BuE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB6020 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Yinjun Zhang In pxe boot case, the pxe firmware is not unloaded in some systems when booting completes. Driver needs to detect it so that it has chance to load the correct firmware. Signed-off-by: Yinjun Zhang Reviewed-by: Niklas Söderlund Acked-by: Simon Horman Signed-off-by: Louis Peens --- drivers/net/ethernet/netronome/nfp/nfp_main.c | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_main.c b/drivers/net/ethernet/netronome/nfp/nfp_main.c index c81784a626a6..778f21dfbbd5 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_main.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_main.c @@ -469,6 +469,28 @@ nfp_get_fw_policy_value(struct pci_dev *pdev, struct nfp_nsp *nsp, return err; } +static bool +nfp_skip_fw_load(struct nfp_pf *pf, struct nfp_nsp *nsp) +{ + const struct nfp_mip *mip; + bool skip; + + if (!pf->multi_pf.en || nfp_nsp_fw_loaded(nsp) <= 0) + return false; + + mip = nfp_mip_open(pf->cpp); + if (!mip) + return false; + + /* For the case that system boots from pxe, we need + * reload FW if pxe FW is running. + */ + skip = !!strncmp(nfp_mip_name(mip), "pxe", 3); + nfp_mip_close(mip); + + return skip; +} + /** * nfp_fw_load() - Load the firmware image * @pdev: PCI Device structure @@ -528,8 +550,7 @@ nfp_fw_load(struct pci_dev *pdev, struct nfp_pf *pf, struct nfp_nsp *nsp) if (err) return err; - /* Skip firmware loading in multi-PF setup if firmware is loaded. */ - if (pf->multi_pf.en && nfp_nsp_fw_loaded(nsp)) + if (nfp_skip_fw_load(pf, nsp)) return 1; fw = nfp_net_fw_find(pdev, pf); From patchwork Mon Jul 24 09:48:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Peens X-Patchwork-Id: 13323886 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E673FDDA3 for ; Mon, 24 Jul 2023 09:50:46 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2071d.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe59::71d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1179530C4 for ; Mon, 24 Jul 2023 02:50:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a+nC2yKHZ7X4r4ZzeLB+gESPaw1LV3YsIgxVKGzltyZ1MJ1dimaSQ5m8Vmf5pp7npy9FoKhHik+V27jH6GrowfPVvcOtSJNRQS1i/9uG6ayRbOU+qJlIfS+EBEGwhnRo/LlCI32qmOj+Q8/rFsp66Q4P/0g0C+PTDTP03DxV5s3+yckC5YsjsQH1Fk8mT9Z8lUjwZNY4WqvdyuR605FdsxrPhfoFxFXbr/mfm5b8tsEdcfH3JFmpzn3KSVV8/QtytDBebqo93JHyjqqSDD0s8IxASTZsYdv+f3HoPPGFixbJlf3msQcKYSwe3NlBB+v3mi2cbwcO++rMFp3HS3MdhA== 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=7sCbGh+9x4dpbOD+eyONtMkfEGH4E1zjjEigSmOSLPM=; b=KRiCPn4E+UqJKjeqewxo39sybJg6e3o0UbHMm+9Qtz4AmbZc8AfKw/vsKyDe5FDotpMg+CRAGU5jB4Cr+6ukXqrXhap45U6y7rB8LICKGywIpUGAOaObv0qSoovpuf96WQoykj0Os1Nk+fZG6qn5QJP3cw8WihvB9daI5fXEa04kHF59Xq0xfq1MbQHQ1ZSr4UpQAm72KmXdkW6faTtCx99BR0JbYOjp4ZChmN5cPpKuFtQf5tUbHe/N4ynR9lK2lsgXUDbxjUAu7fzJVPIN7sUFG2+mLgLeDTYZzh7v8PkaTqkR+xHVgLPCs5STfS+tBlPID7LF/1LFdMRUz8CqNg== 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=7sCbGh+9x4dpbOD+eyONtMkfEGH4E1zjjEigSmOSLPM=; b=WbkTPxnt6+HZwEeK6ryGEzs8mBfiiOlwy7k41ieEXOf7IyvlnIjRBtF7AwyH1T+xmKv1xa49bZdT3kjc4ERy45zfc2sDLnK7hOp7FnmGNWSoPxRU9WQmtiuDa/lTCgGdE1IYDhNeuSM1st5dyFGRst/nRw2AlZu4Ab5JQ4NhyQ4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from DM6PR13MB4249.namprd13.prod.outlook.com (2603:10b6:5:7b::25) by PH0PR13MB6020.namprd13.prod.outlook.com (2603:10b6:510:fd::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 09:49:08 +0000 Received: from DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::c131:407c:3679:b781]) by DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::c131:407c:3679:b781%5]) with mapi id 15.20.6609.026; Mon, 24 Jul 2023 09:49:08 +0000 From: Louis Peens To: David Miller , Jakub Kicinski , Paolo Abeni Cc: Simon Horman , Yinjun Zhang , Tianyu Yuan , netdev@vger.kernel.org, oss-drivers@corigine.com Subject: [PATCH net-next 05/12] nfp: introduce keepalive mechanism for multi-PF setup Date: Mon, 24 Jul 2023 11:48:14 +0200 Message-Id: <20230724094821.14295-6-louis.peens@corigine.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230724094821.14295-1-louis.peens@corigine.com> References: <20230724094821.14295-1-louis.peens@corigine.com> X-ClientProxiedBy: JNAP275CA0020.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:4d::20) To DM6PR13MB4249.namprd13.prod.outlook.com (2603:10b6:5:7b::25) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR13MB4249:EE_|PH0PR13MB6020:EE_ X-MS-Office365-Filtering-Correlation-Id: 5dd36d2b-9067-46bc-2a20-08db8c2b39a5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8oITnIMwiytzEby3/bncONGr3N2B/Fa4TGsQUPon7FcalVWJkYEcQxXzufJ5b5m5v5wRvACl+ANM5llirosfi56DegExs8vXM0VMPJ3LsM5ILrz+fpxonyc363tacxl0zfLFQrG1lhK1fePNB0d173T5+jqg7+7OehQ1/cLKPqEpPOxoV50Nqy14VNT9yitfkKKS/sGJv8umKup7g7efwjthC9UKINCSNXzidK0IAWWAZu3r7OyLLvHyOXB1zzMiedy4JjM80O91cdLy0bMUiXitlUzRfS4zhHt/TBVoK9lNdAfxF5bWFRT/9ywziL5YMbWO31MtO5QNO5uF9NeUJEqJsDCkO0SVZiQpKEwzx6Ksa1jrMSjeUD6Z0zOVntq0kes41OLCZDNBNtSOeFfKLcGn9pWTEHDzoTiXXbgE4YW3AV67vHXB4Lbr6dLRbdBvO33Dls25ojlSUe9Y3PD476ch6o/iahumMwGX1l1aONOiuAObBpXgpMrEXz2EZOEHJy/avgR+iEbyKv+UxsyPlby6WSYQl8tFFFJfEkjZjLok9zSa0zWe14W3bnFZfMTBrdnACjL30tNdSQ3FntglnV6Zme/7hXSTPqv9ksm0JgBy1RQ0WGRk0btsoCGTH5lo57JA644X91ne/LnfjG79LSN4tZY6+0HAYgDaBXj5anQ= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR13MB4249.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(396003)(366004)(39840400004)(136003)(346002)(451199021)(1076003)(26005)(8936002)(8676002)(316002)(6486002)(52116002)(6666004)(86362001)(54906003)(107886003)(36756003)(38350700002)(38100700002)(186003)(6506007)(5660300002)(6512007)(41300700001)(66556008)(66476007)(66946007)(4326008)(110136005)(44832011)(2616005)(66574015)(2906002)(83380400001)(478600001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?TznB8L/hN5KnGXjmBQ3671/MTHWw?= =?utf-8?q?FYM8lBDevUUE0OpxGjFfIZuxagl0rMhKeXJ5GwiDanoWFk05IC8XL20tRkNFnnBDu?= =?utf-8?q?XDeU7A5WgyzDS5sDlb6qhRTLlbeJLebkGsggDEQ/PfY2H2jUT1Nt2gClObokO1tCa?= =?utf-8?q?s+3lO4jcVTotPUIPnEVDmlSFPRQxkQKk3jFlLmlpvJ2b7ALeltqsADadXDpZo7Cv3?= =?utf-8?q?MwbfiYZioEs0yIRtzv5sad0a9N8Rkq7Zk96mgrSLXbuc3VWwCP8vGl6lMglujFzJS?= =?utf-8?q?bI7rmBbbX9wabRcYK+XvJJVCXlvtxW0POysVCMfsll+lMDuBqaLHjvySlwzHFTe2K?= =?utf-8?q?dLI+AyxQQKwX0LzKTdLA/Je1gWFXtSWxOglx3tDrMPcohh7lxGUC66osQDRMlnWxK?= =?utf-8?q?4AQsbf01PdV4fwf1EiR5LBxN/lOrQwyDfxPHhwZCkhSmjSB/SU5zi9P5XValzgvte?= =?utf-8?q?OoMqECwplVx2CgyKjqJYVjAdqIBK5DDiFujJKZIMm/J+OQp7Dq5lYFRnO9wlaI9kL?= =?utf-8?q?Ipnru6X60AC5+GHttmdt7j0ewdw3bbkD5cumvW6SFmgmBM4qscsZ7lcM2yV2416PQ?= =?utf-8?q?0OcwULGSYofO1tpCi/Fuo1IVe4Ws8YR/Jl8bk3LVV2II8T/wifJMn4/2sq+wZv+G+?= =?utf-8?q?q2ExxC3JUAW7iAK4igjEwp4bSf7RdWa1iEXuQtr8sxes5voaaMsuU++PHdrVbcenY?= =?utf-8?q?WfEAWe3ZjwoIaosTbZDgMGaM9I9fNKykNQoXAVZYceyfOg8mZiEzM1GV1i3Ofl6Io?= =?utf-8?q?YfS4N42fKsEqd5UtOOxMknT8YoZt+Zf6Cqoln69sKC2dDxSJfYoRMS97UVugJ+i2e?= =?utf-8?q?dM9QIBQnCcFDRsHoqomLO+PeUC67ulZS21HDTkewEMNXGqOLjzeAmTUXod15HNZbH?= =?utf-8?q?WDqPzq/ouc+N2GTrxVOIjfQH3Ra4E1n8gAnIEJgL7/GD3gk58hyWJmxHDEaeV9PBi?= =?utf-8?q?sgGhdcFLt2P0/OmNSa/2B6xRC2bBC1c6mbzpjyX14ztNChfkp9omO1XMxUXkYWYxR?= =?utf-8?q?giu+JLipWCtEnBSY8WE8qqw5Rcu7i8M4ART240wFGQweyiX2FbulQypLzqP8OwTMb?= =?utf-8?q?65/kUhLHr3zB8zCw2i5aWx/9DqX7GWxYOc5oFve7nALGhaJ0JoFn7FXz9liMy7LoJ?= =?utf-8?q?8DRU4Zr6wGaN2B0g2uPSpw7A61pQyJWbZeE5x/Fghc5rV5P2WiS7jAceZIasipk13?= =?utf-8?q?HWnoX4lPYkviBrzdyKoS2aSoDcgM+P7bnEfMplWnxOjzqk3DGo+vZ3w9jnSRAPFrx?= =?utf-8?q?tSNfzrCj7m0MyZ0R00qur7Y9zhPwNygR50vh2nxuwpu0JnBLpiaHBQjIh+ucKg/rV?= =?utf-8?q?strAGQZbmIyPh6KNXffREdDL1CCR0KucUUcBFCXidxaVym1Mg7rpJQOsMreSEUiJv?= =?utf-8?q?q5H3wx7COjMb5TuJWF5MCXx754aAhh8PHoca3QaW2eYW1c2Jf8VyQXtttcwZfROJd?= =?utf-8?q?0+6Ywf9jJUYOOWMhMSwTtKAEQciG01pbkx2ifysHTwY5RDP0vaMmo3qL+Ve9/hlvm?= =?utf-8?q?82oqsSvSs+6ZvXnKRTOUSqzZgODcpfTXbw=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5dd36d2b-9067-46bc-2a20-08db8c2b39a5 X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB4249.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 09:49:08.5453 (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: KWIZX/5evBPTvu2358psi1xQjiSKl69QjEWEoSVyjdc/B2JvCLjGHP62x6YDpFSSzQX9eCoHNJ6HNBB5mCdJVOSildHXyHBMrEQeELoHCqc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB6020 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Yinjun Zhang In multi-PF setup, management firmware is in charge of application firmware unloading instead of driver by keepalive mechanism. A new NSP resource area is allocated for keepalive use with name "nfp.beat". Driver sets the magic number when keepalive is needed and periodically updates the PF's corresponding qword in "nfp.beat". Management firmware checks these PFs' qwords to learn whether and which PFs are alive, and will unload the application firmware if no PF is running. This only works when magic number is correct. Signed-off-by: Yinjun Zhang Reviewed-by: Niklas Söderlund Acked-by: Simon Horman Signed-off-by: Louis Peens --- drivers/net/ethernet/netronome/nfp/nfp_main.c | 88 +++++++++++++++++++ drivers/net/ethernet/netronome/nfp/nfp_main.h | 8 ++ .../net/ethernet/netronome/nfp/nfpcore/nfp.h | 4 + 3 files changed, 100 insertions(+) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_main.c b/drivers/net/ethernet/netronome/nfp/nfp_main.c index 778f21dfbbd5..489113c53596 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_main.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_main.c @@ -469,6 +469,77 @@ nfp_get_fw_policy_value(struct pci_dev *pdev, struct nfp_nsp *nsp, return err; } +static void +nfp_nsp_beat_timer(struct timer_list *t) +{ + struct nfp_pf *pf = from_timer(pf, t, multi_pf.beat_timer); + u8 __iomem *addr; + + /* Each PF has corresponding qword to beat: + * offset | usage + * 0 | magic number + * 8 | beat qword of pf0 + * 16 | beat qword of pf1 + */ + addr = pf->multi_pf.beat_addr + ((pf->multi_pf.id + 1) << 3); + writeq(jiffies, addr); + /* Beat once per second. */ + mod_timer(&pf->multi_pf.beat_timer, jiffies + HZ); +} + +/** + * nfp_nsp_keepalive_start() - Start keepalive mechanism if needed + * @pf: NFP PF Device structure + * + * Return 0 if no error, errno otherwise + */ +static int +nfp_nsp_keepalive_start(struct nfp_pf *pf) +{ + struct nfp_resource *res; + u8 __iomem *base; + int err = 0; + u64 addr; + u32 cpp; + + if (!pf->multi_pf.en) + return 0; + + res = nfp_resource_acquire(pf->cpp, NFP_KEEPALIVE); + if (IS_ERR(res)) + return PTR_ERR(res); + + cpp = nfp_resource_cpp_id(res); + addr = nfp_resource_address(res); + + /* Allocate a fixed area for keepalive. */ + base = nfp_cpp_map_area(pf->cpp, "keepalive", cpp, addr, + nfp_resource_size(res), &pf->multi_pf.beat_area); + if (IS_ERR(base)) { + nfp_err(pf->cpp, "Failed to map area for keepalive\n"); + err = PTR_ERR(base); + goto res_release; + } + + pf->multi_pf.beat_addr = base; + timer_setup(&pf->multi_pf.beat_timer, nfp_nsp_beat_timer, 0); + mod_timer(&pf->multi_pf.beat_timer, jiffies); + +res_release: + nfp_resource_release(res); + return err; +} + +static void +nfp_nsp_keepalive_stop(struct nfp_pf *pf) +{ + if (!pf->multi_pf.beat_area) + return; + + del_timer_sync(&pf->multi_pf.beat_timer); + nfp_cpp_area_release_free(pf->multi_pf.beat_area); +} + static bool nfp_skip_fw_load(struct nfp_pf *pf, struct nfp_nsp *nsp) { @@ -550,6 +621,10 @@ nfp_fw_load(struct pci_dev *pdev, struct nfp_pf *pf, struct nfp_nsp *nsp) if (err) return err; + err = nfp_nsp_keepalive_start(pf); + if (err) + return err; + if (nfp_skip_fw_load(pf, nsp)) return 1; @@ -620,6 +695,16 @@ nfp_fw_load(struct pci_dev *pdev, struct nfp_pf *pf, struct nfp_nsp *nsp) if (fw_loaded && ifcs == 1 && !pf->multi_pf.en) pf->unload_fw_on_remove = true; + /* Only setting magic number when fw is freshly loaded here. NSP + * won't unload fw when heartbeat stops if the magic number is not + * correct. It's used when firmware is preloaded and shouldn't be + * unloaded when driver exits. + */ + if (err < 0) + nfp_nsp_keepalive_stop(pf); + else if (fw_loaded && pf->multi_pf.en) + writeq(NFP_KEEPALIVE_MAGIC, pf->multi_pf.beat_addr); + return err < 0 ? err : fw_loaded; } @@ -666,6 +751,7 @@ static int nfp_nsp_init(struct pci_dev *pdev, struct nfp_pf *pf) } pf->multi_pf.en = pdev->multifunction; + pf->multi_pf.id = PCI_FUNC(pdev->devfn); dev_info(&pdev->dev, "%s-PF detected\n", pf->multi_pf.en ? "Multi" : "Single"); err = nfp_nsp_wait(nsp); @@ -913,6 +999,7 @@ static int nfp_pci_probe(struct pci_dev *pdev, err_net_remove: nfp_net_pci_remove(pf); err_fw_unload: + nfp_nsp_keepalive_stop(pf); kfree(pf->rtbl); nfp_mip_close(pf->mip); if (pf->unload_fw_on_remove) @@ -952,6 +1039,7 @@ static void __nfp_pci_shutdown(struct pci_dev *pdev, bool unload_fw) nfp_net_pci_remove(pf); vfree(pf->dumpspec); + nfp_nsp_keepalive_stop(pf); kfree(pf->rtbl); nfp_mip_close(pf->mip); if (unload_fw && pf->unload_fw_on_remove) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_main.h b/drivers/net/ethernet/netronome/nfp/nfp_main.h index 72ea3b83d313..c58849a332b0 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_main.h +++ b/drivers/net/ethernet/netronome/nfp/nfp_main.h @@ -86,6 +86,10 @@ struct nfp_dumpspec { * @num_shared_bufs: Number of elements in @shared_bufs * @multi_pf: Used in multi-PF setup * @multi_pf.en: True if it's a NIC with multiple PFs + * @multi_pf.id: PF index + * @multi_pf.beat_timer:Timer for beat to keepalive + * @multi_pf.beat_area: Pointer to CPP area for beat to keepalive + * @multi_pf.beat_addr: Pointer to mapped beat address used for keepalive * * Fields which may change after proble are protected by devlink instance lock. */ @@ -146,6 +150,10 @@ struct nfp_pf { struct { bool en; + u8 id; + struct timer_list beat_timer; + struct nfp_cpp_area *beat_area; + u8 __iomem *beat_addr; } multi_pf; }; diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp.h b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp.h index db94b0bddc92..89a131cffc48 100644 --- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp.h +++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp.h @@ -64,6 +64,10 @@ int nfp_nsp_read_sensors(struct nfp_nsp *state, unsigned int sensor_mask, /* MAC Statistics Accumulator */ #define NFP_RESOURCE_MAC_STATISTICS "mac.stat" +/* Keepalive */ +#define NFP_KEEPALIVE "nfp.beat" +#define NFP_KEEPALIVE_MAGIC 0x6e66702e62656174ULL /* ASCII of "nfp.beat" */ + int nfp_resource_table_init(struct nfp_cpp *cpp); struct nfp_resource * From patchwork Mon Jul 24 09:48:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Peens X-Patchwork-Id: 13323888 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AEF7EDDA3 for ; Mon, 24 Jul 2023 09:50:52 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2124.outbound.protection.outlook.com [40.107.243.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 138FA524B for ; Mon, 24 Jul 2023 02:50:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ecddcKqQMO8pD5W0FzwLx9/xGUskgCm1A+2IqGuB8XJES0hX1qKpVnWOW4wZyyMhHF/oYxFTLqA+M16WYVAosPW45zBksIr3Q2IKrzrQaON/Tdc4IHSHCwrs4Ab4fbB4jThQHhSUQs/cQRNch04B9zW9203tMfxVwRe9x4SXw84PnTuw26SMQ8/whTsDsCVsyg71n4llmdiONnWds0VZQ9P8cUOoM+bkaIeiVMk3/0MmMkKZAxen7X7Ps+CovU4U0UVAdO0NlobDdgMxHHssxoNEyDHV0OmR70gil5PPRorETvkGDte2uixHiuKgUQceJrw2DRqBEDZzedLx7AuqZQ== 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=xBaCd1M8cGniBmbrxUKvcUgFyV0fqOdb+LDNHqazl/w=; b=ZsyiphrVYmHKHwpjabLFnAnyjaSmiPiRKB6rFTrfie8I3WalBQzFLc6pHOUFs89gQKB7eKE9UP9WIV2C6bDrGtk3zgIXrkhZ7ISUTyIVU4BGK3I3SKZqBgfrsCoOqYxRNN4fkrfvTD1IUqbZwky8tol3meQzOyK4Mq4SycZV5GGDbwerh6krPre/Dauniy8Lf27msiLWrvgGRnK1ayRsI3GiFwjTaRdO0HvhNwQd8+1tVkqkSYUaFWbmnUt1kZuCcNvin6EUMb456CuU2HiEvIkwi0AI0oMC4ntTfmZLiS4pFUNYNShO7HHPAl2g3G33X6HLPx1g//WF7d0hTb2Kdg== 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=xBaCd1M8cGniBmbrxUKvcUgFyV0fqOdb+LDNHqazl/w=; b=iajXpYhqhdlvtAQP5avlf3G7CKBhGP/cFPJYa1e0vlAB4RRCj7ab2/MgBiTWXccVRbEV3lqUHzvmq2CoCJWQ8CsJVE7pgPRllVi75J8VHefz8M5WrgT+maDa6gSGSWoariISiHXnEp0lG0qdnwnYKa1XLw2u19bJxVga/CCppbA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from DM6PR13MB4249.namprd13.prod.outlook.com (2603:10b6:5:7b::25) by PH0PR13MB6020.namprd13.prod.outlook.com (2603:10b6:510:fd::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 09:49:12 +0000 Received: from DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::c131:407c:3679:b781]) by DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::c131:407c:3679:b781%5]) with mapi id 15.20.6609.026; Mon, 24 Jul 2023 09:49:12 +0000 From: Louis Peens To: David Miller , Jakub Kicinski , Paolo Abeni Cc: Simon Horman , Yinjun Zhang , Tianyu Yuan , netdev@vger.kernel.org, oss-drivers@corigine.com Subject: [PATCH net-next 06/12] nfp: avoid reclaiming resource mutex by mistake Date: Mon, 24 Jul 2023 11:48:15 +0200 Message-Id: <20230724094821.14295-7-louis.peens@corigine.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230724094821.14295-1-louis.peens@corigine.com> References: <20230724094821.14295-1-louis.peens@corigine.com> X-ClientProxiedBy: JNAP275CA0020.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:4d::20) To DM6PR13MB4249.namprd13.prod.outlook.com (2603:10b6:5:7b::25) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR13MB4249:EE_|PH0PR13MB6020:EE_ X-MS-Office365-Filtering-Correlation-Id: 3cc9b96a-b9ea-4e7a-8e88-08db8c2b3bfb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tP8H2o5oSA4dsiLN94Qsxv1Nq6XVuzOQoY6fAGkCvjai7hXHg0Yi4pSSf1TIq/TRbu4uyuXKKSqS1R+mSYS6JTRQErmmicJXgSYSskaRGDhBvk0EuhiXz2mBsvIMiJ476YWBzCV/l8aFfbLMPa2kcy/tLB9sa0Kka7gXOAwjoI79zRTQvTWymg0SOYzJYgqAU02vlGrSCVR38HWOcQEPW8qAvQ8mVyC3NWsZilUkL+g58M2UAAFo/RB3gNMv9JAfhNJhJf9ZwutM4T7a5nEJZcEo9Vnhb5s3Uc9WkHbqsUFCwPdIvFC6+0EtnfK5o7vx5sU4K6WZZqSbTqOnBjcpE+jduWv5tMUaTwcTQUAKF6bt4o0IpJtmsMYFMW/8/x6Y//hh6Af+GFQkvmaHxdadfWNgGi/0k000jX98tZYcRbdQI6F+fcC3UBnVuL6LKvctGynJx51nyBQ/L32xjR88IDos89zx/OuLe4aJZW8brcDoWe61ftTIHEw1OhJn5o34l341i/sm9IBrMpfbOCHaEFwjlCZCLwCiHoOyjW4NeqPLoXZckkzgcF5WVp/oNL/mYzjwbFDegyZY2c4je9s9xvtL34d7oTBavRZK47QhIdCzKN6hf2Q1xenBzCiHap7zRhenBB4wnWYQ0qPo5790Jy6XJO3GE/vTCuTf2T71Zjg= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR13MB4249.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(396003)(366004)(39840400004)(136003)(346002)(451199021)(1076003)(26005)(8936002)(8676002)(316002)(6486002)(52116002)(86362001)(54906003)(107886003)(36756003)(38350700002)(38100700002)(186003)(6506007)(5660300002)(6512007)(41300700001)(66556008)(66476007)(66946007)(4326008)(110136005)(44832011)(2616005)(66574015)(2906002)(83380400001)(478600001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?BHqfkLEqGhqoQaHur9hRMMZZ50aD?= =?utf-8?q?fjwfKAHFiZoBKRH08Pp61BUWiNugEQIowZh81380kmnpk5frSuCzqDAjOl57VLDkF?= =?utf-8?q?vAhnoJ2q3UHXZGkWcDlmTZ0qC3MtkZoWZL4eOSzG2IHwuDTN7q+WOtgudmkmfAWzn?= =?utf-8?q?WjrdIQHTyqxoRT5NN0UNVWiA8wLJDuFCRcQ20s3t8t9B5qdOdOU2jLuK0kVk9tPLH?= =?utf-8?q?ej6z4OT2ywCJjhjkeKnUeoBcU/62vAxgY7M8JmiL3F1CS6JaSeq5Xd/6S48JHC1Vq?= =?utf-8?q?7UKAhqSuC58HIbhOgu2gfbrDcszK9RgLANevIMOzaRUryuLLyj4zHdut3hCFvn8LR?= =?utf-8?q?q6m55r4+oW+ZKz2KdDh/L8Ey7iDczCe15P7IXnsYcfrghfVN5EEPNXlbo6SXSzTBY?= =?utf-8?q?VSXCS6/9Y6gU83IlFF/RoQWtAldL5f3TtNicIppkJQXIBxoe7SM8aAkeWbH9jgILU?= =?utf-8?q?GraAOmLiNlCeAD+yvT5/ao8outdx2Q4m/T+Ym9yTnnl2dT/DFHkJI0gDOE1U3FZUy?= =?utf-8?q?ktA2R9ejj3widVkiKPZCITxrUUcO7nhTGYUUNRY3yYkoiyX1hRkcB14A3vOo1KN7m?= =?utf-8?q?/Jhh67CQVzUooet7iMZiBh1KQbYUO0wsJown9v/kn1Klbuw0tq6jblifEpPvTJTtj?= =?utf-8?q?ofbazgV0+VKAmtyCJp+c87UyDF0gIIrSYEG2e0lOGtMN+PSHgWqQADkIjzQ7OR9xH?= =?utf-8?q?3XMZzxlek1Zl02cYNyBwndIjXehpdRczqKQ9xC/MtOBuuXlaYIsQTDiNScH8jMQL/?= =?utf-8?q?QWvJnE++F33WR3yI950vQM6ZtBTy3TFg7VmXsmrwBlV3gLLzEI6ITzpQQnBF7XXhu?= =?utf-8?q?YiUWknzCOoH32haKQzRwMw8Gj5vIIEjxk/ey3mEyQ8FzWVCXHi94NngdWGXUAhmEz?= =?utf-8?q?mYWXgsSQpIZhmopVbtbsNyn9UL/bt4wYrlmXgbifo5E6I6nqpG0t2DcFkHofyo5fS?= =?utf-8?q?rrv5hAJjGdtGxIDlSTqrKSjCmi9xk2nSstBgGHoYuNcYfgM7sQrBqXKwLP/kVb9V+?= =?utf-8?q?ZLeHBB9jAnf0zYfTGWPTVerKDXBCfC5Vvs+Jg/aFXUHhfJxAtmKWmyyYDDYP960qw?= =?utf-8?q?vLIB9CRGiv6d+/mVHdjWWbhpjGwo6T4VoQ8MRrRl4EEH/fe8dPU/XwTMj4hLza+mN?= =?utf-8?q?lwJPCLQEADjdzt1h/pdZzK6dFQOyLlXpeIgOBd8ZUZ242dOU4LC7DfcN5hQno9MlO?= =?utf-8?q?pXiM/7md1DignVuVvUvik5BL01zMbOy+VPKr16WQbKIgXK+NKkRaEKLpuuUcWVKGH?= =?utf-8?q?dXS31HhoCe+n0aClkXJL66PYk1rV8AdC5A9XFpYcof+ZcRakw6hem7eX+FDxlOgsS?= =?utf-8?q?7MisD39JZFAXfvYkiprn+bnyHZZd1s3q6FpEea2wc32H4Rdsw2JoUKSBC5/GVZQJ6?= =?utf-8?q?yE2JRNq83mGGq4rBDoOYVYl1ysEOcVB7hIbBsStkxXlfsUGxgCfOdFzn+LaOpMVmb?= =?utf-8?q?PEs8gyxfJefoc3fTQjwi14vCyQF+CAF+5oqgrSLVEWh0f5VSYV+/OV0X/CuFcAkvI?= =?utf-8?q?05lQRff/AY24iDOz9+V8fopmSFR/30JyWA=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3cc9b96a-b9ea-4e7a-8e88-08db8c2b3bfb X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB4249.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 09:49:12.1900 (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: FyUQfQBtzQmw+TiQ45zGVm63SrGdoGt+/FFSu4byZRmJQEpP/XOH314tXheuM/GN4E9XKi/Pj7k6Di1tM9jkX8vLR8uR2oOTFfk9ea8CESI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB6020 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Yinjun Zhang Multiple PFs of the same controller use the same interface id. So we shouldn't unconditionally reclaim resource mutex when probing, because the mutex may be held by another PF from the same controller. Now give it some time to release the mutex, and reclaim it if timeout. Signed-off-by: Yinjun Zhang Reviewed-by: Niklas Söderlund Acked-by: Simon Horman Signed-off-by: Louis Peens --- .../netronome/nfp/nfpcore/nfp_mutex.c | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_mutex.c b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_mutex.c index 7bc17b94ac60..1b9170d9da77 100644 --- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_mutex.c +++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_mutex.c @@ -343,6 +343,7 @@ int nfp_cpp_mutex_reclaim(struct nfp_cpp *cpp, int target, { const u32 mur = NFP_CPP_ID(target, 3, 0); /* atomic_read */ const u32 muw = NFP_CPP_ID(target, 4, 0); /* atomic_write */ + unsigned long timeout = jiffies + 2 * HZ; u16 interface = nfp_cpp_interface(cpp); int err; u32 tmp; @@ -351,13 +352,21 @@ int nfp_cpp_mutex_reclaim(struct nfp_cpp *cpp, int target, if (err) return err; - /* Check lock */ - err = nfp_cpp_readl(cpp, mur, address, &tmp); - if (err < 0) - return err; + /* Check lock. Note that PFs from the same controller use same interface ID. + * So considering that the lock may be held by other PFs from the same + * controller, we give it some time to release the lock, and only reclaim it + * if timeout. + */ + while (time_is_after_jiffies(timeout)) { + err = nfp_cpp_readl(cpp, mur, address, &tmp); + if (err < 0) + return err; - if (nfp_mutex_is_unlocked(tmp) || nfp_mutex_owner(tmp) != interface) - return 0; + if (nfp_mutex_is_unlocked(tmp) || nfp_mutex_owner(tmp) != interface) + return 0; + + msleep_interruptible(10); + } /* Bust the lock */ err = nfp_cpp_writel(cpp, muw, address, nfp_mutex_unlocked(interface)); From patchwork Mon Jul 24 09:48:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Peens X-Patchwork-Id: 13323889 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F719DF4B for ; Mon, 24 Jul 2023 09:50:56 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2122.outbound.protection.outlook.com [40.107.243.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9577C30E1 for ; Mon, 24 Jul 2023 02:50:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=at3ZOR3UzeYjY03ZwRK7wy4jove9kNYYygwFUYee3LvL4chlHycTxEg/GCg0UVG3Kvx3ocRr31JWI12PiGXiLpSd3wKRaym6lisWAhVgF9M761UbAFYev06OCvS68A5aLxib2dwoF9+FzuKzA2fMBKl1mRRXMfeSAvCRYOC3NFTz2CTPWiRzfCKUEB8Sn++VzkaK5hWwTDvLXI4g1+pOn5n4tSzyw+o+FoT6eMlPrQfTyoEuQ0kCQq9IdfQeKZ+IfwP++kubPCSpfvXZCReBwIt3q4sJR1911X5PMgRKCge1JqECaebP1Y20NeCZV5UihEUqEewt2TmFelMsa7aJSA== 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=FBD580DaiUnSfTUN87A8oZ7d1leIQpq4MQYDC0Ch+CU=; b=W63ZnyhAWPYJvQDI2ZckfhANmgPYxnDfsxtmE6TMckp6uMA/i/0gLbHlDMQhEAHvDtvsBkTA71gCysBF1ksIjm8WtIUUtsFma56yD8kepzgeFZywXmRzJfR8u0X61PpNuH2G1w7DwNivon67iOAenkY4Z07SnPg6KCycw8mjIY1hrxVV2MpYgqyfQVUV4HgyRpizlfJQv3MH3yDF8oq3QwVm7d6bZ2iqJHtgQ3wW5yqsIZopxVi2TQoqezMEBZxNKuvTxF6w1LB4uU0vwayBDcTVcb86kZkE3AE2bH5d78csi5X2sFA/ksn+T+anS3wTyuvjkvLPR66ytlwnAodvSQ== 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=FBD580DaiUnSfTUN87A8oZ7d1leIQpq4MQYDC0Ch+CU=; b=sEFYFNixFcga/gZkO02P2wWse3+xlGCM5UVJjTEldrT3oOJK8iejj9jwIna8r7GgsbzvGbE20qJpzi6KQ/+/YT2jfXWR0BsNSBamzQ5evaQwmKARFuA5LGuTybUnAifLxOG9vYSZ+kqVyicCGfngcJ2+caF8NBfOxNw3WNg+x7I= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from DM6PR13MB4249.namprd13.prod.outlook.com (2603:10b6:5:7b::25) by PH0PR13MB6020.namprd13.prod.outlook.com (2603:10b6:510:fd::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 09:49:15 +0000 Received: from DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::c131:407c:3679:b781]) by DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::c131:407c:3679:b781%5]) with mapi id 15.20.6609.026; Mon, 24 Jul 2023 09:49:15 +0000 From: Louis Peens To: David Miller , Jakub Kicinski , Paolo Abeni Cc: Simon Horman , Yinjun Zhang , Tianyu Yuan , netdev@vger.kernel.org, oss-drivers@corigine.com Subject: [PATCH net-next 07/12] nfp: redefine PF id used to format symbols Date: Mon, 24 Jul 2023 11:48:16 +0200 Message-Id: <20230724094821.14295-8-louis.peens@corigine.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230724094821.14295-1-louis.peens@corigine.com> References: <20230724094821.14295-1-louis.peens@corigine.com> X-ClientProxiedBy: JNAP275CA0020.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:4d::20) To DM6PR13MB4249.namprd13.prod.outlook.com (2603:10b6:5:7b::25) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR13MB4249:EE_|PH0PR13MB6020:EE_ X-MS-Office365-Filtering-Correlation-Id: 1266545c-e27e-4837-e445-08db8c2b3e00 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /h2bcB0If6pBrNTMXrzXErejL2v0wq2bgEEkp2LMJHkOMJs/7h/adElU2cFsHgXuO7gppSkzgEVJ5g8JGpO0uE9RQz93jivVY3MoNxU8vTaQXmKQ/P9tX4CF9VciZqU+O9jZnToeZ0D3bGuj8TrZCq1wPQsLzaa437d/LNCXWn0THGIhdPKJlZzDNEVd6QWQnaf235nICjBoJjM//APZlJVazJrk8TDUaki70l4Ea9dpYNUCcKa7GfkO8n9ztmjQf//7FK9YFp97X/ncB4RxLOevB19f00EOURUkkqpeepP/H5+zjAfGwWyQUsphq6y3yOfldlyaqprT1T8NbzYz4YBeGwO0KecTkytgDGEB0YoCAFUeQlWfiaYBzWp/zENom1aGkY7z1zg7M7RvdrFk7/EmYP+5KkM7SwG88YR+edxUYrGEpce7CZgI3IwoIMjN81nfIAXEVkowFOdrmQsTf5+eGcTtiFrQJd6Lxjel/2fUF8axTH0t9Nf8dS/2p8PF/tLzJ9HjCcvwtcqZVBvRmyz99Y3pYzwt1OIGzCpSOqPCuIeH82IXVAlnjfBMAJhItfxEmsHpcVO6evg49PMfNPUQUkml/VjeW54k7azGZ3Oj4wBVxsIF4m0P/K54+4+Lp9ZnGdQ9u/IrIMK46bjoQPgyUlOGdswVu+u7nUyTLV0= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR13MB4249.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(396003)(366004)(39840400004)(136003)(346002)(451199021)(1076003)(26005)(8936002)(8676002)(316002)(6486002)(52116002)(86362001)(54906003)(107886003)(36756003)(38350700002)(38100700002)(186003)(6506007)(5660300002)(6512007)(41300700001)(66556008)(66476007)(66946007)(4326008)(110136005)(44832011)(2616005)(66574015)(2906002)(83380400001)(478600001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?22fN1hkr6YBJhVRSDJz6EwhP7q4X?= =?utf-8?q?/fOjllesc9JU/FiQe92Hr4hfovB5zYnsp+MBDvueC+aW5LeCcdIR3CTGnFPg4BAOp?= =?utf-8?q?fL/fF54zbm8yjoD5hEOPgaVUhja1JdVcy9nYYUy27RudptnBfqf1AhQoJDhK2eGPH?= =?utf-8?q?+YbOi8ZdMfwBIB0lXayfqCFa0We42ZvQdhHnL0tFBR6LlNHdS1K4RUFQfF3hAUx8F?= =?utf-8?q?AbS5dspFk6NeztEVr1duEqSi/lqM+NC5xfbBVcaNs3pi6NhcGdrMRVzpfxtgXXuhu?= =?utf-8?q?wxnlWBfsMP7W81HIf/xKWFKcXNFwi7yJVg4q5+yNPHFhuGCScFUtkAH30gdy0W092?= =?utf-8?q?FmDPYApm+qF8mH0fwdmXloSKJt8oKcSjwqmZ56kuh4PzMo/ku0OIOldJusXtb8dWv?= =?utf-8?q?kUnUzuXHn6LMHp0O81F2JbLO57L4+homgAQ4fFfnsTrcJ52i+jPKKF1TJAjnYKMTh?= =?utf-8?q?hxNe1h48pPAc44+gZ27Lc0AVL2tMq+6xj797r0yPrrPAZuH0VFdSbwHiMfhlz6FSJ?= =?utf-8?q?EyKxguWhYO7y1Y1F/F6LuBKfPkPS3GlourlOVy7a7lE7ckPgDaQbxDuWgrpOdxHSP?= =?utf-8?q?R0Nc/FgLPG1l2cmQ+MMMtiv0ABirrAWeNGGWbRS2Wx47dNKSXMCO/LXe0f/ldtH7k?= =?utf-8?q?MbM+1gHt6RLX8ecmlWFeCRk6RZcgWedaDvnmRJ5yHX5vJffeG+BVtmqmjJ7FkUF+u?= =?utf-8?q?7kKAnoLxro0GjXmCbpzdGwZq5cTOpWtjASlzMDFnMOnPWVe0rO/eYGjdgtwqftYfr?= =?utf-8?q?8BX+6+o2ZvaRCoPHpEZBc9xOfMK4ExlIGIOKDTq/Z83v7Iu2Bkwvvl3hCLMgv7ex0?= =?utf-8?q?51Hp52UhrDKg/jeL4p6gD1mgHeZ6XbJtMDpO5Xfe5aQ351m01LDfrmBTP75kgjoLW?= =?utf-8?q?5VnknAdoof2XLZfmKYCP9Cb+8er0YNXbH+C+95ivTVIBo/T9zNyj31lIn4LvwhSGm?= =?utf-8?q?E6iTu/FzSKZPicf2FFVb/95vgxEXFIM/na8CyBYMxDw6EcEhj38U7tJFxVFLZRJDC?= =?utf-8?q?LDXetMFeqKfC/BmiCUrPr4zoWKZrFB5and2FLUKWPNWOgU/4N8VmWIti5ecDn/rRF?= =?utf-8?q?t5rraqX0DmYLcHzKwoBEs0pv0WmeVhbdetPdYDlUlegFAYcKJjNkzZtVicI3QsDAS?= =?utf-8?q?13fS0fVD2l8u2s2AAVvleDqsubrhw/0xWPs7i2bi2mE1sA/b7F//2I10R069G05Gj?= =?utf-8?q?MeXQ0oE8y+AYlYscFDE/ygQXTMAVhENbAL/T/gghUe6P+cst/etyIewByzqisi63M?= =?utf-8?q?Xp0OnC9tyPaq1EtT4YtjppZGYQHYDCPIZfUqB8/irTCN3DnY6PtfPa6WHeXu4ny9H?= =?utf-8?q?mXwxXHjQ/+gnAnRHTuAc2oT7wC9S2JSnSAFdg9UcjmEIRemlmNxzkLiHGf/6MB5Tf?= =?utf-8?q?8WtIkEKvRmiIiFu/aBoPNlEvZDrIxCCd6B22/yuogZqlivOOu4cO72PdXfa7TB2dX?= =?utf-8?q?2ZM+I5IEKOWAxyccTruGMB8ytQ5LP6v45UX2daviJqCbSdK009gCGpn+gPF8K8VEU?= =?utf-8?q?g6sbx2g54zQw8BU6Gav+21a/TGndpwvTaA=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1266545c-e27e-4837-e445-08db8c2b3e00 X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB4249.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 09:49:15.5682 (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: 4EKZ+6sfAQlZ8c0q7lF9eM7suF7Z5CakvjedqjRYLQh57rPvDhQaLMLlYqXNasVOLk8IZVusWBx5sne1xNkWapGe49JvF97O5yHzkFXPeTo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB6020 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Yinjun Zhang Taking account that NFP3800 supports 4 physical functions per controller, now recalculate PF id to be used to format symbols to communicate with application firmware. Signed-off-by: Yinjun Zhang Reviewed-by: Niklas Söderlund Acked-by: Simon Horman Signed-off-by: Louis Peens --- drivers/net/ethernet/netronome/nfp/abm/ctrl.c | 2 +- .../net/ethernet/netronome/nfp/flower/main.c | 2 +- drivers/net/ethernet/netronome/nfp/nfp_main.c | 18 +++++++++++------- drivers/net/ethernet/netronome/nfp/nfp_main.h | 2 ++ .../ethernet/netronome/nfp/nfpcore/nfp_dev.c | 2 ++ .../ethernet/netronome/nfp/nfpcore/nfp_dev.h | 1 + 6 files changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/abm/ctrl.c b/drivers/net/ethernet/netronome/nfp/abm/ctrl.c index 69e84ff7f2e5..41d18df97c85 100644 --- a/drivers/net/ethernet/netronome/nfp/abm/ctrl.c +++ b/drivers/net/ethernet/netronome/nfp/abm/ctrl.c @@ -362,7 +362,7 @@ int nfp_abm_ctrl_find_addrs(struct nfp_abm *abm) const struct nfp_rtsym *sym; int res; - abm->pf_id = nfp_cppcore_pcie_unit(pf->cpp); + abm->pf_id = nfp_get_pf_id(pf); /* Check if Qdisc offloads are supported */ res = nfp_pf_rtsym_read_optional(pf, NFP_RED_SUPPORT_SYM_NAME, 1); diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.c b/drivers/net/ethernet/netronome/nfp/flower/main.c index 83eaa5ae3cd4..565987f0a595 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/main.c +++ b/drivers/net/ethernet/netronome/nfp/flower/main.c @@ -378,10 +378,10 @@ nfp_flower_spawn_vnic_reprs(struct nfp_app *app, enum nfp_flower_cmsg_port_vnic_type vnic_type, enum nfp_repr_type repr_type, unsigned int cnt) { - u8 nfp_pcie = nfp_cppcore_pcie_unit(app->pf->cpp); struct nfp_flower_priv *priv = app->priv; atomic_t *replies = &priv->reify_replies; struct nfp_flower_repr_priv *repr_priv; + u8 nfp_pcie = nfp_get_pf_id(app->pf); enum nfp_port_type port_type; struct nfp_repr *nfp_repr; struct nfp_reprs *reprs; diff --git a/drivers/net/ethernet/netronome/nfp/nfp_main.c b/drivers/net/ethernet/netronome/nfp/nfp_main.c index 489113c53596..74767729e542 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_main.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_main.c @@ -69,6 +69,13 @@ static const struct pci_device_id nfp_pci_device_ids[] = { }; MODULE_DEVICE_TABLE(pci, nfp_pci_device_ids); +u8 nfp_get_pf_id(struct nfp_pf *pf) +{ + return nfp_cppcore_pcie_unit(pf->cpp) * + pf->dev_info->pf_num_per_unit + + pf->multi_pf.id; +} + int nfp_pf_rtsym_read_optional(struct nfp_pf *pf, const char *format, unsigned int default_val) { @@ -76,7 +83,7 @@ int nfp_pf_rtsym_read_optional(struct nfp_pf *pf, const char *format, int err = 0; u64 val; - snprintf(name, sizeof(name), format, nfp_cppcore_pcie_unit(pf->cpp)); + snprintf(name, sizeof(name), format, nfp_get_pf_id(pf)); val = nfp_rtsym_read_le(pf->rtbl, name, &err); if (err) { @@ -95,8 +102,7 @@ nfp_pf_map_rtsym(struct nfp_pf *pf, const char *name, const char *sym_fmt, { char pf_symbol[256]; - snprintf(pf_symbol, sizeof(pf_symbol), sym_fmt, - nfp_cppcore_pcie_unit(pf->cpp)); + snprintf(pf_symbol, sizeof(pf_symbol), sym_fmt, nfp_get_pf_id(pf)); return nfp_rtsym_map(pf->rtbl, pf_symbol, name, min_size, area); } @@ -803,10 +809,8 @@ static void nfp_fw_unload(struct nfp_pf *pf) static int nfp_pf_find_rtsyms(struct nfp_pf *pf) { + unsigned int pf_id = nfp_get_pf_id(pf); char pf_symbol[256]; - unsigned int pf_id; - - pf_id = nfp_cppcore_pcie_unit(pf->cpp); /* Optional per-PCI PF mailbox */ snprintf(pf_symbol, sizeof(pf_symbol), NFP_MBOX_SYM_NAME, pf_id); @@ -832,7 +836,7 @@ static u64 nfp_net_pf_get_app_cap(struct nfp_pf *pf) int err = 0; u64 val; - snprintf(name, sizeof(name), "_pf%u_net_app_cap", nfp_cppcore_pcie_unit(pf->cpp)); + snprintf(name, sizeof(name), "_pf%u_net_app_cap", nfp_get_pf_id(pf)); val = nfp_rtsym_read_le(pf->rtbl, name, &err); if (err) { diff --git a/drivers/net/ethernet/netronome/nfp/nfp_main.h b/drivers/net/ethernet/netronome/nfp/nfp_main.h index c58849a332b0..7f76c718fef8 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_main.h +++ b/drivers/net/ethernet/netronome/nfp/nfp_main.h @@ -208,4 +208,6 @@ void nfp_devlink_params_unregister(struct nfp_pf *pf); unsigned int nfp_net_lr2speed(unsigned int linkrate); unsigned int nfp_net_speed2lr(unsigned int speed); + +u8 nfp_get_pf_id(struct nfp_pf *pf); #endif /* NFP_MAIN_H */ diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_dev.c b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_dev.c index 0725b51c2a95..8a7c5de0de77 100644 --- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_dev.c +++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_dev.c @@ -19,6 +19,7 @@ const struct nfp_dev_info nfp_dev_info[NFP_DEV_CNT] = { .pcie_cfg_expbar_offset = 0x0a00, .pcie_expl_offset = 0xd000, .qc_area_sz = 0x100000, + .pf_num_per_unit = 4, }, [NFP_DEV_NFP3800_VF] = { .dma_mask = DMA_BIT_MASK(48), @@ -38,6 +39,7 @@ const struct nfp_dev_info nfp_dev_info[NFP_DEV_CNT] = { .pcie_cfg_expbar_offset = 0x0400, .pcie_expl_offset = 0x1000, .qc_area_sz = 0x80000, + .pf_num_per_unit = 1, }, [NFP_DEV_NFP6000_VF] = { .dma_mask = DMA_BIT_MASK(40), diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_dev.h b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_dev.h index e4d38178de0f..d948c9c4a09a 100644 --- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_dev.h +++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_dev.h @@ -35,6 +35,7 @@ struct nfp_dev_info { u32 pcie_cfg_expbar_offset; u32 pcie_expl_offset; u32 qc_area_sz; + u8 pf_num_per_unit; }; extern const struct nfp_dev_info nfp_dev_info[NFP_DEV_CNT]; From patchwork Mon Jul 24 09:48:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Peens X-Patchwork-Id: 13323890 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63387DF4B for ; Mon, 24 Jul 2023 09:51:08 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2071d.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe59::71d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24D7730C4 for ; Mon, 24 Jul 2023 02:50:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P67L3GTkP5uAk7wIKW/wjpXBtvYZe006o96iZ+DC71Itb5vUBnkBDA/7VJOaaCKT0V3PMxNvflt6hx/MMqmnBggEcu8WTY3piWJRlITqlL8FJQlIQGWnCHz0MoE4yKOi2kDLeHw5BcfnFJVQW0ulQdsYmqnPYFPCJyEqq2knv0pI2Fm7KCXUlhRz3WARMC2ICIyqfExvVA+GuOn63iKTTb+Oh8heLaI0Os/pnUig28Gv9dTqLAKnC7ExTNtHnxKFHA+joUZgi0U513zkILGynoucVRWK3T/mcEIvpM2ZM9z2IMhpAQuPwy9yGOQAm4Z5U4ermvyA3zZXIvnuAk5EEA== 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=RVUFfMqVp60K93bqETr9AAhjfji0GkRrh5Ikr8sz7F8=; b=Mxj6xBGWaxh/MZA4qcu2bpmZY4XC9aKCNvU9XI+LuyOxeKjKVPkLK6ulvqcF+Nh3cYEatlT86K2uDARLkXee6qmKKsE14ppf0AB+AUPY5UEu+0PWtsppOaAEt7rSu4X4TykvvPX0pc8JhBfwd4ifFVq2QhtsIYLwCDSXhEPH11T1n+t7WGHucLe9crYAvo48naSJY9MH6KbaJqgh8xIg2vw60djDXJ8NcmJLsDdqRBMSG0qSFeX1JMCchylpqLx43DjXCfSuW+y9uVfnPhYsWW8BP361elx19LXIZjlmfxWbPYKTDCOd7Mpy+PjfYB+InqAlFbYRPx04JvKFoB/P1Q== 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=RVUFfMqVp60K93bqETr9AAhjfji0GkRrh5Ikr8sz7F8=; b=J37oC+1FGxhhRNcIo8BuwjFUTFhFexnnnSvv5+y5ZUqsEMKcbFI4k7ZtOaMyJUOwYzTCbwOIoSWNRwScQAxSqq3o45adpNp4cnUZaSdZnjrt5VaMFZ5jVDJk7XsSUhBBo3ChU87oWXifVo64VcX1eibSOKqQIPmsGvJv/gdB48A= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from DM6PR13MB4249.namprd13.prod.outlook.com (2603:10b6:5:7b::25) by PH0PR13MB6020.namprd13.prod.outlook.com (2603:10b6:510:fd::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 09:49:19 +0000 Received: from DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::c131:407c:3679:b781]) by DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::c131:407c:3679:b781%5]) with mapi id 15.20.6609.026; Mon, 24 Jul 2023 09:49:19 +0000 From: Louis Peens To: David Miller , Jakub Kicinski , Paolo Abeni Cc: Simon Horman , Yinjun Zhang , Tianyu Yuan , netdev@vger.kernel.org, oss-drivers@corigine.com Subject: [PATCH net-next 08/12] nfp: apply one port per PF for multi-PF setup Date: Mon, 24 Jul 2023 11:48:17 +0200 Message-Id: <20230724094821.14295-9-louis.peens@corigine.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230724094821.14295-1-louis.peens@corigine.com> References: <20230724094821.14295-1-louis.peens@corigine.com> X-ClientProxiedBy: JNAP275CA0020.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:4d::20) To DM6PR13MB4249.namprd13.prod.outlook.com (2603:10b6:5:7b::25) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR13MB4249:EE_|PH0PR13MB6020:EE_ X-MS-Office365-Filtering-Correlation-Id: d159dc55-b5a7-4c53-110d-08db8c2b401e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: e698Sj3Nx5f+4VBDjEPl03kjN6fILtznxDzEbGLI4/CPOUSLlmQgBADM/d58sFVvYKuBqgLBoGkAElYzmfAO5QQTtlNeM/03xHoigiloRjI5fleeCFxDoyqPHdHWqrhN5ZcPyug3Yo4fM8K4nz6+H7OIzapvKz8Sh8w6UaWEuTC/1ymOJUoMl/PV4BnP+faYXszqmlFdoDiqOCkadYFEPx9OS/H3Uc0FpK1XVqi9EkABmPvdGCV8zxZJcziDm/mmMutlbkTiOOrXR6RLEZI4YHPsuxFO4xWNG6gsxUH669+DybbPSCVPZdWAjdipCdroq2arqZJLJYOr/a1ImPKTP2sOpHm8usWTCRuaSofkgiegjTOER+NWcAkpMes+tQ9vmmPqntA4Xn1NEliyAB6PXFp4IYCmQsIM/3yIQQ6/xV0fKFSgok4A60lDiBWEFtPpgfpZXXdTiwljXMvI3EwIRNlweDmAfoGIDWoomFd+NEdbfw5aykJxeOM7UhbF9e3YMeY2vw6Ayyv9/eXuaSrb3BBG958K9nShmFJxUi0XfHGlamBWdCrRtjFNNOPqDPs2HFgP7VctWyArUhMwhDROh3kBTVnfGsMQEO4nc5c+338jAT4mB7h2sbdUCJRdYEZJi+LOM86FSpxYbXbKjQGxqSmFSU9ymXnwWAJRv2JIpkg= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR13MB4249.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(396003)(366004)(39840400004)(136003)(346002)(451199021)(1076003)(26005)(8936002)(8676002)(316002)(6486002)(52116002)(86362001)(54906003)(107886003)(36756003)(38350700002)(38100700002)(186003)(6506007)(5660300002)(6512007)(41300700001)(66556008)(66476007)(66946007)(4326008)(110136005)(44832011)(2616005)(2906002)(83380400001)(478600001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?AUxTAV1z71DunT77fc28xD2C+34j?= =?utf-8?q?tVwa3BFjWfn8VWVCYqTgzSIgw1MQEe3YS/w59wtOlk50kNsxZexQEo2FtFpvld2tf?= =?utf-8?q?D27uY3uGhNGQY+NdfGkzArnfQC+AhXkMxa9D+VYtIpRqQraSBKfsEHzbiRTMzwkRe?= =?utf-8?q?qdpgsdKVgHczg2qiLVV4GE64ie7EeZPFhokxLnFwU6D9B6jMPd7S4SDKew6nLN9F0?= =?utf-8?q?gIKlovTzzkDIKPr7ssT+XDtyz4TfOmt73jrjfHQAwHmuQU5fx/mW/mm8jO3OiK0j5?= =?utf-8?q?T5l8E1E0HYFSxInfJVgHDajmFAu7Qnqum7xOph0F6ytEcd5iPlRau7cIoO0uwjVEF?= =?utf-8?q?1En2judcpDaD03DwYbxL3ff9h2Jy77tWfyA0j1MSYtaL+/soTeLNmQ6f8SD0HbjuZ?= =?utf-8?q?MMNQAjmW4/px/u5/CjtGxqUMzIU7gCj4yV1Cl9LWtW1aDm8pgeveyAB3Gl5PM4n7j?= =?utf-8?q?ONF/IruCzxkPbwGS99XvpEp+mkxz0/7iDr9FN7fguj2NH2NIPIOUVIvW2Z8DUMhYv?= =?utf-8?q?TeGT9cmOxzyrrZr174LfjAI9PURlvc9H/AhV5vSmXjpw4q7hHE+jQHKdGJndXq9BL?= =?utf-8?q?7tCemejRlE2psA1dOPLRU07kYVWoxmw4KzvS6v21CxNJOSIlccNtWK6iq99Y0UWiP?= =?utf-8?q?mjUv+eH4U3Fx14n+EUsFmXAGwblWlfVcPK/PH+cI2iFO4Hj/cTj7ZUWhf6fHV0uLa?= =?utf-8?q?+pUaRXv+IAG6dIO1Alhy3kU+Rnr6z9Qc2yxD1SwLzJr5dFJjnMejs+r1GHMHYCnft?= =?utf-8?q?VtY4YPEov3ZDhpJ6e4CBL839SXDbeJfRobmYyd+pfody81TErrWErffwRuIiT8ybX?= =?utf-8?q?kmTQo/wydn2vhPqHCrYXvMsjjcI84S8VbDefDucHHkGe6YEQIU0j7nzjQQdRhWWOD?= =?utf-8?q?Z3n2I6amIzLRKwOV10ckZ2QGhWbitujHMjeISaQVfyeiSfq4QmnkdPOF1Fh5DoqJ7?= =?utf-8?q?XbVGpEYD+DckfEUrFiUEANMDqd6z9XrYlGxJxL1UNkMmpct5CzmaHMA1euBDe/smQ?= =?utf-8?q?bVuCzpwSLiXhy0c5BFP9WQXG+5NCBYlLUDuvOP8PiRoI1qmtKrSrcY8BSz4OLb7mI?= =?utf-8?q?AELqC/PAgNmNJE7NH9XByC+rLYD0UJ27ysiiPnw3dpbue2/DZlmnVR7lQ5blpCHrl?= =?utf-8?q?t+8HNFw9Ebf3SD+LMtAcVqFPhdIUB6NvQPFfqDSxyJfp9jPlcj7+KLwtG9FsKd6+x?= =?utf-8?q?HhxGpc5cFMW9WRlUAWQIbhO6tF94F5jfYx508sQcNBYl8KWP38YkFLaQCHhP8q8cy?= =?utf-8?q?jzZFIn9GUferViB960RLVtVI1M+zQrrQ0g5A1En61tXt4xMnMYqow1hFMR9GnZP+/?= =?utf-8?q?REC9YO9Ko8LkNRcaPyK6CfT5iXuMILmOMkDFholayqseh8L4wNx8HGkOfqX3YbdOR?= =?utf-8?q?JBgLmqZJoSppievuMWqqtIpBER6yDhlXOzTPjmoAh6gz4a11V0Lo08ZEhh8+dRttK?= =?utf-8?q?aUVO+dhRCYpKg8CYT3wHmfdy5WgXaco/HfdikGHL6at50QbQ91ZEHsICNdB9Zt3L0?= =?utf-8?q?kWL89Rgx4dOcW0m9EalfhDyAXwTEQdADMw=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: d159dc55-b5a7-4c53-110d-08db8c2b401e X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB4249.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 09:49:19.3842 (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: dxjBvkfd7bMmXZR9gflIZ42mAnpysfj4aGpnf7RU28j3E6suCNie+QIZ2KeHKvcZtRMgsqdX5hjSkJXM6Ar+MviZ51AsjtU6/RmcEyr9EGM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB6020 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Tianyu Yuan Only one port per PF is allowed in multi-PF setup. While eth_table still carries the total port info, each PF need bind itself with correct port according to PF id. Signed-off-by: Tianyu Yuan Reviewed-by: Niklas Söderlund Acked-by: Simon Horman Signed-off-by: Louis Peens --- drivers/net/ethernet/netronome/nfp/abm/main.c | 2 +- drivers/net/ethernet/netronome/nfp/bpf/main.c | 2 +- .../net/ethernet/netronome/nfp/flower/main.c | 17 ++++++++++------- drivers/net/ethernet/netronome/nfp/nfp_main.h | 6 ++++++ .../net/ethernet/netronome/nfp/nfp_net_main.c | 11 ++++++++--- drivers/net/ethernet/netronome/nfp/nfp_port.c | 4 +++- drivers/net/ethernet/netronome/nfp/nic/main.c | 3 ++- 7 files changed, 31 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/abm/main.c b/drivers/net/ethernet/netronome/nfp/abm/main.c index 5d3df28c648f..d4acaa15629d 100644 --- a/drivers/net/ethernet/netronome/nfp/abm/main.c +++ b/drivers/net/ethernet/netronome/nfp/abm/main.c @@ -451,7 +451,7 @@ static int nfp_abm_init(struct nfp_app *app) nfp_err(pf->cpp, "ABM NIC requires ETH table\n"); return -EINVAL; } - if (pf->max_data_vnics != pf->eth_tbl->count) { + if (pf->max_data_vnics != pf->eth_tbl->count && !pf->multi_pf.en) { nfp_err(pf->cpp, "ETH entries don't match vNICs (%d vs %d)\n", pf->max_data_vnics, pf->eth_tbl->count); return -EINVAL; diff --git a/drivers/net/ethernet/netronome/nfp/bpf/main.c b/drivers/net/ethernet/netronome/nfp/bpf/main.c index f469950c7265..3d928dfba114 100644 --- a/drivers/net/ethernet/netronome/nfp/bpf/main.c +++ b/drivers/net/ethernet/netronome/nfp/bpf/main.c @@ -70,7 +70,7 @@ nfp_bpf_vnic_alloc(struct nfp_app *app, struct nfp_net *nn, unsigned int id) nfp_err(pf->cpp, "No ETH table\n"); return -EINVAL; } - if (pf->max_data_vnics != pf->eth_tbl->count) { + if (pf->max_data_vnics != pf->eth_tbl->count && !pf->multi_pf.en) { nfp_err(pf->cpp, "ETH entries don't match vNICs (%d vs %d)\n", pf->max_data_vnics, pf->eth_tbl->count); return -EINVAL; diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.c b/drivers/net/ethernet/netronome/nfp/flower/main.c index 565987f0a595..2e79b6d981de 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/main.c +++ b/drivers/net/ethernet/netronome/nfp/flower/main.c @@ -428,10 +428,10 @@ nfp_flower_spawn_vnic_reprs(struct nfp_app *app, goto err_reprs_clean; } if (repr_type == NFP_REPR_TYPE_PF) { - port->pf_id = i; + port->pf_id = nfp_net_get_id(app->pf, i); port->vnic = priv->nn->dp.ctrl_bar; } else { - port->pf_id = 0; + port->pf_id = nfp_net_get_id(app->pf, 0); port->vf_id = i; port->vnic = app->pf->vf_cfg_mem + i * NFP_NET_CFG_BAR_SZ; @@ -496,28 +496,31 @@ nfp_flower_spawn_phy_reprs(struct nfp_app *app, struct nfp_flower_priv *priv) struct nfp_eth_table *eth_tbl = app->pf->eth_tbl; atomic_t *replies = &priv->reify_replies; struct nfp_flower_repr_priv *repr_priv; + int err, reify_cnt, phy_reprs_num; struct nfp_repr *nfp_repr; struct sk_buff *ctrl_skb; struct nfp_reprs *reprs; - int err, reify_cnt; unsigned int i; ctrl_skb = nfp_flower_cmsg_mac_repr_start(app, eth_tbl->count); if (!ctrl_skb) return -ENOMEM; + phy_reprs_num = app->pf->multi_pf.en ? app->pf->max_data_vnics : eth_tbl->count; reprs = nfp_reprs_alloc(eth_tbl->max_index + 1); if (!reprs) { err = -ENOMEM; goto err_free_ctrl_skb; } - for (i = 0; i < eth_tbl->count; i++) { - unsigned int phys_port = eth_tbl->ports[i].index; + for (i = 0; i < phy_reprs_num; i++) { + int idx = nfp_net_get_id(app->pf, i); struct net_device *repr; + unsigned int phys_port; struct nfp_port *port; u32 cmsg_port_id; + phys_port = eth_tbl->ports[idx].index; repr = nfp_repr_alloc(app); if (!repr) { err = -ENOMEM; @@ -542,7 +545,7 @@ nfp_flower_spawn_phy_reprs(struct nfp_app *app, struct nfp_flower_priv *priv) nfp_repr_free(repr); goto err_reprs_clean; } - err = nfp_port_init_phy_port(app->pf, app, port, i); + err = nfp_port_init_phy_port(app->pf, app, port, idx); if (err) { kfree(repr_priv); nfp_port_free(port); @@ -609,7 +612,7 @@ nfp_flower_spawn_phy_reprs(struct nfp_app *app, struct nfp_flower_priv *priv) static int nfp_flower_vnic_alloc(struct nfp_app *app, struct nfp_net *nn, unsigned int id) { - if (id > 0) { + if (id > 0 && !app->pf->multi_pf.en) { nfp_warn(app->cpp, "FlowerNIC doesn't support more than one data vNIC\n"); goto err_invalid_port; } diff --git a/drivers/net/ethernet/netronome/nfp/nfp_main.h b/drivers/net/ethernet/netronome/nfp/nfp_main.h index 7f76c718fef8..4f6763ca1c92 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_main.h +++ b/drivers/net/ethernet/netronome/nfp/nfp_main.h @@ -210,4 +210,10 @@ unsigned int nfp_net_lr2speed(unsigned int linkrate); unsigned int nfp_net_speed2lr(unsigned int speed); u8 nfp_get_pf_id(struct nfp_pf *pf); + +static inline unsigned int nfp_net_get_id(const struct nfp_pf *pf, unsigned int id) +{ + return pf->multi_pf.en ? pf->multi_pf.id : id; +} + #endif /* NFP_MAIN_H */ diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_main.c b/drivers/net/ethernet/netronome/nfp/nfp_net_main.c index cbe4972ba104..98e155d79eb8 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_main.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_main.c @@ -141,7 +141,7 @@ nfp_net_pf_init_vnic(struct nfp_pf *pf, struct nfp_net *nn, unsigned int id) { int err; - nn->id = id; + nn->id = nfp_net_get_id(pf, id); if (nn->port) { err = nfp_devlink_port_register(pf->app, nn->port); @@ -183,8 +183,8 @@ nfp_net_pf_alloc_vnics(struct nfp_pf *pf, void __iomem *ctrl_bar, int err; for (i = 0; i < pf->max_data_vnics; i++) { - nn = nfp_net_pf_alloc_vnic(pf, true, ctrl_bar, qc_bar, - stride, i); + nn = nfp_net_pf_alloc_vnic(pf, true, ctrl_bar, qc_bar, stride, + nfp_net_get_id(pf, i)); if (IS_ERR(nn)) { err = PTR_ERR(nn); goto err_free_prev; @@ -707,6 +707,11 @@ int nfp_net_pci_probe(struct nfp_pf *pf) if ((int)pf->max_data_vnics < 0) return pf->max_data_vnics; + if (pf->multi_pf.en && pf->max_data_vnics != 1) { + nfp_err(pf->cpp, "Only one data_vnic per PF is supported in multiple PF setup.\n"); + return -EINVAL; + } + err = nfp_net_pci_map_mem(pf); if (err) return err; diff --git a/drivers/net/ethernet/netronome/nfp/nfp_port.c b/drivers/net/ethernet/netronome/nfp/nfp_port.c index 54640bcb70fb..c1612a464b5d 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_port.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_port.c @@ -189,7 +189,9 @@ int nfp_port_init_phy_port(struct nfp_pf *pf, struct nfp_app *app, port->eth_port = &pf->eth_tbl->ports[id]; port->eth_id = pf->eth_tbl->ports[id].index; - port->netdev->dev_port = id; + if (!pf->multi_pf.en) + port->netdev->dev_port = id; + if (pf->mac_stats_mem) port->eth_stats = pf->mac_stats_mem + port->eth_id * NFP_MAC_STATS_SIZE; diff --git a/drivers/net/ethernet/netronome/nfp/nic/main.c b/drivers/net/ethernet/netronome/nfp/nic/main.c index 9dd5afe37f6e..e7a2d01bcbff 100644 --- a/drivers/net/ethernet/netronome/nfp/nic/main.c +++ b/drivers/net/ethernet/netronome/nfp/nic/main.c @@ -12,7 +12,8 @@ static int nfp_nic_init(struct nfp_app *app) { struct nfp_pf *pf = app->pf; - if (pf->eth_tbl && pf->max_data_vnics != pf->eth_tbl->count) { + if (pf->eth_tbl && pf->max_data_vnics != pf->eth_tbl->count && + !pf->multi_pf.en) { nfp_err(pf->cpp, "ETH entries don't match vNICs (%d vs %d)\n", pf->max_data_vnics, pf->eth_tbl->count); return -EINVAL; From patchwork Mon Jul 24 09:48:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Peens X-Patchwork-Id: 13323892 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20AF7EAF3 for ; Mon, 24 Jul 2023 09:51:13 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2124.outbound.protection.outlook.com [40.107.243.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99D0A55A1 for ; Mon, 24 Jul 2023 02:50:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f6301xw9oCBEWsQ7kmEBiuIVX8rhB2sqGOrAP3/c8JvdXie1F0XVIuhksI+/Hg7hAqgGgTzqWwmh2TlB6pdtoIzp8hhVgygXRYGt7De9/dApVNsDKOQhZ8N5U2+Zy0qRh4/uleJpPw4Sa4b1VloFi3hbZt3lVhjpi1WGe6P/6SoJcK5/ZWvXZT7wQVcJMxAgKUMcmSFPndbdl69ZzkGj83ORBKYXHMCnBz8ua1J1M/poMNF0SvFFgBZ+Tef/bGc/7N/krGjT79jRkqZ4Xtsl42IO5bg12sFAYXeDzyDGVC+isP3/rih5rfnoNecZwmQsQavqlRyE96QRFjnJ7cTMEw== 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=hPhWVA1wbxobRo4QVLXkLP4gZDZuwS/3TwtbdfZbRZs=; b=EqDrEyhl7YdtGz5FX0isH7JdtgSifWghBdhykDM82ywtRKagOzNjuCDU39/7S6FehrXeny/4cLXE2d8i+ZpDaKibx3jUJCIPapwcFLZ6FhOA/OYniPsT8OTYLsmKbdUsAnXdutajUry4wD1alvw5+vCyxrSdi2aPzX3juv/D3FlEwldAXLmWivzmQSHX9L1vE/+sQhr1dtFbh/op/pZqEjSFwvUxH5HLCLtHDUJPL32nmc9/Oxg6Q0TEAOvNiEFDn4iGV+9Lk1HAr8BVdCFqrmKQxxaLCx8C/BKyrE1e4S6aogbifO5WhlZYLQyE/iBgBO/TVfL0PBgZRlzMp+RQ6w== 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=hPhWVA1wbxobRo4QVLXkLP4gZDZuwS/3TwtbdfZbRZs=; b=Kq2xGxHbdB3lk2ap5Qs3eCMGEQMS76Ay+shZ9sEsp6i3uGQD97vvQK1BmhXR/09wbVcle4Kq1nfJfmu9xsp3PuqZQbhiAKKDMhq5/io1tczUv5XqcPIWpRennfoy4NHGGB5HGU13x3Tc6Uem21eKg1Nx87qJv6594nVA7mwE0X0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from DM6PR13MB4249.namprd13.prod.outlook.com (2603:10b6:5:7b::25) by PH0PR13MB6020.namprd13.prod.outlook.com (2603:10b6:510:fd::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 09:49:23 +0000 Received: from DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::c131:407c:3679:b781]) by DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::c131:407c:3679:b781%5]) with mapi id 15.20.6609.026; Mon, 24 Jul 2023 09:49:23 +0000 From: Louis Peens To: David Miller , Jakub Kicinski , Paolo Abeni Cc: Simon Horman , Yinjun Zhang , Tianyu Yuan , netdev@vger.kernel.org, oss-drivers@corigine.com Subject: [PATCH net-next 09/12] nfp: enable multi-PF in application firmware if supported Date: Mon, 24 Jul 2023 11:48:18 +0200 Message-Id: <20230724094821.14295-10-louis.peens@corigine.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230724094821.14295-1-louis.peens@corigine.com> References: <20230724094821.14295-1-louis.peens@corigine.com> X-ClientProxiedBy: JNAP275CA0020.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:4d::20) To DM6PR13MB4249.namprd13.prod.outlook.com (2603:10b6:5:7b::25) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR13MB4249:EE_|PH0PR13MB6020:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e751475-8c42-4f69-009e-08db8c2b425f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rlBP/4bZHsMznW+jyVjJqunKF0OChDyw6x5W2aPtfBVpus4yD1BO8mDKBwfcmIMqvkuhbSFBqeedKIjB1N0P8A0gpG+T43nu5+YISi8eEcrFrSUse+dMFanhsaiwZgHjd6SWwV0ID1zVlQH4q3Rxz7OW6l8mn3jRVixbEJY1M0XDxiuetbtCs8KqmESUGIk0fkqUAAkIr5yWmd0Ve4S8f40qnnz4NBPhvrxLXjEfoRtjXNtmWvpQS0owmtO2qTx5mJoBw54oey5hgjf4bP1enX8TfMhPCdgRmrKOU2STSYIkna3AKfF4R7EwjZrKlJSz58c87hlp90zd4lbLVQlQccadnaIA8P023kE/+sGxzpN8suvJeKKD4PEE0PJJKnq6amucCxY2ZtCTIu8+buIh/jFtR/v0juzjV41ndD0xSubWB4J8vjXwLQzQknpPTNMHEdzIdaaseUYNBdUyOTP8fqwO5rfC5jIc3ArRvc5GQp9sUP9oTXoJR0yruL7pkhvOubV+VRpaiL1YP795xsIAbtEWUityUJiNnW8sF6r9USM/TDwRRF9rXzF1ZNPuoEqE8krHJ1abGfD1NMkCSnEDYD2wJ9FUisXqitwJJhrzehTzXMiHx7PkwATwH/vLTwZAmBOXUvMpmbwBDREvh5tBciHVcwjx7Du0QjhSTntVU9o= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR13MB4249.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(396003)(366004)(39840400004)(136003)(346002)(451199021)(1076003)(26005)(8936002)(8676002)(316002)(6486002)(52116002)(6666004)(86362001)(54906003)(107886003)(36756003)(38350700002)(38100700002)(186003)(6506007)(5660300002)(6512007)(41300700001)(66556008)(66476007)(66946007)(4326008)(110136005)(44832011)(2616005)(66574015)(2906002)(83380400001)(478600001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?KOSzmvcJlio82hx8YS1RuBnpdKOe?= =?utf-8?q?G0a9b+TyxWxhHAcFEuQoBMKx4FtkLsdelLey/hry5WW4qOnnJKKaBkvtrEfp35vwS?= =?utf-8?q?g++chEdXLKZ3qRZKGkRroHwGPKA+OSEmL3LL8zW7af7+wsnXYQp0Oqmicj7gQILLr?= =?utf-8?q?PXc9T4RlmaGTCCe8ap5IVb8jrnwYiNK9oE28ebWqi/Wp+h8X5i7B/+4Z5/UlQKld9?= =?utf-8?q?7vjtv4/qaNhcS+Jq9vy0guCY6um/awLJtzgdVYGoixW1ibDB2vdjmaZgQCXyr6P+L?= =?utf-8?q?kL765Aj8a2mZTrN5rE+7HCHXR115P7QSnkSLMGZ1rFQPSdM7lSrr8VUt56/JbGyS0?= =?utf-8?q?y/33pK5P92pa3s3UsZddf6L9f1TE+J/jJlmWhW7d3gVFAH2yIRYBPDQtSMdtgiZ2W?= =?utf-8?q?WH/MTn3f9zWeviKU1vl/MVTB9OLZVvTAZeEuw7jaSaPgoMhtcH/h80tdcOQcSA5XP?= =?utf-8?q?KOb94F2+2bcRdfW618apJLPKAtTg84JK5Ujws5/7DkiFCk9bwAP1hzlEY4mr4WAvy?= =?utf-8?q?R/Z11ftJq0uyJy88mHA0UoxjmJ3S2x8W/JjpfsG3tI1OwuJlEg4yzixaDRuWE7dFg?= =?utf-8?q?BD+NbdeUVcF5IJTbCIikDKHZY8J9V7PKc4yDE/bgMo3RegGYjGNgc26IWoE9AnyfD?= =?utf-8?q?nNxjITXfvRljRx1CVe4bKJJsN0GUsGEMB8oRtM258QdPGf5B9myPK6VFdKJ24zk6c?= =?utf-8?q?9zY2xy48bfALM95FOJnOgyL17/V2roJDhV9spFt2gDOQ+UyNPr3aRPf811vWiRMLG?= =?utf-8?q?mqry84i8eXUCB6imiovKEvgZ2208rUMUzz7gHZTvk6+Aw1of+WiIVmWW5CxwUAbWV?= =?utf-8?q?+aDpwilzZyBayOz901uUwDk01QSV6Coxhldfm0n1G00B+Y8Xu9o+oVdQSdUlRcyI5?= =?utf-8?q?fhGPC99PTAndh8J+hJVmn1gRd3JdHif16x9qWX9MbEqYanpbfepAMfch1NDAO3bgy?= =?utf-8?q?4ryPcP787B57LlcjJpKMsuCkZxmtXraDasnsdGWs2mMR+xLSVeKRMkr9Z1A6hbrhs?= =?utf-8?q?qZCGFM/5mOHgJPUsFmy/RpmoZ94IYPLKjFoRpbPh84fVfkb2BMhmcdGeubLm3GkmD?= =?utf-8?q?UlFCaP6HnR5MIIfyjxLA0CkliICBMqrzAs/WHOBMIXmifO7gq1hx1/h98GA5BZRwe?= =?utf-8?q?bphxY+xQEABt5yptXJ59wiyW3h965q8Dt6HD28nF0gaUhbb7HUysErnEvIBKt5m2o?= =?utf-8?q?M+vjvjQhi49JYtsrw9FWYjc/nnAO86U4UChiCnCMVg8zKvdnnbPdC9dMPF//GOtnz?= =?utf-8?q?wwyfGSeyh0MSJDRL6/oFF7EIIskP+63NCet9LETWY150scTorUQnO/iHtXaCLkgSa?= =?utf-8?q?mqrHEbdi1qtSVtcJbZYmhOwp7natKFPtKL2TzCvxk+WBwYfkx9ietXqFSkLoSOVJF?= =?utf-8?q?BMGMsCGOI6vTyoaoFlh/FpR3MxS2bVNNjZlQMO59LJyyJTHVNjZz4GZVAde+8rqNw?= =?utf-8?q?+RdRrxq4rYXMzmuHJnYftX5Vwbb9l8RchiIkj9LoHr+hKiAYKmDX6z1INTR6NmPQG?= =?utf-8?q?qwIvgFup0izKm1DfTq6e7JYRcixUQqcwDg=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7e751475-8c42-4f69-009e-08db8c2b425f X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB4249.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 09:49:22.9137 (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: AxRrFFahvf3x9m7KEqDo3GIeNafOsbGENpWyULiTDGuItklaicy3xxYk5lzvkTG7qlTst54UTxAlfleQIVXmDQg8WA9NafRI45ONQdOdDJs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB6020 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Yinjun Zhang For backward compatibility concern, the new application firmware is designed to support both single-PF setup and multi-PF setup. Thus driver should inform application firmware which setup current is. This should be done as early as possible since the setup may affect some configurations exposed by firmware. Signed-off-by: Yinjun Zhang Reviewed-by: Niklas Söderlund Acked-by: Simon Horman Signed-off-by: Louis Peens --- .../net/ethernet/netronome/nfp/nfp_net_ctrl.h | 1 + .../net/ethernet/netronome/nfp/nfp_net_main.c | 129 ++++++++++++++---- 2 files changed, 100 insertions(+), 30 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_ctrl.h b/drivers/net/ethernet/netronome/nfp/nfp_net_ctrl.h index 3e63f6d6a563..d6b127f13ed3 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_ctrl.h +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_ctrl.h @@ -268,6 +268,7 @@ #define NFP_NET_CFG_CTRL_PKT_TYPE (0x1 << 0) /* Pkttype offload */ #define NFP_NET_CFG_CTRL_IPSEC (0x1 << 1) /* IPsec offload */ #define NFP_NET_CFG_CTRL_MCAST_FILTER (0x1 << 2) /* Multicast Filter */ +#define NFP_NET_CFG_CTRL_MULTI_PF (0x1 << 5) /* Multi PF */ #define NFP_NET_CFG_CTRL_FREELIST_EN (0x1 << 6) /* Freelist enable flag bit */ #define NFP_NET_CFG_CAP_WORD1 0x00a4 diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_main.c b/drivers/net/ethernet/netronome/nfp/nfp_net_main.c index 98e155d79eb8..f6f4fea0a791 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_main.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_main.c @@ -684,15 +684,108 @@ int nfp_net_refresh_eth_port(struct nfp_port *port) return ret; } +/** + * nfp_net_pre_init() - Some necessary check and configuration + * in firmware before fully utilizing it. + * @pf: NFP PF handler + * @stride: queue stride + * + * Return: 0 on success, a negative error code otherwise. + */ +static int nfp_net_pre_init(struct nfp_pf *pf, int *stride) +{ + struct nfp_net_fw_version fw_ver; + struct nfp_cpp_area *area; + u8 __iomem *ctrl_bar; + int err = 0; + + ctrl_bar = nfp_pf_map_rtsym(pf, NULL, "_pf%d_net_bar0", NFP_PF_CSR_SLICE_SIZE, &area); + if (IS_ERR(ctrl_bar)) { + nfp_err(pf->cpp, "Failed to find data vNIC memory symbol\n"); + return PTR_ERR(ctrl_bar); + } + + nfp_net_get_fw_version(&fw_ver, ctrl_bar); + if (fw_ver.extend & NFP_NET_CFG_VERSION_RESERVED_MASK || + fw_ver.class != NFP_NET_CFG_VERSION_CLASS_GENERIC) { + nfp_err(pf->cpp, "Unknown Firmware ABI %d.%d.%d.%d\n", + fw_ver.extend, fw_ver.class, + fw_ver.major, fw_ver.minor); + err = -EINVAL; + goto end; + } + + /* Determine stride */ + if (nfp_net_fw_ver_eq(&fw_ver, 0, 0, 0, 1)) { + *stride = 2; + nfp_warn(pf->cpp, "OBSOLETE Firmware detected - VF isolation not available\n"); + } else { + switch (fw_ver.major) { + case 1 ... 5: + *stride = 4; + break; + default: + nfp_err(pf->cpp, "Unsupported Firmware ABI %d.%d.%d.%d\n", + fw_ver.extend, fw_ver.class, + fw_ver.major, fw_ver.minor); + err = -EINVAL; + goto end; + } + } + + if (!pf->multi_pf.en) + goto end; + + /* Enable multi-PF. */ + if (readl(ctrl_bar + NFP_NET_CFG_CAP_WORD1) & NFP_NET_CFG_CTRL_MULTI_PF) { + unsigned long long addr; + u32 cfg_q, cpp_id, ret; + unsigned long timeout; + + writel(NFP_NET_CFG_CTRL_MULTI_PF, ctrl_bar + NFP_NET_CFG_CTRL_WORD1); + writel(NFP_NET_CFG_UPDATE_GEN, ctrl_bar + NFP_NET_CFG_UPDATE); + + /* Config queue is next to txq. */ + cfg_q = readl(ctrl_bar + NFP_NET_CFG_START_TXQ) + 1; + addr = nfp_qcp_queue_offset(pf->dev_info, cfg_q) + NFP_QCP_QUEUE_ADD_WPTR; + cpp_id = NFP_CPP_ISLAND_ID(0, NFP_CPP_ACTION_RW, 0, 0); + err = nfp_cpp_writel(pf->cpp, cpp_id, addr, 1); + if (err) + goto end; + + timeout = jiffies + HZ * NFP_NET_POLL_TIMEOUT; + while ((ret = readl(ctrl_bar + NFP_NET_CFG_UPDATE))) { + if (ret & NFP_NET_CFG_UPDATE_ERR) { + nfp_err(pf->cpp, "Enable multi-PF failed\n"); + err = -EIO; + break; + } + + usleep_range(250, 500); + if (time_is_before_eq_jiffies(timeout)) { + nfp_err(pf->cpp, "Enable multi-PF timeout\n"); + err = -ETIMEDOUT; + break; + } + }; + } else { + nfp_err(pf->cpp, "Loaded firmware doesn't support multi-PF\n"); + err = -EINVAL; + } + +end: + nfp_cpp_area_release_free(area); + return err; +} + /* * PCI device functions */ int nfp_net_pci_probe(struct nfp_pf *pf) { struct devlink *devlink = priv_to_devlink(pf); - struct nfp_net_fw_version fw_ver; u8 __iomem *ctrl_bar, *qc_bar; - int stride; + int stride = 0; int err; INIT_WORK(&pf->port_refresh_work, nfp_net_refresh_vnics); @@ -703,6 +796,10 @@ int nfp_net_pci_probe(struct nfp_pf *pf) return -EINVAL; } + err = nfp_net_pre_init(pf, &stride); + if (err) + return err; + pf->max_data_vnics = nfp_net_pf_get_num_ports(pf); if ((int)pf->max_data_vnics < 0) return pf->max_data_vnics; @@ -723,34 +820,6 @@ int nfp_net_pci_probe(struct nfp_pf *pf) goto err_unmap; } - nfp_net_get_fw_version(&fw_ver, ctrl_bar); - if (fw_ver.extend & NFP_NET_CFG_VERSION_RESERVED_MASK || - fw_ver.class != NFP_NET_CFG_VERSION_CLASS_GENERIC) { - nfp_err(pf->cpp, "Unknown Firmware ABI %d.%d.%d.%d\n", - fw_ver.extend, fw_ver.class, - fw_ver.major, fw_ver.minor); - err = -EINVAL; - goto err_unmap; - } - - /* Determine stride */ - if (nfp_net_fw_ver_eq(&fw_ver, 0, 0, 0, 1)) { - stride = 2; - nfp_warn(pf->cpp, "OBSOLETE Firmware detected - VF isolation not available\n"); - } else { - switch (fw_ver.major) { - case 1 ... 5: - stride = 4; - break; - default: - nfp_err(pf->cpp, "Unsupported Firmware ABI %d.%d.%d.%d\n", - fw_ver.extend, fw_ver.class, - fw_ver.major, fw_ver.minor); - err = -EINVAL; - goto err_unmap; - } - } - err = nfp_net_pf_app_init(pf, qc_bar, stride); if (err) goto err_unmap; From patchwork Mon Jul 24 09:48:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Peens X-Patchwork-Id: 13323893 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A65979E3 for ; Mon, 24 Jul 2023 09:51:16 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2122.outbound.protection.outlook.com [40.107.243.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23CC3527E for ; Mon, 24 Jul 2023 02:50:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hYR2gcC4fRZLyx/Vwz/khGAC+iRYNt0LX3ROcxVHuEEo5eM2adFenIFosbCH51nyZdYijFTQxdmOP5oqxTJa91XO6TPgsSex+D6Gv9CwZHnIRTHceYX8sJzcvltoFMhdxRwfX1IKz5dTTNdKHVOme5zlZOx6/xyV4A9DsCqQBoczNxSmMCbfICT42D82zzoHuzDePHEUdYnFBOPDr6KYeVsQBbFCJ1A116qhGVgbXt7vEELe3qyG+6J3w5GATwfX+0FrA6ZRxEWYbgYJa0J2S112hpiUxHXxx70YKHefg8UEi+wtAoZaO5X/PB6BOTgp+YPDhV286EjZjvLSbXE+/Q== 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=5uusrKWNjPd2rs5/75cR2smhvHy8SOvmHJq/TbJD29E=; b=hLU7TXoRnM0GpztiSMwpXfqs5bxsXsLpFW1KoCfdVKA+lDeUfRjMswx0YEPxbG1F6iINSTHfigABM29ERMgrs63kp2dLD1sGSMI62X+RCVQ3vV4glNXnwV8Rr8eKVT2JALrYBxNCzJhr5bn8zXj4agMS97KSvQa8khMd9HpU8B2KdIvacT39N4fVjKKbJANX2MiWFpEDafCM0/VmSmT7u+Ur3zWQ9s+ZH8pt2NKW3cf1EhZrdws4BQKrc0g7ZmjJ9To+e4fqGnXhSKZzbHWBr85bEPv9feogTaXjjrNEJSoErTvHYONqBoZktXoWvCetuvQnuRj9XsD06SSZhH0XzQ== 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=5uusrKWNjPd2rs5/75cR2smhvHy8SOvmHJq/TbJD29E=; b=lcTF2bl3QQk7taJm6bDlkmOBu0gZprct4/BJbk+ROKKeNvXwDgS0oBGtnyQwI9yKS0Dubvl5Nws7EHfY/d08N50/dU4xUX8ta0aVFCp7WnwWga/UBXV3oQtyXxC+lsr3xXrJmt4xqb8bY9Zu+CBmCaPOFZ2FSvnr+nxQyWmpZg4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from DM6PR13MB4249.namprd13.prod.outlook.com (2603:10b6:5:7b::25) by PH0PR13MB6020.namprd13.prod.outlook.com (2603:10b6:510:fd::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 09:49:27 +0000 Received: from DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::c131:407c:3679:b781]) by DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::c131:407c:3679:b781%5]) with mapi id 15.20.6609.026; Mon, 24 Jul 2023 09:49:26 +0000 From: Louis Peens To: David Miller , Jakub Kicinski , Paolo Abeni Cc: Simon Horman , Yinjun Zhang , Tianyu Yuan , netdev@vger.kernel.org, oss-drivers@corigine.com Subject: [PATCH net-next 10/12] nfp: configure VF total count for each PF Date: Mon, 24 Jul 2023 11:48:19 +0200 Message-Id: <20230724094821.14295-11-louis.peens@corigine.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230724094821.14295-1-louis.peens@corigine.com> References: <20230724094821.14295-1-louis.peens@corigine.com> X-ClientProxiedBy: JNAP275CA0020.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:4d::20) To DM6PR13MB4249.namprd13.prod.outlook.com (2603:10b6:5:7b::25) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR13MB4249:EE_|PH0PR13MB6020:EE_ X-MS-Office365-Filtering-Correlation-Id: edd16a6a-32c6-4721-546f-08db8c2b4483 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uqvE+HCA/sZEd2mJCs6R5SP+cp1IkO5c0WFbv7O4Ev3rK34piPw+qBlx8HNN0gyc7nA2imEAr+xcmUVfGPsZNd1U+ASO75pWm62JpmONHIm7edQMr4PHgXu0lEogifDvilJpWKN6uvHZhlLYRE732hUKgrRy+t7oJVHmllSw4zgtto0V0NcQOuEJLSYXOahOyo+TjjyfWkbsJHYBs3jZdxgEoN7p1uT0VzniJUdHSRS9HUugF+M/2MLrzTqLOFrGkvkquu98sxpwwrwVySMJ1fwoCtSx+XnZcBJVDnQYlKZEam80n5kAekYdifVKk16jyas6s4MYGVmJko6N/UnL1ppmYhMk3v/2vv7zOWydT19tvMVxTa40GHFivoy0dMVHxSK0FQO4Z52h2MYvm+1Nq4xVkjp55H5e7djmFayrqU4y/WiXopa4BpdRXMkI80JplYx8bv1o1TVdihzmYszjrhBGfsfu/R2yX0ihZXNHx04D7oHmfQArZXDw2o1HcEuyTgCaFbW+Ik+yleVYdjHK13bYoq5k8pPZqAWUdqjrVoTXKAI+LpzWbNkZPy0Ad83j9SIjkv6rYkK5ekxQ6uJ+pyAjT2GRAHWX/s42ORairpqVUCUCibNm45A1Tg1i+3AFKmAsXlpyumwyWGkm0SgRLpwQNiGkw4PMidTDdNtElG4= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR13MB4249.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(396003)(366004)(39840400004)(136003)(346002)(451199021)(1076003)(26005)(8936002)(8676002)(316002)(6486002)(52116002)(6666004)(86362001)(54906003)(107886003)(36756003)(38350700002)(38100700002)(186003)(6506007)(5660300002)(6512007)(41300700001)(66556008)(66476007)(66946007)(4326008)(110136005)(44832011)(2616005)(66574015)(2906002)(83380400001)(478600001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?S+C7jDgCCWggRU24iEI6Ane8CUbj?= =?utf-8?q?n9sWT4q9wxkq8Q/SV+K8f6nMR3zmCww19+UlnrnqZxI5OB/TS1mNZWL+8qc5JhIid?= =?utf-8?q?mA4BawaNtJzxaxAFtkLFcazEk9uyhMU9om1tcE0SPMvPSQW1qwh4UVeUD4Xk/DKXl?= =?utf-8?q?fc/7+Ar/7iXTuubSzjfFDn0OwFv5kC7D98hgVNiM8HU4cDerewQE/h807c9XoRi0F?= =?utf-8?q?WrF21vCv1Z6voOyJefOMqpKOPAh1an0BN9IbI2dzTbb0SpsRthUy4AETmS8WjShnr?= =?utf-8?q?vlvEbrIT4GSfbxTJPd+UuyRc4tzUJbdNthZ/kkTZkm2RGjn2SEHQ1f8qvoKfdyP19?= =?utf-8?q?59FL1Lj15LoRgKoLl5kgcJ4ga4FA7ImNAZj4v8MLg0xxd+9i089QyqWo8fhg3tMKO?= =?utf-8?q?h5DQR5yVBJLyeQ5rOBufyAO29fTbU76frcqcR6N++f5N2aoToHtAxg9uGKaasZZtE?= =?utf-8?q?p0XwG2u/Uhj5Bl+L0IRBqESf43PdaScvEjQHqBUcoP0ZOPRFHELh/V6jvJxWICdwM?= =?utf-8?q?JRB3G5eRRDmq78dTffzJaF0RiOH/3Q2D5MNADuig6Ih+eoS4wFXAgqPuBz9vM/TRG?= =?utf-8?q?d0o/p9QsU3jSalSDboVxspoq5/4VeKQZPTdCYYegIVgQ16Ueuw9GT6gI8G2KanMEL?= =?utf-8?q?V/D/45zWCrsFl2su4MMpiRVGcfyWwairkRX0bcEZ9E8EGZ0N0GVeFGuZCemmDmVAV?= =?utf-8?q?is7+dQP4fgv3fI8vyExSeu751u17AA5iv2aeK55YdjZHRQg9v80Cov+8EXD8QEseE?= =?utf-8?q?w3gEEHKcOK3niOfSeh1+QtxnwJZZ+3vRVLIqSh5a5N0MBhC46Mv8C9VjJlJ16knij?= =?utf-8?q?LAF5zYs/6Ejzd/iRvAsr4NEWK1sQdcbOnKJUF7lLs1D3+Wp+Ef3kRb0fmNkZcBnK2?= =?utf-8?q?mkZe3IWp1SFTEuF7KOA4aih53Bir0w5CUpDvA68l733I1JSiA8OTVqj59fNE6Bdi6?= =?utf-8?q?h7RuwLFmAu0SuimUmCkZ4Ml1662py74HlSvKHwxBfZsVnBWSoQBrqaFLCzhb6nz19?= =?utf-8?q?FcYR6mGDm6R8SUU2I1+YRNfAQ8+5EZAcCyywsgixa4HqOWUAdHvrgpQK3uRSDaOVv?= =?utf-8?q?ehRlGJtm/cwOXXRrLG8+J5h+Rh9vQWs/Ika7UrynJeIXNRmXNMK8Ihk/har8IUYU4?= =?utf-8?q?Zwo22osRTA86lqMsv2jwUKtKzLq0ob2Dy6K412lyBeCgZirO8vI5xNWhXb09vZpIx?= =?utf-8?q?pTJRr4ahN0duLleAb7cb3qJsfWHxf0Vdk9Mgh6EZeWBFtYXFY9oEksQC1GhT4aJaF?= =?utf-8?q?7S37+VvDhI6nwlqC/9Gpk0XQV/gHMawEAg5PP30JFfXk28cRu8ThfKYxDNlrylX5B?= =?utf-8?q?TsKCYzITuUGpPoaayF6YwH/3uZ90KkD4XDDFIxlJWFORm+FoAXw3iFV8aSPS1NrcU?= =?utf-8?q?5il+EJbIFLdswlNClvLmwZ46Ys035gY9eT9e1VzjwZRpqU1zVqlYf2NJPM3LQCEnv?= =?utf-8?q?zf9a3Lm4OlJOuLXg3p8zZ0bgwzSrsAT2SDzaAYNEuf/I0T7hJHc/iK+ZpmUNfRhE1?= =?utf-8?q?cQNmzSnJ0lahsbmh9dRrgPifdSRg4WQ+4Q=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: edd16a6a-32c6-4721-546f-08db8c2b4483 X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB4249.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 09:49:26.4754 (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: k/ypq4hhuL/+OznDl8I5GhXJ+kU5EnxRaqbGk+kqMzx6Q0NbffcmUM+3E7d+Jnt3Ab2uxDTj9bbqH2OULDinipiFCg+yu46IoHTyazIx+QY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB6020 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Tianyu Yuan By default, PFs share the total 64 VFs equally, i.e., 32 VFs for each PF in two port NIC, which is initialized in each PF’s SR-IOV capability register by management firmware. And a new hwinfo `abi_total_vf` is introduced to make each PF’s VF total count configurable. Management firmware reads the hwinfo and configures it in SR-IOV capability register during boot process. So reboot is required to make the configuration take effect. This is not touched in driver code. Driver then modifies each PF’s `sriov_totalvf` according to maximum VF count supported by the loaded application firmware. Here we apply the rule that the PF with smaller id is satisfied first if total configured count exceeds the limitation. Signed-off-by: Tianyu Yuan Reviewed-by: Niklas Söderlund Acked-by: Simon Horman Signed-off-by: Louis Peens --- drivers/net/ethernet/netronome/nfp/nfp_main.c | 49 +++++++++++++++++-- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_main.c b/drivers/net/ethernet/netronome/nfp/nfp_main.c index 74767729e542..b15b5fe0c1c9 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_main.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_main.c @@ -224,11 +224,48 @@ static int nfp_pf_board_state_wait(struct nfp_pf *pf) return 0; } +static unsigned int nfp_pf_get_limit_vfs(struct nfp_pf *pf, + unsigned int limit_vfs_rtsym) +{ + u16 pos, offset, total; + + if (!pf->multi_pf.en || !limit_vfs_rtsym) + return limit_vfs_rtsym; + + pos = pci_find_ext_capability(pf->pdev, PCI_EXT_CAP_ID_SRIOV); + if (!pos) + return 0; + + /* Management firmware ensures that SR-IOV capability registers + * are initialized correctly. + */ + pci_read_config_word(pf->pdev, pos + PCI_SRIOV_VF_OFFSET, &offset); + pci_read_config_word(pf->pdev, pos + PCI_SRIOV_TOTAL_VF, &total); + if (!total) + return 0; + + /* Offset of first VF is relative to its PF. */ + offset += pf->multi_pf.id; + if (offset < pf->dev_info->pf_num_per_unit) + return 0; + + /* For multi-PF device, VF is numbered from max PF count. */ + offset -= pf->dev_info->pf_num_per_unit; + if (offset >= limit_vfs_rtsym) + return 0; + + if (offset + total > limit_vfs_rtsym) + return limit_vfs_rtsym - offset; + + return total; +} + static int nfp_pcie_sriov_read_nfd_limit(struct nfp_pf *pf) { + unsigned int limit_vfs_rtsym; int err; - pf->limit_vfs = nfp_rtsym_read_le(pf->rtbl, "nfd_vf_cfg_max_vfs", &err); + limit_vfs_rtsym = nfp_rtsym_read_le(pf->rtbl, "nfd_vf_cfg_max_vfs", &err); if (err) { /* For backwards compatibility if symbol not found allow all */ pf->limit_vfs = ~0; @@ -239,9 +276,13 @@ static int nfp_pcie_sriov_read_nfd_limit(struct nfp_pf *pf) return err; } - err = pci_sriov_set_totalvfs(pf->pdev, pf->limit_vfs); - if (err) - nfp_warn(pf->cpp, "Failed to set VF count in sysfs: %d\n", err); + pf->limit_vfs = nfp_pf_get_limit_vfs(pf, limit_vfs_rtsym); + if (pci_sriov_get_totalvfs(pf->pdev) != pf->limit_vfs) { + err = pci_sriov_set_totalvfs(pf->pdev, pf->limit_vfs); + if (err) + nfp_warn(pf->cpp, "Failed to set VF count in sysfs: %d\n", err); + } + return 0; } From patchwork Mon Jul 24 09:48:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Peens X-Patchwork-Id: 13323897 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5117F50B for ; Mon, 24 Jul 2023 09:51:25 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2071d.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe59::71d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E39C59E6 for ; Mon, 24 Jul 2023 02:51:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mMV3EDI1AVMFmjHpjFWId1DiBXSZtTJyelg9uWnuRG8/pLGfOjqftsrAM9GutYLyH+37OQSI41Y4bhrTZVJsweRNuSnykkP2RRHJt68xgCY7ylhda0PbcwlL38CSMieD4ZfyadOwwOUUVgoAECB49W5ugs9ysZbl7vyotBCOGiQsbRvXT5KHRCjvMOXj5/lplWCw50ESbXivWENaggPgHriWLHmhvEC7Poi8ZmoiBiB5vbXqu9uhJ5c+JXr8tA7oCerlFw2dhYncUpJG7a8JcHcWcHPkqWXgM/34FHK3/64fD6OnW4giWrnfj8SHVFwxgkncfDcCtcml3g1Fqr1oRQ== 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=ELJ3sWTRsSpdEgU8Di/2sJRLaUZzkG7S22/xcW1snb8=; b=EYMnUIlZ9tLPqSwLlI/99B1QTW8Nfl/KHfOTQ6tFuVMf8TLdN6pPX0D/n9aTtJ2oxNZYy592+pGxVvh2mz4mqMCyI4lL9eYndJEI/Rk6v2pmnkj4YYGESLELFb5Xb/mtCrcp8f9Cq+gaQaWMS0zrYV4zOHGHl22FfOeLn6nzI8GT7ozJ1wSSlFeg+Gyf7Tdx2SKdAMQFPc3RZkvMGTQZUlRecvlPs1OvhtDgLwoLsq9WguCu09FosbBHnGp0ShyApQ74tmmRgVAMvKQEe6xfJF73SJxtGpJnGioKPo/Ud3dsswxUoR3FvJMUTb9ggxGHpNFxdDiJIra2jcRTP6nPBg== 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=ELJ3sWTRsSpdEgU8Di/2sJRLaUZzkG7S22/xcW1snb8=; b=apJQQG4BlUENFWFo+m/gfWUSAX2DZEHuDdMlM69auFMV75APFKYpSICdlme9PRGDrRPyiIIUeuYHzr+IFZ8x0RqJY0UlMk72yWB00EGhiLBQioZfnNBGQPPrkoNMR77vAEmHYGmINXZnImf+qOQpeqYFkr/4+5rsTSF0ql+P7ic= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from DM6PR13MB4249.namprd13.prod.outlook.com (2603:10b6:5:7b::25) by PH0PR13MB6020.namprd13.prod.outlook.com (2603:10b6:510:fd::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 09:49:30 +0000 Received: from DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::c131:407c:3679:b781]) by DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::c131:407c:3679:b781%5]) with mapi id 15.20.6609.026; Mon, 24 Jul 2023 09:49:30 +0000 From: Louis Peens To: David Miller , Jakub Kicinski , Paolo Abeni Cc: Simon Horman , Yinjun Zhang , Tianyu Yuan , netdev@vger.kernel.org, oss-drivers@corigine.com Subject: [PATCH net-next 11/12] nfp: configure VF split info into application firmware Date: Mon, 24 Jul 2023 11:48:20 +0200 Message-Id: <20230724094821.14295-12-louis.peens@corigine.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230724094821.14295-1-louis.peens@corigine.com> References: <20230724094821.14295-1-louis.peens@corigine.com> X-ClientProxiedBy: JNAP275CA0020.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:4d::20) To DM6PR13MB4249.namprd13.prod.outlook.com (2603:10b6:5:7b::25) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR13MB4249:EE_|PH0PR13MB6020:EE_ X-MS-Office365-Filtering-Correlation-Id: a9879199-5e31-4362-95b7-08db8c2b4694 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LYwKVGXhdQTTdwffJWk3Xq57pEUs/2V5AW2JZY+HyWI3DsdW+JwOgFOFcojTdx0c2V+RlWCiyfPQmC5HBaYJJUCX2NT4e/PCchqqJmxCLRpbOqWUGyRWoV1aV1e1fo6R37QTiJ0f9X1pGiyMpo3OIbfEJL8AIJnxjklHtuBn9DR+RmKT3FqojtUdVcm0eFaYuli/H7InZonL1iUszmIIvHTWBVzsqB4yHf8tjyJWAONsvcNCDQgR+V+kX6Bd59asvLsG9gqe9fD5057qSMdUUpELA9O1pm4dSBIbFZKnQYMDuFgNOrY6W/v6X1DxuoSYVfEjZ8ixLPQTZegKCWxlclpne0sUvs3Z3tQmf2rabi0DtHFob29nxnEN7CKzkFx3G65XRbqR5LFD/tlf1VY8IG3/eWi/EfCfK15zTSzt388TgrcmRCMBcpls2ZOxgyS2MfxKr20CbXk5W61fk88M0A3Fn9fZ7UEHWd1ubqyo3Av8TcGWB7xEBKBYcuQ/DA3krPzOCB0b07wIa6oja6IMnM2Xq6B08/2a2W7hScE5dxoRTgMMUJDk2x8DvTON21UjEX5CM0DjtcfL1PMyDWW9DribAlyLH4nktZarMFRzDriRk9PV95gpojTDbOk5iM7JBJRK/SO/8ujqLQUhgKZNRJLGsPr33dKTWxruySkbJqk= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR13MB4249.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(396003)(366004)(39840400004)(136003)(346002)(451199021)(1076003)(26005)(8936002)(8676002)(316002)(6486002)(52116002)(6666004)(86362001)(54906003)(107886003)(36756003)(38350700002)(38100700002)(186003)(6506007)(5660300002)(6512007)(41300700001)(66556008)(66476007)(66946007)(4326008)(110136005)(44832011)(2616005)(66574015)(2906002)(83380400001)(478600001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?CHIT1EobRkRHDpnsSKlG771EDtnJ?= =?utf-8?q?lNO3WCi5xnt1ACmT3a8DghDI9zTQUcyDVRzqhgVwAVP0bcq9457IDaB81dTgPBt+9?= =?utf-8?q?hi6DwoFoPME0+JsKB5rwtbPH5kjktPDPsQ0+n+FoMfWR66vMUvyHXsddFpUVwwU2e?= =?utf-8?q?lHmdbkaysXCWFFObx11jb0H47kZEDDQg+axbes2/vBatfwKeSMryOOwaH4Mg/ra8g?= =?utf-8?q?VromazMRO+wF9dZ5WoVFwEi4Pr25KpG2ZyR7eLQj7I6ZzbehiMojh102yUiXdNk9c?= =?utf-8?q?XzBtS8I6wOUsskvavAHbLMEYS9k5/+EJRbpBeoR4vbhyKQ758JF7rmBrn4OmK3kfy?= =?utf-8?q?0gqO1GXd0GZuFVbHAE1TiC4nc7fjbOA869Gead2SIkO6QbxvI43h8IZmg44tRLhYu?= =?utf-8?q?WkProKPpPAu1l8rUKyd6WGrT7zOylo+hPRueevFC/5j2+fljK8y78EL3Q9ITehet+?= =?utf-8?q?6DukYrt3C2+zfCU13v8uy9+I7yLKSa66wZQEKPt82WNgy1UJgEij+HTemccLPwe+n?= =?utf-8?q?QXV7RERfgd5OD0G/PeFiV84fslm4HVvO/0xwZGHXs1aCQRF5zhY+vyk8MfRLeuNgR?= =?utf-8?q?6PZC+Oty0fvbbkAa3XvMRScuN9L0DR+5M+1O2RIWhDzSor+AufpErrRmTxvvwaRqu?= =?utf-8?q?l4XylQ+ruwobk98Toh37QrSGjDEQfK1vE24yRInGPCD3Y9hGTzG4r0i4z9mMRdVEj?= =?utf-8?q?8F+W4VqCeRMeOEWy9n5WmHgyTrCd1y4lWYWUXXfjfnLiqw4FJEzqLQTZwadZm9dLS?= =?utf-8?q?6nrbfngztsa+kjUP3ezqoYazCHTNSvwxyUuw1PS/k5/15glqu+e+o7HBQObml7Rcj?= =?utf-8?q?WDqv31YCsT9p3a4/Kknla9cILr4Fga9dLwp1Ll5/JrJW60DjXJ4dOTAQDujUdHqVO?= =?utf-8?q?uw1hFXInD045SXia3eCkla3+9pgyyGkWXx6oBCHAQh5Ffrxn7zdOYBHBP5uKY0w9c?= =?utf-8?q?jGdB6/261ENmYC5oSx5BnV+lIBJ+kLhNUZsWB42W3GUqFUbSIfIBcjDxLqX74JKUo?= =?utf-8?q?mv1p+ELt9alXYGDg15YeAwESKBYvKYE1Sqyz8mC6I8t8+Y+z0nBQCFZPPyqTJ527N?= =?utf-8?q?XKsmu5VA+CWd1aWX+VlOrHMY7ZjnsfDiJGDMtL6pYRoE4D3xjnDOP8WiTHBFSnYLt?= =?utf-8?q?yk+ns0ky6zpCHxsEzmApI80fGxFelIs1sFntBjCSbbVgaPU7sIQmqnKbQzKeoe8SW?= =?utf-8?q?h+62hvnPPfJelPJkL2RrlI9VKqxR5T2EzA0CJ4SFDrUTUqDYMSZau3zsCvY0Yd6CO?= =?utf-8?q?/mcqbbufrEfC4njaHdrlsDlVeD+/OI3FUWGqsNJtVQxRzKWO5zwsglLb3XXB1nWbP?= =?utf-8?q?epZWr1+0bmkktQuzIdyeB5Kq1ehSCtwkthwtQAeCu8Ktieuas6kmkf43gQaDBwx6A?= =?utf-8?q?3pocGo+9pbwVJg9ojFdH6QtYA2xFV1ELReEgLcRTiiGsKMBmNiv+/L0w7EoxgwboN?= =?utf-8?q?pVmepqjzDccdr64eRGEfd0teEaUFM8hTEKIzndpKvJCVrGjg77ikkaGBYs9I2G5iA?= =?utf-8?q?5OEEV43yLCM2l2zIvjz5W43gN9fp4zluKA=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: a9879199-5e31-4362-95b7-08db8c2b4694 X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB4249.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 09:49:30.2524 (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: ddPBgw2vMnXTEuaikWjKSvZpaNKxdxrX6tqrWR1tZVsAwPQz29aEloBh/BHYgCaEB7TrB4oivoxki7PZ0zqpUQbT3vUGoBJED8XzTuL9tls= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB6020 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Yinjun Zhang In multi-PF case, all PFs share total 64 VFs. To support the VF count of each PF configurable, driver needs to write the VF count and the first VF id into application firmware, so that firmware can initialize and allocate relevant resource accordingly. Signed-off-by: Yinjun Zhang Reviewed-by: Niklas Söderlund Acked-by: Simon Horman Signed-off-by: Louis Peens --- drivers/net/ethernet/netronome/nfp/nfp_main.c | 1 + drivers/net/ethernet/netronome/nfp/nfp_main.h | 2 ++ .../net/ethernet/netronome/nfp/nfp_net_main.c | 16 ++++++++++++ .../ethernet/netronome/nfp/nfp_net_sriov.c | 25 +++++++++++++++++++ .../ethernet/netronome/nfp/nfp_net_sriov.h | 5 ++++ 5 files changed, 49 insertions(+) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_main.c b/drivers/net/ethernet/netronome/nfp/nfp_main.c index b15b5fe0c1c9..70e140e7d93b 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_main.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_main.c @@ -254,6 +254,7 @@ static unsigned int nfp_pf_get_limit_vfs(struct nfp_pf *pf, if (offset >= limit_vfs_rtsym) return 0; + pf->multi_pf.vf_fid = offset; if (offset + total > limit_vfs_rtsym) return limit_vfs_rtsym - offset; diff --git a/drivers/net/ethernet/netronome/nfp/nfp_main.h b/drivers/net/ethernet/netronome/nfp/nfp_main.h index 4f6763ca1c92..e7f125a3f884 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_main.h +++ b/drivers/net/ethernet/netronome/nfp/nfp_main.h @@ -87,6 +87,7 @@ struct nfp_dumpspec { * @multi_pf: Used in multi-PF setup * @multi_pf.en: True if it's a NIC with multiple PFs * @multi_pf.id: PF index + * @multi_pf.vf_fid: Id of first VF that belongs to this PF * @multi_pf.beat_timer:Timer for beat to keepalive * @multi_pf.beat_area: Pointer to CPP area for beat to keepalive * @multi_pf.beat_addr: Pointer to mapped beat address used for keepalive @@ -151,6 +152,7 @@ struct nfp_pf { struct { bool en; u8 id; + u8 vf_fid; struct timer_list beat_timer; struct nfp_cpp_area *beat_area; u8 __iomem *beat_addr; diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_main.c b/drivers/net/ethernet/netronome/nfp/nfp_net_main.c index f6f4fea0a791..eb7b0ecd65df 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_main.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_main.c @@ -293,6 +293,16 @@ static int nfp_net_pf_init_vnics(struct nfp_pf *pf) return err; } +static void nfp_net_pf_clean_vnics(struct nfp_pf *pf) +{ + struct nfp_net *nn; + + list_for_each_entry(nn, &pf->vnics, vnic_list) { + if (nfp_net_is_data_vnic(nn)) + nfp_net_pf_clean_vnic(pf, nn); + } +} + static int nfp_net_pf_app_init(struct nfp_pf *pf, u8 __iomem *qc_bar, unsigned int stride) { @@ -852,11 +862,17 @@ int nfp_net_pci_probe(struct nfp_pf *pf) if (err) goto err_stop_app; + err = nfp_net_pf_init_sriov(pf); + if (err) + goto err_clean_vnics; + devl_unlock(devlink); devlink_register(devlink); return 0; +err_clean_vnics: + nfp_net_pf_clean_vnics(pf); err_stop_app: nfp_net_pf_app_stop(pf); err_free_irqs: diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_sriov.c b/drivers/net/ethernet/netronome/nfp/nfp_net_sriov.c index 6eeeb0fda91f..f516ba7a429e 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_sriov.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_sriov.c @@ -14,6 +14,9 @@ #include "nfp_net.h" #include "nfp_net_sriov.h" +/* The configurations that precede VF creating. */ +#define NFP_NET_VF_PRE_CONFIG NFP_NET_VF_CFG_MB_CAP_SPLIT + static int nfp_net_sriov_check(struct nfp_app *app, int vf, u16 cap, const char *msg, bool warn) { @@ -29,6 +32,10 @@ nfp_net_sriov_check(struct nfp_app *app, int vf, u16 cap, const char *msg, bool return -EOPNOTSUPP; } + /* No need to check vf for the pre-configurations. */ + if (cap & NFP_NET_VF_PRE_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 +316,21 @@ int nfp_app_get_vf_config(struct net_device *netdev, int vf, return 0; } + +int nfp_net_pf_init_sriov(struct nfp_pf *pf) +{ + int err; + + if (!pf->multi_pf.en || !pf->limit_vfs) + return 0; + + err = nfp_net_sriov_check(pf->app, 0, NFP_NET_VF_CFG_MB_CAP_SPLIT, "split", true); + if (err) + return err; + + writeb(pf->limit_vfs, pf->vfcfg_tbl2 + NFP_NET_VF_CFG_MB_VF_CNT); + + /* Reuse NFP_NET_VF_CFG_MB_VF_NUM to pass vf_fid to FW. */ + return nfp_net_sriov_update(pf->app, pf->multi_pf.vf_fid, + NFP_NET_VF_CFG_MB_UPD_SPLIT, "split"); +} diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_sriov.h b/drivers/net/ethernet/netronome/nfp/nfp_net_sriov.h index 2d445fa199dc..8de959018819 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_SPLIT (0x1 << 8) #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,8 @@ #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_SPLIT (0x1 << 8) +#define NFP_NET_VF_CFG_MB_VF_CNT 0x6 #define NFP_NET_VF_CFG_MB_VF_NUM 0x7 /* VF config entry @@ -68,4 +71,6 @@ int nfp_app_set_vf_link_state(struct net_device *netdev, int vf, int nfp_app_get_vf_config(struct net_device *netdev, int vf, struct ifla_vf_info *ivi); +int nfp_net_pf_init_sriov(struct nfp_pf *pf); + #endif /* _NFP_NET_SRIOV_H_ */ From patchwork Mon Jul 24 09:48:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Peens X-Patchwork-Id: 13323898 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51987F9E5 for ; Mon, 24 Jul 2023 09:51:30 +0000 (UTC) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2124.outbound.protection.outlook.com [40.107.243.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08BE930E7 for ; Mon, 24 Jul 2023 02:51:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AlUsm1RDtm4nn6uIYJqHU3++OCzZS/JkCy4mfV6GwiztaLHWHFnVwWm4VBeC7i0G53TsyFaUoHwnnMec/D+3S9CXYaONd6tnQ32nWMZslHtnTKZumf9ef2YQtCxvsXcnD2oL/nsAai7OPUkfjwlQ8gSTcWL3iB+p9u7hl0DMwofckdQv1fBqEa5KOo5lkYvPoLRDSmsA6xzTGOKF5AMhrnRvQ4VjzO0T39jKVDRiUZhwJL19FVgVUJY4QvxsCH4RM1mgjJMqu406CCtifkrYmBoXCCB8MxloR6t21zJDjKItBeeav5hdZj96cFPSTYnvpjFR9Lw/y8jcXbvrxwL4MA== 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=wW5qAoKKOCJX0LvdrXHIuNMF7UNWYwWcedloEMQCH3s=; b=est4TQrDS/V6QaZ+NxSsSmppfRHSKqt1t2nk8HUcx6jn+JZQlS5+95GKycaMZeNhRfo1HtmH3Qt5nlDjwdOxV94/ssenNHv4ZFewddl4181xhc92AA46aK+NfJFGc+USJ6+Acn+4T9hniTvIyI0MW7OqUZYQt5SG9bTW5183WWcAcMR5Sb2gX1FHUniX9Y3Na2iCLWCeStLU7wQ7GmMsEXd9xfiUqM+5MNN4JEQlqe4AH3itkar0EE42uu2vxOKpEpSFbsHm0zW+WgahZyd0hab+/wlxKSxfH7u5ZoRcYVg1lsJx3zOYWoo5SMztinZQpVv2MmO3bmSgDslFlwI6Iw== 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=wW5qAoKKOCJX0LvdrXHIuNMF7UNWYwWcedloEMQCH3s=; b=k5QilAvVMALMvOVsOcFMc+LLLgu+HTiWOXmjOkATORvuVZ5CrqIPBjuSdekb8NN0R8n9ySCHW3r8WezUux6MJ65xi7C4jebGsZIprYdAb7YzUrlvCdytwP2D+cOvRuPXwYq3oVrjHMhCUrP+zSfPLvkBwuacI4Ne92/8GeAPFx8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from DM6PR13MB4249.namprd13.prod.outlook.com (2603:10b6:5:7b::25) by PH0PR13MB6020.namprd13.prod.outlook.com (2603:10b6:510:fd::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 09:49:33 +0000 Received: from DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::c131:407c:3679:b781]) by DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::c131:407c:3679:b781%5]) with mapi id 15.20.6609.026; Mon, 24 Jul 2023 09:49:33 +0000 From: Louis Peens To: David Miller , Jakub Kicinski , Paolo Abeni Cc: Simon Horman , Yinjun Zhang , Tianyu Yuan , netdev@vger.kernel.org, oss-drivers@corigine.com Subject: [PATCH net-next 12/12] nfp: use absolute vf id for multi-PF case Date: Mon, 24 Jul 2023 11:48:21 +0200 Message-Id: <20230724094821.14295-13-louis.peens@corigine.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230724094821.14295-1-louis.peens@corigine.com> References: <20230724094821.14295-1-louis.peens@corigine.com> X-ClientProxiedBy: JNAP275CA0020.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:4d::20) To DM6PR13MB4249.namprd13.prod.outlook.com (2603:10b6:5:7b::25) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR13MB4249:EE_|PH0PR13MB6020:EE_ X-MS-Office365-Filtering-Correlation-Id: cdde48fb-617e-4353-3760-08db8c2b48c7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZJuh7+iP+rnc7RF1sCZchk4L+FBsy7bCF7wnL9r4/FDo0j6uKCrWInaLBYHd571tUSCZl9h+JALXssdX9sJindTvbfvUrJT3JRUdoUsE7bEMMQZOEEEDmiqs1jD2Xc97BjuEau69rLCF6XOFbLKEthxpZy/b5OtqpZi8jPMGxa/d6B2ldgs2yNfClfeCnltT2+cCYvxTb7oGVkFTORODpqnRrlKft8z1v7e4gf8y+i0jAbz/Drrhpx+sj315o3SSc7pHQV1AuZeRC/BWzWZHr7K/XeVupEPV+j+eems5L19aIihpTWqXD+RaRY4GW3QI9ktFf7tmiqAHIE9rDAivwlgRHOGsZ7r+x9lWrm9SmWzJ7CXt7jgLBsV6VJAsA5AETVU6KM6tgEfa9ypypBDVxbBg17Z4LxbIt8T9e/69o/jhrhYTMtaT3aYckHxSCFqu7J2kWbXes001jQuOMePKL7FLaCAYPyu/0kmgnsqs6CUtUAxcl9QJCItxH/wcxJXKQ62A67n/Xid3blnPfia3haa9/clIzwmPgMBn+ri0lsdIi0youvt0fse5h2Qcm6Em21g7EvongkSipFsLv2KxCjHCepBelXGkruBtnF4vAQ7T40Q7WqHcVKPZZGe153M+LuO5IfazUw38LONC3RgtiUFDdk2Leu7cdwz3ynRkeBw= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR13MB4249.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(396003)(366004)(39840400004)(136003)(346002)(451199021)(1076003)(26005)(8936002)(8676002)(316002)(6486002)(52116002)(6666004)(86362001)(54906003)(107886003)(36756003)(38350700002)(38100700002)(186003)(6506007)(5660300002)(6512007)(41300700001)(66556008)(66476007)(66946007)(4326008)(110136005)(44832011)(2616005)(66574015)(2906002)(83380400001)(478600001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?HYBKZQCnBr5YALuc9orA1yIGuYJQ?= =?utf-8?q?m36Smas57Q7kq3hHKEdIaDwTT93XJ7XBKAPFSAnTY9NQfOEWLY+k7P7SaA3rjYHTf?= =?utf-8?q?52qmZdqXA9pFoLLzDmv/rC5SjT9pHid5W/Z8oOsDxZTE20VuCYujRs/egs3kZGCGd?= =?utf-8?q?W+yULbooZ6E7omWjIoq6UFuxDNCOK+kRrOHPKa7satx2lnfH3qEqiLqjOiLvQpKnq?= =?utf-8?q?7iuQgFYYvLT8ioK191OWNBxH83HQBVY0ZdFJfuv/XoZUMw4AUKhss04A18Gt0bobt?= =?utf-8?q?22RKco6W/l922g0GNwf3eWVqNEDmgruOD52eSu4J3U/YTAVb1lvw7DUkqAJJAvGty?= =?utf-8?q?qOTgWHrsNaw6OqlCFLVacaNZXoHdST6cSFpgJ/efKKDoHiPNAvf4gNDOVCYbbm909?= =?utf-8?q?l2x9zCwsGt3ruyKfpOHoF7xlLUKFd26zdUheX146Cl+H4vVv0Ggc6tzmjrzz6SkiT?= =?utf-8?q?Okhx2HIOlRGaOrMkJLqImgj5Aq9/DhWvnME6hph34gqpG1XTCWgnulFFR0XK4gdNL?= =?utf-8?q?QxdASVyiOf0zSgLwOqniuHeMJ+Fhc1oHlUOlQzS303gVeHGOFQ38KJBIu66LAQd9W?= =?utf-8?q?B5N9TTZqJHHEDHli7R2V58pbi7g2i9tY2ANTyImMA49Q5lOUfG9omTx3kDWYa5i4x?= =?utf-8?q?knEulOnJIggtdGPPTlIKUDD3EGnFbfP07vcRMJqLxjJD68pj+DsSFZPjpiNg3Ty20?= =?utf-8?q?6Cbjc5AZ5ZSCJfQrtjw1UBIwhJKmOoDBwE3UHjK8TcCoMABz7f+WL6u6hwEMv3O5a?= =?utf-8?q?YITjF/yEQheo+PcPOFalCpZS4hlTsVxEfa3Hq48bk1zfVRfz+VGbo44hQGpEF/Yiy?= =?utf-8?q?/0uO7VqWYC4qt/JT0v9eIX5ubB0Ki0HZhdwjWxFEYvBnu+3Z2o5leU2GaOso8iZgj?= =?utf-8?q?CfFgf/9qRuvt3+pcjxDNpMnDCZmD6He+ahnkZYrco3drU40aD08MkFIDhC0ae+Gfg?= =?utf-8?q?LBKxHnAgmjYWM1xCKFS706DJDYLgyvNIkLxtn7ltvbI9FONxsP8Ij+uz5pADuTN/h?= =?utf-8?q?3fC1w0wJkImdgmLKfYX1N0YXoTW/s0+7VghDJ4o5tcSlOWEHn17GfVAgEIqe6Ixxc?= =?utf-8?q?Bx6yaIIUeGbVbHRbar76eWRISU85BoClA+d67ePI6ih6znYdGI89aWCiVmJJATvM4?= =?utf-8?q?HNT8iOy28DNYqe7rLAzdoNRrt4di6nHE2/xOEjC9wTF73zCZnrZ+gqI5LJF4Ky3yc?= =?utf-8?q?331lXS2H0U/b0JVqr/8TyunwwU3K29/OUDXBKkzd8Yv3VWvjOU8peZV0VYmO+MXQH?= =?utf-8?q?LDT8iI1XIAxVFIduyLvAdRMJbj6eIH5/Q+hEPN2QmTtUVxbNM4UCh5Sz7l2R2uJDK?= =?utf-8?q?kNMk0YSD5mDQRlLPwC+u5nVVBrDJ2X6W5CNuvkDjWRAqXyVqLl0jh1FDs+A44xa3+?= =?utf-8?q?R1DpXTnl7NJWjMyY/VPzG9s7cPqTfH5+ZWjCeaPpgdHFf+9JNWq5pvspUqmn9l3UI?= =?utf-8?q?tMkWzY79dlXM+bVOesyrEhGJU/eOoirZOkA5sQxR5X7I1dmhpVmiCuqojmNsOmuhS?= =?utf-8?q?B0ueKX/N1tOUSQNUxRP9VjyYSu4IzN2CWA=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: cdde48fb-617e-4353-3760-08db8c2b48c7 X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB4249.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 09:49:33.6698 (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: RZl0dRW3cOxUSZhtTelfHD6sA1/bw5PN54pPQ51C9BblK09GhrIUJsu7D8GK/MbLWPKH8G25V5iKs3tJwlUJXPjroPMNz8w/d/NqEIRBk64= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB6020 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Yinjun Zhang In multi-PF setup, absolute VF id is required to configure attributes for corresponding VF. Add helper function to map rtsym with specified offset. With PF's first VF as base offset, we can access `vf_cfg_mem` as before. Signed-off-by: Yinjun Zhang Reviewed-by: Niklas Söderlund Acked-by: Simon Horman Signed-off-by: Louis Peens --- drivers/net/ethernet/netronome/nfp/nfp_main.c | 14 +++++++++++--- drivers/net/ethernet/netronome/nfp/nfp_main.h | 4 ++++ .../net/ethernet/netronome/nfp/nfp_net_main.c | 10 ++++++---- .../net/ethernet/netronome/nfp/nfp_net_sriov.c | 14 ++++++++++---- .../ethernet/netronome/nfp/nfpcore/nfp_nffw.h | 4 ++++ .../ethernet/netronome/nfp/nfpcore/nfp_rtsym.c | 16 ++++++++++++---- 6 files changed, 47 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_main.c b/drivers/net/ethernet/netronome/nfp/nfp_main.c index 70e140e7d93b..139499d891c1 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_main.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_main.c @@ -97,14 +97,22 @@ int nfp_pf_rtsym_read_optional(struct nfp_pf *pf, const char *format, } u8 __iomem * -nfp_pf_map_rtsym(struct nfp_pf *pf, const char *name, const char *sym_fmt, - unsigned int min_size, struct nfp_cpp_area **area) +nfp_pf_map_rtsym_offset(struct nfp_pf *pf, const char *name, const char *sym_fmt, + unsigned int offset, unsigned int min_size, + struct nfp_cpp_area **area) { char pf_symbol[256]; snprintf(pf_symbol, sizeof(pf_symbol), sym_fmt, nfp_get_pf_id(pf)); - return nfp_rtsym_map(pf->rtbl, pf_symbol, name, min_size, area); + return nfp_rtsym_map_offset(pf->rtbl, pf_symbol, name, offset, min_size, area); +} + +u8 __iomem * +nfp_pf_map_rtsym(struct nfp_pf *pf, const char *name, const char *sym_fmt, + unsigned int min_size, struct nfp_cpp_area **area) +{ + return nfp_pf_map_rtsym_offset(pf, name, sym_fmt, 0, min_size, area); } /* Callers should hold the devlink instance lock */ diff --git a/drivers/net/ethernet/netronome/nfp/nfp_main.h b/drivers/net/ethernet/netronome/nfp/nfp_main.h index e7f125a3f884..4f1623917c4e 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_main.h +++ b/drivers/net/ethernet/netronome/nfp/nfp_main.h @@ -179,6 +179,10 @@ int nfp_pf_rtsym_read_optional(struct nfp_pf *pf, const char *format, unsigned int default_val); int nfp_net_pf_get_app_id(struct nfp_pf *pf); u8 __iomem * +nfp_pf_map_rtsym_offset(struct nfp_pf *pf, const char *name, const char *sym_fmt, + unsigned int offset, unsigned int min_size, + struct nfp_cpp_area **area); +u8 __iomem * nfp_pf_map_rtsym(struct nfp_pf *pf, const char *name, const char *sym_fmt, unsigned int min_size, struct nfp_cpp_area **area); int nfp_mbox_cmd(struct nfp_pf *pf, u32 cmd, void *in_data, u64 in_length, diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_main.c b/drivers/net/ethernet/netronome/nfp/nfp_net_main.c index eb7b0ecd65df..f68fd01dac60 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_main.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_main.c @@ -473,9 +473,10 @@ static int nfp_net_pci_map_mem(struct nfp_pf *pf) } } - pf->vf_cfg_mem = nfp_pf_map_rtsym(pf, "net.vfcfg", "_pf%d_net_vf_bar", - NFP_NET_CFG_BAR_SZ * pf->limit_vfs, - &pf->vf_cfg_bar); + pf->vf_cfg_mem = nfp_pf_map_rtsym_offset(pf, "net.vfcfg", "_pf%d_net_vf_bar", + NFP_NET_CFG_BAR_SZ * pf->multi_pf.vf_fid, + NFP_NET_CFG_BAR_SZ * pf->limit_vfs, + &pf->vf_cfg_bar); if (IS_ERR(pf->vf_cfg_mem)) { if (PTR_ERR(pf->vf_cfg_mem) != -ENOENT) { err = PTR_ERR(pf->vf_cfg_mem); @@ -484,7 +485,8 @@ static int nfp_net_pci_map_mem(struct nfp_pf *pf) pf->vf_cfg_mem = NULL; } - min_size = NFP_NET_VF_CFG_SZ * pf->limit_vfs + NFP_NET_VF_CFG_MB_SZ; + min_size = NFP_NET_VF_CFG_SZ * (pf->limit_vfs + pf->multi_pf.vf_fid) + + NFP_NET_VF_CFG_MB_SZ; pf->vfcfg_tbl2 = nfp_pf_map_rtsym(pf, "net.vfcfg_tbl2", "_pf%d_net_vf_cfg2", min_size, &pf->vfcfg_tbl2_area); diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_sriov.c b/drivers/net/ethernet/netronome/nfp/nfp_net_sriov.c index f516ba7a429e..67aea9445aa2 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_sriov.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_sriov.c @@ -72,7 +72,7 @@ int nfp_app_set_vf_mac(struct net_device *netdev, int vf, u8 *mac) { struct nfp_app *app = nfp_app_from_netdev(netdev); unsigned int vf_offset; - int err; + int err, abs_vf; err = nfp_net_sriov_check(app, vf, NFP_NET_VF_CFG_MB_CAP_MAC, "mac", true); if (err) @@ -85,13 +85,14 @@ int nfp_app_set_vf_mac(struct net_device *netdev, int vf, u8 *mac) return -EINVAL; } + abs_vf = vf + app->pf->multi_pf.vf_fid; /* Write MAC to VF entry in VF config symbol */ - vf_offset = NFP_NET_VF_CFG_MB_SZ + vf * NFP_NET_VF_CFG_SZ; + vf_offset = NFP_NET_VF_CFG_MB_SZ + abs_vf * NFP_NET_VF_CFG_SZ; writel(get_unaligned_be32(mac), app->pf->vfcfg_tbl2 + vf_offset); writew(get_unaligned_be16(mac + 4), app->pf->vfcfg_tbl2 + vf_offset + NFP_NET_VF_CFG_MAC_LO); - err = nfp_net_sriov_update(app, vf, NFP_NET_VF_CFG_MB_UPD_MAC, "MAC"); + err = nfp_net_sriov_update(app, abs_vf, NFP_NET_VF_CFG_MB_UPD_MAC, "MAC"); if (!err) nfp_info(app->pf->cpp, "MAC %pM set on VF %d, reload the VF driver to make this change effective.\n", @@ -145,6 +146,7 @@ int nfp_app_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos, if (vlan_tag && is_proto_sup) vlan_tag |= FIELD_PREP(NFP_NET_VF_CFG_VLAN_PROT, ntohs(vlan_proto)); + vf += app->pf->multi_pf.vf_fid; vf_offset = NFP_NET_VF_CFG_MB_SZ + vf * NFP_NET_VF_CFG_SZ; writel(vlan_tag, app->pf->vfcfg_tbl2 + vf_offset + NFP_NET_VF_CFG_VLAN); @@ -169,6 +171,7 @@ int nfp_app_set_vf_rate(struct net_device *netdev, int vf, return -EINVAL; } + vf += app->pf->multi_pf.vf_fid; vf_offset = NFP_NET_VF_CFG_MB_SZ + vf * NFP_NET_VF_CFG_SZ; ratevalue = FIELD_PREP(NFP_NET_VF_CFG_MAX_RATE, max_tx_rate ? max_tx_rate : @@ -195,6 +198,7 @@ int nfp_app_set_vf_spoofchk(struct net_device *netdev, int vf, bool enable) return err; /* Write spoof check control bit to VF entry in VF config symbol */ + vf += app->pf->multi_pf.vf_fid; vf_offset = NFP_NET_VF_CFG_MB_SZ + vf * NFP_NET_VF_CFG_SZ + NFP_NET_VF_CFG_CTRL; vf_ctrl = readb(app->pf->vfcfg_tbl2 + vf_offset); @@ -219,6 +223,7 @@ int nfp_app_set_vf_trust(struct net_device *netdev, int vf, bool enable) return err; /* Write trust control bit to VF entry in VF config symbol */ + vf += app->pf->multi_pf.vf_fid; vf_offset = NFP_NET_VF_CFG_MB_SZ + vf * NFP_NET_VF_CFG_SZ + NFP_NET_VF_CFG_CTRL; vf_ctrl = readb(app->pf->vfcfg_tbl2 + vf_offset); @@ -253,6 +258,7 @@ int nfp_app_set_vf_link_state(struct net_device *netdev, int vf, } /* Write link state to VF entry in VF config symbol */ + vf += app->pf->multi_pf.vf_fid; vf_offset = NFP_NET_VF_CFG_MB_SZ + vf * NFP_NET_VF_CFG_SZ + NFP_NET_VF_CFG_CTRL; vf_ctrl = readb(app->pf->vfcfg_tbl2 + vf_offset); @@ -278,7 +284,7 @@ int nfp_app_get_vf_config(struct net_device *netdev, int vf, if (err) return err; - vf_offset = NFP_NET_VF_CFG_MB_SZ + vf * NFP_NET_VF_CFG_SZ; + vf_offset = NFP_NET_VF_CFG_MB_SZ + (vf + app->pf->multi_pf.vf_fid) * NFP_NET_VF_CFG_SZ; mac_hi = readl(app->pf->vfcfg_tbl2 + vf_offset); mac_lo = readw(app->pf->vfcfg_tbl2 + vf_offset + NFP_NET_VF_CFG_MAC_LO); diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nffw.h b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nffw.h index 49a4d3f56b56..4042352f83b0 100644 --- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nffw.h +++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nffw.h @@ -101,6 +101,10 @@ u64 nfp_rtsym_read_le(struct nfp_rtsym_table *rtbl, const char *name, int nfp_rtsym_write_le(struct nfp_rtsym_table *rtbl, const char *name, u64 value); u8 __iomem * +nfp_rtsym_map_offset(struct nfp_rtsym_table *rtbl, const char *name, const char *id, + unsigned int offset, unsigned int min_size, + struct nfp_cpp_area **area); +u8 __iomem * nfp_rtsym_map(struct nfp_rtsym_table *rtbl, const char *name, const char *id, unsigned int min_size, struct nfp_cpp_area **area); diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_rtsym.c b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_rtsym.c index 2260c2403a83..97a4417a1c1b 100644 --- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_rtsym.c +++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_rtsym.c @@ -520,8 +520,9 @@ int nfp_rtsym_write_le(struct nfp_rtsym_table *rtbl, const char *name, } u8 __iomem * -nfp_rtsym_map(struct nfp_rtsym_table *rtbl, const char *name, const char *id, - unsigned int min_size, struct nfp_cpp_area **area) +nfp_rtsym_map_offset(struct nfp_rtsym_table *rtbl, const char *name, const char *id, + unsigned int offset, unsigned int min_size, + struct nfp_cpp_area **area) { const struct nfp_rtsym *sym; u8 __iomem *mem; @@ -540,12 +541,12 @@ nfp_rtsym_map(struct nfp_rtsym_table *rtbl, const char *name, const char *id, return (u8 __iomem *)ERR_PTR(err); } - if (sym->size < min_size) { + if (sym->size < min_size + offset) { nfp_err(rtbl->cpp, "rtsym '%s': too small\n", name); return (u8 __iomem *)ERR_PTR(-EINVAL); } - mem = nfp_cpp_map_area(rtbl->cpp, id, cpp_id, addr, sym->size, area); + mem = nfp_cpp_map_area(rtbl->cpp, id, cpp_id, addr + offset, sym->size - offset, area); if (IS_ERR(mem)) { nfp_err(rtbl->cpp, "rtysm '%s': failed to map: %ld\n", name, PTR_ERR(mem)); @@ -554,3 +555,10 @@ nfp_rtsym_map(struct nfp_rtsym_table *rtbl, const char *name, const char *id, return mem; } + +u8 __iomem * +nfp_rtsym_map(struct nfp_rtsym_table *rtbl, const char *name, const char *id, + unsigned int min_size, struct nfp_cpp_area **area) +{ + return nfp_rtsym_map_offset(rtbl, name, id, 0, min_size, area); +}