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 4/4] mlxsw: Set page pools list for netdevices
Date: Tue, 25 Jun 2024 15:08:07 +0300 [thread overview]
Message-ID: <20240625120807.1165581-5-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.
A previous patch uses "dummy" Rx netdevice as the netdevice of each
allocated page pool. This will result "napi_dev_rx->page_pools" holding all
the page pools which are used by the driver.
Ideally, we would like to allow user to dump page pools - to get all the
pools which are allocated from the driver for each netdevice, as each
netdevice uses all the pools. For that, add bus operation to get
'hlist_head' of the "dummy" netdevice. Set this list head for all
netdevices as part of port creation. With the previous patches which allow
filling netlink with netdevice which holds the page pool in its list, now
we can dump all page pools for each netdevice.
Without this set, "dump" commands do not print page pools stats:
$ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml \
--dump page-pool-stats-get --output-json | jq
[]
With this set, "dump" commands print all the page pools for all the
netdevices:
$ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml \
--dump page-pool-stats-get --output-json | jq
[
...
{
"info": {
"id": 5,
"ifindex": 64
},
"alloc-fast": 1434916,
"alloc-slow": 49,
....
"recycle-ring": 1454621,
}
...
]
$ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml \
--dump page-pool-get --output-json | \
jq -e ".[] | select(.ifindex == 64)" | grep "napi-id" | wc -l
56
Note that CONFIG_PAGE_POOL_STATS should be enabled to get statistics.
Signed-off-by: Amit Cohen <amcohen@nvidia.com>
---
drivers/net/ethernet/mellanox/mlxsw/core.c | 6 ++++++
drivers/net/ethernet/mellanox/mlxsw/core.h | 2 ++
drivers/net/ethernet/mellanox/mlxsw/pci.c | 8 ++++++++
drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 2 ++
4 files changed, 18 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c
index 4a79c0d7e7ad..15b367b37ba9 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
@@ -2337,6 +2337,12 @@ int mlxsw_core_skb_transmit(struct mlxsw_core *mlxsw_core, struct sk_buff *skb,
}
EXPORT_SYMBOL(mlxsw_core_skb_transmit);
+struct hlist_head mlxsw_core_page_pools_head(struct mlxsw_core *mlxsw_core)
+{
+ return mlxsw_core->bus->page_pools_head(mlxsw_core->bus_priv);
+}
+EXPORT_SYMBOL(mlxsw_core_page_pools_head);
+
void mlxsw_core_ptp_transmitted(struct mlxsw_core *mlxsw_core,
struct sk_buff *skb, u16 local_port)
{
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h
index 6d11225594dd..9925f541ed50 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/core.h
@@ -95,6 +95,7 @@ bool mlxsw_core_skb_transmit_busy(struct mlxsw_core *mlxsw_core,
const struct mlxsw_tx_info *tx_info);
int mlxsw_core_skb_transmit(struct mlxsw_core *mlxsw_core, struct sk_buff *skb,
const struct mlxsw_tx_info *tx_info);
+struct hlist_head mlxsw_core_page_pools_head(struct mlxsw_core *mlxsw_core);
void mlxsw_core_ptp_transmitted(struct mlxsw_core *mlxsw_core,
struct sk_buff *skb, u16 local_port);
@@ -498,6 +499,7 @@ struct mlxsw_bus {
u32 (*read_utc_nsec)(void *bus_priv);
enum mlxsw_cmd_mbox_config_profile_lag_mode (*lag_mode)(void *bus_priv);
enum mlxsw_cmd_mbox_config_profile_flood_mode (*flood_mode)(void *priv);
+ struct hlist_head (*page_pools_head)(void *bus_priv);
u8 features;
};
diff --git a/drivers/net/ethernet/mellanox/mlxsw/pci.c b/drivers/net/ethernet/mellanox/mlxsw/pci.c
index 7abb4b2fe541..16516ae6a818 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/pci.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/pci.c
@@ -2179,6 +2179,13 @@ mlxsw_pci_flood_mode(void *bus_priv)
return mlxsw_pci->flood_mode;
}
+static struct hlist_head mlxsw_pci_page_pools_head(void *bus_priv)
+{
+ struct mlxsw_pci *mlxsw_pci = bus_priv;
+
+ return mlxsw_pci->napi_dev_rx->page_pools;
+}
+
static const struct mlxsw_bus mlxsw_pci_bus = {
.kind = "pci",
.init = mlxsw_pci_init,
@@ -2192,6 +2199,7 @@ static const struct mlxsw_bus mlxsw_pci_bus = {
.read_utc_nsec = mlxsw_pci_read_utc_nsec,
.lag_mode = mlxsw_pci_lag_mode,
.flood_mode = mlxsw_pci_flood_mode,
+ .page_pools_head = mlxsw_pci_page_pools_head,
.features = MLXSW_BUS_F_TXRX | MLXSW_BUS_F_RESET,
};
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index f064789f3240..3c78690c248f 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -1826,6 +1826,7 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u16 local_port,
goto err_register_netdev;
}
+ dev->page_pools = mlxsw_core_page_pools_head(mlxsw_sp->core);
mlxsw_core_schedule_dw(&mlxsw_sp_port->periodic_hw_stats.update_dw, 0);
return 0;
@@ -1880,6 +1881,7 @@ static void mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u16 local_port)
u8 module = mlxsw_sp_port->mapping.module;
cancel_delayed_work_sync(&mlxsw_sp_port->periodic_hw_stats.update_dw);
+ INIT_HLIST_HEAD(&mlxsw_sp_port->dev->page_pools); /* Reset list head. */
cancel_delayed_work_sync(&mlxsw_sp_port->ptp.shaper_dw);
unregister_netdev(mlxsw_sp_port->dev); /* This calls ndo_stop */
mlxsw_sp_port_ptp_clear(mlxsw_sp_port);
--
2.45.1
next prev 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 ` [PATCH RFC net-next 3/4] mlxsw: pci: Allow get page pool info/stats via netlink Amit Cohen
2024-06-25 12:08 ` Amit Cohen [this message]
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-5-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).