nvme.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. /*
  2. * Copyright (c) 2011-2014, Intel Corporation.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms and conditions of the GNU General Public License,
  6. * version 2, as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. */
  13. #ifndef _NVME_H
  14. #define _NVME_H
  15. #include <linux/nvme.h>
  16. #include <linux/cdev.h>
  17. #include <linux/pci.h>
  18. #include <linux/kref.h>
  19. #include <linux/blk-mq.h>
  20. #include <linux/lightnvm.h>
  21. #include <linux/sed-opal.h>
  22. #include <linux/fault-inject.h>
  23. #include <linux/rcupdate.h>
  24. extern unsigned int nvme_io_timeout;
  25. #define NVME_IO_TIMEOUT (nvme_io_timeout * HZ)
  26. extern unsigned int admin_timeout;
  27. #define ADMIN_TIMEOUT (admin_timeout * HZ)
  28. #define NVME_DEFAULT_KATO 5
  29. #define NVME_KATO_GRACE 10
  30. extern struct workqueue_struct *nvme_wq;
  31. extern struct workqueue_struct *nvme_reset_wq;
  32. extern struct workqueue_struct *nvme_delete_wq;
  33. enum {
  34. NVME_NS_LBA = 0,
  35. NVME_NS_LIGHTNVM = 1,
  36. };
  37. /*
  38. * List of workarounds for devices that required behavior not specified in
  39. * the standard.
  40. */
  41. enum nvme_quirks {
  42. /*
  43. * Prefers I/O aligned to a stripe size specified in a vendor
  44. * specific Identify field.
  45. */
  46. NVME_QUIRK_STRIPE_SIZE = (1 << 0),
  47. /*
  48. * The controller doesn't handle Identify value others than 0 or 1
  49. * correctly.
  50. */
  51. NVME_QUIRK_IDENTIFY_CNS = (1 << 1),
  52. /*
  53. * The controller deterministically returns O's on reads to
  54. * logical blocks that deallocate was called on.
  55. */
  56. NVME_QUIRK_DEALLOCATE_ZEROES = (1 << 2),
  57. /*
  58. * The controller needs a delay before starts checking the device
  59. * readiness, which is done by reading the NVME_CSTS_RDY bit.
  60. */
  61. NVME_QUIRK_DELAY_BEFORE_CHK_RDY = (1 << 3),
  62. /*
  63. * APST should not be used.
  64. */
  65. NVME_QUIRK_NO_APST = (1 << 4),
  66. /*
  67. * The deepest sleep state should not be used.
  68. */
  69. NVME_QUIRK_NO_DEEPEST_PS = (1 << 5),
  70. /*
  71. * Supports the LighNVM command set if indicated in vs[1].
  72. */
  73. NVME_QUIRK_LIGHTNVM = (1 << 6),
  74. /*
  75. * Set MEDIUM priority on SQ creation
  76. */
  77. NVME_QUIRK_MEDIUM_PRIO_SQ = (1 << 7),
  78. };
  79. /*
  80. * Common request structure for NVMe passthrough. All drivers must have
  81. * this structure as the first member of their request-private data.
  82. */
  83. struct nvme_request {
  84. struct nvme_command *cmd;
  85. union nvme_result result;
  86. u8 retries;
  87. u8 flags;
  88. u16 status;
  89. struct nvme_ctrl *ctrl;
  90. };
  91. /*
  92. * Mark a bio as coming in through the mpath node.
  93. */
  94. #define REQ_NVME_MPATH REQ_DRV
  95. enum {
  96. NVME_REQ_CANCELLED = (1 << 0),
  97. NVME_REQ_USERCMD = (1 << 1),
  98. };
  99. static inline struct nvme_request *nvme_req(struct request *req)
  100. {
  101. return blk_mq_rq_to_pdu(req);
  102. }
  103. static inline u16 nvme_req_qid(struct request *req)
  104. {
  105. if (!req->rq_disk)
  106. return 0;
  107. return blk_mq_unique_tag_to_hwq(blk_mq_unique_tag(req)) + 1;
  108. }
  109. /* The below value is the specific amount of delay needed before checking
  110. * readiness in case of the PCI_DEVICE(0x1c58, 0x0003), which needs the
  111. * NVME_QUIRK_DELAY_BEFORE_CHK_RDY quirk enabled. The value (in ms) was
  112. * found empirically.
  113. */
  114. #define NVME_QUIRK_DELAY_AMOUNT 2300
  115. enum nvme_ctrl_state {
  116. NVME_CTRL_NEW,
  117. NVME_CTRL_LIVE,
  118. NVME_CTRL_ADMIN_ONLY, /* Only admin queue live */
  119. NVME_CTRL_RESETTING,
  120. NVME_CTRL_CONNECTING,
  121. NVME_CTRL_DELETING,
  122. NVME_CTRL_DEAD,
  123. };
  124. struct nvme_ctrl {
  125. enum nvme_ctrl_state state;
  126. bool identified;
  127. spinlock_t lock;
  128. struct mutex scan_lock;
  129. const struct nvme_ctrl_ops *ops;
  130. struct request_queue *admin_q;
  131. struct request_queue *connect_q;
  132. struct device *dev;
  133. int instance;
  134. struct blk_mq_tag_set *tagset;
  135. struct blk_mq_tag_set *admin_tagset;
  136. struct list_head namespaces;
  137. struct rw_semaphore namespaces_rwsem;
  138. struct device ctrl_device;
  139. struct device *device; /* char device */
  140. struct cdev cdev;
  141. struct work_struct reset_work;
  142. struct work_struct delete_work;
  143. struct nvme_subsystem *subsys;
  144. struct list_head subsys_entry;
  145. struct opal_dev *opal_dev;
  146. char name[12];
  147. u16 cntlid;
  148. u32 ctrl_config;
  149. u16 mtfa;
  150. u32 queue_count;
  151. u64 cap;
  152. u32 page_size;
  153. u32 max_hw_sectors;
  154. u32 max_segments;
  155. u16 oncs;
  156. u16 oacs;
  157. u16 nssa;
  158. u16 nr_streams;
  159. u32 max_namespaces;
  160. atomic_t abort_limit;
  161. u8 vwc;
  162. u32 vs;
  163. u32 sgls;
  164. u16 kas;
  165. u8 npss;
  166. u8 apsta;
  167. u32 oaes;
  168. u32 aen_result;
  169. unsigned int shutdown_timeout;
  170. unsigned int kato;
  171. bool subsystem;
  172. unsigned long quirks;
  173. struct nvme_id_power_state psd[32];
  174. struct nvme_effects_log *effects;
  175. struct work_struct scan_work;
  176. struct work_struct async_event_work;
  177. struct delayed_work ka_work;
  178. struct nvme_command ka_cmd;
  179. struct work_struct fw_act_work;
  180. unsigned long events;
  181. bool created;
  182. #ifdef CONFIG_NVME_MULTIPATH
  183. /* asymmetric namespace access: */
  184. u8 anacap;
  185. u8 anatt;
  186. u32 anagrpmax;
  187. u32 nanagrpid;
  188. struct mutex ana_lock;
  189. struct nvme_ana_rsp_hdr *ana_log_buf;
  190. size_t ana_log_size;
  191. struct timer_list anatt_timer;
  192. struct work_struct ana_work;
  193. #endif
  194. /* Power saving configuration */
  195. u64 ps_max_latency_us;
  196. bool apst_enabled;
  197. /* PCIe only: */
  198. u32 hmpre;
  199. u32 hmmin;
  200. u32 hmminds;
  201. u16 hmmaxd;
  202. /* Fabrics only */
  203. u16 sqsize;
  204. u32 ioccsz;
  205. u32 iorcsz;
  206. u16 icdoff;
  207. u16 maxcmd;
  208. int nr_reconnects;
  209. struct nvmf_ctrl_options *opts;
  210. struct page *discard_page;
  211. unsigned long discard_page_busy;
  212. };
  213. struct nvme_subsystem {
  214. int instance;
  215. struct device dev;
  216. /*
  217. * Because we unregister the device on the last put we need
  218. * a separate refcount.
  219. */
  220. struct kref ref;
  221. struct list_head entry;
  222. struct mutex lock;
  223. struct list_head ctrls;
  224. struct list_head nsheads;
  225. char subnqn[NVMF_NQN_SIZE];
  226. char serial[20];
  227. char model[40];
  228. char firmware_rev[8];
  229. u8 cmic;
  230. u16 vendor_id;
  231. struct ida ns_ida;
  232. };
  233. /*
  234. * Container structure for uniqueue namespace identifiers.
  235. */
  236. struct nvme_ns_ids {
  237. u8 eui64[8];
  238. u8 nguid[16];
  239. uuid_t uuid;
  240. };
  241. /*
  242. * Anchor structure for namespaces. There is one for each namespace in a
  243. * NVMe subsystem that any of our controllers can see, and the namespace
  244. * structure for each controller is chained of it. For private namespaces
  245. * there is a 1:1 relation to our namespace structures, that is ->list
  246. * only ever has a single entry for private namespaces.
  247. */
  248. struct nvme_ns_head {
  249. #ifdef CONFIG_NVME_MULTIPATH
  250. struct gendisk *disk;
  251. struct nvme_ns __rcu *current_path;
  252. struct bio_list requeue_list;
  253. spinlock_t requeue_lock;
  254. struct work_struct requeue_work;
  255. struct mutex lock;
  256. #endif
  257. struct list_head list;
  258. struct srcu_struct srcu;
  259. struct nvme_subsystem *subsys;
  260. unsigned ns_id;
  261. struct nvme_ns_ids ids;
  262. struct list_head entry;
  263. struct kref ref;
  264. int instance;
  265. };
  266. #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
  267. struct nvme_fault_inject {
  268. struct fault_attr attr;
  269. struct dentry *parent;
  270. bool dont_retry; /* DNR, do not retry */
  271. u16 status; /* status code */
  272. };
  273. #endif
  274. struct nvme_ns {
  275. struct list_head list;
  276. struct nvme_ctrl *ctrl;
  277. struct request_queue *queue;
  278. struct gendisk *disk;
  279. #ifdef CONFIG_NVME_MULTIPATH
  280. enum nvme_ana_state ana_state;
  281. u32 ana_grpid;
  282. #endif
  283. struct list_head siblings;
  284. struct nvm_dev *ndev;
  285. struct kref kref;
  286. struct nvme_ns_head *head;
  287. int lba_shift;
  288. u16 ms;
  289. u16 sgs;
  290. u32 sws;
  291. bool ext;
  292. u8 pi_type;
  293. unsigned long flags;
  294. #define NVME_NS_REMOVING 0
  295. #define NVME_NS_DEAD 1
  296. #define NVME_NS_ANA_PENDING 2
  297. u16 noiob;
  298. #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
  299. struct nvme_fault_inject fault_inject;
  300. #endif
  301. };
  302. struct nvme_ctrl_ops {
  303. const char *name;
  304. struct module *module;
  305. unsigned int flags;
  306. #define NVME_F_FABRICS (1 << 0)
  307. #define NVME_F_METADATA_SUPPORTED (1 << 1)
  308. int (*reg_read32)(struct nvme_ctrl *ctrl, u32 off, u32 *val);
  309. int (*reg_write32)(struct nvme_ctrl *ctrl, u32 off, u32 val);
  310. int (*reg_read64)(struct nvme_ctrl *ctrl, u32 off, u64 *val);
  311. void (*free_ctrl)(struct nvme_ctrl *ctrl);
  312. void (*submit_async_event)(struct nvme_ctrl *ctrl);
  313. void (*delete_ctrl)(struct nvme_ctrl *ctrl);
  314. int (*get_address)(struct nvme_ctrl *ctrl, char *buf, int size);
  315. void (*stop_ctrl)(struct nvme_ctrl *ctrl);
  316. };
  317. #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
  318. void nvme_fault_inject_init(struct nvme_ns *ns);
  319. void nvme_fault_inject_fini(struct nvme_ns *ns);
  320. void nvme_should_fail(struct request *req);
  321. #else
  322. static inline void nvme_fault_inject_init(struct nvme_ns *ns) {}
  323. static inline void nvme_fault_inject_fini(struct nvme_ns *ns) {}
  324. static inline void nvme_should_fail(struct request *req) {}
  325. #endif
  326. static inline bool nvme_ctrl_ready(struct nvme_ctrl *ctrl)
  327. {
  328. u32 val = 0;
  329. if (ctrl->ops->reg_read32(ctrl, NVME_REG_CSTS, &val))
  330. return false;
  331. return val & NVME_CSTS_RDY;
  332. }
  333. static inline int nvme_reset_subsystem(struct nvme_ctrl *ctrl)
  334. {
  335. if (!ctrl->subsystem)
  336. return -ENOTTY;
  337. return ctrl->ops->reg_write32(ctrl, NVME_REG_NSSR, 0x4E564D65);
  338. }
  339. static inline u64 nvme_block_nr(struct nvme_ns *ns, sector_t sector)
  340. {
  341. return (sector >> (ns->lba_shift - 9));
  342. }
  343. static inline void nvme_end_request(struct request *req, __le16 status,
  344. union nvme_result result)
  345. {
  346. struct nvme_request *rq = nvme_req(req);
  347. rq->status = le16_to_cpu(status) >> 1;
  348. rq->result = result;
  349. /* inject error when permitted by fault injection framework */
  350. nvme_should_fail(req);
  351. blk_mq_complete_request(req);
  352. }
  353. static inline void nvme_get_ctrl(struct nvme_ctrl *ctrl)
  354. {
  355. get_device(ctrl->device);
  356. }
  357. static inline void nvme_put_ctrl(struct nvme_ctrl *ctrl)
  358. {
  359. put_device(ctrl->device);
  360. }
  361. void nvme_complete_rq(struct request *req);
  362. void nvme_cancel_request(struct request *req, void *data, bool reserved);
  363. bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
  364. enum nvme_ctrl_state new_state);
  365. int nvme_disable_ctrl(struct nvme_ctrl *ctrl, u64 cap);
  366. int nvme_enable_ctrl(struct nvme_ctrl *ctrl, u64 cap);
  367. int nvme_shutdown_ctrl(struct nvme_ctrl *ctrl);
  368. int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,
  369. const struct nvme_ctrl_ops *ops, unsigned long quirks);
  370. void nvme_uninit_ctrl(struct nvme_ctrl *ctrl);
  371. void nvme_start_ctrl(struct nvme_ctrl *ctrl);
  372. void nvme_stop_ctrl(struct nvme_ctrl *ctrl);
  373. void nvme_put_ctrl(struct nvme_ctrl *ctrl);
  374. int nvme_init_identify(struct nvme_ctrl *ctrl);
  375. void nvme_remove_namespaces(struct nvme_ctrl *ctrl);
  376. int nvme_sec_submit(void *data, u16 spsp, u8 secp, void *buffer, size_t len,
  377. bool send);
  378. void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status,
  379. volatile union nvme_result *res);
  380. void nvme_stop_queues(struct nvme_ctrl *ctrl);
  381. void nvme_start_queues(struct nvme_ctrl *ctrl);
  382. void nvme_kill_queues(struct nvme_ctrl *ctrl);
  383. void nvme_unfreeze(struct nvme_ctrl *ctrl);
  384. void nvme_wait_freeze(struct nvme_ctrl *ctrl);
  385. void nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl, long timeout);
  386. void nvme_start_freeze(struct nvme_ctrl *ctrl);
  387. #define NVME_QID_ANY -1
  388. struct request *nvme_alloc_request(struct request_queue *q,
  389. struct nvme_command *cmd, blk_mq_req_flags_t flags, int qid);
  390. void nvme_cleanup_cmd(struct request *req);
  391. blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req,
  392. struct nvme_command *cmd);
  393. int nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
  394. void *buf, unsigned bufflen);
  395. int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
  396. union nvme_result *result, void *buffer, unsigned bufflen,
  397. unsigned timeout, int qid, int at_head,
  398. blk_mq_req_flags_t flags);
  399. int nvme_set_queue_count(struct nvme_ctrl *ctrl, int *count);
  400. void nvme_stop_keep_alive(struct nvme_ctrl *ctrl);
  401. int nvme_reset_ctrl(struct nvme_ctrl *ctrl);
  402. int nvme_reset_ctrl_sync(struct nvme_ctrl *ctrl);
  403. int nvme_delete_ctrl(struct nvme_ctrl *ctrl);
  404. int nvme_delete_ctrl_sync(struct nvme_ctrl *ctrl);
  405. int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp,
  406. void *log, size_t size, u64 offset);
  407. extern const struct attribute_group *nvme_ns_id_attr_groups[];
  408. extern const struct block_device_operations nvme_ns_head_ops;
  409. #ifdef CONFIG_NVME_MULTIPATH
  410. static inline bool nvme_ctrl_use_ana(struct nvme_ctrl *ctrl)
  411. {
  412. return ctrl->ana_log_buf != NULL;
  413. }
  414. void nvme_mpath_unfreeze(struct nvme_subsystem *subsys);
  415. void nvme_mpath_wait_freeze(struct nvme_subsystem *subsys);
  416. void nvme_mpath_start_freeze(struct nvme_subsystem *subsys);
  417. void nvme_set_disk_name(char *disk_name, struct nvme_ns *ns,
  418. struct nvme_ctrl *ctrl, int *flags);
  419. bool nvme_failover_req(struct request *req);
  420. void nvme_kick_requeue_lists(struct nvme_ctrl *ctrl);
  421. int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl,struct nvme_ns_head *head);
  422. void nvme_mpath_add_disk(struct nvme_ns *ns, struct nvme_id_ns *id);
  423. void nvme_mpath_remove_disk(struct nvme_ns_head *head);
  424. int nvme_mpath_init(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id);
  425. void nvme_mpath_uninit(struct nvme_ctrl *ctrl);
  426. void nvme_mpath_stop(struct nvme_ctrl *ctrl);
  427. static inline void nvme_mpath_clear_current_path(struct nvme_ns *ns)
  428. {
  429. struct nvme_ns_head *head = ns->head;
  430. if (head && ns == rcu_access_pointer(head->current_path))
  431. rcu_assign_pointer(head->current_path, NULL);
  432. }
  433. struct nvme_ns *nvme_find_path(struct nvme_ns_head *head);
  434. static inline void nvme_mpath_check_last_path(struct nvme_ns *ns)
  435. {
  436. struct nvme_ns_head *head = ns->head;
  437. if (head->disk && list_empty(&head->list))
  438. kblockd_schedule_work(&head->requeue_work);
  439. }
  440. static inline void nvme_mpath_update_disk_size(struct gendisk *disk)
  441. {
  442. struct block_device *bdev = bdget_disk(disk, 0);
  443. if (bdev) {
  444. bd_set_size(bdev, get_capacity(disk) << SECTOR_SHIFT);
  445. bdput(bdev);
  446. }
  447. }
  448. extern struct device_attribute dev_attr_ana_grpid;
  449. extern struct device_attribute dev_attr_ana_state;
  450. #else
  451. static inline bool nvme_ctrl_use_ana(struct nvme_ctrl *ctrl)
  452. {
  453. return false;
  454. }
  455. /*
  456. * Without the multipath code enabled, multiple controller per subsystems are
  457. * visible as devices and thus we cannot use the subsystem instance.
  458. */
  459. static inline void nvme_set_disk_name(char *disk_name, struct nvme_ns *ns,
  460. struct nvme_ctrl *ctrl, int *flags)
  461. {
  462. sprintf(disk_name, "nvme%dn%d", ctrl->instance, ns->head->instance);
  463. }
  464. static inline bool nvme_failover_req(struct request *req)
  465. {
  466. return false;
  467. }
  468. static inline void nvme_kick_requeue_lists(struct nvme_ctrl *ctrl)
  469. {
  470. }
  471. static inline int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl,
  472. struct nvme_ns_head *head)
  473. {
  474. return 0;
  475. }
  476. static inline void nvme_mpath_add_disk(struct nvme_ns *ns,
  477. struct nvme_id_ns *id)
  478. {
  479. }
  480. static inline void nvme_mpath_remove_disk(struct nvme_ns_head *head)
  481. {
  482. }
  483. static inline void nvme_mpath_clear_current_path(struct nvme_ns *ns)
  484. {
  485. }
  486. static inline void nvme_mpath_check_last_path(struct nvme_ns *ns)
  487. {
  488. }
  489. static inline int nvme_mpath_init(struct nvme_ctrl *ctrl,
  490. struct nvme_id_ctrl *id)
  491. {
  492. if (ctrl->subsys->cmic & (1 << 3))
  493. dev_warn(ctrl->device,
  494. "Please enable CONFIG_NVME_MULTIPATH for full support of multi-port devices.\n");
  495. return 0;
  496. }
  497. static inline void nvme_mpath_uninit(struct nvme_ctrl *ctrl)
  498. {
  499. }
  500. static inline void nvme_mpath_stop(struct nvme_ctrl *ctrl)
  501. {
  502. }
  503. static inline void nvme_mpath_unfreeze(struct nvme_subsystem *subsys)
  504. {
  505. }
  506. static inline void nvme_mpath_wait_freeze(struct nvme_subsystem *subsys)
  507. {
  508. }
  509. static inline void nvme_mpath_start_freeze(struct nvme_subsystem *subsys)
  510. {
  511. }
  512. static inline void nvme_mpath_update_disk_size(struct gendisk *disk)
  513. {
  514. }
  515. #endif /* CONFIG_NVME_MULTIPATH */
  516. #ifdef CONFIG_NVM
  517. void nvme_nvm_update_nvm_info(struct nvme_ns *ns);
  518. int nvme_nvm_register(struct nvme_ns *ns, char *disk_name, int node);
  519. void nvme_nvm_unregister(struct nvme_ns *ns);
  520. extern const struct attribute_group nvme_nvm_attr_group;
  521. int nvme_nvm_ioctl(struct nvme_ns *ns, unsigned int cmd, unsigned long arg);
  522. #else
  523. static inline void nvme_nvm_update_nvm_info(struct nvme_ns *ns) {};
  524. static inline int nvme_nvm_register(struct nvme_ns *ns, char *disk_name,
  525. int node)
  526. {
  527. return 0;
  528. }
  529. static inline void nvme_nvm_unregister(struct nvme_ns *ns) {};
  530. static inline int nvme_nvm_ioctl(struct nvme_ns *ns, unsigned int cmd,
  531. unsigned long arg)
  532. {
  533. return -ENOTTY;
  534. }
  535. #endif /* CONFIG_NVM */
  536. static inline struct nvme_ns *nvme_get_ns_from_dev(struct device *dev)
  537. {
  538. return dev_to_disk(dev)->private_data;
  539. }
  540. int __init nvme_core_init(void);
  541. void nvme_core_exit(void);
  542. #endif /* _NVME_H */