[ECOS] Event driven ethernet status change

Jonathan Larmour jifl@eCosCentric.com
Thu Mar 4 04:12:00 GMT 2004


Matt Jerdonek wrote:
> Hi Folks,
> 
> I need a way for an ethernet driver (but specifically
> the powerpc/fec driver) to inform an application of a
> loss and restoral of ethernet carrier.
> 
> If possible, I want avoid having the application poll
> the driver for its status.  Instead, I'd like driver
> to inform the application of status changes.
> 
> It looks like I can call if_down(...) or if_up(...)
> from the ethernet driver, then, in the application,
> listen on the routing socket for status changes.  Is
> this a reasonable approach?  Is there a better way?

I'm not definite, but your way might risk losing data since the interfaces 
are administratively down for a while so any threads trying to send would 
instantly get errors (no route to host probably), even if the link loss is 
entirely transient. That's not the way "big UNIX" works anyway.

Instead up versus down is an administrative thing. I think the flag you'd 
want to change if anything is IFF_RUNNING although that may interact badly 
with the way the generic eth layer uses that flag, I'm not sure.

But the driver can get at those flags:

     struct ifnet *ifp = &sc->sc_arpcom.ac_if;
     ifp->if_flags &= ~IFF_RUNNING;

So if you enable the HBERR in the IEVENT mask for the FEC you can diddle 
the flags.

*However* the IFF_RUNNING status is not passed to the routing socket so 
you'll still end up polling.

So either you can add your own private hook to the FEC driver to make a 
callback, or you would poll.

Jifl
-- 
eCosCentric    http://www.eCosCentric.com/    The eCos and RedBoot experts
 >>>>> Visit us in booth 2527 at the Embedded Systems Conference 2004 <<<<<
March 30 - April 1, San Francisco http://www.esconline.com/electronicaUSA/
--["No sense being pessimistic, it wouldn't work anyway"]-- Opinions==mine


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss



More information about the Ecos-discuss mailing list