From patchwork Thu Nov 9 09:00:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 118402 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp6334250qgn; Thu, 9 Nov 2017 01:04:11 -0800 (PST) X-Google-Smtp-Source: ABhQp+Q220J2gUr1SBA+FRFWLxJPLG/T/HmDZ3TetbHyjcr3J8ATrkaszQMa+PyBSb0Tt+ER7fJO X-Received: by 10.237.49.162 with SMTP id 31mr5036834qth.240.1510218251126; Thu, 09 Nov 2017 01:04:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510218251; cv=none; d=google.com; s=arc-20160816; b=ZscfEFQM3PDIoxVNC0WlQtII75Yvt+WocLpv8tHOx9mB3CGkwD3f1KlAMmklSRenap 58yYK1xqRLoU1Fg3SzTxxzmqhgoNJiVJy2E2Lu3MkJ1eAHPn0YWk4R3640rRykep7jKa 8iZIcEFvBvhAfWZxoxL7NMoFd/Mr3ajZyaqL+4eFfIYeF85TvAUoVfNqs60a8AEpgDOq ooHb/7sQPpOMgBsWiwlkkupuuYOaGXBxiQplOvjh74wgYD1Mfs7p0fyRMdEGBepflpZD 97TiOvQEWNxZBKkFg34/YvgUqRicc1XYjdH9fo+NC0y8tsfnVZAlgfofvfTYm7P1V7v8 R9BQ== 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=gzeR+yRYi9JWtZ/3paGkofeufx9Zs9tFV8kqcDneGMo=; b=LEDJsaLHQtoR/E9tSNtVN1Cp94pSZ5uGR7gkXmOolNZReFf86PCzFCfXmMzGh8sQfG MMJoUafNSeTXnZP3X9rSnWkRk31MqLHnBpzPI4oqpT6xCbaYdokHB46Vno7DsFHP3Aqu rLgT79Frv4ZXl6Y28DvxYLXedvwxowbYAKLn5pr95qI15W7eiPSsT/4Sp9jXqqgbZyYb pQypBLg3N03k9vunfcoLwRdYYWIcdHC+1v3J7vZyerx1+gfhXxVNJlUh1zmhu+LQWbPC E3Klu9KoeenXPQMN3RNQl6iS3rWmR2CVjCRM2EGFXFPyHAkJ+YxGIApL8P5zQDLr4lcU P5sg== 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 b37si5751925qtk.315.2017.11.09.01.04.10; Thu, 09 Nov 2017 01:04: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 9C87E60C51; Thu, 9 Nov 2017 09:04: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,URIBL_BLOCKED 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 D5AFA607BA; Thu, 9 Nov 2017 09:01: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 E0C3D607B2; Thu, 9 Nov 2017 09:01:29 +0000 (UTC) Received: from forward100j.mail.yandex.net (forward100j.mail.yandex.net [5.45.198.240]) by lists.linaro.org (Postfix) with ESMTPS id 95FE360594 for ; Thu, 9 Nov 2017 09:00:38 +0000 (UTC) Received: from mxback2j.mail.yandex.net (mxback2j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10b]) by forward100j.mail.yandex.net (Yandex) with ESMTP id 58C1B5D82A99 for ; Thu, 9 Nov 2017 12:00:24 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback2j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id Xc5ijIpHfi-0OK0cXC9; Thu, 09 Nov 2017 12:00:24 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id AXFYGb2yvs-0NtW2Ef3; Thu, 09 Nov 2017 12:00:23 +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: Thu, 9 Nov 2017 12:00:16 +0300 Message-Id: <1510218017-21165-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510218017-21165-1-git-send-email-odpbot@yandex.ru> References: <1510218017-21165-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 269 Subject: [lng-odp] [PATCH API-NEXT v2 3/4] linux-gen: pktio: dpdk: set L3/L4 checksum validation flags 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: Bogdan Pricope L3/L4 checksum validation flags are used to report L3/L4 checksum check status for the incoming packets. Signed-off-by: Bogdan Pricope --- /** Email created from pull request 269 (bogdanPricope:api_next_csum_status_pr) ** https://github.com/Linaro/odp/pull/269 ** Patch: https://github.com/Linaro/odp/pull/269.patch ** Base sha: d22c949cc466bf28de559855a1cb525740578137 ** Merge commit sha: 31b12178be4753494e806513020d7706600c8382 **/ platform/linux-generic/pktio/dpdk.c | 57 ++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index 9782d60c4..764ed37d4 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -337,9 +337,9 @@ static struct rte_mempool_ops ops_stack = { MEMPOOL_REGISTER_OPS(ops_stack); -#define HAS_IP4_CSUM_FLAG(m, f) ((m->ol_flags & PKT_RX_IP_CKSUM_MASK) == f) +#define IP4_CSUM_RESULT(m) (m->ol_flags & PKT_RX_IP_CKSUM_MASK) +#define L4_CSUM_RESULT(m) (m->ol_flags & PKT_RX_L4_CKSUM_MASK) #define HAS_L4_PROTO(m, proto) ((m->packet_type & RTE_PTYPE_L4_MASK) == proto) -#define HAS_L4_CSUM_FLAG(m, f) ((m->ol_flags & PKT_RX_L4_CKSUM_MASK) == f) #define PKTIN_CSUM_BITS 0x1C @@ -347,29 +347,52 @@ static inline int pkt_set_ol_rx(odp_pktin_config_opt_t *pktin_cfg, odp_packet_hdr_t *pkt_hdr, struct rte_mbuf *mbuf) { + uint64_t packet_csum_result; + if (pktin_cfg->bit.ipv4_chksum && - RTE_ETH_IS_IPV4_HDR(mbuf->packet_type) && - HAS_IP4_CSUM_FLAG(mbuf, PKT_RX_IP_CKSUM_BAD)) { - if (pktin_cfg->bit.drop_ipv4_err) - return -1; + RTE_ETH_IS_IPV4_HDR(mbuf->packet_type)) { + packet_csum_result = IP4_CSUM_RESULT(mbuf); + + if (packet_csum_result == PKT_RX_IP_CKSUM_GOOD) { + pkt_hdr->p.input_flags.l3_chksum_done = 1; + } else if (packet_csum_result != PKT_RX_IP_CKSUM_UNKNOWN) { + if (pktin_cfg->bit.drop_ipv4_err) + return -1; - pkt_hdr->p.error_flags.ip_err = 1; + pkt_hdr->p.input_flags.l3_chksum_done = 1; + pkt_hdr->p.error_flags.ip_err = 1; + pkt_hdr->p.error_flags.l3_chksum = 1; + } } if (pktin_cfg->bit.udp_chksum && - HAS_L4_PROTO(mbuf, RTE_PTYPE_L4_UDP) && - HAS_L4_CSUM_FLAG(mbuf, PKT_RX_L4_CKSUM_BAD)) { - if (pktin_cfg->bit.drop_udp_err) - return -1; + HAS_L4_PROTO(mbuf, RTE_PTYPE_L4_UDP)) { + packet_csum_result = L4_CSUM_RESULT(mbuf); - pkt_hdr->p.error_flags.udp_err = 1; + if (packet_csum_result == PKT_RX_L4_CKSUM_GOOD) { + pkt_hdr->p.input_flags.l4_chksum_done = 1; + } else if (packet_csum_result != PKT_RX_L4_CKSUM_UNKNOWN) { + if (pktin_cfg->bit.drop_udp_err) + return -1; + + pkt_hdr->p.input_flags.l4_chksum_done = 1; + pkt_hdr->p.error_flags.udp_err = 1; + pkt_hdr->p.error_flags.l4_chksum = 1; + } } else if (pktin_cfg->bit.tcp_chksum && - HAS_L4_PROTO(mbuf, RTE_PTYPE_L4_TCP) && - HAS_L4_CSUM_FLAG(mbuf, PKT_RX_L4_CKSUM_BAD)) { - if (pktin_cfg->bit.drop_tcp_err) - return -1; + HAS_L4_PROTO(mbuf, RTE_PTYPE_L4_TCP)) { + packet_csum_result = L4_CSUM_RESULT(mbuf); - pkt_hdr->p.error_flags.tcp_err = 1; + if (packet_csum_result == PKT_RX_L4_CKSUM_GOOD) { + pkt_hdr->p.input_flags.l4_chksum_done = 1; + } else if (packet_csum_result != PKT_RX_L4_CKSUM_UNKNOWN) { + if (pktin_cfg->bit.drop_tcp_err) + return -1; + + pkt_hdr->p.input_flags.l4_chksum_done = 1; + pkt_hdr->p.error_flags.tcp_err = 1; + pkt_hdr->p.error_flags.l4_chksum = 1; + } } return 0;