Date: Tue, 2 Oct 2001 21:58:20 -0400 (EDT) From: "Matthew N. Dodd" <winter@jurai.net> To: Matthew Jacob <mjacob@feral.com> Cc: Julian Elischer <julian@elischer.org>, Garrett Wollman <wollman@khavrinen.lcs.mit.edu>, freebsd-net@FreeBSD.ORG Subject: Re: review of minor clarifying comments Message-ID: <Pine.BSF.4.21.0110022142450.38937-100000@sasami.jurai.net> In-Reply-To: <Pine.BSF.4.21.0110011323270.99893-100000@beppo>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 1 Oct 2001, Matthew Jacob wrote: > Yes- this may have been true for a long time - but quite a number of > Unix variants don't require it, so I forgot :-).. For example, neither > OpenBSD nor NetBSD seem to require it. > > It turns out that this is only stumbled on rarely- but if it's all the same to > you, a comment would help a lot. It looks like storing a pointer to struct arpcom in struct ifnet might solve most of the cases where ifp->if_softc == struct arpcom/struct ifnet. I'm not exactly sure how to deal with the miibus stuff at this point; the following, in mii.c:miibus_linkchg(): mii = device_get_softc(dev); ifp = device_get_softc(parent); can be changed to: mii = device_get_softc(dev); ifp = mii->mii_ifp; I'm thinking we could pass struct ifnet in to mii.c:mii_phy_probe() and attach it to the device ivars. > On Mon, 1 Oct 2001, Julian Elischer wrote: > > > Not only that but the ifnet structure must be the first part of the arpcom > > struct so that arpcm, ifnet and softc often need to be the same.. I've > > been gradually trying to remove this requirement over the last 10 years > > but it's still there.. :-/ > > > > Comments can't hurt though.. > > > > > > On Mon, 1 Oct 2001, Matthew Jacob wrote: > > > > > > > > This bit me in the butt yet again about FreeBSD and some assumptions about how > > > a NIC's softc is laid out- I don't really it stated elsewhere, so a couple > > > source file comments seem in order.. Frankly, this kind of assumption is > > > dangerous and unnecessary with methods, but at the very least it ought to be > > > commented, no? > > > > > > -matt > > > > > > > > > Index: net/if_var.h > > > =================================================================== > > > RCS file: /home/ncvs/src/sys/net/if_var.h,v > > > retrieving revision 1.37 > > > diff -u -r1.37 if_var.h > > > --- net/if_var.h 2001/09/18 17:41:42 1.37 > > > +++ net/if_var.h 2001/10/01 20:00:08 > > > @@ -105,6 +105,11 @@ > > > * > > > * (Would like to call this struct ``if'', but C isn't PL/1.) > > > */ > > > + > > > +/* > > > + * 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 ifnet { > > > void *if_softc; /* pointer to driver state */ > > > char *if_name; /* name, e.g. ``en'' or ``lo'' */ > > > Index: dev/mii/mii.c > > > =================================================================== > > > RCS file: /home/ncvs/src/sys/dev/mii/mii.c,v > > > retrieving revision 1.9 > > > diff -u -r1.9 mii.c > > > --- dev/mii/mii.c 2001/09/29 18:40:06 1.9 > > > +++ dev/mii/mii.c 2001/10/01 20:00:09 > > > @@ -167,6 +167,9 @@ > > > struct mii_data *mii; > > > > > > mii = device_get_softc(dev); > > > + /* > > > + * Note that each NIC's softc must start with an ifnet structure. > > > + */ > > > mii->mii_ifp = device_get_softc(device_get_parent(dev)); > > > v = device_get_ivars(dev); > > > ifmedia_upd = v[0]; > > > @@ -233,6 +236,9 @@ > > > MIIBUS_LINKCHG(parent); > > > > > > mii = device_get_softc(dev); > > > + /* > > > + * Note that each NIC's softc must start with an ifnet structure. > > > + */ > > > ifp = device_get_softc(parent); > > > > > > if (mii->mii_media_status & IFM_AVALID) { > > > > > > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > > > with "unsubscribe freebsd-net" in the body of the message > > > > > > > > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-net" in the body of the message > -- | Matthew N. Dodd | '78 Datsun 280Z | '75 Volvo 164E | FreeBSD/NetBSD | | winter@jurai.net | 2 x '84 Volvo 245DL | ix86,sparc,pmax | | http://www.jurai.net/~winter | For Great Justice! | ISO8802.5 4ever | To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0110022142450.38937-100000>