From patchwork Fri Dec 11 17:10:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Haslam X-Patchwork-Id: 58299 Delivered-To: patch@linaro.org Received: by 10.112.73.68 with SMTP id j4csp9013lbv; Fri, 11 Dec 2015 09:11:06 -0800 (PST) X-Received: by 10.140.195.18 with SMTP id q18mr16521973qha.44.1449853866207; Fri, 11 Dec 2015 09:11:06 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id x67si402110qhx.0.2015.12.11.09.11.05; Fri, 11 Dec 2015 09:11:06 -0800 (PST) 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 9B4FE61FDD; Fri, 11 Dec 2015 17:11:05 +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.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW, 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 CA20161FBA; Fri, 11 Dec 2015 17:10:59 +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 1627861FC4; Fri, 11 Dec 2015 17:10:58 +0000 (UTC) Received: from mail-wm0-f47.google.com (mail-wm0-f47.google.com [74.125.82.47]) by lists.linaro.org (Postfix) with ESMTPS id EA2FD61FB5 for ; Fri, 11 Dec 2015 17:10:55 +0000 (UTC) Received: by wmec201 with SMTP id c201so79169339wme.1 for ; Fri, 11 Dec 2015 09:10:55 -0800 (PST) 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; bh=NP1Dqz81s1Fo4Sclnp+sa9Gfo75mPghWyCqvH1XLwI0=; b=sx4DAGD0bRPphiY0qS2/a9yy5AI2bGR/Y+UXFe2/jRpQAgnDOvbmA9pNSnIHNgqNU2 u1vkI63xUnbxyr1U4H3tkQSAqTp1eH4QSNdUU1H2Gw0BFP9Ou1AGskcQfPz1sb+cTTXn /IlaAS965AKb4fBrWw1Szi//IIOgsJCqq/xHaVrd7zSGB+0vigTdL14B23uiagJ2iAkw r85g41msZlg+KmKU0ckwkO671ODd4ZijYpISJn1envHJSyLdtBsjMlFszPXU6lHskKsN ZzPPGM7fIc7RNOYWW/YdcpwOqugrvo4fz1HuWuERjGbm2RD1v4I+URrwOo051HZXiJzl /WNw== 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; bh=NP1Dqz81s1Fo4Sclnp+sa9Gfo75mPghWyCqvH1XLwI0=; b=KFyZt6E3OULEyUPJTSTzZq91AbIMS5oB1THKVf6oWIfSPmYzpWiM8i6o5mB/ajQuK3 RsmgyIXMI2sdBLaZriG5adYyrkQYPq4gzl7PMkX77mx7CodYg4qHIDg/L/KZmgXRUnnz v72EhD3VJKLvJhz65f3q63Bt1gMNhg+qoBPKAqdTcsyO8e0XFJ5YmhtF8S2cX89SYz4N UxLCeMtsqC72GAPNgGXLTo2SVjyG1taGs2WedZeZ2UAG3wH33dfbkwtIgBTLMGSxddsj nhxolVzm6pgz6JSnuAKgFlHozMdQMcEZhWKGMzFGrUoB1qMPzElPsEcrvQD0HWX/P0sr F1eA== X-Gm-Message-State: ALoCoQknl8ex9fmLfqnLVmKxzggc2okI9WeoiXrIZjj5Tgpu2qpPeJIQ8FOsxhgFUKQUFET7VRAlIYJl3Z2NKmw3bYH/OgL0Hw== X-Received: by 10.28.64.131 with SMTP id n125mr7400778wma.103.1449853854907; Fri, 11 Dec 2015 09:10:54 -0800 (PST) Received: from e106441.emea.arm.com ([2001:41d0:a:3cb4::abcd]) by smtp.gmail.com with ESMTPSA id ql10sm17826490wjc.23.2015.12.11.09.10.53 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 11 Dec 2015 09:10:54 -0800 (PST) From: Stuart Haslam To: lng-odp@lists.linaro.org Date: Fri, 11 Dec 2015 17:10:51 +0000 Message-Id: <1449853851-10152-1-git-send-email-stuart.haslam@linaro.org> X-Mailer: git-send-email 2.1.1 X-Topics: patch Subject: [lng-odp] [PATCHv2] validation: pktio: test batch receive 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" Modify the tests that currently transmit packets in batches to also receive packets in batches. This adds coverage of odp_queue_deq_multi() and odp_schedule_multi() specifically against a packet input queue, as this doesn't get tested anywhere else in the validation suite. Signed-off-by: Stuart Haslam --- Changes in v2 - rebased and picked up new time API test/validation/pktio/pktio.c | 139 +++++++++++++++++++++--------------------- 1 file changed, 68 insertions(+), 71 deletions(-) diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c index 52e5414..1eca694 100644 --- a/test/validation/pktio/pktio.c +++ b/test/validation/pktio/pktio.c @@ -137,7 +137,7 @@ static uint32_t pktio_pkt_seq(odp_packet_t pkt) pkt_tail_t tail; if (pkt == ODP_PACKET_INVALID) - return -1; + return TEST_SEQ_INVALID; off = odp_packet_l4_offset(pkt); if (off == ODP_PACKET_OFFSET_INVALID) @@ -332,68 +332,76 @@ static int destroy_inq(odp_pktio_t pktio) return odp_queue_destroy(inq); } -static odp_event_t queue_deq_wait_time(odp_queue_t queue, uint64_t ns) +static int get_packets(pktio_info_t *pktio_rx, odp_packet_t pkt_tbl[], int num) { - odp_time_t start, now, diff; - odp_event_t ev; + odp_event_t evt_tbl[num]; + int num_evts = 0; + int num_pkts = 0; + int i; - start = odp_time_local(); + if (pktio_rx->in_mode == ODP_PKTIN_MODE_RECV) + return odp_pktio_recv(pktio_rx->id, pkt_tbl, num); - do { - ev = odp_queue_deq(queue); - if (ev != ODP_EVENT_INVALID) - return ev; - now = odp_time_local(); - diff = odp_time_diff(now, start); - } while (odp_time_to_ns(diff) < ns); + if (num > 1) { + if (pktio_rx->in_mode == ODP_PKTIN_MODE_POLL) + num_evts = odp_queue_deq_multi(pktio_rx->inq, evt_tbl, + num); + else + num_evts = odp_schedule_multi(NULL, ODP_SCHED_NO_WAIT, + evt_tbl, num); + } else { + odp_event_t evt_tmp; + + if (pktio_rx->in_mode == ODP_PKTIN_MODE_POLL) + evt_tmp = odp_queue_deq(pktio_rx->inq); + else + evt_tmp = odp_schedule(NULL, ODP_SCHED_NO_WAIT); + + if (evt_tmp != ODP_EVENT_INVALID) + evt_tbl[num_evts++] = evt_tmp; + } + + /* convert events to packets, discarding any non-packet events */ + for (i = 0; i < num_evts; ++i) { + if (odp_event_type(evt_tbl[i]) == ODP_EVENT_PACKET) + pkt_tbl[num_pkts++] = odp_packet_from_event(evt_tbl[i]); + else + odp_event_free(evt_tbl[i]); + } - return ODP_EVENT_INVALID; + return num_pkts; } -static odp_packet_t wait_for_packet(pktio_info_t *pktio_rx, - uint32_t seq, uint64_t ns) +static int wait_for_packets(pktio_info_t *pktio_rx, odp_packet_t pkt_tbl[], + uint32_t seq_tbl[], int num, uint64_t ns) { odp_time_t start, now, diff; - odp_event_t ev; - odp_packet_t pkt; - uint64_t wait; + int num_rx = 0; + int i; + odp_packet_t pkt_tmp[num]; start = odp_time_local(); - wait = odp_schedule_wait_time(ns); do { - pkt = ODP_PACKET_INVALID; - - if (pktio_rx->in_mode == ODP_PKTIN_MODE_RECV) { - odp_pktio_recv(pktio_rx->id, &pkt, 1); - } else { - if (pktio_rx->in_mode == ODP_PKTIN_MODE_POLL) - ev = queue_deq_wait_time(pktio_rx->inq, ns); - else - ev = odp_schedule(NULL, wait); - - if (ev != ODP_EVENT_INVALID) { - if (odp_event_type(ev) == ODP_EVENT_PACKET) - pkt = odp_packet_from_event(ev); - else - odp_event_free(ev); - } - } + int n = get_packets(pktio_rx, pkt_tmp, num); - if (pkt != ODP_PACKET_INVALID) { - if (pktio_pkt_seq(pkt) == seq) - return pkt; + if (n < 0) + break; - odp_packet_free(pkt); + for (i = 0; i < n; ++i) { + if (pktio_pkt_seq(pkt_tmp[i]) == seq_tbl[num_rx]) { + pkt_tbl[num_rx++] = pkt_tmp[i]; + num--; + } else { + odp_packet_free(pkt_tmp[i]); + } } now = odp_time_local(); diff = odp_time_diff(now, start); - } while (odp_time_to_ns(diff) < ns); + } while (num_rx < num && odp_time_to_ns(diff) < ns); - CU_FAIL("failed to receive transmitted packet"); - - return ODP_PACKET_INVALID; + return num_rx; } static void pktio_txrx_multi(pktio_info_t *pktio_a, pktio_info_t *pktio_b, @@ -401,9 +409,9 @@ static void pktio_txrx_multi(pktio_info_t *pktio_a, pktio_info_t *pktio_b, { odp_packet_t tx_pkt[num_pkts]; odp_event_t tx_ev[num_pkts]; - odp_packet_t rx_pkt; + odp_packet_t rx_pkt[num_pkts]; uint32_t tx_seq[num_pkts]; - int i, ret; + int i, ret, num_rx; /* generate test packets to send */ for (i = 0; i < num_pkts; ++i) { @@ -447,18 +455,16 @@ static void pktio_txrx_multi(pktio_info_t *pktio_a, pktio_info_t *pktio_b, } /* and wait for them to arrive back */ - for (i = 0; i < num_pkts; ++i) { - rx_pkt = wait_for_packet(pktio_b, tx_seq[i], - ODP_TIME_SEC_IN_NS); - - if (rx_pkt == ODP_PACKET_INVALID) - break; - CU_ASSERT(odp_packet_input(rx_pkt) == pktio_b->id); - CU_ASSERT(odp_packet_has_error(rx_pkt) == 0); - odp_packet_free(rx_pkt); + num_rx = wait_for_packets(pktio_b, rx_pkt, tx_seq, + num_pkts, ODP_TIME_SEC_IN_NS); + 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]); } - - CU_ASSERT(i == num_pkts); } static void test_txrx(odp_pktio_input_mode_t in_mode, int num_pkts) @@ -929,12 +935,8 @@ static void pktio_test_send_failure(void) info_rx.inq = ODP_QUEUE_INVALID; info_rx.in_mode = ODP_PKTIN_MODE_RECV; - for (i = 0; i < ret; ++i) { - pkt_tbl[i] = wait_for_packet(&info_rx, pkt_seq[i], - ODP_TIME_SEC_IN_NS); - if (pkt_tbl[i] == ODP_PACKET_INVALID) - break; - } + i = wait_for_packets(&info_rx, pkt_tbl, pkt_seq, + ret, ODP_TIME_SEC_IN_NS); if (i == ret) { /* now try to send starting with the too-long packet @@ -960,14 +962,9 @@ static void pktio_test_send_failure(void) ret = odp_pktio_send(pktio_tx, &pkt_tbl[i], TX_BATCH_LEN - i); CU_ASSERT_FATAL(ret == (TX_BATCH_LEN - i)); - for (; i < TX_BATCH_LEN; ++i) { - pkt_tbl[i] = wait_for_packet(&info_rx, - pkt_seq[i], - ODP_TIME_SEC_IN_NS); - if (pkt_tbl[i] == ODP_PACKET_INVALID) - break; - } - CU_ASSERT(i == TX_BATCH_LEN); + i = wait_for_packets(&info_rx, &pkt_tbl[i], &pkt_seq[i], + ret, ODP_TIME_SEC_IN_NS); + CU_ASSERT(i == ret); } else { CU_FAIL("failed to generate test packets\n"); }