1d44e1310SMichal Kubecek // SPDX-License-Identifier: GPL-2.0-only
2d44e1310SMichal Kubecek
3c7d759ebSJakub Kicinski #include <linux/ethtool_netlink.h>
4f76510b4SMichal Kubecek #include <linux/net_tstamp.h>
55b071c59SMichal Kubecek #include <linux/phy.h>
64895d780SFlorian Fainelli #include <linux/rtnetlink.h>
7c156174aSYangbo Lu #include <linux/ptp_clock_kernel.h>
8f76510b4SMichal Kubecek
9d44e1310SMichal Kubecek #include "common.h"
10d44e1310SMichal Kubecek
11d44e1310SMichal Kubecek const char netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN] = {
12d44e1310SMichal Kubecek [NETIF_F_SG_BIT] = "tx-scatter-gather",
13d44e1310SMichal Kubecek [NETIF_F_IP_CSUM_BIT] = "tx-checksum-ipv4",
14d44e1310SMichal Kubecek [NETIF_F_HW_CSUM_BIT] = "tx-checksum-ip-generic",
15d44e1310SMichal Kubecek [NETIF_F_IPV6_CSUM_BIT] = "tx-checksum-ipv6",
16d44e1310SMichal Kubecek [NETIF_F_HIGHDMA_BIT] = "highdma",
17d44e1310SMichal Kubecek [NETIF_F_FRAGLIST_BIT] = "tx-scatter-gather-fraglist",
18d44e1310SMichal Kubecek [NETIF_F_HW_VLAN_CTAG_TX_BIT] = "tx-vlan-hw-insert",
19d44e1310SMichal Kubecek
20d44e1310SMichal Kubecek [NETIF_F_HW_VLAN_CTAG_RX_BIT] = "rx-vlan-hw-parse",
21d44e1310SMichal Kubecek [NETIF_F_HW_VLAN_CTAG_FILTER_BIT] = "rx-vlan-filter",
22d44e1310SMichal Kubecek [NETIF_F_HW_VLAN_STAG_TX_BIT] = "tx-vlan-stag-hw-insert",
23d44e1310SMichal Kubecek [NETIF_F_HW_VLAN_STAG_RX_BIT] = "rx-vlan-stag-hw-parse",
24d44e1310SMichal Kubecek [NETIF_F_HW_VLAN_STAG_FILTER_BIT] = "rx-vlan-stag-filter",
25d44e1310SMichal Kubecek [NETIF_F_VLAN_CHALLENGED_BIT] = "vlan-challenged",
26d44e1310SMichal Kubecek [NETIF_F_GSO_BIT] = "tx-generic-segmentation",
27d44e1310SMichal Kubecek [NETIF_F_LLTX_BIT] = "tx-lockless",
28d44e1310SMichal Kubecek [NETIF_F_NETNS_LOCAL_BIT] = "netns-local",
29d44e1310SMichal Kubecek [NETIF_F_GRO_BIT] = "rx-gro",
30d44e1310SMichal Kubecek [NETIF_F_GRO_HW_BIT] = "rx-gro-hw",
31d44e1310SMichal Kubecek [NETIF_F_LRO_BIT] = "rx-lro",
32d44e1310SMichal Kubecek
33d44e1310SMichal Kubecek [NETIF_F_TSO_BIT] = "tx-tcp-segmentation",
34d44e1310SMichal Kubecek [NETIF_F_GSO_ROBUST_BIT] = "tx-gso-robust",
35d44e1310SMichal Kubecek [NETIF_F_TSO_ECN_BIT] = "tx-tcp-ecn-segmentation",
36d44e1310SMichal Kubecek [NETIF_F_TSO_MANGLEID_BIT] = "tx-tcp-mangleid-segmentation",
37d44e1310SMichal Kubecek [NETIF_F_TSO6_BIT] = "tx-tcp6-segmentation",
38d44e1310SMichal Kubecek [NETIF_F_FSO_BIT] = "tx-fcoe-segmentation",
39d44e1310SMichal Kubecek [NETIF_F_GSO_GRE_BIT] = "tx-gre-segmentation",
40d44e1310SMichal Kubecek [NETIF_F_GSO_GRE_CSUM_BIT] = "tx-gre-csum-segmentation",
41d44e1310SMichal Kubecek [NETIF_F_GSO_IPXIP4_BIT] = "tx-ipxip4-segmentation",
42d44e1310SMichal Kubecek [NETIF_F_GSO_IPXIP6_BIT] = "tx-ipxip6-segmentation",
43d44e1310SMichal Kubecek [NETIF_F_GSO_UDP_TUNNEL_BIT] = "tx-udp_tnl-segmentation",
44d44e1310SMichal Kubecek [NETIF_F_GSO_UDP_TUNNEL_CSUM_BIT] = "tx-udp_tnl-csum-segmentation",
45d44e1310SMichal Kubecek [NETIF_F_GSO_PARTIAL_BIT] = "tx-gso-partial",
46b4730ae6SAlexander Lobakin [NETIF_F_GSO_TUNNEL_REMCSUM_BIT] = "tx-tunnel-remcsum-segmentation",
47d44e1310SMichal Kubecek [NETIF_F_GSO_SCTP_BIT] = "tx-sctp-segmentation",
48d44e1310SMichal Kubecek [NETIF_F_GSO_ESP_BIT] = "tx-esp-segmentation",
49d44e1310SMichal Kubecek [NETIF_F_GSO_UDP_L4_BIT] = "tx-udp-segmentation",
50eddbf5d0SAlexander Lobakin [NETIF_F_GSO_FRAGLIST_BIT] = "tx-gso-list",
51d44e1310SMichal Kubecek
52d44e1310SMichal Kubecek [NETIF_F_FCOE_CRC_BIT] = "tx-checksum-fcoe-crc",
53d44e1310SMichal Kubecek [NETIF_F_SCTP_CRC_BIT] = "tx-checksum-sctp",
54d44e1310SMichal Kubecek [NETIF_F_FCOE_MTU_BIT] = "fcoe-mtu",
55d44e1310SMichal Kubecek [NETIF_F_NTUPLE_BIT] = "rx-ntuple-filter",
56d44e1310SMichal Kubecek [NETIF_F_RXHASH_BIT] = "rx-hashing",
57d44e1310SMichal Kubecek [NETIF_F_RXCSUM_BIT] = "rx-checksum",
58d44e1310SMichal Kubecek [NETIF_F_NOCACHE_COPY_BIT] = "tx-nocache-copy",
59d44e1310SMichal Kubecek [NETIF_F_LOOPBACK_BIT] = "loopback",
60d44e1310SMichal Kubecek [NETIF_F_RXFCS_BIT] = "rx-fcs",
61d44e1310SMichal Kubecek [NETIF_F_RXALL_BIT] = "rx-all",
62d44e1310SMichal Kubecek [NETIF_F_HW_L2FW_DOFFLOAD_BIT] = "l2-fwd-offload",
63d44e1310SMichal Kubecek [NETIF_F_HW_TC_BIT] = "hw-tc-offload",
64d44e1310SMichal Kubecek [NETIF_F_HW_ESP_BIT] = "esp-hw-offload",
65d44e1310SMichal Kubecek [NETIF_F_HW_ESP_TX_CSUM_BIT] = "esp-tx-csum-hw-offload",
66d44e1310SMichal Kubecek [NETIF_F_RX_UDP_TUNNEL_PORT_BIT] = "rx-udp_tunnel-port-offload",
67d44e1310SMichal Kubecek [NETIF_F_HW_TLS_RECORD_BIT] = "tls-hw-record",
68d44e1310SMichal Kubecek [NETIF_F_HW_TLS_TX_BIT] = "tls-hw-tx-offload",
69d44e1310SMichal Kubecek [NETIF_F_HW_TLS_RX_BIT] = "tls-hw-rx-offload",
703b335832SSteffen Klassert [NETIF_F_GRO_FRAGLIST_BIT] = "rx-gro-list",
715908220bSAntoine Tenart [NETIF_F_HW_MACSEC_BIT] = "macsec-hw-offload",
726f1c0ea1SAlexander Lobakin [NETIF_F_GRO_UDP_FWD_BIT] = "rx-udp-gro-forwarding",
73dcf0cd1cSGeorge McCollister [NETIF_F_HW_HSR_TAG_INS_BIT] = "hsr-tag-ins-offload",
74dcf0cd1cSGeorge McCollister [NETIF_F_HW_HSR_TAG_RM_BIT] = "hsr-tag-rm-offload",
75dcf0cd1cSGeorge McCollister [NETIF_F_HW_HSR_FWD_BIT] = "hsr-fwd-offload",
76dcf0cd1cSGeorge McCollister [NETIF_F_HW_HSR_DUP_BIT] = "hsr-dup-offload",
77d44e1310SMichal Kubecek };
78d44e1310SMichal Kubecek
79d44e1310SMichal Kubecek const char
80d44e1310SMichal Kubecek rss_hash_func_strings[ETH_RSS_HASH_FUNCS_COUNT][ETH_GSTRING_LEN] = {
81d44e1310SMichal Kubecek [ETH_RSS_HASH_TOP_BIT] = "toeplitz",
82d44e1310SMichal Kubecek [ETH_RSS_HASH_XOR_BIT] = "xor",
83d44e1310SMichal Kubecek [ETH_RSS_HASH_CRC32_BIT] = "crc32",
84d44e1310SMichal Kubecek };
85d44e1310SMichal Kubecek
86d44e1310SMichal Kubecek const char
87d44e1310SMichal Kubecek tunable_strings[__ETHTOOL_TUNABLE_COUNT][ETH_GSTRING_LEN] = {
88d44e1310SMichal Kubecek [ETHTOOL_ID_UNSPEC] = "Unspec",
89d44e1310SMichal Kubecek [ETHTOOL_RX_COPYBREAK] = "rx-copybreak",
90d44e1310SMichal Kubecek [ETHTOOL_TX_COPYBREAK] = "tx-copybreak",
91d44e1310SMichal Kubecek [ETHTOOL_PFC_PREVENTION_TOUT] = "pfc-prevention-tout",
92448f413aSHao Chen [ETHTOOL_TX_COPYBREAK_BUF_SIZE] = "tx-copybreak-buf-size",
93d44e1310SMichal Kubecek };
94d44e1310SMichal Kubecek
95d44e1310SMichal Kubecek const char
96d44e1310SMichal Kubecek phy_tunable_strings[__ETHTOOL_PHY_TUNABLE_COUNT][ETH_GSTRING_LEN] = {
97d44e1310SMichal Kubecek [ETHTOOL_ID_UNSPEC] = "Unspec",
98d44e1310SMichal Kubecek [ETHTOOL_PHY_DOWNSHIFT] = "phy-downshift",
99d44e1310SMichal Kubecek [ETHTOOL_PHY_FAST_LINK_DOWN] = "phy-fast-link-down",
100d44e1310SMichal Kubecek [ETHTOOL_PHY_EDPD] = "phy-energy-detect-power-down",
101d44e1310SMichal Kubecek };
102428c122fSMichal Kubecek
103428c122fSMichal Kubecek #define __LINK_MODE_NAME(speed, type, duplex) \
104428c122fSMichal Kubecek #speed "base" #type "/" #duplex
105428c122fSMichal Kubecek #define __DEFINE_LINK_MODE_NAME(speed, type, duplex) \
106428c122fSMichal Kubecek [ETHTOOL_LINK_MODE(speed, type, duplex)] = \
107428c122fSMichal Kubecek __LINK_MODE_NAME(speed, type, duplex)
108428c122fSMichal Kubecek #define __DEFINE_SPECIAL_MODE_NAME(_mode, _name) \
109428c122fSMichal Kubecek [ETHTOOL_LINK_MODE_ ## _mode ## _BIT] = _name
110428c122fSMichal Kubecek
111428c122fSMichal Kubecek const char link_mode_names[][ETH_GSTRING_LEN] = {
112428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(10, T, Half),
113428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(10, T, Full),
114428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(100, T, Half),
115428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(100, T, Full),
116428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(1000, T, Half),
117428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(1000, T, Full),
118428c122fSMichal Kubecek __DEFINE_SPECIAL_MODE_NAME(Autoneg, "Autoneg"),
119428c122fSMichal Kubecek __DEFINE_SPECIAL_MODE_NAME(TP, "TP"),
120428c122fSMichal Kubecek __DEFINE_SPECIAL_MODE_NAME(AUI, "AUI"),
121428c122fSMichal Kubecek __DEFINE_SPECIAL_MODE_NAME(MII, "MII"),
122428c122fSMichal Kubecek __DEFINE_SPECIAL_MODE_NAME(FIBRE, "FIBRE"),
123428c122fSMichal Kubecek __DEFINE_SPECIAL_MODE_NAME(BNC, "BNC"),
124428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(10000, T, Full),
125428c122fSMichal Kubecek __DEFINE_SPECIAL_MODE_NAME(Pause, "Pause"),
126428c122fSMichal Kubecek __DEFINE_SPECIAL_MODE_NAME(Asym_Pause, "Asym_Pause"),
127428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(2500, X, Full),
128428c122fSMichal Kubecek __DEFINE_SPECIAL_MODE_NAME(Backplane, "Backplane"),
129428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(1000, KX, Full),
130428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(10000, KX4, Full),
131428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(10000, KR, Full),
132428c122fSMichal Kubecek __DEFINE_SPECIAL_MODE_NAME(10000baseR_FEC, "10000baseR_FEC"),
133428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(20000, MLD2, Full),
134428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(20000, KR2, Full),
135428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(40000, KR4, Full),
136428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(40000, CR4, Full),
137428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(40000, SR4, Full),
138428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(40000, LR4, Full),
139428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(56000, KR4, Full),
140428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(56000, CR4, Full),
141428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(56000, SR4, Full),
142428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(56000, LR4, Full),
143428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(25000, CR, Full),
144428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(25000, KR, Full),
145428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(25000, SR, Full),
146428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(50000, CR2, Full),
147428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(50000, KR2, Full),
148428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(100000, KR4, Full),
149428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(100000, SR4, Full),
150428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(100000, CR4, Full),
151428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(100000, LR4_ER4, Full),
152428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(50000, SR2, Full),
153428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(1000, X, Full),
154428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(10000, CR, Full),
155428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(10000, SR, Full),
156428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(10000, LR, Full),
157428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(10000, LRM, Full),
158428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(10000, ER, Full),
159428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(2500, T, Full),
160428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(5000, T, Full),
161428c122fSMichal Kubecek __DEFINE_SPECIAL_MODE_NAME(FEC_NONE, "None"),
162428c122fSMichal Kubecek __DEFINE_SPECIAL_MODE_NAME(FEC_RS, "RS"),
163428c122fSMichal Kubecek __DEFINE_SPECIAL_MODE_NAME(FEC_BASER, "BASER"),
164428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(50000, KR, Full),
165428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(50000, SR, Full),
166428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(50000, CR, Full),
167428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(50000, LR_ER_FR, Full),
168428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(50000, DR, Full),
169428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(100000, KR2, Full),
170428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(100000, SR2, Full),
171428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(100000, CR2, Full),
172428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(100000, LR2_ER2_FR2, Full),
173428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(100000, DR2, Full),
174428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(200000, KR4, Full),
175428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(200000, SR4, Full),
176428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(200000, LR4_ER4_FR4, Full),
177428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(200000, DR4, Full),
178428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(200000, CR4, Full),
179428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(100, T1, Full),
180428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(1000, T1, Full),
181428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(400000, KR8, Full),
182428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(400000, SR8, Full),
183428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(400000, LR8_ER8_FR8, Full),
184428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(400000, DR8, Full),
185428c122fSMichal Kubecek __DEFINE_LINK_MODE_NAME(400000, CR8, Full),
186f623e597SAya Levin __DEFINE_SPECIAL_MODE_NAME(FEC_LLRS, "LLRS"),
187065e0d42SMeir Lichtinger __DEFINE_LINK_MODE_NAME(100000, KR, Full),
188065e0d42SMeir Lichtinger __DEFINE_LINK_MODE_NAME(100000, SR, Full),
189065e0d42SMeir Lichtinger __DEFINE_LINK_MODE_NAME(100000, LR_ER_FR, Full),
190065e0d42SMeir Lichtinger __DEFINE_LINK_MODE_NAME(100000, DR, Full),
191065e0d42SMeir Lichtinger __DEFINE_LINK_MODE_NAME(100000, CR, Full),
192065e0d42SMeir Lichtinger __DEFINE_LINK_MODE_NAME(200000, KR2, Full),
193065e0d42SMeir Lichtinger __DEFINE_LINK_MODE_NAME(200000, SR2, Full),
194065e0d42SMeir Lichtinger __DEFINE_LINK_MODE_NAME(200000, LR2_ER2_FR2, Full),
195065e0d42SMeir Lichtinger __DEFINE_LINK_MODE_NAME(200000, DR2, Full),
196065e0d42SMeir Lichtinger __DEFINE_LINK_MODE_NAME(200000, CR2, Full),
197065e0d42SMeir Lichtinger __DEFINE_LINK_MODE_NAME(400000, KR4, Full),
198065e0d42SMeir Lichtinger __DEFINE_LINK_MODE_NAME(400000, SR4, Full),
199065e0d42SMeir Lichtinger __DEFINE_LINK_MODE_NAME(400000, LR4_ER4_FR4, Full),
200065e0d42SMeir Lichtinger __DEFINE_LINK_MODE_NAME(400000, DR4, Full),
201065e0d42SMeir Lichtinger __DEFINE_LINK_MODE_NAME(400000, CR4, Full),
20255f13311SDan Murphy __DEFINE_LINK_MODE_NAME(100, FX, Half),
20355f13311SDan Murphy __DEFINE_LINK_MODE_NAME(100, FX, Full),
2043254e0b9SAlexandru Tachici __DEFINE_LINK_MODE_NAME(10, T1L, Full),
205404c7678SAmit Cohen __DEFINE_LINK_MODE_NAME(800000, CR8, Full),
206404c7678SAmit Cohen __DEFINE_LINK_MODE_NAME(800000, KR8, Full),
207404c7678SAmit Cohen __DEFINE_LINK_MODE_NAME(800000, DR8, Full),
208404c7678SAmit Cohen __DEFINE_LINK_MODE_NAME(800000, DR8_2, Full),
209404c7678SAmit Cohen __DEFINE_LINK_MODE_NAME(800000, SR8, Full),
210404c7678SAmit Cohen __DEFINE_LINK_MODE_NAME(800000, VR8, Full),
21116178c8eSPiergiorgio Beruto __DEFINE_LINK_MODE_NAME(10, T1S, Full),
21216178c8eSPiergiorgio Beruto __DEFINE_LINK_MODE_NAME(10, T1S, Half),
21316178c8eSPiergiorgio Beruto __DEFINE_LINK_MODE_NAME(10, T1S_P2MP, Half),
214428c122fSMichal Kubecek };
215428c122fSMichal Kubecek static_assert(ARRAY_SIZE(link_mode_names) == __ETHTOOL_LINK_MODE_MASK_NBITS);
216459e0b81SMichal Kubecek
217c8907043SDanielle Ratson #define __LINK_MODE_LANES_CR 1
218c8907043SDanielle Ratson #define __LINK_MODE_LANES_CR2 2
219c8907043SDanielle Ratson #define __LINK_MODE_LANES_CR4 4
220c8907043SDanielle Ratson #define __LINK_MODE_LANES_CR8 8
221c8907043SDanielle Ratson #define __LINK_MODE_LANES_DR 1
222c8907043SDanielle Ratson #define __LINK_MODE_LANES_DR2 2
223c8907043SDanielle Ratson #define __LINK_MODE_LANES_DR4 4
224c8907043SDanielle Ratson #define __LINK_MODE_LANES_DR8 8
225c8907043SDanielle Ratson #define __LINK_MODE_LANES_KR 1
226c8907043SDanielle Ratson #define __LINK_MODE_LANES_KR2 2
227c8907043SDanielle Ratson #define __LINK_MODE_LANES_KR4 4
228c8907043SDanielle Ratson #define __LINK_MODE_LANES_KR8 8
229c8907043SDanielle Ratson #define __LINK_MODE_LANES_SR 1
230c8907043SDanielle Ratson #define __LINK_MODE_LANES_SR2 2
231c8907043SDanielle Ratson #define __LINK_MODE_LANES_SR4 4
232c8907043SDanielle Ratson #define __LINK_MODE_LANES_SR8 8
233c8907043SDanielle Ratson #define __LINK_MODE_LANES_ER 1
234c8907043SDanielle Ratson #define __LINK_MODE_LANES_KX 1
235c8907043SDanielle Ratson #define __LINK_MODE_LANES_KX4 4
236c8907043SDanielle Ratson #define __LINK_MODE_LANES_LR 1
237c8907043SDanielle Ratson #define __LINK_MODE_LANES_LR4 4
238c8907043SDanielle Ratson #define __LINK_MODE_LANES_LR4_ER4 4
239c8907043SDanielle Ratson #define __LINK_MODE_LANES_LR_ER_FR 1
240c8907043SDanielle Ratson #define __LINK_MODE_LANES_LR2_ER2_FR2 2
241c8907043SDanielle Ratson #define __LINK_MODE_LANES_LR4_ER4_FR4 4
242c8907043SDanielle Ratson #define __LINK_MODE_LANES_LR8_ER8_FR8 8
243c8907043SDanielle Ratson #define __LINK_MODE_LANES_LRM 1
244c8907043SDanielle Ratson #define __LINK_MODE_LANES_MLD2 2
245c8907043SDanielle Ratson #define __LINK_MODE_LANES_T 1
246c8907043SDanielle Ratson #define __LINK_MODE_LANES_T1 1
247c8907043SDanielle Ratson #define __LINK_MODE_LANES_X 1
248c8907043SDanielle Ratson #define __LINK_MODE_LANES_FX 1
2493254e0b9SAlexandru Tachici #define __LINK_MODE_LANES_T1L 1
25016178c8eSPiergiorgio Beruto #define __LINK_MODE_LANES_T1S 1
25116178c8eSPiergiorgio Beruto #define __LINK_MODE_LANES_T1S_P2MP 1
252404c7678SAmit Cohen #define __LINK_MODE_LANES_VR8 8
253404c7678SAmit Cohen #define __LINK_MODE_LANES_DR8_2 8
254c8907043SDanielle Ratson
255c8907043SDanielle Ratson #define __DEFINE_LINK_MODE_PARAMS(_speed, _type, _duplex) \
256c8907043SDanielle Ratson [ETHTOOL_LINK_MODE(_speed, _type, _duplex)] = { \
257c8907043SDanielle Ratson .speed = SPEED_ ## _speed, \
258c8907043SDanielle Ratson .lanes = __LINK_MODE_LANES_ ## _type, \
259c8907043SDanielle Ratson .duplex = __DUPLEX_ ## _duplex \
260c8907043SDanielle Ratson }
261c8907043SDanielle Ratson #define __DUPLEX_Half DUPLEX_HALF
262c8907043SDanielle Ratson #define __DUPLEX_Full DUPLEX_FULL
263c8907043SDanielle Ratson #define __DEFINE_SPECIAL_MODE_PARAMS(_mode) \
264c8907043SDanielle Ratson [ETHTOOL_LINK_MODE_ ## _mode ## _BIT] = { \
265c8907043SDanielle Ratson .speed = SPEED_UNKNOWN, \
266c8907043SDanielle Ratson .lanes = 0, \
267c8907043SDanielle Ratson .duplex = DUPLEX_UNKNOWN, \
268c8907043SDanielle Ratson }
269c8907043SDanielle Ratson
270c8907043SDanielle Ratson const struct link_mode_info link_mode_params[] = {
271c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(10, T, Half),
272c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(10, T, Full),
273c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(100, T, Half),
274c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(100, T, Full),
275c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(1000, T, Half),
276c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(1000, T, Full),
277c8907043SDanielle Ratson __DEFINE_SPECIAL_MODE_PARAMS(Autoneg),
278c8907043SDanielle Ratson __DEFINE_SPECIAL_MODE_PARAMS(TP),
279c8907043SDanielle Ratson __DEFINE_SPECIAL_MODE_PARAMS(AUI),
280c8907043SDanielle Ratson __DEFINE_SPECIAL_MODE_PARAMS(MII),
281c8907043SDanielle Ratson __DEFINE_SPECIAL_MODE_PARAMS(FIBRE),
282c8907043SDanielle Ratson __DEFINE_SPECIAL_MODE_PARAMS(BNC),
283c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(10000, T, Full),
284c8907043SDanielle Ratson __DEFINE_SPECIAL_MODE_PARAMS(Pause),
285c8907043SDanielle Ratson __DEFINE_SPECIAL_MODE_PARAMS(Asym_Pause),
286c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(2500, X, Full),
287c8907043SDanielle Ratson __DEFINE_SPECIAL_MODE_PARAMS(Backplane),
288c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(1000, KX, Full),
289c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(10000, KX4, Full),
290c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(10000, KR, Full),
291c8907043SDanielle Ratson [ETHTOOL_LINK_MODE_10000baseR_FEC_BIT] = {
292c8907043SDanielle Ratson .speed = SPEED_10000,
293fde32dbeSDanielle Ratson .lanes = 1,
294c8907043SDanielle Ratson .duplex = DUPLEX_FULL,
295c8907043SDanielle Ratson },
296c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(20000, MLD2, Full),
297c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(20000, KR2, Full),
298c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(40000, KR4, Full),
299c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(40000, CR4, Full),
300c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(40000, SR4, Full),
301c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(40000, LR4, Full),
302c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(56000, KR4, Full),
303c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(56000, CR4, Full),
304c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(56000, SR4, Full),
305c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(56000, LR4, Full),
306c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(25000, CR, Full),
307c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(25000, KR, Full),
308c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(25000, SR, Full),
309c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(50000, CR2, Full),
310c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(50000, KR2, Full),
311c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(100000, KR4, Full),
312c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(100000, SR4, Full),
313c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(100000, CR4, Full),
314c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(100000, LR4_ER4, Full),
315c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(50000, SR2, Full),
316c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(1000, X, Full),
317c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(10000, CR, Full),
318c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(10000, SR, Full),
319c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(10000, LR, Full),
320c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(10000, LRM, Full),
321c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(10000, ER, Full),
322c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(2500, T, Full),
323c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(5000, T, Full),
324c8907043SDanielle Ratson __DEFINE_SPECIAL_MODE_PARAMS(FEC_NONE),
325c8907043SDanielle Ratson __DEFINE_SPECIAL_MODE_PARAMS(FEC_RS),
326c8907043SDanielle Ratson __DEFINE_SPECIAL_MODE_PARAMS(FEC_BASER),
327c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(50000, KR, Full),
328c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(50000, SR, Full),
329c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(50000, CR, Full),
330c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(50000, LR_ER_FR, Full),
331c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(50000, DR, Full),
332c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(100000, KR2, Full),
333c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(100000, SR2, Full),
334c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(100000, CR2, Full),
335c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(100000, LR2_ER2_FR2, Full),
336c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(100000, DR2, Full),
337c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(200000, KR4, Full),
338c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(200000, SR4, Full),
339c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(200000, LR4_ER4_FR4, Full),
340c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(200000, DR4, Full),
341c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(200000, CR4, Full),
342c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(100, T1, Full),
343c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(1000, T1, Full),
344c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(400000, KR8, Full),
345c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(400000, SR8, Full),
346c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(400000, LR8_ER8_FR8, Full),
347c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(400000, DR8, Full),
348c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(400000, CR8, Full),
349c8907043SDanielle Ratson __DEFINE_SPECIAL_MODE_PARAMS(FEC_LLRS),
350c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(100000, KR, Full),
351c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(100000, SR, Full),
352c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(100000, LR_ER_FR, Full),
353c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(100000, DR, Full),
354c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(100000, CR, Full),
355c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(200000, KR2, Full),
356c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(200000, SR2, Full),
357c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(200000, LR2_ER2_FR2, Full),
358c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(200000, DR2, Full),
359c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(200000, CR2, Full),
360c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(400000, KR4, Full),
361c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(400000, SR4, Full),
362c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(400000, LR4_ER4_FR4, Full),
363c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(400000, DR4, Full),
364c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(400000, CR4, Full),
365c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(100, FX, Half),
366c8907043SDanielle Ratson __DEFINE_LINK_MODE_PARAMS(100, FX, Full),
3673254e0b9SAlexandru Tachici __DEFINE_LINK_MODE_PARAMS(10, T1L, Full),
368404c7678SAmit Cohen __DEFINE_LINK_MODE_PARAMS(800000, CR8, Full),
369404c7678SAmit Cohen __DEFINE_LINK_MODE_PARAMS(800000, KR8, Full),
370404c7678SAmit Cohen __DEFINE_LINK_MODE_PARAMS(800000, DR8, Full),
371404c7678SAmit Cohen __DEFINE_LINK_MODE_PARAMS(800000, DR8_2, Full),
372404c7678SAmit Cohen __DEFINE_LINK_MODE_PARAMS(800000, SR8, Full),
373404c7678SAmit Cohen __DEFINE_LINK_MODE_PARAMS(800000, VR8, Full),
37416178c8eSPiergiorgio Beruto __DEFINE_LINK_MODE_PARAMS(10, T1S, Full),
37516178c8eSPiergiorgio Beruto __DEFINE_LINK_MODE_PARAMS(10, T1S, Half),
37616178c8eSPiergiorgio Beruto __DEFINE_LINK_MODE_PARAMS(10, T1S_P2MP, Half),
377c8907043SDanielle Ratson };
378c8907043SDanielle Ratson static_assert(ARRAY_SIZE(link_mode_params) == __ETHTOOL_LINK_MODE_MASK_NBITS);
379c8907043SDanielle Ratson
3806a94b8ccSMichal Kubecek const char netif_msg_class_names[][ETH_GSTRING_LEN] = {
3816a94b8ccSMichal Kubecek [NETIF_MSG_DRV_BIT] = "drv",
3826a94b8ccSMichal Kubecek [NETIF_MSG_PROBE_BIT] = "probe",
3836a94b8ccSMichal Kubecek [NETIF_MSG_LINK_BIT] = "link",
3846a94b8ccSMichal Kubecek [NETIF_MSG_TIMER_BIT] = "timer",
3856a94b8ccSMichal Kubecek [NETIF_MSG_IFDOWN_BIT] = "ifdown",
3866a94b8ccSMichal Kubecek [NETIF_MSG_IFUP_BIT] = "ifup",
3876a94b8ccSMichal Kubecek [NETIF_MSG_RX_ERR_BIT] = "rx_err",
3886a94b8ccSMichal Kubecek [NETIF_MSG_TX_ERR_BIT] = "tx_err",
3896a94b8ccSMichal Kubecek [NETIF_MSG_TX_QUEUED_BIT] = "tx_queued",
3906a94b8ccSMichal Kubecek [NETIF_MSG_INTR_BIT] = "intr",
3916a94b8ccSMichal Kubecek [NETIF_MSG_TX_DONE_BIT] = "tx_done",
3926a94b8ccSMichal Kubecek [NETIF_MSG_RX_STATUS_BIT] = "rx_status",
3936a94b8ccSMichal Kubecek [NETIF_MSG_PKTDATA_BIT] = "pktdata",
3946a94b8ccSMichal Kubecek [NETIF_MSG_HW_BIT] = "hw",
3956a94b8ccSMichal Kubecek [NETIF_MSG_WOL_BIT] = "wol",
3966a94b8ccSMichal Kubecek };
3976a94b8ccSMichal Kubecek static_assert(ARRAY_SIZE(netif_msg_class_names) == NETIF_MSG_CLASS_COUNT);
3986a94b8ccSMichal Kubecek
39951ea22b0SMichal Kubecek const char wol_mode_names[][ETH_GSTRING_LEN] = {
40051ea22b0SMichal Kubecek [const_ilog2(WAKE_PHY)] = "phy",
40151ea22b0SMichal Kubecek [const_ilog2(WAKE_UCAST)] = "ucast",
40251ea22b0SMichal Kubecek [const_ilog2(WAKE_MCAST)] = "mcast",
40351ea22b0SMichal Kubecek [const_ilog2(WAKE_BCAST)] = "bcast",
40451ea22b0SMichal Kubecek [const_ilog2(WAKE_ARP)] = "arp",
40551ea22b0SMichal Kubecek [const_ilog2(WAKE_MAGIC)] = "magic",
40651ea22b0SMichal Kubecek [const_ilog2(WAKE_MAGICSECURE)] = "magicsecure",
40751ea22b0SMichal Kubecek [const_ilog2(WAKE_FILTER)] = "filter",
40851ea22b0SMichal Kubecek };
40951ea22b0SMichal Kubecek static_assert(ARRAY_SIZE(wol_mode_names) == WOL_MODE_COUNT);
41051ea22b0SMichal Kubecek
411f76510b4SMichal Kubecek const char sof_timestamping_names[][ETH_GSTRING_LEN] = {
412f76510b4SMichal Kubecek [const_ilog2(SOF_TIMESTAMPING_TX_HARDWARE)] = "hardware-transmit",
413f76510b4SMichal Kubecek [const_ilog2(SOF_TIMESTAMPING_TX_SOFTWARE)] = "software-transmit",
414f76510b4SMichal Kubecek [const_ilog2(SOF_TIMESTAMPING_RX_HARDWARE)] = "hardware-receive",
415f76510b4SMichal Kubecek [const_ilog2(SOF_TIMESTAMPING_RX_SOFTWARE)] = "software-receive",
416f76510b4SMichal Kubecek [const_ilog2(SOF_TIMESTAMPING_SOFTWARE)] = "software-system-clock",
417f76510b4SMichal Kubecek [const_ilog2(SOF_TIMESTAMPING_SYS_HARDWARE)] = "hardware-legacy-clock",
418f76510b4SMichal Kubecek [const_ilog2(SOF_TIMESTAMPING_RAW_HARDWARE)] = "hardware-raw-clock",
419f76510b4SMichal Kubecek [const_ilog2(SOF_TIMESTAMPING_OPT_ID)] = "option-id",
420f76510b4SMichal Kubecek [const_ilog2(SOF_TIMESTAMPING_TX_SCHED)] = "sched-transmit",
421f76510b4SMichal Kubecek [const_ilog2(SOF_TIMESTAMPING_TX_ACK)] = "ack-transmit",
422f76510b4SMichal Kubecek [const_ilog2(SOF_TIMESTAMPING_OPT_CMSG)] = "option-cmsg",
423f76510b4SMichal Kubecek [const_ilog2(SOF_TIMESTAMPING_OPT_TSONLY)] = "option-tsonly",
424f76510b4SMichal Kubecek [const_ilog2(SOF_TIMESTAMPING_OPT_STATS)] = "option-stats",
425f76510b4SMichal Kubecek [const_ilog2(SOF_TIMESTAMPING_OPT_PKTINFO)] = "option-pktinfo",
426f76510b4SMichal Kubecek [const_ilog2(SOF_TIMESTAMPING_OPT_TX_SWHW)] = "option-tx-swhw",
427d463126eSYangbo Lu [const_ilog2(SOF_TIMESTAMPING_BIND_PHC)] = "bind-phc",
428b534dc46SWillem de Bruijn [const_ilog2(SOF_TIMESTAMPING_OPT_ID_TCP)] = "option-id-tcp",
429f76510b4SMichal Kubecek };
430f76510b4SMichal Kubecek static_assert(ARRAY_SIZE(sof_timestamping_names) == __SOF_TIMESTAMPING_CNT);
431f76510b4SMichal Kubecek
432f76510b4SMichal Kubecek const char ts_tx_type_names[][ETH_GSTRING_LEN] = {
433f76510b4SMichal Kubecek [HWTSTAMP_TX_OFF] = "off",
434f76510b4SMichal Kubecek [HWTSTAMP_TX_ON] = "on",
435f76510b4SMichal Kubecek [HWTSTAMP_TX_ONESTEP_SYNC] = "onestep-sync",
436f76510b4SMichal Kubecek [HWTSTAMP_TX_ONESTEP_P2P] = "onestep-p2p",
437f76510b4SMichal Kubecek };
438f76510b4SMichal Kubecek static_assert(ARRAY_SIZE(ts_tx_type_names) == __HWTSTAMP_TX_CNT);
439f76510b4SMichal Kubecek
440f76510b4SMichal Kubecek const char ts_rx_filter_names[][ETH_GSTRING_LEN] = {
441f76510b4SMichal Kubecek [HWTSTAMP_FILTER_NONE] = "none",
442f76510b4SMichal Kubecek [HWTSTAMP_FILTER_ALL] = "all",
443f76510b4SMichal Kubecek [HWTSTAMP_FILTER_SOME] = "some",
444f76510b4SMichal Kubecek [HWTSTAMP_FILTER_PTP_V1_L4_EVENT] = "ptpv1-l4-event",
445f76510b4SMichal Kubecek [HWTSTAMP_FILTER_PTP_V1_L4_SYNC] = "ptpv1-l4-sync",
446f76510b4SMichal Kubecek [HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ] = "ptpv1-l4-delay-req",
447f76510b4SMichal Kubecek [HWTSTAMP_FILTER_PTP_V2_L4_EVENT] = "ptpv2-l4-event",
448f76510b4SMichal Kubecek [HWTSTAMP_FILTER_PTP_V2_L4_SYNC] = "ptpv2-l4-sync",
449f76510b4SMichal Kubecek [HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ] = "ptpv2-l4-delay-req",
450f76510b4SMichal Kubecek [HWTSTAMP_FILTER_PTP_V2_L2_EVENT] = "ptpv2-l2-event",
451f76510b4SMichal Kubecek [HWTSTAMP_FILTER_PTP_V2_L2_SYNC] = "ptpv2-l2-sync",
452f76510b4SMichal Kubecek [HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ] = "ptpv2-l2-delay-req",
453f76510b4SMichal Kubecek [HWTSTAMP_FILTER_PTP_V2_EVENT] = "ptpv2-event",
454f76510b4SMichal Kubecek [HWTSTAMP_FILTER_PTP_V2_SYNC] = "ptpv2-sync",
455f76510b4SMichal Kubecek [HWTSTAMP_FILTER_PTP_V2_DELAY_REQ] = "ptpv2-delay-req",
456f76510b4SMichal Kubecek [HWTSTAMP_FILTER_NTP_ALL] = "ntp-all",
457f76510b4SMichal Kubecek };
458f76510b4SMichal Kubecek static_assert(ARRAY_SIZE(ts_rx_filter_names) == __HWTSTAMP_FILTER_CNT);
459f76510b4SMichal Kubecek
460c7d759ebSJakub Kicinski const char udp_tunnel_type_names[][ETH_GSTRING_LEN] = {
461c7d759ebSJakub Kicinski [ETHTOOL_UDP_TUNNEL_TYPE_VXLAN] = "vxlan",
462c7d759ebSJakub Kicinski [ETHTOOL_UDP_TUNNEL_TYPE_GENEVE] = "geneve",
463c7d759ebSJakub Kicinski [ETHTOOL_UDP_TUNNEL_TYPE_VXLAN_GPE] = "vxlan-gpe",
464c7d759ebSJakub Kicinski };
465c7d759ebSJakub Kicinski static_assert(ARRAY_SIZE(udp_tunnel_type_names) ==
466c7d759ebSJakub Kicinski __ETHTOOL_UDP_TUNNEL_TYPE_CNT);
467c7d759ebSJakub Kicinski
468459e0b81SMichal Kubecek /* return false if legacy contained non-0 deprecated fields
469459e0b81SMichal Kubecek * maxtxpkt/maxrxpkt. rest of ksettings always updated
470459e0b81SMichal Kubecek */
471459e0b81SMichal Kubecek bool
convert_legacy_settings_to_link_ksettings(struct ethtool_link_ksettings * link_ksettings,const struct ethtool_cmd * legacy_settings)472459e0b81SMichal Kubecek convert_legacy_settings_to_link_ksettings(
473459e0b81SMichal Kubecek struct ethtool_link_ksettings *link_ksettings,
474459e0b81SMichal Kubecek const struct ethtool_cmd *legacy_settings)
475459e0b81SMichal Kubecek {
476459e0b81SMichal Kubecek bool retval = true;
477459e0b81SMichal Kubecek
478459e0b81SMichal Kubecek memset(link_ksettings, 0, sizeof(*link_ksettings));
479459e0b81SMichal Kubecek
480459e0b81SMichal Kubecek /* This is used to tell users that driver is still using these
481459e0b81SMichal Kubecek * deprecated legacy fields, and they should not use
482459e0b81SMichal Kubecek * %ETHTOOL_GLINKSETTINGS/%ETHTOOL_SLINKSETTINGS
483459e0b81SMichal Kubecek */
484459e0b81SMichal Kubecek if (legacy_settings->maxtxpkt ||
485459e0b81SMichal Kubecek legacy_settings->maxrxpkt)
486459e0b81SMichal Kubecek retval = false;
487459e0b81SMichal Kubecek
488459e0b81SMichal Kubecek ethtool_convert_legacy_u32_to_link_mode(
489459e0b81SMichal Kubecek link_ksettings->link_modes.supported,
490459e0b81SMichal Kubecek legacy_settings->supported);
491459e0b81SMichal Kubecek ethtool_convert_legacy_u32_to_link_mode(
492459e0b81SMichal Kubecek link_ksettings->link_modes.advertising,
493459e0b81SMichal Kubecek legacy_settings->advertising);
494459e0b81SMichal Kubecek ethtool_convert_legacy_u32_to_link_mode(
495459e0b81SMichal Kubecek link_ksettings->link_modes.lp_advertising,
496459e0b81SMichal Kubecek legacy_settings->lp_advertising);
497459e0b81SMichal Kubecek link_ksettings->base.speed
498459e0b81SMichal Kubecek = ethtool_cmd_speed(legacy_settings);
499459e0b81SMichal Kubecek link_ksettings->base.duplex
500459e0b81SMichal Kubecek = legacy_settings->duplex;
501459e0b81SMichal Kubecek link_ksettings->base.port
502459e0b81SMichal Kubecek = legacy_settings->port;
503459e0b81SMichal Kubecek link_ksettings->base.phy_address
504459e0b81SMichal Kubecek = legacy_settings->phy_address;
505459e0b81SMichal Kubecek link_ksettings->base.autoneg
506459e0b81SMichal Kubecek = legacy_settings->autoneg;
507459e0b81SMichal Kubecek link_ksettings->base.mdio_support
508459e0b81SMichal Kubecek = legacy_settings->mdio_support;
509459e0b81SMichal Kubecek link_ksettings->base.eth_tp_mdix
510459e0b81SMichal Kubecek = legacy_settings->eth_tp_mdix;
511459e0b81SMichal Kubecek link_ksettings->base.eth_tp_mdix_ctrl
512459e0b81SMichal Kubecek = legacy_settings->eth_tp_mdix_ctrl;
513459e0b81SMichal Kubecek return retval;
514459e0b81SMichal Kubecek }
5153d2b847fSMichal Kubecek
__ethtool_get_link(struct net_device * dev)5163d2b847fSMichal Kubecek int __ethtool_get_link(struct net_device *dev)
5173d2b847fSMichal Kubecek {
5183d2b847fSMichal Kubecek if (!dev->ethtool_ops->get_link)
5193d2b847fSMichal Kubecek return -EOPNOTSUPP;
5203d2b847fSMichal Kubecek
5213d2b847fSMichal Kubecek return netif_running(dev) && dev->ethtool_ops->get_link(dev);
5223d2b847fSMichal Kubecek }
523e19c591eSMichal Kubecek
ethtool_get_rxnfc_rule_count(struct net_device * dev)52447f3ecf4SGal Pressman static int ethtool_get_rxnfc_rule_count(struct net_device *dev)
52547f3ecf4SGal Pressman {
52647f3ecf4SGal Pressman const struct ethtool_ops *ops = dev->ethtool_ops;
52747f3ecf4SGal Pressman struct ethtool_rxnfc info = {
52847f3ecf4SGal Pressman .cmd = ETHTOOL_GRXCLSRLCNT,
52947f3ecf4SGal Pressman };
53047f3ecf4SGal Pressman int err;
53147f3ecf4SGal Pressman
53247f3ecf4SGal Pressman err = ops->get_rxnfc(dev, &info, NULL);
53347f3ecf4SGal Pressman if (err)
53447f3ecf4SGal Pressman return err;
53547f3ecf4SGal Pressman
53647f3ecf4SGal Pressman return info.rule_cnt;
53747f3ecf4SGal Pressman }
53847f3ecf4SGal Pressman
ethtool_get_max_rxnfc_channel(struct net_device * dev,u64 * max)53947f3ecf4SGal Pressman int ethtool_get_max_rxnfc_channel(struct net_device *dev, u64 *max)
54047f3ecf4SGal Pressman {
54147f3ecf4SGal Pressman const struct ethtool_ops *ops = dev->ethtool_ops;
54247f3ecf4SGal Pressman struct ethtool_rxnfc *info;
54347f3ecf4SGal Pressman int err, i, rule_cnt;
54447f3ecf4SGal Pressman u64 max_ring = 0;
54547f3ecf4SGal Pressman
54647f3ecf4SGal Pressman if (!ops->get_rxnfc)
54747f3ecf4SGal Pressman return -EOPNOTSUPP;
54847f3ecf4SGal Pressman
54947f3ecf4SGal Pressman rule_cnt = ethtool_get_rxnfc_rule_count(dev);
55047f3ecf4SGal Pressman if (rule_cnt <= 0)
55147f3ecf4SGal Pressman return -EINVAL;
55247f3ecf4SGal Pressman
55347f3ecf4SGal Pressman info = kvzalloc(struct_size(info, rule_locs, rule_cnt), GFP_KERNEL);
55447f3ecf4SGal Pressman if (!info)
55547f3ecf4SGal Pressman return -ENOMEM;
55647f3ecf4SGal Pressman
55747f3ecf4SGal Pressman info->cmd = ETHTOOL_GRXCLSRLALL;
55847f3ecf4SGal Pressman info->rule_cnt = rule_cnt;
55947f3ecf4SGal Pressman err = ops->get_rxnfc(dev, info, info->rule_locs);
56047f3ecf4SGal Pressman if (err)
56147f3ecf4SGal Pressman goto err_free_info;
56247f3ecf4SGal Pressman
56347f3ecf4SGal Pressman for (i = 0; i < rule_cnt; i++) {
56447f3ecf4SGal Pressman struct ethtool_rxnfc rule_info = {
56547f3ecf4SGal Pressman .cmd = ETHTOOL_GRXCLSRULE,
56647f3ecf4SGal Pressman .fs.location = info->rule_locs[i],
56747f3ecf4SGal Pressman };
56847f3ecf4SGal Pressman
56947f3ecf4SGal Pressman err = ops->get_rxnfc(dev, &rule_info, NULL);
57047f3ecf4SGal Pressman if (err)
57147f3ecf4SGal Pressman goto err_free_info;
57247f3ecf4SGal Pressman
57347f3ecf4SGal Pressman if (rule_info.fs.ring_cookie != RX_CLS_FLOW_DISC &&
57447f3ecf4SGal Pressman rule_info.fs.ring_cookie != RX_CLS_FLOW_WAKE &&
57547f3ecf4SGal Pressman !(rule_info.flow_type & FLOW_RSS) &&
57647f3ecf4SGal Pressman !ethtool_get_flow_spec_ring_vf(rule_info.fs.ring_cookie))
57747f3ecf4SGal Pressman max_ring =
57847f3ecf4SGal Pressman max_t(u64, max_ring, rule_info.fs.ring_cookie);
57947f3ecf4SGal Pressman }
58047f3ecf4SGal Pressman
58147f3ecf4SGal Pressman kvfree(info);
58247f3ecf4SGal Pressman *max = max_ring;
58347f3ecf4SGal Pressman return 0;
58447f3ecf4SGal Pressman
58547f3ecf4SGal Pressman err_free_info:
58647f3ecf4SGal Pressman kvfree(info);
58747f3ecf4SGal Pressman return err;
58847f3ecf4SGal Pressman }
58947f3ecf4SGal Pressman
ethtool_get_max_rxfh_channel(struct net_device * dev,u32 * max)590e19c591eSMichal Kubecek int ethtool_get_max_rxfh_channel(struct net_device *dev, u32 *max)
591e19c591eSMichal Kubecek {
592e19c591eSMichal Kubecek u32 dev_size, current_max = 0;
593e19c591eSMichal Kubecek u32 *indir;
594e19c591eSMichal Kubecek int ret;
595e19c591eSMichal Kubecek
596e19c591eSMichal Kubecek if (!dev->ethtool_ops->get_rxfh_indir_size ||
597e19c591eSMichal Kubecek !dev->ethtool_ops->get_rxfh)
598e19c591eSMichal Kubecek return -EOPNOTSUPP;
599e19c591eSMichal Kubecek dev_size = dev->ethtool_ops->get_rxfh_indir_size(dev);
600e19c591eSMichal Kubecek if (dev_size == 0)
601e19c591eSMichal Kubecek return -EOPNOTSUPP;
602e19c591eSMichal Kubecek
603e19c591eSMichal Kubecek indir = kcalloc(dev_size, sizeof(indir[0]), GFP_USER);
604e19c591eSMichal Kubecek if (!indir)
605e19c591eSMichal Kubecek return -ENOMEM;
606e19c591eSMichal Kubecek
607e19c591eSMichal Kubecek ret = dev->ethtool_ops->get_rxfh(dev, indir, NULL, NULL);
608e19c591eSMichal Kubecek if (ret)
609e19c591eSMichal Kubecek goto out;
610e19c591eSMichal Kubecek
611e19c591eSMichal Kubecek while (dev_size--)
612e19c591eSMichal Kubecek current_max = max(current_max, indir[dev_size]);
613e19c591eSMichal Kubecek
614e19c591eSMichal Kubecek *max = current_max;
615e19c591eSMichal Kubecek
616e19c591eSMichal Kubecek out:
617e19c591eSMichal Kubecek kfree(indir);
618e19c591eSMichal Kubecek return ret;
619e19c591eSMichal Kubecek }
6209000edb7SJakub Kicinski
ethtool_check_ops(const struct ethtool_ops * ops)6219000edb7SJakub Kicinski int ethtool_check_ops(const struct ethtool_ops *ops)
6229000edb7SJakub Kicinski {
6239000edb7SJakub Kicinski if (WARN_ON(ops->set_coalesce && !ops->supported_coalesce_params))
6249000edb7SJakub Kicinski return -EINVAL;
6259000edb7SJakub Kicinski /* NOTE: sufficiently insane drivers may swap ethtool_ops at runtime,
6269000edb7SJakub Kicinski * the fact that ops are checked at registration time does not
6279000edb7SJakub Kicinski * mean the ops attached to a netdev later on are sane.
6289000edb7SJakub Kicinski */
6299000edb7SJakub Kicinski return 0;
6309000edb7SJakub Kicinski }
6315b071c59SMichal Kubecek
__ethtool_get_ts_info(struct net_device * dev,struct ethtool_ts_info * info)6325b071c59SMichal Kubecek int __ethtool_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info)
6335b071c59SMichal Kubecek {
6345b071c59SMichal Kubecek const struct ethtool_ops *ops = dev->ethtool_ops;
6355b071c59SMichal Kubecek struct phy_device *phydev = dev->phydev;
6365b071c59SMichal Kubecek
6375b071c59SMichal Kubecek memset(info, 0, sizeof(*info));
6385b071c59SMichal Kubecek info->cmd = ETHTOOL_GET_TS_INFO;
6395b071c59SMichal Kubecek
6405b071c59SMichal Kubecek if (phy_has_tsinfo(phydev))
6415b071c59SMichal Kubecek return phy_ts_info(phydev, info);
6425b071c59SMichal Kubecek if (ops->get_ts_info)
6435b071c59SMichal Kubecek return ops->get_ts_info(dev, info);
6445b071c59SMichal Kubecek
6455b071c59SMichal Kubecek info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE |
6465b071c59SMichal Kubecek SOF_TIMESTAMPING_SOFTWARE;
6475b071c59SMichal Kubecek info->phc_index = -1;
6485b071c59SMichal Kubecek
6495b071c59SMichal Kubecek return 0;
6505b071c59SMichal Kubecek }
6514895d780SFlorian Fainelli
ethtool_get_phc_vclocks(struct net_device * dev,int ** vclock_index)652c156174aSYangbo Lu int ethtool_get_phc_vclocks(struct net_device *dev, int **vclock_index)
653c156174aSYangbo Lu {
654c156174aSYangbo Lu struct ethtool_ts_info info = { };
655c156174aSYangbo Lu int num = 0;
656c156174aSYangbo Lu
657c156174aSYangbo Lu if (!__ethtool_get_ts_info(dev, &info))
658c156174aSYangbo Lu num = ptp_get_vclocks_index(info.phc_index, vclock_index);
659c156174aSYangbo Lu
660c156174aSYangbo Lu return num;
661c156174aSYangbo Lu }
662c156174aSYangbo Lu EXPORT_SYMBOL(ethtool_get_phc_vclocks);
663c156174aSYangbo Lu
6644895d780SFlorian Fainelli const struct ethtool_phy_ops *ethtool_phy_ops;
6654895d780SFlorian Fainelli
ethtool_set_ethtool_phy_ops(const struct ethtool_phy_ops * ops)6664895d780SFlorian Fainelli void ethtool_set_ethtool_phy_ops(const struct ethtool_phy_ops *ops)
6674895d780SFlorian Fainelli {
668*70ef7d87SVladimir Oltean ASSERT_RTNL();
6694895d780SFlorian Fainelli ethtool_phy_ops = ops;
6704895d780SFlorian Fainelli }
6714895d780SFlorian Fainelli EXPORT_SYMBOL_GPL(ethtool_set_ethtool_phy_ops);
672a975d7d8SDanielle Ratson
673a975d7d8SDanielle Ratson void
ethtool_params_from_link_mode(struct ethtool_link_ksettings * link_ksettings,enum ethtool_link_mode_bit_indices link_mode)674a975d7d8SDanielle Ratson ethtool_params_from_link_mode(struct ethtool_link_ksettings *link_ksettings,
675a975d7d8SDanielle Ratson enum ethtool_link_mode_bit_indices link_mode)
676a975d7d8SDanielle Ratson {
677a975d7d8SDanielle Ratson const struct link_mode_info *link_info;
678a975d7d8SDanielle Ratson
679a975d7d8SDanielle Ratson if (WARN_ON_ONCE(link_mode >= __ETHTOOL_LINK_MODE_MASK_NBITS))
680a975d7d8SDanielle Ratson return;
681a975d7d8SDanielle Ratson
682a975d7d8SDanielle Ratson link_info = &link_mode_params[link_mode];
683a975d7d8SDanielle Ratson link_ksettings->base.speed = link_info->speed;
684a975d7d8SDanielle Ratson link_ksettings->lanes = link_info->lanes;
685a975d7d8SDanielle Ratson link_ksettings->base.duplex = link_info->duplex;
686a975d7d8SDanielle Ratson }
687a975d7d8SDanielle Ratson EXPORT_SYMBOL_GPL(ethtool_params_from_link_mode);
688