netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: Andy Gospodarek <andrew.gospodarek@broadcom.com>,
	Aron Silverton <aron.silverton@oracle.com>,
	Dan Williams <dan.j.williams@intel.com>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	Dave Jiang <dave.jiang@intel.com>,
	David Ahern <dsahern@kernel.org>,
	Andy Gospodarek <gospo@broadcom.com>,
	Christoph Hellwig <hch@infradead.org>,
	Itay Avraham <itayavr@nvidia.com>, Jiri Pirko <jiri@nvidia.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Leonid Bloch <lbloch@nvidia.com>,
	Leon Romanovsky <leonro@nvidia.com>, <linux-cxl@vger.kernel.org>,
	<linux-rdma@vger.kernel.org>, <netdev@vger.kernel.org>,
	Saeed Mahameed <saeedm@nvidia.com>,
	"Nelson, Shannon" <shannon.nelson@amd.com>
Subject: Re: [PATCH v4 09/10] fwctl/bnxt: Support communicating with bnxt fw
Date: Fri, 7 Feb 2025 14:59:23 +0000	[thread overview]
Message-ID: <20250207145923.0000335e@huawei.com> (raw)
In-Reply-To: <9-v4-0cf4ec3b8143+4995-fwctl_jgg@nvidia.com>

On Thu,  6 Feb 2025 20:13:31 -0400
Jason Gunthorpe <jgg@nvidia.com> wrote:

> From: Andy Gospodarek <gospo@broadcom.com>
> 
> This patch adds basic support for the fwctl infrastructure.  With the
> approriate tool, the most basic RPC to the bnxt_en firmware can be
> called.
> 
> Signed-off-by: Andy Gospodarek <gospo@broadcom.com>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
As commented on below, this one should perhaps have been marked
RFC given there are a bunch of FIXME inline.


> diff --git a/drivers/fwctl/bnxt/bnxt.c b/drivers/fwctl/bnxt/bnxt.c
> new file mode 100644
> index 00000000000000..d2b9a64a1402bf
> --- /dev/null
> +++ b/drivers/fwctl/bnxt/bnxt.c
> @@ -0,0 +1,167 @@

> +
> +/*
> + * bnxt_fw_msg->msg has the whole command
> + * the start of message is of type struct input
> + * struct input {
> + *         __le16  req_type;
> + *         __le16  cmpl_ring;
> + *         __le16  seq_id;
> + *         __le16  target_id;
> + *         __le64  resp_addr;
> + * };
> + * so the hwrm op should be (struct input *)(hwrm_in->msg)->req_type
> + */
> +static bool bnxtctl_validate_rpc(struct fwctl_uctx *uctx,
> +				 struct bnxt_fw_msg *hwrm_in)
> +{
> +	struct input *req = (struct input *)hwrm_in->msg;

hwrm_in->msg is void * so should be no need to cast here.

> +
> +	switch (req->req_type) {
> +	case HWRM_VER_GET:
> +		return true;
> +	default:
> +		return false;
> +	}
> +}
> +
> +static void *bnxtctl_fw_rpc(struct fwctl_uctx *uctx, enum fwctl_rpc_scope scope,
> +			    void *in, size_t in_len, size_t *out_len)
> +{
> +	struct bnxtctl_dev *bnxtctl =
> +		container_of(uctx->fwctl, struct bnxtctl_dev, fwctl);
> +	struct bnxt_aux_priv *bnxt_aux_priv = bnxtctl->aux_priv;
> +	/* FIXME: Check me */

With the various FIXME in here I'm guessing this is an RFC for now?
Maybe better to make that clear in the patch title.

> +	struct bnxt_fw_msg rpc_in = {
> +		// FIXME: does bnxt_send_msg() copy?
> +		.msg = in,
> +		.msg_len = in_len,
> +		.resp = in,
> +		// FIXME: Dynamic memory for out_len
> +		.resp_max_len = in_len,
> +	};
> +	int rc;
> +
> +	if (!bnxtctl_validate_rpc(uctx, &rpc_in))
> +		return ERR_PTR(-EPERM);
> +
> +	rc = bnxt_send_msg(bnxt_aux_priv->edev, &rpc_in);
> +	if (!rc)
> +		return ERR_PTR(-EOPNOTSUPP);
> +	return in;
> +}

