net: hns3: Fix for DEFAULT_DV when dev doesn't support DCB
authorYunsheng Lin <linyunsheng@huawei.com>
Wed, 20 Sep 2017 10:52:52 +0000 (18:52 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 20 Sep 2017 23:15:39 +0000 (16:15 -0700)
When ae_dev doesn't support DCB, DEFAULT_DV must be set to
a lower value, otherwise the buffer allocation process will
fail.
This patch fix it by setting it to 30K bytes.

Fixes: 46a3df9f9718 ("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support")
Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

index c2b613b40509f9b3b3f7fadec1f25843775cd921..30e2ad5ac0dab72e2694ad6e43d7c7239df9063e 100644 (file)
@@ -688,6 +688,7 @@ struct hclge_reset_tqp_queue {
 #define HCLGE_DEFAULT_TX_BUF           0x4000   /* 16k  bytes */
 #define HCLGE_TOTAL_PKT_BUF            0x108000 /* 1.03125M bytes */
 #define HCLGE_DEFAULT_DV               0xA000   /* 40k byte */
+#define HCLGE_DEFAULT_NON_DCB_DV       0x7800  /* 30K byte */
 
 #define HCLGE_TYPE_CRQ                 0
 #define HCLGE_TYPE_CSQ                 1
index 903f43a8c2a12c14d21d716c012dc8956cdd326b..796370adf99ce910b9daf29b34524568dbbc2ed8 100644 (file)
@@ -1444,7 +1444,11 @@ static bool  hclge_is_rx_buf_ok(struct hclge_dev *hdev, u32 rx_all)
        tc_num = hclge_get_tc_num(hdev);
        pfc_enable_num = hclge_get_pfc_enalbe_num(hdev);
 
-       shared_buf_min = 2 * hdev->mps + HCLGE_DEFAULT_DV;
+       if (hnae3_dev_dcb_supported(hdev))
+               shared_buf_min = 2 * hdev->mps + HCLGE_DEFAULT_DV;
+       else
+               shared_buf_min = 2 * hdev->mps + HCLGE_DEFAULT_NON_DCB_DV;
+
        shared_buf_tc = pfc_enable_num * hdev->mps +
                        (tc_num - pfc_enable_num) * hdev->mps / 2 +
                        hdev->mps;