]> git.ipfire.org Git - people/arne_f/kernel.git/commitdiff
net: hns3: add limit ets dwrr bandwidth cannot be 0
authorGuangbin Huang <huangguangbin2@huawei.com>
Tue, 19 Oct 2021 14:16:30 +0000 (22:16 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Oct 2021 07:56:49 +0000 (09:56 +0200)
[ Upstream commit 731797fdffa3d083db536e2fdd07ceb050bb40b1 ]

If ets dwrr bandwidth of tc is set to 0, the hardware will switch to SP
mode. In this case, this tc may occupy all the tx bandwidth if it has
huge traffic, so it violates the purpose of the user setting.

To fix this problem, limit the ets dwrr bandwidth must greater than 0.

Fixes: cacde272dd00 ("net: hns3: Add hclge_dcb module for the support of DCB feature")
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c

index 28a90ead4795d005f4f3b8912751557679ecb911..8e6085753b9f2e2f015efd11ec288f026f9ebd3f 100644 (file)
@@ -134,6 +134,15 @@ static int hclge_ets_validate(struct hclge_dev *hdev, struct ieee_ets *ets,
                                *changed = true;
                        break;
                case IEEE_8021QAZ_TSA_ETS:
+                       /* The hardware will switch to sp mode if bandwidth is
+                        * 0, so limit ets bandwidth must be greater than 0.
+                        */
+                       if (!ets->tc_tx_bw[i]) {
+                               dev_err(&hdev->pdev->dev,
+                                       "tc%u ets bw cannot be 0\n", i);
+                               return -EINVAL;
+                       }
+
                        if (hdev->tm_info.tc_info[i].tc_sch_mode !=
                                HCLGE_SCH_MODE_DWRR)
                                *changed = true;