diff mbox series

[ndctl,4/6] cxl/list: Filter decoders by region

Message ID 165973189465.1528532.9072953032089147905.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
With a region name in hand, it is useful to be able to filter all the
decoders in the topology that are mapping that region.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 cxl/filter.c |   23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
diff mbox series

Patch

diff --git a/cxl/filter.c b/cxl/filter.c
index 38ece5528794..9a3de8c75387 100644
--- a/cxl/filter.c
+++ b/cxl/filter.c
@@ -652,6 +652,26 @@  struct cxl_region *util_cxl_region_filter(struct cxl_region *region,
 
 }
 
+static struct cxl_decoder *
+util_cxl_decoder_filter_by_region(struct cxl_decoder *decoder,
+				  const char *__ident)
+{
+	struct cxl_region *region;
+
+	if (!__ident)
+		return decoder;
+
+	region = cxl_decoder_get_region(decoder);
+	if (!region)
+		return NULL;
+
+	region = util_cxl_region_filter(region, __ident);
+	if (!region)
+		return NULL;
+
+	return decoder;
+}
+
 static unsigned long params_to_flags(struct cxl_filter_params *param)
 {
 	unsigned long flags = 0;
@@ -790,6 +810,9 @@  static void walk_decoders(struct cxl_port *port, struct cxl_filter_params *p,
 		if (!util_cxl_decoder_filter_by_memdev(
 			    decoder, p->memdev_filter, p->serial_filter))
 			goto walk_children;
+		if (!util_cxl_decoder_filter_by_region(decoder,
+						       p->region_filter))
+			goto walk_children;
 		if (!p->idle && cxl_decoder_get_size(decoder) == 0)
 			continue;
 		jdecoder = util_cxl_decoder_to_json(decoder, flags);