Damjan Marion | f0ccbb0 | 2016-10-06 16:53:32 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Damjan Marion | f9e3cd4 | 2021-11-10 00:44:17 +0100 | [diff] [blame] | 3 | declare -A IDS |
| 4 | IDS["8086:10fb"]="82599ES PF" |
| 5 | IDS["8086:1583"]="XL710 PF" |
| 6 | IDS["8086:158b"]="XXV710 PF" |
| 7 | IDS["8086:154c"]="XXV710 VF" |
| 8 | IDS["8086:37d1"]="X722 PF" |
| 9 | IDS["8086:37cd"]="X722 VF" |
| 10 | IDS["8086:1889"]="AVF" |
| 11 | IDS["8086:1593"]="E810 PF" |
| 12 | IDS["15b3:1015"]="CX-4 Lx PF" |
| 13 | IDS["15b3:1017"]="CX-5 PF" |
| 14 | IDS["15b3:1019"]="CX-5 Ex PF" |
Damjan Marion | f0ccbb0 | 2016-10-06 16:53:32 +0200 | [diff] [blame] | 15 | |
Damjan Marion | f9e3cd4 | 2021-11-10 00:44:17 +0100 | [diff] [blame] | 16 | echo "PCI Address N PCI-ID Driver MAC address Device Name State Speed Port Type" |
| 17 | echo "============ = =========== ========== ================= ============== ===== ========== ====================" |
| 18 | |
| 19 | for 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 Marion | f0ccbb0 | 2016-10-06 16:53:32 +0200 | [diff] [blame] | 51 | done |