Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - dev_attach function: (12 Items)
   
dev_attach function  
Hi,


In dev_attach function /sys/Device_qnx.c

Prototype :

int dev_attach(char *drvr, 
                        char *options, struct cfattach *ca,
                        void *cfat_arg,
                         int *single,   /* 4th argument */
                        struct device **devp,
    int (*print)(void *, const char *))

Can you please tellme what is the 4th argument. i will not found any explanation for this...

Please help me on this.

Thanks and Regards
K.Senthil
RE: dev_attach function  
Hi,

From my understanding, if the unit=x is specified in command line
arguments, single is set to true(1), probably to indicate the caller
that dev_attach need not to be called again because we have to  bring
only 1 interface as specified by user.


BR,
Akash

-----Original Message-----
From: Senthil K [mailto:community-noreply@qnx.com] 
Sent: Thursday, September 17, 2009 7:27 PM
To: drivers-networking
Subject: dev_attach function

Hi,


In dev_attach function /sys/Device_qnx.c

Prototype :

int dev_attach(char *drvr, 
                        char *options, struct cfattach *ca,
                        void *cfat_arg,
                         int *single,   /* 4th argument */
                        struct device **devp,
    int (*print)(void *, const char *))

Can you please tellme what is the 4th argument. i will not found any
explanation for this...

Please help me on this.

Thanks and Regards
K.Senthil



_______________________________________________

Networking Drivers
http://community.qnx.com/sf/go/post38158
Re: RE: dev_attach function  
Hi,

 i loading the driver using mount command.

if i specify the unit=1 on mount command.it throws an error.

Where i can specify unit option?

Thanks and Regards
K.Senthil
Re: RE: dev_attach function  
On Fri, Sep 18, 2009 at 09:39:46AM -0400, Senthil K wrote:
> Hi,
> 
>  i loading the driver using mount command.
> 
> if i specify the unit=1 on mount command.it throws an error.
> 
> Where i can specify unit option?

Please post the mount command.

Thanks,

-seanb
Re: RE: dev_attach function  
Hi ,


The following command i used to load the driver.
mount -T io-pkt devnp-xxx.so unit=1


Thanks and Regards
K.Senthil
Re: RE: dev_attach function  
On Fri, Sep 18, 2009 at 10:04:50AM -0400, Senthil K wrote:
> Hi ,
> 
> 
> The following command i used to load the driver.
> mount -T io-pkt devnp-xxx.so unit=1

Should be:

mount -T io-pkt -ounit=1 devnp-xxx.so
Re: RE: dev_attach function  
Hi Sean,

I am using the sample ethernet driver.

If  i gave the mount command with the option unit=1,

system gets hung.

Thanks and Regards
K.Senthil
Re: RE: dev_attach function  
On Fri, Sep 18, 2009 at 10:27:12AM -0400, Senthil K wrote:
> Hi Sean,
> 
> I am using the sample ethernet driver.
> 
> If  i gave the mount command with the option unit=1,
> 
> system gets hung.

Seems to work here.  Can you be more detailed?

-seanb
Re: RE: dev_attach function  
Hi Sean,

I got following error.

mount -T io-pkt -ounit=1 /lib/dll/devnp-PE.so
mount: Can't mount / (type io-pkt)
mount: Possible reason: No such device

Please tell me why the single variable is set  to 1(What it mean) in the below function.


int
sam_entry(void *dll_hdl,  struct _iopkt_self *iopkt, char *options)
{
	int		instance, single;
	struct device	*dev;
	void		*attach_args;

	/* parse options */

	/* do options imply single? */
	single = 1;

	/* initialize to whatever you want to pass to sam_attach() */
	attach_args = NULL;

	for (instance = 0;;) {
		/* Apply detection criteria */

		/* Found one */
		dev = NULL; /* No Parent */
		if (dev_attach("sam", options, &sam_ca, attach_args,
		    &single, &dev, NULL) != EOK) {
			break;
		}
		dev->dv_dll_hdl = dll_hdl;
		instance++;

	
		if (/* done_detection || */ single)
			break;
	}

	if (instance > 0)
		return EOK;

	return ENODEV;
}


