Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
nvme.h
Go to the documentation of this file.
1 /*
2  * Definitions for the NVM Express interface
3  * Copyright (c) 2011, Intel Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms and conditions of the GNU General Public License,
7  * version 2, as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef _LINUX_NVME_H
20 #define _LINUX_NVME_H
21 
22 #include <linux/types.h>
23 
24 struct nvme_bar {
25  __u64 cap; /* Controller Capabilities */
26  __u32 vs; /* Version */
27  __u32 intms; /* Interrupt Mask Set */
28  __u32 intmc; /* Interrupt Mask Clear */
29  __u32 cc; /* Controller Configuration */
30  __u32 rsvd1; /* Reserved */
31  __u32 csts; /* Controller Status */
32  __u32 rsvd2; /* Reserved */
33  __u32 aqa; /* Admin Queue Attributes */
34  __u64 asq; /* Admin SQ Base Address */
35  __u64 acq; /* Admin CQ Base Address */
36 };
37 
38 #define NVME_CAP_MQES(cap) ((cap) & 0xffff)
39 #define NVME_CAP_TIMEOUT(cap) (((cap) >> 24) & 0xff)
40 #define NVME_CAP_STRIDE(cap) (((cap) >> 32) & 0xf)
41 #define NVME_CAP_MPSMIN(cap) (((cap) >> 48) & 0xf)
42 
43 enum {
44  NVME_CC_ENABLE = 1 << 0,
45  NVME_CC_CSS_NVM = 0 << 4,
47  NVME_CC_ARB_RR = 0 << 11,
48  NVME_CC_ARB_WRRU = 1 << 11,
49  NVME_CC_ARB_VS = 7 << 11,
50  NVME_CC_SHN_NONE = 0 << 14,
51  NVME_CC_SHN_NORMAL = 1 << 14,
52  NVME_CC_SHN_ABRUPT = 2 << 14,
53  NVME_CC_IOSQES = 6 << 16,
54  NVME_CC_IOCQES = 4 << 20,
55  NVME_CSTS_RDY = 1 << 0,
56  NVME_CSTS_CFS = 1 << 1,
60 };
61 
63  __le16 max_power; /* centiwatts */
65  __le32 entry_lat; /* microseconds */
66  __le32 exit_lat; /* microseconds */
71  __u8 rsvd16[16];
72 };
73 
74 #define NVME_VS(major, minor) (major << 16 | minor)
75 
76 struct nvme_id_ctrl {
79  char sn[20];
80  char mn[40];
81  char fr[8];
83  __u8 ieee[3];
86  __u8 rsvd78[178];
94  __u8 rsvd264[248];
105  __u8 rsvd530[1518];
107  __u8 vs[1024];
108 };
109 
110 struct nvme_lbaf {
114 };
115 
116 struct nvme_id_ns {
127  struct nvme_lbaf lbaf[16];
128  __u8 rsvd192[192];
129  __u8 vs[3712];
130 };
131 
132 enum {
138 };
139 
143  __u8 rsvd2[14];
146  __u8 guid[16];
148 };
149 
150 enum {
155 
158 };
159 
160 /* I/O commands */
161 
168  nvme_cmd_dsm = 0x09,
169 };
170 
181 };
182 
199 };
200 
201 enum {
202  NVME_RW_LR = 1 << 15,
203  NVME_RW_FUA = 1 << 14,
219 };
220 
221 /* Admin commands */
222 
239 };
240 
241 enum {
245  NVME_SQ_PRIO_HIGH = (1 << 1),
247  NVME_SQ_PRIO_LOW = (3 << 1),
260 };
261 
272 };
273 
285 };
286 
299 };
300 
313 };
314 
323 };
324 
335 };
336 
337 struct nvme_command {
338  union {
347  };
348 };
349 
350 enum {
385 };
386 
388  __le32 result; /* Used by admin commands to return data */
390  __le16 sq_head; /* how much of this queue may be reclaimed */
391  __le16 sq_id; /* submission queue that generated this entry */
392  __u16 command_id; /* of the command which completed */
393  __le16 status; /* did the command fail, and if so, why? */
394 };
395 
396 struct nvme_user_io {
409 };
410 
430 };
431 
432 #define NVME_IOCTL_ID _IO('N', 0x40)
433 #define NVME_IOCTL_ADMIN_CMD _IOWR('N', 0x41, struct nvme_admin_cmd)
434 #define NVME_IOCTL_SUBMIT_IO _IOW('N', 0x42, struct nvme_user_io)
435 
436 #endif /* _LINUX_NVME_H */