iwl-dev.h 37 KB

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