> +
> +static int bnxtctl_probe(struct auxiliary_device *adev,
> +			 const struct auxiliary_device_id *id)
> +{
> +	struct bnxt_aux_priv *aux_priv =
> +		container_of(adev, struct bnxt_aux_priv, aux_dev);
> +	struct bnxtctl_dev *bnxtctl __free(bnxtctl) =
> +		fwctl_alloc_device(&aux_priv->edev->pdev->dev, &bnxtctl_ops,

Does this make more sense than setting parent to the
auxiliary device?  (same applies to the mlx5 driver but I didn't notice
it there).  That will result in a deeper nest in sysfs but
at least makes it obvious what the aux dev is doing.

> +				   struct bnxtctl_dev, fwctl);
> +	int rc;
> +
> +	if (!bnxtctl)
> +		return -ENOMEM;
> +
> +	bnxtctl->aux_priv = aux_priv;
> +
> +	rc = fwctl_register(&bnxtctl->fwctl);
> +	if (rc)
> +		return rc;
> +
> +	auxiliary_set_drvdata(adev, no_free_ptr(bnxtctl));
> +	return 0;
> +}

> +static const struct auxiliary_device_id bnxtctl_id_table[] = {
> +	{ .name = "bnxt_en.fwctl", },
> +	{},

Trivial but no need for that trailing comma given this will always
be the last entry.

> +};
> +MODULE_DEVICE_TABLE(auxiliary, bnxtctl_id_table);
> +
> +static struct auxiliary_driver bnxtctl_driver = {
> +	.name = "bnxt_fwctl",
> +	.probe = bnxtctl_probe,
> +	.remove = bnxtctl_remove,
> +	.id_table = bnxtctl_id_table,
> +};
> +
> +module_auxiliary_driver(bnxtctl_driver);

