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 41179425A3; Fri, 15 Sep 2023 11:18:00 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1739141611; Fri, 15 Sep 2023 11:16:43 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2091.outbound.protection.outlook.com [40.107.237.91]) by mails.dpdk.org (Postfix) with ESMTP id 3F04F41157 for ; Fri, 15 Sep 2023 11:16:40 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kn6QCgk2vZwipiaAoEfBaX91AfoZd8F8wE7/kRcDqMYIM6UvYx6YcL4lJzaHEC6p2Lf/LF9MpjpqAKph6Rk/BOXZk3Pt8KBT/ulubOZs9IdMVno/z6M0V9sfevP8cmWpf4SNB8SYDpPMMjMOXn6mOwf+qJf/bvou3Yc7F0uLfYc3lfxMf6F4nq2ITDGoIxkeOIy50FWBcFtr/ngzoh5jpi0fZ73lra0vCXEnTSct7b+8cyA32k0cAlz7EsR3kh5ioAmKeSTacnmKNkKMb385OAfnMxO41YOMlUskbCCwpKckV3ByvdZFf9q6sYuXwuFtktI3V3tOSFafCcPEEWAlqQ== 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=+yvZDG2HDEPnYtWF1Wkl+yal9KI7LdfqgZhh7PgB9Zg=; b=V2tVULe2v96LHzNnbtUq/n+qKOY0RJiDnvxS/fpJJnT6p1wS7hwpXYWqXOX9zADYAVMDm3LmySdBS4JQqIMmr1Jqd4INqheZUM/62zECO1501S551xU/Kpa2QoF/24f5lTr16DqHB7Tysm+EP8XriD2VSC4n+Wb8cNEI4EP9l1WTyaceEhtcvHR1YFZDmYvmp5l3oXhOFCPBCcKkBn1bavWcYevkmmYzVD38o6ybCg2NYkszbNsmLw1r1KttIZBzN0Lfr5rT1bJNYoku9cK8qPDeOu3s9GaU+ozFI66/1pP9tZX+1Cf6dmYSrVaW1Saouj/B+/ElQTP6O+aIAzYg8Q== 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=+yvZDG2HDEPnYtWF1Wkl+yal9KI7LdfqgZhh7PgB9Zg=; b=Td/wvO2F93XNIx86mgfrV3Axfzw+9ZEhjtS/0lCO/A7AKl821Lz5bHWnNKhZHWKnt7ylNwYoQ9saEEaGadoQVer+lL7iHtBiokSRQd0sRRvPJJi/+mYWukykYVr5wjuNCbfTGgzTKJeC6aICGPavY2Qisz6OgkMXZXQ0KkyX3sE= 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 CO1PR13MB4773.namprd13.prod.outlook.com (2603:10b6:303:fb::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.21; Fri, 15 Sep 2023 09:16:38 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::c05c:6915:1628:70c4]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::c05c:6915:1628:70c4%7]) with mapi id 15.20.6768.029; Fri, 15 Sep 2023 09:16:38 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Chaoyong He , =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [PATCH v3 12/27] net/nfp: refact the hwinfo module Date: Fri, 15 Sep 2023 17:15:36 +0800 Message-Id: <20230915091551.1459606-13-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230915091551.1459606-1-chaoyong.he@corigine.com> References: <20230830021457.2064750-1-chaoyong.he@corigine.com> <20230915091551.1459606-1-chaoyong.he@corigine.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: PH7PR10CA0017.namprd10.prod.outlook.com (2603:10b6:510:23d::10) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|CO1PR13MB4773:EE_ X-MS-Office365-Filtering-Correlation-Id: c9deae8d-dd65-435e-e93d-08dbb5cc7770 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Oghf1cMwp4EcG71HBQ5iXzwfbrAG52UpSufZ3mEDX8AtvV7WLvICYEGfLsHDSLfiGWCS3vEqWg85kla53IviCZrHf1W9+y/QM3e1t5J3NAqFE1zF8pv7Vm1DnUx6YoDoA1YPCyC0OLHf8kV67TZJXV2jFamO0ozXGeEbdc6mg7V7hPUXMT2XizqQr+FLKYjJ94lzDsiWsbDypJm/dYjKmd44ZaX+mzZh9Nv8IN616KF4N3S20JL0Q9UQDheNX9E1nJ3QLekYC6gPXBehYzTNxO6yfk6cgihCdxOw9rqtDvQISHva4OwvtcuqPIYDx7Vwd3pwLoTfCxVr0MEhr0lFu/+7JXdfnWCUeWU1MfS6fxoAOgrbaXg5LGL9GbXz/2jaLOApjZg1zl8iRbQP5P/mp0kJRbpem8XXJxzrB3tC0rmOTXEVUPPDEth/DYX7oksbuXqLGrMoRtye9pWbiIHAiaoSqG3j4PNJm5JqB88MPAqf5djh3PENNJQSkgXpy4QtuL6lfmDA+A/oZMZidTkLEFWZdosN4QHLn2BmDAdAeMBpy18RKORymY2aJw67oO/Ra1Qu2ff+92mwV0DH3VC0viP4+FMtRb7ebCWycRjp6yDFxRkt8xj+9p4gFQ1Fbz0PMuDv3UXVHx8Mjlbc7LTlycrxe6h7LX3wC0bc67mLPsI= 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)(39840400004)(346002)(136003)(376002)(396003)(366004)(451199024)(186009)(1800799009)(6512007)(107886003)(1076003)(2616005)(52116002)(6506007)(6486002)(66946007)(26005)(316002)(41300700001)(66476007)(66556008)(6916009)(54906003)(5660300002)(4326008)(8676002)(38350700002)(8936002)(38100700002)(478600001)(66574015)(83380400001)(36756003)(44832011)(86362001)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?d1BQMmV6MjhwZ2tkeDBCWjNpT1NJYVFGWDRZdE91UVN3cjB6cXBpd1ZwT25u?= =?utf-8?B?Z1VqaVFoV1UvVmxIVGhZTTlKM0xSWkNVNTdzZVZnbjA0NUlGMnNTcUpSNVpJ?= =?utf-8?B?NWJHSXJ0RFlHN1FWRjY4bFlNS0xxakFMekxISFY5cHhXRFpUVjIyMXZQdU5n?= =?utf-8?B?M0lmVzdycUR5UWFNOUtBTHpuQmRhM2V6M0RMMlVXSS9HUnAzYzZ0S3RPTVRL?= =?utf-8?B?N0ZFeXhobTBycWsrZU9ibk1SUFdLcFgvVHBxallRSmxzR0tiak1iMit1ZXlh?= =?utf-8?B?M09BUUYrWmRKcEh6VDZCYWlrK3lHaTNwY3lEWTBLRFVFTStNZ0JWVHhPaksw?= =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mNwTVd6NytxSGpEVEt6TW9P?= =?utf-8?B?Y1E9PQ==?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: c9deae8d-dd65-435e-e93d-08dbb5cc7770 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2023 09:16:38.7860 (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: a+UjetcMufvl2zoh3JpiDJuvoPqNnmoxwUuJF/xyeNCFoXPyi9VmiuKw6n+JtM9AL7ZKd7GFRrTiNVFXM30a42NkmpWY8lkeAuwZ1P+60AU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR13MB4773 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 remove the unneeded header file include statements. Signed-off-by: Chaoyong He Reviewed-by: Niklas Söderlund --- drivers/net/nfp/nfpcore/nfp_hwinfo.c | 84 +++++++++++++++++++++++++--- drivers/net/nfp/nfpcore/nfp_hwinfo.h | 71 +---------------------- 2 files changed, 77 insertions(+), 78 deletions(-) diff --git a/drivers/net/nfp/nfpcore/nfp_hwinfo.c b/drivers/net/nfp/nfpcore/nfp_hwinfo.c index cee37210b0..25c2262dfc 100644 --- a/drivers/net/nfp/nfpcore/nfp_hwinfo.c +++ b/drivers/net/nfp/nfpcore/nfp_hwinfo.c @@ -17,17 +17,82 @@ * (ie, in this example, ME 39 has been reserved by boardconfig.) */ -#include -#include +#include "nfp_hwinfo.h" -#include "nfp_cpp.h" +#include "nfp_crc.h" #include "nfp_logs.h" -#include "nfp6000/nfp6000.h" #include "nfp_resource.h" -#include "nfp_hwinfo.h" -#include "nfp_crc.h" -static int +#define HWINFO_SIZE_MIN 0x100 + +/* + * The Hardware Info Table defines the properties of the system. + * + * HWInfo v1 Table (fixed size) + * + * 0x0000: uint32_t version Hardware Info Table version (1.0) + * 0x0004: uint32_t size Total size of the table, including the + * CRC32 (IEEE 802.3) + * 0x0008: uint32_t jumptab Offset of key/value table + * 0x000c: uint32_t keys Total number of keys in the key/value table + * NNNNNN: Key/value jump table and string data + * (size - 4): uint32_t crc32 CRC32 (same as IEEE 802.3, POSIX csum, etc) + * CRC32("",0) = ~0, CRC32("a",1) = 0x48C279FE + * + * HWInfo v2 Table (variable size) + * + * 0x0000: uint32_t version Hardware Info Table version (2.0) + * 0x0004: uint32_t size Current size of the data area, excluding CRC32 + * 0x0008: uint32_t limit Maximum size of the table + * 0x000c: uint32_t reserved Unused, set to zero + * NNNNNN: Key/value data + * (size - 4): uint32_t crc32 CRC32 (same as IEEE 802.3, POSIX csum, etc) + * CRC32("",0) = ~0, CRC32("a",1) = 0x48C279FE + * + * If the HWInfo table is in the process of being updated, the low bit of + * version will be set. + * + * HWInfo v1 Key/Value Table + * ------------------------- + * + * The key/value table is a set of offsets to ASCIIZ strings which have + * been strcmp(3) sorted (yes, please use bsearch(3) on the table). + * + * All keys are guaranteed to be unique. + * + * N+0: uint32_t key_1 Offset to the first key + * N+4: uint32_t val_1 Offset to the first value + * N+8: uint32_t key_2 Offset to the second key + * N+c: uint32_t val_2 Offset to the second value + * ... + * + * HWInfo v2 Key/Value Table + * ------------------------- + * + * Packed UTF8Z strings, ie 'key1\000value1\000key2\000value2\000' + * Unsorted. + * + * Note: Only the HwInfo v2 Table be supported now. + */ + +#define NFP_HWINFO_VERSION_1 ('H' << 24 | 'I' << 16 | 1 << 8 | 0 << 1 | 0) +#define NFP_HWINFO_VERSION_2 ('H' << 24 | 'I' << 16 | 2 << 8 | 0 << 1 | 0) +#define NFP_HWINFO_VERSION_UPDATING RTE_BIT32(0) + +struct nfp_hwinfo { + uint8_t start[0]; + + uint32_t version; + uint32_t size; + + /* V2 specific fields */ + uint32_t limit; + uint32_t resv; + + char data[]; +}; + +static bool nfp_hwinfo_is_updating(struct nfp_hwinfo *hwinfo) { return hwinfo->version & NFP_HWINFO_VERSION_UPDATING; @@ -120,7 +185,7 @@ nfp_hwinfo_try_fetch(struct nfp_cpp *cpp, goto exit_free; } - header = (void *)db; + header = (struct nfp_hwinfo *)db; if (nfp_hwinfo_is_updating(header)) goto exit_free; @@ -133,7 +198,8 @@ nfp_hwinfo_try_fetch(struct nfp_cpp *cpp, /* NULL-terminate for safety */ db[*cpp_size] = '\0'; - return (void *)db; + return (struct nfp_hwinfo *)db; + exit_free: rte_free(db); return NULL; diff --git a/drivers/net/nfp/nfpcore/nfp_hwinfo.h b/drivers/net/nfp/nfpcore/nfp_hwinfo.h index 543562779a..c812f10076 100644 --- a/drivers/net/nfp/nfpcore/nfp_hwinfo.h +++ b/drivers/net/nfp/nfpcore/nfp_hwinfo.h @@ -6,76 +6,9 @@ #ifndef __NFP_HWINFO_H__ #define __NFP_HWINFO_H__ -#include +#include "nfp_cpp.h" -#define HWINFO_SIZE_MIN 0x100 - -/* - * The Hardware Info Table defines the properties of the system. - * - * HWInfo v1 Table (fixed size) - * - * 0x0000: uint32_t version Hardware Info Table version (1.0) - * 0x0004: uint32_t size Total size of the table, including the - * CRC32 (IEEE 802.3) - * 0x0008: uint32_t jumptab Offset of key/value table - * 0x000c: uint32_t keys Total number of keys in the key/value table - * NNNNNN: Key/value jump table and string data - * (size - 4): uint32_t crc32 CRC32 (same as IEEE 802.3, POSIX csum, etc) - * CRC32("",0) = ~0, CRC32("a",1) = 0x48C279FE - * - * HWInfo v2 Table (variable size) - * - * 0x0000: uint32_t version Hardware Info Table version (2.0) - * 0x0004: uint32_t size Current size of the data area, excluding CRC32 - * 0x0008: uint32_t limit Maximum size of the table - * 0x000c: uint32_t reserved Unused, set to zero - * NNNNNN: Key/value data - * (size - 4): uint32_t crc32 CRC32 (same as IEEE 802.3, POSIX csum, etc) - * CRC32("",0) = ~0, CRC32("a",1) = 0x48C279FE - * - * If the HWInfo table is in the process of being updated, the low bit of - * version will be set. - * - * HWInfo v1 Key/Value Table - * ------------------------- - * - * The key/value table is a set of offsets to ASCIIZ strings which have - * been strcmp(3) sorted (yes, please use bsearch(3) on the table). - * - * All keys are guaranteed to be unique. - * - * N+0: uint32_t key_1 Offset to the first key - * N+4: uint32_t val_1 Offset to the first value - * N+8: uint32_t key_2 Offset to the second key - * N+c: uint32_t val_2 Offset to the second value - * ... - * - * HWInfo v2 Key/Value Table - * ------------------------- - * - * Packed UTF8Z strings, ie 'key1\000value1\000key2\000value2\000' - * Unsorted. - * - * Note: Only the HwInfo v2 Table be supported now. - */ - -#define NFP_HWINFO_VERSION_1 ('H' << 24 | 'I' << 16 | 1 << 8 | 0 << 1 | 0) -#define NFP_HWINFO_VERSION_2 ('H' << 24 | 'I' << 16 | 2 << 8 | 0 << 1 | 0) -#define NFP_HWINFO_VERSION_UPDATING RTE_BIT32(0) - -struct nfp_hwinfo { - uint8_t start[0]; - - uint32_t version; - uint32_t size; - - /* v2 specific fields */ - uint32_t limit; - uint32_t resv; - - char data[]; -}; +struct nfp_hwinfo; struct nfp_hwinfo *nfp_hwinfo_read(struct nfp_cpp *cpp); -- 2.39.1