From patchwork Wed Oct 28 19:29:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Haslam X-Patchwork-Id: 55718 Delivered-To: patch@linaro.org Received: by 10.112.61.134 with SMTP id p6csp138674lbr; Wed, 28 Oct 2015 12:35:15 -0700 (PDT) X-Received: by 10.107.14.74 with SMTP id 71mr16028698ioo.92.1446060915082; Wed, 28 Oct 2015 12:35:15 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id a126si35390978ioe.74.2015.10.28.12.35.14; Wed, 28 Oct 2015 12:35:15 -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 7026061B2D; Wed, 28 Oct 2015 19:35:14 +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 857C562002; Wed, 28 Oct 2015 19:30:23 +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 1BB2C62004; Wed, 28 Oct 2015 19:30:17 +0000 (UTC) Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com [209.85.212.172]) by lists.linaro.org (Postfix) with ESMTPS id 41E8C61FE6 for ; Wed, 28 Oct 2015 19:29:29 +0000 (UTC) Received: by wijp11 with SMTP id p11so267906709wij.0 for ; Wed, 28 Oct 2015 12:29:28 -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=c9y/xofWWv5iwr154w1qxPM1Ftbgd6awCTBCalZIGS0=; b=wL3wRVrvhAEmx2TaCBZ6wckYuT2p8mqL/P5ehfBwdmzzZkounRWuinY2XtbY276pbw OqDVN1cA04lWQkJLbEahr3n7KFXL6o6P9lBFOW8nWAtsAyQLTPTUzO+Z5u+neErjH+LE 9HsVN7w18t+QpSOwoYD3HU1RqxzOMgnY+3vXGEE6joXcRRFgvqdmtMc6wbeJrFXVS65N KGuvy+O72AHL3DAiYK/3BebcXJy9ybpc16R8rCipVOOUOjnVYSd/jnCGwhkraWC/2ECW jwoi7dDDS1jIO9MQGJxECnnb9KAPikjvEDf2tWYQ4wnvSxZbB9muABeIXfl4VOFoLSSr nXOA== 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=c9y/xofWWv5iwr154w1qxPM1Ftbgd6awCTBCalZIGS0=; b=idh91TQ04xBw/6W0msqtfg5E0kvOPHT7dkJJINIBRq2ocYRj0Vue8PUnudsb3p6ikQ Exd9bAU59avk9yjapUfpxEsXzdzXRZ3oXKBK859kQ2XqRowMFpRYBy353DSo7d9sfs3F M/uJq5xiiwPZ7HFHTGRltkPEmO4oALBl8OWC5owFLDzsZtYLGdrNWktms+2FfH8Nlwak PwC+qdKLLgt/EgSE4fEHBs2kVyBD8e0+dV2T3sL27mRMMJiUitlLJWNVUgrBv7vaCFHt GDPSJdn9h2ToGCgRJyHz37d462/GgPCUqfyXmDdAiv+OGuTbBypyOJ6p96LLAO1uDWe6 4vsA== X-Gm-Message-State: ALoCoQl3weOG2me+1T5HzPiyqSN77yaWbZA/PxrdZqxodVDMqtmnX8eALuRWiG2krBAWyr2++3uf X-Received: by 10.195.12.39 with SMTP id en7mr33594166wjd.126.1446060568496; Wed, 28 Oct 2015 12:29:28 -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.27 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Oct 2015 12:29:27 -0700 (PDT) From: Stuart Haslam To: lng-odp@lists.linaro.org Date: Wed, 28 Oct 2015 19:29:10 +0000 Message-Id: <1446060551-21029-9-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 8/9] linux-generic: validation: add netmap test 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" Add a test for the netmap pktio type. This test will only run as root and if the netmap kernel module is loaded, otherwise it will be skipped. There are three different interface types tested by default, VALE ports, pipe ports and veth (veth only if the netmap enabled veth module is loaded). Signed-off-by: Stuart Haslam --- platform/linux-generic/test/Makefile.am | 4 + platform/linux-generic/test/pktio/pktio_run_netmap | 133 +++++++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100755 platform/linux-generic/test/pktio/pktio_run_netmap diff --git a/platform/linux-generic/test/Makefile.am b/platform/linux-generic/test/Makefile.am index 11648d4..b78259c 100644 --- a/platform/linux-generic/test/Makefile.am +++ b/platform/linux-generic/test/Makefile.am @@ -31,6 +31,10 @@ if HAVE_PCAP TESTS += pktio/pktio_run_pcap endif +if netmap_support +TESTS += pktio/pktio_run_netmap +endif + endif #performance tests refer to pktio_env diff --git a/platform/linux-generic/test/pktio/pktio_run_netmap b/platform/linux-generic/test/pktio/pktio_run_netmap new file mode 100755 index 0000000..bbb4c87 --- /dev/null +++ b/platform/linux-generic/test/pktio/pktio_run_netmap @@ -0,0 +1,133 @@ +#!/bin/sh +# +# Copyright (c) 2015, Linaro Limited +# All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +# directories where pktio_main binary can be found: +# -in the validation dir when running make check (intree or out of tree) +# -in the script directory, when running after 'make install', or +# -in the validation when running standalone (./pktio_run) intree. +# -in the current directory. +# running stand alone out of tree requires setting PATH +PATH=${TEST_DIR}/pktio:$PATH +PATH=$(dirname $0):$PATH +PATH=$(dirname $0)/../../../../test/validation/pktio:$PATH +PATH=.:$PATH + +pktio_main_path=$(which pktio_main${EXEEXT}) +if [ -x "$pktio_main_path" ] ; then + echo "running with pktio_main: $pktio_main_path" +else + echo "cannot find pktio_main: please set you PATH for it." +fi + +# directory where platform test sources are, including scripts +TEST_SRC_DIR=$(dirname $0) + +# exit codes expected by automake for skipped tests +TEST_SKIPPED=77 + +# Use installed pktio env or for make check take it from the test directory +if [ -f "./pktio_env" ]; then + . ./pktio_env +elif [ -f ${TEST_SRC_DIR}/pktio_env ]; then + . ${TEST_SRC_DIR}/pktio_env +else + echo "ERROR: unable to find pktio_env!" + echo "pktio_env has to be in current directory or in ${TEST_SRC_DIR}" + exit 1 +fi + +run_test() +{ + local ret=0 + + pktio_main${EXEEXT} + ret=$? + + if [ $ret -ne 0 ]; then + echo "!!! FAILED !!!" + fi + + return $ret +} + +run_test_vale() +{ + # use two vale ports on the same switch + export ODP_PKTIO_IF0=valetest:0 + export ODP_PKTIO_IF1=valetest:1 + run_test + return $? +} + +run_test_pipe() +{ + # use a netmap pipe + export ODP_PKTIO_IF0=valetest:0{0 + export ODP_PKTIO_IF1=valetest:0}0 + run_test + return $? +} + +run_test_veth() +{ + if [ "$(lsmod | grep netmap | grep veth)" = "" ]; then + echo "netmap enabled veth module not loaded, skipping test." + return 0 + fi + + setup_pktio_env clean + export ODP_PKTIO_IF0=$IF0 + export ODP_PKTIO_IF1=$IF1 + run_test + return $? +} + +run() +{ + local ret=0 + + # need to be root to run these tests + if [ "$(id -u)" != "0" ]; then + echo "netmap tests must be run as root, skipping test." + exit $TEST_SKIPPED + fi + + NETMAP_PARAMS=/sys/module/netmap/parameters + if [ ! -d $NETMAP_PARAMS ]; then + echo "netmap kernel module not loaded, skipping test." + exit $TEST_SKIPPED + fi + + NM_BUF_SIZE=9216 + NM_PARAM_BUF_SIZE=$(cat $NETMAP_PARAMS/buf_size) + NM_PARAM_PRIV_BUF_SIZE=$(cat $NETMAP_PARAMS/priv_buf_size) + + echo "Setting netmap buffer size to $NM_BUF_SIZE" + echo $NM_BUF_SIZE > $NETMAP_PARAMS/buf_size + echo $NM_BUF_SIZE > $NETMAP_PARAMS/priv_buf_size + + if [ "$ODP_PKTIO_IF0" != "" ]; then + run_test + ret=$? + else + run_test_vale + r=$?; [ $ret = 0 ] && ret=$r + run_test_pipe + r=$?; [ $ret = 0 ] && ret=$r + run_test_veth + r=$?; [ $ret = 0 ] && ret=$r + fi + + echo "Restoring buffer sizes" + echo $NM_PARAM_BUF_SIZE > $NETMAP_PARAMS/buf_size + echo $NM_PARAM_PRIV_BUF_SIZE > $NETMAP_PARAMS/priv_buf_size + + exit $ret +} + +run