@@ -1296,7 +1296,7 @@ static int wdc_do_cap_diag(int fd, char *file, __u32 xfer_size)
12961296 return ret ;
12971297}
12981298
1299- static int wdc_do_cap_dui (int fd , char * file , __u32 xfer_size , int data_area )
1299+ static int wdc_do_cap_dui (int fd , char * file , __u32 xfer_size , int data_area , int verbose )
13001300{
13011301 int ret = 0 ;
13021302 __u32 dui_log_hdr_size = WDC_NVME_CAP_DUI_HEADER_SIZE ;
@@ -1312,7 +1312,8 @@ static int wdc_do_cap_dui(int fd, char *file, __u32 xfer_size, int data_area)
13121312
13131313 log_hdr = (struct wdc_dui_log_hdr * ) malloc (dui_log_hdr_size );
13141314 if (log_hdr == NULL ) {
1315- fprintf (stderr , "%s: ERROR : log header malloc failed : %s\n" , __func__ , strerror (errno ));
1315+ fprintf (stderr , "%s: ERROR : log header malloc failed : status %s, size 0x%x\n" ,
1316+ __func__ , strerror (errno ), dui_log_hdr_size );
13161317 return -1 ;
13171318 }
13181319 memset (log_hdr , 0 , dui_log_hdr_size );
@@ -1335,7 +1336,8 @@ static int wdc_do_cap_dui(int fd, char *file, __u32 xfer_size, int data_area)
13351336
13361337 cap_dui_length_v2 = le64_to_cpu (log_hdr_v2 -> log_size );
13371338
1338- fprintf (stderr , "INFO : WDC : Capture V2 Device Unit Info log\n" );
1339+ if (verbose )
1340+ fprintf (stderr , "INFO : WDC : Capture V2 Device Unit Info log, data area = %d\n" , data_area );
13391341
13401342 if (cap_dui_length_v2 == 0 ) {
13411343 fprintf (stderr , "INFO : WDC : Capture V2 Device Unit Info log is empty\n" );
@@ -1344,10 +1346,17 @@ static int wdc_do_cap_dui(int fd, char *file, __u32 xfer_size, int data_area)
13441346 if (data_area != WDC_NVME_DUI_MAX_DATA_AREA ) {
13451347 for (int i = 0 ; i < WDC_NVME_DUI_MAX_SECTION_V2 ; i ++ ) {
13461348 if (log_hdr_v2 -> log_section [i ].data_area_id <= data_area &&
1347- log_hdr_v2 -> log_section [i ].data_area_id != 0 )
1349+ log_hdr_v2 -> log_section [i ].data_area_id != 0 ) {
13481350 log_size += log_hdr_v2 -> log_section [i ].section_size ;
1349- else
1351+ if (verbose )
1352+ fprintf (stderr , "%s: Data area ID %d : section size 0x%x, total size = 0x%lx\n" ,
1353+ __func__ , log_hdr_v2 -> log_section [i ].data_area_id , (unsigned int )log_hdr_v2 -> log_section [i ].section_size , (long unsigned int )log_size );
1354+ }
1355+ else {
1356+ if (verbose )
1357+ fprintf (stderr , "%s: break, total size = 0x%lx\n" , __func__ , (long unsigned int )log_size );
13501358 break ;
1359+ }
13511360 }
13521361 } else
13531362 log_size = cap_dui_length_v2 ;
@@ -1356,7 +1365,7 @@ static int wdc_do_cap_dui(int fd, char *file, __u32 xfer_size, int data_area)
13561365
13571366 dump_data = (__u8 * ) malloc (sizeof (__u8 ) * total_size );
13581367 if (dump_data == NULL ) {
1359- fprintf (stderr , "%s: ERROR : dump data V2 malloc failed : %s, size = 0x%lx\n" ,
1368+ fprintf (stderr , "%s: ERROR : dump data V2 malloc failed : status %s, size = 0x%lx\n" ,
13601369 __func__ , strerror (errno ), (long unsigned int )total_size );
13611370 ret = -1 ;
13621371 goto out ;
@@ -1396,7 +1405,8 @@ static int wdc_do_cap_dui(int fd, char *file, __u32 xfer_size, int data_area)
13961405
13971406 cap_dui_length = le32_to_cpu (log_hdr -> log_size );
13981407
1399- fprintf (stderr , "INFO : WDC : Capture V1 Device Unit Info log\n" );
1408+ if (verbose )
1409+ fprintf (stderr , "INFO : WDC : Capture V1 Device Unit Info log, data area = %d\n" , data_area );
14001410
14011411 if (cap_dui_length == 0 ) {
14021412 fprintf (stderr , "INFO : WDC : Capture V1 Device Unit Info log is empty\n" );
@@ -1405,18 +1415,28 @@ static int wdc_do_cap_dui(int fd, char *file, __u32 xfer_size, int data_area)
14051415 if (data_area != WDC_NVME_DUI_MAX_DATA_AREA ) {
14061416 for (int i = 0 ; i < WDC_NVME_DUI_MAX_SECTION ; i ++ ) {
14071417 if (log_hdr -> log_section [i ].data_area_id <= data_area &&
1408- log_hdr -> log_section [i ].data_area_id != 0 )
1418+ log_hdr -> log_section [i ].data_area_id != 0 ) {
14091419 log_size += log_hdr -> log_section [i ].section_size ;
1410- else
1420+ if (verbose )
1421+ fprintf (stderr , "%s: Data area ID %d : section size 0x%x, total size = 0x%x\n" ,
1422+ __func__ , log_hdr -> log_section [i ].data_area_id , (unsigned int )log_hdr -> log_section [i ].section_size , (unsigned int )log_size );
1423+
1424+ }
1425+ else {
1426+ if (verbose )
1427+ fprintf (stderr , "%s: break, total size = 0x%x\n" , __func__ , (unsigned int )log_size );
14111428 break ;
1429+ }
14121430 }
14131431 } else
14141432 log_size = cap_dui_length ;
14151433
14161434 total_size = log_size ;
1435+
14171436 dump_data = (__u8 * ) malloc (sizeof (__u8 ) * total_size );
14181437 if (dump_data == NULL ) {
1419- fprintf (stderr , "%s: ERROR : dump data V1 malloc failed : %s\n" , __func__ , strerror (errno ));
1438+ fprintf (stderr , "%s: ERROR : dump data V1 malloc failed : status %s, size = 0x%lx\n" ,
1439+ __func__ , strerror (errno ), (long unsigned int )total_size );
14201440 ret = -1 ;
14211441 goto out ;
14221442 }
@@ -1454,7 +1474,8 @@ static int wdc_do_cap_dui(int fd, char *file, __u32 xfer_size, int data_area)
14541474
14551475 if (ret == 0 ) {
14561476 fprintf (stderr , "%s: NVMe Status:%s(%x)\n" , __func__ , nvme_status_to_string (ret ), ret );
1457- fprintf (stderr , "INFO : WDC : Capture Device Unit Info log, length = 0x%lx\n" , (long unsigned int )total_size );
1477+ if (verbose )
1478+ fprintf (stderr , "INFO : WDC : Capture Device Unit Info log, length = 0x%lx\n" , (long unsigned int )total_size );
14581479
14591480 ret = wdc_create_log_file (file , dump_data , total_size );
14601481 }
@@ -1756,6 +1777,7 @@ static int wdc_vs_internal_fw_log(int argc, char **argv, struct command *command
17561777 char * file = "Output file pathname." ;
17571778 char * size = "Data retrieval transfer size." ;
17581779 char * data_area = "Data area to retrieve up to." ;
1780+ char * verbose = "Display more debug messages." ;
17591781 char f [PATH_MAX ] = {0 };
17601782 char fileSuffix [PATH_MAX ] = {0 };
17611783 __u32 xfer_size = 0 ;
@@ -1768,18 +1790,21 @@ static int wdc_vs_internal_fw_log(int argc, char **argv, struct command *command
17681790 char * file ;
17691791 __u32 xfer_size ;
17701792 int data_area ;
1793+ int verbose ;
17711794 };
17721795
17731796 struct config cfg = {
17741797 .file = NULL ,
17751798 .xfer_size = 0x10000 ,
1776- .data_area = 5
1799+ .data_area = 5 ,
1800+ .verbose = 0 ,
17771801 };
17781802
17791803 const struct argconfig_commandline_options command_line_options [] = {
17801804 {"output-file" , 'o' , "FILE" , CFG_STRING , & cfg .file , required_argument , file },
17811805 {"transfer-size" , 's' , "NUM" , CFG_POSITIVE , & cfg .xfer_size , required_argument , size },
17821806 {"data-area" , 'd' , "NUM" , CFG_POSITIVE , & cfg .data_area , required_argument , data_area },
1807+ {"verbose" , 'v' , "" , CFG_NONE , & cfg .verbose , no_argument , verbose },
17831808 { NULL , '\0' , NULL , CFG_NONE , NULL , no_argument , desc },
17841809 };
17851810
@@ -1833,9 +1858,9 @@ static int wdc_vs_internal_fw_log(int argc, char **argv, struct command *command
18331858 if ((capabilities & WDC_DRIVE_CAP_INTERNAL_LOG ) == WDC_DRIVE_CAP_INTERNAL_LOG ) {
18341859 return wdc_do_cap_diag (fd , f , xfer_size );
18351860 } else if ((capabilities & WDC_DRIVE_CAP_SN340_DUI ) == WDC_DRIVE_CAP_SN340_DUI ) {
1836- return wdc_do_cap_dui (fd , f , xfer_size , cfg .data_area );
1861+ return wdc_do_cap_dui (fd , f , xfer_size , cfg .data_area , cfg . verbose );
18371862 } else if ((capabilities & WDC_DRIVE_CAP_DUI_DATA ) == WDC_DRIVE_CAP_DUI_DATA ) {
1838- return wdc_do_cap_dui (fd , f , xfer_size , WDC_NVME_DUI_MAX_DATA_AREA );
1863+ return wdc_do_cap_dui (fd , f , xfer_size , cfg . data_area , cfg . verbose );
18391864 } else if ((capabilities & WDC_SN730_CAP_VUC_LOG ) == WDC_SN730_CAP_VUC_LOG ) {
18401865 return wdc_do_sn730_get_and_tar (fd , f );
18411866 } else {
0 commit comments