From owner-freebsd-net Mon Oct 1 13:23:11 2001 Delivered-To: freebsd-net@freebsd.org Received: from beppo.feral.com (beppo.feral.com [192.67.166.79]) by hub.freebsd.org (Postfix) with ESMTP id E9A3637B409 for ; Mon, 1 Oct 2001 13:23:04 -0700 (PDT) Received: from mailhost.feral.com (mjacob@mailhost.feral.com [192.67.166.1]) by beppo.feral.com (8.11.3/8.11.3) with ESMTP id f91KN1H84957; Mon, 1 Oct 2001 13:23:01 -0700 (PDT) (envelope-from mjacob@feral.com) Date: Mon, 1 Oct 2001 13:23:01 -0700 (PDT) From: Matthew Jacob X-Sender: mjacob@beppo Reply-To: mjacob@feral.com To: Jim McGrath Cc: freebsd-net@FreeBSD.ORG Subject: RE: review of minor clarifying comments In-Reply-To: <31269226357BD211979E00A0C9866DAB01BE796A@rios.sitaranetworks.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org Huh. Too bad you didn't point me at the bug- it would have saved me a morning's debugging. On Mon, 1 Oct 2001, Jim McGrath wrote: > I ran into this same problem with the wx driver and submitted a pr. > http://www.freebsd.org/cgi/query-pr.cgi?pr=29249 > > Jim > > > -----Original Message----- > From: Matthew Jacob [mailto:mjacob@feral.com] > Sent: Monday, October 01, 2001 4:05 PM > To: freebsd-net@FreeBSD.ORG > Subject: review of minor clarifying comments > > > > 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