Blame SOURCES/0205-cxl-list-Add-depth-to-port-listings.patch

26ccd9
From 2ceddb91d3a0d70a59242b3a9dab401be6e5c825 Mon Sep 17 00:00:00 2001
26ccd9
From: Dan Williams <dan.j.williams@intel.com>
26ccd9
Date: Fri, 5 Aug 2022 13:38:20 -0700
26ccd9
Subject: [PATCH 205/217] cxl/list: Add 'depth' to port listings
26ccd9
26ccd9
Simplify the task of determining how deep a port is in the hierarchy by
26ccd9
just emitting what libcxl already counted. This is useful for validating
26ccd9
interleave math.
26ccd9
26ccd9
Link: https://lore.kernel.org/r/165973190022.1528532.6351628365510289908.stgit@dwillia2-xfh.jf.intel.com
26ccd9
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
26ccd9
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
26ccd9
---
26ccd9
 Documentation/cxl/lib/libcxl.txt | 1 +
26ccd9
 cxl/json.c                       | 4 ++++
26ccd9
 cxl/lib/libcxl.c                 | 5 +++++
26ccd9
 cxl/lib/libcxl.sym               | 1 +
26ccd9
 cxl/libcxl.h                     | 1 +
26ccd9
 5 files changed, 12 insertions(+)
26ccd9
26ccd9
diff --git a/Documentation/cxl/lib/libcxl.txt b/Documentation/cxl/lib/libcxl.txt
26ccd9
index 6756d2f..fd2962a 100644
26ccd9
--- a/Documentation/cxl/lib/libcxl.txt
26ccd9
+++ b/Documentation/cxl/lib/libcxl.txt
26ccd9
@@ -290,6 +290,7 @@ int cxl_port_is_enabled(struct cxl_port *port);
26ccd9
 bool cxl_port_is_root(struct cxl_port *port);
26ccd9
 bool cxl_port_is_switch(struct cxl_port *port);
26ccd9
 bool cxl_port_is_endpoint(struct cxl_port *port);
26ccd9
+int cxl_port_get_depth(struct cxl_port *port);
26ccd9
 bool cxl_port_hosts_memdev(struct cxl_port *port, struct cxl_memdev *memdev);
26ccd9
 int cxl_port_get_nr_dports(struct cxl_port *port);
26ccd9
 ----
26ccd9
diff --git a/cxl/json.c b/cxl/json.c
26ccd9
index c3d9299..63c1751 100644
26ccd9
--- a/cxl/json.c
26ccd9
+++ b/cxl/json.c
26ccd9
@@ -769,6 +769,10 @@ static struct json_object *__util_cxl_port_to_json(struct cxl_port *port,
26ccd9
 	if (jobj)
26ccd9
 		json_object_object_add(jport, "host", jobj);
26ccd9
 
26ccd9
+	jobj = json_object_new_int(cxl_port_get_depth(port));
26ccd9
+	if (jobj)
26ccd9
+		json_object_object_add(jport, "depth", jobj);
26ccd9
+
26ccd9
 	if (!cxl_port_is_enabled(port)) {
26ccd9
 		jobj = json_object_new_string("disabled");
26ccd9
 		if (jobj)
26ccd9
diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c
26ccd9
index ff85b23..021d59f 100644
26ccd9
--- a/cxl/lib/libcxl.c
26ccd9
+++ b/cxl/lib/libcxl.c
26ccd9
@@ -2417,6 +2417,11 @@ CXL_EXPORT bool cxl_port_is_endpoint(struct cxl_port *port)
26ccd9
 	return port->type == CXL_PORT_ENDPOINT;
26ccd9
 }
26ccd9
 
26ccd9
+CXL_EXPORT int cxl_port_get_depth(struct cxl_port *port)
26ccd9
+{
26ccd9
+	return port->depth;
26ccd9
+}
26ccd9
+
26ccd9
 CXL_EXPORT struct cxl_bus *cxl_port_get_bus(struct cxl_port *port)
26ccd9
 {
26ccd9
 	struct cxl_bus *bus;
26ccd9
diff --git a/cxl/lib/libcxl.sym b/cxl/lib/libcxl.sym
26ccd9
index 385a8f0..8bb91e0 100644
26ccd9
--- a/cxl/lib/libcxl.sym
26ccd9
+++ b/cxl/lib/libcxl.sym
26ccd9
@@ -96,6 +96,7 @@ global:
26ccd9
 	cxl_port_get_parent;
26ccd9
 	cxl_port_is_root;
26ccd9
 	cxl_port_is_switch;
26ccd9
+	cxl_port_get_depth;
26ccd9
 	cxl_port_to_bus;
26ccd9
 	cxl_port_is_endpoint;
26ccd9
 	cxl_port_to_endpoint;
26ccd9
diff --git a/cxl/libcxl.h b/cxl/libcxl.h
26ccd9
index 2498fa1..9fe4e99 100644
26ccd9
--- a/cxl/libcxl.h
26ccd9
+++ b/cxl/libcxl.h
26ccd9
@@ -90,6 +90,7 @@ int cxl_port_is_enabled(struct cxl_port *port);
26ccd9
 struct cxl_port *cxl_port_get_parent(struct cxl_port *port);
26ccd9
 bool cxl_port_is_root(struct cxl_port *port);
26ccd9
 bool cxl_port_is_switch(struct cxl_port *port);
26ccd9
+int cxl_port_get_depth(struct cxl_port *port);
26ccd9
 struct cxl_bus *cxl_port_to_bus(struct cxl_port *port);
26ccd9
 bool cxl_port_is_endpoint(struct cxl_port *port);
26ccd9
 struct cxl_endpoint *cxl_port_to_endpoint(struct cxl_port *port);
26ccd9
-- 
26ccd9
2.27.0
26ccd9