2 * Copyright (c) 2011-2014 Espressif System.
4 * wlan device header file
10 #include <linux/etherdevice.h>
11 #include <linux/rtnetlink.h>
12 #include <linux/firmware.h>
13 #include <linux/sched.h>
14 #include <net/mac80211.h>
15 #include <net/cfg80211.h>
16 #include <linux/version.h>
17 #include "sip2_common.h"
19 // to support kernel < 2.6.28 there's no ieee80211_sta
20 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28))
21 #include <net/wireless.h>
25 ESP_SDIO_STATE_FIRST_INIT,
26 ESP_SDIO_STATE_FIRST_NORMAL_EXIT,
27 ESP_SDIO_STATE_FIRST_ERROR_EXIT,
28 ESP_SDIO_STATE_SECOND_INIT,
29 ESP_SDIO_STATE_SECOND_ERROR_EXIT,
34 ESP_TID_STATE_TRIGGER,
35 ESP_TID_STATE_PROGRESS,
36 ESP_TID_STATE_OPERATIONAL,
37 ESP_TID_STATE_WAIT_STOP,
47 #define WME_NUM_TID 16
49 struct esp_tx_tid tid[WME_NUM_TID];
50 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28))
51 struct ieee80211_sta *sta;
55 u64 supp_rates[IEEE80211_NUM_BANDS];
56 struct ieee80211_ht_info ht_info;
80 struct timer_list beacon_timer;
83 /* WLAN related, mostly... */
84 /*struct hw_scan_timeout {
85 struct delayed_work w;
86 struct ieee80211_hw *hw;
89 typedef struct esp_wl {
91 u8 req_bssid[ETH_ALEN];
93 //struct hw_scan_timeout *hsd;
94 struct cfg80211_scan_request *scan_req;
97 atomic_t tkip_key_set;
99 /* so far only 2G band */
100 struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
106 typedef struct esp_hw_idx_map {
111 #define ESP_WL_FLAG_RFKILL BIT(0)
112 #define ESP_WL_FLAG_HW_REGISTERED BIT(1)
113 #define ESP_WL_FLAG_CONNECT BIT(2)
114 #define ESP_WL_FLAG_STOP_TXQ BIT(3)
116 #define ESP_PUB_MAX_VIF 2
117 #define ESP_PUB_MAX_STA 4 //for one interface
118 #define ESP_PUB_MAX_RXAMPDU 8 //for all interfaces
124 ESP_PM_TURNING_OFF, /* Do NOT change the order */
129 u32 max_sleep_period;
130 unsigned long last_config_time;
135 struct esp_mac_prefix {
137 u8 mac_addr_prefix[3];
142 #ifdef ESP_NO_MAC80211
143 struct net_device *net_dev;
144 struct wireless_dev *wdev;
145 struct net_device_stats *net_stats;
147 struct ieee80211_hw *hw;
148 struct ieee80211_vif *vif;
150 #endif /* ESP_MAC80211 */
152 void *sif; /* serial interface control block, e.g. sdio */
153 enum esp_sdio_state sdio_state;
156 struct esp_hw_idx_map hi_map[19];
157 struct esp_hw_idx_map low_map[ESP_PUB_MAX_VIF][2];
158 //u32 flags; //flags to represent rfkill switch,start
159 u8 roc_flags; //0: not in remain on channel state, 1: in roc state
161 struct work_struct tx_work; /* attach to ieee80211 workqueue */
162 /* latest mac80211 has multiple tx queue, but we stick with single queue now */
164 spinlock_t tx_ampdu_lock;
165 spinlock_t rx_ampdu_lock;
168 struct sk_buff_head txq;
169 atomic_t txq_stopped;
171 struct work_struct sendup_work; /* attach to ieee80211 workqueue */
172 struct sk_buff_head txdoneq;
173 struct sk_buff_head rxq;
175 struct workqueue_struct *esp_wkq;
177 //u8 bssid[ETH_ALEN];
178 u8 mac_addr[ETH_ALEN];
181 unsigned long scan_permit;
182 bool scan_permit_valid;
183 struct delayed_work scan_timeout_work;
186 u32 enodes_maps[ESP_PUB_MAX_VIF];
187 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28))
188 struct esp_node nodes[ESP_PUB_MAX_STA + 1];
190 struct esp_node * enodes[ESP_PUB_MAX_STA + 1];
191 struct esp_node * rxampdu_node[ESP_PUB_MAX_RXAMPDU];
192 u8 rxampdu_tid[ESP_PUB_MAX_RXAMPDU];
198 typedef struct esp_pub esp_pub_t;
200 struct esp_pub *esp_pub_alloc_mac80211(struct device *dev);
201 int esp_pub_dealloc_mac80211(struct esp_pub *epub);
202 int esp_register_mac80211(struct esp_pub *epub);
204 int esp_pub_init_all(struct esp_pub *epub);
206 char *mod_eagle_path_get(void);
208 void esp_dsr(struct esp_pub *epub);
209 void hw_scan_done(struct esp_pub *epub, bool aborted);
210 void esp_rocdone_process(struct ieee80211_hw *hw, struct sip_evt_roc *report);
212 void esp_ps_config(struct esp_pub *epub, struct esp_ps *ps, bool on);
215 void esp_register_early_suspend(void);
216 void esp_unregister_early_suspend(void);
217 void esp_wakelock_init(void);
218 void esp_wakelock_destroy(void);
219 void esp_wake_lock(void);
220 void esp_wake_unlock(void);
221 struct esp_node * esp_get_node_by_addr(struct esp_pub * epub, const u8 *addr);
222 struct esp_node * esp_get_node_by_index(struct esp_pub * epub, u8 index);
223 int esp_get_empty_rxampdu(struct esp_pub * epub, const u8 *addr, u8 tid);
224 int esp_get_exist_rxampdu(struct esp_pub * epub, const u8 *addr, u8 tid);
227 int test_init_netlink(struct esp_sip *sip);
228 void test_exit_netlink(void);
229 void esp_test_cmd_event(u32 cmd_type, char *reply_info);
230 void esp_test_init(struct esp_pub *epub);
232 #endif /* _ESP_PUB_H_ */