Skip to content

Commit

Permalink
feat: Finish ata_wrv
Browse files Browse the repository at this point in the history
  • Loading branch information
vonericsen committed Jan 30, 2024
2 parents 9ad9855 + 2da1e6c commit 4989739
Show file tree
Hide file tree
Showing 5 changed files with 171 additions and 3 deletions.
19 changes: 19 additions & 0 deletions include/openseachest_util_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -1614,6 +1614,23 @@ extern "C"
#define FREE_FALL_LONG_OPT_STRING "freeFall"
#define FREE_FALL_LONG_OPT { FREE_FALL_LONG_OPT_STRING, required_argument, NULL, 0 }

//ATA Write-read-verify
#define WRV_FLAG setWRV
#define WRV_DISABLE disableWRV
#define WRV_INFO wrvInformation
#define WRV_USER_VALUE wrvUserValue
#define WRV_ALL setWRVallSectors
#define WRV_VENDOR setWRVvendorSpecific
#define WRV_VARS \
bool WRV_FLAG = false;\
bool WRV_INFO = false;\
bool WRV_DISABLE = false;\
bool WRV_ALL = false;\
bool WRV_VENDOR = false;\
uint32_t WRV_USER_VALUE = 0;//user provides sector count. Converted as required by standard by library.
#define WRV_LONG_OPT_STRING "wrv"
#define WRV_LONG_OPT { WRV_LONG_OPT_STRING, required_argument, NULL, 0 }

//SCSI defect list
#define SCSI_DEFECTS_FLAG showSCSIDefects
#define SCSI_DEFECTS_PRIMARY_LIST scsiPrimaryDefects
Expand Down Expand Up @@ -3533,6 +3550,8 @@ extern "C"

void print_DCO_Disable_Features_Help(bool shortHelp);

void print_WRV_Help(bool shortHelp);

#define OUTPUTPATH_PARSE outputPathPtr = optarg;

typedef struct _deviceScanFlags
Expand Down
27 changes: 27 additions & 0 deletions src/openseachest_util_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -2670,6 +2670,33 @@ void print_Set_APM_Level_Help(bool shortHelp)
}
}

void print_WRV_Help(bool shortHelp)
{
printf("\t--%s [ info | all | vendor | # | disable ]\t(SATA Only)\n", WRV_LONG_OPT_STRING);
if (!shortHelp)
{
printf("\t\tThis option can report the current configuration of the\n");
printf("\t\tATA Write-Read-Verify feature, enable the feature, or\n");
printf("\t\tdisable the feature.\n");
printf("\t\tEnabling this feature instructs the device to perform a\n");
printf("\t\tverification of all data after it has been written.\n");
printf("\t\tEnabling this may result in lower device performance.\n");
printf("\t\tIf write caching is enabled, this feature may return\n");
printf("\t\tcompletion before writing to the medium and verifying\n");
printf("\t\tthe medium. If Write caching is disabled, the write and\n");
printf("\t\tverification must complete before returning command status.\n");
printf("\t\tArgument usage:\n");
printf("\t\t info - Display the current status of the feature\n");
printf("\t\t all - set verification on for all written sectors\n");
printf("\t\t vendor - set verification for the 1st vendor specific\n");
printf("\t\t number of sectors.\n");
printf("\t\t # - Perform verification for the first user defined\n");
printf("\t\t number of sectors. Note: This is rounded up to the\n");
printf("\t\t nearest 1024 sectors. Max value of 261120 sectors.\n");
printf("\t\t disable - disable the Write-Read-Verify feature.\n\n");
}
}

void print_Show_APM_Level_Help(bool shortHelp)
{
printf("\t--%s (SATA Only)\n", SHOW_APM_LEVEL_LONG_OPT_STRING);
Expand Down
2 changes: 1 addition & 1 deletion subprojects/opensea-operations
2 changes: 1 addition & 1 deletion subprojects/opensea-transport
124 changes: 123 additions & 1 deletion utils/C/openSeaChest/openSeaChest_Configure.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
// Global Variables //
////////////////////////
const char *util_name = "openSeaChest_Configure";
const char *buildVersion = "2.5.1";
const char *buildVersion = "2.6.0";

////////////////////////////
// functions to declare //
Expand Down Expand Up @@ -108,6 +108,7 @@ int32_t main(int argc, char *argv[])
#endif
SCT_ERROR_RECOVERY_CONTROL_VARS
FREE_FALL_VARS
WRV_VARS

SCSI_MP_RESET_VARS
SCSI_MP_RESTORE_VARS
Expand Down Expand Up @@ -189,6 +190,7 @@ int32_t main(int argc, char *argv[])
ATA_DCO_SETMAXLBA_LONG_OPT,
ATA_DCO_SETMAXMODE_LONG_OPT,
ATA_DCO_DISABLE_FEEATURES_LONG_OPT,
WRV_LONG_OPT,
LONG_OPT_TERMINATOR
};

