Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * num_vfs > 0; number of VFs to enable
- * num_vfs = 0; disable all VFs
- *
- * Note: SRIOV spec doesn't allow partial VF
- * disable, so it's all or none.
- */
- static ssize_t sriov_numvfs_store(struct device *dev,
- struct device_attribute *attr,
- const char *buf, size_t count)
- {
- struct pci_dev *pdev = to_pci_dev(dev);
- int ret;
- u16 num_vfs;
- ret = kstrtou16(buf, 0, &num_vfs);
- if (ret < 0)
- return ret;
- if (num_vfs > pci_sriov_get_totalvfs(pdev))
- return -ERANGE;
- if (num_vfs == pdev->sriov->num_VFs)
- return count; /* no change */
- /* is PF driver loaded w/callback */
- if (!pdev->driver || !pdev->driver->sriov_configure) {
- dev_info(&pdev->dev, "Driver doesn't support SRIOV configuration via sysfs\n");
- return -ENOSYS;
- }
- if (num_vfs == 0) {
- /* disable VFs */
- ret = pdev->driver->sriov_configure(pdev, 0);
- if (ret < 0)
- return ret;
- return count;
- }
- /* enable VFs */
- if (pdev->sriov->num_VFs) {
- dev_warn(&pdev->dev, "%d VFs already enabled. Disable before enabling %d VFs\n",
- pdev->sriov->num_VFs, num_vfs);
- return -EINVAL;
- }
- ret = pdev->driver->sriov_configure(pdev, num_vfs);
- if (ret < 0)
- return ret;
- if (ret != num_vfs)
- dev_warn(&pdev->dev, "%d VFs requested; only %d enabled\n",
- num_vfs, ret);
- return count;
- }
Advertisement
Add Comment
Please, Sign In to add comment