Skip to content

Commit 4fc4180

Browse files
LorenzoBianconikuba-moo
authored andcommitted
net: veth: add page_pool stats
Introduce page_pool stats support to report info about local page_pool through ethtool Tested-by: Maryam Tahhan <mtahhan@redhat.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 0ebab78 commit 4fc4180

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

drivers/net/Kconfig

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

drivers/net/veth.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ static void veth_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
157157
for (j = 0; j < VETH_TQ_STATS_LEN; j++)
158158
ethtool_sprintf(&p, "tx_queue_%u_%.18s",
159159
i, veth_tq_stats_desc[j].desc);
160+
161+
page_pool_ethtool_stats_get_strings(p);
160162
break;
161163
}
162164
}
@@ -167,7 +169,8 @@ static int veth_get_sset_count(struct net_device *dev, int sset)
167169
case ETH_SS_STATS:
168170
return ARRAY_SIZE(ethtool_stats_keys) +
169171
VETH_RQ_STATS_LEN * dev->real_num_rx_queues +
170-
VETH_TQ_STATS_LEN * dev->real_num_tx_queues;
172+
VETH_TQ_STATS_LEN * dev->real_num_tx_queues +
173+
page_pool_ethtool_stats_get_count();
171174
default:
172175
return -EOPNOTSUPP;
173176
}
@@ -178,7 +181,8 @@ static void veth_get_ethtool_stats(struct net_device *dev,
178181
{
179182
struct veth_priv *rcv_priv, *priv = netdev_priv(dev);
180183
struct net_device *peer = rtnl_dereference(priv->peer);
181-
int i, j, idx;
184+
struct page_pool_stats pp_stats = {};
185+
int i, j, idx, pp_idx;
182186

183187
data[0] = peer ? peer->ifindex : 0;
184188
idx = 1;
@@ -197,9 +201,10 @@ static void veth_get_ethtool_stats(struct net_device *dev,
197201
} while (u64_stats_fetch_retry(&rq_stats->syncp, start));
198202
idx += VETH_RQ_STATS_LEN;
199203
}
204+
pp_idx = idx;
200205

201206
if (!peer)
202-
return;
207+
goto page_pool_stats;
203208

204209
rcv_priv = netdev_priv(peer);
205210
for (i = 0; i < peer->real_num_rx_queues; i++) {
@@ -216,7 +221,16 @@ static void veth_get_ethtool_stats(struct net_device *dev,
216221
data[tx_idx + j] += *(u64 *)(base + offset);
217222
}
218223
} while (u64_stats_fetch_retry(&rq_stats->syncp, start));
224+
pp_idx = tx_idx + VETH_TQ_STATS_LEN;
225+
}
226+
227+
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);
219232
}
233+
page_pool_ethtool_stats_get(&data[pp_idx], &pp_stats);
220234
}
221235

222236
static void veth_get_channels(struct net_device *dev,

0 commit comments

Comments
 (0)