Skip to content

Commit 671cb8c

Browse files
321lipengdavem330
authored andcommitted
net: hns3: clean residual vf config after disable sriov
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: fa8d82e ("net: hns3: Add support of .sriov_configure in HNS3 driver") Signed-off-by: Peng Li<lipeng321@huawei.com> Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a89cbb1 commit 671cb8c

3 files changed

Lines changed: 71 additions & 0 deletions

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,8 @@ struct hnae3_ae_dev {
537537
* Get 1588 rx hwstamp
538538
* get_ts_info
539539
* Get phc info
540+
* clean_vf_config
541+
* Clean residual vf info after disable sriov
540542
*/
541543
struct hnae3_ae_ops {
542544
int (*init_ae_dev)(struct hnae3_ae_dev *ae_dev);
@@ -730,6 +732,7 @@ struct hnae3_ae_ops {
730732
struct ethtool_ts_info *info);
731733
int (*get_link_diagnosis_info)(struct hnae3_handle *handle,
732734
u32 *status_code);
735+
void (*clean_vf_config)(struct hnae3_ae_dev *ae_dev, int num_vfs);
733736
};
734737

735738
struct hnae3_dcb_ops {

drivers/net/ethernet/hisilicon/hns3/hns3_enet.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3060,6 +3060,21 @@ static int hns3_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
30603060
return ret;
30613061
}
30623062

3063+
/**
3064+
* hns3_clean_vf_config
3065+
* @pdev: pointer to a pci_dev structure
3066+
* @num_vfs: number of VFs allocated
3067+
*
3068+
* Clean residual vf config after disable sriov
3069+
**/
3070+
static void hns3_clean_vf_config(struct pci_dev *pdev, int num_vfs)
3071+
{
3072+
struct hnae3_ae_dev *ae_dev = pci_get_drvdata(pdev);
3073+
3074+
if (ae_dev->ops->clean_vf_config)
3075+
ae_dev->ops->clean_vf_config(ae_dev, num_vfs);
3076+
}
3077+
30633078
/* hns3_remove - Device removal routine
30643079
* @pdev: PCI device information struct
30653080
*/
@@ -3098,7 +3113,10 @@ static int hns3_pci_sriov_configure(struct pci_dev *pdev, int num_vfs)
30983113
else
30993114
return num_vfs;
31003115
} else if (!pci_vfs_assigned(pdev)) {
3116+
int num_vfs_pre = pci_num_vf(pdev);
3117+
31013118
pci_disable_sriov(pdev);
3119+
hns3_clean_vf_config(pdev, num_vfs_pre);
31023120
} else {
31033121
dev_warn(&pdev->dev,
31043122
"Unable to free VFs because some are assigned to VMs.\n");

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12724,6 +12724,55 @@ static int hclge_get_link_diagnosis_info(struct hnae3_handle *handle,
1272412724
return 0;
1272512725
}
1272612726

12727+
/* After disable sriov, VF still has some config and info need clean,
12728+
* which configed by PF.
12729+
*/
12730+
static void hclge_clear_vport_vf_info(struct hclge_vport *vport, int vfid)
12731+
{
12732+
struct hclge_dev *hdev = vport->back;
12733+
struct hclge_vlan_info vlan_info;
12734+
int ret;
12735+
12736+
/* after disable sriov, clean VF rate configured by PF */
12737+
ret = hclge_tm_qs_shaper_cfg(vport, 0);
12738+
if (ret)
12739+
dev_err(&hdev->pdev->dev,
12740+
"failed to clean vf%d rate config, ret = %d\n",
12741+
vfid, ret);
12742+
12743+
vlan_info.vlan_tag = 0;
12744+
vlan_info.qos = 0;
12745+
vlan_info.vlan_proto = ETH_P_8021Q;
12746+
ret = hclge_update_port_base_vlan_cfg(vport,
12747+
HNAE3_PORT_BASE_VLAN_DISABLE,
12748+
&vlan_info);
12749+
if (ret)
12750+
dev_err(&hdev->pdev->dev,
12751+
"failed to clean vf%d port base vlan, ret = %d\n",
12752+
vfid, ret);
12753+
12754+
ret = hclge_set_vf_spoofchk_hw(hdev, vport->vport_id, false);
12755+
if (ret)
12756+
dev_err(&hdev->pdev->dev,
12757+
"failed to clean vf%d spoof config, ret = %d\n",
12758+
vfid, ret);
12759+
12760+
memset(&vport->vf_info, 0, sizeof(vport->vf_info));
12761+
}
12762+
12763+
static void hclge_clean_vport_config(struct hnae3_ae_dev *ae_dev, int num_vfs)
12764+
{
12765+
struct hclge_dev *hdev = ae_dev->priv;
12766+
struct hclge_vport *vport;
12767+
int i;
12768+
12769+
for (i = 0; i < num_vfs; i++) {
12770+
vport = &hdev->vport[i + HCLGE_VF_VPORT_START_NUM];
12771+
12772+
hclge_clear_vport_vf_info(vport, i);
12773+
}
12774+
}
12775+
1272712776
static const struct hnae3_ae_ops hclge_ops = {
1272812777
.init_ae_dev = hclge_init_ae_dev,
1272912778
.uninit_ae_dev = hclge_uninit_ae_dev,
@@ -12825,6 +12874,7 @@ static const struct hnae3_ae_ops hclge_ops = {
1282512874
.get_rx_hwts = hclge_ptp_get_rx_hwts,
1282612875
.get_ts_info = hclge_ptp_get_ts_info,
1282712876
.get_link_diagnosis_info = hclge_get_link_diagnosis_info,
12877+
.clean_vf_config = hclge_clean_vport_config,
1282812878
};
1282912879

1283012880
static struct hnae3_ae_algo ae_algo = {

0 commit comments

Comments
 (0)