2 * Espressif Systems Wireless LAN device driver
4 * Copyright (C) 2015-2021 Espressif Systems (Shanghai) PTE LTD
6 * This software file (the "File") is distributed by Espressif Systems (Shanghai)
7 * PTE LTD under the terms of the GNU General Public License Version 2, June 1991
8 * (the "License"). You may use, redistribute and/or modify this File in
9 * accordance with the terms and conditions of the License, a copy of which
10 * is available by writing to the Free Software Foundation, Inc.,
11 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
12 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
14 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
16 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
17 * this warranty disclaimer.
23 #include <linux/workqueue.h>
24 #include <linux/wait.h>
25 #include <linux/interrupt.h>
26 #include <linux/netdevice.h>
27 #include <linux/etherdevice.h>
28 #include <linux/spinlock.h>
29 #include <net/cfg80211.h>
30 #include <net/bluetooth/bluetooth.h>
31 #include <net/bluetooth/hci_core.h>
34 #define ESP_IF_TYPE_SDIO 1
35 #define ESP_IF_TYPE_SPI 2
37 /* Network link status */
38 #define ESP_LINK_DOWN 0
41 #define ESP_MAX_INTERFACE 1
42 //#define ESP_MAX_INTERFACE 2
43 #define ESP_STA_NW_IF 0
44 #define ESP_AP_NW_IF 1
46 /* ESP in sdkconfig has CONFIG_IDF_FIRMWARE_CHIP_ID entry.
47 * supported values of CONFIG_IDF_FIRMWARE_CHIP_ID are - */
49 ESP_FIRMWARE_CHIP_UNRECOGNIZED = 0xff,
50 ESP_FIRMWARE_CHIP_ESP32 = 0x0,
51 ESP_FIRMWARE_CHIP_ESP32S2 = 0x2,
52 ESP_FIRMWARE_CHIP_ESP32C3 = 0x5,
53 ESP_FIRMWARE_CHIP_ESP32S3 = 0x9,
56 #define ESP_PAYLOAD_HEADER 8
60 #define ACQUIRE_LOCK 1
61 #define LOCK_ALREADY_ACQUIRED 0
63 #define SKB_DATA_ADDR_ALIGNMENT 4
64 #define INTERFACE_HEADER_PADDING (SKB_DATA_ADDR_ALIGNMENT*3)
66 enum adapter_flags_e {
67 ESP_CLEANUP_IN_PROGRESS, /* Driver unloading or ESP reseted */
68 ESP_CMD_INIT_DONE, /* Cmd component is initialized with esp_commands_setup() */
69 ESP_DRIVER_ACTIVE, /* kernel module __exit is not yet invoked */
77 struct list_head list;
79 struct sk_buff *cmd_skb;
80 struct sk_buff *resp_skb;
91 * struct esp_sdio_context */
94 struct esp_if_ops *if_ops;
96 /* Private for each interface */
97 struct esp_wifi_device *priv[ESP_MAX_INTERFACE];
98 struct hci_dev *hcidev;
100 struct workqueue_struct *if_rx_workqueue;
101 struct work_struct if_rx_work;
103 wait_queue_head_t wait_for_cmd_resp;
106 /* wpa supplicant commands structures */
107 struct command_node *cmd_pool;
108 struct list_head cmd_free_queue;
109 spinlock_t cmd_free_queue_lock;
110 struct list_head cmd_pending_queue;
111 spinlock_t cmd_pending_queue_lock;
113 struct command_node *cur_cmd;
116 struct workqueue_struct *cmd_wq;
117 struct work_struct cmd_work;
119 struct sk_buff_head events_skb_q;
120 struct workqueue_struct *events_wq;
121 struct work_struct events_work;
123 unsigned long state_flags;
129 struct esp_adapter *adapter;
132 struct esp_wifi_device {
133 struct wireless_dev wdev;
134 struct net_device *ndev;
135 struct esp_device *esp_dev;
136 struct esp_adapter *adapter;
138 struct net_device_stats stats;
140 u8 mac_address[MAC_ADDR_LEN];
147 volatile u8 stop_data;
148 volatile u8 port_open;
150 /* This is needed to notify scan completion*/
151 struct cfg80211_scan_request *request;
152 struct cfg80211_bss *bss;
153 uint8_t *assoc_req_ie;
154 size_t assoc_req_ie_len;
156 uint8_t scan_in_progress;
157 uint8_t waiting_for_scan_done;
158 wait_queue_head_t wait_for_scan_completion;
159 unsigned long priv_flags;
165 struct esp_adapter *adapter;
166 struct net_device *ndev;
167 struct net_device_stats stats;
176 /* struct esp_private *priv;*/
177 struct esp_wifi_device *priv;