|
Packit Service |
87a54e |
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
Packit |
5756e2 |
/*
|
|
Packit |
5756e2 |
* Copyright (C) 2015 Red Hat, Inc.
|
|
Packit |
5756e2 |
*/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
#ifndef __NM_PLATFORM_UTILS_H__
|
|
Packit |
5756e2 |
#define __NM_PLATFORM_UTILS_H__
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
#include "nm-platform.h"
|
|
Packit |
5756e2 |
#include "nm-setting-wired.h"
|
|
Packit |
5756e2 |
#include "nm-libnm-core-intern/nm-ethtool-utils.h"
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
const char *nmp_utils_ethtool_get_driver(int ifindex);
|
|
Packit Service |
a1bd4f |
gboolean nmp_utils_ethtool_supports_carrier_detect(int ifindex);
|
|
Packit Service |
a1bd4f |
gboolean nmp_utils_ethtool_supports_vlans(int ifindex);
|
|
Packit Service |
a1bd4f |
int nmp_utils_ethtool_get_peer_ifindex(int ifindex);
|
|
Packit Service |
a1bd4f |
gboolean nmp_utils_ethtool_get_wake_on_lan(int ifindex);
|
|
Packit Service |
a1bd4f |
gboolean nmp_utils_ethtool_set_wake_on_lan(int ifindex,
|
|
Packit Service |
a1bd4f |
NMSettingWiredWakeOnLan wol,
|
|
Packit Service |
a1bd4f |
const char * wol_password);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
gboolean nmp_utils_ethtool_get_link_settings(int ifindex,
|
|
Packit Service |
a1bd4f |
gboolean * out_autoneg,
|
|
Packit Service |
a1bd4f |
guint32 * out_speed,
|
|
Packit Service |
a1bd4f |
NMPlatformLinkDuplexType *out_duplex);
|
|
Packit Service |
a1bd4f |
gboolean nmp_utils_ethtool_set_link_settings(int ifindex,
|
|
Packit Service |
a1bd4f |
gboolean autoneg,
|
|
Packit Service |
a1bd4f |
guint32 speed,
|
|
Packit Service |
a1bd4f |
NMPlatformLinkDuplexType duplex);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
gboolean nmp_utils_ethtool_get_permanent_address(int ifindex, guint8 *buf, size_t *length);
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
typedef struct {
|
|
Packit Service |
a1bd4f |
/* We don't want to include <linux/ethtool.h> in header files,
|
|
Packit Service |
a1bd4f |
* thus create a ABI compatible version of struct ethtool_drvinfo.*/
|
|
Packit Service |
a1bd4f |
guint32 _private_cmd;
|
|
Packit Service |
a1bd4f |
char driver[32];
|
|
Packit Service |
a1bd4f |
char version[32];
|
|
Packit Service |
a1bd4f |
char fw_version[32];
|
|
Packit Service |
a1bd4f |
char _private_bus_info[32];
|
|
Packit Service |
a1bd4f |
char _private_erom_version[32];
|
|
Packit Service |
a1bd4f |
char _private_reserved2[12];
|
|
Packit Service |
a1bd4f |
guint32 _private_n_priv_flags;
|
|
Packit Service |
a1bd4f |
guint32 _private_n_stats;
|
|
Packit Service |
a1bd4f |
guint32 _private_testinfo_len;
|
|
Packit Service |
a1bd4f |
guint32 _private_eedump_len;
|
|
Packit Service |
a1bd4f |
guint32 _private_regdump_len;
|
|
Packit |
5756e2 |
} NMPUtilsEthtoolDriverInfo;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
gboolean nmp_utils_ethtool_get_driver_info(int ifindex, NMPUtilsEthtoolDriverInfo *data);
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
typedef struct {
|
|
Packit Service |
a1bd4f |
NMEthtoolID ethtool_id;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
guint8 n_kernel_names;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
/* one NMEthtoolID refers to one or more kernel_names. The reason for supporting this complexity
|
|
Packit Service |
a1bd4f |
* (where one NMSettingEthtool option refers to multiple kernel features) is to follow what
|
|
Packit Service |
a1bd4f |
* ethtool does, where "tx" is an alias for multiple features. */
|
|
Packit Service |
a1bd4f |
const char *const *kernel_names;
|
|
Packit |
5756e2 |
} NMEthtoolFeatureInfo;
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
typedef struct {
|
|
Packit Service |
a1bd4f |
const NMEthtoolFeatureInfo *info;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
guint idx_ss_features;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
/* one NMEthtoolFeatureInfo references one or more kernel_names. This is the index
|
|
Packit Service |
a1bd4f |
* of the matching info->kernel_names */
|
|
Packit Service |
a1bd4f |
guint8 idx_kernel_name;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
bool available : 1;
|
|
Packit Service |
a1bd4f |
bool requested : 1;
|
|
Packit Service |
a1bd4f |
bool active : 1;
|
|
Packit Service |
a1bd4f |
bool never_changed : 1;
|
|
Packit |
5756e2 |
} NMEthtoolFeatureState;
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
struct _NMEthtoolFeatureStates {
|
|
Packit Service |
a1bd4f |
guint n_states;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
guint n_ss_features;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
/* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */
|
|
Packit Service |
a1bd4f |
const NMEthtoolFeatureState *const *states_indexed[_NM_ETHTOOL_ID_FEATURE_NUM];
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
/* the same content, here as a list of n_states entries. */
|
|
Packit Service |
a1bd4f |
const NMEthtoolFeatureState states_list[];
|
|
Packit |
5756e2 |
};
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
NMEthtoolFeatureStates *nmp_utils_ethtool_get_features(int ifindex);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
gboolean nmp_utils_ethtool_set_features(
|
|
Packit Service |
a1bd4f |
int ifindex,
|
|
Packit Service |
a1bd4f |
const NMEthtoolFeatureStates *features,
|
|
Packit Service |
a1bd4f |
const NMTernary *requested /* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */,
|
|
Packit Service |
a1bd4f |
gboolean do_set /* or reset */);
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
struct _NMEthtoolCoalesceState {
|
|
Packit Service |
a1bd4f |
guint32
|
|
Packit Service |
a1bd4f |
s[_NM_ETHTOOL_ID_COALESCE_NUM /* indexed by (NMEthtoolID - _NM_ETHTOOL_ID_COALESCE_FIRST) */
|
|
Packit Service |
a1bd4f |
];
|
|
Packit |
5756e2 |
};
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
gboolean nmp_utils_ethtool_get_coalesce(int ifindex, NMEthtoolCoalesceState *coalesce);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
gboolean nmp_utils_ethtool_set_coalesce(int ifindex, const NMEthtoolCoalesceState *coalesce);
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
struct _NMEthtoolRingState {
|
|
Packit Service |
a1bd4f |
guint32 rx_pending;
|
|
Packit Service |
a1bd4f |
guint32 rx_mini_pending;
|
|
Packit Service |
a1bd4f |
guint32 rx_jumbo_pending;
|
|
Packit Service |
a1bd4f |
guint32 tx_pending;
|
|
Packit |
5756e2 |
};
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
gboolean nmp_utils_ethtool_get_ring(int ifindex, NMEthtoolRingState *ring);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
gboolean nmp_utils_ethtool_set_ring(int ifindex, const NMEthtoolRingState *ring);
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
gboolean nmp_utils_mii_supports_carrier_detect(int ifindex);
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
struct udev_device;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
const char *nmp_utils_udev_get_driver(struct udev_device *udevice);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
NMIPConfigSource nmp_utils_ip_config_source_from_rtprot(guint8 rtprot) _nm_const;
|
|
Packit Service |
a1bd4f |
guint8 nmp_utils_ip_config_source_coerce_to_rtprot(NMIPConfigSource source) _nm_const;
|
|
Packit Service |
a1bd4f |
NMIPConfigSource nmp_utils_ip_config_source_coerce_from_rtprot(NMIPConfigSource source) _nm_const;
|
|
Packit Service |
a1bd4f |
NMIPConfigSource nmp_utils_ip_config_source_round_trip_rtprot(NMIPConfigSource source) _nm_const;
|
|
Packit Service |
a1bd4f |
const char *nmp_utils_ip_config_source_to_string(NMIPConfigSource source, char *buf, gsize len);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
const char *nmp_utils_if_indextoname(int ifindex, char *out_ifname /*IFNAMSIZ*/);
|
|
Packit Service |
a1bd4f |
int nmp_utils_if_nametoindex(const char *ifname);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
int nmp_utils_sysctl_open_netdir(int ifindex, const char *ifname_guess, char *out_ifname);
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
#endif /* __NM_PLATFORM_UTILS_H__ */
|