Skip to content

Commit 882481b

Browse files
Jijie Shaodavem330
authored andcommitted
net: hns3: fix wrong bw weight of disabled tc issue
In dwrr mode, the default bandwidth weight of disabled tc is set to 0. If the bandwidth weight is 0, the mode will change to sp. Therefore, disabled tc default bandwidth weight need changed to 1, and 0 is returned when query the bandwidth weight of disabled tc. In addition, driver need stop configure bandwidth weight if tc is disabled. Fixes: 8484405 ("net: hns3: Add support of TX Scheduler & Shaper to HNS3 driver") Signed-off-by: Jie Wang <wangjie125@huawei.com> Signed-off-by: Jijie Shao <shaojijie@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 116d9f7 commit 882481b

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ static void hclge_tm_info_to_ieee_ets(struct hclge_dev *hdev,
5252

5353
for (i = 0; i < HNAE3_MAX_TC; i++) {
5454
ets->prio_tc[i] = hdev->tm_info.prio_tc[i];
55-
ets->tc_tx_bw[i] = hdev->tm_info.pg_info[0].tc_dwrr[i];
55+
if (i < hdev->tm_info.num_tc)
56+
ets->tc_tx_bw[i] = hdev->tm_info.pg_info[0].tc_dwrr[i];
57+
else
58+
ets->tc_tx_bw[i] = 0;
5659

5760
if (hdev->tm_info.tc_info[i].tc_sch_mode ==
5861
HCLGE_SCH_MODE_SP)
@@ -123,7 +126,8 @@ static u8 hclge_ets_tc_changed(struct hclge_dev *hdev, struct ieee_ets *ets,
123126
}
124127

125128
static int hclge_ets_sch_mode_validate(struct hclge_dev *hdev,
126-
struct ieee_ets *ets, bool *changed)
129+
struct ieee_ets *ets, bool *changed,
130+
u8 tc_num)
127131
{
128132
bool has_ets_tc = false;
129133
u32 total_ets_bw = 0;
@@ -137,6 +141,13 @@ static int hclge_ets_sch_mode_validate(struct hclge_dev *hdev,
137141
*changed = true;
138142
break;
139143
case IEEE_8021QAZ_TSA_ETS:
144+
if (i >= tc_num) {
145+
dev_err(&hdev->pdev->dev,
146+
"tc%u is disabled, cannot set ets bw\n",
147+
i);
148+
return -EINVAL;
149+
}
150+
140151
/* The hardware will switch to sp mode if bandwidth is
141152
* 0, so limit ets bandwidth must be greater than 0.
142153
*/
@@ -176,7 +187,7 @@ static int hclge_ets_validate(struct hclge_dev *hdev, struct ieee_ets *ets,
176187
if (ret)
177188
return ret;
178189

179-
ret = hclge_ets_sch_mode_validate(hdev, ets, changed);
190+
ret = hclge_ets_sch_mode_validate(hdev, ets, changed, tc_num);
180191
if (ret)
181192
return ret;
182193

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,7 @@ static void hclge_tm_tc_info_init(struct hclge_dev *hdev)
785785
static void hclge_tm_pg_info_init(struct hclge_dev *hdev)
786786
{
787787
#define BW_PERCENT 100
788+
#define DEFAULT_BW_WEIGHT 1
788789

789790
u8 i;
790791

@@ -806,7 +807,7 @@ static void hclge_tm_pg_info_init(struct hclge_dev *hdev)
806807
for (k = 0; k < hdev->tm_info.num_tc; k++)
807808
hdev->tm_info.pg_info[i].tc_dwrr[k] = BW_PERCENT;
808809
for (; k < HNAE3_MAX_TC; k++)
809-
hdev->tm_info.pg_info[i].tc_dwrr[k] = 0;
810+
hdev->tm_info.pg_info[i].tc_dwrr[k] = DEFAULT_BW_WEIGHT;
810811
}
811812
}
812813

0 commit comments

Comments
 (0)