[dpdk-dev,2/3] net/bnxt: check vnic_id before issuing set_rx_mask

Message ID 20180419235754.75550-3-ajit.khaparde@broadcom.com (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Ajit Khaparde April 19, 2018, 11:57 p.m. UTC
  In some cases bnxt_hwrm_cfa_l2_set_rx_mask is being called before
VNICs are allocated. The FW returns an error in such cases.
Prevent sending the command the FW by checking for a valid vnic id.

Fixes: 244bc98b0da7 ("net/bnxt: set L2 Rx mask")
Cc: stable@dpdk.org
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_ethdev.c | 7 ++-----
 drivers/net/bnxt/bnxt_hwrm.c   | 3 +++
 2 files changed, 5 insertions(+), 5 deletions(-)
  

Comments

Ferruh Yigit April 20, 2018, 12:47 a.m. UTC | #1
On 4/20/2018 12:57 AM, Ajit Khaparde wrote:
> In some cases bnxt_hwrm_cfa_l2_set_rx_mask is being called before
> VNICs are allocated. The FW returns an error in such cases.
> Prevent sending the command the FW by checking for a valid vnic id

Hi Ajit,

Commit title doesn't explain "why" but explains what has been done. It is easier
to see "what" part from code but not easy to see "why" without explanation. Here
commit log explain the reason and scope, only title doesn't reflect it. Title
can be something like "fix firmware error" ...

Please check patches with "check-git-log.sh", it will already complain about
title, script complains about "_" to force explaining "why" instead of using
variable/function names.

Previous set you have sent has same problem, they are already in next-net but if
you have bandwidth can you please check them too? If you can send revised commit
log/title I can update them. "check-git-log.sh" will help to find failing ones.

<...>

> @@ -594,7 +590,7 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
>  	}
>  	bp->dev_stopped = 0;
>  
> -	rc = bnxt_init_nic(bp);
> +	rc = bnxt_init_chip(bp);

Is this bnxt_init_nic()/bnxt_init_chip() changes related to what has been
described in commit log? If so can you explain in commit log why there are related?
  
Ajit Khaparde April 20, 2018, 3:32 a.m. UTC | #2
On Thu, Apr 19, 2018 at 5:47 PM, Ferruh Yigit <ferruh.yigit@intel.com>
wrote:

> On 4/20/2018 12:57 AM, Ajit Khaparde wrote:
> > In some cases bnxt_hwrm_cfa_l2_set_rx_mask is being called before
> > VNICs are allocated. The FW returns an error in such cases.
> > Prevent sending the command the FW by checking for a valid vnic id
>
> Hi Ajit,
>
> Commit title doesn't explain "why" but explains what has been done. It is
> easier
> to see "what" part from code but not easy to see "why" without
> explanation. Here
> commit log explain the reason and scope, only title doesn't reflect it.
> Title
> can be something like "fix firmware error" ...
>
Yes, Sure. I missed it. ​I was concentrating on keeping the title short.​



> Please check patches with "check-git-log.sh", it will already complain
> about
> title, script complains about "_" to force explaining "why" instead of
> using
> variable/function names.
>
> Previous set you have sent has same problem, they are already in next-net
> but if
> you have bandwidth can you please check them too? If you can send revised
> commit
> log/title
> ​​
> I can update them. "check-git-log.sh" will help to find failing ones.
>
​Will do. Thanks
​


>
> <...>
>
> > @@ -594,7 +590,7 @@ static int bnxt_dev_start_op(struct rte_eth_dev
> *eth_dev)
> >       }
> >       bp->dev_stopped = 0;
> >
> > -     rc = bnxt_init_nic(bp);
> > +     rc = bnxt_init_chip(bp);
>
> Is this bnxt_init_nic()/bnxt_init_chip() changes related to what has been
> described in commit log? If so can you explain in commit log why there are
> related?
>
  

Patch

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index a133114a3..348129dad 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -395,10 +395,6 @@  static int bnxt_init_nic(struct bnxt *bp)
 	bnxt_init_vnics(bp);
 	bnxt_init_filters(bp);
 
-	rc = bnxt_init_chip(bp);
-	if (rc)
-		return rc;
-
 	return 0;
 }
 
@@ -594,7 +590,7 @@  static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
 	}
 	bp->dev_stopped = 0;
 
-	rc = bnxt_init_nic(bp);
+	rc = bnxt_init_chip(bp);
 	if (rc)
 		goto error;
 
@@ -3398,6 +3394,7 @@  bnxt_dev_init(struct rte_eth_dev *eth_dev)
 		goto error_free_int;
 
 	bnxt_enable_int(bp);
+	bnxt_init_nic(bp);
 
 	return 0;
 
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 11204bf42..bc8773509 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -221,6 +221,9 @@  int bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt *bp,
 	struct hwrm_cfa_l2_set_rx_mask_output *resp = bp->hwrm_cmd_resp_addr;
 	uint32_t mask = 0;
 
+	if (vnic->fw_vnic_id == INVALID_HW_RING_ID)
+		return rc;
+
 	HWRM_PREP(req, CFA_L2_SET_RX_MASK);
 	req.vnic_id = rte_cpu_to_le_16(vnic->fw_vnic_id);