numam-spdk/scripts/gen_nvme.sh
Pawel Kaminski f54df84058 rpc: Rename construct_nvme_bdev to bdev_nvme_attach_controller
Change-Id: I1831eb39d3d357594968271b2ee69bb48502a59c
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/466138
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
2019-09-18 21:53:25 +00:00

57 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
rootdir=$(readlink -f $(dirname $0))/..
source "$rootdir/scripts/common.sh"
function create_classic_config()
{
echo "[Nvme]"
for (( i=0; i < ${#bdfs[@]}; i++))
do
echo " TransportID \"trtype:PCIe traddr:${bdfs[i]}\" Nvme$i"
done
}
function create_json_config()
{
echo "{"
echo '"subsystem": "bdev",'
echo '"config": ['
for (( i=0; i < ${#bdfs[@]}; i++))
do
echo '{'
echo '"params": {'
echo '"trtype": "PCIe",'
echo "\"name\": \"Nvme$i\","
echo "\"traddr\": \"${bdfs[i]}\""
echo '},'
echo '"method": "bdev_nvme_attach_controller"'
if [ -z ${bdfs[i+1]} ]; then
echo '}'
else
echo '},'
fi
done
echo ']'
echo '}'
}
bdfs=()
# Check used drivers. If it's not vfio-pci or uio-pci-generic
# then most likely PCI_WHITELIST option was used for setup.sh
# and we do not want to use that disk.
for bdf in $(iter_pci_class_code 01 08 02); do
driver=$(grep DRIVER /sys/bus/pci/devices/$bdf/uevent | awk -F"=" '{print $2}')
if [ "$driver" != "nvme" ]; then
bdfs+=("$bdf")
fi
done
if [ "$1" = "--json" ]; then
create_json_config
else
create_classic_config
fi