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,
76 struct list_head list;
78 struct sk_buff *cmd_skb;
79 struct sk_buff *resp_skb;
90 * struct esp_sdio_context */
93 struct esp_if_ops *if_ops;
95 /* Private for each interface */
96 struct esp_wifi_device *priv[ESP_MAX_INTERFACE];
97 struct hci_dev *hcidev;
99 struct workqueue_struct *if_rx_workqueue;
100 struct work_struct if_rx_work;
102 wait_queue_head_t wait_for_cmd_resp;
105 /* wpa supplicant commands structures */
106 struct command_node *cmd_pool;
107 struct list_head cmd_free_queue;
108 spinlock_t cmd_free_queue_lock;
109 struct list_head cmd_pending_queue;
110 spinlock_t cmd_pending_queue_lock;
112 struct command_node *cur_cmd;
115 struct workqueue_struct *cmd_wq;
116 struct work_struct cmd_work;
118 struct sk_buff_head events_skb_q;
119 struct workqueue_struct *events_wq;
120 struct work_struct events_work;
122 unsigned long state_flags;
128 struct esp_adapter *adapter;
131 struct esp_wifi_device {
132 struct wireless_dev wdev;
133 struct net_device *ndev;
134 struct esp_device *esp_dev;
135 struct esp_adapter *adapter;
137 struct net_device_stats stats;
139 u8 mac_address[MAC_ADDR_LEN];
146 volatile u8 stop_data;
147 volatile u8 port_open;
149 /* This is needed to notify scan completion*/
150 struct cfg80211_scan_request *request;
152 uint8_t scan_in_progress;
153 uint8_t waiting_for_scan_done;
154 wait_queue_head_t wait_for_scan_completion;
155 unsigned long priv_flags;
161 struct esp_adapter *adapter;
162 struct net_device *ndev;
163 struct net_device_stats stats;
172 /* struct esp_private *priv;*/
173 struct esp_wifi_device *priv;