net/ngbe: fix packet statistics
[dpdk.git] / drivers / net / hns3 / hns3_ethdev.c
index b417d55..2641b6f 100644 (file)
@@ -587,22 +587,6 @@ hns3_set_vlan_rx_offload_cfg(struct hns3_adapter *hns,
        return ret;
 }
 
-static void
-hns3_update_rx_offload_cfg(struct hns3_adapter *hns,
-                          struct hns3_rx_vtag_cfg *vcfg)
-{
-       struct hns3_pf *pf = &hns->pf;
-       memcpy(&pf->vtag_config.rx_vcfg, vcfg, sizeof(pf->vtag_config.rx_vcfg));
-}
-
-static void
-hns3_update_tx_offload_cfg(struct hns3_adapter *hns,
-                          struct hns3_tx_vtag_cfg *vcfg)
-{
-       struct hns3_pf *pf = &hns->pf;
-       memcpy(&pf->vtag_config.tx_vcfg, vcfg, sizeof(pf->vtag_config.tx_vcfg));
-}
-
 static int
 hns3_en_hw_strip_rxvtag(struct hns3_adapter *hns, bool enable)
 {
@@ -632,7 +616,8 @@ hns3_en_hw_strip_rxvtag(struct hns3_adapter *hns, bool enable)
                return ret;
        }
 
-       hns3_update_rx_offload_cfg(hns, &rxvlan_cfg);
+       memcpy(&hns->pf.vtag_config.rx_vcfg, &rxvlan_cfg,
+              sizeof(struct hns3_rx_vtag_cfg));
 
        return ret;
 }
@@ -830,7 +815,9 @@ hns3_vlan_txvlan_cfg(struct hns3_adapter *hns, uint16_t port_base_vlan_state,
                return ret;
        }
 
-       hns3_update_tx_offload_cfg(hns, &txvlan_cfg);
+       memcpy(&hns->pf.vtag_config.tx_vcfg, &txvlan_cfg,
+              sizeof(struct hns3_tx_vtag_cfg));
+
        return ret;
 }
 
@@ -956,7 +943,9 @@ hns3_en_pvid_strip(struct hns3_adapter *hns, int on)
        if (ret)
                return ret;
 
-       hns3_update_rx_offload_cfg(hns, &rx_vlan_cfg);
+       memcpy(&hns->pf.vtag_config.rx_vcfg, &rx_vlan_cfg,
+              sizeof(struct hns3_rx_vtag_cfg));
+
        return ret;
 }
 
@@ -2086,7 +2075,6 @@ static int
 hns3_config_mtu(struct hns3_hw *hw, uint16_t mps)
 {
        struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw);
-       uint16_t original_mps = hns->pf.mps;
        int err;
        int ret;
 
@@ -2096,22 +2084,20 @@ hns3_config_mtu(struct hns3_hw *hw, uint16_t mps)
                return ret;
        }
 
-       hns->pf.mps = mps;
        ret = hns3_buffer_alloc(hw);
        if (ret) {
                hns3_err(hw, "failed to allocate buffer, ret = %d", ret);
                goto rollback;
        }
 
+       hns->pf.mps = mps;
+
        return 0;
 
 rollback:
-       err = hns3_set_mac_mtu(hw, original_mps);
-       if (err) {
+       err = hns3_set_mac_mtu(hw, hns->pf.mps);
+       if (err)
                hns3_err(hw, "fail to rollback MTU, err = %d", err);
-               return ret;
-       }
-       hns->pf.mps = original_mps;
 
        return ret;
 }
@@ -2747,6 +2733,10 @@ hns3_get_capability(struct hns3_hw *hw)
        if (ret)
                return ret;
 
+       ret = hns3_query_mac_stats_reg_num(hw);
+       if (ret)
+               return ret;
+
        if (hw->revision < PCI_REVISION_ID_HIP09_A) {
                hns3_set_default_dev_specifications(hw);
                hw->intr.mapping_mode = HNS3_INTR_MAPPING_VEC_RSV_ONE;
@@ -4388,6 +4378,10 @@ hns3_init_hardware(struct hns3_adapter *hns)
        struct hns3_hw *hw = &hns->hw;
        int ret;
 
+       /*
+        * All queue-related HW operations must be performed after the TCAM
+        * table is configured.
+        */
        ret = hns3_map_tqp(hw);
        if (ret) {
                PMD_INIT_LOG(ERR, "Failed to map tqp: %d", ret);
@@ -5557,15 +5551,15 @@ hns3_reinit_dev(struct hns3_adapter *hns)
                return ret;
        }
 
-       ret = hns3_reset_all_tqps(hns);
+       ret = hns3_init_hardware(hns);
        if (ret) {
-               hns3_err(hw, "Failed to reset all queues: %d", ret);
+               hns3_err(hw, "Failed to init hardware: %d", ret);
                return ret;
        }
 
-       ret = hns3_init_hardware(hns);
+       ret = hns3_reset_all_tqps(hns);
        if (ret) {
-               hns3_err(hw, "Failed to init hardware: %d", ret);
+               hns3_err(hw, "Failed to reset all queues: %d", ret);
                return ret;
        }