]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/VirtioNetDxe/SnpInitialize.c
OvmfPkg/VirtioNetDxe: dynamically alloc transmit header
[mirror_edk2.git] / OvmfPkg / VirtioNetDxe / SnpInitialize.c
1 /** @file
2
3 Implementation of the SNP.Initialize() function and its private helpers if
4 any.
5
6 Copyright (C) 2013, Red Hat, Inc.
7 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
8 Copyright (c) 2017, AMD Inc, All rights reserved.<BR>
9
10 This program and the accompanying materials are licensed and made available
11 under the terms and conditions of the BSD License which accompanies this
12 distribution. The full text of the license may be found at
13 http://opensource.org/licenses/bsd-license.php
14
15 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
16 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17
18 **/
19
20 #include <Library/BaseLib.h>
21 #include <Library/BaseMemoryLib.h>
22 #include <Library/MemoryAllocationLib.h>
23 #include <Library/UefiBootServicesTableLib.h>
24
25 #include "VirtioNet.h"
26
27 /**
28 Initialize a virtio ring for a specific transfer direction of the virtio-net
29 device.
30
31 This function may only be called by VirtioNetInitialize().
32
33 @param[in,out] Dev The VNET_DEV driver instance about to enter the
34 EfiSimpleNetworkInitialized state.
35 @param[in] Selector Identifies the transfer direction (virtio queue) of
36 the network device.
37 @param[out] Ring The virtio-ring inside the VNET_DEV structure,
38 corresponding to Selector.
39 @param[out] Mapping A resulting token to pass to VirtioNetUninitRing()
40
41 @retval EFI_UNSUPPORTED The queue size reported by the virtio-net device is
42 too small.
43 @return Status codes from VIRTIO_CFG_WRITE(),
44 VIRTIO_CFG_READ(), VirtioRingInit() and
45 VirtioRingMap().
46 @retval EFI_SUCCESS Ring initialized.
47 */
48
49 STATIC
50 EFI_STATUS
51 EFIAPI
52 VirtioNetInitRing (
53 IN OUT VNET_DEV *Dev,
54 IN UINT16 Selector,
55 OUT VRING *Ring,
56 OUT VOID **Mapping
57 )
58 {
59 EFI_STATUS Status;
60 UINT16 QueueSize;
61 UINT64 RingBaseShift;
62 VOID *MapInfo;
63
64 //
65 // step 4b -- allocate selected queue
66 //
67 Status = Dev->VirtIo->SetQueueSel (Dev->VirtIo, Selector);
68 if (EFI_ERROR (Status)) {
69 return Status;
70 }
71 Status = Dev->VirtIo->GetQueueNumMax (Dev->VirtIo, &QueueSize);
72 if (EFI_ERROR (Status)) {
73 return Status;
74 }
75
76 //
77 // For each packet (RX and TX alike), we need two descriptors:
78 // one for the virtio-net request header, and another one for the data
79 //
80 if (QueueSize < 2) {
81 return EFI_UNSUPPORTED;
82 }
83 Status = VirtioRingInit (Dev->VirtIo, QueueSize, Ring);
84 if (EFI_ERROR (Status)) {
85 return Status;
86 }
87
88 //
89 // If anything fails from here on, we must release the ring resources.
90 //
91 Status = VirtioRingMap (Dev->VirtIo, Ring, &RingBaseShift, &MapInfo);
92 if (EFI_ERROR (Status)) {
93 goto ReleaseQueue;
94 }
95
96 //
97 // Additional steps for MMIO: align the queue appropriately, and set the
98 // size. If anything fails from here on, we must unmap the ring resources.
99 //
100 Status = Dev->VirtIo->SetQueueNum (Dev->VirtIo, QueueSize);
101 if (EFI_ERROR (Status)) {
102 goto UnmapQueue;
103 }
104
105 Status = Dev->VirtIo->SetQueueAlign (Dev->VirtIo, EFI_PAGE_SIZE);
106 if (EFI_ERROR (Status)) {
107 goto UnmapQueue;
108 }
109
110 //
111 // step 4c -- report GPFN (guest-physical frame number) of queue
112 //
113 Status = Dev->VirtIo->SetQueueAddress (Dev->VirtIo, Ring, RingBaseShift);
114 if (EFI_ERROR (Status)) {
115 goto UnmapQueue;
116 }
117
118 *Mapping = MapInfo;
119
120 return EFI_SUCCESS;
121
122 UnmapQueue:
123 Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, MapInfo);
124
125 ReleaseQueue:
126 VirtioRingUninit (Dev->VirtIo, Ring);
127
128 return Status;
129 }
130
131
132 /**
133 Set up static scaffolding for the VirtioNetTransmit() and
134 VirtioNetGetStatus() SNP methods.
135
136 This function may only be called by VirtioNetInitialize().
137
138 The structures laid out and resources configured include:
139 - fully populate the TX queue with a static pattern of virtio descriptor
140 chains,
141 - tracking of heads of free descriptor chains from the above,
142 - one common virtio-net request header (never modified by the host) for all
143 pending TX packets,
144 - select polling over TX interrupt.
145
146 @param[in,out] Dev The VNET_DEV driver instance about to enter the
147 EfiSimpleNetworkInitialized state.
148
149 @retval EFI_OUT_OF_RESOURCES Failed to allocate the stack to track the heads
150 of free descriptor chains.
151 @return Status codes from VIRTIO_DEVICE_PROTOCOL.
152 AllocateSharedPages() or
153 VirtioMapAllBytesInSharedBuffer()
154 @retval EFI_SUCCESS TX setup successful.
155 */
156
157 STATIC
158 EFI_STATUS
159 EFIAPI
160 VirtioNetInitTx (
161 IN OUT VNET_DEV *Dev
162 )
163 {
164 UINTN TxSharedReqSize;
165 UINTN PktIdx;
166 EFI_STATUS Status;
167 EFI_PHYSICAL_ADDRESS DeviceAddress;
168 VOID *TxSharedReqBuffer;
169
170 Dev->TxMaxPending = (UINT16) MIN (Dev->TxRing.QueueSize / 2,
171 VNET_MAX_PENDING);
172 Dev->TxCurPending = 0;
173 Dev->TxFreeStack = AllocatePool (Dev->TxMaxPending *
174 sizeof *Dev->TxFreeStack);
175 if (Dev->TxFreeStack == NULL) {
176 return EFI_OUT_OF_RESOURCES;
177 }
178
179 //
180 // Allocate TxSharedReq header and map with BusMasterCommonBuffer so that it
181 // can be accessed equally by both processor and device.
182 //
183 Status = Dev->VirtIo->AllocateSharedPages (
184 Dev->VirtIo,
185 EFI_SIZE_TO_PAGES (sizeof *Dev->TxSharedReq),
186 &TxSharedReqBuffer
187 );
188 if (EFI_ERROR (Status)) {
189 goto FreeTxFreeStack;
190 }
191
192 ZeroMem (TxSharedReqBuffer, sizeof *Dev->TxSharedReq);
193
194 Status = VirtioMapAllBytesInSharedBuffer (
195 Dev->VirtIo,
196 VirtioOperationBusMasterCommonBuffer,
197 TxSharedReqBuffer,
198 sizeof *(Dev->TxSharedReq),
199 &DeviceAddress,
200 &Dev->TxSharedReqMap
201 );
202 if (EFI_ERROR (Status)) {
203 goto FreeTxSharedReqBuffer;
204 }
205
206 Dev->TxSharedReq = TxSharedReqBuffer;
207
208
209 //
210 // In VirtIo 1.0, the NumBuffers field is mandatory. In 0.9.5, it depends on
211 // VIRTIO_NET_F_MRG_RXBUF, which we never negotiate.
212 //
213 TxSharedReqSize = (Dev->VirtIo->Revision < VIRTIO_SPEC_REVISION (1, 0, 0)) ?
214 sizeof (Dev->TxSharedReq->V0_9_5) :
215 sizeof *Dev->TxSharedReq;
216
217 for (PktIdx = 0; PktIdx < Dev->TxMaxPending; ++PktIdx) {
218 UINT16 DescIdx;
219
220 DescIdx = (UINT16) (2 * PktIdx);
221 Dev->TxFreeStack[PktIdx] = DescIdx;
222
223 //
224 // For each possibly pending packet, lay out the descriptor for the common
225 // (unmodified by the host) virtio-net request header.
226 //
227 Dev->TxRing.Desc[DescIdx].Addr = DeviceAddress;
228 Dev->TxRing.Desc[DescIdx].Len = (UINT32) TxSharedReqSize;
229 Dev->TxRing.Desc[DescIdx].Flags = VRING_DESC_F_NEXT;
230 Dev->TxRing.Desc[DescIdx].Next = (UINT16) (DescIdx + 1);
231
232 //
233 // The second descriptor of each pending TX packet is updated on the fly,
234 // but it always terminates the descriptor chain of the packet.
235 //
236 Dev->TxRing.Desc[DescIdx + 1].Flags = 0;
237 }
238
239 //
240 // virtio-0.9.5, Appendix C, Packet Transmission
241 //
242 Dev->TxSharedReq->V0_9_5.Flags = 0;
243 Dev->TxSharedReq->V0_9_5.GsoType = VIRTIO_NET_HDR_GSO_NONE;
244
245 //
246 // For VirtIo 1.0 only -- the field exists, but it is unused
247 //
248 Dev->TxSharedReq->NumBuffers = 0;
249
250 //
251 // virtio-0.9.5, 2.4.2 Receiving Used Buffers From the Device
252 //
253 MemoryFence ();
254 Dev->TxLastUsed = *Dev->TxRing.Used.Idx;
255 ASSERT (Dev->TxLastUsed == 0);
256
257 //
258 // want no interrupt when a transmit completes
259 //
260 *Dev->TxRing.Avail.Flags = (UINT16) VRING_AVAIL_F_NO_INTERRUPT;
261
262 return EFI_SUCCESS;
263
264 FreeTxSharedReqBuffer:
265 Dev->VirtIo->FreeSharedPages (
266 Dev->VirtIo,
267 EFI_SIZE_TO_PAGES (sizeof *(Dev->TxSharedReq)),
268 TxSharedReqBuffer
269 );
270 FreeTxFreeStack:
271 FreePool (Dev->TxFreeStack);
272
273 return Status;
274 }
275
276
277 /**
278 Set up static scaffolding for the VirtioNetReceive() SNP method and enable
279 live device operation.
280
281 This function may only be called as VirtioNetInitialize()'s final step.
282
283 The structures laid out and resources configured include:
284 - destination area for the host to write virtio-net request headers and
285 packet data into,
286 - select polling over RX interrupt,
287 - fully populate the RX queue with a static pattern of virtio descriptor
288 chains.
289
290 @param[in,out] Dev The VNET_DEV driver instance about to enter the
291 EfiSimpleNetworkInitialized state.
292
293 @return Status codes from VIRTIO_CFG_WRITE() or
294 VIRTIO_DEVICE_PROTOCOL.AllocateSharedPages or
295 VirtioMapAllBytesInSharedBuffer().
296 @retval EFI_SUCCESS RX setup successful. The device is live and may
297 already be writing to the receive area.
298 */
299
300 STATIC
301 EFI_STATUS
302 EFIAPI
303 VirtioNetInitRx (
304 IN OUT VNET_DEV *Dev
305 )
306 {
307 EFI_STATUS Status;
308 UINTN VirtioNetReqSize;
309 UINTN RxBufSize;
310 UINT16 RxAlwaysPending;
311 UINTN PktIdx;
312 UINT16 DescIdx;
313 UINTN NumBytes;
314 EFI_PHYSICAL_ADDRESS RxBufDeviceAddress;
315 VOID *RxBuffer;
316
317 //
318 // In VirtIo 1.0, the NumBuffers field is mandatory. In 0.9.5, it depends on
319 // VIRTIO_NET_F_MRG_RXBUF, which we never negotiate.
320 //
321 VirtioNetReqSize = (Dev->VirtIo->Revision < VIRTIO_SPEC_REVISION (1, 0, 0)) ?
322 sizeof (VIRTIO_NET_REQ) :
323 sizeof (VIRTIO_1_0_NET_REQ);
324
325 //
326 // For each incoming packet we must supply two descriptors:
327 // - the recipient for the virtio-net request header, plus
328 // - the recipient for the network data (which consists of Ethernet header
329 // and Ethernet payload).
330 //
331 RxBufSize = VirtioNetReqSize +
332 (Dev->Snm.MediaHeaderSize + Dev->Snm.MaxPacketSize);
333
334 //
335 // Limit the number of pending RX packets if the queue is big. The division
336 // by two is due to the above "two descriptors per packet" trait.
337 //
338 RxAlwaysPending = (UINT16) MIN (Dev->RxRing.QueueSize / 2, VNET_MAX_PENDING);
339
340 //
341 // The RxBuf is shared between guest and hypervisor, use
342 // AllocateSharedPages() to allocate this memory region and map it with
343 // BusMasterCommonBuffer so that it can be accessed by both guest and
344 // hypervisor.
345 //
346 NumBytes = RxAlwaysPending * RxBufSize;
347 Dev->RxBufNrPages = EFI_SIZE_TO_PAGES (NumBytes);
348 Status = Dev->VirtIo->AllocateSharedPages (
349 Dev->VirtIo,
350 Dev->RxBufNrPages,
351 &RxBuffer
352 );
353 if (EFI_ERROR (Status)) {
354 return Status;
355 }
356
357 ZeroMem (RxBuffer, NumBytes);
358
359 Status = VirtioMapAllBytesInSharedBuffer (
360 Dev->VirtIo,
361 VirtioOperationBusMasterCommonBuffer,
362 RxBuffer,
363 NumBytes,
364 &Dev->RxBufDeviceBase,
365 &Dev->RxBufMap
366 );
367 if (EFI_ERROR (Status)) {
368 goto FreeSharedBuffer;
369 }
370
371 Dev->RxBuf = RxBuffer;
372
373 //
374 // virtio-0.9.5, 2.4.2 Receiving Used Buffers From the Device
375 //
376 MemoryFence ();
377 Dev->RxLastUsed = *Dev->RxRing.Used.Idx;
378 ASSERT (Dev->RxLastUsed == 0);
379
380 //
381 // virtio-0.9.5, 2.4.2 Receiving Used Buffers From the Device:
382 // the host should not send interrupts, we'll poll in VirtioNetReceive()
383 // and VirtioNetIsPacketAvailable().
384 //
385 *Dev->RxRing.Avail.Flags = (UINT16) VRING_AVAIL_F_NO_INTERRUPT;
386
387 //
388 // now set up a separate, two-part descriptor chain for each RX packet, and
389 // link each chain into (from) the available ring as well
390 //
391 DescIdx = 0;
392 RxBufDeviceAddress = Dev->RxBufDeviceBase;
393 for (PktIdx = 0; PktIdx < RxAlwaysPending; ++PktIdx) {
394 //
395 // virtio-0.9.5, 2.4.1.2 Updating the Available Ring
396 // invisible to the host until we update the Index Field
397 //
398 Dev->RxRing.Avail.Ring[PktIdx] = DescIdx;
399
400 //
401 // virtio-0.9.5, 2.4.1.1 Placing Buffers into the Descriptor Table
402 //
403 Dev->RxRing.Desc[DescIdx].Addr = RxBufDeviceAddress;
404 Dev->RxRing.Desc[DescIdx].Len = (UINT32) VirtioNetReqSize;
405 Dev->RxRing.Desc[DescIdx].Flags = VRING_DESC_F_WRITE | VRING_DESC_F_NEXT;
406 Dev->RxRing.Desc[DescIdx].Next = (UINT16) (DescIdx + 1);
407 RxBufDeviceAddress += Dev->RxRing.Desc[DescIdx++].Len;
408
409 Dev->RxRing.Desc[DescIdx].Addr = RxBufDeviceAddress;
410 Dev->RxRing.Desc[DescIdx].Len = (UINT32) (RxBufSize - VirtioNetReqSize);
411 Dev->RxRing.Desc[DescIdx].Flags = VRING_DESC_F_WRITE;
412 RxBufDeviceAddress += Dev->RxRing.Desc[DescIdx++].Len;
413 }
414
415 //
416 // virtio-0.9.5, 2.4.1.3 Updating the Index Field
417 //
418 MemoryFence ();
419 *Dev->RxRing.Avail.Idx = RxAlwaysPending;
420
421 //
422 // At this point reception may already be running. In order to make it sure,
423 // kick the hypervisor. If we fail to kick it, we must first abort reception
424 // before tearing down anything, because reception may have been already
425 // running even without the kick.
426 //
427 // virtio-0.9.5, 2.4.1.4 Notifying the Device
428 //
429 MemoryFence ();
430 Status = Dev->VirtIo->SetQueueNotify (Dev->VirtIo, VIRTIO_NET_Q_RX);
431 if (EFI_ERROR (Status)) {
432 Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);
433 goto UnmapSharedBuffer;
434 }
435
436 return Status;
437
438 UnmapSharedBuffer:
439 Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RxBufMap);
440
441 FreeSharedBuffer:
442 Dev->VirtIo->FreeSharedPages (
443 Dev->VirtIo,
444 Dev->RxBufNrPages,
445 RxBuffer
446 );
447 return Status;
448 }
449
450
451 /**
452 Resets a network adapter and allocates the transmit and receive buffers
453 required by the network interface; optionally, also requests allocation of
454 additional transmit and receive buffers.
455
456 @param This The protocol instance pointer.
457 @param ExtraRxBufferSize The size, in bytes, of the extra receive buffer
458 space that the driver should allocate for the
459 network interface. Some network interfaces will not
460 be able to use the extra buffer, and the caller
461 will not know if it is actually being used.
462 @param ExtraTxBufferSize The size, in bytes, of the extra transmit buffer
463 space that the driver should allocate for the
464 network interface. Some network interfaces will not
465 be able to use the extra buffer, and the caller
466 will not know if it is actually being used.
467
468 @retval EFI_SUCCESS The network interface was initialized.
469 @retval EFI_NOT_STARTED The network interface has not been started.
470 @retval EFI_OUT_OF_RESOURCES There was not enough memory for the transmit
471 and receive buffers.
472 @retval EFI_INVALID_PARAMETER One or more of the parameters has an
473 unsupported value.
474 @retval EFI_DEVICE_ERROR The command could not be sent to the network
475 interface.
476 @retval EFI_UNSUPPORTED This function is not supported by the network
477 interface.
478
479 **/
480
481 EFI_STATUS
482 EFIAPI
483 VirtioNetInitialize (
484 IN EFI_SIMPLE_NETWORK_PROTOCOL *This,
485 IN UINTN ExtraRxBufferSize OPTIONAL,
486 IN UINTN ExtraTxBufferSize OPTIONAL
487 )
488 {
489 VNET_DEV *Dev;
490 EFI_TPL OldTpl;
491 EFI_STATUS Status;
492 UINT8 NextDevStat;
493 UINT64 Features;
494
495 if (This == NULL) {
496 return EFI_INVALID_PARAMETER;
497 }
498 if (ExtraRxBufferSize > 0 || ExtraTxBufferSize > 0) {
499 return EFI_UNSUPPORTED;
500 }
501
502 Dev = VIRTIO_NET_FROM_SNP (This);
503 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
504 if (Dev->Snm.State != EfiSimpleNetworkStarted) {
505 Status = EFI_NOT_STARTED;
506 goto InitFailed;
507 }
508
509 //
510 // In the EfiSimpleNetworkStarted state the virtio-net device has status
511 // value 0 (= reset) -- see the state diagram, the full call chain to
512 // the end of VirtioNetGetFeatures() (considering we're here now),
513 // the DeviceFailed label below, and VirtioNetShutdown().
514 //
515 // Accordingly, the below is a subsequence of the steps found in the
516 // virtio-0.9.5 spec, 2.2.1 Device Initialization Sequence.
517 //
518 NextDevStat = VSTAT_ACK; // step 2 -- acknowledge device presence
519 Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
520 if (EFI_ERROR (Status)) {
521 goto InitFailed;
522 }
523
524 NextDevStat |= VSTAT_DRIVER; // step 3 -- we know how to drive it
525 Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
526 if (EFI_ERROR (Status)) {
527 goto DeviceFailed;
528 }
529
530 //
531 // Set Page Size - MMIO VirtIo Specific
532 //
533 Status = Dev->VirtIo->SetPageSize (Dev->VirtIo, EFI_PAGE_SIZE);
534 if (EFI_ERROR (Status)) {
535 goto DeviceFailed;
536 }
537
538 //
539 // step 4a -- retrieve features. Note that we're past validating required
540 // features in VirtioNetGetFeatures().
541 //
542 Status = Dev->VirtIo->GetDeviceFeatures (Dev->VirtIo, &Features);
543 if (EFI_ERROR (Status)) {
544 goto DeviceFailed;
545 }
546
547 ASSERT (Features & VIRTIO_NET_F_MAC);
548 ASSERT (Dev->Snm.MediaPresentSupported ==
549 !!(Features & VIRTIO_NET_F_STATUS));
550
551 Features &= VIRTIO_NET_F_MAC | VIRTIO_NET_F_STATUS | VIRTIO_F_VERSION_1;
552
553 //
554 // In virtio-1.0, feature negotiation is expected to complete before queue
555 // discovery, and the device can also reject the selected set of features.
556 //
557 if (Dev->VirtIo->Revision >= VIRTIO_SPEC_REVISION (1, 0, 0)) {
558 Status = Virtio10WriteFeatures (Dev->VirtIo, Features, &NextDevStat);
559 if (EFI_ERROR (Status)) {
560 goto DeviceFailed;
561 }
562 }
563
564 //
565 // step 4b, 4c -- allocate and report virtqueues
566 //
567 Status = VirtioNetInitRing (
568 Dev,
569 VIRTIO_NET_Q_RX,
570 &Dev->RxRing,
571 &Dev->RxRingMap
572 );
573 if (EFI_ERROR (Status)) {
574 goto DeviceFailed;
575 }
576
577 Status = VirtioNetInitRing (
578 Dev,
579 VIRTIO_NET_Q_TX,
580 &Dev->TxRing,
581 &Dev->TxRingMap
582 );
583 if (EFI_ERROR (Status)) {
584 goto ReleaseRxRing;
585 }
586
587 //
588 // step 5 -- keep only the features we want
589 //
590 if (Dev->VirtIo->Revision < VIRTIO_SPEC_REVISION (1, 0, 0)) {
591 Features &= ~(UINT64)VIRTIO_F_VERSION_1;
592 Status = Dev->VirtIo->SetGuestFeatures (Dev->VirtIo, Features);
593 if (EFI_ERROR (Status)) {
594 goto ReleaseTxRing;
595 }
596 }
597
598 //
599 // step 6 -- virtio-net initialization complete
600 //
601 NextDevStat |= VSTAT_DRIVER_OK;
602 Status = Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, NextDevStat);
603 if (EFI_ERROR (Status)) {
604 goto ReleaseTxRing;
605 }
606
607 Status = VirtioNetInitTx (Dev);
608 if (EFI_ERROR (Status)) {
609 goto AbortDevice;
610 }
611
612 //
613 // start receiving
614 //
615 Status = VirtioNetInitRx (Dev);
616 if (EFI_ERROR (Status)) {
617 goto ReleaseTxAux;
618 }
619
620 Dev->Snm.State = EfiSimpleNetworkInitialized;
621 gBS->RestoreTPL (OldTpl);
622 return EFI_SUCCESS;
623
624 ReleaseTxAux:
625 VirtioNetShutdownTx (Dev);
626
627 AbortDevice:
628 Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);
629
630 ReleaseTxRing:
631 VirtioNetUninitRing (Dev, &Dev->TxRing, Dev->TxRingMap);
632
633 ReleaseRxRing:
634 VirtioNetUninitRing (Dev, &Dev->RxRing, Dev->RxRingMap);
635
636 DeviceFailed:
637 //
638 // restore device status invariant for the EfiSimpleNetworkStarted state
639 //
640 Dev->VirtIo->SetDeviceStatus (Dev->VirtIo, 0);
641
642 InitFailed:
643 gBS->RestoreTPL (OldTpl);
644 return Status;
645 }