iwl-4965.h 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358
  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_4965_h__
  27. #define __iwl_4965_h__
  28. #include <linux/pci.h> /* for struct pci_device_id */
  29. #include <linux/kernel.h>
  30. #include <net/ieee80211_radiotap.h>
  31. struct iwl4965_priv;
  32. /* Hardware specific file defines the PCI IDs table for that hardware module */
  33. extern struct pci_device_id iwl4965_hw_card_ids[];
  34. #define DRV_NAME "iwl4965"
  35. #include "iwl-4965-hw.h"
  36. #include "iwl-prph.h"
  37. #include "iwl-4965-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 iwl4965_param_hwcrypto;
  52. extern int iwl4965_param_queues_num;
  53. enum iwl4965_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 iwl4965_rx_mem_buffer {
  75. dma_addr_t dma_addr;
  76. struct sk_buff *skb;
  77. struct list_head list;
  78. };
  79. struct iwl4965_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 iwl4965_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 iwl4965_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 iwl4965_tx_info {
  119. struct ieee80211_tx_status status;
  120. struct sk_buff *skb[MAX_NUM_OF_TBS];
  121. };
  122. /**
  123. * struct iwl4965_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 iwl4965_tx_queue {
  130. struct iwl4965_queue q;
  131. struct iwl4965_tfd_frame *bd;
  132. struct iwl4965_cmd *cmd;
  133. dma_addr_t dma_addr_cmd;
  134. struct iwl4965_tx_info *txb;
  135. int need_update;
  136. int sched_retry;
  137. int active;
  138. };
  139. #define IWL_NUM_SCAN_RATES (2)
  140. struct iwl4965_channel_tgd_info {
  141. u8 type;
  142. s8 max_power;
  143. };
  144. struct iwl4965_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 iwl4965_channel_power_info {
  155. struct iwl4965_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 iwl4965_scan_power_info {
  163. struct iwl4965_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 iwl4965_channel_info {
  181. struct iwl4965_channel_tgd_info tgd;
  182. struct iwl4965_channel_tgh_info tgh;
  183. struct iwl4965_eeprom_channel eeprom; /* EEPROM regulatory limit */
  184. struct iwl4965_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 iwl4965_channel_power_info power_info[IWL4965_MAX_RATE];
  199. /* FAT channel info */
  200. s8 fat_max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */
  201. s8 fat_curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) */
  202. s8 fat_min_power; /* always 0 */
  203. s8 fat_scan_power; /* (dBm) eeprom, direct scans, any rate */
  204. u8 fat_flags; /* flags copied from EEPROM */
  205. u8 fat_extension_channel;
  206. /* Radio/DSP gain settings for each scan rate, for directed scans. */
  207. struct iwl4965_scan_power_info scan_pwr_info[IWL_NUM_SCAN_RATES];
  208. };
  209. struct iwl4965_clip_group {
  210. /* maximum power level to prevent clipping for each rate, derived by
  211. * us from this band's saturation power in EEPROM */
  212. const s8 clip_powers[IWL_MAX_RATES];
  213. };
  214. #include "iwl-4965-rs.h"
  215. #define IWL_TX_FIFO_AC0 0
  216. #define IWL_TX_FIFO_AC1 1
  217. #define IWL_TX_FIFO_AC2 2
  218. #define IWL_TX_FIFO_AC3 3
  219. #define IWL_TX_FIFO_HCCA_1 5
  220. #define IWL_TX_FIFO_HCCA_2 6
  221. #define IWL_TX_FIFO_NONE 7
  222. /* Minimum number of queues. MAX_NUM is defined in hw specific files */
  223. #define IWL_MIN_NUM_QUEUES 4
  224. /* Power management (not Tx power) structures */
  225. struct iwl4965_power_vec_entry {
  226. struct iwl4965_powertable_cmd cmd;
  227. u8 no_dtim;
  228. };
  229. #define IWL_POWER_RANGE_0 (0)
  230. #define IWL_POWER_RANGE_1 (1)
  231. #define IWL_POWER_MODE_CAM 0x00 /* Continuously Aware Mode, always on */
  232. #define IWL_POWER_INDEX_3 0x03
  233. #define IWL_POWER_INDEX_5 0x05
  234. #define IWL_POWER_AC 0x06
  235. #define IWL_POWER_BATTERY 0x07
  236. #define IWL_POWER_LIMIT 0x07
  237. #define IWL_POWER_MASK 0x0F
  238. #define IWL_POWER_ENABLED 0x10
  239. #define IWL_POWER_LEVEL(x) ((x) & IWL_POWER_MASK)
  240. struct iwl4965_power_mgr {
  241. spinlock_t lock;
  242. struct iwl4965_power_vec_entry pwr_range_0[IWL_POWER_AC];
  243. struct iwl4965_power_vec_entry pwr_range_1[IWL_POWER_AC];
  244. u8 active_index;
  245. u32 dtim_val;
  246. };
  247. #define IEEE80211_DATA_LEN 2304
  248. #define IEEE80211_4ADDR_LEN 30
  249. #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
  250. #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
  251. struct iwl4965_frame {
  252. union {
  253. struct ieee80211_hdr frame;
  254. struct iwl4965_tx_beacon_cmd beacon;
  255. u8 raw[IEEE80211_FRAME_LEN];
  256. u8 cmd[360];
  257. } u;
  258. struct list_head list;
  259. };
  260. #define SEQ_TO_QUEUE(x) ((x >> 8) & 0xbf)
  261. #define QUEUE_TO_SEQ(x) ((x & 0xbf) << 8)
  262. #define SEQ_TO_INDEX(x) (x & 0xff)
  263. #define INDEX_TO_SEQ(x) (x & 0xff)
  264. #define SEQ_HUGE_FRAME (0x4000)
  265. #define SEQ_RX_FRAME __constant_cpu_to_le16(0x8000)
  266. #define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
  267. #define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ)
  268. #define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4)
  269. enum {
  270. /* CMD_SIZE_NORMAL = 0, */
  271. CMD_SIZE_HUGE = (1 << 0),
  272. /* CMD_SYNC = 0, */
  273. CMD_ASYNC = (1 << 1),
  274. /* CMD_NO_SKB = 0, */
  275. CMD_WANT_SKB = (1 << 2),
  276. };
  277. struct iwl4965_cmd;
  278. struct iwl4965_priv;
  279. struct iwl4965_cmd_meta {
  280. struct iwl4965_cmd_meta *source;
  281. union {
  282. struct sk_buff *skb;
  283. int (*callback)(struct iwl4965_priv *priv,
  284. struct iwl4965_cmd *cmd, struct sk_buff *skb);
  285. } __attribute__ ((packed)) u;
  286. /* The CMD_SIZE_HUGE flag bit indicates that the command
  287. * structure is stored at the end of the shared queue memory. */
  288. u32 flags;
  289. } __attribute__ ((packed));
  290. struct iwl4965_cmd {
  291. struct iwl4965_cmd_meta meta;
  292. struct iwl4965_cmd_header hdr;
  293. union {
  294. struct iwl4965_addsta_cmd addsta;
  295. struct iwl4965_led_cmd led;
  296. u32 flags;
  297. u8 val8;
  298. u16 val16;
  299. u32 val32;
  300. struct iwl4965_bt_cmd bt;
  301. struct iwl4965_rxon_time_cmd rxon_time;
  302. struct iwl4965_powertable_cmd powertable;
  303. struct iwl4965_qosparam_cmd qosparam;
  304. struct iwl4965_tx_cmd tx;
  305. struct iwl4965_tx_beacon_cmd tx_beacon;
  306. struct iwl4965_rxon_assoc_cmd rxon_assoc;
  307. u8 *indirect;
  308. u8 payload[360];
  309. } __attribute__ ((packed)) cmd;
  310. } __attribute__ ((packed));
  311. struct iwl4965_host_cmd {
  312. u8 id;
  313. u16 len;
  314. struct iwl4965_cmd_meta meta;
  315. const void *data;
  316. };
  317. #define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl4965_cmd) - \
  318. sizeof(struct iwl4965_cmd_meta))
  319. /*
  320. * RX related structures and functions
  321. */
  322. #define RX_FREE_BUFFERS 64
  323. #define RX_LOW_WATERMARK 8
  324. #define SUP_RATE_11A_MAX_NUM_CHANNELS 8
  325. #define SUP_RATE_11B_MAX_NUM_CHANNELS 4
  326. #define SUP_RATE_11G_MAX_NUM_CHANNELS 12
  327. /**
  328. * struct iwl4965_rx_queue - Rx queue
  329. * @processed: Internal index to last handled Rx packet
  330. * @read: Shared index to newest available Rx buffer
  331. * @write: Shared index to oldest written Rx packet
  332. * @free_count: Number of pre-allocated buffers in rx_free
  333. * @rx_free: list of free SKBs for use
  334. * @rx_used: List of Rx buffers with no SKB
  335. * @need_update: flag to indicate we need to update read/write index
  336. *
  337. * NOTE: rx_free and rx_used are used as a FIFO for iwl4965_rx_mem_buffers
  338. */
  339. struct iwl4965_rx_queue {
  340. __le32 *bd;
  341. dma_addr_t dma_addr;
  342. struct iwl4965_rx_mem_buffer pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS];
  343. struct iwl4965_rx_mem_buffer *queue[RX_QUEUE_SIZE];
  344. u32 processed;
  345. u32 read;
  346. u32 write;
  347. u32 free_count;
  348. struct list_head rx_free;
  349. struct list_head rx_used;
  350. int need_update;
  351. spinlock_t lock;
  352. };
  353. #define IWL_SUPPORTED_RATES_IE_LEN 8
  354. #define SCAN_INTERVAL 100
  355. #define MAX_A_CHANNELS 252
  356. #define MIN_A_CHANNELS 7
  357. #define MAX_B_CHANNELS 14
  358. #define MIN_B_CHANNELS 1
  359. #define STATUS_HCMD_ACTIVE 0 /* host command in progress */
  360. #define STATUS_INT_ENABLED 1
  361. #define STATUS_RF_KILL_HW 2
  362. #define STATUS_RF_KILL_SW 3
  363. #define STATUS_INIT 4
  364. #define STATUS_ALIVE 5
  365. #define STATUS_READY 6
  366. #define STATUS_TEMPERATURE 7
  367. #define STATUS_GEO_CONFIGURED 8
  368. #define STATUS_EXIT_PENDING 9
  369. #define STATUS_IN_SUSPEND 10
  370. #define STATUS_STATISTICS 11
  371. #define STATUS_SCANNING 12
  372. #define STATUS_SCAN_ABORTING 13
  373. #define STATUS_SCAN_HW 14
  374. #define STATUS_POWER_PMI 15
  375. #define STATUS_FW_ERROR 16
  376. #define MAX_TID_COUNT 9
  377. #define IWL_INVALID_RATE 0xFF
  378. #define IWL_INVALID_VALUE -1
  379. #ifdef CONFIG_IWL4965_HT
  380. #ifdef CONFIG_IWL4965_HT_AGG
  381. struct iwl4965_ht_agg {
  382. u16 txq_id;
  383. u16 frame_count;
  384. u16 wait_for_ba;
  385. u16 start_idx;
  386. u32 bitmap0;
  387. u32 bitmap1;
  388. u32 rate_n_flags;
  389. };
  390. #endif /* CONFIG_IWL4965_HT_AGG */
  391. #endif /* CONFIG_IWL4965_HT */
  392. struct iwl4965_tid_data {
  393. u16 seq_number;
  394. #ifdef CONFIG_IWL4965_HT
  395. #ifdef CONFIG_IWL4965_HT_AGG
  396. struct iwl4965_ht_agg agg;
  397. #endif /* CONFIG_IWL4965_HT_AGG */
  398. #endif /* CONFIG_IWL4965_HT */
  399. };
  400. struct iwl4965_hw_key {
  401. enum ieee80211_key_alg alg;
  402. int keylen;
  403. u8 key[32];
  404. };
  405. union iwl4965_ht_rate_supp {
  406. u16 rates;
  407. struct {
  408. u8 siso_rate;
  409. u8 mimo_rate;
  410. };
  411. };
  412. #ifdef CONFIG_IWL4965_HT
  413. #define CFG_HT_RX_AMPDU_FACTOR_DEF (0x3)
  414. #define HT_IE_MAX_AMSDU_SIZE_4K (0)
  415. #define CFG_HT_MPDU_DENSITY_2USEC (0x5)
  416. #define CFG_HT_MPDU_DENSITY_DEF CFG_HT_MPDU_DENSITY_2USEC
  417. struct sta_ht_info {
  418. u8 is_ht;
  419. u16 rx_mimo_ps_mode;
  420. u16 tx_mimo_ps_mode;
  421. u16 control_channel;
  422. u8 max_amsdu_size;
  423. u8 ampdu_factor;
  424. u8 mpdu_density;
  425. u8 operating_mode;
  426. u8 supported_chan_width;
  427. u8 extension_chan_offset;
  428. u8 is_green_field;
  429. u8 sgf;
  430. u8 supp_rates[16];
  431. u8 tx_chan_width;
  432. u8 chan_width_cap;
  433. };
  434. #endif /*CONFIG_IWL4965_HT */
  435. #ifdef CONFIG_IWL4965_QOS
  436. union iwl4965_qos_capabity {
  437. struct {
  438. u8 edca_count:4; /* bit 0-3 */
  439. u8 q_ack:1; /* bit 4 */
  440. u8 queue_request:1; /* bit 5 */
  441. u8 txop_request:1; /* bit 6 */
  442. u8 reserved:1; /* bit 7 */
  443. } q_AP;
  444. struct {
  445. u8 acvo_APSD:1; /* bit 0 */
  446. u8 acvi_APSD:1; /* bit 1 */
  447. u8 ac_bk_APSD:1; /* bit 2 */
  448. u8 ac_be_APSD:1; /* bit 3 */
  449. u8 q_ack:1; /* bit 4 */
  450. u8 max_len:2; /* bit 5-6 */
  451. u8 more_data_ack:1; /* bit 7 */
  452. } q_STA;
  453. u8 val;
  454. };
  455. /* QoS structures */
  456. struct iwl4965_qos_info {
  457. int qos_enable;
  458. int qos_active;
  459. union iwl4965_qos_capabity qos_cap;
  460. struct iwl4965_qosparam_cmd def_qos_parm;
  461. };
  462. #endif /*CONFIG_IWL4965_QOS */
  463. #define STA_PS_STATUS_WAKE 0
  464. #define STA_PS_STATUS_SLEEP 1
  465. struct iwl4965_station_entry {
  466. struct iwl4965_addsta_cmd sta;
  467. struct iwl4965_tid_data tid[MAX_TID_COUNT];
  468. u8 used;
  469. u8 ps_status;
  470. struct iwl4965_hw_key keyinfo;
  471. };
  472. /* one for each uCode image (inst/data, boot/init/runtime) */
  473. struct fw_desc {
  474. void *v_addr; /* access by driver */
  475. dma_addr_t p_addr; /* access by card's busmaster DMA */
  476. u32 len; /* bytes */
  477. };
  478. /* uCode file layout */
  479. struct iwl4965_ucode {
  480. __le32 ver; /* major/minor/subminor */
  481. __le32 inst_size; /* bytes of runtime instructions */
  482. __le32 data_size; /* bytes of runtime data */
  483. __le32 init_size; /* bytes of initialization instructions */
  484. __le32 init_data_size; /* bytes of initialization data */
  485. __le32 boot_size; /* bytes of bootstrap instructions */
  486. u8 data[0]; /* data in same order as "size" elements */
  487. };
  488. #define IWL_IBSS_MAC_HASH_SIZE 32
  489. struct iwl4965_ibss_seq {
  490. u8 mac[ETH_ALEN];
  491. u16 seq_num;
  492. u16 frag_num;
  493. unsigned long packet_time;
  494. struct list_head list;
  495. };
  496. struct iwl4965_driver_hw_info {
  497. u16 max_txq_num;
  498. u16 ac_queue_count;
  499. u16 tx_cmd_len;
  500. u16 max_rxq_size;
  501. u32 rx_buffer_size;
  502. u16 max_rxq_log;
  503. u8 max_stations;
  504. u8 bcast_sta_id;
  505. void *shared_virt;
  506. dma_addr_t shared_phys;
  507. };
  508. #define STA_FLG_RTS_MIMO_PROT_MSK __constant_cpu_to_le32(1 << 17)
  509. #define STA_FLG_AGG_MPDU_8US_MSK __constant_cpu_to_le32(1 << 18)
  510. #define STA_FLG_MAX_AGG_SIZE_POS (19)
  511. #define STA_FLG_MAX_AGG_SIZE_MSK __constant_cpu_to_le32(3 << 19)
  512. #define STA_FLG_FAT_EN_MSK __constant_cpu_to_le32(1 << 21)
  513. #define STA_FLG_MIMO_DIS_MSK __constant_cpu_to_le32(1 << 22)
  514. #define STA_FLG_AGG_MPDU_DENSITY_POS (23)
  515. #define STA_FLG_AGG_MPDU_DENSITY_MSK __constant_cpu_to_le32(7 << 23)
  516. #define HT_SHORT_GI_20MHZ_ONLY (1 << 0)
  517. #define HT_SHORT_GI_40MHZ_ONLY (1 << 1)
  518. #define IWL_RX_HDR(x) ((struct iwl4965_rx_frame_hdr *)(\
  519. x->u.rx_frame.stats.payload + \
  520. x->u.rx_frame.stats.phy_count))
  521. #define IWL_RX_END(x) ((struct iwl4965_rx_frame_end *)(\
  522. IWL_RX_HDR(x)->payload + \
  523. le16_to_cpu(IWL_RX_HDR(x)->len)))
  524. #define IWL_RX_STATS(x) (&x->u.rx_frame.stats)
  525. #define IWL_RX_DATA(x) (IWL_RX_HDR(x)->payload)
  526. /******************************************************************************
  527. *
  528. * Functions implemented in iwl-base.c which are forward declared here
  529. * for use by iwl-*.c
  530. *
  531. *****************************************************************************/
  532. struct iwl4965_addsta_cmd;
  533. extern int iwl4965_send_add_station(struct iwl4965_priv *priv,
  534. struct iwl4965_addsta_cmd *sta, u8 flags);
  535. extern u8 iwl4965_add_station_flags(struct iwl4965_priv *priv, const u8 *bssid,
  536. int is_ap, u8 flags);
  537. extern int iwl4965_is_network_packet(struct iwl4965_priv *priv,
  538. struct ieee80211_hdr *header);
  539. extern int iwl4965_power_init_handle(struct iwl4965_priv *priv);
  540. extern int iwl4965_eeprom_init(struct iwl4965_priv *priv);
  541. #ifdef CONFIG_IWL4965_DEBUG
  542. extern void iwl4965_report_frame(struct iwl4965_priv *priv,
  543. struct iwl4965_rx_packet *pkt,
  544. struct ieee80211_hdr *header, int group100);
  545. #else
  546. static inline void iwl4965_report_frame(struct iwl4965_priv *priv,
  547. struct iwl4965_rx_packet *pkt,
  548. struct ieee80211_hdr *header,
  549. int group100) {}
  550. #endif
  551. extern void iwl4965_handle_data_packet_monitor(struct iwl4965_priv *priv,
  552. struct iwl4965_rx_mem_buffer *rxb,
  553. void *data, short len,
  554. struct ieee80211_rx_status *stats,
  555. u16 phy_flags);
  556. extern int iwl4965_is_duplicate_packet(struct iwl4965_priv *priv,
  557. struct ieee80211_hdr *header);
  558. extern int iwl4965_rx_queue_alloc(struct iwl4965_priv *priv);
  559. extern void iwl4965_rx_queue_reset(struct iwl4965_priv *priv,
  560. struct iwl4965_rx_queue *rxq);
  561. extern int iwl4965_calc_db_from_ratio(int sig_ratio);
  562. extern int iwl4965_calc_sig_qual(int rssi_dbm, int noise_dbm);
  563. extern int iwl4965_tx_queue_init(struct iwl4965_priv *priv,
  564. struct iwl4965_tx_queue *txq, int count, u32 id);
  565. extern void iwl4965_rx_replenish(void *data);
  566. extern void iwl4965_tx_queue_free(struct iwl4965_priv *priv, struct iwl4965_tx_queue *txq);
  567. extern int iwl4965_send_cmd_pdu(struct iwl4965_priv *priv, u8 id, u16 len,
  568. const void *data);
  569. extern int __must_check iwl4965_send_cmd(struct iwl4965_priv *priv,
  570. struct iwl4965_host_cmd *cmd);
  571. extern unsigned int iwl4965_fill_beacon_frame(struct iwl4965_priv *priv,
  572. struct ieee80211_hdr *hdr,
  573. const u8 *dest, int left);
  574. extern int iwl4965_rx_queue_update_write_ptr(struct iwl4965_priv *priv,
  575. struct iwl4965_rx_queue *q);
  576. extern int iwl4965_send_statistics_request(struct iwl4965_priv *priv);
  577. extern void iwl4965_set_decrypted_flag(struct iwl4965_priv *priv, struct sk_buff *skb,
  578. u32 decrypt_res,
  579. struct ieee80211_rx_status *stats);
  580. extern __le16 *ieee80211_get_qos_ctrl(struct ieee80211_hdr *hdr);
  581. extern const u8 iwl4965_broadcast_addr[ETH_ALEN];
  582. /*
  583. * Currently used by iwl-3945-rs... look at restructuring so that it doesn't
  584. * call this... todo... fix that.
  585. */
  586. extern u8 iwl4965_sync_station(struct iwl4965_priv *priv, int sta_id,
  587. u16 tx_rate, u8 flags);
  588. /******************************************************************************
  589. *
  590. * Functions implemented in iwl-[34]*.c which are forward declared here
  591. * for use by iwl-base.c
  592. *
  593. * NOTE: The implementation of these functions are hardware specific
  594. * which is why they are in the hardware specific files (vs. iwl-base.c)
  595. *
  596. * Naming convention --
  597. * iwl4965_ <-- Its part of iwlwifi (should be changed to iwl4965_)
  598. * iwl4965_hw_ <-- Hardware specific (implemented in iwl-XXXX.c by all HW)
  599. * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
  600. * iwl4965_bg_ <-- Called from work queue context
  601. * iwl4965_mac_ <-- mac80211 callback
  602. *
  603. ****************************************************************************/
  604. extern void iwl4965_hw_rx_handler_setup(struct iwl4965_priv *priv);
  605. extern void iwl4965_hw_setup_deferred_work(struct iwl4965_priv *priv);
  606. extern void iwl4965_hw_cancel_deferred_work(struct iwl4965_priv *priv);
  607. extern int iwl4965_hw_rxq_stop(struct iwl4965_priv *priv);
  608. extern int iwl4965_hw_set_hw_setting(struct iwl4965_priv *priv);
  609. extern int iwl4965_hw_nic_init(struct iwl4965_priv *priv);
  610. extern int iwl4965_hw_nic_stop_master(struct iwl4965_priv *priv);
  611. extern void iwl4965_hw_txq_ctx_free(struct iwl4965_priv *priv);
  612. extern void iwl4965_hw_txq_ctx_stop(struct iwl4965_priv *priv);
  613. extern int iwl4965_hw_nic_reset(struct iwl4965_priv *priv);
  614. extern int iwl4965_hw_txq_attach_buf_to_tfd(struct iwl4965_priv *priv, void *tfd,
  615. dma_addr_t addr, u16 len);
  616. extern int iwl4965_hw_txq_free_tfd(struct iwl4965_priv *priv, struct iwl4965_tx_queue *txq);
  617. extern int iwl4965_hw_get_temperature(struct iwl4965_priv *priv);
  618. extern int iwl4965_hw_tx_queue_init(struct iwl4965_priv *priv,
  619. struct iwl4965_tx_queue *txq);
  620. extern unsigned int iwl4965_hw_get_beacon_cmd(struct iwl4965_priv *priv,
  621. struct iwl4965_frame *frame, u8 rate);
  622. extern int iwl4965_hw_get_rx_read(struct iwl4965_priv *priv);
  623. extern void iwl4965_hw_build_tx_cmd_rate(struct iwl4965_priv *priv,
  624. struct iwl4965_cmd *cmd,
  625. struct ieee80211_tx_control *ctrl,
  626. struct ieee80211_hdr *hdr,
  627. int sta_id, int tx_id);
  628. extern int iwl4965_hw_reg_send_txpower(struct iwl4965_priv *priv);
  629. extern int iwl4965_hw_reg_set_txpower(struct iwl4965_priv *priv, s8 power);
  630. extern void iwl4965_hw_rx_statistics(struct iwl4965_priv *priv,
  631. struct iwl4965_rx_mem_buffer *rxb);
  632. extern void iwl4965_disable_events(struct iwl4965_priv *priv);
  633. extern int iwl4965_get_temperature(const struct iwl4965_priv *priv);
  634. /**
  635. * iwl4965_hw_find_station - Find station id for a given BSSID
  636. * @bssid: MAC address of station ID to find
  637. *
  638. * NOTE: This should not be hardware specific but the code has
  639. * not yet been merged into a single common layer for managing the
  640. * station tables.
  641. */
  642. extern u8 iwl4965_hw_find_station(struct iwl4965_priv *priv, const u8 *bssid);
  643. extern int iwl4965_hw_channel_switch(struct iwl4965_priv *priv, u16 channel);
  644. extern int iwl4965_tx_queue_reclaim(struct iwl4965_priv *priv, int txq_id, int index);
  645. struct iwl4965_priv;
  646. struct sta_ht_info;
  647. /*
  648. * Forward declare iwl-4965.c functions for iwl-base.c
  649. */
  650. extern int iwl4965_eeprom_acquire_semaphore(struct iwl4965_priv *priv);
  651. extern void iwl4965_eeprom_release_semaphore(struct iwl4965_priv *priv);
  652. extern int iwl4965_tx_queue_update_wr_ptr(struct iwl4965_priv *priv,
  653. struct iwl4965_tx_queue *txq,
  654. u16 byte_cnt);
  655. extern void iwl4965_add_station(struct iwl4965_priv *priv, const u8 *addr,
  656. int is_ap);
  657. extern void iwl4965_set_rxon_ht(struct iwl4965_priv *priv,
  658. struct sta_ht_info *ht_info);
  659. extern void iwl4965_set_rxon_chain(struct iwl4965_priv *priv);
  660. extern int iwl4965_tx_cmd(struct iwl4965_priv *priv, struct iwl4965_cmd *out_cmd,
  661. u8 sta_id, dma_addr_t txcmd_phys,
  662. struct ieee80211_hdr *hdr, u8 hdr_len,
  663. struct ieee80211_tx_control *ctrl, void *sta_in);
  664. extern int iwl4965_alive_notify(struct iwl4965_priv *priv);
  665. extern void iwl4965_update_rate_scaling(struct iwl4965_priv *priv, u8 mode);
  666. extern void iwl4965_set_ht_add_station(struct iwl4965_priv *priv, u8 index);
  667. extern void iwl4965_chain_noise_reset(struct iwl4965_priv *priv);
  668. extern void iwl4965_init_sensitivity(struct iwl4965_priv *priv, u8 flags,
  669. u8 force);
  670. extern int iwl4965_set_fat_chan_info(struct iwl4965_priv *priv, int phymode,
  671. u16 channel,
  672. const struct iwl4965_eeprom_channel *eeprom_ch,
  673. u8 fat_extension_channel);
  674. extern void iwl4965_rf_kill_ct_config(struct iwl4965_priv *priv);
  675. #ifdef CONFIG_IWL4965_HT
  676. #ifdef CONFIG_IWL4965_HT_AGG
  677. extern int iwl4965_mac_ht_tx_agg_start(struct ieee80211_hw *hw, u8 *da,
  678. u16 tid, u16 *start_seq_num);
  679. extern int iwl4965_mac_ht_rx_agg_start(struct ieee80211_hw *hw, u8 *da,
  680. u16 tid, u16 start_seq_num);
  681. extern int iwl4965_mac_ht_rx_agg_stop(struct ieee80211_hw *hw, u8 *da,
  682. u16 tid, int generator);
  683. extern int iwl4965_mac_ht_tx_agg_stop(struct ieee80211_hw *hw, u8 *da,
  684. u16 tid, int generator);
  685. extern void iwl4965_turn_off_agg(struct iwl4965_priv *priv, u8 tid);
  686. #endif /* CONFIG_IWL4965_HT_AGG */
  687. #endif /*CONFIG_IWL4965_HT */
  688. /* Structures, enum, and defines specific to the 4965 */
  689. #define IWL4965_KW_SIZE 0x1000 /*4k */
  690. struct iwl4965_kw {
  691. dma_addr_t dma_addr;
  692. void *v_addr;
  693. size_t size;
  694. };
  695. #define TID_QUEUE_CELL_SPACING 50 /*mS */
  696. #define TID_QUEUE_MAX_SIZE 20
  697. #define TID_ROUND_VALUE 5 /* mS */
  698. #define TID_MAX_LOAD_COUNT 8
  699. #define TID_MAX_TIME_DIFF ((TID_QUEUE_MAX_SIZE - 1) * TID_QUEUE_CELL_SPACING)
  700. #define TIME_WRAP_AROUND(x, y) (((y) > (x)) ? (y) - (x) : (0-(x)) + (y))
  701. #define TID_ALL_ENABLED 0x7f
  702. #define TID_ALL_SPECIFIED 0xff
  703. #define TID_AGG_TPT_THREHOLD 0x0
  704. #define IWL_CHANNEL_WIDTH_20MHZ 0
  705. #define IWL_CHANNEL_WIDTH_40MHZ 1
  706. #define IWL_MIMO_PS_STATIC 0
  707. #define IWL_MIMO_PS_NONE 3
  708. #define IWL_MIMO_PS_DYNAMIC 1
  709. #define IWL_MIMO_PS_INVALID 2
  710. #define IWL_OPERATION_MODE_AUTO 0
  711. #define IWL_OPERATION_MODE_HT_ONLY 1
  712. #define IWL_OPERATION_MODE_MIXED 2
  713. #define IWL_OPERATION_MODE_20MHZ 3
  714. #define IWL_EXT_CHANNEL_OFFSET_AUTO 0
  715. #define IWL_EXT_CHANNEL_OFFSET_ABOVE 1
  716. #define IWL_EXT_CHANNEL_OFFSET_ 2
  717. #define IWL_EXT_CHANNEL_OFFSET_BELOW 3
  718. #define IWL_EXT_CHANNEL_OFFSET_MAX 4
  719. #define NRG_NUM_PREV_STAT_L 20
  720. #define NUM_RX_CHAINS (3)
  721. #define TX_POWER_IWL_ILLEGAL_VDET -100000
  722. #define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000
  723. #define TX_POWER_IWL_CLOSED_LOOP_MIN_POWER 18
  724. #define TX_POWER_IWL_CLOSED_LOOP_MAX_POWER 34
  725. #define TX_POWER_IWL_VDET_SLOPE_BELOW_NOMINAL 17
  726. #define TX_POWER_IWL_VDET_SLOPE_ABOVE_NOMINAL 20
  727. #define TX_POWER_IWL_NOMINAL_POWER 26
  728. #define TX_POWER_IWL_CLOSED_LOOP_ITERATION_LIMIT 1
  729. #define TX_POWER_IWL_VOLTAGE_CODES_PER_03V 7
  730. #define TX_POWER_IWL_DEGREES_PER_VDET_CODE 11
  731. #define IWL_TX_POWER_MAX_NUM_PA_MEASUREMENTS 1
  732. #define IWL_TX_POWER_CCK_COMPENSATION_B_STEP (9)
  733. #define IWL_TX_POWER_CCK_COMPENSATION_C_STEP (5)
  734. struct iwl4965_traffic_load {
  735. unsigned long time_stamp;
  736. u32 packet_count[TID_QUEUE_MAX_SIZE];
  737. u8 queue_count;
  738. u8 head;
  739. u32 total;
  740. };
  741. #ifdef CONFIG_IWL4965_HT_AGG
  742. struct iwl4965_agg_control {
  743. unsigned long next_retry;
  744. u32 wait_for_agg_status;
  745. u32 tid_retry;
  746. u32 requested_ba;
  747. u32 granted_ba;
  748. u8 auto_agg;
  749. u32 tid_traffic_load_threshold;
  750. u32 ba_timeout;
  751. struct iwl4965_traffic_load traffic_load[TID_MAX_LOAD_COUNT];
  752. };
  753. #endif /*CONFIG_IWL4965_HT_AGG */
  754. struct iwl4965_lq_mngr {
  755. #ifdef CONFIG_IWL4965_HT_AGG
  756. struct iwl4965_agg_control agg_ctrl;
  757. #endif
  758. spinlock_t lock;
  759. s32 max_window_size;
  760. s32 *expected_tpt;
  761. u8 *next_higher_rate;
  762. u8 *next_lower_rate;
  763. unsigned long stamp;
  764. unsigned long stamp_last;
  765. u32 flush_time;
  766. u32 tx_packets;
  767. u8 lq_ready;
  768. };
  769. /* Sensitivity and chain noise calibration */
  770. #define INTERFERENCE_DATA_AVAILABLE __constant_cpu_to_le32(1)
  771. #define INITIALIZATION_VALUE 0xFFFF
  772. #define CAL_NUM_OF_BEACONS 20
  773. #define MAXIMUM_ALLOWED_PATHLOSS 15
  774. /* Param table within SENSITIVITY_CMD */
  775. #define HD_MIN_ENERGY_CCK_DET_INDEX (0)
  776. #define HD_MIN_ENERGY_OFDM_DET_INDEX (1)
  777. #define HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX (2)
  778. #define HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX (3)
  779. #define HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX (4)
  780. #define HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX (5)
  781. #define HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX (6)
  782. #define HD_BARKER_CORR_TH_ADD_MIN_INDEX (7)
  783. #define HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX (8)
  784. #define HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX (9)
  785. #define HD_OFDM_ENERGY_TH_IN_INDEX (10)
  786. #define SENSITIVITY_CMD_CONTROL_DEFAULT_TABLE __constant_cpu_to_le16(0)
  787. #define SENSITIVITY_CMD_CONTROL_WORK_TABLE __constant_cpu_to_le16(1)
  788. #define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3
  789. #define MAX_FA_OFDM 50
  790. #define MIN_FA_OFDM 5
  791. #define MAX_FA_CCK 50
  792. #define MIN_FA_CCK 5
  793. #define NRG_MIN_CCK 97
  794. #define NRG_MAX_CCK 0
  795. #define AUTO_CORR_MIN_OFDM 85
  796. #define AUTO_CORR_MIN_OFDM_MRC 170
  797. #define AUTO_CORR_MIN_OFDM_X1 105
  798. #define AUTO_CORR_MIN_OFDM_MRC_X1 220
  799. #define AUTO_CORR_MAX_OFDM 120
  800. #define AUTO_CORR_MAX_OFDM_MRC 210
  801. #define AUTO_CORR_MAX_OFDM_X1 140
  802. #define AUTO_CORR_MAX_OFDM_MRC_X1 270
  803. #define AUTO_CORR_STEP_OFDM 1
  804. #define AUTO_CORR_MIN_CCK (125)
  805. #define AUTO_CORR_MAX_CCK (200)
  806. #define AUTO_CORR_MIN_CCK_MRC 200
  807. #define AUTO_CORR_MAX_CCK_MRC 400
  808. #define AUTO_CORR_STEP_CCK 3
  809. #define AUTO_CORR_MAX_TH_CCK 160
  810. #define NRG_ALG 0
  811. #define AUTO_CORR_ALG 1
  812. #define NRG_DIFF 2
  813. #define NRG_STEP_CCK 2
  814. #define NRG_MARGIN 8
  815. #define MAX_NUMBER_CCK_NO_FA 100
  816. #define AUTO_CORR_CCK_MIN_VAL_DEF (125)
  817. #define CHAIN_A 0
  818. #define CHAIN_B 1
  819. #define CHAIN_C 2
  820. #define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4
  821. #define ALL_BAND_FILTER 0xFF00
  822. #define IN_BAND_FILTER 0xFF
  823. #define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF
  824. enum iwl4965_false_alarm_state {
  825. IWL_FA_TOO_MANY = 0,
  826. IWL_FA_TOO_FEW = 1,
  827. IWL_FA_GOOD_RANGE = 2,
  828. };
  829. enum iwl4965_chain_noise_state {
  830. IWL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */
  831. IWL_CHAIN_NOISE_ACCUMULATE = 1,
  832. IWL_CHAIN_NOISE_CALIBRATED = 2,
  833. };
  834. enum iwl4965_sensitivity_state {
  835. IWL_SENS_CALIB_ALLOWED = 0,
  836. IWL_SENS_CALIB_NEED_REINIT = 1,
  837. };
  838. enum iwl4965_calib_enabled_state {
  839. IWL_CALIB_DISABLED = 0, /* must be 0 */
  840. IWL_CALIB_ENABLED = 1,
  841. };
  842. struct statistics_general_data {
  843. u32 beacon_silence_rssi_a;
  844. u32 beacon_silence_rssi_b;
  845. u32 beacon_silence_rssi_c;
  846. u32 beacon_energy_a;
  847. u32 beacon_energy_b;
  848. u32 beacon_energy_c;
  849. };
  850. /* Sensitivity calib data */
  851. struct iwl4965_sensitivity_data {
  852. u32 auto_corr_ofdm;
  853. u32 auto_corr_ofdm_mrc;
  854. u32 auto_corr_ofdm_x1;
  855. u32 auto_corr_ofdm_mrc_x1;
  856. u32 auto_corr_cck;
  857. u32 auto_corr_cck_mrc;
  858. u32 last_bad_plcp_cnt_ofdm;
  859. u32 last_fa_cnt_ofdm;
  860. u32 last_bad_plcp_cnt_cck;
  861. u32 last_fa_cnt_cck;
  862. u32 nrg_curr_state;
  863. u32 nrg_prev_state;
  864. u32 nrg_value[10];
  865. u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L];
  866. u32 nrg_silence_ref;
  867. u32 nrg_energy_idx;
  868. u32 nrg_silence_idx;
  869. u32 nrg_th_cck;
  870. s32 nrg_auto_corr_silence_diff;
  871. u32 num_in_cck_no_fa;
  872. u32 nrg_th_ofdm;
  873. u8 state;
  874. };
  875. /* Chain noise (differential Rx gain) calib data */
  876. struct iwl4965_chain_noise_data {
  877. u8 state;
  878. u16 beacon_count;
  879. u32 chain_noise_a;
  880. u32 chain_noise_b;
  881. u32 chain_noise_c;
  882. u32 chain_signal_a;
  883. u32 chain_signal_b;
  884. u32 chain_signal_c;
  885. u8 disconn_array[NUM_RX_CHAINS];
  886. u8 delta_gain_code[NUM_RX_CHAINS];
  887. u8 radio_write;
  888. };
  889. /* IWL4965 */
  890. #define RATE_MCS_CODE_MSK 0x7
  891. #define RATE_MCS_MIMO_POS 3
  892. #define RATE_MCS_MIMO_MSK 0x8
  893. #define RATE_MCS_HT_DUP_POS 5
  894. #define RATE_MCS_HT_DUP_MSK 0x20
  895. #define RATE_MCS_FLAGS_POS 8
  896. #define RATE_MCS_HT_POS 8
  897. #define RATE_MCS_HT_MSK 0x100
  898. #define RATE_MCS_CCK_POS 9
  899. #define RATE_MCS_CCK_MSK 0x200
  900. #define RATE_MCS_GF_POS 10
  901. #define RATE_MCS_GF_MSK 0x400
  902. #define RATE_MCS_FAT_POS 11
  903. #define RATE_MCS_FAT_MSK 0x800
  904. #define RATE_MCS_DUP_POS 12
  905. #define RATE_MCS_DUP_MSK 0x1000
  906. #define RATE_MCS_SGI_POS 13
  907. #define RATE_MCS_SGI_MSK 0x2000
  908. #define EEPROM_SEM_TIMEOUT 10
  909. #define EEPROM_SEM_RETRY_LIMIT 1000
  910. #ifdef CONFIG_IWL4965_SPECTRUM_MEASUREMENT
  911. enum {
  912. MEASUREMENT_READY = (1 << 0),
  913. MEASUREMENT_ACTIVE = (1 << 1),
  914. };
  915. #endif
  916. struct iwl4965_priv {
  917. /* ieee device used by generic ieee processing code */
  918. struct ieee80211_hw *hw;
  919. struct ieee80211_channel *ieee_channels;
  920. struct ieee80211_rate *ieee_rates;
  921. /* temporary frame storage list */
  922. struct list_head free_frames;
  923. int frames_count;
  924. u8 phymode;
  925. int alloc_rxb_skb;
  926. void (*rx_handlers[REPLY_MAX])(struct iwl4965_priv *priv,
  927. struct iwl4965_rx_mem_buffer *rxb);
  928. const struct ieee80211_hw_mode *modes;
  929. #ifdef CONFIG_IWL4965_SPECTRUM_MEASUREMENT
  930. /* spectrum measurement report caching */
  931. struct iwl4965_spectrum_notification measure_report;
  932. u8 measurement_status;
  933. #endif
  934. /* ucode beacon time */
  935. u32 ucode_beacon_time;
  936. /* we allocate array of iwl4965_channel_info for NIC's valid channels.
  937. * Access via channel # using indirect index array */
  938. struct iwl4965_channel_info *channel_info; /* channel info array */
  939. u8 channel_count; /* # of channels */
  940. /* each calibration channel group in the EEPROM has a derived
  941. * clip setting for each rate. */
  942. const struct iwl4965_clip_group clip_groups[5];
  943. /* thermal calibration */
  944. s32 temperature; /* degrees Kelvin */
  945. s32 last_temperature;
  946. /* Scan related variables */
  947. unsigned long last_scan_jiffies;
  948. unsigned long scan_start;
  949. unsigned long scan_pass_start;
  950. unsigned long scan_start_tsf;
  951. int scan_bands;
  952. int one_direct_scan;
  953. u8 direct_ssid_len;
  954. u8 direct_ssid[IW_ESSID_MAX_SIZE];
  955. struct iwl4965_scan_cmd *scan;
  956. u8 only_active_channel;
  957. /* spinlock */
  958. spinlock_t lock; /* protect general shared data */
  959. spinlock_t hcmd_lock; /* protect hcmd */
  960. struct mutex mutex;
  961. /* basic pci-network driver stuff */
  962. struct pci_dev *pci_dev;
  963. /* pci hardware address support */
  964. void __iomem *hw_base;
  965. /* uCode images, save to reload in case of failure */
  966. struct fw_desc ucode_code; /* runtime inst */
  967. struct fw_desc ucode_data; /* runtime data original */
  968. struct fw_desc ucode_data_backup; /* runtime data save/restore */
  969. struct fw_desc ucode_init; /* initialization inst */
  970. struct fw_desc ucode_init_data; /* initialization data */
  971. struct fw_desc ucode_boot; /* bootstrap inst */
  972. struct iwl4965_rxon_time_cmd rxon_timing;
  973. /* We declare this const so it can only be
  974. * changed via explicit cast within the
  975. * routines that actually update the physical
  976. * hardware */
  977. const struct iwl4965_rxon_cmd active_rxon;
  978. struct iwl4965_rxon_cmd staging_rxon;
  979. int error_recovering;
  980. struct iwl4965_rxon_cmd recovery_rxon;
  981. /* 1st responses from initialize and runtime uCode images.
  982. * 4965's initialize alive response contains some calibration data. */
  983. struct iwl4965_init_alive_resp card_alive_init;
  984. struct iwl4965_alive_resp card_alive;
  985. #ifdef LED
  986. /* LED related variables */
  987. struct iwl4965_activity_blink activity;
  988. unsigned long led_packets;
  989. int led_state;
  990. #endif
  991. u16 active_rate;
  992. u16 active_rate_basic;
  993. u8 call_post_assoc_from_beacon;
  994. u8 assoc_station_added;
  995. u8 use_ant_b_for_management_frame; /* Tx antenna selection */
  996. /* HT variables */
  997. u8 is_dup;
  998. u8 is_ht_enabled;
  999. u8 channel_width; /* 0=20MHZ, 1=40MHZ */
  1000. u8 current_channel_width;
  1001. u8 valid_antenna; /* Bit mask of antennas actually connected */
  1002. #ifdef CONFIG_IWL4965_SENSITIVITY
  1003. struct iwl4965_sensitivity_data sensitivity_data;
  1004. struct iwl4965_chain_noise_data chain_noise_data;
  1005. u8 start_calib;
  1006. __le16 sensitivity_tbl[HD_TABLE_SIZE];
  1007. #endif /*CONFIG_IWL4965_SENSITIVITY*/
  1008. #ifdef CONFIG_IWL4965_HT
  1009. struct sta_ht_info current_assoc_ht;
  1010. #endif
  1011. u8 active_rate_ht[2];
  1012. u8 last_phy_res[100];
  1013. /* Rate scaling data */
  1014. struct iwl4965_lq_mngr lq_mngr;
  1015. /* Rate scaling data */
  1016. s8 data_retry_limit;
  1017. u8 retry_rate;
  1018. wait_queue_head_t wait_command_queue;
  1019. int activity_timer_active;
  1020. /* Rx and Tx DMA processing queues */
  1021. struct iwl4965_rx_queue rxq;
  1022. struct iwl4965_tx_queue txq[IWL_MAX_NUM_QUEUES];
  1023. unsigned long txq_ctx_active_msk;
  1024. struct iwl4965_kw kw; /* keep warm address */
  1025. u32 scd_base_addr; /* scheduler sram base address */
  1026. unsigned long status;
  1027. u32 config;
  1028. int last_rx_rssi; /* From Rx packet statisitics */
  1029. int last_rx_noise; /* From beacon statistics */
  1030. struct iwl4965_power_mgr power_data;
  1031. struct iwl4965_notif_statistics statistics;
  1032. unsigned long last_statistics_time;
  1033. /* context information */
  1034. u8 essid[IW_ESSID_MAX_SIZE];
  1035. u8 essid_len;
  1036. u16 rates_mask;
  1037. u32 power_mode;
  1038. u32 antenna;
  1039. u8 bssid[ETH_ALEN];
  1040. u16 rts_threshold;
  1041. u8 mac_addr[ETH_ALEN];
  1042. /*station table variables */
  1043. spinlock_t sta_lock;
  1044. int num_stations;
  1045. struct iwl4965_station_entry stations[IWL_STATION_COUNT];
  1046. /* Indication if ieee80211_ops->open has been called */
  1047. int is_open;
  1048. u8 mac80211_registered;
  1049. int is_abg;
  1050. u32 notif_missed_beacons;
  1051. /* Rx'd packet timing information */
  1052. u32 last_beacon_time;
  1053. u64 last_tsf;
  1054. /* Duplicate packet detection */
  1055. u16 last_seq_num;
  1056. u16 last_frag_num;
  1057. unsigned long last_packet_time;
  1058. struct list_head ibss_mac_hash[IWL_IBSS_MAC_HASH_SIZE];
  1059. /* eeprom */
  1060. struct iwl4965_eeprom eeprom;
  1061. int iw_mode;
  1062. struct sk_buff *ibss_beacon;
  1063. /* Last Rx'd beacon timestamp */
  1064. u32 timestamp0;
  1065. u32 timestamp1;
  1066. u16 beacon_int;
  1067. struct iwl4965_driver_hw_info hw_setting;
  1068. int interface_id;
  1069. /* Current association information needed to configure the
  1070. * hardware */
  1071. u16 assoc_id;
  1072. u16 assoc_capability;
  1073. u8 ps_mode;
  1074. #ifdef CONFIG_IWL4965_QOS
  1075. struct iwl4965_qos_info qos_data;
  1076. #endif /*CONFIG_IWL4965_QOS */
  1077. struct workqueue_struct *workqueue;
  1078. struct work_struct up;
  1079. struct work_struct restart;
  1080. struct work_struct calibrated_work;
  1081. struct work_struct scan_completed;
  1082. struct work_struct rx_replenish;
  1083. struct work_struct rf_kill;
  1084. struct work_struct abort_scan;
  1085. struct work_struct update_link_led;
  1086. struct work_struct auth_work;
  1087. struct work_struct report_work;
  1088. struct work_struct request_scan;
  1089. struct work_struct beacon_update;
  1090. struct tasklet_struct irq_tasklet;
  1091. struct delayed_work init_alive_start;
  1092. struct delayed_work alive_start;
  1093. struct delayed_work activity_timer;
  1094. struct delayed_work thermal_periodic;
  1095. struct delayed_work gather_stats;
  1096. struct delayed_work scan_check;
  1097. struct delayed_work post_associate;
  1098. #define IWL_DEFAULT_TX_POWER 0x0F
  1099. s8 user_txpower_limit;
  1100. s8 max_channel_txpower_limit;
  1101. #ifdef CONFIG_PM
  1102. u32 pm_state[16];
  1103. #endif
  1104. #ifdef CONFIG_IWL4965_DEBUG
  1105. /* debugging info */
  1106. u32 framecnt_to_us;
  1107. atomic_t restrict_refcnt;
  1108. #endif
  1109. struct work_struct txpower_work;
  1110. #ifdef CONFIG_IWL4965_SENSITIVITY
  1111. struct work_struct sensitivity_work;
  1112. #endif
  1113. struct work_struct statistics_work;
  1114. struct timer_list statistics_periodic;
  1115. #ifdef CONFIG_IWL4965_HT_AGG
  1116. struct work_struct agg_work;
  1117. #endif
  1118. }; /*iwl4965_priv */
  1119. static inline int iwl4965_is_associated(struct iwl4965_priv *priv)
  1120. {
  1121. return (priv->active_rxon.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
  1122. }
  1123. static inline int is_channel_valid(const struct iwl4965_channel_info *ch_info)
  1124. {
  1125. if (ch_info == NULL)
  1126. return 0;
  1127. return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0;
  1128. }
  1129. static inline int is_channel_narrow(const struct iwl4965_channel_info *ch_info)
  1130. {
  1131. return (ch_info->flags & EEPROM_CHANNEL_NARROW) ? 1 : 0;
  1132. }
  1133. static inline int is_channel_radar(const struct iwl4965_channel_info *ch_info)
  1134. {
  1135. return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0;
  1136. }
  1137. static inline u8 is_channel_a_band(const struct iwl4965_channel_info *ch_info)
  1138. {
  1139. return ch_info->phymode == MODE_IEEE80211A;
  1140. }
  1141. static inline u8 is_channel_bg_band(const struct iwl4965_channel_info *ch_info)
  1142. {
  1143. return ((ch_info->phymode == MODE_IEEE80211B) ||
  1144. (ch_info->phymode == MODE_IEEE80211G));
  1145. }
  1146. static inline int is_channel_passive(const struct iwl4965_channel_info *ch)
  1147. {
  1148. return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0;
  1149. }
  1150. static inline int is_channel_ibss(const struct iwl4965_channel_info *ch)
  1151. {
  1152. return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0;
  1153. }
  1154. extern const struct iwl4965_channel_info *iwl4965_get_channel_info(
  1155. const struct iwl4965_priv *priv, int phymode, u16 channel);
  1156. /* Requires full declaration of iwl4965_priv before including */
  1157. #include "iwl-4965-io.h"
  1158. #endif /* __iwl4965_4965_h__ */