OSDN Git Service

net: hns3: Change return type of hclge_tm_schd_info_update()
authorHuazhong Tan <tanhuazhong@huawei.com>
Wed, 26 Sep 2018 18:28:38 +0000 (19:28 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 28 Sep 2018 17:37:42 +0000 (10:37 -0700)
hclge_tm_schd_info_update should return an error when num_tc is greater
than alloc_tqps.

This patch changes the return type of hnae3_register_ae_algo from void
to int.

Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Peng Li <lipeng321@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h

index 92f1938..e72f724 100644 (file)
@@ -184,7 +184,9 @@ static int hclge_ieee_setets(struct hnae3_handle *h, struct ieee_ets *ets)
        if (ret)
                return ret;
 
-       hclge_tm_schd_info_update(hdev, num_tc);
+       ret = hclge_tm_schd_info_update(hdev, num_tc);
+       if (ret)
+               return ret;
 
        ret = hclge_ieee_ets_to_tm_info(hdev, ets);
        if (ret)
@@ -310,7 +312,9 @@ static int hclge_setup_tc(struct hnae3_handle *h, u8 tc, u8 *prio_tc)
                return -EINVAL;
        }
 
-       hclge_tm_schd_info_update(hdev, tc);
+       ret = hclge_tm_schd_info_update(hdev, tc);
+       if (ret)
+               return ret;
 
        ret = hclge_tm_prio_tc_info_update(hdev, prio_tc);
        if (ret)
index ab7280d..aa5cb98 100644 (file)
@@ -1280,10 +1280,15 @@ int hclge_tm_prio_tc_info_update(struct hclge_dev *hdev, u8 *prio_tc)
        return 0;
 }
 
-void hclge_tm_schd_info_update(struct hclge_dev *hdev, u8 num_tc)
+int hclge_tm_schd_info_update(struct hclge_dev *hdev, u8 num_tc)
 {
        u8 i, bit_map = 0;
 
+       for (i = 0; i < hdev->num_alloc_vport; i++) {
+               if (num_tc > hdev->vport[i].alloc_tqps)
+                       return -EINVAL;
+       }
+
        hdev->tm_info.num_tc = num_tc;
 
        for (i = 0; i < hdev->tm_info.num_tc; i++)
@@ -1297,6 +1302,8 @@ void hclge_tm_schd_info_update(struct hclge_dev *hdev, u8 num_tc)
        hdev->hw_tc_map = bit_map;
 
        hclge_tm_schd_info_init(hdev);
+
+       return 0;
 }
 
 int hclge_tm_init_hw(struct hclge_dev *hdev)
index e1568b8..25eef13 100644 (file)
@@ -132,7 +132,7 @@ int hclge_tm_schd_init(struct hclge_dev *hdev);
 int hclge_pause_setup_hw(struct hclge_dev *hdev);
 int hclge_tm_schd_mode_hw(struct hclge_dev *hdev);
 int hclge_tm_prio_tc_info_update(struct hclge_dev *hdev, u8 *prio_tc);
-void hclge_tm_schd_info_update(struct hclge_dev *hdev, u8 num_tc);
+int hclge_tm_schd_info_update(struct hclge_dev *hdev, u8 num_tc);
 int hclge_tm_dwrr_cfg(struct hclge_dev *hdev);
 int hclge_tm_map_cfg(struct hclge_dev *hdev);
 int hclge_tm_init_hw(struct hclge_dev *hdev);