[ovs-dev] [PATCH 2/4 v4] datapath-windows: Add Datapath.[ch] and OVS_USE_NL_INTERFACE CPP

Nithin Raju nithin at vmware.com
Tue Aug 19 20:51:52 UTC 2014


In this change we create peer to OvsIoctl.[ch] that would interface
with userspace using the netlink interface. The new files are called
Datapath.[ch]. We are not deleting OvsIoctl.[ch] yet. Datapath.[ch]
provides bare minimum functionality to register a pseudo device for
communication with userspace.

We also define a CPP called OVS_USE_NL_INTERFACE in the ovsext project.
This defines if the old interface (pre-netlink based) or the new
interface (netlink- based) should be enabled in the kernel. By default,
the value is 0 since the Datapath.[ch] are minimal. In the next change,
we'll turn it to 1.

Since Datapath.[ch] containes code copied from OvsIoctl.[ch], acking
the original author as well.

Signed-off-by: Nithin Raju <nithin at vmware.com>
Co-authored-by: Guolin Yang <gyang at vmware.com>
Acked-by: Alin Serdean <aserdean at cloudbasesolutions.com>
Acked-by: Ankur Sharma <ankursharma at vmware.com>
Acked-by: Saurabh Shah <ssaurabh at vmware.com>
---
 datapath-windows/ovsext/Datapath.c                 |  407 ++++++++++++++++++++
 datapath-windows/ovsext/{OvsIoctl.h => Datapath.h} |   23 +-
 datapath-windows/ovsext/OvsActions.c               |    1 -
 datapath-windows/ovsext/OvsDebug.h                 |    2 +-
 datapath-windows/ovsext/OvsDriver.c                |    2 +-
 datapath-windows/ovsext/OvsEvent.c                 |    2 +-
 datapath-windows/ovsext/OvsFlow.c                  |    2 +-
 datapath-windows/ovsext/OvsIoctl.c                 |   12 +-
 datapath-windows/ovsext/OvsIoctl.h                 |   10 +
 datapath-windows/ovsext/OvsOid.c                   |    1 -
 datapath-windows/ovsext/OvsPacketIO.c              |    1 -
 datapath-windows/ovsext/OvsSwitch.c                |    3 +-
 datapath-windows/ovsext/OvsTunnel.c                |    1 -
 datapath-windows/ovsext/OvsUser.c                  |    2 +-
 datapath-windows/ovsext/OvsVport.c                 |    1 -
 datapath-windows/ovsext/OvsVxlan.c                 |    1 -
 datapath-windows/ovsext/ovsext.vcxproj             |    4 +-
 datapath-windows/ovsext/precomp.h                  |    3 +
 18 files changed, 461 insertions(+), 17 deletions(-)
 create mode 100644 datapath-windows/ovsext/Datapath.c
 copy datapath-windows/ovsext/{OvsIoctl.h => Datapath.h} (66%)

