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