Wireless scan with atheros pcmia card

Under development: PCMCIA, wireless, etc.
Post Reply
Message
Author
mbe
Posts: 18
Joined: Sun 20 Apr 2008, 08:34

Wireless scan with atheros pcmia card

#1 Post by mbe »

Hi Dougal

The new wizard (20th March 2009) is the first version for a very long time that initiates a scan using my phillips SNN6500 pcmcia card (using ath_pci) but it still doesn't report more than one AP even on repeat scans. My AP with a broadcast SSID is over 30dB stronger than my neighbours hidden SSID AP but his is the only one that appears.

Running "iwlist ath0 scan" manually from a console happily brings up several cells and I can connect manually without problems so this is not a driver issue.

The new wizard works every time on my HP Compaq 6715B laptop with an integrated broadcom chipset so I wondered if the problem relates to the fact that the phillips card is pcmcia.

I found that changing line 1750 of wag-profiles.sh from "usleep 10000" to "sleep 5" solves the problem without inducing too much delay. 3 cells then appear and I can pick the one I need. - "sleep 3" works but only sometimes.

Hopefully this will give you a clue as to the real cause. If not then could we get this change included as a temporary workaround for the next version of the wizard, maybe with an option to change the delay for those not having success.

Thanks

Martin
Last edited by mbe on Sat 28 Mar 2009, 12:50, edited 1 time in total.

mbe
Posts: 18
Joined: Sun 20 Apr 2008, 08:34

post in wrong place ?

#2 Post by mbe »

This is pcmcia but would be better moved to the Network wizard thread
Thanks
Martin

User avatar
Dougal
Posts: 2502
Joined: Wed 19 Oct 2005, 13:06
Location: Hell more grotesque than any medieval woodcut

Re: Wireless scan with atheros pcmia card

#3 Post by Dougal »

mbe wrote:My AP with a broadcast SSID is over 30dB stronger than my neighbours hidden SSID AP but his is the only one that appears.

Running "iwlist ath0 scan" manually from a console happily brings up several cells and I can connect manually without problems so this is not a driver issue.
This is something very strange that I also encountered: the first time I tried using it at home, it found nothing, I chose "yes" on the "try again" dialog and still it returned nothing -- only after I was back again at the main window and pressed "scan" again did it find the network. And it actually tried twice every time before reporting failure, so in fact it took at least 5 scans to find something.
And all the while running scans in a terminal worked!
So it seems like somehow the scan doesn't work well from within the script -- which makes no sense at all!

I found that changing line 1750 of wag-profiles.sh from "usleep 10000" to "sleep 5" solves the problem without inducing too much delay. 3 cells then appear and I can pick the one I need. - sleep 3 works but only sometimes.
This is also strange... the sleep there is because I run the scan twice, in case it will work better the second time -- originally the wizard only tun one scan, so I'd imagine it wouldn't have found it anyway...
I'll add the "sleep 5" for pcmcia cards. Also at boot time.
What's the ugliest part of your body?
Some say your nose
Some say your toes
But I think it's your mind

mbe
Posts: 18
Joined: Sun 20 Apr 2008, 08:34

Wireless wizard and scanning

#4 Post by mbe »

[/quote]I'll add the "sleep 5" for pcmcia cards. Also at boot time.

Great Thanks Dougal

Previously I have connected manually with wpa_supplicant but I am posting this from a connection made entirely via the latest wizard with the workaround added manually.

I tried moving "sleep 5" to line 1746 and also then commenting out the second scan - in both cases the wizard works just as well for me so I think this workaround must simply be allowing time for things to settle after resetting the interface.

Hope this helps

Martin

User avatar
Dougal
Posts: 2502
Joined: Wed 19 Oct 2005, 13:06
Location: Hell more grotesque than any medieval woodcut

Re: Wireless wizard and scanning

#5 Post by Dougal »

mbe wrote:I tried moving "sleep 5" to line 1746 and also then commenting out the second scan - in both cases the wizard works just as well for me so I think this workaround must simply be allowing time for things to settle after resetting the interface.

