Is there a utility to peek and poke PCIe devices

Is there a utility that does peeks and pokes to PCIe devices. I'm developing an FPGA with a PCIe interface and I'd like to do some simple memory accesses before I move on to the more complicated things like DMA. We have a driver in development but I think there is a standard Altera driver already in the kernel which I assume would be good enough for simple accesses.

I'm running on Scientific Linux 6.1.

lspci identifies the device as an Altera device which is correct.

01:00.0 Unassigned class [ff00]: Altera Corporation Device 0004 (rev 01)
Reply to
General Schvantzkoph
Loading thread data ...

you don't even need a driver for simple memory access. if your device is detected by the kernel you can directly access the BARs via sysfs: # ls -l /sys/bus/pci/devices/0000\:01\:00.0/ [...]

-rw------- 1 root root 256M Aug 11 08:51 resource0

-rw------- 1 root root 256 Aug 11 08:51 resource1

-rw------- 1 root root 64K Aug 2 08:14 resource2 [...]

This is an example of a device with 3 BARs. These files can be read/written/mmapped... you could use "dd" or write a little C program to mmap the files.

HTH

Reply to
rndhro

(snip)

I remember doing this with VME based Suns and SunOS. Device mapped VME addressing space, and memory mapped files combine to form memory mapped memory space.

-- glen

Reply to
glen herrmannsfeldt

How do I determine which device is mine?

Here is the lspci output

01:00.0 Unassigned class [ff00]: Altera Corporation Device 0004 (rev 01)

Here are the devices under /sys/bus/pci_express/devices

0000:00:0b.0:pcie01/ 0000:00:0c.0:pcie01/ 0000:00:0d.0:pcie01/ 0000:00:0e.0:pcie01/ 0000:00:0b.0:pcie08/ 0000:00:0c.0:pcie08/ 0000:00:0d.0:pcie08/ 0000:00:0e.0:pcie08

Here are the devices under /sys/bus/pci/devices

0000:00:00.0/ 0000:00:02.0/ 0000:00:06.0/ 0000:00:09.0/ 0000:00:0c.0/ 0000:00:18.0/ 0000:00:18.3/ 0000:05:00.0/ 0000:00:01.0/ 0000:00:02.1/ 0000:00:07.0/ 0000:00:0a.0/ 0000:00:0d.0/ 0000:00:18.1/ 0000:01:0d.0/ 0000:00:01.1/ 0000:00:04.0/ 0000:00:08.0/ 0000:00:0b.0/ 0000:00:0e.0/ 0000:00:18.2/ 0000:03:00.0
Reply to
General Schvantzkoph

you should be able to use the pci-ID from lspci as directory name in /sys/bus/pcie/devices/

I don't really know why your device 0000:01:00.0 doesn't appear here - did you list the directory on the same machine & while the card is detected? Just a guess: maybe you have to set a device class in the FPGA Firmware other than ff00? (my Xilinx ML605 gets detected as "RAM memory" for example by setting the appropriate device/vendor IDs)

Reply to
rndhro

0000:00:0c.0/
0000:00:02.1/
0000:01:0d.0/
0000:00:0e.0/

I'm switching the class to 5 from FF, I'll see what happens.

Reply to
General Schvantzkoph

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.