Commit b62afba4 authored by Hao Lan's avatar Hao Lan Committed by Jiantao Xiao
Browse files

net: hns3: add tm flush when setting tm

driver inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7B8SA


CVE: NA

----------------------------------------------------------------------

When the tm module is configured with traffic, traffic
may be abnormal. This patch fixes this problem.
Before the tm module is configured, traffic processing
should be stopped. After the tm module is configured,
traffic processing is enabled.

Fixes: 84844054 ("net: hns3: Add support of TX Scheduler & Shaper to HNS3 driver")
Signed-off-by: default avatarHao Lan <lanhao@huawei.com>
parent 702c687c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -105,6 +105,7 @@ enum HNAE3_DEV_CAP_BITS {
	HNAE3_DEV_SUPPORT_WOL_B,
	HNAE3_DEV_SUPPORT_VF_FAULT_B,
	HNAE3_DEV_SUPPORT_NOTIFY_PKT_B,
	HNAE3_DEV_SUPPORT_TM_FLUSH_B,
};

#define hnae3_ae_dev_fd_supported(ae_dev) \
@@ -179,6 +180,9 @@ enum HNAE3_DEV_CAP_BITS {
#define hnae3_ae_dev_notify_pkt_supported(ae_dev) \
	test_bit(HNAE3_DEV_SUPPORT_NOTIFY_PKT_B, (ae_dev)->caps)

#define hnae3_ae_dev_tm_flush_supported(hdev) \
	test_bit(HNAE3_DEV_SUPPORT_TM_FLUSH_B, (hdev)->ae_dev->caps)

enum HNAE3_PF_CAP_BITS {
	HNAE3_PF_SUPPORT_VLAN_FLTR_MDF_B = 0,
};
+1 −0
Original line number Diff line number Diff line
@@ -157,6 +157,7 @@ static const struct hclge_comm_caps_bit_map hclge_pf_cmd_caps[] = {
	{HCLGE_COMM_CAP_WOL_B, HNAE3_DEV_SUPPORT_WOL_B},
	{HCLGE_COMM_CAP_VF_FAULT_B, HNAE3_DEV_SUPPORT_VF_FAULT_B},
	{HCLGE_COMM_CAP_NOTIFY_PKT_B, HNAE3_DEV_SUPPORT_NOTIFY_PKT_B},
	{HCLGE_COMM_CAP_TM_FLUSH_B, HNAE3_DEV_SUPPORT_TM_FLUSH_B},
};

static const struct hclge_comm_caps_bit_map hclge_vf_cmd_caps[] = {
+2 −0
Original line number Diff line number Diff line
@@ -153,6 +153,7 @@ enum hclge_opcode_type {
	HCLGE_OPC_TM_INTERNAL_STS	= 0x0850,
	HCLGE_OPC_TM_INTERNAL_CNT	= 0x0851,
	HCLGE_OPC_TM_INTERNAL_STS_1	= 0x0852,
	HCLGE_OPC_TM_FLUSH		= 0x0872,

	/* Packet buffer allocate commands */
	HCLGE_OPC_TX_BUFF_ALLOC		= 0x0901,
@@ -350,6 +351,7 @@ enum HCLGE_COMM_CAP_BITS {
	HCLGE_COMM_CAP_LANE_NUM_B = 27,
	HCLGE_COMM_CAP_WOL_B = 28,
	HCLGE_COMM_CAP_NOTIFY_PKT_B = 29,
	HCLGE_COMM_CAP_TM_FLUSH_B = 31,
};

enum HCLGE_COMM_API_CAP_BITS {
+3 −0
Original line number Diff line number Diff line
@@ -415,6 +415,9 @@ static struct hns3_dbg_cap_info hns3_dbg_cap[] = {
	}, {
		.name = "support vf fault detect",
		.cap_bit = HNAE3_DEV_SUPPORT_VF_FAULT_B,
	}, {
		.name = "support tm flush",
		.cap_bit = HNAE3_DEV_SUPPORT_TM_FLUSH_B,
	}
};

+29 −5
Original line number Diff line number Diff line
@@ -216,6 +216,10 @@ static int hclge_notify_down_uinit(struct hclge_dev *hdev)
	if (ret)
		return ret;

	ret = hclge_tm_flush_cfg(hdev, true);
	if (ret)
		return ret;

	return hclge_notify_client(hdev, HNAE3_UNINIT_CLIENT);
}

@@ -227,6 +231,10 @@ static int hclge_notify_init_up(struct hclge_dev *hdev)
	if (ret)
		return ret;

	ret = hclge_tm_flush_cfg(hdev, false);
	if (ret)
		return ret;

	return hclge_notify_client(hdev, HNAE3_UP_CLIENT);
}

@@ -313,6 +321,7 @@ static int hclge_ieee_setpfc(struct hnae3_handle *h, struct ieee_pfc *pfc)
	struct net_device *netdev = h->kinfo.netdev;
	struct hclge_dev *hdev = vport->back;
	u8 i, j, pfc_map, *prio_tc;
	int last_bad_ret = 0;
	int ret;

	if (!(hdev->dcbx_cap & DCB_CAP_DCBX_VER_IEEE))
@@ -350,13 +359,28 @@ static int hclge_ieee_setpfc(struct hnae3_handle *h, struct ieee_pfc *pfc)
	if (ret)
		return ret;

	ret = hclge_buffer_alloc(hdev);
	if (ret) {
		hclge_notify_client(hdev, HNAE3_UP_CLIENT);
	ret = hclge_tm_flush_cfg(hdev, true);
	if (ret)
		return ret;
	}

	return hclge_notify_client(hdev, HNAE3_UP_CLIENT);
	/* No matter whether the following operations are performed
	 * successfully or not, disabling the tm flush and notify
	 * the network status to up are necessary.
	 * Do not return immediately.
	 */
	ret = hclge_buffer_alloc(hdev);
	if (ret)
		last_bad_ret = ret;

	ret = hclge_tm_flush_cfg(hdev, false);
	if (ret)
		last_bad_ret = ret;

	ret = hclge_notify_client(hdev, HNAE3_UP_CLIENT);
	if (ret)
		last_bad_ret = ret;

	return last_bad_ret;
}

static int hclge_ieee_setapp(struct hnae3_handle *h, struct dcb_app *app)
Loading