scripts: Add helper script for looking up PMR info under qemu
Added mainly to verify if the PMR setup on the VM is correct. Example of an output with PMR device size of 32M configured for two nvme devices, and one nvme device with 128M CMB. [root@fedora31-cloud-1614680581-9ba06c102 ~]# /tmp/get-pmr nvme0:0000:00:04.0:64-bit:prefetchable:0xf0000000:0xf7ffffff:0x08000000:cmb nvme1:0000:00:05.0:64-bit:prefetchable:0xf8000000:0xf9ffffff:0x02000000:pmr nvme2:0000:00:06.0:64-bit:prefetchable:0xfa000000:0xfbffffff:0x02000000:pmr Signed-off-by: Michal Berger <michalx.berger@intel.com> Change-Id: I522cebd8b5a16f8a37c6e0e01a0288fb310467fb Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7019 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
45fc211e5f
commit
0cb256c03d
50
scripts/get-pmr
Executable file
50
scripts/get-pmr
Executable file
@ -0,0 +1,50 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# We simply check if BAR2 is present as that's where PMR or CMB is
|
||||||
|
# meant to be located under qemu. If found, print some stats then exit.
|
||||||
|
|
||||||
|
[[ $(uname -s) == Linux ]] || exit 0
|
||||||
|
# Use MSR instead?
|
||||||
|
[[ $(< /sys/class/dmi/id/chassis_vendor) == QEMU ]] || exit 0
|
||||||
|
|
||||||
|
get_bar2() {
|
||||||
|
echo "0x$(setpci -s "$1" 0x18.L)"
|
||||||
|
}
|
||||||
|
|
||||||
|
get_size() {
|
||||||
|
local addr=$1
|
||||||
|
local start end type
|
||||||
|
|
||||||
|
while IFS="- " read -r start end type; do
|
||||||
|
start=0x$start end=0x$end
|
||||||
|
if ((start == addr)) && [[ $type == *"$pci"* ]]; then
|
||||||
|
printf '0x%08x:0x%08x:0x%08x\n' \
|
||||||
|
"$start" "$end" $((end - start + 1))
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done < /proc/iomem
|
||||||
|
echo "unknown"
|
||||||
|
}
|
||||||
|
|
||||||
|
info() {
|
||||||
|
local bar=$1
|
||||||
|
|
||||||
|
local pref loc
|
||||||
|
|
||||||
|
pref[0]=non-prefetchable
|
||||||
|
pref[1]=prefetchable
|
||||||
|
|
||||||
|
loc[0]=32-bit
|
||||||
|
loc[1]="<1MiB"
|
||||||
|
loc[2]=64-bit
|
||||||
|
|
||||||
|
echo "${loc[(bar >> 1) & 0x3]}:${pref[bar & 1 << 3 ? 1 : 0]}:$(get_size $((bar & ~0xf)))"
|
||||||
|
}
|
||||||
|
|
||||||
|
for nvme in /sys/class/nvme/nvme*; do
|
||||||
|
pci=$(readlink -f "$nvme/device") pci=${pci##*/}
|
||||||
|
bar2=$(get_bar2 "$pci") || continue
|
||||||
|
((bar2 != 0x0)) || continue
|
||||||
|
bar=pmr
|
||||||
|
[[ -e $nvme/cmb ]] && bar=cmb
|
||||||
|
echo "${nvme##*/}:$pci:$(info "$bar2"):$bar"
|
||||||
|
done
|
Loading…
Reference in New Issue
Block a user