From patchwork Thu Nov 9 12:00:28 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: 118440 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp6505219qgn; Thu, 9 Nov 2017 04:07:02 -0800 (PST) X-Google-Smtp-Source: AGs4zMatvN5+YrBU12tAaKuZYIv2MrXgqu99RZncFI76TNf3sDMpA0tN3jwAavXIV+LCy+kZRSk9 X-Received: by 10.55.53.76 with SMTP id c73mr333418qka.147.1510229222287; Thu, 09 Nov 2017 04:07:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510229222; cv=none; d=google.com; s=arc-20160816; b=SoarK0MtxUp3pljwRpvsjBZu8UeRRIA64h+/YGqTdnzN3GABBc5qzIlCTMdUIx4lzv sbPe+RZ1K518TLHBmoZrbRav59lyrqKH3Xk7SnxVdrh3GJtSj/4toUjZzzxf6mdn4AlA 7kQ4rNqfmNHe9pw+9vn4AEadGag0WMPJgYZCgcrSYkTXmNH5toBBEb+Vhlbk8oqRRXCn 8o4cIG86GgV0jIHNo2ifwJE+d5UPv6ZH3QxwvsN1Odsff67UAMoyW6sMXgGJpNUUUYq6 6GNrGP69CSoBVZApKCiqXSru1muU1unVXhfjNfSbkAEOlcXO+Wr0XwCSTueme0dolSuU n1bQ== 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=ra9FjLvFahMNqMzvGhRgUZg9V91zO87rrqBJPspLGC0=; b=WnuWRyQezpPsHEED+yAA7nEwdLvsSVDpK1Po9ik/ouQN6QB9KBmsCVG1y5ww3Tkmlh we5E6772l1HDBtHvqpc7LJBIUBeuG04BjMSeObsfxE+l3SFDrCF9+hjXH86sNTSG+c+E GgFFv1b/lZ6NM8FOBf8HTH8d3hdAYikPrbft+GENv5l0NjFsD5imJ+Iq9nvGDSZQaFeM PXI7LauG8RIlm6NjQR/J+uCCHTzXOr9MvqGItLiMUqTc5SAJAwl+Q7Zx9PkGd1IVrnRa w2rBz4aJ2l9LviRiTEZNf7GPrLtb+pfVf/HLFGdzAWu9aEEvD61gg1gmW6pFabTXymKe e/Dg== 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 o13si417148qtg.227.2017.11.09.04.07.02; Thu, 09 Nov 2017 04:07:02 -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 E54AF60D3C; Thu, 9 Nov 2017 12:07:01 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 E060F61001; Thu, 9 Nov 2017 12:02:48 +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 AE05560CCA; Thu, 9 Nov 2017 12:02:25 +0000 (UTC) Received: from forward101o.mail.yandex.net (forward101o.mail.yandex.net [37.140.190.181]) by lists.linaro.org (Postfix) with ESMTPS id 0890F61003 for ; Thu, 9 Nov 2017 12:00:33 +0000 (UTC) Received: from mxback1o.mail.yandex.net (mxback1o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1b]) by forward101o.mail.yandex.net (Yandex) with ESMTP id D781D134716C for ; Thu, 9 Nov 2017 15:00:31 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback1o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 5M4uwkOZiH-0V9eiIRg; Thu, 09 Nov 2017 15:00:31 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id InclDaSPWn-0VnOFb33; Thu, 09 Nov 2017 15:00:31 +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: Thu, 9 Nov 2017 15:00:28 +0300 Message-Id: <1510228830-21766-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510228830-21766-1-git-send-email-odpbot@yandex.ru> References: <1510228830-21766-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 242 Subject: [lng-odp] [PATCH API-NEXT v4 1/3] api: packet: ones complement sum 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 Added packet metadata for ones complement sum over packet data. Some NICs calculate the sum during packet input (at least for IP fragments) and store the value into the packet descriptor. This offloads L4 checksum calculation for IP fragments as SW does not need sum all payload data, but just combine pre-calculated sums from packet descriptors and remove extra header fields from the sum. Signed-off-by: Petri Savolainen --- /** Email created from pull request 242 (psavol:next-checksum-metadata) ** https://github.com/Linaro/odp/pull/242 ** Patch: https://github.com/Linaro/odp/pull/242.patch ** Base sha: d22c949cc466bf28de559855a1cb525740578137 ** Merge commit sha: 02aa905e6f9d4be66e19ccdb577e40a293be2902 **/ include/odp/api/spec/packet.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h index fac7790ba..8e1575600 100644 --- a/include/odp/api/spec/packet.h +++ b/include/odp/api/spec/packet.h @@ -1437,6 +1437,26 @@ void odp_packet_l3_chksum_insert(odp_packet_t pkt, int insert); void odp_packet_l4_chksum_insert(odp_packet_t pkt, int insert); /** + * Ones' complement sum of packet data + * + * Returns 16-bit ones' complement sum that was calculated over a portion of + * packet data during a packet processing operation (e.g. packet input or + * IPSEC offload). The data range is output with 'range' parameter, and usually + * includes IP payload (L4 headers and payload). When 'range.length' is zero, + * the sum has not been calculated. In case of odd number of bytes, + * calculation uses a zero byte as padding at the end. The sum may be used as + * part of e.g. UDP/TCP checksum checking, especially with IP fragments. + * + * @param pkt Packet handle + * @param[out] range Data range of the sum (output). The calculation started + * from range.offset and included range.length bytes. When + * range.length is zero, the sum has not been calculated. + * + * @return Ones' complement sum over the data range + */ +uint16_t odp_packet_ones_comp(odp_packet_t pkt, odp_packet_data_range_t *range); + +/** * Packet flow hash value * * Returns the hash generated from the packet header. Use From patchwork Thu Nov 9 12:00:29 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: 118444 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp6508182qgn; Thu, 9 Nov 2017 04:09:43 -0800 (PST) X-Google-Smtp-Source: ABhQp+T7vg0KRN+3WC//r9NZusmOiWp33qEd646ARR7XbL/hC/Hb6vKyzORs3Fah+2o168cmEsaS X-Received: by 10.55.55.146 with SMTP id e140mr354431qka.106.1510229382980; Thu, 09 Nov 2017 04:09:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510229382; cv=none; d=google.com; s=arc-20160816; b=u6NGvyvGt5RIxA+gR+MfuV4uePwTCdwOW1rm+8GeH4qg9/faCReR0++CqiUs8QC1qO STHcvfEfdYeXgktULUs8U5broo5K5vgEx6Hg9WHf0wujeP75eUwxmmwuVEFUcf4mX5iq NDPKgLsfGQMH4HsDf+9lT4nwgx0gzEhJ0fKqs3lHUetEWzP3hOQIG5nlzpUPS1IN2PVO aFxUfk54p2xwbeQ/LfTqVLFMaRXRHeireJp1xQDipREmqB1gHr/pYEQ/8wkNcC2UX21t HearJdG9idLmdrUXO/Y4TVD18WBM9q4fAvsafM5aUrS3lKT4dSEfYQvClOQByZ632W2K g1TQ== 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=inP2eqCSU0ozLW6quEX9/lk4NjJ1sQhbiHoPPynllkU=; b=QtXikDaZpsiKZhJBrbrInRAcmJk2MJOe2jYS43bqpngcOlc3MZ2y/E6ugtA89+1Yrr ZnkguCi1OR1fU4Z9TdcUFVnNhjz+eLDmLnWNLEvUno+2gBoEEPXIr1f0KC2753+I9ZS5 w2c229p9rWY9T7jQ4LehkPG0l/U9AFUDNy/5DtuoQnaqcx8vAwX8OG0+njJnYNcBpp9K TkLizytMAGhTWIAK7iMtKzelDLNKBOFIIHGKK+irc8hn0awNVsE35S9iKv6oBL2OTjoB q/YdQ4PoeNDsAHhLSFJeiadVhc1lf31aGxwQkSyPa3tM3tMaPXzVikqSNnlj/XoaHh4i XYMQ== 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 n72si6108192qki.55.2017.11.09.04.09.42; Thu, 09 Nov 2017 04:09:42 -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 9E12D60CDF; Thu, 9 Nov 2017 12:09: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=-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 528E861013; Thu, 9 Nov 2017 12:03:11 +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 7666F60CCA; Thu, 9 Nov 2017 12:02:32 +0000 (UTC) Received: from forward104p.mail.yandex.net (forward104p.mail.yandex.net [77.88.28.107]) by lists.linaro.org (Postfix) with ESMTPS id D915A609FD for ; Thu, 9 Nov 2017 12:00:33 +0000 (UTC) Received: from mxback9o.mail.yandex.net (mxback9o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::23]) by forward104p.mail.yandex.net (Yandex) with ESMTP id 59E8D184E87 for ; Thu, 9 Nov 2017 15:00:32 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback9o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id Ri6EVqlgLb-0WXm46kV; Thu, 09 Nov 2017 15:00:32 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id InclDaSPWn-0VnqGPbF; Thu, 09 Nov 2017 15:00:31 +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: Thu, 9 Nov 2017 15:00:29 +0300 Message-Id: <1510228830-21766-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510228830-21766-1-git-send-email-odpbot@yandex.ru> References: <1510228830-21766-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 242 Subject: [lng-odp] [PATCH API-NEXT v4 2/3] linux-gen: packet: dummy ones complement implementation 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 Added dummy implementation of ones complement calls. Linux generic implementation does not calculate the sum for all incoming packets as it would be wasteful in SW. It's better to wait until application asks it with odp_chksum_ones_comp16(). Later on, the sum could be stored into the packet header, if we found a way to get it from the HW. Signed-off-by: Petri Savolainen --- /** Email created from pull request 242 (psavol:next-checksum-metadata) ** https://github.com/Linaro/odp/pull/242 ** Patch: https://github.com/Linaro/odp/pull/242.patch ** Base sha: d22c949cc466bf28de559855a1cb525740578137 ** Merge commit sha: 02aa905e6f9d4be66e19ccdb577e40a293be2902 **/ platform/linux-generic/odp_packet.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 3b2fac212..84790ba23 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -1284,6 +1284,14 @@ int odp_packet_l4_offset_set(odp_packet_t pkt, uint32_t offset) return 0; } +uint16_t odp_packet_ones_comp(odp_packet_t pkt, odp_packet_data_range_t *range) +{ + (void)pkt; + range->length = 0; + range->offset = 0; + return 0; +} + void odp_packet_flow_hash_set(odp_packet_t pkt, uint32_t flow_hash) { odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); From patchwork Thu Nov 9 12:00:30 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: 118443 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp6507626qgn; Thu, 9 Nov 2017 04:09:11 -0800 (PST) X-Google-Smtp-Source: AGs4zMbEn8QWFnNXJyrKpj0Lj7yNgS97h5qAygQheKw/rSYnsK8jjoH5hXz2vu0bBHTX24wxmGoL X-Received: by 10.200.52.118 with SMTP id v51mr353682qtb.266.1510229351411; Thu, 09 Nov 2017 04:09:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510229351; cv=none; d=google.com; s=arc-20160816; b=Cm41mni4QFtrXb7bRNehwht2ND4X+MbIaJ/rqn2v0eF9b1zacg1OhYc24fWu08id1k sW3wtmTZUm26MvEJIkwVVAaiiSTvuNuNG2uEIMvXZ1W9FZEY4vSq8l7S9B7sdfCOaNCW PynRQEsGaozSlwb6IiBk8bFbdWLLTQQvcyjtuRyI0R7q4NxE7n9gnzgWv5vdMGN8u2ux K30KA5snmlQKKWHRafWO0KNS/SJyR2Gs9ZD8/dk0e5mdbVKGIl5Khgz4NPOgvet0zZV+ Y9XR7OVmweyoeg06g+j/oAHwtqHWckbG/cJDEQ2XcfPBc1qOsNnP5ROtH8FsQhgJWPzG 1Pxw== 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=EtCubTEUBIY994DERzl0a+hZ+gS3IshTRsNMNMrD6e4=; b=EATdxwvpxlILJcRlGwPrm6QzC6U0CiqWDSesk8ES5S8qkNo48nRxSK4yvHXX3oXMFi haI/rP/RKHUEEu/af/3JQMCCn3RRYZBT74pC1coAmabHfZdNGCCqiIl9ik7rTx/gKqRD S0f8mCLhf+4yoIiV5ZyjSdcB8ai/wEXlGeNNyNmDAWzSHyDV5MNyQhgdHkuDlvElyWO/ urKvl7h2FjzkMBXWOd5Xmr//47avXRSm6ahKBHPc3sQHM1XHalQ76N3lu9wLJff3YEgP Au/Nm1Z9R9m8RMDg34b2mYKde6hXrx7eTH/IPsuCg6LZ4Plr8J3fzO4Q28PW0ClXxLu3 USgQ== 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 41si3161614qtb.359.2017.11.09.04.09.11; Thu, 09 Nov 2017 04:09:11 -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 1F03C609FD; Thu, 9 Nov 2017 12:09:11 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,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 0217061019; Thu, 9 Nov 2017 12:03:03 +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 435D860C1C; Thu, 9 Nov 2017 12:02:30 +0000 (UTC) Received: from forward103j.mail.yandex.net (forward103j.mail.yandex.net [5.45.198.246]) by lists.linaro.org (Postfix) with ESMTPS id 406C861007 for ; Thu, 9 Nov 2017 12:00:34 +0000 (UTC) Received: from mxback5j.mail.yandex.net (mxback5j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10e]) by forward103j.mail.yandex.net (Yandex) with ESMTP id D657634C234F for ; Thu, 9 Nov 2017 15:00:32 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback5j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 8NVVj3UTvl-0Wm8IEQ5; Thu, 09 Nov 2017 15:00:32 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id InclDaSPWn-0WneXvQD; Thu, 09 Nov 2017 15:00:32 +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: Thu, 9 Nov 2017 15:00:30 +0300 Message-Id: <1510228830-21766-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510228830-21766-1-git-send-email-odpbot@yandex.ru> References: <1510228830-21766-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 242 Subject: [lng-odp] [PATCH API-NEXT v4 3/3] validation: packet: add call to ones complement 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 Call ones complement function. Actual validation of correctness of the sum is to be done, when an implementation exist which sets the sum on packet input. Signed-off-by: Petri Savolainen --- /** Email created from pull request 242 (psavol:next-checksum-metadata) ** https://github.com/Linaro/odp/pull/242 ** Patch: https://github.com/Linaro/odp/pull/242.patch ** Base sha: d22c949cc466bf28de559855a1cb525740578137 ** Merge commit sha: 02aa905e6f9d4be66e19ccdb577e40a293be2902 **/ test/validation/api/packet/packet.c | 6 ++++++ test/validation/api/pktio/pktio.c | 25 +++++++++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c index 37550a2f5..dc99395c5 100644 --- a/test/validation/api/packet/packet.c +++ b/test/validation/api/packet/packet.c @@ -503,6 +503,7 @@ void packet_test_basic_metadata(void) { odp_packet_t pkt = test_packet; odp_time_t ts; + odp_packet_data_range_t range; CU_ASSERT_PTR_NOT_NULL(odp_packet_head(pkt)); CU_ASSERT_PTR_NOT_NULL(odp_packet_data(pkt)); @@ -512,6 +513,11 @@ void packet_test_basic_metadata(void) CU_ASSERT(odp_packet_input(pkt) == ODP_PKTIO_INVALID); CU_ASSERT(odp_packet_input_index(pkt) < 0); + /* Packet was not received from a packet IO, shouldn't have ones + * complement calculated. */ + odp_packet_ones_comp(pkt, &range); + CU_ASSERT(range.length == 0); + odp_packet_flow_hash_set(pkt, UINT32_MAX); CU_ASSERT(odp_packet_has_flow_hash(pkt)); CU_ASSERT(odp_packet_flow_hash(pkt) == UINT32_MAX); diff --git a/test/validation/api/pktio/pktio.c b/test/validation/api/pktio/pktio.c index 720707358..004379cd8 100644 --- a/test/validation/api/pktio/pktio.c +++ b/test/validation/api/pktio/pktio.c @@ -48,6 +48,9 @@ static int num_ifaces; interface that just become up.*/ static bool wait_for_network; +/* Dummy global variable to avoid compiler optimizing out API calls */ +static volatile uint64_t test_pktio_dummy_u64; + /** local container for pktio attributes */ typedef struct { const char *name; @@ -661,10 +664,24 @@ static void pktio_txrx_multi(pktio_info_t *pktio_a, pktio_info_t *pktio_b, CU_ASSERT(num_rx == num_pkts); for (i = 0; i < num_rx; ++i) { - CU_ASSERT_FATAL(rx_pkt[i] != ODP_PACKET_INVALID); - CU_ASSERT(odp_packet_input(rx_pkt[i]) == pktio_b->id); - CU_ASSERT(odp_packet_has_error(rx_pkt[i]) == 0); - odp_packet_free(rx_pkt[i]); + odp_packet_data_range_t range; + uint16_t sum; + odp_packet_t pkt = rx_pkt[i]; + + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + CU_ASSERT(odp_packet_input(pkt) == pktio_b->id); + CU_ASSERT(odp_packet_has_error(pkt) == 0); + + /* Dummy read to ones complement in case pktio has set it */ + sum = odp_packet_ones_comp(pkt, &range); + if (range.length > 0) + test_pktio_dummy_u64 += sum; + + /* Dummy read to flow hash in case pktio has set it */ + if (odp_packet_has_flow_hash(pkt)) + test_pktio_dummy_u64 += odp_packet_flow_hash(pkt); + + odp_packet_free(pkt); } }