@@ -2237,6 +2237,106 @@ static int set_dssd_power_state_feature(int argc, char **argv, struct command *c
2237
2237
return err ;
2238
2238
}
2239
2239
2240
+ ///////////////////////////////////////////////////////////////////////////////
2241
+ ///////////////////////////////////////////////////////////////////////////////
2242
+ ///////////////////////////////////////////////////////////////////////////////
2243
+ ///////////////////////////////////////////////////////////////////////////////
2244
+ /// DSSD Power State (Feature Identifier C7h) Get Feature
2245
+
2246
+ static int get_dssd_power_state (struct nvme_dev * dev , const __u32 nsid ,
2247
+ const __u8 fid , __u8 sel , bool uuid )
2248
+ {
2249
+ __u32 result ;
2250
+ int err ;
2251
+ __u8 uuid_index = 0 ;
2252
+
2253
+ if (uuid ) {
2254
+ /* OCP 2.0 requires UUID index support */
2255
+ err = ocp_get_uuid_index (dev , & uuid_index );
2256
+ if (err || !uuid_index ) {
2257
+ nvme_show_error ("ERROR: No OCP UUID index found" );
2258
+ return err ;
2259
+ }
2260
+ }
2261
+
2262
+ struct nvme_get_features_args args = {
2263
+ .args_size = sizeof (args ),
2264
+ .fd = dev_fd (dev ),
2265
+ .fid = fid ,
2266
+ .nsid = nsid ,
2267
+ .sel = sel ,
2268
+ .cdw11 = 0 ,
2269
+ .uuidx = uuid_index ,
2270
+ .data_len = 0 ,
2271
+ .data = NULL ,
2272
+ .timeout = NVME_DEFAULT_IOCTL_TIMEOUT ,
2273
+ .result = & result ,
2274
+ };
2275
+
2276
+ err = nvme_get_features (& args );
2277
+ if (!err ) {
2278
+ printf ("get-feature:0xC7 %s value: %#08x\n" , nvme_select_to_string (sel ), result );
2279
+
2280
+ if (sel == NVME_GET_FEATURES_SEL_SUPPORTED )
2281
+ nvme_show_select_result (fid , result );
2282
+ } else {
2283
+ nvme_show_error ("Could not get feature: 0xC7 with sel: %d\n" , sel );
2284
+ }
2285
+
2286
+ return err ;
2287
+ }
2288
+
2289
+ static int get_dssd_power_state_feature (int argc , char * * argv , struct command * cmd ,
2290
+ struct plugin * plugin )
2291
+ {
2292
+ const char * desc = "Define DSSD Power State (Feature Identifier C7h) Get Feature." ;
2293
+ const char * all = "Print out all 3 values at once - Current, Default, and Saved" ;
2294
+ const char * sel = "[0-3]: current/default/saved/supported/" ;
2295
+ const __u32 nsid = 0 ;
2296
+ const __u8 fid = 0xC7 ;
2297
+ struct nvme_dev * dev ;
2298
+ int i , err ;
2299
+
2300
+ struct config {
2301
+ __u8 sel ;
2302
+ bool all ;
2303
+ };
2304
+
2305
+ struct config cfg = {
2306
+ .sel = 0 ,
2307
+ .all = false,
2308
+ };
2309
+
2310
+ OPT_ARGS (opts ) = {
2311
+ OPT_BYTE ("sel" , 'S' , & cfg .sel , sel ),
2312
+ OPT_FLAG ("all" , 'a' , NULL , all ),
2313
+ OPT_FLAG ("no-uuid" , 'n' , NULL ,
2314
+ "Skip UUID index search (UUID index not required for OCP 1.0)" ),
2315
+ OPT_END ()
2316
+ };
2317
+
2318
+ err = parse_and_open (& dev , argc , argv , desc , opts );
2319
+ if (err )
2320
+ return err ;
2321
+
2322
+ if (argconfig_parse_seen (opts , "all" )) {
2323
+ for (i = 0 ; i < 3 ; i ++ ) {
2324
+ err = get_dssd_power_state (dev , nsid , fid , i ,
2325
+ !argconfig_parse_seen (opts , "no-uuid" ));
2326
+ if (err )
2327
+ break ;
2328
+ }
2329
+ } else if (argconfig_parse_seen (opts , "sel" ))
2330
+ err = get_dssd_power_state (dev , nsid , fid , cfg .sel ,
2331
+ !argconfig_parse_seen (opts , "no-uuid" ));
2332
+ else
2333
+ nvme_show_error ("Required to have --sel as an argument, or pass the --all flag." );
2334
+
2335
+ dev_close (dev );
2336
+
2337
+ return err ;
2338
+ }
2339
+
2240
2340
///////////////////////////////////////////////////////////////////////////////
2241
2341
///////////////////////////////////////////////////////////////////////////////
2242
2342
///////////////////////////////////////////////////////////////////////////////
0 commit comments