From owner-freebsd-hackers@FreeBSD.ORG Wed Sep 14 03:27:39 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E09CE16A41F for ; Wed, 14 Sep 2005 03:27:39 +0000 (GMT) (envelope-from scottl@samsco.org) Received: from pooker.samsco.org (pooker.samsco.org [168.103.85.57]) by mx1.FreeBSD.org (Postfix) with ESMTP id 599DE43D45 for ; Wed, 14 Sep 2005 03:27:36 +0000 (GMT) (envelope-from scottl@samsco.org) Received: from [192.168.254.11] (junior.samsco.home [192.168.254.11]) (authenticated bits=0) by pooker.samsco.org (8.13.3/8.13.3) with ESMTP id j8E3RYN6033594; Tue, 13 Sep 2005 21:27:35 -0600 (MDT) (envelope-from scottl@samsco.org) Message-ID: <432798A5.7070105@samsco.org> Date: Tue, 13 Sep 2005 21:27:33 -0600 From: Scott Long User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.8) Gecko/20050615 X-Accept-Language: en-us, en MIME-Version: 1.0 To: nsrashmi@gmail.com References: <9f99931605091320002845705e@mail.gmail.com> In-Reply-To: <9f99931605091320002845705e@mail.gmail.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.8 required=3.8 tests=ALL_TRUSTED autolearn=failed version=3.0.2 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on pooker.samsco.org Cc: freebsd-hackers@freebsd.org Subject: Re: PCI_MULTI FUNCTION DEVICE DRIVERS X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Sep 2005 03:27:40 -0000 rashmi ns wrote: > Hello All, > While writing a pci-driver for hdlc controller which has two functions > 1.BRIDGE > 2.Network > Do we need to write two separate drivers for each class-code or how can a > single driver manage two different functionalites .Are there any examples on > pci-multifunction drivers .I read in the documents that we need to use mbuf > structure for multi-function devises are there any drivers which uses the > same. > Thanks in advance , > Rashmi.N.S In the FreeBSD driver model, the driver 'probe' method will get called for each PCI function in the system. The driver can either bid to claim it, or reject it. It's up to the driver author as to what criteria is used to bid/accept vs reject a function. Almost all drivers look at the pci device id set. Looking at merely the PCI class code is not recommended since it it far too ambiguous. Also, unlike Linux, the driver does not have easy access to the PCI enumeration internals of the OS. There are also no guarantees as to what order the bus will be probed or what order functions will be enumerated in. Do you actually need to program both functions of the hardware? Usually a bridge device tends to be passive from a driver standpoint. Is there something special that your bridge does? If so then you'll need to write two sets of drivers, each with a unique probe, attach, and detach method. Making the separate driver instances work together will be a bit tricky. The easy but really messy approach is to create some global variables and methods and have the drivers cheat. I'd avoid this is at all possible. Probably the more correct approach is to have each function walk the device tree and look for its sibling, then communicate via custom DEVMETHOD's. This does have performance implications though, so a combination of walking the tree then calling via direct dispatch is probably the best approach if performance is a factor. If you could provide more information about what your device is and what each function does, I can probably give better answers. Scott