net/bnxt: fix allocation of COS queue info
authorAjit Khaparde <ajit.khaparde@broadcom.com>
Fri, 15 May 2020 18:07:32 +0000 (11:07 -0700)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 18 May 2020 18:35:57 +0000 (20:35 +0200)
Fixes: 698aa7e95325 ("net/bnxt: add code to determine the Tx COS queue")
Cc: stable@dpdk.org
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
drivers/net/bnxt/bnxt.h
drivers/net/bnxt/bnxt_ethdev.c

index f4b39b3..5707672 100644 (file)
@@ -637,8 +637,8 @@ struct bnxt {
        uint32_t                        hwrm_cmd_timeout;
 
        struct bnxt_link_info   link_info;
-       struct bnxt_cos_queue_info      rx_cos_queue[BNXT_COS_QUEUE_COUNT];
-       struct bnxt_cos_queue_info      tx_cos_queue[BNXT_COS_QUEUE_COUNT];
+       struct bnxt_cos_queue_info      *rx_cos_queue;
+       struct bnxt_cos_queue_info      *tx_cos_queue;
        uint8_t                 tx_cosq_id[BNXT_COS_QUEUE_COUNT];
        uint8_t                 rx_cosq_cnt;
        uint8_t                 max_tc;
index 3bd30df..fa1f84d 100644 (file)
@@ -197,6 +197,12 @@ static void bnxt_free_leds_info(struct bnxt *bp)
        bp->leds = NULL;
 }
 
+static void bnxt_free_cos_queues(struct bnxt *bp)
+{
+       rte_free(bp->rx_cos_queue);
+       rte_free(bp->tx_cos_queue);
+}
+
 static void bnxt_free_mem(struct bnxt *bp, bool reconfig)
 {
        bnxt_free_filter_mem(bp);
@@ -230,6 +236,27 @@ static int bnxt_alloc_leds_info(struct bnxt *bp)
        return 0;
 }
 
+static int bnxt_alloc_cos_queues(struct bnxt *bp)
+{
+       bp->rx_cos_queue =
+               rte_zmalloc("bnxt_rx_cosq",
+                           BNXT_COS_QUEUE_COUNT *
+                           sizeof(struct bnxt_cos_queue_info),
+                           0);
+       if (bp->rx_cos_queue == NULL)
+               return -ENOMEM;
+
+       bp->tx_cos_queue =
+               rte_zmalloc("bnxt_tx_cosq",
+                           BNXT_COS_QUEUE_COUNT *
+                           sizeof(struct bnxt_cos_queue_info),
+                           0);
+       if (bp->tx_cos_queue == NULL)
+               return -ENOMEM;
+
+       return 0;
+}
+
 static int bnxt_alloc_mem(struct bnxt *bp, bool reconfig)
 {
        int rc;
@@ -1234,6 +1261,7 @@ static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev)
        bnxt_uninit_resources(bp, false);
 
        bnxt_free_leds_info(bp);
+       bnxt_free_cos_queues(bp);
 
        eth_dev->dev_ops = NULL;
        eth_dev->rx_pkt_burst = NULL;
@@ -5382,6 +5410,10 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
        if (rc)
                goto error_free;
 
+       rc = bnxt_alloc_cos_queues(bp);
+       if (rc)
+               goto error_free;
+
        rc = bnxt_init_resources(bp, false);
        if (rc)
                goto error_free;