diff mbox series

[v4,for-next,3/6] RDMA/bnxt_re: Query function capabilities from firmware

Message ID 1685617837-15725-4-git-send-email-selvin.xavier@broadcom.com (mailing list archive)
State Superseded
Headers show
Series RDMA/bnxt_re: driver update for supporting low latency push | expand

Commit Message

Selvin Xavier June 1, 2023, 11:10 a.m. UTC
Query Function capabilities to enable advanced features.

Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
---
 drivers/infiniband/hw/bnxt_re/main.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

Comments

Leon Romanovsky June 11, 2023, 1:04 p.m. UTC | #1
On Thu, Jun 01, 2023 at 04:10:34AM -0700, Selvin Xavier wrote:
> Query Function capabilities to enable advanced features.
> 
> Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
> ---
>  drivers/infiniband/hw/bnxt_re/main.c | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/drivers/infiniband/hw/bnxt_re/main.c b/drivers/infiniband/hw/bnxt_re/main.c
> index 9cc652e..da99f69 100644
> --- a/drivers/infiniband/hw/bnxt_re/main.c
> +++ b/drivers/infiniband/hw/bnxt_re/main.c
> @@ -83,6 +83,7 @@ static int bnxt_re_netdev_event(struct notifier_block *notifier,
>  				unsigned long event, void *ptr);
>  static struct bnxt_re_dev *bnxt_re_from_netdev(struct net_device *netdev);
>  static void bnxt_re_dev_uninit(struct bnxt_re_dev *rdev);
> +static int bnxt_re_hwrm_qcaps(struct bnxt_re_dev *rdev);
>  
>  static void bnxt_re_set_drv_mode(struct bnxt_re_dev *rdev, u8 mode)
>  {
> @@ -91,6 +92,9 @@ static void bnxt_re_set_drv_mode(struct bnxt_re_dev *rdev, u8 mode)
>  	cctx = rdev->chip_ctx;
>  	cctx->modes.wqe_mode = bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx) ?
>  			       mode : BNXT_QPLIB_WQE_MODE_STATIC;
> +	if (bnxt_re_hwrm_qcaps(rdev))
> +		dev_err(rdev_to_dev(rdev),
> +			"Failed to query hwrm qcaps\n");
>  }
>  
>  static void bnxt_re_destroy_chip_ctx(struct bnxt_re_dev *rdev)
> @@ -340,6 +344,25 @@ static void bnxt_re_fill_fw_msg(struct bnxt_fw_msg *fw_msg, void *msg,
>  	fw_msg->timeout = timeout;
>  }
>  
> +/* Query function capabilities using common hwrm */
> +int bnxt_re_hwrm_qcaps(struct bnxt_re_dev *rdev)
> +{
> +	struct bnxt_en_dev *en_dev = rdev->en_dev;
> +	struct hwrm_func_qcaps_output resp = {0};
> +	struct hwrm_func_qcaps_input req = {0};

There is no need in 0 here, just use {}

> +	struct bnxt_qplib_chip_ctx *cctx;
> +	struct bnxt_fw_msg fw_msg;

Initialize it to zero from the beginning and remove memset()

> +
> +	cctx = rdev->chip_ctx;
> +	memset(&fw_msg, 0, sizeof(fw_msg));
> +	bnxt_re_init_hwrm_hdr(rdev, (void *)&req,
> +			      HWRM_FUNC_QCAPS, -1, -1);

All callers to bnxt_re_init_hwrm_hdr() provide "-1, -1" and rdev is not
used at all.

> +	req.fid = cpu_to_le16(0xffff);
> +	bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
> +			    sizeof(resp), DFLT_HWRM_CMD_TIMEOUT);
> +	return bnxt_send_msg(en_dev, &fw_msg);
> +}
> +
>  static int bnxt_re_net_ring_free(struct bnxt_re_dev *rdev,
>  				 u16 fw_ring_id, int type)
>  {
> -- 
> 2.5.5
>
Selvin Xavier June 12, 2023, 5:50 a.m. UTC | #2
On Sun, Jun 11, 2023 at 6:34 PM Leon Romanovsky <leon@kernel.org> wrote:
>
> On Thu, Jun 01, 2023 at 04:10:34AM -0700, Selvin Xavier wrote:
> > Query Function capabilities to enable advanced features.
> >
> > Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
> > ---
> >  drivers/infiniband/hw/bnxt_re/main.c | 23 +++++++++++++++++++++++
> >  1 file changed, 23 insertions(+)
> >
> > diff --git a/drivers/infiniband/hw/bnxt_re/main.c b/drivers/infiniband/hw/bnxt_re/main.c
> > index 9cc652e..da99f69 100644
> > --- a/drivers/infiniband/hw/bnxt_re/main.c
> > +++ b/drivers/infiniband/hw/bnxt_re/main.c
> > @@ -83,6 +83,7 @@ static int bnxt_re_netdev_event(struct notifier_block *notifier,
> >                               unsigned long event, void *ptr);
> >  static struct bnxt_re_dev *bnxt_re_from_netdev(struct net_device *netdev);
> >  static void bnxt_re_dev_uninit(struct bnxt_re_dev *rdev);
> > +static int bnxt_re_hwrm_qcaps(struct bnxt_re_dev *rdev);
> >
> >  static void bnxt_re_set_drv_mode(struct bnxt_re_dev *rdev, u8 mode)
> >  {
> > @@ -91,6 +92,9 @@ static void bnxt_re_set_drv_mode(struct bnxt_re_dev *rdev, u8 mode)
> >       cctx = rdev->chip_ctx;
> >       cctx->modes.wqe_mode = bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx) ?
> >                              mode : BNXT_QPLIB_WQE_MODE_STATIC;
> > +     if (bnxt_re_hwrm_qcaps(rdev))
> > +             dev_err(rdev_to_dev(rdev),
> > +                     "Failed to query hwrm qcaps\n");
> >  }
> >
> >  static void bnxt_re_destroy_chip_ctx(struct bnxt_re_dev *rdev)
> > @@ -340,6 +344,25 @@ static void bnxt_re_fill_fw_msg(struct bnxt_fw_msg *fw_msg, void *msg,
> >       fw_msg->timeout = timeout;
> >  }
> >
> > +/* Query function capabilities using common hwrm */
> > +int bnxt_re_hwrm_qcaps(struct bnxt_re_dev *rdev)
> > +{
> > +     struct bnxt_en_dev *en_dev = rdev->en_dev;
> > +     struct hwrm_func_qcaps_output resp = {0};
> > +     struct hwrm_func_qcaps_input req = {0};
>
> There is no need in 0 here, just use {}
>
> > +     struct bnxt_qplib_chip_ctx *cctx;
> > +     struct bnxt_fw_msg fw_msg;
>
> Initialize it to zero from the beginning and remove memset()
There are other functions that also uses bnxt_re_init_hwrm_hdr which uses
the extra memset. I will add a separate patch to this series which removes
the memset code and the extra parameters to  bnxt_re_init_hwrm_hdr
and prepare this patch on top of that.

Will post a v5 soon.
>
> > +
> > +     cctx = rdev->chip_ctx;
> > +     memset(&fw_msg, 0, sizeof(fw_msg));
> > +     bnxt_re_init_hwrm_hdr(rdev, (void *)&req,
> > +                           HWRM_FUNC_QCAPS, -1, -1);
>
> All callers to bnxt_re_init_hwrm_hdr() provide "-1, -1" and rdev is not
> used at all.
-1
>
> > +     req.fid = cpu_to_le16(0xffff);
> > +     bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
> > +                         sizeof(resp), DFLT_HWRM_CMD_TIMEOUT);
> > +     return bnxt_send_msg(en_dev, &fw_msg);
> > +}
> > +
> >  static int bnxt_re_net_ring_free(struct bnxt_re_dev *rdev,
> >                                u16 fw_ring_id, int type)
> >  {
> > --
> > 2.5.5
> >
>
>
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/bnxt_re/main.c b/drivers/infiniband/hw/bnxt_re/main.c
index 9cc652e..da99f69 100644
--- a/drivers/infiniband/hw/bnxt_re/main.c
+++ b/drivers/infiniband/hw/bnxt_re/main.c
@@ -83,6 +83,7 @@  static int bnxt_re_netdev_event(struct notifier_block *notifier,
 				unsigned long event, void *ptr);
 static struct bnxt_re_dev *bnxt_re_from_netdev(struct net_device *netdev);
 static void bnxt_re_dev_uninit(struct bnxt_re_dev *rdev);
+static int bnxt_re_hwrm_qcaps(struct bnxt_re_dev *rdev);
 
 static void bnxt_re_set_drv_mode(struct bnxt_re_dev *rdev, u8 mode)
 {
@@ -91,6 +92,9 @@  static void bnxt_re_set_drv_mode(struct bnxt_re_dev *rdev, u8 mode)
 	cctx = rdev->chip_ctx;
 	cctx->modes.wqe_mode = bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx) ?
 			       mode : BNXT_QPLIB_WQE_MODE_STATIC;
+	if (bnxt_re_hwrm_qcaps(rdev))
+		dev_err(rdev_to_dev(rdev),
+			"Failed to query hwrm qcaps\n");
 }
 
 static void bnxt_re_destroy_chip_ctx(struct bnxt_re_dev *rdev)
@@ -340,6 +344,25 @@  static void bnxt_re_fill_fw_msg(struct bnxt_fw_msg *fw_msg, void *msg,
 	fw_msg->timeout = timeout;
 }
 
+/* Query function capabilities using common hwrm */
+int bnxt_re_hwrm_qcaps(struct bnxt_re_dev *rdev)
+{
+	struct bnxt_en_dev *en_dev = rdev->en_dev;
+	struct hwrm_func_qcaps_output resp = {0};
+	struct hwrm_func_qcaps_input req = {0};
+	struct bnxt_qplib_chip_ctx *cctx;
+	struct bnxt_fw_msg fw_msg;
+
+	cctx = rdev->chip_ctx;
+	memset(&fw_msg, 0, sizeof(fw_msg));
+	bnxt_re_init_hwrm_hdr(rdev, (void *)&req,
+			      HWRM_FUNC_QCAPS, -1, -1);
+	req.fid = cpu_to_le16(0xffff);
+	bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
+			    sizeof(resp), DFLT_HWRM_CMD_TIMEOUT);
+	return bnxt_send_msg(en_dev, &fw_msg);
+}
+
 static int bnxt_re_net_ring_free(struct bnxt_re_dev *rdev,
 				 u16 fw_ring_id, int type)
 {