Lines Matching +full:array +full:- +full:nest
1 // SPDX-License-Identifier: GPL-2.0-only
31 [ETHTOOL_STATS_ETH_PHY] = "eth-phy",
32 [ETHTOOL_STATS_ETH_MAC] = "eth-mac",
33 [ETHTOOL_STATS_ETH_CTRL] = "eth-ctrl",
96 err = ethnl_update_bitset(req_info->stat_mask, __ETHTOOL_STATS_CNT, in stats_parse_request()
104 return -EINVAL; in stats_parse_request()
110 req_info->src = src; in stats_parse_request()
121 enum ethtool_mac_stats_src src = req_info->src; in stats_prepare_data()
122 struct net_device *dev = reply_base->dev; in stats_prepare_data()
132 NL_SET_ERR_MSG_MOD(info->extack, in stats_prepare_data()
135 return -EOPNOTSUPP; in stats_prepare_data()
141 memset(&data->stats, 0xff, sizeof(data->stats)); in stats_prepare_data()
143 data->phy_stats.src = src; in stats_prepare_data()
144 data->mac_stats.src = src; in stats_prepare_data()
145 data->ctrl_stats.src = src; in stats_prepare_data()
146 data->rmon_stats.src = src; in stats_prepare_data()
148 if (test_bit(ETHTOOL_STATS_ETH_PHY, req_info->stat_mask) && in stats_prepare_data()
149 dev->ethtool_ops->get_eth_phy_stats) in stats_prepare_data()
150 dev->ethtool_ops->get_eth_phy_stats(dev, &data->phy_stats); in stats_prepare_data()
151 if (test_bit(ETHTOOL_STATS_ETH_MAC, req_info->stat_mask) && in stats_prepare_data()
152 dev->ethtool_ops->get_eth_mac_stats) in stats_prepare_data()
153 dev->ethtool_ops->get_eth_mac_stats(dev, &data->mac_stats); in stats_prepare_data()
154 if (test_bit(ETHTOOL_STATS_ETH_CTRL, req_info->stat_mask) && in stats_prepare_data()
155 dev->ethtool_ops->get_eth_ctrl_stats) in stats_prepare_data()
156 dev->ethtool_ops->get_eth_ctrl_stats(dev, &data->ctrl_stats); in stats_prepare_data()
157 if (test_bit(ETHTOOL_STATS_RMON, req_info->stat_mask) && in stats_prepare_data()
158 dev->ethtool_ops->get_rmon_stats) in stats_prepare_data()
159 dev->ethtool_ops->get_rmon_stats(dev, &data->rmon_stats, in stats_prepare_data()
160 &data->rmon_ranges); in stats_prepare_data()
175 if (test_bit(ETHTOOL_STATS_ETH_PHY, req_info->stat_mask)) { in stats_reply_size()
179 if (test_bit(ETHTOOL_STATS_ETH_MAC, req_info->stat_mask)) { in stats_reply_size()
183 if (test_bit(ETHTOOL_STATS_ETH_CTRL, req_info->stat_mask)) { in stats_reply_size()
187 if (test_bit(ETHTOOL_STATS_RMON, req_info->stat_mask)) { in stats_reply_size()
209 struct nlattr *nest; in stat_put() local
217 * of ETHTOOL_A_STATS_GRP_STAT. Since we're one nest away from the in stat_put()
218 * actual attr we're 4B off - nla_need_padding_for_64bit() & co. in stat_put()
224 return -EMSGSIZE; in stat_put()
227 nest = nla_nest_start(skb, ETHTOOL_A_STATS_GRP_STAT); in stat_put()
228 if (!nest) in stat_put()
229 return -EMSGSIZE; in stat_put()
231 ret = nla_put_u64_64bit(skb, attrtype, val, -1 /* not used */); in stat_put()
233 nla_nest_cancel(skb, nest); in stat_put()
237 nla_nest_end(skb, nest); in stat_put()
245 data->phy_stats.SymbolErrorDuringCarrier)) in stats_put_phy_stats()
246 return -EMSGSIZE; in stats_put_phy_stats()
254 data->mac_stats.FramesTransmittedOK) || in stats_put_mac_stats()
256 data->mac_stats.SingleCollisionFrames) || in stats_put_mac_stats()
258 data->mac_stats.MultipleCollisionFrames) || in stats_put_mac_stats()
260 data->mac_stats.FramesReceivedOK) || in stats_put_mac_stats()
262 data->mac_stats.FrameCheckSequenceErrors) || in stats_put_mac_stats()
264 data->mac_stats.AlignmentErrors) || in stats_put_mac_stats()
266 data->mac_stats.OctetsTransmittedOK) || in stats_put_mac_stats()
268 data->mac_stats.FramesWithDeferredXmissions) || in stats_put_mac_stats()
270 data->mac_stats.LateCollisions) || in stats_put_mac_stats()
272 data->mac_stats.FramesAbortedDueToXSColls) || in stats_put_mac_stats()
274 data->mac_stats.FramesLostDueToIntMACXmitError) || in stats_put_mac_stats()
276 data->mac_stats.CarrierSenseErrors) || in stats_put_mac_stats()
278 data->mac_stats.OctetsReceivedOK) || in stats_put_mac_stats()
280 data->mac_stats.FramesLostDueToIntMACRcvError) || in stats_put_mac_stats()
282 data->mac_stats.MulticastFramesXmittedOK) || in stats_put_mac_stats()
284 data->mac_stats.BroadcastFramesXmittedOK) || in stats_put_mac_stats()
286 data->mac_stats.FramesWithExcessiveDeferral) || in stats_put_mac_stats()
288 data->mac_stats.MulticastFramesReceivedOK) || in stats_put_mac_stats()
290 data->mac_stats.BroadcastFramesReceivedOK) || in stats_put_mac_stats()
292 data->mac_stats.InRangeLengthErrors) || in stats_put_mac_stats()
294 data->mac_stats.OutOfRangeLengthField) || in stats_put_mac_stats()
296 data->mac_stats.FrameTooLongErrors)) in stats_put_mac_stats()
297 return -EMSGSIZE; in stats_put_mac_stats()
305 data->ctrl_stats.MACControlFramesTransmitted) || in stats_put_ctrl_stats()
307 data->ctrl_stats.MACControlFramesReceived) || in stats_put_ctrl_stats()
309 data->ctrl_stats.UnsupportedOpcodesReceived)) in stats_put_ctrl_stats()
310 return -EMSGSIZE; in stats_put_ctrl_stats()
317 struct nlattr *nest; in stats_put_rmon_hist() local
329 nest = nla_nest_start(skb, attr); in stats_put_rmon_hist()
330 if (!nest) in stats_put_rmon_hist()
331 return -EMSGSIZE; in stats_put_rmon_hist()
341 nla_nest_end(skb, nest); in stats_put_rmon_hist()
347 nla_nest_cancel(skb, nest); in stats_put_rmon_hist()
348 return -EMSGSIZE; in stats_put_rmon_hist()
355 data->rmon_stats.hist, data->rmon_ranges) || in stats_put_rmon_stats()
357 data->rmon_stats.hist_tx, data->rmon_ranges)) in stats_put_rmon_stats()
358 return -EMSGSIZE; in stats_put_rmon_stats()
361 data->rmon_stats.undersize_pkts) || in stats_put_rmon_stats()
363 data->rmon_stats.oversize_pkts) || in stats_put_rmon_stats()
365 data->rmon_stats.fragments) || in stats_put_rmon_stats()
367 data->rmon_stats.jabbers)) in stats_put_rmon_stats()
368 return -EMSGSIZE; in stats_put_rmon_stats()
379 struct nlattr *nest; in stats_put_stats() local
381 nest = nla_nest_start(skb, ETHTOOL_A_STATS_GRP); in stats_put_stats()
382 if (!nest) in stats_put_stats()
383 return -EMSGSIZE; in stats_put_stats()
392 nla_nest_end(skb, nest); in stats_put_stats()
396 nla_nest_cancel(skb, nest); in stats_put_stats()
397 return -EMSGSIZE; in stats_put_stats()
408 if (nla_put_u32(skb, ETHTOOL_A_STATS_SRC, req_info->src)) in stats_fill_reply()
409 return -EMSGSIZE; in stats_fill_reply()
411 if (!ret && test_bit(ETHTOOL_STATS_ETH_PHY, req_info->stat_mask)) in stats_fill_reply()
415 if (!ret && test_bit(ETHTOOL_STATS_ETH_MAC, req_info->stat_mask)) in stats_fill_reply()
419 if (!ret && test_bit(ETHTOOL_STATS_ETH_CTRL, req_info->stat_mask)) in stats_fill_reply()
423 if (!ret && test_bit(ETHTOOL_STATS_RMON, req_info->stat_mask)) in stats_fill_reply()
453 * by treating the structures as an array of u64 statistics.
472 const struct ethtool_ops *ops = dev->ethtool_ops; in ethtool_aggregate_mac_stats()
480 ops->get_eth_mac_stats(dev, &emac); in ethtool_aggregate_mac_stats()
481 ops->get_eth_mac_stats(dev, &pmac); in ethtool_aggregate_mac_stats()
484 sizeof(mac_stats->stats), in ethtool_aggregate_mac_stats()
492 const struct ethtool_ops *ops = dev->ethtool_ops; in ethtool_aggregate_phy_stats()
500 ops->get_eth_phy_stats(dev, &emac); in ethtool_aggregate_phy_stats()
501 ops->get_eth_phy_stats(dev, &pmac); in ethtool_aggregate_phy_stats()
504 sizeof(phy_stats->stats), in ethtool_aggregate_phy_stats()
512 const struct ethtool_ops *ops = dev->ethtool_ops; in ethtool_aggregate_ctrl_stats()
520 ops->get_eth_ctrl_stats(dev, &emac); in ethtool_aggregate_ctrl_stats()
521 ops->get_eth_ctrl_stats(dev, &pmac); in ethtool_aggregate_ctrl_stats()
524 sizeof(ctrl_stats->stats), in ethtool_aggregate_ctrl_stats()
532 const struct ethtool_ops *ops = dev->ethtool_ops; in ethtool_aggregate_pause_stats()
540 ops->get_pause_stats(dev, &emac); in ethtool_aggregate_pause_stats()
541 ops->get_pause_stats(dev, &pmac); in ethtool_aggregate_pause_stats()
544 sizeof(pause_stats->stats), in ethtool_aggregate_pause_stats()
552 const struct ethtool_ops *ops = dev->ethtool_ops; in ethtool_aggregate_rmon_stats()
561 ops->get_rmon_stats(dev, &emac, &dummy); in ethtool_aggregate_rmon_stats()
562 ops->get_rmon_stats(dev, &pmac, &dummy); in ethtool_aggregate_rmon_stats()
565 sizeof(rmon_stats->stats), in ethtool_aggregate_rmon_stats()