Skip to content

Commit 25284c5

Browse files
A-Fellow-Comradeigaw
authored andcommitted
Plugin: ScaleFlux Seperating Types
Moving types associated with ScaleFlux into new file sfx-types.h Signed-off-by: Jayden Stenfort <[email protected]>
1 parent b7a7cd0 commit 25284c5

File tree

2 files changed

+190
-137
lines changed

2 files changed

+190
-137
lines changed

plugins/scaleflux/sfx-nvme.c

Lines changed: 1 addition & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#define CREATE_CMD
2727
#include "sfx-nvme.h"
28+
#include "sfx-types.h"
2829

2930
#define SFX_PAGE_SHIFT 12
3031
#define SECTOR_SHIFT 9
@@ -41,93 +42,6 @@
4142
#define MYRTLE_MAJOR_IDX 4
4243
#define MYRTLE_MINOR_IDX 1
4344

44-
enum {
45-
SFX_LOG_LATENCY_READ_STATS = 0xc1,
46-
SFX_LOG_SMART = 0xc2,
47-
SFX_LOG_LATENCY_WRITE_STATS = 0xc3,
48-
SFX_LOG_QUAL = 0xc4,
49-
SFX_LOG_MISMATCHLBA = 0xc5,
50-
SFX_LOG_MEDIA = 0xc6,
51-
SFX_LOG_BBT = 0xc7,
52-
SFX_LOG_IDENTIFY = 0xcc,
53-
SFX_FEAT_ATOMIC = 0x01,
54-
SFX_FEAT_UP_P_CAP = 0xac,
55-
SFX_FEAT_CLR_CARD = 0xdc,
56-
};
57-
58-
enum sfx_nvme_admin_opcode {
59-
nvme_admin_query_cap_info = 0xd3,
60-
nvme_admin_change_cap = 0xd4,
61-
nvme_admin_sfx_set_features = 0xd5,
62-
nvme_admin_sfx_get_features = 0xd6,
63-
};
64-
65-
struct sfx_freespace_ctx {
66-
__u64 free_space;
67-
__u64 phy_cap; /* physical capacity, in unit of sector */
68-
__u64 phy_space; /* physical space considering OP, in unit of sector */
69-
__u64 user_space; /* user required space, in unit of sector*/
70-
__u64 hw_used; /* hw space used in 4K */
71-
__u64 app_written; /* app data written in 4K */
72-
__u64 out_of_space;
73-
__u64 map_unit;
74-
__u64 max_user_space;
75-
__u64 extendible_user_cap_lba_count;
76-
__u64 friendly_change_cap_support;
77-
};
78-
79-
struct nvme_capacity_info {
80-
__u64 lba_sec_sz;
81-
__u64 phy_sec_sz;
82-
__u64 used_space;
83-
__u64 free_space;
84-
};
85-
86-
struct __packed nvme_additional_smart_log_item {
87-
__u8 key;
88-
__u8 _kp[2];
89-
__u8 norm;
90-
__u8 _np;
91-
union __packed {
92-
__u8 raw[6];
93-
struct __packed wear_level {
94-
__le16 min;
95-
__le16 max;
96-
__le16 avg;
97-
} wear_level;
98-
struct __packed thermal_throttle {
99-
__u8 pct;
100-
__u32 count;
101-
} thermal_throttle;
102-
};
103-
__u8 _rp;
104-
};
105-
106-
struct nvme_additional_smart_log {
107-
struct nvme_additional_smart_log_item program_fail_cnt;
108-
struct nvme_additional_smart_log_item erase_fail_cnt;
109-
struct nvme_additional_smart_log_item wear_leveling_cnt;
110-
struct nvme_additional_smart_log_item e2e_err_cnt;
111-
struct nvme_additional_smart_log_item crc_err_cnt;
112-
struct nvme_additional_smart_log_item timed_workload_media_wear;
113-
struct nvme_additional_smart_log_item timed_workload_host_reads;
114-
struct nvme_additional_smart_log_item timed_workload_timer;
115-
struct nvme_additional_smart_log_item thermal_throttle_status;
116-
struct nvme_additional_smart_log_item retry_buffer_overflow_cnt;
117-
struct nvme_additional_smart_log_item pll_lock_loss_cnt;
118-
struct nvme_additional_smart_log_item nand_bytes_written;
119-
struct nvme_additional_smart_log_item host_bytes_written;
120-
struct nvme_additional_smart_log_item raid_recover_cnt; /* errors which can be recovered by RAID */
121-
struct nvme_additional_smart_log_item prog_timeout_cnt;
122-
struct nvme_additional_smart_log_item erase_timeout_cnt;
123-
struct nvme_additional_smart_log_item read_timeout_cnt;
124-
struct nvme_additional_smart_log_item read_ecc_cnt; /* retry cnt */
125-
struct nvme_additional_smart_log_item non_media_crc_err_cnt;
126-
struct nvme_additional_smart_log_item compression_path_err_cnt;
127-
struct nvme_additional_smart_log_item out_of_space_flag;
128-
struct nvme_additional_smart_log_item physical_usage_ratio;
129-
struct nvme_additional_smart_log_item grown_bb; /* grown bad block */
130-
};
13145

