sriov: add eswitch-inline-mode and eswitch-encap-mode properties

Those are related to the eswitch mode and can be configured together.

(cherry picked from commit 8a88386e3a)
This commit is contained in:
Íñigo Huguet 2024-02-08 12:46:27 +01:00
parent dd7810c473
commit a8c4372d42
7 changed files with 157 additions and 5 deletions

View file

@ -1969,4 +1969,8 @@ global:
nm_setting_get_enum_property_type;
nm_setting_sriov_get_eswitch_mode;
nm_sriov_eswitch_mode_get_type;
nm_setting_sriov_get_eswitch_inline_mode;
nm_sriov_eswitch_inline_mode_get_type;
nm_setting_sriov_get_eswitch_encap_mode;
nm_sriov_eswitch_encap_mode_get_type;
} libnm_1_44_0;

View file

@ -2198,6 +2198,14 @@
dbus-type="i"
gprop-type="NMTernary"
/>
<property name="eswitch-encap-mode"
dbus-type="i"
gprop-type="gint"
/>
<property name="eswitch-inline-mode"
dbus-type="i"
gprop-type="gint"
/>
<property name="eswitch-mode"
dbus-type="i"
gprop-type="gint"

View file

@ -23,7 +23,9 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingSriov,
PROP_TOTAL_VFS,
PROP_VFS,
PROP_AUTOPROBE_DRIVERS,
PROP_ESWITCH_MODE, );
PROP_ESWITCH_MODE,
PROP_ESWITCH_INLINE_MODE,
PROP_ESWITCH_ENCAP_MODE, );
/**
* NMSettingSriov:
@ -38,6 +40,8 @@ struct _NMSettingSriov {
int autoprobe_drivers;
guint32 total_vfs;
int eswitch_mode;
int eswitch_inline_mode;
int eswitch_encap_mode;
};
struct _NMSettingSriovClass {
@ -857,6 +861,38 @@ nm_setting_sriov_get_eswitch_mode(NMSettingSriov *setting)
return setting->eswitch_mode;
}
/**
* nm_setting_sriov_get_eswitch_inline_mode:
* @setting: the #NMSettingSriov
*
* Returns: the value contained in the #NMSettingSriov:eswitch-inline-mode property.
*
* Since: 1.46
*/
NMSriovEswitchInlineMode
nm_setting_sriov_get_eswitch_inline_mode(NMSettingSriov *setting)
{
g_return_val_if_fail(NM_IS_SETTING_SRIOV(setting), NM_SRIOV_ESWITCH_INLINE_MODE_PRESERVE);
return setting->eswitch_inline_mode;
}
/**
* nm_setting_sriov_get_eswitch_encap_mode:
* @setting: the #NMSettingSriov
*
* Returns: the value contained in the #NMSettingSriov:eswitch-encap-mode property.
*
* Since: 1.46
*/
NMSriovEswitchEncapMode
nm_setting_sriov_get_eswitch_encap_mode(NMSettingSriov *setting)
{
g_return_val_if_fail(NM_IS_SETTING_SRIOV(setting), NM_SRIOV_ESWITCH_ENCAP_MODE_PRESERVE);
return setting->eswitch_encap_mode;
}
static int
vf_index_compare(gconstpointer a, gconstpointer b)
{
@ -1376,6 +1412,56 @@ nm_setting_sriov_class_init(NMSettingSriovClass *klass)
NMSettingSriov,
eswitch_mode);
/**
* NMSettingSriov:eswitch-inline-mode
*
* Select the eswitch inline-mode of the device. Some HWs need the VF driver to put
* part of the packet headers on the TX descriptor so the e-switch can do proper
* matching and steering.
*
* Currently it's only supported for PCI PF devices, and only if the eswitch device
* is managed from the same PCI address than the PF.
*
* If set to %NM_SRIOV_ESWITCH_INLINE_MODE_PRESERVE (default) the eswitch inline-mode
* won't be modified by NetworkManager.
*
* Since: 1.46
*/
_nm_setting_property_define_direct_enum(properties_override,
obj_properties,
NM_SETTING_SRIOV_ESWITCH_INLINE_MODE,
PROP_ESWITCH_INLINE_MODE,
NM_TYPE_SRIOV_ESWITCH_INLINE_MODE,
NM_SRIOV_ESWITCH_INLINE_MODE_PRESERVE,
NM_SETTING_PARAM_FUZZY_IGNORE,
NULL,
NMSettingSriov,
eswitch_inline_mode);
/**
* NMSettingSriov:eswitch-encap-mode
*
* Select the eswitch encapsulation support.
*
* Currently it's only supported for PCI PF devices, and only if the eswitch device
* is managed from the same PCI address than the PF.
*
* If set to %NM_SRIOV_ESWITCH_ENCAP_MODE_PRESERVE (default) the eswitch encap-mode
* won't be modified by NetworkManager.
*
* Since: 1.46
*/
_nm_setting_property_define_direct_enum(properties_override,
obj_properties,
NM_SETTING_SRIOV_ESWITCH_ENCAP_MODE,
PROP_ESWITCH_ENCAP_MODE,
NM_TYPE_SRIOV_ESWITCH_ENCAP_MODE,
NM_SRIOV_ESWITCH_ENCAP_MODE_PRESERVE,
NM_SETTING_PARAM_FUZZY_IGNORE,
NULL,
NMSettingSriov,
eswitch_encap_mode);
g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties);
_nm_setting_class_commit(setting_class,

View file

@ -26,10 +26,12 @@ G_BEGIN_DECLS
#define NM_SETTING_SRIOV_SETTING_NAME "sriov"
#define NM_SETTING_SRIOV_TOTAL_VFS "total-vfs"
#define NM_SETTING_SRIOV_VFS "vfs"
#define NM_SETTING_SRIOV_AUTOPROBE_DRIVERS "autoprobe-drivers"
#define NM_SETTING_SRIOV_ESWITCH_MODE "eswitch-mode"
#define NM_SETTING_SRIOV_TOTAL_VFS "total-vfs"
#define NM_SETTING_SRIOV_VFS "vfs"
#define NM_SETTING_SRIOV_AUTOPROBE_DRIVERS "autoprobe-drivers"
#define NM_SETTING_SRIOV_ESWITCH_MODE "eswitch-mode"
#define NM_SETTING_SRIOV_ESWITCH_INLINE_MODE "eswitch-inline-mode"
#define NM_SETTING_SRIOV_ESWITCH_ENCAP_MODE "eswitch-encap-mode"
#define NM_SRIOV_VF_ATTRIBUTE_MAC "mac"
#define NM_SRIOV_VF_ATTRIBUTE_SPOOF_CHECK "spoof-check"
@ -68,6 +70,38 @@ typedef enum {
NM_SRIOV_ESWITCH_MODE_SWITCHDEV = 1,
} NMSriovEswitchMode;
/**
* NMSriovEswitchInlineMode:
* @NM_SRIOV_ESWITCH_INLINE_MODE_PRESERVE: don't modify current inline-mode
* @NM_SRIOV_ESWITCH_INLINE_MODE_NONE: don't use inline mode
* @NM_SRIOV_ESWITCH_INLINE_MODE_LINK: L2 mode
* @NM_SRIOV_ESWITCH_INLINE_MODE_NETWORK: L3 mode
* @NM_SRIOV_ESWITCH_INLINE_MODE_TRANSPORT: L4 mode
*
* Since: 1.46
*/
typedef enum {
NM_SRIOV_ESWITCH_INLINE_MODE_PRESERVE = -1,
NM_SRIOV_ESWITCH_INLINE_MODE_NONE = 0,
NM_SRIOV_ESWITCH_INLINE_MODE_LINK = 1,
NM_SRIOV_ESWITCH_INLINE_MODE_NETWORK = 2,
NM_SRIOV_ESWITCH_INLINE_MODE_TRANSPORT = 3,
} NMSriovEswitchInlineMode;
/**
* NMSriovEswitchEncapMode:
* @NM_SRIOV_ESWITCH_ENCAP_MODE_PRESERVE: don't modify current encap-mode
* @NM_SRIOV_ESWITCH_ENCAP_MODE_NONE: disable encapsulation mode
* @NM_SRIOV_ESWITCH_ENCAP_MODE_BASIC: enable encapsulation mode
*
* Since: 1.46
*/
typedef enum {
NM_SRIOV_ESWITCH_ENCAP_MODE_PRESERVE = -1,
NM_SRIOV_ESWITCH_ENCAP_MODE_NONE = 0,
NM_SRIOV_ESWITCH_ENCAP_MODE_BASIC = 1,
} NMSriovEswitchEncapMode;
NM_AVAILABLE_IN_1_14
GType nm_setting_sriov_get_type(void);
NM_AVAILABLE_IN_1_14
@ -90,6 +124,10 @@ NM_AVAILABLE_IN_1_14
NMTernary nm_setting_sriov_get_autoprobe_drivers(NMSettingSriov *setting);
NM_AVAILABLE_IN_1_46
NMSriovEswitchMode nm_setting_sriov_get_eswitch_mode(NMSettingSriov *setting);
NM_AVAILABLE_IN_1_46
NMSriovEswitchInlineMode nm_setting_sriov_get_eswitch_inline_mode(NMSettingSriov *setting);
NM_AVAILABLE_IN_1_46
NMSriovEswitchEncapMode nm_setting_sriov_get_eswitch_encap_mode(NMSettingSriov *setting);
NM_AVAILABLE_IN_1_14
gboolean nm_sriov_vf_add_vlan(NMSriovVF *vf, guint vlan_id);

View file

@ -7366,6 +7366,12 @@ static const NMMetaPropertyInfo *const property_infos_SRIOV[] = {
PROPERTY_INFO_WITH_DESC (NM_SETTING_SRIOV_ESWITCH_MODE,
.property_type = &_pt_gobject_enum,
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_SRIOV_ESWITCH_INLINE_MODE,
.property_type = &_pt_gobject_enum,
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_SRIOV_ESWITCH_ENCAP_MODE,
.property_type = &_pt_gobject_enum,
),
NULL
};

View file

@ -310,6 +310,8 @@
#define DESCRIBE_DOC_NM_SETTING_SERIAL_SEND_DELAY N_("Time to delay between each byte sent to the modem, in microseconds.")
#define DESCRIBE_DOC_NM_SETTING_SERIAL_STOPBITS N_("Number of stop bits for communication on the serial port. Either 1 or 2. The 1 in \"8n1\" for example.")
#define DESCRIBE_DOC_NM_SETTING_SRIOV_AUTOPROBE_DRIVERS N_("Whether to autoprobe virtual functions by a compatible driver. If set to \"true\" (1), the kernel will try to bind VFs to a compatible driver and if this succeeds a new network interface will be instantiated for each VF. If set to \"false\" (0), VFs will not be claimed and no network interfaces will be created for them. When set to \"default\" (-1), the global default is used; in case the global default is unspecified it is assumed to be \"true\" (1).")
#define DESCRIBE_DOC_NM_SETTING_SRIOV_ESWITCH_ENCAP_MODE N_("Select the eswitch encapsulation support. Currently it's only supported for PCI PF devices, and only if the eswitch device is managed from the same PCI address than the PF. If set to \"preserve\" (-1) (default) the eswitch encap-mode won't be modified by NetworkManager.")
#define DESCRIBE_DOC_NM_SETTING_SRIOV_ESWITCH_INLINE_MODE N_("Select the eswitch inline-mode of the device. Some HWs need the VF driver to put part of the packet headers on the TX descriptor so the e-switch can do proper matching and steering. Currently it's only supported for PCI PF devices, and only if the eswitch device is managed from the same PCI address than the PF. If set to \"preserve\" (-1) (default) the eswitch inline-mode won't be modified by NetworkManager.")
#define DESCRIBE_DOC_NM_SETTING_SRIOV_ESWITCH_MODE N_("Select the eswitch mode of the device. Currently it's only supported for PCI PF devices, and only if the eswitch device is managed from the same PCI address than the PF. If set to \"preserve\" (-1) (default) the eswitch mode won't be modified by NetworkManager.")
#define DESCRIBE_DOC_NM_SETTING_SRIOV_TOTAL_VFS N_("The total number of virtual functions to create. Note that when the sriov setting is present NetworkManager enforces the number of virtual functions on the interface (also when it is zero) during activation and resets it upon deactivation. To prevent any changes to SR-IOV parameters don't add a sriov setting to the connection.")
#define DESCRIBE_DOC_NM_SETTING_SRIOV_VFS N_("Array of virtual function descriptors. Each VF descriptor is a dictionary mapping attribute names to GVariant values. The 'index' entry is mandatory for each VF. When represented as string a VF is in the form: \"INDEX [ATTR=VALUE[ ATTR=VALUE]...]\". for example: \"2 mac=00:11:22:33:44:55 spoof-check=true\". Multiple VFs can be specified using a comma as separator. Currently, the following attributes are supported: mac, spoof-check, trust, min-tx-rate, max-tx-rate, vlans. The \"vlans\" attribute is represented as a semicolon-separated list of VLAN descriptors, where each descriptor has the form \"ID[.PRIORITY[.PROTO]]\". PROTO can be either 'q' for 802.1Q (the default) or 'ad' for 802.1ad.")

View file

@ -1824,6 +1824,14 @@
nmcli-description="Select the eswitch mode of the device. Currently it&apos;s only supported for PCI PF devices, and only if the eswitch device is managed from the same PCI address than the PF. If set to &quot;preserve&quot; (-1) (default) the eswitch mode won&apos;t be modified by NetworkManager."
format="choice (NMSriovEswitchMode)"
values="preserve (-1), legacy (0), switchdev (1)" />
<property name="eswitch-inline-mode"
nmcli-description="Select the eswitch inline-mode of the device. Some HWs need the VF driver to put part of the packet headers on the TX descriptor so the e-switch can do proper matching and steering. Currently it&apos;s only supported for PCI PF devices, and only if the eswitch device is managed from the same PCI address than the PF. If set to &quot;preserve&quot; (-1) (default) the eswitch inline-mode won&apos;t be modified by NetworkManager."
format="choice (NMSriovEswitchInlineMode)"
values="preserve (-1), none (0), link (1), network (2), transport (3)" />
<property name="eswitch-encap-mode"
nmcli-description="Select the eswitch encapsulation support. Currently it&apos;s only supported for PCI PF devices, and only if the eswitch device is managed from the same PCI address than the PF. If set to &quot;preserve&quot; (-1) (default) the eswitch encap-mode won&apos;t be modified by NetworkManager."
format="choice (NMSriovEswitchEncapMode)"
values="preserve (-1), none (0), basic (1)" />
</setting>
<setting name="tc" >
<property name="qdiscs"