Commit d0caf987 authored by Mina Almasry's avatar Mina Almasry Committed by Jakub Kicinski

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: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarMina Almasry <almasrymina@google.com>
Reviewed-by: default avatarJakub Kicinski <kuba@kernel.org>
Link: https://patch.msgid.link/20240910171458.219195-14-almasrymina@google.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 85585b4b
...@@ -167,6 +167,10 @@ attribute-sets: ...@@ -167,6 +167,10 @@ attribute-sets:
"re-attached", they are just waiting to disappear. "re-attached", they are just waiting to disappear.
Attribute is absent if Page Pool has not been detached, and Attribute is absent if Page Pool has not been detached, and
can still be used to allocate new memory. can still be used to allocate new memory.
-
name: dmabuf
doc: ID of the dmabuf this page-pool is attached to.
type: u32
- -
name: page-pool-info name: page-pool-info
subset-of: page-pool subset-of: page-pool
...@@ -268,6 +272,10 @@ attribute-sets: ...@@ -268,6 +272,10 @@ attribute-sets:
name: napi-id name: napi-id
doc: ID of the NAPI instance which services this queue. doc: ID of the NAPI instance which services this queue.
type: u32 type: u32
-
name: dmabuf
doc: ID of the dmabuf attached to this queue, if any.
type: u32
- -
name: qstats name: qstats
...@@ -543,6 +551,7 @@ operations: ...@@ -543,6 +551,7 @@ operations:
- inflight - inflight
- inflight-mem - inflight-mem
- detach-time - detach-time
- dmabuf
dump: dump:
reply: *pp-reply reply: *pp-reply
config-cond: page-pool config-cond: page-pool
...@@ -607,6 +616,7 @@ operations: ...@@ -607,6 +616,7 @@ operations:
- type - type
- napi-id - napi-id
- ifindex - ifindex
- dmabuf
dump: dump:
request: request:
attributes: attributes:
......
...@@ -93,6 +93,7 @@ enum { ...@@ -93,6 +93,7 @@ enum {
NETDEV_A_PAGE_POOL_INFLIGHT, NETDEV_A_PAGE_POOL_INFLIGHT,
NETDEV_A_PAGE_POOL_INFLIGHT_MEM, NETDEV_A_PAGE_POOL_INFLIGHT_MEM,
NETDEV_A_PAGE_POOL_DETACH_TIME, NETDEV_A_PAGE_POOL_DETACH_TIME,
NETDEV_A_PAGE_POOL_DMABUF,
__NETDEV_A_PAGE_POOL_MAX, __NETDEV_A_PAGE_POOL_MAX,
NETDEV_A_PAGE_POOL_MAX = (__NETDEV_A_PAGE_POOL_MAX - 1) NETDEV_A_PAGE_POOL_MAX = (__NETDEV_A_PAGE_POOL_MAX - 1)
...@@ -131,6 +132,7 @@ enum { ...@@ -131,6 +132,7 @@ enum {
NETDEV_A_QUEUE_IFINDEX, NETDEV_A_QUEUE_IFINDEX,
NETDEV_A_QUEUE_TYPE, NETDEV_A_QUEUE_TYPE,
NETDEV_A_QUEUE_NAPI_ID, NETDEV_A_QUEUE_NAPI_ID,
NETDEV_A_QUEUE_DMABUF,
__NETDEV_A_QUEUE_MAX, __NETDEV_A_QUEUE_MAX,
NETDEV_A_QUEUE_MAX = (__NETDEV_A_QUEUE_MAX - 1) NETDEV_A_QUEUE_MAX = (__NETDEV_A_QUEUE_MAX - 1)
......
...@@ -295,6 +295,7 @@ static int ...@@ -295,6 +295,7 @@ static int
netdev_nl_queue_fill_one(struct sk_buff *rsp, struct net_device *netdev, netdev_nl_queue_fill_one(struct sk_buff *rsp, struct net_device *netdev,
u32 q_idx, u32 q_type, const struct genl_info *info) u32 q_idx, u32 q_type, const struct genl_info *info)
{ {
struct net_devmem_dmabuf_binding *binding;
struct netdev_rx_queue *rxq; struct netdev_rx_queue *rxq;
struct netdev_queue *txq; struct netdev_queue *txq;
void *hdr; void *hdr;
...@@ -314,6 +315,12 @@ netdev_nl_queue_fill_one(struct sk_buff *rsp, struct net_device *netdev, ...@@ -314,6 +315,12 @@ netdev_nl_queue_fill_one(struct sk_buff *rsp, struct net_device *netdev,
if (rxq->napi && nla_put_u32(rsp, NETDEV_A_QUEUE_NAPI_ID, if (rxq->napi && nla_put_u32(rsp, NETDEV_A_QUEUE_NAPI_ID,
rxq->napi->napi_id)) rxq->napi->napi_id))
goto nla_put_failure; goto nla_put_failure;
binding = rxq->mp_params.mp_priv;
if (binding &&
nla_put_u32(rsp, NETDEV_A_QUEUE_DMABUF, binding->id))
goto nla_put_failure;
break; break;
case NETDEV_QUEUE_TYPE_TX: case NETDEV_QUEUE_TYPE_TX:
txq = netdev_get_tx_queue(netdev, q_idx); txq = netdev_get_tx_queue(netdev, q_idx);
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <net/page_pool/types.h> #include <net/page_pool/types.h>
#include <net/sock.h> #include <net/sock.h>
#include "devmem.h"
#include "page_pool_priv.h" #include "page_pool_priv.h"
#include "netdev-genl-gen.h" #include "netdev-genl-gen.h"
...@@ -213,6 +214,7 @@ static int ...@@ -213,6 +214,7 @@ static int
page_pool_nl_fill(struct sk_buff *rsp, const struct page_pool *pool, page_pool_nl_fill(struct sk_buff *rsp, const struct page_pool *pool,
const struct genl_info *info) const struct genl_info *info)
{ {
struct net_devmem_dmabuf_binding *binding = pool->mp_priv;
size_t inflight, refsz; size_t inflight, refsz;
void *hdr; void *hdr;
...@@ -242,6 +244,9 @@ page_pool_nl_fill(struct sk_buff *rsp, const struct page_pool *pool, ...@@ -242,6 +244,9 @@ page_pool_nl_fill(struct sk_buff *rsp, const struct page_pool *pool,
pool->user.detach_time)) pool->user.detach_time))
goto err_cancel; goto err_cancel;
if (binding && nla_put_u32(rsp, NETDEV_A_PAGE_POOL_DMABUF, binding->id))
goto err_cancel;
genlmsg_end(rsp, hdr); genlmsg_end(rsp, hdr);
return 0; return 0;
......
...@@ -93,6 +93,7 @@ enum { ...@@ -93,6 +93,7 @@ enum {
NETDEV_A_PAGE_POOL_INFLIGHT, NETDEV_A_PAGE_POOL_INFLIGHT,
NETDEV_A_PAGE_POOL_INFLIGHT_MEM, NETDEV_A_PAGE_POOL_INFLIGHT_MEM,
NETDEV_A_PAGE_POOL_DETACH_TIME, NETDEV_A_PAGE_POOL_DETACH_TIME,
NETDEV_A_PAGE_POOL_DMABUF,
__NETDEV_A_PAGE_POOL_MAX, __NETDEV_A_PAGE_POOL_MAX,
NETDEV_A_PAGE_POOL_MAX = (__NETDEV_A_PAGE_POOL_MAX - 1) NETDEV_A_PAGE_POOL_MAX = (__NETDEV_A_PAGE_POOL_MAX - 1)
...@@ -131,6 +132,7 @@ enum { ...@@ -131,6 +132,7 @@ enum {
NETDEV_A_QUEUE_IFINDEX, NETDEV_A_QUEUE_IFINDEX,
NETDEV_A_QUEUE_TYPE, NETDEV_A_QUEUE_TYPE,
NETDEV_A_QUEUE_NAPI_ID, NETDEV_A_QUEUE_NAPI_ID,
NETDEV_A_QUEUE_DMABUF,
__NETDEV_A_QUEUE_MAX, __NETDEV_A_QUEUE_MAX,
NETDEV_A_QUEUE_MAX = (__NETDEV_A_QUEUE_MAX - 1) NETDEV_A_QUEUE_MAX = (__NETDEV_A_QUEUE_MAX - 1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment