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 "esp_err.h"
12 #include "esp_wifi_types.h"
13 #include "esp_wifi_he_types.h"
14 #include "esp_wifi_he_types_private.h"
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 float esp_test_get_bfr_avgsnr(void);
21 
22 void esp_test_enable_edca_tx(esp_wifi_aci_t aci);
23 void esp_test_disable_edca_tx(esp_wifi_aci_t aci);
24 
25 esp_err_t esp_wifi_enable_htc_uph(bool enable);
26 esp_err_t esp_wifi_set_htc_omc(const esp_wifi_htc_omc_t *om);
27 void esp_wifi_enable_rx_stbc(bool enable);
28 void esp_wifi_enable_su_bmfmee(bool enable);
29 esp_err_t esp_wifi_set_tf_padding_duration(int tf_padding_duration);
30 void esp_test_set_tx_mcs_pwr(wifi_phy_rate_t rate, int8_t max_pwr);
31 
32 void hal_he_set_ul_mu(bool ul_mu_disable, bool ul_mu_data_disable);
33 void hal_he_set_bf_report_rate(sig_mode_t sig_mode, wifi_phy_rate_t rate);
34 
35 void dbg_read_muedca_timer(uint8_t aci);
36 void dbg_read_axtb_diag(void);
37 void dbg_read_ax_diag(bool verbose);
38 void dbg_tb_ignore_cca_enable(bool enable);
39 
40 esp_err_t esp_wifi_sta_report_bsscolor_collision(void);
41 esp_err_t esp_wifi_sta_report_bsscolor_inuse(void);
42 
43 /* RX */
44 esp_err_t esp_test_clr_rx_error_occurs(void);
45 esp_err_t esp_test_get_rx_error_occurs(esp_test_rx_error_occurs_t *err_occurs);
46 
47 /* HW */
48 void esp_test_clr_hw_statistics(void);
49 esp_err_t esp_test_get_hw_rx_statistics(esp_test_hw_rx_statistics_t *hw_rx_stats);
50 esp_err_t esp_test_get_hw_tb_statistics(esp_test_hw_tb_statistics_t *hw_tb_stats);
51 
52 /**
53   * @brief     Clear DL MU-MIMO and DL OFDMA reception statistics.
54   *
55   * @return
56   *    - ESP_OK
57   *    - ESP_FAIL
58   */
59 esp_err_t esp_wifi_clr_rx_mu_statistics(void);
60 
61 /**
62   * @brief     Get the DL MU-MIMO and DL OFDMA reception statistics.
63   *
64   * @param[in]    mu_stats the DL MU-MIMO and DL OFDMA reception statistics
65   *
66   * @return
67   *    - ESP_OK
68   *    - ESP_FAIL
69   */
70 esp_err_t esp_wifi_get_rx_mu_statistics(esp_test_rx_mu_statistics_t *mu_stats);
71 
72 /**
73   * @brief     Clear the reception statistics excluding DL MU-MIMO and DL OFDMA.
74   *
75   * @param[in]    tid the traffic id, accept tid = 0, tid = 7 and tid = 8. tid = 8 will clear reception statistics for both tid = 0 and tid = 7
76   *
77   * @return
78   *    - ESP_OK
79   *    - ESP_FAIL
80   */
81 esp_err_t esp_wifi_clr_rx_statistics(uint8_t tid);
82 
83 /**
84   * @brief     Get the reception statistics excluding DL MU-MIMO and DL OFDMA.
85   *
86   * @param[in]    tid the traffic id, only accept tid = 0 or tid = 7
87   * @param[in]    rx_stats the reception statistics
88   *
89   * @return
90   *    - ESP_OK
91   *    - ESP_FAIL
92   */
93 esp_err_t esp_wifi_get_rx_statistics(uint8_t tid, esp_test_rx_statistics_t *rx_stats);
94 
95 /**
96   * @brief     Clear the transmission statistics.
97   *
98   * @param[in]    aci access category id.
99   *                   Generally, for data frames, aci = ESP_WIFI_ACI_BE; for management frames, aci = ESP_WIFI_ACI_VO.
100   *
101   * @return
102   *    - ESP_OK
103   *    - ESP_FAIL
104   */
105 esp_err_t esp_wifi_clr_tx_statistics(esp_wifi_aci_t aci);
106 
107 /**
108   * @brief     Get the transmission statistics.
109   *
110   * @param[in]    aci access category id.
111   * @param[in]    tx_stats the transmission statistics
112   * @param[in]    tx_fail the common failure state and reason
113   *
114   * @return
115   *    - ESP_OK
116   *    - ESP_FAIL
117   */
118 esp_err_t esp_wifi_get_tx_statistics(esp_wifi_aci_t aci, esp_test_tx_statistics_t *tx_stats, esp_test_tx_fail_statistics_t *tx_fail);
119 
120 /**
121   * @brief     Clear the TB PPDU transmission statistics.
122   *
123   * @param[in]    aci access category id.
124   *                   Generally, for data frames, aci = ESP_WIFI_ACI_BE; for management frames, aci = ESP_WIFI_ACI_VO.
125   *
126   * @return
127   *    - ESP_OK
128   *    - ESP_FAIL
129   */
130 esp_err_t esp_wifi_clr_tx_tb_statistics(esp_wifi_aci_t aci);
131 
132 /**
133   * @brief     Get the TB PPDU transmission statistics.
134   *
135   * @param[in]    aci access category id.
136   * @param[in]    tb_stats TB PPDU statistics.
137   *
138   * @return
139   *    - ESP_OK
140   *    - ESP_FAIL
141   */
142 esp_err_t esp_wifi_get_tx_tb_statistics(esp_wifi_aci_t aci, esp_test_tx_tb_statistics_t *tb_stats);
143 
144 /**
145 * @brief Add BSS color change announcement IE
146 *
147 * @attention This API should be called after esp_wifi_start().
148 *
149 * @param color new bss color, 0 means disable.
150 *
151 * @return
152 *  - ESP_OK: succeed
153 *  - others: failed
154 */
155 esp_err_t esp_wifi_softap_add_color_change_announcement(uint8_t color);
156 
157 /**
158 * @brief Add bss max idle ie
159 *
160 * @attention This API should be called after esp_wifi_start().
161 *
162 * @param[in] bss_max_idle_enable enbale bss max idle
163 * @param[in] bss_max_idle_period_secs bss max idle period, unit seconds
164 * @param[in] protected_keep_alive using protected/unprotected frame to keep alive
165 *
166 * @return
167 *  - ESP_OK: succeed
168 *  - others: failed
169 */
170 esp_err_t esp_wifi_softap_set_bss_max_idle(bool bss_max_idle_enable, uint16_t bss_max_idle_period_secs, bool protected_keep_alive);
171 
172 /**
173 * @brief Reset MU EDCA Timer
174 *
175 * @attention This API should be called after esp_wifi_start().
176 *
177 * @param aci_bitmap bit0: BK
178 *                   bit1: BE
179 *                   bit2: VI
180 *                   bit3: VO
181 *
182 * @return
183 *  - ESP_OK: succeed
184 *  - others: failed
185 */
186 esp_err_t esp_wifi_sta_reset_muedca_timer(uint8_t aci_bitmap);
187 
188 /**
189   * @brief     Set bss color collision detection duration and frame threshold.
190   *
191   * @param[in] threshold the number of HE frames with the same BSS color as STA but in different BSSs.
192   * @param[in] duration duration of the detection. If the number of frames that STA detects reaches threshold,
193   *            STA will report BSS Color Collision to the associated AP. Unit seconds.
194   *
195   * @return
196   *    - ESP_OK: succeed
197   *    - ESP_ERR_INVALID_ARG: invalid argument
198   */
199 esp_err_t esp_wifi_sta_set_bss_color_collision_detection(int threshold, int duration);
200 
201 #ifdef __cplusplus
202 }
203 #endif
204