From patchwork Fri Jul 27 19:10:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10547629 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3718E180E for ; Fri, 27 Jul 2018 19:10:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 247822C453 for ; Fri, 27 Jul 2018 19:10:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 22BCB2C49B; Fri, 27 Jul 2018 19:10:50 +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 63BFE2C49A for ; Fri, 27 Jul 2018 19:10:49 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41cdpb1N3vzF14j for ; Sat, 28 Jul 2018 05:10:47 +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="VxiTrxi3"; 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=40.107.6.57; helo=eur04-db3-obe.outbound.protection.outlook.com; envelope-from=petrm@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="VxiTrxi3"; dkim-atps=neutral Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60057.outbound.protection.outlook.com [40.107.6.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41cdpS4fLSzF132 for ; Sat, 28 Jul 2018 05:10:40 +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=IvyWojp8J1BofvozELII0bRrW0W1XLodYFAZbdNRFqM=; b=VxiTrxi3Z1Qk8ZVXM1/rLrOS3jfVwJFjLkNHdA9lUoDf8NBUOmqBG1GglM6KR9DbcTayqswHrOy2efx0INaNCBg3N1RftftdUyAXx0Lf+R1wpcnYrwe3VQ3LGwFOgud5Z8n+1diAdWJ4atRuG/gsdH0ZfWjT4fvYjwSxtA1Fkmw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (78.45.160.211) by VI1PR05MB4192.eurprd05.prod.outlook.com (2603:10a6:803:4e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.21; Fri, 27 Jul 2018 19:10:37 +0000 From: Petr Machata To: Subject: [PATCH net-next mlxsw v3 08/10] selftests: forwarding: lib: Add DSCP capture In-Reply-To: References: Message-Id: <7d9b5ce7ae80826de8c48441e5a0a22e8c449c88.1532716714.git.petrm@mellanox.com> Date: Fri, 27 Jul 2018 21:10:33 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 X-Originating-IP: [78.45.160.211] X-ClientProxiedBy: VI1PR04CA0079.eurprd04.prod.outlook.com (2603:10a6:803:64::14) To VI1PR05MB4192.eurprd05.prod.outlook.com (2603:10a6:803:4e::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c2bdedd4-db5e-4206-e897-08d5f3f4a34e X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR05MB4192; X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4192; 3:ijl5Lj65xl+4ryyapH/izVBpjWXGxVV9xU2h/2cHreaCos4MXH7rMy4Tdovv5R9SDZAFK5CmC/GXS1H7mmL2/JE4+LtU/acZvrCUmLdv57HkVoxP4mpUEICOkNfo1wnrTFFjx+sokcPvsnu9+J/vohNL/xxtk8cGAmEDUv59wColxTuMjX2Dyuv49XrG/gXv5sZWC1TmsHO1EUM/5+TwqoQtB4DyueMoIeV/BqgYATKV5aJP1T0pQDsiiqGaNT4j; 25:00CLTAzelgIsX9PQmE5Y+06m/E5nZwiDDOi+JQrARZ+8qsKIiPlEUDFcR+hpnApB7YmkSUnV12sBhoZLPBGwT6BpmJyDD8kMKDVKGh3xooU50iP8PK3nFeAj9XI0+0sm+RRmgCCzkenPkh1FI7zrtVOiA/Opdp56zEIa0WZ/Es8LlVEzH1U75/s7jfKJRQQRrIeY9OwbGX6PyKQZ4auZ3ywZ6kE7Hi6fVKWYrRsjD/CsH5PJLguhQpCnfohlWBim8y9sVkdHtYL+fcn8QNwE9lIV99k1SHJPkZU0szLPmSawQG8mGB7W5mQRy42EECQvFvQ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5LsTBKl7RyB9tXqCWBVdQVr9LzMpfBw1UEJU4XcntrUeGTV2wnao+7d/3KA== 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)(93006095)(93001095)(3002001)(3231311)(944501410)(52105095)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:VI1PR05MB4192; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB4192; X-Forefront-PRVS: 07467C4D33 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(346002)(136003)(366004)(376002)(39860400002)(189003)(199004)(6862004)(105586002)(316002)(66066001)(2616005)(14444005)(52116002)(118296001)(106356001)(47776003)(2351001)(51416003)(478600001)(186003)(486006)(956004)(476003)(11346002)(386003)(53936002)(25786009)(16526019)(446003)(97736004)(6666003)(8936002)(6496006)(81166006)(6486002)(81156014)(76176011)(6636002)(8676002)(48376002)(37006003)(50466002)(36756003)(16586007)(86362001)(58126008)(68736007)(26005)(305945005)(6116002)(5660300001)(3846002)(7736002)(2906002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB4192; 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; VI1PR05MB4192; 23:L80GMB0br/y+S/3hcE7UfxXuP7J6vQjXSOgaKubSK?= 3kBlFOhofS3baGmmzh410VwmCU2vaqGdHI1YlnbF+5M0HE0Lc2/vZrqA8LTqDHjQq/py/Ih2aecmDhWhJ/zKHDSxd6dCsxtN/qehfPj00i+t2Zrg6Z1UjB1kqOLgrtIbq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6krUKad7CB01DJhLCX5VKglvCqSnWlA3MvC+vvVu5zF/VRzyxxKGUaYfIYP/ArdTF/aM304CL0h8V94qdaejmNBLsEHK4mKTA6rUe1lqmofKumgK0f8oy+YxSE/wi1e4xcISuVBMtScGItOunSu+yIcHvgm8FD7duQBD37Enbx+iH4BOXOF0zWLtm+CVGdMkiy/q4hsHQQkSa92Wg2DWItSvSxBnwCCcYL SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2018 19:10:37.9283 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c2bdedd4-db5e-4206-e897-08d5f3f4a34e X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB4192 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 DSCP captures are TC rules intended to notice packets with a given DSCP value. Add dscp_capture_install(), dscp_capture_uninstall() and their helper along the lines of ICMP and VLAN captures already present in lib.sh. Complementary to the install and uninstall functions is a function to collect the capture stats: dscp_fetch_stats(). Signed-off-by: Petr Machata --- tools/testing/selftests/net/forwarding/lib.sh | 42 +++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index 158d59ffee40..d396f89d864d 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -605,6 +605,48 @@ vlan_capture_uninstall() __vlan_capture_add_del del 100 "$@" } +__dscp_capture_add_del() +{ + local add_del=$1; shift + local dev=$1; shift + local base=$1; shift + local dscp; + + for prio in {0..7}; do + dscp=$((base + prio)) + __icmp_capture_add_del $add_del $((dscp + 100)) "" $dev \ + "skip_hw ip_tos $((dscp << 2))" + done +} + +dscp_capture_install() +{ + local dev=$1; shift + local base=$1; shift + + __dscp_capture_add_del add $dev $base +} + +dscp_capture_uninstall() +{ + local dev=$1; shift + local base=$1; shift + + __dscp_capture_add_del del $dev $base +} + +dscp_fetch_stats() +{ + local dev=$1; shift + local base=$1; shift + + for prio in {0..7}; do + local dscp=$((base + prio)) + local t=$(tc_rule_stats_get $dev $((dscp + 100))) + echo "[$dscp]=$t " + done +} + matchall_sink_create() { local dev=$1; shift