@@ -423,6 +423,78 @@ int ocp_set_latency_monitor_feature(int argc, char **argv, struct command *cmd,
423423 return err ;
424424}
425425
426+ static int ocp_get_latency_monitor_feature (int argc , char * * argv , struct command * cmd ,
427+ struct plugin * plugin )
428+ {
429+ const char * desc = "Define Issue Get Feature command (FID: 0xC5) Latency Monitor" ;
430+ const char * sel = "[0-3]: current/default/saved/supported/" ;
431+ const char * nsid = "Byte[04-07]: Namespace Identifier Valid/Invalid/Inactive" ;
432+ struct nvme_dev * dev ;
433+ __u32 result ;
434+ int err ;
435+ bool uuid ;
436+ __u8 uuid_index = 0 ;
437+
438+ struct config {
439+ __u8 sel ;
440+ __u32 nsid ;
441+ };
442+
443+ struct config cfg = {
444+ .sel = 0 ,
445+ .nsid = 0 ,
446+ };
447+
448+ OPT_ARGS (opts ) = {
449+ OPT_BYTE ("sel" , 's' , & cfg .sel , sel ),
450+ OPT_BYTE ("namespace-id" , 'n' , & cfg .nsid , nsid ),
451+ OPT_FLAG ("no-uuid" , 'u' , NULL , no_uuid ),
452+ OPT_END ()
453+ };
454+
455+ err = parse_and_open (& dev , argc , argv , desc , opts );
456+ if (err )
457+ return err ;
458+
459+ uuid = !argconfig_parse_seen (opts , "no-uuid" );
460+
461+ if (uuid ) {
462+ /* OCP 2.0 requires UUID index support */
463+ err = ocp_get_uuid_index (dev , & uuid_index );
464+ if (err || !uuid_index ) {
465+ nvme_show_error ("ERROR: No OCP UUID index found" );
466+ return err ;
467+ }
468+ }
469+
470+ struct nvme_get_features_args args = {
471+ .args_size = sizeof (args ),
472+ .fd = dev_fd (dev ),
473+ .fid = OCP_FID_LM ,
474+ .nsid = cfg .nsid ,
475+ .sel = cfg .sel ,
476+ .cdw11 = 0 ,
477+ .uuidx = uuid_index ,
478+ .data_len = 0 ,
479+ .data = NULL ,
480+ .timeout = NVME_DEFAULT_IOCTL_TIMEOUT ,
481+ .result = & result ,
482+ };
483+
484+ err = nvme_get_features (& args );
485+ if (!err ) {
486+ printf ("get-feature:0xC5 %s value: %#08x\n" ,
487+ nvme_select_to_string (cfg .sel ), result );
488+
489+ if (cfg .sel == NVME_GET_FEATURES_SEL_SUPPORTED )
490+ nvme_show_select_result (OCP_FID_LM , result );
491+ } else {
492+ nvme_show_error ("Could not get feature: 0xC5" );
493+ }
494+
495+ return err ;
496+ }
497+
426498///////////////////////////////////////////////////////////////////////////////
427499///////////////////////////////////////////////////////////////////////////////
428500///////////////////////////////////////////////////////////////////////////////
0 commit comments