1 /* SPDX-License-Identifier: LGPL-2.1+ */
5 Copyright (C) 2013 Tom Gundersen <teg@jklm.no>
9 #include <linux/ethtool.h>
15 /* we can't use DUPLEX_ prefix, as it
16 * clashes with <linux/ethtool.h> */
18 DUP_HALF
= DUPLEX_HALF
,
19 DUP_FULL
= DUPLEX_FULL
,
24 typedef enum WakeOnLan
{
37 typedef enum NetDevFeature
{
44 _NET_DEV_FEAT_INVALID
= -1
47 typedef enum NetDevPort
{
48 NET_DEV_PORT_TP
= 0x00,
49 NET_DEV_PORT_AUI
= 0x01,
50 NET_DEV_PORT_MII
= 0x02,
51 NET_DEV_PORT_FIBRE
= 0x03,
52 NET_DEV_PORT_BNC
= 0x04,
53 NET_DEV_PORT_DA
= 0x05,
54 NET_DEV_PORT_NONE
= 0xef,
55 NET_DEV_PORT_OTHER
= 0xff,
57 _NET_DEV_PORT_INVALID
= -1
60 #define ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32 (SCHAR_MAX)
62 /* layout of the struct passed from/to userland */
63 struct ethtool_link_usettings
{
64 struct ethtool_link_settings base
;
67 uint32_t supported
[ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32
];
68 uint32_t advertising
[ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32
];
69 uint32_t lp_advertising
[ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32
];
73 typedef struct netdev_channels
{
77 uint32_t combined_count
;
82 bool combined_count_set
;
85 int ethtool_connect(int *ret
);
87 int ethtool_get_driver(int *fd
, const char *ifname
, char **ret
);
88 int ethtool_set_speed(int *fd
, const char *ifname
, unsigned int speed
, Duplex duplex
);
89 int ethtool_set_wol(int *fd
, const char *ifname
, WakeOnLan wol
);
90 int ethtool_set_features(int *fd
, const char *ifname
, NetDevFeature
*features
);
91 int ethtool_set_glinksettings(int *fd
, const char *ifname
, struct link_config
*link
);
92 int ethtool_set_channels(int *fd
, const char *ifname
, netdev_channels
*channels
);
94 const char *duplex_to_string(Duplex d
) _const_
;
95 Duplex
duplex_from_string(const char *d
) _pure_
;
97 const char *wol_to_string(WakeOnLan wol
) _const_
;
98 WakeOnLan
wol_from_string(const char *wol
) _pure_
;
100 const char *port_to_string(NetDevPort port
) _const_
;
101 NetDevPort
port_from_string(const char *port
) _pure_
;
103 int config_parse_duplex(const char *unit
, const char *filename
, unsigned line
, const char *section
, unsigned section_line
, const char *lvalue
, int ltype
, const char *rvalue
, void *data
, void *userdata
);
104 int config_parse_wol(const char *unit
, const char *filename
, unsigned line
, const char *section
, unsigned section_line
, const char *lvalue
, int ltype
, const char *rvalue
, void *data
, void *userdata
);
105 int config_parse_port(const char *unit
, const char *filename
, unsigned line
, const char *section
, unsigned section_line
, const char *lvalue
, int ltype
, const char *rvalue
, void *data
, void *userdata
);
106 int config_parse_channel(const char *unit
, const char *filename
, unsigned line
, const char *section
, unsigned section_line
, const char *lvalue
, int ltype
, const char *rvalue
, void *data
, void *userdata
);