blob: 0e882ad89be3e4ad135e2e2a795074daa9205e2f [file] [log] [blame]
Damjan Marionf0ccbb02016-10-06 16:53:32 +02001#!/bin/bash
2
Damjan Marionf9e3cd42021-11-10 00:44:17 +01003declare -A IDS
4IDS["8086:10fb"]="82599ES PF"
5IDS["8086:1583"]="XL710 PF"
6IDS["8086:158b"]="XXV710 PF"
7IDS["8086:154c"]="XXV710 VF"
8IDS["8086:37d1"]="X722 PF"
9IDS["8086:37cd"]="X722 VF"
10IDS["8086:1889"]="AVF"
11IDS["8086:1593"]="E810 PF"
12IDS["15b3:1015"]="CX-4 Lx PF"
13IDS["15b3:1017"]="CX-5 PF"
14IDS["15b3:1019"]="CX-5 Ex PF"
Damjan Marionf0ccbb02016-10-06 16:53:32 +020015
Damjan Marionf9e3cd42021-11-10 00:44:17 +010016echo "PCI Address N PCI-ID Driver MAC address Device Name State Speed Port Type"
17echo "============ = =========== ========== ================= ============== ===== ========== ===================="
18
19for d in /sys/bus/pci/devices/*; do
20 class=$(cat $d/class)
21 [ "${class}" == "0x020000" ] || continue
22 pci_addr=$(basename $d)
23 numa=$(cat $d/numa_node)
24 vid=$(cat $d/vendor | sed -e s/0x//g)
25 did=$(cat $d/device| sed -e s/0x//g)
26 pci_id=${IDS[$vid:$did]}
27
28 [ "$pci_id" == "" ] && pci_id="$vid:$did"
29
30 if [ -e $d/driver ] ; then
31 driver=$(basename $(readlink $d/driver))
32 else
33 driver=" "
34 fi
35 if [ -e $d/net ] ; then
36 dev=$(basename $(ls $d/net | head -1))
37 n=/sys/class/net/$dev
38 mac=$(cat $n/address)
39 oper=$(cat $n/operstate)
40# speed=$(sudo ethtool $dev | grep Speed | cut -d" " -f2)
41##port=$(ethtool $dev 2> /dev/null | sed -ne 's/.*Port: \(.*\)/\1/p')
42 else
43 dev=" "
44 mac=" "
45 oper=" "
46 speed=" "
47 port=" "
48 fi
49 printf "%-12s %s %-11s %-10s %-17s %-14s %-5s %-10s %s\n" \
50 $pci_addr $numa "$pci_id" $driver $mac $dev $oper $speed "$port"
Damjan Marionf0ccbb02016-10-06 16:53:32 +020051done