From owner-freebsd-drivers@freebsd.org Fri Sep 28 16:43:51 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 65BB310B4A26 for ; Fri, 28 Sep 2018 16:43:51 +0000 (UTC) (envelope-from rj@obsigna.com) Received: from mail.cyclaero.com (ec2-18-195-62-44.eu-central-1.compute.amazonaws.com [18.195.62.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D3D2279CB8 for ; Fri, 28 Sep 2018 16:43:50 +0000 (UTC) (envelope-from rj@obsigna.com) Received: from mail.obsigna.com (unknown [191.182.171.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.cyclaero.com (Postfix) with ESMTPSA id D3F8089; Fri, 28 Sep 2018 18:43:42 +0200 (CEST) Received: from rolf-mini.obsigna.com (rolf-mini.obsigna.com [192.168.222.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.obsigna.com (Postfix) with ESMTPSA id A153C1350F946; Fri, 28 Sep 2018 13:43:37 -0300 (BRT) From: "Dr. Rolf Jansen" Message-Id: Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Subject: Re: Writing a PCIe-Driver Date: Fri, 28 Sep 2018 13:43:36 -0300 In-Reply-To: <20180928161205.GN75530@funkthat.com> Cc: freebsd-drivers@freebsd.org To: John-Mark Gurney References: <20180928161205.GN75530@funkthat.com> X-Mailer: Apple Mail (2.3445.9.1) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.27 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:43:51 -0000 > Am 28.09.2018 um 13:12 schrieb John-Mark Gurney : >=20 > 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. >>=20 >> See: How to map device addresses into user space >> = https://lists.freebsd.org/pipermail/freebsd-drivers/2013-January/thread.ht= ml >>=20 >> 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. >>=20 >> = https://www.freebsd.org/doc/en_US.ISO8859-1/books/arch-handbook/pci.html >>=20 >> 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? >=20 > I'm a bit surprised that this didn't work, as PCIe is effectively > backwards compatible w/ PCI except a few exceptions like MSI... >=20 > 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... In the meantime, the issue has been resolved. See my other post on this = list: = https://lists.freebsd.org/pipermail/freebsd-drivers/2018-September/002129.= html = The driver is working now, and I am able to address the basic = functionality of the NI PCIe-6351 DAQ board from user space. I didn=E2=80=99= t come to check whether interrupts and DMA do work like it did with the = older PCI DAQ boards. Best regards Rolf=20=