From patchwork Sat Jul 7 00:46:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vishal Deep Ajmera X-Patchwork-Id: 940629 X-Patchwork-Delegate: ian.stokes@intel.com 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ericsson.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ericsson.com header.i=@ericsson.com header.b="KxeCqr5X"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ericsson.com header.i=@ericsson.com header.b="JPcgDeff"; dkim-atps=neutral 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 41Mgbr0nDLz9s4Z for ; Sat, 7 Jul 2018 02:46:31 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id A8380D5A; Fri, 6 Jul 2018 16:46:28 +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 9F004D59 for ; Fri, 6 Jul 2018 16:46:26 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from sessmg23.ericsson.net (sessmg23.ericsson.net [193.180.251.45]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 4949B124 for ; Fri, 6 Jul 2018 16:46:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/simple; q=dns/txt; i=@ericsson.com; t=1530895583; h=From:Sender:Reply-To:Subject:Date:Message-Id:To:CC:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=WNucnvN+09FiLRt7fcMdTDr6Y3b2fedUSMYns0uko+Q=; b=KxeCqr5Xex+bzQm1URugjPSPAHHv3EFo7p8XhWxl9/D7/pT/h9kvSkBsahknbGrb QReC2QTdGEW+6d2wm1cYbLnW0w0ywfvoHeKR/TIun1YR+kVytFFP+5uG8VhyCUU0 OJbDff/Lo9wKMl/TpJNk9/qfTUvEER310S0S26CdeSY=; X-AuditID: c1b4fb2d-5ecb19c0000055ff-55-5b3f9cdf5fd4 Received: from ESESSMB501.ericsson.se (Unknown_Domain [153.88.183.119]) by sessmg23.ericsson.net (Symantec Mail Security) with SMTP id D5.CC.22015.FDC9F3B5; Fri, 6 Jul 2018 18:46:23 +0200 (CEST) Received: from ESESSMR505.ericsson.se (153.88.183.127) by ESESSMB501.ericsson.se (153.88.183.189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 6 Jul 2018 18:45:56 +0200 Received: from ESESSMB505.ericsson.se (153.88.183.166) by ESESSMR505.ericsson.se (153.88.183.127) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Fri, 6 Jul 2018 18:45:56 +0200 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (153.88.183.157) by ESESSMB505.ericsson.se (153.88.183.166) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3 via Frontend Transport; Fri, 6 Jul 2018 18:45:56 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IMn2q9mstPqeBHSIClVt0I9c1ocbBuhyAhWJsxfmMhM=; b=JPcgDeffFf3XswaOGSv/e1xahptRIzU11Z86Wupe5ajW/53OO80vKMmjw3yZS+aL2VjrFAi2jul3Ncea5s4GNXoG4uLIfnYyGfgpEDfpwRwsImkShjHz4EVibnXjzO6r47UI3neWJWYlzfRLNG1L7Bg0sMQPwkTAKGCa4LRtUEc= Received: from localhost.localdomain (125.16.128.122) by AM5PR0701MB2691.eurprd07.prod.outlook.com (2603:10a6:203:75::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.930.13; Fri, 6 Jul 2018 16:45:54 +0000 From: Vishal Deep Ajmera To: Date: Sat, 7 Jul 2018 06:16:41 +0530 Message-Id: <1530924401-32446-1-git-send-email-vishal.deep.ajmera@ericsson.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [125.16.128.122] X-ClientProxiedBy: BM1PR0101CA0047.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:1a::33) To AM5PR0701MB2691.eurprd07.prod.outlook.com (2603:10a6:203:75::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c58289d8-ebeb-4563-b392-08d5e35ff123 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:AM5PR0701MB2691; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0701MB2691; 3:wkH4yC0ZY5IAcIWdUGa3LDJ7OHC2p3MMJ3nU94uPB2dmu11s3fXJNgUgeNRe5tlqE/wnWnPoHALYfkdbGQmfphc6RGraZgk5/akbP+J8N/sh1OwmJclv7mFhCXFQ+Axiaq7wOzpGo+SZO20S+C152Y3iLqFwcru6OFqAljDdc1qiYTO/GgEfyy+cYt3cB52NjPLKp7iOow6nS4FoCYMRg7wsp/bWfU0RqqLOUFCzKn9OvnFAu+CZXUQm7OpB45l3; 25:3uN0KjEV4R2qoQuV0+M722fehbPGJud56yf0+2LHSHOVSDS4VdvPxPI8ZLmHhJzsJEI0iS4PSHbowUWni0oiuQWTdRPrmzR7UWondk1L7pnJZNdZ0l1dAuN/T1W+Pu/9JDfgcnON81OrbpmY/O5aZBYShXLb1e1Jo4RoTgH1IwBUPQelpjKGXLgXVUNaWiYXSNWI2yn7bWgcMBIcVutUFCW9vDUiQEchFPo2x9K7dvNsg82v002jyGk1MF0Z9cnKEmMCsQH2Ok6V2EFHOY2m8EM4ScYCneZVDMxmlWnG7k+YVKULt82+OrdbhmNZHw1WiVT9K+WcQY4HT3pfXTiYrQ==; 31:OQ3g033lDkgsa7Gi8rj4Moq/DMHYBwDZxRm5NnAxAdyPgF1cgT5fVoZLCOrRWi7VBp+5COZA6agfa+lYJTNHrWs9VLHJGoYHxOPoQtmDYVZGHNFaz5+3vUcNq6qYEymcYgzAYB/2G2zKlO6lxMqkJmRFDHj11xg1VH/p2wbmfahlYsuSLy9i+bX2SqmQpioWm4yPFAvuPKRQrcBTP4Lkss9TRZp0l7URuHehwzBpSIs= X-MS-TrafficTypeDiagnostic: AM5PR0701MB2691: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=vishal.deep.ajmera@ericsson.com; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0701MB2691; 20:f35g+r/FcNgHoBSy4TsXRO9uMU9/zuTPSXd7jSm2rQ4kS5yy3QgABJ3marP7ddpnY9qlvhiVGvECdwIW4zj0NKROxiQMo83xXQY0Hkby7a3NHDWlYo4jr390RNZzP3FUrS60A5deJlLCrAe2gQzllXmw9/d/wHfS4hIsOaVSO3oLuHIWnwttIqSKc0v/C75k7NmUfHLXI40PlR4Xph3adPnUI4fd8GxMYCJqdJQW+/35lmYYiJbvR9ty3WhmOYdtyweoboKjaL1VfhSxfmTFRrYnYf49O9qfh6wRSdIpXsjBEqY2TrZRww+mgnvQVkPVaKQgebfd5ge4pw7o+788wSEoLCVkdpRowT+lkbmjPdnEIgB+h3LDa4xY1bdG7b1VrHCQwuUNgqia+8AGn/2v2Pau8Ae1c28pmoNdObPJN+yd4ZEq+6woXw8ILpkzUf1Mw95Phr0EVclA8lij1PlanESPGBiXZBXXb31zdgkglmgtOVWYe/B4+Td5QhQIgnaT; 4:InzXY7uk1rv2vINphWTRrf4mgKHDrAyMT79XiAnKCXXx1CqTKL/doqMzapcpBhNImbhcDTESx1nMFk/D4a5ddPA/eDK4vd781VpyyZspekTDIj1cmDm8NLocE3D835eZpQ+LpEgDUNwvqk1ayarRYKA23MuZRak2YkUk5TeaVHkWIIoHaUd+vZJ5j9TBDxHppbuj7q62AyxxwnT9anHHyrj6lciwGjK8yWgi7YE1C7I494WKwMiFSLbcn4m1mo6T0OqoOc3ZdVWQ5mQk1vPEcrxWiwEby5RYFYdHBP6ALVr8oxZlRAreiqZrVtCBrW+x X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(37575265505322); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231291)(944501410)(52105095)(149027)(150027)(6041310)(20161123562045)(20161123564045)(20161123560045)(20161123558120)(201703131423095)(201703061421075)(201703161042150)(6072148)(6042181)(201708071742011)(7699016); SRVR:AM5PR0701MB2691; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0701MB2691; X-Forefront-PRVS: 0725D9E8D0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(366004)(199004)(189003)(47776003)(54906003)(106356001)(105586002)(97736004)(6512007)(486006)(23676004)(476003)(53936002)(956004)(8936002)(2361001)(68736007)(6916009)(6666003)(107886003)(4326008)(52116002)(6486002)(50226002)(2616005)(86362001)(8676002)(36756003)(5660300001)(498600001)(2906002)(14444005)(26005)(186003)(2870700001)(16526019)(50466002)(7736002)(2351001)(55236004)(3846002)(81166006)(6116002)(305945005)(81156014)(25786009)(6506007)(386003)(66066001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0701MB2691; H:localhost.localdomain; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?q?1=3BAM5PR0701MB2691=3B23=3AXa?= =?utf-8?q?jY2cSA+xurfZbfovAYajFvM7bYCLKp/5qB8U6Zf1C1vK20Zb4o6M51OX?= =?utf-8?q?V8STcencvj2V5F6j6DL72ZwzRlVLvYd7/shWzRBmwmnvu+jdko3ePgt8?= =?utf-8?q?praetDG4+mqCyc2mWwzoyu22/AelPPGoWXhqGUqPi2N44LljsyzPj/6S?= =?utf-8?q?xF8TElFx+KDBtvb3ma/AkVAUjLTzcmSmdrBmA3bpeWNha+hxetmYiuas?= =?utf-8?q?SA6Gd1dTpt9f1w73tt4S18o8GGEkMkcGnjtiaUTaLYEukXX6uBNusmJm?= =?utf-8?q?pe0JP+LgVLAcIe0ZrVuxGHRIaRfGcF0joBEeArJpYXmFErhnBHA1s8en?= =?utf-8?q?jHQ2/HD+ucKeOtNx45GNraI7UCcleSFGpAm+wRfjJ+KbjnopJ2rcgBCz?= =?utf-8?q?oUfAMxufvyP4mlNNZNUbkSQKVx+JEXwqmBJeTcvvy2T8B25MR96x7uwz?= =?utf-8?q?lu3QSlpJhA8oxBriSU9KMet7JVf1bX4xzXRpRDQub189qoHSN90w3lc9?= =?utf-8?q?O/HKf0tafvkxRSnQtfX3GvDuHz+7qFwqUe1kX5TW500sPzGNlgj8RrRi?= =?utf-8?q?MRDFPY3l3C0Ih8wj59TuB5bu+vJ42ef6O75L8ppUDIFM8vtl7uUDxqQ+?= =?utf-8?q?DqjPC/HYxP4b7ZBnzPYAuID7clAmW5VDZQrxAABOrWMk4Mm659oY+GBq?= =?utf-8?q?KgdWGlr1jEkspW41BF1bguxAv0aQBhXFFX9LBU2oQA6MvkD9wFgmgNdl?= =?utf-8?q?5O8tDULXGEFokjKnCjJQZEJVUe2lEUWn9msKk4BITxtXyYFhMOGOtosq?= =?utf-8?q?oQNzcM2pdSvemp30hQIstqI8zgYvR/5t3AzqmEXOxjRfhvGHgcOpuMxt?= =?utf-8?q?sSR2u9keUNSO12jFWVG45Gg2yTsR8ra+oXGYA6AvjlOnUpyU+uKvU6pD?= =?utf-8?q?CFm509a/tgO7/APvX64ABrVt6KYoMFbM2bNrH9OZSicXCBWVF2KZDr/S?= =?utf-8?q?++wrXr8WjsIhOWlSPUOsQF0CzmGMvuTkzcXSIMtJ4bUHKuR38MRqt7eQ?= =?utf-8?q?hMc9g+lST7KhXY1I1oi0CQ4Z+8qMR1qc/LpX+h/H+Ni97qvL6oqu4AjV?= =?utf-8?q?5JrYv/Bm8bfJHEP5W6m9i52W8QLFxtz3GlaOhiV8xlPV7zWwwJxlrgu/?= =?utf-8?q?u9gqtZOVo=3D?= X-Microsoft-Antispam-Message-Info: obz7RoeEMsNaZchvwB5uUK21UXxlznNq79oef1xic1wC8fuv0YPGpk5uOy+RtgSUJQ3HnhWy7AIcP9xq6c8pJ00Z4Ghi97QQp1RatoqFxU1/LfiMzJ4B+5cyxierU2obw+mjMwXnJKJbcGG590Q+JgiAKkOJCAMJvKQ+KKiw3fOYIg0afQVTDQDGMy79bgy41p98ABHlbXhkiQNYVaFQU1DuZSeGD7jBL5d/PwDBAbaiDe9kS+IwYaqkQZS4WzTeqVQ5C3xojbd0XyaG1CG47d3oyC+aleipO/YyM3g8pZU5nrBS2dS/1/SM1CuGLdzb964t6sASi0N91n4cjK3xDjOtM1xnBZWkK9bDbEuD3hQ= X-Microsoft-Exchange-Diagnostics: 1; AM5PR0701MB2691; 6:MrUlUV7GZ/Cz+FEnAh0s4WGoT7rHjYm9wPJ4BQiN6NUfwmST9alAOF5O9Jel1SbikTWdhU0MMiOpfqc1PgwJZhpUbE1YUdZCqMhdahEXoULdW/O2uASi7dc1MmH7SfSYpPiOMB8ODYrUnUGoI+wnw+krV5EuN25Rhrm42B6kmzR0kO4+mGiuQ1Rj5ojOJQzqiXiQbUQnWubOrfwCPnnvZRwb9HdPj0prnYRjBSjlZdnY0PsHT+RulyGERTNSwuKzBD9Tq7njprgflCi1hKhuocsc+GS0m6V7qbSaSlcup20MIj14mtUmGdk2nu4oudwh/dT2hsAUyQYksFNgrFYqmTmlmPM2CUaqHJAKQqjh9ereppuLWBiTb0Z66kMqXD+gj1a6ZqtUDvMHm+sp1PgAnYR6BkxPmUQylGQhUEIa5ncOg1+X7GlQU62RFzimhExESFySlldxKz4YBv3Co2mQ2w==; 5:8j3CG76Q4zNDTVYuJmbJMYoE7n+XkUDYONv1UpMlIzxJcEJPdyWq386IbVANlx6I4aWo6YNO5Bt+3Cq+uanrOvKBAdefEDa/L7ITKgIVq2yLRB0TJnUuD7XzrWfZnIVuMvwum/u8StC1CzEVSnxdBeSntzpRHqOXFdi2BTQLw4s=; 24:xm5+P71AtDkDOcug5DUn/mINqqm/fbqpxRV8naOU5D3s7qVad1C8v7H/WnxUHLmSiHf6+C7QrI64z8s7f01j5g6c07MXaWZumUtQQwtzVSY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0701MB2691; 7:e31spNob5JStMV4t95/5uOPWGieV64+oovB6X4/wMq4l5L3cypZ29ZDVhqi5XmGEf5NlaZntyaVpQpfP1qZ2zQ3zND0l2gK3FryfG1/mrPq8cHbJV5r5rKZgHWafXnXX+E2Hw5fMcrvRJ2XSfCQIPxKvgjw4/Fb6gLqTPX5NGHnsIS+7F2xhaaI0YXCNHjnq2zS4f4ij1ne2uny7iKZID4vVAVcRGQDOlpeKHP3JVx/wA4OD+7mVSXV9xtodKzjt X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2018 16:45:54.2694 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c58289d8-ebeb-4563-b392-08d5e35ff123 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0701MB2691 X-OriginatorOrg: ericsson.com X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrPIsWRmVeSWpSXmKPExsUyM2J7ue79OfbRBpvnqlkcPb2H2YHR49nN /4wBjFFcNimpOZllqUX6dglcGVPf7mQrOB9dcfLRZeYGxm9OXYycHBICJhILV69h7GLk4hAS OMoosXRiExuE85VRoqXhDgucs+PffCYIZzGTRPOFGWAZFoEJzBKXDv6H6ulmkvj4ZRkbyGQ2 ASuJX1P6WUBsEQFJiX+LtwDFOTiYBQokOu4JgYSFBaIklpzdzQhiswioSjyZNY0ZxOYV8Jc4 u+kbG8SBchInj01mhYgLSpyc+YQFYoy6xPp5YGOYBeQlmrfOZoYoV5LYtfk+lD2bUeLZJj4Q W0hAR+LU8+usEHFZiaNn57BA2L4S1288YQY5X0LgNqPEl91tjBBOE7vE7aX9UEfoSHybDXIE BwejQJLEg5cWEDW/2CR2fN0NtS1fYt+CY1D1VhKvf31nhHngVO85JoiGVcwSqw88hiqSkdjT t5dlAqPeLCTPzUJ4bhaS5xYwMq9iFC1OLS7OTTcy1kstykwuLs7P08tLLdnECEwGB7f81t3B uPq14yFGAQ5GJR7etCn20UKsiWXFlbmHGCU4mJVEeLXqgUK8KYmVValF+fFFpTmpxYcYpTlY lMR59VbtiRISSE8sSc1OTS1ILYLJMnFwSjUwMgW5Oy3wc5B5emA/T3KjhaiE6JHyQ1aekS9s +H+oHkop8tHntV8tP1UoyE6hMMNBOWLfC9MZdvdPnhQ5qqd5yk3LNt8iUn1iwF375qN1ru/5 3/PMSv0aXuJ290HnPe2bN/x0Sp/l/tWtFp6XYZXN1j3BQDO2OnbKlIZ95hyHhB+kuu5U+67E UpyRaKjFXFScCACJL47IAgMAAA== X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00, DATE_IN_FUTURE_06_12, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_MED 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 v3] dpif-netdev: Avoid reordering of packets in a batch with same megaflow 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 OVS reads packets in batches from a given port and packets in the batch are subjected to potentially 3 levels of lookups to identify the datapath megaflow entry (or flow) associated with the packet. Each megaflow entry has a dedicated buffer in which packets that match the flow classification criteria are collected. This buffer helps OVS perform batch processing for all packets associated with a given flow. Each packet in the received batch is first subjected to lookup in the Exact Match Cache (EMC). Each EMC entry will point to a flow. If the EMC lookup is successful, the packet is moved from the rx batch to the per-flow buffer. Packets that did not match any EMC entry are rearranged in the rx batch at the beginning and are now subjected to a lookup in the megaflow cache. Packets that match a megaflow cache entry are *appended* to the per-flow buffer. Packets that do not match any megaflow entry are subjected to slow-path processing through the upcall mechanism. This cannot change the order of packets as by definition upcall processing is only done for packets without matching megaflow entry. The EMC entry match fields encompass all potentially significant header fields, typically more than specified in the associated flow's match criteria. Hence, multiple EMC entries can point to the same flow. Given that per-flow batching happens at each lookup stage, packets belonging to the same megaflow can get re-ordered because some packets match EMC entries while others do not. The following example can illustrate the issue better. Consider following batch of packets (labelled P1 to P8) associated with a single TCP connection and associated with a single flow. Let us assume that packets with just the ACK bit set in TCP flags have been received in a prior batch also and a corresponding EMC entry exists. 1. P1 (TCP Flag: ACK) 2. P2 (TCP Flag: ACK) 3. P3 (TCP Flag: ACK) 4. P4 (TCP Flag: ACK, PSH) 5. P5 (TCP Flag: ACK) 6. P6 (TCP Flag: ACK) 7. P7 (TCP Flag: ACK) 8. P8 (TCP Flag: ACK) The megaflow classification criteria does not include TCP flags while the EMC match criteria does. Thus, all packets other than P4 match the existing EMC entry and are moved to the per-flow packet batch. Subsequently, packet P4 is moved to the same per-flow packet batch as a result of the megaflow lookup. Though the packets have all been correctly classified as being associated with the same flow, the packet order has not been preserved because of the per-flow batching performed during the EMC lookup stage. This packet re-ordering has performance implications for TCP applications. This patch preserves the packet ordering by performing the per-flow batching after both the EMC and megaflow lookups are complete. As an optimization, packets are flow-batched in emc processing till any packet in the batch has an EMC miss. A new flow map is maintained to keep the original order of packet along with flow information. Post fastpath processing, packets from flow map are *appended* to per-flow buffer. Signed-off-by: Vishal Deep Ajmera Co-authored-by: Venkatesan Pradeep Signed-off-by: Venkatesan Pradeep --- lib/dpif-netdev.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 67 insertions(+), 13 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 9390fff..23cda57 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -207,6 +207,13 @@ struct dpcls_rule { /* 'flow' must be the last field, additional space is allocated here. */ }; +/* data structure to keep packet order till fastpath processing */ +struct dp_packet_flow_map { + struct dp_packet *packet; + struct dp_netdev_flow *flow; + uint16_t tcp_flags; +}; + static void dpcls_init(struct dpcls *); static void dpcls_destroy(struct dpcls *); static void dpcls_sort_subtable_vector(struct dpcls *); @@ -5081,10 +5088,10 @@ struct packet_batch_per_flow { static inline void packet_batch_per_flow_update(struct packet_batch_per_flow *batch, struct dp_packet *packet, - const struct miniflow *mf) + uint16_t tcp_flags) { batch->byte_count += dp_packet_size(packet); - batch->tcp_flags |= miniflow_get_tcp_flags(mf); + batch->tcp_flags |= tcp_flags; batch->array.packets[batch->array.count++] = packet; } @@ -5118,7 +5125,7 @@ packet_batch_per_flow_execute(struct packet_batch_per_flow *batch, static inline void dp_netdev_queue_batches(struct dp_packet *pkt, - struct dp_netdev_flow *flow, const struct miniflow *mf, + struct dp_netdev_flow *flow, uint16_t tcp_flags, struct packet_batch_per_flow *batches, size_t *n_batches) { @@ -5129,7 +5136,7 @@ dp_netdev_queue_batches(struct dp_packet *pkt, packet_batch_per_flow_init(batch, flow); } - packet_batch_per_flow_update(batch, pkt, mf); + packet_batch_per_flow_update(batch, pkt, tcp_flags); } /* Try to process all ('cnt') the 'packets' using only the exact match cache @@ -5151,6 +5158,9 @@ emc_processing(struct dp_netdev_pmd_thread *pmd, struct dp_packet_batch *packets_, struct netdev_flow_key *keys, struct packet_batch_per_flow batches[], size_t *n_batches, + struct dp_packet_flow_map *flow_map, + size_t *n_flows, + uint8_t *index_map, bool md_is_valid, odp_port_t port_no) { struct emc_cache *flow_cache = &pmd->flow_cache; @@ -5160,6 +5170,9 @@ emc_processing(struct dp_netdev_pmd_thread *pmd, const size_t cnt = dp_packet_batch_size(packets_); uint32_t cur_min; int i; + size_t map_cnt = 0; + uint16_t tcp_flags = 0; + bool batch_enable = true; atomic_read_relaxed(&pmd->dp->emc_insert_min, &cur_min); pmd_perf_update_counter(&pmd->perf_stats, @@ -5168,6 +5181,7 @@ emc_processing(struct dp_netdev_pmd_thread *pmd, DP_PACKET_BATCH_REFILL_FOR_EACH (i, cnt, packet, packets_) { struct dp_netdev_flow *flow; + struct dp_packet_flow_map *map; if (OVS_UNLIKELY(dp_packet_size(packet) < ETH_HEADER_LEN)) { dp_packet_delete(packet); @@ -5200,8 +5214,20 @@ emc_processing(struct dp_netdev_pmd_thread *pmd, flow = NULL; } if (OVS_LIKELY(flow)) { - dp_netdev_queue_batches(packet, flow, &key->mf, batches, - n_batches); + tcp_flags = miniflow_get_tcp_flags(&key->mf); + if (OVS_LIKELY(batch_enable)) { + dp_netdev_queue_batches(packet, flow, tcp_flags, batches, + n_batches); + } else { + /* Flow batching should be performed only after fast-path + * processing is also completed for packets with emc miss + * or else it will result in reordering of packets with + * same datapath flows. */ + map = &flow_map[map_cnt++]; + map->flow = flow; + map->packet = packet; + map->tcp_flags = tcp_flags; + } } else { /* Exact match cache missed. Group missed packets together at * the beginning of the 'packets' array. */ @@ -5210,9 +5236,17 @@ emc_processing(struct dp_netdev_pmd_thread *pmd, * must be returned to the caller. The next key should be extracted * to 'keys[n_missed + 1]'. */ key = &keys[++n_missed]; + + /* preserve the order of packet for flow batching */ + index_map[packets_->count - 1] = map_cnt; + flow_map[map_cnt++].flow = NULL; + + /* skip batching for subsequent packets to avoid reordering */ + batch_enable = false; } } + *n_flows = map_cnt; pmd_perf_update_counter(&pmd->perf_stats, PMD_STAT_EXACT_HIT, cnt - n_dropped - n_missed); @@ -5299,8 +5333,8 @@ static inline void fast_path_processing(struct dp_netdev_pmd_thread *pmd, struct dp_packet_batch *packets_, struct netdev_flow_key *keys, - struct packet_batch_per_flow batches[], - size_t *n_batches, + struct dp_packet_flow_map *flow_map, + uint8_t *index_map, odp_port_t in_port) { const size_t cnt = dp_packet_batch_size(packets_); @@ -5379,6 +5413,8 @@ fast_path_processing(struct dp_netdev_pmd_thread *pmd, DP_PACKET_BATCH_FOR_EACH (i, packet, packets_) { struct dp_netdev_flow *flow; + /* get the original order of this packet in received batch */ + int recv_idx = index_map[i]; if (OVS_UNLIKELY(!rules[i])) { continue; @@ -5387,7 +5423,12 @@ fast_path_processing(struct dp_netdev_pmd_thread *pmd, flow = dp_netdev_flow_cast(rules[i]); emc_probabilistic_insert(pmd, &keys[i], flow); - dp_netdev_queue_batches(packet, flow, &keys[i].mf, batches, n_batches); + /* add these packets into the flow map in the same order + * as received. + */ + flow_map[recv_idx].packet = packet; + flow_map[recv_idx].flow = flow; + flow_map[recv_idx].tcp_flags = miniflow_get_tcp_flags(&keys[i].mf); } pmd_perf_update_counter(&pmd->perf_stats, PMD_STAT_MASKED_HIT, @@ -5418,17 +5459,31 @@ dp_netdev_input__(struct dp_netdev_pmd_thread *pmd, OVS_ALIGNED_VAR(CACHE_LINE_SIZE) struct netdev_flow_key keys[PKT_ARRAY_SIZE]; struct packet_batch_per_flow batches[PKT_ARRAY_SIZE]; - size_t n_batches; + struct dp_packet_flow_map flow_map[PKT_ARRAY_SIZE]; + uint8_t index_map[PKT_ARRAY_SIZE]; + size_t n_batches, n_flows = 0; odp_port_t in_port; + size_t i; n_batches = 0; emc_processing(pmd, packets, keys, batches, &n_batches, - md_is_valid, port_no); + flow_map, &n_flows, index_map, md_is_valid, port_no); if (!dp_packet_batch_is_empty(packets)) { /* Get ingress port from first packet's metadata. */ in_port = packets->packets[0]->md.in_port.odp_port; fast_path_processing(pmd, packets, keys, - batches, &n_batches, in_port); + flow_map, index_map, in_port); + } + + /* batch rest of packets which are in flow map */ + for (i = 0; i < n_flows; i++) { + struct dp_packet_flow_map *map = &flow_map[i]; + + if (OVS_UNLIKELY(!map->flow)) { + continue; + } + dp_netdev_queue_batches(map->packet, map->flow, map->tcp_flags, + batches, &n_batches); } /* All the flow batches need to be reset before any call to @@ -5440,7 +5495,6 @@ dp_netdev_input__(struct dp_netdev_pmd_thread *pmd, * already its own batches[k] still waiting to be served. So if its * ‘batch’ member is not reset, the recirculated packet would be wrongly * appended to batches[k] of the 1st call to dp_netdev_input__(). */ - size_t i; for (i = 0; i < n_batches; i++) { batches[i].flow->batch = NULL; }