2 * Copyright (c) 2010-2011 Atheros Communications Inc.
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 static ssize_t
read_file_tgt_int_stats(struct file
*file
, char __user
*user_buf
,
20 size_t count
, loff_t
*ppos
)
22 struct ath9k_htc_priv
*priv
= file
->private_data
;
23 struct ath9k_htc_target_int_stats cmd_rsp
;
28 memset(&cmd_rsp
, 0, sizeof(cmd_rsp
));
30 ath9k_htc_ps_wakeup(priv
);
32 WMI_CMD(WMI_INT_STATS_CMDID
);
34 ath9k_htc_ps_restore(priv
);
38 ath9k_htc_ps_restore(priv
);
40 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
41 "%20s : %10u\n", "RX",
42 be32_to_cpu(cmd_rsp
.rx
));
44 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
45 "%20s : %10u\n", "RXORN",
46 be32_to_cpu(cmd_rsp
.rxorn
));
48 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
49 "%20s : %10u\n", "RXEOL",
50 be32_to_cpu(cmd_rsp
.rxeol
));
52 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
53 "%20s : %10u\n", "TXURN",
54 be32_to_cpu(cmd_rsp
.txurn
));
56 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
57 "%20s : %10u\n", "TXTO",
58 be32_to_cpu(cmd_rsp
.txto
));
60 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
61 "%20s : %10u\n", "CST",
62 be32_to_cpu(cmd_rsp
.cst
));
64 if (len
> sizeof(buf
))
67 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
70 static const struct file_operations fops_tgt_int_stats
= {
71 .read
= read_file_tgt_int_stats
,
74 .llseek
= default_llseek
,
77 static ssize_t
read_file_tgt_tx_stats(struct file
*file
, char __user
*user_buf
,
78 size_t count
, loff_t
*ppos
)
80 struct ath9k_htc_priv
*priv
= file
->private_data
;
81 struct ath9k_htc_target_tx_stats cmd_rsp
;
86 memset(&cmd_rsp
, 0, sizeof(cmd_rsp
));
88 ath9k_htc_ps_wakeup(priv
);
90 WMI_CMD(WMI_TX_STATS_CMDID
);
92 ath9k_htc_ps_restore(priv
);
96 ath9k_htc_ps_restore(priv
);
98 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
99 "%20s : %10u\n", "Xretries",
100 be32_to_cpu(cmd_rsp
.xretries
));
102 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
103 "%20s : %10u\n", "FifoErr",
104 be32_to_cpu(cmd_rsp
.fifoerr
));
106 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
107 "%20s : %10u\n", "Filtered",
108 be32_to_cpu(cmd_rsp
.filtered
));
110 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
111 "%20s : %10u\n", "TimerExp",
112 be32_to_cpu(cmd_rsp
.timer_exp
));
114 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
115 "%20s : %10u\n", "ShortRetries",
116 be32_to_cpu(cmd_rsp
.shortretries
));
118 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
119 "%20s : %10u\n", "LongRetries",
120 be32_to_cpu(cmd_rsp
.longretries
));
122 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
123 "%20s : %10u\n", "QueueNull",
124 be32_to_cpu(cmd_rsp
.qnull
));
126 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
127 "%20s : %10u\n", "EncapFail",
128 be32_to_cpu(cmd_rsp
.encap_fail
));
130 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
131 "%20s : %10u\n", "NoBuf",
132 be32_to_cpu(cmd_rsp
.nobuf
));
134 if (len
> sizeof(buf
))
137 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
140 static const struct file_operations fops_tgt_tx_stats
= {
141 .read
= read_file_tgt_tx_stats
,
143 .owner
= THIS_MODULE
,
144 .llseek
= default_llseek
,
147 static ssize_t
read_file_tgt_rx_stats(struct file
*file
, char __user
*user_buf
,
148 size_t count
, loff_t
*ppos
)
150 struct ath9k_htc_priv
*priv
= file
->private_data
;
151 struct ath9k_htc_target_rx_stats cmd_rsp
;
153 unsigned int len
= 0;
156 memset(&cmd_rsp
, 0, sizeof(cmd_rsp
));
158 ath9k_htc_ps_wakeup(priv
);
160 WMI_CMD(WMI_RX_STATS_CMDID
);
162 ath9k_htc_ps_restore(priv
);
166 ath9k_htc_ps_restore(priv
);
168 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
169 "%20s : %10u\n", "NoBuf",
170 be32_to_cpu(cmd_rsp
.nobuf
));
172 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
173 "%20s : %10u\n", "HostSend",
174 be32_to_cpu(cmd_rsp
.host_send
));
176 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
177 "%20s : %10u\n", "HostDone",
178 be32_to_cpu(cmd_rsp
.host_done
));
180 if (len
> sizeof(buf
))
183 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
186 static const struct file_operations fops_tgt_rx_stats
= {
187 .read
= read_file_tgt_rx_stats
,
189 .owner
= THIS_MODULE
,
190 .llseek
= default_llseek
,
193 static ssize_t
read_file_xmit(struct file
*file
, char __user
*user_buf
,
194 size_t count
, loff_t
*ppos
)
196 struct ath9k_htc_priv
*priv
= file
->private_data
;
198 unsigned int len
= 0;
200 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
201 "%20s : %10u\n", "Buffers queued",
202 priv
->debug
.tx_stats
.buf_queued
);
203 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
204 "%20s : %10u\n", "Buffers completed",
205 priv
->debug
.tx_stats
.buf_completed
);
206 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
207 "%20s : %10u\n", "SKBs queued",
208 priv
->debug
.tx_stats
.skb_queued
);
209 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
210 "%20s : %10u\n", "SKBs success",
211 priv
->debug
.tx_stats
.skb_success
);
212 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
213 "%20s : %10u\n", "SKBs failed",
214 priv
->debug
.tx_stats
.skb_failed
);
215 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
216 "%20s : %10u\n", "CAB queued",
217 priv
->debug
.tx_stats
.cab_queued
);
219 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
220 "%20s : %10u\n", "BE queued",
221 priv
->debug
.tx_stats
.queue_stats
[WME_AC_BE
]);
222 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
223 "%20s : %10u\n", "BK queued",
224 priv
->debug
.tx_stats
.queue_stats
[WME_AC_BK
]);
225 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
226 "%20s : %10u\n", "VI queued",
227 priv
->debug
.tx_stats
.queue_stats
[WME_AC_VI
]);
228 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
229 "%20s : %10u\n", "VO queued",
230 priv
->debug
.tx_stats
.queue_stats
[WME_AC_VO
]);
232 if (len
> sizeof(buf
))
235 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
238 static const struct file_operations fops_xmit
= {
239 .read
= read_file_xmit
,
241 .owner
= THIS_MODULE
,
242 .llseek
= default_llseek
,
245 void ath9k_htc_err_stat_rx(struct ath9k_htc_priv
*priv
,
246 struct ath_htc_rx_status
*rxs
)
248 #define RX_PHY_ERR_INC(c) priv->debug.rx_stats.err_phy_stats[c]++
250 if (rxs
->rs_status
& ATH9K_RXERR_CRC
)
251 priv
->debug
.rx_stats
.err_crc
++;
252 if (rxs
->rs_status
& ATH9K_RXERR_DECRYPT
)
253 priv
->debug
.rx_stats
.err_decrypt_crc
++;
254 if (rxs
->rs_status
& ATH9K_RXERR_MIC
)
255 priv
->debug
.rx_stats
.err_mic
++;
256 if (rxs
->rs_status
& ATH9K_RX_DELIM_CRC_PRE
)
257 priv
->debug
.rx_stats
.err_pre_delim
++;
258 if (rxs
->rs_status
& ATH9K_RX_DELIM_CRC_POST
)
259 priv
->debug
.rx_stats
.err_post_delim
++;
260 if (rxs
->rs_status
& ATH9K_RX_DECRYPT_BUSY
)
261 priv
->debug
.rx_stats
.err_decrypt_busy
++;
263 if (rxs
->rs_status
& ATH9K_RXERR_PHY
) {
264 priv
->debug
.rx_stats
.err_phy
++;
265 if (rxs
->rs_phyerr
< ATH9K_PHYERR_MAX
)
266 RX_PHY_ERR_INC(rxs
->rs_phyerr
);
269 #undef RX_PHY_ERR_INC
272 static ssize_t
read_file_recv(struct file
*file
, char __user
*user_buf
,
273 size_t count
, loff_t
*ppos
)
275 #define PHY_ERR(s, p) \
276 len += snprintf(buf + len, size - len, "%20s : %10u\n", s, \
277 priv->debug.rx_stats.err_phy_stats[p]);
279 struct ath9k_htc_priv
*priv
= file
->private_data
;
281 unsigned int len
= 0, size
= 1500;
284 buf
= kzalloc(size
, GFP_KERNEL
);
288 len
+= snprintf(buf
+ len
, size
- len
,
289 "%20s : %10u\n", "SKBs allocated",
290 priv
->debug
.rx_stats
.skb_allocated
);
291 len
+= snprintf(buf
+ len
, size
- len
,
292 "%20s : %10u\n", "SKBs completed",
293 priv
->debug
.rx_stats
.skb_completed
);
294 len
+= snprintf(buf
+ len
, size
- len
,
295 "%20s : %10u\n", "SKBs Dropped",
296 priv
->debug
.rx_stats
.skb_dropped
);
298 len
+= snprintf(buf
+ len
, size
- len
,
299 "%20s : %10u\n", "CRC ERR",
300 priv
->debug
.rx_stats
.err_crc
);
301 len
+= snprintf(buf
+ len
, size
- len
,
302 "%20s : %10u\n", "DECRYPT CRC ERR",
303 priv
->debug
.rx_stats
.err_decrypt_crc
);
304 len
+= snprintf(buf
+ len
, size
- len
,
305 "%20s : %10u\n", "MIC ERR",
306 priv
->debug
.rx_stats
.err_mic
);
307 len
+= snprintf(buf
+ len
, size
- len
,
308 "%20s : %10u\n", "PRE-DELIM CRC ERR",
309 priv
->debug
.rx_stats
.err_pre_delim
);
310 len
+= snprintf(buf
+ len
, size
- len
,
311 "%20s : %10u\n", "POST-DELIM CRC ERR",
312 priv
->debug
.rx_stats
.err_post_delim
);
313 len
+= snprintf(buf
+ len
, size
- len
,
314 "%20s : %10u\n", "DECRYPT BUSY ERR",
315 priv
->debug
.rx_stats
.err_decrypt_busy
);
316 len
+= snprintf(buf
+ len
, size
- len
,
317 "%20s : %10u\n", "TOTAL PHY ERR",
318 priv
->debug
.rx_stats
.err_phy
);
321 PHY_ERR("UNDERRUN", ATH9K_PHYERR_UNDERRUN
);
322 PHY_ERR("TIMING", ATH9K_PHYERR_TIMING
);
323 PHY_ERR("PARITY", ATH9K_PHYERR_PARITY
);
324 PHY_ERR("RATE", ATH9K_PHYERR_RATE
);
325 PHY_ERR("LENGTH", ATH9K_PHYERR_LENGTH
);
326 PHY_ERR("RADAR", ATH9K_PHYERR_RADAR
);
327 PHY_ERR("SERVICE", ATH9K_PHYERR_SERVICE
);
328 PHY_ERR("TOR", ATH9K_PHYERR_TOR
);
329 PHY_ERR("OFDM-TIMING", ATH9K_PHYERR_OFDM_TIMING
);
330 PHY_ERR("OFDM-SIGNAL-PARITY", ATH9K_PHYERR_OFDM_SIGNAL_PARITY
);
331 PHY_ERR("OFDM-RATE", ATH9K_PHYERR_OFDM_RATE_ILLEGAL
);
332 PHY_ERR("OFDM-LENGTH", ATH9K_PHYERR_OFDM_LENGTH_ILLEGAL
);
333 PHY_ERR("OFDM-POWER-DROP", ATH9K_PHYERR_OFDM_POWER_DROP
);
334 PHY_ERR("OFDM-SERVICE", ATH9K_PHYERR_OFDM_SERVICE
);
335 PHY_ERR("OFDM-RESTART", ATH9K_PHYERR_OFDM_RESTART
);
336 PHY_ERR("FALSE-RADAR-EXT", ATH9K_PHYERR_FALSE_RADAR_EXT
);
337 PHY_ERR("CCK-TIMING", ATH9K_PHYERR_CCK_TIMING
);
338 PHY_ERR("CCK-HEADER-CRC", ATH9K_PHYERR_CCK_HEADER_CRC
);
339 PHY_ERR("CCK-RATE", ATH9K_PHYERR_CCK_RATE_ILLEGAL
);
340 PHY_ERR("CCK-SERVICE", ATH9K_PHYERR_CCK_SERVICE
);
341 PHY_ERR("CCK-RESTART", ATH9K_PHYERR_CCK_RESTART
);
342 PHY_ERR("CCK-LENGTH", ATH9K_PHYERR_CCK_LENGTH_ILLEGAL
);
343 PHY_ERR("CCK-POWER-DROP", ATH9K_PHYERR_CCK_POWER_DROP
);
344 PHY_ERR("HT-CRC", ATH9K_PHYERR_HT_CRC_ERROR
);
345 PHY_ERR("HT-LENGTH", ATH9K_PHYERR_HT_LENGTH_ILLEGAL
);
346 PHY_ERR("HT-RATE", ATH9K_PHYERR_HT_RATE_ILLEGAL
);
351 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
359 static const struct file_operations fops_recv
= {
360 .read
= read_file_recv
,
362 .owner
= THIS_MODULE
,
363 .llseek
= default_llseek
,
366 static ssize_t
read_file_slot(struct file
*file
, char __user
*user_buf
,
367 size_t count
, loff_t
*ppos
)
369 struct ath9k_htc_priv
*priv
= file
->private_data
;
371 unsigned int len
= 0;
373 spin_lock_bh(&priv
->tx
.tx_lock
);
375 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, "TX slot bitmap : ");
377 len
+= bitmap_scnprintf(buf
+ len
, sizeof(buf
) - len
,
378 priv
->tx
.tx_slot
, MAX_TX_BUF_NUM
);
380 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, "\n");
382 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
384 bitmap_weight(priv
->tx
.tx_slot
, MAX_TX_BUF_NUM
));
386 spin_unlock_bh(&priv
->tx
.tx_lock
);
388 if (len
> sizeof(buf
))
391 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
394 static const struct file_operations fops_slot
= {
395 .read
= read_file_slot
,
397 .owner
= THIS_MODULE
,
398 .llseek
= default_llseek
,
401 static ssize_t
read_file_queue(struct file
*file
, char __user
*user_buf
,
402 size_t count
, loff_t
*ppos
)
404 struct ath9k_htc_priv
*priv
= file
->private_data
;
406 unsigned int len
= 0;
408 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, "%20s : %10u\n",
409 "Mgmt endpoint", skb_queue_len(&priv
->tx
.mgmt_ep_queue
));
411 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, "%20s : %10u\n",
412 "Cab endpoint", skb_queue_len(&priv
->tx
.cab_ep_queue
));
414 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, "%20s : %10u\n",
415 "Data BE endpoint", skb_queue_len(&priv
->tx
.data_be_queue
));
417 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, "%20s : %10u\n",
418 "Data BK endpoint", skb_queue_len(&priv
->tx
.data_bk_queue
));
420 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, "%20s : %10u\n",
421 "Data VI endpoint", skb_queue_len(&priv
->tx
.data_vi_queue
));
423 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, "%20s : %10u\n",
424 "Data VO endpoint", skb_queue_len(&priv
->tx
.data_vo_queue
));
426 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, "%20s : %10u\n",
427 "Failed queue", skb_queue_len(&priv
->tx
.tx_failed
));
429 spin_lock_bh(&priv
->tx
.tx_lock
);
430 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
, "%20s : %10u\n",
431 "Queued count", priv
->tx
.queued_cnt
);
432 spin_unlock_bh(&priv
->tx
.tx_lock
);
434 if (len
> sizeof(buf
))
437 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
441 static const struct file_operations fops_queue
= {
442 .read
= read_file_queue
,
444 .owner
= THIS_MODULE
,
445 .llseek
= default_llseek
,
448 static ssize_t
read_file_debug(struct file
*file
, char __user
*user_buf
,
449 size_t count
, loff_t
*ppos
)
451 struct ath9k_htc_priv
*priv
= file
->private_data
;
452 struct ath_common
*common
= ath9k_hw_common(priv
->ah
);
456 len
= sprintf(buf
, "0x%08x\n", common
->debug_mask
);
457 return simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
460 static ssize_t
write_file_debug(struct file
*file
, const char __user
*user_buf
,
461 size_t count
, loff_t
*ppos
)
463 struct ath9k_htc_priv
*priv
= file
->private_data
;
464 struct ath_common
*common
= ath9k_hw_common(priv
->ah
);
469 len
= min(count
, sizeof(buf
) - 1);
470 if (copy_from_user(buf
, user_buf
, len
))
474 if (strict_strtoul(buf
, 0, &mask
))
477 common
->debug_mask
= mask
;
481 static const struct file_operations fops_debug
= {
482 .read
= read_file_debug
,
483 .write
= write_file_debug
,
485 .owner
= THIS_MODULE
,
486 .llseek
= default_llseek
,
489 static ssize_t
read_file_base_eeprom(struct file
*file
, char __user
*user_buf
,
490 size_t count
, loff_t
*ppos
)
492 struct ath9k_htc_priv
*priv
= file
->private_data
;
493 struct ath_common
*common
= ath9k_hw_common(priv
->ah
);
494 struct base_eep_header
*pBase
= NULL
;
495 unsigned int len
= 0, size
= 1500;
500 * This can be done since all the 3 EEPROM families have the
501 * same base header upto a certain point, and we are interested in
502 * the data only upto that point.
505 if (AR_SREV_9271(priv
->ah
))
506 pBase
= (struct base_eep_header
*)
507 &priv
->ah
->eeprom
.map4k
.baseEepHeader
;
508 else if (priv
->ah
->hw_version
.usbdev
== AR9280_USB
)
509 pBase
= (struct base_eep_header
*)
510 &priv
->ah
->eeprom
.def
.baseEepHeader
;
511 else if (priv
->ah
->hw_version
.usbdev
== AR9287_USB
)
512 pBase
= (struct base_eep_header
*)
513 &priv
->ah
->eeprom
.map9287
.baseEepHeader
;
516 ath_err(common
, "Unknown EEPROM type\n");
520 buf
= kzalloc(size
, GFP_KERNEL
);
524 len
+= snprintf(buf
+ len
, size
- len
,
525 "%20s : %10d\n", "Major Version",
526 pBase
->version
>> 12);
527 len
+= snprintf(buf
+ len
, size
- len
,
528 "%20s : %10d\n", "Minor Version",
529 pBase
->version
& 0xFFF);
530 len
+= snprintf(buf
+ len
, size
- len
,
531 "%20s : %10d\n", "Checksum",
533 len
+= snprintf(buf
+ len
, size
- len
,
534 "%20s : %10d\n", "Length",
536 len
+= snprintf(buf
+ len
, size
- len
,
537 "%20s : %10d\n", "RegDomain1",
539 len
+= snprintf(buf
+ len
, size
- len
,
540 "%20s : %10d\n", "RegDomain2",
542 len
+= snprintf(buf
+ len
, size
- len
,
544 "TX Mask", pBase
->txMask
);
545 len
+= snprintf(buf
+ len
, size
- len
,
547 "RX Mask", pBase
->rxMask
);
548 len
+= snprintf(buf
+ len
, size
- len
,
551 !!(pBase
->opCapFlags
& AR5416_OPFLAGS_11A
));
552 len
+= snprintf(buf
+ len
, size
- len
,
555 !!(pBase
->opCapFlags
& AR5416_OPFLAGS_11G
));
556 len
+= snprintf(buf
+ len
, size
- len
,
559 !!(pBase
->opCapFlags
& AR5416_OPFLAGS_N_2G_HT20
));
560 len
+= snprintf(buf
+ len
, size
- len
,
563 !!(pBase
->opCapFlags
& AR5416_OPFLAGS_N_2G_HT40
));
564 len
+= snprintf(buf
+ len
, size
- len
,
567 !!(pBase
->opCapFlags
& AR5416_OPFLAGS_N_5G_HT20
));
568 len
+= snprintf(buf
+ len
, size
- len
,
571 !!(pBase
->opCapFlags
& AR5416_OPFLAGS_N_5G_HT40
));
572 len
+= snprintf(buf
+ len
, size
- len
,
575 !!(pBase
->eepMisc
& 0x01));
576 len
+= snprintf(buf
+ len
, size
- len
,
579 (pBase
->binBuildNumber
>> 24) & 0xFF);
580 len
+= snprintf(buf
+ len
, size
- len
,
583 (pBase
->binBuildNumber
>> 16) & 0xFF);
584 len
+= snprintf(buf
+ len
, size
- len
,
587 (pBase
->binBuildNumber
>> 8) & 0xFF);
590 * UB91 specific data.
592 if (AR_SREV_9271(priv
->ah
)) {
593 struct base_eep_header_4k
*pBase4k
=
594 &priv
->ah
->eeprom
.map4k
.baseEepHeader
;
596 len
+= snprintf(buf
+ len
, size
- len
,
599 pBase4k
->txGainType
);
603 * UB95 specific data.
605 if (priv
->ah
->hw_version
.usbdev
== AR9287_USB
) {
606 struct base_eep_ar9287_header
*pBase9287
=
607 &priv
->ah
->eeprom
.map9287
.baseEepHeader
;
609 len
+= snprintf(buf
+ len
, size
- len
,
611 "Power Table Offset",
612 pBase9287
->pwrTableOffset
);
614 len
+= snprintf(buf
+ len
, size
- len
,
616 "OpenLoop Power Ctrl",
617 pBase9287
->openLoopPwrCntl
);
620 len
+= snprintf(buf
+ len
, size
- len
, "%20s : %pM\n", "MacAddress",
625 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
631 static const struct file_operations fops_base_eeprom
= {
632 .read
= read_file_base_eeprom
,
634 .owner
= THIS_MODULE
,
635 .llseek
= default_llseek
,
638 static ssize_t
read_4k_modal_eeprom(struct file
*file
,
639 char __user
*user_buf
,
640 size_t count
, loff_t
*ppos
)
642 #define PR_EEP(_s, _val) \
644 len += snprintf(buf + len, size - len, "%20s : %10d\n", \
648 struct ath9k_htc_priv
*priv
= file
->private_data
;
649 struct modal_eep_4k_header
*pModal
= &priv
->ah
->eeprom
.map4k
.modalHeader
;
650 unsigned int len
= 0, size
= 2048;
654 buf
= kzalloc(size
, GFP_KERNEL
);
658 PR_EEP("Chain0 Ant. Control", pModal
->antCtrlChain
[0]);
659 PR_EEP("Ant. Common Control", pModal
->antCtrlCommon
);
660 PR_EEP("Chain0 Ant. Gain", pModal
->antennaGainCh
[0]);
661 PR_EEP("Switch Settle", pModal
->switchSettling
);
662 PR_EEP("Chain0 TxRxAtten", pModal
->txRxAttenCh
[0]);
663 PR_EEP("Chain0 RxTxMargin", pModal
->rxTxMarginCh
[0]);
664 PR_EEP("ADC Desired size", pModal
->adcDesiredSize
);
665 PR_EEP("PGA Desired size", pModal
->pgaDesiredSize
);
666 PR_EEP("Chain0 xlna Gain", pModal
->xlnaGainCh
[0]);
667 PR_EEP("txEndToXpaOff", pModal
->txEndToXpaOff
);
668 PR_EEP("txEndToRxOn", pModal
->txEndToRxOn
);
669 PR_EEP("txFrameToXpaOn", pModal
->txFrameToXpaOn
);
670 PR_EEP("CCA Threshold)", pModal
->thresh62
);
671 PR_EEP("Chain0 NF Threshold", pModal
->noiseFloorThreshCh
[0]);
672 PR_EEP("xpdGain", pModal
->xpdGain
);
673 PR_EEP("External PD", pModal
->xpd
);
674 PR_EEP("Chain0 I Coefficient", pModal
->iqCalICh
[0]);
675 PR_EEP("Chain0 Q Coefficient", pModal
->iqCalQCh
[0]);
676 PR_EEP("pdGainOverlap", pModal
->pdGainOverlap
);
677 PR_EEP("O/D Bias Version", pModal
->version
);
678 PR_EEP("CCK OutputBias", pModal
->ob_0
);
679 PR_EEP("BPSK OutputBias", pModal
->ob_1
);
680 PR_EEP("QPSK OutputBias", pModal
->ob_2
);
681 PR_EEP("16QAM OutputBias", pModal
->ob_3
);
682 PR_EEP("64QAM OutputBias", pModal
->ob_4
);
683 PR_EEP("CCK Driver1_Bias", pModal
->db1_0
);
684 PR_EEP("BPSK Driver1_Bias", pModal
->db1_1
);
685 PR_EEP("QPSK Driver1_Bias", pModal
->db1_2
);
686 PR_EEP("16QAM Driver1_Bias", pModal
->db1_3
);
687 PR_EEP("64QAM Driver1_Bias", pModal
->db1_4
);
688 PR_EEP("CCK Driver2_Bias", pModal
->db2_0
);
689 PR_EEP("BPSK Driver2_Bias", pModal
->db2_1
);
690 PR_EEP("QPSK Driver2_Bias", pModal
->db2_2
);
691 PR_EEP("16QAM Driver2_Bias", pModal
->db2_3
);
692 PR_EEP("64QAM Driver2_Bias", pModal
->db2_4
);
693 PR_EEP("xPA Bias Level", pModal
->xpaBiasLvl
);
694 PR_EEP("txFrameToDataStart", pModal
->txFrameToDataStart
);
695 PR_EEP("txFrameToPaOn", pModal
->txFrameToPaOn
);
696 PR_EEP("HT40 Power Inc.", pModal
->ht40PowerIncForPdadc
);
697 PR_EEP("Chain0 bswAtten", pModal
->bswAtten
[0]);
698 PR_EEP("Chain0 bswMargin", pModal
->bswMargin
[0]);
699 PR_EEP("HT40 Switch Settle", pModal
->swSettleHt40
);
700 PR_EEP("Chain0 xatten2Db", pModal
->xatten2Db
[0]);
701 PR_EEP("Chain0 xatten2Margin", pModal
->xatten2Margin
[0]);
702 PR_EEP("Ant. Diversity ctl1", pModal
->antdiv_ctl1
);
703 PR_EEP("Ant. Diversity ctl2", pModal
->antdiv_ctl2
);
704 PR_EEP("TX Diversity", pModal
->tx_diversity
);
709 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
717 static ssize_t
read_def_modal_eeprom(struct file
*file
,
718 char __user
*user_buf
,
719 size_t count
, loff_t
*ppos
)
721 #define PR_EEP(_s, _val) \
723 if (pBase->opCapFlags & AR5416_OPFLAGS_11G) { \
724 pModal = &priv->ah->eeprom.def.modalHeader[1]; \
725 len += snprintf(buf + len, size - len, "%20s : %8d%7s", \
728 if (pBase->opCapFlags & AR5416_OPFLAGS_11A) { \
729 pModal = &priv->ah->eeprom.def.modalHeader[0]; \
730 len += snprintf(buf + len, size - len, "%9d\n", \
735 struct ath9k_htc_priv
*priv
= file
->private_data
;
736 struct base_eep_header
*pBase
= &priv
->ah
->eeprom
.def
.baseEepHeader
;
737 struct modal_eep_header
*pModal
= NULL
;
738 unsigned int len
= 0, size
= 3500;
742 buf
= kzalloc(size
, GFP_KERNEL
);
746 len
+= snprintf(buf
+ len
, size
- len
,
747 "%31s %15s\n", "2G", "5G");
748 len
+= snprintf(buf
+ len
, size
- len
,
749 "%32s %16s\n", "====", "====\n");
751 PR_EEP("Chain0 Ant. Control", pModal
->antCtrlChain
[0]);
752 PR_EEP("Chain1 Ant. Control", pModal
->antCtrlChain
[1]);
753 PR_EEP("Chain2 Ant. Control", pModal
->antCtrlChain
[2]);
754 PR_EEP("Ant. Common Control", pModal
->antCtrlCommon
);
755 PR_EEP("Chain0 Ant. Gain", pModal
->antennaGainCh
[0]);
756 PR_EEP("Chain1 Ant. Gain", pModal
->antennaGainCh
[1]);
757 PR_EEP("Chain2 Ant. Gain", pModal
->antennaGainCh
[2]);
758 PR_EEP("Switch Settle", pModal
->switchSettling
);
759 PR_EEP("Chain0 TxRxAtten", pModal
->txRxAttenCh
[0]);
760 PR_EEP("Chain1 TxRxAtten", pModal
->txRxAttenCh
[1]);
761 PR_EEP("Chain2 TxRxAtten", pModal
->txRxAttenCh
[2]);
762 PR_EEP("Chain0 RxTxMargin", pModal
->rxTxMarginCh
[0]);
763 PR_EEP("Chain1 RxTxMargin", pModal
->rxTxMarginCh
[1]);
764 PR_EEP("Chain2 RxTxMargin", pModal
->rxTxMarginCh
[2]);
765 PR_EEP("ADC Desired size", pModal
->adcDesiredSize
);
766 PR_EEP("PGA Desired size", pModal
->pgaDesiredSize
);
767 PR_EEP("Chain0 xlna Gain", pModal
->xlnaGainCh
[0]);
768 PR_EEP("Chain1 xlna Gain", pModal
->xlnaGainCh
[1]);
769 PR_EEP("Chain2 xlna Gain", pModal
->xlnaGainCh
[2]);
770 PR_EEP("txEndToXpaOff", pModal
->txEndToXpaOff
);
771 PR_EEP("txEndToRxOn", pModal
->txEndToRxOn
);
772 PR_EEP("txFrameToXpaOn", pModal
->txFrameToXpaOn
);
773 PR_EEP("CCA Threshold)", pModal
->thresh62
);
774 PR_EEP("Chain0 NF Threshold", pModal
->noiseFloorThreshCh
[0]);
775 PR_EEP("Chain1 NF Threshold", pModal
->noiseFloorThreshCh
[1]);
776 PR_EEP("Chain2 NF Threshold", pModal
->noiseFloorThreshCh
[2]);
777 PR_EEP("xpdGain", pModal
->xpdGain
);
778 PR_EEP("External PD", pModal
->xpd
);
779 PR_EEP("Chain0 I Coefficient", pModal
->iqCalICh
[0]);
780 PR_EEP("Chain1 I Coefficient", pModal
->iqCalICh
[1]);
781 PR_EEP("Chain2 I Coefficient", pModal
->iqCalICh
[2]);
782 PR_EEP("Chain0 Q Coefficient", pModal
->iqCalQCh
[0]);
783 PR_EEP("Chain1 Q Coefficient", pModal
->iqCalQCh
[1]);
784 PR_EEP("Chain2 Q Coefficient", pModal
->iqCalQCh
[2]);
785 PR_EEP("pdGainOverlap", pModal
->pdGainOverlap
);
786 PR_EEP("Chain0 OutputBias", pModal
->ob
);
787 PR_EEP("Chain0 DriverBias", pModal
->db
);
788 PR_EEP("xPA Bias Level", pModal
->xpaBiasLvl
);
789 PR_EEP("2chain pwr decrease", pModal
->pwrDecreaseFor2Chain
);
790 PR_EEP("3chain pwr decrease", pModal
->pwrDecreaseFor3Chain
);
791 PR_EEP("txFrameToDataStart", pModal
->txFrameToDataStart
);
792 PR_EEP("txFrameToPaOn", pModal
->txFrameToPaOn
);
793 PR_EEP("HT40 Power Inc.", pModal
->ht40PowerIncForPdadc
);
794 PR_EEP("Chain0 bswAtten", pModal
->bswAtten
[0]);
795 PR_EEP("Chain1 bswAtten", pModal
->bswAtten
[1]);
796 PR_EEP("Chain2 bswAtten", pModal
->bswAtten
[2]);
797 PR_EEP("Chain0 bswMargin", pModal
->bswMargin
[0]);
798 PR_EEP("Chain1 bswMargin", pModal
->bswMargin
[1]);
799 PR_EEP("Chain2 bswMargin", pModal
->bswMargin
[2]);
800 PR_EEP("HT40 Switch Settle", pModal
->swSettleHt40
);
801 PR_EEP("Chain0 xatten2Db", pModal
->xatten2Db
[0]);
802 PR_EEP("Chain1 xatten2Db", pModal
->xatten2Db
[1]);
803 PR_EEP("Chain2 xatten2Db", pModal
->xatten2Db
[2]);
804 PR_EEP("Chain0 xatten2Margin", pModal
->xatten2Margin
[0]);
805 PR_EEP("Chain1 xatten2Margin", pModal
->xatten2Margin
[1]);
806 PR_EEP("Chain2 xatten2Margin", pModal
->xatten2Margin
[2]);
807 PR_EEP("Chain1 OutputBias", pModal
->ob_ch1
);
808 PR_EEP("Chain1 DriverBias", pModal
->db_ch1
);
809 PR_EEP("LNA Control", pModal
->lna_ctl
);
810 PR_EEP("XPA Bias Freq0", pModal
->xpaBiasLvlFreq
[0]);
811 PR_EEP("XPA Bias Freq1", pModal
->xpaBiasLvlFreq
[1]);
812 PR_EEP("XPA Bias Freq2", pModal
->xpaBiasLvlFreq
[2]);
817 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
825 static ssize_t
read_9287_modal_eeprom(struct file
*file
,
826 char __user
*user_buf
,
827 size_t count
, loff_t
*ppos
)
829 #define PR_EEP(_s, _val) \
831 len += snprintf(buf + len, size - len, "%20s : %10d\n", \
835 struct ath9k_htc_priv
*priv
= file
->private_data
;
836 struct modal_eep_ar9287_header
*pModal
= &priv
->ah
->eeprom
.map9287
.modalHeader
;
837 unsigned int len
= 0, size
= 3000;
841 buf
= kzalloc(size
, GFP_KERNEL
);
845 PR_EEP("Chain0 Ant. Control", pModal
->antCtrlChain
[0]);
846 PR_EEP("Chain1 Ant. Control", pModal
->antCtrlChain
[1]);
847 PR_EEP("Ant. Common Control", pModal
->antCtrlCommon
);
848 PR_EEP("Chain0 Ant. Gain", pModal
->antennaGainCh
[0]);
849 PR_EEP("Chain1 Ant. Gain", pModal
->antennaGainCh
[1]);
850 PR_EEP("Switch Settle", pModal
->switchSettling
);
851 PR_EEP("Chain0 TxRxAtten", pModal
->txRxAttenCh
[0]);
852 PR_EEP("Chain1 TxRxAtten", pModal
->txRxAttenCh
[1]);
853 PR_EEP("Chain0 RxTxMargin", pModal
->rxTxMarginCh
[0]);
854 PR_EEP("Chain1 RxTxMargin", pModal
->rxTxMarginCh
[1]);
855 PR_EEP("ADC Desired size", pModal
->adcDesiredSize
);
856 PR_EEP("txEndToXpaOff", pModal
->txEndToXpaOff
);
857 PR_EEP("txEndToRxOn", pModal
->txEndToRxOn
);
858 PR_EEP("txFrameToXpaOn", pModal
->txFrameToXpaOn
);
859 PR_EEP("CCA Threshold)", pModal
->thresh62
);
860 PR_EEP("Chain0 NF Threshold", pModal
->noiseFloorThreshCh
[0]);
861 PR_EEP("Chain1 NF Threshold", pModal
->noiseFloorThreshCh
[1]);
862 PR_EEP("xpdGain", pModal
->xpdGain
);
863 PR_EEP("External PD", pModal
->xpd
);
864 PR_EEP("Chain0 I Coefficient", pModal
->iqCalICh
[0]);
865 PR_EEP("Chain1 I Coefficient", pModal
->iqCalICh
[1]);
866 PR_EEP("Chain0 Q Coefficient", pModal
->iqCalQCh
[0]);
867 PR_EEP("Chain1 Q Coefficient", pModal
->iqCalQCh
[1]);
868 PR_EEP("pdGainOverlap", pModal
->pdGainOverlap
);
869 PR_EEP("xPA Bias Level", pModal
->xpaBiasLvl
);
870 PR_EEP("txFrameToDataStart", pModal
->txFrameToDataStart
);
871 PR_EEP("txFrameToPaOn", pModal
->txFrameToPaOn
);
872 PR_EEP("HT40 Power Inc.", pModal
->ht40PowerIncForPdadc
);
873 PR_EEP("Chain0 bswAtten", pModal
->bswAtten
[0]);
874 PR_EEP("Chain1 bswAtten", pModal
->bswAtten
[1]);
875 PR_EEP("Chain0 bswMargin", pModal
->bswMargin
[0]);
876 PR_EEP("Chain1 bswMargin", pModal
->bswMargin
[1]);
877 PR_EEP("HT40 Switch Settle", pModal
->swSettleHt40
);
878 PR_EEP("AR92x7 Version", pModal
->version
);
879 PR_EEP("DriverBias1", pModal
->db1
);
880 PR_EEP("DriverBias2", pModal
->db1
);
881 PR_EEP("CCK OutputBias", pModal
->ob_cck
);
882 PR_EEP("PSK OutputBias", pModal
->ob_psk
);
883 PR_EEP("QAM OutputBias", pModal
->ob_qam
);
884 PR_EEP("PAL_OFF OutputBias", pModal
->ob_pal_off
);
889 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
897 static ssize_t
read_file_modal_eeprom(struct file
*file
, char __user
*user_buf
,
898 size_t count
, loff_t
*ppos
)
900 struct ath9k_htc_priv
*priv
= file
->private_data
;
902 if (AR_SREV_9271(priv
->ah
))
903 return read_4k_modal_eeprom(file
, user_buf
, count
, ppos
);
904 else if (priv
->ah
->hw_version
.usbdev
== AR9280_USB
)
905 return read_def_modal_eeprom(file
, user_buf
, count
, ppos
);
906 else if (priv
->ah
->hw_version
.usbdev
== AR9287_USB
)
907 return read_9287_modal_eeprom(file
, user_buf
, count
, ppos
);
912 static const struct file_operations fops_modal_eeprom
= {
913 .read
= read_file_modal_eeprom
,
915 .owner
= THIS_MODULE
,
916 .llseek
= default_llseek
,
919 int ath9k_htc_init_debug(struct ath_hw
*ah
)
921 struct ath_common
*common
= ath9k_hw_common(ah
);
922 struct ath9k_htc_priv
*priv
= (struct ath9k_htc_priv
*) common
->priv
;
924 priv
->debug
.debugfs_phy
= debugfs_create_dir(KBUILD_MODNAME
,
925 priv
->hw
->wiphy
->debugfsdir
);
926 if (!priv
->debug
.debugfs_phy
)
929 debugfs_create_file("tgt_int_stats", S_IRUSR
, priv
->debug
.debugfs_phy
,
930 priv
, &fops_tgt_int_stats
);
931 debugfs_create_file("tgt_tx_stats", S_IRUSR
, priv
->debug
.debugfs_phy
,
932 priv
, &fops_tgt_tx_stats
);
933 debugfs_create_file("tgt_rx_stats", S_IRUSR
, priv
->debug
.debugfs_phy
,
934 priv
, &fops_tgt_rx_stats
);
935 debugfs_create_file("xmit", S_IRUSR
, priv
->debug
.debugfs_phy
,
937 debugfs_create_file("recv", S_IRUSR
, priv
->debug
.debugfs_phy
,
939 debugfs_create_file("slot", S_IRUSR
, priv
->debug
.debugfs_phy
,
941 debugfs_create_file("queue", S_IRUSR
, priv
->debug
.debugfs_phy
,
943 debugfs_create_file("debug", S_IRUSR
| S_IWUSR
, priv
->debug
.debugfs_phy
,
945 debugfs_create_file("base_eeprom", S_IRUSR
, priv
->debug
.debugfs_phy
,
946 priv
, &fops_base_eeprom
);
947 debugfs_create_file("modal_eeprom", S_IRUSR
, priv
->debug
.debugfs_phy
,
948 priv
, &fops_modal_eeprom
);