Skip to content

Commit d078d48

Browse files
minimaxwelldavem330
authored andcommitted
net: ethtool: strset: Allow querying phy stats by index
The ETH_SS_PHY_STATS command gets PHY statistics. Use the phydev pointer from the ethnl request to allow query phy stats from each PHY on the link. Signed-off-by: Maxime Chevallier <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fcc4b10 commit d078d48

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

net/ethtool/strset.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,17 +233,18 @@ static void strset_cleanup_data(struct ethnl_reply_data *reply_base)
233233
}
234234

235235
static int strset_prepare_set(struct strset_info *info, struct net_device *dev,
236-
unsigned int id, bool counts_only)
236+
struct phy_device *phydev, unsigned int id,
237+
bool counts_only)
237238
{
238239
const struct ethtool_phy_ops *phy_ops = ethtool_phy_ops;
239240
const struct ethtool_ops *ops = dev->ethtool_ops;
240241
void *strings;
241242
int count, ret;
242243

243-
if (id == ETH_SS_PHY_STATS && dev->phydev &&
244+
if (id == ETH_SS_PHY_STATS && phydev &&
244245
!ops->get_ethtool_phy_stats && phy_ops &&
245246
phy_ops->get_sset_count)
246-
ret = phy_ops->get_sset_count(dev->phydev);
247+
ret = phy_ops->get_sset_count(phydev);
247248
else if (ops->get_sset_count && ops->get_strings)
248249
ret = ops->get_sset_count(dev, id);
249250
else
@@ -258,10 +259,10 @@ static int strset_prepare_set(struct strset_info *info, struct net_device *dev,
258259
strings = kcalloc(count, ETH_GSTRING_LEN, GFP_KERNEL);
259260
if (!strings)
260261
return -ENOMEM;
261-
if (id == ETH_SS_PHY_STATS && dev->phydev &&
262+
if (id == ETH_SS_PHY_STATS && phydev &&
262263
!ops->get_ethtool_phy_stats && phy_ops &&
263264
phy_ops->get_strings)
264-
phy_ops->get_strings(dev->phydev, strings);
265+
phy_ops->get_strings(phydev, strings);
265266
else
266267
ops->get_strings(dev, id, strings);
267268
info->strings = strings;
@@ -305,8 +306,8 @@ static int strset_prepare_data(const struct ethnl_req_info *req_base,
305306
!data->sets[i].per_dev)
306307
continue;
307308

308-
ret = strset_prepare_set(&data->sets[i], dev, i,
309-
req_info->counts_only);
309+
ret = strset_prepare_set(&data->sets[i], dev, req_base->phydev,
310+
i, req_info->counts_only);
310311
if (ret < 0)
311312
goto err_ops;
312313
}

0 commit comments

Comments
 (0)