From patchwork Fri Sep 4 09:55:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Haslam X-Patchwork-Id: 53078 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by patches.linaro.org (Postfix) with ESMTPS id 01C152159E for ; Fri, 4 Sep 2015 10:00:14 +0000 (UTC) Received: by wicgb1 with SMTP id gb1sf3313744wic.3 for ; Fri, 04 Sep 2015 03:00:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:errors-to :sender:x-original-sender:x-original-authentication-results :mailing-list; bh=4eSYfgwBE7XMI40fAHm/7xJ6atZwrwPIFkqj+l+MymI=; b=dPnVW0XQAMsJjiwijerd94/+jpwl96iQA53N21+N6ZmaK/QIWdPVHYGw9vbwhqQk6C vj7mMBAzy9e9eRh/IHWKa1VFBNYS3DebxyOhOWUHKhUQRGafa+CbdGChX7uJef+ejPeD 0PH46Jjr0PrdJ6VKUcK9s3H21oqUaz1SC+Q1A5Kmg6ni4nhHG72XyzJvvFFjnjjtEeol kPbxcZBq+TTp7xYvJdt46FmIu9gjOnXxiyZfyMJpCJgaeZvLhK1fTprQNSuR9VauaI64 /Bgh/P+j7Y51j16rb9wyZI41Xg8uEVDYGChAsQTgUpNMzd6xF/I9JEB9RQJ9ncOd6VMu RlvQ== X-Gm-Message-State: ALoCoQn1gX8MbZ3VUbpTVTtoRaKdB2/zUffcS6k8hFEa6sagUXXlN9CyeS2k06mC149Zrf0BdnAL X-Received: by 10.180.9.104 with SMTP id y8mr867763wia.7.1441360813345; Fri, 04 Sep 2015 03:00:13 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.28.226 with SMTP id e2ls291526lah.14.gmail; Fri, 04 Sep 2015 03:00:13 -0700 (PDT) X-Received: by 10.112.140.104 with SMTP id rf8mr2659808lbb.30.1441360813172; Fri, 04 Sep 2015 03:00:13 -0700 (PDT) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id o6si1861498laj.10.2015.09.04.03.00.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Sep 2015 03:00:12 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by lbcao8 with SMTP id ao8so8337973lbc.3 for ; Fri, 04 Sep 2015 03:00:12 -0700 (PDT) X-Received: by 10.152.22.133 with SMTP id d5mr2866292laf.112.1441360812453; Fri, 04 Sep 2015 03:00:12 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.164.42 with SMTP id yn10csp1839752lbb; Fri, 4 Sep 2015 03:00:11 -0700 (PDT) X-Received: by 10.140.109.164 with SMTP id l33mr3628225qgf.101.1441360811418; Fri, 04 Sep 2015 03:00:11 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id p28si2202147qkh.92.2015.09.04.03.00.10; Fri, 04 Sep 2015 03:00:11 -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; Received: by lists.linaro.org (Postfix, from userid 109) id 6CDBA619B9; Fri, 4 Sep 2015 10:00:10 +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_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 3AAA461CE8; Fri, 4 Sep 2015 09:57:09 +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 86DA76195C; Fri, 4 Sep 2015 09:56:56 +0000 (UTC) Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com [209.85.212.175]) by lists.linaro.org (Postfix) with ESMTPS id 80D5961A3B for ; Fri, 4 Sep 2015 09:56:25 +0000 (UTC) Received: by wiclk2 with SMTP id lk2so12204322wic.1 for ; Fri, 04 Sep 2015 02:56:24 -0700 (PDT) X-Received: by 10.194.21.98 with SMTP id u2mr5747732wje.141.1441360584786; Fri, 04 Sep 2015 02:56:24 -0700 (PDT) Received: from e106441.emea.arm.com ([2001:41d0:a:3cb4::abcd]) by smtp.gmail.com with ESMTPSA id vl1sm3083000wjc.0.2015.09.04.02.56.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 04 Sep 2015 02:56:24 -0700 (PDT) From: Stuart Haslam To: lng-odp@lists.linaro.org Date: Fri, 4 Sep 2015 10:55:47 +0100 Message-Id: <1441360547-18999-7-git-send-email-stuart.haslam@linaro.org> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1441360547-18999-1-git-send-email-stuart.haslam@linaro.org> References: <1441360547-18999-1-git-send-email-stuart.haslam@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv2 7/7] validation: pktio: test for transmit error handling X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: 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" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: stuart.haslam@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Test that transmit errors are handled correctly by attempting to send a packet larger than the MTU of the interface. Signed-off-by: Stuart Haslam --- test/validation/pktio/pktio.c | 124 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 121 insertions(+), 3 deletions(-) diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c index 95c3c34..fa146c5 100644 --- a/test/validation/pktio/pktio.c +++ b/test/validation/pktio/pktio.c @@ -21,6 +21,7 @@ #define MAX_NUM_IFACES 2 #define TEST_SEQ_INVALID ((uint32_t)~0) #define TEST_SEQ_MAGIC 0x92749451 +#define TX_BATCH_LEN 4 /** interface names used for testing */ static const char *iface_name[MAX_NUM_IFACES]; @@ -507,7 +508,7 @@ void pktio_test_poll_queue(void) void pktio_test_poll_multi(void) { - test_txrx(ODP_PKTIN_MODE_POLL, 4); + test_txrx(ODP_PKTIN_MODE_POLL, TX_BATCH_LEN); } void pktio_test_sched_queue(void) @@ -517,7 +518,7 @@ void pktio_test_sched_queue(void) void pktio_test_sched_multi(void) { - test_txrx(ODP_PKTIN_MODE_SCHED, 4); + test_txrx(ODP_PKTIN_MODE_SCHED, TX_BATCH_LEN); } void pktio_test_recv(void) @@ -527,7 +528,7 @@ void pktio_test_recv(void) void pktio_test_recv_multi(void) { - test_txrx(ODP_PKTIN_MODE_RECV, 4); + test_txrx(ODP_PKTIN_MODE_RECV, TX_BATCH_LEN); } void pktio_test_jumbo(void) @@ -790,6 +791,121 @@ static void pktio_test_start_stop(void) } } +static void pktio_test_send_failure(void) +{ + odp_pktio_t pktio_tx, pktio_rx; + odp_packet_t pkt_tbl[TX_BATCH_LEN]; + uint32_t pkt_seq[TX_BATCH_LEN]; + int ret, mtu, i, alloc_pkts; + odp_pool_param_t pool_params; + odp_pool_t pkt_pool; + int long_pkt_idx = TX_BATCH_LEN / 2; + pktio_info_t info_rx; + + pktio_tx = create_pktio(0, ODP_PKTIN_MODE_RECV); + if (pktio_tx == ODP_PKTIO_INVALID) { + CU_FAIL("failed to open pktio"); + return; + } + + /* read the MTU from the transmit interface */ + mtu = odp_pktio_mtu(pktio_tx); + + /* if the interface MTU is larger that the biggest packet we can + * allocate then we can't use this method to test transmit failures */ + if (mtu > ODP_CONFIG_PACKET_BUF_LEN_MAX - 32) { + CU_ASSERT(odp_pktio_close(pktio_tx) == 0); + return; + } + + ret = odp_pktio_start(pktio_tx); + CU_ASSERT_FATAL(ret == 0); + + /* configure the pool so that we can generate test packets larger + * than the interface MTU */ + memset(&pool_params, 0, sizeof(pool_params)); + pool_params.pkt.len = mtu + 32; + pool_params.pkt.seg_len = pool_params.pkt.len; + pool_params.pkt.num = TX_BATCH_LEN + 1; + pool_params.type = ODP_POOL_PACKET; + pkt_pool = odp_pool_create("pkt_pool_oversize", &pool_params); + CU_ASSERT_FATAL(pkt_pool != ODP_POOL_INVALID); + + if (num_ifaces > 1) { + pktio_rx = create_pktio(1, ODP_PKTIN_MODE_RECV); + ret = odp_pktio_start(pktio_rx); + CU_ASSERT_FATAL(ret == 0); + } else { + pktio_rx = pktio_tx; + } + + /* generate a batch of packets with a single overly long packet + * in the middle */ + for (i = 0; i < TX_BATCH_LEN; ++i) { + uint32_t pkt_len; + + if (i == long_pkt_idx) + pkt_len = pool_params.pkt.len; + else + pkt_len = PKT_LEN_NORMAL; + + pkt_tbl[i] = odp_packet_alloc(pkt_pool, pkt_len); + if (pkt_tbl[i] == ODP_PACKET_INVALID) + break; + + pkt_seq[i] = pktio_init_packet(pkt_tbl[i]); + if (pkt_seq[i] == TEST_SEQ_INVALID) + break; + } + alloc_pkts = i; + + if (alloc_pkts == TX_BATCH_LEN) { + /* try to send the batch with the long packet in the middle, + * the initial short packets should be sent successfully */ + odp_errno_zero(); + ret = odp_pktio_send(pktio_tx, pkt_tbl, TX_BATCH_LEN); + CU_ASSERT(ret == long_pkt_idx); + CU_ASSERT(odp_errno() == 0); + + info_rx.id = pktio_rx; + info_rx.outq = ODP_QUEUE_INVALID; + 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); + if (pkt_tbl[i] == ODP_PACKET_INVALID) + break; + } + + if (i == ret) { + /* now try to send starting with the too-long packet + * and verify it fails */ + odp_errno_zero(); + ret = odp_pktio_send(pktio_tx, + &pkt_tbl[long_pkt_idx], + TX_BATCH_LEN - long_pkt_idx); + CU_ASSERT(ret == -1); + CU_ASSERT(odp_errno() != 0); + } else { + CU_FAIL("failed to receive transmitted packets\n"); + } + } else { + CU_FAIL("failed to generate test packets\n"); + } + + for (i = 0; i < alloc_pkts; ++i) { + if (pkt_tbl[i] != ODP_PACKET_INVALID) + odp_packet_free(pkt_tbl[i]); + } + + if (pktio_rx != pktio_tx) + CU_ASSERT(odp_pktio_close(pktio_rx) == 0); + CU_ASSERT(odp_pktio_close(pktio_tx) == 0); + CU_ASSERT(odp_pool_destroy(pkt_pool) == 0); +} + static int create_pool(const char *iface, int num) { char pool_name[ODP_POOL_NAME_LEN]; @@ -897,6 +1013,7 @@ CU_TestInfo pktio_suite_unsegmented[] = { _CU_TEST_INFO(pktio_test_recv), _CU_TEST_INFO(pktio_test_recv_multi), _CU_TEST_INFO(pktio_test_jumbo), + _CU_TEST_INFO(pktio_test_send_failure), _CU_TEST_INFO(pktio_test_mtu), _CU_TEST_INFO(pktio_test_promisc), _CU_TEST_INFO(pktio_test_mac), @@ -913,6 +1030,7 @@ CU_TestInfo pktio_suite_segmented[] = { _CU_TEST_INFO(pktio_test_recv), _CU_TEST_INFO(pktio_test_recv_multi), _CU_TEST_INFO(pktio_test_jumbo), + _CU_TEST_INFO(pktio_test_send_failure), CU_TEST_INFO_NULL };