summaryrefslogtreecommitdiff
path: root/datapath-windows/ovsext/BufferMgmt.c
diff options
context:
space:
mode:
authorSairam Venugopal <vsairam@vmware.com>2015-10-26 16:48:39 -0700
committerGurucharan Shetty <gshetty@nicira.com>2015-10-27 13:48:06 -0700
commit9a80ee1443134fe36d15c76bc77b567315f948f9 (patch)
treea4c75c85cd84e267ac9dc85af369f84907dc04c5 /datapath-windows/ovsext/BufferMgmt.c
parent481c5a6d836f77331e42b1fd65b5fc9786bda5d5 (diff)
downloadopenvswitch-9a80ee1443134fe36d15c76bc77b567315f948f9.tar.gz
datapath-windows: Move OvsAllocateNBLFromBuffer to BufferMgmt
Move the functionality around creating an NBL from Buffer to Buffermanagement. This function will be used for converting the buffer from user-space to NBL and also by STT - reassembly logic. Signed-off-by: Sairam Venugopal <vsairam@vmware.com> Acked-by: Nithin Raju <nithin@vmware.com> Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Diffstat (limited to 'datapath-windows/ovsext/BufferMgmt.c')
-rw-r--r--datapath-windows/ovsext/BufferMgmt.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/datapath-windows/ovsext/BufferMgmt.c b/datapath-windows/ovsext/BufferMgmt.c
index 9a1cf96b1..ab7a18e91 100644
--- a/datapath-windows/ovsext/BufferMgmt.c
+++ b/datapath-windows/ovsext/BufferMgmt.c
@@ -1308,6 +1308,52 @@ nblcopy_error:
return NULL;
}
+/*
+ * --------------------------------------------------------------------------
+ * OvsAllocateNBLFromBuffer --
+ *
+ * This function allocates all the stuff necessary for creating an NBL from the
+ * input buffer of specified length, namely, a nonpaged data buffer of size
+ * length, an MDL from it, and a NB and NBL from it. It does not allocate an NBL
+ * context yet. It also copies data from the specified buffer to the NBL.
+ * --------------------------------------------------------------------------
+ */
+PNET_BUFFER_LIST
+OvsAllocateNBLFromBuffer(PVOID context,
+ PVOID buffer,
+ ULONG length)
+{
+ POVS_SWITCH_CONTEXT switchContext = (POVS_SWITCH_CONTEXT)context;
+ UINT8 *data = NULL;
+ PNET_BUFFER_LIST nbl = NULL;
+ PNET_BUFFER nb;
+ PMDL mdl;
+
+ if (length > OVS_DEFAULT_DATA_SIZE) {
+ nbl = OvsAllocateVariableSizeNBL(switchContext, length,
+ OVS_DEFAULT_HEADROOM_SIZE);
+
+ } else {
+ nbl = OvsAllocateFixSizeNBL(switchContext, length,
+ OVS_DEFAULT_HEADROOM_SIZE);
+ }
+ if (nbl == NULL) {
+ return NULL;
+ }
+
+ nb = NET_BUFFER_LIST_FIRST_NB(nbl);
+ mdl = NET_BUFFER_CURRENT_MDL(nb);
+ data = (PUINT8)MmGetSystemAddressForMdlSafe(mdl, LowPagePriority) +
+ NET_BUFFER_CURRENT_MDL_OFFSET(nb);
+ if (!data) {
+ OvsCompleteNBL(switchContext, nbl, TRUE);
+ return NULL;
+ }
+
+ NdisMoveMemory(data, buffer, length);
+
+ return nbl;
+}
/*
* --------------------------------------------------------------------------