Hope this helps
Thanks, Martin, that actually helps a lot...
It's rather hard to know what is the cause of trouble and I can't just add sleeps everywhere "just in case", as users then complain that when they boot the network isn't connected by the time X starts...
I've moved the sleep for pcmcia devices to before we start to scan at all (I just hope that /sys/class/net/ath0/device/modalias actually starts with "pcmcia:" and not "pci:"...).
It is a shame, though, that we don't have a decent way to know when the device is "settled"... rather than always forcing the (arbitrary) 5 second sleep.
What's the ugliest part of your body?
Some say your nose
Some say your toes
But I think it's your mind

mbe
Posts: 18
Joined: Sun 20 Apr 2008, 08:34

detecting pcmcia

#6 Post by mbe »

Dougal

Thanks for following up on this. I assume you were planning to differentiate between a pci and pcmcia card by looking in modalias unfortunately in my case the one line file starts pci: - maybe there is another way ? Alternatively I suppose you could keep the arbitrary sleep just in the retry loop ?

Martin

User avatar
Dougal
Posts: 2502
Joined: Wed 19 Oct 2005, 13:06
Location: Hell more grotesque than any medieval woodcut

Re: detecting pcmcia

#7 Post by Dougal »

mbe wrote:I assume you were planning to differentiate between a pci and pcmcia card by looking in modalias unfortunately in my case the one line file starts pci: - maybe there is another way ?
Maybe if you can find another way to differentiate... I don't have a pcmcia slot.
The modalias is a string identifying your HW, which is used by modprobe to match a module to it (by comparing it with /lib/modules/$uname -r)/modules.alias ).
Maybe if you can look in /sys and find some link to pcmcia... I think there is a pcmcia dir in one of the top dirs in /sys, but we need to get to it via /sys/class/net... maybe what the link /sys/class/net/ath0/device points to?? I'm doubtful. And it's not like the module is any help (ath_pci, ffs...).
Anyway, maybe if you try rummaging in /sys/class/net/ath0/device and find some hint in one of the text files there...
What's the ugliest part of your body?
Some say your nose
Some say your toes
But I think it's your mind

mbe
Posts: 18
Joined: Sun 20 Apr 2008, 08:34

pcmcia

#8 Post by mbe »

There is a pcmcia_socket folder in /sys/class and in my case this contains two folders pcmcia_socket0 and pcmcia_socket1 but I can't see anything very useful inside that might specifically pick out pcmcia for wireless and these two folders are present even on a cold restart with no pcmcia cards installed.

With the wireless card present there is a uevent file in /sys/class/net/ath0/device that may help if you can make sense of PCI_CLASS

DRIVER=ath_pci
PCI_CLASS=20000
PCI_ID=168C:001B
PCI_SUBSYS_ID=1113:D301
PCI_SLOT_NAME=0000:02:00.0
MODALIAS=pci:v0000168Cd....xx

Barry did some work on hotplugging pcmcia a while ago but got very differnt PCI_CLASS numbers see http://www.puppylinux.com/blog/?viewDetailed=00158

I tried an alternative approach - if I pull my USB adaptor card out slightly so only the wireless card is in use, the 20th March wizard mostly finds one (undesired) AP on the first or second scan. If I also comment out the two cardctl lines in the wizard then I can build up the number of detected APs on each scan until I finally see mine (number 6 on the list currently). With the USB pcmcia card adaptor installed as well I get "no network found" using the wizard unless I add the sleep (even if I comment out the cardctl lines). I assume this means time following reset is marginal with a single card and too fast with both.

User avatar
Dougal
Posts: 2502
Joined: Wed 19 Oct 2005, 13:06
Location: Hell more grotesque than any medieval woodcut

#9 Post by Dougal »

With the wireless card present there is a uevent file in /sys/class/net/ath0/device that may help if you can make sense of PCI_CLASS

