From b0d5386de3b97be1a030c12766e606c8aa162a12 Mon Sep 17 00:00:00 2001 From: Fernando Fernandez Mancera Date: Tue, 19 Mar 2024 13:03:28 +0100 Subject: [PATCH] fixup! WIP: support ethtool Forward Error Correction(fec) Declare NMEthtoolFec in nm-base.h instead of exposing it in libnm setting. For Ethtool features we do not expose the enum values. --- src/core/devices/nm-device.c | 14 ++----------- src/libnm-base/nm-base.h | 10 --------- src/libnm-core-public/nm-setting-ethtool.h | 24 ---------------------- src/libnm-platform/nm-platform-utils.c | 4 ++-- src/libnm-platform/nm-platform-utils.h | 2 +- src/libnm-platform/nm-platform.c | 2 +- src/libnm-platform/nm-platform.h | 2 +- src/libnm-platform/nmp-base.h | 9 ++++++++ 8 files changed, 16 insertions(+), 51 deletions(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 984ce825b0..fac623d182 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -2451,20 +2451,12 @@ _ethtool_features_reset(NMDevice *self, NMPlatform *platform, EthtoolState *etht _LOGD(LOGD_DEVICE, "ethtool: offload features successfully reset"); } -static inline _NMEthtoolFec -_NM_ETHTOOL_FEC_CAST(NMEthtoolFec v) -{ - return (_NMEthtoolFec) v; -} - static void _ethtool_fec_reset(NMDevice *self, NMPlatform *platform, EthtoolState *ethtool_state) { gs_free NMEthtoolFeatureStates *features = NULL; - if (!nm_platform_ethtool_set_fec(platform, - ethtool_state->ifindex, - _NM_ETHTOOL_FEC_CAST(NM_ETHTOOL_FEC_AUTO))) + if (!nm_platform_ethtool_set_fec(platform, ethtool_state->ifindex, NM_ETHTOOL_FEC_AUTO)) _LOGW(LOGD_DEVICE, "ethtool: failure resetting FEC"); else _LOGD(LOGD_DEVICE, "ethtool: FEC reset to auto"); @@ -2513,9 +2505,7 @@ _ethtool_fec_set(NMDevice *self, return; } - if (!nm_platform_ethtool_set_fec(platform, - ethtool_state->ifindex, - _NM_ETHTOOL_FEC_CAST(fec_mode))) + if (!nm_platform_ethtool_set_fec(platform, ethtool_state->ifindex, fec_mode)) _LOGW(LOGD_DEVICE, "ethtool: failure setting FEC %d", fec_mode); else _LOGD(LOGD_DEVICE, "ethtool: FEC %d successfully set", fec_mode); diff --git a/src/libnm-base/nm-base.h b/src/libnm-base/nm-base.h index 080a6a92c7..8dcddb991d 100644 --- a/src/libnm-base/nm-base.h +++ b/src/libnm-base/nm-base.h @@ -211,16 +211,6 @@ nm_ethtool_id_is_fec(NMEthtoolID id) return id == NM_ETHTOOL_ID_FEC; } -typedef enum { - // Mirrors libnm's NMEthtoolFec. - _NM_ETHTOOL_FEC_NONE = ETHTOOL_FEC_NONE, - _NM_ETHTOOL_FEC_AUTO = ETHTOOL_FEC_AUTO, - _NM_ETHTOOL_FEC_OFF = ETHTOOL_FEC_OFF, - _NM_ETHTOOL_FEC_RS = ETHTOOL_FEC_RS, - _NM_ETHTOOL_FEC_BASER = ETHTOOL_FEC_BASER, - _NM_ETHTOOL_FEC_LLRS = ETHTOOL_FEC_LLRS, -} _NMEthtoolFec; - /*****************************************************************************/ typedef enum { diff --git a/src/libnm-core-public/nm-setting-ethtool.h b/src/libnm-core-public/nm-setting-ethtool.h index b6a36eff69..a304c22e64 100644 --- a/src/libnm-core-public/nm-setting-ethtool.h +++ b/src/libnm-core-public/nm-setting-ethtool.h @@ -11,33 +11,9 @@ #endif #include "nm-setting.h" -#include G_BEGIN_DECLS -/** - * NMEthtoolFec: - * @NM_ETHTOOL_FEC_NONE: Internal use only - * @NM_ETHTOOL_FEC_AUTO: Select default/best FEC mode automatically - * @NM_ETHTOOL_FEC_OFF: No FEC Mode - * @NM_ETHTOOL_FEC_RS: Reed-Solomon FEC Mode - * @NM_ETHTOOL_FEC_BASER: Base-R/Reed-Solomon FEC Mode - * @NM_ETHTOOL_FEC_LLRS: Low Latency Reed Solomon FEC Mode - * - * #NMEthtoolFec describe ethtool Forward Error Correction(FEC) encoding modes. - * FQDN. - * - * Since: 1.48 - */ -typedef enum /*< flags >*/ { - NM_ETHTOOL_FEC_NONE = ETHTOOL_FEC_NONE, - NM_ETHTOOL_FEC_AUTO = ETHTOOL_FEC_AUTO, - NM_ETHTOOL_FEC_OFF = ETHTOOL_FEC_OFF, - NM_ETHTOOL_FEC_RS = ETHTOOL_FEC_RS, - NM_ETHTOOL_FEC_BASER = ETHTOOL_FEC_BASER, - NM_ETHTOOL_FEC_LLRS = ETHTOOL_FEC_LLRS, -} NMEthtoolFec; - NM_AVAILABLE_IN_1_20 gboolean nm_ethtool_optname_is_feature(const char *optname); diff --git a/src/libnm-platform/nm-platform-utils.c b/src/libnm-platform/nm-platform-utils.c index 5270757992..ba236fcf62 100644 --- a/src/libnm-platform/nm-platform-utils.c +++ b/src/libnm-platform/nm-platform-utils.c @@ -1819,7 +1819,7 @@ nmp_utils_ethtool_set_wake_on_lan(int ifindex, } gboolean -nmp_utils_ethtool_set_fec(int ifindex, const _NMEthtoolFec fec) +nmp_utils_ethtool_set_fec(int ifindex, const NMEthtoolFec fec) { struct ethtool_fecparam fec_param = { .cmd = ETHTOOL_SFECPARAM, @@ -1828,7 +1828,7 @@ nmp_utils_ethtool_set_fec(int ifindex, const _NMEthtoolFec fec) g_return_val_if_fail(ifindex > 0, FALSE); - if (fec == _NM_ETHTOOL_FEC_NONE) + if (fec == NM_ETHTOOL_FEC_NONE) return TRUE; nm_log_dbg(LOGD_PLATFORM, "ethtool[%d]: setting FEC options 0x%x", ifindex, fec); diff --git a/src/libnm-platform/nm-platform-utils.h b/src/libnm-platform/nm-platform-utils.h index 1728556b89..7df1cfecaf 100644 --- a/src/libnm-platform/nm-platform-utils.h +++ b/src/libnm-platform/nm-platform-utils.h @@ -66,7 +66,7 @@ gboolean nmp_utils_ethtool_get_eee(int ifindex, NMEthtoolEEEState *eee); gboolean nmp_utils_ethtool_set_eee(int ifindex, const NMEthtoolEEEState *eee); -gboolean nmp_utils_ethtool_set_fec(int ifindex, const _NMEthtoolFec fec); +gboolean nmp_utils_ethtool_set_fec(int ifindex, const NMEthtoolFec fec); /*****************************************************************************/ diff --git a/src/libnm-platform/nm-platform.c b/src/libnm-platform/nm-platform.c index db99410400..a322983326 100644 --- a/src/libnm-platform/nm-platform.c +++ b/src/libnm-platform/nm-platform.c @@ -3570,7 +3570,7 @@ nm_platform_ethtool_set_features( } gboolean -nm_platform_ethtool_set_fec(NMPlatform *self, int ifindex, const _NMEthtoolFec fec) +nm_platform_ethtool_set_fec(NMPlatform *self, int ifindex, const NMEthtoolFec fec) { _CHECK_SELF_NETNS(self, klass, netns, FALSE); diff --git a/src/libnm-platform/nm-platform.h b/src/libnm-platform/nm-platform.h index 0da94ad434..78aa0fe757 100644 --- a/src/libnm-platform/nm-platform.h +++ b/src/libnm-platform/nm-platform.h @@ -2615,7 +2615,7 @@ gboolean nm_platform_ethtool_set_channels(NMPlatform *self, int ifindex, const NMEthtoolChannelsState *channels); -gboolean nm_platform_ethtool_set_fec(NMPlatform *self, int ifindex, const _NMEthtoolFec fec); +gboolean nm_platform_ethtool_set_fec(NMPlatform *self, int ifindex, const NMEthtoolFec fec); gboolean nm_platform_ethtool_get_link_pause(NMPlatform *self, int ifindex, NMEthtoolPauseState *pause); diff --git a/src/libnm-platform/nmp-base.h b/src/libnm-platform/nmp-base.h index cf2f635d98..b03f27025d 100644 --- a/src/libnm-platform/nmp-base.h +++ b/src/libnm-platform/nmp-base.h @@ -124,6 +124,15 @@ typedef struct { bool enabled : 1; } NMEthtoolEEEState; +typedef enum { + NM_ETHTOOL_FEC_NONE = ETHTOOL_FEC_NONE, + NM_ETHTOOL_FEC_AUTO = ETHTOOL_FEC_AUTO, + NM_ETHTOOL_FEC_OFF = ETHTOOL_FEC_OFF, + NM_ETHTOOL_FEC_RS = ETHTOOL_FEC_RS, + NM_ETHTOOL_FEC_BASER = ETHTOOL_FEC_BASER, + NM_ETHTOOL_FEC_LLRS = ETHTOOL_FEC_LLRS, +} NMEthtoolFec; + /*****************************************************************************/ typedef struct _NMPNetns NMPNetns;