On Mon, 2021-07-12 at 22:12 -0700, Dan Williams wrote: > On Thu, Jul 1, 2021 at 1:10 PM Vishal Verma <[email protected]> wrote: > > > > Add 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 command submission. > > It strikes me after reading the above that it would be useful to have > a cxl list option that enumerates the command support on a given > memdev. Basically a "query-to-json" helper.
Hm, yes that makes sense.. There may not always be a 1:1 correlation between the commands returned by query and the actual cxl-cli command corresponding with that - and for some commands, there may not even be a cxl-cli equivalent. Do we want to create a json representation of the raw query data, or cxl-cli equivalents? > > > > Cc: Ben Widawsky <[email protected]> > > Cc: Dan Williams <[email protected]> > > Signed-off-by: Vishal Verma <[email protected]> > > --- > > cxl/lib/private.h | 33 ++++ > > cxl/lib/libcxl.c | 388 +++++++++++++++++++++++++++++++++++++++++++++ > > cxl/libcxl.h | 11 ++ > > cxl/lib/libcxl.sym | 13 ++ > > 4 files changed, 445 insertions(+) > > > [..] > > +static int cxl_cmd_alloc_query(struct cxl_cmd *cmd, int num_cmds) > > +{ > > + size_t size; > > + > > + if (!cmd) > > + return -EINVAL; > > + > > + if (cmd->query_cmd != NULL) > > + free(cmd->query_cmd); > > + > > + size = sizeof(struct cxl_mem_query_commands) + > > + (num_cmds * sizeof(struct cxl_command_info)); > > This is asking for the kernel's include/linux/overflow.h to be > imported into ndctl so that struct_size() could be used here. The file > is MIT licensed, just the small matter of factoring out only the MIT > licensed bits. Ah ok let me take a look. > Other than that, looks good to me.
