Commit 30d529c8 authored by Guangbin Huang's avatar Guangbin Huang Committed by Yonglong Liu
Browse files

net: hns3: fix tm port shapping of fibre port is incorrect after driver initialization

mainline inclusion
from mainline-v5.19-rc3
commit 12a36708
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I91FSH


CVE: NA

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

Currently in driver initialization process, driver will set shapping
parameters of tm port to default speed read from firmware. However, the
speed of SFP module may not be default speed, so shapping parameters of
tm port may be incorrect.

To fix this problem, driver sets new shapping parameters for tm port
after getting exact speed of SFP module in this case.

Fixes: 88d10bd6 ("net: hns3: add support for multiple media type")
Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarYonglong Liu <liuyonglong@huawei.com>
parent 7efcac76
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -2916,7 +2916,7 @@ static int hclge_get_sfp_info(struct hclge_dev *hdev, struct hclge_mac *mac)
static int hclge_update_port_info(struct hclge_dev *hdev)
{
	struct hclge_mac *mac = &hdev->hw.mac;
	int speed = HCLGE_MAC_SPEED_UNKNOWN;
	int speed;
	int ret;

	/* get the port info from SFP cmd if not copper port */
@@ -2927,10 +2927,13 @@ static int hclge_update_port_info(struct hclge_dev *hdev)
	if (!hdev->support_sfp_query)
		return 0;

	if (hdev->pdev->revision >= 0x21)
	if (hdev->pdev->revision >= 0x21) {
		speed = mac->speed;
		ret = hclge_get_sfp_info(hdev, mac);
	else
	} else {
		speed = HCLGE_MAC_SPEED_UNKNOWN;
		ret = hclge_get_sfp_speed(hdev, &speed);
	}

	if (ret == -EOPNOTSUPP) {
		hdev->support_sfp_query = false;
@@ -2942,6 +2945,8 @@ static int hclge_update_port_info(struct hclge_dev *hdev)
	if (hdev->pdev->revision >= 0x21) {
		if (mac->speed_type == QUERY_ACTIVE_SPEED) {
			hclge_update_port_capability(mac);
			if (mac->speed != speed)
				(void)hclge_tm_port_shaper_cfg(hdev);
			return 0;
		}
		return hclge_cfg_mac_speed_dup(hdev, mac->speed,
+1 −1
Original line number Diff line number Diff line
@@ -397,7 +397,7 @@ static int hclge_tm_pg_shapping_cfg(struct hclge_dev *hdev,
	return hclge_cmd_send(&hdev->hw, &desc, 1);
}

static int hclge_tm_port_shaper_cfg(struct hclge_dev *hdev)
int hclge_tm_port_shaper_cfg(struct hclge_dev *hdev)
{
	struct hclge_port_shapping_cmd *shap_cfg_cmd;
	struct hclge_desc desc;
+1 −0
Original line number Diff line number Diff line
@@ -188,6 +188,7 @@ int hclge_pause_addr_cfg(struct hclge_dev *hdev, const u8 *mac_addr);
void hclge_pfc_rx_stats_get(struct hclge_dev *hdev, u64 *stats);
void hclge_pfc_tx_stats_get(struct hclge_dev *hdev, u64 *stats);
int hclge_tm_qs_shaper_cfg(struct hclge_vport *vport, int max_tx_rate);
int hclge_tm_port_shaper_cfg(struct hclge_dev *hdev);
int hclge_tm_get_qset_num(struct hclge_dev *hdev, u16 *qset_num);
int hclge_tm_get_pri_num(struct hclge_dev *hdev, u8 *pri_num);
int hclge_tm_get_qset_map_pri(struct hclge_dev *hdev, u16 qset_id, u8 *priority,