]>
Commit | Line | Data |
---|---|---|
e8b168e8 | 1 | // SPDX-License-Identifier: GPL-2.0-only |
774e9b2e MM |
2 | /* |
3 | * Espressif Systems Wireless LAN device driver | |
4 | * | |
d7215282 | 5 | * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD |
774e9b2e | 6 | * |
774e9b2e | 7 | */ |
057d3956 | 8 | #include "utils.h" |
774e9b2e MM |
9 | #include <linux/init.h> |
10 | #include <linux/module.h> | |
11 | #include <linux/kernel.h> | |
12 | #include <linux/gpio.h> | |
7406fe82 | 13 | #include <linux/igmp.h> |
774e9b2e MM |
14 | |
15 | #include "esp.h" | |
16 | #include "esp_if.h" | |
17 | #include "esp_bt_api.h" | |
18 | #include "esp_api.h" | |
19 | #include "esp_cmd.h" | |
aad2ae2e | 20 | #include "esp_kernel_port.h" |
774e9b2e MM |
21 | |
22 | #include "esp_cfg80211.h" | |
bf3d6cb6 | 23 | #include "esp_stats.h" |
774e9b2e | 24 | |
7e6de249 | 25 | #define RELEASE_VERSION "1.0.3" |
774e9b2e | 26 | #define HOST_GPIO_PIN_INVALID -1 |
50785e92 | 27 | #define CONFIG_ALLOW_MULTICAST_WAKEUP 1 |
774e9b2e | 28 | static int resetpin = HOST_GPIO_PIN_INVALID; |
3af0ee08 JT |
29 | static int readypin = HOST_GPIO_PIN_INVALID; |
30 | static int handshakepin = HOST_GPIO_PIN_INVALID; | |
2b40207b | 31 | static u32 clockspeed = 0; |
774e9b2e | 32 | extern u8 ap_bssid[MAC_ADDR_LEN]; |
3fef9acf | 33 | extern volatile u8 host_sleep; |
38a59879 | 34 | u32 raw_tp_mode = 0; |
e2766bb0 | 35 | int log_level = ESP_INFO; |
774e9b2e MM |
36 | |
37 | module_param(resetpin, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); | |
38 | MODULE_PARM_DESC(resetpin, "Host's GPIO pin number which is connected to ESP32's EN to reset ESP32 device"); | |
39 | ||
2b40207b JT |
40 | module_param(clockspeed, uint, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
41 | MODULE_PARM_DESC(clockspeed, "Hosts clock speed in MHz"); | |
42 | ||
38a59879 SS |
43 | module_param(raw_tp_mode, uint, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
44 | MODULE_PARM_DESC(raw_tp_mode, "Mode choosed to test raw throughput"); | |
45 | ||
3af0ee08 JT |
46 | module_param(readypin, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
47 | MODULE_PARM_DESC(readypin, "Data ready pin default is pin 13, gpio27"); | |
48 | ||
49 | module_param(handshakepin, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); | |
50 | MODULE_PARM_DESC(handshakepin, "Handshake pin default is pin 15, gpio22"); | |
51 | ||
774e9b2e MM |
52 | static void deinit_adapter(void); |
53 | ||
54 | ||
7406fe82 | 55 | struct multicast_list mcast_list = {0}; |
774e9b2e MM |
56 | struct esp_adapter adapter; |
57 | /*struct esp_device esp_dev;*/ | |
58 | ||
a3829bf3 | 59 | struct esp_adapter *esp_get_adapter(void) |
774e9b2e MM |
60 | { |
61 | return &adapter; | |
62 | } | |
63 | ||
64 | void esp_process_new_packet_intr(struct esp_adapter *adapter) | |
65 | { | |
a3829bf3 | 66 | if (adapter) |
774e9b2e MM |
67 | queue_work(adapter->if_rx_workqueue, &adapter->if_rx_work); |
68 | } | |
69 | ||
a3829bf3 | 70 | static int process_tx_packet(struct sk_buff *skb) |
774e9b2e MM |
71 | { |
72 | struct esp_wifi_device *priv = NULL; | |
73 | struct esp_skb_cb *cb = NULL; | |
74 | struct esp_payload_header *payload_header = NULL; | |
75 | struct sk_buff *new_skb = NULL; | |
76 | int ret = 0; | |
77 | u8 pad_len = 0, realloc_skb = 0; | |
78 | u16 len = 0; | |
79 | u16 total_len = 0; | |
a3829bf3 | 80 | static u8 c; |
774e9b2e MM |
81 | u8 *pos = NULL; |
82 | ||
83 | c++; | |
84 | /* Get the priv */ | |
85 | cb = (struct esp_skb_cb *) skb->cb; | |
86 | priv = cb->priv; | |
87 | ||
88 | if (!priv) { | |
89 | dev_kfree_skb(skb); | |
6f8fee57 | 90 | esp_info("No priv\n"); |
774e9b2e MM |
91 | return NETDEV_TX_OK; |
92 | } | |
93 | ||
94 | if (netif_queue_stopped((const struct net_device *) priv->ndev)) { | |
6f8fee57 | 95 | esp_info("Netif queue stopped\n"); |
774e9b2e MM |
96 | return NETDEV_TX_BUSY; |
97 | } | |
98 | ||
3fef9acf MM |
99 | if (host_sleep) { |
100 | return NETDEV_TX_BUSY; | |
101 | } | |
102 | ||
774e9b2e MM |
103 | len = skb->len; |
104 | ||
105 | /* Create space for payload header */ | |
106 | pad_len = sizeof(struct esp_payload_header); | |
107 | ||
108 | total_len = len + pad_len; | |
109 | ||
110 | /* Align buffer length */ | |
111 | pad_len += SKB_DATA_ADDR_ALIGNMENT - (total_len % SKB_DATA_ADDR_ALIGNMENT); | |
112 | ||
113 | if (skb_headroom(skb) < pad_len) { | |
114 | /* Headroom is not sufficient */ | |
115 | realloc_skb = 1; | |
116 | } | |
117 | ||
118 | if (realloc_skb || !IS_ALIGNED((unsigned long) skb->data, SKB_DATA_ADDR_ALIGNMENT)) { | |
119 | /* Realloc SKB */ | |
120 | if (skb_linearize(skb)) { | |
121 | priv->stats.tx_errors++; | |
122 | dev_kfree_skb(skb); | |
6f8fee57 | 123 | esp_err("Failed to linearize SKB"); |
774e9b2e MM |
124 | return NETDEV_TX_OK; |
125 | } | |
126 | ||
127 | new_skb = esp_alloc_skb(skb->len + pad_len); | |
128 | ||
129 | if (!new_skb) { | |
6f8fee57 | 130 | esp_err("Failed to allocate SKB"); |
774e9b2e MM |
131 | priv->stats.tx_errors++; |
132 | dev_kfree_skb(skb); | |
133 | return NETDEV_TX_OK; | |
134 | } | |
135 | ||
136 | pos = new_skb->data; | |
137 | pos += pad_len; | |
138 | ||
139 | /* Populate new SKB */ | |
140 | skb_copy_from_linear_data(skb, pos, skb->len); | |
141 | skb_put(new_skb, skb->len + pad_len); | |
142 | ||
143 | /* Replace old SKB */ | |
144 | dev_kfree_skb_any(skb); | |
145 | skb = new_skb; | |
146 | } else { | |
147 | /* Realloc is not needed, Make space for interface header */ | |
148 | skb_push(skb, pad_len); | |
149 | } | |
150 | ||
151 | /* Set payload header */ | |
152 | payload_header = (struct esp_payload_header *) skb->data; | |
153 | memset(payload_header, 0, pad_len); | |
154 | ||
155 | payload_header->if_type = priv->if_type; | |
156 | payload_header->if_num = priv->if_num; | |
157 | payload_header->len = cpu_to_le16(len); | |
158 | payload_header->offset = cpu_to_le16(pad_len); | |
159 | payload_header->packet_type = PACKET_TYPE_DATA; | |
160 | ||
bf3d6cb6 SR |
161 | if (adapter.capabilities & ESP_CHECKSUM_ENABLED) |
162 | payload_header->checksum = cpu_to_le16(compute_checksum(skb->data, (len + pad_len))); | |
774e9b2e MM |
163 | |
164 | if (!priv->stop_data) { | |
165 | ret = esp_send_packet(priv->adapter, skb); | |
166 | ||
167 | if (ret) { | |
c19cde88 | 168 | esp_verbose("Failed to send SKB"); |
774e9b2e MM |
169 | priv->stats.tx_errors++; |
170 | } else { | |
171 | priv->stats.tx_packets++; | |
172 | priv->stats.tx_bytes += skb->len; | |
173 | } | |
174 | } else { | |
175 | dev_kfree_skb_any(skb); | |
176 | priv->stats.tx_dropped++; | |
177 | } | |
178 | ||
179 | return 0; | |
180 | } | |
181 | ||
a3829bf3 | 182 | void esp_port_open(struct esp_wifi_device *priv) |
774e9b2e MM |
183 | { |
184 | priv->port_open = 1; | |
185 | priv->stop_data = 0; | |
186 | } | |
187 | ||
a3829bf3 | 188 | void esp_port_close(struct esp_wifi_device *priv) |
774e9b2e MM |
189 | { |
190 | if (!priv) | |
191 | return; | |
192 | ||
193 | priv->port_open = 0; | |
194 | priv->stop_data = 1; | |
195 | } | |
196 | ||
197 | void print_capabilities(u32 cap) | |
198 | { | |
6f8fee57 | 199 | esp_info("Capabilities: 0x%x. Features supported are:\n", cap); |
774e9b2e | 200 | if (cap & ESP_WLAN_SDIO_SUPPORT) |
6f8fee57 | 201 | esp_info("\t * WLAN on SDIO\n"); |
774e9b2e | 202 | else if (cap & ESP_WLAN_SPI_SUPPORT) |
6f8fee57 | 203 | esp_info("\t * WLAN on SPI\n"); |
774e9b2e MM |
204 | |
205 | if ((cap & ESP_BT_UART_SUPPORT) || | |
bf3d6cb6 SR |
206 | (cap & ESP_BT_SDIO_SUPPORT) || |
207 | (cap & ESP_BT_SPI_SUPPORT)) { | |
6f8fee57 | 208 | esp_info("\t * BT/BLE\n"); |
774e9b2e | 209 | if (cap & ESP_BT_UART_SUPPORT) |
6f8fee57 | 210 | esp_info("\t - HCI over UART\n"); |
774e9b2e | 211 | if (cap & ESP_BT_SDIO_SUPPORT) |
6f8fee57 | 212 | esp_info("\t - HCI over SDIO\n"); |
774e9b2e | 213 | if (cap & ESP_BT_SPI_SUPPORT) |
6f8fee57 | 214 | esp_info("\t - HCI over SPI\n"); |
774e9b2e MM |
215 | |
216 | if ((cap & ESP_BLE_ONLY_SUPPORT) && (cap & ESP_BR_EDR_ONLY_SUPPORT)) | |
6f8fee57 | 217 | esp_info("\t - BT/BLE dual mode\n"); |
774e9b2e | 218 | else if (cap & ESP_BLE_ONLY_SUPPORT) |
6f8fee57 | 219 | esp_info("\t - BLE only\n"); |
774e9b2e | 220 | else if (cap & ESP_BR_EDR_ONLY_SUPPORT) |
6f8fee57 | 221 | esp_info("\t - BR EDR only\n"); |
774e9b2e MM |
222 | } |
223 | } | |
224 | ||
58c0e50b | 225 | void init_bt(struct esp_adapter *adapter) |
774e9b2e | 226 | { |
774e9b2e MM |
227 | |
228 | if ((adapter->capabilities & ESP_BT_SPI_SUPPORT) || | |
229 | (adapter->capabilities & ESP_BT_SDIO_SUPPORT)) { | |
230 | msleep(200); | |
6f8fee57 | 231 | esp_info("ESP Bluetooth init\n"); |
774e9b2e MM |
232 | esp_init_bt(adapter); |
233 | } | |
234 | } | |
235 | ||
236 | static int check_esp_version(struct fw_version *ver) | |
237 | { | |
58c0e50b | 238 | esp_info("ESP Firmware version: %u.%u.%u\n", |
774e9b2e MM |
239 | ver->major1, ver->major2, ver->minor); |
240 | if (!ver->major1) { | |
6f8fee57 | 241 | esp_err("Incompatible ESP firmware release detected, Please use correct ESP-Hosted branch/compatible release\n"); |
774e9b2e MM |
242 | return -1; |
243 | } | |
244 | return 0; | |
245 | } | |
246 | ||
247 | static void print_reset_reason(uint32_t reason) | |
248 | { | |
249 | switch (reason) | |
250 | { | |
a3829bf3 KG |
251 | case 1: esp_info("POWERON_RESET\n"); break; /**<1, Vbat power on reset*/ |
252 | case 3: esp_info("SW_RESET\n"); break; /**<3, Software reset digital core*/ | |
253 | case 4: esp_info("OWDT_RESET\n"); break; /**<4, Legacy watch dog reset digital core*/ | |
254 | case 5: esp_info("DEEPSLEEP_RESET\n"); break; /**<5, Deep Sleep reset digital core*/ | |
255 | case 6: esp_info("SDIO_RESET\n"); break; /**<6, Reset by SLC module, reset digital core*/ | |
256 | case 7: esp_info("TG0WDT_SYS_RESET\n"); break; /**<7, Timer Group0 Watch dog reset digital core*/ | |
257 | case 8: esp_info("TG1WDT_SYS_RESET\n"); break; /**<8, Timer Group1 Watch dog reset digital core*/ | |
258 | case 9: esp_info("RTCWDT_SYS_RESET\n"); break; /**<9, RTC Watch dog Reset digital core*/ | |
259 | case 10: esp_info("INTRUSION_RESET\n"); break; /**<10, Instrusion tested to reset CPU*/ | |
260 | case 11: esp_info("TGWDT_CPU_RESET\n"); break; /**<11, Time Group reset CPU*/ | |
261 | case 12: esp_info("SW_CPU_RESET\n"); break; /**<12, Software reset CPU*/ | |
262 | case 13: esp_info("RTCWDT_CPU_RESET\n"); break; /**<13, RTC Watch dog Reset CPU*/ | |
263 | case 14: esp_info("EXT_CPU_RESET\n"); break; /**<14, for APP CPU, reseted by PRO CPU*/ | |
264 | case 15: esp_info("RTCWDT_BROWN_OUT_RESET\n"); break;/**<15, Reset when the vdd voltage is not stable*/ | |
265 | case 16: esp_info("RTCWDT_RTC_RESET\n"); break; /**<16, RTC Watch dog reset digital core and rtc module*/ | |
266 | default: esp_info("Unknown[%u]\n", reason); break; | |
774e9b2e MM |
267 | } |
268 | } | |
269 | ||
58c0e50b | 270 | static int process_fw_data(struct fw_data *fw_p, int tag_len) |
774e9b2e | 271 | { |
58c0e50b KG |
272 | if (tag_len != sizeof(struct fw_data)) { |
273 | esp_err("Length not matching to firmware data size\n"); | |
774e9b2e MM |
274 | return -1; |
275 | } | |
276 | ||
e58fd496 | 277 | esp_info("ESP chipset's last reset cause:\n"); |
774e9b2e | 278 | print_reset_reason(le32_to_cpu(fw_p->last_reset_reason)); |
58c0e50b | 279 | |
774e9b2e MM |
280 | return check_esp_version(&fw_p->version); |
281 | } | |
282 | ||
58c0e50b KG |
283 | int process_event_esp_bootup(struct esp_adapter *adapter, u8 *evt_buf, u8 len) |
284 | { | |
285 | int len_left = len, tag_len, ret = 0; | |
286 | u8 *pos; | |
287 | ||
288 | if (!adapter || !evt_buf) | |
289 | return -1; | |
290 | ||
291 | if (len_left >= 64) { | |
292 | esp_info("ESP init event len looks unexpected: %u (>=64)\n", len_left); | |
293 | esp_info("You probably facing timing mismatch at transport layer\n"); | |
294 | } | |
295 | ||
296 | clear_bit(ESP_INIT_DONE, &adapter->state_flags); | |
297 | /* Deinit module if already initialized */ | |
48e29210 | 298 | test_raw_tp_cleanup(); |
58c0e50b KG |
299 | esp_deinit_module(adapter); |
300 | ||
301 | pos = evt_buf; | |
302 | ||
303 | while (len_left > 0) { | |
304 | tag_len = *(pos + 1); | |
305 | ||
306 | esp_info("Bootup Event tag: %d\n", *pos); | |
307 | ||
308 | switch (*pos) { | |
309 | case ESP_BOOTUP_CAPABILITY: | |
310 | adapter->capabilities = *(pos + 2); | |
311 | break; | |
312 | case ESP_BOOTUP_FIRMWARE_CHIP_ID: | |
313 | ret = esp_validate_chipset(adapter, *(pos + 2)); | |
314 | break; | |
315 | case ESP_BOOTUP_FW_DATA: | |
316 | ret = process_fw_data((struct fw_data *)(pos + 2), tag_len); | |
317 | break; | |
318 | case ESP_BOOTUP_SPI_CLK_MHZ: | |
319 | ret = esp_adjust_spi_clock(adapter, *(pos + 2)); | |
320 | break; | |
321 | default: | |
322 | esp_warn("Unsupported tag=%x in bootup event\n", *pos); | |
323 | } | |
324 | ||
325 | if (ret < 0) { | |
326 | esp_err("failed to process tag=%x in bootup event\n", *pos); | |
327 | return -1; | |
328 | } | |
329 | pos += (tag_len + 2); | |
330 | len_left -= (tag_len + 2); | |
331 | } | |
332 | ||
333 | if (esp_add_card(adapter)) { | |
334 | esp_err("network iterface init failed\n"); | |
335 | return -1; | |
336 | } | |
337 | init_bt(adapter); | |
38a59879 SS |
338 | |
339 | if (raw_tp_mode !=0) { | |
340 | #if TEST_RAW_TP | |
341 | process_test_capabilities(raw_tp_mode); | |
342 | esp_init_raw_tp(adapter); | |
4ced2c85 | 343 | #else |
38a59879 SS |
344 | esp_err("RAW TP mode selected but not enabled\n"); |
345 | return -1; | |
346 | #endif | |
347 | } | |
58c0e50b KG |
348 | set_bit(ESP_INIT_DONE, &adapter->state_flags); |
349 | print_capabilities(adapter->capabilities); | |
350 | ||
351 | return 0; | |
352 | } | |
353 | ||
774e9b2e MM |
354 | static int esp_open(struct net_device *ndev) |
355 | { | |
774e9b2e MM |
356 | return 0; |
357 | } | |
358 | ||
359 | static int esp_stop(struct net_device *ndev) | |
360 | { | |
2127f3fa | 361 | return 0; |
774e9b2e MM |
362 | } |
363 | ||
a3829bf3 | 364 | static struct net_device_stats *esp_get_stats(struct net_device *ndev) |
774e9b2e MM |
365 | { |
366 | struct esp_wifi_device *priv = netdev_priv(ndev); | |
367 | ||
368 | if (!priv) | |
369 | return NULL; | |
370 | ||
371 | return &priv->stats; | |
372 | } | |
373 | ||
374 | static int esp_set_mac_address(struct net_device *ndev, void *data) | |
375 | { | |
376 | struct esp_wifi_device *priv = netdev_priv(ndev); | |
98f8ece9 KG |
377 | struct sockaddr *sa = (struct sockaddr *)data; |
378 | int ret; | |
774e9b2e MM |
379 | |
380 | if (!priv || !priv->adapter) | |
381 | return -EINVAL; | |
382 | ||
98f8ece9 | 383 | esp_info("%u "MACSTR"\n", __LINE__, MAC2STR(sa->sa_data)); |
774e9b2e | 384 | |
98f8ece9 KG |
385 | ret = cmd_set_mac(priv, sa->sa_data); |
386 | ||
387 | if (ret == 0) | |
388 | eth_hw_addr_set(ndev, priv->mac_address/*mac_addr->sa_data*/); | |
389 | ||
390 | return ret; | |
774e9b2e MM |
391 | } |
392 | ||
774e9b2e MM |
393 | static void esp_set_rx_mode(struct net_device *ndev) |
394 | { | |
c19cde88 | 395 | struct esp_adapter *adapter = esp_get_adapter(); |
7406fe82 | 396 | |
c19cde88 | 397 | schedule_work(&adapter->mac_flter_work); |
774e9b2e MM |
398 | } |
399 | ||
400 | static int esp_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev) | |
401 | { | |
402 | struct esp_wifi_device *priv = NULL; | |
403 | struct esp_skb_cb *cb = NULL; | |
404 | ||
405 | if (!skb || !ndev) | |
406 | return NETDEV_TX_OK; | |
407 | ||
408 | priv = netdev_priv(ndev); | |
409 | if (!priv) { | |
410 | dev_kfree_skb(skb); | |
411 | return NETDEV_TX_OK; | |
412 | } | |
413 | ||
414 | if (!priv->port_open) { | |
415 | priv->stats.tx_dropped++; | |
c19cde88 | 416 | esp_verbose("Port not yet open\n"); |
774e9b2e MM |
417 | dev_kfree_skb(skb); |
418 | return NETDEV_TX_OK; | |
419 | } | |
420 | ||
421 | if (!skb->len || (skb->len > ETH_FRAME_LEN)) { | |
6f8fee57 | 422 | esp_err("Bad len %d\n", skb->len); |
774e9b2e MM |
423 | priv->stats.tx_dropped++; |
424 | dev_kfree_skb(skb); | |
425 | return NETDEV_TX_OK; | |
426 | } | |
427 | ||
428 | cb = (struct esp_skb_cb *) skb->cb; | |
429 | cb->priv = priv; | |
430 | ||
431 | return process_tx_packet(skb); | |
432 | } | |
433 | ||
434 | static const struct net_device_ops esp_netdev_ops = { | |
435 | .ndo_open = esp_open, | |
436 | .ndo_stop = esp_stop, | |
437 | .ndo_start_xmit = esp_hard_start_xmit, | |
98f8ece9 | 438 | .ndo_set_mac_address = esp_set_mac_address, |
774e9b2e | 439 | .ndo_validate_addr = eth_validate_addr, |
774e9b2e MM |
440 | .ndo_get_stats = esp_get_stats, |
441 | .ndo_set_rx_mode = esp_set_rx_mode, | |
442 | }; | |
443 | ||
444 | ||
445 | void esp_init_priv(struct net_device *ndev) | |
446 | { | |
447 | ndev->netdev_ops = &esp_netdev_ops; | |
448 | ndev->needed_headroom = roundup(sizeof(struct esp_payload_header) + | |
449 | INTERFACE_HEADER_PADDING, 4); | |
450 | } | |
451 | ||
58c0e50b | 452 | static int esp_add_network_ifaces(struct esp_adapter *adapter) |
774e9b2e | 453 | { |
a3829bf3 | 454 | struct wireless_dev *wdev = NULL; |
774e9b2e MM |
455 | |
456 | if (!adapter) { | |
6f8fee57 | 457 | esp_info("adapter not yet init\n"); |
774e9b2e MM |
458 | return -EINVAL; |
459 | } | |
460 | ||
774e9b2e | 461 | rtnl_lock(); |
76085845 | 462 | wdev = esp_cfg80211_add_iface(adapter->wiphy, "wlan%d", 1, NL80211_IFTYPE_STATION, NULL); |
774e9b2e MM |
463 | rtnl_unlock(); |
464 | ||
225e14eb YM |
465 | /* Return success if network added successfully */ |
466 | if (wdev) | |
467 | return 0; | |
468 | ||
469 | return -1; | |
774e9b2e MM |
470 | } |
471 | ||
38a59879 SS |
472 | int esp_init_raw_tp(struct esp_adapter *adapter) |
473 | { | |
474 | RET_ON_FAIL(cmd_init_raw_tp_task_timer(adapter->priv[ESP_STA_NW_IF])); | |
475 | return 0; | |
476 | } | |
477 | ||
774e9b2e MM |
478 | int esp_add_card(struct esp_adapter *adapter) |
479 | { | |
225e14eb | 480 | RET_ON_FAIL(esp_commands_setup(adapter)); |
58c0e50b KG |
481 | RET_ON_FAIL(esp_add_wiphy(adapter)); |
482 | RET_ON_FAIL(esp_add_network_ifaces(adapter)); | |
76085845 | 483 | clear_bit(ESP_CLEANUP_IN_PROGRESS, &adapter->state_flags); |
774e9b2e | 484 | |
225e14eb | 485 | return 0; |
774e9b2e MM |
486 | } |
487 | ||
58c0e50b | 488 | static int esp_remove_network_ifaces(struct esp_adapter *adapter) |
774e9b2e MM |
489 | { |
490 | uint8_t iface_idx = 0; | |
491 | struct net_device *ndev = NULL; | |
492 | struct esp_wifi_device *priv = NULL; | |
493 | ||
a3829bf3 | 494 | for (iface_idx = 0; iface_idx < ESP_MAX_INTERFACE; iface_idx++) { |
774e9b2e MM |
495 | |
496 | priv = adapter->priv[iface_idx]; | |
774e9b2e MM |
497 | if (!priv) |
498 | continue; | |
774e9b2e MM |
499 | if (!test_bit(ESP_NETWORK_UP, &priv->priv_flags)) |
500 | continue; | |
501 | ||
774e9b2e | 502 | ndev = priv->ndev; |
2127f3fa | 503 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) |
58c0e50b KG |
504 | if (ndev) |
505 | ndev->needs_free_netdev = true; | |
2127f3fa | 506 | rtnl_lock(); |
58c0e50b KG |
507 | wiphy_lock(adapter->wiphy); |
508 | cfg80211_unregister_wdev(&priv->wdev); | |
509 | wiphy_unlock(adapter->wiphy); | |
2127f3fa KG |
510 | rtnl_unlock(); |
511 | #else | |
512 | if (ndev && ndev->reg_state == NETREG_REGISTERED) { | |
513 | unregister_netdev(ndev); | |
514 | free_netdev(ndev); | |
515 | ndev = NULL; | |
516 | } | |
517 | #endif | |
58c0e50b KG |
518 | adapter->priv[iface_idx] = NULL; |
519 | } | |
774e9b2e | 520 | |
58c0e50b KG |
521 | return 0; |
522 | } | |
774e9b2e | 523 | |
58c0e50b KG |
524 | static int stop_network_iface(struct esp_wifi_device *priv) |
525 | { | |
526 | struct net_device *ndev; | |
774e9b2e | 527 | |
58c0e50b KG |
528 | if (!priv) |
529 | return 0; | |
774e9b2e | 530 | |
58c0e50b KG |
531 | if (!test_bit(ESP_NETWORK_UP, &priv->priv_flags)) |
532 | return 0; | |
533 | ||
2127f3fa | 534 | esp_mark_scan_done_and_disconnect(priv, false); |
58c0e50b | 535 | esp_port_close(priv); |
774e9b2e | 536 | |
58c0e50b KG |
537 | /* stop and unregister network */ |
538 | ndev = priv->ndev; | |
774e9b2e | 539 | |
58c0e50b KG |
540 | if (ndev) { |
541 | netif_carrier_off(ndev); | |
542 | netif_device_detach(ndev); | |
543 | ||
544 | unregister_inetaddr_notifier(&(priv->nb)); | |
774e9b2e | 545 | } |
58c0e50b KG |
546 | |
547 | return 0; | |
774e9b2e MM |
548 | } |
549 | ||
58c0e50b | 550 | int esp_stop_network_ifaces(struct esp_adapter *adapter) |
774e9b2e MM |
551 | { |
552 | uint8_t iface_idx = 0; | |
553 | ||
58c0e50b KG |
554 | for (iface_idx = 0; iface_idx < ESP_MAX_INTERFACE; iface_idx++) { |
555 | stop_network_iface(adapter->priv[iface_idx]); | |
556 | } | |
557 | ||
2127f3fa KG |
558 | rtnl_lock(); |
559 | if (adapter->wiphy) | |
560 | cfg80211_shutdown_all_interfaces(adapter->wiphy); | |
561 | ||
562 | rtnl_unlock(); | |
563 | ||
58c0e50b KG |
564 | return 0; |
565 | } | |
566 | ||
567 | int esp_remove_card(struct esp_adapter *adapter) | |
568 | { | |
774e9b2e MM |
569 | if (!adapter) { |
570 | return 0; | |
571 | } | |
572 | ||
58c0e50b | 573 | esp_stop_network_ifaces(adapter); |
76085845 | 574 | esp_cfg_cleanup(adapter); |
58c0e50b | 575 | /* BT may have been initialized after fw bootup event, deinit it */ |
225e14eb | 576 | esp_deinit_bt(adapter); |
225e14eb | 577 | esp_commands_teardown(adapter); |
58c0e50b KG |
578 | esp_remove_network_ifaces(adapter); |
579 | esp_remove_wiphy(adapter); | |
774e9b2e MM |
580 | |
581 | return 0; | |
582 | } | |
583 | ||
a3829bf3 | 584 | struct esp_wifi_device *get_priv_from_payload_header( |
774e9b2e MM |
585 | struct esp_payload_header *header) |
586 | { | |
587 | struct esp_wifi_device *priv = NULL; | |
588 | u8 i = 0; | |
589 | ||
590 | if (!header) | |
591 | return NULL; | |
592 | ||
593 | for (i = 0; i < ESP_MAX_INTERFACE; i++) { | |
594 | priv = adapter.priv[i]; | |
595 | ||
596 | if (!priv) | |
597 | continue; | |
598 | ||
599 | if (priv->if_type == header->if_type && | |
600 | priv->if_num == header->if_num) { | |
601 | return priv; | |
602 | } | |
603 | } | |
604 | return NULL; | |
605 | } | |
606 | ||
607 | static void process_esp_bootup_event(struct esp_adapter *adapter, | |
608 | struct esp_internal_bootup_event *evt) | |
609 | { | |
610 | if (!adapter || !evt) { | |
6f8fee57 | 611 | esp_err("Invalid arguments\n"); |
774e9b2e MM |
612 | return; |
613 | } | |
614 | ||
615 | if (evt->header.status) { | |
6f8fee57 | 616 | esp_err("Incorrect ESP bootup event\n"); |
774e9b2e MM |
617 | return; |
618 | } | |
619 | ||
58c0e50b | 620 | esp_info("Received ESP bootup event\n"); |
774e9b2e MM |
621 | process_event_esp_bootup(adapter, evt->data, evt->len); |
622 | } | |
623 | ||
624 | static int process_internal_event(struct esp_adapter *adapter, | |
625 | struct sk_buff *skb) | |
626 | { | |
627 | struct event_header *header = NULL; | |
628 | ||
629 | if (!skb || !adapter) { | |
58c0e50b | 630 | esp_err("Incorrect event data!\n"); |
774e9b2e MM |
631 | return -1; |
632 | } | |
633 | ||
634 | header = (struct event_header *) (skb->data); | |
635 | ||
636 | switch (header->event_code) { | |
637 | ||
638 | case ESP_INTERNAL_BOOTUP_EVENT: | |
639 | process_esp_bootup_event(adapter, | |
640 | (struct esp_internal_bootup_event *)(skb->data)); | |
641 | break; | |
642 | ||
643 | default: | |
6f8fee57 KG |
644 | esp_info("%u unhandled internal event[%u]\n", |
645 | __LINE__, header->event_code); | |
774e9b2e MM |
646 | break; |
647 | } | |
648 | ||
649 | return 0; | |
650 | } | |
651 | ||
652 | static void process_rx_packet(struct esp_adapter *adapter, struct sk_buff *skb) | |
653 | { | |
654 | struct esp_wifi_device *priv = NULL; | |
655 | struct esp_payload_header *payload_header = NULL; | |
656 | u16 len = 0, offset = 0; | |
bf3d6cb6 | 657 | u16 rx_checksum = 0, checksum = 0; |
774e9b2e MM |
658 | struct hci_dev *hdev = adapter->hcidev; |
659 | u8 *type = NULL; | |
774e9b2e MM |
660 | |
661 | if (!skb) | |
662 | return; | |
663 | ||
664 | /* get the paload header */ | |
665 | payload_header = (struct esp_payload_header *) skb->data; | |
666 | ||
667 | len = le16_to_cpu(payload_header->len); | |
668 | offset = le16_to_cpu(payload_header->offset); | |
669 | ||
3fef9acf | 670 | if (payload_header->reserved2 == 0xFF) { |
c19cde88 | 671 | esp_hex_dump("Wake up packet: ", skb->data, len+offset); |
3fef9acf | 672 | } |
774e9b2e | 673 | |
bf3d6cb6 SR |
674 | if (adapter->capabilities & ESP_CHECKSUM_ENABLED) { |
675 | rx_checksum = le16_to_cpu(payload_header->checksum); | |
676 | payload_header->checksum = 0; | |
677 | ||
678 | checksum = compute_checksum(skb->data, (len + offset)); | |
679 | ||
680 | if (checksum != rx_checksum) { | |
681 | dev_kfree_skb_any(skb); | |
682 | return; | |
683 | } | |
684 | } | |
685 | ||
774e9b2e MM |
686 | /* chop off the header from skb */ |
687 | skb_pull(skb, offset); | |
688 | ||
689 | if (payload_header->if_type == ESP_STA_IF || payload_header->if_type == ESP_AP_IF) { | |
690 | ||
691 | /* retrieve priv based on payload header contents */ | |
692 | priv = get_priv_from_payload_header(payload_header); | |
693 | ||
694 | if (!priv) { | |
6f8fee57 | 695 | esp_err("Empty priv\n"); |
774e9b2e MM |
696 | dev_kfree_skb_any(skb); |
697 | return; | |
698 | } | |
699 | ||
700 | if (payload_header->packet_type == PACKET_TYPE_EAPOL) { | |
76085845 | 701 | esp_dbg("Rx PACKET_TYPE_EAPOL!!!!\n"); |
774e9b2e | 702 | esp_port_open(priv); |
76085845 KG |
703 | skb->dev = priv->ndev; |
704 | skb->protocol = eth_type_trans(skb, priv->ndev); | |
705 | netif_rx(skb); | |
774e9b2e MM |
706 | |
707 | } else if (payload_header->packet_type == PACKET_TYPE_DATA) { | |
708 | ||
709 | skb->dev = priv->ndev; | |
710 | skb->protocol = eth_type_trans(skb, priv->ndev); | |
711 | skb->ip_summed = CHECKSUM_NONE; | |
712 | ||
713 | priv->stats.rx_bytes += skb->len; | |
714 | /* Forward skb to kernel */ | |
1294f8ac | 715 | NETIF_RX_NI(skb); |
774e9b2e MM |
716 | priv->stats.rx_packets++; |
717 | } else if (payload_header->packet_type == PACKET_TYPE_COMMAND_RESPONSE) { | |
225e14eb | 718 | process_cmd_resp(priv->adapter, skb); |
774e9b2e | 719 | } else if (payload_header->packet_type == PACKET_TYPE_EVENT) { |
225e14eb | 720 | process_cmd_event(priv, skb); |
774e9b2e MM |
721 | dev_kfree_skb_any(skb); |
722 | } | |
723 | ||
724 | } else if (payload_header->if_type == ESP_HCI_IF) { | |
725 | if (hdev) { | |
726 | ||
727 | type = skb->data; | |
728 | hci_skb_pkt_type(skb) = *type; | |
729 | skb_pull(skb, 1); | |
730 | ||
731 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) | |
732 | if (hci_recv_frame(hdev, skb)) { | |
733 | #else | |
734 | if (hci_recv_frame(skb)) { | |
735 | #endif | |
736 | hdev->stat.err_rx++; | |
737 | } else { | |
738 | esp_hci_update_rx_counter(hdev, *type, skb->len); | |
739 | } | |
740 | } | |
741 | } else if (payload_header->if_type == ESP_INTERNAL_IF) { | |
742 | ||
743 | /* Queue event skb for processing in events workqueue */ | |
744 | skb_queue_tail(&adapter->events_skb_q, skb); | |
745 | ||
746 | if (adapter->events_wq) | |
747 | queue_work(adapter->events_wq, &adapter->events_work); | |
748 | else | |
749 | dev_kfree_skb_any(skb); | |
750 | ||
bf3d6cb6 | 751 | } else if (payload_header->if_type == ESP_TEST_IF) { |
38a59879 SS |
752 | #if TEST_RAW_TP |
753 | if (raw_tp_mode != 0) { | |
bf3d6cb6 | 754 | update_test_raw_tp_rx_stats(len); |
38a59879 SS |
755 | } |
756 | #endif | |
bf3d6cb6 | 757 | dev_kfree_skb_any(skb); |
774e9b2e MM |
758 | } else { |
759 | dev_kfree_skb_any(skb); | |
760 | } | |
761 | } | |
762 | ||
76085845 KG |
763 | char *esp_get_hardware_name(int hardware_id) |
764 | { | |
765 | if(hardware_id == ESP_FIRMWARE_CHIP_ESP32) | |
766 | return "ESP32"; | |
767 | else if(hardware_id == ESP_FIRMWARE_CHIP_ESP32S2) | |
768 | return "ESP32S2"; | |
769 | else if(hardware_id == ESP_FIRMWARE_CHIP_ESP32C3) | |
770 | return "ESP32C3"; | |
771 | else if(hardware_id == ESP_FIRMWARE_CHIP_ESP32S3) | |
772 | return "ESP32S3"; | |
773 | else if(hardware_id == ESP_FIRMWARE_CHIP_ESP32C2) | |
774 | return "ESP32C2"; | |
775 | else if(hardware_id == ESP_FIRMWARE_CHIP_ESP32C6) | |
776 | return "ESP32C6"; | |
777 | else | |
778 | return "N/A"; | |
779 | } | |
780 | ||
781 | bool esp_is_valid_hardware_id(int hardware_id) | |
782 | { | |
783 | switch(hardware_id) { | |
784 | case ESP_FIRMWARE_CHIP_ESP32: | |
785 | case ESP_FIRMWARE_CHIP_ESP32S2: | |
786 | case ESP_FIRMWARE_CHIP_ESP32C3: | |
787 | case ESP_FIRMWARE_CHIP_ESP32S3: | |
788 | case ESP_FIRMWARE_CHIP_ESP32C2: | |
789 | case ESP_FIRMWARE_CHIP_ESP32C6: | |
790 | return true; | |
791 | default: | |
792 | return false; | |
793 | } | |
794 | } | |
795 | ||
bf3d6cb6 SR |
796 | int esp_is_tx_queue_paused(struct esp_wifi_device *priv) |
797 | { | |
798 | if (!priv || !priv->ndev) | |
799 | return 0; | |
800 | ||
801 | if ((priv->ndev && | |
802 | !netif_queue_stopped((const struct net_device *)priv->ndev))) | |
803 | return 1; | |
804 | return 0; | |
805 | } | |
806 | ||
774e9b2e MM |
807 | void esp_tx_pause(struct esp_wifi_device *priv) |
808 | { | |
809 | if (!priv || !priv->ndev) | |
810 | return; | |
811 | ||
812 | if (!netif_queue_stopped((const struct net_device *)priv->ndev)) { | |
813 | netif_stop_queue(priv->ndev); | |
814 | } | |
815 | } | |
816 | ||
817 | void esp_tx_resume(struct esp_wifi_device *priv) | |
818 | { | |
819 | if (!priv || !priv->ndev) | |
820 | return; | |
821 | ||
822 | if (netif_queue_stopped((const struct net_device *)priv->ndev)) { | |
823 | netif_wake_queue(priv->ndev); | |
824 | } | |
825 | } | |
826 | ||
a3829bf3 | 827 | struct sk_buff *esp_alloc_skb(u32 len) |
774e9b2e MM |
828 | { |
829 | struct sk_buff *skb = NULL; | |
830 | ||
831 | u8 offset; | |
832 | ||
833 | skb = netdev_alloc_skb(NULL, len + INTERFACE_HEADER_PADDING); | |
834 | ||
835 | if (skb) { | |
836 | /* Align SKB data pointer */ | |
837 | offset = ((unsigned long)skb->data) & (SKB_DATA_ADDR_ALIGNMENT - 1); | |
838 | ||
839 | if (offset) | |
840 | skb_reserve(skb, INTERFACE_HEADER_PADDING - offset); | |
841 | } | |
842 | ||
843 | return skb; | |
844 | } | |
845 | ||
846 | ||
847 | static int esp_get_packets(struct esp_adapter *adapter) | |
848 | { | |
849 | struct sk_buff *skb = NULL; | |
850 | ||
851 | if (!adapter || !adapter->if_ops || !adapter->if_ops->read) | |
852 | return -EINVAL; | |
853 | ||
854 | skb = adapter->if_ops->read(adapter); | |
855 | ||
856 | if (!skb) | |
857 | return -EFAULT; | |
858 | ||
859 | process_rx_packet(adapter, skb); | |
860 | ||
861 | return 0; | |
862 | } | |
863 | ||
864 | int esp_send_packet(struct esp_adapter *adapter, struct sk_buff *skb) | |
865 | { | |
225e14eb | 866 | if (!adapter || !adapter->if_ops || !adapter->if_ops->write) { |
6f8fee57 | 867 | esp_err("%u adapter: %p\n", __LINE__, adapter); |
774e9b2e | 868 | return -EINVAL; |
225e14eb | 869 | } |
774e9b2e MM |
870 | |
871 | return adapter->if_ops->write(adapter, skb); | |
872 | } | |
873 | ||
874 | static void esp_if_rx_work(struct work_struct *work) | |
875 | { | |
876 | /* read inbound packet and forward it to network/serial interface */ | |
877 | esp_get_packets(&adapter); | |
878 | } | |
879 | ||
7406fe82 MM |
880 | static void update_mac_filter(struct work_struct *work) |
881 | { | |
c19cde88 KG |
882 | struct esp_adapter *adapter = esp_get_adapter(); |
883 | struct esp_wifi_device *priv = adapter->priv[0]; | |
884 | struct net_device *ndev; | |
885 | struct netdev_hw_addr *mac_addr; | |
886 | u32 count = 0; | |
887 | ||
888 | if (!priv) | |
889 | return; | |
890 | ||
891 | ndev = priv->ndev; | |
892 | if (!ndev) | |
893 | return; | |
894 | ||
895 | if (!priv->port_open) { | |
896 | esp_verbose("Port is not open yet, skipping mac filter update\n"); | |
897 | return; | |
898 | } | |
899 | ||
50785e92 | 900 | #if CONFIG_ALLOW_MULTICAST_WAKEUP |
c19cde88 KG |
901 | netdev_for_each_mc_addr(mac_addr, ndev) { |
902 | if (count < MAX_MULTICAST_ADDR_COUNT) { | |
903 | esp_verbose("%d: "MACSTR"\n", count+1, MAC2STR(mac_addr->addr)); | |
904 | memcpy(&mcast_list.mcast_addr[count++], mac_addr->addr, ETH_ALEN); | |
905 | } | |
906 | } | |
907 | ||
908 | mcast_list.priv = priv; | |
909 | mcast_list.addr_count = count; | |
910 | ||
911 | esp_verbose("Setting Multicast list\n"); | |
5a47b073 | 912 | cmd_set_mcast_mac_list(mcast_list.priv, &mcast_list); |
50785e92 YM |
913 | #else |
914 | esp_info("Not setting FW multicast addresses\n"); | |
915 | #endif | |
7406fe82 MM |
916 | } |
917 | ||
774e9b2e MM |
918 | static void esp_events_work(struct work_struct *work) |
919 | { | |
920 | struct sk_buff *skb = NULL; | |
921 | ||
922 | skb = skb_dequeue(&adapter.events_skb_q); | |
923 | if (!skb) | |
924 | return; | |
925 | ||
926 | process_internal_event(&adapter, skb); | |
927 | dev_kfree_skb_any(skb); | |
928 | } | |
929 | ||
a3829bf3 | 930 | static struct esp_adapter *init_adapter(void) |
774e9b2e MM |
931 | { |
932 | memset(&adapter, 0, sizeof(adapter)); | |
933 | ||
934 | /* Prepare interface RX work */ | |
935 | adapter.if_rx_workqueue = alloc_workqueue("ESP_IF_RX_WORK_QUEUE", 0, 0); | |
936 | ||
937 | if (!adapter.if_rx_workqueue) { | |
938 | deinit_adapter(); | |
939 | return NULL; | |
940 | } | |
941 | ||
942 | INIT_WORK(&adapter.if_rx_work, esp_if_rx_work); | |
943 | ||
944 | skb_queue_head_init(&adapter.events_skb_q); | |
945 | ||
946 | adapter.events_wq = alloc_workqueue("ESP_EVENTS_WORKQUEUE", WQ_HIGHPRI, 0); | |
947 | ||
948 | if (!adapter.events_wq) { | |
949 | deinit_adapter(); | |
950 | return NULL; | |
951 | } | |
952 | ||
953 | INIT_WORK(&adapter.events_work, esp_events_work); | |
954 | ||
7406fe82 MM |
955 | INIT_WORK(&adapter.mac_flter_work, update_mac_filter); |
956 | ||
774e9b2e MM |
957 | return &adapter; |
958 | } | |
959 | ||
960 | static void deinit_adapter(void) | |
961 | { | |
962 | skb_queue_purge(&adapter.events_skb_q); | |
963 | ||
964 | if (adapter.events_wq) | |
965 | destroy_workqueue(adapter.events_wq); | |
966 | ||
967 | if (adapter.if_rx_workqueue) | |
968 | destroy_workqueue(adapter.if_rx_workqueue); | |
969 | } | |
970 | ||
971 | static void esp_reset(void) | |
972 | { | |
973 | if (resetpin != HOST_GPIO_PIN_INVALID) { | |
974 | /* Check valid GPIO or not */ | |
975 | if (!gpio_is_valid(resetpin)) { | |
6f8fee57 | 976 | esp_warn("host resetpin (%d) configured is invalid GPIO\n", resetpin); |
774e9b2e MM |
977 | resetpin = HOST_GPIO_PIN_INVALID; |
978 | } else { | |
979 | gpio_request(resetpin, "sysfs"); | |
980 | ||
981 | /* HOST's resetpin set to OUTPUT, HIGH */ | |
982 | gpio_direction_output(resetpin, true); | |
983 | ||
984 | /* HOST's resetpin set to LOW */ | |
985 | gpio_set_value(resetpin, 0); | |
986 | udelay(200); | |
987 | ||
988 | /* HOST's resetpin set to INPUT */ | |
989 | gpio_direction_input(resetpin); | |
990 | ||
6f8fee57 | 991 | esp_dbg("Triggering ESP reset.\n"); |
774e9b2e MM |
992 | } |
993 | } | |
994 | } | |
995 | ||
f5051598 JT |
996 | void dt_get_reset_pin(void) |
997 | { | |
998 | struct device_node *resetpin_node = NULL; | |
999 | int temp_resetpin = HOST_GPIO_PIN_INVALID; | |
1000 | ||
1001 | ||
1002 | resetpin_node = of_find_compatible_node(NULL, NULL, "espressif,esp_sdio"); | |
1003 | if (!resetpin_node) | |
1004 | resetpin_node = of_find_compatible_node(NULL, NULL, "espressif,esp_spi"); | |
1005 | if (resetpin_node){ | |
1006 | of_property_read_u32(resetpin_node, "resetpin", &temp_resetpin); | |
1007 | if (temp_resetpin == HOST_GPIO_PIN_INVALID) | |
1008 | esp_warn("Unable to find resetpin in device tree.\n"); | |
1009 | else | |
1010 | resetpin = temp_resetpin; | |
1011 | } | |
1012 | } | |
1013 | ||
774e9b2e MM |
1014 | static int __init esp_init(void) |
1015 | { | |
1016 | int ret = 0; | |
1017 | struct esp_adapter *adapter = NULL; | |
3af0ee08 | 1018 | struct esp_if_params if_params; |
774e9b2e | 1019 | |
f5051598 JT |
1020 | dt_get_reset_pin(); |
1021 | ||
774e9b2e MM |
1022 | /* Reset ESP, Clean start ESP */ |
1023 | esp_reset(); | |
1024 | msleep(200); | |
1025 | ||
1026 | adapter = init_adapter(); | |
1027 | ||
1028 | if (!adapter) | |
1029 | return -EFAULT; | |
1030 | ||
3af0ee08 JT |
1031 | if_params.speed = clockspeed; |
1032 | if_params.handshake_pin = handshakepin; | |
1033 | if_params.data_ready_pin = readypin; | |
774e9b2e | 1034 | /* Init transport layer */ |
3af0ee08 | 1035 | ret = esp_init_interface_layer(adapter, &if_params); |
774e9b2e MM |
1036 | |
1037 | if (ret != 0) { | |
1038 | deinit_adapter(); | |
1039 | } | |
1040 | ||
e2766bb0 | 1041 | ret = debugfs_init(); |
774e9b2e MM |
1042 | return ret; |
1043 | } | |
1044 | ||
1045 | static void __exit esp_exit(void) | |
1046 | { | |
1047 | uint8_t iface_idx = 0; | |
bf3d6cb6 | 1048 | #if TEST_RAW_TP |
38a59879 SS |
1049 | if (raw_tp_mode != 0) { |
1050 | test_raw_tp_cleanup(); | |
1051 | } | |
bf3d6cb6 | 1052 | #endif |
a3829bf3 | 1053 | for (iface_idx = 0; iface_idx < ESP_MAX_INTERFACE; iface_idx++) { |
774e9b2e MM |
1054 | cmd_deinit_interface(adapter.priv[iface_idx]); |
1055 | } | |
225e14eb | 1056 | clear_bit(ESP_DRIVER_ACTIVE, &adapter.state_flags); |
774e9b2e MM |
1057 | |
1058 | esp_deinit_interface_layer(); | |
1059 | deinit_adapter(); | |
1060 | ||
1061 | if (resetpin != HOST_GPIO_PIN_INVALID) { | |
1062 | gpio_free(resetpin); | |
1063 | } | |
e2766bb0 | 1064 | debugfs_exit(); |
774e9b2e MM |
1065 | } |
1066 | MODULE_LICENSE("GPL"); | |
1067 | MODULE_AUTHOR("Amey Inamdar <[email protected]>"); | |
1068 | MODULE_AUTHOR("Mangesh Malusare <[email protected]>"); | |
1069 | MODULE_AUTHOR("Yogesh Mantri <[email protected]>"); | |
e2766bb0 | 1070 | MODULE_AUTHOR("Kapil Gupta <[email protected]>"); |
774e9b2e | 1071 | MODULE_DESCRIPTION("Wifi driver for ESP-Hosted solution"); |
7e6de249 | 1072 | MODULE_VERSION(RELEASE_VERSION); |
774e9b2e MM |
1073 | module_init(esp_init); |
1074 | module_exit(esp_exit); |