Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - How can I access wireless network device (Atheros): (13 Items)
   
How can I access wireless network device (Atheros)  
I'm trying to migrate Atheros's Radio Test Reference tool to QNX system(ART tool for Windows).
So as to implement this tool, I need to access the Atheros device but it seems like impossible to access atheros device 
driver from user application in QNX with io-pkt. 

- Is there any way to access the athero's wireless network driver directly? I need to access the h/w register in the 
WLAN chipset.
(It is not on the /dev directory)

- Does io-pkt provide any way to control athero's WLAN chipset ?

Thanks,
Dooeui

RE: How can I access wireless network device (Atheros)  
Hello:

	The answer to this question really is "it depends".  If the test
tool needs to work in conjunction with the driver, that is, it requires
access to registers that the driver has to read / write to and must
synchronize access with the driver, then the only way to implement it will
be to take the driver source and modify it yourself.  This will likely
include the addition of some sort of user interface to feed information from
the driver to a user land application.

If the test tools only reads registers and doesn't care about what the
driver does (e.g. if it's a monitoring tool only), you can create a user
application that does all of the PCI things necessary to figure out where
the Atheros card is and then access the registers directly from the user
app.  Again, this would assume that the test tool and the driver don't
conflict with one another.

Given that the driver completely hides all hardware details from the stack,
the stack doesn't provide any mechanism for accessing hardware registers
directly.  However, as a final thought, you could provide a customized ioctl
interface for getting / setting registers specifically. 

I've just taken a look through the source code (trunk/sys/dev/ic/ath.c) and,
funnily enough, the code says that this mechanism is already supported.  If
you look at the ath_ioctl_diag function, it says "This is used by various
tools to do things like retrieve register contents for debugging".  So it
looks like at least a register read interface is supported through the ioctl
already.  Does the utility that you're trying to port have any code which
makes ioctls using SIOCGATHDIAG?  This goes into the ath_ioctl function
which calls into ath_hal_getdiagstate which is a macro that calls the HAL
getDiagState function which maps to an ath_hal_getdiagstate function in the
HAL.  All fairly complicated...  

I'm guessing that this tool came directly from Atheros, so I'd recommend
getting back in touch with them and asking for a version of the tool which
supports the SIOCGATHDIAG ioctl mechanism for register access through the
HAL.

As a side note, the source layout for NetBSD drivers is a bit strange in
that the dev/driver directory contains only initialization source for
connecting the driver into the stack.  If you look at the common.mk file in
the driver directory, you can see that it actually requires a number of
different source files (ath.c, ath_netbsd.c, athrate-sample.c, etc.) which
are located in either dev/ic or dev/pci in addition to an athhal.o file to
actually build the driver.  The HAL object file is either the public NetBSD
file or an in-house one that was generated from the Atheros source directory
(which we are currently not able to release publicly because we are sorting
out licensing details).

	Hope that helps,
		Robert.


-----Original Message-----
From: Dooeui Hong [mailto:dooeui@lge.com] 
Sent: Tuesday, January 08, 2008 3:43 AM
To: drivers-networking
Subject: How can I access wireless network device (Atheros)


I'm trying to migrate Atheros's Radio Test Reference tool to QNX system(ART
tool for Windows).
So as to implement this tool, I need to access the Atheros device but it
seems like impossible to access atheros device driver from user application
in QNX with io-pkt. 

- Is there any way to access the athero's wireless network driver directly?
I need to access the h/w register in the WLAN chipset.
(It is not on the /dev directory)

- Does io-pkt provide any way to control athero's WLAN chipset ?

Thanks,
Dooeui



_______________________________________________
Networking Drivers
http://community.qnx.com/sf/go/post4113
Re: RE: How can I access wireless network device (Atheros)  
Thanks for your reply.

I have another questions. 
So as to meet our customer's request, our WiFi module should have at least 5 CTL group.  I'd like to know whether io-
pket or QNX Atheros WiFi driver provides any method of selecting CTL group in WiFi module.

Thanks,
Dooeui
RE: RE: How can I access wireless network device (Atheros)  
Hi Dooeui:
	This is my unfamiliarity with WiFi coming through...  What is meant
by a "CTL group"?

		Robert.

-----Original Message-----
From: Dooeui Hong [mailto:dooeui@lge.com] 
Sent: Friday, January 11, 2008 3:52 AM
To: drivers-networking
Subject: Re: RE: How can I access wireless network device (Atheros)

Thanks for your reply.

I have another questions. 
So as to meet our customer's request, our WiFi module should have at least 5
CTL group.  I'd like to know whether io-pket or QNX Atheros WiFi driver
provides any method of selecting CTL group in WiFi module.

Thanks,
Dooeui

_______________________________________________
Networking Drivers
http://community.qnx.com/sf/go/post4210
Re: RE: RE: How can I access wireless network device (Atheros)  
CTL stand for "Conformance Test Limits".

It is WiFi power related calibration parameter sets which are stored in EEPROM of WiFi module. As I understand, usually 
a WiFi module has multiful set of CTL group to support multiful nations or multiful situation(such as power regulation).
 

I'm attaching a file to help your understanding. 

What I'd like to know is, Does io-pkt or Atheros wifi driver support selection of CTL group ? 

Our moudle need to have at least 5 CTL paramter set. and need to select one of them by application. 

Please let me know how it could done.
Attachment: Text CTL_document.doc 59 KB
RE: RE: RE: How can I access wireless network device (Atheros)  
Hi Dooeui:

	That helps considerably.  I started looking through the source for
the driver (which I believe that you also have) and it looks like there is
support in there for regulatory domains.

In sys/dev/ic/ath.c, you will see:
	ath_attch which calls:
		ath_getchannels which calls:
			ath_hal_init_channels which is in the hal.

The ath_hal_init_channels is in the regdomain.c file in the Atheros HAL
directory and this is what seems to take care of the regulatory settings on
a per country basis. (As a side note, you'll also find in the "diag"
directory code showing how to read and write registers using the ioctl
interface that may help you with your previous question about porting the
Atheros testing application).

Is setting either the regulatory domain sufficient for determining the
appropriate CTL? 

There is a sysctl interface that allows some of the atheros driver options
to be changed on the fly.  With the Atheros driver loaded, if you type

# sysctl -a | grep ath

You'll see a list of options that the Atheros driver presents through the
sysctl interface.  Some of these are read/writable (sysctl -w variable=value
to change then) and some are read only.

It appears that the regdomain is read/writable (although I couldn't seem to
make it work with my particular card, possibly due to the EEPROM contents).
The country code isn't writable.

While it is relatively simple to make the country code writable, one has to
question why it wasn't made writable in the first place and I believe this
is because the getchannels / init_channels calls (which seems to be the only
place which uses the country code) are only called from the attach function
which is only called on startup.

This should be a question that is addressed to Atheros directly at this
stage.  There seems to be a tight tie in between the EEPROM values and
allowable Regulation Domains and Country Codes, so a mechanism for changing
them should be approved by them.  Given that our interfaces into the stack
are identical to those provided by NetBSD it should be as simple as asking
them the mechanism for how these values should be adjusted in NetBSD
(unfortunately, we won't have the technical contacts into Atheros to ask
those questions ourselves until the licensing issues are resolved).  It
would be relatively simple to add a command line option specifying the
country code if this is deemed to be the easiest way to go, but this should
be confirmed by Atheros.  Maybe the regdomain sysctl interface will be
sufficient if the hardware supports it.

I'd also strongly recommend having a look through the driver source as a
means to understanding what's buried in the driver (specifically the HAL
layer).  Unfortunately, as is often the case, we didn't receive any detailed
documentation describing the HAL and its usage so our knowledge is limited
to the code paths that were necessary for porting rather than the overall
HAL functionality.

	Hope that helps a bit,
		Robert.


