net: hns3: Fix for packet buffer setting bug
The hardware expects a unit of 128 bytes when setting
packet buffer. When calculating the packet buffer size,
hclge_rx_buffer_calc does not round up the size as a unit
of 128 byte, which may casue packet lost problem when stress
testing.
This patch fixes it by rounding up packet size when calculating.
Fixes: 46a3df9f97
("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support")
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>
This commit is contained in:
parent
4dc13b9668
commit
996ff91840
|
@ -1356,11 +1356,13 @@ static int hclge_tx_buffer_calc(struct hclge_dev *hdev,
|
||||||
static int hclge_rx_buffer_calc(struct hclge_dev *hdev,
|
static int hclge_rx_buffer_calc(struct hclge_dev *hdev,
|
||||||
struct hclge_pkt_buf_alloc *buf_alloc)
|
struct hclge_pkt_buf_alloc *buf_alloc)
|
||||||
{
|
{
|
||||||
u32 rx_all = hdev->pkt_buf_size;
|
#define HCLGE_BUF_SIZE_UNIT 128
|
||||||
|
u32 rx_all = hdev->pkt_buf_size, aligned_mps;
|
||||||
int no_pfc_priv_num, pfc_priv_num;
|
int no_pfc_priv_num, pfc_priv_num;
|
||||||
struct hclge_priv_buf *priv;
|
struct hclge_priv_buf *priv;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
aligned_mps = round_up(hdev->mps, HCLGE_BUF_SIZE_UNIT);
|
||||||
rx_all -= hclge_get_tx_buff_alloced(buf_alloc);
|
rx_all -= hclge_get_tx_buff_alloced(buf_alloc);
|
||||||
|
|
||||||
/* When DCB is not supported, rx private
|
/* When DCB is not supported, rx private
|
||||||
|
@ -1379,13 +1381,13 @@ static int hclge_rx_buffer_calc(struct hclge_dev *hdev,
|
||||||
if (hdev->hw_tc_map & BIT(i)) {
|
if (hdev->hw_tc_map & BIT(i)) {
|
||||||
priv->enable = 1;
|
priv->enable = 1;
|
||||||
if (hdev->tm_info.hw_pfc_map & BIT(i)) {
|
if (hdev->tm_info.hw_pfc_map & BIT(i)) {
|
||||||
priv->wl.low = hdev->mps;
|
priv->wl.low = aligned_mps;
|
||||||
priv->wl.high = priv->wl.low + hdev->mps;
|
priv->wl.high = priv->wl.low + aligned_mps;
|
||||||
priv->buf_size = priv->wl.high +
|
priv->buf_size = priv->wl.high +
|
||||||
HCLGE_DEFAULT_DV;
|
HCLGE_DEFAULT_DV;
|
||||||
} else {
|
} else {
|
||||||
priv->wl.low = 0;
|
priv->wl.low = 0;
|
||||||
priv->wl.high = 2 * hdev->mps;
|
priv->wl.high = 2 * aligned_mps;
|
||||||
priv->buf_size = priv->wl.high;
|
priv->buf_size = priv->wl.high;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1417,11 +1419,11 @@ static int hclge_rx_buffer_calc(struct hclge_dev *hdev,
|
||||||
|
|
||||||
if (hdev->tm_info.hw_pfc_map & BIT(i)) {
|
if (hdev->tm_info.hw_pfc_map & BIT(i)) {
|
||||||
priv->wl.low = 128;
|
priv->wl.low = 128;
|
||||||
priv->wl.high = priv->wl.low + hdev->mps;
|
priv->wl.high = priv->wl.low + aligned_mps;
|
||||||
priv->buf_size = priv->wl.high + HCLGE_DEFAULT_DV;
|
priv->buf_size = priv->wl.high + HCLGE_DEFAULT_DV;
|
||||||
} else {
|
} else {
|
||||||
priv->wl.low = 0;
|
priv->wl.low = 0;
|
||||||
priv->wl.high = hdev->mps;
|
priv->wl.high = aligned_mps;
|
||||||
priv->buf_size = priv->wl.high;
|
priv->buf_size = priv->wl.high;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue