linux/net/ethtool/common.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0-only
   2
   3#include <linux/ethtool_netlink.h>
   4#include <linux/net_tstamp.h>
   5#include <linux/phy.h>
   6
   7#include "common.h"
   8
   9const char netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN] = {
  10        [NETIF_F_SG_BIT] =               "tx-scatter-gather",
  11        [NETIF_F_IP_CSUM_BIT] =          "tx-checksum-ipv4",
  12        [NETIF_F_HW_CSUM_BIT] =          "tx-checksum-ip-generic",
  13        [NETIF_F_IPV6_CSUM_BIT] =        "tx-checksum-ipv6",
  14        [NETIF_F_HIGHDMA_BIT] =          "highdma",
  15        [NETIF_F_FRAGLIST_BIT] =         "tx-scatter-gather-fraglist",
  16        [NETIF_F_HW_VLAN_CTAG_TX_BIT] =  "tx-vlan-hw-insert",
  17
  18        [NETIF_F_HW_VLAN_CTAG_RX_BIT] =  "rx-vlan-hw-parse",
  19        [NETIF_F_HW_VLAN_CTAG_FILTER_BIT] = "rx-vlan-filter",
  20        [NETIF_F_HW_VLAN_STAG_TX_BIT] =  "tx-vlan-stag-hw-insert",
  21        [NETIF_F_HW_VLAN_STAG_RX_BIT] =  "rx-vlan-stag-hw-parse",
  22        [NETIF_F_HW_VLAN_STAG_FILTER_BIT] = "rx-vlan-stag-filter",
  23        [NETIF_F_VLAN_CHALLENGED_BIT] =  "vlan-challenged",
  24        [NETIF_F_GSO_BIT] =              "tx-generic-segmentation",
  25        [NETIF_F_LLTX_BIT] =             "tx-lockless",
  26        [NETIF_F_NETNS_LOCAL_BIT] =      "netns-local",
  27        [NETIF_F_GRO_BIT] =              "rx-gro",
  28        [NETIF_F_GRO_HW_BIT] =           "rx-gro-hw",
  29        [NETIF_F_LRO_BIT] =              "rx-lro",
  30
  31        [NETIF_F_TSO_BIT] =              "tx-tcp-segmentation",
  32        [NETIF_F_GSO_ROBUST_BIT] =       "tx-gso-robust",
  33        [NETIF_F_TSO_ECN_BIT] =          "tx-tcp-ecn-segmentation",
  34        [NETIF_F_TSO_MANGLEID_BIT] =     "tx-tcp-mangleid-segmentation",
  35        [NETIF_F_TSO6_BIT] =             "tx-tcp6-segmentation",
  36        [NETIF_F_FSO_BIT] =              "tx-fcoe-segmentation",
  37        [NETIF_F_GSO_GRE_BIT] =          "tx-gre-segmentation",
  38        [NETIF_F_GSO_GRE_CSUM_BIT] =     "tx-gre-csum-segmentation",
  39        [NETIF_F_GSO_IPXIP4_BIT] =       "tx-ipxip4-segmentation",
  40        [NETIF_F_GSO_IPXIP6_BIT] =       "tx-ipxip6-segmentation",
  41        [NETIF_F_GSO_UDP_TUNNEL_BIT] =   "tx-udp_tnl-segmentation",
  42        [NETIF_F_GSO_UDP_TUNNEL_CSUM_BIT] = "tx-udp_tnl-csum-segmentation",
  43        [NETIF_F_GSO_PARTIAL_BIT] =      "tx-gso-partial",
  44        [NETIF_F_GSO_TUNNEL_REMCSUM_BIT] = "tx-tunnel-remcsum-segmentation",
  45        [NETIF_F_GSO_SCTP_BIT] =         "tx-sctp-segmentation",
  46        [NETIF_F_GSO_ESP_BIT] =          "tx-esp-segmentation",
  47        [NETIF_F_GSO_UDP_L4_BIT] =       "tx-udp-segmentation",
  48        [NETIF_F_GSO_FRAGLIST_BIT] =     "tx-gso-list",
  49
  50        [NETIF_F_FCOE_CRC_BIT] =         "tx-checksum-fcoe-crc",
  51        [NETIF_F_SCTP_CRC_BIT] =        "tx-checksum-sctp",
  52        [NETIF_F_FCOE_MTU_BIT] =         "fcoe-mtu",
  53        [NETIF_F_NTUPLE_BIT] =           "rx-ntuple-filter",
  54        [NETIF_F_RXHASH_BIT] =           "rx-hashing",
  55        [NETIF_F_RXCSUM_BIT] =           "rx-checksum",
  56        [NETIF_F_NOCACHE_COPY_BIT] =     "tx-nocache-copy",
  57        [NETIF_F_LOOPBACK_BIT] =         "loopback",
  58        [NETIF_F_RXFCS_BIT] =            "rx-fcs",
  59        [NETIF_F_RXALL_BIT] =            "rx-all",
  60        [NETIF_F_HW_L2FW_DOFFLOAD_BIT] = "l2-fwd-offload",
  61        [NETIF_F_HW_TC_BIT] =            "hw-tc-offload",
  62        [NETIF_F_HW_ESP_BIT] =           "esp-hw-offload",
  63        [NETIF_F_HW_ESP_TX_CSUM_BIT] =   "esp-tx-csum-hw-offload",
  64        [NETIF_F_RX_UDP_TUNNEL_PORT_BIT] =       "rx-udp_tunnel-port-offload",
  65        [NETIF_F_HW_TLS_RECORD_BIT] =   "tls-hw-record",
  66        [NETIF_F_HW_TLS_TX_BIT] =        "tls-hw-tx-offload",
  67        [NETIF_F_HW_TLS_RX_BIT] =        "tls-hw-rx-offload",
  68        [NETIF_F_GRO_FRAGLIST_BIT] =     "rx-gro-list",
  69};
  70
  71const char
  72rss_hash_func_strings[ETH_RSS_HASH_FUNCS_COUNT][ETH_GSTRING_LEN] = {
  73        [ETH_RSS_HASH_TOP_BIT] =        "toeplitz",
  74        [ETH_RSS_HASH_XOR_BIT] =        "xor",
  75        [ETH_RSS_HASH_CRC32_BIT] =      "crc32",
  76};
  77
  78const char
  79tunable_strings[__ETHTOOL_TUNABLE_COUNT][ETH_GSTRING_LEN] = {
  80        [ETHTOOL_ID_UNSPEC]     = "Unspec",
  81        [ETHTOOL_RX_COPYBREAK]  = "rx-copybreak",
  82        [ETHTOOL_TX_COPYBREAK]  = "tx-copybreak",
  83        [ETHTOOL_PFC_PREVENTION_TOUT] = "pfc-prevention-tout",
  84};
  85
  86const char
  87phy_tunable_strings[__ETHTOOL_PHY_TUNABLE_COUNT][ETH_GSTRING_LEN] = {
  88        [ETHTOOL_ID_UNSPEC]     = "Unspec",
  89        [ETHTOOL_PHY_DOWNSHIFT] = "phy-downshift",
  90        [ETHTOOL_PHY_FAST_LINK_DOWN] = "phy-fast-link-down",
  91        [ETHTOOL_PHY_EDPD]      = "phy-energy-detect-power-down",
  92};
  93
  94#define __LINK_MODE_NAME(speed, type, duplex) \
  95        #speed "base" #type "/" #duplex
  96#define __DEFINE_LINK_MODE_NAME(speed, type, duplex) \
  97        [ETHTOOL_LINK_MODE(speed, type, duplex)] = \
  98        __LINK_MODE_NAME(speed, type, duplex)
  99#define __DEFINE_SPECIAL_MODE_NAME(_mode, _name) \
 100        [ETHTOOL_LINK_MODE_ ## _mode ## _BIT] = _name
 101
 102const char link_mode_names[][ETH_GSTRING_LEN] = {
 103        __DEFINE_LINK_MODE_NAME(10, T, Half),
 104        __DEFINE_LINK_MODE_NAME(10, T, Full),
 105        __DEFINE_LINK_MODE_NAME(100, T, Half),
 106        __DEFINE_LINK_MODE_NAME(100, T, Full),
 107        __DEFINE_LINK_MODE_NAME(1000, T, Half),
 108        __DEFINE_LINK_MODE_NAME(1000, T, Full),
 109        __DEFINE_SPECIAL_MODE_NAME(Autoneg, "Autoneg"),
 110        __DEFINE_SPECIAL_MODE_NAME(TP, "TP"),
 111        __DEFINE_SPECIAL_MODE_NAME(AUI, "AUI"),
 112        __DEFINE_SPECIAL_MODE_NAME(MII, "MII"),
 113        __DEFINE_SPECIAL_MODE_NAME(FIBRE, "FIBRE"),
 114        __DEFINE_SPECIAL_MODE_NAME(BNC, "BNC"),
 115        __DEFINE_LINK_MODE_NAME(10000, T, Full),
 116        __DEFINE_SPECIAL_MODE_NAME(Pause, "Pause"),
 117        __DEFINE_SPECIAL_MODE_NAME(Asym_Pause, "Asym_Pause"),
 118        __DEFINE_LINK_MODE_NAME(2500, X, Full),
 119        __DEFINE_SPECIAL_MODE_NAME(Backplane, "Backplane"),
 120        __DEFINE_LINK_MODE_NAME(1000, KX, Full),
 121        __DEFINE_LINK_MODE_NAME(10000, KX4, Full),
 122        __DEFINE_LINK_MODE_NAME(10000, KR, Full),
 123        __DEFINE_SPECIAL_MODE_NAME(10000baseR_FEC, "10000baseR_FEC"),
 124        __DEFINE_LINK_MODE_NAME(20000, MLD2, Full),
 125        __DEFINE_LINK_MODE_NAME(20000, KR2, Full),
 126        __DEFINE_LINK_MODE_NAME(40000, KR4, Full),
 127        __DEFINE_LINK_MODE_NAME(40000, CR4, Full),
 128        __DEFINE_LINK_MODE_NAME(40000, SR4, Full),
 129        __DEFINE_LINK_MODE_NAME(40000, LR4, Full),
 130        __DEFINE_LINK_MODE_NAME(56000, KR4, Full),
 131        __DEFINE_LINK_MODE_NAME(56000, CR4, Full),
 132        __DEFINE_LINK_MODE_NAME(56000, SR4, Full),
 133        __DEFINE_LINK_MODE_NAME(56000, LR4, Full),
 134        __DEFINE_LINK_MODE_NAME(25000, CR, Full),
 135        __DEFINE_LINK_MODE_NAME(25000, KR, Full),
 136        __DEFINE_LINK_MODE_NAME(25000, SR, Full),
 137        __DEFINE_LINK_MODE_NAME(50000, CR2, Full),
 138        __DEFINE_LINK_MODE_NAME(50000, KR2, Full),
 139        __DEFINE_LINK_MODE_NAME(100000, KR4, Full),
 140        __DEFINE_LINK_MODE_NAME(100000, SR4, Full),
 141        __DEFINE_LINK_MODE_NAME(100000, CR4, Full),
 142        __DEFINE_LINK_MODE_NAME(100000, LR4_ER4, Full),
 143        __DEFINE_LINK_MODE_NAME(50000, SR2, Full),
 144        __DEFINE_LINK_MODE_NAME(1000, X, Full),
 145        __DEFINE_LINK_MODE_NAME(10000, CR, Full),
 146        __DEFINE_LINK_MODE_NAME(10000, SR, Full),
 147        __DEFINE_LINK_MODE_NAME(10000, LR, Full),
 148        __DEFINE_LINK_MODE_NAME(10000, LRM, Full),
 149        __DEFINE_LINK_MODE_NAME(10000, ER, Full),
 150        __DEFINE_LINK_MODE_NAME(2500, T, Full),
 151        __DEFINE_LINK_MODE_NAME(5000, T, Full),
 152        __DEFINE_SPECIAL_MODE_NAME(FEC_NONE, "None"),
 153        __DEFINE_SPECIAL_MODE_NAME(FEC_RS, "RS"),
 154        __DEFINE_SPECIAL_MODE_NAME(FEC_BASER, "BASER"),
 155        __DEFINE_LINK_MODE_NAME(50000, KR, Full),
 156        __DEFINE_LINK_MODE_NAME(50000, SR, Full),
 157        __DEFINE_LINK_MODE_NAME(50000, CR, Full),
 158        __DEFINE_LINK_MODE_NAME(50000, LR_ER_FR, Full),
 159        __DEFINE_LINK_MODE_NAME(50000, DR, Full),
 160        __DEFINE_LINK_MODE_NAME(100000, KR2, Full),
 161        __DEFINE_LINK_MODE_NAME(100000, SR2, Full),
 162        __DEFINE_LINK_MODE_NAME(100000, CR2, Full),
 163        __DEFINE_LINK_MODE_NAME(100000, LR2_ER2_FR2, Full),
 164        __DEFINE_LINK_MODE_NAME(100000, DR2, Full),
 165        __DEFINE_LINK_MODE_NAME(200000, KR4, Full),
 166        __DEFINE_LINK_MODE_NAME(200000, SR4, Full),
 167        __DEFINE_LINK_MODE_NAME(200000, LR4_ER4_FR4, Full),
 168        __DEFINE_LINK_MODE_NAME(200000, DR4, Full),
 169        __DEFINE_LINK_MODE_NAME(200000, CR4, Full),
 170        __DEFINE_LINK_MODE_NAME(100, T1, Full),
 171        __DEFINE_LINK_MODE_NAME(1000, T1, Full),
 172        __DEFINE_LINK_MODE_NAME(400000, KR8, Full),
 173        __DEFINE_LINK_MODE_NAME(400000, SR8, Full),
 174        __DEFINE_LINK_MODE_NAME(400000, LR8_ER8_FR8, Full),
 175        __DEFINE_LINK_MODE_NAME(400000, DR8, Full),
 176        __DEFINE_LINK_MODE_NAME(400000, CR8, Full),
 177        __DEFINE_SPECIAL_MODE_NAME(FEC_LLRS, "LLRS"),
 178        __DEFINE_LINK_MODE_NAME(100000, KR, Full),
 179        __DEFINE_LINK_MODE_NAME(100000, SR, Full),
 180        __DEFINE_LINK_MODE_NAME(100000, LR_ER_FR, Full),
 181        __DEFINE_LINK_MODE_NAME(100000, DR, Full),
 182        __DEFINE_LINK_MODE_NAME(100000, CR, Full),
 183        __DEFINE_LINK_MODE_NAME(200000, KR2, Full),
 184        __DEFINE_LINK_MODE_NAME(200000, SR2, Full),
 185        __DEFINE_LINK_MODE_NAME(200000, LR2_ER2_FR2, Full),
 186        __DEFINE_LINK_MODE_NAME(200000, DR2, Full),
 187        __DEFINE_LINK_MODE_NAME(200000, CR2, Full),
 188        __DEFINE_LINK_MODE_NAME(400000, KR4, Full),
 189        __DEFINE_LINK_MODE_NAME(400000, SR4, Full),
 190        __DEFINE_LINK_MODE_NAME(400000, LR4_ER4_FR4, Full),
 191        __DEFINE_LINK_MODE_NAME(400000, DR4, Full),
 192        __DEFINE_LINK_MODE_NAME(400000, CR4, Full),
 193};
 194static_assert(ARRAY_SIZE(link_mode_names) == __ETHTOOL_LINK_MODE_MASK_NBITS);
 195
 196const char netif_msg_class_names[][ETH_GSTRING_LEN] = {
 197        [NETIF_MSG_DRV_BIT]             = "drv",
 198        [NETIF_MSG_PROBE_BIT]           = "probe",
 199        [NETIF_MSG_LINK_BIT]            = "link",
 200        [NETIF_MSG_TIMER_BIT]           = "timer",
 201        [NETIF_MSG_IFDOWN_BIT]          = "ifdown",
 202        [NETIF_MSG_IFUP_BIT]            = "ifup",
 203        [NETIF_MSG_RX_ERR_BIT]          = "rx_err",
 204        [NETIF_MSG_TX_ERR_BIT]          = "tx_err",
 205        [NETIF_MSG_TX_QUEUED_BIT]       = "tx_queued",
 206        [NETIF_MSG_INTR_BIT]            = "intr",
 207        [NETIF_MSG_TX_DONE_BIT]         = "tx_done",
 208        [NETIF_MSG_RX_STATUS_BIT]       = "rx_status",
 209        [NETIF_MSG_PKTDATA_BIT]         = "pktdata",
 210        [NETIF_MSG_HW_BIT]              = "hw",
 211        [NETIF_MSG_WOL_BIT]             = "wol",
 212};
 213static_assert(ARRAY_SIZE(netif_msg_class_names) == NETIF_MSG_CLASS_COUNT);
 214
 215const char wol_mode_names[][ETH_GSTRING_LEN] = {
 216        [const_ilog2(WAKE_PHY)]         = "phy",
 217        [const_ilog2(WAKE_UCAST)]       = "ucast",
 218        [const_ilog2(WAKE_MCAST)]       = "mcast",
 219        [const_ilog2(WAKE_BCAST)]       = "bcast",
 220        [const_ilog2(WAKE_ARP)]         = "arp",
 221        [const_ilog2(WAKE_MAGIC)]       = "magic",
 222        [const_ilog2(WAKE_MAGICSECURE)] = "magicsecure",
 223        [const_ilog2(WAKE_FILTER)]      = "filter",
 224};
 225static_assert(ARRAY_SIZE(wol_mode_names) == WOL_MODE_COUNT);
 226
 227const char sof_timestamping_names[][ETH_GSTRING_LEN] = {
 228        [const_ilog2(SOF_TIMESTAMPING_TX_HARDWARE)]  = "hardware-transmit",
 229        [const_ilog2(SOF_TIMESTAMPING_TX_SOFTWARE)]  = "software-transmit",
 230        [const_ilog2(SOF_TIMESTAMPING_RX_HARDWARE)]  = "hardware-receive",
 231        [const_ilog2(SOF_TIMESTAMPING_RX_SOFTWARE)]  = "software-receive",
 232        [const_ilog2(SOF_TIMESTAMPING_SOFTWARE)]     = "software-system-clock",
 233        [const_ilog2(SOF_TIMESTAMPING_SYS_HARDWARE)] = "hardware-legacy-clock",
 234        [const_ilog2(SOF_TIMESTAMPING_RAW_HARDWARE)] = "hardware-raw-clock",
 235        [const_ilog2(SOF_TIMESTAMPING_OPT_ID)]       = "option-id",
 236        [const_ilog2(SOF_TIMESTAMPING_TX_SCHED)]     = "sched-transmit",
 237        [const_ilog2(SOF_TIMESTAMPING_TX_ACK)]       = "ack-transmit",
 238        [const_ilog2(SOF_TIMESTAMPING_OPT_CMSG)]     = "option-cmsg",
 239        [const_ilog2(SOF_TIMESTAMPING_OPT_TSONLY)]   = "option-tsonly",
 240        [const_ilog2(SOF_TIMESTAMPING_OPT_STATS)]    = "option-stats",
 241        [const_ilog2(SOF_TIMESTAMPING_OPT_PKTINFO)]  = "option-pktinfo",
 242        [const_ilog2(SOF_TIMESTAMPING_OPT_TX_SWHW)]  = "option-tx-swhw",
 243};
 244static_assert(ARRAY_SIZE(sof_timestamping_names) == __SOF_TIMESTAMPING_CNT);
 245
 246const char ts_tx_type_names[][ETH_GSTRING_LEN] = {
 247        [HWTSTAMP_TX_OFF]               = "off",
 248        [HWTSTAMP_TX_ON]                = "on",
 249        [HWTSTAMP_TX_ONESTEP_SYNC]      = "onestep-sync",
 250};
 251static_assert(ARRAY_SIZE(ts_tx_type_names) == __HWTSTAMP_TX_CNT);
 252
 253const char ts_rx_filter_names[][ETH_GSTRING_LEN] = {
 254        [HWTSTAMP_FILTER_NONE]                  = "none",
 255        [HWTSTAMP_FILTER_ALL]                   = "all",
 256        [HWTSTAMP_FILTER_SOME]                  = "some",
 257        [HWTSTAMP_FILTER_PTP_V1_L4_EVENT]       = "ptpv1-l4-event",
 258        [HWTSTAMP_FILTER_PTP_V1_L4_SYNC]        = "ptpv1-l4-sync",
 259        [HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ]   = "ptpv1-l4-delay-req",
 260        [HWTSTAMP_FILTER_PTP_V2_L4_EVENT]       = "ptpv2-l4-event",
 261        [HWTSTAMP_FILTER_PTP_V2_L4_SYNC]        = "ptpv2-l4-sync",
 262        [HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ]   = "ptpv2-l4-delay-req",
 263        [HWTSTAMP_FILTER_PTP_V2_L2_EVENT]       = "ptpv2-l2-event",
 264        [HWTSTAMP_FILTER_PTP_V2_L2_SYNC]        = "ptpv2-l2-sync",
 265        [HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ]   = "ptpv2-l2-delay-req",
 266        [HWTSTAMP_FILTER_PTP_V2_EVENT]          = "ptpv2-event",
 267        [HWTSTAMP_FILTER_PTP_V2_SYNC]           = "ptpv2-sync",
 268        [HWTSTAMP_FILTER_PTP_V2_DELAY_REQ]      = "ptpv2-delay-req",
 269        [HWTSTAMP_FILTER_NTP_ALL]               = "ntp-all",
 270};
 271static_assert(ARRAY_SIZE(ts_rx_filter_names) == __HWTSTAMP_FILTER_CNT);
 272
 273const char udp_tunnel_type_names[][ETH_GSTRING_LEN] = {
 274        [ETHTOOL_UDP_TUNNEL_TYPE_VXLAN]         = "vxlan",
 275        [ETHTOOL_UDP_TUNNEL_TYPE_GENEVE]        = "geneve",
 276        [ETHTOOL_UDP_TUNNEL_TYPE_VXLAN_GPE]     = "vxlan-gpe",
 277};
 278static_assert(ARRAY_SIZE(udp_tunnel_type_names) ==
 279              __ETHTOOL_UDP_TUNNEL_TYPE_CNT);
 280
 281/* return false if legacy contained non-0 deprecated fields
 282 * maxtxpkt/maxrxpkt. rest of ksettings always updated
 283 */
 284bool
 285convert_legacy_settings_to_link_ksettings(
 286        struct ethtool_link_ksettings *link_ksettings,
 287        const struct ethtool_cmd *legacy_settings)
 288{
 289        bool retval = true;
 290
 291        memset(link_ksettings, 0, sizeof(*link_ksettings));
 292
 293        /* This is used to tell users that driver is still using these
 294         * deprecated legacy fields, and they should not use
 295         * %ETHTOOL_GLINKSETTINGS/%ETHTOOL_SLINKSETTINGS
 296         */
 297        if (legacy_settings->maxtxpkt ||
 298            legacy_settings->maxrxpkt)
 299                retval = false;
 300
 301        ethtool_convert_legacy_u32_to_link_mode(
 302                link_ksettings->link_modes.supported,
 303                legacy_settings->supported);
 304        ethtool_convert_legacy_u32_to_link_mode(
 305                link_ksettings->link_modes.advertising,
 306                legacy_settings->advertising);
 307        ethtool_convert_legacy_u32_to_link_mode(
 308                link_ksettings->link_modes.lp_advertising,
 309                legacy_settings->lp_advertising);
 310        link_ksettings->base.speed
 311                = ethtool_cmd_speed(legacy_settings);
 312        link_ksettings->base.duplex
 313                = legacy_settings->duplex;
 314        link_ksettings->base.port
 315                = legacy_settings->port;
 316        link_ksettings->base.phy_address
 317                = legacy_settings->phy_address;
 318        link_ksettings->base.autoneg
 319                = legacy_settings->autoneg;
 320        link_ksettings->base.mdio_support
 321                = legacy_settings->mdio_support;
 322        link_ksettings->base.eth_tp_mdix
 323                = legacy_settings->eth_tp_mdix;
 324        link_ksettings->base.eth_tp_mdix_ctrl
 325                = legacy_settings->eth_tp_mdix_ctrl;
 326        return retval;
 327}
 328
 329int __ethtool_get_link(struct net_device *dev)
 330{
 331        if (!dev->ethtool_ops->get_link)
 332                return -EOPNOTSUPP;
 333
 334        return netif_running(dev) && dev->ethtool_ops->get_link(dev);
 335}
 336
 337int ethtool_get_max_rxfh_channel(struct net_device *dev, u32 *max)
 338{
 339        u32 dev_size, current_max = 0;
 340        u32 *indir;
 341        int ret;
 342
 343        if (!dev->ethtool_ops->get_rxfh_indir_size ||
 344            !dev->ethtool_ops->get_rxfh)
 345                return -EOPNOTSUPP;
 346        dev_size = dev->ethtool_ops->get_rxfh_indir_size(dev);
 347        if (dev_size == 0)
 348                return -EOPNOTSUPP;
 349
 350        indir = kcalloc(dev_size, sizeof(indir[0]), GFP_USER);
 351        if (!indir)
 352                return -ENOMEM;
 353
 354        ret = dev->ethtool_ops->get_rxfh(dev, indir, NULL, NULL);
 355        if (ret)
 356                goto out;
 357
 358        while (dev_size--)
 359                current_max = max(current_max, indir[dev_size]);
 360
 361        *max = current_max;
 362
 363out:
 364        kfree(indir);
 365        return ret;
 366}
 367
 368int __ethtool_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info)
 369{
 370        const struct ethtool_ops *ops = dev->ethtool_ops;
 371        struct phy_device *phydev = dev->phydev;
 372
 373        memset(info, 0, sizeof(*info));
 374        info->cmd = ETHTOOL_GET_TS_INFO;
 375
 376        if (phy_has_tsinfo(phydev))
 377                return phy_ts_info(phydev, info);
 378        if (ops->get_ts_info)
 379                return ops->get_ts_info(dev, info);
 380
 381        info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE |
 382                                SOF_TIMESTAMPING_SOFTWARE;
 383        info->phc_index = -1;
 384
 385        return 0;
 386}
 387