Commit b3fc7922 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by David S. Miller
Browse files

net: mvneta: add support for page_pool_get_stats



Introduce support for the page_pool stats API into mvneta driver.
Report page_pool stats through ethtool.

Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f3c5264f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ config MVNETA
	select MVMDIO
	select PHYLINK
	select PAGE_POOL
	select PAGE_POOL_STATS
	help
	  This driver supports the network interface units in the
	  Marvell ARMADA XP, ARMADA 370, ARMADA 38x and
+19 −1
Original line number Diff line number Diff line
@@ -4735,6 +4735,9 @@ static void mvneta_ethtool_get_strings(struct net_device *netdev, u32 sset,
		for (i = 0; i < ARRAY_SIZE(mvneta_statistics); i++)
			memcpy(data + i * ETH_GSTRING_LEN,
			       mvneta_statistics[i].name, ETH_GSTRING_LEN);

		data += ETH_GSTRING_LEN * ARRAY_SIZE(mvneta_statistics);
		page_pool_ethtool_stats_get_strings(data);
	}
}

@@ -4847,6 +4850,17 @@ static void mvneta_ethtool_update_stats(struct mvneta_port *pp)
	}
}

static void mvneta_ethtool_pp_stats(struct mvneta_port *pp, u64 *data)
{
	struct page_pool_stats stats = {};
	int i;

	for (i = 0; i < rxq_number; i++)
		page_pool_get_stats(pp->rxqs[i].page_pool, &stats);

	page_pool_ethtool_stats_get(data, &stats);
}

static void mvneta_ethtool_get_stats(struct net_device *dev,
				     struct ethtool_stats *stats, u64 *data)
{
@@ -4857,12 +4871,16 @@ static void mvneta_ethtool_get_stats(struct net_device *dev,

	for (i = 0; i < ARRAY_SIZE(mvneta_statistics); i++)
		*data++ = pp->ethtool_stats[i];

	mvneta_ethtool_pp_stats(pp, data);
}

static int mvneta_ethtool_get_sset_count(struct net_device *dev, int sset)
{
	if (sset == ETH_SS_STATS)
		return ARRAY_SIZE(mvneta_statistics);
		return ARRAY_SIZE(mvneta_statistics) +
		       page_pool_ethtool_stats_get_count();

	return -EOPNOTSUPP;
}