]>
Commit | Line | Data |
---|---|---|
c803536e SS |
1 | /* |
2 | * Copyright (c) 2014 VMware, Inc. | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at: | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | ||
fa1324c9 SG |
17 | #ifndef __UTIL_H_ |
18 | #define __UTIL_H_ 1 | |
c803536e SS |
19 | |
20 | #define OVS_MEMORY_TAG 'TSVO' | |
21 | #define OVS_FIX_SIZE_NBL_POOL_TAG 'FSVO' | |
22 | #define OVS_VARIABLE_SIZE_NBL_POOL_TAG 'VSVO' | |
23 | #define OVS_NBL_ONLY_POOL_TAG 'OSVO' | |
24 | #define OVS_NET_BUFFER_POOL_TAG 'NSVO' | |
25 | #define OVS_OTHER_POOL_TAG 'MSVO' | |
48b3e646 | 26 | #define OVS_MDL_POOL_TAG 'BSVO' |
5bf61915 | 27 | #define OVS_DATAPATH_POOL_TAG 'DSVO' |
84726095 | 28 | #define OVS_EVENT_POOL_TAG 'ESVO' |
99075373 | 29 | #define OVS_FLOW_POOL_TAG 'LSVO' |
cc26fc92 | 30 | #define OVS_VXLAN_POOL_TAG 'XSVO' |
f68ddba9 | 31 | #define OVS_IPHELPER_POOL_TAG 'HSVO' |
5b55d0ab | 32 | #define OVS_OID_POOL_TAG 'ASVO' |
ba7f9d90 | 33 | #define OVS_SWITCH_POOL_TAG 'SSVO' |
d016f841 | 34 | #define OVS_USER_POOL_TAG 'USVO' |
2be9ec26 | 35 | #define OVS_VPORT_POOL_TAG 'PSVO' |
8defc4d3 | 36 | #define OVS_STT_POOL_TAG 'RSVO' |
c803536e SS |
37 | |
38 | VOID *OvsAllocateMemory(size_t size); | |
aa63bc9d | 39 | VOID *OvsAllocateMemoryWithTag(size_t size, ULONG tag); |
c803536e SS |
40 | VOID *OvsAllocateAlignedMemory(size_t size, UINT16 align); |
41 | VOID OvsFreeMemory(VOID *ptr); | |
aa63bc9d | 42 | VOID OvsFreeMemoryWithTag(VOID *ptr, ULONG tag); |
c803536e SS |
43 | VOID OvsFreeAlignedMemory(VOID *ptr); |
44 | ||
45 | #define LIST_FORALL(_headPtr, _itemPtr) \ | |
46 | for (_itemPtr = (_headPtr)->Flink; \ | |
47 | _itemPtr != _headPtr; \ | |
48 | _itemPtr = (_itemPtr)->Flink) | |
49 | ||
50 | #define LIST_FORALL_SAFE(_headPtr, _itemPtr, _nextPtr) \ | |
51 | for (_itemPtr = (_headPtr)->Flink, _nextPtr = (_itemPtr)->Flink; \ | |
52 | _itemPtr != _headPtr; \ | |
53 | _itemPtr = _nextPtr, _nextPtr = (_itemPtr)->Flink) | |
54 | ||
55 | #define LIST_FORALL_REVERSE(_headPtr, _itemPtr) \ | |
56 | for (_itemPtr = (_headPtr)->Blink; \ | |
57 | _itemPtr != _headPtr; \ | |
58 | _itemPtr = (_itemPtr)->Blink) | |
59 | ||
60 | #define LIST_FORALL_REVERSE_SAFE(_headPtr, _itemPtr, _nextPtr) \ | |
61 | for (_itemPtr = (_headPtr)->Blink, _nextPtr = (_itemPtr)->Blink; \ | |
62 | _itemPtr != _headPtr; \ | |
63 | _itemPtr = _nextPtr, _nextPtr = (_itemPtr)->Blink) | |
64 | ||
65 | VOID OvsAppendList(PLIST_ENTRY dst, PLIST_ENTRY src); | |
66 | ||
67 | ||
68 | #define MIN(_a, _b) (_a) > (_b) ? (_b) : (_a) | |
69 | #define ARRAY_SIZE(_x) ((sizeof(_x))/sizeof (_x)[0]) | |
70 | #define OVS_SWITCH_PORT_ID_INVALID (NDIS_SWITCH_PORT_ID)(-1) | |
71 | ||
72 | #ifndef htons | |
73 | #define htons(_x) _byteswap_ushort((USHORT)(_x)) | |
74 | #define ntohs(_x) _byteswap_ushort((USHORT)(_x)) | |
75 | #define htonl(_x) _byteswap_ulong((ULONG)(_x)) | |
76 | #define ntohl(_x) _byteswap_ulong((ULONG)(_x)) | |
77 | #endif | |
78 | ||
79 | #define OVS_INIT_OBJECT_HEADER(_obj, _type, _revision, _size) \ | |
80 | { \ | |
81 | PNDIS_OBJECT_HEADER hdrp = _obj; \ | |
82 | hdrp->Type = _type; \ | |
83 | hdrp->Revision = _revision; \ | |
84 | hdrp->Size = _size; \ | |
85 | } | |
86 | ||
87 | ||
88 | #define BIT16(_x) ((UINT16)0x1 << (_x)) | |
89 | #define BIT32(_x) ((UINT32)0x1 << (_x)) | |
90 | ||
824c061a NR |
91 | BOOLEAN OvsCompareString(PVOID string1, PVOID string2); |
92 | ||
fa1324c9 | 93 | #endif /* __UTIL_H_ */ |