]>
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 | ||
9c3d71b0 NR |
17 | #ifndef __DP_INTERNAL_H_ |
18 | #define __DP_INTERNAL_H_ 1 | |
c803536e | 19 | |
a2ab813b NR |
20 | #include <netioapi.h> |
21 | #define IFNAMSIZ IF_NAMESIZE | |
b52641dd | 22 | #include "../ovsext/Netlink/Netlink.h" |
5874d571 | 23 | #include "Mpls.h" |
c803536e | 24 | |
c803536e | 25 | #define OVS_DP_NUMBER ((uint32_t) 0) |
c803536e SS |
26 | |
27 | typedef __declspec(align(8)) uint64_t Ovs64AlignedU64; | |
28 | typedef __declspec(align(8)) ovs_be64 Ovs64AlignedBe64; | |
29 | #pragma pack(push, 1) | |
30 | ||
a2ab813b | 31 | #define OVS_MAX_PORT_NAME_LENGTH IFNAMSIZ |
c803536e SS |
32 | |
33 | typedef struct _OVS_VPORT_GET { | |
34 | uint32_t dpNo; | |
35 | uint32_t portNo; | |
36 | char name[OVS_MAX_PORT_NAME_LENGTH]; | |
37 | } OVS_VPORT_GET, *POVS_VPORT_GET; | |
38 | ||
c803536e SS |
39 | #define OVS_MAX_VM_UUID_LEN 128 |
40 | #define OVS_MAX_VIF_UUID_LEN 128 | |
41 | ||
42 | typedef struct _OVS_VPORT_EXT_INFO { | |
43 | uint32_t dpNo; | |
44 | uint32_t portNo; | |
b3123b20 NR |
45 | uint8_t macAddress[ETH_ADDR_LEN]; |
46 | uint8_t permMACAddress[ETH_ADDR_LEN]; | |
47 | uint8_t vmMACAddress[ETH_ADDR_LEN]; | |
c803536e SS |
48 | uint16_t nicIndex; |
49 | uint32_t portId; | |
50 | uint32_t type; | |
51 | uint32_t mtu; | |
52 | char name[OVS_MAX_PORT_NAME_LENGTH]; | |
53 | uint32_t status; | |
54 | char vmUUID[OVS_MAX_VM_UUID_LEN]; | |
55 | char vifUUID[OVS_MAX_VIF_UUID_LEN]; | |
56 | } OVS_VPORT_EXT_INFO, *POVS_VPORT_EXT_INFO; | |
57 | ||
58 | ||
59 | /* Flows. */ | |
60 | #define OVSWIN_VLAN_CFI 0x1000 | |
c803536e SS |
61 | |
62 | /* Used for OvsFlowKey's dlType member for frames that have no Ethernet type, | |
63 | * that is, pure 802.2 frames. */ | |
64 | #define OVSWIN_DL_TYPE_NONE 0x5ff | |
65 | ||
c803536e SS |
66 | typedef struct L4Key { |
67 | ovs_be16 tpSrc; /* TCP/UDP/SCTP source port. */ | |
68 | ovs_be16 tpDst; /* TCP/UDP/SCTP destination port. */ | |
69 | } L4Key; | |
70 | ||
71 | typedef struct Ipkey { | |
72 | ovs_be32 nwSrc; /* IPv4 source address. */ | |
73 | ovs_be32 nwDst; /* IPv4 destination address. */ | |
74 | uint8_t nwProto; /* IP protocol or low 8 bits of ARP opcode. */ | |
75 | uint8_t nwTos; /* IP ToS (including DSCP and ECN). */ | |
76 | uint8_t nwTtl; /* IP TTL/Hop Limit. */ | |
77 | uint8_t nwFrag; /* FLOW_FRAG_* flags. */ | |
78 | L4Key l4; | |
481c5a6d | 79 | } IpKey; /* Size of 16 byte. */ |
c803536e SS |
80 | |
81 | typedef struct ArpKey { | |
82 | ovs_be32 nwSrc; /* IPv4 source address. */ | |
83 | ovs_be32 nwDst; /* IPv4 destination address. */ | |
84 | uint8_t arpSha[6]; /* ARP/ND source hardware address. */ | |
85 | uint8_t arpTha[6]; /* ARP/ND target hardware address. */ | |
86 | uint8_t nwProto; /* IP protocol or low 8 bits of ARP opcode. */ | |
87 | uint8_t pad[3]; | |
88 | } ArpKey; /* Size of 24 byte. */ | |
89 | ||
90 | typedef struct Ipv6Key { | |
91 | struct in6_addr ipv6Src; /* IPv6 source address. */ | |
92 | struct in6_addr ipv6Dst; /* IPv6 destination address. */ | |
93 | ovs_be32 ipv6Label; /* IPv6 flow label. */ | |
94 | uint8_t nwProto; /* IP protocol or low 8 bits of ARP opcode. */ | |
95 | uint8_t nwTos; /* IP ToS (including DSCP and ECN). */ | |
96 | uint8_t nwTtl; /* IP TTL/Hop Limit. */ | |
97 | uint8_t nwFrag; /* FLOW_FRAG_* flags. */ | |
98 | L4Key l4; | |
481c5a6d | 99 | uint32_t pad; |
c803536e SS |
100 | } Ipv6Key; /* Size of 48 byte. */ |
101 | ||
102 | typedef struct Icmp6Key { | |
103 | struct in6_addr ipv6Src; /* IPv6 source address. */ | |
104 | struct in6_addr ipv6Dst; /* IPv6 destination address. */ | |
105 | ovs_be32 ipv6Label; /* IPv6 flow label. */ | |
106 | uint8_t nwProto; /* IP protocol or low 8 bits of ARP opcode. */ | |
107 | uint8_t nwTos; /* IP ToS (including DSCP and ECN). */ | |
108 | uint8_t nwTtl; /* IP TTL/Hop Limit. */ | |
109 | uint8_t nwFrag; /* FLOW_FRAG_* flags. */ | |
110 | L4Key l4; | |
111 | uint8_t arpSha[6]; /* ARP/ND source hardware address. */ | |
112 | uint8_t arpTha[6]; /* ARP/ND target hardware address. */ | |
113 | struct in6_addr ndTarget; /* IPv6 neighbor discovery (ND) target. */ | |
481c5a6d | 114 | } Icmp6Key; /* Size of 72 byte. */ |
c803536e SS |
115 | |
116 | typedef struct L2Key { | |
117 | uint32_t inPort; /* Port number of input port. */ | |
118 | union { | |
119 | struct { | |
120 | uint16_t offset; | |
121 | uint16_t keyLen; | |
122 | }; | |
123 | uint32_t val; | |
124 | }; | |
125 | uint8_t dlSrc[6]; /* Ethernet source address. */ | |
126 | uint8_t dlDst[6]; /* Ethernet destination address. */ | |
127 | ovs_be16 vlanTci; /* If 802.1Q, TCI | VLAN_CFI; otherwise 0. */ | |
128 | ovs_be16 dlType; /* Ethernet frame type. */ | |
5874d571 | 129 | } L2Key; /* Size of 24 byte. */ |
c803536e SS |
130 | |
131 | /* Number of packet attributes required to store OVS tunnel key. */ | |
132 | #define NUM_PKT_ATTR_REQUIRED 3 | |
133 | ||
134 | typedef union OvsIPv4TunnelKey { | |
135 | struct { | |
136 | ovs_be32 dst; | |
137 | ovs_be32 src; | |
138 | ovs_be64 tunnelId; | |
139 | uint16_t flags; | |
140 | uint8_t tos; | |
141 | uint8_t ttl; | |
142 | union { | |
143 | uint32_t pad; | |
144 | struct { | |
145 | ovs_be16 dst_port; | |
146 | uint16_t flow_hash; | |
147 | }; | |
148 | }; | |
149 | }; | |
150 | uint64_t attr[NUM_PKT_ATTR_REQUIRED]; | |
5874d571 SV |
151 | } OvsIPv4TunnelKey; /* Size of 24 byte. */ |
152 | ||
153 | typedef struct MplsKey { | |
154 | ovs_be32 lse; /* MPLS topmost label stack entry. */ | |
155 | uint8 pad[4]; | |
156 | } MplsKey; /* Size of 8 bytes. */ | |
c803536e SS |
157 | |
158 | typedef __declspec(align(8)) struct OvsFlowKey { | |
159 | OvsIPv4TunnelKey tunKey; /* 24 bytes */ | |
160 | L2Key l2; /* 24 bytes */ | |
161 | union { | |
5874d571 | 162 | /* These headers are mutually exclusive. */ |
c803536e SS |
163 | IpKey ipKey; /* size 16 */ |
164 | ArpKey arpKey; /* size 24 */ | |
165 | Ipv6Key ipv6Key; /* size 48 */ | |
166 | Icmp6Key icmp6Key; /* size 72 */ | |
5874d571 | 167 | MplsKey mplsKey; /* size 8 */ |
c803536e SS |
168 | }; |
169 | } OvsFlowKey; | |
170 | ||
171 | #define OVS_WIN_TUNNEL_KEY_SIZE (sizeof (OvsIPv4TunnelKey)) | |
172 | #define OVS_L2_KEY_SIZE (sizeof (L2Key)) | |
173 | #define OVS_IP_KEY_SIZE (sizeof (IpKey)) | |
174 | #define OVS_IPV6_KEY_SIZE (sizeof (Ipv6Key)) | |
175 | #define OVS_ARP_KEY_SIZE (sizeof (ArpKey)) | |
176 | #define OVS_ICMPV6_KEY_SIZE (sizeof (Icmp6Key)) | |
177 | ||
178 | typedef struct OvsFlowStats { | |
179 | Ovs64AlignedU64 packetCount; | |
180 | Ovs64AlignedU64 byteCount; | |
181 | uint32_t used; | |
182 | uint8_t tcpFlags; | |
183 | } OvsFlowStats; | |
184 | ||
185 | typedef struct OvsFlowInfo { | |
186 | OvsFlowKey key; | |
187 | struct OvsFlowStats stats; | |
188 | uint32_t actionsLen; | |
90439167 | 189 | PNL_ATTR actions; |
c803536e SS |
190 | } OvsFlowInfo; |
191 | ||
192 | enum GetFlags { | |
193 | FLOW_GET_KEY = 0x00000001, | |
194 | FLOW_GET_STATS = 0x00000010, | |
195 | FLOW_GET_ACTIONS = 0x00000100, | |
196 | }; | |
197 | ||
198 | typedef struct OvsFlowDumpInput { | |
199 | uint32_t dpNo; | |
200 | uint32_t position[2]; /* Offset hint to the start of flow dump. */ | |
201 | /* 0 - index of the hash table. | |
202 | * 1 - nth element in the hash table index. */ | |
203 | uint32_t getFlags; /* Information to get in addition to keys. */ | |
204 | uint32_t actionsLen; | |
205 | } OvsFlowDumpInput; | |
206 | ||
207 | ||
208 | typedef struct OvsFlowDumpOutput { | |
209 | /* Hint for the next flow dump operation. */ | |
210 | uint32_t position[2]; | |
211 | ||
212 | /* #flows (currently 0 or 1). In case the buffer is too small to output all | |
213 | * actions, this field indicates actual size needed to dump all actions. */ | |
214 | uint32_t n; | |
215 | ||
216 | OvsFlowInfo flow; | |
217 | } OvsFlowDumpOutput; | |
218 | ||
219 | typedef struct OvsFlowGetInput { | |
220 | uint32_t dpNo; | |
221 | OvsFlowKey key; | |
222 | uint32_t getFlags; /* Information to get in addition to keys. */ | |
223 | uint32_t actionsLen; /* Sizeof of buffer for actions. */ | |
224 | } OvsFlowGetInput; | |
225 | ||
226 | typedef struct OvsFlowGetOutput { | |
227 | OvsFlowInfo info; /* Variable length. */ | |
228 | } OvsFlowGetOutput; | |
229 | ||
230 | ||
231 | typedef enum OvsFlowPutFlags { | |
232 | OVSWIN_FLOW_PUT_CREATE = 1 << 0, | |
233 | OVSWIN_FLOW_PUT_MODIFY = 1 << 1, | |
234 | OVSWIN_FLOW_PUT_DELETE = 1 << 2, | |
235 | ||
236 | OVSWIN_FLOW_PUT_CLEAR = 1 << 3 | |
237 | } OvsFlowPutFlags; | |
238 | ||
239 | ||
240 | typedef struct OvsFlowPut { | |
241 | uint32_t dpNo; | |
242 | uint32_t actionsLen; | |
243 | OvsFlowKey key; | |
244 | uint32_t flags; | |
8a79c2d4 | 245 | PNL_ATTR actions; |
c803536e SS |
246 | } OvsFlowPut; |
247 | ||
248 | #define OVS_MIN_PACKET_SIZE 60 | |
249 | typedef struct _OVS_PACKET_INFO { | |
250 | uint32_t totalLen; | |
251 | uint32_t userDataLen; | |
252 | uint32_t packetLen; | |
253 | uint32_t queue; | |
254 | uint32_t inPort; | |
255 | uint32_t cmd; | |
256 | OvsIPv4TunnelKey tunnelKey; | |
1293a628 | 257 | uint8_t *payload; |
c803536e SS |
258 | /* Includes user data defined as chain of netlink attributes followed by the |
259 | * packet data. */ | |
260 | uint8_t data[0]; | |
261 | } OVS_PACKET_INFO, *POVS_PACKET_INFO; | |
262 | ||
263 | typedef struct OvsPacketExecute { | |
264 | uint32_t dpNo; | |
265 | uint32_t inPort; | |
266 | ||
267 | uint32_t packetLen; | |
268 | uint32_t actionsLen; | |
a74933bc AS |
269 | PCHAR packetBuf; |
270 | PNL_ATTR actions; | |
c803536e SS |
271 | } OvsPacketExecute; |
272 | ||
273 | ||
274 | typedef struct _OVS_EVENT_SUBSCRIBE { | |
275 | uint32_t cookie; | |
276 | uint32_t dpNo; | |
277 | uint32_t subscribe; | |
278 | uint32_t mask; | |
279 | } OVS_EVENT_SUBSCRIBE, *POVS_EVENT_SUBSCRIBE; | |
280 | ||
281 | typedef struct _OVS_EVENT_POLL { | |
282 | uint32_t cookie; | |
283 | uint32_t dpNo; | |
284 | } OVS_EVENT_POLL, *POVS_EVENT_POLL; | |
285 | ||
286 | enum { | |
287 | OVS_EVENT_CONNECT = ((uint32_t)0x1 << 0), | |
288 | OVS_EVENT_DISCONNECT = ((uint32_t)0x1 << 1), | |
289 | OVS_EVENT_LINK_UP = ((uint32_t)0x1 << 2), | |
290 | OVS_EVENT_LINK_DOWN = ((uint32_t)0x1 << 3), | |
291 | OVS_EVENT_MAC_CHANGE = ((uint32_t)0x1 << 4), | |
292 | OVS_EVENT_MTU_CHANGE = ((uint32_t)0x1 << 5), | |
293 | OVS_EVENT_MASK_ALL = 0x3f, | |
294 | }; | |
295 | ||
296 | ||
297 | typedef struct _OVS_EVENT_ENTRY { | |
9be4a837 NR |
298 | UINT32 portNo; |
299 | OVS_VPORT_TYPE ovsType; | |
300 | UINT32 upcallPid; | |
301 | CHAR ovsName[OVS_MAX_PORT_NAME_LENGTH]; | |
302 | UINT32 type; | |
c803536e SS |
303 | } OVS_EVENT_ENTRY, *POVS_EVENT_ENTRY; |
304 | ||
c803536e SS |
305 | |
306 | typedef struct _OVS_EVENT_STATUS { | |
307 | uint32_t numberEntries; | |
308 | OVS_EVENT_ENTRY eventEntries[0]; | |
309 | } OVS_EVENT_STATUS, *POVS_EVENT_STATUS; | |
310 | ||
311 | #pragma pack(pop) | |
312 | ||
9c3d71b0 | 313 | #endif /* __DP_INTERNAL_H_ */ |