^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /* Copyright 2019 NXP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/debugfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include "dpseci-debugfs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) static int dpseci_dbg_fqs_show(struct seq_file *file, void *offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) struct dpaa2_caam_priv *priv = (struct dpaa2_caam_priv *)file->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) u32 fqid, fcnt, bcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) int i, err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) seq_printf(file, "FQ stats for %s:\n", dev_name(priv->dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) seq_printf(file, "%s%16s%16s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) "Rx-VFQID",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) "Pending frames",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) "Pending bytes");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) for (i = 0; i < priv->num_pairs; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) fqid = priv->rx_queue_attr[i].fqid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) err = dpaa2_io_query_fq_count(NULL, fqid, &fcnt, &bcnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) seq_printf(file, "%5d%16u%16u\n", fqid, fcnt, bcnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) seq_printf(file, "%s%16s%16s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) "Tx-VFQID",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) "Pending frames",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) "Pending bytes");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) for (i = 0; i < priv->num_pairs; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) fqid = priv->tx_queue_attr[i].fqid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) err = dpaa2_io_query_fq_count(NULL, fqid, &fcnt, &bcnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) seq_printf(file, "%5d%16u%16u\n", fqid, fcnt, bcnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) DEFINE_SHOW_ATTRIBUTE(dpseci_dbg_fqs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) void dpaa2_dpseci_debugfs_init(struct dpaa2_caam_priv *priv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) priv->dfs_root = debugfs_create_dir(dev_name(priv->dev), NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) debugfs_create_file("fq_stats", 0444, priv->dfs_root, priv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) &dpseci_dbg_fqs_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) void dpaa2_dpseci_debugfs_exit(struct dpaa2_caam_priv *priv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) debugfs_remove_recursive(priv->dfs_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) }