Thanks and Regards
K.Senthil
Re: RE: dev_attach function  
On Fri, Sep 18, 2009 at 11:08:36AM -0400, Senthil K wrote:
> 
> Hi Sean,
> 
> I got following error.
> 
> mount -T io-pkt -ounit=1 /lib/dll/devnp-PE.so
> mount: Can't mount / (type io-pkt)
> mount: Possible reason: No such device
> 
> Please tell me why the single variable is set  to 1(What it mean) in the below function.

It's an example.  Often drivers scan in a loop detecting
all instances of hardware they're to handle.  single = 1
means stop scaning.  There's no real hardware in the sample
driver; it's an example.

-seanb

> 
> 
> int
> sam_entry(void *dll_hdl,  struct _iopkt_self *iopkt, char *options)
> {
> 	int		instance, single;
> 	struct device	*dev;
> 	void		*attach_args;
> 
> 	/* parse options */
> 
> 	/* do options imply single? */
> 	single = 1;
> 
> 	/* initialize to whatever you want to pass to sam_attach() */
> 	attach_args = NULL;
> 
> 	for (instance = 0;;) {
> 		/* Apply detection criteria */
> 
> 		/* Found one */
> 		dev = NULL; /* No Parent */
> 		if (dev_attach("sam", options, &sam_ca, attach_args,
> 		    &single, &dev, NULL) != EOK) {
> 			break;
> 		}
> 		dev->dv_dll_hdl = dll_hdl;
> 		instance++;
> 
> 	
> 		if (/* done_detection || */ single)
> 			break;
> 	}
> 
> 	if (instance > 0)
> 		return EOK;
> 
> 	return ENODEV;
> }
> 
> 
> Thanks and Regards
> K.Senthil
> 
> 
> 
> _______________________________________________
> 
> Networking Drivers
> http://community.qnx.com/sf/go/post38313
> 
Re: RE: dev_attach function  
Hi Sean,

i tried the following approach in sample driver(devnp-sample.so).

Approach 1:
                         mount -T io-pkt -ounit=1 devnp-sample.so then i do
#ifconfig
sam1: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
        address: 00:01:02:03:04:05

 Approach 2:
                       mount -T io-pkt -ounit=10 devnp-sample.so then i do
#ifconfig
sam10: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
        address: 00:01:02:03:04:05

Approach 3:
                      I changed single variable value as 0 instead of 1,then 
                      mount -T io-pkt -ounit=1 devnp-sample.so then i do

#ifconfig
sam1: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
        address: 00:01:02:03:04:05

Why i m telling different apprach,there is no difference if i changed the  variable single as 
as 0. I m not able to understand how the relation between the single varaible and unit option in the mount command.

Can you please help me.

Thanks and Regards
K.Senthil


Re: RE: dev_attach function  
On Mon, Sep 28, 2009 at 01:38:03AM -0400, Senthil K wrote:
> Hi Sean,
> 
> i tried the following approach in sample driver(devnp-sample.so).
> 
> Approach 1:
>                          mount -T io-pkt -ounit=1 devnp-sample.so then i do
> #ifconfig
> sam1: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
>         address: 00:01:02:03:04:05
> 
>  Approach 2:
>                        mount -T io-pkt -ounit=10 devnp-sample.so then i do
> #ifconfig
> sam10: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
>         address: 00:01:02:03:04:05
> 
> Approach 3:
>                       I changed single variable value as 0 instead of 1,then 
>                       mount -T io-pkt -ounit=1 devnp-sample.so then i do
> 
> #ifconfig
> sam1: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
>         address: 00:01:02:03:04:05
> 
> Why i m telling different apprach,there is no difference if i changed the  variable single as 
> as 0. I m not able to understand how the relation between the single varaible and unit option in the mount command.
> 
> Can you please help me.

There is no relation between 'unit' and single.  Unit
is working as expected in the examples above.  The
sample driver doesn't scan in a loop so in effect single=1
always.

Try putting two pci cards of the same type in a machine,
start the driver with no args, then try passing the pci
index of one of them to see the effect of single = 0 vs
single = 1.

-seanb