[ovs-dev] datapath-windows: Avoid unnecessary vport array search
diff mbox

Message ID 1441159785-16317-1-git-send-email-svinturis@cloudbasesolutions.com
State Accepted
Headers show

Commit Message

Sorin Vinturis Sept. 23, 2015, 12:40 p.m. UTC
Signed-off-by: Sorin Vinturis <svinturis@cloudbasesolutions.com>
---
This patch is for both master and 2.4 branch.
---
 datapath-windows/ovsext/Actions.c  | 20 ++++++++++----------
 datapath-windows/ovsext/PacketIO.c |  6 +++---
 datapath-windows/ovsext/PacketIO.h | 10 +++++-----
 datapath-windows/ovsext/Tunnel.c   |  8 ++++----
 datapath-windows/ovsext/User.c     | 12 ++++--------
 datapath-windows/ovsext/User.h     |  5 +++--
 6 files changed, 29 insertions(+), 32 deletions(-)

Comments

Sairam Venugopal Sept. 28, 2015, 9:42 p.m. UTC | #1
Acked-by: Sairam Venugopal <vsairam@vmware.com>



On 9/23/15, 5:40 AM, "Sorin Vinturis" <svinturis@cloudbasesolutions.com>
wrote:

>Signed-off-by: Sorin Vinturis <svinturis@cloudbasesolutions.com>
>---
>This patch is for both master and 2.4 branch.
>---
> datapath-windows/ovsext/Actions.c  | 20 ++++++++++----------
> datapath-windows/ovsext/PacketIO.c |  6 +++---
> datapath-windows/ovsext/PacketIO.h | 10 +++++-----
> datapath-windows/ovsext/Tunnel.c   |  8 ++++----
> datapath-windows/ovsext/User.c     | 12 ++++--------
> datapath-windows/ovsext/User.h     |  5 +++--
> 6 files changed, 29 insertions(+), 32 deletions(-)
>
>diff --git a/datapath-windows/ovsext/Actions.c
>b/datapath-windows/ovsext/Actions.c
>index bfe5d7f..b4644a7 100644
>--- a/datapath-windows/ovsext/Actions.c
>+++ b/datapath-windows/ovsext/Actions.c
>@@ -566,9 +566,10 @@ OvsDoFlowLookupOutput(OvsForwardingContext
>*ovsFwdCtx)
> 
>     /* Assert that in the Rx direction, key is always setup. */
>     ASSERT(ovsFwdCtx->tunnelRxNic == NULL || ovsFwdCtx->tunKey.dst != 0);
>-    status = OvsExtractFlow(ovsFwdCtx->curNbl, ovsFwdCtx->srcVportNo,
>-                          &key, &ovsFwdCtx->layers,
>ovsFwdCtx->tunKey.dst != 0 ?
>-                                         &ovsFwdCtx->tunKey : NULL);
>+    status =
>+        OvsExtractFlow(ovsFwdCtx->curNbl, ovsFwdCtx->srcVportNo,
>+                       &key, &ovsFwdCtx->layers,
>+                       ovsFwdCtx->tunKey.dst != 0 ? &ovsFwdCtx->tunKey :
>NULL);
>     if (status != NDIS_STATUS_SUCCESS) {
>         OvsCompleteNBLForwardingCtx(ovsFwdCtx,
>                                     L"OVS-Flow extract failed");
>@@ -581,18 +582,17 @@ OvsDoFlowLookupOutput(OvsForwardingContext
>*ovsFwdCtx)
>         OvsFlowUsed(flow, ovsFwdCtx->curNbl, &ovsFwdCtx->layers);
>         ovsFwdCtx->switchContext->datapath.hits++;
>         status = OvsActionsExecute(ovsFwdCtx->switchContext,
>-                                 ovsFwdCtx->completionList,
>ovsFwdCtx->curNbl,
>-                                 ovsFwdCtx->srcVportNo,
>ovsFwdCtx->sendFlags,
>-                                 &key, &hash, &ovsFwdCtx->layers,
>-                                 flow->actions, flow->actionsLen);
>+                                   ovsFwdCtx->completionList,
>ovsFwdCtx->curNbl,
>+                                   ovsFwdCtx->srcVportNo,
>ovsFwdCtx->sendFlags,
>+                                   &key, &hash, &ovsFwdCtx->layers,
>+                                   flow->actions, flow->actionsLen);
>         ovsFwdCtx->curNbl = NULL;
>     } else {
>         LIST_ENTRY missedPackets;
>         UINT32 num = 0;
>         ovsFwdCtx->switchContext->datapath.misses++;
>         InitializeListHead(&missedPackets);
>-        status = OvsCreateAndAddPackets(NULL, 0, OVS_PACKET_CMD_MISS,
>-                          ovsFwdCtx->srcVportNo,
>+        status = OvsCreateAndAddPackets(NULL, 0, OVS_PACKET_CMD_MISS,
>vport,
>                           &key,ovsFwdCtx->curNbl,
>                           ovsFwdCtx->tunnelRxNic != NULL,
>&ovsFwdCtx->layers,
>                           ovsFwdCtx->switchContext, &missedPackets,
>&num);
>@@ -1530,7 +1530,7 @@ OvsActionsExecute(POVS_SWITCH_CONTEXT switchContext,
>             elem = OvsCreateQueueNlPacket((PVOID)userdataAttr,
>                                     userdataAttr->nlaLen,
>                                     OVS_PACKET_CMD_ACTION,
>-                                    portNo, key,ovsFwdCtx.curNbl,
>+                                    vport, key, ovsFwdCtx.curNbl,
>                  
>NET_BUFFER_LIST_FIRST_NB(ovsFwdCtx.curNbl),
>                                     isRecv,
>                                     layers);
>diff --git a/datapath-windows/ovsext/PacketIO.c
>b/datapath-windows/ovsext/PacketIO.c
>index d41335b..cfbae34 100644
>--- a/datapath-windows/ovsext/PacketIO.c
>+++ b/datapath-windows/ovsext/PacketIO.c
>@@ -333,8 +333,8 @@ OvsStartNBLIngress(POVS_SWITCH_CONTEXT switchContext,
>                  * Otherwise, it adds it to the completionList. No need
>to
>                  * check the return value. */
>                 OvsActionsExecute(switchContext, &completionList, curNbl,
>-                                portNo, SendFlags, &key, &hash, &layers,
>-                                flow->actions, flow->actionsLen);
>+                                  portNo, SendFlags, &key, &hash,
>&layers,
>+                                  flow->actions, flow->actionsLen);
>                 OvsReleaseDatapath(datapath, &dpLockState);
>                 NdisReleaseRWLock(switchContext->dispatchLock,
>&lockState);
>                 continue;
>@@ -343,7 +343,7 @@ OvsStartNBLIngress(POVS_SWITCH_CONTEXT switchContext,
> 
>                 datapath->misses++;
>                 status = OvsCreateAndAddPackets(NULL, 0,
>OVS_PACKET_CMD_MISS,
>-                             portNo, &key, curNbl,
>+                             vport, &key, curNbl,
>                              sourcePort ==
>switchContext->virtualExternalPortId,
>                              &layers, switchContext, &missedPackets,
>&num);
>                 if (status == NDIS_STATUS_SUCCESS) {
>diff --git a/datapath-windows/ovsext/PacketIO.h
>b/datapath-windows/ovsext/PacketIO.h
>index 4d29a18..7247869 100644
>--- a/datapath-windows/ovsext/PacketIO.h
>+++ b/datapath-windows/ovsext/PacketIO.h
>@@ -49,11 +49,11 @@ VOID OvsSendNBLIngress(POVS_SWITCH_CONTEXT
>switchContext,
>                        ULONG sendFlags);
> 
> NDIS_STATUS OvsActionsExecute(POVS_SWITCH_CONTEXT switchContext,
>-                            OvsCompletionList *completionList,
>-                            PNET_BUFFER_LIST curNbl, UINT32 srcVportNo,
>-                            ULONG sendFlags, OvsFlowKey *key, UINT64
>*hash,
>-                            OVS_PACKET_HDR_INFO *layers,
>-                            const PNL_ATTR actions, int actionsLen);
>+                              OvsCompletionList *completionList,
>+                              PNET_BUFFER_LIST curNbl, UINT32 srcVportNo,
>+                              ULONG sendFlags, OvsFlowKey *key, UINT64
>*hash,
>+                              OVS_PACKET_HDR_INFO *layers,
>+                              const PNL_ATTR actions, int actionsLen);
> 
> VOID OvsLookupFlowOutput(POVS_SWITCH_CONTEXT switchContext,
>                          VOID *compList, PNET_BUFFER_LIST curNbl);
>diff --git a/datapath-windows/ovsext/Tunnel.c
>b/datapath-windows/ovsext/Tunnel.c
>index ffb9c01..eea4a84 100644
>--- a/datapath-windows/ovsext/Tunnel.c
>+++ b/datapath-windows/ovsext/Tunnel.c
>@@ -309,8 +309,8 @@ OvsInjectPacketThroughActions(PNET_BUFFER_LIST pNbl,
>             datapath->hits++;
> 
>             OvsActionsExecute(gOvsSwitchContext, &completionList, pNbl,
>-                            portNo, SendFlags, &key, &hash, &layers,
>-                            flow->actions, flow->actionsLen);
>+                              portNo, SendFlags, &key, &hash, &layers,
>+                              flow->actions, flow->actionsLen);
> 
>             OvsReleaseDatapath(datapath, &dpLockState);
>         } else {
>@@ -318,8 +318,8 @@ OvsInjectPacketThroughActions(PNET_BUFFER_LIST pNbl,
> 
>             datapath->misses++;
>             elem = OvsCreateQueueNlPacket(NULL, 0, OVS_PACKET_CMD_MISS,
>-                                        portNo, &key, pNbl, curNb,
>-                                        TRUE, &layers);
>+                                          vport, &key, pNbl, curNb,
>+                                          TRUE, &layers);
>             if (elem) {
>                 /* Complete the packet since it was copied to user
>buffer. */
>                 InsertTailList(&missedPackets, &elem->link);
>diff --git a/datapath-windows/ovsext/User.c
>b/datapath-windows/ovsext/User.c
>index 8045e9a..7af4816 100644
>--- a/datapath-windows/ovsext/User.c
>+++ b/datapath-windows/ovsext/User.c
>@@ -772,7 +772,7 @@ NTSTATUS
> OvsCreateAndAddPackets(PVOID userData,
>                        UINT32 userDataLen,
>                        UINT32 cmd,
>-                       UINT32 inPort,
>+                       POVS_VPORT_ENTRY vport,
>                        OvsFlowKey *key,
>                        PNET_BUFFER_LIST nbl,
>                        BOOLEAN isRecv,
>@@ -809,7 +809,7 @@ OvsCreateAndAddPackets(PVOID userData,
>     nb = NET_BUFFER_LIST_FIRST_NB(nbl);
>     while (nb) {
>         elem = OvsCreateQueueNlPacket(userData, userDataLen,
>-                                    cmd, inPort, key, nbl, nb,
>+                                    cmd, vport, key, nbl, nb,
>                                     isRecv, hdrInfo);
>         if (elem) {
>             InsertTailList(list, &elem->link);
>@@ -988,7 +988,7 @@ POVS_PACKET_QUEUE_ELEM
> OvsCreateQueueNlPacket(PVOID userData,
>                        UINT32 userDataLen,
>                        UINT32 cmd,
>-                       UINT32 inPort,
>+                       POVS_VPORT_ENTRY vport,
>                        OvsFlowKey *key,
>                        PNET_BUFFER_LIST nbl,
>                        PNET_BUFFER nb,
>@@ -1007,10 +1007,6 @@ OvsCreateQueueNlPacket(PVOID userData,
>     NL_BUFFER nlBuf;
>     PNL_MSG_HDR nlMsg;
> 
>-    /* XXX pass vport in the stack rather than portNo */
>-    POVS_VPORT_ENTRY vport =
>-        OvsFindVportByPortNo(gOvsSwitchContext, inPort);
>-
>     if (vport == NULL){
>         /* No vport is not fatal. */
>         return NULL;
>@@ -1062,7 +1058,7 @@ OvsCreateQueueNlPacket(PVOID userData,
>     elem->packet.queue = 0;
>     /* XXX  no need as the length is already in the NL attrib */
>     elem->packet.userDataLen = userDataLen;
>-    elem->packet.inPort = inPort;
>+    elem->packet.inPort = vport->portNo;
>     elem->packet.cmd = cmd;
>     if (cmd == (UINT32)OVS_PACKET_CMD_MISS) {
>         ovsUserStats.miss++;
>diff --git a/datapath-windows/ovsext/User.h
>b/datapath-windows/ovsext/User.h
>index 139b0ca..9182585 100644
>--- a/datapath-windows/ovsext/User.h
>+++ b/datapath-windows/ovsext/User.h
>@@ -72,7 +72,8 @@ VOID OvsCleanupPacketQueue(struct _OVS_OPEN_INSTANCE
>*instance);
> 
> POVS_PACKET_QUEUE_ELEM OvsCreateQueueNlPacket(PVOID userData,
>                                               UINT32 userDataLen,
>-                                              UINT32 cmd, UINT32 inPort,
>+                                              UINT32 cmd,
>+                                              POVS_VPORT_ENTRY vport,
>                                               OvsFlowKey *key,
>                                               PNET_BUFFER_LIST nbl,
>                                               PNET_BUFFER nb,
>@@ -83,7 +84,7 @@ VOID OvsQueuePackets(PLIST_ENTRY packetList, UINT32
>numElems);
> NTSTATUS OvsCreateAndAddPackets(PVOID userData,
>                                 UINT32 userDataLen,
>                                 UINT32 cmd,
>-                                UINT32 inPort,
>+                                POVS_VPORT_ENTRY vport,
>                                 OvsFlowKey *key,
>                                 PNET_BUFFER_LIST nbl,
>                                 BOOLEAN isRecv,
>-- 
>1.9.0.msysgit.0
>_______________________________________________
>dev mailing list
>dev@openvswitch.org
>https://urldefense.proofpoint.com/v2/url?u=http-3A__openvswitch.org_mailma
>n_listinfo_dev&d=BQIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=Dc
>ruz40PROJ40ROzSpxyQSLw6fcrOWpJgEcEmNR3JEQ&m=_QR6L-So8TGmFBV0A2IaeJNUdS4XN2
>ehOcQku6idSxg&s=0PpPW_IBNlEugSSfP_sT2AbB9zvgGgxHLwolWUC_rtg&e=
Ben Pfaff Sept. 29, 2015, 6:56 p.m. UTC | #2
Thanks Sorin and Sairam, applied to master and branch-2.4.

On Mon, Sep 28, 2015 at 09:42:53PM +0000, Sairam Venugopal wrote:
> Acked-by: Sairam Venugopal <vsairam@vmware.com>
> 
> 
> 
> On 9/23/15, 5:40 AM, "Sorin Vinturis" <svinturis@cloudbasesolutions.com>
> wrote:
> 
> >Signed-off-by: Sorin Vinturis <svinturis@cloudbasesolutions.com>
> >---
> >This patch is for both master and 2.4 branch.
> >---
> > datapath-windows/ovsext/Actions.c  | 20 ++++++++++----------
> > datapath-windows/ovsext/PacketIO.c |  6 +++---
> > datapath-windows/ovsext/PacketIO.h | 10 +++++-----
> > datapath-windows/ovsext/Tunnel.c   |  8 ++++----
> > datapath-windows/ovsext/User.c     | 12 ++++--------
> > datapath-windows/ovsext/User.h     |  5 +++--
> > 6 files changed, 29 insertions(+), 32 deletions(-)
> >
> >diff --git a/datapath-windows/ovsext/Actions.c
> >b/datapath-windows/ovsext/Actions.c
> >index bfe5d7f..b4644a7 100644
> >--- a/datapath-windows/ovsext/Actions.c
> >+++ b/datapath-windows/ovsext/Actions.c
> >@@ -566,9 +566,10 @@ OvsDoFlowLookupOutput(OvsForwardingContext
> >*ovsFwdCtx)
> > 
> >     /* Assert that in the Rx direction, key is always setup. */
> >     ASSERT(ovsFwdCtx->tunnelRxNic == NULL || ovsFwdCtx->tunKey.dst != 0);
> >-    status = OvsExtractFlow(ovsFwdCtx->curNbl, ovsFwdCtx->srcVportNo,
> >-                          &key, &ovsFwdCtx->layers,
> >ovsFwdCtx->tunKey.dst != 0 ?
> >-                                         &ovsFwdCtx->tunKey : NULL);
> >+    status =
> >+        OvsExtractFlow(ovsFwdCtx->curNbl, ovsFwdCtx->srcVportNo,
> >+                       &key, &ovsFwdCtx->layers,
> >+                       ovsFwdCtx->tunKey.dst != 0 ? &ovsFwdCtx->tunKey :
> >NULL);
> >     if (status != NDIS_STATUS_SUCCESS) {
> >         OvsCompleteNBLForwardingCtx(ovsFwdCtx,
> >                                     L"OVS-Flow extract failed");
> >@@ -581,18 +582,17 @@ OvsDoFlowLookupOutput(OvsForwardingContext
> >*ovsFwdCtx)
> >         OvsFlowUsed(flow, ovsFwdCtx->curNbl, &ovsFwdCtx->layers);
> >         ovsFwdCtx->switchContext->datapath.hits++;
> >         status = OvsActionsExecute(ovsFwdCtx->switchContext,
> >-                                 ovsFwdCtx->completionList,
> >ovsFwdCtx->curNbl,
> >-                                 ovsFwdCtx->srcVportNo,
> >ovsFwdCtx->sendFlags,
> >-                                 &key, &hash, &ovsFwdCtx->layers,
> >-                                 flow->actions, flow->actionsLen);
> >+                                   ovsFwdCtx->completionList,
> >ovsFwdCtx->curNbl,
> >+                                   ovsFwdCtx->srcVportNo,
> >ovsFwdCtx->sendFlags,
> >+                                   &key, &hash, &ovsFwdCtx->layers,
> >+                                   flow->actions, flow->actionsLen);
> >         ovsFwdCtx->curNbl = NULL;
> >     } else {
> >         LIST_ENTRY missedPackets;
> >         UINT32 num = 0;
> >         ovsFwdCtx->switchContext->datapath.misses++;
> >         InitializeListHead(&missedPackets);
> >-        status = OvsCreateAndAddPackets(NULL, 0, OVS_PACKET_CMD_MISS,
> >-                          ovsFwdCtx->srcVportNo,
> >+        status = OvsCreateAndAddPackets(NULL, 0, OVS_PACKET_CMD_MISS,
> >vport,
> >                           &key,ovsFwdCtx->curNbl,
> >                           ovsFwdCtx->tunnelRxNic != NULL,
> >&ovsFwdCtx->layers,
> >                           ovsFwdCtx->switchContext, &missedPackets,
> >&num);
> >@@ -1530,7 +1530,7 @@ OvsActionsExecute(POVS_SWITCH_CONTEXT switchContext,
> >             elem = OvsCreateQueueNlPacket((PVOID)userdataAttr,
> >                                     userdataAttr->nlaLen,
> >                                     OVS_PACKET_CMD_ACTION,
> >-                                    portNo, key,ovsFwdCtx.curNbl,
> >+                                    vport, key, ovsFwdCtx.curNbl,
> >                  
> >NET_BUFFER_LIST_FIRST_NB(ovsFwdCtx.curNbl),
> >                                     isRecv,
> >                                     layers);
> >diff --git a/datapath-windows/ovsext/PacketIO.c
> >b/datapath-windows/ovsext/PacketIO.c
> >index d41335b..cfbae34 100644
> >--- a/datapath-windows/ovsext/PacketIO.c
> >+++ b/datapath-windows/ovsext/PacketIO.c
> >@@ -333,8 +333,8 @@ OvsStartNBLIngress(POVS_SWITCH_CONTEXT switchContext,
> >                  * Otherwise, it adds it to the completionList. No need
> >to
> >                  * check the return value. */
> >                 OvsActionsExecute(switchContext, &completionList, curNbl,
> >-                                portNo, SendFlags, &key, &hash, &layers,
> >-                                flow->actions, flow->actionsLen);
> >+                                  portNo, SendFlags, &key, &hash,
> >&layers,
> >+                                  flow->actions, flow->actionsLen);
> >                 OvsReleaseDatapath(datapath, &dpLockState);
> >                 NdisReleaseRWLock(switchContext->dispatchLock,
> >&lockState);
> >                 continue;
> >@@ -343,7 +343,7 @@ OvsStartNBLIngress(POVS_SWITCH_CONTEXT switchContext,
> > 
> >                 datapath->misses++;
> >                 status = OvsCreateAndAddPackets(NULL, 0,
> >OVS_PACKET_CMD_MISS,
> >-                             portNo, &key, curNbl,
> >+                             vport, &key, curNbl,
> >                              sourcePort ==
> >switchContext->virtualExternalPortId,
> >                              &layers, switchContext, &missedPackets,
> >&num);
> >                 if (status == NDIS_STATUS_SUCCESS) {
> >diff --git a/datapath-windows/ovsext/PacketIO.h
> >b/datapath-windows/ovsext/PacketIO.h
> >index 4d29a18..7247869 100644
> >--- a/datapath-windows/ovsext/PacketIO.h
> >+++ b/datapath-windows/ovsext/PacketIO.h
> >@@ -49,11 +49,11 @@ VOID OvsSendNBLIngress(POVS_SWITCH_CONTEXT
> >switchContext,
> >                        ULONG sendFlags);
> > 
> > NDIS_STATUS OvsActionsExecute(POVS_SWITCH_CONTEXT switchContext,
> >-                            OvsCompletionList *completionList,
> >-                            PNET_BUFFER_LIST curNbl, UINT32 srcVportNo,
> >-                            ULONG sendFlags, OvsFlowKey *key, UINT64
> >*hash,
> >-                            OVS_PACKET_HDR_INFO *layers,
> >-                            const PNL_ATTR actions, int actionsLen);
> >+                              OvsCompletionList *completionList,
> >+                              PNET_BUFFER_LIST curNbl, UINT32 srcVportNo,
> >+                              ULONG sendFlags, OvsFlowKey *key, UINT64
> >*hash,
> >+                              OVS_PACKET_HDR_INFO *layers,
> >+                              const PNL_ATTR actions, int actionsLen);
> > 
> > VOID OvsLookupFlowOutput(POVS_SWITCH_CONTEXT switchContext,
> >                          VOID *compList, PNET_BUFFER_LIST curNbl);
> >diff --git a/datapath-windows/ovsext/Tunnel.c
> >b/datapath-windows/ovsext/Tunnel.c
> >index ffb9c01..eea4a84 100644
> >--- a/datapath-windows/ovsext/Tunnel.c
> >+++ b/datapath-windows/ovsext/Tunnel.c
> >@@ -309,8 +309,8 @@ OvsInjectPacketThroughActions(PNET_BUFFER_LIST pNbl,
> >             datapath->hits++;
> > 
> >             OvsActionsExecute(gOvsSwitchContext, &completionList, pNbl,
> >-                            portNo, SendFlags, &key, &hash, &layers,
> >-                            flow->actions, flow->actionsLen);
> >+                              portNo, SendFlags, &key, &hash, &layers,
> >+                              flow->actions, flow->actionsLen);
> > 
> >             OvsReleaseDatapath(datapath, &dpLockState);
> >         } else {
> >@@ -318,8 +318,8 @@ OvsInjectPacketThroughActions(PNET_BUFFER_LIST pNbl,
> > 
> >             datapath->misses++;
> >             elem = OvsCreateQueueNlPacket(NULL, 0, OVS_PACKET_CMD_MISS,
> >-                                        portNo, &key, pNbl, curNb,
> >-                                        TRUE, &layers);
> >+                                          vport, &key, pNbl, curNb,
> >+                                          TRUE, &layers);
> >             if (elem) {
> >                 /* Complete the packet since it was copied to user
> >buffer. */
> >                 InsertTailList(&missedPackets, &elem->link);
> >diff --git a/datapath-windows/ovsext/User.c
> >b/datapath-windows/ovsext/User.c
> >index 8045e9a..7af4816 100644
> >--- a/datapath-windows/ovsext/User.c
> >+++ b/datapath-windows/ovsext/User.c
> >@@ -772,7 +772,7 @@ NTSTATUS
> > OvsCreateAndAddPackets(PVOID userData,
> >                        UINT32 userDataLen,
> >                        UINT32 cmd,
> >-                       UINT32 inPort,
> >+                       POVS_VPORT_ENTRY vport,
> >                        OvsFlowKey *key,
> >                        PNET_BUFFER_LIST nbl,
> >                        BOOLEAN isRecv,
> >@@ -809,7 +809,7 @@ OvsCreateAndAddPackets(PVOID userData,
> >     nb = NET_BUFFER_LIST_FIRST_NB(nbl);
> >     while (nb) {
> >         elem = OvsCreateQueueNlPacket(userData, userDataLen,
> >-                                    cmd, inPort, key, nbl, nb,
> >+                                    cmd, vport, key, nbl, nb,
> >                                     isRecv, hdrInfo);
> >         if (elem) {
> >             InsertTailList(list, &elem->link);
> >@@ -988,7 +988,7 @@ POVS_PACKET_QUEUE_ELEM
> > OvsCreateQueueNlPacket(PVOID userData,
> >                        UINT32 userDataLen,
> >                        UINT32 cmd,
> >-                       UINT32 inPort,
> >+                       POVS_VPORT_ENTRY vport,
> >                        OvsFlowKey *key,
> >                        PNET_BUFFER_LIST nbl,
> >                        PNET_BUFFER nb,
> >@@ -1007,10 +1007,6 @@ OvsCreateQueueNlPacket(PVOID userData,
> >     NL_BUFFER nlBuf;
> >     PNL_MSG_HDR nlMsg;
> > 
> >-    /* XXX pass vport in the stack rather than portNo */
> >-    POVS_VPORT_ENTRY vport =
> >-        OvsFindVportByPortNo(gOvsSwitchContext, inPort);
> >-
> >     if (vport == NULL){
> >         /* No vport is not fatal. */
> >         return NULL;
> >@@ -1062,7 +1058,7 @@ OvsCreateQueueNlPacket(PVOID userData,
> >     elem->packet.queue = 0;
> >     /* XXX  no need as the length is already in the NL attrib */
> >     elem->packet.userDataLen = userDataLen;
> >-    elem->packet.inPort = inPort;
> >+    elem->packet.inPort = vport->portNo;
> >     elem->packet.cmd = cmd;
> >     if (cmd == (UINT32)OVS_PACKET_CMD_MISS) {
> >         ovsUserStats.miss++;
> >diff --git a/datapath-windows/ovsext/User.h
> >b/datapath-windows/ovsext/User.h
> >index 139b0ca..9182585 100644
> >--- a/datapath-windows/ovsext/User.h
> >+++ b/datapath-windows/ovsext/User.h
> >@@ -72,7 +72,8 @@ VOID OvsCleanupPacketQueue(struct _OVS_OPEN_INSTANCE
> >*instance);
> > 
> > POVS_PACKET_QUEUE_ELEM OvsCreateQueueNlPacket(PVOID userData,
> >                                               UINT32 userDataLen,
> >-                                              UINT32 cmd, UINT32 inPort,
> >+                                              UINT32 cmd,
> >+                                              POVS_VPORT_ENTRY vport,
> >                                               OvsFlowKey *key,
> >                                               PNET_BUFFER_LIST nbl,
> >                                               PNET_BUFFER nb,
> >@@ -83,7 +84,7 @@ VOID OvsQueuePackets(PLIST_ENTRY packetList, UINT32
> >numElems);
> > NTSTATUS OvsCreateAndAddPackets(PVOID userData,
> >                                 UINT32 userDataLen,
> >                                 UINT32 cmd,
> >-                                UINT32 inPort,
> >+                                POVS_VPORT_ENTRY vport,
> >                                 OvsFlowKey *key,
> >                                 PNET_BUFFER_LIST nbl,
> >                                 BOOLEAN isRecv,
> >-- 
> >1.9.0.msysgit.0
> >_______________________________________________
> >dev mailing list
> >dev@openvswitch.org
> >https://urldefense.proofpoint.com/v2/url?u=http-3A__openvswitch.org_mailma
> >n_listinfo_dev&d=BQIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=Dc
> >ruz40PROJ40ROzSpxyQSLw6fcrOWpJgEcEmNR3JEQ&m=_QR6L-So8TGmFBV0A2IaeJNUdS4XN2
> >ehOcQku6idSxg&s=0PpPW_IBNlEugSSfP_sT2AbB9zvgGgxHLwolWUC_rtg&e= 
> 
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev

Patch
diff mbox

diff --git a/datapath-windows/ovsext/Actions.c b/datapath-windows/ovsext/Actions.c
index bfe5d7f..b4644a7 100644
--- a/datapath-windows/ovsext/Actions.c
+++ b/datapath-windows/ovsext/Actions.c
@@ -566,9 +566,10 @@  OvsDoFlowLookupOutput(OvsForwardingContext *ovsFwdCtx)
 
     /* Assert that in the Rx direction, key is always setup. */
     ASSERT(ovsFwdCtx->tunnelRxNic == NULL || ovsFwdCtx->tunKey.dst != 0);
-    status = OvsExtractFlow(ovsFwdCtx->curNbl, ovsFwdCtx->srcVportNo,
-                          &key, &ovsFwdCtx->layers, ovsFwdCtx->tunKey.dst != 0 ?
-                                         &ovsFwdCtx->tunKey : NULL);
+    status =
+        OvsExtractFlow(ovsFwdCtx->curNbl, ovsFwdCtx->srcVportNo,
+                       &key, &ovsFwdCtx->layers,
+                       ovsFwdCtx->tunKey.dst != 0 ? &ovsFwdCtx->tunKey : NULL);
     if (status != NDIS_STATUS_SUCCESS) {
         OvsCompleteNBLForwardingCtx(ovsFwdCtx,
                                     L"OVS-Flow extract failed");
@@ -581,18 +582,17 @@  OvsDoFlowLookupOutput(OvsForwardingContext *ovsFwdCtx)
         OvsFlowUsed(flow, ovsFwdCtx->curNbl, &ovsFwdCtx->layers);
         ovsFwdCtx->switchContext->datapath.hits++;
         status = OvsActionsExecute(ovsFwdCtx->switchContext,
-                                 ovsFwdCtx->completionList, ovsFwdCtx->curNbl,
-                                 ovsFwdCtx->srcVportNo, ovsFwdCtx->sendFlags,
-                                 &key, &hash, &ovsFwdCtx->layers,
-                                 flow->actions, flow->actionsLen);
+                                   ovsFwdCtx->completionList, ovsFwdCtx->curNbl,
+                                   ovsFwdCtx->srcVportNo, ovsFwdCtx->sendFlags,
+                                   &key, &hash, &ovsFwdCtx->layers,
+                                   flow->actions, flow->actionsLen);
         ovsFwdCtx->curNbl = NULL;
     } else {
         LIST_ENTRY missedPackets;
         UINT32 num = 0;
         ovsFwdCtx->switchContext->datapath.misses++;
         InitializeListHead(&missedPackets);
-        status = OvsCreateAndAddPackets(NULL, 0, OVS_PACKET_CMD_MISS,
-                          ovsFwdCtx->srcVportNo,
+        status = OvsCreateAndAddPackets(NULL, 0, OVS_PACKET_CMD_MISS, vport,
                           &key,ovsFwdCtx->curNbl,
                           ovsFwdCtx->tunnelRxNic != NULL, &ovsFwdCtx->layers,
                           ovsFwdCtx->switchContext, &missedPackets, &num);
@@ -1530,7 +1530,7 @@  OvsActionsExecute(POVS_SWITCH_CONTEXT switchContext,
             elem = OvsCreateQueueNlPacket((PVOID)userdataAttr,
                                     userdataAttr->nlaLen,
                                     OVS_PACKET_CMD_ACTION,
-                                    portNo, key,ovsFwdCtx.curNbl,
+                                    vport, key, ovsFwdCtx.curNbl,
                                     NET_BUFFER_LIST_FIRST_NB(ovsFwdCtx.curNbl),
                                     isRecv,
                                     layers);
diff --git a/datapath-windows/ovsext/PacketIO.c b/datapath-windows/ovsext/PacketIO.c
index d41335b..cfbae34 100644
--- a/datapath-windows/ovsext/PacketIO.c
+++ b/datapath-windows/ovsext/PacketIO.c
@@ -333,8 +333,8 @@  OvsStartNBLIngress(POVS_SWITCH_CONTEXT switchContext,
                  * Otherwise, it adds it to the completionList. No need to
                  * check the return value. */
                 OvsActionsExecute(switchContext, &completionList, curNbl,
-                                portNo, SendFlags, &key, &hash, &layers,
-                                flow->actions, flow->actionsLen);
+                                  portNo, SendFlags, &key, &hash, &layers,
+                                  flow->actions, flow->actionsLen);
                 OvsReleaseDatapath(datapath, &dpLockState);
                 NdisReleaseRWLock(switchContext->dispatchLock, &lockState);
                 continue;
@@ -343,7 +343,7 @@  OvsStartNBLIngress(POVS_SWITCH_CONTEXT switchContext,
 
                 datapath->misses++;
                 status = OvsCreateAndAddPackets(NULL, 0, OVS_PACKET_CMD_MISS,
-                             portNo, &key, curNbl,
+                             vport, &key, curNbl,
                              sourcePort == switchContext->virtualExternalPortId,
                              &layers, switchContext, &missedPackets, &num);
                 if (status == NDIS_STATUS_SUCCESS) {
diff --git a/datapath-windows/ovsext/PacketIO.h b/datapath-windows/ovsext/PacketIO.h
index 4d29a18..7247869 100644
--- a/datapath-windows/ovsext/PacketIO.h
+++ b/datapath-windows/ovsext/PacketIO.h
@@ -49,11 +49,11 @@  VOID OvsSendNBLIngress(POVS_SWITCH_CONTEXT switchContext,
                        ULONG sendFlags);
 
 NDIS_STATUS OvsActionsExecute(POVS_SWITCH_CONTEXT switchContext,
-                            OvsCompletionList *completionList,
-                            PNET_BUFFER_LIST curNbl, UINT32 srcVportNo,
-                            ULONG sendFlags, OvsFlowKey *key, UINT64 *hash,
-                            OVS_PACKET_HDR_INFO *layers,
-                            const PNL_ATTR actions, int actionsLen);
+                              OvsCompletionList *completionList,
+                              PNET_BUFFER_LIST curNbl, UINT32 srcVportNo,
+                              ULONG sendFlags, OvsFlowKey *key, UINT64 *hash,
+                              OVS_PACKET_HDR_INFO *layers,
+                              const PNL_ATTR actions, int actionsLen);
 
 VOID OvsLookupFlowOutput(POVS_SWITCH_CONTEXT switchContext,
                          VOID *compList, PNET_BUFFER_LIST curNbl);
diff --git a/datapath-windows/ovsext/Tunnel.c b/datapath-windows/ovsext/Tunnel.c
index ffb9c01..eea4a84 100644
--- a/datapath-windows/ovsext/Tunnel.c
+++ b/datapath-windows/ovsext/Tunnel.c
@@ -309,8 +309,8 @@  OvsInjectPacketThroughActions(PNET_BUFFER_LIST pNbl,
             datapath->hits++;
 
             OvsActionsExecute(gOvsSwitchContext, &completionList, pNbl,
-                            portNo, SendFlags, &key, &hash, &layers,
-                            flow->actions, flow->actionsLen);
+                              portNo, SendFlags, &key, &hash, &layers,
+                              flow->actions, flow->actionsLen);
 
             OvsReleaseDatapath(datapath, &dpLockState);
         } else {
@@ -318,8 +318,8 @@  OvsInjectPacketThroughActions(PNET_BUFFER_LIST pNbl,
 
             datapath->misses++;
             elem = OvsCreateQueueNlPacket(NULL, 0, OVS_PACKET_CMD_MISS,
-                                        portNo, &key, pNbl, curNb,
-                                        TRUE, &layers);
+                                          vport, &key, pNbl, curNb,
+                                          TRUE, &layers);
             if (elem) {
                 /* Complete the packet since it was copied to user buffer. */
                 InsertTailList(&missedPackets, &elem->link);
diff --git a/datapath-windows/ovsext/User.c b/datapath-windows/ovsext/User.c
index 8045e9a..7af4816 100644
--- a/datapath-windows/ovsext/User.c
+++ b/datapath-windows/ovsext/User.c
@@ -772,7 +772,7 @@  NTSTATUS
 OvsCreateAndAddPackets(PVOID userData,
                        UINT32 userDataLen,
                        UINT32 cmd,
-                       UINT32 inPort,
+                       POVS_VPORT_ENTRY vport,
                        OvsFlowKey *key,
                        PNET_BUFFER_LIST nbl,
                        BOOLEAN isRecv,
@@ -809,7 +809,7 @@  OvsCreateAndAddPackets(PVOID userData,
     nb = NET_BUFFER_LIST_FIRST_NB(nbl);
     while (nb) {
         elem = OvsCreateQueueNlPacket(userData, userDataLen,
-                                    cmd, inPort, key, nbl, nb,
+                                    cmd, vport, key, nbl, nb,
                                     isRecv, hdrInfo);
         if (elem) {
             InsertTailList(list, &elem->link);
@@ -988,7 +988,7 @@  POVS_PACKET_QUEUE_ELEM
 OvsCreateQueueNlPacket(PVOID userData,
                        UINT32 userDataLen,
                        UINT32 cmd,
-                       UINT32 inPort,
+                       POVS_VPORT_ENTRY vport,
                        OvsFlowKey *key,
                        PNET_BUFFER_LIST nbl,
                        PNET_BUFFER nb,
@@ -1007,10 +1007,6 @@  OvsCreateQueueNlPacket(PVOID userData,
     NL_BUFFER nlBuf;
     PNL_MSG_HDR nlMsg;
 
-    /* XXX pass vport in the stack rather than portNo */
-    POVS_VPORT_ENTRY vport =
-        OvsFindVportByPortNo(gOvsSwitchContext, inPort);
-
     if (vport == NULL){
         /* No vport is not fatal. */
         return NULL;
@@ -1062,7 +1058,7 @@  OvsCreateQueueNlPacket(PVOID userData,
     elem->packet.queue = 0;
     /* XXX  no need as the length is already in the NL attrib */
     elem->packet.userDataLen = userDataLen;
-    elem->packet.inPort = inPort;
+    elem->packet.inPort = vport->portNo;
     elem->packet.cmd = cmd;
     if (cmd == (UINT32)OVS_PACKET_CMD_MISS) {
         ovsUserStats.miss++;
diff --git a/datapath-windows/ovsext/User.h b/datapath-windows/ovsext/User.h
index 139b0ca..9182585 100644
--- a/datapath-windows/ovsext/User.h
+++ b/datapath-windows/ovsext/User.h
@@ -72,7 +72,8 @@  VOID OvsCleanupPacketQueue(struct _OVS_OPEN_INSTANCE *instance);
 
 POVS_PACKET_QUEUE_ELEM OvsCreateQueueNlPacket(PVOID userData,
                                               UINT32 userDataLen,
-                                              UINT32 cmd, UINT32 inPort,
+                                              UINT32 cmd, 
+                                              POVS_VPORT_ENTRY vport,
                                               OvsFlowKey *key,
                                               PNET_BUFFER_LIST nbl,
                                               PNET_BUFFER nb,
@@ -83,7 +84,7 @@  VOID OvsQueuePackets(PLIST_ENTRY packetList, UINT32 numElems);
 NTSTATUS OvsCreateAndAddPackets(PVOID userData,
                                 UINT32 userDataLen,
                                 UINT32 cmd,
-                                UINT32 inPort,
+                                POVS_VPORT_ENTRY vport,
                                 OvsFlowKey *key,
                                 PNET_BUFFER_LIST nbl,
                                 BOOLEAN isRecv,