From patchwork Sat Jun 30 00:48:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10497779 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 19437602CC for ; Sat, 30 Jun 2018 00:48:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE8F5295AC for ; Sat, 30 Jun 2018 00:48:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DEFEE295B0; Sat, 30 Jun 2018 00:48:31 +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 176F0295AC for ; Sat, 30 Jun 2018 00:48:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934248AbeF3Asa (ORCPT ); Fri, 29 Jun 2018 20:48:30 -0400 Received: from mail-db5eur01on0062.outbound.protection.outlook.com ([104.47.2.62]:7344 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933750AbeF3As3 (ORCPT ); Fri, 29 Jun 2018 20:48:29 -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=IZCyQt5FuI8NMrBv8PRFxPbOiVXBjeXAYatbQ+D59vA=; b=pGklNUpDBzHJmS4RTtJWudAdcLjOEnWQa9qEF9ej1kde2XiO78CisCGAjB5Ey+tBH6+c4h07yEOr7huHKHskiDchLSR+cCdrOx5N+4MjJvEk72zS21qoCYshERjAsATaNOK7ApfWXbJkJdGZZVx71MOYocHw6IHlnRSiPQ46Gkg= 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:48:26 +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 05/13] selftests: mlxsw: Add devlink_lib_spectrum.sh In-Reply-To: References: Message-Id: Date: Sat, 30 Jun 2018 02:48:12 +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: LO2P265CA0117.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:c::33) 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: 892e4b62-9a7d-471b-6601-08d5de2330fe 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:2k9668rNG4cdp8/ecJcjP3TcbWySKNmxaVWmsK9E7b7/z1kg8+tdnN6H+fhp7LX8vX9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HW7BGsJ7IC4xo+Wuvkr9DjtUC4YdUYxkQyVBWUj51wwZIDi9u42/f3daxG3W8nBTusxcaRdhHLT4sQ+qYewQa14JlsHXmvVhQApsrHh5N2K1yjTtuzp+M/eJJgwSyqIb0ckYncXXSN3Yvk9Bn7zAaz6pugqwra5BEri3uAXMHXH6KtvptmZxrpAAH0YwWC/3hwn7Q0I8sxkux02f8aG3JOf/2nhrY3MDb+O363a0pMLsQqvlCB8dpjQ6i48VBFALfqe1sQnG38jl4YWUHlM; 4:KpmiAbEhQYoM569e2MIEZEpbWJK6lWRL+OYaRaNBmgsOzwaJ+CcbZa1H6o1XSlzuW2ChG98bZVPHHZaX28by2fAK7x08oVOpnh4eSFT30u7PBHh/TIfMGXbWnJMVpmeoms0lO6vtPSOw+CBhX1VUNoRj7ynWNP5LBX+tcreRoQ0aQ+xYKaD0KN+s1gxrXO1rZxrYx69PpyGa1lPCzFbQy5BUf1gF5jRPyuq5CfleVm8P+zondntYay3vapTBqiLKjsGwC292lsIfhdLeP9Qe7nCcutjMob6ujI8G7vsBKsfv5pVmwriD+v8ubQTNib9p X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(171992500451332); 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)(53386004)(5660300001)(4326008)(446003)(11346002)(51416003)(6306002)(6486002)(36756003)(48376002)(118296001)(386003)(50466002)(16526019)(105586002)(186003)(26005)(106356001)(97736004)(25786009)(966005)(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:eljD6oo3TEm+ETDZAqep3ook+1P+1D9oPK/J1L9MZ?= =?us-ascii?Q?xlkZQJXVdTq2BIRFmiIedspC1/L2sR1HEbqDD2JW2xG9c+hJh0/trJbOzGy0?= =?us-ascii?Q?sFsVSo8ldwa69/+9Ows9iwFkX1GYDjo2RsXXJNwmryA4yJIMPhWvN3uw8QwS?= =?us-ascii?Q?0XXZ/stswUYWV4RXUDcvf2PVQYoO5YxnDduzOum0WGj+3Ik8OzYA9vbRD8GY?= =?us-ascii?Q?g2oacXAcjFUmyKbMvgwuAUkdjQjLjC4h/zV3686euHpPbCqWsA91dGlLBk12?= =?us-ascii?Q?Do34E/PNT0qAajZOkLYGxzBQASVFuvDldlWdIi8uKuei3fojvonb90dCdUun?= =?us-ascii?Q?lRxz7NXECpBd5Hu9bLjnhqhXWqhJrHeHjHmmcWIAYNP42AhNOMNFOt7Q0OE+?= =?us-ascii?Q?IJZHY76q/k+in5tZuuM+gQRvfzE8uhTpIASicJwANXvUuxPQvW6hpSSPYGCz?= =?us-ascii?Q?/T7SJ2zCreVr0tafw4JYTCYnCyNRq5ijLRSjak1mL+Pjijp1D68fPfsmWH5T?= =?us-ascii?Q?bxy01A/U5hTVYl0FTbHDKT219HRkZeWbdRYqC/YuSlGjUrGOkhHe2lfGzexH?= =?us-ascii?Q?+TXc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HMUI/UB3Z1KS6KHl4gjqwR9m4yjpPhMOQVzOQOf8BjSHkJKGIbbyxcB1F35lkkvyja+Ps= X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 6:XTbxjwm6foVI4rQhz8fWn5fR8nndccW3G5JvUdy5Rox0XUB2agnC4GUPit6AKkIIHhaedR48TQ/nyDjH2V41AkdziulrKZ29K0eY43Mn4/DI5Zwb5Nm49O1pYLq/eDbbGnBwBvdaP4zP1yO4zqAMzptDFx1h1DQdDHu3YjqbmFSz8OiwY4Evsozhp77M5vENwNwQ3NQN1DE4M0+pDp22jAcVcsZhoduTpvE0HXWsSCEQM/eRSyaismVRZVWTOx0Ng22ZyBACrXASc4dc/zvzAqpwnjALX2i0elg5XBS2VClbILDPqD56i3A1+99HbAwOMBU7L6Ovtcz3M7+Fst3qmX79OjMZo9x3pGgd0GURJxEE3JK8Tlo4GYBRbK/P5kiva3xjPbBERuFmBtNNYpv+aJSuZ0ZssvY+5XvQggjb+O4ZuQWZemYYeMj0bcbiJdYryk3RGf58yu9vhF+s18GeMw==; 5:eSFX57FyoMm5LGb28jou/D2fgmNP3J6zqR5NaW0pcQexWacIouiKltF3H+3evsocjiOCDFIJegaRSw72qjzgKZRv2WIDJb3vv5xJ+m8Mqa+AAexfEx/B7Qdg8HWSZGgMm7SOEiBgzbfj1xrTqGlnYAeJQkxmg6cI3LaQCmGcSyI=; 24:JGt3XVD648nYwjgbKJbjNy3iKqIWG5qMd4pG6gS7406gvJ9VsvMAlZEFe3CvH98UhRR57givsb1MVfr5IxasrkI6NulY0mh2cl88U/Syfck= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 7:9PLCHTv695I3Bk6jcWATuSfxRscxFAnMNs+nQaOVq+91EQVPhJHis7L3hwy+T6Qb75MUBtmcWaWzuoiRrHZUi19fqiDyyiToacawr4FqemL+vPsbvKQopmh4+v+oD8d5rZhUC3n534+/S+sRY9xX5H0y4xZGcXv0+m19Bjj7G06lNXEm/H8YYqBUyUQfyYucBRlKDGlcoeEgOOx/rmukvwL7JR5v3N5quOZrGL7uCk4lZVPBo6ZYHMhFAU/Pnp4K X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2018 00:48:26.4679 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 892e4b62-9a7d-471b-6601-08d5de2330fe 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 This library builds on top of devlink_lib.sh and contains functionality specific to Spectrum ASICs, e.g., re-partitioning the various KVD sub-parts. Signed-off-by: Yuval Mintz [petrm@mellanox.com: Split this out from another patch. Fix line length in devlink_sp_read_kvd_defaults().] Signed-off-by: Petr Machata --- MAINTAINERS | 1 + .../net/mlxsw/spectrum/devlink_lib_spectrum.sh | 119 +++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 tools/testing/selftests/drivers/net/mlxsw/spectrum/devlink_lib_spectrum.sh diff --git a/MAINTAINERS b/MAINTAINERS index f3e766e504d8..f3dd6c4f61e1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9154,6 +9154,7 @@ S: Supported W: http://www.mellanox.com Q: http://patchwork.ozlabs.org/project/netdev/list/ F: drivers/net/ethernet/mellanox/mlxsw/ +F: tools/testing/selftests/drivers/net/mlxsw/ MELLANOX FIRMWARE FLASH LIBRARY (mlxfw) M: mlxsw@mellanox.com diff --git a/tools/testing/selftests/drivers/net/mlxsw/spectrum/devlink_lib_spectrum.sh b/tools/testing/selftests/drivers/net/mlxsw/spectrum/devlink_lib_spectrum.sh new file mode 100644 index 000000000000..73035e25085d --- /dev/null +++ b/tools/testing/selftests/drivers/net/mlxsw/spectrum/devlink_lib_spectrum.sh @@ -0,0 +1,119 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +source "../../../../net/forwarding/devlink_lib.sh" + +if [ "$DEVLINK_VIDDID" != "15b3:cb84" ]; then + echo "SKIP: test is tailored for Mellanox Spectrum" + exit 1 +fi + +# Needed for returning to default +declare -A KVD_DEFAULTS + +KVD_CHILDREN="linear hash_single hash_double" +KVDL_CHILDREN="singles chunks large_chunks" + +devlink_sp_resource_minimize() +{ + local size + local i + + for i in $KVD_CHILDREN; do + size=$(devlink_resource_get kvd "$i" | jq '.["size_min"]') + devlink_resource_size_set "$size" kvd "$i" + done + + for i in $KVDL_CHILDREN; do + size=$(devlink_resource_get kvd linear "$i" | \ + jq '.["size_min"]') + devlink_resource_size_set "$size" kvd linear "$i" + done +} + +devlink_sp_size_kvd_to_default() +{ + local need_reload=0 + local i + + for i in $KVD_CHILDREN; do + local size=$(echo "${KVD_DEFAULTS[kvd_$i]}" | jq '.["size"]') + current_size=$(devlink_resource_size_get kvd "$i") + + if [ "$size" -ne "$current_size" ]; then + devlink_resource_size_set "$size" kvd "$i" + need_reload=1 + fi + done + + for i in $KVDL_CHILDREN; do + local size=$(echo "${KVD_DEFAULTS[kvd_linear_$i]}" | \ + jq '.["size"]') + current_size=$(devlink_resource_size_get kvd linear "$i") + + if [ "$size" -ne "$current_size" ]; then + devlink_resource_size_set "$size" kvd linear "$i" + need_reload=1 + fi + done + + if [ "$need_reload" -ne "0" ]; then + devlink_reload + fi +} + +devlink_sp_read_kvd_defaults() +{ + local key + local i + + KVD_DEFAULTS[kvd]=$(devlink_resource_get "kvd") + for i in $KVD_CHILDREN; do + key=kvd_$i + KVD_DEFAULTS[$key]=$(devlink_resource_get kvd "$i") + done + + for i in $KVDL_CHILDREN; do + key=kvd_linear_$i + KVD_DEFAULTS[$key]=$(devlink_resource_get kvd linear "$i") + done +} + +KVD_PROFILES="default scale ipv4_max" + +devlink_sp_resource_kvd_profile_set() +{ + local profile=$1 + + case "$profile" in + scale) + devlink_resource_size_set 64000 kvd linear + devlink_resource_size_set 15616 kvd linear singles + devlink_resource_size_set 32000 kvd linear chunks + devlink_resource_size_set 16384 kvd linear large_chunks + devlink_resource_size_set 128000 kvd hash_single + devlink_resource_size_set 48000 kvd hash_double + devlink_reload + ;; + ipv4_max) + devlink_resource_size_set 64000 kvd linear + devlink_resource_size_set 15616 kvd linear singles + devlink_resource_size_set 32000 kvd linear chunks + devlink_resource_size_set 16384 kvd linear large_chunks + devlink_resource_size_set 144000 kvd hash_single + devlink_resource_size_set 32768 kvd hash_double + devlink_reload + ;; + default) + devlink_resource_size_set 98304 kvd linear + devlink_resource_size_set 16384 kvd linear singles + devlink_resource_size_set 49152 kvd linear chunks + devlink_resource_size_set 32768 kvd linear large_chunks + devlink_resource_size_set 87040 kvd hash_single + devlink_resource_size_set 60416 kvd hash_double + devlink_reload + ;; + *) + check_err 1 "Unknown profile $profile" + esac +}