Skip to content

Commit d44e131

Browse files
mkubecekdavem330
authored andcommitted
ethtool: move string arrays into common file
Introduce file net/ethtool/common.c for code shared by ioctl and netlink ethtool interface. Move name tables of features, RSS hash functions, tunables and PHY tunables into this file. Signed-off-by: Michal Kubecek <mkubecek@suse.cz> Reviewed-by: Jiri Pirko <jiri@mellanox.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 9ce48e5 commit d44e131

4 files changed

Lines changed: 105 additions & 83 deletions

File tree

‎net/ethtool/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# SPDX-License-Identifier: GPL-2.0-only
22

3-
obj-y += ioctl.o
3+
obj-y += ioctl.o common.o

‎net/ethtool/common.c‎

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
3+
#include "common.h"
4+
5+
const char netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN] = {
6+
[NETIF_F_SG_BIT] = "tx-scatter-gather",
7+
[NETIF_F_IP_CSUM_BIT] = "tx-checksum-ipv4",
8+
[NETIF_F_HW_CSUM_BIT] = "tx-checksum-ip-generic",
9+
[NETIF_F_IPV6_CSUM_BIT] = "tx-checksum-ipv6",
10+
[NETIF_F_HIGHDMA_BIT] = "highdma",
11+
[NETIF_F_FRAGLIST_BIT] = "tx-scatter-gather-fraglist",
12+
[NETIF_F_HW_VLAN_CTAG_TX_BIT] = "tx-vlan-hw-insert",
13+
14+
[NETIF_F_HW_VLAN_CTAG_RX_BIT] = "rx-vlan-hw-parse",
15+
[NETIF_F_HW_VLAN_CTAG_FILTER_BIT] = "rx-vlan-filter",
16+
[NETIF_F_HW_VLAN_STAG_TX_BIT] = "tx-vlan-stag-hw-insert",
17+
[NETIF_F_HW_VLAN_STAG_RX_BIT] = "rx-vlan-stag-hw-parse",
18+
[NETIF_F_HW_VLAN_STAG_FILTER_BIT] = "rx-vlan-stag-filter",
19+
[NETIF_F_VLAN_CHALLENGED_BIT] = "vlan-challenged",
20+
[NETIF_F_GSO_BIT] = "tx-generic-segmentation",
21+
[NETIF_F_LLTX_BIT] = "tx-lockless",
22+
[NETIF_F_NETNS_LOCAL_BIT] = "netns-local",
23+
[NETIF_F_GRO_BIT] = "rx-gro",
24+
[NETIF_F_GRO_HW_BIT] = "rx-gro-hw",
25+
[NETIF_F_LRO_BIT] = "rx-lro",
26+
27+
[NETIF_F_TSO_BIT] = "tx-tcp-segmentation",
28+
[NETIF_F_GSO_ROBUST_BIT] = "tx-gso-robust",
29+
[NETIF_F_TSO_ECN_BIT] = "tx-tcp-ecn-segmentation",
30+
[NETIF_F_TSO_MANGLEID_BIT] = "tx-tcp-mangleid-segmentation",
31+
[NETIF_F_TSO6_BIT] = "tx-tcp6-segmentation",
32+
[NETIF_F_FSO_BIT] = "tx-fcoe-segmentation",
33+
[NETIF_F_GSO_GRE_BIT] = "tx-gre-segmentation",
34+
[NETIF_F_GSO_GRE_CSUM_BIT] = "tx-gre-csum-segmentation",
35+
[NETIF_F_GSO_IPXIP4_BIT] = "tx-ipxip4-segmentation",
36+
[NETIF_F_GSO_IPXIP6_BIT] = "tx-ipxip6-segmentation",
37+
[NETIF_F_GSO_UDP_TUNNEL_BIT] = "tx-udp_tnl-segmentation",
38+
[NETIF_F_GSO_UDP_TUNNEL_CSUM_BIT] = "tx-udp_tnl-csum-segmentation",
39+
[NETIF_F_GSO_PARTIAL_BIT] = "tx-gso-partial",
40+
[NETIF_F_GSO_SCTP_BIT] = "tx-sctp-segmentation",
41+
[NETIF_F_GSO_ESP_BIT] = "tx-esp-segmentation",
42+
[NETIF_F_GSO_UDP_L4_BIT] = "tx-udp-segmentation",
43+
44+
[NETIF_F_FCOE_CRC_BIT] = "tx-checksum-fcoe-crc",
45+
[NETIF_F_SCTP_CRC_BIT] = "tx-checksum-sctp",
46+
[NETIF_F_FCOE_MTU_BIT] = "fcoe-mtu",
47+
[NETIF_F_NTUPLE_BIT] = "rx-ntuple-filter",
48+
[NETIF_F_RXHASH_BIT] = "rx-hashing",
49+
[NETIF_F_RXCSUM_BIT] = "rx-checksum",
50+
[NETIF_F_NOCACHE_COPY_BIT] = "tx-nocache-copy",
51+
[NETIF_F_LOOPBACK_BIT] = "loopback",
52+
[NETIF_F_RXFCS_BIT] = "rx-fcs",
53+
[NETIF_F_RXALL_BIT] = "rx-all",
54+
[NETIF_F_HW_L2FW_DOFFLOAD_BIT] = "l2-fwd-offload",
55+
[NETIF_F_HW_TC_BIT] = "hw-tc-offload",
56+
[NETIF_F_HW_ESP_BIT] = "esp-hw-offload",
57+
[NETIF_F_HW_ESP_TX_CSUM_BIT] = "esp-tx-csum-hw-offload",
58+
[NETIF_F_RX_UDP_TUNNEL_PORT_BIT] = "rx-udp_tunnel-port-offload",
59+
[NETIF_F_HW_TLS_RECORD_BIT] = "tls-hw-record",
60+
[NETIF_F_HW_TLS_TX_BIT] = "tls-hw-tx-offload",
61+
[NETIF_F_HW_TLS_RX_BIT] = "tls-hw-rx-offload",
62+
};
63+
64+
const char
65+
rss_hash_func_strings[ETH_RSS_HASH_FUNCS_COUNT][ETH_GSTRING_LEN] = {
66+
[ETH_RSS_HASH_TOP_BIT] = "toeplitz",
67+
[ETH_RSS_HASH_XOR_BIT] = "xor",
68+
[ETH_RSS_HASH_CRC32_BIT] = "crc32",
69+
};
70+
71+
const char
72+
tunable_strings[__ETHTOOL_TUNABLE_COUNT][ETH_GSTRING_LEN] = {
73+
[ETHTOOL_ID_UNSPEC] = "Unspec",
74+
[ETHTOOL_RX_COPYBREAK] = "rx-copybreak",
75+
[ETHTOOL_TX_COPYBREAK] = "tx-copybreak",
76+
[ETHTOOL_PFC_PREVENTION_TOUT] = "pfc-prevention-tout",
77+
};
78+
79+
const char
80+
phy_tunable_strings[__ETHTOOL_PHY_TUNABLE_COUNT][ETH_GSTRING_LEN] = {
81+
[ETHTOOL_ID_UNSPEC] = "Unspec",
82+
[ETHTOOL_PHY_DOWNSHIFT] = "phy-downshift",
83+
[ETHTOOL_PHY_FAST_LINK_DOWN] = "phy-fast-link-down",
84+
[ETHTOOL_PHY_EDPD] = "phy-energy-detect-power-down",
85+
};