DRIVER=ath_pci
PCI_CLASS=20000
No such luck... "2" means networking, "200" means ethernet. So it simply treats it as a normal pci device (hence the pci: modalias and also the fact that you'll see it in the output of lspci).

However, I'm not giving up yet!
PCI_SLOT_NAME=0000:02:00.0
This probably means that /sys/class/net/ath0/device points to 0000:02:00.0 and that

Code: Select all

readlink /sys/class/net/ath0
probably gives something like

Code: Select all

../../devices/pci0000:00/0000:00:1e.0/0000:02:00.0/net/ath0
So maybe if you look at what /sys/class/pcmcia_socket/pcmcia_socket0 and pcmcia_socket1 you'll get something like

Code: Select all

../../devices/pci0000:00/0000:00:1e.0/pcmcia_socket/pcmcia_socket0
(there might be one more dir between "0000:00:1e.0" and "pcmcia_socket")

Get what I'm aiming for? All we need to do is manage to trace one pcmcia_socket to the same pci sub-device (i.e. "0000:00:1e.0" in my case) as ath0... Simple!
I tried an alternative approach - if I pull my USB adaptor card out slightly so only the wireless card is in use, the 20th March wizard mostly finds one (undesired) AP on the first or second scan. If I also comment out the two cardctl lines in the wizard then I can build up the number of detected APs on each scan until I finally see mine (number 6 on the list currently). With the USB pcmcia card adaptor installed as well I get "no network found" using the wizard unless I add the sleep (even if I comment out the cardctl lines). I assume this means time following reset is marginal with a single card and too fast with both.
Hmm. I wonder why the second card should matter when we don't touch it at all... For the sake of not slowing things down unnecessarily, I could always add a simple test to see if there's another network adaptor around... but first things first -- let's finish the pcmcia detection part and get the wizard working properly.

Anyway, you did mention something that might be worth changing: the eject/insert sequence.
Tempestuous suggested adding that a while ago, as it can sometimes help reset cards. It might be worth removing, but it shouldn't be necessary: that is supposed to be a last-resort kind of attempt to manage to find something. What I want is to be able to add a sufficient sleep so we don't get there at all (unless the card really needs resetting).
What's the ugliest part of your body?
Some say your nose
Some say your toes
But I think it's your mind

mbe
Posts: 18
Joined: Sun 20 Apr 2008, 08:34

Testing for pcmcia cards

#10 Post by mbe »

Firstly a test run using the new wizard..

With both pcmcia cards inserted I confirmed that a manual scan instantly brings up two cells (mine first). However running the March 29th wizard "as is" I can't detect any networks. (same with April 1st.)

I tested the new approach to adding selective sleep for pcmcia by changing "pcmcia:" to "pci:" on all the new test lines (204,222 & 315) in rc.network and of course line 1629 in wag_profiles.sh. The extra delays are evident and I see two progress bars on each scan attempt but I mostly get "no networks found" with occasionally 1 AP (not mine) found after multiple retrys. However as soon as I added sleep 5 on line 1773 (immediately before iwlist...) the wizard immediately detected both APs and I was able to connect. I did the same mods with April 1st version and got the same results -adding sleep 5 before the first iwlist or changing sleep 1 to sleep 5 before the second iwlist did the trick.

Reverting to the unchanged March 29th wizard with sleep 5 on line 1773 gave only one (strongest AP) but adding sleep 5 on line line 1778 gave both APs on most scans. This suggests that the March 29th "pre-settle" does help but that the most significant sleeps are currently in the wrong place and of course pcmcia detection doesn't work..

Regarding detection ...

With just the pcmcia wireless card installed,
/sys/class/net/ath0/device/driver contains a folder that is a symbolic link to ../../../../devices/pci0000:00/000:0a.0/0000:02:00.0

More simply though
sys/class/net/ath0 contains a folder "device" that is a symbolic link to ../../../0000:02:00.0

and /sys/class/pcmcia_socket/pcmcia_socket0/device contains a folder 0000:02:00.0 and within this folder the uvent file contains the same PCI_SLOT_NAME :0000:02:00.0

If I swap the card to other slot...
/sys/class/net/ath0/device/uvent changes and contains

DRIVER=ath_pci
PCI_CLASS=20000
PCI_ID=168C:001B
PCI_SUBSYS_ID=1113:D301
PCI_SLOT_NAME=0000:06:00.0
MODALIAS=pci:v0000....xx

the folder in /sys/class/pcmcia_socket/pcmcia_socket0/device no longer contains a numbered folder and a search of /sys/class/pcmcia_socket/pcmcia_socket1/device reveals a new folder named 0000:06:00.0 and within this the uevent file is as above.

Putting the card back into the orginal slot and inserting a usb adaptor card into the spare slot
/sys/class/pcmcia_socket/pcmcia_socket0/device contains a folder named 0000:02:00.0
/sys/class/pcmcia_socket/pcmcia_socket1/device contains a folder named 0000:06:00.0 (plus 0000:06:00.1 and 0000:06:00.2 which I assume are the USB ports)

So it looks like a test that looks in /sys/class/net/ath0/device and finds the pci slot name from file uevent can then check whether a folder with this name exists in either /sys/class/pcmcia_socket/pcmcia_socket0/device or pcmcia_socket1/device will determine whether ath_pci is servicing a pci or pcmcia device.

Maybe it would be easier to just add a tick box for extra delay with pcmcia cards and move the sleep ?

Martin
Last edited by mbe on Sat 04 Apr 2009, 07:45, edited 1 time in total.

User avatar
Dougal
Posts: 2502
Joined: Wed 19 Oct 2005, 13:06
Location: Hell more grotesque than any medieval woodcut

#11 Post by Dougal »

This suggests that the March 29th "pre-settle" does help but that the most significant sleeps are currently in the wrong place and of course pcmcia detection doesn't work..
D'oh!
My mistake. Since I decided to add the pcmcia progressbar, I put the sleep before buildScanWindow -- but that has the cleanup code in it!

Considering that we're only doing scans in showScanWindow, I think it's safe to just move the cleanup to its beginning -- do it only once, so the repeated scans actually are likely to be more effective... Only thing is I'll add a ifconfig down/up, as someone reported it is needed for configuration to work (see rc.network).
(I'm not sure if to do another cleanup after the eject/insert, though...)

BTW, should I leave the "pcmcia settle" progressbar? I just didn't know if users won't wonder when nothing happens for 5 seconds...
So it looks like a test that looks in /sys/class/net/ath0/device and finds the pci slot name from file uevent can then check whether a folder with this name exists in either /sys/class/pcmcia_socket/pcmcia_socket0 or pcmcia_socket1 will determine whether ath_pci is servicing a pci or pcmcia device.
Ha! Great. That should be pretty simple:

Code: Select all

if PciSlot=$(grep -F 'PCI_SLOT_NAME=' /sys/class/net/$INTERFACE/device/uevent) ; then
  if [ -d /sys/class/pcmcia_socket/pcmcia_socket[0-9]/${PciSlot#PCI_SLOT_NAME=} ] ; then
    IsPCMCIA=yes
  fi
fi
Maybe it would be easier to just add a tick box for extra delay with pcmcia cards and move the sleep ?
Naa, we want everything automatic! Plus, we use it in rc.network.

I think we gor us a winner here!
What's the ugliest part of your body?
Some say your nose
Some say your toes
But I think it's your mind

mbe
Posts: 18
Joined: Sun 20 Apr 2008, 08:34

Testing ath_pci for PCMCIA

#12 Post by mbe »

Oops - I missed "device" from the path in my summary so have edited the post.

Neat script - I have corrected my error on the second line:

if PciSlot=$(grep -F 'PCI_SLOT_NAME=' /sys/class/net/$INTERFACE/device/uevent) ; then
if [ -d /sys/class/pcmcia_socket/pcmcia_socket[0-9]/device/${PciSlot#PCI_SLOT_NAME=} ] ; then
IsPCMCIA=yes
fi
fi

I tried this script in isolation (just added a couple of "echoes") and both tests work well on my machine so I think you do have a winner.

Regarding the wizard, adding ifconfig up is certainly a good idea - my card sometimes needs this. Personally I like the "settle" progress bar - makes for a more professional impression

Edit - I just tried the above mod on the April 2nd wizard - Looks good and seems to work a treat.

Great work

Martin

User avatar
Dougal
Posts: 2502
Joined: Wed 19 Oct 2005, 13:06
Location: Hell more grotesque than any medieval woodcut

Re: Testing ath_pci for PCMCIA

#13 Post by Dougal »

mbe wrote:Oops - I missed "device" from the path in my summary so have edited the post.
Ok, I just uploaded a fixed version of the wizard.
I think this and the moving of the cleanup to before the entire scan function (and adding the ifconfig down/up) should solve a lot of problems. Presuming people actually use it...
What's the ugliest part of your body?
Some say your nose
Some say your toes
But I think it's your mind

Post Reply