fnic_trace.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* Copyright 2012 Cisco Systems, Inc. All rights reserved. */
  3. #ifndef __FNIC_TRACE_H__
  4. #define __FNIC_TRACE_H__
  5. #define FNIC_ENTRY_SIZE_BYTES 64
  6. #define FC_TRC_SIZE_BYTES 256
  7. #define FC_TRC_HEADER_SIZE sizeof(struct fc_trace_hdr)
  8. /*
  9. * Fisrt bit of FNIC_FC_RECV and FNIC_FC_SEND is used to represent the type
  10. * of frame 1 => Eth frame, 0=> FC frame
  11. */
  12. #define FNIC_FC_RECV 0x52 /* Character R */
  13. #define FNIC_FC_SEND 0x54 /* Character T */
  14. #define FNIC_FC_LE 0x4C /* Character L */
  15. extern ssize_t simple_read_from_buffer(void __user *to,
  16. size_t count,
  17. loff_t *ppos,
  18. const void *from,
  19. size_t available);
  20. extern unsigned int fnic_trace_max_pages;
  21. extern int fnic_tracing_enabled;
  22. extern unsigned int trace_max_pages;
  23. extern unsigned int fnic_fc_trace_max_pages;
  24. extern int fnic_fc_tracing_enabled;
  25. extern int fnic_fc_trace_cleared;
  26. typedef struct fnic_trace_dbg {
  27. int wr_idx;
  28. int rd_idx;
  29. unsigned long *page_offset;
  30. } fnic_trace_dbg_t;
  31. typedef struct fnic_dbgfs {
  32. int buffer_len;
  33. char *buffer;
  34. } fnic_dbgfs_t;
  35. struct fnic_trace_data {
  36. union {
  37. struct {
  38. u32 low;
  39. u32 high;
  40. };
  41. u64 val;
  42. } timestamp, fnaddr;
  43. u32 host_no;
  44. u32 tag;
  45. u64 data[5];
  46. } __attribute__((__packed__));
  47. typedef struct fnic_trace_data fnic_trace_data_t;
  48. struct fc_trace_hdr {
  49. struct timespec64 time_stamp;
  50. u32 host_no;
  51. u8 frame_type;
  52. u8 frame_len;
  53. } __attribute__((__packed__));
  54. #define FC_TRACE_ADDRESS(a) \
  55. ((unsigned long)(a) + sizeof(struct fc_trace_hdr))
  56. #define FNIC_TRACE_ENTRY_SIZE \
  57. (FNIC_ENTRY_SIZE_BYTES - sizeof(fnic_trace_data_t))
  58. #define FNIC_TRACE(_fn, _hn, _t, _a, _b, _c, _d, _e) \
  59. if (unlikely(fnic_tracing_enabled)) { \
  60. fnic_trace_data_t *trace_buf = fnic_trace_get_buf(); \
  61. if (trace_buf) { \
  62. if (sizeof(unsigned long) < 8) { \
  63. trace_buf->timestamp.low = jiffies; \
  64. trace_buf->fnaddr.low = (u32)(unsigned long)_fn; \
  65. } else { \
  66. trace_buf->timestamp.val = jiffies; \
  67. trace_buf->fnaddr.val = (u64)(unsigned long)_fn; \
  68. } \
  69. trace_buf->host_no = _hn; \
  70. trace_buf->tag = _t; \
  71. trace_buf->data[0] = (u64)(unsigned long)_a; \
  72. trace_buf->data[1] = (u64)(unsigned long)_b; \
  73. trace_buf->data[2] = (u64)(unsigned long)_c; \
  74. trace_buf->data[3] = (u64)(unsigned long)_d; \
  75. trace_buf->data[4] = (u64)(unsigned long)_e; \
  76. } \
  77. }
  78. fnic_trace_data_t *fnic_trace_get_buf(void);
  79. int fnic_get_trace_data(fnic_dbgfs_t *);
  80. int fnic_trace_buf_init(void);
  81. void fnic_trace_free(void);
  82. int fnic_debugfs_init(void);
  83. void fnic_debugfs_terminate(void);
  84. void fnic_trace_debugfs_init(void);
  85. void fnic_trace_debugfs_terminate(void);
  86. /* Fnic FC CTLR Trace releated function */
  87. int fnic_fc_trace_init(void);
  88. void fnic_fc_trace_free(void);
  89. int fnic_fc_trace_set_data(u32 host_no, u8 frame_type,
  90. char *frame, u32 fc_frame_len);
  91. int fnic_fc_trace_get_data(fnic_dbgfs_t *fnic_dbgfs_prt, u8 rdata_flag);
  92. void copy_and_format_trace_data(struct fc_trace_hdr *tdata,
  93. fnic_dbgfs_t *fnic_dbgfs_prt,
  94. int *len, u8 rdata_flag);
  95. void fnic_fc_trace_debugfs_init(void);
  96. void fnic_fc_trace_debugfs_terminate(void);
  97. #endif