]> Git Repo - esp-hosted.git/blob - esp_hosted_ng/host/include/esp.h
fix(esp_hosted_ng): Add support for esp32-c6 SDIO
[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         ESP_FIRMWARE_CHIP_ESP32C6 = 0x0D,
45 };
46
47 #define ESP_PAYLOAD_HEADER      8
48 struct esp_private;
49 struct esp_adapter;
50
51 #define ACQUIRE_LOCK            1
52 #define LOCK_ALREADY_ACQUIRED   0
53
54 #define SKB_DATA_ADDR_ALIGNMENT 4
55 #define INTERFACE_HEADER_PADDING (SKB_DATA_ADDR_ALIGNMENT*3)
56
57 #define MAX_COUNTRY_LEN 3
58
59 enum adapter_flags_e {
60         ESP_CLEANUP_IN_PROGRESS,    /* Driver unloading or ESP reseted */
61         ESP_CMD_INIT_DONE,          /* Cmd component is initialized with esp_commands_setup() */
62         ESP_DRIVER_ACTIVE,          /* kernel module __exit is not yet invoked */
63         ESP_INIT_DONE,              /* Driver init done */
64 };
65
66 enum priv_flags_e {
67         ESP_NETWORK_UP,
68 };
69
70 struct command_node {
71         struct list_head list;
72         uint8_t cmd_code;
73         struct sk_buff *cmd_skb;
74         struct sk_buff *resp_skb;
75 };
76
77 struct esp_adapter {
78         struct device           *dev;
79         struct wiphy            *wiphy;
80
81         uint8_t                 if_type;
82         uint32_t                capabilities;
83
84         /* Possible types:
85          * struct esp_sdio_context */
86         void                    *if_context;
87
88         struct esp_if_ops       *if_ops;
89
90         /* Private for each interface */
91         struct esp_wifi_device  *priv[ESP_MAX_INTERFACE];
92         struct hci_dev          *hcidev;
93
94         struct workqueue_struct *if_rx_workqueue;
95         struct work_struct      if_rx_work;
96
97         wait_queue_head_t       wait_for_cmd_resp;
98         uint8_t                 cmd_resp;
99
100         /* wpa supplicant commands structures */
101         struct command_node     *cmd_pool;
102         struct list_head        cmd_free_queue;
103         spinlock_t              cmd_free_queue_lock;
104         struct list_head        cmd_pending_queue;
105         spinlock_t              cmd_pending_queue_lock;
106
107         struct command_node     *cur_cmd;
108         spinlock_t              cmd_lock;
109
110         struct workqueue_struct *mac_filter_wq;
111         struct work_struct      mac_flter_work;
112
113         struct workqueue_struct *cmd_wq;
114         struct work_struct      cmd_work;
115
116         struct sk_buff_head     events_skb_q;
117         struct workqueue_struct *events_wq;
118         struct work_struct      events_work;
119
120         unsigned long           state_flags;
121 };
122
123 struct esp_device {
124         struct device           *dev;
125         struct wiphy            *wiphy;
126         struct esp_adapter      *adapter;
127 };
128
129 struct esp_wifi_device {
130         struct wireless_dev     wdev;
131         struct net_device       *ndev;
132         struct esp_device       *esp_dev;
133         struct esp_adapter      *adapter;
134
135         struct net_device_stats stats;
136         uint8_t                 mac_address[MAC_ADDR_LEN];
137         uint8_t                 if_type;
138         uint8_t                 if_num;
139
140         uint32_t                ssid_len;
141         uint8_t                 ssid[32];
142
143         /* This is needed to notify scan completion*/
144         struct cfg80211_scan_request *request;
145         struct cfg80211_bss     *bss;
146         uint8_t                 *assoc_req_ie;
147         size_t                  assoc_req_ie_len;
148
149         uint8_t                 scan_in_progress;
150         uint8_t                 waiting_for_scan_done;
151
152         uint8_t                 link_state;
153
154         volatile uint8_t        stop_data;
155         volatile uint8_t        port_open;
156
157         char                    country_code[MAX_COUNTRY_LEN];
158
159         wait_queue_head_t       wait_for_scan_completion;
160         unsigned long           priv_flags;
161         struct notifier_block   nb;
162         uint8_t                 tx_pwr_type;
163         uint8_t                 tx_pwr;
164 };
165
166
167 struct esp_skb_cb {
168         struct esp_wifi_device      *priv;
169 };
170 #endif
This page took 0.033542 seconds and 4 git commands to generate.