From patchwork Wed Aug 16 08:00:06 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: 110211 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp460659qge; Wed, 16 Aug 2017 01:04:14 -0700 (PDT) X-Received: by 10.55.7.139 with SMTP id 133mr959892qkh.165.1502870654772; Wed, 16 Aug 2017 01:04:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502870654; cv=none; d=google.com; s=arc-20160816; b=dtIz3q/l7Zjyu6KSubT0rSHg2DQS161TK+DPZSdxvDVGXJF2iW/YXXER+0XXW4Qf55 up6b+iPVuKqR9LY57h++oCTYEvsKOcT05GSS5mboFKJK3tCFjNyK7/mcIjaXpbLEnhpa uD0AF2FJ9iFxo4yQghwbBfZg7BogKiTnSD/YNp28LjKJkJM30CEw5iD6+c0w51pip4vh fG0A07feMSwgnLJx9r6D7oPoI1kFrzQJjxrCrlLdPRc0Gs3zOHyS9ZBGcr0zmhj4ityY bl3XI6F55BSfbJFKyYcrW0HgFzOLzuEEbpQNJcI7y2XvsOpuBvNBx82Et/U6FV3OLVWD gRDg== 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=NIF2bxVRlE6EejRSm8x2LvNk74H4CkRDXbtyUHpfqgU=; b=WuKU9hfYz7gvjhcUkKDCuIGf6SDPipxSUVWnxGGPqsknd0UfXm2GdSqQ1qkskhV5LK 51Nb9mpuBj/6b1al3DFmnWeIPNhebKUCUl/NziYiBpZwLID7lhjjR/8zrngBs+HhBMte +CcVgTteFng4k9P+0yfvM+ptsw2LuOqn1U3QQl9vRW/NFvsnKRujUyustI0Jj5WcwUKQ pXDkI1QYAqIlFMtCyw210SwEr3IxuWXCD+Yb+CEJWoWNsVfWIpcctdBg+S0WmhwXy4bA kWSNLPSWyIpN2M4x9ZnnQUQPp6QhIk2I8huuRqfedpktw+++1nwVsE8LQmHl6TDlIkVT hXSw== ARC-Authentication-Results: i=1; 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 sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id n188si253413qkb.440.2017.08.16.01.04.14; Wed, 16 Aug 2017 01:04:14 -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 sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 6DABA644C2; Wed, 16 Aug 2017 08:04:14 +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=BAYES_00,FREEMAIL_FROM, 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 4AC5B644B6; Wed, 16 Aug 2017 08:01:24 +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 52D7E644A6; Wed, 16 Aug 2017 08:01:04 +0000 (UTC) Received: from forward105o.mail.yandex.net (forward105o.mail.yandex.net [37.140.190.183]) by lists.linaro.org (Postfix) with ESMTPS id 6AAA46447C for ; Wed, 16 Aug 2017 08:00:41 +0000 (UTC) Received: from mxback6o.mail.yandex.net (mxback6o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::20]) by forward105o.mail.yandex.net (Yandex) with ESMTP id 50FFF44444DC for ; Wed, 16 Aug 2017 11:00:35 +0300 (MSK) Received: from smtp1j.mail.yandex.net (smtp1j.mail.yandex.net [2a02:6b8:0:801::ab]) by mxback6o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id bMAFyPVaRm-0ZUKvaWM; Wed, 16 Aug 2017 11:00:35 +0300 Received: by smtp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id lI5XI3wvqw-0Y1GxLhI; Wed, 16 Aug 2017 11:00:34 +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: Wed, 16 Aug 2017 11:00:06 +0300 Message-Id: <1502870408-2658-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1502870408-2658-1-git-send-email-odpbot@yandex.ru> References: <1502870408-2658-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 124 Subject: [lng-odp] [PATCH v2 4/6] linux-gen: dpdk: RX - process checksum validation offload 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 Signed-off-by: Bogdan Pricope --- /** Email created from pull request 124 (bogdanPricope:dpdk_hw_csum_pr) ** https://github.com/Linaro/odp/pull/124 ** Patch: https://github.com/Linaro/odp/pull/124.patch ** Base sha: 90d4ce1b3b25ca18446131906007571cc0ed0191 ** Merge commit sha: 223e557905dfa62704233e593e0a052a44fb3b4e **/ platform/linux-generic/pktio/dpdk.c | 47 +++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index a5e1d4b5..af727ae0 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -301,6 +301,40 @@ static struct rte_mempool_ops ops_stack = { MEMPOOL_REGISTER_OPS(ops_stack); +#define HAS_L4_PROTO(m, proto) ((m->packet_type & RTE_PTYPE_L4_MASK) == proto) + +static inline int pkt_set_ol_rx(odp_pktin_config_opt_t *pktin_cfg, + odp_packet_hdr_t *pkt_hdr, + struct rte_mbuf *mbuf) +{ + if (pktin_cfg->bit.ipv4_chksum && + (mbuf->packet_type & RTE_PTYPE_L3_IPV4) && + mbuf->ol_flags & PKT_RX_IP_CKSUM_BAD) { + if (pktin_cfg->bit.drop_ipv4_err) + return -1; + + pkt_hdr->p.error_flags.ip_err = 1; + } + + if (pktin_cfg->bit.udp_chksum && + HAS_L4_PROTO(mbuf, RTE_PTYPE_L4_UDP) && + mbuf->ol_flags & PKT_RX_L4_CKSUM_BAD) { + if (pktin_cfg->bit.drop_udp_err) + return -1; + + pkt_hdr->p.error_flags.udp_err = 1; + } else if (pktin_cfg->bit.tcp_chksum && + HAS_L4_PROTO(mbuf, RTE_PTYPE_L4_TCP) && + mbuf->ol_flags & PKT_RX_L4_CKSUM_BAD) { + if (pktin_cfg->bit.drop_tcp_err) + return -1; + + pkt_hdr->p.error_flags.tcp_err = 1; + } + + return 0; +} + static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry, odp_packet_t pkt_table[], struct rte_mbuf *mbuf_table[], @@ -315,6 +349,7 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry, int nb_pkts = 0; int alloc_len, num; odp_pool_t pool = pktio_entry->s.pkt_dpdk.pool; + odp_pktin_config_opt_t *pktin_cfg = &pktio_entry->s.config.pktin; /* Allocate maximum sized packets */ alloc_len = pktio_entry->s.pkt_dpdk.data_room; @@ -369,6 +404,12 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry, packet_set_ts(pkt_hdr, ts); + if (pkt_set_ol_rx(pktin_cfg, pkt_hdr, mbuf)) { + odp_packet_free(pkt); + rte_pktmbuf_free(mbuf); + continue; + } + pkt_table[nb_pkts++] = pkt; rte_pktmbuf_free(mbuf); @@ -435,6 +476,7 @@ static inline int mbuf_to_pkt_zero(pktio_entry_t *pktio_entry, int i; int nb_pkts = 0; odp_pool_t pool = pktio_entry->s.pkt_dpdk.pool; + odp_pktin_config_opt_t *pktin_cfg = &pktio_entry->s.config.pktin; for (i = 0; i < mbuf_num; i++) { odp_packet_hdr_t parsed_hdr; @@ -480,6 +522,11 @@ static inline int mbuf_to_pkt_zero(pktio_entry_t *pktio_entry, packet_set_ts(pkt_hdr, ts); + if (pkt_set_ol_rx(pktin_cfg, pkt_hdr, mbuf)) { + rte_pktmbuf_free(mbuf); + continue; + } + pkt_table[nb_pkts++] = pkt; }