Date: Sun, 21 Apr 2002 16:04:24 -0700 (PDT) From: wpaul@FreeBSD.ORG (Bill Paul) To: semenu@FreeBSD.org (Semen A. Ustimenko) Cc: freebsd-hackers@FreeBSD.org Subject: Re: MIIBUS_MEDIAINIT method Message-ID: <20020421230424.9B4B637B400@hub.freebsd.org> In-Reply-To: <20020422020233.W611-100000@def.the.net> from "Semen A. Ustimenko" at "Apr 22, 2002 02:13:12 am"
next in thread | previous in thread | raw e-mail | index | archive | help
> Hi! > > I was just thinking about the purpose of this method... What is it? > > It used to be used by NIC drivers to add something like AUI beside MII > provided media, correct? It is _still_ used that way. See if_xl.c. There exists a 3c905B-Combo card which supports a 10/100 RJ-45 port, a 10Mbps-only BNC port and a 10Mbps only AUI port. Why did I concoct MEDIAINIT for this? Because each device can have only one ifmedia structure. When a driver uses miibus, the ifmedia struct is initialized by the underlying PHY driver, and that initialization does not happen until after we leave the MAC driver's attach routine. It's not a problem to add additional media types to the ifmedia struct later, but we need to have the PHY driver call back to the MAC driver to do this, which is why every PHY driver has a call to MIIBUS_MEDIAINIT() in its attach routine. If the parent MAC driver does not implement this method, nothing happens. But if it does implement this method, the parent can use it to do some extra ifmedia_add()s to tack on some extra media types. > But it looks like every PHY's driver thinks it must call MEDIAINIT in its > attach() routine. So, if there would be two PHY on MII (can this happen?), Yes, though it's rare, and not always useful. > then the method will be called twice, and some NIC drivers (tx, xl, dc, > maybe more) will not behave well. They work fine if the author of the MAC driver was smart enough to check for this in his mediainit method and just return immmediately if the auxilliary media types have already been ifmedia_add()ed. Right now, the only card that uses this feature is the 3c905B-Combo, and its hardware configuration does not permit the sort of edge condition you are fretting over. > Isn't it reasonable to stop all PHY drivers from calling MEDIAINIT, and > call it once per miibus instance in miibus_attach() or miibus_probe() > instead? No. We want the PHY driver to set up its media types in the ifmedia struct first, and then add our own after those, which means we have to wait until the end of the PHY's attach routine, and it's newbus that calls the attach routines, not the miibus code. If you have a card or hardware configuration which is actually causing the scenario you describe, then say so. Otherwise, keep your fingers out of this code. No user-servicable parts inside. Keep out of children. Do not look into laser optics with remaining eye. -Bill -- ============================================================================= -Bill Paul (510) 749-2329 | Senior Engineer, Master of Unix-Fu wpaul@windriver.com | Wind River Systems ============================================================================= God was my co-pilot, until we crashed in the mountains and I had to eat him. ============================================================================= To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020421230424.9B4B637B400>