From patchwork Tue Aug 22 08:00:08 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: 110616 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp5005482obb; Tue, 22 Aug 2017 01:03:42 -0700 (PDT) X-Received: by 10.200.48.151 with SMTP id v23mr7540582qta.339.1503389022813; Tue, 22 Aug 2017 01:03:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503389022; cv=none; d=google.com; s=arc-20160816; b=ADSSKfx/fWDP8XOf9tz2PjMHWf1dk9FyNnuHt96XJFrCSQySWPMKS1RAjAc8QhXsRm iZWZC2v5kAqpuwP0++wvO6u5Dc4dlqXJTi4FwceA1xvF8mdWLIM7mTaJ5AsoZ2VMY3+4 68CVgpufTkwQGiiY16dAnm/mB5Va8cy3ttyoxAbi8jat9f0EHpP8g5HzHUlMnv05DbjT WgrwNtQXU9RdGL8MkVv1Fjz6sMfFOSZU0vpaYe7pqm12ulEVJheBHqK6sZ8hgd7d0WZa fkW8GrpflqRlnshn1YRJ2GJsHi8+2CvxDFJOUV3ldSsIcSAUheLexL+VDB3yBsAPL+7g hBGg== 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=s8LEgKrv7TTBI2VkPnB0SBJtNyKGi7iZeRwyJmwrdRw=; b=amYeCAtnYzqWMtp6rCBl3Qd2zi41RTj4K/pE6thBOAQprhlu+n8QE8dCGixlgWJQ/j LK7NXsPlaQaJXS7RoEm4lYAYKU/mmQr4XJLYoxlWKQOTo2fIik/JBxhaMdwI5U+0wvGY sMXVjgepWe+35ClycfzQPM/KNCgAgBkEJyERsacrjtiTJ75VVasWxJ6PHUjAP7ODqlUc 9lolURLbqSZoWVAyeNHCZRO6HuXe9M1dwOHrA8Lg7fZhjcKllQjyMFpHe9Kqo4wttOHx BSdDl2B4xgf4hrNFlPAyPiWnNftm/V+dJ9wVD23AQfX96Z5g3HSlRBVLMogX3U1wJBaq QAXg== 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 g123si13275621qkd.142.2017.08.22.01.03.42; Tue, 22 Aug 2017 01:03:42 -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 57140644B7; Tue, 22 Aug 2017 08:03:42 +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 03A4564492; Tue, 22 Aug 2017 08:01:12 +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 6CFB2644CD; Tue, 22 Aug 2017 08:00:49 +0000 (UTC) Received: from forward101o.mail.yandex.net (forward101o.mail.yandex.net [37.140.190.181]) by lists.linaro.org (Postfix) with ESMTPS id BD91664492 for ; Tue, 22 Aug 2017 08:00:17 +0000 (UTC) Received: from mxback9g.mail.yandex.net (mxback9g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:170]) by forward101o.mail.yandex.net (Yandex) with ESMTP id 6241E134384E for ; Tue, 22 Aug 2017 11:00:16 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback9g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id WvxBFICcsW-0FEaK9pn; Tue, 22 Aug 2017 11:00:16 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id IVkIzK7jNZ-0F0Gqopl; Tue, 22 Aug 2017 11:00:15 +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, 22 Aug 2017 11:00:08 +0300 Message-Id: <1503388810-6999-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503388810-6999-1-git-send-email-odpbot@yandex.ru> References: <1503388810-6999-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 124 Subject: [lng-odp] [PATCH v3 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: aecb3c7a442b426761f1e6f43308a1e9ea709ef3 ** Merge commit sha: 23658e7f5acf9d3621ec7a8f617db98a26ee1bda **/ platform/linux-generic/pktio/dpdk.c | 59 +++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index 693c0c97..6dfb8c7a 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -301,6 +301,48 @@ static struct rte_mempool_ops ops_stack = { MEMPOOL_REGISTER_OPS(ops_stack); +#define HAS_IP4_PROTO(m, proto) ((m->packet_type & RTE_PTYPE_L3_MASK) == proto) +#define HAS_IP4_PROTOS(m) (HAS_IP4_PROTO(m, RTE_PTYPE_L3_IPV4) ||\ + HAS_IP4_PROTO(m, RTE_PTYPE_L3_IPV4_EXT) ||\ + HAS_IP4_PROTO(m, RTE_PTYPE_L3_IPV4_EXT_UNKNOWN)) +#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 && + HAS_IP4_PROTOS(mbuf) && + 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[], @@ -315,6 +357,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 +412,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); @@ -435,6 +486,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 +532,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; }