diff --git a/datapath-windows/ovsext/Datapath.c b/datapath-windows/ovsext/Datapath.c
new file mode 100644
index 0000000..3fa56eb
--- /dev/null
+++ b/datapath-windows/ovsext/Datapath.c
@@ -0,0 +1,407 @@
+/*
+ * Copyright (c) 2014 VMware, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * XXX: OVS_USE_NL_INTERFACE is being used to keep the legacy DPIF interface
+ * alive while we transition over to the netlink based interface.
+ * OVS_USE_NL_INTERFACE = 0 => legacy inteface to use with dpif-windows.c
+ * OVS_USE_NL_INTERFACE = 1 => netlink inteface to use with ported dpif-linux.c
+ */
+#if defined OVS_USE_NL_INTERFACE && OVS_USE_NL_INTERFACE == 1
+
+#include "precomp.h"
+#include "OvsDatapath.h"
+#include "OvsJhash.h"
+#include "OvsSwitch.h"
+#include "OvsVport.h"
+#include "OvsEvent.h"
+#include "OvsUser.h"
+#include "OvsPacketIO.h"
+#include "OvsNetProto.h"
+#include "OvsFlow.h"
+#include "OvsUser.h"
+
+#ifdef OVS_DBG_MOD
+#undef OVS_DBG_MOD
+#endif
+#define OVS_DBG_MOD OVS_DBG_DATAPATH
+#include "OvsDebug.h"
+
+#define NETLINK_FAMILY_NAME_LEN 48
+
+/* Handles to the device object for communication with userspace. */
+NDIS_HANDLE gOvsDeviceHandle;
+PDEVICE_OBJECT gOvsDeviceObject;
+
+_Dispatch_type_(IRP_MJ_CREATE)
+_Dispatch_type_(IRP_MJ_CLOSE)
+DRIVER_DISPATCH OvsOpenCloseDevice;
+
+_Dispatch_type_(IRP_MJ_CLEANUP)
+DRIVER_DISPATCH OvsCleanupDevice;
+
+_Dispatch_type_(IRP_MJ_DEVICE_CONTROL)
+DRIVER_DISPATCH OvsDeviceControl;
+
+#ifdef ALLOC_PRAGMA
+#pragma alloc_text(INIT, OvsCreateDeviceObject)
+#pragma alloc_text(PAGE, OvsOpenCloseDevice)
+#pragma alloc_text(PAGE, OvsCleanupDevice)
+#pragma alloc_text(PAGE, OvsDeviceControl)
+#endif // ALLOC_PRAGMA
+
+#define OVS_MAX_OPEN_INSTANCES 128
+
+POVS_OPEN_INSTANCE ovsOpenInstanceArray[OVS_MAX_OPEN_INSTANCES];
+UINT32 ovsNumberOfOpenInstances;
+extern POVS_SWITCH_CONTEXT gOvsSwitchContext;
+
+NDIS_SPIN_LOCK ovsCtrlLockObj;
+PNDIS_SPIN_LOCK gOvsCtrlLock;
+
+
+VOID
+OvsInit()
+{
+    gOvsCtrlLock = &ovsCtrlLockObj;
+    NdisAllocateSpinLock(gOvsCtrlLock);
+    OvsInitEventQueue();
+    OvsUserInit();
+}
+
+VOID
+OvsCleanup()
+{
+    OvsCleanupEventQueue();
+    if (gOvsCtrlLock) {
+        NdisFreeSpinLock(gOvsCtrlLock);
+        gOvsCtrlLock = NULL;
+    }
+    OvsUserCleanup();
+}
+
+VOID
+OvsAcquireCtrlLock()
+{
+    NdisAcquireSpinLock(gOvsCtrlLock);
+}
+
+VOID
+OvsReleaseCtrlLock()
+{
+    NdisReleaseSpinLock(gOvsCtrlLock);
+}
+
+
+/*
+ * --------------------------------------------------------------------------
+ * Creates the communication device between user and kernel, and also
+ * initializes the data associated data structures.
+ * --------------------------------------------------------------------------
+ */
+NDIS_STATUS
+OvsCreateDeviceObject(NDIS_HANDLE ovsExtDriverHandle)
+{
+    NDIS_STATUS status = NDIS_STATUS_SUCCESS;
+    UNICODE_STRING deviceName;
+    UNICODE_STRING symbolicDeviceName;
+    PDRIVER_DISPATCH dispatchTable[IRP_MJ_MAXIMUM_FUNCTION+1];
+    NDIS_DEVICE_OBJECT_ATTRIBUTES deviceAttributes;
+    OVS_LOG_TRACE("ovsExtDriverHandle: %p", ovsExtDriverHandle);
+
+    RtlZeroMemory(dispatchTable,
+                  (IRP_MJ_MAXIMUM_FUNCTION + 1) * sizeof (PDRIVER_DISPATCH));
+    dispatchTable[IRP_MJ_CREATE] = OvsOpenCloseDevice;
+    dispatchTable[IRP_MJ_CLOSE] = OvsOpenCloseDevice;
+    dispatchTable[IRP_MJ_CLEANUP] = OvsCleanupDevice;
+    dispatchTable[IRP_MJ_DEVICE_CONTROL] = OvsDeviceControl;
+
+    NdisInitUnicodeString(&deviceName, OVS_DEVICE_NAME_NT);
+    NdisInitUnicodeString(&symbolicDeviceName, OVS_DEVICE_NAME_DOS);
+
+    RtlZeroMemory(&deviceAttributes, sizeof (NDIS_DEVICE_OBJECT_ATTRIBUTES));
+
+    OVS_INIT_OBJECT_HEADER(&deviceAttributes.Header,
+                           NDIS_OBJECT_TYPE_DEVICE_OBJECT_ATTRIBUTES,
+                           NDIS_DEVICE_OBJECT_ATTRIBUTES_REVISION_1,
+                           sizeof (NDIS_DEVICE_OBJECT_ATTRIBUTES));
+
+    deviceAttributes.DeviceName = &deviceName;
+    deviceAttributes.SymbolicName = &symbolicDeviceName;
+    deviceAttributes.MajorFunctions = dispatchTable;
+    deviceAttributes.ExtensionSize = sizeof (OVS_DEVICE_EXTENSION);
+
+    status = NdisRegisterDeviceEx(ovsExtDriverHandle,
+                                  &deviceAttributes,
+                                  &gOvsDeviceObject,
+                                  &gOvsDeviceHandle);
+    if (status != NDIS_STATUS_SUCCESS) {
+        POVS_DEVICE_EXTENSION ovsExt =
+            (POVS_DEVICE_EXTENSION)NdisGetDeviceReservedExtension(gOvsDeviceObject);
+        ASSERT(gOvsDeviceObject != NULL);
+        ASSERT(gOvsDeviceHandle != NULL);
+
+        if (ovsExt) {
+            ovsExt->numberOpenInstance = 0;
+        }
+    } else {
+        /* Initialize the associated data structures. */
+        OvsInit();
+    }
+    OVS_LOG_TRACE("DeviceObject: %p", gOvsDeviceObject);
+    return status;
+}
+
+
+VOID
+OvsDeleteDeviceObject()
+{
+    if (gOvsDeviceHandle) {
+#ifdef DBG
+        POVS_DEVICE_EXTENSION ovsExt = (POVS_DEVICE_EXTENSION)
+                    NdisGetDeviceReservedExtension(gOvsDeviceObject);
+        if (ovsExt) {
+            ASSERT(ovsExt->numberOpenInstance == 0);
+        }
+#endif
+
+        ASSERT(gOvsDeviceObject);
+        NdisDeregisterDeviceEx(gOvsDeviceHandle);
+        gOvsDeviceHandle = NULL;
+        gOvsDeviceObject = NULL;
+    }
+    OvsCleanup();
+}
+
+POVS_OPEN_INSTANCE
+OvsGetOpenInstance(PFILE_OBJECT fileObject,
+                   UINT32 dpNo)
+{
+    POVS_OPEN_INSTANCE instance = (POVS_OPEN_INSTANCE)fileObject->FsContext;
+    ASSERT(instance);
+    ASSERT(instance->fileObject == fileObject);
+    if (gOvsSwitchContext == NULL ||
+        gOvsSwitchContext->dpNo != dpNo) {
+        return NULL;
+    }
+    return instance;
+}
+
+
+POVS_OPEN_INSTANCE
+OvsFindOpenInstance(PFILE_OBJECT fileObject)
+{
+    UINT32 i, j;
+    for (i = 0, j = 0; i < OVS_MAX_OPEN_INSTANCES &&
+                       j < ovsNumberOfOpenInstances; i++) {
+        if (ovsOpenInstanceArray[i]) {
+            if (ovsOpenInstanceArray[i]->fileObject == fileObject) {
+                return ovsOpenInstanceArray[i];
+            }
+            j++;
+        }
+    }
+    return NULL;
+}
+
+NTSTATUS
+OvsAddOpenInstance(PFILE_OBJECT fileObject)
+{
+    POVS_OPEN_INSTANCE instance =
+        (POVS_OPEN_INSTANCE) OvsAllocateMemory(sizeof (OVS_OPEN_INSTANCE));
+    UINT32 i;
+
+    if (instance == NULL) {
+        return STATUS_NO_MEMORY;
+    }
+    OvsAcquireCtrlLock();
+    ASSERT(OvsFindOpenInstance(fileObject) == NULL);
+
+    if (ovsNumberOfOpenInstances >= OVS_MAX_OPEN_INSTANCES) {
+        OvsReleaseCtrlLock();
+        OvsFreeMemory(instance);
+        return STATUS_INSUFFICIENT_RESOURCES;
+    }
+    RtlZeroMemory(instance, sizeof (OVS_OPEN_INSTANCE));
+
+    for (i = 0; i < OVS_MAX_OPEN_INSTANCES; i++) {
+        if (ovsOpenInstanceArray[i] == NULL) {
+            ovsOpenInstanceArray[i] = instance;
+            instance->cookie = i;
+            break;
+        }
+    }
+    ASSERT(i < OVS_MAX_OPEN_INSTANCES);
+    instance->fileObject = fileObject;
+    ASSERT(fileObject->FsContext == NULL);
+    fileObject->FsContext = instance;
+    OvsReleaseCtrlLock();
+    return STATUS_SUCCESS;
+}
+
+static VOID
+OvsCleanupOpenInstance(PFILE_OBJECT fileObject)
+{
+    POVS_OPEN_INSTANCE instance = (POVS_OPEN_INSTANCE)fileObject->FsContext;
+    ASSERT(instance);
+    ASSERT(fileObject == instance->fileObject);
+    OvsCleanupEvent(instance);
+    OvsCleanupPacketQueue(instance);
+}
+
+VOID
+OvsRemoveOpenInstance(PFILE_OBJECT fileObject)
+{
+    POVS_OPEN_INSTANCE instance;
+    ASSERT(fileObject->FsContext);
+    instance = (POVS_OPEN_INSTANCE)fileObject->FsContext;
+    ASSERT(instance->cookie < OVS_MAX_OPEN_INSTANCES);
+
+    OvsAcquireCtrlLock();
+    fileObject->FsContext = NULL;
+    ASSERT(ovsOpenInstanceArray[instance->cookie] == instance);
+    ovsOpenInstanceArray[instance->cookie] = NULL;
+    OvsReleaseCtrlLock();
+    ASSERT(instance->eventQueue == NULL);
+    ASSERT (instance->packetQueue == NULL);
+    OvsFreeMemory(instance);
+}
+
+NTSTATUS
+OvsCompleteIrpRequest(PIRP irp,
+                      ULONG_PTR infoPtr,
+                      NTSTATUS status)
+{
+    irp->IoStatus.Information = infoPtr;
+    irp->IoStatus.Status = status;
+    IoCompleteRequest(irp, IO_NO_INCREMENT);
+    return status;
+}
+
+
+NTSTATUS
+OvsOpenCloseDevice(PDEVICE_OBJECT deviceObject,
+                   PIRP irp)
+{
+    PIO_STACK_LOCATION irpSp;
+    NTSTATUS status = STATUS_SUCCESS;
+    PFILE_OBJECT fileObject;
+    POVS_DEVICE_EXTENSION ovsExt =
+        (POVS_DEVICE_EXTENSION)NdisGetDeviceReservedExtension(deviceObject);
+
+    ASSERT(deviceObject == gOvsDeviceObject);
+    ASSERT(ovsExt != NULL);
+
+    irpSp = IoGetCurrentIrpStackLocation(irp);
+    fileObject = irpSp->FileObject;
+    OVS_LOG_TRACE("DeviceObject: %p, fileObject:%p, instance: %u",
+                  deviceObject, fileObject,
+                  ovsExt->numberOpenInstance);
+
+    switch (irpSp->MajorFunction) {
+    case IRP_MJ_CREATE:
+        status = OvsAddOpenInstance(fileObject);
+        if (STATUS_SUCCESS == status) {
+            InterlockedIncrement((LONG volatile *)&ovsExt->numberOpenInstance);
+        }
+        break;
+    case IRP_MJ_CLOSE:
+        ASSERT(ovsExt->numberOpenInstance > 0);
+        OvsRemoveOpenInstance(fileObject);
+        InterlockedDecrement((LONG volatile *)&ovsExt->numberOpenInstance);
+        break;
+    default:
+        ASSERT(0);
+    }
+    return OvsCompleteIrpRequest(irp, (ULONG_PTR)0, status);
+}
+
+_Use_decl_annotations_
+NTSTATUS
+OvsCleanupDevice(PDEVICE_OBJECT deviceObject,
+                 PIRP irp)
+{
+
+    PIO_STACK_LOCATION irpSp;
+    PFILE_OBJECT fileObject;
+
+    NTSTATUS status = STATUS_SUCCESS;
+#ifdef DBG
+    POVS_DEVICE_EXTENSION ovsExt =
+        (POVS_DEVICE_EXTENSION)NdisGetDeviceReservedExtension(deviceObject);
+    if (ovsExt) {
+        ASSERT(ovsExt->numberOpenInstance > 0);
+    }
+#else
+    UNREFERENCED_PARAMETER(deviceObject);
+#endif
+    ASSERT(deviceObject == gOvsDeviceObject);
+    irpSp = IoGetCurrentIrpStackLocation(irp);
+    fileObject = irpSp->FileObject;
+
+    ASSERT(irpSp->MajorFunction == IRP_MJ_CLEANUP);
+
+    OvsCleanupOpenInstance(fileObject);
+
+    return OvsCompleteIrpRequest(irp, (ULONG_PTR)0, status);
+}
+
+
+/*
+ * --------------------------------------------------------------------------
+ * IOCTL function handler for the device.
+ * --------------------------------------------------------------------------
+ */
+NTSTATUS
+OvsDeviceControl(PDEVICE_OBJECT deviceObject,
+                 PIRP irp)
+{
+
+    PIO_STACK_LOCATION irpSp;
+    NTSTATUS status = STATUS_SUCCESS;
+    PFILE_OBJECT fileObject;
+    PVOID inputBuffer;
+    PVOID outputBuffer;
+    UINT32 inputBufferLen, outputBufferLen;
+    UINT32 code, replyLen = 0;
+    POVS_OPEN_INSTANCE instance;
+
+#ifdef DBG
+    POVS_DEVICE_EXTENSION ovsExt =
+        (POVS_DEVICE_EXTENSION)NdisGetDeviceReservedExtension(deviceObject);
+    ASSERT(deviceObject == gOvsDeviceObject);
+    ASSERT(ovsExt);
+    ASSERT(ovsExt->numberOpenInstance > 0);
+#else
+    UNREFERENCED_PARAMETER(deviceObject);
+#endif
+
+    irpSp = IoGetCurrentIrpStackLocation(irp);
+
+    ASSERT(irpSp->MajorFunction == IRP_MJ_DEVICE_CONTROL);
+    ASSERT(irpSp->FileObject != NULL);
+
+    fileObject = irpSp->FileObject;
+    instance = (POVS_OPEN_INSTANCE)fileObject->FsContext;
+    code = irpSp->Parameters.DeviceIoControl.IoControlCode;
+    inputBufferLen = irpSp->Parameters.DeviceIoControl.InputBufferLength;
+    outputBufferLen = irpSp->Parameters.DeviceIoControl.OutputBufferLength;
+    outputBuffer = inputBuffer = irp->AssociatedIrp.SystemBuffer;
+
+    return OvsCompleteIrpRequest(irp, (ULONG_PTR)replyLen, status);
+}
+
+#endif /* OVS_USE_NL_INTERFACE */
diff --git a/datapath-windows/ovsext/OvsIoctl.h b/datapath-windows/ovsext/Datapath.h
similarity index 66%
copy from datapath-windows/ovsext/OvsIoctl.h
copy to datapath-windows/ovsext/Datapath.h
index 9f2bf85..b68010b 100644
--- a/datapath-windows/ovsext/OvsIoctl.h
+++ b/datapath-windows/ovsext/Datapath.h
@@ -14,14 +14,29 @@
  * limitations under the License.
  */
 
