[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240625120807.1165581-5-amcohen@nvidia.com>
Date: Tue, 25 Jun 2024 15:08:07 +0300
From: Amit Cohen <amcohen@...dia.com>
To: <kuba@...nel.org>
CC: <davem@...emloft.net>, <edumazet@...gle.com>, <pabeni@...hat.com>,
<hawk@...nel.org>, <idosch@...dia.com>, <petrm@...dia.com>,
<mlxsw@...dia.com>, <netdev@...r.kernel.org>, Amit Cohen <amcohen@...dia.com>
Subject: [PATCH RFC net-next 4/4] mlxsw: Set page pools list for netdevices
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@...dia.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
Powered by blists - more mailing lists