lspci详解

lspci的作用

lspci是一个Linux命令,用于列出系统中的PCI总线设备信息。PCI(Peripheral Component Interconnect)是一种常见的计算机总线标准,用于连接各种外部设备(如网卡、显卡、声卡等)到计算机主板上。

通过运行lspci命令,可以查看系统中安装的PCI设备的详细信息,包括设备的厂商信息、设备ID、驱动程序信息等。lspci命令通常在终端中执行,不需要特殊的权限。

以下是lspci命令的一些常用选项:

-v:显示更详细的设备信息,包括设备的IRQ、I/O端口等。

-nn:显示设备的厂商和设备ID。

-k:显示设备对应的内核模块(驱动程序)信息。

-s <slot>:仅显示指定PCI插槽的设备信息。

通过`lspci`命令,您可以快速了解系统中安装的PCI设备,有助于识别设备、查找驱动程序以及进行系统调试和故障排除。

root@velinux:~# lspci help
Usage: lspci [<switches>]

Basic display modes:
-mm             Produce machine-readable output (single -m for an obsolete format)
-t              Show bus tree

Display options:
-v              Be verbose (-vv for very verbose)
-k              Show kernel drivers handling each device
-x              Show hex-dump of the standard part of the config space
-xxx            Show hex-dump of the whole config space (dangerous; root only)
-xxxx           Show hex-dump of the 4096-byte extended config space (root only)
-b              Bus-centric view (addresses and IRQ's as seen by the bus)
-D              Always show domain numbers

Resolving of device ID's to names:
-n              Show numeric ID's
-nn             Show both textual and numeric ID's (names & numbers)
-q              Query the PCI ID database for unknown ID's via DNS
-qq             As above, but re-query locally cached entries
-Q              Query the PCI ID database for all ID's via DNS

Selection of devices:
-s [[[[<domain>]:]<bus>]:][<slot>][.[<func>]]   Show only devices in selected slots
-d [<vendor>]:[<device>][:<class>]              Show only devices with specified ID's

Other options:
-i <file>       Use specified ID database instead of /usr/share/misc/pci.ids.gz
-p <file>       Look up kernel modules in a given file instead of default modules.pcimap
-M              Enable `bus mapping' mode (dangerous; root only)

PCI access options:
-A <method>     Use the specified PCI access method (see `-A help' for a list)
-O <par>=<val>  Set PCI access parameter (see `-O help' for a list)
-G              Enable PCI access debugging
-H <mode>       Use direct hardware access (<mode> = 1 or 2)
-F <file>       Read PCI configuration dump from a given file

lspci查看设备

root@bsp:/home/bsp-server# lspci
00:00.0 Host bridge: Intel Corporation Sky Lake-E DMI3 Registers (rev 04)
00:04.0 System peripheral: Intel Corporation Sky Lake-E CBDMA Registers (rev 04)
00:04.1 System peripheral: Intel Corporation Sky Lake-E CBDMA Registers (rev 04)
00:04.2 System peripheral: Intel Corporation Sky Lake-E CBDMA Registers (rev 04)
00:04.3 System peripheral: Intel Corporation Sky Lake-E CBDMA Registers (rev 04)
00:04.4 System peripheral: Intel Corporation Sky Lake-E CBDMA Registers (rev 04)
00:04.5 System peripheral: Intel Corporation Sky Lake-E CBDMA Registers (rev 04)
00:04.6 System peripheral: Intel Corporation Sky Lake-E CBDMA Registers (rev 04)
00:04.7 System peripheral: Intel Corporation Sky Lake-E CBDMA Registers (rev 04)

以第一条为例子:

00:00.0 Host bridge: Intel Corporation Sky Lake-E DMI3 Registers (rev 04)

00:00.0表示连接到PCI总线0、插槽0、功能0的PCI设备。通常情况下,PCI设备的地址格式为<总线号>:<插槽号>.<功能号>,用于唯一标识系统中的PCI设备。

  • 0000:00:00.0 中的0000代表PCI域号,用于区分不同的PCI域。在大多数情况下,都是0000,在没有别的域的情况下不会显示出来

可以通过lspci -D显示出来

root@bsp:/home/bsp-server# lspci -d 14e4:168e -D
0000:12:00.0 Ethernet controller: Broadcom Inc. and subsidiaries NetXtreme II BCM57810 10 Gigabit Ethernet (rev 10)
0000:12:00.1 Ethernet controller: Broadcom Inc. and subsidiaries NetXtreme II BCM57810 10 Gigabit Ethernet (rev 10)

Host bridge是主机桥接器,用于连接CPU和其他系统组件

厂商是Intel Corporation

设备类型是Sky Lake-E DMI3 Registers

版本是04

查看指定bdf设备,lspci -s

root@bsp:/home/bsp-server# lspci -s 12:00.0
12:00.0 Ethernet controller: Broadcom Inc. and subsidiaries NetXtreme II BCM57810 10 Gigabit Ethernet (rev 10)

查看指定id的pci设备,lspci -d

root@bsp:/home/bsp-server# lspci -d 14e4:168e
12:00.0 Ethernet controller: Broadcom Inc. and subsidiaries NetXtreme II BCM57810 10 Gigabit Ethernet (rev 10)
12:00.1 Ethernet controller: Broadcom Inc. and subsidiaries NetXtreme II BCM57810 10 Gigabit Ethernet (rev 10)

lspci -v查看更加详细的信息

最多4个v

root@bsp:/home/bsp-server# lspci -s 12:00.0 -v
12:00.0 Ethernet controller: Broadcom Inc. and subsidiaries NetXtreme II BCM57810 10 Gigabit Ethernet (rev 10)
        Subsystem: Hewlett-Packard Company Ethernet 10Gb 2-port 530SFP+ Adapter
        Physical Slot: 1
        Flags: bus master, fast devsel, latency 0, IRQ 26, NUMA node 0
        Memory at df800000 (64-bit, prefetchable) [size=8M]
        Memory at e0000000 (64-bit, prefetchable) [size=8M]
        Memory at e0810000 (64-bit, prefetchable) [size=64K]
        Expansion ROM at de400000 [virtual] [disabled] [size=512K]
        Capabilities: [48] Power Management version 3
        Capabilities: [50] Vital Product Data
        Capabilities: [58] MSI: Enable- Count=1/8 Maskable- 64bit+
        Capabilities: [a0] MSI-X: Enable+ Count=32 Masked-
        Capabilities: [ac] Express Endpoint, MSI 00
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [13c] Device Serial Number b4-7a-f1-ff-fe-72-c3-40
        Capabilities: [150] Power Budgeting <?>
        Capabilities: [160] Virtual Channel
        Capabilities: [1b8] Alternative Routing-ID Interpretation (ARI)
        Capabilities: [220] Physical Resizable BAR
        Capabilities: [300] Secondary PCI Express
        Kernel driver in use: bnx2x
        Kernel modules: bnx2x

查看ID信息,lspci -n

root@bsp:/home/bsp-server# lspci -s 12:00.0 -n
12:00.0 0200: 14e4:168e (rev 10)
root@bsp:/home/bsp-server# lspci -s 12:00.0 -nn
12:00.0 Ethernet controller [0200]: Broadcom Inc. and subsidiaries NetXtreme II BCM57810 10 Gigabit Ethernet [14e4:168e] (rev 10)

查看寄存器值,lspci -x

最多可以使用4个x

 root@bsp:/home/bsp-server# lspci -s 12:00.0 -x
12:00.0 Ethernet controller: Broadcom Inc. and subsidiaries NetXtreme II BCM57810 10 Gigabit Ethernet (rev 10)
00: e4 14 8e 16 46 05 10 00 10 00 00 02 10 00 80 00
10: 0c 00 80 df 00 00 00 00 0c 00 00 e0 00 00 00 00
20: 0c 00 81 e0 00 00 00 00 00 00 00 00 3c 10 9d 33
30: 00 00 00 00 48 00 00 00 00 00 00 00 ff 01 00 00

查看树目录结构,lspci -tv

root@bsp:/home/bsp-server# lspci -tv
-+-[0000:d7]-+-00.0-[d8]--
 |           +-05.0  Intel Corporation Sky Lake-E VT-d
 |           \-16.4  Intel Corporation Sky Lake-E M2PCI Registers
 +-[0000:ae]-+-00.0-[af]--
 |           +-05.0  Intel Corporation Sky Lake-E VT-d

这里只有读取pci设备,那怎么去写呢?

那就是使用setpci,下一篇见

  • 7
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值