1 /*
2  * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #pragma once
8 
9 #include <stdint.h>
10 #include <stdbool.h>
11 #include "sys/queue.h"
12 #include "esp_err.h"
13 #include "esp_event_base.h"
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 typedef enum {
20     SIG_MODE_LEGACY = 0,
21     SIG_MODE_HT = 1,
22     SIG_MODE_HE = 2,
23     SIG_MODE_VHT = 3,
24 } sig_mode_t;
25 
26 typedef struct {
27     uint32_t mcs : 7;
28     uint32_t cwb : 1;
29     uint32_t ht_length : 16;
30     uint32_t smoothing : 1;
31     uint32_t not_sounding : 1;
32     uint32_t : 1;
33     uint32_t aggregation : 1;
34     uint32_t stbc : 2;
35     uint32_t fec_coding : 1;
36     uint32_t sgi : 1;
37 } esp_wifi_htsig_t;
38 
39 typedef struct {
40     uint32_t format : 1;
41     uint32_t beam_change : 1;
42     uint32_t ul_dl : 1;
43     uint32_t he_mcs : 4;
44     uint32_t dcm : 1;
45     uint32_t bss_color : 6;
46     uint32_t rsvd : 1;
47     uint32_t spatial_reuse : 4;
48     uint32_t bw : 2;
49     uint32_t gi_and_he_ltf_size : 2;
50     uint32_t nsts_and_midamble_periodicity : 3;
51     uint32_t rsvd1 : 6;
52 } esp_wifi_su_siga1_t;
53 
54 typedef struct {
55     uint32_t format : 1;
56     uint32_t bss_color : 6;
57     uint32_t spatial_reuse1 : 4;
58     uint32_t spatial_reuse2 : 4;
59     uint32_t spatial_reuse3 : 4;
60     uint32_t spatial_reuse4 : 4;
61     uint32_t rsvd : 1;
62     uint32_t bw : 2;
63     uint32_t rsvd1 : 6;
64 } esp_wifi_tb_siga1_t;
65 
66 typedef struct {
67     uint32_t ul_dl : 1;
68     uint32_t sigb_mcs : 3;
69     uint32_t sigb_dcm : 1;
70     uint32_t bss_color : 6;
71     uint32_t spatial_reuse : 4;
72     uint32_t bw : 3;
73     uint32_t sigb_sym_num_or_mu_mimo_users : 4;
74     uint32_t sigb_compression : 1;
75     uint32_t gi_and_he_ltf_size : 2;
76     uint32_t doppler : 1;
77     uint32_t rsvd : 6;
78 } esp_wifi_mu_siga1_t;
79 
80 typedef struct {
81     uint16_t txop : 7;
82     uint16_t coding : 1;
83     uint16_t ldpc_extra_symbol_segment : 1;
84     uint16_t stbc : 1;
85     uint16_t beamformed : 1;
86     uint16_t pre_fec_padding_factor : 2;
87     uint16_t pe_disambiguity : 1;
88     uint16_t rsvd : 1;
89     uint16_t doppler : 1;
90 } __attribute__((packed)) esp_wifi_su_siga2_t;
91 
92 typedef struct {
93     uint16_t txop : 7;
94     uint16_t siga2_rsvd : 9;
95 } __attribute__((packed)) esp_wifi_tb_siga2_t;
96 
97 typedef struct {
98     uint16_t txop : 7;
99     uint16_t rsvd : 1;
100     uint16_t nltf_and_midamble_periodicity : 3;
101     uint16_t ldpc_extra_symbol_segment : 1;
102     uint16_t stbc : 1;
103     uint16_t pre_fec_padding_factor : 2;
104     uint16_t pe_disambiguation : 1;
105 } __attribute__((packed)) esp_wifi_mu_siga2_t;
106 
107 #define ESP_TEST_RX_MU_USER_NUM        (9)
108 //support buffer mu-users for 4 duts
109 typedef struct {
110     uint16_t aid;
111     /* MIMO */
112     uint32_t mimo_rx;
113     uint32_t mimo_sigb_mcs[6];      //MCS[0, 5]
114     /*
115      * count sigb info, max: 8 users
116      *
117      * mimo_user_num_occu[0] = the number of occurrences of user_num=2 within a period of rx
118      * mimo_user_num_occu[1] = the number of occurrences of user_num=3 within a period of rx
119      * ......
120      * mimo_user_num_occu[6] = the number of occurrences of user_num=8 within a period of rx
121      */
122     uint32_t mimo_user_num_occu[7]; //UserNum[2, 8]
123     struct {
124         uint16_t aid;
125         uint32_t occu_mcs[12];
126         /*
127          * occu_ss[0] = the number of occurrences of SS0 within a period of rx
128          * occu_ss[1] = the number of occurrences of SS1 within a period of rx
129          * ......
130          * occu_ss[7] = the number of occurrences of SS7 within a period of rx
131          */
132         uint32_t occu_ss[8];
133     } mimo[ESP_TEST_RX_MU_USER_NUM];
134     /* Non-MIMO */
135     uint32_t nonmimo_rx;
136     uint32_t nonmimo_sigb_mcs[6];      //MCS[0, 5]
137     uint32_t nonmimo_ru_alloc[256][9]; // size: 9216 bytes
138     uint32_t nonmimo_user_num_occu[9]; // UserNum[1, 9]
139     struct {
140         uint16_t aid;
141         uint32_t occu_nsts[8];
142         uint32_t occu_mcs[12];
143         uint32_t txbf;
144         uint32_t dcm;
145     } nonmimo[ESP_TEST_RX_MU_USER_NUM];
146     uint32_t ru_alloc_96_num_2046; // 106+106
147     uint32_t ru_alloc_112_num_2046; // 52+52+52+52
148 } esp_test_rx_mu_statistics_t; //10932 bytes
149 
150 typedef struct {
151     uint32_t legacy;
152     uint32_t legacy_noeb;
153     uint32_t ht;
154     uint32_t ht_noeb;
155     uint32_t ht_retry;
156     uint32_t ersu;
157     uint32_t ersu_noeb;
158     uint32_t ersu_dcm;
159     uint32_t su;
160     uint32_t su_noeb;
161     uint32_t su_stbc;
162     uint32_t su_txbf;
163     uint32_t su_retry;
164     uint32_t mu;
165     uint32_t mu_noeb;
166     uint32_t mu_stbc;
167     uint32_t mu_mimo;
168     uint32_t mu_ofdma;
169     uint32_t mu_txbf;
170     uint32_t mu_retry;
171     uint32_t rx_isr;
172     uint32_t rx_nblks;
173 } esp_test_rx_statistics_t; //88 bytes
174 
175 typedef enum {
176     TEST_TX_SUCCESS,
177     TEST_TX_FAIL_RTS,
178     TEST_TX_WAIT_CTS,    //RX
179     TEST_TX_FAIL_CTS,
180     TEST_TX_FAIL_DATA,
181     TEST_TX_WAIT_ACK,    //RX
182     TEST_TX_FAIL_MAX,
183 } esp_test_tx_fail_state_t;
184 
185 /* only happen when TEST_TX_WAIT_CTS(2), TEST_TX_WAIT_ACK(5) */
186 typedef enum {
187     TEST_TX_WAIT_MATCH,
188     TEST_TX_WAIT_NOT2SELF,
189     TEST_TX_MISMATCH,
190     TEST_TX_WAIT_TIMEOUT,
191     TEST_TX_WAIT_MAX,
192 } esp_test_tx_fail_match_t;
193 
194 /* only happen when TEST_TX_WAIT_MATCH(0) */
195 typedef enum {
196     TEST_TX_FAIL_ERROR_H00,
197     TEST_TX_FAIL_ERROR_H53,
198     TEST_TX_FAIL_ERROR_H63,
199     TEST_TX_FAIL_ERROR_H75,
200     TEST_TX_FAIL_ERROR_H41,
201     TEST_TX_FAIL_ERROR_H42,
202     TEST_TX_FAIL_ERROR_H47,
203     TEST_TX_FAIL_ERROR_H80,
204     TEST_TX_FAIL_ERROR_H5A,
205     TEST_TX_FAIL_ERROR_HXX,
206     TEST_TX_FAIL_ERROR_MAX, //10
207 } esp_test_tx_fail_error_t;
208 
209 typedef struct {
210     uint32_t match[TEST_TX_WAIT_MAX][TEST_TX_FAIL_ERROR_MAX];
211     uint32_t count;
212 } esp_test_tx_fail_statistics_t; //164 bytes
213 
214 typedef struct {
215     uint32_t tb_last;         /* count times of the last TX through TB */
216     uint32_t tb_times;        /* count total TX times through TB */
217     uint32_t tb_rx_ba;        /* can't know the exact packets number of BA or ACK*/
218     uint32_t retry_edca;
219     uint32_t retry_tb;
220     uint32_t rx_ack;          /* count ACKs response to TX through EDCA */
221     uint32_t rx_ba;           /* count BAs response to TX through EDCA */
222     uint32_t rx_dump_ba;
223     uint8_t rx_max_bitmap;
224     uint8_t rx_min_bitmap;
225     uint32_t rx_tot_bitmap;
226     uint32_t tx_enable;
227     uint32_t tx_complete;
228     uint32_t tx_succ;
229     uint32_t tx_no_mem;
230     uint32_t tx_max_rtt;
231     uint32_t tx_min_rtt;
232     uint32_t tx_tot_rtt;
233     uint32_t tx_seq_max_rtt; /* rtt of a sequence number containing the time of retries */
234     uint32_t tx_seq_min_rtt;
235     int64_t tx_start_time;
236     int64_t tx_seqno_time;
237     int64_t tx_muedca_time;
238     uint32_t tx_max_muedca_time;
239     uint32_t tx_min_muedca_time;
240     uint32_t tx_tot_muedca_time;
241     uint32_t muedca_times;
242     uint32_t tx_muedca_enable; /* count TX times within mu-timer working */
243     uint32_t collision;
244     uint32_t timeout;
245 } esp_test_tx_statistics_t; //136 bytes
246 
247 typedef struct {
248     uint32_t complete_suc_tb;
249     uint32_t complete_ack_tb;
250     uint32_t complete_err_tb;
251     uint32_t complete_tb_suc_count;
252     uint32_t complete_tb_ack_count;
253     uint32_t complete_tb_err_count;
254     uint32_t complete_tb_tot_count;
255     uint32_t complete_tb_pack_sent;
256 } esp_test_tx_tb_statistics_t; //32 bytes
257 
258 typedef struct {
259     uint16_t rx_trig;
260     uint16_t tb_times;
261     uint16_t tb_qos_null;
262     uint16_t tx_bfrpt;
263     uint16_t tb_cca_cancel;
264     uint16_t tb_sifs_abort;
265     uint16_t tb_pwr_outof_range;
266 } esp_test_hw_tb_statistics_t; //14 bytes
267 
268 typedef struct {
269     uint16_t rx_fcs_err;
270     uint16_t rx_abort;
271     uint16_t rx_abort_fcs_pass;
272     uint16_t nrx_err_pwrdrop;
273     uint16_t nrx_hesigb_err;
274     uint16_t rx_samebm_errcnt;
275     uint16_t rx_mpdu;
276     uint16_t rx_end_cnt;
277     uint16_t rx_datasuc;
278     int16_t rx_cfo_hz;
279     uint16_t rx_sf;
280     uint16_t rx_other_ucast;
281     uint16_t rx_buf_fullcnt;
282     uint16_t rx_fifo_ovfcnt;
283     uint16_t rx_tkip_errcnt;
284     uint16_t rx_btblock_err;
285     uint16_t rx_freqhop_err;
286     uint16_t rx_lastunmatch_err;
287     uint16_t rx_ack_int_cnt;
288     uint16_t rx_rts_int_cnt;
289     uint16_t brx_err_agc;
290     uint16_t brx_err;
291     uint16_t nrx_err;
292     uint16_t nrx_err_abort;
293     uint16_t nrx_err_agcexit;
294     uint16_t nrx_err_bboff;
295     uint16_t nrx_err_fdm_wdg;
296     uint16_t nrx_err_restart;
297     uint16_t nrx_err_serv;
298     uint16_t nrx_err_txover;
299     uint16_t nrx_err_unsupport;
300     uint16_t nrx_htsig_err;
301     uint16_t nrx_heunsupport;
302     uint16_t nrx_hesiga_crc;
303     uint16_t rxhung_statis;
304     uint16_t txhung_statis;
305     uint32_t rxtxhung;
306 } esp_test_hw_rx_statistics_t; //76 bytes
307 
308 typedef struct {
309     uint32_t tot;
310     uint32_t occurs[2];       // 0: 0xc6 same bitmap; 1: 0xf5 tkip error
311 } esp_test_rx_error_occurs_t; //12 bytes
312 
313 
314 #ifdef __cplusplus
315 }
316 #endif
317