Linux Audio

Check our new training course

Loading...
v5.9
  1/*
  2 * Copyright 2012 Cisco Systems, Inc.  All rights reserved.
  3 *
  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.
  7 *
  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.
 16 */
 17
 18#ifndef __FNIC_TRACE_H__
 19#define __FNIC_TRACE_H__
 20
 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)
 24
 25/*
 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
 28 */
 29
 30#define FNIC_FC_RECV 0x52 /* Character R */
 31#define FNIC_FC_SEND 0x54 /* Character T */
 32#define FNIC_FC_LE 0x4C /* Character L */
 33
 34extern 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);
 39
 40extern unsigned int fnic_trace_max_pages;
 41extern int fnic_tracing_enabled;
 42extern unsigned int trace_max_pages;
 43
 44extern unsigned int fnic_fc_trace_max_pages;
 45extern int fnic_fc_tracing_enabled;
 46extern int fnic_fc_trace_cleared;
 47
 48typedef struct fnic_trace_dbg {
 49	int wr_idx;
 50	int rd_idx;
 51	unsigned long *page_offset;
 52} fnic_trace_dbg_t;
 53
 54typedef struct fnic_dbgfs {
 55	int buffer_len;
 56	char *buffer;
 57} fnic_dbgfs_t;
 58
 59struct fnic_trace_data {
 60	union {
 61		struct {
 62			u32 low;
 63			u32 high;
 64		};
 65		u64 val;
 66	} timestamp, fnaddr;
 67	u32 host_no;
 68	u32 tag;
 69	u64 data[5];
 70} __attribute__((__packed__));
 71
 72typedef struct fnic_trace_data fnic_trace_data_t;
 73
 74struct fc_trace_hdr {
 75	struct timespec64 time_stamp;
 76	u32 host_no;
 77	u8 frame_type;
 78	u8 frame_len;
 79} __attribute__((__packed__));
 80
 81#define FC_TRACE_ADDRESS(a) \
 82	((unsigned long)(a) + sizeof(struct fc_trace_hdr))
 83
 84#define FNIC_TRACE_ENTRY_SIZE \
 85		  (FNIC_ENTRY_SIZE_BYTES - sizeof(fnic_trace_data_t))
 86
 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; \
105		} \
106	}
107
108fnic_trace_data_t *fnic_trace_get_buf(void);
109int fnic_get_trace_data(fnic_dbgfs_t *);
110int fnic_trace_buf_init(void);
111void fnic_trace_free(void);
112int fnic_debugfs_init(void);
113void fnic_debugfs_terminate(void);
114void fnic_trace_debugfs_init(void);
115void fnic_trace_debugfs_terminate(void);
116
117/* Fnic FC CTLR Trace releated function */
118int fnic_fc_trace_init(void);
119void fnic_fc_trace_free(void);
120int fnic_fc_trace_set_data(u32 host_no, u8 frame_type,
121				char *frame, u32 fc_frame_len);
122int fnic_fc_trace_get_data(fnic_dbgfs_t *fnic_dbgfs_prt, u8 rdata_flag);
123void copy_and_format_trace_data(struct fc_trace_hdr *tdata,
124				fnic_dbgfs_t *fnic_dbgfs_prt,
125				int *len, u8 rdata_flag);
126void fnic_fc_trace_debugfs_init(void);
127void fnic_fc_trace_debugfs_terminate(void);
128
129#endif
v5.9
  1/*
  2 * Copyright 2012 Cisco Systems, Inc.  All rights reserved.
  3 *
  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.
  7 *
  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.
 16 */
 17
 18#ifndef __FNIC_TRACE_H__
 19#define __FNIC_TRACE_H__
 20
 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)
 24
 25/*
 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
 28 */
 29
 30#define FNIC_FC_RECV 0x52 /* Character R */
 31#define FNIC_FC_SEND 0x54 /* Character T */
 32#define FNIC_FC_LE 0x4C /* Character L */
 33
 34extern 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);
 39
 40extern unsigned int fnic_trace_max_pages;
 41extern int fnic_tracing_enabled;
 42extern unsigned int trace_max_pages;
 43
 44extern unsigned int fnic_fc_trace_max_pages;
 45extern int fnic_fc_tracing_enabled;
 46extern int fnic_fc_trace_cleared;
 47
 48typedef struct fnic_trace_dbg {
 49	int wr_idx;
 50	int rd_idx;
 51	unsigned long *page_offset;
 52} fnic_trace_dbg_t;
 53
 54typedef struct fnic_dbgfs {
 55	int buffer_len;
 56	char *buffer;
 57} fnic_dbgfs_t;
 58
 59struct fnic_trace_data {
 60	union {
 61		struct {
 62			u32 low;
 63			u32 high;
 64		};
 65		u64 val;
 66	} timestamp, fnaddr;
 67	u32 host_no;
 68	u32 tag;
 69	u64 data[5];
 70} __attribute__((__packed__));
 71
 72typedef struct fnic_trace_data fnic_trace_data_t;
 73
 74struct fc_trace_hdr {
 75	struct timespec64 time_stamp;
 76	u32 host_no;
 77	u8 frame_type;
 78	u8 frame_len;
 79} __attribute__((__packed__));
 80
 81#define FC_TRACE_ADDRESS(a) \
 82	((unsigned long)(a) + sizeof(struct fc_trace_hdr))
 83
 84#define FNIC_TRACE_ENTRY_SIZE \
 85		  (FNIC_ENTRY_SIZE_BYTES - sizeof(fnic_trace_data_t))
 86
 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; \
105		} \
106	}
107
108fnic_trace_data_t *fnic_trace_get_buf(void);
109int fnic_get_trace_data(fnic_dbgfs_t *);
110int fnic_trace_buf_init(void);
111void fnic_trace_free(void);
112int fnic_debugfs_init(void);
113void fnic_debugfs_terminate(void);
114void fnic_trace_debugfs_init(void);
115void fnic_trace_debugfs_terminate(void);
116
117/* Fnic FC CTLR Trace releated function */
118int fnic_fc_trace_init(void);
119void fnic_fc_trace_free(void);
120int fnic_fc_trace_set_data(u32 host_no, u8 frame_type,
121				char *frame, u32 fc_frame_len);
122int fnic_fc_trace_get_data(fnic_dbgfs_t *fnic_dbgfs_prt, u8 rdata_flag);
123void copy_and_format_trace_data(struct fc_trace_hdr *tdata,
124				fnic_dbgfs_t *fnic_dbgfs_prt,
125				int *len, u8 rdata_flag);
126void fnic_fc_trace_debugfs_init(void);
127void fnic_fc_trace_debugfs_terminate(void);
128
129#endif