cvs commit: src/sys/net if.c if_vlan.c

Luigi Rizzo luigi at FreeBSD.org
Sat Apr 24 16:22:47 PDT 2004


On Sun, Apr 25, 2004 at 01:51:55AM +0300, Ruslan Ermilov wrote:
...
> >   In this case also fix a difference in assumptions WRT the rest of
> >   the net/ sources: it is not the 'struct *softc' that starts with a
> >   'struct arpcom', but a 'struct arpcom' that starts with a
> >   'struct ifnet'
> >   
> Hmm, actually both statements are true.  From if_var.h:

yes but apparently (though not 100% sure) only the arpcom-ifnet
layout is used by the majority of the code, whereas the softc-arpcom
layout restriction is only left in sys/dev/mii.c
Now, i _believe_ this can be removed as well because there are
device-specific methods which probably override the generic
miibus_attach() below, and they know the *_softc layout.
But we should ask the author of the MII code to see if this is true.

	cheers
	luigi

> /*
>  * NB: For FreeBSD, it is assumed that each NIC driver's softc starts with
>  * one of these structures, typically held within an arpcom structure.
>  *
>  *      struct <foo>_softc {
>  *              struct arpcom {
>  *                      struct  ifnet ac_if;
>  *                      ...
>  *              } <arpcom> ;
>  *              ...
>  *      };
>  *
>  * The assumption is used in a number of places, including many
>  * files in sys/net, device drivers, and sys/dev/mii.c:miibus_attach().
>  *
>  * Unfortunately devices' softc are opaque, so we depend on this layout
>  * to locate the struct ifnet from the softc in the generic code.
>  *
>  */
> 
> But I think your intention is to only leave the latter; in this
> case, please care to update this comment in if_var.h.  It came
> very handy when I fixed the problem in sys/netgraph/ng_eiface.c,
> rev. 1.11, and I'll sure look here again next time I do something
> similar.


More information about the cvs-src mailing list