From patchwork Mon Aug 21 21:45:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shashank Ram X-Patchwork-Id: 804186 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xbnMN3qMBz9t1t for ; Tue, 22 Aug 2017 07:46:40 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 390B5900; Mon, 21 Aug 2017 21:46:36 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 391E68E3 for ; Mon, 21 Aug 2017 21:46:35 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from EX13-EDG-OU-001.vmware.com (ex13-edg-ou-001.vmware.com [208.91.0.189]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 21F1B460 for ; Mon, 21 Aug 2017 21:46:35 +0000 (UTC) Received: from sc9-mailhost1.vmware.com (10.113.161.71) by EX13-EDG-OU-001.vmware.com (10.113.208.155) with Microsoft SMTP Server id 15.0.1156.6; Mon, 21 Aug 2017 14:45:44 -0700 Received: from localhost.localdomain (htb-1s-eng-dhcp79.eng.vmware.com [10.33.78.79]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id 76F0718524; Mon, 21 Aug 2017 14:46:34 -0700 (PDT) From: Shashank Ram To: Date: Mon, 21 Aug 2017 14:45:23 -0700 Message-ID: <20170821214523.17860-1-rams@vmware.com> X-Mailer: git-send-email 2.9.3.windows.2 MIME-Version: 1.0 Received-SPF: None (EX13-EDG-OU-001.vmware.com: rams@vmware.com does not designate permitted sender hosts) Subject: [ovs-dev] [PATCH] datapath-windows: Move OvsCreateNewNBLsFromMultipleNBs to BuggerMgmt X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Moves function OvsCreateNewNBLsFromMultipleNBs() to BufferMgmt.c to facilitate consumption from outside PacketIO.c. Signed-off-by: Shashank Ram Acked-by: Anand Kumar Acked-by: Alin Gabriel Serdean --- 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(-) -- 2.9.3.windows.2 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; -}