Commit | Line | Data |
---|---|---|
bb9f8692 ZY |
1 | /* |
2 | * Intel Wireless Multicomm 3200 WiFi driver | |
3 | * | |
4 | * Copyright (C) 2009 Intel Corporation. All rights reserved. | |
5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | |
9 | * | |
10 | * * Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | |
12 | * * Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in | |
14 | * the documentation and/or other materials provided with the | |
15 | * distribution. | |
16 | * * Neither the name of Intel Corporation nor the names of its | |
17 | * contributors may be used to endorse or promote products derived | |
18 | * from this software without specific prior written permission. | |
19 | * | |
20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
31 | * | |
32 | * | |
33 | * Intel Corporation <ilw@linux.intel.com> | |
34 | * Samuel Ortiz <samuel.ortiz@intel.com> | |
35 | * Zhu Yi <yi.zhu@intel.com> | |
36 | * | |
37 | */ | |
38 | ||
39 | #ifndef __IWM_H__ | |
40 | #define __IWM_H__ | |
41 | ||
42 | #include <linux/netdevice.h> | |
43 | #include <linux/wireless.h> | |
44 | #include <net/cfg80211.h> | |
45 | ||
46 | #include "debug.h" | |
47 | #include "hal.h" | |
48 | #include "umac.h" | |
49 | #include "lmac.h" | |
50 | #include "eeprom.h" | |
51 | ||
52 | #define IWM_COPYRIGHT "Copyright(c) 2009 Intel Corporation" | |
53 | #define IWM_AUTHOR "<ilw@linux.intel.com>" | |
54 | ||
bb9f8692 ZY |
55 | #define IWM_SRC_LMAC UMAC_HDI_IN_SOURCE_FHRX |
56 | #define IWM_SRC_UDMA UMAC_HDI_IN_SOURCE_UDMA | |
57 | #define IWM_SRC_UMAC UMAC_HDI_IN_SOURCE_FW | |
58 | #define IWM_SRC_NUM 3 | |
59 | ||
60 | #define IWM_POWER_INDEX_MIN 0 | |
61 | #define IWM_POWER_INDEX_MAX 5 | |
62 | #define IWM_POWER_INDEX_DEFAULT 3 | |
63 | ||
64 | struct iwm_conf { | |
65 | u32 sdio_ior_timeout; | |
fd2c7fe0 | 66 | unsigned long calib_map; |
d04bd628 | 67 | unsigned long expected_calib_map; |
e85498b2 SO |
68 | u8 ct_kill_entry; |
69 | u8 ct_kill_exit; | |
bb9f8692 ZY |
70 | bool reset_on_fatal_err; |
71 | bool auto_connect; | |
72 | bool wimax_not_present; | |
73 | bool enable_qos; | |
74 | u32 mode; | |
75 | ||
76 | u32 power_index; | |
77 | u32 frag_threshold; | |
78 | u32 rts_threshold; | |
79 | bool cts_to_self; | |
80 | ||
81 | u32 assoc_timeout; | |
82 | u32 roam_timeout; | |
83 | u32 wireless_mode; | |
84 | u32 coexist_mode; | |
85 | ||
86 | u8 ibss_band; | |
87 | u8 ibss_channel; | |
88 | ||
89 | u8 mac_addr[ETH_ALEN]; | |
bb9f8692 ZY |
90 | }; |
91 | ||
92 | enum { | |
93 | COEX_MODE_SA = 1, | |
94 | COEX_MODE_XOR, | |
95 | COEX_MODE_CM, | |
96 | COEX_MODE_MAX, | |
97 | }; | |
98 | ||
99 | struct iwm_if_ops; | |
100 | struct iwm_wifi_cmd; | |
101 | ||
102 | struct pool_entry { | |
103 | int id; /* group id */ | |
104 | int sid; /* super group id */ | |
105 | int min_pages; /* min capacity in pages */ | |
106 | int max_pages; /* max capacity in pages */ | |
107 | int alloc_pages; /* allocated # of pages. incresed by driver */ | |
108 | int total_freed_pages; /* total freed # of pages. incresed by UMAC */ | |
109 | }; | |
110 | ||
111 | struct spool_entry { | |
112 | int id; | |
113 | int max_pages; | |
114 | int alloc_pages; | |
115 | }; | |
116 | ||
117 | struct iwm_tx_credit { | |
118 | spinlock_t lock; | |
119 | int pool_nr; | |
120 | unsigned long full_pools_map; /* bitmap for # of filled tx pools */ | |
121 | struct pool_entry pools[IWM_MACS_OUT_GROUPS]; | |
122 | struct spool_entry spools[IWM_MACS_OUT_SGROUPS]; | |
123 | }; | |
124 | ||
125 | struct iwm_notif { | |
126 | struct list_head pending; | |
127 | u32 cmd_id; | |
128 | void *cmd; | |
129 | u8 src; | |
130 | void *buf; | |
131 | unsigned long buf_size; | |
132 | }; | |
133 | ||
134 | struct iwm_sta_info { | |
135 | u8 addr[ETH_ALEN]; | |
136 | bool valid; | |
137 | bool qos; | |
138 | u8 color; | |
139 | }; | |
140 | ||
141 | struct iwm_tx_info { | |
142 | u8 sta; | |
143 | u8 color; | |
144 | u8 tid; | |
145 | }; | |
146 | ||
147 | struct iwm_rx_info { | |
148 | unsigned long rx_size; | |
149 | unsigned long rx_buf_size; | |
150 | }; | |
151 | ||
152 | #define IWM_NUM_KEYS 4 | |
153 | ||
154 | struct iwm_umac_key_hdr { | |
155 | u8 mac[ETH_ALEN]; | |
156 | u8 key_idx; | |
157 | u8 multicast; /* BCast encrypt & BCast decrypt of frames FROM mac */ | |
158 | } __attribute__ ((packed)); | |
159 | ||
160 | struct iwm_key { | |
161 | struct iwm_umac_key_hdr hdr; | |
13e0fe70 SO |
162 | u32 cipher; |
163 | u8 key[WLAN_MAX_KEY_LEN]; | |
164 | u8 seq[IW_ENCODE_SEQ_MAX_SIZE]; | |
165 | int key_len; | |
166 | int seq_len; | |
bb9f8692 ZY |
167 | }; |
168 | ||
169 | #define IWM_RX_ID_HASH 0xff | |
170 | #define IWM_RX_ID_GET_HASH(id) ((id) % IWM_RX_ID_HASH) | |
171 | ||
172 | #define IWM_STA_TABLE_NUM 16 | |
173 | #define IWM_TX_LIST_SIZE 64 | |
174 | #define IWM_RX_LIST_SIZE 256 | |
175 | ||
176 | #define IWM_SCAN_ID_MAX 0xff | |
177 | ||
178 | #define IWM_STATUS_READY 0 | |
179 | #define IWM_STATUS_SCANNING 1 | |
180 | #define IWM_STATUS_SCAN_ABORTING 2 | |
de15fd31 | 181 | #define IWM_STATUS_SME_CONNECTING 3 |
bb9f8692 | 182 | #define IWM_STATUS_ASSOCIATED 4 |
d210176e | 183 | #define IWM_STATUS_RESETTING 5 |
bb9f8692 | 184 | |
bb9f8692 ZY |
185 | struct iwm_tx_queue { |
186 | int id; | |
187 | struct sk_buff_head queue; | |
188 | struct workqueue_struct *wq; | |
189 | struct work_struct worker; | |
190 | u8 concat_buf[IWM_HAL_CONCATENATE_BUF_SIZE]; | |
191 | int concat_count; | |
192 | u8 *concat_ptr; | |
193 | }; | |
194 | ||
195 | /* Queues 0 ~ 3 for AC data, 5 for iPAN */ | |
196 | #define IWM_TX_QUEUES 5 | |
197 | #define IWM_TX_DATA_QUEUES 4 | |
198 | #define IWM_TX_CMD_QUEUE 4 | |
199 | ||
200 | struct iwm_bss_info { | |
201 | struct list_head node; | |
202 | struct cfg80211_bss *cfg_bss; | |
203 | struct iwm_umac_notif_bss_info *bss; | |
204 | }; | |
205 | ||
206 | typedef int (*iwm_handler)(struct iwm_priv *priv, u8 *buf, | |
207 | unsigned long buf_size, struct iwm_wifi_cmd *cmd); | |
208 | ||
209 | #define IWM_WATCHDOG_PERIOD (6 * HZ) | |
210 | ||
211 | struct iwm_priv { | |
212 | struct wireless_dev *wdev; | |
213 | struct iwm_if_ops *bus_ops; | |
214 | ||
215 | struct iwm_conf conf; | |
216 | ||
217 | unsigned long status; | |
bb9f8692 ZY |
218 | |
219 | struct list_head pending_notif; | |
220 | wait_queue_head_t notif_queue; | |
221 | ||
222 | wait_queue_head_t nonwifi_queue; | |
223 | ||
224 | unsigned long calib_done_map; | |
225 | struct { | |
226 | u8 *buf; | |
227 | u32 size; | |
228 | } calib_res[CALIBRATION_CMD_NUM]; | |
229 | ||
230 | struct iwm_umac_profile *umac_profile; | |
231 | bool umac_profile_active; | |
232 | ||
233 | u8 bssid[ETH_ALEN]; | |
234 | u8 channel; | |
235 | u16 rate; | |
257862f3 | 236 | u32 txpower; |
bb9f8692 ZY |
237 | |
238 | struct iwm_sta_info sta_table[IWM_STA_TABLE_NUM]; | |
239 | struct list_head bss_list; | |
240 | ||
241 | void (*nonwifi_rx_handlers[UMAC_HDI_IN_OPCODE_NONWIFI_MAX]) | |
242 | (struct iwm_priv *priv, u8 *buf, unsigned long buf_size); | |
243 | ||
244 | const iwm_handler *umac_handlers; | |
245 | const iwm_handler *lmac_handlers; | |
246 | DECLARE_BITMAP(lmac_handler_map, LMAC_COMMAND_ID_NUM); | |
247 | DECLARE_BITMAP(umac_handler_map, LMAC_COMMAND_ID_NUM); | |
248 | DECLARE_BITMAP(udma_handler_map, LMAC_COMMAND_ID_NUM); | |
249 | ||
250 | struct list_head wifi_pending_cmd; | |
251 | struct list_head nonwifi_pending_cmd; | |
252 | u16 wifi_seq_num; | |
253 | u8 nonwifi_seq_num; | |
254 | spinlock_t cmd_lock; | |
255 | ||
256 | u32 core_enabled; | |
257 | ||
258 | u8 scan_id; | |
259 | struct cfg80211_scan_request *scan_request; | |
260 | ||
261 | struct sk_buff_head rx_list; | |
262 | struct list_head rx_tickets; | |
263 | struct list_head rx_packets[IWM_RX_ID_HASH]; | |
264 | struct workqueue_struct *rx_wq; | |
265 | struct work_struct rx_worker; | |
266 | ||
267 | struct iwm_tx_credit tx_credit; | |
268 | struct iwm_tx_queue txq[IWM_TX_QUEUES]; | |
269 | ||
270 | struct iwm_key keys[IWM_NUM_KEYS]; | |
13e0fe70 | 271 | s8 default_key; |
bb9f8692 | 272 | |
a70742f1 SO |
273 | DECLARE_BITMAP(wifi_ntfy, WIFI_IF_NTFY_MAX); |
274 | wait_queue_head_t wifi_ntfy_queue; | |
275 | ||
bb9f8692 ZY |
276 | wait_queue_head_t mlme_queue; |
277 | ||
278 | struct iw_statistics wstats; | |
279 | struct delayed_work stats_request; | |
c7436273 | 280 | struct delayed_work disconnect; |
e85498b2 | 281 | struct delayed_work ct_kill_delay; |
bb9f8692 ZY |
282 | |
283 | struct iwm_debugfs dbg; | |
284 | ||
285 | u8 *eeprom; | |
286 | struct timer_list watchdog; | |
287 | struct work_struct reset_worker; | |
9829e1b5 | 288 | struct work_struct auth_retry_worker; |
68810c5d | 289 | struct mutex mutex; |
bb9f8692 | 290 | |
b68518fc ZY |
291 | u8 *req_ie; |
292 | int req_ie_len; | |
293 | u8 *resp_ie; | |
294 | int resp_ie_len; | |
295 | ||
04e715cd | 296 | struct iwm_fw_error_hdr *last_fw_err; |
5dc53163 SO |
297 | char umac_version[8]; |
298 | char lmac_version[8]; | |
04e715cd | 299 | |
bb9f8692 ZY |
300 | char private[0] __attribute__((__aligned__(NETDEV_ALIGN))); |
301 | }; | |
302 | ||
303 | static inline void *iwm_private(struct iwm_priv *iwm) | |
304 | { | |
305 | BUG_ON(!iwm); | |
306 | return &iwm->private; | |
307 | } | |
308 | ||
309 | #define hw_to_iwm(h) (h->iwm) | |
310 | #define iwm_to_dev(i) (wiphy_dev(i->wdev->wiphy)) | |
311 | #define iwm_to_wiphy(i) (i->wdev->wiphy) | |
312 | #define wiphy_to_iwm(w) (struct iwm_priv *)(wiphy_priv(w)) | |
313 | #define iwm_to_wdev(i) (i->wdev) | |
314 | #define wdev_to_iwm(w) (struct iwm_priv *)(wdev_priv(w)) | |
315 | #define iwm_to_ndev(i) (i->wdev->netdev) | |
316 | #define ndev_to_iwm(n) (wdev_to_iwm(n->ieee80211_ptr)) | |
317 | #define skb_to_rx_info(s) ((struct iwm_rx_info *)(s->cb)) | |
318 | #define skb_to_tx_info(s) ((struct iwm_tx_info *)s->cb) | |
319 | ||
bb9f8692 ZY |
320 | void *iwm_if_alloc(int sizeof_bus, struct device *dev, |
321 | struct iwm_if_ops *if_ops); | |
322 | void iwm_if_free(struct iwm_priv *iwm); | |
d7e057dc ZY |
323 | int iwm_if_add(struct iwm_priv *iwm); |
324 | void iwm_if_remove(struct iwm_priv *iwm); | |
bb9f8692 ZY |
325 | int iwm_mode_to_nl80211_iftype(int mode); |
326 | int iwm_priv_init(struct iwm_priv *iwm); | |
8d96e796 | 327 | void iwm_priv_deinit(struct iwm_priv *iwm); |
bb9f8692 | 328 | void iwm_reset(struct iwm_priv *iwm); |
d210176e | 329 | void iwm_resetting(struct iwm_priv *iwm); |
bb9f8692 ZY |
330 | void iwm_tx_credit_init_pools(struct iwm_priv *iwm, |
331 | struct iwm_umac_notif_alive *alive); | |
332 | int iwm_tx_credit_alloc(struct iwm_priv *iwm, int id, int nb); | |
333 | int iwm_notif_send(struct iwm_priv *iwm, struct iwm_wifi_cmd *cmd, | |
334 | u8 cmd_id, u8 source, u8 *buf, unsigned long buf_size); | |
335 | int iwm_notif_handle(struct iwm_priv *iwm, u32 cmd, u8 source, long timeout); | |
336 | void iwm_init_default_profile(struct iwm_priv *iwm, | |
337 | struct iwm_umac_profile *profile); | |
338 | void iwm_link_on(struct iwm_priv *iwm); | |
339 | void iwm_link_off(struct iwm_priv *iwm); | |
340 | int iwm_up(struct iwm_priv *iwm); | |
341 | int iwm_down(struct iwm_priv *iwm); | |
342 | ||
343 | /* TX API */ | |
344 | void iwm_tx_credit_inc(struct iwm_priv *iwm, int id, int total_freed_pages); | |
345 | void iwm_tx_worker(struct work_struct *work); | |
346 | int iwm_xmit_frame(struct sk_buff *skb, struct net_device *netdev); | |
347 | ||
348 | /* RX API */ | |
349 | void iwm_rx_setup_handlers(struct iwm_priv *iwm); | |
350 | int iwm_rx_handle(struct iwm_priv *iwm, u8 *buf, unsigned long buf_size); | |
351 | int iwm_rx_handle_resp(struct iwm_priv *iwm, u8 *buf, unsigned long buf_size, | |
352 | struct iwm_wifi_cmd *cmd); | |
353 | void iwm_rx_free(struct iwm_priv *iwm); | |
354 | ||
bb9f8692 | 355 | #endif |