howto determine network device unit number? device.hints?

Yony Yossef yonyossef.lists at gmail.com
Thu Jan 15 03:15:45 PST 2009


 

> -----Original Message-----
> From: rea-fbsd at codelabs.ru [mailto:rea-fbsd at codelabs.ru] 
> Sent: Thursday, January 15, 2009 12:01 PM
> To: Yony Yossef
> Cc: 'Julian Elischer'; Liran Liss; freebsd-net at freebsd.org; 
> Oleg Kats; 'H.fazaeli'; Eitan Shefi; freebsd-questions at freebsd.org
> Subject: Re: howto determine network device unit number? device.hints?
> 
> Yony, good day.
> 
> Thu, Jan 15, 2009 at 11:26:34AM +0200, Yony Yossef wrote:
> > All I'm doing is unloading and reloading the driver.
> > Unit numbers change and it makes my automatic subnet configuration
> > (/etc/rc.conf) assign bad IPs.
> 
> You're using your own driver, aren't you?  If yes, could you 
> show your device_method_t structure and the corresponding 
> identify, probe, attach and detach routines?  You're setting 
> the unit numbers via 'if_initname(ifp, device_get_name(dev), 
> device_get_unit(dev))' or alike?

My device has 2 ports, therefore my if_initname is that:

if_initname(dev, device_get_name(mdev->pdev), 
                port + 2 * device_get_unit(mdev->pdev));


> > I still don't get the reason for this arbitrarily assigned unit 
> > numbers and what is the common solution for it. Except post load 
> > rename of the interfaces.
> 
> I was under impression that the unit number are coming from 
> the parent busses and they should be stable, at least for the 
> case when the parent bus driver isn't unloaded (and for PCI 
> it should be the case).  So, either the driver sets device 
> unit names weirdly or you hit some bug.
> --
> Eygene

This is what I captured the last time it happened. 

# pciconf -l | grep mtnic
mtnic0 at pci0:19:0:0:     class=0x020000 card=0x001715b3 chip=0x636815b3
rev=0xa0 hdr=0x00
mtnic1 at pci0:16:0:0:     class=0x020000 card=0x001715b3 chip=0x636815b3
rev=0xa0 hdr=0x00

# kldunload if_mtnic
# kldload if_mtnic

# pciconf -l | grep mtnic
mtnic1 at pci0:19:0:0:     class=0x020000 card=0x001715b3 chip=0x636815b3
rev=0xa0 hdr=0x00
mtnic0 at pci0:16:0:0:     class=0x020000 card=0x001715b3 chip=0x636815b3
rev=0xa0 hdr=0x00



More information about the freebsd-questions mailing list