From patchwork Sat Jan 13 08:00:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 124412 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp64530lje; Sat, 13 Jan 2018 00:01:16 -0800 (PST) X-Google-Smtp-Source: ACJfBotPMeT0Hu6M6EzbgztYcJ9AeFUH/czP+NpIIGvKtXQRVr0bIf1NoUIzvCV6wcnBtQyqer9V X-Received: by 10.55.115.194 with SMTP id o185mr37051804qkc.143.1515830476040; Sat, 13 Jan 2018 00:01:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515830476; cv=none; d=google.com; s=arc-20160816; b=YDgyi0/akK9dpm/VlKkQXDKfxananH/p4iIPCa9ImNdESVvQtDlq1tEfeWimVeqkpX vQMM8yUCz/YHs1VGJem4N82zhzn3TeF1lobMTxcs73gO3OMsd1ILArS2nRadOhR0mIkN veFzMmxd3gHGXHideWcjIKga3SXgN4weSXI9wkrqsh5pJsFEgIL06m0x3eWTEyCfl+VN h7hMqYZ7pstPdgtIi5EAzVpoY/ZYCGX/8GTJ9jjQCnrv5KZnbeY7Er9wrdssL8JKzKXi lz3eQ9Id+OarYzTFHSyGoCub05vVu+WZUwpvLon1t1CstH+KHQneiNuOZTr6WBMKWuQb L7gA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=Yj99C68kIW6f7W2wAy4s8G81zUDEQoS6I2ixZdDAwJI=; b=kGBhwA0h7wvKJIbK/vxhT1m4bREI2kgHjzxE9gPCDAaOqF+/TEwFybAdQusx1UnPwD cH+Sd7TFdmRLySU2wyq1tJWrTi/R2bUAeF3y1r0OgCVmrkjLa2qq1Bpdv3GGWFOCx2/W Y9RZ17kYzMwyYtxpjmazCQoVc2Kpd04P0iSa7LO7JKCefu3jYHmVTASWiMOQiOYXm9N/ uJxcCAI/nmU8tFuS0Skuyvzqv1UN144YBY28xVWP1kgIx/8GIa2No5WWPBeR4l5v4od8 f4xXBWFUktWzZywJ46fLlTOUz483poUcAzU1eRWLnP1pJUv/e3xqK5bJz0RChJfmTc+2 rxDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id x63si1010267qka.397.2018.01.13.00.01.15; Sat, 13 Jan 2018 00:01:15 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 98FE96176F; Sat, 13 Jan 2018 08:01:15 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 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 A92A16175F; Sat, 13 Jan 2018 08:00:27 +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 06BD161758; Sat, 13 Jan 2018 08:00:23 +0000 (UTC) Received: from forward105p.mail.yandex.net (forward105p.mail.yandex.net [77.88.28.108]) by lists.linaro.org (Postfix) with ESMTPS id 00E0A6173A for ; Sat, 13 Jan 2018 08:00:11 +0000 (UTC) Received: from mxback2o.mail.yandex.net (mxback2o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1c]) by forward105p.mail.yandex.net (Yandex) with ESMTP id 47E504082650 for ; Sat, 13 Jan 2018 11:00:09 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback2o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id fr1t1jnXsk-09Q88iYa; Sat, 13 Jan 2018 11:00:09 +0300 Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 8Hzdfi2ypg-08YmbntT; Sat, 13 Jan 2018 11:00:08 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Sat, 13 Jan 2018 11:00:01 +0300 Message-Id: <1515830407-13301-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515830407-13301-1-git-send-email-odpbot@yandex.ru> References: <1515830407-13301-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 389 Subject: [lng-odp] [PATCH v2][WIP 1/7] validation: ipsec: fix packet checksums 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" From: Dmitry Eremin-Solenikov Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 389 (lumag:parse-checksums) ** https://github.com/Linaro/odp/pull/389 ** Patch: https://github.com/Linaro/odp/pull/389.patch ** Base sha: 49ebafae0edebbc750742d8874ad0a7588286dea ** Merge commit sha: 29d9c9fa8235c01897c72e823b57525e37f896d3 **/ test/validation/api/ipsec/ipsec.c | 1 + test/validation/api/ipsec/test_vectors.h | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/test/validation/api/ipsec/ipsec.c b/test/validation/api/ipsec/ipsec.c index ea3cff052..322b03ad2 100644 --- a/test/validation/api/ipsec/ipsec.c +++ b/test/validation/api/ipsec/ipsec.c @@ -905,6 +905,7 @@ int ipsec_config(odp_instance_t ODP_UNUSED inst) ipsec_config.outbound_mode = suite_context.outbound_op_mode; ipsec_config.inbound.default_queue = suite_context.queue; ipsec_config.inbound.parse_level = ODP_PROTO_LAYER_ALL; + ipsec_config.inbound.chksums.all_chksum = ~0; if (ODP_IPSEC_OK != odp_ipsec_config(&ipsec_config)) return -1; diff --git a/test/validation/api/ipsec/test_vectors.h b/test/validation/api/ipsec/test_vectors.h index a6b8616b6..0a46ec758 100644 --- a/test/validation/api/ipsec/test_vectors.h +++ b/test/validation/api/ipsec/test_vectors.h @@ -264,7 +264,7 @@ static const ODP_UNUSED ipsec_test_packet pkt_ipv4_icmp_0_ah_sha256_1_bad1 = { /* IP */ 0x45, 0x00, 0x00, 0x9a, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x33, 0xab, 0xd9, 0xc0, 0xa8, 0x6f, 0x02, + 0x40, 0x33, 0xab, 0xdb, 0xc0, 0xa8, 0x6f, 0x02, 0xc0, 0xa8, 0xde, 0x02, /* AH */ @@ -664,7 +664,7 @@ static const ODP_UNUSED ipsec_test_packet pkt_ipv4_icmp_0_esp_aes_cbc_null_1 = { /* IP */ 0x45, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x32, 0xab, 0xca, 0xc0, 0xa8, 0x6f, 0x02, + 0x40, 0x32, 0xab, 0xda, 0xc0, 0xa8, 0x6f, 0x02, 0xc0, 0xa8, 0xde, 0x02, /* ESP */ @@ -1494,7 +1494,7 @@ static const ipsec_test_packet pkt_mcgrew_gcm_test_2_esp = { /* IP - not a part of RFC, added for simplicity */ 0x45, 0x00, 0x00, 0x74, 0x69, 0x8f, 0x00, 0x00, - 0x80, 0x32, 0x4d, 0x76, 0xc0, 0xa8, 0x01, 0x02, + 0x80, 0x32, 0x4d, 0x75, 0xc0, 0xa8, 0x01, 0x02, 0xc0, 0xa8, 0x01, 0x01, /* ESP */ @@ -1552,7 +1552,7 @@ static const ipsec_test_packet pkt_mcgrew_gcm_test_3_esp = { /* IP - not a part of RFC, added for simplicity */ 0x45, 0x00, 0x00, 0x68, 0x69, 0x8f, 0x00, 0x00, - 0x80, 0x32, 0x4d, 0x82, 0xc0, 0xa8, 0x01, 0x02, + 0x80, 0x32, 0x4d, 0x81, 0xc0, 0xa8, 0x01, 0x02, 0xc0, 0xa8, 0x01, 0x01, /* ESP */ @@ -1610,7 +1610,7 @@ static const ipsec_test_packet pkt_mcgrew_gcm_test_4_esp = { /* IP - not a part of RFC, added for simplicity */ 0x45, 0x00, 0x00, 0x74, 0x69, 0x8f, 0x00, 0x00, - 0x80, 0x32, 0x4d, 0x76, 0xc0, 0xa8, 0x01, 0x02, + 0x80, 0x32, 0x4d, 0x75, 0xc0, 0xa8, 0x01, 0x02, 0xc0, 0xa8, 0x01, 0x01, /* ESP */ @@ -1708,7 +1708,7 @@ static const ipsec_test_packet pkt_mcgrew_gcm_test_15_esp = { /* IP - not a part of RFC, added for simplicity */ 0x45, 0x00, 0x00, 0x68, 0x69, 0x8f, 0x00, 0x00, - 0x80, 0x32, 0x4d, 0xb2, 0xc0, 0xa8, 0x01, 0x02, + 0x80, 0x32, 0x4d, 0x81, 0xc0, 0xa8, 0x01, 0x02, 0xc0, 0xa8, 0x01, 0x01, /* ESP */ @@ -1752,7 +1752,7 @@ static const ODP_UNUSED ipsec_test_packet 0x11, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, /* UDP encap */ - 0x11, 0x94, 0x11, 0x94, 0x00, 0x90, 0x00, 0x00, + 0x11, 0x94, 0x11, 0x94, 0x00, 0x90, 0x51, 0x33, /* ESP */ 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, 0x01, From patchwork Sat Jan 13 08:00:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 124414 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp64845lje; Sat, 13 Jan 2018 00:02:30 -0800 (PST) X-Google-Smtp-Source: ACJfBov8QEeQHmsdBszHVzNUQ6e/SZtjbgtfkbayjGgLzRVhfKUDt+J5mLjOsO/mIiVv4f1u5J5x X-Received: by 10.200.81.154 with SMTP id c26mr12409883qtn.129.1515830550305; Sat, 13 Jan 2018 00:02:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515830550; cv=none; d=google.com; s=arc-20160816; b=ETPtihdN3f8Xqeew+Gl4WJuCdHJdWHBMWKFtarsVCpsZFkHIKpxL83zMkqV9crNs4A 1h0mxuwHkVhHoFXMuUaDSppxQOYh7K0ZjRJ4VsDqhT/NuG4RAac3uQiiJ+oRF3E0cJ+i 9XgNvUKIsiYrYUhvc0wThBt6G2n9ie2cqj1OQhQ5SMDey6jewyAhus+nilyEZn5BXZsV lc7c9qJHTgxOGuwpO6AJP+QXBjkayooeHz6Immt+vMtWbH9sZXEcE0DAPsio0zEtS+JN +jlXfSXOSSmXRut7vxZ9vX8JQIGOuVSJitEekYy0QrEs27W2OdckIflltCRi7s72/xga /zUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=TH7N0bfo8vzpq/XSpxwnCdMWbtOxLLcaZXLEjxRdSHU=; b=zLdt2IU8ums/agR+DIHqUWztQILYdRyjkLq1qUyZPtsgMz+kFEy7dQ2P28KbOs0NP8 vM9k/uqeDWQXrGiPEbrQxMNhI/MVTKS1PY9XiIKSFyfQEDQ4L5Rtk+36LVkoITPcCtxy bj0N5IZAeAR1EpH48+c/sidc0/Nw9y3ccmVgHIx5ydOfRH12MHM/cwLNceSCVALHh09U 6ixyJNd1WUpfAXJ/QfpWjunUhFhOC5ZOtL2br+Z8m3e4TkxVBZ3ue9zDhvC402JUk7Wt zIHYoNC8A0ofVwel9RBmjeUkW0yAgXjN6+jyNgJrVCh5zRvIxIYl8vwCe4uc+hCW4N8N QdZg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id s16si8762612qki.293.2018.01.13.00.02.30; Sat, 13 Jan 2018 00:02:30 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id F2E7561758; Sat, 13 Jan 2018 08:02:29 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL 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 6C7E761751; Sat, 13 Jan 2018 08:00:34 +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 43CD461762; Sat, 13 Jan 2018 08:00:25 +0000 (UTC) Received: from forward106o.mail.yandex.net (forward106o.mail.yandex.net [37.140.190.187]) by lists.linaro.org (Postfix) with ESMTPS id 2F6C26175C for ; Sat, 13 Jan 2018 08:00:12 +0000 (UTC) Received: from mxback11j.mail.yandex.net (mxback11j.mail.yandex.net [IPv6:2a02:6b8:0:1619::84]) by forward106o.mail.yandex.net (Yandex) with ESMTP id 01104782792 for ; Sat, 13 Jan 2018 11:00:10 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback11j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id iJa0yMXGDW-09Ea1o9V; Sat, 13 Jan 2018 11:00:09 +0300 Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 8Hzdfi2ypg-09YGWC78; Sat, 13 Jan 2018 11:00:09 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Sat, 13 Jan 2018 11:00:02 +0300 Message-Id: <1515830407-13301-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515830407-13301-1-git-send-email-odpbot@yandex.ru> References: <1515830407-13301-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 389 Subject: [lng-odp] [PATCH v2][WIP 2/7] linux-gen: packet: drop unused function 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" From: Dmitry Eremin-Solenikov Drop unused packet_parse_l3_l4() function Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 389 (lumag:parse-checksums) ** https://github.com/Linaro/odp/pull/389 ** Patch: https://github.com/Linaro/odp/pull/389.patch ** Base sha: 49ebafae0edebbc750742d8874ad0a7588286dea ** Merge commit sha: 29d9c9fa8235c01897c72e823b57525e37f896d3 **/ platform/linux-generic/include/odp_packet_internal.h | 6 ------ platform/linux-generic/odp_packet.c | 16 ---------------- 2 files changed, 22 deletions(-) diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index 62888f8a5..43c8da5cb 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -298,12 +298,6 @@ int packet_alloc_multi(odp_pool_t pool_hdl, uint32_t len, int packet_parse_layer(odp_packet_hdr_t *pkt_hdr, odp_proto_layer_t layer); -/* Perform L3 and L4 parsing up to a given protocol layer */ -int packet_parse_l3_l4(odp_packet_hdr_t *pkt_hdr, - odp_proto_layer_t layer, - uint32_t l3_offset, - uint16_t ethtype); - /* Reset parser metadata for a new parse */ void packet_parse_reset(odp_packet_hdr_t *pkt_hdr); diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 83a880947..a0bc8911a 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -2312,22 +2312,6 @@ int packet_parse_layer(odp_packet_hdr_t *pkt_hdr, seg_len, layer); } -int packet_parse_l3_l4(odp_packet_hdr_t *pkt_hdr, - odp_proto_layer_t layer, - uint32_t l3_offset, - uint16_t ethtype) -{ - uint32_t seg_len = 0; - void *base = packet_map(pkt_hdr, l3_offset, &seg_len, NULL); - - if (seg_len == 0) - return -1; - - return packet_parse_common_l3_l4(&pkt_hdr->p, base, l3_offset, - pkt_hdr->frame_len, seg_len, - layer, ethtype); -} - int odp_packet_parse(odp_packet_t pkt, uint32_t offset, const odp_packet_parse_param_t *param) { From patchwork Sat Jan 13 08:00:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 124413 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp64681lje; Sat, 13 Jan 2018 00:01:50 -0800 (PST) X-Google-Smtp-Source: ACJfBoso+VBiuldoK4i69/jOa5muDH9mj9lxq+KYbBewv/sZwf/xdaTxskPmD8q1xh2c8Z5e8XJb X-Received: by 10.200.10.11 with SMTP id b11mr41425120qti.287.1515830510242; Sat, 13 Jan 2018 00:01:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515830510; cv=none; d=google.com; s=arc-20160816; b=zwOOY5Too8fOyu1iecBsXS7e+VrcioIhE2MZjRCWAjz93F0XQbAOl327Et/6n5jlpG v2GS9L0qedGSFyfFzb8wR4TI7CXoJQvo1JWusi+GwXBZNpFYrLK6HX+6e8G+lCTRGocx Ny1ci6p7OnkoBenxqM2xm5xFKbNa4v17gnllSPPdj3J+bLdozZ+nzbfw3E/cYia7PUbB 2clrsi6vYSKw/iCF45X8a7oW5f7LZ3qfG1KvnmdXfPY2KbWLdpKeS3rltlXa6jOE8h7g kBmsjAUB1sR7cPTB6wI0u8eLZhB4t00GpZH+GoBEFxCdU20rNJDB7XQM5wU9WW9WSsE4 XBww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=lyx8WOlAYP2u0OUFV9vOXwYEdJ/tF4jfKgifRE9QlV0=; b=H2jxCkQARAshImoAmH2RXNWnQiuGZWWXtHmGklUSMxPtUemLJ38sMImL9gJvTLN/2S 5UvoWOD/oFIz7yxY2Y16X7aYhuCfTkw97EwzFG2jBVEEd0rcbbqBXYoixTUhRAB79Sdl mqLuW0D4ugfY5GXegbwlJtslH5q3vqtng4oZEg+aQk1taTNKreVunTCjF/doVY485QI3 Wl4eN6MAOLS6KHyuKXNQHKXlh/19UVNsO+AwHmpwMIIhL7Jn2WyXKp0nkVtIEFMdotOI Cy1hc5i6gE/21BjwJ3WYyLbv6TGifUM7E8UmY/VfNS03SaRZCQQTkaeW2HD4EQaDYOFB RIUQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id x7si3097871qkd.52.2018.01.13.00.01.49; Sat, 13 Jan 2018 00:01:50 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id E52296150E; Sat, 13 Jan 2018 08:01:49 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL 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 1BF9E616B9; Sat, 13 Jan 2018 08:00:31 +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 99A676173A; Sat, 13 Jan 2018 08:00:23 +0000 (UTC) Received: from forward106j.mail.yandex.net (forward106j.mail.yandex.net [5.45.198.249]) by lists.linaro.org (Postfix) with ESMTPS id 05D3761727 for ; Sat, 13 Jan 2018 08:00:12 +0000 (UTC) Received: from mxback13j.mail.yandex.net (mxback13j.mail.yandex.net [IPv6:2a02:6b8:0:1619::88]) by forward106j.mail.yandex.net (Yandex) with ESMTP id B080818035A6 for ; Sat, 13 Jan 2018 11:00:10 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback13j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id huBUDbF32A-0AdWeSl4; Sat, 13 Jan 2018 11:00:10 +0300 Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 8Hzdfi2ypg-0AYO43g0; Sat, 13 Jan 2018 11:00:10 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Sat, 13 Jan 2018 11:00:03 +0300 Message-Id: <1515830407-13301-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515830407-13301-1-git-send-email-odpbot@yandex.ru> References: <1515830407-13301-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 389 Subject: [lng-odp] [PATCH v2][WIP 3/7] linux-gen: pktio: introduce checksum settings 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" From: Dmitry Eremin-Solenikov Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 389 (lumag:parse-checksums) ** https://github.com/Linaro/odp/pull/389 ** Patch: https://github.com/Linaro/odp/pull/389.patch ** Base sha: 49ebafae0edebbc750742d8874ad0a7588286dea ** Merge commit sha: 29d9c9fa8235c01897c72e823b57525e37f896d3 **/ platform/linux-generic/include/odp_packet_io_internal.h | 1 + platform/linux-generic/odp_packet_io.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 25e037182..851515810 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -151,6 +151,7 @@ struct pktio_entry { odp_pktio_config_t config; /**< Device configuration */ classifier_t cls; /**< classifier linked with this pktio*/ odp_pktio_stats_t stats; /**< statistic counters for pktio */ + odp_proto_chksums_t in_chksums; /**< Checksums validation settings */ enum { STATS_SYSFS = 0, STATS_ETHTOOL, diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index ffbc73b26..1f1d46423 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -432,6 +432,12 @@ int odp_pktio_config(odp_pktio_t hdl, const odp_pktio_config_t *config) entry->s.config = *config; + entry->s.in_chksums.all_chksum = 0; + entry->s.in_chksums.chksum.ipv4 = config->pktin.bit.ipv4_chksum; + entry->s.in_chksums.chksum.tcp = config->pktin.bit.tcp_chksum; + entry->s.in_chksums.chksum.udp = config->pktin.bit.udp_chksum; + entry->s.in_chksums.chksum.sctp = config->pktin.bit.sctp_chksum; + if (entry->s.ops->config) res = entry->s.ops->config(entry, config); From patchwork Sat Jan 13 08:00:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 124416 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp65214lje; Sat, 13 Jan 2018 00:04:01 -0800 (PST) X-Google-Smtp-Source: ACJfBosTtkHNAW4dTP1meKN8WrbzenRmbk0FXsjBWbRZ2Rdixn4dGEYxiMFLdIcB9xANmerx1BWT X-Received: by 10.55.105.194 with SMTP id e185mr41244590qkc.192.1515830641449; Sat, 13 Jan 2018 00:04:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515830641; cv=none; d=google.com; s=arc-20160816; b=Pb+ePJ64CrpX83QfH2z4BoSyaJ81gkZe1Sp0aenJzfg7cD6mpFQvkP0rVetjML12wh eoXAH3Mwa2n9WT+C6GAqXij7cejbkFeY3WvHVu+KFtjAt0oa+CumSFtcajPB+acvg2Li fCiaIdb2Fte5ZAhmEcP8O4rx5j+4Fi2RjZwxE/aUA9DYuBkZtMVOZLUOn/q0pRz7ak7O e6oeLDyNzAe4QJAk8FliOZDNEh8KTuM3kNdEDkXDUj9+DjDlhgb03oYr72Y0fBAXr+n0 XWN+bWGO6vjxRAApi7BOGb6chRZqlr4QwVysNV1c5y5kLPRn21s4UhcylJnUKs+L8UcB 9Sqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=zP3swCdfjT9wRx36Y7RyCJGAtzOWGKzJ7rQc9UnK/FQ=; b=MBU4qRBXtDlR1IH4sAasXGAvXZwhvxZ9ekkMO7zSzGNcv/Fija1JX9Wb5p+wtC6dOC gQVM6bM/DaXapAm5ijRPin7BlD0VImo8aGdooCnzOR7WB/+jWf83Kyk4heXHN3WLKdrj 1Nu4gwmDDA2i7VY40kNvKDkrXbNWGRiXStU7pZkAhVtEcrDNxCsGLYhInI70wDlHBaZe cewkquSzeCz/00f5iduQegP166Aq7MKpXjjyb9KuP0igFTzy9GLp9aO9JSt//xkXiAqO JWE5H/ZLkJuJ/NIF3fsJ4ek1qIlGlzxiIYuDCp5qIjgNtAZgIJbUUsml+q3X/I0uOXBv 77mg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id e64si10216468qtd.147.2018.01.13.00.04.01; Sat, 13 Jan 2018 00:04:01 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 20D4A61751; Sat, 13 Jan 2018 08:04:01 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 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 E76796176A; Sat, 13 Jan 2018 08:00:42 +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 88C046175C; Sat, 13 Jan 2018 08:00:28 +0000 (UTC) Received: from forward103p.mail.yandex.net (forward103p.mail.yandex.net [77.88.28.106]) by lists.linaro.org (Postfix) with ESMTPS id 8E5836150E for ; Sat, 13 Jan 2018 08:00:12 +0000 (UTC) Received: from mxback12j.mail.yandex.net (mxback12j.mail.yandex.net [IPv6:2a02:6b8:0:1619::87]) by forward103p.mail.yandex.net (Yandex) with ESMTP id 47A412183A24 for ; Sat, 13 Jan 2018 11:00:11 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback12j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id DL6jatJdnZ-0Br0svPg; Sat, 13 Jan 2018 11:00:11 +0300 Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 8Hzdfi2ypg-0AYaeiwa; Sat, 13 Jan 2018 11:00:10 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Sat, 13 Jan 2018 11:00:04 +0300 Message-Id: <1515830407-13301-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515830407-13301-1-git-send-email-odpbot@yandex.ru> References: <1515830407-13301-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 389 Subject: [lng-odp] [PATCH v2][WIP 4/7] linux-gen: packet: add IPv4 checksum validation 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" From: Dmitry Eremin-Solenikov If configured, check IPv4 header checksum. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 389 (lumag:parse-checksums) ** https://github.com/Linaro/odp/pull/389 ** Patch: https://github.com/Linaro/odp/pull/389.patch ** Base sha: 49ebafae0edebbc750742d8874ad0a7588286dea ** Merge commit sha: 29d9c9fa8235c01897c72e823b57525e37f896d3 **/ .../linux-generic/include/odp_packet_internal.h | 6 ++-- platform/linux-generic/odp_classification.c | 3 +- platform/linux-generic/odp_packet.c | 32 ++++++++++++++++------ platform/linux-generic/pktio/loop.c | 3 +- platform/linux-generic/pktio/pcap.c | 3 +- platform/linux-generic/pktio/socket.c | 3 +- platform/linux-generic/pktio/socket_mmap.c | 3 +- platform/linux-generic/pktio/tap.c | 3 +- 8 files changed, 39 insertions(+), 17 deletions(-) diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index 43c8da5cb..86f0d80a5 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -296,7 +296,8 @@ int packet_alloc_multi(odp_pool_t pool_hdl, uint32_t len, /* Perform packet parse up to a given protocol layer */ int packet_parse_layer(odp_packet_hdr_t *pkt_hdr, - odp_proto_layer_t layer); + odp_proto_layer_t layer, + odp_proto_chksums_t chksums); /* Reset parser metadata for a new parse */ void packet_parse_reset(odp_packet_hdr_t *pkt_hdr); @@ -333,7 +334,8 @@ static inline void packet_set_ts(odp_packet_hdr_t *pkt_hdr, odp_time_t *ts) } int packet_parse_common(packet_parser_t *pkt_hdr, const uint8_t *ptr, - uint32_t pkt_len, uint32_t seg_len, int layer); + uint32_t pkt_len, uint32_t seg_len, int layer, + odp_proto_chksums_t chksums); int _odp_cls_parse(odp_packet_hdr_t *pkt_hdr, const uint8_t *parseptr); diff --git a/platform/linux-generic/odp_classification.c b/platform/linux-generic/odp_classification.c index 276430923..4d3df49e2 100644 --- a/platform/linux-generic/odp_classification.c +++ b/platform/linux-generic/odp_classification.c @@ -973,7 +973,8 @@ int cls_classify_packet(pktio_entry_t *entry, const uint8_t *base, packet_set_len(pkt_hdr, pkt_len); packet_parse_common(&pkt_hdr->p, base, pkt_len, seg_len, - ODP_PROTO_LAYER_ALL); + ODP_PROTO_LAYER_ALL, + entry->s.in_chksums); cos = cls_select_cos(entry, base, pkt_hdr); if (cos == NULL) diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index a0bc8911a..d3c608ab0 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -2024,7 +2024,8 @@ static inline uint16_t parse_eth(packet_parser_t *prs, const uint8_t **parseptr, * Parser helper function for IPv4 */ static inline uint8_t parse_ipv4(packet_parser_t *prs, const uint8_t **parseptr, - uint32_t *offset, uint32_t frame_len) + uint32_t *offset, uint32_t frame_len, + odp_proto_chksums_t chksums) { const _odp_ipv4hdr_t *ipv4 = (const _odp_ipv4hdr_t *)*parseptr; uint8_t ver = _ODP_IPV4HDR_VER(ipv4->ver_ihl); @@ -2040,6 +2041,14 @@ static inline uint8_t parse_ipv4(packet_parser_t *prs, const uint8_t **parseptr, return 0; } + if (chksums.chksum.ipv4) { + prs->input_flags.l3_chksum_done = 1; + if (odp_chksum_ones_comp16(ipv4, ihl * 4) != 0xffff) { + prs->error_flags.l3_chksum = 1; + return 0; + } + } + *offset += ihl * 4; *parseptr += ihl * 4; @@ -2175,7 +2184,8 @@ static inline int packet_parse_common_l3_l4(packet_parser_t *prs, const uint8_t *parseptr, uint32_t offset, uint32_t frame_len, uint32_t seg_len, - int layer, uint16_t ethtype) + int layer, uint16_t ethtype, + odp_proto_chksums_t chksums) { uint8_t ip_proto; @@ -2191,7 +2201,7 @@ int packet_parse_common_l3_l4(packet_parser_t *prs, const uint8_t *parseptr, switch (ethtype) { case _ODP_ETHTYPE_IPV4: prs->input_flags.ipv4 = 1; - ip_proto = parse_ipv4(prs, &parseptr, &offset, frame_len); + ip_proto = parse_ipv4(prs, &parseptr, &offset, frame_len, chksums); prs->l4_offset = offset; break; @@ -2275,7 +2285,7 @@ int packet_parse_common_l3_l4(packet_parser_t *prs, const uint8_t *parseptr, */ int packet_parse_common(packet_parser_t *prs, const uint8_t *ptr, uint32_t frame_len, uint32_t seg_len, - int layer) + int layer, odp_proto_chksums_t chksums) { uint32_t offset; uint16_t ethtype; @@ -2296,20 +2306,21 @@ int packet_parse_common(packet_parser_t *prs, const uint8_t *ptr, ethtype = parse_eth(prs, &parseptr, &offset, frame_len); return packet_parse_common_l3_l4(prs, parseptr, offset, frame_len, - seg_len, layer, ethtype); + seg_len, layer, ethtype, chksums); } /** * Simple packet parser */ int packet_parse_layer(odp_packet_hdr_t *pkt_hdr, - odp_proto_layer_t layer) + odp_proto_layer_t layer, + odp_proto_chksums_t chksums) { uint32_t seg_len = packet_first_seg_len(pkt_hdr); void *base = packet_data(pkt_hdr); return packet_parse_common(&pkt_hdr->p, base, pkt_hdr->frame_len, - seg_len, layer); + seg_len, layer, chksums); } int odp_packet_parse(odp_packet_t pkt, uint32_t offset, @@ -2336,7 +2347,8 @@ int odp_packet_parse(odp_packet_t pkt, uint32_t offset, if (proto == ODP_PROTO_ETH) { ret = packet_parse_common(&pkt_hdr->p, data, packet_len, - seg_len, layer); + seg_len, layer, + param->chksums); if (ret) return -1; @@ -2348,7 +2360,9 @@ int odp_packet_parse(odp_packet_t pkt, uint32_t offset, ret = packet_parse_common_l3_l4(&pkt_hdr->p, data, offset, packet_len, seg_len, - layer, ethtype); + layer, ethtype, + param->chksums); + if (ret) return -1; diff --git a/platform/linux-generic/pktio/loop.c b/platform/linux-generic/pktio/loop.c index ad2cb39f8..bf6365e94 100644 --- a/platform/linux-generic/pktio/loop.c +++ b/platform/linux-generic/pktio/loop.c @@ -146,7 +146,8 @@ static int loopback_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, } } else { packet_parse_layer(pkt_hdr, - pktio_entry->s.config.parser.layer); + pktio_entry->s.config.parser.layer, + pktio_entry->s.in_chksums); } packet_set_ts(pkt_hdr, ts); diff --git a/platform/linux-generic/pktio/pcap.c b/platform/linux-generic/pktio/pcap.c index 596bf6f28..573c31744 100644 --- a/platform/linux-generic/pktio/pcap.c +++ b/platform/linux-generic/pktio/pcap.c @@ -255,7 +255,8 @@ static int pcapif_recv_pkt(pktio_entry_t *pktio_entry, int index ODP_UNUSED, } packet_parse_layer(pkt_hdr, - pktio_entry->s.config.parser.layer); + pktio_entry->s.config.parser.layer, + pktio_entry->s.in_chksums); pktio_entry->s.stats.in_octets += pkt_hdr->frame_len; packet_set_ts(pkt_hdr, ts); diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c index 0a80035f5..d0a55effe 100644 --- a/platform/linux-generic/pktio/socket.c +++ b/platform/linux-generic/pktio/socket.c @@ -676,7 +676,8 @@ static int sock_mmsg_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, if (!pktio_cls_enabled(pktio_entry)) packet_parse_layer(pkt_hdr, - pktio_entry->s.config.parser.layer); + pktio_entry->s.config.parser.layer, + pktio_entry->s.in_chksums); pkt_hdr->input = pktio_entry->s.handle; packet_set_ts(pkt_hdr, ts); diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c index c63a25398..f31d34dca 100644 --- a/platform/linux-generic/pktio/socket_mmap.c +++ b/platform/linux-generic/pktio/socket_mmap.c @@ -234,7 +234,8 @@ static inline unsigned pkt_mmap_v2_rx(pktio_entry_t *pktio_entry, copy_packet_cls_metadata(&parsed_hdr, hdr); else packet_parse_layer(hdr, - pktio_entry->s.config.parser.layer); + pktio_entry->s.config.parser.layer, + pktio_entry->s.in_chksums); packet_set_ts(hdr, ts); diff --git a/platform/linux-generic/pktio/tap.c b/platform/linux-generic/pktio/tap.c index d8b78f3f8..da7a7b3a2 100644 --- a/platform/linux-generic/pktio/tap.c +++ b/platform/linux-generic/pktio/tap.c @@ -285,7 +285,8 @@ static odp_packet_t pack_odp_pkt(pktio_entry_t *pktio_entry, const void *data, copy_packet_cls_metadata(&parsed_hdr, pkt_hdr); else packet_parse_layer(pkt_hdr, - pktio_entry->s.config.parser.layer); + pktio_entry->s.config.parser.layer, + pktio_entry->s.in_chksums); packet_set_ts(pkt_hdr, ts); pkt_hdr->input = pktio_entry->s.handle; From patchwork Sat Jan 13 08:00:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 124415 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp65017lje; Sat, 13 Jan 2018 00:03:11 -0800 (PST) X-Google-Smtp-Source: ACJfBou0c0AeKmjiNIdzXzzvZshryb1VWyAeLi6J5GkD58aPkgJuSAdbrHQUt5/COjNIqzJWK4T2 X-Received: by 10.55.217.132 with SMTP id q4mr37670935qkl.236.1515830591270; Sat, 13 Jan 2018 00:03:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515830591; cv=none; d=google.com; s=arc-20160816; b=CRPDAkhPE+CWUyWI8KoQmL7rbCsaV/16GhY8TFv+mac4u2WnN6W3E1onzzGTONMgGD VKgBbC/Bk3NS0TAHXzIL8v3EhJWtN3v+vFKu0RAVNEyS1cC7NZMygYraz0DsTuyhtFYE llHG2TXtm1AbEEIeAMEHmSpz2tGDJb/G+syZ2TWGGo6DRyAd5MHROIwVZSrZ+UO04tTg QH0QiiAObIe0geAYWzQRggdQk9vTI4uUlgHJFpQcxtHMV5T/qJQ5Lr4BQVTzPYhgZYx1 x/U/yNBkKkiiYmfN76dIgb1Umgl4FQ/MxfTyQs+E49tksUX479ZF8r+p8I207eg7C2kd FEYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=UVCmrCykghOCFTY5nzbUHW4wBbjfaKEkAY/qnoKrmPg=; b=KxMsSW4nsRuEeu32y4AfLJSpXT3oOjRAYnK0EYQAD2Ytrb58rgWIUh1k3k7T5+yqCc PtVuKAVlJXCDpJD+lbU8wOMEAfxoQMsIOIvXtgr+DfkPp7GUPMMkuqDZ2u7tJBwfwyOU bECUxUB6ia161TAynzkTECcjQIHk/g/oulxcLPk+fdlVjHcQOi7+Hjoe/RhQBVtJ0VpV wj5239iao5W0f+fLbNtAXMuLv2P+nTeFC7k8Ccn76KOkWlOC6sOIXXeb2AcDW2C+J3Wd AKk9GKYp2y97eKBmddX4DyVyexXCJSIlTVPdaCc7MuFuDiCg76IzJVB4z5vMl6+4oL40 gGAw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id q17si7110312qte.468.2018.01.13.00.03.11; Sat, 13 Jan 2018 00:03:11 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 00B8E61751; Sat, 13 Jan 2018 08:03:10 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 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 AE10B616F7; Sat, 13 Jan 2018 08:00:38 +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 0C69461766; Sat, 13 Jan 2018 08:00:28 +0000 (UTC) Received: from forward102p.mail.yandex.net (forward102p.mail.yandex.net [77.88.28.102]) by lists.linaro.org (Postfix) with ESMTPS id 6EF39616B9 for ; Sat, 13 Jan 2018 08:00:13 +0000 (UTC) Received: from mxback12g.mail.yandex.net (mxback12g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:91]) by forward102p.mail.yandex.net (Yandex) with ESMTP id 06D1B430428A for ; Sat, 13 Jan 2018 11:00:12 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback12g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id Bk6v7e1CX1-0BX8ZrfA; Sat, 13 Jan 2018 11:00:12 +0300 Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 8Hzdfi2ypg-0BYquNR7; Sat, 13 Jan 2018 11:00:11 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Sat, 13 Jan 2018 11:00:05 +0300 Message-Id: <1515830407-13301-6-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515830407-13301-1-git-send-email-odpbot@yandex.ru> References: <1515830407-13301-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 389 Subject: [lng-odp] [PATCH v2][WIP 5/7] linux-gen: chksum: separate checksumming function 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" From: Dmitry Eremin-Solenikov Separate main checksumming code, it will be used for packet checksum validation. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 389 (lumag:parse-checksums) ** https://github.com/Linaro/odp/pull/389 ** Patch: https://github.com/Linaro/odp/pull/389.patch ** Base sha: 49ebafae0edebbc750742d8874ad0a7588286dea ** Merge commit sha: 29d9c9fa8235c01897c72e823b57525e37f896d3 **/ platform/linux-generic/Makefile.am | 1 + .../linux-generic/include/odp_chksum_internal.h | 59 ++++++++++++++++++++++ platform/linux-generic/odp_chksum.c | 18 ++----- 3 files changed, 63 insertions(+), 15 deletions(-) create mode 100644 platform/linux-generic/include/odp_chksum_internal.h diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 7e40448bd..9c7563fb1 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -134,6 +134,7 @@ noinst_HEADERS = \ include/odp_bitmap_internal.h \ include/odp_bitset.h \ include/odp_buffer_internal.h \ + include/odp_chksum_internal.h \ include/odp_classification_datamodel.h \ include/odp_classification_inlines.h \ include/odp_classification_internal.h \ diff --git a/platform/linux-generic/include/odp_chksum_internal.h b/platform/linux-generic/include/odp_chksum_internal.h new file mode 100644 index 000000000..779598bbf --- /dev/null +++ b/platform/linux-generic/include/odp_chksum_internal.h @@ -0,0 +1,59 @@ +/* Copyright (c) 2013, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP checksum - implementation internal + */ + +#ifndef ODP_CHKSUM_INTERNAL_H_ +#define ODP_CHKSUM_INTERNAL_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Simple implementation of ones complement sum. + * Based on RFC1071 and its errata. + */ +static uint32_t _odp_chksum_ones_comp16_32(const void *p, uint32_t len, + odp_bool_t odd_offset) + +{ + uint32_t sum = 0; + const uint16_t *data = p; + + if (odd_offset) { + uint16_t left_over = 0; + + *(uint8_t *)&left_over = *(const uint8_t *)data; + sum = left_over; + data++; + len--; + } + + while (len > 1) { + sum += *data++; + len -= 2; + } + + /* Add left-over byte, if any */ + if (len > 0) { + uint16_t left_over = 0; + + *(uint8_t *)&left_over = *(const uint8_t *)data; + sum += left_over; + } + + return sum; +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/odp_chksum.c b/platform/linux-generic/odp_chksum.c index a792971ef..484b2b0ae 100644 --- a/platform/linux-generic/odp_chksum.c +++ b/platform/linux-generic/odp_chksum.c @@ -7,26 +7,14 @@ #include #include +#include + /* Simple implementation of ones complement sum. * Based on RFC1071 and its errata. */ uint16_t odp_chksum_ones_comp16(const void *p, uint32_t len) { - uint32_t sum = 0; - const uint16_t *data = p; - - while (len > 1) { - sum += *data++; - len -= 2; - } - - /* Add left-over byte, if any */ - if (len > 0) { - uint16_t left_over = 0; - - *(uint8_t *)&left_over = *(const uint8_t *)data; - sum += left_over; - } + uint32_t sum = _odp_chksum_ones_comp16_32(p, len, false); /* Fold 32-bit sum to 16 bits */ while (sum >> 16) From patchwork Sat Jan 13 08:00:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 124418 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp65406lje; Sat, 13 Jan 2018 00:05:00 -0800 (PST) X-Google-Smtp-Source: ACJfBouCB+KX/xsG6Hxpvgji0BpjhZIkdwXp8sqQmDthS7AGTHxQXwl1ubHcUGH5o3+XKLTuF5L2 X-Received: by 10.200.42.135 with SMTP id b7mr40725855qta.321.1515830700410; Sat, 13 Jan 2018 00:05:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515830700; cv=none; d=google.com; s=arc-20160816; b=yYw5gBja688LwpiFJ4/vDIH1HDY1wGzn22asLcLBPd2dsE0a5Vv3OFJiFhIV18zy3U lBWcH6BBxtJY8srZLrWSvI0J27jTnFD/IXVibs5VYmgX/Gqz0lGGlXEf/VFuNdmqbi6S +vy/ZWfLdNPCtbQTMKXJ5ocf6z1co9Hnvor2Gny64J7Q0zIjsESW9BXtOsoRpEXT/Aar gqV1b1xEPiffSF9/0ARrTm41FMRROWbI7KCf8P/nwKhev8ccFujH7pIwSw3X3jwMqHal RDcEbiTm0YqKX6hFhlYzHU2l7TCpWq5Ye+ARavw6W2DscfpTMXOc2dXH87waPuLGfHax m9KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=xrgiyI5Wjr7L8hN+Da3hfDuVgLSz3aXly4qSz4N6CgY=; b=qfE+hZopBlK6otPktOVcl+w6wHjtV5CerXAodeLmzgCoSexTgdFAapnMgmBnrEuxaL d+iwitleLmjXoVd1uFclEwYMjk1N5175jK9kVXPRRaF39hGSa+qbsv4JkR4O3RtvXey5 w/6aS4n5nzGHQVTKP4y6wASjP405gaXt7FLMk5bpnQF8+4da3vFolB5pYRed/VFt7KrP Ga2KuFTHJ3ufrKSr03jCBhiLWXDb4Endfma+N4GdSSqYrdvZIIWtpwGTVDNbhNpvZYJA OIm5m2uXNDWuEqXWg+AEOmxhlty938VemC15skf1bZ6P/YTehx9o3UpFYtapyzv/pKZn Mrhg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id m63si3438592qke.337.2018.01.13.00.05.00; Sat, 13 Jan 2018 00:05:00 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 23368607A9; Sat, 13 Jan 2018 08:05:00 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 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 8B4C161778; Sat, 13 Jan 2018 08:00:52 +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 70B9F61765; Sat, 13 Jan 2018 08:00:32 +0000 (UTC) Received: from forward101o.mail.yandex.net (forward101o.mail.yandex.net [37.140.190.181]) by lists.linaro.org (Postfix) with ESMTPS id 6525161750 for ; Sat, 13 Jan 2018 08:00:14 +0000 (UTC) Received: from mxback16j.mail.yandex.net (mxback16j.mail.yandex.net [IPv6:2a02:6b8:0:1619::92]) by forward101o.mail.yandex.net (Yandex) with ESMTP id 16EA51341C45 for ; Sat, 13 Jan 2018 11:00:13 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback16j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id ZUli9oBvJj-0CG4VfnE; Sat, 13 Jan 2018 11:00:13 +0300 Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 8Hzdfi2ypg-0CYex1di; Sat, 13 Jan 2018 11:00:12 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Sat, 13 Jan 2018 11:00:06 +0300 Message-Id: <1515830407-13301-7-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515830407-13301-1-git-send-email-odpbot@yandex.ru> References: <1515830407-13301-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 389 Subject: [lng-odp] [PATCH v2][WIP 6/7] linux-gen: packet: check UDP checksums 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" From: Dmitry Eremin-Solenikov Add code to enable checking of UDP checksums. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 389 (lumag:parse-checksums) ** https://github.com/Linaro/odp/pull/389 ** Patch: https://github.com/Linaro/odp/pull/389.patch ** Base sha: 49ebafae0edebbc750742d8874ad0a7588286dea ** Merge commit sha: 29d9c9fa8235c01897c72e823b57525e37f896d3 **/ .../linux-generic/include/odp_packet_internal.h | 6 + platform/linux-generic/odp_packet.c | 134 +++++++++++++++++++-- 2 files changed, 132 insertions(+), 8 deletions(-) diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index 86f0d80a5..f8b698335 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -100,6 +100,12 @@ typedef struct { /* offset to L4 hdr (TCP, UDP, SCTP, also ICMP) */ uint16_t l4_offset; + + /* Partial sum for L4 checksumming */ + uint32_t l4_part_sum; + + /* L4 checksum */ + uint32_t l4_sum; } packet_parser_t; /* Packet extra data length */ diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index d3c608ab0..4adffc66a 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -1948,6 +1949,35 @@ int _odp_packet_copy_md_to_packet(odp_packet_t srcpkt, odp_packet_t dstpkt) return dst_uarea_size < src_uarea_size; } +static uint16_t packet_sum_ones_comp16(odp_packet_hdr_t *pkt_hdr, + uint32_t offset, + uint32_t len) +{ + uint32_t sum = pkt_hdr->p.l4_part_sum; + odp_bool_t odd_offset = false; + + if (offset + len > pkt_hdr->frame_len) + return 0; + + while (len > 0) { + uint32_t seglen = 0; /* GCC */ + void *mapaddr = packet_map(pkt_hdr, offset, &seglen, NULL); + + if (seglen < len) + seglen = len; + + len -= seglen; + sum += _odp_chksum_ones_comp16_32(mapaddr, seglen, odd_offset); + odd_offset ^= (seglen % 2); + } + + /* Not more than two additions */ + sum = (sum & 0xffff) + (sum >> 16); + sum = (sum & 0xffff) + (sum >> 16); + + return ~sum; +} + /** Parser helper function for Ethernet packets */ static inline uint16_t parse_eth(packet_parser_t *prs, const uint8_t **parseptr, uint32_t *offset, uint32_t frame_len) @@ -2033,6 +2063,7 @@ static inline uint8_t parse_ipv4(packet_parser_t *prs, const uint8_t **parseptr, uint16_t frag_offset; uint32_t dstaddr = odp_be_to_cpu_32(ipv4->dst_addr); uint32_t l3_len = odp_be_to_cpu_16(ipv4->tot_len); + uint32_t l4_part_sum = 0; if (odp_unlikely(ihl < _ODP_IPV4HDR_IHL_MIN) || odp_unlikely(ver != 4) || @@ -2052,6 +2083,18 @@ static inline uint8_t parse_ipv4(packet_parser_t *prs, const uint8_t **parseptr, *offset += ihl * 4; *parseptr += ihl * 4; + if (chksums.chksum.udp || chksums.chksum.tcp) { + l4_part_sum = _odp_chksum_ones_comp16_32( + (const uint16_t *)&ipv4->src_addr, + 2 * _ODP_IPV4ADDR_LEN, false); +#if ODP_BYTE_ORDER == ODP_BIG_ENDIAN + l4_part_sum += ipv4->proto; +#else + l4_part_sum += ((uint16_t)ipv4->proto) << 8; +#endif + prs->l4_part_sum = l4_part_sum; + } + if (odp_unlikely(ihl > _ODP_IPV4HDR_IHL_MIN)) prs->input_flags.ipopt = 1; @@ -2076,13 +2119,15 @@ static inline uint8_t parse_ipv4(packet_parser_t *prs, const uint8_t **parseptr, */ static inline uint8_t parse_ipv6(packet_parser_t *prs, const uint8_t **parseptr, uint32_t *offset, uint32_t frame_len, - uint32_t seg_len) + uint32_t seg_len, + odp_proto_chksums_t chksums) { const _odp_ipv6hdr_t *ipv6 = (const _odp_ipv6hdr_t *)*parseptr; const _odp_ipv6hdr_ext_t *ipv6ext; uint32_t dstaddr0 = odp_be_to_cpu_32(ipv6->dst_addr.u8[0]); uint32_t l3_len = odp_be_to_cpu_16(ipv6->payload_len) + _ODP_IPV6HDR_LEN; + uint32_t l4_part_sum = 0; /* Basic sanity checks on IPv6 header */ if ((odp_be_to_cpu_32(ipv6->ver_tc_flow) >> 28) != 6 || @@ -2099,6 +2144,18 @@ static inline uint8_t parse_ipv6(packet_parser_t *prs, const uint8_t **parseptr, *offset += sizeof(_odp_ipv6hdr_t); *parseptr += sizeof(_odp_ipv6hdr_t); + if (chksums.chksum.udp || chksums.chksum.tcp) { + l4_part_sum = _odp_chksum_ones_comp16_32( + (const uint16_t *)&ipv6->src_addr, + 2 * _ODP_IPV6ADDR_LEN, false); +#if ODP_BYTE_ORDER == ODP_BIG_ENDIAN + l4_part_sum += ipv6->next_hdr; +#else + l4_part_sum += ((uint16_t)ipv6->next_hdr) << 8; +#endif + prs->l4_part_sum = l4_part_sum; + } + /* Skip past any IPv6 extension headers */ if (ipv6->next_hdr == _ODP_IPPROTO_HOPOPTS || ipv6->next_hdr == _ODP_IPPROTO_ROUTE) { @@ -2155,14 +2212,35 @@ static inline void parse_tcp(packet_parser_t *prs, /** * Parser helper function for UDP */ -static inline void parse_udp(packet_parser_t *prs, - const uint8_t **parseptr, uint32_t *offset) +static inline void parse_udp(packet_parser_t *prs, const uint8_t **parseptr, + uint32_t *offset, odp_proto_chksums_t chksums) { const _odp_udphdr_t *udp = (const _odp_udphdr_t *)*parseptr; uint32_t udplen = odp_be_to_cpu_16(udp->length); - if (odp_unlikely(udplen < sizeof(_odp_udphdr_t))) + if (odp_unlikely(udplen < sizeof(_odp_udphdr_t))) { prs->error_flags.udp_err = 1; + return; + } + + if (chksums.chksum.udp && + !prs->input_flags.ipfrag) { + if (udp->chksum == 0) { + prs->input_flags.l4_chksum_done = + (prs->input_flags.ipv4 != 1); + prs->error_flags.l4_chksum = + (prs->input_flags.ipv4 != 1); + } else { + prs->input_flags.l4_chksum_done = 1; + prs->l4_part_sum += udp->length; + /* Do not include checksum into partial sum */ + prs->l4_part_sum += _odp_chksum_ones_comp16_32( + (const void *)udp, + _ODP_UDPHDR_LEN - 2, + false); + } + prs->l4_sum = udp->chksum; + } if (odp_cpu_to_be_16(_ODP_UDP_IPSEC_PORT) == udp->dst_port && udplen > 4) { @@ -2208,7 +2286,7 @@ int packet_parse_common_l3_l4(packet_parser_t *prs, const uint8_t *parseptr, case _ODP_ETHTYPE_IPV6: prs->input_flags.ipv6 = 1; ip_proto = parse_ipv6(prs, &parseptr, &offset, frame_len, - seg_len); + seg_len, chksums); prs->l4_offset = offset; break; @@ -2252,7 +2330,7 @@ int packet_parse_common_l3_l4(packet_parser_t *prs, const uint8_t *parseptr, if (odp_unlikely(offset + _ODP_UDPHDR_LEN > seg_len)) return -1; prs->input_flags.udp = 1; - parse_udp(prs, &parseptr, NULL); + parse_udp(prs, &parseptr, NULL, chksums); break; case _ODP_IPPROTO_AH: @@ -2309,6 +2387,35 @@ int packet_parse_common(packet_parser_t *prs, const uint8_t *ptr, seg_len, layer, ethtype, chksums); } +static int packet_l4_chksum(odp_packet_hdr_t *pkt_hdr, + odp_proto_chksums_t chksums) +{ + /* UDP chksum == 0 case is covered in parse_udp() */ + if (chksums.chksum.udp && + pkt_hdr->p.input_flags.udp && + !pkt_hdr->p.input_flags.ipfrag && + pkt_hdr->p.l4_sum != 0) { + uint16_t sum = packet_sum_ones_comp16(pkt_hdr, + pkt_hdr->p.l4_offset + + _ODP_UDPHDR_LEN, + pkt_hdr->frame_len - + pkt_hdr->p.l4_offset - + _ODP_UDPHDR_LEN); + + if (sum == 0) + sum = 0xffff; + + if (sum != pkt_hdr->p.l4_sum) { + pkt_hdr->p.error_flags.l4_chksum = 1; + ODP_DBG("UDP chksum fail (%x)!\n", sum); + } else { + ODP_DBG("UDP chksum OK!\n"); + } + } + + return pkt_hdr->p.error_flags.all != 0; +} + /** * Simple packet parser */ @@ -2318,9 +2425,15 @@ int packet_parse_layer(odp_packet_hdr_t *pkt_hdr, { uint32_t seg_len = packet_first_seg_len(pkt_hdr); void *base = packet_data(pkt_hdr); + int rc; + + rc = packet_parse_common(&pkt_hdr->p, base, pkt_hdr->frame_len, + seg_len, layer, chksums); - return packet_parse_common(&pkt_hdr->p, base, pkt_hdr->frame_len, - seg_len, layer, chksums); + if (rc != 0) + return rc; + + return packet_l4_chksum(pkt_hdr, chksums); } int odp_packet_parse(odp_packet_t pkt, uint32_t offset, @@ -2363,7 +2476,12 @@ int odp_packet_parse(odp_packet_t pkt, uint32_t offset, layer, ethtype, param->chksums); + if (ret) + return -1; + } + if (layer == ODP_PROTO_LAYER_L4) { + ret = packet_l4_chksum(pkt_hdr, param->chksums); if (ret) return -1; } From patchwork Sat Jan 13 08:00:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 124417 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp65228lje; Sat, 13 Jan 2018 00:04:04 -0800 (PST) X-Google-Smtp-Source: ACJfBotmKqxd9XNQHMxRjZvQ4e7ssR+35thRcVJdkiLM/Y9bRTAaGQmS2M8bJF6HzxfwZsM4Ka5H X-Received: by 10.200.17.25 with SMTP id c25mr37846260qtj.97.1515830644493; Sat, 13 Jan 2018 00:04:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515830644; cv=none; d=google.com; s=arc-20160816; b=ZEFqnFpjMg+buckl9ErfDffYSv9iVAlV0Qbe6WGttr5ti72MFCkqrwDruKtpfe6jSU 8TUEe/g2iZK5fBSnA63wzt/TmFiwtxt6nZco71+fDG9qvV+piUwacNjfs8Om6v3bloKt am47zhpOyfADp/mPe8hdLZIY+L7qCG3UhxI3rOvCBW2TEw6g6dPoMTKplPXgo6s4IwJ0 tCKATW/EWEGV1dzvE9Q8dd1XNzsXk/RorCyFuxQIIkOSqFz9Y4mu5bNKfWnaLk5vK4sE LGnh1fes2WJWha3Ovv43HpKRANPsTxESRxj6qWDBoiKs4tziTiahNm44voFqaa62uUYX xm7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=QFTwjN/POe50HlAVwW7nYnFMUtVf3y0wcFHyFfF6g0c=; b=IMobd9TLScXbgIica0segDPKiPH9IS2eOYyrvnE3yahTq1a0wjbZZo+PyFYH2hPCmF U1zRdWnyUMVA78aqe8q/yHnK9So4MKdEKUN91yHI4PPws8M9jeqYc0nswrjVz7M3krDu s/5xVzTD46K1NsPU1A7jWqOdrqk5USmsWYMRtNrBGvf67Ue37s2zcvbx7dhMyJ4e5i0H s7NMvLgNF4NMTbTCPzFrg/SoCIDi/+XLO2W1ZOlfZLQihK8Z2MUjcTQ5uq30Y4ytvaIx 7McmgnRmS4pTrsp5PxjljwUdnJbx5LepCTV1jvERxKuA5XdPew5huh7530sjPks38r49 sUtg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id x52si7238787qtj.122.2018.01.13.00.04.04; Sat, 13 Jan 2018 00:04:04 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 3456A61751; Sat, 13 Jan 2018 08:04:04 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL 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 2F80161770; Sat, 13 Jan 2018 08:00:47 +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 8616A616B9; Sat, 13 Jan 2018 08:00:30 +0000 (UTC) Received: from forward101j.mail.yandex.net (forward101j.mail.yandex.net [5.45.198.241]) by lists.linaro.org (Postfix) with ESMTPS id A8B4361751 for ; Sat, 13 Jan 2018 08:00:14 +0000 (UTC) Received: from mxback4j.mail.yandex.net (mxback4j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10d]) by forward101j.mail.yandex.net (Yandex) with ESMTP id 66CCA1242AEF for ; Sat, 13 Jan 2018 11:00:13 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback4j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id u9DLLAoz7W-0DGii2NG; Sat, 13 Jan 2018 11:00:13 +0300 Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 8Hzdfi2ypg-0DYqt3YP; Sat, 13 Jan 2018 11:00:13 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Sat, 13 Jan 2018 11:00:07 +0300 Message-Id: <1515830407-13301-8-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515830407-13301-1-git-send-email-odpbot@yandex.ru> References: <1515830407-13301-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 389 Subject: [lng-odp] [PATCH v2][WIP 7/7] linux-gen: pktio: loop: support checksum parsing 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" From: Dmitry Eremin-Solenikov Add capability bits referencing support for IPv4 and UDP checksum validation for loop pktio device. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 389 (lumag:parse-checksums) ** https://github.com/Linaro/odp/pull/389 ** Patch: https://github.com/Linaro/odp/pull/389.patch ** Base sha: 49ebafae0edebbc750742d8874ad0a7588286dea ** Merge commit sha: 29d9c9fa8235c01897c72e823b57525e37f896d3 **/ platform/linux-generic/pktio/loop.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/platform/linux-generic/pktio/loop.c b/platform/linux-generic/pktio/loop.c index bf6365e94..9b470c083 100644 --- a/platform/linux-generic/pktio/loop.c +++ b/platform/linux-generic/pktio/loop.c @@ -250,6 +250,8 @@ static int loopback_capability(pktio_entry_t *pktio_entry ODP_UNUSED, odp_pktio_config_init(&capa->config); capa->config.pktin.bit.ts_all = 1; capa->config.pktin.bit.ts_ptp = 1; + capa->config.pktin.bit.ipv4_chksum = 1; + capa->config.pktin.bit.udp_chksum = 1; capa->config.inbound_ipsec = 1; capa->config.outbound_ipsec = 1;