提交 ea3c3ca1 编写于 作者: Y Yonglong Liu 提交者: Xie XiuQi

net: hns3: fix shaper parameter algorithm

driver inclusion
category: bugfix
bugzilla: NA
CVE: NA

HNS3 driver use unsigned int to calculate the shaper parameter,
when the configured bandwidth is small, like 1M, the actual result
is 1.28M in the chip side. This bug only appears when the bandwidth
is less than 20M.

This patch plus the ir_s one more time when the calculated result
is equals to the configured bandwidth, so that can get a value
closer to the configured bandwidth.

Feature or Bugfix:Bugfix
Signed-off-by: NYonglong Liu <liuyonglong@huawei.com>
Reviewed-by: Nlinyunsheng <linyunsheng@huawei.com>
Reviewed-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 80bcc5f0
......@@ -81,16 +81,13 @@ static int hclge_shaper_para_calc(u32 ir, u8 shaper_level,
return 0;
} else if (ir_calc > ir) {
/* Increasing the denominator to select ir_s value */
while (ir_calc > ir) {
while (ir_calc >= ir && ir) {
ir_s_calc++;
ir_calc = DIVISOR_IR_B_126 / (tick * (1 << ir_s_calc));
}
if (ir_calc == ir)
*ir_b = 126;
else
*ir_b = (ir * tick * (1 << ir_s_calc) +
(DIVISOR_CLK >> 1)) / DIVISOR_CLK;
*ir_b = (ir * tick * (1 << ir_s_calc) + (DIVISOR_CLK >> 1)) /
DIVISOR_CLK;
} else {
/* Increasing the numerator to select ir_u value */
u32 numerator;
......@@ -104,7 +101,7 @@ static int hclge_shaper_para_calc(u32 ir, u8 shaper_level,
if (ir_calc == ir) {
*ir_b = 126;
} else {
u32 denominator = (DIVISOR_CLK * (1 << --ir_u_calc));
u32 denominator = DIVISOR_CLK * (1 << --ir_u_calc);
*ir_b = (ir * tick + (denominator >> 1)) / denominator;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册