2019-06-18 13:19:06 +00:00
|
|
|
# Common utility functions to be sourced by the libftl test scripts
|
|
|
|
|
|
|
|
function get_chunk_size() {
|
2020-05-11 22:02:01 +00:00
|
|
|
$SPDK_EXAMPLE_DIR/identify -r "trtype:PCIe traddr:$1" \
|
2020-05-07 11:27:06 +00:00
|
|
|
| grep 'Logical blks per chunk' | sed 's/[^0-9]//g'
|
2019-06-18 13:19:06 +00:00
|
|
|
}
|
|
|
|
|
2019-09-10 13:01:27 +00:00
|
|
|
function get_num_group() {
|
2020-05-11 22:02:01 +00:00
|
|
|
$SPDK_EXAMPLE_DIR/identify -r "trtype:PCIe traddr:$1" \
|
2020-05-07 11:27:06 +00:00
|
|
|
| grep 'Groups' | sed 's/[^0-9]//g'
|
2019-09-10 13:01:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function get_num_pu() {
|
2020-05-11 22:02:01 +00:00
|
|
|
$SPDK_EXAMPLE_DIR/identify -r "trtype:PCIe traddr:$1" \
|
2020-05-07 11:27:06 +00:00
|
|
|
| grep 'PUs' | sed 's/[^0-9]//g'
|
2019-09-10 13:01:27 +00:00
|
|
|
}
|
|
|
|
|
2019-06-18 13:19:06 +00:00
|
|
|
function has_separate_md() {
|
2019-10-24 13:58:04 +00:00
|
|
|
local md_type
|
2020-05-11 22:02:01 +00:00
|
|
|
md_type=$($SPDK_EXAMPLE_DIR/identify -r "trtype:PCIe traddr:$1" \
|
2020-05-07 11:27:06 +00:00
|
|
|
| grep 'Metadata Transferred' | cut -d: -f2)
|
2019-06-18 13:19:06 +00:00
|
|
|
if [[ "$md_type" =~ Separate ]]; then
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function create_nv_cache_bdev() {
|
|
|
|
local name=$1
|
|
|
|
local ocssd_bdf=$2
|
|
|
|
local cache_bdf=$3
|
|
|
|
local num_punits=$4
|
|
|
|
|
2019-08-05 13:43:47 +00:00
|
|
|
local bytes_to_mb=$((1024 * 1024))
|
2019-10-24 13:58:04 +00:00
|
|
|
local chunk_size
|
|
|
|
chunk_size=$(get_chunk_size $ocssd_bdf)
|
2019-06-18 13:19:06 +00:00
|
|
|
|
|
|
|
# We need at least 2 bands worth of data + 1 block
|
2019-11-05 09:28:35 +00:00
|
|
|
local size=$((2 * 4096 * chunk_size * num_punits + 1))
|
2019-06-18 13:19:06 +00:00
|
|
|
# Round the size up to the nearest megabyte
|
2019-11-05 09:28:35 +00:00
|
|
|
local size=$(((size + bytes_to_mb) / bytes_to_mb))
|
2019-06-18 13:19:06 +00:00
|
|
|
|
|
|
|
# Create NVMe bdev on specified device and split it so that it has the desired size
|
2019-10-24 13:58:04 +00:00
|
|
|
local nvc_bdev
|
|
|
|
nvc_bdev=$($rootdir/scripts/rpc.py bdev_nvme_attach_controller -b $name -t PCIe -a $cache_bdf)
|
2019-09-11 11:10:43 +00:00
|
|
|
$rootdir/scripts/rpc.py bdev_split_create $nvc_bdev -s $size 1
|
2019-06-18 13:19:06 +00:00
|
|
|
}
|
2019-10-25 07:31:14 +00:00
|
|
|
|
|
|
|
function gen_ftl_nvme_conf() {
|
2020-05-07 11:27:06 +00:00
|
|
|
jq . <<- JSON
|
2020-03-18 10:23:51 +00:00
|
|
|
{
|
|
|
|
"subsystems": [
|
|
|
|
{
|
|
|
|
"subsystem": "bdev",
|
|
|
|
"config": [
|
|
|
|
{
|
|
|
|
"params": {
|
|
|
|
"nvme_adminq_poll_period_us": 100
|
|
|
|
},
|
|
|
|
"method": "bdev_nvme_set_options"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
JSON
|
2019-10-25 07:31:14 +00:00
|
|
|
}
|