# Dell D830 Broadcom 432AGN WiFi mini PCI-Express



## Seeker (Dec 9, 2009)

```
hdr=0x00
    vendor     = 'Broadcom Corporation'
    device     = 'Broadcom 432AGN 802.11a/b/g/draft-n Wi-Fi Solution (BCM4321KFBG)'
    class      = network
    bar   [10] = type Memory, range 64, base 0xf1ffc000, size 16384, enabled
    bar   [18] = type Prefetchable Memory, range 64, base 0xf0000000, size 1048576, enabled
    cap 01[40] = powerspec 2  supports D0 D1 D2 D3  current D0
    cap 09[58] = vendor (length 120)
    cap 05[e8] = MSI supports 1 message, 64 bit
    cap 10[d0] = PCI-Express 1 endpoint max data 128(128) link x1(x1)
```
I have 8.0 STABLE with GENERIC kernel(built today), but there is no if_bwi.ko in /boot/modules, which I could load with kldload

I have also installed bwi-firmware-kmod-3.130.20
Now I have /boot/modules/bwi_v3_ucode.ko

```
# kldload bwi_v3_ucode

# cd /usr/src/sys/modules/bwi
# make
# make install
# make clean
```

Now modules are located here:
_/boot/kernel/if_bwi.ko
/boot/modules/bwi_v3_ucode.ko_

I've added _if_bwi_load="YES"_, in loader.conf

And after a reboot

```
# kldstat
Id Refs Address    Size     Name
 1   10 0xc0400000 b77ebc   kernel
 2    1 0xc0f78000 1ddc0    if_bwi.ko
 3    1 0xc7823000 e000     fuse.ko
 4    1 0xc78e6000 35000    pf.ko
```

Now...

```
# kldload bwi_v3_ucode
```

... _and_ *NADA!*
_
PS: Please, don't mention ndis._


----------



## richardpl (Dec 9, 2009)

I want to mention NDISulator aka The Project Evil.


----------



## Seeker (Dec 10, 2009)

richardpl said:
			
		

> I want to mention NDISulator aka The Project Evil.



Of 6 WinXP drivers, for that WiFi adapter, using ndisgen, only *1* _barely_ worked under 7.2
Now under 8.0 STABLE, even that *1* stopped to work.

At boot time, it makes kernel, constantly, into panic! (with other 5 too)
Duh!
I am so frustrated with hardware support.


----------



## richardpl (Dec 10, 2009)

Please post bt from crashdump or from kdb prompt. If you do not know what I'm talking about, please read very short FreeBSD handbook for developers.

For start is /var/crash/ empty?

How do you do expect bugs get fixed if users never reports them?


----------



## Seeker (Dec 10, 2009)

I know, what you are talking about.
I did that many times. 

I will do that when I come home.
I need to build latest driver again, with ndisgen and make it crash.

It is not, that I am not wiling to report a problem, but I'm, waiting for if_bwi driver.


----------



## richardpl (Dec 10, 2009)

if_bwi(4) doesnt have support for that chip.
Just look into *64 functions.
There is another driver currently in development but for broadcom cards with newer firmware.


----------



## Seeker (Dec 11, 2009)

Ok, I've succeeded, with oldest working driver, from last year.
So..., at start debugging wpa_supplicant:

```
Trying to get current scan results first without requesting a new scan to speed up initial association
Cached scan results are empty - not posting
Selecting BSS from priority group 0
Try to find WPA-enabled AP
Try to find non-WPA AP
No suitable AP found.
Setting scan request: 0 sec 0 usec
Starting AP scan (broadcast SSID)
NDIS: Set OID 0d01011a - hexdump(len=4): [REMOVED]
ndis_get_oid: oid=0xd010101 len (6) failed
EAPOL: disable timer tick
[B][color="DarkRed"]ndis_get_oid: oid=0xd010101 len (6) failed
ndis_get_oid: oid=0xd010101 len (6) failed
ndis_get_oid: oid=0xd010101 len (6) failed
ndis_get_oid: oid=0xd010101 len (6) failed
ndis_get_oid: oid=0xd010101 len (6) failed[/color][/B]
Scan timeout - try to get results
CTRL-EVENT-SCAN-RESULTS
Selecting BSS from priority group 0
Try to find WPA-enabled AP
Try to find non-WPA AP
No suitable AP found.
Setting scan request: 5 sec 0 usec
[B][color="DarkRed"]ndis_get_oid: oid=0xd010101 len (6) failed
....[/color][/B]
```
Looks like ndis's scan is blind.

I added this in wpa_supplicant.conf

```
scan_ssid=1
```

Now..., loop above will end up, in successful connection.
But then, connection breaks very shortly and even ping is not possible:

```
: EAPOL-Key Replay Counter did not increase - dropping packet
RX EAPOL from 00:0e:2e:e5:0b:b9
RX EAPOL - hexdump(len=99): 02 03 00 5f 02 00 8a 00 10 00 00 00 00 00 00 00 04 c
b f0 72 9f 20 f2 08 ed a1 8a 3c a7 b9 c0 8b d2 53 14 f1 e7 4e 9c 24 c2 d4 61 8e
38 4c 96 08 c9 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0
0 00
IEEE 802.1X RX: version=2 type=3 length=95
  EAPOL-Key type=2
  key_info 0x8a (ver=2 keyidx=0 rsvd=0 Pairwise Ack)
  key_length=16 key_data_length=0
  replay_counter - hexdump(len=8): 00 00 00 00 00 00 00 04
  key_nonce - hexdump(len=32): cb f0 72 9f 20 f2 08 ed a1 8a 3c a7 b9 c0 8b d2 5
3 14 f1 e7 4e 9c 24 c2 d4 61 8e 38 4c 96 08 c9
  key_iv - hexdump(len=16): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  key_rsc - hexdump(len=8): 00 00 00 00 00 00 00 00
  key_id (reserved) - hexdump(len=8): 00 00 00 00 00 00 00 00
  key_mic - hexdump(len=16): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
WPA: RX EAPOL-Key - hexdump(len=99): 02 03 00 5f 02 00 8a 00 10 00 00 00 00 00 0
0 00 04 cb f0 72 9f 20 f2 08 ed a1 8a 3c a7 b9 c0 8b d2 53 14 f1 e7 4e 9c 24 c2
d4 61 8e 38 4c 96 08 c9 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0
0 00 00 00 00
[B][color="DarkRed"]WPA: EAPOL-Key Replay Counter did not increase - dropping packet[/color][/B]
```
And this message is constantly looping

Then I kill:

```
Association info event
req_ies - hexdump(len=76): 00 09 42 4c 41 43 4b 48 4f 4c 45 01 08 82 84 8b 96 24
 30 48 6c 21 02 08 12 24 02 01 0e 30 14 01 00 00 0f ac 04 01 00 00 0f ac 04 01 0
0 00 0f ac 02 00 00 32 04 0c 12 18 60 dd 09 00 10 18 02 00 10 01 00 00 dd 06 00
40 96 01 01 00
resp_ies - hexdump(len=16): 01 08 82 84 8b 0c 12 96 18 24 32 04 30 48 60 6c
beacon_ies - hexdump(len=69): 00 09 42 4c 41 43 4b 48 4f 4c 45 01 08 82 84 8b 96
 0c 12 18 24 03 01 06 05 04 00 01 00 00 07 06 48 52 20 01 0b 1e 2a 01 00 32 04 3
0 48 60 6c 30 14 01 00 00 0f ac eloop: could not process SIGINT or SIGTERM in tw
o seconds. Looks like there
is a bug that ends up in a busy loop that prevents clean shutdown.
Killing program forcefully.
```

PS:

```
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/sys/dev/if_ndis/if_ndis.c,v [B][color="DarkRed"]1.166.2.2[/color][/B] 2009/10/06 16:05:06 cokane Exp $");
```


----------



## richardpl (Dec 12, 2009)

```
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/sys/dev/if_ndis/if_ndis.c,v [B][color="DarkRed"]1.166.2.2[/color][/B] 2009/10/06 16:05:06 cokane Exp $");
```
Irrelevant, if_ndis.c code is not used with wpa_supplicant's *ndis* driver.

Try ndis_events(8).


----------



## Seeker (Dec 12, 2009)

richardpl said:
			
		

> ```
> #include <sys/cdefs.h>
> __FBSDID("$FreeBSD: src/sys/dev/if_ndis/if_ndis.c,v [B][color="DarkRed"]1.166.2.2[/color][/B] 2009/10/06 16:05:06 cokane Exp $");
> ```
> ...



It is, as I've figured out that:

```
# ifconfig wlan0 scan
```
Does not work.
It just hangs and results are never being displayed.
Even I am surrounded with _ssids_


----------



## richardpl (Dec 12, 2009)

You should use *list scan*
There is some problems with net80211, if_ndis will send scan results
but net80211 will ignore them:
try `# sysctl debug.ndis=1` you will see scan results on console.

Again, *wpa_supplicant -Dndis* ignore almost everything from if_ndis.c it only use ndisapi (/sys/compat/ndis).

Anyway I still need bt from crashdump of newer drivers.

How do you expect bugs can get fixed if newer reported, correctly ...

Did you tried ndis_events(8)?


----------



## Seeker (Dec 13, 2009)

richardpl said:
			
		

> You should use *list scan*
> There is some problems with net80211, if_ndis will send scan results
> but net80211 will ignore them:
> try `# sysctl debug.ndis=1` you will see scan results on console.



As soon as I did:

```
# sysctl debug.ndis=1
```
I started to get this on a console:

```
...
ndis_scan_results: 0 results
ndis_scan_results: 0 results
ndis_scan_results: 0 results
ndis_scan_results: 0 results
ndis_scan_results: 0 results
ndis_scan_results: 0 results
ndis_scan_results: 0 results
ndis_scan_results: 0 results
ndis_scan_results: 0 results
...
```

PS: *list scan* and *scan* alone, did nothing!



			
				richardpl said:
			
		

> Again, *wpa_supplicant -Dndis* ignore almost everything from if_ndis.c it only use ndisapi (/sys/compat/ndis).
> 
> Anyway I still need bt from crashdump of newer drivers.
> 
> ...




```
# ndis_events -d
```
echoed nothing, bur then again, this time I didn't used wpa_supplicant.

First step is to scan ssids and get results, then to connect to non protected wifi network.
*When* I get ndis working with this old driver, *then* I will use latest drivers that crashes server.
We will go step by step.


----------



## richardpl (Dec 13, 2009)

Point of ndis_events is to start it when you start wpa_supplicant. So then EAP can actually work. (for explanation read code ...)

Maybe radio is turned off, so scan doesnt work?
Try to change ssid via ifconfig(8)


----------



## Seeker (Dec 14, 2009)

First step, is to get a scan actually and connect to an unprotected WiFi AP.
So...

Radio was off, I did turned it on and nothing.

```
# sysctl dev.ndis.0.RadioState=1
```


```
# sysctl debug.ndis=1
```
Continued to give:

```
...
ndis_scan_results: 0 results
ndis_scan_results: 0 results
...
```
both *scan* and *list scan* have not worked...


Finally this is a list of all posible sysctl settings for ndis0:

