From patchwork Sat Jun 30 00:51:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10497787 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 1C730602CC for ; Sat, 30 Jun 2018 00:52:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE8D028641 for ; Sat, 30 Jun 2018 00:51:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E13DA2873A; Sat, 30 Jun 2018 00:51:59 +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 59EA328641 for ; Sat, 30 Jun 2018 00:51:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933750AbeF3Av7 (ORCPT ); Fri, 29 Jun 2018 20:51:59 -0400 Received: from mail-db5eur01on0088.outbound.protection.outlook.com ([104.47.2.88]:10160 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932296AbeF3Av5 (ORCPT ); Fri, 29 Jun 2018 20:51:57 -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=rCeGmzuo7ZVpT+JMQPWx8RQU4rx/Ngqkc+/+ungpRtk=; b=qZf/4m4EC3kV6vjqz1/uRLGgdp07Ro1/2K2VRWLrro5kHP9LXxTkL+83/taLsfQo8POfny3IvYNKTic4xdzCTOUe+Qk4VTr4BhxJS5U/z0DbgiTLBUOlOhy0f582y0DL4zsa3HOsdg3nTV5Forc8qFnlZM9H+qVn+QE6YD59cdQ= 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:51:54 +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 09/13] selftests: mlxsw: Add tc flower scale test In-Reply-To: References: Message-Id: <8b350871ba1694582a105c597371f5b39af24b72.1530319109.git.petrm@mellanox.com> Date: Sat, 30 Jun 2018 02:51:05 +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: DB6P18901CA0010.EURP189.PROD.OUTLOOK.COM (2603:10a6:4:16::20) 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: 9877c9f8-9fe1-449b-c572-08d5de23ad44 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:f6ecgPSoQ8DS6+91siy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7dJAitarKvRkXwWGkZbId/P7XGPvzqAKtjmqm8kv7I7AUJlarJDRIAgJsVjL6swyq+jEbBnzg2ewb2iztWMLTj+5dP4t4vJpEUuVQcigrgFptAUH3hft9EiEiS99EBmuxRv57YkKcSH8Fy9qBkqWI7LBDAOHg6v6qOf3+cYzG+3Xig++ysKXkgBxYa6Z1ggj6ODCu/AUkys2xM31N9q3F+Y2mkvH0Ncf/bOKgZPaCHgykM7Y6NjzY2P0krC4C4bKj9kxZtV8RiAWG9k7Nrh30JZscHLGD15Kc90FZL3dxKay0910cxUowMHnPFwztsQoP2Osa; 4:0ZLUqhNcc/NL3y6VuhtwYO4Qun7jz74F4sSlJbyoFTngDqm8GDI0qx0gFzgCyy/FeUv2I7mmxVgv+dP7DyKSEo/8S1nO2kGsEguO5jIGYrldorJDkisiOR5frrC36ltLI/Gt5UctqkJZ3xXKHMOwv3QVxRtUTOLjWBTiNnXl1+V0PYRxcMgU4Shk8H/jqMFkdb3Q4yX9siOk/4l/DTnygnObpx608hb0eLoqpw8hf2WJ+O8hibVY72CsQaDWi4Pes1+NYklD1eOAOaxRhfuNhQ== 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:WaeGa8MYYYD1s45kXM0gcL/ICu/yq6pcJkhcIEu9N?= =?us-ascii?Q?aJ69qy4Y9c+/63z1jDZ2mfgKSoQLy6pdhKeIB/APz6gZLLgRcD3JH+im2HBk?= =?us-ascii?Q?PrD6kPJsT+3dipNlaerYnKjf3IDDtyaKz99cZSedUaAHmYjexu/kyAzi1QY1?= =?us-ascii?Q?/K9QQRmAuo8r7pU9LwjcY6mdbo/lL3/zAtvTt3yPpfY0bg7NN12C7ws4JJhz?= =?us-ascii?Q?OGir3eDXcYJIM728P6Wr/MZCRpQtPKhxnsflAisQwhCYNsewQ82hlkF6ZK2O?= =?us-ascii?Q?veTDjQNqcJjjKBZhhqby3EAtKdfEFstR8y1u1qsLqKLyQheOvLqXlxGWO3dl?= =?us-ascii?Q?n5UuHxRICtLay+91lmHjwPDvYAnN0y4MC2ZmzPCNpvonO+UHwcpkhlQ2dg+5?= =?us-ascii?Q?LayrZxFJLrsYl789+KmGTHSAPPnEKFuBuvnNvctCFuXafZGVdzeON5TjVYaU?= =?us-ascii?Q?p1x5UcPW22csZWW3RWr/bjfaCqpwbNCNCF6CHQsw7dA4J2nq1fNFNJvQEElW?= =?us-ascii?Q?/Oiabbz+e+816+Km/a61OEv6ZoX04Nv9aT+brZ+FNDXn0pl90TbdQHYFoAKw?= =?us-ascii?Q?9RX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BVJwtKfUerfhDfDaMyoVL54IbsegQh62ZzYL8= X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 6:WpAGb2hm7AdlNFE6c9trwBomnb8x758hMqqog2g4OvFBye9UbCoHqwgOSIBS5Yc+kpsuF9ksOViuk8h9X/jYFKZ9yKtIY3ur05kLDCzPmB3Lu4djuBXlbzoO8jAPKdtjO0XLhPcYX3UpxM9rcpd5fDR86DJItEasAWiPYrUTrAX84sH26aj+/JioreW6uEst5/FLGunbvwatBGDndKKl8PXsOeSvF1p4s+fT4uJ1XhEcuB5iryvOkaevLBxS7CK4Y949BwdXVlWIwNosj2xFx/ppxEOzyMkgXtOEK/T5+atCbrRrg+3IXHSt6pppWl4wCAXxFeM5ai+qUsyAP4y8edowY1s6ZTjq8qMdY9SzkbeDs3a61Ya4RKjYanB0OM2+M12w0CN1VBzicO3TAdCBCkK2oU04RQaMXvcRbJSbcXYC1xTZphjwCnAu/D2KkY5ztXZqWsccjg8FGUKOQJwwlQ==; 5:+83Us15GmO93FY1xfvUIOc/0LVo543J+MLnrZLeR8eO4z2dFD3PKLil4V/Ikvv8OMtyYHB0lgMK5d1rQQOFneO0N+VimLZCRd2TFEo+syhWL8OvUWHP+hqW7QL1Ieg8XqkAf8sZ7Lfw6oLFbo0f7mDW2ZZmjIYY6NtWrRkeEZGU=; 24:/WowSEzYBbm9w4Tip1VNHS2+O9J/YFWr5U4galt2yflZ5JKNqwSMZfX6FBHihwGCyvo/V/rn6QUHDO3Q1Gvog6qRByTnm3CCCtBKt3uJsKU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 7:RgNK6kC65KX31Q/SyYK4E5k41IL6XEoaJ3iaoAnx+jRMf/32gV9/FKOt2d9d0QpmWfp77/a5G2TR2riuYvynyxb8eIMXDJllft2GvOz8W2cmh6Mcq4NjvN9S7VPjgROg8rgxvYvfLh1GBy5gB2M9G5Hmo3shN1kz8WQe5fP79bgDEgVedRaibzwrUUT4ggvm516lx4Npl8Xrzc3hRtpm9R22KwdRfsdtx+USKeg7eHfT03j94i6Of3mfsvdCUL8S X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2018 00:51:54.7775 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9877c9f8-9fe1-449b-c572-08d5de23ad44 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 Add test of capacity to offload flower. This is a generic portion of the test that is meant to be called from a driver that supplies a particular number of rules to be tested with. Signed-off-by: Petr Machata Reviewed-by: Yuval Mintz --- .../selftests/drivers/net/mlxsw/tc_flower_scale.sh | 134 +++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 tools/testing/selftests/drivers/net/mlxsw/tc_flower_scale.sh diff --git a/tools/testing/selftests/drivers/net/mlxsw/tc_flower_scale.sh b/tools/testing/selftests/drivers/net/mlxsw/tc_flower_scale.sh new file mode 100644 index 000000000000..a6d733d2a4b4 --- /dev/null +++ b/tools/testing/selftests/drivers/net/mlxsw/tc_flower_scale.sh @@ -0,0 +1,134 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# Test for resource limit of offloaded flower rules. The test adds a given +# number of flower matches for different IPv6 addresses, then generates traffic, +# and ensures each was hit exactly once. This file contains functions to set up +# a testing topology and run the test, and is meant to be sourced from a test +# script that calls the testing routine with a given number of rules. + +TC_FLOWER_NUM_NETIFS=2 + +tc_flower_h1_create() +{ + simple_if_init $h1 + tc qdisc add dev $h1 clsact +} + +tc_flower_h1_destroy() +{ + tc qdisc del dev $h1 clsact + simple_if_fini $h1 +} + +tc_flower_h2_create() +{ + simple_if_init $h2 + tc qdisc add dev $h2 clsact +} + +tc_flower_h2_destroy() +{ + tc qdisc del dev $h2 clsact + simple_if_fini $h2 +} + +tc_flower_setup_prepare() +{ + h1=${NETIFS[p1]} + h2=${NETIFS[p2]} + + vrf_prepare + + tc_flower_h1_create + tc_flower_h2_create +} + +tc_flower_cleanup() +{ + pre_cleanup + + tc_flower_h2_destroy + tc_flower_h1_destroy + + vrf_cleanup + + if [[ -v TC_FLOWER_BATCH_FILE ]]; then + rm -f $TC_FLOWER_BATCH_FILE + fi +} + +tc_flower_addr() +{ + local num=$1; shift + + printf "2001:db8:1::%x" $num +} + +tc_flower_rules_create() +{ + local count=$1; shift + local should_fail=$1; shift + + TC_FLOWER_BATCH_FILE="$(mktemp)" + + for ((i = 0; i < count; ++i)); do + cat >> $TC_FLOWER_BATCH_FILE <<-EOF + filter add dev $h2 ingress \ + prot ipv6 \ + pref 1000 \ + flower $tcflags dst_ip $(tc_flower_addr $i) \ + action drop + EOF + done + + tc -b $TC_FLOWER_BATCH_FILE + check_err_fail $should_fail $? "Rule insertion" +} + +__tc_flower_test() +{ + local count=$1; shift + local should_fail=$1; shift + local last=$((count - 1)) + + tc_flower_rules_create $count $should_fail + + for ((i = 0; i < count; ++i)); do + $MZ $h1 -q -c 1 -t ip -p 20 -b bc -6 \ + -A 2001:db8:2::1 \ + -B $(tc_flower_addr $i) + done + + MISMATCHES=$( + tc -j -s filter show dev $h2 ingress | + jq -r '[ .[] | select(.kind == "flower") | .options | + values as $rule | .actions[].stats.packets | + select(. != 1) | "\(.) on \($rule.keys.dst_ip)" ] | + join(", ")' + ) + + test -z "$MISMATCHES" + check_err $? "Expected to capture 1 packet for each IP, but got $MISMATCHES" +} + +tc_flower_test() +{ + local count=$1; shift + local should_fail=$1; shift + + # We use lower 16 bits of IPv6 address for match. Also there are only 16 + # bits of rule priority space. + if ((count > 65536)); then + check_err 1 "Invalid count of $count. At most 65536 rules supported" + return + fi + + if ! tc_offload_check $TC_FLOWER_NUM_NETIFS; then + check_err 1 "Could not test offloaded functionality" + return + fi + + tcflags="skip_sw" + __tc_flower_test $count $should_fail +}