Skip to content

Commit

Permalink
net: mvpp2: Rename mvpp2_ethtool_counters to mvpp2_ethtool_mib_counters
Browse files Browse the repository at this point in the history
Since we'll be adding support for other kind of internal counters, make
clear that the currently supported counters are the MIB counters.

Signed-off-by: Maxime Chevallier <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
minimaxwell authored and davem330 committed Jun 10, 2019
1 parent 6410c13 commit f9fa96b
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ static u64 mvpp2_read_count(struct mvpp2_port *port,
* Hence, statistics gathered from userspace with ifconfig (software) and
* ethtool (hardware) cannot be compared.
*/
static const struct mvpp2_ethtool_counter mvpp2_ethtool_regs[] = {
static const struct mvpp2_ethtool_counter mvpp2_ethtool_mib_regs[] = {
{ MVPP2_MIB_GOOD_OCTETS_RCVD, "good_octets_received", true },
{ MVPP2_MIB_BAD_OCTETS_RCVD, "bad_octets_received" },
{ MVPP2_MIB_CRC_ERRORS_SENT, "crc_errors_sent" },
Expand Down Expand Up @@ -1303,9 +1303,10 @@ static void mvpp2_ethtool_get_strings(struct net_device *netdev, u32 sset,
if (sset == ETH_SS_STATS) {
int i;

for (i = 0; i < ARRAY_SIZE(mvpp2_ethtool_regs); i++)
for (i = 0; i < ARRAY_SIZE(mvpp2_ethtool_mib_regs); i++)
strscpy(data + i * ETH_GSTRING_LEN,
mvpp2_ethtool_regs[i].string, ETH_GSTRING_LEN);
mvpp2_ethtool_mib_regs[i].string,
ETH_GSTRING_LEN);
}
}

Expand All @@ -1320,8 +1321,8 @@ static void mvpp2_gather_hw_statistics(struct work_struct *work)
mutex_lock(&port->gather_stats_lock);

pstats = port->ethtool_stats;
for (i = 0; i < ARRAY_SIZE(mvpp2_ethtool_regs); i++)
*pstats++ += mvpp2_read_count(port, &mvpp2_ethtool_regs[i]);
for (i = 0; i < ARRAY_SIZE(mvpp2_ethtool_mib_regs); i++)
*pstats++ += mvpp2_read_count(port, &mvpp2_ethtool_mib_regs[i]);

/* No need to read again the counters right after this function if it
* was called asynchronously by the user (ie. use of ethtool).
Expand All @@ -1345,14 +1346,14 @@ static void mvpp2_ethtool_get_stats(struct net_device *dev,

mutex_lock(&port->gather_stats_lock);
memcpy(data, port->ethtool_stats,
sizeof(u64) * ARRAY_SIZE(mvpp2_ethtool_regs));
sizeof(u64) * ARRAY_SIZE(mvpp2_ethtool_mib_regs));
mutex_unlock(&port->gather_stats_lock);
}

static int mvpp2_ethtool_get_sset_count(struct net_device *dev, int sset)
{
if (sset == ETH_SS_STATS)
return ARRAY_SIZE(mvpp2_ethtool_regs);
return ARRAY_SIZE(mvpp2_ethtool_mib_regs);

return -EOPNOTSUPP;
}
Expand Down Expand Up @@ -4368,8 +4369,8 @@ static int mvpp2_port_init(struct mvpp2_port *port)
goto err_free_percpu;

/* Read the GOP statistics to reset the hardware counters */
for (i = 0; i < ARRAY_SIZE(mvpp2_ethtool_regs); i++)
mvpp2_read_count(port, &mvpp2_ethtool_regs[i]);
for (i = 0; i < ARRAY_SIZE(mvpp2_ethtool_mib_regs); i++)
mvpp2_read_count(port, &mvpp2_ethtool_mib_regs[i]);

return 0;

Expand Down Expand Up @@ -5052,7 +5053,7 @@ static int mvpp2_port_probe(struct platform_device *pdev,
}

port->ethtool_stats = devm_kcalloc(&pdev->dev,
ARRAY_SIZE(mvpp2_ethtool_regs),
ARRAY_SIZE(mvpp2_ethtool_mib_regs),
sizeof(u64), GFP_KERNEL);
if (!port->ethtool_stats) {
err = -ENOMEM;
Expand Down

0 comments on commit f9fa96b

Please sign in to comment.