]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/NvmExpressPassthru.h
MdePkg: Fix EOL to be DOS format.
[mirror_edk2.git] / MdePkg / Include / Protocol / NvmExpressPassthru.h
CommitLineData
21bd4958
FT
1/** @file\r
2 This protocol provides services that allow NVM Express commands to be sent to an\r
3 NVM Express controller or to a specific namespace in a NVM Express controller.\r
4 This protocol interface is optimized for storage.\r
5\r
6 Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.<BR>\r
7 This program and the accompanying materials\r
8 are licensed and made available under the terms and conditions of the BSD License\r
9 which accompanies this distribution. The full text of the license may be found at\r
10 http://opensource.org/licenses/bsd-license.php.\r
11\r
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15**/\r
16\r
17#ifndef _UEFI_NVM_EXPRESS_PASS_THRU_H_\r
18#define _UEFI_NVM_EXPRESS_PASS_THRU_H_\r
19\r
20#define EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL_GUID \\r
21 { \\r
22 0x52c78312, 0x8edc, 0x4233, { 0x98, 0xf2, 0x1a, 0x1a, 0xa5, 0xe3, 0x88, 0xa5 } \\r
23 }\r
24\r
25typedef struct _EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL;\r
26\r
27typedef struct {\r
28 UINT32 Attributes;\r
29 UINT32 IoAlign;\r
30 UINT32 NvmeVersion;\r
31} EFI_NVM_EXPRESS_PASS_THRU_MODE;\r
32\r
33//\r
34// If this bit is set, then the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL interface is\r
35// for directly addressable namespaces.\r
36//\r
37#define EFI_NVM_EXPRESS_PASS_THRU_ATTRIBUTES_PHYSICAL 0x0001\r
38//\r
39// If this bit is set, then the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL interface is\r
40// for a single volume logical namespace comprised of multiple namespaces.\r
41//\r
42#define EFI_NVM_EXPRESS_PASS_THRU_ATTRIBUTES_LOGICAL 0x0002\r
43//\r
44// If this bit is set, then the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL interface\r
45// supports non-blocking I/O.\r
46//\r
47#define EFI_NVM_EXPRESS_PASS_THRU_ATTRIBUTES_NONBLOCKIO 0x0004\r
48//\r
49// If this bit is set, then the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL interface\r
50// supports NVM command set.\r
51//\r
52#define EFI_NVM_EXPRESS_PASS_THRU_ATTRIBUTES_CMD_SET_NVM 0x0008\r
53\r
54//\r
55// FusedOperation\r
56//\r
57#define NORMAL_CMD 0x00\r
58#define FUSED_FIRST_CMD 0x01\r
59#define FUSED_SECOND_CMD 0x02\r
60\r
61typedef struct {\r
62 UINT32 Opcode:8;\r
63 UINT32 FusedOperation:2;\r
64 UINT32 Reserved:22;\r
65} NVME_CDW0;\r
66\r
67//\r
68// Flags\r
69//\r
70#define CDW2_VALID 0x01\r
71#define CDW3_VALID 0x02\r
72#define CDW10_VALID 0x04\r
73#define CDW11_VALID 0x08\r
74#define CDW12_VALID 0x10\r
75#define CDW13_VALID 0x20\r
76#define CDW14_VALID 0x40\r
77#define CDW15_VALID 0x80\r
78\r
79//\r
80// Queue Type\r
81//\r
82#define NVME_ADMIN_QUEUE 0x00\r
83#define NVME_IO_QUEUE 0x01\r
84\r
85typedef struct {\r
86 NVME_CDW0 Cdw0;\r
87 UINT8 Flags;\r
88 UINT32 Nsid;\r
89 UINT32 Cdw2;\r
90 UINT32 Cdw3;\r
91 UINT32 Cdw10;\r
92 UINT32 Cdw11;\r
93 UINT32 Cdw12;\r
94 UINT32 Cdw13;\r
95 UINT32 Cdw14;\r
96 UINT32 Cdw15;\r
97} EFI_NVM_EXPRESS_COMMAND;\r
98\r
99typedef struct {\r
100 UINT32 DW0;\r
101 UINT32 DW1;\r
102 UINT32 DW2;\r
103 UINT32 DW3;\r
104} EFI_NVM_EXPRESS_COMPLETION;\r
105\r
106typedef struct {\r
107 UINT64 CommandTimeout;\r
108 VOID *TransferBuffer;\r
109 UINT32 TransferLength;\r
110 VOID *MetadataBuffer;\r
111 UINT32 MetadataLength;\r
112 UINT8 QueueType;\r
113 EFI_NVM_EXPRESS_COMMAND *NvmeCmd;\r
114 EFI_NVM_EXPRESS_COMPLETION *NvmeCompletion;\r
115} EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET;\r
116\r
117//\r
118// Protocol funtion prototypes\r
119//\r
120/**\r
121 Sends an NVM Express Command Packet to an NVM Express controller or namespace. This function supports\r
122 both blocking I/O and non-blocking I/O. The blocking I/O functionality is required, and the non-blocking\r
123 I/O functionality is optional.\r
124\r
125\r
126 @param[in] This A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance.\r
127 @param[in] NamespaceId A 32 bit namespace ID as defined in the NVMe specification to which the NVM Express Command\r
128 Packet will be sent. A value of 0 denotes the NVM Express controller, a value of all 0xFF's\r
129 (all bytes are 0xFF) in the namespace ID specifies that the command packet should be sent to\r
130 all valid namespaces.\r
131 @param[in,out] Packet A pointer to the NVM Express Command Packet.\r
132 @param[in] Event If non-blocking I/O is not supported then Event is ignored, and blocking I/O is performed.\r
133 If Event is NULL, then blocking I/O is performed. If Event is not NULL and non-blocking I/O\r
134 is supported, then non-blocking I/O is performed, and Event will be signaled when the NVM\r
135 Express Command Packet completes. \r
136\r
137 @retval EFI_SUCCESS The NVM Express Command Packet was sent by the host. TransferLength bytes were transferred\r
138 to, or from DataBuffer.\r
139 @retval EFI_BAD_BUFFER_SIZE The NVM Express Command Packet was not executed. The number of bytes that could be transferred\r
140 is returned in TransferLength.\r
141 @retval EFI_NOT_READY The NVM Express Command Packet could not be sent because the controller is not ready. The caller\r
142 may retry again later.\r
143 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the NVM Express Command Packet.\r
144 @retval EFI_INVALID_PARAMETER NamespaceId or the contents of EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET are invalid. The NVM\r
145 Express Command Packet was not sent, so no additional status information is available.\r
146 @retval EFI_UNSUPPORTED The command described by the NVM Express Command Packet is not supported by the NVM Express\r
147 controller. The NVM Express Command Packet was not sent so no additional status information\r
148 is available.\r
149 @retval EFI_TIMEOUT A timeout occurred while waiting for the NVM Express Command Packet to execute.\r
150\r
151**/\r
152typedef\r
153EFI_STATUS\r
154(EFIAPI *EFI_NVM_EXPRESS_PASS_THRU_PASSTHRU)(\r
155 IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *This,\r
156 IN UINT32 NamespaceId,\r
157 IN OUT EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET *Packet,\r
158 IN EFI_EVENT Event OPTIONAL\r
159 );\r
160\r
161/**\r
162 Used to retrieve the next namespace ID for this NVM Express controller.\r
163\r
164 The EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL.GetNextNamespace() function retrieves the next valid\r
165 namespace ID on this NVM Express controller. \r
166\r
167 If on input the value pointed to by NamespaceId is 0xFFFFFFFF, then the first valid namespace\r
168 ID defined on the NVM Express controller is returned in the location pointed to by NamespaceId\r
169 and a status of EFI_SUCCESS is returned.\r
170\r
171 If on input the value pointed to by NamespaceId is an invalid namespace ID other than 0xFFFFFFFF,\r
172 then EFI_INVALID_PARAMETER is returned.\r
173\r
174 If on input the value pointed to by NamespaceId is a valid namespace ID, then the next valid\r
175 namespace ID on the NVM Express controller is returned in the location pointed to by NamespaceId,\r
176 and EFI_SUCCESS is returned.\r
177\r
178 If the value pointed to by NamespaceId is the namespace ID of the last namespace on the NVM\r
179 Express controller, then EFI_NOT_FOUND is returned.\r
180\r
181 @param[in] This A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance.\r
182 @param[in,out] NamespaceId On input, a pointer to a legal NamespaceId for an NVM Express\r
183 namespace present on the NVM Express controller. On output, a\r
184 pointer to the next NamespaceId of an NVM Express namespace on\r
185 an NVM Express controller. An input value of 0xFFFFFFFF retrieves\r
186 the first NamespaceId for an NVM Express namespace present on an\r
187 NVM Express controller.\r
188\r
189 @retval EFI_SUCCESS The Namespace ID of the next Namespace was returned.\r
190 @retval EFI_NOT_FOUND There are no more namespaces defined on this controller.\r
191 @retval EFI_INVALID_PARAMETER NamespaceId is an invalid value other than 0xFFFFFFFF.\r
192\r
193**/\r
194typedef\r
195EFI_STATUS\r
196(EFIAPI *EFI_NVM_EXPRESS_PASS_THRU_GET_NEXT_NAMESPACE)(\r
197 IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *This,\r
198 IN OUT UINT32 *NamespaceId\r
199 );\r
200\r
201/**\r
202 Used to allocate and build a device path node for an NVM Express namespace on an NVM Express controller.\r
203\r
204 The EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL.BuildDevicePath() function allocates and builds a single device\r
205 path node for the NVM Express namespace specified by NamespaceId.\r
206\r
207 If the NamespaceId is not valid, then EFI_NOT_FOUND is returned.\r
208\r
209 If DevicePath is NULL, then EFI_INVALID_PARAMETER is returned. \r
210\r
211 If there are not enough resources to allocate the device path node, then EFI_OUT_OF_RESOURCES is returned.\r
212\r
213 Otherwise, DevicePath is allocated with the boot service AllocatePool(), the contents of DevicePath are\r
214 initialized to describe the NVM Express namespace specified by NamespaceId, and EFI_SUCCESS is returned.\r
215\r
216 @param[in] This A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance.\r
217 @param[in] NamespaceId The NVM Express namespace ID for which a device path node is to be\r
218 allocated and built. Caller must set the NamespaceId to zero if the\r
219 device path node will contain a valid UUID.\r
220 @param[in,out] DevicePath A pointer to a single device path node that describes the NVM Express\r
221 namespace specified by NamespaceId. This function is responsible for\r
222 allocating the buffer DevicePath with the boot service AllocatePool().\r
223 It is the caller's responsibility to free DevicePath when the caller\r
224 is finished with DevicePath.\r
225 @retval EFI_SUCCESS The device path node that describes the NVM Express namespace specified\r
226 by NamespaceId was allocated and returned in DevicePath.\r
227 @retval EFI_NOT_FOUND The NamespaceId is not valid.\r
228 @retval EFI_INVALID_PARAMETER DevicePath is NULL.\r
229 @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate the DevicePath node.\r
230\r
231**/\r
232typedef\r
233EFI_STATUS\r
234(EFIAPI *EFI_NVM_EXPRESS_PASS_THRU_BUILD_DEVICE_PATH)(\r
235 IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *This,\r
236 IN UINT32 NamespaceId,\r
237 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath\r
238 );\r
239\r
240/**\r
241 Used to translate a device path node to a namespace ID.\r
242\r
243 The EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL.GetNamespace() function determines the namespace ID associated with the\r
244 namespace described by DevicePath.\r
245\r
246 If DevicePath is a device path node type that the NVM Express Pass Thru driver supports, then the NVM Express\r
247 Pass Thru driver will attempt to translate the contents DevicePath into a namespace ID.\r
248\r
249 If this translation is successful, then that namespace ID is returned in NamespaceId, and EFI_SUCCESS is returned\r
250\r
251 @param[in] This A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance.\r
252 @param[in] DevicePath A pointer to the device path node that describes an NVM Express namespace on\r
253 the NVM Express controller.\r
254 @param[out] NamespaceId The NVM Express namespace ID contained in the device path node.\r
255\r
256 @retval EFI_SUCCESS DevicePath was successfully translated to NamespaceId.\r
257 @retval EFI_INVALID_PARAMETER If DevicePath or NamespaceId are NULL, then EFI_INVALID_PARAMETER is returned.\r
258 @retval EFI_UNSUPPORTED If DevicePath is not a device path node type that the NVM Express Pass Thru driver\r
259 supports, then EFI_UNSUPPORTED is returned.\r
260 @retval EFI_NOT_FOUND If DevicePath is a device path node type that the NVM Express Pass Thru driver\r
261 supports, but there is not a valid translation from DevicePath to a namespace ID,\r
262 then EFI_NOT_FOUND is returned.\r
263**/\r
264typedef\r
265EFI_STATUS\r
266(EFIAPI *EFI_NVM_EXPRESS_PASS_THRU_GET_NAMESPACE)(\r
267 IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *This,\r
268 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
269 OUT UINT32 *NamespaceId\r
270 );\r
271\r
272//\r
273// Protocol Interface Structure\r
274//\r
275struct _EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL {\r
276 EFI_NVM_EXPRESS_PASS_THRU_MODE *Mode;\r
277 EFI_NVM_EXPRESS_PASS_THRU_PASSTHRU PassThru;\r
278 EFI_NVM_EXPRESS_PASS_THRU_GET_NEXT_NAMESPACE GetNextNamespace;\r
279 EFI_NVM_EXPRESS_PASS_THRU_BUILD_DEVICE_PATH BuildDevicePath;\r
280 EFI_NVM_EXPRESS_PASS_THRU_GET_NAMESPACE GetNamespace;\r
281};\r
282\r
283extern EFI_GUID gEfiNvmExpressPassThruProtocolGuid;\r
284\r
285#endif\r
286\r