From: Pavan Chebbi <pavan.chebbi@broadcom.com>
To: jgg@ziepe.ca, michael.chan@broadcom.com
Cc: linux-kernel@vger.kernel.org, dave.jiang@intel.com,
saeedm@nvidia.com, jic23@kernel.org, gospo@broadcom.com,
selvin.xavier@broadcom.com, leon@kernel.org,
kalesh-anakkur.purayil@broadcom.com,
Pavan Chebbi <pavan.chebbi@broadcom.com>
Subject: [PATCH v4 fwctl 1/3] fwctl: Add driver_data field to fwctl_rpc
Date: Thu, 2 Jul 2026 11:21:23 +0530 [thread overview]
Message-ID: <20260702055125.557963-2-pavan.chebbi@broadcom.com> (raw)
In-Reply-To: <20260702055125.557963-1-pavan.chebbi@broadcom.com>
Add a driver_data field to struct fwctl_rpc in the UAPI and thread the
value through the fw_rpc() ops callback as a new __u64 parameter. The
field is opaque and driver-defined.
Drivers that do not define a driver_data format may return -EOPNOTSUPP.
Update the existing drivers' fw_rpc implementations to enforce this.
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
---
drivers/cxl/core/features.c | 6 +++++-
drivers/fwctl/bnxt/main.c | 6 +++++-
drivers/fwctl/main.c | 3 ++-
drivers/fwctl/mlx5/main.c | 6 +++++-
drivers/fwctl/pds/main.c | 6 +++++-
include/linux/fwctl.h | 8 ++++++--
include/uapi/fwctl/fwctl.h | 3 +++
7 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/drivers/cxl/core/features.c b/drivers/cxl/core/features.c
index 3435db9ea6b1..a0d7f26c5b6d 100644
--- a/drivers/cxl/core/features.c
+++ b/drivers/cxl/core/features.c
@@ -643,7 +643,8 @@ static void *cxlctl_handle_commands(struct cxl_features_state *cxlfs,
}
static void *cxlctl_fw_rpc(struct fwctl_uctx *uctx, enum fwctl_rpc_scope scope,
- void *in, size_t in_len, size_t *out_len)
+ void *in, size_t in_len, size_t *out_len,
+ __u64 driver_data)
{
struct fwctl_device *fwctl_dev = uctx->fwctl;
struct cxl_memdev *cxlmd = fwctl_to_memdev(fwctl_dev);
@@ -651,6 +652,9 @@ static void *cxlctl_fw_rpc(struct fwctl_uctx *uctx, enum fwctl_rpc_scope scope,
const struct fwctl_rpc_cxl *rpc_in = in;
u16 opcode = rpc_in->opcode;
+ if (driver_data)
+ return ERR_PTR(-EOPNOTSUPP);
+
if (!cxlctl_validate_hw_command(cxlfs, rpc_in, scope, opcode))
return ERR_PTR(-EINVAL);
diff --git a/drivers/fwctl/bnxt/main.c b/drivers/fwctl/bnxt/main.c
index 951c8ac2e0a1..5eb3651a1784 100644
--- a/drivers/fwctl/bnxt/main.c
+++ b/drivers/fwctl/bnxt/main.c
@@ -172,7 +172,8 @@ static unsigned int bnxtctl_get_timeout(struct input *req)
static void *bnxtctl_fw_rpc(struct fwctl_uctx *uctx,
enum fwctl_rpc_scope scope,
- void *in, size_t in_len, size_t *out_len)
+ void *in, size_t in_len, size_t *out_len,
+ __u64 driver_data)
{
struct bnxtctl_dev *bnxtctl =
container_of(uctx->fwctl, struct bnxtctl_dev, fwctl);
@@ -180,6 +181,9 @@ static void *bnxtctl_fw_rpc(struct fwctl_uctx *uctx,
struct bnxt_fw_msg rpc_in = {0};
int rc;
+ if (driver_data)
+ return ERR_PTR(-EOPNOTSUPP);
+
if (in_len < sizeof(struct input) || in_len > HWRM_MAX_REQ_LEN)
return ERR_PTR(-EINVAL);
diff --git a/drivers/fwctl/main.c b/drivers/fwctl/main.c
index 098c3824ad75..32c4c66dd7d5 100644
--- a/drivers/fwctl/main.c
+++ b/drivers/fwctl/main.c
@@ -122,7 +122,8 @@ static int fwctl_cmd_rpc(struct fwctl_ucmd *ucmd)
out_len = cmd->out_len;
void *outbuf __free(kvfree) = fwctl->ops->fw_rpc(
- ucmd->uctx, cmd->scope, inbuf, cmd->in_len, &out_len);
+ ucmd->uctx, cmd->scope, inbuf, cmd->in_len, &out_len,
+ cmd->driver_data);
if (IS_ERR(outbuf))
return PTR_ERR(outbuf);
if (outbuf == inbuf) {
diff --git a/drivers/fwctl/mlx5/main.c b/drivers/fwctl/mlx5/main.c
index e86ab703c767..2a5105769126 100644
--- a/drivers/fwctl/mlx5/main.c
+++ b/drivers/fwctl/mlx5/main.c
@@ -304,7 +304,8 @@ static bool mlx5ctl_validate_rpc(const void *in, enum fwctl_rpc_scope scope)
}
static void *mlx5ctl_fw_rpc(struct fwctl_uctx *uctx, enum fwctl_rpc_scope scope,
- void *rpc_in, size_t in_len, size_t *out_len)
+ void *rpc_in, size_t in_len, size_t *out_len,
+ __u64 driver_data)
{
struct mlx5ctl_dev *mcdev =
container_of(uctx->fwctl, struct mlx5ctl_dev, fwctl);
@@ -313,6 +314,9 @@ static void *mlx5ctl_fw_rpc(struct fwctl_uctx *uctx, enum fwctl_rpc_scope scope,
void *rpc_out;
int ret;
+ if (driver_data)
+ return ERR_PTR(-EOPNOTSUPP);
+
if (in_len < MLX5_ST_SZ_BYTES(mbox_in_hdr) ||
*out_len < MLX5_ST_SZ_BYTES(mbox_out_hdr))
return ERR_PTR(-EMSGSIZE);
diff --git a/drivers/fwctl/pds/main.c b/drivers/fwctl/pds/main.c
index 08872ee8422f..bb61e60843cf 100644
--- a/drivers/fwctl/pds/main.c
+++ b/drivers/fwctl/pds/main.c
@@ -348,7 +348,8 @@ static int pdsfc_validate_rpc(struct pdsfc_dev *pdsfc,
}
static void *pdsfc_fw_rpc(struct fwctl_uctx *uctx, enum fwctl_rpc_scope scope,
- void *in, size_t in_len, size_t *out_len)
+ void *in, size_t in_len, size_t *out_len,
+ __u64 driver_data)
{
struct pdsfc_dev *pdsfc = container_of(uctx->fwctl, struct pdsfc_dev, fwctl);
struct device *dev = &uctx->fwctl->dev;
@@ -362,6 +363,9 @@ static void *pdsfc_fw_rpc(struct fwctl_uctx *uctx, enum fwctl_rpc_scope scope,
void *out = NULL;
int err;
+ if (driver_data)
+ return ERR_PTR(-EOPNOTSUPP);
+
err = pdsfc_validate_rpc(pdsfc, rpc, scope);
if (err)
return ERR_PTR(err);
diff --git a/include/linux/fwctl.h b/include/linux/fwctl.h
index 5d61fc8a6871..afb7f72d0cb1 100644
--- a/include/linux/fwctl.h
+++ b/include/linux/fwctl.h
@@ -51,10 +51,14 @@ struct fwctl_ops {
* @fw_rpc: Implement FWCTL_RPC. Deliver rpc_in/in_len to the FW and
* return the response and set out_len. rpc_in can be returned as the
* response pointer. Otherwise the returned pointer is freed with
- * kvfree().
+ * kvfree(). driver_data is the opaque value from fwctl_rpc, passed
+ * verbatim from userspace. The driver is responsible for interpreting
+ * and validating it. Drivers that do not define a driver_data format
+ * must return -EOPNOTSUPP if driver_data is non-zero.
*/
void *(*fw_rpc)(struct fwctl_uctx *uctx, enum fwctl_rpc_scope scope,
- void *rpc_in, size_t in_len, size_t *out_len);
+ void *rpc_in, size_t in_len, size_t *out_len,
+ __u64 driver_data);
};
/**
diff --git a/include/uapi/fwctl/fwctl.h b/include/uapi/fwctl/fwctl.h
index 2d6d4049c205..2e07425402a3 100644
--- a/include/uapi/fwctl/fwctl.h
+++ b/include/uapi/fwctl/fwctl.h
@@ -120,6 +120,8 @@ enum fwctl_rpc_scope {
* @out_len: Length of the out memory
* @in: Request message in device specific format
* @out: Response message in device specific format
+ * @driver_data: Opaque userspace pointer passed verbatim to the driver.
+ * Must be 0 for drivers that do not define a driver_data format.
*
* Deliver a Remote Procedure Call to the device FW and return the response. The
* call's parameters and return are marshaled into linear buffers of memory. Any
@@ -136,6 +138,7 @@ struct fwctl_rpc {
__u32 out_len;
__aligned_u64 in;
__aligned_u64 out;
+ __aligned_u64 driver_data;
};
#define FWCTL_RPC _IO(FWCTL_TYPE, FWCTL_CMD_RPC)
--
2.52.0
next prev parent reply other threads:[~2026-07-02 5:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-02 5:51 [PATCH v4 fwctl 0/3] fwctl/bnxt: DMA buffer support for HWRM commands Pavan Chebbi
2026-07-02 5:51 ` Pavan Chebbi [this message]
2026-07-02 5:51 ` [PATCH v4 fwctl 2/3] bnxt_en: Update bnxt firmware spec Pavan Chebbi
2026-07-02 5:51 ` [PATCH v4 fwctl 3/3] fwctl/bnxt: add DMA buffer support for HWRM commands Pavan Chebbi
2026-07-03 17:51 ` [PATCH v4 fwctl 0/3] fwctl/bnxt: " Jason Gunthorpe
2026-07-04 6:04 ` Pavan Chebbi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260702055125.557963-2-pavan.chebbi@broadcom.com \
--to=pavan.chebbi@broadcom.com \
--cc=dave.jiang@intel.com \
--cc=gospo@broadcom.com \
--cc=jgg@ziepe.ca \
--cc=jic23@kernel.org \
--cc=kalesh-anakkur.purayil@broadcom.com \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.chan@broadcom.com \
--cc=saeedm@nvidia.com \
--cc=selvin.xavier@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.