net/hns3: fix delay for waiting to stop Rx/Tx
[dpdk.git] / drivers / net / hns3 / hns3_ethdev.c
index f49f220..dff2658 100644 (file)
@@ -2273,24 +2273,6 @@ hns3_check_mq_mode(struct rte_eth_dev *dev)
        return 0;
 }
 
-static int
-hns3_check_dcb_cfg(struct rte_eth_dev *dev)
-{
-       struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
-
-       if (!hns3_dev_dcb_supported(hw)) {
-               hns3_err(hw, "this port does not support dcb configurations.");
-               return -EOPNOTSUPP;
-       }
-
-       if (hw->current_fc_status == HNS3_FC_STATUS_MAC_PAUSE) {
-               hns3_err(hw, "MAC pause enabled, cannot config dcb info.");
-               return -EOPNOTSUPP;
-       }
-
-       return 0;
-}
-
 static int
 hns3_bind_ring_with_vector(struct hns3_hw *hw, uint16_t vector_id, bool en,
                           enum hns3_ring_type queue_type, uint16_t queue_id)
@@ -2426,6 +2408,30 @@ hns3_refresh_mtu(struct rte_eth_dev *dev, struct rte_eth_conf *conf)
        return 0;
 }
 
+static int
+hns3_setup_dcb(struct rte_eth_dev *dev)
+{
+       struct hns3_adapter *hns = dev->data->dev_private;
+       struct hns3_hw *hw = &hns->hw;
+       int ret;
+
+       if (!hns3_dev_dcb_supported(hw)) {
+               hns3_err(hw, "this port does not support dcb configurations.");
+               return -EOPNOTSUPP;
+       }
+
+       if (hw->current_fc_status == HNS3_FC_STATUS_MAC_PAUSE) {
+               hns3_err(hw, "MAC pause enabled, cannot config dcb info.");
+               return -EOPNOTSUPP;
+       }
+
+       ret = hns3_dcb_configure(hns);
+       if (ret)
+               hns3_err(hw, "failed to config dcb: %d", ret);
+
+       return ret;
+}
+
 static int
 hns3_check_link_speed(struct hns3_hw *hw, uint32_t link_speeds)
 {
@@ -2506,7 +2512,7 @@ hns3_dev_configure(struct rte_eth_dev *dev)
                goto cfg_err;
 
        if ((uint32_t)mq_mode & ETH_MQ_RX_DCB_FLAG) {
-               ret = hns3_check_dcb_cfg(dev);
+               ret = hns3_setup_dcb(dev);
                if (ret)
                        goto cfg_err;
        }
@@ -5574,14 +5580,14 @@ hns3_do_start(struct hns3_adapter *hns, bool reset_queue)
        struct hns3_hw *hw = &hns->hw;
        int ret;
 
-       ret = hns3_dcb_cfg_update(hns);
-       if (ret)
+       ret = hns3_update_queue_map_configure(hns);
+       if (ret) {
+               hns3_err(hw, "failed to update queue mapping configuration, ret = %d",
+                        ret);
                return ret;
+       }
 
-       /*
-        * The hns3_dcb_cfg_update may configure TM module, so
-        * hns3_tm_conf_update must called later.
-        */
+       /* Note: hns3_tm_conf_update must be called after configuring DCB. */
        ret = hns3_tm_conf_update(hw);
        if (ret) {
                PMD_INIT_LOG(ERR, "failed to update tm conf, ret = %d.", ret);
@@ -5889,7 +5895,7 @@ hns3_dev_stop(struct rte_eth_dev *dev)
        /* Disable datapath on secondary process. */
        hns3_mp_req_stop_rxtx(dev);
        /* Prevent crashes when queues are still in use. */
-       rte_delay_ms(hw->tqps_num);
+       rte_delay_ms(hw->cfg_max_queues);
 
        rte_spinlock_lock(&hw->lock);
        if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED) == 0) {
@@ -6505,7 +6511,7 @@ hns3_stop_service(struct hns3_adapter *hns)
        rte_wmb();
        /* Disable datapath on secondary process. */
        hns3_mp_req_stop_rxtx(eth_dev);
-       rte_delay_ms(hw->tqps_num);
+       rte_delay_ms(hw->cfg_max_queues);
 
        rte_spinlock_lock(&hw->lock);
        if (hns->hw.adapter_state == HNS3_NIC_STARTED ||