From patchwork Fri Jan 22 18:48:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Haslam X-Patchwork-Id: 60180 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp28270lbb; Fri, 22 Jan 2016 10:51:59 -0800 (PST) X-Received: by 10.107.185.132 with SMTP id j126mr5197096iof.149.1453488719556; Fri, 22 Jan 2016 10:51:59 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 86si13787288iod.161.2016.01.22.10.51.58; Fri, 22 Jan 2016 10:51:59 -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 65C2B618E2; Fri, 22 Jan 2016 18:51:58 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=dGNOWcL2; 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 3540361960; Fri, 22 Jan 2016 18:48:48 +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 0BD9A6193B; Fri, 22 Jan 2016 18:48:30 +0000 (UTC) Received: from mail-wm0-f54.google.com (mail-wm0-f54.google.com [74.125.82.54]) by lists.linaro.org (Postfix) with ESMTPS id 7FBD3618E0 for ; Fri, 22 Jan 2016 18:48:25 +0000 (UTC) Received: by mail-wm0-f54.google.com with SMTP id b14so146398969wmb.1 for ; Fri, 22 Jan 2016 10:48:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=LU8qvJY6+psUAWbsJcNZat5cnTY7xCpM7QEgWg22Znw=; b=dGNOWcL2ETcIvk32guj1soObbaWbmJigCUsvGmFIOct9XvP9KqeN9cNYGatDoag6wf vzT03JzztAzcoLCRFJimmTXtwsB/xwzVDeuq+9qh7YIteKOwWWDss3kKo02L1+UxBWgd y0o293cQCko6KHclh9UFrLmVBAsMYcuT+P3eE= 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=LU8qvJY6+psUAWbsJcNZat5cnTY7xCpM7QEgWg22Znw=; b=MSCoaaNjg2y5trrI3pKCqjniFzxoipmihID7BeG7aHP3CxLBNC6ify4vmdQ8HZuu7O Mv1XBH2AYXP1LCC3fTC+PbtuoNjrXFZz+fnUcAVKtKdzDtB0c7mI3JZg/zDdidw7m204 arDW+7jFfU5sQooMheXTg6LVLvS2T655t4a3039xWfUf3y5vYRnbft2wHa0oCOo6CBeb tawu8peYsFx6+sbSwfb+ixC2yCJGw/FNtnqIXFDvjVyU33Dtc5uRbjZUbnhXC/N/sxkR Bt0p4Lrmm7m2mvh9VjNQCDwc7p+4F8TxRSqU+C7J/BUCLKLjkhqItKvl5uo8T5u150Qq g+Nw== X-Gm-Message-State: AG10YOQVtVx3sL26/zbmHobtG7bKPFZYoIo8WwD4oHSqI5fvx9dp9yOnkHdpptBGZUtDFJqlOQg= X-Received: by 10.194.58.165 with SMTP id s5mr5151610wjq.70.1453488504785; Fri, 22 Jan 2016 10:48:24 -0800 (PST) Received: from e106441.emea.arm.com ([2001:41d0:a:3cb4::1]) by smtp.gmail.com with ESMTPSA id p9sm7085262wjy.41.2016.01.22.10.48.24 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 22 Jan 2016 10:48:24 -0800 (PST) From: Stuart Haslam To: lng-odp@lists.linaro.org Date: Fri, 22 Jan 2016 18:48:06 +0000 Message-Id: <1453488486-12176-6-git-send-email-stuart.haslam@linaro.org> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1453488486-12176-1-git-send-email-stuart.haslam@linaro.org> References: <1453488486-12176-1-git-send-email-stuart.haslam@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv2 5/5] 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 | 5 + platform/linux-generic/test/pktio/pktio_run_netmap | 133 +++++++++++++++++++++ 2 files changed, 138 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 e629872..05baa51 100644 --- a/platform/linux-generic/test/Makefile.am +++ b/platform/linux-generic/test/Makefile.am @@ -34,6 +34,11 @@ SUBDIRS = $(ODP_MODULES) if HAVE_PCAP TESTS += pktio/pktio_run_pcap endif + +if netmap_support +TESTS += pktio/pktio_run_netmap +endif + endif dist_check_SCRIPTS = run-test tests-validation.env $(LOG_COMPILER) 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