iwl-dev.h 38 KB

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