svn commit: r297457 - head/sys/dev/vnic
Zbigniew Bodek
zbb at FreeBSD.org
Thu Mar 31 16:44:34 UTC 2016
Author: zbb
Date: Thu Mar 31 16:44:32 2016
New Revision: 297457
URL: https://svnweb.freebsd.org/changeset/base/297457
Log:
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
Modified:
head/sys/dev/vnic/nic_main.c
Modified: head/sys/dev/vnic/nic_main.c
==============================================================================
--- head/sys/dev/vnic/nic_main.c Thu Mar 31 16:09:59 2016 (r297456)
+++ head/sys/dev/vnic/nic_main.c Thu Mar 31 16:44:32 2016 (r297457)
@@ -269,18 +269,9 @@ nicpf_iov_init(device_t dev, uint16_t nu
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
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,
}
/* 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,
device_printf(dev,
"Failed to initialize SR-IOV (error=%d)\n",
err);
- nic->num_vf_en = 0;
return (err);
}
#endif
More information about the svn-src-all
mailing list