1# Copyright 2020 Espressif Systems (Shanghai) PTE LTD
2
3menuconfig WIFI_ESP32
4	bool "ESP32 SoC WiFi support"
5	default y
6	depends on DT_HAS_ESPRESSIF_ESP32_WIFI_ENABLED
7	depends on ZEPHYR_HAL_ESPRESSIF_MODULE_BLOBS || BUILD_ONLY_NO_BLOBS
8	depends on !SMP
9	select THREAD_CUSTOM_DATA
10	select NET_L2_WIFI_MGMT
11	select WIFI_USE_NATIVE_NETWORKING
12	select MBEDTLS
13	select THREAD_STACK_INFO
14	select DYNAMIC_THREAD
15	select DYNAMIC_THREAD_ALLOC
16	help
17	  Enable ESP32 SoC WiFi support. Only supported in single
18	  core mode because the network stack is not aware of SMP
19	  stuff.
20
21if WIFI_ESP32
22
23config HEAP_MEM_POOL_ADD_SIZE_ESP_WIFI
24	int
25	default 40960 if ESP_WIFI_HEAP_SYSTEM
26	default 0
27	help
28	  Make sure there is a minimal heap available for Wi-Fi driver.
29
30choice ESP_WIFI_HEAP
31	prompt "Wi-Fi adapter heap memory"
32	default ESP_WIFI_HEAP_SYSTEM
33
34	config ESP_WIFI_HEAP_SYSTEM
35		bool "Wi-Fi adapter use kernel mempool heap (k_malloc)"
36
37endchoice # ESP_WIFI_HEAP
38
39config NET_TCP_WORKQ_STACK_SIZE
40	default 2048
41
42config NET_RX_STACK_SIZE
43	default 2048
44
45config NET_MGMT_EVENT_STACK_SIZE
46	default 2048
47
48config ESP32_WIFI_STA_AUTO_DHCPV4
49	bool "Automatically starts DHCP4 negotiation"
50	depends on NET_DHCPV4
51	depends on NET_IPV4
52	help
53	  WiFi driver will automatically initiate DHCPV4 negotiation when connected.
54
55config ESP32_WIFI_AP_STA_MODE
56	bool "Activates the Station/AP co-existence mode."
57	depends on WIFI_NM
58	help
59	  The Station/AP coexistence mode allows the ESP32 to operate as both a station and
60	  an access point simultaneously. This mode is not enabled by default.
61
62config ESP32_WIFI_STA_RECONNECT
63	bool "WiFi connection retry"
64	help
65	  Set auto WiFI reconnection when disconnected.
66
67config ESP32_WIFI_STA_SCAN_ALL
68	bool "Scan all available APs when connecting in station mode"
69	help
70	  When connecting in station mode, scan all channels and connect to the channel with the
71	  highest RSSI. Without this, a fast scan is performed which connects to the first AP
72	  found.
73
74config ESP32_WIFI_NET_ALLOC_SPIRAM
75	bool "Allocate memory of WiFi and NET in SPIRAM"
76	depends on ESP_SPIRAM
77	help
78	  Allocate memory of WiFi and NET stack in SPIRAM, increasing available RAM memory space
79	  for application stack.
80
81config ESP32_WIFI_STATIC_RX_BUFFER_NUM
82	int "Max number of WiFi static RX buffers"
83	range 2 25
84	default 10
85	help
86	  Set the number of WiFi static RX buffers. Each buffer takes approximately 1.6KB of RAM.
87	  The static rx buffers are allocated when esp_wifi_init is called, they are not freed
88	  until esp_wifi_deinit is called.
89
90	  WiFi hardware use these buffers to receive all 802.11 frames.
91	  A higher number may allow higher throughput but increases memory use. If ESP32_WIFI_AMPDU_RX_ENABLED
92	  is enabled, this value is recommended to set equal or bigger than ESP32_WIFI_RX_BA_WIN in order to
93	  achieve better throughput and compatibility with both stations and APs.
94
95config ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM
96	int "Max number of WiFi dynamic RX buffers"
97	range 0 128
98	default 32
99	help
100	  Set the number of WiFi dynamic RX buffers, 0 means unlimited RX buffers
101	  will be allocated (provided sufficient free RAM). The size of each dynamic
102	  RX buffer depends on the size of the received data frame.
103
104	  For each received data frame, the WiFi driver makes a copy to an RX buffer
105	  and then delivers it to the high layer TCP/IP stack. The dynamic RX buffer
106	  is freed after the higher layer has successfully received the data frame.
107
108	  For some applications, WiFi data frames may be received faster than the
109	  application can process them. In these cases we may run out of memory if
110	  RX buffer number is unlimited (0). If a dynamic RX buffer limit is set,
111	  it should be at least the number of static RX buffers.
112
113choice ESP32_WIFI_TX_BUFFER
114	prompt "Type of WiFi TX buffers"
115	default ESP32_WIFI_DYNAMIC_TX_BUFFER
116	help
117	  Select type of WiFi TX buffers:
118
119	  If "Static" is selected, WiFi TX buffers are allocated when WiFi is
120	  initialized and released when WiFi is de-initialized. The size of each
121	  static TX buffer is fixed to about 1.6KB.
122
123	  If "Dynamic" is selected, each WiFi TX buffer is allocated as needed
124	  when a data frame is delivered to the Wifi driver from the TCP/IP stack.
125	  The buffer is freed after the data frame has been sent by the WiFi driver.
126	  The size of each dynamic TX buffer depends on the length of each data
127	  frame sent by the TCP/IP layer.
128
129	  If PSRAM is enabled, "Static" should be selected to guarantee enough
130	  WiFi TX buffers. If PSRAM is disabled, "Dynamic" should be selected
131	  to improve the utilization of RAM.
132
133	config ESP32_WIFI_STATIC_TX_BUFFER
134		bool "Static"
135	config ESP32_WIFI_DYNAMIC_TX_BUFFER
136		bool "Dynamic"
137endchoice
138
139config ESP32_WIFI_TX_BUFFER_TYPE
140	int
141	default 0 if ESP32_WIFI_STATIC_TX_BUFFER
142	default 1 if ESP32_WIFI_DYNAMIC_TX_BUFFER
143
144config ESP32_WIFI_STATIC_TX_BUFFER_NUM
145	int "Max number of WiFi static TX buffers"
146	depends on ESP32_WIFI_STATIC_TX_BUFFER
147	range 1 64
148	default 16
149	help
150	  Set the number of WiFi static TX buffers. Each buffer takes approximately
151	  1.6KB of RAM. The static RX buffers are allocated when esp_wifi_init() is
152	  called, they are not released until esp_wifi_deinit() is called.
153
154	  For each transmitted data frame from the higher layer TCP/IP stack,
155	  the WiFi driver makes a copy of it in a TX buffer.  For some applications
156	  especially UDP applications, the upper layer can deliver frames faster
157	  than WiFi layer can transmit.
158	  In these cases, we may run out of TX buffers.
159
160config ESP32_WIFI_CACHE_TX_BUFFER_NUM
161	int "Max number of WiFi cache TX buffers"
162	depends on ESP_SPIRAM
163	range 16 128
164	default 32
165	help
166	  Set the number of WiFi cache TX buffer number.
167
168	  For each TX packet from uplayer, such as LWIP etc, WiFi driver needs to
169	  allocate a static TX buffer and makes a copy of uplayer packet. If WiFi
170	  driver fails to allocate the static TX buffer, it caches the uplayer
171	  packets to a dedicated buffer queue, this option is used to configure the
172	  size of the cached TX queue.
173
174config ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM
175	int "Max number of WiFi dynamic TX buffers"
176	depends on ESP32_WIFI_DYNAMIC_TX_BUFFER
177	range 1 128
178	default 32
179	help
180	  Set the number of WiFi dynamic TX buffers. The size of each
181	  dynamic TXbuffer is not fixed, it depends on the size of each
182	  transmitted data frame.
183
184	  For each transmitted frame from the higher layer TCP/IP stack,
185	  the WiFi driver makes a copy of it in a TX buffer. For some applications,
186	  especially UDP applications, the upper layer can deliver frames faster
187	  than WiFi layer can transmit. In these cases, we may run out of TX
188	  buffers.
189
190choice ESP32_WIFI_MGMT_RX_BUFFER
191	prompt "Type of WiFi RX MGMT buffers"
192	default ESP32_WIFI_STATIC_RX_MGMT_BUFFER
193	help
194	  Select type of WiFi RX MGMT buffers:
195
196	  If "Static" is selected, WiFi RX MGMT buffers are allocated when WiFi is initialized and released
197	  when WiFi is de-initialized. The size of each static RX MGMT buffer is fixed to about 500 Bytes.
198
199	  If "Dynamic" is selected, each WiFi RX MGMT buffer is allocated as needed when a MGMT data frame is
200	  received. The MGMT buffer is freed after the MGMT data frame has been processed by the WiFi driver.
201
202	config ESP32_WIFI_STATIC_RX_MGMT_BUFFER
203		bool "Static"
204	config ESP32_WIFI_DYNAMIC_RX_MGMT_BUFFER
205		bool "Dynamic"
206endchoice
207
208config ESP32_WIFI_DYNAMIC_RX_MGMT_BUF
209	int
210	default 0 if ESP32_WIFI_STATIC_RX_MGMT_BUFFER
211	default 1 if ESP32_WIFI_DYNAMIC_RX_MGMT_BUFFER
212
213config ESP32_WIFI_RX_MGMT_BUF_NUM_DEF
214	int "Max number of WiFi RX MGMT buffers"
215	range 1 10
216	default 5
217	help
218	  Set the number of WiFi RX_MGMT buffers.
219
220	  For Management buffers, the number of dynamic and static management buffers is the same.
221	  In order to prevent memory fragmentation, the management buffer type should be set to static first.
222
223config ESP32_WIFI_CSI_ENABLED
224	bool "WiFi CSI(Channel State Information)"
225	help
226	  Select this option to enable CSI(Channel State Information) feature.
227	  CSI takes about CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM KB of RAM.
228	  If CSI is not used, it is better to disable this feature in order
229	  to save memory.
230
231config ESP32_WIFI_AMPDU_TX_ENABLED
232	bool "WiFi AMPDU TX"
233	default y
234	help
235	  Select this option to enable AMPDU TX feature. It improves transmission
236	  error checking and overall network performance with the cost of processing
237	  speed. Helpful when the device is operating in crowded wireless area.
238
239config ESP32_WIFI_TX_BA_WIN
240	int "WiFi AMPDU TX BA window size"
241	depends on ESP32_WIFI_AMPDU_TX_ENABLED
242	range 2 32
243	default 6
244	help
245	  Set the size of WiFi Block Ack TX window. Generally a bigger value means
246	  higher throughput but more memory. Most of time we should NOT change the
247	  default value unless special reason, e.g. test the maximum
248	  UDP TX throughput with iperf etc. For iperf test in shieldbox,
249	  the recommended value is 9~12.
250
251config ESP32_WIFI_AMPDU_RX_ENABLED
252	bool "WiFi AMPDU RX"
253	default y
254	help
255	  Select this option to enable AMPDU RX feature. It improves transmission
256	  error checking and overall network performance with the cost of processing
257	  speed. Helpful when the device is operating in crowded wireless area.
258
259config ESP32_WIFI_RX_BA_WIN
260	int "WiFi AMPDU RX BA window size"
261	depends on ESP32_WIFI_AMPDU_RX_ENABLED
262	range 2 32
263	default 6
264	help
265	  Set the size of WiFi Block Ack RX window. Generally a bigger value means
266	  higher throughput and better compatibility but more memory. Most of time
267	  we should NOT change the default value unless special reason,
268	  e.g. test the maximum UDP RX throughput with iperf etc. For iperf test in
269	  shieldbox, the recommended value is 9~12. If PSRAM is used and WiFi memory
270	  is preferred to be allocated in PSRAM first, the default and minimum value
271	  should be 16 to achieve better throughput and compatibility with both
272	  stations and APs.
273
274config ESP32_WIFI_AMSDU_TX_ENABLED
275	bool "WiFi AMSDU TX"
276	depends on ESP_SPIRAM
277	help
278	  Select this option to enable AMSDU TX feature
279
280config ESP32_WIFI_MGMT_SBUF_NUM
281	int "WiFi mgmt short buffer number"
282	range 6 32
283	default 32
284	help
285	  Set the number of WiFi management short buffer.
286
287config ESP32_WIFI_IRAM_OPT
288	bool "WiFi IRAM speed optimization"
289	help
290	  Select this option to place frequently called Wi-Fi library functions in IRAM.
291	  When this option is disabled, more than 10Kbytes of IRAM memory will be saved
292	  but Wi-Fi throughput will be reduced.
293
294config ESP32_WIFI_RX_IRAM_OPT
295	bool "WiFi RX IRAM speed optimization"
296	help
297	  Select this option to place frequently called Wi-Fi library RX functions in IRAM.
298	  When this option is disabled, more than 17Kbytes of IRAM memory will be saved
299	  but Wi-Fi performance will be reduced.
300
301config ESP32_WIFI_MAX_THREAD_PRIORITY
302	int "Maximum work queue thread priority"
303	default 7
304	help
305	  Maximum priority of thread used for processing driver work queue items.
306
307config ESP32_WIFI_SLP_DEFAULT_MIN_ACTIVE_TIME
308	int "Minimum active time"
309	range 8 60
310	default 50
311	help
312	  Only for station in WIFI_PS_MIN_MODEM or WIFI_PS_MAX_MODEM. When the station enters the active state,
313	  it will work for at least ESP_WIFI_SLP_DEFAULT_MIN_ACTIVE_TIME. If a data packet is received or sent
314	  during this period, the time will be refreshed. If the time is up, but the station still has packets
315	  to receive or send, the time will also be refreshed. unit: milliseconds.
316
317config ESP32_WIFI_SLP_DEFAULT_MAX_ACTIVE_TIME
318	int "Maximum keep alive time"
319	range 10 60
320	default 10
321	help
322	  Only for station in WIFI_PS_MIN_MODEM or WIFI_PS_MAX_MODEM. If no packet has been
323	  sent within ESP_WIFI_SLP_DEFAULT_MAX_ACTIVE_TIME, a null data packet will be sent
324	  to maintain the connection with the AP. unit: seconds.
325
326config ESP32_WIFI_SLP_DEFAULT_WAIT_BROADCAST_DATA_TIME
327	int "Minimum wait broadcast data time"
328	range 10 30
329	default 15
330	help
331	  Only for station in WIFI_PS_MIN_MODEM or WIFI_PS_MAX_MODEM. When the station knows through the beacon
332	  that AP will send broadcast packet, it will wait for ESP_WIFI_SLP_DEFAULT_WAIT_BROADCAST_DATA_TIME
333	  before entering the sleep process. If a broadcast packet is received with more data bits, the time
334	  will refreshed. unit: milliseconds.
335
336config ESP32_WIFI_FTM_ENABLE
337	bool "WiFi FTM"
338	depends on SOC_SERIES_ESP32C2 || SOC_SERIES_ESP32C3 || SOC_SERIES_ESP32C6 || SOC_SERIES_ESP32S2 || SOC_SERIES_ESP32S3
339	help
340	  Enable feature Fine Timing Measurement for calculating WiFi Round-Trip-Time (RTT).
341
342config ESP32_WIFI_FTM_INITIATOR_SUPPORT
343	bool "FTM Initiator support"
344	default y
345	depends on ESP32_WIFI_FTM_ENABLE
346
347config ESP32_WIFI_FTM_RESPONDER_SUPPORT
348	bool "FTM Responder support"
349	default y
350	depends on ESP32_WIFI_FTM_ENABLE
351
352config ESP32_WIFI_SOFTAP_SUPPORT
353	bool
354	default y
355	help
356	  Hidden option to enable Wi-Fi SoftAP functions in WPA supplicant and RF libraries.
357
358config ESP32_WIFI_MBEDTLS_CRYPTO
359	bool "Use MbedTLS crypto APIs"
360	select MBEDTLS_ECP_C
361	select MBEDTLS_ECDH_C
362	select MBEDTLS_ECDSA_C
363	select MBEDTLS_PKCS5_C
364	select MBEDTLS_PK_WRITE_C
365	select MBEDTLS_CIPHER_MODE_CTR_ENABLED
366	select MBEDTLS_CMAC
367	select MBEDTLS_ENTROPY_C
368	help
369	  Select this option to use MbedTLS crypto APIs which utilize hardware acceleration.
370
371config ESP32_WIFI_ENABLE_WPA3_SAE
372	bool "WPA3-Personal"
373	select ESP32_WIFI_MBEDTLS_CRYPTO
374	help
375	  Select this option to allow the device to establish a WPA3-Personal connection.
376
377config ESP32_WIFI_ENABLE_WPA3_OWE_STA
378	bool "OWE STA"
379	default y
380	depends on ESP32_WIFI_ENABLE_WPA3_SAE
381	help
382	  Select this option to allow the device to establish OWE connection with eligible AP's.
383
384config ESP32_WIFI_ENABLE_SAE_PK
385	bool "SAE-PK"
386	default y
387	depends on ESP32_WIFI_ENABLE_WPA3_SAE
388	help
389	  Select this option to enable SAE-PK
390
391config ESP32_WIFI_DEBUG_PRINT
392	bool "Print debug messages from WPA Supplicant"
393	help
394	  Select this option to print logging information from WPA supplicant,
395	  this includes handshake information and key hex dumps depending
396	  on the project logging level.
397
398	  Enabling this could increase the build size ~60kb
399	  depending on the project logging level.
400
401endif # WIFI_ESP32
402