summaryrefslogtreecommitdiffstats
path: root/src/spdk/scripts/gen_nvme.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/spdk/scripts/gen_nvme.sh
parentInitial commit. (diff)
downloadceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz
ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/spdk/scripts/gen_nvme.sh')
-rwxr-xr-xsrc/spdk/scripts/gen_nvme.sh46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/spdk/scripts/gen_nvme.sh b/src/spdk/scripts/gen_nvme.sh
new file mode 100755
index 00000000..fa8a9242
--- /dev/null
+++ b/src/spdk/scripts/gen_nvme.sh
@@ -0,0 +1,46 @@
+#!/usr/bin/env bash
+
+set -e
+
+rootdir=$(readlink -f $(dirname $0))/..
+source "$rootdir/scripts/common.sh"
+
+bdfs=($(iter_pci_class_code 01 08 02))
+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": "construct_nvme_bdev"'
+ if [ -z ${bdfs[i+1]} ]; then
+ echo '}'
+ else
+ echo '},'
+ fi
+ done
+ echo ']'
+ echo '}'
+}
+
+if [ "$1" = "--json" ]; then
+ create_json_config
+else
+ create_classic_config
+fi