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. > > 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. Other than that, looks good to me.
