• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (c) 2015, The Linux Foundation. All rights reserved.
2  *
3  * Redistribution and use in source and binary forms, with or without
4  * modification, are permitted provided that the following conditions
5  * are met:
6  *  * Redistributions of source code must retain the above copyright
7  *    notice, this list of conditions and the following disclaimer.
8  *  * Redistributions in binary form must reproduce the above
9  *    copyright notice, this list of conditions and the following
10  *    disclaimer in the documentation and/or other materials provided
11  *    with the distribution.
12  *  * Neither the name of The Linux Foundation nor the names of its
13  *    contributors may be used to endorse or promote products derived
14  *    from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef _PKT_STATS_H_
30 #define _PKT_STATS_H_
31 
32 /* Types of packet log events.
33  * Tx stats will be sent from driver with the help of multiple events.
34  * Need to parse the events PKTLOG_TYPE_TX_CTRL and PKTLOG_TYPE_TX_STAT
35  * as of now for the required stats. Rest of the events can ignored.
36  */
37 #define PKTLOG_TYPE_TX_CTRL         1
38 #define PKTLOG_TYPE_TX_STAT         2
39 #define PKTLOG_TYPE_TX_MSDU_ID      3
40 #define PKTLOG_TYPE_TX_FRM_HDR      4
41 /* Rx stats will be sent from driver with event ID- PKTLOG_TYPE_RX_STAT */
42 #define PKTLOG_TYPE_RX_STAT         5
43 #define PKTLOG_TYPE_RC_FIND         6
44 #define PKTLOG_TYPE_RC_UPDATE       7
45 #define PKTLOG_TYPE_TX_VIRT_ADDR    8
46 #define PKTLOG_TYPE_PKT_STATS       9
47 #define PKTLOG_TYPE_PKT_DUMP        10
48 #define PKTLOG_TYPE_PKT_DUMP_V2     11
49 #define PKTLOG_TYPE_MAX             12
50 #define BW_OFFSET 8
51 #define INVALID_RSSI 255
52 
53 /* Based on pkt log V2, this type of event will triggered */
54 #define PKTLOG_TYPE_PKT_SW_EVENT    10
55 
56 #define PKT_INFO_FLG_TX_LOCAL_S          0x1
57 #define PKT_INFO_FLG_RX_HOST_RXD         0x2
58 #define PKT_INFO_FLG_TX_REMOTE_S         0x4
59 #define PKT_INFO_FLG_RX_LOCAL_S          0x8
60 #define PKT_INFO_FLG_RX_REMOTE_S         0x10
61 #define PKT_INFO_FLG_RX_LOCAL_DISCARD_S  0x20
62 #define PKT_INFO_FLG_RX_REMOTE_DISCARD_S 0x40
63 #define PKT_INFO_FLG_RX_REORDER_STORE_S  0x80
64 #define PKT_INFO_FLG_RX_REORDER_DROP_S   0x100
65 #define PKT_INFO_FLG_RX_PEER_INFO_S      0x200
66 #define PKT_INFO_FLG_UNKNOWN_S           0x400
67 #define PKT_INFO_FLG_PKT_DUMP_V2         0x8000
68 
69 /* Depend on packet log version V2 this
70  * offset are define, for more info need to
71  * check from firmware side.
72  */
73 #define TX_SUCCESS_TMS_OFFSET 56
74 #define LINK_LAYER_TX_SQN_OFFSET 66
75 #define RATE_CODE_OFFSET 68
76 #define TX_STATUS_OFFSET 70
77 #define TX_RSSI_OFFSET 71
78 #define NO_RETRIES_OFFSET 75
79 #define EXT_FLAGS_OFFSET 76
80 #define BMAP_FAILED_OFFSET 84
81 #define BMAP_ENQUEUED_OFFSET 92
82 #define FRAME_CTRL_OFFSET 216
83 #define QOS_CTRL_OFFSET 218
84 
85 /* MAX HT/VHT mcs index */
86 #define MAX_VHT_MCS_IDX 10
87 #define MAX_HT_MCS_IDX 8
88 
89 /* MAX CCK/OFDM rate index */
90 #define MAX_CCK_MCS_IDX 4
91 #define MAX_OFDM_MCS_IDX 8
92 
93 /* MASK value of flags based on RX_STAT content.
94  * These are the events that carry Rx decriptor
95  */
96 #define PKT_INFO_FLG_RX_RXDESC_MASK \
97         (PKT_INFO_FLG_RX_HOST_RXD | \
98          PKT_INFO_FLG_RX_LOCAL_S | \
99          PKT_INFO_FLG_RX_REMOTE_S | \
100          PKT_INFO_FLG_RX_LOCAL_DISCARD_S | \
101          PKT_INFO_FLG_RX_REMOTE_DISCARD_S)
102 
103 /* Format of the packet stats event*/
104 typedef struct {
105     u16 flags;
106     u16 missed_cnt;
107     u16 log_type;
108     u16 size;
109     u32 timestamp;
110 } __attribute__((packed)) wh_pktlog_hdr_t;
111 
112 /* Format of the v2 packet stats event*/
113 typedef struct {
114     u16 flags;
115     u16 missed_cnt;
116     u16 log_type        : 8; //[7:0]
117     u16 mac_id          : 8; //[15:8]
118     u16 size;
119     u32 timestamp;
120     u32 reserved;
121 } __attribute__((packed)) wh_pktlog_hdr_v2_t;
122 
123 /*Rx stats specific structures. */
124 struct rx_attention {
125     u32 first_mpdu                      :  1; //[0]
126     u32 last_mpdu                       :  1; //[1]
127     u32 reserved1                       :  6; //[7:2]
128     u32 mgmt_type                       :  1; //[8]
129     u32 ctrl_type                       :  1; //[9]
130     u32 reserved2                       :  6; //[15:10]
131     u32 overflow_err                    :  1; //[16]
132     u32 msdu_length_err                 :  1; //[17]
133     u32 tcp_udp_chksum_fail             :  1; //[18]
134     u32 ip_chksum_fail                  :  1; //[19]
135     u32 reserved3                       :  7; //[26:20]
136     u32 mpdu_length_err                 :  1; //[27]
137     u32 tkip_mic_err                    :  1; //[28]
138     u32 decrypt_err                     :  1; //[29]
139     u32 fcs_err                         :  1; //[30]
140     u32 msdu_done                       :  1; //[31]
141 } __attribute__((packed));
142 
143 struct rx_mpdu_start {
144     u32 reserved1                       : 13; //[12:0]
145     u32 encrypted                       :  1; //[13]
146     u32 retry                           :  1; //[14]
147     u32 reserved2                       :  1; //[15]
148     u32 seq_num                         : 12; //[27:16]
149     u32 reserved3                       :  4; //[31:28]
150     u32 reserved4;
151     u32 reserved5                       : 28; //[27:0]
152     u32 tid                             :  4; //[31:28]
153 } __attribute__((packed));
154 
155 /*Indicates the decap-format of the packet*/
156 enum {
157     RAW=0,      // RAW: No decapsulation
158     NATIVEWIFI,
159     ETHERNET2,  // (DIX)
160     ETHERNET    // (SNAP/LLC)
161 };
162 
163 struct rx_msdu_start {
164     u32 reserved1[2];
165     u32 reserved2                       :  8; //[7:0]
166     u32 decap_format                    :  2; //[9:8]
167     u32 reserved3                       : 22; //[31:10]
168 } __attribute__((packed));
169 
170 struct rx_msdu_end {
171     u32 reserved1[4];
172     u32 reserved2                       : 15;
173     u32 last_msdu                       :  1; //[15]
174     u32 reserved3                       : 16; //[31:16]
175 } __attribute__((packed));
176 
177 struct rx_mpdu_end {
178     u32 reserved1                       : 13; //[12:0]
179     u32 overflow_err                    :  1; //[13]
180     u32 last_mpdu                       :  1; //[14]
181     u32 post_delim_err                  :  1; //[15]
182     u32 reserved2                       : 12; //[27:16]
183     u32 mpdu_length_err                 :  1; //[28]
184     u32 tkip_mic_err                    :  1; //[29]
185     u32 decrypt_err                     :  1; //[30]
186     u32 fcs_err                         :  1; //[31]
187 } __attribute__((packed));
188 
189 /* structure implemented w.r.t PKT_LOG_V2 Version */
190 struct rx_msdu_start_v1 {
191     u32 reserved1[2];
192     u32 reserved2                       :  8; //[7:0]
193     u32 decap_format                    :  2; //[9:8]
194     u32 reserved3                       : 22; //[31:10]
195     u32 reserved4[2];
196 } __attribute__((packed));
197 
198 struct rx_msdu_end_v1 {
199     u32 reserved1[4];
200     u32 reserved2                       : 15; //[14:0]
201     u32 last_msdu                       :  1; //[15]
202     u32 reserved3                       : 16; //[31:16]
203     u32 reserved4[9];
204 } __attribute__((packed));
205 /************************************************************/
206 
207 #define PREAMBLE_L_SIG_RATE     0x04
208 #define PREAMBLE_VHT_SIG_A_1    0x08
209 #define PREAMBLE_VHT_SIG_A_2    0x0c
210 
211 /* Wifi Logger preamble */
212 #define WL_PREAMBLE_CCK  0
213 #define WL_PREAMBLE_OFDM 1
214 #define WL_PREAMBLE_HT   2
215 #define WL_PREAMBLE_VHT  3
216 
217 #define BITMASK(x) ((1<<(x)) - 1 )
218 #define MAX_BA_WINDOW_SIZE 64
219 #define SEQ_NUM_RANGE 4096
220 #define BITMAP_VAR_SIZE 32
221 
222 /* Contains MCS related stats */
223 struct rx_ppdu_start {
224     u32 reserved1[4];
225     u32 rssi_comb                       :  8; //[7:0]
226     u32 reserved2                       : 24; //[31:8]
227     u32 l_sig_rate                      :  4; //[3:0]
228     u32 l_sig_rate_select               :  1; //[4]
229     u32 reserved3                       : 19; //[23:5]
230     u32 preamble_type                   :  8; //[31:24]
231     u32 ht_sig_vht_sig_a_1              : 24; //[23:0]
232     u32 reserved4                       :  8; //[31:24]
233     u32 ht_sig_vht_sig_a_2              : 24; //[23:0]
234     u32 reserved5                       :  8; //[31:25]
235     u32 reserved6[2];
236 } __attribute__((packed));
237 
238 struct rx_ppdu_end {
239     u32 reserved1[16];
240     u32 tsf_timestamp;
241     u32 reserved2[5];
242 } __attribute__((packed));
243 
244 struct rx_ppdu_end_V1 {
245     u32 reserved1[18];
246     u32 wb_timestamp_lower_32;
247     u32 reserved2[18];
248 } __attribute__((packed));
249 
250 #define MAX_MSDUS_PER_MPDU 3
251 #define MAX_RXMPDUS_PER_AMPDU 64
252 #define RX_HTT_HDR_STATUS_LEN 64
253 /* RX Data length is 256 for PKT_LOG_V2 Version */
254 #define RX_HTT_HDR_STATUS_LEN_V1 256
255 
256 typedef struct {
257     struct rx_attention attention;
258     u32 reserved1;
259     struct rx_mpdu_start mpdu_start;
260     struct rx_msdu_start msdu_start;
261     struct rx_msdu_end   msdu_end;
262     struct rx_mpdu_end   mpdu_end;
263     struct rx_ppdu_start ppdu_start;
264     struct rx_ppdu_end   ppdu_end;
265     char rx_hdr_status[RX_HTT_HDR_STATUS_LEN];
266 }__attribute__((packed)) rb_pkt_stats_t;
267 
268 /* structure implemented w.r.t PKT_LOG_V2 Version */
269 typedef struct {
270     struct rx_attention attention;
271     u32 reserved1[2];
272     struct rx_mpdu_start    mpdu_start;
273     struct rx_msdu_start_v1 msdu_start;
274     struct rx_msdu_end_v1   msdu_end;
275     struct rx_mpdu_end      mpdu_end;
276     struct rx_ppdu_start    ppdu_start;
277     struct rx_ppdu_end_V1    ppdu_end;
278     char rx_hdr_status[RX_HTT_HDR_STATUS_LEN_V1];
279 }__attribute__((packed)) rb_pkt_stats_t_v1;
280 /************************************************************/
281 
282 /*Tx stats specific structures. */
283 struct ppdu_status {
284     u32 ba_start_seq_num                : 12; //[11:0]
285     u32 reserved1                       :  3; //[14:12]
286     u32 ba_status                       :  1; //[15]
287     u32 reserved2                       : 15; //[30:16]
288     u32 tx_ok                           :  1; //[31]
289     u32 ba_bitmap_31_0                  : 32; //[31:0]
290     u32 ba_bitmap_63_32                 : 32; //[31:0]
291     u32 reserved3[8];
292     u32 ack_rssi_ave                    :  8; //[7:0]
293     u32 reserved4                       : 16; //[23:8]
294     u32 total_tries                     :  5; //[28:24]
295     u32 reserved5                       :  3; //[31:29]
296     u32 reserved6[4];
297 } __attribute__((packed));
298 
299 /*Contains tx timestamp*/
300 struct try_status {
301     u32 timestamp                       : 23; //[22:0]
302     u32 reserved1                       :  1; //[23]
303     u32 series                          :  1; //[24]
304     u32 reserved2                       :  3; //[27:25]
305     u32 packet_bw                       :  2; //[29:28]
306     u32 reserved3                       :  1; //[30]
307     u32 tx_packet                       :  1; //[31]
308 } __attribute__((packed));
309 
310 struct try_list {
311     struct try_status try_st[16];
312 } __attribute__((packed));
313 
314 
315 struct tx_ppdu_end {
316     struct try_list try_list;
317     struct ppdu_status stat;
318 } __attribute__((packed));
319 
320 /*Tx MCS and data rate ralated stats */
321 struct series_bw {
322     u32 reserved1                       : 28; //[27:0]
323     u32 short_gi                        :  1; //[28]
324     u32 reserved2                       :  3; //[31:29]
325     u32 reserved3                       : 24; //[23:21]
326     u32 rate                            :  4; //[27:24]
327     u32 nss                             :  2; //[29:28]
328     u32 preamble_type                   :  2; //[31:30]
329     u32 reserved4[2];
330 } __attribute__((packed));
331 
332 enum tx_bw {
333     BW_20_MHZ,
334     BW_40_MHZ,
335     BW_80_MHZ,
336     BW_160_MHZ
337 };
338 
339 #define DATA_PROTECTED 14
340 struct tx_ppdu_start {
341     u32 reserved1[2];
342     u32 start_seq_num                   : 12; //[11:0]
343     u32 reserved2                       : 20; //[31:12]
344     u32 seqnum_bitmap_31_0              : 32; //[31:0]
345     u32 seqnum_bitmap_63_32             : 32; //[31:0]
346     u32 reserved3[8];
347     u32 reserved4                       : 15; //[14:0]
348     u32 ampdu                           :  1; //[15]
349     u32 no_ack                          :  1; //[16]
350     u32 reserved5                       : 15; //[31:17]
351     u32 reserved6                       : 16; //[15:0]
352     u32 frame_control                   : 16; //[31:16]
353     u32 reserved7                       : 16; //[23:21]
354     u32 qos_ctl                         : 16; //[31:16]
355     u32 reserved8[4];
356     u32 reserved9                       : 24; //[23:21]
357     u32 valid_s0_bw20                   :  1; //[24]
358     u32 valid_s0_bw40                   :  1; //[25]
359     u32 valid_s0_bw80                   :  1; //[26]
360     u32 valid_s0_bw160                  :  1; //[27]
361     u32 valid_s1_bw20                   :  1; //[28]
362     u32 valid_s1_bw40                   :  1; //[29]
363     u32 valid_s1_bw80                   :  1; //[30]
364     u32 valid_s1_bw160                  :  1; //[31]
365     struct series_bw s0_bw20;
366     struct series_bw s0_bw40;
367     struct series_bw s0_bw80;
368     struct series_bw s0_bw160;
369     struct series_bw s1_bw20;
370     struct series_bw s1_bw40;
371     struct series_bw s1_bw80;
372     struct series_bw s1_bw160;
373     u32 reserved10[3];
374 } __attribute__((packed));
375 
376 #define PKTLOG_MAX_TXCTL_WORDS 57 /* +2 words for bitmap */
377 typedef struct {
378     u32 reserved1[3];
379     union {
380         u32 txdesc_ctl[PKTLOG_MAX_TXCTL_WORDS];
381         struct tx_ppdu_start ppdu_start;
382     }u;
383 } __attribute__((packed)) wh_pktlog_txctl;
384 
385 /* Required stats are spread across multiple
386  * events(PKTLOG_TYPE_TX_CTRL and PKTLOG_TYPE_TX_STAT here).
387  * Need to aggregate the stats collected in each event and write to the
388  * ring buffer only after receiving all the expected stats.
389  * Need to preserve the stats in hal_info till then and use tx_stats_events
390  * flag to track the events.
391  * prev_seq_no: Can used to track the events that come from driver and identify
392  * if any event is missed.
393  */
394 
395 /* PKT_LOG_V2 Base strcuture used to parse buffer */
396 typedef struct {
397     u16 frm_ctrl;
398     u8  tx_ok;
399     u16 qos_ctrl;
400     u64 bmap_failed;
401     u64 bmap_enqueued;
402 } __attribute__((packed)) node_pkt_stats;
403 
404 typedef u8 A_RATECODE;
405 
406 /* Rate Code as per PKT_LOG_V2 Version */
407 typedef struct {
408     A_RATECODE rateCode;
409     u8 flags;
410 } RATE_CODE;
411 
412 /* bandwidht type*/
413 typedef enum {
414     BW_20MHZ,
415     BW_40MHZ,
416     BW_80MHZ,
417     BW_160MHZ,
418 } bandwidth;
419 
420 /* Preamble type*/
421 typedef enum {
422     WIFI_HW_RATECODE_PREAM_OFDM = 0,
423     WIFI_HW_RATECODE_PREAM_CCK  = 1,
424     WIFI_HW_RATECODE_PREAM_HT   = 2,
425     WIFI_HW_RATECODE_PREAM_VHT  = 3,
426     WIFI_HW_RATECODE_PREAM_COUNT,
427 } WIFI_HW_RATECODE_PREAM_TYPE;
428 
429 /**
430  * struct index_data_rate_type - non vht data rate type
431  * @rate_index: cck  rate index
432  * @cck_rate: CCK supported rate table
433  */
434 struct index_data_rate_cck_type {
435     uint8_t  rate_index;
436     uint16_t cck_rate[2];
437 };
438 
439 /**
440  * struct index_data_rate_type - non vht data rate type
441  * @rate_index: ofdm  rate index
442  * @ofdm__rate: OFDM supported rate table
443  */
444 struct index_data_rate_ofdm_type {
445     uint8_t  rate_index;
446     uint16_t ofdm_rate[2];
447 };
448 
449 /*Below CCK/OFDM table refer from firmware Arch */
450 /* Rate Table Based on CCK */
451 static struct index_data_rate_cck_type cck_mcs_nss1[] = {
452     /*RC     LKbps   SKbps */
453     {0x40,  {11000,  11000} },
454     {0x41,  {5500,   5500} },
455     {0x42,  {2000,   2000} },
456     {0x43,  {1000,   1000} }
457 };
458 
459 /* Rate Table Based on OFDM */
460 static struct index_data_rate_ofdm_type ofdm_mcs_nss1[] = {
461     /*RC     LKbps   SKbps */
462     {0x00,  {48000,  48000} },
463     {0x01,  {34000,  24000} },
464     {0x02,  {12000,  12000} },
465     {0x03,  {6000,   6000} },
466     {0x04,  {54000,  54000} },
467     {0x05,  {36000,  36000} },
468     {0x06,  {18000,  18000} },
469     {0x07,  {9000,   9000} }
470 };
471 
472 /**
473  * struct index_data_rate_type - non vht data rate type
474  * @mcs_index: mcs rate index
475  * @ht20_rate: HT20 supported rate table
476  * @ht40_rate: HT40 supported rate table
477  */
478 struct index_data_rate_type {
479     uint8_t  mcs_index;
480     uint16_t ht20_rate[2];
481     uint16_t ht40_rate[2];
482 };
483 
484 /**
485  * struct index_vht_data_rate_type - vht data rate type
486  * @mcs_index: mcs rate index
487  * @ht20_rate: VHT20 supported rate table
488  * @ht40_rate: VHT40 supported rate table
489  * @ht80_rate: VHT80 supported rate table
490  */
491 struct index_vht_data_rate_type {
492     uint8_t mcs_index;
493     uint16_t ht20_rate[2];
494     uint16_t ht40_rate[2];
495     uint16_t ht80_rate[2];
496 };
497 
498 /*Below HT/VHT table refer from Host Driver
499  * MCS Based rate table
500  * HT MCS parameters with Nss = 1
501  */
502 static struct index_data_rate_type mcs_nss1[] = {
503     /* MCS L20  S20   L40   S40 */
504     {0,  {65,  72},  {135,  150 } },
505     {1,  {130, 144}, {270,  300 } },
506     {2,  {195, 217}, {405,  450 } },
507     {3,  {260, 289}, {540,  600 } },
508     {4,  {390, 433}, {815,  900 } },
509     {5,  {520, 578}, {1080, 1200} },
510     {6,  {585, 650}, {1215, 1350} },
511     {7,  {650, 722}, {1350, 1500} }
512 };
513 
514 /* HT MCS parameters with Nss = 2 */
515 static struct index_data_rate_type mcs_nss2[] = {
516     /* MCS L20  S20    L40   S40 */
517     {0,  {130,  144},  {270,  300 } },
518     {1,  {260,  289},  {540,  600 } },
519     {2,  {390,  433},  {810,  900 } },
520     {3,  {520,  578},  {1080, 1200} },
521     {4,  {780,  867},  {1620, 1800} },
522     {5,  {1040, 1156}, {2160, 2400} },
523     {6,  {1170, 1300}, {2430, 2700} },
524     {7,  {1300, 1440}, {2700, 3000} }
525 };
526 
527 /* MCS Based VHT rate table
528  * MCS parameters with Nss = 1
529  */
530 static struct index_vht_data_rate_type vht_mcs_nss1[] = {
531     /* MCS L20  S20    L40   S40    L80   S80 */
532     {0,  {65,   72 }, {135,  150},  {293,  325} },
533     {1,  {130,  144}, {270,  300},  {585,  650} },
534     {2,  {195,  217}, {405,  450},  {878,  975} },
535     {3,  {260,  289}, {540,  600},  {1170, 1300} },
536     {4,  {390,  433}, {810,  900},  {1755, 1950} },
537     {5,  {520,  578}, {1080, 1200}, {2340, 2600} },
538     {6,  {585,  650}, {1215, 1350}, {2633, 2925} },
539     {7,  {650,  722}, {1350, 1500}, {2925, 3250} },
540     {8,  {780,  867}, {1620, 1800}, {3510, 3900} },
541     {9,  {865,  960}, {1800, 2000}, {3900, 4333} }
542 };
543 
544 /*MCS parameters with Nss = 2*/
545 static struct index_vht_data_rate_type vht_mcs_nss2[] = {
546     /* MCS L20  S20    L40    S40    L80    S80 */
547     {0,  {130,  144},  {270,  300},  { 585,  650} },
548     {1,  {260,  289},  {540,  600},  {1170, 1300} },
549     {2,  {390,  433},  {810,  900},  {1755, 1950} },
550     {3,  {520,  578},  {1080, 1200}, {2340, 2600} },
551     {4,  {780,  867},  {1620, 1800}, {3510, 3900} },
552     {5,  {1040, 1156}, {2160, 2400}, {4680, 5200} },
553     {6,  {1170, 1300}, {2430, 2700}, {5265, 5850} },
554     {7,  {1300, 1444}, {2700, 3000}, {5850, 6500} },
555     {8,  {1560, 1733}, {3240, 3600}, {7020, 7800} },
556     {9,  {1730, 1920}, {3600, 4000}, {7800, 8667} }
557 };
558 /*********************************************************/
559 
560 #define RING_BUF_ENTRY_SIZE 512
561 #define PKT_STATS_BUF_SIZE 128
562 struct pkt_stats_s {
563     u8 tx_stats_events;
564     /* TODO: Need to handle the case if size of the stats are more
565      * than 512 bytes. Currently, the tx size is 34 bytes and ring buffer entry
566      * size is 12 bytes.
567      */
568     u8 tx_stats[PKT_STATS_BUF_SIZE];
569     u8 num_msdu;
570     u16 start_seq_num;
571     u16 ba_seq_num;
572     u32 ba_bitmap_31_0;
573     u32 ba_bitmap_63_32;
574     u32 tx_seqnum_bitmap_31_0;
575     u32 tx_seqnum_bitmap_63_32;
576     u32 shifted_bitmap_31_0;
577     u32 shifted_bitmap_63_32;
578     bool isBlockAck;
579     u8 tx_bandwidth;
580     u8 series;
581 };
582 
583 typedef union {
584     struct {
585         u16 rate                            :  4;
586         u16 nss                             :  2;
587         u16 preamble                        :  2;
588         u16 bw                              :  2;
589         u16 short_gi                        :  1;
590         u16 reserved                        :  5;
591     } mcs_s;
592     u16 mcs;
593 } MCS;
594 
595 typedef struct {
596     MCS RxMCS;
597     u16 last_transmit_rate;
598     u16 rssi;
599     u32 timestamp;
600     u8  tid;
601 } rx_aggr_stats;
602 
603 
604 typedef struct drv_msg_s
605 {
606     u16 length;
607     u16 event_type;
608     u32 timestamp_low;
609     u32 timestamp_high;
610     union {
611         struct {
612             u32 version;
613             u32 msg_seq_no;
614             u32 payload_len;
615             u8  payload[0];
616         } __attribute__((packed)) pkt_stats_event;
617     } u;
618 } __attribute__((packed)) drv_msg_t;
619 
620 typedef enum {
621     START_MONITOR = 1,
622     STOP_MONITOR,
623     TX_MGMT_PKT,
624     TX_DATA_PKT,
625     RX_MGMT_PKT,
626     RX_DATA_PKT,
627 } pktdump_event_type;
628 
629 typedef struct {
630     u8 status;
631     u8 type;
632     u32 driver_ts;
633     u16 fw_ts;
634 } __attribute__((packed)) pktdump_hdr;
635 
636 typedef struct {
637     frame_type payload_type;
638     u32 driver_timestamp_usec;
639     u32 firmware_timestamp_usec;
640     size_t frame_len;
641     char *frame_content;
642 } frame_info_i;
643 
644 typedef struct {
645     // Prefix of MD5 hash of |frame_inf.frame_content|. If frame
646     // content is not provided, prefix of MD5 hash over the same data
647     // that would be in frame_content, if frame content were provided.
648     char md5_prefix[MD5_PREFIX_LEN];  // Prefix of MD5 hash of packet bytes
649     wifi_tx_packet_fate fate;
650     frame_info_i frame_inf;
651 } wifi_tx_report_i;
652 
653 typedef struct {
654     // Prefix of MD5 hash of |frame_inf.frame_content|. If frame
655     // content is not provided, prefix of MD5 hash over the same data
656     // that would be in frame_content, if frame content were provided.
657     char md5_prefix[MD5_PREFIX_LEN];
658     wifi_rx_packet_fate fate;
659     frame_info_i frame_inf;
660 } wifi_rx_report_i;
661 
662 typedef struct {
663     wifi_tx_report_i tx_fate_stats[MAX_FATE_LOG_LEN];
664     size_t n_tx_stats_collected;
665     wifi_rx_report_i rx_fate_stats[MAX_FATE_LOG_LEN];
666     size_t n_rx_stats_collected;
667 } packet_fate_monitor_info;
668 
669 #endif
670