net/hns3: simplify process of some return values
[dpdk.git] / drivers / net / hns3 / hns3_ethdev_vf.c
index e7e2cba..eca585d 100644 (file)
@@ -283,10 +283,9 @@ hns3vf_add_mc_mac_addr(struct hns3_adapter *hns,
                                      mac_addr);
                hns3_err(hw, "Failed to add mc mac addr(%s) for vf: %d",
                         mac_str, ret);
-               return ret;
        }
 
-       return 0;
+       return ret;
 }
 
 static int
@@ -306,10 +305,9 @@ hns3vf_remove_mc_mac_addr(struct hns3_adapter *hns,
                                      mac_addr);
                hns3_err(hw, "Failed to remove mc mac addr(%s) for vf: %d",
                         mac_str, ret);
-               return ret;
        }
 
-       return 0;
+       return ret;
 }
 
 static int
@@ -550,13 +548,11 @@ hns3vf_bind_ring_with_vector(struct hns3_hw *hw, uint8_t vector_id,
        op_str = mmap ? "Map" : "Unmap";
        ret = hns3_send_mbx_msg(hw, code, 0, (uint8_t *)&bind_msg,
                                sizeof(bind_msg), false, NULL, 0);
-       if (ret) {
+       if (ret)
                hns3_err(hw, "%s TQP %d fail, vector_id is %d, ret is %d.",
                         op_str, queue_id, bind_msg.vector_id, ret);
-               return ret;
-       }
 
-       return 0;
+       return ret;
 }
 
 static int
@@ -1022,6 +1018,7 @@ hns3vf_get_configuration(struct hns3_hw *hw)
        int ret;
 
        hw->mac.media_type = HNS3_MEDIA_TYPE_NONE;
+       hw->rss_dis_flag = false;
 
        /* Get queue configuration from PF */
        ret = hns3vf_get_queue_info(hw);
@@ -1149,6 +1146,13 @@ hns3vf_vlan_offload_set(struct rte_eth_dev *dev, int mask)
        struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
        struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
        unsigned int tmp_mask;
+       int ret = 0;
+
+       if (rte_atomic16_read(&hw->reset.resetting)) {
+               hns3_err(hw, "vf set vlan offload failed during resetting, "
+                            "mask = 0x%x", mask);
+               return -EIO;
+       }
 
        tmp_mask = (unsigned int)mask;
        /* Vlan stripping setting */
@@ -1156,13 +1160,13 @@ hns3vf_vlan_offload_set(struct rte_eth_dev *dev, int mask)
                rte_spinlock_lock(&hw->lock);
                /* Enable or disable VLAN stripping */
                if (dev_conf->rxmode.offloads & DEV_RX_OFFLOAD_VLAN_STRIP)
-                       hns3vf_en_hw_strip_rxvtag(hw, true);
+                       ret = hns3vf_en_hw_strip_rxvtag(hw, true);
                else
-                       hns3vf_en_hw_strip_rxvtag(hw, false);
+                       ret = hns3vf_en_hw_strip_rxvtag(hw, false);
                rte_spinlock_unlock(&hw->lock);
        }
 
-       return 0;
+       return ret;
 }
 
 static int
@@ -1667,12 +1671,10 @@ hns3vf_do_start(struct hns3_adapter *hns, bool reset_queue)
                return ret;
 
        ret = hns3_start_queues(hns, reset_queue);
-       if (ret) {
+       if (ret)
                hns3_err(hw, "Failed to start queues: %d", ret);
-               return ret;
-       }
 
-       return 0;
+       return ret;
 }
 
 static int
@@ -1744,6 +1746,12 @@ vf_alloc_intr_vec_error:
        return ret;
 }
 
+static void
+hns3vf_restore_filter(struct rte_eth_dev *dev)
+{
+       hns3_restore_rss_filter(dev);
+}
+
 static int
 hns3vf_dev_start(struct rte_eth_dev *dev)
 {
@@ -1773,6 +1781,8 @@ hns3vf_dev_start(struct rte_eth_dev *dev)
        hns3_mp_req_start_rxtx(dev);
        rte_eal_alarm_set(HNS3VF_SERVICE_INTERVAL, hns3vf_service_handler, dev);
 
+       hns3vf_restore_filter(dev);
+
        return ret;
 }