xref: /illumos-gate/usr/src/uts/common/io/nvme/nvme_var.h (revision f5f0964ce91892f7482efc86903b0ec7c7b6ba66)
1 /*
2  * This file and its contents are supplied under the terms of the
3  * Common Development and Distribution License ("CDDL"), version 1.0.
4  * You may only use this file in accordance with the terms of version
5  * 1.0 of the CDDL.
6  *
7  * A full copy of the text of the CDDL should have accompanied this
8  * source.  A copy of the CDDL is also available via the Internet at
9  * http://www.illumos.org/license/CDDL.
10  */
11 
12 /*
13  * Copyright 2016 The MathWorks, Inc. All rights reserved.
14  * Copyright 2019 Joyent, Inc.
15  * Copyright 2019 Unix Software Ltd.
16  * Copyright 2025 Oxide Computer Company.
17  * Copyright 2022 OmniOS Community Edition (OmniOSce) Association.
18  * Copyright 2022 Tintri by DDN, Inc. All rights reserved.
19  */
20 
21 #ifndef _NVME_VAR_H
22 #define	_NVME_VAR_H
23 
24 #include <sys/ddi.h>
25 #include <sys/sunddi.h>
26 #include <sys/blkdev.h>
27 #include <sys/taskq_impl.h>
28 #include <sys/list.h>
29 #include <sys/ddi_ufm.h>
30 #include <nvme_common.h>
31 
32 /*
33  * NVMe driver state
34  */
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 #define	NVME_MODULE_NAME		"nvme"
41 
42 typedef enum {
43 	NVME_PCI_CONFIG			= 1 << 0,
44 	NVME_FMA_INIT			= 1 << 1,
45 	NVME_REGS_MAPPED		= 1 << 2,
46 	NVME_ADMIN_QUEUE		= 1 << 3,
47 	NVME_CTRL_LIMITS		= 1 << 4,
48 	NVME_INTERRUPTS			= 1 << 5,
49 	NVME_UFM_INIT			= 1 << 6,
50 	NVME_MUTEX_INIT			= 1 << 7,
51 	NVME_MGMT_INIT			= 1 << 8,
52 	NVME_STAT_INIT			= 1 << 9
53 } nvme_progress_t;
54 
55 typedef enum {
56 	NVME_NS_LOCK	= 1 << 0,
57 	/*
58 	 * This flag indicates whether or not we've created a minor node for
59 	 * this namespace. We limit the number of minor nodes that we actually
60 	 * create in the file system due to minor node constraints. The
61 	 * controller minors are preferred to the namespace minors, so the lack
62 	 * of such a minor is considered a non-fatal condition. Minor nodes are
63 	 * removed all in one go right now when we detach, so this currently
64 	 * serves as an internal signifier.
65 	 */
66 	NVME_NS_MINOR	= 1 << 1
67 } nvme_ns_progress_t;
68 
69 typedef enum {
70 	/*
71 	 * The controller fails to properly process commands on the admin queue
72 	 * if the first one has CID 0. Subsequent use of CID 0 doesn't present
73 	 * a problem.
74 	 */
75 	NVME_QUIRK_START_CID		= 1 << 0,
76 } nvme_quirk_t;
77 
78 #define	NVME_MIN_ADMIN_QUEUE_LEN	16
79 #define	NVME_MIN_IO_QUEUE_LEN		16
80 #define	NVME_DEFAULT_ADMIN_QUEUE_LEN	256
81 #define	NVME_DEFAULT_IO_QUEUE_LEN	1024
82 #define	NVME_DEFAULT_ASYNC_EVENT_LIMIT	10
83 #define	NVME_MIN_ASYNC_EVENT_LIMIT	1
84 #define	NVME_DEFAULT_MIN_BLOCK_SIZE	512
85 
86 typedef struct nvme nvme_t;
87 typedef struct nvme_namespace nvme_namespace_t;
88 typedef struct nvme_minor nvme_minor_t;
89 typedef struct nvme_lock nvme_lock_t;
90 typedef struct nvme_minor_lock_info nvme_minor_lock_info_t;
91 typedef struct nvme_dma nvme_dma_t;
92 typedef struct nvme_cmd nvme_cmd_t;
93 typedef struct nvme_cq nvme_cq_t;
94 typedef struct nvme_qpair nvme_qpair_t;
95 typedef struct nvme_task_arg nvme_task_arg_t;
96 typedef struct nvme_device_stat nvme_device_stat_t;
97 typedef struct nvme_admin_stat nvme_admin_stat_t;
98 
99 /*
100  * These states represent the minor's perspective. That is, of a minor's
101  * namespace and controller lock, where is it?
102  */
103 typedef enum {
104 	NVME_LOCK_STATE_UNLOCKED	= 0,
105 	NVME_LOCK_STATE_BLOCKED,
106 	NVME_LOCK_STATE_ACQUIRED
107 } nvme_minor_lock_state_t;
108 
109 struct nvme_minor_lock_info {
110 	list_node_t nli_node;
111 	nvme_lock_t *nli_lock;
112 	nvme_minor_lock_state_t nli_state;
113 	nvme_lock_level_t nli_curlevel;
114 	/*
115 	 * While the minor points back to itself and the nvme_t should always
116 	 * point to the current controller, the namespace should only point to
117 	 * one if this is a particular namespace lock. The former two are
118 	 * initialized at minor initialization time.
119 	 */
120 	nvme_minor_t *nli_minor;
121 	nvme_t *nli_nvme;
122 	nvme_namespace_t *nli_ns;
123 	/*
124 	 * This is the common ioctl information that should be filled in when
125 	 * we're being woken up for any reason other than an interrupted signal.
126 	 * This should only be set while blocking.
127 	 */
128 	nvme_ioctl_common_t *nli_ioc;
129 	/*
130 	 * The following are provided for debugging purposes. In particular,
131 	 * information like the kthread_t and related that performed this should
132 	 * be considered suspect as it represents who took the operation, not
133 	 * who performed the operation (unless we're actively blocking).
134 	 */
135 	hrtime_t nli_last_change;
136 	uintptr_t nli_acq_kthread;
137 	pid_t nli_acq_pid;
138 };
139 
140 struct nvme_minor {
141 	/*
142 	 * The following three fields are set when this is created.
143 	 */
144 	id_t nm_minor;
145 	nvme_t *nm_ctrl;
146 	nvme_namespace_t *nm_ns;
147 	/*
148 	 * This link is used to index this minor on the global list of active
149 	 * open-related minors. This is only manipulated under the
150 	 * nvme_open_minors_mutex.
151 	 */
152 	avl_node_t nm_avl;
153 	/*
154 	 * Information related to locking. Note, there is no pointer to a locked
155 	 * controller as the only one can be the one specified here. This data
156 	 * is protected by the controller's n_minor_mutex.
157 	 */
158 	kcondvar_t nm_cv;
159 	nvme_minor_lock_info_t nm_ctrl_lock;
160 	nvme_minor_lock_info_t nm_ns_lock;
161 };
162 
163 struct nvme_lock {
164 	nvme_minor_lock_info_t *nl_writer;
165 	list_t nl_readers;
166 	list_t nl_pend_readers;
167 	list_t nl_pend_writers;
168 	/*
169 	 * The following are stats to indicate how often certain locking
170 	 * activities have occurred for debugging purposes.
171 	 */
172 	uint32_t nl_nwrite_locks;
173 	uint32_t nl_nread_locks;
174 	uint32_t nl_npend_writes;
175 	uint32_t nl_npend_reads;
176 	uint32_t nl_nnonblock;
177 	uint32_t nl_nsignals;
178 	uint32_t nl_nsig_unlock;
179 	uint32_t nl_nsig_blocks;
180 	uint32_t nl_nsig_acq;
181 };
182 
183 struct nvme_dma {
184 	ddi_dma_handle_t nd_dmah;
185 	ddi_acc_handle_t nd_acch;
186 	ddi_dma_cookie_t nd_cookie;
187 	uint_t nd_ncookie;
188 	caddr_t nd_memp;
189 	size_t nd_len;
190 	boolean_t nd_cached;
191 };
192 
193 typedef enum {
194 	NVME_CMD_ALLOCATED = 0,
195 	NVME_CMD_SUBMITTED,
196 	NVME_CMD_QUEUED,
197 	NVME_CMD_COMPLETED,
198 	NVME_CMD_LOST
199 } nvme_cmd_state_t;
200 
201 typedef enum {
202 	NVME_CMD_F_DONTPANIC	= 1 << 0,
203 	NVME_CMD_F_USELOCK	= 1 << 1,
204 } nvme_cmd_flag_t;
205 
206 /*
207  * This command structure is shared between admin and I/O commands. When used
208  * for an admin command, nc_mutex and nc_cv are used to synchronise access to
209  * various fields, and to signal command completion. NVME_CMD_F_USELOCK in
210  * nc_flags indicates whether the lock and CV are in use. For I/O commands,
211  * these are neither initialised nor used.
212  */
213 struct nvme_cmd {
214 	struct list_node nc_list;
215 
216 	nvme_sqe_t nc_sqe;
217 	nvme_cqe_t nc_cqe;
218 
219 	void (*nc_callback)(void *);
220 	bd_xfer_t *nc_xfer;
221 
222 	uint32_t nc_timeout;
223 	nvme_cmd_flag_t nc_flags;
224 	nvme_cmd_state_t nc_state; /* Protected by nc_mutex iff F_USELOCK */
225 	uint16_t nc_sqid;
226 
227 	hrtime_t nc_submit_ts;
228 	hrtime_t nc_queue_ts;
229 
230 	nvme_dma_t *nc_dma;
231 	nvme_dma_t *nc_prp; /* DMA for PRP lists */
232 
233 	kmutex_t nc_mutex;
234 	kcondvar_t nc_cv;
235 
236 	taskq_ent_t nc_tqent;
237 	nvme_t *nc_nvme;
238 };
239 
240 struct nvme_cq {
241 	size_t ncq_nentry;
242 	uint16_t ncq_id;
243 
244 	nvme_dma_t *ncq_dma;
245 	nvme_cqe_t *ncq_cq;
246 	uint_t ncq_head;
247 	uintptr_t ncq_hdbl;
248 	int ncq_phase;
249 
250 	taskq_t *ncq_cmd_taskq;
251 
252 	kmutex_t ncq_mutex;
253 };
254 
255 struct nvme_qpair {
256 	size_t nq_nentry;
257 
258 	/* submission fields */
259 	nvme_dma_t *nq_sqdma;
260 	nvme_sqe_t *nq_sq;
261 	uint_t nq_sqhead;
262 	uint_t nq_sqtail;
263 	uintptr_t nq_sqtdbl;
264 
265 	/* completion */
266 	nvme_cq_t *nq_cq;
267 
268 	/* shared structures for completion and submission */
269 	nvme_cmd_t **nq_cmd;	/* active command array */
270 	uint16_t nq_next_cmd;	/* next potential empty queue slot */
271 	uint_t nq_active_cmds;	/* number of active cmds */
272 	uint32_t nq_active_timeout; /* sum of the timeouts of active cmds */
273 
274 	kmutex_t nq_mutex;	/* protects shared state */
275 	ksema_t nq_sema; /* semaphore to ensure q always has >= 1 empty slot */
276 };
277 
278 typedef struct nvme_mgmt_lock {
279 	kmutex_t nml_lock;
280 	kcondvar_t nml_cv;
281 	uintptr_t nml_bd_own;
282 } nvme_mgmt_lock_t;
283 
284 struct nvme_device_stat {
285 	/* Errors detected by driver */
286 	kstat_named_t nds_dma_bind_err;
287 	kstat_named_t nds_abort_timeout;
288 	kstat_named_t nds_abort_failed;
289 	kstat_named_t nds_abort_successful;
290 	kstat_named_t nds_abort_unsuccessful;
291 	kstat_named_t nds_cmd_timeout;
292 	kstat_named_t nds_wrong_logpage;
293 	kstat_named_t nds_unknown_logpage;
294 	kstat_named_t nds_too_many_cookies;
295 	kstat_named_t nds_unknown_cid;
296 
297 	/* Errors detected by hardware */
298 	kstat_named_t nds_inv_cmd_err;
299 	kstat_named_t nds_inv_field_err;
300 	kstat_named_t nds_inv_nsfmt_err;
301 	kstat_named_t nds_data_xfr_err;
302 	kstat_named_t nds_internal_err;
303 	kstat_named_t nds_abort_rq_err;
304 	kstat_named_t nds_abort_pwrloss_err;
305 	kstat_named_t nds_abort_sq_del;
306 	kstat_named_t nds_nvm_cap_exc;
307 	kstat_named_t nds_nvm_ns_notrdy;
308 	kstat_named_t nds_nvm_ns_formatting;
309 	kstat_named_t nds_inv_cq_err;
310 	kstat_named_t nds_inv_qid_err;
311 	kstat_named_t nds_max_qsz_exc;
312 	kstat_named_t nds_inv_int_vect;
313 	kstat_named_t nds_inv_log_page;
314 	kstat_named_t nds_inv_format;
315 	kstat_named_t nds_inv_q_del;
316 	kstat_named_t nds_cnfl_attr;
317 	kstat_named_t nds_inv_prot;
318 	kstat_named_t nds_readonly;
319 	kstat_named_t nds_inv_fwslot;
320 	kstat_named_t nds_inv_fwimg;
321 	kstat_named_t nds_fwact_creset;
322 	kstat_named_t nds_fwact_nssr;
323 	kstat_named_t nds_fwact_reset;
324 	kstat_named_t nds_fwact_mtfa;
325 	kstat_named_t nds_fwact_prohibited;
326 	kstat_named_t nds_fw_overlap;
327 	kstat_named_t nds_inv_cmdseq_err;
328 	kstat_named_t nds_ns_attached;
329 	kstat_named_t nds_ns_priv;
330 	kstat_named_t nds_ns_not_attached;
331 	kstat_named_t nds_inc_ctrl_list;
332 	kstat_named_t nds_ana_attach;
333 	kstat_named_t nds_ns_attach_lim;
334 
335 	/* Errors reported by asynchronous events */
336 	kstat_named_t nds_diagfail_event;
337 	kstat_named_t nds_persistent_event;
338 	kstat_named_t nds_transient_event;
339 	kstat_named_t nds_fw_load_event;
340 	kstat_named_t nds_reliability_event;
341 	kstat_named_t nds_temperature_event;
342 	kstat_named_t nds_spare_event;
343 	kstat_named_t nds_vendor_event;
344 	kstat_named_t nds_notice_event;
345 	kstat_named_t nds_unknown_event;
346 };
347 
348 #define	NAS_CNT 0
349 #define	NAS_AVG 1
350 #define	NAS_MAX 2
351 struct nvme_admin_stat {
352 	kstat_named_t nas_getlogpage[3];
353 	kstat_named_t nas_identify[3];
354 	kstat_named_t nas_abort[3];
355 	kstat_named_t nas_fwactivate[3];
356 	kstat_named_t nas_fwimgload[3];
357 	kstat_named_t nas_nsformat[3];
358 	kstat_named_t nas_vendor[3];
359 	kstat_named_t nas_other[3];
360 };
361 
362 struct nvme {
363 	dev_info_t *n_dip;
364 	nvme_progress_t n_progress;
365 	nvme_quirk_t n_quirks;
366 
367 	caddr_t n_regs;
368 	ddi_acc_handle_t n_regh;
369 
370 	kmem_cache_t *n_cmd_cache;
371 	kmem_cache_t *n_prp_cache;
372 
373 	size_t n_inth_sz;
374 	ddi_intr_handle_t *n_inth;
375 	int n_intr_cnt;
376 	uint_t n_intr_pri;
377 	int n_intr_cap;
378 	int n_intr_type;
379 	int n_intr_types;
380 
381 	ddi_acc_handle_t n_pcicfg_handle;
382 	uint16_t n_vendor_id;
383 	uint16_t n_device_id;
384 	uint16_t n_subsystem_vendor_id;
385 	uint16_t n_subsystem_device_id;
386 	uint8_t n_revision_id;
387 
388 	char *n_product;
389 	char *n_vendor;
390 
391 	nvme_version_t n_version;
392 	boolean_t n_dead;
393 	nvme_ioctl_errno_t n_dead_status;
394 	taskq_ent_t n_dead_tqent;
395 	boolean_t n_strict_version;
396 	boolean_t n_ignore_unknown_vendor_status;
397 	uint32_t n_admin_queue_len;
398 	uint32_t n_io_squeue_len;
399 	uint32_t n_io_cqueue_len;
400 	uint16_t n_async_event_limit;
401 	uint_t n_min_block_size;
402 	uint16_t n_abort_command_limit;
403 	uint64_t n_max_data_transfer_size;
404 	boolean_t n_write_cache_present;
405 	boolean_t n_write_cache_enabled;
406 	int n_error_log_len;
407 	boolean_t n_async_event_supported;
408 	int n_submission_queues;
409 	int n_completion_queues;
410 
411 	int n_nssr_supported;
412 	int n_doorbell_stride;
413 	int n_timeout;
414 	int n_arbitration_mechanisms;
415 	int n_cont_queues_reqd;
416 	int n_max_queue_entries;
417 	int n_pageshift;
418 	int n_pagesize;
419 
420 	uint32_t n_namespace_count;
421 	uint_t n_namespaces_attachable;
422 	uint_t n_ioq_count;
423 	uint_t n_cq_count;
424 
425 	/*
426 	 * This is cached identify controller and common namespace data that
427 	 * exists in the system. This generally can be used in the kernel;
428 	 * however, we have to be careful about what we use here because these
429 	 * values are not refreshed after attach. Therefore these are good for
430 	 * answering the question what does the controller support or what is in
431 	 * the common namespace information, but not otherwise. That means you
432 	 * shouldn't use this to try to answer how much capacity is still in the
433 	 * controller because this information is just cached.
434 	 */
435 	nvme_identify_ctrl_t *n_idctl;
436 	nvme_identify_nsid_t *n_idcomns;
437 
438 	/* Pointer to the admin queue, which is always queue 0 in n_ioq. */
439 	nvme_qpair_t *n_adminq;
440 	/*
441 	 * All command queues, including the admin queue.
442 	 * Its length is: n_ioq_count + 1.
443 	 */
444 	nvme_qpair_t **n_ioq;
445 	nvme_cq_t **n_cq;
446 
447 	nvme_namespace_t *n_ns;
448 
449 	ddi_dma_attr_t n_queue_dma_attr;
450 	ddi_dma_attr_t n_prp_dma_attr;
451 	ddi_dma_attr_t n_sgl_dma_attr;
452 	ddi_device_acc_attr_t n_reg_acc_attr;
453 	ddi_iblock_cookie_t n_fm_ibc;
454 	int n_fm_cap;
455 
456 	ksema_t n_abort_sema;
457 
458 	/* protects namespace management operations */
459 	nvme_mgmt_lock_t n_mgmt;
460 
461 	/*
462 	 * This lock protects the minor node locking state across the controller
463 	 * and all related namespaces.
464 	 */
465 	kmutex_t n_minor_mutex;
466 	nvme_lock_t n_lock;
467 
468 	kstat_t *n_device_kstat;
469 	nvme_device_stat_t n_device_stat;
470 
471 	kstat_t *n_admin_kstat;
472 	kmutex_t n_admin_stat_mutex;
473 	nvme_admin_stat_t n_admin_stat;
474 
475 	/* hot removal NDI event handling */
476 	ddi_eventcookie_t n_rm_cookie;
477 	ddi_callback_id_t n_ev_rm_cb_id;
478 
479 	/* DDI UFM handle */
480 	ddi_ufm_handle_t *n_ufmh;
481 	/* Cached Firmware Slot Information log page */
482 	nvme_fwslot_log_t *n_fwslot;
483 	/* Lock protecting the cached firmware slot info */
484 	kmutex_t n_fwslot_mutex;
485 };
486 
487 struct nvme_namespace {
488 	nvme_t *ns_nvme;
489 	nvme_ns_progress_t ns_progress;
490 	uint8_t ns_eui64[8];
491 	uint8_t	ns_nguid[16];
492 	char	ns_name[11];
493 
494 	bd_handle_t ns_bd_hdl;
495 
496 	uint32_t ns_id;
497 	size_t ns_block_count;
498 	size_t ns_block_size;
499 	size_t ns_best_block_size;
500 	nvme_ns_state_t ns_state;
501 
502 	nvme_identify_nsid_t *ns_idns;
503 
504 	/*
505 	 * Namespace lock, see the theory statement for more information.
506 	 */
507 	nvme_lock_t ns_lock;
508 
509 	/*
510 	 * If a namespace has neither NGUID nor EUI64, we create a devid in
511 	 * nvme_prepare_devid().
512 	 */
513 	char *ns_devid;
514 };
515 
516 struct nvme_task_arg {
517 	nvme_t *nt_nvme;
518 	nvme_cmd_t *nt_cmd;
519 };
520 
521 typedef enum {
522 	/*
523 	 * This indicates that there is no exclusive access required for this
524 	 * operation. However, this operation will fail if someone attempts to
525 	 * perform this operation and someone else holds a write lock.
526 	 */
527 	NVME_IOCTL_EXCL_NONE	= 0,
528 	/*
529 	 * This indicates that a write lock is required to perform the
530 	 * operation.
531 	 */
532 	NVME_IOCTL_EXCL_WRITE,
533 	/*
534 	 * This indicates that a write lock over the controller is required to
535 	 * perform the operation. An example of this is creating a namespace
536 	 * because it operates on the controller as a whole.
537 	 */
538 	NVME_IOCTL_EXCL_CTRL,
539 	/*
540 	 * This indicates that the exclusive check should be skipped. The only
541 	 * case this should be used in is the lock and unlock ioctls as they
542 	 * should be able to proceed even when the controller is being used
543 	 * exclusively.
544 	 */
545 	NVME_IOCTL_EXCL_SKIP
546 } nvme_ioctl_excl_t;
547 
548 /*
549  * This structure represents the set of checks that we apply to ioctl's using
550  * the nvme_ioctl_common_t structure as part of validation.
551  */
552 typedef struct nvme_ioctl_check {
553 	/*
554 	 * This indicates whether or not the command in question allows a
555 	 * namespace to be specified at all. If this is false, a namespace minor
556 	 * cannot be used and a controller minor must leave the nsid set to
557 	 * zero.
558 	 */
559 	boolean_t nck_ns_ok;
560 	/*
561 	 * This indicates that a minor node corresponding to a namespace is
562 	 * allowed to issue this.
563 	 */
564 	boolean_t nck_ns_minor_ok;
565 	/*
566 	 * This indicates that the controller should be skipped from all of the
567 	 * following processing behavior. That is, it's allowed to specify
568 	 * whatever it wants in the nsid field, regardless if it is valid or
569 	 * not. This is required for some of the Identify Command options that
570 	 * list endpoints. This should generally not be used and the driver
571 	 * should still validate the nuance here.
572 	 */
573 	boolean_t nck_skip_ctrl;
574 	/*
575 	 * This indicates that if we're on the controller's minor and we don't
576 	 * have an explicit namespace ID (i.e. 0), should the namespace be
577 	 * rewritten to be the broadcast namespace.
578 	 */
579 	boolean_t nck_ctrl_rewrite;
580 	/*
581 	 * This indicates whether or not the broadcast NSID is acceptable for
582 	 * the controller node.
583 	 */
584 	boolean_t nck_bcast_ok;
585 
586 	/*
587 	 * This indicates to the lock checking code what kind of exclusive
588 	 * access is required. This check occurs after any namespace rewriting
589 	 * has occurred. When looking at exclusivity, a broadcast namespace or
590 	 * namespace 0 indicate that the controller is the target, otherwise the
591 	 * target namespace will be checked for a write lock.
592 	 */
593 	nvme_ioctl_excl_t nck_excl;
594 } nvme_ioctl_check_t;
595 
596 /*
597  * Constants
598  */
599 extern uint_t nvme_vendor_specific_admin_cmd_max_timeout;
600 extern uint32_t nvme_vendor_specific_admin_cmd_size;
601 
602 /*
603  * Common functions.
604  */
605 extern nvme_namespace_t *nvme_nsid2ns(nvme_t *, uint32_t);
606 extern boolean_t nvme_ioctl_error(nvme_ioctl_common_t *, nvme_ioctl_errno_t,
607     uint32_t, uint32_t);
608 extern boolean_t nvme_ctrl_atleast(nvme_t *, const nvme_version_t *);
609 extern void nvme_ioctl_success(nvme_ioctl_common_t *);
610 
611 /*
612  * Validation related functions and kernel tunable limits.
613  */
614 extern boolean_t nvme_validate_logpage(nvme_t *, nvme_ioctl_get_logpage_t *);
615 extern boolean_t nvme_validate_identify(nvme_t *, nvme_ioctl_identify_t *,
616     boolean_t);
617 extern boolean_t nvme_validate_get_feature(nvme_t *,
618     nvme_ioctl_get_feature_t *);
619 extern boolean_t nvme_validate_vuc(nvme_t *, nvme_ioctl_passthru_t *);
620 extern boolean_t nvme_validate_format(nvme_t *, nvme_ioctl_format_t *);
621 extern boolean_t nvme_validate_fw_load(nvme_t *, nvme_ioctl_fw_load_t *);
622 extern boolean_t nvme_validate_fw_commit(nvme_t *, nvme_ioctl_fw_commit_t *);
623 extern boolean_t nvme_validate_ctrl_attach_detach_ns(nvme_t *,
624     nvme_ioctl_common_t *);
625 extern boolean_t nvme_validate_ns_delete(nvme_t *, nvme_ioctl_common_t *);
626 extern boolean_t nvme_validate_ns_create(nvme_t *, nvme_ioctl_ns_create_t *);
627 
628 /*
629  * Locking functions
630  */
631 extern void nvme_rwlock(nvme_minor_t *, nvme_ioctl_lock_t *);
632 extern void nvme_rwunlock(nvme_minor_lock_info_t *, nvme_lock_t *);
633 extern void nvme_rwlock_ctrl_dead(void *);
634 extern void nvme_lock_init(nvme_lock_t *);
635 extern void nvme_lock_fini(nvme_lock_t *);
636 
637 /*
638  * Statistics functions
639  */
640 extern boolean_t nvme_stat_init(nvme_t *);
641 extern void nvme_stat_cleanup(nvme_t *);
642 extern void nvme_admin_stat_cmd(nvme_t *, nvme_cmd_t *);
643 
644 #ifdef __cplusplus
645 }
646 #endif
647 
648 #endif /* _NVME_VAR_H */
649