[ovs-dev] Please review: [PATCH 2/3] Refactor OvsInitNBLContext and OvsInitExternalNBLContext

Samuel Ghinet sghinet at cloudbasesolutions.com
Fri Aug 29 13:31:36 UTC 2014


Hello,

Part 2 of the patch is below:

=======================

---
 datapath-windows/ovsext/OvsBufferMgmt.c | 39 +++++++++++++++++----------------
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/datapath-windows/ovsext/OvsBufferMgmt.c b/datapath-windows/ovsext/OvsBufferMgmt.c
index c367d2f..48c5702 100644
--- a/datapath-windows/ovsext/OvsBufferMgmt.c
+++ b/datapath-windows/ovsext/OvsBufferMgmt.c
@@ -254,16 +254,16 @@ OvsCleanupBufferPool(PVOID ovsContext)
 
 
 static VOID
-OvsInitNBLContext(POVS_BUFFER_CONTEXT ctx,
-                  UINT16 flags,
+OvsInitNBLContext(POVS_BUFFER_CONTEXT bufferContext,
+                  UINT16 bufferFlags,
                   UINT32 origDataLength,
                   UINT32 srcPortNo)
 {
-    ctx->magic = OVS_CTX_MAGIC;
-    ctx->refCount = 1;
-    ctx->flags = flags;
-    ctx->srcPortNo = srcPortNo;
-    ctx->origDataLength = origDataLength;
+    bufferContext->magic = OVS_CTX_MAGIC;
+    bufferContext->refCount = 1;
+    bufferContext->flags = bufferFlags;
+    bufferContext->srcPortNo = srcPortNo;
+    bufferContext->origDataLength = origDataLength;
 }
 
 
@@ -552,15 +552,15 @@ OvsInitExternalNBLContext(PVOID ovsContext,
                           BOOLEAN isRecv)
 {
     NDIS_HANDLE poolHandle;
-    POVS_SWITCH_CONTEXT context = (POVS_SWITCH_CONTEXT)ovsContext;
-    POVS_BUFFER_CONTEXT ctx;
-    PNET_BUFFER nb;
+    POVS_SWITCH_CONTEXT switchContext = (POVS_SWITCH_CONTEXT)ovsContext;
+    POVS_BUFFER_CONTEXT bufferContext;
+    ULONG nbLen;
     NDIS_STATUS status;
-    UINT16 flags;
+    UINT16 bufferFlags;
 
     poolHandle = NdisGetPoolFromNetBufferList(nbl);
 
-    if (poolHandle == context->ovsPool.ndisHandle) {
+    if (poolHandle == switchContext->ovsPool.ndisHandle) {
         return (POVS_BUFFER_CONTEXT)NET_BUFFER_LIST_CONTEXT_DATA_START(nbl);
     }
     status = NdisAllocateNetBufferListContext(nbl, sizeof (OVS_BUFFER_CONTEXT),
@@ -571,19 +571,20 @@ OvsInitExternalNBLContext(PVOID ovsContext,
     }
 #ifdef DBG
     OvsDumpNBLContext(nbl);
-    InterlockedIncrement((LONG volatile *)&context->ovsPool.sysNBLCount);
+    InterlockedIncrement((LONG volatile *)&switchContext->ovsPool.sysNBLCount);
 #endif
-    flags = isRecv ? OVS_BUFFER_RECV_BUFFER : OVS_BUFFER_SEND_BUFFER;
-    flags |= OVS_BUFFER_NEED_COMPLETE | OVS_BUFFER_PRIVATE_CONTEXT;
-    ctx = (POVS_BUFFER_CONTEXT)NET_BUFFER_LIST_CONTEXT_DATA_START(nbl);
 
-    nb = NET_BUFFER_LIST_FIRST_NB(nbl);
+    bufferFlags = isRecv ? OVS_BUFFER_RECV_BUFFER : OVS_BUFFER_SEND_BUFFER;
+    bufferFlags |= OVS_BUFFER_NEED_COMPLETE | OVS_BUFFER_PRIVATE_CONTEXT;
+    bufferContext = (POVS_BUFFER_CONTEXT)NET_BUFFER_LIST_CONTEXT_DATA_START(nbl);
+
+    nbLen = NET_BUFFER_DATA_LENGTH(nbl->FirstNetBuffer);
     /*
      * we use first nb to decide whether we need advance or retreat during
      * complete.
      */
-    OvsInitNBLContext(ctx, flags, NET_BUFFER_DATA_LENGTH(nb), OVS_DEFAULT_PORT_NO);
-    return ctx;
+    OvsInitNBLContext(bufferContext, bufferFlags, nbLen, OVS_DEFAULT_PORT_NO);
+    return bufferContext;
 }
 
 /*
-- 
1.8.3.msysgit.0




More information about the dev mailing list