[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220725205629.3993766-4-jacob.e.keller@intel.com>
Date: Mon, 25 Jul 2022 13:56:28 -0700
From: Jacob Keller <jacob.e.keller@...el.com>
To: netdev@...r.kernel.org
Cc: Jacob Keller <jacob.e.keller@...el.com>,
Jonathan Corbet <corbet@....net>, Jiri Pirko <jiri@...dia.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Tony Nguyen <anthony.l.nguyen@...el.com>,
David Ahern <dsahern@...nel.org>,
Stephen Hemminger <stephen@...workplumber.org>,
linux-doc@...r.kernel.org
Subject: [net-next v3 3/4] pldmfw: offer option to only validate in image but not update
Add an "only_validate" bit in the PLDM firmware context configuration to
allow requesting validation of a PLDM image. Setting this bit causes the
PLDMFW library to stop after finishing validation of the image. No actual
update will be performed.
Signed-off-by: Jacob Keller <jacob.e.keller@...el.com>
---
Changes since v2
* Split PLDMFW changes to their own patch
* Fix code and comments still referring to dry_run
* Name the parameter "only_validate" instead of validate for clarity
Documentation/driver-api/pldmfw/index.rst | 11 +++++++++++
include/linux/pldmfw.h | 5 +++++
lib/pldmfw/pldmfw.c | 12 ++++++++++++
3 files changed, 28 insertions(+)
diff --git a/Documentation/driver-api/pldmfw/index.rst b/Documentation/driver-api/pldmfw/index.rst
index ad2c33ece30f..1eca98f642eb 100644
--- a/Documentation/driver-api/pldmfw/index.rst
+++ b/Documentation/driver-api/pldmfw/index.rst
@@ -51,6 +51,17 @@ unaligned access of multi-byte fields, and to properly convert from Little
Endian to CPU host format. Additionally the records, descriptors, and
components are stored in linked lists.
+Validating a PLDM firmware file
+===============================
+
+To simply validate a PLDM firmware file, and verify whether it applies to
+the device, set the ``only_validate`` flag in the ``pldmfw`` context
+structure. If this flag is set, the library will parse the file, validating
+its UUID and checking if any record matches the device. Note that in this
+mode, the library will *not* issue any ops besides ``match_record``. It will
+not attempt to send the component table or package data to the device
+firmware.
+
Performing a flash update
=========================
diff --git a/include/linux/pldmfw.h b/include/linux/pldmfw.h
index 0fc831338226..820c0e812989 100644
--- a/include/linux/pldmfw.h
+++ b/include/linux/pldmfw.h
@@ -124,10 +124,15 @@ struct pldmfw_ops;
* should embed this in a private structure and use container_of to obtain
* a pointer to their own data, used to implement the device specific
* operations.
+ *
+ * @ops: function pointers used as callbacks from the PLDMFW library
+ * @dev: pointer to the device being updated
+ * @only_validate: if true, only validate the file, do not perform an update.
*/
struct pldmfw {
const struct pldmfw_ops *ops;
struct device *dev;
+ u8 only_validate : 1;
};
bool pldmfw_op_pci_match_record(struct pldmfw *context, struct pldmfw_record *record);
diff --git a/lib/pldmfw/pldmfw.c b/lib/pldmfw/pldmfw.c
index 6e77eb6d8e72..cb4a105487bd 100644
--- a/lib/pldmfw/pldmfw.c
+++ b/lib/pldmfw/pldmfw.c
@@ -827,6 +827,10 @@ static int pldm_finalize_update(struct pldmfw_priv *data)
* to the device firmware. Extract and write the flash data for each of the
* components indicated in the firmware file.
*
+ * If the context->only_validate bit is set, this is a request to stop after
+ * validating the image, and do not actually attempt to update the device. If
+ * this is set, stop and exit after we find a valid matching record.
+ *
* Returns: zero on success, or a negative error code on failure.
*/
int pldmfw_flash_image(struct pldmfw *context, const struct firmware *fw)
@@ -844,14 +848,22 @@ int pldmfw_flash_image(struct pldmfw *context, const struct firmware *fw)
data->fw = fw;
data->context = context;
+ /* Parse the image and make sure it is a valid PLDM firmware binary */
err = pldm_parse_image(data);
if (err)
goto out_release_data;
+ /* Search for a record matching the device */
err = pldm_find_matching_record(data);
if (err)
goto out_release_data;
+ /* If this is only to validate the file, do not perform an update */
+ if (context->only_validate)
+ goto out_release_data;
+
+ /* Perform the device update */
+
err = pldm_send_package_data(data);
if (err)
goto out_release_data;
--
2.35.1.456.ga9c7032d4631
Powered by blists - more mailing lists