lspci useful examples

Thank you for visiting this page, this page has been update in another link lspci useful examples


       lspci is a utility for displaying information about PCI buses in the system and devices connected to them.

       By  default,  it  shows  a  brief  list  of devices. Use the options described below to request either a more verbose output or output
       intended for parsing by other programs.
# lspci
00:00.0 Host bridge: Intel Corporation 5520 I/O Hub to ESI Port (rev 22)
...
00:16.7 System peripheral: Intel Corporation 5520/5500/X58 Chipset QuickData Technology Device (rev 22)
00:1a.0 USB controller: Intel Corporation 82801JI (ICH10 Family) USB UHCI Controller #4
...
00:1d.7 USB controller: Intel Corporation 82801JI (ICH10 Family) USB2 EHCI Controller #1
...
0b:00.1 Ethernet controller: Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet (rev 20)
15:00.0 Fibre Channel: QLogic Corp. ISP2532-based 8Gb Fibre Channel to PCI Express HBA (rev 02)
15:00.1 Fibre Channel: QLogic Corp. ISP2532-based 8Gb Fibre Channel to PCI Express HBA (rev 02)
1f:00.0 Ethernet controller: Mellanox Technologies MT26448 [ConnectX EN 10GigE, PCIe 2.0 5GT/s] (rev b0)
The output shows that the whole system pci devices, the first column is each device slot number.
This example shows device in the slot

# lspci -s 1f:00.0
1f:00.0 Ethernet controller: Mellanox Technologies MT26448 [ConnectX EN 10GigE, PCIe 2.0 5GT/s] (rev b0)

       -s [[[[<domain>]:]<bus>]:][<slot>][.[<func>]]
              Show  only  devices  in the specified domain (in case your machine has several host bridges, they can either share a common bus number space or each of them can address a PCI domain of its own; domains are numbered from 0 to ffff), bus (0 to ff), slot  (0 to 1f) and function (0 to 7).  Each component of the device address can be omitted or set to "*", both meaning "any value". All numbers are hexadecimal.  E.g., "0:" means all devices on bus 0, "0" means all functions of device 0 on any bus, "0.3"  selects third function of device 0 on all buses and ".4" shows only the fourth function of each device.

This example shows device verbose output, a sequence of records separated by blank lines. Each line containing a single 'tag: value' pair
# lspci -vmms 1f:00.0
Slot:    1f:00.0
Class:    Ethernet controller
Vendor:    Mellanox Technologies
Device:    MT26448 [ConnectX EN 10GigE, PCIe 2.0 5GT/s]
SVendor:    Mellanox Technologies
SDevice:    Device 0013
PhySlot:    4
Rev:    b0

-mm    Dump PCI device data in a machine readable form for easy parsing by scripts.
-n     Show PCI vendor and device codes as numbers instead of looking them up in the PCI ID list, useful for scripting and programing

# lspci -nvmms 1f:00.0
Slot:    1f:00.0
Class:    0200
Vendor:    15b3
Device:    6750
SVendor:    15b3
SDevice:    0013
PhySlot:    4
Rev:    b0
The following tags are defined
       Slot    The name of the slot where the device resides ([domain:]bus:device.function).  This tag is always the first in a record.
       Class   Name of the class.
       Vendor  Name of the vendor.
       Device  Name of the device.
       SVendor  Name of the subsystem vendor (optional).
       SDevice  Name of the subsystem (optional).
       PhySlot  The physical slot where the device resides (optional, Linux only).
       Rev     Revision number (optional).
       ProgIf  Programming interface (optional).
       Driver  Kernel driver currently handling the device (optional, Linux only).
       Module  Kernel module reporting that it is capable of handling the device (optional, Linux only).
Show kernel module of a device
# lspci -ks 1f:00.0
1f:00.0 Ethernet controller: Mellanox Technologies MT26448 [ConnectX EN 10GigE, PCIe 2.0 5GT/s] (rev b0)
    Subsystem: Mellanox Technologies Device 0013
    Kernel driver in use: mlx4_core
    Kernel modules: mlx4_core, mlx4_en

There is also a easy way to run lspci if you don't mind to search things in a big output
       -v     Be verbose and display detailed information about all devices.

       -vv    Be very verbose and display more details. This level includes everything deemed useful.

       -vvv   Be even more verbose and display everything we are able to parse, even if it doesn't look interesting at all  (e.g.,  undefined
              memory regions).
