tunneling: Remove gre64 tunnel support.
[cascardo/ovs.git] / datapath-windows / ovsext / Datapath.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 /*
18  * XXX: OVS_USE_NL_INTERFACE is being used to keep the legacy DPIF interface
19  * alive while we transition over to the netlink based interface.
20  * OVS_USE_NL_INTERFACE = 0 => legacy inteface to use with dpif-windows.c
21  * OVS_USE_NL_INTERFACE = 1 => netlink inteface to use with ported dpif-linux.c
22  */
23
24 #ifndef __DATAPATH_H_
25 #define __DATAPATH_H_ 1
26
27 /*
28  * Device operations to tag netlink commands with. This is a bitmask since it
29  * is possible that a particular command can be invoked via different device
30  * operations.
31  */
32 #define OVS_READ_DEV_OP          (1 << 0)
33 #define OVS_WRITE_DEV_OP         (1 << 1)
34 #define OVS_TRANSACTION_DEV_OP   (1 << 2)
35
36 typedef struct _OVS_DEVICE_EXTENSION {
37     INT numberOpenInstance;
38     INT pidCount;
39 } OVS_DEVICE_EXTENSION, *POVS_DEVICE_EXTENSION;
40
41 // forward declaration
42 typedef struct _OVS_USER_PACKET_QUEUE OVS_USER_PACKET_QUEUE,
43                                       *POVS_USER_PACKET_QUEUE;
44
45 /*
46  * Private context for each handle on the device.
47  */
48 typedef struct _OVS_OPEN_INSTANCE {
49     UINT32 cookie;
50     PFILE_OBJECT fileObject;
51     PVOID eventQueue;
52     POVS_USER_PACKET_QUEUE packetQueue;
53     UINT32 pid;
54
55     struct {
56         POVS_MESSAGE ovsMsg;    /* OVS message passed during dump start. */
57         UINT32 index[2];        /* markers to continue dump from. One or more
58                                  * of them may be used. Eg. in flow dump, the
59                                  * markers can store the row and the column
60                                  * indices. */
61     } dumpState;                /* data to support dump commands. */
62     LIST_ENTRY             pidLink; /* Links the instance to
63                                      * pidHashArray */
64 } OVS_OPEN_INSTANCE, *POVS_OPEN_INSTANCE;
65
66 NDIS_STATUS OvsCreateDeviceObject(NDIS_HANDLE ovsExtDriverHandle);
67 VOID OvsDeleteDeviceObject();
68 VOID OvsInit();
69 VOID OvsCleanup();
70
71 POVS_OPEN_INSTANCE OvsGetOpenInstance(PFILE_OBJECT fileObject,
72                                       UINT32 dpNo);
73
74 NTSTATUS OvsCompleteIrpRequest(PIRP irp, ULONG_PTR infoPtr, NTSTATUS status);
75
76 VOID OvsAcquireCtrlLock();
77 VOID OvsReleaseCtrlLock();
78
79 /*
80  * Utility structure and functions to collect in one place all the parameters
81  * passed during a call from userspace.
82  */
83 typedef struct _OVS_USER_PARAMS_CONTEXT {
84     PIRP irp;            /* The IRP used for the userspace call. */
85     POVS_OPEN_INSTANCE ovsInstance; /* Private data of the device handle. */
86     UINT32 devOp;        /* Device operation of the userspace call. */
87     POVS_MESSAGE ovsMsg; /* OVS message that userspace passed down. */
88     PVOID inputBuffer;   /* Input data specified by userspace. Maybe NULL. */
89     UINT32 inputLength;  /* Length of input buffer. */
90     PVOID outputBuffer;  /* Output buffer specified by userspace for reading
91                           * data. Maybe NULL. */
92     UINT32 outputLength; /* Length of output buffer. */
93 } OVS_USER_PARAMS_CONTEXT, *POVS_USER_PARAMS_CONTEXT;
94
95 static __inline VOID
96 InitUserParamsCtx(PIRP irp,
97                   POVS_OPEN_INSTANCE ovsInstance,
98                   UINT32 devOp,
99                   POVS_MESSAGE ovsMsg,
100                   PVOID inputBuffer,
101                   UINT32 inputLength,
102                   PVOID outputBuffer,
103                   UINT32 outputLength,
104                   POVS_USER_PARAMS_CONTEXT usrParamsCtx)
105 {
106     usrParamsCtx->irp = irp;
107     usrParamsCtx->ovsInstance = ovsInstance;
108     usrParamsCtx->devOp = devOp;
109     usrParamsCtx->ovsMsg = ovsMsg;
110     usrParamsCtx->inputBuffer = inputBuffer;
111     usrParamsCtx->inputLength = inputLength;
112     usrParamsCtx->outputBuffer = outputBuffer;
113     usrParamsCtx->outputLength = outputLength;
114 }
115
116 NTSTATUS InitUserDumpState(POVS_OPEN_INSTANCE instance,
117                            POVS_MESSAGE ovsMsg);
118
119 VOID FreeUserDumpState(POVS_OPEN_INSTANCE instance);
120
121 NTSTATUS OvsSetupDumpStart(POVS_USER_PARAMS_CONTEXT usrParamsCtx);
122
123 #endif /* __DATAPATH_H_ */