]> Git Repo - esp-hosted.git/blob - esp_hosted_ng/host/include/esp.h
Merge branch 'feature/c2_support_for_spi_and_uart' into 'master'
[esp-hosted.git] / esp_hosted_ng / host / include / esp.h
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Espressif Systems Wireless LAN device driver
4  *
5  * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
6  *
7  */
8 #ifndef __esp__h_
9 #define __esp__h_
10
11 #include <linux/workqueue.h>
12 #include <linux/wait.h>
13 #include <linux/interrupt.h>
14 #include <linux/netdevice.h>
15 #include <linux/inetdevice.h>
16 #include <linux/etherdevice.h>
17 #include <linux/spinlock.h>
18 #include <net/cfg80211.h>
19 #include <net/bluetooth/bluetooth.h>
20 #include <net/bluetooth/hci_core.h>
21 #include "adapter.h"
22
23 #define ESP_IF_TYPE_SDIO        1
24 #define ESP_IF_TYPE_SPI         2
25
26 /* Network link status */
27 #define ESP_LINK_DOWN           0
28 #define ESP_LINK_UP             1
29
30 #define ESP_MAX_INTERFACE       1
31 //#define ESP_MAX_INTERFACE       2
32 #define ESP_STA_NW_IF           0
33 #define ESP_AP_NW_IF            1
34
35 /* ESP in sdkconfig has CONFIG_IDF_FIRMWARE_CHIP_ID entry.
36  * supported values of CONFIG_IDF_FIRMWARE_CHIP_ID are - */
37 enum chipset_type_e {
38         ESP_FIRMWARE_CHIP_UNRECOGNIZED = 0xff,
39         ESP_FIRMWARE_CHIP_ESP32 = 0x0,
40         ESP_FIRMWARE_CHIP_ESP32S2 = 0x2,
41         ESP_FIRMWARE_CHIP_ESP32C3 = 0x5,
42         ESP_FIRMWARE_CHIP_ESP32S3 = 0x9,
43         ESP_FIRMWARE_CHIP_ESP32C2 = 0x0C,
44 };
45
46 #define ESP_PAYLOAD_HEADER      8
47 struct esp_private;
48 struct esp_adapter;
49
50 #define ACQUIRE_LOCK            1
51 #define LOCK_ALREADY_ACQUIRED   0
52
53 #define SKB_DATA_ADDR_ALIGNMENT 4
54 #define INTERFACE_HEADER_PADDING (SKB_DATA_ADDR_ALIGNMENT*3)
55
56 #define MAX_COUNTRY_LEN 3
57
58 enum adapter_flags_e {
59         ESP_CLEANUP_IN_PROGRESS,    /* Driver unloading or ESP reseted */
60         ESP_CMD_INIT_DONE,          /* Cmd component is initialized with esp_commands_setup() */
61         ESP_DRIVER_ACTIVE,          /* kernel module __exit is not yet invoked */
62 };
63
64 enum priv_flags_e {
65         ESP_NETWORK_UP,
66 };
67
68 struct command_node {
69         struct list_head list;
70         uint8_t cmd_code;
71         struct sk_buff *cmd_skb;
72         struct sk_buff *resp_skb;
73 };
74
75 struct esp_adapter {
76         struct device           *dev;
77         struct wiphy            *wiphy;
78
79         uint8_t                 if_type;
80         uint32_t                capabilities;
81
82         /* Possible types:
83          * struct esp_sdio_context */
84         void                    *if_context;
85
86         struct esp_if_ops       *if_ops;
87
88         /* Private for each interface */
89         struct esp_wifi_device  *priv[ESP_MAX_INTERFACE];
90         struct hci_dev          *hcidev;
91
92         struct workqueue_struct *if_rx_workqueue;
93         struct work_struct      if_rx_work;
94
95         wait_queue_head_t       wait_for_cmd_resp;
96         uint8_t                 cmd_resp;
97
98         /* wpa supplicant commands structures */
99         struct command_node     *cmd_pool;
100         struct list_head        cmd_free_queue;
101         spinlock_t              cmd_free_queue_lock;
102         struct list_head        cmd_pending_queue;
103         spinlock_t              cmd_pending_queue_lock;
104
105         struct command_node     *cur_cmd;
106         spinlock_t              cmd_lock;
107
108         struct workqueue_struct *mac_filter_wq;
109         struct work_struct      mac_flter_work;
110
111         struct workqueue_struct *cmd_wq;
112         struct work_struct      cmd_work;
113
114         struct sk_buff_head     events_skb_q;
115         struct workqueue_struct *events_wq;
116         struct work_struct      events_work;
117
118         unsigned long           state_flags;
119 };
120
121 struct esp_device {
122         struct device           *dev;
123         struct wiphy            *wiphy;
124         struct esp_adapter      *adapter;
125 };
126
127 struct esp_wifi_device {
128         struct wireless_dev     wdev;
129         struct net_device       *ndev;
130         struct esp_device       *esp_dev;
131         struct esp_adapter      *adapter;
132
133         struct net_device_stats stats;
134         uint8_t                 mac_address[MAC_ADDR_LEN];
135         uint8_t                 if_type;
136         uint8_t                 if_num;
137
138         uint32_t                ssid_len;
139         uint8_t                 ssid[32];
140
141         /* This is needed to notify scan completion*/
142         struct cfg80211_scan_request *request;
143         struct cfg80211_bss     *bss;
144         uint8_t                 *assoc_req_ie;
145         size_t                  assoc_req_ie_len;
146
147         uint8_t                 scan_in_progress;
148         uint8_t                 waiting_for_scan_done;
149
150         uint8_t                 link_state;
151
152         volatile uint8_t        stop_data;
153         volatile uint8_t        port_open;
154
155         char                    country_code[MAX_COUNTRY_LEN];
156
157         wait_queue_head_t       wait_for_scan_completion;
158         unsigned long           priv_flags;
159         struct notifier_block   nb;
160         uint8_t                 tx_pwr_type;
161         uint8_t                 tx_pwr;
162 };
163
164
165 struct esp_skb_cb {
166         struct esp_wifi_device      *priv;
167 };
168 #endif
This page took 0.032963 seconds and 4 git commands to generate.