Skip to content

Commit

Permalink
feat: Finish sata_phy_event_counters
Browse files Browse the repository at this point in the history
  • Loading branch information
vonericsen committed Jan 30, 2024
2 parents 4989739 + 0a9af78 commit 5d8101a
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 3 deletions.
8 changes: 8 additions & 0 deletions include/openseachest_util_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -1957,6 +1957,12 @@ extern "C"
#define SHOW_CONCURRENT_RANGES_LONG_OPT_STRING "showConcurrentRanges"
#define SHOW_CONCURRENT_RANGES_LONG_OPT { SHOW_CONCURRENT_RANGES_LONG_OPT_STRING, no_argument, &SHOW_CONCURRENT_RANGES, goTrue }

//SATA Phy event counters
#define SHOW_PHY_EVENT_COUNTERS showSataPhyEventCounters
#define SHOW_PHY_EVENT_COUNTERS_VAR getOptBool SHOW_PHY_EVENT_COUNTERS = goFalse;
#define SHOW_PHY_EVENT_COUNTERS_LONG_OPT_STRING "showPhyEvents"
#define SHOW_PHY_EVENT_COUNTERS_LONG_OPT { SHOW_PHY_EVENT_COUNTERS_LONG_OPT_STRING, no_argument, &SHOW_PHY_EVENT_COUNTERS, goTrue }

//SCSI/NVMe reservations
#define SHOW_RESERVATION_CAPABILITIES showReservationCapabilities
#define SHOW_RESERVATION_CAPABILITIES_VAR getOptBool SHOW_RESERVATION_CAPABILITIES = goFalse;
Expand Down Expand Up @@ -3550,6 +3556,8 @@ extern "C"

void print_DCO_Disable_Features_Help(bool shortHelp);

void print_Show_Phy_Event_Counters_Help(bool shortHelp);

void print_WRV_Help(bool shortHelp);

#define OUTPUTPATH_PARSE outputPathPtr = optarg;
Expand Down
10 changes: 10 additions & 0 deletions src/openseachest_util_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,16 @@ void print_Show_NVM_Power_States_Help(bool shortHelp)
}
}

void print_Show_Phy_Event_Counters_Help(bool shortHelp)
{
printf("\t--%s\t(SATA Only)\n", SHOW_PHY_EVENT_COUNTERS_LONG_OPT_STRING);
if (!shortHelp)
{
printf("\t\tUse this option to display a SATA device's supported\n");
printf("\t\tevent counters.\n\n");
}
}

void print_Transition_Power_Help(bool shortHelp)
{
printf("\t--%s [active | idle | idleUnload | standby | idle_a | idle_b | idle_c | standby_y | standby_z | sleep]\n", TRANSITION_POWER_MODE_LONG_OPT_STRING);
Expand Down
2 changes: 1 addition & 1 deletion subprojects/opensea-transport
33 changes: 32 additions & 1 deletion utils/C/openSeaChest/openSeaChest_Info.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@
#include "csmi_helper_func.h"
#endif
#include "partition_info.h"
#include "sata_phy.h"
////////////////////////
// Global Variables //
////////////////////////
const char *util_name = "openSeaChest_Info";
const char *buildVersion = "2.5.0";
const char *buildVersion = "2.6.0";

////////////////////////////
// functions to declare //
Expand Down Expand Up @@ -96,6 +97,7 @@ int32_t main(int argc, char *argv[])
SHOW_CONCURRENT_RANGES_VAR
LOWLEVEL_INFO_VAR
PARTITION_INFO_VAR
SHOW_PHY_EVENT_COUNTERS_VAR

int args = 0;
int argIndex = 0;
Expand Down Expand Up @@ -138,6 +140,7 @@ int32_t main(int argc, char *argv[])
#endif
SHOW_CONCURRENT_RANGES_LONG_OPT,
PARTITION_INFO_LONG_OPT,
SHOW_PHY_EVENT_COUNTERS_LONG_OPT,
LONG_OPT_TERMINATOR
};

Expand Down Expand Up @@ -559,6 +562,7 @@ int32_t main(int argc, char *argv[])
#endif
|| SHOW_CONCURRENT_RANGES
|| PARTITION_INFO_FLAG
|| SHOW_PHY_EVENT_COUNTERS
))
{
utility_Usage(true);
Expand Down Expand Up @@ -982,6 +986,32 @@ int32_t main(int argc, char *argv[])
}
}

if (SHOW_PHY_EVENT_COUNTERS)
{
sataPhyEventCounters events;
memset(&events, 0, sizeof(sataPhyEventCounters));
switch (get_SATA_Phy_Event_Counters(&deviceList[deviceIter], &events))
{
case SUCCESS:
print_SATA_Phy_Event_Counters(&events);
break;
case NOT_SUPPORTED:
if (VERBOSITY_QUIET < toolVerbosity)
{
printf("Phy event counters are not supported on this device.\n");
}
exitCode = UTIL_EXIT_OPERATION_NOT_SUPPORTED;
break;
default:
if (VERBOSITY_QUIET < toolVerbosity)
{
printf("Failed to read the Phy event counters.\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 @@ -1072,6 +1102,7 @@ void utility_Usage(bool shortUsage)
print_Partition_Info_Help(shortUsage);
//SATA Only Options
printf("\n\tSATA Only:\n\t=========\n");
print_Show_Phy_Event_Counters_Help(shortUsage);
print_SMART_Attributes_Help(shortUsage);
//SAS Only Options
printf("\n\tSAS Only:\n\t=========\n");
Expand Down

0 comments on commit 5d8101a

Please sign in to comment.