From owner-freebsd-hardware@FreeBSD.ORG Wed Apr 11 14:32:21 2007 Return-Path: X-Original-To: freebsd-hardware@freebsd.org Delivered-To: freebsd-hardware@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 395C216A52A for ; Wed, 11 Apr 2007 14:32:21 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (66-23-211-162.clients.speedfactory.net [66.23.211.162]) by mx1.freebsd.org (Postfix) with ESMTP id BCFE813C45B for ; Wed, 11 Apr 2007 14:32:20 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from zion.baldwin.cx (zion.baldwin.cx [192.168.0.7]) (authenticated bits=0) by server.baldwin.cx (8.13.8/8.13.8) with ESMTP id l3BEW6M6075077; Wed, 11 Apr 2007 10:32:17 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: freebsd-hardware@freebsd.org Date: Wed, 11 Apr 2007 10:32:02 -0400 User-Agent: KMail/1.9.4 References: <1175864703.4058.20.camel@hiro.auspc.com.au> In-Reply-To: <1175864703.4058.20.camel@hiro.auspc.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200704111032.02374.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [192.168.0.1]); Wed, 11 Apr 2007 10:32:18 -0400 (EDT) X-Virus-Scanned: ClamAV 0.88.3/3067/Wed Apr 11 06:21:12 2007 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: Alan Garfield Subject: Re: Porting a Linux ethernet driver to FreeBSD X-BeenThere: freebsd-hardware@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General discussion of FreeBSD hardware List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Apr 2007 14:32:21 -0000 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