> diff --git a/include/uapi/fwctl/bnxt.h b/include/uapi/fwctl/bnxt.h
> new file mode 100644
> index 00000000000000..ea47fdbbf6ea3e
> --- /dev/null
> +++ b/include/uapi/fwctl/bnxt.h
> @@ -0,0 +1,27 @@
> +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
> +/*
> + * Copyright (c) 2024, Broadcom Corporation
> + *
> + */
> +#ifndef _UAPI_FWCTL_BNXT_H_
> +#define _UAPI_FWCTL_BNXT_H_
> +
> +#include <linux/types.h>
> +
> +enum fwctl_bnxt_commands {
> +	FWCTL_BNXT_QUERY_COMMANDS = 0,
> +	FWCTL_BNXT_SEND_COMMAND,
> +};
> +
> +/**
> + * struct fwctl_info_bnxt - ioctl(FWCTL_INFO) out_device_data
> + * @uctx_caps: The command capabilities driver accepts.

Silly though it may be, if the kernel-doc script runs on this I'm fairly
sure it will moan about lack of docs for reserved.

> + *
> + * Return basic information about the FW interface available.
> + */
> +struct fwctl_info_bnxt {
> +	__u32 uctx_caps;
> +	__u32 reserved;
> +};
> +
> +#endif



  reply	other threads:[~2025-02-07 14:59 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-07  0:13 [PATCH v4 00/10] Introduce fwctl subystem Jason Gunthorpe
2025-02-07  0:13 ` [PATCH v4 01/10] fwctl: Add basic structure for a class subsystem with a cdev Jason Gunthorpe
2025-02-07 23:32   ` Dan Williams
2025-02-07 23:55     ` Jason Gunthorpe
2025-02-08  0:08   ` Dave Jiang
2025-02-07  0:13 ` [PATCH v4 02/10] fwctl: Basic ioctl dispatch for the character device Jason Gunthorpe
2025-02-07 12:59   ` Jonathan Cameron
2025-02-07 13:52     ` Jason Gunthorpe
2025-02-08  0:16   ` Dave Jiang
2025-02-10 15:24     ` Jason Gunthorpe
2025-02-13 12:42   ` Przemek Kitszel
2025-02-13 18:52     ` Jason Gunthorpe
2025-02-07  0:13 ` [PATCH v4 03/10] fwctl: FWCTL_INFO to return basic information about the device Jason Gunthorpe
2025-02-07 13:06   ` Jonathan Cameron
2025-02-07 14:23     ` Jason Gunthorpe
2025-02-08  0:21   ` Dave Jiang
2025-02-07  0:13 ` [PATCH v4 04/10] taint: Add TAINT_FWCTL Jason Gunthorpe
2025-02-07 13:09   ` Jonathan Cameron
2025-02-08  0:24   ` Dave Jiang
2025-02-07  0:13 ` [PATCH v4 05/10] fwctl: FWCTL_RPC to execute a Remote Procedure Call to device firmware Jason Gunthorpe
2025-02-08  0:28   ` Dave Jiang
2025-02-07  0:13 ` [PATCH v4 06/10] fwctl: Add documentation Jason Gunthorpe
2025-02-07 14:42   ` Jonathan Cameron
2025-02-10 15:17     ` Jason Gunthorpe
2025-02-08  0:40   ` Dave Jiang
2025-02-07  0:13 ` [PATCH v4 07/10] fwctl/mlx5: Support for communicating with mlx5 fw Jason Gunthorpe
2025-02-13 13:19   ` Przemek Kitszel
2025-02-13 14:25     ` Leon Romanovsky
2025-02-13 19:18     ` Jason Gunthorpe
2025-02-07  0:13 ` [PATCH v4 08/10] mlx5: Create an auxiliary device for fwctl_mlx5 Jason Gunthorpe
2025-02-07  0:13 ` [PATCH v4 09/10] fwctl/bnxt: Support communicating with bnxt fw Jason Gunthorpe
2025-02-07 14:59   ` Jonathan Cameron [this message]
2025-02-07 15:03     ` Jason Gunthorpe
2025-02-07  0:13 ` [PATCH v4 10/10] bnxt: Create an auxiliary device for fwctl_bnxt Jason Gunthorpe
2025-02-07  0:44   ` Jakub Kicinski
2025-02-07  3:17     ` Andy Gospodarek
2025-02-07 12:46       ` Jason Gunthorpe
2025-02-07 15:36       ` Jakub Kicinski
2025-02-07 20:25         ` Saeed Mahameed
2025-02-07 21:51           ` Jakub Kicinski
2025-02-08  1:10             ` Saeed Mahameed
2025-02-08  1:16             ` Jason Gunthorpe
2025-02-08  3:24               ` Andy Gospodarek
2025-02-11  1:04               ` Jakub Kicinski
2025-02-11  7:55                 ` Leon Romanovsky
2025-02-11 14:27                   ` Andy Gospodarek
2025-02-12 14:20                     ` Leon Romanovsky
2025-02-11 18:36                   ` Nelson, Shannon
2025-02-12 13:22                     ` Leon Romanovsky
2025-02-14  1:03                       ` Saeed Mahameed
2025-02-17 12:49                         ` Jiri Pirko
2025-02-17 19:02                           ` Leon Romanovsky
2025-02-11 16:24                 ` David Ahern
2025-02-18 20:05                   ` Jason Gunthorpe
2025-02-18 21:42                     ` David Ahern
2025-02-18 23:31                       ` Jakub Kicinski
2025-02-24 22:34                         ` Saeed Mahameed
2025-02-07 23:29         ` Andy Gospodarek
2025-02-08  0:08           ` Jakub Kicinski
2025-02-07 21:41 ` [PATCH v4 00/10] Introduce fwctl subystem Dan Williams
2025-02-07 21:58 ` Dave Jiang
2025-02-11  9:33   ` Jonathan Cameron
2025-02-13 17:55     ` Jason Gunthorpe
2025-02-13 17:52   ` Jason Gunthorpe
2025-02-12 22:21 ` Zhu Yanjun
2025-02-13  2:30 ` Nelson, Shannon
2025-02-13 18:02   ` Jason Gunthorpe

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=20250207145923.0000335e@huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=andrew.gospodarek@broadcom.com \
    --cc=aron.silverton@oracle.com \
    --cc=dan.j.williams@intel.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dave.jiang@intel.com \
    --cc=dsahern@kernel.org \
    --cc=gospo@broadcom.com \
    --cc=hch@infradead.org \
    --cc=itayavr@nvidia.com \
    --cc=jgg@nvidia.com \
    --cc=jiri@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=lbloch@nvidia.com \
    --cc=leonro@nvidia.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@nvidia.com \
    --cc=shannon.nelson@amd.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;
as well as URLs for NNTP newsgroup(s).