ipw2200.h 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680
  1. /******************************************************************************
  2. Copyright(c) 2003 - 2004 Intel Corporation. All rights reserved.
  3. This program is free software; you can redistribute it and/or modify it
  4. under the terms of version 2 of the GNU General Public License as
  5. published by the Free Software Foundation.
  6. This program is distributed in the hope that it will be useful, but WITHOUT
  7. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  8. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  9. more details.
  10. You should have received a copy of the GNU General Public License along with
  11. this program; if not, write to the Free Software Foundation, Inc., 59
  12. Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  13. The full GNU General Public License is included in this distribution in the
  14. file called LICENSE.
  15. Contact Information:
  16. James P. Ketrenos <ipw2100-admin@linux.intel.com>
  17. Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  18. ******************************************************************************/
  19. #ifndef __ipw2200_h__
  20. #define __ipw2200_h__
  21. #define WEXT_USECHANNELS 1
  22. #include <linux/module.h>
  23. #include <linux/moduleparam.h>
  24. #include <linux/config.h>
  25. #include <linux/init.h>
  26. #include <linux/version.h>
  27. #include <linux/pci.h>
  28. #include <linux/netdevice.h>
  29. #include <linux/ethtool.h>
  30. #include <linux/skbuff.h>
  31. #include <linux/etherdevice.h>
  32. #include <linux/delay.h>
  33. #include <linux/random.h>
  34. #include <linux/dma-mapping.h>
  35. #include <linux/firmware.h>
  36. #include <linux/wireless.h>
  37. #include <linux/dma-mapping.h>
  38. #include <asm/io.h>
  39. #include <net/ieee80211.h>
  40. #define DRV_NAME "ipw2200"
  41. #include <linux/workqueue.h>
  42. /* Authentication and Association States */
  43. enum connection_manager_assoc_states {
  44. CMAS_INIT = 0,
  45. CMAS_TX_AUTH_SEQ_1,
  46. CMAS_RX_AUTH_SEQ_2,
  47. CMAS_AUTH_SEQ_1_PASS,
  48. CMAS_AUTH_SEQ_1_FAIL,
  49. CMAS_TX_AUTH_SEQ_3,
  50. CMAS_RX_AUTH_SEQ_4,
  51. CMAS_AUTH_SEQ_2_PASS,
  52. CMAS_AUTH_SEQ_2_FAIL,
  53. CMAS_AUTHENTICATED,
  54. CMAS_TX_ASSOC,
  55. CMAS_RX_ASSOC_RESP,
  56. CMAS_ASSOCIATED,
  57. CMAS_LAST
  58. };
  59. #define IPW_WAIT (1<<0)
  60. #define IPW_QUIET (1<<1)
  61. #define IPW_ROAMING (1<<2)
  62. #define IPW_POWER_MODE_CAM 0x00 //(always on)
  63. #define IPW_POWER_INDEX_1 0x01
  64. #define IPW_POWER_INDEX_2 0x02
  65. #define IPW_POWER_INDEX_3 0x03
  66. #define IPW_POWER_INDEX_4 0x04
  67. #define IPW_POWER_INDEX_5 0x05
  68. #define IPW_POWER_AC 0x06
  69. #define IPW_POWER_BATTERY 0x07
  70. #define IPW_POWER_LIMIT 0x07
  71. #define IPW_POWER_MASK 0x0F
  72. #define IPW_POWER_ENABLED 0x10
  73. #define IPW_POWER_LEVEL(x) ((x) & IPW_POWER_MASK)
  74. #define IPW_CMD_HOST_COMPLETE 2
  75. #define IPW_CMD_POWER_DOWN 4
  76. #define IPW_CMD_SYSTEM_CONFIG 6
  77. #define IPW_CMD_MULTICAST_ADDRESS 7
  78. #define IPW_CMD_SSID 8
  79. #define IPW_CMD_ADAPTER_ADDRESS 11
  80. #define IPW_CMD_PORT_TYPE 12
  81. #define IPW_CMD_RTS_THRESHOLD 15
  82. #define IPW_CMD_FRAG_THRESHOLD 16
  83. #define IPW_CMD_POWER_MODE 17
  84. #define IPW_CMD_WEP_KEY 18
  85. #define IPW_CMD_TGI_TX_KEY 19
  86. #define IPW_CMD_SCAN_REQUEST 20
  87. #define IPW_CMD_ASSOCIATE 21
  88. #define IPW_CMD_SUPPORTED_RATES 22
  89. #define IPW_CMD_SCAN_ABORT 23
  90. #define IPW_CMD_TX_FLUSH 24
  91. #define IPW_CMD_QOS_PARAMETERS 25
  92. #define IPW_CMD_SCAN_REQUEST_EXT 26
  93. #define IPW_CMD_DINO_CONFIG 30
  94. #define IPW_CMD_RSN_CAPABILITIES 31
  95. #define IPW_CMD_RX_KEY 32
  96. #define IPW_CMD_CARD_DISABLE 33
  97. #define IPW_CMD_SEED_NUMBER 34
  98. #define IPW_CMD_TX_POWER 35
  99. #define IPW_CMD_COUNTRY_INFO 36
  100. #define IPW_CMD_AIRONET_INFO 37
  101. #define IPW_CMD_AP_TX_POWER 38
  102. #define IPW_CMD_CCKM_INFO 39
  103. #define IPW_CMD_CCX_VER_INFO 40
  104. #define IPW_CMD_SET_CALIBRATION 41
  105. #define IPW_CMD_SENSITIVITY_CALIB 42
  106. #define IPW_CMD_RETRY_LIMIT 51
  107. #define IPW_CMD_IPW_PRE_POWER_DOWN 58
  108. #define IPW_CMD_VAP_BEACON_TEMPLATE 60
  109. #define IPW_CMD_VAP_DTIM_PERIOD 61
  110. #define IPW_CMD_EXT_SUPPORTED_RATES 62
  111. #define IPW_CMD_VAP_LOCAL_TX_PWR_CONSTRAINT 63
  112. #define IPW_CMD_VAP_QUIET_INTERVALS 64
  113. #define IPW_CMD_VAP_CHANNEL_SWITCH 65
  114. #define IPW_CMD_VAP_MANDATORY_CHANNELS 66
  115. #define IPW_CMD_VAP_CELL_PWR_LIMIT 67
  116. #define IPW_CMD_VAP_CF_PARAM_SET 68
  117. #define IPW_CMD_VAP_SET_BEACONING_STATE 69
  118. #define IPW_CMD_MEASUREMENT 80
  119. #define IPW_CMD_POWER_CAPABILITY 81
  120. #define IPW_CMD_SUPPORTED_CHANNELS 82
  121. #define IPW_CMD_TPC_REPORT 83
  122. #define IPW_CMD_WME_INFO 84
  123. #define IPW_CMD_PRODUCTION_COMMAND 85
  124. #define IPW_CMD_LINKSYS_EOU_INFO 90
  125. #define RFD_SIZE 4
  126. #define NUM_TFD_CHUNKS 6
  127. #define TX_QUEUE_SIZE 32
  128. #define RX_QUEUE_SIZE 32
  129. #define DINO_CMD_WEP_KEY 0x08
  130. #define DINO_CMD_TX 0x0B
  131. #define DCT_ANTENNA_A 0x01
  132. #define DCT_ANTENNA_B 0x02
  133. #define IPW_A_MODE 0
  134. #define IPW_B_MODE 1
  135. #define IPW_G_MODE 2
  136. /*
  137. * TX Queue Flag Definitions
  138. */
  139. /* abort attempt if mgmt frame is rx'd */
  140. #define DCT_FLAG_ABORT_MGMT 0x01
  141. /* require CTS */
  142. #define DCT_FLAG_CTS_REQUIRED 0x02
  143. /* use short preamble */
  144. #define DCT_FLAG_SHORT_PREMBL 0x04
  145. /* RTS/CTS first */
  146. #define DCT_FLAG_RTS_REQD 0x08
  147. /* dont calculate duration field */
  148. #define DCT_FLAG_DUR_SET 0x10
  149. /* even if MAC WEP set (allows pre-encrypt) */
  150. #define DCT_FLAG_NO_WEP 0x20
  151. /* overwrite TSF field */
  152. #define DCT_FLAG_TSF_REQD 0x40
  153. /* ACK rx is expected to follow */
  154. #define DCT_FLAG_ACK_REQD 0x80
  155. #define DCT_FLAG_EXT_MODE_CCK 0x01
  156. #define DCT_FLAG_EXT_MODE_OFDM 0x00
  157. #define TX_RX_TYPE_MASK 0xFF
  158. #define TX_FRAME_TYPE 0x00
  159. #define TX_HOST_COMMAND_TYPE 0x01
  160. #define RX_FRAME_TYPE 0x09
  161. #define RX_HOST_NOTIFICATION_TYPE 0x03
  162. #define RX_HOST_CMD_RESPONSE_TYPE 0x04
  163. #define RX_TX_FRAME_RESPONSE_TYPE 0x05
  164. #define TFD_NEED_IRQ_MASK 0x04
  165. #define HOST_CMD_DINO_CONFIG 30
  166. #define HOST_NOTIFICATION_STATUS_ASSOCIATED 10
  167. #define HOST_NOTIFICATION_STATUS_AUTHENTICATE 11
  168. #define HOST_NOTIFICATION_STATUS_SCAN_CHANNEL_RESULT 12
  169. #define HOST_NOTIFICATION_STATUS_SCAN_COMPLETED 13
  170. #define HOST_NOTIFICATION_STATUS_FRAG_LENGTH 14
  171. #define HOST_NOTIFICATION_STATUS_LINK_DETERIORATION 15
  172. #define HOST_NOTIFICATION_DINO_CONFIG_RESPONSE 16
  173. #define HOST_NOTIFICATION_STATUS_BEACON_STATE 17
  174. #define HOST_NOTIFICATION_STATUS_TGI_TX_KEY 18
  175. #define HOST_NOTIFICATION_TX_STATUS 19
  176. #define HOST_NOTIFICATION_CALIB_KEEP_RESULTS 20
  177. #define HOST_NOTIFICATION_MEASUREMENT_STARTED 21
  178. #define HOST_NOTIFICATION_MEASUREMENT_ENDED 22
  179. #define HOST_NOTIFICATION_CHANNEL_SWITCHED 23
  180. #define HOST_NOTIFICATION_RX_DURING_QUIET_PERIOD 24
  181. #define HOST_NOTIFICATION_NOISE_STATS 25
  182. #define HOST_NOTIFICATION_S36_MEASUREMENT_ACCEPTED 30
  183. #define HOST_NOTIFICATION_S36_MEASUREMENT_REFUSED 31
  184. #define HOST_NOTIFICATION_STATUS_BEACON_MISSING 1
  185. #define IPW_MB_DISASSOCIATE_THRESHOLD_DEFAULT 24
  186. #define IPW_MB_ROAMING_THRESHOLD_DEFAULT 8
  187. #define IPW_REAL_RATE_RX_PACKET_THRESHOLD 300
  188. #define MACADRR_BYTE_LEN 6
  189. #define DCR_TYPE_AP 0x01
  190. #define DCR_TYPE_WLAP 0x02
  191. #define DCR_TYPE_MU_ESS 0x03
  192. #define DCR_TYPE_MU_IBSS 0x04
  193. #define DCR_TYPE_MU_PIBSS 0x05
  194. #define DCR_TYPE_SNIFFER 0x06
  195. #define DCR_TYPE_MU_BSS DCR_TYPE_MU_ESS
  196. /**
  197. * Generic queue structure
  198. *
  199. * Contains common data for Rx and Tx queues
  200. */
  201. struct clx2_queue {
  202. int n_bd; /**< number of BDs in this queue */
  203. int first_empty; /**< 1-st empty entry (index) */
  204. int last_used; /**< last used entry (index) */
  205. u32 reg_w; /**< 'write' reg (queue head), addr in domain 1 */
  206. u32 reg_r; /**< 'read' reg (queue tail), addr in domain 1 */
  207. dma_addr_t dma_addr; /**< physical addr for BD's */
  208. int low_mark; /**< low watermark, resume queue if free space more than this */
  209. int high_mark; /**< high watermark, stop queue if free space less than this */
  210. } __attribute__ ((packed));
  211. struct machdr32 {
  212. u16 frame_ctl;
  213. u16 duration; // watch out for endians!
  214. u8 addr1[MACADRR_BYTE_LEN];
  215. u8 addr2[MACADRR_BYTE_LEN];
  216. u8 addr3[MACADRR_BYTE_LEN];
  217. u16 seq_ctrl; // more endians!
  218. u8 addr4[MACADRR_BYTE_LEN];
  219. u16 qos_ctrl;
  220. } __attribute__ ((packed));
  221. struct machdr30 {
  222. u16 frame_ctl;
  223. u16 duration; // watch out for endians!
  224. u8 addr1[MACADRR_BYTE_LEN];
  225. u8 addr2[MACADRR_BYTE_LEN];
  226. u8 addr3[MACADRR_BYTE_LEN];
  227. u16 seq_ctrl; // more endians!
  228. u8 addr4[MACADRR_BYTE_LEN];
  229. } __attribute__ ((packed));
  230. struct machdr26 {
  231. u16 frame_ctl;
  232. u16 duration; // watch out for endians!
  233. u8 addr1[MACADRR_BYTE_LEN];
  234. u8 addr2[MACADRR_BYTE_LEN];
  235. u8 addr3[MACADRR_BYTE_LEN];
  236. u16 seq_ctrl; // more endians!
  237. u16 qos_ctrl;
  238. } __attribute__ ((packed));
  239. struct machdr24 {
  240. u16 frame_ctl;
  241. u16 duration; // watch out for endians!
  242. u8 addr1[MACADRR_BYTE_LEN];
  243. u8 addr2[MACADRR_BYTE_LEN];
  244. u8 addr3[MACADRR_BYTE_LEN];
  245. u16 seq_ctrl; // more endians!
  246. } __attribute__ ((packed));
  247. // TX TFD with 32 byte MAC Header
  248. struct tx_tfd_32 {
  249. struct machdr32 mchdr; // 32
  250. u32 uivplaceholder[2]; // 8
  251. } __attribute__ ((packed));
  252. // TX TFD with 30 byte MAC Header
  253. struct tx_tfd_30 {
  254. struct machdr30 mchdr; // 30
  255. u8 reserved[2]; // 2
  256. u32 uivplaceholder[2]; // 8
  257. } __attribute__ ((packed));
  258. // tx tfd with 26 byte mac header
  259. struct tx_tfd_26 {
  260. struct machdr26 mchdr; // 26
  261. u8 reserved1[2]; // 2
  262. u32 uivplaceholder[2]; // 8
  263. u8 reserved2[4]; // 4
  264. } __attribute__ ((packed));
  265. // tx tfd with 24 byte mac header
  266. struct tx_tfd_24 {
  267. struct machdr24 mchdr; // 24
  268. u32 uivplaceholder[2]; // 8
  269. u8 reserved[8]; // 8
  270. } __attribute__ ((packed));
  271. #define DCT_WEP_KEY_FIELD_LENGTH 16
  272. struct tfd_command {
  273. u8 index;
  274. u8 length;
  275. u16 reserved;
  276. u8 payload[0];
  277. } __attribute__ ((packed));
  278. struct tfd_data {
  279. /* Header */
  280. u32 work_area_ptr;
  281. u8 station_number; /* 0 for BSS */
  282. u8 reserved1;
  283. u16 reserved2;
  284. /* Tx Parameters */
  285. u8 cmd_id;
  286. u8 seq_num;
  287. u16 len;
  288. u8 priority;
  289. u8 tx_flags;
  290. u8 tx_flags_ext;
  291. u8 key_index;
  292. u8 wepkey[DCT_WEP_KEY_FIELD_LENGTH];
  293. u8 rate;
  294. u8 antenna;
  295. u16 next_packet_duration;
  296. u16 next_frag_len;
  297. u16 back_off_counter; //////txop;
  298. u8 retrylimit;
  299. u16 cwcurrent;
  300. u8 reserved3;
  301. /* 802.11 MAC Header */
  302. union {
  303. struct tx_tfd_24 tfd_24;
  304. struct tx_tfd_26 tfd_26;
  305. struct tx_tfd_30 tfd_30;
  306. struct tx_tfd_32 tfd_32;
  307. } tfd;
  308. /* Payload DMA info */
  309. u32 num_chunks;
  310. u32 chunk_ptr[NUM_TFD_CHUNKS];
  311. u16 chunk_len[NUM_TFD_CHUNKS];
  312. } __attribute__ ((packed));
  313. struct txrx_control_flags {
  314. u8 message_type;
  315. u8 rx_seq_num;
  316. u8 control_bits;
  317. u8 reserved;
  318. } __attribute__ ((packed));
  319. #define TFD_SIZE 128
  320. #define TFD_CMD_IMMEDIATE_PAYLOAD_LENGTH (TFD_SIZE - sizeof(struct txrx_control_flags))
  321. struct tfd_frame {
  322. struct txrx_control_flags control_flags;
  323. union {
  324. struct tfd_data data;
  325. struct tfd_command cmd;
  326. u8 raw[TFD_CMD_IMMEDIATE_PAYLOAD_LENGTH];
  327. } u;
  328. } __attribute__ ((packed));
  329. typedef void destructor_func(const void *);
  330. /**
  331. * Tx Queue for DMA. Queue consists of circular buffer of
  332. * BD's and required locking structures.
  333. */
  334. struct clx2_tx_queue {
  335. struct clx2_queue q;
  336. struct tfd_frame *bd;
  337. struct ieee80211_txb **txb;
  338. };
  339. /*
  340. * RX related structures and functions
  341. */
  342. #define RX_FREE_BUFFERS 32
  343. #define RX_LOW_WATERMARK 8
  344. #define SUP_RATE_11A_MAX_NUM_CHANNELS (8)
  345. #define SUP_RATE_11B_MAX_NUM_CHANNELS (4)
  346. #define SUP_RATE_11G_MAX_NUM_CHANNELS (12)
  347. // Used for passing to driver number of successes and failures per rate
  348. struct rate_histogram {
  349. union {
  350. u32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
  351. u32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
  352. u32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
  353. } success;
  354. union {
  355. u32 a[SUP_RATE_11A_MAX_NUM_CHANNELS];
  356. u32 b[SUP_RATE_11B_MAX_NUM_CHANNELS];
  357. u32 g[SUP_RATE_11G_MAX_NUM_CHANNELS];
  358. } failed;
  359. } __attribute__ ((packed));
  360. /* statistics command response */
  361. struct ipw_cmd_stats {
  362. u8 cmd_id;
  363. u8 seq_num;
  364. u16 good_sfd;
  365. u16 bad_plcp;
  366. u16 wrong_bssid;
  367. u16 valid_mpdu;
  368. u16 bad_mac_header;
  369. u16 reserved_frame_types;
  370. u16 rx_ina;
  371. u16 bad_crc32;
  372. u16 invalid_cts;
  373. u16 invalid_acks;
  374. u16 long_distance_ina_fina;
  375. u16 dsp_silence_unreachable;
  376. u16 accumulated_rssi;
  377. u16 rx_ovfl_frame_tossed;
  378. u16 rssi_silence_threshold;
  379. u16 rx_ovfl_frame_supplied;
  380. u16 last_rx_frame_signal;
  381. u16 last_rx_frame_noise;
  382. u16 rx_autodetec_no_ofdm;
  383. u16 rx_autodetec_no_barker;
  384. u16 reserved;
  385. } __attribute__ ((packed));
  386. struct notif_channel_result {
  387. u8 channel_num;
  388. struct ipw_cmd_stats stats;
  389. u8 uReserved;
  390. } __attribute__ ((packed));
  391. struct notif_scan_complete {
  392. u8 scan_type;
  393. u8 num_channels;
  394. u8 status;
  395. u8 reserved;
  396. } __attribute__ ((packed));
  397. struct notif_frag_length {
  398. u16 frag_length;
  399. u16 reserved;
  400. } __attribute__ ((packed));
  401. struct notif_beacon_state {
  402. u32 state;
  403. u32 number;
  404. } __attribute__ ((packed));
  405. struct notif_tgi_tx_key {
  406. u8 key_state;
  407. u8 security_type;
  408. u8 station_index;
  409. u8 reserved;
  410. } __attribute__ ((packed));
  411. struct notif_link_deterioration {
  412. struct ipw_cmd_stats stats;
  413. u8 rate;
  414. u8 modulation;
  415. struct rate_histogram histogram;
  416. u8 reserved1;
  417. u16 reserved2;
  418. } __attribute__ ((packed));
  419. struct notif_association {
  420. u8 state;
  421. } __attribute__ ((packed));
  422. struct notif_authenticate {
  423. u8 state;
  424. struct machdr24 addr;
  425. u16 status;
  426. } __attribute__ ((packed));
  427. struct notif_calibration {
  428. u8 data[104];
  429. } __attribute__ ((packed));
  430. struct notif_noise {
  431. u32 value;
  432. } __attribute__ ((packed));
  433. struct ipw_rx_notification {
  434. u8 reserved[8];
  435. u8 subtype;
  436. u8 flags;
  437. u16 size;
  438. union {
  439. struct notif_association assoc;
  440. struct notif_authenticate auth;
  441. struct notif_channel_result channel_result;
  442. struct notif_scan_complete scan_complete;
  443. struct notif_frag_length frag_len;
  444. struct notif_beacon_state beacon_state;
  445. struct notif_tgi_tx_key tgi_tx_key;
  446. struct notif_link_deterioration link_deterioration;
  447. struct notif_calibration calibration;
  448. struct notif_noise noise;
  449. u8 raw[0];
  450. } u;
  451. } __attribute__ ((packed));
  452. struct ipw_rx_frame {
  453. u32 reserved1;
  454. u8 parent_tsf[4]; // fw_use[0] is boolean for OUR_TSF_IS_GREATER
  455. u8 received_channel; // The channel that this frame was received on.
  456. // Note that for .11b this does not have to be
  457. // the same as the channel that it was sent.
  458. // Filled by LMAC
  459. u8 frameStatus;
  460. u8 rate;
  461. u8 rssi;
  462. u8 agc;
  463. u8 rssi_dbm;
  464. u16 signal;
  465. u16 noise;
  466. u8 antennaAndPhy;
  467. u8 control; // control bit should be on in bg
  468. u8 rtscts_rate; // rate of rts or cts (in rts cts sequence rate
  469. // is identical)
  470. u8 rtscts_seen; // 0x1 RTS seen ; 0x2 CTS seen
  471. u16 length;
  472. u8 data[0];
  473. } __attribute__ ((packed));
  474. struct ipw_rx_header {
  475. u8 message_type;
  476. u8 rx_seq_num;
  477. u8 control_bits;
  478. u8 reserved;
  479. } __attribute__ ((packed));
  480. struct ipw_rx_packet {
  481. struct ipw_rx_header header;
  482. union {
  483. struct ipw_rx_frame frame;
  484. struct ipw_rx_notification notification;
  485. } u;
  486. } __attribute__ ((packed));
  487. #define IPW_RX_NOTIFICATION_SIZE sizeof(struct ipw_rx_header) + 12
  488. #define IPW_RX_FRAME_SIZE sizeof(struct ipw_rx_header) + \
  489. sizeof(struct ipw_rx_frame)
  490. struct ipw_rx_mem_buffer {
  491. dma_addr_t dma_addr;
  492. struct ipw_rx_buffer *rxb;
  493. struct sk_buff *skb;
  494. struct list_head list;
  495. }; /* Not transferred over network, so not __attribute__ ((packed)) */
  496. struct ipw_rx_queue {
  497. struct ipw_rx_mem_buffer pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS];
  498. struct ipw_rx_mem_buffer *queue[RX_QUEUE_SIZE];
  499. u32 processed; /* Internal index to last handled Rx packet */
  500. u32 read; /* Shared index to newest available Rx buffer */
  501. u32 write; /* Shared index to oldest written Rx packet */
  502. u32 free_count; /* Number of pre-allocated buffers in rx_free */
  503. /* Each of these lists is used as a FIFO for ipw_rx_mem_buffers */
  504. struct list_head rx_free; /* Own an SKBs */
  505. struct list_head rx_used; /* No SKB allocated */
  506. spinlock_t lock;
  507. }; /* Not transferred over network, so not __attribute__ ((packed)) */
  508. struct alive_command_responce {
  509. u8 alive_command;
  510. u8 sequence_number;
  511. u16 software_revision;
  512. u8 device_identifier;
  513. u8 reserved1[5];
  514. u16 reserved2;
  515. u16 reserved3;
  516. u16 clock_settle_time;
  517. u16 powerup_settle_time;
  518. u16 reserved4;
  519. u8 time_stamp[5]; /* month, day, year, hours, minutes */
  520. u8 ucode_valid;
  521. } __attribute__ ((packed));
  522. #define IPW_MAX_RATES 12
  523. struct ipw_rates {
  524. u8 num_rates;
  525. u8 rates[IPW_MAX_RATES];
  526. } __attribute__ ((packed));
  527. struct command_block {
  528. unsigned int control;
  529. u32 source_addr;
  530. u32 dest_addr;
  531. unsigned int status;
  532. } __attribute__ ((packed));
  533. #define CB_NUMBER_OF_ELEMENTS_SMALL 64
  534. struct fw_image_desc {
  535. unsigned long last_cb_index;
  536. unsigned long current_cb_index;
  537. struct command_block cb_list[CB_NUMBER_OF_ELEMENTS_SMALL];
  538. void *v_addr;
  539. unsigned long p_addr;
  540. unsigned long len;
  541. };
  542. struct ipw_sys_config {
  543. u8 bt_coexistence;
  544. u8 reserved1;
  545. u8 answer_broadcast_ssid_probe;
  546. u8 accept_all_data_frames;
  547. u8 accept_non_directed_frames;
  548. u8 exclude_unicast_unencrypted;
  549. u8 disable_unicast_decryption;
  550. u8 exclude_multicast_unencrypted;
  551. u8 disable_multicast_decryption;
  552. u8 antenna_diversity;
  553. u8 pass_crc_to_host;
  554. u8 dot11g_auto_detection;
  555. u8 enable_cts_to_self;
  556. u8 enable_multicast_filtering;
  557. u8 bt_coexist_collision_thr;
  558. u8 reserved2;
  559. u8 accept_all_mgmt_bcpr;
  560. u8 accept_all_mgtm_frames;
  561. u8 pass_noise_stats_to_host;
  562. u8 reserved3;
  563. } __attribute__ ((packed));
  564. struct ipw_multicast_addr {
  565. u8 num_of_multicast_addresses;
  566. u8 reserved[3];
  567. u8 mac1[6];
  568. u8 mac2[6];
  569. u8 mac3[6];
  570. u8 mac4[6];
  571. } __attribute__ ((packed));
  572. struct ipw_wep_key {
  573. u8 cmd_id;
  574. u8 seq_num;
  575. u8 key_index;
  576. u8 key_size;
  577. u8 key[16];
  578. } __attribute__ ((packed));
  579. struct ipw_tgi_tx_key {
  580. u8 key_id;
  581. u8 security_type;
  582. u8 station_index;
  583. u8 flags;
  584. u8 key[16];
  585. u32 tx_counter[2];
  586. } __attribute__ ((packed));
  587. #define IPW_SCAN_CHANNELS 54
  588. struct ipw_scan_request {
  589. u8 scan_type;
  590. u16 dwell_time;
  591. u8 channels_list[IPW_SCAN_CHANNELS];
  592. u8 channels_reserved[3];
  593. } __attribute__ ((packed));
  594. enum {
  595. IPW_SCAN_PASSIVE_TILL_FIRST_BEACON_SCAN = 0,
  596. IPW_SCAN_PASSIVE_FULL_DWELL_SCAN,
  597. IPW_SCAN_ACTIVE_DIRECT_SCAN,
  598. IPW_SCAN_ACTIVE_BROADCAST_SCAN,
  599. IPW_SCAN_ACTIVE_BROADCAST_AND_DIRECT_SCAN,
  600. IPW_SCAN_TYPES
  601. };
  602. struct ipw_scan_request_ext {
  603. u32 full_scan_index;
  604. u8 channels_list[IPW_SCAN_CHANNELS];
  605. u8 scan_type[IPW_SCAN_CHANNELS / 2];
  606. u8 reserved;
  607. u16 dwell_time[IPW_SCAN_TYPES];
  608. } __attribute__ ((packed));
  609. extern inline u8 ipw_get_scan_type(struct ipw_scan_request_ext *scan, u8 index)
  610. {
  611. if (index % 2)
  612. return scan->scan_type[index / 2] & 0x0F;
  613. else
  614. return (scan->scan_type[index / 2] & 0xF0) >> 4;
  615. }
  616. extern inline void ipw_set_scan_type(struct ipw_scan_request_ext *scan,
  617. u8 index, u8 scan_type)
  618. {
  619. if (index % 2)
  620. scan->scan_type[index / 2] =
  621. (scan->scan_type[index / 2] & 0xF0) | (scan_type & 0x0F);
  622. else
  623. scan->scan_type[index / 2] =
  624. (scan->scan_type[index / 2] & 0x0F) |
  625. ((scan_type & 0x0F) << 4);
  626. }
  627. struct ipw_associate {
  628. u8 channel;
  629. u8 auth_type:4, auth_key:4;
  630. u8 assoc_type;
  631. u8 reserved;
  632. u16 policy_support;
  633. u8 preamble_length;
  634. u8 ieee_mode;
  635. u8 bssid[ETH_ALEN];
  636. u32 assoc_tsf_msw;
  637. u32 assoc_tsf_lsw;
  638. u16 capability;
  639. u16 listen_interval;
  640. u16 beacon_interval;
  641. u8 dest[ETH_ALEN];
  642. u16 atim_window;
  643. u8 smr;
  644. u8 reserved1;
  645. u16 reserved2;
  646. } __attribute__ ((packed));
  647. struct ipw_supported_rates {
  648. u8 ieee_mode;
  649. u8 num_rates;
  650. u8 purpose;
  651. u8 reserved;
  652. u8 supported_rates[IPW_MAX_RATES];
  653. } __attribute__ ((packed));
  654. struct ipw_rts_threshold {
  655. u16 rts_threshold;
  656. u16 reserved;
  657. } __attribute__ ((packed));
  658. struct ipw_frag_threshold {
  659. u16 frag_threshold;
  660. u16 reserved;
  661. } __attribute__ ((packed));
  662. struct ipw_retry_limit {
  663. u8 short_retry_limit;
  664. u8 long_retry_limit;
  665. u16 reserved;
  666. } __attribute__ ((packed));
  667. struct ipw_dino_config {
  668. u32 dino_config_addr;
  669. u16 dino_config_size;
  670. u8 dino_response;
  671. u8 reserved;
  672. } __attribute__ ((packed));
  673. struct ipw_aironet_info {
  674. u8 id;
  675. u8 length;
  676. u16 reserved;
  677. } __attribute__ ((packed));
  678. struct ipw_rx_key {
  679. u8 station_index;
  680. u8 key_type;
  681. u8 key_id;
  682. u8 key_flag;
  683. u8 key[16];
  684. u8 station_address[6];
  685. u8 key_index;
  686. u8 reserved;
  687. } __attribute__ ((packed));
  688. struct ipw_country_channel_info {
  689. u8 first_channel;
  690. u8 no_channels;
  691. s8 max_tx_power;
  692. } __attribute__ ((packed));
  693. struct ipw_country_info {
  694. u8 id;
  695. u8 length;
  696. u8 country_str[3];
  697. struct ipw_country_channel_info groups[7];
  698. } __attribute__ ((packed));
  699. struct ipw_channel_tx_power {
  700. u8 channel_number;
  701. s8 tx_power;
  702. } __attribute__ ((packed));
  703. #define SCAN_ASSOCIATED_INTERVAL (HZ)
  704. #define SCAN_INTERVAL (HZ / 10)
  705. #define MAX_A_CHANNELS 37
  706. #define MAX_B_CHANNELS 14
  707. struct ipw_tx_power {
  708. u8 num_channels;
  709. u8 ieee_mode;
  710. struct ipw_channel_tx_power channels_tx_power[MAX_A_CHANNELS];
  711. } __attribute__ ((packed));
  712. struct ipw_qos_parameters {
  713. u16 cw_min[4];
  714. u16 cw_max[4];
  715. u8 aifs[4];
  716. u8 flag[4];
  717. u16 tx_op_limit[4];
  718. } __attribute__ ((packed));
  719. struct ipw_rsn_capabilities {
  720. u8 id;
  721. u8 length;
  722. u16 version;
  723. } __attribute__ ((packed));
  724. struct ipw_sensitivity_calib {
  725. u16 beacon_rssi_raw;
  726. u16 reserved;
  727. } __attribute__ ((packed));
  728. /**
  729. * Host command structure.
  730. *
  731. * On input, the following fields should be filled:
  732. * - cmd
  733. * - len
  734. * - status_len
  735. * - param (if needed)
  736. *
  737. * On output,
  738. * - \a status contains status;
  739. * - \a param filled with status parameters.
  740. */
  741. struct ipw_cmd {
  742. u32 cmd; /**< Host command */
  743. u32 status;/**< Status */
  744. u32 status_len;
  745. /**< How many 32 bit parameters in the status */
  746. u32 len; /**< incoming parameters length, bytes */
  747. /**
  748. * command parameters.
  749. * There should be enough space for incoming and
  750. * outcoming parameters.
  751. * Incoming parameters listed 1-st, followed by outcoming params.
  752. * nParams=(len+3)/4+status_len
  753. */
  754. u32 param[0];
  755. } __attribute__ ((packed));
  756. #define STATUS_HCMD_ACTIVE (1<<0) /**< host command in progress */
  757. #define STATUS_INT_ENABLED (1<<1)
  758. #define STATUS_RF_KILL_HW (1<<2)
  759. #define STATUS_RF_KILL_SW (1<<3)
  760. #define STATUS_RF_KILL_MASK (STATUS_RF_KILL_HW | STATUS_RF_KILL_SW)
  761. #define STATUS_INIT (1<<5)
  762. #define STATUS_AUTH (1<<6)
  763. #define STATUS_ASSOCIATED (1<<7)
  764. #define STATUS_STATE_MASK (STATUS_INIT | STATUS_AUTH | STATUS_ASSOCIATED)
  765. #define STATUS_ASSOCIATING (1<<8)
  766. #define STATUS_DISASSOCIATING (1<<9)
  767. #define STATUS_ROAMING (1<<10)
  768. #define STATUS_EXIT_PENDING (1<<11)
  769. #define STATUS_DISASSOC_PENDING (1<<12)
  770. #define STATUS_STATE_PENDING (1<<13)
  771. #define STATUS_SCAN_PENDING (1<<20)
  772. #define STATUS_SCANNING (1<<21)
  773. #define STATUS_SCAN_ABORTING (1<<22)
  774. #define STATUS_INDIRECT_BYTE (1<<28) /* sysfs entry configured for access */
  775. #define STATUS_INDIRECT_DWORD (1<<29) /* sysfs entry configured for access */
  776. #define STATUS_DIRECT_DWORD (1<<30) /* sysfs entry configured for access */
  777. #define STATUS_SECURITY_UPDATED (1<<31) /* Security sync needed */
  778. #define CFG_STATIC_CHANNEL (1<<0) /* Restrict assoc. to single channel */
  779. #define CFG_STATIC_ESSID (1<<1) /* Restrict assoc. to single SSID */
  780. #define CFG_STATIC_BSSID (1<<2) /* Restrict assoc. to single BSSID */
  781. #define CFG_CUSTOM_MAC (1<<3)
  782. #define CFG_PREAMBLE (1<<4)
  783. #define CFG_ADHOC_PERSIST (1<<5)
  784. #define CFG_ASSOCIATE (1<<6)
  785. #define CFG_FIXED_RATE (1<<7)
  786. #define CFG_ADHOC_CREATE (1<<8)
  787. #define CAP_SHARED_KEY (1<<0) /* Off = OPEN */
  788. #define CAP_PRIVACY_ON (1<<1) /* Off = No privacy */
  789. #define MAX_STATIONS 32
  790. #define IPW_INVALID_STATION (0xff)
  791. struct ipw_station_entry {
  792. u8 mac_addr[ETH_ALEN];
  793. u8 reserved;
  794. u8 support_mode;
  795. };
  796. #define AVG_ENTRIES 8
  797. struct average {
  798. s16 entries[AVG_ENTRIES];
  799. u8 pos;
  800. u8 init;
  801. s32 sum;
  802. };
  803. struct ipw_priv {
  804. /* ieee device used by generic ieee processing code */
  805. struct ieee80211_device *ieee;
  806. struct ieee80211_security sec;
  807. /* spinlock */
  808. spinlock_t lock;
  809. /* basic pci-network driver stuff */
  810. struct pci_dev *pci_dev;
  811. struct net_device *net_dev;
  812. /* pci hardware address support */
  813. void __iomem *hw_base;
  814. unsigned long hw_len;
  815. struct fw_image_desc sram_desc;
  816. /* result of ucode download */
  817. struct alive_command_responce dino_alive;
  818. wait_queue_head_t wait_command_queue;
  819. wait_queue_head_t wait_state;
  820. /* Rx and Tx DMA processing queues */
  821. struct ipw_rx_queue *rxq;
  822. struct clx2_tx_queue txq_cmd;
  823. struct clx2_tx_queue txq[4];
  824. u32 status;
  825. u32 config;
  826. u32 capability;
  827. u8 last_rx_rssi;
  828. u8 last_noise;
  829. struct average average_missed_beacons;
  830. struct average average_rssi;
  831. struct average average_noise;
  832. u32 port_type;
  833. int rx_bufs_min; /**< minimum number of bufs in Rx queue */
  834. int rx_pend_max; /**< maximum pending buffers for one IRQ */
  835. u32 hcmd_seq; /**< sequence number for hcmd */
  836. u32 missed_beacon_threshold;
  837. u32 roaming_threshold;
  838. struct ipw_associate assoc_request;
  839. struct ieee80211_network *assoc_network;
  840. unsigned long ts_scan_abort;
  841. struct ipw_supported_rates rates;
  842. struct ipw_rates phy[3]; /**< PHY restrictions, per band */
  843. struct ipw_rates supp; /**< software defined */
  844. struct ipw_rates extended; /**< use for corresp. IE, AP only */
  845. struct notif_link_deterioration last_link_deterioration; /** for statistics */
  846. struct ipw_cmd *hcmd; /**< host command currently executed */
  847. wait_queue_head_t hcmd_wq; /**< host command waits for execution */
  848. u32 tsf_bcn[2]; /**< TSF from latest beacon */
  849. struct notif_calibration calib; /**< last calibration */
  850. /* ordinal interface with firmware */
  851. u32 table0_addr;
  852. u32 table0_len;
  853. u32 table1_addr;
  854. u32 table1_len;
  855. u32 table2_addr;
  856. u32 table2_len;
  857. /* context information */
  858. u8 essid[IW_ESSID_MAX_SIZE];
  859. u8 essid_len;
  860. u8 nick[IW_ESSID_MAX_SIZE];
  861. u16 rates_mask;
  862. u8 channel;
  863. struct ipw_sys_config sys_config;
  864. u32 power_mode;
  865. u8 bssid[ETH_ALEN];
  866. u16 rts_threshold;
  867. u8 mac_addr[ETH_ALEN];
  868. u8 num_stations;
  869. u8 stations[MAX_STATIONS][ETH_ALEN];
  870. u32 notif_missed_beacons;
  871. /* Statistics and counters normalized with each association */
  872. u32 last_missed_beacons;
  873. u32 last_tx_packets;
  874. u32 last_rx_packets;
  875. u32 last_tx_failures;
  876. u32 last_rx_err;
  877. u32 last_rate;
  878. u32 missed_adhoc_beacons;
  879. u32 missed_beacons;
  880. u32 rx_packets;
  881. u32 tx_packets;
  882. u32 quality;
  883. /* eeprom */
  884. u8 eeprom[0x100]; /* 256 bytes of eeprom */
  885. int eeprom_delay;
  886. struct iw_statistics wstats;
  887. struct workqueue_struct *workqueue;
  888. struct work_struct adhoc_check;
  889. struct work_struct associate;
  890. struct work_struct disassociate;
  891. struct work_struct rx_replenish;
  892. struct work_struct request_scan;
  893. struct work_struct adapter_restart;
  894. struct work_struct rf_kill;
  895. struct work_struct up;
  896. struct work_struct down;
  897. struct work_struct gather_stats;
  898. struct work_struct abort_scan;
  899. struct work_struct roam;
  900. struct work_struct scan_check;
  901. struct tasklet_struct irq_tasklet;
  902. #define IPW_2200BG 1
  903. #define IPW_2915ABG 2
  904. u8 adapter;
  905. #define IPW_DEFAULT_TX_POWER 0x14
  906. u8 tx_power;
  907. #ifdef CONFIG_PM
  908. u32 pm_state[16];
  909. #endif
  910. /* network state */
  911. /* Used to pass the current INTA value from ISR to Tasklet */
  912. u32 isr_inta;
  913. /* debugging info */
  914. u32 indirect_dword;
  915. u32 direct_dword;
  916. u32 indirect_byte;
  917. }; /*ipw_priv */
  918. /* debug macros */
  919. #ifdef CONFIG_IPW_DEBUG
  920. #define IPW_DEBUG(level, fmt, args...) \
  921. do { if (ipw_debug_level & (level)) \
  922. printk(KERN_DEBUG DRV_NAME": %c %s " fmt, \
  923. in_interrupt() ? 'I' : 'U', __FUNCTION__ , ## args); } while (0)
  924. #else
  925. #define IPW_DEBUG(level, fmt, args...) do {} while (0)
  926. #endif /* CONFIG_IPW_DEBUG */
  927. /*
  928. * To use the debug system;
  929. *
  930. * If you are defining a new debug classification, simply add it to the #define
  931. * list here in the form of:
  932. *
  933. * #define IPW_DL_xxxx VALUE
  934. *
  935. * shifting value to the left one bit from the previous entry. xxxx should be
  936. * the name of the classification (for example, WEP)
  937. *
  938. * You then need to either add a IPW_xxxx_DEBUG() macro definition for your
  939. * classification, or use IPW_DEBUG(IPW_DL_xxxx, ...) whenever you want
  940. * to send output to that classification.
  941. *
  942. * To add your debug level to the list of levels seen when you perform
  943. *
  944. * % cat /proc/net/ipw/debug_level
  945. *
  946. * you simply need to add your entry to the ipw_debug_levels array.
  947. *
  948. * If you do not see debug_level in /proc/net/ipw then you do not have
  949. * CONFIG_IPW_DEBUG defined in your kernel configuration
  950. *
  951. */
  952. #define IPW_DL_ERROR (1<<0)
  953. #define IPW_DL_WARNING (1<<1)
  954. #define IPW_DL_INFO (1<<2)
  955. #define IPW_DL_WX (1<<3)
  956. #define IPW_DL_HOST_COMMAND (1<<5)
  957. #define IPW_DL_STATE (1<<6)
  958. #define IPW_DL_NOTIF (1<<10)
  959. #define IPW_DL_SCAN (1<<11)
  960. #define IPW_DL_ASSOC (1<<12)
  961. #define IPW_DL_DROP (1<<13)
  962. #define IPW_DL_IOCTL (1<<14)
  963. #define IPW_DL_MANAGE (1<<15)
  964. #define IPW_DL_FW (1<<16)
  965. #define IPW_DL_RF_KILL (1<<17)
  966. #define IPW_DL_FW_ERRORS (1<<18)
  967. #define IPW_DL_ORD (1<<20)
  968. #define IPW_DL_FRAG (1<<21)
  969. #define IPW_DL_WEP (1<<22)
  970. #define IPW_DL_TX (1<<23)
  971. #define IPW_DL_RX (1<<24)
  972. #define IPW_DL_ISR (1<<25)
  973. #define IPW_DL_FW_INFO (1<<26)
  974. #define IPW_DL_IO (1<<27)
  975. #define IPW_DL_TRACE (1<<28)
  976. #define IPW_DL_STATS (1<<29)
  977. #define IPW_ERROR(f, a...) printk(KERN_ERR DRV_NAME ": " f, ## a)
  978. #define IPW_WARNING(f, a...) printk(KERN_WARNING DRV_NAME ": " f, ## a)
  979. #define IPW_DEBUG_INFO(f, a...) IPW_DEBUG(IPW_DL_INFO, f, ## a)
  980. #define IPW_DEBUG_WX(f, a...) IPW_DEBUG(IPW_DL_WX, f, ## a)
  981. #define IPW_DEBUG_SCAN(f, a...) IPW_DEBUG(IPW_DL_SCAN, f, ## a)
  982. #define IPW_DEBUG_STATUS(f, a...) IPW_DEBUG(IPW_DL_STATUS, f, ## a)
  983. #define IPW_DEBUG_TRACE(f, a...) IPW_DEBUG(IPW_DL_TRACE, f, ## a)
  984. #define IPW_DEBUG_RX(f, a...) IPW_DEBUG(IPW_DL_RX, f, ## a)
  985. #define IPW_DEBUG_TX(f, a...) IPW_DEBUG(IPW_DL_TX, f, ## a)
  986. #define IPW_DEBUG_ISR(f, a...) IPW_DEBUG(IPW_DL_ISR, f, ## a)
  987. #define IPW_DEBUG_MANAGEMENT(f, a...) IPW_DEBUG(IPW_DL_MANAGE, f, ## a)
  988. #define IPW_DEBUG_WEP(f, a...) IPW_DEBUG(IPW_DL_WEP, f, ## a)
  989. #define IPW_DEBUG_HC(f, a...) IPW_DEBUG(IPW_DL_HOST_COMMAND, f, ## a)
  990. #define IPW_DEBUG_FRAG(f, a...) IPW_DEBUG(IPW_DL_FRAG, f, ## a)
  991. #define IPW_DEBUG_FW(f, a...) IPW_DEBUG(IPW_DL_FW, f, ## a)
  992. #define IPW_DEBUG_RF_KILL(f, a...) IPW_DEBUG(IPW_DL_RF_KILL, f, ## a)
  993. #define IPW_DEBUG_DROP(f, a...) IPW_DEBUG(IPW_DL_DROP, f, ## a)
  994. #define IPW_DEBUG_IO(f, a...) IPW_DEBUG(IPW_DL_IO, f, ## a)
  995. #define IPW_DEBUG_ORD(f, a...) IPW_DEBUG(IPW_DL_ORD, f, ## a)
  996. #define IPW_DEBUG_FW_INFO(f, a...) IPW_DEBUG(IPW_DL_FW_INFO, f, ## a)
  997. #define IPW_DEBUG_NOTIF(f, a...) IPW_DEBUG(IPW_DL_NOTIF, f, ## a)
  998. #define IPW_DEBUG_STATE(f, a...) IPW_DEBUG(IPW_DL_STATE | IPW_DL_ASSOC | IPW_DL_INFO, f, ## a)
  999. #define IPW_DEBUG_ASSOC(f, a...) IPW_DEBUG(IPW_DL_ASSOC | IPW_DL_INFO, f, ## a)
  1000. #define IPW_DEBUG_STATS(f, a...) IPW_DEBUG(IPW_DL_STATS, f, ## a)
  1001. #include <linux/ctype.h>
  1002. /*
  1003. * Register bit definitions
  1004. */
  1005. /* Dino control registers bits */
  1006. #define DINO_ENABLE_SYSTEM 0x80
  1007. #define DINO_ENABLE_CS 0x40
  1008. #define DINO_RXFIFO_DATA 0x01
  1009. #define DINO_CONTROL_REG 0x00200000
  1010. #define CX2_INTA_RW 0x00000008
  1011. #define CX2_INTA_MASK_R 0x0000000C
  1012. #define CX2_INDIRECT_ADDR 0x00000010
  1013. #define CX2_INDIRECT_DATA 0x00000014
  1014. #define CX2_AUTOINC_ADDR 0x00000018
  1015. #define CX2_AUTOINC_DATA 0x0000001C
  1016. #define CX2_RESET_REG 0x00000020
  1017. #define CX2_GP_CNTRL_RW 0x00000024
  1018. #define CX2_READ_INT_REGISTER 0xFF4
  1019. #define CX2_GP_CNTRL_BIT_INIT_DONE 0x00000004
  1020. #define CX2_REGISTER_DOMAIN1_END 0x00001000
  1021. #define CX2_SRAM_READ_INT_REGISTER 0x00000ff4
  1022. #define CX2_SHARED_LOWER_BOUND 0x00000200
  1023. #define CX2_INTERRUPT_AREA_LOWER_BOUND 0x00000f80
  1024. #define CX2_NIC_SRAM_LOWER_BOUND 0x00000000
  1025. #define CX2_NIC_SRAM_UPPER_BOUND 0x00030000
  1026. #define CX2_BIT_INT_HOST_SRAM_READ_INT_REGISTER (1 << 29)
  1027. #define CX2_GP_CNTRL_BIT_CLOCK_READY 0x00000001
  1028. #define CX2_GP_CNTRL_BIT_HOST_ALLOWS_STANDBY 0x00000002
  1029. /*
  1030. * RESET Register Bit Indexes
  1031. */
  1032. #define CBD_RESET_REG_PRINCETON_RESET 0x00000001 /* Bit 0 (LSB) */
  1033. #define CX2_RESET_REG_SW_RESET 0x00000080 /* Bit 7 */
  1034. #define CX2_RESET_REG_MASTER_DISABLED 0x00000100 /* Bit 8 */
  1035. #define CX2_RESET_REG_STOP_MASTER 0x00000200 /* Bit 9 */
  1036. #define CX2_ARC_KESHET_CONFIG 0x08000000 /* Bit 27 */
  1037. #define CX2_START_STANDBY 0x00000004 /* Bit 2 */
  1038. #define CX2_CSR_CIS_UPPER_BOUND 0x00000200
  1039. #define CX2_DOMAIN_0_END 0x1000
  1040. #define CLX_MEM_BAR_SIZE 0x1000
  1041. #define CX2_BASEBAND_CONTROL_STATUS 0X00200000
  1042. #define CX2_BASEBAND_TX_FIFO_WRITE 0X00200004
  1043. #define CX2_BASEBAND_RX_FIFO_READ 0X00200004
  1044. #define CX2_BASEBAND_CONTROL_STORE 0X00200010
  1045. #define CX2_INTERNAL_CMD_EVENT 0X00300004
  1046. #define CX2_BASEBAND_POWER_DOWN 0x00000001
  1047. #define CX2_MEM_HALT_AND_RESET 0x003000e0
  1048. /* defgroup bits_halt_reset MEM_HALT_AND_RESET register bits */
  1049. #define CX2_BIT_HALT_RESET_ON 0x80000000
  1050. #define CX2_BIT_HALT_RESET_OFF 0x00000000
  1051. #define CB_LAST_VALID 0x20000000
  1052. #define CB_INT_ENABLED 0x40000000
  1053. #define CB_VALID 0x80000000
  1054. #define CB_SRC_LE 0x08000000
  1055. #define CB_DEST_LE 0x04000000
  1056. #define CB_SRC_AUTOINC 0x00800000
  1057. #define CB_SRC_IO_GATED 0x00400000
  1058. #define CB_DEST_AUTOINC 0x00080000
  1059. #define CB_SRC_SIZE_LONG 0x00200000
  1060. #define CB_DEST_SIZE_LONG 0x00020000
  1061. /* DMA DEFINES */
  1062. #define DMA_CONTROL_SMALL_CB_CONST_VALUE 0x00540000
  1063. #define DMA_CB_STOP_AND_ABORT 0x00000C00
  1064. #define DMA_CB_START 0x00000100
  1065. #define CX2_SHARED_SRAM_SIZE 0x00030000
  1066. #define CX2_SHARED_SRAM_DMA_CONTROL 0x00027000
  1067. #define CB_MAX_LENGTH 0x1FFF
  1068. #define CX2_HOST_EEPROM_DATA_SRAM_SIZE 0xA18
  1069. #define CX2_EEPROM_IMAGE_SIZE 0x100
  1070. /* DMA defs */
  1071. #define CX2_DMA_I_CURRENT_CB 0x003000D0
  1072. #define CX2_DMA_O_CURRENT_CB 0x003000D4
  1073. #define CX2_DMA_I_DMA_CONTROL 0x003000A4
  1074. #define CX2_DMA_I_CB_BASE 0x003000A0
  1075. #define CX2_TX_CMD_QUEUE_BD_BASE (0x00000200)
  1076. #define CX2_TX_CMD_QUEUE_BD_SIZE (0x00000204)
  1077. #define CX2_TX_QUEUE_0_BD_BASE (0x00000208)
  1078. #define CX2_TX_QUEUE_0_BD_SIZE (0x0000020C)
  1079. #define CX2_TX_QUEUE_1_BD_BASE (0x00000210)
  1080. #define CX2_TX_QUEUE_1_BD_SIZE (0x00000214)
  1081. #define CX2_TX_QUEUE_2_BD_BASE (0x00000218)
  1082. #define CX2_TX_QUEUE_2_BD_SIZE (0x0000021C)
  1083. #define CX2_TX_QUEUE_3_BD_BASE (0x00000220)
  1084. #define CX2_TX_QUEUE_3_BD_SIZE (0x00000224)
  1085. #define CX2_RX_BD_BASE (0x00000240)
  1086. #define CX2_RX_BD_SIZE (0x00000244)
  1087. #define CX2_RFDS_TABLE_LOWER (0x00000500)
  1088. #define CX2_TX_CMD_QUEUE_READ_INDEX (0x00000280)
  1089. #define CX2_TX_QUEUE_0_READ_INDEX (0x00000284)
  1090. #define CX2_TX_QUEUE_1_READ_INDEX (0x00000288)
  1091. #define CX2_TX_QUEUE_2_READ_INDEX (0x0000028C)
  1092. #define CX2_TX_QUEUE_3_READ_INDEX (0x00000290)
  1093. #define CX2_RX_READ_INDEX (0x000002A0)
  1094. #define CX2_TX_CMD_QUEUE_WRITE_INDEX (0x00000F80)
  1095. #define CX2_TX_QUEUE_0_WRITE_INDEX (0x00000F84)
  1096. #define CX2_TX_QUEUE_1_WRITE_INDEX (0x00000F88)
  1097. #define CX2_TX_QUEUE_2_WRITE_INDEX (0x00000F8C)
  1098. #define CX2_TX_QUEUE_3_WRITE_INDEX (0x00000F90)
  1099. #define CX2_RX_WRITE_INDEX (0x00000FA0)
  1100. /*
  1101. * EEPROM Related Definitions
  1102. */
  1103. #define IPW_EEPROM_DATA_SRAM_ADDRESS (CX2_SHARED_LOWER_BOUND + 0x814)
  1104. #define IPW_EEPROM_DATA_SRAM_SIZE (CX2_SHARED_LOWER_BOUND + 0x818)
  1105. #define IPW_EEPROM_LOAD_DISABLE (CX2_SHARED_LOWER_BOUND + 0x81C)
  1106. #define IPW_EEPROM_DATA (CX2_SHARED_LOWER_BOUND + 0x820)
  1107. #define IPW_EEPROM_UPPER_ADDRESS (CX2_SHARED_LOWER_BOUND + 0x9E0)
  1108. #define IPW_STATION_TABLE_LOWER (CX2_SHARED_LOWER_BOUND + 0xA0C)
  1109. #define IPW_STATION_TABLE_UPPER (CX2_SHARED_LOWER_BOUND + 0xB0C)
  1110. #define IPW_REQUEST_ATIM (CX2_SHARED_LOWER_BOUND + 0xB0C)
  1111. #define IPW_ATIM_SENT (CX2_SHARED_LOWER_BOUND + 0xB10)
  1112. #define IPW_WHO_IS_AWAKE (CX2_SHARED_LOWER_BOUND + 0xB14)
  1113. #define IPW_DURING_ATIM_WINDOW (CX2_SHARED_LOWER_BOUND + 0xB18)
  1114. #define MSB 1
  1115. #define LSB 0
  1116. #define WORD_TO_BYTE(_word) ((_word) * sizeof(u16))
  1117. #define GET_EEPROM_ADDR(_wordoffset,_byteoffset) \
  1118. ( WORD_TO_BYTE(_wordoffset) + (_byteoffset) )
  1119. /* EEPROM access by BYTE */
  1120. #define EEPROM_PME_CAPABILITY (GET_EEPROM_ADDR(0x09,MSB)) /* 1 byte */
  1121. #define EEPROM_MAC_ADDRESS (GET_EEPROM_ADDR(0x21,LSB)) /* 6 byte */
  1122. #define EEPROM_VERSION (GET_EEPROM_ADDR(0x24,MSB)) /* 1 byte */
  1123. #define EEPROM_NIC_TYPE (GET_EEPROM_ADDR(0x25,LSB)) /* 1 byte */
  1124. #define EEPROM_SKU_CAPABILITY (GET_EEPROM_ADDR(0x25,MSB)) /* 1 byte */
  1125. #define EEPROM_COUNTRY_CODE (GET_EEPROM_ADDR(0x26,LSB)) /* 3 bytes */
  1126. #define EEPROM_IBSS_CHANNELS_BG (GET_EEPROM_ADDR(0x28,LSB)) /* 2 bytes */
  1127. #define EEPROM_IBSS_CHANNELS_A (GET_EEPROM_ADDR(0x29,MSB)) /* 5 bytes */
  1128. #define EEPROM_BSS_CHANNELS_BG (GET_EEPROM_ADDR(0x2c,LSB)) /* 2 bytes */
  1129. #define EEPROM_HW_VERSION (GET_EEPROM_ADDR(0x72,LSB)) /* 2 bytes */
  1130. /* NIC type as found in the one byte EEPROM_NIC_TYPE offset*/
  1131. #define EEPROM_NIC_TYPE_STANDARD 0
  1132. #define EEPROM_NIC_TYPE_DELL 1
  1133. #define EEPROM_NIC_TYPE_FUJITSU 2
  1134. #define EEPROM_NIC_TYPE_IBM 3
  1135. #define EEPROM_NIC_TYPE_HP 4
  1136. #define FW_MEM_REG_LOWER_BOUND 0x00300000
  1137. #define FW_MEM_REG_EEPROM_ACCESS (FW_MEM_REG_LOWER_BOUND + 0x40)
  1138. #define EEPROM_BIT_SK (1<<0)
  1139. #define EEPROM_BIT_CS (1<<1)
  1140. #define EEPROM_BIT_DI (1<<2)
  1141. #define EEPROM_BIT_DO (1<<4)
  1142. #define EEPROM_CMD_READ 0x2
  1143. /* Interrupts masks */
  1144. #define CX2_INTA_NONE 0x00000000
  1145. #define CX2_INTA_BIT_RX_TRANSFER 0x00000002
  1146. #define CX2_INTA_BIT_STATUS_CHANGE 0x00000010
  1147. #define CX2_INTA_BIT_BEACON_PERIOD_EXPIRED 0x00000020
  1148. //Inta Bits for CF
  1149. #define CX2_INTA_BIT_TX_CMD_QUEUE 0x00000800
  1150. #define CX2_INTA_BIT_TX_QUEUE_1 0x00001000
  1151. #define CX2_INTA_BIT_TX_QUEUE_2 0x00002000
  1152. #define CX2_INTA_BIT_TX_QUEUE_3 0x00004000
  1153. #define CX2_INTA_BIT_TX_QUEUE_4 0x00008000
  1154. #define CX2_INTA_BIT_SLAVE_MODE_HOST_CMD_DONE 0x00010000
  1155. #define CX2_INTA_BIT_PREPARE_FOR_POWER_DOWN 0x00100000
  1156. #define CX2_INTA_BIT_POWER_DOWN 0x00200000
  1157. #define CX2_INTA_BIT_FW_INITIALIZATION_DONE 0x01000000
  1158. #define CX2_INTA_BIT_FW_CARD_DISABLE_PHY_OFF_DONE 0x02000000
  1159. #define CX2_INTA_BIT_RF_KILL_DONE 0x04000000
  1160. #define CX2_INTA_BIT_FATAL_ERROR 0x40000000
  1161. #define CX2_INTA_BIT_PARITY_ERROR 0x80000000
  1162. /* Interrupts enabled at init time. */
  1163. #define CX2_INTA_MASK_ALL \
  1164. (CX2_INTA_BIT_TX_QUEUE_1 | \
  1165. CX2_INTA_BIT_TX_QUEUE_2 | \
  1166. CX2_INTA_BIT_TX_QUEUE_3 | \
  1167. CX2_INTA_BIT_TX_QUEUE_4 | \
  1168. CX2_INTA_BIT_TX_CMD_QUEUE | \
  1169. CX2_INTA_BIT_RX_TRANSFER | \
  1170. CX2_INTA_BIT_FATAL_ERROR | \
  1171. CX2_INTA_BIT_PARITY_ERROR | \
  1172. CX2_INTA_BIT_STATUS_CHANGE | \
  1173. CX2_INTA_BIT_FW_INITIALIZATION_DONE | \
  1174. CX2_INTA_BIT_BEACON_PERIOD_EXPIRED | \
  1175. CX2_INTA_BIT_SLAVE_MODE_HOST_CMD_DONE | \
  1176. CX2_INTA_BIT_PREPARE_FOR_POWER_DOWN | \
  1177. CX2_INTA_BIT_POWER_DOWN | \
  1178. CX2_INTA_BIT_RF_KILL_DONE )
  1179. #define IPWSTATUS_ERROR_LOG (CX2_SHARED_LOWER_BOUND + 0x410)
  1180. #define IPW_EVENT_LOG (CX2_SHARED_LOWER_BOUND + 0x414)
  1181. /* FW event log definitions */
  1182. #define EVENT_ELEM_SIZE (3 * sizeof(u32))
  1183. #define EVENT_START_OFFSET (1 * sizeof(u32) + 2 * sizeof(u16))
  1184. /* FW error log definitions */
  1185. #define ERROR_ELEM_SIZE (7 * sizeof(u32))
  1186. #define ERROR_START_OFFSET (1 * sizeof(u32))
  1187. enum {
  1188. IPW_FW_ERROR_OK = 0,
  1189. IPW_FW_ERROR_FAIL,
  1190. IPW_FW_ERROR_MEMORY_UNDERFLOW,
  1191. IPW_FW_ERROR_MEMORY_OVERFLOW,
  1192. IPW_FW_ERROR_BAD_PARAM,
  1193. IPW_FW_ERROR_BAD_CHECKSUM,
  1194. IPW_FW_ERROR_NMI_INTERRUPT,
  1195. IPW_FW_ERROR_BAD_DATABASE,
  1196. IPW_FW_ERROR_ALLOC_FAIL,
  1197. IPW_FW_ERROR_DMA_UNDERRUN,
  1198. IPW_FW_ERROR_DMA_STATUS,
  1199. IPW_FW_ERROR_DINOSTATUS_ERROR,
  1200. IPW_FW_ERROR_EEPROMSTATUS_ERROR,
  1201. IPW_FW_ERROR_SYSASSERT,
  1202. IPW_FW_ERROR_FATAL_ERROR
  1203. };
  1204. #define AUTH_OPEN 0
  1205. #define AUTH_SHARED_KEY 1
  1206. #define AUTH_IGNORE 3
  1207. #define HC_ASSOCIATE 0
  1208. #define HC_REASSOCIATE 1
  1209. #define HC_DISASSOCIATE 2
  1210. #define HC_IBSS_START 3
  1211. #define HC_IBSS_RECONF 4
  1212. #define HC_DISASSOC_QUIET 5
  1213. #define IPW_RATE_CAPABILITIES 1
  1214. #define IPW_RATE_CONNECT 0
  1215. /*
  1216. * Rate values and masks
  1217. */
  1218. #define IPW_TX_RATE_1MB 0x0A
  1219. #define IPW_TX_RATE_2MB 0x14
  1220. #define IPW_TX_RATE_5MB 0x37
  1221. #define IPW_TX_RATE_6MB 0x0D
  1222. #define IPW_TX_RATE_9MB 0x0F
  1223. #define IPW_TX_RATE_11MB 0x6E
  1224. #define IPW_TX_RATE_12MB 0x05
  1225. #define IPW_TX_RATE_18MB 0x07
  1226. #define IPW_TX_RATE_24MB 0x09
  1227. #define IPW_TX_RATE_36MB 0x0B
  1228. #define IPW_TX_RATE_48MB 0x01
  1229. #define IPW_TX_RATE_54MB 0x03
  1230. #define IPW_ORD_TABLE_ID_MASK 0x0000FF00
  1231. #define IPW_ORD_TABLE_VALUE_MASK 0x000000FF
  1232. #define IPW_ORD_TABLE_0_MASK 0x0000F000
  1233. #define IPW_ORD_TABLE_1_MASK 0x0000F100
  1234. #define IPW_ORD_TABLE_2_MASK 0x0000F200
  1235. #define IPW_ORD_TABLE_3_MASK 0x0000F300
  1236. #define IPW_ORD_TABLE_4_MASK 0x0000F400
  1237. #define IPW_ORD_TABLE_5_MASK 0x0000F500
  1238. #define IPW_ORD_TABLE_6_MASK 0x0000F600
  1239. #define IPW_ORD_TABLE_7_MASK 0x0000F700
  1240. /*
  1241. * Table 0 Entries (all entries are 32 bits)
  1242. */
  1243. enum {
  1244. IPW_ORD_STAT_TX_CURR_RATE = IPW_ORD_TABLE_0_MASK + 1,
  1245. IPW_ORD_STAT_FRAG_TRESHOLD,
  1246. IPW_ORD_STAT_RTS_THRESHOLD,
  1247. IPW_ORD_STAT_TX_HOST_REQUESTS,
  1248. IPW_ORD_STAT_TX_HOST_COMPLETE,
  1249. IPW_ORD_STAT_TX_DIR_DATA,
  1250. IPW_ORD_STAT_TX_DIR_DATA_B_1,
  1251. IPW_ORD_STAT_TX_DIR_DATA_B_2,
  1252. IPW_ORD_STAT_TX_DIR_DATA_B_5_5,
  1253. IPW_ORD_STAT_TX_DIR_DATA_B_11,
  1254. /* Hole */
  1255. IPW_ORD_STAT_TX_DIR_DATA_G_1 = IPW_ORD_TABLE_0_MASK + 19,
  1256. IPW_ORD_STAT_TX_DIR_DATA_G_2,
  1257. IPW_ORD_STAT_TX_DIR_DATA_G_5_5,
  1258. IPW_ORD_STAT_TX_DIR_DATA_G_6,
  1259. IPW_ORD_STAT_TX_DIR_DATA_G_9,
  1260. IPW_ORD_STAT_TX_DIR_DATA_G_11,
  1261. IPW_ORD_STAT_TX_DIR_DATA_G_12,
  1262. IPW_ORD_STAT_TX_DIR_DATA_G_18,
  1263. IPW_ORD_STAT_TX_DIR_DATA_G_24,
  1264. IPW_ORD_STAT_TX_DIR_DATA_G_36,
  1265. IPW_ORD_STAT_TX_DIR_DATA_G_48,
  1266. IPW_ORD_STAT_TX_DIR_DATA_G_54,
  1267. IPW_ORD_STAT_TX_NON_DIR_DATA,
  1268. IPW_ORD_STAT_TX_NON_DIR_DATA_B_1,
  1269. IPW_ORD_STAT_TX_NON_DIR_DATA_B_2,
  1270. IPW_ORD_STAT_TX_NON_DIR_DATA_B_5_5,
  1271. IPW_ORD_STAT_TX_NON_DIR_DATA_B_11,
  1272. /* Hole */
  1273. IPW_ORD_STAT_TX_NON_DIR_DATA_G_1 = IPW_ORD_TABLE_0_MASK + 44,
  1274. IPW_ORD_STAT_TX_NON_DIR_DATA_G_2,
  1275. IPW_ORD_STAT_TX_NON_DIR_DATA_G_5_5,
  1276. IPW_ORD_STAT_TX_NON_DIR_DATA_G_6,
  1277. IPW_ORD_STAT_TX_NON_DIR_DATA_G_9,
  1278. IPW_ORD_STAT_TX_NON_DIR_DATA_G_11,
  1279. IPW_ORD_STAT_TX_NON_DIR_DATA_G_12,
  1280. IPW_ORD_STAT_TX_NON_DIR_DATA_G_18,
  1281. IPW_ORD_STAT_TX_NON_DIR_DATA_G_24,
  1282. IPW_ORD_STAT_TX_NON_DIR_DATA_G_36,
  1283. IPW_ORD_STAT_TX_NON_DIR_DATA_G_48,
  1284. IPW_ORD_STAT_TX_NON_DIR_DATA_G_54,
  1285. IPW_ORD_STAT_TX_RETRY,
  1286. IPW_ORD_STAT_TX_FAILURE,
  1287. IPW_ORD_STAT_RX_ERR_CRC,
  1288. IPW_ORD_STAT_RX_ERR_ICV,
  1289. IPW_ORD_STAT_RX_NO_BUFFER,
  1290. IPW_ORD_STAT_FULL_SCANS,
  1291. IPW_ORD_STAT_PARTIAL_SCANS,
  1292. IPW_ORD_STAT_TGH_ABORTED_SCANS,
  1293. IPW_ORD_STAT_TX_TOTAL_BYTES,
  1294. IPW_ORD_STAT_CURR_RSSI_RAW,
  1295. IPW_ORD_STAT_RX_BEACON,
  1296. IPW_ORD_STAT_MISSED_BEACONS,
  1297. IPW_ORD_TABLE_0_LAST
  1298. };
  1299. #define IPW_RSSI_TO_DBM 112
  1300. /* Table 1 Entries
  1301. */
  1302. enum {
  1303. IPW_ORD_TABLE_1_LAST = IPW_ORD_TABLE_1_MASK | 1,
  1304. };
  1305. /*
  1306. * Table 2 Entries
  1307. *
  1308. * FW_VERSION: 16 byte string
  1309. * FW_DATE: 16 byte string (only 14 bytes used)
  1310. * UCODE_VERSION: 4 byte version code
  1311. * UCODE_DATE: 5 bytes code code
  1312. * ADDAPTER_MAC: 6 byte MAC address
  1313. * RTC: 4 byte clock
  1314. */
  1315. enum {
  1316. IPW_ORD_STAT_FW_VERSION = IPW_ORD_TABLE_2_MASK | 1,
  1317. IPW_ORD_STAT_FW_DATE,
  1318. IPW_ORD_STAT_UCODE_VERSION,
  1319. IPW_ORD_STAT_UCODE_DATE,
  1320. IPW_ORD_STAT_ADAPTER_MAC,
  1321. IPW_ORD_STAT_RTC,
  1322. IPW_ORD_TABLE_2_LAST
  1323. };
  1324. /* Table 3 */
  1325. enum {
  1326. IPW_ORD_STAT_TX_PACKET = IPW_ORD_TABLE_3_MASK | 0,
  1327. IPW_ORD_STAT_TX_PACKET_FAILURE,
  1328. IPW_ORD_STAT_TX_PACKET_SUCCESS,
  1329. IPW_ORD_STAT_TX_PACKET_ABORTED,
  1330. IPW_ORD_TABLE_3_LAST
  1331. };
  1332. /* Table 4 */
  1333. enum {
  1334. IPW_ORD_TABLE_4_LAST = IPW_ORD_TABLE_4_MASK
  1335. };
  1336. /* Table 5 */
  1337. enum {
  1338. IPW_ORD_STAT_AVAILABLE_AP_COUNT = IPW_ORD_TABLE_5_MASK,
  1339. IPW_ORD_STAT_AP_ASSNS,
  1340. IPW_ORD_STAT_ROAM,
  1341. IPW_ORD_STAT_ROAM_CAUSE_MISSED_BEACONS,
  1342. IPW_ORD_STAT_ROAM_CAUSE_UNASSOC,
  1343. IPW_ORD_STAT_ROAM_CAUSE_RSSI,
  1344. IPW_ORD_STAT_ROAM_CAUSE_LINK_QUALITY,
  1345. IPW_ORD_STAT_ROAM_CAUSE_AP_LOAD_BALANCE,
  1346. IPW_ORD_STAT_ROAM_CAUSE_AP_NO_TX,
  1347. IPW_ORD_STAT_LINK_UP,
  1348. IPW_ORD_STAT_LINK_DOWN,
  1349. IPW_ORD_ANTENNA_DIVERSITY,
  1350. IPW_ORD_CURR_FREQ,
  1351. IPW_ORD_TABLE_5_LAST
  1352. };
  1353. /* Table 6 */
  1354. enum {
  1355. IPW_ORD_COUNTRY_CODE = IPW_ORD_TABLE_6_MASK,
  1356. IPW_ORD_CURR_BSSID,
  1357. IPW_ORD_CURR_SSID,
  1358. IPW_ORD_TABLE_6_LAST
  1359. };
  1360. /* Table 7 */
  1361. enum {
  1362. IPW_ORD_STAT_PERCENT_MISSED_BEACONS = IPW_ORD_TABLE_7_MASK,
  1363. IPW_ORD_STAT_PERCENT_TX_RETRIES,
  1364. IPW_ORD_STAT_PERCENT_LINK_QUALITY,
  1365. IPW_ORD_STAT_CURR_RSSI_DBM,
  1366. IPW_ORD_TABLE_7_LAST
  1367. };
  1368. #define IPW_ORDINALS_TABLE_LOWER (CX2_SHARED_LOWER_BOUND + 0x500)
  1369. #define IPW_ORDINALS_TABLE_0 (CX2_SHARED_LOWER_BOUND + 0x180)
  1370. #define IPW_ORDINALS_TABLE_1 (CX2_SHARED_LOWER_BOUND + 0x184)
  1371. #define IPW_ORDINALS_TABLE_2 (CX2_SHARED_LOWER_BOUND + 0x188)
  1372. #define IPW_MEM_FIXED_OVERRIDE (CX2_SHARED_LOWER_BOUND + 0x41C)
  1373. struct ipw_fixed_rate {
  1374. u16 tx_rates;
  1375. u16 reserved;
  1376. } __attribute__ ((packed));
  1377. #define CX2_INDIRECT_ADDR_MASK (~0x3ul)
  1378. struct host_cmd {
  1379. u8 cmd;
  1380. u8 len;
  1381. u16 reserved;
  1382. u32 param[TFD_CMD_IMMEDIATE_PAYLOAD_LENGTH];
  1383. } __attribute__ ((packed));
  1384. #define CFG_BT_COEXISTENCE_MIN 0x00
  1385. #define CFG_BT_COEXISTENCE_DEFER 0x02
  1386. #define CFG_BT_COEXISTENCE_KILL 0x04
  1387. #define CFG_BT_COEXISTENCE_WME_OVER_BT 0x08
  1388. #define CFG_BT_COEXISTENCE_OOB 0x10
  1389. #define CFG_BT_COEXISTENCE_MAX 0xFF
  1390. #define CFG_BT_COEXISTENCE_DEF 0x80 /* read Bt from EEPROM */
  1391. #define CFG_CTS_TO_ITSELF_ENABLED_MIN 0x0
  1392. #define CFG_CTS_TO_ITSELF_ENABLED_MAX 0x1
  1393. #define CFG_CTS_TO_ITSELF_ENABLED_DEF CFG_CTS_TO_ITSELF_ENABLED_MIN
  1394. #define CFG_SYS_ANTENNA_BOTH 0x000
  1395. #define CFG_SYS_ANTENNA_A 0x001
  1396. #define CFG_SYS_ANTENNA_B 0x003
  1397. /*
  1398. * The definitions below were lifted off the ipw2100 driver, which only
  1399. * supports 'b' mode, so I'm sure these are not exactly correct.
  1400. *
  1401. * Somebody fix these!!
  1402. */
  1403. #define REG_MIN_CHANNEL 0
  1404. #define REG_MAX_CHANNEL 14
  1405. #define REG_CHANNEL_MASK 0x00003FFF
  1406. #define IPW_IBSS_11B_DEFAULT_MASK 0x87ff
  1407. static const long ipw_frequencies[] = {
  1408. 2412, 2417, 2422, 2427,
  1409. 2432, 2437, 2442, 2447,
  1410. 2452, 2457, 2462, 2467,
  1411. 2472, 2484
  1412. };
  1413. #define FREQ_COUNT ARRAY_SIZE(ipw_frequencies)
  1414. #define IPW_MAX_CONFIG_RETRIES 10
  1415. static inline u32 frame_hdr_len(struct ieee80211_hdr *hdr)
  1416. {
  1417. u32 retval;
  1418. u16 fc;
  1419. retval = sizeof(struct ieee80211_hdr);
  1420. fc = le16_to_cpu(hdr->frame_ctl);
  1421. /*
  1422. * Function ToDS FromDS
  1423. * IBSS 0 0
  1424. * To AP 1 0
  1425. * From AP 0 1
  1426. * WDS (bridge) 1 1
  1427. *
  1428. * Only WDS frames use Address4 among them. --YZ
  1429. */
  1430. if (!(fc & IEEE80211_FCTL_TODS) || !(fc & IEEE80211_FCTL_FROMDS))
  1431. retval -= ETH_ALEN;
  1432. return retval;
  1433. }
  1434. #endif /* __ipw2200_h__ */