nx_debugfs.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /**
  2. * debugfs routines supporting the Power 7+ Nest Accelerators driver
  3. *
  4. * Copyright (C) 2011-2012 International Business Machines Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; version 2 only.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. *
  19. * Author: Kent Yoder <yoder1@us.ibm.com>
  20. */
  21. #include <linux/device.h>
  22. #include <linux/kobject.h>
  23. #include <linux/string.h>
  24. #include <linux/debugfs.h>
  25. #include <linux/module.h>
  26. #include <linux/init.h>
  27. #include <linux/crypto.h>
  28. #include <crypto/hash.h>
  29. #include <asm/vio.h>
  30. #include "nx_csbcpb.h"
  31. #include "nx.h"
  32. #ifdef CONFIG_DEBUG_FS
  33. /*
  34. * debugfs
  35. *
  36. * For documentation on these attributes, please see:
  37. *
  38. * Documentation/ABI/testing/debugfs-pfo-nx-crypto
  39. */
  40. int nx_debugfs_init(struct nx_crypto_driver *drv)
  41. {
  42. struct nx_debugfs *dfs = &drv->dfs;
  43. dfs->dfs_root = debugfs_create_dir(NX_NAME, NULL);
  44. dfs->dfs_aes_ops =
  45. debugfs_create_u32("aes_ops",
  46. S_IRUSR | S_IRGRP | S_IROTH,
  47. dfs->dfs_root, (u32 *)&drv->stats.aes_ops);
  48. dfs->dfs_sha256_ops =
  49. debugfs_create_u32("sha256_ops",
  50. S_IRUSR | S_IRGRP | S_IROTH,
  51. dfs->dfs_root,
  52. (u32 *)&drv->stats.sha256_ops);
  53. dfs->dfs_sha512_ops =
  54. debugfs_create_u32("sha512_ops",
  55. S_IRUSR | S_IRGRP | S_IROTH,
  56. dfs->dfs_root,
  57. (u32 *)&drv->stats.sha512_ops);
  58. dfs->dfs_aes_bytes =
  59. debugfs_create_u64("aes_bytes",
  60. S_IRUSR | S_IRGRP | S_IROTH,
  61. dfs->dfs_root,
  62. (u64 *)&drv->stats.aes_bytes);
  63. dfs->dfs_sha256_bytes =
  64. debugfs_create_u64("sha256_bytes",
  65. S_IRUSR | S_IRGRP | S_IROTH,
  66. dfs->dfs_root,
  67. (u64 *)&drv->stats.sha256_bytes);
  68. dfs->dfs_sha512_bytes =
  69. debugfs_create_u64("sha512_bytes",
  70. S_IRUSR | S_IRGRP | S_IROTH,
  71. dfs->dfs_root,
  72. (u64 *)&drv->stats.sha512_bytes);
  73. dfs->dfs_errors =
  74. debugfs_create_u32("errors",
  75. S_IRUSR | S_IRGRP | S_IROTH,
  76. dfs->dfs_root, (u32 *)&drv->stats.errors);
  77. dfs->dfs_last_error =
  78. debugfs_create_u32("last_error",
  79. S_IRUSR | S_IRGRP | S_IROTH,
  80. dfs->dfs_root,
  81. (u32 *)&drv->stats.last_error);
  82. dfs->dfs_last_error_pid =
  83. debugfs_create_u32("last_error_pid",
  84. S_IRUSR | S_IRGRP | S_IROTH,
  85. dfs->dfs_root,
  86. (u32 *)&drv->stats.last_error_pid);
  87. return 0;
  88. }
  89. void
  90. nx_debugfs_fini(struct nx_crypto_driver *drv)
  91. {
  92. debugfs_remove_recursive(drv->dfs.dfs_root);
  93. }
  94. #endif