iwl-3945.h 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2003 - 2007 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. * James P. Ketrenos <ipw2100-admin@linux.intel.com>
  23. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  24. *
  25. *****************************************************************************/
  26. #ifndef __iwl_3945_h__
  27. #define __iwl_3945_h__
  28. #include <linux/pci.h> /* for struct pci_device_id */
  29. #include <linux/kernel.h>
  30. #include <net/ieee80211_radiotap.h>
  31. struct iwl_priv;
  32. /* Hardware specific file defines the PCI IDs table for that hardware module */
  33. extern struct pci_device_id iwl_hw_card_ids[];
  34. #define DRV_NAME "iwl3945"
  35. #include "iwl-3945-hw.h"
  36. #include "iwl-prph.h"
  37. #include "iwl-3945-debug.h"
  38. /* Default noise level to report when noise measurement is not available.
  39. * This may be because we're:
  40. * 1) Not associated (4965, no beacon statistics being sent to driver)
  41. * 2) Scanning (noise measurement does not apply to associated channel)
  42. * 3) Receiving CCK (3945 delivers noise info only for OFDM frames)
  43. * Use default noise value of -127 ... this is below the range of measurable
  44. * Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user.
  45. * Also, -127 works better than 0 when averaging frames with/without
  46. * noise info (e.g. averaging might be done in app); measured dBm values are
  47. * always negative ... using a negative value as the default keeps all
  48. * averages within an s8's (used in some apps) range of negative values. */
  49. #define IWL_NOISE_MEAS_NOT_AVAILABLE (-127)
  50. /* Module parameters accessible from iwl-*.c */
  51. extern int iwl_param_hwcrypto;
  52. extern int iwl_param_queues_num;
  53. enum iwl_antenna {
  54. IWL_ANTENNA_DIVERSITY,
  55. IWL_ANTENNA_MAIN,
  56. IWL_ANTENNA_AUX
  57. };
  58. /*
  59. * RTS threshold here is total size [2347] minus 4 FCS bytes
  60. * Per spec:
  61. * a value of 0 means RTS on all data/management packets
  62. * a value > max MSDU size means no RTS
  63. * else RTS for data/management frames where MPDU is larger
  64. * than RTS value.
  65. */
  66. #define DEFAULT_RTS_THRESHOLD 2347U
  67. #define MIN_RTS_THRESHOLD 0U
  68. #define MAX_RTS_THRESHOLD 2347U
  69. #define MAX_MSDU_SIZE 2304U
  70. #define MAX_MPDU_SIZE 2346U
  71. #define DEFAULT_BEACON_INTERVAL 100U
  72. #define DEFAULT_SHORT_RETRY_LIMIT 7U
  73. #define DEFAULT_LONG_RETRY_LIMIT 4U
  74. struct iwl_rx_mem_buffer {
  75. dma_addr_t dma_addr;
  76. struct sk_buff *skb;
  77. struct list_head list;
  78. };
  79. struct iwl_rt_rx_hdr {
  80. struct ieee80211_radiotap_header rt_hdr;
  81. __le64 rt_tsf; /* TSF */
  82. u8 rt_flags; /* radiotap packet flags */
  83. u8 rt_rate; /* rate in 500kb/s */
  84. __le16 rt_channelMHz; /* channel in MHz */
  85. __le16 rt_chbitmask; /* channel bitfield */
  86. s8 rt_dbmsignal; /* signal in dBm, kluged to signed */
  87. s8 rt_dbmnoise;
  88. u8 rt_antenna; /* antenna number */
  89. u8 payload[0]; /* payload... */
  90. } __attribute__ ((packed));
  91. struct iwl_rt_tx_hdr {
  92. struct ieee80211_radiotap_header rt_hdr;
  93. u8 rt_rate; /* rate in 500kb/s */
  94. __le16 rt_channel; /* channel in mHz */
  95. __le16 rt_chbitmask; /* channel bitfield */
  96. s8 rt_dbmsignal; /* signal in dBm, kluged to signed */
  97. u8 rt_antenna; /* antenna number */
  98. u8 payload[0]; /* payload... */
  99. } __attribute__ ((packed));
  100. /*
  101. * Generic queue structure
  102. *
  103. * Contains common data for Rx and Tx queues
  104. */
  105. struct iwl_queue {
  106. int n_bd; /* number of BDs in this queue */
  107. int write_ptr; /* 1-st empty entry (index) host_w*/
  108. int read_ptr; /* last used entry (index) host_r*/
  109. dma_addr_t dma_addr; /* physical addr for BD's */
  110. int n_window; /* safe queue window */
  111. u32 id;
  112. int low_mark; /* low watermark, resume queue if free
  113. * space more than this */
  114. int high_mark; /* high watermark, stop queue if free
  115. * space less than this */
  116. } __attribute__ ((packed));
  117. #define MAX_NUM_OF_TBS (20)
  118. struct iwl_tx_info {
  119. struct ieee80211_tx_status status;
  120. struct sk_buff *skb[MAX_NUM_OF_TBS];
  121. };
  122. /**
  123. * struct iwl_tx_queue - Tx Queue for DMA
  124. * @need_update: need to update read/write index
  125. * @shed_retry: queue is HT AGG enabled
  126. *
  127. * Queue consists of circular buffer of BD's and required locking structures.
  128. */
  129. struct iwl_tx_queue {
  130. struct iwl_queue q;
  131. struct iwl_tfd_frame *bd;
  132. struct iwl_cmd *cmd;
  133. dma_addr_t dma_addr_cmd;
  134. struct iwl_tx_info *txb;
  135. int need_update;
  136. int sched_retry;
  137. int active;
  138. };
  139. #define IWL_NUM_SCAN_RATES (2)
  140. struct iwl_channel_tgd_info {
  141. u8 type;
  142. s8 max_power;
  143. };
  144. struct iwl_channel_tgh_info {
  145. s64 last_radar_time;
  146. };
  147. /* current Tx power values to use, one for each rate for each channel.
  148. * requested power is limited by:
  149. * -- regulatory EEPROM limits for this channel
  150. * -- hardware capabilities (clip-powers)
  151. * -- spectrum management
  152. * -- user preference (e.g. iwconfig)
  153. * when requested power is set, base power index must also be set. */
  154. struct iwl_channel_power_info {
  155. struct iwl_tx_power tpc; /* actual radio and DSP gain settings */
  156. s8 power_table_index; /* actual (compenst'd) index into gain table */
  157. s8 base_power_index; /* gain index for power at factory temp. */
  158. s8 requested_power; /* power (dBm) requested for this chnl/rate */
  159. };
  160. /* current scan Tx power values to use, one for each scan rate for each
  161. * channel. */
  162. struct iwl_scan_power_info {
  163. struct iwl_tx_power tpc; /* actual radio and DSP gain settings */
  164. s8 power_table_index; /* actual (compenst'd) index into gain table */
  165. s8 requested_power; /* scan pwr (dBm) requested for chnl/rate */
  166. };
  167. /* Channel unlock period is 15 seconds. If no beacon or probe response
  168. * has been received within 15 seconds on a locked channel then the channel
  169. * remains locked. */
  170. #define TX_UNLOCK_PERIOD 15
  171. /* CSA lock period is 15 seconds. If a CSA has been received on a channel in
  172. * the last 15 seconds, the channel is locked */
  173. #define CSA_LOCK_PERIOD 15
  174. /*
  175. * One for each channel, holds all channel setup data
  176. * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant
  177. * with one another!
  178. */
  179. #define IWL4965_MAX_RATE (33)
  180. struct iwl_channel_info {
  181. struct iwl_channel_tgd_info tgd;
  182. struct iwl_channel_tgh_info tgh;
  183. struct iwl_eeprom_channel eeprom; /* EEPROM regulatory limit */
  184. struct iwl_eeprom_channel fat_eeprom; /* EEPROM regulatory limit for
  185. * FAT channel */
  186. u8 channel; /* channel number */
  187. u8 flags; /* flags copied from EEPROM */
  188. s8 max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */
  189. s8 curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) */
  190. s8 min_power; /* always 0 */
  191. s8 scan_power; /* (dBm) regul. eeprom, direct scans, any rate */
  192. u8 group_index; /* 0-4, maps channel to group1/2/3/4/5 */
  193. u8 band_index; /* 0-4, maps channel to band1/2/3/4/5 */
  194. u8 phymode; /* MODE_IEEE80211{A,B,G} */
  195. /* Radio/DSP gain settings for each "normal" data Tx rate.
  196. * These include, in addition to RF and DSP gain, a few fields for
  197. * remembering/modifying gain settings (indexes). */
  198. struct iwl_channel_power_info power_info[IWL4965_MAX_RATE];
  199. /* Radio/DSP gain settings for each scan rate, for directed scans. */
  200. struct iwl_scan_power_info scan_pwr_info[IWL_NUM_SCAN_RATES];
  201. };
  202. struct iwl_clip_group {
  203. /* maximum power level to prevent clipping for each rate, derived by
  204. * us from this band's saturation power in EEPROM */
  205. const s8 clip_powers[IWL_MAX_RATES];
  206. };
  207. #include "iwl-3945-rs.h"
  208. #define IWL_TX_FIFO_AC0 0
  209. #define IWL_TX_FIFO_AC1 1
  210. #define IWL_TX_FIFO_AC2 2
  211. #define IWL_TX_FIFO_AC3 3
  212. #define IWL_TX_FIFO_HCCA_1 5
  213. #define IWL_TX_FIFO_HCCA_2 6
  214. #define IWL_TX_FIFO_NONE 7
  215. /* Minimum number of queues. MAX_NUM is defined in hw specific files */
  216. #define IWL_MIN_NUM_QUEUES 4
  217. /* Power management (not Tx power) structures */
  218. struct iwl_power_vec_entry {
  219. struct iwl_powertable_cmd cmd;
  220. u8 no_dtim;
  221. };
  222. #define IWL_POWER_RANGE_0 (0)
  223. #define IWL_POWER_RANGE_1 (1)
  224. #define IWL_POWER_MODE_CAM 0x00 /* Continuously Aware Mode, always on */
  225. #define IWL_POWER_INDEX_3 0x03
  226. #define IWL_POWER_INDEX_5 0x05
  227. #define IWL_POWER_AC 0x06
  228. #define IWL_POWER_BATTERY 0x07
  229. #define IWL_POWER_LIMIT 0x07
  230. #define IWL_POWER_MASK 0x0F
  231. #define IWL_POWER_ENABLED 0x10
  232. #define IWL_POWER_LEVEL(x) ((x) & IWL_POWER_MASK)
  233. struct iwl_power_mgr {
  234. spinlock_t lock;
  235. struct iwl_power_vec_entry pwr_range_0[IWL_POWER_AC];
  236. struct iwl_power_vec_entry pwr_range_1[IWL_POWER_AC];
  237. u8 active_index;
  238. u32 dtim_val;
  239. };
  240. #define IEEE80211_DATA_LEN 2304
  241. #define IEEE80211_4ADDR_LEN 30
  242. #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
  243. #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
  244. struct iwl_frame {
  245. union {
  246. struct ieee80211_hdr frame;
  247. struct iwl_tx_beacon_cmd beacon;
  248. u8 raw[IEEE80211_FRAME_LEN];
  249. u8 cmd[360];
  250. } u;
  251. struct list_head list;
  252. };
  253. #define SEQ_TO_QUEUE(x) ((x >> 8) & 0xbf)
  254. #define QUEUE_TO_SEQ(x) ((x & 0xbf) << 8)
  255. #define SEQ_TO_INDEX(x) (x & 0xff)
  256. #define INDEX_TO_SEQ(x) (x & 0xff)
  257. #define SEQ_HUGE_FRAME (0x4000)
  258. #define SEQ_RX_FRAME __constant_cpu_to_le16(0x8000)
  259. #define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
  260. #define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ)
  261. #define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4)
  262. enum {
  263. /* CMD_SIZE_NORMAL = 0, */
  264. CMD_SIZE_HUGE = (1 << 0),
  265. /* CMD_SYNC = 0, */
  266. CMD_ASYNC = (1 << 1),
  267. /* CMD_NO_SKB = 0, */
  268. CMD_WANT_SKB = (1 << 2),
  269. };
  270. struct iwl_cmd;
  271. struct iwl_priv;
  272. struct iwl_cmd_meta {
  273. struct iwl_cmd_meta *source;
  274. union {
  275. struct sk_buff *skb;
  276. int (*callback)(struct iwl_priv *priv,
  277. struct iwl_cmd *cmd, struct sk_buff *skb);
  278. } __attribute__ ((packed)) u;
  279. /* The CMD_SIZE_HUGE flag bit indicates that the command
  280. * structure is stored at the end of the shared queue memory. */
  281. u32 flags;
  282. } __attribute__ ((packed));
  283. struct iwl_cmd {
  284. struct iwl_cmd_meta meta;
  285. struct iwl_cmd_header hdr;
  286. union {
  287. struct iwl_addsta_cmd addsta;
  288. struct iwl_led_cmd led;
  289. u32 flags;
  290. u8 val8;
  291. u16 val16;
  292. u32 val32;
  293. struct iwl_bt_cmd bt;
  294. struct iwl_rxon_time_cmd rxon_time;
  295. struct iwl_powertable_cmd powertable;
  296. struct iwl_qosparam_cmd qosparam;
  297. struct iwl_tx_cmd tx;
  298. struct iwl_tx_beacon_cmd tx_beacon;
  299. struct iwl_rxon_assoc_cmd rxon_assoc;
  300. u8 *indirect;
  301. u8 payload[360];
  302. } __attribute__ ((packed)) cmd;
  303. } __attribute__ ((packed));
  304. struct iwl_host_cmd {
  305. u8 id;
  306. u16 len;
  307. struct iwl_cmd_meta meta;
  308. const void *data;
  309. };
  310. #define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl_cmd) - \
  311. sizeof(struct iwl_cmd_meta))
  312. /*
  313. * RX related structures and functions
  314. */
  315. #define RX_FREE_BUFFERS 64
  316. #define RX_LOW_WATERMARK 8
  317. #define SUP_RATE_11A_MAX_NUM_CHANNELS 8
  318. #define SUP_RATE_11B_MAX_NUM_CHANNELS 4
  319. #define SUP_RATE_11G_MAX_NUM_CHANNELS 12
  320. /**
  321. * struct iwl_rx_queue - Rx queue
  322. * @processed: Internal index to last handled Rx packet
  323. * @read: Shared index to newest available Rx buffer
  324. * @write: Shared index to oldest written Rx packet
  325. * @free_count: Number of pre-allocated buffers in rx_free
  326. * @rx_free: list of free SKBs for use
  327. * @rx_used: List of Rx buffers with no SKB
  328. * @need_update: flag to indicate we need to update read/write index
  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 processed;
  338. u32 read;
  339. u32 write;
  340. u32 free_count;
  341. struct list_head rx_free;
  342. struct list_head rx_used;
  343. int need_update;
  344. spinlock_t lock;
  345. };
  346. #define IWL_SUPPORTED_RATES_IE_LEN 8
  347. #define SCAN_INTERVAL 100
  348. #define MAX_A_CHANNELS 252
  349. #define MIN_A_CHANNELS 7
  350. #define MAX_B_CHANNELS 14
  351. #define MIN_B_CHANNELS 1
  352. #define STATUS_HCMD_ACTIVE 0 /* host command in progress */
  353. #define STATUS_INT_ENABLED 1
  354. #define STATUS_RF_KILL_HW 2
  355. #define STATUS_RF_KILL_SW 3
  356. #define STATUS_INIT 4
  357. #define STATUS_ALIVE 5
  358. #define STATUS_READY 6
  359. #define STATUS_TEMPERATURE 7
  360. #define STATUS_GEO_CONFIGURED 8
  361. #define STATUS_EXIT_PENDING 9
  362. #define STATUS_IN_SUSPEND 10
  363. #define STATUS_STATISTICS 11
  364. #define STATUS_SCANNING 12
  365. #define STATUS_SCAN_ABORTING 13
  366. #define STATUS_SCAN_HW 14
  367. #define STATUS_POWER_PMI 15
  368. #define STATUS_FW_ERROR 16
  369. #define MAX_TID_COUNT 9
  370. #define IWL_INVALID_RATE 0xFF
  371. #define IWL_INVALID_VALUE -1
  372. struct iwl_tid_data {
  373. u16 seq_number;
  374. };
  375. struct iwl_hw_key {
  376. enum ieee80211_key_alg alg;
  377. int keylen;
  378. u8 key[32];
  379. };
  380. union iwl_ht_rate_supp {
  381. u16 rates;
  382. struct {
  383. u8 siso_rate;
  384. u8 mimo_rate;
  385. };
  386. };
  387. #ifdef CONFIG_IWLWIFI_HT
  388. #define CFG_HT_RX_AMPDU_FACTOR_DEF (0x3)
  389. #define HT_IE_MAX_AMSDU_SIZE_4K (0)
  390. #define CFG_HT_MPDU_DENSITY_2USEC (0x5)
  391. #define CFG_HT_MPDU_DENSITY_DEF CFG_HT_MPDU_DENSITY_2USEC
  392. struct sta_ht_info {
  393. u8 is_ht;
  394. u16 rx_mimo_ps_mode;
  395. u16 tx_mimo_ps_mode;
  396. u16 control_channel;
  397. u8 max_amsdu_size;
  398. u8 ampdu_factor;
  399. u8 mpdu_density;
  400. u8 operating_mode;
  401. u8 supported_chan_width;
  402. u8 extension_chan_offset;
  403. u8 is_green_field;
  404. u8 sgf;
  405. u8 supp_rates[16];
  406. u8 tx_chan_width;
  407. u8 chan_width_cap;
  408. };
  409. #endif /*CONFIG_IWLWIFI_HT */
  410. #ifdef CONFIG_IWLWIFI_QOS
  411. union iwl_qos_capabity {
  412. struct {
  413. u8 edca_count:4; /* bit 0-3 */
  414. u8 q_ack:1; /* bit 4 */
  415. u8 queue_request:1; /* bit 5 */
  416. u8 txop_request:1; /* bit 6 */
  417. u8 reserved:1; /* bit 7 */
  418. } q_AP;
  419. struct {
  420. u8 acvo_APSD:1; /* bit 0 */
  421. u8 acvi_APSD:1; /* bit 1 */
  422. u8 ac_bk_APSD:1; /* bit 2 */
  423. u8 ac_be_APSD:1; /* bit 3 */
  424. u8 q_ack:1; /* bit 4 */
  425. u8 max_len:2; /* bit 5-6 */
  426. u8 more_data_ack:1; /* bit 7 */
  427. } q_STA;
  428. u8 val;
  429. };
  430. /* QoS structures */
  431. struct iwl_qos_info {
  432. int qos_enable;
  433. int qos_active;
  434. union iwl_qos_capabity qos_cap;
  435. struct iwl_qosparam_cmd def_qos_parm;
  436. };
  437. #endif /*CONFIG_IWLWIFI_QOS */
  438. #define STA_PS_STATUS_WAKE 0
  439. #define STA_PS_STATUS_SLEEP 1
  440. struct iwl_station_entry {
  441. struct iwl_addsta_cmd sta;
  442. struct iwl_tid_data tid[MAX_TID_COUNT];
  443. union {
  444. struct {
  445. u8 rate;
  446. u8 flags;
  447. } s;
  448. u16 rate_n_flags;
  449. } current_rate;
  450. u8 used;
  451. u8 ps_status;
  452. struct iwl_hw_key keyinfo;
  453. };
  454. /* one for each uCode image (inst/data, boot/init/runtime) */
  455. struct fw_desc {
  456. void *v_addr; /* access by driver */
  457. dma_addr_t p_addr; /* access by card's busmaster DMA */
  458. u32 len; /* bytes */
  459. };
  460. /* uCode file layout */
  461. struct iwl_ucode {
  462. __le32 ver; /* major/minor/subminor */
  463. __le32 inst_size; /* bytes of runtime instructions */
  464. __le32 data_size; /* bytes of runtime data */
  465. __le32 init_size; /* bytes of initialization instructions */
  466. __le32 init_data_size; /* bytes of initialization data */
  467. __le32 boot_size; /* bytes of bootstrap instructions */
  468. u8 data[0]; /* data in same order as "size" elements */
  469. };
  470. #define IWL_IBSS_MAC_HASH_SIZE 32
  471. struct iwl_ibss_seq {
  472. u8 mac[ETH_ALEN];
  473. u16 seq_num;
  474. u16 frag_num;
  475. unsigned long packet_time;
  476. struct list_head list;
  477. };
  478. struct iwl_driver_hw_info {
  479. u16 max_txq_num;
  480. u16 ac_queue_count;
  481. u16 tx_cmd_len;
  482. u16 max_rxq_size;
  483. u32 rx_buffer_size;
  484. u16 max_rxq_log;
  485. u8 max_stations;
  486. u8 bcast_sta_id;
  487. void *shared_virt;
  488. dma_addr_t shared_phys;
  489. };
  490. #define STA_FLG_RTS_MIMO_PROT_MSK __constant_cpu_to_le32(1 << 17)
  491. #define STA_FLG_AGG_MPDU_8US_MSK __constant_cpu_to_le32(1 << 18)
  492. #define STA_FLG_MAX_AGG_SIZE_POS (19)
  493. #define STA_FLG_MAX_AGG_SIZE_MSK __constant_cpu_to_le32(3 << 19)
  494. #define STA_FLG_FAT_EN_MSK __constant_cpu_to_le32(1 << 21)
  495. #define STA_FLG_MIMO_DIS_MSK __constant_cpu_to_le32(1 << 22)
  496. #define STA_FLG_AGG_MPDU_DENSITY_POS (23)
  497. #define STA_FLG_AGG_MPDU_DENSITY_MSK __constant_cpu_to_le32(7 << 23)
  498. #define HT_SHORT_GI_20MHZ_ONLY (1 << 0)
  499. #define HT_SHORT_GI_40MHZ_ONLY (1 << 1)
  500. #define IWL_RX_HDR(x) ((struct iwl_rx_frame_hdr *)(\
  501. x->u.rx_frame.stats.payload + \
  502. x->u.rx_frame.stats.phy_count))
  503. #define IWL_RX_END(x) ((struct iwl_rx_frame_end *)(\
  504. IWL_RX_HDR(x)->payload + \
  505. le16_to_cpu(IWL_RX_HDR(x)->len)))
  506. #define IWL_RX_STATS(x) (&x->u.rx_frame.stats)
  507. #define IWL_RX_DATA(x) (IWL_RX_HDR(x)->payload)
  508. /******************************************************************************
  509. *
  510. * Functions implemented in iwl-base.c which are forward declared here
  511. * for use by iwl-*.c
  512. *
  513. *****************************************************************************/
  514. struct iwl_addsta_cmd;
  515. extern int iwl_send_add_station(struct iwl_priv *priv,
  516. struct iwl_addsta_cmd *sta, u8 flags);
  517. extern u8 iwl_add_station(struct iwl_priv *priv, const u8 *bssid,
  518. int is_ap, u8 flags);
  519. extern int iwl_is_network_packet(struct iwl_priv *priv,
  520. struct ieee80211_hdr *header);
  521. extern int iwl_power_init_handle(struct iwl_priv *priv);
  522. extern int iwl_eeprom_init(struct iwl_priv *priv);
  523. #ifdef CONFIG_IWLWIFI_DEBUG
  524. extern void iwl_report_frame(struct iwl_priv *priv,
  525. struct iwl_rx_packet *pkt,
  526. struct ieee80211_hdr *header, int group100);
  527. #else
  528. static inline void iwl_report_frame(struct iwl_priv *priv,
  529. struct iwl_rx_packet *pkt,
  530. struct ieee80211_hdr *header,
  531. int group100) {}
  532. #endif
  533. extern void iwl_handle_data_packet_monitor(struct iwl_priv *priv,
  534. struct iwl_rx_mem_buffer *rxb,
  535. void *data, short len,
  536. struct ieee80211_rx_status *stats,
  537. u16 phy_flags);
  538. extern int is_duplicate_packet(struct iwl_priv *priv, struct ieee80211_hdr
  539. *header);
  540. extern int iwl_rx_queue_alloc(struct iwl_priv *priv);
  541. extern void iwl_rx_queue_reset(struct iwl_priv *priv,
  542. struct iwl_rx_queue *rxq);
  543. extern int iwl_calc_db_from_ratio(int sig_ratio);
  544. extern int iwl_calc_sig_qual(int rssi_dbm, int noise_dbm);
  545. extern int iwl_tx_queue_init(struct iwl_priv *priv,
  546. struct iwl_tx_queue *txq, int count, u32 id);
  547. extern void iwl_rx_replenish(void *data);
  548. extern void iwl_tx_queue_free(struct iwl_priv *priv, struct iwl_tx_queue *txq);
  549. extern int iwl_send_cmd_pdu(struct iwl_priv *priv, u8 id, u16 len,
  550. const void *data);
  551. extern int __must_check iwl_send_cmd(struct iwl_priv *priv,
  552. struct iwl_host_cmd *cmd);
  553. extern unsigned int iwl_fill_beacon_frame(struct iwl_priv *priv,
  554. struct ieee80211_hdr *hdr,
  555. const u8 *dest, int left);
  556. extern int iwl_rx_queue_update_write_ptr(struct iwl_priv *priv,
  557. struct iwl_rx_queue *q);
  558. extern int iwl_send_statistics_request(struct iwl_priv *priv);
  559. extern void iwl_set_decrypted_flag(struct iwl_priv *priv, struct sk_buff *skb,
  560. u32 decrypt_res,
  561. struct ieee80211_rx_status *stats);
  562. extern const u8 BROADCAST_ADDR[ETH_ALEN];
  563. /*
  564. * Currently used by iwl-3945-rs... look at restructuring so that it doesn't
  565. * call this... todo... fix that.
  566. */
  567. extern u8 iwl_sync_station(struct iwl_priv *priv, int sta_id,
  568. u16 tx_rate, u8 flags);
  569. /******************************************************************************
  570. *
  571. * Functions implemented in iwl-[34]*.c which are forward declared here
  572. * for use by iwl-base.c
  573. *
  574. * NOTE: The implementation of these functions are hardware specific
  575. * which is why they are in the hardware specific files (vs. iwl-base.c)
  576. *
  577. * Naming convention --
  578. * iwl_ <-- Its part of iwlwifi (should be changed to iwl_)
  579. * iwl_hw_ <-- Hardware specific (implemented in iwl-XXXX.c by all HW)
  580. * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
  581. * iwl_bg_ <-- Called from work queue context
  582. * iwl_mac_ <-- mac80211 callback
  583. *
  584. ****************************************************************************/
  585. extern void iwl_hw_rx_handler_setup(struct iwl_priv *priv);
  586. extern void iwl_hw_setup_deferred_work(struct iwl_priv *priv);
  587. extern void iwl_hw_cancel_deferred_work(struct iwl_priv *priv);
  588. extern int iwl_hw_rxq_stop(struct iwl_priv *priv);
  589. extern int iwl_hw_set_hw_setting(struct iwl_priv *priv);
  590. extern int iwl_hw_nic_init(struct iwl_priv *priv);
  591. extern int iwl_hw_nic_stop_master(struct iwl_priv *priv);
  592. extern void iwl_hw_txq_ctx_free(struct iwl_priv *priv);
  593. extern void iwl_hw_txq_ctx_stop(struct iwl_priv *priv);
  594. extern int iwl_hw_nic_reset(struct iwl_priv *priv);
  595. extern int iwl_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, void *tfd,
  596. dma_addr_t addr, u16 len);
  597. extern int iwl_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq);
  598. extern int iwl_hw_get_temperature(struct iwl_priv *priv);
  599. extern int iwl_hw_tx_queue_init(struct iwl_priv *priv,
  600. struct iwl_tx_queue *txq);
  601. extern unsigned int iwl_hw_get_beacon_cmd(struct iwl_priv *priv,
  602. struct iwl_frame *frame, u8 rate);
  603. extern int iwl_hw_get_rx_read(struct iwl_priv *priv);
  604. extern void iwl_hw_build_tx_cmd_rate(struct iwl_priv *priv,
  605. struct iwl_cmd *cmd,
  606. struct ieee80211_tx_control *ctrl,
  607. struct ieee80211_hdr *hdr,
  608. int sta_id, int tx_id);
  609. extern int iwl_hw_reg_send_txpower(struct iwl_priv *priv);
  610. extern int iwl_hw_reg_set_txpower(struct iwl_priv *priv, s8 power);
  611. extern void iwl_hw_rx_statistics(struct iwl_priv *priv,
  612. struct iwl_rx_mem_buffer *rxb);
  613. extern void iwl_disable_events(struct iwl_priv *priv);
  614. extern int iwl4965_get_temperature(const struct iwl_priv *priv);
  615. /**
  616. * iwl_hw_find_station - Find station id for a given BSSID
  617. * @bssid: MAC address of station ID to find
  618. *
  619. * NOTE: This should not be hardware specific but the code has
  620. * not yet been merged into a single common layer for managing the
  621. * station tables.
  622. */
  623. extern u8 iwl_hw_find_station(struct iwl_priv *priv, const u8 *bssid);
  624. extern int iwl_hw_channel_switch(struct iwl_priv *priv, u16 channel);
  625. /*
  626. * Forward declare iwl-3945.c functions for iwl-base.c
  627. */
  628. extern int iwl_eeprom_acquire_semaphore(struct iwl_priv *priv);
  629. extern __le32 iwl3945_get_antenna_flags(const struct iwl_priv *priv);
  630. extern int iwl3945_init_hw_rate_table(struct iwl_priv *priv);
  631. extern void iwl3945_reg_txpower_periodic(struct iwl_priv *priv);
  632. extern int iwl3945_txpower_set_from_eeprom(struct iwl_priv *priv);
  633. extern u8 iwl3945_sync_sta(struct iwl_priv *priv, int sta_id,
  634. u16 tx_rate, u8 flags);
  635. #ifdef CONFIG_IWLWIFI_SPECTRUM_MEASUREMENT
  636. enum {
  637. MEASUREMENT_READY = (1 << 0),
  638. MEASUREMENT_ACTIVE = (1 << 1),
  639. };
  640. #endif
  641. struct iwl_priv {
  642. /* ieee device used by generic ieee processing code */
  643. struct ieee80211_hw *hw;
  644. struct ieee80211_channel *ieee_channels;
  645. struct ieee80211_rate *ieee_rates;
  646. /* temporary frame storage list */
  647. struct list_head free_frames;
  648. int frames_count;
  649. u8 phymode;
  650. int alloc_rxb_skb;
  651. void (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv,
  652. struct iwl_rx_mem_buffer *rxb);
  653. const struct ieee80211_hw_mode *modes;
  654. #ifdef CONFIG_IWLWIFI_SPECTRUM_MEASUREMENT
  655. /* spectrum measurement report caching */
  656. struct iwl_spectrum_notification measure_report;
  657. u8 measurement_status;
  658. #endif
  659. /* ucode beacon time */
  660. u32 ucode_beacon_time;
  661. /* we allocate array of iwl_channel_info for NIC's valid channels.
  662. * Access via channel # using indirect index array */
  663. struct iwl_channel_info *channel_info; /* channel info array */
  664. u8 channel_count; /* # of channels */
  665. /* each calibration channel group in the EEPROM has a derived
  666. * clip setting for each rate. */
  667. const struct iwl_clip_group clip_groups[5];
  668. /* thermal calibration */
  669. s32 temperature; /* degrees Kelvin */
  670. s32 last_temperature;
  671. /* Scan related variables */
  672. unsigned long last_scan_jiffies;
  673. unsigned long scan_start;
  674. unsigned long scan_pass_start;
  675. unsigned long scan_start_tsf;
  676. int scan_bands;
  677. int one_direct_scan;
  678. u8 direct_ssid_len;
  679. u8 direct_ssid[IW_ESSID_MAX_SIZE];
  680. struct iwl_scan_cmd *scan;
  681. u8 only_active_channel;
  682. /* spinlock */
  683. spinlock_t lock; /* protect general shared data */
  684. spinlock_t hcmd_lock; /* protect hcmd */
  685. struct mutex mutex;
  686. /* basic pci-network driver stuff */
  687. struct pci_dev *pci_dev;
  688. /* pci hardware address support */
  689. void __iomem *hw_base;
  690. /* uCode images, save to reload in case of failure */
  691. struct fw_desc ucode_code; /* runtime inst */
  692. struct fw_desc ucode_data; /* runtime data original */
  693. struct fw_desc ucode_data_backup; /* runtime data save/restore */
  694. struct fw_desc ucode_init; /* initialization inst */
  695. struct fw_desc ucode_init_data; /* initialization data */
  696. struct fw_desc ucode_boot; /* bootstrap inst */
  697. struct iwl_rxon_time_cmd rxon_timing;
  698. /* We declare this const so it can only be
  699. * changed via explicit cast within the
  700. * routines that actually update the physical
  701. * hardware */
  702. const struct iwl_rxon_cmd active_rxon;
  703. struct iwl_rxon_cmd staging_rxon;
  704. int error_recovering;
  705. struct iwl_rxon_cmd recovery_rxon;
  706. /* 1st responses from initialize and runtime uCode images.
  707. * 4965's initialize alive response contains some calibration data. */
  708. struct iwl_init_alive_resp card_alive_init;
  709. struct iwl_alive_resp card_alive;
  710. #ifdef LED
  711. /* LED related variables */
  712. struct iwl_activity_blink activity;
  713. unsigned long led_packets;
  714. int led_state;
  715. #endif
  716. u16 active_rate;
  717. u16 active_rate_basic;
  718. u8 call_post_assoc_from_beacon;
  719. u8 assoc_station_added;
  720. /* Rate scaling data */
  721. s8 data_retry_limit;
  722. u8 retry_rate;
  723. wait_queue_head_t wait_command_queue;
  724. int activity_timer_active;
  725. /* Rx and Tx DMA processing queues */
  726. struct iwl_rx_queue rxq;
  727. struct iwl_tx_queue txq[IWL_MAX_NUM_QUEUES];
  728. unsigned long status;
  729. u32 config;
  730. int last_rx_rssi; /* From Rx packet statisitics */
  731. int last_rx_noise; /* From beacon statistics */
  732. struct iwl_power_mgr power_data;
  733. struct iwl_notif_statistics statistics;
  734. unsigned long last_statistics_time;
  735. /* context information */
  736. u8 essid[IW_ESSID_MAX_SIZE];
  737. u8 essid_len;
  738. u16 rates_mask;
  739. u32 power_mode;
  740. u32 antenna;
  741. u8 bssid[ETH_ALEN];
  742. u16 rts_threshold;
  743. u8 mac_addr[ETH_ALEN];
  744. /*station table variables */
  745. spinlock_t sta_lock;
  746. int num_stations;
  747. struct iwl_station_entry stations[IWL_STATION_COUNT];
  748. /* Indication if ieee80211_ops->open has been called */
  749. int is_open;
  750. u8 mac80211_registered;
  751. int is_abg;
  752. u32 notif_missed_beacons;
  753. /* Rx'd packet timing information */
  754. u32 last_beacon_time;
  755. u64 last_tsf;
  756. /* Duplicate packet detection */
  757. u16 last_seq_num;
  758. u16 last_frag_num;
  759. unsigned long last_packet_time;
  760. struct list_head ibss_mac_hash[IWL_IBSS_MAC_HASH_SIZE];
  761. /* eeprom */
  762. struct iwl_eeprom eeprom;
  763. int iw_mode;
  764. struct sk_buff *ibss_beacon;
  765. /* Last Rx'd beacon timestamp */
  766. u32 timestamp0;
  767. u32 timestamp1;
  768. u16 beacon_int;
  769. struct iwl_driver_hw_info hw_setting;
  770. int interface_id;
  771. /* Current association information needed to configure the
  772. * hardware */
  773. u16 assoc_id;
  774. u16 assoc_capability;
  775. u8 ps_mode;
  776. #ifdef CONFIG_IWLWIFI_QOS
  777. struct iwl_qos_info qos_data;
  778. #endif /*CONFIG_IWLWIFI_QOS */
  779. struct workqueue_struct *workqueue;
  780. struct work_struct up;
  781. struct work_struct restart;
  782. struct work_struct calibrated_work;
  783. struct work_struct scan_completed;
  784. struct work_struct rx_replenish;
  785. struct work_struct rf_kill;
  786. struct work_struct abort_scan;
  787. struct work_struct update_link_led;
  788. struct work_struct auth_work;
  789. struct work_struct report_work;
  790. struct work_struct request_scan;
  791. struct work_struct beacon_update;
  792. struct tasklet_struct irq_tasklet;
  793. struct delayed_work init_alive_start;
  794. struct delayed_work alive_start;
  795. struct delayed_work activity_timer;
  796. struct delayed_work thermal_periodic;
  797. struct delayed_work gather_stats;
  798. struct delayed_work scan_check;
  799. struct delayed_work post_associate;
  800. #define IWL_DEFAULT_TX_POWER 0x0F
  801. s8 user_txpower_limit;
  802. s8 max_channel_txpower_limit;
  803. #ifdef CONFIG_PM
  804. u32 pm_state[16];
  805. #endif
  806. #ifdef CONFIG_IWLWIFI_DEBUG
  807. /* debugging info */
  808. u32 framecnt_to_us;
  809. atomic_t restrict_refcnt;
  810. #endif
  811. }; /*iwl_priv */
  812. static inline int iwl_is_associated(struct iwl_priv *priv)
  813. {
  814. return (priv->active_rxon.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
  815. }
  816. static inline int is_channel_valid(const struct iwl_channel_info *ch_info)
  817. {
  818. if (ch_info == NULL)
  819. return 0;
  820. return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0;
  821. }
  822. static inline int is_channel_narrow(const struct iwl_channel_info *ch_info)
  823. {
  824. return (ch_info->flags & EEPROM_CHANNEL_NARROW) ? 1 : 0;
  825. }
  826. static inline int is_channel_radar(const struct iwl_channel_info *ch_info)
  827. {
  828. return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0;
  829. }
  830. static inline u8 is_channel_a_band(const struct iwl_channel_info *ch_info)
  831. {
  832. return ch_info->phymode == MODE_IEEE80211A;
  833. }
  834. static inline u8 is_channel_bg_band(const struct iwl_channel_info *ch_info)
  835. {
  836. return ((ch_info->phymode == MODE_IEEE80211B) ||
  837. (ch_info->phymode == MODE_IEEE80211G));
  838. }
  839. static inline int is_channel_passive(const struct iwl_channel_info *ch)
  840. {
  841. return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0;
  842. }
  843. static inline int is_channel_ibss(const struct iwl_channel_info *ch)
  844. {
  845. return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0;
  846. }
  847. extern const struct iwl_channel_info *iwl_get_channel_info(
  848. const struct iwl_priv *priv, int phymode, u16 channel);
  849. /* Requires full declaration of iwl_priv before including */
  850. #include "iwl-3945-io.h"
  851. #endif