From patchwork Wed Aug 16 14:39:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Peens X-Patchwork-Id: 13355320 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 115B8125B3 for ; Wed, 16 Aug 2023 14:40:15 +0000 (UTC) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2133.outbound.protection.outlook.com [40.107.244.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85A412717 for ; Wed, 16 Aug 2023 07:40:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kMyUAHmRdkOq6QLDp+zUzbNdTnszEPl4F6XzchmsIlUDtRNK69BK97+XgVu+Ow7yfx4Sk4M7yiFLOMkY1S+fWEEMimttPgNaYxEVd+cS2CQcgoXQk4wC5TrV9rnbEfL28KPU6WiHOTg66fQ4YxYV2lYut4Grz47iYjLgQsA6fr1eozAfTe14q5JZN/kh9E7jxOFV+1qmMHZjDufdXiRIHPyHJUdFZWWBfa1PF05/JuoYDQ8pOc5ntX3S6Ntybxf1vCLmusrC2Ew7fxo5ih3hDISimaVWwXYptHq/Y/KPe6DzVzIf41Cd8zIy/aWWlmJD1huWGJ7GoUUtVVgSN6rulw== 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=ffjTT9qz3/sjJsa1LeU88N3UAdQemr2WGc9IGaTwCWBs7u4xP8D2tcrMv9OCg7Lv8pMxTj9X9V2gM++FRvXVhQxW78z3EsbnRj4mTngp/JDe8Nam795nQLN8e+g35yTbtVgGshPtMXzuHGoHLphkFphq5PGILVS+SZ+DrZTPB1tuAoWKixDKdxeNcQNNPjjCX0YjH14qzfkXr9tCy7R4JuFD81uLGfgvTE0fQZsGVTB2C+304i2PKZtE1onmdAJ5h8giNeUDqUK8B24ovyCJca+O+JhxLmhwfZV25kuS3zYCtqwSyS2d+qRmgWk73xDF26aeoV61o2XTmmib/Gn7fQ== 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=r/chQkpy7m+4hR16w+yc45ijcofe3jYyYQ2jppxN0t6EINj4GMle7/Fjl3OLObL2t08y6XGhiR0wbMxWOJB/lA41dEBmnvg9Cwgoyt6AjuTNH3x5zjU41ZuW2UU0pGe0P5IRu+6dcDKLZXCFAvVVS2eFK0TWj6YV92LKDbx/yUE= 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 DM6PR13MB4097.namprd13.prod.outlook.com (2603:10b6:5:2a2::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.29; Wed, 16 Aug 2023 14:39:56 +0000 Received: from DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::8de6:efe3:ad0f:2a23]) by DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::8de6:efe3:ad0f:2a23%6]) with mapi id 15.20.6678.025; Wed, 16 Aug 2023 14:39:56 +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 v2 01/13] nsp: generate nsp command with variable nsp major version Date: Wed, 16 Aug 2023 16:39:00 +0200 Message-Id: <20230816143912.34540-2-louis.peens@corigine.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816143912.34540-1-louis.peens@corigine.com> References: <20230816143912.34540-1-louis.peens@corigine.com> X-ClientProxiedBy: JNXP275CA0012.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:19::24) 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_|DM6PR13MB4097:EE_ X-MS-Office365-Filtering-Correlation-Id: f435d6ef-d6c8-4797-c227-08db9e66a8e9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fAIXZyQBl5LUHQNaVDUH060JlS6VKN1zoJl8xKpVRt/eloDtCGdh3NWUWtBF7XfPftYTj2LMvt6Fq5gl+AmBLHjivfzlKDHGmHx82Ai7HEt1QWSwEroTZmO8jV4nHR1w4UjsIpqgUg2heAqsp+hC/iSWKo7CXqK8i5ErPaBqZKQZRfnUzO2kBpGHZQPTCw77uduzuPerC1sOc6FryqhkN/kcwLABFPW3nS1qO09kQwc4d2SF3+vh6VzEsKoKYd9OSPZvyBTieXAa99upU42F6zJQDfv5ys9Agaug3bDusLQpm1weq89t1eYbQSjJYa/0QNF+IOeUI67hlYYOl5XHwD82IjVPXUSdCliEQDEJ4NUAn170XSms9AWPgPJOtNxVuo7Q4XALpxLtD2Om9zzL96bJB27hGKtRM8a8x24TZBTquBUKNZ2Q+jt37ol/8QIC4uVoE5j/Qz4NAlJHnkjzM5an9T8Vj486uXX/fVXOldaWnNNgTOsKxsKriHc/JS1SFbeC9NhB7nTne5KErDRqimqhFIvnlCCEwVmNKZ1zpj5cDr067p4WdRd6MoWPPkJ87F6uBfvFPuwgdUkZZP+MjCnLDcwlxFotYr8jXkq8WAY24BYD6/Zkoq6cd7bKd7SEeygbw07Cea/DvtG0LvPjqcY22f5T8AqPF/VZAxmDy6NKoazR+jSXTVCPX4Jk7GFkpWEzgGSZTJl6Ic1M0/pokA== 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:(13230031)(366004)(39830400003)(136003)(396003)(346002)(376002)(451199024)(1800799009)(186009)(316002)(54906003)(66946007)(110136005)(66476007)(66556008)(12101799020)(41300700001)(5660300002)(44832011)(8936002)(8676002)(38100700002)(38350700002)(4326008)(66574015)(2906002)(83380400001)(26005)(478600001)(86362001)(6512007)(52116002)(107886003)(6666004)(1076003)(36756003)(2616005)(6486002)(6506007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?mx451/QES2umBYW6eVdJ4NJOoeIb?= =?utf-8?q?p/udWxqi/2yljkh+V1VGjeO8P4Z6WOHU9uLdP9QmEDrxV2QQnyVEXkAGEQbD++pgd?= =?utf-8?q?JuGDmZPZUcfkov+gH8MIgJNAZJlkQObcW2Pk69e6V5Xj9K/StREH7ItECGKSgHXRj?= =?utf-8?q?A5GpujKgNLhFlWljkL9M+Ube56WT6JMTr0Wt5XLXRxsgCf+G6O19FBO5NE7Lb7Jeq?= =?utf-8?q?L7POFbs5+FXxczCPAGjtuue0rD5bLoyN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hOLo7Qui2MqsGjdd05br+Pc?= =?utf-8?q?GMSg9+ffHn1zlQG1zNZ3sBWPa2cdKgmqKIMNlqo36Cb6VsYlDbyYTZaiWgzGVqi4H?= =?utf-8?q?07A3tdJALnfDWjvALrOWdPxzYLdpXel9FzWQKbMxpYLs43F7+flGF1qjH0zInnWnq?= =?utf-8?q?gOHUYLVrUGLsYV/eN4GAC9Vo2RCqLLQqUmmFuqc8f4i/X8K13cY/O70dV5RCRkk1v?= =?utf-8?q?jZ8qCML7PM/Y+8n7aflEBFGSWbL2lfRfC7ew4BwDp6lLB3R7+zha+O+2Y0Z/4ri39?= =?utf-8?q?WecxqdehvFVxtADzED3JjBjuPNxufOYuR0ie+TA2hQSg5Y99Ejg4E7iQcwHHEIgVG?= =?utf-8?q?99JpTX9C/Nmx5W3sOkC+mxS+uZP2xJMScVxTIcJnpTeygq4avZza7unl4YHfByxHb?= =?utf-8?q?PGl2Qf5VGfugulYPSEmdkaQz0Tixvd1x+Q=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: f435d6ef-d6c8-4797-c227-08db9e66a8e9 X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB4249.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2023 14:39:56.2043 (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: sKSKYWEqRDZhW38MtyBNorfDR4OffSG5DMobsDb/oELKJfll68w4UapthXi6TQT6erGF4GRjv7GcWRrPuqqYzyO2/eBCh8BGjAeuKxSht1E= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR13MB4097 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS 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 Wed Aug 16 14:39:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Peens X-Patchwork-Id: 13355321 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 6B197134A8 for ; Wed, 16 Aug 2023 14:40:17 +0000 (UTC) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2133.outbound.protection.outlook.com [40.107.244.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A65A326A1 for ; Wed, 16 Aug 2023 07:40:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XrpDnhLGp0oetX1Z9QESlJY1UDWY2NUFWijmuZHN9cK8n+3oMpd7lNmCWx/UktlLBjNoXTgX8Zi5HP56ni6kzY9468f7+e6ZWlvN/WIEpngnsp8PDRgz9aLrOEefWQ+MpusUk3YsjT/pPsaT0es5DeEdiji1LopCDsUHWpEc3kHFa9fR6mU2OQHS8vs/YBrfjyXWsufpQZlsySmZBV2XXqJvXGvsAIUUmMzysckwf9GHHmLcD72LTNgqoksHELa2cJyEdBZ3m5ZzX2QXGJgvp8lTjyOakk77P8uUavUybsjbrjndlpo1VRcwhqoBWxyGeWgJY497as5J2PbvYcc7Mg== 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=KvV+5lfaIgqN7goRxzCatfkvaVN+j/ySwvHElSLOy4NcUg0tzdQXT1wXAfVPNVux/6hugXVydD8rxgqqnSbaeV8Td3EBW5zSSh8nJIS2bDm5x+XSEbiTeFZbNHjCQTgJzx72vXkP2WMPtmrlbwGwXJVUMmMRH5QF84P1h1TWsvI9m9cjtjw84eAjmW6hmeTYI3zOn9Rob6j9ox+TmLJXFaompP4pMsK98WadWHUUCwNLutKtU9cWjiOF8iA/UmVSObUYf44jtl9lcdFNu7YBDigUCbj5vqvwYjonZd7evwXH8f08quLkTwsS2cjOCJK2kecOKaqMVu8IWWkIKmJtCg== 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=CDlUZzIVpC6BOz4GTHXw8mGxQ0URLwG4aAFBY+ILTfvNJRHKzlhxBgV28ie88tcNqAaGkHmHbIcJ+BPZ90up4wa13yOdfTufGjaZRsrZWBwYdIB99R0179kBuh+P/7b05ibhi36IE6slLr7EoeefRo30XgZ5kReU8ATzOWqdgZs= 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 DM6PR13MB4097.namprd13.prod.outlook.com (2603:10b6:5:2a2::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.29; Wed, 16 Aug 2023 14:40:00 +0000 Received: from DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::8de6:efe3:ad0f:2a23]) by DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::8de6:efe3:ad0f:2a23%6]) with mapi id 15.20.6678.025; Wed, 16 Aug 2023 14:40:00 +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 v2 02/13] nfp: bump the nsp major version to support multi-PF Date: Wed, 16 Aug 2023 16:39:01 +0200 Message-Id: <20230816143912.34540-3-louis.peens@corigine.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816143912.34540-1-louis.peens@corigine.com> References: <20230816143912.34540-1-louis.peens@corigine.com> X-ClientProxiedBy: JNXP275CA0012.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:19::24) 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_|DM6PR13MB4097:EE_ X-MS-Office365-Filtering-Correlation-Id: 6f0df09b-37db-42a1-3f02-08db9e66aaf6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nSjSPdCSXjNIzeeNNWNepPJXtV/V46QysyIF39oZeRxSp0b7Q5EAqtwyQi6FAoXdbvR1+ha+9eiGm9JWhymHxYTz9W9rPsTFUAhCEnfGHux/tT/CT+f11Vo8r3gMCLIlTJonFQdt2xXyhz9ySUXCDp2lTkedNXYqWAF70hOquMoOh37VAv6dOJWa90SElaUptb5B94cwFG2E6LZIkynAk0pAy5WeRUvhyXKrQ9//+e1zOlZWVEZp1AGuWemqWIFs1+1nmRf6rd1q2v3mdeaVvPoMFJ/B02hxreogM+nCaK9lRfAcrvvr4dWI71HD0opDH3rp5yyKYK2D7rgnJxLvRERSGFUjtmweuiFfLSH5vkvCLQaBfFjoTf2uPyt91YECoYdfNvYOCQZO5Am7nuDr2pFQRhsv0qfuL0TL1KPo5FJk8PJEDqp2G3JFBnJhmpxiTbts2gL1n3Bmuax+XOlUcCbCWYXC4PzfRw19BGVBrZUQnz2avboNCrmE/h0MYNVYMS7CmSOOTkLr8FHp7bkCjceJZGujutObkH6Ss4R8MkUmMpTTn7zG06P+BU7O6QKuETgbVHFfWeVaN/ecvs46MHjedWurlEJTJ000SGzOIVtJL/l+cPBZuOlrXgsB9VJj9RPMv7TaG8ahSsYjSlLvWksuhVaWXdsOiL+AeMfkHKUgV0A1lmDLJtKfftC6QsttXCMhBPSRj0UkEh/X9oupCw== 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:(13230031)(366004)(39830400003)(136003)(396003)(346002)(376002)(451199024)(1800799009)(186009)(316002)(54906003)(66946007)(110136005)(66476007)(66556008)(12101799020)(41300700001)(5660300002)(44832011)(8936002)(8676002)(38100700002)(38350700002)(4326008)(66574015)(2906002)(83380400001)(26005)(478600001)(86362001)(6512007)(52116002)(107886003)(1076003)(36756003)(2616005)(6486002)(6506007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?PZHZSmsdseAtczz4XA2XjwqZg8vM?= =?utf-8?q?ecEyjVhqdvu+2SlPPthhf+xwNQOxQZ4DcWXmuykpUJ27RtiddIgcEidx0tl2bzgvP?= =?utf-8?q?xnD+4Hub69zxJA4c7ngvBNYdDO88HJ4Mbzx8CJhy+w1/RNUrA7H64GnoPO/v3rM5S?= =?utf-8?q?MDRziD770pQDWxefQO7wwzm5byy3PEvhfdXxN2xxeCGVxKfGHgdCN7C4W5kO97Qri?= =?utf-8?q?aczWjyF7pAfht+RHS1dRiIWg8mAB70x32sxo10YuxzQ6Zq7Oey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dOtl?= =?utf-8?q?uZVye13CXn21BdoiEryvIPFEa977k1WC4tEN+OUJQhuD+PbSMi6epKiBxUdn+NS/b?= =?utf-8?q?MZU6e3P4tgJHConIQq3NRlz+hDNznvfSJ2F+uqTXBvp4U8pg7+UaXfqDiXP3GwRWZ?= =?utf-8?q?xf2OHwitOB7Fav0CWf7q+i32P7OqLy+whpOiaewqUm3kVQ022btya0dErzUr7kqX/?= =?utf-8?q?KrjdDYZ+/JQzuWXf4RyzXLYFGtaKNc1cIkwBW/6gb65385lU9W8mUTZjAzdrMseEq?= =?utf-8?q?vaQFBxW6p7pTm7bCdWkoYOKW/VD2Vg4aJuNL3QDZwv2D3VbECKRiyx66M8DpU2+DC?= =?utf-8?q?tmqnOVp91UPsyelAfOFFJS88iLrRISUPQqAsuPgpaTikE+9gkm/4Fj3eoThA4AXzu?= =?utf-8?q?sAOk1vNn28FZpNoG3Czo8fIsjMPqytILxg=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6f0df09b-37db-42a1-3f02-08db9e66aaf6 X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB4249.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2023 14:39:59.9727 (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: KaskNWxVWoBmYja990Rb/d6H5R4LbjclFCPRHPyjqUhQOzfY9ngnPKT5CKBxrcUQfGL9sjhKBMbcMyYy569TIMaj3NJEaHdQy6NqgcmwOgY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR13MB4097 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS 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 Wed Aug 16 14:39:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Peens X-Patchwork-Id: 13355322 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 31A4D156C8 for ; Wed, 16 Aug 2023 14:40:18 +0000 (UTC) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2133.outbound.protection.outlook.com [40.107.244.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A2C326BD for ; Wed, 16 Aug 2023 07:40:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BPIAaYEd3O6j0QHIErHlMFVmy/lTBl99vN9rKgG5QKORH2qyTv3+W+CHFD1niis0aBXNkP4tdurcUYUh9lBVa4v3xLXu4vn+IM5+uy0b3umi4yO+dREcqw+PtkNIj2oNE7oCdxMaU7NQsdDiSgJAFW8sDCpKIvgeTgCWu0oxlkR8q5rrx5EXOErIcLGYKnNQoHrra9KkhqXgi/ttyVLIR91Pxvps7kGBHrcdBS0385S2IV0J9BahPVIAc7470gwHJ2TLKDZTns7iyn1Jeha5+4veUW8VOF5Yrq+f6M4nbsQN43lGZzKviUHS9E7RBMiFb2kXV82xpWIZjYhov6Vxjw== 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=HWJgtBj36nnW8APwHHm2vDC7O2gVB1AQwmLNDoHmkNSR4KTzeIXWyRmqXnL5mCaXYkvs2xeFCNyg3j1BLIKMpIyqEpmRGXRNgXl2pPN9Tyz1V6UOh6mJs6sdkBnwMKKqsUWjF0qFZHE0rCOnpxZPVb1fcONS197oMbzJJgLdErom58h+x9sQuaDAunw5esc2WAFvdZFb3uTI93WBfL0oDVItq0uE0DYwd9h0HipbBKPFeEIiaa/R/tl6hpeX3OQp3XLXSlso31tl7ihXvn8AS8WJ4DHicNF9kBF/ZGHhhFlJDLkMXmts6qlraz6BaRoNluRyFIShyKm0sOPm8dXk0Q== 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=A7T3z7it13FmhGR0Ji1010pMntjbxZec3IkAE2nks2+fLVIfeldCrxIozvGYH587Kvt4X/qBBHEiIXrOYTI/UwhS8O/Z0Cl5h+ludlfsjUie8ucOsglkFkGHhTzGih+NkpcrA8RXWC1Vf7EqdfSrXpybT/KRFOZGZ7KZP/blyk4= 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 DM6PR13MB4097.namprd13.prod.outlook.com (2603:10b6:5:2a2::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.29; Wed, 16 Aug 2023 14:40:03 +0000 Received: from DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::8de6:efe3:ad0f:2a23]) by DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::8de6:efe3:ad0f:2a23%6]) with mapi id 15.20.6678.025; Wed, 16 Aug 2023 14:40:03 +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 v2 03/13] nfp: change application firmware loading flow in multi-PF setup Date: Wed, 16 Aug 2023 16:39:02 +0200 Message-Id: <20230816143912.34540-4-louis.peens@corigine.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816143912.34540-1-louis.peens@corigine.com> References: <20230816143912.34540-1-louis.peens@corigine.com> X-ClientProxiedBy: JNXP275CA0012.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:19::24) 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_|DM6PR13MB4097:EE_ X-MS-Office365-Filtering-Correlation-Id: 32ce89ce-cca5-4840-2eb8-08db9e66ad37 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VfishdilLOzmuRKdDhTfTkrTs2aKW2QSIP86hSjLYK2XcBzSJ2sX2MYEoioKnxCZKY9HZn008NYnnjhYkSMq5w8MxR24byJSi2UHyo7WTmGNebDSLBQ70pDCe0F8re1xQykw44k0QmUOluwFvC+AyEXx6NK/id8+mhA5L74J6hRKInUbbvPhqdTvI5aApAGSDkSewE1GYqvNaAF571YzrC4yAwvokLjsSF8hKm8vdXjD+ewrvLf8AzwVw1PLOk4TbNvVMMiJsaFXv6cjCjhoiAoPZmGds/PRuOoPVzcLD0/d6vOpVKxmtOqLYosR4c7DyiTZoSuxZs4rJKmhBYYkZ5Fm/PyFjoHML8uQDgxWp2PzGX4nAfD/BYlaZ1Hxs4ku5NJe16eKR5SRYr1VdFs2evQCPLnJrQ0FyCRbl4UiW5pyTyXqTi3BTCtojByMit2qEYrskxmfaPWWNNRBieCr/QBUlvIUUlKGaxAphTj5vmTWTWB8VorXeWC6Zwi3kKZ17dAkUO/5JwdlDkPg/iKacQURSgkM/b0XFa1zzh/7S/1uR6E7btoLLYNMr5p8SLT8NLsy0qO0NMjYS9n1B8ZOG2sSvLeLrviL3XQfti2QHi+9gm+FWtgVy1QQasVcM8s18kHK6vRySLpZT4p1AEQ74+ZskwWNYoanWTvHP0pz1CPdul8kJzpfScILaf4skAi/CUqioCzw6rmCqvUMEw+H7g== 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:(13230031)(366004)(39830400003)(136003)(396003)(346002)(376002)(451199024)(1800799009)(186009)(316002)(54906003)(66946007)(110136005)(66476007)(66556008)(12101799020)(41300700001)(5660300002)(44832011)(8936002)(8676002)(38100700002)(38350700002)(4326008)(66574015)(2906002)(83380400001)(26005)(478600001)(86362001)(6512007)(52116002)(107886003)(1076003)(36756003)(2616005)(6486002)(6506007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?zs2GplW7PTCRz/0p7BPhk9Ps3J0L?= =?utf-8?q?iyOK2YpoEQgqZ9bxjloJWXSY9iAZ/SpYp6tXDvEi3Liae4vxv8RecmFA3ctplDM4H?= =?utf-8?q?LWB41DtiLprVXHcPZZoZZa4tpnezg+YKjWa+dlb8T0EOug2LvBTmk97X47Fcr57Ej?= =?utf-8?q?8+Grc5/QIGj97pAi64V9jVmyHG/ZcQYvVG3ylKsVwKZVdYFd+7jINnDOsaL228CSe?= =?utf-8?q?VllDv1gP7ZzWv8/gb22WRRF6WvKZPXylo6Syv3nb893M4FlWk5qQcUGj401lANorc?= =?utf-8?q?UTUBNSFlki+jqu2JlInYmQ1uURJemfb+CdLgqXYNE6m/+T+yfbKeQv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yy?= =?utf-8?q?VaElCk2FnuIpJauqHsrRAKl9kKoqeG5uqEEWNLqCnNf+wuqCjPbr0je/67JhYumeh?= =?utf-8?q?3/OsmdXbZcxYnAQ+t4rnoU/xQnDOo+6b4q4Etq9SDNpXz4ZGrE7vkZiI61Lp7WkR0?= =?utf-8?q?E6wnMNXC1e4+P6S4kDl7U4BLtlJYBp1tyuyLkAu3EcO0SmCf+mWsZog5fegrVER7q?= =?utf-8?q?8efO35+x8sANc0YRkQMnMKhYdt2ClW31AkMCT8F04Qu+zAkn5yqyRtxB4gxaaFlLV?= =?utf-8?q?jYrFRH5z4N1RV+QqwqoJ/WTJ4zZfC5gxUlK88V8UCXNRJSPiKjldCtHzjw2Yzvb+n?= =?utf-8?q?bGWH5Hhf9v/w4mKfUnyMEzB5TIuHFoqfGw=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 32ce89ce-cca5-4840-2eb8-08db9e66ad37 X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB4249.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2023 14:40:03.4532 (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: Thy/AmE6yj1snlb/zpTJ1rgg6b2vhqConAb5+3x3QBRg0v+4NluvyulORPUxTS84+ME8+bJz7s0IsA0Ce8AY744JZwu9+vmNH3+71xO1BhY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR13MB4097 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS 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 Wed Aug 16 14:39:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Peens X-Patchwork-Id: 13355323 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 85F30156D1 for ; Wed, 16 Aug 2023 14:40:19 +0000 (UTC) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2133.outbound.protection.outlook.com [40.107.244.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EDC82715 for ; Wed, 16 Aug 2023 07:40:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iqdOJtyulPea5UBdfa0EgDIjHG9/8T8NRfTsNlWX8bGQq1+lCfV9mm7l0uTCOiwd0j1ogWapAK9ImstopyBinE2xG/CQlI6pv+to1nhr5jAIqI4/EXuke6fHwypQcrNjAYL5wUQgF1VbrxsUYNOrN+7Q0Zw3N+Jmk5egdl3ujO42AFo9ye89g8g79aNZUMvJ0XPAvhpqfFGQOqiAmmLGjfyJFh4VFGcYHYnx2QCDRTBzyy00+Wu9G62cK+CcFZQXLtHrs9o+7m9S/LLxTmm5D/BeLVo/B1/GAg09KyhSchxp5HsuSSTb0GMnAcoQuWiX5CYFYfd6tI83Iw/w3Z8uKA== 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=BBSt9LV+loSerSqIwIowMjo8ofr6YzVldhKnZcWCwv2zzNsqLtlp19JK8y0wb2TVNSXEnvuvBRZcN5ROZOuWrz57yyedDC4VoCU+mmaln93TroeN40LCDGh+vjacuB6VUyVlZoprhKvKa5Ux8ugM8pw2+829z3lhRrUh1VY1CZeNO6qwpHgNEOmPoDaCME1IOwwnjGGC4hu6RSrwSF1szyvzgClPBNnSqTVGrrLJHZ63Id4Ip6gAnn53UwJcqfarcesIIr4JzSvmQeITjTXV2D5S6w1VbcSyCpjmiyKeBiN8B7xy9JP8/KW+1pZWlzod19YVdp+Ms8cltVB3du+fAw== 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=sIozy7YsPe/pNy5Nz2ONEwVMyP5ztDjWPTVMf6prY+Mf3ojCpincilhddIr9x5le0VGAHfE7PO5kobmC5pT2zIYNlQzS/HSlgWVqqRLszDm0QxBeEV/GXFajKGihfR7efFr8Q9xV4qaar4L4c4hJJiHUghIX9DgRR6Hpmao8usI= 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 DM6PR13MB4097.namprd13.prod.outlook.com (2603:10b6:5:2a2::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.29; Wed, 16 Aug 2023 14:40:07 +0000 Received: from DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::8de6:efe3:ad0f:2a23]) by DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::8de6:efe3:ad0f:2a23%6]) with mapi id 15.20.6678.025; Wed, 16 Aug 2023 14:40:07 +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 v2 04/13] nfp: don't skip firmware loading when it's pxe firmware in running Date: Wed, 16 Aug 2023 16:39:03 +0200 Message-Id: <20230816143912.34540-5-louis.peens@corigine.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816143912.34540-1-louis.peens@corigine.com> References: <20230816143912.34540-1-louis.peens@corigine.com> X-ClientProxiedBy: JNXP275CA0012.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:19::24) 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_|DM6PR13MB4097:EE_ X-MS-Office365-Filtering-Correlation-Id: c919b95b-911a-484d-1e66-08db9e66af78 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: I/+1aufTlL5bTEsFHos+el94BXlj4ObImU8Ot8DcFe3q2Q+p3MS3RT+SkOq6MJSdHGHc31hAC523IBFsTRvCYEs+RUdbE8IKqHz4+iwPmeNbeEaBh3PognYz2NrzLqQ7ueki7pWdLraSvp8Q+nGotJpV1r2W7lie6wFxcAsOReUGQCu1cxEqBkdkWMmx/1ttgqdCrWmjo1bOFg/cLfn1iHE+dt+RLcxEkySBwjEHn3PDmevc0CDf400xCLwCr9bzoSZzcdsBFeQNurHMNNcq7C7OHUnsbGhMvt5rSfEHBy7ygTNccnkeBw9RkQJqxOQ+hIz3Xr1xucdbCDqFU7paCepo6uyvwjhLtTPFYPvzqHwilliF/d4RnDPeB07/WpszJ+qWGogNeWO424bdU+n45q2mXbSY1Chu4DqrjysLdLk9VleWseRjQ0p9viV82qUZlM5k2S3HioN1KuYYTJcvbOcxG1LtsaMQa5HDb4hA8CP0yM/6hx60S7p+0GN+TlblxU6V46D0cZeP0axCnoQjBpO3GEFjmWxibVqAmnV/kBpcx4vpamwmZ2teQ9xl/lZmUh9uFUko2lXtoKMpaME0T8eN2burOGwBIVJapkRDUkm/xuuGQZ7fkKKdsevTDB4lxEN74wBR4mIa9qSRs+02KloiEEx7Ml28qPUvxPcfF5UFrAe38cpSZt3PLp8rSK1evCsbNdeyfBqOeFsgG8URaw8BfdCnjJzbUgopCqPss1g= 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:(13230031)(366004)(136003)(396003)(346002)(39840400004)(376002)(451199024)(1800799009)(186009)(316002)(54906003)(66946007)(110136005)(66476007)(66556008)(12101799020)(41300700001)(5660300002)(44832011)(8936002)(8676002)(38100700002)(38350700002)(4326008)(66574015)(2906002)(83380400001)(26005)(478600001)(86362001)(6512007)(52116002)(107886003)(6666004)(1076003)(36756003)(2616005)(6486002)(6506007)(309714004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?B7hgFE1n/NYfi9WOOMzfYGVjCdm7?= =?utf-8?q?ZK9VhuwC5Fnp6bzFgawRiQJscaI/sqMQSiwltZLEKeJbVz1s9mmZC1y13gBHFLFzU?= =?utf-8?q?CEbhunKY+hWPl+3AxBBHK65aBA7sAxYIBeTbgCUvf62kPmvG3gA1FVysVgUdTlNGA?= =?utf-8?q?B8/r0iuc8ISDtvJ51M4QhoDSUQPI6PTTwanBJLTgaoUgkg5FpnZxtKpB+2CtJDeen?= =?utf-8?q?bGEQcuE3UMl4OzAo+HkZjOypLhh4eoCd7P1h0JWxSEM5dtEdCO013Ya5OH7r49Sn9?= =?utf-8?q?duporp1oqRZkpccLyFOTn/72lkOUsXuM+rRSsQdJ7dFJyYLHJujQfmq3Ws6KOyW+8?= =?utf-8?q?0if+zgRuoWpeiq5bfVhXPrfQtqL394jL6BXYXIcw6iKZTfIaEHuliX6z8ri6Z4kV2?= =?utf-8?q?uHSyHhSJnIOTr71rppFETsRugHC8cNcdbFstP2mrc3Y7O7cq2x6p3uH0b9Y3Cb2Ys?= =?utf-8?q?tfh0PlZJOqA9V3HmSLwwCs3BhlnSUPEdFS3ERgUEPsGUCKf2NnxZzrx530DpSMhEN?= =?utf-8?q?lL7X2ObzY6U2ZBW21dfup17TgzICGFkRTEejDYo7c+MHZjvkUKfTiQvVORp1LsZ+M?= =?utf-8?q?ETzBqFPIuWn0nsNE6M+RF4iAYMwzFlmblWljjwq2Ye91R+pP9nyOwQ4EI8vTydfnX?= =?utf-8?q?wpfLeV+1cXQchZQQhRK5YzHnvM1RyKZxrT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3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: c919b95b-911a-484d-1e66-08db9e66af78 X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB4249.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2023 14:40:07.2269 (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: CU5rAtctOdHonTPMLnqEldlJ87Z8JdHeTbQBWBd1vBgTOGpMBUnIM1217gneMaOQI4ANTcHQkcqcwQGL03qKeOelMw7taZW6n8vEs8kagr8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR13MB4097 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS 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 Wed Aug 16 14:39:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Peens X-Patchwork-Id: 13355324 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 7AE9B156D1 for ; Wed, 16 Aug 2023 14:40:20 +0000 (UTC) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2133.outbound.protection.outlook.com [40.107.244.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 697B3DF for ; Wed, 16 Aug 2023 07:40:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YBsCLWi8qAoQNX4ErRxXgua6RBm5MGwr7CFw1tGYD4dfG+BKZZZLsyuwkrfbCNLV//PGx5/trVEknd1+o178KzZsmMre7u90FKgxyODosxHT1B1A1060wDSpx+o+n+QP9SDZosHuj9Bw4VBnjGaB2X0N1wrh8NnIQOygVP4I6M0VJ3+b9FzgEFtsHJsqPDk43y6rfCzosVX/wJJ/Mrv30WqfOV+lHi7bowjDUdbXQjzrXur45Dsy09a06R1Vs80Y/jPhex5D4ErzH18gjel5APRgymtotAHyXSKIXAcDw8gv4EKM/S7E7ZapozoxGYjHy+CGCcPzz1s+BQzPNfKLnA== 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=pBlNZmNO5a070nckayBvpOAGIsAcwrvOv/jNrAKlHbU=; b=Q/Od989EmMYMYtMSlagEfungHB7LEhBLGQ3qMGiAzLIA3+53ZAE0qCHtdFCxjCCl2kPB04ts2KMpKhtblmWhD95xiD3pkJjYbbQCG7BPIwKtT770ee615DYvKgKfMWNtgfvULxV0OggiUolu3Ht8N+V05QXvO8r98Ijc/nqfofLl6LBA2a1JnYUYnglPaDNngm6FMmPUThyIeaNp2jlKDyvJPJqfwWxopr0YL+B2E05PYWoN2jjDAfCHYHVfgCs2oQ0Fk2RvNu1f0Hl9dd7Nj5dciG4WpLy0N1MVGIUZDr8Yxgdmt611hkB5piFHrwiwdB4e7YNaXFBJcLG52IplZA== 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=pBlNZmNO5a070nckayBvpOAGIsAcwrvOv/jNrAKlHbU=; b=HgV9xDSx/QfsiZR9TgX9xMRNWjLkBDtqx7fOrDQ9pjeVSNSpPG93C/HrAcNld8FpCxw0J99FVtIpPNUxEYl0RdqZu/GohdSdLUIumRIORETmVGlzS2xMjPjXZm2U3qQN1VwiNDQY17mZf9KXZQcTem3ldq9SzrVg+OFMQ8Ah2BI= 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 DM6PR13MB4097.namprd13.prod.outlook.com (2603:10b6:5:2a2::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.29; Wed, 16 Aug 2023 14:40:10 +0000 Received: from DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::8de6:efe3:ad0f:2a23]) by DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::8de6:efe3:ad0f:2a23%6]) with mapi id 15.20.6678.025; Wed, 16 Aug 2023 14:40:10 +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 v2 05/13] io-64-nonatomic: truncate bits explicitly to avoid warning Date: Wed, 16 Aug 2023 16:39:04 +0200 Message-Id: <20230816143912.34540-6-louis.peens@corigine.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816143912.34540-1-louis.peens@corigine.com> References: <20230816143912.34540-1-louis.peens@corigine.com> X-ClientProxiedBy: JNXP275CA0012.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:19::24) 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_|DM6PR13MB4097:EE_ X-MS-Office365-Filtering-Correlation-Id: 3868b850-033e-420a-fd8c-08db9e66b186 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PSNfElvPPiDE2bCbZeFqMcWyIxswCduqRTaXD8d+nSIAooDw6qiZ2eyGAKaqHFQ5RVLX5HPlNWbaOo2B4f9rHFE0WHs17MlApA955uC4ZbrUi4udk3vrS3jbSH9Jh/ippAKp6sfnbGmutpaPxHxWyjg7q5Sc9U58k5ZmPfiRV4j6TYmTJGynQfiw//NRcvCZaX257tbegPHQflDnv1VenxrdCS21YCXVyaOG2b6XPDiUuXl8xawCdHmOdj2U4RDW9kxJe3Qso6f+VL4moaRcStFePw5yZywLjC5FFAqssLTtdMmrQwIMVme7tpa9sQLvzSxfQgKuaGpO/kMbyXZs6AVBkrFx6izRrNY94mvB1/SHPnNvC6BtQAfbr46NUWbWUTXwxz2clti8FQhu80ze8AOk6obNf1PJmk0iKrNe4W86e1nszt/AEI4TqLXYIDE3E6R7G93mVmxokXHrz0C6zkWdegwFdlLv5CNxcGg/Me05sEAn1Daxwae7Dh+JIzCIpW6A8Iuv4FPpnlDADlOf3JsUHVMWv/DNOjGmIOTBvw+Kz3giYBHYtvQd9MUb4xuhbtvrVLyEVHj2m0Xjsy+pN3Inp5PZ2Ew8JG4hAQkna2As9JawwnBkYG5aMNaLJL63QxKcpeFeNRDNlYccv9odTPrMx6cNxpkWA3kXqR6d9YOqtQXgbPp3Iy1PIeMjxc6V 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:(13230031)(366004)(136003)(396003)(346002)(39840400004)(376002)(451199024)(1800799009)(186009)(316002)(54906003)(66946007)(110136005)(66476007)(66556008)(12101799020)(966005)(41300700001)(5660300002)(44832011)(8936002)(8676002)(38100700002)(38350700002)(4326008)(2906002)(83380400001)(26005)(478600001)(86362001)(6512007)(52116002)(107886003)(6666004)(1076003)(36756003)(2616005)(6486002)(6506007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?2LD+bnR4JddbvMXfBp3CinqNErmR?= =?utf-8?q?VAIhxn5ho9f/8xAS3HhrRv1ZvD0HTrn7mvkRzkHspNawdDSR/xhuHizCMC33mSwd9?= =?utf-8?q?oSYnyiHrhQLow/Y5/DyrJ7hT+MxEOTsjy9Q7wMa/a768T5wszzqzoIfQ5DBIWLRZf?= =?utf-8?q?15gnuIrtSJOwiFsgZ4luZycIANrUIk/krml5OyrqRbP0HlChTUt1KkEYXaQ2xIQJD?= =?utf-8?q?EjFSmDSznNWj3emyIPqTUIiLhrkZKE6ctUfensYPuazy8lr0mLPLmvd1mw3Yw0IrB?= =?utf-8?q?RHRavw1mRbgSzFWI1ZwAS2rlOhVyRlyMSGmJ/z1x7xR6x6K1GRQ40Kt5/y682Zc5S?= =?utf-8?q?QeVvSLQ/NnFARNWCFdsanuFFxtZbXxp6kYywluMdu+MEvvIaviVYbpmaf1QfBpx5n?= =?utf-8?q?/SH+2Us99wKh/fj0pDDtBFF5srzUkGJLNrv1kmGp5yN8zvq0PtK1D9Vv+cmyl3W96?= =?utf-8?q?YVVVQiAv7wFFkNO3BSyFrhiDusTYWCbfCHGF+mpHfkQ/6uBK3gRzl3XaOJnimCj3F?= =?utf-8?q?cYQEX0mlhImctVdcE7OeLo4F84N747uGjZh/UKfRM/aTGd7HOyHkzn95rVFl4/q/x?= =?utf-8?q?tOzdie2zYwquN2UP9MTYReWLmo3Cumk181gjgL8r8e273dDpl27sX+WsmAFj1b65w?= =?utf-8?q?tCfP5Z2SpWhDMKde5r+MPqVmewGeGWLR+rovnNAkNuWyySkGudwQ5MfgHSu7VzS7n?= =?utf-8?q?vNoBknmlGuDaf195RX1njwWNCD6GfBzlctlXVu7/9LXygTTTbif0z5QGMePFD/nKG?= =?utf-8?q?9iSWr504ReuSVMX2/YfYY7vEJgQy8tyKx83RlAwaztRKtylEyWpb3tdN+CGvjVg7d?= =?utf-8?q?iQXZt2fEpeMJjJU3MvDPU31rUF+ub9z6YHjJjcK6BMX3abFRw+CYtApHRCto6l1xu?= =?utf-8?q?V+zqDCcX3OusiVC/yXZh0PjICm/k20/m++StslG2CQKUbJ3hjCwyDtOBUqJPPDibq?= =?utf-8?q?xopY/CUKhWQS93sUGaEpdluG0GX3q2YG/Jcdl8O81opINHCxdMx9T5PSQ/iO3b5VY?= =?utf-8?q?7C5bJStucKjDojL1EZweJ8j3QPGkwiSU2DPYMqABCWTmY4fYIP31CuEZtc1+NuZ7Y?= =?utf-8?q?3V4PTaYchoBrAUvCbzSmM+6s7IvVSuz7gGIA5shgARVo7e7pdFwOz1XeihEgeDdMb?= =?utf-8?q?ngVdx2P1SfTW4aE++sPCfab9xL1T6RP4OwYGyN1HtjrxdsfkdVwA03ZpeH77wC7jz?= =?utf-8?q?N46f/PUgIcI9poctP9Cz4F2l+m07856/H8g42RTOhegOiaQkONjk+mDPrpGI1iKik?= =?utf-8?q?upQA8vX+OBspY5xZJ9UfVH85tC24MGUFW6BY0yQDFzwUu3F+bYWfCXWqiOSoYgcLC?= =?utf-8?q?DShuy7R0cZDCn2HFBwEsxFr5sWOaJ7v6y3O0mrKTSW0ir1yAHWriJrA4y6u+tUMVT?= =?utf-8?q?lE2HZKVFThgDBCzUjMBCFYC8+xzOSnwZN9D+7gz+Hn4ff/U9wCls94BoNrbqd6Mp4?= =?utf-8?q?xb1/t1B/Z7kHN3shjNfw4FO0WvCYM4P56vtCd42MLfS6gC3CCI57pO3dAi31rDN0b?= =?utf-8?q?aPBA32oZsmNgy4qtQvVFUTV9qIG60XcJ+A=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3868b850-033e-420a-fd8c-08db9e66b186 X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB4249.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2023 14:40:10.6969 (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: 5OhhGDd1/LjnMx7AxJc7T0UdPU8D/vtqeTsunhv/4ayzqcMcRxhrqxdKh8msUk5MTeVLnPaCNERCELiNlKaCedsfYbC5eWHMDn8sllpBKOs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR13MB4097 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS 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 Sparse complains when passing constant value to these nonatomic io write functions: include/linux/io-64-nonatomic-hi-lo.h:22:16: sparse: sparse: cast truncates bits from constant value Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202307300422.oPy5E1hB-lkp@intel.com/ Signed-off-by: Yinjun Zhang Reviewed-by: Niklas Söderlund Acked-by: Simon Horman Signed-off-by: Louis Peens --- include/linux/io-64-nonatomic-hi-lo.h | 8 ++++---- include/linux/io-64-nonatomic-lo-hi.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/linux/io-64-nonatomic-hi-lo.h b/include/linux/io-64-nonatomic-hi-lo.h index f32522bb3aa5..60bb802d4f23 100644 --- a/include/linux/io-64-nonatomic-hi-lo.h +++ b/include/linux/io-64-nonatomic-hi-lo.h @@ -19,7 +19,7 @@ static inline __u64 hi_lo_readq(const volatile void __iomem *addr) static inline void hi_lo_writeq(__u64 val, volatile void __iomem *addr) { writel(val >> 32, addr + 4); - writel(val, addr); + writel(val & U32_MAX, addr); } static inline __u64 hi_lo_readq_relaxed(const volatile void __iomem *addr) @@ -36,7 +36,7 @@ static inline __u64 hi_lo_readq_relaxed(const volatile void __iomem *addr) static inline void hi_lo_writeq_relaxed(__u64 val, volatile void __iomem *addr) { writel_relaxed(val >> 32, addr + 4); - writel_relaxed(val, addr); + writel_relaxed(val & U32_MAX, addr); } #ifndef readq @@ -73,7 +73,7 @@ static inline u64 ioread64_hi_lo(const void __iomem *addr) static inline void iowrite64_hi_lo(u64 val, void __iomem *addr) { iowrite32(val >> 32, addr + sizeof(u32)); - iowrite32(val, addr); + iowrite32(val & U32_MAX, addr); } #endif @@ -95,7 +95,7 @@ static inline u64 ioread64be_hi_lo(const void __iomem *addr) static inline void iowrite64be_hi_lo(u64 val, void __iomem *addr) { iowrite32be(val >> 32, addr); - iowrite32be(val, addr + sizeof(u32)); + iowrite32be(val & U32_MAX, addr + sizeof(u32)); } #endif diff --git a/include/linux/io-64-nonatomic-lo-hi.h b/include/linux/io-64-nonatomic-lo-hi.h index 448a21435dba..b73acd377507 100644 --- a/include/linux/io-64-nonatomic-lo-hi.h +++ b/include/linux/io-64-nonatomic-lo-hi.h @@ -18,7 +18,7 @@ static inline __u64 lo_hi_readq(const volatile void __iomem *addr) static inline void lo_hi_writeq(__u64 val, volatile void __iomem *addr) { - writel(val, addr); + writel(val & U32_MAX, addr); writel(val >> 32, addr + 4); } @@ -35,7 +35,7 @@ static inline __u64 lo_hi_readq_relaxed(const volatile void __iomem *addr) static inline void lo_hi_writeq_relaxed(__u64 val, volatile void __iomem *addr) { - writel_relaxed(val, addr); + writel_relaxed(val & U32_MAX, addr); writel_relaxed(val >> 32, addr + 4); } @@ -72,7 +72,7 @@ static inline u64 ioread64_lo_hi(const void __iomem *addr) #define iowrite64_lo_hi iowrite64_lo_hi static inline void iowrite64_lo_hi(u64 val, void __iomem *addr) { - iowrite32(val, addr); + iowrite32(val & U32_MAX, addr); iowrite32(val >> 32, addr + sizeof(u32)); } #endif @@ -94,7 +94,7 @@ static inline u64 ioread64be_lo_hi(const void __iomem *addr) #define iowrite64be_lo_hi iowrite64be_lo_hi static inline void iowrite64be_lo_hi(u64 val, void __iomem *addr) { - iowrite32be(val, addr + sizeof(u32)); + iowrite32be(val & U32_MAX, addr + sizeof(u32)); iowrite32be(val >> 32, addr); } #endif From patchwork Wed Aug 16 14:39:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Peens X-Patchwork-Id: 13355325 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 F3B9B15ADB for ; Wed, 16 Aug 2023 14:40:20 +0000 (UTC) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2130.outbound.protection.outlook.com [40.107.93.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BC17E2 for ; Wed, 16 Aug 2023 07:40:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LhGVP2K7qW19hR9P9IBCJMTYzEgiANA2ttRMIIxcUL19yDYwTSXlmJQwOMF2FigJaL5TQVwvGH7laTBaHPPMr4BclaBOD5nS5IebUv10SjCeSO5wj/oiutJjtqhioYKnUAfsvhmOyIV22yUEBxZLBfJfYhpFFkdMVgIXv33wMVNFpJ94jdghhotwRD+yB/KjmW6ArbeVqupKOr3XlXnvf1UxvHqIVx8Lt4fxp0nkKNgPV4WfOIzVxSQpVkgOJYCPKkhKI4YCcBULQn7yPq2i5kWSH60+uxaECBL2p+WvbcF/fEQZ3j+RXJPycm1P5c+C/kowu5ohi+cfskUH+B5leg== 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=anIFKhHJ1IRIpWnRHaIvQDLAb5XScGx39bPjrL0KnulwsJBdGKF8LKTTv1/YXBAtNbJTU/gD1rvQpWXXBk5AxJFU8OopNt8QO9X1Tq6kZiJPkFOo3bE9+Dq+dj5HX9pYQTYHiv0jmjjIbt5qZpxz4mBhjnnGe4KdIqgWr6fBNPvfAmogVYOStMhLQm4X+xrt+3E3qL6Mic3TmYPTj/XWkkUp0JJRnwBBOdh7y1c7ferKaQ40r9uzVtsAXOzSvqN3z/e1xvKvV4PHieuRnLZWYAXdRRMUTz0/jWOfbIeB1MrJXb22cuaX3GC47HvIPW2WbbPZg4CyUBHAsFZGBX+kIw== 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=Pos9JlGL9x4d5+Zw1ewXCbXf8d7juAX7VAaVfNCxCS2Ezru/3cLhR/1BTS5QCCg4PsS0zGoc0ENRqF5H+fREUPjGRAXGvDDMf7Mrd++RnCq4y+QYiZ+kTq7UgtBnIFB9alsqQ0pR0QI1rxf0fx8SNAcmED/g+wEmxqg94w40s7c= 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 SJ0PR13MB5451.namprd13.prod.outlook.com (2603:10b6:a03:425::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.26; Wed, 16 Aug 2023 14:40:15 +0000 Received: from DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::8de6:efe3:ad0f:2a23]) by DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::8de6:efe3:ad0f:2a23%6]) with mapi id 15.20.6678.025; Wed, 16 Aug 2023 14:40:14 +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 v2 06/13] nfp: introduce keepalive mechanism for multi-PF setup Date: Wed, 16 Aug 2023 16:39:05 +0200 Message-Id: <20230816143912.34540-7-louis.peens@corigine.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816143912.34540-1-louis.peens@corigine.com> References: <20230816143912.34540-1-louis.peens@corigine.com> X-ClientProxiedBy: JNXP275CA0012.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:19::24) 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_|SJ0PR13MB5451:EE_ X-MS-Office365-Filtering-Correlation-Id: aebdb5e0-28a0-4252-7a52-08db9e66b393 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 45BBWQeRleKKrDMXlISP+vreoDKD6PY2XM2FTL03+NOwbvuYD2Ey834AojaNxVEGRLMb7tG0AHEvR4kuQ7IlZ+QBl+oYfpUrLlX1YXmIzAd8GWtqZ+fZGJQRFqBfEa+++VfG0K+mfV12o7fgfDZsVd1Ca8WewrpDJGgeRvicfQqX5HmKtq7DL6PkS+vq9280iJxcoehYFAX3wK9NqAkJ+UMKD6usKP9VdSZtDh0ZiN3Yqv3IJTZRJzy0yK+yZNXaQ1+k50zeK9/JCd2DZZl5P7yKWE1VugxQ2X+4XDMR2ayID5zyaRvDpufsAaH37TcISnhCY7IuEt5mEgaDYOYj9qkkebwemL5+liNTQwu+Lm8YF2rDjA/CMVfvC86fHFROXdv/68nJ9bDSCi2qb/qUQwZh3p3ffKjqoE+TSRH6Rdxoe7QoogEx7lDN4iTZDYIJWIhQQZpFvW7y3nWeR8sM8pEoYWZBojrwKpf6jZCfrTgf/t6pE7HUJyOtxDHjsclSvqqZiRAIYisF62VWUYCQTcJ397wfJSv2o2EWawTPxNSM7L3VRNKu/+dcuT92MfKnst1UyXvNiX15Bi2YceeCykUPYYfia3eEEIxdUn2p2k4Ts0B7y9oE7ONeL40aKE8JNq/OTwEKGnAAnQ+v3kc15ou/Rlk/nzECVI2pjrsOZBhh/vV8o5vvoBF83wjZi0sH 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:(13230031)(366004)(136003)(396003)(346002)(39840400004)(376002)(451199024)(1800799009)(186009)(316002)(54906003)(66946007)(110136005)(66476007)(66556008)(12101799020)(41300700001)(5660300002)(44832011)(8936002)(8676002)(38100700002)(38350700002)(4326008)(66574015)(2906002)(83380400001)(26005)(478600001)(86362001)(6512007)(52116002)(107886003)(6666004)(1076003)(36756003)(2616005)(6486002)(6506007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?ut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wzGVCHViLywnmnSZBTFDW0o4A+pcURzadMLxfOKQt0J?= =?utf-8?q?ftB7tzskZ6d90jsRGHni6pVJm+EB6jvkVq9ftHUv8BJNv0/sBXeuivcJ4yAhDuAqG?= =?utf-8?q?4dmr+wLuXK/7Ewd+DTse7470YqFGr3WjhcT54eq/8Q4vaxrYkxi90b4MHFSKW/2e/?= =?utf-8?q?Njj9FHrgby6Aya8r+Uosl/HOPSX2ze5539SsIccTBEbaFxGll/lgKeXMmNbbY925u?= =?utf-8?q?6VE3UwAPbp5Vvk1XhVM6iukq4j2LFsDrRDidimO+5HT3FyyMkQf+3dqCUEZj+e2yT?= =?utf-8?q?sXT6BMHBNjqshgyBVY1WY+/EbeU6Lslkbj3bIJg7XcyD5i7VQy6LhM5LNQd4FgGBK?= =?utf-8?q?Wgl+zn1wB/A5j1kum+MDmnLlMmgmAIxdvDuMsTby52cVe9vzpyaZtzOLDXcloCs51?= =?utf-8?q?jYx9vpkEPY54HzUMX1GpXI836N+ArPYAA/vjJNR+pwi8knkBnHTNgZtQK1ihiFQY1?= =?utf-8?q?p6PSel9sbyMH7T5nZAvkxjqrbAaimdjQwXwLbs0MPneQlMjXA7AybCGjLR61pdSOd?= =?utf-8?q?yGGkSXBZqq0zjz6K//BgsYkqg2X/d2EIHOHGOJmlAZ6GBjWPd8nhsqILb/CumEztP?= =?utf-8?q?6jmFZlDwhrSkidtR7lFa2q9UZG8laEmaJ1rSdvI34BwTU/vawEeA5E0GAbcHbg4hp?= =?utf-8?q?Dw6/aoCI2qLtULWXw1YkNgq5z8/jUUrzWg=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: aebdb5e0-28a0-4252-7a52-08db9e66b393 X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB4249.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2023 14:40:14.3996 (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: J+MmUOSfFoQEf2ijpioSnrnA6YYHr5ReQc7CVEaVGIOnjw//6bfsn76RVRvnhZMSAoCbw1Nt5Mr7+W0Ow14qoDxFjiiVdggBB73NgODEL4g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR13MB5451 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS 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 Wed Aug 16 14:39:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Peens X-Patchwork-Id: 13355326 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 5938716400 for ; Wed, 16 Aug 2023 14:40:22 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2091.outbound.protection.outlook.com [40.107.223.91]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73524E2 for ; Wed, 16 Aug 2023 07:40:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=at+zCVHaPCOE8S/ESb145492qzCpYNdLv06SB7+/gcKBOiXDJRsY6UD4u5ElGN185WUw1F8T2pppiQIa6mlI0vGmjO9aEPQo6PMQ3yLfeJJzkNdrCWXfYGj8D4Tu90BOJ+l0qe3HOYlqUBPcihJnnoYKjHhb7iIfmS/qakmY5pgAXbfcnUWE2Payz8Hx1r/B/z6HeMdwQ1vMtEzJKswGt9A+ehb9jUzMYqS0XbAD7I7faFIuHpkLpcvuaEaabJCiltN4Zqu3CGT69FU24f16Wp7MFJ68hWElZsZ7/f54mJyjD9LPxSoodVrReFx9dVewjVXWC0Br/pJaY7A0s82zLA== 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=Mpp4Z1YDB3RCTpVOHRPtm+U7rjvkakLQMuYHNb4mnYY17W+UGe4AE4cSTVbHWBxyHc07NV845NLWnym+oMB5zRXNdST7g3w+0Fp/2JZ4Q4KiJWsR/xGbSJlPLqCYxkFhgjb6R7pKGCgB0ZwaVoZdcgMaTR/TbVBwov1/l4vX6V1odXAlVkgkWwyGYa6bS5oniT6iucYQ0iH8XQmWN5c6CzKnOSfUzIpAN5KzSgS6U7i8Y2DgLIxEnh6oOjEU8ww3XCs8AFRLRL6F95LBJTIhQIok5xDORrjp1atFHhQFeQ0U0gO2n2tQQ+lcOfZmHv5pir65KnFEnCo+8E749nahtw== 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=LlpqvNWCE79fRMIxuN1rdZwnxP48m6juKknF6PC10kirjF5Qy7pfg0fiku4jwLmUGOwDcrmhUbKk3XBi2JYVgelTcsoSdw5wEOn0yqmr5n6OP/pcSYnkj9KD/sjDOuxWXtjds0Twb9OsmY7yuIDk8l+KM/gLy6xCtxmmkZ34HoE= 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 PH0PR13MB5004.namprd13.prod.outlook.com (2603:10b6:510:7b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.30; Wed, 16 Aug 2023 14:40:18 +0000 Received: from DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::8de6:efe3:ad0f:2a23]) by DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::8de6:efe3:ad0f:2a23%6]) with mapi id 15.20.6678.025; Wed, 16 Aug 2023 14:40:17 +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 v2 07/13] nfp: avoid reclaiming resource mutex by mistake Date: Wed, 16 Aug 2023 16:39:06 +0200 Message-Id: <20230816143912.34540-8-louis.peens@corigine.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816143912.34540-1-louis.peens@corigine.com> References: <20230816143912.34540-1-louis.peens@corigine.com> X-ClientProxiedBy: JNXP275CA0012.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:19::24) 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_|PH0PR13MB5004:EE_ X-MS-Office365-Filtering-Correlation-Id: 32febcce-b8c2-41dc-1c2e-08db9e66b5c6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: h25xjBykcoEj3qhc1b+ySYz6+PRCDXXMUjfbBD46KjPfqiRebcyL8lCH6F4SvM9Pukhlo2Xzpn9f8q5c+KhRTABDYCNvZOwV2vpuQ2svWbCvkyInUOpnk58pyoVnTEYezTyDRA1F5uSYujguVJIsWwbGNM1Ya1kTR+QQ+5t90ZouhSM3qsqTsEmvZ5vvTQfj23OhNclcQh63o1Lj8AQWfvoekEWovrk7c/L64UMY3xBnTCr8fxV/BZJlGpAg6yhUNpZRkNir3kH+d+oM8yCPCbZQsF8QanIrYvtUCbmbHAc9/7btrtoXVaSRRTKa3P2dmZELIR14k7TzVCNzNcLZDqsnbWBgLwimzesVIIcMIBEJqcvOdKo4iwJKJxXsRkH3D7nl+qiuLmMkzu4V4p5g0UBAP9lyvTlgj+i+B8RBn1NTk+jk+ni8cTh8QhLh8yx+2CwIo5c9X2KOMetOI4EWkWHCy0hR22mjmywCIIiaKKG0b351LZESjSjrNpH4diC95+uLWMSaqsVLQvuSWIJ57IEhFAvL73WOawQr9E0tBDVux+8M/56YjJiuMOF2PSdKWiH8UQwZ0vaYgmQI2pNZO4HOL5xIzy/mDaNRha+sX60p4nUQeShnbscyyZgbw2Pf/fzcG+RwpAmAf/XwQaWVGNT5tx+UG+hAUidrMigcXhtm3IzU28K8pxlPDmKcVTRi 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:(13230031)(366004)(136003)(396003)(346002)(39840400004)(376002)(451199024)(1800799009)(186009)(316002)(54906003)(66946007)(110136005)(66476007)(66556008)(12101799020)(41300700001)(5660300002)(44832011)(8936002)(8676002)(38100700002)(38350700002)(4326008)(66574015)(2906002)(83380400001)(26005)(478600001)(86362001)(6512007)(52116002)(107886003)(6666004)(1076003)(36756003)(2616005)(6486002)(6506007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?QQKsdpaXSRe4htuK2j5tTPdalSaQ?= =?utf-8?q?YxntS4v3qIYwEA2TnW7Gg/+1xbglTA+L2W+Z6CLz+Q8HnFq4DL9SAyPBgh+1o21hx?= =?utf-8?q?YowxY5JLtWP4u4F4RDPjJookfgg3jCdfF7N/QS8APZuRagwBNixOwE4/V+m31gf4d?= =?utf-8?q?2yUuDmSFuAbTVAmq1fJ/KvifDWn3QXzcCToZfAQcGxICPwcW8dcqNsI8BBygYDGgL?= =?utf-8?q?ogE2AUKUwCvPfK7ndwQFMu8kA4Y2Ea3fyP771XK9EPP4WhlplCeAlZEjVcaz88LWU?= =?utf-8?q?AzirLgrQaYanzn+PlAAkdTGIbk3Q63UtgzAxc9/n9s3peWKM5BTCPsnWCDtpnnTqb?= =?utf-8?q?HHtFMcR7RIve10iwUIp66hZlqpQhSDgbym8z0zvP1qi6rojAISmpkQwxWdSOa8LY4?= =?utf-8?q?B8EE2C2BXW3Au0z6zL1QpHBOPlar3aBFB/Y1nGUoFMMG6p674Nzk+NdLXbcF8ZU/H?= =?utf-8?q?HwlehCPqWJIHJ0TAyfuJP0lILEh45YLOkDg4/0XZsKSenAmYzOvY+7klIz2nA8bPe?= =?utf-8?q?2KPY5vP3GL9aynjads9Duz9fPx4fcmzaO9HxQ36uCPNkDy4NTGt+5SDSGQm3zaL8p?= =?utf-8?q?r5d6KyPU6iV2Qzs6wpq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pKXNNFcrVmjdGNPIfZYgl9+DdALsY8abZ9YJwV9?= =?utf-8?q?Zv99JlfttqcF9pb3c9IuCZ/mi7puHsFIAQ=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 32febcce-b8c2-41dc-1c2e-08db9e66b5c6 X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB4249.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2023 14:40:17.8260 (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: pZCHCx8nIku0MtL20zVqt7zB28ZK+O8WRBg7mw/0+tlYElCLL5eHrKvOneXeRQR7GvRVvadMNQSn1qX0ZC7Mq93K2btHCXqMxMbLHEOGPY4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5004 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS 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 Wed Aug 16 14:39:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Peens X-Patchwork-Id: 13355327 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 5D4E716400 for ; Wed, 16 Aug 2023 14:40:25 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2092.outbound.protection.outlook.com [40.107.223.92]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5F05268F for ; Wed, 16 Aug 2023 07:40:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ST8ILpYTfwEkMQXgjaYjyLnkYw4FUof9YUoF80bmTByBgycMCATC6b9/dM+TY79xA5KetTFPTEvEzkerQAkz8fGctk+YdZxZgDgwt//j6wgAO4PUv8wz4zckf+pwJf7/s9tVrhO6WhlqyqOzjuLreLb4raIsLemRjHeGLruNwdweUNXHTPEQwoCBAy4yWHW7W0K8eFUoI4xFL4g3y1/G8X6A5PPm6pp6M3SC6AS6+y6oTTQdHuErNNmA2QCQtpwIaZJJbcEUuiZPBMIqtbJ1vL9924T2ySpRl1b6h0zAaf21nHMojGLpZ7AKK2wnYjTMvfmyJPnmZmN7mQHhxgoXig== 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=Aq/0BM1Srbjp/Zy+nnFomuo9NWFXc1+MMx7jFVxbYmqSV5ygDLDAHENd8eW8MHToXntFy/A+G5vcH44He3JuB9MEnkwdsOfJ5jQYkccUEa5t8DIiNeCGx6liYPIn7eRadzS770vHE0P4Gr/j6NkKvbIZeLot2yhmpBLabfFJpeU064ZwyMFFSmTgR2LpKNxJJSK5+QziDhzZp/PeoDOmqPPg8t0k9cGvAE/q2AB+W7eIUQOn64VcBr3kl6PBVIV4+tB8eWOoLPUy86a0gEpYel/PjJjZUmWN91kSfiT4M9KC/9oY5TO4xoZHyxIQ54rXja3tTQfe29Q+1jbBBbAttA== 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=r3Erj/67JpXsqu8bOqo4gt+SCzwC1a4ikLius/VVXLubNP4QKqFXs7tnbY6IcYRlfmZsU0vtlpljH27+/lHkTOMVDIJfeBCI5qC9m4Wd4G36pm8k1PoQxjt5X0CZ6NVpM4hk9eED+yzkS2p0kN0GcJqmp6b+7dXxgesW2Z0awS8= 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 PH0PR13MB5004.namprd13.prod.outlook.com (2603:10b6:510:7b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.30; Wed, 16 Aug 2023 14:40:21 +0000 Received: from DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::8de6:efe3:ad0f:2a23]) by DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::8de6:efe3:ad0f:2a23%6]) with mapi id 15.20.6678.025; Wed, 16 Aug 2023 14:40:21 +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 v2 08/13] nfp: redefine PF id used to format symbols Date: Wed, 16 Aug 2023 16:39:07 +0200 Message-Id: <20230816143912.34540-9-louis.peens@corigine.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816143912.34540-1-louis.peens@corigine.com> References: <20230816143912.34540-1-louis.peens@corigine.com> X-ClientProxiedBy: JNXP275CA0012.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:19::24) 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_|PH0PR13MB5004:EE_ X-MS-Office365-Filtering-Correlation-Id: af30d573-9ed1-4fc6-36ac-08db9e66b7d0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hvbnGkYJalV9eE9DJsU4zf6cAdX00Dxztdo8VeFBapNPgp6nEav3eovqTWT70gu7ThVUvzdgQG8QGtSspBuPLj4fJ9pGxujMYrxlvgDLA9GLpsWK5ltXaVSKd8Y5xAdQZX4Kaycr1h9Dg1xeq8b1kOhPYU06mKeu6Yfvhq64oUNKUcWdV37lGCwrvBN+AO50yMFaMQVJQRCp04/UTV7mPQiEWaSml1zADdizjq7tpmuQPryU1cu+LtFtQeGifmcvkOG/e+Qt+2YUMG252jHzL+U0Vbyqnkk0s0VMhFPdKxVDJ/pQCLcuR3FaBh/zPxpFfAwH0gkhk/5yveIrFo97hcemluCDUTSn25eHXzhU1cys8jqKQ1Ss+u1JL3uu7zyVswfSweWwmvZOF66BZXhF3C/5GGGTk0C/XW6bXoZ+ZSOTOvqTv1Cd3XlDvfT58zskwMXBMOKvNdhpVmAn57RIJWS6Lgkq3kypzuvHrc967Mqaa9a7EVZ+HnwOepr3LTL4X3dKZnn/BRNta3EFPhGMyEMizmHQ43gKMCapVi8w73ZPn0jdmTU8Z8U0av7SjSOSLrTJG53WCTj6nyHOKrBdxIyQALNgu9uYZgqv+9vRDBN8mG1nRFy3o16Eri6oUtj3uX/oXHDUP829VzvSKyIt8L2UEd/i38UKRzrVkVwdhe1ttDJN1JN5iaCQdXc6u8JiEG/ZxpY0UBc0Jg8SPQQ3cA== 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:(13230031)(366004)(136003)(396003)(346002)(39840400004)(376002)(451199024)(1800799009)(186009)(316002)(54906003)(66946007)(110136005)(66476007)(66556008)(12101799020)(41300700001)(5660300002)(44832011)(8936002)(8676002)(38100700002)(38350700002)(4326008)(66574015)(2906002)(83380400001)(26005)(478600001)(86362001)(6512007)(52116002)(107886003)(6666004)(1076003)(36756003)(2616005)(6486002)(6506007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?uTb441GvHGva1UX9NArWIVYX4I3i?= =?utf-8?q?8xC0EYr4ehBtauHk/4+3dqvGTTrlZzyLOq+lRSfIFGWmfFhew/wntaeyXrsMhKZ4E?= =?utf-8?q?L8NCougeGkyygGgKR8j9UGCVwEVlR+6ZG0CcBbih2FW2rRhsWJ9ukRPmZxjSCZLT4?= =?utf-8?q?evb7fwGbojBUXLKXXJuoxcYqOr47GR98CN3gbtcghA/kbL0qUPxYn0JflGGluhlu5?= =?utf-8?q?B0xBRu9CC55PC8lN13NaDfsOgcRwaSfS1ZY3HXfjDGUK0lAkmsnd1TwDMhlgT3sz7?= =?utf-8?q?qtsGIyZuUaGobXtgyhX6aop9S2ML1xnLER2E8Tn0WFhkrx7ymeN191UO9d4EkO6vi?= =?utf-8?q?DwpnMTr0QMQ4ZlwoelbYmHL4XD+496sCZ73bMu5+m3BrpRCghlLwxP2yVd6FkUuLR?= =?utf-8?q?vD942TJr+jPx6yzKIbcbM7VGFOZIgIj1teqxktpM8Feokjwnruy/dnLhGTDpleZD/?= =?utf-8?q?Ue1VLQui59D5vDuYBrHv7HyQqxp0TRpHNm2Zm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clvj2/udj0Bq81L?= =?utf-8?q?P25OFURSgXXdCyP3WoBiCzGZfS9eISbgTstSAQxjWBEa5dSMvuEciKhlFiCv8ovA6?= =?utf-8?q?o1yYJ1y5YsZGxBAucNKSIOKvk09LaYtd61T47e+oeHB207LmIZywD/JvaJ48xARiN?= =?utf-8?q?awRQIz7hTEMz45asLyi9gSPT+hCYxV7MwA=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: af30d573-9ed1-4fc6-36ac-08db9e66b7d0 X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB4249.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2023 14:40:21.4941 (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: BJHJXDBdtQZyuoYMurUJKnnGz3tHChBgB+Qdcuy6W7iXy9aGlgNjPVqdGQBvsf+vt2/euK0ju6HtvrYLq3iVExSOl5t1YarABy56S7Cgo/I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5004 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS 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 Wed Aug 16 14:39:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Peens X-Patchwork-Id: 13355328 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 EB90E11CB4 for ; Wed, 16 Aug 2023 14:40:28 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2125.outbound.protection.outlook.com [40.107.223.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FED0272C for ; Wed, 16 Aug 2023 07:40:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cUujMTf6po7vXmMFDpdybbNJzdrH5gtWw5x3aJHJdA4KZVFONj8ED8qY6epKoCqfqR8g2vcmWDC59zH7ZXuD4mRPqEocrlJjIApYXOBBYMdxktz1h+ouEQ0ov1cx87wONZABVnOefVZv7kW7mfJByhCvALIh6C8z/ANsuDQUgzbMH1+1XFttX/iFK/Fa9jnHgLl1MawGZrFpurQWNfL10pj5O98xHkfEGB/o1LOiQ0mKMEgwEyJ3xdrj60A5dtdeRsbkNJCwWago+aA2iUiKufIRP2k1mt/i9mPJneEJ+NWePk908ytNwfQwOXM0B9PbzPOfoQNWanzIslPkeB1h7Q== 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=O7jyOYD9SPQ42KdnwAlJahG6yF6DNiQpK2NzU5H3afQg1qDFM1T5ml55MAclYkY1yDb5cIiUrI2wkO7f28utDFAeUCJpXH/OZKjcyf98eR9JBiz5KKdDe1u+tqWjwYmVTJitmsNXXTxxB0UtkEuNXOELlUbee4RXKnosjMmFv0pdrKEwKlUua/AxW1qbnVJOFeVUWDN+sftka/OU6dE1STVbJmIgsNBe0krgoN4QWqrzzqKikPWb36/fIX8AVxV5p6swi72bfxfc7Wb5LHfv+i2SM96L8iZ+4V/mDtQgml60vKrhfrQduDvebawUD395Yux30bvwoMVbCDxkavrIUA== 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=Y/1MuXm15KpjEx4WNLlzG8fxf8sPykiVicUfGxrEc3NntSNP3JSqyifZ4bzOjc9LWZXcE7EkRv9uVRzf09+uLrVljT9rUu3xTj9jDfL9zkCMwomL4Mry79+04qDqi3XtGAVgWlM4aGlGTPRYY9yRIo3xomRvfiW2xhJiDeq8eLQ= 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 PH0PR13MB5004.namprd13.prod.outlook.com (2603:10b6:510:7b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.30; Wed, 16 Aug 2023 14:40:25 +0000 Received: from DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::8de6:efe3:ad0f:2a23]) by DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::8de6:efe3:ad0f:2a23%6]) with mapi id 15.20.6678.025; Wed, 16 Aug 2023 14:40:25 +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 v2 09/13] nfp: apply one port per PF for multi-PF setup Date: Wed, 16 Aug 2023 16:39:08 +0200 Message-Id: <20230816143912.34540-10-louis.peens@corigine.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816143912.34540-1-louis.peens@corigine.com> References: <20230816143912.34540-1-louis.peens@corigine.com> X-ClientProxiedBy: JNXP275CA0012.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:19::24) 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_|PH0PR13MB5004:EE_ X-MS-Office365-Filtering-Correlation-Id: 5d305a88-a00e-4dec-7627-08db9e66ba00 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /BKW6zQZC9L/FJ+5OSPRIMBIl+7CcHbitrOZv9ONt0wuBQRleHRHFyU67u41FtjiN3MZp/yO9y63ro1PkHEAmE8m1vJjgvZv3xdFERaHvAvaffxbJhH4Cw6IAJxLgbvbd2D7Vy+Kt7ikrohA3okYqz4t/Nts/ZoUHXi1i8EMIrm/y8Do1jD4ELvE1eBrfwX2SODTmpbW0MFjxm3fMd1le2L1K3H7aiBQpHBSCpqnZfPAxB6SZbcXlxsbsnPsAdHRuAf9pN7VMCZxEqByuXErZ3MK2gVzjHcYdo26DguML1QAR8TBZ4SRkWlP4y72yMtZoUTSxSUQxfxeBWgas0bYLM0DV0RkFyqivA/M4P3CS8uA/4sLcM31KbvBekO5hS3xcaCHxH4e8l65JwU7KrLx87XjNEe6NArSCFyi54on9Ebo2/ZeywIQJKf+NLifh1NVWoUtPC9aH3pKC0/rQRE9r0iesDsbYw7RM7C7/e6GnjjHMDVilDPZ695Nnar03MJ5aLfRKKW+2CbfV2T68ephd3wJ2+rEZP1H8rgVjDimBfpekhsqxIHO5cKCZCUtygb3PHl9UzGc2xBjcR/P6xZVvu51y4F4bzjZW3wPoJyNIthieAe7pI3or8vNEvUAuB7+PLzvyAntpg4VSnHFmiN9xDo/2kckOoIo2PHSlwMfcO6s4pro5ZDIHsYHQMsCGfwq 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:(13230031)(366004)(136003)(396003)(346002)(39840400004)(376002)(451199024)(1800799009)(186009)(316002)(54906003)(66946007)(110136005)(66476007)(66556008)(12101799020)(41300700001)(5660300002)(44832011)(8936002)(8676002)(38100700002)(38350700002)(4326008)(2906002)(83380400001)(26005)(478600001)(86362001)(6512007)(52116002)(107886003)(6666004)(1076003)(36756003)(2616005)(6486002)(6506007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?OTihDMcuoXDSlwTnUzKA7DWDzm/H?= =?utf-8?q?HQB6oaqGaptTatoiG7A/9E1sphvxgHhTmx02AdTK6srRN9NF3omYwYScLZf5fRgoh?= =?utf-8?q?dGm9LPdxi+olX2nqyK0degStjKHpeJiHKnfl3Ul6ber2450obKbMlHph5nvnnBGHi?= =?utf-8?q?O/AHbgwvaAyAqKDiL39yxWtwiEdZZUwYMCyK7CodmsZaJNVl2PDhhCmzuFZBecj0z?= =?utf-8?q?cE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9zZo03lM4KdWLBDqbN76qANlYUgPgNjActkkt4wgSnVrECPqDZELul?= =?utf-8?q?4vHXQGbxJuPK2HTT2p+j+Ztvsd97ImDe3aM27po7LduyJMnvCEZutFBEIzuFkz7vg?= =?utf-8?q?E7YRTxtuNmKvZobyqYQloyVHdlPBoKZy8lueTJdka3LI+NGfXDSygyRI7nsdoGcs/?= =?utf-8?q?Eu+qgUWwXGFzy/9dm3uRpXlr8pdcUYiPnmAyFAFm1lpwZ1nuHuezS8UOCbSP89tBY?= =?utf-8?q?yf55bBKCkj3SQNIVfz4RsAw3qT3L26nV+aRbXbO95++n5s09dJml519TOTDbhIP+d?= =?utf-8?q?jOCdaG+hFk6qfbfbLFZq/1Hn/P5oI5WGA/JClGiYAhd0SJiUDgJWFTiIr38GKo5QV?= =?utf-8?q?aHN0LknP2+Tt/Ql8m1fdNfnnRWy7phpegfmafWCHNvoRFuc7xpZiljRb3RVhHg1Pv?= =?utf-8?q?/+RY95JTBBWT6ieaN0U+PBS9PoVMm6tceA=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d305a88-a00e-4dec-7627-08db9e66ba00 X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB4249.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2023 14:40:25.1645 (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: i6K6pvfSlmKHTTNgAMUuu7ISI/qBZIj7+sMEIi2Mbk9++182SQFck86IclShmHlFlHxUXg+CN4WCPO0Ug1opMCifAoTyY2KkStpk15jQgxU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5004 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS 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 Wed Aug 16 14:39:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Louis Peens X-Patchwork-Id: 13355329 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 624F11640D for ; Wed, 16 Aug 2023 14:40:33 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2133.outbound.protection.outlook.com [40.107.223.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A5BD2D47 for ; Wed, 16 Aug 2023 07:40:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JskBCqcUOeP1cTO+EfOJqcH3fi1FDcNRbYgpSCiF3qjBILdSiR55W0A2KguyFILtKiTM3Awfuqk2L0WfHJSJv+q1UPOZlPtIEzbKiP6XXnn7MY5Up/hfzLH3Iy4XWERI1AygnL9XvFYrNRGVhHeoc0LeMVguPBtnC1CyC6SNBF8iR/Ak0niju8GCIiraOcWK6yhdYqq0qb0jxjDrxl7oBtg8PDDWMkVKehNH+cUEhiu6OA/ohrSqqvAZtQHaGpUCPyN6YrPc6ws69Ro06C+nO1YQ1S05yhpEG2C6Pf25nF4Kf9DjKv4FIh64ZQQcEbbOtiAlfbxWqYUpHA2j0LMFbg== 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=lI0UKAIHPFon3CWmfcgWZH3Zu+vDfUL5JU1fM2Wb9N6s21VYTmzyVwIIgb1WIB97tBTiDDyilKqVqk9iOii/i7Q4IkaEp8rjS6dwgwRedo8Qux5LV408rNVb5H4a5i+fpDMQqut93dF3m0GdJW+Wv7Bkstiogaul7u6d4LMoBNp7iZ0MgilskLd0s7HZbsRAD/tj13GWNIFrDaRJ4WqrtE7tOMQzJs7E8L6NA94YozaKy8F1SNzI6kgs5gbdJoLmzaY2ES+icVMl5FgzpESFkPKLLgdaCLkcKpEdI03cGwqF94LVNr6TRQ7VQsRGSwGnw+rLYqip/4e2SyDMiIKxcw== 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=O9snCF4c8U40ous0LXoesp2I05EaGU33gQqBCHwnX7Fk4+gTBm1xgOflbI7qUho6IyOyPRGoLBv0eG2ZWmiJhyratjLc97ichbkwMSH64gbqPqGA/sr7i7PuWDT3odlFIG4HB1G942TSvQlREZ+arwfjZxk6LI231jZWt+i/i5I= 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 PH0PR13MB5004.namprd13.prod.outlook.com (2603:10b6:510:7b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.30; Wed, 16 Aug 2023 14:40:28 +0000 Received: from DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::8de6:efe3:ad0f:2a23]) by DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::8de6:efe3:ad0f:2a23%6]) with mapi id 15.20.6678.025; Wed, 16 Aug 2023 14:40:28 +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 v2 10/13] nfp: enable multi-PF in application firmware if supported Date: Wed, 16 Aug 2023 16:39:09 +0200 Message-Id: <20230816143912.34540-11-louis.peens@corigine.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816143912.34540-1-louis.peens@corigine.com> References: <20230816143912.34540-1-louis.peens@corigine.com> X-ClientProxiedBy: JNXP275CA0012.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:19::24) 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_|PH0PR13MB5004:EE_ X-MS-Office365-Filtering-Correlation-Id: 3fb1aaea-7db4-42d8-1801-08db9e66bc33 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: y4RNNeyBpQHoKpZNla9s6I4A0M2fWHB+AnliW7YLKEcUmKuYHbVltyge7YU0rGNR94w+jUHkufTNM6tAAdEV3LlUKhVYIosenO/hctI7o+Df9ISy9a9Vvb5asgjtidI2qqT6SoeIF/szRHHQHhT+YG5gKH56msw07IKHJHZBWOw60FVUon/AoJVfI2ITd5PQMR/l7TwaJK3KhbQqpIWg3ZrQ8fDlLezJ0tys3TgnnN4LA8hh1m6JOZ+LnvU321wI8Zi0JieNTnxqtDbUiSZAl9A2jPlFmDcNhQcideiq+0RxPgV3AmLeYs7M80rJ7+Th+IBIWQAIoxJYDCUwOYW/+/geb9aMN9GYIo2j2p5TgTECbCGndzdH4u57s2Wosic2BhdDzi/Iaee9wFSsjvzGpQxzLo2NPQutxuEgSMi9uPeD0nvg82KB0TZ0XqoVpq15HN0Zt8oUlfp9HyUoZaKQyTJj7PR4UBD5kQP/9S/lZYH+zeLKVokp4Fvaet7rAfWllDH7fA/0c+WWqFOHJZJQy+/Lpgw5cz81D+vKWGJ0EoURv6i1dq6+/CpV3BD8xi8WWrvuQEhjMFDDoMeVBdedXxacLNErDdNPimrt1rDKzbjl6R3YUvwz0HKqZmFOg5mrm/WXnfkT2zd2DJVmxf4pUZfrMYFhfDf6vOOHo7rkKbE3tjv9PDgb/a/hJtdkiRwtaZvohNtTVl9rURjO/wjKpQ== 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:(13230031)(366004)(136003)(396003)(346002)(39840400004)(376002)(451199024)(1800799009)(186009)(316002)(54906003)(66946007)(110136005)(66476007)(66556008)(12101799020)(41300700001)(5660300002)(44832011)(8936002)(8676002)(38100700002)(38350700002)(4326008)(66574015)(2906002)(83380400001)(26005)(478600001)(86362001)(6512007)(52116002)(107886003)(6666004)(1076003)(36756003)(2616005)(6486002)(6506007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?7pPCMybuyVm4EW9DVoxXltvAYuV3?= =?utf-8?q?G3z1NyyhbmP4B7ZW1RqFK1XwWBu2E5ZqeA8OM0i/GO+uTEaq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eiVy7KbUt?= =?utf-8?q?gmIrqZXIBIbMdEKDV94UUsdyMJmQBH0t0tflG59V80z83Hz01rmu1gKqGdL6FMOYv?= =?utf-8?q?aCQ1nNu3QuYt+g+HjNze5YBs4ftInicr9ucnEeCd8ToOPn906kYWK2KanAPhaI7be?= =?utf-8?q?U3gRf366XNRXbhG9NjHtcJcDjxkp9O1h6Op7tytWTrL+Oq90Gb906WOcwyYTk2Eaw?= =?utf-8?q?3z0AHlc23jClOmq6J3Yh6B3n5OHJLQsAZRNnLX6Q84TOELQTReBhfx4tazWA4FmQD?= =?utf-8?q?CU6FJ+ZBzxRDTxAZRtphNq+RJ7acDxD/ZbDhibgVh76R25sNraH493BPspR2megWU?= =?utf-8?q?Xm4aFh86zfHM2hXk1UTLBkZguNzuzVTYXVFFBnvznlhqd/6DiN9+HnArM0Q31fphS?= =?utf-8?q?IFyx7zAHyFR/XRdLUNN/gNX9rFXNr6f57ak2TIszPYlSbij76aIvbJEFuJ93bbhHW?= =?utf-8?q?vZsWDW8RG0CqTFMw/eZOlSlY3FmW0JhLhnq4x9IuQHxKpZRJ6/3Dvr10LOsRxC/14?= =?utf-8?q?40iMOCL6tZ8kyGSeGet2QHwVyIZl5TBxQsujaTc9AXqBKxpH+E8njYS/30IGYZLyy?= =?utf-8?q?S5geEizYQoQlcI+gUQoBYb8HzsV+5Cr7wQ=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3fb1aaea-7db4-42d8-1801-08db9e66bc33 X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB4249.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2023 14:40:28.5650 (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: OG20jZ7Wxe8d+oRUYGSVR5VfIQW92FJS9Da9TAa4DrL/60EJn6m6wIx5K/j/Yqi9lI20F4cfo4AGgEnPov8u3g/WXvn1VpGazyJ6dwXmGy4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5004 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS 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 Wed Aug 16 14:39: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: 13355330 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 EA0E3168A4 for ; Wed, 16 Aug 2023 14:40:42 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2138.outbound.protection.outlook.com [40.107.223.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4CE826BD for ; Wed, 16 Aug 2023 07:40:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SIoYswT3alKUlfEZp0oe8WunEXw+Bued8/4KITK5zOw8sPf7pQ5W3Ol0YIC+GrMSMcBmxUzS3hUxPg5h1VPmPHnEvubt3qiPYuC6PGN4aymi9/pB/FOggU8SVGPJ8mCI5DQT+BzyhK6KJ8Xh3rwh0dGHX5FW7uNPX0Lh8mCRPCRJez3r+pjjKPa9vkD1dAhtkPo2lLqvHS4nLh3exnshPdFSpuuJlsaP3yztVT6STXI7vxXkP22Opq7h6gJDE1ox8UavLuMjxIIHy2jfprI8bqn7WpgWoNTfg2JVXyfQ70A2h0pItJbiBJJQFR3yN/iHTS/eu722BmXBQm9Z43aVVA== 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=CnIEepDPVeiTATlu1aMuCRts+YHFIilz+hJUDfCRetc5BsIGIJze4/a08CqAnKjkrQBOiQdxtV/wu7bdpIlBzNeYc+b+B2XJtZ+w4xmFJWCCImEQEVfrIDqssjL0r6e8pJn84tqRRixCzadVveAzoejWhH80iK0g2/bcTaGNRq3nmJ+UZauYJsT0FKGrw57EJg3zLU26a9Pm88BDd331n+j5LfHc7F4Npdgd5xx0VRXVsZ09C2HsgeEilXB0quWkDPP+5F42XfKEWN0ph4/l2RCexcjWu4MZBRKygEmNVayf/UPuYBcesU5H9JEmYV5pr1CbvjZw3i4rwUD4fw40+A== 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=su6MrdHN765uzYjzzkL+q7bVS9EtGR5wElsAD92uVGfUY6ldyWHaqUtXGhBbBeYsi5au8/IMwRxme1Ucbk1J7dR1d4l9P3tEtMf+qZtvE85lTI4RFzyjHbPvkK93AHpeIt+yMleboLGaglid7IwTAZ/JefiT/IsRYWYx32MwV7Q= 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 PH0PR13MB5004.namprd13.prod.outlook.com (2603:10b6:510:7b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.30; Wed, 16 Aug 2023 14:40:32 +0000 Received: from DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::8de6:efe3:ad0f:2a23]) by DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::8de6:efe3:ad0f:2a23%6]) with mapi id 15.20.6678.025; Wed, 16 Aug 2023 14:40:32 +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 v2 11/13] nfp: configure VF total count for each PF Date: Wed, 16 Aug 2023 16:39:10 +0200 Message-Id: <20230816143912.34540-12-louis.peens@corigine.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816143912.34540-1-louis.peens@corigine.com> References: <20230816143912.34540-1-louis.peens@corigine.com> X-ClientProxiedBy: JNXP275CA0012.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:19::24) 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_|PH0PR13MB5004:EE_ X-MS-Office365-Filtering-Correlation-Id: 5b5460ae-78f6-4cd7-6ddd-08db9e66be38 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MVJCJN3vhBJCgyxKxgolKnGoD0mdcHABMhXU4gWs4vc6T15cTMBdutyteAoiTMkc1xdiCJDEIGy3QcPRhoOg86RUJE0+/+eRtTA3jlKRpuxNrlQBuAsGnbRQdbsNpzpnTaOXfXTyZO4MJR6V3RmpPJcq4T//C8kdy5jM6c884AtpwTlYEQwt5OcNDInK9xXRWoqc5KRubIL/x64UstcjMbrUt5ZdP0vMWonhOg5C+OLlodb5bTDaLqpz5gKYS54ggzSnGNbnB+EumkgGzhktWRdkhgylF5/ovehE6L/6pVFEoBFvjrx34LK5SbkgH3KxpDew9K4rM6VxpKmmXFFgbvp9PrMn2t4VPxnfY3PMwzVe9OSn+otG6WiuxN7ivWsxAk+MJ0jydcq1lGOEBy21UtKlZckzoOIba1TiYrKAkvUnaj3nN5xS8lBRrC3BwITtLwMeo1cTtVwmh1ZaFs8NIc9BxC8UIck9IZ+rmL7Ix++7aH8NOKKS4K4QZYz0rQ33SCSTK0v/4uVlr6wFiwglwjvZm1/Tu8/b0tCVfiJLj0velJFUXqDN6ZiNRzQ38uAvkPqijCtw5Y/mzdqph4p5o3nUuu4I53LsDYs6ogfyWGUqfn85e0Ws5Rwh1ZKZok6bLgoAZlk/rJ5Ot595X/KajXndXZXjII1i/YRqNoyEPy7zvSZB6Xg3K/4Q0ASdAUkf 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:(13230031)(366004)(136003)(396003)(346002)(39840400004)(376002)(451199024)(1800799009)(186009)(316002)(54906003)(66946007)(110136005)(66476007)(66556008)(12101799020)(41300700001)(5660300002)(44832011)(8936002)(8676002)(38100700002)(38350700002)(4326008)(66574015)(2906002)(83380400001)(26005)(478600001)(86362001)(6512007)(52116002)(107886003)(6666004)(1076003)(36756003)(2616005)(6486002)(6506007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?JgoFIm6Va8W/DZNK2pOVBEJ/wiMi?= =?utf-8?q?MN9T+UsL1mv8epI+ibP6q2DvvWDsY4/jAEtUsb9nR6tc0xgEtFae1hyjFhOfWuEe0?= =?utf-8?q?UjyBf/5SJlea7dIoyIimYL1XnVaHj2FjmIKVitO5CCBoJBWpZjUclfrbesNq4GHD1?= =?utf-8?q?3xI4rlY5jVE9u4gbwzp++pdw4m9PlWwXlwuKPRjPqHRxVF10OOtU39FfItoun5JfM?= =?utf-8?q?1DnHwp2YehHY3lMIBXjkWWAH3p1CkiGezOa/ma/p+Be8s/f6q68jLoOLr0mRQbw/L?= =?utf-8?q?bOpXjI7/mZPs24q9Zwg2ZhLdVoLMlTF1w5sohgwXC0dfgOuG53UK9JssJjviUP2OZ?= =?utf-8?q?4ujsoh+b2eLIKYM7wGNmHq6obP6ka6v7KWugum4qcB0ouqTJXtl1JHVhyp1daVK2z?= =?utf-8?q?nc6/6U6fBvFbNOOZLrrt3t/RK4pBf6/Wdi5c41HK7BwhH7IuDTNpWH6BCHswQVDLn?= =?utf-8?q?D2GlZ3bO8X1tPBA5jarl/S1K1IikTkx90yendyGlvtP2O5rnwRGZCYsvaebBO9sfD?= =?utf-8?q?rVhfVHrFzicZzw9ddtC7JpGg5Fr9WStC6NXVw5cegmyrv7FpZfbnuMT9oVwkSlag5?= =?utf-8?q?y0vXEk1NXZNcUXM4o9eomJdNO82zHrPCxdbHv87F8LP+DD2UMkmEtVYRW/LqgpDS2?= =?utf-8?q?1ruFEUG2WDrS+SyMGo7ZnFw8CLV5mDoP+fu9B6VzpLLgpvyc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rg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5b5460ae-78f6-4cd7-6ddd-08db9e66be38 X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB4249.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2023 14:40:31.9797 (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: T/A80S5PD5SA2wU0APzakvpbKB2Dn9AP2+wC0Fr+tr5wY9SUfoPlgVZjMLdNL7kcOFaOAJaIjhySc0PTjm83bWcsgdn8+7wxk3YZsvVx9ck= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5004 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 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 Wed Aug 16 14:39: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: 13355331 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 37A31168A4 for ; Wed, 16 Aug 2023 14:41:04 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2138.outbound.protection.outlook.com [40.107.223.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9AC72D5E for ; Wed, 16 Aug 2023 07:40:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XNu+LlX7tXGKL+CG/2T1hmtVa4rDxr48PgIC/fWR240GiLWy+ZitVa3yzUGLUGOe7J9ihEgCbfJmomKAy5ls+zHC3ZoJmLnIqeGIbijN1oJirpYuQif6oh4ax4Samu6wodgJHArLqA37G3tG1usnOs9mR6+rGQowjBJGryEGyTgB3/Io2rAiP2eN3vF2UGC4Od7scIXuFcUO9nmIXhyYQZdrgAV3Tln4XvBEvLDuENwVOvKzlSNMZ42e3GOw5U83l1ZNDyjw5Ey3TuQQn5batZ20YDjqNOUK2kM8hPrf6KjF3E6eNd8TVA/V3Xr4TKLSQdgHzoyg1cqdTBatQugJUg== 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=JFbzFnfoBs91OxSxv4S06QuYhU2cowPdtfdQzXpVkNOMEOYTbObMO/tkkezpmAhqDBJqef3KtZS0qQcgSwZk0tOtPd4zo2vcZ+9J2XWUKBGr/45w0pNROzSXBxXDB3i47f8D8e1l7pnHEeMRIxCTeTz7Rd7V1O1Hl8yFuF38RbMosSx9isVG3tyb/PaFYdEMewDBV0iSueU8Ldx6C9cApb62WtPRjlUH6UmnifeZwgw/I9G/6Znf5bIBfEEiSs1V8n1qnt5h3nwOYmgZ22fDpFhREcIEqv4ciE47VXKlMaoGpOnjnJKDYF6bdxqdkwaFsUuHXlaGm7e3CZuRXJUY3g== 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=BeplYZ+xz24+H3YX02PN0SKfWnWhY2b+2LNajpoMP9J7EMv6NrrH7WwveKnkDvNMAYBbgbkdmvELdGVDDvMIDUMuDEWayOt0Bj6JZnTscPG2sCrHipWdYAYypqVAya6dxUqrywFhAkUiSWXoRULIeYEx7cr5WhYM1qznLdnK2So= 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 PH0PR13MB5004.namprd13.prod.outlook.com (2603:10b6:510:7b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.30; Wed, 16 Aug 2023 14:40:35 +0000 Received: from DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::8de6:efe3:ad0f:2a23]) by DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::8de6:efe3:ad0f:2a23%6]) with mapi id 15.20.6678.025; Wed, 16 Aug 2023 14:40:35 +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 v2 12/13] nfp: configure VF split info into application firmware Date: Wed, 16 Aug 2023 16:39:11 +0200 Message-Id: <20230816143912.34540-13-louis.peens@corigine.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816143912.34540-1-louis.peens@corigine.com> References: <20230816143912.34540-1-louis.peens@corigine.com> X-ClientProxiedBy: JNXP275CA0012.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:19::24) 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_|PH0PR13MB5004:EE_ X-MS-Office365-Filtering-Correlation-Id: 6a92424a-c439-4067-2612-08db9e66c040 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6E8wzr8uZFn/OfG7hjCNqpJ4BLvsJ0EEEZHY+Yt07JF220Uy4iTvZXIbNfcxcLqHR9wqFhxubdeQPDZxg/syZpm3Gu58dY6cut1ssohhWfrYG1xDSSAf54TLQQQ0GKXkj1bFs43wn2/3vO2xjnLiQNdqdjLe9qNqqKz8cKZCXuEGjFbSsYZx3GvrVNki7B8PjpaLgvRlwhI7+KUHL/QUY+FNifZVYZGH9WIsD5tsINRiYWh9c3AA1dihsPQiI6RLIZdBKxDd+O+zLlQgEmO+4VpYaFcbSPOf34QasOPvfu9KdvoIp6WnIuHs3rYXfClva8igmluEpFhn9XHhC3ZUytg15s+xUmoPEJ3CHYVANyRwrkZc1wSBtPo7l0atQJYg/Fv6Rp8Lvr18b4AiOE5j5uBYQzkCWlCclJZw7jl9Igga1hmhm557kjlnvilPU9w4+Mdzu15tG4x88IrMc9ur6l2YLm0F3/2TlN82IxVO5KMzOP5svVpwBpNK0vhQoUVFdvq3Rlz8F1Ra8cYg6ylN3/CzWQpJ7bvN/hlgyywUkyE3mB8imOPcrnKna29kCqa4F+mx31ElEm5ngo9CfsQu2F8Ffkr8zL2JI7jTzB2IUVsBy0bNqBZlGu1u9a7Dbyhwz2GEbwRsSTxUJ8BgjikTJ0POmOv0ugyd+K4W66FX5iqcDmwqr/kgB1t1ppNoygVKa5AP/LJiNMQADnffb4pdEA== 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:(13230031)(366004)(136003)(396003)(346002)(39840400004)(376002)(451199024)(1800799009)(186009)(316002)(54906003)(66946007)(110136005)(66476007)(66556008)(12101799020)(41300700001)(5660300002)(44832011)(8936002)(8676002)(38100700002)(38350700002)(4326008)(66574015)(2906002)(83380400001)(26005)(478600001)(86362001)(6512007)(52116002)(107886003)(6666004)(1076003)(36756003)(2616005)(6486002)(6506007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?sJwoflXw2sX0FSLncDFJ5Yb7WJVD?= =?utf-8?q?F5HHk8gBvH7EGy4rNOFvmSz139Bl9SmuNBRuAd0mXTPLt2dIrXZbgXFJgDjWu8yRf?=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6IA4XR0J9Jz3Fd?= =?utf-8?q?9el8UtNeHQuaLyAS5MKrtDu+Zcpza7TsFQJxOxOlgFK8HNlEC87XJF/wrpIlER5HG?= =?utf-8?q?vz2SsFMlGPCN21pX9BEb8NEDGVxoHfJA4uuBeABLnx67Mln7ApSffpgnHFARCMmzQ?= =?utf-8?q?vQyMHAs0SV5juCgMby6nFuoHn4XYFEdHY3cJ973PLQSPoMcaPbr0nWIfcFLftT7S4?= =?utf-8?q?sGAMBQDnSNrRdlKeL5y6coDgpOXRFKJ900luYEAyT0DLbRoyLuszOjwP6eovb+rfy?= =?utf-8?q?7A2gXErplx+53HwDI1i4295Cp1N+dnTeXWGXAkMTCurz0X+3+vz/ITVGvRZHaLTeR?= =?utf-8?q?7OJuIatdY4JjEJva6O2I4iGYTAq6HEYiYYiEwYVJSRx/OO4D1Ef64XZXIAluLDYAz?= =?utf-8?q?Hr4Fq94naOTK5hZVggbLS85m4VeqDxDm7ppYJWcSES9dScgByxZxfGqo9Cq9d0Owd?= =?utf-8?q?VYA3Zcr86JY4FEvKjA+0rp3i+Gzxr/CksMhKdfdt0+BVmD+penBb/Dp/Co+61q1SF?= =?utf-8?q?RRdFeEgeQG3zIxUp2BAy7utBmWv8Ir7epRWa2XOpGwrZTRpBJGHJmm58LDv3GJeSb?= =?utf-8?q?p8LmfN51IvODvqmUkTrEQaWzyfGBrN/f5w=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6a92424a-c439-4067-2612-08db9e66c040 X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB4249.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2023 14:40:35.6559 (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: SZmiu7caOWEcFGicBMMhuUSJzOYcjZuv/tNRFCI9GnAnvBqvGw3ByAbT5Dxsgu7LYC8ikb0neypq7Kg3EBH4nbTeaiySLPzSU89BDNODg50= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5004 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 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 Wed Aug 16 14:39: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: 13355332 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 B40C3101DA for ; Wed, 16 Aug 2023 14:41:16 +0000 (UTC) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2138.outbound.protection.outlook.com [40.107.223.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB42A2733 for ; Wed, 16 Aug 2023 07:41:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y9eGomKV8IfV7sM0I6ToOrWmcCfQqrMCx/g4s93jxlxtw1+ga5TXRtO3K1FzN6rbDdCk5E8WpDFjKtW6bXR3NgToWgTdi3kUnAoEsYD16KqHYsmFU+5vH+aLRA27tRc4ve+071ADxqKwXAfh3dyM6tjSovWUNPAuFH/E1ExlIMROIQ/UkQgbLGhBx4L6TUDmWsW/mtW052Rizx8l/INW1lrbWuDwCxxrM10PF/M2bw79HGwYv1gQcSEuIwks5IBB7K050OSjngc30SZiDgpr7jDekATtper7DdyL1qkWytq3RCdWA2bNOKP+m8T+zOB8fz3LWP01FM6ztOagnfg5rA== 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=NBvnL6yEJfEDRZz5yafn+bzKYtpjjZdlVdvnAALqp5Mr/f3q9BoHGabQSrFIoSZItnrnZ7PeL2tYWTGWO8GIkD4bR4F90dX3Kf9nhc3IlET7TIHzvwSMcWb/WQK3QIvisrXWfX/l9KH3n8e0I3ReasoG4XoFZMZatK2uDLbJAgKTildjGHcYYfhPo5HarO2aKtca2UgQZPTDS4pDcTGZJ4UviDt2kg/Q2orVMdAkELbkx87WNH2WTV47nQqBDoRjQ4+S6syn2Vml7MKETCB4Ddm0jFi+Z0qLDl/oM0uSK4O2Eo6AAso0+nJY4bIq0ONhyKmuP/0Bjf+oLekB4Ql7nw== 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=iDorbMdaDSDMG4CubR8ER6p8l0Kl55tp+pmqoe0Jh3UlcwRCayyF1f41f5U8zSWdo+ykpz+UK4RZMWPQurG8fAiVAL7HnZI69TOVSYU5RfaGZDdJJGbwc0+lvipynjL/rZ6K9rBbzmmLcu50pbgATTDRoVU7n/qsG66PD1zLe/Q= 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 PH0PR13MB5004.namprd13.prod.outlook.com (2603:10b6:510:7b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.30; Wed, 16 Aug 2023 14:40:39 +0000 Received: from DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::8de6:efe3:ad0f:2a23]) by DM6PR13MB4249.namprd13.prod.outlook.com ([fe80::8de6:efe3:ad0f:2a23%6]) with mapi id 15.20.6678.025; Wed, 16 Aug 2023 14:40:39 +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 v2 13/13] nfp: use absolute vf id for multi-PF case Date: Wed, 16 Aug 2023 16:39:12 +0200 Message-Id: <20230816143912.34540-14-louis.peens@corigine.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816143912.34540-1-louis.peens@corigine.com> References: <20230816143912.34540-1-louis.peens@corigine.com> X-ClientProxiedBy: JNXP275CA0012.ZAFP275.PROD.OUTLOOK.COM (2603:1086:0:19::24) 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_|PH0PR13MB5004:EE_ X-MS-Office365-Filtering-Correlation-Id: b521d6f0-8ac6-42ca-2a3a-08db9e66c275 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c6zZk2l6XoLQSGH8O8so+SHT4SmBAROt8EGTDmwYNf9Ia8JjFUKFno6TwVodMleK/LIqn4lxvCs7VaBgVhhPo3Gbh6HhWJqB3bFJ7LfNvlTubVs2AAQhKZtFsRgRUt8okURs5hG4eAj3sStxZejA/chWFhPyHh3O7Rmt3ODSp4dGNZ0upLQnWIGMv4rHIrXWC5o0mwwBPr2cqOn/kVpPR49DLVPbY/F3btqKfcd1XjXEQdq6GPiQpPp1VwWteyUHRCVZAC266tYvJiEKzxZWJfnLGQ1oi125pVHPdEjW4W8Qc8yY081GzEPjre+Viu5382bqcnvOtD1mKKuv1skK6Mn6t+ueX+KLrQcOzqeY08k4+SJTTDzWVoVarrbKl+PanYktnkO+vPeqL/SFX20cYcRAq9XejAaY/VO5yolF7aO7du030N4HPff4Kk5K0gzPJR98CITt56Wcn4pW77E5DYD3nwnShd2gXq88o54BkUUa23tb4X6lMzS30D6Hjp0557gec0B138NNFj1GvdHdnNIiQB0weyNkOwF5vDoFC3gAaDXyiixcCmNYeDQ2H6V2fKUCWWJqCaJ9I7Q4NJjRxlDoug+PleUpFMk69D78qJ/ZgmI/Q7MyX8bhTFOP7yhlfjCuJ1655tdWt4UtsVfzOOAnrJQ687g64uxJhz9t711lwdjQ7oiZlLy0roN4XW0X 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:(13230031)(366004)(136003)(396003)(346002)(39840400004)(376002)(451199024)(1800799009)(186009)(316002)(54906003)(66946007)(110136005)(66476007)(66556008)(12101799020)(41300700001)(5660300002)(44832011)(8936002)(8676002)(38100700002)(38350700002)(4326008)(66574015)(2906002)(83380400001)(26005)(478600001)(86362001)(6512007)(52116002)(107886003)(6666004)(1076003)(36756003)(2616005)(6486002)(6506007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?lhagwiaiR0nZdz7bWqu1hV4C4d6B?= =?utf-8?q?N4sl6VTA9UHHZwK52t0nbrSKE1kNE2PW+cmXWhdSg4PXBfdarTBYFdCZZiUC9P+Vd?= =?utf-8?q?uCmKvmXtdLvWtekMUCKnFDGqUrDvXCmbkOg3fEBufCr0XlfbSVFX4thAcLzzeHtCU?= =?utf-8?q?dvtqAib3uje4Mlxp8VMW+jRoTI5zTWU/5F3LxhGO9j3RCXEfQVvL5Sao/0zbvAtBz?= =?utf-8?q?6ZahWK6/62s8mNP3SrTPAiw0ZnMB965/1iKu+paMXz8J/vgHKY9FUFmqfDx97aOsD?= =?utf-8?q?rsD8ihJn33a6CrPefFoqIlNzzCTLJABBKsqXYkkNcZ5crYzJR8hi23B6lcnLl7JoD?= =?utf-8?q?dFstJWniZjHvgJgWzK+1N/YV61j7mQwRNL4ZaUr3T52bhlVfh+tW+kShXIvesNdNu?= =?utf-8?q?SnW/ZkrYdgsQPdmUjXI3SBdK0Rydrd2BDZ+KE43eDHZ7fpwWcS8VcoXFjYuEWyLYX?= =?utf-8?q?PUbi+gpqm0iSwECd9Ls7DsM7oWlrI4xt5+YEMmvVbZ8Bxh+cH0mL0ixM2KPm1frV1?= =?utf-8?q?3iaRyk2I6WuiRZLeqjqP0PyuMuUggPHRZ8/Q4Fl2oOO7b0lXYuskGkZmiw/SwHbo0?= =?utf-8?q?N1fdHmVk1besnPIOUWs22zM96EWsqlaZpit6aJYoznUFGXmQU0NZ4Dbe93CCUHNEb?= =?utf-8?q?4KB/9fU5iyes/auJJs6n30t6qk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w=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: b521d6f0-8ac6-42ca-2a3a-08db9e66c275 X-MS-Exchange-CrossTenant-AuthSource: DM6PR13MB4249.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2023 14:40:39.4459 (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: gDY/GAAgT2DsHIEvvKnutzTxrZkj8v6K3a27KW1eU8ggx8eMKJCnlpBlusZQ5JWxJHwv2fj5IGdJI3hOlTpibM9HR+wWCOBPHxl1rR/cIdk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR13MB5004 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 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); +}