How to check how many lanes are used by the PCIe card?

Ok, it seems I missed it on first try in lspci manpages.

Note: Run the command as root/sudo otherwise a lot of detail is ommitted including the Lnk output shown below.

lspci -vv displays a lot of information, including link width:

01:00.0 VGA compatible controller: nVidia Corporation G92 [GeForce 8800 GT] (rev a2) (prog-if 00 [VGA controller])
            [...]
            LnkCap: Port #0, Speed 2.5GT/s, Width x16, ASPM L0s L1, Latency L0 <512ns, L1 <1us
                    ClockPM- Surprise- LLActRep- BwNot-
            LnkCtl: ASPM Disabled; RCB 128 bytes Disabled- Retrain- CommClk+
                    ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
            LnkSta: Speed 2.5GT/s, Width x8, TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-

Sometimes it can be a bit more complicated.

For example, 4 Port GBit ethernet adapters have a PCIe switch on board. I trapped into an issue where I found the Ethernet Adapter connected to x4, but a bottleneck upstream when the onboard pcie switch was connected at x1 to the motherboard only.

See this thread for the issue: http://thread.gmane.org/gmane.linux.drivers.e1000.devel/15192/focus=15254

To get a grasp on tree connectivity, compare the view of

sudo lspci -tv
sudo lspci -vv | grep -P "[0-9a-f]{2}:[0-9a-f]{2}\.[0-9a-f]|LnkSta:"

The last line will show you the Link Status below every device on the bus without the overwelming detail of vv option.

Tags:

Pci