iwl-dev.h 37 KB

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