summaryrefslogtreecommitdiff
path: root/datapath-windows/ovsext/User.c
diff options
context:
space:
mode:
authorAnkur Sharma <ankursharma@vmware.com>2014-10-23 14:24:26 -0700
committerBen Pfaff <blp@nicira.com>2014-10-24 08:46:54 -0700
commit65ae4384236a5aa47ea46a508c80fe7834201ebd (patch)
tree445484bd991e940d83afe04276f8dea22d04f23e /datapath-windows/ovsext/User.c
parent8abaa53cac82dad5e7f8dba9ef30d785b0a46140 (diff)
downloadopenvswitch-65ae4384236a5aa47ea46a508c80fe7834201ebd.tar.gz
datapath-windows: pid-instance hash table APIs.
In this patch we have added APIs for insert, delete and search APIs. Signed-off-by: Ankur Sharma <ankursharma@vmware.com> Acked-by: Nithin Raju <nithin@vmware.com> Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Diffstat (limited to 'datapath-windows/ovsext/User.c')
-rw-r--r--datapath-windows/ovsext/User.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/datapath-windows/ovsext/User.c b/datapath-windows/ovsext/User.c
index b2961601a..213d60607 100644
--- a/datapath-windows/ovsext/User.c
+++ b/datapath-windows/ovsext/User.c
@@ -32,6 +32,7 @@
#include "NetProto.h"
#include "Flow.h"
#include "TunnelIntf.h"
+#include "Jhash.h"
#ifdef OVS_DBG_MOD
#undef OVS_DBG_MOD
@@ -618,6 +619,62 @@ OvsGetQueue(UINT32 pid)
return NULL;
}
+/*
+ * ---------------------------------------------------------------------------
+ * Given a pid, returns the corresponding instance.
+ * gOvsCtrlLock must be acquired before calling this API.
+ * ---------------------------------------------------------------------------
+ */
+POVS_OPEN_INSTANCE
+OvsGetPidInstance(POVS_SWITCH_CONTEXT switchContext, UINT32 pid)
+{
+ POVS_OPEN_INSTANCE instance;
+ PLIST_ENTRY head, link;
+ UINT32 hash = OvsJhashBytes((const VOID *)&pid, sizeof(pid),
+ OVS_HASH_BASIS);
+ head = &(switchContext->pidHashArray[hash & OVS_PID_MASK]);
+ LIST_FORALL(head, link) {
+ instance = CONTAINING_RECORD(link, OVS_OPEN_INSTANCE, pidLink);
+ if (instance->pid == pid) {
+ return instance;
+ }
+ }
+ return NULL;
+}
+
+/*
+ * ---------------------------------------------------------------------------
+ * Given a pid and an instance. This API adds instance to pidHashArray.
+ * gOvsCtrlLock must be acquired before calling this API.
+ * ---------------------------------------------------------------------------
+ */
+VOID
+OvsAddPidInstance(POVS_SWITCH_CONTEXT switchContext, UINT32 pid,
+ POVS_OPEN_INSTANCE instance)
+{
+ PLIST_ENTRY head;
+ UINT32 hash = OvsJhashBytes((const VOID *)&pid, sizeof(pid),
+ OVS_HASH_BASIS);
+ head = &(switchContext->pidHashArray[hash & OVS_PID_MASK]);
+ InsertHeadList(head, &(instance->pidLink));
+}
+
+/*
+ * ---------------------------------------------------------------------------
+ * Given a pid and an instance. This API removes instance from pidHashArray.
+ * gOvsCtrlLock must be acquired before calling this API.
+ * ---------------------------------------------------------------------------
+ */
+VOID
+OvsDelPidInstance(POVS_SWITCH_CONTEXT switchContext, UINT32 pid)
+{
+ POVS_OPEN_INSTANCE instance = OvsGetPidInstance(switchContext, pid);
+
+ if (instance) {
+ RemoveEntryList(&(instance->pidLink));
+ }
+}
+
VOID
OvsQueuePackets(UINT32 queueId,
PLIST_ENTRY packetList,