From owner-freebsd-drivers@freebsd.org Fri Sep 28 16:12:09 2018 Return-Path: Delivered-To: freebsd-drivers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EA9A510B4064 for ; Fri, 28 Sep 2018 16:12:08 +0000 (UTC) (envelope-from jmg@gold.funkthat.com) Received: from gold.funkthat.com (gate2.funkthat.com [208.87.223.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "gate2.funkthat.com", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5DF1F7875F for ; Fri, 28 Sep 2018 16:12:08 +0000 (UTC) (envelope-from jmg@gold.funkthat.com) Received: from gold.funkthat.com (localhost [127.0.0.1]) by gold.funkthat.com (8.15.2/8.15.2) with ESMTPS id w8SGC6aE064693 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 28 Sep 2018 09:12:07 -0700 (PDT) (envelope-from jmg@gold.funkthat.com) Received: (from jmg@localhost) by gold.funkthat.com (8.15.2/8.15.2/Submit) id w8SGC5Fx064691; Fri, 28 Sep 2018 09:12:05 -0700 (PDT) (envelope-from jmg) Date: Fri, 28 Sep 2018 09:12:05 -0700 From: John-Mark Gurney To: "Dr. Rolf Jansen" Cc: freebsd-drivers@freebsd.org Subject: Re: Writing a PCIe-Driver Message-ID: <20180928161205.GN75530@funkthat.com> Mail-Followup-To: "Dr. Rolf Jansen" , freebsd-drivers@freebsd.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: FreeBSD 11.0-RELEASE-p7 amd64 X-PGP-Fingerprint: D87A 235F FB71 1F3F 55B7 ED9B D5FF 5A51 C0AC 3D65 X-Files: The truth is out there X-URL: https://www.funkthat.com/ X-Resume: https://www.funkthat.com/~jmg/resume.html X-TipJar: bitcoin:13Qmb6AeTgQecazTWph4XasEsP7nGRbAPE X-to-the-FBI-CIA-and-NSA: HI! HOW YA DOIN? can i haz chizburger? User-Agent: Mutt/1.6.1 (2016-04-27) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (gold.funkthat.com [127.0.0.1]); Fri, 28 Sep 2018 09:12:07 -0700 (PDT) X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Sep 2018 16:12:09 -0000 Dr. Rolf Jansen wrote this message on Sun, Sep 23, 2018 at 12:56 -0300: > A couple of years ago, with the valuable help of people on this list, I managed to write a PCI driver for the National Instruments DAQ card, NI PCI-6251. The driver was kept very simple, only map the BAR???s and some DMA memory into the user space. The DAC/ADC and DIO is then all controlled from user space by writing command codes to certain offsets from the mapped BAR???s, and reading data from the mapped DMA memory and/or from other given offsets. > > See: How to map device addresses into user space > https://lists.freebsd.org/pipermail/freebsd-drivers/2013-January/thread.html > > > Now, I need to do exactly the same for a PCIe card, namely the NI PCIe-6351. However, I even cannot see where to start. For PCI cards, the respective chapter 11 in the FreeBSD Architecture Handbook was quite helpful, for getting started, in no time, I got the PCI card probed and attached. > > https://www.freebsd.org/doc/en_US.ISO8859-1/books/arch-handbook/pci.html > > The dumb approach, probing the device ID and attaching the PCI(e) driver to the PCIe device in a similar fashion didn???t work - I didn???t expect this either, however, where would I start? How do I attach my driver to a PCIe card on FreeBSD 11 or 12? I'm a bit surprised that this didn't work, as PCIe is effectively backwards compatible w/ PCI except a few exceptions like MSI... Many drivers like em (sys/dev/e1000/if_em.c) are used for both PCI and PCIe cards.. Maybe look at what they are doing differently than your driver... > Please can somebody push me into the right direction. Once I got the driver attached to the card, I guess, I would be able to adapt the mem-mapping code of my old driver for the new card. -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."