From patchwork Thu Oct 27 13:00:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 79654 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp607897qge; Thu, 27 Oct 2016 06:01:45 -0700 (PDT) X-Received: by 10.176.3.183 with SMTP id 52mr4921824uau.10.1477573305731; Thu, 27 Oct 2016 06:01:45 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id l124si2987504vka.179.2016.10.27.06.01.45; Thu, 27 Oct 2016 06:01:45 -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 dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 3EF1B610F4; Thu, 27 Oct 2016 13:01:45 +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, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 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 5176B609E7; Thu, 27 Oct 2016 13:01:30 +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 1F3B760A16; Thu, 27 Oct 2016 13:01:25 +0000 (UTC) Received: from mail-pf0-f175.google.com (mail-pf0-f175.google.com [209.85.192.175]) by lists.linaro.org (Postfix) with ESMTPS id F314E609DE for ; Thu, 27 Oct 2016 13:01:22 +0000 (UTC) Received: by mail-pf0-f175.google.com with SMTP id n85so17318552pfi.1 for ; Thu, 27 Oct 2016 06:01:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=sJJVQuWx0lzUmHaFoWrNV0LIUdHtxo76haL1Ce4nQ/4=; b=IPP1d5imeWa/Sc/Wsze2n0orahlc1lidKEGTBsRHW6jPB086chRLTtc8q36fJ1FsUn 1mHP/pxWKFr4VryslDUj7Qd9t0uqNEgvDGAzRFK4+0URWNWUhC3NonqOSmdVDva18gsE qEAwSWpORFyUmvfkRxbu077KkjOHrF9CbYMEnGdUwz+PwnrD9pH0UU0VvgO5s6WhuYo/ uoKRpfhoPkdbGWhlKsXdsNEDPgwqKjhDY5O1LIY/RnRgHDw0Wu9t/yk01BA0nnrBp+j2 UZ021VugrVt1Ufqo+x7HDlF7NiLqi5Uzi3Frd+JDVAkucqSyeK/o5ldHGGQhh2Y7Zk9/ gNVw== X-Gm-Message-State: ABUngvfKQf2Fkx4o4PHOfgbkddLztpp1m4TzifWxE1gvO6kI3EemSmPcJz1ma9CNlJUtLjxnWes= X-Received: by 10.99.38.66 with SMTP id m63mr11788001pgm.83.1477573281800; Thu, 27 Oct 2016 06:01:21 -0700 (PDT) Received: from bala-Vostro-2520.domain.name ([103.211.133.15]) by smtp.gmail.com with ESMTPSA id h185sm11827322pfe.35.2016.10.27.06.01.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 27 Oct 2016 06:01:20 -0700 (PDT) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Thu, 27 Oct 2016 18:30:55 +0530 Message-Id: <1477573255-28602-1-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: Classification patch Subject: [lng-odp] [PATCHv2 1/1] validation: classification: fix TCP/UDP checksum update 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" Fixes https://bugs.linaro.org/show_bug.cgi?id=2512 Signed-off-by: Balasubramanian Manoharan --- v2: Incorporates review comments .../api/classification/odp_classification_common.c | 14 +++++++++++++- .../api/classification/odp_classification_test_pmr.c | 3 +++ 2 files changed, 16 insertions(+), 1 deletion(-) -- 1.9.1 Reviewed-by: Nikhil Agarwal Signed-off-by: Balasubramanian Manoharan diff --git a/test/common_plat/validation/api/classification/odp_classification_common.c b/test/common_plat/validation/api/classification/odp_classification_common.c index 7a42ac7..2923a71 100644 --- a/test/common_plat/validation/api/classification/odp_classification_common.c +++ b/test/common_plat/validation/api/classification/odp_classification_common.c @@ -11,6 +11,7 @@ #include #include #include +#include "test_debug.h" typedef struct cls_test_packet { odp_u32be_t magic; @@ -291,6 +292,8 @@ odp_packet_t create_packet_len(odp_pool_t pool, bool vlan, parse_ipv4_string(CLS_DEFAULT_SADDR, &addr, &mask); ip->src_addr = odp_cpu_to_be_32(addr); ip->ver_ihl = ODPH_IPV4 << 4 | ODPH_IPV4HDR_IHL_MIN; + odp_packet_has_ipv4_set(pkt, 1); + if (flag_udp) ip->tot_len = odp_cpu_to_be_16(ODPH_UDPHDR_LEN + payload_len + ODPH_IPV4HDR_LEN); @@ -318,14 +321,23 @@ odp_packet_t create_packet_len(odp_pool_t pool, bool vlan, udp->dst_port = odp_cpu_to_be_16(CLS_DEFAULT_DPORT); udp->length = odp_cpu_to_be_16(payload_len + ODPH_UDPHDR_LEN); udp->chksum = 0; + odp_packet_has_udp_set(pkt, 1); + if (odph_udp_tcp_chksum(pkt, ODPH_CHKSUM_GENERATE, NULL) != 0) { + LOG_ERR("odph_udp_tcp_chksum failed\n"); + return ODP_PACKET_INVALID; + } } else { odp_packet_l4_offset_set(pkt, offset); tcp = (odph_tcphdr_t *)odp_packet_l4_ptr(pkt, NULL); tcp->src_port = odp_cpu_to_be_16(CLS_DEFAULT_SPORT); tcp->dst_port = odp_cpu_to_be_16(CLS_DEFAULT_DPORT); tcp->hl = ODPH_TCPHDR_LEN / 4; - /* TODO: checksum field has to be updated */ tcp->cksm = 0; + odp_packet_has_tcp_set(pkt, 1); + if (odph_udp_tcp_chksum(pkt, ODPH_CHKSUM_GENERATE, NULL) != 0) { + LOG_ERR("odph_udp_tcp_chksum failed\n"); + return ODP_PACKET_INVALID; + } } /* set pkt sequence number */ diff --git a/test/common_plat/validation/api/classification/odp_classification_test_pmr.c b/test/common_plat/validation/api/classification/odp_classification_test_pmr.c index c8bbf50..88fbf8f 100644 --- a/test/common_plat/validation/api/classification/odp_classification_test_pmr.c +++ b/test/common_plat/validation/api/classification/odp_classification_test_pmr.c @@ -717,6 +717,7 @@ void classification_test_pmr_term_dmac(void) /* Other packets delivered to default queue */ pkt = create_packet(pkt_pool, false, &seq, false); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); eth = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt, NULL); memset(eth->dst.addr, 0, ODPH_ETHADDR_LEN); CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); @@ -1102,6 +1103,7 @@ static void classification_test_pmr_term_daddr(void) /* packet with dst ip address matching PMR rule to be received in the CoS queue*/ pkt = create_packet(pkt_pool, false, &seq, false); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); eth = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt, NULL); odp_pktio_mac_addr(pktio, eth->src.addr, ODPH_ETHADDR_LEN); odp_pktio_mac_addr(pktio, eth->dst.addr, ODPH_ETHADDR_LEN); @@ -1122,6 +1124,7 @@ static void classification_test_pmr_term_daddr(void) /* Other packets delivered to default queue */ pkt = create_packet(pkt_pool, false, &seq, false); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); seqno = cls_pkt_get_seq(pkt); CU_ASSERT(seqno != TEST_SEQ_INVALID); eth = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt, NULL);