From patchwork Mon Oct 3 11:49:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Elo, Matias \(Nokia - FI/Espoo\)" X-Patchwork-Id: 77213 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp1622421qgf; Mon, 3 Oct 2016 04:50:44 -0700 (PDT) X-Received: by 10.55.110.199 with SMTP id j190mr20896668qkc.203.1475495444190; Mon, 03 Oct 2016 04:50:44 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id h189si20319268qkc.0.2016.10.03.04.50.43; Mon, 03 Oct 2016 04:50:44 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE dis=NONE) header.from=nokia.com Received: by lists.linaro.org (Postfix, from userid 109) id BEF6360D1B; Mon, 3 Oct 2016 11:50:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 413DA60C43; Mon, 3 Oct 2016 11:50:04 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 3443960CEC; Mon, 3 Oct 2016 11:49:59 +0000 (UTC) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0133.outbound.protection.outlook.com [104.47.2.133]) by lists.linaro.org (Postfix) with ESMTPS id E310760C43 for ; Mon, 3 Oct 2016 11:49:39 +0000 (UTC) Received: from DB4PR07CA025.eurprd07.prod.outlook.com (10.242.229.35) by HE1PR07MB0857.eurprd07.prod.outlook.com (10.162.24.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.649.16; Mon, 3 Oct 2016 11:49:37 +0000 Received: from DB3FFO11FD006.protection.gbl (2a01:111:f400:7e04::147) by DB4PR07CA025.outlook.office365.com (2a01:111:e400:9828::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.649.16 via Frontend Transport; Mon, 3 Oct 2016 11:49:37 +0000 Received-SPF: Pass (protection.outlook.com: domain of nokia.com designates 131.228.2.241 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.2.241; helo=fihe3nok0735.emea.nsn-net.net; Received: from fihe3nok0735.emea.nsn-net.net (131.228.2.241) by DB3FFO11FD006.mail.protection.outlook.com (10.47.216.95) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.629.5 via Frontend Transport; Mon, 3 Oct 2016 11:49:37 +0000 Received: from fihe3nok0735.emea.nsn-net.net (localhost [127.0.0.1]) by fihe3nok0735.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id u93BnHAO001129 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 3 Oct 2016 14:49:17 +0300 Received: from 10.144.19.15 ([10.144.104.92]) by fihe3nok0735.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id u93BnHPT001104 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NOT) for ; Mon, 3 Oct 2016 14:49:17 +0300 X-HPESVCS-Source-Ip: 10.144.104.92 From: Matias Elo To: Date: Mon, 3 Oct 2016 14:49:13 +0300 Message-ID: <1475495356-4038-2-git-send-email-matias.elo@nokia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1475495356-4038-1-git-send-email-matias.elo@nokia.com> References: <1475495356-4038-1-git-send-email-matias.elo@nokia.com> X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:131.228.2.241; IPV:NLI; CTRY:FI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(7916002)(2980300002)(438002)(189002)(199003)(107886002)(8936002)(6916009)(42882006)(11100500001)(97736004)(2950100002)(92566002)(50226002)(68736007)(36756003)(81166006)(5660300001)(15650500001)(626004)(8676002)(110136003)(50986999)(81156014)(76176999)(47776003)(106466001)(19580395003)(87936001)(356003)(305945005)(6666003)(450100001)(7846002)(586003)(33646002)(229853001)(2351001)(19580405001)(5003940100001)(189998001)(2906002)(48376002)(50466002)(77096005)(32563001); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR07MB0857; H:fihe3nok0735.emea.nsn-net.net; FPR:; SPF:Pass; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DB3FFO11FD006; 1:N+Qn1P5bWBnBMjZxK4RzajgHuiNMEKFhm07bXZCODe0xebloZU5+fcXrGV9nhVs83l4TtC6vV4lv+QUzV4P3CBwAHuj4AoRBUs3rPJlkkB3Dh+gXsuoPToN2CY4lSMWmkKo7Icp5bg2FDCtHZ4+na/hDg53BbWUx1zKj2iI8vcwGw0nT8DuddkF6Nm2b8DTWQA+2AOh+kWiDlSK5VlMi7g01JwxhLu1GjClHjB2l+EQySlXYPIDJpiY2WEwLItQBcbxOsFPBfE8vOOSyevtdfawxZt3hZbuB8t0kXrWNuV8bJxgLEvtn9wVZO0DaZEG7hafeZ0UMb6jVyAmeXz2PucrM+yhwUlW2bb2ixIanXan34aEc4H2rlQNQyAnt9cB6mna9LXmhmMW6e5e+YJL05RvRf8ISckVoj1yqc1hngqfIK9sBVm1mXym3f8/7MY1J7EprkYh/yV+J30z1VRtKuL4fNEghjaOOYy6on5Mt8Tk= MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 2c0e232c-9c90-4eef-cef2-08d3eb835a4d X-Microsoft-Exchange-Diagnostics: 1; HE1PR07MB0857; 2:/migetuvW/QN6NhmYFtEC40cjOdquKQ1XS3KjfPDHN+ln5BQ9GJMECbJsL3GB24BlUtj+ezUX8y+th5rrB+mjsGDoG8wpM3vbq1iVq6h9bVrgOErMRsST5/iQpMn9Q7V6EcSg/NdDhvMvIUHwdcu9X43Ned4ndjVvMd8OrbhzWj2ZGEtACck5U2gXIJA2/boDvPbG6STchMR25PIalrLnw==; 3:XwdmqeDnKHZgqo4nkOFI8Rb9z/b4RZ5GgZK5b3j4mwfD/PWTvI/0JAJp2Hpqqd7hk55Bi+bXu+S6rIW2lPCe1WAZ22FSq2hiazhhUWWQ3fXW/yUbMqJmzhYORFzGCPi9oPvYJbOR50xXoSllRB81/rfvHsac+/76QZkoAvBNewj+zJVUQJqggssDcPOoRI/aYy1x+PmY6c3veFxhUu76LBc9lldZj+lAk/Dg07Vcm72s2n8nB57AHd/237CCKs2euj9a5xuicZHPgxc9OzW4L1s2DWMMHXlwqkS1nkdUJlA= X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:HE1PR07MB0857; X-Microsoft-Exchange-Diagnostics: 1; HE1PR07MB0857; 25:wLx55FMRVVhy74ulcTMJeYJRcJe4rDodkit13xgqD/7hwF/0uj7ui3ryddiC47REZvDEZqi/eSAkzNUmtHOZ1dDt5tGtz3mP6FS1p+G9TWa3GJKTvuMEEXkgoLtTA3tDZDtfs8pUDq718WckgW+TdcaEsr2lcji3hnkyZG8+xi1e9LH5Ae8mtehw1QcmUfds6TJ3nlZWVXuE3Ihe0u5XzrchRhVkRCg9z9RvzfiLkVQfhc17bt+3No1TknB37k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r8Orpe5+CigEcf2feautJ1Umo6JUGRmuW0tyxnfnW8O6BRX92Gkm1su/NuPY2CUt5v0351cO8VAwLyUE+KV5esF3JIv/bYdW4Okj/8idfXFMpTMy+zP0gIUNuAG4v28c0GQC/RK83hl+aXaY7r3V05Uh8vDz4hbqQ5y+kDik5LWUmn32NmwFOH64NcZ83E8j8uiPbFgLosDKEbfwxki49zOkFSz2FVrhQ6Zd4EjfI1K9GRUN9z5LKNFi65CS2KCwOhmY7M0AF8fwdY2mozX2C8z8eoEQUDawL0Ds7OjHlbtDh7xWd+KnubvNFzp3sQHppjKTlrON6gr5rBEWykXXzVloZlONsZuPOYozBmSCqQpu1l1XiCdzb043oY8zUtCk= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(82608151540597); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(13016025)(13018025)(5005006)(8121501046)(10201501046)(3002001)(6055026); SRVR:HE1PR07MB0857; BCL:0; PCL:0; RULEID:; SRVR:HE1PR07MB0857; X-Microsoft-Exchange-Diagnostics: 1; HE1PR07MB0857; 4:dILQodkmpPAdotcOw1SnJnTM2I0ydKSqrgJ76HiPqer7HmZXt0znQxJRbcmEuCPh7Z1SAuW66ENqahpeK+s2Q2B/Cu+BMDLWHr01YKWcHCtQ84+kjwpajszZ5YF9l0uyh6Fj7jdcUXv+okfDjdgZBqWZV1zWH4j1yDeaZvZ/G7uVdiMDAZkL5a4d0/giiM9Q3DXVfns2oPS6NrZDTMQ+nfIApI+8ACMBW6djLnXapI94jaTt3XK4RtiMKPGOumIxUnlQQR7q7+d2l7cK/vQ/LhNyoz3ilyeHWfgEhRmKBNuH0whrlcYwCeprPE40OElTL60PeTvTYrXpoawIa3j1bwNI+raMtg+tccjVAmOgu2cya1hz0dz8e2YrcU6W9chYN2oIH9Oxs/OPaBAjAmZncpKO+aGtpMARaj5zyZa9TsbTBbZqad0ntcVkYJGmIkakMIVpWNgP/yKUfGZXLFHwKRcJ6pIUgiEw6KVM0lAhf69zV+tesWOi4o0BEe12kXvr X-Forefront-PRVS: 008421A8FF X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR07MB0857; 23:+PTHNce7WsMIUgE/0T59IDfT5iXA77q2KdCJ98Odh?= =?us-ascii?Q?ZyfQKURRsZ81qS592EX9h/iOUsFRnnrB3RuUoJX3/Dtn+h9I0eyvN4rrEhtj?= =?us-ascii?Q?ndPKAHvT8LMQAZAJprqW+LU+UvzmNvycji4/TYQe8leU6cR9oXsQBVh08VDb?= =?us-ascii?Q?jcjIgyFD7vhJje79rfpBwGvxSaKMHUJo6JRo9D4gz6znpqgwTa06j/FxP8qS?= =?us-ascii?Q?MWnc4vgqEx52SZ6jiWue/tgUflYj90c9xEkPrIiMOKVdByyA90idWcnPqMTq?= =?us-ascii?Q?Xb0P/FFNtoXHLn8nPYhg3ActTy7lrfKfm7g9w5lW7j5ia6fak2Yh7u6I8PGt?= =?us-ascii?Q?g10ZwK4dFcK4TY4OCQEdpy0jOos6SCBXD4EeiN51qnS5V1FBXb8FGNOjSdxd?= =?us-ascii?Q?otDOxmKuFwlCAc5z2uQ5wnKH9keH/uaVQy3LTqij65lXP90UL97FlLBoEn0C?= =?us-ascii?Q?L4lI09ptHYXMY2IjLvo1RgSLppESbluNz+jZLUyLOOqBYjbFAIdzJrveyKCZ?= =?us-ascii?Q?C2sTfsGDge99kl6X8dLHgyps5H+OVtBIG5UXusV/Y82VIEguhVoaB6IJ2UEE?= =?us-ascii?Q?7IBEsTNPuQlAYRVCkxcHHiVwgJ/U7c+DdcVN1+2QX+frYoOtwN4DYTbQA30O?= =?us-ascii?Q?PZvW6tu8RbSh0MDaVK4mOSAWgWSk1noRgmXJCL5t8JpZNmmiIPZQByVb/1sB?= =?us-ascii?Q?eKVBdHOWObhOEkxsR4ZK5VycFsZGEanr77jcVddOUOm6e3sGDs0mH6nr9mmG?= =?us-ascii?Q?VezlqueG6hyKOa/EyRpSJcpA2ZPB41SX8YlVsqbV+sW9y/QjqswNJpodAE73?= =?us-ascii?Q?g3m74oCUIHooqioO5E/+I5IoipC0VLH+qPlY+5UQmZ+16fKGkF+i3b5rSipn?= =?us-ascii?Q?VVn8dA5IVn81oy2K6eUFlPlQ+l0/ljOamBHd21tevMtiWUgWO8JOSsy0ORys?= =?us-ascii?Q?Peq6Hu9xEl3Cbt/syka9XWaIMEUCOEfrURDTvJ/qqkaV3JuVjYZpldufWqza?= =?us-ascii?Q?kXupt2Z/3PtL8TyZ+LGZdbJtiSJow/fHUdZA4S8xi6RCoXygoxawdN5228uM?= =?us-ascii?Q?b3n+E2u99KIuFRogdUobzuwvKmNulqzNFkys6YzjSgNbWmYEO1ehJ2FrdKKd?= =?us-ascii?Q?erQa7pn7tDM6AE5EoypgmhtvGycwGQAKIxp0UgjqibtncBWLn0j+ZtKCeJlw?= =?us-ascii?Q?mq03MvhbN43Qsw=3D?= X-Microsoft-Exchange-Diagnostics: 1; HE1PR07MB0857; 6:EAi6W8n7p1YXJq40qnDpHKB28kLq4qVtR9yz9/X556BAVrmSOVRbeI1OdVVtAoUF3Px2t8KUL1ynHEpaBP/VGP8GErAlD0hdbaUhQTToLCbHmVPQiBo1VgdOYqNJSVlEkDYuJf2d3c03obJnThkX2zsiYn8hr10qgFYYDGTl75PWxShP4QfLCRQC1swxlCvknVL+sSHYYVztgeNKKFpFTVLGpQXA+qH/CskrxhqIl2N+b0OslZ27g8P7wQxheVtRWUn+u7MkDgWf9WIqrItHvpp1lz+fYUopZMw1CHMw9eO5rIwD6r25eKipSUSqCt2MwO0isKdifmj3YIhN6dyrcFucMDgnLkvw/5qEUm4riJQ=; 5:S4DU6Plj5eQR77oxcS3i6H+/Yi+l2CdMcYDH6wzAIF/089BJgZLFF9gwp2NlWcLg963JWoc61kaTeICACD43xFzr4DtvfE/PaFSK8VWTnEtivQvahtw8h8vLjSn+Xm3TlyXBemKHyj9ayTmdbuSjR+4D5nskpzPa6jZwtswd05w=; 24:F+joi2YuyoiSowgQZ4o5BTkKBhWINiZ/tk1lvoDX5azhcEYF7+J0u6uskv7QZZpQavp7mfFK48lfaAvFDizxmelNoJmRMR7eux1+jtmTpds= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HE1PR07MB0857; 7:helFPZeRh8VMrMisw6WgsD0YRW9A74brhruLzpD1y9504MJ4IO2rR0EQ/l5jqveEcgio2Ud3b71mrGJ7hLBVzxtdhxJ1reyy3N2xoY9brWAK+Sa1IVl+L6OVU2s5ddW6SygUaWXjZc040HXnuitK66eYHq/5/c46f7Zi4NFLx67hXLCUQDLg9jZzn5/orbLyvyEM1851n/qQYkF/DWcaHB/P8f3gj66jYHLqNr5bRkFKvvxVhWNzOzug4Siolcg65HQt1jeSM5KOA/dIVJ4XoF0YHgglVOTHPft/CpX9vgWeGviK0LICpndW9mW0v3pK083HU4lKUYGlGj4dVld5dQ== X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2016 11:49:37.5791 (UTC) X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0; Ip=[131.228.2.241]; Helo=[fihe3nok0735.emea.nsn-net.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR07MB0857 X-Topics: patch Subject: [lng-odp] [PATCH v3 2/5] example: l3fwd: optimize ip checksum update X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" When decrementing TTL the IPv4 checksum can be incrementally updated. Signed-off-by: Matias Elo --- example/l3fwd/odp_l3fwd.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/example/l3fwd/odp_l3fwd.c b/example/l3fwd/odp_l3fwd.c index 44778b0..95c3d85 100644 --- a/example/l3fwd/odp_l3fwd.c +++ b/example/l3fwd/odp_l3fwd.c @@ -158,6 +158,22 @@ static void setup_fwd_db(void) } } +/** + * Decrement TTL and incrementally update checksum + * + * @param ip IPv4 header + */ +static inline void ipv4_dec_ttl_csum_update(odph_ipv4hdr_t *ip) +{ + uint16_t a = ~odp_cpu_to_be_16(1 << 8); + + ip->ttl--; + if (ip->chksum >= a) + ip->chksum -= a; + else + ip->chksum += odp_cpu_to_be_16(1 << 8); +} + static int l3fwd_pkt_hash(odp_packet_t pkt, int sif) { fwd_db_entry_t *entry; @@ -186,8 +202,7 @@ static int l3fwd_pkt_hash(odp_packet_t pkt, int sif) key.dst_port = 0; } entry = find_fwd_db_entry(&key); - ip->ttl--; - ip->chksum = odph_ipv4_csum_update(pkt); + ipv4_dec_ttl_csum_update(ip); eth = odp_packet_l2_ptr(pkt, NULL); if (entry) { eth->src = entry->src_mac; @@ -211,8 +226,7 @@ static int l3fwd_pkt_lpm(odp_packet_t pkt, int sif) int ret; ip = odp_packet_l3_ptr(pkt, &len); - ip->ttl--; - ip->chksum = odph_ipv4_csum_update(pkt); + ipv4_dec_ttl_csum_update(ip); eth = odp_packet_l2_ptr(pkt, NULL); /* network byte order maybe different from host */