18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ci#include <linux/ethtool_netlink.h> 48c2ecf20Sopenharmony_ci#include <linux/net_tstamp.h> 58c2ecf20Sopenharmony_ci#include <linux/phy.h> 68c2ecf20Sopenharmony_ci#include <linux/rtnetlink.h> 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#include "common.h" 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ciconst char netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN] = { 118c2ecf20Sopenharmony_ci [NETIF_F_SG_BIT] = "tx-scatter-gather", 128c2ecf20Sopenharmony_ci [NETIF_F_IP_CSUM_BIT] = "tx-checksum-ipv4", 138c2ecf20Sopenharmony_ci [NETIF_F_HW_CSUM_BIT] = "tx-checksum-ip-generic", 148c2ecf20Sopenharmony_ci [NETIF_F_IPV6_CSUM_BIT] = "tx-checksum-ipv6", 158c2ecf20Sopenharmony_ci [NETIF_F_HIGHDMA_BIT] = "highdma", 168c2ecf20Sopenharmony_ci [NETIF_F_FRAGLIST_BIT] = "tx-scatter-gather-fraglist", 178c2ecf20Sopenharmony_ci [NETIF_F_HW_VLAN_CTAG_TX_BIT] = "tx-vlan-hw-insert", 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci [NETIF_F_HW_VLAN_CTAG_RX_BIT] = "rx-vlan-hw-parse", 208c2ecf20Sopenharmony_ci [NETIF_F_HW_VLAN_CTAG_FILTER_BIT] = "rx-vlan-filter", 218c2ecf20Sopenharmony_ci [NETIF_F_HW_VLAN_STAG_TX_BIT] = "tx-vlan-stag-hw-insert", 228c2ecf20Sopenharmony_ci [NETIF_F_HW_VLAN_STAG_RX_BIT] = "rx-vlan-stag-hw-parse", 238c2ecf20Sopenharmony_ci [NETIF_F_HW_VLAN_STAG_FILTER_BIT] = "rx-vlan-stag-filter", 248c2ecf20Sopenharmony_ci [NETIF_F_VLAN_CHALLENGED_BIT] = "vlan-challenged", 258c2ecf20Sopenharmony_ci [NETIF_F_GSO_BIT] = "tx-generic-segmentation", 268c2ecf20Sopenharmony_ci [NETIF_F_LLTX_BIT] = "tx-lockless", 278c2ecf20Sopenharmony_ci [NETIF_F_NETNS_LOCAL_BIT] = "netns-local", 288c2ecf20Sopenharmony_ci [NETIF_F_GRO_BIT] = "rx-gro", 298c2ecf20Sopenharmony_ci [NETIF_F_GRO_HW_BIT] = "rx-gro-hw", 308c2ecf20Sopenharmony_ci [NETIF_F_LRO_BIT] = "rx-lro", 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci [NETIF_F_TSO_BIT] = "tx-tcp-segmentation", 338c2ecf20Sopenharmony_ci [NETIF_F_GSO_ROBUST_BIT] = "tx-gso-robust", 348c2ecf20Sopenharmony_ci [NETIF_F_TSO_ECN_BIT] = "tx-tcp-ecn-segmentation", 358c2ecf20Sopenharmony_ci [NETIF_F_TSO_MANGLEID_BIT] = "tx-tcp-mangleid-segmentation", 368c2ecf20Sopenharmony_ci [NETIF_F_TSO6_BIT] = "tx-tcp6-segmentation", 378c2ecf20Sopenharmony_ci [NETIF_F_FSO_BIT] = "tx-fcoe-segmentation", 388c2ecf20Sopenharmony_ci [NETIF_F_GSO_GRE_BIT] = "tx-gre-segmentation", 398c2ecf20Sopenharmony_ci [NETIF_F_GSO_GRE_CSUM_BIT] = "tx-gre-csum-segmentation", 408c2ecf20Sopenharmony_ci [NETIF_F_GSO_IPXIP4_BIT] = "tx-ipxip4-segmentation", 418c2ecf20Sopenharmony_ci [NETIF_F_GSO_IPXIP6_BIT] = "tx-ipxip6-segmentation", 428c2ecf20Sopenharmony_ci [NETIF_F_GSO_UDP_TUNNEL_BIT] = "tx-udp_tnl-segmentation", 438c2ecf20Sopenharmony_ci [NETIF_F_GSO_UDP_TUNNEL_CSUM_BIT] = "tx-udp_tnl-csum-segmentation", 448c2ecf20Sopenharmony_ci [NETIF_F_GSO_PARTIAL_BIT] = "tx-gso-partial", 458c2ecf20Sopenharmony_ci [NETIF_F_GSO_TUNNEL_REMCSUM_BIT] = "tx-tunnel-remcsum-segmentation", 468c2ecf20Sopenharmony_ci [NETIF_F_GSO_SCTP_BIT] = "tx-sctp-segmentation", 478c2ecf20Sopenharmony_ci [NETIF_F_GSO_ESP_BIT] = "tx-esp-segmentation", 488c2ecf20Sopenharmony_ci [NETIF_F_GSO_UDP_L4_BIT] = "tx-udp-segmentation", 498c2ecf20Sopenharmony_ci [NETIF_F_GSO_FRAGLIST_BIT] = "tx-gso-list", 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci [NETIF_F_FCOE_CRC_BIT] = "tx-checksum-fcoe-crc", 528c2ecf20Sopenharmony_ci [NETIF_F_SCTP_CRC_BIT] = "tx-checksum-sctp", 538c2ecf20Sopenharmony_ci [NETIF_F_FCOE_MTU_BIT] = "fcoe-mtu", 548c2ecf20Sopenharmony_ci [NETIF_F_NTUPLE_BIT] = "rx-ntuple-filter", 558c2ecf20Sopenharmony_ci [NETIF_F_RXHASH_BIT] = "rx-hashing", 568c2ecf20Sopenharmony_ci [NETIF_F_RXCSUM_BIT] = "rx-checksum", 578c2ecf20Sopenharmony_ci [NETIF_F_NOCACHE_COPY_BIT] = "tx-nocache-copy", 588c2ecf20Sopenharmony_ci [NETIF_F_LOOPBACK_BIT] = "loopback", 598c2ecf20Sopenharmony_ci [NETIF_F_RXFCS_BIT] = "rx-fcs", 608c2ecf20Sopenharmony_ci [NETIF_F_RXALL_BIT] = "rx-all", 618c2ecf20Sopenharmony_ci [NETIF_F_HW_L2FW_DOFFLOAD_BIT] = "l2-fwd-offload", 628c2ecf20Sopenharmony_ci [NETIF_F_HW_TC_BIT] = "hw-tc-offload", 638c2ecf20Sopenharmony_ci [NETIF_F_HW_ESP_BIT] = "esp-hw-offload", 648c2ecf20Sopenharmony_ci [NETIF_F_HW_ESP_TX_CSUM_BIT] = "esp-tx-csum-hw-offload", 658c2ecf20Sopenharmony_ci [NETIF_F_RX_UDP_TUNNEL_PORT_BIT] = "rx-udp_tunnel-port-offload", 668c2ecf20Sopenharmony_ci [NETIF_F_HW_TLS_RECORD_BIT] = "tls-hw-record", 678c2ecf20Sopenharmony_ci [NETIF_F_HW_TLS_TX_BIT] = "tls-hw-tx-offload", 688c2ecf20Sopenharmony_ci [NETIF_F_HW_TLS_RX_BIT] = "tls-hw-rx-offload", 698c2ecf20Sopenharmony_ci [NETIF_F_GRO_FRAGLIST_BIT] = "rx-gro-list", 708c2ecf20Sopenharmony_ci [NETIF_F_HW_MACSEC_BIT] = "macsec-hw-offload", 718c2ecf20Sopenharmony_ci}; 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ciconst char 748c2ecf20Sopenharmony_cirss_hash_func_strings[ETH_RSS_HASH_FUNCS_COUNT][ETH_GSTRING_LEN] = { 758c2ecf20Sopenharmony_ci [ETH_RSS_HASH_TOP_BIT] = "toeplitz", 768c2ecf20Sopenharmony_ci [ETH_RSS_HASH_XOR_BIT] = "xor", 778c2ecf20Sopenharmony_ci [ETH_RSS_HASH_CRC32_BIT] = "crc32", 788c2ecf20Sopenharmony_ci}; 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ciconst char 818c2ecf20Sopenharmony_citunable_strings[__ETHTOOL_TUNABLE_COUNT][ETH_GSTRING_LEN] = { 828c2ecf20Sopenharmony_ci [ETHTOOL_ID_UNSPEC] = "Unspec", 838c2ecf20Sopenharmony_ci [ETHTOOL_RX_COPYBREAK] = "rx-copybreak", 848c2ecf20Sopenharmony_ci [ETHTOOL_TX_COPYBREAK] = "tx-copybreak", 858c2ecf20Sopenharmony_ci [ETHTOOL_PFC_PREVENTION_TOUT] = "pfc-prevention-tout", 868c2ecf20Sopenharmony_ci}; 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ciconst char 898c2ecf20Sopenharmony_ciphy_tunable_strings[__ETHTOOL_PHY_TUNABLE_COUNT][ETH_GSTRING_LEN] = { 908c2ecf20Sopenharmony_ci [ETHTOOL_ID_UNSPEC] = "Unspec", 918c2ecf20Sopenharmony_ci [ETHTOOL_PHY_DOWNSHIFT] = "phy-downshift", 928c2ecf20Sopenharmony_ci [ETHTOOL_PHY_FAST_LINK_DOWN] = "phy-fast-link-down", 938c2ecf20Sopenharmony_ci [ETHTOOL_PHY_EDPD] = "phy-energy-detect-power-down", 948c2ecf20Sopenharmony_ci}; 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci#define __LINK_MODE_NAME(speed, type, duplex) \ 978c2ecf20Sopenharmony_ci #speed "base" #type "/" #duplex 988c2ecf20Sopenharmony_ci#define __DEFINE_LINK_MODE_NAME(speed, type, duplex) \ 998c2ecf20Sopenharmony_ci [ETHTOOL_LINK_MODE(speed, type, duplex)] = \ 1008c2ecf20Sopenharmony_ci __LINK_MODE_NAME(speed, type, duplex) 1018c2ecf20Sopenharmony_ci#define __DEFINE_SPECIAL_MODE_NAME(_mode, _name) \ 1028c2ecf20Sopenharmony_ci [ETHTOOL_LINK_MODE_ ## _mode ## _BIT] = _name 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ciconst char link_mode_names[][ETH_GSTRING_LEN] = { 1058c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(10, T, Half), 1068c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(10, T, Full), 1078c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(100, T, Half), 1088c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(100, T, Full), 1098c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(1000, T, Half), 1108c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(1000, T, Full), 1118c2ecf20Sopenharmony_ci __DEFINE_SPECIAL_MODE_NAME(Autoneg, "Autoneg"), 1128c2ecf20Sopenharmony_ci __DEFINE_SPECIAL_MODE_NAME(TP, "TP"), 1138c2ecf20Sopenharmony_ci __DEFINE_SPECIAL_MODE_NAME(AUI, "AUI"), 1148c2ecf20Sopenharmony_ci __DEFINE_SPECIAL_MODE_NAME(MII, "MII"), 1158c2ecf20Sopenharmony_ci __DEFINE_SPECIAL_MODE_NAME(FIBRE, "FIBRE"), 1168c2ecf20Sopenharmony_ci __DEFINE_SPECIAL_MODE_NAME(BNC, "BNC"), 1178c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(10000, T, Full), 1188c2ecf20Sopenharmony_ci __DEFINE_SPECIAL_MODE_NAME(Pause, "Pause"), 1198c2ecf20Sopenharmony_ci __DEFINE_SPECIAL_MODE_NAME(Asym_Pause, "Asym_Pause"), 1208c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(2500, X, Full), 1218c2ecf20Sopenharmony_ci __DEFINE_SPECIAL_MODE_NAME(Backplane, "Backplane"), 1228c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(1000, KX, Full), 1238c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(10000, KX4, Full), 1248c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(10000, KR, Full), 1258c2ecf20Sopenharmony_ci __DEFINE_SPECIAL_MODE_NAME(10000baseR_FEC, "10000baseR_FEC"), 1268c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(20000, MLD2, Full), 1278c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(20000, KR2, Full), 1288c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(40000, KR4, Full), 1298c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(40000, CR4, Full), 1308c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(40000, SR4, Full), 1318c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(40000, LR4, Full), 1328c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(56000, KR4, Full), 1338c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(56000, CR4, Full), 1348c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(56000, SR4, Full), 1358c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(56000, LR4, Full), 1368c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(25000, CR, Full), 1378c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(25000, KR, Full), 1388c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(25000, SR, Full), 1398c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(50000, CR2, Full), 1408c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(50000, KR2, Full), 1418c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(100000, KR4, Full), 1428c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(100000, SR4, Full), 1438c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(100000, CR4, Full), 1448c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(100000, LR4_ER4, Full), 1458c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(50000, SR2, Full), 1468c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(1000, X, Full), 1478c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(10000, CR, Full), 1488c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(10000, SR, Full), 1498c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(10000, LR, Full), 1508c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(10000, LRM, Full), 1518c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(10000, ER, Full), 1528c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(2500, T, Full), 1538c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(5000, T, Full), 1548c2ecf20Sopenharmony_ci __DEFINE_SPECIAL_MODE_NAME(FEC_NONE, "None"), 1558c2ecf20Sopenharmony_ci __DEFINE_SPECIAL_MODE_NAME(FEC_RS, "RS"), 1568c2ecf20Sopenharmony_ci __DEFINE_SPECIAL_MODE_NAME(FEC_BASER, "BASER"), 1578c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(50000, KR, Full), 1588c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(50000, SR, Full), 1598c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(50000, CR, Full), 1608c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(50000, LR_ER_FR, Full), 1618c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(50000, DR, Full), 1628c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(100000, KR2, Full), 1638c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(100000, SR2, Full), 1648c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(100000, CR2, Full), 1658c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(100000, LR2_ER2_FR2, Full), 1668c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(100000, DR2, Full), 1678c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(200000, KR4, Full), 1688c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(200000, SR4, Full), 1698c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(200000, LR4_ER4_FR4, Full), 1708c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(200000, DR4, Full), 1718c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(200000, CR4, Full), 1728c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(100, T1, Full), 1738c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(1000, T1, Full), 1748c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(400000, KR8, Full), 1758c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(400000, SR8, Full), 1768c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(400000, LR8_ER8_FR8, Full), 1778c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(400000, DR8, Full), 1788c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(400000, CR8, Full), 1798c2ecf20Sopenharmony_ci __DEFINE_SPECIAL_MODE_NAME(FEC_LLRS, "LLRS"), 1808c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(100000, KR, Full), 1818c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(100000, SR, Full), 1828c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(100000, LR_ER_FR, Full), 1838c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(100000, DR, Full), 1848c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(100000, CR, Full), 1858c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(200000, KR2, Full), 1868c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(200000, SR2, Full), 1878c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(200000, LR2_ER2_FR2, Full), 1888c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(200000, DR2, Full), 1898c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(200000, CR2, Full), 1908c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(400000, KR4, Full), 1918c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(400000, SR4, Full), 1928c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(400000, LR4_ER4_FR4, Full), 1938c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(400000, DR4, Full), 1948c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(400000, CR4, Full), 1958c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(100, FX, Half), 1968c2ecf20Sopenharmony_ci __DEFINE_LINK_MODE_NAME(100, FX, Full), 1978c2ecf20Sopenharmony_ci}; 1988c2ecf20Sopenharmony_cistatic_assert(ARRAY_SIZE(link_mode_names) == __ETHTOOL_LINK_MODE_MASK_NBITS); 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ciconst char netif_msg_class_names[][ETH_GSTRING_LEN] = { 2018c2ecf20Sopenharmony_ci [NETIF_MSG_DRV_BIT] = "drv", 2028c2ecf20Sopenharmony_ci [NETIF_MSG_PROBE_BIT] = "probe", 2038c2ecf20Sopenharmony_ci [NETIF_MSG_LINK_BIT] = "link", 2048c2ecf20Sopenharmony_ci [NETIF_MSG_TIMER_BIT] = "timer", 2058c2ecf20Sopenharmony_ci [NETIF_MSG_IFDOWN_BIT] = "ifdown", 2068c2ecf20Sopenharmony_ci [NETIF_MSG_IFUP_BIT] = "ifup", 2078c2ecf20Sopenharmony_ci [NETIF_MSG_RX_ERR_BIT] = "rx_err", 2088c2ecf20Sopenharmony_ci [NETIF_MSG_TX_ERR_BIT] = "tx_err", 2098c2ecf20Sopenharmony_ci [NETIF_MSG_TX_QUEUED_BIT] = "tx_queued", 2108c2ecf20Sopenharmony_ci [NETIF_MSG_INTR_BIT] = "intr", 2118c2ecf20Sopenharmony_ci [NETIF_MSG_TX_DONE_BIT] = "tx_done", 2128c2ecf20Sopenharmony_ci [NETIF_MSG_RX_STATUS_BIT] = "rx_status", 2138c2ecf20Sopenharmony_ci [NETIF_MSG_PKTDATA_BIT] = "pktdata", 2148c2ecf20Sopenharmony_ci [NETIF_MSG_HW_BIT] = "hw", 2158c2ecf20Sopenharmony_ci [NETIF_MSG_WOL_BIT] = "wol", 2168c2ecf20Sopenharmony_ci}; 2178c2ecf20Sopenharmony_cistatic_assert(ARRAY_SIZE(netif_msg_class_names) == NETIF_MSG_CLASS_COUNT); 2188c2ecf20Sopenharmony_ci 2198c2ecf20Sopenharmony_ciconst char wol_mode_names[][ETH_GSTRING_LEN] = { 2208c2ecf20Sopenharmony_ci [const_ilog2(WAKE_PHY)] = "phy", 2218c2ecf20Sopenharmony_ci [const_ilog2(WAKE_UCAST)] = "ucast", 2228c2ecf20Sopenharmony_ci [const_ilog2(WAKE_MCAST)] = "mcast", 2238c2ecf20Sopenharmony_ci [const_ilog2(WAKE_BCAST)] = "bcast", 2248c2ecf20Sopenharmony_ci [const_ilog2(WAKE_ARP)] = "arp", 2258c2ecf20Sopenharmony_ci [const_ilog2(WAKE_MAGIC)] = "magic", 2268c2ecf20Sopenharmony_ci [const_ilog2(WAKE_MAGICSECURE)] = "magicsecure", 2278c2ecf20Sopenharmony_ci [const_ilog2(WAKE_FILTER)] = "filter", 2288c2ecf20Sopenharmony_ci}; 2298c2ecf20Sopenharmony_cistatic_assert(ARRAY_SIZE(wol_mode_names) == WOL_MODE_COUNT); 2308c2ecf20Sopenharmony_ci 2318c2ecf20Sopenharmony_ciconst char sof_timestamping_names[][ETH_GSTRING_LEN] = { 2328c2ecf20Sopenharmony_ci [const_ilog2(SOF_TIMESTAMPING_TX_HARDWARE)] = "hardware-transmit", 2338c2ecf20Sopenharmony_ci [const_ilog2(SOF_TIMESTAMPING_TX_SOFTWARE)] = "software-transmit", 2348c2ecf20Sopenharmony_ci [const_ilog2(SOF_TIMESTAMPING_RX_HARDWARE)] = "hardware-receive", 2358c2ecf20Sopenharmony_ci [const_ilog2(SOF_TIMESTAMPING_RX_SOFTWARE)] = "software-receive", 2368c2ecf20Sopenharmony_ci [const_ilog2(SOF_TIMESTAMPING_SOFTWARE)] = "software-system-clock", 2378c2ecf20Sopenharmony_ci [const_ilog2(SOF_TIMESTAMPING_SYS_HARDWARE)] = "hardware-legacy-clock", 2388c2ecf20Sopenharmony_ci [const_ilog2(SOF_TIMESTAMPING_RAW_HARDWARE)] = "hardware-raw-clock", 2398c2ecf20Sopenharmony_ci [const_ilog2(SOF_TIMESTAMPING_OPT_ID)] = "option-id", 2408c2ecf20Sopenharmony_ci [const_ilog2(SOF_TIMESTAMPING_TX_SCHED)] = "sched-transmit", 2418c2ecf20Sopenharmony_ci [const_ilog2(SOF_TIMESTAMPING_TX_ACK)] = "ack-transmit", 2428c2ecf20Sopenharmony_ci [const_ilog2(SOF_TIMESTAMPING_OPT_CMSG)] = "option-cmsg", 2438c2ecf20Sopenharmony_ci [const_ilog2(SOF_TIMESTAMPING_OPT_TSONLY)] = "option-tsonly", 2448c2ecf20Sopenharmony_ci [const_ilog2(SOF_TIMESTAMPING_OPT_STATS)] = "option-stats", 2458c2ecf20Sopenharmony_ci [const_ilog2(SOF_TIMESTAMPING_OPT_PKTINFO)] = "option-pktinfo", 2468c2ecf20Sopenharmony_ci [const_ilog2(SOF_TIMESTAMPING_OPT_TX_SWHW)] = "option-tx-swhw", 2478c2ecf20Sopenharmony_ci}; 2488c2ecf20Sopenharmony_cistatic_assert(ARRAY_SIZE(sof_timestamping_names) == __SOF_TIMESTAMPING_CNT); 2498c2ecf20Sopenharmony_ci 2508c2ecf20Sopenharmony_ciconst char ts_tx_type_names[][ETH_GSTRING_LEN] = { 2518c2ecf20Sopenharmony_ci [HWTSTAMP_TX_OFF] = "off", 2528c2ecf20Sopenharmony_ci [HWTSTAMP_TX_ON] = "on", 2538c2ecf20Sopenharmony_ci [HWTSTAMP_TX_ONESTEP_SYNC] = "onestep-sync", 2548c2ecf20Sopenharmony_ci [HWTSTAMP_TX_ONESTEP_P2P] = "onestep-p2p", 2558c2ecf20Sopenharmony_ci}; 2568c2ecf20Sopenharmony_cistatic_assert(ARRAY_SIZE(ts_tx_type_names) == __HWTSTAMP_TX_CNT); 2578c2ecf20Sopenharmony_ci 2588c2ecf20Sopenharmony_ciconst char ts_rx_filter_names[][ETH_GSTRING_LEN] = { 2598c2ecf20Sopenharmony_ci [HWTSTAMP_FILTER_NONE] = "none", 2608c2ecf20Sopenharmony_ci [HWTSTAMP_FILTER_ALL] = "all", 2618c2ecf20Sopenharmony_ci [HWTSTAMP_FILTER_SOME] = "some", 2628c2ecf20Sopenharmony_ci [HWTSTAMP_FILTER_PTP_V1_L4_EVENT] = "ptpv1-l4-event", 2638c2ecf20Sopenharmony_ci [HWTSTAMP_FILTER_PTP_V1_L4_SYNC] = "ptpv1-l4-sync", 2648c2ecf20Sopenharmony_ci [HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ] = "ptpv1-l4-delay-req", 2658c2ecf20Sopenharmony_ci [HWTSTAMP_FILTER_PTP_V2_L4_EVENT] = "ptpv2-l4-event", 2668c2ecf20Sopenharmony_ci [HWTSTAMP_FILTER_PTP_V2_L4_SYNC] = "ptpv2-l4-sync", 2678c2ecf20Sopenharmony_ci [HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ] = "ptpv2-l4-delay-req", 2688c2ecf20Sopenharmony_ci [HWTSTAMP_FILTER_PTP_V2_L2_EVENT] = "ptpv2-l2-event", 2698c2ecf20Sopenharmony_ci [HWTSTAMP_FILTER_PTP_V2_L2_SYNC] = "ptpv2-l2-sync", 2708c2ecf20Sopenharmony_ci [HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ] = "ptpv2-l2-delay-req", 2718c2ecf20Sopenharmony_ci [HWTSTAMP_FILTER_PTP_V2_EVENT] = "ptpv2-event", 2728c2ecf20Sopenharmony_ci [HWTSTAMP_FILTER_PTP_V2_SYNC] = "ptpv2-sync", 2738c2ecf20Sopenharmony_ci [HWTSTAMP_FILTER_PTP_V2_DELAY_REQ] = "ptpv2-delay-req", 2748c2ecf20Sopenharmony_ci [HWTSTAMP_FILTER_NTP_ALL] = "ntp-all", 2758c2ecf20Sopenharmony_ci}; 2768c2ecf20Sopenharmony_cistatic_assert(ARRAY_SIZE(ts_rx_filter_names) == __HWTSTAMP_FILTER_CNT); 2778c2ecf20Sopenharmony_ci 2788c2ecf20Sopenharmony_ciconst char udp_tunnel_type_names[][ETH_GSTRING_LEN] = { 2798c2ecf20Sopenharmony_ci [ETHTOOL_UDP_TUNNEL_TYPE_VXLAN] = "vxlan", 2808c2ecf20Sopenharmony_ci [ETHTOOL_UDP_TUNNEL_TYPE_GENEVE] = "geneve", 2818c2ecf20Sopenharmony_ci [ETHTOOL_UDP_TUNNEL_TYPE_VXLAN_GPE] = "vxlan-gpe", 2828c2ecf20Sopenharmony_ci}; 2838c2ecf20Sopenharmony_cistatic_assert(ARRAY_SIZE(udp_tunnel_type_names) == 2848c2ecf20Sopenharmony_ci __ETHTOOL_UDP_TUNNEL_TYPE_CNT); 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_ci/* return false if legacy contained non-0 deprecated fields 2878c2ecf20Sopenharmony_ci * maxtxpkt/maxrxpkt. rest of ksettings always updated 2888c2ecf20Sopenharmony_ci */ 2898c2ecf20Sopenharmony_cibool 2908c2ecf20Sopenharmony_ciconvert_legacy_settings_to_link_ksettings( 2918c2ecf20Sopenharmony_ci struct ethtool_link_ksettings *link_ksettings, 2928c2ecf20Sopenharmony_ci const struct ethtool_cmd *legacy_settings) 2938c2ecf20Sopenharmony_ci{ 2948c2ecf20Sopenharmony_ci bool retval = true; 2958c2ecf20Sopenharmony_ci 2968c2ecf20Sopenharmony_ci memset(link_ksettings, 0, sizeof(*link_ksettings)); 2978c2ecf20Sopenharmony_ci 2988c2ecf20Sopenharmony_ci /* This is used to tell users that driver is still using these 2998c2ecf20Sopenharmony_ci * deprecated legacy fields, and they should not use 3008c2ecf20Sopenharmony_ci * %ETHTOOL_GLINKSETTINGS/%ETHTOOL_SLINKSETTINGS 3018c2ecf20Sopenharmony_ci */ 3028c2ecf20Sopenharmony_ci if (legacy_settings->maxtxpkt || 3038c2ecf20Sopenharmony_ci legacy_settings->maxrxpkt) 3048c2ecf20Sopenharmony_ci retval = false; 3058c2ecf20Sopenharmony_ci 3068c2ecf20Sopenharmony_ci ethtool_convert_legacy_u32_to_link_mode( 3078c2ecf20Sopenharmony_ci link_ksettings->link_modes.supported, 3088c2ecf20Sopenharmony_ci legacy_settings->supported); 3098c2ecf20Sopenharmony_ci ethtool_convert_legacy_u32_to_link_mode( 3108c2ecf20Sopenharmony_ci link_ksettings->link_modes.advertising, 3118c2ecf20Sopenharmony_ci legacy_settings->advertising); 3128c2ecf20Sopenharmony_ci ethtool_convert_legacy_u32_to_link_mode( 3138c2ecf20Sopenharmony_ci link_ksettings->link_modes.lp_advertising, 3148c2ecf20Sopenharmony_ci legacy_settings->lp_advertising); 3158c2ecf20Sopenharmony_ci link_ksettings->base.speed 3168c2ecf20Sopenharmony_ci = ethtool_cmd_speed(legacy_settings); 3178c2ecf20Sopenharmony_ci link_ksettings->base.duplex 3188c2ecf20Sopenharmony_ci = legacy_settings->duplex; 3198c2ecf20Sopenharmony_ci link_ksettings->base.port 3208c2ecf20Sopenharmony_ci = legacy_settings->port; 3218c2ecf20Sopenharmony_ci link_ksettings->base.phy_address 3228c2ecf20Sopenharmony_ci = legacy_settings->phy_address; 3238c2ecf20Sopenharmony_ci link_ksettings->base.autoneg 3248c2ecf20Sopenharmony_ci = legacy_settings->autoneg; 3258c2ecf20Sopenharmony_ci link_ksettings->base.mdio_support 3268c2ecf20Sopenharmony_ci = legacy_settings->mdio_support; 3278c2ecf20Sopenharmony_ci link_ksettings->base.eth_tp_mdix 3288c2ecf20Sopenharmony_ci = legacy_settings->eth_tp_mdix; 3298c2ecf20Sopenharmony_ci link_ksettings->base.eth_tp_mdix_ctrl 3308c2ecf20Sopenharmony_ci = legacy_settings->eth_tp_mdix_ctrl; 3318c2ecf20Sopenharmony_ci return retval; 3328c2ecf20Sopenharmony_ci} 3338c2ecf20Sopenharmony_ci 3348c2ecf20Sopenharmony_ciint __ethtool_get_link(struct net_device *dev) 3358c2ecf20Sopenharmony_ci{ 3368c2ecf20Sopenharmony_ci if (!dev->ethtool_ops->get_link) 3378c2ecf20Sopenharmony_ci return -EOPNOTSUPP; 3388c2ecf20Sopenharmony_ci 3398c2ecf20Sopenharmony_ci return netif_running(dev) && dev->ethtool_ops->get_link(dev); 3408c2ecf20Sopenharmony_ci} 3418c2ecf20Sopenharmony_ci 3428c2ecf20Sopenharmony_ciint ethtool_get_max_rxfh_channel(struct net_device *dev, u32 *max) 3438c2ecf20Sopenharmony_ci{ 3448c2ecf20Sopenharmony_ci u32 dev_size, current_max = 0; 3458c2ecf20Sopenharmony_ci u32 *indir; 3468c2ecf20Sopenharmony_ci int ret; 3478c2ecf20Sopenharmony_ci 3488c2ecf20Sopenharmony_ci if (!dev->ethtool_ops->get_rxfh_indir_size || 3498c2ecf20Sopenharmony_ci !dev->ethtool_ops->get_rxfh) 3508c2ecf20Sopenharmony_ci return -EOPNOTSUPP; 3518c2ecf20Sopenharmony_ci dev_size = dev->ethtool_ops->get_rxfh_indir_size(dev); 3528c2ecf20Sopenharmony_ci if (dev_size == 0) 3538c2ecf20Sopenharmony_ci return -EOPNOTSUPP; 3548c2ecf20Sopenharmony_ci 3558c2ecf20Sopenharmony_ci indir = kcalloc(dev_size, sizeof(indir[0]), GFP_USER); 3568c2ecf20Sopenharmony_ci if (!indir) 3578c2ecf20Sopenharmony_ci return -ENOMEM; 3588c2ecf20Sopenharmony_ci 3598c2ecf20Sopenharmony_ci ret = dev->ethtool_ops->get_rxfh(dev, indir, NULL, NULL); 3608c2ecf20Sopenharmony_ci if (ret) 3618c2ecf20Sopenharmony_ci goto out; 3628c2ecf20Sopenharmony_ci 3638c2ecf20Sopenharmony_ci while (dev_size--) 3648c2ecf20Sopenharmony_ci current_max = max(current_max, indir[dev_size]); 3658c2ecf20Sopenharmony_ci 3668c2ecf20Sopenharmony_ci *max = current_max; 3678c2ecf20Sopenharmony_ci 3688c2ecf20Sopenharmony_ciout: 3698c2ecf20Sopenharmony_ci kfree(indir); 3708c2ecf20Sopenharmony_ci return ret; 3718c2ecf20Sopenharmony_ci} 3728c2ecf20Sopenharmony_ci 3738c2ecf20Sopenharmony_ciint ethtool_check_ops(const struct ethtool_ops *ops) 3748c2ecf20Sopenharmony_ci{ 3758c2ecf20Sopenharmony_ci if (WARN_ON(ops->set_coalesce && !ops->supported_coalesce_params)) 3768c2ecf20Sopenharmony_ci return -EINVAL; 3778c2ecf20Sopenharmony_ci /* NOTE: sufficiently insane drivers may swap ethtool_ops at runtime, 3788c2ecf20Sopenharmony_ci * the fact that ops are checked at registration time does not 3798c2ecf20Sopenharmony_ci * mean the ops attached to a netdev later on are sane. 3808c2ecf20Sopenharmony_ci */ 3818c2ecf20Sopenharmony_ci return 0; 3828c2ecf20Sopenharmony_ci} 3838c2ecf20Sopenharmony_ci 3848c2ecf20Sopenharmony_ciint __ethtool_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info) 3858c2ecf20Sopenharmony_ci{ 3868c2ecf20Sopenharmony_ci const struct ethtool_ops *ops = dev->ethtool_ops; 3878c2ecf20Sopenharmony_ci struct phy_device *phydev = dev->phydev; 3888c2ecf20Sopenharmony_ci 3898c2ecf20Sopenharmony_ci memset(info, 0, sizeof(*info)); 3908c2ecf20Sopenharmony_ci info->cmd = ETHTOOL_GET_TS_INFO; 3918c2ecf20Sopenharmony_ci 3928c2ecf20Sopenharmony_ci if (phy_has_tsinfo(phydev)) 3938c2ecf20Sopenharmony_ci return phy_ts_info(phydev, info); 3948c2ecf20Sopenharmony_ci if (ops->get_ts_info) 3958c2ecf20Sopenharmony_ci return ops->get_ts_info(dev, info); 3968c2ecf20Sopenharmony_ci 3978c2ecf20Sopenharmony_ci info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE | 3988c2ecf20Sopenharmony_ci SOF_TIMESTAMPING_SOFTWARE; 3998c2ecf20Sopenharmony_ci info->phc_index = -1; 4008c2ecf20Sopenharmony_ci 4018c2ecf20Sopenharmony_ci return 0; 4028c2ecf20Sopenharmony_ci} 4038c2ecf20Sopenharmony_ci 4048c2ecf20Sopenharmony_ciconst struct ethtool_phy_ops *ethtool_phy_ops; 4058c2ecf20Sopenharmony_ci 4068c2ecf20Sopenharmony_civoid ethtool_set_ethtool_phy_ops(const struct ethtool_phy_ops *ops) 4078c2ecf20Sopenharmony_ci{ 4088c2ecf20Sopenharmony_ci rtnl_lock(); 4098c2ecf20Sopenharmony_ci ethtool_phy_ops = ops; 4108c2ecf20Sopenharmony_ci rtnl_unlock(); 4118c2ecf20Sopenharmony_ci} 4128c2ecf20Sopenharmony_ciEXPORT_SYMBOL_GPL(ethtool_set_ethtool_phy_ops); 413