What is lspci in linux

Linux lspci Command Tutorial with Examples

Linux provides lspci command in order to list PCI bus and devices information. This command will provide brief or detailed information about currently connected PCI devices like GPU, USB Card etc.

Install For Ubuntu, Debian, Kali, Mint

We can install lspci tool with the following command to the deb based distributions.

Install For Ubuntu, Debian, Kali, Mint

Install For Fedora, CentOS, Fedora

In yum or dnf based distributions we can use the following command which will install the package named pciutils .

Install For Fedora, CentOS, Fedora

List PCI Devices

We will start with the simplest form where we will do not provide any option to this command. This will print PCI Address or slot information with the device type and vendor information.

List PCI Devices

Show Specified Slot or Address Devices

Most of the computers have a few PCI interfaces. This may list a lot of information which will jam the output. Or we may be interested in the specific PCI slot of address. In this example, we will print information about PCI slot number 00:10.0 which is SCSI device controller.

Show Specified Slot or Address Devices

The default printing format is human-readable format. This means PCI address or slot, vendor and product information is printed in a space delimited format. Machine-readable format is a double quote separated format which can be parsed easily.

Print Machine-Readable Format

Verbose Output

PCI bus provides a lot of information about the PCI connection and the devices. By default, this information is not printed completely. We can print detailed information about this PCI connection and device with the verbose -v option like below.

Verbose Output

We can see that for every PCI device information like Subsystem, Flag, Memory Location or Address, Kernel Driver In Use, Kernel Modules, I/O ports etc.

We can also print PCI Slot and Devices information in tag:value format. This will make the information readable like JSON format. We will use -vmms option like below.

Print Information In Tag:Value Format

Every computer hardware manufacturer has its own vendor and device code or ID. We can print device vendor, class, svendor,sdevice ID with the -n option like below.

Print Device Vendor Codes

Show Kernel Module Of The PCI Devices

As very PCI device have its kernel module and driver to be used by the Linux operating system. We can list all kernel and drivers with the -k option like below.

Show Kernel Module Of The PCI Devices

Читайте также:  Windows 10 настройка жестов тачпада

We can see that the following information is provided by -k .

  • Device Name
  • Subsystem
  • Kernel driver
  • Kernel module

List PCI Devices In Tree Format

Up to now, we have listed PCI Devices in a line by line or regular format. We can also list the output of the lspci in a tree format with a hierarchical manner. We will use -t option like below.

List PCI Devices In Tree Format

We can see that some devices are listed under VMware USB controller.

Very Verbose Mode All Details

We have already printed detailed or verbose information about the PCI slots. We will use multiple -v option -vv or -vvv . More v means more verbose or detail.

Источник

О команде lspci в Linux

Главное меню » Linux » О команде lspci в Linux

В этой статье мы объясним основы PCI, PCIe и команды lspci для отображения информации в вашей системе.

Что такое PCI?

PCI или Peripheral Component Interconnect – это интерфейс для добавления дополнительных аппаратных компонентов в компьютерную систему. PCIe или PCI Express – это обновленный стандарт, который используется сегодня. Например, предположим, что вы хотите добавить карту Ethernet к своему компьютеру, чтобы он мог получать доступ к Интернету и обмениваться данными. Карта нуждается в протоколе для связи с остальной частью внутренней системы, PCI может быть стандартным интерфейсом, используемым для добавления этой карты в вашу систему. Вам по-прежнему нужен драйвер для этой карты, чтобы ядро ​​могло его использовать, однако PCI – это слот, а также шина и интерфейс, которые будут использоваться для добавления оборудования в систему со стандартным интерфейсом. Создание драйвера PCI linux будет следовать некоторым стандартным интерфейсам. Вы можете увидеть из структуры ниже стандартные методы, которые необходимо реализовать. Такие методы, как зондирование, удаление, приостановка, возобновление и т. д.

Скорость и использование PCI

PCI 3.0 может передавать данные со скоростью до 1 ГБ/сек на полосу. Различные устройства могут иметь более одной полосы, поэтому возможно, что отдельные устройства могут иметь скорость передачи данных в несколько гигабайт. Эти цифры всегда улучшаются по мере выхода новых версий спецификации и нового оборудования, поэтому всегда проверяйте наличие новейших и наиболее быстрых из возможных. Типы компонентов и гаджетов, которые вы можете купить с подключением к интерфейсу PCI, включают: адаптеры WIFI, Bluetooth, карты твердотельного хранилища NVME, видеокарты и многое другое.

Изучение команды lspci

Мы создали экземпляр Ubuntu 19.04 в облаке Google и теперь запущу команду lspci и посмотрю, что произойдет.

Вы видите по одной строке на устройство с числовым кодом и словесным описанием устройства. Фактически в этом выводе отображается 5 полей в каждой строке: слот, класс, поставщик, устройство и версия.

Итак, разбив первую строку, что у нас есть:

SLOT: 00: 00.0
Класс: Хост-мост
Производитель: Intel Corporation
Устройство: 440FX – 82441FX PMC
Revision: 02

И если посмотреть на слот 00: 04.0, это наш контроллер Ethernet, который выглядит как виртуальное устройство как часть виртуальной магии облачного развертывания Google.

Чтобы получить более подробную и подробную информацию о каждом слоте PCI, выполните следующую команду:

Эта команда разбивает каждую строку на поля компонентов и позволяет анализировать каждое устройство с помощью более описательных меток.

Вы также можете попробовать опцию -v для более подробного вывода

И используйте double v или tripple v для подробного вывода:

