@@ -295,6 +295,7 @@ bool cxl_port_is_endpoint(struct cxl_port *port);
int cxl_port_get_depth(struct cxl_port *port);
bool cxl_port_hosts_memdev(struct cxl_port *port, struct cxl_memdev *memdev);
int cxl_port_get_nr_dports(struct cxl_port *port);
+struct cxl_port *cxl_port_decoders_committed(struct cxl_port *port);
----
The port type is communicated via cxl_port_is_<type>(). An 'enabled' port
is one that has succeeded in discovering the CXL component registers in
@@ -1331,6 +1331,10 @@ static struct json_object *__util_cxl_port_to_json(struct cxl_port *port,
json_object_object_add(jport, "state", jobj);
}
+ jobj = json_object_new_int(cxl_port_decoders_committed(port));
+ if (jobj)
+ json_object_object_add(jport, "decoders_committed", jobj);
+
json_object_set_userdata(jport, port, NULL);
return jport;
}
@@ -1880,6 +1880,10 @@ static int cxl_port_init(struct cxl_port *port, struct cxl_port *parent_port,
if (sysfs_read_attr(ctx, path, buf) == 0)
port->module = util_modalias_to_module(ctx, buf);
+ sprintf(path, "%s/decoders_committed", cxlport_base);
+ if (sysfs_read_attr(ctx, path, buf) == 0)
+ port->decoders_committed = strtoul(buf, NULL, 0);
+
free(path);
return 0;
err:
@@ -3121,6 +3125,11 @@ cxl_port_get_dport_by_memdev(struct cxl_port *port, struct cxl_memdev *memdev)
return NULL;
}
+CXL_EXPORT int cxl_port_decoders_committed(struct cxl_port *port)
+{
+ return port->decoders_committed;
+}
+
static void *add_cxl_bus(void *parent, int id, const char *cxlbus_base)
{
const char *devname = devpath_to_devname(cxlbus_base);
@@ -277,4 +277,5 @@ global:
cxl_cmd_new_set_alert_config;
cxl_memdev_trigger_poison_list;
cxl_region_trigger_poison_list;
+ cxl_port_decoders_committed;
} LIBCXL_6;
@@ -87,6 +87,7 @@ struct cxl_port {
int dports_init;
int nr_dports;
int depth;
+ int decoders_committed;
struct cxl_ctx *ctx;
struct cxl_bus *bus;
enum cxl_port_type type;
@@ -145,6 +145,7 @@ bool cxl_port_hosts_memdev(struct cxl_port *port, struct cxl_memdev *memdev);
int cxl_port_get_nr_dports(struct cxl_port *port);
int cxl_port_disable_invalidate(struct cxl_port *port);
int cxl_port_enable(struct cxl_port *port);
+int cxl_port_decoders_committed(struct cxl_port *port);
struct cxl_port *cxl_port_get_next_all(struct cxl_port *port,
const struct cxl_port *top);
Save the number of decoders committed to a port exposed by the kernel to the libcxl cxl_port context. The attribute is helpful for determing if a region is active. Add libcxl API to retrieve the number of decoders committed. Add the decoders_committed attribute to the port for cxl list command. Link: https://lore.kernel.org/linux-cxl/169645700414.623072.3893376765415910289.stgit@djiang5-mobl3/T/#t Signed-off-by: Dave Jiang <dave.jiang@intel.com> --- v2: - Rebase against latest pending branch --- Documentation/cxl/lib/libcxl.txt | 1 + cxl/json.c | 4 ++++ cxl/lib/libcxl.c | 9 +++++++++ cxl/lib/libcxl.sym | 1 + cxl/lib/private.h | 1 + cxl/libcxl.h | 1 + 6 files changed, 17 insertions(+)