mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: Pavan Chebbi <pavan.chebbi@broadcom.com>,
	jgg@ziepe.ca, michael.chan@broadcom.com
Cc: linux-kernel@vger.kernel.org, saeedm@nvidia.com,
	jic23@kernel.org, gospo@broadcom.com, selvin.xavier@broadcom.com,
	leon@kernel.org, kalesh-anakkur.purayil@broadcom.com
Subject: Re: [PATCH v3 fwctl 1/3] fwctl: Add driver_data field to fwctl_rpc
Date: Tue, 26 May 2026 13:46:03 -0700	[thread overview]
Message-ID: <fb71cb37-dd95-4523-ae94-21a79b7f0d37@intel.com> (raw)
In-Reply-To: <20260526144507.822095-2-pavan.chebbi@broadcom.com>



On 5/26/26 7:45 AM, Pavan Chebbi wrote:
> 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.
> 
> Signed-off-by: Pavan Chebbi <pavan.chebbi@broadcom.com>

Reviewed-by: Dave Jiang <dave.jiang@intel.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)
>  


  reply	other threads:[~2026-05-26 20:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-26 14:45 [PATCH v3 fwctl 0/3] fwctl/bnxt: DMA buffer support for HWRM commands Pavan Chebbi
2026-05-26 14:45 ` [PATCH v3 fwctl 1/3] fwctl: Add driver_data field to fwctl_rpc Pavan Chebbi
2026-05-26 20:46   ` Dave Jiang [this message]
2026-05-26 14:45 ` [PATCH v3 fwctl 2/3] bnxt_en: Update bnxt firmware spec Pavan Chebbi
2026-05-26 14:45 ` [PATCH v3 fwctl 3/3] fwctl/bnxt: add DMA buffer support for HWRM commands 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=fb71cb37-dd95-4523-ae94-21a79b7f0d37@intel.com \
    --to=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=pavan.chebbi@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®