openvswitch: Add ovs-dpdk n_rxq property

https://bugzilla.redhat.com/show_bug.cgi?id=2001563
This commit is contained in:
Ana Cabral 2022-01-05 09:58:22 +01:00 committed by Ana Cabral
parent 29cf10ec24
commit 74c08c7084
7 changed files with 85 additions and 15 deletions

View file

@ -752,8 +752,11 @@ _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;
char *dpdk_devargs;
json_t *options = json_array();
json_t *row;
guint32 mtu = 0;
@ -778,11 +781,21 @@ _insert_interface(json_t *params,
s_ovs_patch = nm_connection_get_setting_ovs_patch(interface);
if (s_ovs_dpdk) {
dpdk_devargs = nm_setting_ovs_dpdk_get_devargs(s_ovs_dpdk);
if (dpdk_devargs)
json_array_append_new(options, json_pack("[[s, s]]", "dpdk-devargs", dpdk_devargs));
else
json_array_append_new(options, json_array());
devargs = nm_setting_ovs_dpdk_get_devargs(s_ovs_dpdk);
n_rxq = nm_setting_ovs_dpdk_get_n_rxq(s_ovs_dpdk);
dpdk_array = json_array();
if (devargs)
json_array_append_new(dpdk_array, json_pack("[s,s]", "dpdk-devargs", devargs));
if (n_rxq != 0) {
json_array_append_new(dpdk_array,
json_pack("[s,s]", "n_rxq", nm_sprintf_buf(sbuf, "%u", n_rxq)));
}
json_array_append_new(options, dpdk_array);
} else if (s_ovs_patch) {
json_array_append_new(
options,

View file

@ -1815,4 +1815,9 @@ global:
nm_setting_bond_port_new;
nm_setting_connection_get_dns_over_tls;
nm_setting_connection_dns_over_tls_get_type;
} libnm_1_32_4;
} libnm_1_32_4;
libnm_1_36_0 {
global:
nm_setting_ovs_dpdk_get_n_rxq;
} libnm_1_34_0;

View file

@ -10,6 +10,7 @@
#include "nm-connection-private.h"
#include "nm-setting-connection.h"
#include "nm-setting-private.h"
#include "nm-utils-private.h"
/**
* SECTION:nm-setting-ovs-dpdk
@ -21,7 +22,7 @@
/*****************************************************************************/
NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_DEVARGS, );
NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_DEVARGS, PROP_N_RXQ, );
/**
* NMSettingOvsDpdk:
@ -31,7 +32,8 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_DEVARGS, );
struct _NMSettingOvsDpdk {
NMSetting parent;
char *devargs;
char *devargs;
guint32 n_rxq;
};
struct _NMSettingOvsDpdkClass {
@ -58,6 +60,22 @@ nm_setting_ovs_dpdk_get_devargs(NMSettingOvsDpdk *self)
return self->devargs;
}
/**
* nm_setting_ovs_dpdk_get_n_rxq:
* @self: the #NMSettingOvsDpdk
*
* Returns: the #NMSettingOvsDpdk:n-rxq property of the setting
*
* Since: 1.36
**/
guint32
nm_setting_ovs_dpdk_get_n_rxq(NMSettingOvsDpdk *self)
{
g_return_val_if_fail(NM_IS_SETTING_OVS_DPDK(self), 0);
return self->n_rxq;
}
/*****************************************************************************/
static void
@ -70,7 +88,7 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
g_value_set_string(value, self->devargs);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
_nm_setting_property_get_property_direct(object, prop_id, value, pspec);
break;
}
}
@ -86,7 +104,7 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps
self->devargs = g_value_dup_string(value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
_nm_setting_property_set_property_direct(object, prop_id, value, pspec);
break;
}
}
@ -125,8 +143,9 @@ finalize(GObject *object)
static void
nm_setting_ovs_dpdk_class_init(NMSettingOvsDpdkClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
NMSettingClass *setting_class = NM_SETTING_CLASS(klass);
GObjectClass *object_class = G_OBJECT_CLASS(klass);
NMSettingClass *setting_class = NM_SETTING_CLASS(klass);
GArray *properties_override = _nm_sett_info_property_override_create_array();
object_class->set_property = set_property;
object_class->get_property = get_property;
@ -146,7 +165,31 @@ nm_setting_ovs_dpdk_class_init(NMSettingOvsDpdkClass *klass)
NULL,
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
/**
* NMSettingOvsDpdk:n-rxq:
*
* Open vSwitch DPDK number of rx queues.
* Defaults to zero which means to leave the parameter in OVS unspecified
* and effectively configures one queue.
*
* Since: 1.36
**/
_nm_setting_property_define_direct_uint32(properties_override,
obj_properties,
NM_SETTING_OVS_DPDK_N_RXQ,
PROP_N_RXQ,
0,
G_MAXUINT32,
0,
NM_SETTING_PARAM_INFERRABLE,
NMSettingOvsDpdk,
n_rxq);
g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties);
_nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_OVS_DPDK, NULL, NULL, 0);
_nm_setting_class_commit(setting_class,
NM_META_SETTING_TYPE_OVS_DPDK,
NULL,
properties_override,
0);
}

View file

@ -28,6 +28,7 @@ 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"
typedef struct _NMSettingOvsDpdkClass NMSettingOvsDpdkClass;
@ -38,6 +39,8 @@ NMSetting *nm_setting_ovs_dpdk_new(void);
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);
G_END_DECLS

View file

@ -6685,7 +6685,10 @@ static const NMMetaPropertyInfo *const property_infos_OVS_BRIDGE[] = {
static const NMMetaPropertyInfo *const property_infos_OVS_DPDK[] = {
PROPERTY_INFO_WITH_DESC (NM_SETTING_OVS_DPDK_DEVARGS,
.property_type = &_pt_gobject_string,
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_OVS_DPDK_N_RXQ,
.property_type = &_pt_gobject_int,
),
NULL
};

View file

@ -303,6 +303,7 @@
#define DESCRIBE_DOC_NM_SETTING_OVS_BRIDGE_RSTP_ENABLE N_("Enable or disable RSTP.")
#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_EXTERNAL_IDS_DATA N_("A dictionary of key/value pairs with exernal-ids for OVS.")
#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

@ -818,6 +818,8 @@
<setting name="ovs-dpdk" >
<property name="devargs"
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." />
</setting>
<setting name="ovs-external-ids" >
</setting>