diff options
author | Vladimir Oltean <vladimir.oltean@nxp.com> | 2023-01-19 13:26:56 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2023-01-23 13:44:18 +0100 |
commit | 04692c9020b76939715d6f2b4ff84d832246e0fc (patch) | |
tree | d21fa306edcdbe9e7d31d8c9cb4f8e53d84a8e77 /net/ethtool/mm.c | |
parent | docs: ethtool-netlink: document interface for MAC Merge layer (diff) | |
download | linux-04692c9020b76939715d6f2b4ff84d832246e0fc.tar.xz linux-04692c9020b76939715d6f2b4ff84d832246e0fc.zip |
net: ethtool: netlink: retrieve stats from multiple sources (eMAC, pMAC)
IEEE 802.3-2018 clause 99 defines a MAC Merge sublayer which contains an
Express MAC and a Preemptible MAC. Both MACs are hidden to higher and
lower layers and visible as a single MAC (packet classification to eMAC
or pMAC on TX is done based on priority; classification on RX is done
based on SFD).
For devices which support a MAC Merge sublayer, it is desirable to
retrieve individual packet counters from the eMAC and the pMAC, as well
as aggregate statistics (their sum).
Introduce a new ETHTOOL_A_STATS_SRC attribute which is part of the
policy of ETHTOOL_MSG_STATS_GET and, and an ETHTOOL_A_PAUSE_STATS_SRC
which is part of the policy of ETHTOOL_MSG_PAUSE_GET (accepted when
ETHTOOL_FLAG_STATS is set in the common ethtool header). Both of these
take values from enum ethtool_mac_stats_src, defaulting to "aggregate"
in the absence of the attribute.
Existing drivers do not need to pay attention to this enum which was
added to all driver-facing structures, just the ones which report the
MAC merge layer as supported.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ethtool/mm.c')
-rw-r--r-- | net/ethtool/mm.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/net/ethtool/mm.c b/net/ethtool/mm.c index 76b209ad53d2..809d196665c6 100644 --- a/net/ethtool/mm.c +++ b/net/ethtool/mm.c @@ -253,3 +253,19 @@ out_dev_put: ethnl_parse_header_dev_put(&req_info); return ret; } + +/* Returns whether a given device supports the MAC merge layer + * (has an eMAC and a pMAC). Must be called under rtnl_lock() and + * ethnl_ops_begin(). + */ +bool __ethtool_dev_mm_supported(struct net_device *dev) +{ + const struct ethtool_ops *ops = dev->ethtool_ops; + struct ethtool_mm_state state = {}; + int ret = -EOPNOTSUPP; + + if (ops && ops->get_mm) + ret = ops->get_mm(dev, &state); + + return !!ret; +} |