```
dev.ndis.0.%desc: Dell Wireless 1500 Draft 802.11n WLAN Mini-Card
dev.ndis.0.%driver: ndis
dev.ndis.0.%location: slot=0 function=0 handle=\_SB_.PCI0.RP02.PXS2
dev.ndis.0.%pnpinfo: vendor=0x14e4 device=0x4328 subvendor=0x1028 subdevice=0x000a class=0x028000
dev.ndis.0.%parent: pci12
dev.ndis.0.LOM: 0
dev.ndis.0.RoamDelta: 1
dev.ndis.0.MPC: 1
dev.ndis.0.PLCPHeader: 0
dev.ndis.0.frag: 2346
dev.ndis.0.rts: 2347
dev.ndis.0.NetworkAddress: 
dev.ndis.0.antdiv: -1
dev.ndis.0.FrameBursting: 0
dev.ndis.0.Afterburner: 0
dev.ndis.0.WakeUpCapabilities: 3
dev.ndis.0.WowlKeyRot: 1
dev.ndis.0.ledbh0: -1
dev.ndis.0.ledbh1: -1
dev.ndis.0.ledbh2: -1
dev.ndis.0.ledbh3: -1
dev.ndis.0.leddc: 0xa0000
dev.ndis.0.Interference_Mode: -1
dev.ndis.0.ccx_rm: 1
dev.ndis.0.ccx_rm_limit: 300
dev.ndis.0.EFCEnable: 0
dev.ndis.0.Country: BE
dev.ndis.0.Chanspec: 11
dev.ndis.0.WME: -1
dev.ndis.0.IBSSAllowed: 1
dev.ndis.0.ssid_auto_promote: 0
dev.ndis.0.RadioState: 1
dev.ndis.0.WZCCoexist: 0
dev.ndis.0.Managed: 1
dev.ndis.0.LockWlSettings: 0
dev.ndis.0.vlan_mode: 0
dev.ndis.0.PowerSaveMode: 2
dev.ndis.0.BTCoexist: 1
dev.ndis.0.BTC_stuck_war: 1
dev.ndis.0.abcap: 1
dev.ndis.0.AssocRoamPref: 1
dev.ndis.0.RoamTrigger: 0
dev.ndis.0.11HNetworks: 1
dev.ndis.0.IBSSMode: 0
dev.ndis.0.IBSSGProtection: 2
dev.ndis.0.LegacyMode: 2
dev.ndis.0.band: 0
dev.ndis.0.BandPref: 0
dev.ndis.0.RateA: 0
dev.ndis.0.Rate: 0
dev.ndis.0.ApCompatMode: 0
dev.ndis.0.BandwidthCap: 2
dev.ndis.0.1028000A: Dell Wireless 1505 Draft 802.11n WLAN Mini-Card
dev.ndis.0.Environment: 1
dev.ndis.0.NdisVersion: 0x00050001
dev.ndis.0.BusType: 5
dev.ndis.0.InterruptNumber: 17
dev.ndis.0.DriveStrength: UNSET
dev.ndis.0.DPCPriority: UNSET
dev.ndis.0.DongleImagePath: UNSET
dev.ndis.0.SROMImagePath: UNSET
dev.ndis.0.AllowIntfUp: UNSET
dev.ndis.0.ForcePIO: UNSET
dev.ndis.0.AdapterDesc: UNSET
dev.ndis.0.DriverDesc: UNSET
dev.ndis.0.Brand: UNSET
dev.ndis.0.featureflag: UNSET
dev.ndis.0.LegacyProbe: UNSET
dev.ndis.0.ledblinkslow: UNSET
dev.ndis.0.ledblinkmed: UNSET
dev.ndis.0.ledblinkfast: UNSET
dev.ndis.0.WME_qosinfo: UNSET
dev.ndis.0.ccx_enable: UNSET
dev.ndis.0.RoamScanFreq: UNSET
dev.ndis.0.FullRoamScanInterval: UNSET
dev.ndis.0.IBSSLink: UNSET
dev.ndis.0.mimo_antsel: UNSET
dev.ndis.0.AbRateConvert: UNSET
dev.ndis.0.11NPreamble: UNSET
dev.ndis.0.PwrOut: UNSET
dev.ndis.0.BadFramePreempt: UNSET
dev.ndis.0.assoc_recreate: UNSET
dev.ndis.0.scan_channel_time: UNSET
dev.ndis.0.scan_unassoc_time: UNSET
dev.ndis.0.scan_home_time: UNSET
dev.ndis.0.scan_passive_time: UNSET
dev.ndis.0.scan_passes: UNSET
dev.ndis.0.EnableAutoConnect: UNSET
```


----------



## richardpl (Dec 14, 2009)

Are you sure that hardware rf switch is turned on?

How many APs should appear in scan results?

If AP does not broadcast SSID you will not see it in scan results, until you change SSID via ifconfig(8)


----------



## richardpl (Dec 14, 2009)

Why is Country BE? Change it to US.


----------



## Seeker (Dec 14, 2009)

There should appear around 16 ssids.
Yes hardware is on, because if I boot with hardware switch off, kernel panics during boot.

Yes, I will change country. I did not touched it at all, so I guess BE is default.


----------



## richardpl (Dec 15, 2009)

Could you post driver version?
Try to revert http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/118370

It would be more helpful if you describe how panic happen, what was on console output ....


----------



## Seeker (Dec 15, 2009)

I am running 8.0 STABLE.
That patch I've applied on 7.2 and was able to scan thereafter.

Panic is completely irrelevant here, as it is further step.
Now I just need to be able to scan.

PS: I did successfully connected to WPA AP, buy setting *1* critical option in wpa_supplicant.conf

```
scan_ssid=1
```


----------



## richardpl (Dec 15, 2009)

Not FreeBSD version, miniport driver version (bcmwl5.inf).

wpa_supplicant use another logic for scanning.
Looks like your AP is not broadcasting SSID.

Try code from:
http://www.gitorious.org/NDISulator

Better to use IRC or something else for faster communication ...


----------



## Seeker (Dec 15, 2009)

richardpl said:
			
		

> Not FreeBSD version, miniport driver version (bcmwl5.inf).
> 
> wpa_supplicant use another logic for scanning.
> Looks like your AP is not broadcasting SSID.


I said that in WinXP I see around 16 SSIDs (mine and neighbors).
In FreeBSD with ndis I see none.


			
				richardpl said:
			
		

> Try code from:
> http://www.gitorious.org/NDISulator
> 
> Better to use IRC or something else for faster communication ...


I did it and installed if_ndis and ndis and now not only that I can't scan but wpa_supplicant can't find ssid too, any ssid.
I have no IRC installed at the moment.
Anyway, scanning SSIDs is nmb. 1 issue here.


----------



## richardpl (Dec 16, 2009)

From where you downloaded driver?
What arch are you using?


----------



## Seeker (Dec 16, 2009)

I use i386.
I installed git from ports in order to run:

```
git clone git://gitorious.org/ndisulator/ndisulator.git
```
Then, from downloaded folder, I copied src folder and moved it to /usr/src
Then went to where ndis and if_ndis are and did:
	
	



```
make && make install && make clean
```
 for each.


----------



## richardpl (Dec 16, 2009)

You could use mount_nullfs.

I did not asked that.

Let me repeat once again:
What version of miniport driver are you using?
If you dunno how to find that post link from where you
downloaded miniport driver.


----------



## Seeker (Dec 16, 2009)

How do I obtain version of *miniport driver*
Heck, I even don't know, to what does *miniport driver* refers.

PS: I dunno is this relevant, but I use this for wlan0 creation:

```
create_args_wlan0="wlanmode sta"
```


----------



## richardpl (Dec 16, 2009)

Version is in *.inf file.
It is usually in unicode but it can be converted to ascii via ndisgen, before it build modules, after that it will probably clean up temp files.


----------



## Seeker (Dec 16, 2009)

I caught 2 of them:

```
windrv.h
windrv.o
```
and ony 1 was readable: windrv.h
http://www.starforce.biz/windrv.h


----------



## richardpl (Dec 17, 2009)

This file is what you are looking for: /tmp/ascii_inf.LzpbUk

You  need to read DriverVer from bcmwl5.inf:

```
DriverVer=09/20/2007, 4.170.25.12
```


----------



## Seeker (Dec 17, 2009)

I see, then it is:

```
DriverVer=03/21/2008, 4.170.77.3
```


----------



## richardpl (Dec 17, 2009)

I can not reproduce it, but I don't have your card ...
Does scanning works with code from gitorious (try again with latest changes)?

Does other drivers panic if you kldload them _after_ boot?


----------



## Seeker (Dec 18, 2009)

Ok, now I used latest and newest drivers, that cause panic.

```
DriverVer=08/25/2009, 5.60.18.9
```
Unfortunately there is no vmcore_.n_ to debug, as crash happens in a stage of loading modules.

There is no panic when I kldload module at already booted system.
But there is one line that differ from previous version(in red):

```
[color="Red"]no match for ExFreePoolWithTag[/color]
ndis0: <Dell Wireless 1500 Draft 802.11n WLAN Mini-Card> mem 0xf1ffc000-0xf1ffffff,0xf0000000-0xf00fffff irq 17 at device 0.0 on pci12
ndis0: [ITHREAD]
ndis0: NDIS API version: 5.1
```


----------



## richardpl (Dec 18, 2009)

If you did used code from gitorious, including rebuilding bcmwl5_sys.ko that line would not be displayed.

Also copy ndiscvt and other stuff from usr.sbin (usually done via `make world') like windrv_stub.c in /usr/share/misc/



When panic happens something is displayed on console.
You have dumpdev and other stuff defined in rc.conf?

Without bt I'm blind.


----------



## richardpl (Dec 18, 2009)

When panic happen on boot, is there some kind of prompt?

If driver doesnt panic on kldload then does it work?


----------



## richardpl (Dec 19, 2009)

I managed to reproduce panic on boot ...


----------



## Seeker (Dec 19, 2009)

Excellent!

And a..., I don't understand this part:


> Also copy ndiscvt and other stuff from usr.sbin (usually done via `make world') like windrv_stub.c in /usr/share/misc/



I will do this:
1) Upload source tree as I run 8.0 STBALE
2) :

```
git clone git://gitorious.org/ndisulator/ndisulator.git
```
Then, from downloaded folder, I will move src folder to /usr/src
3) I will rebuild world and kernel regulary...

Tomorrow I guess...


----------



## richardpl (Dec 19, 2009)

`# mount_nullfs /path/to/NDISulator/src/sys/dev/if_ndis /usr/src/sys/dev/if_ndis`
`# mount_nullfs /path/to/NDISulator/src/sys/compat/ndis /usr/src/sys/compat/ndis`
`# mount_nullfs /path/to/NDISulator/src/usr.sbin/ndiscvt /usr/src/usr.sbin/ndiscvt`

You don't need to rebuild world, just code in ndiscvt directory.


----------



## Seeker (Dec 19, 2009)

richardpl said:
			
		

> `# mount_nullfs /path/to/NDISulator/src/sys/dev/if_ndis /usr/src/sys/dev/if_ndis`
> `# mount_nullfs /path/to/NDISulator/src/sys/compat/ndis /usr/src/sys/compat/ndis`
> `# mount_nullfs /path/to/NDISulator/src/usr.sbin/ndiscvt /usr/src/usr.sbin/ndiscvt`



I see..., so after this mounting, access to /usr/src/sys/dev/if_ndis, will actually provide latest _gitted_ version of ndis.

This saves me a step of moving files to /usr/src, after download.

But what did you meant by:


> You don't need to rebuild world, just code in ndiscvt folder


To what do you refer by _code in_


----------



## richardpl (Dec 20, 2009)

`# cd /usr/src/usr.sbin/ndiscvt && make install clean`

And if you use GENERIC kernel (ndis and ndisapi are modules):
`# cd /usr/src/sys/modules/ndis && make install clean`
`# cd /usr/src/sys/modules/if_ndis && make install clean`

So you dont need to rebuild world and kernel.


----------



## Seeker (Dec 20, 2009)

richardpl said:
			
		

> ...
> And if you use GENERIC kernel (ndis and ndisapi are modules):
> `# cd /usr/src/sys/modules/ndis && make install clean`
> `# cd /usr/src/sys/modules/if_ndis && make install clean`
> ...


This is exactly a way I went last time.


----------



## richardpl (Dec 21, 2009)

If you did then *red line* would not be there.


----------



## Seeker (Dec 21, 2009)

Ok, hell, then I'll do it again.
And a..., you said you've reproduced an error.
Does this means, I'll have to wait until problem is solved in ndis code?


----------



## richardpl (Dec 21, 2009)

You picked master branch and not CURRENT?

I first need to find source of the problem ...
BTW new driver appears to freeze system now and then and I still need to find can this be traced via kdb ...

But older drivers and new one should have working scan, does it?


----------



## Seeker (Dec 26, 2009)

Now I used *CURRENT*!
After make *everything* is same.

Scan is not possible!

http://www.starforce.biz/A.JPG
http://www.starforce.biz/B.JPG


It _"simply"_ doesn't work.


----------



## richardpl (Dec 27, 2009)

try master again (sync source first to last commit)

You said that with wpa_supplicant scanning works?


----------



## Seeker (Dec 27, 2009)

No. 
With wpa_supplicant, scanning *doesn't* work.

I merely establish connection, to AP, which *does broadcast it's SSID*, only when I set in wpa_supplicant.conf:

```
scan_ssid=1
```
And that option is intended to successfully connect to APs that *don't* broadcast theirs SSID
And connection breaks soon and is never established again.

In any of this steps scanning never works / show any results.


----------



## Seeker (Jan 4, 2010)

richardpl said:
			
		

> try master again (sync source first to last commit)


Works.
Kind of..

With my newest drivers, there is a crash during a boot.
With my oldest drivers, there is a crash during a boot, only if I set it to connect via wpa_supplicant in rc.conf.

So now it works, with my oldest drivers at 1/10th of speed, when connected to AP manually using wpa_supplicant, after boot.

PS: Used ndis master branch from 7 days ago.

Will test more... :stud


----------



## richardpl (Jan 4, 2010)

There is something wrong with list manipulation during boot (actually just after boot) I have no idea what is source of the problem.

Speaking about speed issue, is that regression? Is `# top -HS` showing something strange (too much use of CPU from ndis threads ...)

Speaking about scan results, maybe OID_802_11_BSSID_LIST(_SCAN) needs some tricks? So last master have some more debug, so just enable debug.ndis=1 while scanning: `# ifconfig wlan0 scan` (BTW: You must be root)


