Initial CXL support
Subsystems (3)
Vishal Verma
maintainercover Initial CXL support
This is an RFC patchset to add a new utility and library to support CXL devices. This comprehends the kernel's sysfs layout for CXL devices, and implements a command submission harness for CXL mailbox commands via ioctl()s definied by the cxl_mem driver.
These patches include:
- libcxl representation of cxl_mem devices
- A command submission harness through libcxl
- A 'cxl-list' command which displays information about a device
Things missing, or next steps are:
- A test/libcxl.c to exercise all library interfaces
- Testing 'vendor specific' commands exported by the QEMU implementation[1]
- API documentation
The latest kernel patches can be found at [2].
An ndctl branch with these patches is also available at [3]
[1]: https://lore.kernel.org/qemu-devel/[email protected]/
[2]: https://gitlab.com/bwidawsk/linux/-/commits/cxl-2.0v3
[3]: https://github.com/pmem/ndctl/tree/cxl-2.0v1
Vishal Verma (5):
cxl: add a cxl utility and libcxl library
cxl: add a local copy of the cxl_mem UAPI header
libcxl: add support for command query and submission
libcxl: add accessors for retrieving 'Identify' information cxl/list: augment cxl-list with more data from the identify command
Documentation/cxl/cxl-list.txt | 65 +++ Documentation/cxl/cxl.txt | 34 ++ Documentation/cxl/human-option.txt | 8 + Documentation/cxl/verbose-option.txt | 5 + configure.ac | 3 + Makefile.am | 4 +- Makefile.am.in | 5 + cxl/lib/private.h | 87 ++++ cxl/lib/libcxl.c | 714 +++++++++++++++++++++++++++ cxl/builtin.h | 8 + cxl/cxl_mem.h | 176 +++++++ cxl/libcxl.h | 66 +++ util/filter.h | 2 + util/json.h | 4 + util/main.h | 3 + cxl/cxl.c | 95 ++++ cxl/list.c | 138 ++++++ util/filter.c | 20 + util/json.c | 46 ++ Documentation/cxl/Makefile.am | 58 +++ cxl/Makefile.am | 21 + cxl/lib/Makefile.am | 32 ++ cxl/lib/libcxl.pc.in | 11 + cxl/lib/libcxl.sym | 41 ++ 24 files changed, 1644 insertions(+), 2 deletions(-) create mode 100644 Documentation/cxl/cxl-list.txt create mode 100644 Documentation/cxl/cxl.txt create mode 100644 Documentation/cxl/human-option.txt create mode 100644 Documentation/cxl/verbose-option.txt create mode 100644 cxl/lib/private.h create mode 100644 cxl/lib/libcxl.c create mode 100644 cxl/builtin.h create mode 100644 cxl/cxl_mem.h create mode 100644 cxl/libcxl.h create mode 100644 cxl/cxl.c create mode 100644 cxl/list.c create mode 100644 Documentation/cxl/Makefile.am create mode 100644 cxl/Makefile.am create mode 100644 cxl/lib/Makefile.am create mode 100644 cxl/lib/libcxl.pc.in create mode 100644 cxl/lib/libcxl.sym
Signature · 4 lines
2.29.2 _______________________________________________ Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]
Vishal Verma
maintainerRFC PATCH 1/5 cxl: add a cxl utility and libcxl library
CXL - or Compute eXpress Link - is a new interconnect that extends PCIe to support a wide range of devices, including cache coherent memory expanders. As such, these devices can be new sources of 'persistent memory', and the 'ndctl' umbrella of tools and libraries needs to be able to interact with them.
Add a new utility and library for managing these CXL memory devices. This is an initial bring-up for interacting with CXL devices, and only includes adding the utility and library infrastructure, parsing device information from sysfs for CXL devices, and providing a 'cxl-list' command to display this information in JSON formatted output.
--- Documentation/cxl/cxl-list.txt | 65 ++++++ Documentation/cxl/cxl.txt | 34 +++ Documentation/cxl/human-option.txt | 8 + Documentation/cxl/verbose-option.txt | 5 + configure.ac | 3 + Makefile.am | 4 +- Makefile.am.in | 4 + cxl/lib/private.h | 28 +++ cxl/lib/libcxl.c | 318 +++++++++++++++++++++++++++ cxl/builtin.h | 8 + cxl/libcxl.h | 52 +++++ util/filter.h | 2 + util/json.h | 3 + util/main.h | 3 + cxl/cxl.c | 95 ++++++++ cxl/list.c | 113 ++++++++++ util/filter.c | 20 ++ util/json.c | 26 +++ Documentation/cxl/Makefile.am | 58 +++++ cxl/Makefile.am | 21 ++ cxl/lib/Makefile.am | 32 +++ cxl/lib/libcxl.pc.in | 11 + cxl/lib/libcxl.sym | 26 +++ 23 files changed, 937 insertions(+), 2 deletions(-) create mode 100644 Documentation/cxl/cxl-list.txt create mode 100644 Documentation/cxl/cxl.txt create mode 100644 Documentation/cxl/human-option.txt create mode 100644 Documentation/cxl/verbose-option.txt create mode 100644 cxl/lib/private.h create mode 100644 cxl/lib/libcxl.c create mode 100644 cxl/builtin.h create mode 100644 cxl/libcxl.h create mode 100644 cxl/cxl.c create mode 100644 cxl/list.c create mode 100644 Documentation/cxl/Makefile.am create mode 100644 cxl/Makefile.am create mode 100644 cxl/lib/Makefile.am create mode 100644 cxl/lib/libcxl.pc.in create mode 100644 cxl/lib/libcxl.sym
Documentation/cxl/cxl-list.txt new file +65 -0
@@ -0,0 +1,65 @@ +// SPDX-License-Identifier: GPL-2.0 + +cxl-list(1) +=========== + +NAME +---- +cxl-list - CXL capable host bridges, switches, devices, and their attributes +in json. + +SYNOPSIS +-------- +[verse] +'cxl list' [<options>] + +Walk the CXL capable device hierarchy in the system and list all device +instances along with some of their major attributes. + +Options can be specified to limit the output to specific devices. +By default, 'cxl list' with no options is equivalent to: +[verse] +cxl list --devices + +EXAMPLE +------- +---- +# cxl list --devices +{ + "memdev":"mem0", + "pmem_size":268435456, + "ram_size":0, +} +---- + +OPTIONS +------- +-d:: +--dev=:: + Specify a cxl device name to filter the listing. For example: +---- +# cxl list --dev=mem0 +{ + "memdev":"mem0", + "pmem_size":268435456, + "ram_size":0, +} +---- + +-D:: +--devices:: + Include all CXL devices in the listing + +-i:: +--idle:: + Include idle (not enabled / zero-sized) devices in the listing + +include::human-option.txt[] + +include::verbose-option.txt[] + +include::../copyright.txt[] + +SEE ALSO +-------- +linkcxl:ndctl-list[1]
Documentation/cxl/cxl.txt new file +34 -0
@@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0 + +cxl(1) +====== + +NAME +---- +cxl - Provides enumeration and provisioning commands for CXL devices + +SYNOPSIS +-------- +[verse] +'cxl' [--version] [--help] COMMAND [ARGS] + +OPTIONS +------- +-v:: +--version:: + Display the version of the 'cxl' utility. + +-h:: +--help:: + Run the 'cxl help' command. + +DESCRIPTION +----------- +The cxl utility provides enumeration and provisioning commands for +the CXL devices managed by the Linux kernel. + +include::../copyright.txt[] + +SEE ALSO +-------- +linkcxl:ndctl[1]
Documentation/cxl/human-option.txt new file +8 -0
@@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 + +-u:: +--human:: + By default the command will output machine-friendly raw-integer + data. Instead, with this flag, numbers representing storage size + will be formatted as human readable strings with units, other + fields are converted to hexadecimal strings.
Documentation/cxl/verbose-option.txt new file +5 -0
@@ -0,0 +1,5 @@ +// SPDX-License-Identifier: GPL-2.0 + +-v:: +--verbose:: + Emit more debug messages
configure.ac +3 -0
@@ -222,12 +222,15 @@ AC_CONFIG_HEADERS(config.h) AC_CONFIG_FILES([ Makefile daxctl/lib/Makefile + cxl/lib/Makefile ndctl/lib/Makefile ndctl/Makefile daxctl/Makefile + cxl/Makefile test/Makefile Documentation/ndctl/Makefile Documentation/daxctl/Makefile + Documentation/cxl/Makefile ]) AC_OUTPUT
Makefile.am +2 -2
@@ -1,9 +1,9 @@ include Makefile.am.in ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} -SUBDIRS = . daxctl/lib ndctl/lib ndctl daxctl +SUBDIRS = . cxl/lib daxctl/lib ndctl/lib cxl ndctl daxctl if ENABLE_DOCS -SUBDIRS += Documentation/ndctl Documentation/daxctl +SUBDIRS += Documentation/ndctl Documentation/daxctl Documentation/cxl endif SUBDIRS += test
Makefile.am.in +4 -0
@@ -42,3 +42,7 @@ LIBNDCTL_AGE=19 LIBDAXCTL_CURRENT=6 LIBDAXCTL_REVISION=0 LIBDAXCTL_AGE=5 + +LIBCXL_CURRENT=0 +LIBCXL_REVISION=0 +LIBCXL_AGE=0
cxl/lib/private.h new file +28 -0
@@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: LGPL-2.1 */ +/* Copyright (C) 2020-2021, Intel Corporation. All rights reserved. */ +#ifndef _LIBCXL_PRIVATE_H_ +#define _LIBCXL_PRIVATE_H_ + +#include <libkmod.h> + +#define CXL_EXPORT __attribute__ ((visibility("default"))) + +struct cxl_memdev { +int id, major, minor; +void *dev_buf; +size_t buf_len; +char *dev_path; +struct cxl_ctx *ctx; +struct list_node list; +unsigned long long pmem_size; +unsigned long long ram_size; +int payload_max; +struct kmod_module *module; +}; + +static inline int check_kmod (struct kmod_ctx *kmod_ctx) +{ +return kmod_ctx ?0 : -ENXIO ; +} + +#endif /* _LIBCXL_PRIVATE_H_ */
cxl/lib/libcxl.c new file +318 -0
318 lines not on this page · raw message
cxl/builtin.h new file +8 -0
@@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) 2020-2021 Intel Corporation. All rights reserved. */ +#ifndef _CXL_BUILTIN_H_ +#define _CXL_BUILTIN_H_ + +struct cxl_ctx ; +int cmd_list (int argc,const char **argv,struct cxl_ctx *ctx); +#endif /* _CXL_BUILTIN_H_ */
cxl/libcxl.h new file +52 -0
52 lines not on this page · raw message
util/filter.h +2 -0
@@ -29,6 +29,8 @@ struct daxctl_dev *util_daxctl_dev_filter(struct daxctl_dev *dev, const char *ident);struct daxctl_region *util_daxctl_region_filter (struct daxctl_region *region,const char *ident); +struct cxl_memdev *util_cxl_memdev_filter (struct cxl_memdev *memdev, +const char *ident);enum ndctl_namespace_mode util_nsmode (const char *mode);const char *util_nsmode_name (enum ndctl_namespace_mode mode);
util/json.h +3 -0
@@ -55,4 +55,7 @@ struct json_object *util_dimm_health_to_json(struct ndctl_dimm *dimm);struct json_object *util_dimm_firmware_to_json (struct ndctl_dimm *dimm,unsigned long flags);struct json_object *util_region_capabilities_to_json (struct ndctl_region *region); +struct cxl_memdev ; +struct json_object *util_cxl_memdev_to_json (struct cxl_memdev *memdev, +unsigned long flags);#endif /* __NDCTL_JSON_H__ */
util/main.h +3 -0
@@ -10,16 +10,19 @@enum program {PROG_NDCTL ,PROG_DAXCTL , +PROG_CXL , };struct ndctl_ctx ;struct daxctl_ctx ; +struct cxl_ctx ;struct cmd_struct {const char *cmd;union {int (*n_fn)(int ,const char **,struct ndctl_ctx *ctx);int (*d_fn)(int ,const char **,struct daxctl_ctx *ctx); +int (*c_fn)(int ,const char **,struct cxl_ctx *ctx); }; };
cxl/cxl.c new file +95 -0
95 lines not on this page · raw message
cxl/list.c new file +113 -0
113 lines not on this page · raw message
util/filter.c +20 -0
@@ -12,6 +12,7 @@#include <util/filter.h> #include <ndctl/libndctl.h> #include <daxctl/libdaxctl.h> +#include <cxl/libcxl.h> struct ndctl_bus *util_bus_filter (struct ndctl_bus *bus,const char *__ident) {
@@ -339,6 +340,25 @@ struct daxctl_region *util_daxctl_region_filter(struct daxctl_region *region,return NULL ; } +struct cxl_memdev *util_cxl_memdev_filter (struct cxl_memdev *memdev, +const char *ident) +{ +int memdev_id; + +if (!ident ||strcmp (ident,"all" ) ==0 ) +return memdev; + +if (strcmp (ident,cxl_memdev_get_devname (memdev)) ==0 ) +return memdev; + +if ((sscanf (ident,"%d" , &memdev_id) ==1 + ||sscanf (ident,"mem%d" , &memdev_id) ==1 ) + &&cxl_memdev_get_id (memdev) == memdev_id) +return memdev; + +return NULL ; +} +enum ndctl_namespace_mode util_nsmode (const char *mode) {if (!mode)
util/json.c +26 -0
@@ -9,6 +9,7 @@#include <json-c/printbuf.h> #include <ndctl/libndctl.h> #include <daxctl/libdaxctl.h> +#include <cxl/libcxl.h> #include <ccan/array_size/array_size.h> #include <ccan/short_types/short_types.h> #include <ndctl.h>
@@ -1429,3 +1430,28 @@ struct json_object *util_badblock_rec_to_json(u64 block, u64 count,json_object_put (jerr);return NULL ; } + +struct json_object *util_cxl_memdev_to_json (struct cxl_memdev *memdev, +unsigned long flags) +{ +const char *devname =cxl_memdev_get_devname (memdev); +struct json_object *jdev, *jobj; + + jdev =json_object_new_object (); +if (!devname || !jdev) +return NULL ; + + jobj =json_object_new_string (devname); +if (jobj) +json_object_object_add (jdev,"memdev" , jobj); + + jobj =util_json_object_size (cxl_memdev_get_pmem_size (memdev), flags); +if (jobj) +json_object_object_add (jdev,"pmem_size" , jobj); + + jobj =util_json_object_size (cxl_memdev_get_ram_size (memdev), flags); +if (jobj) +json_object_object_add (jdev,"ram_size" , jobj); + +return jdev; +}
Documentation/cxl/Makefile.am new file +58 -0
58 lines not on this page · raw message
cxl/Makefile.am new file +21 -0
@@ -0,0 +1,21 @@ +include $(top_srcdir)/Makefile.am.in + +bin_PROGRAMS = cxl + +DISTCLEANFILES = config.h +BUILT_SOURCES = config.h +config.h: $(srcdir)/Makefile.am + $(AM_V_GEN) echo "/* Autogenerated by cxl/Makefile.am */" >$@ + +cxl_SOURCES =\ + cxl.c \ + list.c \ + ../util/json.c \ + builtin.h + +cxl_LDADD =\ + lib/libcxl.la \ + ../libutil.a \ + $(UUID_LIBS) \ + $(KMOD_LIBS) \ + $(JSON_LIBS)
cxl/lib/Makefile.am new file +32 -0
@@ -0,0 +1,32 @@ +include $(top_srcdir)/Makefile.am.in + +%.pc: %.pc.in Makefile + $(SED_PROCESS) + +pkginclude_HEADERS = ../libcxl.h +lib_LTLIBRARIES = libcxl.la + +libcxl_la_SOURCES =\ + ../libcxl.h \ + libcxl-private.h \ + ../../util/sysfs.c \ + ../../util/sysfs.h \ + ../../util/log.c \ + ../../util/log.h \ + libcxl.c + +libcxl_la_LIBADD =\ + $(UUID_LIBS) \ + $(KMOD_LIBS) + +EXTRA_DIST += libcxl.sym + +libcxl_la_LDFLAGS = $(AM_LDFLAGS) \ + -version-info $(LIBCXL_CURRENT):$(LIBCXL_REVISION):$(LIBCXL_AGE) \ + -Wl,--version-script=$(top_srcdir)/cxl/lib/libcxl.sym +libcxl_la_DEPENDENCIES = libcxl.sym + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = libcxl.pc +EXTRA_DIST += libcxl.pc.in +CLEANFILES += libcxl.pc
cxl/lib/libcxl.pc.in new file +11 -0
@@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libcxl +Description: Manage CXL devices +Version: @VERSION@ +Libs: -L${libdir} -lcxl +Libs.private: +Cflags: -I${includedir}
cxl/lib/libcxl.sym new file +26 -0
@@ -0,0 +1,26 @@ +LIBCXL_1 { +global: + cxl_get_userdata; + cxl_set_userdata; + cxl_ref; + cxl_get_log_priority; + cxl_set_log_fn; + cxl_unref; + cxl_set_log_priority; + cxl_new; +local: + *; +}; + +LIBCXL_2 { +global: + cxl_memdev_get_first; + cxl_memdev_get_next; + cxl_memdev_get_id; + cxl_memdev_get_devname; + cxl_memdev_get_major; + cxl_memdev_get_minor; + cxl_memdev_get_ctx; + cxl_memdev_get_pmem_size; + cxl_memdev_get_ram_size; +} LIBCXL_1;
Signature · 4 lines
2.29.2 _______________________________________________ Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]
Vishal Verma
maintainerRFC PATCH 2/5 cxl: add a local copy of the cxl_mem UAPI header
In reply to Vishal VermaWhile CXL functionality is under development, it is useful to have a local copy of the UAPI header for cxl_mem definitions. This allows building cxl and libcxl on systems where the appropriate kernel headers are not installed in the usual locations.
--- Makefile.am.in | 1 + cxl/cxl_mem.h | 176 ++++++++++++++++++++++++++++++++++++++++++++ cxl/lib/Makefile.am | 2 +- 3 files changed, 178 insertions(+), 1 deletion(-) create mode 100644 cxl/cxl_mem.h
Makefile.am.in +1 -0
@@ -11,6 +11,7 @@ AM_CPPFLAGS = \ -DNDCTL_MAN_PATH=\""$(mandir)"\" \ -I${top_srcdir}/ndctl/lib \ -I${top_srcdir}/ndctl \ + -I${top_srcdir}/cxl \ -I${top_srcdir}/ \ $(KMOD_CFLAGS) \ $(UDEV_CFLAGS) \
cxl/cxl_mem.h new file +176 -0
176 lines not on this page · raw message
cxl/lib/Makefile.am +1 -1
@@ -3,7 +3,7 @@ include $(top_srcdir)/Makefile.am.in %.pc: %.pc.in Makefile $(SED_PROCESS) -pkginclude_HEADERS = ../libcxl.h +pkginclude_HEADERS = ../libcxl.h ../cxl_mem.h lib_LTLIBRARIES = libcxl.la libcxl_la_SOURCES =\
Signature · 4 lines
2.29.2 _______________________________________________ Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]
Vishal Verma
maintainerRFC PATCH 3/5 libcxl: add support for command query and submission
In reply to Vishal VermaAdd a set of APIs around 'cxl_cmd' for querying the kernel for supported commands, allocating and validating command structures against the supported set, and submitting the commands.
'Query Commands' and 'Send Command' are implemented as IOCTLs in the kernel. 'Query Commands' returns information about each supported command, such as flags governing its use, or input and output payload sizes. This information is used to validate command support, as well as set up input and output buffers for the actual command submission.
--- cxl/lib/private.h | 40 ++++++ cxl/lib/libcxl.c | 352 +++++++++++++++++++++++++++++++++++++++++++++ cxl/libcxl.h | 11 ++ cxl/lib/libcxl.sym | 12 ++ 4 files changed, 415 insertions(+)
cxl/lib/private.h +40 -0
@@ -4,6 +4,9 @@#define _LIBCXL_PRIVATE_H_#include <libkmod.h> +#include <cxl_mem.h> +#include <ccan/endian/endian.h> +#include <ccan/short_types/short_types.h> #define CXL_EXPORT __attribute__ ((visibility("default")))
@@ -20,6 +23,43 @@ struct cxl_memdev {struct kmod_module *module; }; +#undef C +#define C (a, b) { b } +static struct { +const char *name; +} command_names[] = {CMDS }; +#undef C + +enum cxl_cmd_query_status { +CXL_CMD_QUERY_NOT_RUN =0 , +CXL_CMD_QUERY_OK , +CXL_CMD_QUERY_UNSUPPORTED , +}; + +/** +* struct cxl_cmd - CXL memdev command +* @memdev: the memory device to which the command is being sent +* @query_cmd: structure for the Linux 'Query commands' ioctl +* @send_cmd: structure for the Linux 'Send command' ioctl +* @input_payload: buffer for any input payload +* @output_payload: buffer for any output payload +* @refcount: reference for passing command buffer around +* @query_status: status from query_commands +* @query_status: status from query_commands +* @status: command return status from the device +*/ +struct cxl_cmd { +struct cxl_memdev *memdev; +struct cxl_mem_query_commands *query_cmd; +struct cxl_send_command *send_cmd; +void *input_payload; +void *output_payload; +int refcount; +int query_status; +int query_idx; +int status; +}; +static inline int check_kmod (struct kmod_ctx *kmod_ctx) {return kmod_ctx ?0 : -ENXIO ;
cxl/lib/libcxl.c +352 -0
368 lines not on this page · raw message
cxl/libcxl.h +11 -0
@@ -45,6 +45,17 @@ unsigned long long cxl_memdev_get_ram_size(struct cxl_memdev *memdev); memdev !=NULL ; \ memdev = cxl_memdev_get_next(memdev)) +struct cxl_cmd ; +struct cxl_cmd *cxl_cmd_new_identify (struct cxl_memdev *memdev); +struct cxl_cmd *cxl_cmd_new_raw (struct cxl_memdev *memdev); +struct cxl_cmd *cxl_cmd_new_get_supported_logs (struct cxl_memdev *memdev); +struct cxl_cmd *cxl_cmd_new_get_log (struct cxl_memdev *memdev); +int cxl_cmd_attach_payloads (struct cxl_cmd *cmd, +void *in,int size_in,void *out,int size_out); +void cxl_cmd_ref (struct cxl_cmd *cmd); +void cxl_cmd_unref (struct cxl_cmd *cmd); +int cxl_cmd_submit (struct cxl_cmd *cmd); + #ifdef __cplusplus }/* extern "C" */ #endif
cxl/lib/libcxl.sym +12 -0
@@ -24,3 +24,15 @@ global: cxl_memdev_get_pmem_size; cxl_memdev_get_ram_size; } LIBCXL_1; + +LIBCXL_3 { +global: + cxl_cmd_new_identify; + cxl_cmd_new_raw; + cxl_cmd_new_get_supported_logs; + cxl_cmd_new_get_log; + cxl_cmd_attach_payloads; + cxl_cmd_ref; + cxl_cmd_unref; + cxl_cmd_submit; +} LIBCXL_2;
Signature · 4 lines
2.29.2 _______________________________________________ Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]
Vishal Verma
maintainerRFC PATCH 4/5 libcxl: add accessors for retrieving 'Identify' information
In reply to Vishal VermaAdd APIs to access an incomplete list of fields from the 'Identify' mailbox command. The fields added are fw_revision, partition_align, and lsa_size.
--- cxl/lib/private.h | 19 +++++++++++++++++++ cxl/lib/libcxl.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ cxl/libcxl.h | 3 +++ cxl/lib/libcxl.sym | 3 +++ 4 files changed, 69 insertions(+)
cxl/lib/private.h +19 -0
@@ -60,6 +60,25 @@ struct cxl_cmd {int status; }; +#define CXL_CMD_IDENTIFY_FW_REV_LENGTH 0x10 + +struct cxl_cmd_identify { +char fw_revision[CXL_CMD_IDENTIFY_FW_REV_LENGTH ]; +le64 total_capacity; +le64 volatile_capacity; +le64 persistent_capacity; +le64 partition_align; +le16 info_event_log_size; +le16 warning_event_log_size; +le16 failure_event_log_size; +le16 fatal_event_log_size; +le32 lsa_size; +u8 poison_list_max_mer[3 ]; +le16 inject_poison_limit; +u8 poison_caps; +u8 qos_telemetry_caps; +} __packed; +static inline int check_kmod (struct kmod_ctx *kmod_ctx) {return kmod_ctx ?0 : -ENXIO ;
cxl/lib/libcxl.c +44 -0
57 lines not on this page · raw message
cxl/libcxl.h +3 -0
@@ -55,6 +55,9 @@ int cxl_cmd_attach_payloads(struct cxl_cmd *cmd,void cxl_cmd_ref (struct cxl_cmd *cmd);void cxl_cmd_unref (struct cxl_cmd *cmd);int cxl_cmd_submit (struct cxl_cmd *cmd); +int cxl_cmd_identify_get_fw_rev (struct cxl_cmd *cmd,char *fw_rev,int fw_len); +unsigned long long cxl_cmd_identify_get_partition_align (struct cxl_cmd *cmd); +unsigned int cxl_cmd_identify_get_lsa_size (struct cxl_cmd *cmd); #ifdef __cplusplus }/* extern "C" */
cxl/lib/libcxl.sym +3 -0
@@ -35,4 +35,7 @@ global: cxl_cmd_ref; cxl_cmd_unref; cxl_cmd_submit; + cxl_cmd_identify_get_fw_rev; + cxl_cmd_identify_get_partition_align; + cxl_cmd_identify_get_lsa_size; } LIBCXL_2;
Signature · 4 lines
2.29.2 _______________________________________________ Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]
Vishal Verma
maintainerRFC PATCH 5/5 cxl/list: augment cxl-list with more data from the identify command
In reply to Vishal VermaAugment cxl-list with some more fields obtained from sending an 'Identify' command to the device. If/when these fields are added to the sysfs representation of the memdev, the command submission detour can be removed and replaced with data from sysfs.
--- util/json.h | 3 ++- cxl/list.c | 29 +++++++++++++++++++++++++++-- util/json.c | 22 +++++++++++++++++++++- 3 files changed, 50 insertions(+), 4 deletions(-)
util/json.h +2 -1
@@ -6,6 +6,7 @@#include <stdbool.h> #include <ndctl/libndctl.h> #include <daxctl/libdaxctl.h> +#include <cxl/libcxl.h> #include <ccan/short_types/short_types.h> enum util_json_flags {
@@ -57,5 +58,5 @@ struct json_object *util_dimm_firmware_to_json(struct ndctl_dimm *dimm,struct json_object *util_region_capabilities_to_json (struct ndctl_region *region);struct cxl_memdev ;struct json_object *util_cxl_memdev_to_json (struct cxl_memdev *memdev, -unsigned long flags); +struct cxl_cmd *id,unsigned long flags);#endif /* __NDCTL_JSON_H__ */
cxl/list.c +27 -2
@@ -5,6 +5,7 @@#include <stdlib.h> #include <unistd.h> #include <limits.h> +#include <util/log.h> #include <util/json.h> #include <util/filter.h> #include <json-c/json.h>
@@ -16,6 +17,7 @@ static struct {bool memdevs;bool idle;bool human; +bool verbose; } list;static unsigned long listopts_to_flags (void )
@@ -47,6 +49,19 @@ static int num_list_flags(void)return list.memdevs; } +struct cxl_cmd *memdev_identify (struct cxl_memdev *memdev) +{ +struct cxl_cmd *id; + + id =cxl_cmd_new_identify (memdev); +if (!id) +return NULL ; + +if (cxl_cmd_submit (id) !=0 ) +return NULL ; +return id; +} +int cmd_list (int argc,const char **argv,struct cxl_ctx *ctx) {const struct option options[] = {
@@ -56,7 +71,9 @@ int cmd_list(int argc, const char **argv, struct cxl_ctx *ctx) "include CXL memory device info"),OPT_BOOLEAN ('i' ,"idle" , &list.idle,"include idle devices" ),OPT_BOOLEAN ('u' ,"human" , &list.human, -"use human friendly number formats " ), +"use human friendly number formats" ), +OPT_BOOLEAN ('v' ,"verbose" , &list.verbose, +"enable verbose output" ), OPT_END(), }; const char * const u[] = {
@@ -80,27 +97,35 @@ int cmd_list(int argc, const char **argv, struct cxl_ctx *ctx) list_flags =listopts_to_flags (); +if (list.verbose) +cxl_set_log_priority (ctx,LOG_DEBUG ); + cxl_memdev_foreach(ctx, memdev) {struct json_object *jdev =NULL ; +struct cxl_cmd *id;if (!util_cxl_memdev_filter (memdev, param.memdev))continue ;if (list.memdevs) { + id =memdev_identify (memdev);if (!jdevs) { jdevs =json_object_new_array ();if (!jdevs) {fail ("\n" ); +cxl_cmd_unref (id);continue ; } } - jdev =util_cxl_memdev_to_json (memdev, list_flags); + jdev =util_cxl_memdev_to_json (memdev, id, list_flags);if (!jdev) {fail ("\n" ); +cxl_cmd_unref (id);continue ; }json_object_array_add (jdevs, jdev); +cxl_cmd_unref (id); } }
util/json.c +21 -1
@@ -1432,10 +1432,11 @@ struct json_object *util_badblock_rec_to_json(u64 block, u64 count, }struct json_object *util_cxl_memdev_to_json (struct cxl_memdev *memdev, -unsigned long flags) +struct cxl_cmd *id,unsigned long flags) {const char *devname =cxl_memdev_get_devname (memdev);struct json_object *jdev, *jobj; +char fw_rev[0x10 ]; jdev =json_object_new_object ();if (!devname || !jdev)
@@ -1453,5 +1454,24 @@ struct json_object *util_cxl_memdev_to_json(struct cxl_memdev *memdev,if (jobj)json_object_object_add (jdev,"ram_size" , jobj); +if (!id) +return jdev; + +if (cxl_cmd_identify_get_fw_rev (id, fw_rev,0x10 ) ==0 ) { + jobj =json_object_new_string (fw_rev); +if (jobj) +json_object_object_add (jdev,"fw_revision" , jobj); + } + + jobj =util_json_object_size (cxl_cmd_identify_get_partition_align (id), + flags); +if (jobj) +json_object_object_add (jdev,"partition_align" , jobj); + + jobj =util_json_object_size (cxl_cmd_identify_get_lsa_size (id), + flags); +if (jobj) +json_object_object_add (jdev,"lsa_size" , jobj); +return jdev; }
Signature · 4 lines
2.29.2 _______________________________________________ Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]