2017-11-18 17:09:20 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1+ */
|
2016-02-16 20:05:15 +01:00
|
|
|
#pragma once
|
|
|
|
|
2013-10-28 20:59:56 +01:00
|
|
|
#include <macro.h>
|
2016-11-04 10:55:07 +01:00
|
|
|
#include <linux/ethtool.h>
|
|
|
|
|
2018-11-12 08:45:04 +01:00
|
|
|
#include "conf-parser.h"
|
2018-12-06 07:41:52 +01:00
|
|
|
#include "missing_network.h"
|
2013-10-28 20:59:56 +01:00
|
|
|
|
2017-06-26 00:42:57 +02:00
|
|
|
struct link_config;
|
|
|
|
|
2013-10-28 20:59:56 +01:00
|
|
|
/* we can't use DUPLEX_ prefix, as it
|
|
|
|
* clashes with <linux/ethtool.h> */
|
|
|
|
typedef enum Duplex {
|
2017-06-30 18:55:21 +02:00
|
|
|
DUP_HALF = DUPLEX_HALF,
|
|
|
|
DUP_FULL = DUPLEX_FULL,
|
2013-10-28 20:59:56 +01:00
|
|
|
_DUP_MAX,
|
|
|
|
_DUP_INVALID = -1
|
|
|
|
} Duplex;
|
|
|
|
|
|
|
|
typedef enum WakeOnLan {
|
|
|
|
WOL_PHY,
|
2017-08-31 12:44:43 +02:00
|
|
|
WOL_UCAST,
|
|
|
|
WOL_MCAST,
|
|
|
|
WOL_BCAST,
|
|
|
|
WOL_ARP,
|
2013-10-28 20:59:56 +01:00
|
|
|
WOL_MAGIC,
|
2017-08-31 12:44:43 +02:00
|
|
|
WOL_MAGICSECURE,
|
2013-10-28 20:59:56 +01:00
|
|
|
WOL_OFF,
|
|
|
|
_WOL_MAX,
|
|
|
|
_WOL_INVALID = -1
|
|
|
|
} WakeOnLan;
|
|
|
|
|
2016-08-30 16:52:04 +02:00
|
|
|
typedef enum NetDevFeature {
|
|
|
|
NET_DEV_FEAT_GSO,
|
2016-08-31 09:17:02 +02:00
|
|
|
NET_DEV_FEAT_GRO,
|
|
|
|
NET_DEV_FEAT_LRO,
|
2016-08-30 16:52:04 +02:00
|
|
|
NET_DEV_FEAT_TSO,
|
2017-09-19 10:49:58 +02:00
|
|
|
NET_DEV_FEAT_TSO6,
|
2016-08-30 16:52:04 +02:00
|
|
|
_NET_DEV_FEAT_MAX,
|
|
|
|
_NET_DEV_FEAT_INVALID = -1
|
|
|
|
} NetDevFeature;
|
|
|
|
|
2017-06-26 00:42:57 +02:00
|
|
|
typedef enum NetDevPort {
|
|
|
|
NET_DEV_PORT_TP = 0x00,
|
|
|
|
NET_DEV_PORT_AUI = 0x01,
|
|
|
|
NET_DEV_PORT_MII = 0x02,
|
|
|
|
NET_DEV_PORT_FIBRE = 0x03,
|
|
|
|
NET_DEV_PORT_BNC = 0x04,
|
|
|
|
NET_DEV_PORT_DA = 0x05,
|
|
|
|
NET_DEV_PORT_NONE = 0xef,
|
|
|
|
NET_DEV_PORT_OTHER = 0xff,
|
|
|
|
_NET_DEV_PORT_MAX,
|
|
|
|
_NET_DEV_PORT_INVALID = -1
|
|
|
|
} NetDevPort;
|
2016-11-04 10:55:07 +01:00
|
|
|
|
|
|
|
#define ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32 (SCHAR_MAX)
|
2017-09-16 20:36:56 +02:00
|
|
|
#define ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NBYTES (4 * ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32)
|
2016-11-04 10:55:07 +01:00
|
|
|
|
|
|
|
/* layout of the struct passed from/to userland */
|
|
|
|
struct ethtool_link_usettings {
|
|
|
|
struct ethtool_link_settings base;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
uint32_t supported[ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32];
|
|
|
|
uint32_t advertising[ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32];
|
|
|
|
uint32_t lp_advertising[ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32];
|
|
|
|
} link_modes;
|
|
|
|
};
|
|
|
|
|
2018-05-08 13:03:41 +02:00
|
|
|
typedef struct netdev_channels {
|
|
|
|
uint32_t rx_count;
|
|
|
|
uint32_t tx_count;
|
|
|
|
uint32_t other_count;
|
|
|
|
uint32_t combined_count;
|
|
|
|
|
|
|
|
bool rx_count_set;
|
|
|
|
bool tx_count_set;
|
|
|
|
bool other_count_set;
|
|
|
|
bool combined_count_set;
|
|
|
|
} netdev_channels;
|
|
|
|
|
2013-10-26 18:54:16 +02:00
|
|
|
int ethtool_connect(int *ret);
|
|
|
|
|
2014-09-09 15:36:56 +02:00
|
|
|
int ethtool_get_driver(int *fd, const char *ifname, char **ret);
|
2018-10-19 20:00:46 +02:00
|
|
|
int ethtool_set_speed(int *fd, const char *ifname, unsigned speed, Duplex duplex);
|
2014-09-09 15:36:56 +02:00
|
|
|
int ethtool_set_wol(int *fd, const char *ifname, WakeOnLan wol);
|
2018-08-07 08:55:07 +02:00
|
|
|
int ethtool_set_features(int *fd, const char *ifname, int *features);
|
2017-06-26 00:42:57 +02:00
|
|
|
int ethtool_set_glinksettings(int *fd, const char *ifname, struct link_config *link);
|
2018-05-08 13:03:41 +02:00
|
|
|
int ethtool_set_channels(int *fd, const char *ifname, netdev_channels *channels);
|
2013-10-28 20:59:56 +01:00
|
|
|
|
|
|
|
const char *duplex_to_string(Duplex d) _const_;
|
|
|
|
Duplex duplex_from_string(const char *d) _pure_;
|
|
|
|
|
|
|
|
const char *wol_to_string(WakeOnLan wol) _const_;
|
|
|
|
WakeOnLan wol_from_string(const char *wol) _pure_;
|
|
|
|
|
2017-06-26 00:42:57 +02:00
|
|
|
const char *port_to_string(NetDevPort port) _const_;
|
|
|
|
NetDevPort port_from_string(const char *port) _pure_;
|
|
|
|
|
2018-11-17 15:08:22 +01:00
|
|
|
const char *ethtool_link_mode_bit_to_string(enum ethtool_link_mode_bit_indices val) _const_;
|
|
|
|
enum ethtool_link_mode_bit_indices ethtool_link_mode_bit_from_string(const char *str) _pure_;
|
2017-09-16 20:36:56 +02:00
|
|
|
|
2018-11-12 08:45:04 +01:00
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_duplex);
|
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_wol);
|
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_port);
|
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_channel);
|
|
|
|
CONFIG_PARSER_PROTOTYPE(config_parse_advertise);
|