Skip to content

Commit fa55649

Browse files
Jijie ShaoPaolo Abeni
authored andcommitted
net: hns3: fix invalid mutex between tc qdisc and dcb ets command issue
We hope that tc qdisc and dcb ets commands can not be used crosswise. If we want to use any of the commands to configure tc, We must use the other command to clear the existing configuration. However, when we configure a single tc with tc qdisc, we can still configure it with dcb ets. Because we use mqprio_active as the tag of tc qdisc configuration, but with dcb ets, we do not check mqprio_active. This patch fix this issue by check mqprio_active before executing the dcb ets command. and add dcb_ets_active to replace HCLGE_FLAG_DCB_ENABLE and HCLGE_FLAG_MQPRIO_ENABLE at the hclge layer, Fixes: cacde27 ("net: hns3: Add hclge_dcb module for the support of DCB feature") Signed-off-by: Jijie Shao <shaojijie@huawei.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent c295160 commit fa55649

File tree

4 files changed

+9
-19
lines changed

4 files changed

+9
-19
lines changed

drivers/net/ethernet/hisilicon/hns3/hnae3.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,7 @@ struct hnae3_tc_info {
814814
u8 max_tc; /* Total number of TCs */
815815
u8 num_tc; /* Total number of enabled TCs */
816816
bool mqprio_active;
817+
bool dcb_ets_active;
817818
};
818819

819820
#define HNAE3_MAX_DSCP 64

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ static int hclge_ieee_setets(struct hnae3_handle *h, struct ieee_ets *ets)
259259
int ret;
260260

261261
if (!(hdev->dcbx_cap & DCB_CAP_DCBX_VER_IEEE) ||
262-
hdev->flag & HCLGE_FLAG_MQPRIO_ENABLE)
262+
h->kinfo.tc_info.mqprio_active)
263263
return -EINVAL;
264264

265265
ret = hclge_ets_validate(hdev, ets, &num_tc, &map_changed);
@@ -275,10 +275,7 @@ static int hclge_ieee_setets(struct hnae3_handle *h, struct ieee_ets *ets)
275275
}
276276

277277
hclge_tm_schd_info_update(hdev, num_tc);
278-
if (num_tc > 1)
279-
hdev->flag |= HCLGE_FLAG_DCB_ENABLE;
280-
else
281-
hdev->flag &= ~HCLGE_FLAG_DCB_ENABLE;
278+
h->kinfo.tc_info.dcb_ets_active = num_tc > 1;
282279

283280
ret = hclge_ieee_ets_to_tm_info(hdev, ets);
284281
if (ret)
@@ -487,7 +484,7 @@ static u8 hclge_getdcbx(struct hnae3_handle *h)
487484
struct hclge_vport *vport = hclge_get_vport(h);
488485
struct hclge_dev *hdev = vport->back;
489486

490-
if (hdev->flag & HCLGE_FLAG_MQPRIO_ENABLE)
487+
if (h->kinfo.tc_info.mqprio_active)
491488
return 0;
492489

493490
return hdev->dcbx_cap;
@@ -611,7 +608,8 @@ static int hclge_setup_tc(struct hnae3_handle *h,
611608
if (!test_bit(HCLGE_STATE_NIC_REGISTERED, &hdev->state))
612609
return -EBUSY;
613610

614-
if (hdev->flag & HCLGE_FLAG_DCB_ENABLE)
611+
kinfo = &vport->nic.kinfo;
612+
if (kinfo->tc_info.dcb_ets_active)
615613
return -EINVAL;
616614

617615
ret = hclge_mqprio_qopt_check(hdev, mqprio_qopt);
@@ -625,7 +623,6 @@ static int hclge_setup_tc(struct hnae3_handle *h,
625623
if (ret)
626624
return ret;
627625

628-
kinfo = &vport->nic.kinfo;
629626
memcpy(&old_tc_info, &kinfo->tc_info, sizeof(old_tc_info));
630627
hclge_sync_mqprio_qopt(&kinfo->tc_info, mqprio_qopt);
631628
kinfo->tc_info.mqprio_active = tc > 0;
@@ -634,13 +631,6 @@ static int hclge_setup_tc(struct hnae3_handle *h,
634631
if (ret)
635632
goto err_out;
636633

637-
hdev->flag &= ~HCLGE_FLAG_DCB_ENABLE;
638-
639-
if (tc > 1)
640-
hdev->flag |= HCLGE_FLAG_MQPRIO_ENABLE;
641-
else
642-
hdev->flag &= ~HCLGE_FLAG_MQPRIO_ENABLE;
643-
644634
return hclge_notify_init_up(hdev);
645635

646636
err_out:

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11026,6 +11026,7 @@ static void hclge_get_mdix_mode(struct hnae3_handle *handle,
1102611026

1102711027
static void hclge_info_show(struct hclge_dev *hdev)
1102811028
{
11029+
struct hnae3_handle *handle = &hdev->vport->nic;
1102911030
struct device *dev = &hdev->pdev->dev;
1103011031

1103111032
dev_info(dev, "PF info begin:\n");
@@ -11042,9 +11043,9 @@ static void hclge_info_show(struct hclge_dev *hdev)
1104211043
dev_info(dev, "This is %s PF\n",
1104311044
hdev->flag & HCLGE_FLAG_MAIN ? "main" : "not main");
1104411045
dev_info(dev, "DCB %s\n",
11045-
hdev->flag & HCLGE_FLAG_DCB_ENABLE ? "enable" : "disable");
11046+
handle->kinfo.tc_info.dcb_ets_active ? "enable" : "disable");
1104611047
dev_info(dev, "MQPRIO %s\n",
11047-
hdev->flag & HCLGE_FLAG_MQPRIO_ENABLE ? "enable" : "disable");
11048+
handle->kinfo.tc_info.mqprio_active ? "enable" : "disable");
1104811049
dev_info(dev, "Default tx spare buffer size: %u\n",
1104911050
hdev->tx_spare_buf_size);
1105011051

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,8 +919,6 @@ struct hclge_dev {
919919

920920
#define HCLGE_FLAG_MAIN BIT(0)
921921
#define HCLGE_FLAG_DCB_CAPABLE BIT(1)
922-
#define HCLGE_FLAG_DCB_ENABLE BIT(2)
923-
#define HCLGE_FLAG_MQPRIO_ENABLE BIT(3)
924922
u32 flag;
925923

926924
u32 pkt_buf_size; /* Total pf buf size for tx/rx */

0 commit comments

Comments
 (0)