Sunday, November 1, 2015

How to find the PCI device information in Linux. ?

We can find the PCI device using the following methods.

1)   vendors by name 
2)   vendors by id 
3)   search devices


http://pcidatabase.com/vendor_details.php?id=607

The Linux kernel represents PCI devices as pseudo-devices in the sysfs file system:
$ ls -la /sys/bus/pci/devices
total 0
drwxr-xr-x 2 root root 0 2009-08-03 10:38 .
drwxr-xr-x 5 root root 0 2009-08-03 10:38 ..
lrwxrwxrwx 1 root root 0 2009-08-03 10:38 0000:00:00.0 -> ../../../devices/pci0000:00/0000:00:00.0
lrwxrwxrwx 1 root root 0 2009-08-03 10:38 0000:00:01.0 -> ../../../devices/pci0000:00/0000:00:01.0
lrwxrwxrwx 1 root root 0 2009-08-03 10:38 0000:00:01.1 -> ../../../devices/pci0000:00/0000:00:01.1
lrwxrwxrwx 1 root root 0 2009-08-03 10:38 0000:00:02.0 -> ../../../devices/pci0000:00/0000:00:02.0
lrwxrwxrwx 1 root root 0 2009-08-03 10:38 0000:00:02.1 -> ../../../devices/pci0000:00/0000:00:02.1
lrwxrwxrwx 1 root root 0 2009-08-03 10:38 0000:00:04.0 -> ../../../devices/pci0000:00/0000:00:04.0
lrwxrwxrwx 1 root root 0 2009-08-03 10:38 0000:00:05.0 -> ../../../devices/pci0000:00/0000:00:05.0
lrwxrwxrwx 1 root root 0 2009-08-03 10:38 0000:00:05.1 -> ../../../devices/pci0000:00/0000:00:05.1
lrwxrwxrwx 1 root root 0 2009-08-03 10:38 0000:00:05.2 -> ../../../devices/pci0000:00/0000:00:05.2
lrwxrwxrwx 1 root root 0 2009-08-03 10:38 0000:00:06.0 -> ../../../devices/pci0000:00/0000:00:06.0
lrwxrwxrwx 1 root root 0 2009-08-03 10:38 0000:00:0a.0 -> ../../../devices/pci0000:00/0000:00:0a.0
lrwxrwxrwx 1 root root 0 2009-08-03 10:38 0000:00:0b.0 -> ../../../devices/pci0000:00/0000:00:0b.0
lrwxrwxrwx 1 root root 0 2009-08-03 10:38 0000:00:0c.0 -> ../../../devices/pci0000:00/0000:00:0c.0
lrwxrwxrwx 1 root root 0 2009-08-03 10:38 0000:00:0d.0 -> ../../../devices/pci0000:00/0000:00:0d.0
lrwxrwxrwx 1 root root 0 2009-08-03 10:38 0000:00:0e.0 -> ../../../devices/pci0000:00/0000:00:0e.0
lrwxrwxrwx 1 root root 0 2009-08-03 10:38 0000:00:0f.0 -> ../../../devices/pci0000:00/0000:00:0f.0
lrwxrwxrwx 1 root root 0 2009-08-03 10:38 0000:00:18.0 -> ../../../devices/pci0000:00/0000:00:18.0
lrwxrwxrwx 1 root root 0 2009-08-03 10:38 0000:00:18.1 -> ../../../devices/pci0000:00/0000:00:18.1
lrwxrwxrwx 1 root root 0 2009-08-03 10:38 0000:00:18.2 -> ../../../devices/pci0000:00/0000:00:18.2
lrwxrwxrwx 1 root root 0 2009-08-03 10:38 0000:00:18.3 -> ../../../devices/pci0000:00/0000:00:18.3
lrwxrwxrwx 1 root root 0 2009-08-03 10:38 0000:01:05.0 -> ../../../devices/pci0000:00/0000:00:06.0/0000:01:05.0
lrwxrwxrwx 1 root root 0 2009-08-03 10:38 0000:01:06.0 -> ../../../devices/pci0000:00/0000:00:06.0/0000:01:06.0
lrwxrwxrwx 1 root root 0 2009-08-03 10:38 0000:02:00.0 -> ../../../devices/pci0000:00/0000:00:0a.0/0000:02:00.0
lrwxrwxrwx 1 root root 0 2009-08-03 10:38 0000:03:00.0 -> ../../../devices/pci0000:00/0000:00:0a.0/0000:02:00.0/0000:03:00.0
lrwxrwxrwx 1 root root 0 2009-08-03 10:38 0000:03:00.1 -> ../../../devices/pci0000:00/0000:00:0a.0/0000:02:00.0/0000:03:00.1
lrwxrwxrwx 1 root root 0 2009-08-03 10:38 0000:04:00.0 -> ../../../devices/pci0000:00/0000:00:0b.0/0000:04:00.0
lrwxrwxrwx 1 root root 0 2009-08-03 10:38 0000:05:00.0 -> ../../../devices/pci0000:00/0000:00:0c.0/0000:05:00.0
Given an entry such as:
lrwxrwxrwx 1 root root 0 2009-08-03 10:38 0000:04:00.0 -> ../../../devices/pci0000:00/0000:00:0b.0/0000:04:00.0
We can break the device string "0000:04:00.0" down as follows:
0000 : PCI domain (each domain can contain up to 256 PCI buses)
04   : the bus number the device is attached to
00   : the device number
.0   : PCI device function
To get additional information about the device, we can change into the 0000:04:00.0 directory and execute our favorite pager to display one or more pseudo-device entries:
$ cd 0000:04:00.0

