From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 74B3742600; Tue, 19 Sep 2023 11:55:59 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 639CD40A7D; Tue, 19 Sep 2023 11:55:46 +0200 (CEST) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2090.outbound.protection.outlook.com [40.107.96.90]) by mails.dpdk.org (Postfix) with ESMTP id BCE1840A6C for ; Tue, 19 Sep 2023 11:55:43 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gUE8dDiY+efc0qwSHbLCRhXRQBax9I4ULoOKSCx3AWthM3NL4IdzllU3vifH9cMeVOPgnrlvsLqux5zuRokOc3L7Crk8S8nhKFy5TobNJo7BObLsR4M96Ivdq3Vd+706O2ZJX1yhwFuHugceB358mZsa29tW5pOmO6s2gx/YHhefqO96afF6C1zhgRLJjfbcxLPBcx95O5SkjiEyKXgweH9jBsMtuDDdkD88A/6uBsM+kYxTFaixqAs1fBFpnSR1sPxtZ2gViz31hB6Zr6K5r9PZ7gzK+g/gMBJpAG4znABByuOaVcyCLV5efTlpI3Kdg6oTiQM8eevabvtI1yTddw== 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=9RaAR0u1CrKW8F7nMsWWUYiZP90uqq6koH/kanjCHR0=; b=AJLHLDAq6l6a+F5Afux52J9Yxw4lCFcF2aBNGXfS94vpIGEseSzjnszMrglhHrRXPThk+uKI6S3nktH23DxZLaRWd9E0qMeal7KeztlGRo6BpDxAOd+oHPC3A55ecLq8GsJyg5NVkyUJV4Xzd0LZL1p8JCYUuUjdL6DkU7O5HYTQu/SNS0X2fysD+Rqig2gfG3nwI310JiprCUyeOWS23PIKtAQqguKukQgUhvZ3VokvC/NoYp4XCua0gfPv4op3uhnYiSw1z2mhugjzMjm1yY1LlFsFUcw+7NUBxascz/O5wP7GU9UR1YM9eJa/JK2hLuuNN1eum5n9LfIfLwcXBg== 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=9RaAR0u1CrKW8F7nMsWWUYiZP90uqq6koH/kanjCHR0=; b=iGjFnN82HiEnAImkeILzBcLSQKIsHjX7HMBcw9yvzWSnyTpo38W0UoqcsIYmqCEVDxZ41wAJtY4huLp/LVYQqe3+yiNFQ+/w9Fg0OnMShoMGjWywz0Kthx6zkrTfNCHaphqa8fU9F62pClK9hQv++Kc6QH/euMCfG1wy6C0l3Hw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by PH7PR13MB5868.namprd13.prod.outlook.com (2603:10b6:510:15a::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.26; Tue, 19 Sep 2023 09:55:40 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::7a1c:2887:348a:84bd]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::7a1c:2887:348a:84bd%6]) with mapi id 15.20.6792.026; Tue, 19 Sep 2023 09:55:40 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Chaoyong He Subject: [PATCH v5 12/26] net/nfp: refact the nffw module Date: Tue, 19 Sep 2023 17:54:26 +0800 Message-Id: <20230919095440.45445-13-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230919095440.45445-1-chaoyong.he@corigine.com> References: <20230918024612.1600536-1-chaoyong.he@corigine.com> <20230919095440.45445-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: BY5PR04CA0014.namprd04.prod.outlook.com (2603:10b6:a03:1d0::24) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|PH7PR13MB5868:EE_ X-MS-Office365-Filtering-Correlation-Id: 8700e895-8a4c-48e1-ffc3-08dbb8f694ee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yskHu9RrgfRtPRZBGRq5vJqG9v4h8LdM5BOwqkbq4bMgAtj7j3rYUQmobTbA73rBEcrl/3ig8L9SqsgP3sc+LNxiWKSIj2Iixwr4n69Arw/2KTPVfZ/uGneAfpt/AqHAtjfaI9QgiZts4od2v/bIv0QvoaFXZg8w/Ux8z6mRGVasMuq3HupT7zmV6rSGCPYojCHVnD2eSp+9xnO0DLBZjB2WF4jpSIfZriD293hKrSH+Z1B8RW/gfOAHWt3H23v7D3e39YYxhoPvqG/J1Jrv3ewtzmhZSeFJxMt9OEJETxG5j0sTSM28w5JBS9dcc0eAYGfik8d0rQdEGSRq5eGdmQOo29VaHWgCkyZBSyvSn/vFLZuzGXIow43R6AYAwEp/PHMfB614WPhT9iDyTIteF9Z5zC8Cr5MnPm4Pc/mLFw3u2F5Q+F0ate3vRTQudD5xbVUxg6q4iuWiUJC9Ufwy+2gogxW75AT0G/iPi/2iBCm2SUYEmjUUbKwIgMXggm2IT44EGHKgUu+WCuR5aE2b/3wiF7iuSLobrGkBTRwlRLyhgcgURtwLXSxuBfMD0QOnubgp6KPa7OsL2EWhEfnzUARA+C+gmP+Bqwo1On3ECeVlcs9aFde5soXsG6AiJYclQ7qryl9L5jWhZCO0jBbC/MQ6Hu6V57DQ5nM0L/CkREo= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(136003)(39830400003)(366004)(346002)(376002)(396003)(1800799009)(186009)(451199024)(26005)(8936002)(2616005)(1076003)(8676002)(4326008)(107886003)(83380400001)(2906002)(36756003)(44832011)(86362001)(52116002)(6506007)(6486002)(478600001)(5660300002)(6666004)(6916009)(316002)(6512007)(38100700002)(66946007)(66476007)(41300700001)(66556008)(38350700002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?ooaj7jXNeIU6vIru+ir8TmlIZy43PM5zAuKsUTeW8BuGkGX5W7X7Tn/DP7fc?= =?us-ascii?Q?Koog3+SlH/I0pQHB5z/RULpERjC+O2nQ5Tvcux8CjKVmrNTPVZ1sPrEdiMiC?= =?us-ascii?Q?a3bHyXr2cJ8p90G0Y129H4FcARw0GgUdnuNET+5VSUumUb1D4XU3krrZc3ij?= =?us-ascii?Q?cZwk5o0Qogfh8+e4Pmulz3SGH0rlX1FZ1X/sk/h4bCZNaOsEFzUC2+GwcA2u?= =?us-ascii?Q?8HfqIticnLpWFf4LObNCwR7ZropF18N+u7kV6Q1MYAVitu3HRFqVSXAj0Rn6?= =?us-ascii?Q?UsK1aF5gCeK1Uqi+zFurxh1zJZBRBqxh6C880ySk9D2Nf4YfheWjpoWwNvny?= =?us-ascii?Q?bbzNZExRkpEPGPR8Po4LAcMa+Tk8V3TBlKpsqTJd/hQjw31cTrT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NpDjvgPouzu1NKTUYEsiCkzL5/oN34i0BoT?= =?us-ascii?Q?wuBK10Y5y/4TXYDMOUp44Qf+mK13yvLR9v4FiXpUQmDSscJlQOVjUAqUglVl?= =?us-ascii?Q?6Y/P2eNeoqXXjv0nmCo03qjBw+YyACY8gnxJ9F2ryikVm+kZYynEf1nbkcRE?= =?us-ascii?Q?cY8kMWJTrqVJyK300jkH0N5ku/6rOWoXmJ1G3/uwjAm4pApWLWR10WMmsSU0?= =?us-ascii?Q?+55ML++/3prhgLm4uNqft4yAJimXKDLtbNsNaOaIio8mvtcizCvYG5ScmhwR?= =?us-ascii?Q?9l5ztS34RN/fLCl3xCIVdyLugEMH6hkdogUHLDsCw7PJ5wrMm1hpsjij3fin?= =?us-ascii?Q?Aw=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8700e895-8a4c-48e1-ffc3-08dbb8f694ee X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2023 09:55:40.6095 (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: o74jDEKKx3n8IB4CMiC4321WcWOs966HxVpwtXjcRIyyeZQVJGOCTlx9XdveScy+bYQ5Rm32VT1KG0vOlZyj1AqnUa0aCTYn0VxCL5yNWwA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR13MB5868 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Move the definition of data structure and macro into the implement file. Also sync the logic from kernel driver and remove the unneeded header file include statements. Signed-off-by: Chaoyong He --- drivers/net/nfp/nfpcore/nfp_mip.h | 4 +- drivers/net/nfp/nfpcore/nfp_nffw.c | 105 +++++++++++++++++++---------- drivers/net/nfp/nfpcore/nfp_nffw.h | 66 +----------------- 3 files changed, 72 insertions(+), 103 deletions(-) diff --git a/drivers/net/nfp/nfpcore/nfp_mip.h b/drivers/net/nfp/nfpcore/nfp_mip.h index 7fa09ee575..dbd9af31ed 100644 --- a/drivers/net/nfp/nfpcore/nfp_mip.h +++ b/drivers/net/nfp/nfpcore/nfp_mip.h @@ -6,7 +6,7 @@ #ifndef __NFP_MIP_H__ #define __NFP_MIP_H__ -#include "nfp_nffw.h" +#include "nfp_cpp.h" struct nfp_mip; @@ -16,7 +16,5 @@ void nfp_mip_close(struct nfp_mip *mip); const char *nfp_mip_name(const struct nfp_mip *mip); void nfp_mip_symtab(const struct nfp_mip *mip, uint32_t *addr, uint32_t *size); void nfp_mip_strtab(const struct nfp_mip *mip, uint32_t *addr, uint32_t *size); -int nfp_nffw_info_mip_first(struct nfp_nffw_info *state, uint32_t *cpp_id, - uint64_t *offset); #endif /* __NFP_MIP_H__ */ diff --git a/drivers/net/nfp/nfpcore/nfp_nffw.c b/drivers/net/nfp/nfpcore/nfp_nffw.c index df6292e909..2f07fcd6c1 100644 --- a/drivers/net/nfp/nfpcore/nfp_nffw.c +++ b/drivers/net/nfp/nfpcore/nfp_nffw.c @@ -3,12 +3,76 @@ * All rights reserved. */ -#include "../nfp_logs.h" -#include "nfp_cpp.h" #include "nfp_nffw.h" + +#include "../nfp_logs.h" #include "nfp_mip.h" -#include "nfp6000/nfp6000.h" #include "nfp_resource.h" +#include "nfp6000/nfp6000.h" + +/* + * Init-CSR owner IDs for firmware map to firmware IDs which start at 4. + * Lower IDs are reserved for target and loader IDs. + */ +#define NFFW_FWID_EXT 3 /* For active MEs that we didn't load. */ +#define NFFW_FWID_BASE 4 + +#define NFFW_FWID_ALL 255 + +/* + * NFFW_INFO_VERSION history: + * 0: This was never actually used (before versioning), but it refers to + * the previous struct which had FWINFO_CNT = MEINFO_CNT = 120 that later + * changed to 200. + * 1: First versioned struct, with + * FWINFO_CNT = 120 + * MEINFO_CNT = 120 + * 2: FWINFO_CNT = 200 + * MEINFO_CNT = 200 + */ +#define NFFW_INFO_VERSION_CURRENT 2 + +/* Enough for all current chip families */ +#define NFFW_MEINFO_CNT_V1 120 +#define NFFW_FWINFO_CNT_V1 120 +#define NFFW_MEINFO_CNT_V2 200 +#define NFFW_FWINFO_CNT_V2 200 + +/* nfp.nffw meinfo */ +struct nffw_meinfo { + uint32_t ctxmask_fwid_meid; +}; + +struct nffw_fwinfo { + uint32_t loaded_mu_da_mip_off_hi; + uint32_t mip_cppid; /**< 0 means no MIP */ + uint32_t mip_offset_lo; +}; + +struct nfp_nffw_info_v1 { + struct nffw_meinfo meinfo[NFFW_MEINFO_CNT_V1]; + struct nffw_fwinfo fwinfo[NFFW_FWINFO_CNT_V1]; +}; + +struct nfp_nffw_info_v2 { + struct nffw_meinfo meinfo[NFFW_MEINFO_CNT_V2]; + struct nffw_fwinfo fwinfo[NFFW_FWINFO_CNT_V2]; +}; + +struct nfp_nffw_info_data { + uint32_t flags[2]; + union { + struct nfp_nffw_info_v1 v1; + struct nfp_nffw_info_v2 v2; + } info; +}; + +struct nfp_nffw_info { + struct nfp_cpp *cpp; + struct nfp_resource *res; + + struct nfp_nffw_info_data fwinf; +}; /* * flg_info_version = flags[0]<27:16> @@ -61,32 +125,6 @@ nffw_fwinfo_mip_offset_get(const struct nffw_fwinfo *fi) return (mip_off_hi & 0xFF) << 32 | fi->mip_offset_lo; } -#define NFP_IMB_TGTADDRESSMODECFG_MODE_of(_x) (((_x) >> 13) & 0x7) -#define NFP_IMB_TGTADDRESSMODECFG_ADDRMODE RTE_BIT32(12) -#define NFP_IMB_TGTADDRESSMODECFG_ADDRMODE_32_BIT 0 -#define NFP_IMB_TGTADDRESSMODECFG_ADDRMODE_40_BIT RTE_BIT32(12) - -static int -nfp_mip_mu_locality_lsb(struct nfp_cpp *cpp) -{ - int err; - uint32_t mode; - uint32_t addr40; - uint32_t xpbaddr; - uint32_t imbcppat; - - /* Hardcoded XPB IMB Base, island 0 */ - xpbaddr = 0x000a0000 + NFP_CPP_TARGET_MU * 4; - err = nfp_xpb_readl(cpp, xpbaddr, &imbcppat); - if (err < 0) - return err; - - mode = NFP_IMB_TGTADDRESSMODECFG_MODE_of(imbcppat); - addr40 = !!(imbcppat & NFP_IMB_TGTADDRESSMODECFG_ADDRMODE); - - return nfp_cppat_mu_locality_lsb(mode, addr40); -} - static uint32_t nffw_res_fwinfos(struct nfp_nffw_info_data *fwinf, struct nffw_fwinfo **arr) @@ -239,14 +277,7 @@ nfp_nffw_info_mip_first(struct nfp_nffw_info *state, *offset = nffw_fwinfo_mip_offset_get(fwinfo); if (nffw_fwinfo_mip_mu_da_get(fwinfo) != 0) { - int locality_off; - - if (NFP_CPP_ID_TARGET_of(*cpp_id) != NFP_CPP_TARGET_MU) - return 0; - - locality_off = nfp_mip_mu_locality_lsb(state->cpp); - if (locality_off < 0) - return locality_off; + int locality_off = nfp_cpp_mu_locality_lsb(state->cpp); *offset &= ~(NFP_MU_ADDR_ACCESS_TYPE_MASK << locality_off); *offset |= NFP_MU_ADDR_ACCESS_TYPE_DIRECT << locality_off; diff --git a/drivers/net/nfp/nfpcore/nfp_nffw.h b/drivers/net/nfp/nfpcore/nfp_nffw.h index 52e25c090a..fd46009d37 100644 --- a/drivers/net/nfp/nfpcore/nfp_nffw.h +++ b/drivers/net/nfp/nfpcore/nfp_nffw.h @@ -8,71 +8,11 @@ #include "nfp_cpp.h" -/* - * Init-CSR owner IDs for firmware map to firmware IDs which start at 4. - * Lower IDs are reserved for target and loader IDs. - */ -#define NFFW_FWID_EXT 3 /* For active MEs that we didn't load. */ -#define NFFW_FWID_BASE 4 - -#define NFFW_FWID_ALL 255 - -/* - * NFFW_INFO_VERSION history: - * 0: This was never actually used (before versioning), but it refers to - * the previous struct which had FWINFO_CNT = MEINFO_CNT = 120 that later - * changed to 200. - * 1: First versioned struct, with - * FWINFO_CNT = 120 - * MEINFO_CNT = 120 - * 2: FWINFO_CNT = 200 - * MEINFO_CNT = 200 - */ -#define NFFW_INFO_VERSION_CURRENT 2 - -/* Enough for all current chip families */ -#define NFFW_MEINFO_CNT_V1 120 -#define NFFW_FWINFO_CNT_V1 120 -#define NFFW_MEINFO_CNT_V2 200 -#define NFFW_FWINFO_CNT_V2 200 - -/* nfp.nffw meinfo */ -struct nffw_meinfo { - uint32_t ctxmask_fwid_meid; -}; - -struct nffw_fwinfo { - uint32_t loaded_mu_da_mip_off_hi; - uint32_t mip_cppid; /* 0 means no MIP */ - uint32_t mip_offset_lo; -}; - -struct nfp_nffw_info_v1 { - struct nffw_meinfo meinfo[NFFW_MEINFO_CNT_V1]; - struct nffw_fwinfo fwinfo[NFFW_FWINFO_CNT_V1]; -}; - -struct nfp_nffw_info_v2 { - struct nffw_meinfo meinfo[NFFW_MEINFO_CNT_V2]; - struct nffw_fwinfo fwinfo[NFFW_FWINFO_CNT_V2]; -}; - -struct nfp_nffw_info_data { - uint32_t flags[2]; - union { - struct nfp_nffw_info_v1 v1; - struct nfp_nffw_info_v2 v2; - } info; -}; - -struct nfp_nffw_info { - struct nfp_cpp *cpp; - struct nfp_resource *res; - - struct nfp_nffw_info_data fwinf; -}; +struct nfp_nffw_info; struct nfp_nffw_info *nfp_nffw_info_open(struct nfp_cpp *cpp); void nfp_nffw_info_close(struct nfp_nffw_info *state); +int nfp_nffw_info_mip_first(struct nfp_nffw_info *state, uint32_t *cpp_id, + uint64_t *offset); #endif /* __NFP_NFFW_H__ */ -- 2.39.1