datapath-windows: Cleanup Stt.c
[cascardo/ovs.git] / datapath-windows / ovsext / Flow.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 __FLOW_H_
18 #define __FLOW_H_ 1
19
20 #include "precomp.h"
21 #include "Switch.h"
22 #include "User.h"
23 #include "NetProto.h"
24 #include "Datapath.h"
25
26 typedef struct _OvsFlow {
27     LIST_ENTRY ListEntry;            // In Datapath's flowTable.
28     OvsFlowKey key;
29     UINT64 hash;
30     UINT32 actionsLen;
31     UINT8 tcpFlags;
32     UINT64 used;
33     UINT64 packetCount;
34     UINT64 byteCount;
35     UINT32 userActionsLen;   // used for flow query
36     UINT32 actionBufferLen;  // used for flow reuse
37     NL_ATTR actions[1];
38 } OvsFlow;
39
40
41 typedef struct _OvsLayers {
42     UINT32 l3Ofs;             // IPv4, IPv6, ARP, or other L3 header.
43     UINT32 l4Ofs;             // TCP, UDP, SCTP, ICMP, ICMPv6, or other L4 header.
44     UINT32 l7Ofs;             // L4 protocol's payload.
45 } OvsLayers;
46
47 extern UINT64 ovsUserTimestampDelta;
48 extern UINT64 ovsTimeIncrementPerTick;
49
50 NDIS_STATUS OvsDeleteFlowTable(OVS_DATAPATH *datapath);
51 NDIS_STATUS OvsAllocateFlowTable(OVS_DATAPATH *datapath,
52                                  POVS_SWITCH_CONTEXT switchContext);
53
54 NDIS_STATUS OvsExtractFlow(const NET_BUFFER_LIST *pkt, UINT32 inPort,
55                            OvsFlowKey *flow, POVS_PACKET_HDR_INFO layers,
56                            OvsIPv4TunnelKey *tunKey);
57 OvsFlow *OvsLookupFlow(OVS_DATAPATH *datapath, const OvsFlowKey *key,
58                        UINT64 *hash, BOOLEAN hashValid);
59 UINT64 OvsHashFlow(const OvsFlowKey *key);
60 VOID OvsFlowUsed(OvsFlow *flow, const NET_BUFFER_LIST *pkt,
61                  const POVS_PACKET_HDR_INFO layers);
62
63 NTSTATUS OvsDumpFlowIoctl(PVOID inputBuffer, UINT32 inputLength,
64                           PVOID outputBuffer, UINT32 outputLength,
65                           UINT32 *replyLen);
66 NTSTATUS OvsPutFlowIoctl(PVOID inputBuffer, UINT32 inputLength,
67                          struct OvsFlowStats *stats);
68 NTSTATUS OvsGetFlowIoctl(PVOID inputBuffer, PVOID outputBuffer);
69 NTSTATUS OvsFlushFlowIoctl(UINT32 dpNo);
70
71 NTSTATUS OvsFlowNlCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
72                              UINT32 *replyLen);
73 NTSTATUS OvsFlowNlGetCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
74                                 UINT32 *replyLen);
75 NTSTATUS MapFlowKeyToNlKey(PNL_BUFFER nlBuf, OvsFlowKey *flowKey,
76                            UINT16 keyType, UINT16 tunKeyType);
77 NTSTATUS MapFlowTunKeyToNlKey(PNL_BUFFER nlBuf, OvsIPv4TunnelKey *tunKey,
78                               UINT16 tunKeyType);
79 UINT32 OvsFlowKeyAttrSize(void);
80 UINT32 OvsTunKeyAttrSize(void);
81
82 /* Flags for tunneling */
83 #define OVS_TNL_F_DONT_FRAGMENT         (1 << 0)
84 #define OVS_TNL_F_CSUM                  (1 << 1)
85 #define OVS_TNL_F_KEY                   (1 << 2)
86
87 #endif /* __FLOW_H_ */