File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -507,12 +507,32 @@ flags! {
507507 }
508508}
509509
510+ // MI v2.0, 5.6, Figure 108, SW
511+ flags ! {
512+ pub enum SmartWarningFlags : u8 {
513+ Ascbt ,
514+ Ttc ,
515+ Ndr ,
516+ Amro ,
517+ Vmbf ,
518+ Pmrro ,
519+ }
520+ }
521+
522+ impl From < FlagSet < super :: CriticalWarningFlags > > for WireFlagSet < SmartWarningFlags > {
523+ fn from ( value : FlagSet < super :: CriticalWarningFlags > ) -> Self {
524+ FlagSet :: < SmartWarningFlags > :: new ( ( !value. bits ( ) ) & 0x3f )
525+ . expect ( "Undefined bits set" )
526+ . into ( )
527+ }
528+ }
529+
510530// MI v2.0, 5.6, Figure 108
511531#[ derive( Debug , DekuRead , DekuWrite ) ]
512532#[ deku( endian = "little" ) ]
513533struct NvmSubsystemHealthDataStructureResponse {
514534 nss : WireFlagSet < NvmSubsystemStatusFlags > ,
515- sw : u8 ,
535+ sw : WireFlagSet < SmartWarningFlags > ,
516536 ctemp : u8 ,
517537 pldu : u8 ,
518538}
Original file line number Diff line number Diff line change @@ -234,13 +234,26 @@ impl RequestHandler for NvmeMiCommandRequestHeader {
234234 flags
235235 }
236236 . into ( ) ,
237- #[ allow( clippy:: nonminimal_bool) ]
238- sw : ( !false as u8 ) << 5 // PMRRO
239- | ( !false as u8 ) << 4 // VMBF
240- | ( !ctlr. ro as u8 ) << 3 // AMRO
241- | ( !ctlr. ro as u8 ) << 2 // NDR
242- | ( !( ctlr. temp_range . lower <= ctlr. temp && ctlr. temp <= ctlr. temp_range . upper ) as u8 ) << 1 // TTC
243- | ( !( ( 100 * ctlr. spare / ctlr. capacity ) < ctlr. spare_range . lower ) as u8 ) ,
237+ sw : {
238+ let mut flags = FlagSet :: full ( ) ;
239+
240+ if ctlr. ro {
241+ flags -= super :: SmartWarningFlags :: Amro ;
242+ flags -= super :: SmartWarningFlags :: Ndr ;
243+ }
244+
245+ if ctlr. temp_range . lower <= ctlr. temp && ctlr. temp <= ctlr. temp_range . upper
246+ {
247+ flags -= super :: SmartWarningFlags :: Ttc ;
248+ }
249+
250+ if ( 100 * ctlr. spare / ctlr. capacity ) < ctlr. spare_range . lower {
251+ flags -= super :: SmartWarningFlags :: Ascbt ;
252+ }
253+
254+ flags
255+ }
256+ . into ( ) ,
244257 ctemp : ctemp as u8 ,
245258 pldu : pdlu as u8 ,
246259 }
You can’t perform that action at this time.
0 commit comments