13246
int nvme_query_cap(int fd, __u32 nsid, __u32 data_len, void *data)
13347
{
@@ -453,56 +367,6 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd,
453367
return err;
454368
}
455369

456-
struct __packed sfx_lat_stats_vanda {
457-
__u16 maj;
458-
__u16 min;
459-
__u32 bucket_1[32]; /* 0~1ms, step 32us */
460-
__u32 bucket_2[31]; /* 1~32ms, step 1ms */
461-
__u32 bucket_3[31]; /* 32ms~1s, step 32ms */
462-
__u32 bucket_4[1]; /* 1s~2s, specifically 1024ms~2047ms */
463-
__u32 bucket_5[1]; /* 2s~4s, specifically 2048ms~4095ms */
464-
__u32 bucket_6[1]; /* 4s+, specifically 4096ms+ */
465-
};
466-
467-
struct __packed sfx_lat_stats_myrtle {
468-
__u16 maj;
469-
__u16 min;
470-
__u32 bucket_1[64]; /* 0us~63us, step 1us */
471-
__u32 bucket_2[64]; /* 63us~127us, step 1us */
472-
__u32 bucket_3[64]; /* 127us~255us, step 2us */
473-
__u32 bucket_4[64]; /* 255us~510us, step 4us */
474-
__u32 bucket_5[64]; /* 510us~1.02ms step 8us */
475-
__u32 bucket_6[64]; /* 1.02ms~2.04ms step 16us */
476-
__u32 bucket_7[64]; /* 2.04ms~4.08ms step 32us */
477-
__u32 bucket_8[64]; /* 4.08ms~8.16ms step 64us */
478-
__u32 bucket_9[64]; /* 8.16ms~16.32ms step 128us */
479-
__u32 bucket_10[64]; /* 16.32ms~32.64ms step 256us */
480-
__u32 bucket_11[64]; /* 32.64ms~65.28ms step 512us */
481-
__u32 bucket_12[64]; /* 65.28ms~130.56ms step 1.024ms */
482-
__u32 bucket_13[64]; /* 130.56ms~261.12ms step 2.048ms */
483-
__u32 bucket_14[64]; /* 261.12ms~522.24ms step 4.096ms */
484-
__u32 bucket_15[64]; /* 522.24ms~1.04s step 8.192ms */
485-
__u32 bucket_16[64]; /* 1.04s~2.09s step 16.384ms */
486-
__u32 bucket_17[64]; /* 2.09s~4.18s step 32.768ms */
487-
__u32 bucket_18[64]; /* 4.18s~8.36s step 65.536ms */
488-
__u32 bucket_19[64]; /* 8.36s~ step 131.072ms */
489-
__u64 average; /* average latency statistics */
490-
};
491-
492-
493-
struct __packed sfx_lat_status_ver {
494-
__u16 maj;
495-
__u16 min;
496-
};
497-
498-
struct sfx_lat_stats {
499-
union {
500-
struct sfx_lat_status_ver ver;
501-
struct sfx_lat_stats_vanda vanda;
502-
struct sfx_lat_stats_myrtle myrtle;
503-
};
504-
};
505-
506370
static void show_lat_stats_vanda(struct sfx_lat_stats_vanda *stats, int write)
507371
{
508372
int i;

plugins/scaleflux/sfx-types.h

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
/* SPDX-License-Identifier: GPL-2.0-or-later */
2+
3+
#include <inttypes.h>
4+
5+
#define FMT_RED "\x1b[31m"
6+
#define FMT_GREEN "\x1b[32m"
7+
#define FMT_YELLOW "\x1b[33m"
8+
#define FMT_BLUE "\x1b[34m"
9+
#define FMT_RESET "\x1b[0m"
10+
11+
12+
enum {
13+
SFX_LOG_LATENCY_READ_STATS = 0xc1,
14+
SFX_LOG_EXTENDED_HEALTH = 0xc2,
15+
SFX_LOG_LATENCY_WRITE_STATS = 0xc3,
16+
SFX_LOG_QUAL = 0xc4,
17+
SFX_LOG_MISMATCHLBA = 0xc5,
18+
SFX_LOG_MEDIA = 0xc6,
19+
SFX_LOG_BBT = 0xc7,
20+
SFX_LOG_IDENTIFY = 0xcc,
21+
SFX_FEAT_ATOMIC = 0x01,
22+
SFX_FEAT_UP_P_CAP = 0xac,
23+
SFX_LOG_EXTENDED_HEALTH_ALT = 0xd2,
24+
SFX_FEAT_CLR_CARD = 0xdc,
25+
};
26+
27+
enum {
28+
SFX_CRIT_PWR_FAIL_DATA_LOSS = 0x01,
29+
SFX_CRIT_OVER_CAP = 0x02,
30+
SFX_CRIT_RW_LOCK = 0x04,
31+
};
32+
33+
enum sfx_nvme_admin_opcode {
34+
nvme_admin_query_cap_info = 0xd3,
35+
nvme_admin_change_cap = 0xd4,
36+
nvme_admin_sfx_set_features = 0xd5,
37+
nvme_admin_sfx_get_features = 0xd6,
38+
};
39+
40+
struct sfx_freespace_ctx {
41+
__u64 free_space;
42+
__u64 phy_cap; /* physical capacity, in unit of sector */
43+
__u64 phy_space; /* physical space considering OP, in unit of sector */
44+
__u64 user_space; /* user required space, in unit of sector*/
45+
__u64 hw_used; /* hw space used in 4K */
46+
__u64 app_written; /* app data written in 4K */
47+
__u64 out_of_space;
48+
__u64 map_unit;
49+
__u64 max_user_space;
50+
__u64 extendible_user_cap_lba_count;
51+
__u64 friendly_change_cap_support;
52+
};
53+
54+
struct nvme_capacity_info {
55+
__u64 lba_sec_sz;
56+
__u64 phy_sec_sz;
57+
__u64 used_space;
58+
__u64 free_space;
59+
};
60+
61+
struct __packed nvme_additional_smart_log_item {
62+
__u8 key;
63+
__u8 _kp[2];
64+
__u8 norm;
65+
__u8 _np;
66+
union __packed {
67+
__u8 raw[6];
68+
struct __packed wear_level {
69+
__le16 min;
70+
__le16 max;
71+
__le16 avg;
72+
} wear_level;
73+
struct __packed thermal_throttle {
74+
__u8 pct;
75+
__u32 count;
76+
} thermal_throttle;
77+
};
78+
__u8 _rp;
79+
};
80+
81+
struct __packed sfx_lat_stats_vanda {
82+
__u16 maj;
83+
__u16 min;
84+
__u32 bucket_1[32]; /* 0~1ms, step 32us */
85+
__u32 bucket_2[31]; /* 1~32ms, step 1ms */
86+
__u32 bucket_3[31]; /* 32ms~1s, step 32ms */
87+
__u32 bucket_4[1]; /* 1s~2s, specifically 1024ms~2047ms */
88+
__u32 bucket_5[1]; /* 2s~4s, specifically 2048ms~4095ms */
89+
__u32 bucket_6[1]; /* 4s+, specifically 4096ms+ */
90+
};
91+
92+
struct __packed sfx_lat_stats_myrtle {
93+
__u16 maj;
94+
__u16 min;
95+
__u32 bucket_1[64]; /* 0us~63us, step 1us */
96+
__u32 bucket_2[64]; /* 63us~127us, step 1us */
97+
__u32 bucket_3[64]; /* 127us~255us, step 2us */
98+
__u32 bucket_4[64]; /* 255us~510us, step 4us */
99+
__u32 bucket_5[64]; /* 510us~1.02ms step 8us */
100+
__u32 bucket_6[64]; /* 1.02ms~2.04ms step 16us */
101+
__u32 bucket_7[64]; /* 2.04ms~4.08ms step 32us */
102+
__u32 bucket_8[64]; /* 4.08ms~8.16ms step 64us */
103+
__u32 bucket_9[64]; /* 8.16ms~16.32ms step 128us */
104+
__u32 bucket_10[64]; /* 16.32ms~32.64ms step 256us */
105+
__u32 bucket_11[64]; /* 32.64ms~65.28ms step 512us */
106+
__u32 bucket_12[64]; /* 65.28ms~130.56ms step 1.024ms */
107+
__u32 bucket_13[64]; /* 130.56ms~261.12ms step 2.048ms */
108+
__u32 bucket_14[64]; /* 261.12ms~522.24ms step 4.096ms */
109+
__u32 bucket_15[64]; /* 522.24ms~1.04s step 8.192ms */
110+
__u32 bucket_16[64]; /* 1.04s~2.09s step 16.384ms */
111+
__u32 bucket_17[64]; /* 2.09s~4.18s step 32.768ms */
112+
__u32 bucket_18[64]; /* 4.18s~8.36s step 65.536ms */
113+
__u32 bucket_19[64]; /* 8.36s~ step 131.072ms */
114+
__u64 average; /* average latency statistics */
115+
};
116+
117+
118+
struct __packed sfx_lat_status_ver {
119+
__u16 maj;
120+
__u16 min;
121+
};
122+
123+
struct sfx_lat_stats {
124+
union {
125+
struct sfx_lat_status_ver ver;
126+
struct sfx_lat_stats_vanda vanda;
127+
struct sfx_lat_stats_myrtle myrtle;
128+
};
129+
};
130+
131+
struct nvme_additional_smart_log {
132+
struct nvme_additional_smart_log_item program_fail_cnt;
133+
struct nvme_additional_smart_log_item erase_fail_cnt;
134+
struct nvme_additional_smart_log_item wear_leveling_cnt;
135+
struct nvme_additional_smart_log_item e2e_err_cnt;
136+
struct nvme_additional_smart_log_item crc_err_cnt;
137+
struct nvme_additional_smart_log_item timed_workload_media_wear;
138+
struct nvme_additional_smart_log_item timed_workload_host_reads;
139+
struct nvme_additional_smart_log_item timed_workload_timer;
140+
struct nvme_additional_smart_log_item thermal_throttle_status;
141+
struct nvme_additional_smart_log_item retry_buffer_overflow_cnt;
142+
struct nvme_additional_smart_log_item pll_lock_loss_cnt;
143+
struct nvme_additional_smart_log_item nand_bytes_written;
144+
struct nvme_additional_smart_log_item host_bytes_written;
145+
struct nvme_additional_smart_log_item raid_recover_cnt;
146+
/* errors which can be recovered by RAID */
147+
struct nvme_additional_smart_log_item prog_timeout_cnt;
148+
struct nvme_additional_smart_log_item erase_timeout_cnt;
149+
struct nvme_additional_smart_log_item read_timeout_cnt;
150+
struct nvme_additional_smart_log_item read_ecc_cnt; /* retry cnt */
151+
struct nvme_additional_smart_log_item non_media_crc_err_cnt;
152+
struct nvme_additional_smart_log_item compression_path_err_cnt;
153+
struct nvme_additional_smart_log_item out_of_space_flag;
154+
struct nvme_additional_smart_log_item physical_usage_ratio;
155+
struct nvme_additional_smart_log_item grown_bb; /* grown bad block */
156+
};
157+
158+
159+
struct __packed extended_health_info_myrtle {
160+
__u32 soft_read_recoverable_errs;
161+
__u32 flash_die_raid_recoverable_errs;
162+
__u32 pcie_rx_correct_errs;
163+
__u32 pcie_rx_uncorrect_errs;
164+
__u32 data_read_from_flash;
165+
__u32 data_write_to_flash;
166+
__u32 temp_throttle_info;// bit0: 0--> normal, 1 --> throttled
167+
// bit 31:1 --> throttle events count, resets on power cycle
168+
__u32 power_consumption;
169+
__u32 pf_bbd_read_cnt;
170+
__u32 sfx_critical_warning;
171+
__u32 raid_recovery_total_count;
172+
__u32 rsvd;
173+
__u8 opn[32];
174+
__u64 total_physical_capability;
175+
__u64 free_physical_capability;
176+
__u32 physical_usage_ratio;
177+
__u32 comp_ratio;
178+
__u32 otp_rsa_en;
179+
__u32 power_mw_consumption;
180+
__u32 io_speed;
181+
__u64 max_formatted_capability;
182+
__u32 map_unit;
183+
__u64 extendible_cap_lbacount;
184+
__u32 friendly_changecap_support;
185+
__u32 rvd1;
186+
__u64 cur_formatted_capability;
187+
};
188+
189+

0 commit comments

Comments
 (0)