From patchwork Wed Jul 4 23:06:49 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: 939424 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="P8gRP+KA"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ericsson.com header.i=@ericsson.com header.b="PIuYag0X"; 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 41LPSy6YKrz9s29 for ; Thu, 5 Jul 2018 01:06:10 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id E0DA0CD7; Wed, 4 Jul 2018 15:06:06 +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 AA53ECC4 for ; Wed, 4 Jul 2018 15:06:05 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from sessmg22.ericsson.net (sessmg22.ericsson.net [193.180.251.58]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 3AE832C4 for ; Wed, 4 Jul 2018 15:06:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/simple; q=dns/txt; i=@ericsson.com; t=1530716762; 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=BsHuP/Enl9zQFVFs+R5jZRG+CeeKvvfoLAa0ZSD5/WM=; b=P8gRP+KAlqYLp6dnSA/l2hkZaoHU64SDQXLBEhLIaB4L/0yld8GcKQXmhqRF+Uu8 GziDNrBjeLXdQgAIqvFn/m2s3uTOtZO35ZBmDLfT0KijqlAk3aXiP3i4TK6aX7ZC XiqPuZrDvjOE8nrACsuRnmWh0FkzJngGEofXuHQ2oGg=; X-AuditID: c1b4fb3a-9e9ff700000079c1-ac-5b3ce25a9c7a Received: from ESESSMB503.ericsson.se (Unknown_Domain [153.88.183.121]) by sessmg22.ericsson.net (Symantec Mail Security) with SMTP id A9.D9.31169.A52EC3B5; Wed, 4 Jul 2018 17:06:02 +0200 (CEST) Received: from ESESBMR502.ericsson.se (153.88.183.134) by ESESSMB503.ericsson.se (153.88.183.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Wed, 4 Jul 2018 17:06:02 +0200 Received: from ESESBMB505.ericsson.se (153.88.183.172) by ESESBMR502.ericsson.se (153.88.183.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Wed, 4 Jul 2018 17:06:02 +0200 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (153.88.183.157) by ESESBMB505.ericsson.se (153.88.183.172) 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; Wed, 4 Jul 2018 17:06:01 +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=jlRFqc7SLcoyT8Kvl/6JusTa0rFnrp3U/12eA6IERaQ=; b=PIuYag0X37LPdGoeAIJNfGtJtLz2EiyTIKghU6FTuIwLFzwXk0q/QMazqVWKo9on/lG+brMRLC1h9iyCZSQCJ4qAsR3Zkj/Hi5+NBlYH6HNHv9Xo57Uj/h3izpBUut/XbgLqzZIUu0rpQioO2PGly+b5k3thu8iRqiCfTjJ1Hfk= Received: from localhost.localdomain (125.16.128.122) by AM5PR0701MB2692.eurprd07.prod.outlook.com (2603:10a6:203:75::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.930.13; Wed, 4 Jul 2018 15:05:58 +0000 From: Vishal Deep Ajmera To: Date: Thu, 5 Jul 2018 04:36:49 +0530 Message-Id: <1530745609-15522-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: MA1PR0101CA0038.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::24) To AM5PR0701MB2692.eurprd07.prod.outlook.com (2603:10a6:203:75::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f416d0fd-09a7-4a52-6492-08d5e1bfa69e X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:AM5PR0701MB2692; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0701MB2692; 3:rVsWoN23J/GsOXNqT3ghPd0473fcNTWkb5zwhn0akrqowFhL4ZJmrcwfMHzprsSDcaqE5mwvSS6KO8AQlq5cEpJpVsVspmvW6Tw7a1kf8MZRisK9cBdhBuZ8WxInKWBU2sAs/jNbGafcTzIANTzY3VpjiyjnB3sJoelR7W7oWZ9kWx8QckFEHFxvauAARWssjM7/XlpqID8O/iELO+0J3mwfi7ap09tTtqCP9FvcRXg3REp9tXgImgz1ETjsoaI2; 25:RiwKDJM7BBRAKGFzp9S6mYcDEXHLAFlvVdZ0lDfI7TEvDm8tH+pMLePK1tljBFwQLfHX/nGEeJskxGmd4wgjVmDl6EOmh8mB3R6UDx/D+rwAl3ZbgUQUJfBShcZSOzsZo4O/UhpNbqjiqSjoMmrv8rS9DJ6rmZVWHAWuC23FUF0rOATY003hodOxfX2w5VJJKM9uqdzh112ApoXNyWlsohpEsAyKp6emU1yZ/IwmLTW2qn4UBMk3rtw0kIAj/KsDkrO0SGiKDeSXpw/bCIvVy8ZwJjun0qCn4D0lpgIux3y2Zyw2nllQ1BZ/XosNNUOcB7TLBdh3M5Z+URGdM9pK/g==; 31:K4XzkTneVH8jCVau8alupmTy59pk7npj1uQtx8s6CgN8Gc+0rMYwjRMGYsQ4ZPjA8Sl8hIuazhfoV9v0MYUQwOwHJilwmVaUp4aUAGFILt/SMaYClxAbRJXi4zq0YoZWAc0twxbKNbyuJSjJPglAaYFCN8XD7tS7ofkM7N0nTZ2KAd3iuhgADIW8IoOishc6aai6Llkkr8XYwTgJyg0kXk1sY4gh2kmKASXrtSYsTHw= X-MS-TrafficTypeDiagnostic: AM5PR0701MB2692: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=vishal.deep.ajmera@ericsson.com; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0701MB2692; 20:TOFaCHx2EXp46zrRZg+KEmzf150khVVFIfK9J6LpaL0mTXpg/aQ8xdN9Ry4+6X1fv8YImbuH+QtejXRfb86aDqVTi190PVQTrE6iD5ZSrQrwJyqGfcWjGd3ZwWEnBmoCQBzpCV0lv0UlxR7fbVmjsB+eWjYxVOf1FvsgXXu6nGhFe80cVdPiKTB6uaYnrgGViPLKHWeB6n8k8arovostyJ+pK1UM8MG+ghnZRr7FwKeIayxiLB7laTXwNFtgS7tFE5DXpiGwwklFjyBhcEZIwDzTk6UqSgKQ/+HYuNXGL8Y4G9FRhMODcv3qDXRVPp3YWILqIqOh/JaVYO2jSbar0SXvMnvBMpR9X3Cn8M+bDmlcC2vV03m/PRwqmuejkVhLnNLUGfW+DVf0wDRFxrR80nKGtTWjEaXecJ5qZZt3B1oTTBIYQTiVBp6p6gYI0xQ90aHuSye6dBP3ufaom7Ph5sO+WmuvoN4K7F9WzZmMcz3YEuyq9xeRnFVl92BnHPSH; 4:KWB5Gs28j72ObdFg+M6z6wJ7+PgNNEKOreKVAWsN6qPRsZeVDs3tmL4KuLAZ0K5pCiWSEcUDxsGfy+A7/jUAsXHiXAIkx0N8laU+PIXhF2ZiP1mRDPdzG144pCnSI6JbNY3ogd2nGbPEprsmVRADuP85pKKLbuEca724uxK93x4lL2++yihkC4vLZ1VwXWVAa/xqDNCbDmDdbOsSn9kz8B8teQHAzui5JMbXf9uiDAPZk3+iD6DyNrbweOdQ2/tb8ZzDvG1E2CetbqjdL8ZarcOFPwRqW5TCG6ft91aS4IZN8hdj59gDRYX55ebx0L1Q 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)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3231280)(944501410)(52105095)(3002001)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(6072148)(201708071742011)(7699016); SRVR:AM5PR0701MB2692; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0701MB2692; X-Forefront-PRVS: 0723A02764 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(396003)(376002)(346002)(39860400002)(366004)(136003)(189003)(199004)(23676004)(66066001)(186003)(53936002)(52116002)(2906002)(2870700001)(16526019)(2361001)(68736007)(956004)(50466002)(478600001)(97736004)(47776003)(25786009)(2616005)(4326008)(107886003)(6916009)(575784001)(316002)(5660300001)(54906003)(50226002)(2351001)(6116002)(3846002)(86362001)(14444005)(8936002)(105586002)(81166006)(6666003)(486006)(6506007)(55236004)(106356001)(386003)(8676002)(36756003)(6486002)(305945005)(6512007)(476003)(7736002)(26005)(81156014); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0701MB2692; H:localhost.localdomain; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:3; A:3; Received-SPF: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?q?1=3BAM5PR0701MB2692=3B23=3ALA?= =?utf-8?q?KM59mo2PsBT3gSuimundA9685vUrRpUWI8mndZ3rMGkGyf0SqDGOmNve?= =?utf-8?q?pRnXXFpswrRUxoiLacNhAxmH/PkWff66IjEkCELukWIeVTAOgyDrontN?= =?utf-8?q?BiWgbA1j7hozpS/jLijGBbgextkbcFmapv6rr7Va99z6Nz4ju4xlkJD5?= =?utf-8?q?N4BQ02Mfzj77tZF5Nt0F68Tgqcr64hWyt68ZRrwm98GGBGFGWHoAUliX?= =?utf-8?q?u9sYxwjcFcpcIH4LAqeO84e2I9zXcohM9cyMftNL8lEwXAeBblfWIcba?= =?utf-8?q?ceS+g8BONvxv//EN9Num40fUQRI0H6OBd4GcxXzEWs8Dh7S+i2mGucm5?= =?utf-8?q?vNbwvCOlRI4SZdLmyAaZAOlluLBVQx8PrMLwgQjf9QwlWcS7GhjHE1ue?= =?utf-8?q?JrdOA1GA/PrRX2YAADlUQ7gDn8GYTJ8NRXZFGUgRjB0hElzuBMaI8fHH?= =?utf-8?q?2nW+RHeHdkVqV2dTsD04AIlUs96VS+1vknWk6MVYorrkKu9VCwCngqVE?= =?utf-8?q?l5N8vNmLVZDTFNUg8CHzJcLt4GXWdx3cII08ePdI+KS7IkJebNEdgBln?= =?utf-8?q?fpxiV3fO2pENwEx9TTZwKRnzm4pm279BlFAeiaTdvbXei67I7wfegnrw?= =?utf-8?q?Sk8YRp/3yC0JIB4MxRZpiNkFtjaWqj78LPU95KIw8dBIryMS9WECXn0G?= =?utf-8?q?3snuL14pDKs0fyfY1BR9S1lsjwpIam8TLW8ktYu5US5G7DGULte7j3tv?= =?utf-8?q?CA80ochqCgTNeXq4TWTjGxsiESOYG7pexIp9WUZ2m4MODhjWZk8ZqJb/?= =?utf-8?q?KuofHE/jkQONt6GA/JnDHSxM3plBl6O1nP+n6hIn9XbDNdQo6gZkCWj/?= =?utf-8?q?UpNPxSocfPzNKX88r3K0HYnCfvv0mTQvpVipQzFcJHM8LhJDwIRp+AGX?= =?utf-8?q?N0oW295JBEmLeIyXu8U5mjHJfmDnQFbb9qD1yoK9LGQZosHiDcTnGveY?= =?utf-8?q?WUDO9w4hla7uPVm5olgvGDuzzx69xkDeZySCT8qKwlJZeAr6YzDVUdjv?= =?utf-8?q?7D8tx6HbyRoH2ArzheApiSWLtUHhX/yZms9XBJit69eD6RKB3dyhH1Us?= =?utf-8?q?lAYecbF6cSn3rU5F7CI1o7axsPDt/PQVky4ZGxg/rWeaVl8Nt2sx02DV?= =?utf-8?q?5R+5QnWJpF8AjzoEuAl6oy10ITTZQ0Cue/c8Y6AIucRcabOb2FgetDLN?= =?utf-8?q?iDdtDyuWj6jzze/17laHus7SHjGOShZu6KXzQYDmaaWHf4lsDfvtsK5+?= =?utf-8?q?vLlnmZMr2TO+LldhTPDPm3cQM=3D?= X-Microsoft-Antispam-Message-Info: upfuWLSx50XnVnigrNN2fcDrrWJK06EzdrBM1x45JTGlM8+g1PKtUIFmRlufFZ4+zdZ7pm0IQGrV6RCa/WSluGnFZdtGO82+akPISAUg7+L3omLE4X5v2oUoJFLj8uVZQYLOa/ArBi3aOg8wDP5wcmUyRlfkJ0K5d9+esw1hjJijXkvIcNfFLcns47TN/yD3KCR0sskZ1oqM92UhaLTOQsVKTIQZx0qG7gpOug8GqNreuGZUETR+Ld3TanYj0a3b2QsxstUoH6ciFqxynhw0KgOFF2ol8M5F4d2MUIrdxyd6PyKpISNyvEFEBt03QfreXxYL/bnKkqAzRX97xdHh7rHyZlG16KEXexqCGl1oNV4= X-Microsoft-Exchange-Diagnostics: 1; AM5PR0701MB2692; 6:snfEem2RwFQ+QUPbk//wku9HbSsgJQvCD3eYFPYjYofOD0dYU0HtP12cGN4qrtFPFI0byJDAS7UFJmhCizgkdpaCRu8bKDHdWVg0Pz4zhVS9oydQDcKl8Tg7vr7RmbI1XUu/JQkbwq7rhs10S0js+AbzxcYPqTFB5zJ0H24rqtbShzjBBtp767p5ijizuepO1Becyq0218ahzvjL2S75oURER3EPaX3JXXKB5A17Orv9jC3nWkab4OCaAz2hcKN+3i+HwvaVUMXOZk8fgArR1oksUeV2WIZwtUzG0+RUmofwyrVkWLo8UdxK9uhRlElQ1tzzrfywfZgudImVTa2PJw7S1SiNkzJ969hImRfOyzOguJ5N93uHEUXFwNPyuai9SD3jpTjlSa8otNlrfDhAR33urOtlv2AynDTDyOXSXsDpjUsaTSAYO8FNQ+GStlmiqGNbOFUyCRuUE/jaShZIiw==; 5:hIoDUh6YIPy2zzoSSeUCI7MxsK+h4RHwqDwNB/u1n/ksHAiovZmRdc9u6cJ0plnQDw5JqKijna1uTCD6ne5+YUAKFVdIJYuEHvYoIM16JIaqNfOoKUBBet/CTDdgjac8S7xqHqtKRq1UrRo+flgLz+/2lUMBczvGVHOMG7yUSak=; 24:r/4+Jx33jzpU6SRK/HDPfk2zFRmZncnNXsdMNT7gGljYlRnXV6LG6w5VhToLtb1TA8SIyhpvCSWk9WH+bD6plRzSi+jVEYQrwvxPUu+LW1M= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0701MB2692; 7:ezzZgxs6e6XwdFQEu7ft5l/z83A8haQIt+TkWjkJVO5vc6SRLmzCmoRdAF/uNyv6ytid+fUvWbefDkeHGZ4s9WKmL/ZZ6eBgGIrxQbr8jtnzlLhGUfEuz3WmPY53gG8A6WbtBqTKexaE8nKWIz07gpRE/EKqWb+e3beo6lrK8uVnFwjQ/CIw8nBQcCiTla9s3T2L6X0f9h1utVTBFNsOxGSpQkECok7YWUCpioYWObbk5zAI8nvzN+1Ba00dLUd8 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jul 2018 15:05:58.4417 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f416d0fd-09a7-4a52-6492-08d5e1bfa69e X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0701MB2692 X-OriginatorOrg: ericsson.com X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrPIsWRmVeSWpSXmKPExsUyM2J7pW7UI5tog6VnlS2Ont7D7MDo8ezm f8YAxigum5TUnMyy1CJ9uwSujJ7dF9gKnkVXbHt2gKmBsdu5i5GTQ0LARKKn6RRzFyMXh5DA UUaJvpkTmCCcr4wSex7MZ4Vzfr84xQjhLGaS2LxvD1iGRWACs8TaG/+gMt1MEtfvNrKATGYT sJL4NaUfzBYRkJT4t3gLWxcjBwezQIFExz0hkLCwQJRE07sj7CA2i4CqxIfDuxlBbF4Bf4nN V/+yQxwoJ3Hy2GRWiLigxMmZT1ggxqhLrJ8HNoZZQF6ieetsZohyJYldm++D/SMhMJtR4tCa 3WAnCAnoSJx6fp0VokhW4ujZOWBzJAR8JU5v0oOov80osX7yVqjmJnaJC3MvQh2hI7FxyTUm kAZGgSSJBy8tIGp+sUl0vDvPCFGTL7Fq3jEWCNtK4vWv74wwD5zqPccE0XCIWaJ/8XeoU2Uk DjTeZprAqDcLyXOzEJ6bheS5BYzMqxhFi1OLi3PTjYz0Uosyk4uL8/P08lJLNjECk8HBLb+t djAefO54iFGAg1GJh1ftrE20EGtiWXFl7iFGCQ5mJRHe6s1AId6UxMqq1KL8+KLSnNTiQ4zS HCxK4rxOaRZRQgLpiSWp2ampBalFMFkmDk6pBsYN9Vyfn8yZyyXEeGnWQ9sJIj47+drzTbey HOl2Kjy6wjxmevxe18SJu11XHxNd/+/aKYHdKf0XVS/eFXzGvOdPY5CYZ0mmdueBKeW9O2T5 fx0Uec1dPnFDT8wPYY7fMuVufIY86/sXLggSmvPO8IqXgVL/86o/FyTT595wPDhJU0c7aVEl 0wIlluKMREMt5qLiRADevlQJAgMAAA== 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 v2] 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..b0e3d76 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; + 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); + if (OVS_LIKELY(batch_enable)) { + tcp_flags = miniflow_get_tcp_flags(&key->mf); + 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 = miniflow_get_tcp_flags(&key->mf); + } } 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; }