2 * Copyright (c) 2014 VMware, Inc.
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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
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
25 #define __DATAPATH_H_ 1
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
32 #define OVS_READ_DEV_OP (1 << 0)
33 #define OVS_WRITE_DEV_OP (1 << 1)
34 #define OVS_TRANSACTION_DEV_OP (1 << 2)
36 typedef struct _OVS_DEVICE_EXTENSION {
37 INT numberOpenInstance;
39 } OVS_DEVICE_EXTENSION, *POVS_DEVICE_EXTENSION;
41 // forward declaration
42 typedef struct _OVS_USER_PACKET_QUEUE OVS_USER_PACKET_QUEUE,
43 *POVS_USER_PACKET_QUEUE;
46 * Private context for each handle on the device.
48 typedef struct _OVS_OPEN_INSTANCE {
50 PFILE_OBJECT fileObject;
52 POVS_USER_PACKET_QUEUE packetQueue;
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
61 } dumpState; /* data to support dump commands. */
62 LIST_ENTRY pidLink; /* Links the instance to
64 } OVS_OPEN_INSTANCE, *POVS_OPEN_INSTANCE;
66 NDIS_STATUS OvsCreateDeviceObject(NDIS_HANDLE ovsExtDriverHandle);
67 VOID OvsDeleteDeviceObject();
71 POVS_OPEN_INSTANCE OvsGetOpenInstance(PFILE_OBJECT fileObject,
74 NTSTATUS OvsCompleteIrpRequest(PIRP irp, ULONG_PTR infoPtr, NTSTATUS status);
76 VOID OvsAcquireCtrlLock();
77 VOID OvsReleaseCtrlLock();
80 * Utility structure and functions to collect in one place all the parameters
81 * passed during a call from userspace.
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;
96 InitUserParamsCtx(PIRP irp,
97 POVS_OPEN_INSTANCE ovsInstance,
104 POVS_USER_PARAMS_CONTEXT usrParamsCtx)
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;
116 NTSTATUS InitUserDumpState(POVS_OPEN_INSTANCE instance,
117 POVS_MESSAGE ovsMsg);
119 VOID FreeUserDumpState(POVS_OPEN_INSTANCE instance);
121 NTSTATUS OvsSetupDumpStart(POVS_USER_PARAMS_CONTEXT usrParamsCtx);
123 #endif /* __DATAPATH_H_ */