1 /**
2  * collectd - src/intel-nvme.h
3  * MIT License
4  *
5  * Copyright (C) 2020  Intel Corporation. All rights reserved.
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a
8  * copy of this software and associated documentation files (the "Software"),
9  * to deal in the Software without restriction, including without limitation
10  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11  * and/or sell copies of the Software, and to permit persons to whom the
12  * Software is furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in
15  * all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23  * DEALINGS IN THE SOFTWARE.
24  *
25  * Authors:
26  *   Bartlomiej Kotlowski <bartlomiej.kotlowski@intel.com>
27  * **/
28 
29 #include <linux/types.h>
30 
31 #ifdef __CHECKER__
32 #define __force __attribute__((force))
33 #else
34 #define __force
35 #endif
36 
37 #define NVME_SMART_INTEL_CDW10 0x008000ca
38 #define INTEL_VENDOR_ID 0x8086
39 
40 struct __attribute__((packed)) nvme_additional_smart_log_item {
41   __u8 key;
42   __u8 _kp[2];
43   __u8 norm;
44   __u8 _np;
45   union __attribute__((packed)) {
46     __u8 raw[6];
47     struct __attribute__((packed)) wear_level {
48       __le16 min;
49       __le16 max;
50       __le16 avg;
51     } wear_level;
52     struct __attribute__((packed)) thermal_throttle {
53       __u8 pct;
54       __u32 count;
55     } thermal_throttle;
56   };
57   __u8 _rp;
58 };
59 
60 struct nvme_additional_smart_log {
61   struct nvme_additional_smart_log_item program_fail_cnt;
62   struct nvme_additional_smart_log_item erase_fail_cnt;
63   struct nvme_additional_smart_log_item wear_leveling_cnt;
64   struct nvme_additional_smart_log_item e2e_err_cnt;
65   struct nvme_additional_smart_log_item crc_err_cnt;
66   struct nvme_additional_smart_log_item timed_workload_media_wear;
67   struct nvme_additional_smart_log_item timed_workload_host_reads;
68   struct nvme_additional_smart_log_item timed_workload_timer;
69   struct nvme_additional_smart_log_item thermal_throttle_status;
70   struct nvme_additional_smart_log_item retry_buffer_overflow_cnt;
71   struct nvme_additional_smart_log_item pll_lock_loss_cnt;
72   struct nvme_additional_smart_log_item nand_bytes_written;
73   struct nvme_additional_smart_log_item host_bytes_written;
74 };
75