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 * The controller doesn't handle the Identify Namespace 135 * Identification Descriptor list subcommand despite claiming 136 * NVMe 1.3 compliance. 137 */ 138 NVME_QUIRK_NO_NS_DESC_LIST = (1 << 15), 139 }; 140 141 /* 142 * Common request structure for NVMe passthrough. All drivers must have 143 * this structure as the first member of their request-private data. 144 */ 145 struct nvme_request { 146 struct nvme_command *cmd; 147 union nvme_result result; 148 u8 retries; 149 u8 flags; 150 u16 status; 151 struct nvme_ctrl *ctrl; 152 }; 153 154 /* 155 * Mark a bio as coming in through the mpath node. 156 */ 157 #define REQ_NVME_MPATH REQ_DRV 158 159 enum { 160 NVME_REQ_CANCELLED = (1 << 0), 161 NVME_REQ_USERCMD = (1 << 1), 162 }; 163 164 static inline struct nvme_request *nvme_req(struct request *req) 165 { 166 return blk_mq_rq_to_pdu(req); 167 } 168 169 static inline u16 nvme_req_qid(struct request *req) 170 { 171 if (!req->rq_disk) 172 return 0; 173 return blk_mq_unique_tag_to_hwq(blk_mq_unique_tag(req)) + 1; 174 } 175 176 /* The below value is the specific amount of delay needed before checking 177 * readiness in case of the PCI_DEVICE(0x1c58, 0x0003), which needs the 178 * NVME_QUIRK_DELAY_BEFORE_CHK_RDY quirk enabled. The value (in ms) was 179 * found empirically. 180 */ 181 #define NVME_QUIRK_DELAY_AMOUNT 2300 182 183 enum nvme_ctrl_state { 184 NVME_CTRL_NEW, 185 NVME_CTRL_LIVE, 186 NVME_CTRL_RESETTING, 187 NVME_CTRL_CONNECTING, 188 NVME_CTRL_DELETING, 189 NVME_CTRL_DEAD, 190 }; 191 192 struct nvme_fault_inject { 193 #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS 194 struct fault_attr attr; 195 struct dentry *parent; 196 bool dont_retry; /* DNR, do not retry */ 197 u16 status; /* status code */ 198 #endif 199 }; 200 201 struct nvme_ctrl { 202 bool comp_seen; 203 enum nvme_ctrl_state state; 204 bool identified; 205 spinlock_t lock; 206 struct mutex scan_lock; 207 const struct nvme_ctrl_ops *ops; 208 struct request_queue *admin_q; 209 struct request_queue *connect_q; 210 struct request_queue *fabrics_q; 211 struct device *dev; 212 int instance; 213 int numa_node; 214 struct blk_mq_tag_set *tagset; 215 struct blk_mq_tag_set *admin_tagset; 216 struct list_head namespaces; 217 struct rw_semaphore namespaces_rwsem; 218 struct device ctrl_device; 219 struct device *device; /* char device */ 220 struct cdev cdev; 221 struct work_struct reset_work; 222 struct work_struct delete_work; 223 wait_queue_head_t state_wq; 224 225 struct nvme_subsystem *subsys; 226 struct list_head subsys_entry; 227 228 struct opal_dev *opal_dev; 229 230 char name[12]; 231 u16 cntlid; 232 233 u32 ctrl_config; 234 u16 mtfa; 235 u32 queue_count; 236 237 u64 cap; 238 u32 page_size; 239 u32 max_hw_sectors; 240 u32 max_segments; 241 u32 max_integrity_segments; 242 u16 crdt[3]; 243 u16 oncs; 244 u16 oacs; 245 u16 nssa; 246 u16 nr_streams; 247 u16 sqsize; 248 u32 max_namespaces; 249 atomic_t abort_limit; 250 u8 vwc; 251 u32 vs; 252 u32 sgls; 253 u16 kas; 254 u8 npss; 255 u8 apsta; 256 u16 wctemp; 257 u16 cctemp; 258 u32 oaes; 259 u32 aen_result; 260 u32 ctratt; 261 unsigned int shutdown_timeout; 262 unsigned int kato; 263 bool subsystem; 264 unsigned long quirks; 265 struct nvme_id_power_state psd[32]; 266 struct nvme_effects_log *effects; 267 struct work_struct scan_work; 268 struct work_struct async_event_work; 269 struct delayed_work ka_work; 270 struct nvme_command ka_cmd; 271 struct work_struct fw_act_work; 272 unsigned long events; 273 bool created; 274 275 #ifdef CONFIG_NVME_MULTIPATH 276 /* asymmetric namespace access: */ 277 u8 anacap; 278 u8 anatt; 279 u32 anagrpmax; 280 u32 nanagrpid; 281 struct mutex ana_lock; 282 struct nvme_ana_rsp_hdr *ana_log_buf; 283 size_t ana_log_size; 284 struct timer_list anatt_timer; 285 struct work_struct ana_work; 286 #endif 287 288 /* Power saving configuration */ 289 u64 ps_max_latency_us; 290 bool apst_enabled; 291 292 /* PCIe only: */ 293 u32 hmpre; 294 u32 hmmin; 295 u32 hmminds; 296 u16 hmmaxd; 297 298 /* Fabrics only */ 299 u32 ioccsz; 300 u32 iorcsz; 301 u16 icdoff; 302 u16 maxcmd; 303 int nr_reconnects; 304 struct nvmf_ctrl_options *opts; 305 306 struct page *discard_page; 307 unsigned long discard_page_busy; 308 309 struct nvme_fault_inject fault_inject; 310 }; 311 312 enum nvme_iopolicy { 313 NVME_IOPOLICY_NUMA, 314 NVME_IOPOLICY_RR, 315 }; 316 317 struct nvme_subsystem { 318 int instance; 319 struct device dev; 320 /* 321 * Because we unregister the device on the last put we need 322 * a separate refcount. 323 */ 324 struct kref ref; 325 struct list_head entry; 326 struct mutex lock; 327 struct list_head ctrls; 328 struct list_head nsheads; 329 char subnqn[NVMF_NQN_SIZE]; 330 char serial[20]; 331 char model[40]; 332 char firmware_rev[8]; 333 u8 cmic; 334 u16 vendor_id; 335 u16 awupf; /* 0's based awupf value. */ 336 struct ida ns_ida; 337 #ifdef CONFIG_NVME_MULTIPATH 338 enum nvme_iopolicy iopolicy; 339 #endif 340 }; 341 342 /* 343 * Container structure for uniqueue namespace identifiers. 344 */ 345 struct nvme_ns_ids { 346 u8 eui64[8]; 347 u8 nguid[16]; 348 uuid_t uuid; 349 }; 350 351 /* 352 * Anchor structure for namespaces. There is one for each namespace in a 353 * NVMe subsystem that any of our controllers can see, and the namespace 354 * structure for each controller is chained of it. For private namespaces 355 * there is a 1:1 relation to our namespace structures, that is ->list 356 * only ever has a single entry for private namespaces. 357 */ 358 struct nvme_ns_head { 359 struct list_head list; 360 struct srcu_struct srcu; 361 struct nvme_subsystem *subsys; 362 unsigned ns_id; 363 struct nvme_ns_ids ids; 364 struct list_head entry; 365 struct kref ref; 366 bool shared; 367 int instance; 368 #ifdef CONFIG_NVME_MULTIPATH 369 struct gendisk *disk; 370 struct bio_list requeue_list; 371 spinlock_t requeue_lock; 372 struct work_struct requeue_work; 373 struct mutex lock; 374 unsigned long flags; 375 #define NVME_NSHEAD_DISK_LIVE 0 376 struct nvme_ns __rcu *current_path[]; 377 #endif 378 }; 379 380 enum nvme_ns_features { 381 NVME_NS_EXT_LBAS = 1 << 0, /* support extended LBA format */ 382 NVME_NS_METADATA_SUPPORTED = 1 << 1, /* support getting generated md */ 383 }; 384 385 struct nvme_ns { 386 struct list_head list; 387 388 struct nvme_ctrl *ctrl; 389 struct request_queue *queue; 390 struct gendisk *disk; 391 #ifdef CONFIG_NVME_MULTIPATH 392 enum nvme_ana_state ana_state; 393 u32 ana_grpid; 394 #endif 395 struct list_head siblings; 396 struct nvm_dev *ndev; 397 struct kref kref; 398 struct nvme_ns_head *head; 399 400 int lba_shift; 401 u16 ms; 402 u16 sgs; 403 u32 sws; 404 u8 pi_type; 405 unsigned long features; 406 unsigned long flags; 407 #define NVME_NS_REMOVING 0 408 #define NVME_NS_DEAD 1 409 #define NVME_NS_ANA_PENDING 2 410 411 struct nvme_fault_inject fault_inject; 412 413 }; 414 415 /* NVMe ns supports metadata actions by the controller (generate/strip) */ 416 static inline bool nvme_ns_has_pi(struct nvme_ns *ns) 417 { 418 return ns->pi_type && ns->ms == sizeof(struct t10_pi_tuple); 419 } 420 421 struct nvme_ctrl_ops { 422 const char *name; 423 struct module *module; 424 unsigned int flags; 425 #define NVME_F_FABRICS (1 << 0) 426 #define NVME_F_METADATA_SUPPORTED (1 << 1) 427 #define NVME_F_PCI_P2PDMA (1 << 2) 428 int (*reg_read32)(struct nvme_ctrl *ctrl, u32 off, u32 *val); 429 int (*reg_write32)(struct nvme_ctrl *ctrl, u32 off, u32 val); 430 int (*reg_read64)(struct nvme_ctrl *ctrl, u32 off, u64 *val); 431 void (*free_ctrl)(struct nvme_ctrl *ctrl); 432 void (*submit_async_event)(struct nvme_ctrl *ctrl); 433 void (*delete_ctrl)(struct nvme_ctrl *ctrl); 434 int (*get_address)(struct nvme_ctrl *ctrl, char *buf, int size); 435 }; 436 437 #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS 438 void nvme_fault_inject_init(struct nvme_fault_inject *fault_inj, 439 const char *dev_name); 440 void nvme_fault_inject_fini(struct nvme_fault_inject *fault_inject); 441 void nvme_should_fail(struct request *req); 442 #else 443 static inline void nvme_fault_inject_init(struct nvme_fault_inject *fault_inj, 444 const char *dev_name) 445 { 446 } 447 static inline void nvme_fault_inject_fini(struct nvme_fault_inject *fault_inj) 448 { 449 } 450 static inline void nvme_should_fail(struct request *req) {} 451 #endif 452 453 static inline int nvme_reset_subsystem(struct nvme_ctrl *ctrl) 454 { 455 if (!ctrl->subsystem) 456 return -ENOTTY; 457 return ctrl->ops->reg_write32(ctrl, NVME_REG_NSSR, 0x4E564D65); 458 } 459 460 /* 461 * Convert a 512B sector number to a device logical block number. 462 */ 463 static inline u64 nvme_sect_to_lba(struct nvme_ns *ns, sector_t sector) 464 { 465 return sector >> (ns->lba_shift - SECTOR_SHIFT); 466 } 467 468 /* 469 * Convert a device logical block number to a 512B sector number. 470 */ 471 static inline sector_t nvme_lba_to_sect(struct nvme_ns *ns, u64 lba) 472 { 473 return lba << (ns->lba_shift - SECTOR_SHIFT); 474 } 475 476 /* 477 * Convert byte length to nvme's 0-based num dwords 478 */ 479 static inline u32 nvme_bytes_to_numd(size_t len) 480 { 481 return (len >> 2) - 1; 482 } 483 484 static inline void nvme_end_request(struct request *req, __le16 status, 485 union nvme_result result) 486 { 487 struct nvme_request *rq = nvme_req(req); 488 489 rq->status = le16_to_cpu(status) >> 1; 490 rq->result = result; 491 /* inject error when permitted by fault injection framework */ 492 nvme_should_fail(req); 493 blk_mq_complete_request(req); 494 } 495 496 static inline void nvme_get_ctrl(struct nvme_ctrl *ctrl) 497 { 498 get_device(ctrl->device); 499 } 500 501 static inline void nvme_put_ctrl(struct nvme_ctrl *ctrl) 502 { 503 put_device(ctrl->device); 504 } 505 506 static inline bool nvme_is_aen_req(u16 qid, __u16 command_id) 507 { 508 return !qid && command_id >= NVME_AQ_BLK_MQ_DEPTH; 509 } 510 511 void nvme_complete_rq(struct request *req); 512 bool nvme_cancel_request(struct request *req, void *data, bool reserved); 513 bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl, 514 enum nvme_ctrl_state new_state); 515 bool nvme_wait_reset(struct nvme_ctrl *ctrl); 516 int nvme_disable_ctrl(struct nvme_ctrl *ctrl); 517 int nvme_enable_ctrl(struct nvme_ctrl *ctrl); 518 int nvme_shutdown_ctrl(struct nvme_ctrl *ctrl); 519 int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev, 520 const struct nvme_ctrl_ops *ops, unsigned long quirks); 521 void nvme_uninit_ctrl(struct nvme_ctrl *ctrl); 522 void nvme_start_ctrl(struct nvme_ctrl *ctrl); 523 void nvme_stop_ctrl(struct nvme_ctrl *ctrl); 524 int nvme_init_identify(struct nvme_ctrl *ctrl); 525 526 void nvme_remove_namespaces(struct nvme_ctrl *ctrl); 527 528 int nvme_sec_submit(void *data, u16 spsp, u8 secp, void *buffer, size_t len, 529 bool send); 530 531 void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status, 532 volatile union nvme_result *res); 533 534 void nvme_stop_queues(struct nvme_ctrl *ctrl); 535 void nvme_start_queues(struct nvme_ctrl *ctrl); 536 void nvme_kill_queues(struct nvme_ctrl *ctrl); 537 void nvme_sync_queues(struct nvme_ctrl *ctrl); 538 void nvme_unfreeze(struct nvme_ctrl *ctrl); 539 void nvme_wait_freeze(struct nvme_ctrl *ctrl); 540 void nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl, long timeout); 541 void nvme_start_freeze(struct nvme_ctrl *ctrl); 542 543 #define NVME_QID_ANY -1 544 struct request *nvme_alloc_request(struct request_queue *q, 545 struct nvme_command *cmd, blk_mq_req_flags_t flags, int qid); 546 void nvme_cleanup_cmd(struct request *req); 547 blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req, 548 struct nvme_command *cmd); 549 int nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd, 550 void *buf, unsigned bufflen); 551 int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd, 552 union nvme_result *result, void *buffer, unsigned bufflen, 553 unsigned timeout, int qid, int at_head, 554 blk_mq_req_flags_t flags, bool poll); 555 int nvme_set_features(struct nvme_ctrl *dev, unsigned int fid, 556 unsigned int dword11, void *buffer, size_t buflen, 557 u32 *result); 558 int nvme_get_features(struct nvme_ctrl *dev, unsigned int fid, 559 unsigned int dword11, void *buffer, size_t buflen, 560 u32 *result); 561 int nvme_set_queue_count(struct nvme_ctrl *ctrl, int *count); 562 void nvme_stop_keep_alive(struct nvme_ctrl *ctrl); 563 int nvme_reset_ctrl(struct nvme_ctrl *ctrl); 564 int nvme_reset_ctrl_sync(struct nvme_ctrl *ctrl); 565 int nvme_try_sched_reset(struct nvme_ctrl *ctrl); 566 int nvme_delete_ctrl(struct nvme_ctrl *ctrl); 567 568 int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp, 569 void *log, size_t size, u64 offset); 570 571 extern const struct attribute_group *nvme_ns_id_attr_groups[]; 572 extern const struct block_device_operations nvme_ns_head_ops; 573 574 #ifdef CONFIG_NVME_MULTIPATH 575 static inline bool nvme_ctrl_use_ana(struct nvme_ctrl *ctrl) 576 { 577 return ctrl->ana_log_buf != NULL; 578 } 579 580 void nvme_mpath_unfreeze(struct nvme_subsystem *subsys); 581 void nvme_mpath_wait_freeze(struct nvme_subsystem *subsys); 582 void nvme_mpath_start_freeze(struct nvme_subsystem *subsys); 583 void nvme_set_disk_name(char *disk_name, struct nvme_ns *ns, 584 struct nvme_ctrl *ctrl, int *flags); 585 bool nvme_failover_req(struct request *req); 586 void nvme_kick_requeue_lists(struct nvme_ctrl *ctrl); 587 int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl,struct nvme_ns_head *head); 588 void nvme_mpath_add_disk(struct nvme_ns *ns, struct nvme_id_ns *id); 589 void nvme_mpath_remove_disk(struct nvme_ns_head *head); 590 int nvme_mpath_init(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id); 591 void nvme_mpath_uninit(struct nvme_ctrl *ctrl); 592 void nvme_mpath_stop(struct nvme_ctrl *ctrl); 593 bool nvme_mpath_clear_current_path(struct nvme_ns *ns); 594 void nvme_mpath_clear_ctrl_paths(struct nvme_ctrl *ctrl); 595 struct nvme_ns *nvme_find_path(struct nvme_ns_head *head); 596 597 static inline void nvme_mpath_check_last_path(struct nvme_ns *ns) 598 { 599 struct nvme_ns_head *head = ns->head; 600 601 if (head->disk && list_empty(&head->list)) 602 kblockd_schedule_work(&head->requeue_work); 603 } 604 605 static inline void nvme_trace_bio_complete(struct request *req, 606 blk_status_t status) 607 { 608 struct nvme_ns *ns = req->q->queuedata; 609 610 if (req->cmd_flags & REQ_NVME_MPATH) 611 trace_block_bio_complete(ns->head->disk->queue, req->bio); 612 } 613 614 static inline void nvme_mpath_update_disk_size(struct gendisk *disk) 615 { 616 struct block_device *bdev = bdget_disk(disk, 0); 617 618 if (bdev) { 619 bd_set_size(bdev, get_capacity(disk) << SECTOR_SHIFT); 620 bdput(bdev); 621 } 622 } 623 624 extern struct device_attribute dev_attr_ana_grpid; 625 extern struct device_attribute dev_attr_ana_state; 626 extern struct device_attribute subsys_attr_iopolicy; 627 628 #else 629 static inline bool nvme_ctrl_use_ana(struct nvme_ctrl *ctrl) 630 { 631 return false; 632 } 633 /* 634 * Without the multipath code enabled, multiple controller per subsystems are 635 * visible as devices and thus we cannot use the subsystem instance. 636 */ 637 static inline void nvme_set_disk_name(char *disk_name, struct nvme_ns *ns, 638 struct nvme_ctrl *ctrl, int *flags) 639 { 640 sprintf(disk_name, "nvme%dn%d", ctrl->instance, ns->head->instance); 641 } 642 643 static inline bool nvme_failover_req(struct request *req) 644 { 645 return false; 646 } 647 static inline void nvme_kick_requeue_lists(struct nvme_ctrl *ctrl) 648 { 649 } 650 static inline int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl, 651 struct nvme_ns_head *head) 652 { 653 return 0; 654 } 655 static inline void nvme_mpath_add_disk(struct nvme_ns *ns, 656 struct nvme_id_ns *id) 657 { 658 } 659 static inline void nvme_mpath_remove_disk(struct nvme_ns_head *head) 660 { 661 } 662 static inline bool nvme_mpath_clear_current_path(struct nvme_ns *ns) 663 { 664 return false; 665 } 666 static inline void nvme_mpath_clear_ctrl_paths(struct nvme_ctrl *ctrl) 667 { 668 } 669 static inline void nvme_mpath_check_last_path(struct nvme_ns *ns) 670 { 671 } 672 static inline void nvme_trace_bio_complete(struct request *req, 673 blk_status_t status) 674 { 675 } 676 static inline int nvme_mpath_init(struct nvme_ctrl *ctrl, 677 struct nvme_id_ctrl *id) 678 { 679 if (ctrl->subsys->cmic & (1 << 3)) 680 dev_warn(ctrl->device, 681 "Please enable CONFIG_NVME_MULTIPATH for full support of multi-port devices.\n"); 682 return 0; 683 } 684 static inline void nvme_mpath_uninit(struct nvme_ctrl *ctrl) 685 { 686 } 687 static inline void nvme_mpath_stop(struct nvme_ctrl *ctrl) 688 { 689 } 690 static inline void nvme_mpath_unfreeze(struct nvme_subsystem *subsys) 691 { 692 } 693 static inline void nvme_mpath_wait_freeze(struct nvme_subsystem *subsys) 694 { 695 } 696 static inline void nvme_mpath_start_freeze(struct nvme_subsystem *subsys) 697 { 698 } 699 static inline void nvme_mpath_update_disk_size(struct gendisk *disk) 700 { 701 } 702 #endif /* CONFIG_NVME_MULTIPATH */ 703 704 #ifdef CONFIG_NVM 705 int nvme_nvm_register(struct nvme_ns *ns, char *disk_name, int node); 706 void nvme_nvm_unregister(struct nvme_ns *ns); 707 extern const struct attribute_group nvme_nvm_attr_group; 708 int nvme_nvm_ioctl(struct nvme_ns *ns, unsigned int cmd, unsigned long arg); 709 #else 710 static inline int nvme_nvm_register(struct nvme_ns *ns, char *disk_name, 711 int node) 712 { 713 return 0; 714 } 715 716 static inline void nvme_nvm_unregister(struct nvme_ns *ns) {}; 717 static inline int nvme_nvm_ioctl(struct nvme_ns *ns, unsigned int cmd, 718 unsigned long arg) 719 { 720 return -ENOTTY; 721 } 722 #endif /* CONFIG_NVM */ 723 724 static inline struct nvme_ns *nvme_get_ns_from_dev(struct device *dev) 725 { 726 return dev_to_disk(dev)->private_data; 727 } 728 729 #ifdef CONFIG_NVME_HWMON 730 void nvme_hwmon_init(struct nvme_ctrl *ctrl); 731 #else 732 static inline void nvme_hwmon_init(struct nvme_ctrl *ctrl) { } 733 #endif 734 735 #endif /* _NVME_H */ 736