[ovs-dev] [PATCH v1 4/6] datapath-windows: Add code for OvsGetQueue.
Ankur Sharma
ankursharma at vmware.com
Tue Oct 21 00:35:17 UTC 2014
Signed-off-by: Ankur Sharma <ankursharma at vmware.com>
---
datapath-windows/ovsext/User.c | 45 +++++++++++++++++++++++++++++++++++++-----
1 file changed, 40 insertions(+), 5 deletions(-)
diff --git a/datapath-windows/ovsext/User.c b/datapath-windows/ovsext/User.c
index 42473ab..95b8652 100644
--- a/datapath-windows/ovsext/User.c
+++ b/datapath-windows/ovsext/User.c
@@ -608,16 +608,35 @@ OvsGetNextPacket(POVS_OPEN_INSTANCE instance)
return CONTAINING_RECORD(link, OVS_PACKET_QUEUE_ELEM, link);
}
-
+/*
+ * ---------------------------------------------------------------------------
+ * Given a pid, returns the corresponding USER_PACKET_QUEUE.
+ * ---------------------------------------------------------------------------
+ */
POVS_USER_PACKET_QUEUE
OvsGetQueue(UINT32 pid)
{
- /* XXX To be implemented. Return the queue assoiated with the pid*/
- UNREFERENCED_PARAMETER(pid);
- ASSERT(FALSE);
- return NULL;
+ POVS_OPEN_INSTANCE instance;
+ POVS_USER_PACKET_QUEUE ret = NULL;
+
+ OvsAcquireCtrlLock();
+ instance = OvsGetPidInstance(gOvsSwitchContext, pid);
+
+ if (instance) {
+ ret = instance->packetQueue;
+ }
+
+ OvsReleaseCtrlLock();
+
+ return ret;
}
+/*
+ * ---------------------------------------------------------------------------
+ * 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)
{
@@ -635,6 +654,12 @@ OvsGetPidInstance(POVS_SWITCH_CONTEXT switchContext, UINT32 pid)
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)
@@ -647,6 +672,12 @@ OvsAddPidInstance(POVS_SWITCH_CONTEXT switchContext, UINT32 pid,
&(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)
{
@@ -903,6 +934,10 @@ OvsGetPid(POVS_VPORT_ENTRY vport, PNET_BUFFER nb, UINT32 *pid)
{
UNREFERENCED_PARAMETER(nb);
+ if (!vport) {
+ return STATUS_INVALID_PARAMETER;
+ }
+
/* XXX select a pid from an array of pids using a flow based hash */
*pid = vport->upcallPid;
return STATUS_SUCCESS;
--
1.9.1
More information about the dev
mailing list