b010af02d28ac03228fe1f4264f10bcc1cede423
[cascardo/ovs.git] / datapath-windows / ovsext / Vxlan.h
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 __VXLAN_H_
18 #define __VXLAN_H_ 1
19
20 #include "NetProto.h"
21 typedef struct _OVS_VXLAN_VPORT {
22     UINT16 dstPort;
23     UINT64 inPkts;
24     UINT64 outPkts;
25     UINT64 slowInPkts;
26     UINT64 slowOutPkts;
27     UINT64 filterID;
28     /*
29      * To be filled
30      */
31 } OVS_VXLAN_VPORT, *POVS_VXLAN_VPORT;
32
33 /* VXLAN header. */
34 typedef struct VXLANHdr {
35     /* Flags. */
36     UINT32   flags1:2;
37     /* Packet needs replication to multicast group (used for multicast proxy). */
38     UINT32   locallyReplicate:1;
39     /* Instance ID flag, must be set to 1. */
40     UINT32   instanceID:1;
41     /* Flags. */
42     UINT32   flags2:4;
43     /* Reserved. */
44     UINT32  reserved1:24;
45     /* VXLAN ID. */
46     UINT32  vxlanID:24;
47     /* Reserved. */
48     UINT32   reserved2:8;
49 } VXLANHdr;
50
51 NTSTATUS OvsInitVxlanTunnel(PIRP irp,
52                             POVS_VPORT_ENTRY vport,
53                             UINT16 udpDestPort,
54                             PFNTunnelVportPendingOp callback,
55                             PVOID tunnelContext);
56
57 NTSTATUS OvsCleanupVxlanTunnel(PIRP irp,
58                                POVS_VPORT_ENTRY vport,
59                                PFNTunnelVportPendingOp callback,
60                                PVOID tunnelContext);
61
62 NDIS_STATUS OvsSlowPathDecapVxlan(const PNET_BUFFER_LIST packet,
63                                   OvsIPv4TunnelKey *tunnelKey);
64
65 NDIS_STATUS OvsEncapVxlan(POVS_VPORT_ENTRY vport,
66                           PNET_BUFFER_LIST curNbl,
67                           OvsIPv4TunnelKey *tunKey,
68                           POVS_SWITCH_CONTEXT switchContext,
69                           POVS_PACKET_HDR_INFO layers,
70                           PNET_BUFFER_LIST *newNbl);
71
72 NDIS_STATUS OvsDecapVxlan(POVS_SWITCH_CONTEXT switchContext,
73                           PNET_BUFFER_LIST curNbl,
74                           OvsIPv4TunnelKey *tunKey,
75                           PNET_BUFFER_LIST *newNbl);
76
77 static __inline UINT32
78 OvsGetVxlanTunHdrSize(VOID)
79 {
80     /* XXX: Can L2 include VLAN at all? */
81     return sizeof (EthHdr) + sizeof (IPHdr) + sizeof (UDPHdr) +
82            sizeof (VXLANHdr);
83 }
84
85 #define VXLAN_UDP_PORT 4789
86 #define VXLAN_UDP_PORT_NBO 0xB512
87
88 #endif /* __VXLAN_H_ */