Re: [PATCH v9 3/4] fpga: dfl: add basic support for DFHv1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


On Mon, 9 Jan 2023, Xu Yilun wrote:

On 2023-01-04 at 15:22:52 -0800, matthew.gerlach@xxxxxxxxxxxxxxx wrote:
From: Matthew Gerlach <matthew.gerlach@xxxxxxxxxxxxxxx>

Version 1 of the Device Feature Header (DFH) definition adds
functionality to the Device Feature List (DFL) bus.

A DFHv1 header may have one or more parameter blocks that
further describes the HW to SW. Add support to the DFL bus
to parse the MSI-X parameter.

The location of a feature's register set is explicitly
described in DFHv1 and can be relative to the base of the DFHv1
or an absolute address. Parse the location and pass the information
to DFL driver.

Signed-off-by: Matthew Gerlach <matthew.gerlach@xxxxxxxxxxxxxxx>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx>


+static u64 *find_param(u64 *params, resource_size_t max, int param_id)
+	u64 *end = params + max / sizeof(u64);
+	u64 v, next;
+	while (params < end) {
+		v = *params;
+		if (param_id == FIELD_GET(DFHv1_PARAM_HDR_ID, v))
+			return params;
+			break;
+		params += next;
+	}
+	return NULL;
+ * dfh_find_param() - find parameter block for the given parameter id
+ * @dfl_dev: dfl device
+ * @param_id: id of dfl parameter
+ * @pcount: destination to store size of parameter data in u64 bit words

As I mentioned before, could the size of the parameter data just be number
of bytes? This is the most common way for a data block.

returning a void* and a size_t in bytes would be more consistent. I will make your suggested change.

Matthew Gerlach


+ *
+ * Return: pointer to start of parameter data, PTR_ERR otherwise.
+ */
+void *dfh_find_param(struct dfl_device *dfl_dev, int param_id, size_t *pcount)
+	u64 *phdr = find_param(dfl_dev->params, dfl_dev->param_size, param_id);
+	if (!phdr)
+		return ERR_PTR(-ENOENT);
+	if (pcount)
+		*pcount = FIELD_GET(DFHv1_PARAM_HDR_NEXT_OFFSET, *phdr) - 1;
+	return phdr + 1;

[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux