Skip to content

Commit 5e316a8

Browse files
LorenzoBianconidavem330
authored andcommitted
net: veth: make PAGE_POOL_STATS optional
Since veth is very likely to be enabled and there are some drivers (e.g. mlx5) where CONFIG_PAGE_POOL_STATS is optional, make CONFIG_PAGE_POOL_STATS optional for veth too in order to keep it optional instead of required. Suggested-by: Jiri Benc <jbenc@redhat.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Reviewed-by: Simon Horman <simon.horman@corigine.com> Acked-by: Jesper Dangaard Brouer <brouer@redhat.com> Acked-by: Toke Høiland-Jørgensen <toke@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 65718c4 commit 5e316a8

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

drivers/net/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,6 @@ config TUN_VNET_CROSS_LE
403403
config VETH
404404
tristate "Virtual ethernet pair device"
405405
select PAGE_POOL
406-
select PAGE_POOL_STATS
407406
help
408407
This device is a local ethernet tunnel. Devices are created in pairs.
409408
When one end receives the packet it appears on its pair and vice

drivers/net/veth.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,27 @@ static int veth_get_sset_count(struct net_device *dev, int sset)
176176
}
177177
}
178178

179+
static void veth_get_page_pool_stats(struct net_device *dev, u64 *data)
180+
{
181+
#ifdef CONFIG_PAGE_POOL_STATS
182+
struct veth_priv *priv = netdev_priv(dev);
183+
struct page_pool_stats pp_stats = {};
184+
int i;
185+
186+
for (i = 0; i < dev->real_num_rx_queues; i++) {
187+
if (!priv->rq[i].page_pool)
188+
continue;
189+
page_pool_get_stats(priv->rq[i].page_pool, &pp_stats);
190+
}
191+
page_pool_ethtool_stats_get(data, &pp_stats);
192+
#endif /* CONFIG_PAGE_POOL_STATS */
193+
}
194+
179195
static void veth_get_ethtool_stats(struct net_device *dev,
180196
struct ethtool_stats *stats, u64 *data)
181197
{
182198
struct veth_priv *rcv_priv, *priv = netdev_priv(dev);
183199
struct net_device *peer = rtnl_dereference(priv->peer);
184-
struct page_pool_stats pp_stats = {};
185200
int i, j, idx, pp_idx;
186201

187202
data[0] = peer ? peer->ifindex : 0;
@@ -225,12 +240,7 @@ static void veth_get_ethtool_stats(struct net_device *dev,
225240
}
226241

227242
page_pool_stats:
228-
for (i = 0; i < dev->real_num_rx_queues; i++) {
229-
if (!priv->rq[i].page_pool)
230-
continue;
231-
page_pool_get_stats(priv->rq[i].page_pool, &pp_stats);
232-
}
233-
page_pool_ethtool_stats_get(&data[pp_idx], &pp_stats);
243+
veth_get_page_pool_stats(dev, &data[pp_idx]);
234244
}
235245

236246
static void veth_get_channels(struct net_device *dev,

0 commit comments

Comments
 (0)