Linux wireless drivers development
 help / color / mirror / Atom feed
* Re: RTL 8187b - naughty behaviour
From: Rogerio Luz Coelho @ 2010-06-03 15:40 UTC (permalink / raw)
  To: Gábor Stefanik; +Cc: linux-wireless, Herton Ronaldo Krzesinski
In-Reply-To: <q2k69e28c911004110635nac8100f6pe014361ed0a516a5@mail.gmail.com>

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

You need to enable MMIO tracing support in your kernel config, and
> recompile your kernel (assuming it is not enabled already - distros
> usually disable the entire tracing framework by default). Then:
> -Mount debugfs to /debug. (Usually it is mounted by default, but some
> distros like to mount it @ /sys/kernel/debug instead - remount it to
> /debug.)
> -"echo mmiotrace > /debug/tracing/current_tracer"
> -"cat /debug/tracing/trace_pipe >  trace.txt &" - at this point, tracing begins.
> -Load r8187b and connect.
> -"echo "Driver loaded!" > /debug/tracing/trace_marker"
> -"echo nop


Ok here are some news: 

1) The rtl8187b problem is a know bug in Ubuntu since forever - bug
#215802 https://bugs.launchpad.net/ubuntu/+source/linux/+bug/215802

2) Tryied the Realtek driver found in: 
http://ubuntuforums.org/showthread.php?t=1446894 
(rtl8187B_linux_26.1056.1112.2009.release.tar.gz )

- as seno said here on the list in 14-05-2010 17:20:02

It installs a module called r8187b, witch I managed to use ONCE, after
it installed, then after it disconnected it would not connect again, and
after I rebooted there was no more wi-fi interface (!!!) ifconfig and
iwconfig confirm that my wi-fi card (wlan0) is nowhere to be found

5) Rate seems weird on this card. If I define the rate with 
"iwconfig wlan0 rate 11M" it gives the best download speed, even if I
rase this to 24M or 54M I get at least a 40% difference, same if I lower
the rate. 
Maybe what Hin-Tak Leung (2010-04-03) said about the Minstrel algorithm?
Could we try to install both Minstrel and older algorithms side by side
and make a comparison? from what I read here: 

http://wireless.kernel.org/en/developers/Documentation/mac80211/RateControl/minstrel
"Further, it means that the 1 Mbps rate (which typically has a high
probability of successful transmission) will not be used in preference
to the 11 Mbps rate." 

But my rate is always a defaulted 1Mb/s on bootup. I put it to 11M
manually and the connection improves dramatically 

4) Ran the mmiotrace on the rtl8187 driver, it all seems gibberish to
me ;) 

one while it was at 1m from the router giving me top speed (same as
Win7): trace1.txt:
 
VERSION 20070824
PCIDEV 0000 10390671 0 d0000000 0 0 0 0 0 0 8000000 0 0 0 0 0 0
agpgart-sis
PCIDEV 0008 10390003 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
PCIDEV 0010 10390968 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
PCIDEV 0015 10395513 10 1f0 3f6 170 376 1081 0 0 8 0 8 0 10 0 0 pata_sis
PCIDEV 0018 10397001 14 d8404000 0 0 0 0 0 0 1000 0 0 0 0 0 0 ohci_hcd
PCIDEV 0019 10397001 15 d8405000 0 0 0 0 0 0 1000 0 0 0 0 0 0 ohci_hcd
PCIDEV 001b 10397002 16 d8406000 0 0 0 0 0 0 1000 0 0 0 0 0 0 ehci_hcd
PCIDEV 0020 10390191 13 d8407000 1001 0 0 0 0 0 80 80 0 0 0 0 0 sis190
PCIDEV 0028 10391183 11 10c9 10bd 10c1 10b9 10a1 0 0 8 4 8 4 10 0 0
sata_sis
PCIDEV 0030 1039000a 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 pcieport
PCIDEV 0038 1039000a 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 pcieport
PCIDEV 0078 10397502 12 d8400000 0 0 0 0 0 0 4000 0 0 0 0 0 0 HDA Intel
PCIDEV 00f8 10390004 1a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 pcieport
PCIDEV 0100 10396351 10 c0000008 d8000000 9001 0 0 0 2 10000000 20000 80
0 0 0 0 
PCIDEV 0300 197b2382 10 d8100000 0 0 0 0 0 d8500000 100 0 0 0 0 0 10000
sdhci-pci
PCIDEV 0302 197b2381 10 d8100400 0 0 0 0 0 0 100 0 0 0 0 0 0 
PCIDEV 0303 197b2383 10 d8100800 0 0 0 0 0 0 100 0 0 0 0 0 0 jmb38x_ms

** then when it was about 10m - failed to connect (Windows 7 connects
normally) trace2.txt 

VERSION 20070824
PCIDEV 0000 10390671 0 d0000000 0 0 0 0 0 0 8000000 0 0 0 0 0 0
agpgart-sis
PCIDEV 0008 10390003 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
PCIDEV 0010 10390968 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
PCIDEV 0015 10395513 10 1f0 3f6 170 376 1081 0 0 8 0 8 0 10 0 0 pata_sis
PCIDEV 0018 10397001 14 d8404000 0 0 0 0 0 0 1000 0 0 0 0 0 0 ohci_hcd
PCIDEV 0019 10397001 15 d8405000 0 0 0 0 0 0 1000 0 0 0 0 0 0 ohci_hcd
PCIDEV 001b 10397002 16 d8406000 0 0 0 0 0 0 1000 0 0 0 0 0 0 ehci_hcd
PCIDEV 0020 10390191 13 d8407000 1001 0 0 0 0 0 80 80 0 0 0 0 0 sis190
PCIDEV 0028 10391183 11 10c9 10bd 10c1 10b9 10a1 0 0 8 4 8 4 10 0 0
sata_sis
PCIDEV 0030 1039000a 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 pcieport
PCIDEV 0038 1039000a 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 pcieport
PCIDEV 0078 10397502 12 d8400000 0 0 0 0 0 0 4000 0 0 0 0 0 0 HDA Intel
PCIDEV 00f8 10390004 1a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 pcieport
PCIDEV 0100 10396351 10 c0000008 d8000000 9001 0 0 0 2 10000000 20000 80
0 0 0 0 
PCIDEV 0300 197b2382 10 d8100000 0 0 0 0 0 d8500000 100 0 0 0 0 0 10000
sdhci-pci
PCIDEV 0302 197b2381 10 d8100400 0 0 0 0 0 0 100 0 0 0 0 0 0 
PCIDEV 0303 197b2383 10 d8100800 0 0 0 0 0 0 100 0 0 0 0 0 0 jmb38x_ms

*** All the steps asked by Gábor were done. 

Thanks all you guys.

Rogerio 

