]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
0ef6f454 LP |
2 | #pragma once |
3 | ||
a5010333 TG |
4 | /*** |
5 | This file is part of systemd. | |
6 | ||
7 | Copyright (C) 2013 Tom Gundersen <teg@jklm.no> | |
8 | ||
9 | systemd is free software; you can redistribute it and/or modify it | |
10 | under the terms of the GNU Lesser General Public License as published by | |
11 | the Free Software Foundation; either version 2.1 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | systemd is distributed in the hope that it will be useful, but | |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | Lesser General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU Lesser General Public License | |
20 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
21 | ***/ | |
22 | ||
5fde13d7 | 23 | #include <macro.h> |
a39f92d3 SS |
24 | #include <linux/ethtool.h> |
25 | ||
26 | #include "missing.h" | |
5fde13d7 | 27 | |
593022fa SS |
28 | struct link_config; |
29 | ||
5fde13d7 TG |
30 | /* we can't use DUPLEX_ prefix, as it |
31 | * clashes with <linux/ethtool.h> */ | |
32 | typedef enum Duplex { | |
9432a05c SS |
33 | DUP_HALF = DUPLEX_HALF, |
34 | DUP_FULL = DUPLEX_FULL, | |
5fde13d7 TG |
35 | _DUP_MAX, |
36 | _DUP_INVALID = -1 | |
37 | } Duplex; | |
38 | ||
39 | typedef enum WakeOnLan { | |
40 | WOL_PHY, | |
617da14c SS |
41 | WOL_UCAST, |
42 | WOL_MCAST, | |
43 | WOL_BCAST, | |
44 | WOL_ARP, | |
5fde13d7 | 45 | WOL_MAGIC, |
617da14c | 46 | WOL_MAGICSECURE, |
5fde13d7 TG |
47 | WOL_OFF, |
48 | _WOL_MAX, | |
49 | _WOL_INVALID = -1 | |
50 | } WakeOnLan; | |
51 | ||
50725d10 SS |
52 | typedef enum NetDevFeature { |
53 | NET_DEV_FEAT_GSO, | |
f7ea90fb SS |
54 | NET_DEV_FEAT_GRO, |
55 | NET_DEV_FEAT_LRO, | |
50725d10 | 56 | NET_DEV_FEAT_TSO, |
ffa69a04 | 57 | NET_DEV_FEAT_TSO6, |
50725d10 SS |
58 | NET_DEV_FEAT_UFO, |
59 | _NET_DEV_FEAT_MAX, | |
60 | _NET_DEV_FEAT_INVALID = -1 | |
61 | } NetDevFeature; | |
62 | ||
593022fa SS |
63 | typedef enum NetDevPort { |
64 | NET_DEV_PORT_TP = 0x00, | |
65 | NET_DEV_PORT_AUI = 0x01, | |
66 | NET_DEV_PORT_MII = 0x02, | |
67 | NET_DEV_PORT_FIBRE = 0x03, | |
68 | NET_DEV_PORT_BNC = 0x04, | |
69 | NET_DEV_PORT_DA = 0x05, | |
70 | NET_DEV_PORT_NONE = 0xef, | |
71 | NET_DEV_PORT_OTHER = 0xff, | |
72 | _NET_DEV_PORT_MAX, | |
73 | _NET_DEV_PORT_INVALID = -1 | |
74 | } NetDevPort; | |
a39f92d3 SS |
75 | |
76 | #define ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32 (SCHAR_MAX) | |
77 | ||
78 | /* layout of the struct passed from/to userland */ | |
79 | struct ethtool_link_usettings { | |
80 | struct ethtool_link_settings base; | |
81 | ||
82 | struct { | |
83 | uint32_t supported[ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32]; | |
84 | uint32_t advertising[ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32]; | |
85 | uint32_t lp_advertising[ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32]; | |
86 | } link_modes; | |
87 | }; | |
88 | ||
a5010333 TG |
89 | int ethtool_connect(int *ret); |
90 | ||
aedca892 TG |
91 | int ethtool_get_driver(int *fd, const char *ifname, char **ret); |
92 | int ethtool_set_speed(int *fd, const char *ifname, unsigned int speed, Duplex duplex); | |
93 | int ethtool_set_wol(int *fd, const char *ifname, WakeOnLan wol); | |
50725d10 | 94 | int ethtool_set_features(int *fd, const char *ifname, NetDevFeature *features); |
593022fa | 95 | int ethtool_set_glinksettings(int *fd, const char *ifname, struct link_config *link); |
5fde13d7 TG |
96 | |
97 | const char *duplex_to_string(Duplex d) _const_; | |
98 | Duplex duplex_from_string(const char *d) _pure_; | |
99 | ||
100 | const char *wol_to_string(WakeOnLan wol) _const_; | |
101 | WakeOnLan wol_from_string(const char *wol) _pure_; | |
102 | ||
593022fa SS |
103 | const char *port_to_string(NetDevPort port) _const_; |
104 | NetDevPort port_from_string(const char *port) _pure_; | |
105 | ||
71a61510 TG |
106 | 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); |
107 | 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); | |
593022fa | 108 | 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); |