From patchwork Sat Jun 30 00:48:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10497781 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1ADC260327 for ; Sat, 30 Jun 2018 00:49:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0AF6295AC for ; Sat, 30 Jun 2018 00:49:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E40C0295B1; Sat, 30 Jun 2018 00:49:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B4D6295AD for ; Sat, 30 Jun 2018 00:49:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934366AbeF3Atg (ORCPT ); Fri, 29 Jun 2018 20:49:36 -0400 Received: from mail-eopbgr60050.outbound.protection.outlook.com ([40.107.6.50]:31264 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933750AbeF3Ate (ORCPT ); Fri, 29 Jun 2018 20:49:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GvkFqiJSRX1U01Ra2CEpRnMUboq75PoXcpsjkoK+Pec=; b=PO4EN4y/0HGcEghMwO4JYhfBSxLKFKlurGNC6MbcrNBePT/n87WHIonLtcimvXHkHO6xCYK5dVqGvRTYi5DR6FBj5LgldFikyB8bMPRRXU4mXvsHe6vfT6KrXju+tZeFfIdfOm7mflyO+C7ONfFNostshEwwBsXySYoCrIIS92A= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (89.176.83.59) by VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.906.25; Sat, 30 Jun 2018 00:49:30 +0000 From: Petr Machata To: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: jiri@mellanox.com, idosch@mellanox.com, shuah@kernel.org, davem@davemloft.net Subject: [PATCH net-next 06/13] selftests: mlxsw: Add devlink KVD resource test In-Reply-To: References: Message-Id: <812360f52f4f3a670c7432784f775f36749b9b0e.1530319109.git.petrm@mellanox.com> Date: Sat, 30 Jun 2018 02:48:27 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 X-Originating-IP: [89.176.83.59] X-ClientProxiedBy: HE1PR05CA0358.eurprd05.prod.outlook.com (2603:10a6:7:94::17) To VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 35b4e23f-77c0-4fa0-4a62-08d5de2357c9 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(48565401081)(5600052)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:VI1PR05MB4191; X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 3:UsSHb6MzlE14dV+6zwKKrQ2+Fp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/OIkXKs7c/hpB4+T4VKZvO8WApO8p14Cb7342IKHsjyGnkwZ1mamUZyRM18hImh4uzJSD4Rs3GY15paRbShF2OOc6lAMRZiLuDGndiFNChADwFuNbG7eZnbpXBwBQH+7jF1pdShgT/yHm79/Ciwffw70F0pkRUhs0jKCAENR0BPxZmne+vfcPZIlYZCyv4L0vivEeP6/e7DRWp2SGaw2jaWLGOHb/2g280wbWReBAgq17BZ1NnoBC0j4cB/fIgPxGxQm+hwng1Vb9tW7OYaBeDRpW+6SxXS+RPMygZ4nYv/ZD353pOSkXt9+4HbWvCJl5gQ/; 4:3xMcxy9dp6Ho4otkBN/+vK0l7GjODAJcnVHd1mHBkQdoteIy2qw2R11f6+YfkAcomF6VM+v5fOPT1/BVfLoCgTO23ENJTcGX4Xzy/Z1pPwwf13dxIH/ZF+3ilOxiOyJSMnxTpoPIIbloZkmnFn8lyo+ABaBI7+/lYW009VUP2lRcDr+jFNruwKeZsISNLvwGsANQ9p3TNTk0DAIjxge4rYW6x9O2e4bpe7wyf6rATNDMiyu5QIeLx7VWkGcDcs/Q83xsliENx9e5uoajnozVOQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231254)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(6072148)(201708071742011)(7699016); SRVR:VI1PR05MB4191; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB4191; X-Forefront-PRVS: 0719EC6A9A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(346002)(366004)(39860400002)(396003)(136003)(189003)(199004)(86362001)(478600001)(476003)(486006)(68736007)(956004)(2616005)(6116002)(6496006)(2906002)(66066001)(52116002)(3846002)(47776003)(76176011)(53936002)(5660300001)(4326008)(14444005)(446003)(11346002)(51416003)(6486002)(36756003)(48376002)(118296001)(386003)(50466002)(16526019)(105586002)(186003)(26005)(106356001)(97736004)(25786009)(8936002)(316002)(6666003)(81166006)(7736002)(16586007)(8676002)(305945005)(58126008)(81156014); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB4191; H:t540p; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR05MB4191; 23:73+ROqoYNeCCHZZSXyvVewctB0WrOQSi26nu6bbbf?= =?us-ascii?Q?PNDth+B5cX3VunHCZa3Uxw5wBsOsNUezL1VbJe0LKQmp2wA8Jr+sjB5MSLx8?= =?us-ascii?Q?xLfZ4a7G3fsZwpxIZo4X3/MOp73F7aOGv2rtjq7dI0UcZU2BBLeb/WU3BuyC?= =?us-ascii?Q?697gTpf4Q6B8o6LVeglVr5FTTym+rDI3TdHdRs6GrKbClG8UBOtUDOR6dpt1?= =?us-ascii?Q?Z6OAFk/92UmPT25rFDYooMwPtIgHkySdrCTkN2GGTC2QkVKOLpYSnq2Hu8Td?= =?us-ascii?Q?IDV2XAnHJ5ASAAHv+J99/cnaZV0dWcki1wDQTi1Fvv70kAv1jvWLu+qdGLlJ?= =?us-ascii?Q?zhyIrfPASx8AGFrwmdd/Sb0opLIw+Uf2cWn3BK1kifc2RVRRFI8UvNVuVzUF?= =?us-ascii?Q?odGwkW7S+urbkhPICP4Ip09Z2UbuXDOexNkxnNDaC3qaPz7KRNaw6z3bXMye?= =?us-ascii?Q?17Gt+lWKAJdQQjPUjTacvDHhubuQTXVzyql616iX2WEsF7Hp+s6aZGK6KXKy?= =?us-ascii?Q?c19RAZs3Ky1690xC1ySVMO77uF35VKYf6hsMf5X/DGG+gin/PTxgJWi3f1kl?= =?us-ascii?Q?Iet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HJp029yXg/dttOIvFyre5uLddw= X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 6:azP2thyQB26NHeZAYuGUpFVFwlbnpIogdbbaQX43HLktc0ms2dON6wNaI+AMIvsSuPeoXxP7FppE1+R/s+WMZG7C/fd0IQbp1IWGlGBChF7/HeV6Ajs90gBPhnf5pYfSrLa8bQt+cpINCkClONywa6CvUi+DGDgI0JTp1susetyA30KKjliJ6WpDk5GiHz9JMCTvOo2ZvNKhHhPkqTenOimT67OoCOhnbwrM/9eLCTx/XJlK24BIxHYVDYu0oDHgoiZU7dokenYhIo+/x355mAaWBnp8pnz4lG1IgcvhfhoftiYVkd7vd8Wj7j/2VYliGz7tkXLMA5YHFceeXsejHgRaziu0yBZFyurIfa5SQp7bkKVRxY5h/YTvcgF3JbKhZIsf0wuKs8YRnXuOVesTy65qPItOs/uK0LI/KCzZgvpQKVyWdPvfQnzIk3NgQWCxnXHqnwBvYsyk24JkOpxR6Q==; 5:T24aC2cci0DkB6E7hOJsuUi0eYri+1vW11kF32cUhLp4+rX1IZnGtnZiYxIvEGLuh66Os83hLAebsFbcWa3LXIAmlpDIQs/CpnUWrK4XTjNmFQFDG3jlk1937caiA1EF9jaMicdoPIcCMZFT90p0R41DaC4G4V4QIZuwDWJVo1o=; 24:fvpofNh4Fn0qn7ERqakR9tMV8NTHgCwRe512j1/h7ktGfpEMkQc88mEqYNvnOb69DjCDLD96aAfDgRIoR5SkXuPgqac/tARezpMisxEpX34= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 7:U4d4Ktp/n59ubX66Lvh1M2qvYhcLqwIC4tHnK5oGoN+Yr//VqeFjN6BgsDiQ0rW1073ueKMP1R9cuPZvf39Rr64BFsry4a+CNmcWJkfbDO60EOku4wiyMlk/rsGQ9TbQZpquzkEVxz31e5rsXXmp0bV5CTy2Ro0QktqsgK2tUXdUoAXoEVCq6LQ37GUoZ8dcc5iDbG2lgDQca19p3692GvZxtY9b+JaVAnxgFPEplGmpfqluE/1cmH2MpyIeFuVN X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2018 00:49:30.9956 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 35b4e23f-77c0-4fa0-4a62-08d5de2357c9 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB4191 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Yuval Mintz Add a selftest that can be used to perform basic sanity of the devlink resource API as well as test the behavior of KVD manipulation in the driver. This is the first case of a HW-only test - in order to test the devlink resource a driver capable of exposing resources has to be provided first. Signed-off-by: Yuval Mintz [petrm@mellanox.com: Extracted two patches out of this patch. Tweaked commit message.] Signed-off-by: Petr Machata --- .../net/mlxsw/spectrum/devlink_resources.sh | 117 +++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100755 tools/testing/selftests/drivers/net/mlxsw/spectrum/devlink_resources.sh diff --git a/tools/testing/selftests/drivers/net/mlxsw/spectrum/devlink_resources.sh b/tools/testing/selftests/drivers/net/mlxsw/spectrum/devlink_resources.sh new file mode 100755 index 000000000000..b1fe960e398a --- /dev/null +++ b/tools/testing/selftests/drivers/net/mlxsw/spectrum/devlink_resources.sh @@ -0,0 +1,117 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +NUM_NETIFS=1 +source devlink_lib_spectrum.sh + +setup_prepare() +{ + devlink_sp_read_kvd_defaults +} + +cleanup() +{ + pre_cleanup + devlink_sp_size_kvd_to_default +} + +trap cleanup EXIT + +setup_prepare + +profiles_test() +{ + local i + + log_info "Running profile tests" + + for i in $KVD_PROFILES; do + RET=0 + devlink_sp_resource_kvd_profile_set $i + log_test "'$i' profile" + done + + # Default is explicitly tested at end to ensure it's actually applied + RET=0 + devlink_sp_resource_kvd_profile_set "default" + log_test "'default' profile" +} + +resources_min_test() +{ + local size + local i + local j + + log_info "Running KVD-minimum tests" + + for i in $KVD_CHILDREN; do + RET=0 + size=$(devlink_resource_get kvd "$i" | jq '.["size_min"]') + devlink_resource_size_set "$size" kvd "$i" + + # In case of linear, need to minimize sub-resources as well + if [[ "$i" == "linear" ]]; then + for j in $KVDL_CHILDREN; do + devlink_resource_size_set 0 kvd linear "$j" + done + fi + + devlink_reload + devlink_sp_size_kvd_to_default + log_test "'$i' minimize [$size]" + done +} + +resources_max_test() +{ + local min_size + local size + local i + local j + + log_info "Running KVD-maximum tests" + for i in $KVD_CHILDREN; do + RET=0 + devlink_sp_resource_minimize + + # Calculate the maximum possible size for the given partition + size=$(devlink_resource_size_get kvd) + for j in $KVD_CHILDREN; do + if [ "$i" != "$j" ]; then + min_size=$(devlink_resource_get kvd "$j" | \ + jq '.["size_min"]') + size=$((size - min_size)) + fi + done + + # Test almost maximum size + devlink_resource_size_set "$((size - 128))" kvd "$i" + devlink_reload + log_test "'$i' almost maximize [$((size - 128))]" + + # Test above maximum size + devlink resource set "$DEVLINK_DEV" \ + path "kvd/$i" size $((size + 128)) &> /dev/null + check_fail $? "Set kvd/$i to size $((size + 128)) should fail" + log_test "'$i' Overflow rejection [$((size + 128))]" + + # Test maximum size + if [ "$i" == "hash_single" ] || [ "$i" == "hash_double" ]; then + echo "SKIP: Observed problem with exact max $i" + continue + fi + + devlink_resource_size_set "$size" kvd "$i" + devlink_reload + log_test "'$i' maximize [$size]" + + devlink_sp_size_kvd_to_default + done +} + +profiles_test +resources_min_test +resources_max_test + +exit "$RET"