1 /** @file moal_debug.c
2 *
3 * @brief This file contains functions for debug proc file.
4 *
5 *
6 * Copyright 2008-2022 NXP
7 *
8 * This software file (the File) is distributed by NXP
9 * under the terms of the GNU General Public License Version 2, June 1991
10 * (the License). You may use, redistribute and/or modify the File in
11 * accordance with the terms and conditions of the License, a copy of which
12 * is available by writing to the Free Software Foundation, Inc.,
13 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
14 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
15 *
16 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
18 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
19 * this warranty disclaimer.
20 *
21 */
22
23 /********************************************************
24 Change log:
25 11/03/2008: initial version
26 ********************************************************/
27
28 #include "moal_main.h"
29 #ifdef USB
30 #include "moal_usb.h"
31 #endif
32
33 /********************************************************
34 Global Variables
35 ********************************************************/
36
37 /********************************************************
38 Local Variables
39 ********************************************************/
40 #ifdef CONFIG_PROC_FS
41
42 /** Get info item size */
43 #define item_size(n) (sizeof(((mlan_debug_info *)0)->n))
44 /** Get info item address */
45 #define item_addr(n) ((t_ptr) & (((mlan_debug_info *)0)->n))
46
47 /** Get moal_private member size */
48 #define item_priv_size(n) (sizeof(((moal_private *)0)->n))
49 /** Get moal_private member address */
50 #define item_priv_addr(n) ((t_ptr) & (((moal_private *)0)->n))
51
52 /** Get moal_handle member size */
53 #define item_handle_size(n) (sizeof(((moal_handle *)0)->n))
54 /** Get moal_handle member address */
55 #define item_handle_addr(n) ((t_ptr) & (((moal_handle *)0)->n))
56
57 #ifdef USB
58 /** Get moal card member size */
59 #define item_card_size(n) (sizeof(((struct usb_card_rec *)0)->n))
60 /** Get moal card member address */
61 #define item_card_addr(n) ((t_ptr) & (((struct usb_card_rec *)0)->n))
62 #endif
63
64 #ifdef STA_SUPPORT
65 static struct debug_data items[] = {
66 #ifdef DEBUG_LEVEL1
67 {"drvdbg", sizeof(drvdbg), (t_ptr)&drvdbg, 0},
68 #endif
69 {"mlan_processing", item_size(mlan_processing),
70 item_addr(mlan_processing), INFO_ADDR},
71 {"main_process_cnt", item_size(main_process_cnt),
72 item_addr(main_process_cnt), INFO_ADDR},
73 {"main_lock_flag", item_size(main_lock_flag), item_addr(main_lock_flag),
74 INFO_ADDR},
75 {"delay_task_flag", item_size(delay_task_flag),
76 item_addr(delay_task_flag), INFO_ADDR},
77 {"mlan_rx_processing", item_size(mlan_rx_processing),
78 item_addr(mlan_rx_processing), INFO_ADDR},
79 {"rx_pkts_queued", item_size(rx_pkts_queued), item_addr(rx_pkts_queued),
80 INFO_ADDR},
81 {"wmm_ac_vo", item_size(wmm_ac_vo), item_addr(wmm_ac_vo), INFO_ADDR},
82 {"wmm_ac_vi", item_size(wmm_ac_vi), item_addr(wmm_ac_vi), INFO_ADDR},
83 {"wmm_ac_be", item_size(wmm_ac_be), item_addr(wmm_ac_be), INFO_ADDR},
84 {"wmm_ac_bk", item_size(wmm_ac_bk), item_addr(wmm_ac_bk), INFO_ADDR},
85 {"max_tx_buf_size", item_size(max_tx_buf_size),
86 item_addr(max_tx_buf_size), INFO_ADDR},
87 {"tx_buf_size", item_size(tx_buf_size), item_addr(tx_buf_size),
88 INFO_ADDR},
89 {"curr_tx_buf_size", item_size(curr_tx_buf_size),
90 item_addr(curr_tx_buf_size), INFO_ADDR},
91 {"ps_mode", item_size(ps_mode), item_addr(ps_mode), INFO_ADDR},
92 {"ps_state", item_size(ps_state), item_addr(ps_state), INFO_ADDR},
93 {"is_deep_sleep", item_size(is_deep_sleep), item_addr(is_deep_sleep),
94 INFO_ADDR},
95 {"wakeup_dev_req", item_size(pm_wakeup_card_req),
96 item_addr(pm_wakeup_card_req), INFO_ADDR},
97 {"wakeup_tries", item_size(pm_wakeup_fw_try),
98 item_addr(pm_wakeup_fw_try), INFO_ADDR},
99 {"wakeup_timeout", item_size(pm_wakeup_timeout),
100 item_addr(pm_wakeup_timeout), INFO_ADDR},
101 {"hs_configured", item_size(is_hs_configured),
102 item_addr(is_hs_configured), INFO_ADDR},
103 {"hs_activated", item_size(hs_activated), item_addr(hs_activated),
104 INFO_ADDR},
105 {"rx_pkts_queued", item_size(rx_pkts_queued), item_addr(rx_pkts_queued),
106 INFO_ADDR},
107 {"tx_pkts_queued", item_size(tx_pkts_queued), item_addr(tx_pkts_queued),
108 INFO_ADDR},
109 {"pps_uapsd_mode", item_size(pps_uapsd_mode), item_addr(pps_uapsd_mode),
110 INFO_ADDR},
111 {"sleep_pd", item_size(sleep_pd), item_addr(sleep_pd), INFO_ADDR},
112 {"qos_cfg", item_size(qos_cfg), item_addr(qos_cfg), INFO_ADDR},
113 {"tx_lock_flag", item_size(tx_lock_flag), item_addr(tx_lock_flag),
114 INFO_ADDR},
115 {"port_open", item_size(port_open), item_addr(port_open), INFO_ADDR},
116 {"bypass_pkt_count", item_size(bypass_pkt_count),
117 item_addr(bypass_pkt_count), INFO_ADDR},
118 {"scan_processing", item_size(scan_processing),
119 item_addr(scan_processing), INFO_ADDR},
120 {"scan_state", item_size(scan_state), item_addr(scan_state), INFO_ADDR},
121 {"num_cmd_timeout", item_size(num_cmd_timeout),
122 item_addr(num_cmd_timeout), INFO_ADDR},
123 {"timeout_cmd_id", item_size(timeout_cmd_id), item_addr(timeout_cmd_id),
124 INFO_ADDR},
125 {"timeout_cmd_act", item_size(timeout_cmd_act),
126 item_addr(timeout_cmd_act), INFO_ADDR},
127 {"last_cmd_id", item_size(last_cmd_id), item_addr(last_cmd_id),
128 INFO_ADDR},
129 {"last_cmd_act", item_size(last_cmd_act), item_addr(last_cmd_act),
130 INFO_ADDR},
131 {"last_cmd_index", item_size(last_cmd_index), item_addr(last_cmd_index),
132 INFO_ADDR},
133 {"last_cmd_resp_id", item_size(last_cmd_resp_id),
134 item_addr(last_cmd_resp_id), INFO_ADDR},
135 {"last_cmd_resp_index", item_size(last_cmd_resp_index),
136 item_addr(last_cmd_resp_index), INFO_ADDR},
137 {"last_event", item_size(last_event), item_addr(last_event), INFO_ADDR},
138 {"last_event_index", item_size(last_event_index),
139 item_addr(last_event_index), INFO_ADDR},
140 {"num_no_cmd_node", item_size(num_no_cmd_node),
141 item_addr(num_no_cmd_node), INFO_ADDR},
142 {"num_cmd_h2c_fail", item_size(num_cmd_host_to_card_failure),
143 item_addr(num_cmd_host_to_card_failure), INFO_ADDR},
144 {"num_cmd_sleep_cfm_fail",
145 item_size(num_cmd_sleep_cfm_host_to_card_failure),
146 item_addr(num_cmd_sleep_cfm_host_to_card_failure), INFO_ADDR},
147 {"num_tx_h2c_fail", item_size(num_tx_host_to_card_failure),
148 item_addr(num_tx_host_to_card_failure), INFO_ADDR},
149 {"num_alloc_buffer_failure", item_size(num_alloc_buffer_failure),
150 item_addr(num_alloc_buffer_failure), INFO_ADDR},
151 #ifdef SDIO
152 {"num_cmdevt_c2h_fail", item_size(num_cmdevt_card_to_host_failure),
153 item_addr(num_cmdevt_card_to_host_failure),
154 INFO_ADDR | (INTF_SD << 8)},
155 {"num_rx_c2h_fail", item_size(num_rx_card_to_host_failure),
156 item_addr(num_rx_card_to_host_failure), INFO_ADDR | (INTF_SD << 8)},
157 {"num_int_read_fail", item_size(num_int_read_failure),
158 item_addr(num_int_read_failure), INFO_ADDR | (INTF_SD << 8)},
159 {"last_int_status", item_size(last_int_status),
160 item_addr(last_int_status), INFO_ADDR | (INTF_SD << 8)},
161 {"num_of_irq", item_size(num_of_irq), item_addr(num_of_irq),
162 INFO_ADDR | (INTF_SD << 8)},
163 {"mp_invalid_update", item_size(mp_invalid_update),
164 item_addr(mp_invalid_update), INFO_ADDR | (INTF_SD << 8)},
165 {"sdio_rx_aggr", item_size(sdio_rx_aggr), item_addr(sdio_rx_aggr),
166 INFO_ADDR | (INTF_SD << 8)},
167 {"mpa_sent_last_pkt", item_size(mpa_sent_last_pkt),
168 item_addr(mpa_sent_last_pkt), INFO_ADDR | (INTF_SD << 8)},
169 {"mpa_sent_no_ports", item_size(mpa_sent_no_ports),
170 item_addr(mpa_sent_no_ports), INFO_ADDR | (INTF_SD << 8)},
171 #endif
172 {"num_evt_deauth", item_size(num_event_deauth),
173 item_addr(num_event_deauth), INFO_ADDR},
174 {"num_evt_disassoc", item_size(num_event_disassoc),
175 item_addr(num_event_disassoc), INFO_ADDR},
176 {"num_evt_link_lost", item_size(num_event_link_lost),
177 item_addr(num_event_link_lost), INFO_ADDR},
178 {"num_cmd_deauth", item_size(num_cmd_deauth), item_addr(num_cmd_deauth),
179 INFO_ADDR},
180 {"num_cmd_assoc_ok", item_size(num_cmd_assoc_success),
181 item_addr(num_cmd_assoc_success), INFO_ADDR},
182 {"num_cmd_assoc_fail", item_size(num_cmd_assoc_failure),
183 item_addr(num_cmd_assoc_failure), INFO_ADDR},
184 {"num_cons_assoc_failure", item_size(num_cons_assoc_failure),
185 item_addr(num_cons_assoc_failure), INFO_ADDR},
186 {"cmd_sent", item_size(cmd_sent), item_addr(cmd_sent), INFO_ADDR},
187 {"data_sent", item_size(data_sent), item_addr(data_sent), INFO_ADDR},
188 {"data_sent_cnt", item_size(data_sent_cnt), item_addr(data_sent_cnt),
189 INFO_ADDR},
190 {"mp_rd_bitmap", item_size(mp_rd_bitmap), item_addr(mp_rd_bitmap),
191 INFO_ADDR},
192 {"curr_rd_port", item_size(curr_rd_port), item_addr(curr_rd_port),
193 INFO_ADDR},
194 {"mp_wr_bitmap", item_size(mp_wr_bitmap), item_addr(mp_wr_bitmap),
195 INFO_ADDR},
196 {"curr_wr_port", item_size(curr_wr_port), item_addr(curr_wr_port),
197 INFO_ADDR},
198 #ifdef PCIE
199 {"txbd_rdptr", item_size(txbd_rdptr), item_addr(txbd_rdptr),
200 INFO_ADDR | (INTF_PCIE << 8)},
201 {"txbd_wrptr", item_size(txbd_wrptr), item_addr(txbd_wrptr),
202 INFO_ADDR | (INTF_PCIE << 8)},
203 {"rxbd_rdptr", item_size(rxbd_rdptr), item_addr(rxbd_rdptr),
204 INFO_ADDR | (INTF_PCIE << 8)},
205 {"rxbd_wrptr", item_size(rxbd_wrptr), item_addr(rxbd_wrptr),
206 INFO_ADDR | (INTF_PCIE << 8)},
207 {"eventbd_rdptr", item_size(eventbd_rdptr), item_addr(eventbd_rdptr),
208 INFO_ADDR | (INTF_PCIE << 8)},
209 {"eventbd_wrptr", item_size(eventbd_wrptr), item_addr(eventbd_wrptr),
210 INFO_ADDR | (INTF_PCIE << 8)},
211 #endif
212 {"cmd_resp_received", item_size(cmd_resp_received),
213 item_addr(cmd_resp_received), INFO_ADDR},
214 {"event_received", item_size(event_received), item_addr(event_received),
215 INFO_ADDR},
216
217 #ifdef USB
218 {"tx_cmd_urb_pending", item_card_size(tx_cmd_urb_pending),
219 item_card_addr(tx_cmd_urb_pending), CARD_ADDR | (INTF_USB << 8)},
220 {"tx_data_urb_pending", item_card_size(tx_data_urb_pending),
221 item_card_addr(tx_data_urb_pending), CARD_ADDR | (INTF_USB << 8)},
222 #ifdef USB_CMD_DATA_EP
223 {"rx_cmd_urb_pending", item_card_size(rx_cmd_urb_pending),
224 item_card_addr(rx_cmd_urb_pending), CARD_ADDR | (INTF_USB << 8)},
225 #endif
226 {"rx_data_urb_pending", item_card_size(rx_data_urb_pending),
227 item_card_addr(rx_data_urb_pending), CARD_ADDR | (INTF_USB << 8)},
228 #endif /* USB */
229 {"num_tx_timeout", item_priv_size(num_tx_timeout),
230 item_priv_addr(num_tx_timeout), PRIV_ADDR},
231 {"ioctl_pending", item_handle_size(ioctl_pending),
232 item_handle_addr(ioctl_pending), HANDLE_ADDR},
233 {"tx_pending", item_handle_size(tx_pending),
234 item_handle_addr(tx_pending), HANDLE_ADDR},
235 {"rx_pending", item_handle_size(rx_pending),
236 item_handle_addr(rx_pending), HANDLE_ADDR},
237 {"lock_count", item_handle_size(lock_count),
238 item_handle_addr(lock_count), HANDLE_ADDR},
239 {"malloc_count", item_handle_size(malloc_count),
240 item_handle_addr(malloc_count), HANDLE_ADDR},
241 {"vmalloc_count", item_handle_size(vmalloc_count),
242 item_handle_addr(vmalloc_count), HANDLE_ADDR},
243 {"mbufalloc_count", item_handle_size(mbufalloc_count),
244 item_handle_addr(mbufalloc_count), HANDLE_ADDR},
245 #ifdef PCIE
246 {"malloc_cons_count", item_handle_size(malloc_cons_count),
247 item_handle_addr(malloc_cons_count), HANDLE_ADDR},
248 #endif
249 {"main_state", item_handle_size(main_state),
250 item_handle_addr(main_state), HANDLE_ADDR},
251 {"driver_state", item_handle_size(driver_state),
252 item_handle_addr(driver_state), HANDLE_ADDR},
253 #ifdef SDIO_MMC_DEBUG
254 {"sdiocmd53w", item_handle_size(cmd53w), item_handle_addr(cmd53w),
255 HANDLE_ADDR},
256 {"sdiocmd53r", item_handle_size(cmd53r), item_handle_addr(cmd53r),
257 HANDLE_ADDR},
258 #endif
259 {"hs_skip_count", item_handle_size(hs_skip_count),
260 item_handle_addr(hs_skip_count), HANDLE_ADDR},
261 {"hs_force_count", item_handle_size(hs_force_count),
262 item_handle_addr(hs_force_count), HANDLE_ADDR},
263 #ifdef STA_CFG80211
264 {"scan_timeout", item_handle_size(scan_timeout),
265 item_handle_addr(scan_timeout), HANDLE_ADDR},
266 #endif
267 };
268
269 #endif
270
271 #ifdef UAP_SUPPORT
272 static struct debug_data uap_items[] = {
273 #ifdef DEBUG_LEVEL1
274 {"drvdbg", sizeof(drvdbg), (t_ptr)&drvdbg, 0},
275 #endif
276 {"mlan_processing", item_size(mlan_processing),
277 item_addr(mlan_processing), INFO_ADDR},
278 {"main_process_cnt", item_size(main_process_cnt),
279 item_addr(main_process_cnt), INFO_ADDR},
280 {"main_lock_flag", item_size(main_lock_flag), item_addr(main_lock_flag),
281 INFO_ADDR},
282 {"delay_task_flag", item_size(delay_task_flag),
283 item_addr(delay_task_flag), INFO_ADDR},
284 {"mlan_rx_processing", item_size(mlan_rx_processing),
285 item_addr(mlan_rx_processing), INFO_ADDR},
286 {"rx_pkts_queued", item_size(rx_pkts_queued), item_addr(rx_pkts_queued),
287 INFO_ADDR},
288 {"wmm_ac_vo", item_size(wmm_ac_vo), item_addr(wmm_ac_vo), INFO_ADDR},
289 {"wmm_ac_vi", item_size(wmm_ac_vi), item_addr(wmm_ac_vi), INFO_ADDR},
290 {"wmm_ac_be", item_size(wmm_ac_be), item_addr(wmm_ac_be), INFO_ADDR},
291 {"wmm_ac_bk", item_size(wmm_ac_bk), item_addr(wmm_ac_bk), INFO_ADDR},
292 {"max_tx_buf_size", item_size(max_tx_buf_size),
293 item_addr(max_tx_buf_size), INFO_ADDR},
294 {"tx_buf_size", item_size(tx_buf_size), item_addr(tx_buf_size),
295 INFO_ADDR},
296 {"curr_tx_buf_size", item_size(curr_tx_buf_size),
297 item_addr(curr_tx_buf_size), INFO_ADDR},
298 {"ps_mode", item_size(ps_mode), item_addr(ps_mode), INFO_ADDR},
299 {"ps_state", item_size(ps_state), item_addr(ps_state), INFO_ADDR},
300 {"wakeup_dev_req", item_size(pm_wakeup_card_req),
301 item_addr(pm_wakeup_card_req), INFO_ADDR},
302 {"wakeup_tries", item_size(pm_wakeup_fw_try),
303 item_addr(pm_wakeup_fw_try), INFO_ADDR},
304 {"wakeup_timeout", item_size(pm_wakeup_timeout),
305 item_addr(pm_wakeup_timeout), INFO_ADDR},
306 {"hs_configured", item_size(is_hs_configured),
307 item_addr(is_hs_configured), INFO_ADDR},
308 {"hs_activated", item_size(hs_activated), item_addr(hs_activated),
309 INFO_ADDR},
310 {"rx_pkts_queued", item_size(rx_pkts_queued), item_addr(rx_pkts_queued),
311 INFO_ADDR},
312 {"tx_pkts_queued", item_size(tx_pkts_queued), item_addr(tx_pkts_queued),
313 INFO_ADDR},
314 {"bypass_pkt_count", item_size(bypass_pkt_count),
315 item_addr(bypass_pkt_count), INFO_ADDR},
316 {"num_bridge_pkts", item_size(num_bridge_pkts),
317 item_addr(num_bridge_pkts), INFO_ADDR},
318 {"num_drop_pkts", item_size(num_drop_pkts), item_addr(num_drop_pkts),
319 INFO_ADDR},
320 {"num_cmd_timeout", item_size(num_cmd_timeout),
321 item_addr(num_cmd_timeout), INFO_ADDR},
322 {"timeout_cmd_id", item_size(timeout_cmd_id), item_addr(timeout_cmd_id),
323 INFO_ADDR},
324 {"timeout_cmd_act", item_size(timeout_cmd_act),
325 item_addr(timeout_cmd_act), INFO_ADDR},
326 {"last_cmd_id", item_size(last_cmd_id), item_addr(last_cmd_id),
327 INFO_ADDR},
328 {"last_cmd_act", item_size(last_cmd_act), item_addr(last_cmd_act),
329 INFO_ADDR},
330 {"last_cmd_index", item_size(last_cmd_index), item_addr(last_cmd_index),
331 INFO_ADDR},
332 {"last_cmd_resp_id", item_size(last_cmd_resp_id),
333 item_addr(last_cmd_resp_id), INFO_ADDR},
334 {"last_cmd_resp_index", item_size(last_cmd_resp_index),
335 item_addr(last_cmd_resp_index), INFO_ADDR},
336 {"last_event", item_size(last_event), item_addr(last_event), INFO_ADDR},
337 {"last_event_index", item_size(last_event_index),
338 item_addr(last_event_index), INFO_ADDR},
339 {"num_no_cmd_node", item_size(num_no_cmd_node),
340 item_addr(num_no_cmd_node), INFO_ADDR},
341 {"num_cmd_h2c_fail", item_size(num_cmd_host_to_card_failure),
342 item_addr(num_cmd_host_to_card_failure), INFO_ADDR},
343 {"num_cmd_sleep_cfm_fail",
344 item_size(num_cmd_sleep_cfm_host_to_card_failure),
345 item_addr(num_cmd_sleep_cfm_host_to_card_failure), INFO_ADDR},
346 {"num_tx_h2c_fail", item_size(num_tx_host_to_card_failure),
347 item_addr(num_tx_host_to_card_failure), INFO_ADDR},
348 {"num_alloc_buffer_failure", item_size(num_alloc_buffer_failure),
349 item_addr(num_alloc_buffer_failure), INFO_ADDR},
350 #ifdef SDIO
351 {"num_cmdevt_c2h_fail", item_size(num_cmdevt_card_to_host_failure),
352 item_addr(num_cmdevt_card_to_host_failure),
353 INFO_ADDR | (INTF_SD << 8)},
354 {"num_rx_c2h_fail", item_size(num_rx_card_to_host_failure),
355 item_addr(num_rx_card_to_host_failure), INFO_ADDR | (INTF_SD << 8)},
356 {"num_int_read_fail", item_size(num_int_read_failure),
357 item_addr(num_int_read_failure), INFO_ADDR | (INTF_SD << 8)},
358 {"last_int_status", item_size(last_int_status),
359 item_addr(last_int_status), INFO_ADDR | (INTF_SD << 8)},
360 {"num_of_irq", item_size(num_of_irq), item_addr(num_of_irq),
361 INFO_ADDR | (INTF_SD << 8)},
362 {"mp_invalid_update", item_size(mp_invalid_update),
363 item_addr(mp_invalid_update), INFO_ADDR | (INTF_SD << 8)},
364 {"sdio_rx_aggr", item_size(sdio_rx_aggr), item_addr(sdio_rx_aggr),
365 INFO_ADDR | (INTF_SD << 8)},
366 {"mpa_sent_last_pkt", item_size(mpa_sent_last_pkt),
367 item_addr(mpa_sent_last_pkt), INFO_ADDR | (INTF_SD << 8)},
368 {"mpa_sent_no_ports", item_size(mpa_sent_no_ports),
369 item_addr(mpa_sent_no_ports), INFO_ADDR | (INTF_SD << 8)},
370 #endif
371 {"cmd_sent", item_size(cmd_sent), item_addr(cmd_sent), INFO_ADDR},
372 {"data_sent", item_size(data_sent), item_addr(data_sent), INFO_ADDR},
373 {"data_sent_cnt", item_size(data_sent_cnt), item_addr(data_sent_cnt),
374 INFO_ADDR},
375 {"mp_rd_bitmap", item_size(mp_rd_bitmap), item_addr(mp_rd_bitmap),
376 INFO_ADDR},
377 {"curr_rd_port", item_size(curr_rd_port), item_addr(curr_rd_port),
378 INFO_ADDR},
379 {"mp_wr_bitmap", item_size(mp_wr_bitmap), item_addr(mp_wr_bitmap),
380 INFO_ADDR},
381 {"curr_wr_port", item_size(curr_wr_port), item_addr(curr_wr_port),
382 INFO_ADDR},
383 #ifdef PCIE
384 {"txbd_rdptr", item_size(txbd_rdptr), item_addr(txbd_rdptr),
385 INFO_ADDR | (INTF_PCIE << 8)},
386 {"txbd_wrptr", item_size(txbd_wrptr), item_addr(txbd_wrptr),
387 INFO_ADDR | (INTF_PCIE << 8)},
388 {"rxbd_rdptr", item_size(rxbd_rdptr), item_addr(rxbd_rdptr),
389 INFO_ADDR | (INTF_PCIE << 8)},
390 {"rxbd_wrptr", item_size(rxbd_wrptr), item_addr(rxbd_wrptr),
391 INFO_ADDR | (INTF_PCIE << 8)},
392 {"eventbd_rdptr", item_size(eventbd_rdptr), item_addr(eventbd_rdptr),
393 INFO_ADDR | (INTF_PCIE << 8)},
394 {"eventbd_wrptr", item_size(eventbd_wrptr), item_addr(eventbd_wrptr),
395 INFO_ADDR | (INTF_PCIE << 8)},
396 #endif
397 {"cmd_resp_received", item_size(cmd_resp_received),
398 item_addr(cmd_resp_received), INFO_ADDR},
399 {"event_received", item_size(event_received), item_addr(event_received),
400 INFO_ADDR},
401
402 #ifdef USB
403 {"tx_cmd_urb_pending", item_card_size(tx_cmd_urb_pending),
404 item_card_addr(tx_cmd_urb_pending), CARD_ADDR | (INTF_USB << 8)},
405 {"tx_data_urb_pending", item_card_size(tx_data_urb_pending),
406 item_card_addr(tx_data_urb_pending), CARD_ADDR | (INTF_USB << 8)},
407 #ifdef USB_CMD_DATA_EP
408 {"rx_cmd_urb_pending", item_card_size(rx_cmd_urb_pending),
409 item_card_addr(rx_cmd_urb_pending), CARD_ADDR | (INTF_USB << 8)},
410 #endif
411 {"rx_data_urb_pending", item_card_size(rx_data_urb_pending),
412 item_card_addr(rx_data_urb_pending), CARD_ADDR | (INTF_USB << 8)},
413 #endif /* USB */
414 {"num_tx_timeout", item_priv_size(num_tx_timeout),
415 item_priv_addr(num_tx_timeout), PRIV_ADDR},
416 {"ioctl_pending", item_handle_size(ioctl_pending),
417 item_handle_addr(ioctl_pending), HANDLE_ADDR},
418 {"tx_pending", item_handle_size(tx_pending),
419 item_handle_addr(tx_pending), HANDLE_ADDR},
420 {"rx_pending", item_handle_size(rx_pending),
421 item_handle_addr(rx_pending), HANDLE_ADDR},
422 {"lock_count", item_handle_size(lock_count),
423 item_handle_addr(lock_count), HANDLE_ADDR},
424 {"malloc_count", item_handle_size(malloc_count),
425 item_handle_addr(malloc_count), HANDLE_ADDR},
426 {"vmalloc_count", item_handle_size(vmalloc_count),
427 item_handle_addr(vmalloc_count), HANDLE_ADDR},
428 {"mbufalloc_count", item_handle_size(mbufalloc_count),
429 item_handle_addr(mbufalloc_count), HANDLE_ADDR},
430 #ifdef PCIE
431 {"malloc_cons_count", item_handle_size(malloc_cons_count),
432 item_handle_addr(malloc_cons_count), HANDLE_ADDR | (INTF_PCIE << 8)},
433 #endif
434 {"main_state", item_handle_size(main_state),
435 item_handle_addr(main_state), HANDLE_ADDR},
436 {"driver_state", item_handle_size(driver_state),
437 item_handle_addr(driver_state), HANDLE_ADDR},
438 #ifdef SDIO_MMC_DEBUG
439 {"sdiocmd53w", item_handle_size(cmd53w), item_handle_addr(cmd53w),
440 HANDLE_ADDR | (INTF_SD << 8)},
441 {"sdiocmd53r", item_handle_size(cmd53r), item_handle_addr(cmd53r),
442 HANDLE_ADDR | (INTF_SD << 8)},
443 #endif
444 {"hs_skip_count", item_handle_size(hs_skip_count),
445 item_handle_addr(hs_skip_count), HANDLE_ADDR},
446 {"hs_force_count", item_handle_size(hs_force_count),
447 item_handle_addr(hs_force_count), HANDLE_ADDR},
448 };
449 #endif /* UAP_SUPPORT */
450
451 /**
452 * @brief This function reset histogram data
453 *
454 * @param priv A pointer to moal_private
455 *
456 * @return N/A
457 */
woal_hist_do_reset(moal_private * priv,void * data)458 void woal_hist_do_reset(moal_private *priv, void *data)
459 {
460 hgm_data *phist_data = (hgm_data *)data;
461 int ix;
462 t_u16 rx_rate_max_size = priv->phandle->card_info->rx_rate_max;
463
464 if (!phist_data)
465 return;
466 atomic_set(&(phist_data->num_samples), 0);
467 for (ix = 0; ix < rx_rate_max_size; ix++)
468 atomic_set(&(phist_data->rx_rate[ix]), 0);
469 for (ix = 0; ix < SNR_MAX; ix++)
470 atomic_set(&(phist_data->snr[ix]), 0);
471 for (ix = 0; ix < NOISE_FLR_MAX; ix++)
472 atomic_set(&(phist_data->noise_flr[ix]), 0);
473 for (ix = 0; ix < SIG_STRENGTH_MAX; ix++)
474 atomic_set(&(phist_data->sig_str[ix]), 0);
475 }
476
477 /**
478 * @brief This function reset all histogram data
479 *
480 * @param priv A pointer to moal_private
481 *
482 * @return N/A
483 */
woal_hist_data_reset(moal_private * priv)484 void woal_hist_data_reset(moal_private *priv)
485 {
486 int i = 0;
487 for (i = 0; i < priv->phandle->card_info->histogram_table_num; i++)
488 woal_hist_do_reset(priv, priv->hist_data[i]);
489 }
490 /**
491 * @brief This function reset histogram data according to antenna
492 *
493 * @param priv A pointer to moal_private
494 *
495 * @return N/A
496 */
woal_hist_reset_table(moal_private * priv,t_u8 antenna)497 void woal_hist_reset_table(moal_private *priv, t_u8 antenna)
498 {
499 hgm_data *phist_data = priv->hist_data[antenna];
500
501 woal_hist_do_reset(priv, phist_data);
502 }
503
504 /** NF calculation */
505 #define CAL_NF(NF) ((t_s8)(-(t_s8)(NF)))
506 /** RSSI calculation */
507 #define CAL_RSSI(SNR, NF) ((t_s8)((t_s8)(SNR) + CAL_NF(NF)))
508
509 /**
510 * @brief This function set histogram data
511 *
512 * @param priv A pointer to moal_private
513 * @param rx_rate rx rate
514 * @param snr snr
515 * @param nflr NF
516 *
517 * @return N/A
518 */
woal_hist_data_set(moal_private * priv,t_u16 rx_rate,t_s8 snr,t_s8 nflr,t_u8 antenna)519 static void woal_hist_data_set(moal_private *priv, t_u16 rx_rate, t_s8 snr,
520 t_s8 nflr, t_u8 antenna)
521 {
522 hgm_data *phist_data = priv->hist_data[antenna];
523 t_s8 nf = CAL_NF(nflr);
524 t_s8 rssi = CAL_RSSI(snr, nflr);
525
526 atomic_inc(&(phist_data->num_samples));
527 if (rx_rate < priv->phandle->card_info->rx_rate_max)
528 atomic_inc(&(phist_data->rx_rate[rx_rate]));
529 atomic_inc(&(phist_data->snr[snr + 128]));
530 atomic_inc(&(phist_data->noise_flr[nf + 128]));
531 atomic_inc(&(phist_data->sig_str[rssi + 128]));
532 }
533
534 /**
535 * @brief This function add histogram data
536 *
537 * @param priv A pointer to moal_private
538 * @param rx_rate rx rate
539 * @param snr snr
540 * @param nflr NF
541 *
542 * @return N/A
543 */
woal_hist_data_add(moal_private * priv,t_u16 rx_rate,t_s8 snr,t_s8 nflr,t_u8 antenna)544 void woal_hist_data_add(moal_private *priv, t_u16 rx_rate, t_s8 snr, t_s8 nflr,
545 t_u8 antenna)
546 {
547 hgm_data *phist_data = NULL;
548 unsigned long curr_size;
549
550 if ((antenna + 1) > priv->phandle->card_info->histogram_table_num)
551 antenna = 0;
552 phist_data = priv->hist_data[antenna];
553 curr_size = atomic_read(&(phist_data->num_samples));
554 if (curr_size > HIST_MAX_SAMPLES)
555 woal_hist_reset_table(priv, antenna);
556 woal_hist_data_set(priv, rx_rate, snr, nflr, antenna);
557 }
558 #define MAX_MCS_NUM_SUPP 16
559 #define MAX_MCS_NUM_AC 10
560 #define MAX_MCS_NUM_AX 12
561 /**
562 * @brief histogram info in proc
563 *
564 * @param sfp pointer to seq_file structure
565 * @param data
566 *
567 * @return Number of output data or MLAN_STATUS_FAILURE
568 */
woal_histogram_info(struct seq_file * sfp,void * data)569 static int woal_histogram_info(struct seq_file *sfp, void *data)
570 {
571 hgm_data *phist_data = (hgm_data *)data;
572 int i = 0;
573 int value = 0;
574 t_bool sgi_enable = 0;
575 t_u8 bw = 0;
576 t_u8 mcs_index = 0;
577 t_u8 nss = 0;
578 t_u8 gi = 0;
579 wlan_hist_proc_data *hist_data = (wlan_hist_proc_data *)sfp->private;
580 moal_private *priv = (moal_private *)hist_data->priv;
581 t_u16 rx_rate_max_size = priv->phandle->card_info->rx_rate_max;
582
583 ENTER();
584 if (MODULE_GET == 0) {
585 LEAVE();
586 return -EFAULT;
587 }
588
589 seq_printf(sfp, "total samples = %d \n",
590 atomic_read(&(phist_data->num_samples)));
591 seq_printf(sfp, "rx rates (in Mbps):\n");
592 seq_printf(sfp, "\t0-3: B-MCS 0-3\n");
593 seq_printf(sfp, "\t4-11: G-MCS 0-7\n");
594 seq_printf(
595 sfp,
596 "\t12-27: N-MCS 0-15(BW20) 28-43: N-MCS 0-15(BW40)\n");
597 seq_printf(
598 sfp,
599 "\t44-59: N-MCS 0-15(BW20:SGI) 60-75: N-MCS 0-15(BW40:SGI)\n");
600 seq_printf(
601 sfp,
602 "\t76-85: AC-MCS 0-9(VHT:BW20:NSS1) 86-95: AC-MCS 0-9(VHT:BW20:NSS2)\n");
603 seq_printf(
604 sfp,
605 "\t96-105: AC-MCS 0-9(VHT:BW40:NSS1) 106-115: AC-MCS 0-9(VHT:BW40:NSS2)\n");
606 seq_printf(
607 sfp,
608 "\t116-125: AC-MCS 0-9(VHT:BW80:NSS1) 126-135: AC-MCS 0-9(VHT:BW80:NSS2)\n");
609 seq_printf(
610 sfp,
611 "\t136-145: AC-MCS 0-9(VHT:BW20:NSS1:SGI) 146-155: AC-MCS 0-9(VHT:BW20:NSS2:SGI)\n");
612 seq_printf(
613 sfp,
614 "\t156-165: AC-MCS 0-9(VHT:BW40:NSS1:SGI) 166-175: AC-MCS 0-9(VHT:BW40:NSS2:SGI)\n");
615 seq_printf(
616 sfp,
617 "\t176-185: AC-MCS 0-9(VHT:BW80:NSS1:SGI) 186-195: AC-MCS 0-9(VHT:BW80:NSS2:SGI)\n\n");
618 seq_printf(
619 sfp,
620 "\t196-207: AX-MCS 0-11(BW20:NSS1) 208-219: AX-MCS 0-11(BW20:NSS2)\n");
621 seq_printf(
622 sfp,
623 "\t220-231: AX-MCS 0-11(BW40:NSS1) 232-243: AX-MCS 0-11(BW40:NSS2)\n");
624 seq_printf(
625 sfp,
626 "\t244-255: AX-MCS 0-11(BW80:NSS1) 256-267: AX-MCS 0-11(BW80:NSS2)\n");
627 seq_printf(
628 sfp,
629 "\t268-279: AX-MCS 0-11(BW20:NSS1:GI1) 280-291: AX-MCS 0-11(BW20:NSS2:GI1)\n");
630 seq_printf(
631 sfp,
632 "\t292-303: AX-MCS 0-11(BW40:NSS1:GI1) 304-315: AX-MCS 0-11(BW40:NSS2:GI1)\n");
633 seq_printf(
634 sfp,
635 "\t316-327: AX-MCS 0-11(BW80:NSS1:GI1) 328-339: AX-MCS 0-11(BW80:NSS2:GI1)\n");
636 seq_printf(
637 sfp,
638 "\t340-351: AX-MCS 0-11(BW20:NSS1:GI2) 352-363: AX-MCS 0-11(BW20:NSS2:GI2)\n");
639 seq_printf(
640 sfp,
641 "\t364-375: AX-MCS 0-11(BW40:NSS1:GI2) 376-387: AX-MCS 0-11(BW40:NSS2:GI2)\n");
642 seq_printf(
643 sfp,
644 "\t388-399: AX-MCS 0-11(BW80:NSS1:GI2) 400-411: AX-MCS 0-11(BW80:NSS2:GI2)\n");
645
646 for (i = 0; i < rx_rate_max_size; i++) {
647 value = atomic_read(&(phist_data->rx_rate[i]));
648 if (value) {
649 if (i <= 11)
650 seq_printf(sfp, "rx_rate[%03d] = %d\n", i,
651 value);
652 else if (i <= 75) {
653 sgi_enable = (i - 12) /
654 (MAX_MCS_NUM_SUPP * 2); // 0:LGI,
655 // 1:SGI
656 bw = ((i - 12) % (MAX_MCS_NUM_SUPP * 2)) /
657 MAX_MCS_NUM_SUPP; // 0:20MHz, 1:40MHz
658 mcs_index = (i - 12) % MAX_MCS_NUM_SUPP;
659 seq_printf(
660 sfp,
661 "rx_rate[%03d] = %d (MCS:%d HT BW:%dMHz%s)\n",
662 i, value, mcs_index, (1 << bw) * 20,
663 sgi_enable ? " SGI" : "");
664 } else if (i <= 195) {
665 sgi_enable = (i - 76) /
666 (MAX_MCS_NUM_AC * 6); // 0:LGI,
667 // 1:SGI
668 bw = ((i - 76) % (MAX_MCS_NUM_AC * 6)) /
669 (MAX_MCS_NUM_AC * 2); // 0:20MHz, 1:40MHz,
670 // 2:80MHz
671 nss = (((i - 76) % (MAX_MCS_NUM_AC * 6)) %
672 (MAX_MCS_NUM_AC * 2)) /
673 MAX_MCS_NUM_AC; // 0:NSS1, 1:NSS2
674 mcs_index = (i - 76) % MAX_MCS_NUM_AC;
675
676 seq_printf(
677 sfp,
678 "rx_rate[%03d] = %d (MCS:%d VHT BW:%dMHz NSS:%d%s)\n",
679 i, value, mcs_index, (1 << bw) * 20,
680 nss + 1, sgi_enable ? " SGI" : "");
681 } else if (i <= 411) {
682 gi = (i - 196) / (MAX_MCS_NUM_AX * 6); // 0,1,2
683 bw = ((i - 196) % (MAX_MCS_NUM_AX * 6)) /
684 (MAX_MCS_NUM_AX * 2); // 0:20MHz, 1:40MHz,
685 // 2:80MHz
686 nss = (((i - 196) % (MAX_MCS_NUM_AX * 6)) %
687 (MAX_MCS_NUM_AX * 2)) /
688 MAX_MCS_NUM_AX; // 0:NSS1, 1:NSS2
689 mcs_index = (i - 196) % MAX_MCS_NUM_AX;
690
691 seq_printf(
692 sfp,
693 "rx_rate[%03d] = %d (MCS:%d AX BW:%dMHz NSS:%d GI:%d)\n",
694 i, value, mcs_index, (1 << bw) * 20,
695 nss + 1, gi);
696 }
697 }
698 }
699 for (i = 0; i < SNR_MAX; i++) {
700 value = atomic_read(&(phist_data->snr[i]));
701 if (value)
702 seq_printf(sfp, "snr[%02ddB] = %d\n", (int)(i - 128),
703 value);
704 }
705 for (i = 0; i < NOISE_FLR_MAX; i++) {
706 value = atomic_read(&(phist_data->noise_flr[i]));
707 if (value)
708 seq_printf(sfp, "noise_flr[%02ddBm] = %d\n",
709 (int)(i - 128), value);
710 }
711 for (i = 0; i < SIG_STRENGTH_MAX; i++) {
712 value = atomic_read(&(phist_data->sig_str[i]));
713 if (value)
714 seq_printf(sfp, "sig_strength[%02ddBm] = %d\n",
715 (int)(i - 128), value);
716 }
717
718 MODULE_PUT;
719 LEAVE();
720 return 0;
721 }
722
723 /**
724 * @brief Proc read function for histogram
725 *
726 * @param sfp pointer to seq_file structure
727 * @param data
728 *
729 * @return Number of output data or MLAN_STATUS_FAILURE
730 */
woal_histogram_read(struct seq_file * sfp,void * data)731 static int woal_histogram_read(struct seq_file *sfp, void *data)
732 {
733 wlan_hist_proc_data *hist_data = (wlan_hist_proc_data *)sfp->private;
734 moal_private *priv = (moal_private *)hist_data->priv;
735
736 ENTER();
737 if (!priv) {
738 LEAVE();
739 return -EFAULT;
740 }
741
742 if (hist_data->ant_idx < priv->phandle->card_info->histogram_table_num)
743 woal_histogram_info(sfp, priv->hist_data[hist_data->ant_idx]);
744
745 LEAVE();
746 return 0;
747 }
748
woal_histogram_proc_open(struct inode * inode,struct file * file)749 static int woal_histogram_proc_open(struct inode *inode, struct file *file)
750 {
751 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0)
752 return single_open(file, woal_histogram_read, pde_data(inode));
753 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)
754 return single_open(file, woal_histogram_read, PDE_DATA(inode));
755 #else
756 return single_open(file, woal_histogram_read, PDE(inode)->data);
757 #endif
758 }
759
760 /**
761 * @brief Proc write function for histogram
762 *
763 * @param f file pointer
764 * @param buf pointer to data buffer
765 * @param count data number to write
766 * @param off Offset
767 *
768 * @return number of data
769 */
woal_histogram_write(struct file * f,const char __user * buf,size_t count,loff_t * off)770 static ssize_t woal_histogram_write(struct file *f, const char __user *buf,
771 size_t count, loff_t *off)
772 {
773 struct seq_file *sfp = f->private_data;
774 wlan_hist_proc_data *hist_data = (wlan_hist_proc_data *)sfp->private;
775 moal_private *priv = (moal_private *)hist_data->priv;
776 woal_hist_reset_table(priv, hist_data->ant_idx);
777 return count;
778 }
779
780 /**
781 * @brief Proc read function for log
782 *
783 * @param sfp pointer to seq_file structure
784 * @param data
785 *
786 * @return Number of output data or MLAN_STATUS_FAILURE
787 */
woal_log_read(struct seq_file * sfp,void * data)788 static int woal_log_read(struct seq_file *sfp, void *data)
789 {
790 moal_private *priv = (moal_private *)sfp->private;
791 mlan_ds_get_stats stats;
792 int i = 0;
793 ENTER();
794 if (!priv) {
795 LEAVE();
796 return -EFAULT;
797 }
798 if (MODULE_GET == 0) {
799 LEAVE();
800 return -EFAULT;
801 }
802
803 memset(&stats, 0x00, sizeof(stats));
804 if (MLAN_STATUS_SUCCESS !=
805 woal_get_stats_info(priv, MOAL_IOCTL_WAIT, &stats)) {
806 PRINTM(MERROR,
807 "woal_log_read: Get log: Failed to get stats info!");
808 MODULE_PUT;
809 LEAVE();
810 return -EFAULT;
811 }
812
813 seq_printf(sfp, "dot11GroupTransmittedFrameCount = %d\n",
814 stats.mcast_tx_frame);
815 seq_printf(sfp, "dot11FailedCount = %d\n", stats.failed);
816 seq_printf(sfp, "dot11RetryCount = %d\n", stats.retry);
817 seq_printf(sfp, "dot11MultipleRetryCount = %d\n", stats.multi_retry);
818 seq_printf(sfp, "dot11FrameDuplicateCount = %d\n", stats.frame_dup);
819 seq_printf(sfp, "dot11RTSSuccessCount = %d\n", stats.rts_success);
820 seq_printf(sfp, "dot11RTSFailureCount = %d\n", stats.rts_failure);
821 seq_printf(sfp, "dot11ACKFailureCount = %d\n", stats.ack_failure);
822 seq_printf(sfp, "dot11ReceivedFragmentCount = %d\n", stats.rx_frag);
823 seq_printf(sfp, "dot11GroupReceivedFrameCount = %d\n",
824 stats.mcast_rx_frame);
825 seq_printf(sfp, "dot11FCSErrorCount = %d\n", stats.fcs_error);
826 seq_printf(sfp, "dot11TransmittedFrameCount = %d\n", stats.tx_frame);
827 seq_printf(sfp, "wepicverrcnt-1 = %d\n", stats.wep_icv_error[0]);
828 seq_printf(sfp, "wepicverrcnt-2 = %d\n", stats.wep_icv_error[1]);
829 seq_printf(sfp, "wepicverrcnt-3 = %d\n", stats.wep_icv_error[2]);
830 seq_printf(sfp, "wepicverrcnt-4 = %d\n", stats.wep_icv_error[3]);
831 seq_printf(sfp, "beaconReceivedCount = %d\n", stats.bcn_rcv_cnt);
832 seq_printf(sfp, "beaconMissedCount = %d\n", stats.bcn_miss_cnt);
833 if (stats.amsdu_rx_cnt)
834 seq_printf(sfp, "ReceivedMSDUinPerAMSDU = %d\n",
835 stats.msdu_in_rx_amsdu_cnt / stats.amsdu_rx_cnt);
836 seq_printf(sfp, "ReceivedMSDUinAMSDUCount = %d\n",
837 stats.msdu_in_rx_amsdu_cnt);
838 if (stats.amsdu_tx_cnt)
839 seq_printf(sfp, "TransmitMSDUinPerAMSDU = %d\n",
840 stats.msdu_in_tx_amsdu_cnt / stats.amsdu_tx_cnt);
841 seq_printf(sfp, "TransmitMSDUinAMSDUCount = %d\n",
842 stats.msdu_in_tx_amsdu_cnt);
843 if (priv->phandle->fw_getlog_enable) {
844 seq_printf(sfp, "dot11TransmittedFragmentCount = %u\n",
845 stats.tx_frag_cnt);
846 seq_printf(sfp, "dot11QosTransmittedFragmentCount = ");
847 for (i = 0; i < 8; i++) {
848 seq_printf(sfp, "%u ", stats.qos_tx_frag_cnt[i]);
849 }
850 seq_printf(sfp, "\ndot11QosFailedCount = ");
851 for (i = 0; i < 8; i++) {
852 seq_printf(sfp, "%u ", stats.qos_failed_cnt[i]);
853 }
854 seq_printf(sfp, "\ndot11QosRetryCount = ");
855 for (i = 0; i < 8; i++) {
856 seq_printf(sfp, "%u ", stats.qos_retry_cnt[i]);
857 }
858 seq_printf(sfp, "\ndot11QosMultipleRetryCount = ");
859 for (i = 0; i < 8; i++) {
860 seq_printf(sfp, "%u ", stats.qos_multi_retry_cnt[i]);
861 }
862 seq_printf(sfp, "\ndot11QosFrameDuplicateCount = ");
863 for (i = 0; i < 8; i++) {
864 seq_printf(sfp, "%u ", stats.qos_frm_dup_cnt[i]);
865 }
866 seq_printf(sfp, "\ndot11QosRTSSuccessCount = ");
867 for (i = 0; i < 8; i++) {
868 seq_printf(sfp, "%u ", stats.qos_rts_suc_cnt[i]);
869 }
870 seq_printf(sfp, "\ndot11QosRTSFailureCount = ");
871 for (i = 0; i < 8; i++) {
872 seq_printf(sfp, "%u ", stats.qos_rts_failure_cnt[i]);
873 }
874 seq_printf(sfp, "\ndot11QosACKFailureCount = ");
875 for (i = 0; i < 8; i++) {
876 seq_printf(sfp, "%u ", stats.qos_ack_failure_cnt[i]);
877 }
878 seq_printf(sfp, "\ndot11QosReceivedFragmentCount = ");
879 for (i = 0; i < 8; i++) {
880 seq_printf(sfp, "%u ", stats.qos_rx_frag_cnt[i]);
881 }
882 seq_printf(sfp, "\ndot11QosTransmittedFrameCount = ");
883 for (i = 0; i < 8; i++) {
884 seq_printf(sfp, "%u ", stats.qos_tx_frm_cnt[i]);
885 }
886 seq_printf(sfp, "\ndot11QosDiscardedFrameCount = ");
887 for (i = 0; i < 8; i++) {
888 seq_printf(sfp, "%u ", stats.qos_discarded_frm_cnt[i]);
889 }
890 seq_printf(sfp, "\ndot11QosMPDUsReceivedCount = ");
891 for (i = 0; i < 8; i++) {
892 seq_printf(sfp, "%u ", stats.qos_mpdus_rx_cnt[i]);
893 }
894 seq_printf(sfp, "\ndot11QosRetriesReceivedCount = ");
895 for (i = 0; i < 8; i++) {
896 seq_printf(sfp, "%u ", stats.qos_retries_rx_cnt[i]);
897 }
898 seq_printf(sfp,
899 "\ndot11RSNAStatsCMACICVErrors = %u\n"
900 "dot11RSNAStatsCMACReplays = %u\n"
901 "dot11RSNAStatsRobustMgmtCCMPReplays = %u\n"
902 "dot11RSNAStatsTKIPICVErrors = %u\n"
903 "dot11RSNAStatsTKIPReplays = %u\n"
904 "dot11RSNAStatsCCMPDecryptErrors = %u\n"
905 "dot11RSNAstatsCCMPReplays = %u\n"
906 "dot11TransmittedAMSDUCount = %u\n"
907 "dot11FailedAMSDUCount = %u\n"
908 "dot11RetryAMSDUCount = %u\n"
909 "dot11MultipleRetryAMSDUCount = %u\n"
910 "dot11TransmittedOctetsInAMSDUCount = %llu\n"
911 "dot11AMSDUAckFailureCount = %u\n"
912 "dot11ReceivedAMSDUCount = %u\n"
913 "dot11ReceivedOctetsInAMSDUCount = %llu\n"
914 "dot11TransmittedAMPDUCount = %u\n"
915 "dot11TransmittedMPDUsInAMPDUCount = %u\n"
916 "dot11TransmittedOctetsInAMPDUCount = %llu\n"
917 "dot11AMPDUReceivedCount = %u\n"
918 "dot11MPDUInReceivedAMPDUCount = %u\n"
919 "dot11ReceivedOctetsInAMPDUCount = %llu\n"
920 "dot11AMPDUDelimiterCRCErrorCount = %u\n",
921 stats.cmacicv_errors, stats.cmac_replays,
922 stats.mgmt_ccmp_replays, stats.tkipicv_errors,
923 stats.tkip_replays, stats.ccmp_decrypt_errors,
924 stats.ccmp_replays, stats.tx_amsdu_cnt,
925 stats.failed_amsdu_cnt, stats.retry_amsdu_cnt,
926 stats.multi_retry_amsdu_cnt,
927 stats.tx_octets_in_amsdu_cnt,
928 stats.amsdu_ack_failure_cnt, stats.rx_amsdu_cnt,
929 stats.rx_octets_in_amsdu_cnt, stats.tx_ampdu_cnt,
930 stats.tx_mpdus_in_ampdu_cnt,
931 stats.tx_octets_in_ampdu_cnt, stats.ampdu_rx_cnt,
932 stats.mpdu_in_rx_ampdu_cnt,
933 stats.rx_octets_in_ampdu_cnt,
934 stats.ampdu_delimiter_crc_error_cnt);
935 }
936
937 MODULE_PUT;
938 LEAVE();
939 return 0;
940 }
941
942 /**
943 * @brief Proc read function for log
944 *
945 * @param inode pointer to inode
946 * @param file file pointer
947 *
948 * @return number of data
949 */
woal_log_proc_open(struct inode * inode,struct file * file)950 static int woal_log_proc_open(struct inode *inode, struct file *file)
951 {
952 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0)
953 return single_open(file, woal_log_read, pde_data(inode));
954 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)
955 return single_open(file, woal_log_read, PDE_DATA(inode));
956 #else
957 return single_open(file, woal_log_read, PDE(inode)->data);
958 #endif
959 }
960
961 /********************************************************
962 Local Functions
963 ********************************************************/
964 /**
965 * @brief Proc read function
966 *
967 * @param sfp pointer to seq_file structure
968 * @param data
969 *
970 * @return Number of output data or MLAN_STATUS_FAILURE
971 */
woal_debug_read(struct seq_file * sfp,void * data)972 static int woal_debug_read(struct seq_file *sfp, void *data)
973 {
974 int val = 0;
975 unsigned int i;
976
977 struct debug_data_priv *items_priv =
978 (struct debug_data_priv *)sfp->private;
979 struct debug_data *d = items_priv->items;
980 moal_private *priv = items_priv->priv;
981 mlan_debug_info *info = NULL;
982 t_u32 intf_mask = INTF_MASK << 8;
983 unsigned int j;
984 #ifdef SDIO
985 t_u8 mp_aggr_pkt_limit = 0;
986 #endif
987
988 ENTER();
989
990 if (priv == NULL) {
991 LEAVE();
992 return -EFAULT;
993 }
994
995 info = &(priv->phandle->debug_info);
996
997 if (MODULE_GET == 0) {
998 LEAVE();
999 return -EFAULT;
1000 }
1001
1002 priv->phandle->driver_state = woal_check_driver_status(priv->phandle);
1003 /* Get debug information */
1004 if (woal_get_debug_info(priv, MOAL_IOCTL_WAIT, info))
1005 goto exit;
1006
1007 for (i = 0; i < (unsigned int)items_priv->num_of_items; i++) {
1008 /* If this item is interface specific but card interface is NOT
1009 * correspond type, we will not count it. */
1010 if ((d[i].attr & intf_mask) &&
1011 !((d[i].attr & intf_mask) &
1012 (priv->phandle->card_type & intf_mask)))
1013 continue;
1014
1015 if (d[i].size == 1)
1016 val = *((t_u8 *)d[i].addr);
1017 else if (d[i].size == 2)
1018 val = *((t_u16 *)d[i].addr);
1019 else if (d[i].size == 4)
1020 val = *((t_u32 *)d[i].addr);
1021 else {
1022 seq_printf(sfp, "%s=", d[i].name);
1023 for (j = 0; j < d[i].size; j += 2) {
1024 val = *(t_u16 *)(d[i].addr + j);
1025 seq_printf(sfp, "0x%x ", val);
1026 }
1027 seq_printf(sfp, "\n");
1028 continue;
1029 }
1030 if (strstr(d[i].name, "id") || strstr(d[i].name, "bitmap")
1031 #ifdef PCIE
1032 || strstr(d[i].name, "ptr")
1033 #endif
1034 )
1035 seq_printf(sfp, "%s=0x%x\n", d[i].name, val);
1036 else
1037 seq_printf(sfp, "%s=%d\n", d[i].name, val);
1038 }
1039 #ifdef SDIO
1040 if (IS_SD(priv->phandle->card_type)) {
1041 mp_aggr_pkt_limit = info->mp_aggr_pkt_limit;
1042 seq_printf(sfp, "last_recv_wr_bitmap=0x%x last_mp_index=%d\n",
1043 info->last_recv_wr_bitmap, info->last_mp_index);
1044 seq_printf(sfp,
1045 "last_recv_rd_bitmap=0x%x mp_data_port_mask=0x%x\n",
1046 info->last_recv_rd_bitmap, info->mp_data_port_mask);
1047 for (i = 0; i < SDIO_MP_DBG_NUM; i++) {
1048 seq_printf(
1049 sfp,
1050 "mp_wr_bitmap: 0x%x mp_wr_ports=0x%x len=%d curr_wr_port=0x%x\n",
1051 info->last_mp_wr_bitmap[i],
1052 info->last_mp_wr_ports[i],
1053 info->last_mp_wr_len[i],
1054 info->last_curr_wr_port[i]);
1055 for (j = 0; j < mp_aggr_pkt_limit; j++) {
1056 seq_printf(sfp, "0x%02x ",
1057 info->last_mp_wr_info
1058 [i * mp_aggr_pkt_limit + j]);
1059 }
1060 seq_printf(sfp, "\n");
1061 }
1062 seq_printf(sfp, "SDIO MPA Tx: ");
1063 for (i = 0; i < mp_aggr_pkt_limit; i++)
1064 seq_printf(sfp, "%d ", info->mpa_tx_count[i]);
1065 seq_printf(sfp, "\n");
1066 seq_printf(sfp, "SDIO MPA Rx: ");
1067 for (i = 0; i < mp_aggr_pkt_limit; i++)
1068 seq_printf(sfp, "%d ", info->mpa_rx_count[i]);
1069 seq_printf(sfp, "\n");
1070 seq_printf(sfp, "SDIO MP Update: ");
1071 for (i = 0; i < (mp_aggr_pkt_limit * 2); i++)
1072 seq_printf(sfp, "%d ", info->mp_update[i]);
1073 seq_printf(sfp, "\n");
1074 }
1075 #endif
1076 #ifdef PCIE
1077 if (IS_PCIE(priv->phandle->card_type)) {
1078 seq_printf(sfp, "txbd_rdptr=0x%x txbd_wrptr=0x%x\n",
1079 info->txbd_rdptr, info->txbd_wrptr);
1080 seq_printf(sfp, "rxbd_rdptr=0x%x rxbd_wrptr=0x%x\n",
1081 info->rxbd_rdptr, info->rxbd_wrptr);
1082 seq_printf(sfp, "eventbd_rdptr=0x%x event_wrptr=0x%x\n",
1083 info->eventbd_rdptr, info->eventbd_wrptr);
1084 seq_printf(sfp, "last_wr_index:%d\n",
1085 info->txbd_wrptr & (info->txrx_bd_size - 1));
1086 seq_printf(sfp, "txrx bd size:%d\n", info->txrx_bd_size);
1087 }
1088 #endif
1089 seq_printf(sfp, "tcp_ack_drop_cnt=%d\n", priv->tcp_ack_drop_cnt);
1090 seq_printf(sfp, "tcp_ack_cnt=%d\n", priv->tcp_ack_cnt);
1091 seq_printf(sfp, "tcp_ack_payload=%d\n", priv->tcp_ack_payload);
1092 #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 29)
1093 for (i = 0; i < 4; i++)
1094 seq_printf(sfp, "wmm_tx_pending[%d]:%d\n", i,
1095 atomic_read(&priv->wmm_tx_pending[i]));
1096 #endif
1097 if (info->tx_tbl_num) {
1098 seq_printf(sfp, "Tx BA stream table:\n");
1099 for (i = 0; i < info->tx_tbl_num; i++) {
1100 seq_printf(
1101 sfp,
1102 "tid = %d, ra = %02x:%02x:%02x:%02x:%02x:%02x amsdu=%d\n",
1103 (int)info->tx_tbl[i].tid, info->tx_tbl[i].ra[0],
1104 info->tx_tbl[i].ra[1], info->tx_tbl[i].ra[2],
1105 info->tx_tbl[i].ra[3], info->tx_tbl[i].ra[4],
1106 info->tx_tbl[i].ra[5],
1107 (int)info->tx_tbl[i].amsdu);
1108 }
1109 }
1110 if (info->rx_tbl_num) {
1111 seq_printf(sfp, "Rx reorder table:\n");
1112 for (i = 0; i < info->rx_tbl_num; i++) {
1113 seq_printf(
1114 sfp,
1115 "tid = %d, ta = %02x:%02x:%02x:%02x:%02x:%02x, start_win = %d, "
1116 "win_size = %d, amsdu=%d",
1117 (int)info->rx_tbl[i].tid, info->rx_tbl[i].ta[0],
1118 info->rx_tbl[i].ta[1], info->rx_tbl[i].ta[2],
1119 info->rx_tbl[i].ta[3], info->rx_tbl[i].ta[4],
1120 info->rx_tbl[i].ta[5],
1121 (int)info->rx_tbl[i].start_win,
1122 (int)info->rx_tbl[i].win_size,
1123 (int)info->rx_tbl[i].amsdu);
1124 seq_printf(sfp, "\n");
1125
1126 seq_printf(sfp, "buffer: ");
1127 for (j = 0; j < info->rx_tbl[i].win_size; j++) {
1128 if (info->rx_tbl[i].buffer[j] == MTRUE)
1129 seq_printf(sfp, "1 ");
1130 else
1131 seq_printf(sfp, "0 ");
1132 }
1133 seq_printf(sfp, "\n");
1134 }
1135 }
1136 for (i = 0; i < info->ralist_num; i++) {
1137 seq_printf(
1138 sfp,
1139 "ralist ra: %02x:%02x:%02x:%02x:%02x:%02x tid=%d pkts=%d pause=%d\n",
1140 info->ralist[i].ra[0], info->ralist[i].ra[1],
1141 info->ralist[i].ra[2], info->ralist[i].ra[3],
1142 info->ralist[i].ra[4], info->ralist[i].ra[5],
1143 info->ralist[i].tid, info->ralist[i].total_pkts,
1144 info->ralist[i].tx_pause);
1145 }
1146
1147 for (i = 0; i < info->tdls_peer_num; i++) {
1148 seq_printf(
1149 sfp,
1150 "tdls peer: %02x:%02x:%02x:%02x:%02x:%02x snr=%d nf=%d\n",
1151 info->tdls_peer_list[i].mac_addr[0],
1152 info->tdls_peer_list[i].mac_addr[1],
1153 info->tdls_peer_list[i].mac_addr[2],
1154 info->tdls_peer_list[i].mac_addr[3],
1155 info->tdls_peer_list[i].mac_addr[4],
1156 info->tdls_peer_list[i].mac_addr[5],
1157 info->tdls_peer_list[i].snr,
1158 -info->tdls_peer_list[i].nf);
1159 seq_printf(sfp, "htcap: ");
1160 for (j = 0; j < sizeof(IEEEtypes_HTCap_t); j++)
1161 seq_printf(sfp, "%02x ",
1162 info->tdls_peer_list[i].ht_cap[j]);
1163 seq_printf(sfp, "\nExtcap: ");
1164 for (j = 0; j < sizeof(IEEEtypes_ExtCap_t); j++)
1165 seq_printf(sfp, "%02x ",
1166 info->tdls_peer_list[i].ext_cap[j]);
1167 seq_printf(sfp, "\n");
1168 seq_printf(sfp, "vhtcap: ");
1169 for (j = 0; j < sizeof(IEEEtypes_VHTCap_t); j++)
1170 seq_printf(sfp, "%02x ",
1171 info->tdls_peer_list[i].vht_cap[j]);
1172 seq_printf(sfp, "\n");
1173 }
1174 exit:
1175 MODULE_PUT;
1176 LEAVE();
1177 return 0;
1178 }
1179
1180 /**
1181 * @brief Proc write function
1182 *
1183 * @param f file pointer
1184 * @param buf pointer to data buffer
1185 * @param count data number to write
1186 * @param off Offset
1187 *
1188 * @return number of data
1189 */
woal_debug_write(struct file * f,const char __user * buf,size_t count,loff_t * off)1190 static ssize_t woal_debug_write(struct file *f, const char __user *buf,
1191 size_t count, loff_t *off)
1192 {
1193 int r, i;
1194 char *pdata;
1195 char *p;
1196 char *p0;
1197 char *p1;
1198 char *p2;
1199 struct seq_file *sfp = f->private_data;
1200 struct debug_data_priv *items_priv =
1201 (struct debug_data_priv *)sfp->private;
1202 struct debug_data *d = items_priv->items;
1203 moal_private *priv = items_priv->priv;
1204 mlan_debug_info *info = &(priv->phandle->debug_info);
1205 #ifdef DEBUG_LEVEL1
1206 t_u32 last_drvdbg = drvdbg;
1207 #endif
1208 gfp_t flag;
1209
1210 ENTER();
1211
1212 if (MODULE_GET == 0) {
1213 LEAVE();
1214 return MLAN_STATUS_FAILURE;
1215 }
1216 flag = (in_atomic() || irqs_disabled()) ? GFP_ATOMIC : GFP_KERNEL;
1217 pdata = kzalloc(count + 1, flag);
1218 if (pdata == NULL) {
1219 MODULE_PUT;
1220 LEAVE();
1221 return 0;
1222 }
1223
1224 if (copy_from_user(pdata, buf, count)) {
1225 PRINTM(MERROR, "Copy from user failed\n");
1226 kfree(pdata);
1227 MODULE_PUT;
1228 LEAVE();
1229 return 0;
1230 }
1231 pdata[count] = '\0';
1232
1233 if (woal_get_debug_info(priv, MOAL_IOCTL_WAIT, info)) {
1234 kfree(pdata);
1235 MODULE_PUT;
1236 LEAVE();
1237 return 0;
1238 }
1239
1240 p0 = pdata;
1241 for (i = 0; i < items_priv->num_of_items; i++) {
1242 do {
1243 p = strstr(p0, d[i].name);
1244 if (p == NULL)
1245 break;
1246 p1 = strchr(p, '\n');
1247 if (p1 == NULL)
1248 break;
1249 p0 = p1++;
1250 p2 = strchr(p, '=');
1251 if (!p2)
1252 break;
1253 p2++;
1254 r = woal_string_to_number(p2);
1255 if (d[i].size == 1)
1256 *((t_u8 *)d[i].addr) = (t_u8)r;
1257 else if (d[i].size == 2)
1258 *((t_u16 *)d[i].addr) = (t_u16)r;
1259 else if (d[i].size == 4)
1260 *((t_u32 *)d[i].addr) = (t_u32)r;
1261 break;
1262 } while (MTRUE);
1263 }
1264 kfree(pdata);
1265
1266 #ifdef DEBUG_LEVEL1
1267 if (last_drvdbg != drvdbg)
1268 woal_set_drvdbg(priv, drvdbg);
1269 #endif
1270
1271 MODULE_PUT;
1272 LEAVE();
1273 return count;
1274 }
1275
woal_debug_proc_open(struct inode * inode,struct file * file)1276 static int woal_debug_proc_open(struct inode *inode, struct file *file)
1277 {
1278 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0)
1279 return single_open(file, woal_debug_read, pde_data(inode));
1280 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)
1281 return single_open(file, woal_debug_read, PDE_DATA(inode));
1282 #else
1283 return single_open(file, woal_debug_read, PDE(inode)->data);
1284 #endif
1285 }
1286
1287 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
1288 static const struct proc_ops debug_proc_fops = {
1289 .proc_open = woal_debug_proc_open,
1290 .proc_read = seq_read,
1291 .proc_lseek = seq_lseek,
1292 .proc_release = single_release,
1293 .proc_write = woal_debug_write,
1294 };
1295 #else
1296 static const struct file_operations debug_proc_fops = {
1297 .owner = THIS_MODULE,
1298 .open = woal_debug_proc_open,
1299 .read = seq_read,
1300 .llseek = seq_lseek,
1301 .release = single_release,
1302 .write = woal_debug_write,
1303 };
1304 #endif
1305
1306 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
1307 static const struct proc_ops histogram_proc_fops = {
1308 .proc_open = woal_histogram_proc_open,
1309 .proc_read = seq_read,
1310 .proc_lseek = seq_lseek,
1311 .proc_release = single_release,
1312 .proc_write = woal_histogram_write,
1313 };
1314 #else
1315 static const struct file_operations histogram_proc_fops = {
1316 .owner = THIS_MODULE,
1317 .open = woal_histogram_proc_open,
1318 .read = seq_read,
1319 .llseek = seq_lseek,
1320 .release = single_release,
1321 .write = woal_histogram_write,
1322 };
1323 #endif
1324
1325 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
1326 static const struct proc_ops log_proc_fops = {
1327 .proc_open = woal_log_proc_open,
1328 .proc_read = seq_read,
1329 .proc_lseek = seq_lseek,
1330 .proc_release = single_release,
1331 };
1332 #else
1333 static const struct file_operations log_proc_fops = {
1334 .owner = THIS_MODULE,
1335 .open = woal_log_proc_open,
1336 .read = seq_read,
1337 .llseek = seq_lseek,
1338 .release = single_release,
1339 };
1340 #endif
1341 /********************************************************
1342 Global Functions
1343 ********************************************************/
1344 /**
1345 * @brief Create debug proc file
1346 *
1347 * @param priv A pointer to a moal_private structure
1348 *
1349 * @return N/A
1350 */
woal_debug_entry(moal_private * priv)1351 void woal_debug_entry(moal_private *priv)
1352 {
1353 struct proc_dir_entry *r;
1354 int i;
1355 char hist_entry[50];
1356 struct debug_data *d = NULL;
1357
1358 ENTER();
1359
1360 if (priv->proc_entry == NULL) {
1361 LEAVE();
1362 return;
1363 }
1364
1365 #ifdef STA_SUPPORT
1366 if (GET_BSS_ROLE(priv) == MLAN_BSS_ROLE_STA) {
1367 priv->items_priv.items = kmalloc(sizeof(items), GFP_KERNEL);
1368 if (!priv->items_priv.items) {
1369 PRINTM(MERROR,
1370 "Failed to allocate memory for debug data\n");
1371 LEAVE();
1372 return;
1373 }
1374 moal_memcpy_ext(priv->phandle, priv->items_priv.items, items,
1375 sizeof(items), sizeof(items));
1376 priv->items_priv.num_of_items = ARRAY_SIZE(items);
1377 }
1378 #endif
1379 #ifdef UAP_SUPPORT
1380 if (GET_BSS_ROLE(priv) == MLAN_BSS_ROLE_UAP) {
1381 priv->items_priv.items = kmalloc(sizeof(uap_items), GFP_KERNEL);
1382 if (!priv->items_priv.items) {
1383 PRINTM(MERROR,
1384 "Failed to allocate memory for debug data\n");
1385 LEAVE();
1386 return;
1387 }
1388 moal_memcpy_ext(priv->phandle, priv->items_priv.items,
1389 uap_items, sizeof(uap_items),
1390 sizeof(uap_items));
1391 priv->items_priv.num_of_items = ARRAY_SIZE(uap_items);
1392 }
1393 #endif
1394
1395 priv->items_priv.priv = priv;
1396
1397 d = priv->items_priv.items;
1398 for (i = 0; i < priv->items_priv.num_of_items; i++) {
1399 if (IS_INFO_ADDR(d[i].attr))
1400 d[i].addr += (t_ptr) & (priv->phandle->debug_info);
1401 else if (IS_HANDLE_ADDR(d[i].attr))
1402 d[i].addr += (t_ptr)(priv->phandle);
1403 else if (IS_PRIV_ADDR(d[i].attr))
1404 d[i].addr += (t_ptr)(priv);
1405 else if (IS_CARD_ADDR(d[i].attr))
1406 d[i].addr += (t_ptr)(priv->phandle->card);
1407 }
1408
1409 /* Create proc entry */
1410 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
1411 r = proc_create_data("debug", 0644, priv->proc_entry, &debug_proc_fops,
1412 &priv->items_priv);
1413 if (r == NULL)
1414 #else
1415 r = create_proc_entry("debug", 0644, priv->proc_entry);
1416 if (r) {
1417 r->data = &priv->items_priv;
1418 r->proc_fops = &debug_proc_fops;
1419 } else
1420 #endif
1421 {
1422 PRINTM(MMSG, "Fail to create proc debug entry\n");
1423 LEAVE();
1424 return;
1425 }
1426 if (priv->bss_type == MLAN_BSS_TYPE_STA ||
1427 priv->bss_type == MLAN_BSS_TYPE_UAP) {
1428 priv->hist_entry = proc_mkdir("histogram", priv->proc_entry);
1429 if (!priv->hist_entry) {
1430 PRINTM(MERROR, "Fail to mkdir histogram!\n");
1431 LEAVE();
1432 return;
1433 }
1434 for (i = 0; i < priv->phandle->card_info->histogram_table_num;
1435 i++) {
1436 priv->hist_proc[i].ant_idx = i;
1437 priv->hist_proc[i].priv = priv;
1438 snprintf(hist_entry, sizeof(hist_entry), "wlan-ant%d",
1439 i);
1440 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
1441 r = proc_create_data(hist_entry, 0644, priv->hist_entry,
1442 &histogram_proc_fops,
1443 &priv->hist_proc[i]);
1444 if (r == NULL)
1445 #else
1446 r = create_proc_entry("histogram", 0644,
1447 priv->hist_entry);
1448 if (r) {
1449 r->data = &priv->hist_proc[i];
1450 r->proc_fops = &histogram_proc_fops;
1451 } else
1452 #endif
1453 {
1454 PRINTM(MMSG,
1455 "Fail to create proc histogram entry %s\n",
1456 hist_entry);
1457 LEAVE();
1458 return;
1459 }
1460 }
1461 }
1462
1463 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
1464 r = proc_create_data("log", 0644, priv->proc_entry, &log_proc_fops,
1465 priv);
1466 if (r == NULL)
1467 #else
1468 r = create_proc_entry("log", 0644, priv->proc_entry);
1469 if (r) {
1470 r->data = priv;
1471 r->proc_fops = &log_proc_fops;
1472 } else
1473 #endif
1474 {
1475 PRINTM(MMSG, "Fail to create proc log entry\n");
1476 LEAVE();
1477 return;
1478 }
1479
1480 LEAVE();
1481 }
1482
1483 /**
1484 * @brief Remove proc file
1485 *
1486 * @param priv A pointer to a moal_private structure
1487 *
1488 * @return N/A
1489 */
woal_debug_remove(moal_private * priv)1490 void woal_debug_remove(moal_private *priv)
1491 {
1492 char hist_entry[50];
1493 int i;
1494 ENTER();
1495
1496 kfree(priv->items_priv.items);
1497 /* Remove proc entry */
1498 remove_proc_entry("debug", priv->proc_entry);
1499 if (priv->bss_type == MLAN_BSS_TYPE_STA ||
1500 priv->bss_type == MLAN_BSS_TYPE_UAP) {
1501 for (i = 0; i < priv->phandle->card_info->histogram_table_num;
1502 i++) {
1503 snprintf(hist_entry, sizeof(hist_entry), "wlan-ant%d",
1504 i);
1505 remove_proc_entry(hist_entry, priv->hist_entry);
1506 }
1507 remove_proc_entry("histogram", priv->proc_entry);
1508 }
1509 remove_proc_entry("log", priv->proc_entry);
1510
1511 LEAVE();
1512 }
1513 #endif
1514