deleted file mode 100755
@@ -1,45 +0,0 @@
-#!/bin/bash -x
-# SPDX-License-Identifier: GPL-2.0
-# Copyright (C) 2015-2020 Intel Corporation. All rights reserved.
-
-set -e
-
-SECTOR_SIZE="4096"
-rc=77
-
-. $(dirname $0)/common
-
-check_min_kver "4.5" || do_skip "may lack namespace mode attribute"
-
-trap 'err $LINENO' ERR
-
-# setup (reset nfit_test dimms)
-modprobe nfit_test
-reset
-
-rc=1
-
-# create pmem
-dev="x"
-json=$($NDCTL create-namespace -b $NFIT_TEST_BUS0 -t pmem -m raw)
-eval $(echo $json | json2var )
-[ $dev = "x" ] && echo "fail: $LINENO" && exit 1
-[ $mode != "raw" ] && echo "fail: $LINENO" && exit 1
-
-# convert pmem to fsdax mode
-json=$($NDCTL create-namespace -m fsdax -f -e $dev)
-eval $(echo $json | json2var)
-[ $mode != "fsdax" ] && echo "fail: $LINENO" && exit 1
-
-# convert pmem to sector mode
-json=$($NDCTL create-namespace -m sector -l $SECTOR_SIZE -f -e $dev)
-eval $(echo $json | json2var)
-[ $sector_size != $SECTOR_SIZE ] && echo "fail: $LINENO" && exit 1
-[ $mode != "sector" ] && echo "fail: $LINENO" && exit 1
-
-# free capacity for blk creation
-$NDCTL destroy-namespace -f $dev
-
-_cleanup
-
-exit 0
new file mode 100644
@@ -0,0 +1,25 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2024 Intel Corporation. All rights reserved.
+
+cxl_create_region()
+{
+ decoder=$($CXL list -b cxl_test -D -d root | jq -r ".[] |
+ select(.pmem_capable == true) |
+ select(.nr_targets == 1) |
+ .decoder")
+
+ port_dev0=$($CXL list -T -d "$decoder" | jq -r ".[] |
+ .targets | .[] | select(.position == 0) | .target")
+ mem0=$($CXL list -M -p "$port_dev0" | jq -r ".[0].memdev")
+
+ region=$($CXL create-region -d "$decoder" -m "$mem0" |
+ jq -r ".region")
+ if [[ ! $region ]]; then
+ err "$LINENO"
+ fi
+}
+
+modprobe -r cxl_test
+modprobe cxl_test
+rc=1
+cxl_create_region
new file mode 100644
@@ -0,0 +1,5 @@
+#!/bin/bash -Ex
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2024 Intel Corporation. All rights reserved.
+
+. $(dirname $0)/namespace.sh cxl
@@ -132,7 +132,7 @@ revoke_devmem = executable('revoke_devmem', testcore + [
mmap = executable('mmap', 'mmap.c',)
-create = find_program('create.sh')
+nfit_namespace = find_program('nfit-namespace.sh')
clear = find_program('clear.sh')
pmem_errors = find_program('pmem-errors.sh')
daxdev_errors_sh = find_program('daxdev-errors.sh')
@@ -160,11 +160,12 @@ cxl_events = find_program('cxl-events.sh')
cxl_sanitize = find_program('cxl-sanitize.sh')
cxl_destroy_region = find_program('cxl-destroy-region.sh')
cxl_qos_class = find_program('cxl-qos-class.sh')
+cxl_namespace = find_program('cxl-namespace.sh')
tests = [
[ 'libndctl', libndctl, 'ndctl' ],
[ 'dsm-fail', dsm_fail, 'ndctl' ],
- [ 'create.sh', create, 'ndctl' ],
+ [ 'nfit-namespace.sh', nfit_namespace, 'ndctl' ],
[ 'clear.sh', clear, 'ndctl' ],
[ 'pmem-errors.sh', pmem_errors, 'ndctl' ],
[ 'daxdev-errors.sh', daxdev_errors_sh, 'dax' ],
@@ -192,6 +193,7 @@ tests = [
[ 'cxl-sanitize.sh', cxl_sanitize, 'cxl' ],
[ 'cxl-destroy-region.sh', cxl_destroy_region, 'cxl' ],
[ 'cxl-qos-class.sh', cxl_qos_class, 'cxl' ],
+ [ 'cxl-namespace.sh', cxl_namespace, 'cxl' ],
]
if get_option('destructive').enabled()
new file mode 100644
@@ -0,0 +1,95 @@
+#!/bin/bash -Ex
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2024 Intel Corporation. All rights reserved.
+
+. "$(dirname "$0")/common"
+
+rc=77
+trap 'err $LINENO' ERR
+check_prereq "jq"
+
+
+do_set_up()
+{
+ # Set up based on calling environment
+ if [[ "$1" == "nfit" ]]; then
+ . "$(dirname "$0")/nfit-namespace"
+ target=(-b "$NFIT_TEST_BUS0")
+ elif [[ "$1" == "cxl" ]]; then
+ . "$(dirname "$0")/cxl-namespace"
+ target=(--region="$region")
+ else
+ do_skip "Missing nfit or cxl input parameter"
+ fi
+
+ rc=1
+}
+
+test_namespace_create()
+{
+ local mode_list=("raw" "fsdax" "devdax" "sector")
+
+ for ns_mode in "${mode_list[@]}"; do
+ local params json
+ local dev="x"
+
+ if [[ "$ns_mode" == "devdax" || "$ns_mode" == "fsdax" ]]; then
+ params=("${target[@]}" -m "$ns_mode" --map=mem)
+ else
+ params=("${target[@]}" -m "$ns_mode")
+ fi
+
+ json=$($NDCTL create-namespace "${params[@]}")
+ eval "$(echo "$json" | json2var)"
+
+ if [[ "$dev" == "x" || "$mode" != "$ns_mode" ]]; then
+ err "$LINENO"
+ fi
+
+ $NDCTL destroy-namespace -f $dev || err "$LINENO"
+ done
+}
+
+test_namespace_reconfigure()
+{
+ # Create a raw pmem namespace then reconfigure it.
+ # Based on the original nfit create.sh plus devdax.
+
+ local json mode sector_size
+ local dev="x"
+
+ json=$($NDCTL create-namespace "${target[@]}" -t pmem -m raw)
+ eval "$(echo "$json" | json2var )"
+ [ "$dev" = "x" ] && err "$LINENO"
+ [ "$mode" != "raw" ] && err "$LINENO"
+
+ # convert pmem to fsdax mode
+ json=$($NDCTL create-namespace -m fsdax -f -e "$dev" --map=mem)
+ eval "$(echo "$json" | json2var )"
+ [ "$mode" != "fsdax" ] && err "$LINENO"
+
+ # convert pmem to sector mode
+ json=$($NDCTL create-namespace -m sector -l 4096 -f -e "$dev")
+ eval "$(echo "$json" | json2var )"
+ [ "$sector_size" != 4096 ] && err "$LINENO"
+ [ "$mode" != "sector" ] && err "$LINENO"
+
+ # convert pmem to devdax mode
+ json=$($NDCTL create-namespace -m devdax -f -e "$dev" --map=mem)
+ eval "$(echo "$json" | json2var )"
+ [ "$mode" != "devdax" ] && err "$LINENO"
+
+ $NDCTL destroy-namespace -f "$dev" || err "$LINENO"
+}
+
+do_set_up "$1"
+test_namespace_create
+test_namespace_reconfigure
+
+check_dmesg "$LINENO"
+
+if [ "$1" = "nfit" ]; then
+ _cleanup
+elif [ "$1" = "cxl" ]; then
+ _cxl_cleanup
+fi
new file mode 100644
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2024 Intel Corporation. All rights reserved.
+
+modprobe -r nfit_test
+modprobe nfit_test
+reset
new file mode 100644
@@ -0,0 +1,5 @@
+#!/bin/bash -Ex
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2024 Intel Corporation. All rights reserved.
+
+. $(dirname $0)/namespace.sh nfit