On Fri, Apr 16, 2021 at 12:27:39PM -0700, Jakub Kicinski wrote: > +static int stats_prepare_data(const struct ethnl_req_info *req_base, > + struct ethnl_reply_data *reply_base, > + struct genl_info *info) > +{ > + const struct stats_req_info *req_info = STATS_REQINFO(req_base); > + struct stats_reply_data *data = STATS_REPDATA(reply_base); > + struct net_device *dev = reply_base->dev; > + int ret; > + > + ret = ethnl_ops_begin(dev); > + if (ret < 0) > + return ret; > +
Nit: A comment here would be nice. Something like: 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. > + memset(&data->phy_stats, 0xff, sizeof(data->phy_stats)); > + > + 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, &data->phy_stats); > + > + ethnl_ops_complete(dev); > + return 0; > +}