]> git.droids-corp.org - dpdk.git/commitdiff
net/bnxt: fix initialization
authorKalesh AP <kalesh-anakkur.purayil@broadcom.com>
Mon, 4 Nov 2019 10:02:39 +0000 (15:32 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 8 Nov 2019 22:15:04 +0000 (23:15 +0100)
During initialization sequence in bnxt_alloc_mem()
if bnxt_alloc_async_cp_ring() fails, driver invokes bnxt_free_mem()
which in turn call bnxt_free_vnic_mem() which causes the error logs
"bnxt_free_vnic_mem(): VNIC is not freed yet!". This is because
vnic memory is allocated but not initialized yet.

Fix this by moving bnxt_init_vnics() from bnxt_init_nic() to
bnxt_alloc_vnic_mem(). Also get rid of bnxt_init_nic() as the
initialization is done in respective functions now.

Fixes: 1bf01f5135f8 ("net/bnxt: prevent device access when device is in reset")
Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Santoshkumar Karanappa Rastapur <santosh.rastapur@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
drivers/net/bnxt/bnxt_ethdev.c
drivers/net/bnxt/bnxt_filter.c
drivers/net/bnxt/bnxt_filter.h
drivers/net/bnxt/bnxt_ring.c
drivers/net/bnxt/bnxt_ring.h
drivers/net/bnxt/bnxt_vnic.c
drivers/net/bnxt/bnxt_vnic.h

index a1e9c7066e67c25a4a8025e730a746156d64252a..74388f2c853bd0ac507385af4e35cd406cfcbc80 100644 (file)
@@ -479,22 +479,6 @@ static int bnxt_shutdown_nic(struct bnxt *bp)
        return 0;
 }
 
-static int bnxt_init_nic(struct bnxt *bp)
-{
-       int rc;
-
-       if (BNXT_HAS_RING_GRPS(bp)) {
-               rc = bnxt_init_ring_grps(bp);
-               if (rc)
-                       return rc;
-       }
-
-       bnxt_init_vnics(bp);
-       bnxt_init_filters(bp);
-
-       return 0;
-}
-
 /*
  * Device configuration and status function
  */
@@ -4662,8 +4646,6 @@ static int bnxt_init_resources(struct bnxt *bp, bool reconfig_dev)
        if (rc)
                return rc;
 
-       bnxt_init_nic(bp);
-
        rc = bnxt_request_int(bp);
        if (rc)
                return rc;
index 7e29468b744d74883054055adf83aae077761235..da1a6c24a9090b9a0cff13c84f9103cb1a625ac4 100644 (file)
@@ -61,7 +61,7 @@ struct bnxt_filter_info *bnxt_alloc_vf_filter(struct bnxt *bp, uint16_t vf)
        return filter;
 }
 
-void bnxt_init_filters(struct bnxt *bp)
+static void bnxt_init_filters(struct bnxt *bp)
 {
        struct bnxt_filter_info *filter;
        int i, max_filters;
@@ -171,6 +171,7 @@ int bnxt_alloc_filter_mem(struct bnxt *bp)
                return -ENOMEM;
        }
        bp->filter_info = filter_mem;
+       bnxt_init_filters(bp);
        return 0;
 }
 
