[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0d1d3002-ff8b-4601-84d5-ee26733af54e@amd.com>
Date: Thu, 14 Dec 2023 16:05:37 -0800
From: "Nelson, Shannon" <shannon.nelson@....com>
To: edward.cree@....com, linux-net-drivers@....com, davem@...emloft.net,
kuba@...nel.org, pabeni@...hat.com, edumazet@...gle.com
Cc: Edward Cree <ecree.xilinx@...il.com>, netdev@...r.kernel.org,
habetsm.xilinx@...il.com, Jonathan Cooper <jonathan.s.cooper@....com>
Subject: Re: [PATCH net-next 3/7] sfc: debugfs for (nic) RX queues
On 12/11/2023 9:18 AM, edward.cree@....com wrote:
>
> From: Edward Cree <ecree.xilinx@...il.com>
>
> Expose each RX queue's core RXQ association, and the read/write/etc
> pointers for the descriptor ring.
> Each RXQ dir also symlinks to its owning channel.
>
> Reviewed-by: Jonathan Cooper <jonathan.s.cooper@....com>
> Signed-off-by: Edward Cree <ecree.xilinx@...il.com>
> ---
> drivers/net/ethernet/sfc/debugfs.c | 69 ++++++++++++++++++++++++++-
> drivers/net/ethernet/sfc/debugfs.h | 15 ++++++
> drivers/net/ethernet/sfc/net_driver.h | 6 +++
> drivers/net/ethernet/sfc/rx_common.c | 9 ++++
> 4 files changed, 98 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/sfc/debugfs.c b/drivers/net/ethernet/sfc/debugfs.c
> index b46339249794..43b1d06a985e 100644
> --- a/drivers/net/ethernet/sfc/debugfs.c
> +++ b/drivers/net/ethernet/sfc/debugfs.c
> @@ -78,6 +78,72 @@ void efx_update_debugfs_netdev(struct efx_nic *efx)
> mutex_unlock(&efx->debugfs_symlink_mutex);
> }
>
> +#define EFX_DEBUGFS_RXQ(_type, _name) \
> + debugfs_create_##_type(#_name, 0444, rx_queue->debug_dir, &rx_queue->_name)
> +
> +/* Create basic debugfs parameter files for an Efx RXQ */
> +static void efx_init_debugfs_rx_queue_files(struct efx_rx_queue *rx_queue)
> +{
> + EFX_DEBUGFS_RXQ(u32, core_index); /* actually an int */
> + /* descriptor ring indices */
> + EFX_DEBUGFS_RXQ(u32, added_count);
> + EFX_DEBUGFS_RXQ(u32, notified_count);
> + EFX_DEBUGFS_RXQ(u32, granted_count);
> + EFX_DEBUGFS_RXQ(u32, removed_count);
> +}
> +
> +/**
> + * efx_init_debugfs_rx_queue - create debugfs directory for RX queue
> + * @rx_queue: Efx RX queue
> + *
> + * Create a debugfs directory containing parameter-files for @rx_queue.
> + * The directory must be cleaned up using efx_fini_debugfs_rx_queue(),
> + * even if this function returns an error.
> + *
> + * Return: a negative error code or 0 on success.
> + */
> +int efx_init_debugfs_rx_queue(struct efx_rx_queue *rx_queue)
> +{
> + struct efx_channel *channel = efx_rx_queue_channel(rx_queue);
> + char target[EFX_DEBUGFS_NAME_LEN];
> + char name[EFX_DEBUGFS_NAME_LEN];
> +
> + if (!rx_queue->efx->debug_queues_dir)
> + return -ENODEV;
> + /* Create directory */
> + if (snprintf(name, sizeof(name), "rx-%d", efx_rx_queue_index(rx_queue))
Adding leading 0's here can be helpful for directory entry sorting
> + >= sizeof(name))
> + return -ENAMETOOLONG;
> + rx_queue->debug_dir = debugfs_create_dir(name,
> + rx_queue->efx->debug_queues_dir);
> + if (!rx_queue->debug_dir)
> + return -ENOMEM;
> +
> + /* Create files */
> + efx_init_debugfs_rx_queue_files(rx_queue);
> +
> + /* Create symlink to channel */
> + if (snprintf(target, sizeof(target), "../../channels/%d",
> + channel->channel) >= sizeof(target))
> + return -ENAMETOOLONG;
> + if (!debugfs_create_symlink("channel", rx_queue->debug_dir, target))
> + return -ENOMEM;
If these fail, should you clean up the earlier create_dir()?
> +
> + return 0;
> +}
> +
> +/**
> + * efx_fini_debugfs_rx_queue - remove debugfs directory for RX queue
> + * @rx_queue: Efx RX queue
> + *
> + * Remove directory created for @rx_queue by efx_init_debugfs_rx_queue().
> + */
> +void efx_fini_debugfs_rx_queue(struct efx_rx_queue *rx_queue)
> +{
> + debugfs_remove_recursive(rx_queue->debug_dir);
> + rx_queue->debug_dir = NULL;
> +}
> +
> #define EFX_DEBUGFS_CHANNEL(_type, _name) \
> debugfs_create_##_type(#_name, 0444, channel->debug_dir, &channel->_name)
>
> @@ -208,9 +274,10 @@ int efx_init_debugfs_nic(struct efx_nic *efx)
> if (!efx->debug_dir)
> return -ENOMEM;
> efx_init_debugfs_nic_files(efx);
> - /* Create channels subdirectory */
> + /* Create subdirectories */
> efx->debug_channels_dir = debugfs_create_dir("channels",
> efx->debug_dir);
> + efx->debug_queues_dir = debugfs_create_dir("queues", efx->debug_dir);
> return 0;
> }
>
> diff --git a/drivers/net/ethernet/sfc/debugfs.h b/drivers/net/ethernet/sfc/debugfs.h
> index 4af4a03d1b97..53c98a2fb4c9 100644
> --- a/drivers/net/ethernet/sfc/debugfs.h
> +++ b/drivers/net/ethernet/sfc/debugfs.h
> @@ -28,11 +28,20 @@
> * * "channels/" (&efx_nic.debug_channels_dir). For each channel, this will
> * contain a directory (&efx_channel.debug_dir), whose name is the channel
> * index (in decimal).
> + * * "queues/" (&efx_nic.debug_queues_dir).
> + *
> + * * For each NIC RX queue, this will contain a directory
> + * (&efx_rx_queue.debug_dir), whose name is "rx-N" where N is the RX queue
> + * index. (This may not be the same as the kernel core RX queue index.)
> + * The directory will contain a symlink to the owning channel.
> */
>
> void efx_fini_debugfs_netdev(struct net_device *net_dev);
> void efx_update_debugfs_netdev(struct efx_nic *efx);
>
> +int efx_init_debugfs_rx_queue(struct efx_rx_queue *rx_queue);
> +void efx_fini_debugfs_rx_queue(struct efx_rx_queue *rx_queue);
> +
> int efx_init_debugfs_channel(struct efx_channel *channel);
> void efx_fini_debugfs_channel(struct efx_channel *channel);
>
> @@ -48,6 +57,12 @@ static inline void efx_fini_debugfs_netdev(struct net_device *net_dev) {}
>
> static inline void efx_update_debugfs_netdev(struct efx_nic *efx) {}
>
> +int efx_init_debugfs_rx_queue(struct efx_rx_queue *rx_queue)
> +{
> + return 0;
> +}
> +void efx_fini_debugfs_rx_queue(struct efx_rx_queue *rx_queue) {}
> +
> int efx_init_debugfs_channel(struct efx_channel *channel)
> {
> return 0;
> diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h
> index 2b92c5461fe3..63eb32670826 100644
> --- a/drivers/net/ethernet/sfc/net_driver.h
> +++ b/drivers/net/ethernet/sfc/net_driver.h
> @@ -424,6 +424,10 @@ struct efx_rx_queue {
> struct work_struct grant_work;
> /* Statistics to supplement MAC stats */
> unsigned long rx_packets;
> +#ifdef CONFIG_DEBUG_FS
> + /** @debug_dir: Queue debugfs directory (under @efx->debug_queues_dir) */
> + struct dentry *debug_dir;
> +#endif
> struct xdp_rxq_info xdp_rxq_info;
> bool xdp_rxq_info_valid;
> };
> @@ -1150,6 +1154,8 @@ struct efx_nic {
> struct dentry *debug_dir;
> /** @debug_channels_dir: contains channel debugfs dirs. Under @debug_dir */
> struct dentry *debug_channels_dir;
> + /** @debug_queues_dir: contains RX/TX queue debugfs dirs. Under @debug_dir */
> + struct dentry *debug_queues_dir;
> /** @debug_symlink: NIC debugfs symlink (``nic_eth%d``) */
> struct dentry *debug_symlink;
> /** @debug_interrupt_mode: debugfs details for printing @interrupt_mode */
> diff --git a/drivers/net/ethernet/sfc/rx_common.c b/drivers/net/ethernet/sfc/rx_common.c
> index d2f35ee15eff..7f63f70f082d 100644
> --- a/drivers/net/ethernet/sfc/rx_common.c
> +++ b/drivers/net/ethernet/sfc/rx_common.c
> @@ -14,6 +14,7 @@
> #include "efx.h"
> #include "nic.h"
> #include "rx_common.h"
> +#include "debugfs.h"
>
> /* This is the percentage fill level below which new RX descriptors
> * will be added to the RX descriptor ring.
> @@ -208,6 +209,12 @@ int efx_probe_rx_queue(struct efx_rx_queue *rx_queue)
> if (!rx_queue->buffer)
> return -ENOMEM;
>
> + rc = efx_init_debugfs_rx_queue(rx_queue);
> + if (rc) /* not fatal */
> + netif_err(efx, drv, efx->net_dev,
> + "Failed to create debugfs for RXQ %d, rc=%d\n",
> + efx_rx_queue_index(rx_queue), rc);
> +
> rc = efx_nic_probe_rx(rx_queue);
> if (rc) {
> kfree(rx_queue->buffer);
> @@ -311,6 +318,8 @@ void efx_remove_rx_queue(struct efx_rx_queue *rx_queue)
>
> efx_nic_remove_rx(rx_queue);
>
> + efx_fini_debugfs_rx_queue(rx_queue);
> +
> kfree(rx_queue->buffer);
> rx_queue->buffer = NULL;
> }
>
Powered by blists - more mailing lists