PM / sleep: Asynchronous threads for suspend_noirq
[linux/fpc-iii.git] / drivers / scsi / fnic / fnic_trace.h
blobd412f2ee3c4fec83ee58b52ec5b7370658e39fdf
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
23 extern ssize_t simple_read_from_buffer(void __user *to,
24 size_t count,
25 loff_t *ppos,
26 const void *from,
27 size_t available);
29 extern unsigned int fnic_trace_max_pages;
30 extern int fnic_tracing_enabled;
31 extern unsigned int trace_max_pages;
33 typedef struct fnic_trace_dbg {
34 int wr_idx;
35 int rd_idx;
36 unsigned long *page_offset;
37 } fnic_trace_dbg_t;
39 typedef struct fnic_dbgfs {
40 int buffer_len;
41 char *buffer;
42 } fnic_dbgfs_t;
44 struct fnic_trace_data {
45 union {
46 struct {
47 u32 low;
48 u32 high;
50 u64 val;
51 } timestamp, fnaddr;
52 u32 host_no;
53 u32 tag;
54 u64 data[5];
55 } __attribute__((__packed__));
57 typedef struct fnic_trace_data fnic_trace_data_t;
59 #define FNIC_TRACE_ENTRY_SIZE \
60 (FNIC_ENTRY_SIZE_BYTES - sizeof(fnic_trace_data_t))
62 #define FNIC_TRACE(_fn, _hn, _t, _a, _b, _c, _d, _e) \
63 if (unlikely(fnic_tracing_enabled)) { \
64 fnic_trace_data_t *trace_buf = fnic_trace_get_buf(); \
65 if (trace_buf) { \
66 if (sizeof(unsigned long) < 8) { \
67 trace_buf->timestamp.low = jiffies; \
68 trace_buf->fnaddr.low = (u32)(unsigned long)_fn; \
69 } else { \
70 trace_buf->timestamp.val = jiffies; \
71 trace_buf->fnaddr.val = (u64)(unsigned long)_fn; \
72 } \
73 trace_buf->host_no = _hn; \
74 trace_buf->tag = _t; \
75 trace_buf->data[0] = (u64)(unsigned long)_a; \
76 trace_buf->data[1] = (u64)(unsigned long)_b; \
77 trace_buf->data[2] = (u64)(unsigned long)_c; \
78 trace_buf->data[3] = (u64)(unsigned long)_d; \
79 trace_buf->data[4] = (u64)(unsigned long)_e; \
80 } \
83 fnic_trace_data_t *fnic_trace_get_buf(void);
84 int fnic_get_trace_data(fnic_dbgfs_t *);
85 int fnic_trace_buf_init(void);
86 void fnic_trace_free(void);
87 int fnic_debugfs_init(void);
88 void fnic_debugfs_terminate(void);
89 int fnic_trace_debugfs_init(void);
90 void fnic_trace_debugfs_terminate(void);
91 #endif