iwl-dev.h 36 KB

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