]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c
OvmfPkg/VirtioNetDxe: alloc RxBuf using AllocateSharedPages()
[mirror_edk2.git] / OvmfPkg / VirtioNetDxe / SnpSharedHelpers.c
CommitLineData
12384f9b
LE
1/** @file\r
2\r
3 Helper functions used by at least two Simple Network Protocol methods.\r
4\r
5 Copyright (C) 2013, Red Hat, Inc.\r
6\r
7 This program and the accompanying materials are licensed and made available\r
8 under the terms and conditions of the BSD License which accompanies this\r
9 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, WITHOUT\r
13 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15**/\r
16\r
17#include <Library/MemoryAllocationLib.h>\r
18\r
19#include "VirtioNet.h"\r
20\r
21/**\r
22 Release RX and TX resources on the boundary of the\r
23 EfiSimpleNetworkInitialized state.\r
24\r
25 These functions contribute to rolling back a partial, failed initialization\r
26 of the virtio-net SNP driver instance, or to shutting down a fully\r
27 initialized, running instance.\r
28\r
29 They are only callable by the VirtioNetInitialize() and the\r
30 VirtioNetShutdown() SNP methods. See the state diagram in "VirtioNet.h".\r
31\r
32 @param[in,out] Dev The VNET_DEV driver instance being shut down, or whose\r
33 partial, failed initialization is being rolled back.\r
34*/\r
35\r
36VOID\r
37EFIAPI\r
38VirtioNetShutdownRx (\r
39 IN OUT VNET_DEV *Dev\r
40 )\r
41{\r
46b11f00
BS
42 Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->RxBufMap);\r
43 Dev->VirtIo->FreeSharedPages (\r
44 Dev->VirtIo,\r
45 Dev->RxBufNrPages,\r
46 Dev->RxBuf\r
47 );\r
12384f9b
LE
48}\r
49\r
50\r
51VOID\r
52EFIAPI\r
53VirtioNetShutdownTx (\r
54 IN OUT VNET_DEV *Dev\r
55 )\r
56{\r
57 FreePool (Dev->TxFreeStack);\r
58}\r
55dd5a67
BS
59\r
60/**\r
61 Release TX and RX VRING resources.\r
62\r
940baec0
BS
63 @param[in,out] Dev The VNET_DEV driver instance which was using\r
64 the ring.\r
65 @param[in,out] Ring The virtio ring to clean up.\r
66 @param[in] RingMap A token return from the VirtioRingMap()\r
55dd5a67
BS
67*/\r
68VOID\r
69EFIAPI\r
70VirtioNetUninitRing (\r
71 IN OUT VNET_DEV *Dev,\r
940baec0
BS
72 IN OUT VRING *Ring,\r
73 IN VOID *RingMap\r
55dd5a67
BS
74 )\r
75{\r
940baec0 76 Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, RingMap);\r
55dd5a67
BS
77 VirtioRingUninit (Dev->VirtIo, Ring);\r
78}\r