From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,LOTS_OF_MONEY, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D97BC4360F for ; Thu, 28 Mar 2019 12:12:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 63E26217D7 for ; Thu, 28 Mar 2019 12:12:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=Mellanox.com header.i=@Mellanox.com header.b="ie/l3cPt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726555AbfC1MMe (ORCPT ); Thu, 28 Mar 2019 08:12:34 -0400 Received: from mail-eopbgr80057.outbound.protection.outlook.com ([40.107.8.57]:55059 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726381AbfC1MMd (ORCPT ); Thu, 28 Mar 2019 08:12:33 -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=e0i+P+kIyqk8wUH9+b1KY0KkzFsOH0rX9tQ5Xl80nqo=; b=ie/l3cPtPtdxinzS1oLpc2KtanIolPPppNPIhEhDAjnFD9sM7WmKLBG4ekgTs0BHkiznkr/RLvbkTC/FFkw/4R3ti481V/dGnmGv/K5sok9UCO5IP5lhuhsXurH08b82gYAN8QestZnCa9EhAwfrLFS1dOhBigB+5jh98EQQLCA= Received: from AM0PR05MB6100.eurprd05.prod.outlook.com (20.178.119.209) by AM0PR05MB4307.eurprd05.prod.outlook.com (52.134.91.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1750.17; Thu, 28 Mar 2019 12:12:27 +0000 Received: from AM0PR05MB6100.eurprd05.prod.outlook.com ([fe80::85ee:723:721e:51f9]) by AM0PR05MB6100.eurprd05.prod.outlook.com ([fe80::85ee:723:721e:51f9%4]) with mapi id 15.20.1730.019; Thu, 28 Mar 2019 12:12:27 +0000 From: Ido Schimmel To: "netdev@vger.kernel.org" CC: "davem@davemloft.net" , mlxsw , Petr Machata , Ido Schimmel Subject: [PATCH net-next 8/9] selftests: mlxsw: Add qos_lib.sh Thread-Topic: [PATCH net-next 8/9] selftests: mlxsw: Add qos_lib.sh Thread-Index: AQHU5V+CCzrwTsLQ0kK+0/J4oCH7UQ== Date: Thu, 28 Mar 2019 12:12:26 +0000 Message-ID: <20190328121144.22911-9-idosch@mellanox.com> References: <20190328121144.22911-1-idosch@mellanox.com> In-Reply-To: <20190328121144.22911-1-idosch@mellanox.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: LO2P265CA0425.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a0::29) To AM0PR05MB6100.eurprd05.prod.outlook.com (2603:10a6:208:12e::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=idosch@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e5fbd907-3dd5-4c8f-abd7-08d6b376a452 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020);SRVR:AM0PR05MB4307; x-ms-traffictypediagnostic: AM0PR05MB4307: x-microsoft-antispam-prvs: x-forefront-prvs: 0990C54589 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(366004)(346002)(376002)(136003)(39860400002)(396003)(189003)(199004)(26005)(6506007)(11346002)(386003)(2616005)(446003)(186003)(68736007)(4326008)(52116002)(102836004)(6436002)(66066001)(99286004)(14454004)(2906002)(86362001)(107886003)(53936002)(6916009)(1076003)(71200400001)(71190400001)(76176011)(476003)(486006)(5660300002)(14444005)(256004)(25786009)(8676002)(2501003)(81166006)(1730700003)(36756003)(81156014)(3846002)(6512007)(316002)(50226002)(106356001)(5640700003)(105586002)(54906003)(2351001)(8936002)(305945005)(97736004)(6116002)(478600001)(7736002)(6486002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR05MB4307;H:AM0PR05MB6100.eurprd05.prod.outlook.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-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: lcH8FuMmOaRT2EEgFj/qHjeSXa4mlUi4zZsHXxqiMdeeHm+VFay9LdIwOGTPyPDKfpk/Tj/QppS6igdlb2oYtvTKIf+JDe/N49XgJqhQCQ0jjZQkp5fqDLnFgaUYpZncZaXXxntG7guboMuaZfU7nPYcLfDwxSGy3HSuqgccxEY784Py81Gb4OFDBOIIah6gIV8DBVoJeNsfPUfxThvDKkZXmYu2t/n+BVkwx5JmMEikVACaQlfFqQxuOBGQ5OHn6hqFe7H9eKX8gc1iL+b5tG/lAJWRCNEdrvGib0kh2znzLlg6TWDZjcLvSxmn9WMSFgYWcHIpph5uaNJHtvFMdn8aE3+FTYiQqYPu/TdyeuqFHCK8+9S58eIhKCtY7r3s4pdZ+bXha5VRodM/iYE+2uMyDfp3BUn9n0b+Pe5J824= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: e5fbd907-3dd5-4c8f-abd7-08d6b376a452 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Mar 2019 12:12:26.8481 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB4307 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Petr Machata Extract reusable code from qos_mc_aware.sh and put into a new library. Signed-off-by: Petr Machata Signed-off-by: Ido Schimmel --- .../selftests/drivers/net/mlxsw/qos_lib.sh | 98 +++++++++++++++++ .../drivers/net/mlxsw/qos_mc_aware.sh | 103 ++---------------- 2 files changed, 109 insertions(+), 92 deletions(-) create mode 100644 tools/testing/selftests/drivers/net/mlxsw/qos_lib.sh diff --git a/tools/testing/selftests/drivers/net/mlxsw/qos_lib.sh b/tools/t= esting/selftests/drivers/net/mlxsw/qos_lib.sh new file mode 100644 index 000000000000..e80be65799ad --- /dev/null +++ b/tools/testing/selftests/drivers/net/mlxsw/qos_lib.sh @@ -0,0 +1,98 @@ +# SPDX-License-Identifier: GPL-2.0 + +humanize() +{ + local speed=3D$1; shift + + for unit in bps Kbps Mbps Gbps; do + if (($(echo "$speed < 1024" | bc))); then + break + fi + + speed=3D$(echo "scale=3D1; $speed / 1024" | bc) + done + + echo "$speed${unit}" +} + +rate() +{ + local t0=3D$1; shift + local t1=3D$1; shift + local interval=3D$1; shift + + echo $((8 * (t1 - t0) / interval)) +} + +start_traffic() +{ + local h_in=3D$1; shift # Where the traffic egresses the host + local sip=3D$1; shift + local dip=3D$1; shift + local dmac=3D$1; shift + + $MZ $h_in -p 8000 -A $sip -B $dip -c 0 \ + -a own -b $dmac -t udp -q & + sleep 1 +} + +stop_traffic() +{ + # Suppress noise from killing mausezahn. + { kill %% && wait %%; } 2>/dev/null +} + +check_rate() +{ + local rate=3D$1; shift + local min=3D$1; shift + local what=3D$1; shift + + if ((rate > min)); then + return 0 + fi + + echo "$what $(humanize $ir) < $(humanize $min)" > /dev/stderr + return 1 +} + +measure_rate() +{ + local sw_in=3D$1; shift # Where the traffic ingresses the switch + local host_in=3D$1; shift # Where it ingresses another host + local counter=3D$1; shift # Counter to use for measurement + local what=3D$1; shift + + local interval=3D10 + local i + local ret=3D0 + + # Dips in performance might cause momentary ingress rate to drop below + # 1Gbps. That wouldn't saturate egress and MC would thus get through, + # seemingly winning bandwidth on account of UC. Demand at least 2Gbps + # average ingress rate to somewhat mitigate this. + local min_ingress=3D2147483648 + + for i in {5..0}; do + local t0=3D$(ethtool_stats_get $host_in $counter) + local u0=3D$(ethtool_stats_get $sw_in $counter) + sleep $interval + local t1=3D$(ethtool_stats_get $host_in $counter) + local u1=3D$(ethtool_stats_get $sw_in $counter) + + local ir=3D$(rate $u0 $u1 $interval) + local er=3D$(rate $t0 $t1 $interval) + + if check_rate $ir $min_ingress "$what ingress rate"; then + break + fi + + # Fail the test if we can't get the throughput. + if ((i =3D=3D 0)); then + ret=3D1 + fi + done + + echo $ir $er + return $ret +} diff --git a/tools/testing/selftests/drivers/net/mlxsw/qos_mc_aware.sh b/to= ols/testing/selftests/drivers/net/mlxsw/qos_mc_aware.sh index 2e17fe3b4872..71231ad2dbfb 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/qos_mc_aware.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/qos_mc_aware.sh @@ -68,6 +68,7 @@ lib_dir=3D$(dirname $0)/../../../net/forwarding NUM_NETIFS=3D6 source $lib_dir/lib.sh source $lib_dir/devlink_lib.sh +source qos_lib.sh =20 h1_create() { @@ -220,107 +221,28 @@ ping_ipv4() ping_test $h2 192.0.2.130 } =20 -humanize() -{ - local speed=3D$1; shift - - for unit in bps Kbps Mbps Gbps; do - if (($(echo "$speed < 1024" | bc))); then - break - fi - - speed=3D$(echo "scale=3D1; $speed / 1024" | bc) - done - - echo "$speed${unit}" -} - -rate() -{ - local t0=3D$1; shift - local t1=3D$1; shift - local interval=3D$1; shift - - echo $((8 * (t1 - t0) / interval)) -} - -check_rate() -{ - local rate=3D$1; shift - local min=3D$1; shift - local what=3D$1; shift - - if ((rate > min)); then - return 0 - fi - - echo "$what $(humanize $ir) < $(humanize $min_ingress)" > /dev/stderr - return 1 -} - -measure_uc_rate() -{ - local what=3D$1; shift - - local interval=3D10 - local i - local ret=3D0 - - # Dips in performance might cause momentary ingress rate to drop below - # 1Gbps. That wouldn't saturate egress and MC would thus get through, - # seemingly winning bandwidth on account of UC. Demand at least 2Gbps - # average ingress rate to somewhat mitigate this. - local min_ingress=3D2147483648 - - $MZ $h2.111 -p 8000 -A 192.0.2.129 -B 192.0.2.130 -c 0 \ - -a own -b $h3mac -t udp -q & - sleep 1 - - for i in {5..0}; do - local t0=3D$(ethtool_stats_get $h3 rx_octets_prio_1) - local u0=3D$(ethtool_stats_get $swp2 rx_octets_prio_1) - sleep $interval - local t1=3D$(ethtool_stats_get $h3 rx_octets_prio_1) - local u1=3D$(ethtool_stats_get $swp2 rx_octets_prio_1) - - local ir=3D$(rate $u0 $u1 $interval) - local er=3D$(rate $t0 $t1 $interval) - - if check_rate $ir $min_ingress "$what ingress rate"; then - break - fi - - # Fail the test if we can't get the throughput. - if ((i =3D=3D 0)); then - ret=3D1 - fi - done - - # Suppress noise from killing mausezahn. - { kill %% && wait; } 2>/dev/null - - echo $ir $er - exit $ret -} - test_mc_aware() { RET=3D0 =20 local -a uc_rate - uc_rate=3D($(measure_uc_rate "UC-only")) + start_traffic $h2.111 192.0.2.129 192.0.2.130 $h3mac + uc_rate=3D($(measure_rate $swp2 $h3 rx_octets_prio_1 "UC-only")) check_err $? "Could not get high enough UC-only ingress rate" + stop_traffic local ucth1=3D${uc_rate[1]} =20 - $MZ $h1 -p 8000 -c 0 -a own -b bc -t udp -q & + start_traffic $h1 own bc bc =20 local d0=3D$(date +%s) local t0=3D$(ethtool_stats_get $h3 rx_octets_prio_0) local u0=3D$(ethtool_stats_get $swp1 rx_octets_prio_0) =20 local -a uc_rate_2 - uc_rate_2=3D($(measure_uc_rate "UC+MC")) + start_traffic $h2.111 192.0.2.129 192.0.2.130 $h3mac + uc_rate_2=3D($(measure_rate $swp2 $h3 rx_octets_prio_1 "UC+MC")) check_err $? "Could not get high enough UC+MC ingress rate" + stop_traffic local ucth2=3D${uc_rate_2[1]} =20 local d1=3D$(date +%s) @@ -338,8 +260,7 @@ test_mc_aware() local mc_ir=3D$(rate $u0 $u1 $interval) local mc_er=3D$(rate $t0 $t1 $interval) =20 - # Suppress noise from killing mausezahn. - { kill %% && wait; } 2>/dev/null + stop_traffic =20 log_test "UC performace under MC overload" =20 @@ -363,8 +284,7 @@ test_uc_aware() { RET=3D0 =20 - $MZ $h2.111 -p 8000 -A 192.0.2.129 -B 192.0.2.130 -c 0 \ - -a own -b $h3mac -t udp -q & + start_traffic $h2.111 192.0.2.129 192.0.2.130 $h3mac =20 local d0=3D$(date +%s) local t0=3D$(ethtool_stats_get $h3 rx_octets_prio_1) @@ -394,8 +314,7 @@ test_uc_aware() ((attempts =3D=3D passes)) check_err $? =20 - # Suppress noise from killing mausezahn. - { kill %% && wait; } 2>/dev/null + stop_traffic =20 log_test "MC performace under UC overload" echo " ingress UC throughput $(humanize ${uc_ir})" --=20 2.20.1