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