net/bnxt: avoid invalid vnic id in set L2 Rx mask
authorAjit Khaparde <ajit.khaparde@broadcom.com>
Fri, 20 Apr 2018 14:22:01 +0000 (07:22 -0700)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 27 Apr 2018 14:54:56 +0000 (15:54 +0100)
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.
Move bnxt_init_nic to bnxt_dev_init such that the ids are initialized
to an invalid id.
Prevent sending the command to the FW only with 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
drivers/net/bnxt/bnxt_hwrm.c

index a133114..348129d 100644 (file)
@@ -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 @@ skip_init:
                goto error_free_int;
 
        bnxt_enable_int(bp);
+       bnxt_init_nic(bp);
 
        return 0;
 
index 11204bf..bc87735 100644 (file)
@@ -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);