----------



## Seeker (Jan 4, 2010)

Ok I've just csup-ed src tree and downloaded latest master branch
Regarding booting, here is a latest crash http://www.starforce.biz/C.JPG

Forget speed, as it is now ok.
I simply didn't do any real speed test, till now.

It works when I kldload it after boot and scan works too.
Scan now works super fast!

```
ifconfig wlan0 scan
```
Best of all ndis versions! 
And

```
ifconfig wlan0 list scan
```
..., even faster

There is an issue with APs, that hide theirs ssid.
I can't connect, even when I use in wpa_supplicant.conf:

```
scan_ssid=1
```

But I solved that anyway by using this wpa_supplicant.conf:

```
eapol_version=2

ap_scan=2

network={
  ssid="xxx"
  scan_ssid=1
  proto=WPA
  key_mgmt=WPA-PSK
  pairwise=CCMP
  psk="xxxxxxxxxxxxx"
}
```

Now, your last issue, is a boot time crash.


----------



## richardpl (Jan 4, 2010)

For hidden APs encryption must be changed to what AP is using, I dunno is this driver issue or just NDIS limitation.


----------



## Seeker (Jan 4, 2010)

Look a post above, as I've just edited it,... few sec before your post.

Now, your last issue, is a *boot time crash*.


----------



## richardpl (Jan 4, 2010)

Seeker said:
			
		

> Look a post above, as I've just edited it,... few sec before your post.
> 
> Now, your last issue, is a *boot time crash*.



Does *wpa_supplicant -Dbsd* works instead of *-Dndis* for you?

There are many other issues to be resolved .... the worst one is that amd64 is broken with my card.


----------



## Seeker (Jan 4, 2010)

richardpl said:
			
		

> Does *wpa_supplicant -Dbsd* works instead of *-Dndis* for you?
> ...



Nope! 
Error snip:

```
... No such file or directory
Association request to the driver failed
...
```


----------



## richardpl (Jan 9, 2010)

Seeker, could you test last master, scan results should now be available after one second(previously it was after 3 or 6).


----------



## Seeker (Jan 9, 2010)

Yes, I tested it.

It behaves this way:
I initiate a scan and in a fraction of sec., I get list of just 1 entry.
Then I do it again and in less then sec I get another 6 SSIDs
Then I do it again and in less then sec I get another 4-8 SSIDs
...


----------



## richardpl (Jan 10, 2010)

Does 11n stuff works?


----------



## Seeker (Jan 11, 2010)

I haven't tried, as only my laptop has 11n support in WiFi module.
AP and other desktop use 11g, so does a laptop too then.


----------



## Seeker (Jan 20, 2010)

Because of this, I had to downgrade from 8.0-STABLE to 8.0-RELEASE-p2
Now I can't get max speed, but max is 1/3.

I also had one freeze when I initiated first scan, which also damaged some files(0 lenght)
I think I caught crash so will post it if I did.

PS: I see new ndis5 branch there, HEAD?


----------



## richardpl (Jan 20, 2010)

There was bug with bssid list OID, so it is important what was last commit when you used git code.
Also it is sane when testing non-stable code to first use INVARIANTS+WITNESSkernel, so to make use of KASSERTs and possible lock order reversal so they got showed in console/dmesg output. Deadlocks are possible and could cause hang.

When you are speaking of max speed to what are you referring to?

ndis5 is going to become NDIS API 5.1 only (only XP drivers with 4 - 5.1 NDIS API version)

master should become NDIS API 6.20 or higher but currently I did not make single step in that direction...


----------



## richardpl (Jan 20, 2010)

Also, do not scan via ifconfig on 8.0 RELEASE with that broadcom driver, 8.0 RELEASE's if_ndis.c have serious bug there.


----------



## Seeker (Jan 20, 2010)

So I have to build a custom kernel, to properly debug?

Regarding max speed, it was 650 kb/s, now I get 200 -150 kb/s, and it oscillates a lot.


			
				richardpl said:
			
		

> Also, do not scan via ifconfig on 8.0 RELEASE with that broadcom driver, 8.0 RELEASE's if_ndis.c have serious bug there.


That was a motive, for creating this thread.
I download your master, then copy it to /usr/src and compile each ndis and then do a scan and it works.

Thing that never worked, was loading a kernel module at boot time via /boot/loader.conf, of ndis driver, as it causes panic (1 second of uptime)
Even now I have to _kldload_ it when system is fully booted.


----------



## richardpl (Jan 20, 2010)

Depends on what you want to debug. If you found bug in my code than using debug kernel (one from CURRENT is good example) is right direction.

What program you use that give such results?
Are there any strange results in  *top -HS*.
The only thing I changed in that direction from your last test is changeset which should improve general stuff lowering latency and initialization times.

How good is ping to your router/nameserver?

Speaking about boot bug, there is workaround, config_intrhook(9).


----------



## Seeker (Jan 20, 2010)

You are developing with STABLE / CURRENT.
As I reverted from STABLE to RELEASE, I get slower speed.
So maybe FreeBSD's code change between STABLE and RELEASE makes speed slower.

I use my server and in it's apache dir is file of size 80 MB.
Then I use my laptop, which connects to server via WLAN(your code -master) using *wget* from shell to download that 80 MB file.

I code only in PHP, HTML, JS. That is my realm.
I can't find bug in your code, as I haven't learned it's syntax.


			
				richardpl said:
			
		

> Speaking about boot bug, there is workaround, config_intrhook(9).


This type of utilization, is out of my scope for now.
I simply don't know, what to do with it.


----------



## Seeker (Jan 20, 2010)

Ok, I've just downloaded latest master and installed it.
I am not home, but in a caffe and am using it's unencrypted WLAN.

I firstly initiated download from my server in WinXP and got 505 Kb/s
Then I reeboted into FreeBSD and got max speed of 50 Kb/s
After installation of latest ndis master and rebuilding of bcmwl5_sys.ko
I got speed oscilating from 450 - 490 Kb/s, which is very close to WinXP's 0.5 MB/s

PS: wpa_suppliciant hasn't been used! I will when I come home.


----------



## richardpl (Jan 20, 2010)

I dunno why RELEASE is slow in your environment.

As you noticed there is still place for improvements...


----------



## Seeker (Jan 21, 2010)

It is not slow anymore.
Just 5-10% slower then in WinXP, which is completely fine by me.
Good work!


----------



## Seeker (Feb 1, 2010)

Yesterday I _did_ MASTER.
I had a crappy speed of 50kB/s to 150kB/s with latest win drivers, the one that always panics at boot.

I tried my old win drivers...
At once I succeeded in getting speeds higher then when booted at XP. 720kB/s! 
Now I *can now boot with kldloaded module* and speed is max 430kB/s

But there is a catch!
If file being downloaded is smaller then 100kB then I need to do:

```
wget 192.168.0.1/big_file.rar
```
Which would then start to dowmload at speeds of 230kB/s - 430kB/s
AND it enables that small file to start download from the internet.

That drove me nuts as I had to download 50 those small files, and I had to *wget* 50 times or they would time out.


----------



## richardpl (Feb 1, 2010)

New broadcom drivers use some other methods comparing to older ones. And current implementation is just broken (and too slow).

Did new driver worked better with older master or code from  RELEASE you are currently using?

With git it is easy to find commit which introduced some kind of regression.


----------



## Seeker (Feb 2, 2010)

Forget RELEASE, as I can't scan, with any driver version on it.
So master was always a better solution.

I dunno, as I always download tarball.


----------



## richardpl (Feb 2, 2010)

Do you have link to small files, so I can try to reproduce it.

Did you tried to use other programs instead of wget.

Sometimes it is not problem with NDISulator at all, and sometimes there is no fix but just workaround.

For benchmark you could try various torrents to find out what maximal speed you can get, it is also stress test for possible other problems.


----------



## Seeker (Feb 2, 2010)

I used only wget and nothing more, to fetch big file from my getaway server.

I deleted /usr/ports
So small files being downloaded were those of xorg various libs, with command:
[CMD="portupgrade"]-afF[/CMD]
I just refetched them to distfiles


----------



## Seeker (Feb 8, 2010)

I just had a crash with your latest master ndis and my newest driver, with which I can't boot too (currently using old driver, as I can also boot with it)
This time I have a crash core:

```
# cat info.11
Dump header from device /dev/ad4s3b
  Architecture: i386
  Architecture Version: 2
  Dump Length: 205078528B (195 MB)
  Blocksize: 512
  Dumptime: Mon Feb  8 18:20:29 2010
  Hostname: cruiser.starforce.biz
  Magic: FreeBSD Kernel Dump
  Version String: FreeBSD 8.0-RELEASE-p2 #0: Sun Jan 31 18:18:54 CET 2010
    root@cruiser.starforce.biz:/usr/obj/usr/src/sys/GENERIC
  Panic String: vm_fault: fault on nofault entry, addr: e81ea000
  Dump Parity: 3760290330
  Bounds: 11
  Dump Status: good
```
http://www.starforce.biz/core.txt.11.txt


----------



## richardpl (Feb 17, 2010)

Exact what revision?

There are some LORs with scanning and with other stuff ...
And I did fixed problem that cause panic when scanning for some reason fails.
It looks to me that panic happens because of constant link state change.
Are those changes rapid in small time period?
Do you now how to reproduce it?

I dont see backtrace, probably because either driver corrupted random virtual memory or you are just out of luck.

If there is no real reason to use newer driver, do not use it.
Current implementation in that area is plain broken.
BTW:
Next time contact me directly via mail because I do not use forum that much.

And use git, it just makes things easier for everyone.


----------



## Seeker (Feb 18, 2010)

Revision? I dunno.
I downloaded tar ball at February 8th, 2010, 18:00

I am very happy with old driver now, as I can boot with it and have almost max speed with it.

Ok, with e-mail then.

git? I see, it is very popular, too.
Ok, I'll have to study it a bit, first.


----------



## Seeker (Nov 26, 2010)

In a meantime I've shifted to:

```
# uname -a
FreeBSD cruiser.starforce.biz 8.1-RELEASE-p1 FreeBSD 8.1-RELEASE-p1 #0: Sat Nov 20 17:44:22 CET 2010     root@cruiser.starforce.biz:/usr/obj/usr/src/sys/GENERIC   amd64
```

I can see, that now you have 3 dev branches of ndisulator, instead of 2. 
I've used 'ndisulator-ndisulator-stable_ndis5.tar', downloaded ~10 hrs ago.


```
# kldload bcmwl564_sys.ko
ndis0: <Dell Wireless 1500 Draft 802.11n WLAN Mini-Card> mem 0xf1ffc000-0xf1ffff
ff,0xf0000000-0xf00fffff irq 17 at device 0.0 on pci12
ndis0: [ITHREAD]
fpudna in kernel mode!

# ifconfig wlan0 create wlandev ndis0
wlan0: Ethernet address: 00:1f:e1:71:1a:b9

# ifconfig wlan0 up scan
fpudna in kernel mode!
wlan0: ieee80211_new_state_locked: pending INIT -> SCAN transition lost
fpudna in kernel mode!
fpudna in kernel mode!
fpudna in kernel mode!
fpudna in kernel mode!
fpudna in kernel mode!
fpudna in kernel mode!
fpudna in kernel mode!
fpudna in kernel mode!
fpudna in kernel mode!
...

# ifconfig wlan0 scan
fpudna in kernel mode!
...
fpudna in kernel mode!
fpudna in kernel mode!
fpudna in kernel mode!
SSID/MESH ID    BSSID              CHAN RATE   S:N     INT CAPS
NETGEAR         00:1b:2f:00:ff:fa   11   54M -64:-96  100 EP   WPA
Berce           00:1f:c6:8c:a5:f0    1   54M -75:-96  100 EP   WME
cb18e7          00:26:18:04:2d:19    1   54M -92:-96  100 EP   WPS WPA WME
Skugor          00:02:cf:a8:fa:fa    1   54M -89:-96  100 EPSB WPA
Tajana          00:24:8c:68:85:fd    4   54M -86:-96  100 EP   WPS WPA WME
Thom_D014900    00:24:d1:79:53:d1    3   54M -92:-96  100 EP   WME
                00:0e:2e:e5:0b:b9    6   54M -58:-96  100 EPS  WPA
kek_mreza       00:4f:74:31:1d:aa    4   54M -89:-96  100 EP   HTCAP WME WPS
cruiser# fpudna in kernel mode!
```

Attempt to connect:


