anitazha / rpms / ndctl

Forked from rpms/ndctl 2 years ago
Clone

Blame SOURCES/0206-cxl-test-Validate-switch-port-settings-in-cxl-region.patch

e0018b
From bcc9897b38be91df38f81fb3105d2351f7941377 Mon Sep 17 00:00:00 2001
e0018b
From: Dan Williams <dan.j.williams@intel.com>
e0018b
Date: Fri, 5 Aug 2022 13:38:26 -0700
e0018b
Subject: [PATCH 206/217] cxl/test: Validate switch port settings in
e0018b
 cxl-region-sysfs.sh
e0018b
e0018b
A recent kernel fix to add the missing update of endpoint decoder HPA range
e0018b
settings regressed switch decoder HPA range settings. Add validation for
e0018b
switch port settings to avoid regressions like that going forward.
e0018b
e0018b
Link: https://lore.kernel.org/r/165973190625.1528532.12244196912617964754.stgit@dwillia2-xfh.jf.intel.com
e0018b
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
e0018b
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
e0018b
---
e0018b
 test/cxl-region-sysfs.sh | 32 ++++++++++++++++++++++++++++++++
e0018b
 1 file changed, 32 insertions(+)
e0018b
e0018b
diff --git a/test/cxl-region-sysfs.sh b/test/cxl-region-sysfs.sh
e0018b
index 110e037..ae0f556 100644
e0018b
--- a/test/cxl-region-sysfs.sh
e0018b
+++ b/test/cxl-region-sysfs.sh
e0018b
@@ -112,6 +112,38 @@ do
e0018b
 	[ $res -ne $region_base ] && err "$LINENO: decoder: $i base: $res region_base: $region_base"
e0018b
 done
e0018b
 
e0018b
+# validate all switch decoders have the correct settings
e0018b
+nr_switches=$((nr_targets/2))
e0018b
+nr_host_bridges=$((nr_switches/2))
e0018b
+nr_switch_decoders=$((nr_switches + nr_host_bridges))
e0018b
+
e0018b
+json=$($CXL list -D -r $region -d switch)
e0018b
+readarray -t switch_decoders < <(echo $json | jq -r ".[].decoder")
e0018b
+
e0018b
+[ ${#switch_decoders[@]} -ne $nr_switch_decoders ] && err \
e0018b
+"$LINENO: expected $nr_switch_decoders got ${#switch_decoders[@]} switch decoders"
e0018b
+
e0018b
+for i in ${switch_decoders[@]}
e0018b
+do
e0018b
+	decoder=$(echo $json | jq -r ".[] | select(.decoder == \"$i\")")
e0018b
+	id=${i#decoder}
e0018b
+	port_id=${id%.*}
e0018b
+	depth=$($CXL list -p $port_id -S | jq -r ".[].depth")
e0018b
+	iw=$(echo $decoder | jq -r ".interleave_ways")
e0018b
+	ig=$(echo $decoder | jq -r ".interleave_granularity")
e0018b
+
e0018b
+	[ $iw -ne 2 ] && err "$LINENO: decoder: $i iw: $iw targets: 2"
e0018b
+	[ $ig -ne $((r_ig << depth)) ] && err \
e0018b
+	"$LINENO: decoder: $i ig: $ig switch_ig: $((r_ig << depth))"
e0018b
+
e0018b
+	res=$(echo $decoder | jq -r ".resource")
e0018b
+	sz=$(echo $decoder | jq -r ".size")
e0018b
+	[ $sz -ne $region_size ] && err \
e0018b
+	"$LINENO: decoder: $i sz: $sz region_size: $region_size"
e0018b
+	[ $res -ne $region_base ] && err \
e0018b
+	"$LINENO: decoder: $i base: $res region_base: $region_base"
e0018b
+done
e0018b
+
e0018b
 # walk up the topology and commit all decoders
e0018b
 echo 1 > /sys/bus/cxl/devices/$region/commit
e0018b
 
e0018b
-- 
e0018b
2.27.0
e0018b