-----Original Message-----
From: Dooeui Hong [mailto:dooeui@lge.com] 
Sent: Monday, January 14, 2008 7:55 PM
To: drivers-networking
Subject: Re: RE: RE: How can I access wireless network device (Atheros)


CTL stand for "Conformance Test Limits".

It is WiFi power related calibration parameter sets which are stored in
EEPROM of WiFi module. As I understand, usually a WiFi module has multiful
set of CTL group to support multiful nations or multiful situation(such as
power regulation). 

I'm attaching a file to help your understanding. 

What I'd like to know is, Does io-pkt or Atheros wifi driver support
selection of CTL group ? 

Our moudle need to have at least 5 CTL paramter set. and need to select one
of them by application. 

Please let me know how it could done.


_______________________________________________
Networking Drivers
http://community.qnx.com/sf/go/post4292
Re: RE: RE: RE: How can I access wireless network device (Atheros)  
Dear QNX team

I spent some times to analyze and test atheros driver and "diag" applications. Robert's advice helped me a lot.

First sysctl I/F seems like works fine but it only provide limited access. 

So I ported the "dumpregs" in "diag" directory. (Actually I just compiled it with minimum modifications).

Anyway I found that it's first "ioctl" which get "devID" won't return correct value. 

---------------------------------------------------------------------------
atd.ad_id = HAL_DIAG_REVS
atd.ad_out_data = (caddr_t) &revs;
atd.ad_out_size = sizeof(revs);

