From owner-freebsd-drivers@freebsd.org Thu Sep 3 23:07:12 2015 Return-Path: Delivered-To: freebsd-drivers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CB4D79CA456; Thu, 3 Sep 2015 23:07:12 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A97421029; Thu, 3 Sep 2015 23:07:12 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id C01C0B941; Thu, 3 Sep 2015 19:07:11 -0400 (EDT) From: John Baldwin To: freebsd-hackers@freebsd.org, Nomad Esst Cc: "freebsd-drivers@freebsd.org" Subject: Re: Get pci slot number in driver Date: Thu, 03 Sep 2015 15:57:15 -0700 Message-ID: <8357967.OxrZP5NxFz@ralph.baldwin.cx> User-Agent: KMail/4.14.3 (FreeBSD/10.2-PRERELEASE; KDE/4.14.3; amd64; ; ) In-Reply-To: <1473579278.716147.1440404222458.JavaMail.yahoo@mail.yahoo.com> References: <1473579278.716147.1440404222458.JavaMail.yahoo@mail.yahoo.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Thu, 03 Sep 2015 19:07:11 -0400 (EDT) X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Sep 2015 23:07:12 -0000 On Monday, August 24, 2015 08:17:02 AM Nomad Esst via freebsd-hackers wrote: > Is it possible to find out the pci slot number on which the card is mounted in driver? I tried pci_get_slot but it's always 0.Any ideas about doing this? > regards It depends on what you mean by slot. If you mean the label of the physical slot in a chassis / motherboard, then there is no reliable way to determine this. (There are some PCI extended capabilities that I've never seen in the wild that can communicate this. There are various firmware tables ($PIR and SMBIOS) on x86 that can in theory tell you this, but it's a crap shoot whether the tables are correct or a pack of lies. If you want to determine the "device" field of a PCI device's (bus, device, function) config space access, you can use pci_get_slot() (FreeBSD calls it a slot even though the standard name in the PCI spec is "device" for legacy reasons as in original PCI a physical slot did have a unique "device" address on a given bus). -- John Baldwin