-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathnvme_zns.h
226 lines (196 loc) · 4.42 KB
/
nvme_zns.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
// SPDX-License-Identifier: GPL-2.0-only
#ifndef _NVME_ZNS_H
#define _NVME_ZNS_H
#include "nvme.h"
/* admin command */
struct nvme_id_zns_ctrl {
__u8 zasl; // zone append size limit
__u8 rsvd1[4095];
};
struct nvme_zns_lbaf {
__le64 zsze;
__u8 zdes;
__u8 resv[7];
};
struct nvme_id_zns_ns {
__u16 zoc; // zone operation characteristics
__u16 ozcs; // optional zoned command support
// (read across zone boundaries, ZRWA)
__le32 mar; // maximum active resources
__le32 mor; // maximum open resources
__le32 rrl;
__le32 frl;
__le32 rsv1[6];
__le32 numzrwa; // Maximum ZRWA Resources
__le16 zrwafg; // zrwa flush granularity (lbas)
__le16 zrwasz; // zrwa size (lbas)
__u8 zrwacap; // zrwa capability (bit 0: explicit zrwa flush)
__u8 rsv2[2763];
struct nvme_zns_lbaf lbaf[16];
__u8 rsv3[768];
__u8 vs[256];
};
enum {
NVME_SC_ZNS_INVALID_ZONE_OPERATION = ((NVME_SCT_CMD_SPECIFIC_STATUS << 8) | 0xB6),
NVME_SC_ZNS_ZRWA_RSRC_UNAVAIL,
NVME_SC_ZNS_ERR_BOUNDARY,
NVME_SC_ZNS_ERR_FULL,
NVME_SC_ZNS_ERR_READ_ONLY,
NVME_SC_ZNS_ERR_OFFLINE,
NVME_SC_ZNS_INVALID_WRITE,
NVME_SC_ZNS_NO_ACTIVE_ZONE,
NVME_SC_ZNS_NO_OPEN_ZONE,
NVME_SC_ZNS_INVALID_TRANSITION
};
enum {
OZCS_READ_ACROSS_ZONE = (1 << 0),
OZCS_ZRWA = (1 << 1),
};
enum {
ZRWACAP_EXPFLUSHSUP = (1 << 0),
};
enum { ZONE_TYPE_SEQ_WRITE_REQUIRED = 0x2 };
enum zone_state {
ZONE_STATE_EMPTY = 0x1,
ZONE_STATE_OPENED_IMPL = 0x2,
ZONE_STATE_OPENED_EXPL = 0x3,
ZONE_STATE_CLOSED = 0x4,
ZONE_STATE_READ_ONLY = 0xD,
ZONE_STATE_FULL = 0xE,
ZONE_STATE_OFFLINE = 0xF
};
enum zone_resource_type { ACTIVE_ZONE, OPEN_ZONE, ZRWA_ZONE, RES_TYPE_COUNT };
struct zone_descriptor {
__u8 type : 4;
__u8 : 4;
__u8 : 4;
__u8 state : 4;
union {
__u8 za; // zone attributes
struct {
__u8 zfc : 1; // zone finished by controller
__u8 fzr : 1; // finish zone recommended
__u8 rzr : 1; // reset zone recommended
__u8 zrwav : 1; //zone random write area valid
__u8 : 3;
__u8 zdef : 1; // zone descriptor extension valid
};
};
union {
__u8 zai; // zone attributes information
struct {
__u8 fzrtl : 2; // finish zone recommnded time limit
__u8 rzrtl : 2; // reset zone recommended time limit
__u8 : 4;
};
};
__u32 reserved;
__u64 zone_capacity;
__u64 zslba; // zone start logical block address
__u64 wp;
__u32 rsvd[8];
};
struct zone_report {
__u64 nr_zones;
__u64 rsvd[7];
//several zone descriptors..
struct zone_descriptor zd[1];
};
// zone management receive command
struct nvme_zone_mgmt_recv {
__u8 opcode;
__u8 flags;
__u16 command_id;
__le32 nsid;
__le32 cdw2[2];
__le64 metadata;
__le64 prp1;
__le64 prp2;
__le64 slba; // DW 10, 11
__le32 nr_dw; // DW 12
union {
__le32 DW13;
struct {
__u8 zra; // zone recive action 00h : report zones, 01h : extended report zones
__u8 zra_specific_field;
__u16 zra_specific_features : 1;
__u16 reserved : 15;
};
};
__le32 rsvd[3];
};
enum zone_send_action {
ZSA_CLOSE_ZONE = 0x1,
ZSA_FINISH_ZONE,
ZSA_OPEN_ZONE,
ZSA_RESET_ZONE,
ZSA_OFFLINE_ZONE,
ZSA_SET_ZONE_DESC_EXT = 0x10,
ZSA_FLUSH_EXPL_ZRWA = 0x11,
};
// zone management send command
struct nvme_zone_mgmt_send {
__u8 opcode;
__u8 flags;
__u16 command_id;
__le32 nsid;
__le32 cdw2[2];
__le64 metadata;
__le64 prp1;
__le64 prp2;
__le64 slba; // DW 10, 11
__le32 reserved; // DW 12 Not used.
union {
__le32 DW13;
struct {
__u32 zsa : 8; // zone send action
// 01h : close, 02h : finish
// 03h : open, 04h: reset
// 05h:offline, 10h:set zone descriptor extension
__u32 select_all : 1; // 1 : SLBA field is ignored,
__u32 zsaso : 1; // Zone send action specific option
__u32 : 22;
};
};
__le32 rsvd[3];
};
struct nvme_zone_append {
__u8 opcode;
__u8 flags;
__u16 command_id;
__le32 nsid;
__le32 cdw2[2];
__le64 metadata;
__le64 prp1;
__le64 prp2;
__le64 slba; // DW 10, 11
union {
__le32 DW12;
struct {
__le32 nr_lba : 16;
__le32 : 4;
__le32 dtype : 4; // directive type
__le32 stc : 1; // storage tag check
__le32 piremap : 1; //protection information remap
__le32 printfo : 4; //protection information field
__le32 fua : 1; ///force unit access
__le32 lr : 1; //limited retry
};
};
union {
__le32 DW13;
struct {
__le32 : 16;
__le32 dspec : 16; // directive specific
};
};
__le32 DW14;
union {
__le32 DW15;
struct {
__le32 lbat : 16; //logical block application tag
__le32 lbatm : 16; // logical block application tag mask
};
};
};
#endif