DragonFly BSD
DragonFly submit List (threaded) for 2006-07
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: lnc(4) driver ported from freebsd (le(4))

From: "Sepherosa Ziehau" <sepherosa@xxxxxxxxx>
Date: Sun, 2 Jul 2006 13:16:31 +0800

On 7/2/06, Bill Marquette <bill.marquette@xxxxxxxxx> wrote:
I was interested in learning something about the kernel, so figured
I'd take a crack at porting the le(4) driver that FreeBSD brought in
from NetBSD - the ultimate goal is to bring pcn(4) from NetBSD over -
the combination of the two drivers appears to be better than the
existing lnc(4)/pcn(4) that Dragonfly has today (at least for VMWare)

VMware only uses lnc(4)

and supports VLANs which the existing lnc(4) doesn't appear to (maybe
I missed something).  As Dragonfly already has a le(4) driver and this
was really a replacement for the existing lnc(4), I changed the driver
name to lnc (functions and some defines are a little goofy right now
because of it - looking for a little direction there).

If there's interest, I'm looking for a little feedback on the port.  I
know there's still some cleanup to do (and a man page update!), but
more importantly:

I borrowed the lock code from aac(4) - I'm not sure it's the "right
way" to do things as it's the only driver that seems to use lock(9)
functions - but it was the easiest one to use to see Dragonfly vs
FreeBSD differences.
I ifdef'd out FreeBSD-isms (I still have some cleaning to do there) -
I'm not sure how that's treat in the Dragonfly tree, I only see a few
instances of that in the network drivers, maybe that code should just

No extra lock is needed, all of the functions in "ifnet" struct are called with ifp->if_serializer held, that means most functions in network driver are protected by ifp->if_serializer (which you have passed to bus_setup_intr() too). So you can safely nuke most of the LE_(UN)LOCK stuffs, except for "suspend", "resume", "shutdown" and "detach", LE_(UN)LOCK should be changed to lwkt_serializer_{enter,exit}() there (you can take a look to xl(4) for example). Special care should be taken for "detach": you should held serializer for driver functions (e.g. lance_stop()) and bus_teardown_intr(), while serializer should be released before calling ether_ifdetach(), you can take a look at pcn_detach() for example. Since no callouts are used, there is nothing to worry about the callout callback functions, otherwise the callback functions should hold serializer too.

FreeBSD has BUS_PROBE_LOW_PRIORITY to set bus priorities so drivers
can pre-empt other drivers, I didn't see anything akin to that in
Dragonfly (and sadly hardcoded the value - this needs to be cleaned up
still).  The old driver defined LNC_PROBE_PRIORITY to -1, is that the
"correct way" ? :)

Less than 0 is OK.

Thank you for the submission!! If you can change the LE_(UN)LOCK stuffs, we can call for testing and bring it into base soon.


Live Free or Die

[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]