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