From patchwork Fri Dec 18 12:07:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Haslam X-Patchwork-Id: 58652 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp981906lbb; Fri, 18 Dec 2015 04:09:21 -0800 (PST) X-Received: by 10.140.86.85 with SMTP id o79mr4328257qgd.3.1450440560976; Fri, 18 Dec 2015 04:09:20 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 23si15053165qgb.90.2015.12.18.04.09.20; Fri, 18 Dec 2015 04:09:20 -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 Received: by lists.linaro.org (Postfix, from userid 109) id 614A361615; Fri, 18 Dec 2015 12:09:20 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=BXh4ckKB; dkim-adsp=none (unprotected policy); dkim-atps=neutral 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 992996107B; Fri, 18 Dec 2015 12:09:08 +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 E2DB5615D5; Fri, 18 Dec 2015 12:09:02 +0000 (UTC) Received: from mail-wm0-f45.google.com (mail-wm0-f45.google.com [74.125.82.45]) by lists.linaro.org (Postfix) with ESMTPS id 030A461662 for ; Fri, 18 Dec 2015 12:08:08 +0000 (UTC) Received: by mail-wm0-f45.google.com with SMTP id p187so60806832wmp.1 for ; Fri, 18 Dec 2015 04:08:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=7lFhzfGPFf5whAgDR7twinF+0TETeCc8ahX8NHYc1oA=; b=BXh4ckKBYZTXk/LOIznODdQqdMCaFbY780zVNHwzQqHekZQsi5tOmnFqeSRNzCU9DT xDCA4rAmNVoOvau1FwI3gLYJyQVW13jAU6xJRr9DpunZrdJx8Tot0WNh59aufwWj25Yz jaWR9xP/UvJBeH80l/wRfoJ/jugsmx2IZY1OY= 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=7lFhzfGPFf5whAgDR7twinF+0TETeCc8ahX8NHYc1oA=; b=dps2tU2qgNqonf/JKdwMuMGkADkWaprZPaC9b79VpiyBlbf1+a3ZtVjMW6cl58JIQJ x+gaXWc9nLkrLbGeBNAZEJmxjW5sb2zUNLZ9sCwhPbkZhM1xT3SkWqsU4vc3qX+qNjgj iQCAYgyvbQatSqvqjySrxi4tasgu7ym3JRY/6X27tZ9BjCcLMyz5MxV1iZpfkcDpl9qh U3YD+5p9xzyaNPD/hRwOldmLnbTNn6pS48VnlOF2UglF7gS+Omo5fZ1i5i4JN4gtNdAR DLEXprngUSZy8PsnsbkjSgpi8iwARFvmTBSKs4uoggeSh+5wYD/tXBFa2rGkELd937Lb nIRQ== X-Gm-Message-State: ALoCoQmwJXU8c+xhWJfw96f6S9kgAzNB6FAEZz018jYwMmTY3PK3GeVzYjRpqHchpDpnJo70mf0goZwgFb8qwe1m3YNTjWuQSw== X-Received: by 10.194.24.97 with SMTP id t1mr3667893wjf.127.1450440487183; Fri, 18 Dec 2015 04:08:07 -0800 (PST) Received: from e106441.emea.arm.com ([2001:41d0:a:3cb4::abcd]) by smtp.gmail.com with ESMTPSA id 143sm6421437wmv.18.2015.12.18.04.08.06 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 18 Dec 2015 04:08:06 -0800 (PST) From: Stuart Haslam To: lng-odp@lists.linaro.org Date: Fri, 18 Dec 2015 12:07:57 +0000 Message-Id: <1450440477-7017-1-git-send-email-stuart.haslam@linaro.org> X-Mailer: git-send-email 2.1.1 X-Topics: patch Subject: [lng-odp] [PATCHv3] 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 v3 - test odp_queue_[enq|deq]_multi() and odp_schedule_multi() APIs with batch length of 1. Changes in v2 - rebased and picked up new time API test/validation/pktio/pktio.c | 185 ++++++++++++++++++++++-------------------- 1 file changed, 97 insertions(+), 88 deletions(-) diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c index 28bfd30..05ddd68 100644 --- a/test/validation/pktio/pktio.c +++ b/test/validation/pktio/pktio.c @@ -58,8 +58,13 @@ typedef struct ODP_PACKED { typedef enum { PKT_POOL_UNSEGMENTED, PKT_POOL_SEGMENTED, -} pkt_segmented_e -; +} pkt_segmented_e; + +typedef enum { + TXRX_MODE_SINGLE, + TXRX_MODE_MULTI +} txrx_mode_e; + /** size of transmitted packets */ static uint32_t packet_len = PKT_LEN_NORMAL; @@ -142,7 +147,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) @@ -351,78 +356,86 @@ 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, txrx_mode_e mode) { - 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 (mode == TXRX_MODE_MULTI) { + 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); - return ODP_EVENT_INVALID; + 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 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, txrx_mode_e mode, + 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); + int n = get_packets(pktio_rx, pkt_tmp, num - num_rx, mode); - if (ev != ODP_EVENT_INVALID) { - if (odp_event_type(ev) == ODP_EVENT_PACKET) - pkt = odp_packet_from_event(ev); - else - odp_event_free(ev); - } - } - - 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]; + 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, - int num_pkts) + int num_pkts, txrx_mode_e mode) { 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) { @@ -451,12 +464,14 @@ static void pktio_txrx_multi(pktio_info_t *pktio_a, pktio_info_t *pktio_b, } /* send packet(s) out */ - if (num_pkts == 1) { - ret = odp_queue_enq(pktio_a->outq, tx_ev[0]); - if (ret != 0) { - CU_FAIL("failed to enqueue test packet"); - odp_packet_free(tx_pkt[0]); - return; + if (mode == TXRX_MODE_SINGLE) { + for (i = 0; i < num_pkts; ++i) { + ret = odp_queue_enq(pktio_a->outq, tx_ev[i]); + if (ret != 0) { + CU_FAIL("failed to enqueue test packet"); + odp_packet_free(tx_pkt[i]); + return; + } } } else { ret = odp_queue_enq_multi(pktio_a->outq, tx_ev, num_pkts); @@ -470,21 +485,20 @@ 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, mode, 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) +static void test_txrx(odp_pktio_input_mode_t in_mode, int num_pkts, + txrx_mode_e mode) { int ret, i, if_b; pktio_info_t pktios[MAX_NUM_IFACES]; @@ -518,7 +532,7 @@ static void test_txrx(odp_pktio_input_mode_t in_mode, int num_pkts) /* if we have two interfaces then send through one and receive on * another but if there's only one assume it's a loopback */ if_b = (num_ifaces == 1) ? 0 : 1; - pktio_txrx_multi(&pktios[0], &pktios[if_b], num_pkts); + pktio_txrx_multi(&pktios[0], &pktios[if_b], num_pkts, mode); for (i = 0; i < num_ifaces; ++i) { ret = odp_pktio_stop(pktios[i].id); @@ -532,32 +546,36 @@ static void test_txrx(odp_pktio_input_mode_t in_mode, int num_pkts) void pktio_test_poll_queue(void) { - test_txrx(ODP_PKTIN_MODE_POLL, 1); + test_txrx(ODP_PKTIN_MODE_POLL, 1, TXRX_MODE_SINGLE); + test_txrx(ODP_PKTIN_MODE_POLL, TX_BATCH_LEN, TXRX_MODE_SINGLE); } void pktio_test_poll_multi(void) { - test_txrx(ODP_PKTIN_MODE_POLL, TX_BATCH_LEN); + test_txrx(ODP_PKTIN_MODE_POLL, TX_BATCH_LEN, TXRX_MODE_MULTI); + test_txrx(ODP_PKTIN_MODE_POLL, 1, TXRX_MODE_MULTI); } void pktio_test_sched_queue(void) { - test_txrx(ODP_PKTIN_MODE_SCHED, 1); + test_txrx(ODP_PKTIN_MODE_SCHED, 1, TXRX_MODE_SINGLE); + test_txrx(ODP_PKTIN_MODE_SCHED, TX_BATCH_LEN, TXRX_MODE_SINGLE); } void pktio_test_sched_multi(void) { - test_txrx(ODP_PKTIN_MODE_SCHED, TX_BATCH_LEN); + test_txrx(ODP_PKTIN_MODE_SCHED, TX_BATCH_LEN, TXRX_MODE_MULTI); + test_txrx(ODP_PKTIN_MODE_SCHED, 1, TXRX_MODE_MULTI); } void pktio_test_recv(void) { - test_txrx(ODP_PKTIN_MODE_RECV, 1); + test_txrx(ODP_PKTIN_MODE_RECV, 1, TXRX_MODE_SINGLE); } void pktio_test_recv_multi(void) { - test_txrx(ODP_PKTIN_MODE_RECV, TX_BATCH_LEN); + test_txrx(ODP_PKTIN_MODE_RECV, TX_BATCH_LEN, TXRX_MODE_MULTI); } void pktio_test_jumbo(void) @@ -975,12 +993,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, + TXRX_MODE_MULTI, ODP_TIME_SEC_IN_NS); if (i == ret) { /* now try to send starting with the too-long packet @@ -1011,14 +1025,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, + TXRX_MODE_MULTI, ODP_TIME_SEC_IN_NS); + CU_ASSERT(i == ret); } else { CU_FAIL("failed to generate test packets\n"); }