All of lore.kernel.org
 help / color / mirror / Atom feed
* 3.1-rc6+ rtl8192se issue
@ 2011-09-15 12:44 Borislav Petkov
  2011-09-15 15:23 ` Larry Finger
  0 siblings, 1 reply; 16+ messages in thread
From: Borislav Petkov @ 2011-09-15 12:44 UTC (permalink / raw)
  To: Larry Finger; +Cc: linux-wireless, LKML

[-- Attachment #1: Type: text/plain, Size: 1037 bytes --]

Hi Larry,

I'm experiencing an issue with rtl8192se since 3.1-ish timeframe where
the machine becomes completely unresponsive and only a reboot helps
the situation. I think the issue has to do with the rtl8192se wireless
driver because if I connect the machine through ethernet, it runs pretty
smoothly.

Today, I left the machine on the vt console in the expectation of an
oops or something to appear in the logs and logged into it from another
machine over ssh.

After a while, the unresponsiveness happened and the box didn't
react to keyboard input except sysrq with which I was able to do the
show-backtrace-all-active-cpus(L) thing and attached is a partial
screen cap of that. It looks like the stuck-up happens somewhere in
rtl_lps_leave() along the rtl92s_phy_set_rf_power_state() path but the
register dump is missing with the exact %rIP.

Anyway, pls take a look and let me know if it rings any bells. I'll
continue trying to debug the issue, maybe I should bisect it if nothing
else pops up.

TIA.

-- 
Regards/Gruss,
Boris.

[-- Attachment #2: IMG10076.jpg --]
[-- Type: image/jpeg, Size: 674313 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: 3.1-rc6+ rtl8192se issue
  2011-09-15 12:44 3.1-rc6+ rtl8192se issue Borislav Petkov
@ 2011-09-15 15:23 ` Larry Finger
  2011-09-15 18:41   ` Borislav Petkov
  2011-09-16 18:03   ` Borislav Petkov
  0 siblings, 2 replies; 16+ messages in thread
From: Larry Finger @ 2011-09-15 15:23 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: linux-wireless, LKML, 'Chaoming_Li'

On 09/15/2011 07:44 AM, Borislav Petkov wrote:
> Hi Larry,
>
> I'm experiencing an issue with rtl8192se since 3.1-ish timeframe where
> the machine becomes completely unresponsive and only a reboot helps
> the situation. I think the issue has to do with the rtl8192se wireless
> driver because if I connect the machine through ethernet, it runs pretty
> smoothly.
>
> Today, I left the machine on the vt console in the expectation of an
> oops or something to appear in the logs and logged into it from another
> machine over ssh.
>
> After a while, the unresponsiveness happened and the box didn't
> react to keyboard input except sysrq with which I was able to do the
> show-backtrace-all-active-cpus(L) thing and attached is a partial
> screen cap of that. It looks like the stuck-up happens somewhere in
> rtl_lps_leave() along the rtl92s_phy_set_rf_power_state() path but the
> register dump is missing with the exact %rIP.
>
> Anyway, pls take a look and let me know if it rings any bells. I'll
> continue trying to debug the issue, maybe I should bisect it if nothing
> else pops up.

Borislav,

Thanks for the report. I have been running rtl8192se for the past few days and I 
have also noticed two such system freezes, but not been able to capture any 
info. As I have recently made many changes in my system recently, I did not know 
what might be the cause, but rtl8192se is certainly on the suspect list.

I have added Chaoming Li to the Cc list. I will send him the screen photo 
separately.

Some questions:

I expect that you are running a mainline kernel from Linus's tree. If not, 
please let me know. Mine is 3.1-rc4 from the wireless-testing tree. I don't 
recall any changes in out "next-flavored" version that are not in 3.1.

Which flavor of RTL8192SE card do you have? The one I'm running shows as 
"Realtek Semiconductor Co., Ltd. RTL8191SEvB Wireless LAN Controller [10ec:8172] 
(rev 10)", but I have two others. The differences are in the number of TX and RX 
streams. Mine is the 1x2 variety.

How frequently do your freezes occur? As I said before, I have only had two in 2 
or 3 days, which would make bisection tricky.

I see from the dump that you have x86_64 architecture. How many CPUs and how 
fast? There is one questionable report of problems on a box with an 8-way fast 
processor. That was on initialization and is not the same, but may indicate a 
problem. My system has a dual AMD CPU at 2.0 GHz.

Would you also try loading rtl8192se with the "ips=0" option? As power save is 
implicated in your traceback, that may help. I will be trying "swlps=0 ips=0".

Thanks for the report,

Larry

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: 3.1-rc6+ rtl8192se issue
  2011-09-15 15:23 ` Larry Finger
@ 2011-09-15 18:41   ` Borislav Petkov
  2011-09-16 18:03   ` Borislav Petkov
  1 sibling, 0 replies; 16+ messages in thread
From: Borislav Petkov @ 2011-09-15 18:41 UTC (permalink / raw)
  To: Larry Finger; +Cc: linux-wireless, LKML, 'Chaoming_Li'

On Thu, Sep 15, 2011 at 10:23:29AM -0500, Larry Finger wrote:
> Thanks for the report. I have been running rtl8192se for the past
> few days and I have also noticed two such system freezes, but not

Ah ok, so it's not only me seeing this.

> I expect that you are running a mainline kernel from Linus's tree.

It is Linus' tree: v3.1-rc6-10-g003f6c9

> If not, please let me know. Mine is 3.1-rc4 from the
> wireless-testing tree. I don't recall any changes in out
> "next-flavored" version that are not in 3.1.
> 
> Which flavor of RTL8192SE card do you have? The one I'm running
> shows as "Realtek Semiconductor Co., Ltd. RTL8191SEvB Wireless LAN
> Controller [10ec:8172] (rev 10)", but I have two others. The
> differences are in the number of TX and RX streams. Mine is the 1x2
> variety.

lspci says:

03:00.0 Network controller [0280]: Realtek Semiconductor Co., Ltd. RTL8191SEvB Wireless LAN Controller [10ec:8172] (rev 10)

so it is exactly the same as yours.

> How frequently do your freezes occur? As I said before, I have only
> had two in 2 or 3 days, which would make bisection tricky.

Well, I can reproduce it pretty reliably: it happens shortly after I
up the iface and establish the WIFI connection with wpa_supplicant. A
couple of minutes after that, more or less, the box grinds down to a
halt.

> I see from the dump that you have x86_64 architecture. How many CPUs
> and how fast? There is one questionable report of problems on a box
> with an 8-way fast processor. That was on initialization and is not
> the same, but may indicate a problem. My system has a dual AMD CPU
> at 2.0 GHz.

I don't think that has any effect on the wifi iface but here it is: dual
core K8 laptop:

...
processor       : 1
vendor_id       : AuthenticAMD
cpu family      : 15
model           : 107
model name      : AMD Turion(tm) Neo X2 Dual Core Processor L625
stepping        : 2
cpu MHz         : 800.000

this is of cource the lowest P-state freq - P0 is 1.6GHz.

> Would you also try loading rtl8192se with the "ips=0" option? As
> power save is implicated in your traceback, that may help. I will be
> trying "swlps=0 ips=0".

Ok, I'll run both just in case and let you know.

Thanks for looking into this.

-- 
Regards/Gruss,
Boris.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: 3.1-rc6+ rtl8192se issue
  2011-09-15 15:23 ` Larry Finger
  2011-09-15 18:41   ` Borislav Petkov
@ 2011-09-16 18:03   ` Borislav Petkov
       [not found]     ` <CD4D8CF16C39438E82FE8241C9AF80F4@realsil.com.cn>
  1 sibling, 1 reply; 16+ messages in thread
From: Borislav Petkov @ 2011-09-16 18:03 UTC (permalink / raw)
  To: Larry Finger; +Cc: linux-wireless, LKML, 'Chaoming_Li'

On Thu, Sep 15, 2011 at 10:23:29AM -0500, Larry Finger wrote:
> Would you also try loading rtl8192se with the "ips=0" option? As power
> save is implicated in your traceback, that may help. I will be trying
> "swlps=0 ips=0".

Ok, "ips=0" seems to fix the issue ... almost. I say, almost because I
had only one hang so far for running the box for a day today. Will try
together with "swlps=0" next week.

Thanks.

-- 
Regards/Gruss,
Boris.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: 答复: 3.1-rc6+ rtl8192se issue
       [not found]     ` <CD4D8CF16C39438E82FE8241C9AF80F4@realsil.com.cn>
@ 2011-09-19  9:54       ` Borislav Petkov
  2011-09-19 17:13       ` Borislav Petkov
  2011-09-21 18:58       ` Borislav Petkov
  2 siblings, 0 replies; 16+ messages in thread
From: Borislav Petkov @ 2011-09-19  9:54 UTC (permalink / raw)
  To: 李朝明
  Cc: 'Larry Finger', linux-wireless, 'LKML'

On Mon, Sep 19, 2011 at 12:43:45PM +0800, 李朝明 wrote:
> Dear sir:
> 
> 	Can you give me the screen pcitrue after crash again with ips = 0;
> or swlps=0 ips=0.
> 	Thank you!

I just started a "swlps=0 ips=0" test and will try to capture something
if the slowdown happens again - I can't promise you a whole stack trace
because the sysrq output doesn't fit on the screen fully...

Stay tuned.

-- 
Regards/Gruss,
Boris.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: 答复: 3.1-rc6+ rtl8192se issue
       [not found]     ` <CD4D8CF16C39438E82FE8241C9AF80F4@realsil.com.cn>
  2011-09-19  9:54       ` 答复: " Borislav Petkov
@ 2011-09-19 17:13       ` Borislav Petkov
  2011-09-21 18:58       ` Borislav Petkov
  2 siblings, 0 replies; 16+ messages in thread
From: Borislav Petkov @ 2011-09-19 17:13 UTC (permalink / raw)
  To: 李朝明
  Cc: 'Larry Finger', linux-wireless, 'LKML'

On Mon, Sep 19, 2011 at 12:43:45PM +0800, 李朝明 wrote:
> Dear sir:
> 
> 	Can you give me the screen pcitrue after crash again with ips = 0;
> or swlps=0 ips=0.

FWIW,

the box has been running stable a whole workday today with "swlps=0
ips=0" I'll run it only with "ips=0" tomorrow to try the reproduce the
sluggishness again.

Thanks.

-- 
Regards/Gruss,
Boris.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: 答复: 3.1-rc6+ rtl8192se issue
       [not found]     ` <CD4D8CF16C39438E82FE8241C9AF80F4@realsil.com.cn>
  2011-09-19  9:54       ` 答复: " Borislav Petkov
  2011-09-19 17:13       ` Borislav Petkov
@ 2011-09-21 18:58       ` Borislav Petkov
       [not found]         ` <791179BCE62F4954AB936E6CAC9CA977@realsil.com.cn>
  2 siblings, 1 reply; 16+ messages in thread
From: Borislav Petkov @ 2011-09-21 18:58 UTC (permalink / raw)
  To: 李朝明
  Cc: 'Larry Finger', linux-wireless, 'LKML'

