Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - ifconfig issue: (4 Items)
   
ifconfig issue  
Hello.

My driver detect and initialise several instances of the device, a FPGA IP core.

When I run the driver, and i do an ifconfig on a specific interface, it works :

Jul 22 15:22:09    5    10     0 men-z087
Jul 22 15:22:09    5    10     0 Vendor .............. 0x1172
Jul 22 15:22:09    5    10     0 Device .............. 0x4d45
Jul 22 15:22:09    5    10     0 Revision ............ 0x0
Jul 22 15:22:09    5    10     0 Interrupt ........... 0xa
Jul 22 15:22:09    5    10     0 MAC address ......... 00c03a 9cc018
Jul 22 15:22:10    5    10     0 men-z087
Jul 22 15:22:10    5    10     0 Vendor .............. 0x1172
Jul 22 15:22:10    5    10     0 Device .............. 0x4d45
Jul 22 15:22:10    5    10     0 Revision ............ 0x0
Jul 22 15:22:10    5    10     0 Interrupt ........... 0xa
Jul 22 15:22:10    5    10     0 Interrupt ........... 0x0
Jul 22 15:22:10    5    10     0 MAC address ......... 00c03a 9cd018
Jul 22 15:22:12    5    14     0 men-z087 : link 0 up (100 BaseT Half Duplex)
Jul 22 15:22:13    5    14     0 men-z087 : link 1 up (100 BaseT Full Duplex)
#
# ifconfig men0
men0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
Jul 22 15:47:21    0    14     0 ifmedia_ioctl(ifp = 8154478,ifr = 824f01c,&dev->bsd_mii.mii_media = 815485c,cmd = 
3223873846)
        address: 00:c0:3a:9c:c0:18
Jul 22 15:47:21    0    14     0 ifmedia_ioctl(ifp = 8154478,ifr = 825281c,&dev->bsd_mii.mii_media = 815485c,cmd = 
3223873846)
        media: Ethernet autoselect (100baseTX)
Jul 22 15:47:21    0    14     0 ifmedia_ioctl(ifp = 8154478,ifr = 825201c,&dev->bsd_mii.mii_media = 815485c,cmd = 
3223873846)
        status: active
#
#
#
# ifconfig men1
men1: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
Jul 22 15:47:38    0    14     0 ifmedia_ioctl(ifp = 815e798,ifr = 825981c,&dev->bsd_mii.mii_media = 815eb7c,cmd = 
3223873846)
        address: 00:c0:3a:9c:d0:18
Jul 22 15:47:38    0    14     0 ifmedia_ioctl(ifp = 815e798,ifr = 825981c,&dev->bsd_mii.mii_media = 815eb7c,cmd = 
3223873846)
        media: Ethernet autoselect (100baseTX full-duplex)
Jul 22 15:47:38    0    14     0 ifmedia_ioctl(ifp = 815e798,ifr = 825981c,&dev->bsd_mii.mii_media = 815eb7c,cmd = 
3223873846)
        status: active
#


But if I do an ifconfig without specifying the interface the driver crashes while trying to access the media state:

#
# ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33192
        inet 127.0.0.1 netmask 0xff000000
men0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
Jul 22 16:13:34    0    14     0 ifmedia_ioctl(ifp = 8154478,ifr = 812541293,&dev->bsd_mii.mii_media = 0,cmd = 0)
Jul 22 16:13:34    5    14     0 men-z087 : destroy the driver
Jul 22 16:13:34    5    21     0 run fault pid 790571 tid 2 signal 11 code 1 ip 0xb0328476 tmp/io-pkt-v4-
hcgvarlet12482704615876
        address: 00:c0:3a:9c:c0:18

The debuger show me that the crash is done on the second call of ifmedia_ioctl() because MAC address can be displayed.

Do you have any idea of the source of the bug ?

Thanks.
Guillaume.

