iwl-dev.h 40 KB

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