From patchwork Wed May 31 14:40:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bogdan Pricope X-Patchwork-Id: 100793 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp356953qge; Wed, 31 May 2017 07:43:09 -0700 (PDT) X-Received: by 10.237.62.115 with SMTP id m48mr30446363qtf.179.1496241789446; Wed, 31 May 2017 07:43:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496241789; cv=none; d=google.com; s=arc-20160816; b=k0UxlNLAhVg4jGB5mtGwmgmi0oKZ8LG2c+BVc/nUM8Jh8RXN+TJ+x0SDthgZJuS0s+ IhyBoQAhk2mtyYIa4J0uSoMw6V/V672cpxnTyTfR5L2gUaGcJx83KPpZ+jRObWoLCWot VWeTdhXfUs3UaUgvBdU7xaJ1Emm+oRbgxCMK75rh0L7lpVULPLIyuvUW3gOimLErQuBA Mtt5J6OP6jEUxqVv/axJSEq+aQo7ObuRsiMFYglF16AzrslxB3TZH0xN9sdw9D7bIMWO Ar5JQK3E/ptomrvVmELMgi5gP7SX4DdbzI31QECdkwtbi8wzha4iPeJtIa+DDkzj6KnH caLQ== 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:references:in-reply-to :message-id:date:to:from:delivered-to:arc-authentication-results; bh=3InCbwKle5Qoza8L3a5RSq2fnOTAlGP1Y/2uZ3YjR/s=; b=XygGb54AxfJrVMAvHaN+tWPBJGY/5UW19pIVyLEKTDth3EFgv4dQqcFtLj+tSyEblb LeIYZvh5Aecio0ZZoi0W26oCD2Xi0EE85IAKVsEbXyRWe2ZOCZ7bNABeyp0SpEkcQgso bP1pCDGqd8cdJL+u5TzZKMxRqW7odEiz00UeXqXjMUzQ7mRzRNoJikXH9f7XRHzN2zXA yiF9Guftqtc9sk2+Liyz6qsu33DiB1m4MzASVLEBlLxrLXVr2J4R7n8EBWm8e2cKYwYj aoNTb6UcxUJGU4jP4GefrRTZ254D+MFnjtjPO0bYCIHpcwFq7SPiMppPODAys1cO2c3R 3P5A== 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id p68si16292697qkb.237.2017.05.31.07.43.09; Wed, 31 May 2017 07:43:09 -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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 2124F60CBA; Wed, 31 May 2017 14:43:09 +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.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_SPAM, 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 362CA60CE2; Wed, 31 May 2017 14:41: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 9B68660729; Wed, 31 May 2017 14:41:22 +0000 (UTC) Received: from mail-wm0-f44.google.com (mail-wm0-f44.google.com [74.125.82.44]) by lists.linaro.org (Postfix) with ESMTPS id BE6EE60690 for ; Wed, 31 May 2017 14:41:20 +0000 (UTC) Received: by mail-wm0-f44.google.com with SMTP id e127so23686862wmg.1 for ; Wed, 31 May 2017 07:41:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3InCbwKle5Qoza8L3a5RSq2fnOTAlGP1Y/2uZ3YjR/s=; b=X8wW4CGCaRh6PnQroIKk2/k4dcFow9lVHb+6xbR0U9CLTei2Y/hCOylmN5QbgO9Mxr C7z4zbxXaEAlawt2Nkt0gf2OkcvvRDpu5ggfiCXVIKfy28ztxt/o1QiuidB8CClJiMgV KwACjHS+Si3Ia6whNBuppZHmVUFAdtGEqPLSny5RA9UFCLtlC6UXclDuJuIPYgiwx9WS eLysZPAwtikxRsZ7PWsZZkviGSAzXhssKtIJoKx0b88+KGQWxTJSwRHQbB8LMVK3M2Aj /PpWe5kGwqq4frPH775ApNj+S6s4i4jgfAt37WHSx7og1/cQyOpdHA8FOCxQz8mo3CpQ O0lQ== X-Gm-Message-State: AODbwcDYVKGRJxB4EO+6sOw9jLkaXM/672tiWcXosRZGFBcixn3CvNk4 WeKr3VsS8v5Ccn+q/LwmGMz3 X-Received: by 10.223.177.215 with SMTP id r23mr21421917wra.97.1496241679676; Wed, 31 May 2017 07:41:19 -0700 (PDT) Received: from netbricks-team.enea.se ([193.202.22.66]) by smtp.gmail.com with ESMTPSA id e23sm22483032wre.54.2017.05.31.07.41.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 31 May 2017 07:41:19 -0700 (PDT) From: Bogdan Pricope To: lng-odp@lists.linaro.org Date: Wed, 31 May 2017 17:40:58 +0300 Message-Id: <1496241660-27492-5-git-send-email-bogdan.pricope@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1496241660-27492-1-git-send-email-bogdan.pricope@linaro.org> References: <1496241660-27492-1-git-send-email-bogdan.pricope@linaro.org> Subject: [lng-odp] [PATCH 4/6] 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" Signed-off-by: Bogdan Pricope --- platform/linux-generic/pktio/dpdk.c | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) -- 1.9.1 diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index 94d2abe..58e6db0 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -649,6 +649,8 @@ static int dpdk_stop(pktio_entry_t *pktio_entry) return 0; } +#define HAS_L4_PROTO(m, proto) ((m->packet_type & RTE_PTYPE_L4_MASK) == proto) + static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry, odp_packet_t pkt_table[], struct rte_mbuf *mbuf_table[], @@ -663,9 +665,11 @@ 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; /* Allocate maximum sized packets */ alloc_len = pktio_entry->s.pkt_dpdk.data_room; + pktin_cfg = &pktio_entry->s.config.pktin; num = packet_alloc_multi(pool, alloc_len, pkt_table, mbuf_num); if (num != mbuf_num) { @@ -718,6 +722,40 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry, packet_set_ts(pkt_hdr, ts); + 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) { + odp_packet_free(pkt); + rte_pktmbuf_free(mbuf); + continue; + } else { + 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) { + odp_packet_free(pkt); + rte_pktmbuf_free(mbuf); + continue; + } else { + 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) { + odp_packet_free(pkt); + rte_pktmbuf_free(mbuf); + continue; + } else { + pkt_hdr->p.error_flags.tcp_err = 1; + } + } + pkt_table[nb_pkts++] = pkt; rte_pktmbuf_free(mbuf);