LG Just add comment that these functions should be executed when the pidHash (table or table entry) lock is held.
-----Original Message----- From: dev [mailto:dev-boun...@openvswitch.org] On Behalf Of Ankur Sharma Sent: Monday, October 20, 2014 5:35 PM To: dev@openvswitch.org Subject: [ovs-dev] [PATCH v1 2/6] 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 <ankursha...@vmware.com> --- datapath-windows/ovsext/User.c | 40 ++++++++++++++++++++++++++++++++++++++++ datapath-windows/ovsext/User.h | 10 ++++++++++ 2 files changed, 50 insertions(+) diff --git a/datapath-windows/ovsext/User.c b/datapath-windows/ovsext/User.c index a4c736b..a8d9107 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 @@ -597,6 +598,45 @@ OvsGetQueue(UINT32 pid) return NULL; } +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; +} + +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(&gOvsSwitchContext->pidHashArray[hash & OVS_PID_MASK], + &(instance->pidLink)); } + +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, diff --git a/datapath-windows/ovsext/User.h b/datapath-windows/ovsext/User.h index 0c18e2f..47fb10b 100644 --- a/datapath-windows/ovsext/User.h +++ b/datapath-windows/ovsext/User.h @@ -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_ */ -- 1.9.1 _______________________________________________ dev mailing list dev@openvswitch.org https://urldefense.proofpoint.com/v1/url?u=http://openvswitch.org/mailman/listinfo/dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=yTvML8OxA42Jb6ViHe7fUXbvPVOYDPVq87w43doxtlY%3D%0A&m=DpYNIV0H8d7fbwYPi8Nm4hpYShmCdVok4d53VhMOClE%3D%0A&s=95e79a4b05ea761331b8ad49580fb1cc4c082a726f32f74077b1559277359d8c _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev