9p.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #undef TRACE_SYSTEM
  3. #define TRACE_SYSTEM 9p
  4. #if !defined(_TRACE_9P_H) || defined(TRACE_HEADER_MULTI_READ)
  5. #define _TRACE_9P_H
  6. #include <linux/tracepoint.h>
  7. #define P9_MSG_T \
  8. EM( P9_TLERROR, "P9_TLERROR" ) \
  9. EM( P9_RLERROR, "P9_RLERROR" ) \
  10. EM( P9_TSTATFS, "P9_TSTATFS" ) \
  11. EM( P9_RSTATFS, "P9_RSTATFS" ) \
  12. EM( P9_TLOPEN, "P9_TLOPEN" ) \
  13. EM( P9_RLOPEN, "P9_RLOPEN" ) \
  14. EM( P9_TLCREATE, "P9_TLCREATE" ) \
  15. EM( P9_RLCREATE, "P9_RLCREATE" ) \
  16. EM( P9_TSYMLINK, "P9_TSYMLINK" ) \
  17. EM( P9_RSYMLINK, "P9_RSYMLINK" ) \
  18. EM( P9_TMKNOD, "P9_TMKNOD" ) \
  19. EM( P9_RMKNOD, "P9_RMKNOD" ) \
  20. EM( P9_TRENAME, "P9_TRENAME" ) \
  21. EM( P9_RRENAME, "P9_RRENAME" ) \
  22. EM( P9_TREADLINK, "P9_TREADLINK" ) \
  23. EM( P9_RREADLINK, "P9_RREADLINK" ) \
  24. EM( P9_TGETATTR, "P9_TGETATTR" ) \
  25. EM( P9_RGETATTR, "P9_RGETATTR" ) \
  26. EM( P9_TSETATTR, "P9_TSETATTR" ) \
  27. EM( P9_RSETATTR, "P9_RSETATTR" ) \
  28. EM( P9_TXATTRWALK, "P9_TXATTRWALK" ) \
  29. EM( P9_RXATTRWALK, "P9_RXATTRWALK" ) \
  30. EM( P9_TXATTRCREATE, "P9_TXATTRCREATE" ) \
  31. EM( P9_RXATTRCREATE, "P9_RXATTRCREATE" ) \
  32. EM( P9_TREADDIR, "P9_TREADDIR" ) \
  33. EM( P9_RREADDIR, "P9_RREADDIR" ) \
  34. EM( P9_TFSYNC, "P9_TFSYNC" ) \
  35. EM( P9_RFSYNC, "P9_RFSYNC" ) \
  36. EM( P9_TLOCK, "P9_TLOCK" ) \
  37. EM( P9_RLOCK, "P9_RLOCK" ) \
  38. EM( P9_TGETLOCK, "P9_TGETLOCK" ) \
  39. EM( P9_RGETLOCK, "P9_RGETLOCK" ) \
  40. EM( P9_TLINK, "P9_TLINK" ) \
  41. EM( P9_RLINK, "P9_RLINK" ) \
  42. EM( P9_TMKDIR, "P9_TMKDIR" ) \
  43. EM( P9_RMKDIR, "P9_RMKDIR" ) \
  44. EM( P9_TRENAMEAT, "P9_TRENAMEAT" ) \
  45. EM( P9_RRENAMEAT, "P9_RRENAMEAT" ) \
  46. EM( P9_TUNLINKAT, "P9_TUNLINKAT" ) \
  47. EM( P9_RUNLINKAT, "P9_RUNLINKAT" ) \
  48. EM( P9_TVERSION, "P9_TVERSION" ) \
  49. EM( P9_RVERSION, "P9_RVERSION" ) \
  50. EM( P9_TAUTH, "P9_TAUTH" ) \
  51. EM( P9_RAUTH, "P9_RAUTH" ) \
  52. EM( P9_TATTACH, "P9_TATTACH" ) \
  53. EM( P9_RATTACH, "P9_RATTACH" ) \
  54. EM( P9_TERROR, "P9_TERROR" ) \
  55. EM( P9_RERROR, "P9_RERROR" ) \
  56. EM( P9_TFLUSH, "P9_TFLUSH" ) \
  57. EM( P9_RFLUSH, "P9_RFLUSH" ) \
  58. EM( P9_TWALK, "P9_TWALK" ) \
  59. EM( P9_RWALK, "P9_RWALK" ) \
  60. EM( P9_TOPEN, "P9_TOPEN" ) \
  61. EM( P9_ROPEN, "P9_ROPEN" ) \
  62. EM( P9_TCREATE, "P9_TCREATE" ) \
  63. EM( P9_RCREATE, "P9_RCREATE" ) \
  64. EM( P9_TREAD, "P9_TREAD" ) \
  65. EM( P9_RREAD, "P9_RREAD" ) \
  66. EM( P9_TWRITE, "P9_TWRITE" ) \
  67. EM( P9_RWRITE, "P9_RWRITE" ) \
  68. EM( P9_TCLUNK, "P9_TCLUNK" ) \
  69. EM( P9_RCLUNK, "P9_RCLUNK" ) \
  70. EM( P9_TREMOVE, "P9_TREMOVE" ) \
  71. EM( P9_RREMOVE, "P9_RREMOVE" ) \
  72. EM( P9_TSTAT, "P9_TSTAT" ) \
  73. EM( P9_RSTAT, "P9_RSTAT" ) \
  74. EM( P9_TWSTAT, "P9_TWSTAT" ) \
  75. EMe(P9_RWSTAT, "P9_RWSTAT" )
  76. #define P9_FID_REFTYPE \
  77. EM( P9_FID_REF_CREATE, "create " ) \
  78. EM( P9_FID_REF_GET, "get " ) \
  79. EM( P9_FID_REF_PUT, "put " ) \
  80. EMe(P9_FID_REF_DESTROY, "destroy" )
  81. /* Define EM() to export the enums to userspace via TRACE_DEFINE_ENUM() */
  82. #undef EM
  83. #undef EMe
  84. #define EM(a, b) TRACE_DEFINE_ENUM(a);
  85. #define EMe(a, b) TRACE_DEFINE_ENUM(a);
  86. P9_MSG_T
  87. P9_FID_REFTYPE
  88. /* And also use EM/EMe to define helper enums -- once */
  89. #ifndef __9P_DECLARE_TRACE_ENUMS_ONLY_ONCE
  90. #define __9P_DECLARE_TRACE_ENUMS_ONLY_ONCE
  91. #undef EM
  92. #undef EMe
  93. #define EM(a, b) a,
  94. #define EMe(a, b) a
  95. enum p9_fid_reftype {
  96. P9_FID_REFTYPE
  97. } __mode(byte);
  98. #endif
  99. /*
  100. * Now redefine the EM() and EMe() macros to map the enums to the strings
  101. * that will be printed in the output.
  102. */
  103. #undef EM
  104. #undef EMe
  105. #define EM(a, b) { a, b },
  106. #define EMe(a, b) { a, b }
  107. #define show_9p_op(type) \
  108. __print_symbolic(type, P9_MSG_T)
  109. #define show_9p_fid_reftype(type) \
  110. __print_symbolic(type, P9_FID_REFTYPE)
  111. TRACE_EVENT(9p_client_req,
  112. TP_PROTO(struct p9_client *clnt, int8_t type, int tag),
  113. TP_ARGS(clnt, type, tag),
  114. TP_STRUCT__entry(
  115. __field( void *, clnt )
  116. __field( __u8, type )
  117. __field( __u32, tag )
  118. ),
  119. TP_fast_assign(
  120. __entry->clnt = clnt;
  121. __entry->type = type;
  122. __entry->tag = tag;
  123. ),
  124. TP_printk("client %lu request %s tag %d",
  125. (long)__entry->clnt, show_9p_op(__entry->type),
  126. __entry->tag)
  127. );
  128. TRACE_EVENT(9p_client_res,
  129. TP_PROTO(struct p9_client *clnt, int8_t type, int tag, int err),
  130. TP_ARGS(clnt, type, tag, err),
  131. TP_STRUCT__entry(
  132. __field( void *, clnt )
  133. __field( __u8, type )
  134. __field( __u32, tag )
  135. __field( __u32, err )
  136. ),
  137. TP_fast_assign(
  138. __entry->clnt = clnt;
  139. __entry->type = type;
  140. __entry->tag = tag;
  141. __entry->err = err;
  142. ),
  143. TP_printk("client %lu response %s tag %d err %d",
  144. (long)__entry->clnt, show_9p_op(__entry->type),
  145. __entry->tag, __entry->err)
  146. );
  147. /* dump 32 bytes of protocol data */
  148. #define P9_PROTO_DUMP_SZ 32
  149. TRACE_EVENT(9p_protocol_dump,
  150. TP_PROTO(struct p9_client *clnt, struct p9_fcall *pdu),
  151. TP_ARGS(clnt, pdu),
  152. TP_STRUCT__entry(
  153. __field( void *, clnt )
  154. __field( __u8, type )
  155. __field( __u16, tag )
  156. __array( unsigned char, line, P9_PROTO_DUMP_SZ )
  157. ),
  158. TP_fast_assign(
  159. __entry->clnt = clnt;
  160. __entry->type = pdu->id;
  161. __entry->tag = pdu->tag;
  162. memcpy(__entry->line, pdu->sdata, P9_PROTO_DUMP_SZ);
  163. ),
  164. TP_printk("clnt %lu %s(tag = %d)\n%.3x: %16ph\n%.3x: %16ph\n",
  165. (unsigned long)__entry->clnt, show_9p_op(__entry->type),
  166. __entry->tag, 0, __entry->line, 16, __entry->line + 16)
  167. );
  168. TRACE_EVENT(9p_fid_ref,
  169. TP_PROTO(struct p9_fid *fid, __u8 type),
  170. TP_ARGS(fid, type),
  171. TP_STRUCT__entry(
  172. __field( int, fid )
  173. __field( int, refcount )
  174. __field( __u8, type )
  175. ),
  176. TP_fast_assign(
  177. __entry->fid = fid->fid;
  178. __entry->refcount = refcount_read(&fid->count);
  179. __entry->type = type;
  180. ),
  181. TP_printk("%s fid %d, refcount %d",
  182. show_9p_fid_reftype(__entry->type),
  183. __entry->fid, __entry->refcount)
  184. );
  185. #endif /* _TRACE_9P_H */
  186. /* This part must be outside protection */
  187. #include <trace/define_trace.h>