mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-03 07:00:13 +01:00
ethtool: introduce EEE support
Some Applications require to explicitly enable or disable EEE. Therefore introduce EEE (Energy Efficient Ethernet) support with: * ethtool.eee on/off Unit test case included. Signed-off-by: Johannes Zink <j.zink@pengutronix.de>
This commit is contained in:
parent
3842418512
commit
3165d9a2de
20 changed files with 318 additions and 3 deletions
|
|
@ -305,6 +305,7 @@ typedef struct {
|
||||||
NMEthtoolRingState *ring;
|
NMEthtoolRingState *ring;
|
||||||
NMEthtoolPauseState *pause;
|
NMEthtoolPauseState *pause;
|
||||||
NMEthtoolChannelsState *channels;
|
NMEthtoolChannelsState *channels;
|
||||||
|
NMEthtoolEEEState *eee;
|
||||||
} EthtoolState;
|
} EthtoolState;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
@ -2722,6 +2723,25 @@ _ethtool_pause_reset(NMDevice *self, NMPlatform *platform, EthtoolState *ethtool
|
||||||
_LOGD(LOGD_DEVICE, "ethtool: pause settings successfully reset");
|
_LOGD(LOGD_DEVICE, "ethtool: pause settings successfully reset");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_ethtool_eee_reset(NMDevice *self, NMPlatform *platform, EthtoolState *ethtool_state)
|
||||||
|
{
|
||||||
|
gs_free NMEthtoolEEEState *eee = NULL;
|
||||||
|
|
||||||
|
nm_assert(NM_IS_DEVICE(self));
|
||||||
|
nm_assert(NM_IS_PLATFORM(platform));
|
||||||
|
nm_assert(ethtool_state);
|
||||||
|
|
||||||
|
eee = g_steal_pointer(ðtool_state->eee);
|
||||||
|
if (!eee)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!nm_platform_ethtool_set_eee(platform, ethtool_state->ifindex, eee))
|
||||||
|
_LOGW(LOGD_DEVICE, "ethtool: failure resetting eee settings");
|
||||||
|
else
|
||||||
|
_LOGD(LOGD_DEVICE, "ethtool: eee settings successfully reset");
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ethtool_pause_set(NMDevice *self,
|
_ethtool_pause_set(NMDevice *self,
|
||||||
NMPlatform *platform,
|
NMPlatform *platform,
|
||||||
|
|
@ -2810,6 +2830,73 @@ _ethtool_pause_set(NMDevice *self,
|
||||||
_LOGD(LOGD_DEVICE, "ethtool: pause settings successfully set");
|
_LOGD(LOGD_DEVICE, "ethtool: pause settings successfully set");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_ethtool_eee_set(NMDevice *self,
|
||||||
|
NMPlatform *platform,
|
||||||
|
EthtoolState *ethtool_state,
|
||||||
|
NMSettingEthtool *s_ethtool)
|
||||||
|
{
|
||||||
|
NMEthtoolEEEState eee_old;
|
||||||
|
NMEthtoolEEEState eee_new;
|
||||||
|
GHashTable *hash;
|
||||||
|
GHashTableIter iter;
|
||||||
|
const char *name;
|
||||||
|
GVariant *variant;
|
||||||
|
gboolean has_old = FALSE;
|
||||||
|
NMTernary eee = NM_TERNARY_DEFAULT;
|
||||||
|
|
||||||
|
nm_assert(NM_IS_DEVICE(self));
|
||||||
|
nm_assert(NM_IS_PLATFORM(platform));
|
||||||
|
nm_assert(NM_IS_SETTING_ETHTOOL(s_ethtool));
|
||||||
|
nm_assert(ethtool_state);
|
||||||
|
nm_assert(!ethtool_state->eee);
|
||||||
|
|
||||||
|
hash = _nm_setting_option_hash(NM_SETTING(s_ethtool), FALSE);
|
||||||
|
if (!hash)
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_hash_table_iter_init(&iter, hash);
|
||||||
|
while (g_hash_table_iter_next(&iter, (gpointer *) &name, (gpointer *) &variant)) {
|
||||||
|
NMEthtoolID ethtool_id = nm_ethtool_id_get_by_name(name);
|
||||||
|
|
||||||
|
if (!nm_ethtool_id_is_eee(ethtool_id))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
nm_assert(g_variant_is_of_type(variant, G_VARIANT_TYPE_BOOLEAN));
|
||||||
|
|
||||||
|
if (!has_old) {
|
||||||
|
if (!nm_platform_ethtool_get_link_eee(platform, ethtool_state->ifindex, &eee_old)) {
|
||||||
|
_LOGW(LOGD_DEVICE,
|
||||||
|
"ethtool: failure setting eee options (cannot read "
|
||||||
|
"existing setting)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
has_old = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ethtool_id == NM_ETHTOOL_ID_EEE_ENABLED)
|
||||||
|
eee = g_variant_get_boolean(variant);
|
||||||
|
else
|
||||||
|
nm_assert_not_reached();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!has_old)
|
||||||
|
return;
|
||||||
|
|
||||||
|
eee_new = eee_old;
|
||||||
|
if (eee != NM_TERNARY_DEFAULT)
|
||||||
|
eee_new.enabled = !!eee;
|
||||||
|
|
||||||
|
ethtool_state->eee = nm_memdup(&eee_old, sizeof(eee_old));
|
||||||
|
|
||||||
|
if (!nm_platform_ethtool_set_eee(platform, ethtool_state->ifindex, &eee_new)) {
|
||||||
|
_LOGW(LOGD_DEVICE, "ethtool: failure setting eee settings");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_LOGD(LOGD_DEVICE, "ethtool: eee settings successfully set");
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ethtool_state_reset(NMDevice *self)
|
_ethtool_state_reset(NMDevice *self)
|
||||||
{
|
{
|
||||||
|
|
@ -2825,6 +2912,7 @@ _ethtool_state_reset(NMDevice *self)
|
||||||
_ethtool_ring_reset(self, platform, ethtool_state);
|
_ethtool_ring_reset(self, platform, ethtool_state);
|
||||||
_ethtool_pause_reset(self, platform, ethtool_state);
|
_ethtool_pause_reset(self, platform, ethtool_state);
|
||||||
_ethtool_channels_reset(self, platform, ethtool_state);
|
_ethtool_channels_reset(self, platform, ethtool_state);
|
||||||
|
_ethtool_eee_reset(self, platform, ethtool_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -2860,9 +2948,10 @@ _ethtool_state_set(NMDevice *self)
|
||||||
_ethtool_ring_set(self, platform, ethtool_state, s_ethtool);
|
_ethtool_ring_set(self, platform, ethtool_state, s_ethtool);
|
||||||
_ethtool_pause_set(self, platform, ethtool_state, s_ethtool);
|
_ethtool_pause_set(self, platform, ethtool_state, s_ethtool);
|
||||||
_ethtool_channels_set(self, platform, ethtool_state, s_ethtool);
|
_ethtool_channels_set(self, platform, ethtool_state, s_ethtool);
|
||||||
|
_ethtool_eee_set(self, platform, ethtool_state, s_ethtool);
|
||||||
|
|
||||||
if (ethtool_state->features || ethtool_state->coalesce || ethtool_state->ring
|
if (ethtool_state->features || ethtool_state->coalesce || ethtool_state->ring
|
||||||
|| ethtool_state->pause || ethtool_state->channels)
|
|| ethtool_state->pause || ethtool_state->channels || ethtool_state->eee)
|
||||||
priv->ethtool_state = g_steal_pointer(ðtool_state);
|
priv->ethtool_state = g_steal_pointer(ðtool_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1439,6 +1439,18 @@ write_ethtool_setting(NMConnection *connection, shvarFile *ifcfg, GError **error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is_first = TRUE;
|
||||||
|
for (ethtool_id = _NM_ETHTOOL_ID_EEE_FIRST; ethtool_id <= _NM_ETHTOOL_ID_EEE_LAST;
|
||||||
|
ethtool_id++) {
|
||||||
|
if (nm_setting_option_get_boolean(NM_SETTING(s_ethtool),
|
||||||
|
nm_ethtool_data[ethtool_id]->optname,
|
||||||
|
&b)) {
|
||||||
|
nm_sprintf_buf(prop_name, "ethtool.%s", nm_ethtool_data[ethtool_id]->optname);
|
||||||
|
set_error_unsupported(error, connection, prop_name, FALSE);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!any_option) {
|
if (!any_option) {
|
||||||
/* Write an empty dummy "-A" option without arguments. This is to
|
/* Write an empty dummy "-A" option without arguments. This is to
|
||||||
* ensure that the reader will create an (all default) NMSettingEthtool.
|
* ensure that the reader will create an (all default) NMSettingEthtool.
|
||||||
|
|
|
||||||
|
|
@ -3623,7 +3623,7 @@ test_roundtrip_ethtool(void)
|
||||||
optname = nm_ethtool_data[ethtool_id]->optname;
|
optname = nm_ethtool_data[ethtool_id]->optname;
|
||||||
vtype = nm_ethtool_id_get_variant_type(ethtool_id);
|
vtype = nm_ethtool_id_get_variant_type(ethtool_id);
|
||||||
|
|
||||||
if (nm_ethtool_optname_is_channels(optname)) {
|
if (nm_ethtool_optname_is_channels(optname) || nm_ethtool_optname_is_eee(optname)) {
|
||||||
/* Not supported */
|
/* Not supported */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,11 @@ typedef enum {
|
||||||
NM_ETHTOOL_ID_PAUSE_TX,
|
NM_ETHTOOL_ID_PAUSE_TX,
|
||||||
_NM_ETHTOOL_ID_PAUSE_LAST = NM_ETHTOOL_ID_PAUSE_TX,
|
_NM_ETHTOOL_ID_PAUSE_LAST = NM_ETHTOOL_ID_PAUSE_TX,
|
||||||
|
|
||||||
_NM_ETHTOOL_ID_RING_FIRST = _NM_ETHTOOL_ID_PAUSE_LAST + 1,
|
_NM_ETHTOOL_ID_EEE_FIRST = _NM_ETHTOOL_ID_PAUSE_LAST + 1,
|
||||||
|
NM_ETHTOOL_ID_EEE_ENABLED = _NM_ETHTOOL_ID_EEE_FIRST,
|
||||||
|
_NM_ETHTOOL_ID_EEE_LAST = NM_ETHTOOL_ID_EEE_ENABLED,
|
||||||
|
|
||||||
|
_NM_ETHTOOL_ID_RING_FIRST = _NM_ETHTOOL_ID_EEE_LAST + 1,
|
||||||
NM_ETHTOOL_ID_RING_RX = _NM_ETHTOOL_ID_RING_FIRST,
|
NM_ETHTOOL_ID_RING_RX = _NM_ETHTOOL_ID_RING_FIRST,
|
||||||
NM_ETHTOOL_ID_RING_RX_JUMBO,
|
NM_ETHTOOL_ID_RING_RX_JUMBO,
|
||||||
NM_ETHTOOL_ID_RING_RX_MINI,
|
NM_ETHTOOL_ID_RING_RX_MINI,
|
||||||
|
|
@ -153,6 +157,7 @@ typedef enum {
|
||||||
NM_ETHTOOL_TYPE_RING,
|
NM_ETHTOOL_TYPE_RING,
|
||||||
NM_ETHTOOL_TYPE_PAUSE,
|
NM_ETHTOOL_TYPE_PAUSE,
|
||||||
NM_ETHTOOL_TYPE_CHANNELS,
|
NM_ETHTOOL_TYPE_CHANNELS,
|
||||||
|
NM_ETHTOOL_TYPE_EEE,
|
||||||
} NMEthtoolType;
|
} NMEthtoolType;
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
@ -187,6 +192,12 @@ nm_ethtool_id_is_channels(NMEthtoolID id)
|
||||||
return id >= _NM_ETHTOOL_ID_CHANNELS_FIRST && id <= _NM_ETHTOOL_ID_CHANNELS_LAST;
|
return id >= _NM_ETHTOOL_ID_CHANNELS_FIRST && id <= _NM_ETHTOOL_ID_CHANNELS_LAST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline gboolean
|
||||||
|
nm_ethtool_id_is_eee(NMEthtoolID id)
|
||||||
|
{
|
||||||
|
return id >= _NM_ETHTOOL_ID_EEE_FIRST && id <= _NM_ETHTOOL_ID_EEE_LAST;
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ const NMEthtoolData *const nm_ethtool_data[_NM_ETHTOOL_ID_NUM + 1] = {
|
||||||
ETHT_DATA(COALESCE_TX_USECS_HIGH),
|
ETHT_DATA(COALESCE_TX_USECS_HIGH),
|
||||||
ETHT_DATA(COALESCE_TX_USECS_IRQ),
|
ETHT_DATA(COALESCE_TX_USECS_IRQ),
|
||||||
ETHT_DATA(COALESCE_TX_USECS_LOW),
|
ETHT_DATA(COALESCE_TX_USECS_LOW),
|
||||||
|
ETHT_DATA(EEE_ENABLED),
|
||||||
ETHT_DATA(FEATURE_ESP_HW_OFFLOAD),
|
ETHT_DATA(FEATURE_ESP_HW_OFFLOAD),
|
||||||
ETHT_DATA(FEATURE_ESP_TX_CSUM_HW_OFFLOAD),
|
ETHT_DATA(FEATURE_ESP_TX_CSUM_HW_OFFLOAD),
|
||||||
ETHT_DATA(FEATURE_FCOE_MTU),
|
ETHT_DATA(FEATURE_FCOE_MTU),
|
||||||
|
|
@ -141,6 +142,7 @@ static const guint8 _by_name[_NM_ETHTOOL_ID_NUM] = {
|
||||||
NM_ETHTOOL_ID_COALESCE_TX_USECS_HIGH,
|
NM_ETHTOOL_ID_COALESCE_TX_USECS_HIGH,
|
||||||
NM_ETHTOOL_ID_COALESCE_TX_USECS_IRQ,
|
NM_ETHTOOL_ID_COALESCE_TX_USECS_IRQ,
|
||||||
NM_ETHTOOL_ID_COALESCE_TX_USECS_LOW,
|
NM_ETHTOOL_ID_COALESCE_TX_USECS_LOW,
|
||||||
|
NM_ETHTOOL_ID_EEE_ENABLED,
|
||||||
NM_ETHTOOL_ID_FEATURE_ESP_HW_OFFLOAD,
|
NM_ETHTOOL_ID_FEATURE_ESP_HW_OFFLOAD,
|
||||||
NM_ETHTOOL_ID_FEATURE_ESP_TX_CSUM_HW_OFFLOAD,
|
NM_ETHTOOL_ID_FEATURE_ESP_TX_CSUM_HW_OFFLOAD,
|
||||||
NM_ETHTOOL_ID_FEATURE_FCOE_MTU,
|
NM_ETHTOOL_ID_FEATURE_FCOE_MTU,
|
||||||
|
|
@ -301,6 +303,8 @@ nm_ethtool_id_to_type(NMEthtoolID id)
|
||||||
return NM_ETHTOOL_TYPE_PAUSE;
|
return NM_ETHTOOL_TYPE_PAUSE;
|
||||||
if (nm_ethtool_id_is_channels(id))
|
if (nm_ethtool_id_is_channels(id))
|
||||||
return NM_ETHTOOL_TYPE_CHANNELS;
|
return NM_ETHTOOL_TYPE_CHANNELS;
|
||||||
|
if (nm_ethtool_id_is_eee(id))
|
||||||
|
return NM_ETHTOOL_TYPE_EEE;
|
||||||
|
|
||||||
return NM_ETHTOOL_TYPE_UNKNOWN;
|
return NM_ETHTOOL_TYPE_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
@ -311,6 +315,7 @@ nm_ethtool_id_get_variant_type(NMEthtoolID ethtool_id)
|
||||||
switch (nm_ethtool_id_to_type(ethtool_id)) {
|
switch (nm_ethtool_id_to_type(ethtool_id)) {
|
||||||
case NM_ETHTOOL_TYPE_FEATURE:
|
case NM_ETHTOOL_TYPE_FEATURE:
|
||||||
case NM_ETHTOOL_TYPE_PAUSE:
|
case NM_ETHTOOL_TYPE_PAUSE:
|
||||||
|
case NM_ETHTOOL_TYPE_EEE:
|
||||||
return G_VARIANT_TYPE_BOOLEAN;
|
return G_VARIANT_TYPE_BOOLEAN;
|
||||||
case NM_ETHTOOL_TYPE_CHANNELS:
|
case NM_ETHTOOL_TYPE_CHANNELS:
|
||||||
case NM_ETHTOOL_TYPE_COALESCE:
|
case NM_ETHTOOL_TYPE_COALESCE:
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,7 @@ G_BEGIN_DECLS
|
||||||
#define NM_ETHTOOL_OPTNAME_CHANNELS_OTHER "channels-other"
|
#define NM_ETHTOOL_OPTNAME_CHANNELS_OTHER "channels-other"
|
||||||
#define NM_ETHTOOL_OPTNAME_CHANNELS_COMBINED "channels-combined"
|
#define NM_ETHTOOL_OPTNAME_CHANNELS_COMBINED "channels-combined"
|
||||||
|
|
||||||
|
#define NM_ETHTOOL_OPTNAME_EEE_ENABLED "eee"
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
||||||
|
|
@ -1948,4 +1948,5 @@ libnm_1_46_0 {
|
||||||
global:
|
global:
|
||||||
nm_access_point_get_bandwidth;
|
nm_access_point_get_bandwidth;
|
||||||
nm_ethtool_optname_is_channels;
|
nm_ethtool_optname_is_channels;
|
||||||
|
nm_ethtool_optname_is_eee;
|
||||||
} libnm_1_44_0;
|
} libnm_1_44_0;
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,7 @@ G_BEGIN_DECLS
|
||||||
#define NM_ETHTOOL_OPTNAME_CHANNELS_OTHER "channels-other"
|
#define NM_ETHTOOL_OPTNAME_CHANNELS_OTHER "channels-other"
|
||||||
#define NM_ETHTOOL_OPTNAME_CHANNELS_COMBINED "channels-combined"
|
#define NM_ETHTOOL_OPTNAME_CHANNELS_COMBINED "channels-combined"
|
||||||
|
|
||||||
|
#define NM_ETHTOOL_OPTNAME_EEE_ENABLED "eee"
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
||||||
|
|
@ -1276,6 +1276,10 @@
|
||||||
dbus-type="b"
|
dbus-type="b"
|
||||||
is-setting-option="1"
|
is-setting-option="1"
|
||||||
/>
|
/>
|
||||||
|
<property name="eee"
|
||||||
|
dbus-type="b"
|
||||||
|
is-setting-option="1"
|
||||||
|
/>
|
||||||
<property name="ring-rx"
|
<property name="ring-rx"
|
||||||
dbus-type="u"
|
dbus-type="u"
|
||||||
is-setting-option="1"
|
is-setting-option="1"
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,21 @@ nm_ethtool_optname_is_channels(const char *optname)
|
||||||
return optname && nm_ethtool_id_is_channels(nm_ethtool_id_get_by_name(optname));
|
return optname && nm_ethtool_id_is_channels(nm_ethtool_id_get_by_name(optname));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nm_ethtool_optname_is_eee:
|
||||||
|
* @optname: (nullable): the option name to check
|
||||||
|
*
|
||||||
|
* Checks whether @optname is a valid option name for an eee setting.
|
||||||
|
*
|
||||||
|
* Returns: %TRUE, if @optname is valid
|
||||||
|
*
|
||||||
|
* Since: 1.46
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
nm_ethtool_optname_is_eee(const char *optname)
|
||||||
|
{
|
||||||
|
return optname && nm_ethtool_id_is_eee(nm_ethtool_id_get_by_name(optname));
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* nm_ethtool_optname_is_pause:
|
* nm_ethtool_optname_is_pause:
|
||||||
* @optname: (nullable): the option name to check
|
* @optname: (nullable): the option name to check
|
||||||
|
|
|
||||||
|
|
@ -2303,6 +2303,79 @@ test_ethtool_pause(void)
|
||||||
g_assert_true(out_value);
|
g_assert_true(out_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_ethtool_eee(void)
|
||||||
|
{
|
||||||
|
gs_unref_object NMConnection *con = NULL;
|
||||||
|
gs_unref_object NMConnection *con2 = NULL;
|
||||||
|
gs_unref_object NMConnection *con3 = NULL;
|
||||||
|
gs_unref_variant GVariant *variant = NULL;
|
||||||
|
gs_free_error GError *error = NULL;
|
||||||
|
nm_auto_unref_keyfile GKeyFile *keyfile = NULL;
|
||||||
|
NMSettingConnection *s_con;
|
||||||
|
NMSettingEthtool *s_ethtool;
|
||||||
|
NMSettingEthtool *s_ethtool2;
|
||||||
|
NMSettingEthtool *s_ethtool3;
|
||||||
|
gboolean out_value;
|
||||||
|
|
||||||
|
con =
|
||||||
|
nmtst_create_minimal_connection("ethtool-eee", NULL, NM_SETTING_WIRED_SETTING_NAME, &s_con);
|
||||||
|
s_ethtool = NM_SETTING_ETHTOOL(nm_setting_ethtool_new());
|
||||||
|
nm_connection_add_setting(con, NM_SETTING(s_ethtool));
|
||||||
|
|
||||||
|
nm_setting_option_set_boolean(NM_SETTING(s_ethtool), NM_ETHTOOL_OPTNAME_EEE_ENABLED, FALSE);
|
||||||
|
|
||||||
|
g_assert_true(nm_setting_option_get_boolean(NM_SETTING(s_ethtool),
|
||||||
|
NM_ETHTOOL_OPTNAME_EEE_ENABLED,
|
||||||
|
&out_value));
|
||||||
|
g_assert_true(!out_value);
|
||||||
|
|
||||||
|
nmtst_connection_normalize(con);
|
||||||
|
|
||||||
|
variant = nm_connection_to_dbus(con, NM_CONNECTION_SERIALIZE_ALL);
|
||||||
|
|
||||||
|
con2 = nm_simple_connection_new_from_dbus(variant, &error);
|
||||||
|
nmtst_assert_success(con2, error);
|
||||||
|
|
||||||
|
s_ethtool2 = NM_SETTING_ETHTOOL(nm_connection_get_setting(con2, NM_TYPE_SETTING_ETHTOOL));
|
||||||
|
|
||||||
|
g_assert_true(nm_setting_option_get_boolean(NM_SETTING(s_ethtool2),
|
||||||
|
NM_ETHTOOL_OPTNAME_EEE_ENABLED,
|
||||||
|
&out_value));
|
||||||
|
g_assert_true(!out_value);
|
||||||
|
|
||||||
|
nmtst_assert_connection_verifies_without_normalization(con2);
|
||||||
|
|
||||||
|
nmtst_assert_connection_equals(con, FALSE, con2, FALSE);
|
||||||
|
|
||||||
|
con2 = nm_simple_connection_new_from_dbus(variant, &error);
|
||||||
|
nmtst_assert_success(con2, error);
|
||||||
|
|
||||||
|
keyfile = nm_keyfile_write(con, NM_KEYFILE_HANDLER_FLAGS_NONE, NULL, NULL, &error);
|
||||||
|
nmtst_assert_success(keyfile, error);
|
||||||
|
|
||||||
|
con3 = nm_keyfile_read(keyfile,
|
||||||
|
"/ignored/current/working/directory/for/loading/relative/paths",
|
||||||
|
NM_KEYFILE_HANDLER_FLAGS_NONE,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
&error);
|
||||||
|
nmtst_assert_success(con3, error);
|
||||||
|
|
||||||
|
nm_keyfile_read_ensure_id(con3, "unused-because-already-has-id");
|
||||||
|
nm_keyfile_read_ensure_uuid(con3, "unused-because-already-has-uuid");
|
||||||
|
|
||||||
|
nmtst_connection_normalize(con3);
|
||||||
|
|
||||||
|
nmtst_assert_connection_equals(con, FALSE, con3, FALSE);
|
||||||
|
|
||||||
|
s_ethtool3 = NM_SETTING_ETHTOOL(nm_connection_get_setting(con3, NM_TYPE_SETTING_ETHTOOL));
|
||||||
|
|
||||||
|
g_assert_true(nm_setting_option_get_boolean(NM_SETTING(s_ethtool3),
|
||||||
|
NM_ETHTOOL_OPTNAME_EEE_ENABLED,
|
||||||
|
&out_value));
|
||||||
|
g_assert_true(!out_value);
|
||||||
|
}
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -5326,6 +5399,7 @@ main(int argc, char **argv)
|
||||||
g_test_add_func("/libnm/settings/ethtool/coalesce", test_ethtool_coalesce);
|
g_test_add_func("/libnm/settings/ethtool/coalesce", test_ethtool_coalesce);
|
||||||
g_test_add_func("/libnm/settings/ethtool/ring", test_ethtool_ring);
|
g_test_add_func("/libnm/settings/ethtool/ring", test_ethtool_ring);
|
||||||
g_test_add_func("/libnm/settings/ethtool/pause", test_ethtool_pause);
|
g_test_add_func("/libnm/settings/ethtool/pause", test_ethtool_pause);
|
||||||
|
g_test_add_func("/libnm/settings/ethtool/eee", test_ethtool_eee);
|
||||||
|
|
||||||
g_test_add_func("/libnm/settings/6lowpan/1", test_6lowpan_1);
|
g_test_add_func("/libnm/settings/6lowpan/1", test_6lowpan_1);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@ gboolean nm_ethtool_optname_is_pause(const char *optname);
|
||||||
NM_AVAILABLE_IN_1_46
|
NM_AVAILABLE_IN_1_46
|
||||||
gboolean nm_ethtool_optname_is_channels(const char *optname);
|
gboolean nm_ethtool_optname_is_channels(const char *optname);
|
||||||
|
|
||||||
|
NM_AVAILABLE_IN_1_46
|
||||||
|
gboolean nm_ethtool_optname_is_eee(const char *optname);
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define NM_TYPE_SETTING_ETHTOOL (nm_setting_ethtool_get_type())
|
#define NM_TYPE_SETTING_ETHTOOL (nm_setting_ethtool_get_type())
|
||||||
|
|
|
||||||
|
|
@ -1161,6 +1161,35 @@ nmp_utils_ethtool_get_pause(int ifindex, NMEthtoolPauseState *pause)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
nmp_utils_ethtool_get_eee(int ifindex, NMEthtoolEEEState *eee)
|
||||||
|
{
|
||||||
|
struct ethtool_eee eth_data;
|
||||||
|
nm_auto_socket_handle SocketHandle shandle = SOCKET_HANDLE_INIT(ifindex);
|
||||||
|
|
||||||
|
g_return_val_if_fail(ifindex > 0, FALSE);
|
||||||
|
g_return_val_if_fail(eee, FALSE);
|
||||||
|
|
||||||
|
eth_data.cmd = ETHTOOL_GEEE;
|
||||||
|
if (_ethtool_call_handle(&shandle, ð_data, sizeof(struct ethtool_eee)) != 0) {
|
||||||
|
nm_log_trace(LOGD_PLATFORM,
|
||||||
|
"ethtool[%d]: %s: failure getting eee settings",
|
||||||
|
ifindex,
|
||||||
|
"get-eee");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*eee = (NMEthtoolEEEState){
|
||||||
|
.enabled = eth_data.eee_enabled == 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
nm_log_trace(LOGD_PLATFORM,
|
||||||
|
"ethtool[%d]: %s: retrieved kernel eee settings",
|
||||||
|
ifindex,
|
||||||
|
"get-eee");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
nmp_utils_ethtool_set_pause(int ifindex, const NMEthtoolPauseState *pause)
|
nmp_utils_ethtool_set_pause(int ifindex, const NMEthtoolPauseState *pause)
|
||||||
{
|
{
|
||||||
|
|
@ -1188,6 +1217,36 @@ nmp_utils_ethtool_set_pause(int ifindex, const NMEthtoolPauseState *pause)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
nmp_utils_ethtool_set_eee(int ifindex, const NMEthtoolEEEState *eee)
|
||||||
|
{
|
||||||
|
struct ethtool_eee eth_data;
|
||||||
|
nm_auto_socket_handle SocketHandle shandle = SOCKET_HANDLE_INIT(ifindex);
|
||||||
|
|
||||||
|
g_return_val_if_fail(ifindex > 0, FALSE);
|
||||||
|
g_return_val_if_fail(eee, FALSE);
|
||||||
|
|
||||||
|
eth_data.cmd = ETHTOOL_GEEE;
|
||||||
|
if (_ethtool_call_handle(&shandle, ð_data, sizeof(struct ethtool_eee)) != 0) {
|
||||||
|
nm_log_trace(LOGD_PLATFORM,
|
||||||
|
"ethtool[%d]: %s: failure getting eee settings",
|
||||||
|
ifindex,
|
||||||
|
"get-eee");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
eth_data.cmd = ETHTOOL_SEEE, eth_data.eee_enabled = eee->enabled ? 1 : 0;
|
||||||
|
|
||||||
|
if (_ethtool_call_handle(&shandle, ð_data, sizeof(struct ethtool_eee)) != 0) {
|
||||||
|
nm_log_trace(LOGD_PLATFORM,
|
||||||
|
"ethtool[%d]: %s: failure setting eee settings",
|
||||||
|
ifindex,
|
||||||
|
"set-eee");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
nm_log_trace(LOGD_PLATFORM, "ethtool[%d]: %s: set kernel eee settings", ifindex, "set-eee");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,10 @@ gboolean nmp_utils_ethtool_get_pause(int ifindex, NMEthtoolPauseState *pause);
|
||||||
|
|
||||||
gboolean nmp_utils_ethtool_set_pause(int ifindex, const NMEthtoolPauseState *pause);
|
gboolean nmp_utils_ethtool_set_pause(int ifindex, const NMEthtoolPauseState *pause);
|
||||||
|
|
||||||
|
gboolean nmp_utils_ethtool_get_eee(int ifindex, NMEthtoolEEEState *eee);
|
||||||
|
|
||||||
|
gboolean nmp_utils_ethtool_set_eee(int ifindex, const NMEthtoolEEEState *eee);
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
gboolean nmp_utils_mii_supports_carrier_detect(int ifindex);
|
gboolean nmp_utils_mii_supports_carrier_detect(int ifindex);
|
||||||
|
|
|
||||||
|
|
@ -3628,6 +3628,17 @@ nm_platform_ethtool_get_link_pause(NMPlatform *self, int ifindex, NMEthtoolPause
|
||||||
return nmp_utils_ethtool_get_pause(ifindex, pause);
|
return nmp_utils_ethtool_get_pause(ifindex, pause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
nm_platform_ethtool_get_link_eee(NMPlatform *self, int ifindex, NMEthtoolEEEState *eee)
|
||||||
|
{
|
||||||
|
_CHECK_SELF_NETNS(self, klass, netns, FALSE);
|
||||||
|
|
||||||
|
g_return_val_if_fail(ifindex > 0, FALSE);
|
||||||
|
g_return_val_if_fail(eee, FALSE);
|
||||||
|
|
||||||
|
return nmp_utils_ethtool_get_eee(ifindex, eee);
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
nm_platform_ethtool_set_pause(NMPlatform *self, int ifindex, const NMEthtoolPauseState *pause)
|
nm_platform_ethtool_set_pause(NMPlatform *self, int ifindex, const NMEthtoolPauseState *pause)
|
||||||
{
|
{
|
||||||
|
|
@ -3638,6 +3649,15 @@ nm_platform_ethtool_set_pause(NMPlatform *self, int ifindex, const NMEthtoolPaus
|
||||||
return nmp_utils_ethtool_set_pause(ifindex, pause);
|
return nmp_utils_ethtool_set_pause(ifindex, pause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
nm_platform_ethtool_set_eee(NMPlatform *self, int ifindex, const NMEthtoolEEEState *eee)
|
||||||
|
{
|
||||||
|
_CHECK_SELF_NETNS(self, klass, netns, FALSE);
|
||||||
|
|
||||||
|
g_return_val_if_fail(ifindex > 0, FALSE);
|
||||||
|
|
||||||
|
return nmp_utils_ethtool_set_eee(ifindex, eee);
|
||||||
|
}
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
const NMDedupMultiHeadEntry *
|
const NMDedupMultiHeadEntry *
|
||||||
|
|
|
||||||
|
|
@ -2578,9 +2578,13 @@ gboolean nm_platform_ethtool_set_channels(NMPlatform *self,
|
||||||
gboolean
|
gboolean
|
||||||
nm_platform_ethtool_get_link_pause(NMPlatform *self, int ifindex, NMEthtoolPauseState *pause);
|
nm_platform_ethtool_get_link_pause(NMPlatform *self, int ifindex, NMEthtoolPauseState *pause);
|
||||||
|
|
||||||
|
gboolean nm_platform_ethtool_get_link_eee(NMPlatform *self, int ifindex, NMEthtoolEEEState *eee);
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
nm_platform_ethtool_set_pause(NMPlatform *self, int ifindex, const NMEthtoolPauseState *pause);
|
nm_platform_ethtool_set_pause(NMPlatform *self, int ifindex, const NMEthtoolPauseState *pause);
|
||||||
|
|
||||||
|
gboolean nm_platform_ethtool_set_eee(NMPlatform *self, int ifindex, const NMEthtoolEEEState *eee);
|
||||||
|
|
||||||
void nm_platform_ip4_dev_route_blacklist_set(NMPlatform *self,
|
void nm_platform_ip4_dev_route_blacklist_set(NMPlatform *self,
|
||||||
int ifindex,
|
int ifindex,
|
||||||
GPtrArray *ip4_dev_route_blacklist);
|
GPtrArray *ip4_dev_route_blacklist);
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,10 @@ typedef struct {
|
||||||
guint32 combined;
|
guint32 combined;
|
||||||
} NMEthtoolChannelsState;
|
} NMEthtoolChannelsState;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
bool enabled : 1;
|
||||||
|
} NMEthtoolEEEState;
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
typedef struct _NMPNetns NMPNetns;
|
typedef struct _NMPNetns NMPNetns;
|
||||||
|
|
|
||||||
|
|
@ -4433,6 +4433,7 @@ _get_fcn_ethtool(ARGS_GET_FCN)
|
||||||
RETURN_STR_TO_FREE(nm_strdup_int(u32));
|
RETURN_STR_TO_FREE(nm_strdup_int(u32));
|
||||||
case NM_ETHTOOL_TYPE_FEATURE:
|
case NM_ETHTOOL_TYPE_FEATURE:
|
||||||
case NM_ETHTOOL_TYPE_PAUSE:
|
case NM_ETHTOOL_TYPE_PAUSE:
|
||||||
|
case NM_ETHTOOL_TYPE_EEE:
|
||||||
if (!nm_setting_option_get_boolean(setting, nm_ethtool_data[ethtool_id]->optname, &b)) {
|
if (!nm_setting_option_get_boolean(setting, nm_ethtool_data[ethtool_id]->optname, &b)) {
|
||||||
NM_SET_OUT(out_is_default, TRUE);
|
NM_SET_OUT(out_is_default, TRUE);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -4479,6 +4480,7 @@ _set_fcn_ethtool(ARGS_SET_FCN)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
case NM_ETHTOOL_TYPE_FEATURE:
|
case NM_ETHTOOL_TYPE_FEATURE:
|
||||||
case NM_ETHTOOL_TYPE_PAUSE:
|
case NM_ETHTOOL_TYPE_PAUSE:
|
||||||
|
case NM_ETHTOOL_TYPE_EEE:
|
||||||
if (!nmc_string_to_ternary_full(value,
|
if (!nmc_string_to_ternary_full(value,
|
||||||
NMC_STRING_TO_TERNARY_FLAGS_IGNORE_FOR_DEFAULT,
|
NMC_STRING_TO_TERNARY_FLAGS_IGNORE_FOR_DEFAULT,
|
||||||
&t,
|
&t,
|
||||||
|
|
@ -5926,6 +5928,7 @@ static const NMMetaPropertyInfo *const property_infos_ETHTOOL[] = {
|
||||||
DEFINE_PROPERTY_TYP_DATA_SUBTYPE
|
DEFINE_PROPERTY_TYP_DATA_SUBTYPE
|
||||||
(ethtool, .ethtool_id = NM_ETHTOOL_ID_PAUSE_TX)
|
(ethtool, .ethtool_id = NM_ETHTOOL_ID_PAUSE_TX)
|
||||||
),
|
),
|
||||||
|
PROPERTY_INFO_ETHTOOL (EEE_ENABLED),
|
||||||
PROPERTY_INFO_ETHTOOL (RING_RX),
|
PROPERTY_INFO_ETHTOOL (RING_RX),
|
||||||
PROPERTY_INFO_ETHTOOL (RING_RX_JUMBO),
|
PROPERTY_INFO_ETHTOOL (RING_RX_JUMBO),
|
||||||
PROPERTY_INFO_ETHTOOL (RING_RX_MINI),
|
PROPERTY_INFO_ETHTOOL (RING_RX_MINI),
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,7 @@ get_ethtool_format(const NMMetaPropertyInfo *prop_info)
|
||||||
return g_strdup("integer");
|
return g_strdup("integer");
|
||||||
case NM_ETHTOOL_TYPE_FEATURE:
|
case NM_ETHTOOL_TYPE_FEATURE:
|
||||||
case NM_ETHTOOL_TYPE_PAUSE:
|
case NM_ETHTOOL_TYPE_PAUSE:
|
||||||
|
case NM_ETHTOOL_TYPE_EEE:
|
||||||
return g_strdup("ternary");
|
return g_strdup("ternary");
|
||||||
case NM_ETHTOOL_TYPE_UNKNOWN:
|
case NM_ETHTOOL_TYPE_UNKNOWN:
|
||||||
nm_assert_not_reached();
|
nm_assert_not_reached();
|
||||||
|
|
@ -317,6 +318,7 @@ append_ethtool_valid_values(const NMMetaPropertyInfo *prop_info, GPtrArray *vali
|
||||||
break;
|
break;
|
||||||
case NM_ETHTOOL_TYPE_FEATURE:
|
case NM_ETHTOOL_TYPE_FEATURE:
|
||||||
case NM_ETHTOOL_TYPE_PAUSE:
|
case NM_ETHTOOL_TYPE_PAUSE:
|
||||||
|
case NM_ETHTOOL_TYPE_EEE:
|
||||||
append_vals(valid_values, "on", "off", "ignore");
|
append_vals(valid_values, "on", "off", "ignore");
|
||||||
break;
|
break;
|
||||||
case NM_ETHTOOL_TYPE_UNKNOWN:
|
case NM_ETHTOOL_TYPE_UNKNOWN:
|
||||||
|
|
|
||||||
|
|
@ -1028,6 +1028,9 @@
|
||||||
nmcli-description="Whether TX pause should be enabled. Only valid when automatic negotiation is disabled"
|
nmcli-description="Whether TX pause should be enabled. Only valid when automatic negotiation is disabled"
|
||||||
format="ternary"
|
format="ternary"
|
||||||
values="on, off, ignore" />
|
values="on, off, ignore" />
|
||||||
|
<property name="eee"
|
||||||
|
format="ternary"
|
||||||
|
values="on, off, ignore" />
|
||||||
<property name="ring-rx"
|
<property name="ring-rx"
|
||||||
format="integer"
|
format="integer"
|
||||||
values="0 - 4294967295" />
|
values="0 - 4294967295" />
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue