Increase tx_queues and rx_queues non-null judgment before free tx or
rx resources, and modify some formate for logs.

Fixes: 54faba2295bd ("net/hinic: adds Tx queue xstats members")

Cc: sta...@dpdk.org
Signed-off-by: Xiaoyun wang <cloud.wangxiao...@huawei.com>
---
 drivers/net/hinic/base/hinic_pmd_cmdq.h  |  2 +-
 drivers/net/hinic/base/hinic_pmd_hwif.c  |  2 +-
 drivers/net/hinic/base/hinic_pmd_nicio.c |  1 -
 drivers/net/hinic/hinic_pmd_ethdev.c     | 13 ++++++-------
 drivers/net/hinic/hinic_pmd_rx.c         |  3 ++-
 drivers/net/hinic/hinic_pmd_tx.c         |  5 ++++-
 6 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/net/hinic/base/hinic_pmd_cmdq.h 
b/drivers/net/hinic/base/hinic_pmd_cmdq.h
index 4ce0a4c..0d5e380 100644
--- a/drivers/net/hinic/base/hinic_pmd_cmdq.h
+++ b/drivers/net/hinic/base/hinic_pmd_cmdq.h
@@ -9,7 +9,7 @@
 
 #define HINIC_SCMD_DATA_LEN            16
 
-/* hiovs pmd use 64, kernel l2nic use 4096 */
+/* pmd driver uses 64, kernel l2nic use 4096 */
 #define        HINIC_CMDQ_DEPTH                64
 
 #define        HINIC_CMDQ_BUF_SIZE             2048U
diff --git a/drivers/net/hinic/base/hinic_pmd_hwif.c 
b/drivers/net/hinic/base/hinic_pmd_hwif.c
index 63fba0d..1839df0 100644
--- a/drivers/net/hinic/base/hinic_pmd_hwif.c
+++ b/drivers/net/hinic/base/hinic_pmd_hwif.c
@@ -99,7 +99,7 @@ void hinic_set_pf_status(struct hinic_hwif *hwif, enum 
hinic_pf_status status)
        u32 addr  = HINIC_CSR_FUNC_ATTR5_ADDR;
 
        if (hwif->attr.func_type == TYPE_VF) {
-               PMD_DRV_LOG(ERR, "VF doesn't support set attr5");
+               PMD_DRV_LOG(INFO, "VF doesn't support set attr5");
                return;
        }
 
diff --git a/drivers/net/hinic/base/hinic_pmd_nicio.c 
b/drivers/net/hinic/base/hinic_pmd_nicio.c
index 60c4e14..7f7e11d 100644
--- a/drivers/net/hinic/base/hinic_pmd_nicio.c
+++ b/drivers/net/hinic/base/hinic_pmd_nicio.c
@@ -369,7 +369,6 @@ static int init_rq_ctxts(struct hinic_nic_io *nic_io)
                                             HINIC_MOD_L2NIC,
                                             HINIC_UCODE_CMD_MDY_QUEUE_CONTEXT,
                                             cmd_buf, &out_param, 0);
-
                if ((err) || out_param != 0) {
                        PMD_DRV_LOG(ERR, "Failed to set RQ ctxts");
                        err = -EFAULT;
diff --git a/drivers/net/hinic/hinic_pmd_ethdev.c 
b/drivers/net/hinic/hinic_pmd_ethdev.c
index cfbca64..5fcff81 100644
--- a/drivers/net/hinic/hinic_pmd_ethdev.c
+++ b/drivers/net/hinic/hinic_pmd_ethdev.c
@@ -354,7 +354,7 @@ static int hinic_dev_configure(struct rte_eth_dev *dev)
                return err;
        }
 
-       /*clear fdir filter flag in function table*/
+       /* clear fdir filter flag in function table */
        hinic_free_fdir_filter(nic_dev);
 
        return HINIC_OK;
@@ -440,7 +440,7 @@ static int hinic_rx_queue_setup(struct rte_eth_dev *dev, 
uint16_t queue_idx,
        }
        nic_dev->rxqs[queue_idx] = rxq;
 