RE: ifconfig issue  
Gosh.  Generally, if you just copy the bsd_media.c file
(that all native io-pkt drivers use) it works out of the
box.

Anyways, reproducible io-pkt faults are pretty easy to
diagnose.  Re-compile whatever part is faulting with 
"-g -O0" and re-run it.  Get it to fault, get the core
file, and now you can see the exact source line and
variable that you're blowing up on.  Usually you can
see exactly what the problem is (e.g. null pointer).

--
aboyd
RE: ifconfig issue  
I come back on this issue because I got no progress so far.

The following list are the values of the struct mii_data.struct ifmedia when specifying the interface :

{ifm_mask = 4026531840, ifm_media = 0, ifm_cur = 0x813c2c0, ifm_list = {tqh_first = 0x813c2c0, tqh_last = 0x813c360}, 
ifm_change = 0xb8202d0e <bsd_mii_mediachange>, ifm_status = 0xb8202baf <bsd_mii_mediastatus>}

Here are the values of the struct mii_data.struct ifmedia when NOT specifying the interface :

{ifm_mask = 0, ifm_media = 0, ifm_cur = 0x100, ifm_list = {tqh_first = 0x0, tqh_last = 0x0}, ifm_change = 0, ifm_status 
= 0}

The values are clearly 0, but why ?
I'm getting a similar error for data transmiting.

It seems to have difficulties with functions that are using a struct ifnet to retreive the device structure, such as :

int z87_ioctl( struct ifnet* ifp, unsigned long cmd, caddr_t data )
{
	z87_dev_t*				dev;
	int						error;
	struct ifdrv_com*		ifDriverCom;
	struct drvcom_config*	driverCfg;
	struct drvcom_stats*	driverStats;

	dev = ifp->if_softc;
...
}

void z87_start( struct ifnet* ifp )
{
	z87_dev_t*				dev = ifp->if_softc;
...
}

I remember I'm instancing a random list of devices with a device double-linked list on the same driver. I mean that I 
list all devices in my system, and then I add them in the list at devce detection time. Then I initialise and register 
any devices present in my system :

	for(	dev = (z87_dev_t*) g_z87UnitList.head;
			dev->z87UnitNode.next != NULL;
			dev = (z87_dev_t*) dev->z87UnitNode.next ){

		dev->ifNetP = &dev->ecom.ec_if;
		dev->ifNetP->if_softc = dev;
		dev->interruptID = -1;

	    /* Configure the device */
            ...

		/*--- setup network interface struct ---*/
		sprintf( dev->ifNetP->if_xname, "men%d", (int)dev->chamInstance );
		dev->ifNetP->if_flags 	= IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
		dev->ifNetP->if_ioctl 	= z87_ioctl;
		dev->ifNetP->if_start	= z87_start;
		dev->ifNetP->if_init 	= z87_init;
		dev->ifNetP->if_stop	= z87_stop;
		IFQ_SET_READY(&dev->ifNetP->if_snd);
		dev->ifNetP->if_softc = dev;

		/* register BSD media interface */
		bsd_mii_initmedia( dev );

		/* register and attach network interface */
		if_attach(dev->ifNetP);
		ether_ifattach(dev->ifNetP, dev->cfg.current_address);
	}

Many thanks for the help.
Guillaume.
RE: ifconfig issue  
> I got no progress so far.

Stepping back for a moment, two really dumb questions:

1) does this functionality exist and work correctly in 
other native io-pkt drivers (eg sys/dev_qnx/mpc85xx, 
i85244, e1000, speedo, etc) which have a bsd_media.c
file?

2) if the answer to #1 above is "yes", what is the
source code difference between your driver and all
the other io-pkt drivers which function correctly?

3) if the answer to #1 above is "no" then you're a
bit like Captain Kirk, except that I personally might 
hope you give the green alien women a break.  You might 
want to look at some NetBSD driver source for some 
ideas as to how they implemented similar functionality.  

Click on:

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/?only_with_tag=MAIN

--
aboyd