```
cruiser# ifconfig wlan0 inet 192.168.0.3 netmask 255.255.255.0
cruiser# route add default 192.168.0.1
add net default: gateway 192.168.0.1
cruiser# wpa_supplicant -d -D ndis -i wlan0 -c /etc/wpa_supplicant.conf
Initializing interface 'wlan0' conf '/etc/wpa_supplicant.conf' driver 'ndis' ctr
l_interface 'N/A' bridge 'N/A'
Configuration file '/etc/wpa_supplicant.conf' -> '/etc/wpa_supplicant.conf'
Reading configuration file '/etc/wpa_supplicant.conf'
eapol_version=2
ap_scan=2
Priority group 0
   id=0 ssid='BLACKHOLE'
Initializing interface (2) 'wlan0'
NDIS: Packet.dll version: FreeBSD WinPcap compatibility shim v1.0
NDIS: 1 adapter names found
NDIS: 1 adapter descriptions found
NDIS: 0 - wlan0 - wlan0
NDIS: Adapter description prefix 'wlan0'
ndis_get_oid: oid=0x1010102 len (6) failed
NDIS: Get OID_802_3_CURRENT_ADDRESS failed
Failed to initialize driver interface
Failed to add interface wlan0
Cancelling scan request
Cancelling authentication timeout
```


----------



## richardpl (Nov 26, 2010)

8 STABLE have fpu_kern api, 8.2 will also get some mayor stuff from my git NDISulator (mainly resurrrected amd64).

Note that amd64 works for me (on CURRENT) starting from monday version of my git repo.
I do not get fpudna in kernel mode on console, but also I did not tested WPA yet on amd64.

However amd64 miniport drivers do use XMM registers on amd64. Mixing userland
and kernelland XMM registers may cause problems on 8.

8.2 RELEASE, (8 releng) will get mayor NDISulator stuff from 9.0 CURRENT in next days.

Solution for corruption of XMM registers will be available in next days (on my git repo).

To make use of that solution you will need to run recent 8 STABLE - what is going to be 8.2 RELEASE in couple of months because older FreeBSD versions do not have (and will not have) fpu_kern API.


----------



## Seeker (Nov 26, 2010)

So, I have to get rid of /usr/src and csup 8_releng and compile and run 8-STABLE on my laptop? (I had a VARY BAD experience, with STABLE. 1 year ago)
And then download 'ndisulator-ndisulator-stable_ndis5.tar' in a next $N days ...?


----------



## richardpl (Nov 26, 2010)

You can use release source and merge fpu_kern API from STABLE. I use git mirror of freebsd source so this is fast and trivial.

cvs and svn is for history.

Anyway 8 STABLE is in PRERELEASE stage, so testing it and reporting bugs will make 8.2 RELEASE better.


----------



## Seeker (Nov 26, 2010)

Ok, so ...

```
cd /usr/ports/devel/git
make install clean
```
Now, I would like to keep RELEASE sources and download, _what-you-said-to_, via git, into:

```
mkdir ~/ndis_stable
```
After that, I would mount ~/ndis_stable, via nullfs, over my existing sources 

Can I get CMDs to achieve this?
Especially git fetching part.


----------



## richardpl (Nov 26, 2010)

Use FreeBSD git mirror: git://gitorious.org/freebsd/freebsd.git

It keeps CURRENT, STABLE, RELEASE and even 4.11 in one go, and consume only ~350 MB.

NDISulator got README and Makefile, and wiki+issue page at https://github.com/richardpl/NDISulator


----------



## richardpl (Nov 26, 2010)

```
#ndis_get_oid: oid=0x1010102 len (6) failed
NDIS: Get OID_802_3_CURRENT_ADDRESS failed
Failed to initialize driver interface
Failed to add interface wlan0
Cancelling scan request
Cancelling authentication timeout
```

Looks like this is completly another problem (it have nothing to do with fpudna).


----------



## richardpl (Nov 26, 2010)

It was my fault. Fixed.


----------



## Seeker (Nov 27, 2010)

Ok, so here is a report:

I've used 2 type of 64bit drivers, latest versions of:
ndis 5
ndis 4

Both worked, BUT, ndis5 driver, if loaded at boot time, causes panic!

So I stick with ndis 4 driver.


PS: Is there a way to shut up _fpudna_ kernel's screaming?
This made me to completely avoid using console on ttyv0, so now am on ttyv1+


----------



## richardpl (Nov 27, 2010)

fpudna will be gone once you use FreeBSD & NDISulator with fpu_kern API.

Even Windows does not load drivers at boot time - I will see what can be done to delay ndis initialization.
In meantime instead of loader.conf(5) use rc.local(8)


----------



## Seeker (Nov 30, 2010)

If wlan0 is idle(no data transfers) for 15 min, connection acts like broken, even 'ifconfig wlan0' states associated:
From log:

```
wpa_supplicant[396]: WPA: EAPOL-Key Replay Counter did not increase - dropping packet
```
But if I do:

```
ifconfig wlan0 down
ifconfig wlan0 up
```
... and wait for a *few minutes*, all is back to normal.

How should I solve this?


----------



## richardpl (Nov 30, 2010)

Now NDISulator have ultimate debug support. Make sure you use latest version.

Debug is compiled by default. Enable it with:
`# sysctl debug.ndis=1`

This will show all OID request on console.

If you set this to -1 instead you will get burst of messages on console, so be warned.

Is something else displayed on console?
Perhaps this will be fixed with fpu_kern API.

I think this is because you do not run ndis_events(8) (you really should). AP probably disconnected you due to inactivity.


----------



## Seeker (Nov 30, 2010)

Ok, I will try 'ndis_events', as I haven't used it.
I've set up all, to be fully configured at boot time. (kldload, config in rc.conf)
So after boot, when I reach console, with login prompt, sys is already associated with AP.
How do I make 'ndis_events' start at boot, too?
I've searched but haven't found any directives in rc.


----------



## richardpl (Nov 30, 2010)

Put it in rc.local


----------



## Seeker (Dec 2, 2010)

As usual, yesterday I've downloaded latest ndisulator-ndisulator-*stable_ndis5*.tar.gz
Under 8.1R it compiled and run.
This time I had a lots of:

```
wpa_supplicant[407]: CTRL-EVENT-DISCONNECTED - Disconnect event - remove keys
```
At some time of usage, I had a huge packet loss of approx 75% and ifconfig showed speed of 1Mbps.

```
ping -c10 192.168.0.1 | grep -oE '[^ ]+ packet loss'
80.0% packet loss
cruiser# ping -c10 192.168.0.1 | grep -oE '[^ ]+ packet loss'           0 /root
100.0% packet loss
cruiser# ping -c10 192.168.0.1 | grep -oE '[^ ]+ packet loss'           2 /root
50.0% packet loss
cruiser# ping -c10 192.168.0.1 | grep -oE '[^ ]+ packet loss'           0 /root
70.0% packet loss
cruiser# ping -c10 192.168.0.1 | grep -oE '[^ ]+ packet loss'           0 /root
90.0% packet loss
cruiser# ping -c10 192.168.0.1 | grep -oE '[^ ]+ packet loss'           0 /root
80.0% packet loss
cruiser# ping -c10 192.168.0.1 | grep -oE '[^ ]+ packet loss'           0 /root
70.0% packet loss
cruiser# ping -c10 192.168.0.1 | grep -oE '[^ ]+ packet loss'           0 /root
90.0% packet loss
cruiser# ping -c10 192.168.0.1 | grep -oE '[^ ]+ packet loss'           0 /root
60.0% packet loss
```

So I upgraded to 8.2 PRERELEASE and compiled ndisulator-ndisulator-*stable_ndis5*
I've received an errors during ndisgen attempt to create kernel module.
This is how, my dir, looked like:

```
total 3912
-rw-r--r--  1 root  wheel  -  1.1K Dec  2 16:11:39 2010 .depend
lrwxr-xr-x  1 root  wheel  -   12B Dec  2 16:11:39 2010 @ -> /usr/src/sys
-rwx------  1 root  wheel  -  754K Oct 24 19:00:30 2008 [B]bcmwl5.inf[/B]
-rwx------  1 root  wheel  -  1.4M Oct 24 19:00:30 2008 [B]bcmwl564.sys[/B]
-rw-r--r--  1 root  wheel  -   30K Dec  2 16:11:39 2010 bus_if.h
-rw-r--r--  1 root  wheel  -   11K Dec  2 16:11:39 2010 device_if.h
lrwxr-xr-x  1 root  wheel  -   26B Dec  2 16:11:39 2010 machine -> /usr/src/sys/amd64/include
-rw-r--r--  1 root  wheel  -  100K Dec  2 16:11:32 2010 windrv.h
-rw-r--r--  1 root  wheel  -  1.5M Dec  2 16:11:32 2010 windrv.o
```

Looks like it's broken.


----------



## richardpl (Dec 2, 2010)

Read README and follow it, nothing is broken.

Please post output of dmesg(8) somewhere.


----------



## Seeker (Dec 3, 2010)

*During boot*, now it collapses with both drivers:
Driver v4
Driver v5

Driver v5, also once crashed while working, but it also might be NFS as a cause, or something tird, who would know.

I am now with latest Driver v5.
There is an issue, where if there is no data passing through wlan0, for some time, it simply doesn't work anymore even when associated with an AP.

Log said:

```
WPA: EAPOL-Key Replay Counter did not increase - dropping packet
```


----------



## richardpl (Dec 3, 2010)

Seeker said:
			
		

> *During boot*, now it collapses with both drivers:
> Driver v4
> Driver v5



Just stop loading it during boot, please.

I asked for dmesg output. The info you gave me is useless.

Can you make use of textdump, because looking jpeg is daunting task.

If you use latest version on 8.2 , "fpudna" should be gone, is this true?

Is it so hard to contact me directly? Trying to debug this stuff via forum
interface is daunting task for me.

Make account on github.com, so that you can make unlimited number of tracked
issues in github.com/richardpl/ndisulator instead of spreading them on this forum.


----------



## Seeker (Dec 3, 2010)

richardpl said:
			
		

> Just stop loading it during boot, please.


Done.


			
				richardpl said:
			
		

> I asked for dmesg output. The info you gave me is useless.


Here it is ...


			
				richardpl said:
			
		

> Can you make use of textdump, because looking jpeg is daunting task.


No core dump has occurred.


			
				richardpl said:
			
		

> If you use latest version on 8.2 , "fpudna" should be gone, is this true?


Yes.


			
				richardpl said:
			
		

> Is it so hard to contact me directly? Trying to debug this stuff via forum interface is daunting task for me.


I don't have your personal contact.


			
				richardpl said:
			
		

> Make account on github.com, so that you can make unlimited number of tracked
> issues in github.com/richardpl/ndisulator instead of spreading them on this forum.


Done.

Also, regarding idle wlan0, here is a log, when tried to use it again(down then up):

```
Dec  3 07:14:00 cruiser wpa_supplicant[1557]: Authentication with 00:00:00:00:00:00 timed out.
Dec  3 07:14:00 cruiser wpa_supplicant[1557]: Trying to associate with SSID 'MY_SID'
Dec  3 07:15:00 cruiser wpa_supplicant[1557]: Authentication with 00:00:00:00:00:00 timed out.
Dec  3 07:15:00 cruiser wpa_supplicant[1557]: Trying to associate with SSID 'MY_SID'
Dec  3 07:16:00 cruiser wpa_supplicant[1557]: Authentication with 00:00:00:00:00:00 timed out.
Dec  3 07:16:00 cruiser wpa_supplicant[1557]: Trying to associate with SSID 'MY_SID'
Dec  3 07:16:03 cruiser kernel: wlan0: link state changed to UP
Dec  3 07:16:03 cruiser wpa_supplicant[1557]: Associated with 00:0e:2e:e5:0b:b9
Dec  3 07:16:13 cruiser wpa_supplicant[1557]: Authentication with 00:0e:2e:e5:0b:b9 timed out.
Dec  3 07:16:13 cruiser kernel: wlan0: link state changed to DOWN
Dec  3 07:16:13 cruiser wpa_supplicant[1557]: Trying to associate with SSID 'MY_SID'
Dec  3 07:16:14 cruiser wpa_supplicant[1557]: CTRL-EVENT-DISCONNECTED - Disconnect event - remove keys
Dec  3 07:17:13 cruiser wpa_supplicant[1557]: Authentication with 00:00:00:00:00:00 timed out.
Dec  3 07:17:13 cruiser wpa_supplicant[1557]: Trying to associate with SSID 'MY_SID'
```

And when frantically initiating scan, kernel said:

```
wlan0: ieee80211_new_state_locked: pending RUN -> SCAN transition lost
```


----------



## richardpl (Dec 3, 2010)

My email is displayed in every commit log.

There should not be state change if roaming is manual - when using wpa_supplicant with ndis driver.

I managed to reproduce crash in workitem3 for drivers using NdisSheduleWorkItem - the same one causing panic at boot.

So use older version of driver until I fix this bug.


----------



## Seeker (Dec 4, 2010)

Idle connection becomes useless, with both driver versions (roaming MANUAL) and very hard to re-associate with AP

