netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Amit Cohen <amcohen@nvidia.com>
To: <kuba@kernel.org>
Cc: <davem@davemloft.net>, <edumazet@google.com>, <pabeni@redhat.com>,
	<hawk@kernel.org>, <idosch@nvidia.com>, <petrm@nvidia.com>,
	<mlxsw@nvidia.com>, <netdev@vger.kernel.org>,
	Amit Cohen <amcohen@nvidia.com>
Subject: [PATCH RFC net-next 3/4] mlxsw: pci: Allow get page pool info/stats via netlink
Date: Tue, 25 Jun 2024 15:08:06 +0300	[thread overview]
Message-ID: <20240625120807.1165581-4-amcohen@nvidia.com> (raw)
In-Reply-To: <20240625120807.1165581-1-amcohen@nvidia.com>

Spectrum ASICs do not have queue per netdevice, so mlxsw driver does not
have NAPI per netdevice, instead "dummy" netdevice is used. Lately, the
driver started using page pool for buffers allocations, each Rx queue (RDQ)
uses a dedicated page pool.

To allow user to query page pool info and statistics, page pool should
be attached to netdevice. Setting "dummy" netdevice as part of page pool
parameters allows querying info about specific pool.

Without this patch, "do" commands fail:
$ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml \
	--do page-pool-get --json '{"id" : "20"}' --output-json
Netlink error: No such file or directory
nl_len = 36 (20) nl_flags = 0x100 nl_type = 2
	error: -2

With this patch, user can query info of specific pool:
$ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml \
	--do page-pool-get --json '{"id" : "20"}' --output-json
{"id": 20, "ifindex": 0, "napi-id": 108, "inflight": 3072, "inflight-mem": 12582912}

Note that this behavior works only in case that the devlink instance in the
initial namespace, in case that the devlink instance is reloaded to
another namesapce, get command will fail as the dummy netdevice associated with
the pools belongs to the initial namespace.

$ ip netns add pp_test
$ devlink dev reload pci/0000:xx:00.0 netns pp_test
$ ip netns exec pp_test ./tools/net/ynl/cli.py \
	--spec Documentation/netlink/specs/netdev.yaml \
	--do page-pool-stats-get --json '{"info" : {"id" : "20"}}' --output-json
Netlink error: No such file or directory
nl_len = 36 (20) nl_flags = 0x100 nl_type = 2
	error: -2

A next patch will allow user use "dump" command also.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlxsw/pci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/pci.c b/drivers/net/ethernet/mellanox/mlxsw/pci.c
index cb043379c01c..7abb4b2fe541 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/pci.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/pci.c
@@ -892,6 +892,7 @@ static int mlxsw_pci_cq_page_pool_init(struct mlxsw_pci_queue *q,
 	pp_params.dev = &mlxsw_pci->pdev->dev;
 	pp_params.napi = &q->u.cq.napi;
 	pp_params.dma_dir = DMA_FROM_DEVICE;
+	pp_params.netdev = q->pci->napi_dev_rx;
 
 	page_pool = page_pool_create(&pp_params);
 	if (IS_ERR(page_pool))
-- 
2.45.1


  parent reply	other threads:[~2024-06-25 12:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-25 12:08 [PATCH RFC net-next 0/4] Adjust page pool netlink filling to non common case Amit Cohen
2024-06-25 12:08 ` [PATCH RFC net-next 1/4] net: core: page_pool_user: Allow flexibility of 'ifindex' value Amit Cohen
2024-06-25 12:08 ` [PATCH RFC net-next 2/4] net: core: page_pool_user: Change 'ifindex' for page pool dump Amit Cohen
2024-06-25 12:08 ` Amit Cohen [this message]
2024-06-25 12:08 ` [PATCH RFC net-next 4/4] mlxsw: Set page pools list for netdevices Amit Cohen
2024-06-25 14:35 ` [PATCH RFC net-next 0/4] Adjust page pool netlink filling to non common case Jakub Kicinski
2024-06-25 15:37   ` Amit Cohen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240625120807.1165581-4-amcohen@nvidia.com \
    --to=amcohen@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hawk@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=mlxsw@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=petrm@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).