aironet4500.h
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:49k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. /*
  2.  *  Aironet 4500 Pcmcia driver
  3.  *
  4.  * Elmer Joandi, Januar 1999
  5.  * Copyright: GPL
  6.  *
  7.  *
  8.  * Revision 0.1 ,started  30.12.1998
  9.  *
  10.  *
  11.  */
  12.  
  13. #ifndef AIRONET4500_H
  14. #define AIRONET4500_H
  15. // redefined to avoid PCMCIA includes
  16.  #include <linux/version.h>
  17. /*#include <linux/module.h>
  18.  #include <linux/kernel.h>
  19. */
  20. /*
  21. #include <linux/types.h>
  22. #include <linux/netdevice.h>
  23. #include <linux/etherdevice.h>
  24. #include <linux/delay.h>
  25. #include <linux/time.h>
  26. */
  27. #include <linux/802_11.h>
  28. //damn idiot PCMCIA stuff
  29. #ifndef DEV_NAME_LEN
  30. #define DEV_NAME_LEN 32
  31. #endif
  32. struct pcmcia_junkdev_node_t {
  33.     char dev_name[DEV_NAME_LEN];
  34.     u_short major, minor;
  35.     struct dev_node_t *next;
  36. };
  37. #ifndef CS_RELEASE
  38. typedef struct pcmcia_junkdev_node_t dev_node_t;
  39. #endif
  40. #include <linux/spinlock.h>
  41. #define AWC_ERROR -1
  42. #define AWC_SUCCESS 0
  43. struct awc_cis {
  44. unsigned char cis[0x301];
  45. unsigned char unknown302[0xdf];
  46. unsigned short configuration_register;
  47. unsigned short pin_replacement_register;
  48. unsigned short socket_and_copy_register;
  49. };
  50. /* timeout for transmit watchdog timer, AP default is 8 sec */
  51. #define AWC_TX_TIMEOUT (HZ * 8) 
  52. /***************************  REGISTER OFFSETS *********************/
  53. #define awc_Command_register  0x00
  54. #define awc_Param0_register  0x02
  55. #define awc_Param1_register  0x04
  56. #define awc_Param2_register  0x06
  57. #define awc_Status_register  0x08
  58. #define awc_Resp0_register  0x0A
  59. #define awc_Resp1_register  0x0C
  60. #define awc_Resp2_register  0x0E
  61. #define awc_EvStat_register  0x30
  62. #define awc_EvIntEn_register  0x32
  63. #define awc_EvAck_register  0x34
  64. #define awc_SWSupport0_register  0x28
  65. #define awc_SWSupport1_register  0x2A
  66. #define awc_SWSupport2_register  0x2C
  67. #define awc_SWSupport3_register  0x2E
  68. #define awc_LinkStatus_register  0x10
  69. // Memory access  RID FID
  70. #define awc_Select0_register  0x18
  71. #define awc_Offset0_register  0x1C
  72. #define awc_Data0_register  0x36
  73. #define awc_Select1_register  0x1A
  74. #define awc_Offset1_register  0x1E
  75. #define awc_Data1_register  0x38
  76. //
  77. #define awc_RxFID_register  0x20
  78. #define awc_TxAllocFID_register  0x22
  79. #define awc_TxComplFID_register  0x24
  80. #define awc_AuxPage_register  0x3A
  81. #define awc_AuxOffset_register  0x3C
  82. #define awc_AuxData_register  0x3E
  83. struct awc_bap {
  84. u16 select;
  85. u16 offset;
  86. u16 data;
  87. volatile int lock;
  88. volatile int status;
  89. struct semaphore sem;
  90. spinlock_t spinlock;
  91. unsigned long flags;
  92. };
  93. #define AWC_COMMAND_STATE_WAIT_CMD_BUSY 1
  94. #define AWC_COMMAND_STATE_WAIT_CMD_ACK 2
  95. #define AWC_COMMAND_STATE_WAIT_BAP_BUSY 3
  96. #define AWC_COMMAND_STATE_BAP_NOT_SET 4
  97. #define AWC_COMMAND_STATE_BAP_SET 5
  98. struct awc_command {
  99. volatile int state;
  100. volatile int lock_state;
  101. struct net_device * dev;
  102. struct awc_private * priv;
  103. u16 port;
  104. struct awc_bap *  bap;
  105. u16 command;
  106. u16 par0;
  107. u16 par1;
  108. u16 par2;
  109. u16 status;
  110. u16 resp0;
  111. u16 resp1;
  112. u16 resp2;
  113. u16 rid;
  114. u16 offset;
  115. u16 len;
  116. void * buff;
  117. };
  118. #define DOWN(a) down_interruptible( a ) ; 
  119. // if (in_interrupt()) { down_interruptible( a ) ; } else printk("semaphore DOWN in interrupt tried n");
  120. #define UP(a)   up( a ) ;
  121. // if (in_interrupt()) {up( a ) ; } else printk("semaphore UP in interrupt tried n");
  122. /* if (!in_interrupt())
  123. printk("bap lock under cli but not in intn");
  124. */
  125. #define AWC_LOCK_COMMAND_ISSUING(a) spin_lock_irqsave(&a->command_issuing_spinlock,a->command_issuing_spinlock_flags);
  126. #define AWC_UNLOCK_COMMAND_ISSUING(a) spin_unlock_irqrestore(&a->command_issuing_spinlock,a->command_issuing_spinlock_flags);
  127. #define AWC_BAP_LOCK_UNDER_CLI_REAL(cmd) 
  128.   if (!cmd.priv) {
  129. printk(KERN_CRIT "awc4500: no priv present in command !");
  130. }
  131. cmd.bap = &(cmd.priv->bap1);
  132. if (both_bap_lock)
  133. spin_lock_irqsave(&cmd.priv->both_bap_spinlock,cmd.priv->both_bap_spinlock_flags);
  134. if (cmd.bap){
  135. spin_lock_irqsave(&(cmd.bap->spinlock),cmd.bap->flags);
  136. cmd.bap->lock++;
  137. if (cmd.bap->lock > 1)
  138. printk("Bap 1 lock highn");
  139. cmd.lock_state |= AWC_BAP_LOCKED;
  140. }
  141. #define AWC_BAP_LOCK_NOT_CLI_REAL(cmd) {
  142. if (in_interrupt())
  143. printk("bap lock not cli in intn");
  144.   if (!cmd.priv) {
  145. printk(KERN_CRIT "awc4500: no priv present in command,lockup follows !");
  146. }
  147. cmd.bap = &(cmd.priv->bap0);
  148. if (both_bap_lock)
  149. spin_lock_irqsave(&cmd.priv->both_bap_spinlock,cmd.priv->both_bap_spinlock_flags);
  150. spin_lock_irqsave(&(cmd.bap->spinlock),cmd.bap->flags);
  151. DOWN(&(cmd.priv->bap0.sem));
  152. cmd.bap->lock++;
  153. if (cmd.bap->lock > 1)
  154. printk("Bap 0 lock highn");
  155. cmd.lock_state |= AWC_BAP_SEMALOCKED;
  156. }
  157. #define AWC_BAP_LOCK_NOT_CLI_CLI_REAL(cmd) {
  158. cmd.bap = &(cmd.priv->bap0);
  159. if (both_bap_lock)
  160. spin_lock_irqsave(&cmd.priv->both_bap_spinlock,cmd.priv->both_bap_spinlock_flags);
  161. spin_lock_irqsave(&(cmd.bap->spinlock),cmd.bap->flags);
  162. cmd.bap->lock++;
  163. if (cmd.bap->lock > 1)
  164. printk("Bap 0 lock highn");
  165. cmd.lock_state |= AWC_BAP_LOCKED;
  166. }
  167. #define BAP_LOCK_ANY(cmd)
  168. if (in_interrupt()) AWC_BAP_LOCK_NOT_CLI_CLI_REAL(cmd)
  169. else AWC_BAP_LOCK_NOT_CLI_REAL(cmd)
  170. #define AWC_BAP_LOCK_NOT_CLI(cmd) BAP_LOCK_ANY(cmd)
  171. #define AWC_BAP_LOCK_UNDER_CLI(cmd) AWC_BAP_LOCK_UNDER_CLI_REAL(cmd)
  172. /*
  173. if (!cmd.priv->bap1.lock ) {BAP_LOCK_ANY(cmd);}
  174. else AWC_BAP_LOCK_NOT_CLI_CLI_REAL(cmd);
  175. */
  176. #define AWC_BAP_LOCKED  0x01
  177. #define AWC_BAP_SEMALOCKED  0x02
  178. #define AWC_BAP_BUSY 0x8000
  179. #define AWC_BAP_ERR 0x4000
  180. #define AWC_BAP_DONE 0x2000
  181. #define AWC_CLI 1
  182. #define AWC_NOT_CLI  2
  183. /*#define WAIT61x3 inb(0x61);
  184.           inb(0x61);
  185.                      inb(0x61);
  186. */ 
  187. #define WAIT61x3  udelay(bap_sleep)                  
  188. #define AWC_INIT_COMMAND(context, a_com, a_dev,a_cmmand,a_pr0, a_rid, a_offset, a_len, a_buff) {
  189. memset(&a_com,0,sizeof(a_com) );
  190. a_com.dev = a_dev;
  191. a_com.priv = a_dev->priv;
  192. a_com.port = a_dev->base_addr;
  193. a_com.bap = NULL;
  194. a_com.command = a_cmmand;
  195. a_com.par0 = a_pr0;
  196. a_com.rid = a_rid;
  197. a_com.offset = a_offset;
  198. a_com.len = a_len;
  199. a_com.buff = a_buff;
  200. a_com.lock_state = 0;
  201. };
  202. /* v鋑a veider asi j鋜gnevast 
  203.  makrost v鋖ja j鋏tud if (cmd.bap) AWC_IN((cmd.bap)->data);
  204. */
  205. #define AWC_BAP_UNLOCK(com) { 
  206. if (com.bap){ 
  207. if ( (com.lock_state & AWC_BAP_SEMALOCKED) &&
  208.      (com.lock_state & AWC_BAP_LOCKED) ){
  209.       printk("Both Sema and simple lock n");
  210. }
  211. if ( com.lock_state & AWC_BAP_SEMALOCKED ){
  212.  com.bap->lock--; 
  213.  com.lock_state &= ~AWC_BAP_SEMALOCKED;
  214.  UP(&(com.bap->sem)); 
  215.  spin_unlock_irqrestore(&(cmd.bap->spinlock),cmd.bap->flags);
  216. } else if (com.lock_state & AWC_BAP_LOCKED){
  217.  com.bap->lock--; 
  218.  com.lock_state &= ~AWC_BAP_LOCKED;
  219.  spin_unlock_irqrestore(&(cmd.bap->spinlock),cmd.bap->flags);
  220. }
  221. }
  222. if (both_bap_lock)
  223. spin_unlock_irqrestore(&cmd.priv->both_bap_spinlock,cmd.priv->both_bap_spinlock_flags);
  224. }
  225. #define AWC_RELEASE_COMMAND(com) {
  226. AWC_BAP_UNLOCK(cmd);
  227. }
  228. #define awc_manufacturer_code  0x015F
  229. #define awc_product_code 0x0005
  230. #define awc_write(base,register,u16value) outw(u16value, (base)+(register))
  231. #define awc_read(base,register)           inw((base)+(register))
  232. #define AWC_OUT(base,val) outw(val, base)
  233. #define AWC_IN(base) inw(base)
  234. #define awc_read_response(cmd) {
  235. cmd->status=awc_read(cmd->port,awc_Status_register);
  236. cmd->resp0=awc_read(cmd->port,awc_Resp0_register);
  237. cmd->resp1=awc_read(cmd->port,awc_Resp1_register);
  238. cmd->resp2=awc_read(cmd->port,awc_Resp2_register);
  239. };
  240. #define awc_command_busy(base) (awc_read(base,awc_Command_register) & 0x8000)
  241. #define awc_command_read(base) awc_read(base,awc_Command_register)
  242. #define awc_command_write(base,cmd) awc_write(base,awc_Command_register,cmd) 
  243. #define awc_event_status_Awake(base) (awc_read(base,awc_EvStat_register) & 0x0100)
  244. #define awc_event_status_Link(base) (awc_read(base,awc_EvStat_register) & 0x0080)
  245. #define awc_event_status_Cmd(base) (awc_read(base,awc_EvStat_register) & 0x0010)
  246. #define awc_event_status_Alloc(base) (awc_read(base,awc_EvStat_register) & 0x0008)
  247. #define awc_event_status_TxExc(base) (awc_read(base,awc_EvStat_register) & 0x0004)
  248. #define awc_event_status_Tx(base) (awc_read(base,awc_EvStat_register) & 0x0002)
  249. #define awc_event_status_TxResp(base) (awc_read(base,awc_EvStat_register) & 0x0006)
  250. #define awc_event_status_Rx(base) (awc_read(base,awc_EvStat_register) & 0x0001)
  251. #define awc_event_status(base) (awc_read(base,awc_EvStat_register))
  252. #define awc_Link_Status(base) awc_read(base,awc_LinkStatus_register)
  253. #define awc_Rx_Fid(base) awc_read(base,awc_RxFID_register)
  254. #define awc_Tx_Allocated_Fid(base) awc_read(base,awc_TxAllocFID_register)
  255. #define awc_Tx_Compl_Fid(base) awc_read(base,awc_TxComplFID_register)
  256. #define awc_event_ack_ClrStckCmdBsy(base) awc_write(base,awc_EvAck_register, 0x4000)
  257. #define awc_event_ack_WakeUp(base) awc_write(base,awc_EvAck_register, 0x2000)
  258. #define awc_event_ack_Awaken(base) awc_write(base,awc_EvAck_register, 0x0100)
  259. #define awc_event_ack_Link(base) awc_write(base,awc_EvAck_register, 0x0080)
  260. #define awc_event_ack_Cmd(base) awc_write(base,awc_EvAck_register, 0x0010)
  261. #define awc_event_ack_Alloc(base) awc_write(base,awc_EvAck_register, 0x0008)
  262. #define awc_event_ack_TxExc(base) awc_write(base,awc_EvAck_register, 0x0004)
  263. #define awc_event_ack_Tx(base) awc_write(base,awc_EvAck_register, 0x0002)
  264. #define awc_event_ack_Rx(base) awc_write(base,awc_EvAck_register, 0x0001)
  265. #define awc_event_ack(base,ints) awc_write(base,awc_EvAck_register,ints)
  266. #define awc_ints_enabled(base) (awc_read(base,awc_EvIntEn_register))
  267. #define awc_ints_enable(base,ints) awc_write(base,awc_EvIntEn_register,ints)
  268. /************************   RX TX  BUFF ************************/
  269. struct aironet4500_radio_rx_header {
  270. u32 RxTime;
  271. u16 Status;
  272. u16 PayloadLength;
  273. u8 Reserved0;
  274. u8 RSSI;
  275. u8 Rate;
  276. u8 Frequency;
  277. u8 Rx_association_count;
  278. u8  Reserved1[3];
  279. u8 PLCP_header[4];
  280. };
  281. struct aironet4500_radio_tx_header {
  282. u32 SWSupport;
  283. u16 Status;
  284. #define aironet4500_tx_status_max_retries 0x0002
  285. #define aironet4500_tx_status_lifetime_exceeded 0x0004
  286. #define aironet4500_tx_status_AID_failure 0x0008
  287. #define aironet4500_tx_status_MAC_disabled 0x0010
  288. #define aironet4500_tx_status_association_lost 0x0020
  289. u16 PayloadLength;
  290. u16 TX_Control;
  291. #define aironet4500_tx_control_tx_ok_event_enable  0x0002
  292. #define aironet4500_tx_control_tx_fail_event_enable  0x0004
  293. #define aironet4500_tx_control_header_type_802_11  0x0008
  294. #define aironet4500_tx_control_payload_type_llc  0x0010
  295. #define aironet4500_tx_control_no_release  0x0020
  296. #define aironet4500_tx_control_reuse_fid 
  297. (aironet4500_tx_control_tx_ok_event_enable |
  298.  aironet4500_tx_control_tx_fail_event_enable |
  299.   aironet4500_tx_control_no_release)
  300. #define aironet4500_tx_control_no_retries  0x0040
  301. #define aironet4500_tx_control_clear_AID  0x0080
  302. #define aironet4500_tx_control_strict_order  0x0100
  303. #define aironet4500_tx_control_use_rts  0x0200
  304. u16 AID;
  305. u8 Tx_Long_Retry;
  306. u8 Tx_Short_Retry;
  307. u8 tx_association_count;
  308. u8 tx_bit_rate;
  309. #define aironet4500_tx_bit_rate_automatic 0
  310. #define aironet4500_tx_bit_rate_500kbps 1
  311. #define aironet4500_tx_bit_rate_1Mbps 2
  312. #define aironet4500_tx_bit_rate_2Mbps 4
  313. u8 Max_Long_Retry;
  314. u8 Max_Short_Retry;
  315. u8 Reserved0[2];
  316. };
  317. struct aironet4500_rx_fid {
  318. u16 rid;
  319. struct aironet4500_radio_rx_header  radio_rx;
  320. struct ieee_802_11_header      ieee_802_11;
  321. u16  gap_length;
  322. struct ieee_802_3_header     ieee_802_3;
  323. u8 * payload;
  324. };
  325. struct aironet4500_tx_fid {
  326. u16 fid;
  327. u16 fid_size;
  328. struct aironet4500_radio_tx_header  radio_tx;
  329. struct ieee_802_11_header      ieee_802_11;
  330. u16  gap_length;
  331. #define aironet4500_gap_len_without_802_3 6
  332. #define aironet4500_gap_len_with_802_3 0
  333. struct ieee_802_3_header     ieee_802_3;
  334. u8 * payload;
  335. };
  336. struct awc_fid {
  337. u32 type;
  338. #define p80211_llc_snap 0x0100
  339. #define p80211_8021H 0x0200
  340. #define p80211_8022 0x0400
  341. #define p80211_8023 0x0800
  342. #define p80211_snap_8021H 0x1000
  343. #define p80211copy_path_skb 0x2000
  344. u8 priority;
  345. u8 busy;
  346. #define awc_tx_fid_complete_read 0x01
  347. u16 state;
  348. union {
  349. struct aironet4500_tx_fid tx;
  350. struct aironet4500_rx_fid rx;
  351. } u;
  352. struct ieee_802_11_snap_header snap;
  353. struct ieee_802_11_802_1H_header bridge;
  354. u16 bridge_size;
  355. struct ieee_802_11_802_2_header p8022;
  356. u16 pkt_len;
  357. u8 * mac;
  358. struct sk_buff * skb;
  359. long long transmit_start_time;
  360. struct awc_fid * next;
  361. struct awc_fid * prev;
  362. };
  363. struct awc_fid_queue {
  364. struct awc_fid * head;
  365. struct awc_fid * tail;
  366. int size;
  367. spinlock_t spinlock;
  368. };
  369. extern  __inline__ void
  370. awc_fid_queue_init(struct awc_fid_queue * queue){
  371. unsigned long flags;
  372. memset(queue,0, sizeof(struct awc_fid_queue));
  373. spin_lock_init(&queue->spinlock);
  374. spin_lock_irqsave(&queue->spinlock,flags);
  375. queue->head = NULL;
  376. queue->tail = NULL;
  377. queue->size = 0;
  378. spin_unlock_irqrestore(&queue->spinlock,flags);
  379. };
  380. extern inline void
  381. awc_fid_queue_push_tail( struct awc_fid_queue *  queue,
  382. struct awc_fid * fid){
  383. unsigned long flags;
  384. spin_lock_irqsave(&queue->spinlock,flags);
  385. fid->prev = queue->tail;
  386. fid->next = NULL;
  387. if (queue->tail){
  388. queue->tail->next = fid;
  389. queue->tail  = fid;
  390. if (!queue->head)
  391. queue->head = fid;
  392. queue->size++;
  393. spin_unlock_irqrestore(&queue->spinlock,flags);
  394. };
  395. extern inline void
  396. awc_fid_queue_push_head( struct awc_fid_queue *  queue,
  397. struct awc_fid * fid){
  398. unsigned long flags;
  399. spin_lock_irqsave(&queue->spinlock,flags);
  400. fid->prev = NULL;
  401. fid->next = queue->head;
  402. if (queue->head){
  403. queue->head->prev = fid;
  404. queue->head  = fid;
  405. if (!queue->tail)
  406. queue->tail = fid;
  407. queue->size++;
  408. spin_unlock_irqrestore(&queue->spinlock,flags);
  409. };
  410. extern inline void
  411. awc_fid_queue_rm( struct awc_fid_queue *  queue,
  412. struct awc_fid * fid){
  413. if (fid->prev) {
  414. fid->prev->next = fid->next;
  415. };
  416. if (fid->next) {
  417. fid->next->prev = fid->prev;
  418. };
  419. if (fid == queue->tail) {
  420. queue->tail = fid->prev;
  421. };
  422. if (fid == queue->head) {
  423. queue->head = fid->next;
  424. };
  425. fid->next = NULL;
  426. fid->prev = NULL;
  427. queue->size--;
  428. if (queue->size ==0 ){
  429. queue->tail = NULL;
  430. queue->head = NULL;
  431. }
  432. };
  433. extern inline void
  434. awc_fid_queue_remove( struct awc_fid_queue *  queue,
  435. struct awc_fid * fid){
  436. unsigned long flags;
  437. spin_lock_irqsave(&queue->spinlock,flags);
  438. awc_fid_queue_rm(queue,fid);
  439. spin_unlock_irqrestore(&queue->spinlock,flags);
  440. };
  441. extern inline struct awc_fid * 
  442. awc_fid_queue_pop_head( struct awc_fid_queue *  queue){
  443. unsigned long flags;
  444. struct awc_fid * fid;
  445. spin_lock_irqsave(&queue->spinlock,flags);
  446. fid = queue->head;
  447. if (fid)
  448. awc_fid_queue_rm(queue,fid);
  449. spin_unlock_irqrestore(&queue->spinlock,flags);
  450. return fid;
  451. };
  452. extern inline struct awc_fid * 
  453. awc_fid_queue_pop_tail( struct awc_fid_queue *  queue){
  454. unsigned long flags;
  455. struct awc_fid * fid;
  456. spin_lock_irqsave(&queue->spinlock,flags);
  457. fid = queue->tail;
  458. if (fid)
  459. awc_fid_queue_rm(queue,fid);
  460. spin_unlock_irqrestore(&queue->spinlock,flags);
  461. return fid;
  462. };
  463. #define AWC_TX_HEAD_SIZE 0x44
  464. #define AWC_TX_ALLOC_SMALL_SIZE  200
  465. #define AWC_RX_BUFFS 50
  466. /*****************************      RID & CONFIG  ***********************/
  467. struct awc_config{
  468.     unsigned short    Len;                                /* sizeof(PC4500_CONFIG) */
  469.     unsigned short    OperatingMode;                      /* operating mode        */
  470.     #define           MODE_STA_IBSS                0
  471.     #define           MODE_STA_ESS                 1
  472.     #define           MODE_AP                      2
  473.     #define           MODE_AP_RPTR                 3
  474.     #define           MODE_ETHERNET_HOST           (0<<8)    /* rx payloads converted */
  475.     #define           MODE_LLC_HOST                (1<<8)    /* rx payloads left as is */
  476.     #define           MODE_AIRONET_EXTEND          (1<<9)    /* enable Aironet extenstions */
  477.     #define           MODE_AP_INTERFACE            (1<<10) /* enable ap interface extensions */
  478.     unsigned short    ReceiveMode;                        /* receive mode */
  479.     #define           RXMODE_BC_MC_ADDR            0
  480.     #define           RXMODE_BC_ADDR               1         /* ignore multicasts */
  481.     #define           RXMODE_ADDR                  2         /* ignore multicast and broadcast */
  482.     #define           RXMODE_RFMON                 3         /* wireless monitor mode */
  483.     #define           RXMODE_RFMON_ANYBSS 4
  484.     #define           RXMODE_LANMON                5         /* lan style monitor -- data packets only */
  485.     #define           RXMODE_DISABLE_802_3_HEADER  0x100    /* disables 802.3 header on rx */
  486.     unsigned short    FragmentThreshold;
  487.     unsigned short    RtsThreshold;
  488.     unsigned char     StationMacAddress[6];
  489.     unsigned char     Rates[8];
  490.     unsigned short    ShortRetryLimit;
  491.     unsigned short    LongRetryLimit;
  492.     unsigned short    TxLifetime;                         /* in kusec */
  493.     unsigned short    RxLifetime;                         /* in kusec */
  494.     unsigned short    Stationary;
  495.     unsigned short    Ordering;
  496.     unsigned short    DeviceType;                         /* for overriding device type */
  497.     unsigned short    _reserved1[5];                         /*---------- Scanning/Associating ----------*/
  498.     unsigned short    ScanMode;
  499.     #define           SCANMODE_ACTIVE              0
  500.     #define           SCANMODE_PASSIVE             1
  501.     #define           SCANMODE_AIROSCAN            2
  502.     unsigned short    ProbeDelay;                         /* in kusec */
  503.     unsigned short    ProbeEnergyTimeout;                 /* in kusec */
  504.     unsigned short    ProbeResponseTimeout;
  505.     unsigned short    BeaconListenTimeout;
  506.     unsigned short    JoinNetTimeout;
  507.     unsigned short    AuthenticationTimeout;
  508.     unsigned short    AuthenticationType;
  509.     #define           AUTH_OPEN                    1
  510.     #define           AUTH_SHAREDKEY               2
  511.     #define           AUTH_EXCLUDENONWEP           4
  512.     unsigned short    AssociationTimeout;
  513.     unsigned short    SpecifiedApTimeout;
  514.     unsigned short    OfflineScanInterval;
  515.     unsigned short    OfflineScanDuration;
  516.     unsigned short    LinkLossDelay;
  517.     unsigned short    MaxBeaconLostTime;
  518.     unsigned short    RefreshInterval;
  519.    #define           DISABLE_REFRESH           0xFFFF
  520.    unsigned short    _reserved1a[1];                      /*---------- Power save operation ----------*/
  521.    unsigned short    PowerSaveMode;
  522.    #define           POWERSAVE_CAM             0
  523.    #define           POWERSAVE_PSP             1
  524.    #define           POWERSAVE_PSP_CAM         2
  525.    unsigned short    SleepForDtims;
  526.    unsigned short    ListenInterval;
  527.    unsigned short    FastListenInterval;
  528.    unsigned short    ListenDecay;
  529.    unsigned short    FastListenDelay;
  530.    unsigned short    _reserved2[2];                       /*---------- Ap/Ibss config items ----------*/
  531.    unsigned short    BeaconPeriod;
  532.    unsigned short    AtimDuration;
  533.    unsigned short    HopPeriod;
  534.    unsigned short    ChannelSet;
  535.    unsigned short    Channel;
  536.    unsigned short    DtimPeriod;
  537.    unsigned short    _reserved3[2];                       /*---------- Radio configuration ----------*/
  538.    unsigned short    RadioType;
  539.    #define           RADIOTYPE_DEFAULT         0
  540.    #define           RADIOTYPE_802_11          1
  541.    #define           RADIOTYPE_LEGACY          2
  542.    unsigned char     u8RxDiversity;
  543.    unsigned char     u8TxDiversity;
  544.    unsigned short    TxPower;
  545.    #define           TXPOWER_DEFAULT           0
  546.    unsigned short    RssiThreshold;
  547.    #define           RSSI_DEFAULT              0
  548.    unsigned short    RadioSpecific[4];                 /*---------- Aironet Extensions ----------*/
  549.    unsigned char     NodeName[16];
  550.    unsigned short    ArlThreshold;
  551.    unsigned short    ArlDecay;
  552.    unsigned short    ArlDelay;
  553.    unsigned short    _reserved4[1];                       /*---------- Aironet Extensions ----------*/
  554.    unsigned short    MagicAction;
  555.    #define           MAGIC_ACTION_STSCHG       1
  556.    #define           MACIC_ACTION_RESUME       2
  557.    #define           MAGIC_IGNORE_MCAST        (1<<8)
  558.    #define           MAGIC_IGNORE_BCAST        (1<<9)
  559.    #define           MAGIC_SWITCH_TO_PSP       (0<<10)
  560.    #define           MAGIC_STAY_IN_CAM         (1<<10)
  561. };
  562. struct awc_SSID {
  563. u16  lenght;
  564. u8 SSID[32];
  565. };
  566. struct awc_SSIDs {
  567. u16  ridLen;
  568. struct awc_SSID SSID[3];
  569. };
  570. struct awc_fixed_APs{
  571. u16 ridLen;
  572. u8 AP[4][6];
  573. };
  574. struct awc_driver_name{
  575. u16 ridLen;
  576. u8 name[16];
  577. };
  578. struct awc_encapsulation{
  579. u16  etherType;
  580. u16 Action;
  581. };
  582. struct awc_enc_trans{
  583. u16 ridLen;
  584. struct awc_encapsulation  rules[8];
  585. };
  586. struct awc_wep_key {
  587. u16 ridLen;
  588. u16 KeyIndex;
  589. u8 Address[6];
  590. u16 KeyLen;
  591. u8 Key[16];
  592. };
  593. struct awc_modulation {
  594. u16 ridLen;
  595. u16 Modulation;
  596. };
  597. struct awc_cap{
  598. u16 ridLen;
  599. u8 OUI[3];
  600. u8 ProductNum[3];
  601. u8 ManufacturerName[32];
  602. u8 ProductName[16];
  603. u8 ProductVersion[8];
  604. u8 FactoryAddress[6];
  605. u8 AironetAddress[6];
  606. u16 RadioType;
  607. u16 RegDomain;
  608. u8 Callid[6];
  609. u8 SupportedRates[8];
  610. u8 RxDiversity;
  611. u8 TxDiversity;
  612. u16 TxPowerLevels[8];
  613. u16 HardwareVersion;
  614. u16 HardwareCapabilities;
  615. u16 TemperatureRange;
  616. u16 SoftwareVersion;
  617. u16 SoftwareSubVersion;
  618. u16 InterfaceVersion;
  619. u16 SoftwareCapabilities;
  620. u8 BootBlockVersionMajor;
  621. u8              BootBlockVersionMinor;
  622.         
  623. };
  624. struct awc_status{
  625. u16 ridLen;
  626. u8 MacAddress[6];
  627. u16 OperationalMode;
  628. u16 ErrorCode;
  629. u16 CurrentSignalQuality;
  630. u16 SSIDlength;
  631. u8 SSID[32];
  632. u8 ApName[16];
  633. u8 CurrentBssid[32];
  634. u8 PreviousBSSIDs[3][6];
  635. u16 BeaconPeriod;
  636. u16 DtimPeriod;
  637. u16 AtimDuration;
  638. u16 HopPeriod;
  639. u16 ChannelSet;
  640. u16 Channel;
  641. u16 HopsToBackbone;
  642. u16 ApTotalLoad;
  643. u16 OurGeneratedLoad;
  644. u16 AccumulatedArl;
  645. };
  646. struct awc_AP{
  647. u16 ridLen;
  648. u16 TIM_Addr;
  649. u16 Airo_Addr;
  650. };
  651. struct awc_Statistics_32 {
  652. u32 RidLen;
  653. u32 RxOverrunErr;
  654. u32 RxPlcpCrcErr;
  655. u32 RxPlcpFormat;
  656. u32 RxPlcpLength;
  657. u32 RxMacCrcErr;
  658. u32 RxMacCrcOk;
  659. u32 RxWepErr;
  660. u32 RxWepOk;
  661. u32 RetryLong;
  662. u32 RetryShort;
  663. u32 MaxRetries;
  664. u32 NoAck;
  665. u32 NoCts;
  666. u32 RxAck;
  667. u32 RxCts;
  668. u32 TxAck;
  669. u32 TxRts;
  670. u32 TxCts;
  671. u32 TxMc;
  672. u32 TxBc;
  673. u32 TxUcFrags;
  674. u32 TxUcPackets;
  675. u32 TxBeacon;
  676. u32 RxBeacon;
  677. u32 TxSinColl;
  678. u32 TxMulColl;
  679. u32 DefersNo;
  680. u32 DefersProt;
  681. u32 DefersEngy;
  682. u32 DupFram;
  683. u32 RxFragDisc;
  684. u32 TxAged;
  685. u32 RxAged;
  686. u32 LostSync_Max;
  687. u32 LostSync_Mis;
  688. u32 LostSync_Arl;
  689. u32 LostSync_Dea;
  690. u32 LostSync_Disa;
  691. u32 LostSync_Tsf;
  692. u32 HostTxMc;
  693. u32 HostTxBc;
  694. u32 HostTxUc;
  695. u32 HostTxFail;
  696. u32 HostRxMc;
  697. u32 HostRxBc;
  698. u32 HostRxUc;
  699. u32 HostRxDiscar;
  700. u32 HmacTxMc;
  701. u32 HmacTxBc;
  702. u32 HmacTxUc;
  703. u32 HmacTxFail;
  704. u32 HmacRxMc;
  705. u32 HmacRxBc;
  706. u32 HmacRxUc;
  707. u32 HmacRxDisca;
  708. u32 HmacRxAcce;
  709. u32 SsidMismatch;
  710. u32 ApMismatch;
  711. u32 RatesMismatc;
  712. u32 AuthReject;
  713. u32 AuthTimeout;
  714. u32 AssocReject;
  715. u32 AssocTimeout;
  716. u32 NewReason;
  717. u32 AuthFail_1;
  718. u32 AuthFail_2;
  719. u32 AuthFail_3;
  720. u32 AuthFail_4;
  721. u32 AuthFail_5;
  722. u32 AuthFail_6;
  723. u32 AuthFail_7;
  724. u32 AuthFail_8;
  725. u32 AuthFail_9;
  726. u32 AuthFail_10;
  727. u32 AuthFail_11;
  728. u32 AuthFail_12;
  729. u32 AuthFail_13;
  730. u32 AuthFail_14;
  731. u32 AuthFail_15;
  732. u32 AuthFail_16;
  733. u32 AuthFail_17;
  734. u32 AuthFail_18;
  735. u32 AuthFail_19;
  736. u32 RxMan;
  737. u32 TxMan;
  738. u32 RxRefresh;
  739. u32 TxRefresh;
  740. u32 RxPoll;
  741. u32 TxPoll;
  742. u32 HostRetries;
  743. u32 LostSync_HostReq;
  744. u32 HostTxBytes;
  745. u32 HostRxBytes;
  746. u32 ElapsedUsec;
  747. u32 ElapsedSec;
  748. u32 LostSyncBett;
  749. };
  750. struct awc_Statistics_16 {
  751. u16 RidLen;
  752. u16 RxOverrunErr;
  753. u16 RxPlcpCrcErr;
  754. u16 RxPlcpFormat;
  755. u16 RxPlcpLength;
  756. u16 RxMacCrcErr;
  757. u16 RxMacCrcOk;
  758. u16 RxWepErr;
  759. u16 RxWepOk;
  760. u16 RetryLong;
  761. u16 RetryShort;
  762. u16 MaxRetries;
  763. u16 NoAck;
  764. u16 NoCts;
  765. u16 RxAck;
  766. u16 RxCts;
  767. u16 TxAck;
  768. u16 TxRts;
  769. u16 TxCts;
  770. u16 TxMc;
  771. u16 TxBc;
  772. u16 TxUcFrags;
  773. u16 TxUcPackets;
  774. u16 TxBeacon;
  775. u16 RxBeacon;
  776. u16 TxSinColl;
  777. u16 TxMulColl;
  778. u16 DefersNo;
  779. u16 DefersProt;
  780. u16 DefersEngy;
  781. u16 DupFram;
  782. u16 RxFragDisc;
  783. u16 TxAged;
  784. u16 RxAged;
  785. u16 LostSync_Max;
  786. u16 LostSync_Mis;
  787. u16 LostSync_Arl;
  788. u16 LostSync_Dea;
  789. u16 LostSync_Disa;
  790. u16 LostSync_Tsf;
  791. u16 HostTxMc;
  792. u16 HostTxBc;
  793. u16 HostTxUc;
  794. u16 HostTxFail;
  795. u16 HostRxMc;
  796. u16 HostRxBc;
  797. u16 HostRxUc;
  798. u16 HostRxDiscar;
  799. u16 HmacTxMc;
  800. u16 HmacTxBc;
  801. u16 HmacTxUc;
  802. u16 HmacTxFail;
  803. u16 HmacRxMc;
  804. u16 HmacRxBc;
  805. u16 HmacRxUc;
  806. u16 HmacRxDisca;
  807. u16 HmacRxAcce;
  808. u16 SsidMismatch;
  809. u16 ApMismatch;
  810. u16 RatesMismatc;
  811. u16 AuthReject;
  812. u16 AuthTimeout;
  813. u16 AssocReject;
  814. u16 AssocTimeout;
  815. u16 NewReason;
  816. u16 AuthFail_1;
  817. u16 AuthFail_2;
  818. u16 AuthFail_3;
  819. u16 AuthFail_4;
  820. u16 AuthFail_5;
  821. u16 AuthFail_6;
  822. u16 AuthFail_7;
  823. u16 AuthFail_8;
  824. u16 AuthFail_9;
  825. u16 AuthFail_10;
  826. u16 AuthFail_11;
  827. u16 AuthFail_12;
  828. u16 AuthFail_13;
  829. u16 AuthFail_14;
  830. u16 AuthFail_15;
  831. u16 AuthFail_16;
  832. u16 AuthFail_17;
  833. u16 AuthFail_18;
  834. u16 AuthFail_19;
  835. u16 RxMan;
  836. u16 TxMan;
  837. u16 RxRefresh;
  838. u16 TxRefresh;
  839. u16 RxPoll;
  840. u16 TxPoll;
  841. u16 HostRetries;
  842. u16 LostSync_HostReq;
  843. u16 HostTxBytes;
  844. u16 HostRxBytes;
  845. u16 ElapsedUsec;
  846. u16 ElapsedSec;
  847. u16 LostSyncBett;
  848. };
  849. #define AWC_TXCTL_TXOK  (1<<1) /* report if tx is ok */
  850. #define AWC_TXCTL_TXEX  (1<<2) /* report if tx fails */
  851. #define AWC_TXCTL_802_3 (0<<3) /* 802.3 packet */
  852. #define AWC_TXCTL_802_11     (1<<3) /* 802.11 mac packet */
  853. #define AWC_TXCTL_ETHERNET   (0<<4) /* payload has ethertype */
  854. #define AWC_TXCTL_LLC   (1<<4) /* payload is llc */
  855. #define AWC_TXCTL_RELEASE    (0<<5) /* release after completion */
  856. #define AWC_TXCTL_NORELEASE  (1<<5) /* on completion returns to host */
  857. /************************* LINK STATUS STUFF *******************/
  858. #define awc_link_status_loss_of_sync_missed_beacons 0x8000
  859. #define awc_link_status_loss_of_sync_max_retries  0x8001
  860. #define awc_link_status_loss_of_sync_ARL_exceed   0x8002
  861. #define awc_link_status_loss_of_sync_host_request  0x8003
  862. #define awc_link_status_loss_of_sync_TSF_sync 0x8004
  863. #define awc_link_status_deauthentication 0x8100
  864. #define awc_link_status_disassociation 0x8200
  865. #define awc_link_status_association_failed 0x8400
  866. #define awc_link_status_authentication_failed 0x0300
  867. #define awc_link_status_associated 0x0400
  868. struct awc_strings {
  869. int par;
  870. unsigned int mask;
  871. const char * string;
  872. };
  873. #define awc_link_status_strings {
  874. {awc_link_status_loss_of_sync_missed_beacons, 0xFFFF,"Loss of sync -- missed beacons"},
  875. {awc_link_status_loss_of_sync_max_retries, 0xFFFF,"Loss of sync -- max retries"},
  876. {awc_link_status_loss_of_sync_ARL_exceed, 0xFFFF,"Loss of sync -- average retry level (ARL) exceeded"},
  877. {awc_link_status_loss_of_sync_host_request, 0xFFFF,"Loss of sync -- host request"},
  878. {awc_link_status_loss_of_sync_TSF_sync, 0xFFFF,"Loss of sync -- TSF synchronization"},
  879. {awc_link_status_deauthentication, 0xFF00,"Deauthentication "},
  880. {awc_link_status_disassociation, 0xFF00,"Disassocation "},
  881. {awc_link_status_association_failed , 0xFF00,"Association failed "},
  882. {awc_link_status_authentication_failed, 0xFF00,"Authentication failure"},
  883. {awc_link_status_associated, 0xFFFF,"Associated "},
  884. {0,0,NULL}
  885. /****************************** COMMANDS and DEFAULTS and STATUSES ***********/
  886. /****************************** COMMANDS */
  887. // Command definitions
  888. #define awc4500wout(base, com, p0,p1,p2) {
  889. awc_write(base,awc_Param0_register, p0);
  890. awc_write(base,awc_Param1_register, p1);
  891. awc_write(base,awc_Param2_register, p2);
  892. WAIT61x3;
  893. awc_write(base,awc_Command_register, com);
  894. WAIT61x3;
  895. }
  896. #define awc_wout(cmd, com, p0,p1,p2) {
  897. awc_write(base,awc_Param0_register, p0);
  898. awc_write(base,awc_Param1_register, p1);
  899. awc_write(base,awc_Param2_register, p2);
  900. WAIT61x3;
  901. awc_write(base,awc_Command_register, com);
  902. WAIT61x3;
  903. }
  904. #define awc_command_NOP(cmd) awc_wout( cmd,0x0000,0,0,0) //  NOP
  905. #define awc_command_Enable_All(cmd) awc_wout( cmd,0x0001,0,0,0) //  Enable
  906. #define awc_command_Enable_MAC(cmd) awc_wout( cmd,0x0101,0,0,0) //  Enable Mac
  907. #define awc_command_Enable_Rx(cmd) awc_wout( cmd,0x0201,0,0,0) //  Enable Rx
  908. #define awc_command_Disable_MAC(cmd) awc_wout( cmd,0x0002,0,0,0) //  Disable
  909. #define awc_command_Sync_Loss(cmd) awc_wout( cmd,0x0003,0,0,0) //  Force a Loss of Sync
  910. #define awc_command_Soft_Reset(cmd) awc_wout( cmd,0x0004,0,0,0) //  Firmware Restart (soft reset)
  911. #define awc_command_Host_Sleep(cmd) awc_wout( cmd,0x0005,0,0,0) //  Host Sleep (must be issued as 0x0085)
  912. #define awc_command_Magic_Packet(cmd) awc_wout( cmd,0x0006,0,0,0) //  Magic Packet
  913. #define awc_command_Read_Configuration(cmd) awc_wout( cmd,0x0008,0,0,0) //  Read the Configuration from nonvolatile  storage
  914. #define awc_command_Allocate_TX_Buff(cmd,size) awc_wout( cmd,0x000A,size,0,0) //  Allocate Transmit Buffer
  915. #define awc_command_TX(cmd,FID) awc_wout( cmd,0x000B,FID ,0,0) //  Transmit
  916. #define awc_command_Deallocate(cmd,FID) awc_wout( cmd,0x000C,FID ,0,0) //  Deallocate
  917. #define awc_command_NOP2(cmd) awc_wout( cmd,0x0010,0,0,0) //  NOP (same as 0x0000)
  918. #define awc_command_Read_RID(cmd,RID) awc_wout( cmd,0x0021,RID ,0,0) //  Read RID
  919. #define awc_command_Write_RID(cmd,RID) awc_wout( cmd,0x0121,RID ,0,0) //  Write RID
  920. #define awc_command_Allocate_Buff(cmd,size) awc_wout( cmd,0x0028,size,0,0) //  Allocate Buffer
  921. #define awc_command_PSP_Nodes(cmd) awc_wout( cmd,0x0030,0,0,0) //  PSP nodes (AP only)
  922. #define awc_command_Set_Phy_register(cmd,phy_register,clear_bits, set_bits)
  923. awc_wout( cmd,0x003E,phy_register,clear_bits, set_bits) //  Set PHY register
  924. #define awc_command_TX_Test(cmd,command, frequency, pattern) awc_wout( cmd,0x003F,command, frequency, pattern) //  Transmitter Test
  925. #define awc_command_RX_Test(cmd) awc_wout( cmd,0x013F,0,0,0) //  RX Test
  926. #define awc_command_Sleep(cmd) awc_wout( cmd,0x0085,0,0,0) //  Go to Sleep (No Ack bit is mandatory)
  927. #define awc_command_Save_Configuration(cmd) awc_wout( cmd,0x0108,0,0,0) //  Save the configuration to nonvolatile
  928. #define AWC_COMMAND_NOOP_BULL  0x000
  929. #define AWC_COMMAND_ENABLE 0x001
  930. #define AWC_COMMAND_ENABLE_MAC 0x101
  931. #define AWC_COMMAND_ENABLE_RX 0x201
  932. #define AWC_COMMAND_DISABLE 0x002
  933. #define AWC_COMMAND_LOSE_SYNC 0x003
  934. #define AWC_COMMAND_SOFT_RESET 0x004
  935. #define AWC_COMMAND_HOST_SLEEP 0x085
  936. #define AWC_COMMAND_MAGIC_PACKET 0x006
  937. #define AWC_COMMAND_READ_CONF 0x008
  938. #define AWC_COMMAND_SAVE_CONF 0x108
  939. #define AWC_COMMAND_TX_ALLOC 0x00A
  940. #define AWC_COMMAND_TX 0x00B
  941. #define AWC_COMMAND_DEALLOC 0x00C
  942. #define AWC_COMMAND_NOOP 0x010
  943. #define AWC_COMMAND_READ_RID 0x021
  944. #define AWC_COMMAND_WRITE_RID 0x121
  945. #define AWC_COMMAND_ALLOC 0x028
  946. #define AWC_COMMAND_PSP_NODES 0x030
  947. #define AWC_COMMAND_SET_PHY 0x03E
  948. #define AWC_COMMAND_TX_TEST 0x03F
  949. #define AWC_COMMAND_SLEEP 0x085
  950. #define awc_command_name_strings {
  951. {0x0000, 0x00FF,"awc_command_NOP " },
  952. {0x0001, 0x00FF,"awc_command_Enable_All " },
  953. {0x0101, 0x01FF,"awc_command_Enable_MAC " },
  954. {0x0201, 0x01FF,"awc_command_Enable_Rx " },
  955. {0x0002, 0x00FF,"awc_command_Disable_MAC " },
  956. {0x0003, 0x00FF,"awc_command_Sync_Loss " },
  957. {0x0004, 0x00FF,"awc_command_Soft_Reset " },
  958. {0x0005, 0x00FF,"awc_command_Host_Sleep " },
  959. {0x0006, 0x00FF,"awc_command_Magic_Packet " },
  960. {0x0008, 0x00FF,"awc_command_Read_Configuration " },
  961. {0x000A, 0x00FF,"awc_command_Allocate_TX_Buff " },
  962. {0x000B, 0x00FF,"awc_command_TX " },
  963. {0x000C, 0x00FF,"awc_command_Deallocate " },
  964. {0x0010, 0x00FF,"awc_command_NOP2 " },
  965. {0x0021, 0x00FF,"awc_command_Read_RID " },
  966. {0x0121, 0x01FF,"awc_command_Write_RID " },
  967. {0x0028, 0x00FF,"awc_command_Allocate_Buff " },
  968. {0x0030, 0x00FF,"awc_command_PSP_Nodes " },
  969. {0x003E, 0x00FF,"awc_command_Set_Phy_register " },
  970. {0x003F, 0x00FF,"awc_command_TX_Test " },
  971. {0x013F, 0x01FF,"awc_command_RX_Test " },
  972. {0x0085, 0x00FF,"awc_command_Sleep " },
  973. {0x0108, 0x01FF,"awc_command_Save_Configuration " },
  974. {0x0000, 0x00FF, NULL}
  975. };
  976. /***************************** STATUSES */
  977. #define awc_reply_success 0x0000
  978. #define awc_reply_error_strings {
  979.    { 0x0000, 0x00FF,"    Success"},
  980.    { 0x0001, 0x00FF,"    Illegal command."},
  981.    { 0x0002, 0x00FF,"    Illegal format."},
  982.    { 0x0003, 0x00FF,"    Invalid FID."},
  983.    { 0x0004, 0x00FF,"    Invalid RID."},
  984.    { 0x0005, 0x00FF,"    Too Large"},
  985.    { 0x0006, 0x00FF,"    MAC is not disabled."},
  986.    { 0x0007, 0x00FF,"    Alloc is still busy processing previous alloc"},
  987.    { 0x0008, 0x00FF,"    Invalid Mode Field"},
  988.    { 0x0009, 0x00FF,"    Tx is not allowed in monitor mode"},
  989.    { 0x000A, 0x00FF,"    Loop test or memory test error"},
  990.    { 0x000B, 0x00FF,"    Cannot read this RID."},
  991.    { 0x000C, 0x00FF,"    Cannot write to this RID."},
  992.    { 0x000D, 0x00FF,"    Tag not found."},
  993.    { 0x0080, 0x00FF,"    Config mode is invalid."},
  994.    { 0x0081, 0x00FF,"    Config hop interval is invalid."},
  995.    { 0x0082, 0x00FF,"    Config beacon interval is invalid."},
  996.    { 0x0083, 0x00FF,"    Config receive mode is invalid."},
  997.    { 0x0084, 0x00FF,"    Config MAC address is invalid."},
  998.    { 0x0085, 0x00FF,"    Config rates are invalid."},
  999.    { 0x0086, 0x00FF,"    Config ordering field is invalid."},
  1000.    { 0x0087, 0x00FF,"    Config scan mode is invalid."},
  1001.    { 0x0088, 0x00FF,"    Config authentication type is invalid."},
  1002.    { 0x0089, 0x00FF,"    Config power save mode is invalid."},
  1003.    { 0x008A, 0x00FF,"    Config radio type is invalid."},
  1004.    { 0x008B, 0x00FF,"    Config diversity is invalid."},
  1005.    { 0x008C, 0x00FF,"    Config SSID list is invalid."},
  1006.    { 0x008D, 0x00FF,"    Config specified AP list is invalid."},
  1007.    { 0x0000, 0x00FF, NULL}
  1008. };
  1009. #define awc_reply_command_failed( status) ((status & 0x7F00) == 0x7F)
  1010. /*************************   PHY and TEST commands   ****************/
  1011. // this might be wrong and reading is not implemented(was not in spec properly)
  1012. #define awc_Set_PLCP_Word(PLCP_Word)
  1013. awc_command_Set_Phy_register(base,0x8000,0 ,PLCP_Word)
  1014. #define awc_Set_TX_Test_Freq(Tx_Test_Freq)
  1015. awc_command_Set_Phy_register(base,0x8002,0 ,Tx_Test_Freq)
  1016. #define awc_Set_Tx_Power(Tx_Power)
  1017. awc_command_Set_Phy_register(base,0x8004,0 ,Tx_Power)
  1018. #define awc_Set_RSSI_Treshold(RSSI_Treshold)
  1019. awc_command_Set_Phy_register(base,0x8006,0 ,RSSI_Treshold)
  1020. #define awc_Get_PLCP_Word(PLCP_Word)
  1021. awc_command_Set_Phy_register(base,0x8000,0 ,0)
  1022. #define awc_Get_TX_Test_Freq(Tx_Test_Freq)
  1023. awc_command_Set_Phy_register(base,0x8002,0 ,0)
  1024. #define awc_Get_Tx_Power(Tx_Power)
  1025. awc_command_Set_Phy_register(base,0x8004,0 ,0)
  1026. #define awc_Get_RSSI_Treshold(RSSI_Treshold)
  1027. awc_command_Set_Phy_register(base,0x8006,0 ,0)
  1028. #define awc_tx_test_code_end  0x0000   //  Ends the transmitter test
  1029. #define awc_tx_test_code_loop 0x0001   //  Loop back to the beginning of the commands
  1030. #define awc_tx_test_code_start 0x0002   //  Start transmitting
  1031. #define awc_tx_test_code_stop 0x0003   //  Stop transmitting
  1032. #define awc_tx_test_code_delayu 0x0004   //  Delay for N usec where N is the next word
  1033. #define awc_tx_test_code_delayk 0x0005   //  Delay for N Kusec where N is the next word
  1034. #define awc_tx_test_code_next 0x0006   //  Go to the next frequency in the frequency RID
  1035. #define awc_tx_test_code_rx 0x0007   //  Start receive mode
  1036. #define awc_tx_test_code_strings {
  1037. {  awc_tx_test_code_end ,  0x000f ,"    Ends the transmitter test"},
  1038. {  awc_tx_test_code_loop ,  0x000f ,"     Loop back to the beginning of the commands"},
  1039. {  awc_tx_test_code_start ,  0x000f ,"    Start transmitting"},
  1040. {  awc_tx_test_code_stop , 0x000f ,"    Stop transmitting"},
  1041. {  awc_tx_test_code_delayu ,  0x000f ,"    Delay for N usec where N is the next word"},
  1042. {  awc_tx_test_code_delayk ,  0x000f ,"    Delay for N Kusec where N is the next word"},
  1043. {  awc_tx_test_code_next ,  0x000f ,"    Go to the next frequency in the frequency RID"},
  1044. {  awc_tx_test_code_rx  , 0x000f ,"    Start receive mode"},
  1045. {  0   , 0x000f ,NULL}
  1046. };
  1047. #define AWC_COMMSTAT_HARD_RESET 0x0000001
  1048. #define AWC_COMMSTAT_WAKE 0x0000002
  1049. #define AWC_COMMSTAT_SOFT_RESET 0x0000004
  1050. #define AWC_COMMSTAT_CONFIGURE 0x0000008
  1051. #define AWC_COMMSTAT_READ_CONF 0x0000010
  1052. #define AWC_COMMSTAT_SAVE_CONF 0x0000020
  1053. #define AWC_COMMSTAT_DEALLOC 0x0000040
  1054. #define AWC_COMMSTAT_ALLOC_TX 0x0000080
  1055. #define AWC_COMMSTAT_ALLOC_TEST 0x0000100
  1056. #define AWC_COMMSTAT_ENABLE_MAC 0x0000200
  1057. #define AWC_COMMSTAT_ENABLE_RX 0x0000400
  1058. #define AWC_COMMSTAT_DISABLE_MAC 0x0000800
  1059. #define AWC_COMMSTAT_RX_ACK 0x0001000
  1060. #define AWC_COMMSTAT_TX_ACK 0x0002000
  1061. #define AWC_COMMSTAT_AWAKEN_ACK 0x0004000
  1062. #define AWC_COMMSTAT_TX_FAIL_ACK 0x0008000
  1063. #define AWC_COMMSTAT_LINK_ACK 0x0010000
  1064. #define AWC_COMMSTAT_CLR_CMD 0x0020000
  1065. #define AWC_COMMSTAT_ALLOC_ACK 0x0040000
  1066. #define AWC_COMMSTAT_HOST_SLEEP 0x0080000
  1067. #define AWC_COMMSTAT_RX 0x0100000
  1068. #define AWC_COMMSTAT_TX 0x0200000
  1069. #define AWC_COMMSTAT_SLEEP 0x0400000
  1070. #define AWC_COMMSTAT_PSP_NODES 0x0800000
  1071. #define AWC_COMMSTAT_SET_TX_POWER  0x1000000
  1072. /*****************************     R  I  D ***************/
  1073. #define AWC_NOF_RIDS 18
  1074. extern int awc_rid_setup(struct net_device * dev);
  1075. struct aironet4500_rid_selector{
  1076. const u16 selector;
  1077. const unsigned  MAC_Disable_at_write:1;
  1078. const unsigned read_only:1;
  1079. const unsigned  may_change:1;
  1080. const char * name;
  1081. };
  1082. extern const struct aironet4500_rid_selector aironet4500_RID_Select_General_Config;
  1083. extern const struct aironet4500_rid_selector aironet4500_RID_Select_SSID_list;
  1084. extern const struct aironet4500_rid_selector aironet4500_RID_Select_AP_list ;
  1085. extern const struct aironet4500_rid_selector aironet4500_RID_Select_Driver_name;
  1086. extern const struct aironet4500_rid_selector aironet4500_RID_Select_Encapsulation;
  1087. extern const struct aironet4500_rid_selector aironet4500_RID_Select_Active_Config;
  1088. extern const struct aironet4500_rid_selector aironet4500_RID_Select_Capabilities;
  1089. extern const struct aironet4500_rid_selector aironet4500_RID_Select_AP_Info ;
  1090. extern const struct aironet4500_rid_selector aironet4500_RID_Select_Radio_Info;
  1091. extern const struct aironet4500_rid_selector aironet4500_RID_Select_Status ;
  1092. extern const struct aironet4500_rid_selector aironet4500_RID_Select_Modulation ;
  1093. extern const struct aironet4500_rid_selector aironet4500_RID_Select_WEP_volatile ;
  1094. extern const struct aironet4500_rid_selector aironet4500_RID_Select_WEP_nonvolatile ;
  1095. extern const struct aironet4500_rid_selector aironet4500_RID_Select_16_stats;
  1096. extern const struct aironet4500_rid_selector aironet4500_RID_Select_16_stats_delta;
  1097. extern const struct aironet4500_rid_selector aironet4500_RID_Select_16_stats_clear;
  1098. extern const struct aironet4500_rid_selector aironet4500_RID_Select_32_stats;
  1099. extern const struct aironet4500_rid_selector aironet4500_RID_Select_32_stats_delta;
  1100. extern const struct aironet4500_rid_selector aironet4500_RID_Select_32_stats_clear;
  1101. #define awc_def_gen_RID(offset,name, bits,mask,value,value_name)
  1102.  {&aironet4500_RID_Select_General_Config,offset, bits,1,1,0,0, mask, value, name, value_name}
  1103. #define awc_def_SSID_RID(offset,name, bits,mask,value,value_name)
  1104.   {&aironet4500_RID_Select_SSID_list,offset, bits,1,1,0,0, mask, value, name, value_name}
  1105. #define awc_def_AP_List_RID(offset,name, bits,mask,value,value_name)
  1106.  {&aironet4500_RID_Select_AP_list,offset, bits,1,1,0,0, mask, value, name, value_name}
  1107. #define awc_def_Dname_RID(offset,name, bits,mask,value,value_name)
  1108.  {&aironet4500_RID_Select_Driver_name,offset, bits,1,1,0,0, mask, value, name, value_name}
  1109. #define awc_def_act_RID(offset,name, bits,mask,value,value_name)
  1110.  {&aironet4500_RID_Select_Active_Config,offset, bits,1,1,0,0, mask, value, name, value_name}
  1111. #define awc_def_Cap_RID(offset,name, bits,mask,value,value_name)
  1112.  {&aironet4500_RID_Select_Capabilities,offset, bits,1,1,0,0, mask, value, name, value_name}
  1113. #define awc_def_AP_RID(offset,name, bits,mask,value,value_name)
  1114.  {&aironet4500_RID_Select_AP_Info,offset, bits,1,1,0,0, mask, value, name, value_name}
  1115. #define awc_def_Radio_RID(offset,name, bits,mask,value,value_name)
  1116.  {&aironet4500_RID_Select_Radio_Info,offset, bits,1,1,0,0, mask, value, name, value_name}
  1117. #define awc_def_Stat_RID(offset,name, bits,mask,value,value_name)
  1118.  {&aironet4500_RID_Select_Status,offset, bits,1,1,0,0, mask, value, name, value_name}
  1119. #define awc_def_Enc_RID(offset,name, bits,mask,value,value_name)
  1120.  {&aironet4500_RID_Select_Encapsulation,offset, bits,1,1,0,0, mask, value, name, value_name}
  1121. #define awc_def_WEPv_RID(offset,name, bits,mask,value,value_name)
  1122.  {&aironet4500_RID_Select_WEP_volatile,offset, bits,1,1,0,0, mask, value, name, value_name}
  1123. #define awc_def_WEPnv_RID(offset,name, bits,mask,value,value_name)
  1124.  {&aironet4500_RID_Select_WEP_nonvolatile,offset, bits,1,1,0,0, mask, value, name, value_name}
  1125. #define awc_def_Modulation_RID(offset,name, bits,mask,value,value_name)
  1126.  {&aironet4500_RID_Select_Modulation,offset, bits,1,1,0,0, mask, value, name, value_name}
  1127. #define awc_def_Stats_RID(o16,offset,name, value_name)
  1128.  {&aironet4500_RID_Select_32_stats,offset, 32,1,1,0,0, 0xffffffff, 0, name, value_name}
  1129. #define awc_def_Stats_delta_RID(o16,offset,name, value_name)
  1130.  {&aironet4500_RID_Select_32_stats_delta,offset, 32,1,1,0,0, 0xffffffff, 0, name, value_name}
  1131. #define awc_def_Stats_clear_RID(o16,offset,name, value_name)
  1132.  {&aironet4500_RID_Select_32_stats_delta,offset,32,1,1,0,0, 0xffffffff,  0, name,value_name}
  1133. #define awc_def_Stats16_RID(offset,o32,name, value_name)
  1134.  {&aironet4500_RID_Select_16_stats,offset, 16,1,1,0,0, 0xffffffff, 0, name, value_name}
  1135. #define awc_def_Stats16_delta_RID(offset,o32,name, value_name)
  1136.  {&aironet4500_RID_Select_16_stats_delta,offset, 16,1,1,0,0, 0xffffffff,  0, name,value_name}
  1137. #define awc_def_Stats16_clear_RID(offset,o32,name, value_name)
  1138.  {&aironet4500_RID_Select_16_stats_delta,offset, 16,1,1,0,0, 0xffffffff,  0, name,value_name}
  1139. #define aironet4500_RID_Select_strings {
  1140. { 0xFF10, 0xffff, "General Configuration"},
  1141. { 0xFF11, 0xffff, "Valid SSID list" },
  1142. { 0xFF12, 0xffff, "Valid AP list"},
  1143. { 0xFF13, 0xffff, "Driver name"},
  1144. { 0xFF14, 0xffff, "Ethernet Protocol"},
  1145. { 0xFF15, 0xffff, "WEP volatile"},
  1146. { 0xFF16, 0xffff, "WEP nonvolatile"},
  1147. { 0xFF17, 0xffff, "Modulation"},
  1148. { 0xFF20, 0xffff, "Actual Configuration"},
  1149. { 0xFF00, 0xffff, "Capabilities"},
  1150. { 0xFF01, 0xffff, "AP Info"},
  1151. { 0xFF02, 0xffff, "Radio Info"},
  1152. { 0xFF50, 0xffff, "Status"},
  1153. { 0xFF60, 0xffff, "Cumulative 16-bit Statistics"},
  1154. { 0xFF61, 0xffff, "Delta 16-bit Statistics"},
  1155. { 0xFF62, 0xffff, "Delta 16-bit Statistics and Clear"},
  1156. { 0xFF68, 0xffff, "Cumulative 32-bit Statistics"},
  1157. { 0xFF69, 0xffff, "Delta 32-bit Statistics "},
  1158. { 0xFF6A, 0xffff, "Delta 32-bit Statistics and Clear"},
  1159. { 0x0000, 0xffff, NULL}
  1160. }
  1161. struct aironet4500_RID {
  1162. const struct aironet4500_rid_selector *  selector;
  1163. const u32  offset;
  1164. const u8  bits;
  1165. const u8  array;
  1166. const u32  units;
  1167. const unsigned read_only:1;
  1168. const unsigned null_terminated:1;
  1169. const u32  mask;
  1170. const u32  value;
  1171. const char * name;
  1172. const char * value_name;
  1173. };
  1174. struct aironet4500_RID_names{
  1175. struct aironet4500_RID rid;
  1176. char *name;
  1177. };
  1178. struct aironet4500_RID_names_values{
  1179. struct aironet4500_RID rid;
  1180. char *name;
  1181. u32 mask;
  1182. };
  1183. struct awc_rid_dir{
  1184. const struct aironet4500_rid_selector * selector;
  1185. const int size;
  1186. const struct aironet4500_RID * rids;
  1187. struct net_device * dev ;
  1188. void *  buff;
  1189. int bufflen; // just checking
  1190. };
  1191. extern int awc_nof_rids;
  1192. extern struct awc_rid_dir  awc_rids[];
  1193. struct awc_private {
  1194. dev_node_t node; // somewhere back in times PCMCIA needed that
  1195. int dummy_test; // left for cleanup
  1196. // card rid inmemory copy
  1197. struct awc_config  config; // card RID mirrors
  1198. struct awc_config  general_config; // 
  1199. struct awc_SSIDs   SSIDs;
  1200. struct awc_fixed_APs  fixed_APs;
  1201. struct awc_driver_name driver_name;
  1202. struct awc_enc_trans enc_trans;
  1203. struct awc_cap capabilities;
  1204. struct awc_status status;
  1205. struct awc_AP AP;
  1206. struct awc_Statistics_32  statistics;
  1207. struct awc_Statistics_32  statistics_delta;
  1208. struct awc_Statistics_32  statistics_delta_clear;
  1209. struct awc_Statistics_16  statistics16;
  1210. struct awc_Statistics_16  statistics16_delta;
  1211. struct awc_Statistics_16  statistics16_delta_clear;
  1212. struct awc_wep_key wep_volatile;
  1213. struct awc_wep_key wep_nonvolatile;
  1214. struct awc_modulation modulation;
  1215. // here are just references to rids
  1216. struct awc_rid_dir rid_dir[AWC_NOF_RIDS];
  1217. int rids_read;
  1218. struct awc_bap bap0;
  1219. struct awc_bap bap1;
  1220. int sleeping_bap;
  1221. struct awc_fid_queue    tx_small_ready;
  1222. struct awc_fid_queue    tx_large_ready;
  1223. struct awc_fid_queue    tx_post_process;
  1224. struct awc_fid_queue    tx_in_transmit;
  1225. spinlock_t queues_lock;
  1226. struct awc_fid_queue    rx_ready;
  1227. struct awc_fid_queue    rx_post_process;
  1228. struct semaphore tx_buff_semaphore;
  1229. volatile int tx_buffs_in_use;
  1230. volatile int  tx_small_buffs_in_use;
  1231. volatile int tx_buffs_total;
  1232. volatile int tx_small_buffs_total;
  1233. int large_buff_mem;
  1234. int small_buff_no;
  1235. volatile int mac_enabled;
  1236. u16 link_status;
  1237. u8 link_status_changed;
  1238. volatile int ejected;
  1239. volatile int bh_running;
  1240. volatile int bh_active;
  1241. volatile long tx_chain_active;
  1242. volatile u16 enabled_interrupts;
  1243. volatile u16 waiting_interrupts;
  1244. volatile int interrupt_count;
  1245. // Command serialize stuff
  1246. //changed to spinlock        struct semaphore  command_semaphore;
  1247. spinlock_t both_bap_spinlock; // on SMP, card should theorethically live without that
  1248. unsigned long both_bap_spinlock_flags;
  1249. spinlock_t bap_setup_spinlock; // on SMP, card should theoretically live without that
  1250. unsigned long bap_setup_spinlock_flags;
  1251. spinlock_t command_issuing_spinlock;
  1252. unsigned long command_issuing_spinlock_flags;
  1253. spinlock_t interrupt_spinlock;
  1254.         volatile int unlock_command_postponed;
  1255.         struct awc_command cmd;
  1256.         long long async_command_start;
  1257.         volatile int command_semaphore_on;
  1258.         struct tq_struct  immediate_bh;
  1259. volatile int process_tx_results;
  1260. u8 p2p[6];
  1261. u8 bssid[6];
  1262. int p2p_uc;
  1263. int p2p_found;
  1264. int p802_11_send;
  1265. int simple_bridge;
  1266. int force_rts_on_shorter;
  1267. int force_tx_rate;
  1268. int ip_tos_reliability_rts;
  1269. int ip_tos_troughput_no_retries;
  1270. int  full_stats;
  1271. int  debug;
  1272. struct net_device_stats stats;
  1273. struct ctl_table * proc_table;
  1274. void *  bus;
  1275. int  card_type;
  1276. };
  1277. extern int  awc_init(struct net_device * dev);
  1278. extern void  awc_reset(struct net_device *dev);
  1279. extern int  awc_config(struct net_device *dev);
  1280. extern int  awc_open(struct net_device *dev);
  1281. extern void  awc_tx_timeout(struct net_device *dev);
  1282. extern int  awc_start_xmit(struct sk_buff *, struct net_device *);
  1283. extern void  awc_interrupt(int irq, void *dev_id, struct pt_regs *regs);
  1284. extern struct net_device_stats * awc_get_stats(struct net_device *dev);
  1285. extern void awc_set_multicast_list(struct net_device *dev);
  1286. extern int awc_change_mtu(struct net_device *dev, int new_mtu);  
  1287. extern int  awc_close(struct net_device *dev);
  1288. extern int awc_private_init(struct net_device * dev);
  1289. extern int awc_register_proc(int (*awc_proc_set_device) (int),int (*awc_proc_unset_device)(int));
  1290. extern int awc_unregister_proc(void);
  1291. extern int (* awc_proc_set_fun) (int) ;
  1292. extern int (* awc_proc_unset_fun) (int) ;
  1293. extern int awc_interrupt_process(struct net_device * dev);
  1294. extern int awc_readrid(struct net_device * dev, struct aironet4500_RID * rid, void *pBuf );
  1295. extern int  awc_writerid(struct net_device * dev, struct aironet4500_RID * rid, void *pBuf);
  1296. extern int  awc_readrid_dir(struct net_device * dev, struct awc_rid_dir * rid );
  1297. extern int  awc_writerid_dir(struct net_device * dev, struct awc_rid_dir * rid);
  1298. extern int  awc_tx_alloc(struct net_device * dev) ;
  1299. extern int awc_tx_dealloc(struct net_device * dev);
  1300. extern struct awc_fid *awc_tx_fid_lookup(struct net_device * dev, u16 fid);
  1301. extern int  awc_issue_soft_reset(struct net_device * dev);
  1302. extern int awc_issue_noop(struct net_device * dev);
  1303. extern int  awc_dump_registers(struct net_device * dev);
  1304. extern unsigned short  awc_issue_command_and_block(struct awc_command * cmd);
  1305. extern int awc_enable_MAC(struct net_device * dev);
  1306. extern int awc_disable_MAC(struct net_device * dev);
  1307. extern int awc_read_all_rids(struct net_device * dev);
  1308. extern int awc_write_all_rids(struct net_device * dev);
  1309. extern int awc_receive_packet(struct net_device * dev);
  1310. extern int awc_transmit_packet(struct net_device * dev, struct awc_fid * tx_buff) ;
  1311. extern int awc_tx_complete_check(struct net_device * dev);
  1312. extern int awc_interrupt_process(struct net_device * dev);
  1313. extern void  awc_bh(struct net_device *dev);
  1314. extern int  awc_802_11_find_copy_path(struct net_device * dev, struct awc_fid * rx_buff);
  1315. extern void  awc_802_11_router_rx(struct net_device * dev,struct awc_fid * rx_buff);
  1316. extern int  awc_802_11_tx_find_path_and_post(struct net_device * dev, struct sk_buff * skb);
  1317. extern void  awc_802_11_after_tx_packet_to_card_write(struct net_device * dev, struct awc_fid * tx_buff);
  1318. extern void  awc_802_11_after_failed_tx_packet_to_card_write(struct net_device * dev,struct awc_fid * tx_buff);
  1319. extern void  awc_802_11_after_tx_complete(struct net_device * dev, struct awc_fid * tx_buff);
  1320. extern void  awc_802_11_failed_rx_copy(struct net_device * dev,struct awc_fid * rx_buff);
  1321. extern int  awc_tx_alloc(struct net_device * dev) ;
  1322. extern int  awc_tx_dealloc_fid(struct net_device * dev,struct awc_fid * fid);
  1323. extern int awc_tx_dealloc(struct net_device * dev);
  1324. extern struct awc_fid *
  1325. awc_tx_fid_lookup_and_remove(struct net_device * dev, u16 fid_handle);
  1326. extern int  awc_queues_init(struct net_device * dev);
  1327. extern int  awc_queues_destroy(struct net_device * dev);
  1328. extern int  awc_rids_setup(struct net_device * dev);
  1329. extern int awc_debug;
  1330. extern int bap_sleep ;
  1331. extern int bap_sleep_after_setup ;
  1332. extern int sleep_before_command  ;
  1333. extern int bap_sleep_before_write;
  1334. extern int sleep_in_command    ;
  1335. extern int both_bap_lock;
  1336. extern int bap_setup_spinlock;
  1337. extern int tx_queue_len ;
  1338. extern int tx_rate;
  1339. extern int awc_full_stats;
  1340. #define MAX_AWCS 4
  1341. extern struct net_device * aironet4500_devices[MAX_AWCS];
  1342. #define AWC_DEBUG 1
  1343. #ifdef AWC_DEBUG
  1344. #define DEBUG(a,args...) if (awc_debug & a) printk( args)
  1345. #define AWC_ENTRY_EXIT_DEBUG(a)  if (awc_debug & 8) printk( a)
  1346. #else
  1347. #define DEBUG(a, args...)
  1348. #define AWC_ENTRY_EXIT_DEBUG(a)
  1349. #endif
  1350. #endif /* AIRONET4500_H */