Beniamino Galvani 2023-01-13 10:33:26 +01:00
parent 4721f83003
commit f930d55fea
8 changed files with 164 additions and 7 deletions

View file

@ -867,8 +867,6 @@ _insert_interface(json_t *params,
const char *type = NULL;
NMSettingOvsInterface *s_ovs_iface;
NMSettingOvsDpdk *s_ovs_dpdk;
const char *devargs;
guint32 n_rxq;
char sbuf[64];
json_t *dpdk_array;
NMSettingOvsPatch *s_ovs_patch;
@ -899,8 +897,15 @@ _insert_interface(json_t *params,
s_ovs_patch = nm_connection_get_setting_ovs_patch(interface);
if (s_ovs_dpdk) {
devargs = nm_setting_ovs_dpdk_get_devargs(s_ovs_dpdk);
n_rxq = nm_setting_ovs_dpdk_get_n_rxq(s_ovs_dpdk);
const char *devargs;
guint32 n_rxq;
guint32 n_rxq_desc;
guint32 n_txq_desc;
devargs = nm_setting_ovs_dpdk_get_devargs(s_ovs_dpdk);
n_rxq = nm_setting_ovs_dpdk_get_n_rxq(s_ovs_dpdk);
n_rxq_desc = nm_setting_ovs_dpdk_get_n_rxq_desc(s_ovs_dpdk);
n_txq_desc = nm_setting_ovs_dpdk_get_n_txq_desc(s_ovs_dpdk);
dpdk_array = json_array();
@ -911,6 +916,16 @@ _insert_interface(json_t *params,
json_array_append_new(dpdk_array,
json_pack("[s,s]", "n_rxq", nm_sprintf_buf(sbuf, "%u", n_rxq)));
}
if (n_rxq_desc != 0) {
json_array_append_new(
dpdk_array,
json_pack("[s,s]", "n_rxq_desc", nm_sprintf_buf(sbuf, "%u", n_rxq_desc)));
}
if (n_txq_desc != 0) {
json_array_append_new(
dpdk_array,
json_pack("[s,s]", "n_txq_desc", nm_sprintf_buf(sbuf, "%u", n_txq_desc)));
}
json_array_append_new(options, dpdk_array);

View file

@ -1901,6 +1901,8 @@ global:
nm_setting_loopback_get_mtu;
nm_setting_loopback_get_type;
nm_setting_loopback_new;
nm_setting_ovs_dpdk_get_n_rxq_desc;
nm_setting_ovs_dpdk_get_n_txq_desc;
nm_setting_ovs_interface_get_ofport_request;
nm_setting_ovs_other_config_get_data;
nm_setting_ovs_other_config_get_data_keys;

View file

@ -1858,6 +1858,14 @@
dbus-type="u"
gprop-type="guint"
/>
<property name="n-rxq-desc"
dbus-type="u"
gprop-type="guint"
/>
<property name="n-txq-desc"
dbus-type="u"
gprop-type="guint"
/>
</setting>
<setting name="ovs-external-ids"
gtype="NMSettingOvsExternalIDs"

View file

@ -22,7 +22,7 @@
/*****************************************************************************/
NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_DEVARGS, PROP_N_RXQ, );
NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_DEVARGS, PROP_N_RXQ, PROP_N_RXQ_DESC, PROP_N_TXQ_DESC, );
/**
* NMSettingOvsDpdk:
@ -34,6 +34,8 @@ struct _NMSettingOvsDpdk {
char *devargs;
guint32 n_rxq;
guint32 n_rxq_desc;
guint32 n_txq_desc;
};
struct _NMSettingOvsDpdkClass {
@ -76,6 +78,72 @@ nm_setting_ovs_dpdk_get_n_rxq(NMSettingOvsDpdk *self)
return self->n_rxq;
}
/**
* nm_setting_ovs_dpdk_get_n_rxq_desc:
* @self: the #NMSettingOvsDpdk
*
* Returns: the #NMSettingOvsDpdk:n-rxq-desc property of the setting
*
* Since: 1.42
**/
guint32
nm_setting_ovs_dpdk_get_n_rxq_desc(NMSettingOvsDpdk *self)
{
g_return_val_if_fail(NM_IS_SETTING_OVS_DPDK(self), 0);
return self->n_rxq_desc;
}
/**
* nm_setting_ovs_dpdk_get_n_txq_desc:
* @self: the #NMSettingOvsDpdk
*
* Returns: the #NMSettingOvsDpdk:n-txq-desc property of the setting
*
* Since: 1.42
**/
guint32
nm_setting_ovs_dpdk_get_n_txq_desc(NMSettingOvsDpdk *self)
{
g_return_val_if_fail(NM_IS_SETTING_OVS_DPDK(self), 0);
return self->n_txq_desc;
}
/*****************************************************************************/
static gboolean
verify(NMSetting *setting, NMConnection *connection, GError **error)
{
NMSettingOvsDpdk *self = NM_SETTING_OVS_DPDK(setting);
if (self->n_rxq_desc != 0 && !nm_utils_is_power_of_two(self->n_rxq_desc)) {
g_set_error(error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_INVALID_PROPERTY,
_("must be a power of two"));
g_prefix_error(error,
"%s.%s: ",
NM_SETTING_OVS_DPDK_SETTING_NAME,
NM_SETTING_OVS_DPDK_N_RXQ_DESC);
return FALSE;
}
if (self->n_txq_desc != 0 && !nm_utils_is_power_of_two(self->n_txq_desc)) {
g_set_error(error,
NM_CONNECTION_ERROR,
NM_CONNECTION_ERROR_INVALID_PROPERTY,
_("must be a power of two"));
g_prefix_error(error,
"%s.%s: ",
NM_SETTING_OVS_DPDK_SETTING_NAME,
NM_SETTING_OVS_DPDK_N_TXQ_DESC);
return FALSE;
}
return TRUE;
}
/*****************************************************************************/
static void
@ -107,6 +175,8 @@ nm_setting_ovs_dpdk_class_init(NMSettingOvsDpdkClass *klass)
object_class->get_property = _nm_setting_property_get_property_direct;
object_class->set_property = _nm_setting_property_set_property_direct;
setting_class->verify = verify;
/**
* NMSettingOvsDpdk:devargs:
*
@ -142,6 +212,50 @@ nm_setting_ovs_dpdk_class_init(NMSettingOvsDpdkClass *klass)
NMSettingOvsDpdk,
n_rxq);
/**
* NMSettingOvsDpdk:n-rxq-desc:
*
* The rx queue size (number of rx descriptors) for DPDK ports.
* Must be zero or a power of 2 between 1 and 4096, and supported
* by the hardware. Defaults to zero which means to leave the
* parameter in OVS unspecified and effectively configures 2048
* descriptors.
*
* Since: 1.42
**/
_nm_setting_property_define_direct_uint32(properties_override,
obj_properties,
NM_SETTING_OVS_DPDK_N_RXQ_DESC,
PROP_N_RXQ_DESC,
0,
4096,
0,
NM_SETTING_PARAM_INFERRABLE,
NMSettingOvsDpdk,
n_rxq_desc);
/**
* NMSettingOvsDpdk:n-txq-desc:
*
* The tx queue size (number of tx descriptors) for DPDK ports.
* Must be zero or a power of 2 between 1 and 4096, and supported
* by the hardware. Defaults to zero which means to leave the
* parameter in OVS unspecified and effectively configures 2048
* descriptors.
*
* Since: 1.42
**/
_nm_setting_property_define_direct_uint32(properties_override,
obj_properties,
NM_SETTING_OVS_DPDK_N_TXQ_DESC,
PROP_N_TXQ_DESC,
0,
4096,
0,
NM_SETTING_PARAM_INFERRABLE,
NMSettingOvsDpdk,
n_txq_desc);
g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties);
_nm_setting_class_commit(setting_class,

View file

@ -27,8 +27,10 @@ G_BEGIN_DECLS
#define NM_SETTING_OVS_DPDK_SETTING_NAME "ovs-dpdk"
#define NM_SETTING_OVS_DPDK_DEVARGS "devargs"
#define NM_SETTING_OVS_DPDK_N_RXQ "n-rxq"
#define NM_SETTING_OVS_DPDK_DEVARGS "devargs"
#define NM_SETTING_OVS_DPDK_N_RXQ "n-rxq"
#define NM_SETTING_OVS_DPDK_N_RXQ_DESC "n-rxq-desc"
#define NM_SETTING_OVS_DPDK_N_TXQ_DESC "n-txq-desc"
typedef struct _NMSettingOvsDpdkClass NMSettingOvsDpdkClass;
@ -41,6 +43,10 @@ NM_AVAILABLE_IN_1_20
const char *nm_setting_ovs_dpdk_get_devargs(NMSettingOvsDpdk *self);
NM_AVAILABLE_IN_1_36
guint32 nm_setting_ovs_dpdk_get_n_rxq(NMSettingOvsDpdk *self);
NM_AVAILABLE_IN_1_42
guint32 nm_setting_ovs_dpdk_get_n_rxq_desc(NMSettingOvsDpdk *self);
NM_AVAILABLE_IN_1_42
guint32 nm_setting_ovs_dpdk_get_n_txq_desc(NMSettingOvsDpdk *self);
G_END_DECLS

View file

@ -6859,6 +6859,12 @@ static const NMMetaPropertyInfo *const property_infos_OVS_DPDK[] = {
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_OVS_DPDK_N_RXQ,
.property_type = &_pt_gobject_int,
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_OVS_DPDK_N_RXQ_DESC,
.property_type = &_pt_gobject_int,
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_OVS_DPDK_N_TXQ_DESC,
.property_type = &_pt_gobject_int,
),
NULL
};

