iwl-4965.h 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2003 - 2007 Intel Corporation. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. * The full GNU General Public License is included in this distribution in the
  19. * file called LICENSE.
  20. *
  21. * Contact Information:
  22. * James P. Ketrenos <ipw2100-admin@linux.intel.com>
  23. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  24. *
  25. *****************************************************************************/
  26. #ifndef __iwl_4965_h__
  27. #define __iwl_4965_h__
  28. #include <linux/pci.h> /* for struct pci_device_id */
  29. #include <linux/kernel.h>
  30. #include <net/ieee80211_radiotap.h>
  31. struct iwl_priv;
  32. /* Hardware specific file defines the PCI IDs table for that hardware module */
  33. extern struct pci_device_id iwl_hw_card_ids[];
  34. #define DRV_NAME "iwl4965"
  35. #include "iwl-4965-hw.h"
  36. #include "iwl-prph.h"
  37. #include "iwl-4965-debug.h"
  38. /* Default noise level to report when noise measurement is not available.
  39. * This may be because we're:
  40. * 1) Not associated (4965, no beacon statistics being sent to driver)
  41. * 2) Scanning (noise measurement does not apply to associated channel)
  42. * 3) Receiving CCK (3945 delivers noise info only for OFDM frames)
  43. * Use default noise value of -127 ... this is below the range of measurable
  44. * Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user.
  45. * Also, -127 works better than 0 when averaging frames with/without
  46. * noise info (e.g. averaging might be done in app); measured dBm values are
  47. * always negative ... using a negative value as the default keeps all
  48. * averages within an s8's (used in some apps) range of negative values. */
  49. #define IWL_NOISE_MEAS_NOT_AVAILABLE (-127)
  50. /* Module parameters accessible from iwl-*.c */
  51. extern int iwl_param_hwcrypto;
  52. extern int iwl_param_queues_num;
  53. enum iwl_antenna {
  54. IWL_ANTENNA_DIVERSITY,
  55. IWL_ANTENNA_MAIN,
  56. IWL_ANTENNA_AUX
  57. };
  58. /*
  59. * RTS threshold here is total size [2347] minus 4 FCS bytes
  60. * Per spec:
  61. * a value of 0 means RTS on all data/management packets
  62. * a value > max MSDU size means no RTS
  63. * else RTS for data/management frames where MPDU is larger
  64. * than RTS value.
  65. */
  66. #define DEFAULT_RTS_THRESHOLD 2347U
  67. #define MIN_RTS_THRESHOLD 0U
  68. #define MAX_RTS_THRESHOLD 2347U
  69. #define MAX_MSDU_SIZE 2304U
  70. #define MAX_MPDU_SIZE 2346U
  71. #define DEFAULT_BEACON_INTERVAL 100U
  72. #define DEFAULT_SHORT_RETRY_LIMIT 7U
  73. #define DEFAULT_LONG_RETRY_LIMIT 4U
  74. struct iwl_rx_mem_buffer {
  75. dma_addr_t dma_addr;
  76. struct sk_buff *skb;
  77. struct list_head list;
  78. };
  79. struct iwl_rt_rx_hdr {
  80. struct ieee80211_radiotap_header rt_hdr;
  81. __le64 rt_tsf; /* TSF */
  82. u8 rt_flags; /* radiotap packet flags */
  83. u8 rt_rate; /* rate in 500kb/s */
  84. __le16 rt_channelMHz; /* channel in MHz */
  85. __le16 rt_chbitmask; /* channel bitfield */
  86. s8 rt_dbmsignal; /* signal in dBm, kluged to signed */
  87. s8 rt_dbmnoise;
  88. u8 rt_antenna; /* antenna number */
  89. u8 payload[0]; /* payload... */
  90. } __attribute__ ((packed));
  91. struct iwl_rt_tx_hdr {
  92. struct ieee80211_radiotap_header rt_hdr;
  93. u8 rt_rate; /* rate in 500kb/s */
  94. __le16 rt_channel; /* channel in mHz */
  95. __le16 rt_chbitmask; /* channel bitfield */
  96. s8 rt_dbmsignal; /* signal in dBm, kluged to signed */
  97. u8 rt_antenna; /* antenna number */
  98. u8 payload[0]; /* payload... */
  99. } __attribute__ ((packed));
  100. /*
  101. * Generic queue structure
  102. *
  103. * Contains common data for Rx and Tx queues
  104. */
  105. struct iwl_queue {
  106. int n_bd; /* number of BDs in this queue */
  107. int write_ptr; /* 1-st empty entry (index) host_w*/
  108. int read_ptr; /* last used entry (index) host_r*/
  109. dma_addr_t dma_addr; /* physical addr for BD's */
  110. int n_window; /* safe queue window */
  111. u32 id;
  112. int low_mark; /* low watermark, resume queue if free
  113. * space more than this */
  114. int high_mark; /* high watermark, stop queue if free
  115. * space less than this */
  116. } __attribute__ ((packed));
  117. #define MAX_NUM_OF_TBS (20)
  118. struct iwl_tx_info {
  119. struct ieee80211_tx_status status;
  120. struct sk_buff *skb[MAX_NUM_OF_TBS];
  121. };
  122. /**
  123. * struct iwl_tx_queue - Tx Queue for DMA
  124. * @need_update: need to update read/write index
  125. * @shed_retry: queue is HT AGG enabled
  126. *
  127. * Queue consists of circular buffer of BD's and required locking structures.
  128. */
  129. struct iwl_tx_queue {
  130. struct iwl_queue q;
  131. struct iwl_tfd_frame *bd;
  132. struct iwl_cmd *cmd;
  133. dma_addr_t dma_addr_cmd;
  134. struct iwl_tx_info *txb;
  135. int need_update;
  136. int sched_retry;
  137. int active;
  138. };
  139. #define IWL_NUM_SCAN_RATES (2)
  140. struct iwl_channel_tgd_info {
  141. u8 type;
  142. s8 max_power;
  143. };
  144. struct iwl_channel_tgh_info {
  145. s64 last_radar_time;
  146. };
  147. /* current Tx power values to use, one for each rate for each channel.
  148. * requested power is limited by:
  149. * -- regulatory EEPROM limits for this channel
  150. * -- hardware capabilities (clip-powers)
  151. * -- spectrum management
  152. * -- user preference (e.g. iwconfig)
  153. * when requested power is set, base power index must also be set. */
  154. struct iwl_channel_power_info {
  155. struct iwl_tx_power tpc; /* actual radio and DSP gain settings */
  156. s8 power_table_index; /* actual (compenst'd) index into gain table */
  157. s8 base_power_index; /* gain index for power at factory temp. */
  158. s8 requested_power; /* power (dBm) requested for this chnl/rate */
  159. };
  160. /* current scan Tx power values to use, one for each scan rate for each
  161. * channel. */
  162. struct iwl_scan_power_info {
  163. struct iwl_tx_power tpc; /* actual radio and DSP gain settings */
  164. s8 power_table_index; /* actual (compenst'd) index into gain table */
  165. s8 requested_power; /* scan pwr (dBm) requested for chnl/rate */
  166. };
  167. /* Channel unlock period is 15 seconds. If no beacon or probe response
  168. * has been received within 15 seconds on a locked channel then the channel
  169. * remains locked. */
  170. #define TX_UNLOCK_PERIOD 15
  171. /* CSA lock period is 15 seconds. If a CSA has been received on a channel in
  172. * the last 15 seconds, the channel is locked */
  173. #define CSA_LOCK_PERIOD 15
  174. /*
  175. * One for each channel, holds all channel setup data
  176. * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant
  177. * with one another!
  178. */
  179. #define IWL4965_MAX_RATE (33)
  180. struct iwl_channel_info {
  181. struct iwl_channel_tgd_info tgd;
  182. struct iwl_channel_tgh_info tgh;
  183. struct iwl_eeprom_channel eeprom; /* EEPROM regulatory limit */
  184. struct iwl_eeprom_channel fat_eeprom; /* EEPROM regulatory limit for
  185. * FAT channel */
  186. u8 channel; /* channel number */
  187. u8 flags; /* flags copied from EEPROM */
  188. s8 max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */
  189. s8 curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) */
  190. s8 min_power; /* always 0 */
  191. s8 scan_power; /* (dBm) regul. eeprom, direct scans, any rate */
  192. u8 group_index; /* 0-4, maps channel to group1/2/3/4/5 */
  193. u8 band_index; /* 0-4, maps channel to band1/2/3/4/5 */
  194. u8 phymode; /* MODE_IEEE80211{A,B,G} */
  195. /* Radio/DSP gain settings for each "normal" data Tx rate.
  196. * These include, in addition to RF and DSP gain, a few fields for
  197. * remembering/modifying gain settings (indexes). */
  198. struct iwl_channel_power_info power_info[IWL4965_MAX_RATE];
  199. /* FAT channel info */
  200. s8 fat_max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */
  201. s8 fat_curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) */
  202. s8 fat_min_power; /* always 0 */
  203. s8 fat_scan_power; /* (dBm) eeprom, direct scans, any rate */
  204. u8 fat_flags; /* flags copied from EEPROM */
  205. u8 fat_extension_channel;
  206. /* Radio/DSP gain settings for each scan rate, for directed scans. */
  207. struct iwl_scan_power_info scan_pwr_info[IWL_NUM_SCAN_RATES];
  208. };
  209. struct iwl_clip_group {
  210. /* maximum power level to prevent clipping for each rate, derived by
  211. * us from this band's saturation power in EEPROM */
  212. const s8 clip_powers[IWL_MAX_RATES];
  213. };
  214. #include "iwl-4965-rs.h"
  215. #define IWL_TX_FIFO_AC0 0
  216. #define IWL_TX_FIFO_AC1 1
  217. #define IWL_TX_FIFO_AC2 2
  218. #define IWL_TX_FIFO_AC3 3
  219. #define IWL_TX_FIFO_HCCA_1 5
  220. #define IWL_TX_FIFO_HCCA_2 6
  221. #define IWL_TX_FIFO_NONE 7
  222. /* Minimum number of queues. MAX_NUM is defined in hw specific files */
  223. #define IWL_MIN_NUM_QUEUES 4
  224. /* Power management (not Tx power) structures */
  225. struct iwl_power_vec_entry {
  226. struct iwl_powertable_cmd cmd;
  227. u8 no_dtim;
  228. };
  229. #define IWL_POWER_RANGE_0 (0)
  230. #define IWL_POWER_RANGE_1 (1)
  231. #define IWL_POWER_MODE_CAM 0x00 /* Continuously Aware Mode, always on */
  232. #define IWL_POWER_INDEX_3 0x03
  233. #define IWL_POWER_INDEX_5 0x05
  234. #define IWL_POWER_AC 0x06
  235. #define IWL_POWER_BATTERY 0x07
  236. #define IWL_POWER_LIMIT 0x07
  237. #define IWL_POWER_MASK 0x0F
  238. #define IWL_POWER_ENABLED 0x10
  239. #define IWL_POWER_LEVEL(x) ((x) & IWL_POWER_MASK)
  240. struct iwl_power_mgr {
  241. spinlock_t lock;
  242. struct iwl_power_vec_entry pwr_range_0[IWL_POWER_AC];
  243. struct iwl_power_vec_entry pwr_range_1[IWL_POWER_AC];
  244. u8 active_index;
  245. u32 dtim_val;
  246. };
  247. #define IEEE80211_DATA_LEN 2304
  248. #define IEEE80211_4ADDR_LEN 30
  249. #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
  250. #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
  251. struct iwl_frame {
  252. union {
  253. struct ieee80211_hdr frame;
  254. struct iwl_tx_beacon_cmd beacon;
  255. u8 raw[IEEE80211_FRAME_LEN];
  256. u8 cmd[360];
  257. } u;
  258. struct list_head list;
  259. };
  260. #define SEQ_TO_QUEUE(x) ((x >> 8) & 0xbf)
  261. #define QUEUE_TO_SEQ(x) ((x & 0xbf) << 8)
  262. #define SEQ_TO_INDEX(x) (x & 0xff)
  263. #define INDEX_TO_SEQ(x) (x & 0xff)
  264. #define SEQ_HUGE_FRAME (0x4000)
  265. #define SEQ_RX_FRAME __constant_cpu_to_le16(0x8000)
  266. #define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
  267. #define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ)
  268. #define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4)
  269. enum {
  270. /* CMD_SIZE_NORMAL = 0, */
  271. CMD_SIZE_HUGE = (1 << 0),
  272. /* CMD_SYNC = 0, */
  273. CMD_ASYNC = (1 << 1),
  274. /* CMD_NO_SKB = 0, */
  275. CMD_WANT_SKB = (1 << 2),
  276. };
  277. struct iwl_cmd;
  278. struct iwl_priv;
  279. struct iwl_cmd_meta {
  280. struct iwl_cmd_meta *source;
  281. union {
  282. struct sk_buff *skb;
  283. int (*callback)(struct iwl_priv *priv,
  284. struct iwl_cmd *cmd, struct sk_buff *skb);
  285. } __attribute__ ((packed)) u;
  286. /* The CMD_SIZE_HUGE flag bit indicates that the command
  287. * structure is stored at the end of the shared queue memory. */
  288. u32 flags;
  289. } __attribute__ ((packed));
  290. struct iwl_cmd {
  291. struct iwl_cmd_meta meta;
  292. struct iwl_cmd_header hdr;
  293. union {
  294. struct iwl_addsta_cmd addsta;
  295. struct iwl_led_cmd led;
  296. u32 flags;
  297. u8 val8;
  298. u16 val16;
  299. u32 val32;
  300. struct iwl_bt_cmd bt;
  301. struct iwl_rxon_time_cmd rxon_time;
  302. struct iwl_powertable_cmd powertable;
  303. struct iwl_qosparam_cmd qosparam;
  304. struct iwl_tx_cmd tx;
  305. struct iwl_tx_beacon_cmd tx_beacon;
  306. struct iwl_rxon_assoc_cmd rxon_assoc;
  307. u8 *indirect;
  308. u8 payload[360];
  309. } __attribute__ ((packed)) cmd;
  310. } __attribute__ ((packed));
  311. struct iwl_host_cmd {
  312. u8 id;
  313. u16 len;
  314. struct iwl_cmd_meta meta;
  315. const void *data;
  316. };
  317. #define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl_cmd) - \
  318. sizeof(struct iwl_cmd_meta))
  319. /*
  320. * RX related structures and functions
  321. */
  322. #define RX_FREE_BUFFERS 64
  323. #define RX_LOW_WATERMARK 8
  324. #define SUP_RATE_11A_MAX_NUM_CHANNELS 8
  325. #define SUP_RATE_11B_MAX_NUM_CHANNELS 4
  326. #define SUP_RATE_11G_MAX_NUM_CHANNELS 12
  327. /**
  328. * struct iwl_rx_queue - Rx queue
  329. * @processed: Internal index to last handled Rx packet
  330. * @read: Shared index to newest available Rx buffer
  331. * @write: Shared index to oldest written Rx packet
  332. * @free_count: Number of pre-allocated buffers in rx_free
  333. * @rx_free: list of free SKBs for use
  334. * @rx_used: List of Rx buffers with no SKB
  335. * @need_update: flag to indicate we need to update read/write index
  336. *
  337. * NOTE: rx_free and rx_used are used as a FIFO for iwl_rx_mem_buffers
  338. */
  339. struct iwl_rx_queue {
  340. __le32 *bd;
  341. dma_addr_t dma_addr;
  342. struct iwl_rx_mem_buffer pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS];
  343. struct iwl_rx_mem_buffer *queue[RX_QUEUE_SIZE];
  344. u32 processed;
  345. u32 read;
  346. u32 write;
  347. u32 free_count;
  348. struct list_head rx_free;
  349. struct list_head rx_used;
  350. int need_update;
  351. spinlock_t lock;
  352. };
  353. #define IWL_SUPPORTED_RATES_IE_LEN 8
  354. #define SCAN_INTERVAL 100
  355. #define MAX_A_CHANNELS 252
  356. #define MIN_A_CHANNELS 7
  357. #define MAX_B_CHANNELS 14
  358. #define MIN_B_CHANNELS 1
  359. #define STATUS_HCMD_ACTIVE 0 /* host command in progress */
  360. #define STATUS_INT_ENABLED 1
  361. #define STATUS_RF_KILL_HW 2
  362. #define STATUS_RF_KILL_SW 3
  363. #define STATUS_INIT 4
  364. #define STATUS_ALIVE 5
  365. #define STATUS_READY 6
  366. #define STATUS_TEMPERATURE 7
  367. #define STATUS_GEO_CONFIGURED 8
  368. #define STATUS_EXIT_PENDING 9
  369. #define STATUS_IN_SUSPEND 10
  370. #define STATUS_STATISTICS 11
  371. #define STATUS_SCANNING 12
  372. #define STATUS_SCAN_ABORTING 13
  373. #define STATUS_SCAN_HW 14
  374. #define STATUS_POWER_PMI 15
  375. #define STATUS_FW_ERROR 16
  376. #define MAX_TID_COUNT 9
  377. #define IWL_INVALID_RATE 0xFF
  378. #define IWL_INVALID_VALUE -1
  379. #ifdef CONFIG_IWLWIFI_HT
  380. #ifdef CONFIG_IWLWIFI_HT_AGG
  381. struct iwl_ht_agg {
  382. u16 txq_id;
  383. u16 frame_count;
  384. u16 wait_for_ba;
  385. u16 start_idx;
  386. u32 bitmap0;
  387. u32 bitmap1;
  388. u32 rate_n_flags;
  389. };
  390. #endif /* CONFIG_IWLWIFI_HT_AGG */
  391. #endif /* CONFIG_IWLWIFI_HT */
  392. struct iwl_tid_data {
  393. u16 seq_number;
  394. #ifdef CONFIG_IWLWIFI_HT
  395. #ifdef CONFIG_IWLWIFI_HT_AGG
  396. struct iwl_ht_agg agg;
  397. #endif /* CONFIG_IWLWIFI_HT_AGG */
  398. #endif /* CONFIG_IWLWIFI_HT */
  399. };
  400. struct iwl_hw_key {
  401. enum ieee80211_key_alg alg;
  402. int keylen;
  403. u8 key[32];
  404. };
  405. union iwl_ht_rate_supp {
  406. u16 rates;
  407. struct {
  408. u8 siso_rate;
  409. u8 mimo_rate;
  410. };
  411. };
  412. #ifdef CONFIG_IWLWIFI_HT
  413. #define CFG_HT_RX_AMPDU_FACTOR_DEF (0x3)
  414. #define HT_IE_MAX_AMSDU_SIZE_4K (0)
  415. #define CFG_HT_MPDU_DENSITY_2USEC (0x5)
  416. #define CFG_HT_MPDU_DENSITY_DEF CFG_HT_MPDU_DENSITY_2USEC
  417. struct sta_ht_info {
  418. u8 is_ht;
  419. u16 rx_mimo_ps_mode;
  420. u16 tx_mimo_ps_mode;
  421. u16 control_channel;
  422. u8 max_amsdu_size;
  423. u8 ampdu_factor;
  424. u8 mpdu_density;
  425. u8 operating_mode;
  426. u8 supported_chan_width;
  427. u8 extension_chan_offset;
  428. u8 is_green_field;
  429. u8 sgf;
  430. u8 supp_rates[16];
  431. u8 tx_chan_width;
  432. u8 chan_width_cap;
  433. };
  434. #endif /*CONFIG_IWLWIFI_HT */
  435. #ifdef CONFIG_IWLWIFI_QOS
  436. union iwl_qos_capabity {
  437. struct {
  438. u8 edca_count:4; /* bit 0-3 */
  439. u8 q_ack:1; /* bit 4 */
  440. u8 queue_request:1; /* bit 5 */
  441. u8 txop_request:1; /* bit 6 */
  442. u8 reserved:1; /* bit 7 */
  443. } q_AP;
  444. struct {
  445. u8 acvo_APSD:1; /* bit 0 */
  446. u8 acvi_APSD:1; /* bit 1 */
  447. u8 ac_bk_APSD:1; /* bit 2 */
  448. u8 ac_be_APSD:1; /* bit 3 */
  449. u8 q_ack:1; /* bit 4 */
  450. u8 max_len:2; /* bit 5-6 */
  451. u8 more_data_ack:1; /* bit 7 */
  452. } q_STA;
  453. u8 val;
  454. };
  455. /* QoS structures */
  456. struct iwl_qos_info {
  457. int qos_enable;
  458. int qos_active;
  459. union iwl_qos_capabity qos_cap;
  460. struct iwl_qosparam_cmd def_qos_parm;
  461. };
  462. #endif /*CONFIG_IWLWIFI_QOS */
  463. #define STA_PS_STATUS_WAKE 0
  464. #define STA_PS_STATUS_SLEEP 1
  465. struct iwl_station_entry {
  466. struct iwl_addsta_cmd sta;
  467. struct iwl_tid_data tid[MAX_TID_COUNT];
  468. u8 used;
  469. u8 ps_status;
  470. struct iwl_hw_key keyinfo;
  471. };
  472. /* one for each uCode image (inst/data, boot/init/runtime) */
  473. struct fw_desc {
  474. void *v_addr; /* access by driver */
  475. dma_addr_t p_addr; /* access by card's busmaster DMA */
  476. u32 len; /* bytes */
  477. };
  478. /* uCode file layout */
  479. struct iwl_ucode {
  480. __le32 ver; /* major/minor/subminor */
  481. __le32 inst_size; /* bytes of runtime instructions */
  482. __le32 data_size; /* bytes of runtime data */
  483. __le32 init_size; /* bytes of initialization instructions */
  484. __le32 init_data_size; /* bytes of initialization data */
  485. __le32 boot_size; /* bytes of bootstrap instructions */
  486. u8 data[0]; /* data in same order as "size" elements */
  487. };
  488. #define IWL_IBSS_MAC_HASH_SIZE 32
  489. struct iwl_ibss_seq {
  490. u8 mac[ETH_ALEN];
  491. u16 seq_num;
  492. u16 frag_num;
  493. unsigned long packet_time;
  494. struct list_head list;
  495. };
  496. struct iwl_driver_hw_info {
  497. u16 max_txq_num;
  498. u16 ac_queue_count;
  499. u16 tx_cmd_len;
  500. u16 max_rxq_size;
  501. u32 rx_buffer_size;
  502. u16 max_rxq_log;
  503. u8 max_stations;
  504. u8 bcast_sta_id;
  505. void *shared_virt;
  506. dma_addr_t shared_phys;
  507. };
  508. #define STA_FLG_RTS_MIMO_PROT_MSK __constant_cpu_to_le32(1 << 17)
  509. #define STA_FLG_AGG_MPDU_8US_MSK __constant_cpu_to_le32(1 << 18)
  510. #define STA_FLG_MAX_AGG_SIZE_POS (19)
  511. #define STA_FLG_MAX_AGG_SIZE_MSK __constant_cpu_to_le32(3 << 19)
  512. #define STA_FLG_FAT_EN_MSK __constant_cpu_to_le32(1 << 21)
  513. #define STA_FLG_MIMO_DIS_MSK __constant_cpu_to_le32(1 << 22)
  514. #define STA_FLG_AGG_MPDU_DENSITY_POS (23)
  515. #define STA_FLG_AGG_MPDU_DENSITY_MSK __constant_cpu_to_le32(7 << 23)
  516. #define HT_SHORT_GI_20MHZ_ONLY (1 << 0)
  517. #define HT_SHORT_GI_40MHZ_ONLY (1 << 1)
  518. #define IWL_RX_HDR(x) ((struct iwl_rx_frame_hdr *)(\
  519. x->u.rx_frame.stats.payload + \
  520. x->u.rx_frame.stats.phy_count))
  521. #define IWL_RX_END(x) ((struct iwl_rx_frame_end *)(\
  522. IWL_RX_HDR(x)->payload + \
  523. le16_to_cpu(IWL_RX_HDR(x)->len)))
  524. #define IWL_RX_STATS(x) (&x->u.rx_frame.stats)
  525. #define IWL_RX_DATA(x) (IWL_RX_HDR(x)->payload)
  526. /******************************************************************************
  527. *
  528. * Functions implemented in iwl-base.c which are forward declared here
  529. * for use by iwl-*.c
  530. *
  531. *****************************************************************************/
  532. struct iwl_addsta_cmd;
  533. extern int iwl_send_add_station(struct iwl_priv *priv,
  534. struct iwl_addsta_cmd *sta, u8 flags);
  535. extern u8 iwl_add_station(struct iwl_priv *priv, const u8 *bssid,
  536. int is_ap, u8 flags);
  537. extern int iwl_is_network_packet(struct iwl_priv *priv,
  538. struct ieee80211_hdr *header);
  539. extern int iwl_power_init_handle(struct iwl_priv *priv);
  540. extern int iwl_eeprom_init(struct iwl_priv *priv);
  541. #ifdef CONFIG_IWLWIFI_DEBUG
  542. extern void iwl_report_frame(struct iwl_priv *priv,
  543. struct iwl_rx_packet *pkt,
  544. struct ieee80211_hdr *header, int group100);
  545. #else
  546. static inline void iwl_report_frame(struct iwl_priv *priv,
  547. struct iwl_rx_packet *pkt,
  548. struct ieee80211_hdr *header,
  549. int group100) {}
  550. #endif
  551. extern void iwl_handle_data_packet_monitor(struct iwl_priv *priv,
  552. struct iwl_rx_mem_buffer *rxb,
  553. void *data, short len,
  554. struct ieee80211_rx_status *stats,
  555. u16 phy_flags);
  556. extern int is_duplicate_packet(struct iwl_priv *priv, struct ieee80211_hdr
  557. *header);
  558. extern int iwl_rx_queue_alloc(struct iwl_priv *priv);
  559. extern void iwl_rx_queue_reset(struct iwl_priv *priv,
  560. struct iwl_rx_queue *rxq);
  561. extern int iwl_calc_db_from_ratio(int sig_ratio);
  562. extern int iwl_calc_sig_qual(int rssi_dbm, int noise_dbm);
  563. extern int iwl_tx_queue_init(struct iwl_priv *priv,
  564. struct iwl_tx_queue *txq, int count, u32 id);
  565. extern void iwl_rx_replenish(void *data);
  566. extern void iwl_tx_queue_free(struct iwl_priv *priv, struct iwl_tx_queue *txq);
  567. extern int iwl_send_cmd_pdu(struct iwl_priv *priv, u8 id, u16 len,
  568. const void *data);
  569. extern int __must_check iwl_send_cmd(struct iwl_priv *priv,
  570. struct iwl_host_cmd *cmd);
  571. extern unsigned int iwl_fill_beacon_frame(struct iwl_priv *priv,
  572. struct ieee80211_hdr *hdr,
  573. const u8 *dest, int left);
  574. extern int iwl_rx_queue_update_write_ptr(struct iwl_priv *priv,
  575. struct iwl_rx_queue *q);
  576. extern int iwl_send_statistics_request(struct iwl_priv *priv);
  577. extern void iwl_set_decrypted_flag(struct iwl_priv *priv, struct sk_buff *skb,
  578. u32 decrypt_res,
  579. struct ieee80211_rx_status *stats);
  580. extern __le16 *ieee80211_get_qos_ctrl(struct ieee80211_hdr *hdr);
  581. extern const u8 BROADCAST_ADDR[ETH_ALEN];
  582. /*
  583. * Currently used by iwl-3945-rs... look at restructuring so that it doesn't
  584. * call this... todo... fix that.
  585. */
  586. extern u8 iwl_sync_station(struct iwl_priv *priv, int sta_id,
  587. u16 tx_rate, u8 flags);
  588. /******************************************************************************
  589. *
  590. * Functions implemented in iwl-[34]*.c which are forward declared here
  591. * for use by iwl-base.c
  592. *
  593. * NOTE: The implementation of these functions are hardware specific
  594. * which is why they are in the hardware specific files (vs. iwl-base.c)
  595. *
  596. * Naming convention --
  597. * iwl_ <-- Its part of iwlwifi (should be changed to iwl_)
  598. * iwl_hw_ <-- Hardware specific (implemented in iwl-XXXX.c by all HW)
  599. * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
  600. * iwl_bg_ <-- Called from work queue context
  601. * iwl_mac_ <-- mac80211 callback
  602. *
  603. ****************************************************************************/
  604. extern void iwl_hw_rx_handler_setup(struct iwl_priv *priv);
  605. extern void iwl_hw_setup_deferred_work(struct iwl_priv *priv);
  606. extern void iwl_hw_cancel_deferred_work(struct iwl_priv *priv);
  607. extern int iwl_hw_rxq_stop(struct iwl_priv *priv);
  608. extern int iwl_hw_set_hw_setting(struct iwl_priv *priv);
  609. extern int iwl_hw_nic_init(struct iwl_priv *priv);
  610. extern int iwl_hw_nic_stop_master(struct iwl_priv *priv);
  611. extern void iwl_hw_txq_ctx_free(struct iwl_priv *priv);
  612. extern void iwl_hw_txq_ctx_stop(struct iwl_priv *priv);
  613. extern int iwl_hw_nic_reset(struct iwl_priv *priv);
  614. extern int iwl_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, void *tfd,
  615. dma_addr_t addr, u16 len);
  616. extern int iwl_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq);
  617. extern int iwl_hw_get_temperature(struct iwl_priv *priv);
  618. extern int iwl_hw_tx_queue_init(struct iwl_priv *priv,
  619. struct iwl_tx_queue *txq);
  620. extern unsigned int iwl_hw_get_beacon_cmd(struct iwl_priv *priv,
  621. struct iwl_frame *frame, u8 rate);
  622. extern int iwl_hw_get_rx_read(struct iwl_priv *priv);
  623. extern void iwl_hw_build_tx_cmd_rate(struct iwl_priv *priv,
  624. struct iwl_cmd *cmd,
  625. struct ieee80211_tx_control *ctrl,
  626. struct ieee80211_hdr *hdr,
  627. int sta_id, int tx_id);
  628. extern int iwl_hw_reg_send_txpower(struct iwl_priv *priv);
  629. extern int iwl_hw_reg_set_txpower(struct iwl_priv *priv, s8 power);
  630. extern void iwl_hw_rx_statistics(struct iwl_priv *priv,
  631. struct iwl_rx_mem_buffer *rxb);
  632. extern void iwl_disable_events(struct iwl_priv *priv);
  633. extern int iwl4965_get_temperature(const struct iwl_priv *priv);
  634. /**
  635. * iwl_hw_find_station - Find station id for a given BSSID
  636. * @bssid: MAC address of station ID to find
  637. *
  638. * NOTE: This should not be hardware specific but the code has
  639. * not yet been merged into a single common layer for managing the
  640. * station tables.
  641. */
  642. extern u8 iwl_hw_find_station(struct iwl_priv *priv, const u8 *bssid);
  643. extern int iwl_hw_channel_switch(struct iwl_priv *priv, u16 channel);
  644. extern int iwl_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index);
  645. struct iwl_priv;
  646. struct sta_ht_info;
  647. /*
  648. * Forward declare iwl-4965.c functions for iwl-base.c
  649. */
  650. extern int iwl_eeprom_acquire_semaphore(struct iwl_priv *priv);
  651. extern void iwl_eeprom_release_semaphore(struct iwl_priv *priv);
  652. extern int iwl4965_tx_queue_update_wr_ptr(struct iwl_priv *priv,
  653. struct iwl_tx_queue *txq,
  654. u16 byte_cnt);
  655. extern void iwl4965_add_station(struct iwl_priv *priv, const u8 *addr,
  656. int is_ap);
  657. extern void iwl4965_set_rxon_ht(struct iwl_priv *priv,
  658. struct sta_ht_info *ht_info);
  659. extern void iwl4965_set_rxon_chain(struct iwl_priv *priv);
  660. extern int iwl4965_tx_cmd(struct iwl_priv *priv, struct iwl_cmd *out_cmd,
  661. u8 sta_id, dma_addr_t txcmd_phys,
  662. struct ieee80211_hdr *hdr, u8 hdr_len,
  663. struct ieee80211_tx_control *ctrl, void *sta_in);
  664. extern int iwl4965_init_hw_rates(struct iwl_priv *priv,
  665. struct ieee80211_rate *rates);
  666. extern int iwl4965_alive_notify(struct iwl_priv *priv);
  667. extern void iwl4965_update_rate_scaling(struct iwl_priv *priv, u8 mode);
  668. extern void iwl4965_set_ht_add_station(struct iwl_priv *priv, u8 index);
  669. extern void iwl4965_chain_noise_reset(struct iwl_priv *priv);
  670. extern void iwl4965_init_sensitivity(struct iwl_priv *priv, u8 flags,
  671. u8 force);
  672. extern int iwl4965_set_fat_chan_info(struct iwl_priv *priv, int phymode,
  673. u16 channel,
  674. const struct iwl_eeprom_channel *eeprom_ch,
  675. u8 fat_extension_channel);
  676. extern void iwl4965_rf_kill_ct_config(struct iwl_priv *priv);
  677. #ifdef CONFIG_IWLWIFI_HT
  678. #ifdef CONFIG_IWLWIFI_HT_AGG
  679. extern int iwl_mac_ht_tx_agg_start(struct ieee80211_hw *hw, u8 *da,
  680. u16 tid, u16 *start_seq_num);
  681. extern int iwl_mac_ht_rx_agg_start(struct ieee80211_hw *hw, u8 *da,
  682. u16 tid, u16 start_seq_num);
  683. extern int iwl_mac_ht_rx_agg_stop(struct ieee80211_hw *hw, u8 *da,
  684. u16 tid, int generator);
  685. extern int iwl_mac_ht_tx_agg_stop(struct ieee80211_hw *hw, u8 *da,
  686. u16 tid, int generator);
  687. extern void iwl4965_turn_off_agg(struct iwl_priv *priv, u8 tid);
  688. #endif /* CONFIG_IWLWIFI_HT_AGG */
  689. #endif /*CONFIG_IWLWIFI_HT */
  690. /* Structures, enum, and defines specific to the 4965 */
  691. #define IWL4965_KW_SIZE 0x1000 /*4k */
  692. struct iwl_kw {
  693. dma_addr_t dma_addr;
  694. void *v_addr;
  695. size_t size;
  696. };
  697. #define TID_QUEUE_CELL_SPACING 50 /*mS */
  698. #define TID_QUEUE_MAX_SIZE 20
  699. #define TID_ROUND_VALUE 5 /* mS */
  700. #define TID_MAX_LOAD_COUNT 8
  701. #define TID_MAX_TIME_DIFF ((TID_QUEUE_MAX_SIZE - 1) * TID_QUEUE_CELL_SPACING)
  702. #define TIME_WRAP_AROUND(x, y) (((y) > (x)) ? (y) - (x) : (0-(x)) + (y))
  703. #define TID_ALL_ENABLED 0x7f
  704. #define TID_ALL_SPECIFIED 0xff
  705. #define TID_AGG_TPT_THREHOLD 0x0
  706. #define IWL_CHANNEL_WIDTH_20MHZ 0
  707. #define IWL_CHANNEL_WIDTH_40MHZ 1
  708. #define IWL_MIMO_PS_STATIC 0
  709. #define IWL_MIMO_PS_NONE 3
  710. #define IWL_MIMO_PS_DYNAMIC 1
  711. #define IWL_MIMO_PS_INVALID 2
  712. #define IWL_OPERATION_MODE_AUTO 0
  713. #define IWL_OPERATION_MODE_HT_ONLY 1
  714. #define IWL_OPERATION_MODE_MIXED 2
  715. #define IWL_OPERATION_MODE_20MHZ 3
  716. #define IWL_EXT_CHANNEL_OFFSET_AUTO 0
  717. #define IWL_EXT_CHANNEL_OFFSET_ABOVE 1
  718. #define IWL_EXT_CHANNEL_OFFSET_ 2
  719. #define IWL_EXT_CHANNEL_OFFSET_BELOW 3
  720. #define IWL_EXT_CHANNEL_OFFSET_MAX 4
  721. #define NRG_NUM_PREV_STAT_L 20
  722. #define NUM_RX_CHAINS (3)
  723. #define TX_POWER_IWL_ILLEGAL_VDET -100000
  724. #define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000
  725. #define TX_POWER_IWL_CLOSED_LOOP_MIN_POWER 18
  726. #define TX_POWER_IWL_CLOSED_LOOP_MAX_POWER 34
  727. #define TX_POWER_IWL_VDET_SLOPE_BELOW_NOMINAL 17
  728. #define TX_POWER_IWL_VDET_SLOPE_ABOVE_NOMINAL 20
  729. #define TX_POWER_IWL_NOMINAL_POWER 26
  730. #define TX_POWER_IWL_CLOSED_LOOP_ITERATION_LIMIT 1
  731. #define TX_POWER_IWL_VOLTAGE_CODES_PER_03V 7
  732. #define TX_POWER_IWL_DEGREES_PER_VDET_CODE 11
  733. #define IWL_TX_POWER_MAX_NUM_PA_MEASUREMENTS 1
  734. #define IWL_TX_POWER_CCK_COMPENSATION_B_STEP (9)
  735. #define IWL_TX_POWER_CCK_COMPENSATION_C_STEP (5)
  736. struct iwl_traffic_load {
  737. unsigned long time_stamp;
  738. u32 packet_count[TID_QUEUE_MAX_SIZE];
  739. u8 queue_count;
  740. u8 head;
  741. u32 total;
  742. };
  743. #ifdef CONFIG_IWLWIFI_HT_AGG
  744. struct iwl_agg_control {
  745. unsigned long next_retry;
  746. u32 wait_for_agg_status;
  747. u32 tid_retry;
  748. u32 requested_ba;
  749. u32 granted_ba;
  750. u8 auto_agg;
  751. u32 tid_traffic_load_threshold;
  752. u32 ba_timeout;
  753. struct iwl_traffic_load traffic_load[TID_MAX_LOAD_COUNT];
  754. };
  755. #endif /*CONFIG_IWLWIFI_HT_AGG */
  756. struct iwl_lq_mngr {
  757. #ifdef CONFIG_IWLWIFI_HT_AGG
  758. struct iwl_agg_control agg_ctrl;
  759. #endif
  760. spinlock_t lock;
  761. s32 max_window_size;
  762. s32 *expected_tpt;
  763. u8 *next_higher_rate;
  764. u8 *next_lower_rate;
  765. unsigned long stamp;
  766. unsigned long stamp_last;
  767. u32 flush_time;
  768. u32 tx_packets;
  769. u8 lq_ready;
  770. };
  771. /* Sensitivity and chain noise calibration */
  772. #define INTERFERENCE_DATA_AVAILABLE __constant_cpu_to_le32(1)
  773. #define INITIALIZATION_VALUE 0xFFFF
  774. #define CAL_NUM_OF_BEACONS 20
  775. #define MAXIMUM_ALLOWED_PATHLOSS 15
  776. /* Param table within SENSITIVITY_CMD */
  777. #define HD_MIN_ENERGY_CCK_DET_INDEX (0)
  778. #define HD_MIN_ENERGY_OFDM_DET_INDEX (1)
  779. #define HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX (2)
  780. #define HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX (3)
  781. #define HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX (4)
  782. #define HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX (5)
  783. #define HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX (6)
  784. #define HD_BARKER_CORR_TH_ADD_MIN_INDEX (7)
  785. #define HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX (8)
  786. #define HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX (9)
  787. #define HD_OFDM_ENERGY_TH_IN_INDEX (10)
  788. #define SENSITIVITY_CMD_CONTROL_DEFAULT_TABLE __constant_cpu_to_le16(0)
  789. #define SENSITIVITY_CMD_CONTROL_WORK_TABLE __constant_cpu_to_le16(1)
  790. #define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3
  791. #define MAX_FA_OFDM 50
  792. #define MIN_FA_OFDM 5
  793. #define MAX_FA_CCK 50
  794. #define MIN_FA_CCK 5
  795. #define NRG_MIN_CCK 97
  796. #define NRG_MAX_CCK 0
  797. #define AUTO_CORR_MIN_OFDM 85
  798. #define AUTO_CORR_MIN_OFDM_MRC 170
  799. #define AUTO_CORR_MIN_OFDM_X1 105
  800. #define AUTO_CORR_MIN_OFDM_MRC_X1 220
  801. #define AUTO_CORR_MAX_OFDM 120
  802. #define AUTO_CORR_MAX_OFDM_MRC 210
  803. #define AUTO_CORR_MAX_OFDM_X1 140
  804. #define AUTO_CORR_MAX_OFDM_MRC_X1 270
  805. #define AUTO_CORR_STEP_OFDM 1
  806. #define AUTO_CORR_MIN_CCK (125)
  807. #define AUTO_CORR_MAX_CCK (200)
  808. #define AUTO_CORR_MIN_CCK_MRC 200
  809. #define AUTO_CORR_MAX_CCK_MRC 400
  810. #define AUTO_CORR_STEP_CCK 3
  811. #define AUTO_CORR_MAX_TH_CCK 160
  812. #define NRG_ALG 0
  813. #define AUTO_CORR_ALG 1
  814. #define NRG_DIFF 2
  815. #define NRG_STEP_CCK 2
  816. #define NRG_MARGIN 8
  817. #define MAX_NUMBER_CCK_NO_FA 100
  818. #define AUTO_CORR_CCK_MIN_VAL_DEF (125)
  819. #define CHAIN_A 0
  820. #define CHAIN_B 1
  821. #define CHAIN_C 2
  822. #define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4
  823. #define ALL_BAND_FILTER 0xFF00
  824. #define IN_BAND_FILTER 0xFF
  825. #define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF
  826. enum iwl_false_alarm_state {
  827. IWL_FA_TOO_MANY = 0,
  828. IWL_FA_TOO_FEW = 1,
  829. IWL_FA_GOOD_RANGE = 2,
  830. };
  831. enum iwl_chain_noise_state {
  832. IWL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */
  833. IWL_CHAIN_NOISE_ACCUMULATE = 1,
  834. IWL_CHAIN_NOISE_CALIBRATED = 2,
  835. };
  836. enum iwl_sensitivity_state {
  837. IWL_SENS_CALIB_ALLOWED = 0,
  838. IWL_SENS_CALIB_NEED_REINIT = 1,
  839. };
  840. enum iwl_calib_enabled_state {
  841. IWL_CALIB_DISABLED = 0, /* must be 0 */
  842. IWL_CALIB_ENABLED = 1,
  843. };
  844. struct statistics_general_data {
  845. u32 beacon_silence_rssi_a;
  846. u32 beacon_silence_rssi_b;
  847. u32 beacon_silence_rssi_c;
  848. u32 beacon_energy_a;
  849. u32 beacon_energy_b;
  850. u32 beacon_energy_c;
  851. };
  852. /* Sensitivity calib data */
  853. struct iwl_sensitivity_data {
  854. u32 auto_corr_ofdm;
  855. u32 auto_corr_ofdm_mrc;
  856. u32 auto_corr_ofdm_x1;
  857. u32 auto_corr_ofdm_mrc_x1;
  858. u32 auto_corr_cck;
  859. u32 auto_corr_cck_mrc;
  860. u32 last_bad_plcp_cnt_ofdm;
  861. u32 last_fa_cnt_ofdm;
  862. u32 last_bad_plcp_cnt_cck;
  863. u32 last_fa_cnt_cck;
  864. u32 nrg_curr_state;
  865. u32 nrg_prev_state;
  866. u32 nrg_value[10];
  867. u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L];
  868. u32 nrg_silence_ref;
  869. u32 nrg_energy_idx;
  870. u32 nrg_silence_idx;
  871. u32 nrg_th_cck;
  872. s32 nrg_auto_corr_silence_diff;
  873. u32 num_in_cck_no_fa;
  874. u32 nrg_th_ofdm;
  875. u8 state;
  876. };
  877. /* Chain noise (differential Rx gain) calib data */
  878. struct iwl_chain_noise_data {
  879. u8 state;
  880. u16 beacon_count;
  881. u32 chain_noise_a;
  882. u32 chain_noise_b;
  883. u32 chain_noise_c;
  884. u32 chain_signal_a;
  885. u32 chain_signal_b;
  886. u32 chain_signal_c;
  887. u8 disconn_array[NUM_RX_CHAINS];
  888. u8 delta_gain_code[NUM_RX_CHAINS];
  889. u8 radio_write;
  890. };
  891. /* IWL4965 */
  892. #define RATE_MCS_CODE_MSK 0x7
  893. #define RATE_MCS_MIMO_POS 3
  894. #define RATE_MCS_MIMO_MSK 0x8
  895. #define RATE_MCS_HT_DUP_POS 5
  896. #define RATE_MCS_HT_DUP_MSK 0x20
  897. #define RATE_MCS_FLAGS_POS 8
  898. #define RATE_MCS_HT_POS 8
  899. #define RATE_MCS_HT_MSK 0x100
  900. #define RATE_MCS_CCK_POS 9
  901. #define RATE_MCS_CCK_MSK 0x200
  902. #define RATE_MCS_GF_POS 10
  903. #define RATE_MCS_GF_MSK 0x400
  904. #define RATE_MCS_FAT_POS 11
  905. #define RATE_MCS_FAT_MSK 0x800
  906. #define RATE_MCS_DUP_POS 12
  907. #define RATE_MCS_DUP_MSK 0x1000
  908. #define RATE_MCS_SGI_POS 13
  909. #define RATE_MCS_SGI_MSK 0x2000
  910. #define EEPROM_SEM_TIMEOUT 10
  911. #define EEPROM_SEM_RETRY_LIMIT 1000
  912. #ifdef CONFIG_IWLWIFI_SPECTRUM_MEASUREMENT
  913. enum {
  914. MEASUREMENT_READY = (1 << 0),
  915. MEASUREMENT_ACTIVE = (1 << 1),
  916. };
  917. #endif
  918. struct iwl_priv {
  919. /* ieee device used by generic ieee processing code */
  920. struct ieee80211_hw *hw;
  921. struct ieee80211_channel *ieee_channels;
  922. struct ieee80211_rate *ieee_rates;
  923. /* temporary frame storage list */
  924. struct list_head free_frames;
  925. int frames_count;
  926. u8 phymode;
  927. int alloc_rxb_skb;
  928. void (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv,
  929. struct iwl_rx_mem_buffer *rxb);
  930. const struct ieee80211_hw_mode *modes;
  931. #ifdef CONFIG_IWLWIFI_SPECTRUM_MEASUREMENT
  932. /* spectrum measurement report caching */
  933. struct iwl_spectrum_notification measure_report;
  934. u8 measurement_status;
  935. #endif
  936. /* ucode beacon time */
  937. u32 ucode_beacon_time;
  938. /* we allocate array of iwl_channel_info for NIC's valid channels.
  939. * Access via channel # using indirect index array */
  940. struct iwl_channel_info *channel_info; /* channel info array */
  941. u8 channel_count; /* # of channels */
  942. /* each calibration channel group in the EEPROM has a derived
  943. * clip setting for each rate. */
  944. const struct iwl_clip_group clip_groups[5];
  945. /* thermal calibration */
  946. s32 temperature; /* degrees Kelvin */
  947. s32 last_temperature;
  948. /* Scan related variables */
  949. unsigned long last_scan_jiffies;
  950. unsigned long scan_start;
  951. unsigned long scan_pass_start;
  952. unsigned long scan_start_tsf;
  953. int scan_bands;
  954. int one_direct_scan;
  955. u8 direct_ssid_len;
  956. u8 direct_ssid[IW_ESSID_MAX_SIZE];
  957. struct iwl_scan_cmd *scan;
  958. u8 only_active_channel;
  959. /* spinlock */
  960. spinlock_t lock; /* protect general shared data */
  961. spinlock_t hcmd_lock; /* protect hcmd */
  962. struct mutex mutex;
  963. /* basic pci-network driver stuff */
  964. struct pci_dev *pci_dev;
  965. /* pci hardware address support */
  966. void __iomem *hw_base;
  967. /* uCode images, save to reload in case of failure */
  968. struct fw_desc ucode_code; /* runtime inst */
  969. struct fw_desc ucode_data; /* runtime data original */
  970. struct fw_desc ucode_data_backup; /* runtime data save/restore */
  971. struct fw_desc ucode_init; /* initialization inst */
  972. struct fw_desc ucode_init_data; /* initialization data */
  973. struct fw_desc ucode_boot; /* bootstrap inst */
  974. struct iwl_rxon_time_cmd rxon_timing;
  975. /* We declare this const so it can only be
  976. * changed via explicit cast within the
  977. * routines that actually update the physical
  978. * hardware */
  979. const struct iwl_rxon_cmd active_rxon;
  980. struct iwl_rxon_cmd staging_rxon;
  981. int error_recovering;
  982. struct iwl_rxon_cmd recovery_rxon;
  983. /* 1st responses from initialize and runtime uCode images.
  984. * 4965's initialize alive response contains some calibration data. */
  985. struct iwl_init_alive_resp card_alive_init;
  986. struct iwl_alive_resp card_alive;
  987. #ifdef LED
  988. /* LED related variables */
  989. struct iwl_activity_blink activity;
  990. unsigned long led_packets;
  991. int led_state;
  992. #endif
  993. u16 active_rate;
  994. u16 active_rate_basic;
  995. u8 call_post_assoc_from_beacon;
  996. u8 assoc_station_added;
  997. u8 use_ant_b_for_management_frame; /* Tx antenna selection */
  998. /* HT variables */
  999. u8 is_dup;
  1000. u8 is_ht_enabled;
  1001. u8 channel_width; /* 0=20MHZ, 1=40MHZ */
  1002. u8 current_channel_width;
  1003. u8 valid_antenna; /* Bit mask of antennas actually connected */
  1004. #ifdef CONFIG_IWLWIFI_SENSITIVITY
  1005. struct iwl_sensitivity_data sensitivity_data;
  1006. struct iwl_chain_noise_data chain_noise_data;
  1007. u8 start_calib;
  1008. __le16 sensitivity_tbl[HD_TABLE_SIZE];
  1009. #endif /*CONFIG_IWLWIFI_SENSITIVITY*/
  1010. #ifdef CONFIG_IWLWIFI_HT
  1011. struct sta_ht_info current_assoc_ht;
  1012. #endif
  1013. u8 active_rate_ht[2];
  1014. u8 last_phy_res[100];
  1015. /* Rate scaling data */
  1016. struct iwl_lq_mngr lq_mngr;
  1017. /* Rate scaling data */
  1018. s8 data_retry_limit;
  1019. u8 retry_rate;
  1020. wait_queue_head_t wait_command_queue;
  1021. int activity_timer_active;
  1022. /* Rx and Tx DMA processing queues */
  1023. struct iwl_rx_queue rxq;
  1024. struct iwl_tx_queue txq[IWL_MAX_NUM_QUEUES];
  1025. unsigned long txq_ctx_active_msk;
  1026. struct iwl_kw kw; /* keep warm address */
  1027. u32 scd_base_addr; /* scheduler sram base address */
  1028. unsigned long status;
  1029. u32 config;
  1030. int last_rx_rssi; /* From Rx packet statisitics */
  1031. int last_rx_noise; /* From beacon statistics */
  1032. struct iwl_power_mgr power_data;
  1033. struct iwl_notif_statistics statistics;
  1034. unsigned long last_statistics_time;
  1035. /* context information */
  1036. u8 essid[IW_ESSID_MAX_SIZE];
  1037. u8 essid_len;
  1038. u16 rates_mask;
  1039. u32 power_mode;
  1040. u32 antenna;
  1041. u8 bssid[ETH_ALEN];
  1042. u16 rts_threshold;
  1043. u8 mac_addr[ETH_ALEN];
  1044. /*station table variables */
  1045. spinlock_t sta_lock;
  1046. int num_stations;
  1047. struct iwl_station_entry stations[IWL_STATION_COUNT];
  1048. /* Indication if ieee80211_ops->open has been called */
  1049. int is_open;
  1050. u8 mac80211_registered;
  1051. int is_abg;
  1052. u32 notif_missed_beacons;
  1053. /* Rx'd packet timing information */
  1054. u32 last_beacon_time;
  1055. u64 last_tsf;
  1056. /* Duplicate packet detection */
  1057. u16 last_seq_num;
  1058. u16 last_frag_num;
  1059. unsigned long last_packet_time;
  1060. struct list_head ibss_mac_hash[IWL_IBSS_MAC_HASH_SIZE];
  1061. /* eeprom */
  1062. struct iwl_eeprom eeprom;
  1063. int iw_mode;
  1064. struct sk_buff *ibss_beacon;
  1065. /* Last Rx'd beacon timestamp */
  1066. u32 timestamp0;
  1067. u32 timestamp1;
  1068. u16 beacon_int;
  1069. struct iwl_driver_hw_info hw_setting;
  1070. int interface_id;
  1071. /* Current association information needed to configure the
  1072. * hardware */
  1073. u16 assoc_id;
  1074. u16 assoc_capability;
  1075. u8 ps_mode;
  1076. #ifdef CONFIG_IWLWIFI_QOS
  1077. struct iwl_qos_info qos_data;
  1078. #endif /*CONFIG_IWLWIFI_QOS */
  1079. struct workqueue_struct *workqueue;
  1080. struct work_struct up;
  1081. struct work_struct restart;
  1082. struct work_struct calibrated_work;
  1083. struct work_struct scan_completed;
  1084. struct work_struct rx_replenish;
  1085. struct work_struct rf_kill;
  1086. struct work_struct abort_scan;
  1087. struct work_struct update_link_led;
  1088. struct work_struct auth_work;
  1089. struct work_struct report_work;
  1090. struct work_struct request_scan;
  1091. struct work_struct beacon_update;
  1092. struct tasklet_struct irq_tasklet;
  1093. struct delayed_work init_alive_start;
  1094. struct delayed_work alive_start;
  1095. struct delayed_work activity_timer;
  1096. struct delayed_work thermal_periodic;
  1097. struct delayed_work gather_stats;
  1098. struct delayed_work scan_check;
  1099. struct delayed_work post_associate;
  1100. #define IWL_DEFAULT_TX_POWER 0x0F
  1101. s8 user_txpower_limit;
  1102. s8 max_channel_txpower_limit;
  1103. #ifdef CONFIG_PM
  1104. u32 pm_state[16];
  1105. #endif
  1106. #ifdef CONFIG_IWLWIFI_DEBUG
  1107. /* debugging info */
  1108. u32 framecnt_to_us;
  1109. atomic_t restrict_refcnt;
  1110. #endif
  1111. struct work_struct txpower_work;
  1112. #ifdef CONFIG_IWLWIFI_SENSITIVITY
  1113. struct work_struct sensitivity_work;
  1114. #endif
  1115. struct work_struct statistics_work;
  1116. struct timer_list statistics_periodic;
  1117. #ifdef CONFIG_IWLWIFI_HT_AGG
  1118. struct work_struct agg_work;
  1119. #endif
  1120. }; /*iwl_priv */
  1121. static inline int iwl_is_associated(struct iwl_priv *priv)
  1122. {
  1123. return (priv->active_rxon.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
  1124. }
  1125. static inline int is_channel_valid(const struct iwl_channel_info *ch_info)
  1126. {
  1127. if (ch_info == NULL)
  1128. return 0;
  1129. return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0;
  1130. }
  1131. static inline int is_channel_narrow(const struct iwl_channel_info *ch_info)
  1132. {
  1133. return (ch_info->flags & EEPROM_CHANNEL_NARROW) ? 1 : 0;
  1134. }
  1135. static inline int is_channel_radar(const struct iwl_channel_info *ch_info)
  1136. {
  1137. return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0;
  1138. }
  1139. static inline u8 is_channel_a_band(const struct iwl_channel_info *ch_info)
  1140. {
  1141. return ch_info->phymode == MODE_IEEE80211A;
  1142. }
  1143. static inline u8 is_channel_bg_band(const struct iwl_channel_info *ch_info)
  1144. {
  1145. return ((ch_info->phymode == MODE_IEEE80211B) ||
  1146. (ch_info->phymode == MODE_IEEE80211G));
  1147. }
  1148. static inline int is_channel_passive(const struct iwl_channel_info *ch)
  1149. {
  1150. return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0;
  1151. }
  1152. static inline int is_channel_ibss(const struct iwl_channel_info *ch)
  1153. {
  1154. return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0;
  1155. }
  1156. extern const struct iwl_channel_info *iwl_get_channel_info(
  1157. const struct iwl_priv *priv, int phymode, u16 channel);
  1158. /* Requires full declaration of iwl_priv before including */
  1159. #include "iwl-4965-io.h"
  1160. #endif /* __iwl_4965_h__ */