iwl-dev.h 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2003 - 2009 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. * Intel Linux Wireless <ilw@linux.intel.com>
  23. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  24. *
  25. *****************************************************************************/
  26. /*
  27. * Please use this file (iwl-dev.h) for driver implementation definitions.
  28. * Please use iwl-commands.h for uCode API definitions.
  29. * Please use iwl-4965-hw.h for hardware-related definitions.
  30. */
  31. #ifndef __iwl_dev_h__
  32. #define __iwl_dev_h__
  33. #include <linux/pci.h> /* for struct pci_device_id */
  34. #include <linux/kernel.h>
  35. #include <net/ieee80211_radiotap.h>
  36. #include "iwl-eeprom.h"
  37. #include "iwl-csr.h"
  38. #include "iwl-prph.h"
  39. #include "iwl-fh.h"
  40. #include "iwl-debug.h"
  41. #include "iwl-4965-hw.h"
  42. #include "iwl-3945-hw.h"
  43. #include "iwl-led.h"
  44. #include "iwl-power.h"
  45. #include "iwl-agn-rs.h"
  46. /* configuration for the iwl4965 */
  47. extern struct iwl_cfg iwl4965_agn_cfg;
  48. extern struct iwl_cfg iwl5300_agn_cfg;
  49. extern struct iwl_cfg iwl5100_agn_cfg;
  50. extern struct iwl_cfg iwl5350_agn_cfg;
  51. extern struct iwl_cfg iwl5100_bg_cfg;
  52. extern struct iwl_cfg iwl5100_abg_cfg;
  53. extern struct iwl_cfg iwl5150_agn_cfg;
  54. extern struct iwl_cfg iwl6000h_2agn_cfg;
  55. extern struct iwl_cfg iwl6000h_2abg_cfg;
  56. extern struct iwl_cfg iwl6000h_2bg_cfg;
  57. extern struct iwl_cfg iwl6000i_2agn_cfg;
  58. extern struct iwl_cfg iwl6000i_2abg_cfg;
  59. extern struct iwl_cfg iwl6000i_2bg_cfg;
  60. extern struct iwl_cfg iwl6000_3agn_cfg;
  61. extern struct iwl_cfg iwl6050_2agn_cfg;
  62. extern struct iwl_cfg iwl6050_2abg_cfg;
  63. extern struct iwl_cfg iwl6050_3agn_cfg;
  64. extern struct iwl_cfg iwl1000_bgn_cfg;
  65. extern struct iwl_cfg iwl1000_bg_cfg;
  66. struct iwl_tx_queue;
  67. /* shared structures from iwl-5000.c */
  68. extern struct iwl_mod_params iwl50_mod_params;
  69. extern struct iwl_ucode_ops iwl5000_ucode;
  70. extern struct iwl_lib_ops iwl5000_lib;
  71. extern struct iwl_hcmd_ops iwl5000_hcmd;
  72. extern struct iwl_hcmd_utils_ops iwl5000_hcmd_utils;
  73. /* shared functions from iwl-5000.c */
  74. extern u16 iwl5000_get_hcmd_size(u8 cmd_id, u16 len);
  75. extern u16 iwl5000_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd,
  76. u8 *data);
  77. extern void iwl5000_rts_tx_cmd_flag(struct ieee80211_tx_info *info,
  78. __le32 *tx_flags);
  79. extern int iwl5000_calc_rssi(struct iwl_priv *priv,
  80. struct iwl_rx_phy_res *rx_resp);
  81. extern int iwl5000_apm_init(struct iwl_priv *priv);
  82. extern void iwl5000_apm_stop(struct iwl_priv *priv);
  83. extern int iwl5000_apm_reset(struct iwl_priv *priv);
  84. extern void iwl5000_nic_config(struct iwl_priv *priv);
  85. extern u16 iwl5000_eeprom_calib_version(struct iwl_priv *priv);
  86. extern const u8 *iwl5000_eeprom_query_addr(const struct iwl_priv *priv,
  87. size_t offset);
  88. extern void iwl5000_txq_update_byte_cnt_tbl(struct iwl_priv *priv,
  89. struct iwl_tx_queue *txq,
  90. u16 byte_cnt);
  91. extern void iwl5000_txq_inval_byte_cnt_tbl(struct iwl_priv *priv,
  92. struct iwl_tx_queue *txq);
  93. extern int iwl5000_load_ucode(struct iwl_priv *priv);
  94. extern void iwl5000_init_alive_start(struct iwl_priv *priv);
  95. extern int iwl5000_alive_notify(struct iwl_priv *priv);
  96. extern int iwl5000_hw_set_hw_params(struct iwl_priv *priv);
  97. extern int iwl5000_txq_agg_enable(struct iwl_priv *priv, int txq_id,
  98. int tx_fifo, int sta_id, int tid, u16 ssn_idx);
  99. extern int iwl5000_txq_agg_disable(struct iwl_priv *priv, u16 txq_id,
  100. u16 ssn_idx, u8 tx_fifo);
  101. extern void iwl5000_txq_set_sched(struct iwl_priv *priv, u32 mask);
  102. extern void iwl5000_setup_deferred_work(struct iwl_priv *priv);
  103. extern void iwl5000_rx_handler_setup(struct iwl_priv *priv);
  104. extern int iwl5000_hw_valid_rtc_data_addr(u32 addr);
  105. extern int iwl5000_send_tx_power(struct iwl_priv *priv);
  106. extern void iwl5000_temperature(struct iwl_priv *priv);
  107. /* CT-KILL constants */
  108. #define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */
  109. #define CT_KILL_THRESHOLD 114 /* in Celsius */
  110. #define CT_KILL_EXIT_THRESHOLD 95 /* in Celsius */
  111. /* Default noise level to report when noise measurement is not available.
  112. * This may be because we're:
  113. * 1) Not associated (4965, no beacon statistics being sent to driver)
  114. * 2) Scanning (noise measurement does not apply to associated channel)
  115. * 3) Receiving CCK (3945 delivers noise info only for OFDM frames)
  116. * Use default noise value of -127 ... this is below the range of measurable
  117. * Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user.
  118. * Also, -127 works better than 0 when averaging frames with/without
  119. * noise info (e.g. averaging might be done in app); measured dBm values are
  120. * always negative ... using a negative value as the default keeps all
  121. * averages within an s8's (used in some apps) range of negative values. */
  122. #define IWL_NOISE_MEAS_NOT_AVAILABLE (-127)
  123. /*
  124. * RTS threshold here is total size [2347] minus 4 FCS bytes
  125. * Per spec:
  126. * a value of 0 means RTS on all data/management packets
  127. * a value > max MSDU size means no RTS
  128. * else RTS for data/management frames where MPDU is larger
  129. * than RTS value.
  130. */
  131. #define DEFAULT_RTS_THRESHOLD 2347U
  132. #define MIN_RTS_THRESHOLD 0U
  133. #define MAX_RTS_THRESHOLD 2347U
  134. #define MAX_MSDU_SIZE 2304U
  135. #define MAX_MPDU_SIZE 2346U
  136. #define DEFAULT_BEACON_INTERVAL 100U
  137. #define DEFAULT_SHORT_RETRY_LIMIT 7U
  138. #define DEFAULT_LONG_RETRY_LIMIT 4U
  139. struct iwl_rx_mem_buffer {
  140. dma_addr_t real_dma_addr;
  141. dma_addr_t aligned_dma_addr;
  142. struct sk_buff *skb;
  143. struct list_head list;
  144. };
  145. /* defined below */
  146. struct iwl_device_cmd;
  147. struct iwl_cmd_meta {
  148. /* only for SYNC commands, iff the reply skb is wanted */
  149. struct iwl_host_cmd *source;
  150. /*
  151. * only for ASYNC commands
  152. * (which is somewhat stupid -- look at iwl-sta.c for instance
  153. * which duplicates a bunch of code because the callback isn't
  154. * invoked for SYNC commands, if it were and its result passed
  155. * through it would be simpler...)
  156. */
  157. void (*callback)(struct iwl_priv *priv,
  158. struct iwl_device_cmd *cmd,
  159. struct sk_buff *skb);
  160. /* The CMD_SIZE_HUGE flag bit indicates that the command
  161. * structure is stored at the end of the shared queue memory. */
  162. u32 flags;
  163. DECLARE_PCI_UNMAP_ADDR(mapping)
  164. DECLARE_PCI_UNMAP_LEN(len)
  165. };
  166. /*
  167. * Generic queue structure
  168. *
  169. * Contains common data for Rx and Tx queues
  170. */
  171. struct iwl_queue {
  172. int n_bd; /* number of BDs in this queue */
  173. int write_ptr; /* 1-st empty entry (index) host_w*/
  174. int read_ptr; /* last used entry (index) host_r*/
  175. dma_addr_t dma_addr; /* physical addr for BD's */
  176. int n_window; /* safe queue window */
  177. u32 id;
  178. int low_mark; /* low watermark, resume queue if free
  179. * space more than this */
  180. int high_mark; /* high watermark, stop queue if free
  181. * space less than this */
  182. } __attribute__ ((packed));
  183. /* One for each TFD */
  184. struct iwl_tx_info {
  185. struct sk_buff *skb[IWL_NUM_OF_TBS - 1];
  186. };
  187. /**
  188. * struct iwl_tx_queue - Tx Queue for DMA
  189. * @q: generic Rx/Tx queue descriptor
  190. * @bd: base of circular buffer of TFDs
  191. * @cmd: array of command/TX buffer pointers
  192. * @meta: array of meta data for each command/tx buffer
  193. * @dma_addr_cmd: physical address of cmd/tx buffer array
  194. * @txb: array of per-TFD driver data
  195. * @need_update: indicates need to update read/write index
  196. * @sched_retry: indicates queue is high-throughput aggregation (HT AGG) enabled
  197. *
  198. * A Tx queue consists of circular buffer of BDs (a.k.a. TFDs, transmit frame
  199. * descriptors) and required locking structures.
  200. */
  201. #define TFD_TX_CMD_SLOTS 256
  202. #define TFD_CMD_SLOTS 32
  203. struct iwl_tx_queue {
  204. struct iwl_queue q;
  205. void *tfds;
  206. struct iwl_device_cmd **cmd;
  207. struct iwl_cmd_meta *meta;
  208. struct iwl_tx_info *txb;
  209. u8 need_update;
  210. u8 sched_retry;
  211. u8 active;
  212. u8 swq_id;
  213. };
  214. #define IWL_NUM_SCAN_RATES (2)
  215. struct iwl4965_channel_tgd_info {
  216. u8 type;
  217. s8 max_power;
  218. };
  219. struct iwl4965_channel_tgh_info {
  220. s64 last_radar_time;
  221. };
  222. #define IWL4965_MAX_RATE (33)
  223. struct iwl3945_clip_group {
  224. /* maximum power level to prevent clipping for each rate, derived by
  225. * us from this band's saturation power in EEPROM */
  226. const s8 clip_powers[IWL_MAX_RATES];
  227. };
  228. /* current Tx power values to use, one for each rate for each channel.
  229. * requested power is limited by:
  230. * -- regulatory EEPROM limits for this channel
  231. * -- hardware capabilities (clip-powers)
  232. * -- spectrum management
  233. * -- user preference (e.g. iwconfig)
  234. * when requested power is set, base power index must also be set. */
  235. struct iwl3945_channel_power_info {
  236. struct iwl3945_tx_power tpc; /* actual radio and DSP gain settings */
  237. s8 power_table_index; /* actual (compenst'd) index into gain table */
  238. s8 base_power_index; /* gain index for power at factory temp. */
  239. s8 requested_power; /* power (dBm) requested for this chnl/rate */
  240. };
  241. /* current scan Tx power values to use, one for each scan rate for each
  242. * channel. */
  243. struct iwl3945_scan_power_info {
  244. struct iwl3945_tx_power tpc; /* actual radio and DSP gain settings */
  245. s8 power_table_index; /* actual (compenst'd) index into gain table */
  246. s8 requested_power; /* scan pwr (dBm) requested for chnl/rate */
  247. };
  248. /*
  249. * One for each channel, holds all channel setup data
  250. * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant
  251. * with one another!
  252. */
  253. struct iwl_channel_info {
  254. struct iwl4965_channel_tgd_info tgd;
  255. struct iwl4965_channel_tgh_info tgh;
  256. struct iwl_eeprom_channel eeprom; /* EEPROM regulatory limit */
  257. struct iwl_eeprom_channel ht40_eeprom; /* EEPROM regulatory limit for
  258. * HT40 channel */
  259. u8 channel; /* channel number */
  260. u8 flags; /* flags copied from EEPROM */
  261. s8 max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */
  262. s8 curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) limit */
  263. s8 min_power; /* always 0 */
  264. s8 scan_power; /* (dBm) regul. eeprom, direct scans, any rate */
  265. u8 group_index; /* 0-4, maps channel to group1/2/3/4/5 */
  266. u8 band_index; /* 0-4, maps channel to band1/2/3/4/5 */
  267. enum ieee80211_band band;
  268. /* HT40 channel info */
  269. s8 ht40_max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */
  270. s8 ht40_curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) */
  271. s8 ht40_min_power; /* always 0 */
  272. s8 ht40_scan_power; /* (dBm) eeprom, direct scans, any rate */
  273. u8 ht40_flags; /* flags copied from EEPROM */
  274. u8 ht40_extension_channel; /* HT_IE_EXT_CHANNEL_* */
  275. /* Radio/DSP gain settings for each "normal" data Tx rate.
  276. * These include, in addition to RF and DSP gain, a few fields for
  277. * remembering/modifying gain settings (indexes). */
  278. struct iwl3945_channel_power_info power_info[IWL4965_MAX_RATE];
  279. /* Radio/DSP gain settings for each scan rate, for directed scans. */
  280. struct iwl3945_scan_power_info scan_pwr_info[IWL_NUM_SCAN_RATES];
  281. };
  282. #define IWL_TX_FIFO_AC0 0
  283. #define IWL_TX_FIFO_AC1 1
  284. #define IWL_TX_FIFO_AC2 2
  285. #define IWL_TX_FIFO_AC3 3
  286. #define IWL_TX_FIFO_HCCA_1 5
  287. #define IWL_TX_FIFO_HCCA_2 6
  288. #define IWL_TX_FIFO_NONE 7
  289. /* Minimum number of queues. MAX_NUM is defined in hw specific files.
  290. * Set the minimum to accommodate the 4 standard TX queues, 1 command
  291. * queue, 2 (unused) HCCA queues, and 4 HT queues (one for each AC) */
  292. #define IWL_MIN_NUM_QUEUES 10
  293. /* Power management (not Tx power) structures */
  294. enum iwl_pwr_src {
  295. IWL_PWR_SRC_VMAIN,
  296. IWL_PWR_SRC_VAUX,
  297. };
  298. #define IEEE80211_DATA_LEN 2304
  299. #define IEEE80211_4ADDR_LEN 30
  300. #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
  301. #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
  302. struct iwl_frame {
  303. union {
  304. struct ieee80211_hdr frame;
  305. struct iwl_tx_beacon_cmd beacon;
  306. u8 raw[IEEE80211_FRAME_LEN];
  307. u8 cmd[360];
  308. } u;
  309. struct list_head list;
  310. };
  311. #define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
  312. #define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ)
  313. #define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4)
  314. enum {
  315. CMD_SYNC = 0,
  316. CMD_SIZE_NORMAL = 0,
  317. CMD_NO_SKB = 0,
  318. CMD_SIZE_HUGE = (1 << 0),
  319. CMD_ASYNC = (1 << 1),
  320. CMD_WANT_SKB = (1 << 2),
  321. };
  322. #define IWL_CMD_MAX_PAYLOAD 320
  323. /**
  324. * struct iwl_device_cmd
  325. *
  326. * For allocation of the command and tx queues, this establishes the overall
  327. * size of the largest command we send to uCode, except for a scan command
  328. * (which is relatively huge; space is allocated separately).
  329. */
  330. struct iwl_device_cmd {
  331. struct iwl_cmd_header hdr; /* uCode API */
  332. union {
  333. u32 flags;
  334. u8 val8;
  335. u16 val16;
  336. u32 val32;
  337. struct iwl_tx_cmd tx;
  338. u8 payload[IWL_CMD_MAX_PAYLOAD];
  339. } __attribute__ ((packed)) cmd;
  340. } __attribute__ ((packed));
  341. #define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl_device_cmd))
  342. struct iwl_host_cmd {
  343. const void *data;
  344. struct sk_buff *reply_skb;
  345. void (*callback)(struct iwl_priv *priv,
  346. struct iwl_device_cmd *cmd,
  347. struct sk_buff *skb);
  348. u32 flags;
  349. u16 len;
  350. u8 id;
  351. };
  352. /*
  353. * RX related structures and functions
  354. */
  355. #define RX_FREE_BUFFERS 64
  356. #define RX_LOW_WATERMARK 8
  357. #define SUP_RATE_11A_MAX_NUM_CHANNELS 8
  358. #define SUP_RATE_11B_MAX_NUM_CHANNELS 4
  359. #define SUP_RATE_11G_MAX_NUM_CHANNELS 12
  360. /**
  361. * struct iwl_rx_queue - Rx queue
  362. * @bd: driver's pointer to buffer of receive buffer descriptors (rbd)
  363. * @dma_addr: bus address of buffer of receive buffer descriptors (rbd)
  364. * @read: Shared index to newest available Rx buffer
  365. * @write: Shared index to oldest written Rx packet
  366. * @free_count: Number of pre-allocated buffers in rx_free
  367. * @rx_free: list of free SKBs for use
  368. * @rx_used: List of Rx buffers with no SKB
  369. * @need_update: flag to indicate we need to update read/write index
  370. * @rb_stts: driver's pointer to receive buffer status
  371. * @rb_stts_dma: bus address of receive buffer status
  372. *
  373. * NOTE: rx_free and rx_used are used as a FIFO for iwl_rx_mem_buffers
  374. */
  375. struct iwl_rx_queue {
  376. __le32 *bd;
  377. dma_addr_t dma_addr;
  378. struct iwl_rx_mem_buffer pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS];
  379. struct iwl_rx_mem_buffer *queue[RX_QUEUE_SIZE];
  380. u32 read;
  381. u32 write;
  382. u32 free_count;
  383. u32 write_actual;
  384. struct list_head rx_free;
  385. struct list_head rx_used;
  386. int need_update;
  387. struct iwl_rb_status *rb_stts;
  388. dma_addr_t rb_stts_dma;
  389. spinlock_t lock;
  390. };
  391. #define IWL_SUPPORTED_RATES_IE_LEN 8
  392. #define MAX_TID_COUNT 9
  393. #define IWL_INVALID_RATE 0xFF
  394. #define IWL_INVALID_VALUE -1
  395. /**
  396. * struct iwl_ht_agg -- aggregation status while waiting for block-ack
  397. * @txq_id: Tx queue used for Tx attempt
  398. * @frame_count: # frames attempted by Tx command
  399. * @wait_for_ba: Expect block-ack before next Tx reply
  400. * @start_idx: Index of 1st Transmit Frame Descriptor (TFD) in Tx window
  401. * @bitmap0: Low order bitmap, one bit for each frame pending ACK in Tx window
  402. * @bitmap1: High order, one bit for each frame pending ACK in Tx window
  403. * @rate_n_flags: Rate at which Tx was attempted
  404. *
  405. * If REPLY_TX indicates that aggregation was attempted, driver must wait
  406. * for block ack (REPLY_COMPRESSED_BA). This struct stores tx reply info
  407. * until block ack arrives.
  408. */
  409. struct iwl_ht_agg {
  410. u16 txq_id;
  411. u16 frame_count;
  412. u16 wait_for_ba;
  413. u16 start_idx;
  414. u64 bitmap;
  415. u32 rate_n_flags;
  416. #define IWL_AGG_OFF 0
  417. #define IWL_AGG_ON 1
  418. #define IWL_EMPTYING_HW_QUEUE_ADDBA 2
  419. #define IWL_EMPTYING_HW_QUEUE_DELBA 3
  420. u8 state;
  421. };
  422. struct iwl_tid_data {
  423. u16 seq_number;
  424. u16 tfds_in_queue;
  425. struct iwl_ht_agg agg;
  426. };
  427. struct iwl_hw_key {
  428. enum ieee80211_key_alg alg;
  429. int keylen;
  430. u8 keyidx;
  431. u8 key[32];
  432. };
  433. union iwl_ht_rate_supp {
  434. u16 rates;
  435. struct {
  436. u8 siso_rate;
  437. u8 mimo_rate;
  438. };
  439. };
  440. #define CFG_HT_RX_AMPDU_FACTOR_DEF (0x3)
  441. /*
  442. * Maximal MPDU density for TX aggregation
  443. * 4 - 2us density
  444. * 5 - 4us density
  445. * 6 - 8us density
  446. * 7 - 16us density
  447. */
  448. #define CFG_HT_MPDU_DENSITY_4USEC (0x5)
  449. #define CFG_HT_MPDU_DENSITY_DEF CFG_HT_MPDU_DENSITY_4USEC
  450. struct iwl_ht_config {
  451. /* self configuration data */
  452. bool is_ht;
  453. bool is_40mhz;
  454. bool single_chain_sufficient;
  455. /* BSS related data */
  456. u8 extension_chan_offset;
  457. u8 ht_protection;
  458. u8 non_GF_STA_present;
  459. };
  460. union iwl_qos_capabity {
  461. struct {
  462. u8 edca_count:4; /* bit 0-3 */
  463. u8 q_ack:1; /* bit 4 */
  464. u8 queue_request:1; /* bit 5 */
  465. u8 txop_request:1; /* bit 6 */
  466. u8 reserved:1; /* bit 7 */
  467. } q_AP;
  468. struct {
  469. u8 acvo_APSD:1; /* bit 0 */
  470. u8 acvi_APSD:1; /* bit 1 */
  471. u8 ac_bk_APSD:1; /* bit 2 */
  472. u8 ac_be_APSD:1; /* bit 3 */
  473. u8 q_ack:1; /* bit 4 */
  474. u8 max_len:2; /* bit 5-6 */
  475. u8 more_data_ack:1; /* bit 7 */
  476. } q_STA;
  477. u8 val;
  478. };
  479. /* QoS structures */
  480. struct iwl_qos_info {
  481. int qos_active;
  482. union iwl_qos_capabity qos_cap;
  483. struct iwl_qosparam_cmd def_qos_parm;
  484. };
  485. #define STA_PS_STATUS_WAKE 0
  486. #define STA_PS_STATUS_SLEEP 1
  487. struct iwl3945_station_entry {
  488. struct iwl3945_addsta_cmd sta;
  489. struct iwl_tid_data tid[MAX_TID_COUNT];
  490. u8 used;
  491. u8 ps_status;
  492. struct iwl_hw_key keyinfo;
  493. };
  494. struct iwl_station_entry {
  495. struct iwl_addsta_cmd sta;
  496. struct iwl_tid_data tid[MAX_TID_COUNT];
  497. u8 used;
  498. u8 ps_status;
  499. struct iwl_hw_key keyinfo;
  500. };
  501. /* one for each uCode image (inst/data, boot/init/runtime) */
  502. struct fw_desc {
  503. void *v_addr; /* access by driver */
  504. dma_addr_t p_addr; /* access by card's busmaster DMA */
  505. u32 len; /* bytes */
  506. };
  507. /* uCode file layout */
  508. struct iwl_ucode_header {
  509. __le32 ver; /* major/minor/API/serial */
  510. union {
  511. struct {
  512. __le32 inst_size; /* bytes of runtime code */
  513. __le32 data_size; /* bytes of runtime data */
  514. __le32 init_size; /* bytes of init code */
  515. __le32 init_data_size; /* bytes of init data */
  516. __le32 boot_size; /* bytes of bootstrap code */
  517. u8 data[0]; /* in same order as sizes */
  518. } v1;
  519. struct {
  520. __le32 build; /* build number */
  521. __le32 inst_size; /* bytes of runtime code */
  522. __le32 data_size; /* bytes of runtime data */
  523. __le32 init_size; /* bytes of init code */
  524. __le32 init_data_size; /* bytes of init data */
  525. __le32 boot_size; /* bytes of bootstrap code */
  526. u8 data[0]; /* in same order as sizes */
  527. } v2;
  528. } u;
  529. };
  530. #define UCODE_HEADER_SIZE(ver) ((ver) == 1 ? 24 : 28)
  531. struct iwl4965_ibss_seq {
  532. u8 mac[ETH_ALEN];
  533. u16 seq_num;
  534. u16 frag_num;
  535. unsigned long packet_time;
  536. struct list_head list;
  537. };
  538. struct iwl_sensitivity_ranges {
  539. u16 min_nrg_cck;
  540. u16 max_nrg_cck;
  541. u16 nrg_th_cck;
  542. u16 nrg_th_ofdm;
  543. u16 auto_corr_min_ofdm;
  544. u16 auto_corr_min_ofdm_mrc;
  545. u16 auto_corr_min_ofdm_x1;
  546. u16 auto_corr_min_ofdm_mrc_x1;
  547. u16 auto_corr_max_ofdm;
  548. u16 auto_corr_max_ofdm_mrc;
  549. u16 auto_corr_max_ofdm_x1;
  550. u16 auto_corr_max_ofdm_mrc_x1;
  551. u16 auto_corr_max_cck;
  552. u16 auto_corr_max_cck_mrc;
  553. u16 auto_corr_min_cck;
  554. u16 auto_corr_min_cck_mrc;
  555. };
  556. #define KELVIN_TO_CELSIUS(x) ((x)-273)
  557. #define CELSIUS_TO_KELVIN(x) ((x)+273)
  558. /**
  559. * struct iwl_hw_params
  560. * @max_txq_num: Max # Tx queues supported
  561. * @dma_chnl_num: Number of Tx DMA/FIFO channels
  562. * @scd_bc_tbls_size: size of scheduler byte count tables
  563. * @tfd_size: TFD size
  564. * @tx/rx_chains_num: Number of TX/RX chains
  565. * @valid_tx/rx_ant: usable antennas
  566. * @max_rxq_size: Max # Rx frames in Rx queue (must be power-of-2)
  567. * @max_rxq_log: Log-base-2 of max_rxq_size
  568. * @rx_buf_size: Rx buffer size
  569. * @rx_wrt_ptr_reg: FH{39}_RSCSR_CHNL0_WPTR
  570. * @max_stations:
  571. * @bcast_sta_id:
  572. * @ht40_channel: is 40MHz width possible in band 2.4
  573. * BIT(IEEE80211_BAND_5GHZ) BIT(IEEE80211_BAND_5GHZ)
  574. * @sw_crypto: 0 for hw, 1 for sw
  575. * @max_xxx_size: for ucode uses
  576. * @ct_kill_threshold: temperature threshold
  577. * @calib_init_cfg: setup initial calibrations for the hw
  578. * @struct iwl_sensitivity_ranges: range of sensitivity values
  579. */
  580. struct iwl_hw_params {
  581. u8 max_txq_num;
  582. u8 dma_chnl_num;
  583. u16 scd_bc_tbls_size;
  584. u32 tfd_size;
  585. u8 tx_chains_num;
  586. u8 rx_chains_num;
  587. u8 valid_tx_ant;
  588. u8 valid_rx_ant;
  589. u16 max_rxq_size;
  590. u16 max_rxq_log;
  591. u32 rx_buf_size;
  592. u32 rx_wrt_ptr_reg;
  593. u32 max_pkt_size;
  594. u8 max_stations;
  595. u8 bcast_sta_id;
  596. u8 ht40_channel;
  597. u8 max_beacon_itrvl; /* in 1024 ms */
  598. u32 max_inst_size;
  599. u32 max_data_size;
  600. u32 max_bsm_size;
  601. u32 ct_kill_threshold; /* value in hw-dependent units */
  602. u32 ct_kill_exit_threshold; /* value in hw-dependent units */
  603. /* for 1000, 6000 series and up */
  604. u32 calib_init_cfg;
  605. const struct iwl_sensitivity_ranges *sens;
  606. };
  607. /******************************************************************************
  608. *
  609. * Functions implemented in core module which are forward declared here
  610. * for use by iwl-[4-5].c
  611. *
  612. * NOTE: The implementation of these functions are not hardware specific
  613. * which is why they are in the core module files.
  614. *
  615. * Naming convention --
  616. * iwl_ <-- Is part of iwlwifi
  617. * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
  618. * iwl4965_bg_ <-- Called from work queue context
  619. * iwl4965_mac_ <-- mac80211 callback
  620. *
  621. ****************************************************************************/
  622. extern void iwl_update_chain_flags(struct iwl_priv *priv);
  623. extern int iwl_set_pwr_src(struct iwl_priv *priv, enum iwl_pwr_src src);
  624. extern const u8 iwl_bcast_addr[ETH_ALEN];
  625. extern int iwl_rxq_stop(struct iwl_priv *priv);
  626. extern void iwl_txq_ctx_stop(struct iwl_priv *priv);
  627. extern int iwl_queue_space(const struct iwl_queue *q);
  628. static inline int iwl_queue_used(const struct iwl_queue *q, int i)
  629. {
  630. return q->write_ptr > q->read_ptr ?
  631. (i >= q->read_ptr && i < q->write_ptr) :
  632. !(i < q->read_ptr && i >= q->write_ptr);
  633. }
  634. static inline u8 get_cmd_index(struct iwl_queue *q, u32 index, int is_huge)
  635. {
  636. /* This is for scan command, the big buffer at end of command array */
  637. if (is_huge)
  638. return q->n_window; /* must be power of 2 */
  639. /* Otherwise, use normal size buffers */
  640. return index & (q->n_window - 1);
  641. }
  642. struct iwl_dma_ptr {
  643. dma_addr_t dma;
  644. void *addr;
  645. size_t size;
  646. };
  647. #define IWL_OPERATION_MODE_AUTO 0
  648. #define IWL_OPERATION_MODE_HT_ONLY 1
  649. #define IWL_OPERATION_MODE_MIXED 2
  650. #define IWL_OPERATION_MODE_20MHZ 3
  651. #define IWL_TX_CRC_SIZE 4
  652. #define IWL_TX_DELIMITER_SIZE 4
  653. #define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000
  654. /* Sensitivity and chain noise calibration */
  655. #define INITIALIZATION_VALUE 0xFFFF
  656. #define IWL4965_CAL_NUM_BEACONS 20
  657. #define IWL_CAL_NUM_BEACONS 16
  658. #define MAXIMUM_ALLOWED_PATHLOSS 15
  659. #define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3
  660. #define MAX_FA_OFDM 50
  661. #define MIN_FA_OFDM 5
  662. #define MAX_FA_CCK 50
  663. #define MIN_FA_CCK 5
  664. #define AUTO_CORR_STEP_OFDM 1
  665. #define AUTO_CORR_STEP_CCK 3
  666. #define AUTO_CORR_MAX_TH_CCK 160
  667. #define NRG_DIFF 2
  668. #define NRG_STEP_CCK 2
  669. #define NRG_MARGIN 8
  670. #define MAX_NUMBER_CCK_NO_FA 100
  671. #define AUTO_CORR_CCK_MIN_VAL_DEF (125)
  672. #define CHAIN_A 0
  673. #define CHAIN_B 1
  674. #define CHAIN_C 2
  675. #define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4
  676. #define ALL_BAND_FILTER 0xFF00
  677. #define IN_BAND_FILTER 0xFF
  678. #define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF
  679. #define NRG_NUM_PREV_STAT_L 20
  680. #define NUM_RX_CHAINS 3
  681. enum iwl4965_false_alarm_state {
  682. IWL_FA_TOO_MANY = 0,
  683. IWL_FA_TOO_FEW = 1,
  684. IWL_FA_GOOD_RANGE = 2,
  685. };
  686. enum iwl4965_chain_noise_state {
  687. IWL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */
  688. IWL_CHAIN_NOISE_ACCUMULATE,
  689. IWL_CHAIN_NOISE_CALIBRATED,
  690. IWL_CHAIN_NOISE_DONE,
  691. };
  692. enum iwl4965_calib_enabled_state {
  693. IWL_CALIB_DISABLED = 0, /* must be 0 */
  694. IWL_CALIB_ENABLED = 1,
  695. };
  696. /*
  697. * enum iwl_calib
  698. * defines the order in which results of initial calibrations
  699. * should be sent to the runtime uCode
  700. */
  701. enum iwl_calib {
  702. IWL_CALIB_XTAL,
  703. IWL_CALIB_DC,
  704. IWL_CALIB_LO,
  705. IWL_CALIB_TX_IQ,
  706. IWL_CALIB_TX_IQ_PERD,
  707. IWL_CALIB_BASE_BAND,
  708. IWL_CALIB_MAX
  709. };
  710. /* Opaque calibration results */
  711. struct iwl_calib_result {
  712. void *buf;
  713. size_t buf_len;
  714. };
  715. enum ucode_type {
  716. UCODE_NONE = 0,
  717. UCODE_INIT,
  718. UCODE_RT
  719. };
  720. /* Sensitivity calib data */
  721. struct iwl_sensitivity_data {
  722. u32 auto_corr_ofdm;
  723. u32 auto_corr_ofdm_mrc;
  724. u32 auto_corr_ofdm_x1;
  725. u32 auto_corr_ofdm_mrc_x1;
  726. u32 auto_corr_cck;
  727. u32 auto_corr_cck_mrc;
  728. u32 last_bad_plcp_cnt_ofdm;
  729. u32 last_fa_cnt_ofdm;
  730. u32 last_bad_plcp_cnt_cck;
  731. u32 last_fa_cnt_cck;
  732. u32 nrg_curr_state;
  733. u32 nrg_prev_state;
  734. u32 nrg_value[10];
  735. u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L];
  736. u32 nrg_silence_ref;
  737. u32 nrg_energy_idx;
  738. u32 nrg_silence_idx;
  739. u32 nrg_th_cck;
  740. s32 nrg_auto_corr_silence_diff;
  741. u32 num_in_cck_no_fa;
  742. u32 nrg_th_ofdm;
  743. };
  744. /* Chain noise (differential Rx gain) calib data */
  745. struct iwl_chain_noise_data {
  746. u32 active_chains;
  747. u32 chain_noise_a;
  748. u32 chain_noise_b;
  749. u32 chain_noise_c;
  750. u32 chain_signal_a;
  751. u32 chain_signal_b;
  752. u32 chain_signal_c;
  753. u16 beacon_count;
  754. u8 disconn_array[NUM_RX_CHAINS];
  755. u8 delta_gain_code[NUM_RX_CHAINS];
  756. u8 radio_write;
  757. u8 state;
  758. };
  759. #define EEPROM_SEM_TIMEOUT 10 /* milliseconds */
  760. #define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */
  761. #define IWL_TRAFFIC_ENTRIES (256)
  762. #define IWL_TRAFFIC_ENTRY_SIZE (64)
  763. enum {
  764. MEASUREMENT_READY = (1 << 0),
  765. MEASUREMENT_ACTIVE = (1 << 1),
  766. };
  767. enum iwl_nvm_type {
  768. NVM_DEVICE_TYPE_EEPROM = 0,
  769. NVM_DEVICE_TYPE_OTP,
  770. };
  771. /*
  772. * Two types of OTP memory access modes
  773. * IWL_OTP_ACCESS_ABSOLUTE - absolute address mode,
  774. * based on physical memory addressing
  775. * IWL_OTP_ACCESS_RELATIVE - relative address mode,
  776. * based on logical memory addressing
  777. */
  778. enum iwl_access_mode {
  779. IWL_OTP_ACCESS_ABSOLUTE,
  780. IWL_OTP_ACCESS_RELATIVE,
  781. };
  782. /**
  783. * enum iwl_pa_type - Power Amplifier type
  784. * @IWL_PA_SYSTEM: based on uCode configuration
  785. * @IWL_PA_HYBRID: use both Internal and external PA
  786. * @IWL_PA_INTERNAL: use Internal only
  787. */
  788. enum iwl_pa_type {
  789. IWL_PA_SYSTEM = 0,
  790. IWL_PA_HYBRID = 1,
  791. IWL_PA_INTERNAL = 2,
  792. };
  793. /* interrupt statistics */
  794. struct isr_statistics {
  795. u32 hw;
  796. u32 sw;
  797. u32 sw_err;
  798. u32 sch;
  799. u32 alive;
  800. u32 rfkill;
  801. u32 ctkill;
  802. u32 wakeup;
  803. u32 rx;
  804. u32 rx_handlers[REPLY_MAX];
  805. u32 tx;
  806. u32 unhandled;
  807. };
  808. #ifdef CONFIG_IWLWIFI_DEBUGFS
  809. /* management statistics */
  810. enum iwl_mgmt_stats {
  811. MANAGEMENT_ASSOC_REQ = 0,
  812. MANAGEMENT_ASSOC_RESP,
  813. MANAGEMENT_REASSOC_REQ,
  814. MANAGEMENT_REASSOC_RESP,
  815. MANAGEMENT_PROBE_REQ,
  816. MANAGEMENT_PROBE_RESP,
  817. MANAGEMENT_BEACON,
  818. MANAGEMENT_ATIM,
  819. MANAGEMENT_DISASSOC,
  820. MANAGEMENT_AUTH,
  821. MANAGEMENT_DEAUTH,
  822. MANAGEMENT_ACTION,
  823. MANAGEMENT_MAX,
  824. };
  825. /* control statistics */
  826. enum iwl_ctrl_stats {
  827. CONTROL_BACK_REQ = 0,
  828. CONTROL_BACK,
  829. CONTROL_PSPOLL,
  830. CONTROL_RTS,
  831. CONTROL_CTS,
  832. CONTROL_ACK,
  833. CONTROL_CFEND,
  834. CONTROL_CFENDACK,
  835. CONTROL_MAX,
  836. };
  837. struct traffic_stats {
  838. u32 mgmt[MANAGEMENT_MAX];
  839. u32 ctrl[CONTROL_MAX];
  840. u32 data_cnt;
  841. u64 data_bytes;
  842. };
  843. #else
  844. struct traffic_stats {
  845. u64 data_bytes;
  846. };
  847. #endif
  848. #define IWL_MAX_NUM_QUEUES 20 /* FIXME: do dynamic allocation */
  849. struct iwl_priv {
  850. /* ieee device used by generic ieee processing code */
  851. struct ieee80211_hw *hw;
  852. struct ieee80211_channel *ieee_channels;
  853. struct ieee80211_rate *ieee_rates;
  854. struct iwl_cfg *cfg;
  855. /* temporary frame storage list */
  856. struct list_head free_frames;
  857. int frames_count;
  858. enum ieee80211_band band;
  859. int alloc_rxb_skb;
  860. void (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv,
  861. struct iwl_rx_mem_buffer *rxb);
  862. struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS];
  863. #if defined(CONFIG_IWLWIFI_SPECTRUM_MEASUREMENT) || defined(CONFIG_IWL3945_SPECTRUM_MEASUREMENT)
  864. /* spectrum measurement report caching */
  865. struct iwl_spectrum_notification measure_report;
  866. u8 measurement_status;
  867. #endif
  868. /* ucode beacon time */
  869. u32 ucode_beacon_time;
  870. /* we allocate array of iwl4965_channel_info for NIC's valid channels.
  871. * Access via channel # using indirect index array */
  872. struct iwl_channel_info *channel_info; /* channel info array */
  873. u8 channel_count; /* # of channels */
  874. /* each calibration channel group in the EEPROM has a derived
  875. * clip setting for each rate. 3945 only.*/
  876. const struct iwl3945_clip_group clip39_groups[5];
  877. /* thermal calibration */
  878. s32 temperature; /* degrees Kelvin */
  879. s32 last_temperature;
  880. /* init calibration results */
  881. struct iwl_calib_result calib_results[IWL_CALIB_MAX];
  882. /* Scan related variables */
  883. unsigned long last_scan_jiffies;
  884. unsigned long next_scan_jiffies;
  885. unsigned long scan_start;
  886. unsigned long scan_pass_start;
  887. unsigned long scan_start_tsf;
  888. void *scan;
  889. int scan_bands;
  890. struct cfg80211_scan_request *scan_request;
  891. u8 scan_tx_ant[IEEE80211_NUM_BANDS];
  892. u8 mgmt_tx_ant;
  893. /* spinlock */
  894. spinlock_t lock; /* protect general shared data */
  895. spinlock_t hcmd_lock; /* protect hcmd */
  896. spinlock_t reg_lock; /* protect hw register access */
  897. struct mutex mutex;
  898. /* basic pci-network driver stuff */
  899. struct pci_dev *pci_dev;
  900. /* pci hardware address support */
  901. void __iomem *hw_base;
  902. u32 hw_rev;
  903. u32 hw_wa_rev;
  904. u8 rev_id;
  905. /* uCode images, save to reload in case of failure */
  906. u32 ucode_ver; /* version of ucode, copy of
  907. iwl_ucode.ver */
  908. struct fw_desc ucode_code; /* runtime inst */
  909. struct fw_desc ucode_data; /* runtime data original */
  910. struct fw_desc ucode_data_backup; /* runtime data save/restore */
  911. struct fw_desc ucode_init; /* initialization inst */
  912. struct fw_desc ucode_init_data; /* initialization data */
  913. struct fw_desc ucode_boot; /* bootstrap inst */
  914. enum ucode_type ucode_type;
  915. u8 ucode_write_complete; /* the image write is complete */
  916. struct iwl_rxon_time_cmd rxon_timing;
  917. /* We declare this const so it can only be
  918. * changed via explicit cast within the
  919. * routines that actually update the physical
  920. * hardware */
  921. const struct iwl_rxon_cmd active_rxon;
  922. struct iwl_rxon_cmd staging_rxon;
  923. struct iwl_rxon_cmd recovery_rxon;
  924. /* 1st responses from initialize and runtime uCode images.
  925. * 4965's initialize alive response contains some calibration data. */
  926. struct iwl_init_alive_resp card_alive_init;
  927. struct iwl_alive_resp card_alive;
  928. unsigned long last_blink_time;
  929. u8 last_blink_rate;
  930. u8 allow_blinking;
  931. u64 led_tpt;
  932. u16 active_rate;
  933. u16 active_rate_basic;
  934. u8 assoc_station_added;
  935. u8 start_calib;
  936. struct iwl_sensitivity_data sensitivity_data;
  937. struct iwl_chain_noise_data chain_noise_data;
  938. __le16 sensitivity_tbl[HD_TABLE_SIZE];
  939. struct iwl_ht_config current_ht_config;
  940. u8 last_phy_res[100];
  941. /* Rate scaling data */
  942. s8 data_retry_limit;
  943. u8 retry_rate;
  944. wait_queue_head_t wait_command_queue;
  945. int activity_timer_active;
  946. /* Rx and Tx DMA processing queues */
  947. struct iwl_rx_queue rxq;
  948. struct iwl_tx_queue txq[IWL_MAX_NUM_QUEUES];
  949. unsigned long txq_ctx_active_msk;
  950. struct iwl_dma_ptr kw; /* keep warm address */
  951. struct iwl_dma_ptr scd_bc_tbls;
  952. u32 scd_base_addr; /* scheduler sram base address */
  953. unsigned long status;
  954. int last_rx_rssi; /* From Rx packet statistics */
  955. int last_rx_noise; /* From beacon statistics */
  956. /* counts mgmt, ctl, and data packets */
  957. struct traffic_stats tx_stats;
  958. struct traffic_stats rx_stats;
  959. /* counts interrupts */
  960. struct isr_statistics isr_stats;
  961. struct iwl_power_mgr power_data;
  962. struct iwl_tt_mgmt thermal_throttle;
  963. struct iwl_notif_statistics statistics;
  964. unsigned long last_statistics_time;
  965. /* context information */
  966. u16 rates_mask;
  967. u8 bssid[ETH_ALEN];
  968. u16 rts_threshold;
  969. u8 mac_addr[ETH_ALEN];
  970. /*station table variables */
  971. spinlock_t sta_lock;
  972. int num_stations;
  973. struct iwl_station_entry stations[IWL_STATION_COUNT];
  974. struct iwl_wep_key wep_keys[WEP_KEYS_MAX];
  975. u8 default_wep_key;
  976. u8 key_mapping_key;
  977. unsigned long ucode_key_table;
  978. /* queue refcounts */
  979. #define IWL_MAX_HW_QUEUES 32
  980. unsigned long queue_stopped[BITS_TO_LONGS(IWL_MAX_HW_QUEUES)];
  981. /* for each AC */
  982. atomic_t queue_stop_count[4];
  983. /* Indication if ieee80211_ops->open has been called */
  984. u8 is_open;
  985. u8 mac80211_registered;
  986. /* Rx'd packet timing information */
  987. u32 last_beacon_time;
  988. u64 last_tsf;
  989. /* eeprom */
  990. u8 *eeprom;
  991. int nvm_device_type;
  992. struct iwl_eeprom_calib_info *calib_info;
  993. enum nl80211_iftype iw_mode;
  994. struct sk_buff *ibss_beacon;
  995. /* Last Rx'd beacon timestamp */
  996. u64 timestamp;
  997. u16 beacon_int;
  998. struct ieee80211_vif *vif;
  999. /*Added for 3945 */
  1000. void *shared_virt;
  1001. dma_addr_t shared_phys;
  1002. /*End*/
  1003. struct iwl_hw_params hw_params;
  1004. /* INT ICT Table */
  1005. __le32 *ict_tbl;
  1006. dma_addr_t ict_tbl_dma;
  1007. dma_addr_t aligned_ict_tbl_dma;
  1008. int ict_index;
  1009. void *ict_tbl_vir;
  1010. u32 inta;
  1011. bool use_ict;
  1012. u32 inta_mask;
  1013. /* Current association information needed to configure the
  1014. * hardware */
  1015. u16 assoc_id;
  1016. u16 assoc_capability;
  1017. struct iwl_qos_info qos_data;
  1018. struct workqueue_struct *workqueue;
  1019. struct work_struct up;
  1020. struct work_struct restart;
  1021. struct work_struct calibrated_work;
  1022. struct work_struct scan_completed;
  1023. struct work_struct rx_replenish;
  1024. struct work_struct abort_scan;
  1025. struct work_struct update_link_led;
  1026. struct work_struct auth_work;
  1027. struct work_struct report_work;
  1028. struct work_struct request_scan;
  1029. struct work_struct beacon_update;
  1030. struct work_struct tt_work;
  1031. struct work_struct ct_enter;
  1032. struct work_struct ct_exit;
  1033. struct tasklet_struct irq_tasklet;
  1034. struct delayed_work init_alive_start;
  1035. struct delayed_work alive_start;
  1036. struct delayed_work scan_check;
  1037. /*For 3945 only*/
  1038. struct delayed_work thermal_periodic;
  1039. struct delayed_work rfkill_poll;
  1040. /* TX Power */
  1041. s8 tx_power_user_lmt;
  1042. s8 tx_power_device_lmt;
  1043. #ifdef CONFIG_IWLWIFI_DEBUG
  1044. /* debugging info */
  1045. u32 debug_level; /* per device debugging will override global
  1046. iwl_debug_level if set */
  1047. u32 framecnt_to_us;
  1048. atomic_t restrict_refcnt;
  1049. bool disable_ht40;
  1050. #ifdef CONFIG_IWLWIFI_DEBUGFS
  1051. /* debugfs */
  1052. u16 tx_traffic_idx;
  1053. u16 rx_traffic_idx;
  1054. u8 *tx_traffic;
  1055. u8 *rx_traffic;
  1056. struct iwl_debugfs *dbgfs;
  1057. #endif /* CONFIG_IWLWIFI_DEBUGFS */
  1058. #endif /* CONFIG_IWLWIFI_DEBUG */
  1059. struct work_struct txpower_work;
  1060. u32 disable_sens_cal;
  1061. u32 disable_chain_noise_cal;
  1062. u32 disable_tx_power_cal;
  1063. struct work_struct run_time_calib_work;
  1064. struct timer_list statistics_periodic;
  1065. bool hw_ready;
  1066. /*For 3945*/
  1067. #define IWL_DEFAULT_TX_POWER 0x0F
  1068. struct iwl3945_notif_statistics statistics_39;
  1069. u32 sta_supp_rates;
  1070. }; /*iwl_priv */
  1071. static inline void iwl_txq_ctx_activate(struct iwl_priv *priv, int txq_id)
  1072. {
  1073. set_bit(txq_id, &priv->txq_ctx_active_msk);
  1074. }
  1075. static inline void iwl_txq_ctx_deactivate(struct iwl_priv *priv, int txq_id)
  1076. {
  1077. clear_bit(txq_id, &priv->txq_ctx_active_msk);
  1078. }
  1079. #ifdef CONFIG_IWLWIFI_DEBUG
  1080. const char *iwl_get_tx_fail_reason(u32 status);
  1081. /*
  1082. * iwl_get_debug_level: Return active debug level for device
  1083. *
  1084. * Using sysfs it is possible to set per device debug level. This debug
  1085. * level will be used if set, otherwise the global debug level which can be
  1086. * set via module parameter is used.
  1087. */
  1088. static inline u32 iwl_get_debug_level(struct iwl_priv *priv)
  1089. {
  1090. if (priv->debug_level)
  1091. return priv->debug_level;
  1092. else
  1093. return iwl_debug_level;
  1094. }
  1095. #else
  1096. static inline const char *iwl_get_tx_fail_reason(u32 status) { return ""; }
  1097. static inline u32 iwl_get_debug_level(struct iwl_priv *priv)
  1098. {
  1099. return iwl_debug_level;
  1100. }
  1101. #endif
  1102. static inline struct ieee80211_hdr *iwl_tx_queue_get_hdr(struct iwl_priv *priv,
  1103. int txq_id, int idx)
  1104. {
  1105. if (priv->txq[txq_id].txb[idx].skb[0])
  1106. return (struct ieee80211_hdr *)priv->txq[txq_id].
  1107. txb[idx].skb[0]->data;
  1108. return NULL;
  1109. }
  1110. static inline int iwl_is_associated(struct iwl_priv *priv)
  1111. {
  1112. return (priv->active_rxon.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
  1113. }
  1114. static inline int is_channel_valid(const struct iwl_channel_info *ch_info)
  1115. {
  1116. if (ch_info == NULL)
  1117. return 0;
  1118. return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0;
  1119. }
  1120. static inline int is_channel_radar(const struct iwl_channel_info *ch_info)
  1121. {
  1122. return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0;
  1123. }
  1124. static inline u8 is_channel_a_band(const struct iwl_channel_info *ch_info)
  1125. {
  1126. return ch_info->band == IEEE80211_BAND_5GHZ;
  1127. }
  1128. static inline u8 is_channel_bg_band(const struct iwl_channel_info *ch_info)
  1129. {
  1130. return ch_info->band == IEEE80211_BAND_2GHZ;
  1131. }
  1132. static inline int is_channel_passive(const struct iwl_channel_info *ch)
  1133. {
  1134. return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0;
  1135. }
  1136. static inline int is_channel_ibss(const struct iwl_channel_info *ch)
  1137. {
  1138. return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0;
  1139. }
  1140. #endif /* __iwl_dev_h__ */