View file

@ -255,6 +255,8 @@
#define DESCRIBE_DOC_NM_SETTING_OVS_BRIDGE_STP_ENABLE N_("Enable or disable STP.")
#define DESCRIBE_DOC_NM_SETTING_OVS_DPDK_DEVARGS N_("Open vSwitch DPDK device arguments.")
#define DESCRIBE_DOC_NM_SETTING_OVS_DPDK_N_RXQ N_("Open vSwitch DPDK number of rx queues. Defaults to zero which means to leave the parameter in OVS unspecified and effectively configures one queue.")
#define DESCRIBE_DOC_NM_SETTING_OVS_DPDK_N_RXQ_DESC N_("The rx queue size (number of rx descriptors) for DPDK ports. Must be zero or a power of 2 between 1 and 4096, and supported by the hardware. Defaults to zero which means to leave the parameter in OVS unspecified and effectively configures 2048 descriptors.")
#define DESCRIBE_DOC_NM_SETTING_OVS_DPDK_N_TXQ_DESC N_("The tx queue size (number of tx descriptors) for DPDK ports. Must be zero or a power of 2 between 1 and 4096, and supported by the hardware. Defaults to zero which means to leave the parameter in OVS unspecified and effectively configures 2048 descriptors.")
#define DESCRIBE_DOC_NM_SETTING_OVS_INTERFACE_OFPORT_REQUEST N_("Open vSwitch openflow port number. Defaults to zero which means that port number will not be specified and it will be chosen randomly by ovs. OpenFlow ports are the network interfaces for passing packets between OpenFlow processing and the rest of the network. OpenFlow switches connect logically to each other via their OpenFlow ports.")
#define DESCRIBE_DOC_NM_SETTING_OVS_INTERFACE_TYPE N_("The interface type. Either \"internal\", \"system\", \"patch\", \"dpdk\", or empty.")
#define DESCRIBE_DOC_NM_SETTING_OVS_PATCH_PEER N_("Specifies the name of the interface for the other side of the patch. The patch on the other side must also set this interface as peer.")

View file

@ -839,6 +839,10 @@
description="Open vSwitch DPDK device arguments." />
<property name="n-rxq"
description="Open vSwitch DPDK number of rx queues. Defaults to zero which means to leave the parameter in OVS unspecified and effectively configures one queue." />
<property name="n-rxq-desc"
description="The rx queue size (number of rx descriptors) for DPDK ports. Must be zero or a power of 2 between 1 and 4096, and supported by the hardware. Defaults to zero which means to leave the parameter in OVS unspecified and effectively configures 2048 descriptors." />
<property name="n-txq-desc"
description="The tx queue size (number of tx descriptors) for DPDK ports. Must be zero or a power of 2 between 1 and 4096, and supported by the hardware. Defaults to zero which means to leave the parameter in OVS unspecified and effectively configures 2048 descriptors." />
</setting>
<setting name="ovs-external-ids" >
</setting>