-#ifndef __OVS_IOCTL_H_
-#define __OVS_IOCTL_H_ 1
+/*
+ * XXX: OVS_USE_NL_INTERFACE is being used to keep the legacy DPIF interface
+ * alive while we transition over to the netlink based interface.
+ * OVS_USE_NL_INTERFACE = 0 => legacy inteface to use with dpif-windows.c
+ * OVS_USE_NL_INTERFACE = 1 => netlink inteface to use with ported dpif-linux.c
+ */
+#if defined OVS_USE_NL_INTERFACE && OVS_USE_NL_INTERFACE == 0
+#include "OvsIoctl.h"
+
+#else
+
+#ifndef __OVS_DATAPATH_H_
+#define __OVS_DATAPATH_H_ 1
 
 typedef struct _OVS_DEVICE_EXTENSION {
     INT numberOpenInstance;
+    INT pidCount;
 } OVS_DEVICE_EXTENSION, *POVS_DEVICE_EXTENSION;
 
 
+/*
+ * Private context for each handle on the device.
+ */
 typedef struct _OVS_OPEN_INSTANCE {
     UINT32 cookie;
     PFILE_OBJECT fileObject;
@@ -37,4 +52,6 @@ POVS_OPEN_INSTANCE OvsGetOpenInstance(PFILE_OBJECT fileObject,
 
 NTSTATUS OvsCompleteIrpRequest(PIRP irp, ULONG_PTR infoPtr, NTSTATUS status);
 
-#endif /* __OVS_IOCTL_H_ */
+#endif /* __OVS_DATAPATH_H_ */
+
+#endif /* OVS_USE_NL_INTERFACE */
diff --git a/datapath-windows/ovsext/OvsActions.c b/datapath-windows/ovsext/OvsActions.c
index 635becc..d62f2a7 100644
--- a/datapath-windows/ovsext/OvsActions.c
+++ b/datapath-windows/ovsext/OvsActions.c
@@ -16,7 +16,6 @@
 
 #include "precomp.h"
 
-#include "OvsIoctl.h"
 #include "OvsSwitch.h"
 #include "OvsVport.h"
 #include "OvsEvent.h"
diff --git a/datapath-windows/ovsext/OvsDebug.h b/datapath-windows/ovsext/OvsDebug.h
index 3705d1e..6941f13 100644
--- a/datapath-windows/ovsext/OvsDebug.h
+++ b/datapath-windows/ovsext/OvsDebug.h
@@ -33,7 +33,7 @@
 #define OVS_DBG_GRE      BIT32(13)
 #define OVS_DBG_GRE64    BIT32(14)
 #define OVS_DBG_ACTION   BIT32(15)
-#define OVS_DBG_IOCTL    BIT32(16)
+#define OVS_DBG_DATAPATH BIT32(16)
 #define OVS_DBG_PROPERTY BIT32(17)
 #define OVS_DBG_IPHELPER BIT32(18)
 #define OVS_DBG_BUFMGMT  BIT32(19)
diff --git a/datapath-windows/ovsext/OvsDriver.c b/datapath-windows/ovsext/OvsDriver.c
index 7b57fbd..1163221 100644
--- a/datapath-windows/ovsext/OvsDriver.c
+++ b/datapath-windows/ovsext/OvsDriver.c
@@ -16,7 +16,7 @@
 
 #include "precomp.h"
 #include "OvsSwitch.h"
-#include "OvsIoctl.h"
+#include "Datapath.h"
 
 #ifdef OVS_DBG_MOD
 #undef OVS_DBG_MOD
diff --git a/datapath-windows/ovsext/OvsEvent.c b/datapath-windows/ovsext/OvsEvent.c
index a75b2bd..d324bc6 100644
--- a/datapath-windows/ovsext/OvsEvent.c
+++ b/datapath-windows/ovsext/OvsEvent.c
@@ -16,7 +16,7 @@
 
 #include "precomp.h"
 
-#include "OvsIoctl.h"
+#include "Datapath.h"
 #include "OvsSwitch.h"
 #include "OvsVport.h"
 #include "OvsEvent.h"
diff --git a/datapath-windows/ovsext/OvsFlow.c b/datapath-windows/ovsext/OvsFlow.c
index daa64e0..4e31f17 100644
--- a/datapath-windows/ovsext/OvsFlow.c
+++ b/datapath-windows/ovsext/OvsFlow.c
@@ -32,6 +32,7 @@
 
 extern PNDIS_SPIN_LOCK gOvsCtrlLock;
 extern POVS_SWITCH_CONTEXT gOvsSwitchContext;
+extern UINT64 ovsTimeIncrementPerTick;
 
 static NTSTATUS ReportFlowInfo(OvsFlow *flow, UINT32 getFlags,
                                UINT32 getActionsLen, OvsFlowInfo *info);
@@ -142,7 +143,6 @@ OvsFlowUsed(OvsFlow *flow,
 
     KeQueryTickCount(&tickCount);
     flow->used = tickCount.QuadPart * ovsTimeIncrementPerTick;
-    flow->used += ovsUserTimestampDelta;
     flow->packetCount++;
     flow->byteCount += OvsPacketLenNBL(packet);
     flow->tcpFlags |= OvsGetTcpFlags(packet, &flow->key, layers);
diff --git a/datapath-windows/ovsext/OvsIoctl.c b/datapath-windows/ovsext/OvsIoctl.c
index 893cbf7..ef4864d 100644
--- a/datapath-windows/ovsext/OvsIoctl.c
+++ b/datapath-windows/ovsext/OvsIoctl.c
@@ -14,6 +14,14 @@
  * limitations under the License.
  */
 
+/*
+ * XXX: OVS_USE_NL_INTERFACE is being used to keep the legacy DPIF interface
+ * alive while we transition over to the netlink based interface.
+ * OVS_USE_NL_INTERFACE = 0 => legacy inteface to use with dpif-windows.c
+ * OVS_USE_NL_INTERFACE = 1 => netlink inteface to use with ported dpif-linux.c
+ */
+#if defined OVS_USE_NL_INTERFACE && OVS_USE_NL_INTERFACE == 0
+
 #include "precomp.h"
 #include "OvsIoctl.h"
 #include "OvsJhash.h"
@@ -29,7 +37,7 @@
 #ifdef OVS_DBG_MOD
 #undef OVS_DBG_MOD
 #endif
-#define OVS_DBG_MOD OVS_DBG_IOCTL
+#define OVS_DBG_MOD OVS_DBG_DATAPATH
 #include "OvsDebug.h"
 
 /* Handles to the device object for communication with userspace. */
@@ -756,3 +764,5 @@ OvsDeviceControl(PDEVICE_OBJECT deviceObject,
         return OvsCompleteIrpRequest(irp, (ULONG_PTR)replyLen, status);
     }
 }
+
+#endif /* OVS_USE_NL_INTERFACE */
diff --git a/datapath-windows/ovsext/OvsIoctl.h b/datapath-windows/ovsext/OvsIoctl.h
index 9f2bf85..5487694 100644
--- a/datapath-windows/ovsext/OvsIoctl.h
+++ b/datapath-windows/ovsext/OvsIoctl.h
@@ -14,6 +14,14 @@
  * limitations under the License.
  */
 
+/*
+ * XXX: OVS_USE_NL_INTERFACE is being used to keep the legacy DPIF interface
+ * alive while we transition over to the netlink based interface.
+ * OVS_USE_NL_INTERFACE = 0 => legacy inteface to use with dpif-windows.c
+ * OVS_USE_NL_INTERFACE = 1 => netlink inteface to use with ported dpif-linux.c
+ */
+#if defined OVS_USE_NL_INTERFACE && OVS_USE_NL_INTERFACE == 0
+
 #ifndef __OVS_IOCTL_H_
 #define __OVS_IOCTL_H_ 1
 
@@ -38,3 +46,5 @@ POVS_OPEN_INSTANCE OvsGetOpenInstance(PFILE_OBJECT fileObject,
 NTSTATUS OvsCompleteIrpRequest(PIRP irp, ULONG_PTR infoPtr, NTSTATUS status);
 
 #endif /* __OVS_IOCTL_H_ */
+
+#endif /* OVS_USE_NL_INTERFACE */
diff --git a/datapath-windows/ovsext/OvsOid.c b/datapath-windows/ovsext/OvsOid.c
index 487191a..ad66be4 100644
--- a/datapath-windows/ovsext/OvsOid.c
+++ b/datapath-windows/ovsext/OvsOid.c
@@ -15,7 +15,6 @@
  */
 
 #include "precomp.h"
-#include "OvsIoctl.h"
 #include "OvsSwitch.h"
 #include "OvsVport.h"
 #include "OvsNetProto.h"
diff --git a/datapath-windows/ovsext/OvsPacketIO.c b/datapath-windows/ovsext/OvsPacketIO.c
index 39e5703..6017f30 100644
--- a/datapath-windows/ovsext/OvsPacketIO.c
+++ b/datapath-windows/ovsext/OvsPacketIO.c
@@ -20,7 +20,6 @@
  */
 
 #include "precomp.h"
-#include "OvsIoctl.h"
 #include "OvsSwitch.h"
 #include "OvsVport.h"
 #include "OvsNetProto.h"
diff --git a/datapath-windows/ovsext/OvsSwitch.c b/datapath-windows/ovsext/OvsSwitch.c
index 97ce2ae..f548599 100644
--- a/datapath-windows/ovsext/OvsSwitch.c
+++ b/datapath-windows/ovsext/OvsSwitch.c
@@ -21,7 +21,6 @@
 
 #include "precomp.h"
 
-#include "OvsIoctl.h"
 #include "OvsSwitch.h"
 #include "OvsVport.h"
 #include "OvsEvent.h"
@@ -38,6 +37,8 @@
 
 POVS_SWITCH_CONTEXT gOvsSwitchContext;
 BOOLEAN gOvsInAttach;
+UINT64 ovsTimeIncrementPerTick;
+
 extern PNDIS_SPIN_LOCK gOvsCtrlLock;
 extern NDIS_HANDLE gOvsExtDriverHandle;
 extern NDIS_HANDLE gOvsExtDriverObject;
diff --git a/datapath-windows/ovsext/OvsTunnel.c b/datapath-windows/ovsext/OvsTunnel.c
index b5a369a..d0288cc 100644
--- a/datapath-windows/ovsext/OvsTunnel.c
+++ b/datapath-windows/ovsext/OvsTunnel.c
@@ -31,7 +31,6 @@
 
 #include <fwpmk.h>
 #include "OvsTunnel.h"
-#include "OvsIoctl.h"
 #include "OvsSwitch.h"
 #include "OvsVport.h"
 #include "OvsEvent.h"
diff --git a/datapath-windows/ovsext/OvsUser.c b/datapath-windows/ovsext/OvsUser.c
index 5093f20..9fafb16 100644
--- a/datapath-windows/ovsext/OvsUser.c
+++ b/datapath-windows/ovsext/OvsUser.c
@@ -22,7 +22,7 @@
 
 #include "precomp.h"
 
-#include "OvsIoctl.h"
+#include "Datapath.h"
 #include "OvsSwitch.h"
 #include "OvsVport.h"
 #include "OvsEvent.h"
diff --git a/datapath-windows/ovsext/OvsVport.c b/datapath-windows/ovsext/OvsVport.c
index 35bdaea..0c00e52 100644
--- a/datapath-windows/ovsext/OvsVport.c
+++ b/datapath-windows/ovsext/OvsVport.c
@@ -15,7 +15,6 @@
  */
 
 #include "precomp.h"
-#include "OvsIoctl.h"
 #include "OvsJhash.h"
 #include "OvsSwitch.h"
 #include "OvsVport.h"
diff --git a/datapath-windows/ovsext/OvsVxlan.c b/datapath-windows/ovsext/OvsVxlan.c
index 63909ae..db1909e 100644
--- a/datapath-windows/ovsext/OvsVxlan.c
+++ b/datapath-windows/ovsext/OvsVxlan.c
@@ -16,7 +16,6 @@
 
 #include "precomp.h"
 #include "OvsNetProto.h"
-#include "OvsIoctl.h"
 #include "OvsSwitch.h"
 #include "OvsVport.h"
 #include "OvsFlow.h"
diff --git a/datapath-windows/ovsext/ovsext.vcxproj b/datapath-windows/ovsext/ovsext.vcxproj
index 4febef6..5ecc81a 100644
--- a/datapath-windows/ovsext/ovsext.vcxproj
+++ b/datapath-windows/ovsext/ovsext.vcxproj
@@ -74,6 +74,7 @@
     <ClInclude Include="OvsAtomic.h" />
     <ClInclude Include="OvsBufferMgmt.h" />
     <ClInclude Include="OvsChecksum.h" />
+    <ClInclude Include="Datapath.h" />
     <ClInclude Include="OvsDebug.h" />
     <ClInclude Include="OvsEth.h" />
     <ClInclude Include="OvsEvent.h" />
@@ -99,7 +100,7 @@
   </PropertyGroup>
   <ItemDefinitionGroup>
     <ClCompile>
-      <PreprocessorDefinitions>%(PreprocessorDefinitions);NDIS_WDM=1;NDIS630=1;OVS_WIN_DP=1</PreprocessorDefinitions>
+      <PreprocessorDefinitions>%(PreprocessorDefinitions);NDIS_WDM=1;NDIS630=1;OVS_WIN_DP=1;OVS_USE_NL_INTERFACE=0</PreprocessorDefinitions>
     </ClCompile>
     <Midl>
       <PreprocessorDefinitions>%(PreprocessorDefinitions);NDIS_WDM=1;NDIS630=1</PreprocessorDefinitions>
@@ -124,6 +125,7 @@
     </ClCompile>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClCompile Include="Datapath.c" />
     <ClCompile Include="OvsDriver.c" />
     <ClCompile Include="OvsJhash.c" />
     <ClCompile Include="OvsOid.c" />
diff --git a/datapath-windows/ovsext/precomp.h b/datapath-windows/ovsext/precomp.h
index ec4a621..5f23d02 100644
--- a/datapath-windows/ovsext/precomp.h
+++ b/datapath-windows/ovsext/precomp.h
@@ -29,3 +29,6 @@
  * include/linux is pending discussion.
  */
 #include "..\include\OvsDpInterface.h"
+#if defined OVS_USE_NL_INTERFACE && OVS_USE_NL_INTERFACE == 1
+#include "..\include\OvsDpInterfaceExt.h"
+#endif
-- 
1.7.4.1




More information about the dev mailing list