```
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	ether 00:1f:e1:71:1a:b9
	inet 192.168.0.3 netmask 0xffffff00 broadcast 192.168.0.255
	media: IEEE 802.11 Wireless Ethernet OFDM/54Mbps mode 11g
	status: associated
	ssid MY_SSID channel 6 (2437 MHz 11g) bssid 00:0e:2e:e5:0b:b9
	regdomain ETSI country HR authmode WPA privacy OFF txpower 30 bmiss 7
	mcastrate 6 mgmtrate 6 scanvalid 60 protmode CTS roaming MANUAL
```
Both driver versions cause panic at boot.


----------



## richardpl (Dec 4, 2010)

Try again with last version.


----------



## Seeker (Dec 4, 2010)

All compiles but, at the end:

```
cruiser# kldload bcmwl564
link_elf_obj: symbol kuser_shared_data undefined
linker_load_file: Unsupported file type
KLD if_ndis.ko: depends on ndisapi - not available or version mismatch
linker_load_file: Unsupported file type
KLD bcmwl564.ko: depends on ndis - not available or version mismatch
linker_load_file: Unsupported file type
kldload: can't load bcmwl564: Exec format error
```

Ps: I've also created *issue* and wrote (regarding idle wlan):


> My AP hides ssid.
> When I removed that AP option, problem is gone.
> 
> You should test it with AP that hides it's ssid.


----------



## richardpl (Dec 4, 2010)

I fixed error in loading. On i386 AP had hiden SSID too?


----------



## Seeker (Dec 4, 2010)

Yes


----------



## Seeker (Dec 5, 2010)

```
/usr/src/sys/modules/ndis/../../compat/ndis/kern_windrv.c: In function 'patch_user_shared_data_address':
/usr/src/sys/modules/ndis/../../compat/ndis/kern_windrv.c:287: error: 'kuser_shared_data' undeclared (first use in this function)
/usr/src/sys/modules/ndis/../../compat/ndis/kern_windrv.c:287: error: (Each undeclared identifier is reported only once
/usr/src/sys/modules/ndis/../../compat/ndis/kern_windrv.c:287: error: for each function it appears in.)
*** Error code 1

Stop in /usr/src/sys/modules/ndis.
*** Error code 1

Stop in /root/ndisulator-ndisulator.
```
Code slower ...


----------



## richardpl (Dec 5, 2010)

Try again.


----------



## Seeker (Dec 5, 2010)

*Regression*

I've used latest v5 drivers.

This is a worst sample ever.
As soon I compiled it and created modules, crash occurred upon kldload

Not only that it crashes machine at boot time, but also during work time.
Worst part, is it's complete inability, to associate with non-hidden AP, which worked excellent before.

This is serious regression, in all 3 points.


----------



## richardpl (Dec 5, 2010)

I already said not to use last driver because it easily exposes bugs in NDISulator and panics. The last change just expose bug more directly.

Use older driver until I rewrite big pile of awful code in WorkItem implementation.


----------



## Seeker (Dec 5, 2010)

Oh, I see.
I've thought you've meant not to use v5 if I intend to boot with it.

Will try v4 then.


----------



## Seeker (Dec 5, 2010)

It only doesn't crash, but AP association is obliterated!
Can I have a code(how to get), from point in time, just before I've told you about hidden ssid issue.
Obviously you've did a major regression, on that part, in your attempt to fix it.


----------



## wblock@ (Dec 5, 2010)

You realize that hidden SSIDs are not really hidden, right?


----------



## richardpl (Dec 5, 2010)

Seeker said:
			
		

> Can I have a code(how to get), from point in time, just before I've told you about hidden ssid issue.



Clone git, checkout stable_ndis5 branch, look at git log and checkout second to last commit.

You can also download tar.gz state of tree before last commit.


----------



## Seeker (Dec 7, 2010)

I can see, you now have 2 branches, as merging occurred.
I've fetched latest FreeBSD's src and recompiled world+kern, about 14 hrs ago.

I've downloaded ndis 'stable' 1 hrs ago.

It compiled and I've created module.
Upon kldload:

```
link_elf_obj: symbol x86_64_call2 undefined
linker_load_file: Unsupported file type
KLD if_ndis.ko: depends on ndisapi - not available or version mismatch
linker_load_file: Unsupported file type
KLD bcmwl564.ko: depends on ndis - not available or version mismatch
linker_load_file: Unsupported file type
```


----------



## richardpl (Dec 7, 2010)

stable is for FreeBSD STABLE as mentioned in README

modules loads fine for me on amd64 and i386.

You can not mix modules/kernel with different __FreeBSD__version.


----------



## Seeker (Dec 7, 2010)

???
But I have been using *stable_ndis5* up to now!
Isn't this now a *stable* branch after merge?

I still run 8.2 PRERELEASE
That is whats gets compiled when I download RELENG_8 (aka STABLE)


----------



## richardpl (Dec 7, 2010)

The makefile for ndis on STABLE is incorrect. Will fix that.


----------



## Seeker (Dec 12, 2010)

Using ndis *v4* drivers ...

If AP hiddes ssid, association isn't posible:

```
Dec 12 02:29:24 cruiser wpa_supplicant[399]: CTRL-EVENT-SCAN-RESULTS
Dec 12 02:30:00 cruiser last message repeated 3 times
Dec 12 02:32:01 cruiser last message repeated 10 times
```
Unhiding solves an issue.

For some reason, ndis now sets txpower to 0, which results in disastrous speeds. (20 Kbps)
Setting it to txpower 30, fixes it.

However(when encryption used), speed varies on it's own, so I get 20% of max speed, which seems now to be 50~80%, with just downloaded ndis sources.
Lastly I've saw this:

```
media DS/5.5Mbps
```
And it was supposed to be OFDM/54
It varies on it's own, sometimes giving speeds of funny 1Kb/s ?!


I did ifconfig up and down and even achieved max speed.

If wlan0 is idle, I can't use it anymore:

```
Dec 12 05:03:03 cruiser wpa_supplicant[399]: WPA: EAPOL-Key Replay Counter did not increase - dropping packet
Dec 12 05:03:29 cruiser last message repeated 5 times
Dec 12 05:09:04 cruiser wpa_supplicant[399]: WPA: EAPOL-Key Replay Counter did not increase - dropping packet
```


----------



## richardpl (Dec 12, 2010)

Does similar bad performance and idle issue happens on i386?

How are you starting wpa_supplicant?


----------



## Seeker (Dec 12, 2010)

I remember having max speeds even on amd64. At that time there was 3 branches, before you did a merge.
It also seems I don't have this problem, if I use ndis v5 drivers, that is, I can get max speeds, but am not using it, as you said not to + I can't boot with it, while with v4 I can.
After more testing in current situation, I am getting on average max ~100 Kb/s

Via rc.conf

```
/usr/sbin/wpa_supplicant -dd -s -B -i wlan0 -c /etc/wpa_supplicant.conf -D ndis -P /var/run/wpa_supplicant/wlan0.pid
```


----------



## richardpl (Dec 12, 2010)

I can use latest broadcom driver: version 5.100.9.142 just fine except I never load miniport drivers via loader.conf.

So just use last driver but do not touch loader.conf until I announce it is safe.

Did you ever tried to load driver via rc.local ?

Repeating over and over again boot issue will not make it get fixed sooner - ever heard about negative feedback?


----------



## Seeker (Dec 12, 2010)

Ok, I've just reached ~350 Kb/s with v4
Ok, will try v5 @reboot


----------



## richardpl (Dec 12, 2010)

Reboot is not required, ever heard about kldunload(8)?


----------



## Seeker (Dec 12, 2010)

ROFLMAO!
I was refering to *cron's* *@*reboot, which I would use, to kldload v5 driver, at boot time.
And even configure *if* ...


----------



## Seeker (Dec 12, 2010)

