iwl-dev.h 32 KB

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