提交 873adb30 编写于 作者: P Peng Li 提交者: Zheng Zengkai

net: hns3: clean residual vf config after disable sriov

mainline inclusion
from mainline-net-5.17
commit 671cb8cb
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4YXIM
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=671cb8cbb9c9

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

After disable sriov, VF still has some config and info need to be
cleaned, which configured by PF. This patch clean the HW config
and SW struct vport->vf_info.

Fixes: fa8d82e8 ("net: hns3: Add support of .sriov_configure in HNS3 driver")
Signed-off-by: Peng Li<lipeng321@huawei.com>
Signed-off-by: NGuangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Reviewed-by: NYue Haibing <yuehaibing@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 bde8509c
...@@ -536,6 +536,8 @@ struct hnae3_ae_dev { ...@@ -536,6 +536,8 @@ struct hnae3_ae_dev {
* Get 1588 rx hwstamp * Get 1588 rx hwstamp
* get_ts_info * get_ts_info
* Get phc info * Get phc info
* clean_vf_config
* Clean residual vf info after disable sriov
*/ */
struct hnae3_ae_ops { struct hnae3_ae_ops {
int (*init_ae_dev)(struct hnae3_ae_dev *ae_dev); int (*init_ae_dev)(struct hnae3_ae_dev *ae_dev);
...@@ -729,6 +731,7 @@ struct hnae3_ae_ops { ...@@ -729,6 +731,7 @@ struct hnae3_ae_ops {
struct ethtool_ts_info *info); struct ethtool_ts_info *info);
int (*get_link_diagnosis_info)(struct hnae3_handle *handle, int (*get_link_diagnosis_info)(struct hnae3_handle *handle,
u32 *status_code); u32 *status_code);
void (*clean_vf_config)(struct hnae3_ae_dev *ae_dev, int num_vfs);
}; };
struct hnae3_dcb_ops { struct hnae3_dcb_ops {
......
...@@ -3059,6 +3059,21 @@ static int hns3_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -3059,6 +3059,21 @@ static int hns3_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
return ret; return ret;
} }
/**
* hns3_clean_vf_config
* @pdev: pointer to a pci_dev structure
* @num_vfs: number of VFs allocated
*
* Clean residual vf config after disable sriov
**/
static void hns3_clean_vf_config(struct pci_dev *pdev, int num_vfs)
{
struct hnae3_ae_dev *ae_dev = pci_get_drvdata(pdev);
if (ae_dev->ops->clean_vf_config)
ae_dev->ops->clean_vf_config(ae_dev, num_vfs);
}
/* hns3_remove - Device removal routine /* hns3_remove - Device removal routine
* @pdev: PCI device information struct * @pdev: PCI device information struct
*/ */
...@@ -3097,7 +3112,10 @@ static int hns3_pci_sriov_configure(struct pci_dev *pdev, int num_vfs) ...@@ -3097,7 +3112,10 @@ static int hns3_pci_sriov_configure(struct pci_dev *pdev, int num_vfs)
else else
return num_vfs; return num_vfs;
} else if (!pci_vfs_assigned(pdev)) { } else if (!pci_vfs_assigned(pdev)) {
int num_vfs_pre = pci_num_vf(pdev);
pci_disable_sriov(pdev); pci_disable_sriov(pdev);
hns3_clean_vf_config(pdev, num_vfs_pre);
} else { } else {
dev_warn(&pdev->dev, dev_warn(&pdev->dev,
"Unable to free VFs because some are assigned to VMs.\n"); "Unable to free VFs because some are assigned to VMs.\n");
......
...@@ -12724,6 +12724,55 @@ static int hclge_get_link_diagnosis_info(struct hnae3_handle *handle, ...@@ -12724,6 +12724,55 @@ static int hclge_get_link_diagnosis_info(struct hnae3_handle *handle,
return 0; return 0;
} }
/* After disable sriov, VF still has some config and info need clean,
* which configed by PF.
*/
static void hclge_clear_vport_vf_info(struct hclge_vport *vport, int vfid)
{
struct hclge_dev *hdev = vport->back;
struct hclge_vlan_info vlan_info;
int ret;
/* after disable sriov, clean VF rate configured by PF */
ret = hclge_tm_qs_shaper_cfg(vport, 0);
if (ret)
dev_err(&hdev->pdev->dev,
"failed to clean vf%d rate config, ret = %d\n",
vfid, ret);
vlan_info.vlan_tag = 0;
vlan_info.qos = 0;
vlan_info.vlan_proto = ETH_P_8021Q;
ret = hclge_update_port_base_vlan_cfg(vport,
HNAE3_PORT_BASE_VLAN_DISABLE,
&vlan_info);
if (ret)
dev_err(&hdev->pdev->dev,
"failed to clean vf%d port base vlan, ret = %d\n",
vfid, ret);
ret = hclge_set_vf_spoofchk_hw(hdev, vport->vport_id, false);
if (ret)
dev_err(&hdev->pdev->dev,
"failed to clean vf%d spoof config, ret = %d\n",
vfid, ret);
memset(&vport->vf_info, 0, sizeof(vport->vf_info));
}
static void hclge_clean_vport_config(struct hnae3_ae_dev *ae_dev, int num_vfs)
{
struct hclge_dev *hdev = ae_dev->priv;
struct hclge_vport *vport;
int i;
for (i = 0; i < num_vfs; i++) {
vport = &hdev->vport[i + HCLGE_VF_VPORT_START_NUM];
hclge_clear_vport_vf_info(vport, i);
}
}
static const struct hnae3_ae_ops hclge_ops = { static const struct hnae3_ae_ops hclge_ops = {
.init_ae_dev = hclge_init_ae_dev, .init_ae_dev = hclge_init_ae_dev,
.uninit_ae_dev = hclge_uninit_ae_dev, .uninit_ae_dev = hclge_uninit_ae_dev,
...@@ -12825,6 +12874,7 @@ static const struct hnae3_ae_ops hclge_ops = { ...@@ -12825,6 +12874,7 @@ static const struct hnae3_ae_ops hclge_ops = {
.get_rx_hwts = hclge_ptp_get_rx_hwts, .get_rx_hwts = hclge_ptp_get_rx_hwts,
.get_ts_info = hclge_ptp_get_ts_info, .get_ts_info = hclge_ptp_get_ts_info,
.get_link_diagnosis_info = hclge_get_link_diagnosis_info, .get_link_diagnosis_info = hclge_get_link_diagnosis_info,
.clean_vf_config = hclge_clean_vport_config,
}; };
static struct hnae3_ae_algo ae_algo = { static struct hnae3_ae_algo ae_algo = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册