2 * Intel Wireless Multicomm 3200 WiFi driver
4 * Copyright (C) 2009 Intel Corporation. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
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
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.
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.
33 * Intel Corporation <ilw@linux.intel.com>
34 * Samuel Ortiz <samuel.ortiz@intel.com>
35 * Zhu Yi <yi.zhu@intel.com>
42 #include <linux/netdevice.h>
43 #include <linux/wireless.h>
44 #include <net/cfg80211.h>
52 #define IWM_COPYRIGHT "Copyright(c) 2009 Intel Corporation"
53 #define IWM_AUTHOR "<ilw@linux.intel.com>"
55 #define CONFIG_IWM_B0_HW_SUPPORT 1
57 #define IWM_SRC_LMAC UMAC_HDI_IN_SOURCE_FHRX
58 #define IWM_SRC_UDMA UMAC_HDI_IN_SOURCE_UDMA
59 #define IWM_SRC_UMAC UMAC_HDI_IN_SOURCE_FW
62 #define IWM_POWER_INDEX_MIN 0
63 #define IWM_POWER_INDEX_MAX 5
64 #define IWM_POWER_INDEX_DEFAULT 3
68 unsigned long init_calib_map;
69 unsigned long periodic_calib_map;
70 bool reset_on_fatal_err;
72 bool wimax_not_present;
89 u8 mac_addr[ETH_ALEN];
90 #ifdef CONFIG_IWM_B0_HW_SUPPORT
106 int id; /* group id */
107 int sid; /* super group id */
108 int min_pages; /* min capacity in pages */
109 int max_pages; /* max capacity in pages */
110 int alloc_pages; /* allocated # of pages. incresed by driver */
111 int total_freed_pages; /* total freed # of pages. incresed by UMAC */
120 struct iwm_tx_credit {
123 unsigned long full_pools_map; /* bitmap for # of filled tx pools */
124 struct pool_entry pools[IWM_MACS_OUT_GROUPS];
125 struct spool_entry spools[IWM_MACS_OUT_SGROUPS];
129 struct list_head pending;
134 unsigned long buf_size;
137 struct iwm_sta_info {
151 unsigned long rx_size;
152 unsigned long rx_buf_size;
155 #define IWM_NUM_KEYS 4
157 struct iwm_umac_key_hdr {
160 u8 multicast; /* BCast encrypt & BCast decrypt of frames FROM mac */
161 } __attribute__ ((packed));
164 struct iwm_umac_key_hdr hdr;
168 u8 tx_seq[IW_ENCODE_SEQ_MAX_SIZE];
169 u8 rx_seq[IW_ENCODE_SEQ_MAX_SIZE];
174 #define IWM_RX_ID_HASH 0xff
175 #define IWM_RX_ID_GET_HASH(id) ((id) % IWM_RX_ID_HASH)
177 #define IWM_STA_TABLE_NUM 16
178 #define IWM_TX_LIST_SIZE 64
179 #define IWM_RX_LIST_SIZE 256
181 #define IWM_SCAN_ID_MAX 0xff
183 #define IWM_STATUS_READY 0
184 #define IWM_STATUS_SCANNING 1
185 #define IWM_STATUS_SCAN_ABORTING 2
186 #define IWM_STATUS_ASSOCIATING 3
187 #define IWM_STATUS_ASSOCIATED 4
189 #define IWM_RADIO_RFKILL_OFF 0
190 #define IWM_RADIO_RFKILL_HW 1
191 #define IWM_RADIO_RFKILL_SW 2
193 struct iwm_tx_queue {
195 struct sk_buff_head queue;
196 struct workqueue_struct *wq;
197 struct work_struct worker;
198 u8 concat_buf[IWM_HAL_CONCATENATE_BUF_SIZE];
203 /* Queues 0 ~ 3 for AC data, 5 for iPAN */
204 #define IWM_TX_QUEUES 5
205 #define IWM_TX_DATA_QUEUES 4
206 #define IWM_TX_CMD_QUEUE 4
208 struct iwm_bss_info {
209 struct list_head node;
210 struct cfg80211_bss *cfg_bss;
211 struct iwm_umac_notif_bss_info *bss;
214 typedef int (*iwm_handler)(struct iwm_priv *priv, u8 *buf,
215 unsigned long buf_size, struct iwm_wifi_cmd *cmd);
217 #define IWM_WATCHDOG_PERIOD (6 * HZ)
220 struct wireless_dev *wdev;
221 struct iwm_if_ops *bus_ops;
223 struct iwm_conf conf;
225 unsigned long status;
228 struct list_head pending_notif;
229 wait_queue_head_t notif_queue;
231 wait_queue_head_t nonwifi_queue;
233 unsigned long calib_done_map;
237 } calib_res[CALIBRATION_CMD_NUM];
239 struct iwm_umac_profile *umac_profile;
240 bool umac_profile_active;
246 struct iwm_sta_info sta_table[IWM_STA_TABLE_NUM];
247 struct list_head bss_list;
249 void (*nonwifi_rx_handlers[UMAC_HDI_IN_OPCODE_NONWIFI_MAX])
250 (struct iwm_priv *priv, u8 *buf, unsigned long buf_size);
252 const iwm_handler *umac_handlers;
253 const iwm_handler *lmac_handlers;
254 DECLARE_BITMAP(lmac_handler_map, LMAC_COMMAND_ID_NUM);
255 DECLARE_BITMAP(umac_handler_map, LMAC_COMMAND_ID_NUM);
256 DECLARE_BITMAP(udma_handler_map, LMAC_COMMAND_ID_NUM);
258 struct list_head wifi_pending_cmd;
259 struct list_head nonwifi_pending_cmd;
267 struct cfg80211_scan_request *scan_request;
269 struct sk_buff_head rx_list;
270 struct list_head rx_tickets;
271 struct list_head rx_packets[IWM_RX_ID_HASH];
272 struct workqueue_struct *rx_wq;
273 struct work_struct rx_worker;
275 struct iwm_tx_credit tx_credit;
276 struct iwm_tx_queue txq[IWM_TX_QUEUES];
278 struct iwm_key keys[IWM_NUM_KEYS];
279 struct iwm_key *default_key;
281 wait_queue_head_t mlme_queue;
283 struct iw_statistics wstats;
284 struct delayed_work stats_request;
286 struct iwm_debugfs dbg;
289 struct timer_list watchdog;
290 struct work_struct reset_worker;
292 struct rfkill *rfkill;
294 char private[0] __attribute__((__aligned__(NETDEV_ALIGN)));
297 static inline void *iwm_private(struct iwm_priv *iwm)
300 return &iwm->private;
303 #define hw_to_iwm(h) (h->iwm)
304 #define iwm_to_dev(i) (wiphy_dev(i->wdev->wiphy))
305 #define iwm_to_wiphy(i) (i->wdev->wiphy)
306 #define wiphy_to_iwm(w) (struct iwm_priv *)(wiphy_priv(w))
307 #define iwm_to_wdev(i) (i->wdev)
308 #define wdev_to_iwm(w) (struct iwm_priv *)(wdev_priv(w))
309 #define iwm_to_ndev(i) (i->wdev->netdev)
310 #define ndev_to_iwm(n) (wdev_to_iwm(n->ieee80211_ptr))
311 #define skb_to_rx_info(s) ((struct iwm_rx_info *)(s->cb))
312 #define skb_to_tx_info(s) ((struct iwm_tx_info *)s->cb)
314 extern const struct iw_handler_def iwm_iw_handler_def;
316 void *iwm_if_alloc(int sizeof_bus, struct device *dev,
317 struct iwm_if_ops *if_ops);
318 void iwm_if_free(struct iwm_priv *iwm);
319 int iwm_if_add(struct iwm_priv *iwm);
320 void iwm_if_remove(struct iwm_priv *iwm);
321 int iwm_mode_to_nl80211_iftype(int mode);
322 int iwm_priv_init(struct iwm_priv *iwm);
323 void iwm_priv_deinit(struct iwm_priv *iwm);
324 void iwm_reset(struct iwm_priv *iwm);
325 void iwm_tx_credit_init_pools(struct iwm_priv *iwm,
326 struct iwm_umac_notif_alive *alive);
327 int iwm_tx_credit_alloc(struct iwm_priv *iwm, int id, int nb);
328 int iwm_notif_send(struct iwm_priv *iwm, struct iwm_wifi_cmd *cmd,
329 u8 cmd_id, u8 source, u8 *buf, unsigned long buf_size);
330 int iwm_notif_handle(struct iwm_priv *iwm, u32 cmd, u8 source, long timeout);
331 void iwm_init_default_profile(struct iwm_priv *iwm,
332 struct iwm_umac_profile *profile);
333 void iwm_link_on(struct iwm_priv *iwm);
334 void iwm_link_off(struct iwm_priv *iwm);
335 int iwm_up(struct iwm_priv *iwm);
336 int iwm_down(struct iwm_priv *iwm);
339 void iwm_tx_credit_inc(struct iwm_priv *iwm, int id, int total_freed_pages);
340 void iwm_tx_worker(struct work_struct *work);
341 int iwm_xmit_frame(struct sk_buff *skb, struct net_device *netdev);
344 void iwm_rx_setup_handlers(struct iwm_priv *iwm);
345 int iwm_rx_handle(struct iwm_priv *iwm, u8 *buf, unsigned long buf_size);
346 int iwm_rx_handle_resp(struct iwm_priv *iwm, u8 *buf, unsigned long buf_size,
347 struct iwm_wifi_cmd *cmd);
348 void iwm_rx_free(struct iwm_priv *iwm);