Fix number of the enabled VFs in VNIC
nic->num_vf_en is set based on the number of the enabled LMACs. This number should not be overwritten later by any routine. Instead it should fail PCI_IOV_ADD_VF() so that available VFs with the corresponding LMACs will attach whereas other, disabled VFs will fail with the proper error code. Error signaling (due to improper number of VFs requested) is also moved from PCI_IOV_INIT() to PCI_IOV_ADD_VF(). This will be reworked when multiple queue sets are enabled but for now this is the correct behavior of the driver. Obtained from: Semihalf Sponsored by: Cavium
This commit is contained in:
parent
5a8d10d763
commit
4764669155
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=297457
@ -269,18 +269,9 @@ nicpf_iov_init(device_t dev, uint16_t num_vfs, const nvlist_t *params)
|
||||
|
||||
nic = device_get_softc(dev);
|
||||
|
||||
nic->num_vf_en = 0;
|
||||
if (num_vfs == 0)
|
||||
return (ENXIO);
|
||||
if (num_vfs > MAX_NUM_VFS_SUPPORTED)
|
||||
return (EINVAL);
|
||||
|
||||
/*
|
||||
* Just set variables here.
|
||||
* The number of VFs will be written to configuration
|
||||
* space later in PCI_ADD_VF().
|
||||
*/
|
||||
nic->num_vf_en = num_vfs;
|
||||
nic->flags |= NIC_SRIOV_ENABLED;
|
||||
|
||||
return (0);
|
||||
@ -306,6 +297,9 @@ nicpf_iov_add_vf(device_t dev, uint16_t vfnum, const nvlist_t *params)
|
||||
if ((nic->flags & NIC_SRIOV_ENABLED) == 0)
|
||||
return (ENXIO);
|
||||
|
||||
if (vfnum > (nic->num_vf_en - 1))
|
||||
return (EINVAL);
|
||||
|
||||
if (nvlist_exists_binary(params, "mac-addr") != 0) {
|
||||
mac = nvlist_get_binary(params, "mac-addr", &size);
|
||||
bgx = NIC_GET_BGX_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vfnum]);
|
||||
@ -1094,11 +1088,8 @@ static int nic_sriov_init(device_t dev, struct nicpf *nic)
|
||||
}
|
||||
/* Fix-up the number of enabled VFs */
|
||||
total_vf_cnt = pci_read_config(dev, iov_pos + PCIR_SRIOV_TOTAL_VFS, 2);
|
||||
if (total_vf_cnt < nic->num_vf_en)
|
||||
nic->num_vf_en = total_vf_cnt;
|
||||
|
||||
if (total_vf_cnt == 0)
|
||||
return (0);
|
||||
return (ENXIO);
|
||||
|
||||
/* Attach SR-IOV */
|
||||
pf_schema = pci_iov_schema_alloc_node();
|
||||
@ -1116,7 +1107,6 @@ static int nic_sriov_init(device_t dev, struct nicpf *nic)
|
||||
device_printf(dev,
|
||||
"Failed to initialize SR-IOV (error=%d)\n",
|
||||
err);
|
||||
nic->num_vf_en = 0;
|
||||
return (err);
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user