Skip to content

Commit

Permalink
net: hns3: Change return type of hclge_tm_schd_info_update()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Huazhong Tan authored and David S. Miller committed Sep 28, 2018
1 parent 93d8daf commit fe5eb04
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
8 changes: 6 additions & 2 deletions drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 8 additions & 1 deletion drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit fe5eb04

Please sign in to comment.