From patchwork Sun Jun 17 02:21:51 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: 930375 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="DQTeehJd"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ericsson.com header.i=@ericsson.com header.b="JFrPZQXX"; 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 417QfQ6WyLz9s4n for ; Sun, 17 Jun 2018 04:21:18 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 7D356AD2; Sat, 16 Jun 2018 18:21:14 +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 3DC5549B for ; Sat, 16 Jun 2018 18:21:13 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from sesbmg22.ericsson.net (sesbmg22.ericsson.net [193.180.251.48]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id C7518787 for ; Sat, 16 Jun 2018 18:21:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; d=ericsson.com; s=mailgw201801; c=relaxed/simple; q=dns/txt; i=@ericsson.com; t=1529173269; 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=nRpfGCsMd9uIuw14OfsBxdfL6MXGI818LPSMPma8Pag=; b=DQTeehJd4R11d4MyUtFfk35hgq3zrz7uI0mkleOTFDiHuQtPDgb/s7qJuvYrbATw K8ebBK9q9Lzkpu+rw/46hGV5c63+O5wUfHO2MvkyXpTTZ5D5bqMtOrKzh5Hxujs4 7o/84cG585stxMEXPQiAJkVfBLTH2I8lCsOKFbBBAEo=; X-AuditID: c1b4fb30-925ff70000000a77-6c-5b2555156ed5 Received: from ESESSMB501.ericsson.se (Unknown_Domain [153.88.183.119]) by sesbmg22.ericsson.net (Symantec Mail Security) with SMTP id 5B.67.02679.515552B5; Sat, 16 Jun 2018 20:21:09 +0200 (CEST) Received: from ESESSMB504.ericsson.se (153.88.183.165) by ESESSMB501.ericsson.se (153.88.183.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Sat, 16 Jun 2018 20:21:09 +0200 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (153.88.183.157) by ESESSMB504.ericsson.se (153.88.183.165) 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; Sat, 16 Jun 2018 20:21:09 +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=fYKO7ykv74L+L6+nb+8SrLorzZ+xEtYGBbd9XKiZ0FU=; b=JFrPZQXXFvbtywasIpbjed5ijo2HZ+hBx/B7vDnirnprKhD7gJ2cr3ty3oj9HaoMfvhhl35Gy+x76cDVMPOBiXjWMk517feHnZlahGazLrFFrhk7SIQA5svR/agPwBBNBPrW7ccVvVyE55szJ7bg8mlDDzF/ZtE2Aa+QoNbdG5I= 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.884.15; Sat, 16 Jun 2018 18:21:07 +0000 From: Vishal Deep Ajmera To: Date: Sun, 17 Jun 2018 07:51:51 +0530 Message-Id: <1529202111-20855-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: PN1PR0101CA0064.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:d::26) To AM5PR0701MB2691.eurprd07.prod.outlook.com (2603:10a6:203:75::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 43296ac8-e60a-4c76-22f1-08d5d3b5ee0d X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(5600026)(711020)(2017052603328)(7153060)(7193020); SRVR:AM5PR0701MB2691; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0701MB2691; 3:ETct7w8/UenxEtMsoDebchh92WUCe/eCK1p3BvWp+JGpry7lJ+h+ZbHzXv1vpmH2dT8CuSIut+iZHfPcLoXF/ADfpFx2h0ZjFceWlDFqdj80hnS3gogFu0YBLqwMMLaKL0JGP4tRFlyR9hTOWQLIAbSU9Xwh62jNGVngij/Ae4kgnBSkSctxBvPwSnaFzlTRWDaf9WJVTBlxCkmLgbutFx9LpakH5c1NjbKj1JNIWkuEraK5cs72ku//oJ3/pRfT; 25:5m2cR/06bvR7XkMD7STQyehaYzT99Rydp5kZ21qJF1ury+d51XaugVv7wyeaaZGeQYcXMLAAzhMILYL62yccFs/NVG/h6xuIGjnBlfiGs8/D/cG28kCaK64f7/hyjyExKdiCi3JfbHoJwh445EiCyKuHaRZLdSrE4NnLG32NX8/Zy1oGPAV+G5EaHy64xERmiKp0eju15q3LnQftaLlf/UEbcmelDUdB19gNnpalyEO9POyU3uNTZKyd0FD60OIg/jNdRj8V6FUx8G/Kf5zvn7YZRrpzgpiW08DLi10p7ClFjsOTsP01EK6AvQYTFjkV43E+/KrxQOALy0ZGP0qB9A==; 31:z+8uUOF7Z6RZydKAePYCHKt1SHEV6JxziKt6RXNX4mDWFjoV4ABBLq/bQwGOe3RYF6/Q59q2HkQOnf13dmmeA2cQq1m8sEtgEqD6Pa224xQDMu3efeUy52efT84fPbfM+RMx1vBHRgom6wrHCS72smZhTTmp5ljJP5mu+p0MfUWzhkMQqM6808V/pb9dlSjVKTXQiGWzBVWhcEOMKOFTLYcvrd8yTYsKdUfQzxsaw6M= 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:MjdklVoYOmaBd5S2PYTOQWfptM7k34XLCCJ9VohMl4NjZBGvsCjKcERmAsiNd/Nb7Mcj9YAPfASzjyioeexPNrwBV/xw41W9ZpWULzR1Sm4Km2EuknS9kd2gg9E7GLARHr5zADO+z6MtLDEyS/9iBNlqkg4nEXksAtUfQ6mpElIiuw3B8SAJoaJSzNOPIAE1gram/irOrFEgVzTes96LWCYqIp0QNHDfHgHwy11vZ5yX3tA94p1Urpsx5L363bPcZ8a7YhaYH5x+ij/6yzA7hDto2VRKSx3fdjJ7vvwCLrWIGJ0isc40gUiB8sr+TcsaVFDIQue1AGR8aP/CVVkOKX2qBK1e2g7VsAXBsO5QuHJ87Yg8m/MxvJph5VBQQZaxeNKiQE4VfyGyj2lKtmNyQ9A/64fpxMPqWqZGAOgxBO6lv9Yv/b/Rx3kDnY5wnV/ch7HpyY3Io2bZ1LJTmqawOeALJccPO4OEfDkjQfM3SLlhWfn6arqB0suRKNlkpwsJ; 4:GezK89+/v3oHG4gQyshF1FFwh8kLfBrTL9jq5stvzpiSxHoceITBf9bnV4y3VfEjDdMi2XGOYsXuTC4S6MOoMoLaLcpixj+gEGYIWRAn3i3pxwqPGewNRs6QdFtR10z3YCF4ITiwwF8sH/i8tg/V3BZ/yJASdRtFXSpzuzen0HsVAbOKvLPjJoZT3oadrcEimufaWelwPPyJaBZUpGtfjmJQbP44xP165DcfFUEvs9IgqOchp4XyWY/JiRhw4G9Br/cJsVrliRwnoeeQ7BAY6i9iOdpkzPkhLkXnLhA5trdK3KqxRZ0uv5+EMfVZNeRm 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)(10201501046)(3002001)(93006095)(93001095)(3231254)(944501410)(52105095)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(6072148)(201708071742011)(7699016); SRVR:AM5PR0701MB2691; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0701MB2691; X-Forefront-PRVS: 0705EB1700 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(366004)(39380400002)(376002)(39860400002)(396003)(346002)(199004)(189003)(3846002)(6506007)(55236004)(53936002)(1857600001)(6666003)(478600001)(6486002)(386003)(97736004)(6916009)(305945005)(2361001)(105586002)(7736002)(59450400001)(68736007)(8936002)(16526019)(81166006)(26005)(50226002)(186003)(6116002)(5660300001)(106356001)(81156014)(6512007)(2906002)(8676002)(50466002)(2351001)(316002)(54906003)(4326008)(25786009)(86362001)(36756003)(66066001)(47776003)(486006)(956004)(107886003)(52116002)(2616005)(476003)(2870700001); 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: =?us-ascii?Q?1; AM5PR0701MB2691; 23:PP9S0Pja9NuY6B6mtMLWOClF0fVFBmVS7lcgc2x?= dES/VrGdmHan3eRCXTiEWMzZgb5Q4nudgmD38ZyXj9dFreOC3TSJk9Y6gAMpD7+6cRrS3R/dWCrO9w3ucfm9/ggciFwDdsIVRETYtvHEj0qJJPcryYI0U/QKeB2jIcT9lW45jm3fZNYhbuuCwXtSVL1urxPdjOgFBMVo32EvhQps6hY1jp74xvsYYtgKUDFg64EIOameX1HDQ9Lj6PiVx6oM12OYacXYI2sJmmxpJ8h+cbl+b4VtzMywPIJ1z+GPZ2sHi8IvwsT6MdRXSTcz5BYmRuc/vT1uPv/6EaWmr70T+YdXFMSmKqc1WuwJXxu5S7wabMzeWAGCB3i++BcfFmFqrM4jj3WCZlTNjEFJ2OTPEPdYpFo27o5ujBaqQFlbPrlHuMDYfb3DVKq05lQ9wAgEGiwKNWB9wifmagKT5w2p9FdOoqqwCD5ZJfuyX9Vv/Ax7YKIZCYF1dmyU6XNQHJKXJ8JyeUpji/B2ziBjkji4R/Fr6fHJDChjGloUsbATssi/MICgR8gCd99ENX3408pBLS/ieO87iKz5ZjIsHgqyD8bJU2P6tNZhHaifRcc5PTc4VjvPhBI5i/qmZvo3fm5cIFytEiDLqCzI1jCa9f+uWgFZ4SMhxXLuftUwKQFGfXJU8bZzpsyeS3AOzXZ5SjKpQMeNzHWdz6cnF61E473jNxrhFK3gg5kF+Mu8IB36hYTn4RwIbp/qR+gdVolkBmeosTnHHuAqjtfL53IU9KwkK6R75UBNLGtupH+EcS0di1bcaOEX3J2EQMJq134bCaXBal7qVQi24S+2aUBmYYPsqziwy532ZWT240cR5VhYbor6jJseNcMOenhO7fLbEJzTlCBKo6d8dLMIhsQfHheMC9HVLPsNCwknTpnK4rPZScf5mN9Ow6ZgAFQic00isyeJWNpJ7LgGjvcYTPaCSYYBR5lqdGfZH2UIS6GXSpU6QHdENsxlzsSehLtqJFdjmL45iN0d7qJY9Q9h1fFzrFutXJRhydGZsup4hmOUmxeA2kPc1I2gEzEWq8Sij+DC6h7bLeMhyFqu4VM/kW0FJPEDMjh9nJtKU6ACMM4YrwEB4haNjYNzMF2iMfvZarJcl1T2ay6uj7SyMEWQLFC+A+I4YgCi7wPjga9b8sYdgVcbHayQxVJ5teFb3o/9/8kj2Osk/CFdpzEavYGSZ9j1qGEZcDAWZdT871IRYk9oV8ATagTs= X-Microsoft-Antispam-Message-Info: U+V1rc3eBXkoOcMO4qirA18/mNGXjTecHDMszJZP4U+QMB1WK4G1s10NYRfiHRIXfnqZDSOHvDcRSY2CODBYm7c4weO113vni7CVNN3ngWAi+SkTxyTcNSec1THk2KtyvGGladNX5HgRY8lApOdLI3jSfjiCkH+ImF4BH4l0IoGFZpPmQs4cWlAMnYBFE8Gl X-Microsoft-Exchange-Diagnostics: 1; AM5PR0701MB2691; 6:Gvdux8oi6D/bNgt6+YoN+lB8nNkf9zYzSbRENhDl+J6whVpP215i/MdUk8C5xPdVVb1Wgy4QHi8wv4/rCziash8g1vMiVNxQiyvgybz+t9QglTlER7DvotOoEFmfkK09HSJiu2cMD6t632xb+v0uK+uin8oYx4taYa1vq9AHuK/E/L1A5ybbIx/nEHrdGTvnWnUswTE5yWhmj07gH4tdg4uNI+4aPj1LuBxxjDyWsFlAp5q0LqPrgB96Z5kgm6wiEcmIHiN+bK33VQkA1X2vq3WIHhgRRp0WnP8tY5QEqPvXj6zfuxOtm7/fgQhIo82lFL0hTccAADB84v21mENLWYoj3QeWw4ceTGe4gGtsmxT0jyeL0voMhpeDA42FvmmlzhbYiNuBTch1TaUxgb9IsCKk+xlGhl0TpgbWxdJ8zTq1OVRUHlCUr0YXNHC+THY0XZ5F+fqEEuV94FOrtCYDKQ==; 5:qEy0KVn70iTCefTb/O1J6g78YtWBZ5cuCuRj4+C4+chVdL7CLw5hOGZpdq+tz8tpN4Sg6kYbUeBENpZpDa3Kd0zLhgYLTzZpRFDkNxp6ugHcpaDXqzfkRxzcnBaKwTTwF5FroOpvnIo7kp0o1Jo1xj5CBxl6MWORFXt4XXBmrHI=; 24:budMytKQwZGwLQLkJ3ckRJxdvitqOYkD6Ifel8gWUu6y9BdhDw4O74tkCf8elJ2P9SNUrcqkR5y9BYTUlKpEi4K7qDytRwTX7jPdu0Mqn0g= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0701MB2691; 7:C6lG5TmRHA2Nq7/VDIYQoyYZaVRnyF7zKbs1PQjWoZ19Wt0NHXu7Eks23JO+g2GDWxYmt71FR8dAe8nI7OHK1jBuxWqhqCudUlpKoc+F7LiZ++rCVvSo7WeJ3Nr5qMuRS1ukVRRokrmv1pGTFdt1n6QOUYq8AeNyfEAkbOo7M3smDJtokMwmIxiAl7cvbfrjlwtzIFQGDWfGPf1OhClVPQv/w2GQk7mwIOEBOzdbkbfOSs9j3G3eb9VCDrOpz3fK X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2018 18:21:07.1672 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 43296ac8-e60a-4c76-22f1-08d5d3b5ee0d 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: H4sIAAAAAAAAA01SW0hTcRjnfy7zOBr8O2p+aRYeG0SoqUSohBU9ZA+aRFG5h5p5UFGnneM1 okTp4ipdThOnRlEMs3rJhXfF5aSpW6WELTIVoiH1kF2UNp05zwTfvu/7Xfj94GNIdoEKYXI0 RbygUedxMjnVdLazNCrotFIVU9uRGG8Z6yMPo+RvjlWUhtLlBzP5vJwSXtiXdEGe3T/ZShcO qcrG37+jKlD1US3yZwDvB/1KnUyL5AyLLQhsA/O0tCwiWPYME9LyhABb63U/r4TCOhJ+rUZJ wB0C9No5wgvIcCK46msp7xyIt4PnsWnNl2FIXAi3vrDecwA+A0sLLkLyUYJu8P66pwKfgDmX k5Yi7QTriJ6W7lvB2vR13ZLEEaAdN8qkeRdUvWomJT4HPR0zpDcPYAOCuoGpdRKLI2HUOeUz DQOLrYWS5hRwv3kqkwRWBN0vqpG0VPrBiGnCx4qExWZvDIZBOANm5+MljksG073NhMQpgJ8O nY+fCN9dS2ijwuhdOyEJzCQ0GLt8gh1Q9ee2L+trGoz1NbQORRk2dTVs6mrY1PUhIttRkMiL GflZcXHRvJBzURQLNNEavuglWnuEIZM7pgvNO4+YEWYQt0VhT1aqWFpdIpbnmxEwJBeoEEt2 q1hFprr8Mi8UnBeK83jRjEIZigtWxKd2pLM4S13E5/J8IS9soATjH1KBGnsrauvSIviHSY09 DyrlCTP3+tw1XO5wn1655NZnHGA9q8uhg5+H+o+lPD/nTLja3zk6GzZO3SAjj38wRTxbwfw2 20S941A4YQz4d6265WTqox9vf8tXuhd6ow2e8Mm44r8Wx1yw/crNBldsY9vHUnPbqT2f7A3l lwbGrO3TZRwlZqtj95KCqP4PfOnDbwQDAAA= 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] 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 | 79 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 66 insertions(+), 13 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 9390fff..2c423ed 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,30 @@ 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; 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); + } + + size_t i; + /* 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 +5494,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; }