From patchwork Tue Sep 5 10:06:33 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: 111650 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp2632014qge; Tue, 5 Sep 2017 03:17:19 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5dI9NgrncIyNsMCVnG+1eNmUFyoro1TTPfthrBsr6p3ccAXCPgF1lN8Z8KypsDim4qvLtK X-Received: by 10.55.209.155 with SMTP id o27mr4779502qkl.145.1504606639158; Tue, 05 Sep 2017 03:17:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504606639; cv=none; d=google.com; s=arc-20160816; b=K9t2Zbr72dgR8d2XmzjakOhLU3q0X9/ZGnMomXe0r7WkoRlT8UKqQLCejPbMCTXdTp VwR2Hn3zhq7VpRJH8u7gAK5NR2BuORYq7rowjPEdWTHOBRZ0F6sSSv/09Sk4ATaxB9yT g+ktnKhi33PcDEKZ+XQjXv0h73aYNVpJIRQz/DXPvKYJyk1kaypZgWdCq51sHR7SPEo/ AfmQ8g/S+IxUbO/TCWO458RDdAQogNK8/FPjmdJXuGsy2cC1UfJH4A02xS0rgt6Gtueq kbZKma9RZZwL6Fn7Wl5m78T/bXb0oYnkKAPcXuWqNDQdKbPKjV8C0ZgeIUH9JHhOvblK 4jjg== 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=SGZ0LUzW5Fn3egn6oD42C0ephHn4xQwsqTBJWKJKnFI=; b=D+Px+no4bVStRD4roaXxC/H+11+f1cHvkWgidiuCRQ+cNW2Wy7GhBcpDG5vE5vI5Ul bTreTSjGIu6ayeLU4vDtUWv/4UGxMk4C/mcYfHzFXJ7wPYbwllOaOSDbv8O2Dx/C+JSi vFdtfu0643my7iaKrB+ki1PfVXjQ7AJFovBMP5Nfz1Jvkwtf44x5r0iYYpmL5QKLQKiM qbpTl3ovaly5j4DlJngVGtpv7dFyRTv9SnsZ7bDNd3M9XMS34HRKPys7n0EGikI//M3+ KzQwlK9Xs1sWAFoIhX3Sj58zAGPm4V0JqUWdS1b2HYZcNjncwZLIIGygEEhjTqgC8y9z rIVA== 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 62si294789qtb.398.2017.09.05.03.17.18; Tue, 05 Sep 2017 03:17:19 -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 D1DA2644E9; Tue, 5 Sep 2017 10:17:18 +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, RCVD_IN_DNSWL_NONE,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 385A561CBB; Tue, 5 Sep 2017 10:09:21 +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 1FB2F61BBA; Tue, 5 Sep 2017 10:09:01 +0000 (UTC) Received: from forward104j.mail.yandex.net (forward104j.mail.yandex.net [5.45.198.247]) by lists.linaro.org (Postfix) with ESMTPS id 931E460D79 for ; Tue, 5 Sep 2017 10:06:43 +0000 (UTC) Received: from mxback16j.mail.yandex.net (mxback16j.mail.yandex.net [IPv6:2a02:6b8:0:1619::92]) by forward104j.mail.yandex.net (Yandex) with ESMTP id 4786B41F5D for ; Tue, 5 Sep 2017 13:06:42 +0300 (MSK) Received: from smtp3p.mail.yandex.net (smtp3p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:8]) by mxback16j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id yLWdOedW0u-6gxmQ7uq; Tue, 05 Sep 2017 13:06:42 +0300 Received: by smtp3p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id oPs3E3RFkM-6fOiA0Ed; Tue, 05 Sep 2017 13:06:41 +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: Tue, 5 Sep 2017 13:06:33 +0300 Message-Id: <1504605995-28026-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1504605995-28026-1-git-send-email-odpbot@yandex.ru> References: <1504605995-28026-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 124 Subject: [lng-odp] [PATCH v4 3/5] 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: 7508c5ac906bb7cb1d339b4c5e924f3a18e504ca ** Merge commit sha: 086fe31f96e49f97f945702d0691f019245b959c **/ platform/linux-generic/pktio/dpdk.c | 55 +++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index f2a54b75..891adcd5 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -303,6 +303,44 @@ 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 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 + +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 && + 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; + + pkt_hdr->p.error_flags.ip_err = 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; + + pkt_hdr->p.error_flags.udp_err = 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; + + 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[], @@ -317,6 +355,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; @@ -371,6 +410,14 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry, packet_set_ts(pkt_hdr, ts); + if (pktin_cfg->all_bits & PKTIN_CSUM_BITS) { + 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); @@ -437,6 +484,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; @@ -482,6 +530,13 @@ static inline int mbuf_to_pkt_zero(pktio_entry_t *pktio_entry, packet_set_ts(pkt_hdr, ts); + if (pktin_cfg->all_bits & PKTIN_CSUM_BITS) { + if (pkt_set_ol_rx(pktin_cfg, pkt_hdr, mbuf)) { + rte_pktmbuf_free(mbuf); + continue; + } + } + pkt_table[nb_pkts++] = pkt; }