@@ -876,6 +876,24 @@ static enum ndctl_fwa_method fwa_method_to_method(const char *fwa_method)
return NDCTL_FWA_METHOD_RESET;
}
+static int is_subsys_cxl(const char *subsys)
+{
+ char *path;
+ int rc;
+
+ path = realpath(subsys, NULL);
+ if (!path)
+ return -errno;
+
+ if (!strcmp(subsys, "/sys/bus/cxl"))
+ rc = 1;
+ else
+ rc = 0;
+
+ free(path);
+ return rc;
+}
+
static void *add_bus(void *parent, int id, const char *ctl_base)
{
char buf[SYSFS_ATTR_SIZE];
@@ -919,6 +937,12 @@ static void *add_bus(void *parent, int id, const char *ctl_base)
else
bus->has_of_node = 1;
+ sprintf(path, "%s/device/../subsys", ctl_base);
+ if (is_subsys_cxl(path))
+ bus->has_cxl = 1;
+ else
+ bus->has_cxl = 0;
+
sprintf(path, "%s/device/nfit/dsm_mask", ctl_base);
if (sysfs_read_attr(ctx, path, buf) < 0)
bus->nfit_dsm_mask = 0;
@@ -1050,6 +1074,11 @@ NDCTL_EXPORT int ndctl_bus_has_of_node(struct ndctl_bus *bus)
return bus->has_of_node;
}
+NDCTL_EXPORT int ndctl_bus_has_cxl(struct ndctl_bus *bus)
+{
+ return bus->has_cxl;
+}
+
NDCTL_EXPORT int ndctl_bus_is_papr_scm(struct ndctl_bus *bus)
{
char buf[SYSFS_ATTR_SIZE];
@@ -464,4 +464,5 @@ LIBNDCTL_27 {
} LIBNDCTL_26;
LIBNDCTL_28 {
ndctl_dimm_disable_master_passphrase;
+ ndctl_bus_has_cxl;
} LIBNDCTL_27;
@@ -163,6 +163,7 @@ struct ndctl_bus {
int regions_init;
int has_nfit;
int has_of_node;
+ int has_cxl;
char *bus_path;
char *bus_buf;
size_t buf_len;
@@ -133,6 +133,7 @@ struct ndctl_bus *ndctl_bus_get_next(struct ndctl_bus *bus);
struct ndctl_ctx *ndctl_bus_get_ctx(struct ndctl_bus *bus);
int ndctl_bus_has_nfit(struct ndctl_bus *bus);
int ndctl_bus_has_of_node(struct ndctl_bus *bus);
+int ndctl_bus_has_cxl(struct ndctl_bus *bus);
int ndctl_bus_is_papr_scm(struct ndctl_bus *bus);
unsigned int ndctl_bus_get_major(struct ndctl_bus *bus);
unsigned int ndctl_bus_get_minor(struct ndctl_bus *bus);