index 7415b3612e3150ad51f6da68a11525fae49a639c..9db3e748776e56a81b84a5ccc9318608fbbb8c54 100644 (file)
@@ -81,7 +81,6 @@ struct bnxt_filter_info {
 
 struct bnxt_filter_info *bnxt_alloc_filter(struct bnxt *bp);
 struct bnxt_filter_info *bnxt_alloc_vf_filter(struct bnxt *bp, uint16_t vf);
-void bnxt_init_filters(struct bnxt *bp);
 void bnxt_free_all_filters(struct bnxt *bp);
 void bnxt_free_filter_mem(struct bnxt *bp);
 int bnxt_alloc_filter_mem(struct bnxt *bp);
index 0a182d3a8411547357cdf1e52b3c987ad28fb78a..ea46fa9bc0667832278e126a1f57a2ed9ee8ef60 100644 (file)
@@ -38,15 +38,13 @@ void bnxt_free_ring(struct bnxt_ring *ring)
  * Ring groups
  */
 
-int bnxt_init_ring_grps(struct bnxt *bp)
+static void bnxt_init_ring_grps(struct bnxt *bp)
 {
        unsigned int i;
 
        for (i = 0; i < bp->max_ring_grps; i++)
                memset(&bp->grp_info[i], (uint8_t)HWRM_NA_SIGNATURE,
                       sizeof(struct bnxt_ring_grp_info));
-
-       return 0;
 }
 
 int bnxt_alloc_ring_grps(struct bnxt *bp)
@@ -76,6 +74,7 @@ int bnxt_alloc_ring_grps(struct bnxt *bp)
                                    "Failed to alloc grp info tbl.\n");
                        return -ENOMEM;
                }
+               bnxt_init_ring_grps(bp);
        }
 
        return 0;
index 833118391b76e4d32dec9e3b81ce87a7034b17d3..48a39d78845a30a836d46c36a68553ffeafc67f9 100644 (file)
@@ -65,7 +65,6 @@ struct bnxt_tx_ring_info;
 struct bnxt_rx_ring_info;
 struct bnxt_cp_ring_info;
 void bnxt_free_ring(struct bnxt_ring *ring);
-int bnxt_init_ring_grps(struct bnxt *bp);
 int bnxt_alloc_ring_grps(struct bnxt *bp);
 int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx,
                            struct bnxt_tx_queue *txq,
index 2f0ed10265c290214a07c7eb087d8900c599d5ba..412a53dc0717b9d921619858a39fb480130524af 100644 (file)
@@ -35,7 +35,7 @@ void prandom_bytes(void *dest_ptr, size_t len)
        }
 }
 
-void bnxt_init_vnics(struct bnxt *bp)
+static void bnxt_init_vnics(struct bnxt *bp)
 {
        struct bnxt_vnic_info *vnic;
        uint16_t max_vnics;
@@ -52,7 +52,6 @@ void bnxt_init_vnics(struct bnxt *bp)
                vnic->hash_mode =
                        HWRM_VNIC_RSS_CFG_INPUT_HASH_MODE_FLAGS_DEFAULT;
 
-               prandom_bytes(vnic->rss_hash_key, HW_HASH_KEY_SIZE);
                STAILQ_INIT(&vnic->filter);
                STAILQ_INIT(&vnic->flow_list);
                STAILQ_INSERT_TAIL(&bp->free_vnic_list, vnic, next);
@@ -179,6 +178,7 @@ int bnxt_alloc_vnic_attributes(struct bnxt *bp)
                                HW_HASH_KEY_SIZE);
                vnic->mc_list_dma_addr = vnic->rss_hash_key_dma_addr +
                                HW_HASH_KEY_SIZE;
+               prandom_bytes(vnic->rss_hash_key, HW_HASH_KEY_SIZE);
        }
 
        return 0;
@@ -220,6 +220,7 @@ int bnxt_alloc_vnic_mem(struct bnxt *bp)
                return -ENOMEM;
        }
        bp->vnic_info = vnic_mem;
+       bnxt_init_vnics(bp);
        return 0;
 }
 
index 4f760e0b08c974dab6d976c188823c29b6188397..a372b899bce8392b9e5c1a2efe6306225aefef23 100644 (file)
@@ -58,7 +58,6 @@ struct bnxt_vnic_info {
 };
 
 struct bnxt;
-void bnxt_init_vnics(struct bnxt *bp);
 int bnxt_free_vnic(struct bnxt *bp, struct bnxt_vnic_info *vnic,
                          int pool);
 struct bnxt_vnic_info *bnxt_alloc_vnic(struct bnxt *bp);