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
[IEEE80211_AC_BE
]);
222 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
223 "%20s : %10u\n", "BK queued",
224 priv
->debug
.tx_stats
.queue_stats
[IEEE80211_AC_BK
]);
225 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
226 "%20s : %10u\n", "VI queued",
227 priv
->debug
.tx_stats
.queue_stats
[IEEE80211_AC_VI
]);
228 len
+= snprintf(buf
+ len
, sizeof(buf
) - len
,
229 "%20s : %10u\n", "VO queued",
230 priv
->debug
.tx_stats
.queue_stats
[IEEE80211_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 (kstrtoul(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;
499 pBase
= ath9k_htc_get_eeprom_base(priv
);
502 ath_err(common
, "Unknown EEPROM type\n");
506 buf
= kzalloc(size
, GFP_KERNEL
);
510 len
+= snprintf(buf
+ len
, size
- len
,
511 "%20s : %10d\n", "Major Version",
512 pBase
->version
>> 12);
513 len
+= snprintf(buf
+ len
, size
- len
,
514 "%20s : %10d\n", "Minor Version",
515 pBase
->version
& 0xFFF);
516 len
+= snprintf(buf
+ len
, size
- len
,
517 "%20s : %10d\n", "Checksum",
519 len
+= snprintf(buf
+ len
, size
- len
,
520 "%20s : %10d\n", "Length",
522 len
+= snprintf(buf
+ len
, size
- len
,
523 "%20s : %10d\n", "RegDomain1",
525 len
+= snprintf(buf
+ len
, size
- len
,
526 "%20s : %10d\n", "RegDomain2",
528 len
+= snprintf(buf
+ len
, size
- len
,
530 "TX Mask", pBase
->txMask
);
531 len
+= snprintf(buf
+ len
, size
- len
,
533 "RX Mask", pBase
->rxMask
);
534 len
+= snprintf(buf
+ len
, size
- len
,
537 !!(pBase
->opCapFlags
& AR5416_OPFLAGS_11A
));
538 len
+= snprintf(buf
+ len
, size
- len
,
541 !!(pBase
->opCapFlags
& AR5416_OPFLAGS_11G
));
542 len
+= snprintf(buf
+ len
, size
- len
,
545 !!(pBase
->opCapFlags
& AR5416_OPFLAGS_N_2G_HT20
));
546 len
+= snprintf(buf
+ len
, size
- len
,
549 !!(pBase
->opCapFlags
& AR5416_OPFLAGS_N_2G_HT40
));
550 len
+= snprintf(buf
+ len
, size
- len
,
553 !!(pBase
->opCapFlags
& AR5416_OPFLAGS_N_5G_HT20
));
554 len
+= snprintf(buf
+ len
, size
- len
,
557 !!(pBase
->opCapFlags
& AR5416_OPFLAGS_N_5G_HT40
));
558 len
+= snprintf(buf
+ len
, size
- len
,
561 !!(pBase
->eepMisc
& 0x01));
562 len
+= snprintf(buf
+ len
, size
- len
,
565 (pBase
->binBuildNumber
>> 24) & 0xFF);
566 len
+= snprintf(buf
+ len
, size
- len
,
569 (pBase
->binBuildNumber
>> 16) & 0xFF);
570 len
+= snprintf(buf
+ len
, size
- len
,
573 (pBase
->binBuildNumber
>> 8) & 0xFF);
576 * UB91 specific data.
578 if (AR_SREV_9271(priv
->ah
)) {
579 struct base_eep_header_4k
*pBase4k
=
580 &priv
->ah
->eeprom
.map4k
.baseEepHeader
;
582 len
+= snprintf(buf
+ len
, size
- len
,
585 pBase4k
->txGainType
);
589 * UB95 specific data.
591 if (priv
->ah
->hw_version
.usbdev
== AR9287_USB
) {
592 struct base_eep_ar9287_header
*pBase9287
=
593 &priv
->ah
->eeprom
.map9287
.baseEepHeader
;
595 len
+= snprintf(buf
+ len
, size
- len
,
597 "Power Table Offset",
598 pBase9287
->pwrTableOffset
);
600 len
+= snprintf(buf
+ len
, size
- len
,
602 "OpenLoop Power Ctrl",
603 pBase9287
->openLoopPwrCntl
);
606 len
+= snprintf(buf
+ len
, size
- len
, "%20s : %pM\n", "MacAddress",
611 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
617 static const struct file_operations fops_base_eeprom
= {
618 .read
= read_file_base_eeprom
,
620 .owner
= THIS_MODULE
,
621 .llseek
= default_llseek
,
624 static ssize_t
read_4k_modal_eeprom(struct file
*file
,
625 char __user
*user_buf
,
626 size_t count
, loff_t
*ppos
)
628 #define PR_EEP(_s, _val) \
630 len += snprintf(buf + len, size - len, "%20s : %10d\n", \
634 struct ath9k_htc_priv
*priv
= file
->private_data
;
635 struct modal_eep_4k_header
*pModal
= &priv
->ah
->eeprom
.map4k
.modalHeader
;
636 unsigned int len
= 0, size
= 2048;
640 buf
= kzalloc(size
, GFP_KERNEL
);
644 PR_EEP("Chain0 Ant. Control", pModal
->antCtrlChain
[0]);
645 PR_EEP("Ant. Common Control", pModal
->antCtrlCommon
);
646 PR_EEP("Chain0 Ant. Gain", pModal
->antennaGainCh
[0]);
647 PR_EEP("Switch Settle", pModal
->switchSettling
);
648 PR_EEP("Chain0 TxRxAtten", pModal
->txRxAttenCh
[0]);
649 PR_EEP("Chain0 RxTxMargin", pModal
->rxTxMarginCh
[0]);
650 PR_EEP("ADC Desired size", pModal
->adcDesiredSize
);
651 PR_EEP("PGA Desired size", pModal
->pgaDesiredSize
);
652 PR_EEP("Chain0 xlna Gain", pModal
->xlnaGainCh
[0]);
653 PR_EEP("txEndToXpaOff", pModal
->txEndToXpaOff
);
654 PR_EEP("txEndToRxOn", pModal
->txEndToRxOn
);
655 PR_EEP("txFrameToXpaOn", pModal
->txFrameToXpaOn
);
656 PR_EEP("CCA Threshold)", pModal
->thresh62
);
657 PR_EEP("Chain0 NF Threshold", pModal
->noiseFloorThreshCh
[0]);
658 PR_EEP("xpdGain", pModal
->xpdGain
);
659 PR_EEP("External PD", pModal
->xpd
);
660 PR_EEP("Chain0 I Coefficient", pModal
->iqCalICh
[0]);
661 PR_EEP("Chain0 Q Coefficient", pModal
->iqCalQCh
[0]);
662 PR_EEP("pdGainOverlap", pModal
->pdGainOverlap
);
663 PR_EEP("O/D Bias Version", pModal
->version
);
664 PR_EEP("CCK OutputBias", pModal
->ob_0
);
665 PR_EEP("BPSK OutputBias", pModal
->ob_1
);
666 PR_EEP("QPSK OutputBias", pModal
->ob_2
);
667 PR_EEP("16QAM OutputBias", pModal
->ob_3
);
668 PR_EEP("64QAM OutputBias", pModal
->ob_4
);
669 PR_EEP("CCK Driver1_Bias", pModal
->db1_0
);
670 PR_EEP("BPSK Driver1_Bias", pModal
->db1_1
);
671 PR_EEP("QPSK Driver1_Bias", pModal
->db1_2
);
672 PR_EEP("16QAM Driver1_Bias", pModal
->db1_3
);
673 PR_EEP("64QAM Driver1_Bias", pModal
->db1_4
);
674 PR_EEP("CCK Driver2_Bias", pModal
->db2_0
);
675 PR_EEP("BPSK Driver2_Bias", pModal
->db2_1
);
676 PR_EEP("QPSK Driver2_Bias", pModal
->db2_2
);
677 PR_EEP("16QAM Driver2_Bias", pModal
->db2_3
);
678 PR_EEP("64QAM Driver2_Bias", pModal
->db2_4
);
679 PR_EEP("xPA Bias Level", pModal
->xpaBiasLvl
);
680 PR_EEP("txFrameToDataStart", pModal
->txFrameToDataStart
);
681 PR_EEP("txFrameToPaOn", pModal
->txFrameToPaOn
);
682 PR_EEP("HT40 Power Inc.", pModal
->ht40PowerIncForPdadc
);
683 PR_EEP("Chain0 bswAtten", pModal
->bswAtten
[0]);
684 PR_EEP("Chain0 bswMargin", pModal
->bswMargin
[0]);
685 PR_EEP("HT40 Switch Settle", pModal
->swSettleHt40
);
686 PR_EEP("Chain0 xatten2Db", pModal
->xatten2Db
[0]);
687 PR_EEP("Chain0 xatten2Margin", pModal
->xatten2Margin
[0]);
688 PR_EEP("Ant. Diversity ctl1", pModal
->antdiv_ctl1
);
689 PR_EEP("Ant. Diversity ctl2", pModal
->antdiv_ctl2
);
690 PR_EEP("TX Diversity", pModal
->tx_diversity
);
695 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
703 static ssize_t
read_def_modal_eeprom(struct file
*file
,
704 char __user
*user_buf
,
705 size_t count
, loff_t
*ppos
)
707 #define PR_EEP(_s, _val) \
709 if (pBase->opCapFlags & AR5416_OPFLAGS_11G) { \
710 pModal = &priv->ah->eeprom.def.modalHeader[1]; \
711 len += snprintf(buf + len, size - len, "%20s : %8d%7s", \
714 if (pBase->opCapFlags & AR5416_OPFLAGS_11A) { \
715 pModal = &priv->ah->eeprom.def.modalHeader[0]; \
716 len += snprintf(buf + len, size - len, "%9d\n", \
721 struct ath9k_htc_priv
*priv
= file
->private_data
;
722 struct base_eep_header
*pBase
= &priv
->ah
->eeprom
.def
.baseEepHeader
;
723 struct modal_eep_header
*pModal
= NULL
;
724 unsigned int len
= 0, size
= 3500;
728 buf
= kzalloc(size
, GFP_KERNEL
);
732 len
+= snprintf(buf
+ len
, size
- len
,
733 "%31s %15s\n", "2G", "5G");
734 len
+= snprintf(buf
+ len
, size
- len
,
735 "%32s %16s\n", "====", "====\n");
737 PR_EEP("Chain0 Ant. Control", pModal
->antCtrlChain
[0]);
738 PR_EEP("Chain1 Ant. Control", pModal
->antCtrlChain
[1]);
739 PR_EEP("Chain2 Ant. Control", pModal
->antCtrlChain
[2]);
740 PR_EEP("Ant. Common Control", pModal
->antCtrlCommon
);
741 PR_EEP("Chain0 Ant. Gain", pModal
->antennaGainCh
[0]);
742 PR_EEP("Chain1 Ant. Gain", pModal
->antennaGainCh
[1]);
743 PR_EEP("Chain2 Ant. Gain", pModal
->antennaGainCh
[2]);
744 PR_EEP("Switch Settle", pModal
->switchSettling
);
745 PR_EEP("Chain0 TxRxAtten", pModal
->txRxAttenCh
[0]);
746 PR_EEP("Chain1 TxRxAtten", pModal
->txRxAttenCh
[1]);
747 PR_EEP("Chain2 TxRxAtten", pModal
->txRxAttenCh
[2]);
748 PR_EEP("Chain0 RxTxMargin", pModal
->rxTxMarginCh
[0]);
749 PR_EEP("Chain1 RxTxMargin", pModal
->rxTxMarginCh
[1]);
750 PR_EEP("Chain2 RxTxMargin", pModal
->rxTxMarginCh
[2]);
751 PR_EEP("ADC Desired size", pModal
->adcDesiredSize
);
752 PR_EEP("PGA Desired size", pModal
->pgaDesiredSize
);
753 PR_EEP("Chain0 xlna Gain", pModal
->xlnaGainCh
[0]);
754 PR_EEP("Chain1 xlna Gain", pModal
->xlnaGainCh
[1]);
755 PR_EEP("Chain2 xlna Gain", pModal
->xlnaGainCh
[2]);
756 PR_EEP("txEndToXpaOff", pModal
->txEndToXpaOff
);
757 PR_EEP("txEndToRxOn", pModal
->txEndToRxOn
);
758 PR_EEP("txFrameToXpaOn", pModal
->txFrameToXpaOn
);
759 PR_EEP("CCA Threshold)", pModal
->thresh62
);
760 PR_EEP("Chain0 NF Threshold", pModal
->noiseFloorThreshCh
[0]);
761 PR_EEP("Chain1 NF Threshold", pModal
->noiseFloorThreshCh
[1]);
762 PR_EEP("Chain2 NF Threshold", pModal
->noiseFloorThreshCh
[2]);
763 PR_EEP("xpdGain", pModal
->xpdGain
);
764 PR_EEP("External PD", pModal
->xpd
);
765 PR_EEP("Chain0 I Coefficient", pModal
->iqCalICh
[0]);
766 PR_EEP("Chain1 I Coefficient", pModal
->iqCalICh
[1]);
767 PR_EEP("Chain2 I Coefficient", pModal
->iqCalICh
[2]);
768 PR_EEP("Chain0 Q Coefficient", pModal
->iqCalQCh
[0]);
769 PR_EEP("Chain1 Q Coefficient", pModal
->iqCalQCh
[1]);
770 PR_EEP("Chain2 Q Coefficient", pModal
->iqCalQCh
[2]);
771 PR_EEP("pdGainOverlap", pModal
->pdGainOverlap
);
772 PR_EEP("Chain0 OutputBias", pModal
->ob
);
773 PR_EEP("Chain0 DriverBias", pModal
->db
);
774 PR_EEP("xPA Bias Level", pModal
->xpaBiasLvl
);
775 PR_EEP("2chain pwr decrease", pModal
->pwrDecreaseFor2Chain
);
776 PR_EEP("3chain pwr decrease", pModal
->pwrDecreaseFor3Chain
);
777 PR_EEP("txFrameToDataStart", pModal
->txFrameToDataStart
);
778 PR_EEP("txFrameToPaOn", pModal
->txFrameToPaOn
);
779 PR_EEP("HT40 Power Inc.", pModal
->ht40PowerIncForPdadc
);
780 PR_EEP("Chain0 bswAtten", pModal
->bswAtten
[0]);
781 PR_EEP("Chain1 bswAtten", pModal
->bswAtten
[1]);
782 PR_EEP("Chain2 bswAtten", pModal
->bswAtten
[2]);
783 PR_EEP("Chain0 bswMargin", pModal
->bswMargin
[0]);
784 PR_EEP("Chain1 bswMargin", pModal
->bswMargin
[1]);
785 PR_EEP("Chain2 bswMargin", pModal
->bswMargin
[2]);
786 PR_EEP("HT40 Switch Settle", pModal
->swSettleHt40
);
787 PR_EEP("Chain0 xatten2Db", pModal
->xatten2Db
[0]);
788 PR_EEP("Chain1 xatten2Db", pModal
->xatten2Db
[1]);
789 PR_EEP("Chain2 xatten2Db", pModal
->xatten2Db
[2]);
790 PR_EEP("Chain0 xatten2Margin", pModal
->xatten2Margin
[0]);
791 PR_EEP("Chain1 xatten2Margin", pModal
->xatten2Margin
[1]);
792 PR_EEP("Chain2 xatten2Margin", pModal
->xatten2Margin
[2]);
793 PR_EEP("Chain1 OutputBias", pModal
->ob_ch1
);
794 PR_EEP("Chain1 DriverBias", pModal
->db_ch1
);
795 PR_EEP("LNA Control", pModal
->lna_ctl
);
796 PR_EEP("XPA Bias Freq0", pModal
->xpaBiasLvlFreq
[0]);
797 PR_EEP("XPA Bias Freq1", pModal
->xpaBiasLvlFreq
[1]);
798 PR_EEP("XPA Bias Freq2", pModal
->xpaBiasLvlFreq
[2]);
803 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
811 static ssize_t
read_9287_modal_eeprom(struct file
*file
,
812 char __user
*user_buf
,
813 size_t count
, loff_t
*ppos
)
815 #define PR_EEP(_s, _val) \
817 len += snprintf(buf + len, size - len, "%20s : %10d\n", \
821 struct ath9k_htc_priv
*priv
= file
->private_data
;
822 struct modal_eep_ar9287_header
*pModal
= &priv
->ah
->eeprom
.map9287
.modalHeader
;
823 unsigned int len
= 0, size
= 3000;
827 buf
= kzalloc(size
, GFP_KERNEL
);
831 PR_EEP("Chain0 Ant. Control", pModal
->antCtrlChain
[0]);
832 PR_EEP("Chain1 Ant. Control", pModal
->antCtrlChain
[1]);
833 PR_EEP("Ant. Common Control", pModal
->antCtrlCommon
);
834 PR_EEP("Chain0 Ant. Gain", pModal
->antennaGainCh
[0]);
835 PR_EEP("Chain1 Ant. Gain", pModal
->antennaGainCh
[1]);
836 PR_EEP("Switch Settle", pModal
->switchSettling
);
837 PR_EEP("Chain0 TxRxAtten", pModal
->txRxAttenCh
[0]);
838 PR_EEP("Chain1 TxRxAtten", pModal
->txRxAttenCh
[1]);
839 PR_EEP("Chain0 RxTxMargin", pModal
->rxTxMarginCh
[0]);
840 PR_EEP("Chain1 RxTxMargin", pModal
->rxTxMarginCh
[1]);
841 PR_EEP("ADC Desired size", pModal
->adcDesiredSize
);
842 PR_EEP("txEndToXpaOff", pModal
->txEndToXpaOff
);
843 PR_EEP("txEndToRxOn", pModal
->txEndToRxOn
);
844 PR_EEP("txFrameToXpaOn", pModal
->txFrameToXpaOn
);
845 PR_EEP("CCA Threshold)", pModal
->thresh62
);
846 PR_EEP("Chain0 NF Threshold", pModal
->noiseFloorThreshCh
[0]);
847 PR_EEP("Chain1 NF Threshold", pModal
->noiseFloorThreshCh
[1]);
848 PR_EEP("xpdGain", pModal
->xpdGain
);
849 PR_EEP("External PD", pModal
->xpd
);
850 PR_EEP("Chain0 I Coefficient", pModal
->iqCalICh
[0]);
851 PR_EEP("Chain1 I Coefficient", pModal
->iqCalICh
[1]);
852 PR_EEP("Chain0 Q Coefficient", pModal
->iqCalQCh
[0]);
853 PR_EEP("Chain1 Q Coefficient", pModal
->iqCalQCh
[1]);
854 PR_EEP("pdGainOverlap", pModal
->pdGainOverlap
);
855 PR_EEP("xPA Bias Level", pModal
->xpaBiasLvl
);
856 PR_EEP("txFrameToDataStart", pModal
->txFrameToDataStart
);
857 PR_EEP("txFrameToPaOn", pModal
->txFrameToPaOn
);
858 PR_EEP("HT40 Power Inc.", pModal
->ht40PowerIncForPdadc
);
859 PR_EEP("Chain0 bswAtten", pModal
->bswAtten
[0]);
860 PR_EEP("Chain1 bswAtten", pModal
->bswAtten
[1]);
861 PR_EEP("Chain0 bswMargin", pModal
->bswMargin
[0]);
862 PR_EEP("Chain1 bswMargin", pModal
->bswMargin
[1]);
863 PR_EEP("HT40 Switch Settle", pModal
->swSettleHt40
);
864 PR_EEP("AR92x7 Version", pModal
->version
);
865 PR_EEP("DriverBias1", pModal
->db1
);
866 PR_EEP("DriverBias2", pModal
->db1
);
867 PR_EEP("CCK OutputBias", pModal
->ob_cck
);
868 PR_EEP("PSK OutputBias", pModal
->ob_psk
);
869 PR_EEP("QAM OutputBias", pModal
->ob_qam
);
870 PR_EEP("PAL_OFF OutputBias", pModal
->ob_pal_off
);
875 retval
= simple_read_from_buffer(user_buf
, count
, ppos
, buf
, len
);
883 static ssize_t
read_file_modal_eeprom(struct file
*file
, char __user
*user_buf
,
884 size_t count
, loff_t
*ppos
)
886 struct ath9k_htc_priv
*priv
= file
->private_data
;
888 if (AR_SREV_9271(priv
->ah
))
889 return read_4k_modal_eeprom(file
, user_buf
, count
, ppos
);
890 else if (priv
->ah
->hw_version
.usbdev
== AR9280_USB
)
891 return read_def_modal_eeprom(file
, user_buf
, count
, ppos
);
892 else if (priv
->ah
->hw_version
.usbdev
== AR9287_USB
)
893 return read_9287_modal_eeprom(file
, user_buf
, count
, ppos
);
898 static const struct file_operations fops_modal_eeprom
= {
899 .read
= read_file_modal_eeprom
,
901 .owner
= THIS_MODULE
,
902 .llseek
= default_llseek
,
906 /* Ethtool support for get-stats */
907 #define AMKSTR(nm) #nm "_BE", #nm "_BK", #nm "_VI", #nm "_VO"
908 static const char ath9k_htc_gstrings_stats
[][ETH_GSTRING_LEN
] = {
917 "d_rx_decrypt_crc_err",
920 "d_rx_pre_delim_crc_err",
921 "d_rx_post_delim_crc_err",
922 "d_rx_decrypt_busy_err",
925 "d_rx_phyerr_ofdm_timing",
926 "d_rx_phyerr_cck_timing",
929 #define ATH9K_HTC_SSTATS_LEN ARRAY_SIZE(ath9k_htc_gstrings_stats)
931 void ath9k_htc_get_et_strings(struct ieee80211_hw
*hw
,
932 struct ieee80211_vif
*vif
,
935 if (sset
== ETH_SS_STATS
)
936 memcpy(data
, *ath9k_htc_gstrings_stats
,
937 sizeof(ath9k_htc_gstrings_stats
));
940 int ath9k_htc_get_et_sset_count(struct ieee80211_hw
*hw
,
941 struct ieee80211_vif
*vif
, int sset
)
943 if (sset
== ETH_SS_STATS
)
944 return ATH9K_HTC_SSTATS_LEN
;
948 #define STXBASE priv->debug.tx_stats
949 #define SRXBASE priv->debug.rx_stats
951 data[i++] = STXBASE.a[IEEE80211_AC_BE]; \
952 data[i++] = STXBASE.a[IEEE80211_AC_BK]; \
953 data[i++] = STXBASE.a[IEEE80211_AC_VI]; \
954 data[i++] = STXBASE.a[IEEE80211_AC_VO]
956 void ath9k_htc_get_et_stats(struct ieee80211_hw
*hw
,
957 struct ieee80211_vif
*vif
,
958 struct ethtool_stats
*stats
, u64
*data
)
960 struct ath9k_htc_priv
*priv
= hw
->priv
;
963 data
[i
++] = STXBASE
.skb_success
;
964 data
[i
++] = STXBASE
.skb_success_bytes
;
965 data
[i
++] = SRXBASE
.skb_completed
;
966 data
[i
++] = SRXBASE
.skb_completed_bytes
;
970 data
[i
++] = SRXBASE
.err_crc
;
971 data
[i
++] = SRXBASE
.err_decrypt_crc
;
972 data
[i
++] = SRXBASE
.err_phy
;
973 data
[i
++] = SRXBASE
.err_mic
;
974 data
[i
++] = SRXBASE
.err_pre_delim
;
975 data
[i
++] = SRXBASE
.err_post_delim
;
976 data
[i
++] = SRXBASE
.err_decrypt_busy
;
978 data
[i
++] = SRXBASE
.err_phy_stats
[ATH9K_PHYERR_RADAR
];
979 data
[i
++] = SRXBASE
.err_phy_stats
[ATH9K_PHYERR_OFDM_TIMING
];
980 data
[i
++] = SRXBASE
.err_phy_stats
[ATH9K_PHYERR_CCK_TIMING
];
982 WARN_ON(i
!= ATH9K_HTC_SSTATS_LEN
);
986 int ath9k_htc_init_debug(struct ath_hw
*ah
)
988 struct ath_common
*common
= ath9k_hw_common(ah
);
989 struct ath9k_htc_priv
*priv
= (struct ath9k_htc_priv
*) common
->priv
;
991 priv
->debug
.debugfs_phy
= debugfs_create_dir(KBUILD_MODNAME
,
992 priv
->hw
->wiphy
->debugfsdir
);
993 if (!priv
->debug
.debugfs_phy
)
996 debugfs_create_file("tgt_int_stats", S_IRUSR
, priv
->debug
.debugfs_phy
,
997 priv
, &fops_tgt_int_stats
);
998 debugfs_create_file("tgt_tx_stats", S_IRUSR
, priv
->debug
.debugfs_phy
,
999 priv
, &fops_tgt_tx_stats
);
1000 debugfs_create_file("tgt_rx_stats", S_IRUSR
, priv
->debug
.debugfs_phy
,
1001 priv
, &fops_tgt_rx_stats
);
1002 debugfs_create_file("xmit", S_IRUSR
, priv
->debug
.debugfs_phy
,
1004 debugfs_create_file("recv", S_IRUSR
, priv
->debug
.debugfs_phy
,
1006 debugfs_create_file("slot", S_IRUSR
, priv
->debug
.debugfs_phy
,
1008 debugfs_create_file("queue", S_IRUSR
, priv
->debug
.debugfs_phy
,
1010 debugfs_create_file("debug", S_IRUSR
| S_IWUSR
, priv
->debug
.debugfs_phy
,
1012 debugfs_create_file("base_eeprom", S_IRUSR
, priv
->debug
.debugfs_phy
,
1013 priv
, &fops_base_eeprom
);
1014 debugfs_create_file("modal_eeprom", S_IRUSR
, priv
->debug
.debugfs_phy
,
1015 priv
, &fops_modal_eeprom
);