Commit 32975b6a authored by Beniamino Galvani's avatar Beniamino Galvani

core: allow setting SR-IOV num_vfs

parent f13fd452
......@@ -855,6 +855,16 @@ unmanaged=1
</para>
</listitem>
</varlistentry>
<varlistentry id="sriov-num-vfs">
<term><varname>sriov-num-vfs</varname></term>
<listitem>
<para>
Specify the number of virtual functions (VF) to enable
for a PCI physical device that supports single-root I/O
virtualization (SR-IOV).
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect2>
......
......@@ -2814,6 +2814,27 @@ update_device_from_platform_link (NMDevice *self, const NMPlatformLink *plink)
}
}
static void
device_init_sriov_num_vfs (NMDevice *self)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
gs_free char *value = NULL;
int num_vfs;
if ( priv->ifindex > 0
&& nm_device_has_capability (self, NM_DEVICE_CAP_SRIOV)) {
value = nm_config_data_get_device_config (NM_CONFIG_GET_DATA,
"sriov-num-vfs",
self,
NULL);
num_vfs = _nm_utils_ascii_str_to_int64 (value, 10, 0, G_MAXINT32, -1);
if (num_vfs >= 0) {
nm_platform_link_set_sriov_num_vfs (nm_device_get_platform (self),
priv->ifindex, num_vfs);
}
}
}
static void
config_changed_update_ignore_carrier (NMConfig *config,
NMConfigData *config_data,
......@@ -2978,6 +2999,8 @@ realize_start_setup (NMDevice *self,
priv->carrier = TRUE;
}
device_init_sriov_num_vfs (self);
nm_assert (!priv->stats.timeout_id);
real_rate = _stats_refresh_rate_real (priv->stats.refresh_rate_ms);
if (real_rate)
......
......@@ -171,6 +171,8 @@ const char *nm_config_data_get_rc_manager (const NMConfigData *self);
gboolean nm_config_data_get_ignore_carrier (const NMConfigData *self, NMDevice *device);
gboolean nm_config_data_get_assume_ipv6ll_only (const NMConfigData *self, NMDevice *device);
int nm_config_data_get_sriov_num_vfs (const NMConfigData *self, NMDevice *device);
NMGlobalDnsConfig *nm_config_data_get_global_dns_config (const NMConfigData *self);
char *nm_config_data_get_connection_default (const NMConfigData *self,
......
......@@ -75,6 +75,7 @@
#define NM_CONFIG_KEYFILE_KEY_AUDIT "audit"
#define NM_CONFIG_KEYFILE_KEY_DEVICE_IGNORE_CARRIER "ignore-carrier"
#define NM_CONFIG_KEYFILE_KEY_DEVICE_SRIOV_NUM_VFS "sriov-num-vfs"
#define NM_CONFIG_KEYFILE_KEYPREFIX_WAS ".was."
#define NM_CONFIG_KEYFILE_KEYPREFIX_SET ".set."
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment