net/hns3: clear residual flow rules on init
authorChengwen Feng <fengchengwen@huawei.com>
Fri, 10 Apr 2020 11:09:26 +0000 (19:09 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 21 Apr 2020 11:57:07 +0000 (13:57 +0200)
This patch fixes that the flow director rules are not cleared during
initialization, which lead to remaining flow director rules after upper
application (such as testpmd) restarted.

Fixes: fcba820d9b9e ("net/hns3: support flow director")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
drivers/net/hns3/hns3_fdir.c

index a395eb1..26c3117 100644 (file)
@@ -772,6 +772,20 @@ static int hns3_config_action(struct hns3_hw *hw, struct hns3_fdir_rule *rule)
        return hns3_fd_ad_config(hw, ad_data.ad_id, &ad_data);
 }
 
+static int hns3_fd_clear_all_rules(struct hns3_hw *hw, uint32_t rule_num)
+{
+       uint32_t i;
+       int ret;
+
+       for (i = 0; i < rule_num; i++) {
+               ret = hns3_fd_tcam_config(hw, true, i, NULL, false);
+               if (ret)
+                       return ret;
+       }
+
+       return 0;
+}
+
 int hns3_fdir_filter_init(struct hns3_adapter *hns)
 {
        struct hns3_pf *pf = &hns->pf;
@@ -785,6 +799,13 @@ int hns3_fdir_filter_init(struct hns3_adapter *hns)
                .hash_func = rte_hash_crc,
                .hash_func_init_val = 0,
        };
+       int ret;
+
+       ret = hns3_fd_clear_all_rules(&hns->hw, rule_num);
+       if (ret) {
+               PMD_INIT_LOG(ERR, "Clear all fd rules fail! ret = %d", ret);
+               return ret;
+       }
 
        fdir_hash_params.socket_id = rte_socket_id();
        TAILQ_INIT(&fdir_info->fdir_list);