diff mbox series

[ndctl,6/6] cxl/test: Validate switch port settings in cxl-region-sysfs.sh

Message ID 165973190625.1528532.12244196912617964754.stgit@dwillia2-xfh.jf.intel.com
State New, archived
Headers show
Series cxl/test: Add more region ABI validation | expand

Commit Message

Dan Williams Aug. 5, 2022, 8:38 p.m. UTC
A recent kernel fix to add the missing update of endpoint decoder HPA range
settings regressed switch decoder HPA range settings. Add validation for
switch port settings to avoid regressions like that going forward.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 test/cxl-region-sysfs.sh |   32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
diff mbox series

Patch

diff --git a/test/cxl-region-sysfs.sh b/test/cxl-region-sysfs.sh
index 110e03709e39..ae0f55653814 100644
--- a/test/cxl-region-sysfs.sh
+++ b/test/cxl-region-sysfs.sh
@@ -112,6 +112,38 @@  do
 	[ $res -ne $region_base ] && err "$LINENO: decoder: $i base: $res region_base: $region_base"
 done
 
+# validate all switch decoders have the correct settings
+nr_switches=$((nr_targets/2))
+nr_host_bridges=$((nr_switches/2))
+nr_switch_decoders=$((nr_switches + nr_host_bridges))
+
+json=$($CXL list -D -r $region -d switch)
+readarray -t switch_decoders < <(echo $json | jq -r ".[].decoder")
+
+[ ${#switch_decoders[@]} -ne $nr_switch_decoders ] && err \
+"$LINENO: expected $nr_switch_decoders got ${#switch_decoders[@]} switch decoders"
+
+for i in ${switch_decoders[@]}
+do
+	decoder=$(echo $json | jq -r ".[] | select(.decoder == \"$i\")")
+	id=${i#decoder}
+	port_id=${id%.*}
+	depth=$($CXL list -p $port_id -S | jq -r ".[].depth")
+	iw=$(echo $decoder | jq -r ".interleave_ways")
+	ig=$(echo $decoder | jq -r ".interleave_granularity")
+
+	[ $iw -ne 2 ] && err "$LINENO: decoder: $i iw: $iw targets: 2"
+	[ $ig -ne $((r_ig << depth)) ] && err \
+	"$LINENO: decoder: $i ig: $ig switch_ig: $((r_ig << depth))"
+
+	res=$(echo $decoder | jq -r ".resource")
+	sz=$(echo $decoder | jq -r ".size")
+	[ $sz -ne $region_size ] && err \
+	"$LINENO: decoder: $i sz: $sz region_size: $region_size"
+	[ $res -ne $region_base ] && err \
+	"$LINENO: decoder: $i base: $res region_base: $region_base"
+done
+
 # walk up the topology and commit all decoders
 echo 1 > /sys/bus/cxl/devices/$region/commit