[-- Attachment #2: trace2.txt --]
[-- Type: text/plain, Size: 1183 bytes --]

VERSION 20070824
PCIDEV 0000 10390671 0 d0000000 0 0 0 0 0 0 8000000 0 0 0 0 0 0 agpgart-sis
PCIDEV 0008 10390003 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
PCIDEV 0010 10390968 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
PCIDEV 0015 10395513 10 1f0 3f6 170 376 1081 0 0 8 0 8 0 10 0 0 pata_sis
PCIDEV 0018 10397001 14 d8404000 0 0 0 0 0 0 1000 0 0 0 0 0 0 ohci_hcd
PCIDEV 0019 10397001 15 d8405000 0 0 0 0 0 0 1000 0 0 0 0 0 0 ohci_hcd
PCIDEV 001b 10397002 16 d8406000 0 0 0 0 0 0 1000 0 0 0 0 0 0 ehci_hcd
PCIDEV 0020 10390191 13 d8407000 1001 0 0 0 0 0 80 80 0 0 0 0 0 sis190
PCIDEV 0028 10391183 11 10c9 10bd 10c1 10b9 10a1 0 0 8 4 8 4 10 0 0 sata_sis
PCIDEV 0030 1039000a 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 pcieport
PCIDEV 0038 1039000a 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 pcieport
PCIDEV 0078 10397502 12 d8400000 0 0 0 0 0 0 4000 0 0 0 0 0 0 HDA Intel
PCIDEV 00f8 10390004 1a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 pcieport
PCIDEV 0100 10396351 10 c0000008 d8000000 9001 0 0 0 2 10000000 20000 80 0 0 0 0 
PCIDEV 0300 197b2382 10 d8100000 0 0 0 0 0 d8500000 100 0 0 0 0 0 10000 sdhci-pci
PCIDEV 0302 197b2381 10 d8100400 0 0 0 0 0 0 100 0 0 0 0 0 0 
PCIDEV 0303 197b2383 10 d8100800 0 0 0 0 0 0 100 0 0 0 0 0 0 jmb38x_ms

[-- Attachment #3: trace1.txt --]
[-- Type: text/plain, Size: 1183 bytes --]

VERSION 20070824
PCIDEV 0000 10390671 0 d0000000 0 0 0 0 0 0 8000000 0 0 0 0 0 0 agpgart-sis
PCIDEV 0008 10390003 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
PCIDEV 0010 10390968 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
PCIDEV 0015 10395513 10 1f0 3f6 170 376 1081 0 0 8 0 8 0 10 0 0 pata_sis
PCIDEV 0018 10397001 14 d8404000 0 0 0 0 0 0 1000 0 0 0 0 0 0 ohci_hcd
PCIDEV 0019 10397001 15 d8405000 0 0 0 0 0 0 1000 0 0 0 0 0 0 ohci_hcd
PCIDEV 001b 10397002 16 d8406000 0 0 0 0 0 0 1000 0 0 0 0 0 0 ehci_hcd
PCIDEV 0020 10390191 13 d8407000 1001 0 0 0 0 0 80 80 0 0 0 0 0 sis190
PCIDEV 0028 10391183 11 10c9 10bd 10c1 10b9 10a1 0 0 8 4 8 4 10 0 0 sata_sis
PCIDEV 0030 1039000a 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 pcieport
PCIDEV 0038 1039000a 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 pcieport
PCIDEV 0078 10397502 12 d8400000 0 0 0 0 0 0 4000 0 0 0 0 0 0 HDA Intel
PCIDEV 00f8 10390004 1a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 pcieport
PCIDEV 0100 10396351 10 c0000008 d8000000 9001 0 0 0 2 10000000 20000 80 0 0 0 0 
PCIDEV 0300 197b2382 10 d8100000 0 0 0 0 0 d8500000 100 0 0 0 0 0 10000 sdhci-pci
PCIDEV 0302 197b2381 10 d8100400 0 0 0 0 0 0 100 0 0 0 0 0 0 
PCIDEV 0303 197b2383 10 d8100800 0 0 0 0 0 0 100 0 0 0 0 0 0 jmb38x_ms

^ permalink raw reply

* Re: IWL3945 problems in 2.6.35-rc1
From: reinette chatre @ 2010-06-03 15:55 UTC (permalink / raw)
  To: sedat.dilek@gmail.com
  Cc: Kolekar, Abhijeet, Maxim Levitsky, linux-wireless,
	iwlwifi maling list
In-Reply-To: <AANLkTinDduWj_BbLINeMmF3hChf4x2znxDLhWDDJzQqY@mail.gmail.com>

Hi Sedat,

On Thu, 2010-06-03 at 02:18 -0700, Sedat Dilek wrote:
> The good news at first:
> Your patch applies against 2.6.35-rc1 vanilla (tested with linux-2.6 GIT).

That was what you asked for.

> BUT....
> This patch should be renamed to "iwl3945-fix-internal-scan-2.6.35-rc1.patch".

Feel free to rename it.


> It differs from the one in iwiwifi-2.6 (see below).

Right, I had to make a change to the patch to get it to apply to
2.6.35-rc1.

> Thus, I said to myself let's dig deeper into it.
> 
> First, here is my GIT workflow (I use linux-2.6 rcX, later pull in
> wireless-2.6 and finally iwlwifi-2.6 master GIT)
> 
> [CODE]
> $ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
> 
> $ git reset --hard v2.6.35-rc1
> 
> $ git pull git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-2.6.git
> master:wireless-2.6

ok so far.

> 
> $ git pull http://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/iwlwifi-2.6.git
> master:iwlwifi-2.6

Don't do this. iwlwifi-2.6's master branch is a clone of
wireless-testing's master branch plus all the iwlwifi patches that has
not been sent to wireless-testing yet.

> [/CODE]
> 
> If I do so, I get NON-iwlwifi related stuff pulled in and that should
> not be the case?

This is how we work. iwlwifi-2.6's master branch tracks upstream
wireless development from wireless-testing. 

> I am not a git tool expert, there might be some magic tricks I do not know.
> Thanks for any hints on git tool :-).
> 
> It would be very helpfull (if you want people to follow iwlwifi
> development) to have something similiar like in linux-wireless GIT
> trees - just a proposal:
> 
> iwlwifi-2.6 -> wireless-2.6 -> net-2.6 -> linux-2.6
> iwlwifi-next-2.6 -> wireless-next-2.6 -> net-next-2.6 -> linux-next
> iwlwifi-testing -> wireless-testing

iwlwifi-2.6 has a wireless-2.6 and wireless-next-2.6 branch that
accomplishes this. We do not see the need for more repositories.

> As I said I am no git expert, so I don't know if you want to setup 3
> diverse GIT repsoitories (as John did for wireless-* trees) or have 3
> different GIT branches within existing iwlwifi-2.6 GIT repository as
> in drm-2.6 [1].

We have three branches.

Reinette


^ permalink raw reply

* Re: linux-next: Tree for June 3 (iwlwifi)
From: Randy Dunlap @ 2010-06-03 15:55 UTC (permalink / raw)
  To: Stephen Rothwell, linux-wireless; +Cc: linux-next, LKML
In-Reply-To: <20100603134753.710a64b3.sfr@canb.auug.org.au>

On Thu, 3 Jun 2010 13:47:53 +1000 Stephen Rothwell wrote:

> Hi all,
> 
> Changes since 20100602:


when CONFIG_IWLAGN=n:

drivers/net/wireless/iwlwifi/iwl-rx.c:254: error: 'struct iwl_priv' has no member named '_agn'
drivers/net/wireless/iwlwifi/iwl-rx.c:303: error: 'struct iwl_priv' has no member named '_agn'
drivers/net/wireless/iwlwifi/iwl-rx.c:304: error: 'struct iwl_priv' has no member named '_agn'
drivers/net/wireless/iwlwifi/iwl-rx.c:305: error: 'struct iwl_priv' has no member named '_agn'
drivers/net/wireless/iwlwifi/iwl-rx.c:306: error: 'struct iwl_priv' has no member named '_agn'

and many more.

Haven't we seen this movie before?

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

^ permalink raw reply

* Re: iwl3945 oops with latest git
From: Sedat Dilek @ 2010-06-03 15:56 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Miklos Szeredi, Reinette Chatre, linux-kernel, linux-wireless
In-Reply-To: <20100603151752.GB2053@tiehlicka.suse.cz>

The patch in [1] applies against 2.6.35-rc1 and works fine since...

$ uptime
 17:54:38 up  2:32,  1 user,  load average: 0.23, 0.26, 0.18

$ cat /proc/version
Linux version 2.6.35-rc1-iniza-686-kms (Debian 2.6.35~rc1-4~git1.sd.1)
(sedat.dilek@gmail.com) (gcc version 4.4.4 (Debian 4.4.4-4) ) #1 SMP
PREEMPT Thu Jun 3 14:58:19 CEST 2010

Hope this information helps you.

- Sedat -

[1] https://patchwork.kernel.org/patch/104010/

On Thu, Jun 3, 2010 at 5:17 PM, Michal Hocko <mhocko@suse.cz> wrote:
> On Thu 03-06-10 17:01:50, Miklos Szeredi wrote:
>> Hi,
>
> Hi,
>
>>
>> This oops comes shortly after booting machine and using wireless
>> network.  Reproduced two times now.
>>
>> Please let me know if you need more info.
>>
>> Thanks,
>> Miklos
>>
>>
>> BUG: unable to handle kernel NULL pointer dereference at (null)
>> IP: [<ffffffffa022738f>] iwl3945_request_scan+0x961/0xd68 [iwl3945]
>
> Sounds pretty much like https://patchwork.kernel.org/patch/103596/
> I have similar problem but didn't get to testing the patch.
>
>> PGD 0
>> Oops: 0000 [#1] PREEMPT SMP
>> last sysfs file: /sys/class/rfkill/rfkill1/state
>> CPU 0
>> Modules linked in: nfs lockd nfs_acl sunrpc rfcomm sco bnep l2cap acpi_cpufreq mperf nf_conntrack_netbios_ns fuse iwl3945 iwlcore thinkpad_acpi nsc_ircc mac80211 backlight btusb led_class uinput ac irda battery crc_ccitt thermal cfg80211 bluetooth button processor e1000e rfkill kvm_intel kvm
>>
>> Pid: 1493, comm: iwl3945 Not tainted 2.6.35-rc1-00194-gaef4b9a #76 2007FUG/2007FUG
>> RIP: 0010:[<ffffffffa022738f>]  [<ffffffffa022738f>] iwl3945_request_scan+0x961/0xd68 [iwl3945]
>> RSP: 0018:ffff8800b4d71d10  EFLAGS: 00010287
>> RAX: ffff8800bea80c00 RBX: ffff8800b4171380 RCX: 0000000000000021
>> RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff8800b4171380
>> RBP: ffff8800b4d71de0 R08: 000000000000030e R09: 00000000ffffffff
>> R10: 000000000ad21900 R11: 0000000000000292 R12: 0000000000000000
>> R13: ffff8800b60950f2 R14: 0000000000000000 R15: 0000000000000058
>> FS:  0000000000000000(0000) GS:ffff880001a00000(0000) knlGS:0000000000000000
>> CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
>> CR2: 0000000000000000 CR3: 0000000001612000 CR4: 00000000000006f0
>> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
>> DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
>> Process iwl3945 (pid: 1493, threadinfo ffff8800b4d70000, task ffff8800b6790940)
>> Stack:
>>  ffff880001a12f40 0000000000012f40 ffff8800b64f8800 ffffffff8161a378
>> <0> 0000000000000000 ffff8800b6095000 00578800b4d71e20 0000005800000021
>> <0> ffff8800b4d71fd8 00ff8800b4175128 ffff8800b4d71fd8 002188ffb6790940
>> Call Trace:
>>  [<ffffffffa01f9bb5>] iwl_bg_start_internal_scan+0x34f/0x371 [iwlcore]
>>  [<ffffffff8104e175>] worker_thread+0x1fc/0x2a3
>>  [<ffffffffa01f9866>] ? iwl_bg_start_internal_scan+0x0/0x371 [iwlcore]
>>  [<ffffffff81051d96>] ? autoremove_wake_function+0x0/0x34
>>  [<ffffffff813f4590>] ? _raw_spin_unlock_irqrestore+0x27/0x29
>>  [<ffffffff8104df79>] ? worker_thread+0x0/0x2a3
>>  [<ffffffff810518db>] kthread+0x7a/0x82
>>  [<ffffffff81002c94>] kernel_thread_helper+0x4/0x10
>>  [<ffffffff81051861>] ? kthread+0x0/0x82
>>  [<ffffffff81002c90>] ? kernel_thread_helper+0x0/0x10
>> Code: 48 b5 00 00 48 89 45 80 48 89 85 70 ff ff ff 41 8d 47 ff 66 89 85 66 ff ff ff e9 43 02 00 00 48 63 55 a8 4c 8b 64 d0 38 8b 55 a4 <41> 39 14 24 0f 85 2a 02 00 00 66 41 8b 54 24 06 48 89 df 41 88
>> RIP  [<ffffffffa022738f>] iwl3945_request_scan+0x961/0xd68 [iwl3945]
>>  RSP <ffff8800b4d71d10>
>> CR2: 0000000000000000
>> ---[ end trace 63fe07b50f147114 ]---
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/
>
> --
> Michal Hocko
> L3 team
> SUSE LINUX s.r.o.
> Lihovarska 1060/12
> 190 00 Praha 9
> Czech Republic
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply

* Re: Problems connectring to an AP with Acer Aspire Revo
From: Christian P. Schmidt @ 2010-06-03 15:56 UTC (permalink / raw)
  To: Johannes Berg; +Cc: reinette chatre, linux-wireless@vger.kernel.org
In-Reply-To: <1275045843.3909.92.camel@jlt3.sipsolutions.net>


On 05/28/2010 01:24 PM, Johannes Berg wrote:
> On Fri, 2010-05-28 at 13:10 +0200, Christian P. Schmidt wrote:
> 
>>> Those values make no sense to me .. can you use "iw scan" and tell us
>>> the dBm value?
>>
>> This translates to -52 to -30dBm.
> 
> Ok that sounds like you have antennas.

Yes, I double checked it. Associations with my Linksys WRT54G running
OpenWRT times out as well, two laptops can successfully connect.

> Maybe try the rfkill tool:
> http://wireless.kernel.org/en/users/Documentation/rfkill

Yes, it was the rfkill tool that caused my attempts to fail. However,
this didn't change my association attempt problems.
I also took my time to look at the PCIe port - steady 3.3V on the RFKILL
pin, which means "no RFKILL".

Any further ideas?

Regards,
Christian

^ permalink raw reply

* Re: iwl3945 oops with latest git
From: Miklos Szeredi @ 2010-06-03 16:13 UTC (permalink / raw)
  To: Michal Hocko; +Cc: miklos, reinette.chatre, linux-kernel, linux-wireless
In-Reply-To: <20100603151752.GB2053@tiehlicka.suse.cz>

On Thu, 3 Jun 2010, Michal Hocko wrote:
> On Thu 03-06-10 17:01:50, Miklos Szeredi wrote:
> > Hi,
> 
> Hi,
> 
> > 
> > This oops comes shortly after booting machine and using wireless
> > network.  Reproduced two times now.
> > 
> > Please let me know if you need more info.
> > 
> > Thanks,
> > Miklos
> > 
> > 
> > BUG: unable to handle kernel NULL pointer dereference at (null)
> > IP: [<ffffffffa022738f>] iwl3945_request_scan+0x961/0xd68 [iwl3945]
> 
> Sounds pretty much like https://patchwork.kernel.org/patch/103596/
> I have similar problem but didn't get to testing the patch.

Yes, patch fixed it for me.

Thanks,
Miklos

> 
> > PGD 0 
> > Oops: 0000 [#1] PREEMPT SMP 
> > last sysfs file: /sys/class/rfkill/rfkill1/state
> > CPU 0 
> > Modules linked in: nfs lockd nfs_acl sunrpc rfcomm sco bnep l2cap acpi_cpufreq mperf nf_conntrack_netbios_ns fuse iwl3945 iwlcore thinkpad_acpi nsc_ircc mac80211 backlight btusb led_class uinput ac irda battery crc_ccitt thermal cfg80211 bluetooth button processor e1000e rfkill kvm_intel kvm
> > 
> > Pid: 1493, comm: iwl3945 Not tainted 2.6.35-rc1-00194-gaef4b9a #76 2007FUG/2007FUG
> > RIP: 0010:[<ffffffffa022738f>]  [<ffffffffa022738f>] iwl3945_request_scan+0x961/0xd68 [iwl3945]
> > RSP: 0018:ffff8800b4d71d10  EFLAGS: 00010287
> > RAX: ffff8800bea80c00 RBX: ffff8800b4171380 RCX: 0000000000000021
> > RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff8800b4171380
> > RBP: ffff8800b4d71de0 R08: 000000000000030e R09: 00000000ffffffff
> > R10: 000000000ad21900 R11: 0000000000000292 R12: 0000000000000000
> > R13: ffff8800b60950f2 R14: 0000000000000000 R15: 0000000000000058
> > FS:  0000000000000000(0000) GS:ffff880001a00000(0000) knlGS:0000000000000000
> > CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
> > CR2: 0000000000000000 CR3: 0000000001612000 CR4: 00000000000006f0
> > DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> > DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
> > Process iwl3945 (pid: 1493, threadinfo ffff8800b4d70000, task ffff8800b6790940)
> > Stack:
> >  ffff880001a12f40 0000000000012f40 ffff8800b64f8800 ffffffff8161a378
> > <0> 0000000000000000 ffff8800b6095000 00578800b4d71e20 0000005800000021
> > <0> ffff8800b4d71fd8 00ff8800b4175128 ffff8800b4d71fd8 002188ffb6790940
> > Call Trace:
> >  [<ffffffffa01f9bb5>] iwl_bg_start_internal_scan+0x34f/0x371 [iwlcore]
> >  [<ffffffff8104e175>] worker_thread+0x1fc/0x2a3
> >  [<ffffffffa01f9866>] ? iwl_bg_start_internal_scan+0x0/0x371 [iwlcore]
> >  [<ffffffff81051d96>] ? autoremove_wake_function+0x0/0x34
> >  [<ffffffff813f4590>] ? _raw_spin_unlock_irqrestore+0x27/0x29
> >  [<ffffffff8104df79>] ? worker_thread+0x0/0x2a3
> >  [<ffffffff810518db>] kthread+0x7a/0x82
> >  [<ffffffff81002c94>] kernel_thread_helper+0x4/0x10
> >  [<ffffffff81051861>] ? kthread+0x0/0x82
> >  [<ffffffff81002c90>] ? kernel_thread_helper+0x0/0x10
> > Code: 48 b5 00 00 48 89 45 80 48 89 85 70 ff ff ff 41 8d 47 ff 66 89 85 66 ff ff ff e9 43 02 00 00 48 63 55 a8 4c 8b 64 d0 38 8b 55 a4 <41> 39 14 24 0f 85 2a 02 00 00 66 41 8b 54 24 06 48 89 df 41 88 
> > RIP  [<ffffffffa022738f>] iwl3945_request_scan+0x961/0xd68 [iwl3945]
> >  RSP <ffff8800b4d71d10>
> > CR2: 0000000000000000
> > ---[ end trace 63fe07b50f147114 ]---
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at  http://www.tux.org/lkml/
> 
> -- 
> Michal Hocko
> L3 team 
> SUSE LINUX s.r.o.
> Lihovarska 1060/12
> 190 00 Praha 9    
> Czech Republic
> 

^ permalink raw reply

* Re: [PATCH] iwlwifi: use the DMA state API instead of the pci equivalents
From: reinette chatre @ 2010-06-03 16:27 UTC (permalink / raw)
  To: FUJITA Tomonori
  Cc: Zhu, Yi, ilw@linux.intel.com, linux-wireless@vger.kernel.org,
	linville@tuxdriver.com
In-Reply-To: <20100603141853Z.fujita.tomonori@lab.ntt.co.jp>

On Wed, 2010-06-02 at 22:19 -0700, FUJITA Tomonori wrote:
> This can be cleanly applied to wireless-2.6 and iwlwifi git trees.
> 
> =
> From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
> Subject: [PATCH] iwlwifi: use the DMA state API instead of the pci equivalents
> 
> This replace the PCI DMA state API (include/linux/pci-dma.h) with the
> DMA equivalents since the PCI DMA state API will be obsolete.

Does that mean we need to modify out other PCI DMA calls (eg.
pci_unmap_single etc.) also?

> 
> No functional change.
> 
> For further information about the background:
> 
> http://marc.info/?l=linux-netdev&m=127037540020276&w=2
> 
> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>

Thank you

Acked-by: Reinette Chatre <reinette.chatre@intel.com>

Reinette



^ permalink raw reply

* Re: linux-next: Tree for June 3 (iwlwifi)
From: John W. Linville @ 2010-06-03 17:21 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: Stephen Rothwell, linux-wireless, linux-next, LKML,
	reinette.chatre
In-Reply-To: <20100603085501.ac113779.randy.dunlap@oracle.com>

On Thu, Jun 03, 2010 at 08:55:01AM -0700, Randy Dunlap wrote:
> On Thu, 3 Jun 2010 13:47:53 +1000 Stephen Rothwell wrote:
> 
> > Hi all,
> > 
> > Changes since 20100602:
> 
> 
> when CONFIG_IWLAGN=n:
> 
> drivers/net/wireless/iwlwifi/iwl-rx.c:254: error: 'struct iwl_priv' has no member named '_agn'
> drivers/net/wireless/iwlwifi/iwl-rx.c:303: error: 'struct iwl_priv' has no member named '_agn'
> drivers/net/wireless/iwlwifi/iwl-rx.c:304: error: 'struct iwl_priv' has no member named '_agn'
> drivers/net/wireless/iwlwifi/iwl-rx.c:305: error: 'struct iwl_priv' has no member named '_agn'
> drivers/net/wireless/iwlwifi/iwl-rx.c:306: error: 'struct iwl_priv' has no member named '_agn'
> 
> and many more.
> 
> Haven't we seen this movie before?

Ugh...caused be this:

commit a2064b7a4a22d118087898e4308670da7ac07911
Author: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Date:   Fri Apr 30 14:21:48 2010 -0700

    iwlwifi: move _agn statistics related structure
    
    agn and 3945 has different statistics_notif data structure; since 3945
    has it statistics_notif data structure inside the _3945 portion of
    iwl_priv, it make sense to move the agn statistics_notif into _agn portion.
    
    Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
    Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>

Since iwl-rx.o is part of iwlcore.ko, this change seems wrong.
Reinette, any reason why I shouldn't just revert it?

John
-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply

* Re: linux-next: Tree for June 3 (iwlwifi)
From: Guy, Wey-Yi @ 2010-06-03 17:42 UTC (permalink / raw)
  To: John W. Linville
  Cc: Randy Dunlap, Stephen Rothwell, linux-wireless@vger.kernel.org,
	linux-next@vger.kernel.org, LKML, Chatre, Reinette
In-Reply-To: <20100603172114.GA14597@tuxdriver.com>

Hi John,

On Thu, 2010-06-03 at 10:21 -0700, John W. Linville wrote:
> On Thu, Jun 03, 2010 at 08:55:01AM -0700, Randy Dunlap wrote:
> > On Thu, 3 Jun 2010 13:47:53 +1000 Stephen Rothwell wrote:
> > 
> > > Hi all,
> > > 
> > > Changes since 20100602:
> > 
> > 
> > when CONFIG_IWLAGN=n:
> > 
> > drivers/net/wireless/iwlwifi/iwl-rx.c:254: error: 'struct iwl_priv' has no member named '_agn'
> > drivers/net/wireless/iwlwifi/iwl-rx.c:303: error: 'struct iwl_priv' has no member named '_agn'
> > drivers/net/wireless/iwlwifi/iwl-rx.c:304: error: 'struct iwl_priv' has no member named '_agn'
> > drivers/net/wireless/iwlwifi/iwl-rx.c:305: error: 'struct iwl_priv' has no member named '_agn'
> > drivers/net/wireless/iwlwifi/iwl-rx.c:306: error: 'struct iwl_priv' has no member named '_agn'
> > 
> > and many more.
> > 
> > Haven't we seen this movie before?
> 
> Ugh...caused be this:
> 
> commit a2064b7a4a22d118087898e4308670da7ac07911
> Author: Wey-Yi Guy <wey-yi.w.guy@intel.com>
> Date:   Fri Apr 30 14:21:48 2010 -0700
> 
>     iwlwifi: move _agn statistics related structure
>     
>     agn and 3945 has different statistics_notif data structure; since 3945
>     has it statistics_notif data structure inside the _3945 portion of
>     iwl_priv, it make sense to move the agn statistics_notif into _agn portion.
>     
>     Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
>     Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
> 
> Since iwl-rx.o is part of iwlcore.ko, this change seems wrong.
> Reinette, any reason why I shouldn't just revert it?
> 
Sorry for the mistake, please revert it and I will fix the issue and
re-submit.

Thanks
Wey


^ permalink raw reply

* pull request: wireless-2.6 2010-06-03
From: John W. Linville @ 2010-06-03 17:38 UTC (permalink / raw)
  To: davem; +Cc: linux-wireless, netdev, linux-kernel

Dave,

This is a handful of fixes intended for 2.6.35.  The ath5k patch fixes a
problem reported by multiple people as "Commit 6b5d11 breaks association
with WPA enabled APs".  The ones from Johannes fix a locking problem and
and a problem caused by reading the wrong data location.

Please let me know if there are problems!

Thanks,

John

---

The following changes since commit a1868dc2878e61778b9d6d8c61d5368e51d68a29:
  Jeff Kirsher (1):
        ixgbe: return IXGBE_ERR_RAR_INDEX when out of range

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-2.6.git master

Bruno Randolf (1):
      ath5k: wake queues on reset

Johannes Berg (2):
      mac80211: fix blockack-req processing
      mac80211: fix dialog token allocator

 drivers/net/wireless/ath/ath5k/base.c |   17 +++--------------
 net/mac80211/agg-tx.c                 |    6 ++++--
 net/mac80211/rx.c                     |   13 +++++++++++--
 3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index cc6d41d..2978359 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -222,7 +222,6 @@ static int ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb);
 static int ath5k_tx_queue(struct ieee80211_hw *hw, struct sk_buff *skb,
 		struct ath5k_txq *txq);
 static int ath5k_reset(struct ath5k_softc *sc, struct ieee80211_channel *chan);
-static int ath5k_reset_wake(struct ath5k_softc *sc);
 static int ath5k_start(struct ieee80211_hw *hw);
 static void ath5k_stop(struct ieee80211_hw *hw);
 static int ath5k_add_interface(struct ieee80211_hw *hw,
@@ -2770,7 +2769,7 @@ ath5k_tasklet_reset(unsigned long data)
 {
 	struct ath5k_softc *sc = (void *)data;
 
-	ath5k_reset_wake(sc);
+	ath5k_reset(sc, sc->curchan);
 }
 
 /*
@@ -2941,23 +2940,13 @@ ath5k_reset(struct ath5k_softc *sc, struct ieee80211_channel *chan)
 	ath5k_beacon_config(sc);
 	/* intrs are enabled by ath5k_beacon_config */
 
+	ieee80211_wake_queues(sc->hw);
+
 	return 0;
 err:
 	return ret;
 }
 
-static int
-ath5k_reset_wake(struct ath5k_softc *sc)
-{
-	int ret;
-
-	ret = ath5k_reset(sc, sc->curchan);
-	if (!ret)
-		ieee80211_wake_queues(sc->hw);
-
-	return ret;
-}
-
 static int ath5k_start(struct ieee80211_hw *hw)
 {
 	return ath5k_init(hw->priv);
diff --git a/net/mac80211/agg-tx.c b/net/mac80211/agg-tx.c
index c163d0a..98258b7 100644
--- a/net/mac80211/agg-tx.c
+++ b/net/mac80211/agg-tx.c
@@ -332,14 +332,16 @@ int ieee80211_start_tx_ba_session(struct ieee80211_sta *pubsta, u16 tid)
 		IEEE80211_QUEUE_STOP_REASON_AGGREGATION);
 
 	spin_unlock(&local->ampdu_lock);
-	spin_unlock_bh(&sta->lock);
 
-	/* send an addBA request */
+	/* prepare tid data */
 	sta->ampdu_mlme.dialog_token_allocator++;
 	sta->ampdu_mlme.tid_tx[tid]->dialog_token =
 			sta->ampdu_mlme.dialog_token_allocator;
 	sta->ampdu_mlme.tid_tx[tid]->ssn = start_seq_num;
 
+	spin_unlock_bh(&sta->lock);
+
+	/* send AddBA request */
 	ieee80211_send_addba_request(sdata, pubsta->addr, tid,
 			 sta->ampdu_mlme.tid_tx[tid]->dialog_token,
 			 sta->ampdu_mlme.tid_tx[tid]->ssn,
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 6e2a7bc..5e0b654 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1818,17 +1818,26 @@ ieee80211_rx_h_ctrl(struct ieee80211_rx_data *rx, struct sk_buff_head *frames)
 		return RX_CONTINUE;
 
 	if (ieee80211_is_back_req(bar->frame_control)) {
+		struct {
+			__le16 control, start_seq_num;
+		} __packed bar_data;
+
 		if (!rx->sta)
 			return RX_DROP_MONITOR;
+
+		if (skb_copy_bits(skb, offsetof(struct ieee80211_bar, control),
+				  &bar_data, sizeof(bar_data)))
+			return RX_DROP_MONITOR;
+
 		spin_lock(&rx->sta->lock);
-		tid = le16_to_cpu(bar->control) >> 12;
+		tid = le16_to_cpu(bar_data.control) >> 12;
 		if (!rx->sta->ampdu_mlme.tid_active_rx[tid]) {
 			spin_unlock(&rx->sta->lock);
 			return RX_DROP_MONITOR;
 		}
 		tid_agg_rx = rx->sta->ampdu_mlme.tid_rx[tid];
 
-		start_seq_num = le16_to_cpu(bar->start_seq_num) >> 4;
+		start_seq_num = le16_to_cpu(bar_data.start_seq_num) >> 4;
 
 		/* reset session timer */
 		if (tid_agg_rx->timeout)
-- 
John W. Linville		Someday the world will need a hero, and you
linville@tuxdriver.com			might be all we have.  Be ready.

^ permalink raw reply related

* Re: linux-next: Tree for June 3 (iwlwifi)
From: reinette chatre @ 2010-06-03 17:45 UTC (permalink / raw)
  To: John W. Linville
  Cc: Randy Dunlap, Stephen Rothwell, linux-wireless@vger.kernel.org,
	linux-next@vger.kernel.org, LKML, Guy, Wey-Yi W
In-Reply-To: <20100603172114.GA14597@tuxdriver.com>

Hi John,

On Thu, 2010-06-03 at 10:21 -0700, John W. Linville wrote:
> On Thu, Jun 03, 2010 at 08:55:01AM -0700, Randy Dunlap wrote:
> > On Thu, 3 Jun 2010 13:47:53 +1000 Stephen Rothwell wrote:
> > 
> > > Hi all,
> > > 
> > > Changes since 20100602:
> > 
> > 
> > when CONFIG_IWLAGN=n:
> > 
> > drivers/net/wireless/iwlwifi/iwl-rx.c:254: error: 'struct iwl_priv' has no member named '_agn'
> > drivers/net/wireless/iwlwifi/iwl-rx.c:303: error: 'struct iwl_priv' has no member named '_agn'
> > drivers/net/wireless/iwlwifi/iwl-rx.c:304: error: 'struct iwl_priv' has no member named '_agn'
> > drivers/net/wireless/iwlwifi/iwl-rx.c:305: error: 'struct iwl_priv' has no member named '_agn'
> > drivers/net/wireless/iwlwifi/iwl-rx.c:306: error: 'struct iwl_priv' has no member named '_agn'
> > 
> > and many more.
> > 
> > Haven't we seen this movie before?
> 
> Ugh...caused be this:
> 
> commit a2064b7a4a22d118087898e4308670da7ac07911
> Author: Wey-Yi Guy <wey-yi.w.guy@intel.com>
> Date:   Fri Apr 30 14:21:48 2010 -0700
> 
>     iwlwifi: move _agn statistics related structure
>     
>     agn and 3945 has different statistics_notif data structure; since 3945
>     has it statistics_notif data structure inside the _3945 portion of
>     iwl_priv, it make sense to move the agn statistics_notif into _agn portion.
>     
>     Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
>     Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
> 
> Since iwl-rx.o is part of iwlcore.ko, this change seems wrong.

Indeed. Sorry about this.

> Reinette, any reason why I shouldn't just revert it?

No - please do revert it. I am getting an unfamiliar error when I tried
to revert it from linux-2.6 as well as wireless-testing, but perhaps it
is something your are familiar with. Please let me know if you need a
patch that will take care of the revert.

Reinette



^ permalink raw reply

* Re: pull request: wireless-2.6 2010-06-03
From: David Miller @ 2010-06-03 19:30 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, netdev, linux-kernel
In-Reply-To: <20100603173843.GB14597@tuxdriver.com>

From: "John W. Linville" <linville@tuxdriver.com>
Date: Thu, 3 Jun 2010 13:38:43 -0400

> This is a handful of fixes intended for 2.6.35.  The ath5k patch fixes a
> problem reported by multiple people as "Commit 6b5d11 breaks association
> with WPA enabled APs".  The ones from Johannes fix a locking problem and
> and a problem caused by reading the wrong data location.
> 
> Please let me know if there are problems!

Pulled, thanks John!

^ permalink raw reply

* [PATCH] [ath5k][leds] Ability to disable leds support. If leds support enabled do not force mac802.11 leds layer selection.
From: Dmytro Milinevskyy @ 2010-06-03 19:39 UTC (permalink / raw)
  Cc: Jiri Slaby, Nick Kossifidis, Luis R. Rodriguez, Bob Copeland,
	John W. Linville, GeunSik Lim, Greg Kroah-Hartman, Lukas Turek,
	Mark Hindley, Johannes Berg, Jiri Kosina, Kalle Valo, Keng-Yu Lin,
	Luca Verdesca, Shahar Or, linux-wireless, netdev, linux-kernel

Hi!

Here is the patch to disable ath5k leds support on build stage.
However if the leds support was enabled do not force selection of 802.11 leds layer.
Depency on LEDS_CLASS is kept.

Suggestion given by Pavel Roskin and Bob Copeland applied.

Regards,

--Dima

---
 drivers/net/wireless/ath/ath5k/Kconfig  |   12 +++++++++---
 drivers/net/wireless/ath/ath5k/Makefile |    2 +-
 drivers/net/wireless/ath/ath5k/ath5k.h  |   22 ++++++++++++++++++++++
 drivers/net/wireless/ath/ath5k/base.h   |   13 +++++++++----
 drivers/net/wireless/ath/ath5k/gpio.c   |    2 ++
 5 files changed, 43 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/ath/ath5k/Kconfig b/drivers/net/wireless/ath/ath5k/Kconfig
index eb83b7b..29f4572 100644
--- a/drivers/net/wireless/ath/ath5k/Kconfig
+++ b/drivers/net/wireless/ath/ath5k/Kconfig
@@ -1,9 +1,6 @@
 config ATH5K
 	tristate "Atheros 5xxx wireless cards support"
 	depends on PCI && MAC80211
-	select MAC80211_LEDS
-	select LEDS_CLASS
-	select NEW_LEDS
 	---help---
 	  This module adds support for wireless adapters based on
 	  Atheros 5xxx chipset.
@@ -18,6 +15,15 @@ config ATH5K
 	  If you choose to build a module, it'll be called ath5k. Say M if
 	  unsure.
 
+
+config ATH5K_LEDS
+	tristate "Atheros 5xxx wireless cards LEDs support"
+	depends on ATH5K
+	select NEW_LEDS
+	select LEDS_CLASS
+	---help---
+	  Atheros 5xxx LED support.
+
 config ATH5K_DEBUG
 	bool "Atheros 5xxx debugging"
 	depends on ATH5K
diff --git a/drivers/net/wireless/ath/ath5k/Makefile b/drivers/net/wireless/ath/ath5k/Makefile
index cc09595..6d552dd 100644
--- a/drivers/net/wireless/ath/ath5k/Makefile
+++ b/drivers/net/wireless/ath/ath5k/Makefile
@@ -10,8 +10,8 @@ ath5k-y				+= phy.o
 ath5k-y				+= reset.o
 ath5k-y				+= attach.o
 ath5k-y				+= base.o
-ath5k-y				+= led.o
 ath5k-y				+= rfkill.o
 ath5k-y				+= ani.o
 ath5k-$(CONFIG_ATH5K_DEBUG)	+= debug.o
+ath5k-$(CONFIG_ATH5K_LEDS) += led.o
 obj-$(CONFIG_ATH5K)		+= ath5k.o
diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h
index 2785946..bb7e09a 100644
--- a/drivers/net/wireless/ath/ath5k/ath5k.h
+++ b/drivers/net/wireless/ath/ath5k/ath5k.h
@@ -1148,11 +1148,27 @@ struct ath5k_hw {
 int ath5k_hw_attach(struct ath5k_softc *sc);
 void ath5k_hw_detach(struct ath5k_hw *ah);
 
+#ifdef CONFIG_ATH5K_LEDS
 /* LED functions */
 int ath5k_init_leds(struct ath5k_softc *sc);
 void ath5k_led_enable(struct ath5k_softc *sc);
 void ath5k_led_off(struct ath5k_softc *sc);
 void ath5k_unregister_leds(struct ath5k_softc *sc);
+#else
+static inline int ath5k_init_leds(struct ath5k_softc *sc)
+{
+	return 0;
+}
+static inline void ath5k_led_enable(struct ath5k_softc *sc)
+{
+}
+static inline void ath5k_led_off(struct ath5k_softc *sc)
+{
+}
+static inline void ath5k_unregister_leds(struct ath5k_softc *sc)
+{
+}
+#endif
 
 /* Reset Functions */
 int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, int flags, bool initial);
@@ -1233,7 +1249,13 @@ int ath5k_hw_set_slot_time(struct ath5k_hw *ah, unsigned int slot_time);
 int ath5k_hw_init_desc_functions(struct ath5k_hw *ah);
 
 /* GPIO Functions */
+#ifdef CONFIG_ATH5K_LEDS
 void ath5k_hw_set_ledstate(struct ath5k_hw *ah, unsigned int state);
+#else
+static inline void ath5k_hw_set_ledstate(struct ath5k_hw *ah, unsigned int state)
+{
+}
+#endif
 int ath5k_hw_set_gpio_input(struct ath5k_hw *ah, u32 gpio);
 int ath5k_hw_set_gpio_output(struct ath5k_hw *ah, u32 gpio);
 u32 ath5k_hw_get_gpio(struct ath5k_hw *ah, u32 gpio);
diff --git a/drivers/net/wireless/ath/ath5k/base.h b/drivers/net/wireless/ath/ath5k/base.h
index 56221bc..97b26c1 100644
--- a/drivers/net/wireless/ath/ath5k/base.h
+++ b/drivers/net/wireless/ath/ath5k/base.h
@@ -86,6 +86,7 @@ struct ath5k_txq {
 
 #define ATH5K_LED_MAX_NAME_LEN 31
 
+#ifdef CONFIG_ATH5K_LEDS
 /*
  * State for LED triggers
  */
@@ -95,6 +96,7 @@ struct ath5k_led
 	struct ath5k_softc *sc;			/* driver state */
 	struct led_classdev led_dev;		/* led classdev */
 };
+#endif
 
 /* Rfkill */
 struct ath5k_rfkill {
@@ -186,9 +188,6 @@ struct ath5k_softc {
 
 	u8			bssidmask[ETH_ALEN];
 
-	unsigned int		led_pin,	/* GPIO pin for driving LED */
-				led_on;		/* pin setting for LED on */
-
 	struct tasklet_struct	restq;		/* reset tasklet */
 
 	unsigned int		rxbufsize;	/* rx size based on mtu */
@@ -196,7 +195,6 @@ struct ath5k_softc {
 	spinlock_t		rxbuflock;
 	u32			*rxlink;	/* link ptr in last RX desc */
 	struct tasklet_struct	rxtq;		/* rx intr tasklet */
-	struct ath5k_led	rx_led;		/* rx led */
 
 	struct list_head	txbuf;		/* transmit buffer */
 	spinlock_t		txbuflock;
@@ -204,7 +202,14 @@ struct ath5k_softc {
 	struct ath5k_txq	txqs[AR5K_NUM_TX_QUEUES];	/* tx queues */
 	struct ath5k_txq	*txq;		/* main tx queue */
 	struct tasklet_struct	txtq;		/* tx intr tasklet */
+
+
+#ifdef CONFIG_ATH5K_LEDS
+	unsigned int		led_pin,	/* GPIO pin for driving LED */
+				led_on;		/* pin setting for LED on */
+	struct ath5k_led	rx_led;		/* rx led */
 	struct ath5k_led	tx_led;		/* tx led */
+#endif
 
 	struct ath5k_rfkill	rf_kill;
 
diff --git a/drivers/net/wireless/ath/ath5k/gpio.c b/drivers/net/wireless/ath/ath5k/gpio.c
index 64a27e7..9e757b3 100644
--- a/drivers/net/wireless/ath/ath5k/gpio.c
+++ b/drivers/net/wireless/ath/ath5k/gpio.c
@@ -25,6 +25,7 @@
 #include "debug.h"
 #include "base.h"
 
+#ifdef CONFIG_ATH5K_LEDS
 /*
  * Set led state
  */
@@ -76,6 +77,7 @@ void ath5k_hw_set_ledstate(struct ath5k_hw *ah, unsigned int state)
 	else
 		AR5K_REG_ENABLE_BITS(ah, AR5K_PCICFG, led_5210);
 }
+#endif
 
 /*
  * Set GPIO inputs
-- 
1.7.1


^ permalink raw reply related

* Re: iwl3945 bug in 2.6.34
From: reinette chatre @ 2010-06-03 21:32 UTC (permalink / raw)
  To: Satish Eerpini; +Cc: linux-kernel, linux-wireless@vger.kernel.org
In-Reply-To: <1274830187.2091.17034.camel@rchatre-DESK>

Hi Satish,

On Tue, 2010-05-25 at 16:29 -0700, reinette chatre wrote:
> On Mon, 2010-05-24 at 15:08 -0700, reinette chatre wrote:
> > On Mon, 2010-05-24 at 11:33 -0700, reinette chatre wrote:
> > > On Sat, 2010-05-22 at 23:25 -0700, Satish Eerpini wrote:
> > > 
> > > > No probe response from AP 00:1b:da:2a:a1:53 after 500ms, disconnecting.
> > > > iwl3945 0000:10:00.0: Error sending REPLY_RXON: time out after 500ms.
> > > > iwl3945 0000:10:00.0: Error setting new configuration (-110).
> > > > iwl3945 0000:10:00.0: Error sending REPLY_RXON: time out after 500ms.
> > > > iwl3945 0000:10:00.0: Error setting new configuration (-110).
> > > 
> > > This did not use to be an issue with 3945 and unfortunately we do not
> > > know what is triggering it now. Please try the "Enable stuck queue
> > > detection on 3945" patch that is attached to
> > > http://bugzilla.intellinuxwireless.org/show_bug.cgi?id=1834 as a
> > > workaround.
> > 
> > Actually, sorry, but that patch will not work on 2.6.34 since the
> > feature it enables is not present there - it will be in 2.6.35 though.
> > To enable the feature in 2.6.34 will take some more backporting effort
> > that I'm looking into now.
> 
> Please try the attached two patches.

Were you able to test these patches?

Thanks

Reinette



^ permalink raw reply

* [PATCH] staging/wlan-ng: Switch from wext to cfg80211
From: Karl Relton @ 2010-06-03 22:04 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, linux-wireless

Switch driver over from wext to cfg80211 interface.

Signed-off-by: Karl Relton <karllinuxtest.relton@ntlworld.com>

---

Some Notes:

- Applies against linux-next (as of 20100602), tested on my system

- This patch moves the driver wholesale from wext to cfg80211. Wext
support is still provided through the cfg80211 provided wext
compatability layer.

- Currently only infrastructure mode is implemented. Ad hoc mode is not
yet implemented, but can be added.

- It does not support connecting to a specified bssid, instead roaming
is handled by the card itself. This matches the behaviour of the
existing driver.

- It has been tested using NetworkManager (via wpa_supplicant)
configured to use the wext compatability layer, and then again with the
native nl80211 layer.

--- old/drivers/staging/wlan-ng/Makefile	2010-05-30 21:21:02.000000000 +0100
+++ new/drivers/staging/wlan-ng/Makefile	2010-06-03 18:34:27.000000000 +0100
@@ -4,5 +4,4 @@ prism2_usb-objs := prism2usb.o \
 		p80211conv.o \
 		p80211req.o \
 		p80211wep.o \
-		p80211wext.o \
 		p80211netdev.o
--- old/drivers/staging/wlan-ng/hfa384x.h	2010-05-30 21:21:02.000000000 +0100
+++ new/drivers/staging/wlan-ng/hfa384x.h	2010-06-03 18:34:27.000000000 +0100
@@ -1284,6 +1284,8 @@ typedef struct hfa384x {
 	u16 link_status_new;
 	struct sk_buff_head authq;
 
+	u32 txrate;
+
 	/* And here we have stuff that used to be in priv */
 
 	/* State variables */
--- old/drivers/staging/wlan-ng/p80211metastruct.h	2010-05-30 21:21:02.000000000 +0100
+++ new/drivers/staging/wlan-ng/p80211metastruct.h	2010-06-03 18:34:27.000000000 +0100
@@ -113,6 +113,7 @@ typedef struct p80211msg_dot11req_scan_r
 	p80211item_uint32_t cfpollable;
 	p80211item_uint32_t cfpollreq;
 	p80211item_uint32_t privacy;
+	p80211item_uint32_t capinfo;
 	p80211item_uint32_t basicrate1;
 	p80211item_uint32_t basicrate2;
 	p80211item_uint32_t basicrate3;
@@ -209,6 +210,7 @@ typedef struct p80211msg_lnxreq_commsqua
 	p80211item_uint32_t link;
 	p80211item_uint32_t level;
 	p80211item_uint32_t noise;
+	p80211item_uint32_t txrate;
 } __attribute__ ((packed)) p80211msg_lnxreq_commsquality_t;
 
 typedef struct p80211msg_lnxreq_autojoin {
--- old/drivers/staging/wlan-ng/p80211netdev.c	2010-05-30 21:21:02.000000000 +0100
+++ new/drivers/staging/wlan-ng/p80211netdev.c	2010-06-03 18:34:27.000000000 +0100
@@ -75,6 +75,7 @@
 
 #include <net/iw_handler.h>
 #include <net/net_namespace.h>
+#include <net/cfg80211.h>
 
 #include "p80211types.h"
 #include "p80211hdr.h"
@@ -87,6 +88,8 @@
 #include "p80211metastruct.h"
 #include "p80211metadef.h"
 
+#include "cfg80211.c"
+
 /* Support functions */
 static void p80211netdev_rx_bh(unsigned long arg);
 
@@ -732,6 +735,7 @@ static const struct net_device_ops p8021
 * Arguments:
 *	wlandev		ptr to the wlandev structure for the
 *			interface.
+*	physdev		ptr to usb device
 * Returns:
 *	zero on success, non-zero otherwise.
 * Call Context:
@@ -740,10 +744,12 @@ static const struct net_device_ops p8021
 *	compiled drivers, this function will be called in the
 *	context of the kernel startup code.
 ----------------------------------------------------------------*/
-int wlan_setup(wlandevice_t *wlandev)
+int wlan_setup(wlandevice_t *wlandev, struct device *physdev)
 {
 	int result = 0;
-	netdevice_t *dev;
+	netdevice_t *netdev;
+	struct wiphy *wiphy;
+	struct wireless_dev *wdev;
 
 	/* Set up the wlandev */
 	wlandev->state = WLAN_DEVICE_CLOSED;
@@ -755,20 +761,30 @@ int wlan_setup(wlandevice_t *wlandev)
 	tasklet_init(&wlandev->rx_bh,
 		     p80211netdev_rx_bh, (unsigned long)wlandev);
 
+	/* Allocate and initialize the wiphy struct */
+	wiphy = wlan_create_wiphy(physdev, wlandev);
+	if (wiphy == NULL) {
+		printk(KERN_ERR "Failed to alloc wiphy.\n");
+		return 1;
+	}
+
 	/* Allocate and initialize the struct device */
-	dev = alloc_netdev(0, "wlan%d", ether_setup);
-	if (dev == NULL) {
+	netdev = alloc_netdev(sizeof(struct wireless_dev), "wlan%d", ether_setup);
+	if (netdev == NULL) {
 		printk(KERN_ERR "Failed to alloc netdev.\n");
+		wlan_free_wiphy(wiphy);
 		result = 1;
 	} else {
-		wlandev->netdev = dev;
-		dev->ml_priv = wlandev;
-		dev->netdev_ops = &p80211_netdev_ops;
-
-		dev->wireless_handlers = &p80211wext_handler_def;
+		wlandev->netdev = netdev;
+		netdev->ml_priv = wlandev;
+		netdev->netdev_ops = &p80211_netdev_ops;
+		wdev = netdev_priv(netdev);
+		wdev->wiphy = wiphy;
+		wdev->iftype = NL80211_IFTYPE_STATION;
+		netdev->ieee80211_ptr = wdev;
 
-		netif_stop_queue(dev);
-		netif_carrier_off(dev);
+		netif_stop_queue(netdev);
+		netif_carrier_off(netdev);
 	}
 
 	return result;
@@ -797,14 +813,13 @@ int wlan_setup(wlandevice_t *wlandev)
 ----------------------------------------------------------------*/
 int wlan_unsetup(wlandevice_t *wlandev)
 {
-	int result = 0;
+	struct wireless_dev *wdev;
 
 	tasklet_kill(&wlandev->rx_bh);
 
-	if (wlandev->netdev == NULL) {
-		printk(KERN_ERR "called without wlandev->netdev set.\n");
-		result = 1;
-	} else {
+	if (wlandev->netdev) {
+		wdev = netdev_priv(wlandev->netdev);
+		if(wdev->wiphy) wlan_free_wiphy(wdev->wiphy);
 		free_netdev(wlandev->netdev);
 		wlandev->netdev = NULL;
 	}
--- old/drivers/staging/wlan-ng/p80211netdev.h	2010-05-30 21:21:02.000000000 +0100
+++ new/drivers/staging/wlan-ng/p80211netdev.h	2010-06-03 18:34:27.000000000 +0100
@@ -148,6 +148,7 @@ int p80211wext_event_associated(struct w
 #define MAX_KEYLEN 32
 
 #define HOSTWEP_DEFAULTKEY_MASK (BIT(1)|BIT(0))
+#define HOSTWEP_SHAREDKEY BIT(3)
 #define HOSTWEP_DECRYPT  BIT(4)
 #define HOSTWEP_ENCRYPT  BIT(5)
 #define HOSTWEP_PRIVACYINVOKED BIT(6)
@@ -233,7 +234,7 @@ int wep_decrypt(wlandevice_t *wlandev, u
 int wep_encrypt(wlandevice_t *wlandev, u8 *buf, u8 *dst, u32 len, int keynum,
 		u8 *iv, u8 *icv);
 
-int wlan_setup(wlandevice_t *wlandev);
+int wlan_setup(wlandevice_t *wlandev, struct device *physdev);
 int wlan_unsetup(wlandevice_t *wlandev);
 int register_wlandev(wlandevice_t *wlandev);
 int unregister_wlandev(wlandevice_t *wlandev);
--- old/drivers/staging/wlan-ng/prism2mgmt.c	2010-05-30 21:21:02.000000000 +0100
+++ new/drivers/staging/wlan-ng/prism2mgmt.c	2010-06-03 18:34:27.000000000 +0100
@@ -463,6 +463,8 @@ int prism2mgmt_scan_results(wlandevice_t
 
 	/* capinfo bits */
 	count = le16_to_cpu(item->capinfo);
+	req->capinfo.status = P80211ENUM_msgitem_status_data_ok;
+	req->capinfo.data = count;
 
 	/* privacy flag */
 	req->privacy.status = P80211ENUM_msgitem_status_data_ok;
--- old/drivers/staging/wlan-ng/prism2sta.c	2010-05-30 21:21:02.000000000 +0100
+++ new/drivers/staging/wlan-ng/prism2sta.c	2010-06-03 18:34:27.000000000 +0100
@@ -124,6 +124,10 @@ MODULE_PARM_DESC(prism2_reset_settletime
 
 MODULE_LICENSE("Dual MPL/GPL");
 
+void prism2_connect_result(wlandevice_t *wlandev, u8 failed);
+void prism2_disconnected(wlandevice_t *wlandev);
+void prism2_roamed(wlandevice_t *wlandev);
+
 static int prism2sta_open(wlandevice_t *wlandev);
 static int prism2sta_close(wlandevice_t *wlandev);
 static void prism2sta_reset(wlandevice_t *wlandev);
@@ -401,6 +405,7 @@ static int prism2sta_mlmerequest(wlandev
 			qualmsg->link.data = le16_to_cpu(hw->qual.CQ_currBSS);
 			qualmsg->level.data = le16_to_cpu(hw->qual.ASL_currBSS);
 			qualmsg->noise.data = le16_to_cpu(hw->qual.ANL_currFC);
+			qualmsg->txrate.data = hw->txrate;
 
 			break;
 		}
@@ -1300,6 +1305,9 @@ void prism2sta_processing_defer(struct w
 			    (portstatus == HFA384x_PSTATUS_CONN_IBSS) ?
 			    WLAN_MACMODE_IBSS_STA : WLAN_MACMODE_ESS_STA;
 
+			/* signal back up to cfg80211 layer */
+			prism2_connect_result(wlandev, P80211ENUM_truth_false);
+
 			/* Get the ball rolling on the comms quality stuff */
 			prism2sta_commsqual_defer(&hw->commsqual_bh);
 		}
@@ -1315,25 +1323,16 @@ void prism2sta_processing_defer(struct w
 		 * Indicate Deauthentication
 		 * Block Transmits, Ignore receives of data frames
 		 */
-		if (hw->join_ap == 2) {
-			hfa384x_JoinRequest_data_t joinreq;
-			joinreq = hw->joinreq;
-			/* Send the join request */
-			hfa384x_drvr_setconfig(hw,
-					       HFA384x_RID_JOINREQUEST,
-					       &joinreq,
-					       HFA384x_RID_JOINREQUEST_LEN);
+		if (wlandev->netdev->type == ARPHRD_ETHER)
 			printk(KERN_INFO
-			    "linkstatus=DISCONNECTED (re-submitting join)\n");
-		} else {
-			if (wlandev->netdev->type == ARPHRD_ETHER)
-				printk(KERN_INFO
-				       "linkstatus=DISCONNECTED (unhandled)\n");
-		}
+			       "linkstatus=DISCONNECTED (unhandled)\n");
 		wlandev->macmode = WLAN_MACMODE_NONE;
 
 		netif_carrier_off(wlandev->netdev);
 
+		/* signal back up to cfg80211 layer */
+		prism2_disconnected(wlandev);
+
 		break;
 
 	case HFA384x_LINK_AP_CHANGE:
@@ -1376,6 +1375,9 @@ void prism2sta_processing_defer(struct w
 		hw->link_status = HFA384x_LINK_CONNECTED;
 		netif_carrier_on(wlandev->netdev);
 
+		/* signal back up to cfg80211 layer */
+		prism2_roamed(wlandev);
+
 		break;
 
 	case HFA384x_LINK_AP_OUTOFRANGE:
@@ -1435,6 +1437,9 @@ void prism2sta_processing_defer(struct w
 
 		netif_carrier_off(wlandev->netdev);
 
+		/* signal back up to cfg80211 layer */
+		prism2_connect_result(wlandev, P80211ENUM_truth_true);
+
 		break;
 
 	default:
@@ -1446,7 +1451,6 @@ void prism2sta_processing_defer(struct w
 	}
 
 	wlandev->linkstatus = (hw->link_status == HFA384x_LINK_CONNECTED);
-	p80211wext_event_associated(wlandev, wlandev->linkstatus);
 
 failed:
 	return;
@@ -1985,6 +1989,8 @@ void prism2sta_commsqual_defer(struct wo
 	hfa384x_t *hw = container_of(data, struct hfa384x, commsqual_bh);
 	wlandevice_t *wlandev = hw->wlandev;
 	hfa384x_bytestr32_t ssid;
+	p80211msg_dot11req_mibget_t msg;
+	p80211item_uint32_t *mibitem = (p80211item_uint32_t *) &msg.mibattribute.data;
 	int result = 0;
 
 	if (hw->wlandev->hwremoved)
@@ -2013,6 +2019,34 @@ void prism2sta_commsqual_defer(struct wo
 			 le16_to_cpu(hw->qual.ANL_currFC));
 	}
 
+	/* Get the signal rate */
+	msg.msgcode = DIDmsg_dot11req_mibget;
+	mibitem->did = DIDmib_p2_p2MAC_p2CurrentTxRate;
+	result = p80211req_dorequest(wlandev, (u8 *) & msg);
+
+	if (result) {
+		pr_debug("get signal rate failed, result = %d\n",
+			 result);
+		goto done;
+	}
+
+	switch (mibitem->data) {
+	case HFA384x_RATEBIT_1:
+		hw->txrate = 10;
+		break;
+	case HFA384x_RATEBIT_2:
+		hw->txrate = 20;
+		break;
+	case HFA384x_RATEBIT_5dot5:
+		hw->txrate = 55;
+		break;
+	case HFA384x_RATEBIT_11:
+		hw->txrate = 110;
+		break;
+	default:
+		pr_debug("Bad ratebit (%d)\n", mibitem->data);
+	}
+
 	/* Lastly, we need to make sure the BSSID didn't change on us */
 	result = hfa384x_drvr_getconfig(hw,
 					HFA384x_RID_CURRENTBSSID,
--- old/drivers/staging/wlan-ng/prism2usb.c	2010-05-30 21:21:02.000000000 +0100
+++ new/drivers/staging/wlan-ng/prism2usb.c	2010-06-03 18:34:28.000000000 +0100
@@ -119,7 +119,7 @@ static int prism2sta_probe_usb(struct us
 	}
 	hw = wlandev->priv;
 
-	if (wlan_setup(wlandev) != 0) {
+	if (wlan_setup(wlandev, &(interface->dev)) != 0) {
 		printk(KERN_ERR "%s: wlan_setup() failed.\n", dev_info);
 		result = -EIO;
 		goto failed;
--- old/drivers/staging/wlan-ng/cfg80211.c	1970-01-01 01:00:00.000000000 +0100
+++ new/drivers/staging/wlan-ng/cfg80211.c	2010-06-03 22:48:06.000000000 +0100
@@ -0,0 +1,735 @@
+/* cfg80211 Interface for prism2_usb module */
+
+
+/* Prism2 channell/frequency/bitrate declarations */
+static const struct ieee80211_channel prism2_channels[] = {
+	{ .center_freq = 2412 },
+	{ .center_freq = 2417 },
+	{ .center_freq = 2422 },
+	{ .center_freq = 2427 },
+	{ .center_freq = 2432 },
+	{ .center_freq = 2437 },
+	{ .center_freq = 2442 },
+	{ .center_freq = 2447 },
+	{ .center_freq = 2452 },
+	{ .center_freq = 2457 },
+	{ .center_freq = 2462 },
+	{ .center_freq = 2467 },
+	{ .center_freq = 2472 },
+	{ .center_freq = 2484 },
+};
+
+static const struct ieee80211_rate prism2_rates[] = {
+	{ .bitrate = 10 },
+	{ .bitrate = 20 },
+	{ .bitrate = 55 },
+	{ .bitrate = 110 }
+};
+
+#define PRISM2_NUM_CIPHER_SUITES 2
+static const u32 prism2_cipher_suites[PRISM2_NUM_CIPHER_SUITES] = {
+	WLAN_CIPHER_SUITE_WEP40,
+	WLAN_CIPHER_SUITE_WEP104
+};
+
+
+/* prism2 device private data */
+struct prism2_wiphy_private {
+	wlandevice_t *wlandev;
+
+	struct ieee80211_supported_band band;
+	struct ieee80211_channel channels[ARRAY_SIZE(prism2_channels)];
+	struct ieee80211_rate rates[ARRAY_SIZE(prism2_rates)];
+
+	struct cfg80211_scan_request *scan_request;
+};
+
+static const void * const prism2_wiphy_privid = &prism2_wiphy_privid;
+
+
+/* Helper Functions */
+static int prism2_result2err(int prism2_result)
+{
+	int err = 0;
+
+	switch (prism2_result) {
+	case P80211ENUM_resultcode_invalid_parameters:
+		err = -EINVAL;
+		break;
+	case P80211ENUM_resultcode_implementation_failure:
+		err = -EIO;
+		break;
+	case P80211ENUM_resultcode_not_supported:
+		err = -EOPNOTSUPP;
+		break;
+	default:
+		err = 0;
+		break;
+	}
+
+	return err;
+}
+
+static int prism2_domibset_uint32(wlandevice_t *wlandev, u32 did, u32 data)
+{
+	p80211msg_dot11req_mibset_t msg;
+	p80211item_uint32_t *mibitem = (p80211item_uint32_t *) &msg.mibattribute.data;
+
+	msg.msgcode = DIDmsg_dot11req_mibset;
+	mibitem->did = did;
+	mibitem->data = data;
+
+	return p80211req_dorequest(wlandev, (u8 *) & msg);
+}
+
+static int prism2_domibset_pstr32(wlandevice_t *wlandev,
+				  u32 did, u8 len, u8 *data)
+{
+	p80211msg_dot11req_mibset_t msg;
+	p80211item_pstr32_t *mibitem = (p80211item_pstr32_t *) &msg.mibattribute.data;
+
+	msg.msgcode = DIDmsg_dot11req_mibset;
+	mibitem->did = did;
+	mibitem->data.len = len;
+	memcpy(mibitem->data.data, data, len);
+
+	return p80211req_dorequest(wlandev, (u8 *) & msg);
+}
+
+
+/* The interface functions, called by the cfg80211 layer */
+int prism2_change_virtual_intf(struct wiphy *wiphy,
+			       struct net_device *dev,
+			       enum nl80211_iftype type, u32 *flags,
+			       struct vif_params *params)
+{
+	wlandevice_t *wlandev = dev->ml_priv;
+	u32 data;
+	int result;
+	int err = 0;
+
+	switch (type) {
+	case NL80211_IFTYPE_ADHOC:
+		if (wlandev->macmode == WLAN_MACMODE_IBSS_STA) goto exit;
+		wlandev->macmode = WLAN_MACMODE_IBSS_STA;
+		data = 0;
+		break;
+	case NL80211_IFTYPE_STATION:
+		if (wlandev->macmode == WLAN_MACMODE_ESS_STA) goto exit;
+		wlandev->macmode = WLAN_MACMODE_ESS_STA;
+		data = 1;
+		break;
+	default:
+		printk(KERN_WARNING "Operation mode: %d not support\n", type);
+		return -EOPNOTSUPP;
+	}
+
+	/* Set Operation mode to the PORT TYPE RID */
+	result = prism2_domibset_uint32(wlandev, DIDmib_p2_p2Static_p2CnfPortType, data);
+
+	if (result)
+		err = -EFAULT;
+    
+	dev->ieee80211_ptr->iftype = type;
+
+exit:
+	return err;
+}
+
+int prism2_add_key(struct wiphy *wiphy, struct net_device *dev,
+		   u8 key_index, const u8 *mac_addr,
+		   struct key_params *params) {
+	wlandevice_t *wlandev = dev->ml_priv;
+	u32 did;
+
+	int err = 0;
+	int result = 0;
+
+	switch (params->cipher) {
+	case WLAN_CIPHER_SUITE_WEP40:
+	case WLAN_CIPHER_SUITE_WEP104:
+		result = prism2_domibset_uint32(wlandev,
+			DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID,
+			key_index);
+		if (result) goto exit;
+
+		/* send key to driver */
+		switch (key_index) {
+		case 0:
+			did =
+			    DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0;
+			break;
+
+		case 1:
+			did =
+			    DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1;
+			break;
+
+		case 2:
+			did =
+			    DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2;
+			break;
+
+		case 3:
+			did =
+			    DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3;
+			break;
+
+		default:
+			err = -EINVAL;
+			goto exit;
+		}
+
+		result = prism2_domibset_pstr32(wlandev, did, params->key_len, params->key);
+		if (result) goto exit;
+		break;
+
+	default:
+		pr_debug("Unsupported cipher suite\n");
+		result = 1;
+	}
+
+exit:
+	if (result) err = -EFAULT;
+
+	return err;
+}
+
+int prism2_get_key(struct wiphy *wiphy, struct net_device *dev,
+		   u8 key_index, const u8 *mac_addr, void *cookie,
+		   void (*callback)(void *cookie, struct key_params*)) {
+	wlandevice_t *wlandev = dev->ml_priv;
+	struct key_params params;
+	int len;
+
+	if(key_index >= NUM_WEPKEYS) return -EINVAL;
+
+	len = wlandev->wep_keylens[key_index];
+	memset(&params, 0, sizeof(params));
+
+	if (len == 13) {
+		params.cipher = WLAN_CIPHER_SUITE_WEP104;
+	} else if (len == 5) {
+		params.cipher = WLAN_CIPHER_SUITE_WEP104;
+	} else return -ENOENT;
+	params.key_len = len;
+	params.key = wlandev->wep_keys[key_index];
+
+	callback(cookie, &params);
+	return 0;
+}
+
+int prism2_del_key(struct wiphy *wiphy, struct net_device *dev,
+		   u8 key_index, const u8 *mac_addr) {
+	wlandevice_t *wlandev = dev->ml_priv;
+	u32 did;
+	int err = 0;
+	int result = 0;
+
+	/* There is no direct way in the hardware (AFAIK) of removing
+	   a key, so we will cheat by setting the key to a bogus value */
+	/* send key to driver */
+	switch (key_index) {
+	case 0:
+		did =
+		    DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0;
+		break;
+
+	case 1:
+		did =
+		    DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1;
+		break;
+
+	case 2:
+		did =
+		    DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2;
+		break;
+
+	case 3:
+		did =
+		    DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3;
+		break;
+
+	default:
+		err = -EINVAL;
+		goto exit;
+	}
+
+	result = prism2_domibset_pstr32(wlandev, did, 13, "0000000000000");
+
+exit:
+	if (result) err = -EFAULT;
+
+	return err;
+}
+
+int prism2_set_default_key(struct wiphy *wiphy, struct net_device *dev,
+			   u8 key_index) {
+	wlandevice_t *wlandev = dev->ml_priv;
+
+	int err = 0;
+	int result = 0;
+
+	result = prism2_domibset_uint32(wlandev,
+		DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID,
+		key_index);
+
+	if (result) err = -EFAULT;
+
+	return err;
+}
+
+
+int prism2_get_station(struct wiphy *wiphy, struct net_device *dev,
+		       u8 *mac, struct station_info *sinfo) {
+	wlandevice_t *wlandev = dev->ml_priv;
+	p80211msg_lnxreq_commsquality_t quality;
+	int result;
+
+	memset(sinfo, 0, sizeof(*sinfo));
+
+	if ((wlandev == NULL) || (wlandev->msdstate != WLAN_MSD_RUNNING))
+		return -EOPNOTSUPP;
+
+	/* build request message */
+	quality.msgcode = DIDmsg_lnxreq_commsquality;
+	quality.dbm.data = P80211ENUM_truth_true;
+	quality.dbm.status = P80211ENUM_msgitem_status_data_ok;
+
+	/* send message to nsd */
+	if (wlandev->mlmerequest == NULL)
+		return -EOPNOTSUPP;
+
+	result = wlandev->mlmerequest(wlandev, (p80211msg_t *) & quality);
+
+
+	if (result == 0) {
+		sinfo->txrate.legacy = quality.txrate.data;
+		sinfo->filled |= STATION_INFO_TX_BITRATE;
+		sinfo->signal = quality.level.data;
+		sinfo->filled |= STATION_INFO_SIGNAL;
+	}
+
+	return result;
+}
+
+int prism2_scan(struct wiphy *wiphy, struct net_device *dev,
+	       struct cfg80211_scan_request *request)
+{
+	struct prism2_wiphy_private *priv = wiphy_priv(wiphy);
+	wlandevice_t *wlandev = dev->ml_priv;
+	p80211msg_dot11req_scan_t msg1;
+	p80211msg_dot11req_scan_results_t msg2;
+	int result;
+	int err = 0;
+	int numbss = 0;
+	int i = 0;
+	u8 ie_buf[46];
+	int ie_len;
+
+	if (!request)
+		return -EINVAL;
+
+	if (priv->scan_request && priv->scan_request != request)
+		return -EBUSY;
+
+	if (wlandev->macmode == WLAN_MACMODE_ESS_AP) {
+		printk(KERN_ERR "Can't scan in AP mode\n");
+		return -EOPNOTSUPP;
+	}
+
+	priv->scan_request = request;
+
+	memset(&msg1, 0x00, sizeof(p80211msg_dot11req_scan_t));
+	msg1.msgcode = DIDmsg_dot11req_scan;
+	msg1.bsstype.data = P80211ENUM_bsstype_any;
+
+	memset(&(msg1.bssid.data), 0xFF, sizeof(p80211item_pstr6_t));
+	msg1.bssid.data.len = 6;
+
+	if (request->n_ssids > 0) {
+		msg1.scantype.data = P80211ENUM_scantype_active;
+		msg1.ssid.data.len = request->ssids->ssid_len;
+		memcpy(msg1.ssid.data.data, request->ssids->ssid, request->ssids->ssid_len);
+	} else {
+		msg1.scantype.data = 0;
+	}
+	msg1.probedelay.data = 0;
+
+	for (i = 0;
+		(i < request->n_channels) && i < ARRAY_SIZE(prism2_channels);
+		i++)
+		msg1.channellist.data.data[i] =
+			ieee80211_frequency_to_channel(request->channels[i]->center_freq);
+	msg1.channellist.data.len = request->n_channels;
+
+	msg1.maxchanneltime.data = 250;
+	msg1.minchanneltime.data = 200;
+
+	result = p80211req_dorequest(wlandev, (u8 *) &msg1);
+	if (result) {
+		err = prism2_result2err(msg1.resultcode.data);
+		goto exit;
+	}
+	/* Now retrieve scan results */
+	numbss = msg1.numbss.data;
+
+	for (i = 0; i < numbss; i++) {
+		memset(&msg2, 0, sizeof(msg2));
+		msg2.msgcode = DIDmsg_dot11req_scan_results;
+		msg2.bssindex.data = i;
+
+		result = p80211req_dorequest(wlandev, (u8 *) &msg2);
+		if ((result != 0) ||
+		    (msg2.resultcode.data != P80211ENUM_resultcode_success)) {
+			break;
+		}
+
+		ie_buf[0] = WLAN_EID_SSID;
+		ie_buf[1] = msg2.ssid.data.len;
+		ie_len = ie_buf[1] + 2;
+		memcpy(&ie_buf[2], &(msg2.ssid.data.data), msg2.ssid.data.len);
+		cfg80211_inform_bss(wiphy,
+			ieee80211_get_channel(wiphy, ieee80211_dsss_chan_to_freq(msg2.dschannel.data)),
+			(const u8 *) &(msg2.bssid.data.data),
+			msg2.timestamp.data, msg2.capinfo.data,
+			msg2.beaconperiod.data,
+			ie_buf,
+			ie_len,
+			(msg2.signal.data - 65536) * 100, /* Conversion to signed type */
+			GFP_KERNEL
+		);
+	}
+
+	if (result) {
+		err = prism2_result2err(msg2.resultcode.data);
+	}
+
+exit:
+	cfg80211_scan_done(request, err ? 1 : 0);
+	priv->scan_request = NULL;
+	return err;
+}
+
+int prism2_set_wiphy_params(struct wiphy *wiphy, u32 changed) {
+	struct prism2_wiphy_private *priv = wiphy_priv(wiphy);
+	wlandevice_t *wlandev = priv->wlandev;
+	u32 data;
+	int result;
+	int err = 0;
+
+	if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
+		if (wiphy->rts_threshold == -1)
+			data = 2347;
+		else
+			data = wiphy->rts_threshold;
+
+		result =
+			prism2_domibset_uint32(wlandev,
+				DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold,
+				data);
+		if (result) {
+			err = -EFAULT;
+			goto exit;
+		}
+	}
+
+	if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
+			
+		if (wiphy->frag_threshold == -1)
+			data = 2346;
+		else
+			data = wiphy->frag_threshold;
+
+		result =
+			prism2_domibset_uint32(wlandev,
+				DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold,
+				data);
+		if (result) {
+			err = -EFAULT;
+			goto exit;
+		}
+	}
+
+exit:
+	return err;
+}
+
+int prism2_connect(struct wiphy *wiphy, struct net_device *dev,
+		   struct cfg80211_connect_params *sme) {
+	wlandevice_t *wlandev = dev->ml_priv;
+	struct ieee80211_channel *channel = sme->channel;
+	p80211msg_lnxreq_autojoin_t msg_join;
+	u32 did;
+	int length = sme->ssid_len;
+	int chan = -1;
+	int is_wep = (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) ||
+	    (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104);
+	int result;
+	int err = 0;
+
+	/* Set the channel */
+	if (channel) {
+		chan = ieee80211_frequency_to_channel(channel->center_freq);
+		
+		result =
+			prism2_domibset_uint32(wlandev,
+				DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel,
+				chan);
+
+		if (result) goto exit;
+	}
+
+	/* Set the authorisation */
+	if ((sme->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM) ||
+		((sme->auth_type == NL80211_AUTHTYPE_AUTOMATIC) && !is_wep))
+			msg_join.authtype.data = P80211ENUM_authalg_opensystem;
+	else if ((sme->auth_type == NL80211_AUTHTYPE_SHARED_KEY) ||
+		((sme->auth_type == NL80211_AUTHTYPE_AUTOMATIC) && is_wep))
+			msg_join.authtype.data = P80211ENUM_authalg_sharedkey;
+	else printk(KERN_WARNING "Unhandled authorisation type for connect (%d)\n", sme->auth_type);
+
+	/* Set the encryption - we only support wep */
+	if (is_wep) {
+
+		if (sme->key) {
+			result = prism2_domibset_uint32(wlandev,
+				DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID,
+				sme->key_idx);
+			if (result) goto exit;
+
+			/* send key to driver */
+			switch (sme->key_idx) {
+			case 0:
+				did =
+				    DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0;
+				break;
+
+			case 1:
+				did =
+				    DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1;
+				break;
+
+			case 2:
+				did =
+				    DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2;
+				break;
+
+			case 3:
+				did =
+				    DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3;
+				break;
+
+			default:
+				err = -EINVAL;
+				goto exit;
+			}
+
+			result = prism2_domibset_pstr32(wlandev, did, sme->key_len, (u8 *) sme->key);
+			if (result) goto exit;
+
+		}
+
+		/* Assume we should set privacy invoked and exclude unencrypted
+		   We could possibly use sme->privacy here, but the assumption
+		   seems reasonable anyway */
+		result = prism2_domibset_uint32(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked,
+			 P80211ENUM_truth_true);
+		if (result) goto exit;
+		result = prism2_domibset_uint32(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted,
+			 P80211ENUM_truth_true);
+		if (result) goto exit;
+
+	} else {
+		/* Assume we should unset privacy invoked and exclude unencrypted */
+		result = prism2_domibset_uint32(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked,
+			 P80211ENUM_truth_false);
+		if (result) goto exit;
+		result = prism2_domibset_uint32(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted,
+			 P80211ENUM_truth_false);
+		if (result) goto exit;
+
+	}
+
+	/* Now do the actual join. Note there is no way that I can
+	   see to request a specific bssid */
+	msg_join.msgcode = DIDmsg_lnxreq_autojoin;
+
+	memcpy(msg_join.ssid.data.data, sme->ssid, length);
+	msg_join.ssid.data.len = length;
+
+	result = p80211req_dorequest(wlandev, (u8 *) & msg_join);
+
+exit:
+	if (result) err = -EFAULT;
+
+	return err;
+}
+
+int prism2_disconnect(struct wiphy *wiphy, struct net_device *dev,
+		      u16 reason_code) {
+	wlandevice_t *wlandev = dev->ml_priv;
+	p80211msg_lnxreq_autojoin_t msg_join;
+	int result;
+	int err = 0;
+
+
+	/* Do a join, with a bogus ssid. Thats the only way I can think of */
+	msg_join.msgcode = DIDmsg_lnxreq_autojoin;
+
+	memcpy(msg_join.ssid.data.data, "---", 3);
+	msg_join.ssid.data.len = 3;
+
+	result = p80211req_dorequest(wlandev, (u8 *) & msg_join);
+
+	if (result) err = -EFAULT;
+
+	return err;
+}
+
+
+int prism2_join_ibss(struct wiphy *wiphy, struct net_device *dev,
+		     struct cfg80211_ibss_params *params) {
+	return -EOPNOTSUPP;
+}
+
+int prism2_leave_ibss(struct wiphy *wiphy, struct net_device *dev) {
+	return -EOPNOTSUPP;
+}
+
+
+int prism2_set_tx_power(struct wiphy *wiphy,
+			enum tx_power_setting type, int dbm) {
+	struct prism2_wiphy_private *priv = wiphy_priv(wiphy);
+	wlandevice_t *wlandev = priv->wlandev;
+	u32 data;
+	int result;
+	int err = 0;
+
+	if (type == TX_POWER_AUTOMATIC)
+		data = 30;
+	else
+		data = dbm;
+
+	result = prism2_domibset_uint32(wlandev,
+		DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel,
+		data);
+
+	if (result) {
+		err = -EFAULT;
+		goto exit;
+	}
+
+exit:
+	return err;
+}
+
+int prism2_get_tx_power(struct wiphy *wiphy, int *dbm) {
+	struct prism2_wiphy_private *priv = wiphy_priv(wiphy);
+	wlandevice_t *wlandev = priv->wlandev;
+	p80211msg_dot11req_mibget_t msg;
+	p80211item_uint32_t *mibitem = (p80211item_uint32_t *) &msg.mibattribute.data;
+	int result;
+	int err = 0;
+
+	msg.msgcode = DIDmsg_dot11req_mibget;
+	mibitem->did =
+	    DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel;
+
+	result = p80211req_dorequest(wlandev, (u8 *) & msg);
+
+	if (result) {
+		err = -EFAULT;
+		goto exit;
+	}
+
+	*dbm = mibitem->data;
+
+exit:
+	return err;
+}
+
+
+
+
+/* Interface callback functions, passing data back up to the cfg80211 layer */
+void	prism2_connect_result(wlandevice_t *wlandev, u8 failed) {
+
+	cfg80211_connect_result(wlandev->netdev, wlandev->bssid,
+		NULL, 0, NULL, 0,
+		failed ? WLAN_STATUS_UNSPECIFIED_FAILURE : WLAN_STATUS_SUCCESS, GFP_KERNEL);
+}
+
+void	prism2_disconnected(wlandevice_t *wlandev) {
+
+	cfg80211_disconnected(wlandev->netdev, 0, NULL,
+		0, GFP_KERNEL);
+}
+
+void	prism2_roamed(wlandevice_t *wlandev) {
+
+	cfg80211_roamed(wlandev->netdev, wlandev->bssid,
+		NULL, 0, NULL, 0, GFP_KERNEL);
+}
+
+
+/* Structures for declaring wiphy interface */
+static const struct cfg80211_ops prism2_usb_cfg_ops = {
+	.change_virtual_intf = prism2_change_virtual_intf,
+	.add_key = prism2_add_key,
+	.get_key = prism2_get_key,
+	.del_key = prism2_del_key,
+	.set_default_key = prism2_set_default_key,
+	.get_station = prism2_get_station,
+	.scan = prism2_scan,
+	.set_wiphy_params = prism2_set_wiphy_params,
+	.connect = prism2_connect,
+	.disconnect = prism2_disconnect,
+	.join_ibss = prism2_join_ibss,
+	.leave_ibss = prism2_leave_ibss,
+	.set_tx_power = prism2_set_tx_power,
+	.get_tx_power = prism2_get_tx_power,
+};
+
+
+/* Functions to create/free wiphy interface */
+struct wiphy *wlan_create_wiphy(struct device *dev, wlandevice_t *wlandev)
+{
+	struct wiphy *wiphy;
+	struct prism2_wiphy_private *priv;
+	wiphy = wiphy_new(&prism2_usb_cfg_ops, sizeof(struct prism2_wiphy_private));
+	if (!wiphy)
+		return NULL;
+
+	priv = wiphy_priv(wiphy);
+	priv->wlandev = wlandev;
+	memcpy(priv->channels, prism2_channels, sizeof(prism2_channels));
+	memcpy(priv->rates, prism2_rates, sizeof(prism2_rates));
+	priv->band.channels = priv->channels;
+	priv->band.n_channels = ARRAY_SIZE(prism2_channels);
+	priv->band.bitrates = priv->rates;
+	priv->band.n_bitrates = ARRAY_SIZE(prism2_rates);
+	wiphy->bands[IEEE80211_BAND_2GHZ] = &priv->band;
+
+	set_wiphy_dev(wiphy, dev);
+	wiphy->privid = prism2_wiphy_privid;
+	wiphy->max_scan_ssids = 1;
+	wiphy->interface_modes =
+		BIT(NL80211_IFTYPE_STATION) |
+		BIT(NL80211_IFTYPE_ADHOC);
+	wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
+	wiphy->n_cipher_suites = PRISM2_NUM_CIPHER_SUITES;
+	wiphy->cipher_suites = prism2_cipher_suites;
+
+	if (wiphy_register(wiphy) < 0)
+		return NULL;
+
+	return wiphy;
+}
+
+
+void wlan_free_wiphy(struct wiphy *wiphy)
+{
+	wiphy_unregister(wiphy);
+	wiphy_free(wiphy);
+}
--- old/drivers/staging/wlan-ng/p80211wext.c	2010-05-30 21:21:02.000000000 +0100
+++ new/drivers/staging/wlan-ng/p80211wext.c	1970-01-01 01:00:00.000000000 +0100
@@ -1,1690 +0,0 @@
-/* src/p80211/p80211wext.c
-*
-* Glue code to make linux-wlan-ng a happy wireless extension camper.
-*
-* original author:  Reyk Floeter <reyk@synack.de>
-* Completely re-written by Solomon Peachy <solomon@linux-wlan.com>
-*
-* Copyright (C) 2002 AbsoluteValue Systems, Inc.  All Rights Reserved.
-* --------------------------------------------------------------------
-*
-* linux-wlan
-*
-*   The contents of this file are subject to the Mozilla Public
-*   License Version 1.1 (the "License"); you may not use this file
-*   except in compliance with the License. You may obtain a copy of
-*   the License at http://www.mozilla.org/MPL/
-*
-*   Software distributed under the License is distributed on an "AS
-*   IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-*   implied. See the License for the specific language governing
-*   rights and limitations under the License.
-*
-*   Alternatively, the contents of this file may be used under the
-*   terms of the GNU Public License version 2 (the "GPL"), in which
-*   case the provisions of the GPL are applicable instead of the
-*   above.  If you wish to allow the use of your version of this file
-*   only under the terms of the GPL and not to allow others to use
-*   your version of this file under the MPL, indicate your decision
-*   by deleting the provisions above and replace them with the notice
-*   and other provisions required by the GPL.  If you do not delete
-*   the provisions above, a recipient may use your version of this
-*   file under either the MPL or the GPL.
-*
-* --------------------------------------------------------------------
-*/
-
-/*================================================================*/
-/* System Includes */
-
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/types.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/wireless.h>
-#include <net/iw_handler.h>
-#include <linux/if_arp.h>
-#include <linux/bitops.h>
-#include <linux/uaccess.h>
-#include <asm/byteorder.h>
-#include <linux/if_ether.h>
-
-#include "p80211types.h"
-#include "p80211hdr.h"
-#include "p80211conv.h"
-#include "p80211mgmt.h"
-#include "p80211msg.h"
-#include "p80211metastruct.h"
-#include "p80211metadef.h"
-#include "p80211netdev.h"
-#include "p80211ioctl.h"
-#include "p80211req.h"
-
-static int p80211wext_giwrate(netdevice_t *dev,
-			      struct iw_request_info *info,
-			      struct iw_param *rrq, char *extra);
-static int p80211wext_giwessid(netdevice_t *dev,
-			       struct iw_request_info *info,
-			       struct iw_point *data, char *essid);
-
-static u8 p80211_mhz_to_channel(u16 mhz)
-{
-	if (mhz >= 5000)
-		return (mhz - 5000) / 5;
-
-	if (mhz == 2484)
-		return 14;
-
-	if (mhz >= 2407)
-		return (mhz - 2407) / 5;
-
-	return 0;
-}
-
-static u16 p80211_channel_to_mhz(u8 ch, int dot11a)
-{
-
-	if (ch == 0)
-		return 0;
-	if (ch > 200)
-		return 0;
-
-	/* 5G */
-	if (dot11a)
-		return 5000 + (5 * ch);
-
-	/* 2.4G */
-	if (ch == 14)
-		return 2484;
-
-	if ((ch < 14) && (ch > 0))
-		return 2407 + (5 * ch);
-
-	return 0;
-}
-
-/* taken from orinoco.c ;-) */
-static const long p80211wext_channel_freq[] = {
-	2412, 2417, 2422, 2427, 2432, 2437, 2442,
-	2447, 2452, 2457, 2462, 2467, 2472, 2484
-};
-
-#define NUM_CHANNELS ARRAY_SIZE(p80211wext_channel_freq)
-
-/* steal a spare bit to store the shared/opensystems state.
-   should default to open if not set */
-#define HOSTWEP_SHAREDKEY BIT(3)
-
-static int qual_as_percent(int snr)
-{
-	if (snr <= 0)
-		return 0;
-	if (snr <= 40)
-		return snr * 5 / 2;
-	return 100;
-}
-
-static int p80211wext_setmib(wlandevice_t *wlandev, u32 did, u32 data)
-{
-	p80211msg_dot11req_mibset_t msg;
-	p80211item_uint32_t *mibitem =
-		(p80211item_uint32_t *)&msg.mibattribute.data;
-	int result;
-
-	msg.msgcode = DIDmsg_dot11req_mibset;
-	memset(mibitem, 0, sizeof(*mibitem));
-	mibitem->did = did;
-	mibitem->data = data;
-	result = p80211req_dorequest(wlandev, (u8 *) &msg);
-
-	return result;
-}
-
-/*
- * get a 32 bit mib value
- */
-static int p80211wext_getmib(wlandevice_t *wlandev, u32 did, u32 *data)
-{
-	p80211msg_dot11req_mibset_t msg;
-	p80211item_uint32_t *mibitem =
-		(p80211item_uint32_t *)&msg.mibattribute.data;
-	int result;
-
-	msg.msgcode = DIDmsg_dot11req_mibget;
-	memset(mibitem, 0, sizeof(*mibitem));
-	mibitem->did = did;
-	result = p80211req_dorequest(wlandev, (u8 *) &msg);
-	if (!result)
-		*data = mibitem->data;
-
-	return result;
-}
-
-static int p80211wext_autojoin(wlandevice_t *wlandev)
-{
-	p80211msg_lnxreq_autojoin_t msg;
-	struct iw_point data;
-	char ssid[IW_ESSID_MAX_SIZE];
-
-	int result;
-	int err = 0;
-
-	/* Get ESSID */
-	result = p80211wext_giwessid(wlandev->netdev, NULL, &data, ssid);
-
-	if (result) {
-		err = -EFAULT;
-		goto exit;
-	}
-
-	if (wlandev->hostwep & HOSTWEP_SHAREDKEY)
-		msg.authtype.data = P80211ENUM_authalg_sharedkey;
-	else
-		msg.authtype.data = P80211ENUM_authalg_opensystem;
-
-	msg.msgcode = DIDmsg_lnxreq_autojoin;
-
-	/* Trim the last '\0' to fit the SSID format */
-
-	if (data.length && ssid[data.length - 1] == '\0')
-		data.length = data.length - 1;
-
-	memcpy(msg.ssid.data.data, ssid, data.length);
-	msg.ssid.data.len = data.length;
-
-	result = p80211req_dorequest(wlandev, (u8 *) &msg);
-
-	if (result) {
-		err = -EFAULT;
-		goto exit;
-	}
-
-exit:
-
-	return err;
-
-}
-
-/* called by /proc/net/wireless */
-struct iw_statistics *p80211wext_get_wireless_stats(netdevice_t *dev)
-{
-	p80211msg_lnxreq_commsquality_t quality;
-	wlandevice_t *wlandev = dev->ml_priv;
-	struct iw_statistics *wstats = &wlandev->wstats;
-	int retval;
-
-	/* Check */
-	if ((wlandev == NULL) || (wlandev->msdstate != WLAN_MSD_RUNNING))
-		return NULL;
-
-	/* XXX Only valid in station mode */
-	wstats->status = 0;
-
-	/* build request message */
-	quality.msgcode = DIDmsg_lnxreq_commsquality;
-	quality.dbm.data = P80211ENUM_truth_true;
-	quality.dbm.status = P80211ENUM_msgitem_status_data_ok;
-
-	/* send message to nsd */
-	if (wlandev->mlmerequest == NULL)
-		return NULL;
-
-	retval = wlandev->mlmerequest(wlandev, (p80211msg_t *) &quality);
-
-	wstats->qual.qual = qual_as_percent(quality.link.data);	/* overall link quality */
-	wstats->qual.level = quality.level.data;	/* instant signal level */
-	wstats->qual.noise = quality.noise.data;	/* instant noise level */
-
-	wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM;
-	wstats->discard.code = wlandev->rx.decrypt_err;
-	wstats->discard.nwid = 0;
-	wstats->discard.misc = 0;
-
-	wstats->discard.fragment = 0;	/* incomplete fragments */
-	wstats->discard.retries = 0;	/* tx retries. */
-	wstats->miss.beacon = 0;
-
-	return wstats;
-}
-
-static int p80211wext_giwname(netdevice_t *dev,
-			      struct iw_request_info *info,
-			      char *name, char *extra)
-{
-	struct iw_param rate;
-	int result;
-	int err = 0;
-
-	result = p80211wext_giwrate(dev, NULL, &rate, NULL);
-
-	if (result) {
-		err = -EFAULT;
-		goto exit;
-	}
-
-	switch (rate.value) {
-	case 1000000:
-	case 2000000:
-		strcpy(name, "IEEE 802.11-DS");
-		break;
-	case 5500000:
-	case 11000000:
-		strcpy(name, "IEEE 802.11-b");
-		break;
-	}
-exit:
-	return err;
-}
-
-static int p80211wext_giwfreq(netdevice_t *dev,
-			      struct iw_request_info *info,
-			      struct iw_freq *freq, char *extra)
-{
-	wlandevice_t *wlandev = dev->ml_priv;
-	int result;
-	int err = 0;
-	unsigned int value;
-
-	result = p80211wext_getmib(wlandev,
-				   DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel,
-				   &value);
-	if (result) {
-		err = -EFAULT;
-		goto exit;
-	}
-
-	if (value > NUM_CHANNELS) {
-		err = -EFAULT;
-		goto exit;
-	}
-
-	/* convert into frequency instead of a channel */
-	freq->e = 1;
-	freq->m = p80211_channel_to_mhz(value, 0) * 100000;
-
-exit:
-	return err;
-}
-
-static int p80211wext_siwfreq(netdevice_t *dev,
-			      struct iw_request_info *info,
-			      struct iw_freq *freq, char *extra)
-{
-	wlandevice_t *wlandev = dev->ml_priv;
-	int result;
-	int err = 0;
-	unsigned int value;
-
-	if (!wlan_wext_write) {
-		err = -EOPNOTSUPP;
-		goto exit;
-	}
-
-	if ((freq->e == 0) && (freq->m <= 1000))
-		value = freq->m;
-	else
-		value = p80211_mhz_to_channel(freq->m);
-
-	result = p80211wext_setmib(wlandev,
-			     DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel,
-			     value);
-
-	if (result) {
-		err = -EFAULT;
-		goto exit;
-	}
-
-exit:
-	return err;
-}
-
-static int p80211wext_giwmode(netdevice_t *dev,
-			      struct iw_request_info *info,
-			      __u32 *mode, char *extra)
-{
-	wlandevice_t *wlandev = dev->ml_priv;
-
-	switch (wlandev->macmode) {
-	case WLAN_MACMODE_IBSS_STA:
-		*mode = IW_MODE_ADHOC;
-		break;
-	case WLAN_MACMODE_ESS_STA:
-		*mode = IW_MODE_INFRA;
-		break;
-	case WLAN_MACMODE_ESS_AP:
-		*mode = IW_MODE_MASTER;
-		break;
-	default:
-		/* Not set yet. */
-		*mode = IW_MODE_AUTO;
-	}
-
-	return 0;
-}
-
-static int p80211wext_siwmode(netdevice_t *dev,
-			      struct iw_request_info *info,
-			      __u32 *mode, char *extra)
-{
-	wlandevice_t *wlandev = dev->ml_priv;
-	int result;
-	int err = 0;
-
-	if (!wlan_wext_write) {
-		err = -EOPNOTSUPP;
-		goto exit;
-	}
-
-	if (*mode != IW_MODE_ADHOC && *mode != IW_MODE_INFRA &&
-	    *mode != IW_MODE_MASTER) {
-		err = (-EOPNOTSUPP);
-		goto exit;
-	}
-
-	/* Operation mode is the same with current mode */
-	if (*mode == wlandev->macmode)
-		goto exit;
-
-	switch (*mode) {
-	case IW_MODE_ADHOC:
-		wlandev->macmode = WLAN_MACMODE_IBSS_STA;
-		break;
-	case IW_MODE_INFRA:
-		wlandev->macmode = WLAN_MACMODE_ESS_STA;
-		break;
-	case IW_MODE_MASTER:
-		wlandev->macmode = WLAN_MACMODE_ESS_AP;
-		break;
-	default:
-		/* Not set yet. */
-		printk(KERN_INFO "Operation mode: %d not support\n", *mode);
-		return -EOPNOTSUPP;
-	}
-
-	/* Set Operation mode to the PORT TYPE RID */
-	result = p80211wext_setmib(wlandev,
-				DIDmib_p2_p2Static_p2CnfPortType,
-				(*mode == IW_MODE_ADHOC) ? 0 : 1);
-	if (result)
-		err = -EFAULT;
-exit:
-	return err;
-}
-
-static int p80211wext_giwrange(netdevice_t *dev,
-			       struct iw_request_info *info,
-			       struct iw_point *data, char *extra)
-{
-	struct iw_range *range = (struct iw_range *)extra;
-	int i, val;
-
-	/* for backward compatability set size and zero everything we don't understand */
-	data->length = sizeof(*range);
-	memset(range, 0, sizeof(*range));
-
-	range->txpower_capa = IW_TXPOW_DBM;
-	/* XXX what about min/max_pmp, min/max_pmt, etc. */
-
-	range->we_version_compiled = WIRELESS_EXT;
-	range->we_version_source = 13;
-
-	range->retry_capa = IW_RETRY_LIMIT;
-	range->retry_flags = IW_RETRY_LIMIT;
-	range->min_retry = 0;
-	range->max_retry = 255;
-
-	range->event_capa[0] = (IW_EVENT_CAPA_K_0 |	/* mode/freq/ssid */
-				IW_EVENT_CAPA_MASK(SIOCGIWAP) |
-				IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
-	range->event_capa[1] = IW_EVENT_CAPA_K_1;	/* encode */
-	range->event_capa[4] = (IW_EVENT_CAPA_MASK(IWEVQUAL) |
-				IW_EVENT_CAPA_MASK(IWEVCUSTOM));
-
-	range->num_channels = NUM_CHANNELS;
-
-	/* XXX need to filter against the regulatory domain &| active set */
-	val = 0;
-	for (i = 0; i < NUM_CHANNELS; i++) {
-		range->freq[val].i = i + 1;
-		range->freq[val].m = p80211wext_channel_freq[i] * 100000;
-		range->freq[val].e = 1;
-		val++;
-	}
-
-	range->num_frequency = val;
-
-	/* Max of /proc/net/wireless */
-	range->max_qual.qual = 100;
-	range->max_qual.level = 0;
-	range->max_qual.noise = 0;
-	range->sensitivity = 3;
-	/* XXX these need to be nsd-specific! */
-
-	range->min_rts = 0;
-	range->max_rts = 2347;
-	range->min_frag = 256;
-	range->max_frag = 2346;
-
-	range->max_encoding_tokens = NUM_WEPKEYS;
-	range->num_encoding_sizes = 2;
-	range->encoding_size[0] = 5;
-	range->encoding_size[1] = 13;
-
-	/* XXX what about num_bitrates/throughput? */
-	range->num_bitrates = 0;
-
-	/* estimated max throughput */
-	/* XXX need to cap it if we're running at ~2Mbps.. */
-	range->throughput = 5500000;
-
-	return 0;
-}
-
-static int p80211wext_giwap(netdevice_t *dev,
-			    struct iw_request_info *info,
-			    struct sockaddr *ap_addr, char *extra)
-{
-
-	wlandevice_t *wlandev = dev->ml_priv;
-
-	memcpy(ap_addr->sa_data, wlandev->bssid, WLAN_BSSID_LEN);
-	ap_addr->sa_family = ARPHRD_ETHER;
-
-	return 0;
-}
-
-static int p80211wext_giwencode(netdevice_t *dev,
-				struct iw_request_info *info,
-				struct iw_point *erq, char *key)
-{
-	wlandevice_t *wlandev = dev->ml_priv;
-	int err = 0;
-	int i;
-
-	i = (erq->flags & IW_ENCODE_INDEX) - 1;
-	erq->flags = 0;
-
-	if (wlandev->hostwep & HOSTWEP_PRIVACYINVOKED)
-		erq->flags |= IW_ENCODE_ENABLED;
-	else
-		erq->flags |= IW_ENCODE_DISABLED;
-
-	if (wlandev->hostwep & HOSTWEP_EXCLUDEUNENCRYPTED)
-		erq->flags |= IW_ENCODE_RESTRICTED;
-	else
-		erq->flags |= IW_ENCODE_OPEN;
-
-	i = (erq->flags & IW_ENCODE_INDEX) - 1;
-
-	if (i == -1)
-		i = wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK;
-
-	if ((i < 0) || (i >= NUM_WEPKEYS)) {
-		err = -EINVAL;
-		goto exit;
-	}
-
-	erq->flags |= i + 1;
-
-	/* copy the key from the driver cache as the keys are read-only MIBs */
-	erq->length = wlandev->wep_keylens[i];
-	memcpy(key, wlandev->wep_keys[i], erq->length);
-
-exit:
-	return err;
-}
-
-static int p80211wext_siwencode(netdevice_t *dev,
-				struct iw_request_info *info,
-				struct iw_point *erq, char *key)
-{
-	wlandevice_t *wlandev = dev->ml_priv;
-	p80211msg_dot11req_mibset_t msg;
-	p80211item_pstr32_t pstr;
-
-	int err = 0;
-	int result = 0;
-	int i;
-
-	if (!wlan_wext_write) {
-		err = (-EOPNOTSUPP);
-		goto exit;
-	}
-
-	/* Check the Key index first. */
-	i = (erq->flags & IW_ENCODE_INDEX);
-	if (i) {
-		if ((i < 1) || (i > NUM_WEPKEYS)) {
-			err = -EINVAL;
-			goto exit;
-		} else {
-			i--;
-		}
-		/* Set current key number only if no keys are given */
-		if (erq->flags & IW_ENCODE_NOKEY) {
-			result =
-				p80211wext_setmib(wlandev,
-						  DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID,
-						  i);
-
-			if (result) {
-				err = -EFAULT;
-				goto exit;
-			}
-		}
-
-	} else {
-		/* Use defaultkey if no Key Index */
-		i = wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK;
-	}
-
-	/* Check if there is no key information in the iwconfig request */
-	if ((erq->flags & IW_ENCODE_NOKEY) == 0) {
-
-		/*------------------------------------------------------------
-		 * If there is WEP Key for setting, check the Key Information
-		 * and then set it to the firmware.
-		 -------------------------------------------------------------*/
-
-		if (erq->length > 0) {
-			/* copy the key from the driver cache as the keys are read-only MIBs */
-			wlandev->wep_keylens[i] = erq->length;
-			memcpy(wlandev->wep_keys[i], key, erq->length);
-
-			/* Prepare data struture for p80211req_dorequest. */
-			memcpy(pstr.data.data, key, erq->length);
-			pstr.data.len = erq->length;
-
-			switch (i) {
-			case 0:
-				pstr.did =
-				    DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0;
-				break;
-
-			case 1:
-				pstr.did =
-				    DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1;
-				break;
-
-			case 2:
-				pstr.did =
-				    DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2;
-				break;
-
-			case 3:
-				pstr.did =
-				    DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3;
-				break;
-
-			default:
-				err = -EINVAL;
-				goto exit;
-			}
-
-			msg.msgcode = DIDmsg_dot11req_mibset;
-			memcpy(&msg.mibattribute.data, &pstr, sizeof(pstr));
-			result = p80211req_dorequest(wlandev, (u8 *) &msg);
-
-			if (result) {
-				err = -EFAULT;
-				goto exit;
-			}
-		}
-
-	}
-
-	/* Check the PrivacyInvoked flag */
-	if (erq->flags & IW_ENCODE_DISABLED) {
-		result =
-		    p80211wext_setmib(wlandev,
-					 DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked,
-					 P80211ENUM_truth_false);
-	} else {
-		result =
-		    p80211wext_setmib(wlandev,
-					 DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked,
-					 P80211ENUM_truth_true);
-	}
-
-	if (result) {
-		err = -EFAULT;
-		goto exit;
-	}
-
-	/*  The  security  mode  may  be open or restricted, and its meaning
-	   depends on the card used. With  most  cards,  in  open  mode  no
-	   authentication  is  used  and  the  card  may  also  accept non-
-	   encrypted sessions, whereas in restricted  mode  only  encrypted
-	   sessions  are  accepted  and the card will use authentication if
-	   available.
-	 */
-	if (erq->flags & IW_ENCODE_RESTRICTED) {
-		result =
-		    p80211wext_setmib(wlandev,
-					 DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted,
-					 P80211ENUM_truth_true);
-	} else if (erq->flags & IW_ENCODE_OPEN) {
-		result =
-		    p80211wext_setmib(wlandev,
-					 DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted,
-					 P80211ENUM_truth_false);
-	}
-
-	if (result) {
-		err = -EFAULT;
-		goto exit;
-	}
-
-exit:
-
-	return err;
-}
-
-static int p80211wext_giwessid(netdevice_t *dev,
-			       struct iw_request_info *info,
-			       struct iw_point *data, char *essid)
-{
-	wlandevice_t *wlandev = dev->ml_priv;
-
-	if (wlandev->ssid.len) {
-		data->length = wlandev->ssid.len;
-		data->flags = 1;
-		memcpy(essid, wlandev->ssid.data, data->length);
-		essid[data->length] = 0;
-	} else {
-		memset(essid, 0, sizeof(wlandev->ssid.data));
-		data->length = 0;
-		data->flags = 0;
-	}
-
-	return 0;
-}
-
-static int p80211wext_siwessid(netdevice_t *dev,
-			       struct iw_request_info *info,
-			       struct iw_point *data, char *essid)
-{
-	wlandevice_t *wlandev = dev->ml_priv;
-	p80211msg_lnxreq_autojoin_t msg;
-
-	int result;
-	int err = 0;
-	int length = data->length;
-
-	if (!wlan_wext_write) {
-		err = (-EOPNOTSUPP);
-		goto exit;
-	}
-
-	if (wlandev->hostwep & HOSTWEP_SHAREDKEY)
-		msg.authtype.data = P80211ENUM_authalg_sharedkey;
-	else
-		msg.authtype.data = P80211ENUM_authalg_opensystem;
-
-	msg.msgcode = DIDmsg_lnxreq_autojoin;
-
-	/* Trim the last '\0' to fit the SSID format */
-	if (length && essid[length - 1] == '\0')
-		length--;
-
-	memcpy(msg.ssid.data.data, essid, length);
-	msg.ssid.data.len = length;
-
-	pr_debug("autojoin_ssid for %s \n", essid);
-	result = p80211req_dorequest(wlandev, (u8 *) &msg);
-	pr_debug("autojoin_ssid %d\n", result);
-
-	if (result) {
-		err = -EFAULT;
-		goto exit;
-	}
-
-exit:
-	return err;
-}
-
-static int p80211wext_siwcommit(netdevice_t *dev,
-				struct iw_request_info *info,
-				struct iw_point *data, char *essid)
-{
-	wlandevice_t *wlandev = dev->ml_priv;
-	int err = 0;
-
-	if (!wlan_wext_write) {
-		err = (-EOPNOTSUPP);
-		goto exit;
-	}
-
-	/* Auto Join */
-	err = p80211wext_autojoin(wlandev);
-
-exit:
-	return err;
-}
-
-static int p80211wext_giwrate(netdevice_t *dev,
-			      struct iw_request_info *info,
-			      struct iw_param *rrq, char *extra)
-{
-	wlandevice_t *wlandev = dev->ml_priv;
-	int result;
-	int err = 0;
-	unsigned int value;
-
-	result = p80211wext_getmib(wlandev, DIDmib_p2_p2MAC_p2CurrentTxRate, &value);
-	if (result) {
-		err = -EFAULT;
-		goto exit;
-	}
-
-	rrq->fixed = 0;		/* can it change? */
-	rrq->disabled = 0;
-	rrq->value = 0;
-
-#define		HFA384x_RATEBIT_1			((u16)1)
-#define		HFA384x_RATEBIT_2			((u16)2)
-#define		HFA384x_RATEBIT_5dot5			((u16)4)
-#define		HFA384x_RATEBIT_11			((u16)8)
-
-	switch (value) {
-	case HFA384x_RATEBIT_1:
-		rrq->value = 1000000;
-		break;
-	case HFA384x_RATEBIT_2:
-		rrq->value = 2000000;
-		break;
-	case HFA384x_RATEBIT_5dot5:
-		rrq->value = 5500000;
-		break;
-	case HFA384x_RATEBIT_11:
-		rrq->value = 11000000;
-		break;
-	default:
-		err = -EINVAL;
-	}
-exit:
-	return err;
-}
-
-static int p80211wext_giwrts(netdevice_t *dev,
-			     struct iw_request_info *info,
-			     struct iw_param *rts, char *extra)
-{
-	wlandevice_t *wlandev = dev->ml_priv;
-	int result;
-	int err = 0;
-	unsigned int value;
-
-	result = p80211wext_getmib(wlandev,
-				   DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold,
-				   &value);
-	if (result) {
-		err = -EFAULT;
-		goto exit;
-	}
-
-	rts->value = value;
-	rts->disabled = (rts->value == 2347);
-	rts->fixed = 1;
-
-exit:
-	return err;
-}
-
-static int p80211wext_siwrts(netdevice_t *dev,
-			     struct iw_request_info *info,
-			     struct iw_param *rts, char *extra)
-{
-	wlandevice_t *wlandev = dev->ml_priv;
-	int result;
-	int err = 0;
-	unsigned int value;
-
-	if (!wlan_wext_write) {
-		err = -EOPNOTSUPP;
-		goto exit;
-	}
-
-	if (rts->disabled)
-		value = 2347;
-	else
-		value = rts->value;
-
-	result = p80211wext_setmib(wlandev,
-				   DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold,
-				   value);
-	if (result) {
-		err = -EFAULT;
-		goto exit;
-	}
-
-exit:
-	return err;
-}
-
-static int p80211wext_giwfrag(netdevice_t *dev,
-			      struct iw_request_info *info,
-			      struct iw_param *frag, char *extra)
-{
-	wlandevice_t *wlandev = dev->ml_priv;
-	int result;
-	int err = 0;
-	unsigned int value;
-
-	result = p80211wext_getmib(wlandev,
-				   DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold,
-				   &value);
-	if (result) {
-		err = -EFAULT;
-		goto exit;
-	}
-
-	frag->value = value;
-	frag->disabled = (frag->value == 2346);
-	frag->fixed = 1;
-
-exit:
-	return err;
-}
-
-static int p80211wext_siwfrag(netdevice_t *dev,
-			      struct iw_request_info *info,
-			      struct iw_param *frag, char *extra)
-{
-	wlandevice_t *wlandev = dev->ml_priv;
-	int result;
-	int err = 0;
-	int value;
-
-	if (!wlan_wext_write) {
-		err = (-EOPNOTSUPP);
-		goto exit;
-	}
-
-	if (frag->disabled)
-		value = 2346;
-	else
-		value = frag->value;
-
-	result = p80211wext_setmib(wlandev,
-		   DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold,
-				      value);
-
-	if (result) {
-		err = -EFAULT;
-		goto exit;
-	}
-
-exit:
-	return err;
-}
-
-#ifndef IW_RETRY_LONG
-#define IW_RETRY_LONG IW_RETRY_MAX
-#endif
-
-#ifndef IW_RETRY_SHORT
-#define IW_RETRY_SHORT IW_RETRY_MIN
-#endif
-
-static int p80211wext_giwretry(netdevice_t *dev,
-			       struct iw_request_info *info,
-			       struct iw_param *rrq, char *extra)
-{
-	wlandevice_t *wlandev = dev->ml_priv;
-	int result;
-	int err = 0;
-	u16 shortretry, longretry, lifetime;
-	unsigned int value;
-
-	result = p80211wext_getmib(wlandev,
-				   DIDmib_dot11mac_dot11OperationTable_dot11ShortRetryLimit,
-				   &value);
-	if (result) {
-		err = -EFAULT;
-		goto exit;
-	}
-
-	shortretry = value;
-
-	result = p80211wext_getmib(wlandev,
-				   DIDmib_dot11mac_dot11OperationTable_dot11LongRetryLimit,
-				   &value);
-	if (result) {
-		err = -EFAULT;
-		goto exit;
-	}
-
-	longretry = value;
-
-	result = p80211wext_getmib(wlandev,
-				   DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime,
-				   &value);
-	if (result) {
-		err = -EFAULT;
-		goto exit;
-	}
-
-	lifetime = value;
-
-	rrq->disabled = 0;
-
-	if ((rrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
-		rrq->flags = IW_RETRY_LIFETIME;
-		rrq->value = lifetime * 1024;
-	} else {
-		if (rrq->flags & IW_RETRY_LONG) {
-			rrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
-			rrq->value = longretry;
-		} else {
-			rrq->flags = IW_RETRY_LIMIT;
-			rrq->value = shortretry;
-			if (shortretry != longretry)
-				rrq->flags |= IW_RETRY_SHORT;
-		}
-	}
-
-exit:
-	return err;
-
-}
-
-static int p80211wext_siwretry(netdevice_t *dev,
-			       struct iw_request_info *info,
-			       struct iw_param *rrq, char *extra)
-{
-	wlandevice_t *wlandev = dev->ml_priv;
-	p80211item_uint32_t mibitem;
-	p80211msg_dot11req_mibset_t msg;
-	int result;
-	int err = 0;
-	unsigned int value;
-
-	if (!wlan_wext_write) {
-		err = (-EOPNOTSUPP);
-		goto exit;
-	}
-
-	if (rrq->disabled) {
-		err = -EINVAL;
-		goto exit;
-	}
-
-	msg.msgcode = DIDmsg_dot11req_mibset;
-
-	if ((rrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
-
-		value = rrq->value /= 1024;
-		result = p80211wext_setmib(wlandev,
-					   DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime,
-					   value);
-		if (result) {
-			err = -EFAULT;
-			goto exit;
-		}
-	} else {
-		if (rrq->flags & IW_RETRY_LONG) {
-			result = p80211wext_setmib(wlandev,
-						   DIDmib_dot11mac_dot11OperationTable_dot11LongRetryLimit,
-						   rrq->value);
-
-			if (result) {
-				err = -EFAULT;
-				goto exit;
-			}
-		}
-
-		if (rrq->flags & IW_RETRY_SHORT) {
-			result = p80211wext_setmib(wlandev,
-						   DIDmib_dot11mac_dot11OperationTable_dot11ShortRetryLimit,
-						   rrq->value);
-
-			if (result) {
-				err = -EFAULT;
-				goto exit;
-			}
-		}
-	}
-
-exit:
-	return err;
-
-}
-
-static int p80211wext_siwtxpow(netdevice_t *dev,
-			       struct iw_request_info *info,
-			       struct iw_param *rrq, char *extra)
-{
-	wlandevice_t *wlandev = dev->ml_priv;
-	p80211item_uint32_t mibitem;
-	p80211msg_dot11req_mibset_t msg;
-	int result;
-	int err = 0;
-	unsigned int value;
-
-	if (!wlan_wext_write) {
-		err = (-EOPNOTSUPP);
-		goto exit;
-	}
-
-	if (rrq->fixed == 0)
-		value = 30;
-	else
-		value = rrq->value;
-	result = p80211wext_setmib(wlandev,
-				   DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel,
-				   value);
-
-	if (result) {
-		err = -EFAULT;
-		goto exit;
-	}
-
-exit:
-	return err;
-}
-
-static int p80211wext_giwtxpow(netdevice_t *dev,
-			       struct iw_request_info *info,
-			       struct iw_param *rrq, char *extra)
-{
-	wlandevice_t *wlandev = dev->ml_priv;
-	int result;
-	int err = 0;
-	unsigned int value;
-
-	result = p80211wext_getmib(wlandev,
-				   DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel,
-				   &value);
-
-	if (result) {
-		err = -EFAULT;
-		goto exit;
-	}
-
-	/* XXX handle OFF by setting disabled = 1; */
-
-	rrq->flags = 0;		/* IW_TXPOW_DBM; */
-	rrq->disabled = 0;
-	rrq->fixed = 0;
-	rrq->value = value;
-
-exit:
-	return err;
-}
-
-static int p80211wext_siwspy(netdevice_t *dev,
-			     struct iw_request_info *info,
-			     struct iw_point *srq, char *extra)
-{
-	wlandevice_t *wlandev = dev->ml_priv;
-	struct sockaddr address[IW_MAX_SPY];
-	int number = srq->length;
-	int i;
-
-	/* Copy the data from the input buffer */
-	memcpy(address, extra, sizeof(struct sockaddr) * number);
-
-	wlandev->spy_number = 0;
-
-	if (number > 0) {
-
-		/* extract the addresses */
-		for (i = 0; i < number; i++) {
-
-			memcpy(wlandev->spy_address[i], address[i].sa_data,
-			       ETH_ALEN);
-		}
-
-		/* reset stats */
-		memset(wlandev->spy_stat, 0,
-		       sizeof(struct iw_quality) * IW_MAX_SPY);
-
-		/* set number of addresses */
-		wlandev->spy_number = number;
-	}
-
-	return 0;
-}
-
-/* jkriegl: from orinoco, modified */
-static int p80211wext_giwspy(netdevice_t *dev,
-			     struct iw_request_info *info,
-			     struct iw_point *srq, char *extra)
-{
-	wlandevice_t *wlandev = dev->ml_priv;
-
-	struct sockaddr address[IW_MAX_SPY];
-	struct iw_quality spy_stat[IW_MAX_SPY];
-	int number;
-	int i;
-
-	number = wlandev->spy_number;
-
-	if (number > 0) {
-
-		/* populate address and spy struct's */
-		for (i = 0; i < number; i++) {
-			memcpy(address[i].sa_data, wlandev->spy_address[i],
-			       ETH_ALEN);
-			address[i].sa_family = AF_UNIX;
-			memcpy(&spy_stat[i], &wlandev->spy_stat[i],
-			       sizeof(struct iw_quality));
-		}
-
-		/* reset update flag */
-		for (i = 0; i < number; i++)
-			wlandev->spy_stat[i].updated = 0;
-	}
-
-	/* push stuff to user space */
-	srq->length = number;
-	memcpy(extra, address, sizeof(struct sockaddr) * number);
-	memcpy(extra + sizeof(struct sockaddr) * number, spy_stat,
-	       sizeof(struct iw_quality) * number);
-
-	return 0;
-}
-
-static int prism2_result2err(int prism2_result)
-{
-	int err = 0;
-
-	switch (prism2_result) {
-	case P80211ENUM_resultcode_invalid_parameters:
-		err = -EINVAL;
-		break;
-	case P80211ENUM_resultcode_implementation_failure:
-		err = -EIO;
-		break;
-	case P80211ENUM_resultcode_not_supported:
-		err = -EOPNOTSUPP;
-		break;
-	default:
-		err = 0;
-		break;
-	}
-
-	return err;
-}
-
-static int p80211wext_siwscan(netdevice_t *dev,
-			      struct iw_request_info *info,
-			      struct iw_point *srq, char *extra)
-{
-	wlandevice_t *wlandev = dev->ml_priv;
-	p80211msg_dot11req_scan_t msg;
-	int result;
-	int err = 0;
-	int i = 0;
-
-	if (wlandev->macmode == WLAN_MACMODE_ESS_AP) {
-		printk(KERN_ERR "Can't scan in AP mode\n");
-		err = (-EOPNOTSUPP);
-		goto exit;
-	}
-
-	memset(&msg, 0x00, sizeof(p80211msg_dot11req_scan_t));
-	msg.msgcode = DIDmsg_dot11req_scan;
-	msg.bsstype.data = P80211ENUM_bsstype_any;
-
-	memset(&(msg.bssid.data), 0xFF, sizeof(p80211item_pstr6_t));
-	msg.bssid.data.len = 6;
-
-	msg.scantype.data = P80211ENUM_scantype_active;
-	msg.probedelay.data = 0;
-
-	for (i = 1; i <= 14; i++)
-		msg.channellist.data.data[i - 1] = i;
-	msg.channellist.data.len = 14;
-
-	msg.maxchanneltime.data = 250;
-	msg.minchanneltime.data = 200;
-
-	result = p80211req_dorequest(wlandev, (u8 *) &msg);
-	if (result)
-		err = prism2_result2err(msg.resultcode.data);
-
-exit:
-	return err;
-}
-
-/* Helper to translate scan into Wireless Extensions scan results.
- * Inspired by the prism54 code, which was in turn inspired by the
- * airo driver code.
- */
-static char *wext_translate_bss(struct iw_request_info *info, char *current_ev,
-				char *end_buf,
-				p80211msg_dot11req_scan_results_t *bss)
-{
-	struct iw_event iwe;	/* Temporary buffer */
-
-	/* The first entry must be the MAC address */
-	memcpy(iwe.u.ap_addr.sa_data, bss->bssid.data.data, WLAN_BSSID_LEN);
-	iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
-	iwe.cmd = SIOCGIWAP;
-	current_ev =
-	    iwe_stream_add_event(info, current_ev, end_buf, &iwe,
-				 IW_EV_ADDR_LEN);
-
-	/* The following entries will be displayed in the same order we give them */
-
-	/* The ESSID. */
-	if (bss->ssid.data.len > 0) {
-		char essid[IW_ESSID_MAX_SIZE + 1];
-		int size;
-
-		size =
-		    min_t(unsigned short, IW_ESSID_MAX_SIZE,
-			  bss->ssid.data.len);
-		memset(&essid, 0, sizeof(essid));
-		memcpy(&essid, bss->ssid.data.data, size);
-		pr_debug(" essid size = %d\n", size);
-		iwe.u.data.length = size;
-		iwe.u.data.flags = 1;
-		iwe.cmd = SIOCGIWESSID;
-		current_ev =
-		    iwe_stream_add_point(info, current_ev, end_buf, &iwe,
-					 &essid[0]);
-		pr_debug(" essid size OK.\n");
-	}
-
-	switch (bss->bsstype.data) {
-	case P80211ENUM_bsstype_infrastructure:
-		iwe.u.mode = IW_MODE_MASTER;
-		break;
-
-	case P80211ENUM_bsstype_independent:
-		iwe.u.mode = IW_MODE_ADHOC;
-		break;
-
-	default:
-		iwe.u.mode = 0;
-		break;
-	}
-	iwe.cmd = SIOCGIWMODE;
-	if (iwe.u.mode)
-		current_ev =
-		    iwe_stream_add_event(info, current_ev, end_buf, &iwe,
-					 IW_EV_UINT_LEN);
-
-	/* Encryption capability */
-	if (bss->privacy.data == P80211ENUM_truth_true)
-		iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
-	else
-		iwe.u.data.flags = IW_ENCODE_DISABLED;
-	iwe.u.data.length = 0;
-	iwe.cmd = SIOCGIWENCODE;
-	current_ev =
-	    iwe_stream_add_point(info, current_ev, end_buf, &iwe, NULL);
-
-	/* Add frequency. (short) bss->channel is the frequency in MHz */
-	iwe.u.freq.m = bss->dschannel.data;
-	iwe.u.freq.e = 0;
-	iwe.cmd = SIOCGIWFREQ;
-	current_ev =
-	    iwe_stream_add_event(info, current_ev, end_buf, &iwe,
-				 IW_EV_FREQ_LEN);
-
-	/* Add quality statistics */
-	iwe.u.qual.level = bss->signal.data;
-	iwe.u.qual.noise = bss->noise.data;
-	/* do a simple SNR for quality */
-	iwe.u.qual.qual = qual_as_percent(bss->signal.data - bss->noise.data);
-	iwe.cmd = IWEVQUAL;
-	current_ev =
-	    iwe_stream_add_event(info, current_ev, end_buf, &iwe,
-				 IW_EV_QUAL_LEN);
-
-	return current_ev;
-}
-
-static int p80211wext_giwscan(netdevice_t *dev,
-			      struct iw_request_info *info,
-			      struct iw_point *srq, char *extra)
-{
-	wlandevice_t *wlandev = dev->ml_priv;
-	p80211msg_dot11req_scan_results_t msg;
-	int result = 0;
-	int err = 0;
-	int i = 0;
-	int scan_good = 0;
-	char *current_ev = extra;
-
-	/* Since wireless tools doesn't really have a way of passing how
-	 * many scan results results there were back here, keep grabbing them
-	 * until we fail.
-	 */
-	do {
-		memset(&msg, 0, sizeof(msg));
-		msg.msgcode = DIDmsg_dot11req_scan_results;
-		msg.bssindex.data = i;
-
-		result = p80211req_dorequest(wlandev, (u8 *) &msg);
-		if ((result != 0) ||
-		    (msg.resultcode.data != P80211ENUM_resultcode_success)) {
-			break;
-		}
-
-		current_ev =
-		    wext_translate_bss(info, current_ev,
-				       extra + IW_SCAN_MAX_DATA, &msg);
-		scan_good = 1;
-		i++;
-	} while (i < IW_MAX_AP);
-
-	srq->length = (current_ev - extra);
-	srq->flags = 0;		/* todo */
-
-	if (result && !scan_good)
-		err = prism2_result2err(msg.resultcode.data);
-
-	return err;
-}
-
-/* extra wireless extensions stuff to support NetworkManager (I hope) */
-
-/* SIOCSIWENCODEEXT */
-static int p80211wext_set_encodeext(struct net_device *dev,
-				    struct iw_request_info *info,
-				    union iwreq_data *wrqu, char *extra)
-{
-	wlandevice_t *wlandev = dev->ml_priv;
-	struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
-	p80211msg_dot11req_mibset_t msg;
-	p80211item_pstr32_t *pstr;
-
-	int result = 0;
-	struct iw_point *encoding = &wrqu->encoding;
-	int idx = encoding->flags & IW_ENCODE_INDEX;
-
-	pr_debug("set_encode_ext flags[%d] alg[%d] keylen[%d]\n",
-		 ext->ext_flags, (int)ext->alg, (int)ext->key_len);
-
-	if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) {
-		/* set default key ? I'm not sure if this the the correct thing to do here */
-
-		if (idx) {
-			if (idx < 1 || idx > NUM_WEPKEYS)
-				return -EINVAL;
-			else
-				idx--;
-		}
-		pr_debug("setting default key (%d)\n", idx);
-		result =
-		    p80211wext_setmib(wlandev,
-					 DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID,
-					 idx);
-		if (result)
-			return -EFAULT;
-	}
-
-	if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
-		if (ext->alg != IW_ENCODE_ALG_WEP) {
-			pr_debug("asked to set a non wep key :(\n");
-			return -EINVAL;
-		}
-		if (idx) {
-			if (idx < 1 || idx > NUM_WEPKEYS)
-				return -EINVAL;
-			else
-				idx--;
-		}
-		pr_debug("Set WEP key (%d)\n", idx);
-		wlandev->wep_keylens[idx] = ext->key_len;
-		memcpy(wlandev->wep_keys[idx], ext->key, ext->key_len);
-
-		memset(&msg, 0, sizeof(msg));
-		pstr = (p80211item_pstr32_t *) &msg.mibattribute.data;
-		memcpy(pstr->data.data, ext->key, ext->key_len);
-		pstr->data.len = ext->key_len;
-		switch (idx) {
-		case 0:
-			pstr->did =
-			    DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0;
-			break;
-		case 1:
-			pstr->did =
-			    DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1;
-			break;
-		case 2:
-			pstr->did =
-			    DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2;
-			break;
-		case 3:
-			pstr->did =
-			    DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3;
-			break;
-		default:
-			break;
-		}
-		msg.msgcode = DIDmsg_dot11req_mibset;
-		result = p80211req_dorequest(wlandev, (u8 *) &msg);
-		pr_debug("result (%d)\n", result);
-	}
-	return result;
-}
-
-/* SIOCGIWENCODEEXT */
-static int p80211wext_get_encodeext(struct net_device *dev,
-				    struct iw_request_info *info,
-				    union iwreq_data *wrqu, char *extra)
-{
-	wlandevice_t *wlandev = dev->ml_priv;
-	struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
-
-	struct iw_point *encoding = &wrqu->encoding;
-	int result = 0;
-	int max_len;
-	int idx;
-
-	pr_debug("get_encode_ext flags[%d] alg[%d] keylen[%d]\n",
-		 ext->ext_flags, (int)ext->alg, (int)ext->key_len);
-
-	max_len = encoding->length - sizeof(*ext);
-	if (max_len <= 0) {
-		pr_debug("get_encodeext max_len [%d] invalid\n", max_len);
-		result = -EINVAL;
-		goto exit;
-	}
-	idx = encoding->flags & IW_ENCODE_INDEX;
-
-	pr_debug("get_encode_ext index [%d]\n", idx);
-
-	if (idx) {
-		if (idx < 1 || idx > NUM_WEPKEYS) {
-			pr_debug("get_encode_ext invalid key index [%d]\n",
-				 idx);
-			result = -EINVAL;
-			goto exit;
-		}
-		idx--;
-	} else {
-		/* default key ? not sure what to do */
-		/* will just use key[0] for now ! FIX ME */
-	}
-
-	encoding->flags = idx + 1;
-	memset(ext, 0, sizeof(*ext));
-
-	ext->alg = IW_ENCODE_ALG_WEP;
-	ext->key_len = wlandev->wep_keylens[idx];
-	memcpy(ext->key, wlandev->wep_keys[idx], ext->key_len);
-
-	encoding->flags |= IW_ENCODE_ENABLED;
-exit:
-	return result;
-}
-
-/* SIOCSIWAUTH */
-static int p80211_wext_set_iwauth(struct net_device *dev,
-				  struct iw_request_info *info,
-				  union iwreq_data *wrqu, char *extra)
-{
-	wlandevice_t *wlandev = dev->ml_priv;
-	struct iw_param *param = &wrqu->param;
-	int result = 0;
-
-	pr_debug("set_iwauth flags[%d]\n", (int)param->flags & IW_AUTH_INDEX);
-
-	switch (param->flags & IW_AUTH_INDEX) {
-	case IW_AUTH_DROP_UNENCRYPTED:
-		pr_debug("drop_unencrypted %d\n", param->value);
-		if (param->value)
-			result =
-			    p80211wext_setmib(wlandev,
-						 DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted,
-						 P80211ENUM_truth_true);
-		else
-			result =
-			    p80211wext_setmib(wlandev,
-						 DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted,
-						 P80211ENUM_truth_false);
-		break;
-
-	case IW_AUTH_PRIVACY_INVOKED:
-		pr_debug("privacy invoked %d\n", param->value);
-		if (param->value)
-			result =
-			    p80211wext_setmib(wlandev,
-						 DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked,
-						 P80211ENUM_truth_true);
-		else
-			result =
-			    p80211wext_setmib(wlandev,
-						 DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked,
-						 P80211ENUM_truth_false);
-
-		break;
-
-	case IW_AUTH_80211_AUTH_ALG:
-		if (param->value & IW_AUTH_ALG_OPEN_SYSTEM) {
-			pr_debug("set open_system\n");
-			wlandev->hostwep &= ~HOSTWEP_SHAREDKEY;
-		} else if (param->value & IW_AUTH_ALG_SHARED_KEY) {
-			pr_debug("set shared key\n");
-			wlandev->hostwep |= HOSTWEP_SHAREDKEY;
-		} else {
-			/* don't know what to do know  */
-			pr_debug("unknown AUTH_ALG (%d)\n", param->value);
-			result = -EINVAL;
-		}
-		break;
-
-	default:
-		break;
-	}
-
-	return result;
-}
-
-/* SIOCSIWAUTH */
-static int p80211_wext_get_iwauth(struct net_device *dev,
-				  struct iw_request_info *info,
-				  union iwreq_data *wrqu, char *extra)
-{
-	wlandevice_t *wlandev = dev->ml_priv;
-	struct iw_param *param = &wrqu->param;
-	int result = 0;
-
-	pr_debug("get_iwauth flags[%d]\n", (int)param->flags & IW_AUTH_INDEX);
-
-	switch (param->flags & IW_AUTH_INDEX) {
-	case IW_AUTH_DROP_UNENCRYPTED:
-		param->value =
-		    wlandev->hostwep & HOSTWEP_EXCLUDEUNENCRYPTED ? 1 : 0;
-		break;
-
-	case IW_AUTH_PRIVACY_INVOKED:
-		param->value =
-		    wlandev->hostwep & HOSTWEP_PRIVACYINVOKED ? 1 : 0;
-		break;
-
-	case IW_AUTH_80211_AUTH_ALG:
-		param->value =
-		    wlandev->hostwep & HOSTWEP_SHAREDKEY ?
-		    IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM;
-		break;
-
-	default:
-		break;
-	}
-
-	return result;
-}
-
-#define IW_IOCTL(x) [(x)-SIOCSIWCOMMIT]
-
-static iw_handler p80211wext_handlers[] = {
-	IW_IOCTL(SIOCSIWCOMMIT) = (iw_handler) p80211wext_siwcommit,
-	IW_IOCTL(SIOCGIWNAME) = (iw_handler) p80211wext_giwname,
-/* SIOCSIWNWID,SIOCGIWNWID */
-	IW_IOCTL(SIOCSIWFREQ) = (iw_handler) p80211wext_siwfreq,
-	IW_IOCTL(SIOCGIWFREQ) = (iw_handler) p80211wext_giwfreq,
-	IW_IOCTL(SIOCSIWMODE) = (iw_handler) p80211wext_siwmode,
-	IW_IOCTL(SIOCGIWMODE) = (iw_handler) p80211wext_giwmode,
-/* SIOCSIWSENS,SIOCGIWSENS,SIOCSIWRANGE */
-	IW_IOCTL(SIOCGIWRANGE) = (iw_handler) p80211wext_giwrange,
-/* SIOCSIWPRIV,SIOCGIWPRIV,SIOCSIWSTATS,SIOCGIWSTATS */
-	IW_IOCTL(SIOCSIWSPY) = (iw_handler) p80211wext_siwspy,
-	IW_IOCTL(SIOCGIWSPY) = (iw_handler) p80211wext_giwspy,
-/* SIOCSIWAP */
-	IW_IOCTL(SIOCGIWAP) = (iw_handler) p80211wext_giwap,
-/* SIOCGIWAPLIST */
-	IW_IOCTL(SIOCSIWSCAN) = (iw_handler) p80211wext_siwscan,
-	IW_IOCTL(SIOCGIWSCAN) = (iw_handler) p80211wext_giwscan,
-	IW_IOCTL(SIOCSIWESSID) = (iw_handler) p80211wext_siwessid,
-	IW_IOCTL(SIOCGIWESSID) = (iw_handler) p80211wext_giwessid,
-/* SIOCSIWNICKN */
-	IW_IOCTL(SIOCGIWNICKN) = (iw_handler) p80211wext_giwessid,
-/* SIOCSIWRATE */
-	IW_IOCTL(SIOCGIWRATE) = (iw_handler) p80211wext_giwrate,
-	IW_IOCTL(SIOCSIWRTS) = (iw_handler) p80211wext_siwrts,
-	IW_IOCTL(SIOCGIWRTS) = (iw_handler) p80211wext_giwrts,
-	IW_IOCTL(SIOCSIWFRAG) = (iw_handler) p80211wext_siwfrag,
-	IW_IOCTL(SIOCGIWFRAG) = (iw_handler) p80211wext_giwfrag,
-	IW_IOCTL(SIOCSIWTXPOW) = (iw_handler) p80211wext_siwtxpow,
-	IW_IOCTL(SIOCGIWTXPOW) = (iw_handler) p80211wext_giwtxpow,
-	IW_IOCTL(SIOCSIWRETRY) = (iw_handler) p80211wext_siwretry,
-	IW_IOCTL(SIOCGIWRETRY) = (iw_handler) p80211wext_giwretry,
-	IW_IOCTL(SIOCSIWENCODE) = (iw_handler) p80211wext_siwencode,
-	IW_IOCTL(SIOCGIWENCODE) = (iw_handler) p80211wext_giwencode,
-/* SIOCSIWPOWER,SIOCGIWPOWER */
-/* WPA operations */
-/* SIOCSIWGENIE,SIOCGIWGENIE generic IE */
-	IW_IOCTL(SIOCSIWAUTH) = (iw_handler) p80211_wext_set_iwauth, /*set authentication mode params */
-	IW_IOCTL(SIOCGIWAUTH) = (iw_handler) p80211_wext_get_iwauth, /*get authentication mode params */
-	IW_IOCTL(SIOCSIWENCODEEXT) = (iw_handler) p80211wext_set_encodeext, /*set encoding token & mode */
-	IW_IOCTL(SIOCGIWENCODEEXT) = (iw_handler) p80211wext_get_encodeext, /*get encoding token & mode */
-/* SIOCSIWPMKSA      PMKSA cache operation */
-};
-
-struct iw_handler_def p80211wext_handler_def = {
-	.num_standard = ARRAY_SIZE(p80211wext_handlers),
-	.standard = p80211wext_handlers,
-	.get_wireless_stats = p80211wext_get_wireless_stats
-};
-
-int p80211wext_event_associated(wlandevice_t *wlandev, int assoc)
-{
-	union iwreq_data data;
-
-	/* Send the association state first */
-	data.ap_addr.sa_family = ARPHRD_ETHER;
-	if (assoc)
-		memcpy(data.ap_addr.sa_data, wlandev->bssid, ETH_ALEN);
-	else
-		memset(data.ap_addr.sa_data, 0, ETH_ALEN);
-
-	if (wlan_wext_write)
-		wireless_send_event(wlandev->netdev, SIOCGIWAP, &data, NULL);
-
-	if (!assoc)
-		goto done;
-
-	/* XXX send association data, like IEs, etc etc. */
-
-done:
-	return 0;
-}



^ permalink raw reply

* Re: [stable] [PATCH] ath5k: drop warning on jumbo frames
From: Greg KH @ 2010-06-03 22:09 UTC (permalink / raw)
  To: Luis R. Rodriguez; +Cc: linville, linux-wireless, stable
In-Reply-To: <1273519587-25740-1-git-send-email-lrodriguez@atheros.com>

On Mon, May 10, 2010 at 03:26:27PM -0400, Luis R. Rodriguez wrote:
> Jumbo frames are not supported, and if they are seen it is likely
> a bogus frame so just silently discard them instead of warning on
> them all time. Also, instead of dropping them immediately though
> move the check *after* we check for all sort of frame errors. This
> should enable us to discard these frames if the hardware picks
> other bogus items first. Lets see if we still get those jumbo
> counters increasing still with this.
> 
> Jumbo frames would happen if we tell hardware we can support
> a small 802.11 chunks of DMA'd frame, hardware would split RX'd
> frames into parts and we'd have to reconstruct them in software.
> This is done with USB due to the bulk size but with ath5k we
> already provide a good limit to hardware and this should not be
> happening.
> 
> This is reported quite often and if it fills the logs then this
> needs to be addressed and to avoid spurious reports.
> 
> Cc: stable@kernel.org
> Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
> ---
>  drivers/net/wireless/ath/ath5k/base.c |   12 ++++++------

This is now upstream, but doesn't seem to apply to any of the .32, .33,
or .34 trees.  If you want it there, please send me a backported version
of it.

thanks,

greg k-h

^ permalink raw reply

* Re: [stable] [PATCH 2/2] ath9k: Avoid corrupt frames being forwarded to mac80211.
From: Greg KH @ 2010-06-03 22:17 UTC (permalink / raw)
  To: Vivek Natarajan; +Cc: linville, linux-wireless, stable, Ranga Rao Ravuri
In-Reply-To: <1272353738-17084-2-git-send-email-vnatarajan@atheros.com>

On Tue, Apr 27, 2010 at 01:05:38PM +0530, Vivek Natarajan wrote:
> If bit 29 is set, MAC H/W can attempt to decrypt the received aggregate
> with WEP or TKIP, eventhough the received frame may be a CRC failed
> corrupted frame. If this bit is set, H/W obeys key type in keycache.
> If it is not set and if the key type in keycache is neither open nor
> AES, H/W forces key type to be open.  But bit 29 should be set to 1
> for AsyncFIFO feature to encrypt/decrypt the aggregate with WEP or TKIP. 
> 
> Cc: stable@kernel.org
> Reported-by: Johan Hovold <johan.hovold@lundinova.se>
> Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
> Signed-off-by: Ranga Rao Ravuri <ranga.ravuri@atheros.com>
> ---
>  drivers/net/wireless/ath/ath9k/ar5008_initvals.h |    2 +-
>  drivers/net/wireless/ath/ath9k/ar9002_initvals.h |    8 ++++----

This is now upstream in Linus's tree, but does not apply to the .32,
.32, or .34 kernel trees due to the file movements in this area.  I
tried to apply this by hand, but didn't get it correct.

Can someone please send me a properly backported version of this patch
to apply to the -stable tree?

thanks,

greg k-h

^ permalink raw reply

* Re: [stable] [PATCH] ath5k: drop warning on jumbo frames
From: Luis R. Rodriguez @ 2010-06-03 22:49 UTC (permalink / raw)
  To: Greg KH
  Cc: Luis Rodriguez, linville@tuxdriver.com,
	linux-wireless@vger.kernel.org, stable@kernel.org
In-Reply-To: <20100603220947.GA22595@kroah.com>

On Thu, Jun 03, 2010 at 03:09:47PM -0700, Greg KH wrote:
> On Mon, May 10, 2010 at 03:26:27PM -0400, Luis R. Rodriguez wrote:
> > Jumbo frames are not supported, and if they are seen it is likely
> > a bogus frame so just silently discard them instead of warning on
> > them all time. Also, instead of dropping them immediately though
> > move the check *after* we check for all sort of frame errors. This
> > should enable us to discard these frames if the hardware picks
> > other bogus items first. Lets see if we still get those jumbo
> > counters increasing still with this.
> > 
> > Jumbo frames would happen if we tell hardware we can support
> > a small 802.11 chunks of DMA'd frame, hardware would split RX'd
> > frames into parts and we'd have to reconstruct them in software.
> > This is done with USB due to the bulk size but with ath5k we
> > already provide a good limit to hardware and this should not be
> > happening.
> > 
> > This is reported quite often and if it fills the logs then this
> > needs to be addressed and to avoid spurious reports.
> > 
> > Cc: stable@kernel.org
> > Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
> > ---
> >  drivers/net/wireless/ath/ath5k/base.c |   12 ++++++------
> 
> This is now upstream, but doesn't seem to apply to any of the .32, .33,
> or .34 trees.  If you want it there, please send me a backported version
> of it.

Thanks Greg. I cannot address this right now so I've stashed it here:

http://wireless.kernel.org/en/developers/stable-pending

If anyone has free time please feel free to address the backport and
any other listed above (just one more).

  Luis

^ permalink raw reply

* Re: [PATCH] staging/wlan-ng: Switch from wext to cfg80211
From: Greg KH @ 2010-06-03 22:51 UTC (permalink / raw)
  To: Karl Relton; +Cc: linux-kernel, linux-wireless
In-Reply-To: <1275602646.2005.13.camel@dellpc>

On Thu, Jun 03, 2010 at 11:04:06PM +0100, Karl Relton wrote:
> Switch driver over from wext to cfg80211 interface.

Wow!  Nice job, I'll queue this up in my tree for inclusion in
linux-next after 2.6.35-rc2 comes out.

thanks,

greg k-h

^ permalink raw reply

* Re: [stable] [PATCH 2/2] ath9k: Avoid corrupt frames being forwarded to mac80211.
From: Luis R. Rodriguez @ 2010-06-03 22:52 UTC (permalink / raw)
  To: Greg KH; +Cc: Vivek Natarajan, linville, linux-wireless, stable,
	Ranga Rao Ravuri
In-Reply-To: <20100603221751.GB22595@kroah.com>

On Thu, Jun 3, 2010 at 3:17 PM, Greg KH <greg@kroah.com> wrote:
> On Tue, Apr 27, 2010 at 01:05:38PM +0530, Vivek Natarajan wrote:
>> If bit 29 is set, MAC H/W can attempt to decrypt the received aggregate
>> with WEP or TKIP, eventhough the received frame may be a CRC failed
>> corrupted frame. If this bit is set, H/W obeys key type in keycache.
>> If it is not set and if the key type in keycache is neither open nor
>> AES, H/W forces key type to be open.  But bit 29 should be set to 1
>> for AsyncFIFO feature to encrypt/decrypt the aggregate with WEP or TKIP.
>>
>> Cc: stable@kernel.org
>> Reported-by: Johan Hovold <johan.hovold@lundinova.se>
>> Signed-off-by: Vivek Natarajan <vnatarajan@atheros.com>
>> Signed-off-by: Ranga Rao Ravuri <ranga.ravuri@atheros.com>
>> ---
>>  drivers/net/wireless/ath/ath9k/ar5008_initvals.h |    2 +-
>>  drivers/net/wireless/ath/ath9k/ar9002_initvals.h |    8 ++++----
>
> This is now upstream in Linus's tree, but does not apply to the .32,
> .32, or .34 kernel trees due to the file movements in this area.  I
> tried to apply this by hand, but didn't get it correct.
>
> Can someone please send me a properly backported version of this patch
> to apply to the -stable tree?

I've stashed this here for book keeping:

http://wireless.kernel.org/en/developers/stable-pending

  Luis

^ permalink raw reply

* Power save mode in 2.6.32-22
From: Gordon, Charles @ 2010-06-03 23:27 UTC (permalink / raw)
  To: linux-wireless@vger.kernel.org

Hi,

I'm trying to get power save mode to work in a wireless driver on Linux
2.6.32.  What I'm seeing is that the wireless stack is sending null-data
frames with the power management bit on or off from time to time.  It does
this regardless of whether flags IEEE80211_HW_SUPPORTS_PS and
IEEE80211_HW_SUPPORTS_DYNAMIC_PS are set.  This is not how I would expect
it to work.  If IEEE80211_HW_SUPPORTS_PS is set, I would expect it to let
the driver handle the sending of these frames.  If IEEE80211_HW_SUPPORTS_PS
is not set, then this would indicate that the driver cannot power down, in
which case I still would not expect the stack to be sending these frames. 
The documentation for power save is very thin and it seems the
implementation has changed recently. 

Why is the stack sending these frames when the driver says the H/W does not
support powering down? 

Why is the stack sending these frames when it would seem that the driver
could better handle them? 

The reason why I think the driver can better handle them is that if the
stack sends a frame with the power-mgmt bit set, and then tells the driver
to power down, there will be a race condition where the interface could
receive a frame before the hardware is powered down.  The AP may send such
a frame after it receives the null-data frame because some could be in a
H/W queue.  I have seen this happen.  In this case, the interface H/W on
the station will send an ACK and since the H/W does not know that it is
about to be powered down, that ACK will be sent with the power-mgmt bit
clear, which may confuse the access point.  In short, sending these frames
is something the driver should do since it will know that it should adjust
the H/W so that any ACKs or other control frames will be sent with the
power mgmt bit correctly set until such time as the H/W is actually powered
down.

Anyway, that's my take on it.  As I said, the documentation on power save
doesn't say much and it is not clear to me how it is suppose to work. 
Perhaps someone can provide an explanation.

Thanks for any help you can provide.


^ permalink raw reply

* Re: [PATCH] iwlwifi: use the DMA state API instead of the pci equivalents
From: FUJITA Tomonori @ 2010-06-04  0:15 UTC (permalink / raw)
  To: reinette.chatre; +Cc: fujita.tomonori, yi.zhu, ilw, linux-wireless, linville
In-Reply-To: <1275582441.2091.31678.camel@rchatre-DESK>

On Thu, 03 Jun 2010 09:27:21 -0700
reinette chatre <reinette.chatre@intel.com> wrote:

> On Wed, 2010-06-02 at 22:19 -0700, FUJITA Tomonori wrote:
> > This can be cleanly applied to wireless-2.6 and iwlwifi git trees.
> > 
> > =
> > From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
> > Subject: [PATCH] iwlwifi: use the DMA state API instead of the pci equivalents
> > 
> > This replace the PCI DMA state API (include/linux/pci-dma.h) with the
> > DMA equivalents since the PCI DMA state API will be obsolete.
> 
> Does that mean we need to modify out other PCI DMA calls (eg.
> pci_unmap_single etc.) also?

Yeah, in the long term. PCI DMA API is just the wrapper of DMA API
(all the architectures use include/asm-generic/pci-dma-compat.h) so
you can safely move to DMA API.


> > 
> > No functional change.
> > 
> > For further information about the background:
> > 
> > http://marc.info/?l=linux-netdev&m=127037540020276&w=2
> > 
> > Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
> 
> Thank you
> 
> Acked-by: Reinette Chatre <reinette.chatre@intel.com>

Thanks!

^ permalink raw reply

* Re: Power save mode in 2.6.32-22
From: Christian Lamparter @ 2010-06-04  0:55 UTC (permalink / raw)
  To: Gordon, Charles; +Cc: linux-wireless@vger.kernel.org
In-Reply-To: <8DCC153EAFE67A4B990A840E829F704B017C658D620C@mtk-sms-exch01.digi.com>

On Friday 04 June 2010 01:27:38 Gordon, Charles wrote:
> Hi,
> 
> I'm trying to get power save mode to work in a wireless driver on Linux
> 2.6.32.  What I'm seeing is that the wireless stack is sending null-data
> frames with the power management bit on or off from time to time.  It does
> this regardless of whether flags IEEE80211_HW_SUPPORTS_PS and
> IEEE80211_HW_SUPPORTS_DYNAMIC_PS are set.  This is not how I would expect
> it to work.  If IEEE80211_HW_SUPPORTS_PS is set, I would expect it to let
> the driver handle the sending of these frames.  If IEEE80211_HW_SUPPORTS_PS
> is not set, then this would indicate that the driver cannot power down, in
> which case I still would not expect the stack to be sending these frames. 
> The documentation for power save is very thin and it seems the
> implementation has changed recently. 
> 
> Why is the stack sending these frames when the driver says the H/W does not
> support powering down?

well, could this be a periodic scan / site survey? (perhaps
NM/wicd/wpa_supplicant is running in the background?).

The device signalize the AP that it goes "off-channel" to scan on other
frequencies. Therefore the AP should be prepared to buffer any traffic,
until the STA resumes normal operation.

This can be easily tested with the help of a sniffer,
because you should then get probe requests from the interface.

> Why is the stack sending these frames when it would seem that the driver
> could better handle them?
> 
> The reason why I think the driver can better handle them is that if the
> stack sends a frame with the power-mgmt bit set, and then tells the driver
> to power down, there will be a race condition where the interface could
> receive a frame before the hardware is powered down.  The AP may send such
> a frame after it receives the null-data frame because some could be in a
> H/W queue.  I have seen this happen.  In this case, the interface H/W on
> the station will send an ACK and since the H/W does not know that it is
> about to be powered down, that ACK will be sent with the power-mgmt bit
> clear, which may confuse the access point.

> In short, sending these frames
> is something the driver should do since it will know that it should adjust
> the H/W so that any ACKs or other control frames will be sent with the
> power mgmt bit correctly set until such time as the H/W is actually powered
> down.

quote from: 802.11-2007 "11.2.1 Power management in an infrastructure network"

"A STA shall remain in its current Power Management mode until it informs the AP of
 a Power Management mode change via a frame exchange that includes an acknowledgment
 from the AP. Power Management mode shall not change during any single frame exchange
 sequence as described in 9.12"

The way I read it, it means two things:

Firstly, the STA has to initiate a "frame exchange" in order to
notify the AP about its new power state. (And importantly, that
frame exchange has to succeed, before the STA can actually
go off-channel/sleep! - This is important, because not all
drivers/HW do support an accurate *frame success* report.)

Secondly: The AP should only consider the PSM bit setting,
if the "exchange" was actually initiated by the STA and not
by the AP. (Furthermore, for most control frames timing is
critical. Therefore they have to be implemented in the
hardware/firmware and this makes it nearly impossible to
do what you are describing in your last _quoted_ sentence) 

BTW: have you tried to reproduce your "timing" problem with
a recent compat-wireless?

Regards,
	Chr

^ permalink raw reply

* [patch 4/5] b44: replace the ssb_dma API with the generic DMA API
From: akpm @ 2010-06-04  2:37 UTC (permalink / raw)
  To: linville
  Cc: linux-wireless, akpm, fujita.tomonori, Larry.Finger, davem, mb,
	zambrano

From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>

Note that dma_sync_single_for_device and dma_sync_single_for_cpu support a
partial sync.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Gary Zambrano <zambrano@broadcom.com>
Acked-by: Michael Buesch <mb@bu3sch.de>
Acked-by: David S. Miller <davem@davemloft.net>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 drivers/net/b44.c |  144 +++++++++++++++++++++-----------------------
 1 file changed, 70 insertions(+), 74 deletions(-)

diff -puN drivers/net/b44.c~b44-replace-the-ssb_dma-api-with-the-generic-dma-api drivers/net/b44.c
--- a/drivers/net/b44.c~b44-replace-the-ssb_dma-api-with-the-generic-dma-api
+++ a/drivers/net/b44.c
@@ -150,9 +150,8 @@ static inline void b44_sync_dma_desc_for
 						unsigned long offset,
 						enum dma_data_direction dir)
 {
-	ssb_dma_sync_single_range_for_device(sdev, dma_base,
-					     offset & dma_desc_align_mask,
-					     dma_desc_sync_size, dir);
+	dma_sync_single_for_device(sdev->dma_dev, dma_base + offset,
+				   dma_desc_sync_size, dir);
 }
 
 static inline void b44_sync_dma_desc_for_cpu(struct ssb_device *sdev,
@@ -160,9 +159,8 @@ static inline void b44_sync_dma_desc_for
 					     unsigned long offset,
 					     enum dma_data_direction dir)
 {
-	ssb_dma_sync_single_range_for_cpu(sdev, dma_base,
-					  offset & dma_desc_align_mask,
-					  dma_desc_sync_size, dir);
+	dma_sync_single_for_cpu(sdev->dma_dev, dma_base + offset,
+				dma_desc_sync_size, dir);
 }
 
 static inline unsigned long br32(const struct b44 *bp, unsigned long reg)
@@ -608,10 +606,10 @@ static void b44_tx(struct b44 *bp)
 
 		BUG_ON(skb == NULL);
 
-		ssb_dma_unmap_single(bp->sdev,
-				     rp->mapping,
-				     skb->len,
-				     DMA_TO_DEVICE);
+		dma_unmap_single(bp->sdev->dma_dev,
+				 rp->mapping,
+				 skb->len,
+				 DMA_TO_DEVICE);
 		rp->skb = NULL;
 		dev_kfree_skb_irq(skb);
 	}
@@ -648,29 +646,29 @@ static int b44_alloc_rx_skb(struct b44 *
 	if (skb == NULL)
 		return -ENOMEM;
 
-	mapping = ssb_dma_map_single(bp->sdev, skb->data,
-				     RX_PKT_BUF_SZ,
-				     DMA_FROM_DEVICE);
+	mapping = dma_map_single(bp->sdev->dma_dev, skb->data,
+				 RX_PKT_BUF_SZ,
+				 DMA_FROM_DEVICE);
 
 	/* Hardware bug work-around, the chip is unable to do PCI DMA
 	   to/from anything above 1GB :-( */
-	if (ssb_dma_mapping_error(bp->sdev, mapping) ||
+	if (dma_mapping_error(bp->sdev->dma_dev, mapping) ||
 		mapping + RX_PKT_BUF_SZ > DMA_BIT_MASK(30)) {
 		/* Sigh... */
-		if (!ssb_dma_mapping_error(bp->sdev, mapping))
-			ssb_dma_unmap_single(bp->sdev, mapping,
+		if (!dma_mapping_error(bp->sdev->dma_dev, mapping))
+			dma_unmap_single(bp->sdev->dma_dev, mapping,
 					     RX_PKT_BUF_SZ, DMA_FROM_DEVICE);
 		dev_kfree_skb_any(skb);
 		skb = __netdev_alloc_skb(bp->dev, RX_PKT_BUF_SZ, GFP_ATOMIC|GFP_DMA);
 		if (skb == NULL)
 			return -ENOMEM;
-		mapping = ssb_dma_map_single(bp->sdev, skb->data,
-					     RX_PKT_BUF_SZ,
-					     DMA_FROM_DEVICE);
-		if (ssb_dma_mapping_error(bp->sdev, mapping) ||
-			mapping + RX_PKT_BUF_SZ > DMA_BIT_MASK(30)) {
-			if (!ssb_dma_mapping_error(bp->sdev, mapping))
-				ssb_dma_unmap_single(bp->sdev, mapping, RX_PKT_BUF_SZ,DMA_FROM_DEVICE);
+		mapping = dma_map_single(bp->sdev->dma_dev, skb->data,
+					 RX_PKT_BUF_SZ,
+					 DMA_FROM_DEVICE);
+		if (dma_mapping_error(bp->sdev->dma_dev, mapping) ||
+		    mapping + RX_PKT_BUF_SZ > DMA_BIT_MASK(30)) {
+			if (!dma_mapping_error(bp->sdev->dma_dev, mapping))
+				dma_unmap_single(bp->sdev->dma_dev, mapping, RX_PKT_BUF_SZ,DMA_FROM_DEVICE);
 			dev_kfree_skb_any(skb);
 			return -ENOMEM;
 		}
@@ -745,9 +743,9 @@ static void b44_recycle_rx(struct b44 *b
 					     dest_idx * sizeof(*dest_desc),
 					     DMA_BIDIRECTIONAL);
 
-	ssb_dma_sync_single_for_device(bp->sdev, dest_map->mapping,
-				       RX_PKT_BUF_SZ,
-				       DMA_FROM_DEVICE);
+	dma_sync_single_for_device(bp->sdev->dma_dev, dest_map->mapping,
+				   RX_PKT_BUF_SZ,
+				   DMA_FROM_DEVICE);
 }
 
 static int b44_rx(struct b44 *bp, int budget)
@@ -767,9 +765,9 @@ static int b44_rx(struct b44 *bp, int bu
 		struct rx_header *rh;
 		u16 len;
 
-		ssb_dma_sync_single_for_cpu(bp->sdev, map,
-					    RX_PKT_BUF_SZ,
-					    DMA_FROM_DEVICE);
+		dma_sync_single_for_cpu(bp->sdev->dma_dev, map,
+					RX_PKT_BUF_SZ,
+					DMA_FROM_DEVICE);
 		rh = (struct rx_header *) skb->data;
 		len = le16_to_cpu(rh->len);
 		if ((len > (RX_PKT_BUF_SZ - RX_PKT_OFFSET)) ||
@@ -801,8 +799,8 @@ static int b44_rx(struct b44 *bp, int bu
 			skb_size = b44_alloc_rx_skb(bp, cons, bp->rx_prod);
 			if (skb_size < 0)
 				goto drop_it;
-			ssb_dma_unmap_single(bp->sdev, map,
-					     skb_size, DMA_FROM_DEVICE);
+			dma_unmap_single(bp->sdev->dma_dev, map,
+					 skb_size, DMA_FROM_DEVICE);
 			/* Leave out rx_header */
 			skb_put(skb, len + RX_PKT_OFFSET);
 			skb_pull(skb, RX_PKT_OFFSET);
@@ -954,24 +952,24 @@ static netdev_tx_t b44_start_xmit(struct
 		goto err_out;
 	}
 
-	mapping = ssb_dma_map_single(bp->sdev, skb->data, len, DMA_TO_DEVICE);
-	if (ssb_dma_mapping_error(bp->sdev, mapping) || mapping + len > DMA_BIT_MASK(30)) {
+	mapping = dma_map_single(bp->sdev->dma_dev, skb->data, len, DMA_TO_DEVICE);
+	if (dma_mapping_error(bp->sdev->dma_dev, mapping) || mapping + len > DMA_BIT_MASK(30)) {
 		struct sk_buff *bounce_skb;
 
 		/* Chip can't handle DMA to/from >1GB, use bounce buffer */
-		if (!ssb_dma_mapping_error(bp->sdev, mapping))
-			ssb_dma_unmap_single(bp->sdev, mapping, len,
+		if (!dma_mapping_error(bp->sdev->dma_dev, mapping))
+			dma_unmap_single(bp->sdev->dma_dev, mapping, len,
 					     DMA_TO_DEVICE);
 
 		bounce_skb = __netdev_alloc_skb(dev, len, GFP_ATOMIC | GFP_DMA);
 		if (!bounce_skb)
 			goto err_out;
 
-		mapping = ssb_dma_map_single(bp->sdev, bounce_skb->data,
-					     len, DMA_TO_DEVICE);
-		if (ssb_dma_mapping_error(bp->sdev, mapping) || mapping + len > DMA_BIT_MASK(30)) {
-			if (!ssb_dma_mapping_error(bp->sdev, mapping))
-				ssb_dma_unmap_single(bp->sdev, mapping,
+		mapping = dma_map_single(bp->sdev->dma_dev, bounce_skb->data,
+					 len, DMA_TO_DEVICE);
+		if (dma_mapping_error(bp->sdev->dma_dev, mapping) || mapping + len > DMA_BIT_MASK(30)) {
+			if (!dma_mapping_error(bp->sdev->dma_dev, mapping))
+				dma_unmap_single(bp->sdev->dma_dev, mapping,
 						     len, DMA_TO_DEVICE);
 			dev_kfree_skb_any(bounce_skb);
 			goto err_out;
@@ -1068,8 +1066,8 @@ static void b44_free_rings(struct b44 *b
 
 		if (rp->skb == NULL)
 			continue;
-		ssb_dma_unmap_single(bp->sdev, rp->mapping, RX_PKT_BUF_SZ,
-				     DMA_FROM_DEVICE);
+		dma_unmap_single(bp->sdev->dma_dev, rp->mapping, RX_PKT_BUF_SZ,
+				 DMA_FROM_DEVICE);
 		dev_kfree_skb_any(rp->skb);
 		rp->skb = NULL;
 	}
@@ -1080,8 +1078,8 @@ static void b44_free_rings(struct b44 *b
 
 		if (rp->skb == NULL)
 			continue;
-		ssb_dma_unmap_single(bp->sdev, rp->mapping, rp->skb->len,
-				     DMA_TO_DEVICE);
+		dma_unmap_single(bp->sdev->dma_dev, rp->mapping, rp->skb->len,
+				 DMA_TO_DEVICE);
 		dev_kfree_skb_any(rp->skb);
 		rp->skb = NULL;
 	}
@@ -1103,14 +1101,12 @@ static void b44_init_rings(struct b44 *b
 	memset(bp->tx_ring, 0, B44_TX_RING_BYTES);
 
 	if (bp->flags & B44_FLAG_RX_RING_HACK)
-		ssb_dma_sync_single_for_device(bp->sdev, bp->rx_ring_dma,
-					       DMA_TABLE_BYTES,
-					       DMA_BIDIRECTIONAL);
+		dma_sync_single_for_device(bp->sdev->dma_dev, bp->rx_ring_dma,
+					   DMA_TABLE_BYTES, DMA_BIDIRECTIONAL);
 
 	if (bp->flags & B44_FLAG_TX_RING_HACK)
-		ssb_dma_sync_single_for_device(bp->sdev, bp->tx_ring_dma,
-					       DMA_TABLE_BYTES,
-					       DMA_TO_DEVICE);
+		dma_sync_single_for_device(bp->sdev->dma_dev, bp->tx_ring_dma,
+					   DMA_TABLE_BYTES, DMA_TO_DEVICE);
 
 	for (i = 0; i < bp->rx_pending; i++) {
 		if (b44_alloc_rx_skb(bp, -1, i) < 0)
@@ -1130,27 +1126,23 @@ static void b44_free_consistent(struct b
 	bp->tx_buffers = NULL;
 	if (bp->rx_ring) {
 		if (bp->flags & B44_FLAG_RX_RING_HACK) {
-			ssb_dma_unmap_single(bp->sdev, bp->rx_ring_dma,
-					     DMA_TABLE_BYTES,
-					     DMA_BIDIRECTIONAL);
+			dma_unmap_single(bp->sdev->dma_dev, bp->rx_ring_dma,
+					 DMA_TABLE_BYTES, DMA_BIDIRECTIONAL);
 			kfree(bp->rx_ring);
 		} else
-			ssb_dma_free_consistent(bp->sdev, DMA_TABLE_BYTES,
-						bp->rx_ring, bp->rx_ring_dma,
-						GFP_KERNEL);
+			dma_free_coherent(bp->sdev->dma_dev, DMA_TABLE_BYTES,
+					  bp->rx_ring, bp->rx_ring_dma);
 		bp->rx_ring = NULL;
 		bp->flags &= ~B44_FLAG_RX_RING_HACK;
 	}
 	if (bp->tx_ring) {
 		if (bp->flags & B44_FLAG_TX_RING_HACK) {
-			ssb_dma_unmap_single(bp->sdev, bp->tx_ring_dma,
-					     DMA_TABLE_BYTES,
-					     DMA_TO_DEVICE);
+			dma_unmap_single(bp->sdev->dma_dev, bp->tx_ring_dma,
+					 DMA_TABLE_BYTES, DMA_TO_DEVICE);
 			kfree(bp->tx_ring);
 		} else
-			ssb_dma_free_consistent(bp->sdev, DMA_TABLE_BYTES,
-						bp->tx_ring, bp->tx_ring_dma,
-						GFP_KERNEL);
+			dma_free_coherent(bp->sdev->dma_dev, DMA_TABLE_BYTES,
+					  bp->tx_ring, bp->tx_ring_dma);
 		bp->tx_ring = NULL;
 		bp->flags &= ~B44_FLAG_TX_RING_HACK;
 	}
@@ -1175,7 +1167,8 @@ static int b44_alloc_consistent(struct b
 		goto out_err;
 
 	size = DMA_TABLE_BYTES;
-	bp->rx_ring = ssb_dma_alloc_consistent(bp->sdev, size, &bp->rx_ring_dma, gfp);
+	bp->rx_ring = dma_alloc_coherent(bp->sdev->dma_dev, size,
+					 &bp->rx_ring_dma, gfp);
 	if (!bp->rx_ring) {
 		/* Allocation may have failed due to pci_alloc_consistent
 		   insisting on use of GFP_DMA, which is more restrictive
@@ -1187,11 +1180,11 @@ static int b44_alloc_consistent(struct b
 		if (!rx_ring)
 			goto out_err;
 
-		rx_ring_dma = ssb_dma_map_single(bp->sdev, rx_ring,
-						 DMA_TABLE_BYTES,
-						 DMA_BIDIRECTIONAL);
+		rx_ring_dma = dma_map_single(bp->sdev->dma_dev, rx_ring,
+					     DMA_TABLE_BYTES,
+					     DMA_BIDIRECTIONAL);
 
-		if (ssb_dma_mapping_error(bp->sdev, rx_ring_dma) ||
+		if (dma_mapping_error(bp->sdev->dma_dev, rx_ring_dma) ||
 			rx_ring_dma + size > DMA_BIT_MASK(30)) {
 			kfree(rx_ring);
 			goto out_err;
@@ -1202,7 +1195,8 @@ static int b44_alloc_consistent(struct b
 		bp->flags |= B44_FLAG_RX_RING_HACK;
 	}
 
-	bp->tx_ring = ssb_dma_alloc_consistent(bp->sdev, size, &bp->tx_ring_dma, gfp);
+	bp->tx_ring = dma_alloc_coherent(bp->sdev->dma_dev, size,
+					 &bp->tx_ring_dma, gfp);
 	if (!bp->tx_ring) {
 		/* Allocation may have failed due to ssb_dma_alloc_consistent
 		   insisting on use of GFP_DMA, which is more restrictive
@@ -1214,11 +1208,11 @@ static int b44_alloc_consistent(struct b
 		if (!tx_ring)
 			goto out_err;
 
-		tx_ring_dma = ssb_dma_map_single(bp->sdev, tx_ring,
-			                    DMA_TABLE_BYTES,
-			                    DMA_TO_DEVICE);
+		tx_ring_dma = dma_map_single(bp->sdev->dma_dev, tx_ring,
+					     DMA_TABLE_BYTES,
+					     DMA_TO_DEVICE);
 
-		if (ssb_dma_mapping_error(bp->sdev, tx_ring_dma) ||
+		if (dma_mapping_error(bp->sdev->dma_dev, tx_ring_dma) ||
 			tx_ring_dma + size > DMA_BIT_MASK(30)) {
 			kfree(tx_ring);
 			goto out_err;
@@ -2176,12 +2170,14 @@ static int __devinit b44_init_one(struct
 			"Failed to powerup the bus\n");
 		goto err_out_free_dev;
 	}
-	err = ssb_dma_set_mask(sdev, DMA_BIT_MASK(30));
-	if (err) {
+
+	if (dma_set_mask(sdev->dma_dev, DMA_BIT_MASK(30)) ||
+	    dma_set_coherent_mask(sdev->dma_dev, DMA_BIT_MASK(30))) {
 		dev_err(sdev->dev,
 			"Required 30BIT DMA mask unsupported by the system\n");
 		goto err_out_powerdown;
 	}
+
 	err = b44_get_invariants(bp);
 	if (err) {
 		dev_err(sdev->dev,
_

^ permalink raw reply

* [patch 5/5] ssb: remove the ssb DMA API
From: akpm @ 2010-06-04  2:37 UTC (permalink / raw)
  To: linville
  Cc: linux-wireless, akpm, fujita.tomonori, Larry.Finger, davem, mb,
	stefano.brivio, zambrano

From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>

Now they are unnecessary.  We can use the generic DMA API with any bus.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Michael Buesch <mb@bu3sch.de>
Cc: Gary Zambrano <zambrano@broadcom.com>
Cc: Stefano Brivio <stefano.brivio@polimi.it>
Cc: Larry Finger <Larry.Finger@lwfinger.net>
Cc: John W. Linville <linville@tuxdriver.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 drivers/ssb/main.c      |   74 -----------------
 include/linux/ssb/ssb.h |  157 --------------------------------------
 2 files changed, 231 deletions(-)

diff -puN drivers/ssb/main.c~ssb-remove-the-ssb-dma-api drivers/ssb/main.c
--- a/drivers/ssb/main.c~ssb-remove-the-ssb-dma-api
+++ a/drivers/ssb/main.c
@@ -1228,80 +1228,6 @@ u32 ssb_dma_translation(struct ssb_devic
 }
 EXPORT_SYMBOL(ssb_dma_translation);
 
-int ssb_dma_set_mask(struct ssb_device *dev, u64 mask)
-{
-#ifdef CONFIG_SSB_PCIHOST
-	int err;
-#endif
-
-	switch (dev->bus->bustype) {
-	case SSB_BUSTYPE_PCI:
-#ifdef CONFIG_SSB_PCIHOST
-		err = pci_set_dma_mask(dev->bus->host_pci, mask);
-		if (err)
-			return err;
-		err = pci_set_consistent_dma_mask(dev->bus->host_pci, mask);
-		return err;
-#endif
-	case SSB_BUSTYPE_SSB:
-		return dma_set_mask(dev->dev, mask);
-	default:
-		__ssb_dma_not_implemented(dev);
-	}
-	return -ENOSYS;
-}
-EXPORT_SYMBOL(ssb_dma_set_mask);
-
-void * ssb_dma_alloc_consistent(struct ssb_device *dev, size_t size,
-				dma_addr_t *dma_handle, gfp_t gfp_flags)
-{
-	switch (dev->bus->bustype) {
-	case SSB_BUSTYPE_PCI:
-#ifdef CONFIG_SSB_PCIHOST
-		if (gfp_flags & GFP_DMA) {
-			/* Workaround: The PCI API does not support passing
-			 * a GFP flag. */
-			return dma_alloc_coherent(&dev->bus->host_pci->dev,
-						  size, dma_handle, gfp_flags);
-		}
-		return pci_alloc_consistent(dev->bus->host_pci, size, dma_handle);
-#endif
-	case SSB_BUSTYPE_SSB:
-		return dma_alloc_coherent(dev->dev, size, dma_handle, gfp_flags);
-	default:
-		__ssb_dma_not_implemented(dev);
-	}
-	return NULL;
-}
-EXPORT_SYMBOL(ssb_dma_alloc_consistent);
-
-void ssb_dma_free_consistent(struct ssb_device *dev, size_t size,
-			     void *vaddr, dma_addr_t dma_handle,
-			     gfp_t gfp_flags)
-{
-	switch (dev->bus->bustype) {
-	case SSB_BUSTYPE_PCI:
-#ifdef CONFIG_SSB_PCIHOST
-		if (gfp_flags & GFP_DMA) {
-			/* Workaround: The PCI API does not support passing
-			 * a GFP flag. */
-			dma_free_coherent(&dev->bus->host_pci->dev,
-					  size, vaddr, dma_handle);
-			return;
-		}
-		pci_free_consistent(dev->bus->host_pci, size,
-				    vaddr, dma_handle);
-		return;
-#endif
-	case SSB_BUSTYPE_SSB:
-		dma_free_coherent(dev->dev, size, vaddr, dma_handle);
-		return;
-	default:
-		__ssb_dma_not_implemented(dev);
-	}
-}
-EXPORT_SYMBOL(ssb_dma_free_consistent);
-
 int ssb_bus_may_powerdown(struct ssb_bus *bus)
 {
 	struct ssb_chipcommon *cc;
diff -puN include/linux/ssb/ssb.h~ssb-remove-the-ssb-dma-api include/linux/ssb/ssb.h
--- a/include/linux/ssb/ssb.h~ssb-remove-the-ssb-dma-api
+++ a/include/linux/ssb/ssb.h
@@ -470,14 +470,6 @@ extern u32 ssb_dma_translation(struct ss
 #define SSB_DMA_TRANSLATION_MASK	0xC0000000
 #define SSB_DMA_TRANSLATION_SHIFT	30
 
-extern int ssb_dma_set_mask(struct ssb_device *dev, u64 mask);
-
-extern void * ssb_dma_alloc_consistent(struct ssb_device *dev, size_t size,
-				       dma_addr_t *dma_handle, gfp_t gfp_flags);
-extern void ssb_dma_free_consistent(struct ssb_device *dev, size_t size,
-				    void *vaddr, dma_addr_t dma_handle,
-				    gfp_t gfp_flags);
-
 static inline void __cold __ssb_dma_not_implemented(struct ssb_device *dev)
 {
 #ifdef CONFIG_SSB_DEBUG
@@ -486,155 +478,6 @@ static inline void __cold __ssb_dma_not_
 #endif /* DEBUG */
 }
 
-static inline int ssb_dma_mapping_error(struct ssb_device *dev, dma_addr_t addr)
-{
-	switch (dev->bus->bustype) {
-	case SSB_BUSTYPE_PCI:
-#ifdef CONFIG_SSB_PCIHOST
-		return pci_dma_mapping_error(dev->bus->host_pci, addr);
-#endif
-		break;
-	case SSB_BUSTYPE_SSB:
-		return dma_mapping_error(dev->dev, addr);
-	default:
-		break;
-	}
-	__ssb_dma_not_implemented(dev);
-	return -ENOSYS;
-}
-
-static inline dma_addr_t ssb_dma_map_single(struct ssb_device *dev, void *p,
-					    size_t size, enum dma_data_direction dir)
-{
-	switch (dev->bus->bustype) {
-	case SSB_BUSTYPE_PCI:
-#ifdef CONFIG_SSB_PCIHOST
-		return pci_map_single(dev->bus->host_pci, p, size, dir);
-#endif
-		break;
-	case SSB_BUSTYPE_SSB:
-		return dma_map_single(dev->dev, p, size, dir);
-	default:
-		break;
-	}
-	__ssb_dma_not_implemented(dev);
-	return 0;
-}
-
-static inline void ssb_dma_unmap_single(struct ssb_device *dev, dma_addr_t dma_addr,
-					size_t size, enum dma_data_direction dir)
-{
-	switch (dev->bus->bustype) {
-	case SSB_BUSTYPE_PCI:
-#ifdef CONFIG_SSB_PCIHOST
-		pci_unmap_single(dev->bus->host_pci, dma_addr, size, dir);
-		return;
-#endif
-		break;
-	case SSB_BUSTYPE_SSB:
-		dma_unmap_single(dev->dev, dma_addr, size, dir);
-		return;
-	default:
-		break;
-	}
-	__ssb_dma_not_implemented(dev);
-}
-
-static inline void ssb_dma_sync_single_for_cpu(struct ssb_device *dev,
-					       dma_addr_t dma_addr,
-					       size_t size,
-					       enum dma_data_direction dir)
-{
-	switch (dev->bus->bustype) {
-	case SSB_BUSTYPE_PCI:
-#ifdef CONFIG_SSB_PCIHOST
-		pci_dma_sync_single_for_cpu(dev->bus->host_pci, dma_addr,
-					    size, dir);
-		return;
-#endif
-		break;
-	case SSB_BUSTYPE_SSB:
-		dma_sync_single_for_cpu(dev->dev, dma_addr, size, dir);
-		return;
-	default:
-		break;
-	}
-	__ssb_dma_not_implemented(dev);
-}
-
-static inline void ssb_dma_sync_single_for_device(struct ssb_device *dev,
-						  dma_addr_t dma_addr,
-						  size_t size,
-						  enum dma_data_direction dir)
-{
-	switch (dev->bus->bustype) {
-	case SSB_BUSTYPE_PCI:
-#ifdef CONFIG_SSB_PCIHOST
-		pci_dma_sync_single_for_device(dev->bus->host_pci, dma_addr,
-					       size, dir);
-		return;
-#endif
-		break;
-	case SSB_BUSTYPE_SSB:
-		dma_sync_single_for_device(dev->dev, dma_addr, size, dir);
-		return;
-	default:
-		break;
-	}
-	__ssb_dma_not_implemented(dev);
-}
-
-static inline void ssb_dma_sync_single_range_for_cpu(struct ssb_device *dev,
-						     dma_addr_t dma_addr,
-						     unsigned long offset,
-						     size_t size,
-						     enum dma_data_direction dir)
-{
-	switch (dev->bus->bustype) {
-	case SSB_BUSTYPE_PCI:
-#ifdef CONFIG_SSB_PCIHOST
-		/* Just sync everything. That's all the PCI API can do. */
-		pci_dma_sync_single_for_cpu(dev->bus->host_pci, dma_addr,
-					    offset + size, dir);
-		return;
-#endif
-		break;
-	case SSB_BUSTYPE_SSB:
-		dma_sync_single_range_for_cpu(dev->dev, dma_addr, offset,
-					      size, dir);
-		return;
-	default:
-		break;
-	}
-	__ssb_dma_not_implemented(dev);
-}
-
-static inline void ssb_dma_sync_single_range_for_device(struct ssb_device *dev,
-							dma_addr_t dma_addr,
-							unsigned long offset,
-							size_t size,
-							enum dma_data_direction dir)
-{
-	switch (dev->bus->bustype) {
-	case SSB_BUSTYPE_PCI:
-#ifdef CONFIG_SSB_PCIHOST
-		/* Just sync everything. That's all the PCI API can do. */
-		pci_dma_sync_single_for_device(dev->bus->host_pci, dma_addr,
-					       offset + size, dir);
-		return;
-#endif
-		break;
-	case SSB_BUSTYPE_SSB:
-		dma_sync_single_range_for_device(dev->dev, dma_addr, offset,
-						 size, dir);
-		return;
-	default:
-		break;
-	}
-	__ssb_dma_not_implemented(dev);
-}
-
-
 #ifdef CONFIG_SSB_PCIHOST
 /* PCI-host wrapper driver */
 extern int ssb_pcihost_register(struct pci_driver *driver);
_

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox