dpseci-debugfs.c 1.4 KB

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