1 /******************************************************************************
2 * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
3 * Linux device driver for RTL8192U
5 * Based on the r8187 driver, which is:
6 * Copyright 2004-2005 Andrea Merello <andreamrl@tiscali.it>, et al.
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * You should have received a copy of the GNU General Public License along with
17 * this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
20 * The full GNU General Public License is included in this distribution in the
21 * file called LICENSE.
23 * Contact Information:
24 * Jerry chuang <wlanfae@realtek.com>
27 #ifndef CONFIG_FORCE_HARD_FLOAT
28 double __floatsidf (int i
) { return i
; }
29 unsigned int __fixunsdfsi (double d
) { return d
; }
30 double __adddf3(double a
, double b
) { return a
+b
; }
31 double __addsf3(float a
, float b
) { return a
+b
; }
32 double __subdf3(double a
, double b
) { return a
-b
; }
33 double __extendsfdf2(float a
) {return a
;}
40 #undef RX_DONT_PASS_UL
42 #undef DEBUG_RX_VERBOSE
48 #undef DEBUG_TX_FILLDESC
53 #undef DEBUG_REGISTERS
55 #undef DEBUG_IRQ_TASKLET
59 #define CONFIG_RTL8192_IO_MAP
62 #include <asm/uaccess.h>
64 //#include "r8190_rtl8256.h" /* RTL8225 Radio frontend */
65 #include "r8180_93cx6.h" /* Card EEPROM */
66 #include "r8192U_wx.h"
68 #include "r8192S_rtl8225.h"
69 #include "r8192S_hw.h"
70 #include "r8192S_phy.h"
71 #include "r8192S_phyreg.h"
72 #include "r8192S_Efuse.h"
74 #include "r819xU_cmdpkt.h"
75 #include "r8192U_dm.h"
76 //#include "r8192xU_phyreg.h"
77 #include <linux/usb.h>
79 #include "r8192U_pm.h"
81 #include "ieee80211/dot11d.h"
85 #include <asm/uaccess.h>
86 #include "r8192U_hw.h"
88 #include "r8190_rtl8256.h" /* RTL8225 Radio frontend */
89 #include "r8180_93cx6.h" /* Card EEPROM */
90 #include "r8192U_wx.h"
91 #include "r819xU_phy.h" //added by WB 4.30.2008
92 #include "r819xU_phyreg.h"
93 #include "r819xU_cmdpkt.h"
94 #include "r8192U_dm.h"
95 //#include "r8192xU_phyreg.h"
96 #include <linux/usb.h>
98 #include "r8192U_pm.h"
100 #include "ieee80211/dot11d.h"
106 u32 rt_global_debug_component
= \
116 COMP_POWER_TRACKING
|
138 COMP_ERR
; //always open err flags on
140 //set here to open your trace code. //WB
141 u32 rt_global_debug_component
= \
149 // COMP_POWER_TRACKING |
160 COMP_ERR
; //always open err flags on
163 #define TOTAL_CAM_ENTRY 32
164 #define CAM_CONTENT_COUNT 8
166 static struct usb_device_id rtl8192_usb_id_tbl
[] = {
168 {USB_DEVICE(0x0bda, 0x8192)},
169 {USB_DEVICE(0x0bda, 0x8709)},
171 {USB_DEVICE(0x07aa, 0x0043)},
173 {USB_DEVICE(0x050d, 0x805E)},
175 {USB_DEVICE(0x0df6, 0x0031)},
177 {USB_DEVICE(0x1740, 0x9201)},
179 {USB_DEVICE(0x2001, 0x3301)},
181 {USB_DEVICE(0x5a57, 0x0290)},
183 {USB_DEVICE(0x0bda, 0x8172)},
187 MODULE_LICENSE("GPL");
188 MODULE_VERSION("V 1.1");
189 MODULE_DEVICE_TABLE(usb
, rtl8192_usb_id_tbl
);
190 MODULE_DESCRIPTION("Linux driver for Realtek RTL8192 USB WiFi cards");
192 static char* ifname
= "wlan%d";
194 static int hwseqnum
= 0;
195 static int hwwep
= 0;
197 static int hwwep
= 1; //default use hw. set 0 to use software security
198 static int channels
= 0x3fff;
202 module_param(ifname
, charp
, S_IRUGO
|S_IWUSR
);
203 //module_param(hwseqnum,int, S_IRUGO|S_IWUSR);
204 module_param(hwwep
,int, S_IRUGO
|S_IWUSR
);
205 module_param(channels
,int, S_IRUGO
|S_IWUSR
);
207 MODULE_PARM_DESC(ifname
," Net interface name, wlan%d=default");
208 //MODULE_PARM_DESC(hwseqnum," Try to use hardware 802.11 header sequence numbers. Zero=default");
209 MODULE_PARM_DESC(hwwep
," Try to use hardware security support. ");
210 MODULE_PARM_DESC(channels
," Channel bitmask for specific locales. NYI");
212 static int __devinit
rtl8192_usb_probe(struct usb_interface
*intf
,
213 const struct usb_device_id
*id
);
214 static void __devexit
rtl8192_usb_disconnect(struct usb_interface
*intf
);
216 static struct usb_driver rtl8192_usb_driver
= {
217 .name
= RTL819xU_MODULE_NAME
, /* Driver name */
218 .id_table
= rtl8192_usb_id_tbl
, /* PCI_ID table */
219 .probe
= rtl8192_usb_probe
, /* probe fn */
220 .disconnect
= rtl8192_usb_disconnect
, /* remove fn */
221 .suspend
= rtl8192U_suspend
, /* PM suspend fn */
222 .resume
= rtl8192U_resume
, /* PM resume fn */
223 .reset_resume
= rtl8192U_resume
, /* PM reset resume fn */
228 static void rtl8192SU_read_eeprom_info(struct net_device
*dev
);
229 short rtl8192SU_tx(struct net_device
*dev
, struct sk_buff
* skb
);
230 void rtl8192SU_rx_nomal(struct sk_buff
* skb
);
231 void rtl8192SU_rx_cmd(struct sk_buff
*skb
);
232 bool rtl8192SU_adapter_start(struct net_device
*dev
);
233 short rtl8192SU_tx_cmd(struct net_device
*dev
, struct sk_buff
*skb
);
234 void rtl8192SU_link_change(struct net_device
*dev
);
235 void InitialGain8192S(struct net_device
*dev
,u8 Operation
);
236 void rtl8192SU_query_rxdesc_status(struct sk_buff
*skb
, struct ieee80211_rx_stats
*stats
, bool bIsRxAggrSubframe
);
238 struct rtl819x_ops rtl8192su_ops
= {
239 .nic_type
= NIC_8192SU
,
240 .rtl819x_read_eeprom_info
= rtl8192SU_read_eeprom_info
,
241 .rtl819x_tx
= rtl8192SU_tx
,
242 .rtl819x_tx_cmd
= rtl8192SU_tx_cmd
,
243 .rtl819x_rx_nomal
= rtl8192SU_rx_nomal
,
244 .rtl819x_rx_cmd
= rtl8192SU_rx_cmd
,
245 .rtl819x_adapter_start
= rtl8192SU_adapter_start
,
246 .rtl819x_link_change
= rtl8192SU_link_change
,
247 .rtl819x_initial_gain
= InitialGain8192S
,
248 .rtl819x_query_rxdesc_status
= rtl8192SU_query_rxdesc_status
,
251 static void rtl8192_read_eeprom_info(struct net_device
*dev
);
252 short rtl8192_tx(struct net_device
*dev
, struct sk_buff
* skb
);
253 void rtl8192_rx_nomal(struct sk_buff
* skb
);
254 void rtl8192_rx_cmd(struct sk_buff
*skb
);
255 bool rtl8192_adapter_start(struct net_device
*dev
);
256 short rtl819xU_tx_cmd(struct net_device
*dev
, struct sk_buff
*skb
);
257 void rtl8192_link_change(struct net_device
*dev
);
258 void InitialGain819xUsb(struct net_device
*dev
,u8 Operation
);
259 void query_rxdesc_status(struct sk_buff
*skb
, struct ieee80211_rx_stats
*stats
, bool bIsRxAggrSubframe
);
261 struct rtl819x_ops rtl8192u_ops
= {
262 .nic_type
= NIC_8192U
,
263 .rtl819x_read_eeprom_info
= rtl8192_read_eeprom_info
,
264 .rtl819x_tx
= rtl8192_tx
,
265 .rtl819x_tx_cmd
= rtl819xU_tx_cmd
,
266 .rtl819x_rx_nomal
= rtl8192_rx_nomal
,
267 .rtl819x_rx_cmd
= rtl8192_rx_cmd
,
268 .rtl819x_adapter_start
= rtl8192_adapter_start
,
269 .rtl819x_link_change
= rtl8192_link_change
,
270 .rtl819x_initial_gain
= InitialGain819xUsb
,
271 .rtl819x_query_rxdesc_status
= query_rxdesc_status
,
276 typedef struct _CHANNEL_LIST
280 }CHANNEL_LIST
, *PCHANNEL_LIST
;
282 static CHANNEL_LIST ChannelPlan
[] = {
283 {{1,2,3,4,5,6,7,8,9,10,11,36,40,44,48,52,56,60,64,149,153,157,161,165},24}, //FCC
284 {{1,2,3,4,5,6,7,8,9,10,11},11}, //IC
285 {{1,2,3,4,5,6,7,8,9,10,11,12,13,36,40,44,48,52,56,60,64},21}, //ETSI
286 {{1,2,3,4,5,6,7,8,9,10,11,12,13},13}, //Spain. Change to ETSI.
287 {{1,2,3,4,5,6,7,8,9,10,11,12,13},13}, //France. Change to ETSI.
288 {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22}, //MKK //MKK
289 {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22},//MKK1
290 {{1,2,3,4,5,6,7,8,9,10,11,12,13},13}, //Israel.
291 {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64},22}, // For 11a , TELEC
292 {{1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,40,44,48,52,56,60,64}, 22}, //MIC
293 {{1,2,3,4,5,6,7,8,9,10,11,12,13,14},14} //For Global Domain. 1-11:active scan, 12-14 passive scan. //+YJ, 080626
296 static void rtl819x_set_channel_map(u8 channel_plan
, struct r8192_priv
* priv
)
298 int i
, max_chan
=-1, min_chan
=-1;
299 struct ieee80211_device
* ieee
= priv
->ieee80211
;
300 switch (channel_plan
)
302 case COUNTRY_CODE_FCC
:
303 case COUNTRY_CODE_IC
:
304 case COUNTRY_CODE_ETSI
:
305 case COUNTRY_CODE_SPAIN
:
306 case COUNTRY_CODE_FRANCE
:
307 case COUNTRY_CODE_MKK
:
308 case COUNTRY_CODE_MKK1
:
309 case COUNTRY_CODE_ISRAEL
:
310 case COUNTRY_CODE_TELEC
:
311 case COUNTRY_CODE_MIC
:
314 ieee
->bGlobalDomain
= false;
315 //acturally 8225 & 8256 rf chip only support B,G,24N mode
316 if ((priv
->rf_chip
== RF_8225
) || (priv
->rf_chip
== RF_8256
) || (priv
->rf_chip
== RF_6052
))
323 RT_TRACE(COMP_ERR
, "unknown rf chip, can't set channel map in function:%s()\n", __FUNCTION__
);
325 if (ChannelPlan
[channel_plan
].Len
!= 0){
326 // Clear old channel map
327 memset(GET_DOT11D_INFO(ieee
)->channel_map
, 0, sizeof(GET_DOT11D_INFO(ieee
)->channel_map
));
328 // Set new channel map
329 for (i
=0;i
<ChannelPlan
[channel_plan
].Len
;i
++)
331 if (ChannelPlan
[channel_plan
].Channel
[i
] < min_chan
|| ChannelPlan
[channel_plan
].Channel
[i
] > max_chan
)
333 GET_DOT11D_INFO(ieee
)->channel_map
[ChannelPlan
[channel_plan
].Channel
[i
]] = 1;
338 case COUNTRY_CODE_GLOBAL_DOMAIN
:
340 GET_DOT11D_INFO(ieee
)->bEnabled
= 0;//this flag enabled to follow 11d country IE setting, otherwise, it shall follow global domain settings.
342 ieee
->bGlobalDomain
= true;
351 #define eqMacAddr(a,b) ( ((a)[0]==(b)[0] && (a)[1]==(b)[1] && (a)[2]==(b)[2] && (a)[3]==(b)[3] && (a)[4]==(b)[4] && (a)[5]==(b)[5]) ? 1:0 )
354 #define rx_hal_is_cck_rate(_pDesc)\
355 ((_pDesc->RxMCS == DESC92S_RATE1M ||\
356 _pDesc->RxMCS == DESC92S_RATE2M ||\
357 _pDesc->RxMCS == DESC92S_RATE5_5M ||\
358 _pDesc->RxMCS == DESC92S_RATE11M) &&\
361 #define tx_hal_is_cck_rate(_DataRate)\
362 ( _DataRate == MGN_1M ||\
363 _DataRate == MGN_2M ||\
364 _DataRate == MGN_5_5M ||\
365 _DataRate == MGN_11M )
368 #define rx_hal_is_cck_rate(_pdrvinfo)\
369 ((_pdrvinfo->RxRate == DESC90_RATE1M ||\
370 _pdrvinfo->RxRate == DESC90_RATE2M ||\
371 _pdrvinfo->RxRate == DESC90_RATE5_5M ||\
372 _pdrvinfo->RxRate == DESC90_RATE11M) &&\
378 void CamResetAllEntry(struct net_device
*dev
)
382 //2004/02/11 In static WEP, OID_ADD_KEY or OID_ADD_WEP are set before STA associate to AP.
383 // However, ResetKey is called on OID_802_11_INFRASTRUCTURE_MODE and MlmeAssociateRequest
384 // In this condition, Cam can not be reset because upper layer will not set this static key again.
385 //if(Adapter->EncAlgorithm == WEP_Encryption)
388 //DbgPrint("========================================\n");
389 //DbgPrint(" Call ResetAllEntry \n");
390 //DbgPrint("========================================\n\n");
391 ulcommand
|= BIT31
|BIT30
;
392 write_nic_dword(dev
, RWCAM
, ulcommand
);
394 for(ucIndex
=0;ucIndex
<TOTAL_CAM_ENTRY
;ucIndex
++)
395 CAM_mark_invalid(dev
, ucIndex
);
396 for(ucIndex
=0;ucIndex
<TOTAL_CAM_ENTRY
;ucIndex
++)
397 CAM_empty_entry(dev
, ucIndex
);
403 void write_cam(struct net_device
*dev
, u8 addr
, u32 data
)
405 write_nic_dword(dev
, WCAMI
, data
);
406 write_nic_dword(dev
, RWCAM
, BIT31
|BIT16
|(addr
&0xff) );
409 u32
read_cam(struct net_device
*dev
, u8 addr
)
411 write_nic_dword(dev
, RWCAM
, 0x80000000|(addr
&0xff) );
412 return read_nic_dword(dev
, 0xa8);
415 void write_nic_byte_E(struct net_device
*dev
, int indx
, u8 data
)
418 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
419 struct usb_device
*udev
= priv
->udev
;
421 status
= usb_control_msg(udev
, usb_sndctrlpipe(udev
, 0),
422 RTL8187_REQ_SET_REGS
, RTL8187_REQT_WRITE
,
423 indx
|0xfe00, 0, &data
, 1, HZ
/ 2);
427 printk("write_nic_byte_E TimeOut! status:%d\n", status
);
431 u8
read_nic_byte_E(struct net_device
*dev
, int indx
)
435 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
436 struct usb_device
*udev
= priv
->udev
;
438 status
= usb_control_msg(udev
, usb_rcvctrlpipe(udev
, 0),
439 RTL8187_REQ_GET_REGS
, RTL8187_REQT_READ
,
440 indx
|0xfe00, 0, &data
, 1, HZ
/ 2);
444 printk("read_nic_byte_E TimeOut! status:%d\n", status
);
449 //as 92U has extend page from 4 to 16, so modify functions below.
450 void write_nic_byte(struct net_device
*dev
, int indx
, u8 data
)
454 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
455 struct usb_device
*udev
= priv
->udev
;
457 status
= usb_control_msg(udev
, usb_sndctrlpipe(udev
, 0),
458 RTL8187_REQ_SET_REGS
, RTL8187_REQT_WRITE
,
460 indx
, 0, &data
, 1, HZ
/ 2);
462 (indx
&0xff)|0xff00, (indx
>>8)&0x0f, &data
, 1, HZ
/ 2);
467 printk("write_nic_byte TimeOut! status:%d\n", status
);
474 void write_nic_word(struct net_device
*dev
, int indx
, u16 data
)
479 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
480 struct usb_device
*udev
= priv
->udev
;
482 status
= usb_control_msg(udev
, usb_sndctrlpipe(udev
, 0),
483 RTL8187_REQ_SET_REGS
, RTL8187_REQT_WRITE
,
485 indx
, 0, &data
, 2, HZ
/ 2);
487 (indx
&0xff)|0xff00, (indx
>>8)&0x0f, &data
, 2, HZ
/ 2);
492 printk("write_nic_word TimeOut! status:%d\n", status
);
498 void write_nic_dword(struct net_device
*dev
, int indx
, u32 data
)
503 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
504 struct usb_device
*udev
= priv
->udev
;
506 status
= usb_control_msg(udev
, usb_sndctrlpipe(udev
, 0),
507 RTL8187_REQ_SET_REGS
, RTL8187_REQT_WRITE
,
509 indx
, 0, &data
, 4, HZ
/ 2);
511 (indx
&0xff)|0xff00, (indx
>>8)&0x0f, &data
, 4, HZ
/ 2);
517 printk("write_nic_dword TimeOut! status:%d\n", status
);
524 u8
read_nic_byte(struct net_device
*dev
, int indx
)
528 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
529 struct usb_device
*udev
= priv
->udev
;
531 status
= usb_control_msg(udev
, usb_rcvctrlpipe(udev
, 0),
532 RTL8187_REQ_GET_REGS
, RTL8187_REQT_READ
,
534 indx
, 0, &data
, 1, HZ
/ 2);
536 (indx
&0xff)|0xff00, (indx
>>8)&0x0f, &data
, 1, HZ
/ 2);
541 printk("read_nic_byte TimeOut! status:%d\n", status
);
549 u16
read_nic_word(struct net_device
*dev
, int indx
)
553 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
554 struct usb_device
*udev
= priv
->udev
;
556 status
= usb_control_msg(udev
, usb_rcvctrlpipe(udev
, 0),
557 RTL8187_REQ_GET_REGS
, RTL8187_REQT_READ
,
559 indx
, 0, &data
, 2, HZ
/ 2);
561 (indx
&0xff)|0xff00, (indx
>>8)&0x0f, &data
, 2, HZ
/ 2);
566 printk("read_nic_word TimeOut! status:%d\n", status
);
573 u16
read_nic_word_E(struct net_device
*dev
, int indx
)
577 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
578 struct usb_device
*udev
= priv
->udev
;
580 status
= usb_control_msg(udev
, usb_rcvctrlpipe(udev
, 0),
581 RTL8187_REQ_GET_REGS
, RTL8187_REQT_READ
,
582 indx
|0xfe00, 0, &data
, 2, HZ
/ 2);
586 printk("read_nic_word TimeOut! status:%d\n", status
);
593 u32
read_nic_dword(struct net_device
*dev
, int indx
)
599 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
600 struct usb_device
*udev
= priv
->udev
;
602 status
= usb_control_msg(udev
, usb_rcvctrlpipe(udev
, 0),
603 RTL8187_REQ_GET_REGS
, RTL8187_REQT_READ
,
605 indx
, 0, &data
, 4, HZ
/ 2);
607 (indx
&0xff)|0xff00, (indx
>>8)&0x0f, &data
, 4, HZ
/ 2);
610 // printk(KERN_WARNING "read size of data = %d\, date = %d\n", result, data);
615 printk("read_nic_dword TimeOut! status:%d\n", status
);
616 if(status
== -ENODEV
) {
617 priv
->usb_error
= true;
627 //u8 read_phy_cck(struct net_device *dev, u8 adr);
628 //u8 read_phy_ofdm(struct net_device *dev, u8 adr);
629 /* this might still called in what was the PHY rtl8185/rtl8192 common code
630 * plans are to possibilty turn it again in one common code...
632 inline void force_pci_posting(struct net_device
*dev
)
637 static struct net_device_stats
*rtl8192_stats(struct net_device
*dev
);
638 void rtl8192_commit(struct net_device
*dev
);
639 //void rtl8192_restart(struct net_device *dev);
640 void rtl8192_restart(struct work_struct
*work
);
641 //void rtl8192_rq_tx_ack(struct work_struct *work);
643 void watch_dog_timer_callback(unsigned long data
);
645 /****************************************************************************
646 -----------------------------PROCFS STUFF-------------------------
647 *****************************************************************************/
649 static struct proc_dir_entry
*rtl8192_proc
= NULL
;
653 static int proc_get_stats_ap(char *page
, char **start
,
654 off_t offset
, int count
,
655 int *eof
, void *data
)
657 struct net_device
*dev
= data
;
658 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
659 struct ieee80211_device
*ieee
= priv
->ieee80211
;
660 struct ieee80211_network
*target
;
664 list_for_each_entry(target
, &ieee
->network_list
, list
) {
666 len
+= snprintf(page
+ len
, count
- len
,
667 "%s ", target
->ssid
);
669 if(target
->wpa_ie_len
>0 || target
->rsn_ie_len
>0){
670 len
+= snprintf(page
+ len
, count
- len
,
674 len
+= snprintf(page
+ len
, count
- len
,
685 static int proc_get_registers(char *page
, char **start
,
686 off_t offset
, int count
,
687 int *eof
, void *data
)
689 struct net_device
*dev
= data
;
690 // struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
693 int i
,n
,page0
,page1
,page2
;
700 /* This dump the current register page */
701 if(!IS_BB_REG_OFFSET_92S(page0
)){
702 len
+= snprintf(page
+ len
, count
- len
,
703 "\n####################page %x##################\n ", (page0
>>8));
706 len
+= snprintf(page
+ len
, count
- len
,
708 for(i
=0;i
<16 && n
<=max
;i
++,n
++)
709 len
+= snprintf(page
+ len
, count
- len
,
710 "%2.2x ",read_nic_byte(dev
,(page0
|n
)));
713 len
+= snprintf(page
+ len
, count
- len
,
714 "\n####################page %x##################\n ", (page0
>>8));
717 len
+= snprintf(page
+ len
, count
- len
, "\nD: %2x > ",n
);
718 for(i
=0;i
<4 && n
<=max
;n
+=4,i
++)
719 len
+= snprintf(page
+ len
, count
- len
,
720 "%8.8x ",rtl8192_QueryBBReg(dev
,(page0
|n
), bMaskDWord
));
723 len
+= snprintf(page
+ len
, count
- len
,"\n");
728 static int proc_get_registers_1(char *page
, char **start
,
729 off_t offset
, int count
,
730 int *eof
, void *data
)
732 struct net_device
*dev
= data
;
733 // struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
741 /* This dump the current register page */
742 len
+= snprintf(page
+ len
, count
- len
,
743 "\n####################page %x##################\n ", (page0
>>8));
746 len
+= snprintf(page
+ len
, count
- len
,
748 for(i
=0;i
<16 && n
<=max
;i
++,n
++)
749 len
+= snprintf(page
+ len
, count
- len
,
750 "%2.2x ",read_nic_byte(dev
,(page0
|n
)));
752 len
+= snprintf(page
+ len
, count
- len
,"\n");
757 static int proc_get_registers_2(char *page
, char **start
,
758 off_t offset
, int count
,
759 int *eof
, void *data
)
761 struct net_device
*dev
= data
;
762 // struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
770 /* This dump the current register page */
771 len
+= snprintf(page
+ len
, count
- len
,
772 "\n####################page %x##################\n ", (page0
>>8));
775 len
+= snprintf(page
+ len
, count
- len
,
777 for(i
=0;i
<16 && n
<=max
;i
++,n
++)
778 len
+= snprintf(page
+ len
, count
- len
,
779 "%2.2x ",read_nic_byte(dev
,(page0
|n
)));
781 len
+= snprintf(page
+ len
, count
- len
,"\n");
786 static int proc_get_registers_8(char *page
, char **start
,
787 off_t offset
, int count
,
788 int *eof
, void *data
)
790 struct net_device
*dev
= data
;
798 /* This dump the current register page */
799 len
+= snprintf(page
+ len
, count
- len
,
800 "\n####################page %x##################\n ", (page0
>>8));
803 len
+= snprintf(page
+ len
, count
- len
, "\nD: %2x > ",n
);
804 for(i
=0;i
<4 && n
<=max
;n
+=4,i
++)
805 len
+= snprintf(page
+ len
, count
- len
,
806 "%8.8x ",rtl8192_QueryBBReg(dev
,(page0
|n
), bMaskDWord
));
808 len
+= snprintf(page
+ len
, count
- len
,"\n");
813 static int proc_get_registers_9(char *page
, char **start
,
814 off_t offset
, int count
,
815 int *eof
, void *data
)
817 struct net_device
*dev
= data
;
818 // struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
826 /* This dump the current register page */
827 len
+= snprintf(page
+ len
, count
- len
,
828 "\n####################page %x##################\n ", (page0
>>8));
831 len
+= snprintf(page
+ len
, count
- len
, "\nD: %2x > ",n
);
832 for(i
=0;i
<4 && n
<=max
;n
+=4,i
++)
833 len
+= snprintf(page
+ len
, count
- len
,
834 "%8.8x ",rtl8192_QueryBBReg(dev
,(page0
|n
), bMaskDWord
));
836 len
+= snprintf(page
+ len
, count
- len
,"\n");
840 static int proc_get_registers_a(char *page
, char **start
,
841 off_t offset
, int count
,
842 int *eof
, void *data
)
844 struct net_device
*dev
= data
;
845 // struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
853 /* This dump the current register page */
854 len
+= snprintf(page
+ len
, count
- len
,
855 "\n####################page %x##################\n ", (page0
>>8));
858 len
+= snprintf(page
+ len
, count
- len
, "\nD: %2x > ",n
);
859 for(i
=0;i
<4 && n
<=max
;n
+=4,i
++)
860 len
+= snprintf(page
+ len
, count
- len
,
861 "%8.8x ",rtl8192_QueryBBReg(dev
,(page0
|n
), bMaskDWord
));
863 len
+= snprintf(page
+ len
, count
- len
,"\n");
867 static int proc_get_registers_b(char *page
, char **start
,
868 off_t offset
, int count
,
869 int *eof
, void *data
)
871 struct net_device
*dev
= data
;
872 // struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
880 /* This dump the current register page */
881 len
+= snprintf(page
+ len
, count
- len
,
882 "\n####################page %x##################\n ", (page0
>>8));
885 len
+= snprintf(page
+ len
, count
- len
, "\nD: %2x > ",n
);
886 for(i
=0;i
<4 && n
<=max
;n
+=4,i
++)
887 len
+= snprintf(page
+ len
, count
- len
,
888 "%8.8x ",rtl8192_QueryBBReg(dev
,(page0
|n
), bMaskDWord
));
890 len
+= snprintf(page
+ len
, count
- len
,"\n");
894 static int proc_get_registers_c(char *page
, char **start
,
895 off_t offset
, int count
,
896 int *eof
, void *data
)
898 struct net_device
*dev
= data
;
899 // struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
907 /* This dump the current register page */
908 len
+= snprintf(page
+ len
, count
- len
,
909 "\n####################page %x##################\n ", (page0
>>8));
912 len
+= snprintf(page
+ len
, count
- len
, "\nD: %2x > ",n
);
913 for(i
=0;i
<4 && n
<=max
;n
+=4,i
++)
914 len
+= snprintf(page
+ len
, count
- len
,
915 "%8.8x ",rtl8192_QueryBBReg(dev
,(page0
|n
), bMaskDWord
));
917 len
+= snprintf(page
+ len
, count
- len
,"\n");
921 static int proc_get_registers_d(char *page
, char **start
,
922 off_t offset
, int count
,
923 int *eof
, void *data
)
925 struct net_device
*dev
= data
;
926 // struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
934 /* This dump the current register page */
935 len
+= snprintf(page
+ len
, count
- len
,
936 "\n####################page %x##################\n ", (page0
>>8));
939 len
+= snprintf(page
+ len
, count
- len
, "\nD: %2x > ",n
);
940 for(i
=0;i
<4 && n
<=max
;n
+=4,i
++)
941 len
+= snprintf(page
+ len
, count
- len
,
942 "%8.8x ",rtl8192_QueryBBReg(dev
,(page0
|n
), bMaskDWord
));
944 len
+= snprintf(page
+ len
, count
- len
,"\n");
948 static int proc_get_registers_e(char *page
, char **start
,
949 off_t offset
, int count
,
950 int *eof
, void *data
)
952 struct net_device
*dev
= data
;
953 // struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
961 /* This dump the current register page */
962 len
+= snprintf(page
+ len
, count
- len
,
963 "\n####################page %x##################\n ", (page0
>>8));
966 len
+= snprintf(page
+ len
, count
- len
, "\nD: %2x > ",n
);
967 for(i
=0;i
<4 && n
<=max
;n
+=4,i
++)
968 len
+= snprintf(page
+ len
, count
- len
,
969 "%8.8x ",rtl8192_QueryBBReg(dev
,(page0
|n
), bMaskDWord
));
971 len
+= snprintf(page
+ len
, count
- len
,"\n");
976 static int proc_get_registers(char *page
, char **start
,
977 off_t offset
, int count
,
978 int *eof
, void *data
)
980 struct net_device
*dev
= data
;
981 // struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
988 /* This dump the current register page */
989 len
+= snprintf(page
+ len
, count
- len
,
990 "\n####################page 0##################\n ");
994 //printk( "\nD: %2x> ", n);
995 len
+= snprintf(page
+ len
, count
- len
,
998 for(i
=0;i
<16 && n
<=max
;i
++,n
++)
999 len
+= snprintf(page
+ len
, count
- len
,
1000 "%2x ",read_nic_byte(dev
,0x000|n
));
1002 // printk("%2x ",read_nic_byte(dev,n));
1005 len
+= snprintf(page
+ len
, count
- len
,
1006 "\n####################page 1##################\n ");
1009 //printk( "\nD: %2x> ", n);
1010 len
+= snprintf(page
+ len
, count
- len
,
1013 for(i
=0;i
<16 && n
<=max
;i
++,n
++)
1014 len
+= snprintf(page
+ len
, count
- len
,
1015 "%2x ",read_nic_byte(dev
,0x100|n
));
1017 // printk("%2x ",read_nic_byte(dev,n));
1019 len
+= snprintf(page
+ len
, count
- len
,
1020 "\n####################page 3##################\n ");
1023 //printk( "\nD: %2x> ", n);
1024 len
+= snprintf(page
+ len
, count
- len
,
1027 for(i
=0;i
<16 && n
<=max
;i
++,n
++)
1028 len
+= snprintf(page
+ len
, count
- len
,
1029 "%2x ",read_nic_byte(dev
,0x300|n
));
1031 // printk("%2x ",read_nic_byte(dev,n));
1036 len
+= snprintf(page
+ len
, count
- len
,"\n");
1044 static int proc_get_cck_reg(char *page
, char **start
,
1045 off_t offset
, int count
,
1046 int *eof
, void *data
)
1048 struct net_device
*dev
= data
;
1049 // struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
1056 /* This dump the current register page */
1059 //printk( "\nD: %2x> ", n);
1060 len
+= snprintf(page
+ len
, count
- len
,
1063 for(i
=0;i
<16 && n
<=max
;i
++,n
++)
1064 len
+= snprintf(page
+ len
, count
- len
,
1065 "%2x ",read_phy_cck(dev
,n
));
1067 // printk("%2x ",read_nic_byte(dev,n));
1069 len
+= snprintf(page
+ len
, count
- len
,"\n");
1079 static int proc_get_ofdm_reg(char *page
, char **start
,
1080 off_t offset
, int count
,
1081 int *eof
, void *data
)
1083 struct net_device
*dev
= data
;
1084 // struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
1092 /* This dump the current register page */
1095 //printk( "\nD: %2x> ", n);
1096 len
+= snprintf(page
+ len
, count
- len
,
1099 for(i
=0;i
<16 && n
<=max
;i
++,n
++)
1100 len
+= snprintf(page
+ len
, count
- len
,
1101 "%2x ",read_phy_ofdm(dev
,n
));
1103 // printk("%2x ",read_nic_byte(dev,n));
1105 len
+= snprintf(page
+ len
, count
- len
,"\n");
1116 static int proc_get_stats_hw(char *page
, char **start
,
1117 off_t offset
, int count
,
1118 int *eof
, void *data
)
1120 struct net_device
*dev
= data
;
1121 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
1125 len
+= snprintf(page
+ len
, count
- len
,
1129 priv
->stats
.shints
);
1136 static int proc_get_stats_tx(char *page
, char **start
,
1137 off_t offset
, int count
,
1138 int *eof
, void *data
)
1140 struct net_device
*dev
= data
;
1141 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
1145 len
+= snprintf(page
+ len
, count
- len
,
1146 "TX VI priority ok int: %lu\n"
1147 "TX VI priority error int: %lu\n"
1148 "TX VO priority ok int: %lu\n"
1149 "TX VO priority error int: %lu\n"
1150 "TX BE priority ok int: %lu\n"
1151 "TX BE priority error int: %lu\n"
1152 "TX BK priority ok int: %lu\n"
1153 "TX BK priority error int: %lu\n"
1154 "TX MANAGE priority ok int: %lu\n"
1155 "TX MANAGE priority error int: %lu\n"
1156 "TX BEACON priority ok int: %lu\n"
1157 "TX BEACON priority error int: %lu\n"
1158 // "TX high priority ok int: %lu\n"
1159 // "TX high priority failed error int: %lu\n"
1160 "TX queue resume: %lu\n"
1161 "TX queue stopped?: %d\n"
1162 "TX fifo overflow: %lu\n"
1163 // "TX beacon: %lu\n"
1168 // "TX HW queue: %d\n"
1169 "TX VI dropped: %lu\n"
1170 "TX VO dropped: %lu\n"
1171 "TX BE dropped: %lu\n"
1172 "TX BK dropped: %lu\n"
1173 "TX total data packets %lu\n",
1174 // "TX beacon aborted: %lu\n",
1175 priv
->stats
.txviokint
,
1176 priv
->stats
.txvierr
,
1177 priv
->stats
.txvookint
,
1178 priv
->stats
.txvoerr
,
1179 priv
->stats
.txbeokint
,
1180 priv
->stats
.txbeerr
,
1181 priv
->stats
.txbkokint
,
1182 priv
->stats
.txbkerr
,
1183 priv
->stats
.txmanageokint
,
1184 priv
->stats
.txmanageerr
,
1185 priv
->stats
.txbeaconokint
,
1186 priv
->stats
.txbeaconerr
,
1187 // priv->stats.txhpokint,
1188 // priv->stats.txhperr,
1189 priv
->stats
.txresumed
,
1190 netif_queue_stopped(dev
),
1191 priv
->stats
.txoverflow
,
1192 // priv->stats.txbeacon,
1193 atomic_read(&(priv
->tx_pending
[VI_PRIORITY
])),
1194 atomic_read(&(priv
->tx_pending
[VO_PRIORITY
])),
1195 atomic_read(&(priv
->tx_pending
[BE_PRIORITY
])),
1196 atomic_read(&(priv
->tx_pending
[BK_PRIORITY
])),
1197 // read_nic_byte(dev, TXFIFOCOUNT),
1198 priv
->stats
.txvidrop
,
1199 priv
->stats
.txvodrop
,
1200 priv
->stats
.txbedrop
,
1201 priv
->stats
.txbkdrop
,
1202 priv
->stats
.txdatapkt
1203 // priv->stats.txbeaconerr
1212 static int proc_get_stats_rx(char *page
, char **start
,
1213 off_t offset
, int count
,
1214 int *eof
, void *data
)
1216 struct net_device
*dev
= data
;
1217 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
1221 len
+= snprintf(page
+ len
, count
- len
,
1223 "RX urb status error: %lu\n"
1224 "RX invalid urb error: %lu\n",
1225 priv
->stats
.rxoktotal
,
1226 priv
->stats
.rxstaterr
,
1227 priv
->stats
.rxurberr
);
1233 void rtl8192_proc_module_init(void)
1235 RT_TRACE(COMP_INIT
, "Initializing proc filesystem");
1236 rtl8192_proc
=create_proc_entry(RTL819xU_MODULE_NAME
, S_IFDIR
, init_net
.proc_net
);
1240 void rtl8192_proc_module_remove(void)
1242 remove_proc_entry(RTL819xU_MODULE_NAME
, init_net
.proc_net
);
1246 void rtl8192_proc_remove_one(struct net_device
*dev
)
1248 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
1251 if (priv
->dir_dev
) {
1252 // remove_proc_entry("stats-hw", priv->dir_dev);
1253 remove_proc_entry("stats-tx", priv
->dir_dev
);
1254 remove_proc_entry("stats-rx", priv
->dir_dev
);
1255 // remove_proc_entry("stats-ieee", priv->dir_dev);
1256 remove_proc_entry("stats-ap", priv
->dir_dev
);
1257 remove_proc_entry("registers", priv
->dir_dev
);
1258 remove_proc_entry("registers-1", priv
->dir_dev
);
1259 remove_proc_entry("registers-2", priv
->dir_dev
);
1260 remove_proc_entry("registers-8", priv
->dir_dev
);
1261 remove_proc_entry("registers-9", priv
->dir_dev
);
1262 remove_proc_entry("registers-a", priv
->dir_dev
);
1263 remove_proc_entry("registers-b", priv
->dir_dev
);
1264 remove_proc_entry("registers-c", priv
->dir_dev
);
1265 remove_proc_entry("registers-d", priv
->dir_dev
);
1266 remove_proc_entry("registers-e", priv
->dir_dev
);
1267 // remove_proc_entry("cck-registers",priv->dir_dev);
1268 // remove_proc_entry("ofdm-registers",priv->dir_dev);
1269 //remove_proc_entry(dev->name, rtl8192_proc);
1270 remove_proc_entry("wlan0", rtl8192_proc
);
1271 priv
->dir_dev
= NULL
;
1276 void rtl8192_proc_init_one(struct net_device
*dev
)
1278 struct proc_dir_entry
*e
;
1279 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
1280 priv
->dir_dev
= create_proc_entry(dev
->name
,
1281 S_IFDIR
| S_IRUGO
| S_IXUGO
,
1283 if (!priv
->dir_dev
) {
1284 RT_TRACE(COMP_ERR
, "Unable to initialize /proc/net/rtl8192/%s\n",
1289 e
= create_proc_read_entry("stats-hw", S_IFREG
| S_IRUGO
,
1290 priv
->dir_dev
, proc_get_stats_hw
, dev
);
1293 DMESGE("Unable to initialize "
1294 "/proc/net/rtl8192/%s/stats-hw\n",
1298 e
= create_proc_read_entry("stats-rx", S_IFREG
| S_IRUGO
,
1299 priv
->dir_dev
, proc_get_stats_rx
, dev
);
1302 RT_TRACE(COMP_ERR
,"Unable to initialize "
1303 "/proc/net/rtl8192/%s/stats-rx\n",
1308 e
= create_proc_read_entry("stats-tx", S_IFREG
| S_IRUGO
,
1309 priv
->dir_dev
, proc_get_stats_tx
, dev
);
1312 RT_TRACE(COMP_ERR
, "Unable to initialize "
1313 "/proc/net/rtl8192/%s/stats-tx\n",
1317 e
= create_proc_read_entry("stats-ieee", S_IFREG
| S_IRUGO
,
1318 priv
->dir_dev
, proc_get_stats_ieee
, dev
);
1321 DMESGE("Unable to initialize "
1322 "/proc/net/rtl8192/%s/stats-ieee\n",
1328 e
= create_proc_read_entry("stats-ap", S_IFREG
| S_IRUGO
,
1329 priv
->dir_dev
, proc_get_stats_ap
, dev
);
1332 RT_TRACE(COMP_ERR
, "Unable to initialize "
1333 "/proc/net/rtl8192/%s/stats-ap\n",
1337 e
= create_proc_read_entry("registers", S_IFREG
| S_IRUGO
,
1338 priv
->dir_dev
, proc_get_registers
, dev
);
1340 RT_TRACE(COMP_ERR
, "Unable to initialize "
1341 "/proc/net/rtl8192/%s/registers\n",
1345 e
= create_proc_read_entry("registers-1", S_IFREG
| S_IRUGO
,
1346 priv
->dir_dev
, proc_get_registers_1
, dev
);
1348 RT_TRACE(COMP_ERR
, "Unable to initialize "
1349 "/proc/net/rtl8192/%s/registers-1\n",
1352 e
= create_proc_read_entry("registers-2", S_IFREG
| S_IRUGO
,
1353 priv
->dir_dev
, proc_get_registers_2
, dev
);
1355 RT_TRACE(COMP_ERR
, "Unable to initialize "
1356 "/proc/net/rtl8192/%s/registers-2\n",
1359 e
= create_proc_read_entry("registers-8", S_IFREG
| S_IRUGO
,
1360 priv
->dir_dev
, proc_get_registers_8
, dev
);
1362 RT_TRACE(COMP_ERR
, "Unable to initialize "
1363 "/proc/net/rtl8192/%s/registers-8\n",
1366 e
= create_proc_read_entry("registers-9", S_IFREG
| S_IRUGO
,
1367 priv
->dir_dev
, proc_get_registers_9
, dev
);
1369 RT_TRACE(COMP_ERR
, "Unable to initialize "
1370 "/proc/net/rtl8192/%s/registers-9\n",
1373 e
= create_proc_read_entry("registers-a", S_IFREG
| S_IRUGO
,
1374 priv
->dir_dev
, proc_get_registers_a
, dev
);
1376 RT_TRACE(COMP_ERR
, "Unable to initialize "
1377 "/proc/net/rtl8192/%s/registers-a\n",
1380 e
= create_proc_read_entry("registers-b", S_IFREG
| S_IRUGO
,
1381 priv
->dir_dev
, proc_get_registers_b
, dev
);
1383 RT_TRACE(COMP_ERR
, "Unable to initialize "
1384 "/proc/net/rtl8192/%s/registers-b\n",
1387 e
= create_proc_read_entry("registers-c", S_IFREG
| S_IRUGO
,
1388 priv
->dir_dev
, proc_get_registers_c
, dev
);
1390 RT_TRACE(COMP_ERR
, "Unable to initialize "
1391 "/proc/net/rtl8192/%s/registers-c\n",
1394 e
= create_proc_read_entry("registers-d", S_IFREG
| S_IRUGO
,
1395 priv
->dir_dev
, proc_get_registers_d
, dev
);
1397 RT_TRACE(COMP_ERR
, "Unable to initialize "
1398 "/proc/net/rtl8192/%s/registers-d\n",
1401 e
= create_proc_read_entry("registers-e", S_IFREG
| S_IRUGO
,
1402 priv
->dir_dev
, proc_get_registers_e
, dev
);
1404 RT_TRACE(COMP_ERR
, "Unable to initialize "
1405 "/proc/net/rtl8192/%s/registers-e\n",
1410 e
= create_proc_read_entry("cck-registers", S_IFREG
| S_IRUGO
,
1411 priv
->dir_dev
, proc_get_cck_reg
, dev
);
1413 RT_TRACE(COMP_ERR
, "Unable to initialize "
1414 "/proc/net/rtl8192/%s/cck-registers\n",
1418 e
= create_proc_read_entry("ofdm-registers", S_IFREG
| S_IRUGO
,
1419 priv
->dir_dev
, proc_get_ofdm_reg
, dev
);
1421 RT_TRACE(COMP_ERR
, "Unable to initialize "
1422 "/proc/net/rtl8192/%s/ofdm-registers\n",
1427 /****************************************************************************
1428 -----------------------------MISC STUFF-------------------------
1429 *****************************************************************************/
1431 /* this is only for debugging */
1432 void print_buffer(u32
*buffer
, int len
)
1435 u8
*buf
=(u8
*)buffer
;
1437 printk("ASCII BUFFER DUMP (len: %x):\n",len
);
1440 printk("%c",buf
[i
]);
1442 printk("\nBINARY BUFFER DUMP (len: %x):\n",len
);
1445 printk("%x",buf
[i
]);
1450 //short check_nic_enough_desc(struct net_device *dev, priority_t priority)
1451 short check_nic_enough_desc(struct net_device
*dev
,int queue_index
)
1453 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1454 int used
= atomic_read(&priv
->tx_pending
[queue_index
]);
1456 return (used
< MAX_TX_URB
);
1459 void tx_timeout(struct net_device
*dev
)
1461 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1462 //rtl8192_commit(dev);
1464 schedule_work(&priv
->reset_wq
);
1465 //DMESG("TXTIMEOUT");
1469 /* this is only for debug */
1470 void dump_eprom(struct net_device
*dev
)
1474 RT_TRACE(COMP_EPROM
, "EEPROM addr %x : %x", i
, eprom_read(dev
,i
));
1477 /* this is only for debug */
1478 void rtl8192_dump_reg(struct net_device
*dev
)
1484 RT_TRACE(COMP_PHY
, "Dumping NIC register map");
1488 printk( "\nD: %2x> ", n
);
1489 for(i
=0;i
<16 && n
<=max
;i
++,n
++)
1490 printk("%2x ",read_nic_byte(dev
,n
));
1495 /****************************************************************************
1496 ------------------------------HW STUFF---------------------------
1497 *****************************************************************************/
1500 void rtl8192_irq_enable(struct net_device
*dev
)
1502 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
1503 //priv->irq_enabled = 1;
1505 write_nic_word(dev,INTA_MASK,INTA_RXOK | INTA_RXDESCERR | INTA_RXOVERFLOW |\
1506 INTA_TXOVERFLOW | INTA_HIPRIORITYDESCERR | INTA_HIPRIORITYDESCOK |\
1507 INTA_NORMPRIORITYDESCERR | INTA_NORMPRIORITYDESCOK |\
1508 INTA_LOWPRIORITYDESCERR | INTA_LOWPRIORITYDESCOK | INTA_TIMEOUT);
1510 write_nic_word(dev
,INTA_MASK
, priv
->irq_mask
);
1514 void rtl8192_irq_disable(struct net_device
*dev
)
1516 // struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
1518 write_nic_word(dev
,INTA_MASK
,0);
1519 force_pci_posting(dev
);
1520 // priv->irq_enabled = 0;
1524 void rtl8192_set_mode(struct net_device
*dev
,int mode
)
1527 ecmd
=read_nic_byte(dev
, EPROM_CMD
);
1528 ecmd
=ecmd
&~ EPROM_CMD_OPERATING_MODE_MASK
;
1529 ecmd
=ecmd
| (mode
<<EPROM_CMD_OPERATING_MODE_SHIFT
);
1530 ecmd
=ecmd
&~ (1<<EPROM_CS_SHIFT
);
1531 ecmd
=ecmd
&~ (1<<EPROM_CK_SHIFT
);
1532 write_nic_byte(dev
, EPROM_CMD
, ecmd
);
1536 void rtl8192_update_msr(struct net_device
*dev
)
1538 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1541 msr
= read_nic_byte(dev
, MSR
);
1542 msr
&= ~ MSR_LINK_MASK
;
1544 /* do not change in link_state != WLAN_LINK_ASSOCIATED.
1545 * msr must be updated if the state is ASSOCIATING.
1546 * this is intentional and make sense for ad-hoc and
1547 * master (see the create BSS/IBSS func)
1549 if (priv
->ieee80211
->state
== IEEE80211_LINKED
){
1551 if (priv
->ieee80211
->iw_mode
== IW_MODE_INFRA
)
1552 msr
|= (MSR_LINK_MANAGED
<<MSR_LINK_SHIFT
);
1553 else if (priv
->ieee80211
->iw_mode
== IW_MODE_ADHOC
)
1554 msr
|= (MSR_LINK_ADHOC
<<MSR_LINK_SHIFT
);
1555 else if (priv
->ieee80211
->iw_mode
== IW_MODE_MASTER
)
1556 msr
|= (MSR_LINK_MASTER
<<MSR_LINK_SHIFT
);
1559 msr
|= (MSR_LINK_NONE
<<MSR_LINK_SHIFT
);
1561 write_nic_byte(dev
, MSR
, msr
);
1564 void rtl8192_set_chan(struct net_device
*dev
,short ch
)
1566 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
1568 RT_TRACE(COMP_CH
, "=====>%s()====ch:%d\n", __FUNCTION__
, ch
);
1569 //printk("=====>%s()====ch:%d\n", __FUNCTION__, ch);
1572 if(priv
->ieee80211
->iw_mode
== IW_MODE_ADHOC
||
1573 priv
->ieee80211
->iw_mode
== IW_MODE_MASTER
){
1575 priv
->ieee80211
->link_state
= WLAN_LINK_ASSOCIATED
;
1576 priv
->ieee80211
->master_chan
= ch
;
1577 rtl8192_update_beacon_ch(dev
);
1581 /* this hack should avoid frame TX during channel setting*/
1584 // tx = read_nic_dword(dev,TX_CONF);
1585 // tx &= ~TX_LOOPBACK_MASK;
1588 // write_nic_dword(dev,TX_CONF, tx |( TX_LOOPBACK_MAC<<TX_LOOPBACK_SHIFT));
1590 //need to implement rf set channel here WB
1592 if (priv
->rf_set_chan
)
1593 priv
->rf_set_chan(dev
,priv
->chan
);
1595 // write_nic_dword(dev,TX_CONF,tx | (TX_LOOPBACK_NONE<<TX_LOOPBACK_SHIFT));
1599 static void rtl8192_rx_isr(struct urb
*urb
);
1601 u32
get_rxpacket_shiftbytes_819xusb(struct ieee80211_rx_stats
*pstats
)
1604 return (sizeof(rx_desc_819x_usb
) + pstats
->RxDrvInfoSize
1605 + pstats
->RxBufShift
);
1608 static int rtl8192_rx_initiate(struct net_device
*dev
)
1610 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
1612 struct sk_buff
*skb
;
1613 struct rtl8192_rx_info
*info
;
1615 /* nomal packet rx procedure */
1616 while (skb_queue_len(&priv
->rx_queue
) < MAX_RX_URB
) {
1617 skb
= __dev_alloc_skb(RX_URB_SIZE
, GFP_KERNEL
);
1620 entry
= usb_alloc_urb(0, GFP_KERNEL
);
1625 // printk("nomal packet IN request!\n");
1626 usb_fill_bulk_urb(entry
, priv
->udev
,
1627 usb_rcvbulkpipe(priv
->udev
, 3), skb
->tail
,
1628 RX_URB_SIZE
, rtl8192_rx_isr
, skb
);
1629 info
= (struct rtl8192_rx_info
*) skb
->cb
;
1632 info
->out_pipe
= 3; //denote rx normal packet queue
1633 skb_queue_tail(&priv
->rx_queue
, skb
);
1634 usb_submit_urb(entry
, GFP_KERNEL
);
1637 /* command packet rx procedure */
1638 while (skb_queue_len(&priv
->rx_queue
) < MAX_RX_URB
+ 3) {
1639 // printk("command packet IN request!\n");
1640 skb
= __dev_alloc_skb(RX_URB_SIZE
,GFP_KERNEL
);
1643 entry
= usb_alloc_urb(0, GFP_KERNEL
);
1648 usb_fill_bulk_urb(entry
, priv
->udev
,
1649 usb_rcvbulkpipe(priv
->udev
, 9), skb
->tail
,
1650 RX_URB_SIZE
, rtl8192_rx_isr
, skb
);
1651 info
= (struct rtl8192_rx_info
*) skb
->cb
;
1654 info
->out_pipe
= 9; //denote rx cmd packet queue
1655 skb_queue_tail(&priv
->rx_queue
, skb
);
1656 usb_submit_urb(entry
, GFP_KERNEL
);
1662 void rtl8192_set_rxconf(struct net_device
*dev
)
1664 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
1667 rxconf
=read_nic_dword(dev
,RCR
);
1668 rxconf
= rxconf
&~ MAC_FILTER_MASK
;
1669 rxconf
= rxconf
| RCR_AMF
;
1670 rxconf
= rxconf
| RCR_ADF
;
1671 rxconf
= rxconf
| RCR_AB
;
1672 rxconf
= rxconf
| RCR_AM
;
1673 //rxconf = rxconf | RCR_ACF;
1675 if (dev
->flags
& IFF_PROMISC
) {DMESG ("NIC in promisc mode");}
1677 if(priv
->ieee80211
->iw_mode
== IW_MODE_MONITOR
|| \
1678 dev
->flags
& IFF_PROMISC
){
1679 rxconf
= rxconf
| RCR_AAP
;
1680 } /*else if(priv->ieee80211->iw_mode == IW_MODE_MASTER){
1681 rxconf = rxconf | (1<<ACCEPT_ALLMAC_FRAME_SHIFT);
1682 rxconf = rxconf | (1<<RX_CHECK_BSSID_SHIFT);
1684 rxconf
= rxconf
| RCR_APM
;
1685 rxconf
= rxconf
| RCR_CBSSID
;
1689 if(priv
->ieee80211
->iw_mode
== IW_MODE_MONITOR
){
1690 rxconf
= rxconf
| RCR_AICV
;
1691 rxconf
= rxconf
| RCR_APWRMGT
;
1694 if( priv
->crcmon
== 1 && priv
->ieee80211
->iw_mode
== IW_MODE_MONITOR
)
1695 rxconf
= rxconf
| RCR_ACRC32
;
1698 rxconf
= rxconf
&~ RX_FIFO_THRESHOLD_MASK
;
1699 rxconf
= rxconf
| (RX_FIFO_THRESHOLD_NONE
<<RX_FIFO_THRESHOLD_SHIFT
);
1700 rxconf
= rxconf
&~ MAX_RX_DMA_MASK
;
1701 rxconf
= rxconf
| ((u32
)7<<RCR_MXDMA_OFFSET
);
1703 // rxconf = rxconf | (1<<RX_AUTORESETPHY_SHIFT);
1704 rxconf
= rxconf
| RCR_ONLYERLPKT
;
1706 // rxconf = rxconf &~ RCR_CS_MASK;
1707 // rxconf = rxconf | (1<<RCR_CS_SHIFT);
1709 write_nic_dword(dev
, RCR
, rxconf
);
1712 DMESG("rxconf: %x %x",rxconf
,read_nic_dword(dev
,RCR
));
1715 //wait to be removed
1716 void rtl8192_rx_enable(struct net_device
*dev
)
1720 //struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
1722 rtl8192_rx_initiate(dev
);
1724 // rtl8192_set_rxconf(dev);
1726 if(NIC_8187
== priv
->card_8187
) {
1727 cmd
=read_nic_byte(dev
,CMD
);
1728 write_nic_byte(dev
,CMD
,cmd
| (1<<CMD_RX_ENABLE_SHIFT
));
1731 //write_nic_dword(dev, RX_CONF, priv->ReceiveConfig);
1737 void rtl8192_tx_enable(struct net_device
*dev
)
1743 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
1745 // priv->TransmitConfig |= (TX_LOOPBACK_BASEBAND<<TX_LOOPBACK_SHIFT);
1746 if(NIC_8187B
== priv
->card_8187
){
1747 write_nic_dword(dev
, TX_CONF
, priv
->TransmitConfig
);
1748 byte
= read_nic_byte(dev
, MSR
);
1749 byte
|= MSR_LINK_ENEDCA
;
1750 write_nic_byte(dev
, MSR
, byte
);
1752 byte
= read_nic_byte(dev
,CW_CONF
);
1753 byte
&= ~(1<<CW_CONF_PERPACKET_CW_SHIFT
);
1754 byte
&= ~(1<<CW_CONF_PERPACKET_RETRY_SHIFT
);
1755 write_nic_byte(dev
, CW_CONF
, byte
);
1757 byte
= read_nic_byte(dev
, TX_AGC_CTL
);
1758 byte
&= ~(1<<TX_AGC_CTL_PERPACKET_GAIN_SHIFT
);
1759 byte
&= ~(1<<TX_AGC_CTL_PERPACKET_ANTSEL_SHIFT
);
1760 byte
&= ~(1<<TX_AGC_CTL_FEEDBACK_ANT
);
1761 write_nic_byte(dev
, TX_AGC_CTL
, byte
);
1763 txconf
= read_nic_dword(dev
,TX_CONF
);
1766 txconf
= txconf
&~ TX_LOOPBACK_MASK
;
1769 txconf
= txconf
| (TX_LOOPBACK_NONE
<<TX_LOOPBACK_SHIFT
);
1771 txconf
= txconf
| (TX_LOOPBACK_BASEBAND
<<TX_LOOPBACK_SHIFT
);
1773 txconf
= txconf
&~ TCR_SRL_MASK
;
1774 txconf
= txconf
&~ TCR_LRL_MASK
;
1776 txconf
= txconf
| (priv
->retry_data
<<TX_LRLRETRY_SHIFT
); // long
1777 txconf
= txconf
| (priv
->retry_rts
<<TX_SRLRETRY_SHIFT
); // short
1779 txconf
= txconf
&~ (1<<TX_NOCRC_SHIFT
);
1781 txconf
= txconf
&~ TCR_MXDMA_MASK
;
1782 txconf
= txconf
| (TCR_MXDMA_2048
<<TCR_MXDMA_SHIFT
);
1784 txconf
= txconf
| TCR_DISReqQsize
;
1785 txconf
= txconf
| TCR_DISCW
;
1786 txconf
= txconf
&~ TCR_SWPLCPLEN
;
1788 txconf
=txconf
| (1<<TX_NOICV_SHIFT
);
1790 write_nic_dword(dev
,TX_CONF
,txconf
);
1793 DMESG("txconf: %x %x",txconf
,read_nic_dword(dev
,TX_CONF
));
1796 cmd
=read_nic_byte(dev
,CMD
);
1797 write_nic_byte(dev
,CMD
,cmd
| (1<<CMD_TX_ENABLE_SHIFT
));
1803 void rtl8192_beacon_tx_enable(struct net_device
*dev
)
1805 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
1806 priv
->dma_poll_mask
&=~(1<<TX_DMA_STOP_BEACON_SHIFT
);
1807 rtl8192_set_mode(dev
,EPROM_CMD_CONFIG
);
1808 write_nic_byte(dev
,TX_DMA_POLLING
,priv
->dma_poll_mask
);
1809 rtl8192_set_mode(dev
,EPROM_CMD_NORMAL
);
1814 _disable(struct net_device
*dev
)
1816 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
1817 priv
->dma_poll_mask
|= (1<<TX_DMA_STOP_BEACON_SHIFT
);
1818 rtl8192_set_mode(dev
,EPROM_CMD_CONFIG
);
1819 write_nic_byte(dev
,TX_DMA_POLLING
,priv
->dma_poll_mask
);
1820 rtl8192_set_mode(dev
,EPROM_CMD_NORMAL
);
1826 void rtl8192_rtx_disable(struct net_device
*dev
)
1829 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1830 struct sk_buff
*skb
;
1831 struct rtl8192_rx_info
*info
;
1833 cmd
=read_nic_byte(dev
,CMDR
);
1834 write_nic_byte(dev
, CMDR
, cmd
&~ \
1836 force_pci_posting(dev
);
1839 while ((skb
= __skb_dequeue(&priv
->rx_queue
))) {
1840 info
= (struct rtl8192_rx_info
*) skb
->cb
;
1844 usb_kill_urb(info
->urb
);
1848 if (skb_queue_len(&priv
->skb_queue
)) {
1849 printk(KERN_WARNING
"skb_queue not empty\n");
1852 skb_queue_purge(&priv
->skb_queue
);
1857 int alloc_tx_beacon_desc_ring(struct net_device
*dev
, int count
)
1862 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
1864 priv
->txbeaconring
= (u32
*)pci_alloc_consistent(priv
->pdev
,
1865 sizeof(u32
)*8*count
,
1866 &priv
->txbeaconringdma
);
1867 if (!priv
->txbeaconring
) return -1;
1868 for (tmp
=priv
->txbeaconring
,i
=0;i
<count
;i
++){
1869 *tmp
= *tmp
&~ (1<<31); // descriptor empty, owned by the drv
1871 *(tmp+2) = (u32)dma_tmp;
1875 *(tmp
+4) = (u32
)priv
->txbeaconringdma
+((i
+1)*8*4);
1877 *(tmp
+4) = (u32
)priv
->txbeaconringdma
;
1886 void rtl8192_reset(struct net_device
*dev
)
1889 //struct r8192_priv *priv = ieee80211_priv(dev);
1893 /* make sure the analog power is on before
1894 * reset, otherwise reset may fail
1897 if(NIC_8187
== priv
->card_8187
) {
1898 rtl8192_set_anaparam(dev
, RTL8225_ANAPARAM_ON
);
1899 rtl8185_set_anaparam2(dev
, RTL8225_ANAPARAM2_ON
);
1900 rtl8192_irq_disable(dev
);
1902 write_nic_byte_E(dev
,0x18,0x10);
1903 write_nic_byte_E(dev
,0x18,0x11);
1904 write_nic_byte_E(dev
,0x18,0x00);
1908 printk("=====>reset?\n");
1910 cr
=read_nic_byte(dev
,CMD
);
1912 cr
= cr
| (1<<CMD_RST_SHIFT
);
1913 write_nic_byte(dev
,CMD
,cr
);
1915 force_pci_posting(dev
);
1919 if(read_nic_byte(dev
,CMD
) & (1<<CMD_RST_SHIFT
))
1920 RT_TRACE(COMP_ERR
, "Card reset timeout!\n");
1922 RT_TRACE(COMP_DOWN
, "Card successfully reset\n");
1925 if(NIC_8187
== priv
->card_8187
) {
1927 printk("This is RTL8187 Reset procedure\n");
1928 rtl8192_set_mode(dev
,EPROM_CMD_LOAD
);
1929 force_pci_posting(dev
);
1932 /* after the eeprom load cycle, make sure we have
1935 rtl8192_set_anaparam(dev
, RTL8225_ANAPARAM_ON
);
1936 rtl8185_set_anaparam2(dev
, RTL8225_ANAPARAM2_ON
);
1940 printk("This is RTL8187B Reset procedure\n");
1944 inline u16
ieeerate2rtlrate(int rate
)
1976 static u16 rtl_rate
[] = {10,20,55,110,60,90,120,180,240,360,480,540};
1977 inline u16
rtl8192_rate2rate(short rate
)
1979 if (rate
>11) return 0;
1980 return rtl_rate
[rate
];
1983 static void rtl8192_rx_isr(struct urb
*urb
)
1985 struct sk_buff
*skb
= (struct sk_buff
*) urb
->context
;
1986 struct rtl8192_rx_info
*info
= (struct rtl8192_rx_info
*)skb
->cb
;
1987 struct net_device
*dev
= info
->dev
;
1988 struct r8192_priv
*priv
= ieee80211_priv(dev
);
1989 int out_pipe
= info
->out_pipe
;
1993 if (unlikely(urb
->status
)) {
1995 priv
->stats
.rxstaterr
++;
1996 priv
->ieee80211
->stats
.rx_errors
++;
1998 // printk("%s():rx status err\n",__FUNCTION__);
2002 skb_unlink(skb
, &priv
->rx_queue
);
2003 skb_put(skb
, urb
->actual_length
);
2005 skb_queue_tail(&priv
->skb_queue
, skb
);
2006 tasklet_schedule(&priv
->irq_rx_tasklet
);
2008 skb
= dev_alloc_skb(RX_URB_SIZE
);
2009 if (unlikely(!skb
)) {
2011 printk("%s():can,t alloc skb\n",__FUNCTION__
);
2012 /* TODO check rx queue length and refill *somewhere* */
2016 usb_fill_bulk_urb(urb
, priv
->udev
,
2017 usb_rcvbulkpipe(priv
->udev
, out_pipe
), skb
->tail
,
2018 RX_URB_SIZE
, rtl8192_rx_isr
, skb
);
2020 info
= (struct rtl8192_rx_info
*) skb
->cb
;
2023 info
->out_pipe
= out_pipe
;
2025 urb
->transfer_buffer
= skb
->tail
;
2027 skb_queue_tail(&priv
->rx_queue
, skb
);
2028 err
= usb_submit_urb(urb
, GFP_ATOMIC
);
2029 if(err
&& err
!= EPERM
)
2030 printk("can not submit rxurb, err is %x,URB status is %x\n",err
,urb
->status
);
2034 rtl819xusb_rx_command_packet(
2035 struct net_device
*dev
,
2036 struct ieee80211_rx_stats
*pstats
2041 //RT_TRACE(COMP_RECV, DBG_TRACE, ("---> RxCommandPacketHandle819xUsb()\n"));
2043 status
= cmpk_message_handle_rx(dev
, pstats
);
2046 DMESG("rxcommandpackethandle819xusb: It is a command packet\n");
2050 //RT_TRACE(COMP_RECV, DBG_TRACE, ("RxCommandPacketHandle819xUsb: It is not a command packet\n"));
2053 //RT_TRACE(COMP_RECV, DBG_TRACE, ("<--- RxCommandPacketHandle819xUsb()\n"));
2058 void rtl8192_tx_queues_stop(struct net_device
*dev
)
2060 //struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
2061 u8 dma_poll_mask
= (1<<TX_DMA_STOP_LOWPRIORITY_SHIFT
);
2062 dma_poll_mask
|= (1<<TX_DMA_STOP_HIPRIORITY_SHIFT
);
2063 dma_poll_mask
|= (1<<TX_DMA_STOP_NORMPRIORITY_SHIFT
);
2064 dma_poll_mask
|= (1<<TX_DMA_STOP_BEACON_SHIFT
);
2066 rtl8192_set_mode(dev
,EPROM_CMD_CONFIG
);
2067 write_nic_byte(dev
,TX_DMA_POLLING
,dma_poll_mask
);
2068 rtl8192_set_mode(dev
,EPROM_CMD_NORMAL
);
2072 void rtl8192_data_hard_stop(struct net_device
*dev
)
2076 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
2077 priv
->dma_poll_mask
|= (1<<TX_DMA_STOP_LOWPRIORITY_SHIFT
);
2078 rtl8192_set_mode(dev
,EPROM_CMD_CONFIG
);
2079 write_nic_byte(dev
,TX_DMA_POLLING
,priv
->dma_poll_mask
);
2080 rtl8192_set_mode(dev
,EPROM_CMD_NORMAL
);
2085 void rtl8192_data_hard_resume(struct net_device
*dev
)
2089 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
2090 priv
->dma_poll_mask
&= ~(1<<TX_DMA_STOP_LOWPRIORITY_SHIFT
);
2091 rtl8192_set_mode(dev
,EPROM_CMD_CONFIG
);
2092 write_nic_byte(dev
,TX_DMA_POLLING
,priv
->dma_poll_mask
);
2093 rtl8192_set_mode(dev
,EPROM_CMD_NORMAL
);
2097 /* this function TX data frames when the ieee80211 stack requires this.
2098 * It checks also if we need to stop the ieee tx queue, eventually do it
2100 void rtl8192_hard_data_xmit(struct sk_buff
*skb
, struct net_device
*dev
, int rate
)
2102 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
2104 unsigned long flags
;
2105 cb_desc
*tcb_desc
= (cb_desc
*)(skb
->cb
+ MAX_DEV_ADDR_SIZE
);
2106 u8 queue_index
= tcb_desc
->queue_index
;
2108 /* shall not be referred by command packet */
2109 assert(queue_index
!= TXCMD_QUEUE
);
2111 spin_lock_irqsave(&priv
->tx_lock
,flags
);
2113 memcpy((unsigned char *)(skb
->cb
),&dev
,sizeof(dev
));
2114 // tcb_desc->RATRIndex = 7;
2115 // tcb_desc->bTxDisableRateFallBack = 1;
2116 // tcb_desc->bTxUseDriverAssingedRate = 1;
2117 tcb_desc
->bTxEnableFwCalcDur
= 1;
2118 skb_push(skb
, priv
->ieee80211
->tx_headroom
);
2119 ret
= priv
->ops
->rtl819x_tx(dev
, skb
);
2121 //priv->ieee80211->stats.tx_bytes+=(skb->len - priv->ieee80211->tx_headroom);
2122 //priv->ieee80211->stats.tx_packets++;
2124 spin_unlock_irqrestore(&priv
->tx_lock
,flags
);
2130 /* This is a rough attempt to TX a frame
2131 * This is called by the ieee 80211 stack to TX management frames.
2132 * If the ring is full packet are dropped (for data frame the queue
2133 * is stopped before this can happen).
2135 int rtl8192_hard_start_xmit(struct sk_buff
*skb
,struct net_device
*dev
)
2137 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
2139 unsigned long flags
;
2140 cb_desc
*tcb_desc
= (cb_desc
*)(skb
->cb
+ MAX_DEV_ADDR_SIZE
);
2141 u8 queue_index
= tcb_desc
->queue_index
;
2144 spin_lock_irqsave(&priv
->tx_lock
,flags
);
2146 memcpy((unsigned char *)(skb
->cb
),&dev
,sizeof(dev
));
2147 if(queue_index
== TXCMD_QUEUE
) {
2148 skb_push(skb
, USB_HWDESC_HEADER_LEN
);
2149 priv
->ops
->rtl819x_tx_cmd(dev
, skb
);
2151 spin_unlock_irqrestore(&priv
->tx_lock
,flags
);
2154 skb_push(skb
, priv
->ieee80211
->tx_headroom
);
2155 ret
= priv
->ops
->rtl819x_tx(dev
, skb
);
2158 spin_unlock_irqrestore(&priv
->tx_lock
,flags
);
2164 void rtl8192_try_wake_queue(struct net_device
*dev
, int pri
);
2167 static void rtl8192_tx_isr(struct urb
*tx_urb
)
2169 struct sk_buff
*skb
= (struct sk_buff
*)tx_urb
->context
;
2170 struct net_device
*dev
= NULL
;
2171 struct r8192_priv
*priv
= NULL
;
2172 cb_desc
*tcb_desc
= (cb_desc
*)(skb
->cb
+ MAX_DEV_ADDR_SIZE
);
2173 u8 queue_index
= tcb_desc
->queue_index
;
2174 // bool bToSend0Byte;
2175 // u16 BufLen = skb->len;
2177 memcpy(&dev
,(struct net_device
*)(skb
->cb
),sizeof(struct net_device
*));
2178 priv
= ieee80211_priv(dev
);
2180 if(tcb_desc
->queue_index
!= TXCMD_QUEUE
) {
2181 if(tx_urb
->status
== 0) {
2182 // dev->trans_start = jiffies;
2183 // As act as station mode, destion shall be unicast address.
2184 //priv->ieee80211->stats.tx_bytes+=(skb->len - priv->ieee80211->tx_headroom);
2185 //priv->ieee80211->stats.tx_packets++;
2186 priv
->stats
.txoktotal
++;
2187 priv
->ieee80211
->LinkDetectInfo
.NumTxOkInPeriod
++;
2188 priv
->stats
.txbytesunicast
+= (skb
->len
- priv
->ieee80211
->tx_headroom
);
2190 priv
->ieee80211
->stats
.tx_errors
++;
2191 //priv->stats.txmanageerr++;
2196 /* free skb and tx_urb */
2198 dev_kfree_skb_any(skb
);
2199 usb_free_urb(tx_urb
);
2200 atomic_dec(&priv
->tx_pending
[queue_index
]);
2203 #if 0 //we need to send zero byte packet just after 512 byte(64 byte)packet is transmitted, or we will halt. It will greatly reduced available page in FW, and ruin our throughput. WB 2008.08.27
2204 if(BufLen
> 0 && ((BufLen
% 512 == 0)||(BufLen
% 64 == 0))) {
2205 bToSend0Byte
= true;
2208 bToSend0Byte
= false;
2210 // Note that, we at most handle 1 MPDU to send here, either
2211 // fragment or MPDU in wait queue.
2217 // Handle HW Beacon:
2218 // We had transfer our beacon frame to host controler at this moment.
2221 if(tcb_desc
->tx_queue
== BEACON_QUEUE
)
2223 priv
->bSendingBeacon
= FALSE
;
2228 // Handling the wait queue of command packets.
2229 // For Tx command packets, we must not do TCB fragment because it is not handled right now.
2230 // We must cut the packets to match the size of TX_CMD_PKT before we send it.
2232 if (queue_index
== MGNT_QUEUE
){
2233 if (priv
->ieee80211
->ack_tx_to_ieee
){
2234 if (rtl8192_is_tx_queue_empty(dev
)){
2235 priv
->ieee80211
->ack_tx_to_ieee
= 0;
2236 ieee80211_ps_tx_ack(priv
->ieee80211
, 1);
2240 /* Handle MPDU in wait queue. */
2241 if(queue_index
!= BEACON_QUEUE
) {
2242 /* Don't send data frame during scanning.*/
2243 if((skb_queue_len(&priv
->ieee80211
->skb_waitQ
[queue_index
]) != 0)&&\
2244 (!(priv
->ieee80211
->queue_stop
))) {
2245 if(NULL
!= (skb
= skb_dequeue(&(priv
->ieee80211
->skb_waitQ
[queue_index
]))))
2246 priv
->ieee80211
->softmac_hard_start_xmit(skb
, dev
);
2248 return; //modified by david to avoid further processing AMSDU
2256 RT_TRACE( COMP_SEND
,"HalUsbOutComplete(%d): bToSend0Byte.\n", PipeIndex
);
2259 // In this case, we don't return skb now.
2260 // It will be returned when the 0-byte request completed.
2264 // Bulk out an 0-byte padding transfer.
2266 HalUsbOut0Byte(pAdapter
, PipeIndex
, skb
);
2272 void rtl8192_beacon_stop(struct net_device
*dev
)
2275 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2277 msr
= read_nic_byte(dev
, MSR
);
2278 msrm
= msr
& MSR_LINK_MASK
;
2279 msr2
= msr
& ~MSR_LINK_MASK
;
2281 if(NIC_8192U
== priv
->card_8192
) {
2282 usb_kill_urb(priv
->rx_urb
[MAX_RX_URB
]);
2284 if ((msrm
== (MSR_LINK_ADHOC
<<MSR_LINK_SHIFT
) ||
2285 (msrm
== (MSR_LINK_MASTER
<<MSR_LINK_SHIFT
)))){
2286 write_nic_byte(dev
, MSR
, msr2
| MSR_LINK_NONE
);
2287 write_nic_byte(dev
, MSR
, msr
);
2291 void rtl8192_config_rate(struct net_device
* dev
, u16
* rate_config
)
2293 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2294 struct ieee80211_network
*net
;
2295 u8 i
=0, basic_rate
= 0;
2296 net
= & priv
->ieee80211
->current_network
;
2298 for (i
=0; i
<net
->rates_len
; i
++)
2300 basic_rate
= net
->rates
[i
]&0x7f;
2303 case MGN_1M
: *rate_config
|= RRSR_1M
; break;
2304 case MGN_2M
: *rate_config
|= RRSR_2M
; break;
2305 case MGN_5_5M
: *rate_config
|= RRSR_5_5M
; break;
2306 case MGN_11M
: *rate_config
|= RRSR_11M
; break;
2307 case MGN_6M
: *rate_config
|= RRSR_6M
; break;
2308 case MGN_9M
: *rate_config
|= RRSR_9M
; break;
2309 case MGN_12M
: *rate_config
|= RRSR_12M
; break;
2310 case MGN_18M
: *rate_config
|= RRSR_18M
; break;
2311 case MGN_24M
: *rate_config
|= RRSR_24M
; break;
2312 case MGN_36M
: *rate_config
|= RRSR_36M
; break;
2313 case MGN_48M
: *rate_config
|= RRSR_48M
; break;
2314 case MGN_54M
: *rate_config
|= RRSR_54M
; break;
2317 for (i
=0; i
<net
->rates_ex_len
; i
++)
2319 basic_rate
= net
->rates_ex
[i
]&0x7f;
2322 case MGN_1M
: *rate_config
|= RRSR_1M
; break;
2323 case MGN_2M
: *rate_config
|= RRSR_2M
; break;
2324 case MGN_5_5M
: *rate_config
|= RRSR_5_5M
; break;
2325 case MGN_11M
: *rate_config
|= RRSR_11M
; break;
2326 case MGN_6M
: *rate_config
|= RRSR_6M
; break;
2327 case MGN_9M
: *rate_config
|= RRSR_9M
; break;
2328 case MGN_12M
: *rate_config
|= RRSR_12M
; break;
2329 case MGN_18M
: *rate_config
|= RRSR_18M
; break;
2330 case MGN_24M
: *rate_config
|= RRSR_24M
; break;
2331 case MGN_36M
: *rate_config
|= RRSR_36M
; break;
2332 case MGN_48M
: *rate_config
|= RRSR_48M
; break;
2333 case MGN_54M
: *rate_config
|= RRSR_54M
; break;
2339 #define SHORT_SLOT_TIME 9
2340 #define NON_SHORT_SLOT_TIME 20
2342 void rtl8192_update_cap(struct net_device
* dev
, u16 cap
)
2345 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2346 struct ieee80211_network
*net
= &priv
->ieee80211
->current_network
;
2347 priv
->short_preamble
= cap
& WLAN_CAPABILITY_SHORT_PREAMBLE
;
2349 //LZM MOD 090303 HW_VAR_ACK_PREAMBLE
2354 tmp
= ((priv
->nCur40MhzPrimeSC
) << 5);
2355 if (priv
->short_preamble
)
2357 write_nic_byte(dev
, RRSR
+2, tmp
);
2362 tmp
= priv
->basic_rate
;
2363 if (priv
->short_preamble
)
2364 tmp
|= BRSR_AckShortPmb
;
2365 write_nic_dword(dev
, RRSR
, tmp
);
2369 if (net
->mode
& (IEEE_G
|IEEE_N_24G
))
2372 if ((cap
& WLAN_CAPABILITY_SHORT_SLOT
)&&(!priv
->ieee80211
->pHTInfo
->bCurrentRT2RTLongSlotTime
))
2374 slot_time
= SHORT_SLOT_TIME
;
2376 else //long slot time
2377 slot_time
= NON_SHORT_SLOT_TIME
;
2378 priv
->slot_time
= slot_time
;
2379 write_nic_byte(dev
, SLOT_TIME
, slot_time
);
2383 void rtl8192_net_update(struct net_device
*dev
)
2386 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2387 struct ieee80211_network
*net
;
2388 u16 BcnTimeCfg
= 0, BcnCW
= 6, BcnIFS
= 0xf;
2389 u16 rate_config
= 0;
2390 net
= & priv
->ieee80211
->current_network
;
2392 rtl8192_config_rate(dev
, &rate_config
);
2393 priv
->basic_rate
= rate_config
&= 0x15f;
2395 write_nic_dword(dev
,BSSIDR
,((u32
*)net
->bssid
)[0]);
2396 write_nic_word(dev
,BSSIDR
+4,((u16
*)net
->bssid
)[2]);
2397 //for(i=0;i<ETH_ALEN;i++)
2398 // write_nic_byte(dev,BSSID+i,net->bssid[i]);
2400 rtl8192_update_msr(dev
);
2401 // rtl8192_update_cap(dev, net->capability);
2402 if (priv
->ieee80211
->iw_mode
== IW_MODE_ADHOC
)
2404 write_nic_word(dev
, ATIMWND
, 2);
2405 write_nic_word(dev
, BCN_DMATIME
, 1023);
2406 write_nic_word(dev
, BCN_INTERVAL
, net
->beacon_interval
);
2407 // write_nic_word(dev, BcnIntTime, 100);
2408 write_nic_word(dev
, BCN_DRV_EARLY_INT
, 1);
2409 write_nic_byte(dev
, BCN_ERR_THRESH
, 100);
2410 BcnTimeCfg
|= (BcnCW
<<BCN_TCFG_CW_SHIFT
);
2411 // TODO: BcnIFS may required to be changed on ASIC
2412 BcnTimeCfg
|= BcnIFS
<<BCN_TCFG_IFS
;
2414 write_nic_word(dev
, BCN_TCFG
, BcnTimeCfg
);
2421 //temporary hw beacon is not used any more.
2422 //open it when necessary
2424 void rtl819xusb_beacon_tx(struct net_device
*dev
,u16 tx_rate
)
2428 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2429 struct sk_buff
*skb
;
2433 rtl8192_net_update(dev
);
2435 skb
= ieee80211_get_beacon(priv
->ieee80211
);
2437 DMESG("not enought memory for allocating beacon");
2442 write_nic_byte(dev
, BQREQ
, read_nic_byte(dev
, BQREQ
) | (1<<7));
2445 //while(!read_nic_byte(dev,BQREQ & (1<<7)))
2446 while( (read_nic_byte(dev
, BQREQ
) & (1<<7)) == 0 )
2448 msleep_interruptible_rtl(HZ
/2);
2450 DMESGW("get stuck to wait HW beacon to be ready");
2454 skb
->cb
[0] = NORM_PRIORITY
;
2455 skb
->cb
[1] = 0; //morefragment = 0
2456 skb
->cb
[2] = ieeerate2rtlrate(tx_rate
);
2458 rtl8192_tx(dev
,skb
);
2463 inline u8
rtl8192_IsWirelessBMode(u16 rate
)
2465 if( ((rate
<= 110) && (rate
!= 60) && (rate
!= 90)) || (rate
== 220) )
2470 u16
N_DBPSOfRate(u16 DataRate
);
2475 u8 bManagementFrame
,
2483 if( rtl8192_IsWirelessBMode(DataRate
) )
2485 if( bManagementFrame
|| !bShortPreamble
|| DataRate
== 10 )
2487 FrameTime
= (u16
)(144+48+(FrameLength
*8/(DataRate
/10)));
2491 FrameTime
= (u16
)(72+24+(FrameLength
*8/(DataRate
/10)));
2493 if( ( FrameLength
*8 % (DataRate
/10) ) != 0 ) //Get the Ceilling
2495 } else { //802.11g DSSS-OFDM PLCP length field calculation.
2496 N_DBPS
= N_DBPSOfRate(DataRate
);
2497 Ceiling
= (16 + 8*FrameLength
+ 6) / N_DBPS
2498 + (((16 + 8*FrameLength
+ 6) % N_DBPS
) ? 1 : 0);
2499 FrameTime
= (u16
)(16 + 4 + 4*Ceiling
+ 6);
2504 u16
N_DBPSOfRate(u16 DataRate
)
2549 void rtl819xU_cmd_isr(struct urb
*tx_cmd_urb
, struct pt_regs
*regs
)
2552 struct net_device
*dev
= (struct net_device
*)tx_cmd_urb
->context
;
2553 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2554 int last_init_packet
= 0;
2558 if(tx_cmd_urb
->status
!= 0) {
2559 priv
->pFirmware
.firmware_seg_index
= 0; //only begin transter, should it can be set to 1
2562 /* Free the urb and the corresponding buf for common Tx cmd packet, or
2563 * last segment of each firmware img.
2565 if((priv
->pFirmware
.firmware_seg_index
== 0) ||(priv
->pFirmware
.firmware_seg_index
== priv
->pFirmware
.firmware_seg_maxnum
)) {
2566 priv
->pFirmware
.firmware_seg_index
= 0;//only begin transter, should it can be set to 1
2568 /* prepare for last transfer */
2569 /* update some infomation for */
2570 /* last segment of the firmware img need indicate to device */
2571 priv
->pFirmware
.firmware_seg_index
++;
2572 if(priv
->pFirmware
.firmware_seg_index
== priv
->pFirmware
.firmware_seg_maxnum
) {
2573 last_init_packet
= 1;
2576 cmd_buf_len
= priv
->pFirmware
.firmware_seg_container
[priv
->pFirmware
.firmware_seg_index
-1].seg_size
;
2577 ptr_cmd_buf
= priv
->pFfirmware
.firmware_seg_container
[priv
->pFfirmware
.firmware_seg_index
-1].seg_ptr
;
2578 rtl819xU_tx_cmd(dev
, ptr_cmd_buf
, cmd_buf_len
, last_init_packet
, DESC_PACKET_TYPE_INIT
);
2581 kfree(tx_cmd_urb
->transfer_buffer
);
2583 usb_free_urb(tx_cmd_urb
);
2586 unsigned int txqueue2outpipe(struct r8192_priv
* priv
,unsigned int tx_queue
) {
2590 RT_TRACE(COMP_ERR
,"%s():Unknown queue ID!!!\n",__FUNCTION__
);
2593 return priv
->txqueue_to_outpipemap
[tx_queue
];
2597 short rtl8192SU_tx_cmd(struct net_device
*dev
, struct sk_buff
*skb
)
2599 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2602 unsigned int idx_pipe
;
2603 tx_desc_cmd_819x_usb
*pdesc
= (tx_desc_cmd_819x_usb
*)skb
->data
;
2604 cb_desc
*tcb_desc
= (cb_desc
*)(skb
->cb
+ MAX_DEV_ADDR_SIZE
);
2605 u8 queue_index
= tcb_desc
->queue_index
;
2608 //printk("\n %s::::::::::::::::::::::queue_index = %d\n",__FUNCTION__, queue_index);
2609 atomic_inc(&priv
->tx_pending
[queue_index
]);
2611 tx_urb
= usb_alloc_urb(0,GFP_ATOMIC
);
2617 memset(pdesc
, 0, USB_HWDESC_HEADER_LEN
);
2619 /* Tx descriptor ought to be set according to the skb->cb */
2620 pdesc
->LINIP
= tcb_desc
->bLastIniPkt
;
2621 PktSize
= (u16
)(skb
->len
- USB_HWDESC_HEADER_LEN
);
2622 pdesc
->PktSize
= PktSize
;
2623 //printk("PKTSize = %d %x\n",pdesc->PktSize,pdesc->PktSize);
2624 //----------------------------------------------------------------------------
2625 // Fill up USB_OUT_CONTEXT.
2626 //----------------------------------------------------------------------------
2627 // Get index to out pipe from specified QueueID.
2628 idx_pipe
= txqueue2outpipe(priv
,queue_index
);
2629 //printk("=============>%s queue_index:%d, outpipe:%d\n", __func__,queue_index,priv->RtOutPipes[idx_pipe]);
2631 #ifdef JOHN_DUMP_TXDESC
2633 printk("Len = %d\n", skb
->len
);
2634 for (i
= 0; i
< 8; i
++)
2635 printk("%2.2x ", *((u8
*)skb
->data
+i
));
2639 usb_fill_bulk_urb(tx_urb
,
2641 usb_sndbulkpipe(priv
->udev
,priv
->RtOutPipes
[idx_pipe
]),
2647 status
= usb_submit_urb(tx_urb
, GFP_ATOMIC
);
2651 printk("Error TX CMD URB, error %d",
2657 short rtl819xU_tx_cmd(struct net_device
*dev
, struct sk_buff
*skb
)
2659 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2664 unsigned int idx_pipe
;
2665 tx_desc_cmd_819x_usb
*pdesc
= (tx_desc_cmd_819x_usb
*)skb
->data
;
2666 cb_desc
*tcb_desc
= (cb_desc
*)(skb
->cb
+ MAX_DEV_ADDR_SIZE
);
2667 u8 queue_index
= tcb_desc
->queue_index
;
2669 //printk("\n %s::queue_index = %d\n",__FUNCTION__, queue_index);
2670 atomic_inc(&priv
->tx_pending
[queue_index
]);
2672 tx_urb
= usb_alloc_urb(0,GFP_ATOMIC
);
2678 memset(pdesc
, 0, USB_HWDESC_HEADER_LEN
);
2679 /* Tx descriptor ought to be set according to the skb->cb */
2680 pdesc
->FirstSeg
= 1;//bFirstSeg;
2681 pdesc
->LastSeg
= 1;//bLastSeg;
2682 pdesc
->CmdInit
= tcb_desc
->bCmdOrInit
;
2683 pdesc
->TxBufferSize
= tcb_desc
->txbuf_size
;
2685 pdesc
->LINIP
= tcb_desc
->bLastIniPkt
;
2687 //----------------------------------------------------------------------------
2688 // Fill up USB_OUT_CONTEXT.
2689 //----------------------------------------------------------------------------
2690 // Get index to out pipe from specified QueueID.
2691 idx_pipe
= txqueue2outpipe(priv
,queue_index
);
2692 #ifdef JOHN_DUMP_TXDESC
2694 printk("<Tx descriptor>--rate %x---",rate
);
2695 for (i
= 0; i
< 8; i
++)
2696 printk("%8x ", tx
[i
]);
2699 usb_fill_bulk_urb(tx_urb
,priv
->udev
, usb_sndbulkpipe(priv
->udev
,idx_pipe
), \
2700 skb
->data
, skb
->len
, rtl8192_tx_isr
, skb
);
2702 status
= usb_submit_urb(tx_urb
, GFP_ATOMIC
);
2706 DMESGE("Error TX CMD URB, error %d",
2714 * Mapping Software/Hardware descriptor queue id to "Queue Select Field"
2715 * in TxFwInfo data structure
2716 * 2006.10.30 by Emily
2718 * \param QUEUEID Software Queue
2720 u8
MapHwQueueToFirmwareQueue(u8 QueueID
)
2722 u8 QueueSelect
= 0x0; //defualt set to
2726 QueueSelect
= QSLT_BE
; //or QSelect = pTcb->priority;
2730 QueueSelect
= QSLT_BK
; //or QSelect = pTcb->priority;
2734 QueueSelect
= QSLT_VO
; //or QSelect = pTcb->priority;
2738 QueueSelect
= QSLT_VI
; //or QSelect = pTcb->priority;
2741 QueueSelect
= QSLT_MGNT
;
2745 QueueSelect
= QSLT_BEACON
;
2748 // TODO: 2006.10.30 mark other queue selection until we verify it is OK
2749 // TODO: Remove Assertions
2750 //#if (RTL819X_FPGA_VER & RTL819X_FPGA_GUANGAN_070502)
2752 QueueSelect
= QSLT_CMD
;
2756 QueueSelect
= QSLT_HIGH
;
2760 RT_TRACE(COMP_ERR
, "TransmitTCB(): Impossible Queue Selection: %d \n", QueueID
);
2767 u8
MRateToHwRate8190Pci(u8 rate
)
2769 u8 ret
= DESC92S_RATE1M
;
2773 // CCK and OFDM non-HT rates
2774 case MGN_1M
: ret
= DESC92S_RATE1M
; break;
2775 case MGN_2M
: ret
= DESC92S_RATE2M
; break;
2776 case MGN_5_5M
: ret
= DESC92S_RATE5_5M
; break;
2777 case MGN_11M
: ret
= DESC92S_RATE11M
; break;
2778 case MGN_6M
: ret
= DESC92S_RATE6M
; break;
2779 case MGN_9M
: ret
= DESC92S_RATE9M
; break;
2780 case MGN_12M
: ret
= DESC92S_RATE12M
; break;
2781 case MGN_18M
: ret
= DESC92S_RATE18M
; break;
2782 case MGN_24M
: ret
= DESC92S_RATE24M
; break;
2783 case MGN_36M
: ret
= DESC92S_RATE36M
; break;
2784 case MGN_48M
: ret
= DESC92S_RATE48M
; break;
2785 case MGN_54M
: ret
= DESC92S_RATE54M
; break;
2787 // HT rates since here
2788 case MGN_MCS0
: ret
= DESC92S_RATEMCS0
; break;
2789 case MGN_MCS1
: ret
= DESC92S_RATEMCS1
; break;
2790 case MGN_MCS2
: ret
= DESC92S_RATEMCS2
; break;
2791 case MGN_MCS3
: ret
= DESC92S_RATEMCS3
; break;
2792 case MGN_MCS4
: ret
= DESC92S_RATEMCS4
; break;
2793 case MGN_MCS5
: ret
= DESC92S_RATEMCS5
; break;
2794 case MGN_MCS6
: ret
= DESC92S_RATEMCS6
; break;
2795 case MGN_MCS7
: ret
= DESC92S_RATEMCS7
; break;
2796 case MGN_MCS8
: ret
= DESC92S_RATEMCS8
; break;
2797 case MGN_MCS9
: ret
= DESC92S_RATEMCS9
; break;
2798 case MGN_MCS10
: ret
= DESC92S_RATEMCS10
; break;
2799 case MGN_MCS11
: ret
= DESC92S_RATEMCS11
; break;
2800 case MGN_MCS12
: ret
= DESC92S_RATEMCS12
; break;
2801 case MGN_MCS13
: ret
= DESC92S_RATEMCS13
; break;
2802 case MGN_MCS14
: ret
= DESC92S_RATEMCS14
; break;
2803 case MGN_MCS15
: ret
= DESC92S_RATEMCS15
; break;
2805 // Set the highest SG rate
2823 ret
= DESC92S_RATEMCS15_SG
;
2832 u8
MRateToHwRate8190Pci(u8 rate
)
2834 u8 ret
= DESC90_RATE1M
;
2837 case MGN_1M
: ret
= DESC90_RATE1M
; break;
2838 case MGN_2M
: ret
= DESC90_RATE2M
; break;
2839 case MGN_5_5M
: ret
= DESC90_RATE5_5M
; break;
2840 case MGN_11M
: ret
= DESC90_RATE11M
; break;
2841 case MGN_6M
: ret
= DESC90_RATE6M
; break;
2842 case MGN_9M
: ret
= DESC90_RATE9M
; break;
2843 case MGN_12M
: ret
= DESC90_RATE12M
; break;
2844 case MGN_18M
: ret
= DESC90_RATE18M
; break;
2845 case MGN_24M
: ret
= DESC90_RATE24M
; break;
2846 case MGN_36M
: ret
= DESC90_RATE36M
; break;
2847 case MGN_48M
: ret
= DESC90_RATE48M
; break;
2848 case MGN_54M
: ret
= DESC90_RATE54M
; break;
2850 // HT rate since here
2851 case MGN_MCS0
: ret
= DESC90_RATEMCS0
; break;
2852 case MGN_MCS1
: ret
= DESC90_RATEMCS1
; break;
2853 case MGN_MCS2
: ret
= DESC90_RATEMCS2
; break;
2854 case MGN_MCS3
: ret
= DESC90_RATEMCS3
; break;
2855 case MGN_MCS4
: ret
= DESC90_RATEMCS4
; break;
2856 case MGN_MCS5
: ret
= DESC90_RATEMCS5
; break;
2857 case MGN_MCS6
: ret
= DESC90_RATEMCS6
; break;
2858 case MGN_MCS7
: ret
= DESC90_RATEMCS7
; break;
2859 case MGN_MCS8
: ret
= DESC90_RATEMCS8
; break;
2860 case MGN_MCS9
: ret
= DESC90_RATEMCS9
; break;
2861 case MGN_MCS10
: ret
= DESC90_RATEMCS10
; break;
2862 case MGN_MCS11
: ret
= DESC90_RATEMCS11
; break;
2863 case MGN_MCS12
: ret
= DESC90_RATEMCS12
; break;
2864 case MGN_MCS13
: ret
= DESC90_RATEMCS13
; break;
2865 case MGN_MCS14
: ret
= DESC90_RATEMCS14
; break;
2866 case MGN_MCS15
: ret
= DESC90_RATEMCS15
; break;
2867 case (0x80|0x20): ret
= DESC90_RATEMCS32
; break;
2875 u8
QueryIsShort(u8 TxHT
, u8 TxRate
, cb_desc
*tcb_desc
)
2879 tmp_Short
= (TxHT
==1)?((tcb_desc
->bUseShortGI
)?1:0):((tcb_desc
->bUseShortPreamble
)?1:0);
2881 if(TxHT
==1 && TxRate
!= DESC90_RATEMCS15
)
2887 static void tx_zero_isr(struct urb
*tx_urb
)
2895 * The tx procedure is just as following, skb->cb will contain all the following
2896 *information: * priority, morefrag, rate, &dev.
2898 // <Note> Buffer format for 8192S Usb bulk out:
2900 // --------------------------------------------------
2901 // | 8192S Usb Tx Desc | 802_11_MAC_header | data |
2902 // --------------------------------------------------
2903 // | 32 bytes | 24 bytes |0-2318 bytes|
2904 // --------------------------------------------------
2905 // |<------------ BufferLen ------------------------->|
2907 short rtl8192SU_tx(struct net_device
*dev
, struct sk_buff
* skb
)
2909 struct r8192_priv
*priv
= ieee80211_priv(dev
);
2910 cb_desc
*tcb_desc
= (cb_desc
*)(skb
->cb
+ MAX_DEV_ADDR_SIZE
);
2911 tx_desc_819x_usb
*tx_desc
= (tx_desc_819x_usb
*)skb
->data
;
2912 //tx_fwinfo_819x_usb *tx_fwinfo = (tx_fwinfo_819x_usb *)(skb->data + USB_HWDESC_HEADER_LEN);//92su del
2913 struct usb_device
*udev
= priv
->udev
;
2916 struct urb
*tx_urb
= NULL
, *tx_urb_zero
= NULL
;
2918 unsigned int idx_pipe
;
2919 u16 MPDUOverhead
= 0;
2920 //RT_DEBUG_DATA(COMP_SEND, tcb_desc, sizeof(cb_desc));
2923 /* Added by Annie for filling Len_Adjust field. 2005-12-14. */
2924 RT_ENC_ALG EncAlg
= NO_Encryption
;
2928 pend
= atomic_read(&priv
->tx_pending
[tcb_desc
->queue_index
]);
2929 /* we are locked here so the two atomic_read and inc are executed
2930 * without interleaves * !!! For debug purpose */
2931 if( pend
> MAX_TX_URB
){
2932 switch (tcb_desc
->queue_index
) {
2934 priv
->stats
.txvodrop
++;
2937 priv
->stats
.txvidrop
++;
2940 priv
->stats
.txbedrop
++;
2942 default://BK_PRIORITY
2943 priv
->stats
.txbkdrop
++;
2946 printk("To discard skb packet!\n");
2947 dev_kfree_skb_any(skb
);
2951 tx_urb
= usb_alloc_urb(0,GFP_ATOMIC
);
2953 dev_kfree_skb_any(skb
);
2957 memset(tx_desc
, 0, sizeof(tx_desc_819x_usb
));
2960 tx_desc
->NonQos
= (IsQoSDataFrame(skb
->data
)==TRUE
)? 0:1;
2962 /* Fill Tx descriptor */
2963 //memset(tx_fwinfo,0,sizeof(tx_fwinfo_819x_usb));
2965 // This part can just fill to the first descriptor of the frame.
2967 tx_desc
->TxHT
= (tcb_desc
->data_rate
&0x80)?1:0;
2970 tx_desc
->TxRate
= MRateToHwRate8190Pci(tcb_desc
->data_rate
);
2971 //tx_desc->EnableCPUDur = tcb_desc->bTxEnableFwCalcDur;
2972 tx_desc
->TxShort
= QueryIsShort(tx_desc
->TxHT
, tx_desc
->TxRate
, tcb_desc
);
2975 // Aggregation related
2976 if(tcb_desc
->bAMPDUEnable
) {//AMPDU enabled
2977 tx_desc
->AllowAggregation
= 1;
2979 //tx_fwinfo->RxMF = tcb_desc->ampdu_factor;
2980 //tx_fwinfo->RxAMD = tcb_desc->ampdu_density&0x07;//ampdudensity
2982 tx_desc
->AllowAggregation
= 0;
2984 //tx_fwinfo->RxMF = 0;
2985 //tx_fwinfo->RxAMD = 0;
2989 // <Roger_Notes> For AMPDU case, we must insert SSN into TX_DESC,
2990 // FW according as this SSN to do necessary packet retry.
2996 //pSeq = (u8 *)(VirtualAddress+USB_HWDESC_HEADER_LEN + FRAME_OFFSET_SEQUENCE);
2997 pSeq
= (u8
*)(skb
->data
+USB_HWDESC_HEADER_LEN
+ 22);
3000 Temp
|= (*(u16
*)pSeq
)>>4;
3001 tx_desc
->Seq
= Temp
;
3004 /* Protection mode related */
3005 tx_desc
->RTSEn
= (tcb_desc
->bRTSEnable
)?1:0;
3006 tx_desc
->CTS2Self
= (tcb_desc
->bCTSEnable
)?1:0;
3007 tx_desc
->RTSSTBC
= (tcb_desc
->bRTSSTBC
)?1:0;
3008 tx_desc
->RTSHT
= (tcb_desc
->rts_rate
&0x80)?1:0;
3009 tx_desc
->RTSRate
= MRateToHwRate8190Pci((u8
)tcb_desc
->rts_rate
);
3010 tx_desc
->RTSSubcarrier
= (tx_desc
->RTSHT
==0)?(tcb_desc
->RTSSC
):0;
3011 tx_desc
->RTSBW
= (tx_desc
->RTSHT
==1)?((tcb_desc
->bRTSBW
)?1:0):0;
3012 tx_desc
->RTSShort
= (tx_desc
->RTSHT
==0)?(tcb_desc
->bRTSUseShortPreamble
?1:0):\
3013 (tcb_desc
->bRTSUseShortGI
?1:0);
3015 tx_desc
->DisRTSFB
= 0;
3016 tx_desc
->RTSRateFBLmt
= 0xf;
3018 // <Roger_EXP> 2008.09.22. We disable RTS rate fallback temporarily.
3019 //tx_desc->DisRTSFB = 0x01;
3021 /* Set Bandwidth and sub-channel settings. */
3022 if(priv
->CurrentChannelBW
== HT_CHANNEL_WIDTH_20_40
)
3024 if(tcb_desc
->bPacketBW
) {
3025 tx_desc
->TxBandwidth
= 1;
3026 tx_desc
->TxSubCarrier
= 0; //By SD3's Jerry suggestion, use duplicated mode
3028 tx_desc
->TxBandwidth
= 0;
3029 tx_desc
->TxSubCarrier
= priv
->nCur40MhzPrimeSC
;
3032 tx_desc
->TxBandwidth
= 0;
3033 tx_desc
->TxSubCarrier
= 0;
3037 //memset(tx_desc, 0, sizeof(tx_desc_819x_usb));
3040 //tx_desc->CmdInit = 1; //92su del
3041 tx_desc
->Offset
= USB_HWDESC_HEADER_LEN
;
3044 tx_desc
->PktSize
= (skb
->len
- USB_HWDESC_HEADER_LEN
) & 0xffff;
3048 //tx_desc->SecCAMID= 0;//92su del
3049 tx_desc
->RaBRSRID
= tcb_desc
->RATRIndex
;
3050 //#ifdef RTL8192S_PREPARE_FOR_NORMAL_RELEASE
3052 tx_desc
->RaBRSRID
= 1;
3056 /* Fill security related */
3057 if( pTcb
->bEncrypt
&& !Adapter
->MgntInfo
.SecurityInfo
.SWTxEncryptFlag
)
3059 EncAlg
= SecGetEncryptionOverhead(
3061 &EncryptionMPDUHeadOverhead
,
3062 &EncryptionMPDUTailOverhead
,
3067 //2004/07/22, kcwu, EncryptionMPDUHeadOverhead has been added in previous code
3068 //MPDUOverhead = EncryptionMPDUHeadOverhead + EncryptionMPDUTailOverhead;
3069 MPDUOverhead
= EncryptionMPDUTailOverhead
;
3071 RT_TRACE(COMP_SEC
, DBG_LOUD
, ("******We in the loop SecCAMID is %d SecDescAssign is %d The Sec is %d********\n",tx_desc
->SecCAMID
,tx_desc
->SecDescAssign
,EncAlg
));
3072 //CamDumpAll(Adapter);
3078 //tx_desc->NoEnc = 1;//92su del
3083 tx_desc
->SecType
= 0x0;
3085 case WEP40_Encryption
:
3086 case WEP104_Encryption
:
3087 tx_desc
->SecType
= 0x1;
3089 case TKIP_Encryption
:
3090 tx_desc
->SecType
= 0x2;
3092 case AESCCMP_Encryption
:
3093 tx_desc
->SecType
= 0x3;
3096 tx_desc
->SecType
= 0x0;
3100 tx_desc
->SecType
= 0x0;
3102 if (tcb_desc
->bHwSec
)
3104 switch (priv
->ieee80211
->pairwise_key_type
)
3106 case KEY_TYPE_WEP40
:
3107 case KEY_TYPE_WEP104
:
3108 tx_desc
->SecType
= 0x1;
3109 //tx_desc->NoEnc = 0;//92su del
3112 tx_desc
->SecType
= 0x2;
3113 //tx_desc->NoEnc = 0;//92su del
3116 tx_desc
->SecType
= 0x3;
3117 //tx_desc->NoEnc = 0;//92su del
3120 tx_desc
->SecType
= 0x0;
3121 //tx_desc->NoEnc = 1;//92su del
3124 tx_desc
->SecType
= 0x0;
3125 //tx_desc->NoEnc = 1;//92su del
3130 //tx_desc->TxFWInfoSize = sizeof(tx_fwinfo_819x_usb);//92su del
3133 tx_desc
->USERATE
= tcb_desc
->bTxUseDriverAssingedRate
;
3134 tx_desc
->DISFB
= tcb_desc
->bTxDisableRateFallBack
;
3135 tx_desc
->DataRateFBLmt
= 0x1F;// Alwasy enable all rate fallback range
3137 tx_desc
->QueueSelect
= MapHwQueueToFirmwareQueue(tcb_desc
->queue_index
);
3140 /* Fill fields that are required to be initialized in all of the descriptors */
3143 tx_desc
->FirstSeg
= (tcb_desc
->bFirstSeg
)? 1:0;
3144 tx_desc
->LastSeg
= (tcb_desc
->bLastSeg
)?1:0;
3146 tx_desc
->FirstSeg
= 1;
3147 tx_desc
->LastSeg
= 1;
3153 //tx_desc->TxBufferSize = (u32)(skb->len - USB_HWDESC_HEADER_LEN);
3154 tx_desc
->TxBufferSize
= (u32
)(skb
->len
);//92su mod FIXLZM
3158 RT_TRACE(COMP_FPGA
, DBG_LOUD
, ("(1)TxFillDescriptor8192SUsb(): DataRate(%#x)\n", pTcb
->DataRate
));
3159 RT_TRACE(COMP_FPGA
, DBG_LOUD
, ("(2)TxFillDescriptor8192SUsb(): bTxUseDriverAssingedRate(%#x)\n", pTcb
->bTxUseDriverAssingedRate
));
3160 RT_TRACE(COMP_FPGA
, DBG_LOUD
, ("(3)TxFillDescriptor8192SUsb(): bAMPDUEnable(%d)\n", pTcb
->bAMPDUEnable
));
3161 RT_TRACE(COMP_FPGA
, DBG_LOUD
, ("(4)TxFillDescriptor8192SUsb(): bRTSEnable(%d)\n", pTcb
->bRTSEnable
));
3162 RT_TRACE(COMP_FPGA
, DBG_LOUD
, ("(5)TxFillDescriptor8192SUsb(): RTSRate(%#x)\n", pTcb
->RTSRate
));
3163 RT_TRACE(COMP_FPGA
, DBG_LOUD
, ("(6)TxFillDescriptor8192SUsb(): bCTSEnable(%d)\n", pTcb
->bCTSEnable
));
3164 RT_TRACE(COMP_FPGA
, DBG_LOUD
, ("(7)TxFillDescriptor8192SUsb(): bUseShortGI(%d)\n", pTcb
->bUseShortGI
));
3165 RT_TRACE(COMP_FPGA
, DBG_LOUD
, ("(8)TxFillDescriptor8192SUsb(): bPacketBW(%d)\n", pTcb
->bPacketBW
));
3166 RT_TRACE(COMP_FPGA
, DBG_LOUD
, ("(9)TxFillDescriptor8192SUsb(): CurrentChannelBW(%d)\n", pHalData
->CurrentChannelBW
));
3167 RT_TRACE(COMP_FPGA
, DBG_LOUD
, ("(10)TxFillDescriptor8192SUsb(): bTxDisableRateFallBack(%d)\n", pTcb
->bTxDisableRateFallBack
));
3168 RT_TRACE(COMP_FPGA
, DBG_LOUD
, ("(11)TxFillDescriptor8192SUsb(): RATRIndex(%d)\n", pTcb
->RATRIndex
));
3171 /* Get index to out pipe from specified QueueID */
3172 idx_pipe
= txqueue2outpipe(priv
,tcb_desc
->queue_index
);
3173 //printk("=============>%s queue_index:%d, outpipe:%d\n", __func__,tcb_desc->queue_index,priv->RtOutPipes[idx_pipe]);
3175 //RT_DEBUG_DATA(COMP_SEND,tx_fwinfo,sizeof(tx_fwinfo_819x_usb));
3176 //RT_DEBUG_DATA(COMP_SEND,tx_desc,sizeof(tx_desc_819x_usb));
3178 /* To submit bulk urb */
3179 usb_fill_bulk_urb(tx_urb
,
3181 usb_sndbulkpipe(udev
,priv
->RtOutPipes
[idx_pipe
]),
3183 skb
->len
, rtl8192_tx_isr
, skb
);
3185 status
= usb_submit_urb(tx_urb
, GFP_ATOMIC
);
3187 //we need to send 0 byte packet whenever 512N bytes/64N(HIGN SPEED/NORMAL SPEED) bytes packet has been transmitted. Otherwise, it will be halt to wait for another packet. WB. 2008.08.27
3188 bool bSend0Byte
= false;
3190 if(udev
->speed
== USB_SPEED_HIGH
)
3192 if (skb
->len
> 0 && skb
->len
% 512 == 0)
3197 if (skb
->len
> 0 && skb
->len
% 64 == 0)
3203 tx_urb_zero
= usb_alloc_urb(0,GFP_ATOMIC
);
3205 RT_TRACE(COMP_ERR
, "can't alloc urb for zero byte\n");
3208 usb_fill_bulk_urb(tx_urb_zero
,udev
,
3209 usb_sndbulkpipe(udev
,idx_pipe
), &zero
,
3210 0, tx_zero_isr
, dev
);
3211 status
= usb_submit_urb(tx_urb_zero
, GFP_ATOMIC
);
3213 RT_TRACE(COMP_ERR
, "Error TX URB for zero byte %d, error %d", atomic_read(&priv
->tx_pending
[tcb_desc
->queue_index
]), status
);
3218 dev
->trans_start
= jiffies
;
3219 atomic_inc(&priv
->tx_pending
[tcb_desc
->queue_index
]);
3222 RT_TRACE(COMP_ERR
, "Error TX URB %d, error %d", atomic_read(&priv
->tx_pending
[tcb_desc
->queue_index
]),
3230 * The tx procedure is just as following,
3231 * skb->cb will contain all the following information,
3232 * priority, morefrag, rate, &dev.
3234 short rtl8192_tx(struct net_device
*dev
, struct sk_buff
* skb
)
3236 struct r8192_priv
*priv
= ieee80211_priv(dev
);
3237 cb_desc
*tcb_desc
= (cb_desc
*)(skb
->cb
+ MAX_DEV_ADDR_SIZE
);
3238 tx_desc_819x_usb
*tx_desc
= (tx_desc_819x_usb
*)skb
->data
;
3239 tx_fwinfo_819x_usb
*tx_fwinfo
= (tx_fwinfo_819x_usb
*)(skb
->data
+ USB_HWDESC_HEADER_LEN
);
3240 struct usb_device
*udev
= priv
->udev
;
3243 struct urb
*tx_urb
= NULL
, *tx_urb_zero
= NULL
;
3245 unsigned int idx_pipe
;
3246 // RT_DEBUG_DATA(COMP_SEND, tcb_desc, sizeof(cb_desc));
3248 /* Added by Annie for filling Len_Adjust field. 2005-12-14. */
3249 RT_ENC_ALG EncAlg
= NO_Encryption
;
3251 // printk("=============> %s\n", __FUNCTION__);
3252 pend
= atomic_read(&priv
->tx_pending
[tcb_desc
->queue_index
]);
3253 /* we are locked here so the two atomic_read and inc are executed
3254 * without interleaves
3255 * !!! For debug purpose
3257 if( pend
> MAX_TX_URB
){
3259 switch (tcb_desc
->queue_index
) {
3261 priv
->stats
.txvodrop
++;
3264 priv
->stats
.txvidrop
++;
3267 priv
->stats
.txbedrop
++;
3269 default://BK_PRIORITY
3270 priv
->stats
.txbkdrop
++;
3274 printk("To discard skb packet!\n");
3275 dev_kfree_skb_any(skb
);
3279 tx_urb
= usb_alloc_urb(0,GFP_ATOMIC
);
3281 dev_kfree_skb_any(skb
);
3285 /* Fill Tx firmware info */
3286 memset(tx_fwinfo
,0,sizeof(tx_fwinfo_819x_usb
));
3288 tx_fwinfo
->TxHT
= (tcb_desc
->data_rate
&0x80)?1:0;
3289 tx_fwinfo
->TxRate
= MRateToHwRate8190Pci(tcb_desc
->data_rate
);
3290 tx_fwinfo
->EnableCPUDur
= tcb_desc
->bTxEnableFwCalcDur
;
3291 tx_fwinfo
->Short
= QueryIsShort(tx_fwinfo
->TxHT
, tx_fwinfo
->TxRate
, tcb_desc
);
3292 if(tcb_desc
->bAMPDUEnable
) {//AMPDU enabled
3293 tx_fwinfo
->AllowAggregation
= 1;
3295 tx_fwinfo
->RxMF
= tcb_desc
->ampdu_factor
;
3296 tx_fwinfo
->RxAMD
= tcb_desc
->ampdu_density
&0x07;//ampdudensity
3298 tx_fwinfo
->AllowAggregation
= 0;
3300 tx_fwinfo
->RxMF
= 0;
3301 tx_fwinfo
->RxAMD
= 0;
3304 /* Protection mode related */
3305 tx_fwinfo
->RtsEnable
= (tcb_desc
->bRTSEnable
)?1:0;
3306 tx_fwinfo
->CtsEnable
= (tcb_desc
->bCTSEnable
)?1:0;
3307 tx_fwinfo
->RtsSTBC
= (tcb_desc
->bRTSSTBC
)?1:0;
3308 tx_fwinfo
->RtsHT
= (tcb_desc
->rts_rate
&0x80)?1:0;
3309 tx_fwinfo
->RtsRate
= MRateToHwRate8190Pci((u8
)tcb_desc
->rts_rate
);
3310 tx_fwinfo
->RtsSubcarrier
= (tx_fwinfo
->RtsHT
==0)?(tcb_desc
->RTSSC
):0;
3311 tx_fwinfo
->RtsBandwidth
= (tx_fwinfo
->RtsHT
==1)?((tcb_desc
->bRTSBW
)?1:0):0;
3312 tx_fwinfo
->RtsShort
= (tx_fwinfo
->RtsHT
==0)?(tcb_desc
->bRTSUseShortPreamble
?1:0):\
3313 (tcb_desc
->bRTSUseShortGI
?1:0);
3315 /* Set Bandwidth and sub-channel settings. */
3316 if(priv
->CurrentChannelBW
== HT_CHANNEL_WIDTH_20_40
)
3318 if(tcb_desc
->bPacketBW
) {
3319 tx_fwinfo
->TxBandwidth
= 1;
3320 tx_fwinfo
->TxSubCarrier
= 0; //By SD3's Jerry suggestion, use duplicated mode
3322 tx_fwinfo
->TxBandwidth
= 0;
3323 tx_fwinfo
->TxSubCarrier
= priv
->nCur40MhzPrimeSC
;
3326 tx_fwinfo
->TxBandwidth
= 0;
3327 tx_fwinfo
->TxSubCarrier
= 0;
3330 /* Fill Tx descriptor */
3331 memset(tx_desc
, 0, sizeof(tx_desc_819x_usb
));
3334 tx_desc
->CmdInit
= 1;
3335 tx_desc
->Offset
= sizeof(tx_fwinfo_819x_usb
) + 8;
3338 tx_desc
->PktSize
= (skb
->len
- TX_PACKET_SHIFT_BYTES
) & 0xffff;
3342 tx_desc
->SecCAMID
= 0;
3343 tx_desc
->RATid
= tcb_desc
->RATRIndex
;
3345 /* Fill security related */
3346 if( pTcb
->bEncrypt
&& !Adapter
->MgntInfo
.SecurityInfo
.SWTxEncryptFlag
)
3348 EncAlg
= SecGetEncryptionOverhead(
3350 &EncryptionMPDUHeadOverhead
,
3351 &EncryptionMPDUTailOverhead
,
3356 //2004/07/22, kcwu, EncryptionMPDUHeadOverhead has been added in previous code
3357 //MPDUOverhead = EncryptionMPDUHeadOverhead + EncryptionMPDUTailOverhead;
3358 MPDUOverhead
= EncryptionMPDUTailOverhead
;
3360 RT_TRACE(COMP_SEC
, DBG_LOUD
, ("******We in the loop SecCAMID is %d SecDescAssign is %d The Sec is %d********\n",tx_desc
->SecCAMID
,tx_desc
->SecDescAssign
,EncAlg
));
3361 //CamDumpAll(Adapter);
3372 tx_desc
->SecType
= 0x0;
3374 case WEP40_Encryption
:
3375 case WEP104_Encryption
:
3376 tx_desc
->SecType
= 0x1;
3378 case TKIP_Encryption
:
3379 tx_desc
->SecType
= 0x2;
3381 case AESCCMP_Encryption
:
3382 tx_desc
->SecType
= 0x3;
3385 tx_desc
->SecType
= 0x0;
3389 tx_desc
->SecType
= 0x0;
3391 if (tcb_desc
->bHwSec
)
3393 switch (priv
->ieee80211
->pairwise_key_type
)
3395 case KEY_TYPE_WEP40
:
3396 case KEY_TYPE_WEP104
:
3397 tx_desc
->SecType
= 0x1;
3401 tx_desc
->SecType
= 0x2;
3405 tx_desc
->SecType
= 0x3;
3409 tx_desc
->SecType
= 0x0;
3415 tx_desc
->QueueSelect
= MapHwQueueToFirmwareQueue(tcb_desc
->queue_index
);
3416 tx_desc
->TxFWInfoSize
= sizeof(tx_fwinfo_819x_usb
);
3418 tx_desc
->DISFB
= tcb_desc
->bTxDisableRateFallBack
;
3419 tx_desc
->USERATE
= tcb_desc
->bTxUseDriverAssingedRate
;
3421 /* Fill fields that are required to be initialized in all of the descriptors */
3424 tx_desc
->FirstSeg
= (tcb_desc
->bFirstSeg
)? 1:0;
3425 tx_desc
->LastSeg
= (tcb_desc
->bLastSeg
)?1:0;
3427 tx_desc
->FirstSeg
= 1;
3428 tx_desc
->LastSeg
= 1;
3434 tx_desc
->TxBufferSize
= (u32
)(skb
->len
- USB_HWDESC_HEADER_LEN
);
3436 /* Get index to out pipe from specified QueueID */
3437 idx_pipe
= txqueue2outpipe(priv
,tcb_desc
->queue_index
);
3439 //RT_DEBUG_DATA(COMP_SEND,tx_fwinfo,sizeof(tx_fwinfo_819x_usb));
3440 //RT_DEBUG_DATA(COMP_SEND,tx_desc,sizeof(tx_desc_819x_usb));
3442 /* To submit bulk urb */
3443 usb_fill_bulk_urb(tx_urb
,udev
,
3444 usb_sndbulkpipe(udev
,idx_pipe
), skb
->data
,
3445 skb
->len
, rtl8192_tx_isr
, skb
);
3447 status
= usb_submit_urb(tx_urb
, GFP_ATOMIC
);
3449 //we need to send 0 byte packet whenever 512N bytes/64N(HIGN SPEED/NORMAL SPEED) bytes packet has been transmitted. Otherwise, it will be halt to wait for another packet. WB. 2008.08.27
3450 bool bSend0Byte
= false;
3452 if(udev
->speed
== USB_SPEED_HIGH
)
3454 if (skb
->len
> 0 && skb
->len
% 512 == 0)
3459 if (skb
->len
> 0 && skb
->len
% 64 == 0)
3465 tx_urb_zero
= usb_alloc_urb(0,GFP_ATOMIC
);
3467 RT_TRACE(COMP_ERR
, "can't alloc urb for zero byte\n");
3470 usb_fill_bulk_urb(tx_urb_zero
,udev
,
3471 usb_sndbulkpipe(udev
,idx_pipe
), &zero
,
3472 0, tx_zero_isr
, dev
);
3473 status
= usb_submit_urb(tx_urb_zero
, GFP_ATOMIC
);
3475 RT_TRACE(COMP_ERR
, "Error TX URB for zero byte %d, error %d", atomic_read(&priv
->tx_pending
[tcb_desc
->queue_index
]), status
);
3480 dev
->trans_start
= jiffies
;
3481 atomic_inc(&priv
->tx_pending
[tcb_desc
->queue_index
]);
3484 RT_TRACE(COMP_ERR
, "Error TX URB %d, error %d", atomic_read(&priv
->tx_pending
[tcb_desc
->queue_index
]),
3492 void rtl8192_set_rate(struct net_device
*dev
)
3496 int basic_rate
,min_rr_rate
,max_rr_rate
;
3498 // struct r8192_priv *priv = ieee80211_priv(dev);
3500 //if (ieee80211_is_54g(priv->ieee80211->current_network) &&
3501 // priv->ieee80211->state == IEEE80211_LINKED){
3502 basic_rate
= ieeerate2rtlrate(240);
3503 min_rr_rate
= ieeerate2rtlrate(60);
3504 max_rr_rate
= ieeerate2rtlrate(240);
3508 // basic_rate = ieeerate2rtlrate(20);
3509 // min_rr_rate = ieeerate2rtlrate(10);
3510 // max_rr_rate = ieeerate2rtlrate(110);
3513 write_nic_byte(dev
, RESP_RATE
,
3514 max_rr_rate
<<MAX_RESP_RATE_SHIFT
| min_rr_rate
<<MIN_RESP_RATE_SHIFT
);
3516 //word = read_nic_word(dev, BRSR);
3517 word
= read_nic_word(dev
, BRSR_8187
);
3518 word
&= ~BRSR_MBR_8185
;
3521 for(i
=0;i
<=basic_rate
;i
++)
3524 //write_nic_word(dev, BRSR, word);
3525 write_nic_word(dev
, BRSR_8187
, word
);
3526 //DMESG("RR:%x BRSR: %x", read_nic_byte(dev,RESP_RATE), read_nic_word(dev,BRSR));
3532 void rtl8192SU_net_update(struct net_device
*dev
)
3535 struct r8192_priv
*priv
= ieee80211_priv(dev
);
3536 struct ieee80211_device
* ieee
= priv
->ieee80211
;
3537 struct ieee80211_network
*net
= &priv
->ieee80211
->current_network
;
3538 //u16 BcnTimeCfg = 0, BcnCW = 6, BcnIFS = 0xf;
3539 u16 rate_config
= 0;
3542 u8 retrylimit
= 0x30;
3543 u16 cap
= net
->capability
;
3545 priv
->short_preamble
= cap
& WLAN_CAPABILITY_SHORT_PREAMBLE
;
3548 //update Basic rate: RR, BRSR
3549 rtl8192_config_rate(dev
, &rate_config
); //HalSetBrateCfg
3551 priv
->basic_rate
= rate_config
= rate_config
& 0x15f;
3553 // Set RRSR rate table.
3554 write_nic_byte(dev
, RRSR
, rate_config
&0xff);
3555 write_nic_byte(dev
, RRSR
+1, (rate_config
>>8)&0xff);
3557 // Set RTS initial rate
3558 while(rate_config
> 0x1)
3560 rate_config
= (rate_config
>> 1);
3563 write_nic_byte(dev
, INIRTSMCS_SEL
, rateIndex
);
3567 regTmp
= (priv
->nCur40MhzPrimeSC
) << 5;
3568 if (priv
->short_preamble
)
3570 write_nic_byte(dev
, RRSR
+2, regTmp
);
3572 write_nic_dword(dev
,BSSIDR
,((u32
*)net
->bssid
)[0]);
3573 write_nic_word(dev
,BSSIDR
+4,((u16
*)net
->bssid
)[2]);
3575 write_nic_word(dev
, BCN_INTERVAL
, net
->beacon_interval
);
3576 //2008.10.24 added by tynli for beacon changed.
3577 PHY_SetBeaconHwReg( dev
, net
->beacon_interval
);
3579 rtl8192_update_cap(dev
, cap
);
3581 if (ieee
->iw_mode
== IW_MODE_ADHOC
){
3583 //we should enable ibss interrupt here, but disable it temporarily
3585 priv
->irq_mask
|= (IMR_BcnInt
| IMR_BcnInt
| IMR_TBDOK
| IMR_TBDER
);
3586 //rtl8192_irq_disable(dev);
3587 //rtl8192_irq_enable(dev);
3592 priv
->irq_mask
&= ~(IMR_BcnInt
| IMR_BcnInt
| IMR_TBDOK
| IMR_TBDER
);
3593 //rtl8192_irq_disable(dev);
3594 //rtl8192_irq_enable(dev);
3598 priv
->ShortRetryLimit
= priv
->LongRetryLimit
= retrylimit
;
3600 write_nic_word(dev
, RETRY_LIMIT
,
3601 retrylimit
<< RETRY_LIMIT_SHORT_SHIFT
| \
3602 retrylimit
<< RETRY_LIMIT_LONG_SHIFT
);
3605 void rtl8192SU_update_ratr_table(struct net_device
* dev
)
3607 struct r8192_priv
* priv
= ieee80211_priv(dev
);
3608 struct ieee80211_device
* ieee
= priv
->ieee80211
;
3609 u8
* pMcsRate
= ieee
->dot11HTOperationalRateSet
;
3610 //struct ieee80211_network *net = &ieee->current_network;
3614 int WirelessMode
= ieee
->mode
;
3615 u8 MimoPs
= ieee
->pHTInfo
->PeerMimoPs
;
3619 rtl8192_config_rate(dev
, (u16
*)(&ratr_value
));
3620 ratr_value
|= (*(u16
*)(pMcsRate
)) << 12;
3622 //switch (ieee->mode)
3623 switch (WirelessMode
)
3626 ratr_value
&= 0x00000FF0;
3629 ratr_value
&= 0x0000000D;
3632 ratr_value
&= 0x00000FF5;
3639 if (MimoPs
== 0) //MIMO_PS_STATIC
3641 ratr_value
&= 0x0007F005;
3644 { // MCS rate only => for 11N mode.
3647 // 1T2R or 1T1R, Spatial Stream 2 should be disabled
3648 if ( priv
->rf_type
== RF_1T2R
||
3649 priv
->rf_type
== RF_1T1R
||
3650 (ieee
->pHTInfo
->IOTAction
& HT_IOT_ACT_DISABLE_TX_2SS
) )
3651 ratr_mask
= 0x000ff005;
3653 ratr_mask
= 0x0f0ff005;
3655 if((ieee
->pHTInfo
->bCurTxBW40MHz
) &&
3656 !(ieee
->pHTInfo
->IOTAction
& HT_IOT_ACT_DISABLE_TX_40_MHZ
))
3657 ratr_mask
|= 0x00000010; // Set 6MBps
3659 // Select rates for rate adaptive mechanism.
3660 ratr_value
&= ratr_mask
;
3667 if(priv
->rf_type
== RF_1T2R
) // 1T2R, Spatial Stream 2 should be disabled
3669 ratr_value
&= 0x000ff0f5;
3673 ratr_value
&= 0x0f0ff0f5;
3676 //printk("====>%s(), mode is not correct:%x\n", __FUNCTION__, ieee->mode);
3680 ratr_value
&= 0x0FFFFFFF;
3682 // Get MAX MCS available.
3683 if ( (bNMode
&& ((ieee
->pHTInfo
->IOTAction
& HT_IOT_ACT_DISABLE_SHORT_GI
)==0)) &&
3684 ((ieee
->pHTInfo
->bCurBW40MHz
&& ieee
->pHTInfo
->bCurShortGI40MHz
) ||
3685 (!ieee
->pHTInfo
->bCurBW40MHz
&& ieee
->pHTInfo
->bCurShortGI20MHz
)))
3687 u8 shortGI_rate
= 0;
3688 u32 tmp_ratr_value
= 0;
3689 ratr_value
|= 0x10000000;//???
3690 tmp_ratr_value
= (ratr_value
>>12);
3691 for(shortGI_rate
=15; shortGI_rate
>0; shortGI_rate
--)
3693 if((1<<shortGI_rate
) & tmp_ratr_value
)
3696 shortGI_rate
= (shortGI_rate
<<12)|(shortGI_rate
<<8)|(shortGI_rate
<<4)|(shortGI_rate
);
3697 write_nic_byte(dev
, SG_RATE
, shortGI_rate
);
3698 //printk("==>SG_RATE:%x\n", read_nic_byte(dev, SG_RATE));
3700 write_nic_dword(dev
, ARFR0
+rate_index
*4, ratr_value
);
3701 printk("=============>ARFR0+rate_index*4:%#x\n", ratr_value
);
3704 if (ratr_value
& 0xfffff000){
3705 //printk("===>set to N mode\n");
3706 HalSetFwCmd8192S(dev
, FW_CMD_RA_REFRESH_N
);
3709 //printk("===>set to B/G mode\n");
3710 HalSetFwCmd8192S(dev
, FW_CMD_RA_REFRESH_BG
);
3714 void rtl8192SU_link_change(struct net_device
*dev
)
3716 struct r8192_priv
*priv
= ieee80211_priv(dev
);
3717 struct ieee80211_device
* ieee
= priv
->ieee80211
;
3718 //unsigned long flags;
3721 printk("=====>%s 1\n", __func__
);
3722 reg
= read_nic_dword(dev
, RCR
);
3724 if (ieee
->state
== IEEE80211_LINKED
)
3727 rtl8192SU_net_update(dev
);
3728 rtl8192SU_update_ratr_table(dev
);
3729 ieee
->SetFwCmdHandler(dev
, FW_CMD_HIGH_PWR_ENABLE
);
3730 priv
->ReceiveConfig
= reg
|= RCR_CBSSID
;
3733 priv
->ReceiveConfig
= reg
&= ~RCR_CBSSID
;
3737 write_nic_dword(dev
, RCR
, reg
);
3738 rtl8192_update_msr(dev
);
3740 printk("<=====%s 2\n", __func__
);
3743 extern void rtl8192_update_ratr_table(struct net_device
* dev
);
3744 void rtl8192_link_change(struct net_device
*dev
)
3748 struct r8192_priv
*priv
= ieee80211_priv(dev
);
3749 struct ieee80211_device
* ieee
= priv
->ieee80211
;
3750 //write_nic_word(dev, BCN_INTR_ITV, net->beacon_interval);
3751 if (ieee
->state
== IEEE80211_LINKED
)
3753 rtl8192_net_update(dev
);
3754 rtl8192_update_ratr_table(dev
);
3756 //add this as in pure N mode, wep encryption will use software way, but there is no chance to set this as wep will not set group key in wext. WB.2008.07.08
3757 if ((KEY_TYPE_WEP40
== ieee
->pairwise_key_type
) || (KEY_TYPE_WEP104
== ieee
->pairwise_key_type
))
3758 EnableHWSecurityConfig8192(dev
);
3761 /*update timing params*/
3762 // RT_TRACE(COMP_CH, "========>%s(), chan:%d\n", __FUNCTION__, priv->chan);
3763 // rtl8192_set_chan(dev, priv->chan);
3764 if (ieee
->iw_mode
== IW_MODE_INFRA
|| ieee
->iw_mode
== IW_MODE_ADHOC
)
3767 reg
= read_nic_dword(dev
, RCR
);
3768 if (priv
->ieee80211
->state
== IEEE80211_LINKED
)
3769 priv
->ReceiveConfig
= reg
|= RCR_CBSSID
;
3771 priv
->ReceiveConfig
= reg
&= ~RCR_CBSSID
;
3772 write_nic_dword(dev
, RCR
, reg
);
3775 // rtl8192_set_rxconf(dev);
3779 static struct ieee80211_qos_parameters def_qos_parameters
= {
3780 {3,3,3,3},/* cw_min */
3781 {7,7,7,7},/* cw_max */
3782 {2,2,2,2},/* aifs */
3783 {0,0,0,0},/* flags */
3784 {0,0,0,0} /* tx_op_limit */
3788 void rtl8192_update_beacon(struct work_struct
* work
)
3790 struct r8192_priv
*priv
= container_of(work
, struct r8192_priv
, update_beacon_wq
.work
);
3791 struct net_device
*dev
= priv
->ieee80211
->dev
;
3792 struct ieee80211_device
* ieee
= priv
->ieee80211
;
3793 struct ieee80211_network
* net
= &ieee
->current_network
;
3795 if (ieee
->pHTInfo
->bCurrentHTSupport
)
3796 HTUpdateSelfAndPeerSetting(ieee
, net
);
3797 ieee
->pHTInfo
->bCurrentRT2RTLongSlotTime
= net
->bssht
.bdRT2RTLongSlotTime
;
3798 // Joseph test for turbo mode with AP
3799 ieee
->pHTInfo
->RT2RT_HT_Mode
= net
->bssht
.RT2RT_HT_Mode
;
3800 rtl8192_update_cap(dev
, net
->capability
);
3803 * background support to run QoS activate functionality
3805 int WDCAPARA_ADD
[] = {EDCAPARA_BE
,EDCAPARA_BK
,EDCAPARA_VI
,EDCAPARA_VO
};
3807 void rtl8192_qos_activate(struct work_struct
* work
)
3809 struct r8192_priv
*priv
= container_of(work
, struct r8192_priv
, qos_activate
);
3810 struct net_device
*dev
= priv
->ieee80211
->dev
;
3811 struct ieee80211_qos_parameters
*qos_parameters
= &priv
->ieee80211
->current_network
.qos_data
.parameters
;
3812 u8 mode
= priv
->ieee80211
->current_network
.mode
;
3813 //u32 size = sizeof(struct ieee80211_qos_parameters);
3821 mutex_lock(&priv
->mutex
);
3823 if(priv
->ieee80211
->state
!= IEEE80211_LINKED
)
3825 RT_TRACE(COMP_QOS
,"qos active process with associate response received\n");
3826 /* It better set slot time at first */
3827 /* For we just support b/g mode at present, let the slot time at 9/20 selection */
3828 /* update the ac parameter to related registers */
3829 for(i
= 0; i
< QOS_QUEUE_NUM
; i
++) {
3830 //Mode G/A: slotTimeTimer = 9; Mode B: 20
3831 u1bAIFS
= qos_parameters
->aifs
[i
] * ((mode
&(IEEE_G
|IEEE_N_24G
)) ?9:20) + aSifsTime
;
3832 u4bAcParam
= ((((u32
)(qos_parameters
->tx_op_limit
[i
]))<< AC_PARAM_TXOP_LIMIT_OFFSET
)|
3833 (((u32
)(qos_parameters
->cw_max
[i
]))<< AC_PARAM_ECW_MAX_OFFSET
)|
3834 (((u32
)(qos_parameters
->cw_min
[i
]))<< AC_PARAM_ECW_MIN_OFFSET
)|
3835 ((u32
)u1bAIFS
<< AC_PARAM_AIFS_OFFSET
));
3837 write_nic_dword(dev
, WDCAPARA_ADD
[i
], u4bAcParam
);
3838 //write_nic_dword(dev, WDCAPARA_ADD[i], 0x005e4322);
3842 mutex_unlock(&priv
->mutex
);
3845 static int rtl8192_qos_handle_probe_response(struct r8192_priv
*priv
,
3847 struct ieee80211_network
*network
)
3850 u32 size
= sizeof(struct ieee80211_qos_parameters
);
3852 if(priv
->ieee80211
->state
!=IEEE80211_LINKED
)
3855 if ((priv
->ieee80211
->iw_mode
!= IW_MODE_INFRA
))
3858 if (network
->flags
& NETWORK_HAS_QOS_MASK
) {
3859 if (active_network
&&
3860 (network
->flags
& NETWORK_HAS_QOS_PARAMETERS
))
3861 network
->qos_data
.active
= network
->qos_data
.supported
;
3863 if ((network
->qos_data
.active
== 1) && (active_network
== 1) &&
3864 (network
->flags
& NETWORK_HAS_QOS_PARAMETERS
) &&
3865 (network
->qos_data
.old_param_count
!=
3866 network
->qos_data
.param_count
)) {
3867 network
->qos_data
.old_param_count
=
3868 network
->qos_data
.param_count
;
3869 queue_work(priv
->priv_wq
, &priv
->qos_activate
);
3870 RT_TRACE (COMP_QOS
, "QoS parameters change call "
3874 memcpy(&priv
->ieee80211
->current_network
.qos_data
.parameters
,\
3875 &def_qos_parameters
, size
);
3877 if ((network
->qos_data
.active
== 1) && (active_network
== 1)) {
3878 queue_work(priv
->priv_wq
, &priv
->qos_activate
);
3879 RT_TRACE(COMP_QOS
, "QoS was disabled call qos_activate \n");
3881 network
->qos_data
.active
= 0;
3882 network
->qos_data
.supported
= 0;
3888 /* handle manage frame frame beacon and probe response */
3889 static int rtl8192_handle_beacon(struct net_device
* dev
,
3890 struct ieee80211_beacon
* beacon
,
3891 struct ieee80211_network
* network
)
3893 struct r8192_priv
*priv
= ieee80211_priv(dev
);
3895 rtl8192_qos_handle_probe_response(priv
,1,network
);
3896 queue_delayed_work(priv
->priv_wq
, &priv
->update_beacon_wq
, 0);
3903 * handling the beaconing responses. if we get different QoS setting
3904 * off the network from the associated setting, adjust the QoS
3907 static int rtl8192_qos_association_resp(struct r8192_priv
*priv
,
3908 struct ieee80211_network
*network
)
3911 unsigned long flags
;
3912 u32 size
= sizeof(struct ieee80211_qos_parameters
);
3913 int set_qos_param
= 0;
3915 if ((priv
== NULL
) || (network
== NULL
))
3918 if(priv
->ieee80211
->state
!=IEEE80211_LINKED
)
3921 if ((priv
->ieee80211
->iw_mode
!= IW_MODE_INFRA
))
3924 spin_lock_irqsave(&priv
->ieee80211
->lock
, flags
);
3925 if(network
->flags
& NETWORK_HAS_QOS_PARAMETERS
) {
3926 memcpy(&priv
->ieee80211
->current_network
.qos_data
.parameters
,\
3927 &network
->qos_data
.parameters
,\
3928 sizeof(struct ieee80211_qos_parameters
));
3929 priv
->ieee80211
->current_network
.qos_data
.active
= 1;
3931 if((priv
->ieee80211
->current_network
.qos_data
.param_count
!= \
3932 network
->qos_data
.param_count
))
3936 /* update qos parameter for current network */
3937 priv
->ieee80211
->current_network
.qos_data
.old_param_count
= \
3938 priv
->ieee80211
->current_network
.qos_data
.param_count
;
3939 priv
->ieee80211
->current_network
.qos_data
.param_count
= \
3940 network
->qos_data
.param_count
;
3943 memcpy(&priv
->ieee80211
->current_network
.qos_data
.parameters
,\
3944 &def_qos_parameters
, size
);
3945 priv
->ieee80211
->current_network
.qos_data
.active
= 0;
3946 priv
->ieee80211
->current_network
.qos_data
.supported
= 0;
3950 spin_unlock_irqrestore(&priv
->ieee80211
->lock
, flags
);
3952 RT_TRACE(COMP_QOS
, "%s: network->flags = %d,%d\n",__FUNCTION__
,network
->flags
,priv
->ieee80211
->current_network
.qos_data
.active
);
3953 if (set_qos_param
== 1)
3954 queue_work(priv
->priv_wq
, &priv
->qos_activate
);
3960 static int rtl8192_handle_assoc_response(struct net_device
*dev
,
3961 struct ieee80211_assoc_response_frame
*resp
,
3962 struct ieee80211_network
*network
)
3964 struct r8192_priv
*priv
= ieee80211_priv(dev
);
3965 rtl8192_qos_association_resp(priv
, network
);
3970 void rtl8192_update_ratr_table(struct net_device
* dev
)
3971 // POCTET_STRING posLegacyRate,
3973 // PRT_WLAN_STA pEntry)
3975 struct r8192_priv
* priv
= ieee80211_priv(dev
);
3976 struct ieee80211_device
* ieee
= priv
->ieee80211
;
3977 u8
* pMcsRate
= ieee
->dot11HTOperationalRateSet
;
3978 //struct ieee80211_network *net = &ieee->current_network;
3981 rtl8192_config_rate(dev
, (u16
*)(&ratr_value
));
3982 ratr_value
|= (*(u16
*)(pMcsRate
)) << 12;
3983 // switch (net->mode)
3987 ratr_value
&= 0x00000FF0;
3990 ratr_value
&= 0x0000000F;
3993 ratr_value
&= 0x00000FF7;
3997 if (ieee
->pHTInfo
->PeerMimoPs
== 0) //MIMO_PS_STATIC
3998 ratr_value
&= 0x0007F007;
4000 if (priv
->rf_type
== RF_1T2R
)
4001 ratr_value
&= 0x000FF007;
4003 ratr_value
&= 0x0F81F007;
4009 ratr_value
&= 0x0FFFFFFF;
4010 if(ieee
->pHTInfo
->bCurTxBW40MHz
&& ieee
->pHTInfo
->bCurShortGI40MHz
){
4011 ratr_value
|= 0x80000000;
4012 }else if(!ieee
->pHTInfo
->bCurTxBW40MHz
&& ieee
->pHTInfo
->bCurShortGI20MHz
){
4013 ratr_value
|= 0x80000000;
4015 write_nic_dword(dev
, RATR0
+rate_index
*4, ratr_value
);
4016 write_nic_byte(dev
, UFWP
, 1);
4019 static u8 ccmp_ie
[4] = {0x00,0x50,0xf2,0x04};
4020 static u8 ccmp_rsn_ie
[4] = {0x00, 0x0f, 0xac, 0x04};
4021 bool GetNmodeSupportBySecCfg8192(struct net_device
*dev
)
4024 struct r8192_priv
* priv
= ieee80211_priv(dev
);
4025 struct ieee80211_device
* ieee
= priv
->ieee80211
;
4026 struct ieee80211_network
* network
= &ieee
->current_network
;
4027 int wpa_ie_len
= ieee
->wpa_ie_len
;
4028 struct ieee80211_crypt_data
* crypt
;
4032 crypt
= ieee
->crypt
[ieee
->tx_keyidx
];
4033 //we use connecting AP's capability instead of only security config on our driver to distinguish whether it should use N mode or G mode
4034 encrypt
= (network
->capability
& WLAN_CAPABILITY_PRIVACY
) || (ieee
->host_encrypt
&& crypt
&& crypt
->ops
&& (0 == strcmp(crypt
->ops
->name
,"WEP")));
4037 if(encrypt
&& (wpa_ie_len
== 0)) {
4038 /* wep encryption, no N mode setting */
4040 // } else if((wpa_ie_len != 0)&&(memcmp(&(ieee->wpa_ie[14]),ccmp_ie,4))) {
4041 } else if((wpa_ie_len
!= 0)) {
4042 /* parse pairwise key type */
4043 //if((pairwisekey = WEP40)||(pairwisekey = WEP104)||(pairwisekey = TKIP))
4044 if (((ieee
->wpa_ie
[0] == 0xdd) && (!memcmp(&(ieee
->wpa_ie
[14]),ccmp_ie
,4))) || ((ieee
->wpa_ie
[0] == 0x30) && (!memcmp(&ieee
->wpa_ie
[10],ccmp_rsn_ie
, 4))))
4053 //In here we discuss with SD4 David. He think we still can send TKIP in broadcast group key in MCS rate.
4054 //We can't force in G mode if Pairwie key is AES and group key is TKIP
4055 if((pSecInfo
->GroupEncAlgorithm
== WEP104_Encryption
) || (pSecInfo
->GroupEncAlgorithm
== WEP40_Encryption
) ||
4056 (pSecInfo
->PairwiseEncAlgorithm
== WEP104_Encryption
) ||
4057 (pSecInfo
->PairwiseEncAlgorithm
== WEP40_Encryption
) || (pSecInfo
->PairwiseEncAlgorithm
== TKIP_Encryption
))
4068 bool GetHalfNmodeSupportByAPs819xUsb(struct net_device
* dev
)
4071 struct r8192_priv
* priv
= ieee80211_priv(dev
);
4072 struct ieee80211_device
* ieee
= priv
->ieee80211
;
4074 // Added by Roger, 2008.08.29.
4079 if(ieee
->bHalfWirelessN24GMode
== true)
4087 void rtl8192_refresh_supportrate(struct r8192_priv
* priv
)
4089 struct ieee80211_device
* ieee
= priv
->ieee80211
;
4090 //we donot consider set support rate for ABG mode, only HT MCS rate is set here.
4091 if (ieee
->mode
== WIRELESS_MODE_N_24G
|| ieee
->mode
== WIRELESS_MODE_N_5G
)
4093 memcpy(ieee
->Regdot11HTOperationalRateSet
, ieee
->RegHTSuppRateSet
, 16);
4094 //RT_DEBUG_DATA(COMP_INIT, ieee->RegHTSuppRateSet, 16);
4095 //RT_DEBUG_DATA(COMP_INIT, ieee->Regdot11HTOperationalRateSet, 16);
4098 memset(ieee
->Regdot11HTOperationalRateSet
, 0, 16);
4102 u8
rtl8192_getSupportedWireleeMode(struct net_device
*dev
)
4104 struct r8192_priv
*priv
= ieee80211_priv(dev
);
4106 switch(priv
->rf_chip
)
4112 ret
= (WIRELESS_MODE_N_24G
|WIRELESS_MODE_G
|WIRELESS_MODE_B
);
4115 ret
= (WIRELESS_MODE_A
|WIRELESS_MODE_N_5G
);
4118 ret
= WIRELESS_MODE_B
;
4123 void rtl8192_SetWirelessMode(struct net_device
* dev
, u8 wireless_mode
)
4125 struct r8192_priv
*priv
= ieee80211_priv(dev
);
4126 u8 bSupportMode
= rtl8192_getSupportedWireleeMode(dev
);
4129 if ((wireless_mode
== WIRELESS_MODE_AUTO
) || ((wireless_mode
&bSupportMode
)==0))
4131 if(bSupportMode
& WIRELESS_MODE_N_24G
)
4133 wireless_mode
= WIRELESS_MODE_N_24G
;
4135 else if(bSupportMode
& WIRELESS_MODE_N_5G
)
4137 wireless_mode
= WIRELESS_MODE_N_5G
;
4139 else if((bSupportMode
& WIRELESS_MODE_A
))
4141 wireless_mode
= WIRELESS_MODE_A
;
4143 else if((bSupportMode
& WIRELESS_MODE_G
))
4145 wireless_mode
= WIRELESS_MODE_G
;
4147 else if((bSupportMode
& WIRELESS_MODE_B
))
4149 wireless_mode
= WIRELESS_MODE_B
;
4152 RT_TRACE(COMP_ERR
, "%s(), No valid wireless mode supported, SupportedWirelessMode(%x)!!!\n", __FUNCTION__
,bSupportMode
);
4153 wireless_mode
= WIRELESS_MODE_B
;
4156 #ifdef TO_DO_LIST //// TODO: this function doesn't work well at this time, we shoud wait for FPGA
4157 ActUpdateChannelAccessSetting( pAdapter
, pHalData
->CurrentWirelessMode
, &pAdapter
->MgntInfo
.Info8185
.ChannelAccessSetting
);
4160 //LZM 090306 usb crash here, mark it temp
4161 //write_nic_word(dev, SIFS_OFDM, 0x0e0e);
4163 priv
->ieee80211
->mode
= wireless_mode
;
4165 if ((wireless_mode
== WIRELESS_MODE_N_24G
) || (wireless_mode
== WIRELESS_MODE_N_5G
))
4166 priv
->ieee80211
->pHTInfo
->bEnableHT
= 1;
4168 priv
->ieee80211
->pHTInfo
->bEnableHT
= 0;
4169 RT_TRACE(COMP_INIT
, "Current Wireless Mode is %x\n", wireless_mode
);
4170 rtl8192_refresh_supportrate(priv
);
4176 short rtl8192_is_tx_queue_empty(struct net_device
*dev
)
4179 struct r8192_priv
*priv
= ieee80211_priv(dev
);
4180 //struct ieee80211_device* ieee = priv->ieee80211;
4181 for (i
=0; i
<=MGNT_QUEUE
; i
++)
4183 if ((i
== TXCMD_QUEUE
) || (i
== HCCA_QUEUE
) )
4185 if (atomic_read(&priv
->tx_pending
[i
]))
4187 printk("===>tx queue is not empty:%d, %d\n", i
, atomic_read(&priv
->tx_pending
[i
]));
4194 void rtl8192_rq_tx_ack(struct net_device
*dev
)
4196 struct r8192_priv
*priv
= ieee80211_priv(dev
);
4197 priv
->ieee80211
->ack_tx_to_ieee
= 1;
4200 void rtl8192_hw_sleep_down(struct net_device
*dev
)
4202 RT_TRACE(COMP_POWER
, "%s()============>come to sleep down\n", __FUNCTION__
);
4204 // MgntActSet_RF_State(dev, eRfSleep, RF_CHANGE_BY_PS);
4208 void rtl8192_hw_sleep_wq (struct work_struct
*work
)
4210 // struct r8180_priv *priv = container_of(work, struct r8180_priv, watch_dog_wq);
4211 // struct ieee80211_device * ieee = (struct ieee80211_device*)
4212 // container_of(work, struct ieee80211_device, watch_dog_wq);
4213 struct delayed_work
*dwork
= container_of(work
,struct delayed_work
,work
);
4214 struct ieee80211_device
*ieee
= container_of(dwork
,struct ieee80211_device
,hw_sleep_wq
);
4215 struct net_device
*dev
= ieee
->dev
;
4217 //printk("=========>%s()\n", __FUNCTION__);
4218 rtl8192_hw_sleep_down(dev
);
4220 // printk("dev is %d\n",dev);
4221 // printk("&*&(^*(&(&=========>%s()\n", __FUNCTION__);
4222 void rtl8192_hw_wakeup(struct net_device
* dev
)
4226 // spin_lock_irqsave(&priv->ps_lock,flags);
4227 RT_TRACE(COMP_POWER
, "%s()============>come to wake up\n", __FUNCTION__
);
4229 // MgntActSet_RF_State(dev, eRfSleep, RF_CHANGE_BY_PS);
4231 //FIXME: will we send package stored while nic is sleep?
4232 // spin_unlock_irqrestore(&priv->ps_lock,flags);
4235 void rtl8192_hw_wakeup_wq (struct work_struct
*work
)
4237 // struct r8180_priv *priv = container_of(work, struct r8180_priv, watch_dog_wq);
4238 // struct ieee80211_device * ieee = (struct ieee80211_device*)
4239 // container_of(work, struct ieee80211_device, watch_dog_wq);
4240 struct delayed_work
*dwork
= container_of(work
,struct delayed_work
,work
);
4241 struct ieee80211_device
*ieee
= container_of(dwork
,struct ieee80211_device
,hw_wakeup_wq
);
4242 struct net_device
*dev
= ieee
->dev
;
4244 rtl8192_hw_wakeup(dev
);
4247 #define MIN_SLEEP_TIME 50
4248 #define MAX_SLEEP_TIME 10000
4249 void rtl8192_hw_to_sleep(struct net_device
*dev
, u32 th
, u32 tl
)
4252 struct r8192_priv
*priv
= ieee80211_priv(dev
);
4255 unsigned long flags
;
4257 spin_lock_irqsave(&priv
->ps_lock
,flags
);
4259 /* Writing HW register with 0 equals to disable
4260 * the timer, that is not really what we want
4262 tl
-= MSECS(4+16+7);
4264 //if(tl == 0) tl = 1;
4266 /* FIXME HACK FIXME HACK */
4267 // force_pci_posting(dev);
4270 // rb = read_nic_dword(dev, TSFTR);
4272 /* If the interval in witch we are requested to sleep is too
4273 * short then give up and remain awake
4275 if(((tl
>=rb
)&& (tl
-rb
) <= MSECS(MIN_SLEEP_TIME
))
4276 ||((rb
>tl
)&& (rb
-tl
) < MSECS(MIN_SLEEP_TIME
))) {
4277 spin_unlock_irqrestore(&priv
->ps_lock
,flags
);
4278 printk("too short to sleep\n");
4282 // write_nic_dword(dev, TimerInt, tl);
4283 // rb = read_nic_dword(dev, TSFTR);
4285 u32 tmp
= (tl
>rb
)?(tl
-rb
):(rb
-tl
);
4288 queue_delayed_work(priv
->ieee80211
->wq
, &priv
->ieee80211
->hw_wakeup_wq
, tmp
); //as tl may be less than rb
4290 /* if we suspect the TimerInt is gone beyond tl
4291 * while setting it, then give up
4294 if(((tl
> rb
) && ((tl
-rb
) > MSECS(MAX_SLEEP_TIME
)))||
4295 ((tl
< rb
) && ((rb
-tl
) > MSECS(MAX_SLEEP_TIME
)))) {
4296 printk("========>too long to sleep:%x, %x, %lx\n", tl
, rb
, MSECS(MAX_SLEEP_TIME
));
4297 spin_unlock_irqrestore(&priv
->ps_lock
,flags
);
4301 // if(priv->rf_sleep)
4302 // priv->rf_sleep(dev);
4304 //printk("<=========%s()\n", __FUNCTION__);
4305 queue_delayed_work(priv
->ieee80211
->wq
, (void *)&priv
->ieee80211
->hw_sleep_wq
,0);
4307 spin_unlock_irqrestore(&priv
->ps_lock
,flags
);
4309 //init priv variables here. only non_zero value should be initialized here.
4310 static void rtl8192_init_priv_variable(struct net_device
* dev
)
4312 struct r8192_priv
*priv
= ieee80211_priv(dev
);
4314 priv
->card_8192
= NIC_8192U
;
4315 priv
->chan
= 1; //set to channel 1
4316 priv
->ieee80211
->mode
= WIRELESS_MODE_AUTO
; //SET AUTO
4317 priv
->ieee80211
->iw_mode
= IW_MODE_INFRA
;
4318 priv
->ieee80211
->ieee_up
=0;
4319 priv
->retry_rts
= DEFAULT_RETRY_RTS
;
4320 priv
->retry_data
= DEFAULT_RETRY_DATA
;
4321 priv
->ieee80211
->rts
= DEFAULT_RTS_THRESHOLD
;
4322 priv
->ieee80211
->rate
= 110; //11 mbps
4323 priv
->ieee80211
->short_slot
= 1;
4324 priv
->promisc
= (dev
->flags
& IFF_PROMISC
) ? 1:0;
4327 priv
->IrpPendingCount
= 1;
4328 priv
->ResetProgress
= RESET_TYPE_NORESET
;
4329 priv
->bForcedSilentReset
= 0;
4330 priv
->bDisableNormalResetCheck
= false;
4331 priv
->force_reset
= false;
4333 priv
->ieee80211
->FwRWRF
= 0; //we don't use FW read/write RF until stable firmware is available.
4334 priv
->ieee80211
->current_network
.beacon_interval
= DEFAULT_BEACONINTERVAL
;
4335 priv
->ieee80211
->iw_mode
= IW_MODE_INFRA
;
4336 priv
->ieee80211
->softmac_features
= IEEE_SOFTMAC_SCAN
|
4337 IEEE_SOFTMAC_ASSOCIATE
| IEEE_SOFTMAC_PROBERQ
|
4338 IEEE_SOFTMAC_PROBERS
| IEEE_SOFTMAC_TX_QUEUE
|
4339 IEEE_SOFTMAC_BEACONS
;//added by amy 080604 //| //IEEE_SOFTMAC_SINGLE_QUEUE;
4341 priv
->ieee80211
->active_scan
= 1;
4342 priv
->ieee80211
->modulation
= IEEE80211_CCK_MODULATION
| IEEE80211_OFDM_MODULATION
;
4343 priv
->ieee80211
->host_encrypt
= 1;
4344 priv
->ieee80211
->host_decrypt
= 1;
4345 priv
->ieee80211
->start_send_beacons
= NULL
;//rtl819xusb_beacon_tx;//-by amy 080604
4346 priv
->ieee80211
->stop_send_beacons
= NULL
;//rtl8192_beacon_stop;//-by amy 080604
4347 priv
->ieee80211
->softmac_hard_start_xmit
= rtl8192_hard_start_xmit
;
4348 priv
->ieee80211
->set_chan
= rtl8192_set_chan
;
4349 priv
->ieee80211
->link_change
= priv
->ops
->rtl819x_link_change
;
4350 priv
->ieee80211
->softmac_data_hard_start_xmit
= rtl8192_hard_data_xmit
;
4351 priv
->ieee80211
->data_hard_stop
= rtl8192_data_hard_stop
;
4352 priv
->ieee80211
->data_hard_resume
= rtl8192_data_hard_resume
;
4353 priv
->ieee80211
->init_wmmparam_flag
= 0;
4354 priv
->ieee80211
->fts
= DEFAULT_FRAG_THRESHOLD
;
4355 priv
->ieee80211
->check_nic_enough_desc
= check_nic_enough_desc
;
4356 priv
->ieee80211
->tx_headroom
= TX_PACKET_SHIFT_BYTES
;
4357 priv
->ieee80211
->qos_support
= 1;
4360 // priv->ieee80211->SwChnlByTimerHandler = rtl8192_phy_SwChnl;
4361 priv
->ieee80211
->SetBWModeHandler
= rtl8192_SetBWMode
;
4362 priv
->ieee80211
->handle_assoc_response
= rtl8192_handle_assoc_response
;
4363 priv
->ieee80211
->handle_beacon
= rtl8192_handle_beacon
;
4365 priv
->ieee80211
->sta_wake_up
= rtl8192_hw_wakeup
;
4366 // priv->ieee80211->ps_request_tx_ack = rtl8192_rq_tx_ack;
4367 priv
->ieee80211
->enter_sleep_state
= rtl8192_hw_to_sleep
;
4368 priv
->ieee80211
->ps_is_queue_empty
= rtl8192_is_tx_queue_empty
;
4370 priv
->ieee80211
->GetNmodeSupportBySecCfg
= GetNmodeSupportBySecCfg8192
;
4371 priv
->ieee80211
->GetHalfNmodeSupportByAPsHandler
= GetHalfNmodeSupportByAPs819xUsb
;
4372 priv
->ieee80211
->SetWirelessMode
= rtl8192_SetWirelessMode
;
4374 priv
->ieee80211
->InitialGainHandler
= priv
->ops
->rtl819x_initial_gain
;
4375 priv
->card_type
= USB
;
4379 priv
->ieee80211
->current_network
.beacon_interval
= DEFAULT_BEACONINTERVAL
;
4380 priv
->ieee80211
->SetFwCmdHandler
= HalSetFwCmd8192S
;
4381 priv
->bRFSiOrPi
= 0;//o=si,1=pi;
4383 priv
->bInHctTest
= false;
4385 priv
->MidHighPwrTHR_L1
= 0x3B;
4386 priv
->MidHighPwrTHR_L2
= 0x40;
4388 if(priv
->bInHctTest
)
4390 priv
->ShortRetryLimit
= HAL_RETRY_LIMIT_AP_ADHOC
;
4391 priv
->LongRetryLimit
= HAL_RETRY_LIMIT_AP_ADHOC
;
4395 priv
->ShortRetryLimit
= HAL_RETRY_LIMIT_INFRA
;
4396 priv
->LongRetryLimit
= HAL_RETRY_LIMIT_INFRA
;
4399 priv
->SetFwCmdInProgress
= false; //is set FW CMD in Progress? 92S only
4400 priv
->CurrentFwCmdIO
= 0;
4402 priv
->MinSpaceCfg
= 0;
4404 priv
->EarlyRxThreshold
= 7;
4405 priv
->enable_gpio0
= 0;
4406 priv
->TransmitConfig
=
4407 ((u32
)TCR_MXDMA_2048
<<TCR_MXDMA_OFFSET
) | // Max DMA Burst Size per Tx DMA Burst, 7: reservied.
4408 (priv
->ShortRetryLimit
<<TCR_SRL_OFFSET
) | // Short retry limit
4409 (priv
->LongRetryLimit
<<TCR_LRL_OFFSET
) | // Long retry limit
4410 (false ? TCR_SAT
: 0); // FALSE: HW provies PLCP length and LENGEXT, TURE: SW proiveds them
4411 if(priv
->bInHctTest
)
4412 priv
->ReceiveConfig
= //priv->CSMethod |
4413 RCR_AMF
| RCR_ADF
| //RCR_AAP | //accept management/data
4414 RCR_ACF
|RCR_APPFCS
| //accept control frame for SW AP needs PS-poll, 2005.07.07, by rcnjko.
4415 RCR_AB
| RCR_AM
| RCR_APM
| //accept BC/MC/UC
4416 RCR_AICV
| RCR_ACRC32
| //accept ICV/CRC error packet
4417 RCR_APP_PHYST_STAFF
| RCR_APP_PHYST_RXFF
| // Accept PHY status
4418 ((u32
)7<<RCR_MXDMA_OFFSET
) | // Max DMA Burst Size per Rx DMA Burst, 7: unlimited.
4419 (priv
->EarlyRxThreshold
<<RCR_FIFO_OFFSET
) | // Rx FIFO Threshold, 7: No Rx threshold.
4420 (priv
->EarlyRxThreshold
== 7 ? RCR_OnlyErlPkt
:0);
4422 priv
->ReceiveConfig
= //priv->CSMethod |
4423 RCR_AMF
| RCR_ADF
| RCR_AB
|
4424 RCR_AM
| RCR_APM
|RCR_AAP
|RCR_ADD3
|RCR_APP_ICV
|
4425 RCR_APP_PHYST_STAFF
| RCR_APP_PHYST_RXFF
| // Accept PHY status
4426 RCR_APP_MIC
| RCR_APPFCS
;
4428 // <Roger_EXP> 2008.06.16.
4429 priv
->IntrMask
= (u16
)(IMR_ROK
| IMR_VODOK
| IMR_VIDOK
| IMR_BEDOK
| IMR_BKDOK
| \
4430 IMR_HCCADOK
| IMR_MGNTDOK
| IMR_COMDOK
| IMR_HIGHDOK
| \
4431 IMR_BDOK
| IMR_RXCMDOK
| /*IMR_TIMEOUT0 |*/ IMR_RDU
| IMR_RXFOVW
| \
4432 IMR_TXFOVW
| IMR_BcnInt
| IMR_TBDOK
| IMR_TBDER
);
4439 if(Adapter
->bInHctTest
)
4441 pHalData
->ShortRetryLimit
= 7;
4442 pHalData
->LongRetryLimit
= 7;
4446 priv
->ShortRetryLimit
= 0x30;
4447 priv
->LongRetryLimit
= 0x30;
4449 priv
->EarlyRxThreshold
= 7;
4450 priv
->enable_gpio0
= 0;
4451 priv
->TransmitConfig
=
4452 // TCR_DurProcMode | //for RTL8185B, duration setting by HW
4453 //? TCR_DISReqQsize |
4454 (TCR_MXDMA_2048
<<TCR_MXDMA_OFFSET
)| // Max DMA Burst Size per Tx DMA Burst, 7: reservied.
4455 (priv
->ShortRetryLimit
<<TCR_SRL_OFFSET
)| // Short retry limit
4456 (priv
->LongRetryLimit
<<TCR_LRL_OFFSET
) | // Long retry limit
4457 (false ? TCR_SAT
: 0); // FALSE: HW provies PLCP length and LENGEXT, TURE: SW proiveds them
4459 if(Adapter
->bInHctTest
)
4460 pHalData
->ReceiveConfig
= pHalData
->CSMethod
|
4461 RCR_AMF
| RCR_ADF
| //RCR_AAP | //accept management/data
4463 RCR_ACF
| //accept control frame for SW AP needs PS-poll, 2005.07.07, by rcnjko.
4464 RCR_AB
| RCR_AM
| RCR_APM
| //accept BC/MC/UC
4465 RCR_AICV
| RCR_ACRC32
| //accept ICV/CRC error packet
4466 ((u32
)7<<RCR_MXDMA_OFFSET
) | // Max DMA Burst Size per Rx DMA Burst, 7: unlimited.
4467 (pHalData
->EarlyRxThreshold
<<RCR_FIFO_OFFSET
) | // Rx FIFO Threshold, 7: No Rx threshold.
4468 (pHalData
->EarlyRxThreshold
== 7 ? RCR_OnlyErlPkt
:0);
4472 priv
->ReceiveConfig
=
4473 RCR_AMF
| RCR_ADF
| //accept management/data
4474 RCR_ACF
| //accept control frame for SW AP needs PS-poll, 2005.07.07, by rcnjko.
4475 RCR_AB
| RCR_AM
| RCR_APM
| //accept BC/MC/UC
4476 //RCR_AICV | RCR_ACRC32 | //accept ICV/CRC error packet
4477 ((u32
)7<<RCR_MXDMA_OFFSET
)| // Max DMA Burst Size per Rx DMA Burst, 7: unlimited.
4478 (priv
->EarlyRxThreshold
<<RX_FIFO_THRESHOLD_SHIFT
) | // Rx FIFO Threshold, 7: No Rx threshold.
4479 (priv
->EarlyRxThreshold
== 7 ? RCR_ONLYERLPKT
:0);
4482 priv
->AcmControl
= 0;
4483 priv
->pFirmware
= (rt_firmware
*)vmalloc(sizeof(rt_firmware
));
4484 if (priv
->pFirmware
)
4485 memset(priv
->pFirmware
, 0, sizeof(rt_firmware
));
4487 /* rx related queue */
4488 skb_queue_head_init(&priv
->rx_queue
);
4489 skb_queue_head_init(&priv
->skb_queue
);
4491 /* Tx related queue */
4492 for(i
= 0; i
< MAX_QUEUE_SIZE
; i
++) {
4493 skb_queue_head_init(&priv
->ieee80211
->skb_waitQ
[i
]);
4495 for(i
= 0; i
< MAX_QUEUE_SIZE
; i
++) {
4496 skb_queue_head_init(&priv
->ieee80211
->skb_aggQ
[i
]);
4498 for(i
= 0; i
< MAX_QUEUE_SIZE
; i
++) {
4499 skb_queue_head_init(&priv
->ieee80211
->skb_drv_aggQ
[i
]);
4501 priv
->rf_set_chan
= rtl8192_phy_SwChnl
;
4505 static void rtl8192_init_priv_lock(struct r8192_priv
* priv
)
4507 spin_lock_init(&priv
->tx_lock
);
4508 spin_lock_init(&priv
->irq_lock
);//added by thomas
4509 //spin_lock_init(&priv->rf_lock);//use rf_sem, or will crash in some OS.
4510 sema_init(&priv
->wx_sem
,1);
4511 sema_init(&priv
->rf_sem
,1);
4512 spin_lock_init(&priv
->ps_lock
);
4513 mutex_init(&priv
->mutex
);
4516 extern void rtl819x_watchdog_wqcallback(struct work_struct
*work
);
4518 void rtl8192_irq_rx_tasklet(struct r8192_priv
*priv
);
4519 //init tasklet and wait_queue here. only 2.6 above kernel is considered
4520 #define DRV_NAME "wlan0"
4521 static void rtl8192_init_priv_task(struct net_device
* dev
)
4523 struct r8192_priv
*priv
= ieee80211_priv(dev
);
4525 #ifdef PF_SYNCTHREAD
4526 priv
->priv_wq
= create_workqueue(DRV_NAME
,0);
4528 priv
->priv_wq
= create_workqueue(DRV_NAME
);
4531 INIT_WORK(&priv
->reset_wq
, rtl8192_restart
);
4533 //INIT_DELAYED_WORK(&priv->watch_dog_wq, hal_dm_watchdog);
4534 INIT_DELAYED_WORK(&priv
->watch_dog_wq
, rtl819x_watchdog_wqcallback
);
4535 INIT_DELAYED_WORK(&priv
->txpower_tracking_wq
, dm_txpower_trackingcallback
);
4536 // INIT_DELAYED_WORK(&priv->gpio_change_rf_wq, dm_gpio_change_rf_callback);
4537 INIT_DELAYED_WORK(&priv
->rfpath_check_wq
, dm_rf_pathcheck_workitemcallback
);
4538 INIT_DELAYED_WORK(&priv
->update_beacon_wq
, rtl8192_update_beacon
);
4539 INIT_DELAYED_WORK(&priv
->initialgain_operate_wq
, InitialGainOperateWorkItemCallBack
);
4540 //INIT_WORK(&priv->SwChnlWorkItem, rtl8192_SwChnl_WorkItem);
4541 //INIT_WORK(&priv->SetBWModeWorkItem, rtl8192_SetBWModeWorkItem);
4542 INIT_WORK(&priv
->qos_activate
, rtl8192_qos_activate
);
4543 INIT_DELAYED_WORK(&priv
->ieee80211
->hw_wakeup_wq
,(void*) rtl8192_hw_wakeup_wq
);
4544 INIT_DELAYED_WORK(&priv
->ieee80211
->hw_sleep_wq
,(void*) rtl8192_hw_sleep_wq
);
4546 tasklet_init(&priv
->irq_rx_tasklet
,
4547 (void(*)(unsigned long))rtl8192_irq_rx_tasklet
,
4548 (unsigned long)priv
);
4551 static void rtl8192_get_eeprom_size(struct net_device
* dev
)
4554 struct r8192_priv
*priv
= ieee80211_priv(dev
);
4555 RT_TRACE(COMP_EPROM
, "===========>%s()\n", __FUNCTION__
);
4556 curCR
= read_nic_word_E(dev
,EPROM_CMD
);
4557 RT_TRACE(COMP_EPROM
, "read from Reg EPROM_CMD(%x):%x\n", EPROM_CMD
, curCR
);
4558 //whether need I consider BIT5?
4559 priv
->epromtype
= (curCR
& Cmd9346CR_9356SEL
) ? EPROM_93c56
: EPROM_93c46
;
4560 RT_TRACE(COMP_EPROM
, "<===========%s(), epromtype:%d\n", __FUNCTION__
, priv
->epromtype
);
4563 //used to swap endian. as ntohl & htonl are not neccessary to swap endian, so use this instead.
4564 static inline u16
endian_swap(u16
* data
)
4567 *data
= (tmp
>> 8) | (tmp
<< 8);
4572 u8
rtl8192SU_UsbOptionToEndPointNumber(u8 UsbOption
)
4587 RT_TRACE(COMP_INIT
, "UsbOptionToEndPointNumber(): Invalid UsbOption(%#x)\n", UsbOption
);
4593 u8
rtl8192SU_BoardTypeToRFtype(struct net_device
* dev
, u8 Boardtype
)
4595 u8 RFtype
= RF_1T2R
;
4609 RFtype
= RF_2T2R_GREEN
;
4620 // Config HW adapter information into initial value.
4623 // 1. After Auto load fail(i.e, check CR9346 fail)
4625 // Created by Roger, 2008.10.21.
4628 rtl8192SU_ConfigAdapterInfo8192SForAutoLoadFail(struct net_device
* dev
)
4630 struct r8192_priv
*priv
= ieee80211_priv(dev
);
4632 //u8 sMacAddr[6] = {0x00, 0xE0, 0x4C, 0x81, 0x92, 0x00};
4633 u8 rf_path
, index
; // For EEPROM/EFUSE After V0.6_1117
4636 RT_TRACE(COMP_INIT
, "====> ConfigAdapterInfo8192SForAutoLoadFail\n");
4638 write_nic_byte(dev
, SYS_ISO_CTRL
+1, 0xE8); // Isolation signals from Loader
4639 //PlatformStallExecution(10000);
4641 write_nic_byte(dev
, PMC_FSM
, 0x02); // Enable Loader Data Keep
4643 //RT_ASSERT(priv->AutoloadFailFlag==TRUE, ("ReadAdapterInfo8192SEEPROM(): AutoloadFailFlag !=TRUE\n"));
4645 // Initialize IC Version && Channel Plan
4646 priv
->eeprom_vid
= 0;
4647 priv
->eeprom_pid
= 0;
4648 priv
->card_8192_version
= 0;
4649 priv
->eeprom_ChannelPlan
= 0;
4650 priv
->eeprom_CustomerID
= 0;
4651 priv
->eeprom_SubCustomerID
= 0;
4652 priv
->bIgnoreDiffRateTxPowerOffset
= false;
4654 RT_TRACE(COMP_INIT
, "EEPROM VID = 0x%4x\n", priv
->eeprom_vid
);
4655 RT_TRACE(COMP_INIT
, "EEPROM PID = 0x%4x\n", priv
->eeprom_pid
);
4656 RT_TRACE(COMP_INIT
, "EEPROM Customer ID: 0x%2x\n", priv
->eeprom_CustomerID
);
4657 RT_TRACE(COMP_INIT
, "EEPROM SubCustomer ID: 0x%2x\n", priv
->eeprom_SubCustomerID
);
4658 RT_TRACE(COMP_INIT
, "EEPROM ChannelPlan = 0x%4x\n", priv
->eeprom_ChannelPlan
);
4659 RT_TRACE(COMP_INIT
, "IgnoreDiffRateTxPowerOffset = %d\n", priv
->bIgnoreDiffRateTxPowerOffset
);
4663 priv
->EEPROMUsbOption
= EEPROM_USB_Default_OPTIONAL_FUNC
;
4664 RT_TRACE(COMP_INIT
, "USB Option = %#x\n", priv
->EEPROMUsbOption
);
4667 priv
->EEPROMUsbPhyParam
[i
] = EEPROM_USB_Default_PHY_PARAM
;
4669 //RT_PRINT_DATA(COMP_INIT|COMP_EFUSE, DBG_LOUD, ("EFUSE USB PHY Param: \n"), priv->EEPROMUsbPhyParam, 5);
4672 //<Roger_Notes> In this case, we random assigh MAC address here. 2008.10.15.
4673 static u8 sMacAddr
[6] = {0x00, 0xE0, 0x4C, 0x81, 0x92, 0x00};
4676 //sMacAddr[5] = (u8)GetRandomNumber(1, 254);
4678 for(i
= 0; i
< 6; i
++)
4679 dev
->dev_addr
[i
] = sMacAddr
[i
];
4681 //NicIFSetMacAddress(Adapter, Adapter->PermanentAddress);
4682 write_nic_dword(dev
, IDR0
, ((u32
*)dev
->dev_addr
)[0]);
4683 write_nic_word(dev
, IDR4
, ((u16
*)(dev
->dev_addr
+ 4))[0]);
4685 RT_TRACE(COMP_INIT
, "ReadAdapterInfo8192SEFuse(), Permanent Address = %02x-%02x-%02x-%02x-%02x-%02x\n",
4686 dev
->dev_addr
[0], dev
->dev_addr
[1],
4687 dev
->dev_addr
[2], dev
->dev_addr
[3],
4688 dev
->dev_addr
[4], dev
->dev_addr
[5]);
4690 priv
->EEPROMBoardType
= EEPROM_Default_BoardType
;
4691 priv
->rf_type
= RF_1T2R
; //RF_2T2R
4692 priv
->EEPROMTxPowerDiff
= EEPROM_Default_PwDiff
;
4693 priv
->EEPROMThermalMeter
= EEPROM_Default_ThermalMeter
;
4694 priv
->EEPROMCrystalCap
= EEPROM_Default_CrystalCap
;
4695 priv
->EEPROMTxPwrBase
= EEPROM_Default_TxPowerBase
;
4696 priv
->EEPROMTSSI_A
= EEPROM_Default_TSSI
;
4697 priv
->EEPROMTSSI_B
= EEPROM_Default_TSSI
;
4698 priv
->EEPROMTxPwrTkMode
= EEPROM_Default_TxPwrTkMode
;
4702 for (rf_path
= 0; rf_path
< 2; rf_path
++)
4704 for (i
= 0; i
< 3; i
++)
4706 // Read CCK RF A & B Tx power
4707 priv
->RfCckChnlAreaTxPwr
[rf_path
][i
] =
4708 priv
->RfOfdmChnlAreaTxPwr1T
[rf_path
][i
] =
4709 priv
->RfOfdmChnlAreaTxPwr2T
[rf_path
][i
] =
4710 (u8
)(EEPROM_Default_TxPower
& 0xff);
4714 for (i
= 0; i
< 3; i
++)
4716 //RT_TRACE((COMP_EFUSE), "CCK RF-%d CHan_Area-%d = 0x%x\n", rf_path, i,
4717 //priv->RfCckChnlAreaTxPwr[rf_path][i]);
4718 //RT_TRACE((COMP_EFUSE), "OFDM-1T RF-%d CHan_Area-%d = 0x%x\n", rf_path, i,
4719 //priv->RfOfdmChnlAreaTxPwr1T[rf_path][i]);
4720 //RT_TRACE((COMP_EFUSE), "OFDM-2T RF-%d CHan_Area-%d = 0x%x\n", rf_path, i,
4721 //priv->RfOfdmChnlAreaTxPwr2T[rf_path][i]);
4724 // Assign dedicated channel tx power
4725 for(i
=0; i
<14; i
++) // channel 1~3 use the same Tx Power Level.
4727 if (i
< 3) // Cjanel 1-3
4729 else if (i
< 9) // Channel 4-9
4731 else // Channel 10-14
4734 // Record A & B CCK /OFDM - 1T/2T Channel area tx power
4735 priv
->RfTxPwrLevelCck
[rf_path
][i
] =
4736 priv
->RfCckChnlAreaTxPwr
[rf_path
][index
];
4737 priv
->RfTxPwrLevelOfdm1T
[rf_path
][i
] =
4738 priv
->RfOfdmChnlAreaTxPwr1T
[rf_path
][index
];
4739 priv
->RfTxPwrLevelOfdm2T
[rf_path
][i
] =
4740 priv
->RfOfdmChnlAreaTxPwr2T
[rf_path
][index
];
4745 //RT_TRACE((COMP_EFUSE), "Rf-%d TxPwr CH-%d CCK OFDM_1T OFDM_2T= 0x%x/0x%x/0x%x\n",
4746 //rf_path, i, priv->RfTxPwrLevelCck[0][i],
4747 //priv->RfTxPwrLevelOfdm1T[0][i] ,
4748 //priv->RfTxPwrLevelOfdm2T[0][i] );
4752 // Update remained HAL variables.
4754 priv
->TSSI_13dBm
= priv
->EEPROMThermalMeter
*100;
4755 priv
->LegacyHTTxPowerDiff
= priv
->EEPROMTxPowerDiff
;//new
4756 priv
->TxPowerDiff
= priv
->EEPROMTxPowerDiff
;
4757 //priv->AntennaTxPwDiff[0] = (priv->EEPROMTxPowerDiff & 0xf);// Antenna B gain offset to antenna A, bit0~3
4758 //priv->AntennaTxPwDiff[1] = ((priv->EEPROMTxPowerDiff & 0xf0)>>4);// Antenna C gain offset to antenna A, bit4~7
4759 priv
->CrystalCap
= priv
->EEPROMCrystalCap
; // CrystalCap, bit12~15
4760 priv
->ThermalMeter
[0] = priv
->EEPROMThermalMeter
;// ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2
4761 priv
->LedStrategy
= SW_LED_MODE0
;
4763 init_rate_adaptive(dev
);
4765 RT_TRACE(COMP_INIT
, "<==== ConfigAdapterInfo8192SForAutoLoadFail\n");
4770 static void rtl8192SU_ReadAdapterInfo8192SEEPROM(struct net_device
* dev
)
4773 u8 bLoad_From_EEPOM
= false;
4774 struct r8192_priv
*priv
= ieee80211_priv(dev
);
4779 RT_TRACE(COMP_EPROM
, "===========>%s()\n", __FUNCTION__
);
4782 write_nic_byte(dev
, SYS_ISO_CTRL
+1, 0xE8); // Isolation signals from Loader
4784 write_nic_byte(dev
, PMC_FSM
, 0x02); // Enable Loader Data Keep
4787 EEPROMId
= eprom_read(dev
, 0); //first read EEPROM ID out;
4788 RT_TRACE(COMP_EPROM
, "EEPROM ID is 0x%x\n", EEPROMId
);
4790 if (EEPROMId
!= RTL8190_EEPROM_ID
)
4792 priv
->AutoloadFailFlag
= true;
4793 RT_TRACE(COMP_ERR
, "EEPROM ID is invalid(is 0x%x(should be 0x%x)\n", EEPROMId
, RTL8190_EEPROM_ID
);
4797 priv
->AutoloadFailFlag
= false;
4798 bLoad_From_EEPOM
= true;
4801 if (bLoad_From_EEPOM
)
4803 tmpValue
= eprom_read(dev
, (EEPROM_VID
>>1));
4804 priv
->eeprom_vid
= endian_swap(&tmpValue
);
4805 priv
->eeprom_pid
= eprom_read(dev
, (EEPROM_PID
>>1));
4807 // Version ID, Channel plan
4808 tmpValue
= eprom_read(dev
, (EEPROM_Version
>>1));
4809 //pHalData->card_8192_version = (VERSION_8192S)((usValue&0x00ff));
4810 priv
->eeprom_ChannelPlan
=(tmpValue
&0xff00)>>8;
4811 priv
->bTXPowerDataReadFromEEPORM
= true;
4813 // Customer ID, 0x00 and 0xff are reserved for Realtek.
4814 tmpValue
= eprom_read(dev
, (u16
)(EEPROM_CustomID
>>1)) ;
4815 priv
->eeprom_CustomerID
= (u8
)( tmpValue
& 0xff);
4816 priv
->eeprom_SubCustomerID
= (u8
)((tmpValue
& 0xff00)>>8);
4820 priv
->eeprom_vid
= 0;
4821 priv
->eeprom_pid
= 0;
4822 //priv->card_8192_version = VERSION_8192SU_A;
4823 priv
->eeprom_ChannelPlan
= 0;
4824 priv
->eeprom_CustomerID
= 0;
4825 priv
->eeprom_SubCustomerID
= 0;
4827 RT_TRACE(COMP_EPROM
, "vid:0x%4x, pid:0x%4x, CustomID:0x%2x, ChanPlan:0x%x\n", priv
->eeprom_vid
, priv
->eeprom_pid
, priv
->eeprom_CustomerID
, priv
->eeprom_ChannelPlan
);
4828 //set channelplan from eeprom
4829 priv
->ChannelPlan
= priv
->eeprom_ChannelPlan
;// FIXLZM
4831 RT_TRACE(COMP_INIT
, "EEPROMId = 0x%4x\n", EEPROMId
);
4832 RT_TRACE(COMP_INIT
, "EEPROM VID = 0x%4x\n", priv
->eeprom_vid
);
4833 RT_TRACE(COMP_INIT
, "EEPROM PID = 0x%4x\n", priv
->eeprom_pid
);
4834 //RT_TRACE(COMP_INIT, DBG_LOUD, ("EEPROM Version ID: 0x%2x\n", pHalData->VersionID));
4835 RT_TRACE(COMP_INIT
, "EEPROM Customer ID: 0x%2x\n", priv
->eeprom_CustomerID
);
4836 RT_TRACE(COMP_INIT
, "EEPROM SubCustomer ID: 0x%2x\n", priv
->eeprom_SubCustomerID
);
4837 RT_TRACE(COMP_INIT
, "EEPROM ChannelPlan = 0x%4x\n", priv
->eeprom_ChannelPlan
);
4839 // Read USB optional function.
4840 if(bLoad_From_EEPOM
)
4842 tmpValue
= eprom_read(dev
, (EEPROM_USB_OPTIONAL
>>1));
4843 priv
->EEPROMUsbOption
= (u8
)(tmpValue
&0xff);
4847 priv
->EEPROMUsbOption
= EEPROM_USB_Default_OPTIONAL_FUNC
;
4850 RT_TRACE(COMP_INIT
, "USB Option = %#x\n", priv
->EEPROMUsbOption
);
4853 if (bLoad_From_EEPOM
)
4856 for (i
=0; i
<6; i
+=2)
4859 tmp
= eprom_read(dev
, (u16
)((EEPROM_NODE_ADDRESS_BYTE_0
+ i
)>>1));
4860 *(u16
*)(&dev
->dev_addr
[i
]) = tmp
;
4865 //<Roger_Notes> In this case, we random assigh MAC address here. 2008.10.15.
4866 static u8 sMacAddr
[6] = {0x00, 0xE0, 0x4C, 0x81, 0x92, 0x00};
4869 //sMacAddr[5] = (u8)GetRandomNumber(1, 254);
4871 for(i
= 0; i
< 6; i
++)
4872 dev
->dev_addr
[i
] = sMacAddr
[i
];
4874 //memcpy(dev->dev_addr, sMacAddr, 6);
4875 //should I set IDR0 here?
4877 write_nic_dword(dev
, IDR0
, ((u32
*)dev
->dev_addr
)[0]);
4878 write_nic_word(dev
, IDR4
, ((u16
*)(dev
->dev_addr
+ 4))[0]);
4879 RT_TRACE(COMP_EPROM
, "MAC addr:"MAC_FMT
"\n", MAC_ARG(dev
->dev_addr
));
4881 priv
->rf_type
= RTL819X_DEFAULT_RF_TYPE
; //default 1T2R
4882 priv
->rf_chip
= RF_6052
;
4883 priv
->rf_type
= RTL819X_DEFAULT_RF_TYPE
;
4884 //priv->card_8192_version = VERSION_8192SU_A; //Over write for temporally experiment. 2008.10.16. By Roger.
4888 if(bLoad_From_EEPOM
)
4890 tempval
= (ReadEEprom(Adapter
, (EEPROM_RFInd_PowerDiff
>>1))) & 0xff;
4891 if (tempval
&0x80) //RF-indication, bit[7]
4892 pHalData
->RF_Type
= RF_1T2R
;
4894 pHalData
->RF_Type
= RF_2T4R
;
4898 priv
->EEPROMTxPowerDiff
= EEPROM_Default_TxPowerDiff
;
4899 RT_TRACE(COMP_INIT
, "TxPowerDiff = %#x\n", priv
->EEPROMTxPowerDiff
);
4903 // Read antenna tx power offset of B/C/D to A from EEPROM
4904 // and read ThermalMeter from EEPROM
4906 if(bLoad_From_EEPOM
)
4908 tmpValue
= eprom_read(dev
, (EEPROM_PwDiff
>>1));
4909 priv
->EEPROMPwDiff
= tmpValue
&0x00ff;
4910 priv
->EEPROMThermalMeter
= (tmpValue
&0xff00)>>8;
4914 priv
->EEPROMPwDiff
= EEPROM_Default_PwDiff
;
4915 priv
->EEPROMThermalMeter
= EEPROM_Default_ThermalMeter
;
4917 RT_TRACE(COMP_INIT
, "PwDiff = %#x\n", priv
->EEPROMPwDiff
);
4918 RT_TRACE(COMP_INIT
, "ThermalMeter = %#x\n", priv
->EEPROMThermalMeter
);
4920 priv
->TSSI_13dBm
= priv
->EEPROMThermalMeter
*100;
4923 // Read CrystalCap from EEPROM
4924 if(bLoad_From_EEPOM
)
4926 priv
->EEPROMCrystalCap
=(u8
) (((eprom_read(dev
, (EEPROM_CrystalCap
>>1)))&0xf000)>>12);
4930 priv
->EEPROMCrystalCap
= EEPROM_Default_CrystalCap
;
4932 RT_TRACE(COMP_INIT
, "CrystalCap = %#x\n", priv
->EEPROMCrystalCap
);
4935 //if(pHalData->EEPROM_Def_Ver == 0) // old eeprom definition
4939 // Get Tx Power Base.//===>
4941 if(bLoad_From_EEPOM
)
4943 priv
->EEPROMTxPwrBase
=(u8
) ((eprom_read(dev
, (EEPROM_TxPowerBase
>>1)))&0xff);
4947 priv
->EEPROMTxPwrBase
= EEPROM_Default_TxPowerBase
;
4950 RT_TRACE(COMP_INIT
, "TxPwrBase = %#x\n", priv
->EEPROMTxPwrBase
);
4953 // Get CustomerID(Boad Type)
4954 // i.e., 0x0: RTL8188SU, 0x1: RTL8191SU, 0x2: RTL8192SU, 0x3: RTL8191GU.
4955 // Others: Reserved. Default is 0x2: RTL8192SU.
4957 if(bLoad_From_EEPOM
)
4959 tmpValue
= eprom_read(dev
, (u16
) (EEPROM_BoardType
>>1));
4960 priv
->EEPROMBoardType
= (u8
)(tmpValue
&0xff);
4964 priv
->EEPROMBoardType
= EEPROM_Default_BoardType
;
4967 RT_TRACE(COMP_INIT
, "BoardType = %#x\n", priv
->EEPROMBoardType
);
4969 // Please add code in the section!!!!
4970 // And merge tx power difference section.
4973 // Get TSSI value for each path.
4975 if(bLoad_From_EEPOM
)
4977 tmpValue
= eprom_read(dev
, (u16
) ((EEPROM_TSSI_A
)>>1));
4978 priv
->EEPROMTSSI_A
= (u8
)((tmpValue
&0xff00)>>8);
4981 { // Default setting for Empty EEPROM
4982 priv
->EEPROMTSSI_A
= EEPROM_Default_TSSI
;
4985 if(bLoad_From_EEPOM
)
4987 tmpValue
= eprom_read(dev
, (u16
) ((EEPROM_TSSI_B
)>>1));
4988 priv
->EEPROMTSSI_B
= (u8
)(tmpValue
&0xff);
4989 priv
->EEPROMTxPwrTkMode
= (u8
)((tmpValue
&0xff00)>>8);
4992 { // Default setting for Empty EEPROM
4993 priv
->EEPROMTSSI_B
= EEPROM_Default_TSSI
;
4994 priv
->EEPROMTxPwrTkMode
= EEPROM_Default_TxPwrTkMode
;
4997 RT_TRACE(COMP_INIT
, "TSSI_A = %#x, TSSI_B = %#x\n", priv
->EEPROMTSSI_A
, priv
->EEPROMTSSI_B
);
4998 RT_TRACE(COMP_INIT
, "TxPwrTkMod = %#x\n", priv
->EEPROMTxPwrTkMode
);
5004 priv
->TxPowerDiff
= priv
->EEPROMPwDiff
;
5005 // Antenna B gain offset to antenna A, bit0~3
5006 priv
->AntennaTxPwDiff
[0] = (priv
->EEPROMTxPowerDiff
& 0xf);
5007 // Antenna C gain offset to antenna A, bit4~7
5008 priv
->AntennaTxPwDiff
[1] = ((priv
->EEPROMTxPowerDiff
& 0xf0)>>4);
5009 // CrystalCap, bit12~15
5010 priv
->CrystalCap
= priv
->EEPROMCrystalCap
;
5011 // ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2
5012 // 92U does not enable TX power tracking.
5013 priv
->ThermalMeter
[0] = priv
->EEPROMThermalMeter
;
5016 priv
->LedStrategy
= SW_LED_MODE0
;
5018 if(priv
->rf_type
== RF_1T2R
)
5020 RT_TRACE(COMP_EPROM
, "\n1T2R config\n");
5024 RT_TRACE(COMP_EPROM
, "\n2T4R config\n");
5027 // 2008/01/16 MH We can only know RF type in the function. So we have to init
5028 // DIG RATR table again.
5029 init_rate_adaptive(dev
);
5030 //we need init DIG RATR table here again.
5032 RT_TRACE(COMP_EPROM
, "<===========%s()\n", __FUNCTION__
);
5038 // 1. Read HW adapter information by E-Fuse.
5039 // 2. Refered from SD1 Richard.
5042 // 1. Boot from E-Fuse and CR9346 regiser has verified.
5043 // 2. PASSIVE_LEVEL (USB interface)
5045 // Created by Roger, 2008.10.21.
5048 rtl8192SU_ReadAdapterInfo8192SEFuse(struct net_device
* dev
)
5050 struct r8192_priv
*priv
= ieee80211_priv(dev
);
5058 u8 hwinfo
[HWSET_MAX_SIZE_92S
];
5061 RT_TRACE(COMP_INIT
, "====> ReadAdapterInfo8192SEFuse\n");
5064 // <Roger_Notes> We set Isolation signals from Loader and reset EEPROM after system resuming
5065 // from suspend mode.
5068 write_nic_byte(dev
, SYS_ISO_CTRL
+1, 0xE8); // Isolation signals from Loader
5069 //PlatformStallExecution(10000);
5071 write_nic_byte(dev
, SYS_FUNC_EN
+1, 0x40);
5072 write_nic_byte(dev
, SYS_FUNC_EN
+1, 0x50);
5074 readbyte
= read_nic_byte(dev
, EFUSE_TEST
+3);
5075 write_nic_byte(dev
, EFUSE_TEST
+3, (readbyte
| 0x80));
5076 write_nic_byte(dev
, EFUSE_TEST
+3, 0x72);
5077 write_nic_byte(dev
, EFUSE_CLK
, 0x03);
5080 // Dump EFUSe at init time for later use
5082 // Read EFUSE real map to shadow!!
5083 EFUSE_ShadowMapUpdate(dev
);
5085 memcpy(hwinfo
, (void*)&priv
->EfuseMap
[EFUSE_INIT_MAP
][0], HWSET_MAX_SIZE_92S
);
5086 //RT_PRINT_DATA(COMP_INIT, DBG_LOUD, ("MAP \n"), hwinfo, HWSET_MAX_SIZE_92S);
5089 // <Roger_Notes> Event though CR9346 regiser can verify whether Autoload is success or not, but we still
5090 // double check ID codes for 92S here(e.g., due to HW GPIO polling fail issue).
5093 ReadEFuse(dev
, 0, 2, (unsigned char*) &EEPROMId
);
5095 if( EEPROMId
!= RTL8190_EEPROM_ID
)
5097 RT_TRACE(COMP_INIT
, "EEPROM ID(%#x) is invalid!!\n", EEPROMId
);
5098 priv
->AutoloadFailFlag
=true;
5102 priv
->AutoloadFailFlag
=false;
5105 // Read IC Version && Channel Plan
5106 if(!priv
->AutoloadFailFlag
)
5110 ReadEFuse(dev
, EEPROM_VID
, 2, (unsigned char*) &priv
->eeprom_vid
);
5111 ReadEFuse(dev
, EEPROM_PID
, 2, (unsigned char*) &priv
->eeprom_pid
);
5113 // Version ID, Channel plan
5114 ReadEFuse(dev
, EEPROM_Version
, 2, (unsigned char*) &usValue
);
5115 //pHalData->VersionID = (VERSION_8192S)(usValue&0x00ff);
5116 priv
->eeprom_ChannelPlan
= (usValue
&0xff00>>8);
5117 priv
->bTXPowerDataReadFromEEPORM
= true;
5119 // Customer ID, 0x00 and 0xff are reserved for Realtek.
5120 ReadEFuse(dev
, EEPROM_CustomID
, 2, (unsigned char*) &usValue
);
5121 priv
->eeprom_CustomerID
= (u8
)( usValue
& 0xff);
5122 priv
->eeprom_SubCustomerID
= (u8
)((usValue
& 0xff00)>>8);
5126 priv
->eeprom_vid
= 0;
5127 priv
->eeprom_pid
= 0;
5128 priv
->eeprom_ChannelPlan
= 0;
5129 priv
->eeprom_CustomerID
= 0;
5130 priv
->eeprom_SubCustomerID
= 0;
5133 RT_TRACE(COMP_INIT
, "EEPROM Id = 0x%4x\n", EEPROMId
);
5134 RT_TRACE(COMP_INIT
, "EEPROM VID = 0x%4x\n", priv
->eeprom_vid
);
5135 RT_TRACE(COMP_INIT
, "EEPROM PID = 0x%4x\n", priv
->eeprom_pid
);
5136 //RT_TRACE(COMP_INIT, DBG_LOUD, ("EEPROM Version ID: 0x%2x\n", pHalData->VersionID));
5137 RT_TRACE(COMP_INIT
, "EEPROM Customer ID: 0x%2x\n", priv
->eeprom_CustomerID
);
5138 RT_TRACE(COMP_INIT
, "EEPROM SubCustomer ID: 0x%2x\n", priv
->eeprom_SubCustomerID
);
5139 RT_TRACE(COMP_INIT
, "EEPROM ChannelPlan = 0x%4x\n", priv
->eeprom_ChannelPlan
);
5142 // Read USB optional function.
5143 if(!priv
->AutoloadFailFlag
)
5145 ReadEFuse(dev
, EEPROM_USB_OPTIONAL
, 1, (unsigned char*) &priv
->EEPROMUsbOption
);
5149 priv
->EEPROMUsbOption
= EEPROM_USB_Default_OPTIONAL_FUNC
;
5152 RT_TRACE(COMP_INIT
, "USB Option = %#x\n", priv
->EEPROMUsbOption
);
5155 // Read USB PHY parameters.
5156 if(!priv
->AutoloadFailFlag
)
5158 ReadEFuse(dev
, EEPROM_USB_PHY_PARA1
, 5, (unsigned char*)UsbPhyParam
);
5161 priv
->EEPROMUsbPhyParam
[i
] = UsbPhyParam
[i
];
5162 RT_TRACE(COMP_INIT
, "USB Param = index(%d) = %#x\n", i
, priv
->EEPROMUsbPhyParam
[i
]);
5169 priv
->EEPROMUsbPhyParam
[i
] = EEPROM_USB_Default_PHY_PARAM
;
5170 RT_TRACE(COMP_INIT
, "USB Param = index(%d) = %#x\n", i
, priv
->EEPROMUsbPhyParam
[i
]);
5175 //Read Permanent MAC address
5176 if(!priv
->AutoloadFailFlag
)
5178 u8 macaddr
[6] = {0x00, 0xe1, 0x86, 0x4c, 0x92, 0x00};
5180 ReadEFuse(dev
, EEPROM_NODE_ADDRESS_BYTE_0
, 6, (unsigned char*)macaddr
);
5182 dev
->dev_addr
[i
] = macaddr
[i
];
5187 //<Roger_Notes> In this case, we random assigh MAC address here. 2008.10.15.
5188 static u8 sMacAddr
[6] = {0x00, 0xE0, 0x4C, 0x81, 0x92, 0x00};
5191 //if(!Adapter->bInHctTest)
5192 //sMacAddr[5] = (u8)GetRandomNumber(1, 254);
5194 for(i
= 0; i
< 6; i
++)
5195 dev
->dev_addr
[i
] = sMacAddr
[i
];
5198 //NicIFSetMacAddress(Adapter, Adapter->PermanentAddress);
5199 write_nic_dword(dev
, IDR0
, ((u32
*)dev
->dev_addr
)[0]);
5200 write_nic_word(dev
, IDR4
, ((u16
*)(dev
->dev_addr
+ 4))[0]);
5202 RT_TRACE(COMP_INIT
, "ReadAdapterInfo8192SEFuse(), Permanent Address = %02x-%02x-%02x-%02x-%02x-%02x\n",
5203 dev
->dev_addr
[0], dev
->dev_addr
[1],
5204 dev
->dev_addr
[2], dev
->dev_addr
[3],
5205 dev
->dev_addr
[4], dev
->dev_addr
[5]);
5207 // 2007/11/15 MH For RTL8192USB we assign as 1T2R now.
5208 priv
->rf_type
= RTL819X_DEFAULT_RF_TYPE
; // default : 1T2R
5210 priv
->rf_chip
= RF_6052
;
5211 priv
->rf_type
= RTL819X_DEFAULT_RF_TYPE
;
5215 // Read antenna tx power offset of B/C/D to A from EEPROM
5216 // and read ThermalMeter from EEPROM
5218 if(!priv
->AutoloadFailFlag
)
5220 ReadEFuse(dev
, EEPROM_PwDiff
, 2, (unsigned char*) &usValue
);
5221 priv
->EEPROMPwDiff
= usValue
&0x00ff;
5222 priv
->EEPROMThermalMeter
= (usValue
&0xff00)>>8;
5226 priv
->EEPROMPwDiff
= EEPROM_Default_PwDiff
;
5227 priv
->EEPROMThermalMeter
= EEPROM_Default_ThermalMeter
;
5230 RT_TRACE(COMP_INIT
, "PwDiff = %#x\n", priv
->EEPROMPwDiff
);
5231 RT_TRACE(COMP_INIT
, "ThermalMeter = %#x\n", priv
->EEPROMThermalMeter
);
5233 priv
->TSSI_13dBm
= priv
->EEPROMThermalMeter
*100;
5236 // Read Tx Power gain offset of legacy OFDM to HT rate.
5237 // Read CrystalCap from EEPROM
5239 if(!priv
->AutoloadFailFlag
)
5241 ReadEFuse(dev
, EEPROM_CrystalCap
, 1, (unsigned char*) &usValue
);
5242 priv
->EEPROMCrystalCap
= (u8
)((usValue
&0xf0)>>4);
5246 priv
->EEPROMCrystalCap
= EEPROM_Default_CrystalCap
;
5249 RT_TRACE(COMP_INIT
, "CrystalCap = %#x\n", priv
->EEPROMCrystalCap
);
5251 priv
->EEPROMTxPowerDiff
= EEPROM_Default_TxPowerDiff
;
5252 RT_TRACE(COMP_INIT
, "TxPowerDiff = %d\n", priv
->EEPROMTxPowerDiff
);
5256 // Get Tx Power Base.
5258 if(!priv
->AutoloadFailFlag
)
5260 ReadEFuse(dev
, EEPROM_TxPowerBase
, 1, (unsigned char*) &priv
->EEPROMTxPwrBase
);
5264 priv
->EEPROMTxPwrBase
= EEPROM_Default_TxPowerBase
;
5267 RT_TRACE(COMP_INIT
, "TxPwrBase = %#x\n", priv
->EEPROMTxPwrBase
);
5270 // Get CustomerID(Boad Type)
5271 // i.e., 0x0: RTL8188SU, 0x1: RTL8191SU, 0x2: RTL8192SU, 0x3: RTL8191GU.
5272 // Others: Reserved. Default is 0x2: RTL8192SU.
5274 if(!priv
->AutoloadFailFlag
)
5276 ReadEFuse(dev
, EEPROM_BoardType
, 1, (unsigned char*) &priv
->EEPROMBoardType
);
5280 priv
->EEPROMBoardType
= EEPROM_Default_BoardType
;
5283 RT_TRACE(COMP_INIT
, "BoardType = %#x\n", priv
->EEPROMBoardType
);
5285 //if(pHalData->EEPROM_Def_Ver == 0)
5287 // Please add code in the section!!!!
5288 // And merge tx power difference section.
5291 // Get TSSI value for each path.
5293 if(!priv
->AutoloadFailFlag
)
5295 ReadEFuse(dev
, EEPROM_TSSI_A
, 2, (unsigned char*)&usValue
);
5296 priv
->EEPROMTSSI_A
= (u8
)(usValue
&0xff);
5297 priv
->EEPROMTSSI_B
= (u8
)((usValue
&0xff00)>>8);
5300 { // Default setting for Empty EEPROM
5301 priv
->EEPROMTSSI_A
= EEPROM_Default_TSSI
;
5302 priv
->EEPROMTSSI_B
= EEPROM_Default_TSSI
;
5305 RT_TRACE(COMP_INIT
, "TSSI_A = %#x, TSSI_B = %#x\n",
5306 priv
->EEPROMTSSI_A
, priv
->EEPROMTSSI_B
);
5309 // Get Tx Power tracking mode.
5311 if(!priv
->AutoloadFailFlag
)
5313 ReadEFuse(dev
, EEPROM_TxPwTkMode
, 1, (unsigned char*)&priv
->EEPROMTxPwrTkMode
);
5316 { // Default setting for Empty EEPROM
5317 priv
->EEPROMTxPwrTkMode
= EEPROM_Default_TxPwrTkMode
;
5320 RT_TRACE(COMP_INIT
, "TxPwrTkMod = %#x\n", priv
->EEPROMTxPwrTkMode
);
5323 // TODO: The following HT 2T Path A and B Power Index should be updated.!! Added by Roger, 2008.20.23.
5326 // Get HT 2T Path A and B Power Index.
5328 if(!priv
->AutoloadFailFlag
)
5330 ReadEFuse(dev
, EEPROM_HT2T_CH1_A
, 6, (unsigned char*)HT2T_TxPwr
);
5333 priv
->EEPROMHT2T_TxPwr
[i
] = HT2T_TxPwr
[i
];
5337 { // Default setting for Empty EEPROM
5340 priv
->EEPROMHT2T_TxPwr
[i
] = EEPROM_Default_HT2T_TxPwr
;
5346 RT_TRACE(COMP_INIT
, "EEPROMHT2T_TxPwr, Index %d = 0x%02x\n",
5347 i
, priv
->EEPROMHT2T_TxPwr
[i
]);
5352 priv
->TxPowerDiff
= priv
->EEPROMPwDiff
;
5353 // Antenna B gain offset to antenna A, bit0~3
5354 priv
->AntennaTxPwDiff
[0] = (priv
->EEPROMTxPowerDiff
& 0xf);
5355 // Antenna C gain offset to antenna A, bit4~7
5356 priv
->AntennaTxPwDiff
[1] = ((priv
->EEPROMTxPowerDiff
& 0xf0)>>4);
5357 // CrystalCap, bit12~15
5358 priv
->CrystalCap
= priv
->EEPROMCrystalCap
;
5359 // ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2
5360 // 92U does not enable TX power tracking.
5361 priv
->ThermalMeter
[0] = priv
->EEPROMThermalMeter
;
5364 priv
->LedStrategy
= SW_LED_MODE0
;
5366 init_rate_adaptive(dev
);
5368 RT_TRACE(COMP_INIT
, "<==== ReadAdapterInfo8192SEFuse\n");
5375 // Read HW adapter information by E-Fuse or EEPROM according CR9346 reported.
5378 // 1. CR9346 regiser has verified.
5379 // 2. PASSIVE_LEVEL (USB interface)
5381 // Created by Roger, 2008.10.21.
5384 rtl8192SU_ReadAdapterInfo8192SUsb(struct net_device
* dev
)
5386 struct r8192_priv
*priv
= ieee80211_priv(dev
);
5390 u8 hwinfo
[HWSET_MAX_SIZE_92S
];
5391 u8 rf_path
, index
; // For EEPROM/EFUSE After V0.6_1117
5394 RT_TRACE(COMP_INIT
, "====> ReadAdapterInfo8192SUsb\n");
5397 // <Roger_Note> The following operation are prevent Efuse leakage by turn on 2.5V.
5400 tmpU1b
= read_nic_byte(dev
, EFUSE_TEST
+3);
5401 write_nic_byte(dev
, EFUSE_TEST
+3, tmpU1b
|0x80);
5402 //PlatformStallExecution(1000);
5404 write_nic_byte(dev
, EFUSE_TEST
+3, (tmpU1b
&(~BIT7
)));
5406 // Retrieve Chip version.
5407 priv
->card_8192_version
= (VERSION_8192S
)((read_nic_dword(dev
, PMC_FSM
)>>16)&0xF);
5408 RT_TRACE(COMP_INIT
, "Chip Version ID: 0x%2x\n", priv
->card_8192_version
);
5410 switch(priv
->card_8192_version
)
5413 RT_TRACE(COMP_INIT
, "Chip Version ID: VERSION_8192S_ACUT.\n");
5416 RT_TRACE(COMP_INIT
, "Chip Version ID: VERSION_8192S_BCUT.\n");
5419 RT_TRACE(COMP_INIT
, "Chip Version ID: VERSION_8192S_CCUT.\n");
5422 RT_TRACE(COMP_INIT
, "Unknown Chip Version!!\n");
5423 priv
->card_8192_version
= VERSION_8192S_BCUT
;
5427 //if (IS_BOOT_FROM_EEPROM(Adapter))
5428 if(priv
->EepromOrEfuse
)
5429 { // Read frin EEPROM
5430 write_nic_byte(dev
, SYS_ISO_CTRL
+1, 0xE8); // Isolation signals from Loader
5431 //PlatformStallExecution(10000);
5433 write_nic_byte(dev
, PMC_FSM
, 0x02); // Enable Loader Data Keep
5434 // Read all Content from EEPROM or EFUSE.
5435 for(i
= 0; i
< HWSET_MAX_SIZE_92S
; i
+= 2)
5437 usValue
= eprom_read(dev
, (u16
) (i
>>1));
5438 *((u16
*)(&hwinfo
[i
])) = usValue
;
5441 else if (!(priv
->EepromOrEfuse
))
5442 { // Read from EFUSE
5445 // <Roger_Notes> We set Isolation signals from Loader and reset EEPROM after system resuming
5446 // from suspend mode.
5449 //PlatformEFIOWrite1Byte(Adapter, SYS_ISO_CTRL+1, 0xE8); // Isolation signals from Loader
5450 //PlatformStallExecution(10000);
5451 //PlatformEFIOWrite1Byte(Adapter, SYS_FUNC_EN+1, 0x40);
5452 //PlatformEFIOWrite1Byte(Adapter, SYS_FUNC_EN+1, 0x50);
5454 //tmpU1b = PlatformEFIORead1Byte(Adapter, EFUSE_TEST+3);
5455 //PlatformEFIOWrite1Byte(Adapter, EFUSE_TEST+3, (tmpU1b | 0x80));
5456 //PlatformEFIOWrite1Byte(Adapter, EFUSE_TEST+3, 0x72);
5457 //PlatformEFIOWrite1Byte(Adapter, EFUSE_CLK, 0x03);
5459 // Read EFUSE real map to shadow.
5460 EFUSE_ShadowMapUpdate(dev
);
5461 memcpy(hwinfo
, &priv
->EfuseMap
[EFUSE_INIT_MAP
][0], HWSET_MAX_SIZE_92S
);
5465 RT_TRACE(COMP_INIT
, "ReadAdapterInfo8192SUsb(): Invalid boot type!!\n");
5469 //dump_buf(hwinfo,HWSET_MAX_SIZE_92S);
5471 // <Roger_Notes> The following are EFUSE/EEPROM independent operations!!
5473 //RT_PRINT_DATA(COMP_EFUSE, DBG_LOUD, ("MAP: \n"), hwinfo, HWSET_MAX_SIZE_92S);
5476 // <Roger_Notes> Event though CR9346 regiser can verify whether Autoload is success or not, but we still
5477 // double check ID codes for 92S here(e.g., due to HW GPIO polling fail issue).
5480 EEPROMId
= *((u16
*)&hwinfo
[0]);
5482 if( EEPROMId
!= RTL8190_EEPROM_ID
)
5484 RT_TRACE(COMP_INIT
, "ID(%#x) is invalid!!\n", EEPROMId
);
5485 priv
->bTXPowerDataReadFromEEPORM
= FALSE
;
5486 priv
->AutoloadFailFlag
=TRUE
;
5490 priv
->AutoloadFailFlag
=FALSE
;
5491 priv
->bTXPowerDataReadFromEEPORM
= TRUE
;
5493 // Read IC Version && Channel Plan
5494 if(!priv
->AutoloadFailFlag
)
5497 priv
->eeprom_vid
= *(u16
*)&hwinfo
[EEPROM_VID
];
5498 priv
->eeprom_pid
= *(u16
*)&hwinfo
[EEPROM_PID
];
5499 priv
->bIgnoreDiffRateTxPowerOffset
= false; //cosa for test
5502 // EEPROM Version ID, Channel plan
5503 priv
->EEPROMVersion
= *(u8
*)&hwinfo
[EEPROM_Version
];
5504 priv
->eeprom_ChannelPlan
= *(u8
*)&hwinfo
[EEPROM_ChannelPlan
];
5506 // Customer ID, 0x00 and 0xff are reserved for Realtek.
5507 priv
->eeprom_CustomerID
= *(u8
*)&hwinfo
[EEPROM_CustomID
];
5508 priv
->eeprom_SubCustomerID
= *(u8
*)&hwinfo
[EEPROM_SubCustomID
];
5512 //priv->eeprom_vid = 0;
5513 //priv->eeprom_pid = 0;
5514 //priv->EEPROMVersion = 0;
5515 //priv->eeprom_ChannelPlan = 0;
5516 //priv->eeprom_CustomerID = 0;
5517 //priv->eeprom_SubCustomerID = 0;
5519 rtl8192SU_ConfigAdapterInfo8192SForAutoLoadFail(dev
);
5524 RT_TRACE(COMP_INIT
, "EEPROM Id = 0x%4x\n", EEPROMId
);
5525 RT_TRACE(COMP_INIT
, "EEPROM VID = 0x%4x\n", priv
->eeprom_vid
);
5526 RT_TRACE(COMP_INIT
, "EEPROM PID = 0x%4x\n", priv
->eeprom_pid
);
5527 RT_TRACE(COMP_INIT
, "EEPROM Version ID: 0x%2x\n", priv
->EEPROMVersion
);
5528 RT_TRACE(COMP_INIT
, "EEPROM Customer ID: 0x%2x\n", priv
->eeprom_CustomerID
);
5529 RT_TRACE(COMP_INIT
, "EEPROM SubCustomer ID: 0x%2x\n", priv
->eeprom_SubCustomerID
);
5530 RT_TRACE(COMP_INIT
, "EEPROM ChannelPlan = 0x%4x\n", priv
->eeprom_ChannelPlan
);
5531 RT_TRACE(COMP_INIT
, "bIgnoreDiffRateTxPowerOffset = %d\n", priv
->bIgnoreDiffRateTxPowerOffset
);
5534 // Read USB optional function.
5535 if(!priv
->AutoloadFailFlag
)
5537 priv
->EEPROMUsbOption
= *(u8
*)&hwinfo
[EEPROM_USB_OPTIONAL
];
5541 priv
->EEPROMUsbOption
= EEPROM_USB_Default_OPTIONAL_FUNC
;
5545 priv
->EEPROMUsbEndPointNumber
= rtl8192SU_UsbOptionToEndPointNumber((priv
->EEPROMUsbOption
&EEPROM_EP_NUMBER
)>>3);
5547 RT_TRACE(COMP_INIT
, "USB Option = %#x\n", priv
->EEPROMUsbOption
);
5548 RT_TRACE(COMP_INIT
, "EndPoint Number = %#x\n", priv
->EEPROMUsbEndPointNumber
);
5552 // Decide CustomerID according to VID/DID or EEPROM
5554 switch(pHalData
->EEPROMCustomerID
)
5556 case EEPROM_CID_ALPHA
:
5557 pMgntInfo
->CustomerID
= RT_CID_819x_ALPHA
;
5560 case EEPROM_CID_CAMEO
:
5561 pMgntInfo
->CustomerID
= RT_CID_819x_CAMEO
;
5564 case EEPROM_CID_SITECOM
:
5565 pMgntInfo
->CustomerID
= RT_CID_819x_Sitecom
;
5566 RT_TRACE(COMP_INIT
, DBG_LOUD
, ("CustomerID = 0x%4x\n", pMgntInfo
->CustomerID
));
5570 case EEPROM_CID_WHQL
:
5571 Adapter
->bInHctTest
= TRUE
;
5573 pMgntInfo
->bSupportTurboMode
= FALSE
;
5574 pMgntInfo
->bAutoTurboBy8186
= FALSE
;
5576 pMgntInfo
->PowerSaveControl
.bInactivePs
= FALSE
;
5577 pMgntInfo
->PowerSaveControl
.bIPSModeBackup
= FALSE
;
5578 pMgntInfo
->PowerSaveControl
.bLeisurePs
= FALSE
;
5579 pMgntInfo
->keepAliveLevel
= 0;
5583 pMgntInfo
->CustomerID
= RT_CID_DEFAULT
;
5591 switch(pMgntInfo
->CustomerID
)
5593 case RT_CID_DEFAULT
:
5594 case RT_CID_819x_ALPHA
:
5595 pHalData
->LedStrategy
= SW_LED_MODE1
;
5596 pHalData
->bRegUseLed
= TRUE
;
5597 pHalData
->SwLed1
.bLedOn
= TRUE
;
5599 case RT_CID_819x_CAMEO
:
5600 pHalData
->LedStrategy
= SW_LED_MODE1
;
5601 pHalData
->bRegUseLed
= TRUE
;
5604 case RT_CID_819x_Sitecom
:
5605 pHalData
->LedStrategy
= SW_LED_MODE2
;
5606 pHalData
->bRegUseLed
= TRUE
;
5610 pHalData
->LedStrategy
= SW_LED_MODE0
;
5615 // Read USB PHY parameters.
5617 priv
->EEPROMUsbPhyParam
[i
] = *(u8
*)&hwinfo
[EEPROM_USB_PHY_PARA1
+i
];
5619 //RT_PRINT_DATA(COMP_EFUSE, DBG_LOUD, ("USB PHY Param: \n"), pHalData->EEPROMUsbPhyParam, 5);
5622 //Read Permanent MAC address
5624 dev
->dev_addr
[i
] = *(u8
*)&hwinfo
[EEPROM_NODE_ADDRESS_BYTE_0
+i
];
5626 //NicIFSetMacAddress(Adapter, Adapter->PermanentAddress);
5627 write_nic_dword(dev
, IDR0
, ((u32
*)dev
->dev_addr
)[0]);
5628 write_nic_word(dev
, IDR4
, ((u16
*)(dev
->dev_addr
+ 4))[0]);
5630 RT_TRACE(COMP_INIT
, "ReadAdapterInfo8192SEFuse(), Permanent Address = %02x-%02x-%02x-%02x-%02x-%02x\n",
5631 dev
->dev_addr
[0], dev
->dev_addr
[1],
5632 dev
->dev_addr
[2], dev
->dev_addr
[3],
5633 dev
->dev_addr
[4], dev
->dev_addr
[5]);
5636 // Get CustomerID(Boad Type)
5637 // i.e., 0x0: RTL8188SU, 0x1: RTL8191SU, 0x2: RTL8192SU, 0x3: RTL8191GU.
5638 // Others: Reserved. Default is 0x2: RTL8192SU.
5640 //if(!priv->AutoloadFailFlag)
5642 priv
->EEPROMBoardType
= *(u8
*)&hwinfo
[EEPROM_BoardType
];
5643 priv
->rf_type
= rtl8192SU_BoardTypeToRFtype(dev
, priv
->EEPROMBoardType
);
5647 // priv->EEPROMBoardType = EEPROM_Default_BoardType;
5648 // priv->rf_type = RF_1T2R;
5651 priv
->rf_chip
= RF_6052
;
5653 priv
->rf_chip
= RF_6052
;//lzm test
5654 RT_TRACE(COMP_INIT
, "BoardType = 0x%2x\n", priv
->EEPROMBoardType
);
5655 RT_TRACE(COMP_INIT
, "RF_Type = 0x%2x\n", priv
->rf_type
);
5658 // Read antenna tx power offset of B/C/D to A from EEPROM
5659 // and read ThermalMeter from EEPROM
5661 //if(!priv->AutoloadFailFlag)
5663 priv
->EEPROMTxPowerDiff
= *(u8
*)&hwinfo
[EEPROM_PwDiff
];
5664 priv
->EEPROMThermalMeter
= *(u8
*)&hwinfo
[EEPROM_ThermalMeter
];
5668 // priv->EEPROMTxPowerDiff = EEPROM_Default_PwDiff;
5669 // priv->EEPROMThermalMeter = EEPROM_Default_ThermalMeter;
5672 RT_TRACE(COMP_INIT
, "PwDiff = %#x\n", priv
->EEPROMTxPowerDiff
);
5673 RT_TRACE(COMP_INIT
, "ThermalMeter = %#x\n", priv
->EEPROMThermalMeter
);
5676 // Read Tx Power gain offset of legacy OFDM to HT rate.
5677 // Read CrystalCap from EEPROM
5679 //if(!priv->AutoloadFailFlag)
5681 priv
->EEPROMCrystalCap
= *(u8
*)&hwinfo
[EEPROM_CrystalCap
];
5685 // priv->EEPROMCrystalCap = EEPROM_Default_CrystalCap;
5688 RT_TRACE(COMP_INIT
, "CrystalCap = %#x\n", priv
->EEPROMCrystalCap
);
5691 // Get Tx Power Base.
5693 //if(!priv->AutoloadFailFlag)
5695 priv
->EEPROMTxPwrBase
= *(u8
*)&hwinfo
[EEPROM_TxPowerBase
];
5699 // priv->EEPROMTxPwrBase = EEPROM_Default_TxPowerBase;
5702 RT_TRACE(COMP_INIT
, "TxPwrBase = %#x\n", priv
->EEPROMTxPwrBase
);
5706 // Get TSSI value for each path.
5708 //if(!priv->AutoloadFailFlag)
5710 priv
->EEPROMTSSI_A
= *(u8
*)&hwinfo
[EEPROM_TSSI_A
];
5711 priv
->EEPROMTSSI_B
= *(u8
*)&hwinfo
[EEPROM_TSSI_B
];
5714 //{ // Default setting for Empty EEPROM
5715 // priv->EEPROMTSSI_A = EEPROM_Default_TSSI;
5716 // priv->EEPROMTSSI_B = EEPROM_Default_TSSI;
5719 RT_TRACE(COMP_INIT
, "TSSI_A = %#x, TSSI_B = %#x\n", priv
->EEPROMTSSI_A
, priv
->EEPROMTSSI_B
);
5722 // Get Tx Power tracking mode.
5724 //if(!priv->AutoloadFailFlag)
5726 priv
->EEPROMTxPwrTkMode
= *(u8
*)&hwinfo
[EEPROM_TxPwTkMode
];
5729 RT_TRACE(COMP_INIT
, "TxPwrTkMod = %#x\n", priv
->EEPROMTxPwrTkMode
);
5734 // Buffer TxPwIdx(i.e., from offset 0x55~0x66, total 18Bytes)
5735 // Update CCK, OFDM (1T/2T)Tx Power Index from above buffer.
5739 // Get Tx Power Level by Channel
5741 //if(!priv->AutoloadFailFlag)
5743 // Read Tx power of Channel 1 ~ 14 from EFUSE.
5744 // 92S suupport RF A & B
5745 for (rf_path
= 0; rf_path
< 2; rf_path
++)
5747 for (i
= 0; i
< 3; i
++)
5749 // Read CCK RF A & B Tx power
5750 priv
->RfCckChnlAreaTxPwr
[rf_path
][i
] =
5751 hwinfo
[EEPROM_TxPwIndex
+rf_path
*3+i
];
5753 // Read OFDM RF A & B Tx power for 1T
5754 priv
->RfOfdmChnlAreaTxPwr1T
[rf_path
][i
] =
5755 hwinfo
[EEPROM_TxPwIndex
+6+rf_path
*3+i
];
5757 // Read OFDM RF A & B Tx power for 2T
5758 priv
->RfOfdmChnlAreaTxPwr2T
[rf_path
][i
] =
5759 hwinfo
[EEPROM_TxPwIndex
+12+rf_path
*3+i
];
5765 // Update Tx Power HAL variables.
5767 for (rf_path
= 0; rf_path
< 2; rf_path
++)
5769 for (i
= 0; i
< 3; i
++)
5771 RT_TRACE((COMP_INIT
), "CCK RF-%d CHan_Area-%d = 0x%x\n", rf_path
, i
,
5772 priv
->RfCckChnlAreaTxPwr
[rf_path
][i
]);
5773 RT_TRACE((COMP_INIT
), "OFDM-1T RF-%d CHan_Area-%d = 0x%x\n", rf_path
, i
,
5774 priv
->RfOfdmChnlAreaTxPwr1T
[rf_path
][i
]);
5775 RT_TRACE((COMP_INIT
), "OFDM-2T RF-%d CHan_Area-%d = 0x%x\n", rf_path
, i
, priv
->RfOfdmChnlAreaTxPwr2T
[rf_path
][i
]);
5778 // Assign dedicated channel tx power
5779 for(i
=0; i
<14; i
++) // channel 1~3 use the same Tx Power Level.
5781 if (i
< 3) // Cjanel 1-3
5783 else if (i
< 9) // Channel 4-9
5785 else // Channel 10-14
5788 // Record A & B CCK /OFDM - 1T/2T Channel area tx power
5789 priv
->RfTxPwrLevelCck
[rf_path
][i
] =
5790 priv
->RfCckChnlAreaTxPwr
[rf_path
][index
];
5791 priv
->RfTxPwrLevelOfdm1T
[rf_path
][i
] =
5792 priv
->RfOfdmChnlAreaTxPwr1T
[rf_path
][index
];
5793 priv
->RfTxPwrLevelOfdm2T
[rf_path
][i
] =
5794 priv
->RfOfdmChnlAreaTxPwr2T
[rf_path
][index
];
5797 priv
->TxPowerLevelOFDM24G
[i
] = priv
->RfTxPwrLevelOfdm1T
[rf_path
][i
] ;
5798 priv
->TxPowerLevelCCK
[i
] = priv
->RfTxPwrLevelCck
[rf_path
][i
];
5804 RT_TRACE((COMP_INIT
),
5805 "Rf-%d TxPwr CH-%d CCK OFDM_1T OFDM_2T= 0x%x/0x%x/0x%x\n",
5806 rf_path
, i
, priv
->RfTxPwrLevelCck
[rf_path
][i
],
5807 priv
->RfTxPwrLevelOfdm1T
[rf_path
][i
] ,
5808 priv
->RfTxPwrLevelOfdm2T
[rf_path
][i
] );
5814 // 2009/02/09 Cosa add for new EEPROM format
5816 for(i
=0; i
<14; i
++) // channel 1~3 use the same Tx Power Level.
5818 // Read tx power difference between HT OFDM 20/40 MHZ
5819 if (i
< 3) // Cjanel 1-3
5821 else if (i
< 9) // Channel 4-9
5823 else // Channel 10-14
5826 tempval
= (*(u8
*)&hwinfo
[EEPROM_TX_PWR_HT20_DIFF
+index
])&0xff;
5827 priv
->TxPwrHt20Diff
[RF90_PATH_A
][i
] = (tempval
&0xF);
5828 priv
->TxPwrHt20Diff
[RF90_PATH_B
][i
] = ((tempval
>>4)&0xF);
5830 // Read OFDM<->HT tx power diff
5831 if (i
< 3) // Cjanel 1-3
5832 tempval
= (*(u8
*)&hwinfo
[EEPROM_TX_PWR_OFDM_DIFF
])&0xff;
5833 else if (i
< 9) // Channel 4-9
5834 tempval
= (*(u8
*)&hwinfo
[EEPROM_PwDiff
])&0xff;
5835 else // Channel 10-14
5836 tempval
= (*(u8
*)&hwinfo
[EEPROM_TX_PWR_OFDM_DIFF
+1])&0xff;
5838 //cosa tempval = (*(u1Byte *)&hwinfo[EEPROM_TX_PWR_OFDM_DIFF+index])&0xff;
5839 priv
->TxPwrLegacyHtDiff
[RF90_PATH_A
][i
] = (tempval
&0xF);
5840 priv
->TxPwrLegacyHtDiff
[RF90_PATH_B
][i
] = ((tempval
>>4)&0xF);
5843 // Read Band Edge tx power offset and check if user enable the ability
5845 // HT 40 band edge channel
5846 tempval
= (*(u8
*)&hwinfo
[EEPROM_TX_PWR_BAND_EDGE
])&0xff;
5847 priv
->TxPwrbandEdgeHt40
[RF90_PATH_A
][0] = (tempval
&0xF); // Band edge low channel
5848 priv
->TxPwrbandEdgeHt40
[RF90_PATH_A
][1] = ((tempval
>>4)&0xF); // Band edge high channel
5849 tempval
= (*(u8
*)&hwinfo
[EEPROM_TX_PWR_BAND_EDGE
+1])&0xff;
5850 priv
->TxPwrbandEdgeHt40
[RF90_PATH_B
][0] = (tempval
&0xF); // Band edge low channel
5851 priv
->TxPwrbandEdgeHt40
[RF90_PATH_B
][1] = ((tempval
>>4)&0xF); // Band edge high channel
5852 // HT 20 band edge channel
5853 tempval
= (*(u8
*)&hwinfo
[EEPROM_TX_PWR_BAND_EDGE
+2])&0xff;
5854 priv
->TxPwrbandEdgeHt20
[RF90_PATH_A
][0] = (tempval
&0xF); // Band edge low channel
5855 priv
->TxPwrbandEdgeHt20
[RF90_PATH_A
][1] = ((tempval
>>4)&0xF); // Band edge high channel
5856 tempval
= (*(u8
*)&hwinfo
[EEPROM_TX_PWR_BAND_EDGE
+3])&0xff;
5857 priv
->TxPwrbandEdgeHt20
[RF90_PATH_B
][0] = (tempval
&0xF); // Band edge low channel
5858 priv
->TxPwrbandEdgeHt20
[RF90_PATH_B
][1] = ((tempval
>>4)&0xF); // Band edge high channel
5859 // OFDM band edge channel
5860 tempval
= (*(u8
*)&hwinfo
[EEPROM_TX_PWR_BAND_EDGE
+4])&0xff;
5861 priv
->TxPwrbandEdgeLegacyOfdm
[RF90_PATH_A
][0] = (tempval
&0xF); // Band edge low channel
5862 priv
->TxPwrbandEdgeLegacyOfdm
[RF90_PATH_A
][1] = ((tempval
>>4)&0xF); // Band edge high channel
5863 tempval
= (*(u8
*)&hwinfo
[EEPROM_TX_PWR_BAND_EDGE
+5])&0xff;
5864 priv
->TxPwrbandEdgeLegacyOfdm
[RF90_PATH_B
][0] = (tempval
&0xF); // Band edge low channel
5865 priv
->TxPwrbandEdgeLegacyOfdm
[RF90_PATH_B
][1] = ((tempval
>>4)&0xF); // Band edge high channel
5867 priv
->TxPwrbandEdgeFlag
= (*(u8
*)&hwinfo
[TX_PWR_BAND_EDGE_CHK
]);
5871 RT_TRACE(COMP_INIT
, "RF-A Ht20 to HT40 Diff[%d] = 0x%x\n", i
, priv
->TxPwrHt20Diff
[RF90_PATH_A
][i
]);
5873 RT_TRACE(COMP_INIT
, "RF-A Legacy to Ht40 Diff[%d] = 0x%x\n", i
, priv
->TxPwrLegacyHtDiff
[RF90_PATH_A
][i
]);
5875 RT_TRACE(COMP_INIT
, "RF-B Ht20 to HT40 Diff[%d] = 0x%x\n", i
, priv
->TxPwrHt20Diff
[RF90_PATH_B
][i
]);
5877 RT_TRACE(COMP_INIT
, "RF-B Legacy to HT40 Diff[%d] = 0x%x\n", i
, priv
->TxPwrLegacyHtDiff
[RF90_PATH_B
][i
]);
5878 RT_TRACE(COMP_INIT
, "RF-A HT40 band-edge low/high power diff = 0x%x/0x%x\n",
5879 priv
->TxPwrbandEdgeHt40
[RF90_PATH_A
][0],
5880 priv
->TxPwrbandEdgeHt40
[RF90_PATH_A
][1]);
5881 RT_TRACE((COMP_INIT
&COMP_DBG
), "RF-B HT40 band-edge low/high power diff = 0x%x/0x%x\n",
5882 priv
->TxPwrbandEdgeHt40
[RF90_PATH_B
][0],
5883 priv
->TxPwrbandEdgeHt40
[RF90_PATH_B
][1]);
5885 RT_TRACE((COMP_INIT
&COMP_DBG
), "RF-A HT20 band-edge low/high power diff = 0x%x/0x%x\n",
5886 priv
->TxPwrbandEdgeHt20
[RF90_PATH_A
][0],
5887 priv
->TxPwrbandEdgeHt20
[RF90_PATH_A
][1]);
5888 RT_TRACE((COMP_INIT
&COMP_DBG
), "RF-B HT20 band-edge low/high power diff = 0x%x/0x%x\n",
5889 priv
->TxPwrbandEdgeHt20
[RF90_PATH_B
][0],
5890 priv
->TxPwrbandEdgeHt20
[RF90_PATH_B
][1]);
5892 RT_TRACE((COMP_INIT
&COMP_DBG
), "RF-A OFDM band-edge low/high power diff = 0x%x/0x%x\n",
5893 priv
->TxPwrbandEdgeLegacyOfdm
[RF90_PATH_A
][0],
5894 priv
->TxPwrbandEdgeLegacyOfdm
[RF90_PATH_A
][1]);
5895 RT_TRACE((COMP_INIT
&COMP_DBG
), "RF-B OFDM band-edge low/high power diff = 0x%x/0x%x\n",
5896 priv
->TxPwrbandEdgeLegacyOfdm
[RF90_PATH_B
][0],
5897 priv
->TxPwrbandEdgeLegacyOfdm
[RF90_PATH_B
][1]);
5898 RT_TRACE((COMP_INIT
&COMP_DBG
), "Band-edge enable flag = %d\n", priv
->TxPwrbandEdgeFlag
);
5901 // Update remained HAL variables.
5903 priv
->TSSI_13dBm
= priv
->EEPROMThermalMeter
*100;
5904 priv
->LegacyHTTxPowerDiff
= priv
->EEPROMTxPowerDiff
;
5905 priv
->TxPowerDiff
= priv
->EEPROMTxPowerDiff
;
5906 //priv->AntennaTxPwDiff[0] = (priv->EEPROMTxPowerDiff & 0xf);// Antenna B gain offset to antenna A, bit[3:0]
5907 //priv->AntennaTxPwDiff[1] = ((priv->EEPROMTxPowerDiff & 0xf0)>>4);// Antenna C gain offset to antenna A, bit[7:4]
5908 priv
->CrystalCap
= priv
->EEPROMCrystalCap
; // CrystalCap, bit[15:12]
5909 priv
->ThermalMeter
[0] = (priv
->EEPROMThermalMeter
&0x1f);// ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2
5910 priv
->LedStrategy
= SW_LED_MODE0
;
5912 init_rate_adaptive(dev
);
5914 RT_TRACE(COMP_INIT
, "<==== ReadAdapterInfo8192SUsb\n");
5916 //return RT_STATUS_SUCCESS;
5922 // Read HW adapter information by E-Fuse or EEPROM according CR9346 reported.
5925 // 1. CR9346 regiser has verified.
5926 // 2. PASSIVE_LEVEL (USB interface)
5928 // Created by Roger, 2008.10.21.
5930 static void rtl8192SU_read_eeprom_info(struct net_device
*dev
)
5932 struct r8192_priv
*priv
= ieee80211_priv(dev
);
5935 RT_TRACE(COMP_INIT
, "====> ReadAdapterInfo8192SUsb\n");
5937 // Retrieve Chip version.
5938 priv
->card_8192_version
= (VERSION_8192S
)((read_nic_dword(dev
, PMC_FSM
)>>16)&0xF);
5939 RT_TRACE(COMP_INIT
, "Chip Version ID: 0x%2x\n", priv
->card_8192_version
);
5941 tmpU1b
= read_nic_byte(dev
, EPROM_CMD
);//CR9346
5943 // To check system boot selection.
5944 if (tmpU1b
& CmdEERPOMSEL
)
5946 RT_TRACE(COMP_INIT
, "Boot from EEPROM\n");
5947 priv
->EepromOrEfuse
= TRUE
;
5951 RT_TRACE(COMP_INIT
, "Boot from EFUSE\n");
5952 priv
->EepromOrEfuse
= FALSE
;
5955 // To check autoload success or not.
5956 if (tmpU1b
& CmdEEPROM_En
)
5958 RT_TRACE(COMP_INIT
, "Autoload OK!!\n");
5959 priv
->AutoloadFailFlag
=FALSE
;
5960 rtl8192SU_ReadAdapterInfo8192SUsb(dev
);//eeprom or e-fuse
5963 { // Auto load fail.
5964 RT_TRACE(COMP_INIT
, "AutoLoad Fail reported from CR9346!!\n");
5965 priv
->AutoloadFailFlag
=TRUE
;
5966 rtl8192SU_ConfigAdapterInfo8192SForAutoLoadFail(dev
);
5968 //if (IS_BOOT_FROM_EFUSE(Adapter))
5969 if(!priv
->EepromOrEfuse
)
5971 RT_TRACE(COMP_INIT
, "Update shadow map for EFuse future use!!\n");
5972 EFUSE_ShadowMapUpdate(dev
);
5976 if((priv
->RegChannelPlan
>= RT_CHANNEL_DOMAIN_MAX
) || (pHalData
->EEPROMChannelPlan
& EEPROM_CHANNEL_PLAN_BY_HW_MASK
))
5978 pMgntInfo
->ChannelPlan
= HalMapChannelPlan8192S(Adapter
, (pHalData
->EEPROMChannelPlan
& (~(EEPROM_CHANNEL_PLAN_BY_HW_MASK
))));
5979 pMgntInfo
->bChnlPlanFromHW
= (pHalData
->EEPROMChannelPlan
& EEPROM_CHANNEL_PLAN_BY_HW_MASK
) ? TRUE
: FALSE
; // User cannot change channel plan.
5983 pMgntInfo
->ChannelPlan
= (RT_CHANNEL_DOMAIN
)pMgntInfo
->RegChannelPlan
;
5986 switch(pMgntInfo
->ChannelPlan
)
5988 case RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN
:
5990 PRT_DOT11D_INFO pDot11dInfo
= GET_DOT11D_INFO(pMgntInfo
);
5992 pDot11dInfo
->bEnabled
= TRUE
;
5994 RT_TRACE(COMP_INIT
, DBG_LOUD
, ("ReadAdapterInfo8187(): Enable dot11d when RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN!\n"));
5998 RT_TRACE(COMP_INIT
, DBG_LOUD
, ("RegChannelPlan(%d) EEPROMChannelPlan(%d)", pMgntInfo
->RegChannelPlan
, pHalData
->EEPROMChannelPlan
));
5999 RT_TRACE(COMP_INIT
, DBG_LOUD
, ("ChannelPlan = %d\n" , pMgntInfo
->ChannelPlan
));
6001 RT_TRACE(COMP_INIT
, DBG_LOUD
, ("<==== ReadAdapterInfo8192S\n"));
6004 RT_TRACE(COMP_INIT
, "<==== ReadAdapterInfo8192SUsb\n");
6006 //return RT_STATUS_SUCCESS;
6009 static void rtl8192_read_eeprom_info(struct net_device
* dev
)
6012 u8 bMac_Tmp_Addr
[6] = {0x00, 0xe0, 0x4c, 0x00, 0x00, 0x02};
6013 u8 bLoad_From_EEPOM
= false;
6014 struct r8192_priv
*priv
= ieee80211_priv(dev
);
6016 RT_TRACE(COMP_EPROM
, "===========>%s()\n", __FUNCTION__
);
6017 wEPROM_ID
= eprom_read(dev
, 0); //first read EEPROM ID out;
6018 RT_TRACE(COMP_EPROM
, "EEPROM ID is 0x%x\n", wEPROM_ID
);
6020 if (wEPROM_ID
!= RTL8190_EEPROM_ID
)
6022 RT_TRACE(COMP_ERR
, "EEPROM ID is invalid(is 0x%x(should be 0x%x)\n", wEPROM_ID
, RTL8190_EEPROM_ID
);
6025 bLoad_From_EEPOM
= true;
6027 if (bLoad_From_EEPOM
)
6029 tmpValue
= eprom_read(dev
, (EEPROM_VID
>>1));
6030 priv
->eeprom_vid
= endian_swap(&tmpValue
);
6031 priv
->eeprom_pid
= eprom_read(dev
, (EEPROM_PID
>>1));
6032 tmpValue
= eprom_read(dev
, (EEPROM_ChannelPlan
>>1));
6033 priv
->eeprom_ChannelPlan
=((tmpValue
&0xff00)>>8);
6034 priv
->btxpowerdata_readfromEEPORM
= true;
6035 priv
->eeprom_CustomerID
= eprom_read(dev
, (EEPROM_Customer_ID
>>1)) >>8;
6039 priv
->eeprom_vid
= 0;
6040 priv
->eeprom_pid
= 0;
6041 priv
->card_8192_version
= VERSION_819xU_B
;
6042 priv
->eeprom_ChannelPlan
= 0;
6043 priv
->eeprom_CustomerID
= 0;
6045 RT_TRACE(COMP_EPROM
, "vid:0x%4x, pid:0x%4x, CustomID:0x%2x, ChanPlan:0x%x\n", priv
->eeprom_vid
, priv
->eeprom_pid
, priv
->eeprom_CustomerID
, priv
->eeprom_ChannelPlan
);
6046 //set channelplan from eeprom
6047 priv
->ChannelPlan
= priv
->eeprom_ChannelPlan
;
6048 if (bLoad_From_EEPOM
)
6051 for (i
=0; i
<6; i
+=2)
6054 tmp
= eprom_read(dev
, (u16
)((EEPROM_NODE_ADDRESS_BYTE_0
+ i
)>>1));
6055 *(u16
*)(&dev
->dev_addr
[i
]) = tmp
;
6060 memcpy(dev
->dev_addr
, bMac_Tmp_Addr
, 6);
6061 //should I set IDR0 here?
6063 RT_TRACE(COMP_EPROM
, "MAC addr:"MAC_FMT
"\n", MAC_ARG(dev
->dev_addr
));
6064 priv
->rf_type
= RTL819X_DEFAULT_RF_TYPE
; //default 1T2R
6065 priv
->rf_chip
= RF_8256
;
6067 if (priv
->card_8192_version
== (u8
)VERSION_819xU_A
)
6069 //read Tx power gain offset of legacy OFDM to HT rate
6070 if (bLoad_From_EEPOM
)
6071 priv
->EEPROMTxPowerDiff
= (eprom_read(dev
, (EEPROM_TxPowerDiff
>>1))&0xff00) >> 8;
6073 priv
->EEPROMTxPowerDiff
= EEPROM_Default_TxPower
;
6074 RT_TRACE(COMP_EPROM
, "TxPowerDiff:%d\n", priv
->EEPROMTxPowerDiff
);
6075 //read ThermalMeter from EEPROM
6076 if (bLoad_From_EEPOM
)
6077 priv
->EEPROMThermalMeter
= (u8
)(eprom_read(dev
, (EEPROM_ThermalMeter
>>1))&0x00ff);
6079 priv
->EEPROMThermalMeter
= EEPROM_Default_ThermalMeter
;
6080 RT_TRACE(COMP_EPROM
, "ThermalMeter:%d\n", priv
->EEPROMThermalMeter
);
6081 //vivi, for tx power track
6082 priv
->TSSI_13dBm
= priv
->EEPROMThermalMeter
*100;
6083 //read antenna tx power offset of B/C/D to A from EEPROM
6084 if (bLoad_From_EEPOM
)
6085 priv
->EEPROMPwDiff
= (eprom_read(dev
, (EEPROM_PwDiff
>>1))&0x0f00)>>8;
6087 priv
->EEPROMPwDiff
= EEPROM_Default_PwDiff
;
6088 RT_TRACE(COMP_EPROM
, "TxPwDiff:%d\n", priv
->EEPROMPwDiff
);
6089 // Read CrystalCap from EEPROM
6090 if (bLoad_From_EEPOM
)
6091 priv
->EEPROMCrystalCap
= (eprom_read(dev
, (EEPROM_CrystalCap
>>1))&0x0f);
6093 priv
->EEPROMCrystalCap
= EEPROM_Default_CrystalCap
;
6094 RT_TRACE(COMP_EPROM
, "CrystalCap = %d\n", priv
->EEPROMCrystalCap
);
6095 //get per-channel Tx power level
6096 if (bLoad_From_EEPOM
)
6097 priv
->EEPROM_Def_Ver
= (eprom_read(dev
, (EEPROM_TxPwIndex_Ver
>>1))&0xff00)>>8;
6099 priv
->EEPROM_Def_Ver
= 1;
6100 RT_TRACE(COMP_EPROM
, "EEPROM_DEF_VER:%d\n", priv
->EEPROM_Def_Ver
);
6101 if (priv
->EEPROM_Def_Ver
== 0) //old eeprom definition
6104 if (bLoad_From_EEPOM
)
6105 priv
->EEPROMTxPowerLevelCCK
= (eprom_read(dev
, (EEPROM_TxPwIndex_CCK
>>1))&0xff) >> 8;
6107 priv
->EEPROMTxPowerLevelCCK
= 0x10;
6108 RT_TRACE(COMP_EPROM
, "CCK Tx Power Levl: 0x%02x\n", priv
->EEPROMTxPowerLevelCCK
);
6111 if (bLoad_From_EEPOM
)
6113 tmpValue
= eprom_read(dev
, (EEPROM_TxPwIndex_OFDM_24G
+i
)>>1);
6114 if (((EEPROM_TxPwIndex_OFDM_24G
+i
) % 2) == 0)
6115 tmpValue
= tmpValue
& 0x00ff;
6117 tmpValue
= (tmpValue
& 0xff00) >> 8;
6121 priv
->EEPROMTxPowerLevelOFDM24G
[i
] = (u8
) tmpValue
;
6122 RT_TRACE(COMP_EPROM
, "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n", i
, priv
->EEPROMTxPowerLevelCCK
);
6124 }//end if EEPROM_DEF_VER == 0
6125 else if (priv
->EEPROM_Def_Ver
== 1)
6127 if (bLoad_From_EEPOM
)
6129 tmpValue
= eprom_read(dev
, (EEPROM_TxPwIndex_CCK_V1
>>1));
6130 tmpValue
= (tmpValue
& 0xff00) >> 8;
6134 priv
->EEPROMTxPowerLevelCCK_V1
[0] = (u8
)tmpValue
;
6136 if (bLoad_From_EEPOM
)
6137 tmpValue
= eprom_read(dev
, (EEPROM_TxPwIndex_CCK_V1
+ 2)>>1);
6140 *((u16
*)(&priv
->EEPROMTxPowerLevelCCK_V1
[1])) = tmpValue
;
6141 if (bLoad_From_EEPOM
)
6142 tmpValue
= eprom_read(dev
, (EEPROM_TxPwIndex_OFDM_24G_V1
>>1));
6145 *((u16
*)(&priv
->EEPROMTxPowerLevelOFDM24G
[0])) = tmpValue
;
6146 if (bLoad_From_EEPOM
)
6147 tmpValue
= eprom_read(dev
, (EEPROM_TxPwIndex_OFDM_24G_V1
+2)>>1);
6150 priv
->EEPROMTxPowerLevelOFDM24G
[2] = (u8
)tmpValue
;
6151 }//endif EEPROM_Def_Ver == 1
6153 //update HAL variables
6157 for (i
=0; i
<14; i
++)
6160 priv
->TxPowerLevelOFDM24G
[i
] = priv
->EEPROMTxPowerLevelOFDM24G
[0];
6161 else if (i
>=4 && i
<=9)
6162 priv
->TxPowerLevelOFDM24G
[i
] = priv
->EEPROMTxPowerLevelOFDM24G
[1];
6164 priv
->TxPowerLevelOFDM24G
[i
] = priv
->EEPROMTxPowerLevelOFDM24G
[2];
6167 for (i
=0; i
<14; i
++)
6169 if (priv
->EEPROM_Def_Ver
== 0)
6172 priv
->TxPowerLevelCCK
[i
] = priv
->EEPROMTxPowerLevelOFDM24G
[0] + (priv
->EEPROMTxPowerLevelCCK
- priv
->EEPROMTxPowerLevelOFDM24G
[1]);
6173 else if (i
>=4 && i
<=9)
6174 priv
->TxPowerLevelCCK
[i
] = priv
->EEPROMTxPowerLevelCCK
;
6176 priv
->TxPowerLevelCCK
[i
] = priv
->EEPROMTxPowerLevelOFDM24G
[2] + (priv
->EEPROMTxPowerLevelCCK
- priv
->EEPROMTxPowerLevelOFDM24G
[1]);
6178 else if (priv
->EEPROM_Def_Ver
== 1)
6181 priv
->TxPowerLevelCCK
[i
] = priv
->EEPROMTxPowerLevelCCK_V1
[0];
6182 else if (i
>=4 && i
<=9)
6183 priv
->TxPowerLevelCCK
[i
] = priv
->EEPROMTxPowerLevelCCK_V1
[1];
6185 priv
->TxPowerLevelCCK
[i
] = priv
->EEPROMTxPowerLevelCCK_V1
[2];
6188 }//end update HAL variables
6189 priv
->TxPowerDiff
= priv
->EEPROMPwDiff
;
6190 // Antenna B gain offset to antenna A, bit0~3
6191 priv
->AntennaTxPwDiff
[0] = (priv
->EEPROMTxPowerDiff
& 0xf);
6192 // Antenna C gain offset to antenna A, bit4~7
6193 priv
->AntennaTxPwDiff
[1] = ((priv
->EEPROMTxPowerDiff
& 0xf0)>>4);
6194 // CrystalCap, bit12~15
6195 priv
->CrystalCap
= priv
->EEPROMCrystalCap
;
6196 // ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2
6197 // 92U does not enable TX power tracking.
6198 priv
->ThermalMeter
[0] = priv
->EEPROMThermalMeter
;
6199 }//end if VersionID == VERSION_819xU_A
6201 //added by vivi, for dlink led, 20080416
6202 switch(priv
->eeprom_CustomerID
)
6204 case EEPROM_CID_RUNTOP
:
6205 priv
->CustomerID
= RT_CID_819x_RUNTOP
;
6208 case EEPROM_CID_DLINK
:
6209 priv
->CustomerID
= RT_CID_DLINK
;
6213 priv
->CustomerID
= RT_CID_DEFAULT
;
6218 switch(priv
->CustomerID
)
6220 case RT_CID_819x_RUNTOP
:
6221 priv
->LedStrategy
= SW_LED_MODE2
;
6225 priv
->LedStrategy
= SW_LED_MODE4
;
6229 priv
->LedStrategy
= SW_LED_MODE0
;
6235 if(priv
->rf_type
== RF_1T2R
)
6237 RT_TRACE(COMP_EPROM
, "\n1T2R config\n");
6241 RT_TRACE(COMP_EPROM
, "\n2T4R config\n");
6244 // 2008/01/16 MH We can only know RF type in the function. So we have to init
6245 // DIG RATR table again.
6246 init_rate_adaptive(dev
);
6247 //we need init DIG RATR table here again.
6249 RT_TRACE(COMP_EPROM
, "<===========%s()\n", __FUNCTION__
);
6254 short rtl8192_get_channel_map(struct net_device
* dev
)
6256 struct r8192_priv
*priv
= ieee80211_priv(dev
);
6257 if(priv
->ChannelPlan
> COUNTRY_CODE_GLOBAL_DOMAIN
){
6258 printk("rtl8180_init:Error channel plan! Set to default.\n");
6259 priv
->ChannelPlan
= 0;
6261 RT_TRACE(COMP_INIT
, "Channel plan is %d\n",priv
->ChannelPlan
);
6263 rtl819x_set_channel_map(priv
->ChannelPlan
, priv
);
6267 short rtl8192_init(struct net_device
*dev
)
6270 struct r8192_priv
*priv
= ieee80211_priv(dev
);
6273 memset(&(priv
->stats
),0,sizeof(struct Stats
));
6274 memset(priv
->txqueue_to_outpipemap
,0,9);
6278 u8 queuetopipe
[]={3,2,1,0,4,8,7,6,5};
6279 memcpy(priv
->txqueue_to_outpipemap
,queuetopipe
,9);
6281 printk("%d ",priv->txqueue_to_outpipemap[i]);
6286 u8 queuetopipe
[]={3,2,1,0,4,4,0,4,4};
6287 memcpy(priv
->txqueue_to_outpipemap
,queuetopipe
,9);
6289 printk("%d ",priv->txqueue_to_outpipemap[i]);
6294 rtl8192_init_priv_variable(dev
);
6295 rtl8192_init_priv_lock(priv
);
6296 rtl8192_init_priv_task(dev
);
6297 rtl8192_get_eeprom_size(dev
);
6298 priv
->ops
->rtl819x_read_eeprom_info(dev
);
6299 rtl8192_get_channel_map(dev
);
6301 init_timer(&priv
->watch_dog_timer
);
6302 priv
->watch_dog_timer
.data
= (unsigned long)dev
;
6303 priv
->watch_dog_timer
.function
= watch_dog_timer_callback
;
6305 //rtl8192_adapter_start(dev);
6312 /******************************************************************************
6313 *function: This function actually only set RRSR, RATR and BW_OPMODE registers
6314 * not to do all the hw config as its name says
6315 * input: net_device dev
6318 * notice: This part need to modified according to the rate set we filtered
6319 * ****************************************************************************/
6320 void rtl8192_hwconfig(struct net_device
* dev
)
6322 u32 regRATR
= 0, regRRSR
= 0;
6323 u8 regBwOpMode
= 0, regTmp
= 0;
6324 struct r8192_priv
*priv
= ieee80211_priv(dev
);
6326 // Set RRSR, RATR, and BW_OPMODE registers
6328 switch(priv
->ieee80211
->mode
)
6330 case WIRELESS_MODE_B
:
6331 regBwOpMode
= BW_OPMODE_20MHZ
;
6332 regRATR
= RATE_ALL_CCK
;
6333 regRRSR
= RATE_ALL_CCK
;
6335 case WIRELESS_MODE_A
:
6336 regBwOpMode
= BW_OPMODE_5G
|BW_OPMODE_20MHZ
;
6337 regRATR
= RATE_ALL_OFDM_AG
;
6338 regRRSR
= RATE_ALL_OFDM_AG
;
6340 case WIRELESS_MODE_G
:
6341 regBwOpMode
= BW_OPMODE_20MHZ
;
6342 regRATR
= RATE_ALL_CCK
| RATE_ALL_OFDM_AG
;
6343 regRRSR
= RATE_ALL_CCK
| RATE_ALL_OFDM_AG
;
6345 case WIRELESS_MODE_AUTO
:
6347 if (Adapter
->bInHctTest
)
6349 regBwOpMode
= BW_OPMODE_20MHZ
;
6350 regRATR
= RATE_ALL_CCK
| RATE_ALL_OFDM_AG
;
6351 regRRSR
= RATE_ALL_CCK
| RATE_ALL_OFDM_AG
;
6356 regBwOpMode
= BW_OPMODE_20MHZ
;
6357 regRATR
= RATE_ALL_CCK
| RATE_ALL_OFDM_AG
| RATE_ALL_OFDM_1SS
| RATE_ALL_OFDM_2SS
;
6358 regRRSR
= RATE_ALL_CCK
| RATE_ALL_OFDM_AG
;
6361 case WIRELESS_MODE_N_24G
:
6362 // It support CCK rate by default.
6363 // CCK rate will be filtered out only when associated AP does not support it.
6364 regBwOpMode
= BW_OPMODE_20MHZ
;
6365 regRATR
= RATE_ALL_CCK
| RATE_ALL_OFDM_AG
| RATE_ALL_OFDM_1SS
| RATE_ALL_OFDM_2SS
;
6366 regRRSR
= RATE_ALL_CCK
| RATE_ALL_OFDM_AG
;
6368 case WIRELESS_MODE_N_5G
:
6369 regBwOpMode
= BW_OPMODE_5G
;
6370 regRATR
= RATE_ALL_OFDM_AG
| RATE_ALL_OFDM_1SS
| RATE_ALL_OFDM_2SS
;
6371 regRRSR
= RATE_ALL_OFDM_AG
;
6375 write_nic_byte(dev
, BW_OPMODE
, regBwOpMode
);
6378 ratr_value
= regRATR
;
6379 if (priv
->rf_type
== RF_1T2R
)
6381 ratr_value
&= ~(RATE_ALL_OFDM_2SS
);
6383 write_nic_dword(dev
, RATR0
, ratr_value
);
6384 write_nic_byte(dev
, UFWP
, 1);
6386 regTmp
= read_nic_byte(dev
, 0x313);
6387 regRRSR
= ((regTmp
) << 24) | (regRRSR
& 0x00ffffff);
6388 write_nic_dword(dev
, RRSR
, regRRSR
);
6391 // Set Retry Limit here
6393 write_nic_word(dev
, RETRY_LIMIT
,
6394 priv
->ShortRetryLimit
<< RETRY_LIMIT_SHORT_SHIFT
| \
6395 priv
->LongRetryLimit
<< RETRY_LIMIT_LONG_SHIFT
);
6396 // Set Contention Window here
6400 // Set Tx Antenna including Feedback control
6402 // Set Auto Rate fallback control
6411 // Initial HW relted registers.
6414 // Config RTL8192S USB MAC, we should config MAC before download FW.
6416 // 2008.09.03, Added by Roger.
6418 static void rtl8192SU_MacConfigBeforeFwDownloadASIC(struct net_device
*dev
)
6425 RT_TRACE(COMP_INIT
, "--->MacConfigBeforeFwDownloadASIC()\n");
6427 //2MAC Initialization for power on sequence, Revised by Roger. 2008.09.03.
6430 //<Roger_Notes> Set control path switch to HW control and reset Digital Core, CPU Core and
6431 // MAC I/O to solve FW download fail when system from resume sate.
6434 tmpU1b
= read_nic_byte(dev
, SYS_CLKR
+1);
6438 write_nic_byte(dev
, SYS_CLKR
+1, tmpU1b
);
6440 // Clear FW RPWM for FW control LPS. by tynli. 2009.02.23
6441 write_nic_byte(dev
, RPWM
, 0x0);
6443 tmpU1b
= read_nic_byte(dev
, SYS_FUNC_EN
+1);
6445 write_nic_byte(dev
, SYS_FUNC_EN
+1, tmpU1b
);
6448 //Revised POS, suggested by SD1 Alex, 2008.09.27.
6449 write_nic_byte(dev
, SPS0_CTRL
+1, 0x53);
6450 write_nic_byte(dev
, SPS0_CTRL
, 0x57);
6452 //Enable AFE Macro Block's Bandgap adn Enable AFE Macro Block's Mbias
6453 tmpU1b
= read_nic_byte(dev
, AFE_MISC
);
6454 write_nic_byte(dev
, AFE_MISC
, (tmpU1b
|AFE_BGEN
|AFE_MBEN
));
6456 //Enable PLL Power (LDOA15V)
6457 tmpU1b
= read_nic_byte(dev
, LDOA15_CTRL
);
6458 write_nic_byte(dev
, LDOA15_CTRL
, (tmpU1b
|LDA15_EN
));
6460 //Enable LDOV12D block
6461 tmpU1b
= read_nic_byte(dev
, LDOV12D_CTRL
);
6462 write_nic_byte(dev
, LDOV12D_CTRL
, (tmpU1b
|LDV12_EN
));
6464 //mpU1b = read_nic_byte(Adapter, SPS1_CTRL);
6465 //write_nic_byte(dev, SPS1_CTRL, (tmpU1b|SPS1_LDEN));
6467 //PlatformSleepUs(2000);
6469 //Enable Switch Regulator Block
6470 //tmpU1b = read_nic_byte(Adapter, SPS1_CTRL);
6471 //write_nic_byte(dev, SPS1_CTRL, (tmpU1b|SPS1_SWEN));
6473 //write_nic_dword(Adapter, SPS1_CTRL, 0x00a7b267);
6475 tmpU1b
= read_nic_byte(dev
, SYS_ISO_CTRL
+1);
6476 write_nic_byte(dev
, SYS_ISO_CTRL
+1, (tmpU1b
|0x08));
6478 //Engineer Packet CP test Enable
6479 tmpU1b
= read_nic_byte(dev
, SYS_FUNC_EN
+1);
6480 write_nic_byte(dev
, SYS_FUNC_EN
+1, (tmpU1b
|0x20));
6482 //Support 64k IMEM, suggested by SD1 Alex.
6483 tmpU1b
= read_nic_byte(dev
, SYS_ISO_CTRL
+1);
6484 write_nic_byte(dev
, SYS_ISO_CTRL
+1, (tmpU1b
& 0x68));
6487 tmpU1b
= read_nic_byte(dev
, AFE_XTAL_CTRL
+1);
6488 write_nic_byte(dev
, AFE_XTAL_CTRL
+1, (tmpU1b
& 0xfb));
6490 //Enable AFE PLL Macro Block
6491 tmpU1b
= read_nic_byte(dev
, AFE_PLL_CTRL
);
6492 write_nic_byte(dev
, AFE_PLL_CTRL
, (tmpU1b
|0x11));
6494 //Attatch AFE PLL to MACTOP/BB/PCIe Digital
6495 tmpU1b
= read_nic_byte(dev
, SYS_ISO_CTRL
);
6496 write_nic_byte(dev
, SYS_ISO_CTRL
, (tmpU1b
&0xEE));
6498 // Switch to 40M clock
6499 write_nic_byte(dev
, SYS_CLKR
, 0x00);
6502 tmpU1b
= read_nic_byte(dev
, SYS_CLKR
);
6503 //write_nic_byte(dev, SYS_CLKR, (tmpU1b&0x5f));
6504 write_nic_byte(dev
, SYS_CLKR
, (tmpU1b
|0xa0));
6507 tmpU1b
= read_nic_byte(dev
, SYS_CLKR
+1);
6508 write_nic_byte(dev
, SYS_CLKR
+1, (tmpU1b
|0x18));
6510 //Revised POS, suggested by SD1 Alex, 2008.09.27.
6511 write_nic_byte(dev
, PMC_FSM
, 0x02);
6513 //Enable Core digital and enable IOREG R/W
6514 tmpU1b
= read_nic_byte(dev
, SYS_FUNC_EN
+1);
6515 write_nic_byte(dev
, SYS_FUNC_EN
+1, (tmpU1b
|0x08));
6518 tmpU1b
= read_nic_byte(dev
, SYS_FUNC_EN
+1);
6519 write_nic_byte(dev
, SYS_FUNC_EN
+1, (tmpU1b
|0x80));
6521 //Switch the control path to FW
6522 tmpU1b
= read_nic_byte(dev
, SYS_CLKR
+1);
6523 write_nic_byte(dev
, SYS_CLKR
+1, (tmpU1b
|0x80)& 0xBF);
6525 write_nic_byte(dev
, CMDR
, 0xFC);
6526 write_nic_byte(dev
, CMDR
+1, 0x37);
6528 //Fix the RX FIFO issue(usb error), 970410
6529 tmpU1b
= read_nic_byte_E(dev
, 0x5c);
6530 write_nic_byte_E(dev
, 0x5c, (tmpU1b
|BIT7
));
6532 //For power save, used this in the bit file after 970621
6533 tmpU1b
= read_nic_byte(dev
, SYS_CLKR
);
6534 write_nic_byte(dev
, SYS_CLKR
, tmpU1b
&(~SYS_CPU_CLKSEL
));
6536 // Revised for 8051 ROM code wrong operation. Added by Roger. 2008.10.16.
6537 write_nic_byte_E(dev
, 0x1c, 0x80);
6540 // <Roger_EXP> To make sure that TxDMA can ready to download FW.
6541 // We should reset TxDMA if IMEM RPT was not ready.
6542 // Suggested by SD1 Alex. 2008.10.23.
6546 tmpU1b
= read_nic_byte(dev
, TCR
);
6547 if((tmpU1b
& TXDMA_INIT_VALUE
) == TXDMA_INIT_VALUE
)
6549 //PlatformStallExecution(5);
6551 }while(PollingCnt
--); // Delay 1ms
6553 if(PollingCnt
<= 0 )
6555 RT_TRACE(COMP_INIT
, "MacConfigBeforeFwDownloadASIC(): Polling TXDMA_INIT_VALUE timeout!! Current TCR(%#x)\n", tmpU1b
);
6556 tmpU1b
= read_nic_byte(dev
, CMDR
);
6557 write_nic_byte(dev
, CMDR
, tmpU1b
&(~TXDMA_EN
));
6559 write_nic_byte(dev
, CMDR
, tmpU1b
|TXDMA_EN
);// Reset TxDMA
6563 RT_TRACE(COMP_INIT
, "<---MacConfigBeforeFwDownloadASIC()\n");
6568 static void rtl8192SU_SetHwRegAmpduMinSpace(struct net_device
*dev
, u8 MinSpaceCfg
)
6570 struct r8192_priv
*priv
= ieee80211_priv((struct net_device
*)dev
);
6571 struct ieee80211_device
* ieee
= priv
->ieee80211
;
6575 #ifdef RTL8192S_PREPARE_FOR_NORMAL_RELEASE
6576 MinSpacingToSet
= MinSpaceCfg
;
6577 if(MinSpacingToSet
<= 7)
6579 switch(ieee
->pairwise_key_type
)
6581 case KEY_TYPE_NA
: SecMinSpace
= 0; break;
6583 case KEY_TYPE_WEP40
:
6584 case KEY_TYPE_WEP104
:
6585 case KEY_TYPE_TKIP
: SecMinSpace
= 6; break;
6586 default: SecMinSpace
= 7; break;
6589 if(MinSpacingToSet
< SecMinSpace
)
6590 MinSpacingToSet
= SecMinSpace
;
6591 priv
->MinSpaceCfg
= ((priv
->MinSpaceCfg
&0xf8) |MinSpacingToSet
);
6592 RT_TRACE(COMP_SEC
, "Set AMPDU_MIN_SPACE: %x\n", priv
->MinSpaceCfg
);
6593 write_nic_byte(dev
, AMPDU_MIN_SPACE
, priv
->MinSpaceCfg
);
6597 MinSpacingToSet
= MinSpaceCfg
;
6598 MinSpacingToSet
&= 0x07; // We only care about bit[2:0]
6599 priv
->MinSpaceCfg
|= MinSpacingToSet
;
6600 RT_TRACE(COMP_SEC
, "Set AMPDU_MIN_SPACE: %x\n", priv
->MinSpaceCfg
);
6601 write_nic_byte(dev
, AMPDU_MIN_SPACE
, priv
->MinSpaceCfg
);//FIXLZM
6608 // Initial HW relted registers.
6611 // 1. This function is only invoked at driver intialization once.
6612 // 2. PASSIVE LEVEL.
6614 // 2008.06.10, Added by Roger.
6616 static void rtl8192SU_MacConfigAfterFwDownload(struct net_device
*dev
)
6618 struct r8192_priv
*priv
= ieee80211_priv((struct net_device
*)dev
);
6619 //PRT_HIGH_THROUGHPUT pHTInfo = priv->ieee80211->pHTInfo;
6620 //u8 tmpU1b, RxPageCfg, i;
6625 RT_TRACE(COMP_INIT
, "--->MacConfigAfterFwDownload()\n");
6628 tmpU2b
= (BBRSTn
|BB_GLB_RSTn
|SCHEDULE_EN
|MACRXEN
|MACTXEN
|DDMA_EN
|
6629 FW2HW_EN
|RXDMA_EN
|TXDMA_EN
|HCI_RXDMA_EN
|HCI_TXDMA_EN
); //3
6630 //Adapter->HalFunc.SetHwRegHandler( Adapter, HW_VAR_COMMAND, &tmpU1b );
6631 write_nic_word(dev
, CMDR
, tmpU2b
); //LZM REGISTER COM 090305
6633 // Loopback mode or not
6634 priv
->LoopbackMode
= RTL8192SU_NO_LOOPBACK
; // Set no loopback as default.
6635 if(priv
->LoopbackMode
== RTL8192SU_NO_LOOPBACK
)
6636 tmpU1b
= LBK_NORMAL
;
6637 else if (priv
->LoopbackMode
== RTL8192SU_MAC_LOOPBACK
)
6638 tmpU1b
= LBK_MAC_DLB
;
6640 RT_TRACE(COMP_INIT
, "Serious error: wrong loopback mode setting\n");
6642 //Adapter->HalFunc.SetHwRegHandler( Adapter, HW_VAR_LBK_MODE, &tmpU1b);
6643 write_nic_byte(dev
, LBKMD_SEL
, tmpU1b
);
6646 write_nic_dword(dev
, RCR
, priv
->ReceiveConfig
);
6647 RT_TRACE(COMP_INIT
, "MacConfigAfterFwDownload(): Current RCR settings(%#x)\n", priv
->ReceiveConfig
);
6652 // <Roger_Notes> 2008.08.18.
6654 // (1) Page number on CMDQ is 0x03.
6655 // (2) Page number on BCNQ, HQ and MGTQ is 0.
6656 // (3) Page number on BKQ, BEQ, VIQ and VOQ are 0x07.
6657 // (4) Page number on PUBQ is 0xdd
6660 // (1) Page number on CMDQ is 0x00.
6661 // (2) Page number on BCNQ is 0x02, HQ and MGTQ are 0x03.
6662 // (3) Page number on BKQ, BEQ, VIQ and VOQ are 0x07.
6663 // (4) Page number on PUBQ is 0xd8
6665 //write_nic_dword(Adapter, 0xa0, 0x07070707); //BKQ, BEQ, VIQ and VOQ
6666 //write_nic_byte(dev, 0xa4, 0x00); // HCCAQ
6668 #ifdef USE_SIX_USB_ENDPOINT
6669 //write_nic_dword(Adapter, 0xa5, 0x00000003); //CMDQ, MGTQ, HQ and BCNQ
6670 //write_nic_byte(dev, 0xa9, 0xdd); // PUBQ
6671 tmpU1b
= read_nic_byte(dev
, 0xab); // RQPN
6672 write_nic_byte(dev
, 0xab, tmpU1b
|BIT7
|BIT6
);// reduce to 6 endpoints.
6674 write_nic_dword(dev
, 0xa5, 0x02030300); //CMDQ, MGTQ, HQ and BCNQ
6675 write_nic_byte(dev
, 0xa9, 0xd8); // PUBQ
6676 tmpU1b
= read_nic_byte(dev
, 0xab); // RQPN
6677 write_nic_byte(dev
, 0xab, (tmpU1b
&(~BIT6
))|BIT7
); // Disable reduced endpoint.
6682 // Fix the RX FIFO issue(USB error), Rivesed by Roger, 2008-06-14
6683 tmpU1b
= read_nic_byte_E(dev
, 0x5C);
6684 write_nic_byte_E(dev
, 0x5C, tmpU1b
|BIT7
);
6688 // Suggested by SD1 Alex, 2008-06-14.
6690 write_nic_byte(dev
, TXOP_STALL_CTRL
, 0x80);//NAV
6694 // Set Data Auto Rate Fallback Retry Count register.
6696 write_nic_dword(dev
, DARFRC
, 0x04010000);
6697 write_nic_dword(dev
, DARFRC
+4, 0x09070605);
6698 write_nic_dword(dev
, RARFRC
, 0x04010000);
6699 write_nic_dword(dev
, RARFRC
+4, 0x09070605);
6701 // Set Data Auto Rate Fallback Reg. Added by Roger, 2008.09.22.
6702 for (i
= 0; i
< 8; i
++)
6703 write_nic_dword(dev
, ARFR0
+i
*4, 0x1f0ffff0);
6706 // Set driver info, we only accept PHY status now.
6708 //write_nic_byte(dev, RXDRVINFO_SZ, 4);
6711 // Aggregation length limit. Revised by Roger. 2008.09.22.
6713 write_nic_dword(dev
, AGGLEN_LMT_L
, 0x66666666); // Long GI
6714 write_nic_byte(dev
, AGGLEN_LMT_H
, 0x06); // Set AMPDU length to 12Kbytes for ShortGI case.
6717 // For Min Spacing configuration.
6719 //Adapter->HalFunc.SetHwRegHandler(Adapter, HW_VAR_AMPDU_MIN_SPACE, (u8*)(&Adapter->MgntInfo.MinSpaceCfg));
6720 rtl8192SU_SetHwRegAmpduMinSpace(dev
,priv
->MinSpaceCfg
);
6723 // For EFUSE init configuration.
6724 //if (IS_BOOT_FROM_EFUSE(Adapter)) // We may R/W EFUSE in EFUSE mode
6725 if (priv
->bBootFromEfuse
)
6729 tempval
= read_nic_byte(dev
, SYS_ISO_CTRL
+1);
6731 write_nic_byte(dev
, SYS_ISO_CTRL
+1, tempval
);
6733 // Enable LDO 2.5V for write action
6734 //tempval = read_nic_byte(Adapter, EFUSE_TEST+3);
6735 //write_nic_byte(Adapter, EFUSE_TEST+3, (tempval | 0x80));
6737 // Change Efuse Clock for write action
6738 //write_nic_byte(Adapter, EFUSE_CLK, 0x03);
6740 // Change Program timing
6741 write_nic_byte(dev
, EFUSE_CTRL
+3, 0x72);
6742 //printk("!!!!!!!!!!!!!!!!!!!!!%s: write 0x33 with 0x72\n",__FUNCTION__);
6743 RT_TRACE(COMP_INIT
, "EFUSE CONFIG OK\n");
6747 RT_TRACE(COMP_INIT
, "<---MacConfigAfterFwDownload()\n");
6750 void rtl8192SU_HwConfigureRTL8192SUsb(struct net_device
*dev
)
6753 struct r8192_priv
*priv
= ieee80211_priv(dev
);
6755 u32 regRATR
= 0, regRRSR
= 0;
6759 //1 This part need to modified according to the rate set we filtered!!
6761 // Set RRSR, RATR, and BW_OPMODE registers
6763 switch(priv
->ieee80211
->mode
)
6765 case WIRELESS_MODE_B
:
6766 regBwOpMode
= BW_OPMODE_20MHZ
;
6767 regRATR
= RATE_ALL_CCK
;
6768 regRRSR
= RATE_ALL_CCK
;
6770 case WIRELESS_MODE_A
:
6771 regBwOpMode
= BW_OPMODE_5G
|BW_OPMODE_20MHZ
;
6772 regRATR
= RATE_ALL_OFDM_AG
;
6773 regRRSR
= RATE_ALL_OFDM_AG
;
6775 case WIRELESS_MODE_G
:
6776 regBwOpMode
= BW_OPMODE_20MHZ
;
6777 regRATR
= RATE_ALL_CCK
| RATE_ALL_OFDM_AG
;
6778 regRRSR
= RATE_ALL_CCK
| RATE_ALL_OFDM_AG
;
6780 case WIRELESS_MODE_AUTO
:
6781 if (priv
->bInHctTest
)
6783 regBwOpMode
= BW_OPMODE_20MHZ
;
6784 regRATR
= RATE_ALL_CCK
| RATE_ALL_OFDM_AG
;
6785 regRRSR
= RATE_ALL_CCK
| RATE_ALL_OFDM_AG
;
6789 regBwOpMode
= BW_OPMODE_20MHZ
;
6790 regRATR
= RATE_ALL_CCK
| RATE_ALL_OFDM_AG
| RATE_ALL_OFDM_1SS
| RATE_ALL_OFDM_2SS
;
6791 regRRSR
= RATE_ALL_CCK
| RATE_ALL_OFDM_AG
;
6794 case WIRELESS_MODE_N_24G
:
6795 // It support CCK rate by default.
6796 // CCK rate will be filtered out only when associated AP does not support it.
6797 regBwOpMode
= BW_OPMODE_20MHZ
;
6798 regRATR
= RATE_ALL_CCK
| RATE_ALL_OFDM_AG
| RATE_ALL_OFDM_1SS
| RATE_ALL_OFDM_2SS
;
6799 regRRSR
= RATE_ALL_CCK
| RATE_ALL_OFDM_AG
;
6801 case WIRELESS_MODE_N_5G
:
6802 regBwOpMode
= BW_OPMODE_5G
;
6803 regRATR
= RATE_ALL_OFDM_AG
| RATE_ALL_OFDM_1SS
| RATE_ALL_OFDM_2SS
;
6804 regRRSR
= RATE_ALL_OFDM_AG
;
6809 // <Roger_Notes> We disable CCK response rate until FIB CCK rate IC's back.
6812 regTmp
= read_nic_byte(dev
, INIRTSMCS_SEL
);
6813 regRRSR
= ((regRRSR
& 0x000fffff)<<8) | regTmp
;
6816 // Update SIFS timing.
6818 //priv->SifsTime = 0x0e0e0a0a;
6819 //Adapter->HalFunc.SetHwRegHandler( Adapter, HW_VAR_SIFS, (pu1Byte)&pHalData->SifsTime);
6820 { u8 val
[4] = {0x0e, 0x0e, 0x0a, 0x0a};
6821 // SIFS for CCK Data ACK
6822 write_nic_byte(dev
, SIFS_CCK
, val
[0]);
6823 // SIFS for CCK consecutive tx like CTS data!
6824 write_nic_byte(dev
, SIFS_CCK
+1, val
[1]);
6826 // SIFS for OFDM Data ACK
6827 write_nic_byte(dev
, SIFS_OFDM
, val
[2]);
6828 // SIFS for OFDM consecutive tx like CTS data!
6829 write_nic_byte(dev
, SIFS_OFDM
+1, val
[3]);
6832 write_nic_dword(dev
, INIRTSMCS_SEL
, regRRSR
);
6833 write_nic_byte(dev
, BW_OPMODE
, regBwOpMode
);
6836 // Suggested by SD1 Alex, 2008-06-14.
6838 //PlatformEFIOWrite1Byte(Adapter, TXOP_STALL_CTRL, 0x80);//NAV to protect all TXOP.
6841 // Set Data Auto Rate Fallback Retry Count register.
6843 write_nic_dword(dev
, DARFRC
, 0x02010000);
6844 write_nic_dword(dev
, DARFRC
+4, 0x06050403);
6845 write_nic_dword(dev
, RARFRC
, 0x02010000);
6846 write_nic_dword(dev
, RARFRC
+4, 0x06050403);
6848 // Set Data Auto Rate Fallback Reg. Added by Roger, 2008.09.22.
6849 for (i
= 0; i
< 8; i
++)
6850 write_nic_dword(dev
, ARFR0
+i
*4, 0x1f0ffff0);
6853 // Aggregation length limit. Revised by Roger. 2008.09.22.
6855 write_nic_byte(dev
, AGGLEN_LMT_H
, 0x0f); // Set AMPDU length to 12Kbytes for ShortGI case.
6856 write_nic_dword(dev
, AGGLEN_LMT_L
, 0xddd77442); // Long GI
6857 write_nic_dword(dev
, AGGLEN_LMT_L
+4, 0xfffdd772);
6859 // Set NAV protection length
6860 write_nic_word(dev
, NAV_PROT_LEN
, 0x0080);
6862 // Set TXOP stall control for several queue/HI/BCN/MGT/
6863 write_nic_byte(dev
, TXOP_STALL_CTRL
, 0x00); // NAV Protect next packet.
6865 // Set MSDU lifetime.
6866 write_nic_byte(dev
, MLT
, 0x8f);
6868 // Set CCK/OFDM SIFS
6869 write_nic_word(dev
, SIFS_CCK
, 0x0a0a); // CCK SIFS shall always be 10us.
6870 write_nic_word(dev
, SIFS_OFDM
, 0x0e0e);
6872 write_nic_byte(dev
, ACK_TIMEOUT
, 0x40);
6875 write_nic_byte(dev
, CFEND_TH
, 0xFF);
6878 // For Min Spacing configuration.
6880 switch(priv
->rf_type
)
6884 RT_TRACE(COMP_INIT
, "Initializeadapter: RF_Type%s\n", (priv
->rf_type
==RF_1T1R
? "(1T1R)":"(1T2R)"));
6885 priv
->MinSpaceCfg
= (MAX_MSS_DENSITY_1T
<<3);
6889 RT_TRACE(COMP_INIT
, "Initializeadapter:RF_Type(2T2R)\n");
6890 priv
->MinSpaceCfg
= (MAX_MSS_DENSITY_2T
<<3);
6893 write_nic_byte(dev
, AMPDU_MIN_SPACE
, priv
->MinSpaceCfg
);
6897 // For Min Spacing configuration.
6899 //priv->MinSpaceCfg = 0x00;
6900 //rtl8192SU_SetHwRegAmpduMinSpace(dev, priv->MinSpaceCfg);
6906 // Description: Initial HW relted registers.
6908 // Assumption: This function is only invoked at driver intialization once.
6910 // 2008.06.10, Added by Roger.
6911 bool rtl8192SU_adapter_start(struct net_device
*dev
)
6913 struct r8192_priv
*priv
= ieee80211_priv(dev
);
6914 //u32 dwRegRead = 0;
6915 //bool init_status = true;
6917 bool rtStatus
= true;
6919 //u8 eRFPath, tmpU1b;
6920 u8 fw_download_times
= 1;
6923 RT_TRACE(COMP_INIT
, "--->InitializeAdapter8192SUsb()\n");
6925 //pHalData->bGPIOChangeRF = FALSE;
6929 // <Roger_Notes> 2008.06.15.
6931 // Initialization Steps on RTL8192SU:
6932 // a. MAC initialization prior to sending down firmware code.
6933 // b. Download firmware code step by step(i.e., IMEM, EMEM, DMEM).
6934 // c. MAC configuration after firmware has been download successfully.
6935 // d. Initialize BB related configurations.
6936 // e. Initialize RF related configurations.
6937 // f. Start to BulkIn transfer.
6941 //a. MAC initialization prior to send down firmware code.
6944 rtl8192SU_MacConfigBeforeFwDownloadASIC(dev
);
6947 //b. Download firmware code step by step(i.e., IMEM, EMEM, DMEM).
6949 rtStatus
= FirmwareDownload92S(dev
);
6950 if(rtStatus
!= true)
6952 if(fw_download_times
== 1){
6953 RT_TRACE(COMP_INIT
, "InitializeAdapter8192SUsb(): Download Firmware failed once, Download again!!\n");
6954 fw_download_times
= fw_download_times
+ 1;
6957 RT_TRACE(COMP_INIT
, "InitializeAdapter8192SUsb(): Download Firmware failed twice, end!!\n");
6962 //c. MAC configuration after firmware has been download successfully.
6964 rtl8192SU_MacConfigAfterFwDownload(dev
);
6966 //priv->bLbusEnable = TRUE;
6967 //if(priv->RegRfOff == TRUE)
6968 // priv->eRFPowerState = eRfOff;
6970 // Save target channel
6971 // <Roger_Notes> Current Channel will be updated again later.
6972 //priv->CurrentChannel = Channel;
6973 rtStatus
= PHY_MACConfig8192S(dev
);//===>ok
6974 if(rtStatus
!= true)
6976 RT_TRACE(COMP_INIT
, "InitializeAdapter8192SUsb(): Fail to configure MAC!!\n");
6982 write_nic_dword(dev
,WDCAPARA_ADD
[i
], 0x5e4322);
6983 write_nic_byte(dev
,AcmHwCtrl
, 0x01);
6988 //d. Initialize BB related configurations.
6991 rtStatus
= PHY_BBConfig8192S(dev
);//===>ok
6992 if(rtStatus
!= true)
6994 RT_TRACE(COMP_INIT
, "InitializeAdapter8192SUsb(): Fail to configure BB!!\n");
6998 rtl8192_setBBreg(dev
, rFPGA0_AnalogParameter2
, 0xff, 0x58);//===>ok
7001 // e. Initialize RF related configurations.
7003 // 2007/11/02 MH Before initalizing RF. We can not use FW to do RF-R/W.
7004 priv
->Rf_Mode
= RF_OP_By_SW_3wire
;
7006 // For RF test only from Scott's suggestion
7007 //write_nic_byte(dev, 0x27, 0xDB);
7008 //write_nic_byte(dev, 0x1B, 0x07);
7011 write_nic_byte(dev
, AFE_XTAL_CTRL
+1, 0xDB);
7013 // <Roger_Notes> The following IOs are configured for each RF modules.
7014 // Enable RF module and reset RF and SDM module. 2008.11.17.
7015 if(priv
->card_8192_version
== VERSION_8192S_ACUT
)
7016 write_nic_byte(dev
, SPS1_CTRL
+3, (u8
)(RF_EN
|RF_RSTB
|RF_SDMRSTB
)); // Fix A-Cut bug.
7018 write_nic_byte(dev
, RF_CTRL
, (u8
)(RF_EN
|RF_RSTB
|RF_SDMRSTB
));
7020 rtStatus
= PHY_RFConfig8192S(dev
);//===>ok
7021 if(rtStatus
!= true)
7023 RT_TRACE(COMP_INIT
, "InitializeAdapter8192SUsb(): Fail to configure RF!!\n");
7028 // Set CCK and OFDM Block "ON"
7029 rtl8192_setBBreg(dev
, rFPGA0_RFMOD
, bCCKEn
, 0x1);
7030 rtl8192_setBBreg(dev
, rFPGA0_RFMOD
, bOFDMEn
, 0x1);
7033 // Turn off Radio B while RF type is 1T1R by SD3 Wilsion's request.
7034 // Revised by Roger, 2008.12.18.
7036 if(priv
->rf_type
== RF_1T1R
)
7038 // This is needed for PHY_REG after 20081219
7039 rtl8192_setBBreg(dev
, rFPGA0_RFMOD
, 0xff000000, 0x03);
7040 // This is needed for PHY_REG before 20081219
7041 //PHY_SetBBReg(Adapter, rOFDM0_TRxPathEnable, bMaskByte0, 0x11);
7044 #if (RTL8192SU_DISABLE_IQK==0)
7045 // For 1T2R IQK only currently.
7046 if (priv
->card_8192_version
== VERSION_8192S_BCUT
)
7048 PHY_IQCalibrateBcut(dev
);
7050 else if (priv
->card_8192_version
== VERSION_8192S_ACUT
)
7052 PHY_IQCalibrate(dev
);
7057 // Set CCK and OFDM Block "ON"
7058 //rtl8192_setBBreg(dev, rFPGA0_RFMOD, bCCKEn, 0x1);
7059 //rtl8192_setBBreg(dev, rFPGA0_RFMOD, bOFDMEn, 0x1);
7062 //3//Get hardware version, do it in read eeprom?
7063 //GetHardwareVersion819xUsb(Adapter);
7068 rtl8192SU_HwConfigureRTL8192SUsb(dev
);//==>ok
7071 // <Roger_Notes> We set MAC address here if autoload was failed before,
7072 // otherwise IDR0 will NOT contain any value.
7074 write_nic_dword(dev
, IDR0
, ((u32
*)dev
->dev_addr
)[0]);
7075 write_nic_word(dev
, IDR4
, ((u16
*)(dev
->dev_addr
+ 4))[0]);
7076 if(!priv
->bInHctTest
)
7078 if(priv
->ResetProgress
== RESET_TYPE_NORESET
)
7080 //RT_TRACE(COMP_MLME, DBG_LOUD, ("Initializeadapter8192SUsb():RegWirelessMode(%#x) \n", Adapter->RegWirelessMode));
7081 //Adapter->HalFunc.SetWirelessModeHandler(Adapter, Adapter->RegWirelessMode);
7082 rtl8192_SetWirelessMode(dev
, priv
->ieee80211
->mode
);//===>ok
7087 priv
->ieee80211
->mode
= WIRELESS_MODE_G
;
7088 rtl8192_SetWirelessMode(dev
, WIRELESS_MODE_G
);
7092 //-----------------------------------------------------------------------------
7093 // Set up security related. 070106, by rcnjko:
7094 // 1. Clear all H/W keys.
7095 // 2. Enable H/W encryption/decryption.
7096 //-----------------------------------------------------------------------------
7097 //CamResetAllEntry(Adapter);
7098 //Adapter->HalFunc.EnableHWSecCfgHandler(Adapter);
7100 //SecClearAllKeys(Adapter);
7101 CamResetAllEntry(dev
);
7104 u8 SECR_value
= 0x0;
7105 SECR_value
|= SCR_TxEncEnable
;
7106 SECR_value
|= SCR_RxDecEnable
;
7107 SECR_value
|= SCR_NoSKMC
;
7108 write_nic_byte(dev
, SECR
, SECR_value
);
7113 if(pHalData
->VersionID
== VERSION_8192SU_A
)
7115 // cosa add for tx power level initialization.
7116 GetTxPowerOriginalOffset(Adapter
);
7117 SetTxPowerLevel819xUsb(Adapter
, Channel
);
7124 //PHY_UpdateInitialGain(dev);
7126 if(priv
->RegRfOff
== true)
7127 { // User disable RF via registry.
7130 RT_TRACE((COMP_INIT
|COMP_RF
), "InitializeAdapter8192SUsb(): Turn off RF for RegRfOff ----------\n");
7131 MgntActSet_RF_State(dev
, eRfOff
, RF_CHANGE_BY_SW
);
7132 // Those action will be discard in MgntActSet_RF_State because off the same state
7133 for(eRFPath
= 0; eRFPath
<priv
->NumTotalRFPath
; eRFPath
++)
7134 rtl8192_setBBreg(dev
, (RF90_RADIO_PATH_E
)eRFPath
, 0x4, 0xC00, 0x0);
7136 else if(priv
->RfOffReason
> RF_CHANGE_BY_PS
)
7137 { // H/W or S/W RF OFF before sleep.
7138 RT_TRACE((COMP_INIT
|COMP_RF
), "InitializeAdapter8192SUsb(): Turn off RF for RfOffReason(%d) ----------\n", priv
->RfOffReason
);
7139 MgntActSet_RF_State(dev
, eRfOff
, priv
->RfOffReason
);
7143 priv
->eRFPowerState
= eRfOn
;
7144 priv
->RfOffReason
= 0;
7145 RT_TRACE((COMP_INIT
|COMP_RF
), "InitializeAdapter8192SUsb(): RF is on ----------\n");
7152 // f. Start to BulkIn transfer.
7159 PlatformAcquireSpinLock(Adapter
, RT_RX_SPINLOCK
);
7161 for(PipeIndex
=0; PipeIndex
< MAX_RX_QUEUE
; PipeIndex
++)
7166 HalUsbInMpdu(Adapter
, PipeIndex
);
7170 //HalUsbInMpdu(Adapter, PipeIndex);
7171 //HalUsbInMpdu(Adapter, PipeIndex);
7172 //HalUsbInMpdu(Adapter, PipeIndex);
7175 PlatformReleaseSpinLock(Adapter
, RT_RX_SPINLOCK
);
7178 // Joseph add to 819X code base for Vista USB platform.
7179 // This part may need to be add to Hal819xU code base. too.
7180 PlatformUsbEnableInPipes(Adapter
);
7183 RT_TRACE(COMP_INIT
, "HighestOperaRate = %x\n", Adapter
->MgntInfo
.HighestOperaRate
);
7185 PlatformStartWorkItem( &(pHalData
->RtUsbCheckForHangWorkItem
) );
7188 // <Roger_EXP> The following configurations are for ASIC verification temporally.
7195 // Read EEPROM TX power index and PHY_REG_PG.txt to capture correct
7196 // TX power index for different rate set.
7198 //if(priv->card_8192_version >= VERSION_8192S_ACUT)
7200 // Get original hw reg values
7201 PHY_GetHWRegOriginalValue(dev
);
7203 // Write correct tx power index//FIXLZM
7204 PHY_SetTxPowerLevel8192S(dev
, priv
->chan
);
7209 // EEPROM R/W workaround
7210 tmpU1b
= read_nic_byte(dev
, MAC_PINMUX_CFG
);
7211 write_nic_byte(dev
, MAC_PINMUX_CFG
, tmpU1b
&(~GPIOMUX_EN
));
7215 //<Roger_Notes> 2008.08.19.
7216 // We return status here for temporal FPGA verification, 2008.08.19.
7218 #ifdef RTL8192SU_FW_IQK
7219 write_nic_dword(dev
, WFM5
, FW_IQK_ENABLE
);
7220 ChkFwCmdIoDone(dev
);
7224 // <Roger_Notes> We enable high power mechanism after NIC initialized.
7227 write_nic_dword(dev
, WFM5
, FW_RA_RESET
);
7228 ChkFwCmdIoDone(dev
);
7229 write_nic_dword(dev
, WFM5
, FW_RA_ACTIVE
);
7230 ChkFwCmdIoDone(dev
);
7231 write_nic_dword(dev
, WFM5
, FW_RA_REFRESH
);
7232 ChkFwCmdIoDone(dev
);
7233 write_nic_dword(dev
, WFM5
, FW_BB_RESET_ENABLE
);
7235 // <Roger_Notes> We return status here for temporal FPGA verification. 2008.05.12.
7238 // The following IO was for FPGA verification purpose. Added by Roger, 2008.09.11.
7240 // 2008/08/19 MH From SD1 Jong, we must write some register for true PHY/MAC FPGA.
7241 write_nic_byte(dev
, rOFDM0_XAAGCCore1
, 0x30);
7242 write_nic_byte(dev
, rOFDM0_XBAGCCore1
, 0x30);
7244 write_nic_byte(dev
, rOFDM0_RxDetector1
, 0x42);
7246 //write_nic_dword(Adapter, RCR, 0x817FF02F);
7248 write_nic_dword(Adapter
, rTxAGC_Mcs15_Mcs12
, 0x06060606);
7256 //InitializeAdapter and PhyCfg
7257 bool rtl8192_adapter_start(struct net_device
*dev
)
7259 struct r8192_priv
*priv
= ieee80211_priv(dev
);
7261 bool init_status
= true;
7262 RT_TRACE(COMP_INIT
, "====>%s()\n", __FUNCTION__
);
7263 priv
->Rf_Mode
= RF_OP_By_SW_3wire
;
7264 //for ASIC power on sequence
7265 write_nic_byte_E(dev
, 0x5f, 0x80);
7267 write_nic_byte_E(dev
, 0x5f, 0xf0);
7268 write_nic_byte_E(dev
, 0x5d, 0x00);
7269 write_nic_byte_E(dev
, 0x5e, 0x80);
7270 write_nic_byte(dev
, 0x17, 0x37);
7273 priv
->pFirmware
->firmware_status
= FW_STATUS_0_INIT
;
7274 //config CPUReset Register
7275 //Firmware Reset or not?
7276 dwRegRead
= read_nic_dword(dev
, CPU_GEN
);
7277 if (priv
->pFirmware
->firmware_status
== FW_STATUS_0_INIT
)
7278 dwRegRead
|= CPU_GEN_SYSTEM_RESET
; //do nothing here?
7279 else if (priv
->pFirmware
->firmware_status
== FW_STATUS_5_READY
)
7280 dwRegRead
|= CPU_GEN_FIRMWARE_RESET
;
7282 RT_TRACE(COMP_ERR
, "ERROR in %s(): undefined firmware state(%d)\n", __FUNCTION__
, priv
->pFirmware
->firmware_status
);
7284 write_nic_dword(dev
, CPU_GEN
, dwRegRead
);
7287 rtl8192_BBConfig(dev
);
7290 //Loopback mode or not
7291 priv
->LoopbackMode
= RTL819xU_NO_LOOPBACK
;
7292 // priv->LoopbackMode = RTL819xU_MAC_LOOPBACK;
7294 dwRegRead
= read_nic_dword(dev
, CPU_GEN
);
7295 if (priv
->LoopbackMode
== RTL819xU_NO_LOOPBACK
)
7296 dwRegRead
= ((dwRegRead
& CPU_GEN_NO_LOOPBACK_MSK
) | CPU_GEN_NO_LOOPBACK_SET
);
7297 else if (priv
->LoopbackMode
== RTL819xU_MAC_LOOPBACK
)
7298 dwRegRead
|= CPU_CCK_LOOPBACK
;
7300 RT_TRACE(COMP_ERR
, "Serious error in %s(): wrong loopback mode setting(%d)\n", __FUNCTION__
, priv
->LoopbackMode
);
7302 write_nic_dword(dev
, CPU_GEN
, dwRegRead
);
7304 //after reset cpu, we need wait for a seconds to write in register.
7307 //xiong add for new bitfile:usb suspend reset pin set to 1. //do we need?
7308 write_nic_byte_E(dev
, 0x5f, (read_nic_byte_E(dev
, 0x5f)|0x20));
7311 rtl8192_hwconfig(dev
);
7314 write_nic_byte(dev
, CMDR
, CR_RE
|CR_TE
);
7317 write_nic_dword(dev
, MAC0
, ((u32
*)dev
->dev_addr
)[0]);
7318 write_nic_word(dev
, MAC4
, ((u16
*)(dev
->dev_addr
+ 4))[0]);
7321 write_nic_dword(dev
, RCR
, priv
->ReceiveConfig
);
7323 //Initialize Number of Reserved Pages in Firmware Queue
7324 write_nic_dword(dev
, RQPN1
, NUM_OF_PAGE_IN_FW_QUEUE_BK
<< RSVD_FW_QUEUE_PAGE_BK_SHIFT
|\
7325 NUM_OF_PAGE_IN_FW_QUEUE_BE
<< RSVD_FW_QUEUE_PAGE_BE_SHIFT
| \
7326 NUM_OF_PAGE_IN_FW_QUEUE_VI
<< RSVD_FW_QUEUE_PAGE_VI_SHIFT
| \
7327 NUM_OF_PAGE_IN_FW_QUEUE_VO
<<RSVD_FW_QUEUE_PAGE_VO_SHIFT
);
7328 write_nic_dword(dev
, RQPN2
, NUM_OF_PAGE_IN_FW_QUEUE_MGNT
<< RSVD_FW_QUEUE_PAGE_MGNT_SHIFT
|\
7329 NUM_OF_PAGE_IN_FW_QUEUE_CMD
<< RSVD_FW_QUEUE_PAGE_CMD_SHIFT
);
7330 write_nic_dword(dev
, RQPN3
, APPLIED_RESERVED_QUEUE_IN_FW
| \
7331 NUM_OF_PAGE_IN_FW_QUEUE_BCN
<<RSVD_FW_QUEUE_PAGE_BCN_SHIFT
7332 // | NUM_OF_PAGE_IN_FW_QUEUE_PUB<<RSVD_FW_QUEUE_PAGE_PUB_SHIFT
7334 write_nic_dword(dev
, RATR0
+4*7, (RATE_ALL_OFDM_AG
| RATE_ALL_CCK
));
7337 // TODO: (it value is only for FPGA version). need to be changed!!2006.12.18, by Emily
7338 write_nic_byte(dev
, ACK_TIMEOUT
, 0x30);
7340 // RT_TRACE(COMP_INIT, "%s():priv->ResetProgress is %d\n", __FUNCTION__,priv->ResetProgress);
7341 if(priv
->ResetProgress
== RESET_TYPE_NORESET
)
7342 rtl8192_SetWirelessMode(dev
, priv
->ieee80211
->mode
);
7343 if(priv
->ResetProgress
== RESET_TYPE_NORESET
){
7344 CamResetAllEntry(dev
);
7346 u8 SECR_value
= 0x0;
7347 SECR_value
|= SCR_TxEncEnable
;
7348 SECR_value
|= SCR_RxDecEnable
;
7349 SECR_value
|= SCR_NoSKMC
;
7350 write_nic_byte(dev
, SECR
, SECR_value
);
7355 write_nic_word(dev
, ATIMWND
, 2);
7356 write_nic_word(dev
, BCN_INTERVAL
, 100);
7359 #define DEFAULT_EDCA 0x005e4332
7361 for (i
=0; i
<QOS_QUEUE_NUM
; i
++)
7362 write_nic_dword(dev
, WDCAPARA_ADD
[i
], DEFAULT_EDCA
);
7365 rtl8192_phy_configmac(dev
);
7367 if (priv
->card_8192_version
== (u8
) VERSION_819xU_A
)
7369 rtl8192_phy_getTxPower(dev
);
7370 rtl8192_phy_setTxPower(dev
, priv
->chan
);
7374 priv
->usb_error
= false;
7376 init_status
= init_firmware(dev
);
7379 RT_TRACE(COMP_ERR
,"ERR!!! %s(): Firmware download is failed\n", __FUNCTION__
);
7382 RT_TRACE(COMP_INIT
, "%s():after firmware download\n", __FUNCTION__
);
7385 if(Adapter
->ResetProgress
== RESET_TYPE_NORESET
)
7387 if(pMgntInfo
->RegRfOff
== TRUE
)
7388 { // User disable RF via registry.
7389 RT_TRACE((COMP_INIT
|COMP_RF
), DBG_LOUD
, ("InitializeAdapter819xUsb(): Turn off RF for RegRfOff ----------\n"));
7390 MgntActSet_RF_State(Adapter
, eRfOff
, RF_CHANGE_BY_SW
);
7391 // Those action will be discard in MgntActSet_RF_State because off the same state
7392 for(eRFPath
= 0; eRFPath
<pHalData
->NumTotalRFPath
; eRFPath
++)
7393 PHY_SetRFReg(Adapter
, (RF90_RADIO_PATH_E
)eRFPath
, 0x4, 0xC00, 0x0);
7395 else if(pMgntInfo
->RfOffReason
> RF_CHANGE_BY_PS
)
7396 { // H/W or S/W RF OFF before sleep.
7397 RT_TRACE((COMP_INIT
|COMP_RF
), DBG_LOUD
, ("InitializeAdapter819xUsb(): Turn off RF for RfOffReason(%d) ----------\n", pMgntInfo
->RfOffReason
));
7398 MgntActSet_RF_State(Adapter
, eRfOff
, pMgntInfo
->RfOffReason
);
7402 pHalData
->eRFPowerState
= eRfOn
;
7403 pMgntInfo
->RfOffReason
= 0;
7404 RT_TRACE((COMP_INIT
|COMP_RF
), DBG_LOUD
, ("InitializeAdapter819xUsb(): RF is on ----------\n"));
7409 if(pHalData
->eRFPowerState
== eRfOff
)
7411 MgntActSet_RF_State(Adapter
, eRfOff
, pMgntInfo
->RfOffReason
);
7412 // Those action will be discard in MgntActSet_RF_State because off the same state
7413 for(eRFPath
= 0; eRFPath
<pHalData
->NumTotalRFPath
; eRFPath
++)
7414 PHY_SetRFReg(Adapter
, (RF90_RADIO_PATH_E
)eRFPath
, 0x4, 0xC00, 0x0);
7419 if(priv
->ResetProgress
== RESET_TYPE_NORESET
){
7420 rtl8192_phy_RFConfig(dev
);
7421 RT_TRACE(COMP_INIT
, "%s():after phy RF config\n", __FUNCTION__
);
7425 if(priv
->ieee80211
->FwRWRF
)
7426 // We can force firmware to do RF-R/W
7427 priv
->Rf_Mode
= RF_OP_By_FW
;
7429 priv
->Rf_Mode
= RF_OP_By_SW_3wire
;
7432 rtl8192_phy_updateInitGain(dev
);
7433 /*--set CCK and OFDM Block "ON"--*/
7434 rtl8192_setBBreg(dev
, rFPGA0_RFMOD
, bCCKEn
, 0x1);
7435 rtl8192_setBBreg(dev
, rFPGA0_RFMOD
, bOFDMEn
, 0x1);
7437 if(priv
->ResetProgress
== RESET_TYPE_NORESET
)
7440 u8 tmpvalue
= read_nic_byte(dev
, 0x301);
7444 RT_TRACE(COMP_POWER_TRACKING
, "D-cut\n");
7448 priv
->bDcut
= FALSE
;
7449 RT_TRACE(COMP_POWER_TRACKING
, "C-cut\n");
7451 dm_initialize_txpower_tracking(dev
);
7453 if(priv
->bDcut
== TRUE
)
7456 u32 tmpRegA
= rtl8192_QueryBBReg(dev
,rOFDM0_XATxIQImbalance
,bMaskDWord
);
7457 // u32 tmpRegC= rtl8192_QueryBBReg(dev,rOFDM0_XCTxIQImbalance,bMaskDWord);
7458 for(i
= 0; i
<TxBBGainTableLength
; i
++)
7460 if(tmpRegA
== priv
->txbbgain_table
[i
].txbbgain_value
)
7462 priv
->rfa_txpowertrackingindex
= (u8
)i
;
7463 priv
->rfa_txpowertrackingindex_real
= (u8
)i
;
7464 priv
->rfa_txpowertracking_default
= priv
->rfa_txpowertrackingindex
;
7469 TempCCk
= rtl8192_QueryBBReg(dev
, rCCK0_TxFilter1
, bMaskByte2
);
7471 for(i
=0 ; i
<CCKTxBBGainTableLength
; i
++)
7474 if(TempCCk
== priv
->cck_txbbgain_table
[i
].ccktxbb_valuearray
[0])
7476 priv
->cck_present_attentuation_20Mdefault
=(u8
) i
;
7480 priv
->cck_present_attentuation_40Mdefault
= 0;
7481 priv
->cck_present_attentuation_difference
= 0;
7482 priv
->cck_present_attentuation
= priv
->cck_present_attentuation_20Mdefault
;
7484 // pMgntInfo->bTXPowerTracking = FALSE;//TEMPLY DISABLE
7487 write_nic_byte(dev
, 0x87, 0x0);
7495 /* this configures registers for beacon tx and enables it via
7496 * rtl8192_beacon_tx_enable(). rtl8192_beacon_tx_disable() might
7497 * be used to stop beacon transmission
7500 void rtl8192_start_tx_beacon(struct net_device
*dev
)
7503 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
7505 DMESG("Enabling beacon TX");
7506 //write_nic_byte(dev, TX_CONF,0xe6);// TX_CONF
7507 //rtl8192_init_beacon(dev);
7508 //set_nic_txring(dev);
7509 // rtl8192_prepare_beacon(dev);
7510 rtl8192_irq_disable(dev
);
7511 // rtl8192_beacon_tx_enable(dev);
7512 rtl8192_set_mode(dev
,EPROM_CMD_CONFIG
);
7513 //write_nic_byte(dev,0x9d,0x20); //DMA Poll
7514 //write_nic_word(dev,0x7a,0);
7515 //write_nic_word(dev,0x7a,0x8000);
7518 word
= read_nic_word(dev
, BcnItv
);
7519 word
&= ~BcnItv_BcnItv
; // clear Bcn_Itv
7520 write_nic_word(dev
, BcnItv
, word
);
7522 write_nic_word(dev
, AtimWnd
,
7523 read_nic_word(dev
, AtimWnd
) &~ AtimWnd_AtimWnd
);
7525 word
= read_nic_word(dev
, BCN_INTR_ITV
);
7526 word
&= ~BCN_INTR_ITV_MASK
;
7528 //word |= priv->ieee80211->beacon_interval *
7529 // ((priv->txbeaconcount > 1)?(priv->txbeaconcount-1):1);
7530 // FIXME:FIXME check if correct ^^ worked with 0x3e8;
7532 write_nic_word(dev
, BCN_INTR_ITV
, word
);
7534 //write_nic_word(dev,0x2e,0xe002);
7535 //write_nic_dword(dev,0x30,0xb8c7832e);
7536 for(i
=0; i
<ETH_ALEN
; i
++)
7537 write_nic_byte(dev
, BSSID
+i
, priv
->ieee80211
->beacon_cell_ssid
[i
]);
7539 // rtl8192_update_msr(dev);
7542 //write_nic_byte(dev,CONFIG4,3); /* !!!!!!!!!! */
7544 rtl8192_set_mode(dev
, EPROM_CMD_NORMAL
);
7546 rtl8192_irq_enable(dev
);
7548 /* VV !!!!!!!!!! VV*/
7550 rtl8192_set_mode(dev,EPROM_CMD_CONFIG);
7551 write_nic_byte(dev,0x9d,0x00);
7552 rtl8192_set_mode(dev,EPROM_CMD_NORMAL);
7556 /***************************************************************************
7557 -------------------------------NET STUFF---------------------------
7558 ***************************************************************************/
7560 static struct net_device_stats
*rtl8192_stats(struct net_device
*dev
)
7562 struct r8192_priv
*priv
= ieee80211_priv(dev
);
7564 return &priv
->ieee80211
->stats
;
7568 HalTxCheckStuck819xUsb(
7569 struct net_device
*dev
7572 struct r8192_priv
*priv
= ieee80211_priv(dev
);
7573 u16 RegTxCounter
= read_nic_word(dev
, 0x128);
7574 bool bStuck
= FALSE
;
7575 RT_TRACE(COMP_RESET
,"%s():RegTxCounter is %d,TxCounter is %d\n",__FUNCTION__
,RegTxCounter
,priv
->TxCounter
);
7576 if(priv
->TxCounter
==RegTxCounter
)
7579 priv
->TxCounter
= RegTxCounter
;
7585 * <Assumption: RT_TX_SPINLOCK is acquired.>
7586 * First added: 2006.11.19 by emily
7589 TxCheckStuck(struct net_device
*dev
)
7591 struct r8192_priv
*priv
= ieee80211_priv(dev
);
7594 // u8 ResetThreshold;
7595 bool bCheckFwTxCnt
= false;
7596 //unsigned long flags;
7599 // Decide Stuch threshold according to current power save mode
7602 // RT_TRACE(COMP_RESET, " ==> TxCheckStuck()\n");
7603 // PlatformAcquireSpinLock(Adapter, RT_TX_SPINLOCK);
7604 // spin_lock_irqsave(&priv->ieee80211->lock,flags);
7605 for (QueueID
= 0; QueueID
<=BEACON_QUEUE
;QueueID
++)
7607 if(QueueID
== TXCMD_QUEUE
)
7610 if((skb_queue_len(&priv
->ieee80211
->skb_waitQ
[QueueID
]) == 0) && (skb_queue_len(&priv
->ieee80211
->skb_aggQ
[QueueID
]) == 0))
7614 bCheckFwTxCnt
= true;
7616 // PlatformReleaseSpinLock(Adapter, RT_TX_SPINLOCK);
7617 // spin_unlock_irqrestore(&priv->ieee80211->lock,flags);
7618 // RT_TRACE(COMP_RESET,"bCheckFwTxCnt is %d\n",bCheckFwTxCnt);
7622 if(HalTxCheckStuck819xUsb(dev
))
7624 RT_TRACE(COMP_RESET
, "TxCheckStuck(): Fw indicates no Tx condition! \n");
7625 return RESET_TYPE_SILENT
;
7629 return RESET_TYPE_NORESET
;
7633 HalRxCheckStuck819xUsb(struct net_device
*dev
)
7635 u16 RegRxCounter
= read_nic_word(dev
, 0x130);
7636 struct r8192_priv
*priv
= ieee80211_priv(dev
);
7637 bool bStuck
= FALSE
;
7641 static u8 rx_chk_cnt
= 0;
7642 RT_TRACE(COMP_RESET
,"%s(): RegRxCounter is %d,RxCounter is %d\n",__FUNCTION__
,RegRxCounter
,priv
->RxCounter
);
7643 // If rssi is small, we should check rx for long time because of bad rx.
7644 // or maybe it will continuous silent reset every 2 seconds.
7646 if(priv
->undecorated_smoothed_pwdb
>= (RateAdaptiveTH_High
+5))
7648 rx_chk_cnt
= 0; //high rssi, check rx stuck right now.
7650 else if(priv
->undecorated_smoothed_pwdb
< (RateAdaptiveTH_High
+5) &&
7651 ((priv
->CurrentChannelBW
!=HT_CHANNEL_WIDTH_20
&&priv
->undecorated_smoothed_pwdb
>=RateAdaptiveTH_Low_40M
) ||
7652 (priv
->CurrentChannelBW
==HT_CHANNEL_WIDTH_20
&&priv
->undecorated_smoothed_pwdb
>=RateAdaptiveTH_Low_20M
)) )
7663 else if(((priv
->CurrentChannelBW
!=HT_CHANNEL_WIDTH_20
&&priv
->undecorated_smoothed_pwdb
<RateAdaptiveTH_Low_40M
) ||
7664 (priv
->CurrentChannelBW
==HT_CHANNEL_WIDTH_20
&&priv
->undecorated_smoothed_pwdb
<RateAdaptiveTH_Low_20M
)) &&
7665 priv
->undecorated_smoothed_pwdb
>= VeryLowRSSI
)
7669 //DbgPrint("RSSI < %d && RSSI >= %d, no check this time \n", RateAdaptiveTH_Low, VeryLowRSSI);
7675 //DbgPrint("RSSI < %d && RSSI >= %d, check this time \n", RateAdaptiveTH_Low, VeryLowRSSI);
7682 //DbgPrint("RSSI <= %d, no check this time \n", VeryLowRSSI);
7688 //DbgPrint("RSSI <= %d, check this time \n", VeryLowRSSI);
7693 if(priv
->RxCounter
==RegRxCounter
)
7696 priv
->RxCounter
= RegRxCounter
;
7702 RxCheckStuck(struct net_device
*dev
)
7704 struct r8192_priv
*priv
= ieee80211_priv(dev
);
7706 bool bRxCheck
= FALSE
;
7708 // RT_TRACE(COMP_RESET," ==> RxCheckStuck()\n");
7709 //PlatformAcquireSpinLock(Adapter, RT_RX_SPINLOCK);
7711 if(priv
->IrpPendingCount
> 1)
7713 //PlatformReleaseSpinLock(Adapter, RT_RX_SPINLOCK);
7715 // RT_TRACE(COMP_RESET,"bRxCheck is %d \n",bRxCheck);
7718 if(HalRxCheckStuck819xUsb(dev
))
7720 RT_TRACE(COMP_RESET
, "RxStuck Condition\n");
7721 return RESET_TYPE_SILENT
;
7724 return RESET_TYPE_NORESET
;
7729 * This function is called by Checkforhang to check whether we should ask OS to reset driver
7731 * \param pAdapter The adapter context for this miniport
7733 * Note:NIC with USB interface sholud not call this function because we cannot scan descriptor
7734 * to judge whether there is tx stuck.
7735 * Note: This function may be required to be rewrite for Vista OS.
7736 * <<<Assumption: Tx spinlock has been acquired >>>
7738 * 8185 and 8185b does not implement this function. This is added by Emily at 2006.11.24
7741 rtl819x_ifcheck_resetornot(struct net_device
*dev
)
7743 struct r8192_priv
*priv
= ieee80211_priv(dev
);
7744 RESET_TYPE TxResetType
= RESET_TYPE_NORESET
;
7745 RESET_TYPE RxResetType
= RESET_TYPE_NORESET
;
7746 RT_RF_POWER_STATE rfState
;
7748 return RESET_TYPE_NORESET
;
7750 rfState
= priv
->ieee80211
->eRFPowerState
;
7752 TxResetType
= TxCheckStuck(dev
);
7754 if( rfState
!= eRfOff
||
7755 /*ADAPTER_TEST_STATUS_FLAG(Adapter, ADAPTER_STATUS_FW_DOWNLOAD_FAILURE)) &&*/
7756 (priv
->ieee80211
->iw_mode
!= IW_MODE_ADHOC
))
7758 // If driver is in the status of firmware download failure , driver skips RF initialization and RF is
7759 // in turned off state. Driver should check whether Rx stuck and do silent reset. And
7760 // if driver is in firmware download failure status, driver should initialize RF in the following
7761 // silent reset procedure Emily, 2008.01.21
7763 // Driver should not check RX stuck in IBSS mode because it is required to
7764 // set Check BSSID in order to send beacon, however, if check BSSID is
7765 // set, STA cannot hear any packet a all. Emily, 2008.04.12
7766 RxResetType
= RxCheckStuck(dev
);
7769 if(TxResetType
==RESET_TYPE_NORMAL
|| RxResetType
==RESET_TYPE_NORMAL
)
7770 return RESET_TYPE_NORMAL
;
7771 else if(TxResetType
==RESET_TYPE_SILENT
|| RxResetType
==RESET_TYPE_SILENT
){
7772 RT_TRACE(COMP_RESET
,"%s():silent reset\n",__FUNCTION__
);
7773 return RESET_TYPE_SILENT
;
7776 return RESET_TYPE_NORESET
;
7780 void rtl8192_cancel_deferred_work(struct r8192_priv
* priv
);
7781 int _rtl8192_up(struct net_device
*dev
);
7782 int rtl8192_close(struct net_device
*dev
);
7787 CamRestoreAllEntry( struct net_device
*dev
)
7790 struct r8192_priv
*priv
= ieee80211_priv(dev
);
7791 u8
* MacAddr
= priv
->ieee80211
->current_network
.bssid
;
7793 static u8 CAM_CONST_ADDR
[4][6] = {
7794 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
7795 {0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
7796 {0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
7797 {0x00, 0x00, 0x00, 0x00, 0x00, 0x03}};
7798 static u8 CAM_CONST_BROAD
[] =
7799 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
7801 RT_TRACE(COMP_SEC
, "CamRestoreAllEntry: \n");
7804 if ((priv
->ieee80211
->pairwise_key_type
== KEY_TYPE_WEP40
)||
7805 (priv
->ieee80211
->pairwise_key_type
== KEY_TYPE_WEP104
))
7808 for(EntryId
=0; EntryId
<4; EntryId
++)
7811 MacAddr
= CAM_CONST_ADDR
[EntryId
];
7815 priv
->ieee80211
->pairwise_key_type
,
7823 else if(priv
->ieee80211
->pairwise_key_type
== KEY_TYPE_TKIP
)
7827 if(priv
->ieee80211
->iw_mode
== IW_MODE_ADHOC
)
7831 priv
->ieee80211
->pairwise_key_type
,
7839 priv
->ieee80211
->pairwise_key_type
,
7845 else if(priv
->ieee80211
->pairwise_key_type
== KEY_TYPE_CCMP
)
7849 if(priv
->ieee80211
->iw_mode
== IW_MODE_ADHOC
)
7853 priv
->ieee80211
->pairwise_key_type
,
7861 priv
->ieee80211
->pairwise_key_type
,
7870 if(priv
->ieee80211
->group_key_type
== KEY_TYPE_TKIP
)
7872 MacAddr
= CAM_CONST_BROAD
;
7873 for(EntryId
=1 ; EntryId
<4 ; EntryId
++)
7879 priv
->ieee80211
->group_key_type
,
7885 if(priv
->ieee80211
->iw_mode
== IW_MODE_ADHOC
)
7889 priv
->ieee80211
->group_key_type
,
7894 else if(priv
->ieee80211
->group_key_type
== KEY_TYPE_CCMP
)
7896 MacAddr
= CAM_CONST_BROAD
;
7897 for(EntryId
=1; EntryId
<4 ; EntryId
++)
7903 priv
->ieee80211
->group_key_type
,
7910 if(priv
->ieee80211
->iw_mode
== IW_MODE_ADHOC
)
7914 priv
->ieee80211
->group_key_type
,
7920 //////////////////////////////////////////////////////////////
7921 // This function is used to fix Tx/Rx stop bug temporarily.
7922 // This function will do "system reset" to NIC when Tx or Rx is stuck.
7923 // The method checking Tx/Rx stuck of this function is supported by FW,
7924 // which reports Tx and Rx counter to register 0x128 and 0x130.
7925 //////////////////////////////////////////////////////////////
7927 rtl819x_ifsilentreset(struct net_device
*dev
)
7929 //OCTET_STRING asocpdu;
7930 struct r8192_priv
*priv
= ieee80211_priv(dev
);
7932 int reset_status
= 0;
7933 struct ieee80211_device
*ieee
= priv
->ieee80211
;
7936 // 2007.07.20. If we need to check CCK stop, please uncomment this line.
7937 //bStuck = Adapter->HalFunc.CheckHWStopHandler(Adapter);
7939 if(priv
->ResetProgress
==RESET_TYPE_NORESET
)
7943 RT_TRACE(COMP_RESET
,"=========>Reset progress!! \n");
7945 // Set the variable for reset.
7946 priv
->ResetProgress
= RESET_TYPE_SILENT
;
7947 // rtl8192_close(dev);
7949 down(&priv
->wx_sem
);
7952 RT_TRACE(COMP_ERR
,"%s():the driver is not up! return\n",__FUNCTION__
);
7957 RT_TRACE(COMP_RESET
,"%s():======>start to down the driver\n",__FUNCTION__
);
7958 // if(!netif_queue_stopped(dev))
7959 // netif_stop_queue(dev);
7961 rtl8192_rtx_disable(dev
);
7962 rtl8192_cancel_deferred_work(priv
);
7964 del_timer_sync(&priv
->watch_dog_timer
);
7966 ieee
->sync_scan_hurryup
= 1;
7967 if(ieee
->state
== IEEE80211_LINKED
)
7969 down(&ieee
->wx_sem
);
7970 printk("ieee->state is IEEE80211_LINKED\n");
7971 ieee80211_stop_send_beacons(priv
->ieee80211
);
7972 del_timer_sync(&ieee
->associate_timer
);
7973 cancel_delayed_work(&ieee
->associate_retry_wq
);
7974 ieee80211_stop_scan(ieee
);
7975 netif_carrier_off(dev
);
7979 printk("ieee->state is NOT LINKED\n");
7980 ieee80211_softmac_stop_protocol(priv
->ieee80211
); }
7982 RT_TRACE(COMP_RESET
,"%s():<==========down process is finished\n",__FUNCTION__
);
7983 //rtl8192_irq_disable(dev);
7984 RT_TRACE(COMP_RESET
,"%s():===========>start to up the driver\n",__FUNCTION__
);
7985 reset_status
= _rtl8192_up(dev
);
7987 RT_TRACE(COMP_RESET
,"%s():<===========up process is finished\n",__FUNCTION__
);
7988 if(reset_status
== -EAGAIN
)
7997 RT_TRACE(COMP_ERR
," ERR!!! %s(): Reset Failed!!\n", __FUNCTION__
);
8001 ieee
->is_silent_reset
= 1;
8003 EnableHWSecurityConfig8192(dev
);
8005 if(ieee
->state
== IEEE80211_LINKED
&& ieee
->iw_mode
== IW_MODE_INFRA
)
8007 ieee
->set_chan(ieee
->dev
, ieee
->current_network
.channel
);
8010 queue_work(ieee
->wq
, &ieee
->associate_complete_wq
);
8014 else if(ieee
->state
== IEEE80211_LINKED
&& ieee
->iw_mode
== IW_MODE_ADHOC
)
8016 ieee
->set_chan(ieee
->dev
, ieee
->current_network
.channel
);
8017 ieee
->link_change(ieee
->dev
);
8019 // notify_wx_assoc_event(ieee);
8021 ieee80211_start_send_beacons(ieee
);
8023 if (ieee
->data_hard_resume
)
8024 ieee
->data_hard_resume(ieee
->dev
);
8025 netif_carrier_on(ieee
->dev
);
8029 CamRestoreAllEntry(dev
);
8031 priv
->ResetProgress
= RESET_TYPE_NORESET
;
8032 priv
->reset_count
++;
8034 priv
->bForcedSilentReset
=false;
8035 priv
->bResetInProgress
= false;
8037 // For test --> force write UFWP.
8038 write_nic_byte(dev
, UFWP
, 1);
8039 RT_TRACE(COMP_RESET
, "Reset finished!! ====>[%d]\n", priv
->reset_count
);
8044 void CAM_read_entry(
8045 struct net_device
*dev
,
8049 u32 target_command
=0;
8050 u32 target_content
=0;
8054 // printk("=======>start read CAM\n");
8055 for(entry_i
=0;entry_i
<CAM_CONTENT_COUNT
;entry_i
++)
8057 // polling bit, and No Write enable, and address
8058 target_command
= entry_i
+CAM_CONTENT_COUNT
*iIndex
;
8059 target_command
= target_command
| BIT31
;
8061 //Check polling bit is clear
8066 ulStatus
= read_nic_dword(dev
, RWCAM
);
8067 if(ulStatus
& BIT31
){
8075 write_nic_dword(dev
, RWCAM
, target_command
);
8076 RT_TRACE(COMP_SEC
,"CAM_read_entry(): WRITE A0: %x \n",target_command
);
8077 // printk("CAM_read_entry(): WRITE A0: %lx \n",target_command);
8078 target_content
= read_nic_dword(dev
, RCAMO
);
8079 RT_TRACE(COMP_SEC
, "CAM_read_entry(): WRITE A8: %x \n",target_content
);
8080 // printk("CAM_read_entry(): WRITE A8: %lx \n",target_content);
8085 void rtl819x_update_rxcounts(
8086 struct r8192_priv
*priv
,
8095 *TotalRxDataNum
= 0;
8097 SlotIndex
= (priv
->ieee80211
->LinkDetectInfo
.SlotIndex
++)%(priv
->ieee80211
->LinkDetectInfo
.SlotNum
);
8098 priv
->ieee80211
->LinkDetectInfo
.RxBcnNum
[SlotIndex
] = priv
->ieee80211
->LinkDetectInfo
.NumRecvBcnInPeriod
;
8099 priv
->ieee80211
->LinkDetectInfo
.RxDataNum
[SlotIndex
] = priv
->ieee80211
->LinkDetectInfo
.NumRecvDataInPeriod
;
8100 for( i
=0; i
<priv
->ieee80211
->LinkDetectInfo
.SlotNum
; i
++ ){
8101 *TotalRxBcnNum
+= priv
->ieee80211
->LinkDetectInfo
.RxBcnNum
[i
];
8102 *TotalRxDataNum
+= priv
->ieee80211
->LinkDetectInfo
.RxDataNum
[i
];
8106 extern void rtl819x_watchdog_wqcallback(struct work_struct
*work
)
8108 struct delayed_work
*dwork
= container_of(work
,struct delayed_work
,work
);
8109 struct r8192_priv
*priv
= container_of(dwork
,struct r8192_priv
,watch_dog_wq
);
8110 struct net_device
*dev
= priv
->ieee80211
->dev
;
8111 struct ieee80211_device
* ieee
= priv
->ieee80211
;
8112 RESET_TYPE ResetType
= RESET_TYPE_NORESET
;
8113 static u8 check_reset_cnt
=0;
8114 bool bBusyTraffic
= false;
8118 hal_dm_watchdog(dev
);
8120 {//to get busy traffic condition
8121 if(ieee
->state
== IEEE80211_LINKED
)
8123 //windows mod 666 to 100.
8124 //if( ieee->LinkDetectInfo.NumRxOkInPeriod> 666 ||
8125 // ieee->LinkDetectInfo.NumTxOkInPeriod> 666 ) {
8126 if( ieee
->LinkDetectInfo
.NumRxOkInPeriod
> 100 ||
8127 ieee
->LinkDetectInfo
.NumTxOkInPeriod
> 100 ) {
8128 bBusyTraffic
= true;
8130 ieee
->LinkDetectInfo
.NumRxOkInPeriod
= 0;
8131 ieee
->LinkDetectInfo
.NumTxOkInPeriod
= 0;
8132 ieee
->LinkDetectInfo
.bBusyTraffic
= bBusyTraffic
;
8135 //added by amy for AP roaming
8137 if(priv
->ieee80211
->state
== IEEE80211_LINKED
&& priv
->ieee80211
->iw_mode
== IW_MODE_INFRA
)
8139 u32 TotalRxBcnNum
= 0;
8140 u32 TotalRxDataNum
= 0;
8142 rtl819x_update_rxcounts(priv
, &TotalRxBcnNum
, &TotalRxDataNum
);
8143 if((TotalRxBcnNum
+TotalRxDataNum
) == 0)
8146 if(rfState
== eRfOff
)
8147 RT_TRACE(COMP_ERR
,"========>%s()\n",__FUNCTION__
);
8149 printk("===>%s(): AP is power off,connect another one\n",__FUNCTION__
);
8150 // Dot11d_Reset(dev);
8151 priv
->ieee80211
->state
= IEEE80211_ASSOCIATING
;
8152 notify_wx_assoc_event(priv
->ieee80211
);
8153 RemovePeerTS(priv
->ieee80211
,priv
->ieee80211
->current_network
.bssid
);
8154 ieee
->is_roaming
= true;
8155 priv
->ieee80211
->link_change(dev
);
8156 queue_work(priv
->ieee80211
->wq
, &priv
->ieee80211
->associate_procedure_wq
);
8159 priv
->ieee80211
->LinkDetectInfo
.NumRecvBcnInPeriod
=0;
8160 priv
->ieee80211
->LinkDetectInfo
.NumRecvDataInPeriod
=0;
8162 // CAM_read_entry(dev,4);
8163 //check if reset the driver
8164 if(check_reset_cnt
++ >= 3 && !ieee
->is_roaming
)
8166 ResetType
= rtl819x_ifcheck_resetornot(dev
);
8167 check_reset_cnt
= 3;
8168 //DbgPrint("Start to check silent reset\n");
8170 // RT_TRACE(COMP_RESET,"%s():priv->force_reset is %d,priv->ResetProgress is %d, priv->bForcedSilentReset is %d,priv->bDisableNormalResetCheck is %d,ResetType is %d\n",__FUNCTION__,priv->force_reset,priv->ResetProgress,priv->bForcedSilentReset,priv->bDisableNormalResetCheck,ResetType);
8172 if( (priv
->force_reset
) || (priv
->ResetProgress
==RESET_TYPE_NORESET
&&
8173 (priv
->bForcedSilentReset
||
8174 (!priv
->bDisableNormalResetCheck
&& ResetType
==RESET_TYPE_SILENT
)))) // This is control by OID set in Pomelo
8176 RT_TRACE(COMP_RESET
,"%s():priv->force_reset is %d,priv->ResetProgress is %d, priv->bForcedSilentReset is %d,priv->bDisableNormalResetCheck is %d,ResetType is %d\n",__FUNCTION__
,priv
->force_reset
,priv
->ResetProgress
,priv
->bForcedSilentReset
,priv
->bDisableNormalResetCheck
,ResetType
);
8177 rtl819x_ifsilentreset(dev
);
8180 priv
->force_reset
= false;
8181 priv
->bForcedSilentReset
= false;
8182 priv
->bResetInProgress
= false;
8183 RT_TRACE(COMP_TRACE
, " <==RtUsbCheckForHangWorkItemCallback()\n");
8187 void watch_dog_timer_callback(unsigned long data
)
8189 struct r8192_priv
*priv
= ieee80211_priv((struct net_device
*) data
);
8190 //printk("===============>watch_dog timer\n");
8191 queue_delayed_work(priv
->priv_wq
,&priv
->watch_dog_wq
, 0);
8192 mod_timer(&priv
->watch_dog_timer
, jiffies
+ MSECS(IEEE80211_WATCH_DOG_TIME
));
8194 priv
->watch_dog_timer
.expires
= jiffies
+ MSECS(IEEE80211_WATCH_DOG_TIME
);
8195 add_timer(&priv
->watch_dog_timer
);
8198 int _rtl8192_up(struct net_device
*dev
)
8200 struct r8192_priv
*priv
= ieee80211_priv(dev
);
8202 int init_status
= 0;
8204 priv
->ieee80211
->ieee_up
=1;
8205 RT_TRACE(COMP_INIT
, "Bringing up iface");
8206 init_status
= priv
->ops
->rtl819x_adapter_start(dev
);
8209 RT_TRACE(COMP_ERR
,"ERR!!! %s(): initialization is failed!\n", __FUNCTION__
);
8210 priv
->up
=priv
->ieee80211
->ieee_up
= 0;
8213 RT_TRACE(COMP_INIT
, "start adapter finished\n");
8214 rtl8192_rx_enable(dev
);
8215 // rtl8192_tx_enable(dev);
8216 if(priv
->ieee80211
->state
!= IEEE80211_LINKED
)
8217 ieee80211_softmac_start_protocol(priv
->ieee80211
);
8218 ieee80211_reset_queue(priv
->ieee80211
);
8219 watch_dog_timer_callback((unsigned long) dev
);
8220 if(!netif_queue_stopped(dev
))
8221 netif_start_queue(dev
);
8223 netif_wake_queue(dev
);
8226 * Make sure that drop_unencrypted is initialized as "0"
8227 * No packets will be sent in non-security mode if we had set drop_unencrypted.
8228 * ex, After kill wpa_supplicant process, make the driver up again.
8229 * drop_unencrypted remains as "1", which is set by wpa_supplicant. 2008/12/04.john
8231 priv
->ieee80211
->drop_unencrypted
= 0;
8237 int rtl8192_open(struct net_device
*dev
)
8239 struct r8192_priv
*priv
= ieee80211_priv(dev
);
8241 down(&priv
->wx_sem
);
8242 ret
= rtl8192_up(dev
);
8249 int rtl8192_up(struct net_device
*dev
)
8251 struct r8192_priv
*priv
= ieee80211_priv(dev
);
8253 if (priv
->up
== 1) return -1;
8255 return _rtl8192_up(dev
);
8259 int rtl8192_close(struct net_device
*dev
)
8261 struct r8192_priv
*priv
= ieee80211_priv(dev
);
8264 down(&priv
->wx_sem
);
8266 ret
= rtl8192_down(dev
);
8274 int rtl8192_down(struct net_device
*dev
)
8276 struct r8192_priv
*priv
= ieee80211_priv(dev
);
8279 if (priv
->up
== 0) return -1;
8282 priv
->ieee80211
->ieee_up
= 0;
8283 RT_TRACE(COMP_DOWN
, "==========>%s()\n", __FUNCTION__
);
8285 if (!netif_queue_stopped(dev
))
8286 netif_stop_queue(dev
);
8288 rtl8192_rtx_disable(dev
);
8289 //rtl8192_irq_disable(dev);
8291 /* Tx related queue release */
8292 for(i
= 0; i
< MAX_QUEUE_SIZE
; i
++) {
8293 skb_queue_purge(&priv
->ieee80211
->skb_waitQ
[i
]);
8295 for(i
= 0; i
< MAX_QUEUE_SIZE
; i
++) {
8296 skb_queue_purge(&priv
->ieee80211
->skb_aggQ
[i
]);
8299 for(i
= 0; i
< MAX_QUEUE_SIZE
; i
++) {
8300 skb_queue_purge(&priv
->ieee80211
->skb_drv_aggQ
[i
]);
8303 //as cancel_delayed_work will del work->timer, so if work is not definedas struct delayed_work, it will corrupt
8304 // flush_scheduled_work();
8305 rtl8192_cancel_deferred_work(priv
);
8307 del_timer_sync(&priv
->watch_dog_timer
);
8310 ieee80211_softmac_stop_protocol(priv
->ieee80211
);
8311 memset(&priv
->ieee80211
->current_network
, 0 , offsetof(struct ieee80211_network
, list
));
8312 RT_TRACE(COMP_DOWN
, "<==========%s()\n", __FUNCTION__
);
8318 void rtl8192_commit(struct net_device
*dev
)
8320 struct r8192_priv
*priv
= ieee80211_priv(dev
);
8321 int reset_status
= 0;
8322 //u8 reset_times = 0;
8323 if (priv
->up
== 0) return ;
8326 rtl8192_cancel_deferred_work(priv
);
8327 del_timer_sync(&priv
->watch_dog_timer
);
8328 //cancel_delayed_work(&priv->SwChnlWorkItem);
8330 ieee80211_softmac_stop_protocol(priv
->ieee80211
);
8332 //rtl8192_irq_disable(dev);
8333 rtl8192_rtx_disable(dev
);
8334 reset_status
= _rtl8192_up(dev
);
8339 void rtl8192_restart(struct net_device *dev)
8341 struct r8192_priv *priv = ieee80211_priv(dev);
8343 void rtl8192_restart(struct work_struct
*work
)
8345 struct r8192_priv
*priv
= container_of(work
, struct r8192_priv
, reset_wq
);
8346 struct net_device
*dev
= priv
->ieee80211
->dev
;
8348 down(&priv
->wx_sem
);
8350 rtl8192_commit(dev
);
8355 static void r8192_set_multicast(struct net_device
*dev
)
8357 struct r8192_priv
*priv
= ieee80211_priv(dev
);
8360 //down(&priv->wx_sem);
8364 promisc
= (dev
->flags
& IFF_PROMISC
) ? 1:0;
8366 if (promisc
!= priv
->promisc
)
8367 // rtl8192_commit(dev);
8369 priv
->promisc
= promisc
;
8371 //schedule_work(&priv->reset_wq);
8372 //up(&priv->wx_sem);
8376 int r8192_set_mac_adr(struct net_device
*dev
, void *mac
)
8378 struct r8192_priv
*priv
= ieee80211_priv(dev
);
8379 struct sockaddr
*addr
= mac
;
8381 down(&priv
->wx_sem
);
8383 memcpy(dev
->dev_addr
, addr
->sa_data
, ETH_ALEN
);
8385 schedule_work(&priv
->reset_wq
);
8392 /* based on ipw2200 driver */
8393 int rtl8192_ioctl(struct net_device
*dev
, struct ifreq
*rq
, int cmd
)
8395 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
8396 struct iwreq
*wrq
= (struct iwreq
*)rq
;
8398 struct ieee80211_device
*ieee
= priv
->ieee80211
;
8400 u8 broadcast_addr
[6] = {0xff,0xff,0xff,0xff,0xff,0xff};
8401 u8 zero_addr
[6] = {0};
8402 struct iw_point
*p
= &wrq
->u
.data
;
8403 struct ieee_param
*ipw
= NULL
;//(struct ieee_param *)wrq->u.data.pointer;
8405 down(&priv
->wx_sem
);
8408 if (p
->length
< sizeof(struct ieee_param
) || !p
->pointer
){
8413 ipw
= (struct ieee_param
*)kmalloc(p
->length
, GFP_KERNEL
);
8418 if (copy_from_user(ipw
, p
->pointer
, p
->length
)) {
8425 case RTL_IOCTL_WPA_SUPPLICANT
:
8426 //parse here for HW security
8427 if (ipw
->cmd
== IEEE_CMD_SET_ENCRYPTION
)
8429 if (ipw
->u
.crypt
.set_tx
)
8431 if (strcmp(ipw
->u
.crypt
.alg
, "CCMP") == 0)
8432 ieee
->pairwise_key_type
= KEY_TYPE_CCMP
;
8433 else if (strcmp(ipw
->u
.crypt
.alg
, "TKIP") == 0)
8434 ieee
->pairwise_key_type
= KEY_TYPE_TKIP
;
8435 else if (strcmp(ipw
->u
.crypt
.alg
, "WEP") == 0)
8437 if (ipw
->u
.crypt
.key_len
== 13)
8438 ieee
->pairwise_key_type
= KEY_TYPE_WEP104
;
8439 else if (ipw
->u
.crypt
.key_len
== 5)
8440 ieee
->pairwise_key_type
= KEY_TYPE_WEP40
;
8443 ieee
->pairwise_key_type
= KEY_TYPE_NA
;
8445 if (ieee
->pairwise_key_type
)
8447 // FIXME:these two lines below just to fix ipw interface bug, that is, it will never set mode down to driver. So treat it as ADHOC mode, if no association procedure. WB. 2009.02.04
8448 if (memcmp(ieee
->ap_mac_addr
, zero_addr
, 6) == 0)
8449 ieee
->iw_mode
= IW_MODE_ADHOC
;
8450 memcpy((u8
*)key
, ipw
->u
.crypt
.key
, 16);
8451 EnableHWSecurityConfig8192(dev
);
8452 //we fill both index entry and 4th entry for pairwise key as in IPW interface, adhoc will only get here, so we need index entry for its default key serching!
8454 setKey(dev
, 4, ipw
->u
.crypt
.idx
, ieee
->pairwise_key_type
, (u8
*)ieee
->ap_mac_addr
, 0, key
);
8455 if (ieee
->iw_mode
== IW_MODE_ADHOC
)
8456 setKey(dev
, ipw
->u
.crypt
.idx
, ipw
->u
.crypt
.idx
, ieee
->pairwise_key_type
, (u8
*)ieee
->ap_mac_addr
, 0, key
);
8459 else //if (ipw->u.crypt.idx) //group key use idx > 0
8461 memcpy((u8
*)key
, ipw
->u
.crypt
.key
, 16);
8462 if (strcmp(ipw
->u
.crypt
.alg
, "CCMP") == 0)
8463 ieee
->group_key_type
= KEY_TYPE_CCMP
;
8464 else if (strcmp(ipw
->u
.crypt
.alg
, "TKIP") == 0)
8465 ieee
->group_key_type
= KEY_TYPE_TKIP
;
8466 else if (strcmp(ipw
->u
.crypt
.alg
, "WEP") == 0)
8468 if (ipw
->u
.crypt
.key_len
== 13)
8469 ieee
->group_key_type
= KEY_TYPE_WEP104
;
8470 else if (ipw
->u
.crypt
.key_len
== 5)
8471 ieee
->group_key_type
= KEY_TYPE_WEP40
;
8474 ieee
->group_key_type
= KEY_TYPE_NA
;
8476 if (ieee
->group_key_type
)
8480 ipw
->u
.crypt
.idx
, //KeyIndex
8481 ieee
->group_key_type
, //KeyType
8482 broadcast_addr
, //MacAddr
8488 #ifdef JOHN_HWSEC_DEBUG
8490 printk("@@ wrq->u pointer = ");
8491 for(i
=0;i
<wrq
->u
.data
.length
;i
++){
8492 if(i
%10==0) printk("\n");
8493 printk( "%8x|", ((u32
*)wrq
->u
.data
.pointer
)[i
] );
8496 #endif /*JOHN_HWSEC_DEBUG*/
8497 ret
= ieee80211_wpa_supplicant_ioctl(priv
->ieee80211
, &wrq
->u
.data
);
8512 u8
rtl8192SU_HwRateToMRate(bool bIsHT
, u8 rate
,bool bFirstAMPDU
)
8524 case DESC92S_RATE1M
: ret_rate
= MGN_1M
; break;
8525 case DESC92S_RATE2M
: ret_rate
= MGN_2M
; break;
8526 case DESC92S_RATE5_5M
: ret_rate
= MGN_5_5M
; break;
8527 case DESC92S_RATE11M
: ret_rate
= MGN_11M
; break;
8528 case DESC92S_RATE6M
: ret_rate
= MGN_6M
; break;
8529 case DESC92S_RATE9M
: ret_rate
= MGN_9M
; break;
8530 case DESC92S_RATE12M
: ret_rate
= MGN_12M
; break;
8531 case DESC92S_RATE18M
: ret_rate
= MGN_18M
; break;
8532 case DESC92S_RATE24M
: ret_rate
= MGN_24M
; break;
8533 case DESC92S_RATE36M
: ret_rate
= MGN_36M
; break;
8534 case DESC92S_RATE48M
: ret_rate
= MGN_48M
; break;
8535 case DESC92S_RATE54M
: ret_rate
= MGN_54M
; break;
8538 RT_TRACE(COMP_RECV
, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n", rate
, bIsHT
);
8547 case DESC92S_RATEMCS0
: ret_rate
= MGN_MCS0
; break;
8548 case DESC92S_RATEMCS1
: ret_rate
= MGN_MCS1
; break;
8549 case DESC92S_RATEMCS2
: ret_rate
= MGN_MCS2
; break;
8550 case DESC92S_RATEMCS3
: ret_rate
= MGN_MCS3
; break;
8551 case DESC92S_RATEMCS4
: ret_rate
= MGN_MCS4
; break;
8552 case DESC92S_RATEMCS5
: ret_rate
= MGN_MCS5
; break;
8553 case DESC92S_RATEMCS6
: ret_rate
= MGN_MCS6
; break;
8554 case DESC92S_RATEMCS7
: ret_rate
= MGN_MCS7
; break;
8555 case DESC92S_RATEMCS8
: ret_rate
= MGN_MCS8
; break;
8556 case DESC92S_RATEMCS9
: ret_rate
= MGN_MCS9
; break;
8557 case DESC92S_RATEMCS10
: ret_rate
= MGN_MCS10
; break;
8558 case DESC92S_RATEMCS11
: ret_rate
= MGN_MCS11
; break;
8559 case DESC92S_RATEMCS12
: ret_rate
= MGN_MCS12
; break;
8560 case DESC92S_RATEMCS13
: ret_rate
= MGN_MCS13
; break;
8561 case DESC92S_RATEMCS14
: ret_rate
= MGN_MCS14
; break;
8562 case DESC92S_RATEMCS15
: ret_rate
= MGN_MCS15
; break;
8563 case DESC92S_RATEMCS32
: ret_rate
= (0x80|0x20); break;
8566 RT_TRACE(COMP_RECV
, "HwRateToMRate92S(): Non supported Rate [%x], bIsHT = %d!!!\n",rate
, bIsHT
);
8577 case DESC92S_RATE1M
: ret_rate
= MGN_1M
; break;
8578 case DESC92S_RATE2M
: ret_rate
= MGN_2M
; break;
8579 case DESC92S_RATE5_5M
: ret_rate
= MGN_5_5M
; break;
8580 case DESC92S_RATE11M
: ret_rate
= MGN_11M
; break;
8581 case DESC92S_RATE6M
: ret_rate
= MGN_6M
; break;
8582 case DESC92S_RATE9M
: ret_rate
= MGN_9M
; break;
8583 case DESC92S_RATE12M
: ret_rate
= MGN_12M
; break;
8584 case DESC92S_RATE18M
: ret_rate
= MGN_18M
; break;
8585 case DESC92S_RATE24M
: ret_rate
= MGN_24M
; break;
8586 case DESC92S_RATE36M
: ret_rate
= MGN_36M
; break;
8587 case DESC92S_RATE48M
: ret_rate
= MGN_48M
; break;
8588 case DESC92S_RATE54M
: ret_rate
= MGN_54M
; break;
8589 case DESC92S_RATEMCS0
: ret_rate
= MGN_MCS0
; break;
8590 case DESC92S_RATEMCS1
: ret_rate
= MGN_MCS1
; break;
8591 case DESC92S_RATEMCS2
: ret_rate
= MGN_MCS2
; break;
8592 case DESC92S_RATEMCS3
: ret_rate
= MGN_MCS3
; break;
8593 case DESC92S_RATEMCS4
: ret_rate
= MGN_MCS4
; break;
8594 case DESC92S_RATEMCS5
: ret_rate
= MGN_MCS5
; break;
8595 case DESC92S_RATEMCS6
: ret_rate
= MGN_MCS6
; break;
8596 case DESC92S_RATEMCS7
: ret_rate
= MGN_MCS7
; break;
8597 case DESC92S_RATEMCS8
: ret_rate
= MGN_MCS8
; break;
8598 case DESC92S_RATEMCS9
: ret_rate
= MGN_MCS9
; break;
8599 case DESC92S_RATEMCS10
: ret_rate
= MGN_MCS10
; break;
8600 case DESC92S_RATEMCS11
: ret_rate
= MGN_MCS11
; break;
8601 case DESC92S_RATEMCS12
: ret_rate
= MGN_MCS12
; break;
8602 case DESC92S_RATEMCS13
: ret_rate
= MGN_MCS13
; break;
8603 case DESC92S_RATEMCS14
: ret_rate
= MGN_MCS14
; break;
8604 case DESC92S_RATEMCS15
: ret_rate
= MGN_MCS15
; break;
8605 case DESC92S_RATEMCS32
: ret_rate
= (0x80|0x20); break;
8608 RT_TRACE(COMP_RECV
, "HwRateToMRate92S(): Non supported Rate [%x], bIsHT = %d!!!\n",rate
, bIsHT
);
8616 u8
HwRateToMRate90(bool bIsHT
, u8 rate
)
8622 case DESC90_RATE1M
: ret_rate
= MGN_1M
; break;
8623 case DESC90_RATE2M
: ret_rate
= MGN_2M
; break;
8624 case DESC90_RATE5_5M
: ret_rate
= MGN_5_5M
; break;
8625 case DESC90_RATE11M
: ret_rate
= MGN_11M
; break;
8626 case DESC90_RATE6M
: ret_rate
= MGN_6M
; break;
8627 case DESC90_RATE9M
: ret_rate
= MGN_9M
; break;
8628 case DESC90_RATE12M
: ret_rate
= MGN_12M
; break;
8629 case DESC90_RATE18M
: ret_rate
= MGN_18M
; break;
8630 case DESC90_RATE24M
: ret_rate
= MGN_24M
; break;
8631 case DESC90_RATE36M
: ret_rate
= MGN_36M
; break;
8632 case DESC90_RATE48M
: ret_rate
= MGN_48M
; break;
8633 case DESC90_RATE54M
: ret_rate
= MGN_54M
; break;
8637 RT_TRACE(COMP_RECV
, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n", rate
, bIsHT
);
8643 case DESC90_RATEMCS0
: ret_rate
= MGN_MCS0
; break;
8644 case DESC90_RATEMCS1
: ret_rate
= MGN_MCS1
; break;
8645 case DESC90_RATEMCS2
: ret_rate
= MGN_MCS2
; break;
8646 case DESC90_RATEMCS3
: ret_rate
= MGN_MCS3
; break;
8647 case DESC90_RATEMCS4
: ret_rate
= MGN_MCS4
; break;
8648 case DESC90_RATEMCS5
: ret_rate
= MGN_MCS5
; break;
8649 case DESC90_RATEMCS6
: ret_rate
= MGN_MCS6
; break;
8650 case DESC90_RATEMCS7
: ret_rate
= MGN_MCS7
; break;
8651 case DESC90_RATEMCS8
: ret_rate
= MGN_MCS8
; break;
8652 case DESC90_RATEMCS9
: ret_rate
= MGN_MCS9
; break;
8653 case DESC90_RATEMCS10
: ret_rate
= MGN_MCS10
; break;
8654 case DESC90_RATEMCS11
: ret_rate
= MGN_MCS11
; break;
8655 case DESC90_RATEMCS12
: ret_rate
= MGN_MCS12
; break;
8656 case DESC90_RATEMCS13
: ret_rate
= MGN_MCS13
; break;
8657 case DESC90_RATEMCS14
: ret_rate
= MGN_MCS14
; break;
8658 case DESC90_RATEMCS15
: ret_rate
= MGN_MCS15
; break;
8659 case DESC90_RATEMCS32
: ret_rate
= (0x80|0x20); break;
8663 RT_TRACE(COMP_RECV
, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n",rate
, bIsHT
);
8672 * Function: UpdateRxPktTimeStamp
8673 * Overview: Recored down the TSF time stamp when receiving a packet
8681 * (pRfd->Status.TimeStampHigh is updated)
8682 * (pRfd->Status.TimeStampLow is updated)
8686 void UpdateRxPktTimeStamp8190 (struct net_device
*dev
, struct ieee80211_rx_stats
*stats
)
8688 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
8690 if(stats
->bIsAMPDU
&& !stats
->bFirstMPDU
) {
8691 stats
->mac_time
[0] = priv
->LastRxDescTSFLow
;
8692 stats
->mac_time
[1] = priv
->LastRxDescTSFHigh
;
8694 priv
->LastRxDescTSFLow
= stats
->mac_time
[0];
8695 priv
->LastRxDescTSFHigh
= stats
->mac_time
[1];
8701 long rtl819x_translate_todbm(u8 signal_strength_index
)// 0-100 index.
8703 long signal_power
; // in dBm.
8705 // Translate to dBm (x=0.5y-95).
8706 signal_power
= (long)((signal_strength_index
+ 1) >> 1);
8709 return signal_power
;
8713 /* 2008/01/22 MH We can not delcare RSSI/EVM total value of sliding window to
8714 be a local static. Otherwise, it may increase when we return from S3/S4. The
8715 value will be kept in memory or disk. We must delcare the value in adapter
8716 and it will be reinitialized when return from S3/S4. */
8717 void rtl8192_process_phyinfo(struct r8192_priv
* priv
,u8
* buffer
, struct ieee80211_rx_stats
* pprevious_stats
, struct ieee80211_rx_stats
* pcurrent_stats
)
8719 bool bcheck
= false;
8721 u32 nspatial_stream
, tmp_val
;
8723 static u32 slide_rssi_index
=0, slide_rssi_statistics
=0;
8724 static u32 slide_evm_index
=0, slide_evm_statistics
=0;
8725 static u32 last_rssi
=0, last_evm
=0;
8727 static u32 slide_beacon_adc_pwdb_index
=0, slide_beacon_adc_pwdb_statistics
=0;
8728 static u32 last_beacon_adc_pwdb
=0;
8730 struct ieee80211_hdr_3addr
*hdr
;
8732 unsigned int frag
,seq
;
8733 hdr
= (struct ieee80211_hdr_3addr
*)buffer
;
8734 sc
= le16_to_cpu(hdr
->seq_ctl
);
8735 frag
= WLAN_GET_SEQ_FRAG(sc
);
8736 seq
= WLAN_GET_SEQ_SEQ(sc
);
8737 //cosa add 04292008 to record the sequence number
8738 pcurrent_stats
->Seq_Num
= seq
;
8740 // Check whether we should take the previous packet into accounting
8742 if(!pprevious_stats
->bIsAMPDU
)
8744 // if previous packet is not aggregated packet
8749 // if previous packet is aggregated packet, and current packet
8751 // (2) is the first packet of one AMPDU
8752 // that means the previous packet is the last one aggregated packet
8753 if( !pcurrent_stats
->bIsAMPDU
|| pcurrent_stats
->bFirstMPDU
)
8759 if(slide_rssi_statistics
++ >= PHY_RSSI_SLID_WIN_MAX
)
8761 slide_rssi_statistics
= PHY_RSSI_SLID_WIN_MAX
;
8762 last_rssi
= priv
->stats
.slide_signal_strength
[slide_rssi_index
];
8763 priv
->stats
.slide_rssi_total
-= last_rssi
;
8765 priv
->stats
.slide_rssi_total
+= pprevious_stats
->SignalStrength
;
8767 priv
->stats
.slide_signal_strength
[slide_rssi_index
++] = pprevious_stats
->SignalStrength
;
8768 if(slide_rssi_index
>= PHY_RSSI_SLID_WIN_MAX
)
8769 slide_rssi_index
= 0;
8771 // <1> Showed on UI for user, in dbm
8772 tmp_val
= priv
->stats
.slide_rssi_total
/slide_rssi_statistics
;
8773 priv
->stats
.signal_strength
= rtl819x_translate_todbm((u8
)tmp_val
);
8774 pcurrent_stats
->rssi
= priv
->stats
.signal_strength
;
8776 // If the previous packet does not match the criteria, neglect it
8778 if(!pprevious_stats
->bPacketMatchBSSID
)
8780 if(!pprevious_stats
->bToSelfBA
)
8788 //rtl8190_process_cck_rxpathsel(priv,pprevious_stats);//only rtl8190 supported
8793 priv
->stats
.num_process_phyinfo
++;
8795 /* record the general signal strength to the sliding window. */
8798 // <2> Showed on UI for engineering
8799 // hardware does not provide rssi information for each rf path in CCK
8800 if(!pprevious_stats
->bIsCCK
&& (pprevious_stats
->bPacketToSelf
|| pprevious_stats
->bToSelfBA
))
8802 for (rfpath
= RF90_PATH_A
; rfpath
< priv
->NumTotalRFPath
; rfpath
++)
8804 if (!rtl8192_phy_CheckIsLegalRFPath(priv
->ieee80211
->dev
, rfpath
))
8807 //Fixed by Jacken 2008-03-20
8808 if(priv
->stats
.rx_rssi_percentage
[rfpath
] == 0)
8810 priv
->stats
.rx_rssi_percentage
[rfpath
] = pprevious_stats
->RxMIMOSignalStrength
[rfpath
];
8811 //DbgPrint("MIMO RSSI initialize \n");
8813 if(pprevious_stats
->RxMIMOSignalStrength
[rfpath
] > priv
->stats
.rx_rssi_percentage
[rfpath
])
8815 priv
->stats
.rx_rssi_percentage
[rfpath
] =
8816 ( (priv
->stats
.rx_rssi_percentage
[rfpath
]*(Rx_Smooth_Factor
-1)) +
8817 (pprevious_stats
->RxMIMOSignalStrength
[rfpath
])) /(Rx_Smooth_Factor
);
8818 priv
->stats
.rx_rssi_percentage
[rfpath
] = priv
->stats
.rx_rssi_percentage
[rfpath
] + 1;
8822 priv
->stats
.rx_rssi_percentage
[rfpath
] =
8823 ( (priv
->stats
.rx_rssi_percentage
[rfpath
]*(Rx_Smooth_Factor
-1)) +
8824 (pprevious_stats
->RxMIMOSignalStrength
[rfpath
])) /(Rx_Smooth_Factor
);
8826 RT_TRACE(COMP_DBG
,"priv->stats.rx_rssi_percentage[rfPath] = %d \n" ,priv
->stats
.rx_rssi_percentage
[rfpath
] );
8834 RT_TRACE(COMP_RXDESC
, "Smooth %s PWDB = %d\n",
8835 pprevious_stats
->bIsCCK
? "CCK": "OFDM",
8836 pprevious_stats
->RxPWDBAll
);
8838 if(pprevious_stats
->bPacketBeacon
)
8840 /* record the beacon pwdb to the sliding window. */
8841 if(slide_beacon_adc_pwdb_statistics
++ >= PHY_Beacon_RSSI_SLID_WIN_MAX
)
8843 slide_beacon_adc_pwdb_statistics
= PHY_Beacon_RSSI_SLID_WIN_MAX
;
8844 last_beacon_adc_pwdb
= priv
->stats
.Slide_Beacon_pwdb
[slide_beacon_adc_pwdb_index
];
8845 priv
->stats
.Slide_Beacon_Total
-= last_beacon_adc_pwdb
;
8846 //DbgPrint("slide_beacon_adc_pwdb_index = %d, last_beacon_adc_pwdb = %d, Adapter->RxStats.Slide_Beacon_Total = %d\n",
8847 // slide_beacon_adc_pwdb_index, last_beacon_adc_pwdb, Adapter->RxStats.Slide_Beacon_Total);
8849 priv
->stats
.Slide_Beacon_Total
+= pprevious_stats
->RxPWDBAll
;
8850 priv
->stats
.Slide_Beacon_pwdb
[slide_beacon_adc_pwdb_index
] = pprevious_stats
->RxPWDBAll
;
8851 //DbgPrint("slide_beacon_adc_pwdb_index = %d, pPreviousRfd->Status.RxPWDBAll = %d\n", slide_beacon_adc_pwdb_index, pPreviousRfd->Status.RxPWDBAll);
8852 slide_beacon_adc_pwdb_index
++;
8853 if(slide_beacon_adc_pwdb_index
>= PHY_Beacon_RSSI_SLID_WIN_MAX
)
8854 slide_beacon_adc_pwdb_index
= 0;
8855 pprevious_stats
->RxPWDBAll
= priv
->stats
.Slide_Beacon_Total
/slide_beacon_adc_pwdb_statistics
;
8856 if(pprevious_stats
->RxPWDBAll
>= 3)
8857 pprevious_stats
->RxPWDBAll
-= 3;
8860 RT_TRACE(COMP_RXDESC
, "Smooth %s PWDB = %d\n",
8861 pprevious_stats
->bIsCCK
? "CCK": "OFDM",
8862 pprevious_stats
->RxPWDBAll
);
8865 if(pprevious_stats
->bPacketToSelf
|| pprevious_stats
->bPacketBeacon
|| pprevious_stats
->bToSelfBA
)
8867 if(priv
->undecorated_smoothed_pwdb
< 0) // initialize
8869 priv
->undecorated_smoothed_pwdb
= pprevious_stats
->RxPWDBAll
;
8870 //DbgPrint("First pwdb initialize \n");
8873 if(pprevious_stats
->RxPWDBAll
> (u32
)priv
->undecorated_smoothed_pwdb
)
8875 priv
->undecorated_smoothed_pwdb
=
8876 ( ((priv
->undecorated_smoothed_pwdb
)*(Rx_Smooth_Factor
-1)) +
8877 (pprevious_stats
->RxPWDBAll
)) /(Rx_Smooth_Factor
);
8878 priv
->undecorated_smoothed_pwdb
= priv
->undecorated_smoothed_pwdb
+ 1;
8882 priv
->undecorated_smoothed_pwdb
=
8883 ( ((priv
->undecorated_smoothed_pwdb
)*(Rx_Smooth_Factor
-1)) +
8884 (pprevious_stats
->RxPWDBAll
)) /(Rx_Smooth_Factor
);
8887 //Fixed by Jacken 2008-03-20
8888 if(pPreviousRfd
->Status
.RxPWDBAll
> (u32
)pHalData
->UndecoratedSmoothedPWDB
)
8890 pHalData
->UndecoratedSmoothedPWDB
=
8891 ( ((pHalData
->UndecoratedSmoothedPWDB
)* 5) + (pPreviousRfd
->Status
.RxPWDBAll
)) / 6;
8892 pHalData
->UndecoratedSmoothedPWDB
= pHalData
->UndecoratedSmoothedPWDB
+ 1;
8896 pHalData
->UndecoratedSmoothedPWDB
=
8897 ( ((pHalData
->UndecoratedSmoothedPWDB
)* 5) + (pPreviousRfd
->Status
.RxPWDBAll
)) / 6;
8906 /* record the general EVM to the sliding window. */
8907 if(pprevious_stats
->SignalQuality
== 0)
8912 if(pprevious_stats
->bPacketToSelf
|| pprevious_stats
->bPacketBeacon
|| pprevious_stats
->bToSelfBA
){
8913 if(slide_evm_statistics
++ >= PHY_RSSI_SLID_WIN_MAX
){
8914 slide_evm_statistics
= PHY_RSSI_SLID_WIN_MAX
;
8915 last_evm
= priv
->stats
.slide_evm
[slide_evm_index
];
8916 priv
->stats
.slide_evm_total
-= last_evm
;
8919 priv
->stats
.slide_evm_total
+= pprevious_stats
->SignalQuality
;
8921 priv
->stats
.slide_evm
[slide_evm_index
++] = pprevious_stats
->SignalQuality
;
8922 if(slide_evm_index
>= PHY_RSSI_SLID_WIN_MAX
)
8923 slide_evm_index
= 0;
8925 // <1> Showed on UI for user, in percentage.
8926 tmp_val
= priv
->stats
.slide_evm_total
/slide_evm_statistics
;
8927 priv
->stats
.signal_quality
= tmp_val
;
8928 //cosa add 10/11/2007, Showed on UI for user in Windows Vista, for Link quality.
8929 priv
->stats
.last_signal_strength_inpercent
= tmp_val
;
8932 // <2> Showed on UI for engineering
8933 if(pprevious_stats
->bPacketToSelf
|| pprevious_stats
->bPacketBeacon
|| pprevious_stats
->bToSelfBA
)
8935 for(nspatial_stream
= 0; nspatial_stream
<2 ; nspatial_stream
++) // 2 spatial stream
8937 if(pprevious_stats
->RxMIMOSignalQuality
[nspatial_stream
] != -1)
8939 if(priv
->stats
.rx_evm_percentage
[nspatial_stream
] == 0) // initialize
8941 priv
->stats
.rx_evm_percentage
[nspatial_stream
] = pprevious_stats
->RxMIMOSignalQuality
[nspatial_stream
];
8943 priv
->stats
.rx_evm_percentage
[nspatial_stream
] =
8944 ( (priv
->stats
.rx_evm_percentage
[nspatial_stream
]* (Rx_Smooth_Factor
-1)) +
8945 (pprevious_stats
->RxMIMOSignalQuality
[nspatial_stream
]* 1)) / (Rx_Smooth_Factor
);
8954 /*-----------------------------------------------------------------------------
8955 * Function: rtl819x_query_rxpwrpercentage()
8959 * Input: char antpower
8963 * Return: 0-100 percentage
8967 * 05/26/2008 amy Create Version 0 porting from windows code.
8969 *---------------------------------------------------------------------------*/
8970 static u8
rtl819x_query_rxpwrpercentage(
8974 if ((antpower
<= -100) || (antpower
>= 20))
8978 else if (antpower
>= 0)
8984 return (100+antpower
);
8987 } /* QueryRxPwrPercentage */
8990 rtl819x_evm_dbtopercentage(
9002 ret_val
= 0 - ret_val
;
9010 // We want good-looking for signal strength/quality
9011 // 2007/7/19 01:09, by cosa.
9014 rtl819x_signal_scale_mapping(
9020 // Step 1. Scale mapping.
9021 if(currsig
>= 61 && currsig
<= 100)
9023 retsig
= 90 + ((currsig
- 60) / 4);
9025 else if(currsig
>= 41 && currsig
<= 60)
9027 retsig
= 78 + ((currsig
- 40) / 2);
9029 else if(currsig
>= 31 && currsig
<= 40)
9031 retsig
= 66 + (currsig
- 30);
9033 else if(currsig
>= 21 && currsig
<= 30)
9035 retsig
= 54 + (currsig
- 20);
9037 else if(currsig
>= 5 && currsig
<= 20)
9039 retsig
= 42 + (((currsig
- 5) * 2) / 3);
9041 else if(currsig
== 4)
9045 else if(currsig
== 3)
9049 else if(currsig
== 2)
9053 else if(currsig
== 1)
9066 /*-----------------------------------------------------------------------------
9067 * Function: QueryRxPhyStatus8192S()
9079 * 06/01/2007 MHC Create Version 0.
9080 * 06/05/2007 MHC Accordign to HW's new data sheet, we add CCK and OFDM
9081 * descriptor definition.
9082 * 07/04/2007 MHC According to Jerry and Bryant's document. We read
9083 * ir_isolation and ext_lna for RF's init value and use
9084 * to compensate RSSI after receiving packets.
9085 * 09/10/2008 MHC Modify name and PHY status field for 92SE.
9086 * 09/19/2008 MHC Add CCK/OFDM SS/SQ for 92S series.
9088 *---------------------------------------------------------------------------*/
9089 static void rtl8192SU_query_rxphystatus(
9090 struct r8192_priv
* priv
,
9091 struct ieee80211_rx_stats
* pstats
,
9092 rx_desc_819x_usb
*pDesc
,
9093 rx_drvinfo_819x_usb
* pdrvinfo
,
9094 struct ieee80211_rx_stats
* precord_stats
,
9095 bool bpacket_match_bssid
,
9096 bool bpacket_toself
,
9101 //PRT_RFD_STATUS pRtRfdStatus = &(pRfd->Status);
9102 //PHY_STS_CCK_8192S_T *pCck_buf;
9103 phy_sts_cck_819xusb_t
* pcck_buf
;
9104 phy_ofdm_rx_status_rxsc_sgien_exintfflag
* prxsc
;
9106 //u8 i, max_spatial_stream, tmp_rxsnr, tmp_rxevm, rxsc_sgien_exflg;
9107 u8 i
, max_spatial_stream
, rxsc_sgien_exflg
;
9108 char rx_pwr
[4], rx_pwr_all
=0;
9109 //long rx_avg_pwr = 0;
9110 //char rx_snrX, rx_evmX;
9112 u32 RSSI
, total_rssi
=0;//, total_evm=0;
9113 // long signal_strength_index = 0;
9119 priv
->stats
.numqry_phystatus
++;
9121 is_cck_rate
= rx_hal_is_cck_rate(pDesc
);
9123 // Record it for next packet processing
9124 memset(precord_stats
, 0, sizeof(struct ieee80211_rx_stats
));
9125 pstats
->bPacketMatchBSSID
= precord_stats
->bPacketMatchBSSID
= bpacket_match_bssid
;
9126 pstats
->bPacketToSelf
= precord_stats
->bPacketToSelf
= bpacket_toself
;
9127 pstats
->bIsCCK
= precord_stats
->bIsCCK
= is_cck_rate
;//RX_HAL_IS_CCK_RATE(pDrvInfo);
9128 pstats
->bPacketBeacon
= precord_stats
->bPacketBeacon
= bPacketBeacon
;
9129 pstats
->bToSelfBA
= precord_stats
->bToSelfBA
= bToSelfBA
;
9132 phy_sts_ofdm_819xusb_t
* pofdm_buf
= NULL
;
9133 prxpkt
= (u8
*)pdrvinfo
;
9135 /* Move pointer to the 16th bytes. Phy status start address. */
9136 prxpkt
+= sizeof(rx_drvinfo_819x_usb
);
9138 /* Initial the cck and ofdm buffer pointer */
9139 pcck_buf
= (phy_sts_cck_819xusb_t
*)prxpkt
;
9140 pofdm_buf
= (phy_sts_ofdm_819xusb_t
*)prxpkt
;
9143 pstats
->RxMIMOSignalQuality
[0] = -1;
9144 pstats
->RxMIMOSignalQuality
[1] = -1;
9145 precord_stats
->RxMIMOSignalQuality
[0] = -1;
9146 precord_stats
->RxMIMOSignalQuality
[1] = -1;
9150 u8 report
;//, tmp_pwdb;
9151 //char cck_adc_pwdb[4];
9153 // CCK Driver info Structure is not the same as OFDM packet.
9154 pcck_buf
= (phy_sts_cck_819xusb_t
*)pdrvinfo
;
9157 // (1)Hardware does not provide RSSI for CCK
9161 // (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive)
9164 priv
->stats
.numqry_phystatusCCK
++;
9166 if(!priv
->bCckHighPower
)
9168 report
= pcck_buf
->cck_agc_rpt
& 0xc0;
9172 //Fixed by Jacken from Bryant 2008-03-20
9173 //Original value is -38 , -26 , -14 , -2
9174 //Fixed value is -35 , -23 , -11 , 6
9176 rx_pwr_all
= -35 - (pcck_buf
->cck_agc_rpt
& 0x3e);
9179 rx_pwr_all
= -23 - (pcck_buf
->cck_agc_rpt
& 0x3e);
9182 rx_pwr_all
= -11 - (pcck_buf
->cck_agc_rpt
& 0x3e);
9185 rx_pwr_all
= 8 - (pcck_buf
->cck_agc_rpt
& 0x3e);//6->8
9191 report
= pdrvinfo
->cfosho
[0] & 0x60;
9196 rx_pwr_all
= -35 - ((pcck_buf
->cck_agc_rpt
& 0x1f)<<1) ;
9199 rx_pwr_all
= -23 - ((pcck_buf
->cck_agc_rpt
& 0x1f)<<1);
9202 rx_pwr_all
= -11 - ((pcck_buf
->cck_agc_rpt
& 0x1f)<<1) ;
9205 rx_pwr_all
= -8 - ((pcck_buf
->cck_agc_rpt
& 0x1f)<<1) ;//6->-8
9210 pwdb_all
= rtl819x_query_rxpwrpercentage(rx_pwr_all
);//check it
9211 pstats
->RxPWDBAll
= precord_stats
->RxPWDBAll
= pwdb_all
;
9212 //pstats->RecvSignalPower = pwdb_all;
9213 pstats
->RecvSignalPower
= rx_pwr_all
;
9216 // (3) Get Signal Quality (EVM)
9218 //if(bpacket_match_bssid)
9222 if(pstats
->RxPWDBAll
> 40)
9227 sq
= pcck_buf
->sq_rpt
;
9229 if(pcck_buf
->sq_rpt
> 64)
9231 else if (pcck_buf
->sq_rpt
< 20)
9234 sq
= ((64-sq
) * 100) / 44;
9236 pstats
->SignalQuality
= precord_stats
->SignalQuality
= sq
;
9237 pstats
->RxMIMOSignalQuality
[0] = precord_stats
->RxMIMOSignalQuality
[0] = sq
;
9238 pstats
->RxMIMOSignalQuality
[1] = precord_stats
->RxMIMOSignalQuality
[1] = -1;
9243 priv
->stats
.numqry_phystatusHT
++;
9245 // 2008/09/19 MH For 92S debug, RX RF path always enable!!
9246 priv
->brfpath_rxenable
[0] = priv
->brfpath_rxenable
[1] = TRUE
;
9249 // (1)Get RSSI for HT rate
9251 //for(i=RF90_PATH_A; i<priv->NumTotalRFPath; i++)
9252 for(i
=RF90_PATH_A
; i
<RF90_PATH_MAX
; i
++)
9254 // 2008/01/30 MH we will judge RF RX path now.
9255 if (priv
->brfpath_rxenable
[i
])
9260 //if (!rtl8192_phy_CheckIsLegalRFPath(priv->ieee80211->dev, i))
9263 //Fixed by Jacken from Bryant 2008-03-20
9264 //Original value is 106
9265 //rx_pwr[i] = ((pofdm_buf->trsw_gain_X[i]&0x3F)*2) - 106;
9266 rx_pwr
[i
] = ((pdrvinfo
->gain_trsw
[i
]&0x3F)*2) - 110;
9268 /* Translate DBM to percentage. */
9269 RSSI
= rtl819x_query_rxpwrpercentage(rx_pwr
[i
]); //check ok
9271 RT_TRACE(COMP_RF
, "RF-%d RXPWR=%x RSSI=%d\n", i
, rx_pwr
[i
], RSSI
);
9273 //Get Rx snr value in DB
9274 //tmp_rxsnr = pofdm_buf->rxsnr_X[i];
9275 //rx_snrX = (char)(tmp_rxsnr);
9277 //priv->stats.rxSNRdB[i] = (long)rx_snrX;
9278 priv
->stats
.rxSNRdB
[i
] = (long)(pdrvinfo
->rxsnr
[i
]/2);
9280 /* Translate DBM to percentage. */
9281 //RSSI = rtl819x_query_rxpwrpercentage(rx_pwr[i]);
9282 //total_rssi += RSSI;
9284 /* Record Signal Strength for next packet */
9285 //if(bpacket_match_bssid)
9287 pstats
->RxMIMOSignalStrength
[i
] =(u8
) RSSI
;
9288 precord_stats
->RxMIMOSignalStrength
[i
] =(u8
) RSSI
;
9294 // (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive)
9296 //Fixed by Jacken from Bryant 2008-03-20
9297 //Original value is 106
9298 //rx_pwr_all = (((pofdm_buf->pwdb_all ) >> 1 )& 0x7f) -106;
9299 rx_pwr_all
= (((pdrvinfo
->pwdb_all
) >> 1 )& 0x7f) -106;
9300 pwdb_all
= rtl819x_query_rxpwrpercentage(rx_pwr_all
);
9302 pstats
->RxPWDBAll
= precord_stats
->RxPWDBAll
= pwdb_all
;
9303 pstats
->RxPower
= precord_stats
->RxPower
= rx_pwr_all
;
9304 pstats
->RecvSignalPower
= rx_pwr_all
;
9307 // (3)EVM of HT rate
9309 //if(pdrvinfo->RxHT && pdrvinfo->RxRate>=DESC90_RATEMCS8 &&
9310 // pdrvinfo->RxRate<=DESC90_RATEMCS15)
9311 if(pDesc
->RxHT
&& pDesc
->RxMCS
>=DESC92S_RATEMCS8
&&
9312 pDesc
->RxMCS
<=DESC92S_RATEMCS15
)
9313 max_spatial_stream
= 2; //both spatial stream make sense
9315 max_spatial_stream
= 1; //only spatial stream 1 makes sense
9317 for(i
=0; i
<max_spatial_stream
; i
++)
9319 //tmp_rxevm = pofdm_buf->rxevm_X[i];
9320 //rx_evmX = (char)(tmp_rxevm);
9322 // Do not use shift operation like "rx_evmX >>= 1" because the compilor of free build environment
9323 // fill most significant bit to "zero" when doing shifting operation which may change a negative
9324 // value to positive one, then the dbm value (which is supposed to be negative) is not correct anymore.
9325 //rx_evmX /= 2; //dbm
9327 //evm = rtl819x_evm_dbtopercentage(rx_evmX);
9328 evm
= rtl819x_evm_dbtopercentage( (pdrvinfo
->rxevm
[i
] /*/ 2*/)); //dbm
9329 RT_TRACE(COMP_RF
, "RXRATE=%x RXEVM=%x EVM=%s%d\n", pDesc
->RxMCS
, pdrvinfo
->rxevm
[i
], "%", evm
);
9331 EVM
= SignalScaleMapping(EVM
);//make it good looking, from 0~100//=====>from here
9334 //if(bpacket_match_bssid)
9336 if(i
==0) // Fill value in RFD, Get the first spatial stream only
9337 pstats
->SignalQuality
= precord_stats
->SignalQuality
= (u8
)(evm
& 0xff);
9338 pstats
->RxMIMOSignalQuality
[i
] = precord_stats
->RxMIMOSignalQuality
[i
] = (u8
)(evm
& 0xff);
9343 /* record rx statistics for debug */
9344 //rxsc_sgien_exflg = pofdm_buf->rxsc_sgien_exflg;
9345 prxsc
= (phy_ofdm_rx_status_rxsc_sgien_exintfflag
*)&rxsc_sgien_exflg
;
9346 //if(pdrvinfo->BW) //40M channel
9347 if(pDesc
->BW
) //40M channel
9348 priv
->stats
.received_bwtype
[1+pdrvinfo
->rxsc
]++;
9350 priv
->stats
.received_bwtype
[0]++;
9353 //UI BSS List signal strength(in percentage), make it good looking, from 0~100.
9354 //It is assigned to the BSS List in GetValueFromBeaconOrProbeRsp().
9357 pstats
->SignalStrength
= precord_stats
->SignalStrength
= (u8
)(rtl819x_signal_scale_mapping((long)pwdb_all
));//PWDB_ALL;//check ok
9362 //pRfd->Status.SignalStrength = pRecordRfd->Status.SignalStrength = (u8)(SignalScaleMapping(total_rssi/=RF90_PATH_MAX));//(u8)(total_rssi/=RF90_PATH_MAX);
9363 // We can judge RX path number now.
9365 pstats
->SignalStrength
= precord_stats
->SignalStrength
= (u8
)(rtl819x_signal_scale_mapping((long)(total_rssi
/=rf_rx_num
)));
9367 }/* QueryRxPhyStatus8192S */
9369 static void rtl8192_query_rxphystatus(
9370 struct r8192_priv
* priv
,
9371 struct ieee80211_rx_stats
* pstats
,
9372 rx_drvinfo_819x_usb
* pdrvinfo
,
9373 struct ieee80211_rx_stats
* precord_stats
,
9374 bool bpacket_match_bssid
,
9375 bool bpacket_toself
,
9380 //PRT_RFD_STATUS pRtRfdStatus = &(pRfd->Status);
9381 phy_sts_ofdm_819xusb_t
* pofdm_buf
;
9382 phy_sts_cck_819xusb_t
* pcck_buf
;
9383 phy_ofdm_rx_status_rxsc_sgien_exintfflag
* prxsc
;
9385 u8 i
, max_spatial_stream
, tmp_rxsnr
, tmp_rxevm
, rxsc_sgien_exflg
;
9386 char rx_pwr
[4], rx_pwr_all
=0;
9387 //long rx_avg_pwr = 0;
9388 char rx_snrX
, rx_evmX
;
9390 u32 RSSI
, total_rssi
=0;//, total_evm=0;
9391 // long signal_strength_index = 0;
9396 priv
->stats
.numqry_phystatus
++;
9398 is_cck_rate
= rx_hal_is_cck_rate(pdrvinfo
);
9400 // Record it for next packet processing
9401 memset(precord_stats
, 0, sizeof(struct ieee80211_rx_stats
));
9402 pstats
->bPacketMatchBSSID
= precord_stats
->bPacketMatchBSSID
= bpacket_match_bssid
;
9403 pstats
->bPacketToSelf
= precord_stats
->bPacketToSelf
= bpacket_toself
;
9404 pstats
->bIsCCK
= precord_stats
->bIsCCK
= is_cck_rate
;//RX_HAL_IS_CCK_RATE(pDrvInfo);
9405 pstats
->bPacketBeacon
= precord_stats
->bPacketBeacon
= bPacketBeacon
;
9406 pstats
->bToSelfBA
= precord_stats
->bToSelfBA
= bToSelfBA
;
9408 prxpkt
= (u8
*)pdrvinfo
;
9410 /* Move pointer to the 16th bytes. Phy status start address. */
9411 prxpkt
+= sizeof(rx_drvinfo_819x_usb
);
9413 /* Initial the cck and ofdm buffer pointer */
9414 pcck_buf
= (phy_sts_cck_819xusb_t
*)prxpkt
;
9415 pofdm_buf
= (phy_sts_ofdm_819xusb_t
*)prxpkt
;
9417 pstats
->RxMIMOSignalQuality
[0] = -1;
9418 pstats
->RxMIMOSignalQuality
[1] = -1;
9419 precord_stats
->RxMIMOSignalQuality
[0] = -1;
9420 precord_stats
->RxMIMOSignalQuality
[1] = -1;
9425 // (1)Hardware does not provide RSSI for CCK
9429 // (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive)
9431 u8 report
;//, cck_agc_rpt;
9433 priv
->stats
.numqry_phystatusCCK
++;
9435 if(!priv
->bCckHighPower
)
9437 report
= pcck_buf
->cck_agc_rpt
& 0xc0;
9441 //Fixed by Jacken from Bryant 2008-03-20
9442 //Original value is -38 , -26 , -14 , -2
9443 //Fixed value is -35 , -23 , -11 , 6
9445 rx_pwr_all
= -35 - (pcck_buf
->cck_agc_rpt
& 0x3e);
9448 rx_pwr_all
= -23 - (pcck_buf
->cck_agc_rpt
& 0x3e);
9451 rx_pwr_all
= -11 - (pcck_buf
->cck_agc_rpt
& 0x3e);
9454 rx_pwr_all
= 6 - (pcck_buf
->cck_agc_rpt
& 0x3e);
9460 report
= pcck_buf
->cck_agc_rpt
& 0x60;
9465 rx_pwr_all
= -35 - ((pcck_buf
->cck_agc_rpt
& 0x1f)<<1) ;
9468 rx_pwr_all
= -23 - ((pcck_buf
->cck_agc_rpt
& 0x1f)<<1);
9471 rx_pwr_all
= -11 - ((pcck_buf
->cck_agc_rpt
& 0x1f)<<1) ;
9474 rx_pwr_all
= 6 - ((pcck_buf
->cck_agc_rpt
& 0x1f)<<1) ;
9479 pwdb_all
= rtl819x_query_rxpwrpercentage(rx_pwr_all
);
9480 pstats
->RxPWDBAll
= precord_stats
->RxPWDBAll
= pwdb_all
;
9481 pstats
->RecvSignalPower
= pwdb_all
;
9484 // (3) Get Signal Quality (EVM)
9486 //if(bpacket_match_bssid)
9490 if(pstats
->RxPWDBAll
> 40)
9495 sq
= pcck_buf
->sq_rpt
;
9497 if(pcck_buf
->sq_rpt
> 64)
9499 else if (pcck_buf
->sq_rpt
< 20)
9502 sq
= ((64-sq
) * 100) / 44;
9504 pstats
->SignalQuality
= precord_stats
->SignalQuality
= sq
;
9505 pstats
->RxMIMOSignalQuality
[0] = precord_stats
->RxMIMOSignalQuality
[0] = sq
;
9506 pstats
->RxMIMOSignalQuality
[1] = precord_stats
->RxMIMOSignalQuality
[1] = -1;
9511 priv
->stats
.numqry_phystatusHT
++;
9513 // (1)Get RSSI for HT rate
9515 for(i
=RF90_PATH_A
; i
<priv
->NumTotalRFPath
; i
++)
9517 // 2008/01/30 MH we will judge RF RX path now.
9518 if (priv
->brfpath_rxenable
[i
])
9523 if (!rtl8192_phy_CheckIsLegalRFPath(priv
->ieee80211
->dev
, i
))
9526 //Fixed by Jacken from Bryant 2008-03-20
9527 //Original value is 106
9528 rx_pwr
[i
] = ((pofdm_buf
->trsw_gain_X
[i
]&0x3F)*2) - 106;
9530 //Get Rx snr value in DB
9531 tmp_rxsnr
= pofdm_buf
->rxsnr_X
[i
];
9532 rx_snrX
= (char)(tmp_rxsnr
);
9535 priv
->stats
.rxSNRdB
[i
] = (long)rx_snrX
;
9537 /* Translate DBM to percentage. */
9538 RSSI
= rtl819x_query_rxpwrpercentage(rx_pwr
[i
]);
9541 /* Record Signal Strength for next packet */
9542 //if(bpacket_match_bssid)
9544 pstats
->RxMIMOSignalStrength
[i
] =(u8
) RSSI
;
9545 precord_stats
->RxMIMOSignalStrength
[i
] =(u8
) RSSI
;
9551 // (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive)
9553 //Fixed by Jacken from Bryant 2008-03-20
9554 //Original value is 106
9555 rx_pwr_all
= (((pofdm_buf
->pwdb_all
) >> 1 )& 0x7f) -106;
9556 pwdb_all
= rtl819x_query_rxpwrpercentage(rx_pwr_all
);
9558 pstats
->RxPWDBAll
= precord_stats
->RxPWDBAll
= pwdb_all
;
9559 pstats
->RxPower
= precord_stats
->RxPower
= rx_pwr_all
;
9562 // (3)EVM of HT rate
9564 if(pdrvinfo
->RxHT
&& pdrvinfo
->RxRate
>=DESC90_RATEMCS8
&&
9565 pdrvinfo
->RxRate
<=DESC90_RATEMCS15
)
9566 max_spatial_stream
= 2; //both spatial stream make sense
9568 max_spatial_stream
= 1; //only spatial stream 1 makes sense
9570 for(i
=0; i
<max_spatial_stream
; i
++)
9572 tmp_rxevm
= pofdm_buf
->rxevm_X
[i
];
9573 rx_evmX
= (char)(tmp_rxevm
);
9575 // Do not use shift operation like "rx_evmX >>= 1" because the compilor of free build environment
9576 // fill most significant bit to "zero" when doing shifting operation which may change a negative
9577 // value to positive one, then the dbm value (which is supposed to be negative) is not correct anymore.
9580 evm
= rtl819x_evm_dbtopercentage(rx_evmX
);
9582 EVM
= SignalScaleMapping(EVM
);//make it good looking, from 0~100
9584 //if(bpacket_match_bssid)
9586 if(i
==0) // Fill value in RFD, Get the first spatial stream only
9587 pstats
->SignalQuality
= precord_stats
->SignalQuality
= (u8
)(evm
& 0xff);
9588 pstats
->RxMIMOSignalQuality
[i
] = precord_stats
->RxMIMOSignalQuality
[i
] = (u8
)(evm
& 0xff);
9593 /* record rx statistics for debug */
9594 rxsc_sgien_exflg
= pofdm_buf
->rxsc_sgien_exflg
;
9595 prxsc
= (phy_ofdm_rx_status_rxsc_sgien_exintfflag
*)&rxsc_sgien_exflg
;
9596 if(pdrvinfo
->BW
) //40M channel
9597 priv
->stats
.received_bwtype
[1+prxsc
->rxsc
]++;
9599 priv
->stats
.received_bwtype
[0]++;
9602 //UI BSS List signal strength(in percentage), make it good looking, from 0~100.
9603 //It is assigned to the BSS List in GetValueFromBeaconOrProbeRsp().
9606 pstats
->SignalStrength
= precord_stats
->SignalStrength
= (u8
)(rtl819x_signal_scale_mapping((long)pwdb_all
));//PWDB_ALL;
9611 //pRfd->Status.SignalStrength = pRecordRfd->Status.SignalStrength = (u8)(SignalScaleMapping(total_rssi/=RF90_PATH_MAX));//(u8)(total_rssi/=RF90_PATH_MAX);
9612 // We can judge RX path number now.
9614 pstats
->SignalStrength
= precord_stats
->SignalStrength
= (u8
)(rtl819x_signal_scale_mapping((long)(total_rssi
/=rf_rx_num
)));
9616 } /* QueryRxPhyStatus8190Pci */
9620 rtl8192_record_rxdesc_forlateruse(
9621 struct ieee80211_rx_stats
* psrc_stats
,
9622 struct ieee80211_rx_stats
* ptarget_stats
9625 ptarget_stats
->bIsAMPDU
= psrc_stats
->bIsAMPDU
;
9626 ptarget_stats
->bFirstMPDU
= psrc_stats
->bFirstMPDU
;
9627 ptarget_stats
->Seq_Num
= psrc_stats
->Seq_Num
;
9631 static void rtl8192SU_query_rxphystatus(
9632 struct r8192_priv
* priv
,
9633 struct ieee80211_rx_stats
* pstats
,
9634 rx_desc_819x_usb
*pDesc
,
9635 rx_drvinfo_819x_usb
* pdrvinfo
,
9636 struct ieee80211_rx_stats
* precord_stats
,
9637 bool bpacket_match_bssid
,
9638 bool bpacket_toself
,
9642 void rtl8192SU_TranslateRxSignalStuff(struct sk_buff
*skb
,
9643 struct ieee80211_rx_stats
* pstats
,
9644 rx_desc_819x_usb
*pDesc
,
9645 rx_drvinfo_819x_usb
*pdrvinfo
)
9647 // TODO: We must only check packet for current MAC address. Not finish
9648 rtl8192_rx_info
*info
= (struct rtl8192_rx_info
*)skb
->cb
;
9649 struct net_device
*dev
=info
->dev
;
9650 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
9651 bool bpacket_match_bssid
, bpacket_toself
;
9652 bool bPacketBeacon
=FALSE
, bToSelfBA
=FALSE
;
9653 static struct ieee80211_rx_stats previous_stats
;
9654 struct ieee80211_hdr_3addr
*hdr
;//by amy
9657 // Get Signal Quality for only RX data queue (but not command queue)
9660 //u16 tmp_buf_len = 0;
9663 /* Get MAC frame start address. */
9664 tmp_buf
= (u8
*)skb
->data
;// + get_rxpacket_shiftbytes_819xusb(pstats);
9666 hdr
= (struct ieee80211_hdr_3addr
*)tmp_buf
;
9667 fc
= le16_to_cpu(hdr
->frame_ctl
);
9668 type
= WLAN_FC_GET_TYPE(fc
);
9669 praddr
= hdr
->addr1
;
9671 /* Check if the received packet is acceptabe. */
9672 bpacket_match_bssid
= ((IEEE80211_FTYPE_CTL
!= type
) &&
9673 (eqMacAddr(priv
->ieee80211
->current_network
.bssid
, (fc
& IEEE80211_FCTL_TODS
)? hdr
->addr1
: (fc
& IEEE80211_FCTL_FROMDS
)? hdr
->addr2
: hdr
->addr3
))
9674 && (!pstats
->bHwError
) && (!pstats
->bCRC
)&& (!pstats
->bICV
));
9675 bpacket_toself
= bpacket_match_bssid
& (eqMacAddr(praddr
, priv
->ieee80211
->dev
->dev_addr
));
9678 if(WLAN_FC_GET_FRAMETYPE(fc
)== IEEE80211_STYPE_BEACON
)
9680 bPacketBeacon
= true;
9681 //DbgPrint("Beacon 2, MatchBSSID = %d, ToSelf = %d \n", bPacketMatchBSSID, bPacketToSelf);
9683 if(WLAN_FC_GET_FRAMETYPE(fc
) == IEEE80211_STYPE_BLOCKACK
)
9685 if((eqMacAddr(praddr
,dev
->dev_addr
)))
9687 //DbgPrint("BlockAck, MatchBSSID = %d, ToSelf = %d \n", bPacketMatchBSSID, bPacketToSelf);
9693 if(bpacket_match_bssid
)
9695 priv
->stats
.numpacket_matchbssid
++;
9698 priv
->stats
.numpacket_toself
++;
9701 // Process PHY information for previous packet (RSSI/PWDB/EVM)
9703 // Because phy information is contained in the last packet of AMPDU only, so driver
9704 // should process phy information of previous packet
9705 rtl8192_process_phyinfo(priv
, tmp_buf
, &previous_stats
, pstats
);
9706 rtl8192SU_query_rxphystatus(priv
, pstats
, pDesc
, pdrvinfo
, &previous_stats
, bpacket_match_bssid
,bpacket_toself
,bPacketBeacon
,bToSelfBA
);
9707 rtl8192_record_rxdesc_forlateruse(pstats
, &previous_stats
);
9711 void TranslateRxSignalStuff819xUsb(struct sk_buff
*skb
,
9712 struct ieee80211_rx_stats
* pstats
,
9713 rx_drvinfo_819x_usb
*pdrvinfo
)
9715 // TODO: We must only check packet for current MAC address. Not finish
9716 rtl8192_rx_info
*info
= (struct rtl8192_rx_info
*)skb
->cb
;
9717 struct net_device
*dev
=info
->dev
;
9718 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
9719 bool bpacket_match_bssid
, bpacket_toself
;
9720 bool bPacketBeacon
=FALSE
, bToSelfBA
=FALSE
;
9721 static struct ieee80211_rx_stats previous_stats
;
9722 struct ieee80211_hdr_3addr
*hdr
;//by amy
9725 // Get Signal Quality for only RX data queue (but not command queue)
9728 //u16 tmp_buf_len = 0;
9731 /* Get MAC frame start address. */
9732 tmp_buf
= (u8
*)skb
->data
;// + get_rxpacket_shiftbytes_819xusb(pstats);
9734 hdr
= (struct ieee80211_hdr_3addr
*)tmp_buf
;
9735 fc
= le16_to_cpu(hdr
->frame_ctl
);
9736 type
= WLAN_FC_GET_TYPE(fc
);
9737 praddr
= hdr
->addr1
;
9739 /* Check if the received packet is acceptabe. */
9740 bpacket_match_bssid
= ((IEEE80211_FTYPE_CTL
!= type
) &&
9741 (eqMacAddr(priv
->ieee80211
->current_network
.bssid
, (fc
& IEEE80211_FCTL_TODS
)? hdr
->addr1
: (fc
& IEEE80211_FCTL_FROMDS
)? hdr
->addr2
: hdr
->addr3
))
9742 && (!pstats
->bHwError
) && (!pstats
->bCRC
)&& (!pstats
->bICV
));
9743 bpacket_toself
= bpacket_match_bssid
& (eqMacAddr(praddr
, priv
->ieee80211
->dev
->dev_addr
));
9746 if(WLAN_FC_GET_FRAMETYPE(fc
)== IEEE80211_STYPE_BEACON
)
9748 bPacketBeacon
= true;
9749 //DbgPrint("Beacon 2, MatchBSSID = %d, ToSelf = %d \n", bPacketMatchBSSID, bPacketToSelf);
9751 if(WLAN_FC_GET_FRAMETYPE(fc
) == IEEE80211_STYPE_BLOCKACK
)
9753 if((eqMacAddr(praddr
,dev
->dev_addr
)))
9755 //DbgPrint("BlockAck, MatchBSSID = %d, ToSelf = %d \n", bPacketMatchBSSID, bPacketToSelf);
9761 if(bpacket_match_bssid
)
9763 priv
->stats
.numpacket_matchbssid
++;
9766 priv
->stats
.numpacket_toself
++;
9769 // Process PHY information for previous packet (RSSI/PWDB/EVM)
9771 // Because phy information is contained in the last packet of AMPDU only, so driver
9772 // should process phy information of previous packet
9773 rtl8192_process_phyinfo(priv
, tmp_buf
, &previous_stats
, pstats
);
9774 rtl8192_query_rxphystatus(priv
, pstats
, pdrvinfo
, &previous_stats
, bpacket_match_bssid
,bpacket_toself
,bPacketBeacon
,bToSelfBA
);
9775 rtl8192_record_rxdesc_forlateruse(pstats
, &previous_stats
);
9781 * Function: UpdateReceivedRateHistogramStatistics
9782 * Overview: Recored down the received data rate
9785 * struct net_device *dev
9786 * struct ieee80211_rx_stats *stats
9790 * (priv->stats.ReceivedRateHistogram[] is updated)
9795 UpdateReceivedRateHistogramStatistics8190(
9796 struct net_device
*dev
,
9797 struct ieee80211_rx_stats
*stats
9800 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
9801 u32 rcvType
=1; //0: Total, 1:OK, 2:CRC, 3:ICV
9803 u32 preamble_guardinterval
; //1: short preamble/GI, 0: long preamble/GI
9808 else if(stats
->bICV
)
9811 if(stats
->bShortPreamble
)
9812 preamble_guardinterval
= 1;// short
9814 preamble_guardinterval
= 0;// long
9821 case MGN_1M
: rateIndex
= 0; break;
9822 case MGN_2M
: rateIndex
= 1; break;
9823 case MGN_5_5M
: rateIndex
= 2; break;
9824 case MGN_11M
: rateIndex
= 3; break;
9828 case MGN_6M
: rateIndex
= 4; break;
9829 case MGN_9M
: rateIndex
= 5; break;
9830 case MGN_12M
: rateIndex
= 6; break;
9831 case MGN_18M
: rateIndex
= 7; break;
9832 case MGN_24M
: rateIndex
= 8; break;
9833 case MGN_36M
: rateIndex
= 9; break;
9834 case MGN_48M
: rateIndex
= 10; break;
9835 case MGN_54M
: rateIndex
= 11; break;
9837 // 11n High throughput rate
9839 case MGN_MCS0
: rateIndex
= 12; break;
9840 case MGN_MCS1
: rateIndex
= 13; break;
9841 case MGN_MCS2
: rateIndex
= 14; break;
9842 case MGN_MCS3
: rateIndex
= 15; break;
9843 case MGN_MCS4
: rateIndex
= 16; break;
9844 case MGN_MCS5
: rateIndex
= 17; break;
9845 case MGN_MCS6
: rateIndex
= 18; break;
9846 case MGN_MCS7
: rateIndex
= 19; break;
9847 case MGN_MCS8
: rateIndex
= 20; break;
9848 case MGN_MCS9
: rateIndex
= 21; break;
9849 case MGN_MCS10
: rateIndex
= 22; break;
9850 case MGN_MCS11
: rateIndex
= 23; break;
9851 case MGN_MCS12
: rateIndex
= 24; break;
9852 case MGN_MCS13
: rateIndex
= 25; break;
9853 case MGN_MCS14
: rateIndex
= 26; break;
9854 case MGN_MCS15
: rateIndex
= 27; break;
9855 default: rateIndex
= 28; break;
9857 priv
->stats
.received_preamble_GI
[preamble_guardinterval
][rateIndex
]++;
9858 priv
->stats
.received_rate_histogram
[0][rateIndex
]++; //total
9859 priv
->stats
.received_rate_histogram
[rcvType
][rateIndex
]++;
9863 void rtl8192SU_query_rxdesc_status(struct sk_buff
*skb
, struct ieee80211_rx_stats
*stats
, bool bIsRxAggrSubframe
)
9865 rtl8192_rx_info
*info
= (struct rtl8192_rx_info
*)skb
->cb
;
9866 struct net_device
*dev
=info
->dev
;
9867 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
9868 //rx_desc_819x_usb *desc = (rx_desc_819x_usb *)skb->data;
9869 rx_drvinfo_819x_usb
*driver_info
= NULL
;
9871 //PRT_RFD_STATUS pRtRfdStatus = &pRfd->Status;
9872 //PHAL_DATA_8192SUSB pHalData = GET_HAL_DATA(Adapter);
9873 //pu1Byte pDesc = (pu1Byte)pDescIn;
9874 //PRX_DRIVER_INFO_8192S pDrvInfo;
9876 rx_desc_819x_usb
*desc
= (rx_desc_819x_usb
*)skb
->data
;
9881 printk("========================");
9882 for(m
=0; m
<skb
->len
; m
++){
9885 printk("%2x ",((u8
*)skb
->data
)[m
]);
9887 printk("\n========================\n");
9893 //Get Rx Descriptor Raw Information
9895 stats
->Length
= desc
->Length
;
9896 stats
->RxDrvInfoSize
= desc
->RxDrvInfoSize
*RX_DRV_INFO_SIZE_UNIT
;
9897 stats
->RxBufShift
= (desc
->Shift
)&0x03;
9898 stats
->bICV
= desc
->ICV
;
9899 stats
->bCRC
= desc
->CRC32
;
9900 stats
->bHwError
= stats
->bCRC
|stats
->bICV
;
9901 stats
->Decrypted
= !desc
->SWDec
;//RTL8190 set this bit to indicate that Hw does not decrypt packet
9902 stats
->bIsAMPDU
= (desc
->AMSDU
==1);
9903 stats
->bFirstMPDU
= (desc
->PAGGR
==1) && (desc
->FAGGR
==1);
9904 stats
->bShortPreamble
= desc
->SPLCP
;
9905 stats
->RxIs40MHzPacket
= (desc
->BW
==1);
9906 stats
->TimeStampLow
= desc
->TSFL
;
9908 if((desc
->FAGGR
==1) || (desc
->PAGGR
==1))
9910 RT_TRACE(COMP_RXDESC
, "FirstAGGR = %d, PartAggr = %d\n", desc
->FAGGR
, desc
->PAGGR
);
9916 printk("%s: Receive ICV error!!!!!!!!!!!!!!!!!!!!!!\n", __FUNCTION__
);
9918 printk("%s: Receive CRC error!!!!!!!!!!!!!!!!!!!!!!\n", __FUNCTION__
);
9921 if(IS_UNDER_11N_AES_MODE(priv
->ieee80211
))
9923 // Always received ICV error packets in AES mode.
9924 // This fixed HW later MIC write bug.
9925 if(stats
->bICV
&& !stats
->bCRC
)
9927 stats
->bICV
= FALSE
;
9928 stats
->bHwError
= FALSE
;
9932 // Transform HwRate to MRate
9933 if(!stats
->bHwError
)
9934 //stats->DataRate = HwRateToMRate(
9935 // (BOOLEAN)GET_RX_DESC_RXHT(pDesc),
9936 // (u1Byte)GET_RX_DESC_RXMCS(pDesc),
9937 // (BOOLEAN)GET_RX_DESC_PAGGR(pDesc));
9938 stats
->rate
= rtl8192SU_HwRateToMRate(desc
->RxHT
, desc
->RxMCS
, desc
->PAGGR
);
9940 stats
->rate
= MGN_1M
;
9943 // Collect Rx rate/AMPDU/TSFL
9945 //UpdateRxdRateHistogramStatistics8192S(Adapter, pRfd);
9946 //UpdateRxAMPDUHistogramStatistics8192S(Adapter, pRfd);
9947 //UpdateRxPktTimeStamp8192S(Adapter, pRfd);
9948 UpdateReceivedRateHistogramStatistics8190(dev
, stats
);
9949 //UpdateRxAMPDUHistogramStatistics8192S(dev, stats); //FIXLZM
9950 UpdateRxPktTimeStamp8190(dev
, stats
);
9953 // Get PHY Status and RSVD parts.
9954 // <Roger_Notes> It only appears on last aggregated packet.
9956 if (desc
->PHYStatus
)
9958 //driver_info = (rx_drvinfo_819x_usb *)(skb->data + RX_DESC_SIZE + stats->RxBufShift);
9959 driver_info
= (rx_drvinfo_819x_usb
*)(skb
->data
+ sizeof(rx_desc_819x_usb
) + \
9964 printk("========================\n");
9965 printk("RX_DESC_SIZE:%d, RxBufShift:%d, RxDrvInfoSize:%d\n",
9966 RX_DESC_SIZE
, stats
->RxBufShift
, stats
->RxDrvInfoSize
);
9967 for(m
=0; m
<32; m
++){
9968 printk("%2x ",((u8
*)driver_info
)[m
]);
9970 printk("\n========================\n");
9977 skb_pull(skb
, sizeof(rx_desc_819x_usb
));
9981 // Get Total offset of MPDU Frame Body
9983 if((stats
->RxBufShift
+ stats
->RxDrvInfoSize
) > 0)
9987 skb_pull(skb
, stats
->RxBufShift
+ stats
->RxDrvInfoSize
);
9992 // Get PHY Status and RSVD parts.
9993 // <Roger_Notes> It only appears on last aggregated packet.
9995 if (desc
->PHYStatus
)
9997 rtl8192SU_TranslateRxSignalStuff(skb
, stats
, desc
, driver_info
);
10001 void query_rxdesc_status(struct sk_buff
*skb
, struct ieee80211_rx_stats
*stats
, bool bIsRxAggrSubframe
)
10003 rtl8192_rx_info
*info
= (struct rtl8192_rx_info
*)skb
->cb
;
10004 struct net_device
*dev
=info
->dev
;
10005 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
10006 //rx_desc_819x_usb *desc = (rx_desc_819x_usb *)skb->data;
10007 rx_drvinfo_819x_usb
*driver_info
= NULL
;
10010 //Get Rx Descriptor Information
10013 rx_desc_819x_usb
*desc
= (rx_desc_819x_usb
*)skb
->data
;
10015 stats
->Length
= desc
->Length
;
10016 stats
->RxDrvInfoSize
= desc
->RxDrvInfoSize
;
10017 stats
->RxBufShift
= 0;//desc->Shift&0x03;
10018 stats
->bICV
= desc
->ICV
;
10019 stats
->bCRC
= desc
->CRC32
;
10020 stats
->bHwError
= stats
->bCRC
|stats
->bICV
;
10021 //RTL8190 set this bit to indicate that Hw does not decrypt packet
10022 stats
->Decrypted
= !desc
->SWDec
;
10025 if((priv
->ieee80211
->pHTInfo
->bCurrentHTSupport
== true) && (priv
->ieee80211
->pairwise_key_type
== KEY_TYPE_CCMP
))
10027 stats
->bHwError
= false;
10031 stats
->bHwError
= stats
->bCRC
|stats
->bICV
;
10034 if(stats
->Length
< 24 || stats
->Length
> MAX_8192U_RX_SIZE
)
10035 stats
->bHwError
|= 1;
10039 // TODO: Need to verify it on FGPA platform
10040 //Driver info are written to the RxBuffer following rx desc
10041 if (stats
->RxDrvInfoSize
!= 0) {
10042 driver_info
= (rx_drvinfo_819x_usb
*)(skb
->data
+ sizeof(rx_desc_819x_usb
) + \
10043 stats
->RxBufShift
);
10046 if(!stats
->bHwError
){
10048 ret_rate
= HwRateToMRate90(driver_info
->RxHT
, driver_info
->RxRate
);
10049 if(ret_rate
== 0xff)
10051 // Abnormal Case: Receive CRC OK packet with Rx descriptor indicating non supported rate.
10052 // Special Error Handling here, 2008.05.16, by Emily
10054 stats
->bHwError
= 1;
10055 stats
->rate
= MGN_1M
; //Set 1M rate by default
10058 stats
->rate
= ret_rate
;
10062 stats
->rate
= 0x02;
10064 stats
->bShortPreamble
= driver_info
->SPLCP
;
10067 UpdateReceivedRateHistogramStatistics8190(dev
, stats
);
10069 stats
->bIsAMPDU
= (driver_info
->PartAggr
==1);
10070 stats
->bFirstMPDU
= (driver_info
->PartAggr
==1) && (driver_info
->FirstAGGR
==1);
10072 // TODO: it is debug only. It should be disabled in released driver. 2007.1.12 by Joseph
10073 UpdateRxAMPDUHistogramStatistics8190(Adapter
, pRfd
);
10075 stats
->TimeStampLow
= driver_info
->TSFL
;
10076 // xiong mask it, 070514
10077 //pRfd->Status.TimeStampHigh = PlatformEFIORead4Byte(Adapter, TSFR+4);
10078 // stats->TimeStampHigh = read_nic_dword(dev, TSFR+4);
10080 UpdateRxPktTimeStamp8190(dev
, stats
);
10085 if(driver_info
->FirstAGGR
==1 || driver_info
->PartAggr
== 1)
10086 RT_TRACE(COMP_RXDESC
, "driver_info->FirstAGGR = %d, driver_info->PartAggr = %d\n",
10087 driver_info
->FirstAGGR
, driver_info
->PartAggr
);
10091 skb_pull(skb
,sizeof(rx_desc_819x_usb
));
10093 // Get Total offset of MPDU Frame Body
10095 if((stats
->RxBufShift
+ stats
->RxDrvInfoSize
) > 0) {
10097 skb_pull(skb
,stats
->RxBufShift
+ stats
->RxDrvInfoSize
);
10100 /* for debug 2008.5.29 */
10104 printk("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
10105 for(i
= 0; i
< skb
->len
; i
++) {
10106 if(i
% 10 == 0) printk("\n");
10107 printk("%02x ", skb
->data
[i
]);
10109 printk("\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
10113 //added by vivi, for MP, 20080108
10114 stats
->RxIs40MHzPacket
= driver_info
->BW
;
10115 if(stats
->RxDrvInfoSize
!= 0)
10116 TranslateRxSignalStuff819xUsb(skb
, stats
, driver_info
);
10123 /*-----------------------------------------------------------------------------
10124 * Function: UpdateRxAMPDUHistogramStatistics8192S
10126 * Overview: Recored down the received A-MPDU aggregation size and pkt number
10131 * (Adapter->RxStats.RxAMPDUSizeHistogram[] is updated)
10132 * (Adapter->RxStats.RxAMPDUNumHistogram[] is updated)
10138 * 09/18/2008 MHC Create Version 0.
10140 *---------------------------------------------------------------------------*/
10142 UpdateRxAMPDUHistogramStatistics8192S(
10143 struct net_device
*dev
,
10144 struct ieee80211_rx_stats
*stats
10147 //HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
10150 u16 update_size
= 0;
10153 if(stats
->bIsAMPDU
)
10155 if(stats
->bFirstMPDU
)
10157 if(stats
->nRxAMPDU_Size
!=0 && stats
->nRxAMPDU_AggrNum
!=0)
10159 update_size
= stats
->nRxAMPDU_Size
;
10160 update_num
= stats
->nRxAMPDU_AggrNum
;
10162 stats
->nRxAMPDU_Size
= stats
->Length
;
10163 stats
->nRxAMPDU_AggrNum
= 1;
10167 stats
->nRxAMPDU_Size
+= stats
->Length
;
10168 stats
->nRxAMPDU_AggrNum
++;
10173 if(stats
->nRxAMPDU_Size
!=0 && stats
->nRxAMPDU_AggrNum
!=0)
10175 update_size
= stats
->nRxAMPDU_Size
;
10176 update_num
= stats
->nRxAMPDU_AggrNum
;
10178 stats
->nRxAMPDU_Size
= 0;
10179 stats
->nRxAMPDU_AggrNum
= 0;
10182 if(update_size
!=0 && update_num
!= 0)
10184 if(update_size
< 4096)
10186 else if(update_size
< 8192)
10188 else if(update_size
< 16384)
10190 else if(update_size
< 32768)
10192 else if(update_size
< 65536)
10196 RT_TRACE(COMP_RXDESC
,
10197 ("UpdateRxAMPDUHistogramStatistics8192S(): A-MPDU too large\n");
10200 Adapter
->RxStats
.RxAMPDUSizeHistogram
[size_index
]++;
10204 else if(update_num
< 10)
10206 else if(update_num
< 20)
10208 else if(update_num
< 40)
10213 Adapter
->RxStats
.RxAMPDUNumHistogram
[num_index
]++;
10215 } // UpdateRxAMPDUHistogramStatistics8192S
10224 // The strarting address of wireless lan header will shift 1 or 2 or 3 or "more" bytes for the following reason :
10225 // (1) QoS control : shift 2 bytes
10226 // (2) Mesh Network : shift 1 or 3 bytes
10227 // (3) RxDriverInfo occupies the front parts of Rx Packets buffer(shift units is in 8Bytes)
10229 // It is because Lextra CPU used by 8186 or 865x series assert exception if the statrting address
10230 // of IP header is not double word alignment.
10231 // This features is supported in 818xb and 8190 only, but not 818x.
10233 // parameter: PRT_RFD, Pointer of Reeceive frame descriptor which is initialized according to
10235 // return value: unsigned int, number of total shifted bytes
10237 // Notes: 2008/06/28, created by Roger
10239 u32
GetRxPacketShiftBytes8192SU(struct ieee80211_rx_stats
*Status
, bool bIsRxAggrSubframe
)
10241 //PRT_RFD_STATUS pRtRfdStatus = &pRfd->Status;
10243 return (sizeof(rx_desc_819x_usb
) + Status
->RxDrvInfoSize
+ Status
->RxBufShift
);
10246 void rtl8192SU_rx_nomal(struct sk_buff
* skb
)
10248 rtl8192_rx_info
*info
= (struct rtl8192_rx_info
*)skb
->cb
;
10249 struct net_device
*dev
=info
->dev
;
10250 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
10251 struct ieee80211_rx_stats stats
= {
10255 // .mac_time = jiffies,
10256 .freq
= IEEE80211_24GHZ_BAND
,
10258 u32 rx_pkt_len
= 0;
10259 struct ieee80211_hdr_1addr
*ieee80211_hdr
= NULL
;
10260 bool unicast_packet
= false;
10262 //printk("**********skb->len = %d\n", skb->len);
10263 /* 20 is for ps-poll */
10264 if((skb
->len
>=(20 + sizeof(rx_desc_819x_usb
))) && (skb
->len
< RX_URB_SIZE
)) {
10266 /* first packet should not contain Rx aggregation header */
10267 rtl8192SU_query_rxdesc_status(skb
, &stats
, false);
10270 /* hardware related info */
10271 priv
->stats
.rxoktotal
++; //YJ,test,090108
10273 /* Process the MPDU recevied */
10274 skb_trim(skb
, skb
->len
- 4/*sCrcLng*/);//FIXLZM
10276 rx_pkt_len
= skb
->len
;
10277 ieee80211_hdr
= (struct ieee80211_hdr_1addr
*)skb
->data
;
10278 unicast_packet
= false;
10279 if(is_broadcast_ether_addr(ieee80211_hdr
->addr1
)) {
10281 }else if(is_multicast_ether_addr(ieee80211_hdr
->addr1
)){
10284 /* unicast packet */
10285 unicast_packet
= true;
10288 if(!ieee80211_rx(priv
->ieee80211
,skb
, &stats
)) {
10289 dev_kfree_skb_any(skb
);
10291 // priv->stats.rxoktotal++; //YJ,test,090108
10292 if(unicast_packet
) {
10293 priv
->stats
.rxbytesunicast
+= rx_pkt_len
;
10297 //up is firs pkt, follow is next and next
10301 priv
->stats
.rxurberr
++;
10302 printk("actual_length:%d\n", skb
->len
);
10303 dev_kfree_skb_any(skb
);
10308 u32
GetRxPacketShiftBytes819xUsb(struct ieee80211_rx_stats
*Status
, bool bIsRxAggrSubframe
)
10310 return (sizeof(rx_desc_819x_usb
) + Status
->RxDrvInfoSize
10311 + Status
->RxBufShift
);
10314 void rtl8192_rx_nomal(struct sk_buff
* skb
)
10316 rtl8192_rx_info
*info
= (struct rtl8192_rx_info
*)skb
->cb
;
10317 struct net_device
*dev
=info
->dev
;
10318 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
10319 struct ieee80211_rx_stats stats
= {
10323 // .mac_time = jiffies,
10324 .freq
= IEEE80211_24GHZ_BAND
,
10326 u32 rx_pkt_len
= 0;
10327 struct ieee80211_hdr_1addr
*ieee80211_hdr
= NULL
;
10328 bool unicast_packet
= false;
10330 /* 20 is for ps-poll */
10331 if((skb
->len
>=(20 + sizeof(rx_desc_819x_usb
))) && (skb
->len
< RX_URB_SIZE
)) {
10332 /* first packet should not contain Rx aggregation header */
10333 query_rxdesc_status(skb
, &stats
, false);
10335 /* hardware related info */
10336 /* Process the MPDU recevied */
10337 skb_trim(skb
, skb
->len
- 4/*sCrcLng*/);
10339 rx_pkt_len
= skb
->len
;
10340 ieee80211_hdr
= (struct ieee80211_hdr_1addr
*)skb
->data
;
10341 unicast_packet
= false;
10342 if(is_broadcast_ether_addr(ieee80211_hdr
->addr1
)) {
10344 }else if(is_multicast_ether_addr(ieee80211_hdr
->addr1
)){
10347 /* unicast packet */
10348 unicast_packet
= true;
10351 if(!ieee80211_rx(priv
->ieee80211
,skb
, &stats
)) {
10352 dev_kfree_skb_any(skb
);
10354 priv
->stats
.rxoktotal
++;
10355 if(unicast_packet
) {
10356 priv
->stats
.rxbytesunicast
+= rx_pkt_len
;
10360 priv
->stats
.rxurberr
++;
10361 printk("actual_length:%d\n", skb
->len
);
10362 dev_kfree_skb_any(skb
);
10370 rtl819xusb_process_received_packet(
10371 struct net_device
*dev
,
10372 struct ieee80211_rx_stats
*pstats
10375 // bool bfreerfd=false, bqueued=false;
10378 struct r8192_priv
*priv
= ieee80211_priv(dev
);
10382 //PRX_TS_RECORD pts = NULL;
10384 // Get shifted bytes of Starting address of 802.11 header. 2006.09.28, by Emily
10385 //porting by amy 080508
10386 pstats
->virtual_address
+= get_rxpacket_shiftbytes_819xusb(pstats
);
10387 frame
= pstats
->virtual_address
;
10388 frame_len
= pstats
->packetlength
;
10389 #ifdef TODO // by amy about HCT
10390 if(!Adapter
->bInHctTest
)
10391 CountRxErrStatistics(Adapter
, pRfd
);
10394 #ifdef ENABLE_PS //by amy for adding ps function in future
10395 RT_RF_POWER_STATE rtState
;
10396 // When RF is off, we should not count the packet for hw/sw synchronize
10397 // reason, ie. there may be a duration while sw switch is changed and hw
10398 // switch is being changed. 2006.12.04, by shien chang.
10399 Adapter
->HalFunc
.GetHwRegHandler(Adapter
, HW_VAR_RF_STATE
, (u8
* )(&rtState
));
10400 if (rtState
== eRfOff
)
10405 priv
->stats
.rxframgment
++;
10409 RmMonitorSignalStrength(Adapter
, pRfd
);
10411 /* 2007/01/16 MH Add RX command packet handle here. */
10412 /* 2007/03/01 MH We have to release RFD and return if rx pkt is cmd pkt. */
10413 if (rtl819xusb_rx_command_packet(dev
, pstats
))
10418 #ifdef SW_CRC_CHECK
10425 void query_rx_cmdpkt_desc_status(struct sk_buff
*skb
, struct ieee80211_rx_stats
*stats
)
10427 // rtl8192_rx_info *info = (struct rtl8192_rx_info *)skb->cb;
10428 // struct net_device *dev=info->dev;
10429 // struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
10430 rx_desc_819x_usb
*desc
= (rx_desc_819x_usb
*)skb
->data
;
10431 // rx_drvinfo_819x_usb *driver_info;
10434 //Get Rx Descriptor Information
10436 stats
->virtual_address
= (u8
*)skb
->data
;
10437 stats
->Length
= desc
->Length
;
10438 stats
->RxDrvInfoSize
= 0;
10439 stats
->RxBufShift
= 0;
10440 stats
->packetlength
= stats
->Length
-scrclng
;
10441 stats
->fraglength
= stats
->packetlength
;
10442 stats
->fragoffset
= 0;
10443 stats
->ntotalfrag
= 1;
10447 void rtl8192SU_rx_cmd(struct sk_buff
*skb
)
10449 struct rtl8192_rx_info
*info
= (struct rtl8192_rx_info
*)skb
->cb
;
10450 struct net_device
*dev
= info
->dev
;
10453 struct ieee80211_rx_stats stats
= {
10457 // .mac_time = jiffies,
10458 .freq
= IEEE80211_24GHZ_BAND
,
10462 // Check buffer length to determine if this is a valid MPDU.
10464 if( (skb
->len
>= sizeof(rx_desc_819x_usb
)) && (skb
->len
<= RX_URB_SIZE
) )//&&
10465 //(pHalData->SwChnlInProgress == FALSE))
10468 // Collection information in Rx descriptor.
10471 pRxDesc
= pContext
->Buffer
;
10473 pRfd
->Buffer
.VirtualAddress
= pContext
->Buffer
; // 061109, rcnjko, for multi-platform consideration..
10475 pRtRfdStatus
->Length
= (u2Byte
)GET_RX_DESC_PKT_LEN(pRxDesc
);
10476 pRtRfdStatus
->RxDrvInfoSize
= 0;
10477 pRtRfdStatus
->RxBufShift
= 0;
10479 pRfd
->PacketLength
= pRfd
->Status
.Length
- sCrcLng
;
10480 pRfd
->FragLength
= pRfd
->PacketLength
;
10481 pRfd
->FragOffset
= 0;
10482 pRfd
->nTotalFrag
= 1;
10483 pRfd
->queue_id
= PipeIndex
;
10485 query_rx_cmdpkt_desc_status(skb
,&stats
);
10486 // this is to be done by amy 080508 prfd->queue_id = 1;
10489 // Process the MPDU recevied.
10491 rtl819xusb_process_received_packet(dev
,&stats
);
10493 dev_kfree_skb_any(skb
);
10497 //RTInsertTailListWithCnt(&pAdapter->RfdIdleQueue, &pRfd->List, &pAdapter->NumIdleRfd);
10498 //RT_ASSERT(pAdapter->NumIdleRfd <= pAdapter->NumRfd, ("HalUsbInCommandComplete8192SUsb(): Adapter->NumIdleRfd(%d)\n", pAdapter->NumIdleRfd));
10499 //RT_TRACE(COMP_RECV, DBG_LOUD, ("HalUsbInCommandComplete8192SUsb(): NOT enough Resources!! BufLenUsed(%d), NumIdleRfd(%d)\n",
10500 //pContext->BufLenUsed, pAdapter->NumIdleRfd));
10504 // Reuse USB_IN_CONTEXT since we had finished processing the
10505 // buffer in USB_IN_CONTEXT.
10507 //HalUsbReturnInContext(pAdapter, pContext);
10510 // Issue another bulk IN transfer.
10512 //HalUsbInMpdu(pAdapter, PipeIndex);
10514 RT_TRACE(COMP_RECV
, "<--- HalUsbInCommandComplete8192SUsb()\n");
10518 void rtl8192_rx_cmd(struct sk_buff
*skb
)
10520 struct rtl8192_rx_info
*info
= (struct rtl8192_rx_info
*)skb
->cb
;
10521 struct net_device
*dev
= info
->dev
;
10523 // struct urb *rx_urb = info->urb;
10525 struct ieee80211_rx_stats stats
= {
10529 // .mac_time = jiffies,
10530 .freq
= IEEE80211_24GHZ_BAND
,
10533 if((skb
->len
>=(20 + sizeof(rx_desc_819x_usb
))) && (skb
->len
< RX_URB_SIZE
))
10536 query_rx_cmdpkt_desc_status(skb
,&stats
);
10537 // this is to be done by amy 080508 prfd->queue_id = 1;
10541 // Process the command packet received.
10544 rtl819xusb_process_received_packet(dev
,&stats
);
10546 dev_kfree_skb_any(skb
);
10553 desc
= (u32
*)(skb
->data
);
10554 cmd
= (desc
[0] >> 30) & 0x03;
10556 if(cmd
== 0x00) {//beacon interrupt
10557 //send beacon packet
10558 skb
= ieee80211_get_beacon(priv
->ieee80211
);
10561 DMESG("not enought memory for allocating beacon");
10564 skb
->cb
[0] = BEACON_PRIORITY
;
10566 skb
->cb
[2] = ieeerate2rtlrate(priv
->ieee80211
->basic_rate
);
10567 ret
= rtl8192_tx(dev
, skb
);
10570 printk(KERN_ALERT
"tx beacon packet error : %d !\n", ret
);
10572 dev_kfree_skb_any(skb
);
10574 //{ log the device information
10575 // At present, It is not implemented just now.
10582 void rtl8192_irq_rx_tasklet(struct r8192_priv
*priv
)
10584 struct sk_buff
*skb
;
10585 struct rtl8192_rx_info
*info
;
10587 while (NULL
!= (skb
= skb_dequeue(&priv
->skb_queue
))) {
10588 info
= (struct rtl8192_rx_info
*)skb
->cb
;
10589 switch (info
->out_pipe
) {
10590 /* Nomal packet pipe */
10592 //RT_TRACE(COMP_RECV, "normal in-pipe index(%d)\n",info->out_pipe);
10593 priv
->IrpPendingCount
--;
10594 priv
->ops
->rtl819x_rx_nomal(skb
);
10597 /* Command packet pipe */
10599 RT_TRACE(COMP_RECV
, "command in-pipe index(%d)\n",\
10601 priv
->ops
->rtl819x_rx_cmd(skb
);
10604 default: /* should never get here! */
10605 RT_TRACE(COMP_ERR
, "Unknown in-pipe index(%d)\n",\
10607 dev_kfree_skb(skb
);
10616 /****************************************************************************
10617 ---------------------------- USB_STUFF---------------------------
10618 *****************************************************************************/
10619 //LZM Merge from windows HalUsbSetQueuePipeMapping8192SUsb 090319
10620 static void HalUsbSetQueuePipeMapping8192SUsb(struct usb_interface
*intf
, struct net_device
*dev
)
10622 struct r8192_priv
*priv
= ieee80211_priv(dev
);
10623 struct usb_host_interface
*iface_desc
;
10624 struct usb_endpoint_descriptor
*endpoint
;
10627 priv
->ep_in_num
= 0;
10628 priv
->ep_out_num
= 0;
10629 memset(priv
->RtOutPipes
,0,16);
10630 memset(priv
->RtInPipes
,0,16);
10632 iface_desc
= intf
->cur_altsetting
;
10633 priv
->ep_num
= iface_desc
->desc
.bNumEndpoints
;
10635 for (i
= 0; i
< priv
->ep_num
; ++i
) {
10636 endpoint
= &iface_desc
->endpoint
[i
].desc
;
10637 if (usb_endpoint_is_bulk_in(endpoint
)) {
10638 priv
->RtInPipes
[priv
->ep_in_num
] = usb_endpoint_num(endpoint
);
10639 priv
->ep_in_num
++;
10640 //printk("in_endpoint_idx = %d\n", usb_endpoint_num(endpoint));
10641 } else if (usb_endpoint_is_bulk_out(endpoint
)) {
10642 priv
->RtOutPipes
[priv
->ep_out_num
] = usb_endpoint_num(endpoint
);
10643 priv
->ep_out_num
++;
10644 //printk("out_endpoint_idx = %d\n", usb_endpoint_num(endpoint));
10648 memset(priv
->txqueue_to_outpipemap
,0,9);
10649 if (priv
->ep_num
== 6) {
10650 // BK, BE, VI, VO, HCCA, TXCMD, MGNT, HIGH, BEACON
10651 u8 queuetopipe
[] = {3, 2, 1, 0, 4, 4, 4, 4, 4};
10653 memcpy(priv
->txqueue_to_outpipemap
,queuetopipe
,9);
10654 } else if (priv
->ep_num
== 4) {
10655 // BK, BE, VI, VO, HCCA, TXCMD, MGNT, HIGH, BEACON
10656 u8 queuetopipe
[] = {1, 1, 0, 0, 2, 2, 2, 2, 2};
10658 memcpy(priv
->txqueue_to_outpipemap
,queuetopipe
,9);
10659 } else if (priv
->ep_num
> 9) {
10660 // BK, BE, VI, VO, HCCA, TXCMD, MGNT, HIGH, BEACON
10661 u8 queuetopipe
[] = {3, 2, 1, 0, 4, 8, 7, 6, 5};
10663 memcpy(priv
->txqueue_to_outpipemap
,queuetopipe
,9);
10664 } else {//use sigle pipe
10665 // BK, BE, VI, VO, HCCA, TXCMD, MGNT, HIGH, BEACON
10666 u8 queuetopipe
[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
10667 memcpy(priv
->txqueue_to_outpipemap
,queuetopipe
,9);
10670 printk("==>ep_num:%d, in_ep_num:%d, out_ep_num:%d\n", priv
->ep_num
, priv
->ep_in_num
, priv
->ep_out_num
);
10672 printk("==>RtInPipes:");
10673 for(i
=0; i
< priv
->ep_in_num
; i
++)
10674 printk("%d ", priv
->RtInPipes
[i
]);
10677 printk("==>RtOutPipes:");
10678 for(i
=0; i
< priv
->ep_out_num
; i
++)
10679 printk("%d ", priv
->RtOutPipes
[i
]);
10682 printk("==>txqueue_to_outpipemap for BK, BE, VI, VO, HCCA, TXCMD, MGNT, HIGH, BEACON:\n");
10683 for(i
=0; i
< 9; i
++)
10684 printk("%d ", priv
->txqueue_to_outpipemap
[i
]);
10690 static const struct net_device_ops rtl8192_netdev_ops
= {
10691 .ndo_open
= rtl8192_open
,
10692 .ndo_stop
= rtl8192_close
,
10693 .ndo_get_stats
= rtl8192_stats
,
10694 .ndo_tx_timeout
= tx_timeout
,
10695 .ndo_do_ioctl
= rtl8192_ioctl
,
10696 .ndo_set_multicast_list
= r8192_set_multicast
,
10697 .ndo_set_mac_address
= r8192_set_mac_adr
,
10698 .ndo_validate_addr
= eth_validate_addr
,
10699 .ndo_change_mtu
= eth_change_mtu
,
10700 .ndo_start_xmit
= rtl8192_ieee80211_xmit
,
10703 static int __devinit
rtl8192_usb_probe(struct usb_interface
*intf
,
10704 const struct usb_device_id
*id
)
10706 // unsigned long ioaddr = 0;
10707 struct net_device
*dev
= NULL
;
10708 struct r8192_priv
*priv
= NULL
;
10709 struct usb_device
*udev
= interface_to_usbdev(intf
);
10711 RT_TRACE(COMP_INIT
, "Oops: i'm coming\n");
10713 dev
= alloc_ieee80211(sizeof(struct r8192_priv
));
10715 usb_set_intfdata(intf
, dev
);
10716 SET_NETDEV_DEV(dev
, &intf
->dev
);
10717 priv
= ieee80211_priv(dev
);
10718 priv
->ieee80211
= netdev_priv(dev
);
10722 HalUsbSetQueuePipeMapping8192SUsb(intf
, dev
);
10726 //printk("===============>NIC 8192SU\n");
10727 priv
->ops
= &rtl8192su_ops
;
10729 //printk("===============>NIC 8192U\n");
10730 priv
->ops
= &rtl8192u_ops
;
10733 dev
->netdev_ops
= &rtl8192_netdev_ops
;
10735 //DMESG("Oops: i'm coming\n");
10736 dev
->wireless_handlers
= (struct iw_handler_def
*) &r8192_wx_handlers_def
;
10738 dev
->type
=ARPHRD_ETHER
;
10740 dev
->watchdog_timeo
= HZ
*3; //modified by john, 0805
10742 if (dev_alloc_name(dev
, ifname
) < 0){
10743 RT_TRACE(COMP_INIT
, "Oops: devname already taken! Trying wlan%%d...\n");
10745 dev_alloc_name(dev
, ifname
);
10748 RT_TRACE(COMP_INIT
, "Driver probe completed1\n");
10750 if(rtl8192_init(dev
)!=0){
10751 RT_TRACE(COMP_ERR
, "Initialization failed");
10755 netif_carrier_off(dev
);
10756 netif_stop_queue(dev
);
10758 register_netdev(dev
);
10759 RT_TRACE(COMP_INIT
, "dev name=======> %s\n",dev
->name
);
10760 rtl8192_proc_init_one(dev
);
10763 RT_TRACE(COMP_INIT
, "Driver probe completed\n");
10766 free_ieee80211(dev
);
10768 RT_TRACE(COMP_ERR
, "wlan driver load failed\n");
10772 //detach all the work and timer structure declared or inititialize in r8192U_init function.
10773 void rtl8192_cancel_deferred_work(struct r8192_priv
* priv
)
10775 cancel_work_sync(&priv
->reset_wq
);
10776 cancel_work_sync(&priv
->qos_activate
);
10777 cancel_delayed_work(&priv
->watch_dog_wq
);
10778 cancel_delayed_work(&priv
->update_beacon_wq
);
10779 cancel_delayed_work(&priv
->ieee80211
->hw_wakeup_wq
);
10780 cancel_delayed_work(&priv
->ieee80211
->hw_sleep_wq
);
10781 //cancel_work_sync(&priv->SetBWModeWorkItem);
10782 //cancel_work_sync(&priv->SwChnlWorkItem);
10785 static void __devexit
rtl8192_usb_disconnect(struct usb_interface
*intf
)
10787 struct net_device
*dev
= usb_get_intfdata(intf
);
10788 struct r8192_priv
*priv
= ieee80211_priv(dev
);
10791 unregister_netdev(dev
);
10793 RT_TRACE(COMP_DOWN
, "=============>wlan driver to be removed\n");
10794 rtl8192_proc_remove_one(dev
);
10797 if (priv
->pFirmware
)
10799 vfree(priv
->pFirmware
);
10800 priv
->pFirmware
= NULL
;
10802 // priv->rf_close(dev);
10803 // rtl8192_SetRFPowerState(dev, eRfOff);
10804 destroy_workqueue(priv
->priv_wq
);
10805 //rtl8192_irq_disable(dev);
10806 //rtl8192_reset(dev);
10810 free_ieee80211(dev
);
10811 RT_TRACE(COMP_DOWN
, "wlan driver removed\n");
10814 static int __init
rtl8192_usb_module_init(void)
10816 printk(KERN_INFO
"\nLinux kernel driver for RTL8192 based WLAN cards\n");
10817 printk(KERN_INFO
"Copyright (c) 2007-2008, Realsil Wlan\n");
10818 RT_TRACE(COMP_INIT
, "Initializing module");
10819 RT_TRACE(COMP_INIT
, "Wireless extensions version %d", WIRELESS_EXT
);
10820 rtl8192_proc_module_init();
10821 return usb_register(&rtl8192_usb_driver
);
10825 static void __exit
rtl8192_usb_module_exit(void)
10827 usb_deregister(&rtl8192_usb_driver
);
10829 RT_TRACE(COMP_DOWN
, "Exiting");
10830 rtl8192_proc_module_remove();
10834 void rtl8192_try_wake_queue(struct net_device
*dev
, int pri
)
10836 unsigned long flags
;
10838 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
10840 spin_lock_irqsave(&priv
->tx_lock
,flags
);
10841 enough_desc
= check_nic_enough_desc(dev
,pri
);
10842 spin_unlock_irqrestore(&priv
->tx_lock
,flags
);
10845 ieee80211_wake_queue(priv
->ieee80211
);
10849 void DisableHWSecurityConfig8192SUsb(struct net_device
*dev
)
10851 u8 SECR_value
= 0x0;
10852 write_nic_byte(dev
, SECR
, SECR_value
);//SECR_value | SCR_UseDK );
10856 void EnableHWSecurityConfig8192(struct net_device
*dev
)
10858 u8 SECR_value
= 0x0;
10859 struct r8192_priv
*priv
= (struct r8192_priv
*)ieee80211_priv(dev
);
10860 struct ieee80211_device
* ieee
= priv
->ieee80211
;
10862 SECR_value
= SCR_TxEncEnable
| SCR_RxDecEnable
;
10864 if (((KEY_TYPE_WEP40
== ieee
->pairwise_key_type
) || (KEY_TYPE_WEP104
== ieee
->pairwise_key_type
)) && (priv
->ieee80211
->auth_mode
!= 2))
10866 SECR_value
|= SCR_RxUseDK
;
10867 SECR_value
|= SCR_TxUseDK
;
10869 else if ((ieee
->iw_mode
== IW_MODE_ADHOC
) && (ieee
->pairwise_key_type
& (KEY_TYPE_CCMP
| KEY_TYPE_TKIP
)))
10871 SECR_value
|= SCR_RxUseDK
;
10872 SECR_value
|= SCR_TxUseDK
;
10875 //add HWSec active enable here.
10876 //default using hwsec. when peer AP is in N mode only and pairwise_key_type is none_aes(which HT_IOT_ACT_PURE_N_MODE indicates it), use software security. when peer AP is in b,g,n mode mixed and pairwise_key_type is none_aes, use g mode hw security. WB on 2008.7.4
10878 ieee
->hwsec_active
= 1;
10880 if ((ieee
->pHTInfo
->IOTAction
&HT_IOT_ACT_PURE_N_MODE
) || !hwwep
)//!ieee->hwsec_support) //add hwsec_support flag to totol control hw_sec on/off
10882 ieee
->hwsec_active
= 0;
10883 SECR_value
&= ~SCR_RxDecEnable
;
10886 RT_TRACE(COMP_SEC
,"%s:, hwsec:%d, pairwise_key:%d, SECR_value:%x\n", __FUNCTION__
, \
10887 ieee
->hwsec_active
, ieee
->pairwise_key_type
, SECR_value
);
10889 write_nic_byte(dev
, SECR
, SECR_value
);//SECR_value | SCR_UseDK );
10894 void setKey( struct net_device
*dev
,
10902 u32 TargetCommand
= 0;
10903 u32 TargetContent
= 0;
10906 if (EntryNo
>= TOTAL_CAM_ENTRY
)
10907 RT_TRACE(COMP_ERR
, "cam entry exceeds in setKey()\n");
10909 RT_TRACE(COMP_SEC
, "====>to setKey(), dev:%p, EntryNo:%d, KeyIndex:%d, KeyType:%d, MacAddr"MAC_FMT
"\n", dev
,EntryNo
, KeyIndex
, KeyType
, MAC_ARG(MacAddr
));
10912 usConfig
|= BIT15
| (KeyType
<<2);
10914 usConfig
|= BIT15
| (KeyType
<<2) | KeyIndex
;
10915 // usConfig |= BIT15 | (KeyType<<2) | (DefaultKey<<5) | KeyIndex;
10918 for(i
=0 ; i
<CAM_CONTENT_COUNT
; i
++){
10919 TargetCommand
= i
+CAM_CONTENT_COUNT
*EntryNo
;
10920 TargetCommand
|= BIT31
|BIT16
;
10922 if(i
==0){//MAC|Config
10923 TargetContent
= (u32
)(*(MacAddr
+0)) << 16|
10924 (u32
)(*(MacAddr
+1)) << 24|
10927 write_nic_dword(dev
, WCAMI
, TargetContent
);
10928 write_nic_dword(dev
, RWCAM
, TargetCommand
);
10929 // printk("setkey cam =%8x\n", read_cam(dev, i+6*EntryNo));
10931 else if(i
==1){//MAC
10932 TargetContent
= (u32
)(*(MacAddr
+2)) |
10933 (u32
)(*(MacAddr
+3)) << 8|
10934 (u32
)(*(MacAddr
+4)) << 16|
10935 (u32
)(*(MacAddr
+5)) << 24;
10936 write_nic_dword(dev
, WCAMI
, TargetContent
);
10937 write_nic_dword(dev
, RWCAM
, TargetCommand
);
10941 if(KeyContent
!=NULL
){
10942 write_nic_dword(dev
, WCAMI
, (u32
)(*(KeyContent
+i
-2)) );
10943 write_nic_dword(dev
, RWCAM
, TargetCommand
);
10950 /***************************************************************************
10951 ------------------- module init / exit stubs ----------------
10952 ****************************************************************************/
10953 module_init(rtl8192_usb_module_init
);
10954 module_exit(rtl8192_usb_module_exit
);