Commit 04692c90 authored by Vladimir Oltean's avatar Vladimir Oltean Committed by David S. Miller

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: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 37000004
...@@ -311,6 +311,7 @@ static inline void ethtool_stats_init(u64 *stats, unsigned int n) ...@@ -311,6 +311,7 @@ static inline void ethtool_stats_init(u64 *stats, unsigned int n)
* via a more targeted API. * via a more targeted API.
*/ */
struct ethtool_eth_mac_stats { struct ethtool_eth_mac_stats {
enum ethtool_mac_stats_src src;
u64 FramesTransmittedOK; u64 FramesTransmittedOK;
u64 SingleCollisionFrames; u64 SingleCollisionFrames;
u64 MultipleCollisionFrames; u64 MultipleCollisionFrames;
...@@ -339,6 +340,7 @@ struct ethtool_eth_mac_stats { ...@@ -339,6 +340,7 @@ struct ethtool_eth_mac_stats {
* via a more targeted API. * via a more targeted API.
*/ */
struct ethtool_eth_phy_stats { struct ethtool_eth_phy_stats {
enum ethtool_mac_stats_src src;
u64 SymbolErrorDuringCarrier; u64 SymbolErrorDuringCarrier;
}; };
...@@ -346,6 +348,7 @@ struct ethtool_eth_phy_stats { ...@@ -346,6 +348,7 @@ struct ethtool_eth_phy_stats {
* via a more targeted API. * via a more targeted API.
*/ */
struct ethtool_eth_ctrl_stats { struct ethtool_eth_ctrl_stats {
enum ethtool_mac_stats_src src;
u64 MACControlFramesTransmitted; u64 MACControlFramesTransmitted;
u64 MACControlFramesReceived; u64 MACControlFramesReceived;
u64 UnsupportedOpcodesReceived; u64 UnsupportedOpcodesReceived;
...@@ -353,6 +356,8 @@ struct ethtool_eth_ctrl_stats { ...@@ -353,6 +356,8 @@ struct ethtool_eth_ctrl_stats {
/** /**
* struct ethtool_pause_stats - statistics for IEEE 802.3x pause frames * struct ethtool_pause_stats - statistics for IEEE 802.3x pause frames
* @src: input field denoting whether stats should be queried from the eMAC or
* pMAC (if the MM layer is supported). To be ignored otherwise.
* @tx_pause_frames: transmitted pause frame count. Reported to user space * @tx_pause_frames: transmitted pause frame count. Reported to user space
* as %ETHTOOL_A_PAUSE_STAT_TX_FRAMES. * as %ETHTOOL_A_PAUSE_STAT_TX_FRAMES.
* *
...@@ -366,6 +371,7 @@ struct ethtool_eth_ctrl_stats { ...@@ -366,6 +371,7 @@ struct ethtool_eth_ctrl_stats {
* from the standard. * from the standard.
*/ */
struct ethtool_pause_stats { struct ethtool_pause_stats {
enum ethtool_mac_stats_src src;
u64 tx_pause_frames; u64 tx_pause_frames;
u64 rx_pause_frames; u64 rx_pause_frames;
}; };
...@@ -417,6 +423,8 @@ struct ethtool_rmon_hist_range { ...@@ -417,6 +423,8 @@ struct ethtool_rmon_hist_range {
/** /**
* struct ethtool_rmon_stats - selected RMON (RFC 2819) statistics * struct ethtool_rmon_stats - selected RMON (RFC 2819) statistics
* @src: input field denoting whether stats should be queried from the eMAC or
* pMAC (if the MM layer is supported). To be ignored otherwise.
* @undersize_pkts: Equivalent to `etherStatsUndersizePkts` from the RFC. * @undersize_pkts: Equivalent to `etherStatsUndersizePkts` from the RFC.
* @oversize_pkts: Equivalent to `etherStatsOversizePkts` from the RFC. * @oversize_pkts: Equivalent to `etherStatsOversizePkts` from the RFC.
* @fragments: Equivalent to `etherStatsFragments` from the RFC. * @fragments: Equivalent to `etherStatsFragments` from the RFC.
...@@ -432,6 +440,7 @@ struct ethtool_rmon_hist_range { ...@@ -432,6 +440,7 @@ struct ethtool_rmon_hist_range {
* ranges is left to the driver. * ranges is left to the driver.
*/ */
struct ethtool_rmon_stats { struct ethtool_rmon_stats {
enum ethtool_mac_stats_src src;
u64 undersize_pkts; u64 undersize_pkts;
u64 oversize_pkts; u64 oversize_pkts;
u64 fragments; u64 fragments;
......
...@@ -711,6 +711,24 @@ enum ethtool_stringset { ...@@ -711,6 +711,24 @@ enum ethtool_stringset {
ETH_SS_COUNT ETH_SS_COUNT
}; };
/**
* enum ethtool_mac_stats_src - source of ethtool MAC statistics
* @ETHTOOL_MAC_STATS_SRC_AGGREGATE:
* if device supports a MAC merge layer, this retrieves the aggregate
* statistics of the eMAC and pMAC. Otherwise, it retrieves just the
* statistics of the single (express) MAC.
* @ETHTOOL_MAC_STATS_SRC_EMAC:
* if device supports a MM layer, this retrieves the eMAC statistics.
* Otherwise, it retrieves the statistics of the single (express) MAC.
* @ETHTOOL_MAC_STATS_SRC_PMAC:
* if device supports a MM layer, this retrieves the pMAC statistics.
*/
enum ethtool_mac_stats_src {
ETHTOOL_MAC_STATS_SRC_AGGREGATE,
ETHTOOL_MAC_STATS_SRC_EMAC,
ETHTOOL_MAC_STATS_SRC_PMAC,
};
/** /**
* enum ethtool_module_power_mode_policy - plug-in module power mode policy * enum ethtool_module_power_mode_policy - plug-in module power mode policy
* @ETHTOOL_MODULE_POWER_MODE_POLICY_HIGH: Module is always in high power mode. * @ETHTOOL_MODULE_POWER_MODE_POLICY_HIGH: Module is always in high power mode.
......
...@@ -428,6 +428,7 @@ enum { ...@@ -428,6 +428,7 @@ enum {
ETHTOOL_A_PAUSE_RX, /* u8 */ ETHTOOL_A_PAUSE_RX, /* u8 */
ETHTOOL_A_PAUSE_TX, /* u8 */ ETHTOOL_A_PAUSE_TX, /* u8 */
ETHTOOL_A_PAUSE_STATS, /* nest - _PAUSE_STAT_* */ ETHTOOL_A_PAUSE_STATS, /* nest - _PAUSE_STAT_* */
ETHTOOL_A_PAUSE_STATS_SRC, /* u32 */
/* add new constants above here */ /* add new constants above here */
__ETHTOOL_A_PAUSE_CNT, __ETHTOOL_A_PAUSE_CNT,
...@@ -744,6 +745,8 @@ enum { ...@@ -744,6 +745,8 @@ enum {
ETHTOOL_A_STATS_GRP, /* nest - _A_STATS_GRP_* */ ETHTOOL_A_STATS_GRP, /* nest - _A_STATS_GRP_* */
ETHTOOL_A_STATS_SRC, /* u32 */
/* add new constants above here */ /* add new constants above here */
__ETHTOOL_A_STATS_CNT, __ETHTOOL_A_STATS_CNT,
ETHTOOL_A_STATS_MAX = (__ETHTOOL_A_STATS_CNT - 1) ETHTOOL_A_STATS_MAX = (__ETHTOOL_A_STATS_CNT - 1)
......
...@@ -54,4 +54,6 @@ int ethtool_get_module_info_call(struct net_device *dev, ...@@ -54,4 +54,6 @@ int ethtool_get_module_info_call(struct net_device *dev,
int ethtool_get_module_eeprom_call(struct net_device *dev, int ethtool_get_module_eeprom_call(struct net_device *dev,
struct ethtool_eeprom *ee, u8 *data); struct ethtool_eeprom *ee, u8 *data);
bool __ethtool_dev_mm_supported(struct net_device *dev);
#endif /* _ETHTOOL_COMMON_H */ #endif /* _ETHTOOL_COMMON_H */
...@@ -253,3 +253,19 @@ int ethnl_set_mm(struct sk_buff *skb, struct genl_info *info) ...@@ -253,3 +253,19 @@ int ethnl_set_mm(struct sk_buff *skb, struct genl_info *info)
ethnl_parse_header_dev_put(&req_info); ethnl_parse_header_dev_put(&req_info);
return ret; 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;
}
...@@ -373,7 +373,7 @@ extern const struct nla_policy ethnl_channels_get_policy[ETHTOOL_A_CHANNELS_HEAD ...@@ -373,7 +373,7 @@ extern const struct nla_policy ethnl_channels_get_policy[ETHTOOL_A_CHANNELS_HEAD
extern const struct nla_policy ethnl_channels_set_policy[ETHTOOL_A_CHANNELS_COMBINED_COUNT + 1]; extern const struct nla_policy ethnl_channels_set_policy[ETHTOOL_A_CHANNELS_COMBINED_COUNT + 1];
extern const struct nla_policy ethnl_coalesce_get_policy[ETHTOOL_A_COALESCE_HEADER + 1]; extern const struct nla_policy ethnl_coalesce_get_policy[ETHTOOL_A_COALESCE_HEADER + 1];
extern const struct nla_policy ethnl_coalesce_set_policy[ETHTOOL_A_COALESCE_MAX + 1]; extern const struct nla_policy ethnl_coalesce_set_policy[ETHTOOL_A_COALESCE_MAX + 1];
extern const struct nla_policy ethnl_pause_get_policy[ETHTOOL_A_PAUSE_HEADER + 1]; extern const struct nla_policy ethnl_pause_get_policy[ETHTOOL_A_PAUSE_STATS_SRC + 1];
extern const struct nla_policy ethnl_pause_set_policy[ETHTOOL_A_PAUSE_TX + 1]; extern const struct nla_policy ethnl_pause_set_policy[ETHTOOL_A_PAUSE_TX + 1];
extern const struct nla_policy ethnl_eee_get_policy[ETHTOOL_A_EEE_HEADER + 1]; extern const struct nla_policy ethnl_eee_get_policy[ETHTOOL_A_EEE_HEADER + 1];
extern const struct nla_policy ethnl_eee_set_policy[ETHTOOL_A_EEE_TX_LPI_TIMER + 1]; extern const struct nla_policy ethnl_eee_set_policy[ETHTOOL_A_EEE_TX_LPI_TIMER + 1];
...@@ -384,7 +384,7 @@ extern const struct nla_policy ethnl_tunnel_info_get_policy[ETHTOOL_A_TUNNEL_INF ...@@ -384,7 +384,7 @@ extern const struct nla_policy ethnl_tunnel_info_get_policy[ETHTOOL_A_TUNNEL_INF
extern const struct nla_policy ethnl_fec_get_policy[ETHTOOL_A_FEC_HEADER + 1]; extern const struct nla_policy ethnl_fec_get_policy[ETHTOOL_A_FEC_HEADER + 1];
extern const struct nla_policy ethnl_fec_set_policy[ETHTOOL_A_FEC_AUTO + 1]; extern const struct nla_policy ethnl_fec_set_policy[ETHTOOL_A_FEC_AUTO + 1];
extern const struct nla_policy ethnl_module_eeprom_get_policy[ETHTOOL_A_MODULE_EEPROM_I2C_ADDRESS + 1]; extern const struct nla_policy ethnl_module_eeprom_get_policy[ETHTOOL_A_MODULE_EEPROM_I2C_ADDRESS + 1];
extern const struct nla_policy ethnl_stats_get_policy[ETHTOOL_A_STATS_GROUPS + 1]; extern const struct nla_policy ethnl_stats_get_policy[ETHTOOL_A_STATS_SRC + 1];
extern const struct nla_policy ethnl_phc_vclocks_get_policy[ETHTOOL_A_PHC_VCLOCKS_HEADER + 1]; extern const struct nla_policy ethnl_phc_vclocks_get_policy[ETHTOOL_A_PHC_VCLOCKS_HEADER + 1];
extern const struct nla_policy ethnl_module_get_policy[ETHTOOL_A_MODULE_HEADER + 1]; extern const struct nla_policy ethnl_module_get_policy[ETHTOOL_A_MODULE_HEADER + 1];
extern const struct nla_policy ethnl_module_set_policy[ETHTOOL_A_MODULE_POWER_MODE_POLICY + 1]; extern const struct nla_policy ethnl_module_set_policy[ETHTOOL_A_MODULE_POWER_MODE_POLICY + 1];
......
...@@ -5,8 +5,12 @@ ...@@ -5,8 +5,12 @@
struct pause_req_info { struct pause_req_info {
struct ethnl_req_info base; struct ethnl_req_info base;
enum ethtool_mac_stats_src src;
}; };
#define PAUSE_REQINFO(__req_base) \
container_of(__req_base, struct pause_req_info, base)
struct pause_reply_data { struct pause_reply_data {
struct ethnl_reply_data base; struct ethnl_reply_data base;
struct ethtool_pauseparam pauseparam; struct ethtool_pauseparam pauseparam;
...@@ -19,13 +23,40 @@ struct pause_reply_data { ...@@ -19,13 +23,40 @@ struct pause_reply_data {
const struct nla_policy ethnl_pause_get_policy[] = { const struct nla_policy ethnl_pause_get_policy[] = {
[ETHTOOL_A_PAUSE_HEADER] = [ETHTOOL_A_PAUSE_HEADER] =
NLA_POLICY_NESTED(ethnl_header_policy_stats), NLA_POLICY_NESTED(ethnl_header_policy_stats),
[ETHTOOL_A_PAUSE_STATS_SRC] =
NLA_POLICY_MAX(NLA_U32, ETHTOOL_MAC_STATS_SRC_PMAC),
}; };
static int pause_parse_request(struct ethnl_req_info *req_base,
struct nlattr **tb,
struct netlink_ext_ack *extack)
{
enum ethtool_mac_stats_src src = ETHTOOL_MAC_STATS_SRC_AGGREGATE;
struct pause_req_info *req_info = PAUSE_REQINFO(req_base);
if (tb[ETHTOOL_A_PAUSE_STATS_SRC]) {
if (!(req_base->flags & ETHTOOL_FLAG_STATS)) {
NL_SET_ERR_MSG_MOD(extack,
"ETHTOOL_FLAG_STATS must be set when requesting a source of stats");
return -EINVAL;
}
src = nla_get_u32(tb[ETHTOOL_A_PAUSE_STATS_SRC]);
}
req_info->src = src;
return 0;
}
static int pause_prepare_data(const struct ethnl_req_info *req_base, static int pause_prepare_data(const struct ethnl_req_info *req_base,
struct ethnl_reply_data *reply_base, struct ethnl_reply_data *reply_base,
struct genl_info *info) struct genl_info *info)
{ {
const struct pause_req_info *req_info = PAUSE_REQINFO(req_base);
struct pause_reply_data *data = PAUSE_REPDATA(reply_base); struct pause_reply_data *data = PAUSE_REPDATA(reply_base);
enum ethtool_mac_stats_src src = req_info->src;
struct netlink_ext_ack *extack = info->extack;
struct net_device *dev = reply_base->dev; struct net_device *dev = reply_base->dev;
int ret; int ret;
...@@ -34,14 +65,26 @@ static int pause_prepare_data(const struct ethnl_req_info *req_base, ...@@ -34,14 +65,26 @@ static int pause_prepare_data(const struct ethnl_req_info *req_base,
ethtool_stats_init((u64 *)&data->pausestat, ethtool_stats_init((u64 *)&data->pausestat,
sizeof(data->pausestat) / 8); sizeof(data->pausestat) / 8);
data->pausestat.src = src;
ret = ethnl_ops_begin(dev); ret = ethnl_ops_begin(dev);
if (ret < 0) if (ret < 0)
return ret; return ret;
if ((src == ETHTOOL_MAC_STATS_SRC_EMAC ||
src == ETHTOOL_MAC_STATS_SRC_PMAC) &&
!__ethtool_dev_mm_supported(dev)) {
NL_SET_ERR_MSG_MOD(extack,
"Device does not support MAC merge layer");
ethnl_ops_complete(dev);
return -EOPNOTSUPP;
}
dev->ethtool_ops->get_pauseparam(dev, &data->pauseparam); dev->ethtool_ops->get_pauseparam(dev, &data->pauseparam);
if (req_base->flags & ETHTOOL_FLAG_STATS && if (req_base->flags & ETHTOOL_FLAG_STATS &&
dev->ethtool_ops->get_pause_stats) dev->ethtool_ops->get_pause_stats)
dev->ethtool_ops->get_pause_stats(dev, &data->pausestat); dev->ethtool_ops->get_pause_stats(dev, &data->pausestat);
ethnl_ops_complete(dev); ethnl_ops_complete(dev);
return 0; return 0;
...@@ -56,6 +99,7 @@ static int pause_reply_size(const struct ethnl_req_info *req_base, ...@@ -56,6 +99,7 @@ static int pause_reply_size(const struct ethnl_req_info *req_base,
if (req_base->flags & ETHTOOL_FLAG_STATS) if (req_base->flags & ETHTOOL_FLAG_STATS)
n += nla_total_size(0) + /* _PAUSE_STATS */ n += nla_total_size(0) + /* _PAUSE_STATS */
nla_total_size(sizeof(u32)) + /* _PAUSE_STATS_SRC */
nla_total_size_64bit(sizeof(u64)) * ETHTOOL_PAUSE_STAT_CNT; nla_total_size_64bit(sizeof(u64)) * ETHTOOL_PAUSE_STAT_CNT;
return n; return n;
} }
...@@ -77,6 +121,9 @@ static int pause_put_stats(struct sk_buff *skb, ...@@ -77,6 +121,9 @@ static int pause_put_stats(struct sk_buff *skb,
const u16 pad = ETHTOOL_A_PAUSE_STAT_PAD; const u16 pad = ETHTOOL_A_PAUSE_STAT_PAD;
struct nlattr *nest; struct nlattr *nest;
if (nla_put_u32(skb, ETHTOOL_A_PAUSE_STATS_SRC, pause_stats->src))
return -EMSGSIZE;
nest = nla_nest_start(skb, ETHTOOL_A_PAUSE_STATS); nest = nla_nest_start(skb, ETHTOOL_A_PAUSE_STATS);
if (!nest) if (!nest)
return -EMSGSIZE; return -EMSGSIZE;
...@@ -121,6 +168,7 @@ const struct ethnl_request_ops ethnl_pause_request_ops = { ...@@ -121,6 +168,7 @@ const struct ethnl_request_ops ethnl_pause_request_ops = {
.req_info_size = sizeof(struct pause_req_info), .req_info_size = sizeof(struct pause_req_info),
.reply_data_size = sizeof(struct pause_reply_data), .reply_data_size = sizeof(struct pause_reply_data),
.parse_request = pause_parse_request,
.prepare_data = pause_prepare_data, .prepare_data = pause_prepare_data,
.reply_size = pause_reply_size, .reply_size = pause_reply_size,
.fill_reply = pause_fill_reply, .fill_reply = pause_fill_reply,
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
struct stats_req_info { struct stats_req_info {
struct ethnl_req_info base; struct ethnl_req_info base;
DECLARE_BITMAP(stat_mask, __ETHTOOL_STATS_CNT); DECLARE_BITMAP(stat_mask, __ETHTOOL_STATS_CNT);
enum ethtool_mac_stats_src src;
}; };
#define STATS_REQINFO(__req_base) \ #define STATS_REQINFO(__req_base) \
...@@ -75,16 +76,19 @@ const char stats_rmon_names[__ETHTOOL_A_STATS_RMON_CNT][ETH_GSTRING_LEN] = { ...@@ -75,16 +76,19 @@ const char stats_rmon_names[__ETHTOOL_A_STATS_RMON_CNT][ETH_GSTRING_LEN] = {
[ETHTOOL_A_STATS_RMON_JABBER] = "etherStatsJabbers", [ETHTOOL_A_STATS_RMON_JABBER] = "etherStatsJabbers",
}; };
const struct nla_policy ethnl_stats_get_policy[ETHTOOL_A_STATS_GROUPS + 1] = { const struct nla_policy ethnl_stats_get_policy[ETHTOOL_A_STATS_SRC + 1] = {
[ETHTOOL_A_STATS_HEADER] = [ETHTOOL_A_STATS_HEADER] =
NLA_POLICY_NESTED(ethnl_header_policy), NLA_POLICY_NESTED(ethnl_header_policy),
[ETHTOOL_A_STATS_GROUPS] = { .type = NLA_NESTED }, [ETHTOOL_A_STATS_GROUPS] = { .type = NLA_NESTED },
[ETHTOOL_A_STATS_SRC] =
NLA_POLICY_MAX(NLA_U32, ETHTOOL_MAC_STATS_SRC_PMAC),
}; };
static int stats_parse_request(struct ethnl_req_info *req_base, static int stats_parse_request(struct ethnl_req_info *req_base,
struct nlattr **tb, struct nlattr **tb,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
enum ethtool_mac_stats_src src = ETHTOOL_MAC_STATS_SRC_AGGREGATE;
struct stats_req_info *req_info = STATS_REQINFO(req_base); struct stats_req_info *req_info = STATS_REQINFO(req_base);
bool mod = false; bool mod = false;
int err; int err;
...@@ -100,6 +104,11 @@ static int stats_parse_request(struct ethnl_req_info *req_base, ...@@ -100,6 +104,11 @@ static int stats_parse_request(struct ethnl_req_info *req_base,
return -EINVAL; return -EINVAL;
} }
if (tb[ETHTOOL_A_STATS_SRC])
src = nla_get_u32(tb[ETHTOOL_A_STATS_SRC]);
req_info->src = src;
return 0; return 0;
} }
...@@ -109,6 +118,8 @@ static int stats_prepare_data(const struct ethnl_req_info *req_base, ...@@ -109,6 +118,8 @@ static int stats_prepare_data(const struct ethnl_req_info *req_base,
{ {
const struct stats_req_info *req_info = STATS_REQINFO(req_base); const struct stats_req_info *req_info = STATS_REQINFO(req_base);
struct stats_reply_data *data = STATS_REPDATA(reply_base); struct stats_reply_data *data = STATS_REPDATA(reply_base);
enum ethtool_mac_stats_src src = req_info->src;
struct netlink_ext_ack *extack = info->extack;
struct net_device *dev = reply_base->dev; struct net_device *dev = reply_base->dev;
int ret; int ret;
...@@ -116,11 +127,25 @@ static int stats_prepare_data(const struct ethnl_req_info *req_base, ...@@ -116,11 +127,25 @@ static int stats_prepare_data(const struct ethnl_req_info *req_base,
if (ret < 0) if (ret < 0)
return ret; return ret;
if ((src == ETHTOOL_MAC_STATS_SRC_EMAC ||
src == ETHTOOL_MAC_STATS_SRC_PMAC) &&
!__ethtool_dev_mm_supported(dev)) {
NL_SET_ERR_MSG_MOD(extack,
"Device does not support MAC merge layer");
ethnl_ops_complete(dev);
return -EOPNOTSUPP;
}
/* Mark all stats as unset (see ETHTOOL_STAT_NOT_SET) to prevent them /* Mark all stats as unset (see ETHTOOL_STAT_NOT_SET) to prevent them
* from being reported to user space in case driver did not set them. * from being reported to user space in case driver did not set them.
*/ */
memset(&data->stats, 0xff, sizeof(data->stats)); memset(&data->stats, 0xff, sizeof(data->stats));
data->phy_stats.src = src;
data->mac_stats.src = src;
data->ctrl_stats.src = src;
data->rmon_stats.src = src;
if (test_bit(ETHTOOL_STATS_ETH_PHY, req_info->stat_mask) && if (test_bit(ETHTOOL_STATS_ETH_PHY, req_info->stat_mask) &&
dev->ethtool_ops->get_eth_phy_stats) dev->ethtool_ops->get_eth_phy_stats)
dev->ethtool_ops->get_eth_phy_stats(dev, &data->phy_stats); dev->ethtool_ops->get_eth_phy_stats(dev, &data->phy_stats);
...@@ -146,6 +171,8 @@ static int stats_reply_size(const struct ethnl_req_info *req_base, ...@@ -146,6 +171,8 @@ static int stats_reply_size(const struct ethnl_req_info *req_base,
unsigned int n_grps = 0, n_stats = 0; unsigned int n_grps = 0, n_stats = 0;
int len = 0; int len = 0;
len += nla_total_size(sizeof(u32)); /* _STATS_SRC */
if (test_bit(ETHTOOL_STATS_ETH_PHY, req_info->stat_mask)) { if (test_bit(ETHTOOL_STATS_ETH_PHY, req_info->stat_mask)) {
n_stats += sizeof(struct ethtool_eth_phy_stats) / sizeof(u64); n_stats += sizeof(struct ethtool_eth_phy_stats) / sizeof(u64);
n_grps++; n_grps++;
...@@ -379,6 +406,9 @@ static int stats_fill_reply(struct sk_buff *skb, ...@@ -379,6 +406,9 @@ static int stats_fill_reply(struct sk_buff *skb,
const struct stats_reply_data *data = STATS_REPDATA(reply_base); const struct stats_reply_data *data = STATS_REPDATA(reply_base);
int ret = 0; int ret = 0;
if (nla_put_u32(skb, ETHTOOL_A_STATS_SRC, req_info->src))
return -EMSGSIZE;
if (!ret && test_bit(ETHTOOL_STATS_ETH_PHY, req_info->stat_mask)) if (!ret && test_bit(ETHTOOL_STATS_ETH_PHY, req_info->stat_mask))
ret = stats_put_stats(skb, data, ETHTOOL_STATS_ETH_PHY, ret = stats_put_stats(skb, data, ETHTOOL_STATS_ETH_PHY,
ETH_SS_STATS_ETH_PHY, ETH_SS_STATS_ETH_PHY,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment