dm thin metadata: fix __udivdi3 undefined on 32-bit
[linux/fpc-iii.git] / drivers / scsi / fnic / fnic_trace.h
bloba8aa0578fcb0a1d9a50cb14384360f79bce4f23d
1 /*
2 * Copyright 2012 Cisco Systems, Inc. All rights reserved.
4 * This program is free software; you may redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
9 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
11 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
12 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
13 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
14 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
15 * SOFTWARE.
18 #ifndef __FNIC_TRACE_H__
19 #define __FNIC_TRACE_H__
21 #define FNIC_ENTRY_SIZE_BYTES 64
22 #define FC_TRC_SIZE_BYTES 256
23 #define FC_TRC_HEADER_SIZE sizeof(struct fc_trace_hdr)
26 * Fisrt bit of FNIC_FC_RECV and FNIC_FC_SEND is used to represent the type
27 * of frame 1 => Eth frame, 0=> FC frame
30 #define FNIC_FC_RECV 0x52 /* Character R */
31 #define FNIC_FC_SEND 0x54 /* Character T */
32 #define FNIC_FC_LE 0x4C /* Character L */
34 extern ssize_t simple_read_from_buffer(void __user *to,
35 size_t count,
36 loff_t *ppos,
37 const void *from,
38 size_t available);
40 extern unsigned int fnic_trace_max_pages;
41 extern int fnic_tracing_enabled;
42 extern unsigned int trace_max_pages;
44 extern unsigned int fnic_fc_trace_max_pages;
45 extern int fnic_fc_tracing_enabled;
46 extern int fnic_fc_trace_cleared;
48 typedef struct fnic_trace_dbg {
49 int wr_idx;
50 int rd_idx;
51 unsigned long *page_offset;
52 } fnic_trace_dbg_t;
54 typedef struct fnic_dbgfs {
55 int buffer_len;
56 char *buffer;
57 } fnic_dbgfs_t;
59 struct fnic_trace_data {
60 union {
61 struct {
62 u32 low;
63 u32 high;
65 u64 val;
66 } timestamp, fnaddr;
67 u32 host_no;
68 u32 tag;
69 u64 data[5];
70 } __attribute__((__packed__));
72 typedef struct fnic_trace_data fnic_trace_data_t;
74 struct fc_trace_hdr {
75 struct timespec time_stamp;
76 u32 host_no;
77 u8 frame_type;
78 u8 frame_len;
79 } __attribute__((__packed__));
81 #define FC_TRACE_ADDRESS(a) \
82 ((unsigned long)(a) + sizeof(struct fc_trace_hdr))
84 #define FNIC_TRACE_ENTRY_SIZE \
85 (FNIC_ENTRY_SIZE_BYTES - sizeof(fnic_trace_data_t))
87 #define FNIC_TRACE(_fn, _hn, _t, _a, _b, _c, _d, _e) \
88 if (unlikely(fnic_tracing_enabled)) { \
89 fnic_trace_data_t *trace_buf = fnic_trace_get_buf(); \
90 if (trace_buf) { \
91 if (sizeof(unsigned long) < 8) { \
92 trace_buf->timestamp.low = jiffies; \
93 trace_buf->fnaddr.low = (u32)(unsigned long)_fn; \
94 } else { \
95 trace_buf->timestamp.val = jiffies; \
96 trace_buf->fnaddr.val = (u64)(unsigned long)_fn; \
97 } \
98 trace_buf->host_no = _hn; \
99 trace_buf->tag = _t; \
100 trace_buf->data[0] = (u64)(unsigned long)_a; \
101 trace_buf->data[1] = (u64)(unsigned long)_b; \
102 trace_buf->data[2] = (u64)(unsigned long)_c; \
103 trace_buf->data[3] = (u64)(unsigned long)_d; \
104 trace_buf->data[4] = (u64)(unsigned long)_e; \
108 fnic_trace_data_t *fnic_trace_get_buf(void);
109 int fnic_get_trace_data(fnic_dbgfs_t *);
110 int fnic_trace_buf_init(void);
111 void fnic_trace_free(void);
112 int fnic_debugfs_init(void);
113 void fnic_debugfs_terminate(void);
114 int fnic_trace_debugfs_init(void);
115 void fnic_trace_debugfs_terminate(void);
117 /* Fnic FC CTLR Trace releated function */
118 int fnic_fc_trace_init(void);
119 void fnic_fc_trace_free(void);
120 int fnic_fc_trace_set_data(u32 host_no, u8 frame_type,
121 char *frame, u32 fc_frame_len);
122 int fnic_fc_trace_get_data(fnic_dbgfs_t *fnic_dbgfs_prt, u8 rdata_flag);
123 void copy_and_format_trace_data(struct fc_trace_hdr *tdata,
124 fnic_dbgfs_t *fnic_dbgfs_prt,
125 int *len, u8 rdata_flag);
126 int fnic_fc_trace_debugfs_init(void);
127 void fnic_fc_trace_debugfs_terminate(void);
129 #endif