Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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