numam-spdk/scripts/gen_nvme.sh
Michal Berger 35babaded1 scripts/common: Use separate function for nvme driver lookup
Check if given pci address is bound to nvme driver via a separate
function - this makes the task of getting list of the nvme devices
that can be used in tests a bit easier since we don't have to relay
on, e.g., gen_nvme.sh where the extra step to get said devices is
to parse the actual config.

Change-Id: I1f15f08a3678c0c41b051348af259e225356c340
Signed-off-by: Michal Berger <michalx.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3014
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2020-07-23 07:24:08 +00:00

44 lines
797 B
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=($(nvme_in_userspace))
if [ "$1" = "--json" ]; then
create_json_config
else
create_classic_config
fi