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 807EE42600; Tue, 19 Sep 2023 11:55:46 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0BB3940A6E; Tue, 19 Sep 2023 11:55:44 +0200 (CEST) Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2137.outbound.protection.outlook.com [40.107.96.137]) by mails.dpdk.org (Postfix) with ESMTP id 838F8406FF for ; Tue, 19 Sep 2023 11:55:42 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TlLwQE5WIZ7nd0Ox0bK20FENPBad0HTRUTOhj2vqKpFao2I7MHU0A8Np52rka2555Dzy9QAUPPdYCKOsSUxtPhNhq0nLLAAePDxBLo9Q7Sw46PbVewFXNNmrYo8tmdaLaKC5dfbBbWJBjX3Pm0ezClV83oVjWFIn/RVe6ffWWXipBseUY6bb87ztLINQu47pZAlnhpjzkhaS8R1qPLmMlBfSypC0/n5GdjNSGzvpAVjNN0OvfMNE53uR7BcEcWuhkoQH0/6qSDpImllKTpzWBX/85RloZtW2zFsNyt1CjSGxmHEOkvnSFpp/dE3fFf3KTmJU2fWHCUSgKmE9zc/ZeA== 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=zxWDQ73XSyjxbiBxxIJvtl160kD70OHqwYr5vm8WHSk=; b=F+DXv5G4y8RU6nBlBot/1ban2i2/UO/Do+yP3ewjj7Z4S1DCgIchEouWKhNkFzq9rlZbgOMsjuMlztjRgdLLSCYuemBnUj/CCa+iyGuXbeti7WGOcsOv9AgdoJbwS/CFWqQIn7basJtTrta37ak7eL8y7CI54HhPRpe9BCgaX0Yi0Tf8i5Kekxk5k5vJNNXItfGsBAg3etFqqza3yUUulBtWhT1XeuoWdUknEyhK3JNCVA29chmr9d5dDdsmX3kEAxw5/w/ZFlHVWXq0ObVr6tDI8bgzJb04z/I7LoveUwTnAisVg0u5NozWBXoBWlZPlGKfFYfdtFq079NuNo/4HQ== 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=zxWDQ73XSyjxbiBxxIJvtl160kD70OHqwYr5vm8WHSk=; b=Gx/r/0vERqFzhyD7aq7CgplHKOQgPfB18oWOPuukVBu8hnx5bIvmpT8++Y4h08u0CKpronu2kE/1lM0WyDZUUo2FBiXOlHpCnpsSR+J6h0eTZaaTDhCtnxCBdOwvPNq7f4Sn4j2dBnzm16f83qZ2c0cBig9mvHpGn7GC/BxDZAs= 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:39 +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:39 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Chaoyong He Subject: [PATCH v5 11/26] net/nfp: refact the hwinfo module Date: Tue, 19 Sep 2023 17:54:25 +0800 Message-Id: <20230919095440.45445-12-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: 8a6811cb-f726-4d9a-edd1-08dbb8f6940e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wyxMBpJVdgGsCMqvH5c2GHE0jsAVjb9jmxirZ754Pi2IN5XaUDn5kHHkwyZ0N2/2RtLNduax3Wcjy063u7l+BR2wu9QXj3PzrrlsUbh7UyIc5AK7V0H0oRlRAh+qtpqYmJgXxIF0kffYMK78kgUtsnyLDctyBKx7+9Bk4xS5cGCTn7luQfcmsD7EP0TQ90XLq4UABluGMIsfJ/nkcgZsBHavFcRRyfpfky0tqv0RbIKDpYUQW9/sndhOGXIkqAJpHH0bHHEx8UvztcDdY34lB9abInEmQZKo7EXRnEY6xOoSVyya1XPvgiQe46QxkHD70Vb190YftA6mweiewS3PO2d2Ks+m6Q5F1IkkK3WdMUcWdAaooxaWeG08oU9nN4paBqHO6YCADMQnJF9SEJPjqk1mCAeFJyyfKJe1g8jlSJ4EYrRyYpFf4vWbGyw87MS3tYjSvFjxPMLTmqoIsctv4LQ1SZhB86MAeRuZIrxhvICZOUX3bq9k4thzATfIxfqKtDo1q6xy8KrlP3lh1/Y/+Vgw4XQk3c8lHGdfepyyWw8Ky4WIjGy9/ug5KYz7f5OtC7Xp9vPxrFRcgU9McHDi2KSo4HdZ4l8DtqIJc5tzMEx1xiJ62ol61VsRHGFuW2qPel6sqjJfjPbEeVmBWot+1yf2PSmQyyvfDDZaN1iRe/A= 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?zs/GnduYJz6LC3gDGGfx3QVd+tNRu1q9V25N57c94a8J02MxOfM379STBxKs?= =?us-ascii?Q?gFIJPDPA49i8EjQl4Liu1rhNgZo9FG08EbkrvujbbtfSQy3TtZy4RysKjffM?= =?us-ascii?Q?DKjkW2G13/3igX5zjeStF08F1l4+QCkLutQltvZqnzklfknLzLC0a5tK+zoh?= =?us-ascii?Q?cDGn2GtFY6WQbqZEXXpyNLRxRsWy4Z5NwsxbdxKIeb2rs6MtL44uqrbBaLND?= =?us-ascii?Q?1A+lrEp6XIgfTZAEk1VSJzKEHyIb2PJj0kPAFXKURFNuvAbf3sEIccNxjYtL?= =?us-ascii?Q?01LdwhSJ4Frs1UVhT8mFRjiWeea0TwSRTwVSKDHPikjX9cLnvP3vp+lobiBr?= =?us-ascii?Q?qkPtR9EtiwoYI7PgZwv3iOz/ru3+ly9eMkTxNCOIrkRcMy3LI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0X/76B0DyqmZeLeWwG6gdwuuJ/nU/qwQ0xN?= =?us-ascii?Q?KzbwCH0xxjJ03cI08QyV9pZXAkrJiE9hl63ItwN+LGCSTGxGkxKIxCUl8B5G?= =?us-ascii?Q?MzzFOdYkECBzIK44xWpxa46pAeJDFbZWF5qi6Oz52nxgU15wl8Fqd197x4VT?= =?us-ascii?Q?7SySvGL3qAkEkpBovK4ZInhf3NFeZcVwDCyQsLzR+qSiI1N7DF7An7quzuNz?= =?us-ascii?Q?l3LfS7F3EuhmX/PJr7twNzDpGxo6/5Sjl2zSSFN0YLux9kpHLlJnW81tsbfq?= =?us-ascii?Q?Sh3KNwp9MQlTLzj8tT6cyEYSNGxJ5he22ygUg/wzfnE+LwAFaK2MAglbsV05?= =?us-ascii?Q?RA=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8a6811cb-f726-4d9a-edd1-08dbb8f6940e 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:39.1345 (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: aWF6qoX4O0hqrMvZjxlLQzAiMFIDoHCWr5R3NWUl8nhj6Mo2yZwDspT1jPbahVL8GNQ0uu8MwdayA33wOi2/7GI0809J+li+1xINmKvO1Vg= 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 remove the unneeded header file include statements. Signed-off-by: Chaoyong He --- 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 e33e660ea9..c334202bd7 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: 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