bfbbd71f48a7cae15e5baf808af1b2d47c10857e
[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 #if defined OVS_USE_NL_INTERFACE && OVS_USE_NL_INTERFACE == 0
24 #include "Ioctl.h"
25
26 #else
27
28 #ifndef __DATAPATH_H_
29 #define __DATAPATH_H_ 1
30
31 typedef struct _OVS_DEVICE_EXTENSION {
32     INT numberOpenInstance;
33     INT pidCount;
34 } OVS_DEVICE_EXTENSION, *POVS_DEVICE_EXTENSION;
35
36
37 /*
38  * Private context for each handle on the device.
39  */
40 typedef struct _OVS_OPEN_INSTANCE {
41     UINT32 cookie;
42     PFILE_OBJECT fileObject;
43     PVOID eventQueue;
44     PVOID packetQueue;
45     UINT32 pid;
46
47     /*
48      * On platforms that support netlink natively, there's generally some form of
49      * serialization between concurrent calls to netlink sockets. However, OVS
50      * userspace guarantees that a given netlink handle is not concurrently used.
51      * Despite this, we do want to have some basic checks in the kernel to make
52      * sure that things don't break if there are concurrent calls.
53      *
54      * This is generally not an issue since kernel data structure access should
55      * be sychronized anyway. Only reason to have this safeguared is to protect
56      * the state in "state-aware" read calls which rely on previous state. This
57      * restriction might go away as the userspace code gets implemented.
58      */
59     INT inUse;
60 } OVS_OPEN_INSTANCE, *POVS_OPEN_INSTANCE;
61
62 NDIS_STATUS OvsCreateDeviceObject(NDIS_HANDLE ovsExtDriverHandle);
63 VOID OvsDeleteDeviceObject();
64
65 POVS_OPEN_INSTANCE OvsGetOpenInstance(PFILE_OBJECT fileObject,
66                                       UINT32 dpNo);
67
68 NTSTATUS OvsCompleteIrpRequest(PIRP irp, ULONG_PTR infoPtr, NTSTATUS status);
69
70 /*
71  * Structure of any message passed between userspace and kernel.
72  */
73 typedef struct _OVS_MESSAGE {
74     NL_MSG_HDR nlMsg;
75     GENL_MSG_HDR genlMsg;
76     struct ovs_header ovsHdr;
77     /* Variable length nl_attrs follow. */
78 } OVS_MESSAGE, *POVS_MESSAGE;
79
80 #endif /* __DATAPATH_H_ */
81
82 #endif /* OVS_USE_NL_INTERFACE */