xref: /openbmc/linux/drivers/nvme/host/nvme.h (revision 82df5b73)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (c) 2011-2014, Intel Corporation.
4  */
5 
6 #ifndef _NVME_H
7 #define _NVME_H
8 
9 #include <linux/nvme.h>
10 #include <linux/cdev.h>
11 #include <linux/pci.h>
12 #include <linux/kref.h>
13 #include <linux/blk-mq.h>
14 #include <linux/lightnvm.h>
15 #include <linux/sed-opal.h>
16 #include <linux/fault-inject.h>
17 #include <linux/rcupdate.h>
18 #include <linux/wait.h>
19 #include <linux/t10-pi.h>
20 
21 #include <trace/events/block.h>
22 
23 extern unsigned int nvme_io_timeout;
24 #define NVME_IO_TIMEOUT	(nvme_io_timeout * HZ)
25 
26 extern unsigned int admin_timeout;
27 #define ADMIN_TIMEOUT	(admin_timeout * HZ)
28 
29 #define NVME_DEFAULT_KATO	5
30 #define NVME_KATO_GRACE		10
31 
32 #ifdef CONFIG_ARCH_NO_SG_CHAIN
33 #define  NVME_INLINE_SG_CNT  0
34 #define  NVME_INLINE_METADATA_SG_CNT  0
35 #else
36 #define  NVME_INLINE_SG_CNT  2
37 #define  NVME_INLINE_METADATA_SG_CNT  1
38 #endif
39 
40 extern struct workqueue_struct *nvme_wq;
41 extern struct workqueue_struct *nvme_reset_wq;
42 extern struct workqueue_struct *nvme_delete_wq;
43 
44 enum {
45 	NVME_NS_LBA		= 0,
46 	NVME_NS_LIGHTNVM	= 1,
47 };
48 
49 /*
50  * List of workarounds for devices that required behavior not specified in
51  * the standard.
52  */
53 enum nvme_quirks {
54 	/*
55 	 * Prefers I/O aligned to a stripe size specified in a vendor
56 	 * specific Identify field.
57 	 */
58 	NVME_QUIRK_STRIPE_SIZE			= (1 << 0),
59 
60 	/*
61 	 * The controller doesn't handle Identify value others than 0 or 1
62 	 * correctly.
63 	 */
64 	NVME_QUIRK_IDENTIFY_CNS			= (1 << 1),
65 
66 	/*
67 	 * The controller deterministically returns O's on reads to
68 	 * logical blocks that deallocate was called on.
69 	 */
70 	NVME_QUIRK_DEALLOCATE_ZEROES		= (1 << 2),
71 
72 	/*
73 	 * The controller needs a delay before starts checking the device
74 	 * readiness, which is done by reading the NVME_CSTS_RDY bit.
75 	 */
76 	NVME_QUIRK_DELAY_BEFORE_CHK_RDY		= (1 << 3),
77 
78 	/*
79 	 * APST should not be used.
80 	 */
81 	NVME_QUIRK_NO_APST			= (1 << 4),
82 
83 	/*
84 	 * The deepest sleep state should not be used.
85 	 */
86 	NVME_QUIRK_NO_DEEPEST_PS		= (1 << 5),
87 
88 	/*
89 	 * Supports the LighNVM command set if indicated in vs[1].
90 	 */
91 	NVME_QUIRK_LIGHTNVM			= (1 << 6),
92 
93 	/*
94 	 * Set MEDIUM priority on SQ creation
95 	 */
96 	NVME_QUIRK_MEDIUM_PRIO_SQ		= (1 << 7),
97 
98 	/*
99 	 * Ignore device provided subnqn.
100 	 */
101 	NVME_QUIRK_IGNORE_DEV_SUBNQN		= (1 << 8),
102 
103 	/*
104 	 * Broken Write Zeroes.
105 	 */
106 	NVME_QUIRK_DISABLE_WRITE_ZEROES		= (1 << 9),
107 
108 	/*
109 	 * Force simple suspend/resume path.
110 	 */
111 	NVME_QUIRK_SIMPLE_SUSPEND		= (1 << 10),
112 
113 	/*
114 	 * Use only one interrupt vector for all queues
115 	 */
116 	NVME_QUIRK_SINGLE_VECTOR		= (1 << 11),
117 
118 	/*
119 	 * Use non-standard 128 bytes SQEs.
120 	 */
121 	NVME_QUIRK_128_BYTES_SQES		= (1 << 12),
122 
123 	/*
124 	 * Prevent tag overlap between queues
125 	 */
126 	NVME_QUIRK_SHARED_TAGS                  = (1 << 13),
127 
128 	/*
129 	 * Don't change the value of the temperature threshold feature
130 	 */
131 	NVME_QUIRK_NO_TEMP_THRESH_CHANGE	= (1 << 14),
132 };
133 
134 /*
135  * Common request structure for NVMe passthrough.  All drivers must have
136  * this structure as the first member of their request-private data.
137  */
138 struct nvme_request {
139 	struct nvme_command	*cmd;
140 	union nvme_result	result;
141 	u8			retries;
142 	u8			flags;
143 	u16			status;
144 	struct nvme_ctrl	*ctrl;
145 };
146 
147 /*
148  * Mark a bio as coming in through the mpath node.
149  */
150 #define REQ_NVME_MPATH		REQ_DRV
151 
152 enum {
153 	NVME_REQ_CANCELLED		= (1 << 0),
154 	NVME_REQ_USERCMD		= (1 << 1),
155 };
156 
157 static inline struct nvme_request *nvme_req(struct request *req)
158 {
159 	return blk_mq_rq_to_pdu(req);
160 }
161 
162 static inline u16 nvme_req_qid(struct request *req)
163 {
164 	if (!req->rq_disk)
165 		return 0;
166 	return blk_mq_unique_tag_to_hwq(blk_mq_unique_tag(req)) + 1;
167 }
168 
169 /* The below value is the specific amount of delay needed before checking
170  * readiness in case of the PCI_DEVICE(0x1c58, 0x0003), which needs the
171  * NVME_QUIRK_DELAY_BEFORE_CHK_RDY quirk enabled. The value (in ms) was
172  * found empirically.
173  */
174 #define NVME_QUIRK_DELAY_AMOUNT		2300
175 
176 enum nvme_ctrl_state {
177 	NVME_CTRL_NEW,
178 	NVME_CTRL_LIVE,
179 	NVME_CTRL_RESETTING,
180 	NVME_CTRL_CONNECTING,
181 	NVME_CTRL_DELETING,
182 	NVME_CTRL_DEAD,
183 };
184 
185 struct nvme_fault_inject {
186 #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
187 	struct fault_attr attr;
188 	struct dentry *parent;
189 	bool dont_retry;	/* DNR, do not retry */
190 	u16 status;		/* status code */
191 #endif
192 };
193 
194 struct nvme_ctrl {
195 	bool comp_seen;
196 	enum nvme_ctrl_state state;
197 	bool identified;
198 	spinlock_t lock;
199 	struct mutex scan_lock;
200 	const struct nvme_ctrl_ops *ops;
201 	struct request_queue *admin_q;
202 	struct request_queue *connect_q;
203 	struct request_queue *fabrics_q;
204 	struct device *dev;
205 	int instance;
206 	int numa_node;
207 	struct blk_mq_tag_set *tagset;
208 	struct blk_mq_tag_set *admin_tagset;
209 	struct list_head namespaces;
210 	struct rw_semaphore namespaces_rwsem;
211 	struct device ctrl_device;
212 	struct device *device;	/* char device */
213 	struct cdev cdev;
214 	struct work_struct reset_work;
215 	struct work_struct delete_work;
216 	wait_queue_head_t state_wq;
217 
218 	struct nvme_subsystem *subsys;
219 	struct list_head subsys_entry;
220 
221 	struct opal_dev *opal_dev;
222 
223 	char name[12];
224 	u16 cntlid;
225 
226 	u32 ctrl_config;
227 	u16 mtfa;
228 	u32 queue_count;
229 
230 	u64 cap;
231 	u32 page_size;
232 	u32 max_hw_sectors;
233 	u32 max_segments;
234 	u32 max_integrity_segments;
235 	u16 crdt[3];
236 	u16 oncs;
237 	u16 oacs;
238 	u16 nssa;
239 	u16 nr_streams;
240 	u16 sqsize;
241 	u32 max_namespaces;
242 	atomic_t abort_limit;
243 	u8 vwc;
244 	u32 vs;
245 	u32 sgls;
246 	u16 kas;
247 	u8 npss;
248 	u8 apsta;
249 	u16 wctemp;
250 	u16 cctemp;
251 	u32 oaes;
252 	u32 aen_result;
253 	u32 ctratt;
254 	unsigned int shutdown_timeout;
255 	unsigned int kato;
256 	bool subsystem;
257 	unsigned long quirks;
258 	struct nvme_id_power_state psd[32];
259 	struct nvme_effects_log *effects;
260 	struct work_struct scan_work;
261 	struct work_struct async_event_work;
262 	struct delayed_work ka_work;
263 	struct nvme_command ka_cmd;
264 	struct work_struct fw_act_work;
265 	unsigned long events;
266 	bool created;
267 
268 #ifdef CONFIG_NVME_MULTIPATH
269 	/* asymmetric namespace access: */
270 	u8 anacap;
271 	u8 anatt;
272 	u32 anagrpmax;
273 	u32 nanagrpid;
274 	struct mutex ana_lock;
275 	struct nvme_ana_rsp_hdr *ana_log_buf;
276 	size_t ana_log_size;
277 	struct timer_list anatt_timer;
278 	struct work_struct ana_work;
279 #endif
280 
281 	/* Power saving configuration */
282 	u64 ps_max_latency_us;
283 	bool apst_enabled;
284 
285 	/* PCIe only: */
286 	u32 hmpre;
287 	u32 hmmin;
288 	u32 hmminds;
289 	u16 hmmaxd;
290 
291 	/* Fabrics only */
292 	u32 ioccsz;
293 	u32 iorcsz;
294 	u16 icdoff;
295 	u16 maxcmd;
296 	int nr_reconnects;
297 	struct nvmf_ctrl_options *opts;
298 
299 	struct page *discard_page;
300 	unsigned long discard_page_busy;
301 
302 	struct nvme_fault_inject fault_inject;
303 };
304 
305 enum nvme_iopolicy {
306 	NVME_IOPOLICY_NUMA,
307 	NVME_IOPOLICY_RR,
308 };
309 
310 struct nvme_subsystem {
311 	int			instance;
312 	struct device		dev;
313 	/*
314 	 * Because we unregister the device on the last put we need
315 	 * a separate refcount.
316 	 */
317 	struct kref		ref;
318 	struct list_head	entry;
319 	struct mutex		lock;
320 	struct list_head	ctrls;
321 	struct list_head	nsheads;
322 	char			subnqn[NVMF_NQN_SIZE];
323 	char			serial[20];
324 	char			model[40];
325 	char			firmware_rev[8];
326 	u8			cmic;
327 	u16			vendor_id;
328 	u16			awupf;	/* 0's based awupf value. */
329 	struct ida		ns_ida;
330 #ifdef CONFIG_NVME_MULTIPATH
331 	enum nvme_iopolicy	iopolicy;
332 #endif
333 };
334 
335 /*
336  * Container structure for uniqueue namespace identifiers.
337  */
338 struct nvme_ns_ids {
339 	u8	eui64[8];
340 	u8	nguid[16];
341 	uuid_t	uuid;
342 };
343 
344 /*
345  * Anchor structure for namespaces.  There is one for each namespace in a
346  * NVMe subsystem that any of our controllers can see, and the namespace
347  * structure for each controller is chained of it.  For private namespaces
348  * there is a 1:1 relation to our namespace structures, that is ->list
349  * only ever has a single entry for private namespaces.
350  */
351 struct nvme_ns_head {
352 	struct list_head	list;
353 	struct srcu_struct      srcu;
354 	struct nvme_subsystem	*subsys;
355 	unsigned		ns_id;
356 	struct nvme_ns_ids	ids;
357 	struct list_head	entry;
358 	struct kref		ref;
359 	bool			shared;
360 	int			instance;
361 #ifdef CONFIG_NVME_MULTIPATH
362 	struct gendisk		*disk;
363 	struct bio_list		requeue_list;
364 	spinlock_t		requeue_lock;
365 	struct work_struct	requeue_work;
366 	struct mutex		lock;
367 	struct nvme_ns __rcu	*current_path[];
368 #endif
369 };
370 
371 enum nvme_ns_features {
372 	NVME_NS_EXT_LBAS = 1 << 0, /* support extended LBA format */
373 	NVME_NS_METADATA_SUPPORTED = 1 << 1, /* support getting generated md */
374 };
375 
376 struct nvme_ns {
377 	struct list_head list;
378 
379 	struct nvme_ctrl *ctrl;
380 	struct request_queue *queue;
381 	struct gendisk *disk;
382 #ifdef CONFIG_NVME_MULTIPATH
383 	enum nvme_ana_state ana_state;
384 	u32 ana_grpid;
385 #endif
386 	struct list_head siblings;
387 	struct nvm_dev *ndev;
388 	struct kref kref;
389 	struct nvme_ns_head *head;
390 
391 	int lba_shift;
392 	u16 ms;
393 	u16 sgs;
394 	u32 sws;
395 	u8 pi_type;
396 	unsigned long features;
397 	unsigned long flags;
398 #define NVME_NS_REMOVING	0
399 #define NVME_NS_DEAD     	1
400 #define NVME_NS_ANA_PENDING	2
401 
402 	struct nvme_fault_inject fault_inject;
403 
404 };
405 
406 /* NVMe ns supports metadata actions by the controller (generate/strip) */
407 static inline bool nvme_ns_has_pi(struct nvme_ns *ns)
408 {
409 	return ns->pi_type && ns->ms == sizeof(struct t10_pi_tuple);
410 }
411 
412 struct nvme_ctrl_ops {
413 	const char *name;
414 	struct module *module;
415 	unsigned int flags;
416 #define NVME_F_FABRICS			(1 << 0)
417 #define NVME_F_METADATA_SUPPORTED	(1 << 1)
418 #define NVME_F_PCI_P2PDMA		(1 << 2)
419 	int (*reg_read32)(struct nvme_ctrl *ctrl, u32 off, u32 *val);
420 	int (*reg_write32)(struct nvme_ctrl *ctrl, u32 off, u32 val);
421 	int (*reg_read64)(struct nvme_ctrl *ctrl, u32 off, u64 *val);
422 	void (*free_ctrl)(struct nvme_ctrl *ctrl);
423 	void (*submit_async_event)(struct nvme_ctrl *ctrl);
424 	void (*delete_ctrl)(struct nvme_ctrl *ctrl);
425 	int (*get_address)(struct nvme_ctrl *ctrl, char *buf, int size);
426 };
427 
428 #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
429 void nvme_fault_inject_init(struct nvme_fault_inject *fault_inj,
430 			    const char *dev_name);
431 void nvme_fault_inject_fini(struct nvme_fault_inject *fault_inject);
432 void nvme_should_fail(struct request *req);
433 #else
434 static inline void nvme_fault_inject_init(struct nvme_fault_inject *fault_inj,
435 					  const char *dev_name)
436 {
437 }
438 static inline void nvme_fault_inject_fini(struct nvme_fault_inject *fault_inj)
439 {
440 }
441 static inline void nvme_should_fail(struct request *req) {}
442 #endif
443 
444 static inline int nvme_reset_subsystem(struct nvme_ctrl *ctrl)
445 {
446 	if (!ctrl->subsystem)
447 		return -ENOTTY;
448 	return ctrl->ops->reg_write32(ctrl, NVME_REG_NSSR, 0x4E564D65);
449 }
450 
451 /*
452  * Convert a 512B sector number to a device logical block number.
453  */
454 static inline u64 nvme_sect_to_lba(struct nvme_ns *ns, sector_t sector)
455 {
456 	return sector >> (ns->lba_shift - SECTOR_SHIFT);
457 }
458 
459 /*
460  * Convert a device logical block number to a 512B sector number.
461  */
462 static inline sector_t nvme_lba_to_sect(struct nvme_ns *ns, u64 lba)
463 {
464 	return lba << (ns->lba_shift - SECTOR_SHIFT);
465 }
466 
467 /*
468  * Convert byte length to nvme's 0-based num dwords
469  */
470 static inline u32 nvme_bytes_to_numd(size_t len)
471 {
472 	return (len >> 2) - 1;
473 }
474 
475 static inline void nvme_end_request(struct request *req, __le16 status,
476 		union nvme_result result)
477 {
478 	struct nvme_request *rq = nvme_req(req);
479 
480 	rq->status = le16_to_cpu(status) >> 1;
481 	rq->result = result;
482 	/* inject error when permitted by fault injection framework */
483 	nvme_should_fail(req);
484 	blk_mq_complete_request(req);
485 }
486 
487 static inline void nvme_get_ctrl(struct nvme_ctrl *ctrl)
488 {
489 	get_device(ctrl->device);
490 }
491 
492 static inline void nvme_put_ctrl(struct nvme_ctrl *ctrl)
493 {
494 	put_device(ctrl->device);
495 }
496 
497 static inline bool nvme_is_aen_req(u16 qid, __u16 command_id)
498 {
499 	return !qid && command_id >= NVME_AQ_BLK_MQ_DEPTH;
500 }
501 
502 void nvme_complete_rq(struct request *req);
503 bool nvme_cancel_request(struct request *req, void *data, bool reserved);
504 bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
505 		enum nvme_ctrl_state new_state);
506 bool nvme_wait_reset(struct nvme_ctrl *ctrl);
507 int nvme_disable_ctrl(struct nvme_ctrl *ctrl);
508 int nvme_enable_ctrl(struct nvme_ctrl *ctrl);
509 int nvme_shutdown_ctrl(struct nvme_ctrl *ctrl);
510 int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,
511 		const struct nvme_ctrl_ops *ops, unsigned long quirks);
512 void nvme_uninit_ctrl(struct nvme_ctrl *ctrl);
513 void nvme_start_ctrl(struct nvme_ctrl *ctrl);
514 void nvme_stop_ctrl(struct nvme_ctrl *ctrl);
515 int nvme_init_identify(struct nvme_ctrl *ctrl);
516 
517 void nvme_remove_namespaces(struct nvme_ctrl *ctrl);
518 
519 int nvme_sec_submit(void *data, u16 spsp, u8 secp, void *buffer, size_t len,
520 		bool send);
521 
522 void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status,
523 		volatile union nvme_result *res);
524 
525 void nvme_stop_queues(struct nvme_ctrl *ctrl);
526 void nvme_start_queues(struct nvme_ctrl *ctrl);
527 void nvme_kill_queues(struct nvme_ctrl *ctrl);
528 void nvme_sync_queues(struct nvme_ctrl *ctrl);
529 void nvme_unfreeze(struct nvme_ctrl *ctrl);
530 void nvme_wait_freeze(struct nvme_ctrl *ctrl);
531 void nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl, long timeout);
532 void nvme_start_freeze(struct nvme_ctrl *ctrl);
533 
534 #define NVME_QID_ANY -1
535 struct request *nvme_alloc_request(struct request_queue *q,
536 		struct nvme_command *cmd, blk_mq_req_flags_t flags, int qid);
537 void nvme_cleanup_cmd(struct request *req);
538 blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req,
539 		struct nvme_command *cmd);
540 int nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
541 		void *buf, unsigned bufflen);
542 int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
543 		union nvme_result *result, void *buffer, unsigned bufflen,
544 		unsigned timeout, int qid, int at_head,
545 		blk_mq_req_flags_t flags, bool poll);
546 int nvme_set_features(struct nvme_ctrl *dev, unsigned int fid,
547 		      unsigned int dword11, void *buffer, size_t buflen,
548 		      u32 *result);
549 int nvme_get_features(struct nvme_ctrl *dev, unsigned int fid,
550 		      unsigned int dword11, void *buffer, size_t buflen,
551 		      u32 *result);
552 int nvme_set_queue_count(struct nvme_ctrl *ctrl, int *count);
553 void nvme_stop_keep_alive(struct nvme_ctrl *ctrl);
554 int nvme_reset_ctrl(struct nvme_ctrl *ctrl);
555 int nvme_reset_ctrl_sync(struct nvme_ctrl *ctrl);
556 int nvme_try_sched_reset(struct nvme_ctrl *ctrl);
557 int nvme_delete_ctrl(struct nvme_ctrl *ctrl);
558 
559 int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp,
560 		void *log, size_t size, u64 offset);
561 
562 extern const struct attribute_group *nvme_ns_id_attr_groups[];
563 extern const struct block_device_operations nvme_ns_head_ops;
564 
565 #ifdef CONFIG_NVME_MULTIPATH
566 static inline bool nvme_ctrl_use_ana(struct nvme_ctrl *ctrl)
567 {
568 	return ctrl->ana_log_buf != NULL;
569 }
570 
571 void nvme_mpath_unfreeze(struct nvme_subsystem *subsys);
572 void nvme_mpath_wait_freeze(struct nvme_subsystem *subsys);
573 void nvme_mpath_start_freeze(struct nvme_subsystem *subsys);
574 void nvme_set_disk_name(char *disk_name, struct nvme_ns *ns,
575 			struct nvme_ctrl *ctrl, int *flags);
576 bool nvme_failover_req(struct request *req);
577 void nvme_kick_requeue_lists(struct nvme_ctrl *ctrl);
578 int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl,struct nvme_ns_head *head);
579 void nvme_mpath_add_disk(struct nvme_ns *ns, struct nvme_id_ns *id);
580 void nvme_mpath_remove_disk(struct nvme_ns_head *head);
581 int nvme_mpath_init(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id);
582 void nvme_mpath_uninit(struct nvme_ctrl *ctrl);
583 void nvme_mpath_stop(struct nvme_ctrl *ctrl);
584 bool nvme_mpath_clear_current_path(struct nvme_ns *ns);
585 void nvme_mpath_clear_ctrl_paths(struct nvme_ctrl *ctrl);
586 struct nvme_ns *nvme_find_path(struct nvme_ns_head *head);
587 
588 static inline void nvme_mpath_check_last_path(struct nvme_ns *ns)
589 {
590 	struct nvme_ns_head *head = ns->head;
591 
592 	if (head->disk && list_empty(&head->list))
593 		kblockd_schedule_work(&head->requeue_work);
594 }
595 
596 static inline void nvme_trace_bio_complete(struct request *req,
597         blk_status_t status)
598 {
599 	struct nvme_ns *ns = req->q->queuedata;
600 
601 	if (req->cmd_flags & REQ_NVME_MPATH)
602 		trace_block_bio_complete(ns->head->disk->queue, req->bio);
603 }
604 
605 extern struct device_attribute dev_attr_ana_grpid;
606 extern struct device_attribute dev_attr_ana_state;
607 extern struct device_attribute subsys_attr_iopolicy;
608 
609 #else
610 static inline bool nvme_ctrl_use_ana(struct nvme_ctrl *ctrl)
611 {
612 	return false;
613 }
614 /*
615  * Without the multipath code enabled, multiple controller per subsystems are
616  * visible as devices and thus we cannot use the subsystem instance.
617  */
618 static inline void nvme_set_disk_name(char *disk_name, struct nvme_ns *ns,
619 				      struct nvme_ctrl *ctrl, int *flags)
620 {
621 	sprintf(disk_name, "nvme%dn%d", ctrl->instance, ns->head->instance);
622 }
623 
624 static inline bool nvme_failover_req(struct request *req)
625 {
626 	return false;
627 }
628 static inline void nvme_kick_requeue_lists(struct nvme_ctrl *ctrl)
629 {
630 }
631 static inline int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl,
632 		struct nvme_ns_head *head)
633 {
634 	return 0;
635 }
636 static inline void nvme_mpath_add_disk(struct nvme_ns *ns,
637 		struct nvme_id_ns *id)
638 {
639 }
640 static inline void nvme_mpath_remove_disk(struct nvme_ns_head *head)
641 {
642 }
643 static inline bool nvme_mpath_clear_current_path(struct nvme_ns *ns)
644 {
645 	return false;
646 }
647 static inline void nvme_mpath_clear_ctrl_paths(struct nvme_ctrl *ctrl)
648 {
649 }
650 static inline void nvme_mpath_check_last_path(struct nvme_ns *ns)
651 {
652 }
653 static inline void nvme_trace_bio_complete(struct request *req,
654         blk_status_t status)
655 {
656 }
657 static inline int nvme_mpath_init(struct nvme_ctrl *ctrl,
658 		struct nvme_id_ctrl *id)
659 {
660 	if (ctrl->subsys->cmic & (1 << 3))
661 		dev_warn(ctrl->device,
662 "Please enable CONFIG_NVME_MULTIPATH for full support of multi-port devices.\n");
663 	return 0;
664 }
665 static inline void nvme_mpath_uninit(struct nvme_ctrl *ctrl)
666 {
667 }
668 static inline void nvme_mpath_stop(struct nvme_ctrl *ctrl)
669 {
670 }
671 static inline void nvme_mpath_unfreeze(struct nvme_subsystem *subsys)
672 {
673 }
674 static inline void nvme_mpath_wait_freeze(struct nvme_subsystem *subsys)
675 {
676 }
677 static inline void nvme_mpath_start_freeze(struct nvme_subsystem *subsys)
678 {
679 }
680 #endif /* CONFIG_NVME_MULTIPATH */
681 
682 #ifdef CONFIG_NVM
683 int nvme_nvm_register(struct nvme_ns *ns, char *disk_name, int node);
684 void nvme_nvm_unregister(struct nvme_ns *ns);
685 extern const struct attribute_group nvme_nvm_attr_group;
686 int nvme_nvm_ioctl(struct nvme_ns *ns, unsigned int cmd, unsigned long arg);
687 #else
688 static inline int nvme_nvm_register(struct nvme_ns *ns, char *disk_name,
689 				    int node)
690 {
691 	return 0;
692 }
693 
694 static inline void nvme_nvm_unregister(struct nvme_ns *ns) {};
695 static inline int nvme_nvm_ioctl(struct nvme_ns *ns, unsigned int cmd,
696 							unsigned long arg)
697 {
698 	return -ENOTTY;
699 }
700 #endif /* CONFIG_NVM */
701 
702 static inline struct nvme_ns *nvme_get_ns_from_dev(struct device *dev)
703 {
704 	return dev_to_disk(dev)->private_data;
705 }
706 
707 #ifdef CONFIG_NVME_HWMON
708 void nvme_hwmon_init(struct nvme_ctrl *ctrl);
709 #else
710 static inline void nvme_hwmon_init(struct nvme_ctrl *ctrl) { }
711 #endif
712 
713 #endif /* _NVME_H */
714