-       /* alloc rx sq hw wqepage*/
+       /* alloc rx sq hw wqepage */
        rc = hinic_create_rq(hwdev, queue_idx, rq_depth, socket_id);
        if (rc) {
                PMD_DRV_LOG(ERR, "Create rxq[%d] failed, dev_name: %s, 
rq_depth: %d",
@@ -2070,7 +2070,7 @@ static int hinic_rss_indirtbl_update(struct rte_eth_dev 
*dev,
                        indirtbl[i] = reta_conf[idx].reta[shift];
        }
 
-       for (i = 0 ; i < reta_size; i++) {
+       for (i = 0; i < reta_size; i++) {
                if (indirtbl[i] >= nic_dev->num_rq) {
                        PMD_DRV_LOG(ERR, "Invalid reta entry, index: %d, 
num_rq: %d",
                                    i, nic_dev->num_rq);
@@ -2300,8 +2300,7 @@ static int hinic_dev_xstats_get_names(struct rte_eth_dev 
*dev,
        for (i = 0; i < HINIC_VPORT_XSTATS_NUM; i++) {
                snprintf(xstats_names[count].name,
                         sizeof(xstats_names[count].name),
-                        "%s",
-                        hinic_vport_stats_strings[i].name);
+                        "%s", hinic_vport_stats_strings[i].name);
                count++;
        }
 
@@ -2312,13 +2311,13 @@ static int hinic_dev_xstats_get_names(struct 
rte_eth_dev *dev,
        for (i = 0; i < HINIC_PHYPORT_XSTATS_NUM; i++) {
                snprintf(xstats_names[count].name,
                         sizeof(xstats_names[count].name),
-                        "%s",
-                        hinic_phyport_stats_strings[i].name);
+                        "%s", hinic_phyport_stats_strings[i].name);
                count++;
        }
 
        return count;
 }
+
 /**
  *  DPDK callback to set mac address
  *
diff --git a/drivers/net/hinic/hinic_pmd_rx.c b/drivers/net/hinic/hinic_pmd_rx.c
index 4ca74f0..a49769a 100644
--- a/drivers/net/hinic/hinic_pmd_rx.c
+++ b/drivers/net/hinic/hinic_pmd_rx.c
@@ -413,7 +413,8 @@ void hinic_free_all_rx_resources(struct rte_eth_dev 
*eth_dev)
                                HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(eth_dev);
 
        for (q_id = 0; q_id < nic_dev->num_rq; q_id++) {
-               eth_dev->data->rx_queues[q_id] = NULL;
+               if (eth_dev->data->rx_queues != NULL)
+                       eth_dev->data->rx_queues[q_id] = NULL;
 
                if (nic_dev->rxqs[q_id] == NULL)
                        continue;
diff --git a/drivers/net/hinic/hinic_pmd_tx.c b/drivers/net/hinic/hinic_pmd_tx.c
index 258f2c1..bd39f93 100644
--- a/drivers/net/hinic/hinic_pmd_tx.c
+++ b/drivers/net/hinic/hinic_pmd_tx.c
@@ -313,6 +313,8 @@ static inline struct rte_mbuf *hinic_copy_tx_mbuf(struct 
hinic_nic_dev *nic_dev,
                mbuf = mbuf->next;
        }
 
+       dst_mbuf->pkt_len = dst_mbuf->data_len;
+
        return dst_mbuf;
 }
 
@@ -1217,7 +1219,8 @@ void hinic_free_all_tx_resources(struct rte_eth_dev 
*eth_dev)
                                HINIC_ETH_DEV_TO_PRIVATE_NIC_DEV(eth_dev);
 
        for (q_id = 0; q_id < nic_dev->num_sq; q_id++) {
-               eth_dev->data->tx_queues[q_id] = NULL;
+               if (eth_dev->data->tx_queues != NULL)
+                       eth_dev->data->tx_queues[q_id] = NULL;
 
                if (nic_dev->txqs[q_id] == NULL)
                        continue;
-- 
1.8.3.1

Reply via email to