]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/ethtool-util.h
catalog: update Polish translation
[thirdparty/systemd.git] / src / shared / ethtool-util.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 #include <macro.h>
5 #include <net/ethernet.h>
6 #include <linux/ethtool.h>
7
8 #include "conf-parser.h"
9
10 #define N_ADVERTISE 3
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_RX,
36 NET_DEV_FEAT_TX,
37 NET_DEV_FEAT_GSO,
38 NET_DEV_FEAT_GRO,
39 NET_DEV_FEAT_LRO,
40 NET_DEV_FEAT_TSO,
41 NET_DEV_FEAT_TSO6,
42 _NET_DEV_FEAT_MAX,
43 _NET_DEV_FEAT_INVALID = -1
44 } NetDevFeature;
45
46 typedef enum NetDevPort {
47 NET_DEV_PORT_TP = PORT_TP,
48 NET_DEV_PORT_AUI = PORT_AUI,
49 NET_DEV_PORT_MII = PORT_MII,
50 NET_DEV_PORT_FIBRE = PORT_FIBRE,
51 NET_DEV_PORT_BNC = PORT_BNC,
52 NET_DEV_PORT_DA = PORT_DA,
53 NET_DEV_PORT_NONE = PORT_NONE,
54 NET_DEV_PORT_OTHER = PORT_OTHER,
55 _NET_DEV_PORT_MAX,
56 _NET_DEV_PORT_INVALID = -1
57 } NetDevPort;
58
59 #define ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32 (SCHAR_MAX)
60 #define ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NBYTES (4 * ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32)
61
62 /* layout of the struct passed from/to userland */
63 struct ethtool_link_usettings {
64 struct ethtool_link_settings base;
65
66 struct {
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];
70 } link_modes;
71 };
72
73 typedef struct netdev_channels {
74 uint32_t rx_count;
75 uint32_t tx_count;
76 uint32_t other_count;
77 uint32_t combined_count;
78
79 bool rx_count_set;
80 bool tx_count_set;
81 bool other_count_set;
82 bool combined_count_set;
83 } netdev_channels;
84
85 typedef struct netdev_ring_param {
86 uint32_t rx_pending;
87 uint32_t rx_mini_pending;
88 uint32_t rx_jumbo_pending;
89 uint32_t tx_pending;
90
91 bool rx_pending_set;
92 bool rx_mini_pending_set;
93 bool rx_jumbo_pending_set;
94 bool tx_pending_set;
95 } netdev_ring_param;
96
97 int ethtool_get_driver(int *ethtool_fd, const char *ifname, char **ret);
98 int ethtool_get_link_info(int *ethtool_fd, const char *ifname,
99 int *ret_autonegotiation, uint64_t *ret_speed,
100 Duplex *ret_duplex, NetDevPort *ret_port);
101 int ethtool_get_permanent_macaddr(int *ethtool_fd, const char *ifname, struct ether_addr *ret);
102 int ethtool_set_speed(int *ethtool_fd, const char *ifname, unsigned speed, Duplex duplex);
103 int ethtool_set_wol(int *ethtool_fd, const char *ifname, WakeOnLan wol);
104 int ethtool_set_nic_buffer_size(int *ethtool_fd, const char *ifname, netdev_ring_param *ring);
105 int ethtool_set_features(int *ethtool_fd, const char *ifname, int *features);
106 int ethtool_set_glinksettings(int *ethtool_fd, const char *ifname,
107 int autonegotiation, uint32_t advertise[static N_ADVERTISE],
108 uint64_t speed, Duplex duplex, NetDevPort port);
109 int ethtool_set_channels(int *ethtool_fd, const char *ifname, netdev_channels *channels);
110 int ethtool_set_flow_control(int *fd, const char *ifname, int rx, int tx, int autoneg);
111
112 const char *duplex_to_string(Duplex d) _const_;
113 Duplex duplex_from_string(const char *d) _pure_;
114
115 const char *wol_to_string(WakeOnLan wol) _const_;
116 WakeOnLan wol_from_string(const char *wol) _pure_;
117
118 const char *port_to_string(NetDevPort port) _const_;
119 NetDevPort port_from_string(const char *port) _pure_;
120
121 const char *ethtool_link_mode_bit_to_string(enum ethtool_link_mode_bit_indices val) _const_;
122 enum ethtool_link_mode_bit_indices ethtool_link_mode_bit_from_string(const char *str) _pure_;
123
124 CONFIG_PARSER_PROTOTYPE(config_parse_duplex);
125 CONFIG_PARSER_PROTOTYPE(config_parse_wol);
126 CONFIG_PARSER_PROTOTYPE(config_parse_port);
127 CONFIG_PARSER_PROTOTYPE(config_parse_channel);
128 CONFIG_PARSER_PROTOTYPE(config_parse_advertise);
129 CONFIG_PARSER_PROTOTYPE(config_parse_nic_buffer_size);