From owner-freebsd-arch@FreeBSD.ORG Thu Jul 29 16:13:06 2004 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5F10016A4CE for ; Thu, 29 Jul 2004 16:13:06 +0000 (GMT) Received: from pooker.samsco.org (pooker.samsco.org [168.103.85.57]) by mx1.FreeBSD.org (Postfix) with ESMTP id D288F43D53 for ; Thu, 29 Jul 2004 16:13:05 +0000 (GMT) (envelope-from scottl@freebsd.org) Received: from pooker.samsco.org (scottl@localhost [127.0.0.1]) by pooker.samsco.org (8.12.11/8.12.10) with ESMTP id i6TGJquL019346; Thu, 29 Jul 2004 10:19:53 -0600 (MDT) (envelope-from scottl@freebsd.org) Received: from localhost (scottl@localhost)i6TGJqCC019343; Thu, 29 Jul 2004 10:19:52 -0600 (MDT) (envelope-from scottl@freebsd.org) X-Authentication-Warning: pooker.samsco.org: scottl owned process doing -bs Date: Thu, 29 Jul 2004 10:19:52 -0600 (MDT) From: Scott Long Sender: scottl@pooker.samsco.org To: sah@coraid.com In-Reply-To: <20040728183344.ELWU1792.imf19aec.mail.bellsouth.net@coraid.com> Message-ID: <20040729094711.B32601@pooker.samsco.org> References: <20040728183344.ELWU1792.imf19aec.mail.bellsouth.net@coraid.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=0.0 required=3.8 tests=none autolearn=no version=2.63 X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on pooker.samsco.org cc: arch@freebsd.org Subject: Re: AoE & driver tips X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Jul 2004 16:13:06 -0000 On Wed, 28 Jul 2004 sah@coraid.com wrote: > Hello, > > I'm in the process of writing a AoE disk/protocol driver for freebsd. > AoE (ATA over Ethernet) is used to access ATA devices attached directly to the Ethernet using the AoE registered Ethernet protocol type 0x88a2. I have already written a driver for linux 2.4 and 2.6 that makes AoE devices show up as local disks. I'm hoping to do the same for freebsd. I have some questions from my > initial perusal of the code. I guess the biggest question that you have to answer is whether you want to plug directly into the ATA framework or have your driver be a monolithic block driver. The ATA framework provides generic ATA command transforms and error handling and might be attractive for your needs. However, I have not read the AoE spec so I can't say for sure. Areas like error recovery might or might not be applicable to your needs. The downside to plugging into the ATA layer is that it is very centered on having very thin/simple hardware drivers underneath it. It seems to also be centered on the traditional ATA assumptions of discrete channels with a fixed number of drives that can or cannot do traditional DMA operations. I'm not sure how hard it would be to broaden its scope here. Doing something that crosses from the ATA layer to the network layer might also have some locking implications, but again I don't know for sure. ATA also seems to be on a bit of a rocky road for many people right now, so you might want to seriously investigate it before deciding. In any case, the API that you want to look at for plugging into it is nominally defined in the ata_pci_controller and ata_device structures. One other thing to note is that the ATA driver in 4.x isn't layered like it is in 5.x so plugging into it will be a bit harder. Writing a separate block driver isn't very hard, but it means that your user-visible disk devices will have unique names and not be part of the '/dev/adN' naming scheme. This usually isn't a big deal. Locking is also much simplier in this scheme. You do have to provide your own ATA command transformsi, enumeration/discovery, and error recovery, though. > I've been looking at the code in sys/dev/ata/ for tips on plugging into > the disk device layer. It appears that what I want is disk_create && > disk_destroy. How is the parameter "unit" related to device major & > minor? I don't see anywhere where major and minor are related to the > disk structure, though perhaps I'm just missing it. Do I need to > register a device major? disk_create() and disk_destroy() are block layer API calls that the ATA framework calls on behalf of the lower ATA hardware drivers. Major numbers are dynamically assigned in FreeBSD 5.x. For 4.x, you'll only need a unique major reservation if your driver winds up being a block driver. If it's an ATA driver then it'll use the ATA major/minor scheme. > > If a device fails or vanishes, can i just fail the outstanding bios and > disk_destroy it? How does freebsd do SMART on ata? I'd like to be able > to plug into this as well if the system uses it. I believe that there are some SMART monitoring tools in the ports tree (/usr/ports/sysutils/smartmontools looks promising), but there isn't anything like that integrated into the base system. > > Any other tips/comments about gluing together the disk & network would be appreciated. You might also consider plugging into the SCSI framework (called CAM on FreeBSD). There are many tradeoffs there, but the API is more flexible and is consistent between 4.x and 5.x. If neither frameworks appeal to you then doing a block driver would be the right choice. Block drivers are a bit more flexible in FreeBSD than they are in Linux, too. Scott