if ( ioctl(s, SIOCGATHDIAG, &atd) < 0 )
    err(1, atd.ad_name);

switch (revs.ad_devid){
   ...
}
---------------------------------------------------------------------------

The devid should be"0x0013" in our system. But it returns dummy value. 
I checked the value at ./dev/ic/ath.c -  ath_ioctl_diag().
"outdata" buffer has correct value "0x0013" but it is not correctly delivered to ioctl. 

I checked the value of "outdata" at following lines.
---------------------------------------------------------------------------
...
if(ath_hal_getdiagstate(...){
  ...
  if(outdata !=NULL)
#ifndef __QNXNTO__
  error=copyout(outdata, ad->ad_out_data, ad->ad_out_size_
#else
  error=copyout(outdata, ad + 1, ad->ad_out_size);
#endif

}
---------------------------------------------------------------------------

Also I  cannot understand why QNXNTO code use "ad+1" instead of "ad->ad_out_data". 


Anyway causing by this problem, "SIOCGATHDIAG" w/ioctl won't work. The data is not deliverd to ioctl at all. 

I insert some log and observe it during normal operaton but "SIOCGATHDIAG" is never reqeusted during normal operation. 
I think that this option is not tested when QNX team porting atheros driver. 

Please give me any advice how can I fix it. 

In addition to that, I have one more question. 
I inserted normal "printf" in the driver source code and found that the printf in driver soruce code works like as "slog
" instead of "printf". So I checked it through "sloginfo". Could you explain why this kind of thing is happened? 

Best Regards,
Dooeui
Re: RE: RE: RE: How can I access wireless network device (Atheros)  
On Tue, Jan 29, 2008 at 02:42:42AM -0500, Dooeui Hong wrote:
> Dear QNX team
> 
> I spent some times to analyze and test atheros driver and "diag" applications. Robert's advice helped me a lot.
> 
> First sysctl I/F seems like works fine but it only provide limited access. 
> 
> So I ported the "dumpregs" in "diag" directory. (Actually I just compiled it with minimum modifications).
> 
> Anyway I found that it's first "ioctl" which get "devID" won't return correct value. 
> 
> ---------------------------------------------------------------------------
> atd.ad_id = HAL_DIAG_REVS
> atd.ad_out_data = (caddr_t) &revs;
> atd.ad_out_size = sizeof(revs);
> 
> if ( ioctl(s, SIOCGATHDIAG, &atd) < 0 )
>     err(1, atd.ad_name);
> 
> switch (revs.ad_devid){
>    ...
> }
> ---------------------------------------------------------------------------
> 
> The devid should be"0x0013" in our system. But it returns dummy value. 
> I checked the value at ./dev/ic/ath.c -  ath_ioctl_diag().
> "outdata" buffer has correct value "0x0013" but it is not correctly delivered to ioctl. 
> 
> I checked the value of "outdata" at following lines.
> ---------------------------------------------------------------------------
> ...
> if(ath_hal_getdiagstate(...){
>   ...
>   if(outdata !=NULL)
> #ifndef __QNXNTO__
>   error=copyout(outdata, ad->ad_out_data, ad->ad_out_size_
> #else
>   error=copyout(outdata, ad + 1, ad->ad_out_size);
> #endif
> 
> }
> ---------------------------------------------------------------------------
> 
> Also I  cannot understand why QNXNTO code use "ad+1" instead of "ad->ad_out_data". 
> 
> 
> Anyway causing by this problem, "SIOCGATHDIAG" w/ioctl won't work. The data is not deliverd to ioctl at all. 
> 
> I insert some log and observe it during normal operaton but "SIOCGATHDIAG" is never reqeusted during normal operation.
 
> I think that this option is not tested when QNX team porting atheros driver. 
> 
> Please give me any advice how can I fix it. 

You can't pass a pointer in another process' address space
to the driver.  The convention we (QNX) have used for the
various ioctls that embed pointers in them which would
normally be accessed by a monolithic kernel is to send the
data after the ioctl header.  Thus the (ad + 1) in the
driver.  The utility will have to be tweaked somewhat to
send / receive the data in this format.

> 
> In addition to that, I have one more question. 
> I inserted normal "printf" in the driver source code and found that the printf in driver soruce code works like as "
slog" instead of "printf". So I checked it through "sloginfo". Could you explain why this kind of thing is happened? 

This is by design.  There is a printf() in the NetBSD kernel
that would normally log to their kernel log (dmesg).  We
don't want this going to stdout.  If you really want to send
it to stdout, use fprintf(stdout, ...).

-seanb
Re: RE: RE: RE: How can I access wireless network device (Atheros)  
Dear Sean

I undersood what you mean. Anyway I still could not find any way to get data from drvier to application by using ioctl. 


Only ath_diag data is delivered but the data what I'd like to receive is out of this(ath_diag) data structure.  And I 
could not find any proper example code. 

Could you provide me some sample code or please let me know where I can get sample code. 

Best Regards,
Dooeui
Re: RE: RE: RE: How can I access wireless network device (Atheros)  
On Wed, Jan 30, 2008 at 04:22:18AM -0500, Dooeui Hong wrote:
> Dear Sean
> 
> I undersood what you mean. Anyway I still could not find any way to get data from drvier to application by using ioctl
. 
> 
> Only ath_diag data is delivered but the data what I'd like to receive is out of this(ath_diag) data structure.  And I 
could not find any proper example code. 
> 
> Could you provide me some sample code or please let me know where I can get sample code. 

Look at lib/socket/ioctlsocket.c

Regards,

-seanb
RE: How can I access wireless network device (Atheros)  
Good chance here for a re-cap of the difference between our micro-kernel and
the typical monolithic kernel :> (and I should have been a bit more specific
when I said "just look at the source"!)

With a monolithic kernel, when you pass in a process address to the ioctl,
the ioctl results in a kernel call and the ioctl processing actually happens
in the stack which is embedded in the kernel.  Since the stack is part of
the kernel, it can do pretty much anything it wants... Including reaching
into the application's address space to read / write data.  

With the microkernel, the ioctl results in a message pass under the covers
between the application process and the stack process.  The kernel doesn't
know that this is an "ioctl function to be processed by the stack" and
simply copies the contents of the data buffers from one address space into
buffers in the other address space (note: they are different buffers).  This
means that the stack doesn't reach into the application's address space
directly and leads to one of the more difficult parts of implementing the
port of the stack from the monolithic to microkernel architecture.
Essentially, all data app-to-stack interactions have to be covered with
message passes instead of straight copies.

Most of the ioctl functional compatibility has been taking care of inside of
libsocket (take a look at the source in lib/socket/ioctlsocket.c if you want
all of the details), but for "specialized" (non-stack standard) ioctls, you
need to modify the way that the call is made in order to have the data
properly returned to you.   Unfortunately, you can't actually just adjust
the way that the data is formatted in the ioctl because the size of the
ioctl message is encoded in the ioctl macro, so you'd end up having to
modify the driver as well as the application.

I picked out the relevant portion of the ioctlsocket modified it for the
DIAG ioctl and I'm pasting it in here for you to try out.  Let me know how
it goes.  You'll also have to change it (of course) for any of the other
Atheros specific ioctls that you use (since they may have different ways of
determining address / size parameters for the second IOV).

You can then just replace the ioctl call in the code with ath_ioctl and
you're set.

		Robert.


#include <alloca.h>
#include <errno.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <share.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <sys/types.h>
#include <sys/iomsg.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/sockmsg.h>
#include <sys/ioctl.h>
#include <assert.h>


int ath_ioctl(int fd, int cmd, ...) {
	va_list		vl;
	void		*data;
	iov_t		siov[6], *siovp;
	int			sniov;
	iov_t		riov[6], *riovp;
	int			rniov;
	io_devctl_t	msg;
	int			ret, nbytes;

	/* Pull out the data */
	va_start(vl, cmd);
	data = va_arg(vl, void *);
	va_end(vl);

	nbytes = 0;

	switch (cmd) {
	case SIOCGATHDIAG:
		{
			struct ath_diag *diag = data;
			SETIOV(&siov[1], data, sizeof(*diag));
			SETIOV(&siov[2], diag->ad_out_data,
diag->ad_out_size);
		}
		nbytes += GETIOVLEN(&siov[1]);
		nbytes += GETIOVLEN(&siov[2]);
		
		siovp = riovp = siov;
		sniov = rniov = 2;
		break;
		
	}

	/* The following may set the same iov twice if siovp == riovp */
	SETIOV(siovp, &msg, sizeof(msg)); /* msg.o same size as msg.i */
	SETIOV(riovp, &msg, sizeof(msg)); /* msg.o same size as msg.i */
	sniov++;
	rniov++;

	msg.i.type = _IO_DEVCTL;
	msg.i.combine_len = sizeof msg.i;
	msg.i.dcmd = cmd;
	msg.i.nbytes = IOCPARM_LEN((unsigned)cmd);
	msg.i.zero = 0;

	if ((ret = MsgSendv_r(fd, siovp, sniov, riovp, rniov)) != EOK) {
		errno = -ret;
		return -1;
	}


	return 0;
}



-----Original Message-----
From: Sean Boudreau [mailto:seanb@qnx.com] 
Sent: Tuesday, January 29, 2008 9:20...
View Full Message
Re: RE: How can I access wireless network device (Atheros)  
Dear QNX team,

I appreciate your help. I added "ioctl_ath" in libsocket.so and It works very well. (I just changed function name from "
ath_ioctl" to "ioctl_ath" because there is already "ath_ioctl" fucntion. )

1) At first, I tried to insert this function into atheros wifi device driver.  But I couldn't find any way to link it in
 Makefile. 
Usually, " -l libraryname" is used. but it doesn't seems like to work in case of "dll" file.  Is there any way to link 
it by -l option ?

2) So I tried to use dlopen() in the "dumpregs" application. But following call returns failure during run time.

handle = dlopen( "/lib/dll/devnp-ath.so", RTLD_NOW );

Because I haver never used "dlopen" before. I give it up immediately, Do you have any idea why it failed? 

3) Could you explain why this function(ioctl_ath) cannot be embedded in application(dumpregs)? (If it is possible, LGE 
don't need to modify QNX's library or device driver)  I could not find any technical reason of this. 
(I tried to embed this function in dumpregs but failed to build it.(There were some compile error which are not happen 
when I built it in driver or library) If it is theroically possible, I'll try it again)

Thanks a lot
Dooeui

RE: RE: How can I access wireless network device (Atheros)  
Hi Dooeui:
	My mistake there...  That code snippet was definitely intended for
the dumpregs.c file and NOT for the ioctlsocket.c file.  We certainly
wouldn't want you to have to modify the product source to get your utilities
working since that would mean that you couldn't use our released binaries.
My quick tests were done with that code in the dumpregs.c file.  You
probably just have to modify the include paths to get the proper headers
picked up.

	Robert.

-----Original Message-----
From: Dooeui Hong [mailto:dooeui@lge.com] 
Sent: Friday, February 01, 2008 5:38 AM
To: drivers-networking
Subject: Re: RE: How can I access wireless network device (Atheros)

Dear QNX team,

I appreciate your help. I added "ioctl_ath" in libsocket.so and It works
very well. (I just changed function name from "ath_ioctl" to "ioctl_ath"
because there is already "ath_ioctl" fucntion. )

1) At first, I tried to insert this function into atheros wifi device
driver.  But I couldn't find any way to link it in Makefile. 
Usually, " -l libraryname" is used. but it doesn't seems like to work in
case of "dll" file.  Is there any way to link it by -l option ?

2) So I tried to use dlopen() in the "dumpregs" application. But following
call returns failure during run time.

handle = dlopen( "/lib/dll/devnp-ath.so", RTLD_NOW );

Because I haver never used "dlopen" before. I give it up immediately, Do you
have any idea why it failed? 

3) Could you explain why this function(ioctl_ath) cannot be embedded in
application(dumpregs)? (If it is possible, LGE don't need to modify QNX's
library or device driver)  I could not find any technical reason of this. 
(I tried to embed this function in dumpregs but failed to build it.(There
were some compile error which are not happen when I built it in driver or
library) If it is theroically possible, I'll try it again)

Thanks a lot
Dooeui



_______________________________________________
Networking Drivers
http://community.qnx.com/sf/go/post4725