]> Git Repo - esp-hosted.git/blob - esp_hosted_ng/host/include/esp.h
Implement WPA2 and WPA3 connection as per new wifi lib design
[esp-hosted.git] / esp_hosted_ng / host / include / esp.h
1 /*
2  * Espressif Systems Wireless LAN device driver
3  *
4  * Copyright (C) 2015-2021 Espressif Systems (Shanghai) PTE LTD
5  *
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.
13  *
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.
18  */
19
20 #ifndef __esp__h_
21 #define __esp__h_
22
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>
32 #include "adapter.h"
33
34 #define ESP_IF_TYPE_SDIO        1
35 #define ESP_IF_TYPE_SPI         2
36
37 /* Network link status */
38 #define ESP_LINK_DOWN           0
39 #define ESP_LINK_UP             1
40
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
45
46 /* ESP in sdkconfig has CONFIG_IDF_FIRMWARE_CHIP_ID entry.
47  * supported values of CONFIG_IDF_FIRMWARE_CHIP_ID are - */
48 enum chipset_type_e {
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,
54 };
55
56 #define ESP_PAYLOAD_HEADER      8
57 struct esp_private;
58 struct esp_adapter;
59
60 #define ACQUIRE_LOCK            1
61 #define LOCK_ALREADY_ACQUIRED   0
62
63 #define SKB_DATA_ADDR_ALIGNMENT 4
64 #define INTERFACE_HEADER_PADDING (SKB_DATA_ADDR_ALIGNMENT*3)
65
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 */
70 };
71
72 enum priv_flags_e {
73         ESP_NETWORK_UP,
74 };
75
76 struct command_node {
77         struct list_head list;
78         uint8_t cmd_code;
79         struct sk_buff *cmd_skb;
80         struct sk_buff *resp_skb;
81 };
82
83 struct esp_adapter {
84         struct device           *dev;
85         struct wiphy                    *wiphy;
86
87         u8                      if_type;
88         u32                     capabilities;
89
90         /* Possible types:
91          * struct esp_sdio_context */
92         void                    *if_context;
93
94         struct esp_if_ops       *if_ops;
95
96         /* Private for each interface */
97         struct esp_wifi_device  *priv[ESP_MAX_INTERFACE];
98         struct hci_dev          *hcidev;
99
100         struct workqueue_struct *if_rx_workqueue;
101         struct work_struct       if_rx_work;
102
103         wait_queue_head_t               wait_for_cmd_resp;
104         u8                                              cmd_resp;
105
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;
112
113         struct command_node             *cur_cmd;
114         spinlock_t                              cmd_lock;
115
116         struct workqueue_struct *cmd_wq;
117         struct work_struct      cmd_work;
118
119         struct sk_buff_head     events_skb_q;
120         struct workqueue_struct *events_wq;
121         struct work_struct      events_work;
122
123         unsigned long           state_flags;
124 };
125
126 struct esp_device {
127         struct device                   *dev;
128         struct wiphy                    *wiphy;
129         struct esp_adapter              *adapter;
130 };
131
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;
137
138         struct net_device_stats stats;
139         u8                      link_state;
140         u8                      mac_address[MAC_ADDR_LEN];
141         u8                      if_type;
142         u8                      if_num;
143
144         int                     ssid_len;
145         u8                      ssid[32];
146
147         volatile u8             stop_data;
148         volatile u8             port_open;
149
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;
155
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;
160 };
161
162
163 #if 0
164 struct esp_private {
165         struct esp_adapter      *adapter;
166         struct net_device       *ndev;
167         struct net_device_stats stats;
168         u8                      link_state;
169         u8                      mac_address[6];
170         u8                      if_type;
171         u8                      if_num;
172 };
173 #endif
174
175 struct esp_skb_cb {
176 /*      struct esp_private      *priv;*/
177         struct esp_wifi_device      *priv;
178 };
179 #endif
This page took 0.040789 seconds and 4 git commands to generate.