From patchwork Sat Oct 24 20:40:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sairam Venugopal X-Patchwork-Id: 535464 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (li376-54.members.linode.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 7B92E14131F for ; Sun, 25 Oct 2015 07:42:47 +1100 (AEDT) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id D9CE81092B; Sat, 24 Oct 2015 13:42:38 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e4.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id 3184D1090C for ; Sat, 24 Oct 2015 13:42:37 -0700 (PDT) Received: from bar5.cudamail.com (unknown [192.168.21.12]) by mx1e4.cudamail.com (Postfix) with ESMTPS id A71D71E02DD for ; Sat, 24 Oct 2015 14:42:36 -0600 (MDT) X-ASG-Debug-ID: 1445719355-09eadd4c9329b560001-byXFYA Received: from mx1-pf2.cudamail.com ([192.168.24.2]) by bar5.cudamail.com with ESMTP id BI7O5O57uKWBWDkI (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 24 Oct 2015 14:42:35 -0600 (MDT) X-Barracuda-Envelope-From: vsairam@vmware.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.2 Received: from unknown (HELO smtp-outbound-2.vmware.com) (208.91.2.13) by mx1-pf2.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 24 Oct 2015 20:42:35 -0000 Received-SPF: pass (mx1-pf2.cudamail.com: SPF record at _spf.vmware.com designates 208.91.2.13 as permitted sender) X-Barracuda-Apparent-Source-IP: 208.91.2.13 X-Barracuda-RBL-IP: 208.91.2.13 Received: from sc9-mailhost3.vmware.com (sc9-mailhost3.vmware.com [10.113.161.73]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id 70ABB28F7B for ; Sat, 24 Oct 2015 13:42:38 -0700 (PDT) Received: from localhost.localdomain (unknown [10.33.78.151]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id 9688B405CA; Sat, 24 Oct 2015 13:42:34 -0700 (PDT) X-CudaMail-Envelope-Sender: vsairam@vmware.com From: Sairam Venugopal To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-E2-1023027233 X-CudaMail-DTE: 102415 X-CudaMail-Originating-IP: 208.91.2.13 Date: Sat, 24 Oct 2015 13:40:20 -0700 X-ASG-Orig-Subj: [##CM-E2-1023027233##][PATCH 1/3] datapath-windows: Move OvsAllocateNBLFromBuffer to BufferMgmt Message-Id: <1445719222-4664-2-git-send-email-vsairam@vmware.com> X-Mailer: git-send-email 1.9.5.msysgit.0 In-Reply-To: <1445719222-4664-1-git-send-email-vsairam@vmware.com> References: <1445719222-4664-1-git-send-email-vsairam@vmware.com> X-Barracuda-Connect: UNKNOWN[192.168.24.2] X-Barracuda-Start-Time: 1445719355 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-ASG-Whitelist: EmailCat (corporate) Subject: [ovs-dev] [PATCH 1/3] datapath-windows: Move OvsAllocateNBLFromBuffer to BufferMgmt X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" 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 --- datapath-windows/ovsext/BufferMgmt.c | 46 ++++++++++++++++++++++++++++++++++ datapath-windows/ovsext/BufferMgmt.h | 3 +++ datapath-windows/ovsext/User.c | 48 ++---------------------------------- 3 files changed, 51 insertions(+), 46 deletions(-) diff --git a/datapath-windows/ovsext/BufferMgmt.c b/datapath-windows/ovsext/BufferMgmt.c index 9a1cf96..ab7a18e 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; +} /* * -------------------------------------------------------------------------- diff --git a/datapath-windows/ovsext/BufferMgmt.h b/datapath-windows/ovsext/BufferMgmt.h index 915d7f5..79abc3d 100644 --- a/datapath-windows/ovsext/BufferMgmt.h +++ b/datapath-windows/ovsext/BufferMgmt.h @@ -113,6 +113,9 @@ PNET_BUFFER_LIST OvsTcpSegmentNBL(PVOID context, POVS_PACKET_HDR_INFO hdrInfo, UINT32 MSS, UINT32 headRoom); +PNET_BUFFER_LIST OvsAllocateNBLFromBuffer(PVOID context, + PVOID buffer, + ULONG length); PNET_BUFFER_LIST OvsFullCopyToMultipleNBLs(PVOID context, PNET_BUFFER_LIST nbl, UINT32 headRoom, BOOLEAN copyNblInfo); PNET_BUFFER_LIST OvsCompleteNBL(PVOID context, PNET_BUFFER_LIST nbl, diff --git a/datapath-windows/ovsext/User.c b/datapath-windows/ovsext/User.c index e7be904..7828687 100644 --- a/datapath-windows/ovsext/User.c +++ b/datapath-windows/ovsext/User.c @@ -258,50 +258,6 @@ OvsAllocateForwardingContextForNBL(POVS_SWITCH_CONTEXT switchContext, } /* - * -------------------------------------------------------------------------- - * 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 -OvsAllocateNBLForUserBuffer(POVS_SWITCH_CONTEXT switchContext, - PVOID userBuffer, - ULONG length) -{ - 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, userBuffer, length); - - return nbl; -} - -/* *---------------------------------------------------------------------------- * OvsNlExecuteCmdHandler -- * Handler for OVS_PACKET_CMD_EXECUTE command. @@ -454,8 +410,8 @@ OvsExecuteDpIoctl(OvsPacketExecute *execute) * Allocate the NBL, copy the data from the userspace buffer. Allocate * also, the forwarding context for the packet. */ - pNbl = OvsAllocateNBLForUserBuffer(gOvsSwitchContext, execute->packetBuf, - execute->packetLen); + pNbl = OvsAllocateNBLFromBuffer(gOvsSwitchContext, execute->packetBuf, + execute->packetLen); if (pNbl == NULL) { status = STATUS_NO_MEMORY; goto exit;