Using v5, I get higher average speed ~300 Kb/s
However, I can reach max of ~650 Kb/s(which I can't with v4), if I do $IF up and down, around 4 times.
But, in that process, I can also hit a "null point", which means I can't scan nor connected to AP:

```
Dec 12 19:23:42 cruiser [B]kernel: ifa_add_loopback_route: insertion failed[/B]
Dec 12 19:23:46 cruiser wpa_supplicant[1620]: CTRL-EVENT-SCAN-RESULTS
Dec 12 19:24:22 cruiser last message repeated 3 times
Dec 12 19:24:46 cruiser last message repeated 2 times
Dec 12 19:24:49 cruiser [B]kernel: ifa_add_loopback_route: insertion failed[/B]
Dec 12 19:24:58 cruiser wpa_supplicant[1620]: CTRL-EVENT-SCAN-RESULTS
Dec 12 19:25:34 cruiser last message repeated 3 times
```
I've also noticed that at 2 time, txpower is dropped to 0 instead to 30 (same as with v4), which gives ~ 12 Kb/s


----------



## richardpl (Dec 12, 2010)

Regarding txpower issue: ifconfig txpower output is incorrect. If you do not like such output look at ifconfig manual page for country/regdomain and similar commands.


----------



## Seeker (Dec 12, 2010)

I am already using *county HR* .. ETSI ...
Anyway, when you improve bandwith logic and other issues, throw a post, so I could jump for new drivers.


----------



## Seeker (Dec 16, 2010)

I've tried yours latest sources:
Speed is now improved, up to 80% of max speed.

After done few $IF up and downs (wpa also restarted) I can't scan(nor assocciate with AP), sometimes, with error:

```
ifconfig wlan0 scan
wlan0: ieee80211_new_state_locked: pending INIT -> RUN transition lost

Dec 16 16:18:40 cruiser kernel: ifa_add_loopback_route: insertion failed
Dec 16 16:19:31 cruiser kernel: ifa_add_loopback_route: insertion failed
Dec 16 16:19:39 cruiser wpa_supplicant[1843]: CTRL-EVENT-SCAN-RESULTS
Dec 16 16:20:15 cruiser last message repeated 3 times
Dec 16 16:21:03 cruiser last message repeated 4 times
```


----------



## richardpl (Dec 16, 2010)

There are other problems with ndis driver for wpa_supplicant, if wlan device is gone, wpa_supplicant will start to consume all cpu cycles.

Sometimes ieee80211 state will got corrupted in such way that only wlan recreation will fix it.
I'm looking for solution.
So if wlan destroy/create doesn't fix this it is another problem.


----------



## Seeker (Dec 16, 2010)

I must admit, that I've never reached for *wlan0 destroy/create* as a solution.
Will try it here and there ...


----------



## Seeker (Dec 29, 2010)

With your latest ndisulator -> stable ...
*v4 *drivers -> I can reach 40-50% of max speed and there is no panic
*v5 *drivers -> I can reach 95-100% of max speed and there *is panic* upon scan, sometimes

Part of code, from v5, that enables max speed, should be transferred into v4 part of code.


----------



## richardpl (Dec 29, 2010)

Seeker said:
			
		

> Part of code, from v5, that enables max speed, should be transferred into v4 part of code.


There is no such code. There is nothing that can be transferred.

If speed of v4 on i386 is higher than on amd64 than that is something else....


----------



## Seeker (Dec 29, 2010)

No, no, I am talking about *amd64* in both cases, with your latest ndisulator -> stable ...
*i386* is completely out of context here, as I don't use it, for about few months already.


----------



## Seeker (Jan 3, 2011)

With *v5* ndis I can get max speed in both cases (over encrypted and unencrypted wifi connection), but it likes to panic ATM.
If wpa isn't used (open wifi), then I can get max speed with *v4* ndis too.
Does this fact, gives you any indication, where problem might be?

Will you implement a MONITOR mode too, besides 'sta' only mode?


----------



## richardpl (Jan 3, 2011)

Seeker said:
			
		

> With *v5* ndis I can get max speed in both cases (over encrypted and unencrypted wifi connection), but it likes to panic ATM.
> If wpa isn't used (open wifi), then I can get max speed with *v4* ndis too.
> Does this fact, gives you any indication, where problem might be?
> 
> Will you implement a MONITOR mode too, besides 'sta' only mode?



Got backtrace of panic? It would be very useful.

MONITOR mode could be possible only with 6.20 NDIS API.


----------



## Seeker (Jan 3, 2011)

richardpl said:
			
		

> Got backtrace of panic? It would be very useful.


First v5 panic
Second v5 panic


			
				richardpl said:
			
		

> MONITOR mode could be possible only with 6.20 NDIS API.


When will that happen?

Upon ndis0 detach I get:

```
ndis0: detached
Freed UMA keg was not empty (98 items).  Lost 5 pages of memory.
Warning: memory type ndis_ntoskrnl leaked memory on destroy (24 allocations, 1536 bytes leaked).
```


----------



## richardpl (Jan 5, 2011)

The 6.X NDIS API support is not trivial and I work on it when I can.

ntoskrnl memory leaks are known and currently not really important.

UMA leaks means we probably should flush queued workitems before halting/detaching.


----------



## Seeker (Jan 5, 2011)

Without WPA with *v4* ndis (open WiFi) connection newer break(need to destroy/create wlan0) and can reach full speed!
So problem occurs when wpa_supplicant is being used with *v4* ndis.
Do you have any kind of advice for me, based on provided info?


----------



## Seeker (Jan 6, 2011)

Well here is a breaktgrough ...
By using *v4* ndis, I've managed to reach almost max speeds and no connection breaks('EAPOL-Key Replay Counter did not increase - dropping packet'), when wlan0 is idle, by commenting out:

```
#eapol_version=2
```
In which case it defaults to 1.

Looks like *v4* likes older eapol_version *1*, while *v5* works with eapol_version *2*.


----------



## Seeker (Jan 6, 2011)

Wait, wait, my previous post was related to ndisulator code, dating from *22th*
I see you did a job, on it, last night.

So now I've download that latest code from *5*th and now, situation is quite the contrary:
Tested *v4* only:
With default eapol_version *1* I get ~33% of speed, reaching max of 50% of max speed.
By using 
	
	



```
eapol_version=2
```
, now I finally reach true max speed! 

Idle connection not tested, yet...

Great job!


----------



## richardpl (Jan 6, 2011)

I doubt that any of latest changes improved anything (expect in some strange, unexplored cases) so I believe that your testing environment is always different.

Drivers handle encryption themselves (maybe in hardware) and I yet have to make performance tests and confirm that problem can be fixed.

Note that on SMP there is big mess with locking stuff so it can hurt performance.


----------



## Seeker (Jan 7, 2011)

Unfortunately idle connection now again causes 'EAPOL-Key Replay Counter did not increase - dropping packet' with *both* eapol_versions 1 and 2



			
				richardpl said:
			
		

> I doubt that any of latest changes improved anything (expect in some strange, unexplored cases) so I believe that your testing environment is always different.



Nope! I'm using script which completely shuts down wpa, ndis_events, destroys wlan0 device and unloads modules, THEN reverts those steps and configures everything, always in a same ways as it is scripted and verbose.

I'm just stating cold facts.


			
				richardpl said:
			
		

> Drivers handle encryption themselves (maybe in hardware) and I yet have to make performance tests and confirm that problem can be fixed.
> 
> Note that on SMP there is big mess with locking stuff so it can hurt performance.



I'll go again for 22th code, well ... 23th.


----------



## richardpl (Jan 7, 2011)

So you have idle problems with any AP or with just specific configuration?

Can you change power management settings of AP?

You can change power management setting for client via ifconfig(8) but I'm not sure if net80211 handle this correctly.

Try to ping something behind AP every minute and this should be reliable workaround.


----------



## Seeker (Jan 9, 2011)

My AP is a FreeBSD box, configured via hostapd on ral0 device (Well ..., wlan0)
In response to yours


> I doubt that any of latest changes improved anything (expect in some strange, unexplored cases) so I believe that your testing environment is always different.


I've run my script, several times(_completely shuts down wpa, ndis_events, destroys wlan0 device and unloads modules, THEN reverts those steps and configures everything, always in a same ways as it is scripted and verbose._) and each time I've 5 times downloaded 80MB file from my AP(always getting same average speed).
So, conclusion is very ...
With *v4* ndis I always get transfer speed of ~230 kB/s, *BUT approx EACH 6th time I run my script*, I get ~745 kB/s
I've tested this with *both* eapol_versions 1 and 2 and concluded that those don't affect this in any way!
I simply have to run my script and test speed each time, UNTIL I get max speed, without changing ANY config.

NOTE however, that I dualboot WinXP and while in WinXP I don't have ANY issues with that same AP, only in FreeBSD over ndis.


----------



## Seeker (Jan 10, 2011)

There is also a LAG, whenever I initiate connection over wlan0.
Even if just resolving domain, it hangs for a while and sometimes results in _"unable to resolve host address"_

As my AP is 'ral', in which's man pages, section BUG, states:


> Host AP mode doesn't support client power save.
> Clients using power save mode will experience packet loss (disabling power saving on the client will fix this).


I can confirm this, as I had to do it under WinXP, long ago, to get max speed

'list scan' at my client, shows that AP is using Short Preamble and Power Save mode

```
My_AP       00:0e:2e:e5:0b:b9    6   54M -52:-96  100 EPS  WPA
```

At ndis-ed client, script sets power save to off:

```
# sysctl -d dev.ndis.0 | grep -i power
dev.ndis.0.MPC: Minimum Power Consumption [0=Disabled] [1=Enabled]
dev.ndis.0.PowerSaveMode: Power Save Mode [0=Disabled] [1=Enabled] [2=Fast]
cruiser# sysctl dev.ndis.0.MPC dev.ndis.0.PowerSaveMode
dev.ndis.0.MPC: 0
dev.ndis.0.PowerSaveMode: 0
```

At AP: 'list sta' states that client's CAPS are: EPS
Does this means 'sysctl dev.ndis.0.*' hooks don't work?

How do I make AP get rid of *P* flag in it's CAPS?
How do I force client into changing ndis properties? (manually editing drivers, before using ndisgen on them? TESTED->FAIL!)


----------



## richardpl (Jan 18, 2011)

For changing power save mode of AP you have ifconfig. For changing dev.ndis.0 you have sysctl and/or editor (edit in inf file default value for specific registry entry, note that you need to change all of them, not just first one, unless first one is actually your device and after that you must rebuild module and use this new module) but that one is irrelevant because they are overridden with OID from if_ndis anyway (by default it is always CAM).

I think it is better to have default registry values in file instead of module...


----------



## Seeker (Jan 18, 2011)

When on AP I issue:
[cmd=]ifconfig wlan0 -powersavemode[/cmd]
ndis-ed client still sees AP's CAPS: *EPS*
I simply can't turn *P* off on AP. I even looked into hostapd.conf for relevant entry, but nada!

I already tried changing .inf file before using ndisulator, so I wouldn't have to use [cmd=]sysctl dev.ndis.0[/cmd]

After module has been built, [cmd=]sysctl dev.ndis.0[/cmd] showed it was successful, but all issues remained: 1/3 of speed and broken connection when idle.

What should I do?


----------



## richardpl (Jan 18, 2011)

You disabled powersave on both AP and client?

What happens if you enable powersave on client?


----------



## Seeker (Jan 18, 2011)

It can't be disabled on AP, even when I issue that command via ifocnfig.


```
# ifconfig wlan0 powersave
```
I get lines *powersavemode CAM powersavesleep 100*
Speed remains 1/3, but during download, it start to diminish till it reaches 0 and download hangs.

Ignoring AP, under WinXP I gain full speed, when I turn off PowerSave, so to me, it looks like, ndis always uses drivers default and sysctl has no effect/is ignored.


----------



## richardpl (Jan 18, 2011)

You could modify ndis_powersave() in if_ndis.c to do nothing for start.


----------



## Seeker (Jan 18, 2011)

There is no such a function, but I've found *ndis_set_powersave()* and in it replaced everything with *return (0);*

Now ifconfig constantly shows *powersavemode CAM powersavesleep 100*, even when I did set again *return (1);*
I didn't recompile win_driver kernel module.

At first 3 shoots, I thought it worked as speed improved 2.5 times, but as I continued to test, speed remained at 1/3 as usual, when I repeatedly run my script (this time avoided "effect of eapol_versions")


----------



## richardpl (Jan 19, 2011)

What are results of pinging AP for 1 minute?

Well, use newer broadcom driver (do not initiate scan via ifconfig, wpa_supplicant will care for this).

If panic still happens (I had report that they do if CPUs are heavily used, compiling stuff) I will change how stuff is locked in sched queue and this should resolve such panics.

Also bugs at boot with newer drivers is gooing to be fixed soon. Actually driver does not cause panic any more but it also does not produce useful interface - forcing user to reload driver.


----------



## Seeker (Jan 20, 2011)

Panic occurs as soon as I run my script.
It happens when scan is being done via ifconfig to see which networks are available.
As this is laptop which roams, this is necessary, to know to which network is to be connected, based on written allowed/choosen SSIDs.
I.e; at caffe it would not start wpa and use dhcp, but at home it would be wpa + manual IP settings.

I reverted to v4 ndis, until this is fixed and will try make my AP unencrypted ...


----------



## richardpl (Jan 21, 2011)

wpa_supplicant supports both open and encrypted networks. Also you can use "list scan" because scan is done by kernel anyway (untill associated).


----------



## Seeker (Jan 26, 2011)

*No encryption test*

It is interesting to say that 'P' flag dissapeared from AP, when I commented out 'wpa=1' from hostapd.conf

```
...    6   54M -64:-96  100 ES
```
AP also reported client's caps as ES

Speed remained same, at 1/3, same as over encryption, but there were no breaks, just lags, so now I can compare it to:
In caffe, over unencrypted wifi, I get max speed without breaks.


----------



## Seeker (Jan 29, 2011)

With v4 I get ~220 Kb/s, but with v5, it drops to ~100 Kb/s + panic

I've also tried this patch, but nada.
I'm sick and tired of this wlan.

The fact is, when I boot via WinXP, I can get max speed, via it's v5 ndis.


Also, I suspect that ral0, might be buggy itself, as very rarely, I need to reboot AP, as ral0 stops responding.
And subjectively, even on WinXP, there seems to be lag, upon request and response

v4 driver ping times for 1 minute

One of this crashes was upon using v4
Also looks like I have problem with dumping(hangs)+NFS(I mount /usr/ports/distfiles from server on laptop and crash occurs when ports sources are being downloaded - initiated from laptop)+ndis
Third is VERY interesting!
1, 2, 3, 4


----------



## Seeker (Feb 4, 2011)

Just for fun, I wanted to find a way, to prove that *sysctl dev.ndis.0.** directives *are in effect*, once set.
So, I picked *sysctl dev.ndis.0.led**, as it is very visible one.
*Doesn't work!* Just a placebo effect!
Which explains why under ndisulator, I get a crappy sppeed - powersave mode remains ON.
This is what you should code now. Ensure that *sysctl dev.ndis.0.** is being really enforced.


----------



## richardpl (Feb 6, 2011)

You really do not know what you are talking about. Search in windows registry for those entries. Such entries are not documented at all and you need to reset device (so that entries are read again)...

Actually sysctl stuff is half-broken in such a way to no eat bunch of memory. Entries should be really read from files because sysctl entries are not alowed to have variable memory size ...


----------



## Seeker (Feb 7, 2011)

You are talking way to ambiguously (as you would talk to another ndisulator dev), that is, you assume knowledge on the other part ...

When you say _"Search in windows registry for those entries"_, do you mean in .inf file OR in running WinXP and then set and copy those entries in .inf file?
To what do you refer by *"reset device"*? That is achieved by ...?

Anyway, *I did* edited .inf file, to set a default values. (I've disabled PowerSaveMode and MinimumPowerConsumption)
Then I've used ndisulator on those, to create new kernel module.

Everything remains same, even sysctl now shows, that those are successfully set, to disabled default value.
Reading from above, *"that is irrelevant because they are overridden with OID from if_ndis anyway (by default it is always CAM)."*, looks like explanation to it, which I can't translate ...
Does it mean that even default written values in .inf file, get overwritten by ...?
To what is OID refering to?


----------



## richardpl (Feb 7, 2011)

OID is one of NDIS ways to call driver code. There are many OIDs ... Explore NDIS API (available on msdn) for more info.

I doubt you will find such entries in windows registry, better search complete disk.

One of you earlier report (3rd) is very interesting (locking issue). Did you reload driver module, without reloading ndis modules, in that case?


----------



## Seeker (Feb 8, 2011)

richardpl said:
			
		

> OID is one of NDIS ways to call driver code. There are many OIDs ... Explore NDIS API (available on msdn) for more info.
> 
> I doubt you will find such entries in windows registry, better search complete disk.


That does it! I am sick and tired of this! You said:

```
they are overridden with OID from if_ndis anyway (by default it is always CAM)
```
I confirm that, when I use v5 drivers, I can see CAM in ifconfig.
However, I would like to edit if_ndis code to NOT override my .inf edited directives.
Because of it, I've been editing *.inf* for nothing!



			
				richardpl said:
			
		

> One of you earlier report (3rd) is very interesting (locking issue). Did you reload driver module, without reloading ndis modules, in that case?


Nope. Script handles everything in perfect order.
Shutdown turns off wpa_supplicant, destroys wlan0, unloads ndis-ed_driver, kills ndis_events
Startup load ndis-ed_driver, starts ndis_events, creates wlan0, starts wpa_supplicant.


----------



## richardpl (Feb 8, 2011)

You can make any of set_powersave (or something like that) to just return 0. You actually already did that without any effect.


----------



## Seeker (Feb 16, 2011)

Under WinXP when I've enabled PowerSave mode, even icon indicated associated I couldn't even ping AP
So this might be something else ...

I can also see that ndisulator isn't being developed from begening of January

I've also talked to Weongyo Jeong, regarding BWN(4), which would make my card work and he said:


> No plan to add a code for PHY-N drivers.  It'll be happened by others not me.
> 
> regards,
> Weongyo Jeong


Who are "others", that are developing it?


----------



## richardpl (Feb 17, 2011)

Seeker said:
			
		

> Under WinXP when I've enabled PowerSave mode, even icon indicated associated I couldn't even ping AP
> So this might be something else ...


rum(4) driver in HOSTAP mode does not have support for power save stuff, also mentioned in manual page.
Do you have similar problems with other APs?



			
				Seeker said:
			
		

> I can also see that ndisulator isn't being developed from begening of January


I live in same country as you - does this ring a bell somehow?



			
				Seeker said:
			
		

> Who are "others", that are developing it?



I do not know.


----------



## richardpl (Mar 12, 2011)

Try to disable SMP: 
	
	



```
kern.smp.disabled=1
```
 in /boot/loader.conf.

This is not real fix but might show where the real problem is.


----------



## gk (Mar 28, 2011)

I have a related issue with bcm4353 on amd64.

Broadcom driver bcmwl564.sys ver 5.100.9.142 loads successfully and able to scan networks, unfortunately results are not stable, ssid list becomes empty periodically. But I'm not able to connect, status remains 'no carrier'

Setting debug.ndis=1 spawns console with the same messages, looks like driver returns NDIS_STATUS_ADAPTER_NOT_READY on OID_802_11_BSSID call. Any idea how to fix it?


```
ndis0: <Broadcom 802.11n Network Adapter> mem 0xfb300000-0xfb303fff irq 17 at device 0.0 on pci18
wlan0: Ethernet address: 78:e4:00:12:53:c4
ndis_request_info:req 0 sc 0xfffffe007efa4000 oid 0D010101 buf 0xfffffe0006b9fa00 buflen 6 written 0 needed 0 rval C0010011
ndis_request_info:req 0 sc 0xfffffe007efa4000 oid 0D010101 buf 0xfffffe00a6120360 buflen 6 written 0 needed 0 rval C0010011
ndis_request_info:req 0 sc 0xfffffe007efa4000 oid 0D010101 buf 0xfffffe010190e470 buflen 6 written 0 needed 0 rval C0010011
ndis_request_info:req 0 sc 0xfffffe007efa4000 oid 0D010101 buf 0xfffffe00a61200e0 buflen 6 written 0 needed 0 rval C0010011
ndis_request_info:req 0 sc 0xfffffe007efa4000 oid 0D010101 buf 0xfffffe0055f026d0 buflen 6 written 0 needed 0 rval C0010011
ndis_request_info:req 0 sc 0xfffffe007efa4000 oid 0D010101 buf 0xfffffe00a61201f0 buflen 6 written 0 needed 0 rval C0010011
ndis_request_info:req 0 sc 0xfffffe007efa4000 oid 0D010217 buf 0xffffff8014e20000 buflen 65535 written 124 needed 0 rval 00000000
ndis_request_info:req 0 sc 0xfffffe007efa4000 oid 0D010101 buf 0xfffffe0006b9f900 buflen 6 written 0 needed 0 rval C0010011
ndis_request_info:req 0 sc 0xfffffe007efa4000 oid 0D010101 buf 0xfffffe00a6120460 buflen 6 written 0 needed 0 rval C0010011
ndis_request_info:req 0 sc 0xfffffe007efa4000 oid 0D010101 buf 0xfffffe00a6120360 buflen 6 written 0 needed 0 rval C0010011
ndis_request_info:req 0 sc 0xfffffe007efa4000 oid 0D010101 buf 0xfffffe00a61203f0 buflen 6 written 0 needed 0 rval C0010011
ndis_request_info:req 0 sc 0xfffffe007efa4000 oid 0D010101 buf 0xfffffe00a6120520 buflen 6 written 0 needed 0 rval C0010011
ndis_request_info:req 0 sc 0xfffffe007efa4000 oid 0D010101 buf 0xfffffe00a60806d0 buflen 6 written 0 needed 0 rval C0010011
ndis_request_info:req 0 sc 0xfffffe007efa4000 oid 0D010101 buf 0xfffffe0055f02610 buflen 6 written 0 needed 0 rval C0010011
ndis_request_info:req 0 sc 0xfffffe007efa4000 oid 00010107 buf 0xffffff81b62868f4 buflen 4 written 4 needed 0 rval 00000000
ndis_request_info:req 0 sc 0xfffffe007efa4000 oid 00010107 buf 0xffffff81b62868f4 buflen 4 written 4 needed 0 rval 00000000
ndis_request_info:req 0 sc 0xfffffe007efa4000 oid 00010107 buf 0xffffff81b62868f4 buflen 4 written 4 needed 0 rval 00000000
ndis_request_info:req 0 sc 0xfffffe007efa4000 oid 0D010101 buf 0xfffffe00a6080300 buflen 6 written 0 needed 0 rval C0010011
ndis_request_info:req 0 sc 0xfffffe007efa4000 oid 0D010101 buf 0xfffffe0055f02610 buflen 6 written 0 needed 0 rval C0010011
ndis_request_info:req 0 sc 0xfffffe007efa4000 oid 0D010101 buf 0xfffffe00a60806e0 buflen 6 written 0 needed 0 rval C0010011
ndis_request_info:req 0 sc 0xfffffe007efa4000 oid 0D010101 buf 0xfffffe0055f02580 buflen 6 written 0 needed 0 rval C0010011
ndis_request_info:req 0 sc 0xfffffe007efa4000 oid 0D010217 buf 0xffffff8014c2b000 buflen 65535 written 124 needed 0 rval 00000000
ndis_request_info:req 0 sc 0xfffffe007efa4000 oid 0D010101 buf 0xfffffe00a6080a60 buflen 6 written 0 needed 0 rval C0010011
ndis_request_info:req 0 sc 0xfffffe007efa4000 oid 0D010101 buf 0xfffffe0006b9fa00 buflen 6 written 0 needed 0 rval C0010011
ndis_request_info:req 0 sc 0xfffffe007efa4000 oid 0D010101 buf 0xfffffe00a6120610 buflen 6 written 0 needed 0 rval C0010011
ndis_request_info:req 0 sc 0xfffffe007efa4000 oid 0D010101 buf 0xfffffe0055f028d0 buflen 6 written 0 needed 0 rval C0010011
ndis_request_info:req 0 sc 0xfffffe007efa4000 oid 0D010101 buf 0xfffffe00a6080410 buflen 6 written 0 needed 0 rval C0010011
ndis_request_info:req 0 sc 0xfffffe007efa4000 oid 0D010101 buf 0xfffffe00a61204b0 buflen 6 written 0 needed 0 rval C0010011
```

While trying to make it work I've also experienced occasional panics on *ifconfig wlan0 scan*. The following patch seems to fix it:


```
commit 180539b0bebaf32bbffb4b51fb198d9269ce66a7
Author: Gleb Kurtsou <gleb.kurtsou@gmail.com>
Date:   Sun Mar 27 23:39:38 2011 +0300

    Fix panic in ndis_get_bssid_list, clear result on error

diff --git a/sys/dev/if_ndis/if_ndis.c b/sys/dev/if_ndis/if_ndis.c
index e960cd9..967c749 100644
--- a/sys/dev/if_ndis/if_ndis.c
+++ b/sys/dev/if_ndis/if_ndis.c
@@ -2114,8 +2114,10 @@ ndis_get_bssid_list(struct ndis_softc *sc, struct ndis_80211_bssid_list_ex **bl)
 			return;
 		rval = ndis_get(sc, OID_802_11_BSSID_LIST, *bl, len);
 	}
-	if (rval)
+	if (rval) {
 		free(*bl, M_NDIS_DEV);
+		*bl = NULL;
+	}
 }
 
 static void
```

I've used recent ndisulator version from github.


----------



## richardpl (Mar 28, 2011)

It returns that because client is not associated.

I need more info, like what is AP running and what kind of authentication/encryption. Is ndisevents run in background?

If you want, you can make your clone/code appear on gitorious/github and then I only need to do merge of your fix into "official" tree.


----------



## gk (Mar 30, 2011)

richardpl said:
			
		

> It returns that because client is not associated.
> 
> I need more info, like what is AP running and what kind of authentication/encryption. Is ndisevents run in background?



It didn't work with and without ndis_events running. I was trying to connect to another notebook in open and WEP mode. I've just tried it against router with WPA2 and it connected successfully. It seemed to work but system froze up in ~10 minutes. This way be unrelated to ndisulator itself, I've seen several freezes during last week. I'll investigate it further. 

Thanks!


----------



## richardpl (Mar 30, 2011)

Deadlocks could be caused by introduction of spinlocks in dpc, worker and sched threads - revert those commits and see if that helps.

It is known bug that sched thread (only if your driver is actually calling NdisScheduleWorkItem()) is panicing very easy SMP systems with heavy CPUs usage. I dunno what is causing this - nothing points that miniport drivers are using non-resident memory (kernel stack) for storing such WorkItems.

amd64 is somehow problematic because some drivers use kuser_shared_data struct which should be updated periodicaly but that caused regression so such code is currently disabled. Amd64 support was broken for many years so reproducing bugs on i386 could point us at right direction.


----------



## Seeker (Nov 13, 2011)

Tell me, richardpl ...

Regarding 9.0
Is your ndisulator code, 100% in it?

Or do I have to continue, to download and install it, as I did up to now.


----------



## richardpl (Nov 13, 2011)

Nope, you will need to download, build, install and so on.
Head of master branch looks to be unstable/broken on SMP systems and I'm currently working on replacing ndisgen/ndiscvt with ndisload which will make easy loading of NDIS drivers. No more need to have source files to build modules from sys/inf files.

9.0 just have code that makes amd64 more usable (no more nasty panic on kldload). Safe use of float registers is not there yet, but I have patch floating around.


----------



## Seeker (Nov 14, 2011)

I am running 8.2-p4 amd64 with ndisulator from the beginning of January, when you had a pause for some time.
I am happy with it, except that after resume from S3 state, ndis0 doesn't appear, after I kldload ndisgen-ed driver.

```
# kldload bcmwl564
# ifconfig
pflog0: flags=141<UP,RUNNING,PROMISC> metric 0 mtu 33152
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=3<RXCSUM,TXCSUM>
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
        inet6 ::1 prefixlen 128
        inet 127.0.0.1 netmask 0xff000000
        nd6 options=3<PERFORMNUD,ACCEPT_RTADV>
```
I must restart (And yes ALL dirivers and all related to it was unloaded/stopped before entering S3 state)

Today I've thrown an eye, at yours site and I can see, there was a LOT of going on there.

There are 2 branches master and stable. Which one is for which BSD version?
You said, master is broken? Then I should go for stable?

*ndisload* replaces ndisgen?
With what do I _"feed"_ *ndisload*, if not with driver's sys/inf files?


----------



## richardpl (Nov 14, 2011)

Branch stable is for 8.X
For 9.X you could use older version of master.

Suspend/Resume issues could be partialy related to FreeBSD.

I'm not sure it they have been fixed in 9.0.

Workaround for me was using hw.pci.do_power_nodriver set to 3 and unloading relevant driver and reloading some irrelevant one which attaches to pci but works after resume.
That is workaround for bug where unloading driver will not put relevant device back to S3 state. I'm not sure it this bug have been fixed in 9.0

Right behaviour is to not depend on this hacks but when suspend/resume happens device need to be set into right DX state. NDISulator side of story have been fixed long ago.

Point of ndisload is that it will alow loading driver with only sys file(s). And if additional arguments are not specified (like to which device to attach) it will try to attach to all of them.


----------



## Seeker (Nov 24, 2011)

8.2-p4 amd64
I've used *STABLE*:


> Monday March 28 2011 19:25
> richardpl committed *761c8cf*
> Merge branch 'master' into stable




Worser then ever!

*NDIS v4:*
All is well, until I initiate download ...
Few sec(IF even that) and global FREEZE -> no err, panics, response, no anything!

*NDIS v5*: _(pics sucks!)_
Here I don't even need to initiate download:
http://www.starforce.biz/ndis5/ndis_5_panic_on_assoc.jpg

Once I've succeeded at 3%:
http://www.starforce.biz/ndis5/ndis_5_panic_on_download.jpg


----------



## richardpl (Nov 24, 2011)

Try new stable8 branch instead.

The SMP is broken it always was but it was not so obvious.


----------



## Seeker (Nov 26, 2011)

*5aaaa64*


```
cruiser# make build install clean
cd /usr/src/sys/modules/ndis && make
Warning: Object directory not changed from original /usr/src/sys/modules/ndis
cc -O2 -pipe -march=native -fno-strict-aliasing -D_KERNEL -DKLD_MODULE -nostdinc   -I. -I@ -I@/contrib/altq -finline-limit=8000 --param inline-unit-growth=100 -
-param large-function-growth=1000 -fno-common  -fno-omit-frame-pointer -mcmodel=kernel -mno-red-zone  -mfpmath=387 -mno-sse -mno-sse2 -mno-sse3 -mno-mmx -mno-3d
now  -msoft-float -fno-asynchronous-unwind-tables -ffreestanding -fstack-protector -std=iso9899:1999 -fstack-protector -Wall -Wredundant-decls -Wnested-externs
-Wstrict-prototypes  -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual  -Wundef -Wno-pointer-sign -fformat-extensions -c /usr/src/sys/modules/ndis/../..
/compat/ndis/subr_hal.c
/usr/src/sys/modules/ndis/../../compat/ndis/subr_hal.c: In function 'WRITE_PORT_ULONG':
/usr/src/sys/modules/ndis/../../compat/ndis/subr_hal.c:101: error: 'X86_BUS_SPACE_IO' undeclared (first use in this function)
/usr/src/sys/modules/ndis/../../compat/ndis/subr_hal.c:101: error: (Each undeclared identifier is reported only once
/usr/src/sys/modules/ndis/../../compat/ndis/subr_hal.c:101: error: for each function it appears in.)
/usr/src/sys/modules/ndis/../../compat/ndis/subr_hal.c: In function 'WRITE_PORT_USHORT':
/usr/src/sys/modules/ndis/../../compat/ndis/subr_hal.c:108: error: 'X86_BUS_SPACE_IO' undeclared (first use in this function)
/usr/src/sys/modules/ndis/../../compat/ndis/subr_hal.c: In function 'WRITE_PORT_UCHAR':
/usr/src/sys/modules/ndis/../../compat/ndis/subr_hal.c:115: error: 'X86_BUS_SPACE_IO' undeclared (first use in this function)
/usr/src/sys/modules/ndis/../../compat/ndis/subr_hal.c: In function 'WRITE_PORT_BUFFER_ULONG':
/usr/src/sys/modules/ndis/../../compat/ndis/subr_hal.c:122: error: 'X86_BUS_SPACE_IO' undeclared (first use in this function)
/usr/src/sys/modules/ndis/../../compat/ndis/subr_hal.c: In function 'WRITE_PORT_BUFFER_USHORT':
/usr/src/sys/modules/ndis/../../compat/ndis/subr_hal.c:130: error: 'X86_BUS_SPACE_IO' undeclared (first use in this function)
/usr/src/sys/modules/ndis/../../compat/ndis/subr_hal.c: In function 'WRITE_PORT_BUFFER_UCHAR':
/usr/src/sys/modules/ndis/../../compat/ndis/subr_hal.c:138: error: 'X86_BUS_SPACE_IO' undeclared (first use in this function)
/usr/src/sys/modules/ndis/../../compat/ndis/subr_hal.c: In function 'READ_PORT_USHORT':
/usr/src/sys/modules/ndis/../../compat/ndis/subr_hal.c:146: error: 'X86_BUS_SPACE_IO' undeclared (first use in this function)
/usr/src/sys/modules/ndis/../../compat/ndis/subr_hal.c: In function 'READ_PORT_ULONG':
/usr/src/sys/modules/ndis/../../compat/ndis/subr_hal.c:153: error: 'X86_BUS_SPACE_IO' undeclared (first use in this function)
/usr/src/sys/modules/ndis/../../compat/ndis/subr_hal.c: In function 'READ_PORT_UCHAR':
/usr/src/sys/modules/ndis/../../compat/ndis/subr_hal.c:160: error: 'X86_BUS_SPACE_IO' undeclared (first use in this function)
/usr/src/sys/modules/ndis/../../compat/ndis/subr_hal.c: In function 'READ_PORT_BUFFER_ULONG':
/usr/src/sys/modules/ndis/../../compat/ndis/subr_hal.c:167: error: 'X86_BUS_SPACE_IO' undeclared (first use in this function)
/usr/src/sys/modules/ndis/../../compat/ndis/subr_hal.c: In function 'READ_PORT_BUFFER_USHORT':
/usr/src/sys/modules/ndis/../../compat/ndis/subr_hal.c:175: error: 'X86_BUS_SPACE_IO' undeclared (first use in this function)
/usr/src/sys/modules/ndis/../../compat/ndis/subr_hal.c: In function 'READ_PORT_BUFFER_UCHAR':
/usr/src/sys/modules/ndis/../../compat/ndis/subr_hal.c:183: error: 'X86_BUS_SPACE_IO' undeclared (first use in this function)
*** Error code 1

Stop in /usr/src/sys/modules/ndis.
*** Error code 1
```


----------



## richardpl (Nov 26, 2011)

Fixed.


----------



## Seeker (Nov 26, 2011)

Finally I can say, this is a best release from you, up to now!

With ALL versions, there is initial lag present *upon request*, but my AP might be to blame.

I.e;
URL(_example.com/target_file_) at my AP is requested. Hangs ...
URL at my AP is redirected to _http://www.example.com/target_file_. Hangs ...
Big file is being fetched, with stable continuous speed.


Each tested with few creates/destroys to absolute 0
*NDISv4*
Works, but speed is always crappy ~150 Kb/s

*NDISv5*
Now *finally* I am always getting ~490 Kb/s and up to ~650 Kb/s, which is a Win7 score.

*S3 state*
Before entering S3, all is destroyed to absolute 0
Upon "comeback", during kldloading modules *ndis0* device doesn't appear anymore!
I've tried unloading and loading nvidia.ko module, as a side stuff, then tried again and nothing happens.


----------



## richardpl (Nov 26, 2011)

For example:


```
ndis0@pci0:2:3:0:       class=0x028000 card=0x120f1043 chip=0x431814e4 rev=0x02 hdr=0x00
    vendor     = 'Broadcom Corporation'
    device     = 'BCM4318 [AirForce One 54g] 802.11g Wireless LAN Controller'
    class      = network
```

this is output from *pciconf -lvc*.

As you can see there is no cap which would mention powerspec D0 - D3.

If you see this it means FreeBSD will not put device into D3 state upon suspend ever.

This is FreeBSD bug.

So does your device have cap line?


----------



## Seeker (Nov 27, 2011)

Why would it(D states), be relevant at all, if I destroy/create device via script.
When I turn on laptop, there doesn't exist anything WiFi related, so:[CMD="pciconf"]-lvc[/CMD], won't show ndis0, as it doesn't exist.
Exactly in this state, I enter into S3 state, immediately after power on and root login.
Upon combeack I: (*create ndis0 for a first time, from power on*)
[CMD="bcmwl564"]kldload[/CMD]
*ndis0* isn't created! Simply nothing happens!
This *isn't* a question/case, of going into S3,* WITH EXISTING ndis0*.

But for your curiosity:
[CMD="bcmwl564"]kldload[/CMD][CMD="pciconf"]-lvc[/CMD]

```
ndis0@pci0:12:0:0:      class=0x028000 card=0x000a1028 chip=0x432814e4 rev=0x03 hdr=0x00
    vendor     = 'Broadcom Corporation'
    device     = 'Broadcom 432AGN 802.11a/b/g/draft-n Wi-Fi Solution (BCM4321KFBG)'
    class      = network
    cap 01[40] = powerspec 2  supports D0 D1 D2 D3  current D0
    cap 09[58] = vendor (length 120)
    cap 05[e8] = MSI supports 1 message, 64 bit
    cap 10[d0] = PCI-Express 1 endpoint max data 128(128) link x1(x1)
```

*Problem 2:*
I took my laptop and went to the local caffe, which has unencrypted WiFi AP.

Once *scan is initiated*, with *NDISv5*, I get panics:
http://www.starforce.biz/ndis5/ndis5_scan_panic1.jpg
http://www.starforce.biz/ndis5/ndis5_scan_panic2.jpg
http://www.starforce.biz/ndis5/ndis5_scan_panic3.jpg
http://www.starforce.biz/ndis5/ndis5_scan_panic4.jpg
*NDISv5* obviously has a problem with *unencrypted* APs, during scan!

Then I've ndisulated *NDISv4* driver version and successfully connected, as there were no more panics.
However, I even here had a speed of ~150 Kb/s(same as at home AP), BUT there was no LAG as there is with my home AP!


----------



## richardpl (Nov 27, 2011)

It is FreeBSD bug because FreeBSD kernel is responsible for puting device into D3 state before suspend.
If you kldunload driver before suspend check that pciconf output for relevant device have "current D3".

If device is not put into D3 state before suspend it may not correctly wake up after resume - so trying to kldload driver will not work because driver will fail to initialize device and ndis0 will never appear again until you reboot machine.

I think that this bug have been fixed in FreeBSD 9.0

The panic is same as any other panic you have been posting all these years - it is SMP bug in NDISulator and not some trivial one - it is bug by DESIGN.

If it happens with UP kernel than I will try to fix it ASAP.

As always best way to report any bug is to report in on github page bellow where project is currently located.

There you can create own issue number and post whatever you want.

I do not want to abuse this forum for something it is obviously not made for.


----------



## Seeker (Nov 28, 2011)

richardpl said:
			
		

> It is FreeBSD bug because FreeBSD kernel is responsible for puting device into D3 state before suspend.
> If you kldunload driver before suspend check that pciconf output for relevant device have "current D3".
> 
> If device is not put into D3 state before suspend it may not correctly wake up after resume - so trying to kldload driver will not work because driver will fail to initialize device and ndis0 will never appear again until you reboot machine.
> ...


You gave me an explanation, of a case where ndis device *existed* before S3.
In my(second) case, ndis is created *for a first time, after resume* from S3.


			
				richardpl said:
			
		

> The panic is same as any other panic you have been posting all these years - it is SMP bug in NDISulator and not some trivial one - it is bug by DESIGN.


I wouldn't be able to classify a problem, from the pics.
Well ... if after *all these years*, it is still present, then it must be *really* deeply nested! 
OS level SMP or ndis level SMP?

I can't set device power state?
Also ...

```
# sysctl dev.ndis
```
Has no effect!


			
				richardpl said:
			
		

> If it happens with UP kernel than I will try to fix it ASAP.


What is a UP kernel?!


----------



## richardpl (Nov 28, 2011)

It is completly irrelevant if or when ndis0 is created, ndis0 is just driver attached to device on pci bus (in your case).
Device must be put in S3 state when suspending. It can not be done from NDISulator in any way. NDISulator can only say to driver(and that is exactly what it is doing for a while) that device is going to enter S3 state and then driver prepare itself (stoping any actions on his level and preparing device for S3 state).
Actual change of device power state is done by FreeBSD pci bus code.

UP is kernel without SMP in kernel conf.

UP kernel does not make use of multiple CPUs at same time.

There is also PREEMPTION which means that kernel scheduler can stop some kernel threads in middle of their work and resume other threads ....

What you mean that sysctl on dev.ndis have not effect?

dev.ndis will have entries after creating at least one succesfully operating & attached driver to device (ndis0).


----------



## Seeker (Nov 28, 2011)

I came to a point of associating to AP and transferring few files (which implies ndis0)
Now I've tried to set it's various options:

```
# sysctl dev.ndis.0.*=*
```
None of them takes any effect. Placebo.


----------



## richardpl (Nov 28, 2011)

That never worked. (I mean changing sysctl values after device is attached.)

sysctl entries for ndis are created after module is loaded and device have driver attached.
But sysctls values are read from entries in inf file (same inf file you used while creating module with ndisgen) and also are read only once (when ndis0 is attached) so changing sysctl values this late (after ndis0 attached) would give you nothing.

This is yet another bug by design in NDISulator. The only way you can make sysctl values actually useful is modifying/adding entries in original inf file and recreating module with ndisgen.

You can test this if you set:

`# sysctl debug.ndis=0x8`

*Before!!!* loading bcmw*.ko module.

I think there is at least one entry like NetworkAddress which is read *after* you create wlan0 device from ndis0. But this one use specific call and it just happens that we mapped value to sysctl one.

Note that you need to set NetworkAddress(MAC) twice: once via sysctl and second one via ifconfig:

`# ifconfig ndis0 ether a1b2c3d4e5f6`

If they are not same you will not have operational ndis0.

It is possible that you can set NetworkAddress only once, you need to reboot if you want to change it again, it probably depends on device firmware ...


----------



## Seeker (Dec 8, 2011)

Thx!
I'll play with it when I'll have time.

In a meantime:
*v4* and *v5*
Both have issue with:

```
# ifconfig wlan0 scan
```

*v4* scan stops almost instantly, after this appears:

```
wlan0: ieee80211_new_state_locked: pending SCAN -> RUN transition lost
```
, returning only 1 and always SAME SSID ignoring dozen others! (depending on location)

*v5* will panic instead (you said it is SMP and ndis design)

*v4* is slower, but more stable (won't bring machine down, with itself)


Tried 3 APs


----------