$ ls -la
total 0
drwxr-xr-x 4 root root     0 2009-08-03 10:38 .
drwxr-xr-x 7 root root     0 2009-08-03 10:38 ..
-rw-r--r-- 1 root root  4096 2009-08-03 12:23 broken_parity_status
-r--r--r-- 1 root root  4096 2009-08-03 10:38 class
-rw-r--r-- 1 root root  4096 2009-08-03 11:34 config
-r--r--r-- 1 root root  4096 2009-08-03 10:38 device
lrwxrwxrwx 1 root root     0 2009-08-03 10:38 driver -> ../../../../bus/pci/drivers/tg3
-rw------- 1 root root  4096 2009-08-03 12:23 enable
lrwxrwxrwx 1 root root     0 2009-08-03 12:12 firmware_node -> ../../../LNXSYSTM:00/device:00/PNP0A03:00/device:1a/device:1b
-r--r--r-- 1 root root  4096 2009-08-03 10:38 irq
-r--r--r-- 1 root root  4096 2009-08-03 12:23 local_cpulist
-r--r--r-- 1 root root  4096 2009-08-03 10:38 local_cpus
-r--r--r-- 1 root root  4096 2009-08-03 12:23 modalias
-rw-r--r-- 1 root root  4096 2009-08-03 12:23 msi_bus
drwxr-xr-x 3 root root     0 2009-08-03 10:38 net
-r--r--r-- 1 root root  4096 2009-08-03 12:23 numa_node
drwxr-xr-x 2 root root     0 2009-08-03 12:12 power
-r--r--r-- 1 root root  4096 2009-08-03 11:34 resource
-rw------- 1 root root 65536 2009-08-03 12:23 resource0
lrwxrwxrwx 1 root root     0 2009-08-03 10:38 subsystem -> ../../../../bus/pci
-r--r--r-- 1 root root  4096 2009-08-03 10:38 subsystem_device
-r--r--r-- 1 root root  4096 2009-08-03 10:38 subsystem_vendor
-rw-r--r-- 1 root root  4096 2009-08-03 10:38 uevent
-r--r--r-- 1 root root  4096 2009-08-03 10:38 vendor
-rw------- 1 root root 32768 2009-08-03 12:23 vpd

$ cat vendor
0x14e4

$ cat device
0x1659

$ cat class
0x020000
Each sysfs entry contains a unique piece of data, such as the PCI vendor id (vendor) the device class (class), the device identifier (device), and information on irq and resource assignments. In the next section, we will see how to decode this data

Note: Taken from the net. 

Regards
Gurudatta N.R

1 comment:

  1. Excellent blog I visit this blog it's really awesome.The important thing is that in this blog content written clearly and understandable.PCI Vendor

    ReplyDelete