iwl-4965.h 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2003 - 2008 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. /*
  27. * Please use this file (iwl-4965.h) for driver implementation definitions.
  28. * Please use iwl-4965-commands.h for uCode API definitions.
  29. * Please use iwl-4965-hw.h for hardware-related definitions.
  30. */
  31. #ifndef __iwl_4965_h__
  32. #define __iwl_4965_h__
  33. #include <linux/pci.h> /* for struct pci_device_id */
  34. #include <linux/kernel.h>
  35. #include <net/ieee80211_radiotap.h>
  36. #define DRV_NAME "iwl4965"
  37. #include "iwl-rfkill.h"
  38. #include "iwl-eeprom.h"
  39. #include "iwl-4965-hw.h"
  40. #include "iwl-csr.h"
  41. #include "iwl-prph.h"
  42. #include "iwl-debug.h"
  43. #include "iwl-led.h"
  44. /* configuration for the iwl4965 */
  45. extern struct iwl_cfg iwl4965_agn_cfg;
  46. /* Change firmware file name, using "-" and incrementing number,
  47. * *only* when uCode interface or architecture changes so that it
  48. * is not compatible with earlier drivers.
  49. * This number will also appear in << 8 position of 1st dword of uCode file */
  50. #define IWL4965_UCODE_API "-1"
  51. /* Default noise level to report when noise measurement is not available.
  52. * This may be because we're:
  53. * 1) Not associated (4965, no beacon statistics being sent to driver)
  54. * 2) Scanning (noise measurement does not apply to associated channel)
  55. * 3) Receiving CCK (3945 delivers noise info only for OFDM frames)
  56. * Use default noise value of -127 ... this is below the range of measurable
  57. * Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user.
  58. * Also, -127 works better than 0 when averaging frames with/without
  59. * noise info (e.g. averaging might be done in app); measured dBm values are
  60. * always negative ... using a negative value as the default keeps all
  61. * averages within an s8's (used in some apps) range of negative values. */
  62. #define IWL_NOISE_MEAS_NOT_AVAILABLE (-127)
  63. enum iwl4965_antenna {
  64. IWL_ANTENNA_DIVERSITY,
  65. IWL_ANTENNA_MAIN,
  66. IWL_ANTENNA_AUX
  67. };
  68. /*
  69. * RTS threshold here is total size [2347] minus 4 FCS bytes
  70. * Per spec:
  71. * a value of 0 means RTS on all data/management packets
  72. * a value > max MSDU size means no RTS
  73. * else RTS for data/management frames where MPDU is larger
  74. * than RTS value.
  75. */
  76. #define DEFAULT_RTS_THRESHOLD 2347U
  77. #define MIN_RTS_THRESHOLD 0U
  78. #define MAX_RTS_THRESHOLD 2347U
  79. #define MAX_MSDU_SIZE 2304U
  80. #define MAX_MPDU_SIZE 2346U
  81. #define DEFAULT_BEACON_INTERVAL 100U
  82. #define DEFAULT_SHORT_RETRY_LIMIT 7U
  83. #define DEFAULT_LONG_RETRY_LIMIT 4U
  84. struct iwl4965_rx_mem_buffer {
  85. dma_addr_t dma_addr;
  86. struct sk_buff *skb;
  87. struct list_head list;
  88. };
  89. /*
  90. * Generic queue structure
  91. *
  92. * Contains common data for Rx and Tx queues
  93. */
  94. struct iwl4965_queue {
  95. int n_bd; /* number of BDs in this queue */
  96. int write_ptr; /* 1-st empty entry (index) host_w*/
  97. int read_ptr; /* last used entry (index) host_r*/
  98. dma_addr_t dma_addr; /* physical addr for BD's */
  99. int n_window; /* safe queue window */
  100. u32 id;
  101. int low_mark; /* low watermark, resume queue if free
  102. * space more than this */
  103. int high_mark; /* high watermark, stop queue if free
  104. * space less than this */
  105. } __attribute__ ((packed));
  106. #define MAX_NUM_OF_TBS (20)
  107. /* One for each TFD */
  108. struct iwl4965_tx_info {
  109. struct ieee80211_tx_status status;
  110. struct sk_buff *skb[MAX_NUM_OF_TBS];
  111. };
  112. /**
  113. * struct iwl4965_tx_queue - Tx Queue for DMA
  114. * @q: generic Rx/Tx queue descriptor
  115. * @bd: base of circular buffer of TFDs
  116. * @cmd: array of command/Tx buffers
  117. * @dma_addr_cmd: physical address of cmd/tx buffer array
  118. * @txb: array of per-TFD driver data
  119. * @need_update: indicates need to update read/write index
  120. * @sched_retry: indicates queue is high-throughput aggregation (HT AGG) enabled
  121. *
  122. * A Tx queue consists of circular buffer of BDs (a.k.a. TFDs, transmit frame
  123. * descriptors) and required locking structures.
  124. */
  125. struct iwl4965_tx_queue {
  126. struct iwl4965_queue q;
  127. struct iwl4965_tfd_frame *bd;
  128. struct iwl_cmd *cmd;
  129. dma_addr_t dma_addr_cmd;
  130. struct iwl4965_tx_info *txb;
  131. int need_update;
  132. int sched_retry;
  133. int active;
  134. };
  135. #define IWL_NUM_SCAN_RATES (2)
  136. struct iwl4965_channel_tgd_info {
  137. u8 type;
  138. s8 max_power;
  139. };
  140. struct iwl4965_channel_tgh_info {
  141. s64 last_radar_time;
  142. };
  143. /* current Tx power values to use, one for each rate for each channel.
  144. * requested power is limited by:
  145. * -- regulatory EEPROM limits for this channel
  146. * -- hardware capabilities (clip-powers)
  147. * -- spectrum management
  148. * -- user preference (e.g. iwconfig)
  149. * when requested power is set, base power index must also be set. */
  150. struct iwl4965_channel_power_info {
  151. struct iwl4965_tx_power tpc; /* actual radio and DSP gain settings */
  152. s8 power_table_index; /* actual (compenst'd) index into gain table */
  153. s8 base_power_index; /* gain index for power at factory temp. */
  154. s8 requested_power; /* power (dBm) requested for this chnl/rate */
  155. };
  156. /* current scan Tx power values to use, one for each scan rate for each
  157. * channel. */
  158. struct iwl4965_scan_power_info {
  159. struct iwl4965_tx_power tpc; /* actual radio and DSP gain settings */
  160. s8 power_table_index; /* actual (compenst'd) index into gain table */
  161. s8 requested_power; /* scan pwr (dBm) requested for chnl/rate */
  162. };
  163. /* For fat_extension_channel */
  164. enum {
  165. HT_IE_EXT_CHANNEL_NONE = 0,
  166. HT_IE_EXT_CHANNEL_ABOVE,
  167. HT_IE_EXT_CHANNEL_INVALID,
  168. HT_IE_EXT_CHANNEL_BELOW,
  169. HT_IE_EXT_CHANNEL_MAX
  170. };
  171. /*
  172. * One for each channel, holds all channel setup data
  173. * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant
  174. * with one another!
  175. */
  176. #define IWL4965_MAX_RATE (33)
  177. struct iwl_channel_info {
  178. struct iwl4965_channel_tgd_info tgd;
  179. struct iwl4965_channel_tgh_info tgh;
  180. struct iwl4965_eeprom_channel eeprom; /* EEPROM regulatory limit */
  181. struct iwl4965_eeprom_channel fat_eeprom; /* EEPROM regulatory limit for
  182. * FAT channel */
  183. u8 channel; /* channel number */
  184. u8 flags; /* flags copied from EEPROM */
  185. s8 max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */
  186. s8 curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) limit */
  187. s8 min_power; /* always 0 */
  188. s8 scan_power; /* (dBm) regul. eeprom, direct scans, any rate */
  189. u8 group_index; /* 0-4, maps channel to group1/2/3/4/5 */
  190. u8 band_index; /* 0-4, maps channel to band1/2/3/4/5 */
  191. enum ieee80211_band band;
  192. /* Radio/DSP gain settings for each "normal" data Tx rate.
  193. * These include, in addition to RF and DSP gain, a few fields for
  194. * remembering/modifying gain settings (indexes). */
  195. struct iwl4965_channel_power_info power_info[IWL4965_MAX_RATE];
  196. /* FAT channel info */
  197. s8 fat_max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */
  198. s8 fat_curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) */
  199. s8 fat_min_power; /* always 0 */
  200. s8 fat_scan_power; /* (dBm) eeprom, direct scans, any rate */
  201. u8 fat_flags; /* flags copied from EEPROM */
  202. u8 fat_extension_channel; /* HT_IE_EXT_CHANNEL_* */
  203. /* Radio/DSP gain settings for each scan rate, for directed scans. */
  204. struct iwl4965_scan_power_info scan_pwr_info[IWL_NUM_SCAN_RATES];
  205. };
  206. struct iwl4965_clip_group {
  207. /* maximum power level to prevent clipping for each rate, derived by
  208. * us from this band's saturation power in EEPROM */
  209. const s8 clip_powers[IWL_MAX_RATES];
  210. };
  211. #include "iwl-4965-rs.h"
  212. #define IWL_TX_FIFO_AC0 0
  213. #define IWL_TX_FIFO_AC1 1
  214. #define IWL_TX_FIFO_AC2 2
  215. #define IWL_TX_FIFO_AC3 3
  216. #define IWL_TX_FIFO_HCCA_1 5
  217. #define IWL_TX_FIFO_HCCA_2 6
  218. #define IWL_TX_FIFO_NONE 7
  219. /* Minimum number of queues. MAX_NUM is defined in hw specific files */
  220. #define IWL_MIN_NUM_QUEUES 4
  221. /* Power management (not Tx power) structures */
  222. enum iwl_pwr_src {
  223. IWL_PWR_SRC_VMAIN,
  224. IWL_PWR_SRC_VAUX,
  225. };
  226. struct iwl4965_power_vec_entry {
  227. struct iwl4965_powertable_cmd cmd;
  228. u8 no_dtim;
  229. };
  230. #define IWL_POWER_RANGE_0 (0)
  231. #define IWL_POWER_RANGE_1 (1)
  232. #define IWL_POWER_MODE_CAM 0x00 /* Continuously Aware Mode, always on */
  233. #define IWL_POWER_INDEX_3 0x03
  234. #define IWL_POWER_INDEX_5 0x05
  235. #define IWL_POWER_AC 0x06
  236. #define IWL_POWER_BATTERY 0x07
  237. #define IWL_POWER_LIMIT 0x07
  238. #define IWL_POWER_MASK 0x0F
  239. #define IWL_POWER_ENABLED 0x10
  240. #define IWL_POWER_LEVEL(x) ((x) & IWL_POWER_MASK)
  241. struct iwl4965_power_mgr {
  242. spinlock_t lock;
  243. struct iwl4965_power_vec_entry pwr_range_0[IWL_POWER_AC];
  244. struct iwl4965_power_vec_entry pwr_range_1[IWL_POWER_AC];
  245. u8 active_index;
  246. u32 dtim_val;
  247. };
  248. #define IEEE80211_DATA_LEN 2304
  249. #define IEEE80211_4ADDR_LEN 30
  250. #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
  251. #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
  252. struct iwl4965_frame {
  253. union {
  254. struct ieee80211_hdr frame;
  255. struct iwl4965_tx_beacon_cmd beacon;
  256. u8 raw[IEEE80211_FRAME_LEN];
  257. u8 cmd[360];
  258. } u;
  259. struct list_head list;
  260. };
  261. #define SEQ_TO_QUEUE(x) ((x >> 8) & 0xbf)
  262. #define QUEUE_TO_SEQ(x) ((x & 0xbf) << 8)
  263. #define SEQ_TO_INDEX(x) ((u8)(x & 0xff))
  264. #define INDEX_TO_SEQ(x) ((u8)(x & 0xff))
  265. #define SEQ_HUGE_FRAME (0x4000)
  266. #define SEQ_RX_FRAME __constant_cpu_to_le16(0x8000)
  267. #define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
  268. #define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ)
  269. #define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4)
  270. enum {
  271. /* CMD_SIZE_NORMAL = 0, */
  272. CMD_SIZE_HUGE = (1 << 0),
  273. /* CMD_SYNC = 0, */
  274. CMD_ASYNC = (1 << 1),
  275. /* CMD_NO_SKB = 0, */
  276. CMD_WANT_SKB = (1 << 2),
  277. };
  278. struct iwl_cmd;
  279. struct iwl_priv;
  280. struct iwl_cmd_meta {
  281. struct iwl_cmd_meta *source;
  282. union {
  283. struct sk_buff *skb;
  284. int (*callback)(struct iwl_priv *priv,
  285. struct iwl_cmd *cmd, struct sk_buff *skb);
  286. } __attribute__ ((packed)) u;
  287. /* The CMD_SIZE_HUGE flag bit indicates that the command
  288. * structure is stored at the end of the shared queue memory. */
  289. u32 flags;
  290. } __attribute__ ((packed));
  291. /**
  292. * struct iwl_cmd
  293. *
  294. * For allocation of the command and tx queues, this establishes the overall
  295. * size of the largest command we send to uCode, except for a scan command
  296. * (which is relatively huge; space is allocated separately).
  297. */
  298. struct iwl_cmd {
  299. struct iwl_cmd_meta meta; /* driver data */
  300. struct iwl_cmd_header hdr; /* uCode API */
  301. union {
  302. struct iwl4965_addsta_cmd addsta;
  303. struct iwl4965_led_cmd led;
  304. u32 flags;
  305. u8 val8;
  306. u16 val16;
  307. u32 val32;
  308. struct iwl4965_bt_cmd bt;
  309. struct iwl4965_rxon_time_cmd rxon_time;
  310. struct iwl4965_powertable_cmd powertable;
  311. struct iwl4965_qosparam_cmd qosparam;
  312. struct iwl4965_tx_cmd tx;
  313. struct iwl4965_tx_beacon_cmd tx_beacon;
  314. struct iwl4965_rxon_assoc_cmd rxon_assoc;
  315. u8 *indirect;
  316. u8 payload[360];
  317. } __attribute__ ((packed)) cmd;
  318. } __attribute__ ((packed));
  319. struct iwl_host_cmd {
  320. u8 id;
  321. u16 len;
  322. struct iwl_cmd_meta meta;
  323. const void *data;
  324. };
  325. #define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl_cmd) - \
  326. sizeof(struct iwl_cmd_meta))
  327. /*
  328. * RX related structures and functions
  329. */
  330. #define RX_FREE_BUFFERS 64
  331. #define RX_LOW_WATERMARK 8
  332. #define SUP_RATE_11A_MAX_NUM_CHANNELS 8
  333. #define SUP_RATE_11B_MAX_NUM_CHANNELS 4
  334. #define SUP_RATE_11G_MAX_NUM_CHANNELS 12
  335. /**
  336. * struct iwl4965_rx_queue - Rx queue
  337. * @processed: Internal index to last handled Rx packet
  338. * @read: Shared index to newest available Rx buffer
  339. * @write: Shared index to oldest written Rx packet
  340. * @free_count: Number of pre-allocated buffers in rx_free
  341. * @rx_free: list of free SKBs for use
  342. * @rx_used: List of Rx buffers with no SKB
  343. * @need_update: flag to indicate we need to update read/write index
  344. *
  345. * NOTE: rx_free and rx_used are used as a FIFO for iwl4965_rx_mem_buffers
  346. */
  347. struct iwl4965_rx_queue {
  348. __le32 *bd;
  349. dma_addr_t dma_addr;
  350. struct iwl4965_rx_mem_buffer pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS];
  351. struct iwl4965_rx_mem_buffer *queue[RX_QUEUE_SIZE];
  352. u32 processed;
  353. u32 read;
  354. u32 write;
  355. u32 free_count;
  356. struct list_head rx_free;
  357. struct list_head rx_used;
  358. int need_update;
  359. spinlock_t lock;
  360. };
  361. #define IWL_SUPPORTED_RATES_IE_LEN 8
  362. #define SCAN_INTERVAL 100
  363. #define MAX_A_CHANNELS 252
  364. #define MIN_A_CHANNELS 7
  365. #define MAX_B_CHANNELS 14
  366. #define MIN_B_CHANNELS 1
  367. #define MAX_TID_COUNT 9
  368. #define IWL_INVALID_RATE 0xFF
  369. #define IWL_INVALID_VALUE -1
  370. #ifdef CONFIG_IWL4965_HT
  371. /**
  372. * struct iwl4965_ht_agg -- aggregation status while waiting for block-ack
  373. * @txq_id: Tx queue used for Tx attempt
  374. * @frame_count: # frames attempted by Tx command
  375. * @wait_for_ba: Expect block-ack before next Tx reply
  376. * @start_idx: Index of 1st Transmit Frame Descriptor (TFD) in Tx window
  377. * @bitmap0: Low order bitmap, one bit for each frame pending ACK in Tx window
  378. * @bitmap1: High order, one bit for each frame pending ACK in Tx window
  379. * @rate_n_flags: Rate at which Tx was attempted
  380. *
  381. * If REPLY_TX indicates that aggregation was attempted, driver must wait
  382. * for block ack (REPLY_COMPRESSED_BA). This struct stores tx reply info
  383. * until block ack arrives.
  384. */
  385. struct iwl4965_ht_agg {
  386. u16 txq_id;
  387. u16 frame_count;
  388. u16 wait_for_ba;
  389. u16 start_idx;
  390. u64 bitmap;
  391. u32 rate_n_flags;
  392. #define IWL_AGG_OFF 0
  393. #define IWL_AGG_ON 1
  394. #define IWL_EMPTYING_HW_QUEUE_ADDBA 2
  395. #define IWL_EMPTYING_HW_QUEUE_DELBA 3
  396. u8 state;
  397. };
  398. #endif /* CONFIG_IWL4965_HT */
  399. struct iwl4965_tid_data {
  400. u16 seq_number;
  401. u16 tfds_in_queue;
  402. #ifdef CONFIG_IWL4965_HT
  403. struct iwl4965_ht_agg agg;
  404. #endif /* CONFIG_IWL4965_HT */
  405. };
  406. struct iwl4965_hw_key {
  407. enum ieee80211_key_alg alg;
  408. int keylen;
  409. u8 keyidx;
  410. struct ieee80211_key_conf *conf;
  411. u8 key[32];
  412. };
  413. union iwl4965_ht_rate_supp {
  414. u16 rates;
  415. struct {
  416. u8 siso_rate;
  417. u8 mimo_rate;
  418. };
  419. };
  420. #ifdef CONFIG_IWL4965_HT
  421. #define CFG_HT_RX_AMPDU_FACTOR_DEF (0x3)
  422. #define CFG_HT_MPDU_DENSITY_2USEC (0x5)
  423. #define CFG_HT_MPDU_DENSITY_DEF CFG_HT_MPDU_DENSITY_2USEC
  424. struct iwl_ht_info {
  425. /* self configuration data */
  426. u8 is_ht;
  427. u8 supported_chan_width;
  428. u16 tx_mimo_ps_mode;
  429. u8 is_green_field;
  430. u8 sgf; /* HT_SHORT_GI_* short guard interval */
  431. u8 max_amsdu_size;
  432. u8 ampdu_factor;
  433. u8 mpdu_density;
  434. u8 supp_mcs_set[16];
  435. /* BSS related data */
  436. u8 control_channel;
  437. u8 extension_chan_offset;
  438. u8 tx_chan_width;
  439. u8 ht_protection;
  440. u8 non_GF_STA_present;
  441. };
  442. #endif /*CONFIG_IWL4965_HT */
  443. union iwl4965_qos_capabity {
  444. struct {
  445. u8 edca_count:4; /* bit 0-3 */
  446. u8 q_ack:1; /* bit 4 */
  447. u8 queue_request:1; /* bit 5 */
  448. u8 txop_request:1; /* bit 6 */
  449. u8 reserved:1; /* bit 7 */
  450. } q_AP;
  451. struct {
  452. u8 acvo_APSD:1; /* bit 0 */
  453. u8 acvi_APSD:1; /* bit 1 */
  454. u8 ac_bk_APSD:1; /* bit 2 */
  455. u8 ac_be_APSD:1; /* bit 3 */
  456. u8 q_ack:1; /* bit 4 */
  457. u8 max_len:2; /* bit 5-6 */
  458. u8 more_data_ack:1; /* bit 7 */
  459. } q_STA;
  460. u8 val;
  461. };
  462. /* QoS structures */
  463. struct iwl4965_qos_info {
  464. int qos_enable;
  465. int qos_active;
  466. union iwl4965_qos_capabity qos_cap;
  467. struct iwl4965_qosparam_cmd def_qos_parm;
  468. };
  469. #define STA_PS_STATUS_WAKE 0
  470. #define STA_PS_STATUS_SLEEP 1
  471. struct iwl4965_station_entry {
  472. struct iwl4965_addsta_cmd sta;
  473. struct iwl4965_tid_data tid[MAX_TID_COUNT];
  474. u8 used;
  475. u8 ps_status;
  476. struct iwl4965_hw_key keyinfo;
  477. };
  478. /* one for each uCode image (inst/data, boot/init/runtime) */
  479. struct fw_desc {
  480. void *v_addr; /* access by driver */
  481. dma_addr_t p_addr; /* access by card's busmaster DMA */
  482. u32 len; /* bytes */
  483. };
  484. /* uCode file layout */
  485. struct iwl4965_ucode {
  486. __le32 ver; /* major/minor/subminor */
  487. __le32 inst_size; /* bytes of runtime instructions */
  488. __le32 data_size; /* bytes of runtime data */
  489. __le32 init_size; /* bytes of initialization instructions */
  490. __le32 init_data_size; /* bytes of initialization data */
  491. __le32 boot_size; /* bytes of bootstrap instructions */
  492. u8 data[0]; /* data in same order as "size" elements */
  493. };
  494. #define IWL_IBSS_MAC_HASH_SIZE 32
  495. struct iwl4965_ibss_seq {
  496. u8 mac[ETH_ALEN];
  497. u16 seq_num;
  498. u16 frag_num;
  499. unsigned long packet_time;
  500. struct list_head list;
  501. };
  502. struct iwl_sensitivity_ranges {
  503. u16 min_nrg_cck;
  504. u16 max_nrg_cck;
  505. u16 nrg_th_cck;
  506. u16 nrg_th_ofdm;
  507. u16 auto_corr_min_ofdm;
  508. u16 auto_corr_min_ofdm_mrc;
  509. u16 auto_corr_min_ofdm_x1;
  510. u16 auto_corr_min_ofdm_mrc_x1;
  511. u16 auto_corr_max_ofdm;
  512. u16 auto_corr_max_ofdm_mrc;
  513. u16 auto_corr_max_ofdm_x1;
  514. u16 auto_corr_max_ofdm_mrc_x1;
  515. u16 auto_corr_max_cck;
  516. u16 auto_corr_max_cck_mrc;
  517. u16 auto_corr_min_cck;
  518. u16 auto_corr_min_cck_mrc;
  519. };
  520. /**
  521. * struct iwl_hw_params
  522. * @max_txq_num: Max # Tx queues supported
  523. * @tx_cmd_len: Size of Tx command (but not including frame itself)
  524. * @tx_ant_num: Number of TX antennas
  525. * @max_rxq_size: Max # Rx frames in Rx queue (must be power-of-2)
  526. * @rx_buffer_size:
  527. * @max_rxq_log: Log-base-2 of max_rxq_size
  528. * @max_stations:
  529. * @bcast_sta_id:
  530. * @struct iwl_sensitivity_ranges: range of sensitivity values
  531. */
  532. struct iwl_hw_params {
  533. u16 max_txq_num;
  534. u16 tx_cmd_len;
  535. u8 tx_chains_num;
  536. u8 rx_chains_num;
  537. u8 valid_tx_ant;
  538. u8 valid_rx_ant;
  539. u16 max_rxq_size;
  540. u16 max_rxq_log;
  541. u32 rx_buf_size;
  542. u32 max_pkt_size;
  543. u8 max_stations;
  544. u8 bcast_sta_id;
  545. #ifdef CONFIG_IWLWIFI_RUN_TIME_CALIB
  546. const struct iwl_sensitivity_ranges *sens;
  547. #endif
  548. };
  549. #define HT_SHORT_GI_20MHZ_ONLY (1 << 0)
  550. #define HT_SHORT_GI_40MHZ_ONLY (1 << 1)
  551. #define IWL_RX_HDR(x) ((struct iwl4965_rx_frame_hdr *)(\
  552. x->u.rx_frame.stats.payload + \
  553. x->u.rx_frame.stats.phy_count))
  554. #define IWL_RX_END(x) ((struct iwl4965_rx_frame_end *)(\
  555. IWL_RX_HDR(x)->payload + \
  556. le16_to_cpu(IWL_RX_HDR(x)->len)))
  557. #define IWL_RX_STATS(x) (&x->u.rx_frame.stats)
  558. #define IWL_RX_DATA(x) (IWL_RX_HDR(x)->payload)
  559. /******************************************************************************
  560. *
  561. * Functions implemented in iwl-base.c which are forward declared here
  562. * for use by iwl-*.c
  563. *
  564. *****************************************************************************/
  565. struct iwl4965_addsta_cmd;
  566. extern int iwl4965_send_add_station(struct iwl_priv *priv,
  567. struct iwl4965_addsta_cmd *sta, u8 flags);
  568. extern u8 iwl4965_add_station_flags(struct iwl_priv *priv, const u8 *addr,
  569. int is_ap, u8 flags, void *ht_data);
  570. extern int iwl4965_is_network_packet(struct iwl_priv *priv,
  571. struct ieee80211_hdr *header);
  572. extern int iwl4965_power_init_handle(struct iwl_priv *priv);
  573. extern void iwl4965_handle_data_packet_monitor(struct iwl_priv *priv,
  574. struct iwl4965_rx_mem_buffer *rxb,
  575. void *data, short len,
  576. struct ieee80211_rx_status *stats,
  577. u16 phy_flags);
  578. extern int iwl4965_is_duplicate_packet(struct iwl_priv *priv,
  579. struct ieee80211_hdr *header);
  580. extern int iwl4965_rx_queue_alloc(struct iwl_priv *priv);
  581. extern void iwl4965_rx_queue_reset(struct iwl_priv *priv,
  582. struct iwl4965_rx_queue *rxq);
  583. extern int iwl4965_calc_db_from_ratio(int sig_ratio);
  584. extern int iwl4965_calc_sig_qual(int rssi_dbm, int noise_dbm);
  585. extern int iwl4965_tx_queue_init(struct iwl_priv *priv,
  586. struct iwl4965_tx_queue *txq, int count, u32 id);
  587. extern void iwl4965_rx_replenish(void *data);
  588. extern void iwl4965_tx_queue_free(struct iwl_priv *priv, struct iwl4965_tx_queue *txq);
  589. extern unsigned int iwl4965_fill_beacon_frame(struct iwl_priv *priv,
  590. struct ieee80211_hdr *hdr,
  591. const u8 *dest, int left);
  592. extern int iwl4965_rx_queue_update_write_ptr(struct iwl_priv *priv,
  593. struct iwl4965_rx_queue *q);
  594. extern __le16 *ieee80211_get_qos_ctrl(struct ieee80211_hdr *hdr);
  595. int iwl4965_init_geos(struct iwl_priv *priv);
  596. void iwl4965_free_geos(struct iwl_priv *priv);
  597. extern const u8 iwl4965_broadcast_addr[ETH_ALEN];
  598. int iwl4965_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd);
  599. /*
  600. * Currently used by iwl-3945-rs... look at restructuring so that it doesn't
  601. * call this... todo... fix that.
  602. */
  603. extern u8 iwl4965_sync_station(struct iwl_priv *priv, int sta_id,
  604. u16 tx_rate, u8 flags);
  605. /******************************************************************************
  606. *
  607. * Functions implemented in iwl-[34]*.c which are forward declared here
  608. * for use by iwl-base.c
  609. *
  610. * NOTE: The implementation of these functions are hardware specific
  611. * which is why they are in the hardware specific files (vs. iwl-base.c)
  612. *
  613. * Naming convention --
  614. * iwl4965_ <-- Its part of iwlwifi (should be changed to iwl4965_)
  615. * iwl4965_hw_ <-- Hardware specific (implemented in iwl-XXXX.c by all HW)
  616. * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
  617. * iwl4965_bg_ <-- Called from work queue context
  618. * iwl4965_mac_ <-- mac80211 callback
  619. *
  620. ****************************************************************************/
  621. extern void iwl4965_hw_rx_handler_setup(struct iwl_priv *priv);
  622. extern void iwl4965_hw_setup_deferred_work(struct iwl_priv *priv);
  623. extern void iwl4965_hw_cancel_deferred_work(struct iwl_priv *priv);
  624. extern int iwl4965_hw_rxq_stop(struct iwl_priv *priv);
  625. extern int iwl4965_hw_set_hw_params(struct iwl_priv *priv);
  626. extern int iwl4965_hw_nic_init(struct iwl_priv *priv);
  627. extern int iwl4965_hw_nic_stop_master(struct iwl_priv *priv);
  628. extern void iwl4965_hw_txq_ctx_free(struct iwl_priv *priv);
  629. extern void iwl4965_hw_txq_ctx_stop(struct iwl_priv *priv);
  630. extern int iwl4965_hw_nic_reset(struct iwl_priv *priv);
  631. extern int iwl4965_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, void *tfd,
  632. dma_addr_t addr, u16 len);
  633. extern int iwl4965_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl4965_tx_queue *txq);
  634. extern int iwl4965_hw_get_temperature(struct iwl_priv *priv);
  635. extern int iwl4965_hw_tx_queue_init(struct iwl_priv *priv,
  636. struct iwl4965_tx_queue *txq);
  637. extern unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv,
  638. struct iwl4965_frame *frame, u8 rate);
  639. extern int iwl4965_hw_get_rx_read(struct iwl_priv *priv);
  640. extern void iwl4965_hw_build_tx_cmd_rate(struct iwl_priv *priv,
  641. struct iwl_cmd *cmd,
  642. struct ieee80211_tx_control *ctrl,
  643. struct ieee80211_hdr *hdr,
  644. int sta_id, int tx_id);
  645. extern int iwl4965_hw_reg_send_txpower(struct iwl_priv *priv);
  646. extern int iwl4965_hw_reg_set_txpower(struct iwl_priv *priv, s8 power);
  647. extern void iwl4965_hw_rx_statistics(struct iwl_priv *priv,
  648. struct iwl4965_rx_mem_buffer *rxb);
  649. extern void iwl4965_disable_events(struct iwl_priv *priv);
  650. extern int iwl4965_get_temperature(const struct iwl_priv *priv);
  651. /**
  652. * iwl_find_station - Find station id for a given BSSID
  653. * @bssid: MAC address of station ID to find
  654. *
  655. * NOTE: This should not be hardware specific but the code has
  656. * not yet been merged into a single common layer for managing the
  657. * station tables.
  658. */
  659. extern u8 iwl_find_station(struct iwl_priv *priv, const u8 *bssid);
  660. extern int iwl4965_hw_channel_switch(struct iwl_priv *priv, u16 channel);
  661. extern int iwl4965_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index);
  662. extern int iwl4965_queue_space(const struct iwl4965_queue *q);
  663. struct iwl_priv;
  664. extern void iwl4965_radio_kill_sw(struct iwl_priv *priv, int disable_radio);
  665. /*
  666. * Forward declare iwl-4965.c functions for iwl-base.c
  667. */
  668. extern int iwl4965_tx_queue_update_wr_ptr(struct iwl_priv *priv,
  669. struct iwl4965_tx_queue *txq,
  670. u16 byte_cnt);
  671. extern void iwl4965_add_station(struct iwl_priv *priv, const u8 *addr,
  672. int is_ap);
  673. extern void iwl4965_set_rxon_chain(struct iwl_priv *priv);
  674. extern int iwl4965_alive_notify(struct iwl_priv *priv);
  675. extern void iwl4965_update_rate_scaling(struct iwl_priv *priv, u8 mode);
  676. extern void iwl4965_rf_kill_ct_config(struct iwl_priv *priv);
  677. extern void iwl4965_hwrate_to_tx_control(struct iwl_priv *priv,
  678. u32 rate_n_flags,
  679. struct ieee80211_tx_control *control);
  680. #ifdef CONFIG_IWL4965_HT
  681. void iwl4965_init_ht_hw_capab(struct iwl_priv *priv,
  682. struct ieee80211_ht_info *ht_info,
  683. enum ieee80211_band band);
  684. void iwl4965_set_rxon_ht(struct iwl_priv *priv,
  685. struct iwl_ht_info *ht_info);
  686. void iwl4965_set_ht_add_station(struct iwl_priv *priv, u8 index,
  687. struct ieee80211_ht_info *sta_ht_inf);
  688. int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw,
  689. enum ieee80211_ampdu_mlme_action action,
  690. const u8 *addr, u16 tid, u16 *ssn);
  691. int iwl4965_check_empty_hw_queue(struct iwl_priv *priv, int sta_id,
  692. u8 tid, int txq_id);
  693. #else
  694. static inline void iwl4965_init_ht_hw_capab(struct iwl_priv *priv,
  695. struct ieee80211_ht_info *ht_info,
  696. enum ieee80211_band band) {}
  697. #endif /*CONFIG_IWL4965_HT */
  698. /* Structures, enum, and defines specific to the 4965 */
  699. #define IWL4965_KW_SIZE 0x1000 /*4k */
  700. struct iwl4965_kw {
  701. dma_addr_t dma_addr;
  702. void *v_addr;
  703. size_t size;
  704. };
  705. #define IWL_CHANNEL_WIDTH_20MHZ 0
  706. #define IWL_CHANNEL_WIDTH_40MHZ 1
  707. #define IWL_MIMO_PS_STATIC 0
  708. #define IWL_MIMO_PS_NONE 3
  709. #define IWL_MIMO_PS_DYNAMIC 1
  710. #define IWL_MIMO_PS_INVALID 2
  711. #define IWL_OPERATION_MODE_AUTO 0
  712. #define IWL_OPERATION_MODE_HT_ONLY 1
  713. #define IWL_OPERATION_MODE_MIXED 2
  714. #define IWL_OPERATION_MODE_20MHZ 3
  715. #define IWL_EXT_CHANNEL_OFFSET_NONE 0
  716. #define IWL_EXT_CHANNEL_OFFSET_ABOVE 1
  717. #define IWL_EXT_CHANNEL_OFFSET_RESERVE1 2
  718. #define IWL_EXT_CHANNEL_OFFSET_BELOW 3
  719. #define NRG_NUM_PREV_STAT_L 20
  720. #define NUM_RX_CHAINS (3)
  721. #define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000
  722. struct iwl4965_lq_mngr {
  723. spinlock_t lock;
  724. s32 max_window_size;
  725. s32 *expected_tpt;
  726. u8 *next_higher_rate;
  727. u8 *next_lower_rate;
  728. unsigned long stamp;
  729. unsigned long stamp_last;
  730. u32 flush_time;
  731. u32 tx_packets;
  732. u8 lq_ready;
  733. };
  734. /* Sensitivity and chain noise calibration */
  735. #define INTERFERENCE_DATA_AVAILABLE __constant_cpu_to_le32(1)
  736. #define INITIALIZATION_VALUE 0xFFFF
  737. #define CAL_NUM_OF_BEACONS 20
  738. #define MAXIMUM_ALLOWED_PATHLOSS 15
  739. #define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3
  740. #define MAX_FA_OFDM 50
  741. #define MIN_FA_OFDM 5
  742. #define MAX_FA_CCK 50
  743. #define MIN_FA_CCK 5
  744. #define AUTO_CORR_STEP_OFDM 1
  745. #define AUTO_CORR_STEP_CCK 3
  746. #define AUTO_CORR_MAX_TH_CCK 160
  747. #define NRG_DIFF 2
  748. #define NRG_STEP_CCK 2
  749. #define NRG_MARGIN 8
  750. #define MAX_NUMBER_CCK_NO_FA 100
  751. #define AUTO_CORR_CCK_MIN_VAL_DEF (125)
  752. #define CHAIN_A 0
  753. #define CHAIN_B 1
  754. #define CHAIN_C 2
  755. #define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4
  756. #define ALL_BAND_FILTER 0xFF00
  757. #define IN_BAND_FILTER 0xFF
  758. #define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF
  759. enum iwl4965_false_alarm_state {
  760. IWL_FA_TOO_MANY = 0,
  761. IWL_FA_TOO_FEW = 1,
  762. IWL_FA_GOOD_RANGE = 2,
  763. };
  764. enum iwl4965_chain_noise_state {
  765. IWL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */
  766. IWL_CHAIN_NOISE_ACCUMULATE = 1,
  767. IWL_CHAIN_NOISE_CALIBRATED = 2,
  768. };
  769. enum iwl4965_calib_enabled_state {
  770. IWL_CALIB_DISABLED = 0, /* must be 0 */
  771. IWL_CALIB_ENABLED = 1,
  772. };
  773. struct statistics_general_data {
  774. u32 beacon_silence_rssi_a;
  775. u32 beacon_silence_rssi_b;
  776. u32 beacon_silence_rssi_c;
  777. u32 beacon_energy_a;
  778. u32 beacon_energy_b;
  779. u32 beacon_energy_c;
  780. };
  781. #ifdef CONFIG_IWLWIFI_RUN_TIME_CALIB
  782. /* Sensitivity calib data */
  783. struct iwl_sensitivity_data {
  784. u32 auto_corr_ofdm;
  785. u32 auto_corr_ofdm_mrc;
  786. u32 auto_corr_ofdm_x1;
  787. u32 auto_corr_ofdm_mrc_x1;
  788. u32 auto_corr_cck;
  789. u32 auto_corr_cck_mrc;
  790. u32 last_bad_plcp_cnt_ofdm;
  791. u32 last_fa_cnt_ofdm;
  792. u32 last_bad_plcp_cnt_cck;
  793. u32 last_fa_cnt_cck;
  794. u32 nrg_curr_state;
  795. u32 nrg_prev_state;
  796. u32 nrg_value[10];
  797. u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L];
  798. u32 nrg_silence_ref;
  799. u32 nrg_energy_idx;
  800. u32 nrg_silence_idx;
  801. u32 nrg_th_cck;
  802. s32 nrg_auto_corr_silence_diff;
  803. u32 num_in_cck_no_fa;
  804. u32 nrg_th_ofdm;
  805. };
  806. /* Chain noise (differential Rx gain) calib data */
  807. struct iwl_chain_noise_data {
  808. u8 state;
  809. u16 beacon_count;
  810. u32 chain_noise_a;
  811. u32 chain_noise_b;
  812. u32 chain_noise_c;
  813. u32 chain_signal_a;
  814. u32 chain_signal_b;
  815. u32 chain_signal_c;
  816. u8 disconn_array[NUM_RX_CHAINS];
  817. u8 delta_gain_code[NUM_RX_CHAINS];
  818. u8 radio_write;
  819. };
  820. #endif /* CONFIG_IWLWIFI_RUN_TIME_CALIB */
  821. #define EEPROM_SEM_TIMEOUT 10 /* milliseconds */
  822. #define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */
  823. #ifdef CONFIG_IWL4965_SPECTRUM_MEASUREMENT
  824. enum {
  825. MEASUREMENT_READY = (1 << 0),
  826. MEASUREMENT_ACTIVE = (1 << 1),
  827. };
  828. #endif
  829. #define IWL_MAX_NUM_QUEUES 20 /* FIXME: do dynamic allocation */
  830. struct iwl_priv {
  831. /* ieee device used by generic ieee processing code */
  832. struct ieee80211_hw *hw;
  833. struct ieee80211_channel *ieee_channels;
  834. struct ieee80211_rate *ieee_rates;
  835. struct iwl_cfg *cfg;
  836. /* temporary frame storage list */
  837. struct list_head free_frames;
  838. int frames_count;
  839. enum ieee80211_band band;
  840. int alloc_rxb_skb;
  841. bool add_radiotap;
  842. void (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv,
  843. struct iwl4965_rx_mem_buffer *rxb);
  844. struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS];
  845. #ifdef CONFIG_IWL4965_SPECTRUM_MEASUREMENT
  846. /* spectrum measurement report caching */
  847. struct iwl4965_spectrum_notification measure_report;
  848. u8 measurement_status;
  849. #endif
  850. /* ucode beacon time */
  851. u32 ucode_beacon_time;
  852. /* we allocate array of iwl4965_channel_info for NIC's valid channels.
  853. * Access via channel # using indirect index array */
  854. struct iwl_channel_info *channel_info; /* channel info array */
  855. u8 channel_count; /* # of channels */
  856. /* each calibration channel group in the EEPROM has a derived
  857. * clip setting for each rate. */
  858. const struct iwl4965_clip_group clip_groups[5];
  859. /* thermal calibration */
  860. s32 temperature; /* degrees Kelvin */
  861. s32 last_temperature;
  862. /* Scan related variables */
  863. unsigned long last_scan_jiffies;
  864. unsigned long next_scan_jiffies;
  865. unsigned long scan_start;
  866. unsigned long scan_pass_start;
  867. unsigned long scan_start_tsf;
  868. int scan_bands;
  869. int one_direct_scan;
  870. u8 direct_ssid_len;
  871. u8 direct_ssid[IW_ESSID_MAX_SIZE];
  872. struct iwl4965_scan_cmd *scan;
  873. /* spinlock */
  874. spinlock_t lock; /* protect general shared data */
  875. spinlock_t hcmd_lock; /* protect hcmd */
  876. struct mutex mutex;
  877. /* basic pci-network driver stuff */
  878. struct pci_dev *pci_dev;
  879. /* pci hardware address support */
  880. void __iomem *hw_base;
  881. /* uCode images, save to reload in case of failure */
  882. struct fw_desc ucode_code; /* runtime inst */
  883. struct fw_desc ucode_data; /* runtime data original */
  884. struct fw_desc ucode_data_backup; /* runtime data save/restore */
  885. struct fw_desc ucode_init; /* initialization inst */
  886. struct fw_desc ucode_init_data; /* initialization data */
  887. struct fw_desc ucode_boot; /* bootstrap inst */
  888. struct iwl4965_rxon_time_cmd rxon_timing;
  889. /* We declare this const so it can only be
  890. * changed via explicit cast within the
  891. * routines that actually update the physical
  892. * hardware */
  893. const struct iwl4965_rxon_cmd active_rxon;
  894. struct iwl4965_rxon_cmd staging_rxon;
  895. int error_recovering;
  896. struct iwl4965_rxon_cmd recovery_rxon;
  897. /* 1st responses from initialize and runtime uCode images.
  898. * 4965's initialize alive response contains some calibration data. */
  899. struct iwl4965_init_alive_resp card_alive_init;
  900. struct iwl4965_alive_resp card_alive;
  901. #ifdef CONFIG_IWLWIFI_RFKILL
  902. struct iwl_rfkill_mngr rfkill_mngr;
  903. #endif
  904. #ifdef CONFIG_IWLWIFI_LEDS
  905. struct iwl4965_led led[IWL_LED_TRG_MAX];
  906. unsigned long last_blink_time;
  907. u8 last_blink_rate;
  908. u8 allow_blinking;
  909. u64 led_tpt;
  910. #endif
  911. u16 active_rate;
  912. u16 active_rate_basic;
  913. u8 assoc_station_added;
  914. u8 use_ant_b_for_management_frame; /* Tx antenna selection */
  915. u8 valid_antenna; /* Bit mask of antennas actually connected */
  916. u8 start_calib;
  917. #ifdef CONFIG_IWLWIFI_RUN_TIME_CALIB
  918. struct iwl_sensitivity_data sensitivity_data;
  919. struct iwl_chain_noise_data chain_noise_data;
  920. __le16 sensitivity_tbl[HD_TABLE_SIZE];
  921. #endif /*CONFIG_IWLWIFI_RUN_TIME_CALIB*/
  922. #ifdef CONFIG_IWL4965_HT
  923. struct iwl_ht_info current_ht_config;
  924. #endif
  925. u8 last_phy_res[100];
  926. /* Rate scaling data */
  927. struct iwl4965_lq_mngr lq_mngr;
  928. /* Rate scaling data */
  929. s8 data_retry_limit;
  930. u8 retry_rate;
  931. wait_queue_head_t wait_command_queue;
  932. int activity_timer_active;
  933. /* Rx and Tx DMA processing queues */
  934. struct iwl4965_rx_queue rxq;
  935. struct iwl4965_tx_queue txq[IWL_MAX_NUM_QUEUES];
  936. unsigned long txq_ctx_active_msk;
  937. struct iwl4965_kw kw; /* keep warm address */
  938. u32 scd_base_addr; /* scheduler sram base address */
  939. unsigned long status;
  940. int last_rx_rssi; /* From Rx packet statisitics */
  941. int last_rx_noise; /* From beacon statistics */
  942. /* counts mgmt, ctl, and data packets */
  943. struct traffic_stats {
  944. u32 cnt;
  945. u64 bytes;
  946. } tx_stats[3], rx_stats[3];
  947. struct iwl4965_power_mgr power_data;
  948. struct iwl4965_notif_statistics statistics;
  949. unsigned long last_statistics_time;
  950. /* context information */
  951. u8 essid[IW_ESSID_MAX_SIZE];
  952. u8 essid_len;
  953. u16 rates_mask;
  954. u32 power_mode;
  955. u32 antenna;
  956. u8 bssid[ETH_ALEN];
  957. u16 rts_threshold;
  958. u8 mac_addr[ETH_ALEN];
  959. /*station table variables */
  960. spinlock_t sta_lock;
  961. int num_stations;
  962. struct iwl4965_station_entry stations[IWL_STATION_COUNT];
  963. struct iwl_wep_key wep_keys[WEP_KEYS_MAX];
  964. u8 default_wep_key;
  965. u8 key_mapping_key;
  966. unsigned long ucode_key_table;
  967. /* Indication if ieee80211_ops->open has been called */
  968. u8 is_open;
  969. u8 mac80211_registered;
  970. u32 notif_missed_beacons;
  971. /* Rx'd packet timing information */
  972. u32 last_beacon_time;
  973. u64 last_tsf;
  974. /* Duplicate packet detection */
  975. u16 last_seq_num;
  976. u16 last_frag_num;
  977. unsigned long last_packet_time;
  978. /* Hash table for finding stations in IBSS network */
  979. struct list_head ibss_mac_hash[IWL_IBSS_MAC_HASH_SIZE];
  980. /* eeprom */
  981. struct iwl4965_eeprom eeprom;
  982. enum ieee80211_if_types iw_mode;
  983. struct sk_buff *ibss_beacon;
  984. /* Last Rx'd beacon timestamp */
  985. u64 timestamp;
  986. u16 beacon_int;
  987. struct ieee80211_vif *vif;
  988. struct iwl_hw_params hw_params;
  989. /* driver/uCode shared Tx Byte Counts and Rx status */
  990. void *shared_virt;
  991. /* Physical Pointer to Tx Byte Counts and Rx status */
  992. dma_addr_t shared_phys;
  993. /* Current association information needed to configure the
  994. * hardware */
  995. u16 assoc_id;
  996. u16 assoc_capability;
  997. u8 ps_mode;
  998. struct iwl4965_qos_info qos_data;
  999. struct workqueue_struct *workqueue;
  1000. struct work_struct up;
  1001. struct work_struct restart;
  1002. struct work_struct calibrated_work;
  1003. struct work_struct scan_completed;
  1004. struct work_struct rx_replenish;
  1005. struct work_struct rf_kill;
  1006. struct work_struct abort_scan;
  1007. struct work_struct update_link_led;
  1008. struct work_struct auth_work;
  1009. struct work_struct report_work;
  1010. struct work_struct request_scan;
  1011. struct work_struct beacon_update;
  1012. struct tasklet_struct irq_tasklet;
  1013. struct delayed_work init_alive_start;
  1014. struct delayed_work alive_start;
  1015. struct delayed_work activity_timer;
  1016. struct delayed_work thermal_periodic;
  1017. struct delayed_work gather_stats;
  1018. struct delayed_work scan_check;
  1019. struct delayed_work post_associate;
  1020. #define IWL_DEFAULT_TX_POWER 0x0F
  1021. s8 user_txpower_limit;
  1022. s8 max_channel_txpower_limit;
  1023. #ifdef CONFIG_PM
  1024. u32 pm_state[16];
  1025. #endif
  1026. #ifdef CONFIG_IWLWIFI_DEBUG
  1027. /* debugging info */
  1028. u32 framecnt_to_us;
  1029. atomic_t restrict_refcnt;
  1030. #ifdef CONFIG_IWLWIFI_DEBUGFS
  1031. /* debugfs */
  1032. struct iwl_debugfs *dbgfs;
  1033. #endif /* CONFIG_IWLWIFI_DEBUGFS */
  1034. #endif /* CONFIG_IWLWIFI_DEBUG */
  1035. struct work_struct txpower_work;
  1036. #ifdef CONFIG_IWL4965_RUN_TIME_CALIB
  1037. struct work_struct sensitivity_work;
  1038. #endif
  1039. struct timer_list statistics_periodic;
  1040. }; /*iwl_priv */
  1041. static inline int iwl_is_associated(struct iwl_priv *priv)
  1042. {
  1043. return (priv->active_rxon.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
  1044. }
  1045. static inline int is_channel_valid(const struct iwl_channel_info *ch_info)
  1046. {
  1047. if (ch_info == NULL)
  1048. return 0;
  1049. return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0;
  1050. }
  1051. static inline int is_channel_narrow(const struct iwl_channel_info *ch_info)
  1052. {
  1053. return (ch_info->flags & EEPROM_CHANNEL_NARROW) ? 1 : 0;
  1054. }
  1055. static inline int is_channel_radar(const struct iwl_channel_info *ch_info)
  1056. {
  1057. return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0;
  1058. }
  1059. static inline u8 is_channel_a_band(const struct iwl_channel_info *ch_info)
  1060. {
  1061. return ch_info->band == IEEE80211_BAND_5GHZ;
  1062. }
  1063. static inline u8 is_channel_bg_band(const struct iwl_channel_info *ch_info)
  1064. {
  1065. return ch_info->band == IEEE80211_BAND_2GHZ;
  1066. }
  1067. static inline int is_channel_passive(const struct iwl_channel_info *ch)
  1068. {
  1069. return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0;
  1070. }
  1071. static inline int is_channel_ibss(const struct iwl_channel_info *ch)
  1072. {
  1073. return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0;
  1074. }
  1075. extern const struct iwl_channel_info *iwl_get_channel_info(
  1076. const struct iwl_priv *priv, enum ieee80211_band band, u16 channel);
  1077. /* Requires full declaration of iwl_priv before including */
  1078. #endif /* __iwl4965_4965_h__ */