mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-06 09:08:18 +02:00
core: use NMTernary for SR-IOV autoprobe-drivers
(cherry picked from commit e01a7c1154)
This commit is contained in:
parent
9deca176f8
commit
9ff5e3b2a6
3 changed files with 13 additions and 13 deletions
|
|
@ -4140,7 +4140,7 @@ device_init_static_sriov_num_vfs (NMDevice *self)
|
|||
num_vfs = _nm_utils_ascii_str_to_int64 (value, 10, 0, G_MAXINT32, -1);
|
||||
if (num_vfs >= 0) {
|
||||
nm_platform_link_set_sriov_params (nm_device_get_platform (self),
|
||||
priv->ifindex, num_vfs, -1);
|
||||
priv->ifindex, num_vfs, NM_TERNARY_DEFAULT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6206,7 +6206,7 @@ act_stage1_prepare (NMDevice *self, NMDeviceStateReason *out_failure_reason)
|
|||
nm_auto_freev NMPlatformVF **plat_vfs = NULL;
|
||||
gs_free_error GError *error = NULL;
|
||||
NMSriovVF *vf;
|
||||
int autoprobe;
|
||||
NMTernary autoprobe;
|
||||
|
||||
autoprobe = nm_setting_sriov_get_autoprobe_drivers (s_sriov);
|
||||
if (autoprobe == NM_TERNARY_DEFAULT) {
|
||||
|
|
@ -14766,7 +14766,7 @@ _set_state_full (NMDevice *self,
|
|||
if ( (s_sriov = nm_device_get_applied_setting (self, NM_TYPE_SETTING_SRIOV))
|
||||
&& priv->ifindex > 0) {
|
||||
nm_platform_link_set_sriov_params (nm_device_get_platform (self),
|
||||
priv->ifindex, 0, 1);
|
||||
priv->ifindex, 0, NM_TERNARY_TRUE);
|
||||
}
|
||||
|
||||
_cancel_activation (self);
|
||||
|
|
|
|||
|
|
@ -5737,7 +5737,7 @@ static gboolean
|
|||
link_set_sriov_params (NMPlatform *platform,
|
||||
int ifindex,
|
||||
guint num_vfs,
|
||||
int autoprobe)
|
||||
NMTernary autoprobe)
|
||||
{
|
||||
nm_auto_pop_netns NMPNetns *netns = NULL;
|
||||
nm_auto_close int dirfd = -1;
|
||||
|
|
@ -5782,7 +5782,7 @@ link_set_sriov_params (NMPlatform *platform,
|
|||
"device/sriov_drivers_autoprobe"),
|
||||
10, 0, G_MAXUINT, 0);
|
||||
if ( current_num == num_vfs
|
||||
&& (autoprobe == -1 || current_autoprobe == autoprobe))
|
||||
&& (autoprobe == NM_TERNARY_DEFAULT || current_autoprobe == autoprobe))
|
||||
return TRUE;
|
||||
|
||||
if (current_num != 0) {
|
||||
|
|
@ -5800,14 +5800,14 @@ link_set_sriov_params (NMPlatform *platform,
|
|||
if (num_vfs == 0)
|
||||
return TRUE;
|
||||
|
||||
if ( autoprobe >= 0
|
||||
if ( NM_IN_SET (autoprobe, NM_TERNARY_TRUE, NM_TERNARY_FALSE)
|
||||
&& current_autoprobe != autoprobe
|
||||
&& !nm_platform_sysctl_set (NM_PLATFORM_GET,
|
||||
NMP_SYSCTL_PATHID_NETDIR (dirfd,
|
||||
ifname,
|
||||
"device/sriov_drivers_autoprobe"),
|
||||
nm_sprintf_buf (buf, "%d", autoprobe))) {
|
||||
_LOGW ("link: couldn't set SR-IOV drivers-autoprobe to %d: %s", autoprobe, strerror (errno));
|
||||
nm_sprintf_buf (buf, "%d", (int) autoprobe))) {
|
||||
_LOGW ("link: couldn't set SR-IOV drivers-autoprobe to %d: %s", (int) autoprobe, strerror (errno));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1489,25 +1489,25 @@ nm_platform_link_supports_sriov (NMPlatform *self, int ifindex)
|
|||
* @self: platform instance
|
||||
* @ifindex: the index of the interface to change
|
||||
* @num_vfs: the number of VFs to create
|
||||
* @autoprobe: -1 to keep the current autoprobe-drivers value,
|
||||
* or {0,1} to set a new value
|
||||
* @autoprobe: the new autoprobe-drivers value (pass
|
||||
* %NM_TERNARY_DEFAULT to keep current value)
|
||||
*/
|
||||
gboolean
|
||||
nm_platform_link_set_sriov_params (NMPlatform *self,
|
||||
int ifindex,
|
||||
guint num_vfs,
|
||||
int autoprobe)
|
||||
NMTernary autoprobe)
|
||||
{
|
||||
_CHECK_SELF (self, klass, FALSE);
|
||||
|
||||
g_return_val_if_fail (ifindex > 0, FALSE);
|
||||
g_return_val_if_fail (NM_IN_SET (autoprobe, -1, 0, 1), FALSE);
|
||||
|
||||
_LOGD ("link: setting %u total VFs and autoprobe %d for %s (%d)",
|
||||
num_vfs,
|
||||
autoprobe,
|
||||
(int) autoprobe,
|
||||
nm_strquote_a (25, nm_platform_link_get_name (self, ifindex)),
|
||||
ifindex);
|
||||
|
||||
return klass->link_set_sriov_params (self, ifindex, num_vfs, autoprobe);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue