old mode 100644new mode 100755.. | .. |
---|
15 | 15 | #include <linux/wait.h> |
---|
16 | 16 | #include <linux/workqueue.h> |
---|
17 | 17 | |
---|
18 | | -/** |
---|
19 | | - * struct rwnx_fw_trace_desc - Trace buffer info as provided by fw in ipc |
---|
20 | | - * |
---|
21 | | - * @pattern: Synchro pattern |
---|
22 | | - * @start: Index of first entry in trace buffer |
---|
23 | | - * @end: Index of last entry in trace buffer |
---|
24 | | - * @size: Size, in 16bits words, od the trace buffer |
---|
25 | | - * @offset: Offset, in bytest, to the start of the buffer from the address of |
---|
26 | | - * this field. |
---|
27 | | - * @nb_compo: Number of filterable component (16LSB) synchro pattern (16 MSB) |
---|
28 | | - * @offset_compo: Offset, in bytest, to the start of the component activation |
---|
29 | | - * table from the address of this field. |
---|
30 | | - */ |
---|
31 | | -struct rwnx_fw_trace_ipc_desc { |
---|
32 | | - volatile uint16_t pattern; |
---|
33 | | - volatile uint32_t start; |
---|
34 | | - volatile uint32_t end; |
---|
35 | | - volatile uint32_t size; |
---|
36 | | - volatile uint32_t offset; |
---|
37 | | - volatile uint32_t nb_compo; |
---|
38 | | - volatile uint32_t offset_compo; |
---|
39 | | -}; |
---|
| 18 | +#define FW_LOG_SIZE (10240) |
---|
40 | 19 | |
---|
41 | | -/** |
---|
42 | | - * struct rwnx_fw_trace_buf - Info for trace buffer in shared memory |
---|
43 | | - * |
---|
44 | | - * @lock: Address of the synchro word |
---|
45 | | - * @data: Address of the trace buffer |
---|
46 | | - * @size: Size, in 16bits words, of the trace buffer |
---|
47 | | - * @start: Address on the current index (in 16 bits words) of the first trace |
---|
48 | | - * entry. |
---|
49 | | - * @end: Address on the current index (in 16 bits words) of the last trace |
---|
50 | | - * entry. If *end > size, it means that the trace buffer contains no traces. |
---|
51 | | - * @reset_idx: Increased each time the trace buffer is reset |
---|
52 | | - * (by calling _rwnx_fw_trace_reset()) |
---|
53 | | - * @nb_compo: Size of the compo_table |
---|
54 | | - * @compo_table: Table containing component filter status. |
---|
55 | | - */ |
---|
56 | | -struct rwnx_fw_trace_buf { |
---|
57 | | - volatile uint16_t *lock; |
---|
58 | | - uint16_t *data; |
---|
| 20 | +struct rwnx_fw_log_buf { |
---|
| 21 | + uint8_t *data; |
---|
| 22 | + uint8_t *start; |
---|
| 23 | + uint8_t *end; |
---|
| 24 | + uint8_t *dataend; |
---|
59 | 25 | uint32_t size; |
---|
60 | | - volatile uint32_t *start; |
---|
61 | | - volatile uint32_t *end; |
---|
62 | | - int reset_idx; |
---|
63 | | - unsigned int nb_compo; |
---|
64 | | - uint32_t *compo_table; |
---|
65 | 26 | }; |
---|
66 | 27 | |
---|
67 | | -/** |
---|
68 | | - * struct rwnx_fw_trace_local_buf - Info for a local trace buffer |
---|
69 | | - * |
---|
70 | | - * @data: Address of the local buffer |
---|
71 | | - * @data_end: Address after the end of the local buffer |
---|
72 | | - * @size: Size, in 16bits words, oth the local buffer |
---|
73 | | - * @read: Pointer to the next trace entry to read |
---|
74 | | - * @write: Pointer to the next entry to write |
---|
75 | | - * @nb_entries: Number of trace entries ready to be read |
---|
76 | | - * @free_space: Free space, in 16bits words, in the buffer. |
---|
77 | | - * @last_read: Address of the last entry read in the shared buffer |
---|
78 | | - * @last_read_value: First word of the last trace entry read. |
---|
79 | | - * @reset_idx: Reset index. If it doesn't match share buffer index then it |
---|
80 | | - * means that share buffer has been resetted since last read. |
---|
81 | | - */ |
---|
82 | | -struct rwnx_fw_trace_local_buf { |
---|
83 | | - uint16_t *data; |
---|
84 | | - uint16_t *data_end; |
---|
85 | | - uint32_t size; |
---|
86 | | - uint16_t *read; |
---|
87 | | - uint16_t *write; |
---|
88 | | - uint16_t nb_entries; |
---|
89 | | - uint32_t free_space; |
---|
90 | | - uint16_t *last_read; |
---|
91 | | - uint16_t last_read_value; |
---|
92 | | - int reset_idx; |
---|
93 | | - uint16_t *show_reset; |
---|
| 28 | +struct rwnx_fw_log { |
---|
| 29 | + struct rwnx_fw_log_buf buf; |
---|
| 30 | + spinlock_t lock; |
---|
94 | 31 | }; |
---|
95 | 32 | |
---|
96 | | - |
---|
97 | | -/** |
---|
98 | | - * struct rwnx_fw_trace - info to handle several reader of the shared buffer |
---|
99 | | - * |
---|
100 | | - * @buf: shared trace buffer. |
---|
101 | | - * @mutex: mutex, used to prevent several reader updating shared buffer at the |
---|
102 | | - * same time. |
---|
103 | | - * @queue: queue, used to delay reader. |
---|
104 | | - * @work: work used to periodically check for new traces in shared buffer. |
---|
105 | | - * @last_read_index: Last read index from shared buffer |
---|
106 | | - * @closing: Indicate whether is driver is being removed, meaning that reader |
---|
107 | | - * should no longer wait no new traces |
---|
108 | | - */ |
---|
109 | | -struct rwnx_fw_trace { |
---|
110 | | - struct rwnx_fw_trace_buf buf; |
---|
111 | | - struct mutex mutex; |
---|
112 | | - wait_queue_head_t queue; |
---|
113 | | - struct delayed_work work; |
---|
114 | | - int last_read_index; |
---|
115 | | - bool closing; |
---|
116 | | -}; |
---|
117 | | - |
---|
118 | | -int rwnx_fw_trace_init(struct rwnx_fw_trace *trace, |
---|
119 | | - struct rwnx_fw_trace_ipc_desc *ipc); |
---|
120 | | -void rwnx_fw_trace_deinit(struct rwnx_fw_trace *trace); |
---|
121 | | - |
---|
122 | | -int rwnx_fw_trace_buf_init(struct rwnx_fw_trace_buf *shared_buf, |
---|
123 | | - struct rwnx_fw_trace_ipc_desc *ipc); |
---|
124 | | - |
---|
125 | | -int _rwnx_fw_trace_reset(struct rwnx_fw_trace *trace, bool lock); |
---|
126 | | -void _rwnx_fw_trace_dump(struct rwnx_fw_trace_buf *trace); |
---|
127 | | - |
---|
128 | | -int rwnx_fw_trace_alloc_local(struct rwnx_fw_trace_local_buf *local, |
---|
129 | | - int size); |
---|
130 | | -void rwnx_fw_trace_free_local(struct rwnx_fw_trace_local_buf *local); |
---|
131 | | - |
---|
132 | | - |
---|
133 | | -size_t rwnx_fw_trace_read(struct rwnx_fw_trace *trace, |
---|
134 | | - struct rwnx_fw_trace_local_buf *local_buf, |
---|
135 | | - bool dont_wait, char __user *user_buf, size_t size); |
---|
136 | | - |
---|
137 | | - |
---|
138 | | -size_t rwnx_fw_trace_level_read(struct rwnx_fw_trace *trace, |
---|
139 | | - char __user *user_buf, size_t len, loff_t *ppos); |
---|
140 | | -size_t rwnx_fw_trace_level_write(struct rwnx_fw_trace *trace, |
---|
141 | | - const char __user *user_buf, size_t len); |
---|
142 | | - |
---|
143 | | - |
---|
144 | | -int rwnx_fw_trace_config_filters(struct rwnx_fw_trace_buf *trace_buf, |
---|
145 | | - struct rwnx_fw_trace_ipc_desc *ipc, char *ftl); |
---|
146 | | - |
---|
147 | | -/** |
---|
148 | | - * rwnx_fw_trace_empty() - Check if shared buffer is empty |
---|
149 | | - * |
---|
150 | | - * @shared_buf: Pointer to shared buffer |
---|
151 | | - */ |
---|
152 | | -static inline bool rwnx_fw_trace_empty(struct rwnx_fw_trace_buf *shared_buf) |
---|
153 | | -{ |
---|
154 | | - return (*shared_buf->end >= shared_buf->size); |
---|
155 | | -} |
---|
156 | | - |
---|
| 33 | +int rwnx_fw_log_init(struct rwnx_fw_log *fw_log); |
---|
| 34 | +void rwnx_fw_log_deinit(struct rwnx_fw_log *fw_log); |
---|
157 | 35 | #endif /* _RWNX_FW_TRACE_H_ */ |
---|