@@ -4852,6 +4852,88 @@ static int sec_recv(int argc, char **argv, struct command *cmd, struct plugin *p
48524852 return nvme_status_to_errno (err , false);
48534853}
48544854
4855+ static int get_lba_status (int argc , char * * argv , struct command * cmd ,
4856+ struct plugin * plugin )
4857+ {
4858+ const char * desc = "Information about potentially unrecoverable LBAs." ;
4859+ const char * slba = "Starting LBA(SLBA) in 64-bit address of the first" \
4860+ " logical block addressed by this command" ;
4861+ const char * mndw = "Maximum Number of Dwords(MNDW) specifies maximum" \
4862+ " number of dwords to return" ;
4863+ const char * atype = "Action Type(ATYPE) specifies the mechanism the" \
4864+ " the controller uses in determining the LBA" \
4865+ " Status Descriptors to return." ;
4866+ const char * rl = "Range Length(RL) specifies the length of the range" \
4867+ " of contiguous LBAs beginning at SLBA" ;
4868+ int err , fd , fmt ;
4869+ void * buf ;
4870+ unsigned long buf_len ;
4871+
4872+ struct config {
4873+ __u64 slba ;
4874+ __u32 mndw ;
4875+ __u8 atype ;
4876+ __u16 rl ;
4877+ char * output_format ;
4878+ };
4879+
4880+ struct config cfg = {
4881+ .slba = 0 ,
4882+ .mndw = 0 ,
4883+ .atype = 0 ,
4884+ .rl = 0 ,
4885+ .output_format = "normal" ,
4886+ };
4887+
4888+ const struct argconfig_commandline_options command_line_options [] = {
4889+ {"start-lba" , 's' , "NUM" , CFG_LONG_SUFFIX , & cfg .slba , required_argument , slba },
4890+ {"max-dw" , 'm' , "NUM" , CFG_POSITIVE , & cfg .mndw , required_argument , mndw },
4891+ {"action" , 'a' , "NUM" , CFG_BYTE , & cfg .atype , required_argument , atype },
4892+ {"range-len" , 'l' , "NUM" , CFG_SHORT , & cfg .rl , required_argument , rl },
4893+ {"output-format" , 'o' , "FMT" , CFG_STRING , & cfg .output_format , required_argument , output_format },
4894+ {NULL }
4895+ };
4896+
4897+ err = fd = parse_and_open (argc , argv , desc , command_line_options , & cfg ,
4898+ sizeof (cfg ));
4899+ if (fd < 0 )
4900+ goto ret ;
4901+
4902+ err = fmt = validate_output_format (cfg .output_format );
4903+ if (fmt < 0 )
4904+ goto close_fd ;
4905+
4906+ if (!cfg .atype ) {
4907+ fprintf (stderr , "action type (--action) has to be given\n" );
4908+ err = - EINVAL ;
4909+ goto close_fd ;
4910+ }
4911+
4912+ buf_len = (cfg .mndw + 1 ) * 4 ;
4913+ buf = calloc (1 , buf_len );
4914+ if (!buf ) {
4915+ err = - ENOMEM ;
4916+ goto close_fd ;
4917+ }
4918+
4919+ err = nvme_get_lba_status (fd , cfg .slba , cfg .mndw , cfg .atype , cfg .rl ,
4920+ buf );
4921+ if (err )
4922+ goto free ;
4923+
4924+ if (fmt == BINARY )
4925+ d_raw ((unsigned char * )buf , buf_len );
4926+ else
4927+ show_lba_status (buf );
4928+
4929+ free :
4930+ free (buf );
4931+ close_fd :
4932+ close (fd );
4933+ ret :
4934+ return nvme_status_to_errno (err , false);
4935+ }
4936+
48554937static int dir_receive (int argc , char * * argv , struct command * cmd , struct plugin * plugin )
48564938{
48574939 const char * desc = "Read directive parameters of the " \
0 commit comments