fb3fb598472800de9805e13fb724d72c11b29ce5
[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 OvsGetFlowMetadata(OvsFlowKey *key,
55                                PNL_ATTR *keyAttrs);
56 NDIS_STATUS OvsExtractFlow(const NET_BUFFER_LIST *pkt, UINT32 inPort,
57                            OvsFlowKey *flow, POVS_PACKET_HDR_INFO layers,
58                            OvsIPv4TunnelKey *tunKey);
59 OvsFlow* OvsLookupFlow(OVS_DATAPATH *datapath, const OvsFlowKey *key,
60                        UINT64 *hash, BOOLEAN hashValid);
61 OvsFlow* OvsLookupFlowRecirc(OVS_DATAPATH *datapath,
62                              const OvsFlowKey *key,
63                              UINT64 *hash);
64 UINT64 OvsHashFlow(const OvsFlowKey *key);
65 VOID OvsFlowUsed(OvsFlow *flow, const NET_BUFFER_LIST *pkt,
66                  const POVS_PACKET_HDR_INFO layers);
67
68 NTSTATUS OvsDumpFlowIoctl(PVOID inputBuffer, UINT32 inputLength,
69                           PVOID outputBuffer, UINT32 outputLength,
70                           UINT32 *replyLen);
71 NTSTATUS OvsPutFlowIoctl(PVOID inputBuffer, UINT32 inputLength,
72                          struct OvsFlowStats *stats);
73 NTSTATUS OvsGetFlowIoctl(PVOID inputBuffer, PVOID outputBuffer);
74 NTSTATUS OvsFlushFlowIoctl(UINT32 dpNo);
75
76 NTSTATUS OvsFlowNlCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
77                              UINT32 *replyLen);
78 NTSTATUS OvsFlowNlGetCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
79                                 UINT32 *replyLen);
80 NTSTATUS MapFlowKeyToNlKey(PNL_BUFFER nlBuf, OvsFlowKey *flowKey,
81                            UINT16 keyType, UINT16 tunKeyType);
82 NTSTATUS MapFlowTunKeyToNlKey(PNL_BUFFER nlBuf, OvsIPv4TunnelKey *tunKey,
83                               UINT16 tunKeyType);
84 VOID MapTunAttrToFlowPut(PNL_ATTR *keyAttrs, PNL_ATTR *tunAttrs,
85                          OvsFlowKey *destKey);
86 UINT32 OvsFlowKeyAttrSize(void);
87 UINT32 OvsTunKeyAttrSize(void);
88
89 /* Flags for tunneling */
90 #define OVS_TNL_F_DONT_FRAGMENT         (1 << 0)
91 #define OVS_TNL_F_CSUM                  (1 << 1)
92 #define OVS_TNL_F_KEY                   (1 << 2)
93
94 #endif /* __FLOW_H_ */