From patchwork Fri Nov 24 12: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: 119576 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2115208qgn; Fri, 24 Nov 2017 04:02:43 -0800 (PST) X-Google-Smtp-Source: AGs4zMb/khpjsMWZNjw7ycKuXnpbmePcpwtNKusWsISO6UHnO3lxjhAFH3z75ica2XECwuO0iKS/ X-Received: by 10.55.105.131 with SMTP id e125mr9068741qkc.214.1511524963868; Fri, 24 Nov 2017 04:02:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511524963; cv=none; d=google.com; s=arc-20160816; b=wYkiWB1ofxHshAuKk3qkfAs94XDYF/QaatNR6Chgpignb9A0CU+x9ShdwiM9GDGpfl AYFDNUqzMMVZ1lMx6h4dzdV/4oNHm1mxRu6a0XK8BTRxMaTs5kDuQMhXnGJiF5DJToWr M8QCG4Zshkne15i1Ln0f8f1aPAW7E7lLrTm2QTe1faP8d6+z866HdPYJ+CPIEhqcKh6o wfb+35/mVlTmI0prL8SPtTq2sIqeDPQP6k/9zhgBULrw/SAU97I+/YrAyV6oskgtWIYO 7/PIvmcSqp8nwjEw2Ugm8jLxN9XUQBh+w1iChDhmFOYnEWrNjzyrDiJCHgKVO8ODNSCN W2Rw== 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=YQUqH/yQTcFZ1HIdDyaEExHbcxwgV9LrNHlVXjD2lMA=; b=g+RxSLSkxJoED3WlGp6hEe3oeF5i0bN2gv7j9VgQNXHJD2C/wzn+fXk+Alr11O9ONy RBtG479LRwCLfc3QEEONUSl4Q2j7yCND70EL830DbNqDTrU/RIQ3W+Qkk8Z71h4xbC1R YqRnzu8zrQFXUXXa0eHkeB2U16GN+Ekb3CENSwS7Oo/4nyLuq2YWMfqX4HCSuaDUhGqn XGaSHSx9Oy0UsW1gyxNDx9mKXNW6qUzER0kP7MW3KWMgzxYOa9WVAlEGLxm+IKA4+cNP DNXwwgiNt2XvSAPpOp7fI3uLV09Mm+tjgmIC4BxYxTfwJLvFIUWbDfpGUHvEQk/jsJcl EcCQ== 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 n21si808732qtn.284.2017.11.24.04.02.43; Fri, 24 Nov 2017 04:02:43 -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 826F560841; Fri, 24 Nov 2017 12:02:43 +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=-5.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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 4120760840; Fri, 24 Nov 2017 12:01:49 +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 C0EEE6082A; Fri, 24 Nov 2017 12:01:40 +0000 (UTC) Received: from forward100p.mail.yandex.net (forward100p.mail.yandex.net [77.88.28.100]) by lists.linaro.org (Postfix) with ESMTPS id 067F360816 for ; Fri, 24 Nov 2017 12:00:15 +0000 (UTC) Received: from mxback8g.mail.yandex.net (mxback8g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:169]) by forward100p.mail.yandex.net (Yandex) with ESMTP id 3190C5105390 for ; Fri, 24 Nov 2017 15:00:10 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback8g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id T7CDniqaKY-0AdqXKAK; Fri, 24 Nov 2017 15:00:10 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id S0Ac35Bt7M-09cuK7Fm; Fri, 24 Nov 2017 15:00:09 +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: Fri, 24 Nov 2017 15:00:08 +0300 Message-Id: <1511524808-24013-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511524808-24013-1-git-send-email-odpbot@yandex.ru> References: <1511524808-24013-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 306 Subject: [lng-odp] [PATCH API-NEXT v2 1/1] linux-gen: dpdk: check L3 offset validity 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: Petri Savolainen Application is required to set L3 offset when it requests checksum offload. It caused segfault to assume that L3 offset is always set. Minimize the number of if-clauses in non-checksum path by first checking L3 offset. This fixes https://bugs.linaro.org/show_bug.cgi?id=3491 Signed-off-by: Petri Savolainen --- /** Email created from pull request 306 (psavol:next-tx-checksum-bugfix) ** https://github.com/Linaro/odp/pull/306 ** Patch: https://github.com/Linaro/odp/pull/306.patch ** Base sha: b95e7d08043ba45d12635c5afaa3fbf3a07ecc90 ** Merge commit sha: 0b2307eeccad7cd5357e9559a6ee87696f067bed **/ platform/linux-generic/pktio/dpdk.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index 5032b8dfb..ccccc0a8a 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -567,7 +567,10 @@ static inline void pkt_set_ol_tx(odp_pktout_config_opt_t *pktout_cfg, pkt_p->output_flags.l4_chksum); if (!ipv4_chksum_pkt && !udp_chksum_pkt && !tcp_chksum_pkt) - return; + return; + + if (pkt_p->l4_offset == ODP_PACKET_OFFSET_INVALID) + return; mbuf->l2_len = pkt_p->l3_offset - pkt_p->l2_offset; mbuf->l3_len = pkt_p->l4_offset - pkt_p->l3_offset; @@ -607,8 +610,6 @@ static inline int pkt_to_mbuf(pktio_entry_t *pktio_entry, char *data; uint16_t pkt_len; odp_pktout_config_opt_t *pktout_cfg = &pktio_entry->s.config.pktout; - odp_pktout_config_opt_t *pktout_capa = - &pktio_entry->s.capa.config.pktout; if (odp_unlikely((rte_pktmbuf_alloc_bulk(pkt_dpdk->pkt_pool, mbuf_table, num)))) { @@ -616,7 +617,9 @@ static inline int pkt_to_mbuf(pktio_entry_t *pktio_entry, return 0; } for (i = 0; i < num; i++) { - pkt_len = _odp_packet_len(pkt_table[i]); + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt_table[i]); + + pkt_len = packet_len(pkt_hdr); if (pkt_len > pkt_dpdk->mtu) { if (i == 0) @@ -629,10 +632,13 @@ static inline int pkt_to_mbuf(pktio_entry_t *pktio_entry, odp_packet_copy_to_mem(pkt_table[i], 0, pkt_len, data); - if (pktout_capa->all_bits) - pkt_set_ol_tx(pktout_cfg, pktout_capa, - odp_packet_hdr(pkt_table[i]), + if (pkt_hdr->p.l3_offset != ODP_PACKET_OFFSET_INVALID) { + odp_pktout_config_opt_t *pktout_capa = + &pktio_entry->s.capa.config.pktout; + + pkt_set_ol_tx(pktout_cfg, pktout_capa, pkt_hdr, mbuf_table[i], data); + } } return i; @@ -741,9 +747,9 @@ static inline int pkt_to_mbuf_zero(pktio_entry_t *pktio_entry, pkt_hdr->extra_type == PKT_EXTRA_TYPE_DPDK)) { mbuf_update(mbuf, pkt_hdr, pkt_len); - if (pktout_capa->all_bits) + if (pkt_hdr->p.l3_offset != ODP_PACKET_OFFSET_INVALID) pkt_set_ol_tx(pktout_cfg, pktout_capa, pkt_hdr, - mbuf, odp_packet_data(pkt)); + mbuf, _odp_packet_data(pkt)); } else { pool_t *pool_entry = pkt_hdr->buf_hdr.pool_ptr; @@ -764,11 +770,11 @@ static inline int pkt_to_mbuf_zero(pktio_entry_t *pktio_entry, mbuf_init((struct rte_mempool *) pool_entry->ext_desc, mbuf, pkt_hdr); mbuf_update(mbuf, pkt_hdr, pkt_len); - if (pktout_capa->all_bits) + if (pkt_hdr->p.l3_offset != + ODP_PACKET_OFFSET_INVALID) pkt_set_ol_tx(pktout_cfg, pktout_capa, - pkt_hdr, - mbuf, - odp_packet_data(pkt)); + pkt_hdr, mbuf, + _odp_packet_data(pkt)); } } mbuf_table[i] = mbuf;