From nobody Sat Nov 30 16:34:11 2024 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2124.outbound.protection.outlook.com [40.107.215.124]) (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 E90AAB658 for ; Mon, 9 Sep 2024 06:33:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.215.124 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725863610; cv=fail; b=UP6HM6nAcaQYe59UQeFELfvKxDYllvpbaX0rOj6a5SqzX+ahQdCaR0eUyRjHMGCe66R0PKsKi0ZfZJlx/0jharalkWESDEOxOZa0JCilEvNHrjNnRtYbIXiUCUwMFzVbt7abZTHKIzBdtjD2HfMjbWIwYZEecGQN8w6zrf1eVP0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725863610; c=relaxed/simple; bh=WPNtR9xsoyK/IBAAsPK3GUnHIDoCuavmKZNv8s4yfII=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=qXcja+wh5nkAMU9rtU+LAX/UfoS/Jf3V02bETktifwcTHcoalAAoU2eaBRRa0buHIxuvMJjzWA8oN4tQr7+kSbaBv3wBbSYjziQaZ63n6HkMRVDnzKNpIev8TL86y8gvtghldkJZdgWQFT88uk65CwCi2UeTXfP23A6tU2PxRYM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=jaguarmicro.com; spf=pass smtp.mailfrom=jaguarmicro.com; dkim=pass (2048-bit key) header.d=jaguarmicro.com header.i=@jaguarmicro.com header.b=TmjloNBV; arc=fail smtp.client-ip=40.107.215.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=jaguarmicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=jaguarmicro.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=jaguarmicro.com header.i=@jaguarmicro.com header.b="TmjloNBV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ob7gn7rSIBPz3gPwkzWKxJKVaQc7B+03qDkKrCsdNV7biopq055u2Fd3gAD3RMPRepMTyBY+DZxKTYXddmw07PY8xVAhQ4mcVLOXdsrZILREL0RCDQCybIJAqR3R2nN7XUd9Wq5dpnwNS9RKjbHj3+cDwubh2yWwrbS/5opdMGrGBXr1M6foFI8KuURPBJDxH+1kiRc9E82kDbkIroIT3DYG62eWpgJy/GLjEcG22RzIel3ZeT29HuNd8fzbKl62gKVoKL6jBDJ4zmhR4zHWmKkNhK9yYYrqo9gjLIlvjlERgnkTClAGy5wrKXFT5qH4PKBfoOZ9eo/XqUhQQDIfEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=rl1/cP/r+sNaG8LPik4cC9acY47sknQRoNv9KZVmSJk=; b=UnxH/5wnBU4+aBeV1AZK0yQWQlQeWlHMwgnZhI/KrZ2SbX7U0Y1xvfgL4/RO6p7T8dm7ErEKyX8TcAll5Pse6zosfkmNE+su/Su4vsY8YQ2Op+XMV6tyNOTnqI99PQOePOfW3Xx9UhLbuGGoKB3b7oNPMgnOseouN/cfbFUCwZVM+x62ZKha68ul3sRueXeDdWogJrPDI3pnEIUEtYPoCh0VDl2k9PUh8ViXzoETkSH3f9A5Ekhyp9pfIMYyZj6s/kfQDozWr7rnYD3bjezFKGZUspC1cmI2PugigxCYWUW5OK8l6n1HktFW5BrFu282KPxyUiL8tCUSgj96Z955iQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=jaguarmicro.com; dmarc=pass action=none header.from=jaguarmicro.com; dkim=pass header.d=jaguarmicro.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jaguarmicro.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rl1/cP/r+sNaG8LPik4cC9acY47sknQRoNv9KZVmSJk=; b=TmjloNBVwzbf1HcihM9E51LNRklA9INAe7rAhEicJz3DApM7yGHZbihIe1tvL3Ojt3/BDt6p+MZVNQMU6Je9AmxhPRB4hdswsgM3SsU3kjp8suMufkZXioy3/wElFgXQWnNZHc3By5HGMrMtEmx436JB1vHlHvlYOV7LsQ06ahL8D/QSXgQcSNrXoOumnri++uACrZlmiIi2gyPmy7BnLHhoLTdy4WY1luo8/1TGsD6P0OOfpVzNVk9tJZrxDhxaH7FxHPW8HQVAciq8tUKf4rjWFn7MkL4EVhQAEJn8fnSw4+GhIS8u3rARH0EDlwFKLoX1uJYTmHZx0bWu/kQRdA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=jaguarmicro.com; Received: from TYZPR06MB3933.apcprd06.prod.outlook.com (2603:1096:400:29::9) by KL1PR06MB6473.apcprd06.prod.outlook.com (2603:1096:820:ef::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.23; Mon, 9 Sep 2024 06:33:20 +0000 Received: from TYZPR06MB3933.apcprd06.prod.outlook.com ([fe80::9b60:a415:f5ed:a367]) by TYZPR06MB3933.apcprd06.prod.outlook.com ([fe80::9b60:a415:f5ed:a367%7]) with mapi id 15.20.7939.022; Mon, 9 Sep 2024 06:33:20 +0000 From: "Shawn.Shao" To: jacob.e.keller@intel.com, linux-kernel@vger.kernel.org Cc: Shawn Shao Subject: [PATCH] lib: Export the parsing functions and related data structures of the PLDM library Date: Mon, 9 Sep 2024 14:33:10 +0800 Message-Id: <20240909063310.1730-1-shawn.shao@jaguarmicro.com> X-Mailer: git-send-email 2.37.2.windows.2 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: TYWP286CA0001.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:178::12) To TYZPR06MB3933.apcprd06.prod.outlook.com (2603:1096:400:29::9) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR06MB3933:EE_|KL1PR06MB6473:EE_ X-MS-Office365-Filtering-Correlation-Id: a8ae3b1c-4b3c-4627-de03-08dcd0994bd9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|1800799024|366016|376014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?SFFTNWdHYk1GZTlyVVVCZi9yaTc4aUpJbitRRnQ3bXYwbGV5TDZTRjNaaUJn?= =?utf-8?B?czFhS3dQdzMwa2lhQjJpTFc5SHpGTDRlYSttck1QMFh5ekxFNUJuY2JDVi8v?= =?utf-8?B?TFhBNTYrMlFFWDNZTFZLQXpuTmV3VXU1N2hLQ2VMeURUVkpUU2sxZ1FLaWx3?= =?utf-8?B?Z3U0QjJlVW1jMVhnUk55SGtPbnhtU3YrT2Z1UGFSbUhNTnB4MWJsR2tlU2Zu?= =?utf-8?B?Si9JV1g2YUZvOVlhMG1CcFF6MnZ4SGNYOTBENk56RG83cG9hT2lBem5HWm9P?= =?utf-8?B?UjlPNk0xYVM3Z0tqWTA3TVVJV2E5SXVjYSt3U1dtZ2tPYUwvbVd4TndLdENX?= =?utf-8?B?b3UzQVdPMVpJWW9GWmdNV1hMd2p0bDVQOG1FYVBkL1E0Yjd5STcxMzlVSDJt?= =?utf-8?B?aktYK0lKNThQcm5odU96OGk1R2RDZEVjTjVZUlFya1VLd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c3VmVjZ3lLUktrcUQydDhtOStPL0RtTk1OenpSQUZxbkV2a2JE?= =?utf-8?B?bnliYXRkS3hMRE1XN3NiNWYwZktHbzc0NzhRWi9ac2RLbnFYVm9HQ1c1bU5j?= =?utf-8?B?eHZidE9HNHkvTmF0eVByUlFiTDFJa2NncnBMaGxZVUxhcExnV1M5NnZ0VThX?= =?utf-8?B?a291S3FNOFpjRU11clBRS2wwWUdMd05YMHVQb1N1QmhGcFhLQWdiSEUwK3pv?= =?utf-8?B?bVNGOFVGL3V3dTBsajUrNmpWT3dKWDBhZjZTNnlGazNTMGFkU2hiR292TG91?= =?utf-8?B?NElJQ05saC93SXFkRzZLUlNIT3kxOFFiVnZwa2puSWowcGw0MGo2S3J4amM4?= =?utf-8?B?c21GTEF4UVJNZG5RWkp5R0RkdEZiM1JZTzdheW1RUnJaWTE2cVBZeU9DVk9q?= =?utf-8?B?RTc3UFRCWnhlVnlSYUZEWHhuK0RBbG1ieE5qRHV0OEJuTFpZaXQwSTdIWENp?= =?utf-8?B?MzEwb1Z6dWJrZmZhVDVxQXI4Mm16ZmRpNHlBRDVJa3BKVWVKaG90T2ZVS3R4?= =?utf-8?B?ZVMwS04zd01KdjhqQkFBc3BlVTdVUTJwVlFyQ2Qxc0swSnc9PQ==?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYZPR06MB3933.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(1800799024)(366016)(376014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?SkF2VXJWNkVUek00NUs4aUxNNTIrTlZrcnlacmFickFBVm5VdDN3Ty9mcTZJ?= =?utf-8?B?YmJiVDBodGY2bjVxem8wL1BNWHBCRCs3V0lId25iUFZucFJ5QmtvazUwVXgr?= =?utf-8?B?SjZCN1QvMT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TR3VwVTZSRHBZY0NwN3V5?= =?utf-8?B?c0hiSkcxZEg4OFFwY1JlTlcrQy9NNHNaekg5NlB5cjYyTUtZNnlLcUt2RVNQ?= =?utf-8?B?MzQ3ckFLVGhHbmFyY3RNd0llcmRhQzM5UjEyY2hrRERXL0s1WFk3R2RoMzZq?= =?utf-8?B?eVBlWGYxUWRmVjBveDNzdnk5dy85UjEycDRMY0VuVkZ5UmZHYzVNMnVtY215?= =?utf-8?B?Z0tPeVgyT3BsV2d1SWtCcmdBNkJsc2w0czdtdjRwNDFkOG5GdHUzZFh3SW9y?= =?utf-8?B?WWc9PQ==?= X-OriginatorOrg: jaguarmicro.com X-MS-Exchange-CrossTenant-Network-Message-Id: a8ae3b1c-4b3c-4627-de03-08dcd0994bd9 X-MS-Exchange-CrossTenant-AuthSource: TYZPR06MB3933.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Sep 2024 06:33:20.3440 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 1e45a5c2-d3e1-46b3-a0e6-c5ebf6d8ba7b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: xxeraH8dmqmtCUPGkJM4y+fnznYkVeeX4vkver3X6gMl8qQWrTx91nhNy27l+X0wUTnvzW+HLpNK6KtDZijaErcXlmt+osUANPBG0mcfdIM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR06MB6473 From: Shawn Shao The PLDM library is used to implement firmware upgrades, but the current library functions only support the `pldmfw_flash_image` function to complete a fixed process of parsing, sending data to the backend, and flashing (allowing users to implement custom logic using `pldmfw_ops`). However, this poses significant challenges for device vendors using PLDM for firmware upgrades. The following scenarios are not supported: 1. Only using the PLDM parsing functions, as the current library does not support this operation. 2. The firmware upgrade process differs from this fixed flow (the firmware upgrade process may vary across different vendors). |-> pldmfw_flash_image |-> pldm_parse_image |-> pldm_parse_header (UUID/revision=E6=A0=A1=E9=AA=8C) |-> pldm_parse_records |-> pldm_parse_components -> pldm_verify_header_crc |-> pldm_find_matching_record (xxx_match_record) |-> pldm_send_package_data (xxx_send_package_data) |-> pldm_send_component_tables (xxx_send_package_data) |-> pldm_flash_components (xxx_flash_component) |-> pldm_finalize_update (xxx_finalize_update) Signed-off-by: Shawn Shao Reviewed-by: Jacob Keller --- include/linux/pldmfw.h | 38 +++++++++++++++++++++++++++++++++++++ lib/pldmfw/pldmfw.c | 43 +++++------------------------------------- 2 files changed, 43 insertions(+), 38 deletions(-) diff --git a/include/linux/pldmfw.h b/include/linux/pldmfw.h index 0fc831338226..5058a07a5ea4 100644 --- a/include/linux/pldmfw.h +++ b/include/linux/pldmfw.h @@ -130,6 +130,42 @@ struct pldmfw { struct device *dev; }; =20 +/* pldmfw_priv structure used to store details about the PLDM image file a= s it is + * being validated and processed. + */ +struct pldmfw_priv { + struct pldmfw *context; + const struct firmware *fw; + + /* current offset of firmware image */ + size_t offset; + + struct list_head records; + struct list_head components; + + /* PLDM Firmware Package Header */ + const struct __pldm_header *header; + u16 total_header_size; + + /* length of the component bitmap */ + u16 component_bitmap_len; + u16 bitmap_size; + + /* Start of the component image information */ + u16 component_count; + const u8 *component_start; + + /* Start pf the firmware device id records */ + const u8 *record_start; + u8 record_count; + + /* The CRC at the end of the package header */ + u32 header_crc; + + struct pldmfw_record *matching_record; +}; + + bool pldmfw_op_pci_match_record(struct pldmfw *context, struct pldmfw_reco= rd *record); =20 /* Operations invoked by the generic PLDM firmware update engine. Used to @@ -160,6 +196,8 @@ struct pldmfw_ops { int (*finalize_update)(struct pldmfw *context); }; =20 +int pldm_parse_image(struct pldmfw_priv *data); +void pldmfw_free_priv(struct pldmfw_priv *data); int pldmfw_flash_image(struct pldmfw *context, const struct firmware *fw); =20 #endif diff --git a/lib/pldmfw/pldmfw.c b/lib/pldmfw/pldmfw.c index 54e1809a38fd..cd1698e9c340 100644 --- a/lib/pldmfw/pldmfw.c +++ b/lib/pldmfw/pldmfw.c @@ -14,41 +14,6 @@ =20 #include "pldmfw_private.h" =20 -/* Internal structure used to store details about the PLDM image file as i= t is - * being validated and processed. - */ -struct pldmfw_priv { - struct pldmfw *context; - const struct firmware *fw; - - /* current offset of firmware image */ - size_t offset; - - struct list_head records; - struct list_head components; - - /* PLDM Firmware Package Header */ - const struct __pldm_header *header; - u16 total_header_size; - - /* length of the component bitmap */ - u16 component_bitmap_len; - u16 bitmap_size; - - /* Start of the component image information */ - u16 component_count; - const u8 *component_start; - - /* Start pf the firmware device id records */ - const u8 *record_start; - u8 record_count; - - /* The CRC at the end of the package header */ - u32 header_crc; - - struct pldmfw_record *matching_record; -}; - /** * pldm_check_fw_space - Verify that the firmware image has space left * @data: pointer to private data @@ -341,6 +306,7 @@ pldm_parse_one_record(struct pldmfw_priv *data, return err; =20 record_len =3D get_unaligned_le16(&__record->record_len); + record->device_update_flags =3D get_unaligned_le32(&__record->device_upda= te_flags); record->package_data_len =3D get_unaligned_le16(&__record->package_data_l= en); record->version_len =3D __record->version_len; record->version_type =3D __record->version_type; @@ -540,7 +506,7 @@ static int pldm_verify_header_crc(struct pldmfw_priv *d= ata) * Loops through and clears all allocated memory associated with each * allocated descriptor, record, and component. */ -static void pldmfw_free_priv(struct pldmfw_priv *data) +void pldmfw_free_priv(struct pldmfw_priv *data) { struct pldmfw_component *component, *c_safe; struct pldmfw_record *record, *r_safe; @@ -566,7 +532,7 @@ static void pldmfw_free_priv(struct pldmfw_priv *data) kfree(record); } } - +EXPORT_SYMBOL(pldmfw_free_priv); /** * pldm_parse_image - parse and extract details from PLDM image * @data: pointer to private data @@ -581,7 +547,7 @@ static void pldmfw_free_priv(struct pldmfw_priv *data) * * Returns: zero on success, or a negative error code on failure. */ -static int pldm_parse_image(struct pldmfw_priv *data) +int pldm_parse_image(struct pldmfw_priv *data) { int err; =20 @@ -602,6 +568,7 @@ static int pldm_parse_image(struct pldmfw_priv *data) =20 return pldm_verify_header_crc(data); } +EXPORT_SYMBOL(pldm_parse_image); =20 /* these are u32 so that we can store PCI_ANY_ID */ struct pldm_pci_record_id { --=20 2.34.1