mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-21 18:00:20 +01:00
cli: add support for configuring SR-IOV
This commit is contained in:
parent
a9b4532fa7
commit
a2f12994b7
4 changed files with 112 additions and 1 deletions
|
|
@ -769,7 +769,8 @@ const NmcMetaGenericInfo *const metagen_con_active_vpn[_NMC_GENERIC_INFO_TYPE_CO
|
|||
NM_SETTING_WPAN_SETTING_NAME","\
|
||||
NM_SETTING_6LOWPAN_SETTING_NAME","\
|
||||
NM_SETTING_PROXY_SETTING_NAME"," \
|
||||
NM_SETTING_TC_CONFIG_SETTING_NAME
|
||||
NM_SETTING_TC_CONFIG_SETTING_NAME"," \
|
||||
NM_SETTING_SRIOV_SETTING_NAME
|
||||
// NM_SETTING_DUMMY_SETTING_NAME
|
||||
// NM_SETTING_WIMAX_SETTING_NAME
|
||||
|
||||
|
|
|
|||
|
|
@ -3774,6 +3774,37 @@ _validate_fcn_proxy_pac_script (const char *value, char **out_to_free, GError **
|
|||
RETURN_STR_TO_FREE (script);
|
||||
}
|
||||
|
||||
static gconstpointer
|
||||
_get_fcn_sriov_vfs (ARGS_GET_FCN)
|
||||
{
|
||||
NMSettingSriov *s_sriov = NM_SETTING_SRIOV (setting);
|
||||
GString *printable;
|
||||
guint num_vfs, i;
|
||||
NMSriovVF *vf;
|
||||
char *str;
|
||||
|
||||
RETURN_UNSUPPORTED_GET_TYPE ();
|
||||
|
||||
printable = g_string_new (NULL);
|
||||
|
||||
num_vfs = nm_setting_sriov_get_num_vfs (s_sriov);
|
||||
for (i = 0; i < num_vfs; i++) {
|
||||
vf = nm_setting_sriov_get_vf (s_sriov, i);
|
||||
|
||||
if (printable->len > 0)
|
||||
g_string_append (printable, ", ");
|
||||
|
||||
str = nm_utils_sriov_vf_to_str (vf, FALSE, NULL);
|
||||
if (str) {
|
||||
g_string_append (printable, str);
|
||||
g_free (str);
|
||||
}
|
||||
}
|
||||
|
||||
NM_SET_OUT (out_is_default, num_vfs == 0);
|
||||
RETURN_STR_TO_FREE (g_string_free (printable, FALSE));
|
||||
}
|
||||
|
||||
static gconstpointer
|
||||
_get_fcn_tc_config_qdiscs (ARGS_GET_FCN)
|
||||
{
|
||||
|
|
@ -3805,6 +3836,28 @@ _get_fcn_tc_config_qdiscs (ARGS_GET_FCN)
|
|||
RETURN_STR_TO_FREE (g_string_free (printable, FALSE));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_set_fcn_sriov_vfs (ARGS_SET_FCN)
|
||||
{
|
||||
gs_free const char **strv = NULL;
|
||||
const char *const*iter;
|
||||
NMSriovVF *vf;
|
||||
GError *local = NULL;
|
||||
|
||||
strv = nm_utils_strsplit_set (value, ",");
|
||||
for (iter = strv; strv && *iter; iter++) {
|
||||
vf = nm_utils_sriov_vf_from_str (*iter, &local);
|
||||
if (!vf) {
|
||||
g_set_error (error, 1, 0, "%s. %s", local->message,
|
||||
_("The valid syntax is: vf [attribute=value]... [,vf [attribute=value]...]"));
|
||||
return FALSE;
|
||||
}
|
||||
nm_setting_sriov_add_vf (NM_SETTING_SRIOV (setting), vf);
|
||||
nm_sriov_vf_unref (vf);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_set_fcn_tc_config_qdiscs (ARGS_SET_FCN)
|
||||
{
|
||||
|
|
@ -3827,6 +3880,34 @@ _set_fcn_tc_config_qdiscs (ARGS_SET_FCN)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_validate_and_remove_sriov_vf (NMSettingSriov *setting,
|
||||
const char *value,
|
||||
GError **error)
|
||||
{
|
||||
NMSriovVF *vf;
|
||||
gboolean ret;
|
||||
|
||||
vf = nm_utils_sriov_vf_from_str (value, error);
|
||||
if (!vf)
|
||||
return FALSE;
|
||||
|
||||
ret = nm_setting_sriov_remove_vf_by_index (setting, nm_sriov_vf_get_index (vf));
|
||||
if (!ret) {
|
||||
g_set_error (error, 1, 0,
|
||||
_("the property doesn't contain vf with index %u"),
|
||||
nm_sriov_vf_get_index (vf));
|
||||
}
|
||||
nm_sriov_vf_unref (vf);
|
||||
return ret;
|
||||
}
|
||||
DEFINE_REMOVER_INDEX_OR_VALUE (_remove_fcn_sriov_vfs,
|
||||
NM_SETTING_SRIOV,
|
||||
nm_setting_sriov_get_num_vfs,
|
||||
nm_setting_sriov_remove_vf,
|
||||
_validate_and_remove_sriov_vf)
|
||||
|
||||
|
||||
static gboolean
|
||||
_validate_and_remove_tc_qdisc (NMSettingTCConfig *setting,
|
||||
const char *value,
|
||||
|
|
@ -6831,6 +6912,25 @@ static const NMMetaPropertyInfo *const property_infos_SERIAL[] = {
|
|||
NULL
|
||||
};
|
||||
|
||||
#undef _CURRENT_NM_META_SETTING_TYPE
|
||||
#define _CURRENT_NM_META_SETTING_TYPE NM_META_SETTING_TYPE_SRIOV
|
||||
static const NMMetaPropertyInfo *const property_infos_SRIOV[] = {
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_SRIOV_TOTAL_VFS,
|
||||
.property_type = &_pt_gobject_int,
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_SRIOV_VFS,
|
||||
.property_type = DEFINE_PROPERTY_TYPE (
|
||||
.get_fcn = _get_fcn_sriov_vfs,
|
||||
.set_fcn = _set_fcn_sriov_vfs,
|
||||
.remove_fcn = _remove_fcn_sriov_vfs,
|
||||
),
|
||||
),
|
||||
PROPERTY_INFO_WITH_DESC (NM_SETTING_SRIOV_AUTOPROBE_DRIVERS,
|
||||
.property_type = &_pt_gobject_enum,
|
||||
),
|
||||
NULL
|
||||
};
|
||||
|
||||
#undef _CURRENT_NM_META_SETTING_TYPE
|
||||
#define _CURRENT_NM_META_SETTING_TYPE NM_META_SETTING_TYPE_TUN
|
||||
static const NMMetaPropertyInfo *const property_infos_TUN[] = {
|
||||
|
|
@ -7649,6 +7749,7 @@ _setting_init_fcn_wireless (ARGS_SETTING_INIT_FCN)
|
|||
#define SETTING_PRETTY_NAME_PPPOE N_("PPPoE")
|
||||
#define SETTING_PRETTY_NAME_PROXY N_("Proxy")
|
||||
#define SETTING_PRETTY_NAME_SERIAL N_("Serial settings")
|
||||
#define SETTING_PRETTY_NAME_SRIOV N_("SR-IOV settings")
|
||||
#define SETTING_PRETTY_NAME_TC_CONFIG N_("Traffic controls")
|
||||
#define SETTING_PRETTY_NAME_TEAM N_("Team device")
|
||||
#define SETTING_PRETTY_NAME_TEAM_PORT N_("Team port")
|
||||
|
|
@ -7765,6 +7866,7 @@ const NMMetaSettingInfoEditor nm_meta_setting_infos_editor[] = {
|
|||
.valid_parts = NM_META_SETTING_VALID_PARTS (
|
||||
NM_META_SETTING_VALID_PART_ITEM (CONNECTION, TRUE),
|
||||
NM_META_SETTING_VALID_PART_ITEM (INFINIBAND, TRUE),
|
||||
NM_META_SETTING_VALID_PART_ITEM (SRIOV, FALSE),
|
||||
),
|
||||
.setting_init_fcn = _setting_init_fcn_infiniband,
|
||||
),
|
||||
|
|
@ -7844,6 +7946,7 @@ const NMMetaSettingInfoEditor nm_meta_setting_infos_editor[] = {
|
|||
.setting_init_fcn = _setting_init_fcn_proxy,
|
||||
),
|
||||
SETTING_INFO (SERIAL),
|
||||
SETTING_INFO (SRIOV),
|
||||
SETTING_INFO (TC_CONFIG),
|
||||
SETTING_INFO (TEAM,
|
||||
.valid_parts = NM_META_SETTING_VALID_PARTS (
|
||||
|
|
@ -7896,6 +7999,7 @@ const NMMetaSettingInfoEditor nm_meta_setting_infos_editor[] = {
|
|||
NM_META_SETTING_VALID_PART_ITEM (WIRED, TRUE),
|
||||
NM_META_SETTING_VALID_PART_ITEM (802_1X, FALSE),
|
||||
NM_META_SETTING_VALID_PART_ITEM (DCB, FALSE),
|
||||
NM_META_SETTING_VALID_PART_ITEM (SRIOV, FALSE),
|
||||
),
|
||||
),
|
||||
SETTING_INFO (WIRELESS,
|
||||
|
|
|
|||
|
|
@ -287,6 +287,11 @@ const NMMetaSettingInfo nm_meta_setting_infos[] = {
|
|||
.setting_name = NM_SETTING_SERIAL_SETTING_NAME,
|
||||
.get_setting_gtype = nm_setting_serial_get_type,
|
||||
},
|
||||
[NM_META_SETTING_TYPE_SRIOV] = {
|
||||
.meta_type = NM_META_SETTING_TYPE_SRIOV,
|
||||
.setting_name = NM_SETTING_SRIOV_SETTING_NAME,
|
||||
.get_setting_gtype = nm_setting_sriov_get_type,
|
||||
},
|
||||
[NM_META_SETTING_TYPE_TC_CONFIG] = {
|
||||
.meta_type = NM_META_SETTING_TYPE_TC_CONFIG,
|
||||
.setting_name = NM_SETTING_TC_CONFIG_SETTING_NAME,
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ typedef enum {
|
|||
NM_META_SETTING_TYPE_PPPOE,
|
||||
NM_META_SETTING_TYPE_PROXY,
|
||||
NM_META_SETTING_TYPE_SERIAL,
|
||||
NM_META_SETTING_TYPE_SRIOV,
|
||||
NM_META_SETTING_TYPE_TC_CONFIG,
|
||||
NM_META_SETTING_TYPE_TEAM,
|
||||
NM_META_SETTING_TYPE_TEAM_PORT,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue