platform: move types from "nm-platform-utils.h" to nmp-base.h"

Thereby, also no longer include "nm-platform.h" and "nm-setting-wired.h"
in "nm-platform-utils.h".
This commit is contained in:
Thomas Haller 2021-01-08 18:39:27 +01:00
parent 2bb5c8b13b
commit 126681a965
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
5 changed files with 92 additions and 85 deletions

View file

@ -3,6 +3,92 @@
#ifndef __NMP_FWD_H__
#define __NMP_FWD_H__
#include "nm-base/nm-base.h"
/*****************************************************************************/
typedef enum {
NM_PLATFORM_LINK_DUPLEX_UNKNOWN,
NM_PLATFORM_LINK_DUPLEX_HALF,
NM_PLATFORM_LINK_DUPLEX_FULL,
} NMPlatformLinkDuplexType;
/*****************************************************************************/
typedef struct {
/* We don't want to include <linux/ethtool.h> in header files,
* thus create a ABI compatible version of struct ethtool_drvinfo.*/
guint32 _private_cmd;
char driver[32];
char version[32];
char fw_version[32];
char _private_bus_info[32];
char _private_erom_version[32];
char _private_reserved2[12];
guint32 _private_n_priv_flags;
guint32 _private_n_stats;
guint32 _private_testinfo_len;
guint32 _private_eedump_len;
guint32 _private_regdump_len;
} NMPUtilsEthtoolDriverInfo;
typedef struct {
NMEthtoolID ethtool_id;
guint8 n_kernel_names;
/* one NMEthtoolID refers to one or more kernel_names. The reason for supporting this complexity
* (where one NMSettingEthtool option refers to multiple kernel features) is to follow what
* ethtool does, where "tx" is an alias for multiple features. */
const char *const *kernel_names;
} NMEthtoolFeatureInfo;
typedef struct {
const NMEthtoolFeatureInfo *info;
guint idx_ss_features;
/* one NMEthtoolFeatureInfo references one or more kernel_names. This is the index
* of the matching info->kernel_names */
guint8 idx_kernel_name;
bool available : 1;
bool requested : 1;
bool active : 1;
bool never_changed : 1;
} NMEthtoolFeatureState;
typedef struct {
guint n_states;
guint n_ss_features;
/* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */
const NMEthtoolFeatureState *const *states_indexed[_NM_ETHTOOL_ID_FEATURE_NUM];
/* the same content, here as a list of n_states entries. */
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;
guint32 rx_jumbo_pending;
guint32 tx_pending;
} NMEthtoolRingState;
/*****************************************************************************/
typedef struct _NMPNetns NMPNetns;
#endif /* __NMP_FWD_H__ */

View file

@ -18,12 +18,13 @@
#include <fcntl.h>
#include <libudev.h>
#include "nm-utils.h"
#include "nm-setting-wired.h"
#include "nm-libnm-core-intern/nm-ethtool-utils.h"
#include "nm-utils.h"
#include "nm-platform.h"
#include "nm-core-utils.h"
/*****************************************************************************/
#define ONOFF(bool_val) ((bool_val) ? "on" : "off")
/******************************************************************************

View file

@ -6,9 +6,8 @@
#ifndef __NM_PLATFORM_UTILS_H__
#define __NM_PLATFORM_UTILS_H__
#include "nm-platform.h"
#include "nm-setting-wired.h"
#include "nm-base/nm-base.h"
#include "nm-platform/nmp-base.h"
/*****************************************************************************/
@ -32,63 +31,8 @@ gboolean nmp_utils_ethtool_set_link_settings(int ifindex,
gboolean nmp_utils_ethtool_get_permanent_address(int ifindex, guint8 *buf, size_t *length);
typedef struct {
/* We don't want to include <linux/ethtool.h> in header files,
* thus create a ABI compatible version of struct ethtool_drvinfo.*/
guint32 _private_cmd;
char driver[32];
char version[32];
char fw_version[32];
char _private_bus_info[32];
char _private_erom_version[32];
char _private_reserved2[12];
guint32 _private_n_priv_flags;
guint32 _private_n_stats;
guint32 _private_testinfo_len;
guint32 _private_eedump_len;
guint32 _private_regdump_len;
} NMPUtilsEthtoolDriverInfo;
gboolean nmp_utils_ethtool_get_driver_info(int ifindex, NMPUtilsEthtoolDriverInfo *data);
typedef struct {
NMEthtoolID ethtool_id;
guint8 n_kernel_names;
/* one NMEthtoolID refers to one or more kernel_names. The reason for supporting this complexity
* (where one NMSettingEthtool option refers to multiple kernel features) is to follow what
* ethtool does, where "tx" is an alias for multiple features. */
const char *const *kernel_names;
} NMEthtoolFeatureInfo;
typedef struct {
const NMEthtoolFeatureInfo *info;
guint idx_ss_features;
/* one NMEthtoolFeatureInfo references one or more kernel_names. This is the index
* of the matching info->kernel_names */
guint8 idx_kernel_name;
bool available : 1;
bool requested : 1;
bool active : 1;
bool never_changed : 1;
} NMEthtoolFeatureState;
struct _NMEthtoolFeatureStates {
guint n_states;
guint n_ss_features;
/* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */
const NMEthtoolFeatureState *const *states_indexed[_NM_ETHTOOL_ID_FEATURE_NUM];
/* the same content, here as a list of n_states entries. */
const NMEthtoolFeatureState states_list[];
};
NMEthtoolFeatureStates *nmp_utils_ethtool_get_features(int ifindex);
gboolean nmp_utils_ethtool_set_features(
@ -97,23 +41,10 @@ gboolean nmp_utils_ethtool_set_features(
const NMTernary *requested /* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */,
gboolean do_set /* or reset */);
struct _NMEthtoolCoalesceState {
guint32
s[_NM_ETHTOOL_ID_COALESCE_NUM /* indexed by (NMEthtoolID - _NM_ETHTOOL_ID_COALESCE_FIRST) */
];
};
gboolean nmp_utils_ethtool_get_coalesce(int ifindex, NMEthtoolCoalesceState *coalesce);
gboolean nmp_utils_ethtool_set_coalesce(int ifindex, const NMEthtoolCoalesceState *coalesce);
struct _NMEthtoolRingState {
guint32 rx_pending;
guint32 rx_mini_pending;
guint32 rx_jumbo_pending;
guint32 tx_pending;
};
gboolean nmp_utils_ethtool_get_ring(int ifindex, NMEthtoolRingState *ring);
gboolean nmp_utils_ethtool_set_ring(int ifindex, const NMEthtoolRingState *ring);

View file

@ -978,12 +978,6 @@ typedef struct {
guint8 public_key[NMP_WIREGUARD_PUBLIC_KEY_LEN];
} NMPlatformLnkWireGuard;
typedef enum {
NM_PLATFORM_LINK_DUPLEX_UNKNOWN,
NM_PLATFORM_LINK_DUPLEX_HALF,
NM_PLATFORM_LINK_DUPLEX_FULL,
} NMPlatformLinkDuplexType;
typedef enum {
NM_PLATFORM_WIREGUARD_CHANGE_FLAG_NONE = 0,
NM_PLATFORM_WIREGUARD_CHANGE_FLAG_REPLACE_PEERS = (1LL << 0),
@ -2343,8 +2337,6 @@ gboolean nm_platform_ethtool_get_link_settings(NMPlatform * self,
guint32 * out_speed,
NMPlatformLinkDuplexType *out_duplex);
typedef struct _NMEthtoolFeatureStates NMEthtoolFeatureStates;
NMEthtoolFeatureStates *nm_platform_ethtool_get_link_features(NMPlatform *self, int ifindex);
gboolean nm_platform_ethtool_set_features(
NMPlatform * self,
@ -2353,8 +2345,6 @@ gboolean nm_platform_ethtool_set_features(
const NMTernary *requested /* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */,
gboolean do_set /* or reset */);
typedef struct _NMEthtoolCoalesceState NMEthtoolCoalesceState;
gboolean nm_platform_ethtool_get_link_coalesce(NMPlatform * self,
int ifindex,
NMEthtoolCoalesceState *coalesce);
@ -2363,8 +2353,6 @@ gboolean nm_platform_ethtool_set_coalesce(NMPlatform * self,
int ifindex,
const NMEthtoolCoalesceState *coalesce);
typedef struct _NMEthtoolRingState NMEthtoolRingState;
gboolean nm_platform_ethtool_get_link_ring(NMPlatform *self, int ifindex, NMEthtoolRingState *ring);
gboolean

View file

@ -25,6 +25,7 @@
#include "nm-utils.h"
#include "platform/nm-platform-utils.h"
#include "nm-core-internal.h"
#include "nm-core-utils.h"
typedef struct {
NMWifiUtils parent;