I use the following commands.
lspci -vv provides verbose output. It's parsed with grep to only view "Width" as follows:
lspci -vvv | egrep "0[0-9]:|Width\ "
03:00.0 Ethernet controller: Mellanox Technologies MT26448 [ConnectX EN 10GigE, PCIe 2.0 5GT/s] (rev b0)
pcilib: sysfs_read_vpd: read failed: Input/output error
LnkCap: Port #8, Speed 5GT/s, Width x8, ASPM L0s, Exit Latency L0s unlimited, L1 unlimited
LnkSta: Speed 5GT/s, Width x8, TrErr- Train- SlotClk- DLActive- BWMgmt- ABWMgmt-
Notice the two Width x8 lines above.
LnkSta (Link Status) is less than
LnkCap (Link Capability), it will display
(downgraded) next to the Width. This means that the PCI card is capable of more than what the PCI slot can provide.
Next, you can view display the physical and electrical PCI port information. Physical is the actual slot size on the motherboard. Electrical is how the slot is wired to the chipset. Some motherboards will have a physical x16 slot, but only use x8 lanes.
dmidecode --type 9 | egrep "Usage|Type|Designation"
Designation: PCH SLOT1 PCI-E 3.0 X4(IN X8)
Type: x4 PCI Express 3 x8
Current Usage: Available
Designation is how the motherboard manufacturer reports the SLOT.
Type is electrical and physical characteristics. (ex. electrical x4 lanes, physical slot is x8).