From d51345c0b9af36e0a7d5784905c23f754019de7a Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Wed, 6 May 2020 23:28:52 +0200 Subject: [PATCH] setup.sh: Add basic function for handling status option on FreeBSD Change-Id: I64bcc9f06be7e5cca18195bab58f87a4ba74c903 Signed-off-by: Michal Berger Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2226 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Tomasz Zawadzki Reviewed-by: Jim Harris --- scripts/setup.sh | 61 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/scripts/setup.sh b/scripts/setup.sh index c9331ebf9..ef03a3a3c 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -703,6 +703,65 @@ function status_linux() { done } +function status_freebsd() { + local id pci + local ioat idxd vmd + + status_print() ( + local dev driver + + echo -e "BDF\t\tVendor\tDevice\tDriver" + + for id; do + for pci in ${pci_bus_cache["$id"]}; do + driver=$(pciconf -l "pci$pci") + driver=${driver%@*} + printf '%s\t%s\t%s\t%s\n' \ + "$pci" \ + "${pci_ids_vendor["$pci"]}" \ + "${pci_ids_device["$pci"]}" \ + "$driver" + done + done + ) + + devs=PCI_DEVICE_ID_INTEL_IOAT + devs+="|PCI_DEVICE_ID_INTEL_IDXD" + devs+="|PCI_DEVICE_ID_INTEL_VMD" + + local dev_type dev_id + while read -r _ dev_type dev_id; do + case "$dev_type" in + *IOAT*) ioat+=("0x8086:$dev_id") ;; + *IDXD*) idxd+=("0x8086:$dev_id") ;; + *VMD*) vmd+=("0x8086:$dev_id") ;; + esac + done < <(grep -E "$devs" "$rootdir/include/spdk/pci_ids.h") + + local contigmem=present + if ! kldstat -q -m contigmem; then + contigmem="not present" + fi + + cat <<- BSD_INFO + Contigmem ($contigmem) + Buffer Size: $(kenv hw.contigmem.buffer_size) + Num Buffers: $(kenv hw.contigmem.num_buffers) + + NVMe devices + $(status_print 0x010802) + + I/IOAT DMA + $(status_print "${ioat[@]}") + + IDXD DMA + $(status_print "${idxd[@]}") + + VMD + $(status_print "${vmd[@]}") + BSD_INFO +} + function configure_freebsd_pci() { local devs ids id local BDFS @@ -805,7 +864,7 @@ else elif [ "$mode" == "cleanup" ]; then echo "setup.sh cleanup function not yet supported on $os" elif [ "$mode" == "status" ]; then - echo "setup.sh status function not yet supported on $os" + status_freebsd elif [ "$mode" == "help" ]; then usage $0 else