From c7f006340a1bf53b2b95e36654e528615a80e68d Mon Sep 17 00:00:00 2001 From: Tyler Erickson Date: Thu, 25 Jan 2024 16:33:44 -0700 Subject: [PATCH 1/3] feat: Adding support for ATA WRV feature configuration Adding support for ATA WRV feature to configure it to the different modes as well as read the current state of the feature. Signed-off-by: Tyler Erickson --- include/openseachest_util_options.h | 19 +++ src/openseachest_util_options.c | 27 ++++ subprojects/opensea-operations | 2 +- subprojects/opensea-transport | 2 +- utils/C/openSeaChest/openSeaChest_Configure.c | 124 +++++++++++++++++- 5 files changed, 171 insertions(+), 3 deletions(-) diff --git a/include/openseachest_util_options.h b/include/openseachest_util_options.h index c86ae05..d955fad 100644 --- a/include/openseachest_util_options.h +++ b/include/openseachest_util_options.h @@ -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 @@ -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 diff --git a/src/openseachest_util_options.c b/src/openseachest_util_options.c index f7f0429..f26a020 100644 --- a/src/openseachest_util_options.c +++ b/src/openseachest_util_options.c @@ -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); diff --git a/subprojects/opensea-operations b/subprojects/opensea-operations index d71d18f..020020a 160000 --- a/subprojects/opensea-operations +++ b/subprojects/opensea-operations @@ -1 +1 @@ -Subproject commit d71d18fba0053a473b4b42a086a820a8f6b884d6 +Subproject commit 020020a8f5c5f4847489b08be16b06eb56d3191f diff --git a/subprojects/opensea-transport b/subprojects/opensea-transport index dc2a01b..6a0c8a5 160000 --- a/subprojects/opensea-transport +++ b/subprojects/opensea-transport @@ -1 +1 @@ -Subproject commit dc2a01b4ddd47d2afa40ad90babce31b8174ca74 +Subproject commit 6a0c8a585246f50c5315a65f60f052a768a44018 diff --git a/utils/C/openSeaChest/openSeaChest_Configure.c b/utils/C/openSeaChest/openSeaChest_Configure.c index 9fe7fc0..35fc28e 100644 --- a/utils/C/openSeaChest/openSeaChest_Configure.c +++ b/utils/C/openSeaChest/openSeaChest_Configure.c @@ -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 // @@ -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 @@ -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 }; @@ -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; @@ -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); @@ -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]); } @@ -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"); From 5686dec30ac394f6cbf187c3eafde85d00ae2575 Mon Sep 17 00:00:00 2001 From: Tyler Erickson Date: Mon, 29 Jan 2024 21:20:50 -0700 Subject: [PATCH 2/3] lib: final tweaks for WRV Signed-off-by: Tyler Erickson --- subprojects/opensea-operations | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/opensea-operations b/subprojects/opensea-operations index b6e3d22..22446d5 160000 --- a/subprojects/opensea-operations +++ b/subprojects/opensea-operations @@ -1 +1 @@ -Subproject commit b6e3d22a046739a974d88e2958fcadb5388ae7c3 +Subproject commit 22446d5083fe96c15215eb123f77bdc54183c8f1 From 2da1e6c09b319b69a37d409ba1b7ad7355e9590c Mon Sep 17 00:00:00 2001 From: Tyler Erickson Date: Mon, 29 Jan 2024 21:21:32 -0700 Subject: [PATCH 3/3] lib: Pointing to develop libs after feature completion Signed-off-by: Tyler Erickson --- subprojects/opensea-operations | 2 +- subprojects/opensea-transport | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/subprojects/opensea-operations b/subprojects/opensea-operations index 22446d5..1f94772 160000 --- a/subprojects/opensea-operations +++ b/subprojects/opensea-operations @@ -1 +1 @@ -Subproject commit 22446d5083fe96c15215eb123f77bdc54183c8f1 +Subproject commit 1f9477265993556d47244577b0b7e4261673e2bb diff --git a/subprojects/opensea-transport b/subprojects/opensea-transport index b0b6c5f..45390e6 160000 --- a/subprojects/opensea-transport +++ b/subprojects/opensea-transport @@ -1 +1 @@ -Subproject commit b0b6c5f37f7a11b9acee57c7a411c17191e3f02d +Subproject commit 45390e6689d847831a5b7a91b6cca8b2b6463e5c