From 7635f442340d48ce0d3425b5f5aef44e5054acf4 Mon Sep 17 00:00:00 2001 From: Hao Lan Date: Tue, 13 Dec 2022 11:46:36 +0800 Subject: [PATCH 1/3] net: hns3: fix pointer cast to different type for wol driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7A712 CVE: NA ---------------------------------------------------------------------- The pointer to decs.data is __le32 (*)[6], is incompatible to "struct hclge_wol_cfg_cmd *". So fix the pointer cast to correct type for decs.data. Signed-off-by: Hao Lan (cherry picked from commit f5432d461662fcb9a26c55e11dc4a7351e4f647b) --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 2c61ff5ef9ce..cfc32534ef30 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -12083,7 +12083,7 @@ int hclge_get_wol_supported_mode(struct hclge_dev *hdev, hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_WOL_GET_SUPPORTED_MODE, true); - wol_supported_cmd = (struct hclge_query_wol_supported_cmd *)&desc.data; + wol_supported_cmd = (struct hclge_query_wol_supported_cmd *)desc.data; ret = hclge_cmd_send(&hdev->hw, &desc, 1); if (ret) { @@ -12111,7 +12111,7 @@ int hclge_get_wol_cfg(struct hclge_dev *hdev, u32 *mode) return ret; } - wol_cfg_cmd = (struct hclge_wol_cfg_cmd *)&desc.data; + wol_cfg_cmd = (struct hclge_wol_cfg_cmd *)desc.data; *mode = le32_to_cpu(wol_cfg_cmd->wake_on_lan_mode); return 0; @@ -12125,7 +12125,7 @@ static int hclge_set_wol_cfg(struct hclge_dev *hdev, int ret; hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_WOL_CFG, false); - wol_cfg_cmd = (struct hclge_wol_cfg_cmd *)&desc.data; + wol_cfg_cmd = (struct hclge_wol_cfg_cmd *)desc.data; wol_cfg_cmd->wake_on_lan_mode = cpu_to_le32(wol_info->wol_current_mode); wol_cfg_cmd->sopass_size = wol_info->wol_sopass_size; memcpy(&wol_cfg_cmd->sopass, wol_info->wol_sopass, SOPASS_MAX); -- Gitee From 20a1e3d0ff5caff4d519488d1076c146559acf92 Mon Sep 17 00:00:00 2001 From: Hao Chen Date: Thu, 15 Dec 2022 11:54:02 +0800 Subject: [PATCH 2/3] net: hns3: add support for getting GE port lanes driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7A712 CVE: NA ---------------------------------------------------------------------- The number of lanes on the electrical port is 0, which does not meet the expectation. The patch add support for getting GE port lanes. Signed-off-by: Hao Chen (cherry picked from commit 49acadc5aec49c17080235022bb758d59b2d867f) --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_sysfs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_sysfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_sysfs.c index b7cc89c3f6d8..6840d7bda82e 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_sysfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_sysfs.c @@ -7,11 +7,16 @@ static ssize_t lane_num_show(struct device *dev, struct device_attribute *attr, char *buf) { +#define HCLGE_GE_PORT_ONE_LANE 1 struct pci_dev *pdev = container_of(dev, struct pci_dev, dev); struct hnae3_ae_dev *ae_dev = pci_get_drvdata(pdev); struct hclge_dev *hdev = ae_dev->priv; - return scnprintf(buf, PAGE_SIZE, "%u\n", hdev->hw.mac.lane_num); + if (hdev->hw.mac.media_type == HNAE3_MEDIA_TYPE_COPPER) + return scnprintf(buf, PAGE_SIZE, "%u\n", + HCLGE_GE_PORT_ONE_LANE); + else + return scnprintf(buf, PAGE_SIZE, "%u\n", hdev->hw.mac.lane_num); } static ssize_t lane_num_store(struct device *dev, -- Gitee From 8174d796f595f96dd5e5bb0b6ff410b2023730a6 Mon Sep 17 00:00:00 2001 From: Jiantao Xiao Date: Thu, 1 Jun 2023 19:40:57 +0800 Subject: [PATCH 3/3] net: hns3: fix set cpu affinity when state down driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7A712 CVE: NA ---------------------------------------------------------------------- The CPU affinity can be configured when the network port is down. The patch fixes the problem. Signed-off-by: Jiantao Xiao (cherry picked from commit b2b62276a1f2ee4854d1ae8627161c50cda895a9) --- drivers/net/ethernet/hisilicon/hns3/hns3_ext.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ext.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ext.c index 76fb40c27639..7deed8551a80 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ext.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ext.c @@ -239,6 +239,13 @@ int nic_set_cpu_affinity(struct net_device *ndev, cpumask_t *affinity_mask) goto err_unlock; } + if (test_bit(HNS3_NIC_STATE_DOWN, &priv->state)) { + netdev_err(ndev, + "ethernet is down, not support cpu affinity set\n"); + ret = -ENETDOWN; + goto err_unlock; + } + for (i = 0; i < priv->vector_num; i++) { tqp_vector = &priv->tqp_vector[i]; if (tqp_vector->irq_init_flag != HNS3_VECTOR_INITED) -- Gitee