From patchwork Thu May 4 22:12:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Kumar X-Patchwork-Id: 758805 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3wJq8C0VcRz9s7C for ; Fri, 5 May 2017 08:14:51 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id C4F4CC19; Thu, 4 May 2017 22:13:29 +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 2284DBC3 for ; Thu, 4 May 2017 22:13:26 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from EX13-EDG-OU-002.vmware.com (ex13-edg-ou-002.vmware.com [208.91.0.190]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id A3DB810E for ; Thu, 4 May 2017 22:13:25 +0000 (UTC) Received: from sc9-mailhost1.vmware.com (10.113.161.71) by EX13-EDG-OU-002.vmware.com (10.113.208.156) with Microsoft SMTP Server id 15.0.1156.6; Thu, 4 May 2017 15:12:53 -0700 Received: from localhost.localdomain (htb-1s-eng-dhcp460.eng.vmware.com [10.33.79.204]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id 5AF7018309; Thu, 4 May 2017 15:13:22 -0700 (PDT) From: Anand Kumar To: Date: Thu, 4 May 2017 15:12:54 -0700 Message-ID: <20170504221254.7896-6-kumaranand@vmware.com> X-Mailer: git-send-email 2.9.3.windows.1 In-Reply-To: <20170504221254.7896-1-kumaranand@vmware.com> References: <20170504221254.7896-1-kumaranand@vmware.com> MIME-Version: 1.0 Received-SPF: None (EX13-EDG-OU-002.vmware.com: kumaranand@vmware.com does not designate permitted sender hosts) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v8 5/5] datapath-windows: Fragment NBL based on MRU size 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 This patch adds support for Fragmenting NBL based on the MRU value. MRU value is updated only for Ipv4 fragments, if it is non zero, then fragment the NBL and send out the new NBL to the vnic. Signed-off-by: Anand Kumar Acked-by: Alin Gabriel Serdean --- v7->v8: No change v6->v7: Fragment the NBL for tunnel packets v5->v6: No Change v4->v5: - Use MRU information in the _OVS_BUFFER_CONTEXT to fragment NBL. v3->v4: No Change v2->v3: - Updated log message v1->v2: No change --- datapath-windows/ovsext/Actions.c | 51 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/datapath-windows/ovsext/Actions.c b/datapath-windows/ovsext/Actions.c index b5c13c7..e2eae9a 100644 --- a/datapath-windows/ovsext/Actions.c +++ b/datapath-windows/ovsext/Actions.c @@ -34,6 +34,7 @@ #include "Vport.h" #include "Vxlan.h" #include "Geneve.h" +#include "IpFragment.h" #ifdef OVS_DBG_MOD #undef OVS_DBG_MOD @@ -144,6 +145,36 @@ OvsInitForwardingCtx(OvsForwardingContext *ovsFwdCtx, /* * -------------------------------------------------------------------------- + * OvsDoFragmentNbl -- + * Utility function to Fragment nbl based on mru. + * -------------------------------------------------------------------------- + */ +static __inline VOID +OvsDoFragmentNbl(OvsForwardingContext *ovsFwdCtx, UINT16 mru) +{ + PNET_BUFFER_LIST fragNbl = NULL; + fragNbl = OvsFragmentNBL(ovsFwdCtx->switchContext, + ovsFwdCtx->curNbl, + &(ovsFwdCtx->layers), + mru, 0, TRUE); + + if (fragNbl != NULL) { + OvsCompleteNBL(ovsFwdCtx->switchContext, ovsFwdCtx->curNbl, TRUE); + OvsInitForwardingCtx(ovsFwdCtx, + ovsFwdCtx->switchContext, + fragNbl, + ovsFwdCtx->srcVportNo, + ovsFwdCtx->sendFlags, + NET_BUFFER_LIST_SWITCH_FORWARDING_DETAIL(fragNbl), + ovsFwdCtx->completionList, + &ovsFwdCtx->layers, FALSE); + } else { + OVS_LOG_INFO("Fragment NBL failed for MRU = %u", mru); + } +} + +/* + * -------------------------------------------------------------------------- * OvsDetectTunnelRxPkt -- * Utility function for an RX packet to detect its tunnel type. * @@ -604,6 +635,7 @@ OvsTunnelPortTx(OvsForwardingContext *ovsFwdCtx) UINT32 srcVportNo; NDIS_SWITCH_NIC_INDEX srcNicIndex; NDIS_SWITCH_PORT_ID srcPortId; + POVS_BUFFER_CONTEXT ctx; /* * Setup the source port to be the internal port to as to facilitate the @@ -617,6 +649,10 @@ OvsTunnelPortTx(OvsForwardingContext *ovsFwdCtx) return NDIS_STATUS_FAILURE; } + ctx = (POVS_BUFFER_CONTEXT)NET_BUFFER_LIST_CONTEXT_DATA_START(ovsFwdCtx->curNbl); + if (ctx->mru != 0) { + OvsDoFragmentNbl(ovsFwdCtx, ctx->mru); + } OVS_FWD_INFO switchFwdInfo = { 0 }; /* Apply the encapsulation. The encapsulation will not consume the NBL. */ switch(ovsFwdCtx->tunnelTxNic->ovsType) { @@ -807,6 +843,7 @@ OvsOutputForwardingCtx(OvsForwardingContext *ovsFwdCtx) NDIS_STATUS status = STATUS_SUCCESS; POVS_SWITCH_CONTEXT switchContext = ovsFwdCtx->switchContext; PCWSTR dropReason; + POVS_BUFFER_CONTEXT ctx; /* * Handle the case where the some of the destination ports are tunneled @@ -829,8 +866,12 @@ OvsOutputForwardingCtx(OvsForwardingContext *ovsFwdCtx) * before doing encapsulation. */ if (ovsFwdCtx->tunnelTxNic != NULL || ovsFwdCtx->tunnelRxNic != NULL) { + POVS_BUFFER_CONTEXT oldCtx, newCtx; nb = NET_BUFFER_LIST_FIRST_NB(ovsFwdCtx->curNbl); - newNbl = OvsPartialCopyNBL(ovsFwdCtx->switchContext, ovsFwdCtx->curNbl, + oldCtx = (POVS_BUFFER_CONTEXT) + NET_BUFFER_LIST_CONTEXT_DATA_START(ovsFwdCtx->curNbl); + newNbl = OvsPartialCopyNBL(ovsFwdCtx->switchContext, + ovsFwdCtx->curNbl, 0, 0, TRUE /*copy NBL info*/); if (newNbl == NULL) { status = NDIS_STATUS_RESOURCES; @@ -838,6 +879,9 @@ OvsOutputForwardingCtx(OvsForwardingContext *ovsFwdCtx) dropReason = L"Dropped due to failure to create NBL copy."; goto dropit; } + newCtx = (POVS_BUFFER_CONTEXT) + NET_BUFFER_LIST_CONTEXT_DATA_START(newNbl); + newCtx->mru = oldCtx->mru; } /* It does not seem like we'll get here unless 'portsToUpdate' > 0. */ @@ -852,6 +896,11 @@ OvsOutputForwardingCtx(OvsForwardingContext *ovsFwdCtx) goto dropit; } + ctx = (POVS_BUFFER_CONTEXT)NET_BUFFER_LIST_CONTEXT_DATA_START(ovsFwdCtx->curNbl); + if (ctx->mru != 0) { + OvsDoFragmentNbl(ovsFwdCtx, ctx->mru); + } + OvsSendNBLIngress(ovsFwdCtx->switchContext, ovsFwdCtx->curNbl, ovsFwdCtx->sendFlags); /* End this pipeline by resetting the corresponding context. */