net/hinic: optimize RSS RETA table update
authorXiaoyun Wang <cloud.wangxiaoyun@huawei.com>
Thu, 14 May 2020 09:29:19 +0000 (17:29 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 18 May 2020 18:35:57 +0000 (20:35 +0200)
Before updating RSS indirection table, firstly determine whether
rq num in RETA table is legal, if it is invalid(such as exceeding
the maximum rxq num), driver will not update hw indirection
table and return fail.

Signed-off-by: Xiaoyun Wang <cloud.wangxiaoyun@huawei.com>
drivers/net/hinic/hinic_pmd_ethdev.c

index 8634fe8..2f0f33a 100644 (file)
@@ -2075,16 +2075,16 @@ static int hinic_rss_indirtbl_update(struct rte_eth_dev *dev,
        for (i = 0; i < reta_size; i++) {
                idx = i / RTE_RETA_GROUP_SIZE;
                shift = i % RTE_RETA_GROUP_SIZE;
-               if (reta_conf[idx].mask & (1ULL << shift))
-                       indirtbl[i] = reta_conf[idx].reta[shift];
-       }
 
-       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);
-                       goto disable_rss;
+               if (reta_conf[idx].reta[shift] >= nic_dev->num_rq) {
+                       PMD_DRV_LOG(ERR, "Invalid reta entry, indirtbl[%d]: %d "
+                               "exceeds the maximum rxq num: %d", i,
+                               reta_conf[idx].reta[shift], nic_dev->num_rq);
+                       return -EINVAL;
                }
+
+               if (reta_conf[idx].mask & (1ULL << shift))
+                       indirtbl[i] = reta_conf[idx].reta[shift];
        }
 
        err = hinic_rss_set_indir_tbl(nic_dev->hwdev, tmpl_idx, indirtbl);