Debian Codegraph @

src/nvme/ioctl.h

raw
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 /*
3 * This file is part of libnvme.
4 * Copyright (c) 2020 Western Digital Corporation or its affiliates.
5 *
6 * Authors: Keith Busch <[email protected]>
7 * Chaitanya Kulkarni <[email protected]>
8 */
9
10 #ifndef _LIBNVME_IOCTL_H
11 #define _LIBNVME_IOCTL_H
12
13 #include <errno.h>
14 #include <stddef.h>
15 #include <sys/ioctl.h>
16
17 #include <nvme/types.h>
18 #include <nvme/api-types.h>
19
20 /*
21 * We can not always count on the kernel UAPI being installed. Use the same
22 * 'ifdef' guard to avoid double definitions just in case.
23 */
24 #ifndef _UAPI_LINUX_NVME_IOCTL_H
25 #define _UAPI_LINUX_NVME_IOCTL_H
26
27 #ifndef _LINUX_NVME_IOCTL_H
28 #define _LINUX_NVME_IOCTL_H
29
30 /**
31 * DOC: ioctl.h
32 *
33 * Linux NVMe ioctl interface functions
34 */
35
36 /* '0' is interpreted by the kernel to mean 'apply the default timeout' */
37 #define NVME_DEFAULT_IOCTL_TIMEOUT 0
38
39 /*
40 * 4k is the smallest possible transfer unit, so restricting to 4k
41 * avoids having to check the MDTS value of the controller.
42 */
43 #define NVME_LOG_PAGE_PDU_SIZE 4096
44
45 /*
46 * should not exceed CAP.MQES, 16 is rational for most ssd
47 */
48 #define NVME_URING_ENTRIES 16
49
50 /**
51 * struct nvme_passthru_cmd - nvme passthrough command structure
52 * @opcode: Operation code, see &enum nvme_io_opcodes and &enum nvme_admin_opcodes
53 * @flags: Not supported: intended for command flags (eg: SGL, FUSE)
54 * @rsvd1: Reserved for future use
55 * @nsid: Namespace Identifier, or Fabrics type
56 * @cdw2: Command Dword 2 (no spec defined use)
57 * @cdw3: Command Dword 3 (no spec defined use)
58 * @metadata: User space address to metadata buffer (NULL if not used)
59 * @addr: User space address to data buffer (NULL if not used)
60 * @metadata_len: Metadata buffer transfer length
61 * @data_len: Data buffer transfer length
62 * @cdw10: Command Dword 10 (command specific)
63 * @cdw11: Command Dword 11 (command specific)
64 * @cdw12: Command Dword 12 (command specific)
65 * @cdw13: Command Dword 13 (command specific)
66 * @cdw14: Command Dword 14 (command specific)
67 * @cdw15: Command Dword 15 (command specific)
68 * @timeout_ms: If non-zero, overrides system default timeout in milliseconds
69 * @result: Set on completion to the command's CQE DWORD 0 controller response
70 */
71 struct nvme_passthru_cmd {
72 __u8 opcode;
73 __u8 flags;
74 __u16 rsvd1;
75 __u32 nsid;
76 __u32 cdw2;
77 __u32 cdw3;
78 __u64 metadata;
79 __u64 addr;
80 __u32 metadata_len;
81 __u32 data_len;
82 __u32 cdw10;
83 __u32 cdw11;
84 __u32 cdw12;
85 __u32 cdw13;
86 __u32 cdw14;
87 __u32 cdw15;
88 __u32 timeout_ms;
89 __u32 result;
90 };
91
92 /**
93 * struct nvme_passthru_cmd64 - 64-bit nvme passthrough command structure
94 * @opcode: Operation code, see &enum nvme_io_opcodes and &enum nvme_admin_opcodes
95 * @flags: Not supported: intended for command flags (eg: SGL, FUSE)
96 * @rsvd1: Reserved for future use
97 * @nsid: Namespace Identifier, or Fabrics type
98 * @cdw2: Command Dword 2 (no spec defined use)
99 * @cdw3: Command Dword 3 (no spec defined use)
100 * @metadata: User space address to metadata buffer (NULL if not used)
101 * @addr: User space address to data buffer (NULL if not used)
102 * @metadata_len: Metadata buffer transfer length
103 * @data_len: Data buffer transfer length
104 * @cdw10: Command Dword 10 (command specific)
105 * @cdw11: Command Dword 11 (command specific)
106 * @cdw12: Command Dword 12 (command specific)
107 * @cdw13: Command Dword 13 (command specific)
108 * @cdw14: Command Dword 14 (command specific)
109 * @cdw15: Command Dword 15 (command specific)
110 * @timeout_ms: If non-zero, overrides system default timeout in milliseconds
111 * @rsvd2: Reserved for future use (and fills an implicit struct pad
112 * @result: Set on completion to the command's CQE DWORD 0-1 controller response
113 */
114 struct nvme_passthru_cmd64 {
115 __u8 opcode;
116 __u8 flags;
117 __u16 rsvd1;
118 __u32 nsid;
119 __u32 cdw2;
120 __u32 cdw3;
121 __u64 metadata;
122 __u64 addr;
123 __u32 metadata_len;
124 __u32 data_len;
125 __u32 cdw10;
126 __u32 cdw11;
127 __u32 cdw12;
128 __u32 cdw13;
129 __u32 cdw14;
130 __u32 cdw15;
131 __u32 timeout_ms;
132 __u32 rsvd2;
133 __u64 result;
134 };
135
136 /**
137 * struct nvme_uring_cmd - nvme uring command structure
138 * @opcode: Operation code, see &enum nvme_io_opcodes and &enum nvme_admin_opcodes
139 * @flags: Not supported: intended for command flags (eg: SGL, FUSE)
140 * @rsvd1: Reserved for future use
141 * @nsid: Namespace Identifier, or Fabrics type
142 * @cdw2: Command Dword 2 (no spec defined use)
143 * @cdw3: Command Dword 3 (no spec defined use)
144 * @metadata: User space address to metadata buffer (NULL if not used)
145 * @addr: User space address to data buffer (NULL if not used)
146 * @metadata_len: Metadata buffer transfer length
147 * @data_len: Data buffer transfer length
148 * @cdw10: Command Dword 10 (command specific)
149 * @cdw11: Command Dword 11 (command specific)
150 * @cdw12: Command Dword 12 (command specific)
151 * @cdw13: Command Dword 13 (command specific)
152 * @cdw14: Command Dword 14 (command specific)
153 * @cdw15: Command Dword 15 (command specific)
154 * @timeout_ms: If non-zero, overrides system default timeout in milliseconds
155 * @rsvd2: Reserved for future use (and fills an implicit struct pad
156 */
157 struct nvme_uring_cmd {
158 __u8 opcode;
159 __u8 flags;
160 __u16 rsvd1;
161 __u32 nsid;
162 __u32 cdw2;
163 __u32 cdw3;
164 __u64 metadata;
165 __u64 addr;
166 __u32 metadata_len;
167 __u32 data_len;
168 __u32 cdw10;
169 __u32 cdw11;
170 __u32 cdw12;
171 __u32 cdw13;
172 __u32 cdw14;
173 __u32 cdw15;
174 __u32 timeout_ms;
175 __u32 rsvd2;
176 };
177
178 #define NVME_IOCTL_ID _IO('N', 0x40)
179 #define NVME_IOCTL_RESET _IO('N', 0x44)
180 #define NVME_IOCTL_SUBSYS_RESET _IO('N', 0x45)
181 #define NVME_IOCTL_RESCAN _IO('N', 0x46)
182 #define NVME_IOCTL_ADMIN_CMD _IOWR('N', 0x41, struct nvme_passthru_cmd)
183 #define NVME_IOCTL_IO_CMD _IOWR('N', 0x43, struct nvme_passthru_cmd)
184 #define NVME_IOCTL_ADMIN64_CMD _IOWR('N', 0x47, struct nvme_passthru_cmd64)
185 #define NVME_IOCTL_IO64_CMD _IOWR('N', 0x48, struct nvme_passthru_cmd64)
186
187 /* io_uring async commands: */
188 #define NVME_URING_CMD_IO _IOWR('N', 0x80, struct nvme_uring_cmd)
189 #define NVME_URING_CMD_IO_VEC _IOWR('N', 0x81, struct nvme_uring_cmd)
190 #define NVME_URING_CMD_ADMIN _IOWR('N', 0x82, struct nvme_uring_cmd)
191 #define NVME_URING_CMD_ADMIN_VEC _IOWR('N', 0x83, struct nvme_uring_cmd)
192
193 #endif /* _UAPI_LINUX_NVME_IOCTL_H */
194
195 #endif /* _LINUX_NVME_IOCTL_H */
196
197 /**
198 * sizeof_args - Helper function used to determine structure sizes
199 * @type: Argument structure type
200 * @member: Member inside the type
201 * @align: Alignment information
202 */
203 #define sizeof_args(type, member, align) \
204 ({ \
205 type s; \
206 size_t t = offsetof(type, member) + sizeof(s.member); \
207 size_t p = (sizeof(align) - (t % sizeof(align))) % sizeof(align); \
208 t + p; \
209 })
210
211 enum nvme_cmd_dword_fields {
212 NVME_DEVICE_SELF_TEST_CDW10_STC_SHIFT = 0,
213 NVME_DEVICE_SELF_TEST_CDW10_STC_MASK = 0xf,
214 NVME_DIRECTIVE_CDW11_DOPER_SHIFT = 0,
215 NVME_DIRECTIVE_CDW11_DTYPE_SHIFT = 8,
216 NVME_DIRECTIVE_CDW11_DPSEC_SHIFT = 16,
217 NVME_DIRECTIVE_CDW11_DOPER_MASK = 0xff,
218 NVME_DIRECTIVE_CDW11_DTYPE_MASK = 0xff,
219 NVME_DIRECTIVE_CDW11_DPSEC_MASK = 0xffff,
220 NVME_DIRECTIVE_SEND_IDENTIFY_CDW12_ENDIR_SHIFT = 0,
221 NVME_DIRECTIVE_SEND_IDENTIFY_CDW12_DTYPE_SHIFT = 1,
222 NVME_DIRECTIVE_SEND_IDENTIFY_CDW12_ENDIR_MASK = 0x1,
223 NVME_DIRECTIVE_SEND_IDENTIFY_CDW12_DTYPE_MASK = 0x1,
224 NVME_FW_COMMIT_CDW10_FS_SHIFT = 0,
225 NVME_FW_COMMIT_CDW10_CA_SHIFT = 3,
226 NVME_FW_COMMIT_CDW10_BPID_SHIFT = 31,
227 NVME_FW_COMMIT_CDW10_FS_MASK = 0x7,
228 NVME_FW_COMMIT_CDW10_CA_MASK = 0x7,
229 NVME_FW_COMMIT_CDW10_BPID_MASK = 0x1,
230 NVME_GET_FEATURES_CDW10_SEL_SHIFT = 8,
231 NVME_GET_FEATURES_CDW10_SEL_MASK = 0x7,
232 NVME_SET_FEATURES_CDW10_SAVE_SHIFT = 31,
233 NVME_SET_FEATURES_CDW10_SAVE_MASK = 0x1,
234 NVME_FEATURES_CDW10_FID_SHIFT = 0,
235 NVME_FEATURES_CDW14_UUID_SHIFT = 0,
236 NVME_FEATURES_CDW10_FID_MASK = 0xff,
237 NVME_FEATURES_CDW14_UUID_MASK = 0x7f,
238 NVME_LOG_CDW10_LID_SHIFT = 0,
239 NVME_LOG_CDW10_LSP_SHIFT = 8,
240 NVME_LOG_CDW10_RAE_SHIFT = 15,
241 NVME_LOG_CDW10_NUMDL_SHIFT = 16,
242 NVME_LOG_CDW11_NUMDU_SHIFT = 0,
243 NVME_LOG_CDW11_LSI_SHIFT = 16,
244 NVME_LOG_CDW14_UUID_SHIFT = 0,
245 NVME_LOG_CDW14_CSI_SHIFT = 24,
246 NVME_LOG_CDW14_OT_SHIFT = 23,
247 NVME_LOG_CDW10_LID_MASK = 0xff,
248 NVME_LOG_CDW10_LSP_MASK = 0x7f,
249 NVME_LOG_CDW10_RAE_MASK = 0x1,
250 NVME_LOG_CDW10_NUMDL_MASK = 0xffff,
251 NVME_LOG_CDW11_NUMDU_MASK = 0xffff,
252 NVME_LOG_CDW11_LSI_MASK = 0xffff,
253 NVME_LOG_CDW14_UUID_MASK = 0x7f,
254 NVME_LOG_CDW14_CSI_MASK = 0xff,
255 NVME_LOG_CDW14_OT_MASK = 0x1,
256 NVME_IDENTIFY_CDW10_CNS_SHIFT = 0,
257 NVME_IDENTIFY_CDW10_CNTID_SHIFT = 16,
258 NVME_IDENTIFY_CDW11_CNSSPECID_SHIFT = 0,
259 NVME_IDENTIFY_CDW14_UUID_SHIFT = 0,
260 NVME_IDENTIFY_CDW11_CSI_SHIFT = 24,
261 NVME_IDENTIFY_CDW10_CNS_MASK = 0xff,
262 NVME_IDENTIFY_CDW10_CNTID_MASK = 0xffff,
263 NVME_IDENTIFY_CDW11_CNSSPECID_MASK = 0xffff,
264 NVME_IDENTIFY_CDW14_UUID_MASK = 0x7f,
265 NVME_IDENTIFY_CDW11_CSI_MASK = 0xff,
266 NVME_NAMESPACE_ATTACH_CDW10_SEL_SHIFT = 0,
267 NVME_NAMESPACE_ATTACH_CDW10_SEL_MASK = 0xf,
268 NVME_NAMESPACE_MGMT_CDW10_SEL_SHIFT = 0,
269 NVME_NAMESPACE_MGMT_CDW10_SEL_MASK = 0xf,
270 NVME_NAMESPACE_MGMT_CDW11_CSI_SHIFT = 24,
271 NVME_NAMESPACE_MGMT_CDW11_CSI_MASK = 0xff,
272 NVME_VIRT_MGMT_CDW10_ACT_SHIFT = 0,
273 NVME_VIRT_MGMT_CDW10_RT_SHIFT = 8,
274 NVME_VIRT_MGMT_CDW10_CNTLID_SHIFT = 16,
275 NVME_VIRT_MGMT_CDW11_NR_SHIFT = 0,
276 NVME_VIRT_MGMT_CDW10_ACT_MASK = 0xf,
277 NVME_VIRT_MGMT_CDW10_RT_MASK = 0x7,
278 NVME_VIRT_MGMT_CDW10_CNTLID_MASK = 0xffff,
279 NVME_VIRT_MGMT_CDW11_NR_MASK = 0xffff,
280 NVME_FORMAT_CDW10_LBAF_SHIFT = 0,
281 NVME_FORMAT_CDW10_MSET_SHIFT = 4,
282 NVME_FORMAT_CDW10_PI_SHIFT = 5,
283 NVME_FORMAT_CDW10_PIL_SHIFT = 8,
284 NVME_FORMAT_CDW10_SES_SHIFT = 9,
285 NVME_FORMAT_CDW10_LBAFU_SHIFT = 12,
286 NVME_FORMAT_CDW10_LBAF_MASK = 0xf,
287 NVME_FORMAT_CDW10_MSET_MASK = 0x1,
288 NVME_FORMAT_CDW10_PI_MASK = 0x7,
289 NVME_FORMAT_CDW10_PIL_MASK = 0x1,
290 NVME_FORMAT_CDW10_SES_MASK = 0x7,
291 NVME_FORMAT_CDW10_LBAFU_MASK = 0x3,
292 NVME_SANITIZE_CDW10_SANACT_SHIFT = 0,
293 NVME_SANITIZE_CDW10_AUSE_SHIFT = 3,
294 NVME_SANITIZE_CDW10_OWPASS_SHIFT = 4,
295 NVME_SANITIZE_CDW10_OIPBP_SHIFT = 8,
296 NVME_SANITIZE_CDW10_NODAS_SHIFT = 9,
297 NVME_SANITIZE_CDW10_EMVS_SHIFT = 10,
298 NVME_SANITIZE_CDW10_SANACT_MASK = 0x7,
299 NVME_SANITIZE_CDW10_AUSE_MASK = 0x1,
300 NVME_SANITIZE_CDW10_OWPASS_MASK = 0xf,
301 NVME_SANITIZE_CDW10_OIPBP_MASK = 0x1,
302 NVME_SANITIZE_CDW10_NODAS_MASK = 0x1,
303 NVME_SANITIZE_CDW10_EMVS_MASK = 0x1,
304 NVME_SECURITY_NSSF_SHIFT = 0,
305 NVME_SECURITY_SPSP0_SHIFT = 8,
306 NVME_SECURITY_SPSP1_SHIFT = 16,
307 NVME_SECURITY_SECP_SHIFT = 24,
308 NVME_SECURITY_NSSF_MASK = 0xff,
309 NVME_SECURITY_SPSP0_MASK = 0xff,
310 NVME_SECURITY_SPSP1_MASK = 0xff,
311 NVME_SECURITY_SECP_MASK = 0xffff,
312 NVME_GET_LBA_STATUS_CDW13_RL_SHIFT = 0,
313 NVME_GET_LBA_STATUS_CDW13_ATYPE_SHIFT = 24,
314 NVME_GET_LBA_STATUS_CDW13_RL_MASK = 0xffff,
315 NVME_GET_LBA_STATUS_CDW13_ATYPE_MASK = 0xff,
316 NVME_ZNS_MGMT_SEND_ZSASO_SHIFT = 9,
317 NVME_ZNS_MGMT_SEND_ZSASO_MASK = 0x1,
318 NVME_ZNS_MGMT_SEND_SEL_SHIFT = 8,
319 NVME_ZNS_MGMT_SEND_SEL_MASK = 0x1,
320 NVME_ZNS_MGMT_SEND_ZSA_SHIFT = 0,
321 NVME_ZNS_MGMT_SEND_ZSA_MASK = 0xff,
322 NVME_ZNS_MGMT_RECV_ZRA_SHIFT = 0,
323 NVME_ZNS_MGMT_RECV_ZRA_MASK = 0xff,
324 NVME_ZNS_MGMT_RECV_ZRASF_SHIFT = 8,
325 NVME_ZNS_MGMT_RECV_ZRASF_MASK = 0xff,
326 NVME_ZNS_MGMT_RECV_ZRAS_FEAT_SHIFT = 16,
327 NVME_ZNS_MGMT_RECV_ZRAS_FEAT_MASK = 0x1,
328 NVME_DIM_TAS_SHIFT = 0,
329 NVME_DIM_TAS_MASK = 0xF,
330 };
331
332 /**
333 * nvme_submit_admin_passthru64() - Submit a 64-bit nvme passthrough admin
334 * command
335 * @fd: File descriptor of nvme device
336 * @cmd: The nvme admin command to send
337 * @result: Optional field to return the result from the CQE DW0-1
338 *
339 * Uses NVME_IOCTL_ADMIN64_CMD for the ioctl request.
340 *
341 * Return: The nvme command status if a response was received (see
342 * &enum nvme_status_field) or -1 with errno set otherwise.
343 */
344 int nvme_submit_admin_passthru64(int fd, struct nvme_passthru_cmd64 *cmd,
345 __u64 *result);
346
347 /**
348 * nvme_admin_passthru64() - Submit a 64-bit nvme passthrough command
349 * @fd: File descriptor of nvme device
350 * @opcode: The nvme io command to send
351 * @flags: NVMe command flags (not used)
352 * @rsvd: Reserved for future use
353 * @nsid: Namespace identifier
354 * @cdw2: Command dword 2
355 * @cdw3: Command dword 3
356 * @cdw10: Command dword 10
357 * @cdw11: Command dword 11
358 * @cdw12: Command dword 12
359 * @cdw13: Command dword 13
360 * @cdw14: Command dword 14
361 * @cdw15: Command dword 15
362 * @data_len: Length of the data transferred in this command in bytes
363 * @data: Pointer to user address of the data buffer
364 * @metadata_len:Length of metadata transferred in this command
365 * @metadata: Pointer to user address of the metadata buffer
366 * @timeout_ms: How long the kernel waits for the command to complete
367 * @result: Optional field to return the result from the CQE dword 0
368 *
369 * Parameterized form of nvme_submit_admin_passthru64(). This sets up and
370 * submits a &struct nvme_passthru_cmd64.
371 *
372 * Known values for @opcode are defined in &enum nvme_admin_opcode.
373 *
374 * Return: The nvme command status if a response was received (see
375 * &enum nvme_status_field) or -1 with errno set otherwise.
376 */
377 int nvme_admin_passthru64(int fd, __u8 opcode, __u8 flags, __u16 rsvd,
378 __u32 nsid, __u32 cdw2, __u32 cdw3, __u32 cdw10, __u32 cdw11,
379 __u32 cdw12, __u32 cdw13, __u32 cdw14, __u32 cdw15,
380 __u32 data_len, void *data, __u32 metadata_len, void *metadata,
381 __u32 timeout_ms, __u64 *result);
382
383 /**
384 * nvme_submit_admin_passthru() - Submit an nvme passthrough admin command
385 * @fd: File descriptor of nvme device
386 * @cmd: The nvme admin command to send
387 * @result: Optional field to return the result from the CQE DW0
388 *
389 * Uses NVME_IOCTL_ADMIN_CMD for the ioctl request.
390 *
391 * Return: The nvme command status if a response was received (see
392 * &enum nvme_status_field) or -1 with errno set otherwise.
393 */
394 int nvme_submit_admin_passthru(int fd, struct nvme_passthru_cmd *cmd,
395 __u32 *result);
396
397 /**
398 * nvme_admin_passthru() - Submit an nvme passthrough command
399 * @fd: File descriptor of nvme device
400 * @opcode: The nvme io command to send
401 * @flags: NVMe command flags (not used)
402 * @rsvd: Reserved for future use
403 * @nsid: Namespace identifier
404 * @cdw2: Command dword 2
405 * @cdw3: Command dword 3
406 * @cdw10: Command dword 10
407 * @cdw11: Command dword 11
408 * @cdw12: Command dword 12
409 * @cdw13: Command dword 13
410 * @cdw14: Command dword 14
411 * @cdw15: Command dword 15
412 * @data_len: Length of the data transferred in this command in bytes
413 * @data: Pointer to user address of the data buffer
414 * @metadata_len:Length of metadata transferred in this command
415 * @metadata: Pointer to user address of the metadata buffer
416 * @timeout_ms: How long the kernel waits for the command to complete
417 * @result: Optional field to return the result from the CQE dword 0
418 *
419 * Parameterized form of nvme_submit_admin_passthru(). This sets up and
420 * submits a &struct nvme_passthru_cmd.
421 *
422 * Known values for @opcode are defined in &enum nvme_admin_opcode.
423 *
424 * Return: The nvme command status if a response was received (see
425 * &enum nvme_status_field) or -1 with errno set otherwise.
426 */
427 int nvme_admin_passthru(int fd, __u8 opcode, __u8 flags, __u16 rsvd,
428 __u32 nsid, __u32 cdw2, __u32 cdw3, __u32 cdw10, __u32 cdw11,
429 __u32 cdw12, __u32 cdw13, __u32 cdw14, __u32 cdw15,
430 __u32 data_len, void *data, __u32 metadata_len, void *metadata,
431 __u32 timeout_ms, __u32 *result);
432
433 /**
434 * nvme_submit_io_passthru64() - Submit a 64-bit nvme passthrough command
435 * @fd: File descriptor of nvme device
436 * @cmd: The nvme io command to send
437 * @result: Optional field to return the result from the CQE DW0-1
438 *
439 * Uses NVME_IOCTL_IO64_CMD for the ioctl request.
440 *
441 * Return: The nvme command status if a response was received (see
442 * &enum nvme_status_field) or -1 with errno set otherwise.
443 */
444 int nvme_submit_io_passthru64(int fd, struct nvme_passthru_cmd64 *cmd,
445 __u64 *result);
446
447 /**
448 * nvme_io_passthru64() - Submit an nvme io passthrough command
449 * @fd: File descriptor of nvme device
450 * @opcode: The nvme io command to send
451 * @flags: NVMe command flags (not used)
452 * @rsvd: Reserved for future use
453 * @nsid: Namespace identifier
454 * @cdw2: Command dword 2
455 * @cdw3: Command dword 3
456 * @cdw10: Command dword 10
457 * @cdw11: Command dword 11
458 * @cdw12: Command dword 12
459 * @cdw13: Command dword 13
460 * @cdw14: Command dword 14
461 * @cdw15: Command dword 15
462 * @data_len: Length of the data transferred in this command in bytes
463 * @data: Pointer to user address of the data buffer
464 * @metadata_len:Length of metadata transferred in this command
465 * @metadata: Pointer to user address of the metadata buffer
466 * @timeout_ms: How long the kernel waits for the command to complete
467 * @result: Optional field to return the result from the CQE dword 0
468 *
469 * Parameterized form of nvme_submit_io_passthru64(). This sets up and submits
470 * a &struct nvme_passthru_cmd64.
471 *
472 * Known values for @opcode are defined in &enum nvme_io_opcode.
473 *
474 * Return: The nvme command status if a response was received (see
475 * &enum nvme_status_field) or -1 with errno set otherwise.
476 */
477 int nvme_io_passthru64(int fd, __u8 opcode, __u8 flags, __u16 rsvd,
478 __u32 nsid, __u32 cdw2, __u32 cdw3, __u32 cdw10, __u32 cdw11,
479 __u32 cdw12, __u32 cdw13, __u32 cdw14, __u32 cdw15,
480 __u32 data_len, void *data, __u32 metadata_len, void *metadata,
481 __u32 timeout_ms, __u64 *result);
482
483 /**
484 * nvme_submit_io_passthru() - Submit an nvme passthrough command
485 * @fd: File descriptor of nvme device
486 * @cmd: The nvme io command to send
487 * @result: Optional field to return the result from the CQE dword 0
488 * @result: Optional field to return the result from the CQE DW0
489 *
490 * Uses NVME_IOCTL_IO_CMD for the ioctl request.
491 *
492 * Return: The nvme command status if a response was received (see
493 * &enum nvme_status_field) or -1 with errno set otherwise.
494 */
495 int nvme_submit_io_passthru(int fd, struct nvme_passthru_cmd *cmd,
496 __u32 *result);
497
498 /**
499 * nvme_io_passthru() - Submit an nvme io passthrough command
500 * @fd: File descriptor of nvme device
501 * @opcode: The nvme io command to send
502 * @flags: NVMe command flags (not used)
503 * @rsvd: Reserved for future use
504 * @nsid: Namespace identifier
505 * @cdw2: Command dword 2
506 * @cdw3: Command dword 3
507 * @cdw10: Command dword 10
508 * @cdw11: Command dword 11
509 * @cdw12: Command dword 12
510 * @cdw13: Command dword 13
511 * @cdw14: Command dword 14
512 * @cdw15: Command dword 15
513 * @data_len: Length of the data transferred in this command in bytes
514 * @data: Pointer to user address of the data buffer
515 * @metadata_len:Length of metadata transferred in this command
516 * @metadata: Pointer to user address of the metadata buffer
517 * @timeout_ms: How long the kernel waits for the command to complete
518 * @result: Optional field to return the result from the CQE dword 0
519 *
520 * Parameterized form of nvme_submit_io_passthru(). This sets up and submits
521 * a &struct nvme_passthru_cmd.
522 *
523 * Known values for @opcode are defined in &enum nvme_io_opcode.
524 *
525 * Return: The nvme command status if a response was received (see
526 * &enum nvme_status_field) or -1 with errno set otherwise.
527 */
528 int nvme_io_passthru(int fd, __u8 opcode, __u8 flags, __u16 rsvd,
529 __u32 nsid, __u32 cdw2, __u32 cdw3, __u32 cdw10, __u32 cdw11,
530 __u32 cdw12, __u32 cdw13, __u32 cdw14, __u32 cdw15,
531 __u32 data_len, void *data, __u32 metadata_len, void *metadata,
532 __u32 timeout_ms, __u32 *result);
533
534 /**
535 * nvme_subsystem_reset() - Initiate a subsystem reset
536 * @fd: File descriptor of nvme device
537 *
538 * This should only be sent to controller handles, not to namespaces.
539 *
540 * Return: Zero if a subsystem reset was initiated or -1 with errno set
541 * otherwise.
542 */
543 int nvme_subsystem_reset(int fd);
544
545 /**
546 * nvme_ctrl_reset() - Initiate a controller reset
547 * @fd: File descriptor of nvme device
548 *
549 * This should only be sent to controller handles, not to namespaces.
550 *
551 * Return: 0 if a reset was initiated or -1 with errno set otherwise.
552 */
553 int nvme_ctrl_reset(int fd);
554
555 /**
556 * nvme_ns_rescan() - Initiate a controller rescan
557 * @fd: File descriptor of nvme device
558 *
559 * This should only be sent to controller handles, not to namespaces.
560 *
561 * Return: 0 if a rescan was initiated or -1 with errno set otherwise.
562 */
563 int nvme_ns_rescan(int fd);
564
565 /**
566 * nvme_get_nsid() - Retrieve the NSID from a namespace file descriptor
567 * @fd: File descriptor of nvme namespace
568 * @nsid: User pointer to namespace id
569 *
570 * This should only be sent to namespace handles, not to controllers. The
571 * kernel's interface returns the nsid as the return value. This is unfortunate
572 * for many architectures that are incapable of allowing distinguishing a
573 * namespace id > 0x80000000 from a negative error number.
574 *
575 * Return: 0 if @nsid was set successfully or -1 with errno set otherwise.
576 */
577 int nvme_get_nsid(int fd, __u32 *nsid);
578
579 /**
580 * nvme_identify() - Send the NVMe Identify command
581 * @args: &struct nvme_identify_args argument structure
582 *
583 * The Identify command returns a data buffer that describes information about
584 * the NVM subsystem, the controller or the namespace(s).
585 *
586 * Return: The nvme command status if a response was received (see
587 * &enum nvme_status_field) or -1 with errno set otherwise.
588 */
589 int nvme_identify(struct nvme_identify_args *args);
590
591 static inline int nvme_identify_cns_nsid(int fd, enum nvme_identify_cns cns,
592 __u32 nsid, void *data)
593 {
594 struct nvme_identify_args args = {
595 .result = NULL,
596 .data = data,
597 .args_size = sizeof(args),
598 .fd = fd,
599 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
600 .cns = cns,
601 .csi = NVME_CSI_NVM,
602 .nsid = nsid,
603 .cntid = NVME_CNTLID_NONE,
604 .cns_specific_id = NVME_CNSSPECID_NONE,
605 .uuidx = NVME_UUID_NONE,
606 };
607
608 return nvme_identify(&args);
609 }
610
611 /**
612 * nvme_identify_ctrl() - Retrieves nvme identify controller
613 * @fd: File descriptor of nvme device
614 * @id: User space destination address to transfer the data,
615 *
616 * Sends nvme identify with CNS value %NVME_IDENTIFY_CNS_CTRL.
617 *
618 * See &struct nvme_id_ctrl for details on the data returned.
619 *
620 * Return: The nvme command status if a response was received (see
621 * &enum nvme_status_field) or -1 with errno set otherwise.
622 */
623 static inline int nvme_identify_ctrl(int fd, struct nvme_id_ctrl *id)
624 {
625 return nvme_identify_cns_nsid(fd, NVME_IDENTIFY_CNS_CTRL,
626 NVME_NSID_NONE, id);
627 }
628
629 /**
630 * nvme_identify_ns() - Retrieves nvme identify namespace
631 * @fd: File descriptor of nvme device
632 * @nsid: Namespace to identify
633 * @ns: User space destination address to transfer the data
634 *
635 * If the Namespace Identifier (NSID) field specifies an active NSID, then the
636 * Identify Namespace data structure is returned to the host for that specified
637 * namespace.
638 *
639 * If the controller supports the Namespace Management capability and the NSID
640 * field is set to %NVME_NSID_ALL, then the controller returns an Identify Namespace
641 * data structure that specifies capabilities that are common across namespaces
642 * for this controller.
643 *
644 * See &struct nvme_id_ns for details on the structure returned.
645 *
646 * Return: The nvme command status if a response was received (see
647 * &enum nvme_status_field) or -1 with errno set otherwise.
648 */
649 static inline int nvme_identify_ns(int fd, __u32 nsid, struct nvme_id_ns *ns)
650 {
651 return nvme_identify_cns_nsid(fd, NVME_IDENTIFY_CNS_NS, nsid, ns);
652 }
653
654 /**
655 * nvme_identify_allocated_ns() - Same as nvme_identify_ns, but only for
656 * allocated namespaces
657 * @fd: File descriptor of nvme device
658 * @nsid: Namespace to identify
659 * @ns: User space destination address to transfer the data
660 *
661 * Return: The nvme command status if a response was received (see
662 * &enum nvme_status_field) or -1 with errno set otherwise.
663 */
664 static inline int nvme_identify_allocated_ns(int fd, __u32 nsid,
665 struct nvme_id_ns *ns)
666 {
667 return nvme_identify_cns_nsid(fd, NVME_IDENTIFY_CNS_ALLOCATED_NS,
668 nsid, ns);
669 }
670
671 /**
672 * nvme_identify_active_ns_list() - Retrieves active namespaces id list
673 * @fd: File descriptor of nvme device
674 * @nsid: Return namespaces greater than this identifier
675 * @list: User space destination address to transfer the data
676 *
677 * A list of 1024 namespace IDs is returned to the host containing NSIDs in
678 * increasing order that are greater than the value specified in the Namespace
679 * Identifier (nsid) field of the command.
680 *
681 * See &struct nvme_ns_list for the definition of the returned structure.
682 *
683 * Return: The nvme command status if a response was received (see
684 * &enum nvme_status_field) or -1 with errno set otherwise.
685 */
686 static inline int nvme_identify_active_ns_list(int fd, __u32 nsid,
687 struct nvme_ns_list *list)
688 {
689 return nvme_identify_cns_nsid(fd, NVME_IDENTIFY_CNS_NS_ACTIVE_LIST,
690 nsid, list);
691 }
692
693 /**
694 * nvme_identify_allocated_ns_list() - Retrieves allocated namespace id list
695 * @fd: File descriptor of nvme device
696 * @nsid: Return namespaces greater than this identifier
697 * @list: User space destination address to transfer the data
698 *
699 * A list of 1024 namespace IDs is returned to the host containing NSIDs in
700 * increasing order that are greater than the value specified in the Namespace
701 * Identifier (nsid) field of the command.
702 *
703 * See &struct nvme_ns_list for the definition of the returned structure.
704 *
705 * Return: The nvme command status if a response was received (see
706 * &enum nvme_status_field) or -1 with errno set otherwise.
707 */
708 static inline int nvme_identify_allocated_ns_list(int fd, __u32 nsid,
709 struct nvme_ns_list *list)
710 {
711 return nvme_identify_cns_nsid(fd, NVME_IDENTIFY_CNS_ALLOCATED_NS_LIST,
712 nsid, list);
713 }
714
715 /**
716 * nvme_identify_ctrl_list() - Retrieves identify controller list
717 * @fd: File descriptor of nvme device
718 * @cntid: Starting CNTLID to return in the list
719 * @cntlist: User space destination address to transfer the data
720 *
721 * Up to 2047 controller identifiers is returned containing a controller
722 * identifier greater than or equal to the controller identifier specified in
723 * @cntid.
724 *
725 * See &struct nvme_ctrl_list for a definition of the structure returned.
726 *
727 * Return: The nvme command status if a response was received (see
728 * &enum nvme_status_field) or -1 with errno set otherwise.
729 */
730 static inline int nvme_identify_ctrl_list(int fd, __u16 cntid,
731 struct nvme_ctrl_list *cntlist)
732 {
733 struct nvme_identify_args args = {
734 .result = NULL,
735 .data = cntlist,
736 .args_size = sizeof(args),
737 .fd = fd,
738 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
739 .cns = NVME_IDENTIFY_CNS_CTRL_LIST,
740 .csi = NVME_CSI_NVM,
741 .nsid = NVME_NSID_NONE,
742 .cntid = cntid,
743 .cns_specific_id = NVME_CNSSPECID_NONE,
744 .uuidx = NVME_UUID_NONE,
745 };
746
747 return nvme_identify(&args);
748 }
749
750 /**
751 * nvme_identify_nsid_ctrl_list() - Retrieves controller list attached to an nsid
752 * @fd: File descriptor of nvme device
753 * @nsid: Return controllers that are attached to this nsid
754 * @cntid: Starting CNTLID to return in the list
755 * @cntlist: User space destination address to transfer the data
756 *
757 * Up to 2047 controller identifiers are returned containing a controller
758 * identifier greater than or equal to the controller identifier specified in
759 * @cntid attached to @nsid.
760 *
761 * See &struct nvme_ctrl_list for a definition of the structure returned.
762 *
763 * Return: The nvme command status if a response was received (see
764 * &enum nvme_status_field) or -1
765 */
766 static inline int nvme_identify_nsid_ctrl_list(int fd, __u32 nsid, __u16 cntid,
767 struct nvme_ctrl_list *cntlist)
768 {
769 struct nvme_identify_args args = {
770 .result = NULL,
771 .data = cntlist,
772 .args_size = sizeof(args),
773 .fd = fd,
774 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
775 .cns = NVME_IDENTIFY_CNS_NS_CTRL_LIST,
776 .csi = NVME_CSI_NVM,
777 .nsid = nsid,
778 .cntid = cntid,
779 .cns_specific_id = NVME_CNSSPECID_NONE,
780 .uuidx = NVME_UUID_NONE,
781 };
782
783 return nvme_identify(&args);
784 }
785
786 /**
787 * nvme_identify_ns_descs() - Retrieves namespace descriptor list
788 * @fd: File descriptor of nvme device
789 * @nsid: The namespace id to retrieve descriptors
790 * @descs: User space destination address to transfer the data
791 *
792 * A list of Namespace Identification Descriptor structures is returned to the
793 * host for the namespace specified in the Namespace Identifier (NSID) field if
794 * it is an active NSID.
795 *
796 * The data returned is in the form of an array of 'struct nvme_ns_id_desc'.
797 *
798 * See &struct nvme_ns_id_desc for the definition of the returned structure.
799 *
800 * Return: The nvme command status if a response was received (see
801 * &enum nvme_status_field) or -1 with errno set otherwise.
802 */
803 static inline int nvme_identify_ns_descs(int fd, __u32 nsid,
804 struct nvme_ns_id_desc *descs)
805 {
806 return nvme_identify_cns_nsid(fd, NVME_IDENTIFY_CNS_NS_DESC_LIST,
807 nsid, descs);
808 }
809
810 /**
811 * nvme_identify_nvmset_list() - Retrieves NVM Set List
812 * @fd: File descriptor of nvme device
813 * @nvmsetid: NVM Set Identifier
814 * @nvmset: User space destination address to transfer the data
815 *
816 * Retrieves an NVM Set List, &struct nvme_id_nvmset_list. The data structure
817 * is an ordered list by NVM Set Identifier, starting with the first NVM Set
818 * Identifier supported by the NVM subsystem that is equal to or greater than
819 * the NVM Set Identifier.
820 *
821 * See &struct nvme_id_nvmset_list for the definition of the returned structure.
822 *
823 * Return: The nvme command status if a response was received (see
824 * &enum nvme_status_field) or -1 with errno set otherwise.
825 */
826 static inline int nvme_identify_nvmset_list(int fd, __u16 nvmsetid,
827 struct nvme_id_nvmset_list *nvmset)
828 {
829 struct nvme_identify_args args = {
830 .result = NULL,
831 .data = nvmset,
832 .args_size = sizeof(args),
833 .fd = fd,
834 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
835 .cns = NVME_IDENTIFY_CNS_NVMSET_LIST,
836 .csi = NVME_CSI_NVM,
837 .nsid = NVME_NSID_NONE,
838 .cntid = NVME_CNTLID_NONE,
839 .cns_specific_id = nvmsetid,
840 .uuidx = NVME_UUID_NONE,
841 };
842
843 return nvme_identify(&args);
844 }
845
846 /**
847 * nvme_identify_primary_ctrl() - Retrieve NVMe Primary Controller
848 * identification
849 * @fd: File descriptor of nvme device
850 * @cntid: Return controllers starting at this identifier
851 * @cap: User space destination buffer address to transfer the data
852 *
853 * See &struct nvme_primary_ctrl_cap for the definition of the returned structure, @cap.
854 *
855 * Return: The nvme command status if a response was received (see
856 * &enum nvme_status_field) or -1 with errno set otherwise.
857 */
858 static inline int nvme_identify_primary_ctrl(int fd, __u16 cntid,
859 struct nvme_primary_ctrl_cap *cap)
860 {
861 struct nvme_identify_args args = {
862 .result = NULL,
863 .data = cap,
864 .args_size = sizeof(args),
865 .fd = fd,
866 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
867 .cns = NVME_IDENTIFY_CNS_PRIMARY_CTRL_CAP,
868 .csi = NVME_CSI_NVM,
869 .nsid = NVME_NSID_NONE,
870 .cntid = cntid,
871 .cns_specific_id = NVME_CNSSPECID_NONE,
872 .uuidx = NVME_UUID_NONE,
873 };
874
875 return nvme_identify(&args);
876 }
877
878 /**
879 * nvme_identify_secondary_ctrl_list() - Retrieves secondary controller list
880 * @fd: File descriptor of nvme device
881 * @cntid: Return controllers starting at this identifier
882 * @sc_list: User space destination address to transfer the data
883 *
884 * A Secondary Controller List is returned to the host for up to 127 secondary
885 * controllers associated with the primary controller processing this command.
886 * The list contains entries for controller identifiers greater than or equal
887 * to the value specified in the Controller Identifier (cntid).
888 *
889 * See &struct nvme_secondary_ctrls_list for a definition of the returned
890 * structure.
891 *
892 * Return: The nvme command status if a response was received (see
893 * &enum nvme_status_field) or -1 with errno set otherwise.
894 */
895 static inline int nvme_identify_secondary_ctrl_list(int fd,
896 __u16 cntid, struct nvme_secondary_ctrl_list *sc_list)
897 {
898 struct nvme_identify_args args = {
899 .result = NULL,
900 .data = sc_list,
901 .args_size = sizeof(args),
902 .fd = fd,
903 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
904 .cns = NVME_IDENTIFY_CNS_SECONDARY_CTRL_LIST,
905 .csi = NVME_CSI_NVM,
906 .nsid = NVME_NSID_NONE,
907 .cntid = cntid,
908 .cns_specific_id = NVME_CNSSPECID_NONE,
909 .uuidx = NVME_UUID_NONE,
910 };
911
912 return nvme_identify(&args);
913 }
914
915 /**
916 * nvme_identify_ns_granularity() - Retrieves namespace granularity
917 * identification
918 * @fd: File descriptor of nvme device
919 * @gr_list: User space destination address to transfer the data
920 *
921 * If the controller supports reporting of Namespace Granularity, then a
922 * Namespace Granularity List is returned to the host for up to sixteen
923 * namespace granularity descriptors
924 *
925 * See &struct nvme_id_ns_granularity_list for the definition of the returned
926 * structure.
927 *
928 * Return: The nvme command status if a response was received (see
929 * &enum nvme_status_field) or -1 with errno set otherwise.
930 */
931 static inline int nvme_identify_ns_granularity(int fd,
932 struct nvme_id_ns_granularity_list *gr_list)
933 {
934 return nvme_identify_cns_nsid(fd, NVME_IDENTIFY_CNS_NS_GRANULARITY,
935 NVME_NSID_NONE, gr_list);
936 }
937
938 /**
939 * nvme_identify_uuid() - Retrieves device's UUIDs
940 * @fd: File descriptor of nvme device
941 * @uuid_list: User space destination address to transfer the data
942 *
943 * Each UUID List entry is either 0h, the NVMe Invalid UUID, or a valid UUID.
944 * Valid UUIDs are those which are non-zero and are not the NVMe Invalid UUID.
945 *
946 * See &struct nvme_id_uuid_list for the definition of the returned structure.
947 *
948 * Return: The nvme command status if a response was received (see
949 * &enum nvme_status_field) or -1 with errno set otherwise.
950 */
951 static inline int nvme_identify_uuid(int fd, struct nvme_id_uuid_list *uuid_list)
952 {
953 return nvme_identify_cns_nsid(fd, NVME_IDENTIFY_CNS_UUID_LIST,
954 NVME_NSID_NONE, uuid_list);
955 }
956
957 /**
958 * nvme_identify_ns_csi() - I/O command set specific identify namespace data
959 * @fd: File descriptor of nvme device
960 * @nsid: Namespace to identify
961 * @uuidx: UUID Index for differentiating vendor specific encoding
962 * @csi: Command Set Identifier
963 * @data: User space destination address to transfer the data
964 *
965 * An I/O Command Set specific Identify Namespace data structure is returned
966 * for the namespace specified in @nsid.
967 *
968 * Return: The nvme command status if a response was received (see
969 * &enum nvme_status_field) or -1 with errno set otherwise.
970 */
971 static inline int nvme_identify_ns_csi(int fd, __u32 nsid, __u8 uuidx,
972 enum nvme_csi csi, void *data)
973 {
974 struct nvme_identify_args args = {
975 .result = NULL,
976 .data = data,
977 .args_size = sizeof(args),
978 .fd = fd,
979 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
980 .cns = NVME_IDENTIFY_CNS_CSI_NS,
981 .csi = csi,
982 .nsid = nsid,
983 .cntid = NVME_CNTLID_NONE,
984 .cns_specific_id = NVME_CNSSPECID_NONE,
985 .uuidx = uuidx,
986 };
987
988 return nvme_identify(&args);
989 }
990
991 /**
992 * nvme_identify_ctrl_csi() - I/O command set specific Identify Controller data
993 * @fd: File descriptor of nvme device
994 * @csi: Command Set Identifier
995 * @data: User space destination address to transfer the data
996 *
997 * An I/O Command Set specific Identify Controller data structure is returned
998 * to the host for the controller processing the command. The specific Identify
999 * Controller data structure to be returned is specified by @csi.
1000 *
1001 * Return: The nvme command status if a response was received (see
1002 * &enum nvme_status_field) or -1 with errno set otherwise.
1003 */
1004 static inline int nvme_identify_ctrl_csi(int fd, enum nvme_csi csi, void *data)
1005 {
1006 struct nvme_identify_args args = {
1007 .result = NULL,
1008 .data = data,
1009 .args_size = sizeof(args),
1010 .fd = fd,
1011 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
1012 .cns = NVME_IDENTIFY_CNS_CSI_CTRL,
1013 .csi = csi,
1014 .nsid = NVME_NSID_NONE,
1015 .cntid = NVME_CNTLID_NONE,
1016 .cns_specific_id = NVME_CNSSPECID_NONE,
1017 .uuidx = NVME_UUID_NONE,
1018 };
1019
1020 return nvme_identify(&args);
1021 }
1022
1023 /**
1024 * nvme_identify_active_ns_list_csi() - Active namespace ID list associated with a specified I/O command set
1025 * @fd: File descriptor of nvme device
1026 * @nsid: Return namespaces greater than this identifier
1027 * @csi: Command Set Identifier
1028 * @ns_list: User space destination address to transfer the data
1029 *
1030 * A list of 1024 namespace IDs is returned to the host containing active
1031 * NSIDs in increasing order that are greater than the value specified in
1032 * the Namespace Identifier (nsid) field of the command and matching the
1033 * I/O Command Set specified in the @csi argument.
1034 *
1035 * See &struct nvme_ns_list for the definition of the returned structure.
1036 *
1037 * Return: The nvme command status if a response was received (see
1038 * &enum nvme_status_field) or -1 with errno set otherwise.
1039 */
1040 static inline int nvme_identify_active_ns_list_csi(int fd, __u32 nsid,
1041 enum nvme_csi csi, struct nvme_ns_list *ns_list)
1042 {
1043 struct nvme_identify_args args = {
1044 .result = NULL,
1045 .data = ns_list,
1046 .args_size = sizeof(args),
1047 .fd = fd,
1048 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
1049 .cns = NVME_IDENTIFY_CNS_CSI_NS_ACTIVE_LIST,
1050 .csi = csi,
1051 .nsid = nsid,
1052 .cntid = NVME_CNTLID_NONE,
1053 .cns_specific_id = NVME_CNSSPECID_NONE,
1054 .uuidx = NVME_UUID_NONE,
1055 };
1056
1057 return nvme_identify(&args);
1058 }
1059
1060 /**
1061 * nvme_identify_allocated_ns_list_csi() - Allocated namespace ID list associated with a specified I/O command set
1062 * @fd: File descriptor of nvme device
1063 * @nsid: Return namespaces greater than this identifier
1064 * @csi: Command Set Identifier
1065 * @ns_list: User space destination address to transfer the data
1066 *
1067 * A list of 1024 namespace IDs is returned to the host containing allocated
1068 * NSIDs in increasing order that are greater than the value specified in
1069 * the @nsid field of the command and matching the I/O Command Set
1070 * specified in the @csi argument.
1071 *
1072 * See &struct nvme_ns_list for the definition of the returned structure.
1073 *
1074 * Return: The nvme command status if a response was received (see
1075 * &enum nvme_status_field) or -1 with errno set otherwise.
1076 */
1077 static inline int nvme_identify_allocated_ns_list_csi(int fd, __u32 nsid,
1078 enum nvme_csi csi, struct nvme_ns_list *ns_list)
1079 {
1080 struct nvme_identify_args args = {
1081 .result = NULL,
1082 .data = ns_list,
1083 .args_size = sizeof(args),
1084 .fd = fd,
1085 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
1086 .cns = NVME_IDENTIFY_CNS_CSI_ALLOCATED_NS_LIST,
1087 .csi = csi,
1088 .nsid = nsid,
1089 .cntid = NVME_CNTLID_NONE,
1090 .cns_specific_id = NVME_CNSSPECID_NONE,
1091 .uuidx = NVME_UUID_NONE,
1092 };
1093
1094 return nvme_identify(&args);
1095 }
1096
1097 /**
1098 * nvme_identify_independent_identify_ns() - I/O command set independent Identify namespace data
1099 * @fd: File descriptor of nvme device
1100 * @nsid: Return namespaces greater than this identifier
1101 * @ns: I/O Command Set Independent Identify Namespace data
1102 * structure
1103 *
1104 * The I/O command set independent Identify namespace data structure for
1105 * the namespace identified with @ns is returned to the host.
1106 *
1107 * Return: The nvme command status if a response was received (see
1108 * &enum nvme_status_field) or -1 with errno set otherwise.
1109 */
1110 static inline int nvme_identify_independent_identify_ns(int fd, __u32 nsid,
1111 struct nvme_id_independent_id_ns *ns)
1112 {
1113 return nvme_identify_cns_nsid(
1114 fd, NVME_IDENTIFY_CNS_CSI_INDEPENDENT_ID_NS, nsid, ns);
1115 }
1116
1117 /**
1118 * nvme_identify_ns_csi_user_data_format() - Identify namespace user data format
1119 * @fd: File descriptor of nvme device
1120 * @user_data_format: Return namespaces capability of identifier
1121 * @uuidx: UUID selection, if supported
1122 * @csi: Command Set Identifier
1123 * @data: User space destination address to transfer the data
1124 *
1125 * Identify Namespace data structure for the specified User Data Format
1126 * index containing the namespace capabilities for the NVM Command Set.
1127 *
1128 * Return: The nvme command status if a response was received (see
1129 * &enum nvme_status_field) or -1 with errno set otherwise.
1130 */
1131 static inline int nvme_identify_ns_csi_user_data_format(int fd,
1132 __u16 user_data_format, __u8 uuidx,
1133 enum nvme_csi csi, void *data)
1134 {
1135 struct nvme_identify_args args = {
1136 .result = NULL,
1137 .data = data,
1138 .args_size = sizeof(args),
1139 .fd = fd,
1140 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
1141 .cns = NVME_IDENTIFY_CNS_NS_USER_DATA_FORMAT,
1142 .csi = csi,
1143 .nsid = NVME_NSID_NONE,
1144 .cntid = NVME_CNTLID_NONE,
1145 .cns_specific_id = user_data_format,
1146 .uuidx = uuidx,
1147 };
1148
1149 return nvme_identify(&args);
1150 }
1151
1152 /**
1153 * nvme_identify_iocs_ns_csi_user_data_format() - Identify I/O command set namespace data structure
1154 * @fd: File descriptor of nvme device
1155 * @user_data_format: Return namespaces capability of identifier
1156 * @uuidx: UUID selection, if supported
1157 * @csi: Command Set Identifier
1158 * @data: User space destination address to transfer the data
1159 *
1160 * I/O Command Set specific Identify Namespace data structure for
1161 * the specified User Data Format index containing the namespace
1162 * capabilities for the I/O Command Set specified in the CSI field.
1163 *
1164 * Return: The nvme command status if a response was received (see
1165 * &enum nvme_status_field) or -1 with errno set otherwise.
1166 */
1167 static inline int nvme_identify_iocs_ns_csi_user_data_format(int fd,
1168 __u16 user_data_format, __u8 uuidx,
1169 enum nvme_csi csi, void *data)
1170 {
1171 struct nvme_identify_args args = {
1172 .result = NULL,
1173 .data = data,
1174 .args_size = sizeof(args),
1175 .fd = fd,
1176 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
1177 .cns = NVME_IDENTIFY_CNS_CSI_NS_USER_DATA_FORMAT,
1178 .csi = csi,
1179 .nsid = NVME_NSID_NONE,
1180 .cntid = NVME_CNTLID_NONE,
1181 .cns_specific_id = user_data_format,
1182 .uuidx = uuidx,
1183 };
1184
1185 return nvme_identify(&args);
1186 }
1187
1188 /**
1189 * nvme_nvm_identify_ctrl() - Identify controller data
1190 * @fd: File descriptor of nvme device
1191 * @id: User space destination address to transfer the data
1192 *
1193 * Return an identify controller data structure to the host of
1194 * processing controller.
1195 *
1196 * Return: The nvme command status if a response was received (see
1197 * &enum nvme_status_field) or -1 with errno set otherwise.
1198 */
1199 static inline int nvme_nvm_identify_ctrl(int fd, struct nvme_id_ctrl_nvm *id)
1200 {
1201 return nvme_identify_ctrl_csi(fd, NVME_CSI_NVM, id);
1202 }
1203
1204 /**
1205 * nvme_identify_domain_list() - Domain list data
1206 * @fd: File descriptor of nvme device
1207 * @domid: Domain ID
1208 * @list: User space destination address to transfer data
1209 *
1210 * A list of 31 domain IDs is returned to the host containing domain
1211 * attributes in increasing order that are greater than the value
1212 * specified in the @domid field.
1213 *
1214 * See &struct nvme_identify_domain_attr for the definition of the
1215 * returned structure.
1216 *
1217 * Return: The nvme command status if a response was received (see
1218 * &enum nvme_status_field) or -1 with errno set otherwise.
1219 */
1220 static inline int nvme_identify_domain_list(int fd, __u16 domid,
1221 struct nvme_id_domain_list *list)
1222 {
1223 struct nvme_identify_args args = {
1224 .result = NULL,
1225 .data = list,
1226 .args_size = sizeof(args),
1227 .fd = fd,
1228 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
1229 .cns = NVME_IDENTIFY_CNS_DOMAIN_LIST,
1230 .csi = NVME_CSI_NVM,
1231 .nsid = NVME_NSID_NONE,
1232 .cntid = NVME_CNTLID_NONE,
1233 .cns_specific_id = domid,
1234 .uuidx = NVME_UUID_NONE,
1235 };
1236
1237 return nvme_identify(&args);
1238 }
1239
1240 /**
1241 * nvme_identify_endurance_group_list() - Endurance group list data
1242 * @fd: File descriptor of nvme device
1243 * @endgrp_id: Endurance group identifier
1244 * @list: Array of endurance group identifiers
1245 *
1246 * Return: The nvme command status if a response was received (see
1247 * &enum nvme_status_field) or -1 with errno set otherwise.
1248 */
1249 static inline int nvme_identify_endurance_group_list(int fd, __u16 endgrp_id,
1250 struct nvme_id_endurance_group_list *list)
1251 {
1252 struct nvme_identify_args args = {
1253 .result = NULL,
1254 .data = list,
1255 .args_size = sizeof(args),
1256 .fd = fd,
1257 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
1258 .cns = NVME_IDENTIFY_CNS_ENDURANCE_GROUP_ID,
1259 .csi = NVME_CSI_NVM,
1260 .nsid = NVME_NSID_NONE,
1261 .cntid = NVME_CNTLID_NONE,
1262 .cns_specific_id = endgrp_id,
1263 .uuidx = NVME_UUID_NONE,
1264 };
1265
1266 return nvme_identify(&args);
1267 }
1268
1269 /**
1270 * nvme_identify_iocs() - I/O command set data structure
1271 * @fd: File descriptor of nvme device
1272 * @cntlid: Controller ID
1273 * @iocs: User space destination address to transfer the data
1274 *
1275 * Retrieves list of the controller's supported io command set vectors. See
1276 * &struct nvme_id_iocs.
1277 *
1278 * Return: The nvme command status if a response was received (see
1279 * &enum nvme_status_field) or -1 with errno set otherwise.
1280 */
1281 static inline int nvme_identify_iocs(int fd, __u16 cntlid,
1282 struct nvme_id_iocs *iocs)
1283 {
1284 struct nvme_identify_args args = {
1285 .result = NULL,
1286 .data = iocs,
1287 .args_size = sizeof(args),
1288 .fd = fd,
1289 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
1290 .cns = NVME_IDENTIFY_CNS_COMMAND_SET_STRUCTURE,
1291 .csi = NVME_CSI_NVM,
1292 .nsid = NVME_NSID_NONE,
1293 .cntid = cntlid,
1294 .cns_specific_id = NVME_CNSSPECID_NONE,
1295 .uuidx = NVME_UUID_NONE,
1296 };
1297
1298 return nvme_identify(&args);
1299 }
1300
1301 /**
1302 * nvme_zns_identify_ns() - ZNS identify namespace data
1303 * @fd: File descriptor of nvme device
1304 * @nsid: Namespace to identify
1305 * @data: User space destination address to transfer the data
1306 *
1307 * Return: The nvme command status if a response was received (see
1308 * &enum nvme_status_field) or -1 with errno set otherwise.
1309 */
1310 static inline int nvme_zns_identify_ns(int fd, __u32 nsid,
1311 struct nvme_zns_id_ns *data)
1312 {
1313 return nvme_identify_ns_csi(
1314 fd, nsid, NVME_UUID_NONE, NVME_CSI_ZNS, data);
1315 }
1316
1317 /**
1318 * nvme_zns_identify_ctrl() - ZNS identify controller data
1319 * @fd: File descriptor of nvme device
1320 * @id: User space destination address to transfer the data
1321 *
1322 * Return: The nvme command status if a response was received (see
1323 * &enum nvme_status_field) or -1 with errno set otherwise.
1324 */
1325 static inline int nvme_zns_identify_ctrl(int fd, struct nvme_zns_id_ctrl *id)
1326 {
1327 return nvme_identify_ctrl_csi(fd, NVME_CSI_ZNS, id);
1328 }
1329
1330 /**
1331 * nvme_get_log() - NVMe Admin Get Log command
1332 * @args: &struct nvme_get_log_args argument structure
1333 *
1334 * Return: The nvme command status if a response was received (see
1335 * &enum nvme_status_field) or -1 with errno set otherwise.
1336 */
1337 int nvme_get_log(struct nvme_get_log_args *args);
1338
1339 /**
1340 * nvme_get_log_page() - Get log page data
1341 * @fd: File descriptor of nvme device
1342 * @xfer_len: Max log transfer size per request to split the total.
1343 * @args: &struct nvme_get_log_args argument structure
1344 *
1345 * Return: The nvme command status if a response was received (see
1346 * &enum nvme_status_field) or -1 with errno set otherwise.
1347 */
1348 int nvme_get_log_page(int fd, __u32 xfer_len, struct nvme_get_log_args *args);
1349
1350 static inline int nvme_get_nsid_log(int fd, bool rae,
1351 enum nvme_cmd_get_log_lid lid,
1352 __u32 nsid, __u32 len, void *log)
1353 {
1354 struct nvme_get_log_args args = {
1355 .lpo = 0,
1356 .result = NULL,
1357 .log = log,
1358 .args_size = sizeof(args),
1359 .fd = fd,
1360 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
1361 .lid = lid,
1362 .len = len,
1363 .nsid = nsid,
1364 .csi = NVME_CSI_NVM,
1365 .lsi = NVME_LOG_LSI_NONE,
1366 .lsp = NVME_LOG_LSP_NONE,
1367 .uuidx = NVME_UUID_NONE,
1368 .rae = rae,
1369 .ot = false,
1370 };
1371
1372 return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
1373 }
1374
1375 static inline int nvme_get_endgid_log(int fd, bool rae, enum nvme_cmd_get_log_lid lid, __u16 endgid,
1376 __u32 len, void *log)
1377 {
1378 struct nvme_get_log_args args = {
1379 .lpo = 0,
1380 .result = NULL,
1381 .log = log,
1382 .args_size = sizeof(args),
1383 .fd = fd,
1384 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
1385 .lid = lid,
1386 .len = len,
1387 .nsid = NVME_NSID_NONE,
1388 .csi = NVME_CSI_NVM,
1389 .lsi = endgid,
1390 .lsp = NVME_LOG_LSP_NONE,
1391 .uuidx = NVME_LOG_LSP_NONE,
1392 .rae = rae,
1393 .ot = false,
1394 };
1395
1396 return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
1397 }
1398
1399 static inline int nvme_get_log_simple(int fd, enum nvme_cmd_get_log_lid lid,
1400 __u32 len, void *log)
1401 {
1402 return nvme_get_nsid_log(fd, false, lid, NVME_NSID_ALL, len, log);
1403 }
1404
1405 /**
1406 * nvme_get_log_supported_log_pages() - Retrieve nmve supported log pages
1407 * @fd: File descriptor of nvme device
1408 * @rae: Retain asynchronous events
1409 * @log: Array of LID supported and Effects data structures
1410 *
1411 * Return: The nvme command status if a response was received (see
1412 * &enum nvme_status_field) or -1 with errno set otherwise.
1413 */
1414 static inline int nvme_get_log_supported_log_pages(int fd, bool rae,
1415 struct nvme_supported_log_pages *log)
1416 {
1417 return nvme_get_nsid_log(fd, rae, NVME_LOG_LID_SUPPORTED_LOG_PAGES,
1418 NVME_NSID_ALL, sizeof(*log), log);
1419 }
1420
1421 /**
1422 * nvme_get_log_error() - Retrieve nvme error log
1423 * @fd: File descriptor of nvme device
1424 * @nr_entries: Number of error log entries allocated
1425 * @rae: Retain asynchronous events
1426 * @err_log: Array of error logs of size 'entries'
1427 *
1428 * This log page describes extended error information for a command that
1429 * completed with error, or may report an error that is not specific to a
1430 * particular command.
1431 *
1432 * Return: The nvme command status if a response was received (see
1433 * &enum nvme_status_field) or -1 with errno set otherwise.
1434 */
1435 static inline int nvme_get_log_error(int fd, unsigned int nr_entries, bool rae,
1436 struct nvme_error_log_page *err_log)
1437 {
1438 return nvme_get_nsid_log(fd, rae, NVME_LOG_LID_ERROR,
1439 NVME_NSID_ALL, sizeof(*err_log) * nr_entries,
1440 err_log);
1441 }
1442
1443 /**
1444 * nvme_get_log_smart() - Retrieve nvme smart log
1445 * @fd: File descriptor of nvme device
1446 * @nsid: Optional namespace identifier
1447 * @rae: Retain asynchronous events
1448 * @smart_log: User address to store the smart log
1449 *
1450 * This log page provides SMART and general health information. The information
1451 * provided is over the life of the controller and is retained across power
1452 * cycles. To request the controller log page, the namespace identifier
1453 * specified is FFFFFFFFh. The controller may also support requesting the log
1454 * page on a per namespace basis, as indicated by bit 0 of the LPA field in the
1455 * Identify Controller data structure.
1456 *
1457 * Return: The nvme command status if a response was received (see
1458 * &enum nvme_status_field) or -1 with errno set otherwise.
1459 */
1460 static inline int nvme_get_log_smart(int fd, __u32 nsid, bool rae,
1461 struct nvme_smart_log *smart_log)
1462 {
1463 return nvme_get_nsid_log(fd, rae, NVME_LOG_LID_SMART,
1464 nsid, sizeof(*smart_log), smart_log);
1465 }
1466
1467 /**
1468 * nvme_get_log_fw_slot() - Retrieves the controller firmware log
1469 * @fd: File descriptor of nvme device
1470 * @rae: Retain asynchronous events
1471 * @fw_log: User address to store the log page
1472 *
1473 * This log page describes the firmware revision stored in each firmware slot
1474 * supported. The firmware revision is indicated as an ASCII string. The log
1475 * page also indicates the active slot number.
1476 *
1477 * Return: The nvme command status if a response was received (see
1478 * &enum nvme_status_field) or -1 with errno set otherwise.
1479 */
1480 static inline int nvme_get_log_fw_slot(int fd, bool rae,
1481 struct nvme_firmware_slot *fw_log)
1482 {
1483 return nvme_get_nsid_log(fd, rae, NVME_LOG_LID_FW_SLOT,
1484 NVME_NSID_ALL, sizeof(*fw_log), fw_log);
1485 }
1486
1487 /**
1488 * nvme_get_log_changed_ns_list() - Retrieve namespace changed list
1489 * @fd: File descriptor of nvme device
1490 * @rae: Retain asynchronous events
1491 * @ns_log: User address to store the log page
1492 *
1493 * This log page describes namespaces attached to this controller that have
1494 * changed since the last time the namespace was identified, been added, or
1495 * deleted.
1496 *
1497 * Return: The nvme command status if a response was received (see
1498 * &enum nvme_status_field) or -1 with errno set otherwise.
1499 */
1500 static inline int nvme_get_log_changed_ns_list(int fd, bool rae,
1501 struct nvme_ns_list *ns_log)
1502 {
1503 return nvme_get_nsid_log(fd, rae, NVME_LOG_LID_CHANGED_NS,
1504 NVME_NSID_ALL, sizeof(*ns_log), ns_log);
1505 }
1506
1507 /**
1508 * nvme_get_log_cmd_effects() - Retrieve nvme command effects log
1509 * @fd: File descriptor of nvme device
1510 * @csi: Command Set Identifier
1511 * @effects_log:User address to store the effects log
1512 *
1513 * This log page describes the commands that the controller supports and the
1514 * effects of those commands on the state of the NVM subsystem.
1515 *
1516 * Return: The nvme command status if a response was received (see
1517 * &enum nvme_status_field) or -1 with errno set otherwise.
1518 */
1519 static inline int nvme_get_log_cmd_effects(int fd, enum nvme_csi csi,
1520 struct nvme_cmd_effects_log *effects_log)
1521 {
1522 struct nvme_get_log_args args = {
1523 .lpo = 0,
1524 .result = NULL,
1525 .log = effects_log,
1526 .args_size = sizeof(args),
1527 .fd = fd,
1528 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
1529 .lid = NVME_LOG_LID_CMD_EFFECTS,
1530 .len = sizeof(*effects_log),
1531 .nsid = NVME_NSID_ALL,
1532 .csi = csi,
1533 .lsi = NVME_LOG_LSI_NONE,
1534 .lsp = NVME_LOG_LSP_NONE,
1535 .uuidx = NVME_UUID_NONE,
1536 .rae = false,
1537 .ot = false,
1538 };
1539 return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
1540 }
1541
1542 /**
1543 * nvme_get_log_device_self_test() - Retrieve the device self test log
1544 * @fd: File descriptor of nvme device
1545 * @log: Userspace address of the log payload
1546 *
1547 * The log page indicates the status of an in progress self test and the
1548 * percent complete of that operation, and the results of the previous 20
1549 * self-test operations.
1550 *
1551 * Return: The nvme command status if a response was received (see
1552 * &enum nvme_status_field) or -1 with errno set otherwise.
1553 */
1554 static inline int nvme_get_log_device_self_test(int fd,
1555 struct nvme_self_test_log *log)
1556 {
1557 return nvme_get_nsid_log(fd, false, NVME_LOG_LID_DEVICE_SELF_TEST,
1558 NVME_NSID_ALL, sizeof(*log), log);
1559 }
1560
1561 /**
1562 * nvme_get_log_create_telemetry_host_mcda() - Create host telemetry log
1563 * @fd: File descriptor of nvme device
1564 * @mcda: Maximum Created Data Area
1565 * @log: Userspace address of the log payload
1566 *
1567 * Return: The nvme command status if a response was received (see
1568 * &enum nvme_status_field) or -1 with errno set otherwise.
1569 */
1570 static inline int nvme_get_log_create_telemetry_host_mcda(int fd,
1571 enum nvme_telemetry_da mcda,
1572 struct nvme_telemetry_log *log)
1573 {
1574 struct nvme_get_log_args args = {
1575 .lpo = 0,
1576 .result = NULL,
1577 .log = log,
1578 .args_size = sizeof(args),
1579 .fd = fd,
1580 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
1581 .lid = NVME_LOG_LID_TELEMETRY_HOST,
1582 .len = sizeof(*log),
1583 .nsid = NVME_NSID_NONE,
1584 .csi = NVME_CSI_NVM,
1585 .lsi = NVME_LOG_LSI_NONE,
1586 .lsp = (__u8)((mcda << 1) | NVME_LOG_TELEM_HOST_LSP_CREATE),
1587 .uuidx = NVME_UUID_NONE,
1588 .rae = false,
1589 .ot = false,
1590 };
1591 return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
1592 }
1593
1594 /**
1595 * nvme_get_log_create_telemetry_host() - Create host telemetry log
1596 * @fd: File descriptor of nvme device
1597 * @log: Userspace address of the log payload
1598 *
1599 * Return: The nvme command status if a response was received (see
1600 * &enum nvme_status_field) or -1 with errno set otherwise.
1601 */
1602 static inline int nvme_get_log_create_telemetry_host(int fd,
1603 struct nvme_telemetry_log *log)
1604 {
1605 return nvme_get_log_create_telemetry_host_mcda(fd, NVME_TELEMETRY_DA_CTRL_DETERMINE, log);
1606 }
1607
1608 /**
1609 * nvme_get_log_telemetry_host() - Get Telemetry Host-Initiated log page
1610 * @fd: File descriptor of nvme device
1611 * @offset: Offset into the telemetry data
1612 * @len: Length of provided user buffer to hold the log data in bytes
1613 * @log: User address for log page data
1614 *
1615 * Retrieves the Telemetry Host-Initiated log page at the requested offset
1616 * using the previously existing capture.
1617 *
1618 * Return: The nvme command status if a response was received (see
1619 * &enum nvme_status_field) or -1 with errno set otherwise.
1620 */
1621 static inline int nvme_get_log_telemetry_host(int fd, __u64 offset,
1622 __u32 len, void *log)
1623 {
1624 struct nvme_get_log_args args = {
1625 .lpo = offset,
1626 .result = NULL,
1627 .log = log,
1628 .args_size = sizeof(args),
1629 .fd = fd,
1630 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
1631 .lid = NVME_LOG_LID_TELEMETRY_HOST,
1632 .len = len,
1633 .nsid = NVME_NSID_NONE,
1634 .csi = NVME_CSI_NVM,
1635 .lsi = NVME_LOG_LSI_NONE,
1636 .lsp = NVME_LOG_TELEM_HOST_LSP_RETAIN,
1637 .uuidx = NVME_UUID_NONE,
1638 .rae = false,
1639 .ot = false,
1640 };
1641 return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
1642 }
1643
1644 /**
1645 * nvme_get_log_telemetry_ctrl() - Get Telemetry Controller-Initiated log page
1646 * @fd: File descriptor of nvme device
1647 * @rae: Retain asynchronous events
1648 * @offset: Offset into the telemetry data
1649 * @len: Length of provided user buffer to hold the log data in bytes
1650 * @log: User address for log page data
1651 *
1652 * Retrieves the Telemetry Controller-Initiated log page at the requested offset
1653 * using the previously existing capture.
1654 *
1655 * Return: The nvme command status if a response was received (see
1656 * &enum nvme_status_field) or -1 with errno set otherwise.
1657 */
1658 static inline int nvme_get_log_telemetry_ctrl(int fd, bool rae,
1659 __u64 offset, __u32 len, void *log)
1660 {
1661 struct nvme_get_log_args args = {
1662 .lpo = offset,
1663 .result = NULL,
1664 .log = log,
1665 .args_size = sizeof(args),
1666 .fd = fd,
1667 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
1668 .lid = NVME_LOG_LID_TELEMETRY_CTRL,
1669 .len = len,
1670 .nsid = NVME_NSID_NONE,
1671 .csi = NVME_CSI_NVM,
1672 .lsi = NVME_LOG_LSI_NONE,
1673 .lsp = NVME_LOG_LSP_NONE,
1674 .uuidx = NVME_UUID_NONE,
1675 .rae = rae,
1676 .ot = false,
1677 };
1678 return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
1679 }
1680
1681 /**
1682 * nvme_get_log_endurance_group() - Get Endurance Group log
1683 * @fd: File descriptor of nvme device
1684 * @endgid: Starting group identifier to return in the list
1685 * @log: User address to store the endurance log
1686 *
1687 * This log page indicates if an Endurance Group Event has occurred for a
1688 * particular Endurance Group. If an Endurance Group Event has occurred, the
1689 * details of the particular event are included in the Endurance Group
1690 * Information log page for that Endurance Group. An asynchronous event is
1691 * generated when an entry for an Endurance Group is newly added to this log
1692 * page.
1693 *
1694 * Return: The nvme command status if a response was received (see
1695 * &enum nvme_status_field) or -1 with errno set otherwise.
1696 */
1697 static inline int nvme_get_log_endurance_group(int fd, __u16 endgid,
1698 struct nvme_endurance_group_log *log)
1699 {
1700 struct nvme_get_log_args args = {
1701 .lpo = 0,
1702 .result = NULL,
1703 .log = log,
1704 .args_size = sizeof(args),
1705 .fd = fd,
1706 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
1707 .lid = NVME_LOG_LID_ENDURANCE_GROUP,
1708 .len = sizeof(*log),
1709 .nsid = NVME_NSID_NONE,
1710 .csi = NVME_CSI_NVM,
1711 .lsi = endgid,
1712 .lsp = NVME_LOG_LSP_NONE,
1713 .uuidx = NVME_UUID_NONE,
1714 .rae = false,
1715 .ot = false,
1716 };
1717 return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
1718 }
1719
1720 /**
1721 * nvme_get_log_predictable_lat_nvmset() - Predictable Latency Per NVM Set
1722 * @fd: File descriptor of nvme device
1723 * @nvmsetid: NVM set id
1724 * @log: User address to store the predictable latency log
1725 *
1726 * Return: The nvme command status if a response was received (see
1727 * &enum nvme_status_field) or -1 with errno set otherwise.
1728 */
1729 static inline int nvme_get_log_predictable_lat_nvmset(int fd, __u16 nvmsetid,
1730 struct nvme_nvmset_predictable_lat_log *log)
1731 {
1732 struct nvme_get_log_args args = {
1733 .lpo = 0,
1734 .result = NULL,
1735 .log = log,
1736 .args_size = sizeof(args),
1737 .fd = fd,
1738 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
1739 .lid = NVME_LOG_LID_PREDICTABLE_LAT_NVMSET,
1740 .len = sizeof(*log),
1741 .nsid = NVME_NSID_NONE,
1742 .csi = NVME_CSI_NVM,
1743 .lsi = nvmsetid,
1744 .lsp = NVME_LOG_LSP_NONE,
1745 .uuidx = NVME_UUID_NONE,
1746 .rae = false,
1747 .ot = false,
1748 };
1749 return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
1750 }
1751
1752 /**
1753 * nvme_get_log_predictable_lat_event() - Retrieve Predictable Latency Event Aggregate Log Page
1754 * @fd: File descriptor of nvme device
1755 * @rae: Retain asynchronous events
1756 * @offset: Offset into the predictable latency event
1757 * @len: Length of provided user buffer to hold the log data in bytes
1758 * @log: User address for log page data
1759 *
1760 * Return: The nvme command status if a response was received (see
1761 * &enum nvme_status_field) or -1 with errno set otherwise.
1762 */
1763 static inline int nvme_get_log_predictable_lat_event(int fd, bool rae,
1764 __u32 offset, __u32 len, void *log)
1765 {
1766 struct nvme_get_log_args args = {
1767 .lpo = offset,
1768 .result = NULL,
1769 .log = log,
1770 .args_size = sizeof(args),
1771 .fd = fd,
1772 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
1773 .lid = NVME_LOG_LID_PREDICTABLE_LAT_AGG,
1774 .len = len,
1775 .nsid = NVME_NSID_NONE,
1776 .csi = NVME_CSI_NVM,
1777 .lsi = NVME_LOG_LSI_NONE,
1778 .lsp = NVME_LOG_LSP_NONE,
1779 .uuidx = NVME_UUID_NONE,
1780 .rae = rae,
1781 .ot = false,
1782 };
1783 return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
1784 }
1785
1786 /**
1787 * nvme_get_log_fdp_configurations() - Get list of Flexible Data Placement configurations
1788 * @fd: File descriptor of nvme device
1789 * @egid: Endurance group identifier
1790 * @offset: Offset into log page
1791 * @len: Length (in bytes) of provided user buffer to hold the log data
1792 * @log: Log page data buffer
1793 */
1794 static inline int nvme_get_log_fdp_configurations(int fd, __u16 egid,
1795 __u32 offset, __u32 len, void *log)
1796 {
1797 struct nvme_get_log_args args = {
1798 .lpo = offset,
1799 .result = NULL,
1800 .log = log,
1801 .args_size = sizeof(args),
1802 .fd = fd,
1803 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
1804 .lid = NVME_LOG_LID_FDP_CONFIGS,
1805 .len = len,
1806 .nsid = NVME_NSID_NONE,
1807 .csi = NVME_CSI_NVM,
1808 .lsi = egid,
1809 .lsp = NVME_LOG_LSP_NONE,
1810 .uuidx = NVME_UUID_NONE,
1811 };
1812
1813 return nvme_get_log(&args);
1814 }
1815
1816 /**
1817 * nvme_get_log_reclaim_unit_handle_usage() - Get reclaim unit handle usage
1818 * @fd: File descriptor of nvme device
1819 * @egid: Endurance group identifier
1820 * @offset: Offset into log page
1821 * @len: Length (in bytes) of provided user buffer to hold the log data
1822 * @log: Log page data buffer
1823 */
1824 static inline int nvme_get_log_reclaim_unit_handle_usage(int fd, __u16 egid,
1825 __u32 offset, __u32 len, void *log)
1826 {
1827 struct nvme_get_log_args args = {
1828 .lpo = offset,
1829 .result = NULL,
1830 .log = log,
1831 .args_size = sizeof(args),
1832 .fd = fd,
1833 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
1834 .lid = NVME_LOG_LID_FDP_RUH_USAGE,
1835 .len = len,
1836 .nsid = NVME_NSID_NONE,
1837 .csi = NVME_CSI_NVM,
1838 .lsi = egid,
1839 .lsp = NVME_LOG_LSP_NONE,
1840 .uuidx = NVME_UUID_NONE,
1841 };
1842
1843 return nvme_get_log(&args);
1844 }
1845
1846 /**
1847 * nvme_get_log_fdp_stats() - Get Flexible Data Placement statistics
1848 * @fd: File descriptor of nvme device
1849 * @egid: Endurance group identifier
1850 * @offset: Offset into log page
1851 * @len: Length (in bytes) of provided user buffer to hold the log data
1852 * @log: Log page data buffer
1853 */
1854 static inline int nvme_get_log_fdp_stats(int fd, __u16 egid, __u32 offset, __u32 len, void *log)
1855 {
1856 struct nvme_get_log_args args = {
1857 .lpo = offset,
1858 .result = NULL,
1859 .log = log,
1860 .args_size = sizeof(args),
1861 .fd = fd,
1862 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
1863 .lid = NVME_LOG_LID_FDP_STATS,
1864 .len = len,
1865 .nsid = NVME_NSID_NONE,
1866 .csi = NVME_CSI_NVM,
1867 .lsi = egid,
1868 .lsp = NVME_LOG_LSP_NONE,
1869 .uuidx = NVME_UUID_NONE,
1870 };
1871
1872 return nvme_get_log(&args);
1873 }
1874
1875 /**
1876 * nvme_get_log_fdp_events() - Get Flexible Data Placement events
1877 * @fd: File descriptor of nvme device
1878 * @egid: Endurance group identifier
1879 * @host_events: Whether to report host or controller events
1880 * @offset: Offset into log page
1881 * @len: Length (in bytes) of provided user buffer to hold the log data
1882 * @log: Log page data buffer
1883 */
1884 static inline int nvme_get_log_fdp_events(int fd, __u16 egid, bool host_events, __u32 offset,
1885 __u32 len, void *log)
1886 {
1887 struct nvme_get_log_args args = {
1888 .lpo = offset,
1889 .result = NULL,
1890 .log = log,
1891 .args_size = sizeof(args),
1892 .fd = fd,
1893 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
1894 .lid = NVME_LOG_LID_FDP_EVENTS,
1895 .len = len,
1896 .nsid = NVME_NSID_NONE,
1897 .csi = NVME_CSI_NVM,
1898 .lsi = egid,
1899 .lsp = (__u8)(host_events ? 0x1 : 0x0),
1900 .uuidx = NVME_UUID_NONE,
1901 };
1902
1903 return nvme_get_log(&args);
1904 }
1905
1906 /**
1907 * nvme_get_log_ana() - Retrieve Asymmetric Namespace Access log page
1908 * @fd: File descriptor of nvme device
1909 * @lsp: Log specific, see &enum nvme_get_log_ana_lsp
1910 * @rae: Retain asynchronous events
1911 * @offset: Offset to the start of the log page
1912 * @len: The allocated length of the log page
1913 * @log: User address to store the ana log
1914 *
1915 * This log consists of a header describing the log and descriptors containing
1916 * the asymmetric namespace access information for ANA Groups that contain
1917 * namespaces that are attached to the controller processing the command.
1918 *
1919 * See &struct nvme_ana_log for the definition of the returned structure.
1920 *
1921 * Return: The nvme command status if a response was received (see
1922 * &enum nvme_status_field) or -1 with errno set otherwise.
1923 */
1924 static inline int nvme_get_log_ana(int fd, enum nvme_log_ana_lsp lsp, bool rae,
1925 __u64 offset, __u32 len, void *log)
1926 {
1927 struct nvme_get_log_args args = {
1928 .lpo = offset,
1929 .result = NULL,
1930 .log = log,
1931 .args_size = sizeof(args),
1932 .fd = fd,
1933 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
1934 .lid = NVME_LOG_LID_ANA,
1935 .len = len,
1936 .nsid = NVME_NSID_NONE,
1937 .csi = NVME_CSI_NVM,
1938 .lsi = NVME_LOG_LSI_NONE,
1939 .lsp = (__u8)lsp,
1940 .uuidx = NVME_UUID_NONE,
1941 .rae = rae,
1942 .ot = false,
1943 };
1944 return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
1945 }
1946
1947 /**
1948 * nvme_get_log_ana_groups() - Retrieve Asymmetric Namespace Access groups only log page
1949 * @fd: File descriptor of nvme device
1950 * @rae: Retain asynchronous events
1951 * @len: The allocated length of the log page
1952 * @log: User address to store the ana group log
1953 *
1954 * See &struct nvme_ana_log for the definition of the returned structure.
1955 *
1956 * Return: The nvme command status if a response was received (see
1957 * &enum nvme_status_field) or -1 with errno set otherwise.
1958 */
1959 static inline int nvme_get_log_ana_groups(int fd, bool rae, __u32 len,
1960 struct nvme_ana_log *log)
1961 {
1962 return nvme_get_log_ana(fd, NVME_LOG_ANA_LSP_RGO_GROUPS_ONLY, rae, 0,
1963 len, log);
1964 }
1965
1966 /**
1967 * nvme_get_ana_log_atomic() - Retrieve Asymmetric Namespace Access log page atomically
1968 * @fd: File descriptor of nvme device
1969 * @rgo: Whether to retrieve ANA groups only (no NSIDs)
1970 * @rae: Whether to retain asynchronous events
1971 * @retries: The maximum number of times to retry on log page changes
1972 * @log: Pointer to a buffer to receive the ANA log page
1973 * @len: Input: the length of the log page buffer.
1974 * Output: the actual length of the ANA log page.
1975 *
1976 * See &struct nvme_ana_log for the definition of the returned structure.
1977 *
1978 * Return: If successful, returns 0 and sets *len to the actual log page length.
1979 * If unsuccessful, returns the nvme command status if a response was received
1980 * (see &enum nvme_status_field) or -1 with errno set otherwise.
1981 * Sets errno = EINVAL if retries == 0.
1982 * Sets errno = EAGAIN if unable to read the log page atomically
1983 * because chgcnt changed during each of the retries attempts.
1984 * Sets errno = ENOSPC if the full log page does not fit in the provided buffer.
1985 */
1986 int nvme_get_ana_log_atomic(int fd, bool rgo, bool rae, unsigned int retries,
1987 struct nvme_ana_log *log, __u32 *len);
1988
1989 /**
1990 * nvme_get_log_lba_status() - Retrieve LBA Status
1991 * @fd: File descriptor of nvme device
1992 * @rae: Retain asynchronous events
1993 * @offset: Offset to the start of the log page
1994 * @len: The allocated length of the log page
1995 * @log: User address to store the log page
1996 *
1997 * Return: The nvme command status if a response was received (see
1998 * &enum nvme_status_field) or -1 with errno set otherwise.
1999 */
2000 static inline int nvme_get_log_lba_status(int fd, bool rae,
2001 __u64 offset, __u32 len, void *log)
2002 {
2003 struct nvme_get_log_args args = {
2004 .lpo = offset,
2005 .result = NULL,
2006 .log = log,
2007 .args_size = sizeof(args),
2008 .fd = fd,
2009 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
2010 .lid = NVME_LOG_LID_LBA_STATUS,
2011 .len = len,
2012 .nsid = NVME_NSID_NONE,
2013 .csi = NVME_CSI_NVM,
2014 .lsi = NVME_LOG_LSI_NONE,
2015 .lsp = NVME_LOG_LSP_NONE,
2016 .uuidx = NVME_UUID_NONE,
2017 .rae = rae,
2018 .ot = false,
2019 };
2020 return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
2021 }
2022
2023 /**
2024 * nvme_get_log_endurance_grp_evt() - Retrieve Endurance Group Event Aggregate
2025 * @fd: File descriptor of nvme device
2026 * @rae: Retain asynchronous events
2027 * @offset: Offset to the start of the log page
2028 * @len: The allocated length of the log page
2029 * @log: User address to store the log page
2030 *
2031 * Return: The nvme command status if a response was received (see
2032 * &enum nvme_status_field) or -1 with errno set otherwise.
2033 */
2034 static inline int nvme_get_log_endurance_grp_evt(int fd, bool rae,
2035 __u32 offset, __u32 len, void *log)
2036 {
2037 struct nvme_get_log_args args = {
2038 .lpo = offset,
2039 .result = NULL,
2040 .log = log,
2041 .args_size = sizeof(args),
2042 .fd = fd,
2043 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
2044 .lid = NVME_LOG_LID_ENDURANCE_GRP_EVT,
2045 .len = len,
2046 .nsid = NVME_NSID_NONE,
2047 .csi = NVME_CSI_NVM,
2048 .lsi = NVME_LOG_LSI_NONE,
2049 .lsp = NVME_LOG_LSP_NONE,
2050 .uuidx = NVME_UUID_NONE,
2051 .rae = rae,
2052 .ot = false,
2053 };
2054 return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
2055 }
2056
2057 /**
2058 * nvme_get_log_fid_supported_effects() - Retrieve Feature Identifiers Supported and Effects
2059 * @fd: File descriptor of nvme device
2060 * @rae: Retain asynchronous events
2061 * @log: FID Supported and Effects data structure
2062 *
2063 * Return: The nvme command status if a response was received (see
2064 * &enum nvme_status_field) or -1 with errno set otherwise
2065 */
2066 static inline int nvme_get_log_fid_supported_effects(int fd, bool rae,
2067 struct nvme_fid_supported_effects_log *log)
2068 {
2069 return nvme_get_nsid_log(fd, rae, NVME_LOG_LID_FID_SUPPORTED_EFFECTS,
2070 NVME_NSID_NONE, sizeof(*log), log);
2071 }
2072
2073 /**
2074 * nvme_get_log_mi_cmd_supported_effects() - displays the MI Commands Supported by the controller
2075 * @fd: File descriptor of nvme device
2076 * @rae: Retain asynchronous events
2077 * @log: MI Command Supported and Effects data structure
2078 *
2079 * Return: The nvme command status if a response was received (see
2080 * &enum nvme_status_field) or -1 with errno set otherwise
2081 */
2082 static inline int nvme_get_log_mi_cmd_supported_effects(int fd, bool rae,
2083 struct nvme_mi_cmd_supported_effects_log *log)
2084 {
2085 return nvme_get_nsid_log(fd, rae, NVME_LOG_LID_MI_CMD_SUPPORTED_EFFECTS,
2086 NVME_NSID_NONE, sizeof(*log), log);
2087 }
2088
2089 /**
2090 * nvme_get_log_boot_partition() - Retrieve Boot Partition
2091 * @fd: File descriptor of nvme device
2092 * @rae: Retain asynchronous events
2093 * @lsp: The log specified field of LID
2094 * @len: The allocated size, minimum
2095 * struct nvme_boot_partition
2096 * @part: User address to store the log page
2097 *
2098 * Return: The nvme command status if a response was received (see
2099 * &enum nvme_status_field) or -1 with errno set otherwise
2100 */
2101 static inline int nvme_get_log_boot_partition(int fd, bool rae,
2102 __u8 lsp, __u32 len, struct nvme_boot_partition *part)
2103 {
2104 struct nvme_get_log_args args = {
2105 .lpo = 0,
2106 .result = NULL,
2107 .log = part,
2108 .args_size = sizeof(args),
2109 .fd = fd,
2110 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
2111 .lid = NVME_LOG_LID_BOOT_PARTITION,
2112 .len = len,
2113 .nsid = NVME_NSID_NONE,
2114 .csi = NVME_CSI_NVM,
2115 .lsi = NVME_LOG_LSI_NONE,
2116 .lsp = lsp,
2117 .uuidx = NVME_UUID_NONE,
2118 .rae = rae,
2119 .ot = false,
2120 };
2121 return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
2122 }
2123
2124 /**
2125 * nvme_get_log_rotational_media_info() - Retrieve Rotational Media Information Log
2126 * @fd: File descriptor of nvme device
2127 * @endgid: Endurance Group Identifier
2128 * @len: The allocated length of the log page
2129 * @log: User address to store the log page
2130 *
2131 * Return: The nvme command status if a response was received (see
2132 * &enum nvme_status_field) or -1 with errno set otherwise
2133 */
2134 static inline int nvme_get_log_rotational_media_info(int fd, __u16 endgid, __u32 len,
2135 struct nvme_rotational_media_info_log *log)
2136 {
2137 return nvme_get_endgid_log(fd, false, NVME_LOG_LID_ROTATIONAL_MEDIA_INFO, endgid, len, log);
2138 }
2139
2140 /**
2141 * nvme_get_log_dispersed_ns_participating_nss() - Retrieve Dispersed Namespace Participating NVM
2142 * Subsystems Log
2143 * @fd: File descriptor of nvme device
2144 * @nsid: Namespace Identifier
2145 * @len: The allocated length of the log page
2146 * @log: User address to store the log page
2147 *
2148 * Return: The nvme command status if a response was received (see
2149 * &enum nvme_status_field) or -1 with errno set otherwise
2150 */
2151 static inline int nvme_get_log_dispersed_ns_participating_nss(int fd, __u32 nsid, __u32 len,
2152 struct nvme_dispersed_ns_participating_nss_log *log)
2153 {
2154 return nvme_get_nsid_log(fd, false, NVME_LOG_LID_DISPERSED_NS_PARTICIPATING_NSS, nsid, len,
2155 log);
2156 }
2157
2158 /**
2159 * nvme_get_log_mgmt_addr_list() - Retrieve Management Address List Log
2160 * @fd: File descriptor of nvme device
2161 * @len: The allocated length of the log page
2162 * @log: User address to store the log page
2163 *
2164 * Return: The nvme command status if a response was received (see
2165 * &enum nvme_status_field) or -1 with errno set otherwise
2166 */
2167 static inline int nvme_get_log_mgmt_addr_list(int fd, __u32 len,
2168 struct nvme_mgmt_addr_list_log *log)
2169 {
2170 return nvme_get_log_simple(fd, NVME_LOG_LID_MGMT_ADDR_LIST, len, log);
2171 }
2172
2173 /**
2174 * nvme_get_log_phy_rx_eom() - Retrieve Physical Interface Receiver Eye Opening Measurement Log
2175 * @fd: File descriptor of nvme device
2176 * @lsp: Log specific, controls action and measurement quality
2177 * @controller: Target controller ID
2178 * @len: The allocated size, minimum
2179 * struct nvme_phy_rx_eom_log
2180 * @log: User address to store the log page
2181 *
2182 * Return: The nvme command status if a response was received (see
2183 * &enum nvme_status_field) or -1 with errno set otherwise
2184 */
2185 static inline int nvme_get_log_phy_rx_eom(int fd, __u8 lsp, __u16 controller,
2186 __u32 len, struct nvme_phy_rx_eom_log *log)
2187 {
2188 struct nvme_get_log_args args = {
2189 .lpo = 0,
2190 .result = NULL,
2191 .log = log,
2192 .args_size = sizeof(args),
2193 .fd = fd,
2194 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
2195 .lid = NVME_LOG_LID_PHY_RX_EOM,
2196 .len = len,
2197 .nsid = NVME_NSID_NONE,
2198 .csi = NVME_CSI_NVM,
2199 .lsi = controller,
2200 .lsp = lsp,
2201 .uuidx = NVME_UUID_NONE,
2202 .rae = false,
2203 .ot = false,
2204 };
2205 return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
2206 }
2207
2208 /**
2209 * nvme_get_log_reachability_groups() - Retrieve Reachability Groups Log
2210 * @fd: File descriptor of nvme device
2211 * @rgo: Return groups only
2212 * @rae: Retain asynchronous events
2213 * @len: The allocated length of the log page
2214 * @log: User address to store the log page
2215 *
2216 * Return: The nvme command status if a response was received (see
2217 * &enum nvme_status_field) or -1 with errno set otherwise
2218 */
2219 static inline int nvme_get_log_reachability_groups(int fd, bool rgo, bool rae, __u32 len,
2220 struct nvme_reachability_groups_log *log)
2221 {
2222 struct nvme_get_log_args args = {
2223 .lpo = 0,
2224 .result = NULL,
2225 .log = log,
2226 .args_size = sizeof(args),
2227 .fd = fd,
2228 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
2229 .lid = NVME_LOG_LID_REACHABILITY_GROUPS,
2230 .len = len,
2231 .nsid = NVME_NSID_ALL,
2232 .csi = NVME_CSI_NVM,
2233 .lsi = NVME_LOG_LSI_NONE,
2234 .lsp = rgo,
2235 .uuidx = NVME_LOG_LSP_NONE,
2236 .rae = rae,
2237 .ot = false,
2238 };
2239
2240 return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
2241 }
2242
2243 /**
2244 * nvme_get_log_reachability_associations() - Retrieve Reachability Associations Log
2245 * @fd: File descriptor of nvme device
2246 * @rao: Return associations only
2247 * @rae: Retain asynchronous events
2248 * @len: The allocated length of the log page
2249 * @log: User address to store the log page
2250 *
2251 * Return: The nvme command status if a response was received (see
2252 * &enum nvme_status_field) or -1 with errno set otherwise
2253 */
2254 static inline int nvme_get_log_reachability_associations(int fd, bool rao, bool rae, __u32 len,
2255 struct nvme_reachability_associations_log *log)
2256 {
2257 struct nvme_get_log_args args = {
2258 .lpo = 0,
2259 .result = NULL,
2260 .log = log,
2261 .args_size = sizeof(args),
2262 .fd = fd,
2263 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
2264 .lid = NVME_LOG_LID_REACHABILITY_ASSOCIATIONS,
2265 .len = len,
2266 .nsid = NVME_NSID_ALL,
2267 .csi = NVME_CSI_NVM,
2268 .lsi = NVME_LOG_LSI_NONE,
2269 .lsp = rao,
2270 .uuidx = NVME_LOG_LSP_NONE,
2271 .rae = rae,
2272 .ot = false,
2273 };
2274
2275 return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
2276 }
2277
2278 /**
2279 * nvme_get_log_changed_alloc_ns_list() - Retrieve Changed Allocated Namespace List Log
2280 * @fd: File descriptor of nvme device
2281 * @rae: Retain asynchronous events
2282 * @len: The allocated length of the log page
2283 * @log: User address to store the log page
2284 *
2285 * Return: The nvme command status if a response was received (see
2286 * &enum nvme_status_field) or -1 with errno set otherwise
2287 */
2288 static inline int nvme_get_log_changed_alloc_ns_list(int fd, bool rae, __u32 len,
2289 struct nvme_ns_list *log)
2290 {
2291 return nvme_get_nsid_log(fd, rae, NVME_LOG_LID_CHANGED_ALLOC_NS_LIST, NVME_NSID_ALL, len,
2292 log);
2293 }
2294
2295 /**
2296 * nvme_get_log_discovery() - Retrieve Discovery log page
2297 * @fd: File descriptor of nvme device
2298 * @rae: Retain asynchronous events
2299 * @offset: Offset of this log to retrieve
2300 * @len: The allocated size for this portion of the log
2301 * @log: User address to store the discovery log
2302 *
2303 * Supported only by fabrics discovery controllers, returning discovery
2304 * records.
2305 *
2306 * Return: The nvme command status if a response was received (see
2307 * &enum nvme_status_field) or -1 with errno set otherwise.
2308 */
2309 static inline int nvme_get_log_discovery(int fd, bool rae,
2310 __u32 offset, __u32 len, void *log)
2311 {
2312 struct nvme_get_log_args args = {
2313 .lpo = offset,
2314 .result = NULL,
2315 .log = log,
2316 .args_size = sizeof(args),
2317 .fd = fd,
2318 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
2319 .lid = NVME_LOG_LID_DISCOVER,
2320 .len = len,
2321 .nsid = NVME_NSID_NONE,
2322 .csi = NVME_CSI_NVM,
2323 .lsi = NVME_LOG_LSI_NONE,
2324 .lsp = NVME_LOG_LSP_NONE,
2325 .uuidx = NVME_UUID_NONE,
2326 .rae = rae,
2327 .ot = false,
2328 };
2329 return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
2330 }
2331
2332 /**
2333 * nvme_get_log_host_discover() - Retrieve Host Discovery Log
2334 * @fd: File descriptor of nvme device
2335 * @allhoste: All host entries
2336 * @rae: Retain asynchronous events
2337 * @len: The allocated length of the log page
2338 * @log: User address to store the log page
2339 *
2340 * Return: The nvme command status if a response was received (see
2341 * &enum nvme_status_field) or -1 with errno set otherwise
2342 */
2343 static inline int nvme_get_log_host_discover(int fd, bool allhoste, bool rae, __u32 len,
2344 struct nvme_host_discover_log *log)
2345 {
2346 struct nvme_get_log_args args = {
2347 .lpo = 0,
2348 .result = NULL,
2349 .log = log,
2350 .args_size = sizeof(args),
2351 .fd = fd,
2352 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
2353 .lid = NVME_LOG_LID_HOST_DISCOVER,
2354 .len = len,
2355 .nsid = NVME_NSID_ALL,
2356 .csi = NVME_CSI_NVM,
2357 .lsi = NVME_LOG_LSI_NONE,
2358 .lsp = allhoste,
2359 .uuidx = NVME_LOG_LSP_NONE,
2360 .rae = rae,
2361 .ot = false,
2362 };
2363
2364 return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
2365 }
2366
2367 /**
2368 * nvme_get_log_ave_discover() - Retrieve AVE Discovery Log
2369 * @fd: File descriptor of nvme device
2370 * @rae: Retain asynchronous events
2371 * @len: The allocated length of the log page
2372 * @log: User address to store the log page
2373 *
2374 * Return: The nvme command status if a response was received (see
2375 * &enum nvme_status_field) or -1 with errno set otherwise
2376 */
2377 static inline int nvme_get_log_ave_discover(int fd, bool rae, __u32 len,
2378 struct nvme_ave_discover_log *log)
2379 {
2380 return nvme_get_nsid_log(fd, rae, NVME_LOG_LID_AVE_DISCOVER, NVME_NSID_ALL, len, log);
2381 }
2382
2383 /**
2384 * nvme_get_log_pull_model_ddc_req() - Retrieve Pull Model DDC Request Log
2385 * @fd: File descriptor of nvme device
2386 * @rae: Retain asynchronous events
2387 * @len: The allocated length of the log page
2388 * @log: User address to store the log page
2389 *
2390 * Return: The nvme command status if a response was received (see
2391 * &enum nvme_status_field) or -1 with errno set otherwise
2392 */
2393 static inline int nvme_get_log_pull_model_ddc_req(int fd, bool rae, __u32 len,
2394 struct nvme_pull_model_ddc_req_log *log)
2395 {
2396 return nvme_get_nsid_log(fd, rae, NVME_LOG_LID_PULL_MODEL_DDC_REQ, NVME_NSID_ALL, len, log);
2397 }
2398
2399 /**
2400 * nvme_get_log_media_unit_stat() - Retrieve Media Unit Status
2401 * @fd: File descriptor of nvme device
2402 * @domid: Domain Identifier selection, if supported
2403 * @mus: User address to store the Media Unit statistics log
2404 *
2405 * Return: The nvme command status if a response was received (see
2406 * &enum nvme_status_field) or -1 with errno set otherwise
2407 */
2408 static inline int nvme_get_log_media_unit_stat(int fd, __u16 domid,
2409 struct nvme_media_unit_stat_log *mus)
2410 {
2411 struct nvme_get_log_args args = {
2412 .lpo = 0,
2413 .result = NULL,
2414 .log = mus,
2415 .args_size = sizeof(args),
2416 .fd = fd,
2417 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
2418 .lid = NVME_LOG_LID_MEDIA_UNIT_STATUS,
2419 .len = sizeof(*mus),
2420 .nsid = NVME_NSID_NONE,
2421 .csi = NVME_CSI_NVM,
2422 .lsi = domid,
2423 .lsp = NVME_LOG_LSP_NONE,
2424 .uuidx = NVME_UUID_NONE,
2425 .rae = false,
2426 .ot = false,
2427 };
2428 return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
2429 }
2430
2431 /**
2432 * nvme_get_log_support_cap_config_list() - Retrieve Supported Capacity Configuration List
2433 * @fd: File descriptor of nvme device
2434 * @domid: Domain Identifier selection, if supported
2435 * @cap: User address to store supported capabilities config list
2436 *
2437 * Return: The nvme command status if a response was received (see
2438 * &enum nvme_status_field) or -1 with errno set otherwise
2439 */
2440 static inline int nvme_get_log_support_cap_config_list(int fd, __u16 domid,
2441 struct nvme_supported_cap_config_list_log *cap)
2442 {
2443 struct nvme_get_log_args args = {
2444 .lpo = 0,
2445 .result = NULL,
2446 .log = cap,
2447 .args_size = sizeof(args),
2448 .fd = fd,
2449 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
2450 .lid = NVME_LOG_LID_SUPPORTED_CAP_CONFIG_LIST,
2451 .len = sizeof(*cap),
2452 .nsid = NVME_NSID_NONE,
2453 .csi = NVME_CSI_NVM,
2454 .lsi = domid,
2455 .lsp = NVME_LOG_LSP_NONE,
2456 .uuidx = NVME_UUID_NONE,
2457 .rae = false,
2458 .ot = false,
2459 };
2460 return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
2461 }
2462
2463 /**
2464 * nvme_get_log_reservation() - Retrieve Reservation Notification
2465 * @fd: File descriptor of nvme device
2466 * @rae: Retain asynchronous events
2467 * @log: User address to store the reservation log
2468 *
2469 * Return: The nvme command status if a response was received (see
2470 * &enum nvme_status_field) or -1 with errno set otherwise
2471 */
2472 static inline int nvme_get_log_reservation(int fd, bool rae,
2473 struct nvme_resv_notification_log *log)
2474 {
2475 return nvme_get_nsid_log(fd, rae, NVME_LOG_LID_RESERVATION,
2476 NVME_NSID_ALL, sizeof(*log), log);
2477 }
2478
2479 /**
2480 * nvme_get_log_sanitize() - Retrieve Sanitize Status
2481 * @fd: File descriptor of nvme device
2482 * @rae: Retain asynchronous events
2483 * @log: User address to store the sanitize log
2484 *
2485 * The Sanitize Status log page reports sanitize operation time estimates and
2486 * information about the most recent sanitize operation.
2487 *
2488 * Return: The nvme command status if a response was received (see
2489 * &enum nvme_status_field) or -1 with errno set otherwise.
2490 */
2491 static inline int nvme_get_log_sanitize(int fd, bool rae,
2492 struct nvme_sanitize_log_page *log)
2493 {
2494 return nvme_get_nsid_log(fd, rae, NVME_LOG_LID_SANITIZE,
2495 NVME_NSID_ALL, sizeof(*log), log);
2496 }
2497
2498 /**
2499 * nvme_get_log_zns_changed_zones() - Retrieve list of zones that have changed
2500 * @fd: File descriptor of nvme device
2501 * @nsid: Namespace ID
2502 * @rae: Retain asynchronous events
2503 * @log: User address to store the changed zone log
2504 *
2505 * The list of zones that have changed state due to an exceptional event.
2506 *
2507 * Return: The nvme command status if a response was received (see
2508 * &enum nvme_status_field) or -1 with errno set otherwise.
2509 */
2510 static inline int nvme_get_log_zns_changed_zones(int fd, __u32 nsid, bool rae,
2511 struct nvme_zns_changed_zone_log *log)
2512 {
2513 struct nvme_get_log_args args = {
2514 .lpo = 0,
2515 .result = NULL,
2516 .log = log,
2517 .args_size = sizeof(args),
2518 .fd = fd,
2519 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
2520 .lid = NVME_LOG_LID_ZNS_CHANGED_ZONES,
2521 .len = sizeof(*log),
2522 .nsid = nsid,
2523 .csi = NVME_CSI_ZNS,
2524 .lsi = NVME_LOG_LSI_NONE,
2525 .lsp = NVME_LOG_LSP_NONE,
2526 .uuidx = NVME_UUID_NONE,
2527 .rae = rae,
2528 .ot = false,
2529 };
2530 return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
2531 }
2532
2533 /**
2534 * nvme_get_log_persistent_event() - Retrieve Persistent Event Log
2535 * @fd: File descriptor of nvme device
2536 * @action: Action the controller should take during processing this command
2537 * @size: Size of @pevent_log
2538 * @pevent_log: User address to store the persistent event log
2539 *
2540 * Return: The nvme command status if a response was received (see
2541 * &enum nvme_status_field) or -1 with errno set otherwise.
2542 */
2543 static inline int nvme_get_log_persistent_event(int fd,
2544 enum nvme_pevent_log_action action,
2545 __u32 size, void *pevent_log)
2546 {
2547 struct nvme_get_log_args args = {
2548 .lpo = 0,
2549 .result = NULL,
2550 .log = pevent_log,
2551 .args_size = sizeof(args),
2552 .fd = fd,
2553 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
2554 .lid = NVME_LOG_LID_PERSISTENT_EVENT,
2555 .len = size,
2556 .nsid = NVME_NSID_ALL,
2557 .csi = NVME_CSI_NVM,
2558 .lsi = NVME_LOG_LSI_NONE,
2559 .lsp = (__u8)action,
2560 .uuidx = NVME_UUID_NONE,
2561 .rae = false,
2562 .ot = false,
2563 };
2564 return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
2565 }
2566
2567 /**
2568 * nvme_get_log_lockdown() - Retrieve lockdown Log
2569 * @fd: File descriptor of nvme device
2570 * @cnscp: Contents and Scope of Command and Feature Identifier Lists
2571 * @lockdown_log: Buffer to store the lockdown log
2572 *
2573 * Return: The nvme command status if a response was received (see
2574 * &enum nvme_status_field) or -1 with errno set otherwise.
2575 */
2576 static inline int nvme_get_log_lockdown(int fd,
2577 __u8 cnscp, struct nvme_lockdown_log *lockdown_log)
2578 {
2579 struct nvme_get_log_args args = {
2580 .lpo = 0,
2581 .result = NULL,
2582 .log = lockdown_log,
2583 .args_size = sizeof(args),
2584 .fd = fd,
2585 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
2586 .lid = NVME_LOG_LID_CMD_AND_FEAT_LOCKDOWN,
2587 .len = sizeof(*lockdown_log),
2588 .nsid = NVME_NSID_ALL,
2589 .csi = NVME_CSI_NVM,
2590 .lsi = NVME_LOG_LSI_NONE,
2591 .lsp = cnscp,
2592 .uuidx = NVME_UUID_NONE,
2593 .rae = false,
2594 .ot = false,
2595 };
2596 return nvme_get_log_page(fd, NVME_LOG_PAGE_PDU_SIZE, &args);
2597 }
2598
2599 /**
2600 * nvme_set_features() - Set a feature attribute
2601 * @args: &struct nvme_set_features_args argument structure
2602 *
2603 * Return: The nvme command status if a response was received (see
2604 * &enum nvme_status_field) or -1 with errno set otherwise.
2605 */
2606 int nvme_set_features(struct nvme_set_features_args *args);
2607
2608 /**
2609 * nvme_set_features_data() - Helper function for @nvme_set_features()
2610 * @fd: File descriptor of nvme device
2611 * @fid: Feature identifier
2612 * @nsid: Namespace ID, if applicable
2613 * @cdw11: Value to set the feature to
2614 * @save: Save value across power states
2615 * @data_len: Length of feature data, if applicable, in bytes
2616 * @data: User address of feature data, if applicable
2617 * @result: The command completion result from CQE dword0
2618 *
2619 * Return: The nvme command status if a response was received (see
2620 * &enum nvme_status_field) or -1 with errno set otherwise.
2621 */
2622 static inline int nvme_set_features_data(int fd, __u8 fid, __u32 nsid,
2623 __u32 cdw11, bool save, __u32 data_len, void *data,
2624 __u32 *result)
2625 {
2626 struct nvme_set_features_args args = {
2627 .result = result,
2628 .data = data,
2629 .args_size = sizeof(args),
2630 .fd = fd,
2631 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
2632 .nsid = nsid,
2633 .cdw11 = cdw11,
2634 .cdw12 = 0,
2635 .cdw13 = 0,
2636 .cdw15 = 0,
2637 .data_len = data_len,
2638 .save = save,
2639 .uuidx = NVME_UUID_NONE,
2640 .fid = fid,
2641 };
2642 return nvme_set_features(&args);
2643 }
2644
2645 /**
2646 * nvme_set_features_simple() - Helper function for @nvme_set_features()
2647 * @fd: File descriptor of nvme device
2648 * @fid: Feature identifier
2649 * @nsid: Namespace ID, if applicable
2650 * @cdw11: Value to set the feature to
2651 * @save: Save value across power states
2652 * @result: The command completion result from CQE dword0
2653 *
2654 * Return: The nvme command status if a response was received (see
2655 * &enum nvme_status_field) or -1 with errno set otherwise.
2656 */
2657 static inline int nvme_set_features_simple(int fd, __u8 fid, __u32 nsid,
2658 __u32 cdw11, bool save, __u32 *result)
2659 {
2660 return nvme_set_features_data(fd, fid, nsid, cdw11, save, 0, NULL,
2661 result);
2662 }
2663
2664 /**
2665 * nvme_set_features_arbitration() - Set arbitration features
2666 * @fd: File descriptor of nvme device
2667 * @ab: Arbitration Burst
2668 * @lpw: Low Priority Weight
2669 * @mpw: Medium Priority Weight
2670 * @hpw: High Priority Weight
2671 * @save: Save value across power states
2672 * @result: The command completion result from CQE dword0
2673 *
2674 * Return: The nvme command status if a response was received (see
2675 * &enum nvme_status_field) or -1 with errno set otherwise.
2676 */
2677 int nvme_set_features_arbitration(int fd, __u8 ab, __u8 lpw, __u8 mpw,
2678 __u8 hpw, bool save, __u32 *result);
2679
2680 /**
2681 * nvme_set_features_power_mgmt() - Set power management feature
2682 * @fd: File descriptor of nvme device
2683 * @ps: Power State
2684 * @wh: Workload Hint
2685 * @save: Save value across power states
2686 * @result: The command completion result from CQE dword0
2687 *
2688 * Return: The nvme command status if a response was received (see
2689 * &enum nvme_status_field) or -1 with errno set otherwise.
2690 */
2691 int nvme_set_features_power_mgmt(int fd, __u8 ps, __u8 wh, bool save,
2692 __u32 *result);
2693
2694 /**
2695 * nvme_set_features_lba_range() - Set LBA range feature
2696 * @fd: File descriptor of nvme device
2697 * @nsid: Namespace ID
2698 * @nr_ranges: Number of ranges in @data
2699 * @save: Save value across power states
2700 * @data: User address of feature data
2701 * @result: The command completion result from CQE dword0
2702 *
2703 * Return: The nvme command status if a response was received (see
2704 * &enum nvme_status_field) or -1 with errno set otherwise.
2705 */
2706 int nvme_set_features_lba_range(int fd, __u32 nsid, __u8 nr_ranges, bool save,
2707 struct nvme_lba_range_type *data, __u32 *result);
2708
2709 /**
2710 * nvme_set_features_temp_thresh() - Set temperature threshold feature
2711 * @fd: File descriptor of nvme device
2712 * @tmpth: Temperature Threshold
2713 * @tmpsel: Threshold Temperature Select
2714 * @thsel: Threshold Type Select
2715 * @save: Save value across power states
2716 * @result: The command completion result from CQE dword0
2717 *
2718 * Return: The nvme command status if a response was received (see
2719 * &enum nvme_status_field) or -1 with errno set otherwise.
2720 */
2721 int nvme_set_features_temp_thresh(int fd, __u16 tmpth, __u8 tmpsel,
2722 enum nvme_feat_tmpthresh_thsel thsel,
2723 bool save, __u32 *result);
2724
2725 /**
2726 * nvme_set_features_temp_thresh2() - Set temperature threshold feature
2727 * @fd: File descriptor of nvme device
2728 * @tmpth: Temperature Threshold
2729 * @tmpsel: Threshold Temperature Select
2730 * @thsel: Threshold Type Select
2731 * @tmpthh: Temperature Threshold Hysteresis
2732 * @save: Save value across power states
2733 * @result: The command completion result from CQE dword0
2734 *
2735 * Return: The nvme command status if a response was received (see
2736 * &enum nvme_status_field) or -1 with errno set otherwise.
2737 */
2738 int nvme_set_features_temp_thresh2(int fd, __u16 tmpth, __u8 tmpsel,
2739 enum nvme_feat_tmpthresh_thsel thsel, __u8 tmpthh,
2740 bool save, __u32 *result);
2741
2742 /**
2743 * nvme_set_features_err_recovery() - Set error recovery feature
2744 * @fd: File descriptor of nvme device
2745 * @nsid: Namespace ID
2746 * @tler: Time-limited error recovery value
2747 * @dulbe: Deallocated or Unwritten Logical Block Error Enable
2748 * @save: Save value across power states
2749 * @result: The command completion result from CQE dword0
2750 *
2751 * Return: The nvme command status if a response was received (see
2752 * &enum nvme_status_field) or -1 with errno set otherwise.
2753 */
2754 int nvme_set_features_err_recovery(int fd, __u32 nsid, __u16 tler,
2755 bool dulbe, bool save, __u32 *result);
2756
2757 /**
2758 * nvme_set_features_volatile_wc() - Set volatile write cache feature
2759 * @fd: File descriptor of nvme device
2760 * @wce: Write cache enable
2761 * @save: Save value across power states
2762 * @result: The command completion result from CQE dword0
2763 *
2764 * Return: The nvme command status if a response was received (see
2765 * &enum nvme_status_field) or -1 with errno set otherwise.
2766 */
2767 int nvme_set_features_volatile_wc(int fd, bool wce, bool save,
2768 __u32 *result);
2769
2770 /**
2771 * nvme_set_features_irq_coalesce() - Set IRQ coalesce feature
2772 * @fd: File descriptor of nvme device
2773 * @thr: Aggregation Threshold
2774 * @time: Aggregation Time
2775 * @save: Save value across power states
2776 * @result: The command completion result from CQE dword0
2777 *
2778 * Return: The nvme command status if a response was received (see
2779 * &enum nvme_status_field) or -1 with errno set otherwise.
2780 */
2781 int nvme_set_features_irq_coalesce(int fd, __u8 thr, __u8 time,
2782 bool save, __u32 *result);
2783
2784 /**
2785 * nvme_set_features_irq_config() - Set IRQ config feature
2786 * @fd: File descriptor of nvme device
2787 * @iv: Interrupt Vector
2788 * @cd: Coalescing Disable
2789 * @save: Save value across power states
2790 * @result: The command completion result from CQE dword0
2791 *
2792 * Return: The nvme command status if a response was received (see
2793 * &enum nvme_status_field) or -1 with errno set otherwise.
2794 */
2795 int nvme_set_features_irq_config(int fd, __u16 iv, bool cd, bool save,
2796 __u32 *result);
2797
2798 /**
2799 * nvme_set_features_write_atomic() - Set write atomic feature
2800 * @fd: File descriptor of nvme device
2801 * @dn: Disable Normal
2802 * @save: Save value across power states
2803 * @result: The command completion result from CQE dword0
2804 *
2805 * Return: The nvme command status if a response was received (see
2806 * &enum nvme_status_field) or -1 with errno set otherwise.
2807 */
2808 int nvme_set_features_write_atomic(int fd, bool dn, bool save,
2809 __u32 *result);
2810
2811 /**
2812 * nvme_set_features_async_event() - Set asynchronous event feature
2813 * @fd: File descriptor of nvme device
2814 * @events: Events to enable
2815 * @save: Save value across power states
2816 * @result: The command completion result from CQE dword0
2817 *
2818 * Return: The nvme command status if a response was received (see
2819 * &enum nvme_status_field) or -1 with errno set otherwise.
2820 */
2821 int nvme_set_features_async_event(int fd, __u32 events, bool save,
2822 __u32 *result);
2823
2824 /**
2825 * nvme_set_features_auto_pst() - Set autonomous power state feature
2826 * @fd: File descriptor of nvme device
2827 * @apste: Autonomous Power State Transition Enable
2828 * @apst: Autonomous Power State Transition
2829 * @save: Save value across power states
2830 * @result: The command completion result from CQE dword0
2831 *
2832 * Return: The nvme command status if a response was received (see
2833 * &enum nvme_status_field) or -1 with errno set otherwise.
2834 */
2835 int nvme_set_features_auto_pst(int fd, bool apste, bool save,
2836 struct nvme_feat_auto_pst *apst,
2837 __u32 *result);
2838
2839 /**
2840 * nvme_set_features_timestamp() - Set timestamp feature
2841 * @fd: File descriptor of nvme device
2842 * @save: Save value across power states
2843 * @timestamp: The current timestamp value to assign to this feature
2844 *
2845 * Return: The nvme command status if a response was received (see
2846 * &enum nvme_status_field) or -1 with errno set otherwise.
2847 */
2848 int nvme_set_features_timestamp(int fd, bool save, __u64 timestamp);
2849
2850 /**
2851 * nvme_set_features_hctm() - Set thermal management feature
2852 * @fd: File descriptor of nvme device
2853 * @tmt2: Thermal Management Temperature 2
2854 * @tmt1: Thermal Management Temperature 1
2855 * @save: Save value across power states
2856 * @result: The command completion result from CQE dword0
2857 *
2858 * Return: The nvme command status if a response was received (see
2859 * &enum nvme_status_field) or -1 with errno set otherwise.
2860 */
2861 int nvme_set_features_hctm(int fd, __u16 tmt2, __u16 tmt1, bool save,
2862 __u32 *result);
2863
2864 /**
2865 * nvme_set_features_nopsc() - Set non-operational power state feature
2866 * @fd: File descriptor of nvme device
2867 * @noppme: Non-Operational Power State Permissive Mode Enable
2868 * @save: Save value across power states
2869 * @result: The command completion result from CQE dword0
2870 *
2871 * Return: The nvme command status if a response was received (see
2872 * &enum nvme_status_field) or -1 with errno set otherwise.
2873 */
2874 int nvme_set_features_nopsc(int fd, bool noppme, bool save, __u32 *result);
2875
2876 /**
2877 * nvme_set_features_rrl() - Set read recovery level feature
2878 * @fd: File descriptor of nvme device
2879 * @rrl: Read recovery level setting
2880 * @nvmsetid: NVM set id
2881 * @save: Save value across power states
2882 * @result: The command completion result from CQE dword0
2883 *
2884 * Return: The nvme command status if a response was received (see
2885 * &enum nvme_status_field) or -1 with errno set otherwise.
2886 */
2887 int nvme_set_features_rrl(int fd, __u8 rrl, __u16 nvmsetid, bool save,
2888 __u32 *result);
2889
2890 /**
2891 * nvme_set_features_plm_config() - Set predictable latency feature
2892 * @fd: File descriptor of nvme device
2893 * @enable: Predictable Latency Enable
2894 * @nvmsetid: NVM Set Identifier
2895 * @save: Save value across power states
2896 * @data: Pointer to structure nvme_plm_config
2897 * @result: The command completion result from CQE dword0
2898 *
2899 * Return: The nvme command status if a response was received (see
2900 * &enum nvme_status_field) or -1 with errno set otherwise.
2901 */
2902 int nvme_set_features_plm_config(int fd, bool enable, __u16 nvmsetid,
2903 bool save, struct nvme_plm_config *data,
2904 __u32 *result);
2905
2906 /**
2907 * nvme_set_features_plm_window() - Set window select feature
2908 * @fd: File descriptor of nvme device
2909 * @sel: Window Select
2910 * @nvmsetid: NVM Set Identifier
2911 * @save: Save value across power states
2912 * @result: The command completion result from CQE dword0
2913 *
2914 * Return: The nvme command status if a response was received (see
2915 * &enum nvme_status_field) or -1 with errno set otherwise.
2916 */
2917 int nvme_set_features_plm_window(int fd, enum nvme_feat_plm_window_select sel,
2918 __u16 nvmsetid, bool save, __u32 *result);
2919
2920 /**
2921 * nvme_set_features_lba_sts_interval() - Set LBA status information feature
2922 * @fd: File descriptor of nvme device
2923 * @save: Save value across power states
2924 * @lsiri: LBA Status Information Report Interval
2925 * @lsipi: LBA Status Information Poll Interval
2926 * @result: The command completion result from CQE dword0
2927 *
2928 * Return: The nvme command status if a response was received (see
2929 * &enum nvme_status_field) or -1 with errno set otherwise.
2930 */
2931 int nvme_set_features_lba_sts_interval(int fd, __u16 lsiri, __u16 lsipi,
2932 bool save, __u32 *result);
2933
2934 /**
2935 * nvme_set_features_host_behavior() - Set host behavior feature
2936 * @fd: File descriptor of nvme device
2937 * @save: Save value across power states
2938 * @data: Pointer to structure nvme_feat_host_behavior
2939 *
2940 * Return: The nvme command status if a response was received (see
2941 * &enum nvme_status_field) or -1 with errno set otherwise.
2942 */
2943 int nvme_set_features_host_behavior(int fd, bool save,
2944 struct nvme_feat_host_behavior *data);
2945
2946 /**
2947 * nvme_set_features_sanitize() - Set sanitize feature
2948 * @fd: File descriptor of nvme device
2949 * @nodrm: No-Deallocate Response Mode
2950 * @save: Save value across power states
2951 * @result: The command completion result from CQE dword0
2952 *
2953 * Return: The nvme command status if a response was received (see
2954 * &enum nvme_status_field) or -1 with errno set otherwise.
2955 */
2956 int nvme_set_features_sanitize(int fd, bool nodrm, bool save, __u32 *result);
2957
2958 /**
2959 * nvme_set_features_endurance_evt_cfg() - Set endurance event config feature
2960 * @fd: File descriptor of nvme device
2961 * @endgid: Endurance Group Identifier
2962 * @egwarn: Flags to enable warning, see &enum nvme_eg_critical_warning_flags
2963 * @save: Save value across power states
2964 * @result: The command completion result from CQE dword0
2965 *
2966 * Return: The nvme command status if a response was received (see
2967 * &enum nvme_status_field) or -1 with errno set otherwise.
2968 */
2969 int nvme_set_features_endurance_evt_cfg(int fd, __u16 endgid, __u8 egwarn,
2970 bool save, __u32 *result);
2971
2972 /**
2973 * nvme_set_features_sw_progress() - Set pre-boot software load count feature
2974 * @fd: File descriptor of nvme device
2975 * @pbslc: Pre-boot Software Load Count
2976 * @save: Save value across power states
2977 * @result: The command completion result from CQE dword0
2978 *
2979 * Return: The nvme command status if a response was received (see
2980 * &enum nvme_status_field) or -1 with errno set otherwise.
2981 */
2982 int nvme_set_features_sw_progress(int fd, __u8 pbslc, bool save,
2983 __u32 *result);
2984
2985 /**
2986 * nvme_set_features_host_id() - Set enable extended host identifiers feature
2987 * @fd: File descriptor of nvme device
2988 * @exhid: Enable Extended Host Identifier
2989 * @save: Save value across power states
2990 * @hostid: Host ID to set
2991 *
2992 * Return: The nvme command status if a response was received (see
2993 * &enum nvme_status_field) or -1 with errno set otherwise.
2994 */
2995 int nvme_set_features_host_id(int fd, bool exhid, bool save, __u8 *hostid);
2996
2997 /**
2998 * nvme_set_features_resv_mask() - Set reservation notification mask feature
2999 *
3000 * Deprecated: doesn't support specifying a NSID.
3001 * Use nvme_set_features_resv_mask2() instead.
3002 *
3003 * @fd: File descriptor of nvme device
3004 * @mask: Reservation Notification Mask Field
3005 * @save: Save value across power states
3006 * @result: The command completion result from CQE dword0
3007 *
3008 * Return: The nvme command status if a response was received (see
3009 * &enum nvme_status_field) or -1 with errno set otherwise.
3010 */
3011 int nvme_set_features_resv_mask(int fd, __u32 mask, bool save, __u32 *result)
3012 __attribute__((deprecated));
3013
3014 /**
3015 * nvme_set_features_resv_mask2() - Set reservation notification mask feature
3016 * @fd: File descriptor of nvme device
3017 * @nsid: Namespace ID
3018 * @mask: Reservation Notification Mask Field
3019 * @save: Save value across power states
3020 * @result: The command completion result from CQE dword0
3021 *
3022 * Return: The nvme command status if a response was received (see
3023 * &enum nvme_status_field) or -1 with errno set otherwise.
3024 */
3025 int nvme_set_features_resv_mask2(int fd, __u32 nsid, __u32 mask, bool save,
3026 __u32 *result);
3027
3028 /**
3029 * nvme_set_features_resv_persist() - Set persist through power loss feature
3030 *
3031 * Deprecated: doesn't support specifying a NSID.
3032 * Use nvme_set_features_resv_persist2() instead.
3033 *
3034 * @fd: File descriptor of nvme device
3035 * @ptpl: Persist Through Power Loss
3036 * @save: Save value across power states
3037 * @result: The command completion result from CQE dword0
3038 *
3039 * Return: The nvme command status if a response was received (see
3040 * &enum nvme_status_field) or -1 with errno set otherwise.
3041 */
3042 int nvme_set_features_resv_persist(int fd, bool ptpl, bool save, __u32 *result)
3043 __attribute__((deprecated));
3044
3045 /**
3046 * nvme_set_features_resv_persist2() - Set persist through power loss feature
3047 * @fd: File descriptor of nvme device
3048 * @nsid: Namespace ID
3049 * @ptpl: Persist Through Power Loss
3050 * @save: Save value across power states
3051 * @result: The command completion result from CQE dword0
3052 *
3053 * Return: The nvme command status if a response was received (see
3054 * &enum nvme_status_field) or -1 with errno set otherwise.
3055 */
3056 int nvme_set_features_resv_persist2(int fd, __u32 nsid, bool ptpl, bool save,
3057 __u32 *result);
3058
3059 /**
3060 * nvme_set_features_write_protect() - Set write protect feature
3061 *
3062 * Deprecated: doesn't support specifying a NSID.
3063 * Use nvme_set_features_write_protect2() instead.
3064 *
3065 * @fd: File descriptor of nvme device
3066 * @state: Write Protection State
3067 * @save: Save value across power states
3068 * @result: The command completion result from CQE dword0
3069 *
3070 * Return: The nvme command status if a response was received (see
3071 * &enum nvme_status_field) or -1 with errno set otherwise.
3072 */
3073 int nvme_set_features_write_protect(int fd, enum nvme_feat_nswpcfg_state state,
3074 bool save, __u32 *result)
3075 __attribute__((deprecated));
3076
3077 /**
3078 * nvme_set_features_write_protect2() - Set write protect feature
3079 * @fd: File descriptor of nvme device
3080 * @nsid: Namespace ID
3081 * @state: Write Protection State
3082 * @save: Save value across power states
3083 * @result: The command completion result from CQE dword0
3084 *
3085 * Return: The nvme command status if a response was received (see
3086 * &enum nvme_status_field) or -1 with errno set otherwise.
3087 */
3088 int nvme_set_features_write_protect2(int fd, __u32 nsid,
3089 enum nvme_feat_nswpcfg_state state,
3090 bool save, __u32 *result);
3091
3092 /**
3093 * nvme_set_features_iocs_profile() - Set I/O command set profile feature
3094 * @fd: File descriptor of nvme device
3095 * @iocsi: I/O Command Set Combination Index
3096 * @save: Save value across power states
3097 *
3098 * Return: The nvme command status if a response was received (see
3099 * &enum nvme_status_field) or -1 with errno set otherwise.
3100 */
3101 int nvme_set_features_iocs_profile(int fd, __u16 iocsi, bool save);
3102
3103 /**
3104 * nvme_get_features() - Retrieve a feature attribute
3105 * @args: &struct nvme_get_features_args argument structure
3106 *
3107 * Return: The nvme command status if a response was received (see
3108 * &enum nvme_status_field) or -1 with errno set otherwise.
3109 */
3110 int nvme_get_features(struct nvme_get_features_args *args);
3111
3112 /**
3113 * nvme_get_features_data() - Helper function for @nvme_get_features()
3114 * @fd: File descriptor of nvme device
3115 * @fid: Feature identifier
3116 * @nsid: Namespace ID, if applicable
3117 * @data_len: Length of feature data, if applicable, in bytes
3118 * @data: User address of feature data, if applicable
3119 * @result: The command completion result from CQE dword0
3120 *
3121 * Return: The nvme command status if a response was received (see
3122 * &enum nvme_status_field) or -1 with errno set otherwise.
3123 */
3124 static inline int nvme_get_features_data(int fd, enum nvme_features_id fid,
3125 __u32 nsid, __u32 data_len, void *data, __u32 *result)
3126 {
3127 struct nvme_get_features_args args = {
3128 .result = result,
3129 .data = data,
3130 .args_size = sizeof(args),
3131 .fd = fd,
3132 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
3133 .nsid = nsid,
3134 .sel = NVME_GET_FEATURES_SEL_CURRENT,
3135 .cdw11 = 0,
3136 .data_len = data_len,
3137 .fid = (__u8)fid,
3138 .uuidx = NVME_UUID_NONE,
3139 };
3140
3141 return nvme_get_features(&args);
3142 }
3143
3144 /**
3145 * nvme_get_features_simple() - Helper function for @nvme_get_features()
3146 * @fd: File descriptor of nvme device
3147 * @fid: Feature identifier
3148 * @nsid: Namespace ID, if applicable
3149 * @result: The command completion result from CQE dword0
3150 *
3151 * Return: The nvme command status if a response was received (see
3152 * &enum nvme_status_field) or -1 with errno set otherwise.
3153 */
3154 static inline int nvme_get_features_simple(int fd, enum nvme_features_id fid,
3155 __u32 nsid, __u32 *result)
3156 {
3157 return nvme_get_features_data(fd, fid, nsid, 0, NULL, result);
3158 }
3159
3160 /**
3161 * nvme_get_features_arbitration() - Get arbitration feature
3162 * @fd: File descriptor of nvme device
3163 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3164 * @result: The command completion result from CQE dword0
3165 *
3166 * Return: The nvme command status if a response was received (see
3167 * &enum nvme_status_field) or -1 with errno set otherwise.
3168 */
3169 int nvme_get_features_arbitration(int fd, enum nvme_get_features_sel sel,
3170 __u32 *result);
3171
3172 /**
3173 * nvme_get_features_power_mgmt() - Get power management feature
3174 * @fd: File descriptor of nvme device
3175 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3176 * @result: The command completion result from CQE dword0
3177 *
3178 * Return: The nvme command status if a response was received (see
3179 * &enum nvme_status_field) or -1 with errno set otherwise.
3180 */
3181 int nvme_get_features_power_mgmt(int fd, enum nvme_get_features_sel sel,
3182 __u32 *result);
3183
3184 /**
3185 * nvme_get_features_lba_range() - Get LBA range feature
3186 *
3187 * Deprecated: doesn't support specifying a NSID.
3188 * Use nvme_get_features_lba_range2() instead.
3189 *
3190 * @fd: File descriptor of nvme device
3191 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3192 * @data: User address of feature data, if applicable
3193 * @result: The command completion result from CQE dword0
3194 *
3195 * Return: The nvme command status if a response was received (see
3196 * &enum nvme_status_field) or -1 with errno set otherwise.
3197 */
3198 int nvme_get_features_lba_range(int fd, enum nvme_get_features_sel sel,
3199 struct nvme_lba_range_type *data,
3200 __u32 *result) __attribute__((deprecated));
3201
3202 /**
3203 * nvme_get_features_lba_range2() - Get LBA range feature
3204 * @fd: File descriptor of nvme device
3205 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3206 * @nsid: Namespace ID
3207 * @data: Buffer to receive LBA Range Type data structure
3208 * @result: The command completion result from CQE dword0
3209 *
3210 * Return: The nvme command status if a response was received (see
3211 * &enum nvme_status_field) or -1 with errno set otherwise.
3212 */
3213 int nvme_get_features_lba_range2(int fd, enum nvme_get_features_sel sel,
3214 __u32 nsid, struct nvme_lba_range_type *data,
3215 __u32 *result);
3216
3217 /**
3218 * nvme_get_features_temp_thresh() - Get temperature threshold feature
3219 * @fd: File descriptor of nvme device
3220 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3221 * @result: The command completion result from CQE dword0
3222 *
3223 * Return: The nvme command status if a response was received (see
3224 * &enum nvme_status_field) or -1 with errno set otherwise.
3225 */
3226 int nvme_get_features_temp_thresh(int fd, enum nvme_get_features_sel sel,
3227 __u32 *result);
3228
3229 /**
3230 * nvme_get_features_temp_thresh2() - Get temperature threshold feature
3231 * @fd: File descriptor of nvme device
3232 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3233 * @tmpsel: Threshold Temperature Select
3234 * @thsel: Threshold Type Select
3235 * @result: The command completion result from CQE dword0
3236 *
3237 * Return: The nvme command status if a response was received (see
3238 * &enum nvme_status_field) or -1 with errno set otherwise.
3239 */
3240 int nvme_get_features_temp_thresh2(int fd, enum nvme_get_features_sel sel, __u8 tmpsel,
3241 enum nvme_feat_tmpthresh_thsel thsel, __u32 *result);
3242
3243 /**
3244 * nvme_get_features_err_recovery() - Get error recovery feature
3245 *
3246 * Deprecated: doesn't support specifying a NSID.
3247 * Use nvme_get_features_err_recovery2() instead.
3248 *
3249 * @fd: File descriptor of nvme device
3250 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3251 * @result: The command completion result from CQE dword0
3252 *
3253 * Return: The nvme command status if a response was received (see
3254 * &enum nvme_status_field) or -1 with errno set otherwise.
3255 */
3256 int nvme_get_features_err_recovery(int fd, enum nvme_get_features_sel sel,
3257 __u32 *result) __attribute__((deprecated));
3258
3259 /**
3260 * nvme_get_features_err_recovery2() - Get error recovery feature
3261 * @fd: File descriptor of nvme device
3262 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3263 * @nsid: Namespace ID
3264 * @result: The command completion result from CQE dword0
3265 *
3266 * Return: The nvme command status if a response was received (see
3267 * &enum nvme_status_field) or -1 with errno set otherwise.
3268 */
3269 int nvme_get_features_err_recovery2(int fd, enum nvme_get_features_sel sel,
3270 __u32 nsid, __u32 *result);
3271
3272 /**
3273 * nvme_get_features_volatile_wc() - Get volatile write cache feature
3274 * @fd: File descriptor of nvme device
3275 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3276 * @result: The command completion result from CQE dword0
3277 *
3278 * Return: The nvme command status if a response was received (see
3279 * &enum nvme_status_field) or -1 with errno set otherwise.
3280 */
3281 int nvme_get_features_volatile_wc(int fd, enum nvme_get_features_sel sel,
3282 __u32 *result);
3283
3284 /**
3285 * nvme_get_features_num_queues() - Get number of queues feature
3286 * @fd: File descriptor of nvme device
3287 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3288 * @result: The command completion result from CQE dword0
3289 *
3290 * Return: The nvme command status if a response was received (see
3291 * &enum nvme_status_field) or -1 with errno set otherwise.
3292 */
3293 int nvme_get_features_num_queues(int fd, enum nvme_get_features_sel sel,
3294 __u32 *result);
3295
3296 /**
3297 * nvme_get_features_irq_coalesce() - Get IRQ coalesce feature
3298 * @fd: File descriptor of nvme device
3299 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3300 * @result: The command completion result from CQE dword0
3301 *
3302 * Return: The nvme command status if a response was received (see
3303 * &enum nvme_status_field) or -1 with errno set otherwise.
3304 */
3305 int nvme_get_features_irq_coalesce(int fd, enum nvme_get_features_sel sel,
3306 __u32 *result);
3307
3308 /**
3309 * nvme_get_features_irq_config() - Get IRQ config feature
3310 * @fd: File descriptor of nvme device
3311 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3312 * @iv:
3313 * @result: The command completion result from CQE dword0
3314 *
3315 * Return: The nvme command status if a response was received (see
3316 * &enum nvme_status_field) or -1 with errno set otherwise.
3317 */
3318 int nvme_get_features_irq_config(int fd, enum nvme_get_features_sel sel,
3319 __u16 iv, __u32 *result);
3320
3321 /**
3322 * nvme_get_features_write_atomic() - Get write atomic feature
3323 * @fd: File descriptor of nvme device
3324 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3325 * @result: The command completion result from CQE dword0
3326 *
3327 * Return: The nvme command status if a response was received (see
3328 * &enum nvme_status_field) or -1 with errno set otherwise.
3329 */
3330 int nvme_get_features_write_atomic(int fd, enum nvme_get_features_sel sel,
3331 __u32 *result);
3332
3333 /**
3334 * nvme_get_features_async_event() - Get asynchronous event feature
3335 * @fd: File descriptor of nvme device
3336 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3337 * @result: The command completion result from CQE dword0
3338 *
3339 * Return: The nvme command status if a response was received (see
3340 * &enum nvme_status_field) or -1 with errno set otherwise.
3341 */
3342 int nvme_get_features_async_event(int fd, enum nvme_get_features_sel sel,
3343 __u32 *result);
3344
3345 /**
3346 * nvme_get_features_auto_pst() - Get autonomous power state feature
3347 * @fd: File descriptor of nvme device
3348 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3349 * @apst:
3350 * @result: The command completion result from CQE dword0
3351 *
3352 * Return: The nvme command status if a response was received (see
3353 * &enum nvme_status_field) or -1 with errno set otherwise.
3354 */
3355 int nvme_get_features_auto_pst(int fd, enum nvme_get_features_sel sel,
3356 struct nvme_feat_auto_pst *apst, __u32 *result);
3357
3358 /**
3359 * nvme_get_features_host_mem_buf() - Get host memory buffer feature
3360 *
3361 * Deprecated: doesn't fetch the Host Memory Buffer Attributes data structure.
3362 * Use nvme_get_features_host_mem_buf2() instead.
3363 *
3364 * @fd: File descriptor of nvme device
3365 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3366 * @result: The command completion result from CQE dword0
3367 *
3368 * Return: The nvme command status if a response was received (see
3369 * &enum nvme_status_field) or -1 with errno set otherwise.
3370 */
3371 int nvme_get_features_host_mem_buf(int fd, enum nvme_get_features_sel sel,
3372 __u32 *result) __attribute__((deprecated));
3373
3374 /**
3375 * nvme_get_features_host_mem_buf2() - Get host memory buffer feature
3376 * @fd: File descriptor of nvme device
3377 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3378 * @attrs: Buffer for returned Host Memory Buffer Attributes
3379 * @result: The command completion result from CQE dword0
3380 *
3381 * Return: The nvme command status if a response was received (see
3382 * &enum nvme_status_field) or -1 with errno set otherwise.
3383 */
3384 int nvme_get_features_host_mem_buf2(int fd, enum nvme_get_features_sel sel,
3385 struct nvme_host_mem_buf_attrs *attrs,
3386 __u32 *result);
3387
3388 /**
3389 * nvme_get_features_timestamp() - Get timestamp feature
3390 * @fd: File descriptor of nvme device
3391 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3392 * @ts: Current timestamp
3393 *
3394 * Return: The nvme command status if a response was received (see
3395 * &enum nvme_status_field) or -1 with errno set otherwise.
3396 */
3397 int nvme_get_features_timestamp(int fd, enum nvme_get_features_sel sel,
3398 struct nvme_timestamp *ts);
3399
3400 /**
3401 * nvme_get_features_kato() - Get keep alive timeout feature
3402 * @fd: File descriptor of nvme device
3403 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3404 * @result: The command completion result from CQE dword0
3405 *
3406 * Return: The nvme command status if a response was received (see
3407 * &enum nvme_status_field) or -1 with errno set otherwise.
3408 */
3409 int nvme_get_features_kato(int fd, enum nvme_get_features_sel sel, __u32 *result);
3410
3411 /**
3412 * nvme_get_features_hctm() - Get thermal management feature
3413 * @fd: File descriptor of nvme device
3414 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3415 * @result: The command completion result from CQE dword0
3416 *
3417 * Return: The nvme command status if a response was received (see
3418 * &enum nvme_status_field) or -1 with errno set otherwise.
3419 */
3420 int nvme_get_features_hctm(int fd, enum nvme_get_features_sel sel, __u32 *result);
3421
3422 /**
3423 * nvme_get_features_nopsc() - Get non-operational power state feature
3424 * @fd: File descriptor of nvme device
3425 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3426 * @result: The command completion result from CQE dword0
3427 *
3428 * Return: The nvme command status if a response was received (see
3429 * &enum nvme_status_field) or -1 with errno set otherwise.
3430 */
3431 int nvme_get_features_nopsc(int fd, enum nvme_get_features_sel sel, __u32 *result);
3432
3433 /**
3434 * nvme_get_features_rrl() - Get read recovery level feature
3435 * @fd: File descriptor of nvme device
3436 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3437 * @result: The command completion result from CQE dword0
3438 *
3439 * Return: The nvme command status if a response was received (see
3440 * &enum nvme_status_field) or -1 with errno set otherwise.
3441 */
3442 int nvme_get_features_rrl(int fd, enum nvme_get_features_sel sel, __u32 *result);
3443
3444 /**
3445 * nvme_get_features_plm_config() - Get predictable latency feature
3446 * @fd: File descriptor of nvme device
3447 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3448 * @nvmsetid: NVM set id
3449 * @data:
3450 * @result: The command completion result from CQE dword0
3451 *
3452 * Return: The nvme command status if a response was received (see
3453 * &enum nvme_status_field) or -1 with errno set otherwise.
3454 */
3455 int nvme_get_features_plm_config(int fd, enum nvme_get_features_sel sel,
3456 __u16 nvmsetid, struct nvme_plm_config *data,
3457 __u32 *result);
3458
3459 /**
3460 * nvme_get_features_plm_window() - Get window select feature
3461 * @fd: File descriptor of nvme device
3462 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3463 * @nvmsetid: NVM set id
3464 * @result: The command completion result from CQE dword0
3465 *
3466 * Return: The nvme command status if a response was received (see
3467 * &enum nvme_status_field) or -1 with errno set otherwise.
3468 */
3469 int nvme_get_features_plm_window(int fd, enum nvme_get_features_sel sel,
3470 __u16 nvmsetid, __u32 *result);
3471
3472 /**
3473 * nvme_get_features_lba_sts_interval() - Get LBA status information feature
3474 * @fd: File descriptor of nvme device
3475 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3476 * @result: The command completion result from CQE dword0
3477 *
3478 * Return: The nvme command status if a response was received (see
3479 * &enum nvme_status_field) or -1 with errno set otherwise.
3480 */
3481 int nvme_get_features_lba_sts_interval(int fd, enum nvme_get_features_sel sel,
3482 __u32 *result);
3483
3484 /**
3485 * nvme_get_features_host_behavior() - Get host behavior feature
3486 * @fd: File descriptor of nvme device
3487 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3488 * @data: Pointer to structure nvme_feat_host_behavior
3489 * @result: The command completion result from CQE dword0
3490 *
3491 * Return: The nvme command status if a response was received (see
3492 * &enum nvme_status_field) or -1 with errno set otherwise.
3493 */
3494 int nvme_get_features_host_behavior(int fd, enum nvme_get_features_sel sel,
3495 struct nvme_feat_host_behavior *data,
3496 __u32 *result);
3497
3498 /**
3499 * nvme_get_features_sanitize() - Get sanitize feature
3500 * @fd: File descriptor of nvme device
3501 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3502 * @result: The command completion result from CQE dword0
3503 *
3504 * Return: The nvme command status if a response was received (see
3505 * &enum nvme_status_field) or -1 with errno set otherwise.
3506 */
3507 int nvme_get_features_sanitize(int fd, enum nvme_get_features_sel sel,
3508 __u32 *result);
3509
3510 /**
3511 * nvme_get_features_endurance_event_cfg() - Get endurance event config feature
3512 * @fd: File descriptor of nvme device
3513 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3514 * @endgid: Endurance Group Identifier
3515 * @result: The command completion result from CQE dword0
3516 *
3517 * Return: The nvme command status if a response was received (see
3518 * &enum nvme_status_field) or -1 with errno set otherwise.
3519 */
3520 int nvme_get_features_endurance_event_cfg(int fd, enum nvme_get_features_sel sel,
3521 __u16 endgid, __u32 *result);
3522
3523 /**
3524 * nvme_get_features_sw_progress() - Get software progress feature
3525 * @fd: File descriptor of nvme device
3526 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3527 * @result: The command completion result from CQE dword0
3528 *
3529 * Return: The nvme command status if a response was received (see
3530 * &enum nvme_status_field) or -1 with errno set otherwise.
3531 */
3532 int nvme_get_features_sw_progress(int fd, enum nvme_get_features_sel sel,
3533 __u32 *result);
3534
3535 /**
3536 * nvme_get_features_host_id() - Get host id feature
3537 * @fd: File descriptor of nvme device
3538 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3539 * @exhid: Enable Extended Host Identifier
3540 * @len: Length of @hostid
3541 * @hostid: Buffer for returned host ID
3542 *
3543 * Return: The nvme command status if a response was received (see
3544 * &enum nvme_status_field) or -1 with errno set otherwise.
3545 */
3546 int nvme_get_features_host_id(int fd, enum nvme_get_features_sel sel,
3547 bool exhid, __u32 len, __u8 *hostid);
3548
3549 /**
3550 * nvme_get_features_resv_mask() - Get reservation mask feature
3551 *
3552 * Deprecated: doesn't support specifying a NSID.
3553 * Use nvme_get_features_resv_mask2() instead.
3554 *
3555 * @fd: File descriptor of nvme device
3556 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3557 * @result: The command completion result from CQE dword0
3558 *
3559 * Return: The nvme command status if a response was received (see
3560 * &enum nvme_status_field) or -1 with errno set otherwise.
3561 */
3562 int nvme_get_features_resv_mask(int fd, enum nvme_get_features_sel sel,
3563 __u32 *result) __attribute__((deprecated));
3564
3565 /**
3566 * nvme_get_features_resv_mask2() - Get reservation mask feature
3567 * @fd: File descriptor of nvme device
3568 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3569 * @nsid: Namespace ID
3570 * @result: The command completion result from CQE dword0
3571 *
3572 * Return: The nvme command status if a response was received (see
3573 * &enum nvme_status_field) or -1 with errno set otherwise.
3574 */
3575 int nvme_get_features_resv_mask2(int fd, enum nvme_get_features_sel sel,
3576 __u32 nsid, __u32 *result);
3577
3578 /**
3579 * nvme_get_features_resv_persist() - Get reservation persist feature
3580 *
3581 * Deprecated: doesn't support specifying a NSID.
3582 * Use nvme_get_features_resv_persist2() instead.
3583 *
3584 * @fd: File descriptor of nvme device
3585 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3586 * @result: The command completion result from CQE dword0
3587 *
3588 * Return: The nvme command status if a response was received (see
3589 * &enum nvme_status_field) or -1 with errno set otherwise.
3590 */
3591 int nvme_get_features_resv_persist(int fd, enum nvme_get_features_sel sel,
3592 __u32 *result) __attribute__((deprecated));
3593
3594 /**
3595 * nvme_get_features_resv_persist2() - Get reservation persist feature
3596 * @fd: File descriptor of nvme device
3597 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3598 * @nsid: Namespace ID
3599 * @result: The command completion result from CQE dword0
3600 *
3601 * Return: The nvme command status if a response was received (see
3602 * &enum nvme_status_field) or -1 with errno set otherwise.
3603 */
3604 int nvme_get_features_resv_persist2(int fd, enum nvme_get_features_sel sel,
3605 __u32 nsid, __u32 *result);
3606
3607 /**
3608 * nvme_get_features_write_protect() - Get write protect feature
3609 * @fd: File descriptor of nvme device
3610 * @nsid: Namespace ID
3611 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3612 * @result: The command completion result from CQE dword0
3613 *
3614 * Return: The nvme command status if a response was received (see
3615 * &enum nvme_status_field) or -1 with errno set otherwise.
3616 */
3617 int nvme_get_features_write_protect(int fd, __u32 nsid,
3618 enum nvme_get_features_sel sel,
3619 __u32 *result);
3620
3621 /**
3622 * nvme_get_features_iocs_profile() - Get IOCS profile feature
3623 * @fd: File descriptor of nvme device
3624 * @sel: Select which type of attribute to return, see &enum nvme_get_features_sel
3625 * @result: The command completion result from CQE dword0
3626 *
3627 * Return: The nvme command status if a response was received (see
3628 * &enum nvme_status_field) or -1 with errno set otherwise.
3629 */
3630 int nvme_get_features_iocs_profile(int fd, enum nvme_get_features_sel sel,
3631 __u32 *result);
3632
3633 /**
3634 * nvme_format_nvm() - Format nvme namespace(s)
3635 * @args: &struct nvme_format_nvme_args argument structure
3636 *
3637 * The Format NVM command low level formats the NVM media. This command is used
3638 * by the host to change the LBA data size and/or metadata size. A low level
3639 * format may destroy all data and metadata associated with all namespaces or
3640 * only the specific namespace associated with the command
3641 *
3642 * Return: The nvme command status if a response was received (see
3643 * &enum nvme_status_field) or -1 with errno set otherwise.
3644 */
3645 int nvme_format_nvm(struct nvme_format_nvm_args *args);
3646
3647 /**
3648 * nvme_ns_mgmt() - Issue a Namespace management command
3649 * @args: &struct nvme_ns_mgmt_args Argument structure
3650 *
3651 * Return: The nvme command status if a response was received (see
3652 * &enum nvme_status_field) or -1 with errno set otherwise.
3653 */
3654 int nvme_ns_mgmt(struct nvme_ns_mgmt_args *args);
3655
3656 /**
3657 * nvme_ns_mgmt_create() - Create a non attached namespace
3658 * @fd: File descriptor of nvme device
3659 * @ns: Namespace identification that defines ns creation parameters
3660 * @nsid: On success, set to the namespace id that was created
3661 * @timeout: Override the default timeout to this value in milliseconds;
3662 * set to 0 to use the system default.
3663 * @csi: Command Set Identifier
3664 * @data: Host Software Specified Fields that defines ns creation parameters
3665 *
3666 * On successful creation, the namespace exists in the subsystem, but is not
3667 * attached to any controller. Use the nvme_ns_attach_ctrls() to assign the
3668 * namespace to one or more controllers.
3669 *
3670 * Return: The nvme command status if a response was received (see
3671 * &enum nvme_status_field) or -1 with errno set otherwise.
3672 */
3673 static inline int nvme_ns_mgmt_create(int fd, struct nvme_id_ns *ns,
3674 __u32 *nsid, __u32 timeout, __u8 csi,
3675 struct nvme_ns_mgmt_host_sw_specified *data)
3676 {
3677 struct nvme_ns_mgmt_args args = {
3678 .result = nsid,
3679 .ns = ns,
3680 .args_size = sizeof(args),
3681 .fd = fd,
3682 .timeout = timeout,
3683 .nsid = NVME_NSID_NONE,
3684 .sel = NVME_NS_MGMT_SEL_CREATE,
3685 .csi = csi,
3686 .rsvd1 = { 0, },
3687 .rsvd2 = NULL,
3688 .data = data,
3689 };
3690
3691 return nvme_ns_mgmt(&args);
3692 }
3693
3694 /**
3695 * nvme_ns_mgmt_delete_timeout() - Delete a non attached namespace with timeout
3696 * @fd: File descriptor of nvme device
3697 * @nsid: Namespace identifier to delete
3698 * @timeout: Override the default timeout to this value in milliseconds;
3699 * set to 0 to use the system default.
3700 *
3701 * It is recommended that a namespace being deleted is not attached to any
3702 * controller. Use the nvme_ns_detach_ctrls() first if the namespace is still
3703 * attached.
3704 *
3705 * Return: The nvme command status if a response was received (see
3706 * &enum nvme_status_field) or -1 with errno set otherwise.
3707 */
3708 static inline int nvme_ns_mgmt_delete_timeout(int fd, __u32 nsid, __u32 timeout)
3709 {
3710 struct nvme_ns_mgmt_args args = {
3711 .result = NULL,
3712 .ns = NULL,
3713 .args_size = sizeof(args),
3714 .fd = fd,
3715 .timeout = timeout,
3716 .nsid = nsid,
3717 .sel = NVME_NS_MGMT_SEL_DELETE,
3718 .csi = 0,
3719 .rsvd1 = { 0, },
3720 .rsvd2 = NULL,
3721 .data = NULL,
3722 };
3723
3724 return nvme_ns_mgmt(&args);
3725 }
3726
3727 /**
3728 * nvme_ns_mgmt_delete() - Delete a non attached namespace
3729 * @fd: File descriptor of nvme device
3730 * @nsid: Namespace identifier to delete
3731 *
3732 * It is recommended that a namespace being deleted is not attached to any
3733 * controller. Use the nvme_ns_detach_ctrls() first if the namespace is still
3734 * attached.
3735 *
3736 * Return: The nvme command status if a response was received (see
3737 * &enum nvme_status_field) or -1 with errno set otherwise.
3738 */
3739 static inline int nvme_ns_mgmt_delete(int fd, __u32 nsid)
3740 {
3741 return nvme_ns_mgmt_delete_timeout(fd, nsid, 0);
3742 }
3743
3744 /**
3745 * nvme_ns_attach() - Attach or detach namespace to controller(s)
3746 * @args: &struct nvme_ns_attach_args Argument structure
3747 *
3748 * Return: The nvme command status if a response was received (see
3749 * &enum nvme_status_field) or -1 with errno set otherwise.
3750 */
3751 int nvme_ns_attach(struct nvme_ns_attach_args *args);
3752
3753 /**
3754 * nvme_ns_attach_ctrls() - Attach namespace to controllers
3755 * @fd: File descriptor of nvme device
3756 * @nsid: Namespace ID to attach
3757 * @ctrlist: Controller list to modify attachment state of nsid
3758 *
3759 * Return: The nvme command status if a response was received (see
3760 * &enum nvme_status_field) or -1 with errno set otherwise.
3761 */
3762 static inline int nvme_ns_attach_ctrls(int fd, __u32 nsid,
3763 struct nvme_ctrl_list *ctrlist)
3764 {
3765 struct nvme_ns_attach_args args = {
3766 .result = NULL,
3767 .ctrlist = ctrlist,
3768 .args_size = sizeof(args),
3769 .fd = fd,
3770 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
3771 .nsid = nsid,
3772 .sel = NVME_NS_ATTACH_SEL_CTRL_ATTACH,
3773 };
3774
3775 return nvme_ns_attach(&args);
3776 }
3777
3778 /**
3779 * nvme_ns_detach_ctrls() - Detach namespace from controllers
3780 * @fd: File descriptor of nvme device
3781 * @nsid: Namespace ID to detach
3782 * @ctrlist: Controller list to modify attachment state of nsid
3783 *
3784 * Return: The nvme command status if a response was received (see
3785 * &enum nvme_status_field) or -1 with errno set otherwise.
3786 */
3787 static inline int nvme_ns_detach_ctrls(int fd, __u32 nsid,
3788 struct nvme_ctrl_list *ctrlist)
3789 {
3790 struct nvme_ns_attach_args args = {
3791 .result = NULL,
3792 .ctrlist = ctrlist,
3793 .args_size = sizeof(args),
3794 .fd = fd,
3795 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
3796 .nsid = nsid,
3797 .sel = NVME_NS_ATTACH_SEL_CTRL_DEATTACH,
3798 };
3799
3800 return nvme_ns_attach(&args);
3801 }
3802
3803 /**
3804 * nvme_fw_download() - Download part or all of a firmware image to the
3805 * controller
3806 * @args: &struct nvme_fw_download_args argument structure
3807 *
3808 * The Firmware Image Download command downloads all or a portion of an image
3809 * for a future update to the controller. The Firmware Image Download command
3810 * downloads a new image (in whole or in part) to the controller.
3811 *
3812 * The image may be constructed of multiple pieces that are individually
3813 * downloaded with separate Firmware Image Download commands. Each Firmware
3814 * Image Download command includes a Dword Offset and Number of Dwords that
3815 * specify a dword range.
3816 *
3817 * The new firmware image is not activated as part of the Firmware Image
3818 * Download command. Use the nvme_fw_commit() to activate a newly downloaded
3819 * image.
3820 *
3821 * Return: The nvme command status if a response was received (see
3822 * &enum nvme_status_field) or -1 with errno set otherwise.
3823 */
3824 int nvme_fw_download(struct nvme_fw_download_args *args);
3825
3826 /**
3827 * nvme_fw_commit() - Commit firmware using the specified action
3828 * @args: &struct nvme_fw_commit_args argument structure
3829 *
3830 * The Firmware Commit command modifies the firmware image or Boot Partitions.
3831 *
3832 * Return: The nvme command status if a response was received (see
3833 * &enum nvme_status_field) or -1 with errno set otherwise. The command
3834 * status response may specify additional reset actions required to complete
3835 * the commit process.
3836 */
3837 int nvme_fw_commit(struct nvme_fw_commit_args *args);
3838
3839 /**
3840 * nvme_security_send() - Security Send command
3841 * @args: &struct nvme_security_send argument structure
3842 *
3843 * The Security Send command transfers security protocol data to the
3844 * controller. The data structure transferred to the controller as part of this
3845 * command contains security protocol specific commands to be performed by the
3846 * controller. The data structure transferred may also contain data or
3847 * parameters associated with the security protocol commands.
3848 *
3849 * The security data is protocol specific and is not defined by the NVMe
3850 * specification.
3851 *
3852 * Return: The nvme command status if a response was received (see
3853 * &enum nvme_status_field) or -1 with errno set otherwise.
3854 */
3855 int nvme_security_send(struct nvme_security_send_args *args);
3856
3857 /**
3858 * nvme_security_receive() - Security Receive command
3859 * @args: &struct nvme_security_receive argument structure
3860 *
3861 * Return: The nvme command status if a response was received (see
3862 * &enum nvme_status_field) or -1 with errno set otherwise.
3863 */
3864 int nvme_security_receive(struct nvme_security_receive_args *args);
3865
3866 /**
3867 * nvme_get_lba_status() - Retrieve information on possibly unrecoverable LBAs
3868 * @args: &struct nvme_get_lba_status_args argument structure
3869 *
3870 * The Get LBA Status command requests information about Potentially
3871 * Unrecoverable LBAs. Refer to the specification for action type descriptions.
3872 *
3873 * Return: The nvme command status if a response was received (see
3874 * &enum nvme_status_field) or -1 with errno set otherwise.
3875 */
3876 int nvme_get_lba_status(struct nvme_get_lba_status_args *args);
3877
3878 /**
3879 * nvme_directive_send() - Send directive command
3880 * @args: &struct nvme_directive_send_args argument structure
3881 *
3882 * Directives is a mechanism to enable host and NVM subsystem or controller
3883 * information exchange. The Directive Send command transfers data related to a
3884 * specific Directive Type from the host to the controller.
3885 *
3886 * See the NVMe specification for more information.
3887 *
3888 * Return: The nvme command status if a response was received (see
3889 * &enum nvme_status_field) or -1 with errno set otherwise.
3890 */
3891 int nvme_directive_send(struct nvme_directive_send_args *args);
3892
3893 /**
3894 * nvme_directive_send_id_endir() - Directive Send Enable Directive
3895 * @fd: File descriptor of nvme device
3896 * @nsid: Namespace Identifier
3897 * @endir: Enable Directive
3898 * @dtype: Directive Type
3899 * @id: Pointer to structure nvme_id_directives
3900 *
3901 * Return: The nvme command status if a response was received (see
3902 * &enum nvme_status_field) or -1 with errno set otherwise.
3903 */
3904 int nvme_directive_send_id_endir(int fd, __u32 nsid, bool endir,
3905 enum nvme_directive_dtype dtype,
3906 struct nvme_id_directives *id);
3907
3908 /**
3909 * nvme_directive_send_stream_release_identifier() - Directive Send Stream release
3910 * @fd: File descriptor of nvme device
3911 * @nsid: Namespace ID
3912 * @stream_id: Stream identifier
3913 *
3914 * Return: The nvme command status if a response was received (see
3915 * &enum nvme_status_field) or -1 with errno set otherwise.
3916 */
3917 static inline int nvme_directive_send_stream_release_identifier(int fd,
3918 __u32 nsid, __u16 stream_id)
3919 {
3920 struct nvme_directive_send_args args = {
3921 .result = NULL,
3922 .data = NULL,
3923 .args_size = sizeof(args),
3924 .fd = fd,
3925 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
3926 .nsid = nsid,
3927 .doper = NVME_DIRECTIVE_SEND_STREAMS_DOPER_RELEASE_IDENTIFIER,
3928 .dtype = NVME_DIRECTIVE_DTYPE_STREAMS,
3929 .cdw12 = 0,
3930 .data_len = 0,
3931 .dspec = stream_id,
3932 };
3933
3934 return nvme_directive_send(&args);
3935 }
3936
3937 /**
3938 * nvme_directive_send_stream_release_resource() - Directive Send Stream release resources
3939 * @fd: File descriptor of nvme device
3940 * @nsid: Namespace ID
3941 *
3942 * Return: The nvme command status if a response was received (see
3943 * &enum nvme_status_field) or -1 with errno set otherwise.
3944 */
3945 static inline int nvme_directive_send_stream_release_resource(int fd, __u32 nsid)
3946 {
3947 struct nvme_directive_send_args args = {
3948 .result = NULL,
3949 .data = NULL,
3950 .args_size = sizeof(args),
3951 .fd = fd,
3952 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
3953 .nsid = nsid,
3954 .doper = NVME_DIRECTIVE_SEND_STREAMS_DOPER_RELEASE_RESOURCE,
3955 .dtype = NVME_DIRECTIVE_DTYPE_STREAMS,
3956 .cdw12 = 0,
3957 .data_len = 0,
3958 .dspec = 0,
3959 };
3960
3961 return nvme_directive_send(&args);
3962 }
3963
3964 /**
3965 * nvme_directive_recv() - Receive directive specific data
3966 * @args: &struct nvme_directive_recv_args argument structure
3967 *
3968 * Return: The nvme command status if a response was received (see
3969 * &enum nvme_status_field) or -1 with errno set otherwise.
3970 */
3971 int nvme_directive_recv(struct nvme_directive_recv_args *args);
3972
3973 /**
3974 * nvme_directive_recv_identify_parameters() - Directive receive identifier parameters
3975 * @fd: File descriptor of nvme device
3976 * @nsid: Namespace ID
3977 * @id: Identify parameters buffer
3978 *
3979 * Return: The nvme command status if a response was received (see
3980 * &enum nvme_status_field) or -1 with errno set otherwise.
3981 */
3982 static inline int nvme_directive_recv_identify_parameters(int fd, __u32 nsid,
3983 struct nvme_id_directives *id)
3984 {
3985 struct nvme_directive_recv_args args = {
3986 .result = NULL,
3987 .data = id,
3988 .args_size = sizeof(args),
3989 .fd = fd,
3990 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
3991 .nsid = nsid,
3992 .doper = NVME_DIRECTIVE_RECEIVE_IDENTIFY_DOPER_PARAM,
3993 .dtype = NVME_DIRECTIVE_DTYPE_IDENTIFY,
3994 .cdw12 = 0,
3995 .data_len = sizeof(*id),
3996 .dspec = 0,
3997 };
3998
3999 return nvme_directive_recv(&args);
4000 }
4001
4002 /**
4003 * nvme_directive_recv_stream_parameters() - Directive receive stream parameters
4004 * @fd: File descriptor of nvme device
4005 * @nsid: Namespace ID
4006 * @parms: Streams directive parameters buffer
4007 *
4008 * Return: The nvme command status if a response was received (see
4009 * &enum nvme_status_field) or -1 with errno set otherwise.
4010 */
4011 static inline int nvme_directive_recv_stream_parameters(int fd, __u32 nsid,
4012 struct nvme_streams_directive_params *parms)
4013 {
4014 struct nvme_directive_recv_args args = {
4015 .result = NULL,
4016 .data = parms,
4017 .args_size = sizeof(args),
4018 .fd = fd,
4019 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
4020 .nsid = nsid,
4021 .doper = NVME_DIRECTIVE_RECEIVE_STREAMS_DOPER_PARAM,
4022 .dtype = NVME_DIRECTIVE_DTYPE_STREAMS,
4023 .cdw12 = 0,
4024 .data_len = sizeof(*parms),
4025 .dspec = 0,
4026 };
4027
4028 return nvme_directive_recv(&args);
4029 }
4030
4031 /**
4032 * nvme_directive_recv_stream_status() - Directive receive stream status
4033 * @fd: File descriptor of nvme device
4034 * @nsid: Namespace ID
4035 * @nr_entries: Number of streams to receive
4036 * @id: Stream status buffer
4037 *
4038 * Return: The nvme command status if a response was received (see
4039 * &enum nvme_status_field) or -1 with errno set otherwise.
4040 */
4041 static inline int nvme_directive_recv_stream_status(int fd, __u32 nsid,
4042 unsigned int nr_entries,
4043 struct nvme_streams_directive_status *id)
4044 {
4045 if (nr_entries > NVME_STREAM_ID_MAX) {
4046 errno = EINVAL;
4047 return -1;
4048 }
4049
4050 struct nvme_directive_recv_args args = {
4051 .result = NULL,
4052 .data = id,
4053 .args_size = sizeof(args),
4054 .fd = fd,
4055 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
4056 .nsid = nsid,
4057 .doper = NVME_DIRECTIVE_RECEIVE_STREAMS_DOPER_STATUS,
4058 .dtype = NVME_DIRECTIVE_DTYPE_STREAMS,
4059 .cdw12 = 0,
4060 .data_len = (__u32)(sizeof(*id) + nr_entries * sizeof(__le16)),
4061 .dspec = 0,
4062 };
4063
4064 return nvme_directive_recv(&args);
4065 }
4066
4067 /**
4068 * nvme_directive_recv_stream_allocate() - Directive receive stream allocate
4069 * @fd: File descriptor of nvme device
4070 * @nsid: Namespace ID
4071 * @nsr: Namespace Streams Requested
4072 * @result: If successful, the CQE dword0 value
4073 *
4074 * Return: The nvme command status if a response was received (see
4075 * &enum nvme_status_field) or -1 with errno set otherwise.
4076 */
4077 static inline int nvme_directive_recv_stream_allocate(int fd, __u32 nsid,
4078 __u16 nsr, __u32 *result)
4079 {
4080 struct nvme_directive_recv_args args = {
4081 .result = result,
4082 .data = NULL,
4083 .args_size = sizeof(args),
4084 .fd = fd,
4085 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
4086 .nsid = nsid,
4087 .doper = NVME_DIRECTIVE_RECEIVE_STREAMS_DOPER_RESOURCE,
4088 .dtype = NVME_DIRECTIVE_DTYPE_STREAMS,
4089 .cdw12 = nsr,
4090 .data_len = 0,
4091 .dspec = 0,
4092 };
4093
4094 return nvme_directive_recv(&args);
4095 }
4096
4097 /**
4098 * nvme_capacity_mgmt() - Capacity management command
4099 * @args: &struct nvme_capacity_mgmt_args argument structure
4100 *
4101 * Return: The nvme command status if a response was received (see
4102 * &enum nvme_status_field) or -1 with errno set otherwise.
4103 */
4104 int nvme_capacity_mgmt(struct nvme_capacity_mgmt_args *args);
4105
4106 /**
4107 * nvme_lockdown() - Issue lockdown command
4108 * @args: &struct nvme_lockdown_args argument structure
4109 *
4110 * Return: The nvme command status if a response was received (see
4111 * &enum nvme_status_field) or -1 with errno set otherwise.
4112 */
4113 int nvme_lockdown(struct nvme_lockdown_args *args);
4114
4115 /**
4116 * nvme_set_property() - Set controller property
4117 * @args: &struct nvme_set_property_args argument structure
4118 *
4119 * This is an NVMe-over-Fabrics specific command, not applicable to PCIe. These
4120 * properties align to the PCI MMIO controller registers.
4121 *
4122 * Return: The nvme command status if a response was received (see
4123 * &enum nvme_status_field) or -1 with errno set otherwise.
4124 */
4125 int nvme_set_property(struct nvme_set_property_args *args);
4126
4127 /**
4128 * nvme_get_property() - Get a controller property
4129 * @args: &struct nvme_get_propert_args argument structure
4130 *
4131 * This is an NVMe-over-Fabrics specific command, not applicable to PCIe. These
4132 * properties align to the PCI MMIO controller registers.
4133 *
4134 * Return: The nvme command status if a response was received (see
4135 * &enum nvme_status_field) or -1 with errno set otherwise.
4136 */
4137 int nvme_get_property(struct nvme_get_property_args *args);
4138
4139 /**
4140 * nvme_sanitize_nvm() - Start a sanitize operation
4141 * @args: &struct nvme_sanitize_nvm_args argument structure
4142 *
4143 * A sanitize operation alters all user data in the NVM subsystem such that
4144 * recovery of any previous user data from any cache, the non-volatile media,
4145 * or any Controller Memory Buffer is not possible.
4146 *
4147 * The Sanitize command starts a sanitize operation or to recover from a
4148 * previously failed sanitize operation. The sanitize operation types that may
4149 * be supported are Block Erase, Crypto Erase, and Overwrite. All sanitize
4150 * operations are processed in the background, i.e., completion of the sanitize
4151 * command does not indicate completion of the sanitize operation.
4152 *
4153 * Return: The nvme command status if a response was received (see
4154 * &enum nvme_status_field) or -1 with errno set otherwise.
4155 */
4156 int nvme_sanitize_nvm(struct nvme_sanitize_nvm_args *args);
4157
4158 /**
4159 * nvme_dev_self_test() - Start or abort a self test
4160 * @args: &struct nvme_dev_self_test argument structure
4161 *
4162 * The Device Self-test command starts a device self-test operation or abort a
4163 * device self-test operation. A device self-test operation is a diagnostic
4164 * testing sequence that tests the integrity and functionality of the
4165 * controller and may include testing of the media associated with namespaces.
4166 * The controller may return a response to this command immediately while
4167 * running the self-test in the background.
4168 *
4169 * Set the 'nsid' field to 0 to not include namespaces in the test. Set to
4170 * 0xffffffff to test all namespaces. All other values tests a specific
4171 * namespace, if present.
4172 *
4173 * Return: The nvme command status if a response was received (see
4174 * &enum nvme_status_field) or -1 with errno set otherwise.
4175 */
4176 int nvme_dev_self_test(struct nvme_dev_self_test_args *args);
4177
4178 /**
4179 * nvme_virtual_mgmt() - Virtualization resource management
4180 * @args: &struct nvme_virtual_mgmt_args argument structure
4181 *
4182 * The Virtualization Management command is supported by primary controllers
4183 * that support the Virtualization Enhancements capability. This command is
4184 * used for several functions:
4185 *
4186 * - Modifying Flexible Resource allocation for the primary controller
4187 * - Assigning Flexible Resources for secondary controllers
4188 * - Setting the Online and Offline state for secondary controllers
4189 *
4190 * Return: The nvme command status if a response was received (see
4191 * &enum nvme_status_field) or -1 with errno set otherwise.
4192 */
4193 int nvme_virtual_mgmt(struct nvme_virtual_mgmt_args *args);
4194
4195 /**
4196 * nvme_flush() - Send an nvme flush command
4197 * @fd: File descriptor of nvme device
4198 * @nsid: Namespace identifier
4199 *
4200 * The Flush command requests that the contents of volatile write cache be made
4201 * non-volatile.
4202 *
4203 * Return: The nvme command status if a response was received (see
4204 * &enum nvme_status_field) or -1 with errno set otherwise.
4205 */
4206 static inline int nvme_flush(int fd, __u32 nsid)
4207 {
4208 struct nvme_passthru_cmd cmd = {};
4209
4210 cmd.opcode = nvme_cmd_flush;
4211 cmd.nsid = nsid;
4212
4213 return nvme_submit_io_passthru(fd, &cmd, NULL);
4214 }
4215
4216 /**
4217 * nvme_io() - Submit an nvme user I/O command
4218 * @args: &struct nvme_io_args argument structure
4219 * @opcode: Opcode to execute
4220 *
4221 * Return: The nvme command status if a response was received (see
4222 * &enum nvme_status_field) or -1 with errno set otherwise.
4223 */
4224 int nvme_io(struct nvme_io_args *args, __u8 opcode);
4225
4226 /**
4227 * nvme_read() - Submit an nvme user read command
4228 * @args: &struct nvme_io_args argument structure
4229 *
4230 * Return: The nvme command status if a response was received (see
4231 * &enum nvme_status_field) or -1 with errno set otherwise.
4232 */
4233 static inline int nvme_read(struct nvme_io_args *args)
4234 {
4235 return nvme_io(args, nvme_cmd_read);
4236 }
4237
4238 /**
4239 * nvme_write() - Submit an nvme user write command
4240 * @args: &struct nvme_io_args argument structure
4241 *
4242 * Return: The nvme command status if a response was received (see
4243 * &enum nvme_status_field) or -1 with errno set otherwise.
4244 */
4245 static inline int nvme_write(struct nvme_io_args *args)
4246 {
4247 return nvme_io(args, nvme_cmd_write);
4248 }
4249
4250 /**
4251 * nvme_compare() - Submit an nvme user compare command
4252 * @args: &struct nvme_io_args argument structure
4253 *
4254 * Return: The nvme command status if a response was received (see
4255 * &enum nvme_status_field) or -1 with errno set otherwise.
4256 */
4257 static inline int nvme_compare(struct nvme_io_args *args)
4258 {
4259 return nvme_io(args, nvme_cmd_compare);
4260 }
4261
4262 /**
4263 * nvme_write_zeros() - Submit an nvme write zeroes command
4264 * @args: &struct nvme_io_args argument structure
4265 *
4266 * The Write Zeroes command sets a range of logical blocks to zero. After
4267 * successful completion of this command, the value returned by subsequent
4268 * reads of logical blocks in this range shall be all bytes cleared to 0h until
4269 * a write occurs to this LBA range.
4270 *
4271 * Return: The nvme command status if a response was received (see
4272 * &enum nvme_status_field) or -1 with errno set otherwise.
4273 */
4274 static inline int nvme_write_zeros(struct nvme_io_args *args)
4275 {
4276 return nvme_io(args, nvme_cmd_write_zeroes);
4277 }
4278
4279 /**
4280 * nvme_write_uncorrectable() - Submit an nvme write uncorrectable command
4281 * @args: &struct nvme_io_args argument structure
4282 *
4283 * The Write Uncorrectable command marks a range of logical blocks as invalid.
4284 * When the specified logical block(s) are read after this operation, a failure
4285 * is returned with Unrecovered Read Error status. To clear the invalid logical
4286 * block status, a write operation on those logical blocks is required.
4287 *
4288 * Return: The nvme command status if a response was received (see
4289 * &enum nvme_status_field) or -1 with errno set otherwise.
4290 */
4291 static inline int nvme_write_uncorrectable(struct nvme_io_args *args)
4292 {
4293 return nvme_io(args, nvme_cmd_write_uncor);
4294 }
4295
4296 /**
4297 * nvme_verify() - Send an nvme verify command
4298 * @args: &struct nvme_io_args argument structure
4299 *
4300 * The Verify command verifies integrity of stored information by reading data
4301 * and metadata, if applicable, for the LBAs indicated without transferring any
4302 * data or metadata to the host.
4303 *
4304 * Return: The nvme command status if a response was received (see
4305 * &enum nvme_status_field) or -1 with errno set otherwise.
4306 */
4307 static inline int nvme_verify(struct nvme_io_args *args)
4308 {
4309 return nvme_io(args, nvme_cmd_verify);
4310 }
4311
4312 /**
4313 * nvme_dsm() - Send an nvme data set management command
4314 * @args: &struct nvme_dsm_args argument structure
4315 *
4316 * The Dataset Management command is used by the host to indicate attributes
4317 * for ranges of logical blocks. This includes attributes like frequency that
4318 * data is read or written, access size, and other information that may be used
4319 * to optimize performance and reliability, and may be used to
4320 * deallocate/unmap/trim those logical blocks.
4321 *
4322 * Return: The nvme command status if a response was received (see
4323 * &enum nvme_status_field) or -1 with errno set otherwise.
4324 */
4325 int nvme_dsm(struct nvme_dsm_args *args);
4326
4327 /**
4328 * nvme_copy() - Copy command
4329 *
4330 * @args: &struct nvme_copy_args argument structure
4331 *
4332 * Return: The nvme command status if a response was received (see
4333 * &enum nvme_status_field) or -1 with errno set otherwise.
4334 */
4335 int nvme_copy(struct nvme_copy_args *args);
4336
4337 /**
4338 * nvme_resv_acquire() - Send an nvme reservation acquire
4339 * @args: &struct nvme_resv_acquire argument structure
4340 *
4341 * The Reservation Acquire command acquires a reservation on a namespace,
4342 * preempt a reservation held on a namespace, and abort a reservation held on a
4343 * namespace.
4344 *
4345 * Return: The nvme command status if a response was received (see
4346 * &enum nvme_status_field) or -1 with errno set otherwise.
4347 */
4348 int nvme_resv_acquire(struct nvme_resv_acquire_args *args);
4349
4350 /**
4351 * nvme_resv_register() - Send an nvme reservation register
4352 * @args: &struct nvme_resv_register_args argument structure
4353 *
4354 * The Reservation Register command registers, unregisters, or replaces a
4355 * reservation key.
4356 *
4357 * Return: The nvme command status if a response was received (see
4358 * &enum nvme_status_field) or -1 with errno set otherwise.
4359 */
4360 int nvme_resv_register(struct nvme_resv_register_args *args);
4361
4362 /**
4363 * nvme_resv_release() - Send an nvme reservation release
4364 * @args: &struct nvme_resv_release_args argument structure
4365 *
4366 * Return: The nvme command status if a response was received (see
4367 * &enum nvme_status_field) or -1 with errno set otherwise.
4368 */
4369 int nvme_resv_release(struct nvme_resv_release_args *args);
4370
4371 /**
4372 * nvme_resv_report() - Send an nvme reservation report
4373 * @args: struct nvme_resv_report_args argument structure
4374 *
4375 * Returns a Reservation Status data structure to memory that describes the
4376 * registration and reservation status of a namespace. See the definition for
4377 * the returned structure, &struct nvme_reservation_status, for more details.
4378 *
4379 * Return: The nvme command status if a response was received (see
4380 * &enum nvme_status_field) or -1 with errno set otherwise.
4381 */
4382 int nvme_resv_report(struct nvme_resv_report_args *args);
4383
4384 /**
4385 * nvme_io_mgmt_recv() - I/O Management Receive command
4386 * @args: &struct nvme_io_mgmt_recv_args argument structure
4387 *
4388 * Return: The nvme command status if a response was received (see
4389 * &enum nvme_status_field) or -1 with errno set otherwise.
4390 */
4391 int nvme_io_mgmt_recv(struct nvme_io_mgmt_recv_args *args);
4392
4393 /**
4394 * nvme_fdp_reclaim_unit_handle_status() - Get reclaim unit handle status
4395 * @fd: File descriptor of nvme device
4396 * @nsid: Namespace identifier
4397 * @data_len: Length of response buffer
4398 * @data: Response buffer
4399 *
4400 * Return: The nvme command status if a response was received (see
4401 * &enum nvme_status_field) or -1 with errno set otherwise.
4402 */
4403 static inline int nvme_fdp_reclaim_unit_handle_status(int fd, __u32 nsid,
4404 __u32 data_len, void *data)
4405 {
4406 struct nvme_io_mgmt_recv_args args = {
4407 .data = data,
4408 .args_size = sizeof(args),
4409 .fd = fd,
4410 .nsid = nsid,
4411 .data_len = data_len,
4412 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
4413 .mos = 0,
4414 .mo = NVME_IO_MGMT_RECV_RUH_STATUS,
4415 };
4416
4417 return nvme_io_mgmt_recv(&args);
4418 }
4419
4420 /**
4421 * nvme_io_mgmt_send() - I/O Management Send command
4422 * @args: &struct nvme_io_mgmt_send_args argument structure
4423 *
4424 * Return: The nvme command status if a response was received (see
4425 * &enum nvme_status_field) or -1 with errno set otherwise.
4426 */
4427 int nvme_io_mgmt_send(struct nvme_io_mgmt_send_args *args);
4428
4429 /**
4430 * nvme_fdp_reclaim_unit_handle_update() - Update a list of reclaim unit handles
4431 * @fd: File descriptor of nvme device
4432 * @nsid: Namespace identifier
4433 * @npids: Number of placement identifiers
4434 * @pids: List of placement identifiers
4435 *
4436 * Return: The nvme command status if a response was received (see
4437 * &enum nvme_status_field) or -1 with errno set otherwise.
4438 */
4439 static inline int nvme_fdp_reclaim_unit_handle_update(int fd, __u32 nsid,
4440 unsigned int npids, __u16 *pids)
4441 {
4442 struct nvme_io_mgmt_send_args args = {
4443 .data = (void *)pids,
4444 .args_size = sizeof(args),
4445 .fd = fd,
4446 .nsid = nsid,
4447 .data_len = (__u32)(npids * sizeof(__u16)),
4448 .timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
4449 .mos = (__u16)(npids - 1),
4450 .mo = NVME_IO_MGMT_SEND_RUH_UPDATE,
4451 };
4452
4453 return nvme_io_mgmt_send(&args);
4454 }
4455
4456 /**
4457 * nvme_zns_mgmt_send() - ZNS management send command
4458 * @args: &struct nvme_zns_mgmt_send_args argument structure
4459 *
4460 * Return: The nvme command status if a response was received (see
4461 * &enum nvme_status_field) or -1 with errno set otherwise.
4462 */
4463 int nvme_zns_mgmt_send(struct nvme_zns_mgmt_send_args *args);
4464
4465
4466 /**
4467 * nvme_zns_mgmt_recv() - ZNS management receive command
4468 * @args: &struct nvme_zns_mgmt_recv_args argument structure
4469 *
4470 * Return: The nvme command status if a response was received (see
4471 * &enum nvme_status_field) or -1 with errno set otherwise.
4472 */
4473 int nvme_zns_mgmt_recv(struct nvme_zns_mgmt_recv_args *args);
4474
4475 /**
4476 * nvme_zns_report_zones() - Return the list of zones
4477 * @fd: File descriptor of nvme device
4478 * @nsid: Namespace ID
4479 * @slba: Starting LBA
4480 * @opts: Reporting options
4481 * @extended: Extended report
4482 * @partial: Partial report requested
4483 * @data_len: Length of the data buffer
4484 * @data: Userspace address of the report zones data
4485 * @timeout: timeout in ms
4486 * @result: The command completion result from CQE dword0
4487 *
4488 * Return: The nvme command status if a response was received (see
4489 * &enum nvme_status_field) or -1 with errno set otherwise.
4490 */
4491 static inline int nvme_zns_report_zones(int fd, __u32 nsid, __u64 slba,
4492 enum nvme_zns_report_options opts,
4493 bool extended, bool partial,
4494 __u32 data_len, void *data,
4495 __u32 timeout, __u32 *result)
4496 {
4497 struct nvme_zns_mgmt_recv_args args = {
4498 .slba = slba,
4499 .result = result,
4500 .data = data,
4501 .args_size = sizeof(args),
4502 .fd = fd,
4503 .timeout = timeout,
4504 .nsid = nsid,
4505 .zra = extended ? NVME_ZNS_ZRA_EXTENDED_REPORT_ZONES :
4506 NVME_ZNS_ZRA_REPORT_ZONES,
4507 .data_len = data_len,
4508 .zrasf = (__u16)opts,
4509 .zras_feat = partial,
4510 };
4511
4512 return nvme_zns_mgmt_recv(&args);
4513 }
4514
4515 /**
4516 * nvme_zns_append() - Append data to a zone
4517 * @args: &struct nvme_zns_append_args argument structure
4518 *
4519 * Return: The nvme command status if a response was received (see
4520 * &enum nvme_status_field) or -1 with errno set otherwise.
4521 */
4522 int nvme_zns_append(struct nvme_zns_append_args *args);
4523
4524 /**
4525 * nvme_dim_send - Send a Discovery Information Management (DIM) command
4526 * @args: &struct nvme_dim_args argument structure
4527 *
4528 * Return: The nvme command status if a response was received (see
4529 * &enum nvme_status_field) or -1 with errno set otherwise.
4530 */
4531 int nvme_dim_send(struct nvme_dim_args *args);
4532
4533 /**
4534 * nvme_lm_cdq() - Controller Data Queue - Controller Data Queue command
4535 * @args: &struct nvme_lm_cdq_args argument structure
4536 *
4537 * Return: The nvme command status if a response was received (see
4538 * &enum nvme_status_field) or -1 with errno set otherwise.)
4539 */
4540 int nvme_lm_cdq(struct nvme_lm_cdq_args *args);
4541
4542 /**
4543 * nvme_lm_track_send() - Track Send command
4544 * @args: &struct nvme_lm_track_send_args argument structure
4545 *
4546 * Return: The nvme command status if a response was received (see
4547 * &enum nvme_status_field) or -1 with errno set otherwise.
4548 */
4549 int nvme_lm_track_send(struct nvme_lm_track_send_args *args);
4550
4551 /**
4552 * nvme_lm_migration_send() - Migration Send command
4553 * @args: &struct nvme_lm_migration_send_args argument structure
4554 *
4555 * Return: The nvme command status if a response was received (see
4556 * &enum nvme_status_field) or -1 with errno set otherwise.
4557 */
4558 int nvme_lm_migration_send(struct nvme_lm_migration_send_args *args);
4559
4560 /**
4561 * nvme_lm_migration_recv - Migration Receive command
4562 * @args: &struct nvme_lm_migration_rev_args argument structure
4563 *
4564 * Return: The nvme command status if a response was received (see
4565 * &enum nvme_status_field) or -1 with errno set otherwise.
4566 */
4567 int nvme_lm_migration_recv(struct nvme_lm_migration_recv_args *args);
4568
4569 /**
4570 * nvme_lm_set_features_ctrl_data_queue - Set Controller Datea Queue feature
4571 * @fd: File descriptor of nvme device
4572 * @cdqid: Controller Data Queue ID (CDQID)
4573 * @hp: Head Pointer
4574 * @tpt: Tail Pointer Trigger
4575 * @etpt: Enable Tail Pointer Trigger
4576 * @result: The command completions result from CQE dword0
4577 *
4578 * Return: The nvme command status if a response was received (see
4579 * &enum nvme_status_field) or -1 with errno set otherwise.
4580 */
4581 int nvme_lm_set_features_ctrl_data_queue(int fd, __u16 cdqid, __u32 hp, __u32 tpt, bool etpt,
4582 __u32 *result);
4583
4584 /**
4585 * nvme_lm_get_features_ctrl_data_queue - Get Controller Data Queue feature
4586 * @fd: File descriptor of nvme device
4587 * @cdqid: Controller Data Queue ID (CDQID)
4588 * @data: Get Controller Data Queue feature data
4589 * @result: The command completions result from CQE dword0
4590 *
4591 * Return: The nvme command status if a response was received (see
4592 * &enum nvme_status_field) or -1 with errno set otherwise.
4593 */
4594 int nvme_lm_get_features_ctrl_data_queue(int fd, __u16 cdqid,
4595 struct nvme_lm_ctrl_data_queue_fid_data *data,
4596 __u32 *result);
4597 #endif /* _LIBNVME_IOCTL_H */