Porting a Linux ethernet driver to FreeBSD

John Baldwin jhb at freebsd.org
Wed Apr 11 14:32:21 UTC 2007


On Friday 06 April 2007 09:05, Alan Garfield wrote:
> Hello all!
> 
> I'm posting here because I cannot find enough information elsewhere.
> 
> I've got a Sun Fire V20z (re-badged NewISys E2100) which has a little
> dedicated Service Processor on board running Linux. The "SP" can
> communicate via IPMI and also by Ethernet via two small fifo buffer in
> the PRS via the LPC.
> 
> I have the GPL source for the so-called 'jnet' device which is basically
> a small Ethernet-looking driver that wraps around these 256 byte PRS
> buffers and a single interrupt. 
> 
> -- FROM THE GPL DRIVER COMMENTS
>  
> Jnet is a ethernet adapter driver.  As such, it provides what appears
> to be a typical ethernet adapter interface which the platform can use
> to send/receive IP traffic to the SP.  The actual physical medium is
> the PRS, which resides on the LPC bus, and provides two 256 byte fifo's
> along with an interrupt and a status register.
> 
> When an interrupt is received, the status register can be read, which
> will indicate either a Data Available (DAV), or a Data Acknowledge
> (DAK). We can then choose to read or write data to the fifo, and thus
> facilitate communication between the SP and Platform.
> 
> Because the fifo's provided by the PRS are only 256 bytes, our packet
> size is limited.  As a result, the only feature we can't support is
> DHCP, since a DHCP packet is 313 bytes.
> 
> --
> 
> I'd like to port this driver to FreeBSD but I cannot find any decent
> examples of a basic Ethernet driver. Most have miibus which I don't need
> because there is no PHY, the loopback is clone-able and seems to simple
> and most of the others are all so different from each other I cannot
> really tell where to start. 
> 
> Can someone point me in the direction of an example or the relevant man
> pages I should be reading.
> 
> The device driver for Linux seems quite simple and clearly defined, but
> I cannot find a similar driver that I can hack apart.
> 
> Any help would be gratefully appreciated.

I think de(4) is kind of simple if you ignore all the ifmedia handling stuff.
You basically need to alloc an ifnet, fill out if_init and if_start with routines
to bring up the interface and to drain the tx queue, and then pass it to
ether_ifattach().  When you get packets, you feed them to the stack by calling
ifp->if_input().  You will probably need to set if_mtu during attach to your
256 byte MTU.  And you should add an if_ioctl routine as well.

-- 
John Baldwin


More information about the freebsd-hardware mailing list