diff --git a/src/libnm-platform/nm-platform-utils.c b/src/libnm-platform/nm-platform-utils.c index 08d82fe87a..32c4732d3d 100644 --- a/src/libnm-platform/nm-platform-utils.c +++ b/src/libnm-platform/nm-platform-utils.c @@ -1067,6 +1067,69 @@ nmp_utils_ethtool_set_ring(int ifindex, const NMEthtoolRingState *ring) return TRUE; } +gboolean +nmp_utils_ethtool_get_channels(int ifindex, NMEthtoolChannelsState *channels) +{ + struct ethtool_channels eth_data; + + g_return_val_if_fail(ifindex > 0, FALSE); + g_return_val_if_fail(channels, FALSE); + + eth_data.cmd = ETHTOOL_GCHANNELS; + + if (_ethtool_call_once(ifindex, ð_data, sizeof(eth_data)) < 0) { + nm_log_trace(LOGD_PLATFORM, + "ethtool[%d]: %s: failure getting channels settings", + ifindex, + "get-channels"); + return FALSE; + } + + *channels = (NMEthtoolChannelsState){ + .rx = eth_data.rx_count, + .tx = eth_data.tx_count, + .other = eth_data.other_count, + .combined = eth_data.combined_count, + }; + + nm_log_trace(LOGD_PLATFORM, + "ethtool[%d]: %s: retrieved kernel channels settings", + ifindex, + "get-channels"); + return TRUE; +} + +gboolean +nmp_utils_ethtool_set_channels(int ifindex, const NMEthtoolChannelsState *channels) +{ + struct ethtool_channels eth_data; + + g_return_val_if_fail(ifindex > 0, FALSE); + g_return_val_if_fail(channels, FALSE); + + eth_data = (struct ethtool_channels){ + .cmd = ETHTOOL_SCHANNELS, + .rx_count = channels->rx, + .tx_count = channels->tx, + .other_count = channels->other, + .combined_count = channels->combined, + }; + + if (_ethtool_call_once(ifindex, ð_data, sizeof(eth_data)) < 0) { + nm_log_trace(LOGD_PLATFORM, + "ethtool[%d]: %s: failure setting channels settings", + ifindex, + "set-channels"); + return FALSE; + } + + nm_log_trace(LOGD_PLATFORM, + "ethtool[%d]: %s: set kernel channels settings", + ifindex, + "set-channels"); + return TRUE; +} + gboolean nmp_utils_ethtool_get_pause(int ifindex, NMEthtoolPauseState *pause) { diff --git a/src/libnm-platform/nm-platform-utils.h b/src/libnm-platform/nm-platform-utils.h index 14b09a793e..815d165431 100644 --- a/src/libnm-platform/nm-platform-utils.h +++ b/src/libnm-platform/nm-platform-utils.h @@ -54,6 +54,10 @@ gboolean nmp_utils_ethtool_get_ring(int ifindex, NMEthtoolRingState *ring); gboolean nmp_utils_ethtool_set_ring(int ifindex, const NMEthtoolRingState *ring); +gboolean nmp_utils_ethtool_get_channels(int ifindex, NMEthtoolChannelsState *channels); + +gboolean nmp_utils_ethtool_set_channels(int ifindex, const NMEthtoolChannelsState *channels); + gboolean nmp_utils_ethtool_get_pause(int ifindex, NMEthtoolPauseState *pause); gboolean nmp_utils_ethtool_set_pause(int ifindex, const NMEthtoolPauseState *pause); diff --git a/src/libnm-platform/nm-platform.c b/src/libnm-platform/nm-platform.c index 7bd9de4121..1b513d34be 100644 --- a/src/libnm-platform/nm-platform.c +++ b/src/libnm-platform/nm-platform.c @@ -3580,6 +3580,31 @@ nm_platform_ethtool_set_ring(NMPlatform *self, int ifindex, const NMEthtoolRingS return nmp_utils_ethtool_set_ring(ifindex, ring); } +gboolean +nm_platform_ethtool_get_link_channels(NMPlatform *self, + int ifindex, + NMEthtoolChannelsState *channels) +{ + _CHECK_SELF_NETNS(self, klass, netns, FALSE); + + g_return_val_if_fail(ifindex > 0, FALSE); + g_return_val_if_fail(channels, FALSE); + + return nmp_utils_ethtool_get_channels(ifindex, channels); +} + +gboolean +nm_platform_ethtool_set_channels(NMPlatform *self, + int ifindex, + const NMEthtoolChannelsState *channels) +{ + _CHECK_SELF_NETNS(self, klass, netns, FALSE); + + g_return_val_if_fail(ifindex > 0, FALSE); + + return nmp_utils_ethtool_set_channels(ifindex, channels); +} + gboolean nm_platform_ethtool_get_link_pause(NMPlatform *self, int ifindex, NMEthtoolPauseState *pause) { diff --git a/src/libnm-platform/nm-platform.h b/src/libnm-platform/nm-platform.h index 6ad0d15bd0..bc5bc5e8b4 100644 --- a/src/libnm-platform/nm-platform.h +++ b/src/libnm-platform/nm-platform.h @@ -2567,6 +2567,14 @@ gboolean nm_platform_ethtool_get_link_ring(NMPlatform *self, int ifindex, NMEtht gboolean nm_platform_ethtool_set_ring(NMPlatform *self, int ifindex, const NMEthtoolRingState *ring); +gboolean nm_platform_ethtool_get_link_channels(NMPlatform *self, + int ifindex, + NMEthtoolChannelsState *channels); + +gboolean nm_platform_ethtool_set_channels(NMPlatform *self, + int ifindex, + const NMEthtoolChannelsState *channels); + 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 ffe5936300..eeaad024a0 100644 --- a/src/libnm-platform/nmp-base.h +++ b/src/libnm-platform/nmp-base.h @@ -93,16 +93,12 @@ typedef struct { const NMEthtoolFeatureState states_list[]; } NMEthtoolFeatureStates; -/*****************************************************************************/ - typedef struct { guint32 s[_NM_ETHTOOL_ID_COALESCE_NUM /* indexed by (NMEthtoolID - _NM_ETHTOOL_ID_COALESCE_FIRST) */ ]; } NMEthtoolCoalesceState; -/*****************************************************************************/ - typedef struct { guint32 rx_pending; guint32 rx_mini_pending; @@ -116,6 +112,13 @@ typedef struct { bool tx : 1; } NMEthtoolPauseState; +typedef struct { + guint32 rx; + guint32 tx; + guint32 other; + guint32 combined; +} NMEthtoolChannelsState; + /*****************************************************************************/ typedef struct _NMPNetns NMPNetns;