net/hns3: support Tx push quick doorbell for performance
[dpdk.git] / drivers / net / hns3 / hns3_ethdev_vf.c
index 71f3f95..e582503 100644 (file)
@@ -801,13 +801,11 @@ hns3vf_dev_configure(struct rte_eth_dev *dev)
         * work as usual. But these fake queues are imperceptible, and can not
         * be used by upper applications.
         */
-       if (!hns3_dev_indep_txrx_supported(hw)) {
-               ret = hns3_set_fake_rx_or_tx_queues(dev, nb_rx_q, nb_tx_q);
-               if (ret) {
-                       hns3_err(hw, "fail to set Rx/Tx fake queues, ret = %d.",
-                                ret);
-                       return ret;
-               }
+       ret = hns3_set_fake_rx_or_tx_queues(dev, nb_rx_q, nb_tx_q);
+       if (ret) {
+               hns3_err(hw, "fail to set Rx/Tx fake queues, ret = %d.", ret);
+               hw->cfg_max_queues = 0;
+               return ret;
        }
 
        hw->adapter_state = HNS3_NIC_CONFIGURING;
@@ -866,6 +864,7 @@ hns3vf_dev_configure(struct rte_eth_dev *dev)
        return 0;
 
 cfg_err:
+       hw->cfg_max_queues = 0;
        (void)hns3_set_fake_rx_or_tx_queues(dev, 0, 0);
        hw->adapter_state = HNS3_NIC_INITIALIZED;
 
@@ -1498,18 +1497,6 @@ hns3vf_set_tc_queue_mapping(struct hns3_adapter *hns, uint16_t nb_rx_q,
 {
        struct hns3_hw *hw = &hns->hw;
 
-       if (nb_rx_q < hw->num_tc) {
-               hns3_err(hw, "number of Rx queues(%u) is less than tcs(%u).",
-                        nb_rx_q, hw->num_tc);
-               return -EINVAL;
-       }
-
-       if (nb_tx_q < hw->num_tc) {
-               hns3_err(hw, "number of Tx queues(%u) is less than tcs(%u).",
-                        nb_tx_q, hw->num_tc);
-               return -EINVAL;
-       }
-
        return hns3_queue_to_tc_mapping(hw, nb_rx_q, nb_tx_q);
 }
 
@@ -1621,7 +1608,8 @@ hns3vf_en_hw_strip_rxvtag(struct hns3_hw *hw, bool enable)
        ret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_VLAN, HNS3_MBX_VLAN_RX_OFF_CFG,
                                &msg_data, sizeof(msg_data), false, NULL, 0);
        if (ret)
-               hns3_err(hw, "vf enable strip failed, ret =%d", ret);
+               hns3_err(hw, "vf %s strip failed, ret = %d.",
+                               enable ? "enable" : "disable", ret);
 
        return ret;
 }
@@ -1891,12 +1879,6 @@ hns3vf_init_hardware(struct hns3_adapter *hns)
                goto err_init_hardware;
        }
 
-       ret = hns3vf_set_alive(hw, true);
-       if (ret) {
-               PMD_INIT_LOG(ERR, "Failed to VF send alive to PF: %d", ret);
-               goto err_init_hardware;
-       }
-
        return 0;
 
 err_init_hardware:
@@ -1939,6 +1921,8 @@ hns3vf_init_vf(struct rte_eth_dev *eth_dev)
                goto err_cmd_init;
        }
 
+       hns3_tx_push_init(eth_dev);
+
        /* Get VF resource */
        ret = hns3_query_vf_resource(hw);
        if (ret)
@@ -1995,6 +1979,12 @@ hns3vf_init_vf(struct rte_eth_dev *eth_dev)
 
        hns3_rss_set_default_args(hw);
 
+       ret = hns3vf_set_alive(hw, true);
+       if (ret) {
+               PMD_INIT_LOG(ERR, "Failed to VF send alive to PF: %d", ret);
+               goto err_set_tc_queue;
+       }
+
        return 0;
 
 err_set_tc_queue:
@@ -2119,7 +2109,7 @@ hns3vf_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) {
@@ -2217,16 +2207,18 @@ hns3vf_dev_link_update(struct rte_eth_dev *eth_dev,
        case ETH_SPEED_NUM_50G:
        case ETH_SPEED_NUM_100G:
        case ETH_SPEED_NUM_200G:
-               new_link.link_speed = mac->link_speed;
+               if (mac->link_status)
+                       new_link.link_speed = mac->link_speed;
                break;
        default:
                if (mac->link_status)
                        new_link.link_speed = ETH_SPEED_NUM_UNKNOWN;
-               else
-                       new_link.link_speed = ETH_SPEED_NUM_NONE;
                break;
        }
 
+       if (!mac->link_status)
+               new_link.link_speed = ETH_SPEED_NUM_NONE;
+
        new_link.link_duplex = mac->link_duplex;
        new_link.link_status = mac->link_status ? ETH_LINK_UP : ETH_LINK_DOWN;
        new_link.link_autoneg =
@@ -2568,7 +2560,7 @@ hns3vf_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 (hw->adapter_state == HNS3_NIC_STARTED ||
@@ -2706,6 +2698,13 @@ hns3vf_restore_conf(struct hns3_adapter *hns)
                hns3_info(hw, "hns3vf dev restart successful!");
        } else if (hw->adapter_state == HNS3_NIC_STOPPING)
                hw->adapter_state = HNS3_NIC_CONFIGURED;
+
+       ret = hns3vf_set_alive(hw, true);
+       if (ret) {
+               hns3_err(hw, "failed to VF send alive to PF: %d", ret);
+               goto err_vlan_table;
+       }
+
        return 0;
 
 err_vlan_table:
@@ -2931,8 +2930,8 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev)
                                          "process, ret = %d", ret);
                        goto err_mp_init_secondary;
                }
-
                hw->secondary_cnt++;
+               hns3_tx_push_init(eth_dev);
                return 0;
        }