Re: [PATCH net-next v3 2/2] eth: fbnic: Add devlink dev flash support

From
Simon Horman <horms@kernel.org>
Date
2024-11-12 17:42:48
Also in
linux-doc, lkml
Reply to
Lee Trager, 2024-11-11
On Sun, Nov 10, 2024 at 08:28:42PM -0800, Lee Trager wrote:
fbnic supports updating firmware using a PLDM image signed and distributed
by Meta. PLDM images are written into stored flashed. Flashing does not
interrupt operation.

On host reboot the newly flashed UEFI driver will be used. To run new
control or cmrt firmware the NIC must be power cycled.

Signed-off-by: Lee Trager <redacted>
...
quoted hunk ↗ jump to hunk
diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_devlink.c b/drivers/net/ethernet/meta/fbnic/fbnic_devlink.c
...
quoted hunk ↗ jump to hunk
+/**
+ * fbnic_flash_component - Flash a component of the QSPI
+ * @context: PLDM FW update structure
+ * @component: The component table to send to FW
+ *
+ * Map contents of component and make it available for FW to download
+ * so that it can update the contents of the QSPI Flash.
+ *
+ * Return: zero on success
+ *	    negative error code on failure
+ */
+static int fbnic_flash_component(struct pldmfw *context,
+				 struct pldmfw_component *component)
+{
+	const u8 *data = component->component_data;
+	u32 size = component->component_size;
+	struct fbnic_fw_completion *fw_cmpl;
+	struct device *dev = context->dev;
+	struct pci_dev *pdev = to_pci_dev(dev);
+	u16 id = component->identifier;
+	const char *component_name;
+	int retries = 2;
+	int err;
+
+	struct devlink *devlink;
+	struct fbnic_dev *fbd;
Hi Lee,

Please consider arranging local variables in reverse xmas tree order -
longest line to shortest. Without any blank lines. I think that in this
case that could be:

	const u8 *data = component->component_data;
	u32 size = component->component_size;
	struct fbnic_fw_completion *fw_cmpl;
	struct device *dev = context->dev;
	u16 id = component->identifier;
	const char *component_name;
	struct devlink *devlink;
	struct fbnic_dev *fbd;
	struct pci_dev *pdev;
	int retries = 2;
	int err;

	N.B. pdev is initialised below.
quoted hunk ↗ jump to hunk
+
+	switch (id) {
+	case QSPI_SECTION_CMRT:
+		component_name = "boot1";
+		break;
+	case QSPI_SECTION_CONTROL_FW:
+		component_name = "boot2";
+		break;
+	case QSPI_SECTION_OPTION_ROM:
+		component_name = "option-rom";
+		break;
+	default:
+		dev_err(dev, "Unknown component ID %u\n", id);
+		return -EINVAL;
+	}
+
+	fw_cmpl = kzalloc(sizeof(*fw_cmpl), GFP_KERNEL);
+	if (!fw_cmpl)
+		return -ENOMEM;
+
+	pdev = to_pci_dev(dev);
+	fbd = pci_get_drvdata(pdev);
+	devlink = priv_to_devlink(fbd);
...
Thread (5 messages) 5 messages, 3 authors, last reply 2024-11-12
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help