Pretty much everything you need are here, including device part number
# lspci -vvvs 1f:00.0
1f:00.0 Ethernet controller: Mellanox Technologies MT26448 [ConnectX EN 10GigE, PCIe 2.0 5GT/s] (rev b0)
    Subsystem: Mellanox Technologies Device 0013
    Physical Slot: 4
    Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr+ Stepping- SERR- FastB2B- DisINTx+
    Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
    Latency: 0, Cache Line Size: 64 bytes
    Interrupt: pin A routed to IRQ 30
    Region 0: Memory at 97a00000 (64-bit, non-prefetchable) [size=1M]
    Region 2: Memory at fb800000 (64-bit, prefetchable) [size=8M]
    Expansion ROM at <ignored> [disabled]
    Capabilities: [40] Power Management version 3
        Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
        Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
    Capabilities: [48] Vital Product Data
        Product Name: Hawk Dual Port
        Read-only fields:
            [PN] Part number: 81Y1540             
            [EC] Engineering changes: A3
            [SN] Serial number: 81Y1540YK502000045L    
            [V0] Vendor specific: PCIe Gen2 x8   
            [RV] Reserved: checksum good, 0 byte(s) reserved
        Read/write fields:
            [V1] Vendor specific: N/A  
            [YA] Asset tag: N/A                            
            [RW] Read-write area: 106 byte(s) free
        End
    Capabilities: [9c] MSI-X: Enable+ Count=128 Masked-
        Vector table: BAR=0 offset=0007c000
        PBA: BAR=0 offset=0007d000
    Capabilities: [60] Express (v2) Endpoint, MSI 00
        DevCap:    MaxPayload 256 bytes, PhantFunc 0, Latency L0s <64ns, L1 unlimited
            ExtTag- AttnBtn- AttnInd- PwrInd- RBE+ FLReset+
        DevCtl:    Report errors: Correctable- Non-Fatal+ Fatal+ Unsupported-
            RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop- FLReset-
            MaxPayload 256 bytes, MaxReadReq 4096 bytes
        DevSta:    CorrErr- UncorrErr- FatalErr- UnsuppReq- AuxPwr- TransPend-
        LnkCap:    Port #8, Speed 5GT/s, Width x8, ASPM L0s, Latency L0 unlimited, L1 unlimited
            ClockPM- Surprise- LLActRep- BwNot-
        LnkCtl:    ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk-
            ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
        LnkSta:    Speed 5GT/s, Width x8, TrErr- Train- SlotClk- DLActive- BWMgmt- ABWMgmt-
        DevCap2: Completion Timeout: Range ABCD, TimeoutDis+, LTR-, OBFF Not Supported
        DevCtl2: Completion Timeout: 260ms to 900ms, TimeoutDis-, LTR-, OBFF Disabled
        LnkCtl2: Target Link Speed: 5GT/s, EnterCompliance- SpeedDis-
             Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
             Compliance De-emphasis: -6dB
        LnkSta2: Current De-emphasis Level: -3.5dB, EqualizationComplete-, EqualizationPhase1-
             EqualizationPhase2-, EqualizationPhase3-, LinkEqualizationRequest-
    Capabilities: [100 v1] Alternative Routing-ID Interpretation (ARI)
        ARICap:    MFVC- ACS-, Next Function: 0
        ARICtl:    MFVC- ACS-, Function Group: 0
    Capabilities: [148 v1] Device Serial Number 00-02-c9-03-00-4f-68-7e
    Kernel driver in use: mlx4_core
    Kernel modules: mlx4_core, mlx4_en

If you know verdor code and device code, then you can search the device slot and other info, it seems not useful, but in scripting, it's useful.

# lspci -vmmd 1077:2532
Slot:    15:00.0
Class:    Fibre Channel
Vendor:    QLogic Corp.
Device:    ISP2532-based 8Gb Fibre Channel to PCI Express HBA
SVendor:    QLogic Corp.
SDevice:    Device 015d
PhySlot:    2
Rev:    02

Slot:    15:00.1
Class:    Fibre Channel
Vendor:    QLogic Corp.
Device:    ISP2532-based 8Gb Fibre Channel to PCI Express HBA
SVendor:    QLogic Corp.
SDevice:    Device 015d
PhySlot:    2
Rev:    02
For more info about sysfs filesystem
https://www.kernel.org/pub/linux/kernel/people/mochel/doc/papers/ols-2005/mochel.pdf
原文地址:https://www.cnblogs.com/dream397/p/13552407.html