‎net/ethtool/common.h‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
3+
#ifndef _ETHTOOL_COMMON_H
4+
#define _ETHTOOL_COMMON_H
5+
6+
#include <linux/ethtool.h>
7+
8+
extern const char
9+
netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN];
10+
extern const char
11+
rss_hash_func_strings[ETH_RSS_HASH_FUNCS_COUNT][ETH_GSTRING_LEN];
12+
extern const char
13+
tunable_strings[__ETHTOOL_TUNABLE_COUNT][ETH_GSTRING_LEN];
14+
extern const char
15+
phy_tunable_strings[__ETHTOOL_PHY_TUNABLE_COUNT][ETH_GSTRING_LEN];
16+
17+
#endif /* _ETHTOOL_COMMON_H */

‎net/ethtool/ioctl.c‎

Lines changed: 2 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include <net/xdp_sock.h>
2828
#include <net/flow_offload.h>
2929

30+
#include "common.h"
31+
3032
/*
3133
* Some useful ethtool_ops methods that're device independent.
3234
* If we find that all drivers want to do the same thing here,
@@ -54,88 +56,6 @@ EXPORT_SYMBOL(ethtool_op_get_ts_info);
5456

5557
#define ETHTOOL_DEV_FEATURE_WORDS ((NETDEV_FEATURE_COUNT + 31) / 32)
5658

57-
static const char netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN] = {
58-
[NETIF_F_SG_BIT] = "tx-scatter-gather",
59-
[NETIF_F_IP_CSUM_BIT] = "tx-checksum-ipv4",
60-
[NETIF_F_HW_CSUM_BIT] = "tx-checksum-ip-generic",
61-
[NETIF_F_IPV6_CSUM_BIT] = "tx-checksum-ipv6",
62-
[NETIF_F_HIGHDMA_BIT] = "highdma",
63-
[NETIF_F_FRAGLIST_BIT] = "tx-scatter-gather-fraglist",
64-
[NETIF_F_HW_VLAN_CTAG_TX_BIT] = "tx-vlan-hw-insert",
65-
66-
[NETIF_F_HW_VLAN_CTAG_RX_BIT] = "rx-vlan-hw-parse",
67-
[NETIF_F_HW_VLAN_CTAG_FILTER_BIT] = "rx-vlan-filter",
68-
[NETIF_F_HW_VLAN_STAG_TX_BIT] = "tx-vlan-stag-hw-insert",
69-
[NETIF_F_HW_VLAN_STAG_RX_BIT] = "rx-vlan-stag-hw-parse",
70-
[NETIF_F_HW_VLAN_STAG_FILTER_BIT] = "rx-vlan-stag-filter",
71-
[NETIF_F_VLAN_CHALLENGED_BIT] = "vlan-challenged",
72-
[NETIF_F_GSO_BIT] = "tx-generic-segmentation",
73-
[NETIF_F_LLTX_BIT] = "tx-lockless",
74-
[NETIF_F_NETNS_LOCAL_BIT] = "netns-local",
75-
[NETIF_F_GRO_BIT] = "rx-gro",
76-
[NETIF_F_GRO_HW_BIT] = "rx-gro-hw",
77-
[NETIF_F_LRO_BIT] = "rx-lro",
78-
79-
[NETIF_F_TSO_BIT] = "tx-tcp-segmentation",
80-
[NETIF_F_GSO_ROBUST_BIT] = "tx-gso-robust",
81-
[NETIF_F_TSO_ECN_BIT] = "tx-tcp-ecn-segmentation",
82-
[NETIF_F_TSO_MANGLEID_BIT] = "tx-tcp-mangleid-segmentation",
83-
[NETIF_F_TSO6_BIT] = "tx-tcp6-segmentation",
84-
[NETIF_F_FSO_BIT] = "tx-fcoe-segmentation",
85-
[NETIF_F_GSO_GRE_BIT] = "tx-gre-segmentation",
86-
[NETIF_F_GSO_GRE_CSUM_BIT] = "tx-gre-csum-segmentation",
87-
[NETIF_F_GSO_IPXIP4_BIT] = "tx-ipxip4-segmentation",
88-
[NETIF_F_GSO_IPXIP6_BIT] = "tx-ipxip6-segmentation",
89-
[NETIF_F_GSO_UDP_TUNNEL_BIT] = "tx-udp_tnl-segmentation",
90-
[NETIF_F_GSO_UDP_TUNNEL_CSUM_BIT] = "tx-udp_tnl-csum-segmentation",
91-
[NETIF_F_GSO_PARTIAL_BIT] = "tx-gso-partial",
92-
[NETIF_F_GSO_SCTP_BIT] = "tx-sctp-segmentation",
93-
[NETIF_F_GSO_ESP_BIT] = "tx-esp-segmentation",
94-
[NETIF_F_GSO_UDP_L4_BIT] = "tx-udp-segmentation",
95-
96-
[NETIF_F_FCOE_CRC_BIT] = "tx-checksum-fcoe-crc",
97-
[NETIF_F_SCTP_CRC_BIT] = "tx-checksum-sctp",
98-
[NETIF_F_FCOE_MTU_BIT] = "fcoe-mtu",
99-
[NETIF_F_NTUPLE_BIT] = "rx-ntuple-filter",
100-
[NETIF_F_RXHASH_BIT] = "rx-hashing",
101-
[NETIF_F_RXCSUM_BIT] = "rx-checksum",
102-
[NETIF_F_NOCACHE_COPY_BIT] = "tx-nocache-copy",
103-
[NETIF_F_LOOPBACK_BIT] = "loopback",
104-
[NETIF_F_RXFCS_BIT] = "rx-fcs",
105-
[NETIF_F_RXALL_BIT] = "rx-all",
106-
[NETIF_F_HW_L2FW_DOFFLOAD_BIT] = "l2-fwd-offload",
107-
[NETIF_F_HW_TC_BIT] = "hw-tc-offload",
108-
[NETIF_F_HW_ESP_BIT] = "esp-hw-offload",
109-
[NETIF_F_HW_ESP_TX_CSUM_BIT] = "esp-tx-csum-hw-offload",
110-
[NETIF_F_RX_UDP_TUNNEL_PORT_BIT] = "rx-udp_tunnel-port-offload",
111-
[NETIF_F_HW_TLS_RECORD_BIT] = "tls-hw-record",
112-
[NETIF_F_HW_TLS_TX_BIT] = "tls-hw-tx-offload",
113-
[NETIF_F_HW_TLS_RX_BIT] = "tls-hw-rx-offload",
114-
};
115-
116-
static const char
117-
rss_hash_func_strings[ETH_RSS_HASH_FUNCS_COUNT][ETH_GSTRING_LEN] = {
118-
[ETH_RSS_HASH_TOP_BIT] = "toeplitz",
119-
[ETH_RSS_HASH_XOR_BIT] = "xor",
120-
[ETH_RSS_HASH_CRC32_BIT] = "crc32",
121-
};
122-
123-
static const char
124-
tunable_strings[__ETHTOOL_TUNABLE_COUNT][ETH_GSTRING_LEN] = {
125-
[ETHTOOL_ID_UNSPEC] = "Unspec",
126-
[ETHTOOL_RX_COPYBREAK] = "rx-copybreak",
127-
[ETHTOOL_TX_COPYBREAK] = "tx-copybreak",
128-
[ETHTOOL_PFC_PREVENTION_TOUT] = "pfc-prevention-tout",
129-
};
130-
131-
static const char
132-
phy_tunable_strings[__ETHTOOL_PHY_TUNABLE_COUNT][ETH_GSTRING_LEN] = {
133-
[ETHTOOL_ID_UNSPEC] = "Unspec",
134-
[ETHTOOL_PHY_DOWNSHIFT] = "phy-downshift",
135-
[ETHTOOL_PHY_FAST_LINK_DOWN] = "phy-fast-link-down",
136-
[ETHTOOL_PHY_EDPD] = "phy-energy-detect-power-down",
137-
};
138-
13959
static int ethtool_get_features(struct net_device *dev, void __user *useraddr)
14060
{
14161
struct ethtool_gfeatures cmd = {

0 commit comments

Comments
 (0)