Commit 98f5aff5 authored by Daniil Lunev's avatar Daniil Lunev Committed by Commit Bot

DeviceStatusCollector: Add storage device identity

Adds vendor, product, hardware and firmare revisions of the device to
reporting.
Corresponds to the following platform CL:
https://chromium-review.googlesource.com/c/chromiumos/platform2/+/2241216

BUG=b:151176984
TEST=unittest

Change-Id: I42971baa07ace1e29f17de74bc5da35247185a8b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2294743Reviewed-by: default avatarMaksim Ivanov <emaxx@chromium.org>
Reviewed-by: default avatarJorge Lucangeli Obes <jorgelo@chromium.org>
Reviewed-by: default avatarPaul Moy <pmoy@chromium.org>
Commit-Queue: Daniil Lunev <dlunev@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791727}
parent 0431f251
...@@ -883,6 +883,78 @@ class DeviceStatusCollectorState : public StatusCollectorState { ...@@ -883,6 +883,78 @@ class DeviceStatusCollectorState : public StatusCollectorState {
disk_info_out->set_discard_time_seconds_since_last_boot( disk_info_out->set_discard_time_seconds_since_last_boot(
discard_time->value); discard_time->value);
} }
// vendor_id
const auto& vendor_id = storage->vendor_id;
switch (vendor_id->which()) {
case chromeos::cros_healthd::mojom::BlockDeviceVendor::Tag::
NVME_SUBSYSTEM_VENDOR:
disk_info_out->set_nvme_subsystem_vendor(
vendor_id->get_nvme_subsystem_vendor());
break;
case chromeos::cros_healthd::mojom::BlockDeviceVendor::Tag::
EMMC_OEMID:
disk_info_out->set_emmc_oemid(vendor_id->get_emmc_oemid());
break;
case chromeos::cros_healthd::mojom::BlockDeviceVendor::Tag::OTHER:
disk_info_out->set_other_vendor(vendor_id->get_other());
break;
}
// product_id
const auto& product_id = storage->product_id;
switch (product_id->which()) {
case chromeos::cros_healthd::mojom::BlockDeviceProduct::Tag::
NVME_SUBSYSTEM_DEVICE:
disk_info_out->set_nvme_subsystem_device(
product_id->get_nvme_subsystem_device());
break;
case chromeos::cros_healthd::mojom::BlockDeviceProduct::Tag::
EMMC_PNM:
disk_info_out->set_emmc_pnm(product_id->get_emmc_pnm());
break;
case chromeos::cros_healthd::mojom::BlockDeviceProduct::Tag::
OTHER:
disk_info_out->set_other_product(product_id->get_other());
break;
}
// revision
const auto& revision = storage->revision;
switch (revision->which()) {
case chromeos::cros_healthd::mojom::BlockDeviceRevision::Tag::
NVME_PCIE_REV:
disk_info_out->set_nvme_hardware_rev(
revision->get_nvme_pcie_rev());
break;
case chromeos::cros_healthd::mojom::BlockDeviceRevision::Tag::
EMMC_PRV:
disk_info_out->set_emmc_hardware_rev(revision->get_emmc_prv());
break;
case chromeos::cros_healthd::mojom::BlockDeviceRevision::Tag::
OTHER:
disk_info_out->set_other_hardware_rev(revision->get_other());
break;
}
// firmware version
const auto& fw_version = storage->firmware_version;
switch (fw_version->which()) {
case chromeos::cros_healthd::mojom::BlockDeviceFirmware::Tag::
NVME_FIRMWARE_REV:
disk_info_out->set_nvme_firmware_rev(
fw_version->get_nvme_firmware_rev());
break;
case chromeos::cros_healthd::mojom::BlockDeviceFirmware::Tag::
EMMC_FWREV:
disk_info_out->set_emmc_firmware_rev(
fw_version->get_emmc_fwrev());
break;
case chromeos::cros_healthd::mojom::BlockDeviceFirmware::Tag::
OTHER:
disk_info_out->set_other_firmware_rev(fw_version->get_other());
break;
}
} }
break; break;
} }
......
...@@ -184,6 +184,10 @@ constexpr uint64_t kFakeStorageReadTimeSeconds = 23570; ...@@ -184,6 +184,10 @@ constexpr uint64_t kFakeStorageReadTimeSeconds = 23570;
constexpr uint64_t kFakeStorageWriteTimeSeconds = 5768; constexpr uint64_t kFakeStorageWriteTimeSeconds = 5768;
constexpr uint64_t kFakeStorageIoTimeSeconds = 709; constexpr uint64_t kFakeStorageIoTimeSeconds = 709;
constexpr uint64_t kFakeStorageDiscardTimeSeconds = 9869; constexpr uint64_t kFakeStorageDiscardTimeSeconds = 9869;
constexpr uint16_t kFakeOemid = 274;
constexpr uint64_t kFakePnm = 8321204;
constexpr uint8_t kFakePrv = 5;
constexpr uint64_t kFakeFwrev = 1704189236;
// Timezone test values: // Timezone test values:
constexpr char kPosixTimezone[] = "MST7MDT,M3.2.0,M11.1.0"; constexpr char kPosixTimezone[] = "MST7MDT,M3.2.0,M11.1.0";
constexpr char kTimezoneRegion[] = "America/Denver"; constexpr char kTimezoneRegion[] = "America/Denver";
...@@ -488,11 +492,17 @@ cros_healthd::BatteryResultPtr CreateBatteryResult() { ...@@ -488,11 +492,17 @@ cros_healthd::BatteryResultPtr CreateBatteryResult() {
cros_healthd::NonRemovableBlockDeviceResultPtr CreateBlockDeviceResult() { cros_healthd::NonRemovableBlockDeviceResultPtr CreateBlockDeviceResult() {
std::vector<cros_healthd::NonRemovableBlockDeviceInfoPtr> storage_vector; std::vector<cros_healthd::NonRemovableBlockDeviceInfoPtr> storage_vector;
storage_vector.push_back(cros_healthd::NonRemovableBlockDeviceInfo::New( storage_vector.push_back(cros_healthd::NonRemovableBlockDeviceInfo::New(
kFakeStoragePath, kFakeStorageSize, kFakeStorageType, kFakeStorageManfid, kFakeStorageBytesRead, kFakeStorageBytesWritten,
kFakeStorageName, kFakeStorageSerial, kFakeStorageBytesRead, kFakeStorageReadTimeSeconds, kFakeStorageWriteTimeSeconds,
kFakeStorageBytesWritten, kFakeStorageReadTimeSeconds, kFakeStorageIoTimeSeconds,
kFakeStorageWriteTimeSeconds, kFakeStorageIoTimeSeconds, cros_healthd::UInt64Value::New(kFakeStorageDiscardTimeSeconds),
cros_healthd::UInt64Value::New(kFakeStorageDiscardTimeSeconds))); cros_healthd::BlockDeviceVendor::NewEmmcOemid(kFakeOemid),
cros_healthd::BlockDeviceProduct::NewEmmcPnm(kFakePnm),
cros_healthd::BlockDeviceRevision::NewEmmcPrv(kFakePrv), kFakeStorageName,
kFakeStorageSize,
cros_healthd::BlockDeviceFirmware::NewEmmcFwrev(kFakeFwrev),
kFakeStorageType, kFakeStoragePath, kFakeStorageManfid,
kFakeStorageSerial));
return cros_healthd::NonRemovableBlockDeviceResult::NewBlockDeviceInfo( return cros_healthd::NonRemovableBlockDeviceResult::NewBlockDeviceInfo(
std::move(storage_vector)); std::move(storage_vector));
} }
...@@ -3129,6 +3139,14 @@ TEST_F(DeviceStatusCollectorTest, TestCrosHealthdInfo) { ...@@ -3129,6 +3139,14 @@ TEST_F(DeviceStatusCollectorTest, TestCrosHealthdInfo) {
EXPECT_EQ(disk.io_time_seconds_since_last_boot(), kFakeStorageIoTimeSeconds); EXPECT_EQ(disk.io_time_seconds_since_last_boot(), kFakeStorageIoTimeSeconds);
EXPECT_EQ(disk.discard_time_seconds_since_last_boot(), EXPECT_EQ(disk.discard_time_seconds_since_last_boot(),
kFakeStorageDiscardTimeSeconds); kFakeStorageDiscardTimeSeconds);
ASSERT_TRUE(disk.has_emmc_oemid());
EXPECT_EQ(disk.emmc_oemid(), kFakeOemid);
ASSERT_TRUE(disk.has_emmc_pnm());
EXPECT_EQ(disk.emmc_pnm(), kFakePnm);
ASSERT_TRUE(disk.has_emmc_hardware_rev());
EXPECT_EQ(disk.emmc_hardware_rev(), kFakePrv);
ASSERT_TRUE(disk.has_emmc_firmware_rev());
EXPECT_EQ(disk.emmc_firmware_rev(), kFakeFwrev);
// Verify the system info. // Verify the system info.
ASSERT_TRUE(device_status_.has_system_status()); ASSERT_TRUE(device_status_.has_system_status());
......
...@@ -167,21 +167,41 @@ union NonRemovableBlockDeviceResult { ...@@ -167,21 +167,41 @@ union NonRemovableBlockDeviceResult {
ProbeError error; ProbeError error;
}; };
// Unions for device-specific data fields. |other| is provided by the default
// data adapter and filled with a default value for the unknown device type.
// The manufacturer of the block device.
union BlockDeviceVendor {
uint32 nvme_subsystem_vendor;
uint16 emmc_oemid;
uint16 other;
};
// The manufacturer-specific product identifier.
union BlockDeviceProduct {
uint32 nvme_subsystem_device;
uint64 emmc_pnm;
uint16 other;
};
// The revision of the device's hardware.
union BlockDeviceRevision {
uint8 nvme_pcie_rev;
uint8 emmc_prv;
uint16 other;
};
// The revision of the device's firmware.
union BlockDeviceFirmware {
uint64 nvme_firmware_rev;
uint64 emmc_fwrev;
uint16 other;
};
// Information related to a specific non-removable block device. // Information related to a specific non-removable block device.
struct NonRemovableBlockDeviceInfo { struct NonRemovableBlockDeviceInfo {
// The path of this storage on the system. It is useful if caller needs to // IO statistics
// correlate with other information.
string path;
// Exact size of this storage, reported in bytes
uint64 size;
// Storage type, could be MMC / NVMe / ATA, based on udev subsystem.
string type;
// Manufacturer ID, 8 bits.
uint8 manufacturer_id;
// PNM: Product name, ASCII characters for 6 bytes.
string name;
// PSN: Product serial number, 32 bits
uint32 serial;
// Bytes read since last boot. // Bytes read since last boot.
uint64 bytes_read_since_last_boot; uint64 bytes_read_since_last_boot;
// Bytes written since last boot. // Bytes written since last boot.
...@@ -197,6 +217,33 @@ struct NonRemovableBlockDeviceInfo { ...@@ -197,6 +217,33 @@ struct NonRemovableBlockDeviceInfo {
// Time spent discarding since last boot. Discarding is writing to clear // Time spent discarding since last boot. Discarding is writing to clear
// blocks which are no longer in use. Supported on kernels 4.18+. // blocks which are no longer in use. Supported on kernels 4.18+.
UInt64Value? discard_time_seconds_since_last_boot; UInt64Value? discard_time_seconds_since_last_boot;
// Device identification.
// Device vendor identification.
BlockDeviceVendor vendor_id;
// Device product identification.
BlockDeviceProduct product_id;
// Device revision.
BlockDeviceRevision revision;
// Device model.
string name;
// Device size in bytes.
uint64 size;
// Firmware version.
BlockDeviceFirmware firmware_version;
// Storage type, could be MMC / NVMe / ATA, based on udev subsystem.
string type;
// Additional identification.
// The path of this storage on the system. It is useful if caller needs to
// correlate with other information.
string path;
// Manufacturer ID, 8 bits.
uint8 manufacturer_id;
// PSN: Product serial number, 32 bits
uint32 serial;
}; };
// CPU probe result. Can either be populated with the CpuInfo or an error // CPU probe result. Can either be populated with the CpuInfo or an error
......
...@@ -1030,6 +1030,7 @@ message DiskLifetimeEstimation { ...@@ -1030,6 +1030,7 @@ message DiskLifetimeEstimation {
} }
// Status of the single storage device // Status of the single storage device
// Next id: 26
message DiskInfo { message DiskInfo {
optional string serial = 1; optional string serial = 1;
optional string manufacturer = 2; optional string manufacturer = 2;
...@@ -1052,6 +1053,38 @@ message DiskInfo { ...@@ -1052,6 +1053,38 @@ message DiskInfo {
// Time spent discarding since last boot. Discarding is writing to clear // Time spent discarding since last boot. Discarding is writing to clear
// blocks which are no longer in use. Supported on kernels 4.18+. // blocks which are no longer in use. Supported on kernels 4.18+.
optional uint64 discard_time_seconds_since_last_boot = 13; optional uint64 discard_time_seconds_since_last_boot = 13;
// The manufacturer of the block device.
oneof vendor_id {
// NVME vendors:
// https://pcisig.com/membership/member-companies
uint32 nvme_subsystem_vendor = 14;
// EMMC oemids
// https://screenshot.googleplex.com/eZWNnV8qGnc
uint32 emmc_oemid = 15;
uint32 other_vendor = 16;
}
// The manufacturer-specific product identifier.
oneof product_id {
uint32 nvme_subsystem_device = 17;
uint32 emmc_pnm = 18;
uint32 other_product = 19;
}
// The revision of the device's hardware.
oneof hardware_revision {
uint32 nvme_hardware_rev = 20;
uint32 emmc_hardware_rev = 21;
uint32 other_hardware_rev = 22;
}
// The revision of the device's firmware.
oneof firmware_revision {
uint64 nvme_firmware_rev = 23;
uint64 emmc_firmware_rev = 24;
uint32 other_firmware_rev = 25;
}
} }
// Status of the storage subsystem. // Status of the storage subsystem.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment