bool enable_psmi;
struct {
unsigned int max_vfs;
+ bool admin_only_pf;
} sriov;
} config;
.enable_psmi = false,
.sriov = {
.max_vfs = XE_DEFAULT_MAX_VFS,
+ .admin_only_pf = XE_DEFAULT_ADMIN_ONLY_PF,
},
};
return len;
}
+static ssize_t sriov_admin_only_pf_show(struct config_item *item, char *page)
+{
+ struct xe_config_group_device *dev = to_xe_config_group_device(item->ci_parent);
+
+ guard(mutex)(&dev->lock);
+
+ return sprintf(page, "%s\n", str_yes_no(dev->config.sriov.admin_only_pf));
+}
+
+static ssize_t sriov_admin_only_pf_store(struct config_item *item, const char *page, size_t len)
+{
+ struct xe_config_group_device *dev = to_xe_config_group_device(item->ci_parent);
+ bool admin_only_pf;
+ int ret;
+
+ guard(mutex)(&dev->lock);
+
+ if (is_bound(dev))
+ return -EBUSY;
+
+ ret = kstrtobool(page, &admin_only_pf);
+ if (ret)
+ return ret;
+
+ dev->config.sriov.admin_only_pf = admin_only_pf;
+ return len;
+}
+
CONFIGFS_ATTR(sriov_, max_vfs);
+CONFIGFS_ATTR(sriov_, admin_only_pf);
static struct configfs_attribute *xe_config_sriov_attrs[] = {
&sriov_attr_max_vfs,
+ &sriov_attr_admin_only_pf,
NULL,
};
if (attr == &sriov_attr_max_vfs && dev->mode != XE_SRIOV_MODE_PF)
return false;
+ if (attr == &sriov_attr_admin_only_pf && dev->mode != XE_SRIOV_MODE_PF)
+ return false;
return true;
}
PRI_CUSTOM_ATTR("%llx", engines_allowed);
PRI_CUSTOM_ATTR("%d", enable_psmi);
PRI_CUSTOM_ATTR("%d", survivability_mode);
+ PRI_CUSTOM_ATTR("%u", sriov.admin_only_pf);
#undef PRI_CUSTOM_ATTR
}
}
#ifdef CONFIG_PCI_IOV
+/**
+ * xe_configfs_admin_only_pf() - Get PF's operational mode.
+ * @pdev: the &pci_dev device
+ *
+ * Find the configfs group that belongs to the PCI device and return a flag
+ * whether the PF driver should be dedicated for VFs management only.
+ *
+ * If configfs group is not present, use driver's default value.
+ *
+ * Return: true if PF driver is dedicated for VFs administration only.
+ */
+bool xe_configfs_admin_only_pf(struct pci_dev *pdev)
+{
+ struct xe_config_group_device *dev = find_xe_config_group_device(pdev);
+ bool admin_only_pf;
+
+ if (!dev)
+ return XE_DEFAULT_ADMIN_ONLY_PF;
+
+ scoped_guard(mutex, &dev->lock)
+ admin_only_pf = dev->config.sriov.admin_only_pf;
+
+ config_group_put(&dev->group);
+
+ return admin_only_pf;
+}
/**
* xe_configfs_get_max_vfs() - Get number of VFs that could be managed
* @pdev: the &pci_dev device
#include <linux/limits.h>
#include <linux/types.h>
+#include "xe_defaults.h"
#include "xe_hw_engine_types.h"
#include "xe_module.h"
const u32 **cs);
#ifdef CONFIG_PCI_IOV
unsigned int xe_configfs_get_max_vfs(struct pci_dev *pdev);
+bool xe_configfs_admin_only_pf(struct pci_dev *pdev);
#endif
#else
static inline int xe_configfs_init(void) { return 0; }
{
return xe_modparam.max_vfs;
}
+static inline bool xe_configfs_admin_only_pf(struct pci_dev *pdev)
+{
+ return XE_DEFAULT_ADMIN_ONLY_PF;
+}
#endif
#endif