Или попробуйте параметр -mm для формата вывода, читаемого сценарием.

Чтобы узнать, какой драйвер ядра используется для каждого устройства, запустите параметр -k.

Читайте также:  Nmi hardware failure windows 2019

Многие из моих устройств используют драйвер virtio-pci.

Наконец, вы даже можете увидеть шестнадцатеричный дамп «стандартной части конфигурационного пространства» для каждого устройства PCI. Вы должны быть настоящим хакером ядра, чтобы понять, как использовать эту информацию. -x – это то, что дает вам вывод дампа.

Вывод

Команда lspci – это стандартная команда Linux, которую можно использовать для вывода информации об устройствах, подключенных к PCI в вашей системе. Это может быть полезно, чтобы узнать, какое у вас периферийное оборудование. Он также очень полезен для разработчиков, создателей драйверов устройств и системных специалистов низкого уровня для запроса информации об устройствах, драйверах и системе. Наслаждайтесь использованием lspci.

Если вы нашли ошибку, пожалуйста, выделите фрагмент текста и нажмите Ctrl+Enter.

Источник

lspci

lspci is a handy GNU/Linux command-line utility which will display all kinds of incriminating information about a computers PCI and PCIe devices. It is provided by the pciutils package.

Examples [ edit ]

lspci will, without any arguments, show a simple list of the devices that are connected to the system — not just those that are in PCI(e) slots; it will also show bridges and on-board devices. Here is a partial example of what lspci s output will look like:

Adding the -v will make lspci output a lot more information about each device. Adding it twice ( -vv ) adds even more information to that list. Most of the information lspci -v and lspci -vv can display is only available as root. lspci will happily run lspci -vv as any user and present what it can find out as a regular user. This will be a much shorter list than you get if you run lspci -vv as root.

lspci has a useful -t option which provides a handy tree output which shows what devices are connected to what bridge. Using this option will, by default, only list the PCIe IDs. Combining it with -v to get a «verbose» output is therefore a good idea.


Example of lspci -tv output.

lspci has a lot more switches. Consult the lspci manual page or run lspci -h to see them all.

Listing PCIe devices IOMMU Groups [ edit ]

lspci can’t and won’t show you what IOMMU group a PCIe device belongs to. That’s fine, it is possible to find out without it’s help and use it to list the actual information about each device. The trick is to poke around in /sys/ to get the relevant information.


Example output of a script using lspci to get information about a systems IOMMU devices.

Place this in $HOME/bin or /usr/local/bin/ and make it executable with chmod a+x to use it. It can be used as a regular user, it does not require root .

Источник

About lspci Command on Linux

In this article we will explain the basics of PCI, PCIe and the lspci command to display information on your system.

What is PCI?

PCI, or Peripheral Component Interconnect is an interface to add additional hardware components to a computer system. PCIe or PCI Express is the updated standard that is used today. For example let’s say you want to add a Ethernet card to your computer so that it can access the internet and exchange data. Well the card needs a protocol to communicate with the rest of the internal system, PCI can be the standard interface used to add this card to your system. You still need a driver for this card in order for the kernel to use it, however PCI is the slot, and bus and interface that will be used to add the hardware into the system with a standard interface. Creation of a PCI linux driver will follow some standard interfaces you can see documentation for creating a PCI linux driver here. You can see from the struct below the standard methods that must be implemented. Methods such as probe, remove, suspend, resume, etc.

Читайте также:  Драйвер для intel hd graphics 4400 windows 10

PCI Speeds and Uses

PCI 3.0 can run data up to 1GB/Sec per lane. Different devices can have more than one lane, so it’s possible that individual devices can have multi-gigabytes of data transfer rate. These numbers are always improving as new versions of the specification come out and new hardware comes out, so always check for the latest and fastest you can find. Types of components and gadgets that you can buy that plug into a PCI interface include: WIFI adapters, Bluetooth, NVME Solid State Storage cards, Graphics cards and more.

Exploring the lspci Command

I have created a Ubuntu 19.04 instance on Google cloud and will now run the lspci command and see what happens.

What you see is one line per device with a numerical code and a verbal description of the device. There are actually 5 fields displayed in this output per line: Slot, Class, Vendor, Device, and Revision.

So breaking down the first line what we have:

SLOT: 00:00.0
Class: Host bridge
Vendor: Intel Corporation
Device: 440FX – 82441FX PMC
Revision: 02

And looking at Slot 00:04.0 that is our Ethernet controller, which appears to be a virtual device as part of the virtual magic of Google’s cloud deployment.

To get more detailed, verbose information about each PCI slot, run the following command:

This command will break down each line into its component fields and allow you to analyze each device with more descriptive labels.

You can also try the -v option for more verbose output

And use double v or tripple v for verby verbose output:

Or try the -mm option for script readable output format.

In order to see which kernel driver is being used for each device run -k option.

Many of my devices are using virtio-pci driver.

Lastly you can even see a hexadecimal dump of “the standard part of the configuration space” for each PCI device. You should be a real kernel hacker to figure out how to use that information. -x option is what gives you the dump output.

Conclusion

The lspci command is a standard Linux command that can be used to list information about the PCI connected devices on your system. This can be useful to know what hardware peripherals you have. Its also super useful for developers, device driver creators, low level system folks to query information about the devices, the drivers and the system. Enjoy using lspci.

About the author

Linux Wolfman

Linux Wolfman is interested in Operating Systems, File Systems, Databases and Analytics and always watching for new technologies and trends. Reach me by tweeting to @linuxhint and ask for the Wolfman.

Источник

Оцените статью