提交 d4e83a9a 编写于 作者: Y Yufeng Mo 提交者: Xie XiuQi

net: hns3: change the range of vf id set by ip link set

driver inclusion
category: bugfix
bugzilla: NA
CVE: NA

Currently, the vf id range set by ip link set is the maximum number
of supportable vf. This patch changes the range to the number of enabled
vf, which makes it more reasonable.

This patch also modifies the start vf id from 1 to 0.

Feature or Bugfix:Bugfix
Signed-off-by: NYufeng Mo <moyufeng@huawei.com>
Reviewed-by: Nlinyunsheng <linyunsheng@huawei.com>
Reviewed-by: NYunsheng Lin <linyunsheng@huawei.com>
Reviewed-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 d76ec734
......@@ -55,6 +55,8 @@
#define HCLGE_DFX_TQP_BD_OFFSET 11
#define HCLGE_DFX_SSU_2_BD_OFFSET 12
#define HCLGE_VF_VPORT_START_NUM 1
static int hclge_set_mac_mtu(struct hclge_dev *hdev, int new_mps);
static int hclge_init_vlan_config(struct hclge_dev *hdev);
static void hclge_sync_vlan_filter(struct hclge_dev *hdev);
......@@ -2837,19 +2839,28 @@ static int hclge_get_status(struct hnae3_handle *handle)
return hdev->hw.mac.link;
}
static struct hclge_vport *hclge_get_vf_vport(struct hclge_dev *hdev, int vf)
{
#define HCLGE_VF_VPORT_START_NUM 1
if (vf < 0 || vf >= pci_num_vf(hdev->pdev))
return NULL;
/* vf start from 1 in vport */
vf += HCLGE_VF_VPORT_START_NUM;
return &hdev->vport[vf];
}
static int hclge_get_vf_config(struct hnae3_handle *handle, int vf,
struct ifla_vf_info *ivf)
{
#define HCLGE_VF_VPORT_START_NUM 1
struct hclge_vport *vport = hclge_get_vport(handle);
struct hclge_dev *hdev = vport->back;
if (vf < 0 || vf >= hdev->num_alloc_vport - HCLGE_VF_VPORT_START_NUM)
vport = hclge_get_vf_vport(hdev, vf);
if (!vport)
return -EINVAL;
/* vf start from 1 in vport */
vf += HCLGE_VF_VPORT_START_NUM;
vport = &hdev->vport[vf];
ivf->vf = vf;
ivf->linkstate = vport->link_state;
ivf->spoofchk = vport->spoofchk;
......@@ -2864,10 +2875,11 @@ static int hclge_set_vf_link_state(struct hnae3_handle *handle, int vf,
struct hclge_vport *vport = hclge_get_vport(handle);
struct hclge_dev *hdev = vport->back;
if (vf <= 0 || vf >= hdev->num_alloc_vport)
vport = hclge_get_vf_vport(hdev, vf);
if (!vport)
return -EINVAL;
hdev->vport[vf].link_state = link_state;
vport->link_state = link_state;
return 0;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册