]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/udev/net/ethtool-util.h
fs-util: make CHASE_WARN effective with CHASE_NO_AUTOFS
[thirdparty/systemd.git] / src / udev / net / ethtool-util.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 #include <macro.h>
5 #include <linux/ethtool.h>
6
7 #include "conf-parser.h"
8 #include "missing.h"
9
10 struct link_config;
11
12 /* we can't use DUPLEX_ prefix, as it
13 * clashes with <linux/ethtool.h> */
14 typedef enum Duplex {
15 DUP_HALF = DUPLEX_HALF,
16 DUP_FULL = DUPLEX_FULL,
17 _DUP_MAX,
18 _DUP_INVALID = -1
19 } Duplex;
20
21 typedef enum WakeOnLan {
22 WOL_PHY,
23 WOL_UCAST,
24 WOL_MCAST,
25 WOL_BCAST,
26 WOL_ARP,
27 WOL_MAGIC,
28 WOL_MAGICSECURE,
29 WOL_OFF,
30 _WOL_MAX,
31 _WOL_INVALID = -1
32 } WakeOnLan;
33
34 typedef enum NetDevFeature {
35 NET_DEV_FEAT_GSO,
36 NET_DEV_FEAT_GRO,
37 NET_DEV_FEAT_LRO,
38 NET_DEV_FEAT_TSO,
39 NET_DEV_FEAT_TSO6,
40 _NET_DEV_FEAT_MAX,
41 _NET_DEV_FEAT_INVALID = -1
42 } NetDevFeature;
43
44 typedef enum NetDevPort {
45 NET_DEV_PORT_TP = 0x00,
46 NET_DEV_PORT_AUI = 0x01,
47 NET_DEV_PORT_MII = 0x02,
48 NET_DEV_PORT_FIBRE = 0x03,
49 NET_DEV_PORT_BNC = 0x04,
50 NET_DEV_PORT_DA = 0x05,
51 NET_DEV_PORT_NONE = 0xef,
52 NET_DEV_PORT_OTHER = 0xff,
53 _NET_DEV_PORT_MAX,
54 _NET_DEV_PORT_INVALID = -1
55 } NetDevPort;
56
57 #define ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32 (SCHAR_MAX)
58 #define ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NBYTES (4 * ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32)
59
60 /* layout of the struct passed from/to userland */
61 struct ethtool_link_usettings {
62 struct ethtool_link_settings base;
63
64 struct {
65 uint32_t supported[ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32];
66 uint32_t advertising[ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32];
67 uint32_t lp_advertising[ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32];
68 } link_modes;
69 };
70
71 typedef struct netdev_channels {
72 uint32_t rx_count;
73 uint32_t tx_count;
74 uint32_t other_count;
75 uint32_t combined_count;
76
77 bool rx_count_set;
78 bool tx_count_set;
79 bool other_count_set;
80 bool combined_count_set;
81 } netdev_channels;
82
83 int ethtool_connect(int *ret);
84
85 int ethtool_get_driver(int *fd, const char *ifname, char **ret);
86 int ethtool_set_speed(int *fd, const char *ifname, unsigned speed, Duplex duplex);
87 int ethtool_set_wol(int *fd, const char *ifname, WakeOnLan wol);
88 int ethtool_set_features(int *fd, const char *ifname, int *features);
89 int ethtool_set_glinksettings(int *fd, const char *ifname, struct link_config *link);
90 int ethtool_set_channels(int *fd, const char *ifname, netdev_channels *channels);
91
92 const char *duplex_to_string(Duplex d) _const_;
93 Duplex duplex_from_string(const char *d) _pure_;
94
95 const char *wol_to_string(WakeOnLan wol) _const_;
96 WakeOnLan wol_from_string(const char *wol) _pure_;
97
98 const char *port_to_string(NetDevPort port) _const_;
99 NetDevPort port_from_string(const char *port) _pure_;
100
101 const char *ethtool_link_mode_bit_to_string(enum ethtool_link_mode_bit_indices val) _const_;
102 enum ethtool_link_mode_bit_indices ethtool_link_mode_bit_from_string(const char *str) _pure_;
103
104 CONFIG_PARSER_PROTOTYPE(config_parse_duplex);
105 CONFIG_PARSER_PROTOTYPE(config_parse_wol);
106 CONFIG_PARSER_PROTOTYPE(config_parse_port);
107 CONFIG_PARSER_PROTOTYPE(config_parse_channel);
108 CONFIG_PARSER_PROTOTYPE(config_parse_advertise);