net: dpaa2-eth: export buffer pool info into a new debugfs file
authorIoana Ciornei <ioana.ciornei@nxp.com>
Tue, 18 Oct 2022 14:18:54 +0000 (17:18 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 24 Oct 2022 08:22:11 +0000 (09:22 +0100)
Export the allocated buffer pools, the number of buffers that they have
currently and which channels are using which BP.

The output looks like below:

Buffer pool info for eth2:
IDX        BPID      Buf count      CH#0      CH#1      CH#2      CH#3
BP#0         1           5124         x         x         x         x

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-debugfs.c

index 54e7fcf..1af254c 100644 (file)
@@ -119,6 +119,51 @@ static int dpaa2_dbg_ch_show(struct seq_file *file, void *offset)
 
 DEFINE_SHOW_ATTRIBUTE(dpaa2_dbg_ch);
 
+static int dpaa2_dbg_bp_show(struct seq_file *file, void *offset)
+{
+       struct dpaa2_eth_priv *priv = (struct dpaa2_eth_priv *)file->private;
+       int i, j, num_queues, buf_cnt;
+       struct dpaa2_eth_bp *bp;
+       char ch_name[10];
+       int err;
+
+       /* Print out the header */
+       seq_printf(file, "Buffer pool info for %s:\n", priv->net_dev->name);
+       seq_printf(file, "%s  %10s%15s", "IDX", "BPID", "Buf count");
+       num_queues = dpaa2_eth_queue_count(priv);
+       for (i = 0; i < num_queues; i++) {
+               snprintf(ch_name, sizeof(ch_name), "CH#%d", i);
+               seq_printf(file, "%10s", ch_name);
+       }
+       seq_printf(file, "\n");
+
+       /* For each buffer pool, print out its BPID, the number of buffers in
+        * that buffer pool and the channels which are using it.
+        */
+       for (i = 0; i < priv->num_bps; i++) {
+               bp = priv->bp[i];
+
+               err = dpaa2_io_query_bp_count(NULL, bp->bpid, &buf_cnt);
+               if (err) {
+                       netdev_warn(priv->net_dev, "Buffer count query error %d\n", err);
+                       return err;
+               }
+
+               seq_printf(file, "%3s%d%10d%15d", "BP#", i, bp->bpid, buf_cnt);
+               for (j = 0; j < num_queues; j++) {
+                       if (priv->channel[j]->bp == bp)
+                               seq_printf(file, "%10s", "x");
+                       else
+                               seq_printf(file, "%10s", "");
+               }
+               seq_printf(file, "\n");
+       }
+
+       return 0;
+}
+
+DEFINE_SHOW_ATTRIBUTE(dpaa2_dbg_bp);
+
 void dpaa2_dbg_add(struct dpaa2_eth_priv *priv)
 {
        struct fsl_mc_device *dpni_dev;
@@ -139,6 +184,10 @@ void dpaa2_dbg_add(struct dpaa2_eth_priv *priv)
 
        /* per-fq stats file */
        debugfs_create_file("ch_stats", 0444, dir, priv, &dpaa2_dbg_ch_fops);
+
+       /* per buffer pool stats file */
+       debugfs_create_file("bp_stats", 0444, dir, priv, &dpaa2_dbg_bp_fops);
+
 }
 
 void dpaa2_dbg_remove(struct dpaa2_eth_priv *priv)