[-- Attachment #1: Type: text/plain, Size: 362 bytes --]

On Mon, Sep 19, 2011 at 12:43:45PM +0800, 李朝明 wrote:
> Dear sir:
> 
> 	Can you give me the screen pcitrue after crash again with ips = 0;
> or swlps=0 ips=0.

Ok, I was able to catch a partial trace with "ips=0" Still, the full
call trace is visible and points at rtlwifi:rtl_lps_leave. Shot is
attached.

I really HTH.

Thanks.

-- 
Regards/Gruss,
Boris.

[-- Attachment #2: IMG10081.jpg --]
[-- Type: image/jpeg, Size: 651226 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: 答复: 答复: 3.1-rc6+ rtl8192se issue
       [not found]           ` <4E7AAB8B.40900@lwfinger.net>
@ 2011-09-22  7:51             ` Borislav Petkov
       [not found]               ` <6452E68488784D0EA32E4BDF1B941EFB@realsil.com.cn>
  0 siblings, 1 reply; 16+ messages in thread
From: Borislav Petkov @ 2011-09-22  7:51 UTC (permalink / raw)
  To: Larry Finger; +Cc: 李朝明, linux-wireless, 'LKML'

On Wed, Sep 21, 2011 at 10:29:15PM -0500, Larry Finger wrote:
> On 09/21/2011 08:24 PM, 李朝明 wrote:
> > Dear Sir:
> > 
> > 	I can't find _rtl_pci_lps_leave_tasklet in my driver, So I want to
> > kown which driver did you use.
> > 	Would you like to try this new driver with ips =0 and lps = 0, or
> > some combination of these two functions.
> 
> It is not in my driver either. Where did that driver come from?

That's actually _rtl_pci_ips_leave_tasklet with an "i"
in "_ips_" and it is a wrapper around rtl_lps_leave() in
<drivers/net/wireless/rtlwifi/pci.c>

Basically, that's the tasklet handler for ips_leave_tasklet regged in
_rtl_pci_init_struct():

        tasklet_init(&rtlpriv->works.ips_leave_tasklet,
                     (void (*)(unsigned long))_rtl_pci_ips_leave_tasklet,
                     (unsigned long)hw);


The sluggishness is consistent with the tasklet choking on something,
from looking at rtl_lps_leave() it grabs some spinlocks and then enables
IRQs in the middle of it with a very explanatory comment /* FIXME */
ontop of it which looks very suspicious to me:

/*Leave the leisure power save mode.*/
void rtl_lps_leave(struct ieee80211_hw *hw)
{
        struct rtl_priv *rtlpriv = rtl_priv(hw);
        struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
        struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));

        spin_lock(&rtlpriv->locks.lps_lock);

        if (ppsc->fwctrl_lps) {
                if (ppsc->dot11_psmode != EACTIVE) {

                        /*FIX ME */
                        rtlpriv->cfg->ops->enable_interrupt(hw);
...

But since I don't know anything about networking drivers, I'm actually
hoping that you guys could have an idea here.

HTH.

-- 
Regards/Gruss,
    Boris.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: 答复: 答复: 答复: 3.1-rc6+ rtl8192se issue
       [not found]               ` <6452E68488784D0EA32E4BDF1B941EFB@realsil.com.cn>
@ 2011-09-23 10:33                 ` Borislav Petkov
  2011-09-23 13:50                   ` Larry Finger
  2011-09-23 16:34                   ` Larry Finger
  0 siblings, 2 replies; 16+ messages in thread
From: Borislav Petkov @ 2011-09-23 10:33 UTC (permalink / raw)
  To: 李朝明
  Cc: 'Larry Finger', linux-wireless, 'LKML'

On Fri, Sep 23, 2011 at 06:21:07PM +0800, 李朝明 wrote:
> Please set ips =0 and try again..

What does that mean?

I can trigger the grinding-to-a-halt reliably with "ips=0" - it only
takes a couple of hours of network traffic. Also, I don't want to try
the driver you sent me because the version in the kernel needs fixing
not some out-of-tree codebase.

So please clarify your request.

Thanks.

-- 
Regards/Gruss,
Boris.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: 答复: 答复: 答复: 3.1-rc6+ rtl8192se issue
  2011-09-23 10:33                 ` 答复: " Borislav Petkov
@ 2011-09-23 13:50                   ` Larry Finger
  2011-09-23 16:34                   ` Larry Finger
  1 sibling, 0 replies; 16+ messages in thread
From: Larry Finger @ 2011-09-23 13:50 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: 李朝明, linux-wireless, 'LKML'

On 09/23/2011 05:33 AM, Borislav Petkov wrote:
> On Fri, Sep 23, 2011 at 06:21:07PM +0800, 李朝明 wrote:
>> Please set ips =0 and try again..
>
> What does that mean?
>
> I can trigger the grinding-to-a-halt reliably with "ips=0" - it only
> takes a couple of hours of network traffic. Also, I don't want to try
> the driver you sent me because the version in the kernel needs fixing
> not some out-of-tree codebase.

Does the likelihood of the failure change when "ips=0" is used?

The Realtek group made several changes in the driver that Chaoming sent you that 
have not yet been incorporated in the kernel version. If you test that driver, 
we might learn if any of them are important to your problem. As neither of us 
can duplicate your results, it is not possible for us to do those tests.

I agree that we want to fix the kernel version. It is unfortunate that Realtek 
does not generate their improvements as patches to that kernel version, and 
publish them that way, but that is a fact of life. When they produce a new 
version, I have to look at the diff file between it and the previous version and 
test those differences with my devices. Thus far, there have been no changes 
that have any effect on my system, but who knows on yours. Please run the test 
as Chaoming asked you to do.

Thanks,

Larry

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: 答复: 答复: 答复: 3.1-rc6+ rtl8192se issue
  2011-09-23 10:33                 ` 答复: " Borislav Petkov
  2011-09-23 13:50                   ` Larry Finger
@ 2011-09-23 16:34                   ` Larry Finger
  2011-09-28 13:18                     ` Borislav Petkov
  1 sibling, 1 reply; 16+ messages in thread
From: Larry Finger @ 2011-09-23 16:34 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: 李朝明, linux-wireless, 'LKML'

[-- Attachment #1: Type: text/plain, Size: 1304 bytes --]

On 09/23/2011 05:33 AM, Borislav Petkov wrote:
> On Fri, Sep 23, 2011 at 06:21:07PM +0800, 李朝明 wrote:
>> Please set ips =0 and try again..
>
> What does that mean?
>
> I can trigger the grinding-to-a-halt reliably with "ips=0" - it only
> takes a couple of hours of network traffic. Also, I don't want to try
> the driver you sent me because the version in the kernel needs fixing
> not some out-of-tree codebase.

I got a chance to review the rtl8192se part of the changes in that 08/16/2011 
version. Attached is a patch to update the kernel version.

A prerequisite is:

commit da3ba88a9996cd64c6768bed5727e02da81e2c8d
Author: Larry Finger <Larry.Finger@lwfinger.net>
Date:   Mon Sep 19 14:34:10 2011 -0500

     rtlwifi: Combine instances of RTL_HAL_IS_CCK_RATE macros.

     Three drivers, rtl8192ce, rtl8192cu and rtl8192de, use the same macro
     to check if a particular rate is in the CCK set. This common code is
     relocated to a common header file. A distinct macro used by rtl8192se
     with the same name is renamed.

     Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
     Signed-off-by: John W. Linville <linville@tuxdriver.com>

I have run the new version for a couple of hours without problems. Perhaps it 
will cure your difficulty, but I am not optimistic.

Larry

[-- Attachment #2: rtl8192se_reg_en --]
[-- Type: text/plain, Size: 9033 bytes --]

From: Chaoming Li <chaoming_li@realsil.com.cn>

This patch incorporate the differences between the 06/20/2011 and
08/16/2011 Realtek releases of the rtl8192se driver.

The changes include:

1. Fixing some typos in register usage.
2. A change in the handling of decryption status for 802.11w packets.

Signed-off-by: Chaoming Li <chaoming_li@realsil.com.cn>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
---

Index: wireless-testing-new/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
===================================================================
--- wireless-testing-new.orig/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
+++ wireless-testing-new/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
@@ -1382,7 +1382,7 @@ static void _rtl92se_power_domain_init(s
 	rtl_write_byte(rtlpriv, LDOA15_CTRL, 0x34);
 
 	/* Reset MAC-IO and CPU and Core Digital BIT10/11/15 */
-	tmpu1b = rtl_read_byte(rtlpriv, SYS_FUNC_EN + 1);
+	tmpu1b = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1);
 
 	/* If IPS we need to turn LED on. So we not
 	 * not disable BIT 3/7 of reg3. */
@@ -1391,7 +1391,7 @@ static void _rtl92se_power_domain_init(s
 	else
 		tmpu1b &= 0x73;
 
-	rtl_write_byte(rtlpriv, SYS_FUNC_EN + 1, tmpu1b);
+	rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, tmpu1b);
 	/* wait for BIT 10/11/15 to pull high automatically!! */
 	mdelay(1);
 
@@ -1428,15 +1428,15 @@ static void _rtl92se_power_domain_init(s
 	rtl_write_byte(rtlpriv, LDOA15_CTRL, (tmpu1b | BIT(0)));
 
 	/* Set Digital Vdd to Retention isolation Path. */
-	tmpu2b = rtl_read_word(rtlpriv, SYS_ISO_CTRL);
-	rtl_write_word(rtlpriv, SYS_ISO_CTRL, (tmpu2b | BIT(11)));
+	tmpu2b = rtl_read_word(rtlpriv, REG_SYS_ISO_CTRL);
+	rtl_write_word(rtlpriv, REG_SYS_ISO_CTRL, (tmpu2b | BIT(11)));
 
 
 	/* For warm reboot NIC disappera bug. */
-	tmpu2b = rtl_read_word(rtlpriv, SYS_FUNC_EN);
-	rtl_write_word(rtlpriv, SYS_FUNC_EN, (tmpu2b | BIT(13)));
+	tmpu2b = rtl_read_word(rtlpriv, REG_SYS_FUNC_EN);
+	rtl_write_word(rtlpriv, REG_SYS_FUNC_EN, (tmpu2b | BIT(13)));
 
-	rtl_write_byte(rtlpriv, SYS_ISO_CTRL + 1, 0x68);
+	rtl_write_byte(rtlpriv, REG_SYS_ISO_CTRL + 1, 0x68);
 
 	/* Enable AFE PLL Macro Block */
 	tmpu1b = rtl_read_byte(rtlpriv, AFE_PLL_CTRL);
@@ -1447,17 +1447,17 @@ static void _rtl92se_power_domain_init(s
 	mdelay(1);
 
 	/* Release isolation AFE PLL & MD */
-	rtl_write_byte(rtlpriv, SYS_ISO_CTRL, 0xA6);
+	rtl_write_byte(rtlpriv, REG_SYS_ISO_CTRL, 0xA6);
 
 	/* Enable MAC clock */
 	tmpu2b = rtl_read_word(rtlpriv, SYS_CLKR);
 	rtl_write_word(rtlpriv, SYS_CLKR, (tmpu2b | BIT(12) | BIT(11)));
 
 	/* Enable Core digital and enable IOREG R/W */
-	tmpu2b = rtl_read_word(rtlpriv, SYS_FUNC_EN);
-	rtl_write_word(rtlpriv, SYS_FUNC_EN, (tmpu2b | BIT(11)));
+	tmpu2b = rtl_read_word(rtlpriv, REG_SYS_FUNC_EN);
+	rtl_write_word(rtlpriv, REG_SYS_FUNC_EN, (tmpu2b | BIT(11)));
 	/* enable REG_EN */
-	rtl_write_word(rtlpriv, SYS_FUNC_EN, (tmpu2b | BIT(11) | BIT(15)));
+	rtl_write_word(rtlpriv, REG_SYS_FUNC_EN, (tmpu2b | BIT(11) | BIT(15)));
 
 	/* Switch the control path. */
 	tmpu2b = rtl_read_word(rtlpriv, SYS_CLKR);
Index: wireless-testing-new/drivers/net/wireless/rtlwifi/rtl8192se/reg.h
===================================================================
--- wireless-testing-new.orig/drivers/net/wireless/rtlwifi/rtl8192se/reg.h
+++ wireless-testing-new/drivers/net/wireless/rtlwifi/rtl8192se/reg.h
@@ -735,6 +735,7 @@
 #define	HWSET_MAX_SIZE_92S			128
 #define EFUSE_MAX_SECTION			16
 #define EFUSE_REAL_CONTENT_LEN			512
+#define EFUSE_OOB_PROTECT_BYTES			15
 
 #define RTL8190_EEPROM_ID			0x8129
 #define EEPROM_HPON				0x02
Index: wireless-testing-new/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
===================================================================
--- wireless-testing-new.orig/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
+++ wireless-testing-new/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
@@ -304,6 +304,7 @@ static struct rtl_hal_cfg rtl92se_hal_cf
 	.maps[EFUSE_HWSET_MAX_SIZE] = HWSET_MAX_SIZE_92S,
 	.maps[EFUSE_MAX_SECTION_MAP] = EFUSE_MAX_SECTION,
 	.maps[EFUSE_REAL_CONTENT_SIZE] = EFUSE_REAL_CONTENT_LEN,
+	.maps[EFUSE_OOB_PROTECT_BYTES_LEN] = EFUSE_OOB_PROTECT_BYTES,
 
 	.maps[RWCAM] = REG_RWCAM,
 	.maps[WCAMI] = REG_WCAMI,
Index: wireless-testing-new/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
===================================================================
--- wireless-testing-new.orig/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
+++ wireless-testing-new/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
@@ -124,18 +124,15 @@ static void _rtl92se_query_rxphystatus(s
 	u8 i, max_spatial_stream;
 	u32 rssi, total_rssi = 0;
 	bool in_powersavemode = false;
-	bool is_cck_rate;
+	bool is_cck = pstats->is_cck;
 
-	is_cck_rate = SE_RX_HAL_IS_CCK_RATE(pdesc);
 	pstats->packet_matchbssid = packet_match_bssid;
 	pstats->packet_toself = packet_toself;
-	pstats->is_cck = is_cck_rate;
 	pstats->packet_beacon = packet_beacon;
-	pstats->is_cck = is_cck_rate;
 	pstats->rx_mimo_signalquality[0] = -1;
 	pstats->rx_mimo_signalquality[1] = -1;
 
-	if (is_cck_rate) {
+	if (is_cck) {
 		u8 report, cck_highpwr;
 		cck_buf = (struct phy_sts_cck_8192s_t *)p_drvinfo;
 
@@ -246,9 +243,8 @@ static void _rtl92se_query_rxphystatus(s
 		pstats->rxpower = rx_pwr_all;
 		pstats->recvsignalpower = rx_pwr_all;
 
-		if (GET_RX_STATUS_DESC_RX_HT(pdesc) &&
-			GET_RX_STATUS_DESC_RX_MCS(pdesc) >= DESC92_RATEMCS8 &&
-		    GET_RX_STATUS_DESC_RX_MCS(pdesc) <= DESC92_RATEMCS15)
+		if (pstats->is_ht && pstats->rate >= DESC92_RATEMCS8 &&
+		    pstats->rate <= DESC92_RATEMCS15)
 			max_spatial_stream = 2;
 		else
 			max_spatial_stream = 1;
@@ -266,7 +262,7 @@ static void _rtl92se_query_rxphystatus(s
 		}
 	}
 
-	if (is_cck_rate)
+	if (is_cck)
 		pstats->signalstrength = (u8)(_rtl92se_signal_scale_mapping(hw,
 					 pwdb_all));
 	else if (rf_rx_num != 0)
@@ -518,6 +514,7 @@ bool rtl92se_rx_query_desc(struct ieee80
 {
 	struct rx_fwinfo *p_drvinfo;
 	u32 phystatus = (u32)GET_RX_STATUS_DESC_PHY_STATUS(pdesc);
+	struct ieee80211_hdr *hdr;
 
 	stats->length = (u16)GET_RX_STATUS_DESC_PKT_LEN(pdesc);
 	stats->rx_drvinfo_size = (u8)GET_RX_STATUS_DESC_DRVINFO_SIZE(pdesc) * 8;
@@ -530,8 +527,12 @@ bool rtl92se_rx_query_desc(struct ieee80
 	stats->rate = (u8)GET_RX_STATUS_DESC_RX_MCS(pdesc);
 	stats->shortpreamble = (u16)GET_RX_STATUS_DESC_SPLCP(pdesc);
 	stats->isampdu = (bool)(GET_RX_STATUS_DESC_PAGGR(pdesc) == 1);
+	stats->isfirst_ampdu = (bool) ((GET_RX_STATUS_DESC_PAGGR(pdesc) == 1)
+			       && (GET_RX_STATUS_DESC_FAGGR(pdesc) == 1));
 	stats->timestamp_low = GET_RX_STATUS_DESC_TSFL(pdesc);
 	stats->rx_is40Mhzpacket = (bool)GET_RX_STATUS_DESC_BW(pdesc);
+	stats->is_ht = (bool)GET_RX_STATUS_DESC_RX_HT(pdesc);
+	stats->is_cck = SE_RX_HAL_IS_CCK_RATE(pdesc);
 
 	if (stats->hwerror)
 		return false;
@@ -539,29 +540,39 @@ bool rtl92se_rx_query_desc(struct ieee80
 	rx_status->freq = hw->conf.channel->center_freq;
 	rx_status->band = hw->conf.channel->band;
 
-	if (GET_RX_STATUS_DESC_CRC32(pdesc))
-		rx_status->flag |= RX_FLAG_FAILED_FCS_CRC;
+	hdr = (struct ieee80211_hdr *)(skb->data + stats->rx_drvinfo_size
+	      + stats->rx_bufshift);
 
-	if (!GET_RX_STATUS_DESC_SWDEC(pdesc))
-		rx_status->flag |= RX_FLAG_DECRYPTED;
+	if (stats->crc)
+		rx_status->flag |= RX_FLAG_FAILED_FCS_CRC;
 
-	if (GET_RX_STATUS_DESC_BW(pdesc))
+	if (stats->rx_is40Mhzpacket)
 		rx_status->flag |= RX_FLAG_40MHZ;
 
-	if (GET_RX_STATUS_DESC_RX_HT(pdesc))
+	if (stats->is_ht)
 		rx_status->flag |= RX_FLAG_HT;
 
 	rx_status->flag |= RX_FLAG_MACTIME_MPDU;
 
-	if (stats->decrypted)
-		rx_status->flag |= RX_FLAG_DECRYPTED;
+	/* hw will set stats->decrypted true, if it finds the
+	 * frame is open data frame or mgmt frame,
+	 * hw will not decrypt robust managment frame
+	 * for IEEE80211w but still set stats->decrypted
+	 * true, so here we should set it back to undecrypted
+	 * for IEEE80211w frame, and mac80211 sw will help
+	 * to decrypt it */
+	if (stats->decrypted) {
+		if ((ieee80211_is_robust_mgmt_frame(hdr)) &&
+			(ieee80211_has_protected(hdr->frame_control)))
+			rx_status->flag &= ~RX_FLAG_DECRYPTED;
+		else
+			rx_status->flag |= RX_FLAG_DECRYPTED;
+	}
 
 	rx_status->rate_idx = rtlwifi_rate_mapping(hw,
-				(bool)GET_RX_STATUS_DESC_RX_HT(pdesc),
-				(u8)GET_RX_STATUS_DESC_RX_MCS(pdesc));
-
+			     stats->is_ht, stats->rate);
 
-	rx_status->mactime = GET_RX_STATUS_DESC_TSFL(pdesc);
+	rx_status->mactime = stats->timestamp_low;
 	if (phystatus) {
 		p_drvinfo = (struct rx_fwinfo *)(skb->data +
 						 stats->rx_bufshift);
Index: wireless-testing-new/drivers/net/wireless/rtlwifi/wifi.h
===================================================================
--- wireless-testing-new.orig/drivers/net/wireless/rtlwifi/wifi.h
+++ wireless-testing-new/drivers/net/wireless/rtlwifi/wifi.h
@@ -1325,6 +1325,7 @@ struct rtl_stats {
 	s8 rx_mimo_signalquality[2];
 	bool packet_matchbssid;
 	bool is_cck;
+	bool is_ht;
 	bool packet_toself;
 	bool packet_beacon;	/*for rssi */
 	char cck_adc_pwdb[4];	/*for rx path selection */

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: 答复: 答复: 答复: 3.1-rc6+ rtl8192se issue
  2011-09-23 16:34                   ` Larry Finger
@ 2011-09-28 13:18                     ` Borislav Petkov
  2011-09-29  1:57                       ` Larry Finger
  0 siblings, 1 reply; 16+ messages in thread
From: Borislav Petkov @ 2011-09-28 13:18 UTC (permalink / raw)
  To: Larry Finger; +Cc: 李朝明, linux-wireless, 'LKML'

On Fri, Sep 23, 2011 at 11:34:12AM -0500, Larry Finger wrote:
> On 09/23/2011 05:33 AM, Borislav Petkov wrote:
> >On Fri, Sep 23, 2011 at 06:21:07PM +0800, 李朝明 wrote:
> >>Please set ips =0 and try again..
> >
> >What does that mean?
> >
> >I can trigger the grinding-to-a-halt reliably with "ips=0" - it only
> >takes a couple of hours of network traffic. Also, I don't want to try
> >the driver you sent me because the version in the kernel needs fixing
> >not some out-of-tree codebase.
> 
> I got a chance to review the rtl8192se part of the changes in that
> 08/16/2011 version. Attached is a patch to update the kernel
> version.
> 
> A prerequisite is:
> 
> commit da3ba88a9996cd64c6768bed5727e02da81e2c8d
> Author: Larry Finger <Larry.Finger@lwfinger.net>
> Date:   Mon Sep 19 14:34:10 2011 -0500
> 
>     rtlwifi: Combine instances of RTL_HAL_IS_CCK_RATE macros.
> 
>     Three drivers, rtl8192ce, rtl8192cu and rtl8192de, use the same macro
>     to check if a particular rate is in the CCK set. This common code is
>     relocated to a common header file. A distinct macro used by rtl8192se
>     with the same name is renamed.
> 
>     Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
>     Signed-off-by: John W. Linville <linville@tuxdriver.com>

Ok, here's what I did.

* merge 'master' branch of
git://git.infradead.org/users/linville/wireless-next.git with -rc8 in
order to get da3ba88a9996.

* apply your attached patch with the Realsil facelift:

patching file drivers/net/wireless/rtlwifi/rtl8192se/hw.c
patching file drivers/net/wireless/rtlwifi/rtl8192se/reg.h
patching file drivers/net/wireless/rtlwifi/rtl8192se/sw.c
patching file drivers/net/wireless/rtlwifi/rtl8192se/trx.c
Hunk #6 FAILED at 540.
1 out of 6 hunks FAILED -- saving rejects to file drivers/net/wireless/rtlwifi/rtl8192se/trx.c.rej
patching file drivers/net/wireless/rtlwifi/wifi.h
Hunk #1 succeeded at 1328 (offset 3 lines).

(had to apply hunk #6 by hand though)

* build

drivers/net/wireless/rtlwifi/rtl8192se/sw.c:307:8: error: `EFUSE_OOB_PROTECT_BYTES_LEN' undeclared here (not in a function)
drivers/net/wireless/rtlwifi/rtl8192se/sw.c:307:2: error: array index in initializer not of integer type
drivers/net/wireless/rtlwifi/rtl8192se/sw.c:307:2: error: (near initialization for `rtl92se_hal_cfg.maps')
make[5]: *** [drivers/net/wireless/rtlwifi/rtl8192se/sw.o] Error 1
make[4]: *** [drivers/net/wireless/rtlwifi/rtl8192se] Error 2
make[3]: *** [drivers/net/wireless/rtlwifi] Error 2
make[2]: *** [drivers/net/wireless] Error 2
make[1]: *** [drivers/net] Error 2
make: *** [drivers] Error 2
make: *** Waiting for unfinished jobs....

fix with

diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h
index 615f6b4..55428f2 100644
--- a/drivers/net/wireless/rtlwifi/wifi.h
+++ b/drivers/net/wireless/rtlwifi/wifi.h
@@ -450,6 +450,7 @@ enum rtl_var_map {
        EFUSE_HWSET_MAX_SIZE,
        EFUSE_MAX_SECTION_MAP,
        EFUSE_REAL_CONTENT_SIZE,
+       EFUSE_OOB_PROTECT_BYTES_LEN,
 
        /*CAM map */
        RWCAM,

> I have run the new version for a couple of hours without problems.
> Perhaps it will cure your difficulty, but I am not optimistic.

Yeah, I'm sorry to confirm that your pessimism turned into realism :-).
It froze in under 20 mins. Ran the driver with default module parameters
though.

Looks like I'll have to test the Realsil tarball after all. Question, do
I simply overwrite the subtree under drivers/net/wireless/rtlwifi/ with
the files from the tarball?

Also, any preferred module parameters settings you want me to test?

Thanks.

-- 
Regards/Gruss,
Boris.

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: 答复: 答复: 答复: 3.1-rc6+ rtl8192se issue
  2011-09-28 13:18                     ` Borislav Petkov
@ 2011-09-29  1:57                       ` Larry Finger
  2011-10-05 15:15                         ` Borislav Petkov
  0 siblings, 1 reply; 16+ messages in thread
From: Larry Finger @ 2011-09-29  1:57 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: 李朝明, linux-wireless, 'LKML'

On 09/28/2011 08:18 AM, Borislav Petkov wrote:
> On Fri, Sep 23, 2011 at 11:34:12AM -0500, Larry Finger wrote:
>> On 09/23/2011 05:33 AM, Borislav Petkov wrote:
>>> On Fri, Sep 23, 2011 at 06:21:07PM +0800, 李朝明 wrote:
>>>> Please set ips =0 and try again..
>>>
>>> What does that mean?
>>>
>>> I can trigger the grinding-to-a-halt reliably with "ips=0" - it only
>>> takes a couple of hours of network traffic. Also, I don't want to try
>>> the driver you sent me because the version in the kernel needs fixing
>>> not some out-of-tree codebase.
>>
>> I got a chance to review the rtl8192se part of the changes in that
>> 08/16/2011 version. Attached is a patch to update the kernel
>> version.
>>
>> A prerequisite is:
>>
>> commit da3ba88a9996cd64c6768bed5727e02da81e2c8d
>> Author: Larry Finger<Larry.Finger@lwfinger.net>
>> Date:   Mon Sep 19 14:34:10 2011 -0500
>>
>>      rtlwifi: Combine instances of RTL_HAL_IS_CCK_RATE macros.
>>
>>      Three drivers, rtl8192ce, rtl8192cu and rtl8192de, use the same macro
>>      to check if a particular rate is in the CCK set. This common code is
>>      relocated to a common header file. A distinct macro used by rtl8192se
>>      with the same name is renamed.
>>
>>      Signed-off-by: Larry Finger<Larry.Finger@lwfinger.net>
>>      Signed-off-by: John W. Linville<linville@tuxdriver.com>
>
> Ok, here's what I did.
>
> * merge 'master' branch of
> git://git.infradead.org/users/linville/wireless-next.git with -rc8 in
> order to get da3ba88a9996.
>
> * apply your attached patch with the Realsil facelift:
>
> patching file drivers/net/wireless/rtlwifi/rtl8192se/hw.c
> patching file drivers/net/wireless/rtlwifi/rtl8192se/reg.h
> patching file drivers/net/wireless/rtlwifi/rtl8192se/sw.c
> patching file drivers/net/wireless/rtlwifi/rtl8192se/trx.c
> Hunk #6 FAILED at 540.
> 1 out of 6 hunks FAILED -- saving rejects to file drivers/net/wireless/rtlwifi/rtl8192se/trx.c.rej
> patching file drivers/net/wireless/rtlwifi/wifi.h
> Hunk #1 succeeded at 1328 (offset 3 lines).
>
> (had to apply hunk #6 by hand though)
>
> * build
>
> drivers/net/wireless/rtlwifi/rtl8192se/sw.c:307:8: error: `EFUSE_OOB_PROTECT_BYTES_LEN' undeclared here (not in a function)
> drivers/net/wireless/rtlwifi/rtl8192se/sw.c:307:2: error: array index in initializer not of integer type
> drivers/net/wireless/rtlwifi/rtl8192se/sw.c:307:2: error: (near initialization for `rtl92se_hal_cfg.maps')
> make[5]: *** [drivers/net/wireless/rtlwifi/rtl8192se/sw.o] Error 1
> make[4]: *** [drivers/net/wireless/rtlwifi/rtl8192se] Error 2
> make[3]: *** [drivers/net/wireless/rtlwifi] Error 2
> make[2]: *** [drivers/net/wireless] Error 2
> make[1]: *** [drivers/net] Error 2
> make: *** [drivers] Error 2
> make: *** Waiting for unfinished jobs....
>
> fix with
>
> diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h
> index 615f6b4..55428f2 100644
> --- a/drivers/net/wireless/rtlwifi/wifi.h
> +++ b/drivers/net/wireless/rtlwifi/wifi.h
> @@ -450,6 +450,7 @@ enum rtl_var_map {
>          EFUSE_HWSET_MAX_SIZE,
>          EFUSE_MAX_SECTION_MAP,
>          EFUSE_REAL_CONTENT_SIZE,
> +       EFUSE_OOB_PROTECT_BYTES_LEN,
>
>          /*CAM map */
>          RWCAM,
>
>> I have run the new version for a couple of hours without problems.
>> Perhaps it will cure your difficulty, but I am not optimistic.
>
> Yeah, I'm sorry to confirm that your pessimism turned into realism :-).
> It froze in under 20 mins. Ran the driver with default module parameters
> though.
>
> Looks like I'll have to test the Realsil tarball after all. Question, do
> I simply overwrite the subtree under drivers/net/wireless/rtlwifi/ with
> the files from the tarball?

Asa you probably do not want to kill your standard tree, unpack the Realtek 
version normally, cd to where it unpacked, and do a make. Once it builds, do the 
following:

sudo modprobe -rv rtl8192se
sudo modprobe -v mac80211
sudo insmod rtlwifi.ko
sudo insmod rtl8192se/rtl8192se.ko

>
> Also, any preferred module parameters settings you want me to test?

Try it first with the default parameters. If that fails, use "ips=0".

Larry


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: 答复: 答复: 答复: 3.1-rc6+ rtl8192se issue
  2011-09-29  1:57                       ` Larry Finger
@ 2011-10-05 15:15                         ` Borislav Petkov
  2011-10-06  2:37                           ` Larry Finger
  0 siblings, 1 reply; 16+ messages in thread
From: Borislav Petkov @ 2011-10-05 15:15 UTC (permalink / raw)
  To: Larry Finger; +Cc: 李朝明, linux-wireless, 'LKML'

On Wed, Sep 28, 2011 at 08:57:38PM -0500, Larry Finger wrote:
> Asa you probably do not want to kill your standard tree, unpack the
> Realtek version normally, cd to where it unpacked, and do a make.
> Once it builds, do the following:
> 
> sudo modprobe -rv rtl8192se
> sudo modprobe -v mac80211
> sudo insmod rtlwifi.ko
> sudo insmod rtl8192se/rtl8192se.ko
> 
> >
> >Also, any preferred module parameters settings you want me to test?
> 
> Try it first with the default parameters. If that fails, use "ips=0".

Ok, I can cautiosly say now that after a couple days of running the
Realtek version that the box runs just fine, no hiccups whatsoever.

Larry, you said in an earlier mail that you've gone through the
rtl8192se changes and weren't optimistic with the attached diff you sent
me. What about the rtlwifi changes, is there something in Realtek's
version which is missing upstream that would cause the sluggishness?

Thanks.

-- 
Regards/Gruss,
Boris.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: 答复: 答复: 答复: 3.1-rc6+ rtl8192se issue
  2011-10-05 15:15                         ` Borislav Petkov
@ 2011-10-06  2:37                           ` Larry Finger
  2011-11-15 13:59                             ` Borislav Petkov
  0 siblings, 1 reply; 16+ messages in thread
From: Larry Finger @ 2011-10-06  2:37 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: 李朝明, linux-wireless, 'LKML'

[-- Attachment #1: Type: text/plain, Size: 742 bytes --]

On 10/05/2011 10:15 AM, Borislav Petkov wrote:

> Ok, I can cautiosly say now that after a couple days of running the
> Realtek version that the box runs just fine, no hiccups whatsoever.
>
> Larry, you said in an earlier mail that you've gone through the
> rtl8192se changes and weren't optimistic with the attached diff you sent
> me. What about the rtlwifi changes, is there something in Realtek's
> version which is missing upstream that would cause the sluggishness?

I have been going though the differences between the 06/20/2011 and 08/16/2011 
drivers and making those changes to the kernel drivers. Could you please apply 
the 5 attached patches to the wireless-testing tree and see if your sluggishness 
is fixed?

Thanks,

Larry


[-- Attachment #2: 0001-rtlwifi-Change-PCI-drivers-to-use-the-new-PM-framewo.patch --]
[-- Type: text/x-patch, Size: 5896 bytes --]

>From 7888163e5f25feb9825349e346759f7c884dd074 Mon Sep 17 00:00:00 2001
From: Larry Finger <Larry.Finger@lwfinger.net>
Date: Wed, 5 Oct 2011 10:50:24 -0500
Subject: [PATCH 1/5] rtlwifi: Change PCI drivers to use the new PM framework
To: linville@tuxdriver.com
Cc: linux-wireless@vger.kernel.org

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
---
 drivers/net/wireless/rtlwifi/pci.c          |   19 ++++---------------
 drivers/net/wireless/rtlwifi/pci.h          |    4 ++--
 drivers/net/wireless/rtlwifi/rtl8192ce/sw.c |   16 ++++++++++------
 drivers/net/wireless/rtlwifi/rtl8192de/sw.c |   16 ++++++++++------
 drivers/net/wireless/rtlwifi/rtl8192se/sw.c |   16 ++++++++++------
 5 files changed, 36 insertions(+), 35 deletions(-)

diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
index 9983fa1..5380f3b 100644
--- a/drivers/net/wireless/rtlwifi/pci.c
+++ b/drivers/net/wireless/rtlwifi/pci.c
@@ -1993,36 +1993,25 @@ call rtl_mac_stop() from the mac80211
 suspend function first, So there is
 no need to call hw_disable here.
 ****************************************/
-int rtl_pci_suspend(struct pci_dev *pdev, pm_message_t state)
+int rtl_pci_suspend(struct device *dev)
 {
+	struct pci_dev *pdev = to_pci_dev(dev);
 	struct ieee80211_hw *hw = pci_get_drvdata(pdev);
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 
 	rtlpriv->cfg->ops->hw_suspend(hw);
 	rtl_deinit_rfkill(hw);
 
-	pci_save_state(pdev);
-	pci_disable_device(pdev);
-	pci_set_power_state(pdev, PCI_D3hot);
 	return 0;
 }
 EXPORT_SYMBOL(rtl_pci_suspend);
 
-int rtl_pci_resume(struct pci_dev *pdev)
+int rtl_pci_resume(struct device *dev)
 {
-	int ret;
+	struct pci_dev *pdev = to_pci_dev(dev);
 	struct ieee80211_hw *hw = pci_get_drvdata(pdev);
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 
-	pci_set_power_state(pdev, PCI_D0);
-	ret = pci_enable_device(pdev);
-	if (ret) {
-		RT_ASSERT(false, ("ERR: <======\n"));
-		return ret;
-	}
-
-	pci_restore_state(pdev);
-
 	rtlpriv->cfg->ops->hw_resume(hw);
 	rtl_init_rfkill(hw);
 	return 0;
diff --git a/drivers/net/wireless/rtlwifi/pci.h b/drivers/net/wireless/rtlwifi/pci.h
index a24e505..ebe0b42 100644
--- a/drivers/net/wireless/rtlwifi/pci.h
+++ b/drivers/net/wireless/rtlwifi/pci.h
@@ -237,8 +237,8 @@ extern struct rtl_intf_ops rtl_pci_ops;
 int __devinit rtl_pci_probe(struct pci_dev *pdev,
 			    const struct pci_device_id *id);
 void rtl_pci_disconnect(struct pci_dev *pdev);
-int rtl_pci_suspend(struct pci_dev *pdev, pm_message_t state);
-int rtl_pci_resume(struct pci_dev *pdev);
+int rtl_pci_suspend(struct device *dev);
+int rtl_pci_resume(struct device *dev);
 
 static inline u8 pci_read8_sync(struct rtl_priv *rtlpriv, u32 addr)
 {
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
index b7ecb9e..07a75d3 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
@@ -365,17 +365,21 @@ MODULE_PARM_DESC(ips, "Set to 0 to not use link power save (default 1)\n");
 MODULE_PARM_DESC(swlps, "Set to 1 to use SW control power save (default 0)\n");
 MODULE_PARM_DESC(fwlps, "Set to 1 to use FW control power save (default 1)\n");
 
+static const struct dev_pm_ops rtlwifi_pm_ops = {
+	.suspend = rtl_pci_suspend,
+	.resume = rtl_pci_resume,
+	.freeze = rtl_pci_suspend,
+	.thaw = rtl_pci_resume,
+	.poweroff = rtl_pci_suspend,
+	.restore = rtl_pci_resume,
+};
+
 static struct pci_driver rtl92ce_driver = {
 	.name = KBUILD_MODNAME,
 	.id_table = rtl92ce_pci_ids,
 	.probe = rtl_pci_probe,
 	.remove = rtl_pci_disconnect,
-
-#ifdef CONFIG_PM
-	.suspend = rtl_pci_suspend,
-	.resume = rtl_pci_resume,
-#endif
-
+	.driver.pm = &rtlwifi_pm_ops,
 };
 
 static int __init rtl92ce_module_init(void)
diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
index c681597..12042d8 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c
@@ -385,17 +385,21 @@ MODULE_PARM_DESC(ips, "Set to 0 to not use link power save (default 1)\n");
 MODULE_PARM_DESC(swlps, "Set to 1 to use SW control power save (default 0)\n");
 MODULE_PARM_DESC(fwlps, "Set to 1 to use FW control power save (default 1)\n");
 
+static const struct dev_pm_ops rtlwifi_pm_ops = {
+	.suspend = rtl_pci_suspend,
+	.resume = rtl_pci_resume,
+	.freeze = rtl_pci_suspend,
+	.thaw = rtl_pci_resume,
+	.poweroff = rtl_pci_suspend,
+	.restore = rtl_pci_resume,
+};
+
 static struct pci_driver rtl92de_driver = {
 	.name = KBUILD_MODNAME,
 	.id_table = rtl92de_pci_ids,
 	.probe = rtl_pci_probe,
 	.remove = rtl_pci_disconnect,
-
-#ifdef CONFIG_PM
-	.suspend = rtl_pci_suspend,
-	.resume = rtl_pci_resume,
-#endif
-
+	.driver.pm = &rtlwifi_pm_ops,
 };
 
 /* add global spin lock to solve the problem that
diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
index 24bd331..80facb5 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
@@ -396,17 +396,21 @@ MODULE_PARM_DESC(ips, "Set to 0 to not use link power save (default 1)\n");
 MODULE_PARM_DESC(swlps, "Set to 1 to use SW control power save (default 0)\n");
 MODULE_PARM_DESC(fwlps, "Set to 1 to use FW control power save (default 1)\n");
 
+static const struct dev_pm_ops rtlwifi_pm_ops = {
+	.suspend = rtl_pci_suspend,
+	.resume = rtl_pci_resume,
+	.freeze = rtl_pci_suspend,
+	.thaw = rtl_pci_resume,
+	.poweroff = rtl_pci_suspend,
+	.restore = rtl_pci_resume,
+};
+
 static struct pci_driver rtl92se_driver = {
 	.name = KBUILD_MODNAME,
 	.id_table = rtl92se_pci_ids,
 	.probe = rtl_pci_probe,
 	.remove = rtl_pci_disconnect,
-
-#ifdef CONFIG_PM
-	.suspend = rtl_pci_suspend,
-	.resume = rtl_pci_resume,
-#endif
-
+	.driver.pm = &rtlwifi_pm_ops,
 };
 
 static int __init rtl92se_module_init(void)
-- 
1.7.6.4


[-- Attachment #3: 0002-rtlwifi-Update-to-new-Realtek-version-Part-I.patch --]
[-- Type: text/x-patch, Size: 1944 bytes --]

>From 18157ae7138110bf72540fac4c1fa16e09c81774 Mon Sep 17 00:00:00 2001
From: Chaoming Li <chaoming_li@realsil.com.cn>
Date: Wed, 5 Oct 2011 10:54:06 -0500
Subject: [PATCH 2/5] rtlwifi: Update to new Realtek version - Part I
To: linville@tuxdriver.com
Cc: linux-wireless@vger.kernel.org

This patch incorporate the differences between the 06/20/2011 and
08/16/2011 Realtek releases of the rtlwifi driver.

The changes include:

1. Handling of IEEE80211_HW_CONNECTION_MONITOR.
2. Fix typo to get proper response to nullfunc frames.

Signed-off-by: Chaoming Li <chaoming_li@realsil.com.cn>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
---
 drivers/net/wireless/rtlwifi/base.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c
index eafe980..a2704fb 100644
--- a/drivers/net/wireless/rtlwifi/base.c
+++ b/drivers/net/wireless/rtlwifi/base.c
@@ -311,6 +311,8 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw)
 	    IEEE80211_HW_RX_INCLUDES_FCS |
 	    IEEE80211_HW_BEACON_FILTER |
 	    IEEE80211_HW_AMPDU_AGGREGATION |
+	    IEEE80211_HW_CONNECTION_MONITOR |
+	    /* IEEE80211_HW_SUPPORTS_CQM_RSSI | */
 	    IEEE80211_HW_REPORTS_TX_ACK_STATUS | 0;
 
 	/* swlps or hwlps has been set in diff chip in init_sw_vars */
@@ -850,7 +852,7 @@ void rtl_get_tcb_desc(struct ieee80211_hw *hw,
 		 *So tcb_desc->hw_rate is just used for
 		 *special data and mgt frames
 		 */
-		if (info->control.rates[0].idx == 0 &&
+		if (info->control.rates[0].idx == 0 ||
 				ieee80211_is_nullfunc(fc)) {
 			tcb_desc->use_driver_rate = true;
 			tcb_desc->ratr_index = RATR_INX_WIRELESS_MC;
@@ -1138,7 +1140,7 @@ void rtl_watchdog_wq_callback(void *data)
 	}
 
 	/*
-	 *<3> to check if traffic busy, if
+	 *<2> to check if traffic busy, if
 	 * busytraffic we don't change channel
 	 */
 	if (mac->link_state >= MAC80211_LINKED) {
-- 
1.7.6.4


[-- Attachment #4: 0003-rtlwifi-rtl8192ce-Add-new-chip-revisions.patch --]
[-- Type: text/x-patch, Size: 4354 bytes --]

>From a3c6b35d2d81c99707b1c36fc3b4d84eb461ff7f Mon Sep 17 00:00:00 2001
From: Larry Finger <Larry.Finger@lwfinger.net>
Date: Wed, 5 Oct 2011 11:05:36 -0500
Subject: [PATCH 3/5] rtlwifi: rtl8192ce: Add new chip revisions
To: linville@tuxdriver.com
Cc: linux-wireless@vger.kernel.org

From: Chaoming Li <chaoming_li@realsil.com.cn>

This patch incorporate the differences between the 06/20/2011 and
08/16/2011 Realtek releases of the rtlwifi driver.

The changes include:

1. Adding new chip revisions including new firmware.

Signed-off-by: Chaoming Li <chaoming_li@realsil.com.cn>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
---
 drivers/net/wireless/rtlwifi/rtl8192ce/def.h |   14 ++++++++++++++
 drivers/net/wireless/rtlwifi/rtl8192ce/sw.c  |   14 ++++++++++++--
 drivers/net/wireless/rtlwifi/rtl8192cu/def.h |    4 ----
 3 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/def.h b/drivers/net/wireless/rtlwifi/rtl8192ce/def.h
index 11f4319..a816459 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/def.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/def.h
@@ -142,8 +142,22 @@ enum version_8192c {
 	VERSION_UNKNOWN = 0x88,
 };
 
+#define CUT_VERSION_MASK		(BIT(6)|BIT(7))
+#define CHIP_VENDOR_UMC			BIT(5)
+#define CHIP_VENDOR_UMC_B_CUT		BIT(6) /* Chip version for ECO */
+#define IS_VENDOR_UMC_A_CUT(version)	((IS_CHIP_VENDOR_UMC(version)) ? \
+	((GET_CVID_CUT_VERSION(version)) ? false : true) : false)
 #define IS_CHIP_VER_B(version)  ((version & CHIP_VER_B) ? true : false)
+#define IS_VENDOR_UMC_A_CUT(version)	((IS_CHIP_VENDOR_UMC(version)) ? \
+	((GET_CVID_CUT_VERSION(version)) ? false : true) : false)
 #define IS_92C_SERIAL(version)  ((version & CHIP_92C_BITMASK) ? true : false)
+#define IS_CHIP_VENDOR_UMC(version)		\
+	((version & CHIP_VENDOR_UMC) ? true : false)
+#define GET_CVID_CUT_VERSION(version)	((version) & CUT_VERSION_MASK)
+#define IS_81xxC_VENDOR_UMC_B_CUT(version)		\
+	((IS_CHIP_VENDOR_UMC(version)) ? \
+	((GET_CVID_CUT_VERSION(version) == CHIP_VENDOR_UMC_B_CUT) ?	\
+	true : false) : false)
 
 enum rtl819x_loopback_e {
 	RTL819X_NO_LOOPBACK = 0,
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
index 07a75d3..f515bf7 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
@@ -92,6 +92,8 @@ int rtl92c_init_sw_vars(struct ieee80211_hw *hw)
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
 	const struct firmware *firmware;
+	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
+	char *fw_name = NULL;
 
 	rtl8192ce_bt_reg_init(hw);
 
@@ -159,8 +161,14 @@ int rtl92c_init_sw_vars(struct ieee80211_hw *hw)
 	}
 
 	/* request fw */
-	err = request_firmware(&firmware, rtlpriv->cfg->fw_name,
-			rtlpriv->io.dev);
+	if (IS_VENDOR_UMC_A_CUT(rtlhal->version) &&
+	    !IS_92C_SERIAL(rtlhal->version))
+		fw_name = "rtlwifi/rtl8192cfwU.bin";
+	else if (IS_81xxC_VENDOR_UMC_B_CUT(rtlhal->version))
+		fw_name = "rtlwifi/rtl8192cfwU_B.bin";
+	else
+		fw_name = rtlpriv->cfg->fw_name;
+	err = request_firmware(&firmware, fw_name, rtlpriv->io.dev);
 	if (err) {
 		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
 			 ("Failed to request firmware!\n"));
@@ -355,6 +363,8 @@ MODULE_AUTHOR("Larry Finger	<Larry.Finger@lwfinger.net>");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Realtek 8192C/8188C 802.11n PCI wireless");
 MODULE_FIRMWARE("rtlwifi/rtl8192cfw.bin");
+MODULE_FIRMWARE("rtlwifi/rtl8192cfwU.bin");
+MODULE_FIRMWARE("rtlwifi/rtl8192cfwU_B.bin");
 
 module_param_named(swenc, rtl92ce_mod_params.sw_crypto, bool, 0444);
 module_param_named(ips, rtl92ce_mod_params.inactiveps, bool, 0444);
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/def.h b/drivers/net/wireless/rtlwifi/rtl8192cu/def.h
index c54940e..d097efb 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/def.h
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/def.h
@@ -50,10 +50,6 @@
 #define IS_VENDOR_UMC(version)		\
 	(((version) & CHIP_VENDOR_UMC) ? true : false)
 
-#define IS_VENDOR_UMC_A_CUT(version)	\
-	(((version) & CHIP_VENDOR_UMC) ? (((version) & (BIT(6) | BIT(7))) ? \
-	false : true) : false)
-
 #define IS_VENDOR_8723_A_CUT(version)	\
 	(((version) & CHIP_VENDOR_UMC) ? (((version) & (BIT(6))) ? \
 	false : true) : false)
-- 
1.7.6.4


[-- Attachment #5: 0004-rtlwifi-rtl8192se-Updates-from-latest-Realtek-driver.patch --]
[-- Type: text/x-patch, Size: 9879 bytes --]

>From 958afb7351d9ff1b48b4f53796db1abd78b4b350 Mon Sep 17 00:00:00 2001
From: Larry Finger <Larry.Finger@lwfinger.net>
Date: Wed, 5 Oct 2011 11:11:04 -0500
Subject: [PATCH 4/5] rtlwifi: rtl8192se: Updates from latest Realtek driver
 version - Part II
To: linville@tuxdriver.com
Cc: linux-wireless@vger.kernel.org

From: Chaoming Li <chaoming_li@realsil.com.cn>

This patch incorporate the differences between the 06/20/2011 and
08/16/2011 Realtek releases of the rtl8192se driver.

The changes include:

1. Fixing some typos in register usage.
2. A change in the handling of decryption status for 802.11w packets.

Signed-off-by: Chaoming Li <chaoming_li@realsil.com.cn>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
---
 drivers/net/wireless/rtlwifi/rtl8192se/hw.c  |   22 +++++-----
 drivers/net/wireless/rtlwifi/rtl8192se/reg.h |    1 +
 drivers/net/wireless/rtlwifi/rtl8192se/sw.c  |    1 +
 drivers/net/wireless/rtlwifi/rtl8192se/trx.c |   53 +++++++++++++++----------
 drivers/net/wireless/rtlwifi/wifi.h          |    1 +
 5 files changed, 46 insertions(+), 32 deletions(-)

Index: wireless-testing-new/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
===================================================================
--- wireless-testing-new.orig/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
+++ wireless-testing-new/drivers/net/wireless/rtlwifi/rtl8192se/hw.c
@@ -1382,7 +1382,7 @@ static void _rtl92se_power_domain_init(s
 	rtl_write_byte(rtlpriv, LDOA15_CTRL, 0x34);
 
 	/* Reset MAC-IO and CPU and Core Digital BIT10/11/15 */
-	tmpu1b = rtl_read_byte(rtlpriv, SYS_FUNC_EN + 1);
+	tmpu1b = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1);
 
 	/* If IPS we need to turn LED on. So we not
 	 * not disable BIT 3/7 of reg3. */
@@ -1391,7 +1391,7 @@ static void _rtl92se_power_domain_init(s
 	else
 		tmpu1b &= 0x73;
 
-	rtl_write_byte(rtlpriv, SYS_FUNC_EN + 1, tmpu1b);
+	rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, tmpu1b);
 	/* wait for BIT 10/11/15 to pull high automatically!! */
 	mdelay(1);
 
@@ -1428,15 +1428,15 @@ static void _rtl92se_power_domain_init(s
 	rtl_write_byte(rtlpriv, LDOA15_CTRL, (tmpu1b | BIT(0)));
 
 	/* Set Digital Vdd to Retention isolation Path. */
-	tmpu2b = rtl_read_word(rtlpriv, SYS_ISO_CTRL);
-	rtl_write_word(rtlpriv, SYS_ISO_CTRL, (tmpu2b | BIT(11)));
+	tmpu2b = rtl_read_word(rtlpriv, REG_SYS_ISO_CTRL);
+	rtl_write_word(rtlpriv, REG_SYS_ISO_CTRL, (tmpu2b | BIT(11)));
 
 
 	/* For warm reboot NIC disappera bug. */
-	tmpu2b = rtl_read_word(rtlpriv, SYS_FUNC_EN);
-	rtl_write_word(rtlpriv, SYS_FUNC_EN, (tmpu2b | BIT(13)));
+	tmpu2b = rtl_read_word(rtlpriv, REG_SYS_FUNC_EN);
+	rtl_write_word(rtlpriv, REG_SYS_FUNC_EN, (tmpu2b | BIT(13)));
 
-	rtl_write_byte(rtlpriv, SYS_ISO_CTRL + 1, 0x68);
+	rtl_write_byte(rtlpriv, REG_SYS_ISO_CTRL + 1, 0x68);
 
 	/* Enable AFE PLL Macro Block */
 	tmpu1b = rtl_read_byte(rtlpriv, AFE_PLL_CTRL);
@@ -1447,17 +1447,17 @@ static void _rtl92se_power_domain_init(s
 	mdelay(1);
 
 	/* Release isolation AFE PLL & MD */
-	rtl_write_byte(rtlpriv, SYS_ISO_CTRL, 0xA6);
+	rtl_write_byte(rtlpriv, REG_SYS_ISO_CTRL, 0xA6);
 
 	/* Enable MAC clock */
 	tmpu2b = rtl_read_word(rtlpriv, SYS_CLKR);
 	rtl_write_word(rtlpriv, SYS_CLKR, (tmpu2b | BIT(12) | BIT(11)));
 
 	/* Enable Core digital and enable IOREG R/W */
-	tmpu2b = rtl_read_word(rtlpriv, SYS_FUNC_EN);
-	rtl_write_word(rtlpriv, SYS_FUNC_EN, (tmpu2b | BIT(11)));
+	tmpu2b = rtl_read_word(rtlpriv, REG_SYS_FUNC_EN);
+	rtl_write_word(rtlpriv, REG_SYS_FUNC_EN, (tmpu2b | BIT(11)));
 	/* enable REG_EN */
-	rtl_write_word(rtlpriv, SYS_FUNC_EN, (tmpu2b | BIT(11) | BIT(15)));
+	rtl_write_word(rtlpriv, REG_SYS_FUNC_EN, (tmpu2b | BIT(11) | BIT(15)));
 
 	/* Switch the control path. */
 	tmpu2b = rtl_read_word(rtlpriv, SYS_CLKR);
Index: wireless-testing-new/drivers/net/wireless/rtlwifi/rtl8192se/reg.h
===================================================================
--- wireless-testing-new.orig/drivers/net/wireless/rtlwifi/rtl8192se/reg.h
+++ wireless-testing-new/drivers/net/wireless/rtlwifi/rtl8192se/reg.h
@@ -735,6 +735,7 @@
 #define	HWSET_MAX_SIZE_92S			128
 #define EFUSE_MAX_SECTION			16
 #define EFUSE_REAL_CONTENT_LEN			512
+#define EFUSE_OOB_PROTECT_BYTES			15
 
 #define RTL8190_EEPROM_ID			0x8129
 #define EEPROM_HPON				0x02
Index: wireless-testing-new/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
===================================================================
--- wireless-testing-new.orig/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
+++ wireless-testing-new/drivers/net/wireless/rtlwifi/rtl8192se/sw.c
@@ -304,6 +304,7 @@ static struct rtl_hal_cfg rtl92se_hal_cf
 	.maps[EFUSE_HWSET_MAX_SIZE] = HWSET_MAX_SIZE_92S,
 	.maps[EFUSE_MAX_SECTION_MAP] = EFUSE_MAX_SECTION,
 	.maps[EFUSE_REAL_CONTENT_SIZE] = EFUSE_REAL_CONTENT_LEN,
+	.maps[EFUSE_OOB_PROTECT_BYTES_LEN] = EFUSE_OOB_PROTECT_BYTES,
 
 	.maps[RWCAM] = REG_RWCAM,
 	.maps[WCAMI] = REG_WCAMI,
Index: wireless-testing-new/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
===================================================================
--- wireless-testing-new.orig/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
+++ wireless-testing-new/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
@@ -124,18 +124,15 @@ static void _rtl92se_query_rxphystatus(s
 	u8 i, max_spatial_stream;
 	u32 rssi, total_rssi = 0;
 	bool in_powersavemode = false;
-	bool is_cck_rate;
+	bool is_cck = pstats->is_cck;
 
-	is_cck_rate = SE_RX_HAL_IS_CCK_RATE(pdesc);
 	pstats->packet_matchbssid = packet_match_bssid;
 	pstats->packet_toself = packet_toself;
-	pstats->is_cck = is_cck_rate;
 	pstats->packet_beacon = packet_beacon;
-	pstats->is_cck = is_cck_rate;
 	pstats->rx_mimo_signalquality[0] = -1;
 	pstats->rx_mimo_signalquality[1] = -1;
 
-	if (is_cck_rate) {
+	if (is_cck) {
 		u8 report, cck_highpwr;
 		cck_buf = (struct phy_sts_cck_8192s_t *)p_drvinfo;
 
@@ -246,9 +243,8 @@ static void _rtl92se_query_rxphystatus(s
 		pstats->rxpower = rx_pwr_all;
 		pstats->recvsignalpower = rx_pwr_all;
 
-		if (GET_RX_STATUS_DESC_RX_HT(pdesc) &&
-			GET_RX_STATUS_DESC_RX_MCS(pdesc) >= DESC92_RATEMCS8 &&
-		    GET_RX_STATUS_DESC_RX_MCS(pdesc) <= DESC92_RATEMCS15)
+		if (pstats->is_ht && pstats->rate >= DESC92_RATEMCS8 &&
+		    pstats->rate <= DESC92_RATEMCS15)
 			max_spatial_stream = 2;
 		else
 			max_spatial_stream = 1;
@@ -266,7 +262,7 @@ static void _rtl92se_query_rxphystatus(s
 		}
 	}
 
-	if (is_cck_rate)
+	if (is_cck)
 		pstats->signalstrength = (u8)(_rtl92se_signal_scale_mapping(hw,
 					 pwdb_all));
 	else if (rf_rx_num != 0)
@@ -518,6 +514,7 @@ bool rtl92se_rx_query_desc(struct ieee80
 {
 	struct rx_fwinfo *p_drvinfo;
 	u32 phystatus = (u32)GET_RX_STATUS_DESC_PHY_STATUS(pdesc);
+	struct ieee80211_hdr *hdr;
 
 	stats->length = (u16)GET_RX_STATUS_DESC_PKT_LEN(pdesc);
 	stats->rx_drvinfo_size = (u8)GET_RX_STATUS_DESC_DRVINFO_SIZE(pdesc) * 8;
@@ -530,8 +527,12 @@ bool rtl92se_rx_query_desc(struct ieee80
 	stats->rate = (u8)GET_RX_STATUS_DESC_RX_MCS(pdesc);
 	stats->shortpreamble = (u16)GET_RX_STATUS_DESC_SPLCP(pdesc);
 	stats->isampdu = (bool)(GET_RX_STATUS_DESC_PAGGR(pdesc) == 1);
+	stats->isfirst_ampdu = (bool) ((GET_RX_STATUS_DESC_PAGGR(pdesc) == 1)
+			       && (GET_RX_STATUS_DESC_FAGGR(pdesc) == 1));
 	stats->timestamp_low = GET_RX_STATUS_DESC_TSFL(pdesc);
 	stats->rx_is40Mhzpacket = (bool)GET_RX_STATUS_DESC_BW(pdesc);
+	stats->is_ht = (bool)GET_RX_STATUS_DESC_RX_HT(pdesc);
+	stats->is_cck = SE_RX_HAL_IS_CCK_RATE(pdesc);
 
 	if (stats->hwerror)
 		return false;
@@ -539,29 +540,39 @@ bool rtl92se_rx_query_desc(struct ieee80
 	rx_status->freq = hw->conf.channel->center_freq;
 	rx_status->band = hw->conf.channel->band;
 
-	if (GET_RX_STATUS_DESC_CRC32(pdesc))
-		rx_status->flag |= RX_FLAG_FAILED_FCS_CRC;
+	hdr = (struct ieee80211_hdr *)(skb->data + stats->rx_drvinfo_size
+	      + stats->rx_bufshift);
 
-	if (!GET_RX_STATUS_DESC_SWDEC(pdesc))
-		rx_status->flag |= RX_FLAG_DECRYPTED;
+	if (stats->crc)
+		rx_status->flag |= RX_FLAG_FAILED_FCS_CRC;
 
-	if (GET_RX_STATUS_DESC_BW(pdesc))
+	if (stats->rx_is40Mhzpacket)
 		rx_status->flag |= RX_FLAG_40MHZ;
 
-	if (GET_RX_STATUS_DESC_RX_HT(pdesc))
+	if (stats->is_ht)
 		rx_status->flag |= RX_FLAG_HT;
 
 	rx_status->flag |= RX_FLAG_MACTIME_MPDU;
 
-	if (stats->decrypted)
-		rx_status->flag |= RX_FLAG_DECRYPTED;
+	/* hw will set stats->decrypted true, if it finds the
+	 * frame is open data frame or mgmt frame,
+	 * hw will not decrypt robust managment frame
+	 * for IEEE80211w but still set stats->decrypted
+	 * true, so here we should set it back to undecrypted
+	 * for IEEE80211w frame, and mac80211 sw will help
+	 * to decrypt it */
+	if (stats->decrypted) {
+		if ((ieee80211_is_robust_mgmt_frame(hdr)) &&
+			(ieee80211_has_protected(hdr->frame_control)))
+			rx_status->flag &= ~RX_FLAG_DECRYPTED;
+		else
+			rx_status->flag |= RX_FLAG_DECRYPTED;
+	}
 
 	rx_status->rate_idx = rtlwifi_rate_mapping(hw,
-				(bool)GET_RX_STATUS_DESC_RX_HT(pdesc),
-				(u8)GET_RX_STATUS_DESC_RX_MCS(pdesc));
-
+			     stats->is_ht, stats->rate);
 
-	rx_status->mactime = GET_RX_STATUS_DESC_TSFL(pdesc);
+	rx_status->mactime = stats->timestamp_low;
 	if (phystatus) {
 		p_drvinfo = (struct rx_fwinfo *)(skb->data +
 						 stats->rx_bufshift);
Index: wireless-testing-new/drivers/net/wireless/rtlwifi/wifi.h
===================================================================
--- wireless-testing-new.orig/drivers/net/wireless/rtlwifi/wifi.h
+++ wireless-testing-new/drivers/net/wireless/rtlwifi/wifi.h
@@ -450,6 +450,7 @@ enum rtl_var_map {
 	EFUSE_HWSET_MAX_SIZE,
 	EFUSE_MAX_SECTION_MAP,
 	EFUSE_REAL_CONTENT_SIZE,
+	EFUSE_OOB_PROTECT_BYTES_LEN,
 
 	/*CAM map */
 	RWCAM,
@@ -1324,6 +1325,7 @@ struct rtl_stats {
 	s8 rx_mimo_signalquality[2];
 	bool packet_matchbssid;
 	bool is_cck;
+	bool is_ht;
 	bool packet_toself;
 	bool packet_beacon;	/*for rssi */
 	char cck_adc_pwdb[4];	/*for rx path selection */

[-- Attachment #6: 0005-rtlwifi-rtl8192de-Updates-from-latest-Reaktek-driver.patch --]
[-- Type: text/x-patch, Size: 7962 bytes --]

>From 319071578daa1e1a151d4488510c3b706e2803cd Mon Sep 17 00:00:00 2001
From: Larry Finger <Larry.Finger@lwfinger.net>
Date: Wed, 5 Oct 2011 11:14:37 -0500
Subject: [PATCH 5/5] rtlwifi: rtl8192de: Updates from latest Reaktek driver -
 Part III
To: linville@tuxdriver.com
Cc: linux-wireless@vger.kernel.org

From: Chaoming Li <chaoming_li@realsil.com.cn>

This patch incorporate the differences between the 06/20/2011 and
08/16/2011 Realtek releases of the rtl8192de driver.

The changes include:

1. Update for new chip versions

Signed-off-by: Chaoming Li <chaoming_li@realsil.com.cn>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
---
 drivers/net/wireless/rtlwifi/rtl8192de/def.h |  124 ++++++++++++++++----------
 drivers/net/wireless/rtlwifi/rtl8192de/hw.c  |   19 ++---
 2 files changed, 84 insertions(+), 59 deletions(-)

Index: wireless-testing-new/drivers/net/wireless/rtlwifi/rtl8192de/def.h
===================================================================
--- wireless-testing-new.orig/drivers/net/wireless/rtlwifi/rtl8192de/def.h
+++ wireless-testing-new/drivers/net/wireless/rtlwifi/rtl8192de/def.h
@@ -122,60 +122,99 @@
 #define	GET_C2H_CMD_FEEDBACK_CCX_SEQ(__pcmdfbhdr)	\
 	LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 20, 12)
 
-/*
- * 92D chip ver:
- * BIT8: IS 92D
- * BIT9: single phy
- * BIT10: C-cut
- * BIT11: D-cut
- */
-
-/* Chip specific */
-#define CHIP_92C			BIT(0)
-#define CHIP_92C_1T2R			BIT(1)
-#define CHIP_8723			BIT(2) /* RTL8723 With BT feature */
-#define CHIP_8723_DRV_REV		BIT(3) /* RTL8723 Driver Revised */
-#define NORMAL_CHIP			BIT(4)
-#define CHIP_VENDOR_UMC			BIT(5)
-#define CHIP_VENDOR_UMC_B_CUT		BIT(6) /* Chip version for ECO */
+enum version_8192d {
+	VERSION_TEST_CHIP_88C = 0x0000,
+	VERSION_TEST_CHIP_92C = 0x0020,
+	VERSION_TEST_UMC_CHIP_8723 = 0x0081,
+	VERSION_NORMAL_TSMC_CHIP_88C = 0x0008,
+	VERSION_NORMAL_TSMC_CHIP_92C = 0x0028,
+	VERSION_NORMAL_TSMC_CHIP_92C_1T2R = 0x0018,
+	VERSION_NORMAL_UMC_CHIP_88C_A_CUT = 0x0088,
+	VERSION_NORMAL_UMC_CHIP_92C_A_CUT = 0x00a8,
+	VERSION_NORMAL_UMC_CHIP_92C_1T2R_A_CUT = 0x0098,
+	VERSION_NORMAL_UMC_CHIP_8723_1T1R_A_CUT = 0x0089,
+	VERSION_NORMAL_UMC_CHIP_8723_1T1R_B_CUT = 0x1089,
+	VERSION_NORMAL_UMC_CHIP_88C_B_CUT = 0x1088,
+	VERSION_NORMAL_UMC_CHIP_92C_B_CUT = 0x10a8,
+	VERSION_NORMAL_UMC_CHIP_92C_1T2R_B_CUT = 0x1090,
+	VERSION_TEST_CHIP_92D_SINGLEPHY = 0x0022,
+	VERSION_TEST_CHIP_92D_DUALPHY = 0x0002,
+	VERSION_NORMAL_CHIP_92D_SINGLEPHY = 0x002a,
+	VERSION_NORMAL_CHIP_92D_DUALPHY = 0x000a,
+	VERSION_NORMAL_CHIP_92D_C_CUT_SINGLEPHY = 0x202a,
+	VERSION_NORMAL_CHIP_92D_C_CUT_DUALPHY = 0x200a,
+	VERSION_NORMAL_CHIP_92D_D_CUT_SINGLEPHY = 0x302a,
+	VERSION_NORMAL_CHIP_92D_D_CUT_DUALPHY = 0x300a,
+	VERSION_NORMAL_CHIP_92D_E_CUT_SINGLEPHY = 0x402a,
+	VERSION_NORMAL_CHIP_92D_E_CUT_DUALPHY = 0x400a,
+};
 
 /* for 92D */
-#define CHIP_92D			BIT(8)
 #define CHIP_92D_SINGLEPHY		BIT(9)
+#define C_CUT_VERSION			BIT(13)
+#define D_CUT_VERSION			((BIT(12)|BIT(13)))
+#define E_CUT_VERSION			BIT(14)
+
+/* Chip specific */
+#define CHIP_BONDING_IDENTIFIER(_value)	(((_value)>>22)&0x3)
+#define CHIP_BONDING_92C_1T2R			0x1
+#define CHIP_BONDING_88C_USB_MCARD		0x2
+#define CHIP_BONDING_88C_USB_HP			0x1
+
+/* [15:12] IC version(CUT): A-cut=0, B-cut=1, C-cut=2, D-cut=3 */
+/* [7] Manufacturer: TSMC=0, UMC=1 */
+/* [6:4] RF type: 1T1R=0, 1T2R=1, 2T2R=2 */
+/* [3] Chip type: TEST=0, NORMAL=1 */
+/* [2:0] IC type: 81xxC=0, 8723=1, 92D=2 */
+#define CHIP_8723			BIT(0)
+#define CHIP_92D			BIT(1)
+#define NORMAL_CHIP			BIT(3)
+#define RF_TYPE_1T1R			(~(BIT(4)|BIT(5)|BIT(6)))
+#define RF_TYPE_1T2R			BIT(4)
+#define RF_TYPE_2T2R			BIT(5)
+#define CHIP_VENDOR_UMC			BIT(7)
+#define B_CUT_VERSION			BIT(12)
+
+/* MASK */
+#define IC_TYPE_MASK			(BIT(0)|BIT(1)|BIT(2))
+#define CHIP_TYPE_MASK			BIT(3)
+#define RF_TYPE_MASK			(BIT(4)|BIT(5)|BIT(6))
+#define MANUFACTUER_MASK		BIT(7)
+#define ROM_VERSION_MASK		(BIT(11)|BIT(10)|BIT(9)|BIT(8))
+#define CUT_VERSION_MASK		(BIT(15)|BIT(14)|BIT(13)|BIT(12))
+
+
+/* Get element */
+#define GET_CVID_IC_TYPE(version)	((version) & IC_TYPE_MASK)
+#define GET_CVID_CHIP_TYPE(version)	((version) & CHIP_TYPE_MASK)
+#define GET_CVID_RF_TYPE(version)	((version) & RF_TYPE_MASK)
+#define GET_CVID_MANUFACTUER(version)	((version) & MANUFACTUER_MASK)
+#define GET_CVID_ROM_VERSION(version)	((version) & ROM_VERSION_MASK)
+#define GET_CVID_CUT_VERSION(version)	((version) & CUT_VERSION_MASK)
+
+#define IS_1T1R(version)		((GET_CVID_RF_TYPE(version)) ?	\
+					 false : true)
+#define IS_1T2R(version)		((GET_CVID_RF_TYPE(version) ==	\
+					 RF_TYPE_1T2R) ? true : false)
+#define IS_2T2R(version)		((GET_CVID_RF_TYPE(version) ==	\
+					 RF_TYPE_2T2R) ? true : false)
+
+#define IS_92D_SINGLEPHY(version)	((IS_92D(version)) ?		\
+				 (IS_2T2R(version) ? true : false) : false)
+#define IS_92D(version)			((GET_CVID_IC_TYPE(version) ==	\
+					 CHIP_92D) ? true : false)
+#define IS_92D_C_CUT(version)		((IS_92D(version)) ?		\
+				 ((GET_CVID_CUT_VERSION(version) ==	\
+				 0x2000) ? true : false) : false)
+#define IS_92D_D_CUT(version)			((IS_92D(version)) ?	\
+				 ((GET_CVID_CUT_VERSION(version) ==	\
+				 0x3000) ? true : false) : false)
+#define IS_92D_E_CUT(version)		((IS_92D(version)) ?		\
+				 ((GET_CVID_CUT_VERSION(version) ==	\
+				 0x4000) ? true : false) : false)
 #define CHIP_92D_C_CUT			BIT(10)
 #define CHIP_92D_D_CUT			BIT(11)
 
-enum version_8192d {
-	VERSION_TEST_CHIP_88C = 0x00,
-	VERSION_TEST_CHIP_92C = 0x01,
-	VERSION_NORMAL_TSMC_CHIP_88C = 0x10,
-	VERSION_NORMAL_TSMC_CHIP_92C = 0x11,
-	VERSION_NORMAL_TSMC_CHIP_92C_1T2R = 0x13,
-	VERSION_NORMAL_UMC_CHIP_88C_A_CUT = 0x30,
-	VERSION_NORMAL_UMC_CHIP_92C_A_CUT = 0x31,
-	VERSION_NORMAL_UMC_CHIP_92C_1T2R_A_CUT = 0x33,
-	VERSION_NORMA_UMC_CHIP_8723_1T1R_A_CUT = 0x34,
-	VERSION_NORMA_UMC_CHIP_8723_1T1R_B_CUT = 0x3c,
-	VERSION_NORMAL_UMC_CHIP_88C_B_CUT = 0x70,
-	VERSION_NORMAL_UMC_CHIP_92C_B_CUT = 0x71,
-	VERSION_NORMAL_UMC_CHIP_92C_1T2R_B_CUT = 0x73,
-	VERSION_TEST_CHIP_92D_SINGLEPHY = 0x300,
-	VERSION_TEST_CHIP_92D_DUALPHY = 0x100,
-	VERSION_NORMAL_CHIP_92D_SINGLEPHY = 0x310,
-	VERSION_NORMAL_CHIP_92D_DUALPHY = 0x110,
-	VERSION_NORMAL_CHIP_92D_C_CUT_SINGLEPHY = 0x710,
-	VERSION_NORMAL_CHIP_92D_C_CUT_DUALPHY = 0x510,
-	VERSION_NORMAL_CHIP_92D_D_CUT_SINGLEPHY = 0xB10,
-	VERSION_NORMAL_CHIP_92D_D_CUT_DUALPHY = 0x910,
-};
-
-#define IS_92D_SINGLEPHY(version)		\
-	((version & CHIP_92D_SINGLEPHY) ? true : false)
-#define IS_92D_C_CUT(version)			\
-	((version & CHIP_92D_C_CUT) ? true : false)
-#define IS_92D_D_CUT(version)			\
-	((version & CHIP_92D_D_CUT) ? true : false)
-
 enum rf_optype {
 	RF_OP_BY_SW_3WIRE = 0,
 	RF_OP_BY_FW,
Index: wireless-testing-new/drivers/net/wireless/rtlwifi/rtl8192de/hw.c
===================================================================
--- wireless-testing-new.orig/drivers/net/wireless/rtlwifi/rtl8192de/hw.c
+++ wireless-testing-new/drivers/net/wireless/rtlwifi/rtl8192de/hw.c
@@ -1608,17 +1608,16 @@ static void _rtl92de_read_txpower_info(s
 		tempval[0] = hwinfo[EEPROM_IQK_DELTA] & 0x03;
 		tempval[1] = (hwinfo[EEPROM_LCK_DELTA] & 0x0C) >> 2;
 		rtlefuse->txpwr_fromeprom = true;
-		if (IS_92D_D_CUT(rtlpriv->rtlhal.version)) {
+		if (IS_92D_D_CUT(rtlpriv->rtlhal.version) ||
+		    IS_92D_E_CUT(rtlpriv->rtlhal.version)) {
 			rtlefuse->internal_pa_5g[0] =
-				 !((hwinfo[EEPROM_TSSI_A_5G] &
-				 BIT(6)) >> 6);
+				!((hwinfo[EEPROM_TSSI_A_5G] & BIT(6)) >> 6);
 			rtlefuse->internal_pa_5g[1] =
-				 !((hwinfo[EEPROM_TSSI_B_5G] &
-				 BIT(6)) >> 6);
-			RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
+				!((hwinfo[EEPROM_TSSI_B_5G] & BIT(6)) >> 6);
+			RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
 				 ("Is D cut,Internal PA0 %d Internal PA1 %d\n",
-				  rtlefuse->internal_pa_5g[0],
-				  rtlefuse->internal_pa_5g[1]))
+				 rtlefuse->internal_pa_5g[0],
+				 rtlefuse->internal_pa_5g[1]))
 		}
 		rtlefuse->eeprom_c9 = hwinfo[EEPROM_RF_OPT6];
 		rtlefuse->eeprom_cc = hwinfo[EEPROM_RF_OPT7];

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: 答复: 答复: 答复: 3.1-rc6+ rtl8192se issue
  2011-10-06  2:37                           ` Larry Finger
@ 2011-11-15 13:59                             ` Borislav Petkov
  0 siblings, 0 replies; 16+ messages in thread
From: Borislav Petkov @ 2011-11-15 13:59 UTC (permalink / raw)
  To: Larry Finger; +Cc: 李朝明, linux-wireless, 'LKML'

On Wed, Oct 05, 2011 at 09:37:25PM -0500, Larry Finger wrote:
> I have been going though the differences between the 06/20/2011 and
> 08/16/2011 drivers and making those changes to the kernel drivers.
> Could you please apply the 5 attached patches to the
> wireless-testing tree and see if your sluggishness is fixed?

Just to document it here:

3.1 still has the problem, if you have something ready ported to 3.1
from the Realsil driver version, let me know and I'll give it a run.

Thanks.

-- 
Regards/Gruss,
   Boris

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2011-11-15 13:59 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-15 12:44 3.1-rc6+ rtl8192se issue Borislav Petkov
2011-09-15 15:23 ` Larry Finger
2011-09-15 18:41   ` Borislav Petkov
2011-09-16 18:03   ` Borislav Petkov
     [not found]     ` <CD4D8CF16C39438E82FE8241C9AF80F4@realsil.com.cn>
2011-09-19  9:54       ` 答复: " Borislav Petkov
2011-09-19 17:13       ` Borislav Petkov
2011-09-21 18:58       ` Borislav Petkov
     [not found]         ` <791179BCE62F4954AB936E6CAC9CA977@realsil.com.cn>
     [not found]           ` <4E7AAB8B.40900@lwfinger.net>
2011-09-22  7:51             ` 答复: " Borislav Petkov
     [not found]               ` <6452E68488784D0EA32E4BDF1B941EFB@realsil.com.cn>
2011-09-23 10:33                 ` 答复: " Borislav Petkov
2011-09-23 13:50                   ` Larry Finger
2011-09-23 16:34                   ` Larry Finger
2011-09-28 13:18                     ` Borislav Petkov
2011-09-29  1:57                       ` Larry Finger
2011-10-05 15:15                         ` Borislav Petkov
2011-10-06  2:37                           ` Larry Finger
2011-11-15 13:59                             ` Borislav Petkov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.