Do you know the hardware your software is running on?

Do you know the hardware your software is running on?

As a DevOps professional the hardware is usually discussed in terms of capacity and performance, and that’s pretty much the level required as most of the effort is related to software and configuration. There are situations though that require more information on the hardware presented on the system. Let’s see how the we can find out more about the PCI bus and other devices can be extracted from the system.

 

A handy tool in Linux distros is lspci. As the name suggests, the tool will enumerate all the devices connected to the PCI bus. To do this,  it will use the libpci library, which supports different methods to access the configuration. Each device is identified by the domain it belongs to, the bus number,  the slot and the function with the domain:bus:slot.func format. Domain names are missing unless requested explicitly by the command with the -D option.

 

Usually, lspci is combined with grep to identify the device you are looking for:

stot@lab:~$ lspci | grep -i ethernet
00:1f.6 Ethernet controller: Intel Corporation Ethernet Connection (4) I219-V (rev 21)

This will show us that on the bus number 00, in the slot 1f, the 6th function is an ethernet controller – the NIC we want to investigate.

 

Above we identified a device by its name, but let’s say you want to see what is on a specific slot. We can use with the lspci command with the option -s which will interrogate for a specific bus/slot:

stot@lab:~$ lspci -s 00:1f
00:1f.0 ISA bridge: Intel Corporation Device 9d58 (rev 21)
00:1f.2 Memory controller: Intel Corporation Sunrise Point-LP PMC (rev 21)
00:1f.3 Audio device: Intel Corporation Device 9d71 (rev 21)
00:1f.4 SMBus: Intel Corporation Sunrise Point-LP SMBus (rev 21)
00:1f.6 Ethernet controller: Intel Corporation Ethernet Connection (4) I219-V (rev 21)

 

Let’s follow the NIC example, say we want to find more info at this point. We know that the NIC is connected on bus 00, at the slot 1f, on 6th function. To dig deeper, we can use up to three levels of verbosity. In our case, it will look like this:

stot@lab:~$ sudo lspci -vvs 00:1f.6
00:1f.6 Ethernet controller: Intel Corporation Ethernet Connection (4) I219-V (rev 21)
Subsystem: Lenovo Ethernet Connection (4) I219-V
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
Interrupt: pin A routed to IRQ 130
Region 0: Memory at f1400000 (32-bit, non-prefetchable) [size=128K]
Capabilities: [c8] 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=1 PME-
Capabilities: [d0] MSI: Enable+ Count=1/1 Maskable- 64bit+
Address: 00000000fee00358  Data: 0000
Capabilities: [e0] PCI Advanced Features
AFCap: TP+ FLR+
AFCtrl: FLR-
AFStatus: TP-
Kernel driver in use: e1000e
Kernel modules: e1000e

 

We can see that the command provided different parameters like the kernel module used, the IRQ assigned and more. One thing to keep in mind is that the lspci command provides all the details the current user has access to. In our case, the “Capabilities” section appears only if we run the command as root (sudo). Otherwise, it will just print an “<access denied>” message for the “Capabilities”.

Now, that you have the basic commands to understand your hardware, why not discover it?

Sergiu Tot – Senior Support Engineer & Trainer at SmartSpot

No Comments

Post A Comment