Commit | Line | Data |
---|---|---|
be663ab6 WYG |
1 | /****************************************************************************** |
2 | * | |
3 | * This file is provided under a dual BSD/GPLv2 license. When using or | |
4 | * redistributing this file, you may do so under either license. | |
5 | * | |
6 | * GPL LICENSE SUMMARY | |
7 | * | |
8 | * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. | |
9 | * | |
10 | * This program is free software; you can redistribute it and/or modify | |
11 | * it under the terms of version 2 of the GNU General Public License as | |
12 | * published by the Free Software Foundation. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, but | |
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | * General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, | |
22 | * USA | |
23 | * | |
24 | * The full GNU General Public License is included in this distribution | |
25 | * in the file called LICENSE.GPL. | |
26 | * | |
27 | * Contact Information: | |
28 | * Intel Linux Wireless <ilw@linux.intel.com> | |
29 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 | |
30 | * | |
31 | * BSD LICENSE | |
32 | * | |
33 | * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. | |
34 | * All rights reserved. | |
35 | * | |
36 | * Redistribution and use in source and binary forms, with or without | |
37 | * modification, are permitted provided that the following conditions | |
38 | * are met: | |
39 | * | |
40 | * * Redistributions of source code must retain the above copyright | |
41 | * notice, this list of conditions and the following disclaimer. | |
42 | * * Redistributions in binary form must reproduce the above copyright | |
43 | * notice, this list of conditions and the following disclaimer in | |
44 | * the documentation and/or other materials provided with the | |
45 | * distribution. | |
46 | * * Neither the name Intel Corporation nor the names of its | |
47 | * contributors may be used to endorse or promote products derived | |
48 | * from this software without specific prior written permission. | |
49 | * | |
50 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
51 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
52 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
53 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
54 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
55 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
56 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
57 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
58 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
59 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
60 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
61 | *****************************************************************************/ | |
62 | ||
63 | #ifndef __iwl_legacy_core_h__ | |
64 | #define __iwl_legacy_core_h__ | |
65 | ||
66 | /************************ | |
67 | * forward declarations * | |
68 | ************************/ | |
69 | struct iwl_host_cmd; | |
70 | struct iwl_cmd; | |
71 | ||
72 | ||
73 | #define IWLWIFI_VERSION "in-tree:" | |
74 | #define DRV_COPYRIGHT "Copyright(c) 2003-2011 Intel Corporation" | |
75 | #define DRV_AUTHOR "<ilw@linux.intel.com>" | |
76 | ||
77 | #define IWL_PCI_DEVICE(dev, subdev, cfg) \ | |
78 | .vendor = PCI_VENDOR_ID_INTEL, .device = (dev), \ | |
79 | .subvendor = PCI_ANY_ID, .subdevice = (subdev), \ | |
80 | .driver_data = (kernel_ulong_t)&(cfg) | |
81 | ||
82 | #define TIME_UNIT 1024 | |
83 | ||
84 | #define IWL_SKU_G 0x1 | |
85 | #define IWL_SKU_A 0x2 | |
86 | #define IWL_SKU_N 0x8 | |
87 | ||
88 | #define IWL_CMD(x) case x: return #x | |
89 | ||
90 | struct iwl_hcmd_ops { | |
91 | int (*rxon_assoc)(struct iwl_priv *priv, struct iwl_rxon_context *ctx); | |
92 | int (*commit_rxon)(struct iwl_priv *priv, struct iwl_rxon_context *ctx); | |
93 | void (*set_rxon_chain)(struct iwl_priv *priv, | |
94 | struct iwl_rxon_context *ctx); | |
95 | }; | |
96 | ||
97 | struct iwl_hcmd_utils_ops { | |
98 | u16 (*get_hcmd_size)(u8 cmd_id, u16 len); | |
99 | u16 (*build_addsta_hcmd)(const struct iwl_legacy_addsta_cmd *cmd, | |
100 | u8 *data); | |
101 | int (*request_scan)(struct iwl_priv *priv, struct ieee80211_vif *vif); | |
102 | void (*post_scan)(struct iwl_priv *priv); | |
103 | }; | |
104 | ||
105 | struct iwl_apm_ops { | |
106 | int (*init)(struct iwl_priv *priv); | |
107 | void (*config)(struct iwl_priv *priv); | |
108 | }; | |
109 | ||
110 | struct iwl_debugfs_ops { | |
111 | ssize_t (*rx_stats_read)(struct file *file, char __user *user_buf, | |
112 | size_t count, loff_t *ppos); | |
113 | ssize_t (*tx_stats_read)(struct file *file, char __user *user_buf, | |
114 | size_t count, loff_t *ppos); | |
115 | ssize_t (*general_stats_read)(struct file *file, char __user *user_buf, | |
116 | size_t count, loff_t *ppos); | |
117 | }; | |
118 | ||
119 | struct iwl_temp_ops { | |
120 | void (*temperature)(struct iwl_priv *priv); | |
121 | }; | |
122 | ||
123 | struct iwl_lib_ops { | |
124 | /* set hw dependent parameters */ | |
125 | int (*set_hw_params)(struct iwl_priv *priv); | |
126 | /* Handling TX */ | |
127 | void (*txq_update_byte_cnt_tbl)(struct iwl_priv *priv, | |
128 | struct iwl_tx_queue *txq, | |
129 | u16 byte_cnt); | |
130 | int (*txq_attach_buf_to_tfd)(struct iwl_priv *priv, | |
131 | struct iwl_tx_queue *txq, | |
132 | dma_addr_t addr, | |
133 | u16 len, u8 reset, u8 pad); | |
134 | void (*txq_free_tfd)(struct iwl_priv *priv, | |
135 | struct iwl_tx_queue *txq); | |
136 | int (*txq_init)(struct iwl_priv *priv, | |
137 | struct iwl_tx_queue *txq); | |
138 | /* setup Rx handler */ | |
139 | void (*rx_handler_setup)(struct iwl_priv *priv); | |
140 | /* alive notification after init uCode load */ | |
141 | void (*init_alive_start)(struct iwl_priv *priv); | |
142 | /* check validity of rtc data address */ | |
143 | int (*is_valid_rtc_data_addr)(u32 addr); | |
144 | /* 1st ucode load */ | |
145 | int (*load_ucode)(struct iwl_priv *priv); | |
146 | int (*dump_nic_event_log)(struct iwl_priv *priv, | |
147 | bool full_log, char **buf, bool display); | |
148 | void (*dump_nic_error_log)(struct iwl_priv *priv); | |
149 | int (*dump_fh)(struct iwl_priv *priv, char **buf, bool display); | |
150 | int (*set_channel_switch)(struct iwl_priv *priv, | |
151 | struct ieee80211_channel_switch *ch_switch); | |
152 | /* power management */ | |
153 | struct iwl_apm_ops apm_ops; | |
154 | ||
155 | /* power */ | |
156 | int (*send_tx_power) (struct iwl_priv *priv); | |
157 | void (*update_chain_flags)(struct iwl_priv *priv); | |
158 | ||
159 | /* eeprom operations (as defined in iwl-eeprom.h) */ | |
160 | struct iwl_eeprom_ops eeprom_ops; | |
161 | ||
162 | /* temperature */ | |
163 | struct iwl_temp_ops temp_ops; | |
be663ab6 WYG |
164 | |
165 | struct iwl_debugfs_ops debugfs_ops; | |
166 | ||
167 | }; | |
168 | ||
169 | struct iwl_led_ops { | |
170 | int (*cmd)(struct iwl_priv *priv, struct iwl_led_cmd *led_cmd); | |
171 | }; | |
172 | ||
173 | struct iwl_legacy_ops { | |
174 | void (*post_associate)(struct iwl_priv *priv); | |
175 | void (*config_ap)(struct iwl_priv *priv); | |
176 | /* station management */ | |
177 | int (*update_bcast_stations)(struct iwl_priv *priv); | |
178 | int (*manage_ibss_station)(struct iwl_priv *priv, | |
179 | struct ieee80211_vif *vif, bool add); | |
180 | }; | |
181 | ||
182 | struct iwl_ops { | |
183 | const struct iwl_lib_ops *lib; | |
184 | const struct iwl_hcmd_ops *hcmd; | |
185 | const struct iwl_hcmd_utils_ops *utils; | |
186 | const struct iwl_led_ops *led; | |
187 | const struct iwl_nic_ops *nic; | |
188 | const struct iwl_legacy_ops *legacy; | |
189 | const struct ieee80211_ops *ieee80211_ops; | |
190 | }; | |
191 | ||
192 | struct iwl_mod_params { | |
193 | int sw_crypto; /* def: 0 = using hardware encryption */ | |
194 | int disable_hw_scan; /* def: 0 = use h/w scan */ | |
195 | int num_of_queues; /* def: HW dependent */ | |
196 | int disable_11n; /* def: 0 = 11n capabilities enabled */ | |
197 | int amsdu_size_8K; /* def: 1 = enable 8K amsdu size */ | |
198 | int antenna; /* def: 0 = both antennas (use diversity) */ | |
199 | int restart_fw; /* def: 1 = restart firmware */ | |
200 | }; | |
201 | ||
202 | /* | |
203 | * @led_compensation: compensate on the led on/off time per HW according | |
204 | * to the deviation to achieve the desired led frequency. | |
205 | * The detail algorithm is described in iwl-led.c | |
206 | * @chain_noise_num_beacons: number of beacons used to compute chain noise | |
be663ab6 WYG |
207 | * @wd_timeout: TX queues watchdog timeout |
208 | * @temperature_kelvin: temperature report by uCode in kelvin | |
209 | * @max_event_log_size: size of event log buffer size for ucode event logging | |
210 | * @ucode_tracing: support ucode continuous tracing | |
211 | * @sensitivity_calib_by_driver: driver has the capability to perform | |
212 | * sensitivity calibration operation | |
213 | * @chain_noise_calib_by_driver: driver has the capability to perform | |
214 | * chain noise calibration operation | |
215 | */ | |
216 | struct iwl_base_params { | |
217 | int eeprom_size; | |
218 | int num_of_queues; /* def: HW dependent */ | |
219 | int num_of_ampdu_queues;/* def: HW dependent */ | |
220 | /* for iwl_legacy_apm_init() */ | |
221 | u32 pll_cfg_val; | |
222 | bool set_l0s; | |
223 | bool use_bsm; | |
224 | ||
225 | u16 led_compensation; | |
226 | int chain_noise_num_beacons; | |
be663ab6 WYG |
227 | unsigned int wd_timeout; |
228 | bool temperature_kelvin; | |
229 | u32 max_event_log_size; | |
230 | const bool ucode_tracing; | |
231 | const bool sensitivity_calib_by_driver; | |
232 | const bool chain_noise_calib_by_driver; | |
233 | }; | |
234 | ||
235 | /** | |
236 | * struct iwl_cfg | |
237 | * @fw_name_pre: Firmware filename prefix. The api version and extension | |
238 | * (.ucode) will be added to filename before loading from disk. The | |
239 | * filename is constructed as fw_name_pre<api>.ucode. | |
240 | * @ucode_api_max: Highest version of uCode API supported by driver. | |
241 | * @ucode_api_min: Lowest version of uCode API supported by driver. | |
242 | * @scan_antennas: available antenna for scan operation | |
243 | * @led_mode: 0=blinking, 1=On(RF On)/Off(RF Off) | |
244 | * | |
245 | * We enable the driver to be backward compatible wrt API version. The | |
246 | * driver specifies which APIs it supports (with @ucode_api_max being the | |
247 | * highest and @ucode_api_min the lowest). Firmware will only be loaded if | |
248 | * it has a supported API version. The firmware's API version will be | |
249 | * stored in @iwl_priv, enabling the driver to make runtime changes based | |
250 | * on firmware version used. | |
251 | * | |
252 | * For example, | |
253 | * if (IWL_UCODE_API(priv->ucode_ver) >= 2) { | |
254 | * Driver interacts with Firmware API version >= 2. | |
255 | * } else { | |
256 | * Driver interacts with Firmware API version 1. | |
257 | * } | |
258 | * | |
259 | * The ideal usage of this infrastructure is to treat a new ucode API | |
260 | * release as a new hardware revision. That is, through utilizing the | |
261 | * iwl_hcmd_utils_ops etc. we accommodate different command structures | |
262 | * and flows between hardware versions as well as their API | |
263 | * versions. | |
264 | * | |
265 | */ | |
266 | struct iwl_cfg { | |
267 | /* params specific to an individual device within a device family */ | |
268 | const char *name; | |
269 | const char *fw_name_pre; | |
270 | const unsigned int ucode_api_max; | |
271 | const unsigned int ucode_api_min; | |
272 | u8 valid_tx_ant; | |
273 | u8 valid_rx_ant; | |
274 | unsigned int sku; | |
275 | u16 eeprom_ver; | |
276 | u16 eeprom_calib_ver; | |
277 | const struct iwl_ops *ops; | |
278 | /* module based parameters which can be set from modprobe cmd */ | |
279 | const struct iwl_mod_params *mod_params; | |
280 | /* params not likely to change within a device family */ | |
281 | struct iwl_base_params *base_params; | |
282 | /* params likely to change within a device family */ | |
283 | u8 scan_rx_antennas[IEEE80211_NUM_BANDS]; | |
be663ab6 WYG |
284 | enum iwl_led_mode led_mode; |
285 | }; | |
286 | ||
287 | /*************************** | |
288 | * L i b * | |
289 | ***************************/ | |
290 | ||
291 | struct ieee80211_hw *iwl_legacy_alloc_all(struct iwl_cfg *cfg); | |
292 | int iwl_legacy_mac_conf_tx(struct ieee80211_hw *hw, u16 queue, | |
293 | const struct ieee80211_tx_queue_params *params); | |
294 | int iwl_legacy_mac_tx_last_beacon(struct ieee80211_hw *hw); | |
295 | void iwl_legacy_set_rxon_hwcrypto(struct iwl_priv *priv, | |
296 | struct iwl_rxon_context *ctx, | |
297 | int hw_decrypt); | |
298 | int iwl_legacy_check_rxon_cmd(struct iwl_priv *priv, | |
299 | struct iwl_rxon_context *ctx); | |
300 | int iwl_legacy_full_rxon_required(struct iwl_priv *priv, | |
301 | struct iwl_rxon_context *ctx); | |
302 | int iwl_legacy_set_rxon_channel(struct iwl_priv *priv, | |
303 | struct ieee80211_channel *ch, | |
304 | struct iwl_rxon_context *ctx); | |
305 | void iwl_legacy_set_flags_for_band(struct iwl_priv *priv, | |
306 | struct iwl_rxon_context *ctx, | |
307 | enum ieee80211_band band, | |
308 | struct ieee80211_vif *vif); | |
309 | u8 iwl_legacy_get_single_channel_number(struct iwl_priv *priv, | |
310 | enum ieee80211_band band); | |
311 | void iwl_legacy_set_rxon_ht(struct iwl_priv *priv, | |
312 | struct iwl_ht_config *ht_conf); | |
313 | bool iwl_legacy_is_ht40_tx_allowed(struct iwl_priv *priv, | |
314 | struct iwl_rxon_context *ctx, | |
315 | struct ieee80211_sta_ht_cap *ht_cap); | |
316 | void iwl_legacy_connection_init_rx_config(struct iwl_priv *priv, | |
317 | struct iwl_rxon_context *ctx); | |
318 | void iwl_legacy_set_rate(struct iwl_priv *priv); | |
319 | int iwl_legacy_set_decrypted_flag(struct iwl_priv *priv, | |
320 | struct ieee80211_hdr *hdr, | |
321 | u32 decrypt_res, | |
322 | struct ieee80211_rx_status *stats); | |
323 | void iwl_legacy_irq_handle_error(struct iwl_priv *priv); | |
324 | int iwl_legacy_mac_add_interface(struct ieee80211_hw *hw, | |
325 | struct ieee80211_vif *vif); | |
326 | void iwl_legacy_mac_remove_interface(struct ieee80211_hw *hw, | |
327 | struct ieee80211_vif *vif); | |
328 | int iwl_legacy_mac_change_interface(struct ieee80211_hw *hw, | |
329 | struct ieee80211_vif *vif, | |
330 | enum nl80211_iftype newtype, bool newp2p); | |
331 | int iwl_legacy_alloc_txq_mem(struct iwl_priv *priv); | |
332 | void iwl_legacy_txq_mem(struct iwl_priv *priv); | |
333 | ||
334 | #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS | |
335 | int iwl_legacy_alloc_traffic_mem(struct iwl_priv *priv); | |
336 | void iwl_legacy_free_traffic_mem(struct iwl_priv *priv); | |
337 | void iwl_legacy_reset_traffic_log(struct iwl_priv *priv); | |
338 | void iwl_legacy_dbg_log_tx_data_frame(struct iwl_priv *priv, | |
339 | u16 length, struct ieee80211_hdr *header); | |
340 | void iwl_legacy_dbg_log_rx_data_frame(struct iwl_priv *priv, | |
341 | u16 length, struct ieee80211_hdr *header); | |
342 | const char *iwl_legacy_get_mgmt_string(int cmd); | |
343 | const char *iwl_legacy_get_ctrl_string(int cmd); | |
344 | void iwl_legacy_clear_traffic_stats(struct iwl_priv *priv); | |
345 | void iwl_legacy_update_stats(struct iwl_priv *priv, bool is_tx, __le16 fc, | |
346 | u16 len); | |
347 | #else | |
348 | static inline int iwl_legacy_alloc_traffic_mem(struct iwl_priv *priv) | |
349 | { | |
350 | return 0; | |
351 | } | |
352 | static inline void iwl_legacy_free_traffic_mem(struct iwl_priv *priv) | |
353 | { | |
354 | } | |
355 | static inline void iwl_legacy_reset_traffic_log(struct iwl_priv *priv) | |
356 | { | |
357 | } | |
358 | static inline void iwl_legacy_dbg_log_tx_data_frame(struct iwl_priv *priv, | |
359 | u16 length, struct ieee80211_hdr *header) | |
360 | { | |
361 | } | |
362 | static inline void iwl_legacy_dbg_log_rx_data_frame(struct iwl_priv *priv, | |
363 | u16 length, struct ieee80211_hdr *header) | |
364 | { | |
365 | } | |
366 | static inline void iwl_legacy_update_stats(struct iwl_priv *priv, bool is_tx, | |
367 | __le16 fc, u16 len) | |
368 | { | |
369 | } | |
370 | #endif | |
371 | /***************************************************** | |
372 | * RX handlers. | |
373 | * **************************************************/ | |
374 | void iwl_legacy_rx_pm_sleep_notif(struct iwl_priv *priv, | |
375 | struct iwl_rx_mem_buffer *rxb); | |
376 | void iwl_legacy_rx_pm_debug_statistics_notif(struct iwl_priv *priv, | |
377 | struct iwl_rx_mem_buffer *rxb); | |
378 | void iwl_legacy_rx_reply_error(struct iwl_priv *priv, | |
379 | struct iwl_rx_mem_buffer *rxb); | |
380 | ||
381 | /***************************************************** | |
382 | * RX | |
383 | ******************************************************/ | |
8a032c13 | 384 | void iwl_legacy_cmd_queue_unmap(struct iwl_priv *priv); |
be663ab6 WYG |
385 | void iwl_legacy_cmd_queue_free(struct iwl_priv *priv); |
386 | int iwl_legacy_rx_queue_alloc(struct iwl_priv *priv); | |
387 | void iwl_legacy_rx_queue_update_write_ptr(struct iwl_priv *priv, | |
388 | struct iwl_rx_queue *q); | |
389 | int iwl_legacy_rx_queue_space(const struct iwl_rx_queue *q); | |
390 | void iwl_legacy_tx_cmd_complete(struct iwl_priv *priv, | |
391 | struct iwl_rx_mem_buffer *rxb); | |
392 | /* Handlers */ | |
393 | void iwl_legacy_rx_spectrum_measure_notif(struct iwl_priv *priv, | |
394 | struct iwl_rx_mem_buffer *rxb); | |
395 | void iwl_legacy_recover_from_statistics(struct iwl_priv *priv, | |
396 | struct iwl_rx_packet *pkt); | |
397 | void iwl_legacy_chswitch_done(struct iwl_priv *priv, bool is_success); | |
398 | void iwl_legacy_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb); | |
399 | ||
400 | /* TX helpers */ | |
401 | ||
402 | /***************************************************** | |
403 | * TX | |
404 | ******************************************************/ | |
405 | void iwl_legacy_txq_update_write_ptr(struct iwl_priv *priv, | |
406 | struct iwl_tx_queue *txq); | |
407 | int iwl_legacy_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq, | |
408 | int slots_num, u32 txq_id); | |
409 | void iwl_legacy_tx_queue_reset(struct iwl_priv *priv, | |
410 | struct iwl_tx_queue *txq, | |
411 | int slots_num, u32 txq_id); | |
8a032c13 | 412 | void iwl_legacy_tx_queue_unmap(struct iwl_priv *priv, int txq_id); |
be663ab6 WYG |
413 | void iwl_legacy_tx_queue_free(struct iwl_priv *priv, int txq_id); |
414 | void iwl_legacy_setup_watchdog(struct iwl_priv *priv); | |
415 | /***************************************************** | |
416 | * TX power | |
417 | ****************************************************/ | |
418 | int iwl_legacy_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force); | |
419 | ||
420 | /******************************************************************************* | |
421 | * Rate | |
422 | ******************************************************************************/ | |
423 | ||
424 | u8 iwl_legacy_get_lowest_plcp(struct iwl_priv *priv, | |
425 | struct iwl_rxon_context *ctx); | |
426 | ||
427 | /******************************************************************************* | |
428 | * Scanning | |
429 | ******************************************************************************/ | |
430 | void iwl_legacy_init_scan_params(struct iwl_priv *priv); | |
431 | int iwl_legacy_scan_cancel(struct iwl_priv *priv); | |
432 | int iwl_legacy_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms); | |
433 | void iwl_legacy_force_scan_end(struct iwl_priv *priv); | |
434 | int iwl_legacy_mac_hw_scan(struct ieee80211_hw *hw, | |
435 | struct ieee80211_vif *vif, | |
436 | struct cfg80211_scan_request *req); | |
437 | void iwl_legacy_internal_short_hw_scan(struct iwl_priv *priv); | |
dd6d2a8a | 438 | int iwl_legacy_force_reset(struct iwl_priv *priv, bool external); |
be663ab6 WYG |
439 | u16 iwl_legacy_fill_probe_req(struct iwl_priv *priv, |
440 | struct ieee80211_mgmt *frame, | |
441 | const u8 *ta, const u8 *ie, int ie_len, int left); | |
442 | void iwl_legacy_setup_rx_scan_handlers(struct iwl_priv *priv); | |
443 | u16 iwl_legacy_get_active_dwell_time(struct iwl_priv *priv, | |
444 | enum ieee80211_band band, | |
445 | u8 n_probes); | |
446 | u16 iwl_legacy_get_passive_dwell_time(struct iwl_priv *priv, | |
447 | enum ieee80211_band band, | |
448 | struct ieee80211_vif *vif); | |
449 | void iwl_legacy_setup_scan_deferred_work(struct iwl_priv *priv); | |
450 | void iwl_legacy_cancel_scan_deferred_work(struct iwl_priv *priv); | |
451 | ||
452 | /* For faster active scanning, scan will move to the next channel if fewer than | |
453 | * PLCP_QUIET_THRESH packets are heard on this channel within | |
454 | * ACTIVE_QUIET_TIME after sending probe request. This shortens the dwell | |
455 | * time if it's a quiet channel (nothing responded to our probe, and there's | |
456 | * no other traffic). | |
457 | * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */ | |
458 | #define IWL_ACTIVE_QUIET_TIME cpu_to_le16(10) /* msec */ | |
459 | #define IWL_PLCP_QUIET_THRESH cpu_to_le16(1) /* packets */ | |
460 | ||
461 | #define IWL_SCAN_CHECK_WATCHDOG (HZ * 7) | |
462 | ||
463 | /***************************************************** | |
464 | * S e n d i n g H o s t C o m m a n d s * | |
465 | *****************************************************/ | |
466 | ||
467 | const char *iwl_legacy_get_cmd_string(u8 cmd); | |
468 | int __must_check iwl_legacy_send_cmd_sync(struct iwl_priv *priv, | |
469 | struct iwl_host_cmd *cmd); | |
470 | int iwl_legacy_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd); | |
471 | int __must_check iwl_legacy_send_cmd_pdu(struct iwl_priv *priv, u8 id, | |
472 | u16 len, const void *data); | |
473 | int iwl_legacy_send_cmd_pdu_async(struct iwl_priv *priv, u8 id, u16 len, | |
474 | const void *data, | |
475 | void (*callback)(struct iwl_priv *priv, | |
476 | struct iwl_device_cmd *cmd, | |
477 | struct iwl_rx_packet *pkt)); | |
478 | ||
479 | int iwl_legacy_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd); | |
480 | ||
481 | ||
482 | /***************************************************** | |
483 | * PCI * | |
484 | *****************************************************/ | |
485 | ||
486 | static inline u16 iwl_legacy_pcie_link_ctl(struct iwl_priv *priv) | |
487 | { | |
488 | int pos; | |
489 | u16 pci_lnk_ctl; | |
490 | pos = pci_find_capability(priv->pci_dev, PCI_CAP_ID_EXP); | |
491 | pci_read_config_word(priv->pci_dev, pos + PCI_EXP_LNKCTL, &pci_lnk_ctl); | |
492 | return pci_lnk_ctl; | |
493 | } | |
494 | ||
495 | void iwl_legacy_bg_watchdog(unsigned long data); | |
496 | u32 iwl_legacy_usecs_to_beacons(struct iwl_priv *priv, | |
497 | u32 usec, u32 beacon_interval); | |
498 | __le32 iwl_legacy_add_beacon_time(struct iwl_priv *priv, u32 base, | |
499 | u32 addon, u32 beacon_interval); | |
500 | ||
501 | #ifdef CONFIG_PM | |
502 | int iwl_legacy_pci_suspend(struct device *device); | |
503 | int iwl_legacy_pci_resume(struct device *device); | |
504 | extern const struct dev_pm_ops iwl_legacy_pm_ops; | |
505 | ||
506 | #define IWL_LEGACY_PM_OPS (&iwl_legacy_pm_ops) | |
507 | ||
508 | #else /* !CONFIG_PM */ | |
509 | ||
510 | #define IWL_LEGACY_PM_OPS NULL | |
511 | ||
512 | #endif /* !CONFIG_PM */ | |
513 | ||
514 | /***************************************************** | |
515 | * Error Handling Debugging | |
516 | ******************************************************/ | |
517 | void iwl4965_dump_nic_error_log(struct iwl_priv *priv); | |
518 | int iwl4965_dump_nic_event_log(struct iwl_priv *priv, | |
519 | bool full_log, char **buf, bool display); | |
520 | #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG | |
521 | void iwl_legacy_print_rx_config_cmd(struct iwl_priv *priv, | |
522 | struct iwl_rxon_context *ctx); | |
523 | #else | |
524 | static inline void iwl_legacy_print_rx_config_cmd(struct iwl_priv *priv, | |
525 | struct iwl_rxon_context *ctx) | |
526 | { | |
527 | } | |
528 | #endif | |
529 | ||
530 | void iwl_legacy_clear_isr_stats(struct iwl_priv *priv); | |
531 | ||
532 | /***************************************************** | |
533 | * GEOS | |
534 | ******************************************************/ | |
535 | int iwl_legacy_init_geos(struct iwl_priv *priv); | |
536 | void iwl_legacy_free_geos(struct iwl_priv *priv); | |
537 | ||
538 | /*************** DRIVER STATUS FUNCTIONS *****/ | |
539 | ||
540 | #define STATUS_HCMD_ACTIVE 0 /* host command in progress */ | |
541 | /* 1 is unused (used to be STATUS_HCMD_SYNC_ACTIVE) */ | |
542 | #define STATUS_INT_ENABLED 2 | |
543 | #define STATUS_RF_KILL_HW 3 | |
544 | #define STATUS_CT_KILL 4 | |
545 | #define STATUS_INIT 5 | |
546 | #define STATUS_ALIVE 6 | |
547 | #define STATUS_READY 7 | |
548 | #define STATUS_TEMPERATURE 8 | |
549 | #define STATUS_GEO_CONFIGURED 9 | |
550 | #define STATUS_EXIT_PENDING 10 | |
551 | #define STATUS_STATISTICS 12 | |
552 | #define STATUS_SCANNING 13 | |
553 | #define STATUS_SCAN_ABORTING 14 | |
554 | #define STATUS_SCAN_HW 15 | |
555 | #define STATUS_POWER_PMI 16 | |
556 | #define STATUS_FW_ERROR 17 | |
51e65257 | 557 | #define STATUS_CHANNEL_SWITCH_PENDING 18 |
be663ab6 WYG |
558 | |
559 | static inline int iwl_legacy_is_ready(struct iwl_priv *priv) | |
560 | { | |
561 | /* The adapter is 'ready' if READY and GEO_CONFIGURED bits are | |
562 | * set but EXIT_PENDING is not */ | |
563 | return test_bit(STATUS_READY, &priv->status) && | |
564 | test_bit(STATUS_GEO_CONFIGURED, &priv->status) && | |
565 | !test_bit(STATUS_EXIT_PENDING, &priv->status); | |
566 | } | |
567 | ||
568 | static inline int iwl_legacy_is_alive(struct iwl_priv *priv) | |
569 | { | |
570 | return test_bit(STATUS_ALIVE, &priv->status); | |
571 | } | |
572 | ||
573 | static inline int iwl_legacy_is_init(struct iwl_priv *priv) | |
574 | { | |
575 | return test_bit(STATUS_INIT, &priv->status); | |
576 | } | |
577 | ||
578 | static inline int iwl_legacy_is_rfkill_hw(struct iwl_priv *priv) | |
579 | { | |
580 | return test_bit(STATUS_RF_KILL_HW, &priv->status); | |
581 | } | |
582 | ||
583 | static inline int iwl_legacy_is_rfkill(struct iwl_priv *priv) | |
584 | { | |
585 | return iwl_legacy_is_rfkill_hw(priv); | |
586 | } | |
587 | ||
588 | static inline int iwl_legacy_is_ctkill(struct iwl_priv *priv) | |
589 | { | |
590 | return test_bit(STATUS_CT_KILL, &priv->status); | |
591 | } | |
592 | ||
593 | static inline int iwl_legacy_is_ready_rf(struct iwl_priv *priv) | |
594 | { | |
595 | ||
596 | if (iwl_legacy_is_rfkill(priv)) | |
597 | return 0; | |
598 | ||
599 | return iwl_legacy_is_ready(priv); | |
600 | } | |
601 | ||
602 | extern void iwl_legacy_send_bt_config(struct iwl_priv *priv); | |
603 | extern int iwl_legacy_send_statistics_request(struct iwl_priv *priv, | |
604 | u8 flags, bool clear); | |
605 | void iwl_legacy_apm_stop(struct iwl_priv *priv); | |
606 | int iwl_legacy_apm_init(struct iwl_priv *priv); | |
607 | ||
608 | int iwl_legacy_send_rxon_timing(struct iwl_priv *priv, | |
609 | struct iwl_rxon_context *ctx); | |
610 | static inline int iwl_legacy_send_rxon_assoc(struct iwl_priv *priv, | |
611 | struct iwl_rxon_context *ctx) | |
612 | { | |
613 | return priv->cfg->ops->hcmd->rxon_assoc(priv, ctx); | |
614 | } | |
615 | static inline int iwl_legacy_commit_rxon(struct iwl_priv *priv, | |
616 | struct iwl_rxon_context *ctx) | |
617 | { | |
618 | return priv->cfg->ops->hcmd->commit_rxon(priv, ctx); | |
619 | } | |
620 | static inline const struct ieee80211_supported_band *iwl_get_hw_mode( | |
621 | struct iwl_priv *priv, enum ieee80211_band band) | |
622 | { | |
623 | return priv->hw->wiphy->bands[band]; | |
624 | } | |
625 | ||
be663ab6 WYG |
626 | /* mac80211 handlers */ |
627 | int iwl_legacy_mac_config(struct ieee80211_hw *hw, u32 changed); | |
628 | void iwl_legacy_mac_reset_tsf(struct ieee80211_hw *hw); | |
629 | void iwl_legacy_mac_bss_info_changed(struct ieee80211_hw *hw, | |
630 | struct ieee80211_vif *vif, | |
631 | struct ieee80211_bss_conf *bss_conf, | |
632 | u32 changes); | |
633 | void iwl_legacy_tx_cmd_protection(struct iwl_priv *priv, | |
634 | struct ieee80211_tx_info *info, | |
635 | __le16 fc, __le32 *tx_flags); | |
636 | ||
637 | irqreturn_t iwl_legacy_isr(int irq, void *data); | |
638 | ||
639 | #endif /* __iwl_legacy_core_h__ */ |