2 * This is part of rtl8187 OpenSource driver.
3 * Copyright (C) Andrea Merello 2004-2005 <andrea.merello@gmail.com>
4 * Released under the terms of GPL (General Public Licence)
6 * Parts of this driver are based on the GPL part of the
7 * official realtek driver
9 * Parts of this driver are based on the rtl8192 driver skeleton
10 * from Patric Schenke & Andres Salomon
12 * Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver
14 * We want to thank the Authors of those projects and the Ndiswrapper
21 #include <linux/module.h>
22 #include <linux/kernel.h>
23 #include <linux/ioport.h>
24 #include <linux/sched.h>
25 #include <linux/types.h>
26 #include <linux/slab.h>
27 #include <linux/netdevice.h>
28 #include <linux/usb.h>
29 #include <linux/etherdevice.h>
30 #include <linux/delay.h>
31 #include <linux/rtnetlink.h>
32 #include <linux/wireless.h>
33 #include <linux/timer.h>
34 #include <linux/proc_fs.h>
35 #include <linux/if_arp.h>
36 #include <linux/random.h>
38 #include "ieee80211/ieee80211.h"
41 #define RTL819xU_MODULE_NAME "rtl819xU"
43 #define MAX_KEY_LEN 61
44 #define KEY_BUF_SIZE 5
46 #define BIT0 0x00000001
47 #define BIT1 0x00000002
48 #define BIT2 0x00000004
49 #define BIT3 0x00000008
50 #define BIT4 0x00000010
51 #define BIT5 0x00000020
52 #define BIT6 0x00000040
53 #define BIT7 0x00000080
54 #define BIT8 0x00000100
55 #define BIT9 0x00000200
56 #define BIT10 0x00000400
57 #define BIT11 0x00000800
58 #define BIT12 0x00001000
59 #define BIT13 0x00002000
60 #define BIT14 0x00004000
61 #define BIT15 0x00008000
62 #define BIT16 0x00010000
63 #define BIT17 0x00020000
64 #define BIT18 0x00040000
65 #define BIT19 0x00080000
66 #define BIT20 0x00100000
67 #define BIT21 0x00200000
68 #define BIT22 0x00400000
69 #define BIT23 0x00800000
70 #define BIT24 0x01000000
71 #define BIT25 0x02000000
72 #define BIT26 0x04000000
73 #define BIT27 0x08000000
74 #define BIT28 0x10000000
75 #define BIT29 0x20000000
76 #define BIT30 0x40000000
77 #define BIT31 0x80000000
79 #define Rx_Smooth_Factor 20
80 #define DMESG(x, a...)
81 #define DMESGW(x, a...)
82 #define DMESGE(x, a...)
83 extern u32 rt_global_debug_component
;
84 #define RT_TRACE(component, x, args...) \
86 if (rt_global_debug_component & component) \
87 pr_debug("RTL8192U: " x "\n", ##args); \
90 #define COMP_TRACE BIT0 /* Function call tracing. */
92 #define COMP_INIT BIT2 /* Driver initialization/halt/reset. */
95 #define COMP_RECV BIT3 /* Receive data path. */
96 #define COMP_SEND BIT4 /* Send data path. */
98 /* 802.11 Power Save mode or System/Device Power state. */
99 #define COMP_POWER BIT6
100 /* 802.11 link related: join/start BSS, leave BSS. */
101 #define COMP_EPROM BIT7
102 #define COMP_SWBW BIT8 /* Bandwidth switch. */
103 #define COMP_POWER_TRACKING BIT9 /* 8190 TX Power Tracking */
104 #define COMP_TURBO BIT10 /* Turbo Mode */
105 #define COMP_QOS BIT11
106 #define COMP_RATE BIT12 /* Rate Adaptive mechanism */
107 #define COMP_RM BIT13 /* Radio Measurement */
108 #define COMP_DIG BIT14
109 #define COMP_PHY BIT15
110 #define COMP_CH BIT16 /* Channel setting debug */
111 #define COMP_TXAGC BIT17 /* Tx power */
112 #define COMP_HIPWR BIT18 /* High Power Mechanism */
113 #define COMP_HALDM BIT19 /* HW Dynamic Mechanism */
114 #define COMP_SEC BIT20 /* Event handling */
115 #define COMP_LED BIT21
116 #define COMP_RF BIT22
117 #define COMP_RXDESC BIT23 /* Rx desc information for SD3 debug */
119 /* 11n or 8190 specific code */
121 #define COMP_FIRMWARE BIT24 /* Firmware downloading */
122 #define COMP_HT BIT25 /* 802.11n HT related information */
123 #define COMP_AMSDU BIT26 /* A-MSDU Debugging */
124 #define COMP_SCAN BIT27
125 #define COMP_DOWN BIT29 /* rm driver module */
126 #define COMP_RESET BIT30 /* Silent reset */
127 #define COMP_ERR BIT31 /* Error out, always on */
129 #define RTL819x_DEBUG
131 #define RTL8192U_ASSERT(expr) \
134 pr_debug("Assertion failed! %s, %s, %s, line = %d\n", \
135 #expr, __FILE__, __func__, __LINE__); \
139 * Debug out data buf.
140 * If you want to print DATA buffer related BA,
141 * please set ieee80211_debug_level to DATA|BA
143 #define RT_DEBUG_DATA(level, data, datalen) \
145 if ((rt_global_debug_component & (level)) == (level)) { \
147 u8 *pdata = (u8 *) data; \
148 pr_debug("RTL8192U: %s()\n", __func__); \
149 for (i = 0; i < (int)(datalen); i++) { \
150 printk("%2x ", pdata[i]); \
158 #define RTL8192U_ASSERT(expr) do {} while (0)
159 #define RT_DEBUG_DATA(level, data, datalen) do {} while (0)
160 #endif /* RTL8169_DEBUG */
163 /* Queue Select Value in TxDesc */
168 #define QSLT_BEACON 0x10
169 #define QSLT_HIGH 0x11
170 #define QSLT_MGNT 0x12
171 #define QSLT_CMD 0x13
173 #define DESC90_RATE1M 0x00
174 #define DESC90_RATE2M 0x01
175 #define DESC90_RATE5_5M 0x02
176 #define DESC90_RATE11M 0x03
177 #define DESC90_RATE6M 0x04
178 #define DESC90_RATE9M 0x05
179 #define DESC90_RATE12M 0x06
180 #define DESC90_RATE18M 0x07
181 #define DESC90_RATE24M 0x08
182 #define DESC90_RATE36M 0x09
183 #define DESC90_RATE48M 0x0a
184 #define DESC90_RATE54M 0x0b
185 #define DESC90_RATEMCS0 0x00
186 #define DESC90_RATEMCS1 0x01
187 #define DESC90_RATEMCS2 0x02
188 #define DESC90_RATEMCS3 0x03
189 #define DESC90_RATEMCS4 0x04
190 #define DESC90_RATEMCS5 0x05
191 #define DESC90_RATEMCS6 0x06
192 #define DESC90_RATEMCS7 0x07
193 #define DESC90_RATEMCS8 0x08
194 #define DESC90_RATEMCS9 0x09
195 #define DESC90_RATEMCS10 0x0a
196 #define DESC90_RATEMCS11 0x0b
197 #define DESC90_RATEMCS12 0x0c
198 #define DESC90_RATEMCS13 0x0d
199 #define DESC90_RATEMCS14 0x0e
200 #define DESC90_RATEMCS15 0x0f
201 #define DESC90_RATEMCS32 0x20
203 #define RTL819X_DEFAULT_RF_TYPE RF_1T2R
205 #define IEEE80211_WATCH_DOG_TIME 2000
206 #define PHY_Beacon_RSSI_SLID_WIN_MAX 10
207 /* For Tx Power Tracking */
208 #define OFDM_Table_Length 19
209 #define CCK_Table_length 12
212 typedef struct _tx_desc_819x_usb
{
240 u8 ResvForPaddingLen
:7;
248 } tx_desc_819x_usb
, *ptx_desc_819x_usb
;
250 #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
251 typedef struct _tx_desc_819x_usb_aggr_subframe
{
272 } tx_desc_819x_usb_aggr_subframe
, *ptx_desc_819x_usb_aggr_subframe
;
277 typedef struct _tx_desc_cmd_819x_usb
{
302 } tx_desc_cmd_819x_usb
, *ptx_desc_cmd_819x_usb
;
305 typedef struct _tx_fwinfo_819x_usb
{
312 u8 Short
:1; /* Error out, always on */
313 u8 TxBandwidth
:1; /* Used for HT MCS rate only */
314 u8 TxSubCarrier
:2; /* Used for legacy OFDM rate only */
316 u8 AllowAggregation
:1;
317 /* Interpret RtsRate field as high throughput data rate */
319 u8 RtsShort
:1; /* Short PLCP for CCK or short GI for 11n MCS */
320 u8 RtsBandwidth
:1; /* Used for HT MCS rate only */
321 u8 RtsSubcarrier
:2;/* Used for legacy OFDM rate only */
323 /* Enable firmware to recalculate and assign packet duration */
329 /* 1 indicate Tx info gathered by firmware and returned by Rx Cmd */
330 u32 TxPerPktInfoFeedback
:1;
336 } tx_fwinfo_819x_usb
, *ptx_fwinfo_819x_usb
;
338 typedef struct rtl8192_rx_info
{
340 struct net_device
*dev
;
344 typedef struct rx_desc_819x_usb
{
357 } rx_desc_819x_usb
, *prx_desc_819x_usb
;
359 #ifdef USB_RX_AGGREGATION_SUPPORT
360 typedef struct _rx_desc_819x_usb_aggr_subframe
{
374 } rx_desc_819x_usb_aggr_subframe
, *prx_desc_819x_usb_aggr_subframe
;
377 typedef struct rx_drvinfo_819x_usb
{
398 } rx_drvinfo_819x_usb
, *prx_drvinfo_819x_usb
;
400 /* Support till 64 bit bus width OS */
401 #define MAX_DEV_ADDR_SIZE 8
403 #define MAX_FIRMWARE_INFORMATION_SIZE 32
404 #define MAX_802_11_HEADER_LENGTH (40 + MAX_FIRMWARE_INFORMATION_SIZE)
405 #define ENCRYPTION_MAX_OVERHEAD 128
406 #define USB_HWDESC_HEADER_LEN sizeof(tx_desc_819x_usb)
407 #define TX_PACKET_SHIFT_BYTES (USB_HWDESC_HEADER_LEN + sizeof(tx_fwinfo_819x_usb))
408 #define MAX_FRAGMENT_COUNT 8
409 #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
410 #define MAX_TRANSMIT_BUFFER_SIZE 32000
412 #define MAX_TRANSMIT_BUFFER_SIZE 8000
414 #ifdef USB_TX_DRIVER_AGGREGATION_ENABLE
415 #define TX_PACKET_DRVAGGR_SUBFRAME_SHIFT_BYTES (sizeof(tx_desc_819x_usb_aggr_subframe) + sizeof(tx_fwinfo_819x_usb))
417 /* Octets for crc32 (FCS, ICV) */
420 typedef enum rf_optype
{
421 RF_OP_By_SW_3wire
= 0,
425 /* 8190 Loopback Mode definition */
426 typedef enum _rtl819xUsb_loopback
{
427 RTL819xU_NO_LOOPBACK
= 0,
428 RTL819xU_MAC_LOOPBACK
= 1,
429 RTL819xU_DMA_LOOPBACK
= 2,
430 RTL819xU_CCK_LOOPBACK
= 3,
431 } rtl819xUsb_loopback_e
;
433 /* due to rtl8192 firmware */
434 typedef enum _desc_packet_type_e
{
435 DESC_PACKET_TYPE_INIT
= 0,
436 DESC_PACKET_TYPE_NORMAL
= 1,
437 } desc_packet_type_e
;
439 typedef enum _firmware_status
{
440 FW_STATUS_0_INIT
= 0,
441 FW_STATUS_1_MOVE_BOOT_CODE
= 1,
442 FW_STATUS_2_MOVE_MAIN_CODE
= 2,
443 FW_STATUS_3_TURNON_CPU
= 3,
444 FW_STATUS_4_MOVE_DATA_CODE
= 4,
445 FW_STATUS_5_READY
= 5,
448 typedef struct _rt_firmare_seg_container
{
451 } fw_seg_container
, *pfw_seg_container
;
452 typedef struct _rt_firmware
{
453 firmware_status_e firmware_status
;
454 u16 cmdpacket_frag_thresold
;
455 #define RTL8190_MAX_FIRMWARE_CODE_SIZE 64000
456 u8 firmware_buf
[RTL8190_MAX_FIRMWARE_CODE_SIZE
];
457 u16 firmware_buf_size
;
458 } rt_firmware
, *prt_firmware
;
460 /* Add this to 9100 bytes to receive A-MSDU from RT-AP */
461 #define MAX_RECEIVE_BUFFER_SIZE 9100
463 typedef struct _rt_firmware_info_819xUsb
{
465 } rt_firmware_info_819xUsb
, *prt_firmware_info_819xUsb
;
467 /* Firmware Queue Layout */
468 #define NUM_OF_FIRMWARE_QUEUE 10
469 #define NUM_OF_PAGES_IN_FW 0x100
472 #define NUM_OF_PAGE_IN_FW_QUEUE_BE 0x000
473 #define NUM_OF_PAGE_IN_FW_QUEUE_BK 0x000
474 #define NUM_OF_PAGE_IN_FW_QUEUE_VI 0x0ff
475 #define NUM_OF_PAGE_IN_FW_QUEUE_VO 0x000
476 #define NUM_OF_PAGE_IN_FW_QUEUE_HCCA 0
477 #define NUM_OF_PAGE_IN_FW_QUEUE_CMD 0x0
478 #define NUM_OF_PAGE_IN_FW_QUEUE_MGNT 0x00
479 #define NUM_OF_PAGE_IN_FW_QUEUE_HIGH 0
480 #define NUM_OF_PAGE_IN_FW_QUEUE_BCN 0x0
481 #define NUM_OF_PAGE_IN_FW_QUEUE_PUB 0x00
484 #define NUM_OF_PAGE_IN_FW_QUEUE_BE 0x020
485 #define NUM_OF_PAGE_IN_FW_QUEUE_BK 0x020
486 #define NUM_OF_PAGE_IN_FW_QUEUE_VI 0x040
487 #define NUM_OF_PAGE_IN_FW_QUEUE_VO 0x040
488 #define NUM_OF_PAGE_IN_FW_QUEUE_HCCA 0
489 #define NUM_OF_PAGE_IN_FW_QUEUE_CMD 0x4
490 #define NUM_OF_PAGE_IN_FW_QUEUE_MGNT 0x20
491 #define NUM_OF_PAGE_IN_FW_QUEUE_HIGH 0
492 #define NUM_OF_PAGE_IN_FW_QUEUE_BCN 0x4
493 #define NUM_OF_PAGE_IN_FW_QUEUE_PUB 0x18
497 #define APPLIED_RESERVED_QUEUE_IN_FW 0x80000000
498 #define RSVD_FW_QUEUE_PAGE_BK_SHIFT 0x00
499 #define RSVD_FW_QUEUE_PAGE_BE_SHIFT 0x08
500 #define RSVD_FW_QUEUE_PAGE_VI_SHIFT 0x10
501 #define RSVD_FW_QUEUE_PAGE_VO_SHIFT 0x18
502 #define RSVD_FW_QUEUE_PAGE_MGNT_SHIFT 0x10
503 #define RSVD_FW_QUEUE_PAGE_CMD_SHIFT 0x08
504 #define RSVD_FW_QUEUE_PAGE_BCN_SHIFT 0x00
505 #define RSVD_FW_QUEUE_PAGE_PUB_SHIFT 0x08
508 * =================================================================
509 * =================================================================
512 #define EPROM_93c46 0
513 #define EPROM_93c56 1
515 #define DEFAULT_FRAG_THRESHOLD 2342U
516 #define MIN_FRAG_THRESHOLD 256U
517 #define DEFAULT_BEACONINTERVAL 0x64U
518 #define DEFAULT_BEACON_ESSID "Rtl819xU"
520 #define DEFAULT_SSID ""
521 #define DEFAULT_RETRY_RTS 7
522 #define DEFAULT_RETRY_DATA 7
523 #define PRISM_HDR_SIZE 64
525 #define PHY_RSSI_SLID_WIN_MAX 100
528 typedef enum _WIRELESS_MODE
{
529 WIRELESS_MODE_UNKNOWN
= 0x00,
530 WIRELESS_MODE_A
= 0x01,
531 WIRELESS_MODE_B
= 0x02,
532 WIRELESS_MODE_G
= 0x04,
533 WIRELESS_MODE_AUTO
= 0x08,
534 WIRELESS_MODE_N_24G
= 0x10,
535 WIRELESS_MODE_N_5G
= 0x20
539 #define RTL_IOCTL_WPA_SUPPLICANT (SIOCIWFIRSTPRIV + 30)
541 typedef struct buffer
{
547 typedef struct rtl_reg_debug
{
553 unsigned char length
;
555 unsigned char buf
[0xff];
563 typedef struct _rt_9x_tx_rate_history
{
567 } rt_tx_rahis_t
, *prt_tx_rahis_t
;
568 typedef struct _RT_SMOOTH_DATA_4RF
{
569 char elements
[4][100]; /* array to store values */
570 u32 index
; /* index to current array to store */
571 u32 TotalNum
; /* num of valid elements */
572 u32 TotalVal
[4]; /* sum of valid elements */
573 } RT_SMOOTH_DATA_4RF
, *PRT_SMOOTH_DATA_4RF
;
575 /* This maybe changed for D-cut larger aggregation size */
576 #define MAX_8192U_RX_SIZE 8192
577 /* Stats seems messed up, clean it ASAP */
578 typedef struct Stats
{
581 unsigned long rxframgment
;
582 unsigned long rxurberr
;
583 unsigned long rxstaterr
;
584 /* 0: Total, 1: OK, 2: CRC, 3: ICV */
585 unsigned long received_rate_histogram
[4][32];
586 /* 0: Long preamble/GI, 1: Short preamble/GI */
587 unsigned long received_preamble_GI
[2][32];
588 /* level: (<4K), (4K~8K), (8K~16K), (16K~32K), (32K~64K) */
589 unsigned long rx_AMPDUsize_histogram
[5];
590 /* level: (<5), (5~10), (10~20), (20~40), (>40) */
591 unsigned long rx_AMPDUnum_histogram
[5];
592 unsigned long numpacket_matchbssid
;
593 unsigned long numpacket_toself
;
594 unsigned long num_process_phyinfo
;
595 unsigned long numqry_phystatus
;
596 unsigned long numqry_phystatusCCK
;
597 unsigned long numqry_phystatusHT
;
598 /* 0: 20M, 1: funn40M, 2: upper20M, 3: lower20M, 4: duplicate */
599 unsigned long received_bwtype
[5];
600 unsigned long txnperr
;
601 unsigned long txnpdrop
;
602 unsigned long txresumed
;
603 unsigned long txnpokint
;
604 unsigned long txoverflow
;
605 unsigned long txlpokint
;
606 unsigned long txlpdrop
;
607 unsigned long txlperr
;
608 unsigned long txbeokint
;
609 unsigned long txbedrop
;
610 unsigned long txbeerr
;
611 unsigned long txbkokint
;
612 unsigned long txbkdrop
;
613 unsigned long txbkerr
;
614 unsigned long txviokint
;
615 unsigned long txvidrop
;
616 unsigned long txvierr
;
617 unsigned long txvookint
;
618 unsigned long txvodrop
;
619 unsigned long txvoerr
;
620 unsigned long txbeaconokint
;
621 unsigned long txbeacondrop
;
622 unsigned long txbeaconerr
;
623 unsigned long txmanageokint
;
624 unsigned long txmanagedrop
;
625 unsigned long txmanageerr
;
626 unsigned long txdatapkt
;
627 unsigned long txfeedback
;
628 unsigned long txfeedbackok
;
630 unsigned long txoktotal
;
631 unsigned long txokbytestotal
;
632 unsigned long txokinperiod
;
633 unsigned long txmulticast
;
634 unsigned long txbytesmulticast
;
635 unsigned long txbroadcast
;
636 unsigned long txbytesbroadcast
;
637 unsigned long txunicast
;
638 unsigned long txbytesunicast
;
640 unsigned long rxoktotal
;
641 unsigned long rxbytesunicast
;
642 unsigned long txfeedbackfail
;
643 unsigned long txerrtotal
;
644 unsigned long txerrbytestotal
;
645 unsigned long txerrmulticast
;
646 unsigned long txerrbroadcast
;
647 unsigned long txerrunicast
;
648 unsigned long txretrycount
;
649 unsigned long txfeedbackretry
;
651 unsigned long slide_signal_strength
[100];
652 unsigned long slide_evm
[100];
653 /* For recording sliding window's RSSI value */
654 unsigned long slide_rssi_total
;
655 /* For recording sliding window's EVM value */
656 unsigned long slide_evm_total
;
657 /* Transformed in dbm. Beautified signal strength for UI, not correct */
658 long signal_strength
;
660 long last_signal_strength_inpercent
;
661 /* Correct smoothed ss in dbm, only used in driver
662 * to report real power now */
663 long recv_signal_power
;
664 u8 rx_rssi_percentage
[4];
665 u8 rx_evm_percentage
[2];
667 rt_tx_rahis_t txrate
;
668 /* For beacon RSSI */
669 u32 Slide_Beacon_pwdb
[100];
670 u32 Slide_Beacon_Total
;
671 RT_SMOOTH_DATA_4RF cck_adc_pwdb
;
673 u32 CurrentShowTxate
;
677 /* Bandwidth Offset */
678 #define HAL_PRIME_CHNL_OFFSET_DONT_CARE 0
679 #define HAL_PRIME_CHNL_OFFSET_LOWER 1
680 #define HAL_PRIME_CHNL_OFFSET_UPPER 2
683 typedef struct ChnlAccessSetting
{
690 } *PCHANNEL_ACCESS_SETTING
, CHANNEL_ACCESS_SETTING
;
692 typedef struct _BB_REGISTER_DEFINITION
{
693 /* set software control: 0x870~0x877 [8 bytes] */
695 /* readback data: 0x8e0~0x8e7 [8 bytes] */
697 /* output data: 0x860~0x86f [16 bytes] */
699 /* output enable: 0x860~0x86f [16 bytes] */
701 /* LSSI data: 0x840~0x84f [16 bytes] */
703 /* BB Band Select: 0x878~0x87f [8 bytes] */
705 /* Tx gain stage: 0x80c~0x80f [4 bytes] */
707 /* wire parameter control1: 0x820~0x823, 0x828~0x82b,
708 * 0x830~0x833, 0x838~0x83b [16 bytes] */
710 /* wire parameter control2: 0x824~0x827, 0x82c~0x82f,
711 * 0x834~0x837, 0x83c~0x83f [16 bytes] */
713 /* Tx Rx antenna control: 0x858~0x85f [16 bytes] */
715 /* AGC parameter control1: 0xc50~0xc53, 0xc58~0xc5b,
716 * 0xc60~0xc63, 0xc68~0xc6b [16 bytes] */
718 /* AGC parameter control2: 0xc54~0xc57, 0xc5c~0xc5f,
719 * 0xc64~0xc67, 0xc6c~0xc6f [16 bytes] */
721 /* OFDM Rx IQ imbalance matrix: 0xc14~0xc17, 0xc1c~0xc1f,
722 * 0xc24~0xc27, 0xc2c~0xc2f [16 bytes] */
724 /* Rx IQ DC offset and Rx digital filter, Rx DC notch filter:
725 * 0xc10~0xc13, 0xc18~0xc1b,
726 * 0xc20~0xc23, 0xc28~0xc2b [16 bytes] */
728 /* OFDM Tx IQ imbalance matrix: 0xc80~0xc83, 0xc88~0xc8b,
729 * 0xc90~0xc93, 0xc98~0xc9b [16 bytes] */
731 /* Tx IQ DC Offset and Tx DFIR type:
732 * 0xc84~0xc87, 0xc8c~0xc8f,
733 * 0xc94~0xc97, 0xc9c~0xc9f [16 bytes] */
735 /* LSSI RF readback data: 0x8a0~0x8af [16 bytes] */
737 } BB_REGISTER_DEFINITION_T
, *PBB_REGISTER_DEFINITION_T
;
739 typedef enum _RT_RF_TYPE_819xU
{
745 } RT_RF_TYPE_819xU
, *PRT_RF_TYPE_819xU
;
747 typedef struct _rate_adaptive
{
748 u8 rate_adaptive_disabled
;
752 u32 high_rssi_thresh_for_ra
;
753 u32 high2low_rssi_thresh_for_ra
;
754 u8 low2high_rssi_thresh_for_ra40M
;
755 u32 low_rssi_thresh_for_ra40M
;
756 u8 low2high_rssi_thresh_for_ra20M
;
757 u32 low_rssi_thresh_for_ra20M
;
758 u32 upper_rssi_threshold_ratr
;
759 u32 middle_rssi_threshold_ratr
;
760 u32 low_rssi_threshold_ratr
;
761 u32 low_rssi_threshold_ratr_40M
;
762 u32 low_rssi_threshold_ratr_20M
;
765 u32 ping_rssi_thresh_for_ra
;
768 } rate_adaptive
, *prate_adaptive
;
770 #define TxBBGainTableLength 37
771 #define CCKTxBBGainTableLength 23
773 typedef struct _txbbgain_struct
{
774 long txbb_iq_amplifygain
;
776 } txbbgain_struct
, *ptxbbgain_struct
;
778 typedef struct _ccktxbbgain_struct
{
779 /* The value is from a22 to a29, one byte one time is much safer */
780 u8 ccktxbb_valuearray
[8];
781 } ccktxbbgain_struct
, *pccktxbbgain_struct
;
784 typedef struct _init_gain
{
791 } init_gain
, *pinit_gain
;
793 typedef struct _phy_ofdm_rx_status_report_819xusb
{
807 } phy_sts_ofdm_819xusb_t
;
809 typedef struct _phy_cck_rx_status_report_819xusb
{
810 /* For CCK rate descriptor. This is an unsigned 8:1 variable.
811 * LSB bit presend 0.5. And MSB 7 bts presend a signed value.
812 * Range from -64~+63.5. */
816 } phy_sts_cck_819xusb_t
;
819 typedef struct _phy_ofdm_rx_status_rxsc_sgien_exintfflag
{
824 } phy_ofdm_rx_status_rxsc_sgien_exintfflag
;
826 typedef enum _RT_CUSTOMER_ID
{
828 RT_CID_8187_ALPHA0
= 1,
829 RT_CID_8187_SERCOMM_PS
= 2,
830 RT_CID_8187_HW_LED
= 3,
831 RT_CID_8187_NETGEAR
= 4,
833 RT_CID_819x_CAMEO
= 6,
834 RT_CID_819x_RUNTOP
= 7,
835 RT_CID_819x_Senao
= 8,
837 RT_CID_819x_Netcore
= 10,
838 RT_CID_Nettronix
= 11,
841 } RT_CUSTOMER_ID
, *PRT_CUSTOMER_ID
;
844 * ==========================================================================
846 * ==========================================================================
849 typedef enum _LED_STRATEGY_8190
{
850 SW_LED_MODE0
, /* SW control 1 LED via GPIO0. It is default option. */
851 SW_LED_MODE1
, /* SW control for PCI Express */
852 SW_LED_MODE2
, /* SW control for Cameo. */
853 SW_LED_MODE3
, /* SW control for RunTop. */
854 SW_LED_MODE4
, /* SW control for Netcore. */
855 /* HW control 2 LEDs, LED0 and LED1 (4 different control modes) */
857 } LED_STRATEGY_8190
, *PLED_STRATEGY_8190
;
859 typedef enum _RESET_TYPE
{
860 RESET_TYPE_NORESET
= 0x00,
861 RESET_TYPE_NORMAL
= 0x01,
862 RESET_TYPE_SILENT
= 0x02
865 /* The simple tx command OP code. */
866 typedef enum _tag_TxCmd_Config_Index
{
867 TXCMD_TXRA_HISTORY_CTRL
= 0xFF900000,
868 TXCMD_RESET_TX_PKT_BUFF
= 0xFF900001,
869 TXCMD_RESET_RX_PKT_BUFF
= 0xFF900002,
870 TXCMD_SET_TX_DURATION
= 0xFF900003,
871 TXCMD_SET_RX_RSSI
= 0xFF900004,
872 TXCMD_SET_TX_PWR_TRACKING
= 0xFF900005,
876 typedef struct r8192_priv
{
877 struct usb_device
*udev
;
878 /* For maintain info from eeprom */
882 u8 eeprom_CustomerID
;
883 u8 eeprom_ChannelPlan
;
884 RT_CUSTOMER_ID CustomerID
;
885 LED_STRATEGY_8190 LedStrategy
;
886 u8 txqueue_to_outpipemap
[9];
888 struct ieee80211_device
*ieee80211
;
890 /* O: rtl8192, 1: rtl8185 V B/C, 2: rtl8185 V D */
892 /* If TCR reports card V B/C, this discriminates */
893 u8 card_8192_version
;
896 PCI
, MINIPCI
, CARDBUS
, USB
899 short plcp_preamble_mode
;
912 /* If 1, allow bad crc frame, reception in monitor mode */
915 struct semaphore wx_sem
;
916 struct semaphore rf_sem
; /* Used to lock rf write operation */
918 u8 rf_type
; /* 0: 1T2R, 1: 2T4R */
919 RT_RF_TYPE_819xU rf_chip
;
921 short (*rf_set_sens
)(struct net_device
*dev
, short sens
);
922 u8 (*rf_set_chan
)(struct net_device
*dev
, u8 ch
);
923 void (*rf_close
)(struct net_device
*dev
);
924 void (*rf_init
)(struct net_device
*dev
);
928 struct iw_statistics wstats
;
932 struct urb
**rx_cmd_urb
;
936 #ifdef THOMAS_TASKLET
937 atomic_t irt_counter
; /* count for irq_rx_tasklet */
939 #ifdef JACKSON_NEW_RX
940 struct sk_buff
**pp_rxskb
;
944 struct sk_buff_head rx_queue
;
945 struct sk_buff_head skb_queue
;
946 struct work_struct qos_activate
;
948 atomic_t tx_pending
[0x10]; /* UART_PRIORITY + 1 */
951 struct tasklet_struct irq_rx_tasklet
;
952 struct urb
*rxurb_task
;
954 /* Tx Related variables */
958 u8 RegCWinMin
; /* For turbo mode CW adaptive */
960 u32 LastRxDescTSFHigh
;
961 u32 LastRxDescTSFLow
;
964 /* Rx Related variables */
965 u16 EarlyRxThreshold
;
975 struct ChnlAccessSetting ChannelAccessSetting
;
976 struct work_struct reset_wq
;
978 /**********************************************************/
984 bool bCurrentRxAggrEnable
;
985 u8 Rf_Mode
; /* For Firmware RF -R/W switch */
986 prt_firmware pFirmware
;
987 rtl819xUsb_loopback_e LoopbackMode
;
988 u16 EEPROMTxPowerDiff
;
989 u8 EEPROMThermalMeter
;
993 u8 EEPROMTxPowerLevelCCK
; /* CCK channel 1~14 */
994 u8 EEPROMTxPowerLevelCCK_V1
[3];
995 u8 EEPROMTxPowerLevelOFDM24G
[3]; /* OFDM 2.4G channel 1~14 */
996 u8 EEPROMTxPowerLevelOFDM5G
[24]; /* OFDM 5G */
999 BB_REGISTER_DEFINITION_T PHYRegDef
[4]; /* Radio A/B/C/D */
1000 /* Read/write are allow for following hardware information variables */
1001 u32 MCSTxPowerLevelOriginalOffset
[6];
1002 u32 CCKTxPowerLevelOriginalOffset
;
1003 u8 TxPowerLevelCCK
[14]; /* CCK channel 1~14 */
1004 u8 TxPowerLevelOFDM24G
[14]; /* OFDM 2.4G channel 1~14 */
1005 u8 TxPowerLevelOFDM5G
[14]; /* OFDM 5G */
1008 u8 AntennaTxPwDiff
[2]; /* Antenna gain offset, 0: B, 1: C, 2: D */
1010 u8 ThermalMeter
[2]; /* index 0: RFIC0, index 1: RFIC1 */
1013 /* Use to calculate PWBD */
1015 long undecorated_smoothed_pwdb
;
1017 /* For set channel */
1018 u8 SwChnlInProgress
;
1021 u8 SetBWModeInProgress
;
1022 HT_CHANNEL_WIDTH CurrentChannelBW
;
1024 /* 8190 40MHz mode */
1025 /* Control channel sub-carrier */
1026 u8 nCur40MhzPrimeSC
;
1027 /* Test for shorten RF configuration time.
1028 * We save RF reg0 in this variable to reduce RF reading. */
1031 bool brfpath_rxenable
[4];
1032 /* RF set related */
1033 bool SetRFPowerStateInProgress
;
1034 struct timer_list watch_dog_timer
;
1036 /* For dynamic mechanism */
1037 /* Tx Power Control for Near/Far Range */
1038 bool bdynamic_txpower
;
1039 bool bDynamicTxHighPower
;
1040 bool bDynamicTxLowPower
;
1041 bool bLastDTPFlag_High
;
1042 bool bLastDTPFlag_Low
;
1044 bool bstore_last_dtpflag
;
1045 /* Define to discriminate on High power State or
1046 * on sitesurvey to change Tx gain index */
1047 bool bstart_txctrl_bydtp
;
1048 rate_adaptive rate_adaptive
;
1049 /* TX power tracking
1050 * OPEN/CLOSE TX POWER TRACKING */
1051 txbbgain_struct txbbgain_table
[TxBBGainTableLength
];
1052 u8 txpower_count
; /* For 6 sec do tracking again */
1053 bool btxpower_trackingInit
;
1056 /* CCK TX Power Tracking */
1057 ccktxbbgain_struct cck_txbbgain_table
[CCKTxBBGainTableLength
];
1058 ccktxbbgain_struct cck_txbbgain_ch14_table
[CCKTxBBGainTableLength
];
1059 u8 rfa_txpowertrackingindex
;
1060 u8 rfa_txpowertrackingindex_real
;
1061 u8 rfa_txpowertracking_default
;
1062 u8 rfc_txpowertrackingindex
;
1063 u8 rfc_txpowertrackingindex_real
;
1065 s8 cck_present_attentuation
;
1066 u8 cck_present_attentuation_20Mdefault
;
1067 u8 cck_present_attentuation_40Mdefault
;
1068 char cck_present_attentuation_difference
;
1069 bool btxpower_tracking
;
1071 bool btxpowerdata_readfromEEPORM
;
1073 init_gain initgain_backup
;
1074 u8 DefaultInitialGain
[4];
1075 /* For EDCA Turbo mode */
1076 bool bis_any_nonbepkts
;
1077 bool bcurrent_turbo_EDCA
;
1078 bool bis_cur_rdlstate
;
1079 struct timer_list fsync_timer
;
1080 bool bfsync_processing
; /* 500ms Fsync timer is active or not */
1082 u32 rateCountDiffRecord
;
1083 u32 ContinueDiffCount
;
1088 u8 framesyncMonitor
;
1090 u8 nrxAMPDU_aggr_num
;
1097 u32 txpower_checkcnt
;
1098 u32 txpower_tracking_callback_cnt
;
1099 u8 thermal_read_val
[40];
1100 u8 thermal_readback_index
;
1101 u32 ccktxpower_adjustcnt_not_ch14
;
1102 u32 ccktxpower_adjustcnt_ch14
;
1103 u8 tx_fwinfo_force_subcarriermode
;
1104 u8 tx_fwinfo_force_subcarrierval
;
1105 /* For silent reset */
1106 RESET_TYPE ResetProgress
;
1107 bool bForcedSilentReset
;
1108 bool bDisableNormalResetCheck
;
1111 int IrpPendingCount
;
1112 bool bResetInProgress
;
1114 u8 InitialGainOperateType
;
1118 /* Define work item */
1120 struct delayed_work update_beacon_wq
;
1121 struct delayed_work watch_dog_wq
;
1122 struct delayed_work txpower_tracking_wq
;
1123 struct delayed_work rfpath_check_wq
;
1124 struct delayed_work gpio_change_rf_wq
;
1125 struct delayed_work initialgain_operate_wq
;
1126 struct workqueue_struct
*priv_wq
;
1131 BULK_PRIORITY
= 0x01,
1154 bool init_firmware(struct net_device
*dev
);
1155 short rtl819xU_tx_cmd(struct net_device
*dev
, struct sk_buff
*skb
);
1156 short rtl8192_tx(struct net_device
*dev
, struct sk_buff
*skb
);
1158 u32
read_cam(struct net_device
*dev
, u8 addr
);
1159 void write_cam(struct net_device
*dev
, u8 addr
, u32 data
);
1161 int read_nic_byte(struct net_device
*dev
, int x
, u8
*data
);
1162 int read_nic_byte_E(struct net_device
*dev
, int x
, u8
*data
);
1163 int read_nic_dword(struct net_device
*dev
, int x
, u32
*data
);
1164 int read_nic_word(struct net_device
*dev
, int x
, u16
*data
);
1165 void write_nic_byte(struct net_device
*dev
, int x
, u8 y
);
1166 void write_nic_byte_E(struct net_device
*dev
, int x
, u8 y
);
1167 void write_nic_word(struct net_device
*dev
, int x
, u16 y
);
1168 void write_nic_dword(struct net_device
*dev
, int x
, u32 y
);
1169 void force_pci_posting(struct net_device
*dev
);
1171 void rtl8192_rtx_disable(struct net_device
*);
1172 void rtl8192_rx_enable(struct net_device
*);
1173 void rtl8192_tx_enable(struct net_device
*);
1175 void rtl8192_disassociate(struct net_device
*dev
);
1176 void rtl8185_set_rf_pins_enable(struct net_device
*dev
, u32 a
);
1178 void rtl8192_set_anaparam(struct net_device
*dev
, u32 a
);
1179 void rtl8185_set_anaparam2(struct net_device
*dev
, u32 a
);
1180 void rtl8192_update_msr(struct net_device
*dev
);
1181 int rtl8192_down(struct net_device
*dev
);
1182 int rtl8192_up(struct net_device
*dev
);
1183 void rtl8192_commit(struct net_device
*dev
);
1184 void rtl8192_set_chan(struct net_device
*dev
, short ch
);
1185 void write_phy(struct net_device
*dev
, u8 adr
, u8 data
);
1186 void write_phy_cck(struct net_device
*dev
, u8 adr
, u32 data
);
1187 void write_phy_ofdm(struct net_device
*dev
, u8 adr
, u32 data
);
1188 void rtl8185_tx_antenna(struct net_device
*dev
, u8 ant
);
1189 void rtl8192_set_rxconf(struct net_device
*dev
);
1190 extern void rtl819xusb_beacon_tx(struct net_device
*dev
, u16 tx_rate
);
1192 void EnableHWSecurityConfig8192(struct net_device
*dev
);
1193 void setKey(struct net_device
*dev
, u8 EntryNo
, u8 KeyIndex
, u16 KeyType
, u8
*MacAddr
, u8 DefaultKey
, u32
*KeyContent
);