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)
commit5f543a54eec08228ab0cc0a49cf5d79dd32c9e5e
tree8766e7d7a2619c06d7e81391db73b02f9db2c2ab
parent408f13ef358aa5ad56dc6230c2c7deb92cf462b1
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: 3fe13ed95dd3 ("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