On Thu, Nov 11, 2021 at 12:45 PM Vishal Verma <[email protected]> wrote: > > 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. > > Cc: Ben Widawsky <[email protected]> > Cc: Dan Williams <[email protected]> > Reviewed-by: Dan Williams <[email protected]> > Signed-off-by: Vishal Verma <[email protected]> [..] > +int cmd_list(int argc, const char **argv, struct cxl_ctx *ctx) > +{ > + const struct option options[] = { > + OPT_STRING('d', "memdev", ¶m.memdev, "memory device name", > + "filter by CXL memory device name"), > + OPT_BOOLEAN('D', "memdevs", &list.memdevs, > + "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 "), > + OPT_END(), > + }; > + const char * const u[] = { > + "cxl list [<options>]", > + NULL > + }; > + struct json_object *jdevs = NULL; > + unsigned long list_flags; > + struct cxl_memdev *memdev; > + int i; > + > + argc = parse_options(argc, argv, options, u, 0); > + for (i = 0; i < argc; i++) > + error("unknown parameter \"%s\"\n", argv[i]); > + > + if (argc) > + usage_with_options(u, options); > + > + if (num_list_flags() == 0) > + list.memdevs = true;
It strikes me that we may regret this default. In the interest of giving us flexibility to pick a new default later (i.e. to not grow any maintenance dependencies on this default), let's fail for now if no list options are specified. I expect "cxl list" to enumerate the active and most relevant end user devices by default. For ndctl its namespaces, but for cxl-cli I expect it should be regions by default to show all the CXL address ranges. Likely it should be "--regions --namespaces" by default since regions are the primary user relevant devices for volatile memory and namespaces are the end user relevant devices for persistent memory, but the "--regions" vs "--regions --namespaces" decision can be made later.
