diagnostics_service.mojom 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. // API and definitions exposed by the Telemetry Services. This API is normally
  5. // consumed by the Telemetry Extension APIs implementation.
  6. // Note: This is a subset of the cros_healthd diagnostics service interface
  7. // which is located in
  8. // //chromeos/ash/services/cros_healthd/public/mojom/cros_healthd.mojom.
  9. // This interface serves as PII filtering and data post-processing service
  10. // between the source (cros_healthd) and the clients
  11. // (third-party telemetry extensions).
  12. module crosapi.mojom;
  13. // Interface for exposing diagnostics service. Implemented in ash-chrome.
  14. //
  15. // Next ID: 17
  16. [Stable, Uuid="14bc6194-c059-4048-9bea-ca6823eeda82",
  17. RenamedFrom="ash.health.mojom.DiagnosticsService"]
  18. interface DiagnosticsService {
  19. // Returns an array of all diagnostic routines that the platform supports.
  20. GetAvailableRoutines@0()
  21. => (array<DiagnosticsRoutineEnum> available_routines);
  22. // Sends commands to an existing routine. Also returns status information for
  23. // the routine.
  24. //
  25. // The request:
  26. // * |id| - specifies which routine the command will be sent to. This must be
  27. // the same id that was returned from the RunSomeRoutine function
  28. // call used to create the routine.
  29. // * |command| - command to send the routine.
  30. // * |include_output| - whether or not the response should include any output
  31. // accumulated from the routine.
  32. //
  33. // The response:
  34. // * |routine_update| - status information for the specified routine. See
  35. // cros_healthd_diagnostics.mojom for the structure.
  36. GetRoutineUpdate@1(int32 id, DiagnosticsRoutineCommandEnum command,
  37. bool include_output)
  38. => (DiagnosticsRoutineUpdate routine_update);
  39. // Requests that the BatteryCapacity routine is created and started on the
  40. // platform. This routine checks the battery's design capacity against inputs
  41. // configured in cros_config. If no configuration data is present in
  42. // cros_config, the routine will fall back to fleet-wide default values of
  43. // [1000, 10000]. The routine will pass iff the design capacity of the battery
  44. // read from the platform is inclusively within these bounds. This routine is
  45. // only available if GetAvailableRoutines returned kBatteryCapactity.
  46. //
  47. // The response:
  48. // * |response| - contains a unique identifier and status for the created
  49. // routine.
  50. RunBatteryCapacityRoutine@2() => (DiagnosticsRunRoutineResponse response);
  51. // Requests that the BatteryHealth routine is created and started on the
  52. // platform. This routine checks the cycle count and percent wear of the
  53. // battery against inputs configured in cros_config. If no configuration data
  54. // is present in cros_config, the routine will fall back to fleet-wide default
  55. // values of 1000 for the maximum allowable cycle count and 50% for maximum
  56. // battery wear percentage allowed. This routine is only available if
  57. // GetAvailableRoutines returned kBatteryHealth.
  58. //
  59. // The response:
  60. // * |response| - contains a unique identifier and status for the created
  61. // routine.
  62. RunBatteryHealthRoutine@3() => (DiagnosticsRunRoutineResponse response);
  63. // Requests that the SmartctlCheck routine is created and started on the
  64. // platform. This routine checks available spare NVMe capacity against the
  65. // threshold. This routine is only available if GetAvailableRoutines returned
  66. // kSmartctlCheck.
  67. //
  68. // The response:
  69. // * |response| - contains a unique identifier and status for the created
  70. // routine.
  71. RunSmartctlCheckRoutine@4() => (DiagnosticsRunRoutineResponse response);
  72. // Requests that the AcPower routine is created and started on the
  73. // platform. This routine checks the status of the power supply, and if
  74. // |expected_power_type| is specified, checks to see that
  75. // |expected_power_type| matches the type reported by the power supply. This
  76. // routine is only available if GetAvailableRoutines returned kAcPower.
  77. //
  78. // The request:
  79. // * |expected_status| - whether or not the adapter is expected to be online.
  80. // * |expected_power_type| - if specified, must match the type of the power
  81. // supply for the routine to succeed.
  82. //
  83. // The response:
  84. // * |response| - contains a unique identifier and status for the created
  85. // routine.
  86. RunAcPowerRoutine@5(DiagnosticsAcPowerStatusEnum expected_status,
  87. string? expected_power_type)
  88. => (DiagnosticsRunRoutineResponse response);
  89. // Requests that the CPU cache routine is created and started on the
  90. // platform. This routine runs the stressapptest to test the CPU caches.
  91. // The routine will pass if the stressapptest returns zero. This routine is
  92. // only available if GetAvailableRoutines returned kCpuCache.
  93. //
  94. // The request:
  95. // * |length_seconds| - length of time, in seconds, to run the CPU cache
  96. // routine. This parameter needs to be strictly greater
  97. // than zero.
  98. //
  99. // The response:
  100. // * |response| - contains a unique identifier and status for the created
  101. // routine.
  102. RunCpuCacheRoutine@6(uint32 length_seconds)
  103. => (DiagnosticsRunRoutineResponse response);
  104. // Requests that the CPU stress routine is created and started on the
  105. // platform. This routine runs the stressapptest to stress test the CPU.
  106. // The routine will pass if the stressapptest returns zero. This routine is
  107. // only available if GetAvailableRoutines returned kCpuStress.
  108. //
  109. // The request:
  110. // * |length_seconds| - length of time, in seconds, to run the CPU stress
  111. // routine. This parameter needs to be strictly greater
  112. // than zero.
  113. //
  114. // The response:
  115. // * |response| - contains a unique identifier and status for the created
  116. // routine.
  117. RunCpuStressRoutine@7(uint32 length_seconds)
  118. => (DiagnosticsRunRoutineResponse response);
  119. // Requests that the FloatingPointAccuracy routine is created and started
  120. // on the platform. This routine executes millions of floating-point
  121. // operations by SSE instructions for a specified amount of time. The routine
  122. // will pass if the result values of the operations and known accurate result
  123. // are the same.
  124. //
  125. // The request:
  126. // * |length_seconds| - length of time, in seconds, to run the floating-point
  127. // routine for. Test will executes millions of
  128. // floating-point operations in length seconds and get
  129. // the result to compare with known accurate results.
  130. // This parameter needs to be strictly greater than zero.
  131. //
  132. // The response:
  133. // * |response| - contains a unique identifier and status for the created
  134. // routine.
  135. RunFloatingPointAccuracyRoutine@8(uint32 length_seconds)
  136. => (DiagnosticsRunRoutineResponse response);
  137. // Requests that the NvmeWearLevel routine is created and started on the
  138. // platform. This routine examines wear level of NVMe against input
  139. // threshold. This routine is only available if GetAvailableRoutines returned
  140. // kNvmeWearLevel.
  141. //
  142. // The request:
  143. // * |wear_level_threshold| - threshold number in percentage which routine
  144. // examines wear level status against.
  145. //
  146. // The response:
  147. // * |response| - contains a unique identifier and status for the created
  148. // routine.
  149. RunNvmeWearLevelRoutine@9(uint32 wear_level_threshold)
  150. => (DiagnosticsRunRoutineResponse response);
  151. // Requests that the NvmeSelfTest routine is created and started on the
  152. // platform. This routine launches the NVMe self-test, a tool to perform
  153. // necessary tests to observe the performance and the parameters. This routine
  154. // is only available if GetAvailableRoutines returned kNvmeSelfTest.
  155. //
  156. // The request:
  157. // * |nvme_self_test_type| - specifies the type of test for short period or
  158. // extended version.
  159. //
  160. // The response:
  161. // * |response| - contains a unique identifier and status for the created
  162. // routine.
  163. RunNvmeSelfTestRoutine@10(DiagnosticsNvmeSelfTestTypeEnum nvme_self_test_type)
  164. => (DiagnosticsRunRoutineResponse response);
  165. // Requests that the DiskRead routine is created and started on the platform.
  166. // The routine will create a test file with md5 checksum, read the test file
  167. // either randomly or linearly, repeatedly for a dedicated duration. If the
  168. // md5 checksum of read back is validated, then the test will pass.
  169. // This routine is only available if GetAvailableRoutines returned kDiskRead.
  170. //
  171. // The request:
  172. // * |type| - type of how disk reading is performed, either linear or random.
  173. //
  174. // * |length_seconds| - length of time, in seconds, to run the DiskRead
  175. // routine for. This parameter needs to be strictly
  176. // greater than zero.
  177. // - TODO(b:167963397) - limit routine duration.
  178. // * |file_size_mb| - test file size, in mega bytes, to test with DiskRead
  179. // routine. Maximum file size is 10 GB.
  180. // The response:
  181. // * |response| - contains a unique identifier and status for the created
  182. // routine.
  183. RunDiskReadRoutine@11(DiagnosticsDiskReadRoutineTypeEnum type,
  184. uint32 length_seconds, uint32 file_size_mb)
  185. => (DiagnosticsRunRoutineResponse response);
  186. // Requests that the PrimeSearch routine is created and started on the
  187. // platform. Calculate prime numbers and verifies the calculation repeatedly
  188. // in a duration. This routine is only available if GetAvailableRoutines
  189. // returned kPrimeSearch.
  190. //
  191. // The request:
  192. // * |length_seconds| - length of time, in seconds, to run the PrimeSearch
  193. // routine for. This parameter needs to be strictly
  194. // greater than zero.
  195. //
  196. // The response:
  197. // * |response| - contains a unique identifier and status for the created
  198. // routine.
  199. RunPrimeSearchRoutine@12(uint32 length_seconds)
  200. => (DiagnosticsRunRoutineResponse response);
  201. // Requests that the BatteryDischarge routine is created and started on the
  202. // platform. This routine checks the battery's discharge rate over a period of
  203. // time. This routine is only available if GetAvailableRoutines returned
  204. // kBatteryDischarge.
  205. //
  206. // The request:
  207. // * |length_seconds| - length of time to run the routine for.
  208. // * |maximum_discharge_percent_allowed| - the routine will fail if the
  209. // battery discharges by more than
  210. // this percentage.
  211. //
  212. // The response:
  213. // * |response| - contains a unique identifier and status for the created
  214. // routine.
  215. RunBatteryDischargeRoutine@13(uint32 length_seconds,
  216. uint32 maximum_discharge_percent_allowed)
  217. => (DiagnosticsRunRoutineResponse response);
  218. // Requests that the BatteryCharge routine is created and started on the
  219. // platform. This routine checks the battery's charge rate over a period of
  220. // time. This routine is only available if GetAvailableRoutines returned
  221. // kBatteryCharge.
  222. //
  223. // The request:
  224. // * |length_seconds| - length of time to run the routine for.
  225. // * |minimum_charge_percent_required| - the routine will fail if the battery
  226. // charges by less than this percentage.
  227. //
  228. // The response:
  229. // * |response| - contains a unique identifier and status for the created
  230. // routine.
  231. RunBatteryChargeRoutine@14(uint32 length_seconds,
  232. uint32 minimum_charge_percent_required)
  233. => (DiagnosticsRunRoutineResponse response);
  234. // Requests that the Memory routine is created and started on the platform.
  235. // This routine checks that the device's memory is working correctly. This
  236. // routine is only available if GetAvailableRoutines returned kMemory.
  237. //
  238. // The response:
  239. // * |response| - contains a unique identifier and status for the created
  240. // routine.
  241. RunMemoryRoutine@15() => (DiagnosticsRunRoutineResponse response);
  242. // Requests that the LanConnectivity routine is created and started on the
  243. // platform. This routine checks whether the device is connected to a LAN.
  244. // This routine is only available if GetAvailableRoutines returned
  245. // kLanConnectivity.
  246. //
  247. // The response:
  248. // * |response| - contains a unique identifier and status for the created
  249. // routine.
  250. RunLanConnectivityRoutine@16() => (DiagnosticsRunRoutineResponse response);
  251. };
  252. // Enumeration of each of the diagnostics routines the platform may support.
  253. //
  254. // Next ID: 16
  255. [Stable, Extensible, RenamedFrom="ash.health.mojom.DiagnosticRoutineEnum"]
  256. enum DiagnosticsRoutineEnum {
  257. [Default] kUnknown = 15,
  258. kBatteryCapacity = 0,
  259. kBatteryHealth = 1,
  260. kSmartctlCheck = 2,
  261. kAcPower = 3,
  262. kCpuCache = 4,
  263. kCpuStress = 5,
  264. kFloatingPointAccuracy = 6,
  265. kNvmeWearLevel = 7,
  266. kNvmeSelfTest = 8,
  267. kDiskRead = 9,
  268. kPrimeSearch = 10,
  269. kBatteryDischarge = 11,
  270. kBatteryCharge = 12,
  271. kMemory = 13,
  272. kLanConnectivity = 14,
  273. };
  274. // Enumeration of each of the possible statuses for a diagnostics routine.
  275. //
  276. // Next ID: 13
  277. [Stable, Extensible, RenamedFrom="ash.health.mojom.DiagnosticRoutineStatusEnum"]
  278. enum DiagnosticsRoutineStatusEnum {
  279. [Default] kUnknown = 12,
  280. kReady = 0, // Routine is ready to start.
  281. kRunning = 1, // Routine is currently running.
  282. kWaiting = 2, // Routine needs user input to continue.
  283. kPassed = 3, // Routine completed and passed.
  284. kFailed = 4, // Routine completed and failed.
  285. kError = 5, // An error prevented the routine from completing.
  286. kCancelled = 6, // Routine was cancelled before completion. A cancelled
  287. // routine's information can still be accessed with a
  288. // GetRoutineUpdateRequest.
  289. kFailedToStart = 7, // Routine could not be created.
  290. kRemoved = 8, // Routine has been removed and is no longer valid.
  291. kCancelling = 9, // Routine is in the process of being cancelled.
  292. kUnsupported = 10, // Routine is not supported by the device.
  293. kNotRun = 11, // Routine was not run because it is currently not applicable.
  294. };
  295. // Enumeration of each of the messages a diagnostics routine can pass back.
  296. // These messages prompt interaction from the user of the routine.
  297. //
  298. // Next ID: 3
  299. [Stable, Extensible,
  300. RenamedFrom="ash.health.mojom.DiagnosticRoutineUserMessageEnum"]
  301. enum DiagnosticsRoutineUserMessageEnum {
  302. [Default] kUnknown = 2,
  303. kUnplugACPower = 0, // The user needs to unplug the AC power cord.
  304. kPlugInACPower = 1, // The user needs to plug in the AC power cord.
  305. };
  306. // Enumeration of the possible commands to send a diagnostics routine.
  307. //
  308. // Next ID: 5
  309. [Stable, Extensible,
  310. RenamedFrom="ash.health.mojom.DiagnosticRoutineCommandEnum"]
  311. enum DiagnosticsRoutineCommandEnum {
  312. [Default] kUnknown = 4,
  313. kContinue = 0, // Resume a routine that is waiting.
  314. kCancel = 1, // Cancelled routines must still be removed before the routine
  315. // is destroyed.
  316. kGetStatus = 2, // Used to get status but not otherwise control a routine.
  317. kRemove = 3, // All routines which started successfully must be removed,
  318. // otherwise they will persist on the system. This makes sure
  319. // the routine is terminated before removing it.
  320. };
  321. // Status fields specific to interactive routines.
  322. //
  323. // Next ID: 1
  324. [Stable, RenamedFrom="ash.health.mojom.InteractiveRoutineUpdate"]
  325. struct DiagnosticsInteractiveRoutineUpdate {
  326. // Request for user action. This message should be localized and displayed to
  327. // the user.
  328. DiagnosticsRoutineUserMessageEnum user_message@0;
  329. };
  330. // Status fields specific to noninteractive routines.
  331. //
  332. // Next ID: 2
  333. [Stable, RenamedFrom="ash.health.mojom.NonInteractiveRoutineUpdate"]
  334. struct DiagnosticsNonInteractiveRoutineUpdate {
  335. // Current status of the routine.
  336. DiagnosticsRoutineStatusEnum status@0;
  337. // More detailed status - for example, if |status| was kError,
  338. // |status_message| would describe the error encountered, like "failed to
  339. // read file."
  340. string status_message@1;
  341. };
  342. // Responses will be either interactive or noninteractive.
  343. [Stable, RenamedFrom="ash.health.mojom.RoutineUpdateUnion"]
  344. union DiagnosticsRoutineUpdateUnion {
  345. DiagnosticsInteractiveRoutineUpdate interactive_update;
  346. DiagnosticsNonInteractiveRoutineUpdate noninteractive_update;
  347. };
  348. // Response type for GetRoutineUpdate.
  349. //
  350. // Next ID: 3
  351. [Stable, RenamedFrom="ash.health.mojom.RoutineUpdate"]
  352. struct DiagnosticsRoutineUpdate {
  353. // Percent complete, must be between 0 and 100, inclusive.
  354. uint32 progress_percent@0;
  355. // Any accumulated output, like logs, from the routine. This field is only
  356. // valid when GetRoutineUpdate (see cros_healthd.mojom) is called with
  357. // include_output = true.
  358. string? output@1;
  359. // Information specific to the type of response - interactive or
  360. // noninteractive.
  361. DiagnosticsRoutineUpdateUnion routine_update_union@2;
  362. };
  363. // Generic return value for a RunSomeRoutine call.
  364. //
  365. // Next ID: 2
  366. [Stable, RenamedFrom="ash.health.mojom.RunRoutineResponse"]
  367. struct DiagnosticsRunRoutineResponse {
  368. // Unique identifier for the newly-created routine. An id of kFailedToStartId
  369. // means that the routine was unable to be created. Can be used in a
  370. // GetRoutineUpdate call to control or get the status of the created routine.
  371. int32 id@0;
  372. // Current status of the newly-created routine. A status of kFailedToStart
  373. // means the routine was unable to be created.
  374. DiagnosticsRoutineStatusEnum status@1;
  375. };
  376. // Enumeration of the possible statuses for a power supply in the AC power
  377. // routine.
  378. //
  379. // Next ID: 3
  380. [Stable, Extensible, RenamedFrom="ash.health.mojom.AcPowerStatusEnum"]
  381. enum DiagnosticsAcPowerStatusEnum {
  382. [Default] kUnknown = 2,
  383. kConnected = 0, // Power supply is connected.
  384. kDisconnected = 1, // Power supply is disconnected.
  385. };
  386. // Enumeration of the self-test type in nvme_self_test routine
  387. //
  388. // Next ID: 3
  389. [Stable, Extensible, RenamedFrom="ash.health.mojom.NvmeSelfTestTypeEnum"]
  390. enum DiagnosticsNvmeSelfTestTypeEnum {
  391. [Default] kUnknown = 2,
  392. kShortSelfTest = 0, // Short time self-test.
  393. kLongSelfTest = 1, // Long time self-test.
  394. };
  395. // Enumeration of the possible DiskRead routine's command type
  396. [Stable, Extensible, RenamedFrom="ash.health.mojom.DiskReadRoutineTypeEnum"]
  397. enum DiagnosticsDiskReadRoutineTypeEnum {
  398. kLinearRead = 0,
  399. kRandomRead = 1,
  400. // Sending this to the underlying cros_healthd will result in an error.
  401. [Default] kUnknown = 2,
  402. };