iwl-dev.h 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351
  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 4965.h for hardware-related definitions.
  30. */
  31. #ifndef __il_dev_h__
  32. #define __il_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 "4965.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 il_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 stats 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 IL_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 il_rx_buf {
  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 il_device_cmd;
  88. struct il_cmd_meta {
  89. /* only for SYNC commands, iff the reply skb is wanted */
  90. struct il_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 il_priv *il,
  99. struct il_device_cmd *cmd,
  100. struct il_rx_pkt *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 il_queue {
  113. int n_bd; /* number of BDs in this queue */
  114. int write_ptr; /* 1-st empty entry (idx) host_w*/
  115. int read_ptr; /* last used entry (idx) 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_win; /* safe queue win */
  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 il_tx_info {
  127. struct sk_buff *skb;
  128. struct il_rxon_context *ctx;
  129. };
  130. /**
  131. * struct il_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 idx
  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 il_tx_queue {
  148. struct il_queue q;
  149. void *tfds;
  150. struct il_device_cmd **cmd;
  151. struct il_cmd_meta *meta;
  152. struct il_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 IL_NUM_SCAN_RATES (2)
  160. struct il4965_channel_tgd_info {
  161. u8 type;
  162. s8 max_power;
  163. };
  164. struct il4965_channel_tgh_info {
  165. s64 last_radar_time;
  166. };
  167. #define IL4965_MAX_RATE (33)
  168. struct il3945_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[IL_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 idx must also be set. */
  180. struct il3945_channel_power_info {
  181. struct il3945_tx_power tpc; /* actual radio and DSP gain settings */
  182. s8 power_table_idx; /* actual (compenst'd) idx into gain table */
  183. s8 base_power_idx; /* gain idx 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 il3945_scan_power_info {
  189. struct il3945_tx_power tpc; /* actual radio and DSP gain settings */
  190. s8 power_table_idx; /* actual (compenst'd) idx 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 il_channel_info {
  199. struct il4965_channel_tgd_info tgd;
  200. struct il4965_channel_tgh_info tgh;
  201. struct il_eeprom_channel eeprom; /* EEPROM regulatory limit */
  202. struct il_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_idx; /* 0-4, maps channel to group1/2/3/4/5 */
  211. u8 band_idx; /* 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 (idxes). */
  220. struct il3945_channel_power_info power_info[IL4965_MAX_RATE];
  221. /* Radio/DSP gain settings for each scan rate, for directed scans. */
  222. struct il3945_scan_power_info scan_pwr_info[IL_NUM_SCAN_RATES];
  223. };
  224. #define IL_TX_FIFO_BK 0 /* shared */
  225. #define IL_TX_FIFO_BE 1
  226. #define IL_TX_FIFO_VI 2 /* shared */
  227. #define IL_TX_FIFO_VO 3
  228. #define IL_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 IL_MIN_NUM_QUEUES 10
  233. #define IL_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 il_frame {
  239. union {
  240. struct ieee80211_hdr frame;
  241. struct il_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 il_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 il_device_cmd {
  268. struct il_cmd_header hdr; /* uCode API */
  269. union {
  270. u32 flags;
  271. u8 val8;
  272. u16 val16;
  273. u32 val32;
  274. struct il_tx_cmd tx;
  275. u8 payload[DEF_CMD_PAYLOAD_SIZE];
  276. } __packed cmd;
  277. } __packed;
  278. #define TFD_MAX_PAYLOAD_SIZE (sizeof(struct il_device_cmd))
  279. struct il_host_cmd {
  280. const void *data;
  281. unsigned long reply_page;
  282. void (*callback)(struct il_priv *il,
  283. struct il_device_cmd *cmd,
  284. struct il_rx_pkt *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 il_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 idx to newest available Rx buffer
  297. * @write: Shared idx 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 idx
  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 il_rx_bufs
  306. */
  307. struct il_rx_queue {
  308. __le32 *bd;
  309. dma_addr_t bd_dma;
  310. struct il_rx_buf pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS];
  311. struct il_rx_buf *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 il_rb_status *rb_stts;
  320. dma_addr_t rb_stts_dma;
  321. spinlock_t lock;
  322. };
  323. #define IL_SUPPORTED_RATES_IE_LEN 8
  324. #define MAX_TID_COUNT 9
  325. #define IL_INVALID_RATE 0xFF
  326. #define IL_INVALID_VALUE -1
  327. /**
  328. * struct il_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 win
  333. * @bitmap0: Low order bitmap, one bit for each frame pending ACK in Tx win
  334. * @bitmap1: High order, one bit for each frame pending ACK in Tx win
  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 il_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 IL_AGG_OFF 0
  349. #define IL_AGG_ON 1
  350. #define IL_EMPTYING_HW_QUEUE_ADDBA 2
  351. #define IL_EMPTYING_HW_QUEUE_DELBA 3
  352. u8 state;
  353. };
  354. struct il_tid_data {
  355. u16 seq_number; /* 4965 only */
  356. u16 tfds_in_queue;
  357. struct il_ht_agg agg;
  358. };
  359. struct il_hw_key {
  360. u32 cipher;
  361. int keylen;
  362. u8 keyidx;
  363. u8 key[32];
  364. };
  365. union il_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 il_ht_config {
  394. bool single_chain_sufficient;
  395. enum ieee80211_smps_mode smps; /* current smps mode */
  396. };
  397. /* QoS structures */
  398. struct il_qos_info {
  399. int qos_active;
  400. struct il_qosparam_cmd def_qos_parm;
  401. };
  402. /*
  403. * Structure should be accessed with sta_lock held. When station addition
  404. * is in progress (IL_STA_UCODE_INPROGRESS) it is possible to access only
  405. * the commands (il_addsta_cmd and il_link_quality_cmd) without
  406. * sta_lock held.
  407. */
  408. struct il_station_entry {
  409. struct il_addsta_cmd sta;
  410. struct il_tid_data tid[MAX_TID_COUNT];
  411. u8 used, ctxid;
  412. struct il_hw_key keyinfo;
  413. struct il_link_quality_cmd *lq;
  414. };
  415. struct il_station_priv_common {
  416. struct il_rxon_context *ctx;
  417. u8 sta_id;
  418. };
  419. /*
  420. * il_station_priv: Driver's ilate 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 il_station_priv {
  430. struct il_station_priv_common common;
  431. struct il_lq_sta lq_sta;
  432. atomic_t pending_frames;
  433. bool client;
  434. bool asleep;
  435. };
  436. /**
  437. * struct il_vif_priv - driver's ilate 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 il_vif_priv {
  443. struct il_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 il_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 il4965_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 il_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 il_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 il_sensitivity_ranges: range of sensitivity values
  514. */
  515. struct il_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 il_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. * il_ <-- Is part of iwlwifi
  548. * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
  549. * il4965_bg_ <-- Called from work queue context
  550. * il4965_mac_ <-- mac80211 callback
  551. *
  552. ****************************************************************************/
  553. extern void il4965_update_chain_flags(struct il_priv *il);
  554. extern const u8 il_bcast_addr[ETH_ALEN];
  555. extern int il_queue_space(const struct il_queue *q);
  556. static inline int il_queue_used(const struct il_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 il_get_cmd_idx(struct il_queue *q, u32 idx,
  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_win; /* must be power of 2 */
  572. /* Otherwise, use normal size buffers */
  573. return idx & (q->n_win - 1);
  574. }
  575. struct il_dma_ptr {
  576. dma_addr_t dma;
  577. void *addr;
  578. size_t size;
  579. };
  580. #define IL_OPERATION_MODE_AUTO 0
  581. #define IL_OPERATION_MODE_HT_ONLY 1
  582. #define IL_OPERATION_MODE_MIXED 2
  583. #define IL_OPERATION_MODE_20MHZ 3
  584. #define IL_TX_CRC_SIZE 4
  585. #define IL_TX_DELIMITER_SIZE 4
  586. #define TX_POWER_IL_ILLEGAL_VOLTAGE -10000
  587. /* Sensitivity and chain noise calibration */
  588. #define INITIALIZATION_VALUE 0xFFFF
  589. #define IL4965_CAL_NUM_BEACONS 20
  590. #define IL_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 il4965_false_alarm_state {
  615. IL_FA_TOO_MANY = 0,
  616. IL_FA_TOO_FEW = 1,
  617. IL_FA_GOOD_RANGE = 2,
  618. };
  619. enum il4965_chain_noise_state {
  620. IL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */
  621. IL_CHAIN_NOISE_ACCUMULATE,
  622. IL_CHAIN_NOISE_CALIBRATED,
  623. IL_CHAIN_NOISE_DONE,
  624. };
  625. enum il4965_calib_enabled_state {
  626. IL_CALIB_DISABLED = 0, /* must be 0 */
  627. IL_CALIB_ENABLED = 1,
  628. };
  629. /*
  630. * enum il_calib
  631. * defines the order in which results of initial calibrations
  632. * should be sent to the runtime uCode
  633. */
  634. enum il_calib {
  635. IL_CALIB_MAX,
  636. };
  637. /* Opaque calibration results */
  638. struct il_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 il_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 il_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 IL_TRAFFIC_ENTRIES (256)
  692. #define IL_TRAFFIC_ENTRY_SIZE (64)
  693. enum {
  694. MEASUREMENT_READY = (1 << 0),
  695. MEASUREMENT_ACTIVE = (1 << 1),
  696. };
  697. /* interrupt stats */
  698. struct isr_stats {
  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 stats */
  713. enum il_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 stats */
  729. enum il_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_IWLEGACY_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 IL_HOST_INT_TIMEOUT_MAX (0xFF)
  757. #define IL_HOST_INT_TIMEOUT_DEF (0x40)
  758. #define IL_HOST_INT_TIMEOUT_MIN (0x0)
  759. #define IL_HOST_INT_CALIB_TIMEOUT_MAX (0xFF)
  760. #define IL_HOST_INT_CALIB_TIMEOUT_DEF (0x10)
  761. #define IL_HOST_INT_CALIB_TIMEOUT_MIN (0x0)
  762. #define IL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5)
  763. /* TX queue watchdog timeouts in mSecs */
  764. #define IL_DEF_WD_TIMEOUT (2000)
  765. #define IL_LONG_WD_TIMEOUT (10000)
  766. #define IL_MAX_WD_TIMEOUT (120000)
  767. struct il_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 IL3945_EXT_BEACON_TIME_POS 24
  781. /*
  782. * for _4965 devices
  783. * bits 31:22 - extended
  784. * bits 21:0 - interval
  785. */
  786. #define IL4965_EXT_BEACON_TIME_POS 22
  787. struct il_rxon_context {
  788. struct ieee80211_vif *vif;
  789. const u8 *ac_to_fifo;
  790. const u8 *ac_to_queue;
  791. u8 mcast_queue;
  792. /*
  793. * We could use the vif to indicate active, but we
  794. * also need it to be active during disabling when
  795. * we already removed the vif for type setting.
  796. */
  797. bool always_active, is_active;
  798. bool ht_need_multiple_chains;
  799. int ctxid;
  800. u32 interface_modes, exclusive_interface_modes;
  801. u8 unused_devtype, ap_devtype, ibss_devtype, station_devtype;
  802. /*
  803. * We declare this const so it can only be
  804. * changed via explicit cast within the
  805. * routines that actually update the physical
  806. * hardware.
  807. */
  808. const struct il_rxon_cmd active;
  809. struct il_rxon_cmd staging;
  810. struct il_rxon_time_cmd timing;
  811. struct il_qos_info qos_data;
  812. u8 bcast_sta_id, ap_sta_id;
  813. u8 rxon_cmd, rxon_assoc_cmd, rxon_timing_cmd;
  814. u8 qos_cmd;
  815. u8 wep_key_cmd;
  816. struct il_wep_key wep_keys[WEP_KEYS_MAX];
  817. u8 key_mapping_keys;
  818. __le32 station_flags;
  819. struct {
  820. bool non_gf_sta_present;
  821. u8 protection;
  822. bool enabled, is_40mhz;
  823. u8 extension_chan_offset;
  824. } ht;
  825. };
  826. struct il_priv {
  827. /* ieee device used by generic ieee processing code */
  828. struct ieee80211_hw *hw;
  829. struct ieee80211_channel *ieee_channels;
  830. struct ieee80211_rate *ieee_rates;
  831. struct il_cfg *cfg;
  832. /* temporary frame storage list */
  833. struct list_head free_frames;
  834. int frames_count;
  835. enum ieee80211_band band;
  836. int alloc_rxb_page;
  837. void (*rx_handlers[REPLY_MAX])(struct il_priv *il,
  838. struct il_rx_buf *rxb);
  839. struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS];
  840. /* spectrum measurement report caching */
  841. struct il_spectrum_notification measure_report;
  842. u8 measurement_status;
  843. /* ucode beacon time */
  844. u32 ucode_beacon_time;
  845. int missed_beacon_threshold;
  846. /* track IBSS manager (last beacon) status */
  847. u32 ibss_manager;
  848. /* force reset */
  849. struct il_force_reset force_reset;
  850. /* we allocate array of il_channel_info for NIC's valid channels.
  851. * Access via channel # using indirect idx array */
  852. struct il_channel_info *channel_info; /* channel info array */
  853. u8 channel_count; /* # of channels */
  854. /* thermal calibration */
  855. s32 temperature; /* degrees Kelvin */
  856. s32 last_temperature;
  857. /* init calibration results */
  858. struct il_calib_result calib_results[IL_CALIB_MAX];
  859. /* Scan related variables */
  860. unsigned long scan_start;
  861. unsigned long scan_start_tsf;
  862. void *scan_cmd;
  863. enum ieee80211_band scan_band;
  864. struct cfg80211_scan_request *scan_request;
  865. struct ieee80211_vif *scan_vif;
  866. u8 scan_tx_ant[IEEE80211_NUM_BANDS];
  867. u8 mgmt_tx_ant;
  868. /* spinlock */
  869. spinlock_t lock; /* protect general shared data */
  870. spinlock_t hcmd_lock; /* protect hcmd */
  871. spinlock_t reg_lock; /* protect hw register access */
  872. struct mutex mutex;
  873. /* basic pci-network driver stuff */
  874. struct pci_dev *pci_dev;
  875. /* pci hardware address support */
  876. void __iomem *hw_base;
  877. u32 hw_rev;
  878. u32 hw_wa_rev;
  879. u8 rev_id;
  880. /* command queue number */
  881. u8 cmd_queue;
  882. /* max number of station keys */
  883. u8 sta_key_max_num;
  884. /* EEPROM MAC addresses */
  885. struct mac_address addresses[1];
  886. /* uCode images, save to reload in case of failure */
  887. int fw_idx; /* firmware we're trying to load */
  888. u32 ucode_ver; /* version of ucode, copy of
  889. il_ucode.ver */
  890. struct fw_desc ucode_code; /* runtime inst */
  891. struct fw_desc ucode_data; /* runtime data original */
  892. struct fw_desc ucode_data_backup; /* runtime data save/restore */
  893. struct fw_desc ucode_init; /* initialization inst */
  894. struct fw_desc ucode_init_data; /* initialization data */
  895. struct fw_desc ucode_boot; /* bootstrap inst */
  896. enum ucode_type ucode_type;
  897. u8 ucode_write_complete; /* the image write is complete */
  898. char firmware_name[25];
  899. struct il_rxon_context ctx;
  900. __le16 switch_channel;
  901. /* 1st responses from initialize and runtime uCode images.
  902. * _4965's initialize alive response contains some calibration data. */
  903. struct il_init_alive_resp card_alive_init;
  904. struct il_alive_resp card_alive;
  905. u16 active_rate;
  906. u8 start_calib;
  907. struct il_sensitivity_data sensitivity_data;
  908. struct il_chain_noise_data chain_noise_data;
  909. __le16 sensitivity_tbl[HD_TBL_SIZE];
  910. struct il_ht_config current_ht_config;
  911. /* Rate scaling data */
  912. u8 retry_rate;
  913. wait_queue_head_t wait_command_queue;
  914. int activity_timer_active;
  915. /* Rx and Tx DMA processing queues */
  916. struct il_rx_queue rxq;
  917. struct il_tx_queue *txq;
  918. unsigned long txq_ctx_active_msk;
  919. struct il_dma_ptr kw; /* keep warm address */
  920. struct il_dma_ptr scd_bc_tbls;
  921. u32 scd_base_addr; /* scheduler sram base address */
  922. unsigned long status;
  923. /* counts mgmt, ctl, and data packets */
  924. struct traffic_stats tx_stats;
  925. struct traffic_stats rx_stats;
  926. /* counts interrupts */
  927. struct isr_stats isr_stats;
  928. struct il_power_mgr power_data;
  929. /* context information */
  930. u8 bssid[ETH_ALEN]; /* used only on 3945 but filled by core */
  931. /* station table variables */
  932. /* Note: if lock and sta_lock are needed, lock must be acquired first */
  933. spinlock_t sta_lock;
  934. int num_stations;
  935. struct il_station_entry stations[IL_STATION_COUNT];
  936. unsigned long ucode_key_table;
  937. /* queue refcounts */
  938. #define IL_MAX_HW_QUEUES 32
  939. unsigned long queue_stopped[BITS_TO_LONGS(IL_MAX_HW_QUEUES)];
  940. /* for each AC */
  941. atomic_t queue_stop_count[4];
  942. /* Indication if ieee80211_ops->open has been called */
  943. u8 is_open;
  944. u8 mac80211_registered;
  945. /* eeprom -- this is in the card's little endian byte order */
  946. u8 *eeprom;
  947. struct il_eeprom_calib_info *calib_info;
  948. enum nl80211_iftype iw_mode;
  949. /* Last Rx'd beacon timestamp */
  950. u64 timestamp;
  951. union {
  952. #if defined(CONFIG_IWL3945) || defined(CONFIG_IWL3945_MODULE)
  953. struct {
  954. void *shared_virt;
  955. dma_addr_t shared_phys;
  956. struct delayed_work thermal_periodic;
  957. struct delayed_work rfkill_poll;
  958. struct il3945_notif_stats stats;
  959. #ifdef CONFIG_IWLEGACY_DEBUGFS
  960. struct il3945_notif_stats accum_stats;
  961. struct il3945_notif_stats delta_stats;
  962. struct il3945_notif_stats max_delta;
  963. #endif
  964. u32 sta_supp_rates;
  965. int last_rx_rssi; /* From Rx packet stats */
  966. /* Rx'd packet timing information */
  967. u32 last_beacon_time;
  968. u64 last_tsf;
  969. /*
  970. * each calibration channel group in the
  971. * EEPROM has a derived clip setting for
  972. * each rate.
  973. */
  974. const struct il3945_clip_group clip_groups[5];
  975. } _3945;
  976. #endif
  977. #if defined(CONFIG_IWL4965) || defined(CONFIG_IWL4965_MODULE)
  978. struct {
  979. struct il_rx_phy_res last_phy_res;
  980. bool last_phy_res_valid;
  981. struct completion firmware_loading_complete;
  982. /*
  983. * chain noise reset and gain commands are the
  984. * two extra calibration commands follows the standard
  985. * phy calibration commands
  986. */
  987. u8 phy_calib_chain_noise_reset_cmd;
  988. u8 phy_calib_chain_noise_gain_cmd;
  989. struct il_notif_stats stats;
  990. #ifdef CONFIG_IWLEGACY_DEBUGFS
  991. struct il_notif_stats accum_stats;
  992. struct il_notif_stats delta_stats;
  993. struct il_notif_stats max_delta;
  994. #endif
  995. } _4965;
  996. #endif
  997. };
  998. struct il_hw_params hw_params;
  999. u32 inta_mask;
  1000. struct workqueue_struct *workqueue;
  1001. struct work_struct restart;
  1002. struct work_struct scan_completed;
  1003. struct work_struct rx_replenish;
  1004. struct work_struct abort_scan;
  1005. struct il_rxon_context *beacon_ctx;
  1006. struct sk_buff *beacon_skb;
  1007. struct work_struct tx_flush;
  1008. struct tasklet_struct irq_tasklet;
  1009. struct delayed_work init_alive_start;
  1010. struct delayed_work alive_start;
  1011. struct delayed_work scan_check;
  1012. /* TX Power */
  1013. s8 tx_power_user_lmt;
  1014. s8 tx_power_device_lmt;
  1015. s8 tx_power_next;
  1016. #ifdef CONFIG_IWLEGACY_DEBUG
  1017. /* debugging info */
  1018. u32 debug_level; /* per device debugging will override global
  1019. il_debug_level if set */
  1020. #endif /* CONFIG_IWLEGACY_DEBUG */
  1021. #ifdef CONFIG_IWLEGACY_DEBUGFS
  1022. /* debugfs */
  1023. u16 tx_traffic_idx;
  1024. u16 rx_traffic_idx;
  1025. u8 *tx_traffic;
  1026. u8 *rx_traffic;
  1027. struct dentry *debugfs_dir;
  1028. u32 dbgfs_sram_offset, dbgfs_sram_len;
  1029. bool disable_ht40;
  1030. #endif /* CONFIG_IWLEGACY_DEBUGFS */
  1031. struct work_struct txpower_work;
  1032. u32 disable_sens_cal;
  1033. u32 disable_chain_noise_cal;
  1034. u32 disable_tx_power_cal;
  1035. struct work_struct run_time_calib_work;
  1036. struct timer_list stats_periodic;
  1037. struct timer_list watchdog;
  1038. bool hw_ready;
  1039. struct led_classdev led;
  1040. unsigned long blink_on, blink_off;
  1041. bool led_registered;
  1042. }; /*il_priv */
  1043. static inline void il_txq_ctx_activate(struct il_priv *il, int txq_id)
  1044. {
  1045. set_bit(txq_id, &il->txq_ctx_active_msk);
  1046. }
  1047. static inline void il_txq_ctx_deactivate(struct il_priv *il, int txq_id)
  1048. {
  1049. clear_bit(txq_id, &il->txq_ctx_active_msk);
  1050. }
  1051. #ifdef CONFIG_IWLEGACY_DEBUG
  1052. /*
  1053. * il_get_debug_level: Return active debug level for device
  1054. *
  1055. * Using sysfs it is possible to set per device debug level. This debug
  1056. * level will be used if set, otherwise the global debug level which can be
  1057. * set via module parameter is used.
  1058. */
  1059. static inline u32 il_get_debug_level(struct il_priv *il)
  1060. {
  1061. if (il->debug_level)
  1062. return il->debug_level;
  1063. else
  1064. return il_debug_level;
  1065. }
  1066. #else
  1067. static inline u32 il_get_debug_level(struct il_priv *il)
  1068. {
  1069. return il_debug_level;
  1070. }
  1071. #endif
  1072. static inline struct ieee80211_hdr *
  1073. il_tx_queue_get_hdr(struct il_priv *il,
  1074. int txq_id, int idx)
  1075. {
  1076. if (il->txq[txq_id].txb[idx].skb)
  1077. return (struct ieee80211_hdr *)il->txq[txq_id].
  1078. txb[idx].skb->data;
  1079. return NULL;
  1080. }
  1081. static inline struct il_rxon_context *
  1082. il_rxon_ctx_from_vif(struct ieee80211_vif *vif)
  1083. {
  1084. struct il_vif_priv *vif_priv = (void *)vif->drv_priv;
  1085. return vif_priv->ctx;
  1086. }
  1087. #define for_each_context(il, _ctx) \
  1088. for (_ctx = &il->ctx; _ctx == &il->ctx; _ctx++)
  1089. static inline int il_is_associated(struct il_priv *il)
  1090. {
  1091. return (il->ctx.active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
  1092. }
  1093. static inline int il_is_any_associated(struct il_priv *il)
  1094. {
  1095. return il_is_associated(il);
  1096. }
  1097. static inline int il_is_associated_ctx(struct il_rxon_context *ctx)
  1098. {
  1099. return (ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
  1100. }
  1101. static inline int il_is_channel_valid(const struct il_channel_info *ch_info)
  1102. {
  1103. if (ch_info == NULL)
  1104. return 0;
  1105. return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0;
  1106. }
  1107. static inline int il_is_channel_radar(const struct il_channel_info *ch_info)
  1108. {
  1109. return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0;
  1110. }
  1111. static inline u8 il_is_channel_a_band(const struct il_channel_info *ch_info)
  1112. {
  1113. return ch_info->band == IEEE80211_BAND_5GHZ;
  1114. }
  1115. static inline int
  1116. il_is_channel_passive(const struct il_channel_info *ch)
  1117. {
  1118. return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0;
  1119. }
  1120. static inline int
  1121. il_is_channel_ibss(const struct il_channel_info *ch)
  1122. {
  1123. return (ch->flags & EEPROM_CHANNEL_IBSS) ? 1 : 0;
  1124. }
  1125. static inline void
  1126. __il_free_pages(struct il_priv *il, struct page *page)
  1127. {
  1128. __free_pages(page, il->hw_params.rx_page_order);
  1129. il->alloc_rxb_page--;
  1130. }
  1131. static inline void il_free_pages(struct il_priv *il, unsigned long page)
  1132. {
  1133. free_pages(page, il->hw_params.rx_page_order);
  1134. il->alloc_rxb_page--;
  1135. }
  1136. #endif /* __il_dev_h__ */