From patchwork Tue Jul 17 15:36:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 10529883 X-Patchwork-Delegate: idosch@idosch.org 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 015D56020A for ; Tue, 17 Jul 2018 15:41:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA7672968A for ; Tue, 17 Jul 2018 15:41:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E89982971E; Tue, 17 Jul 2018 15:41:37 +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=-2.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, MAILING_LIST_MULTI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7FCEA2944F for ; Tue, 17 Jul 2018 15:41:36 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41VPdn4lX3zF3JC for ; Wed, 18 Jul 2018 01:41:33 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=mellanox.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b="KMmgq2JE"; dkim-atps=neutral X-Original-To: linux-mlxsw@lists.ozlabs.org Delivered-To: linux-mlxsw@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=mellanox.com (client-ip=2a01:111:f400:fe07::603; helo=eur02-am5-obe.outbound.protection.outlook.com; envelope-from=idosch@mellanox.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=mellanox.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b="KMmgq2JE"; dkim-atps=neutral Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-am5eur02on0603.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe07::603]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41VPYZ52WKzF3HZ for ; Wed, 18 Jul 2018 01:37:54 +1000 (AEST) 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=6CklzbCJL8Wnk+QJEGI/HvUwFnWnhamO5ENDD38EQe8=; b=KMmgq2JEIIFLrgK+0LFF1Ew6ns2rWLKdZoVZk6m7zT8rejJfE1nGyIDR89uLsKaN5ZDvhRZpPuWjzg+Cr2Q1o71lurimr7Ttt7eDc13cTwxdjMdCw2jeNqrbkBobr5B3yJAwGvekRuKjQ3nM2oG0cgSnsff09TvKNtzo0Bli5Eo= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=idosch@mellanox.com; Received: from splinter.mtl.com (193.47.165.251) by HE1PR0501MB2330.eurprd05.prod.outlook.com (2603:10a6:3:27::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.952.21; Tue, 17 Jul 2018 15:37:43 +0000 From: Ido Schimmel To: linux-internal@mellanox.com Subject: [PATCH RESEND net-next mlxsw 18/18] selftests: mlxsw: Add TC flower test for Spectrum-2 Date: Tue, 17 Jul 2018 18:36:57 +0300 Message-Id: <20180717153657.16324-19-idosch@mellanox.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180717153657.16324-1-idosch@mellanox.com> References: <20180717153657.16324-1-idosch@mellanox.com> MIME-Version: 1.0 X-Originating-IP: [193.47.165.251] X-ClientProxiedBy: AM0PR02CA0020.eurprd02.prod.outlook.com (2603:10a6:208:3e::33) To HE1PR0501MB2330.eurprd05.prod.outlook.com (2603:10a6:3:27::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a8ba6f7c-6ad8-4720-e1d3-08d5ebfb3d3a X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(48565401081)(2017052603328)(7153060)(7193020); SRVR:HE1PR0501MB2330; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2330; 3:aG7vmHFO/+v+X2TCz3vCtszqXwELk21VslFPVXRLB1gENChZvm/v9eJVYUxb7QzP9f7/DZOpoNloTLHtexJHv5ohHPUJRBZN9V6li+rTqAgoM2o3ZKXO5NJK7ni26ajQQHdhzAmhNKkOh7tZg/t1dEiyoPM29u8dQhYCJkWxuX7dKjyp5ffyAazZ1JJ5lec6Z4i3x9wasyVfWOlbUC111F2hSdL9smoh9PLFMskRewwOIf9pk4N20Cd52ZTEcjO6; 25:YplkNBknRV5wxpDfVsPhdOHuEdSLas133suVVDKcCQoMhK7eYHLbn7RxzJWAYr1Jsz8m+jPhL5ElGOHHtRKifgmVnxqPewax9Fg0mZ2GvMOiw949qDiCjLvlDIYUdzD3g/22A/VqshtHNKhmSMeSiqlH1LR8Bzs+I/RMyewSm81RiKYClen4rPntI1/SL5ptfBtpttNVsc81WAxPh1h3qHJuS6s0PFiGeCoUTk7ERKnhqKpQkMkQDmylrzakcn/Kq36842vmjjIbeNR1+SUSv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IAK25ztMTNSZUt2PmXxUEBnIcXRVswJWz7jH8koxeOwR/LJDjkQvoQkB77ipMSdLRpIjqU/VTHg+3Hz4pdnsI1eHRw== 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)(8121501046)(5005006)(3231311)(944501410)(52105095)(93006095)(93001095)(10201501046)(3002001)(6055026)(149027)(150027)(6041310)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:HE1PR0501MB2330; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0501MB2330; X-Forefront-PRVS: 073631BD3D X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(1496009)(396003)(39860400002)(346002)(136003)(376002)(366004)(189003)(199004)(51416003)(2906002)(8676002)(476003)(8936002)(6506007)(956004)(81156014)(2616005)(6486002)(2351001)(26005)(386003)(81166006)(16526019)(107886003)(53416004)(486006)(105586002)(446003)(4326008)(11346002)(34206002)(106356001)(66066001)(53936002)(47776003)(76176011)(68736007)(478600001)(6512007)(316002)(50226002)(50466002)(52116002)(7736002)(2361001)(3846002)(14444005)(16586007)(305945005)(37006003)(97736004)(86362001)(6116002)(36756003)(217873002)(1076002)(48376002)(6636002)(5660300001)(6666003)(25786009)(473944003); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0501MB2330; H:splinter.mtl.com; 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; HE1PR0501MB2330; 23:pFuzI8L2md1fIPqfQQxn2racaDPQ/vFNHXQjM6k?= =?us-ascii?Q?/QO1Qh/3lPlyrwmtMUgPtI1rbbDKux+7RHzu529OTMhH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7iy682iKb5/OSHzopkswTLB7ly/j57Y2Z5b9W?= =?us-ascii?Q?t3zgpQ1DWEMAoOMa7VkhIwwIebky87CeZoqSKotees9E8WuK1MXIddZYAkJt?= =?us-ascii?Q?E0Mv9Z/gpBSR+8QYCHCQ2qMkaqY1Oo12m34PszxNNsfPhCNNQvcf6qfT1RGh?= =?us-ascii?Q?MpT1j10ErBZKCO2iLgGQU9F/QbzPvI2t877+TcRPBR9ifuE4ObhQUS3AQ2Xs?= =?us-ascii?Q?MZUCCOQoS3vIjJfmNemgho/TUfK9DZCxyTbUCZ77A41Z6CwlU1iGwfdhGawo?= =?us-ascii?Q?yBYktT+rfmmWyZb6g5bssEGWq/U+bxxUmASozexUCeZNvXcCbO3m+tKHbpke?= =?us-ascii?Q?eecdEsD89JsClF91TgV+xKZ0MVTf81D+h+OGxDl84PTlCD7eTiGS5Z9o4CYU?= =?us-ascii?Q?102cf0Y2vLTRPpn/+PTAEetTO/TY=3D?= X-Microsoft-Antispam-Message-Info: b4jsBkr2JOkwTt5oA9/RoQfrUi/NpNI9aJgwRZTfJbkhDPK7+Dkad/Vh5Acam7iGuKLOaxaKPrbgear6rPr+6R5YRyl03Z8JwxV5cqJIWExK+BAtiURQxhEjJ59nhb6ZfhoXbE4OR0HcweXy+IMeaYwHz7GJm2a+gkqd/RFkFBJSqDYimzjvGbGPee+RlB6F+KEWD5UrxUObUDBj31iZF2J9eL0RYtkdmqUwwQ0cRhJwlJZqkbnp3pVYXLD6OsfiSKtXrGPeZSIzkIOsOVgPyY5YeIcPzhiqART7q/ZCWI5towEJyzfK8ARGWTL1YukmFkcfiGuodjWfxtPxfuTP5zr/11xRi6L6kxRByTvXaDY= X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2330; 6:aTIq6PZGO/yroDvG20XiOCi1lJLZD7ErvnF+5OIbJvpZFDB9EjsPwLGV5uSw9/SigZfV2ixzVXE84yUOb5yref+bsaSoVZBp0oy883bLHiMoZNur/d+KphD/GQVv9r3YCsCTW9gg4a3+MrQvrS6CweJw5l/fZ97B21fTMMCBgNV1DLCziqM4G9UYOpYg8Zt15WkrKgkKE0/Pvsd9pUMAqudQAijsO2QKfoC+DN19AidW3MHl8mGv8FTQDdTzAE+k5AMFZnYNvFiWiuSVVo9rgucDtzCbMKjSkiNLl8oKQ3XyJJPMLmonjajmZ4R5A+ZqZNW/tN76uanseTS/J3AoQ/skic+q8TLKjihUWomdtdZ8SCDDEHw6VeXrh9rynFaOJlHRp8PO5zOu+3pwSFC7Gcub+htJaj6PG843FVtMhxhXaMl5Gek6BTGVf402PhqJWp7AQ7E323hzMPBpyxGP8w==; 5:yWrM7z8P3QNjdnvaVix0CbOjYTIfMiWjt8hYJL8Iie2a2dr9uynAswevVkpCcHRQ27JGp+1J92GzmfrRf6y6cieq5yeaCK7L0VbLVRwZLRhebetvwqhHaBnqUxclTE1w6A6R4AhQZMf+TMaTPDwIhneWUI0m8R8EAnsckod17rQ=; 24:CXSkBzVeDEOfH9sz80qHlVOq8Jmpg4CwqZhtNK82emVC4/bkhfbMEYaclz7rJAsD2jjFJTBn9/o8xiCe8/DGnPjb80EooNsvtRfSpFGghec= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2330; 7:ew2FOtfb5ocCPUpwKMvZAC1MZd93RSkcukVmwydnzdMIdsAfp471ZBoFIxS9ZtdWs1G0Zl9TUh+syMspDixmI4OuLWfJCwhHuBKLKk8QpPLZEwTdyvr2/66FjdKCjsllpww4CGaeg9QyNLMBFgmJCVOAF7F/I8SNpralVzUXMU8cWjrwuO3M9CZzWC24A8R4TdOFVWPpPFMKTiKGHemuauXtmf3K3tQEzEOC31O8eVWOtQoOdiSXU9IwXQEaGTRZ X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2018 15:37:43.3599 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a8ba6f7c-6ad8-4720-e1d3-08d5ebfb3d3a X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0501MB2330 X-BeenThere: linux-mlxsw@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: mlxsw driver development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-mlxsw-bounces+patchwork-linux-mlxsw=patchwork.kernel.org@lists.ozlabs.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Ido Schimmel --- .../drivers/net/mlxsw/spectrum-2/tc_flower.sh | 366 +++++++++++++++++++++ 1 file changed, 366 insertions(+) create mode 100755 tools/testing/selftests/drivers/net/mlxsw/spectrum-2/tc_flower.sh diff --git a/tools/testing/selftests/drivers/net/mlxsw/spectrum-2/tc_flower.sh b/tools/testing/selftests/drivers/net/mlxsw/spectrum-2/tc_flower.sh new file mode 100755 index 000000000000..a57d2278c3ef --- /dev/null +++ b/tools/testing/selftests/drivers/net/mlxsw/spectrum-2/tc_flower.sh @@ -0,0 +1,366 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# This test is for checking the A-TCAM and C-TCAM operation in Spectrum-2. +# It tries to exercise as many code paths in the eRP state machine as +# possible. + +lib_dir=$(dirname $0)/../../../../net/forwarding + +ALL_TESTS="single_mask_test identical_filters_test two_masks_test \ + multiple_masks_test ctcam_edge_cases_test" +NUM_NETIFS=2 +source $lib_dir/tc_common.sh +source $lib_dir/lib.sh + +tcflags="skip_hw" + +h1_create() +{ + simple_if_init $h1 192.0.2.1/24 198.51.100.1/24 +} + +h1_destroy() +{ + simple_if_fini $h1 192.0.2.1/24 198.51.100.1/24 +} + +h2_create() +{ + simple_if_init $h2 192.0.2.2/24 198.51.100.2/24 + tc qdisc add dev $h2 clsact +} + +h2_destroy() +{ + tc qdisc del dev $h2 clsact + simple_if_fini $h2 192.0.2.2/24 198.51.100.2/24 +} + +single_mask_test() +{ + # When only a single mask is required, the device uses the master + # mask and not the eRP table. Verify that under this mode the right + # filter is matched + + RET=0 + + tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \ + $tcflags dst_ip 192.0.2.2 action drop + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 101 1 + check_err $? "Single filter - did not match" + + tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \ + $tcflags dst_ip 198.51.100.2 action drop + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 101 2 + check_err $? "Two filters - did not match highest priority" + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 198.51.100.1 -B 198.51.100.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 102 1 + check_err $? "Two filters - did not match lowest priority" + + tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 198.51.100.1 -B 198.51.100.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 102 2 + check_err $? "Single filter - did not match after delete" + + tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower + + log_test "single mask test ($tcflags)" +} + +identical_filters_test() +{ + # When two filters that only differ in their priority are used, + # one needs to be inserted into the C-TCAM. This test verifies + # that filters are correctly spilled to C-TCAM and that the right + # filter is matched + + RET=0 + + tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \ + $tcflags dst_ip 192.0.2.2 action drop + tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \ + $tcflags dst_ip 192.0.2.2 action drop + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 101 1 + check_err $? "Did not match A-TCAM filter" + + tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 102 1 + check_err $? "Did not match C-TCAM filter after A-TCAM delete" + + tc filter add dev $h2 ingress protocol ip pref 3 handle 103 flower \ + $tcflags dst_ip 192.0.2.2 action drop + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 102 2 + check_err $? "Did not match C-TCAM filter after A-TCAM add" + + tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 103 1 + check_err $? "Did not match A-TCAM filter after C-TCAM delete" + + tc filter del dev $h2 ingress protocol ip pref 3 handle 103 flower + + log_test "identical filters test ($tcflags)" +} + +two_masks_test() +{ + # When more than one mask is required, the eRP table is used. This + # test verifies that the eRP table is correctly allocated and used + + RET=0 + + tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \ + $tcflags dst_ip 192.0.2.2 action drop + tc filter add dev $h2 ingress protocol ip pref 3 handle 103 flower \ + $tcflags dst_ip 192.0.0.0/16 action drop + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 101 1 + check_err $? "Two filters - did not match highest priority" + + tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 103 1 + check_err $? "Single filter - did not match" + + tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \ + $tcflags dst_ip 192.0.2.0/24 action drop + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 102 1 + check_err $? "Two filters - did not match highest priority after add" + + tc filter del dev $h2 ingress protocol ip pref 3 handle 103 flower + tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower + + log_test "two masks test ($tcflags)" +} + +multiple_masks_test() +{ + # The number of masks in a region is limited. Once the maximum + # number of masks has been reached filters that require new + # masks are spilled to the C-TCAM. This test verifies that + # spillage is performed correctly and that the right filter is + # matched + + local index + + RET=0 + + NUM_MASKS=32 + BASE_INDEX=100 + + for i in $(eval echo {1..$NUM_MASKS}); do + index=$((BASE_INDEX - i)) + + tc filter add dev $h2 ingress protocol ip pref $index \ + handle $index \ + flower $tcflags dst_ip 192.0.2.2/${i} src_ip 192.0.2.1 \ + action drop + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 \ + -B 192.0.2.2 -t ip -q + + tc_check_packets "dev $h2 ingress" $index 1 + check_err $? "$i filters - did not match highest priority (add)" + done + + for i in $(eval echo {$NUM_MASKS..1}); do + index=$((BASE_INDEX - i)) + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 \ + -B 192.0.2.2 -t ip -q + + tc_check_packets "dev $h2 ingress" $index 2 + check_err $? "$i filters - did not match highest priority (del)" + + tc filter del dev $h2 ingress protocol ip pref $index \ + handle $index flower + done + + log_test "multiple masks test ($tcflags)" +} + +ctcam_two_atcam_masks_test() +{ + RET=0 + + # First case: C-TCAM is disabled when there are two A-TCAM masks. + # We push a filter into the C-TCAM by using two identical filters + # as in identical_filters_test() + + # Filter goes into A-TCAM + tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \ + $tcflags dst_ip 192.0.2.2 action drop + # Filter goes into C-TCAM + tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \ + $tcflags dst_ip 192.0.2.2 action drop + # Filter goes into A-TCAM + tc filter add dev $h2 ingress protocol ip pref 3 handle 103 flower \ + $tcflags dst_ip 192.0.2.0/24 action drop + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 101 1 + check_err $? "Did not match A-TCAM filter" + + # Delete both A-TCAM and C-TCAM filters and make sure the remaining + # A-TCAM filter still works + tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower + tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 103 1 + check_err $? "Did not match A-TCAM filter" + + tc filter del dev $h2 ingress protocol ip pref 3 handle 103 flower + + log_test "ctcam with two atcam masks test ($tcflags)" +} + +ctcam_one_atcam_mask_test() +{ + RET=0 + + # Second case: C-TCAM is disabled when there is one A-TCAM mask. + # The test is similar to identical_filters_test() + + # Filter goes into A-TCAM + tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \ + $tcflags dst_ip 192.0.2.2 action drop + # Filter goes into C-TCAM + tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \ + $tcflags dst_ip 192.0.2.2 action drop + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 101 1 + check_err $? "Did not match C-TCAM filter" + + tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower + + $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ + -t ip -q + + tc_check_packets "dev $h2 ingress" 102 1 + check_err $? "Did not match A-TCAM filter" + + tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower + + log_test "ctcam with two atcam masks test ($tcflags)" +} + +ctcam_no_atcam_masks_test() +{ + RET=0 + + # Third case: C-TCAM is disabled when there are no A-TCAM masks + # This test exercises the code path that transitions the eRP table + # to its initial state after deleting the last C-TCAM mask + + # Filter goes into A-TCAM + tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \ + $tcflags dst_ip 192.0.2.2 action drop + # Filter goes into C-TCAM + tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \ + $tcflags dst_ip 192.0.2.2 action drop + + tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower + tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower + + log_test "ctcam with no atcam masks test ($tcflags)" +} + +ctcam_edge_cases_test() +{ + # When the C-TCAM is disabled after deleting the last C-TCAM + # mask, we want to make sure the eRP state machine is put in + # the correct state + + ctcam_two_atcam_masks_test + ctcam_one_atcam_mask_test + ctcam_no_atcam_masks_test +} + +setup_prepare() +{ + h1=${NETIFS[p1]} + h2=${NETIFS[p2]} + h1mac=$(mac_get $h1) + h2mac=$(mac_get $h2) + + vrf_prepare + + h1_create + h2_create +} + +cleanup() +{ + pre_cleanup + + h2_destroy + h1_destroy + + vrf_cleanup +} + +trap cleanup EXIT + +setup_prepare +setup_wait + +tests_run + +if ! tc_offload_check; then + check_err 1 "Could not test offloaded functionality" + log_test "mlxsw-specific tests for tc flower" + exit +else + tcflags="skip_sw" + tests_run +fi + +exit $EXIT_STATUS