From 3ed424e5e5d614e08a58ffe700bbe88ed0514a7b Mon Sep 17 00:00:00 2001 From: Sorin Vinturis Date: Thu, 23 Apr 2015 20:27:53 +0000 Subject: datapath-windows: Removed gOvsCtrlLock global spinlock There is no need to use gOvsCtrlLock spinlock to guard the switch context, as there is now the switch context's reference count used for this purpose. Now the gOvsCtrlLock spinlock guards only one shared resource, the OVS_OPEN_INSTANCE global instance array. Signed-off-by: Sorin Vinturis Acked-by: Nithin Raju Signed-off-by: Gurucharan Shetty --- datapath-windows/ovsext/Switch.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'datapath-windows/ovsext/Switch.c') diff --git a/datapath-windows/ovsext/Switch.c b/datapath-windows/ovsext/Switch.c index 9e1e9a4c0..4f784b8a2 100644 --- a/datapath-windows/ovsext/Switch.c +++ b/datapath-windows/ovsext/Switch.c @@ -35,10 +35,9 @@ #include "Debug.h" POVS_SWITCH_CONTEXT gOvsSwitchContext; -BOOLEAN gOvsInAttach; +LONG volatile gOvsInAttach; UINT64 ovsTimeIncrementPerTick; -extern PNDIS_SPIN_LOCK gOvsCtrlLock; extern NDIS_HANDLE gOvsExtDriverHandle; extern NDIS_HANDLE gOvsExtDriverObject; @@ -89,22 +88,18 @@ OvsExtAttach(NDIS_HANDLE ndisFilterHandle, goto cleanup; } - NdisAcquireSpinLock(gOvsCtrlLock); if (gOvsSwitchContext) { - NdisReleaseSpinLock(gOvsCtrlLock); OVS_LOG_TRACE("Exit: Failed to create OVS Switch, only one datapath is" "supported, %p.", gOvsSwitchContext); goto cleanup; } - if (gOvsInAttach) { - NdisReleaseSpinLock(gOvsCtrlLock); + + if (InterlockedCompareExchange(&gOvsInAttach, 1, 0)) { /* Just fail the request. */ OVS_LOG_TRACE("Exit: Failed to create OVS Switch, since another attach" "instance is in attach process."); goto cleanup; } - gOvsInAttach = TRUE; - NdisReleaseSpinLock(gOvsCtrlLock); status = OvsInitIpHelper(ndisFilterHandle); if (status != STATUS_SUCCESS) { @@ -121,7 +116,7 @@ OvsExtAttach(NDIS_HANDLE ndisFilterHandle, /* * Register the switch context with NDIS so NDIS can pass it back to the - * Filterxxx callback functions as the 'FilterModuleContext' parameter. + * FilterXXX callback functions as the 'FilterModuleContext' parameter. */ RtlZeroMemory(&ovsExtAttributes, sizeof(NDIS_FILTER_ATTRIBUTES)); ovsExtAttributes.Header.Revision = NDIS_FILTER_ATTRIBUTES_REVISION_1; -- cgit v1.2.1