Merge "master" into "ovn".
[cascardo/ovs.git] / datapath-windows / ovsext / Stt.h
1 /*
2  * Copyright (c) 2015 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_STT_H_
18 #define __OVS_STT_H_ 1
19
20 #define STT_TCP_PORT 7471
21 #define STT_TCP_PORT_NBO 0x2f1d
22
23 #define MAX_IP_TOTAL_LEN 65535
24
25 // STT defines.
26 #define STT_SEQ_LEN_SHIFT 16
27 #define STT_SEQ_OFFSET_MASK ((1 << STT_SEQ_LEN_SHIFT) - 1)
28 #define STT_FRAME_LEN(seq) ((seq) >> STT_SEQ_LEN_SHIFT)
29 #define STT_SEGMENT_OFF(seq) ((seq) & STT_SEQ_OFFSET_MASK)
30
31 #define STT_CSUM_VERIFIED   (1 << 0)
32 #define STT_CSUM_PARTIAL    (1 << 1)
33 #define STT_PROTO_IPV4      (1 << 2)
34 #define STT_PROTO_TCP       (1 << 3)
35 #define STT_PROTO_TYPES     (STT_PROTO_IPV4 | STT_PROTO_TCP)
36
37 #define STT_ETH_PAD 2
38 typedef struct SttHdr {
39     UINT8    version;
40     UINT8    flags;
41     UINT8    l4Offset;
42     UINT8    reserved;
43     UINT16   mss;
44     UINT16   vlanTCI;
45     UINT64   key;
46 } SttHdr, *PSttHdr;
47
48 #define STT_HDR_LEN (sizeof(SttHdr) + STT_ETH_PAD)
49
50 typedef struct _OVS_STT_VPORT {
51     UINT16 dstPort;
52     UINT64 ackNo;
53     UINT64 ipId;
54
55     UINT64 inPkts;
56     UINT64 outPkts;
57     UINT64 slowInPkts;
58     UINT64 slowOutPkts;
59 } OVS_STT_VPORT, *POVS_STT_VPORT;
60
61 NTSTATUS OvsInitSttTunnel(POVS_VPORT_ENTRY vport,
62                           UINT16 udpDestPort);
63
64 VOID OvsCleanupSttTunnel(POVS_VPORT_ENTRY vport);
65
66
67 void OvsCleanupSttTunnel(POVS_VPORT_ENTRY vport);
68
69 NDIS_STATUS OvsEncapStt(POVS_VPORT_ENTRY vport,
70                         PNET_BUFFER_LIST curNbl,
71                         OvsIPv4TunnelKey *tunKey,
72                         POVS_SWITCH_CONTEXT switchContext,
73                         POVS_PACKET_HDR_INFO layers,
74                         PNET_BUFFER_LIST *newNbl);
75
76
77 NDIS_STATUS OvsDecapStt(POVS_SWITCH_CONTEXT switchContext,
78                         PNET_BUFFER_LIST curNbl,
79                         OvsIPv4TunnelKey *tunKey,
80                         PNET_BUFFER_LIST *newNbl);
81
82 static __inline UINT32
83 OvsGetSttTunHdrSize(VOID)
84 {
85     return sizeof (EthHdr) + sizeof(IPHdr) + sizeof(TCPHdr) +
86                   STT_HDR_LEN;
87 }
88
89 #endif /*__OVS_STT_H_ */