On Tue, Jul 13, 2021 at 2:17 PM Verma, Vishal L
<[email protected]> wrote:
>
> 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?

I was thinking it would purely be a list and association of that to
whether there is a cxl-cli helper for it is left as an exercise for
the reader. Especially when there may be commands that are upgraded
versions of existing commands and cxl-cli handles that difference in
the background.

>
> > >
> > > 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.

I would certainly limit to just copying struct_size() for now and not
try to pull the whole header. If it turns into a larger ordeal and not
a quick copy feel free to table it for later.

Reply via email to