13#define __STDC_FORMAT_MACROS 1 
   27  switch (driveRecordingType & 0x3) {
 
   46  switch (formFactor & 0xF) {
 
   56      return "< 1.8 inches";
 
   70  for (uint8_t hd = 0; hd < (uint8_t)numHeads; hd++) {
 
   71    jout(
"\t\t%s %" PRIu8 
": %" PRIu64 
"\n", desc, hd, paramArray[hd]);
 
   85                                       const int64_t* paramArray, 
const uint64_t numHeads) {
 
   86  for (uint8_t hd = 0; hd < (uint8_t)numHeads; hd++) {
 
   87    snprintf(
buffer, 
sizeof(
buffer), 
"%s_%" PRIu8, desc, hd);
 
   88    jref[
buffer] = paramArray[hd];
 
   99  const uint64_t even_bytes = 0x0000FFFF0000FFFF;
 
  100  const uint64_t odd_bytes  = 0xFFFF0000FFFF0000;
 
  101  return ((param & even_bytes) << 16) | ((param & odd_bytes) >> 16);
 
  114  size_t str_size = 
sizeof(param) / 
sizeof(
buffer[0]);
 
  116  for (uint8_t i = 0; i < str_size; i++) {
 
  117    val = (param >> ((str_size - i - 1) * 8)) & 0xFF;
 
  118    if (32 <= val && val < 127) {
 
  153    jinf(
"FARM support was not tested on Big Endian platforms by the developers.\n" 
  154         "Please report success/failure to " PACKAGE_BUGREPORT 
"\n\n");
 
  163  char worldWideName[64];
 
  176  modelNumber[0] = 
'\0';
 
  187  jout(
"Seagate Field Access Reliability Metrics log (FARM) (GP Log 0xa6)\n");
 
  189  jout(
"\tFARM Log Page 0: Log Header\n");
 
  199  jout(
"\tFARM Log Page 1: Drive Information\n");
 
  201    jout(
"\t\tSerial Number: %s\n", serialNumber);
 
  202    jout(
"\t\tWorld Wide Name: %s\n", worldWideName);
 
  204  jout(
"\t\tDevice Interface: %s\n", deviceInterface);
 
  210  jout(
"\t\tDevice Form Factor: %s\n", formFactor);
 
  212  jout(
"\t\tFirmware Rev: %s\n", firmwareRev);
 
  225  jout(
"\t\tModel Number: %s\n", modelNumber);
 
  226  jout(
"\t\tDrive Recording Type: %s\n", recordingType);
 
  228  jout(
"\t\tAssembly Date (YYWW): %s\n", dateOfAssembly);
 
  232  jout(
"\tFARM Log Page 2: Workload Statistics\n");
 
  240  jout(
"\t\tNumber of dither events during current power cycle: %" PRIu64 
"\n", farmLog.
workload.
dither);
 
  241  jout(
"\t\tNumber of times dither was held off during random workloads: %" PRIu64 
"\n", farmLog.
workload.
ditherRandom);
 
  253  jout(
"\tFARM Log Page 3: Error Statistics\n");
 
  275  for (uint8_t i = flash_led_size; i > 0; i--) {
 
  277    jout(
"\t\tFlash LED Event %" PRIuMAX 
":\n", 
static_cast<uintmax_t
>(flash_led_size - i));
 
  280    jout(
"\t\t\tPower Cycle Event %" PRIuMAX 
": %" PRIx64 
"\n", 
static_cast<uintmax_t
>(flash_led_size - i), farmLog.
error.
powerCycleFlashLED[index]);
 
  287    jout(
"\t\tCum Lifetime Unrecoverable by head %" PRIu8 
":\n", hd);
 
  293  jout(
"\tFARM Log Page 4: Environment Statistics\n");
 
  323  jout(
"\tFARM Log Page 5: Reliability Statistics\n");
 
  349  json::ref jref0 = jref[
"page_0_log_header"];
 
  360  json::ref jref1 = jref[
"page_1_drive_information"];
 
  362    jref1[
"serial_number"] = serialNumber;
 
  363    jref1[
"world_wide_name"] = worldWideName;
 
  365  jref1[
"device_interface"] = deviceInterface;
 
  371  jref1[
"form_factor"] = formFactor;
 
  373  jref1[
"firmware_rev"] = firmwareRev;
 
  383  jref1[
"drive_recording_type"] = recordingType;
 
  385  jref1[
"date_of_assembly"] = dateOfAssembly;
 
  389  json::ref jref2 = jref[
"page_2_workload_statistics"];
 
  410  json::ref jref3 = jref[
"page_3_error_statistics"];
 
  433  for (uint8_t i = flash_led_size; i > 0; i--) {
 
  435    snprintf(
buffer, 
sizeof(
buffer), 
"flash_led_event_%i", index);
 
  444    snprintf(
buffer, 
sizeof(
buffer), 
"cum_lifetime_unrecoverable_by_head_%i", hd);
 
  451  json::ref jref4 = jref[
"page_4_environment_statistics"];
 
  481  json::ref jref5 = jref[
"page_5_reliability_statistics"];
 
  516    jinf(
"FARM support was not tested on Big Endian platforms by the developers.\n" 
  517         "Please report success/failure to " PACKAGE_BUGREPORT 
"\n\n");
 
  524  char worldWideName[64];
 
  548  jout(
"\nSeagate Field Access Reliability Metrics log (FARM) (SCSI Log page 0x3d, sub-page 0x3)\n");
 
  551  jout(
"\tFARM Log Parameter 0: Log Header\n");
 
  559  jout(
"\tFARM Log Parameter 1: Drive Information\n");
 
  561    jout(
"\t\tSerial Number: %s\n", serialNumber);
 
  562    jout(
"\t\tWorld Wide Name: %s\n", worldWideName);
 
  564  jout(
"\t\tFirmware Rev: %s\n", firmwareRev);
 
  565  jout(
"\t\tDevice Interface: %s\n", deviceInterface);
 
  571  jout(
"\t\tDevice form factor: %s\n", formFactor);
 
  576  jout(
"\t\tDate of Assembled: %s\n", dateOfAssembly);
 
  579  jout(
"\tFARM Log Parameter 2: Workload Statistics\n");
 
  597  jout(
"\tFARM Log Parameter 3: Error Statistics\n");
 
  601  jout(
"\t\tFRU code if smart trip from most recent SMART Frame: %" PRIu64 
"\n", farmLog.
error.
tripCode);
 
  612  jout(
"\tFARM Log Parameter 4: Environment Statistics\n");
 
  628  jout(
"\tFARM Log Parameter 5: Reliability Statistics\n");
 
  632  jout(
"\tFARM Log Parameter 6: Drive Information Continued\n");
 
  634  jout(
"\t\tProduct ID: %s\n", productID);
 
  635  jout(
"\t\tDrive Recording Type: %s\n", recordingType);
 
  643  jout(
"\tFARM Log Parameter 7: Environment Information Continued\n");
 
  652  jout(
"\tFARM Log \"By Head\" Information\n");
 
  665  for (uint8_t i = 0; i < 
sizeof(actrefs) / 
sizeof(actrefs[0]); i++) {
 
  666    jout(
"\tFARM Log Actuator Information 0x%" PRIx64 
"\n", actrefs[i].actuatorID);
 
  667    jout(
"\t\tHead Load Events: %" PRIu64 
"\n", actrefs[i].headLoadEvents);
 
  668    jout(
"\t\tTimeStamp of last IDD test: %" PRIu64 
"\n", actrefs[i].timelastIDDTest);
 
  669    jout(
"\t\tSub-Command of Last IDD Test: %" PRIu64 
"\n", actrefs[i].subcommandlastIDDTest);
 
  670    jout(
"\t\tNumber of Reallocated Sector Reclamations: %" PRIu64 
"\n", actrefs[i].numberGListReclam);
 
  671    jout(
"\t\tServo Status: %" PRIu64 
"\n", actrefs[i].servoStatus);
 
  672    jout(
"\t\tNumber of Slipped Sectors Before IDD Scan: %" PRIu64 
"\n", actrefs[i].numberSlippedSectorsBeforeIDD);
 
  673    jout(
"\t\tNumber of Slipped Sectors Before IDD Scan: %" PRIu64 
"\n", actrefs[i].numberSlippedSectorsAfterIDD);
 
  674    jout(
"\t\tNumber of Resident Reallocated Sectors Before IDD Scan: %" PRIu64 
"\n", actrefs[i].numberResidentReallocatedBeforeIDD);
 
  675    jout(
"\t\tNumber of Resident Reallocated Sectors Before IDD Scan: %" PRIu64 
"\n", actrefs[i].numberResidentReallocatedAfterIDD);
 
  676    jout(
"\t\tSuccessfully Scrubbed Sectors Before IDD Scan: %" PRIu64 
"\n", actrefs[i].numberScrubbedSectorsBeforeIDD);
 
  677    jout(
"\t\tSuccessfully Scrubbed Sectors Before IDD Scan: %" PRIu64 
"\n", actrefs[i].numberScrubbedSectorsAfterIDD);
 
  678    jout(
"\t\tNumber of DOS Scans Performed: %" PRIu64 
"\n", actrefs[i].dosScansPerformed);
 
  679    jout(
"\t\tNumber of LBAs Corrected by ISP: %" PRIu64 
"\n", actrefs[i].lbasCorrectedISP);
 
  680    jout(
"\t\tNumber of Valid Parity Sectors: %" PRIu64 
"\n", actrefs[i].numberValidParitySectors);
 
  681    jout(
"\t\tNumber of LBAs Corrected by Parity Sector: %" PRIu64 
"\n", actrefs[i].numberLBACorrectedParitySector);
 
  686  size_t flash_led_size;
 
  690  for (uint8_t i = 0; i < 
sizeof(fledrefs) / 
sizeof(fledrefs[0]); i++) {
 
  691    jout(
"\tFARM Log Actuator 0x%" PRIx64 
" Flash LED Information\n", fledrefs[i].actuatorID);
 
  692    jout(
"\t\tTotal Flash LED Events: %" PRIu64 
"\n", fledrefs[i].totalFlashLED);
 
  693    jout(
"\t\tIndex of Last Flash LED: %" PRIu64 
"\n", fledrefs[i].indexFlashLED);
 
  695    flash_led_size = 
sizeof(fledrefs[i].
flashLEDArray) / 
sizeof(fledrefs[i].flashLEDArray[0]);
 
  696    for (uint8_t j = flash_led_size; j > 0; j--) {
 
  697      index = (j - fledrefs[i].
indexFlashLED + flash_led_size) % flash_led_size;
 
  698      jout(
"\t\tEvent %" PRIuMAX 
":\n", 
static_cast<uintmax_t
>(flash_led_size - j));
 
  699      jout(
"\t\t\tEvent Information: 0x%016" PRIx64 
"\n", fledrefs[i].flashLEDArray[index]);
 
  700      jout(
"\t\t\tTimestamp of Event %" PRIuMAX 
" (hours): %" PRIu64 
"\n", 
static_cast<uintmax_t
>(flash_led_size - j), fledrefs[i].universalTimestampFlashLED[index]);
 
  701      jout(
"\t\t\tPower Cycle Event %" PRIuMAX 
": %" PRIx64 
"\n", 
static_cast<uintmax_t
>(flash_led_size - j), fledrefs[i].powerCycleFlashLED[index]);
 
  709  for (uint8_t i = 0; i < 
sizeof(ararefs) / 
sizeof(ararefs[0]); i++) {
 
  710    jout(
"\tFARM Log Actuator 0x%" PRIx64 
" Reallocation\n", ararefs[i].actuatorID);
 
  711    jout(
"\t\tNumber of Reallocated Sectors: %" PRIu64 
"\n", ararefs[i].totalReallocations);
 
  712    jout(
"\t\tNumber of Reallocated Candidate Sectors: %" PRIu64 
"\n", ararefs[i].totalReallocationCanidates);
 
  727  json::ref jref1 = jref[
"drive_information"];
 
  729    jref1[
"serial_number"] = serialNumber;
 
  730    jref1[
"world_wide_name"] = worldWideName;
 
  732  jref1[
"firmware_rev"] = firmwareRev;
 
  733  jref1[
"device_interface"] = deviceInterface;
 
  739  jref1[
"device_form_factor"] = formFactor;
 
  744  jref1[
"date_of_assembled"] = dateOfAssembly;
 
  747  json::ref jref2 = jref[
"workload_statistics"];
 
  765  json::ref jref3 = jref[
"error_statistics"];
 
  769  jref3[
"fru_code_if_smart_trip_from_most_recent_smart_frame"] = farmLog.
error.
tripCode;
 
  780  json::ref jref4 = jref[
"environment_statistics"];
 
  796  json::ref jref5 = jref[
"reliability_statistics"];
 
  802  json::ref jref6 = jref[
"drive_information_continued"];
 
  804  jref6[
"product_id"] = productID;
 
  805  jref6[
"drive_recording_type"] = recordingType;
 
  813  json::ref jref7 = jref[
"environment_information_continued"];
 
  823  json::ref jrefh = jref[
"head_information"];
 
  833  for (
unsigned i = 0; i < 
sizeof(actrefs) / 
sizeof(actrefs[0]); i++) {
 
  834    snprintf(
buffer, 
sizeof(
buffer), 
"actuator_information_%" PRIx64, actrefs[i].actuatorID);
 
  839    jrefa[
"number_of_reallocated_sector_reclamations"] = actrefs[i].
numberGListReclam;
 
  854  for (
unsigned i = 0; i < 
sizeof(fledrefs) / 
sizeof(fledrefs[0]); i++) {
 
  855    snprintf(
buffer, 
sizeof(
buffer), 
"actuator_flash_led_information_%" PRIx64, fledrefs[i].actuatorID);
 
  858    jrefa[
"index_of_last_flash_led"] = fledrefs[i].
indexFlashLED;
 
  860    snprintf(
buffer, 
sizeof(
buffer), 
"event_%" PRIx64, fledrefs[i].actuatorID);
 
  861    flash_led_size = 
sizeof(fledrefs[i].
flashLEDArray) / 
sizeof(fledrefs[i].flashLEDArray[0]);
 
  862    for (uint8_t j = flash_led_size; j > 0; j--) {
 
  863      index = (j - fledrefs[i].
indexFlashLED + flash_led_size) % flash_led_size;
 
  871  for (
unsigned i = 0; i < 
sizeof(ararefs) / 
sizeof(ararefs[0]); i++) {
 
  872    snprintf(
buffer, 
sizeof(
buffer), 
"actuator_reallocation_information_%" PRIx64, ararefs[i].actuatorID);
 
bool dont_print_serial_number
Reference to a JSON element.
void ataPrintFarmLog(const ataFarmLog &farmLog)
static void farm_print_by_head_to_text(const char *desc, const int64_t *paramArray, const uint64_t numHeads)
static uint64_t farm_byte_swap(const uint64_t param)
static void farm_print_by_head_to_json(const json::ref &jref, char(&buffer)[128], const char *desc, const int64_t *paramArray, const uint64_t numHeads)
void scsiPrintFarmLog(const scsiFarmLog &farmLog)
static const char * farm_get_form_factor(const uint64_t formFactor)
static char * farm_format_id_string(char *buffer, const uint64_t param)
static const char * farm_get_recording_type(const uint64_t driveRecordingType)
void void jinf(const char *fmt,...) __attribute_format_printf(1
void jout(const char *fmt,...) __attribute_format_printf(1
uint64_t currentMotorPower
uint64_t highestShortTemp
uint64_t totalMechanicalStartRetries
uint64_t totalReadRecoveryAttepts
uint64_t cumulativeUnrecoverableReadUnique[24]
uint64_t totalUnrecoverableWriteErrors
uint64_t totalReallocationCanidates
uint64_t attrSpinRetryCount
uint64_t powerCycleFlashLED[8]
uint64_t cumulativeUnrecoverableReadERC
uint64_t totalReallocations
uint64_t totalUnrecoverableReadErrors
uint64_t cumulativeUnrecoverableReadRepeating[24]
uint64_t worstSpinRretryCount
uint64_t universalTimestampFlashLED[8]
uint64_t normalSpinRetryCount
uint64_t flashLEDArray[8]
ataFarmErrorStatistics error
ataFarmReliabilityStatistics reliability
ataFarmWorkloadStatistics workload
ataFarmEnvironmentStatistics environment
ataFarmDriveInformation driveInformation
int64_t RVGASkipWriteDetect[24]
int64_t secondMRHeadResistance[24]
int64_t writeWorkloadPowerOnTime[24]
uint64_t mrHeadResistance[24]
int64_t DVGASkipWriteDetect[24]
int64_t attrErrorRateWorst
int64_t attrSeekErrorRateWorst
int64_t attrUnloadEventsRaw
int64_t reallocatedSectors[24]
int64_t FVGASkipWriteDetect[24]
int64_t attrSeekErrorRateNormal
int64_t skipWriteDetectThresExceeded[24]
int64_t numberLBACorrectedParitySector
int64_t reallocationCandidates[24]
int64_t heliumPresureTrip
int64_t attrErrorRateNormal
int64_t attrSeekErrorRateRaw
uint64_t totalNumberofOtherCMDS
uint64_t writeCommandsByRadius1
uint64_t totalWriteCommands
uint64_t totalRandomWrites
uint64_t readCommandsByRadius1
uint64_t writeCommandsByRadius3
uint64_t logicalSecWritten
uint64_t totalRandomReads
uint64_t writeCommandsByRadius4
uint64_t readCommandsByRadius3
uint64_t writeCommandsByRadius2
uint64_t totalReadCommands
uint64_t readCommandsByRadius4
uint64_t ditherSequential
uint64_t readCommandsByRadius2
uint64_t flashLEDArray[8]
uint64_t powerCycleFlashLED[8]
uint64_t universalTimestampFlashLED[8]
uint64_t totalReallocationCanidates
uint64_t totalReallocations
uint64_t numberSlippedSectorsBeforeIDD
uint64_t lbasCorrectedISP
uint64_t numberResidentReallocatedAfterIDD
uint64_t subcommandlastIDDTest
uint64_t numberScrubbedSectorsAfterIDD
uint64_t numberLBACorrectedParitySector
uint64_t dosScansPerformed
uint64_t numberResidentReallocatedBeforeIDD
uint64_t numberScrubbedSectorsBeforeIDD
uint64_t numberGListReclam
uint64_t numberValidParitySectors
uint64_t numberSlippedSectorsAfterIDD
uint64_t currentMotorPower
uint64_t disparityErrorCodeA
uint64_t lossOfDWordSyncA
uint64_t phyResetProblemA
uint64_t disparityErrorCodeB
uint64_t invalidDWordCountB
uint64_t totalUnrecoverableWriteErrors
uint64_t invalidDWordCountA
uint64_t lossOfDWordSyncB
uint64_t totalMechanicalStartRetries
uint64_t phyResetProblemB
uint64_t totalUnrecoverableReadErrors
scsiFarmByActuator actuator0
scsiFarmByHead totalReallocations
scsiFarmDriveInformation2 driveInformation2
scsiFarmByHead totalReallocationCanidates
scsiFarmByHead cumulativeUnrecoverableReadUnique
scsiFarmByActuatorReallocation actuatorReallocation1
scsiFarmEnvironmentStatistics2 environment2
scsiFarmReliabilityStatistics reliability
scsiFarmDriveInformation driveInformation
scsiFarmByActuator actuator1
scsiFarmByHead writeWorkloadPowerOnTime
scsiFarmEnvironmentStatistics environment
scsiFarmWorkloadStatistics workload
scsiFarmByActuatorFLED actuatorFLED1
scsiFarmByHead secondMRHeadResistance
scsiFarmByActuatorReallocation actuatorReallocation2
scsiFarmByActuatorFLED actuatorFLED0
scsiFarmByHead cumulativeUnrecoverableReadRepeat
scsiFarmByActuatorReallocation actuatorReallocation0
scsiFarmByActuator actuator3
scsiFarmErrorStatistics error
scsiFarmByActuatorReallocation actuatorReallocation3
scsiFarmByActuator actuator2
scsiFarmByHead mrHeadResistance
scsiFarmByActuatorFLED actuatorFLED2
scsiFarmByActuatorFLED actuatorFLED3
int64_t heliumPresureTrip
uint64_t writeCommandsByRadius3
uint64_t writeCommandsByRadius1
uint64_t totalReadCommands
uint64_t writeCommandsByRadius4
uint64_t writeCommandsByRadius2
uint64_t readCommandsByRadius1
uint64_t readCommandsByRadius3
uint64_t totalWriteCommands
uint64_t totalNumberofOtherCMDS
uint64_t totalRandomWrites
uint64_t totalRandomReads
uint64_t readCommandsByRadius2
uint64_t readCommandsByRadius4
uint64_t logicalSecWritten