Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /* Copyright 2012 Cisco Systems, Inc.  All rights reserved. */
0003 
0004 #ifndef __FNIC_TRACE_H__
0005 #define __FNIC_TRACE_H__
0006 
0007 #define FNIC_ENTRY_SIZE_BYTES 64
0008 #define FC_TRC_SIZE_BYTES 256
0009 #define FC_TRC_HEADER_SIZE sizeof(struct fc_trace_hdr)
0010 
0011 /*
0012  * Fisrt bit of FNIC_FC_RECV and FNIC_FC_SEND is used to represent the type
0013  * of frame 1 => Eth frame, 0=> FC frame
0014  */
0015 
0016 #define FNIC_FC_RECV 0x52 /* Character R */
0017 #define FNIC_FC_SEND 0x54 /* Character T */
0018 #define FNIC_FC_LE 0x4C /* Character L */
0019 
0020 extern ssize_t simple_read_from_buffer(void __user *to,
0021                       size_t count,
0022                       loff_t *ppos,
0023                       const void *from,
0024                       size_t available);
0025 
0026 extern unsigned int fnic_trace_max_pages;
0027 extern int fnic_tracing_enabled;
0028 extern unsigned int trace_max_pages;
0029 
0030 extern unsigned int fnic_fc_trace_max_pages;
0031 extern int fnic_fc_tracing_enabled;
0032 extern int fnic_fc_trace_cleared;
0033 
0034 typedef struct fnic_trace_dbg {
0035     int wr_idx;
0036     int rd_idx;
0037     unsigned long *page_offset;
0038 } fnic_trace_dbg_t;
0039 
0040 typedef struct fnic_dbgfs {
0041     int buffer_len;
0042     char *buffer;
0043 } fnic_dbgfs_t;
0044 
0045 struct fnic_trace_data {
0046     union {
0047         struct {
0048             u32 low;
0049             u32 high;
0050         };
0051         u64 val;
0052     } timestamp, fnaddr;
0053     u32 host_no;
0054     u32 tag;
0055     u64 data[5];
0056 } __attribute__((__packed__));
0057 
0058 typedef struct fnic_trace_data fnic_trace_data_t;
0059 
0060 struct fc_trace_hdr {
0061     struct timespec64 time_stamp;
0062     u32 host_no;
0063     u8 frame_type;
0064     u8 frame_len;
0065 } __attribute__((__packed__));
0066 
0067 #define FC_TRACE_ADDRESS(a) \
0068     ((unsigned long)(a) + sizeof(struct fc_trace_hdr))
0069 
0070 #define FNIC_TRACE_ENTRY_SIZE \
0071           (FNIC_ENTRY_SIZE_BYTES - sizeof(fnic_trace_data_t))
0072 
0073 #define FNIC_TRACE(_fn, _hn, _t, _a, _b, _c, _d, _e)           \
0074     if (unlikely(fnic_tracing_enabled)) {                   \
0075         fnic_trace_data_t *trace_buf = fnic_trace_get_buf(); \
0076         if (trace_buf) { \
0077             if (sizeof(unsigned long) < 8) { \
0078                 trace_buf->timestamp.low = jiffies; \
0079                 trace_buf->fnaddr.low = (u32)(unsigned long)_fn; \
0080             } else { \
0081                 trace_buf->timestamp.val = jiffies; \
0082                 trace_buf->fnaddr.val = (u64)(unsigned long)_fn; \
0083             } \
0084             trace_buf->host_no = _hn; \
0085             trace_buf->tag = _t; \
0086             trace_buf->data[0] = (u64)(unsigned long)_a; \
0087             trace_buf->data[1] = (u64)(unsigned long)_b; \
0088             trace_buf->data[2] = (u64)(unsigned long)_c; \
0089             trace_buf->data[3] = (u64)(unsigned long)_d; \
0090             trace_buf->data[4] = (u64)(unsigned long)_e; \
0091         } \
0092     }
0093 
0094 fnic_trace_data_t *fnic_trace_get_buf(void);
0095 int fnic_get_trace_data(fnic_dbgfs_t *);
0096 int fnic_trace_buf_init(void);
0097 void fnic_trace_free(void);
0098 int fnic_debugfs_init(void);
0099 void fnic_debugfs_terminate(void);
0100 void fnic_trace_debugfs_init(void);
0101 void fnic_trace_debugfs_terminate(void);
0102 
0103 /* Fnic FC CTLR Trace releated function */
0104 int fnic_fc_trace_init(void);
0105 void fnic_fc_trace_free(void);
0106 int fnic_fc_trace_set_data(u32 host_no, u8 frame_type,
0107                 char *frame, u32 fc_frame_len);
0108 int fnic_fc_trace_get_data(fnic_dbgfs_t *fnic_dbgfs_prt, u8 rdata_flag);
0109 void copy_and_format_trace_data(struct fc_trace_hdr *tdata,
0110                 fnic_dbgfs_t *fnic_dbgfs_prt,
0111                 int *len, u8 rdata_flag);
0112 void fnic_fc_trace_debugfs_init(void);
0113 void fnic_fc_trace_debugfs_terminate(void);
0114 
0115 #endif