net: hns3: add limit ets dwrr bandwidth cannot be 0
[platform/kernel/linux-starfive.git] / drivers / net / ethernet / hisilicon / hns3 / hns3pf / hclge_dcb.c
index 307c9e8..91cb578 100644 (file)
@@ -137,6 +137,15 @@ static int hclge_ets_sch_mode_validate(struct hclge_dev *hdev,
                                *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;