]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/NvmExpressPassthru.h
MdePkg: Apply uncrustify changes
[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
2f88bd3a
MK
25 UINT32 Attributes;\r
26 UINT32 IoAlign;\r
27 UINT32 NvmeVersion;\r
21bd4958
FT
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
2f88bd3a 34#define EFI_NVM_EXPRESS_PASS_THRU_ATTRIBUTES_PHYSICAL 0x0001\r
21bd4958
FT
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
2f88bd3a 39#define EFI_NVM_EXPRESS_PASS_THRU_ATTRIBUTES_LOGICAL 0x0002\r
21bd4958
FT
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
2f88bd3a 44#define EFI_NVM_EXPRESS_PASS_THRU_ATTRIBUTES_NONBLOCKIO 0x0004\r
21bd4958
FT
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
2f88bd3a 49#define EFI_NVM_EXPRESS_PASS_THRU_ATTRIBUTES_CMD_SET_NVM 0x0008\r
21bd4958
FT
50\r
51//\r
52// FusedOperation\r
53//\r
2f88bd3a
MK
54#define NORMAL_CMD 0x00\r
55#define FUSED_FIRST_CMD 0x01\r
56#define FUSED_SECOND_CMD 0x02\r
21bd4958
FT
57\r
58typedef struct {\r
2f88bd3a
MK
59 UINT32 Opcode : 8;\r
60 UINT32 FusedOperation : 2;\r
61 UINT32 Reserved : 22;\r
21bd4958
FT
62} NVME_CDW0;\r
63\r
64//\r
65// Flags\r
66//\r
2f88bd3a
MK
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
21bd4958
FT
75\r
76//\r
77// Queue Type\r
78//\r
2f88bd3a
MK
79#define NVME_ADMIN_QUEUE 0x00\r
80#define NVME_IO_QUEUE 0x01\r
21bd4958
FT
81\r
82typedef struct {\r
2f88bd3a
MK
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
21bd4958
FT
94} EFI_NVM_EXPRESS_COMMAND;\r
95\r
96typedef struct {\r
2f88bd3a
MK
97 UINT32 DW0;\r
98 UINT32 DW1;\r
99 UINT32 DW2;\r
100 UINT32 DW3;\r
21bd4958
FT
101} EFI_NVM_EXPRESS_COMPLETION;\r
102\r
103typedef struct {\r
2f88bd3a
MK
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
21bd4958
FT
112} EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET;\r
113\r
114//\r
00b7cc0f 115// Protocol function prototypes\r
21bd4958 116//\r
2f88bd3a 117\r
21bd4958
FT
118/**\r
119 Sends an NVM Express Command Packet to an NVM Express controller or namespace. This function supports\r
120 both blocking I/O and non-blocking I/O. The blocking I/O functionality is required, and the non-blocking\r
121 I/O functionality is optional.\r
122\r
123\r
124 @param[in] This A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance.\r
125 @param[in] NamespaceId A 32 bit namespace ID as defined in the NVMe specification to which the NVM Express Command\r
126 Packet will be sent. A value of 0 denotes the NVM Express controller, a value of all 0xFF's\r
127 (all bytes are 0xFF) in the namespace ID specifies that the command packet should be sent to\r
128 all valid namespaces.\r
129 @param[in,out] Packet A pointer to the NVM Express Command Packet.\r
130 @param[in] Event If non-blocking I/O is not supported then Event is ignored, and blocking I/O is performed.\r
131 If Event is NULL, then blocking I/O is performed. If Event is not NULL and non-blocking I/O\r
132 is supported, then non-blocking I/O is performed, and Event will be signaled when the NVM\r
9095d37b 133 Express Command Packet completes.\r
21bd4958
FT
134\r
135 @retval EFI_SUCCESS The NVM Express Command Packet was sent by the host. TransferLength bytes were transferred\r
136 to, or from DataBuffer.\r
137 @retval EFI_BAD_BUFFER_SIZE The NVM Express Command Packet was not executed. The number of bytes that could be transferred\r
138 is returned in TransferLength.\r
139 @retval EFI_NOT_READY The NVM Express Command Packet could not be sent because the controller is not ready. The caller\r
140 may retry again later.\r
141 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send the NVM Express Command Packet.\r
142 @retval EFI_INVALID_PARAMETER NamespaceId or the contents of EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET are invalid. The NVM\r
143 Express Command Packet was not sent, so no additional status information is available.\r
144 @retval EFI_UNSUPPORTED The command described by the NVM Express Command Packet is not supported by the NVM Express\r
145 controller. The NVM Express Command Packet was not sent so no additional status information\r
146 is available.\r
147 @retval EFI_TIMEOUT A timeout occurred while waiting for the NVM Express Command Packet to execute.\r
148\r
149**/\r
150typedef\r
151EFI_STATUS\r
152(EFIAPI *EFI_NVM_EXPRESS_PASS_THRU_PASSTHRU)(\r
153 IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *This,\r
154 IN UINT32 NamespaceId,\r
155 IN OUT EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET *Packet,\r
156 IN EFI_EVENT Event OPTIONAL\r
157 );\r
158\r
159/**\r
160 Used to retrieve the next namespace ID for this NVM Express controller.\r
161\r
162 The EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL.GetNextNamespace() function retrieves the next valid\r
9095d37b 163 namespace ID on this NVM Express controller.\r
21bd4958
FT
164\r
165 If on input the value pointed to by NamespaceId is 0xFFFFFFFF, then the first valid namespace\r
166 ID defined on the NVM Express controller is returned in the location pointed to by NamespaceId\r
167 and a status of EFI_SUCCESS is returned.\r
168\r
169 If on input the value pointed to by NamespaceId is an invalid namespace ID other than 0xFFFFFFFF,\r
170 then EFI_INVALID_PARAMETER is returned.\r
171\r
172 If on input the value pointed to by NamespaceId is a valid namespace ID, then the next valid\r
173 namespace ID on the NVM Express controller is returned in the location pointed to by NamespaceId,\r
174 and EFI_SUCCESS is returned.\r
175\r
176 If the value pointed to by NamespaceId is the namespace ID of the last namespace on the NVM\r
177 Express controller, then EFI_NOT_FOUND is returned.\r
178\r
179 @param[in] This A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance.\r
180 @param[in,out] NamespaceId On input, a pointer to a legal NamespaceId for an NVM Express\r
181 namespace present on the NVM Express controller. On output, a\r
182 pointer to the next NamespaceId of an NVM Express namespace on\r
183 an NVM Express controller. An input value of 0xFFFFFFFF retrieves\r
184 the first NamespaceId for an NVM Express namespace present on an\r
185 NVM Express controller.\r
186\r
187 @retval EFI_SUCCESS The Namespace ID of the next Namespace was returned.\r
188 @retval EFI_NOT_FOUND There are no more namespaces defined on this controller.\r
189 @retval EFI_INVALID_PARAMETER NamespaceId is an invalid value other than 0xFFFFFFFF.\r
190\r
191**/\r
192typedef\r
193EFI_STATUS\r
194(EFIAPI *EFI_NVM_EXPRESS_PASS_THRU_GET_NEXT_NAMESPACE)(\r
195 IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *This,\r
196 IN OUT UINT32 *NamespaceId\r
197 );\r
198\r
199/**\r
200 Used to allocate and build a device path node for an NVM Express namespace on an NVM Express controller.\r
201\r
202 The EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL.BuildDevicePath() function allocates and builds a single device\r
203 path node for the NVM Express namespace specified by NamespaceId.\r
204\r
205 If the NamespaceId is not valid, then EFI_NOT_FOUND is returned.\r
206\r
9095d37b 207 If DevicePath is NULL, then EFI_INVALID_PARAMETER is returned.\r
21bd4958
FT
208\r
209 If there are not enough resources to allocate the device path node, then EFI_OUT_OF_RESOURCES is returned.\r
210\r
211 Otherwise, DevicePath is allocated with the boot service AllocatePool(), the contents of DevicePath are\r
212 initialized to describe the NVM Express namespace specified by NamespaceId, and EFI_SUCCESS is returned.\r
213\r
214 @param[in] This A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance.\r
215 @param[in] NamespaceId The NVM Express namespace ID for which a device path node is to be\r
216 allocated and built. Caller must set the NamespaceId to zero if the\r
217 device path node will contain a valid UUID.\r
ff95c0fc 218 @param[out] DevicePath A pointer to a single device path node that describes the NVM Express\r
21bd4958
FT
219 namespace specified by NamespaceId. This function is responsible for\r
220 allocating the buffer DevicePath with the boot service AllocatePool().\r
221 It is the caller's responsibility to free DevicePath when the caller\r
222 is finished with DevicePath.\r
223 @retval EFI_SUCCESS The device path node that describes the NVM Express namespace specified\r
224 by NamespaceId was allocated and returned in DevicePath.\r
225 @retval EFI_NOT_FOUND The NamespaceId is not valid.\r
226 @retval EFI_INVALID_PARAMETER DevicePath is NULL.\r
227 @retval EFI_OUT_OF_RESOURCES There are not enough resources to allocate the DevicePath node.\r
228\r
229**/\r
230typedef\r
231EFI_STATUS\r
232(EFIAPI *EFI_NVM_EXPRESS_PASS_THRU_BUILD_DEVICE_PATH)(\r
233 IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *This,\r
234 IN UINT32 NamespaceId,\r
ff95c0fc 235 OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath\r
21bd4958
FT
236 );\r
237\r
238/**\r
239 Used to translate a device path node to a namespace ID.\r
240\r
241 The EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL.GetNamespace() function determines the namespace ID associated with the\r
242 namespace described by DevicePath.\r
243\r
244 If DevicePath is a device path node type that the NVM Express Pass Thru driver supports, then the NVM Express\r
245 Pass Thru driver will attempt to translate the contents DevicePath into a namespace ID.\r
246\r
247 If this translation is successful, then that namespace ID is returned in NamespaceId, and EFI_SUCCESS is returned\r
248\r
249 @param[in] This A pointer to the EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL instance.\r
250 @param[in] DevicePath A pointer to the device path node that describes an NVM Express namespace on\r
251 the NVM Express controller.\r
252 @param[out] NamespaceId The NVM Express namespace ID contained in the device path node.\r
253\r
254 @retval EFI_SUCCESS DevicePath was successfully translated to NamespaceId.\r
255 @retval EFI_INVALID_PARAMETER If DevicePath or NamespaceId are NULL, then EFI_INVALID_PARAMETER is returned.\r
256 @retval EFI_UNSUPPORTED If DevicePath is not a device path node type that the NVM Express Pass Thru driver\r
257 supports, then EFI_UNSUPPORTED is returned.\r
258 @retval EFI_NOT_FOUND If DevicePath is a device path node type that the NVM Express Pass Thru driver\r
259 supports, but there is not a valid translation from DevicePath to a namespace ID,\r
260 then EFI_NOT_FOUND is returned.\r
261**/\r
262typedef\r
263EFI_STATUS\r
264(EFIAPI *EFI_NVM_EXPRESS_PASS_THRU_GET_NAMESPACE)(\r
265 IN EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL *This,\r
266 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
2f88bd3a 267 OUT UINT32 *NamespaceId\r
21bd4958
FT
268 );\r
269\r
270//\r
271// Protocol Interface Structure\r
272//\r
273struct _EFI_NVM_EXPRESS_PASS_THRU_PROTOCOL {\r
2f88bd3a
MK
274 EFI_NVM_EXPRESS_PASS_THRU_MODE *Mode;\r
275 EFI_NVM_EXPRESS_PASS_THRU_PASSTHRU PassThru;\r
276 EFI_NVM_EXPRESS_PASS_THRU_GET_NEXT_NAMESPACE GetNextNamespace;\r
277 EFI_NVM_EXPRESS_PASS_THRU_BUILD_DEVICE_PATH BuildDevicePath;\r
278 EFI_NVM_EXPRESS_PASS_THRU_GET_NAMESPACE GetNamespace;\r
21bd4958
FT
279};\r
280\r
2f88bd3a 281extern EFI_GUID gEfiNvmExpressPassThruProtocolGuid;\r
21bd4958
FT
282\r
283#endif\r