From owner-freebsd-current@freebsd.org Fri Apr 1 16:39:38 2016 Return-Path: Delivered-To: freebsd-current@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 481D7AEAAE6 for ; Fri, 1 Apr 2016 16:39:38 +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 254761C50 for ; Fri, 1 Apr 2016 16:39:38 +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 2E8C6B984; Fri, 1 Apr 2016 12:39:37 -0400 (EDT) From: John Baldwin To: Luigi Rizzo Cc: Ryan Stone , Jim Harris , FreeBSD Current , Giuseppe Lettieri , Vincenzo Maffione Subject: Re: accessing a PCIe register from userspace through kmem or other ways ? Date: Fri, 01 Apr 2016 09:31:22 -0700 Message-ID: <5045119.GKNSyI10vh@ralph.baldwin.cx> User-Agent: KMail/4.14.3 (FreeBSD/10.2-STABLE; KDE/4.14.3; amd64; ; ) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Fri, 01 Apr 2016 12:39:37 -0400 (EDT) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2016 16:39:38 -0000 On Friday, April 01, 2016 01:07:55 PM Luigi Rizzo wrote: > On Thu, Mar 31, 2016 at 11:55 PM, Ryan Stone wrot= e: >=20 > > On Thu, Mar 31, 2016 at 4:39 PM, John Baldwin wro= te: > > > >> On Wednesday, March 30, 2016 11:20:51 AM Jim Harris wrote: > >> > On Wed, Mar 30, 2016 at 10:47 AM, Luigi Rizzo > >> wrote: > >> > > >> > > Hi, > >> > > I'd like to test the rate at which I can access device registe= rs > >> > > on a PCIe card, and was wondering whether I need to patch a de= vice > >> > > driver, or perhaps I can use /dev/kmem once I figure out where= > >> > > the registers are mapped ? > >> > > > >> > > >> > You do not need to patch a device driver. Have you looked at > >> > libpciaccess? This should give you everything you need. > >> > >> You can also look at what pciconf uses. (It has a read_config() m= ethod > >> that uses an ioctl on an fd of /dev/pci). > >> > > > > pciconf can only access the configuration space, right? I believe = that > > Luigi is more interested in measuring the latency to a register map= ped from > > a BAR. > > >=20 > =E2=80=8BThank you all for you answers, I will look at libpciaccess. >=20 > Yes my goal is to look at the rate and latency for accessing > BAR-mapped registers Sorry, I mapped PCIe registers to the PCI-e config space register set. = I am not sure exactly how libpciaccess handles register access (perhaps it r= eads raw bars and maps them via /dev/mem)? However, it would not be hard to= a new ioctl to /dev/pci to allow one to mmap a specific BAR of a given de= vice. --=20 John Baldwin