]> git.baikalelectronics.ru Git - kernel.git/commit
net: hns3: fix for not calculating tx bd num correctly
authorYunsheng Lin <linyunsheng@huawei.com>
Thu, 21 Mar 2019 03:28:43 +0000 (11:28 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 21 Mar 2019 20:59:24 +0000 (13:59 -0700)
commit58accda502e55eefb82fb33780e03d4e78909136
tree8766e7d7a2619c06d7e81391db73b02f9db2c2ab
parent36428e9cbca02f4d5c3f4da35890c79ffc668f02
net: hns3: fix for not calculating tx bd num correctly

When there is only one byte in a frag, the current calculation
using "(size + HNS3_MAX_BD_SIZE - 1) >> HNS3_MAX_BD_SIZE_OFFSET"
will return zero, because HNS3_MAX_BD_SIZE is 65535 and
HNS3_MAX_BD_SIZE_OFFSET is 16. So it will cause tx error when
a frag's size is one byte.

This patch fixes it by using DIV_ROUND_UP.

Fixes: 0d9e57f387be ("net: hns3: avoid mult + div op in critical data path")
Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
drivers/net/ethernet/hisilicon/hns3/hns3_enet.h