Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
rtllib.h
Go to the documentation of this file.
1 /*
2  * Merged with mainline rtllib.h in Aug 2004. Original ieee802_11
3  * remains copyright by the original authors
4  *
5  * Portions of the merged code are based on Host AP (software wireless
6  * LAN access point) driver for Intersil Prism2/2.5/3.
7  *
8  * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
10  * Copyright (c) 2002-2003, Jouni Malinen <[email protected]>
11  *
12  * Adaption to a generic IEEE 802.11 stack by James Ketrenos
14  * Copyright (c) 2004, Intel Corporation
15  *
16  * Modified for Realtek's wi-fi cards by Andrea Merello
18  *
19  * This program is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License version 2 as
21  * published by the Free Software Foundation. See README and COPYING for
22  * more details.
23  */
24 #ifndef RTLLIB_H
25 #define RTLLIB_H
26 #include <linux/if_ether.h> /* ETH_ALEN */
27 #include <linux/kernel.h> /* ARRAY_SIZE */
28 #include <linux/module.h>
29 #include <linux/interrupt.h>
30 #include <linux/jiffies.h>
31 #include <linux/timer.h>
32 #include <linux/sched.h>
33 #include <linux/semaphore.h>
34 
35 #include <linux/delay.h>
36 #include <linux/wireless.h>
37 
38 #include "rtllib_debug.h"
39 #include "rtl819x_HT.h"
40 #include "rtl819x_BA.h"
41 #include "rtl819x_TS.h"
42 
43 #include <linux/netdevice.h>
44 #include <linux/if_arp.h> /* ARPHRD_ETHER */
45 #include <net/lib80211.h>
46 
47 #define MAX_PRECMD_CNT 16
48 #define MAX_RFDEPENDCMD_CNT 16
49 #define MAX_POSTCMD_CNT 16
50 
51 #ifndef WIRELESS_SPY
52 #define WIRELESS_SPY
53 #endif
54 #include <net/iw_handler.h>
55 
56 #ifndef IW_MODE_MONITOR
57 #define IW_MODE_MONITOR 6
58 #endif
59 
60 #ifndef IWEVCUSTOM
61 #define IWEVCUSTOM 0x8c02
62 #endif
63 
64 #ifndef IW_CUSTOM_MAX
65 /* Max number of char in custom event - use multiple of them if needed */
66 #define IW_CUSTOM_MAX 256 /* In bytes */
67 #endif
68 
69 #ifndef container_of
70 
78 #define container_of(ptr, type, member) ({ \
79  const typeof(((type *)0)->member)*__mptr = (ptr); \
80  (type *)((char *)__mptr - offsetof(type, member)); })
81 #endif
82 
83 #define skb_tail_pointer_rsl(skb) skb_tail_pointer(skb)
84 
85 #define EXPORT_SYMBOL_RSL(x) EXPORT_SYMBOL(x)
86 
87 
88 #define queue_delayed_work_rsl(x, y, z) queue_delayed_work(x, y, z)
89 #define INIT_DELAYED_WORK_RSL(x, y, z) INIT_DELAYED_WORK(x, y)
90 
91 #define queue_work_rsl(x, y) queue_work(x, y)
92 #define INIT_WORK_RSL(x, y, z) INIT_WORK(x, y)
93 
94 #define container_of_work_rsl(x, y, z) container_of(x, y, z)
95 #define container_of_dwork_rsl(x, y, z) \
96  container_of(container_of(x, struct delayed_work, work), y, z)
97 
98 #define iwe_stream_add_event_rsl(info, start, stop, iwe, len) \
99  iwe_stream_add_event(info, start, stop, iwe, len)
100 
101 #define iwe_stream_add_point_rsl(info, start, stop, iwe, p) \
102  iwe_stream_add_point(info, start, stop, iwe, p)
103 
104 #define usb_alloc_urb_rsl(x, y) usb_alloc_urb(x, y)
105 #define usb_submit_urb_rsl(x, y) usb_submit_urb(x, y)
106 
107 static inline void *netdev_priv_rsl(struct net_device *dev)
108 {
109  return netdev_priv(dev);
110 }
111 
112 #define KEY_TYPE_NA 0x0
113 #define KEY_TYPE_WEP40 0x1
114 #define KEY_TYPE_TKIP 0x2
115 #define KEY_TYPE_CCMP 0x4
116 #define KEY_TYPE_WEP104 0x5
117 /* added for rtl819x tx procedure */
118 #define MAX_QUEUE_SIZE 0x10
119 
120 #define BK_QUEUE 0
121 #define BE_QUEUE 1
122 #define VI_QUEUE 2
123 #define VO_QUEUE 3
124 #define HCCA_QUEUE 4
125 #define TXCMD_QUEUE 5
126 #define MGNT_QUEUE 6
127 #define HIGH_QUEUE 7
128 #define BEACON_QUEUE 8
129 
130 #define LOW_QUEUE BE_QUEUE
131 #define NORMAL_QUEUE MGNT_QUEUE
132 
133 #ifndef IW_MODE_MESH
134 #define IW_MODE_MESH 7
135 #endif
136 #define AMSDU_SUBHEADER_LEN 14
137 #define SWRF_TIMEOUT 50
138 
139 #define IE_CISCO_FLAG_POSITION 0x08
140 #define SUPPORT_CKIP_MIC 0x08
141 #define SUPPORT_CKIP_PK 0x10
142 #define RT_RF_OFF_LEVL_ASPM BIT0
143 #define RT_RF_OFF_LEVL_CLK_REQ BIT1
144 #define RT_RF_OFF_LEVL_PCI_D3 BIT2
145 #define RT_RF_OFF_LEVL_HALT_NIC BIT3
146 #define RT_RF_OFF_LEVL_FREE_FW BIT4
147 #define RT_RF_OFF_LEVL_FW_32K BIT5
148 #define RT_RF_PS_LEVEL_ALWAYS_ASPM BIT6
149 #define RT_RF_LPS_DISALBE_2R BIT30
150 #define RT_RF_LPS_LEVEL_ASPM BIT31
151 #define RT_IN_PS_LEVEL(pPSC, _PS_FLAG) \
152  ((pPSC->CurPsLevel & _PS_FLAG) ? true : false)
153 #define RT_CLEAR_PS_LEVEL(pPSC, _PS_FLAG) \
154  (pPSC->CurPsLevel &= (~(_PS_FLAG)))
155 #define RT_SET_PS_LEVEL(pPSC, _PS_FLAG) (pPSC->CurPsLevel |= _PS_FLAG)
156 
157 /* defined for skb cb field */
158 /* At most 28 byte */
159 struct cb_desc {
160  /* Tx Desc Related flags (8-9) */
169 
171 
172  /* Tx Firmware Related flags (10-11)*/
181 
190 
191  /* Tx Desc related element(12-19) */
201 
202  /* Tx firmware related element(20-27) */
211 
214 };
215 
224 };
225 
226 struct sw_chnl_cmd {
231 } __packed;
232 
233 /*--------------------------Define -------------------------------------------*/
234 #define MGN_1M 0x02
235 #define MGN_2M 0x04
236 #define MGN_5_5M 0x0b
237 #define MGN_11M 0x16
238 
239 #define MGN_6M 0x0c
240 #define MGN_9M 0x12
241 #define MGN_12M 0x18
242 #define MGN_18M 0x24
243 #define MGN_24M 0x30
244 #define MGN_36M 0x48
245 #define MGN_48M 0x60
246 #define MGN_54M 0x6c
247 
248 #define MGN_MCS0 0x80
249 #define MGN_MCS1 0x81
250 #define MGN_MCS2 0x82
251 #define MGN_MCS3 0x83
252 #define MGN_MCS4 0x84
253 #define MGN_MCS5 0x85
254 #define MGN_MCS6 0x86
255 #define MGN_MCS7 0x87
256 #define MGN_MCS8 0x88
257 #define MGN_MCS9 0x89
258 #define MGN_MCS10 0x8a
259 #define MGN_MCS11 0x8b
260 #define MGN_MCS12 0x8c
261 #define MGN_MCS13 0x8d
262 #define MGN_MCS14 0x8e
263 #define MGN_MCS15 0x8f
264 #define MGN_MCS0_SG 0x90
265 #define MGN_MCS1_SG 0x91
266 #define MGN_MCS2_SG 0x92
267 #define MGN_MCS3_SG 0x93
268 #define MGN_MCS4_SG 0x94
269 #define MGN_MCS5_SG 0x95
270 #define MGN_MCS6_SG 0x96
271 #define MGN_MCS7_SG 0x97
272 #define MGN_MCS8_SG 0x98
273 #define MGN_MCS9_SG 0x99
274 #define MGN_MCS10_SG 0x9a
275 #define MGN_MCS11_SG 0x9b
276 #define MGN_MCS12_SG 0x9c
277 #define MGN_MCS13_SG 0x9d
278 #define MGN_MCS14_SG 0x9e
279 #define MGN_MCS15_SG 0x9f
280 
281 
286  inactivity = 0x4,
287  ap_overload = 0x5,
288  class2_err = 0x6,
289  class3_err = 0x7,
290  disas_lv_ss = 0x8,
292 
293  mic_failure = 0xe,
294 
295  invalid_IE = 0x0d,
298  IE_dismatch = 0x11,
301  invalid_AKMP = 0x14,
305  ciper_reject = 0x18,
306 
307  QoS_unspec = 0x20,
310  no_facility = 0x23,
311  req_declined = 0x25,
318 };
319 
329 
340 };
341 
386 
410 
418 
431 };
432 
438 };
439 
440 
441 #define aSifsTime \
442  (((priv->rtllib->current_network.mode == IEEE_A) \
443  || (priv->rtllib->current_network.mode == IEEE_N_24G) \
444  || (priv->rtllib->current_network.mode == IEEE_N_5G)) ? 16 : 10)
445 
446 #define MGMT_QUEUE_NUM 5
447 
448 #define IEEE_CMD_SET_WPA_PARAM 1
449 #define IEEE_CMD_SET_WPA_IE 2
450 #define IEEE_CMD_SET_ENCRYPTION 3
451 #define IEEE_CMD_MLME 4
452 
453 #define IEEE_PARAM_WPA_ENABLED 1
454 #define IEEE_PARAM_TKIP_COUNTERMEASURES 2
455 #define IEEE_PARAM_DROP_UNENCRYPTED 3
456 #define IEEE_PARAM_PRIVACY_INVOKED 4
457 #define IEEE_PARAM_AUTH_ALGS 5
458 #define IEEE_PARAM_IEEE_802_1X 6
459 #define IEEE_PARAM_WPAX_SELECT 7
460 #define IEEE_PROTO_WPA 1
461 #define IEEE_PROTO_RSN 2
462 #define IEEE_WPAX_USEGROUP 0
463 #define IEEE_WPAX_WEP40 1
464 #define IEEE_WPAX_TKIP 2
465 #define IEEE_WPAX_WRAP 3
466 #define IEEE_WPAX_CCMP 4
467 #define IEEE_WPAX_WEP104 5
468 
469 #define IEEE_KEY_MGMT_IEEE8021X 1
470 #define IEEE_KEY_MGMT_PSK 2
471 
472 #define IEEE_MLME_STA_DEAUTH 1
473 #define IEEE_MLME_STA_DISASSOC 2
474 
475 
476 #define IEEE_CRYPT_ERR_UNKNOWN_ALG 2
477 #define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3
478 #define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4
479 #define IEEE_CRYPT_ERR_KEY_SET_FAILED 5
480 #define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6
481 #define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7
482 #define IEEE_CRYPT_ALG_NAME_LEN 16
483 
484 #define MAX_IE_LEN 0xff
485 #define RT_ASSERT_RET(_Exp) do {} while (0)
486 #define RT_ASSERT_RET_VALUE(_Exp, Ret) \
487  do {} while (0)
488 
489 struct ieee_param {
490  u32 cmd;
492  union {
493  struct {
494  u8 name;
495  u32 value;
496  } wpa_param;
497  struct {
498  u32 len;
499  u8 reserved[32];
500  u8 data[0];
501  } wpa_ie;
502  struct {
503  int command;
504  int reason_code;
505  } mlme;
506  struct {
508  u8 set_tx;
509  u32 err;
510  u8 idx;
511  u8 seq[8]; /* sequence counter (set: RX, get: TX) */
512  u16 key_len;
513  u8 key[0];
514  } crypt;
515  } u;
516 };
517 
518 
519 #if WIRELESS_EXT < 17
520 #define IW_QUAL_QUAL_INVALID 0x10
521 #define IW_QUAL_LEVEL_INVALID 0x20
522 #define IW_QUAL_NOISE_INVALID 0x40
523 #define IW_QUAL_QUAL_UPDATED 0x1
524 #define IW_QUAL_LEVEL_UPDATED 0x2
525 #define IW_QUAL_NOISE_UPDATED 0x4
526 #endif
527 
528 #define MSECS(t) msecs_to_jiffies(t)
529 #define msleep_interruptible_rsl msleep_interruptible
530 
531 #define RTLLIB_DATA_LEN 2304
532 /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
533  6.2.1.1.2.
534 
535  The figure in section 7.1.2 suggests a body size of up to 2312
536  bytes is allowed, which is a bit confusing, I suspect this
537  represents the 2304 bytes of real data, plus a possible 8 bytes of
538  WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
539 #define RTLLIB_1ADDR_LEN 10
540 #define RTLLIB_2ADDR_LEN 16
541 #define RTLLIB_3ADDR_LEN 24
542 #define RTLLIB_4ADDR_LEN 30
543 #define RTLLIB_FCS_LEN 4
544 #define RTLLIB_HLEN (RTLLIB_4ADDR_LEN)
545 #define RTLLIB_FRAME_LEN (RTLLIB_DATA_LEN + RTLLIB_HLEN)
546 #define RTLLIB_MGMT_HDR_LEN 24
547 #define RTLLIB_DATA_HDR3_LEN 24
548 #define RTLLIB_DATA_HDR4_LEN 30
549 
550 #define RTLLIB_SKBBUFFER_SIZE 2500
551 
552 #define MIN_FRAG_THRESHOLD 256U
553 #define MAX_FRAG_THRESHOLD 2346U
554 #define MAX_HT_DATA_FRAG_THRESHOLD 0x2000
555 
556 #define HT_AMSDU_SIZE_4K 3839
557 #define HT_AMSDU_SIZE_8K 7935
558 
559 /* Frame control field constants */
560 #define RTLLIB_FCTL_VERS 0x0003
561 #define RTLLIB_FCTL_FTYPE 0x000c
562 #define RTLLIB_FCTL_STYPE 0x00f0
563 #define RTLLIB_FCTL_FRAMETYPE 0x00fc
564 #define RTLLIB_FCTL_TODS 0x0100
565 #define RTLLIB_FCTL_FROMDS 0x0200
566 #define RTLLIB_FCTL_DSTODS 0x0300
567 #define RTLLIB_FCTL_MOREFRAGS 0x0400
568 #define RTLLIB_FCTL_RETRY 0x0800
569 #define RTLLIB_FCTL_PM 0x1000
570 #define RTLLIB_FCTL_MOREDATA 0x2000
571 #define RTLLIB_FCTL_WEP 0x4000
572 #define RTLLIB_FCTL_ORDER 0x8000
573 
574 #define RTLLIB_FTYPE_MGMT 0x0000
575 #define RTLLIB_FTYPE_CTL 0x0004
576 #define RTLLIB_FTYPE_DATA 0x0008
577 
578 /* management */
579 #define RTLLIB_STYPE_ASSOC_REQ 0x0000
580 #define RTLLIB_STYPE_ASSOC_RESP 0x0010
581 #define RTLLIB_STYPE_REASSOC_REQ 0x0020
582 #define RTLLIB_STYPE_REASSOC_RESP 0x0030
583 #define RTLLIB_STYPE_PROBE_REQ 0x0040
584 #define RTLLIB_STYPE_PROBE_RESP 0x0050
585 #define RTLLIB_STYPE_BEACON 0x0080
586 #define RTLLIB_STYPE_ATIM 0x0090
587 #define RTLLIB_STYPE_DISASSOC 0x00A0
588 #define RTLLIB_STYPE_AUTH 0x00B0
589 #define RTLLIB_STYPE_DEAUTH 0x00C0
590 #define RTLLIB_STYPE_MANAGE_ACT 0x00D0
591 
592 /* control */
593 #define RTLLIB_STYPE_PSPOLL 0x00A0
594 #define RTLLIB_STYPE_RTS 0x00B0
595 #define RTLLIB_STYPE_CTS 0x00C0
596 #define RTLLIB_STYPE_ACK 0x00D0
597 #define RTLLIB_STYPE_CFEND 0x00E0
598 #define RTLLIB_STYPE_CFENDACK 0x00F0
599 #define RTLLIB_STYPE_BLOCKACK 0x0094
600 
601 /* data */
602 #define RTLLIB_STYPE_DATA 0x0000
603 #define RTLLIB_STYPE_DATA_CFACK 0x0010
604 #define RTLLIB_STYPE_DATA_CFPOLL 0x0020
605 #define RTLLIB_STYPE_DATA_CFACKPOLL 0x0030
606 #define RTLLIB_STYPE_NULLFUNC 0x0040
607 #define RTLLIB_STYPE_CFACK 0x0050
608 #define RTLLIB_STYPE_CFPOLL 0x0060
609 #define RTLLIB_STYPE_CFACKPOLL 0x0070
610 #define RTLLIB_STYPE_QOS_DATA 0x0080
611 #define RTLLIB_STYPE_QOS_NULL 0x00C0
612 
613 #define RTLLIB_SCTL_FRAG 0x000F
614 #define RTLLIB_SCTL_SEQ 0xFFF0
615 
616 /* QOS control */
617 #define RTLLIB_QCTL_TID 0x000F
618 
619 #define FC_QOS_BIT BIT7
620 #define IsDataFrame(pdu) (((pdu[0] & 0x0C) == 0x08) ? true : false)
621 #define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0]&FC_QOS_BIT)))
622 #define IsQoSDataFrame(pframe) \
623  ((*(u16 *)pframe&(RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA)) == \
624  (RTLLIB_STYPE_QOS_DATA|RTLLIB_FTYPE_DATA))
625 #define Frame_Order(pframe) (*(u16 *)pframe&RTLLIB_FCTL_ORDER)
626 #define SN_LESS(a, b) (((a-b)&0x800) != 0)
627 #define SN_EQUAL(a, b) (a == b)
628 #define MAX_DEV_ADDR_SIZE 8
629 
636 };
637 
638 enum ts_action {
643 };
644 
645 enum ba_action {
649 };
650 
655 };
656 
671 };
672 
674  RF_1T2R = 0,
680 };
681 
690 };
691 
697 };
698 
699 #define OUI_SUBTYPE_WMM_INFO 0
700 #define OUI_SUBTYPE_WMM_PARAM 1
701 #define OUI_SUBTYPE_QOS_CAPABI 5
702 
703 /* debug macros */
704 extern u32 rtllib_debug_level;
705 #define RTLLIB_DEBUG(level, fmt, args...) \
706 do { \
707  if (rtllib_debug_level & (level)) \
708  printk(KERN_DEBUG "rtllib: " fmt, ## args); \
709 } while (0)
710 
711 #define RTLLIB_DEBUG_DATA(level, data, datalen) \
712  do { \
713  if ((rtllib_debug_level & (level)) == (level)) { \
714  int i; \
715  u8 *pdata = (u8 *)data; \
716  printk(KERN_DEBUG "rtllib: %s()\n", __func__); \
717  for (i = 0; i < (int)(datalen); i++) { \
718  printk("%2.2x ", pdata[i]); \
719  if ((i+1)%16 == 0) \
720  printk("\n"); \
721  } \
722  printk("\n"); \
723  } \
724  } while (0)
725 
726 /*
727  * To use the debug system;
728  *
729  * If you are defining a new debug classification, simply add it to the #define
730  * list here in the form of:
731  *
732  * #define RTLLIB_DL_xxxx VALUE
733  *
734  * shifting value to the left one bit from the previous entry. xxxx should be
735  * the name of the classification (for example, WEP)
736  *
737  * You then need to either add a RTLLIB_xxxx_DEBUG() macro definition for your
738  * classification, or use RTLLIB_DEBUG(RTLLIB_DL_xxxx, ...) whenever you want
739  * to send output to that classification.
740  *
741  * To add your debug level to the list of levels seen when you perform
742  *
743  * % cat /proc/net/ipw/debug_level
744  *
745  * you simply need to add your entry to the ipw_debug_levels array.
746  *
747  *
748  */
749 
750 #define RTLLIB_DL_INFO (1<<0)
751 #define RTLLIB_DL_WX (1<<1)
752 #define RTLLIB_DL_SCAN (1<<2)
753 #define RTLLIB_DL_STATE (1<<3)
754 #define RTLLIB_DL_MGMT (1<<4)
755 #define RTLLIB_DL_FRAG (1<<5)
756 #define RTLLIB_DL_EAP (1<<6)
757 #define RTLLIB_DL_DROP (1<<7)
758 
759 #define RTLLIB_DL_TX (1<<8)
760 #define RTLLIB_DL_RX (1<<9)
761 
762 #define RTLLIB_DL_HT (1<<10)
763 #define RTLLIB_DL_BA (1<<11)
764 #define RTLLIB_DL_TS (1<<12)
765 #define RTLLIB_DL_QOS (1<<13)
766 #define RTLLIB_DL_REORDER (1<<14)
767 #define RTLLIB_DL_IOT (1<<15)
768 #define RTLLIB_DL_IPS (1<<16)
769 #define RTLLIB_DL_TRACE (1<<29)
770 #define RTLLIB_DL_DATA (1<<30)
771 #define RTLLIB_DL_ERR (1<<31)
772 #define RTLLIB_ERROR(f, a...) printk(KERN_ERR "rtllib: " f, ## a)
773 #define RTLLIB_WARNING(f, a...) printk(KERN_WARNING "rtllib: " f, ## a)
774 #define RTLLIB_DEBUG_INFO(f, a...) RTLLIB_DEBUG(RTLLIB_DL_INFO, f, ## a)
775 
776 #define RTLLIB_DEBUG_WX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_WX, f, ## a)
777 #define RTLLIB_DEBUG_SCAN(f, a...) RTLLIB_DEBUG(RTLLIB_DL_SCAN, f, ## a)
778 #define RTLLIB_DEBUG_STATE(f, a...) RTLLIB_DEBUG(RTLLIB_DL_STATE, f, ## a)
779 #define RTLLIB_DEBUG_MGMT(f, a...) RTLLIB_DEBUG(RTLLIB_DL_MGMT, f, ## a)
780 #define RTLLIB_DEBUG_FRAG(f, a...) RTLLIB_DEBUG(RTLLIB_DL_FRAG, f, ## a)
781 #define RTLLIB_DEBUG_EAP(f, a...) RTLLIB_DEBUG(RTLLIB_DL_EAP, f, ## a)
782 #define RTLLIB_DEBUG_DROP(f, a...) RTLLIB_DEBUG(RTLLIB_DL_DROP, f, ## a)
783 #define RTLLIB_DEBUG_TX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_TX, f, ## a)
784 #define RTLLIB_DEBUG_RX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_RX, f, ## a)
785 #define RTLLIB_DEBUG_QOS(f, a...) RTLLIB_DEBUG(RTLLIB_DL_QOS, f, ## a)
786 
787 /* Added by Annie, 2005-11-22. */
788 #define MAX_STR_LEN 64
789 /* I want to see ASCII 33 to 126 only. Otherwise, I print '?'. */
790 #define PRINTABLE(_ch) (_ch > '!' && _ch < '~')
791 #define RTLLIB_PRINT_STR(_Comp, _TitleString, _Ptr, _Len) \
792  if ((_Comp) & level) { \
793  int __i; \
794  u8 struct buffer[MAX_STR_LEN]; \
795  int length = (_Len < MAX_STR_LEN) ? _Len : (MAX_STR_LEN-1) ;\
796  memset(struct buffer, 0, MAX_STR_LEN); \
797  memcpy(struct buffer, (u8 *)_Ptr, length); \
798  for (__i = 0; __i < MAX_STR_LEN; __i++) { \
799  if (!PRINTABLE(struct buffer[__i])) \
800  struct buffer[__i] = '?'; \
801  } \
802  struct buffer[length] = '\0'; \
803  printk(KERN_INFO "Rtl819x: "); \
804  printk(_TitleString); \
805  printk(": %d, <%s>\n", _Len, struct buffer); \
806  }
807 #ifndef ETH_P_PAE
808 #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
809 #define ETH_P_IP 0x0800 /* Internet Protocol packet */
810 #define ETH_P_ARP 0x0806 /* Address Resolution packet */
811 #endif /* ETH_P_PAE */
812 
813 #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
814 
815 #ifndef ETH_P_80211_RAW
816 #define ETH_P_80211_RAW (ETH_P_ECONET + 1)
817 #endif
818 
819 /* IEEE 802.11 defines */
820 
821 #define P80211_OUI_LEN 3
822 
824 
825  u8 dsap; /* always 0xAA */
826  u8 ssap; /* always 0xAA */
827  u8 ctrl; /* always 0x03 */
828  u8 oui[P80211_OUI_LEN]; /* organizational universal id */
829 
830 } __packed;
831 
836 };
837 
838 #define SNAP_SIZE sizeof(struct rtllib_snap_hdr)
839 
840 #define WLAN_FC_GET_VERS(fc) ((fc) & RTLLIB_FCTL_VERS)
841 #define WLAN_FC_GET_TYPE(fc) ((fc) & RTLLIB_FCTL_FTYPE)
842 #define WLAN_FC_GET_STYPE(fc) ((fc) & RTLLIB_FCTL_STYPE)
843 #define WLAN_FC_MORE_DATA(fc) ((fc) & RTLLIB_FCTL_MOREDATA)
844 
845 #define WLAN_FC_GET_FRAMETYPE(fc) ((fc) & RTLLIB_FCTL_FRAMETYPE)
846 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTLLIB_SCTL_FRAG)
847 #define WLAN_GET_SEQ_SEQ(seq) (((seq) & RTLLIB_SCTL_SEQ) >> 4)
848 
849 /* Authentication algorithms */
850 #define WLAN_AUTH_OPEN 0
851 #define WLAN_AUTH_SHARED_KEY 1
852 #define WLAN_AUTH_LEAP 128
853 
854 #define WLAN_AUTH_CHALLENGE_LEN 128
855 
856 #define WLAN_CAPABILITY_ESS (1<<0)
857 #define WLAN_CAPABILITY_IBSS (1<<1)
858 #define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
859 #define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
860 #define WLAN_CAPABILITY_PRIVACY (1<<4)
861 #define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
862 #define WLAN_CAPABILITY_PBCC (1<<6)
863 #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
864 #define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8)
865 #define WLAN_CAPABILITY_QOS (1<<9)
866 #define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10)
867 #define WLAN_CAPABILITY_DSSS_OFDM (1<<13)
868 
869 /* 802.11g ERP information element */
870 #define WLAN_ERP_NON_ERP_PRESENT (1<<0)
871 #define WLAN_ERP_USE_PROTECTION (1<<1)
872 #define WLAN_ERP_BARKER_PREAMBLE (1<<2)
873 
874 #define RTLLIB_STATMASK_SIGNAL (1<<0)
875 #define RTLLIB_STATMASK_RSSI (1<<1)
876 #define RTLLIB_STATMASK_NOISE (1<<2)
877 #define RTLLIB_STATMASK_RATE (1<<3)
878 #define RTLLIB_STATMASK_WEMASK 0x7
879 
880 #define RTLLIB_CCK_MODULATION (1<<0)
881 #define RTLLIB_OFDM_MODULATION (1<<1)
882 
883 #define RTLLIB_24GHZ_BAND (1<<0)
884 #define RTLLIB_52GHZ_BAND (1<<1)
885 
886 #define RTLLIB_CCK_RATE_LEN 4
887 #define RTLLIB_CCK_RATE_1MB 0x02
888 #define RTLLIB_CCK_RATE_2MB 0x04
889 #define RTLLIB_CCK_RATE_5MB 0x0B
890 #define RTLLIB_CCK_RATE_11MB 0x16
891 #define RTLLIB_OFDM_RATE_LEN 8
892 #define RTLLIB_OFDM_RATE_6MB 0x0C
893 #define RTLLIB_OFDM_RATE_9MB 0x12
894 #define RTLLIB_OFDM_RATE_12MB 0x18
895 #define RTLLIB_OFDM_RATE_18MB 0x24
896 #define RTLLIB_OFDM_RATE_24MB 0x30
897 #define RTLLIB_OFDM_RATE_36MB 0x48
898 #define RTLLIB_OFDM_RATE_48MB 0x60
899 #define RTLLIB_OFDM_RATE_54MB 0x6C
900 #define RTLLIB_BASIC_RATE_MASK 0x80
901 
902 #define RTLLIB_CCK_RATE_1MB_MASK (1<<0)
903 #define RTLLIB_CCK_RATE_2MB_MASK (1<<1)
904 #define RTLLIB_CCK_RATE_5MB_MASK (1<<2)
905 #define RTLLIB_CCK_RATE_11MB_MASK (1<<3)
906 #define RTLLIB_OFDM_RATE_6MB_MASK (1<<4)
907 #define RTLLIB_OFDM_RATE_9MB_MASK (1<<5)
908 #define RTLLIB_OFDM_RATE_12MB_MASK (1<<6)
909 #define RTLLIB_OFDM_RATE_18MB_MASK (1<<7)
910 #define RTLLIB_OFDM_RATE_24MB_MASK (1<<8)
911 #define RTLLIB_OFDM_RATE_36MB_MASK (1<<9)
912 #define RTLLIB_OFDM_RATE_48MB_MASK (1<<10)
913 #define RTLLIB_OFDM_RATE_54MB_MASK (1<<11)
914 
915 #define RTLLIB_CCK_RATES_MASK 0x0000000F
916 #define RTLLIB_CCK_BASIC_RATES_MASK (RTLLIB_CCK_RATE_1MB_MASK | \
917  RTLLIB_CCK_RATE_2MB_MASK)
918 #define RTLLIB_CCK_DEFAULT_RATES_MASK (RTLLIB_CCK_BASIC_RATES_MASK | \
919  RTLLIB_CCK_RATE_5MB_MASK | \
920  RTLLIB_CCK_RATE_11MB_MASK)
921 
922 #define RTLLIB_OFDM_RATES_MASK 0x00000FF0
923 #define RTLLIB_OFDM_BASIC_RATES_MASK (RTLLIB_OFDM_RATE_6MB_MASK | \
924  RTLLIB_OFDM_RATE_12MB_MASK | \
925  RTLLIB_OFDM_RATE_24MB_MASK)
926 #define RTLLIB_OFDM_DEFAULT_RATES_MASK (RTLLIB_OFDM_BASIC_RATES_MASK | \
927  RTLLIB_OFDM_RATE_9MB_MASK | \
928  RTLLIB_OFDM_RATE_18MB_MASK | \
929  RTLLIB_OFDM_RATE_36MB_MASK | \
930  RTLLIB_OFDM_RATE_48MB_MASK | \
931  RTLLIB_OFDM_RATE_54MB_MASK)
932 #define RTLLIB_DEFAULT_RATES_MASK (RTLLIB_OFDM_DEFAULT_RATES_MASK | \
933  RTLLIB_CCK_DEFAULT_RATES_MASK)
934 
935 #define RTLLIB_NUM_OFDM_RATES 8
936 #define RTLLIB_NUM_CCK_RATES 4
937 #define RTLLIB_OFDM_SHIFT_MASK_A 4
938 
939 
940 /* this is stolen and modified from the madwifi driver*/
941 #define RTLLIB_FC0_TYPE_MASK 0x0c
942 #define RTLLIB_FC0_TYPE_DATA 0x08
943 #define RTLLIB_FC0_SUBTYPE_MASK 0xB0
944 #define RTLLIB_FC0_SUBTYPE_QOS 0x80
945 
946 #define RTLLIB_QOS_HAS_SEQ(fc) \
947  (((fc) & (RTLLIB_FC0_TYPE_MASK | RTLLIB_FC0_SUBTYPE_MASK)) == \
948  (RTLLIB_FC0_TYPE_DATA | RTLLIB_FC0_SUBTYPE_QOS))
949 
950 /* this is stolen from ipw2200 driver */
951 #define IEEE_IBSS_MAC_HASH_SIZE 31
952 struct ieee_ibss_seq {
953  u8 mac[ETH_ALEN];
954  u16 seq_num[17];
955  u16 frag_num[17];
956  unsigned long packet_time[17];
957  struct list_head list;
958 };
959 
960 /* NOTE: This data is for statistical purposes; not all hardware provides this
961  * information for frames received. Not setting these will not cause
962  * any adverse affects. */
968  u16 rate; /* in 100 kbps */
993  bool bShift;
996 
999  bool bIsAMPDU;
1007  bool bIsCCK;
1017  char cck_adc_pwdb[4];
1020 };
1021 
1022 /* IEEE 802.11 requires that STA supports concurrent reception of at least
1023  * three fragmented frames. This define can be increased to support more
1024  * concurrent frames, but it should be noted that each entry can consume about
1025  * 2 kB of RAM and increasing cache size will slow down frame reassembly. */
1026 #define RTLLIB_FRAG_CACHE_LEN 4
1027 
1029  unsigned long first_frag_time;
1030  unsigned int seq;
1031  unsigned int last_frag;
1032  struct sk_buff *skb;
1035 };
1036 
1038  unsigned int tx_unicast_frames;
1039  unsigned int tx_multicast_frames;
1040  unsigned int tx_fragments;
1041  unsigned int tx_unicast_octets;
1042  unsigned int tx_multicast_octets;
1047  unsigned int tx_discards;
1048  unsigned int rx_unicast_frames;
1049  unsigned int rx_multicast_frames;
1050  unsigned int rx_fragments;
1051  unsigned int rx_unicast_octets;
1052  unsigned int rx_multicast_octets;
1053  unsigned int rx_fcs_errors;
1055  unsigned int tx_discards_wrong_sa;
1059 };
1060 
1061 struct rtllib_device;
1062 
1063 #define SEC_KEY_1 (1<<0)
1064 #define SEC_KEY_2 (1<<1)
1065 #define SEC_KEY_3 (1<<2)
1066 #define SEC_KEY_4 (1<<3)
1067 #define SEC_ACTIVE_KEY (1<<4)
1068 #define SEC_AUTH_MODE (1<<5)
1069 #define SEC_UNICAST_GROUP (1<<6)
1070 #define SEC_LEVEL (1<<7)
1071 #define SEC_ENABLED (1<<8)
1072 #define SEC_ENCRYPT (1<<9)
1073 
1074 #define SEC_LEVEL_0 0 /* None */
1075 #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
1076 #define SEC_LEVEL_2 2 /* Level 1 + TKIP */
1077 #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
1078 #define SEC_LEVEL_3 4 /* Level 2 + CCMP */
1079 
1080 #define SEC_ALG_NONE 0
1081 #define SEC_ALG_WEP 1
1082 #define SEC_ALG_TKIP 2
1083 #define SEC_ALG_CCMP 4
1084 
1085 #define WEP_KEY_LEN 13
1086 #define SCM_KEY_LEN 32
1087 #define SCM_TEMPORAL_KEY_LENGTH 16
1088 
1091  enabled:1,
1092  auth_mode:2,
1093  auth_algo:4,
1095  encrypt:1;
1100 } __packed;
1101 
1102 
1103 /*
1104  802.11 data frame from AP
1105  ,-------------------------------------------------------------------.
1106 Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
1107  |------|------|---------|---------|---------|------|---------|------|
1108 Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
1109  | | tion | (BSSID) | | | ence | data | |
1110  `-------------------------------------------------------------------'
1111 Total: 28-2340 bytes
1112 */
1113 
1114 /* Management Frame Information Element Types */
1146 };
1147 
1148 /* Minimal header; can be used for passing 802.11 frames with sufficient
1149  * information to determine what type of underlying data type is actually
1150  * stored in the data. */
1156 } __packed;
1157 
1158 struct rtllib_hdr {
1162 } __packed;
1163 
1169 } __packed;
1170 
1177 } __packed;
1178 
1187 } __packed;
1188 
1198 } __packed;
1199 
1209 } __packed;
1210 
1221 } __packed;
1222 
1226  u8 data[0];
1227 } __packed;
1228 
1234  /*challenge*/
1236 } __packed;
1237 
1241 } __packed;
1242 
1246 } __packed;
1247 
1250  /* SSID, supported rates */
1252 } __packed;
1253 
1259  /* SSID, supported rates, FH params, DS params,
1260  * CF params, IBSS params, TIM (if beacon), RSN */
1262 } __packed;
1263 
1264 /* Alias beacon for probe_response */
1265 #define rtllib_beacon rtllib_probe_response
1266 
1271  /* SSID, supported rates, RSN */
1273 } __packed;
1274 
1280  /* SSID, supported rates, RSN */
1282 } __packed;
1283 
1289  struct rtllib_info_element info_element[0]; /* supported rates */
1290 } __packed;
1291 
1292 struct rtllib_txb {
1300  struct sk_buff *fragments[0];
1301 };
1302 
1303 #define MAX_TX_AGG_COUNT 16
1307 } __packed;
1308 
1309 #define MAX_SUBFRAME_COUNT 64
1310 struct rtllib_rxb {
1315 } __packed;
1316 
1317 union frameqos {
1320  struct {
1326  } field;
1327 };
1328 
1329 /* SWEEP TABLE ENTRIES NUMBER*/
1330 #define MAX_SWEEP_TAB_ENTRIES 42
1331 #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
1332 /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
1333  * only use 8, and then use extended rates for the remaining supported
1334  * rates. Other APs, however, stick all of their supported rates on the
1335  * main rates information element... */
1336 #define MAX_RATES_LENGTH ((u8)12)
1337 #define MAX_RATES_EX_LENGTH ((u8)16)
1338 #define MAX_NETWORK_COUNT 96
1339 
1340 #define MAX_CHANNEL_NUMBER 161
1341 #define RTLLIB_SOFTMAC_SCAN_TIME 100
1342 #define RTLLIB_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2)
1343 
1344 #define CRC_LENGTH 4U
1345 
1346 #define MAX_WPA_IE_LEN 64
1347 #define MAX_WZC_IE_LEN 256
1348 
1349 #define NETWORK_EMPTY_ESSID (1<<0)
1350 #define NETWORK_HAS_OFDM (1<<1)
1351 #define NETWORK_HAS_CCK (1<<2)
1352 
1353 /* QoS structure */
1354 #define NETWORK_HAS_QOS_PARAMETERS (1<<3)
1355 #define NETWORK_HAS_QOS_INFORMATION (1<<4)
1356 #define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | \
1357  NETWORK_HAS_QOS_INFORMATION)
1358 /* 802.11h */
1359 #define NETWORK_HAS_POWER_CONSTRAINT (1<<5)
1360 #define NETWORK_HAS_CSA (1<<6)
1361 #define NETWORK_HAS_QUIET (1<<7)
1362 #define NETWORK_HAS_IBSS_DFS (1<<8)
1363 #define NETWORK_HAS_TPC_REPORT (1<<9)
1364 
1365 #define NETWORK_HAS_ERP_VALUE (1<<10)
1366 
1367 #define QOS_QUEUE_NUM 4
1368 #define QOS_OUI_LEN 3
1369 #define QOS_OUI_TYPE 2
1370 #define QOS_ELEMENT_ID 221
1371 #define QOS_OUI_INFO_SUB_TYPE 0
1372 #define QOS_OUI_PARAM_SUB_TYPE 1
1373 #define QOS_VERSION_1 1
1374 #define QOS_AIFSN_MIN_VALUE 2
1375 
1384 } __packed;
1385 
1390 } __packed;
1391 
1396 } __packed;
1397 
1404 } __packed;
1405 
1408  unsigned int wmm_acm;
1409  int active;
1413 };
1414 
1418 } __packed;
1419 
1424 };
1425 
1430 } __packed;
1431 
1449 } __packed;
1450 
1451 enum eap_type {
1457 };
1458 
1459 static const char *eap_types[] = {
1460  [EAP_PACKET] = "EAP-Packet",
1461  [EAPOL_START] = "EAPOL-Start",
1462  [EAPOL_LOGOFF] = "EAPOL-Logoff",
1463  [EAPOL_KEY] = "EAPOL-Key",
1464  [EAPOL_ENCAP_ASF_ALERT] = "EAPOL-Encap-ASF-Alert"
1465 };
1466 
1467 static inline const char *eap_get_type(int type)
1468 {
1469  return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" :
1470  eap_types[type];
1471 }
1472 static inline u8 Frame_QoSTID(u8 *buf)
1473 {
1474  struct rtllib_hdr_3addr *hdr;
1475  u16 fc;
1476  hdr = (struct rtllib_hdr_3addr *)buf;
1477  fc = le16_to_cpu(hdr->frame_ctl);
1478  return (u8)((union frameqos *)(buf + (((fc & RTLLIB_FCTL_TODS) &&
1479  (fc & RTLLIB_FCTL_FROMDS)) ? 30 : 24)))->field.tid;
1480 }
1481 
1482 
1483 struct eapol {
1484  u8 snap[6];
1485  u16 ethertype;
1486  u8 version;
1487  u8 type;
1488  u16 length;
1489 } __packed;
1490 
1492  unsigned int rx_ass_ok;
1493  unsigned int rx_ass_err;
1494  unsigned int rx_probe_rq;
1495  unsigned int tx_probe_rs;
1496  unsigned int tx_beacons;
1497  unsigned int rx_auth_rq;
1498  unsigned int rx_auth_rs_ok;
1499  unsigned int rx_auth_rs_err;
1500  unsigned int tx_auth_rq;
1501  unsigned int no_auth_rs;
1502  unsigned int no_ass_rs;
1503  unsigned int tx_ass_rq;
1504  unsigned int rx_ass_rq;
1505  unsigned int tx_probe_rq;
1506  unsigned int reassoc;
1507  unsigned int swtxstop;
1508  unsigned int swtxawake;
1509  unsigned char CurrentShowTxate;
1510  unsigned char last_packet_rate;
1511  unsigned int txretrycount;
1512 };
1513 
1514 #define BEACON_PROBE_SSID_ID_POSITION 12
1515 
1519 } __packed;
1520 
1521 /*
1522  * These are the data types that can make up management packets
1523  *
1524  u16 auth_algorithm;
1525  u16 auth_sequence;
1526  u16 beacon_interval;
1527  u16 capability;
1528  u8 current_ap[ETH_ALEN];
1529  u16 listen_interval;
1530  struct {
1531  u16 association_id:14, reserved:2;
1532  } __packed;
1533  u32 time_stamp[2];
1534  u16 reason;
1535  u16 status;
1536 */
1537 
1538 #define RTLLIB_DEFAULT_TX_ESSID "Penguin"
1539 #define RTLLIB_DEFAULT_BASIC_RATE 2
1540 
1542 #define MAX_SP_Len (WMM_all_frame << 4)
1543 #define RTLLIB_QOS_TID 0x0f
1544 #define QOS_CTL_NOTCONTAIN_ACK (0x01 << 5)
1545 
1546 #define RTLLIB_DTIM_MBCAST 4
1547 #define RTLLIB_DTIM_UCAST 2
1548 #define RTLLIB_DTIM_VALID 1
1549 #define RTLLIB_DTIM_INVALID 0
1550 
1551 #define RTLLIB_PS_DISABLED 0
1552 #define RTLLIB_PS_UNICAST RTLLIB_DTIM_UCAST
1553 #define RTLLIB_PS_MBCAST RTLLIB_DTIM_MBCAST
1554 
1555 #define WME_AC_BK 0x00
1556 #define WME_AC_BE 0x01
1557 #define WME_AC_VI 0x02
1558 #define WME_AC_VO 0x03
1559 #define WME_ACI_MASK 0x03
1560 #define WME_AIFSN_MASK 0x03
1561 #define WME_AC_PRAM_LEN 16
1562 
1563 #define MAX_RECEIVE_BUFFER_SIZE 9100
1564 
1565 #define UP2AC(up) ( \
1566  ((up) < 1) ? WME_AC_BE : \
1567  ((up) < 3) ? WME_AC_BK : \
1568  ((up) < 4) ? WME_AC_BE : \
1569  ((up) < 6) ? WME_AC_VI : \
1570  WME_AC_VO)
1571 
1572 #define AC2UP(_ac) ( \
1573  ((_ac) == WME_AC_VO) ? 6 : \
1574  ((_ac) == WME_AC_VI) ? 5 : \
1575  ((_ac) == WME_AC_BK) ? 1 : \
1576  0)
1577 
1578 #define ETHER_ADDR_LEN 6 /* length of an Ethernet address */
1579 #define ETHERNET_HEADER_SIZE 14 /* length of two Ethernet address
1580  * plus ether type*/
1581 
1582 struct ether_header {
1585  u16 ether_type;
1586 } __packed;
1587 
1588 #ifndef ETHERTYPE_PAE
1589 #define ETHERTYPE_PAE 0x888e /* EAPOL PAE/802.1x */
1590 #endif
1591 #ifndef ETHERTYPE_IP
1592 #define ETHERTYPE_IP 0x0800 /* IP protocol */
1593 #endif
1594 
1596 enum erp_t {
1599  ERP_BarkerPreambleMode = 0x04,
1600 };
1602 struct rtllib_network {
1603  /* These entries are used to identify a unique network */
1605  u8 channel;
1606  /* Ensure null-terminated for any debug msgs */
1611  struct rtllib_qos_data qos_data;
1622  /* These are network statistics */
1629  unsigned long last_scanned;
1639  size_t wpa_ie_len;
1641  size_t rsn_ie_len;
1643  size_t wzc_ie_len;
1655  struct bss_ht bssht;
1669  struct list_head list;
1670 };
1671 
1672 #if 1
1673 enum rtllib_state {
1674 
1675  /* the card is not linked at all */
1676  RTLLIB_NOLINK = 0,
1677 
1678  /* RTLLIB_ASSOCIATING* are for BSS client mode
1679  * the driver shall not perform RX filtering unless
1680  * the state is LINKED.
1681  * The driver shall just check for the state LINKED and
1682  * defaults to NOLINK for ALL the other states (including
1683  * LINKED_SCANNING)
1684  */
1685 
1686  /* the association procedure will start (wq scheduling)*/
1689 
1690  /* the association procedure is sending AUTH request*/
1692 
1693  /* the association procedure has successfully authenticated
1694  * and is sending association request
1695  */
1697 
1698  /* the link is ok. the card associated to a BSS or linked
1699  * to a ibss cell or acting as an AP and creating the bss
1700  */
1701  RTLLIB_LINKED,
1702 
1703  /* same as LINKED, but the driver shall apply RX filter
1704  * rules as we are in NO_LINK mode. As the card is still
1705  * logically linked, but it is doing a syncro site survey
1706  * then it will be back to LINKED state.
1707  */
1709 };
1710 #else
1711 enum rtllib_state {
1712  RTLLIB_UNINITIALIZED = 0,
1713  RTLLIB_INITIALIZED,
1715  RTLLIB_ASSOCIATED,
1716  RTLLIB_AUTHENTICATING,
1717  RTLLIB_AUTHENTICATED,
1718  RTLLIB_SHUTDOWN
1719 };
1720 #endif
1722 #define DEFAULT_MAX_SCAN_AGE (15 * HZ)
1723 #define DEFAULT_FTS 2346
1725 #define CFG_RTLLIB_RESERVE_FCS (1<<0)
1726 #define CFG_RTLLIB_COMPUTE_FCS (1<<1)
1727 #define CFG_RTLLIB_RTS (1<<2)
1729 #define RTLLIB_24GHZ_MIN_CHANNEL 1
1730 #define RTLLIB_24GHZ_MAX_CHANNEL 14
1731 #define RTLLIB_24GHZ_CHANNELS (RTLLIB_24GHZ_MAX_CHANNEL - \
1732  RTLLIB_24GHZ_MIN_CHANNEL + 1)
1734 #define RTLLIB_52GHZ_MIN_CHANNEL 34
1735 #define RTLLIB_52GHZ_MAX_CHANNEL 165
1736 #define RTLLIB_52GHZ_CHANNELS (RTLLIB_52GHZ_MAX_CHANNEL - \
1737  RTLLIB_52GHZ_MIN_CHANNEL + 1)
1738 #ifndef eqMacAddr
1739 #define eqMacAddr(a, b) \
1740  (((a)[0] == (b)[0] && (a)[1] == (b)[1] && (a)[2] == (b)[2] && \
1741  (a)[3] == (b)[3] && (a)[4] == (b)[4] && (a)[5] == (b)[5]) ? 1 : 0)
1742 #endif
1743 struct tx_pending {
1744  int frag;
1745  struct rtllib_txb *txb;
1746 };
1752  bool bautoswitch_enable;
1753 };
1754 
1755 
1757 #define REORDER_WIN_SIZE 128
1758 #define REORDER_ENTRY_NUM 128
1760  struct list_head List;
1762  struct rtllib_rxb *prxb;
1763 };
1767  SW_Fsync
1768 };
1774  eAutoPs,
1775 };
1781 };
1787  RT_NO_ACTION = 4,
1788 };
1790 struct ibss_parms {
1791  u16 atimWin;
1792 };
1793 #define MAX_NUM_RATES 264
1798  eRfOff
1799 };
1801 #define MAX_SUPPORT_WOL_PATTERN_NUM 8
1803 #define MAX_WOL_BIT_MASK_SIZE 16
1804 #define MAX_WOL_PATTERN_SIZE 128
1811  eNoDefined,
1812 };
1816  u32 Mask[4];
1820 };
1822 struct rt_pwr_save_ctrl {
1830  struct timer_list InactivePsTimer;
1836  struct rtllib_network tmpBssDesc;
1854  bool bTmpIbpm;
1860  u8 LPSAwakeIntvl;
1863  u32 RegRfPsLevel;
1866  u8 FWCtrlPSMode;
1869  bool BufConnectinfoBefore;
1870 
1872  bool bGpioRfSw;
1874  u8 RegAMDPciASPM;
1878 
1879 };
1881 #define RT_RF_CHANGE_SOURCE u32
1883 #define RF_CHANGE_BY_SW BIT31
1884 #define RF_CHANGE_BY_HW BIT30
1885 #define RF_CHANGE_BY_PS BIT29
1886 #define RF_CHANGE_BY_IPS BIT28
1887 #define RF_CHANGE_BY_INIT 0
1904 };
1909  SCAN_OPT_MAX
1910 };
1943  FW_CMD_CHAN_SET = 30,
1944 };
1946 #define RT_MAX_LD_SLOT_NUM 10
1947 struct rt_link_detect {
1955  u16 SlotIndex;
1967 };
1969 struct sw_cam_table {
1972  bool bused;
1976  u8 key_index;
1977 
1978 };
1979 #define TOTAL_CAM_ENTRY 32
1980 struct rate_adaptive {
1982  u8 ratr_state;
1983  u16 reserve;
1984 
2000  u8 PreRATRState;
2001 
2002 };
2012  RATR_INX_WIRELESS_A = 8,
2013 };
2015 #define NUM_PMKID_CACHE 16
2018  u8 Bssid[6];
2019  u8 PMKID[16];
2022  u16 ssid_length;
2023 };
2028 };
2029 
2030 
2031 /*************** DRIVER STATUS *****/
2032 #define STATUS_SCANNING 0
2033 #define STATUS_SCAN_HW 1
2034 #define STATUS_SCAN_ABORTING 2
2035 #define STATUS_SETTING_CHAN 3
2036 /*************** DRIVER STATUS *****/
2037 
2038 enum {
2039  NO_USE = 0,
2040  USED = 1,
2041  HW_SEC = 2,
2042  SW_SEC = 3,
2043 };
2044 
2045 enum {
2049 };
2052  struct pci_dev *pdev;
2053  struct net_device *dev;
2054  struct rtllib_security sec;
2056  bool disable_mgnt_queue;
2058  unsigned long status;
2063  u8 CntAfterLink;
2065  enum rt_op_mode OpMode;
2067  u8 VersionID;
2068  /* The last AssocReq/Resp IEs */
2080  bool b1SSSupport;
2086  bool ieee_up;
2127 
2128 
2129  /* Bookkeeping structures */
2133 
2134  /* Probe / Beacon management */
2138  int scans;
2139  int scan_age;
2141  int iw_mode; /* operating mode (IW_MODE_*) */
2145  struct iw_spy_data spy_data;
2150  int tx_headroom; /* Set to size of any additional room needed at front
2151  * of allocated Tx SKBs */
2152  u32 config;
2153 
2154  /* WEP and other encryption related settings at the device level */
2155  int open_wep; /* Set to 1 to allow unencrypted frames */
2157  int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
2158  * WEP key changes */
2159 
2160  /* If the host performs {en,de}cryption, then set to 1 */
2163  int host_decrypt;
2164  /* host performs multicast decryption */
2165  int host_mc_decrypt;
2166 
2167  /* host should strip IV and ICV from protected frames */
2168  /* meaningful only when hardware decryption is being used */
2169  int host_strip_iv_icv;
2173  int ieee802_1x; /* is IEEE 802.1X used */
2174 
2175  /* WPA data */
2182  size_t wpa_ie_len;
2184  size_t wps_ie_len;
2193  int bcrx_sta_key; /* use individual keys to override default keys even
2194  * with RX of broad/multicast frames */
2197 
2198  /* Fragmentation structures */
2200  unsigned int frag_next_idx[17];
2201  u16 fts; /* Fragmentation Threshold */
2202 #define DEFAULT_RTS_THRESHOLD 2346U
2203 #define MIN_RTS_THRESHOLD 1
2204 #define MAX_RTS_THRESHOLD 2346U
2205  u16 rts; /* RTS threshold */
2206 
2207  /* Association info */
2208  u8 bssid[ETH_ALEN];
2209 
2210  /* This stores infos for the current network.
2211  * Either the network we are associated in INFRASTRUCTURE
2212  * or the network that we are creating in MASTER mode.
2213  * ad-hoc is a mixture ;-).
2214  * Note that in infrastructure mode, even when not associated,
2215  * fields bssid and essid may be valid (if wpa_set and essid_set
2216  * are true) as thy carry the value set by the user via iwconfig
2217  */
2220  enum rtllib_state state;
2224  int mode; /* A, B, G */
2225  int modulation; /* CCK, OFDM */
2226  int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
2227  int abg_true; /* ABG flag */
2228 
2229  /* used for forcing the ibss workqueue to terminate
2230  * without wait for the syncro scan to terminate
2231  */
2235  int worst_rssi;
2237  u16 prev_seq_ctl; /* used to drop duplicate frames */
2238 
2239  /* map of allowed channels. 0 is dummy */
2247  int rate; /* current rate */
2249  u32 currentRate;
2251  short active_scan;
2252 
2253  /* this contains flags for selectively enable softmac support */
2255 
2256  /* if the sequence control field is not filled by HW */
2257  u16 seq_ctrl[5];
2258 
2259  /* association procedure transaction sequence number */
2261 
2262  /* AID for RTXed association responses */
2263  u16 assoc_id;
2264 
2265  /* power save mode related*/
2267  short ps;
2268  short sta_sleep;
2273  bool polling;
2275  short raw_tx;
2276  /* used if IEEE_SOFTMAC_TX_QUEUE is set */
2277  short queue_stop;
2280  short proto_stoppping;
2284  struct semaphore ips_sem;
2289  short beacon_txing;
2291  short wap_set;
2292  short ssid_set;
2293 
2294  /* set on initialization */
2296  unsigned int wmm_acm;
2297 
2298  /* for discarding duplicated packets in IBSS */
2300 
2301  /* for discarding duplicated packets in BSS */
2302  u16 last_rxseq_num[17]; /* rx seq previous per-tid */
2303  u16 last_rxfrag_num[17];/* tx frag previous per-tid */
2304  unsigned long last_packet_time[17];
2305 
2306  /* for PS mode */
2307  unsigned long last_rx_ps_time;
2309  u8 LPSDelayCnt;
2310 
2311  /* used if IEEE_SOFTMAC_SINGLE_QUEUE is set */
2315 #define RTLLIB_QUEUE_LIMIT 128
2317  unsigned int hw_header;
2324  bool bibsscoordinator;
2329  u8 CTSToSelfTH;
2334  bool bfsync_enable;
2342  bool FwRWRF;
2348 
2349  /* used if IEEE_SOFTMAC_TX_QUEUE is set */
2350  struct tx_pending tx_pending;
2351 
2352  /* used if IEEE_SOFTMAC_ASSOCIATE is set */
2353  struct timer_list associate_timer;
2354 
2355  /* used if IEEE_SOFTMAC_BEACONS is set */
2370  struct workqueue_struct *wq;
2371  union {
2375  struct {
2379  };
2380  };
2381 
2382  /* Callback functions */
2383  void (*set_security)(struct net_device *dev,
2384  struct rtllib_security *sec);
2385 
2386  /* Used to TX data frame by using txb structs.
2387  * this is not used if in the softmac_features
2388  * is set the flag IEEE_SOFTMAC_TX_QUEUE
2389  */
2390  int (*hard_start_xmit)(struct rtllib_txb *txb,
2391  struct net_device *dev);
2394  int (*is_queue_full)(struct net_device *dev, int pri);
2396  int (*handle_management)(struct net_device *dev,
2397  struct rtllib_network *network, u16 type);
2398  int (*is_qos_active)(struct net_device *dev, struct sk_buff *skb);
2399 
2400  /* Softmac-generated frames (management) are TXed via this
2401  * callback if the flag IEEE_SOFTMAC_SINGLE_QUEUE is
2402  * not set. As some cards may have different HW queues that
2403  * one might want to use for data and management frames
2404  * the option to have two callbacks might be useful.
2405  * This function can't sleep.
2406  */
2408  struct net_device *dev);
2409 
2410  /* used instead of hard_start_xmit (not softmac_hard_start_xmit)
2411  * if the IEEE_SOFTMAC_TX_QUEUE feature is used to TX data
2412  * frames. If the option IEEE_SOFTMAC_SINGLE_QUEUE is also set
2413  * then also management frames are sent via this callback.
2414  * This function can't sleep.
2415  */
2417  struct net_device *dev, int rate);
2418 
2419  /* stops the HW queue for DATA frames. Useful to avoid
2420  * waste time to TX data frame when we are reassociating
2421  * This function can sleep.
2422  */
2423  void (*data_hard_stop)(struct net_device *dev);
2424 
2425  /* OK this is complementing to data_poll_hard_stop */
2426  void (*data_hard_resume)(struct net_device *dev);
2427 
2428  /* ask to the driver to retune the radio .
2429  * This function can sleep. the driver should ensure
2430  * the radio has been switched before return.
2431  */
2432  void (*set_chan)(struct net_device *dev, short ch);
2433 
2434  /* These are not used if the ieee stack takes care of
2435  * scanning (IEEE_SOFTMAC_SCAN feature set).
2436  * In this case only the set_chan is used.
2437  *
2438  * The syncro version is similar to the start_scan but
2439  * does not return until all channels has been scanned.
2440  * this is called in user context and should sleep,
2441  * it is called in a work_queue when switching to ad-hoc mode
2442  * or in behalf of iwlist scan when the card is associated
2443  * and root user ask for a scan.
2444  * the function stop_scan should stop both the syncro and
2445  * background scanning and can sleep.
2446  * The function start_scan should initiate the background
2447  * scanning and can't sleep.
2448  */
2451  void (*stop_scan)(struct net_device *dev);
2454  void (*rtllib_stop_hw_scan)(struct net_device *dev);
2455 
2456  /* indicate the driver that the link state is changed
2457  * for example it may indicate the card is associated now.
2458  * Driver might be interested in this to apply RX filter
2459  * rules or simply light the LINK led
2460  */
2461  void (*link_change)(struct net_device *dev);
2462 
2463  /* these two function indicates to the HW when to start
2464  * and stop to send beacons. This is used when the
2465  * IEEE_SOFTMAC_BEACONS is not set. For now the
2466  * stop_send_bacons is NOT guaranteed to be called only
2467  * after start_send_beacons.
2468  */
2470  void (*stop_send_beacons)(struct net_device *dev);
2471 
2472  /* power save mode related */
2476  int (*handle_beacon)(struct net_device *dev,
2477  struct rtllib_beacon *beacon,
2478  struct rtllib_network *network);
2481  struct rtllib_network *network);
2482 
2483 
2484  /* check whether Tx hw resource available */
2487  void (*SetBWModeHandler)(struct net_device *dev,
2488  enum ht_channel_width Bandwidth,
2489  enum ht_extchnl_offset Offset);
2494  void (*HalUsbRxAggrHandler)(struct net_device *dev, bool Value);
2495  void (*InitialGainHandler)(struct net_device *dev, u8 Operation);
2496  bool (*SetFwCmdHandler)(struct net_device *dev,
2497  enum fw_cmd_io_type FwCmdIO);
2498  void (*UpdateHalRAMaskHandler)(struct net_device *dev, bool bMulticast,
2499  u8 macId, u8 MimoPs, u8 WirelessMode,
2500  u8 bCurTxBW40MHz, u8 rssi_level);
2502  bool start);
2503  void (*UpdateInterruptMaskHandler)(struct net_device *dev, u32 AddMSR,
2504  u32 RemoveMSR);
2507  u8 Operation);
2508  void (*LedControlHandler)(struct net_device *dev,
2509  enum led_ctl_mode LedAction);
2514  bool bAllowAllDA, bool WriteIntoReg);
2519  void (*rtllib_rfkill_poll)(struct net_device *dev);
2520 
2521  /* This must be the last item so that it points to the data
2522  * allocated beyond this structure by alloc_rtllib */
2523  u8 priv[0];
2524 };
2526 #define IEEE_A (1<<0)
2527 #define IEEE_B (1<<1)
2528 #define IEEE_G (1<<2)
2529 #define IEEE_N_24G (1<<4)
2530 #define IEEE_N_5G (1<<5)
2531 #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
2532 
2533 /* Generate a 802.11 header */
2534 
2535 /* Uses the channel change callback directly
2536  * instead of [start/stop] scan callbacks
2537  */
2538 #define IEEE_SOFTMAC_SCAN (1<<2)
2539 
2540 /* Perform authentication and association handshake */
2541 #define IEEE_SOFTMAC_ASSOCIATE (1<<3)
2542 
2543 /* Generate probe requests */
2544 #define IEEE_SOFTMAC_PROBERQ (1<<4)
2545 
2546 /* Generate response to probe requests */
2547 #define IEEE_SOFTMAC_PROBERS (1<<5)
2548 
2549 /* The ieee802.11 stack will manage the netif queue
2550  * wake/stop for the driver, taking care of 802.11
2551  * fragmentation. See softmac.c for details. */
2552 #define IEEE_SOFTMAC_TX_QUEUE (1<<7)
2553 
2554 /* Uses only the softmac_data_hard_start_xmit
2555  * even for TX management frames.
2556  */
2557 #define IEEE_SOFTMAC_SINGLE_QUEUE (1<<8)
2558 
2559 /* Generate beacons. The stack will enqueue beacons
2560  * to the card
2561  */
2562 #define IEEE_SOFTMAC_BEACONS (1<<6)
2563 
2564 
2565 static inline void *rtllib_priv(struct net_device *dev)
2566 {
2567  return ((struct rtllib_device *)netdev_priv(dev))->priv;
2568 }
2570 extern inline int rtllib_is_empty_essid(const char *essid, int essid_len)
2571 {
2572  /* Single white space is for Linksys APs */
2573  if (essid_len == 1 && essid[0] == ' ')
2574  return 1;
2575 
2576  /* Otherwise, if the entire essid is 0, we assume it is hidden */
2577  while (essid_len) {
2578  essid_len--;
2579  if (essid[essid_len] != '\0')
2580  return 0;
2581  }
2582 
2583  return 1;
2584 }
2586 extern inline int rtllib_is_valid_mode(struct rtllib_device *ieee, int mode)
2587 {
2588  /*
2589  * It is possible for both access points and our device to support
2590  * combinations of modes, so as long as there is one valid combination
2591  * of ap/device supported modes, then return success
2592  *
2593  */
2594  if ((mode & IEEE_A) &&
2595  (ieee->modulation & RTLLIB_OFDM_MODULATION) &&
2596  (ieee->freq_band & RTLLIB_52GHZ_BAND))
2597  return 1;
2598 
2599  if ((mode & IEEE_G) &&
2600  (ieee->modulation & RTLLIB_OFDM_MODULATION) &&
2601  (ieee->freq_band & RTLLIB_24GHZ_BAND))
2602  return 1;
2603 
2604  if ((mode & IEEE_B) &&
2605  (ieee->modulation & RTLLIB_CCK_MODULATION) &&
2606  (ieee->freq_band & RTLLIB_24GHZ_BAND))
2607  return 1;
2608 
2609  return 0;
2610 }
2612 extern inline int rtllib_get_hdrlen(u16 fc)
2613 {
2614  int hdrlen = RTLLIB_3ADDR_LEN;
2615 
2616  switch (WLAN_FC_GET_TYPE(fc)) {
2617  case RTLLIB_FTYPE_DATA:
2618  if ((fc & RTLLIB_FCTL_FROMDS) && (fc & RTLLIB_FCTL_TODS))
2619  hdrlen = RTLLIB_4ADDR_LEN; /* Addr4 */
2620  if (RTLLIB_QOS_HAS_SEQ(fc))
2621  hdrlen += 2; /* QOS ctrl*/
2622  break;
2623  case RTLLIB_FTYPE_CTL:
2624  switch (WLAN_FC_GET_STYPE(fc)) {
2625  case RTLLIB_STYPE_CTS:
2626  case RTLLIB_STYPE_ACK:
2627  hdrlen = RTLLIB_1ADDR_LEN;
2628  break;
2629  default:
2630  hdrlen = RTLLIB_2ADDR_LEN;
2631  break;
2632  }
2633  break;
2634  }
2635 
2636  return hdrlen;
2637 }
2638 
2639 static inline u8 *rtllib_get_payload(struct rtllib_hdr *hdr)
2640 {
2641  switch (rtllib_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) {
2642  case RTLLIB_1ADDR_LEN:
2643  return ((struct rtllib_hdr_1addr *)hdr)->payload;
2644  case RTLLIB_2ADDR_LEN:
2645  return ((struct rtllib_hdr_2addr *)hdr)->payload;
2646  case RTLLIB_3ADDR_LEN:
2647  return ((struct rtllib_hdr_3addr *)hdr)->payload;
2648  case RTLLIB_4ADDR_LEN:
2649  return ((struct rtllib_hdr_4addr *)hdr)->payload;
2650  }
2651  return NULL;
2652 }
2653 
2654 static inline int rtllib_is_ofdm_rate(u8 rate)
2655 {
2656  switch (rate & ~RTLLIB_BASIC_RATE_MASK) {
2657  case RTLLIB_OFDM_RATE_6MB:
2658  case RTLLIB_OFDM_RATE_9MB:
2659  case RTLLIB_OFDM_RATE_12MB:
2660  case RTLLIB_OFDM_RATE_18MB:
2661  case RTLLIB_OFDM_RATE_24MB:
2662  case RTLLIB_OFDM_RATE_36MB:
2663  case RTLLIB_OFDM_RATE_48MB:
2664  case RTLLIB_OFDM_RATE_54MB:
2665  return 1;
2666  }
2667  return 0;
2668 }
2669 
2670 static inline int rtllib_is_cck_rate(u8 rate)
2671 {
2672  switch (rate & ~RTLLIB_BASIC_RATE_MASK) {
2673  case RTLLIB_CCK_RATE_1MB:
2674  case RTLLIB_CCK_RATE_2MB:
2675  case RTLLIB_CCK_RATE_5MB:
2676  case RTLLIB_CCK_RATE_11MB:
2677  return 1;
2678  }
2679  return 0;
2680 }
2681 
2682 
2683 /* rtllib.c */
2684 extern void free_rtllib(struct net_device *dev);
2685 extern struct net_device *alloc_rtllib(int sizeof_priv);
2686 
2687 extern int rtllib_set_encryption(struct rtllib_device *ieee);
2688 
2689 /* rtllib_tx.c */
2690 
2691 extern int rtllib_encrypt_fragment(
2692  struct rtllib_device *ieee,
2693  struct sk_buff *frag,
2694  int hdr_len);
2695 
2696 extern int rtllib_xmit(struct sk_buff *skb, struct net_device *dev);
2697 extern int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev);
2698 extern void rtllib_txb_free(struct rtllib_txb *);
2699 
2700 /* rtllib_rx.c */
2701 extern int rtllib_rx(struct rtllib_device *ieee, struct sk_buff *skb,
2702  struct rtllib_rx_stats *rx_stats);
2703 extern void rtllib_rx_mgt(struct rtllib_device *ieee,
2704  struct sk_buff *skb,
2705  struct rtllib_rx_stats *stats);
2706 extern void rtllib_rx_probe_rq(struct rtllib_device *ieee,
2707  struct sk_buff *skb);
2708 extern int rtllib_legal_channel(struct rtllib_device *rtllib, u8 channel);
2709 
2710 /* rtllib_wx.c */
2711 extern int rtllib_wx_get_scan(struct rtllib_device *ieee,
2712  struct iw_request_info *info,
2713  union iwreq_data *wrqu, char *key);
2714 extern int rtllib_wx_set_encode(struct rtllib_device *ieee,
2715  struct iw_request_info *info,
2716  union iwreq_data *wrqu, char *key);
2717 extern int rtllib_wx_get_encode(struct rtllib_device *ieee,
2718  struct iw_request_info *info,
2719  union iwreq_data *wrqu, char *key);
2720 #if WIRELESS_EXT >= 18
2721 extern int rtllib_wx_get_encode_ext(struct rtllib_device *ieee,
2722  struct iw_request_info *info,
2723  union iwreq_data *wrqu, char *extra);
2724 extern int rtllib_wx_set_encode_ext(struct rtllib_device *ieee,
2725  struct iw_request_info *info,
2726  union iwreq_data *wrqu, char *extra);
2727 #endif
2728 extern int rtllib_wx_set_auth(struct rtllib_device *ieee,
2729  struct iw_request_info *info,
2730  struct iw_param *data, char *extra);
2731 extern int rtllib_wx_set_mlme(struct rtllib_device *ieee,
2732  struct iw_request_info *info,
2733  union iwreq_data *wrqu, char *extra);
2734 extern int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len);
2735 
2736 /* rtllib_softmac.c */
2737 extern short rtllib_is_54g(struct rtllib_network *net);
2738 extern short rtllib_is_shortslot(const struct rtllib_network *net);
2739 extern int rtllib_rx_frame_softmac(struct rtllib_device *ieee,
2740  struct sk_buff *skb,
2741  struct rtllib_rx_stats *rx_stats, u16 type,
2742  u16 stype);
2743 extern void rtllib_softmac_new_net(struct rtllib_device *ieee,
2744  struct rtllib_network *net);
2745 
2746 void SendDisassociation(struct rtllib_device *ieee, bool deauth, u16 asRsn);
2747 extern void rtllib_softmac_xmit(struct rtllib_txb *txb,
2748  struct rtllib_device *ieee);
2749 
2750 extern void rtllib_stop_send_beacons(struct rtllib_device *ieee);
2751 extern void notify_wx_assoc_event(struct rtllib_device *ieee);
2752 extern void rtllib_softmac_check_all_nets(struct rtllib_device *ieee);
2753 extern void rtllib_start_bss(struct rtllib_device *ieee);
2754 extern void rtllib_start_master_bss(struct rtllib_device *ieee);
2755 extern void rtllib_start_ibss(struct rtllib_device *ieee);
2756 extern void rtllib_softmac_init(struct rtllib_device *ieee);
2757 extern void rtllib_softmac_free(struct rtllib_device *ieee);
2758 extern void rtllib_associate_abort(struct rtllib_device *ieee);
2759 extern void rtllib_disassociate(struct rtllib_device *ieee);
2760 extern void rtllib_stop_scan(struct rtllib_device *ieee);
2761 extern bool rtllib_act_scanning(struct rtllib_device *ieee, bool sync_scan);
2762 extern void rtllib_stop_scan_syncro(struct rtllib_device *ieee);
2763 extern void rtllib_start_scan_syncro(struct rtllib_device *ieee, u8 is_mesh);
2764 extern inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee);
2765 extern u8 MgntQuery_MgntFrameTxRate(struct rtllib_device *ieee);
2766 extern void rtllib_sta_ps_send_null_frame(struct rtllib_device *ieee,
2767  short pwr);
2768 extern void rtllib_sta_wakeup(struct rtllib_device *ieee, short nl);
2769 extern void rtllib_sta_ps_send_pspoll_frame(struct rtllib_device *ieee);
2770 extern void rtllib_check_all_nets(struct rtllib_device *ieee);
2771 extern void rtllib_start_protocol(struct rtllib_device *ieee);
2772 extern void rtllib_stop_protocol(struct rtllib_device *ieee, u8 shutdown);
2773 
2774 extern void rtllib_EnableNetMonitorMode(struct net_device *dev,
2775  bool bInitState);
2776 extern void rtllib_DisableNetMonitorMode(struct net_device *dev,
2777  bool bInitState);
2779  bool bInitState);
2781  bool bInitState);
2782 extern void rtllib_send_probe_requests(struct rtllib_device *ieee, u8 is_mesh);
2783 
2784 extern void rtllib_softmac_stop_protocol(struct rtllib_device *ieee,
2785  u8 mesh_flag, u8 shutdown);
2786 extern void rtllib_softmac_start_protocol(struct rtllib_device *ieee,
2787  u8 mesh_flag);
2788 
2789 extern void rtllib_reset_queue(struct rtllib_device *ieee);
2790 extern void rtllib_wake_queue(struct rtllib_device *ieee);
2791 extern void rtllib_stop_queue(struct rtllib_device *ieee);
2792 extern void rtllib_wake_all_queues(struct rtllib_device *ieee);
2793 extern void rtllib_stop_all_queues(struct rtllib_device *ieee);
2794 extern struct sk_buff *rtllib_get_beacon(struct rtllib_device *ieee);
2795 extern void rtllib_start_send_beacons(struct rtllib_device *ieee);
2796 extern void rtllib_stop_send_beacons(struct rtllib_device *ieee);
2797 extern int rtllib_wpa_supplicant_ioctl(struct rtllib_device *ieee,
2798  struct iw_point *p, u8 is_mesh);
2799 
2800 extern void notify_wx_assoc_event(struct rtllib_device *ieee);
2801 extern void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success);
2802 
2803 extern void softmac_mgmt_xmit(struct sk_buff *skb,
2804  struct rtllib_device *ieee);
2805 extern u16 rtllib_query_seqnum(struct rtllib_device *ieee,
2806  struct sk_buff *skb, u8 *dst);
2807 extern u8 rtllib_ap_sec_type(struct rtllib_device *ieee);
2808 
2809 /* rtllib_crypt_ccmp&tkip&wep.c */
2810 extern void rtllib_tkip_null(void);
2811 extern void rtllib_wep_null(void);
2812 extern void rtllib_ccmp_null(void);
2813 
2814 /* rtllib_softmac_wx.c */
2815 
2816 extern int rtllib_wx_get_wap(struct rtllib_device *ieee,
2817  struct iw_request_info *info,
2818  union iwreq_data *wrqu, char *ext);
2819 
2820 extern int rtllib_wx_set_wap(struct rtllib_device *ieee,
2821  struct iw_request_info *info,
2822  union iwreq_data *awrq,
2823  char *extra);
2824 
2825 extern int rtllib_wx_get_essid(struct rtllib_device *ieee,
2826  struct iw_request_info *a,
2827  union iwreq_data *wrqu, char *b);
2828 
2829 extern int rtllib_wx_set_rate(struct rtllib_device *ieee,
2830  struct iw_request_info *info,
2831  union iwreq_data *wrqu, char *extra);
2832 
2833 extern int rtllib_wx_get_rate(struct rtllib_device *ieee,
2834  struct iw_request_info *info,
2835  union iwreq_data *wrqu, char *extra);
2836 
2837 extern int rtllib_wx_set_mode(struct rtllib_device *ieee,
2838  struct iw_request_info *a,
2839  union iwreq_data *wrqu, char *b);
2840 
2841 extern int rtllib_wx_set_scan(struct rtllib_device *ieee,
2842  struct iw_request_info *a,
2843  union iwreq_data *wrqu, char *b);
2844 
2845 extern int rtllib_wx_set_essid(struct rtllib_device *ieee,
2846  struct iw_request_info *a,
2847  union iwreq_data *wrqu, char *extra);
2848 
2849 extern int rtllib_wx_get_mode(struct rtllib_device *ieee,
2850  struct iw_request_info *a,
2851  union iwreq_data *wrqu, char *b);
2852 
2853 extern int rtllib_wx_set_freq(struct rtllib_device *ieee,
2854  struct iw_request_info *a,
2855  union iwreq_data *wrqu, char *b);
2856 
2857 extern int rtllib_wx_get_freq(struct rtllib_device *ieee,
2858  struct iw_request_info *a,
2859  union iwreq_data *wrqu, char *b);
2860 extern void rtllib_wx_sync_scan_wq(void *data);
2861 
2862 extern int rtllib_wx_set_rawtx(struct rtllib_device *ieee,
2863  struct iw_request_info *info,
2864  union iwreq_data *wrqu, char *extra);
2865 
2866 extern int rtllib_wx_get_name(struct rtllib_device *ieee,
2867  struct iw_request_info *info,
2868  union iwreq_data *wrqu, char *extra);
2869 
2870 extern int rtllib_wx_set_power(struct rtllib_device *ieee,
2871  struct iw_request_info *info,
2872  union iwreq_data *wrqu, char *extra);
2873 
2874 extern int rtllib_wx_get_power(struct rtllib_device *ieee,
2875  struct iw_request_info *info,
2876  union iwreq_data *wrqu, char *extra);
2877 
2878 extern int rtllib_wx_set_rts(struct rtllib_device *ieee,
2879  struct iw_request_info *info,
2880  union iwreq_data *wrqu, char *extra);
2881 
2882 extern int rtllib_wx_get_rts(struct rtllib_device *ieee,
2883  struct iw_request_info *info,
2884  union iwreq_data *wrqu, char *extra);
2885 #define MAX_RECEIVE_BUFFER_SIZE 9100
2886 extern void HTDebugHTCapability(u8 *CapIE, u8 *TitleString);
2887 extern void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString);
2888 
2889 void HTSetConnectBwMode(struct rtllib_device *ieee,
2890  enum ht_channel_width Bandwidth,
2891  enum ht_extchnl_offset Offset);
2892 extern void HTUpdateDefaultSetting(struct rtllib_device *ieee);
2893 extern void HTConstructCapabilityElement(struct rtllib_device *ieee,
2894  u8 *posHTCap, u8 *len,
2895  u8 isEncrypt, bool bAssoc);
2896 extern void HTConstructInfoElement(struct rtllib_device *ieee,
2897  u8 *posHTInfo, u8 *len, u8 isEncrypt);
2898 extern void HTConstructRT2RTAggElement(struct rtllib_device *ieee,
2899  u8 *posRT2RTAgg, u8* len);
2900 extern void HTOnAssocRsp(struct rtllib_device *ieee);
2901 extern void HTInitializeHTInfo(struct rtllib_device *ieee);
2902 extern void HTInitializeBssDesc(struct bss_ht *pBssHT);
2903 extern void HTResetSelfAndSavePeerSetting(struct rtllib_device *ieee,
2904  struct rtllib_network *pNetwork);
2905 extern void HT_update_self_and_peer_setting(struct rtllib_device *ieee,
2906  struct rtllib_network *pNetwork);
2907 extern u8 HTGetHighestMCSRate(struct rtllib_device *ieee, u8 *pMCSRateSet,
2908  u8 *pMCSFilter);
2909 extern u8 MCS_FILTER_ALL[];
2910 extern u16 MCS_DATA_RATE[2][2][77] ;
2911 extern u8 HTCCheck(struct rtllib_device *ieee, u8 *pFrame);
2912 extern void HTResetIOTSetting(struct rt_hi_throughput *pHTInfo);
2913 extern bool IsHTHalfNmodeAPs(struct rtllib_device *ieee);
2914 extern u16 HTHalfMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate);
2915 extern u16 HTMcsToDataRate(struct rtllib_device *ieee, u8 nMcsRate);
2916 extern u16 TxCountToDataRate(struct rtllib_device *ieee, u8 nDataRate);
2917 extern int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb);
2918 extern int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb);
2919 extern int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb);
2920 extern void TsInitAddBA(struct rtllib_device *ieee, struct tx_ts_record *pTS,
2921  u8 Policy, u8 bOverwritePending);
2922 extern void TsInitDelBA(struct rtllib_device *ieee,
2923  struct ts_common_info *pTsCommonInfo,
2924  enum tr_select TxRxSelect);
2925 extern void BaSetupTimeOut(unsigned long data);
2926 extern void TxBaInactTimeout(unsigned long data);
2927 extern void RxBaInactTimeout(unsigned long data);
2928 extern void ResetBaEntry(struct ba_record *pBA);
2929 extern bool GetTs(
2930  struct rtllib_device *ieee,
2931  struct ts_common_info **ppTS,
2932  u8 *Addr,
2933  u8 TID,
2934  enum tr_select TxRxSelect,
2935  bool bAddNewTs
2936 );
2937 extern void TSInitialize(struct rtllib_device *ieee);
2938 extern void TsStartAddBaProcess(struct rtllib_device *ieee,
2939  struct tx_ts_record *pTxTS);
2940 extern void RemovePeerTS(struct rtllib_device *ieee, u8 *Addr);
2941 extern void RemoveAllTS(struct rtllib_device *ieee);
2942 void rtllib_softmac_scan_syncro(struct rtllib_device *ieee, u8 is_mesh);
2943 
2944 extern const long rtllib_wlan_frequencies[];
2946 extern inline void rtllib_increment_scans(struct rtllib_device *ieee)
2947 {
2948  ieee->scans++;
2949 }
2951 extern inline int rtllib_get_scans(struct rtllib_device *ieee)
2952 {
2953  return ieee->scans;
2954 }
2955 
2956 static inline const char *escape_essid(const char *essid, u8 essid_len)
2957 {
2958  static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
2959  const char *s = essid;
2960  char *d = escaped;
2961 
2962  if (rtllib_is_empty_essid(essid, essid_len)) {
2963  memcpy(escaped, "<hidden>", sizeof("<hidden>"));
2964  return escaped;
2965  }
2966 
2967  essid_len = min(essid_len, (u8)IW_ESSID_MAX_SIZE);
2968  while (essid_len--) {
2969  if (*s == '\0') {
2970  *d++ = '\\';
2971  *d++ = '0';
2972  s++;
2973  } else {
2974  *d++ = *s++;
2975  }
2976  }
2977  *d = '\0';
2978  return escaped;
2979 }
2981 #define CONVERT_RATE(_ieee, _MGN_RATE) \
2982  ((_MGN_RATE < MGN_MCS0) ? (_MGN_RATE) : \
2983  (HTMcsToDataRate(_ieee, (u8)_MGN_RATE)))
2984 
2985 /* fun with the built-in rtllib stack... */
2986 bool rtllib_MgntDisconnect(struct rtllib_device *rtllib, u8 asRsn);
2987 
2988 
2989 /* For the function is more related to hardware setting, it's better to use the
2990  * ieee handler to refer to it.
2991  */
2992 extern void rtllib_update_active_chan_map(struct rtllib_device *ieee);
2993 extern void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee,
2994  struct rx_ts_record *pTS);
2995 extern int rtllib_data_xmit(struct sk_buff *skb, struct net_device *dev);
2996 extern int rtllib_parse_info_param(struct rtllib_device *ieee,
2998  u16 length,
2999  struct rtllib_network *network,
3000  struct rtllib_rx_stats *stats);
3001 
3002 void rtllib_indicate_packets(struct rtllib_device *ieee,
3003  struct rtllib_rxb **prxbIndicateArray, u8 index);
3004 extern u8 HTFilterMCSRate(struct rtllib_device *ieee, u8 *pSupportMCS,
3005  u8 *pOperateMCS);
3006 extern void HTUseDefaultSetting(struct rtllib_device *ieee);
3007 #define RT_ASOC_RETRY_LIMIT 5
3009 extern void rtllib_TURBO_Info(struct rtllib_device *ieee, u8 **tag_p);
3010 #ifndef ENABLE_LOCK_DEBUG
3011 #define SPIN_LOCK_IEEE(plock) spin_lock_irqsave((plock), flags)
3012 #define SPIN_UNLOCK_IEEE(plock) spin_unlock_irqrestore((plock), flags)
3013 #define SPIN_LOCK_IEEE_REORDER(plock) spin_lock_irqsave((plock), flags)
3014 #define SPIN_UNLOCK_IEEE_REORDER(plock) spin_unlock_irqrestore((plock), flags)
3015 #define SPIN_LOCK_IEEE_WPAX(plock) spin_lock_irqsave((plock), flags)
3016 #define SPIN_UNLOCK_IEEE_WPAX(plock) spin_unlock_irqrestore((plock), flags)
3017 #define SPIN_LOCK_IEEE_MGNTTX(plock) spin_lock_irqsave((plock), flags)
3018 #define SPIN_UNLOCK_IEEE_MGNTTX(plock) spin_unlock_irqrestore((plock), flags)
3019 #define SPIN_LOCK_IEEE_BCN(plock) spin_lock_irqsave((plock), flags)
3020 #define SPIN_UNLOCK_IEEE_BCN(plock) spin_unlock_irqrestore((plock), flags)
3021 #define SPIN_LOCK_MSH_STAINFO(plock) spin_lock_irqsave((plock), flags)
3022 #define SPIN_UNLOCK_MSH_STAINFO(plock) spin_unlock_irqrestore((plock), flags)
3023 #define SPIN_LOCK_MSH_PREQ(plock) spin_lock_irqsave((plock), flags)
3024 #define SPIN_UNLOCK_MSH_PREQ(plock) spin_unlock_irqrestore((plock), flags)
3025 #define SPIN_LOCK_MSH_QUEUE(plock) spin_lock_irqsave((plock), flags)
3026 #define SPIN_UNLOCK_MSH_QUEUE(plock) spin_unlock_irqrestore((plock), flags)
3027 #define SPIN_LOCK_PRIV_RFPS(plock) spin_lock_irqsave((plock), flags)
3028 #define SPIN_UNLOCK_PRIV_RFPS(plock) spin_unlock_irqrestore((plock), flags)
3029 #define SPIN_LOCK_PRIV_IRQTH(plock) spin_lock_irqsave((plock), flags)
3030 #define SPIN_UNLOCK_PRIV_IRQTH(plock) spin_unlock_irqrestore((plock), flags)
3031 #define SPIN_LOCK_PRIV_TX(plock) spin_lock_irqsave((plock), flags)
3032 #define SPIN_UNLOCK_PRIV_TX(plock) spin_unlock_irqrestore((plock), flags)
3033 #define SPIN_LOCK_PRIV_D3(plock) spin_lock_irqsave((plock), flags)
3034 #define SPIN_UNLOCK_PRIV_D3(plock) spin_unlock_irqrestore((plock), flags)
3035 #define SPIN_LOCK_PRIV_RF(plock) spin_lock_irqsave((plock), flags)
3036 #define SPIN_UNLOCK_PRIV_RF(plock) spin_unlock_irqrestore((plock), flags)
3037 #define SPIN_LOCK_PRIV_PS(plock) spin_lock_irqsave((plock), flags)
3038 #define SPIN_UNLOCK_PRIV_PS(plock) spin_unlock_irqrestore((plock), flags)
3039 #define SEM_DOWN_IEEE_WX(psem) down(psem)
3040 #define SEM_UP_IEEE_WX(psem) up(psem)
3041 #define SEM_DOWN_IEEE_SCAN(psem) down(psem)
3042 #define SEM_UP_IEEE_SCAN(psem) up(psem)
3043 #define SEM_DOWN_IEEE_IPS(psem) down(psem)
3044 #define SEM_UP_IEEE_IPS(psem) up(psem)
3045 #define SEM_DOWN_PRIV_WX(psem) down(psem)
3046 #define SEM_UP_PRIV_WX(psem) up(psem)
3047 #define SEM_DOWN_PRIV_RF(psem) down(psem)
3048 #define SEM_UP_PRIV_RF(psem) up(psem)
3049 #define MUTEX_LOCK_PRIV(pmutex) mutex_lock(pmutex)
3050 #define MUTEX_UNLOCK_PRIV(pmutex) mutex_unlock(pmutex)
3051 #endif
3052 
3053 #endif /* RTLLIB_H */