debugfs.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #ifndef _HFI1_DEBUGFS_H
  2. #define _HFI1_DEBUGFS_H
  3. /*
  4. * Copyright(c) 2015, 2016 Intel Corporation.
  5. *
  6. * This file is provided under a dual BSD/GPLv2 license. When using or
  7. * redistributing this file, you may do so under either license.
  8. *
  9. * GPL LICENSE SUMMARY
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of version 2 of the GNU General Public License as
  13. * published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful, but
  16. * WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * General Public License for more details.
  19. *
  20. * BSD LICENSE
  21. *
  22. * Redistribution and use in source and binary forms, with or without
  23. * modification, are permitted provided that the following conditions
  24. * are met:
  25. *
  26. * - Redistributions of source code must retain the above copyright
  27. * notice, this list of conditions and the following disclaimer.
  28. * - Redistributions in binary form must reproduce the above copyright
  29. * notice, this list of conditions and the following disclaimer in
  30. * the documentation and/or other materials provided with the
  31. * distribution.
  32. * - Neither the name of Intel Corporation nor the names of its
  33. * contributors may be used to endorse or promote products derived
  34. * from this software without specific prior written permission.
  35. *
  36. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  37. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  38. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  39. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  40. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  41. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  42. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  43. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  44. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  45. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  46. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  47. *
  48. */
  49. struct hfi1_ibdev;
  50. #ifdef CONFIG_DEBUG_FS
  51. void hfi1_dbg_ibdev_init(struct hfi1_ibdev *ibd);
  52. void hfi1_dbg_ibdev_exit(struct hfi1_ibdev *ibd);
  53. void hfi1_dbg_init(void);
  54. void hfi1_dbg_exit(void);
  55. #ifdef CONFIG_FAULT_INJECTION
  56. #include <linux/fault-inject.h>
  57. struct fault_opcode {
  58. struct fault_attr attr;
  59. struct dentry *dir;
  60. bool fault_by_opcode;
  61. u64 n_rxfaults[256];
  62. u64 n_txfaults[256];
  63. u8 opcode;
  64. u8 mask;
  65. };
  66. struct fault_packet {
  67. struct fault_attr attr;
  68. struct dentry *dir;
  69. bool fault_by_packet;
  70. u64 n_faults;
  71. };
  72. bool hfi1_dbg_fault_opcode(struct rvt_qp *qp, u32 opcode, bool rx);
  73. bool hfi1_dbg_fault_packet(struct hfi1_packet *packet);
  74. bool hfi1_dbg_fault_suppress_err(struct hfi1_ibdev *ibd);
  75. #else
  76. static inline bool hfi1_dbg_fault_packet(struct hfi1_packet *packet)
  77. {
  78. return false;
  79. }
  80. static inline bool hfi1_dbg_fault_opcode(struct rvt_qp *qp,
  81. u32 opcode, bool rx)
  82. {
  83. return false;
  84. }
  85. static inline bool hfi1_dbg_fault_suppress_err(struct hfi1_ibdev *ibd)
  86. {
  87. return false;
  88. }
  89. #endif
  90. #else
  91. static inline void hfi1_dbg_ibdev_init(struct hfi1_ibdev *ibd)
  92. {
  93. }
  94. static inline void hfi1_dbg_ibdev_exit(struct hfi1_ibdev *ibd)
  95. {
  96. }
  97. static inline void hfi1_dbg_init(void)
  98. {
  99. }
  100. static inline void hfi1_dbg_exit(void)
  101. {
  102. }
  103. static inline bool hfi1_dbg_fault_packet(struct hfi1_packet *packet)
  104. {
  105. return false;
  106. }
  107. static inline bool hfi1_dbg_fault_opcode(struct rvt_qp *qp,
  108. u32 opcode, bool rx)
  109. {
  110. return false;
  111. }
  112. static inline bool hfi1_dbg_fault_suppress_err(struct hfi1_ibdev *ibd)
  113. {
  114. return false;
  115. }
  116. #endif
  117. #endif /* _HFI1_DEBUGFS_H */