platform: use the new ethtool-netlink API for pause settings
This commit is contained in:
@@ -41,6 +41,7 @@
|
||||
#include "libnm-platform/nm-netlink.h"
|
||||
#include "libnm-platform/nm-platform-utils.h"
|
||||
#include "libnm-platform/nmp-netns.h"
|
||||
#include "libnm-platform/nmp-ethtool.h"
|
||||
#include "libnm-platform/nmp-ethtool-ioctl.h"
|
||||
#include "libnm-platform/devlink/nm-devlink.h"
|
||||
#include "libnm-platform/wifi/nm-wifi-utils-wext.h"
|
||||
@@ -11832,6 +11833,30 @@ mptcp_addrs_dump(NMPlatform *platform)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
ethtool_get_pause(NMPlatform *platform, int ifindex, NMEthtoolPauseState *pause)
|
||||
{
|
||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE(platform);
|
||||
|
||||
return nmp_ethtool_get_pause(priv->sk_genl_sync,
|
||||
genl_get_family_id(platform, NMP_GENL_FAMILY_TYPE_ETHTOOL),
|
||||
ifindex,
|
||||
pause);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
ethtool_set_pause(NMPlatform *platform, int ifindex, const NMEthtoolPauseState *pause)
|
||||
{
|
||||
NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE(platform);
|
||||
|
||||
return nmp_ethtool_set_pause(priv->sk_genl_sync,
|
||||
genl_get_family_id(platform, NMP_GENL_FAMILY_TYPE_ETHTOOL),
|
||||
ifindex,
|
||||
pause);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
cache_update_link_udev(NMPlatform *platform, int ifindex, struct udev_device *udevice)
|
||||
{
|
||||
@@ -12329,4 +12354,7 @@ nm_linux_platform_class_init(NMLinuxPlatformClass *klass)
|
||||
platform_class->genl_get_family_id = genl_get_family_id;
|
||||
platform_class->mptcp_addr_update = mptcp_addr_update;
|
||||
platform_class->mptcp_addrs_dump = mptcp_addrs_dump;
|
||||
|
||||
platform_class->ethtool_set_pause = ethtool_set_pause;
|
||||
platform_class->ethtool_get_pause = ethtool_get_pause;
|
||||
}
|
||||
|
@@ -3715,7 +3715,7 @@ nm_platform_ethtool_get_pause(NMPlatform *self, int ifindex, NMEthtoolPauseState
|
||||
g_return_val_if_fail(ifindex > 0, FALSE);
|
||||
g_return_val_if_fail(pause, FALSE);
|
||||
|
||||
return nmp_ethtool_ioctl_get_pause(ifindex, pause);
|
||||
return klass->ethtool_get_pause(self, ifindex, pause);
|
||||
}
|
||||
|
||||
gboolean
|
||||
@@ -3724,8 +3724,9 @@ nm_platform_ethtool_set_pause(NMPlatform *self, int ifindex, const NMEthtoolPaus
|
||||
_CHECK_SELF_NETNS(self, klass, netns, FALSE);
|
||||
|
||||
g_return_val_if_fail(ifindex > 0, FALSE);
|
||||
g_return_val_if_fail(pause, FALSE);
|
||||
|
||||
return nmp_ethtool_ioctl_set_pause(ifindex, pause);
|
||||
return klass->ethtool_set_pause(self, ifindex, pause);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
@@ -1346,6 +1346,9 @@ typedef struct {
|
||||
|
||||
GPtrArray *(*mptcp_addrs_dump)(NMPlatform *self);
|
||||
|
||||
gboolean (*ethtool_get_pause)(NMPlatform *self, int ifindex, NMEthtoolPauseState *pause);
|
||||
gboolean (*ethtool_set_pause)(NMPlatform *self, int ifindex, const NMEthtoolPauseState *pause);
|
||||
|
||||
} NMPlatformClass;
|
||||
|
||||
/* NMPlatform signals
|
||||
|
@@ -1090,64 +1090,6 @@ nmp_ethtool_ioctl_set_channels(int ifindex, const NMEthtoolChannelsState *channe
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nmp_ethtool_ioctl_get_pause(int ifindex, NMEthtoolPauseState *pause)
|
||||
{
|
||||
struct ethtool_pauseparam 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(pause, FALSE);
|
||||
|
||||
eth_data.cmd = ETHTOOL_GPAUSEPARAM;
|
||||
if (_ethtool_call_handle(&shandle, ð_data, sizeof(struct ethtool_pauseparam)) != 0) {
|
||||
nm_log_trace(LOGD_PLATFORM,
|
||||
"ethtool[%d]: %s: failure getting pause settings",
|
||||
ifindex,
|
||||
"get-pause");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*pause = (NMEthtoolPauseState) {
|
||||
.autoneg = eth_data.autoneg == 1,
|
||||
.rx = eth_data.rx_pause == 1,
|
||||
.tx = eth_data.tx_pause == 1,
|
||||
};
|
||||
|
||||
nm_log_trace(LOGD_PLATFORM,
|
||||
"ethtool[%d]: %s: retrieved kernel pause settings",
|
||||
ifindex,
|
||||
"get-pause");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nmp_ethtool_ioctl_set_pause(int ifindex, const NMEthtoolPauseState *pause)
|
||||
{
|
||||
struct ethtool_pauseparam 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(pause, FALSE);
|
||||
|
||||
eth_data = (struct ethtool_pauseparam) {
|
||||
.cmd = ETHTOOL_SPAUSEPARAM,
|
||||
.autoneg = pause->autoneg ? 1 : 0,
|
||||
.rx_pause = pause->rx ? 1 : 0,
|
||||
.tx_pause = pause->tx ? 1 : 0,
|
||||
};
|
||||
|
||||
if (_ethtool_call_handle(&shandle, ð_data, sizeof(struct ethtool_pauseparam)) != 0) {
|
||||
nm_log_trace(LOGD_PLATFORM,
|
||||
"ethtool[%d]: %s: failure setting pause settings",
|
||||
ifindex,
|
||||
"set-pause");
|
||||
return FALSE;
|
||||
}
|
||||
nm_log_trace(LOGD_PLATFORM, "ethtool[%d]: %s: set kernel puase settings", ifindex, "set-pause");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nmp_ethtool_ioctl_get_eee(int ifindex, NMEthtoolEEEState *eee)
|
||||
{
|
||||
|
@@ -50,10 +50,6 @@ gboolean nmp_ethtool_ioctl_get_channels(int ifindex, NMEthtoolChannelsState *cha
|
||||
|
||||
gboolean nmp_ethtool_ioctl_set_channels(int ifindex, const NMEthtoolChannelsState *channels);
|
||||
|
||||
gboolean nmp_ethtool_ioctl_get_pause(int ifindex, NMEthtoolPauseState *pause);
|
||||
|
||||
gboolean nmp_ethtool_ioctl_set_pause(int ifindex, const NMEthtoolPauseState *pause);
|
||||
|
||||
gboolean nmp_ethtool_ioctl_get_eee(int ifindex, NMEthtoolEEEState *eee);
|
||||
|
||||
gboolean nmp_ethtool_ioctl_set_eee(int ifindex, const NMEthtoolEEEState *eee);
|
||||
|
Reference in New Issue
Block a user