2019-09-10 11:19:01 +02:00
|
|
|
// SPDX-License-Identifier: LGPL-2.1+
|
libnm, cli, ifcfg-rh: add NMSettingEthtool setting
Note that in NetworkManager API (D-Bus, libnm, and nmcli),
the features are called "feature-xyz". The "feature-" prefix
is used, because NMSettingEthtool possibly will gain support
for options that are not only -K|--offload|--features, for
example -C|--coalesce.
The "xzy" suffix is either how ethtool utility calls the feature
("tso", "rx"). Or, if ethtool utility specifies no alias for that
feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
If possible, we prefer ethtool utility's naming.
Also note, how the features "feature-sg", "feature-tso", and
"feature-tx" actually refer to multiple underlying kernel features
at once. This too follows what ethtool utility does.
The functionality is not yet implemented server-side.
2018-07-16 23:37:55 +02:00
|
|
|
/*
|
2019-10-01 09:20:35 +02:00
|
|
|
* Copyright (C) 2018 Red Hat, Inc.
|
libnm, cli, ifcfg-rh: add NMSettingEthtool setting
Note that in NetworkManager API (D-Bus, libnm, and nmcli),
the features are called "feature-xyz". The "feature-" prefix
is used, because NMSettingEthtool possibly will gain support
for options that are not only -K|--offload|--features, for
example -C|--coalesce.
The "xzy" suffix is either how ethtool utility calls the feature
("tso", "rx"). Or, if ethtool utility specifies no alias for that
feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
If possible, we prefer ethtool utility's naming.
Also note, how the features "feature-sg", "feature-tso", and
"feature-tx" actually refer to multiple underlying kernel features
at once. This too follows what ethtool utility does.
The functionality is not yet implemented server-side.
2018-07-16 23:37:55 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "nm-default.h"
|
|
|
|
|
|
|
|
|
|
#include "nm-setting-ethtool.h"
|
|
|
|
|
|
|
|
|
|
#include "nm-setting-private.h"
|
shared: build helper "libnm-libnm-core-{intern|aux}.la" library for libnm-core
"libnm-core" implements common functionality for "NetworkManager" and
"libnm".
Note that clients like "nmcli" cannot access the internal API provided
by "libnm-core". So, if nmcli wants to do something that is also done by
"libnm-core", , "libnm", or "NetworkManager", the code would have to be
duplicated.
Instead, such code can be in "libnm-libnm-core-{intern|aux}.la".
Note that:
0) "libnm-libnm-core-intern.la" is used by libnm-core itsself.
On the other hand, "libnm-libnm-core-aux.la" is not used by
libnm-core, but provides utilities on top of it.
1) they both extend "libnm-core" with utlities that are not public
API of libnm itself. Maybe part of the code should one day become
public API of libnm. On the other hand, this is code for which
we may not want to commit to a stable interface or which we
don't want to provide as part of the API.
2) "libnm-libnm-core-intern.la" is statically linked by "libnm-core"
and thus directly available to "libnm" and "NetworkManager".
On the other hand, "libnm-libnm-core-aux.la" may be used by "libnm"
and "NetworkManager".
Both libraries may be statically linked by libnm clients (like
nmcli).
3) it must only use glib, libnm-glib-aux.la, and the public API
of libnm-core.
This is important: it must not use "libnm-core/nm-core-internal.h"
nor "libnm-core/nm-utils-private.h" so the static library is usable
by nmcli which couldn't access these.
Note that "shared/nm-meta-setting.c" is an entirely different case,
because it behaves differently depending on whether linking against
"libnm-core" or the client programs. As such, this file must be compiled
twice.
(cherry picked from commit af07ed01c04867e281cc3982a7ab0d244d4f8e2e)
2019-04-15 09:26:53 +02:00
|
|
|
#include "nm-libnm-core-intern/nm-ethtool-utils.h"
|
libnm, cli, ifcfg-rh: add NMSettingEthtool setting
Note that in NetworkManager API (D-Bus, libnm, and nmcli),
the features are called "feature-xyz". The "feature-" prefix
is used, because NMSettingEthtool possibly will gain support
for options that are not only -K|--offload|--features, for
example -C|--coalesce.
The "xzy" suffix is either how ethtool utility calls the feature
("tso", "rx"). Or, if ethtool utility specifies no alias for that
feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
If possible, we prefer ethtool utility's naming.
Also note, how the features "feature-sg", "feature-tso", and
"feature-tx" actually refer to multiple underlying kernel features
at once. This too follows what ethtool utility does.
The functionality is not yet implemented server-side.
2018-07-16 23:37:55 +02:00
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* SECTION:nm-setting-ethtool
|
|
|
|
|
* @short_description: Describes connection properties for ethtool related options
|
|
|
|
|
*
|
|
|
|
|
* The #NMSettingEthtool object is a #NMSetting subclass that describes properties
|
|
|
|
|
* to control network driver and hardware settings.
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-05-14 09:16:32 +02:00
|
|
|
static const GVariantType *
|
|
|
|
|
get_variant_type_from_ethtool_id (NMEthtoolID ethtool_id)
|
|
|
|
|
{
|
|
|
|
|
if (nm_ethtool_id_is_feature (ethtool_id))
|
|
|
|
|
return G_VARIANT_TYPE_BOOLEAN;
|
|
|
|
|
|
|
|
|
|
if ( nm_ethtool_id_is_coalesce (ethtool_id)
|
|
|
|
|
|| nm_ethtool_id_is_ring (ethtool_id))
|
|
|
|
|
return G_VARIANT_TYPE_UINT32;
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
libnm, cli, ifcfg-rh: add NMSettingEthtool setting
Note that in NetworkManager API (D-Bus, libnm, and nmcli),
the features are called "feature-xyz". The "feature-" prefix
is used, because NMSettingEthtool possibly will gain support
for options that are not only -K|--offload|--features, for
example -C|--coalesce.
The "xzy" suffix is either how ethtool utility calls the feature
("tso", "rx"). Or, if ethtool utility specifies no alias for that
feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
If possible, we prefer ethtool utility's naming.
Also note, how the features "feature-sg", "feature-tso", and
"feature-tx" actually refer to multiple underlying kernel features
at once. This too follows what ethtool utility does.
The functionality is not yet implemented server-side.
2018-07-16 23:37:55 +02:00
|
|
|
/**
|
|
|
|
|
* nm_ethtool_optname_is_feature:
|
2019-06-11 14:47:26 +02:00
|
|
|
* @optname: (allow-none): the option name to check
|
libnm, cli, ifcfg-rh: add NMSettingEthtool setting
Note that in NetworkManager API (D-Bus, libnm, and nmcli),
the features are called "feature-xyz". The "feature-" prefix
is used, because NMSettingEthtool possibly will gain support
for options that are not only -K|--offload|--features, for
example -C|--coalesce.
The "xzy" suffix is either how ethtool utility calls the feature
("tso", "rx"). Or, if ethtool utility specifies no alias for that
feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
If possible, we prefer ethtool utility's naming.
Also note, how the features "feature-sg", "feature-tso", and
"feature-tx" actually refer to multiple underlying kernel features
at once. This too follows what ethtool utility does.
The functionality is not yet implemented server-side.
2018-07-16 23:37:55 +02:00
|
|
|
*
|
|
|
|
|
* Checks whether @optname is a valid option name for an offload feature.
|
|
|
|
|
*
|
|
|
|
|
* %Returns: %TRUE, if @optname is valid
|
|
|
|
|
*
|
2019-06-11 14:47:26 +02:00
|
|
|
* Since: 1.20
|
|
|
|
|
*
|
|
|
|
|
* Note that nm_ethtool_optname_is_feature() was first added to the libnm header files
|
|
|
|
|
* in 1.14.0 but forgot to actually add to the library. This happened belatedly in 1.20.0 and
|
|
|
|
|
* the stable versions 1.18.2, 1.16.4 and 1.14.8 (with linker version "libnm_1_14_8").
|
libnm, cli, ifcfg-rh: add NMSettingEthtool setting
Note that in NetworkManager API (D-Bus, libnm, and nmcli),
the features are called "feature-xyz". The "feature-" prefix
is used, because NMSettingEthtool possibly will gain support
for options that are not only -K|--offload|--features, for
example -C|--coalesce.
The "xzy" suffix is either how ethtool utility calls the feature
("tso", "rx"). Or, if ethtool utility specifies no alias for that
feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
If possible, we prefer ethtool utility's naming.
Also note, how the features "feature-sg", "feature-tso", and
"feature-tx" actually refer to multiple underlying kernel features
at once. This too follows what ethtool utility does.
The functionality is not yet implemented server-side.
2018-07-16 23:37:55 +02:00
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_ethtool_optname_is_feature (const char *optname)
|
|
|
|
|
{
|
|
|
|
|
return optname && nm_ethtool_id_is_feature (nm_ethtool_id_get_by_name (optname));
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-07 16:58:32 +02:00
|
|
|
/**
|
|
|
|
|
* nm_ethtool_optname_is_coalesce:
|
|
|
|
|
* @optname: (allow-none): the option name to check
|
|
|
|
|
*
|
|
|
|
|
* Checks whether @optname is a valid option name for a coalesce setting.
|
|
|
|
|
*
|
|
|
|
|
* %Returns: %TRUE, if @optname is valid
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.26
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_ethtool_optname_is_coalesce (const char *optname)
|
|
|
|
|
{
|
|
|
|
|
return optname && nm_ethtool_id_is_coalesce (nm_ethtool_id_get_by_name (optname));
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-12 17:27:45 +02:00
|
|
|
/**
|
|
|
|
|
* nm_ethtool_optname_is_ring:
|
|
|
|
|
* @optname: (allow-none): the option name to check
|
|
|
|
|
*
|
|
|
|
|
* Checks whether @optname is a valid option name for a ring setting.
|
|
|
|
|
*
|
|
|
|
|
* %Returns: %TRUE, if @optname is valid
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.26
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_ethtool_optname_is_ring (const char *optname)
|
|
|
|
|
{
|
|
|
|
|
return optname && nm_ethtool_id_is_ring (nm_ethtool_id_get_by_name (optname));
|
|
|
|
|
}
|
|
|
|
|
|
libnm, cli, ifcfg-rh: add NMSettingEthtool setting
Note that in NetworkManager API (D-Bus, libnm, and nmcli),
the features are called "feature-xyz". The "feature-" prefix
is used, because NMSettingEthtool possibly will gain support
for options that are not only -K|--offload|--features, for
example -C|--coalesce.
The "xzy" suffix is either how ethtool utility calls the feature
("tso", "rx"). Or, if ethtool utility specifies no alias for that
feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
If possible, we prefer ethtool utility's naming.
Also note, how the features "feature-sg", "feature-tso", and
"feature-tx" actually refer to multiple underlying kernel features
at once. This too follows what ethtool utility does.
The functionality is not yet implemented server-side.
2018-07-16 23:37:55 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingEthtool:
|
|
|
|
|
*
|
|
|
|
|
* Ethtool Ethernet Settings
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.14
|
|
|
|
|
*/
|
|
|
|
|
struct _NMSettingEthtool {
|
|
|
|
|
NMSetting parent;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct _NMSettingEthtoolClass {
|
|
|
|
|
NMSettingClass parent;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (NMSettingEthtool, nm_setting_ethtool, NM_TYPE_SETTING)
|
|
|
|
|
|
|
|
|
|
#define NM_SETTING_ETHTOOL_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMSettingEthtool, NM_IS_SETTING_ETHTOOL, NMSetting)
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_ethtool_get_feature:
|
|
|
|
|
* @setting: the #NMSettingEthtool
|
|
|
|
|
* @optname: option name of the offload feature to get
|
|
|
|
|
*
|
|
|
|
|
* Gets and offload feature setting. Returns %NM_TERNARY_DEFAULT if the
|
|
|
|
|
* feature is not set.
|
|
|
|
|
*
|
2019-06-11 11:20:53 +02:00
|
|
|
* Note that @optname must be a valid name for a feature, according to
|
|
|
|
|
* nm_ethtool_optname_is_feature().
|
|
|
|
|
*
|
libnm, cli, ifcfg-rh: add NMSettingEthtool setting
Note that in NetworkManager API (D-Bus, libnm, and nmcli),
the features are called "feature-xyz". The "feature-" prefix
is used, because NMSettingEthtool possibly will gain support
for options that are not only -K|--offload|--features, for
example -C|--coalesce.
The "xzy" suffix is either how ethtool utility calls the feature
("tso", "rx"). Or, if ethtool utility specifies no alias for that
feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
If possible, we prefer ethtool utility's naming.
Also note, how the features "feature-sg", "feature-tso", and
"feature-tx" actually refer to multiple underlying kernel features
at once. This too follows what ethtool utility does.
The functionality is not yet implemented server-side.
2018-07-16 23:37:55 +02:00
|
|
|
* Returns: a #NMTernary value indicating whether the offload feature
|
|
|
|
|
* is enabled, disabled, or left untouched.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.14
|
2020-05-14 09:16:34 +02:00
|
|
|
*
|
|
|
|
|
* Deprecated: 1.26: use nm_setting_option_get_boolean() instead.
|
libnm, cli, ifcfg-rh: add NMSettingEthtool setting
Note that in NetworkManager API (D-Bus, libnm, and nmcli),
the features are called "feature-xyz". The "feature-" prefix
is used, because NMSettingEthtool possibly will gain support
for options that are not only -K|--offload|--features, for
example -C|--coalesce.
The "xzy" suffix is either how ethtool utility calls the feature
("tso", "rx"). Or, if ethtool utility specifies no alias for that
feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
If possible, we prefer ethtool utility's naming.
Also note, how the features "feature-sg", "feature-tso", and
"feature-tx" actually refer to multiple underlying kernel features
at once. This too follows what ethtool utility does.
The functionality is not yet implemented server-side.
2018-07-16 23:37:55 +02:00
|
|
|
*/
|
|
|
|
|
NMTernary
|
|
|
|
|
nm_setting_ethtool_get_feature (NMSettingEthtool *setting,
|
|
|
|
|
const char *optname)
|
|
|
|
|
{
|
2020-05-14 09:16:33 +02:00
|
|
|
gboolean v;
|
libnm, cli, ifcfg-rh: add NMSettingEthtool setting
Note that in NetworkManager API (D-Bus, libnm, and nmcli),
the features are called "feature-xyz". The "feature-" prefix
is used, because NMSettingEthtool possibly will gain support
for options that are not only -K|--offload|--features, for
example -C|--coalesce.
The "xzy" suffix is either how ethtool utility calls the feature
("tso", "rx"). Or, if ethtool utility specifies no alias for that
feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
If possible, we prefer ethtool utility's naming.
Also note, how the features "feature-sg", "feature-tso", and
"feature-tx" actually refer to multiple underlying kernel features
at once. This too follows what ethtool utility does.
The functionality is not yet implemented server-side.
2018-07-16 23:37:55 +02:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_ETHTOOL (setting), NM_TERNARY_DEFAULT);
|
|
|
|
|
g_return_val_if_fail (optname && nm_ethtool_optname_is_feature (optname), NM_TERNARY_DEFAULT);
|
|
|
|
|
|
2020-05-14 09:16:33 +02:00
|
|
|
if (!nm_setting_option_get_boolean (NM_SETTING (setting), optname, &v))
|
|
|
|
|
return NM_TERNARY_DEFAULT;
|
|
|
|
|
return v
|
|
|
|
|
? NM_TERNARY_TRUE
|
|
|
|
|
: NM_TERNARY_FALSE;
|
libnm, cli, ifcfg-rh: add NMSettingEthtool setting
Note that in NetworkManager API (D-Bus, libnm, and nmcli),
the features are called "feature-xyz". The "feature-" prefix
is used, because NMSettingEthtool possibly will gain support
for options that are not only -K|--offload|--features, for
example -C|--coalesce.
The "xzy" suffix is either how ethtool utility calls the feature
("tso", "rx"). Or, if ethtool utility specifies no alias for that
feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
If possible, we prefer ethtool utility's naming.
Also note, how the features "feature-sg", "feature-tso", and
"feature-tx" actually refer to multiple underlying kernel features
at once. This too follows what ethtool utility does.
The functionality is not yet implemented server-side.
2018-07-16 23:37:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_ethtool_set_feature:
|
|
|
|
|
* @setting: the #NMSettingEthtool
|
|
|
|
|
* @optname: option name of the offload feature to get
|
|
|
|
|
* @value: the new value to set. The special value %NM_TERNARY_DEFAULT
|
|
|
|
|
* means to clear the offload feature setting.
|
|
|
|
|
*
|
|
|
|
|
* Sets and offload feature setting.
|
|
|
|
|
*
|
2019-06-11 11:20:53 +02:00
|
|
|
* Note that @optname must be a valid name for a feature, according to
|
|
|
|
|
* nm_ethtool_optname_is_feature().
|
|
|
|
|
*
|
libnm, cli, ifcfg-rh: add NMSettingEthtool setting
Note that in NetworkManager API (D-Bus, libnm, and nmcli),
the features are called "feature-xyz". The "feature-" prefix
is used, because NMSettingEthtool possibly will gain support
for options that are not only -K|--offload|--features, for
example -C|--coalesce.
The "xzy" suffix is either how ethtool utility calls the feature
("tso", "rx"). Or, if ethtool utility specifies no alias for that
feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
If possible, we prefer ethtool utility's naming.
Also note, how the features "feature-sg", "feature-tso", and
"feature-tx" actually refer to multiple underlying kernel features
at once. This too follows what ethtool utility does.
The functionality is not yet implemented server-side.
2018-07-16 23:37:55 +02:00
|
|
|
* Since: 1.14
|
2020-05-14 09:16:34 +02:00
|
|
|
*
|
|
|
|
|
* Deprecated: 1.26: use nm_setting_option_set() or nm_setting_option_set_boolean() instead.
|
libnm, cli, ifcfg-rh: add NMSettingEthtool setting
Note that in NetworkManager API (D-Bus, libnm, and nmcli),
the features are called "feature-xyz". The "feature-" prefix
is used, because NMSettingEthtool possibly will gain support
for options that are not only -K|--offload|--features, for
example -C|--coalesce.
The "xzy" suffix is either how ethtool utility calls the feature
("tso", "rx"). Or, if ethtool utility specifies no alias for that
feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
If possible, we prefer ethtool utility's naming.
Also note, how the features "feature-sg", "feature-tso", and
"feature-tx" actually refer to multiple underlying kernel features
at once. This too follows what ethtool utility does.
The functionality is not yet implemented server-side.
2018-07-16 23:37:55 +02:00
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
nm_setting_ethtool_set_feature (NMSettingEthtool *setting,
|
|
|
|
|
const char *optname,
|
|
|
|
|
NMTernary value)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (NM_IS_SETTING_ETHTOOL (setting));
|
|
|
|
|
g_return_if_fail (optname && nm_ethtool_optname_is_feature (optname));
|
|
|
|
|
g_return_if_fail (NM_IN_SET (value, NM_TERNARY_DEFAULT,
|
|
|
|
|
NM_TERNARY_FALSE,
|
|
|
|
|
NM_TERNARY_TRUE));
|
|
|
|
|
|
2020-05-14 09:16:33 +02:00
|
|
|
if (value == NM_TERNARY_DEFAULT)
|
|
|
|
|
nm_setting_option_set (NM_SETTING (setting), optname, NULL);
|
|
|
|
|
else
|
|
|
|
|
nm_setting_option_set_boolean (NM_SETTING (setting), optname, (value != NM_TERNARY_FALSE));
|
libnm, cli, ifcfg-rh: add NMSettingEthtool setting
Note that in NetworkManager API (D-Bus, libnm, and nmcli),
the features are called "feature-xyz". The "feature-" prefix
is used, because NMSettingEthtool possibly will gain support
for options that are not only -K|--offload|--features, for
example -C|--coalesce.
The "xzy" suffix is either how ethtool utility calls the feature
("tso", "rx"). Or, if ethtool utility specifies no alias for that
feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
If possible, we prefer ethtool utility's naming.
Also note, how the features "feature-sg", "feature-tso", and
"feature-tx" actually refer to multiple underlying kernel features
at once. This too follows what ethtool utility does.
The functionality is not yet implemented server-side.
2018-07-16 23:37:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_ethtool_clear_features:
|
|
|
|
|
* @setting: the #NMSettingEthtool
|
|
|
|
|
*
|
|
|
|
|
* Clears all offload features settings
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.14
|
2020-05-14 09:16:34 +02:00
|
|
|
*
|
|
|
|
|
* Deprecated: 1.26: use nm_setting_option_clear_by_name() with nm_ethtool_optname_is_feature() predicate instead.
|
libnm, cli, ifcfg-rh: add NMSettingEthtool setting
Note that in NetworkManager API (D-Bus, libnm, and nmcli),
the features are called "feature-xyz". The "feature-" prefix
is used, because NMSettingEthtool possibly will gain support
for options that are not only -K|--offload|--features, for
example -C|--coalesce.
The "xzy" suffix is either how ethtool utility calls the feature
("tso", "rx"). Or, if ethtool utility specifies no alias for that
feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
If possible, we prefer ethtool utility's naming.
Also note, how the features "feature-sg", "feature-tso", and
"feature-tx" actually refer to multiple underlying kernel features
at once. This too follows what ethtool utility does.
The functionality is not yet implemented server-side.
2018-07-16 23:37:55 +02:00
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
nm_setting_ethtool_clear_features (NMSettingEthtool *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (NM_IS_SETTING_ETHTOOL (setting));
|
|
|
|
|
|
2020-05-14 09:16:33 +02:00
|
|
|
nm_setting_option_clear_by_name (NM_SETTING (setting),
|
|
|
|
|
nm_ethtool_optname_is_feature);
|
libnm, cli, ifcfg-rh: add NMSettingEthtool setting
Note that in NetworkManager API (D-Bus, libnm, and nmcli),
the features are called "feature-xyz". The "feature-" prefix
is used, because NMSettingEthtool possibly will gain support
for options that are not only -K|--offload|--features, for
example -C|--coalesce.
The "xzy" suffix is either how ethtool utility calls the feature
("tso", "rx"). Or, if ethtool utility specifies no alias for that
feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
If possible, we prefer ethtool utility's naming.
Also note, how the features "feature-sg", "feature-tso", and
"feature-tx" actually refer to multiple underlying kernel features
at once. This too follows what ethtool utility does.
The functionality is not yet implemented server-side.
2018-07-16 23:37:55 +02:00
|
|
|
}
|
|
|
|
|
|
2020-05-14 20:57:53 +02:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
libnm, cli, ifcfg-rh: add NMSettingEthtool setting
Note that in NetworkManager API (D-Bus, libnm, and nmcli),
the features are called "feature-xyz". The "feature-" prefix
is used, because NMSettingEthtool possibly will gain support
for options that are not only -K|--offload|--features, for
example -C|--coalesce.
The "xzy" suffix is either how ethtool utility calls the feature
("tso", "rx"). Or, if ethtool utility specifies no alias for that
feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
If possible, we prefer ethtool utility's naming.
Also note, how the features "feature-sg", "feature-tso", and
"feature-tx" actually refer to multiple underlying kernel features
at once. This too follows what ethtool utility does.
The functionality is not yet implemented server-side.
2018-07-16 23:37:55 +02:00
|
|
|
guint
|
|
|
|
|
nm_setting_ethtool_init_features (NMSettingEthtool *setting,
|
|
|
|
|
NMTernary *requested /* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */)
|
|
|
|
|
{
|
|
|
|
|
GHashTable *hash;
|
|
|
|
|
GHashTableIter iter;
|
|
|
|
|
guint i;
|
|
|
|
|
guint n_req = 0;
|
|
|
|
|
const char *name;
|
|
|
|
|
GVariant *variant;
|
|
|
|
|
|
|
|
|
|
nm_assert (NM_IS_SETTING_ETHTOOL (setting));
|
|
|
|
|
nm_assert (requested);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < _NM_ETHTOOL_ID_FEATURE_NUM; i++)
|
|
|
|
|
requested[i] = NM_TERNARY_DEFAULT;
|
|
|
|
|
|
2020-05-14 09:16:32 +02:00
|
|
|
hash = _nm_setting_option_hash (NM_SETTING (setting), FALSE);
|
libnm, cli, ifcfg-rh: add NMSettingEthtool setting
Note that in NetworkManager API (D-Bus, libnm, and nmcli),
the features are called "feature-xyz". The "feature-" prefix
is used, because NMSettingEthtool possibly will gain support
for options that are not only -K|--offload|--features, for
example -C|--coalesce.
The "xzy" suffix is either how ethtool utility calls the feature
("tso", "rx"). Or, if ethtool utility specifies no alias for that
feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
If possible, we prefer ethtool utility's naming.
Also note, how the features "feature-sg", "feature-tso", and
"feature-tx" actually refer to multiple underlying kernel features
at once. This too follows what ethtool utility does.
The functionality is not yet implemented server-side.
2018-07-16 23:37:55 +02:00
|
|
|
if (!hash)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
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_feature (ethtool_id))
|
|
|
|
|
continue;
|
|
|
|
|
if (!g_variant_is_of_type (variant, G_VARIANT_TYPE_BOOLEAN))
|
|
|
|
|
continue;
|
|
|
|
|
|
2020-05-14 21:20:05 +02:00
|
|
|
requested[_NM_ETHTOOL_ID_FEATURE_AS_IDX (ethtool_id)] = g_variant_get_boolean (variant)
|
|
|
|
|
? NM_TERNARY_TRUE
|
|
|
|
|
: NM_TERNARY_FALSE;
|
libnm, cli, ifcfg-rh: add NMSettingEthtool setting
Note that in NetworkManager API (D-Bus, libnm, and nmcli),
the features are called "feature-xyz". The "feature-" prefix
is used, because NMSettingEthtool possibly will gain support
for options that are not only -K|--offload|--features, for
example -C|--coalesce.
The "xzy" suffix is either how ethtool utility calls the feature
("tso", "rx"). Or, if ethtool utility specifies no alias for that
feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
If possible, we prefer ethtool utility's naming.
Also note, how the features "feature-sg", "feature-tso", and
"feature-tx" actually refer to multiple underlying kernel features
at once. This too follows what ethtool utility does.
The functionality is not yet implemented server-side.
2018-07-16 23:37:55 +02:00
|
|
|
n_req++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return n_req;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-06-11 11:20:53 +02:00
|
|
|
/**
|
|
|
|
|
* nm_setting_ethtool_get_optnames:
|
|
|
|
|
* @setting: the #NMSettingEthtool instance.
|
|
|
|
|
* @out_length: (out) (optional): return location for the number of keys returned, or %NULL
|
|
|
|
|
*
|
|
|
|
|
* This returns all options names that are set. This includes the feature names
|
|
|
|
|
* like %NM_ETHTOOL_OPTNAME_FEATURE_GRO. See nm_ethtool_optname_is_feature() to
|
|
|
|
|
* check whether the option name is valid for offload features.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (array zero-terminated=1) (transfer container): list of set option
|
|
|
|
|
* names or %NULL if no options are set. The option names are still owned by
|
|
|
|
|
* @setting and may get invalidated when @setting gets modified.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.20
|
2020-05-14 09:16:34 +02:00
|
|
|
*
|
|
|
|
|
* Deprecated: 1.26: use nm_setting_option_get_all_names() instead.
|
2019-06-11 11:20:53 +02:00
|
|
|
*/
|
|
|
|
|
const char **
|
|
|
|
|
nm_setting_ethtool_get_optnames (NMSettingEthtool *setting,
|
|
|
|
|
guint *out_length)
|
|
|
|
|
{
|
2020-05-14 09:16:33 +02:00
|
|
|
const char *const*names;
|
|
|
|
|
guint len;
|
|
|
|
|
|
2019-06-11 11:20:53 +02:00
|
|
|
g_return_val_if_fail (NM_IS_SETTING_ETHTOOL (setting), NULL);
|
|
|
|
|
|
2020-05-14 09:16:33 +02:00
|
|
|
names = nm_setting_option_get_all_names (NM_SETTING (setting), &len);
|
|
|
|
|
NM_SET_OUT (out_length, len);
|
|
|
|
|
return len > 0
|
|
|
|
|
? nm_memdup (names, sizeof (names[0]) * (((gsize) len) + 1u))
|
|
|
|
|
: NULL;
|
2019-06-11 11:20:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
libnm, cli, ifcfg-rh: add NMSettingEthtool setting
Note that in NetworkManager API (D-Bus, libnm, and nmcli),
the features are called "feature-xyz". The "feature-" prefix
is used, because NMSettingEthtool possibly will gain support
for options that are not only -K|--offload|--features, for
example -C|--coalesce.
The "xzy" suffix is either how ethtool utility calls the feature
("tso", "rx"). Or, if ethtool utility specifies no alias for that
feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
If possible, we prefer ethtool utility's naming.
Also note, how the features "feature-sg", "feature-tso", and
"feature-tx" actually refer to multiple underlying kernel features
at once. This too follows what ethtool utility does.
The functionality is not yet implemented server-side.
2018-07-16 23:37:55 +02:00
|
|
|
static gboolean
|
|
|
|
|
verify (NMSetting *setting, NMConnection *connection, GError **error)
|
|
|
|
|
{
|
2020-05-14 20:57:53 +02:00
|
|
|
const char *const*optnames;
|
|
|
|
|
GVariant *const*variants;
|
|
|
|
|
guint len;
|
|
|
|
|
guint i;
|
libnm, cli, ifcfg-rh: add NMSettingEthtool setting
Note that in NetworkManager API (D-Bus, libnm, and nmcli),
the features are called "feature-xyz". The "feature-" prefix
is used, because NMSettingEthtool possibly will gain support
for options that are not only -K|--offload|--features, for
example -C|--coalesce.
The "xzy" suffix is either how ethtool utility calls the feature
("tso", "rx"). Or, if ethtool utility specifies no alias for that
feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
If possible, we prefer ethtool utility's naming.
Also note, how the features "feature-sg", "feature-tso", and
"feature-tx" actually refer to multiple underlying kernel features
at once. This too follows what ethtool utility does.
The functionality is not yet implemented server-side.
2018-07-16 23:37:55 +02:00
|
|
|
|
2020-05-14 20:57:53 +02:00
|
|
|
len = _nm_setting_option_get_all (setting, &optnames, &variants);
|
libnm, cli, ifcfg-rh: add NMSettingEthtool setting
Note that in NetworkManager API (D-Bus, libnm, and nmcli),
the features are called "feature-xyz". The "feature-" prefix
is used, because NMSettingEthtool possibly will gain support
for options that are not only -K|--offload|--features, for
example -C|--coalesce.
The "xzy" suffix is either how ethtool utility calls the feature
("tso", "rx"). Or, if ethtool utility specifies no alias for that
feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
If possible, we prefer ethtool utility's naming.
Also note, how the features "feature-sg", "feature-tso", and
"feature-tx" actually refer to multiple underlying kernel features
at once. This too follows what ethtool utility does.
The functionality is not yet implemented server-side.
2018-07-16 23:37:55 +02:00
|
|
|
|
2020-05-14 20:57:53 +02:00
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
|
const char *optname = optnames[i];
|
|
|
|
|
GVariant *variant = variants[i];
|
2020-05-14 09:16:32 +02:00
|
|
|
const GVariantType *variant_type;
|
|
|
|
|
NMEthtoolID ethtool_id;
|
|
|
|
|
|
|
|
|
|
ethtool_id = nm_ethtool_id_get_by_name (optname);
|
|
|
|
|
variant_type = get_variant_type_from_ethtool_id (ethtool_id);
|
|
|
|
|
|
|
|
|
|
if (!variant_type) {
|
libnm, cli, ifcfg-rh: add NMSettingEthtool setting
Note that in NetworkManager API (D-Bus, libnm, and nmcli),
the features are called "feature-xyz". The "feature-" prefix
is used, because NMSettingEthtool possibly will gain support
for options that are not only -K|--offload|--features, for
example -C|--coalesce.
The "xzy" suffix is either how ethtool utility calls the feature
("tso", "rx"). Or, if ethtool utility specifies no alias for that
feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
If possible, we prefer ethtool utility's naming.
Also note, how the features "feature-sg", "feature-tso", and
"feature-tx" actually refer to multiple underlying kernel features
at once. This too follows what ethtool utility does.
The functionality is not yet implemented server-side.
2018-07-16 23:37:55 +02:00
|
|
|
g_set_error_literal (error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
2020-05-07 16:58:32 +02:00
|
|
|
_("unsupported ethtool setting"));
|
libnm, cli, ifcfg-rh: add NMSettingEthtool setting
Note that in NetworkManager API (D-Bus, libnm, and nmcli),
the features are called "feature-xyz". The "feature-" prefix
is used, because NMSettingEthtool possibly will gain support
for options that are not only -K|--offload|--features, for
example -C|--coalesce.
The "xzy" suffix is either how ethtool utility calls the feature
("tso", "rx"). Or, if ethtool utility specifies no alias for that
feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
If possible, we prefer ethtool utility's naming.
Also note, how the features "feature-sg", "feature-tso", and
"feature-tx" actually refer to multiple underlying kernel features
at once. This too follows what ethtool utility does.
The functionality is not yet implemented server-side.
2018-07-16 23:37:55 +02:00
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_ETHTOOL_SETTING_NAME, optname);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2020-05-14 09:16:32 +02:00
|
|
|
|
|
|
|
|
if (!g_variant_is_of_type (variant, variant_type)) {
|
|
|
|
|
g_set_error_literal (error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("setting has invalid variant type"));
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_ETHTOOL_SETTING_NAME, optname);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2020-05-14 09:16:32 +02:00
|
|
|
|
|
|
|
|
if (NM_IN_SET (ethtool_id,
|
|
|
|
|
NM_ETHTOOL_ID_COALESCE_ADAPTIVE_RX,
|
|
|
|
|
NM_ETHTOOL_ID_COALESCE_ADAPTIVE_TX)) {
|
|
|
|
|
if (!NM_IN_SET (g_variant_get_uint32 (variant), 0, 1)) {
|
|
|
|
|
g_set_error_literal (error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("coalesce option must be either 0 or 1"));
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_ETHTOOL_SETTING_NAME, optname);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
libnm, cli, ifcfg-rh: add NMSettingEthtool setting
Note that in NetworkManager API (D-Bus, libnm, and nmcli),
the features are called "feature-xyz". The "feature-" prefix
is used, because NMSettingEthtool possibly will gain support
for options that are not only -K|--offload|--features, for
example -C|--coalesce.
The "xzy" suffix is either how ethtool utility calls the feature
("tso", "rx"). Or, if ethtool utility specifies no alias for that
feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
If possible, we prefer ethtool utility's naming.
Also note, how the features "feature-sg", "feature-tso", and
"feature-tx" actually refer to multiple underlying kernel features
at once. This too follows what ethtool utility does.
The functionality is not yet implemented server-side.
2018-07-16 23:37:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static const GVariantType *
|
|
|
|
|
get_variant_type (const NMSettInfoSetting *sett_info,
|
|
|
|
|
const char *name,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
2020-05-14 09:16:32 +02:00
|
|
|
const GVariantType *variant_type;
|
2020-05-12 17:27:45 +02:00
|
|
|
|
2020-05-14 09:16:32 +02:00
|
|
|
variant_type = get_variant_type_from_ethtool_id (nm_ethtool_id_get_by_name (name));
|
libnm, cli, ifcfg-rh: add NMSettingEthtool setting
Note that in NetworkManager API (D-Bus, libnm, and nmcli),
the features are called "feature-xyz". The "feature-" prefix
is used, because NMSettingEthtool possibly will gain support
for options that are not only -K|--offload|--features, for
example -C|--coalesce.
The "xzy" suffix is either how ethtool utility calls the feature
("tso", "rx"). Or, if ethtool utility specifies no alias for that
feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
If possible, we prefer ethtool utility's naming.
Also note, how the features "feature-sg", "feature-tso", and
"feature-tx" actually refer to multiple underlying kernel features
at once. This too follows what ethtool utility does.
The functionality is not yet implemented server-side.
2018-07-16 23:37:55 +02:00
|
|
|
|
2020-05-14 09:16:32 +02:00
|
|
|
if (!variant_type) {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("unknown ethtool option '%s'"),
|
|
|
|
|
name);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2020-05-07 16:58:32 +02:00
|
|
|
|
2020-05-14 09:16:32 +02:00
|
|
|
return variant_type;
|
libnm, cli, ifcfg-rh: add NMSettingEthtool setting
Note that in NetworkManager API (D-Bus, libnm, and nmcli),
the features are called "feature-xyz". The "feature-" prefix
is used, because NMSettingEthtool possibly will gain support
for options that are not only -K|--offload|--features, for
example -C|--coalesce.
The "xzy" suffix is either how ethtool utility calls the feature
("tso", "rx"). Or, if ethtool utility specifies no alias for that
feature, it's the name from kernel's ETH_SS_FEATURES ("tx-tcp6-segmentation").
If possible, we prefer ethtool utility's naming.
Also note, how the features "feature-sg", "feature-tso", and
"feature-tx" actually refer to multiple underlying kernel features
at once. This too follows what ethtool utility does.
The functionality is not yet implemented server-side.
2018-07-16 23:37:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_setting_ethtool_init (NMSettingEthtool *setting)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_ethtool_new:
|
|
|
|
|
*
|
|
|
|
|
* Creates a new #NMSettingEthtool object with default values.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer full): the new empty #NMSettingEthtool object
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.14
|
|
|
|
|
**/
|
|
|
|
|
NMSetting *
|
|
|
|
|
nm_setting_ethtool_new (void)
|
|
|
|
|
{
|
|
|
|
|
return g_object_new (NM_TYPE_SETTING_ETHTOOL, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_setting_ethtool_class_init (NMSettingEthtoolClass *klass)
|
|
|
|
|
{
|
|
|
|
|
NMSettingClass *setting_class = NM_SETTING_CLASS (klass);
|
|
|
|
|
|
|
|
|
|
setting_class->verify = verify;
|
|
|
|
|
|
|
|
|
|
_nm_setting_class_commit_full (setting_class,
|
|
|
|
|
NM_META_SETTING_TYPE_ETHTOOL,
|
|
|
|
|
NM_SETT_INFO_SETT_DETAIL (
|
|
|
|
|
.gendata_info = NM_SETT_INFO_SETT_GENDATA (
|
|
|
|
|
.get_variant_type = get_variant_type,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
NULL);
|
|
|
|
|
}
|