|
Jeff Moyer |
2c91dc |
From f39735be3c1157fdfa7dd5c781048a411ebe4dc5 Mon Sep 17 00:00:00 2001
|
|
Jeff Moyer |
2c91dc |
From: Dan Williams <dan.j.williams@intel.com>
|
|
Jeff Moyer |
2c91dc |
Date: Sun, 23 Jan 2022 16:53:34 -0800
|
|
Jeff Moyer |
2c91dc |
Subject: [PATCH 106/217] cxl/list: Add 'host' entries for port-like objects
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
Add the device name of the "host" device for a given CXL port object. The
|
|
Jeff Moyer |
2c91dc |
kernel calls this the 'uport' attribute.
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
Link: https://lore.kernel.org/r/164298561473.3021641.16508989603599026269.stgit@dwillia2-desk3.amr.corp.intel.com
|
|
Jeff Moyer |
2c91dc |
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
|
|
Jeff Moyer |
2c91dc |
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
|
|
Jeff Moyer |
2c91dc |
---
|
|
Jeff Moyer |
2c91dc |
Documentation/cxl/cxl-list.txt | 9 +++++++++
|
|
Jeff Moyer |
2c91dc |
Documentation/cxl/lib/libcxl.txt | 5 +++++
|
|
Jeff Moyer |
2c91dc |
cxl/json.c | 4 ++++
|
|
Jeff Moyer |
2c91dc |
cxl/lib/libcxl.c | 10 ++++++++++
|
|
Jeff Moyer |
2c91dc |
cxl/lib/libcxl.sym | 2 ++
|
|
Jeff Moyer |
2c91dc |
cxl/libcxl.h | 2 ++
|
|
Jeff Moyer |
2c91dc |
6 files changed, 32 insertions(+)
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
diff --git a/Documentation/cxl/cxl-list.txt b/Documentation/cxl/cxl-list.txt
|
|
Jeff Moyer |
2c91dc |
index d342da2..30b6161 100644
|
|
Jeff Moyer |
2c91dc |
--- a/Documentation/cxl/cxl-list.txt
|
|
Jeff Moyer |
2c91dc |
+++ b/Documentation/cxl/cxl-list.txt
|
|
Jeff Moyer |
2c91dc |
@@ -210,6 +210,15 @@ OPTIONS
|
|
Jeff Moyer |
2c91dc |
--endpoints::
|
|
Jeff Moyer |
2c91dc |
Include endpoint objects (CXL Memory Device decoders) in the
|
|
Jeff Moyer |
2c91dc |
listing.
|
|
Jeff Moyer |
2c91dc |
+----
|
|
Jeff Moyer |
2c91dc |
+# cxl list -E
|
|
Jeff Moyer |
2c91dc |
+[
|
|
Jeff Moyer |
2c91dc |
+ {
|
|
Jeff Moyer |
2c91dc |
+ "endpoint":"endpoint2",
|
|
Jeff Moyer |
2c91dc |
+ "host":"mem0"
|
|
Jeff Moyer |
2c91dc |
+ }
|
|
Jeff Moyer |
2c91dc |
+]
|
|
Jeff Moyer |
2c91dc |
+----
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
-e::
|
|
Jeff Moyer |
2c91dc |
--endpoint::
|
|
Jeff Moyer |
2c91dc |
diff --git a/Documentation/cxl/lib/libcxl.txt b/Documentation/cxl/lib/libcxl.txt
|
|
Jeff Moyer |
2c91dc |
index eebab37..e4b372d 100644
|
|
Jeff Moyer |
2c91dc |
--- a/Documentation/cxl/lib/libcxl.txt
|
|
Jeff Moyer |
2c91dc |
+++ b/Documentation/cxl/lib/libcxl.txt
|
|
Jeff Moyer |
2c91dc |
@@ -178,6 +178,7 @@ struct cxl_port *cxl_port_get_next(struct cxl_port *port);
|
|
Jeff Moyer |
2c91dc |
struct cxl_port *cxl_port_get_parent(struct cxl_port *port);
|
|
Jeff Moyer |
2c91dc |
struct cxl_bus *cxl_port_get_bus(struct cxl_port *port);
|
|
Jeff Moyer |
2c91dc |
struct cxl_ctx *cxl_port_get_ctx(struct cxl_port *port);
|
|
Jeff Moyer |
2c91dc |
+const char *cxl_port_get_host(struct cxl_port *port);
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
#define cxl_port_foreach(parent, port) \
|
|
Jeff Moyer |
2c91dc |
for (port = cxl_port_get_first(parent); port != NULL; \
|
|
Jeff Moyer |
2c91dc |
@@ -192,6 +193,9 @@ as a parent object retrievable via cxl_port_get_parent().
|
|
Jeff Moyer |
2c91dc |
The root port of a hiearchy can be retrieved via any port instance in
|
|
Jeff Moyer |
2c91dc |
that hierarchy via cxl_port_get_bus().
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
+The host of a port is the corresponding device name of the PCIe Root
|
|
Jeff Moyer |
2c91dc |
+Port, or Switch Upstream Port with CXL capabilities.
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
=== PORT: Attributes
|
|
Jeff Moyer |
2c91dc |
----
|
|
Jeff Moyer |
2c91dc |
const char *cxl_port_get_devname(struct cxl_port *port);
|
|
Jeff Moyer |
2c91dc |
@@ -222,6 +226,7 @@ struct cxl_endpoint *cxl_endpoint_get_next(struct cxl_endpoint *endpoint);
|
|
Jeff Moyer |
2c91dc |
struct cxl_ctx *cxl_endpoint_get_ctx(struct cxl_endpoint *endpoint);
|
|
Jeff Moyer |
2c91dc |
struct cxl_port *cxl_endpoint_get_parent(struct cxl_endpoint *endpoint);
|
|
Jeff Moyer |
2c91dc |
struct cxl_port *cxl_endpoint_get_port(struct cxl_endpoint *endpoint);
|
|
Jeff Moyer |
2c91dc |
+const char *cxl_endpoint_get_host(struct cxl_endpoint *endpoint);
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
#define cxl_endpoint_foreach(port, endpoint) \
|
|
Jeff Moyer |
2c91dc |
for (endpoint = cxl_endpoint_get_first(port); endpoint != NULL; \
|
|
Jeff Moyer |
2c91dc |
diff --git a/cxl/json.c b/cxl/json.c
|
|
Jeff Moyer |
2c91dc |
index 08f6192..af3b4fe 100644
|
|
Jeff Moyer |
2c91dc |
--- a/cxl/json.c
|
|
Jeff Moyer |
2c91dc |
+++ b/cxl/json.c
|
|
Jeff Moyer |
2c91dc |
@@ -258,6 +258,10 @@ static struct json_object *__util_cxl_port_to_json(struct cxl_port *port,
|
|
Jeff Moyer |
2c91dc |
if (jobj)
|
|
Jeff Moyer |
2c91dc |
json_object_object_add(jport, name_key, jobj);
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
+ jobj = json_object_new_string(cxl_port_get_host(port));
|
|
Jeff Moyer |
2c91dc |
+ if (jobj)
|
|
Jeff Moyer |
2c91dc |
+ json_object_object_add(jport, "host", jobj);
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
if (!cxl_port_is_enabled(port)) {
|
|
Jeff Moyer |
2c91dc |
jobj = json_object_new_string("disabled");
|
|
Jeff Moyer |
2c91dc |
if (jobj)
|
|
Jeff Moyer |
2c91dc |
diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c
|
|
Jeff Moyer |
2c91dc |
index a25e715..5f48202 100644
|
|
Jeff Moyer |
2c91dc |
--- a/cxl/lib/libcxl.c
|
|
Jeff Moyer |
2c91dc |
+++ b/cxl/lib/libcxl.c
|
|
Jeff Moyer |
2c91dc |
@@ -626,6 +626,11 @@ CXL_EXPORT struct cxl_port *cxl_endpoint_get_port(struct cxl_endpoint *endpoint)
|
|
Jeff Moyer |
2c91dc |
return &endpoint->port;
|
|
Jeff Moyer |
2c91dc |
}
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
+CXL_EXPORT const char *cxl_endpoint_get_host(struct cxl_endpoint *endpoint)
|
|
Jeff Moyer |
2c91dc |
+{
|
|
Jeff Moyer |
2c91dc |
+ return cxl_port_get_host(&endpoint->port);
|
|
Jeff Moyer |
2c91dc |
+}
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
CXL_EXPORT int cxl_endpoint_is_enabled(struct cxl_endpoint *endpoint)
|
|
Jeff Moyer |
2c91dc |
{
|
|
Jeff Moyer |
2c91dc |
return cxl_port_is_enabled(&endpoint->port);
|
|
Jeff Moyer |
2c91dc |
@@ -744,6 +749,11 @@ CXL_EXPORT struct cxl_bus *cxl_port_get_bus(struct cxl_port *port)
|
|
Jeff Moyer |
2c91dc |
return bus;
|
|
Jeff Moyer |
2c91dc |
}
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
+CXL_EXPORT const char *cxl_port_get_host(struct cxl_port *port)
|
|
Jeff Moyer |
2c91dc |
+{
|
|
Jeff Moyer |
2c91dc |
+ return devpath_to_devname(port->uport);
|
|
Jeff Moyer |
2c91dc |
+}
|
|
Jeff Moyer |
2c91dc |
+
|
|
Jeff Moyer |
2c91dc |
CXL_EXPORT int cxl_port_is_enabled(struct cxl_port *port)
|
|
Jeff Moyer |
2c91dc |
{
|
|
Jeff Moyer |
2c91dc |
struct cxl_ctx *ctx = cxl_port_get_ctx(port);
|
|
Jeff Moyer |
2c91dc |
diff --git a/cxl/lib/libcxl.sym b/cxl/lib/libcxl.sym
|
|
Jeff Moyer |
2c91dc |
index 7a51a0c..dc2863e 100644
|
|
Jeff Moyer |
2c91dc |
--- a/cxl/lib/libcxl.sym
|
|
Jeff Moyer |
2c91dc |
+++ b/cxl/lib/libcxl.sym
|
|
Jeff Moyer |
2c91dc |
@@ -95,6 +95,7 @@ global:
|
|
Jeff Moyer |
2c91dc |
cxl_port_to_bus;
|
|
Jeff Moyer |
2c91dc |
cxl_port_is_endpoint;
|
|
Jeff Moyer |
2c91dc |
cxl_port_get_bus;
|
|
Jeff Moyer |
2c91dc |
+ cxl_port_get_host;
|
|
Jeff Moyer |
2c91dc |
cxl_endpoint_get_first;
|
|
Jeff Moyer |
2c91dc |
cxl_endpoint_get_next;
|
|
Jeff Moyer |
2c91dc |
cxl_endpoint_get_devname;
|
|
Jeff Moyer |
2c91dc |
@@ -103,4 +104,5 @@ global:
|
|
Jeff Moyer |
2c91dc |
cxl_endpoint_is_enabled;
|
|
Jeff Moyer |
2c91dc |
cxl_endpoint_get_parent;
|
|
Jeff Moyer |
2c91dc |
cxl_endpoint_get_port;
|
|
Jeff Moyer |
2c91dc |
+ cxl_endpoint_get_host;
|
|
Jeff Moyer |
2c91dc |
} LIBCXL_1;
|
|
Jeff Moyer |
2c91dc |
diff --git a/cxl/libcxl.h b/cxl/libcxl.h
|
|
Jeff Moyer |
2c91dc |
index f6ba9a1..a60777e 100644
|
|
Jeff Moyer |
2c91dc |
--- a/cxl/libcxl.h
|
|
Jeff Moyer |
2c91dc |
+++ b/cxl/libcxl.h
|
|
Jeff Moyer |
2c91dc |
@@ -83,6 +83,7 @@ bool cxl_port_is_switch(struct cxl_port *port);
|
|
Jeff Moyer |
2c91dc |
struct cxl_bus *cxl_port_to_bus(struct cxl_port *port);
|
|
Jeff Moyer |
2c91dc |
bool cxl_port_is_endpoint(struct cxl_port *port);
|
|
Jeff Moyer |
2c91dc |
struct cxl_bus *cxl_port_get_bus(struct cxl_port *port);
|
|
Jeff Moyer |
2c91dc |
+const char *cxl_port_get_host(struct cxl_port *port);
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
#define cxl_port_foreach(parent, port) \
|
|
Jeff Moyer |
2c91dc |
for (port = cxl_port_get_first(parent); port != NULL; \
|
|
Jeff Moyer |
2c91dc |
@@ -97,6 +98,7 @@ struct cxl_ctx *cxl_endpoint_get_ctx(struct cxl_endpoint *endpoint);
|
|
Jeff Moyer |
2c91dc |
int cxl_endpoint_is_enabled(struct cxl_endpoint *endpoint);
|
|
Jeff Moyer |
2c91dc |
struct cxl_port *cxl_endpoint_get_parent(struct cxl_endpoint *endpoint);
|
|
Jeff Moyer |
2c91dc |
struct cxl_port *cxl_endpoint_get_port(struct cxl_endpoint *endpoint);
|
|
Jeff Moyer |
2c91dc |
+const char *cxl_endpoint_get_host(struct cxl_endpoint *endpoint);
|
|
Jeff Moyer |
2c91dc |
|
|
Jeff Moyer |
2c91dc |
#define cxl_endpoint_foreach(port, endpoint) \
|
|
Jeff Moyer |
2c91dc |
for (endpoint = cxl_endpoint_get_first(port); endpoint != NULL; \
|
|
Jeff Moyer |
2c91dc |
--
|
|
Jeff Moyer |
2c91dc |
2.27.0
|
|
Jeff Moyer |
2c91dc |
|