summaryrefslogtreecommitdiff
path: root/datapath-windows/ovsext/Driver.c
diff options
context:
space:
mode:
authorSamuel Ghinet <sghinet@cloudbasesolutions.com>2014-08-29 04:06:48 +0000
committerBen Pfaff <blp@nicira.com>2014-08-29 07:55:05 -0700
commitfa1324c92810c6b1e33b7e87caaaf2e6c4041040 (patch)
tree8e06f5d991d755215bb6839a997bc58721b2d754 /datapath-windows/ovsext/Driver.c
parentfd972eb87a888242fb1a8ec2394fa7b3030fbd7d (diff)
downloadopenvswitch-fa1324c92810c6b1e33b7e87caaaf2e6c4041040.tar.gz
datapath-windows: Rename files.
This patch includes the file renaming and accommodations needed for the file renaming to build the forwarding extension for Hyper-V. This patch is also a follow-up for the thread: http://openvswitch.org/pipermail/dev/2014-August/044005.html Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com> Co-authored-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'datapath-windows/ovsext/Driver.c')
-rw-r--r--datapath-windows/ovsext/Driver.c184
1 files changed, 184 insertions, 0 deletions
diff --git a/datapath-windows/ovsext/Driver.c b/datapath-windows/ovsext/Driver.c
new file mode 100644
index 000000000..79d2edf4e
--- /dev/null
+++ b/datapath-windows/ovsext/Driver.c
@@ -0,0 +1,184 @@
+/*
+ * 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.
+ */
+
+#include "precomp.h"
+#include "Switch.h"
+#include "Datapath.h"
+
+#ifdef OVS_DBG_MOD
+#undef OVS_DBG_MOD
+#endif
+#define OVS_DBG_MOD OVS_DBG_DRIVER
+#include "Debug.h"
+
+/* Global handles. XXX: Some of them need not be global. */
+/*
+ * Maps to DriverObject and FilterDriverContext parameters in the NDIS filter
+ * driver functions.
+ * DriverObject is specified by NDIS.
+ * FilterDriverContext is specified by the filter driver.
+ */
+NDIS_HANDLE gOvsExtDriverObject;
+
+/*
+ * Maps to NdisFilterHandle parameter in the NDIS filter driver functions.
+ * NdisFilterHandle is returned by NDISFRegisterFilterDriver.
+ */
+NDIS_HANDLE gOvsExtDriverHandle;
+
+/*
+ * Maps to FilterModuleContext parameter in the NDIS filter driver functions.
+ * FilterModuleContext is a allocated by the driver in the FilterAttach
+ * function.
+ */
+extern POVS_SWITCH_CONTEXT gOvsSwitchContext;
+
+static PWCHAR ovsExtFriendlyName = L"Open vSwitch Extension";
+static PWCHAR ovsExtServiceName = L"OVSExt";
+NDIS_STRING ovsExtGuidUC;
+NDIS_STRING ovsExtFriendlyNameUC;
+
+static PWCHAR ovsExtGuidStr = L"{583CC151-73EC-4A6A-8B47-578297AD7623}";
+static const GUID ovsExtGuid = {
+ 0x583cc151,
+ 0x73ec,
+ 0x4a6a,
+ {0x8b, 0x47, 0x57, 0x82, 0x97, 0xad, 0x76, 0x23}
+};
+
+/* Declarations of callback functions for the filter driver. */
+DRIVER_UNLOAD OvsExtUnload;
+FILTER_NET_PNP_EVENT OvsExtNetPnPEvent;
+FILTER_STATUS OvsExtStatus;
+
+FILTER_ATTACH OvsExtAttach;
+FILTER_DETACH OvsExtDetach;
+FILTER_RESTART OvsExtRestart;
+FILTER_PAUSE OvsExtPause;
+
+FILTER_SEND_NET_BUFFER_LISTS OvsExtSendNBL;
+FILTER_SEND_NET_BUFFER_LISTS_COMPLETE OvsExtSendNBLComplete;
+FILTER_CANCEL_SEND_NET_BUFFER_LISTS OvsExtCancelSendNBL;
+FILTER_RECEIVE_NET_BUFFER_LISTS OvsExtReceiveNBL;
+FILTER_RETURN_NET_BUFFER_LISTS OvsExtReturnNBL;
+
+FILTER_OID_REQUEST OvsExtOidRequest;
+FILTER_OID_REQUEST_COMPLETE OvsExtOidRequestComplete;
+FILTER_CANCEL_OID_REQUEST OvsExtCancelOidRequest;
+
+
+/*
+ * --------------------------------------------------------------------------
+ * Init/Load function for the OVSEXT filter Driver.
+ * --------------------------------------------------------------------------
+ */
+NTSTATUS
+DriverEntry(PDRIVER_OBJECT driverObject,
+ PUNICODE_STRING registryPath)
+{
+ NDIS_STATUS status;
+ NDIS_FILTER_DRIVER_CHARACTERISTICS driverChars;
+
+ UNREFERENCED_PARAMETER(registryPath);
+
+ gOvsExtDriverObject = driverObject;
+
+ RtlZeroMemory(&driverChars, sizeof driverChars);
+ driverChars.Header.Type = NDIS_OBJECT_TYPE_FILTER_DRIVER_CHARACTERISTICS;
+ driverChars.Header.Size = sizeof driverChars;
+ driverChars.Header.Revision = NDIS_FILTER_CHARACTERISTICS_REVISION_2;
+ driverChars.MajorNdisVersion = NDIS_FILTER_MAJOR_VERSION;
+ driverChars.MinorNdisVersion = NDIS_FILTER_MINOR_VERSION;
+ driverChars.MajorDriverVersion = 1;
+ driverChars.MinorDriverVersion = 0;
+ driverChars.Flags = 0;
+
+ RtlInitUnicodeString(&driverChars.ServiceName, ovsExtServiceName);
+ RtlInitUnicodeString(&ovsExtFriendlyNameUC, ovsExtFriendlyName);
+ RtlInitUnicodeString(&ovsExtGuidUC, ovsExtGuidStr);
+
+ driverChars.FriendlyName = ovsExtFriendlyNameUC;
+ driverChars.UniqueName = ovsExtGuidUC;
+
+ driverChars.AttachHandler = OvsExtAttach;
+ driverChars.DetachHandler = OvsExtDetach;
+ driverChars.RestartHandler = OvsExtRestart;
+ driverChars.PauseHandler = OvsExtPause;
+
+ driverChars.SendNetBufferListsHandler = OvsExtSendNBL;
+ driverChars.SendNetBufferListsCompleteHandler = OvsExtSendNBLComplete;
+ driverChars.CancelSendNetBufferListsHandler = OvsExtCancelSendNBL;
+ driverChars.ReceiveNetBufferListsHandler = NULL;
+ driverChars.ReturnNetBufferListsHandler = NULL;
+
+ driverChars.OidRequestHandler = OvsExtOidRequest;
+ driverChars.OidRequestCompleteHandler = OvsExtOidRequestComplete;
+ driverChars.CancelOidRequestHandler = OvsExtCancelOidRequest;
+
+ driverChars.DevicePnPEventNotifyHandler = NULL;
+ driverChars.NetPnPEventHandler = OvsExtNetPnPEvent;
+ driverChars.StatusHandler = NULL;
+
+ driverObject->DriverUnload = OvsExtUnload;
+
+ status = NdisFRegisterFilterDriver(driverObject,
+ (NDIS_HANDLE) gOvsExtDriverObject,
+ &driverChars, &gOvsExtDriverHandle);
+ if (status != NDIS_STATUS_SUCCESS) {
+ return status;
+ }
+
+ /* Create the communication channel for usersapce. */
+ status = OvsCreateDeviceObject(gOvsExtDriverHandle);
+ if (status != NDIS_STATUS_SUCCESS) {
+ NdisFDeregisterFilterDriver(gOvsExtDriverHandle);
+ gOvsExtDriverHandle = NULL;
+ }
+
+ return status;
+}
+
+
+/*
+ * --------------------------------------------------------------------------
+ * Un-init/Unload function for the OVS intermediate Driver.
+ * --------------------------------------------------------------------------
+ */
+VOID
+OvsExtUnload(struct _DRIVER_OBJECT *driverObject)
+{
+ UNREFERENCED_PARAMETER(driverObject);
+
+ OvsDeleteDeviceObject();
+ NdisFDeregisterFilterDriver(gOvsExtDriverHandle);
+}
+
+
+/*
+ * --------------------------------------------------------------------------
+ * Implements filter driver's FilterStatus function.
+ * --------------------------------------------------------------------------
+ */
+VOID
+OvsExtStatus(NDIS_HANDLE filterModuleContext,
+ PNDIS_STATUS_INDICATION statusIndication)
+{
+ UNREFERENCED_PARAMETER(statusIndication);
+ POVS_SWITCH_CONTEXT switchObject = (POVS_SWITCH_CONTEXT)filterModuleContext;
+
+ NdisFIndicateStatus(switchObject->NdisFilterHandle, statusIndication);
+ return;
+}