Skip to content

Commit

Permalink
datapath-windows: pid-instance hash table APIs.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ankursh authored and blp committed Oct 24, 2014
1 parent 8abaa53 commit 65ae438
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
57 changes: 57 additions & 0 deletions datapath-windows/ovsext/User.c
Expand Up @@ -32,6 +32,7 @@
#include "NetProto.h"
#include "Flow.h"
#include "TunnelIntf.h"
#include "Jhash.h"

#ifdef OVS_DBG_MOD
#undef OVS_DBG_MOD
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions datapath-windows/ovsext/User.h
Expand Up @@ -108,4 +108,14 @@ NTSTATUS OvsWaitDpIoctl(PIRP irp, PFILE_OBJECT fileObject);
NTSTATUS OvsNlExecuteCmdHandler(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
UINT32 *replyLen);

POVS_OPEN_INSTANCE
OvsGetPidInstance(POVS_SWITCH_CONTEXT switchContext, UINT32 pid);

VOID
OvsAddPidInstance(POVS_SWITCH_CONTEXT switchContext, UINT32 pid,
POVS_OPEN_INSTANCE instance);

VOID
OvsDelPidInstance(POVS_SWITCH_CONTEXT switchContext, UINT32 pid);

#endif /* __USER_H_ */

0 comments on commit 65ae438

Please sign in to comment.