anitazha / rpms / ndctl

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