xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/intel/iwlegacy/4965-debug.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0-only
2*4882a593Smuzhiyun /******************************************************************************
3*4882a593Smuzhiyun *
4*4882a593Smuzhiyun * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
5*4882a593Smuzhiyun *
6*4882a593Smuzhiyun * Contact Information:
7*4882a593Smuzhiyun *  Intel Linux Wireless <ilw@linux.intel.com>
8*4882a593Smuzhiyun * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
9*4882a593Smuzhiyun *****************************************************************************/
10*4882a593Smuzhiyun #include "common.h"
11*4882a593Smuzhiyun #include "4965.h"
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun static const char *fmt_value = "  %-30s %10u\n";
14*4882a593Smuzhiyun static const char *fmt_table = "  %-30s %10u  %10u  %10u  %10u\n";
15*4882a593Smuzhiyun static const char *fmt_header =
16*4882a593Smuzhiyun     "%-32s    current  cumulative       delta         max\n";
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun static int
il4965_stats_flag(struct il_priv * il,char * buf,int bufsz)19*4882a593Smuzhiyun il4965_stats_flag(struct il_priv *il, char *buf, int bufsz)
20*4882a593Smuzhiyun {
21*4882a593Smuzhiyun 	int p = 0;
22*4882a593Smuzhiyun 	u32 flag;
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun 	flag = le32_to_cpu(il->_4965.stats.flag);
25*4882a593Smuzhiyun 
26*4882a593Smuzhiyun 	p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag);
27*4882a593Smuzhiyun 	if (flag & UCODE_STATS_CLEAR_MSK)
28*4882a593Smuzhiyun 		p += scnprintf(buf + p, bufsz - p,
29*4882a593Smuzhiyun 			       "\tStatistics have been cleared\n");
30*4882a593Smuzhiyun 	p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n",
31*4882a593Smuzhiyun 		       (flag & UCODE_STATS_FREQUENCY_MSK) ? "2.4 GHz" :
32*4882a593Smuzhiyun 		       "5.2 GHz");
33*4882a593Smuzhiyun 	p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n",
34*4882a593Smuzhiyun 		       (flag & UCODE_STATS_NARROW_BAND_MSK) ? "enabled" :
35*4882a593Smuzhiyun 		       "disabled");
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun 	return p;
38*4882a593Smuzhiyun }
39*4882a593Smuzhiyun 
40*4882a593Smuzhiyun static ssize_t
il4965_ucode_rx_stats_read(struct file * file,char __user * user_buf,size_t count,loff_t * ppos)41*4882a593Smuzhiyun il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf,
42*4882a593Smuzhiyun 			   size_t count, loff_t *ppos)
43*4882a593Smuzhiyun {
44*4882a593Smuzhiyun 	struct il_priv *il = file->private_data;
45*4882a593Smuzhiyun 	int pos = 0;
46*4882a593Smuzhiyun 	char *buf;
47*4882a593Smuzhiyun 	int bufsz =
48*4882a593Smuzhiyun 	    sizeof(struct stats_rx_phy) * 40 +
49*4882a593Smuzhiyun 	    sizeof(struct stats_rx_non_phy) * 40 +
50*4882a593Smuzhiyun 	    sizeof(struct stats_rx_ht_phy) * 40 + 400;
51*4882a593Smuzhiyun 	ssize_t ret;
52*4882a593Smuzhiyun 	struct stats_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm;
53*4882a593Smuzhiyun 	struct stats_rx_phy *cck, *accum_cck, *delta_cck, *max_cck;
54*4882a593Smuzhiyun 	struct stats_rx_non_phy *general, *accum_general;
55*4882a593Smuzhiyun 	struct stats_rx_non_phy *delta_general, *max_general;
56*4882a593Smuzhiyun 	struct stats_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht;
57*4882a593Smuzhiyun 
58*4882a593Smuzhiyun 	if (!il_is_alive(il))
59*4882a593Smuzhiyun 		return -EAGAIN;
60*4882a593Smuzhiyun 
61*4882a593Smuzhiyun 	buf = kzalloc(bufsz, GFP_KERNEL);
62*4882a593Smuzhiyun 	if (!buf) {
63*4882a593Smuzhiyun 		IL_ERR("Can not allocate Buffer\n");
64*4882a593Smuzhiyun 		return -ENOMEM;
65*4882a593Smuzhiyun 	}
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun 	/*
68*4882a593Smuzhiyun 	 * the statistic information display here is based on
69*4882a593Smuzhiyun 	 * the last stats notification from uCode
70*4882a593Smuzhiyun 	 * might not reflect the current uCode activity
71*4882a593Smuzhiyun 	 */
72*4882a593Smuzhiyun 	ofdm = &il->_4965.stats.rx.ofdm;
73*4882a593Smuzhiyun 	cck = &il->_4965.stats.rx.cck;
74*4882a593Smuzhiyun 	general = &il->_4965.stats.rx.general;
75*4882a593Smuzhiyun 	ht = &il->_4965.stats.rx.ofdm_ht;
76*4882a593Smuzhiyun 	accum_ofdm = &il->_4965.accum_stats.rx.ofdm;
77*4882a593Smuzhiyun 	accum_cck = &il->_4965.accum_stats.rx.cck;
78*4882a593Smuzhiyun 	accum_general = &il->_4965.accum_stats.rx.general;
79*4882a593Smuzhiyun 	accum_ht = &il->_4965.accum_stats.rx.ofdm_ht;
80*4882a593Smuzhiyun 	delta_ofdm = &il->_4965.delta_stats.rx.ofdm;
81*4882a593Smuzhiyun 	delta_cck = &il->_4965.delta_stats.rx.cck;
82*4882a593Smuzhiyun 	delta_general = &il->_4965.delta_stats.rx.general;
83*4882a593Smuzhiyun 	delta_ht = &il->_4965.delta_stats.rx.ofdm_ht;
84*4882a593Smuzhiyun 	max_ofdm = &il->_4965.max_delta.rx.ofdm;
85*4882a593Smuzhiyun 	max_cck = &il->_4965.max_delta.rx.cck;
86*4882a593Smuzhiyun 	max_general = &il->_4965.max_delta.rx.general;
87*4882a593Smuzhiyun 	max_ht = &il->_4965.max_delta.rx.ofdm_ht;
88*4882a593Smuzhiyun 
89*4882a593Smuzhiyun 	pos += il4965_stats_flag(il, buf, bufsz);
90*4882a593Smuzhiyun 	pos +=
91*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_header,
92*4882a593Smuzhiyun 		      "Statistics_Rx - OFDM:");
93*4882a593Smuzhiyun 	pos +=
94*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "ina_cnt:",
95*4882a593Smuzhiyun 		      le32_to_cpu(ofdm->ina_cnt), accum_ofdm->ina_cnt,
96*4882a593Smuzhiyun 		      delta_ofdm->ina_cnt, max_ofdm->ina_cnt);
97*4882a593Smuzhiyun 	pos +=
98*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_cnt:",
99*4882a593Smuzhiyun 		      le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt,
100*4882a593Smuzhiyun 		      delta_ofdm->fina_cnt, max_ofdm->fina_cnt);
101*4882a593Smuzhiyun 	pos +=
102*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "plcp_err:",
103*4882a593Smuzhiyun 		      le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err,
104*4882a593Smuzhiyun 		      delta_ofdm->plcp_err, max_ofdm->plcp_err);
105*4882a593Smuzhiyun 	pos +=
106*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_err:",
107*4882a593Smuzhiyun 		      le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err,
108*4882a593Smuzhiyun 		      delta_ofdm->crc32_err, max_ofdm->crc32_err);
109*4882a593Smuzhiyun 	pos +=
110*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "overrun_err:",
111*4882a593Smuzhiyun 		      le32_to_cpu(ofdm->overrun_err), accum_ofdm->overrun_err,
112*4882a593Smuzhiyun 		      delta_ofdm->overrun_err, max_ofdm->overrun_err);
113*4882a593Smuzhiyun 	pos +=
114*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "early_overrun_err:",
115*4882a593Smuzhiyun 		      le32_to_cpu(ofdm->early_overrun_err),
116*4882a593Smuzhiyun 		      accum_ofdm->early_overrun_err,
117*4882a593Smuzhiyun 		      delta_ofdm->early_overrun_err,
118*4882a593Smuzhiyun 		      max_ofdm->early_overrun_err);
119*4882a593Smuzhiyun 	pos +=
120*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_good:",
121*4882a593Smuzhiyun 		      le32_to_cpu(ofdm->crc32_good), accum_ofdm->crc32_good,
122*4882a593Smuzhiyun 		      delta_ofdm->crc32_good, max_ofdm->crc32_good);
123*4882a593Smuzhiyun 	pos +=
124*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "false_alarm_cnt:",
125*4882a593Smuzhiyun 		      le32_to_cpu(ofdm->false_alarm_cnt),
126*4882a593Smuzhiyun 		      accum_ofdm->false_alarm_cnt, delta_ofdm->false_alarm_cnt,
127*4882a593Smuzhiyun 		      max_ofdm->false_alarm_cnt);
128*4882a593Smuzhiyun 	pos +=
129*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_sync_err_cnt:",
130*4882a593Smuzhiyun 		      le32_to_cpu(ofdm->fina_sync_err_cnt),
131*4882a593Smuzhiyun 		      accum_ofdm->fina_sync_err_cnt,
132*4882a593Smuzhiyun 		      delta_ofdm->fina_sync_err_cnt,
133*4882a593Smuzhiyun 		      max_ofdm->fina_sync_err_cnt);
134*4882a593Smuzhiyun 	pos +=
135*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "sfd_timeout:",
136*4882a593Smuzhiyun 		      le32_to_cpu(ofdm->sfd_timeout), accum_ofdm->sfd_timeout,
137*4882a593Smuzhiyun 		      delta_ofdm->sfd_timeout, max_ofdm->sfd_timeout);
138*4882a593Smuzhiyun 	pos +=
139*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_timeout:",
140*4882a593Smuzhiyun 		      le32_to_cpu(ofdm->fina_timeout), accum_ofdm->fina_timeout,
141*4882a593Smuzhiyun 		      delta_ofdm->fina_timeout, max_ofdm->fina_timeout);
142*4882a593Smuzhiyun 	pos +=
143*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "unresponded_rts:",
144*4882a593Smuzhiyun 		      le32_to_cpu(ofdm->unresponded_rts),
145*4882a593Smuzhiyun 		      accum_ofdm->unresponded_rts, delta_ofdm->unresponded_rts,
146*4882a593Smuzhiyun 		      max_ofdm->unresponded_rts);
147*4882a593Smuzhiyun 	pos +=
148*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "rxe_frame_lmt_ovrun:",
149*4882a593Smuzhiyun 		      le32_to_cpu(ofdm->rxe_frame_limit_overrun),
150*4882a593Smuzhiyun 		      accum_ofdm->rxe_frame_limit_overrun,
151*4882a593Smuzhiyun 		      delta_ofdm->rxe_frame_limit_overrun,
152*4882a593Smuzhiyun 		      max_ofdm->rxe_frame_limit_overrun);
153*4882a593Smuzhiyun 	pos +=
154*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_ack_cnt:",
155*4882a593Smuzhiyun 		      le32_to_cpu(ofdm->sent_ack_cnt), accum_ofdm->sent_ack_cnt,
156*4882a593Smuzhiyun 		      delta_ofdm->sent_ack_cnt, max_ofdm->sent_ack_cnt);
157*4882a593Smuzhiyun 	pos +=
158*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_cts_cnt:",
159*4882a593Smuzhiyun 		      le32_to_cpu(ofdm->sent_cts_cnt), accum_ofdm->sent_cts_cnt,
160*4882a593Smuzhiyun 		      delta_ofdm->sent_cts_cnt, max_ofdm->sent_cts_cnt);
161*4882a593Smuzhiyun 	pos +=
162*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_ba_rsp_cnt:",
163*4882a593Smuzhiyun 		      le32_to_cpu(ofdm->sent_ba_rsp_cnt),
164*4882a593Smuzhiyun 		      accum_ofdm->sent_ba_rsp_cnt, delta_ofdm->sent_ba_rsp_cnt,
165*4882a593Smuzhiyun 		      max_ofdm->sent_ba_rsp_cnt);
166*4882a593Smuzhiyun 	pos +=
167*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "dsp_self_kill:",
168*4882a593Smuzhiyun 		      le32_to_cpu(ofdm->dsp_self_kill),
169*4882a593Smuzhiyun 		      accum_ofdm->dsp_self_kill, delta_ofdm->dsp_self_kill,
170*4882a593Smuzhiyun 		      max_ofdm->dsp_self_kill);
171*4882a593Smuzhiyun 	pos +=
172*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "mh_format_err:",
173*4882a593Smuzhiyun 		      le32_to_cpu(ofdm->mh_format_err),
174*4882a593Smuzhiyun 		      accum_ofdm->mh_format_err, delta_ofdm->mh_format_err,
175*4882a593Smuzhiyun 		      max_ofdm->mh_format_err);
176*4882a593Smuzhiyun 	pos +=
177*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table,
178*4882a593Smuzhiyun 		      "re_acq_main_rssi_sum:",
179*4882a593Smuzhiyun 		      le32_to_cpu(ofdm->re_acq_main_rssi_sum),
180*4882a593Smuzhiyun 		      accum_ofdm->re_acq_main_rssi_sum,
181*4882a593Smuzhiyun 		      delta_ofdm->re_acq_main_rssi_sum,
182*4882a593Smuzhiyun 		      max_ofdm->re_acq_main_rssi_sum);
183*4882a593Smuzhiyun 
184*4882a593Smuzhiyun 	pos +=
185*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_header,
186*4882a593Smuzhiyun 		      "Statistics_Rx - CCK:");
187*4882a593Smuzhiyun 	pos +=
188*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "ina_cnt:",
189*4882a593Smuzhiyun 		      le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt,
190*4882a593Smuzhiyun 		      delta_cck->ina_cnt, max_cck->ina_cnt);
191*4882a593Smuzhiyun 	pos +=
192*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_cnt:",
193*4882a593Smuzhiyun 		      le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt,
194*4882a593Smuzhiyun 		      delta_cck->fina_cnt, max_cck->fina_cnt);
195*4882a593Smuzhiyun 	pos +=
196*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "plcp_err:",
197*4882a593Smuzhiyun 		      le32_to_cpu(cck->plcp_err), accum_cck->plcp_err,
198*4882a593Smuzhiyun 		      delta_cck->plcp_err, max_cck->plcp_err);
199*4882a593Smuzhiyun 	pos +=
200*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_err:",
201*4882a593Smuzhiyun 		      le32_to_cpu(cck->crc32_err), accum_cck->crc32_err,
202*4882a593Smuzhiyun 		      delta_cck->crc32_err, max_cck->crc32_err);
203*4882a593Smuzhiyun 	pos +=
204*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "overrun_err:",
205*4882a593Smuzhiyun 		      le32_to_cpu(cck->overrun_err), accum_cck->overrun_err,
206*4882a593Smuzhiyun 		      delta_cck->overrun_err, max_cck->overrun_err);
207*4882a593Smuzhiyun 	pos +=
208*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "early_overrun_err:",
209*4882a593Smuzhiyun 		      le32_to_cpu(cck->early_overrun_err),
210*4882a593Smuzhiyun 		      accum_cck->early_overrun_err,
211*4882a593Smuzhiyun 		      delta_cck->early_overrun_err, max_cck->early_overrun_err);
212*4882a593Smuzhiyun 	pos +=
213*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_good:",
214*4882a593Smuzhiyun 		      le32_to_cpu(cck->crc32_good), accum_cck->crc32_good,
215*4882a593Smuzhiyun 		      delta_cck->crc32_good, max_cck->crc32_good);
216*4882a593Smuzhiyun 	pos +=
217*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "false_alarm_cnt:",
218*4882a593Smuzhiyun 		      le32_to_cpu(cck->false_alarm_cnt),
219*4882a593Smuzhiyun 		      accum_cck->false_alarm_cnt, delta_cck->false_alarm_cnt,
220*4882a593Smuzhiyun 		      max_cck->false_alarm_cnt);
221*4882a593Smuzhiyun 	pos +=
222*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_sync_err_cnt:",
223*4882a593Smuzhiyun 		      le32_to_cpu(cck->fina_sync_err_cnt),
224*4882a593Smuzhiyun 		      accum_cck->fina_sync_err_cnt,
225*4882a593Smuzhiyun 		      delta_cck->fina_sync_err_cnt, max_cck->fina_sync_err_cnt);
226*4882a593Smuzhiyun 	pos +=
227*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "sfd_timeout:",
228*4882a593Smuzhiyun 		      le32_to_cpu(cck->sfd_timeout), accum_cck->sfd_timeout,
229*4882a593Smuzhiyun 		      delta_cck->sfd_timeout, max_cck->sfd_timeout);
230*4882a593Smuzhiyun 	pos +=
231*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_timeout:",
232*4882a593Smuzhiyun 		      le32_to_cpu(cck->fina_timeout), accum_cck->fina_timeout,
233*4882a593Smuzhiyun 		      delta_cck->fina_timeout, max_cck->fina_timeout);
234*4882a593Smuzhiyun 	pos +=
235*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "unresponded_rts:",
236*4882a593Smuzhiyun 		      le32_to_cpu(cck->unresponded_rts),
237*4882a593Smuzhiyun 		      accum_cck->unresponded_rts, delta_cck->unresponded_rts,
238*4882a593Smuzhiyun 		      max_cck->unresponded_rts);
239*4882a593Smuzhiyun 	pos +=
240*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "rxe_frame_lmt_ovrun:",
241*4882a593Smuzhiyun 		      le32_to_cpu(cck->rxe_frame_limit_overrun),
242*4882a593Smuzhiyun 		      accum_cck->rxe_frame_limit_overrun,
243*4882a593Smuzhiyun 		      delta_cck->rxe_frame_limit_overrun,
244*4882a593Smuzhiyun 		      max_cck->rxe_frame_limit_overrun);
245*4882a593Smuzhiyun 	pos +=
246*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_ack_cnt:",
247*4882a593Smuzhiyun 		      le32_to_cpu(cck->sent_ack_cnt), accum_cck->sent_ack_cnt,
248*4882a593Smuzhiyun 		      delta_cck->sent_ack_cnt, max_cck->sent_ack_cnt);
249*4882a593Smuzhiyun 	pos +=
250*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_cts_cnt:",
251*4882a593Smuzhiyun 		      le32_to_cpu(cck->sent_cts_cnt), accum_cck->sent_cts_cnt,
252*4882a593Smuzhiyun 		      delta_cck->sent_cts_cnt, max_cck->sent_cts_cnt);
253*4882a593Smuzhiyun 	pos +=
254*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_ba_rsp_cnt:",
255*4882a593Smuzhiyun 		      le32_to_cpu(cck->sent_ba_rsp_cnt),
256*4882a593Smuzhiyun 		      accum_cck->sent_ba_rsp_cnt, delta_cck->sent_ba_rsp_cnt,
257*4882a593Smuzhiyun 		      max_cck->sent_ba_rsp_cnt);
258*4882a593Smuzhiyun 	pos +=
259*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "dsp_self_kill:",
260*4882a593Smuzhiyun 		      le32_to_cpu(cck->dsp_self_kill), accum_cck->dsp_self_kill,
261*4882a593Smuzhiyun 		      delta_cck->dsp_self_kill, max_cck->dsp_self_kill);
262*4882a593Smuzhiyun 	pos +=
263*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "mh_format_err:",
264*4882a593Smuzhiyun 		      le32_to_cpu(cck->mh_format_err), accum_cck->mh_format_err,
265*4882a593Smuzhiyun 		      delta_cck->mh_format_err, max_cck->mh_format_err);
266*4882a593Smuzhiyun 	pos +=
267*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table,
268*4882a593Smuzhiyun 		      "re_acq_main_rssi_sum:",
269*4882a593Smuzhiyun 		      le32_to_cpu(cck->re_acq_main_rssi_sum),
270*4882a593Smuzhiyun 		      accum_cck->re_acq_main_rssi_sum,
271*4882a593Smuzhiyun 		      delta_cck->re_acq_main_rssi_sum,
272*4882a593Smuzhiyun 		      max_cck->re_acq_main_rssi_sum);
273*4882a593Smuzhiyun 
274*4882a593Smuzhiyun 	pos +=
275*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_header,
276*4882a593Smuzhiyun 		      "Statistics_Rx - GENERAL:");
277*4882a593Smuzhiyun 	pos +=
278*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "bogus_cts:",
279*4882a593Smuzhiyun 		      le32_to_cpu(general->bogus_cts), accum_general->bogus_cts,
280*4882a593Smuzhiyun 		      delta_general->bogus_cts, max_general->bogus_cts);
281*4882a593Smuzhiyun 	pos +=
282*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "bogus_ack:",
283*4882a593Smuzhiyun 		      le32_to_cpu(general->bogus_ack), accum_general->bogus_ack,
284*4882a593Smuzhiyun 		      delta_general->bogus_ack, max_general->bogus_ack);
285*4882a593Smuzhiyun 	pos +=
286*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "non_bssid_frames:",
287*4882a593Smuzhiyun 		      le32_to_cpu(general->non_bssid_frames),
288*4882a593Smuzhiyun 		      accum_general->non_bssid_frames,
289*4882a593Smuzhiyun 		      delta_general->non_bssid_frames,
290*4882a593Smuzhiyun 		      max_general->non_bssid_frames);
291*4882a593Smuzhiyun 	pos +=
292*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "filtered_frames:",
293*4882a593Smuzhiyun 		      le32_to_cpu(general->filtered_frames),
294*4882a593Smuzhiyun 		      accum_general->filtered_frames,
295*4882a593Smuzhiyun 		      delta_general->filtered_frames,
296*4882a593Smuzhiyun 		      max_general->filtered_frames);
297*4882a593Smuzhiyun 	pos +=
298*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "non_channel_beacons:",
299*4882a593Smuzhiyun 		      le32_to_cpu(general->non_channel_beacons),
300*4882a593Smuzhiyun 		      accum_general->non_channel_beacons,
301*4882a593Smuzhiyun 		      delta_general->non_channel_beacons,
302*4882a593Smuzhiyun 		      max_general->non_channel_beacons);
303*4882a593Smuzhiyun 	pos +=
304*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "channel_beacons:",
305*4882a593Smuzhiyun 		      le32_to_cpu(general->channel_beacons),
306*4882a593Smuzhiyun 		      accum_general->channel_beacons,
307*4882a593Smuzhiyun 		      delta_general->channel_beacons,
308*4882a593Smuzhiyun 		      max_general->channel_beacons);
309*4882a593Smuzhiyun 	pos +=
310*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "num_missed_bcon:",
311*4882a593Smuzhiyun 		      le32_to_cpu(general->num_missed_bcon),
312*4882a593Smuzhiyun 		      accum_general->num_missed_bcon,
313*4882a593Smuzhiyun 		      delta_general->num_missed_bcon,
314*4882a593Smuzhiyun 		      max_general->num_missed_bcon);
315*4882a593Smuzhiyun 	pos +=
316*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table,
317*4882a593Smuzhiyun 		      "adc_rx_saturation_time:",
318*4882a593Smuzhiyun 		      le32_to_cpu(general->adc_rx_saturation_time),
319*4882a593Smuzhiyun 		      accum_general->adc_rx_saturation_time,
320*4882a593Smuzhiyun 		      delta_general->adc_rx_saturation_time,
321*4882a593Smuzhiyun 		      max_general->adc_rx_saturation_time);
322*4882a593Smuzhiyun 	pos +=
323*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table,
324*4882a593Smuzhiyun 		      "ina_detect_search_tm:",
325*4882a593Smuzhiyun 		      le32_to_cpu(general->ina_detection_search_time),
326*4882a593Smuzhiyun 		      accum_general->ina_detection_search_time,
327*4882a593Smuzhiyun 		      delta_general->ina_detection_search_time,
328*4882a593Smuzhiyun 		      max_general->ina_detection_search_time);
329*4882a593Smuzhiyun 	pos +=
330*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table,
331*4882a593Smuzhiyun 		      "beacon_silence_rssi_a:",
332*4882a593Smuzhiyun 		      le32_to_cpu(general->beacon_silence_rssi_a),
333*4882a593Smuzhiyun 		      accum_general->beacon_silence_rssi_a,
334*4882a593Smuzhiyun 		      delta_general->beacon_silence_rssi_a,
335*4882a593Smuzhiyun 		      max_general->beacon_silence_rssi_a);
336*4882a593Smuzhiyun 	pos +=
337*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table,
338*4882a593Smuzhiyun 		      "beacon_silence_rssi_b:",
339*4882a593Smuzhiyun 		      le32_to_cpu(general->beacon_silence_rssi_b),
340*4882a593Smuzhiyun 		      accum_general->beacon_silence_rssi_b,
341*4882a593Smuzhiyun 		      delta_general->beacon_silence_rssi_b,
342*4882a593Smuzhiyun 		      max_general->beacon_silence_rssi_b);
343*4882a593Smuzhiyun 	pos +=
344*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table,
345*4882a593Smuzhiyun 		      "beacon_silence_rssi_c:",
346*4882a593Smuzhiyun 		      le32_to_cpu(general->beacon_silence_rssi_c),
347*4882a593Smuzhiyun 		      accum_general->beacon_silence_rssi_c,
348*4882a593Smuzhiyun 		      delta_general->beacon_silence_rssi_c,
349*4882a593Smuzhiyun 		      max_general->beacon_silence_rssi_c);
350*4882a593Smuzhiyun 	pos +=
351*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table,
352*4882a593Smuzhiyun 		      "interference_data_flag:",
353*4882a593Smuzhiyun 		      le32_to_cpu(general->interference_data_flag),
354*4882a593Smuzhiyun 		      accum_general->interference_data_flag,
355*4882a593Smuzhiyun 		      delta_general->interference_data_flag,
356*4882a593Smuzhiyun 		      max_general->interference_data_flag);
357*4882a593Smuzhiyun 	pos +=
358*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "channel_load:",
359*4882a593Smuzhiyun 		      le32_to_cpu(general->channel_load),
360*4882a593Smuzhiyun 		      accum_general->channel_load, delta_general->channel_load,
361*4882a593Smuzhiyun 		      max_general->channel_load);
362*4882a593Smuzhiyun 	pos +=
363*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "dsp_false_alarms:",
364*4882a593Smuzhiyun 		      le32_to_cpu(general->dsp_false_alarms),
365*4882a593Smuzhiyun 		      accum_general->dsp_false_alarms,
366*4882a593Smuzhiyun 		      delta_general->dsp_false_alarms,
367*4882a593Smuzhiyun 		      max_general->dsp_false_alarms);
368*4882a593Smuzhiyun 	pos +=
369*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_rssi_a:",
370*4882a593Smuzhiyun 		      le32_to_cpu(general->beacon_rssi_a),
371*4882a593Smuzhiyun 		      accum_general->beacon_rssi_a,
372*4882a593Smuzhiyun 		      delta_general->beacon_rssi_a, max_general->beacon_rssi_a);
373*4882a593Smuzhiyun 	pos +=
374*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_rssi_b:",
375*4882a593Smuzhiyun 		      le32_to_cpu(general->beacon_rssi_b),
376*4882a593Smuzhiyun 		      accum_general->beacon_rssi_b,
377*4882a593Smuzhiyun 		      delta_general->beacon_rssi_b, max_general->beacon_rssi_b);
378*4882a593Smuzhiyun 	pos +=
379*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_rssi_c:",
380*4882a593Smuzhiyun 		      le32_to_cpu(general->beacon_rssi_c),
381*4882a593Smuzhiyun 		      accum_general->beacon_rssi_c,
382*4882a593Smuzhiyun 		      delta_general->beacon_rssi_c, max_general->beacon_rssi_c);
383*4882a593Smuzhiyun 	pos +=
384*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_energy_a:",
385*4882a593Smuzhiyun 		      le32_to_cpu(general->beacon_energy_a),
386*4882a593Smuzhiyun 		      accum_general->beacon_energy_a,
387*4882a593Smuzhiyun 		      delta_general->beacon_energy_a,
388*4882a593Smuzhiyun 		      max_general->beacon_energy_a);
389*4882a593Smuzhiyun 	pos +=
390*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_energy_b:",
391*4882a593Smuzhiyun 		      le32_to_cpu(general->beacon_energy_b),
392*4882a593Smuzhiyun 		      accum_general->beacon_energy_b,
393*4882a593Smuzhiyun 		      delta_general->beacon_energy_b,
394*4882a593Smuzhiyun 		      max_general->beacon_energy_b);
395*4882a593Smuzhiyun 	pos +=
396*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_energy_c:",
397*4882a593Smuzhiyun 		      le32_to_cpu(general->beacon_energy_c),
398*4882a593Smuzhiyun 		      accum_general->beacon_energy_c,
399*4882a593Smuzhiyun 		      delta_general->beacon_energy_c,
400*4882a593Smuzhiyun 		      max_general->beacon_energy_c);
401*4882a593Smuzhiyun 
402*4882a593Smuzhiyun 	pos +=
403*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_header,
404*4882a593Smuzhiyun 		      "Statistics_Rx - OFDM_HT:");
405*4882a593Smuzhiyun 	pos +=
406*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "plcp_err:",
407*4882a593Smuzhiyun 		      le32_to_cpu(ht->plcp_err), accum_ht->plcp_err,
408*4882a593Smuzhiyun 		      delta_ht->plcp_err, max_ht->plcp_err);
409*4882a593Smuzhiyun 	pos +=
410*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "overrun_err:",
411*4882a593Smuzhiyun 		      le32_to_cpu(ht->overrun_err), accum_ht->overrun_err,
412*4882a593Smuzhiyun 		      delta_ht->overrun_err, max_ht->overrun_err);
413*4882a593Smuzhiyun 	pos +=
414*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "early_overrun_err:",
415*4882a593Smuzhiyun 		      le32_to_cpu(ht->early_overrun_err),
416*4882a593Smuzhiyun 		      accum_ht->early_overrun_err, delta_ht->early_overrun_err,
417*4882a593Smuzhiyun 		      max_ht->early_overrun_err);
418*4882a593Smuzhiyun 	pos +=
419*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_good:",
420*4882a593Smuzhiyun 		      le32_to_cpu(ht->crc32_good), accum_ht->crc32_good,
421*4882a593Smuzhiyun 		      delta_ht->crc32_good, max_ht->crc32_good);
422*4882a593Smuzhiyun 	pos +=
423*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_err:",
424*4882a593Smuzhiyun 		      le32_to_cpu(ht->crc32_err), accum_ht->crc32_err,
425*4882a593Smuzhiyun 		      delta_ht->crc32_err, max_ht->crc32_err);
426*4882a593Smuzhiyun 	pos +=
427*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "mh_format_err:",
428*4882a593Smuzhiyun 		      le32_to_cpu(ht->mh_format_err), accum_ht->mh_format_err,
429*4882a593Smuzhiyun 		      delta_ht->mh_format_err, max_ht->mh_format_err);
430*4882a593Smuzhiyun 	pos +=
431*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "agg_crc32_good:",
432*4882a593Smuzhiyun 		      le32_to_cpu(ht->agg_crc32_good), accum_ht->agg_crc32_good,
433*4882a593Smuzhiyun 		      delta_ht->agg_crc32_good, max_ht->agg_crc32_good);
434*4882a593Smuzhiyun 	pos +=
435*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "agg_mpdu_cnt:",
436*4882a593Smuzhiyun 		      le32_to_cpu(ht->agg_mpdu_cnt), accum_ht->agg_mpdu_cnt,
437*4882a593Smuzhiyun 		      delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt);
438*4882a593Smuzhiyun 	pos +=
439*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "agg_cnt:",
440*4882a593Smuzhiyun 		      le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt,
441*4882a593Smuzhiyun 		      delta_ht->agg_cnt, max_ht->agg_cnt);
442*4882a593Smuzhiyun 	pos +=
443*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "unsupport_mcs:",
444*4882a593Smuzhiyun 		      le32_to_cpu(ht->unsupport_mcs), accum_ht->unsupport_mcs,
445*4882a593Smuzhiyun 		      delta_ht->unsupport_mcs, max_ht->unsupport_mcs);
446*4882a593Smuzhiyun 
447*4882a593Smuzhiyun 	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
448*4882a593Smuzhiyun 	kfree(buf);
449*4882a593Smuzhiyun 	return ret;
450*4882a593Smuzhiyun }
451*4882a593Smuzhiyun 
452*4882a593Smuzhiyun static ssize_t
il4965_ucode_tx_stats_read(struct file * file,char __user * user_buf,size_t count,loff_t * ppos)453*4882a593Smuzhiyun il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf,
454*4882a593Smuzhiyun 			   size_t count, loff_t *ppos)
455*4882a593Smuzhiyun {
456*4882a593Smuzhiyun 	struct il_priv *il = file->private_data;
457*4882a593Smuzhiyun 	int pos = 0;
458*4882a593Smuzhiyun 	char *buf;
459*4882a593Smuzhiyun 	int bufsz = (sizeof(struct stats_tx) * 48) + 250;
460*4882a593Smuzhiyun 	ssize_t ret;
461*4882a593Smuzhiyun 	struct stats_tx *tx, *accum_tx, *delta_tx, *max_tx;
462*4882a593Smuzhiyun 
463*4882a593Smuzhiyun 	if (!il_is_alive(il))
464*4882a593Smuzhiyun 		return -EAGAIN;
465*4882a593Smuzhiyun 
466*4882a593Smuzhiyun 	buf = kzalloc(bufsz, GFP_KERNEL);
467*4882a593Smuzhiyun 	if (!buf) {
468*4882a593Smuzhiyun 		IL_ERR("Can not allocate Buffer\n");
469*4882a593Smuzhiyun 		return -ENOMEM;
470*4882a593Smuzhiyun 	}
471*4882a593Smuzhiyun 
472*4882a593Smuzhiyun 	/* the statistic information display here is based on
473*4882a593Smuzhiyun 	 * the last stats notification from uCode
474*4882a593Smuzhiyun 	 * might not reflect the current uCode activity
475*4882a593Smuzhiyun 	 */
476*4882a593Smuzhiyun 	tx = &il->_4965.stats.tx;
477*4882a593Smuzhiyun 	accum_tx = &il->_4965.accum_stats.tx;
478*4882a593Smuzhiyun 	delta_tx = &il->_4965.delta_stats.tx;
479*4882a593Smuzhiyun 	max_tx = &il->_4965.max_delta.tx;
480*4882a593Smuzhiyun 
481*4882a593Smuzhiyun 	pos += il4965_stats_flag(il, buf, bufsz);
482*4882a593Smuzhiyun 	pos += scnprintf(buf + pos, bufsz - pos, fmt_header, "Statistics_Tx:");
483*4882a593Smuzhiyun 	pos +=
484*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "preamble:",
485*4882a593Smuzhiyun 		      le32_to_cpu(tx->preamble_cnt), accum_tx->preamble_cnt,
486*4882a593Smuzhiyun 		      delta_tx->preamble_cnt, max_tx->preamble_cnt);
487*4882a593Smuzhiyun 	pos +=
488*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "rx_detected_cnt:",
489*4882a593Smuzhiyun 		      le32_to_cpu(tx->rx_detected_cnt),
490*4882a593Smuzhiyun 		      accum_tx->rx_detected_cnt, delta_tx->rx_detected_cnt,
491*4882a593Smuzhiyun 		      max_tx->rx_detected_cnt);
492*4882a593Smuzhiyun 	pos +=
493*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "bt_prio_defer_cnt:",
494*4882a593Smuzhiyun 		      le32_to_cpu(tx->bt_prio_defer_cnt),
495*4882a593Smuzhiyun 		      accum_tx->bt_prio_defer_cnt, delta_tx->bt_prio_defer_cnt,
496*4882a593Smuzhiyun 		      max_tx->bt_prio_defer_cnt);
497*4882a593Smuzhiyun 	pos +=
498*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "bt_prio_kill_cnt:",
499*4882a593Smuzhiyun 		      le32_to_cpu(tx->bt_prio_kill_cnt),
500*4882a593Smuzhiyun 		      accum_tx->bt_prio_kill_cnt, delta_tx->bt_prio_kill_cnt,
501*4882a593Smuzhiyun 		      max_tx->bt_prio_kill_cnt);
502*4882a593Smuzhiyun 	pos +=
503*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "few_bytes_cnt:",
504*4882a593Smuzhiyun 		      le32_to_cpu(tx->few_bytes_cnt), accum_tx->few_bytes_cnt,
505*4882a593Smuzhiyun 		      delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt);
506*4882a593Smuzhiyun 	pos +=
507*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "cts_timeout:",
508*4882a593Smuzhiyun 		      le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout,
509*4882a593Smuzhiyun 		      delta_tx->cts_timeout, max_tx->cts_timeout);
510*4882a593Smuzhiyun 	pos +=
511*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "ack_timeout:",
512*4882a593Smuzhiyun 		      le32_to_cpu(tx->ack_timeout), accum_tx->ack_timeout,
513*4882a593Smuzhiyun 		      delta_tx->ack_timeout, max_tx->ack_timeout);
514*4882a593Smuzhiyun 	pos +=
515*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "expected_ack_cnt:",
516*4882a593Smuzhiyun 		      le32_to_cpu(tx->expected_ack_cnt),
517*4882a593Smuzhiyun 		      accum_tx->expected_ack_cnt, delta_tx->expected_ack_cnt,
518*4882a593Smuzhiyun 		      max_tx->expected_ack_cnt);
519*4882a593Smuzhiyun 	pos +=
520*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "actual_ack_cnt:",
521*4882a593Smuzhiyun 		      le32_to_cpu(tx->actual_ack_cnt), accum_tx->actual_ack_cnt,
522*4882a593Smuzhiyun 		      delta_tx->actual_ack_cnt, max_tx->actual_ack_cnt);
523*4882a593Smuzhiyun 	pos +=
524*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "dump_msdu_cnt:",
525*4882a593Smuzhiyun 		      le32_to_cpu(tx->dump_msdu_cnt), accum_tx->dump_msdu_cnt,
526*4882a593Smuzhiyun 		      delta_tx->dump_msdu_cnt, max_tx->dump_msdu_cnt);
527*4882a593Smuzhiyun 	pos +=
528*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table,
529*4882a593Smuzhiyun 		      "abort_nxt_frame_mismatch:",
530*4882a593Smuzhiyun 		      le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt),
531*4882a593Smuzhiyun 		      accum_tx->burst_abort_next_frame_mismatch_cnt,
532*4882a593Smuzhiyun 		      delta_tx->burst_abort_next_frame_mismatch_cnt,
533*4882a593Smuzhiyun 		      max_tx->burst_abort_next_frame_mismatch_cnt);
534*4882a593Smuzhiyun 	pos +=
535*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table,
536*4882a593Smuzhiyun 		      "abort_missing_nxt_frame:",
537*4882a593Smuzhiyun 		      le32_to_cpu(tx->burst_abort_missing_next_frame_cnt),
538*4882a593Smuzhiyun 		      accum_tx->burst_abort_missing_next_frame_cnt,
539*4882a593Smuzhiyun 		      delta_tx->burst_abort_missing_next_frame_cnt,
540*4882a593Smuzhiyun 		      max_tx->burst_abort_missing_next_frame_cnt);
541*4882a593Smuzhiyun 	pos +=
542*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table,
543*4882a593Smuzhiyun 		      "cts_timeout_collision:",
544*4882a593Smuzhiyun 		      le32_to_cpu(tx->cts_timeout_collision),
545*4882a593Smuzhiyun 		      accum_tx->cts_timeout_collision,
546*4882a593Smuzhiyun 		      delta_tx->cts_timeout_collision,
547*4882a593Smuzhiyun 		      max_tx->cts_timeout_collision);
548*4882a593Smuzhiyun 	pos +=
549*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table,
550*4882a593Smuzhiyun 		      "ack_ba_timeout_collision:",
551*4882a593Smuzhiyun 		      le32_to_cpu(tx->ack_or_ba_timeout_collision),
552*4882a593Smuzhiyun 		      accum_tx->ack_or_ba_timeout_collision,
553*4882a593Smuzhiyun 		      delta_tx->ack_or_ba_timeout_collision,
554*4882a593Smuzhiyun 		      max_tx->ack_or_ba_timeout_collision);
555*4882a593Smuzhiyun 	pos +=
556*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "agg ba_timeout:",
557*4882a593Smuzhiyun 		      le32_to_cpu(tx->agg.ba_timeout), accum_tx->agg.ba_timeout,
558*4882a593Smuzhiyun 		      delta_tx->agg.ba_timeout, max_tx->agg.ba_timeout);
559*4882a593Smuzhiyun 	pos +=
560*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table,
561*4882a593Smuzhiyun 		      "agg ba_resched_frames:",
562*4882a593Smuzhiyun 		      le32_to_cpu(tx->agg.ba_reschedule_frames),
563*4882a593Smuzhiyun 		      accum_tx->agg.ba_reschedule_frames,
564*4882a593Smuzhiyun 		      delta_tx->agg.ba_reschedule_frames,
565*4882a593Smuzhiyun 		      max_tx->agg.ba_reschedule_frames);
566*4882a593Smuzhiyun 	pos +=
567*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table,
568*4882a593Smuzhiyun 		      "agg scd_query_agg_frame:",
569*4882a593Smuzhiyun 		      le32_to_cpu(tx->agg.scd_query_agg_frame_cnt),
570*4882a593Smuzhiyun 		      accum_tx->agg.scd_query_agg_frame_cnt,
571*4882a593Smuzhiyun 		      delta_tx->agg.scd_query_agg_frame_cnt,
572*4882a593Smuzhiyun 		      max_tx->agg.scd_query_agg_frame_cnt);
573*4882a593Smuzhiyun 	pos +=
574*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table,
575*4882a593Smuzhiyun 		      "agg scd_query_no_agg:",
576*4882a593Smuzhiyun 		      le32_to_cpu(tx->agg.scd_query_no_agg),
577*4882a593Smuzhiyun 		      accum_tx->agg.scd_query_no_agg,
578*4882a593Smuzhiyun 		      delta_tx->agg.scd_query_no_agg,
579*4882a593Smuzhiyun 		      max_tx->agg.scd_query_no_agg);
580*4882a593Smuzhiyun 	pos +=
581*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "agg scd_query_agg:",
582*4882a593Smuzhiyun 		      le32_to_cpu(tx->agg.scd_query_agg),
583*4882a593Smuzhiyun 		      accum_tx->agg.scd_query_agg, delta_tx->agg.scd_query_agg,
584*4882a593Smuzhiyun 		      max_tx->agg.scd_query_agg);
585*4882a593Smuzhiyun 	pos +=
586*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table,
587*4882a593Smuzhiyun 		      "agg scd_query_mismatch:",
588*4882a593Smuzhiyun 		      le32_to_cpu(tx->agg.scd_query_mismatch),
589*4882a593Smuzhiyun 		      accum_tx->agg.scd_query_mismatch,
590*4882a593Smuzhiyun 		      delta_tx->agg.scd_query_mismatch,
591*4882a593Smuzhiyun 		      max_tx->agg.scd_query_mismatch);
592*4882a593Smuzhiyun 	pos +=
593*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "agg frame_not_ready:",
594*4882a593Smuzhiyun 		      le32_to_cpu(tx->agg.frame_not_ready),
595*4882a593Smuzhiyun 		      accum_tx->agg.frame_not_ready,
596*4882a593Smuzhiyun 		      delta_tx->agg.frame_not_ready,
597*4882a593Smuzhiyun 		      max_tx->agg.frame_not_ready);
598*4882a593Smuzhiyun 	pos +=
599*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "agg underrun:",
600*4882a593Smuzhiyun 		      le32_to_cpu(tx->agg.underrun), accum_tx->agg.underrun,
601*4882a593Smuzhiyun 		      delta_tx->agg.underrun, max_tx->agg.underrun);
602*4882a593Smuzhiyun 	pos +=
603*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "agg bt_prio_kill:",
604*4882a593Smuzhiyun 		      le32_to_cpu(tx->agg.bt_prio_kill),
605*4882a593Smuzhiyun 		      accum_tx->agg.bt_prio_kill, delta_tx->agg.bt_prio_kill,
606*4882a593Smuzhiyun 		      max_tx->agg.bt_prio_kill);
607*4882a593Smuzhiyun 	pos +=
608*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "agg rx_ba_rsp_cnt:",
609*4882a593Smuzhiyun 		      le32_to_cpu(tx->agg.rx_ba_rsp_cnt),
610*4882a593Smuzhiyun 		      accum_tx->agg.rx_ba_rsp_cnt, delta_tx->agg.rx_ba_rsp_cnt,
611*4882a593Smuzhiyun 		      max_tx->agg.rx_ba_rsp_cnt);
612*4882a593Smuzhiyun 
613*4882a593Smuzhiyun 	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
614*4882a593Smuzhiyun 	kfree(buf);
615*4882a593Smuzhiyun 	return ret;
616*4882a593Smuzhiyun }
617*4882a593Smuzhiyun 
618*4882a593Smuzhiyun static ssize_t
il4965_ucode_general_stats_read(struct file * file,char __user * user_buf,size_t count,loff_t * ppos)619*4882a593Smuzhiyun il4965_ucode_general_stats_read(struct file *file, char __user *user_buf,
620*4882a593Smuzhiyun 				size_t count, loff_t *ppos)
621*4882a593Smuzhiyun {
622*4882a593Smuzhiyun 	struct il_priv *il = file->private_data;
623*4882a593Smuzhiyun 	int pos = 0;
624*4882a593Smuzhiyun 	char *buf;
625*4882a593Smuzhiyun 	int bufsz = sizeof(struct stats_general) * 10 + 300;
626*4882a593Smuzhiyun 	ssize_t ret;
627*4882a593Smuzhiyun 	struct stats_general_common *general, *accum_general;
628*4882a593Smuzhiyun 	struct stats_general_common *delta_general, *max_general;
629*4882a593Smuzhiyun 	struct stats_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg;
630*4882a593Smuzhiyun 	struct stats_div *div, *accum_div, *delta_div, *max_div;
631*4882a593Smuzhiyun 
632*4882a593Smuzhiyun 	if (!il_is_alive(il))
633*4882a593Smuzhiyun 		return -EAGAIN;
634*4882a593Smuzhiyun 
635*4882a593Smuzhiyun 	buf = kzalloc(bufsz, GFP_KERNEL);
636*4882a593Smuzhiyun 	if (!buf) {
637*4882a593Smuzhiyun 		IL_ERR("Can not allocate Buffer\n");
638*4882a593Smuzhiyun 		return -ENOMEM;
639*4882a593Smuzhiyun 	}
640*4882a593Smuzhiyun 
641*4882a593Smuzhiyun 	/* the statistic information display here is based on
642*4882a593Smuzhiyun 	 * the last stats notification from uCode
643*4882a593Smuzhiyun 	 * might not reflect the current uCode activity
644*4882a593Smuzhiyun 	 */
645*4882a593Smuzhiyun 	general = &il->_4965.stats.general.common;
646*4882a593Smuzhiyun 	dbg = &il->_4965.stats.general.common.dbg;
647*4882a593Smuzhiyun 	div = &il->_4965.stats.general.common.div;
648*4882a593Smuzhiyun 	accum_general = &il->_4965.accum_stats.general.common;
649*4882a593Smuzhiyun 	accum_dbg = &il->_4965.accum_stats.general.common.dbg;
650*4882a593Smuzhiyun 	accum_div = &il->_4965.accum_stats.general.common.div;
651*4882a593Smuzhiyun 	delta_general = &il->_4965.delta_stats.general.common;
652*4882a593Smuzhiyun 	max_general = &il->_4965.max_delta.general.common;
653*4882a593Smuzhiyun 	delta_dbg = &il->_4965.delta_stats.general.common.dbg;
654*4882a593Smuzhiyun 	max_dbg = &il->_4965.max_delta.general.common.dbg;
655*4882a593Smuzhiyun 	delta_div = &il->_4965.delta_stats.general.common.div;
656*4882a593Smuzhiyun 	max_div = &il->_4965.max_delta.general.common.div;
657*4882a593Smuzhiyun 
658*4882a593Smuzhiyun 	pos += il4965_stats_flag(il, buf, bufsz);
659*4882a593Smuzhiyun 	pos +=
660*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_header,
661*4882a593Smuzhiyun 		      "Statistics_General:");
662*4882a593Smuzhiyun 	pos +=
663*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_value, "temperature:",
664*4882a593Smuzhiyun 		      le32_to_cpu(general->temperature));
665*4882a593Smuzhiyun 	pos +=
666*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_value, "ttl_timestamp:",
667*4882a593Smuzhiyun 		      le32_to_cpu(general->ttl_timestamp));
668*4882a593Smuzhiyun 	pos +=
669*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "burst_check:",
670*4882a593Smuzhiyun 		      le32_to_cpu(dbg->burst_check), accum_dbg->burst_check,
671*4882a593Smuzhiyun 		      delta_dbg->burst_check, max_dbg->burst_check);
672*4882a593Smuzhiyun 	pos +=
673*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "burst_count:",
674*4882a593Smuzhiyun 		      le32_to_cpu(dbg->burst_count), accum_dbg->burst_count,
675*4882a593Smuzhiyun 		      delta_dbg->burst_count, max_dbg->burst_count);
676*4882a593Smuzhiyun 	pos +=
677*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table,
678*4882a593Smuzhiyun 		      "wait_for_silence_timeout_count:",
679*4882a593Smuzhiyun 		      le32_to_cpu(dbg->wait_for_silence_timeout_cnt),
680*4882a593Smuzhiyun 		      accum_dbg->wait_for_silence_timeout_cnt,
681*4882a593Smuzhiyun 		      delta_dbg->wait_for_silence_timeout_cnt,
682*4882a593Smuzhiyun 		      max_dbg->wait_for_silence_timeout_cnt);
683*4882a593Smuzhiyun 	pos +=
684*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "sleep_time:",
685*4882a593Smuzhiyun 		      le32_to_cpu(general->sleep_time),
686*4882a593Smuzhiyun 		      accum_general->sleep_time, delta_general->sleep_time,
687*4882a593Smuzhiyun 		      max_general->sleep_time);
688*4882a593Smuzhiyun 	pos +=
689*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "slots_out:",
690*4882a593Smuzhiyun 		      le32_to_cpu(general->slots_out), accum_general->slots_out,
691*4882a593Smuzhiyun 		      delta_general->slots_out, max_general->slots_out);
692*4882a593Smuzhiyun 	pos +=
693*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "slots_idle:",
694*4882a593Smuzhiyun 		      le32_to_cpu(general->slots_idle),
695*4882a593Smuzhiyun 		      accum_general->slots_idle, delta_general->slots_idle,
696*4882a593Smuzhiyun 		      max_general->slots_idle);
697*4882a593Smuzhiyun 	pos +=
698*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "tx_on_a:",
699*4882a593Smuzhiyun 		      le32_to_cpu(div->tx_on_a), accum_div->tx_on_a,
700*4882a593Smuzhiyun 		      delta_div->tx_on_a, max_div->tx_on_a);
701*4882a593Smuzhiyun 	pos +=
702*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "tx_on_b:",
703*4882a593Smuzhiyun 		      le32_to_cpu(div->tx_on_b), accum_div->tx_on_b,
704*4882a593Smuzhiyun 		      delta_div->tx_on_b, max_div->tx_on_b);
705*4882a593Smuzhiyun 	pos +=
706*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "exec_time:",
707*4882a593Smuzhiyun 		      le32_to_cpu(div->exec_time), accum_div->exec_time,
708*4882a593Smuzhiyun 		      delta_div->exec_time, max_div->exec_time);
709*4882a593Smuzhiyun 	pos +=
710*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "probe_time:",
711*4882a593Smuzhiyun 		      le32_to_cpu(div->probe_time), accum_div->probe_time,
712*4882a593Smuzhiyun 		      delta_div->probe_time, max_div->probe_time);
713*4882a593Smuzhiyun 	pos +=
714*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "rx_enable_counter:",
715*4882a593Smuzhiyun 		      le32_to_cpu(general->rx_enable_counter),
716*4882a593Smuzhiyun 		      accum_general->rx_enable_counter,
717*4882a593Smuzhiyun 		      delta_general->rx_enable_counter,
718*4882a593Smuzhiyun 		      max_general->rx_enable_counter);
719*4882a593Smuzhiyun 	pos +=
720*4882a593Smuzhiyun 	    scnprintf(buf + pos, bufsz - pos, fmt_table, "num_of_sos_states:",
721*4882a593Smuzhiyun 		      le32_to_cpu(general->num_of_sos_states),
722*4882a593Smuzhiyun 		      accum_general->num_of_sos_states,
723*4882a593Smuzhiyun 		      delta_general->num_of_sos_states,
724*4882a593Smuzhiyun 		      max_general->num_of_sos_states);
725*4882a593Smuzhiyun 	ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
726*4882a593Smuzhiyun 	kfree(buf);
727*4882a593Smuzhiyun 	return ret;
728*4882a593Smuzhiyun }
729*4882a593Smuzhiyun 
730*4882a593Smuzhiyun const struct il_debugfs_ops il4965_debugfs_ops = {
731*4882a593Smuzhiyun 	.rx_stats_read = il4965_ucode_rx_stats_read,
732*4882a593Smuzhiyun 	.tx_stats_read = il4965_ucode_tx_stats_read,
733*4882a593Smuzhiyun 	.general_stats_read = il4965_ucode_general_stats_read,
734*4882a593Smuzhiyun };
735