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