Expand Down Expand Up @@ -1182,6 +1184,39 @@ int32_t main(int argc, char *argv[])
exit(UTIL_EXIT_ERROR_IN_COMMAND_LINE);
}
}
else if (strcmp(longopts[optionIndex].name, WRV_LONG_OPT_STRING) == 0)
{
uint64_t tempCount = 0;
if (strcmp(optarg, "info") == 0)
{
WRV_INFO = true;
}
else if (strcmp(optarg, "all") == 0)
{
WRV_FLAG = true;
WRV_ALL = true;
}
else if (strcmp(optarg, "vendor") == 0)
{
WRV_FLAG = true;
WRV_VENDOR = true;
}
else if (strcmp(optarg, "disable") == 0)
{
WRV_FLAG = true;
WRV_DISABLE = true;
}
else if (get_And_Validate_Integer_Input(optarg, &tempCount))
{
WRV_FLAG = true;
WRV_USER_VALUE = C_CAST(uint32_t, tempCount);
}
else
{
print_Error_In_Cmd_Line_Args(WRV_LONG_OPT_STRING, optarg);
exit(UTIL_EXIT_ERROR_IN_COMMAND_LINE);
}
}
else if (strncmp(longopts[optionIndex].name, MODEL_MATCH_LONG_OPT_STRING, M_Min(strlen(longopts[optionIndex].name), strlen(MODEL_MATCH_LONG_OPT_STRING))) == 0)
{
MODEL_MATCH_FLAG = true;
Expand Down Expand Up @@ -1519,6 +1554,8 @@ int32_t main(int argc, char *argv[])
|| ATA_DCO_IDENTIFY
|| ATA_DCO_FREEZE
|| ATA_DCO_RESTORE
|| WRV_FLAG
|| WRV_INFO
))
{
utility_Usage(true);
Expand Down Expand Up @@ -4012,6 +4049,90 @@ int32_t main(int argc, char *argv[])
}
}
}

if (WRV_INFO)
{
wrvInfo info;
memset(&info, 0, sizeof(wrvInfo));
switch (get_Write_Read_Verify_Info(&deviceList[deviceIter], &info))
{
case SUCCESS:
print_Write_Read_Verify_Info(&info);
break;
case NOT_SUPPORTED:
if (VERBOSITY_QUIET < toolVerbosity)
{
printf("Write-Read-Verify feature is not supported on this device.\n");
}
exitCode = UTIL_EXIT_OPERATION_NOT_SUPPORTED;
break;
default:
if (VERBOSITY_QUIET < toolVerbosity)
{
printf("Failed to get Write-Read-Verify feature infomation.\n");
}
exitCode = UTIL_EXIT_OPERATION_FAILURE;
break;
}
}

if (WRV_FLAG)
{
if (WRV_DISABLE)
{
switch (disable_Write_Read_Verify(&deviceList[deviceIter]))
{
case SUCCESS:
if (VERBOSITY_QUIET < toolVerbosity)
{
printf("Successfully disabled Write-Read-Verify feature\n");
}
exitCode = UTIL_EXIT_OPERATION_NOT_SUPPORTED;
break;
case NOT_SUPPORTED:
if (VERBOSITY_QUIET < toolVerbosity)
{
printf("Write-Read-Verify feature is not supported on this device.\n");
}
exitCode = UTIL_EXIT_OPERATION_NOT_SUPPORTED;
break;
default:
if (VERBOSITY_QUIET < toolVerbosity)
{
printf("Failed to disable Write-Read-Verify feature.\n");
}
exitCode = UTIL_EXIT_OPERATION_FAILURE;
break;
}
}
else
{
switch (set_Write_Read_Verify(&deviceList[deviceIter], WRV_ALL, WRV_VENDOR, WRV_USER_VALUE))
{
case SUCCESS:
if (VERBOSITY_QUIET < toolVerbosity)
{
printf("Successfully enabled Write-Read-Verify feature\n");
}
exitCode = UTIL_EXIT_OPERATION_NOT_SUPPORTED;
break;
case NOT_SUPPORTED:
if (VERBOSITY_QUIET < toolVerbosity)
{
printf("Write-Read-Verify feature is not supported on this device.\n");
}
exitCode = UTIL_EXIT_OPERATION_NOT_SUPPORTED;
break;
default:
if (VERBOSITY_QUIET < toolVerbosity)
{
printf("Failed to enable Write-Read-Verify feature.\n");
}
exitCode = UTIL_EXIT_OPERATION_FAILURE;
break;
}
}
}
//At this point, close the device handle since it is no longer needed. Do not put any further IO below this.
close_Device(&deviceList[deviceIter]);
}
Expand Down Expand Up @@ -4141,6 +4262,7 @@ void utility_Usage(bool shortUsage)
print_SCT_Write_Cache_Help(shortUsage);
print_SCT_Write_Cache_Reordering_Help(shortUsage);
print_SCT_Error_Recovery_Write_Help(shortUsage);
print_WRV_Help(shortUsage);

//SAS Only Options
printf("\n\tSAS Only:\n\t========\n");
Expand Down

0 comments on commit 4989739

Please sign in to comment.