@@ -31,12 +31,22 @@ struct temp_thresh_config {
3131 __u8 sel ;
3232};
3333
34+ struct arbitration_config {
35+ __u8 ab ;
36+ __u8 lpw ;
37+ __u8 mpw ;
38+ __u8 hpw ;
39+ __u8 sel ;
40+ };
41+
3442static const char * power_mgmt_feat = "power management feature" ;
3543static const char * sel = "[0-3]: current/default/saved/supported" ;
3644static const char * save = "Specifies that the controller shall save the attribute" ;
3745static const char * perfc_feat = "performance characteristics feature" ;
3846static const char * hctm_feat = "host controlled thermal management feature" ;
3947static const char * timestamp_feat = "timestamp feature" ;
48+ static const char * temp_thresh_feat = "temperature threshold feature" ;
49+ static const char * arbitration_feat = "arbitration feature" ;
4050
4151static int feat_get (struct nvme_dev * dev , const __u8 fid , __u32 cdw11 , __u8 sel , const char * feat )
4252{
@@ -68,7 +78,11 @@ static int feat_get(struct nvme_dev *dev, const __u8 fid, __u32 cdw11, __u8 sel,
6878 };
6979
7080 err = nvme_get_features (& args );
81+
82+ nvme_show_init ();
83+
7184 if (!err ) {
85+ nvme_feature_show (fid , sel , result );
7286 if (NVME_CHECK (sel , GET_FEATURES_SEL , SUPPORTED ))
7387 nvme_show_select_result (fid , result );
7488 else
@@ -79,6 +93,8 @@ static int feat_get(struct nvme_dev *dev, const __u8 fid, __u32 cdw11, __u8 sel,
7993 nvme_show_error ("Get %s: %s" , feat , nvme_strerror (errno ));
8094 }
8195
96+ nvme_show_finish ();
97+
8298 return err ;
8399}
84100
@@ -423,9 +439,9 @@ static int temp_thresh_set(int fd, const __u8 fid, struct argconfig_commandline_
423439 if (err > 0 ) {
424440 nvme_show_status (err );
425441 } else if (err < 0 ) {
426- nvme_show_perror ("Set %s" , timestamp_feat );
442+ nvme_show_perror ("Set %s" , temp_thresh_feat );
427443 } else {
428- nvme_show_result ("Set %s: (%s)" , timestamp_feat , save ? "Save" : "Not save" );
444+ nvme_show_result ("Set %s: (%s)" , temp_thresh_feat , save ? "Save" : "Not save" );
429445 nvme_feature_show_fields (fid , NVME_SET (cfg -> tmpth , FEAT_TT_TMPTH ) |
430446 NVME_SET (cfg -> tmpsel , FEAT_TT_TMPSEL ) |
431447 NVME_SET (cfg -> thsel , FEAT_TT_THSEL ) |
@@ -464,7 +480,83 @@ static int feat_temp_thresh(int argc, char **argv, struct command *cmd, struct p
464480 err = temp_thresh_set (dev_fd (dev ), fid , opts , & cfg );
465481 else
466482 err = feat_get (dev , fid , NVME_SET (cfg .tmpsel , FEAT_TT_TMPSEL ) |
467- NVME_SET (cfg .thsel , FEAT_TT_THSEL ), cfg .sel , timestamp_feat );
483+ NVME_SET (cfg .thsel , FEAT_TT_THSEL ), cfg .sel , temp_thresh_feat );
484+
485+ return err ;
486+ }
487+
488+ static int arbitration_set (int fd , const __u8 fid , struct argconfig_commandline_options * opts ,
489+ struct arbitration_config * cfg )
490+ {
491+ enum nvme_get_features_sel sel = NVME_GET_FEATURES_SEL_CURRENT ;
492+ bool save = argconfig_parse_seen (opts , "save" );
493+ __u8 ab , lpw , mpw , hpw ;
494+ __u32 result ;
495+ int err ;
496+
497+ if (save )
498+ sel = NVME_GET_FEATURES_SEL_SAVED ;
499+
500+ err = nvme_get_features_arbitration (fd , sel , & result );
501+ if (!err ) {
502+ nvme_feature_decode_arbitration (result , & ab , & lpw , & mpw , & hpw );
503+ if (!argconfig_parse_seen (opts , "ab" ))
504+ cfg -> ab = ab ;
505+ if (!argconfig_parse_seen (opts , "lpw" ))
506+ cfg -> lpw = lpw ;
507+ if (!argconfig_parse_seen (opts , "mpw" ))
508+ cfg -> mpw = mpw ;
509+ if (!argconfig_parse_seen (opts , "hpw" ))
510+ cfg -> hpw = hpw ;
511+ }
512+
513+ err = nvme_set_features_arbitration (fd , cfg -> ab , cfg -> lpw , cfg -> mpw , cfg -> hpw ,
514+ save , & result );
515+
516+ nvme_show_init ();
517+
518+ if (err > 0 ) {
519+ nvme_show_status (err );
520+ } else if (err < 0 ) {
521+ nvme_show_perror ("Set %s" , temp_thresh_feat );
522+ } else {
523+ nvme_show_result ("Set %s: (%s)" , arbitration_feat , save ? "Save" : "Not save" );
524+ nvme_feature_show_fields (fid , NVME_SET (cfg -> ab , FEAT_ARBITRATION_BURST ) |
525+ NVME_SET (cfg -> lpw , FEAT_ARBITRATION_LPW ) |
526+ NVME_SET (cfg -> mpw , FEAT_ARBITRATION_MPW ) |
527+ NVME_SET (cfg -> hpw , FEAT_ARBITRATION_HPW ), NULL );
528+ }
529+
530+ nvme_show_finish ();
468531
469532 return err ;
470533}
534+
535+ static int feat_arbitration (int argc , char * * argv , struct command * cmd , struct plugin * plugin )
536+ {
537+ const __u8 fid = NVME_FEAT_FID_ARBITRATION ;
538+ const char * ab = "arbitration burst" ;
539+ const char * lpw = "low priority weight" ;
540+ const char * mpw = "medium priority weight" ;
541+ const char * hpw = "high priority weight" ;
542+ int err ;
543+
544+ _cleanup_nvme_dev_ struct nvme_dev * dev = NULL ;
545+
546+ struct arbitration_config cfg = { 0 };
547+
548+ FEAT_ARGS (opts ,
549+ OPT_BYTE ("ab" , 'a' , & cfg .ab , ab ),
550+ OPT_BYTE ("lpw" , 'l' , & cfg .lpw , lpw ),
551+ OPT_BYTE ("mpw" , 'm' , & cfg .mpw , mpw ),
552+ OPT_BYTE ("hpw" , 'H' , & cfg .hpw , hpw ));
553+
554+ err = parse_and_open (& dev , argc , argv , TEMP_THRESH_DESC , opts );
555+ if (err )
556+ return err ;
557+
558+ if (argc == 2 || argconfig_parse_seen (opts , "sel" ))
559+ return feat_get (dev , fid , 0 , cfg .sel , "arbitration feature" );
560+
561+ return arbitration_set (dev_fd (dev ), fid , opts , & cfg );
562+ }
0 commit comments