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