]> git.proxmox.com Git - mirror_ovs.git/blame - datapath-windows/include/OvsPub.h
datapath-windows: Added the API for getting unused space in nlbuf.
[mirror_ovs.git] / datapath-windows / include / OvsPub.h
CommitLineData
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
17#ifndef __OVS_PUB_H_
18#define __OVS_PUB_H_ 1
19
b52641dd 20#include "../ovsext/Netlink/Netlink.h"
c803536e
SS
21
22#define OVS_DRIVER_MAJOR_VER 1
23#define OVS_DRIVER_MINOR_VER 0
24
25#define OVS_DEVICE_TYPE 45000
26#define OVS_IOCTL_TYPE OVS_DEVICE_TYPE
27#define OVS_DP_NUMBER ((uint32_t) 0)
28#define OVSWIN_DEVICE_NAME_MAX_LENGTH 32
29
30#define IFF_RUNNING 0x20
31#define IFF_PROMISC 0x40
32
33#define OVS_MAX_OPAQUE_NETWORK_ID_LEN 128
34
35#define OVS_NT_DEVICE_NAME L"\\Device\\OvsIoctl"
36#define OVS_DOS_DEVICE_NAME L"\\DosDevices\\OvsIoctl"
37#define OVS_USER_DEVICE_PATH TEXT("\\\\.\\OvsIoctl")
38
39#define OVS_IOCTL_DP_START 0x100
40#define OVS_IOCTL_DP_DUMP \
41 CTL_CODE (OVS_DEVICE_TYPE, OVS_IOCTL_DP_START + 0x0, METHOD_BUFFERED, FILE_READ_ACCESS)
42#define OVS_IOCTL_DP_GET \
43 CTL_CODE (OVS_DEVICE_TYPE, OVS_IOCTL_DP_START + 0x1, METHOD_OUT_DIRECT, FILE_READ_ACCESS)
44#define OVS_IOCTL_DP_SET \
45 CTL_CODE (OVS_DEVICE_TYPE, OVS_IOCTL_DP_START + 0x2, METHOD_IN_DIRECT, FILE_WRITE_ACCESS)
46#define OVS_IOCTL_DP_TIMESTAMP_SET \
47 CTL_CODE (OVS_DEVICE_TYPE, OVS_IOCTL_DP_START + 0x3, METHOD_BUFFERED, FILE_ANY_ACCESS)
48
49
50#define OVS_IOCTL_VPORT_START 0x200
51#define OVS_IOCTL_VPORT_DUMP \
52 CTL_CODE (OVS_DEVICE_TYPE, OVS_IOCTL_VPORT_START + 0x0, METHOD_OUT_DIRECT, FILE_READ_ACCESS)
53#define OVS_IOCTL_VPORT_GET \
54 CTL_CODE (OVS_DEVICE_TYPE, OVS_IOCTL_VPORT_START + 0x1, METHOD_OUT_DIRECT, FILE_READ_ACCESS)
55#define OVS_IOCTL_VPORT_SET \
56 CTL_CODE (OVS_DEVICE_TYPE, OVS_IOCTL_VPORT_START + 0x2, METHOD_IN_DIRECT, FILE_WRITE_ACCESS)
57#define OVS_IOCTL_VPORT_ADD \
58 CTL_CODE (OVS_DEVICE_TYPE, OVS_IOCTL_VPORT_START + 0x3, METHOD_IN_DIRECT, FILE_WRITE_ACCESS)
59#define OVS_IOCTL_VPORT_DEL \
60 CTL_CODE (OVS_DEVICE_TYPE, OVS_IOCTL_VPORT_START + 0x4, METHOD_IN_DIRECT, FILE_WRITE_ACCESS)
61#define OVS_IOCTL_VPORT_EXT_INFO \
62 CTL_CODE (OVS_DEVICE_TYPE, OVS_IOCTL_VPORT_START + 0x5, METHOD_OUT_DIRECT, FILE_READ_ACCESS)
63
64#define OVS_IOCTL_FLOW_START 0x300
65#define OVS_IOCTL_FLOW_DUMP \
66 CTL_CODE (OVS_DEVICE_TYPE, OVS_IOCTL_FLOW_START + 0x0, METHOD_OUT_DIRECT, FILE_READ_ACCESS)
67#define OVS_IOCTL_FLOW_GET \
68 CTL_CODE (OVS_DEVICE_TYPE, OVS_IOCTL_FLOW_START + 0x1, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
69
70#define OVS_IOCTL_FLOW_PUT \
71 CTL_CODE (OVS_DEVICE_TYPE, OVS_IOCTL_FLOW_START + 0x2, METHOD_BUFFERED, FILE_ANY_ACCESS)
72#define OVS_IOCTL_FLOW_FLUSH \
73 CTL_CODE (OVS_DEVICE_TYPE, OVS_IOCTL_FLOW_START + 0x3, METHOD_BUFFERED, FILE_WRITE_ACCESS)
74
75
76#define OVS_IOCTL_QOS_START 0x400
77#define OVS_IOCTL_QOS_QUEUE_DUMP \
78 CTL_CODE (OVS_DEVICE_TYPE, OVS_IOCTL_QOS_START + 0x0, METHOD_OUT_DIRECT, FILE_READ_ACCESS)
79#define OVS_IOCTL_QOS_QUEUE_GET \
80 CTL_CODE (OVS_DEVICE_TYPE, OVS_IOCTL_QOS_START + 0x1, METHOD_OUT_DIRECT, FILE_READ_ACCESS)
81#define OVS_IOCTL_QOS_QUEUE_SET \
82 CTL_CODE (OVS_DEVICE_TYPE, OVS_IOCTL_QOS_START + 0x2, METHOD_IN_DIRECT, FILE_WRITE_ACCESS)
83
84
85#define OVS_IOCTL_DATAPATH_START 0x500
86#define OVS_IOCTL_DATAPATH_SUBSCRIBE \
87 CTL_CODE (OVS_DEVICE_TYPE, OVS_IOCTL_DATAPATH_START + 0x0, METHOD_BUFFERED, FILE_WRITE_ACCESS)
88#define OVS_IOCTL_DATAPATH_READ \
89 CTL_CODE (OVS_DEVICE_TYPE, OVS_IOCTL_DATAPATH_START + 0x1, METHOD_OUT_DIRECT, FILE_READ_ACCESS)
90#define OVS_IOCTL_DATAPATH_EXECUTE \
91 CTL_CODE (OVS_DEVICE_TYPE, OVS_IOCTL_DATAPATH_START + 0x2, METHOD_IN_DIRECT, FILE_WRITE_ACCESS)
92#define OVS_IOCTL_DATAPATH_OPERATE \
93 CTL_CODE (OVS_DEVICE_TYPE, OVS_IOCTL_DATAPATH_START + 0x3, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
94#define OVS_IOCTL_DATAPATH_PURGE \
95 CTL_CODE (OVS_DEVICE_TYPE, OVS_IOCTL_DATAPATH_START + 0x4, METHOD_NEITHER, FILE_ANY_ACCESS)
96#define OVS_IOCTL_DATAPATH_WAIT \
97 CTL_CODE (OVS_DEVICE_TYPE, OVS_IOCTL_DATAPATH_START + 0x5, METHOD_NEITHER, FILE_ANY_ACCESS)
98
99
100
101#define OVS_IOCTL_EVENT_START 0x600
102#define OVS_IOCTL_EVENT_SUBSCRIBE \
103 CTL_CODE (OVS_DEVICE_TYPE, OVS_IOCTL_EVENT_START + 0x0, METHOD_BUFFERED, FILE_WRITE_ACCESS)
104#define OVS_IOCTL_EVENT_POLL \
105 CTL_CODE (OVS_DEVICE_TYPE, OVS_IOCTL_EVENT_START + 0x1, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
106#define OVS_IOCTL_EVENT_WAIT \
107 CTL_CODE (OVS_DEVICE_TYPE, OVS_IOCTL_EVENT_START + 0x2, METHOD_BUFFERED, FILE_ANY_ACCESS)
108
109
110#define OVS_IOCTL_VERSION_START 0x700
111#define OVS_IOCTL_VERSION_GET \
112 CTL_CODE(OVS_DEVICE_TYPE, OVS_IOCTL_VERSION_START + 0x0, METHOD_BUFFERED, FILE_ANY_ACCESS)
113
114typedef __declspec(align(8)) uint64_t Ovs64AlignedU64;
115typedef __declspec(align(8)) ovs_be64 Ovs64AlignedBe64;
116#pragma pack(push, 1)
117
118
119typedef struct _OVS_DP_INFO {
120 char name[128];
121 uint32_t dpNo;
122 uint32_t queue;
123 Ovs64AlignedU64 nHit;
124 Ovs64AlignedU64 nMissed;
125 Ovs64AlignedU64 nLost;
126 Ovs64AlignedU64 nFlows;
127} OVS_DP_INFO, *POVS_DP_INFO;
128
129
130typedef struct _OVS_VERSION {
131 uint8_t mjrDrvVer;
132 uint8_t mnrDrvVer;
133} OVS_VERSION, *POVS_VERSION;
134
135
136
137#define OVS_MAX_PORT_NAME_LENGTH 32
138
139typedef struct _OVS_VPORT_GET {
140 uint32_t dpNo;
141 uint32_t portNo;
142 char name[OVS_MAX_PORT_NAME_LENGTH];
143} OVS_VPORT_GET, *POVS_VPORT_GET;
144
c803536e
SS
145static __inline const char *
146OvsVportTypeToStr(OVS_VPORT_TYPE t)
147{
148 switch(t) {
e00afcf6
SG
149#define STR(t) case OVS_VPORT_TYPE_##t : return "VPORT_##t";
150 STR(UNSPEC)
151 STR(NETDEV)
c803536e 152 STR(INTERNAL)
c803536e
SS
153 STR(GRE)
154 STR(GRE64)
155 STR(VXLAN)
e00afcf6
SG
156 STR(GENEVE)
157 STR(LISP)
c803536e
SS
158 }
159#undef STR
160
161 return "Invalid type";
162}
163
164#define MAC_ADDRESS_LEN 6
165
166typedef struct _OVS_VPORT_INFO {
167 uint32_t dpNo;
168 uint32_t portNo;
169 char name[OVS_MAX_PORT_NAME_LENGTH];
170 uint32_t type;
171 uint32_t queue;
172
173 Ovs64AlignedU64 rxPackets;
174 Ovs64AlignedU64 txPackets;
175 Ovs64AlignedU64 rxBytes;
176 Ovs64AlignedU64 txBytes;
177 Ovs64AlignedU64 rxErrors;
178 Ovs64AlignedU64 txErrors;
179 Ovs64AlignedU64 rxDropped;
180 Ovs64AlignedU64 txDropped;
181
182 uint8_t macAddress[MAC_ADDRESS_LEN];
183 uint16_t pad;
184} OVS_VPORT_INFO, *POVS_VPORT_INFO;
185
186typedef struct _OVS_VPORT_ADD_REQUEST {
187 uint32_t dpNo;
188 uint32_t type;
189 char name[OVS_MAX_PORT_NAME_LENGTH];
190 uint16_t dstPort;
191 uint16_t pad[3];
192} OVS_VPORT_ADD_REQUEST, *POVS_VPORT_ADD_REQUEST;
193
194
195typedef struct _OVS_VPORT_DELETE_REQUEST {
196 uint32_t dpNo;
197 uint32_t portNo;
198 char name[OVS_MAX_PORT_NAME_LENGTH];
199} OVS_VPORT_DELETE_REQUEST, *POVS_VPORT_DELETE_REQUEST;
200
201
202#define OVS_MAX_VM_UUID_LEN 128
203#define OVS_MAX_VIF_UUID_LEN 128
204
205typedef struct _OVS_VPORT_EXT_INFO {
206 uint32_t dpNo;
207 uint32_t portNo;
208 uint8_t macAddress[MAC_ADDRESS_LEN];
209 uint8_t permMACAddress[MAC_ADDRESS_LEN];
210 uint8_t vmMACAddress[MAC_ADDRESS_LEN];
211 uint16_t nicIndex;
212 uint32_t portId;
213 uint32_t type;
214 uint32_t mtu;
215 char name[OVS_MAX_PORT_NAME_LENGTH];
216 uint32_t status;
217 char vmUUID[OVS_MAX_VM_UUID_LEN];
218 char vifUUID[OVS_MAX_VIF_UUID_LEN];
219} OVS_VPORT_EXT_INFO, *POVS_VPORT_EXT_INFO;
220
221
222/* Flows. */
223#define OVSWIN_VLAN_CFI 0x1000
224#define OVSWIN_INPORT_INVALID 0xffffffff
225
226/* Used for OvsFlowKey's dlType member for frames that have no Ethernet type,
227 * that is, pure 802.2 frames. */
228#define OVSWIN_DL_TYPE_NONE 0x5ff
229
230/* Fragment bits, used for IPv4 and IPv6, always zero for non-IP flows. */
231#define OVSWIN_NW_FRAG_ANY (1 << 0) /* Set for any IP frag. */
232#define OVSWIN_NW_FRAG_LATER (1 << 1) /* Set for IP frag with nonzero
233 * offset. */
234#define OVSWIN_NW_FRAG_MASK (OVSWIN_NW_FRAG_ANY | OVSWIN_NW_FRAG_LATER)
235
236typedef struct L4Key {
237 ovs_be16 tpSrc; /* TCP/UDP/SCTP source port. */
238 ovs_be16 tpDst; /* TCP/UDP/SCTP destination port. */
239} L4Key;
240
241typedef struct Ipkey {
242 ovs_be32 nwSrc; /* IPv4 source address. */
243 ovs_be32 nwDst; /* IPv4 destination address. */
244 uint8_t nwProto; /* IP protocol or low 8 bits of ARP opcode. */
245 uint8_t nwTos; /* IP ToS (including DSCP and ECN). */
246 uint8_t nwTtl; /* IP TTL/Hop Limit. */
247 uint8_t nwFrag; /* FLOW_FRAG_* flags. */
248 L4Key l4;
249} IpKey; /* Size of 16 byte. */
250
251typedef struct ArpKey {
252 ovs_be32 nwSrc; /* IPv4 source address. */
253 ovs_be32 nwDst; /* IPv4 destination address. */
254 uint8_t arpSha[6]; /* ARP/ND source hardware address. */
255 uint8_t arpTha[6]; /* ARP/ND target hardware address. */
256 uint8_t nwProto; /* IP protocol or low 8 bits of ARP opcode. */
257 uint8_t pad[3];
258} ArpKey; /* Size of 24 byte. */
259
260typedef struct Ipv6Key {
261 struct in6_addr ipv6Src; /* IPv6 source address. */
262 struct in6_addr ipv6Dst; /* IPv6 destination address. */
263 ovs_be32 ipv6Label; /* IPv6 flow label. */
264 uint8_t nwProto; /* IP protocol or low 8 bits of ARP opcode. */
265 uint8_t nwTos; /* IP ToS (including DSCP and ECN). */
266 uint8_t nwTtl; /* IP TTL/Hop Limit. */
267 uint8_t nwFrag; /* FLOW_FRAG_* flags. */
268 L4Key l4;
269 uint32_t pad;
270} Ipv6Key; /* Size of 48 byte. */
271
272typedef struct Icmp6Key {
273 struct in6_addr ipv6Src; /* IPv6 source address. */
274 struct in6_addr ipv6Dst; /* IPv6 destination address. */
275 ovs_be32 ipv6Label; /* IPv6 flow label. */
276 uint8_t nwProto; /* IP protocol or low 8 bits of ARP opcode. */
277 uint8_t nwTos; /* IP ToS (including DSCP and ECN). */
278 uint8_t nwTtl; /* IP TTL/Hop Limit. */
279 uint8_t nwFrag; /* FLOW_FRAG_* flags. */
280 L4Key l4;
281 uint8_t arpSha[6]; /* ARP/ND source hardware address. */
282 uint8_t arpTha[6]; /* ARP/ND target hardware address. */
283 struct in6_addr ndTarget; /* IPv6 neighbor discovery (ND) target. */
284} Icmp6Key; /* Size of 72 byte. */
285
286typedef struct L2Key {
287 uint32_t inPort; /* Port number of input port. */
288 union {
289 struct {
290 uint16_t offset;
291 uint16_t keyLen;
292 };
293 uint32_t val;
294 };
295 uint8_t dlSrc[6]; /* Ethernet source address. */
296 uint8_t dlDst[6]; /* Ethernet destination address. */
297 ovs_be16 vlanTci; /* If 802.1Q, TCI | VLAN_CFI; otherwise 0. */
298 ovs_be16 dlType; /* Ethernet frame type. */
299} L2Key; /* Size of 24 byte. */
300
301/* Number of packet attributes required to store OVS tunnel key. */
302#define NUM_PKT_ATTR_REQUIRED 3
303
304typedef union OvsIPv4TunnelKey {
305 struct {
306 ovs_be32 dst;
307 ovs_be32 src;
308 ovs_be64 tunnelId;
309 uint16_t flags;
310 uint8_t tos;
311 uint8_t ttl;
312 union {
313 uint32_t pad;
314 struct {
315 ovs_be16 dst_port;
316 uint16_t flow_hash;
317 };
318 };
319 };
320 uint64_t attr[NUM_PKT_ATTR_REQUIRED];
321} OvsIPv4TunnelKey;
322
323typedef __declspec(align(8)) struct OvsFlowKey {
324 OvsIPv4TunnelKey tunKey; /* 24 bytes */
325 L2Key l2; /* 24 bytes */
326 union {
327 IpKey ipKey; /* size 16 */
328 ArpKey arpKey; /* size 24 */
329 Ipv6Key ipv6Key; /* size 48 */
330 Icmp6Key icmp6Key; /* size 72 */
331 };
332} OvsFlowKey;
333
334#define OVS_WIN_TUNNEL_KEY_SIZE (sizeof (OvsIPv4TunnelKey))
335#define OVS_L2_KEY_SIZE (sizeof (L2Key))
336#define OVS_IP_KEY_SIZE (sizeof (IpKey))
337#define OVS_IPV6_KEY_SIZE (sizeof (Ipv6Key))
338#define OVS_ARP_KEY_SIZE (sizeof (ArpKey))
339#define OVS_ICMPV6_KEY_SIZE (sizeof (Icmp6Key))
340
341typedef struct OvsFlowStats {
342 Ovs64AlignedU64 packetCount;
343 Ovs64AlignedU64 byteCount;
344 uint32_t used;
345 uint8_t tcpFlags;
346} OvsFlowStats;
347
348typedef struct OvsFlowInfo {
349 OvsFlowKey key;
350 struct OvsFlowStats stats;
351 uint32_t actionsLen;
d838e577 352 NL_ATTR actions[0];
c803536e
SS
353} OvsFlowInfo;
354
355enum GetFlags {
356 FLOW_GET_KEY = 0x00000001,
357 FLOW_GET_STATS = 0x00000010,
358 FLOW_GET_ACTIONS = 0x00000100,
359};
360
361typedef struct OvsFlowDumpInput {
362 uint32_t dpNo;
363 uint32_t position[2]; /* Offset hint to the start of flow dump. */
364 /* 0 - index of the hash table.
365 * 1 - nth element in the hash table index. */
366 uint32_t getFlags; /* Information to get in addition to keys. */
367 uint32_t actionsLen;
368} OvsFlowDumpInput;
369
370
371typedef struct OvsFlowDumpOutput {
372 /* Hint for the next flow dump operation. */
373 uint32_t position[2];
374
375 /* #flows (currently 0 or 1). In case the buffer is too small to output all
376 * actions, this field indicates actual size needed to dump all actions. */
377 uint32_t n;
378
379 OvsFlowInfo flow;
380} OvsFlowDumpOutput;
381
382typedef struct OvsFlowGetInput {
383 uint32_t dpNo;
384 OvsFlowKey key;
385 uint32_t getFlags; /* Information to get in addition to keys. */
386 uint32_t actionsLen; /* Sizeof of buffer for actions. */
387} OvsFlowGetInput;
388
389typedef struct OvsFlowGetOutput {
390 OvsFlowInfo info; /* Variable length. */
391} OvsFlowGetOutput;
392
393
394typedef enum OvsFlowPutFlags {
395 OVSWIN_FLOW_PUT_CREATE = 1 << 0,
396 OVSWIN_FLOW_PUT_MODIFY = 1 << 1,
397 OVSWIN_FLOW_PUT_DELETE = 1 << 2,
398
399 OVSWIN_FLOW_PUT_CLEAR = 1 << 3
400} OvsFlowPutFlags;
401
402
403typedef struct OvsFlowPut {
404 uint32_t dpNo;
405 uint32_t actionsLen;
406 OvsFlowKey key;
407 uint32_t flags;
8a79c2d4 408 PNL_ATTR actions;
c803536e
SS
409} OvsFlowPut;
410
411#define OVS_MIN_PACKET_SIZE 60
412typedef struct _OVS_PACKET_INFO {
413 uint32_t totalLen;
414 uint32_t userDataLen;
415 uint32_t packetLen;
416 uint32_t queue;
417 uint32_t inPort;
418 uint32_t cmd;
419 OvsIPv4TunnelKey tunnelKey;
420 /* Includes user data defined as chain of netlink attributes followed by the
421 * packet data. */
422 uint8_t data[0];
423} OVS_PACKET_INFO, *POVS_PACKET_INFO;
424
425typedef struct OvsPacketExecute {
426 uint32_t dpNo;
427 uint32_t inPort;
428
429 uint32_t packetLen;
430 uint32_t actionsLen;
431 union {
432 /* Variable size blob with packet data first, followed by action
433 * attrs. */
434 char packetBuf[0];
d838e577 435 NL_ATTR actions[0];
c803536e
SS
436 };
437} OvsPacketExecute;
438
439
440typedef struct _OVS_EVENT_SUBSCRIBE {
441 uint32_t cookie;
442 uint32_t dpNo;
443 uint32_t subscribe;
444 uint32_t mask;
445} OVS_EVENT_SUBSCRIBE, *POVS_EVENT_SUBSCRIBE;
446
447typedef struct _OVS_EVENT_POLL {
448 uint32_t cookie;
449 uint32_t dpNo;
450} OVS_EVENT_POLL, *POVS_EVENT_POLL;
451
452enum {
453 OVS_EVENT_CONNECT = ((uint32_t)0x1 << 0),
454 OVS_EVENT_DISCONNECT = ((uint32_t)0x1 << 1),
455 OVS_EVENT_LINK_UP = ((uint32_t)0x1 << 2),
456 OVS_EVENT_LINK_DOWN = ((uint32_t)0x1 << 3),
457 OVS_EVENT_MAC_CHANGE = ((uint32_t)0x1 << 4),
458 OVS_EVENT_MTU_CHANGE = ((uint32_t)0x1 << 5),
459 OVS_EVENT_MASK_ALL = 0x3f,
460};
461
462
463typedef struct _OVS_EVENT_ENTRY {
464 uint32_t portNo;
465 uint32_t status;
466} OVS_EVENT_ENTRY, *POVS_EVENT_ENTRY;
467
468#define OVS_DEFAULT_PORT_NO 0xffffffff
469#define OVS_DEFAULT_EVENT_STATUS 0xffffffff
470
471typedef struct _OVS_EVENT_STATUS {
472 uint32_t numberEntries;
473 OVS_EVENT_ENTRY eventEntries[0];
474} OVS_EVENT_STATUS, *POVS_EVENT_STATUS;
475
476#pragma pack(pop)
477
478#endif /* __OVS_PUB_H_ */