iwl-dev.h 36 KB

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