mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-07 11:58:12 +02:00
device: extract sriov platform vf generation to separate function
(cherry picked from commit 588a69cd1b)
This commit is contained in:
parent
c0048e0d26
commit
b2d8f60c49
1 changed files with 43 additions and 18 deletions
|
|
@ -10394,6 +10394,43 @@ sriov_params_cb(GError *error, gpointer user_data)
|
||||||
nm_device_activate_schedule_stage1_device_prepare(self, FALSE);
|
nm_device_activate_schedule_stage1_device_prepare(self, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
sriov_gen_platform_vfs(NMDevice *self,
|
||||||
|
NMSettingSriov *s_sriov,
|
||||||
|
NMPlatformVF ***plat_vfs_out,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
nm_auto_freev NMPlatformVF **plat_vfs = NULL;
|
||||||
|
guint num;
|
||||||
|
|
||||||
|
nm_assert(s_sriov);
|
||||||
|
nm_assert(plat_vfs_out && !*plat_vfs_out);
|
||||||
|
|
||||||
|
num = nm_setting_sriov_get_num_vfs(s_sriov);
|
||||||
|
plat_vfs = g_new0(NMPlatformVF *, num + 1);
|
||||||
|
|
||||||
|
for (int i = 0; i < num; i++) {
|
||||||
|
NMSriovVF *vf = nm_setting_sriov_get_vf(s_sriov, i);
|
||||||
|
gs_free_error GError *local = NULL;
|
||||||
|
|
||||||
|
plat_vfs[i] = sriov_vf_config_to_platform(self, vf, &local);
|
||||||
|
|
||||||
|
if (!plat_vfs[i]) {
|
||||||
|
g_set_error(error,
|
||||||
|
local->domain,
|
||||||
|
local->code,
|
||||||
|
"VF '%s' is invalid: %s",
|
||||||
|
nm_utils_sriov_vf_to_str(vf, FALSE, NULL),
|
||||||
|
local->message);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*plat_vfs_out = g_steal_pointer(&plat_vfs);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* activate_stage1_device_prepare
|
* activate_stage1_device_prepare
|
||||||
*
|
*
|
||||||
|
|
@ -10440,10 +10477,7 @@ activate_stage1_device_prepare(NMDevice *self)
|
||||||
if (s_sriov && nm_device_has_capability(self, NM_DEVICE_CAP_SRIOV)) {
|
if (s_sriov && nm_device_has_capability(self, NM_DEVICE_CAP_SRIOV)) {
|
||||||
nm_auto_freev NMPlatformVF **plat_vfs = NULL;
|
nm_auto_freev NMPlatformVF **plat_vfs = NULL;
|
||||||
gs_free_error GError *error = NULL;
|
gs_free_error GError *error = NULL;
|
||||||
NMSriovVF *vf;
|
|
||||||
NMTernary autoprobe;
|
NMTernary autoprobe;
|
||||||
guint num;
|
|
||||||
guint i;
|
|
||||||
|
|
||||||
autoprobe = nm_setting_sriov_get_autoprobe_drivers(s_sriov);
|
autoprobe = nm_setting_sriov_get_autoprobe_drivers(s_sriov);
|
||||||
if (autoprobe == NM_TERNARY_DEFAULT) {
|
if (autoprobe == NM_TERNARY_DEFAULT) {
|
||||||
|
|
@ -10456,21 +10490,12 @@ activate_stage1_device_prepare(NMDevice *self)
|
||||||
NM_OPTION_BOOL_TRUE);
|
NM_OPTION_BOOL_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
num = nm_setting_sriov_get_num_vfs(s_sriov);
|
if (!sriov_gen_platform_vfs(self, s_sriov, &plat_vfs, &error)) {
|
||||||
plat_vfs = g_new0(NMPlatformVF *, num + 1);
|
_LOGE(LOGD_DEVICE, "cannot parse the VF list: %s", error->message);
|
||||||
for (i = 0; i < num; i++) {
|
nm_device_state_changed(self,
|
||||||
vf = nm_setting_sriov_get_vf(s_sriov, i);
|
NM_DEVICE_STATE_FAILED,
|
||||||
plat_vfs[i] = sriov_vf_config_to_platform(self, vf, &error);
|
NM_DEVICE_STATE_REASON_SRIOV_CONFIGURATION_FAILED);
|
||||||
if (!plat_vfs[i]) {
|
return;
|
||||||
_LOGE(LOGD_DEVICE,
|
|
||||||
"failed to apply SR-IOV VF '%s': %s",
|
|
||||||
nm_utils_sriov_vf_to_str(vf, FALSE, NULL),
|
|
||||||
error->message);
|
|
||||||
nm_device_state_changed(self,
|
|
||||||
NM_DEVICE_STATE_FAILED,
|
|
||||||
NM_DEVICE_STATE_REASON_SRIOV_CONFIGURATION_FAILED);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* When changing the number of VFs the kernel can block
|
/* When changing the number of VFs the kernel can block
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue