Skip to content

Commit d0caf98

Browse files
minakuba-moo
authored andcommitted
netdev: add dmabuf introspection
Add dmabuf information to page_pool stats: $ ./cli.py --spec ../netlink/specs/netdev.yaml --dump page-pool-get ... {'dmabuf': 10, 'id': 456, 'ifindex': 3, 'inflight': 1023, 'inflight-mem': 4190208}, {'dmabuf': 10, 'id': 455, 'ifindex': 3, 'inflight': 1023, 'inflight-mem': 4190208}, {'dmabuf': 10, 'id': 454, 'ifindex': 3, 'inflight': 1023, 'inflight-mem': 4190208}, {'dmabuf': 10, 'id': 453, 'ifindex': 3, 'inflight': 1023, 'inflight-mem': 4190208}, {'dmabuf': 10, 'id': 452, 'ifindex': 3, 'inflight': 1023, 'inflight-mem': 4190208}, {'dmabuf': 10, 'id': 451, 'ifindex': 3, 'inflight': 1023, 'inflight-mem': 4190208}, {'dmabuf': 10, 'id': 450, 'ifindex': 3, 'inflight': 1023, 'inflight-mem': 4190208}, {'dmabuf': 10, 'id': 449, 'ifindex': 3, 'inflight': 1023, 'inflight-mem': 4190208}, And queue stats: $ ./cli.py --spec ../netlink/specs/netdev.yaml --dump queue-get ... {'dmabuf': 10, 'id': 8, 'ifindex': 3, 'type': 'rx'}, {'dmabuf': 10, 'id': 9, 'ifindex': 3, 'type': 'rx'}, {'dmabuf': 10, 'id': 10, 'ifindex': 3, 'type': 'rx'}, {'dmabuf': 10, 'id': 11, 'ifindex': 3, 'type': 'rx'}, {'dmabuf': 10, 'id': 12, 'ifindex': 3, 'type': 'rx'}, {'dmabuf': 10, 'id': 13, 'ifindex': 3, 'type': 'rx'}, {'dmabuf': 10, 'id': 14, 'ifindex': 3, 'type': 'rx'}, {'dmabuf': 10, 'id': 15, 'ifindex': 3, 'type': 'rx'}, Suggested-by: Jakub Kicinski <[email protected]> Signed-off-by: Mina Almasry <[email protected]> Reviewed-by: Jakub Kicinski <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 85585b4 commit d0caf98

File tree

5 files changed

+26
-0
lines changed

5 files changed

+26
-0
lines changed

Documentation/netlink/specs/netdev.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ attribute-sets:
167167
"re-attached", they are just waiting to disappear.
168168
Attribute is absent if Page Pool has not been detached, and
169169
can still be used to allocate new memory.
170+
-
171+
name: dmabuf
172+
doc: ID of the dmabuf this page-pool is attached to.
173+
type: u32
170174
-
171175
name: page-pool-info
172176
subset-of: page-pool
@@ -268,6 +272,10 @@ attribute-sets:
268272
name: napi-id
269273
doc: ID of the NAPI instance which services this queue.
270274
type: u32
275+
-
276+
name: dmabuf
277+
doc: ID of the dmabuf attached to this queue, if any.
278+
type: u32
271279

272280
-
273281
name: qstats
@@ -543,6 +551,7 @@ operations:
543551
- inflight
544552
- inflight-mem
545553
- detach-time
554+
- dmabuf
546555
dump:
547556
reply: *pp-reply
548557
config-cond: page-pool
@@ -607,6 +616,7 @@ operations:
607616
- type
608617
- napi-id
609618
- ifindex
619+
- dmabuf
610620
dump:
611621
request:
612622
attributes:

include/uapi/linux/netdev.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ enum {
9393
NETDEV_A_PAGE_POOL_INFLIGHT,
9494
NETDEV_A_PAGE_POOL_INFLIGHT_MEM,
9595
NETDEV_A_PAGE_POOL_DETACH_TIME,
96+
NETDEV_A_PAGE_POOL_DMABUF,
9697

9798
__NETDEV_A_PAGE_POOL_MAX,
9899
NETDEV_A_PAGE_POOL_MAX = (__NETDEV_A_PAGE_POOL_MAX - 1)
@@ -131,6 +132,7 @@ enum {
131132
NETDEV_A_QUEUE_IFINDEX,
132133
NETDEV_A_QUEUE_TYPE,
133134
NETDEV_A_QUEUE_NAPI_ID,
135+
NETDEV_A_QUEUE_DMABUF,
134136

135137
__NETDEV_A_QUEUE_MAX,
136138
NETDEV_A_QUEUE_MAX = (__NETDEV_A_QUEUE_MAX - 1)

net/core/netdev-genl.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ static int
295295
netdev_nl_queue_fill_one(struct sk_buff *rsp, struct net_device *netdev,
296296
u32 q_idx, u32 q_type, const struct genl_info *info)
297297
{
298+
struct net_devmem_dmabuf_binding *binding;
298299
struct netdev_rx_queue *rxq;
299300
struct netdev_queue *txq;
300301
void *hdr;
@@ -314,6 +315,12 @@ netdev_nl_queue_fill_one(struct sk_buff *rsp, struct net_device *netdev,
314315
if (rxq->napi && nla_put_u32(rsp, NETDEV_A_QUEUE_NAPI_ID,
315316
rxq->napi->napi_id))
316317
goto nla_put_failure;
318+
319+
binding = rxq->mp_params.mp_priv;
320+
if (binding &&
321+
nla_put_u32(rsp, NETDEV_A_QUEUE_DMABUF, binding->id))
322+
goto nla_put_failure;
323+
317324
break;
318325
case NETDEV_QUEUE_TYPE_TX:
319326
txq = netdev_get_tx_queue(netdev, q_idx);

net/core/page_pool_user.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <net/page_pool/types.h>
1010
#include <net/sock.h>
1111

12+
#include "devmem.h"
1213
#include "page_pool_priv.h"
1314
#include "netdev-genl-gen.h"
1415

@@ -213,6 +214,7 @@ static int
213214
page_pool_nl_fill(struct sk_buff *rsp, const struct page_pool *pool,
214215
const struct genl_info *info)
215216
{
217+
struct net_devmem_dmabuf_binding *binding = pool->mp_priv;
216218
size_t inflight, refsz;
217219
void *hdr;
218220

@@ -242,6 +244,9 @@ page_pool_nl_fill(struct sk_buff *rsp, const struct page_pool *pool,
242244
pool->user.detach_time))
243245
goto err_cancel;
244246

247+
if (binding && nla_put_u32(rsp, NETDEV_A_PAGE_POOL_DMABUF, binding->id))
248+
goto err_cancel;
249+
245250
genlmsg_end(rsp, hdr);
246251

247252
return 0;

tools/include/uapi/linux/netdev.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ enum {
9393
NETDEV_A_PAGE_POOL_INFLIGHT,
9494
NETDEV_A_PAGE_POOL_INFLIGHT_MEM,
9595
NETDEV_A_PAGE_POOL_DETACH_TIME,
96+
NETDEV_A_PAGE_POOL_DMABUF,
9697

9798
__NETDEV_A_PAGE_POOL_MAX,
9899
NETDEV_A_PAGE_POOL_MAX = (__NETDEV_A_PAGE_POOL_MAX - 1)
@@ -131,6 +132,7 @@ enum {
131132
NETDEV_A_QUEUE_IFINDEX,
132133
NETDEV_A_QUEUE_TYPE,
133134
NETDEV_A_QUEUE_NAPI_ID,
135+
NETDEV_A_QUEUE_DMABUF,
134136

135137
__NETDEV_A_QUEUE_MAX,
136138
NETDEV_A_QUEUE_MAX = (__NETDEV_A_QUEUE_MAX - 1)

0 commit comments

Comments
 (0)