From patchwork Wed Oct 28 19:29:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Haslam X-Patchwork-Id: 55716 Delivered-To: patch@linaro.org Received: by 10.112.61.134 with SMTP id p6csp138106lbr; Wed, 28 Oct 2015 12:33:50 -0700 (PDT) X-Received: by 10.55.76.20 with SMTP id z20mr16339761qka.89.1446060830093; Wed, 28 Oct 2015 12:33:50 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id s72si16881129qki.89.2015.10.28.12.33.49; Wed, 28 Oct 2015 12:33:50 -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; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: by lists.linaro.org (Postfix, from userid 109) id A9D266196A; Wed, 28 Oct 2015 19:33:49 +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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,T_DKIM_INVALID,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 EF0E461FE4; Wed, 28 Oct 2015 19:30:15 +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 951F161FE0; Wed, 28 Oct 2015 19:30:08 +0000 (UTC) Received: from mail-wm0-f42.google.com (mail-wm0-f42.google.com [74.125.82.42]) by lists.linaro.org (Postfix) with ESMTPS id DD76E6198A for ; Wed, 28 Oct 2015 19:29:27 +0000 (UTC) Received: by wmll128 with SMTP id l128so11331635wml.0 for ; Wed, 28 Oct 2015 12:29:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=vEK5iRsR/deNkUPY0+dsZz52o2ZWtw2MicqgHlrj26c=; b=CBHu0APhmQJxdWhfrQWu1m01ApkP3RYoqYLI2n0Tv+undQIKw8E0tzsI6Iac3VRlON Rbiiwip6GVDUWjHsAr/1ahp7ZNoDXZ7unoGNETsqNOwc8LlRYW6S4m6Jool33ibtkJAU iF6iFP2mouO6V6tkOLvrY7QOtVR9nSuOCqmyUEGXdNMsQ8cWYwgi9qbQn5MqKW+cr0QO 9qgTYMRTpYEPn0sh9fUlOk9QLFUuznhBvX2+iIxIPaqOWd9uPC3Ph58S3P+MM0Q/Fc0Y Xe9G12K1OB/7y9jVlsERQB8/0cYZqM33zywwXi6kArkBrSiKGaViykhfHAuV7dJcGBXl Opww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=vEK5iRsR/deNkUPY0+dsZz52o2ZWtw2MicqgHlrj26c=; b=PNfevCnULtVl/nc+rk0A/E4HbZNQ3IMQzy8N75Nv4DiZOMRMPUS5mnzkS+BxL133Pg WIFxMUVE1L6vjLR/Qy7fdBTUBpIC/Bk1WF035LvcsbGrNbFBz3ywZS2GT6uyJBfWTuNf hExu4Ve5loPAK17w+CgICmA/Ud+zsImOnLP+zqQrSRy63BqApa0MCZxI6HgfQv1S3Hnu QrP7CY9z8yCtwAlT0vqYxKCnjR1zyyc+4TsWLCl6UuYyLkGzuH7rC9yphmJYVeq8cr8p ty8IsGnTguHJJ89iq7H8it3muaLI0JKZ6aecE6L53ejw+KWJSvZpa5PnNVvGYgjVVi8n AWvA== X-Gm-Message-State: ALoCoQnlCciz7s5aM7v/Y5iQwMuY/ybRQreiXa1C7t36vIg6pWxCBSSoYNgt2dKOod/F15xzvQ4H X-Received: by 10.28.87.72 with SMTP id l69mr2271734wmb.70.1446060566862; Wed, 28 Oct 2015 12:29:26 -0700 (PDT) Received: from e106441.emea.arm.com ([2001:41d0:a:3cb4::abcd]) by smtp.gmail.com with ESMTPSA id h4sm31286154wjx.41.2015.10.28.12.29.26 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Oct 2015 12:29:26 -0700 (PDT) From: Stuart Haslam To: lng-odp@lists.linaro.org Date: Wed, 28 Oct 2015 19:29:08 +0000 Message-Id: <1446060551-21029-7-git-send-email-stuart.haslam@linaro.org> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1446060551-21029-1-git-send-email-stuart.haslam@linaro.org> References: <1446060551-21029-1-git-send-email-stuart.haslam@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH 6/9] validation: pktio: initialise packet headers in pktio_test_start_stop() 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: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" The pktio_test_start_stop() test wasn't initialising packet headers correctly (source and dest mac, UDP checksum), which can cause test failures depending on the interfaces being tested and how they're connected. Signed-off-by: Stuart Haslam --- test/validation/pktio/pktio.c | 57 ++++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c index 7e0f399..da1442f 100644 --- a/test/validation/pktio/pktio.c +++ b/test/validation/pktio/pktio.c @@ -89,17 +89,17 @@ static void set_pool_len(odp_pool_param_t *params) } static void pktio_pkt_set_macs(odp_packet_t pkt, - pktio_info_t *src, pktio_info_t *dst) + odp_pktio_t src, odp_pktio_t dst) { uint32_t len; odph_ethhdr_t *eth = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt, &len); int ret; - ret = odp_pktio_mac_addr(src->id, ð->src, sizeof(eth->src)); + ret = odp_pktio_mac_addr(src, ð->src, sizeof(eth->src)); if (ret <= 0) memcpy(ð->src, pktio_test_mac_src, sizeof(eth->src)); - ret = odp_pktio_mac_addr(dst->id, ð->dst, sizeof(eth->dst)); + ret = odp_pktio_mac_addr(dst, ð->dst, sizeof(eth->dst)); if (ret <= 0) memcpy(ð->dst, pktio_test_mac_dst, sizeof(eth->dst)); } @@ -235,6 +235,30 @@ static int pktio_fixup_checksums(odp_packet_t pkt) return 0; } +static odp_packet_t pktio_create_packet(odp_pool_t pool, uint32_t packet_len, + odp_pktio_t src, odp_pktio_t dst) +{ + odp_packet_t pkt; + + pkt = odp_packet_alloc(pool, packet_len); + if (pkt == ODP_PACKET_INVALID) + return ODP_PACKET_INVALID; + + if (pktio_init_packet(pkt) == TEST_SEQ_INVALID) { + odp_packet_free(pkt); + return ODP_PACKET_INVALID; + } + + pktio_pkt_set_macs(pkt, src, dst); + + if (pktio_fixup_checksums(pkt) != 0) { + odp_packet_free(pkt); + return ODP_PACKET_INVALID; + } + + return pkt; +} + static int default_pool_create(void) { odp_pool_param_t params; @@ -404,18 +428,10 @@ static void pktio_txrx_multi(pktio_info_t *pktio_a, pktio_info_t *pktio_b, /* generate test packets to send */ for (i = 0; i < num_pkts; ++i) { - tx_pkt[i] = odp_packet_alloc(default_pkt_pool, packet_len); - if (tx_pkt[i] == ODP_PACKET_INVALID) - break; - - tx_seq[i] = pktio_init_packet(tx_pkt[i]); - if (tx_seq[i] == TEST_SEQ_INVALID) - break; - - pktio_pkt_set_macs(tx_pkt[i], pktio_a, pktio_b); - if (pktio_fixup_checksums(tx_pkt[i]) != 0) - break; - + tx_pkt[i] = pktio_create_packet(default_pkt_pool, packet_len, + pktio_a->id, pktio_b->id); + CU_ASSERT_FATAL(tx_pkt[i] != ODP_PACKET_INVALID); + tx_seq[i] = pktio_pkt_seq(tx_pkt[i]); tx_ev[i] = odp_packet_to_event(tx_pkt[i]); } @@ -713,6 +729,7 @@ void pktio_test_start_stop(void) int i, pkts, ret, alloc = 0; odp_queue_t outq; uint64_t wait = odp_schedule_wait_time(ODP_TIME_MSEC); + odp_pktio_t pktio_dst; for (i = 0; i < num_ifaces; i++) { pktio[i] = create_pktio(iface_name[i], ODP_QUEUE_TYPE_SCHED, 0); @@ -720,11 +737,13 @@ void pktio_test_start_stop(void) create_inq(pktio[i], ODP_QUEUE_TYPE_SCHED); } + pktio_dst = num_ifaces > 1 ? pktio[1] : pktio[0]; + for (alloc = 0; alloc < 1000; alloc++) { - pkt = odp_packet_alloc(default_pkt_pool, packet_len); + pkt = pktio_create_packet(default_pkt_pool, packet_len, + pktio[0], pktio_dst); if (pkt == ODP_PACKET_INVALID) break; - pktio_init_packet(pkt); tx_ev[alloc] = odp_packet_to_event(pkt); } @@ -779,10 +798,10 @@ void pktio_test_start_stop(void) /* alloc */ for (alloc = 0; alloc < 1000; alloc++) { - pkt = odp_packet_alloc(default_pkt_pool, packet_len); + pkt = pktio_create_packet(default_pkt_pool, packet_len, + pktio[0], pktio_dst); if (pkt == ODP_PACKET_INVALID) break; - pktio_init_packet(pkt); tx_ev[alloc] = odp_packet_to_event(pkt); }