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
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
,
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
{
36 unsigned long *page_offset
;
39 typedef struct fnic_dbgfs
{
44 struct fnic_trace_data
{
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(); \
66 if (sizeof(unsigned long) < 8) { \
67 trace_buf->timestamp.low = jiffies; \
68 trace_buf->fnaddr.low = (u32)(unsigned long)_fn; \
70 trace_buf->timestamp.val = jiffies; \
71 trace_buf->fnaddr.val = (u64)(unsigned long)_fn; \
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; \
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);