[ovs-dev] [PATCH] datapath-windows: Move OvsCreateNewNBLsFromMultipleNBs to BuggerMgmt

Shashank Ram rams at vmware.com
Mon Aug 21 21:45:23 UTC 2017


Moves function OvsCreateNewNBLsFromMultipleNBs() to BufferMgmt.c
to facilitate consumption from outside PacketIO.c.

Signed-off-by: Shashank Ram <rams at vmware.com>
---
 datapath-windows/ovsext/BufferMgmt.c | 47 ++++++++++++++++++++++++++++++++++++
 datapath-windows/ovsext/BufferMgmt.h |  4 +++
 datapath-windows/ovsext/PacketIO.c   | 42 --------------------------------
 3 files changed, 51 insertions(+), 42 deletions(-)

diff --git a/datapath-windows/ovsext/BufferMgmt.c b/datapath-windows/ovsext/BufferMgmt.c
index 1ede4a3..5c9e562 100644
--- a/datapath-windows/ovsext/BufferMgmt.c
+++ b/datapath-windows/ovsext/BufferMgmt.c
@@ -1783,3 +1783,50 @@ OvsGetCtxSourcePortNo(PNET_BUFFER_LIST nbl,
     *portNo = ctx->srcPortNo;
     return NDIS_STATUS_SUCCESS;
 }
+
+/*
+ * --------------------------------------------------------------------------
+ * OvsCreateNewNBLsFromMultipleNBs --
+ *      Creates an NBL chain where each NBL has a single NB,
+ *      from an NBL which has multiple NBs.
+ *      Sets 'curNbl' and 'lastNbl' to the first and last NBL in the
+ *      newly created NBL chain respectively, and completes the original NBL.
+ * --------------------------------------------------------------------------
+ */
+NTSTATUS
+OvsCreateNewNBLsFromMultipleNBs(POVS_SWITCH_CONTEXT switchContext,
+                                PNET_BUFFER_LIST *curNbl,
+                                PNET_BUFFER_LIST *lastNbl)
+{
+    NTSTATUS status = STATUS_SUCCESS;
+    PNET_BUFFER_LIST newNbls = NULL;
+    PNET_BUFFER_LIST nbl = NULL;
+    BOOLEAN error = TRUE;
+
+    do {
+        /* Create new NBLs from curNbl with multiple net buffers. */
+        newNbls = OvsPartialCopyToMultipleNBLs(switchContext,
+                                               *curNbl, 0, 0, TRUE);
+        if (NULL == newNbls) {
+            OVS_LOG_ERROR("Failed to allocate NBLs with single NB.");
+            status = NDIS_STATUS_RESOURCES;
+            break;
+        }
+
+        nbl = newNbls;
+        while (nbl) {
+            *lastNbl = nbl;
+            nbl = NET_BUFFER_LIST_NEXT_NBL(nbl);
+        }
+
+        (*curNbl)->Next = NULL;
+
+        OvsCompleteNBL(switchContext, *curNbl, TRUE);
+
+        *curNbl = newNbls;
+
+        error = FALSE;
+    } while (error);
+
+    return status;
+}
diff --git a/datapath-windows/ovsext/BufferMgmt.h b/datapath-windows/ovsext/BufferMgmt.h
index e6cc0fe..dcf310a 100644
--- a/datapath-windows/ovsext/BufferMgmt.h
+++ b/datapath-windows/ovsext/BufferMgmt.h
@@ -141,4 +141,8 @@ NDIS_STATUS OvsSetCtxSourcePortNo(PNET_BUFFER_LIST nbl, UINT32 portNo);

 NDIS_STATUS OvsGetCtxSourcePortNo(PNET_BUFFER_LIST nbl, UINT32 *portNo);

+NTSTATUS OvsCreateNewNBLsFromMultipleNBs(PVOID context,
+                                         PNET_BUFFER_LIST *curNbl,
+                                         PNET_BUFFER_LIST *lastNbl);
+
 #endif /* __BUFFER_MGMT_H_ */
diff --git a/datapath-windows/ovsext/PacketIO.c b/datapath-windows/ovsext/PacketIO.c
index 81c574e..38e3e5f 100644
--- a/datapath-windows/ovsext/PacketIO.c
+++ b/datapath-windows/ovsext/PacketIO.c
@@ -46,10 +46,6 @@ extern NDIS_STRING ovsExtFriendlyNameUC;
 static VOID OvsFinalizeCompletionList(OvsCompletionList *completionList);
 static VOID OvsCompleteNBLIngress(POVS_SWITCH_CONTEXT switchContext,
                     PNET_BUFFER_LIST netBufferLists, ULONG sendCompleteFlags);
-static NTSTATUS OvsCreateNewNBLsFromMultipleNBs(
-                    POVS_SWITCH_CONTEXT switchContext,
-                    PNET_BUFFER_LIST *curNbl,
-                    PNET_BUFFER_LIST *lastNbl);

 VOID
 OvsInitCompletionList(OvsCompletionList *completionList,
@@ -500,41 +496,3 @@ OvsExtCancelSendNBL(NDIS_HANDLE filterModuleContext,
     /* All send requests get completed synchronously, so there is no need to
      * implement this callback. */
 }
-
-static NTSTATUS
-OvsCreateNewNBLsFromMultipleNBs(POVS_SWITCH_CONTEXT switchContext,
-                                PNET_BUFFER_LIST *curNbl,
-                                PNET_BUFFER_LIST *lastNbl)
-{
-    NTSTATUS status = STATUS_SUCCESS;
-    PNET_BUFFER_LIST newNbls = NULL;
-    PNET_BUFFER_LIST nbl = NULL;
-    BOOLEAN error = TRUE;
-
-    do {
-        /* Create new NBLs from curNbl with multiple net buffers. */
-        newNbls = OvsPartialCopyToMultipleNBLs(switchContext,
-                                               *curNbl, 0, 0, TRUE);
-        if (NULL == newNbls) {
-            OVS_LOG_ERROR("Failed to allocate NBLs with single NB.");
-            status = NDIS_STATUS_RESOURCES;
-            break;
-        }
-
-        nbl = newNbls;
-        while (nbl) {
-            *lastNbl = nbl;
-            nbl = NET_BUFFER_LIST_NEXT_NBL(nbl);
-        }
-
-        (*curNbl)->Next = NULL;
-
-        OvsCompleteNBL(switchContext, *curNbl, TRUE);
-
-        *curNbl = newNbls;
-
-        error = FALSE;
-    } while (error);
-
-    return status;
-}
--
2.9.3.windows.2



More information about the dev mailing list