From patchwork Mon Mar 2 17:56:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 1247784 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=pmachata.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=pmachata.org header.i=@pmachata.org header.a=rsa-sha256 header.s=MBO0001 header.b=xp63USG+; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 48WShP2br9z9sR4 for ; Tue, 3 Mar 2020 05:04:21 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727450AbgCBSEP (ORCPT ); Mon, 2 Mar 2020 13:04:15 -0500 Received: from mout-u-204.mailbox.org ([91.198.250.253]:65444 "EHLO mout-u-204.mailbox.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726451AbgCBSEO (ORCPT ); Mon, 2 Mar 2020 13:04:14 -0500 Received: from mout-u-107.mailbox.org (mout-u-107.mailbox.org [91.198.250.252]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 48WSXX2hP6zQlFj; Mon, 2 Mar 2020 18:57:32 +0100 (CET) Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-u-107.mailbox.org (Postfix) with ESMTPS id 48WSXX27VWzKmkd; Mon, 2 Mar 2020 18:57:32 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pmachata.org; s=MBO0001; t=1583171850; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EFNTj2brS+Suz58LeVaHlX6Fl9PpRMaDjJlJxRijkYk=; b=xp63USG+5hKY8Y+gpBOPGHYASY+r+fjo7cJpEvl+kLDkLNw1xUjcVFy1STnKF8jsKEcVvS Aq/zmOQiPGwswOFLJeU6EA36lik0V2HX8sbQbSMky8doyaDZZpR6zT0ZhoZ/VIGFjMk+WN 7QYEulr4TfyBM6XDofoPCGvoUXLMpN326bUWv7OCP/q2zu92GjllmmWd3uvK1oP1p5CvhF pFCuVaXwC61rnn1+7l73U9rzyVtirAmmw63hwnoIaYHTFolBSdO+rKuCidmMdduo3PBmZP N6x+ivrHdEmH2/LIXIZ3pzyqd27J4M9jbbKpHLmh2ccnnuQLzzQDUwL3ffr/cg== Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter03.heinlein-hosting.de (spamfilter03.heinlein-hosting.de [80.241.56.117]) (amavisd-new, port 10030) with ESMTP id 3hKnbCX2WzJd; Mon, 2 Mar 2020 18:57:29 +0100 (CET) From: Petr Machata To: netdev@vger.kernel.org Cc: Ido Schimmel , Petr Machata , David Miller , Amit Cohen Subject: [PATCH net-next 2/4] selftests: forwarding: Convert until_counter_is() to take expression Date: Mon, 2 Mar 2020 19:56:03 +0200 Message-Id: <6b4f73d1ec3d11920c5beed8eec7289c74eb66b2.1583170249.git.petrm@mellanox.com> In-Reply-To: References: MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Petr Machata until_counter_is() currently takes as an argument a number and the condition holds when the current counter value is >= that number. Make the function more generic by taking a partial expression instead of just the number. Convert the two existing users. Signed-off-by: Petr Machata Reviewed-by: Amit Cohen --- tools/testing/selftests/drivers/net/mlxsw/sch_red_core.sh | 6 +++--- tools/testing/selftests/net/forwarding/lib.sh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/drivers/net/mlxsw/sch_red_core.sh b/tools/testing/selftests/drivers/net/mlxsw/sch_red_core.sh index ebf7752f6d93..8f833678ac4d 100644 --- a/tools/testing/selftests/drivers/net/mlxsw/sch_red_core.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/sch_red_core.sh @@ -351,7 +351,7 @@ build_backlog() local i=0 while :; do - local cur=$(busywait 1100 until_counter_is $((cur + 1)) \ + local cur=$(busywait 1100 until_counter_is "> $cur" \ get_qdisc_backlog $vlan) local diff=$((size - cur)) local pkts=$(((diff + 7999) / 8000)) @@ -481,14 +481,14 @@ do_mc_backlog_test() start_tcp_traffic $h1.$vlan $(ipaddr 1 $vlan) $(ipaddr 3 $vlan) bc start_tcp_traffic $h2.$vlan $(ipaddr 2 $vlan) $(ipaddr 3 $vlan) bc - qbl=$(busywait 5000 until_counter_is 500000 \ + qbl=$(busywait 5000 until_counter_is ">= 500000" \ get_qdisc_backlog $vlan) check_err $? "Could not build MC backlog" # Verify that we actually see the backlog on BUM TC. Do a busywait as # well, performance blips might cause false fail. local ebl - ebl=$(busywait 5000 until_counter_is 500000 \ + ebl=$(busywait 5000 until_counter_is ">= 500000" \ get_mc_transmit_queue $vlan) check_err $? "MC backlog reported by qdisc not visible in ethtool" diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index de57e8887a7c..7ecce65d08f9 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -277,11 +277,11 @@ wait_for_offload() until_counter_is() { - local value=$1; shift + local expr=$1; shift local current=$("$@") echo $((current)) - ((current >= value)) + ((current $expr)) } busywait_for_counter() @@ -290,7 +290,7 @@ busywait_for_counter() local delta=$1; shift local base=$("$@") - busywait "$timeout" until_counter_is $((base + delta)) "$@" + busywait "$timeout" until_counter_is ">= $((base + delta))" "$@" } setup_wait_dev() From patchwork Mon Mar 2 17:56:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 1247782 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=pmachata.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=pmachata.org header.i=@pmachata.org header.a=rsa-sha256 header.s=MBO0001 header.b=Qz6/hJ5v; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 48WShN3h3Pz9sQt for ; Tue, 3 Mar 2020 05:04:20 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727465AbgCBSEP (ORCPT ); Mon, 2 Mar 2020 13:04:15 -0500 Received: from mout-u-204.mailbox.org ([91.198.250.253]:65448 "EHLO mout-u-204.mailbox.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727250AbgCBSEO (ORCPT ); Mon, 2 Mar 2020 13:04:14 -0500 Received: from mout-u-107.mailbox.org (mout-u-107.mailbox.org [91.198.250.252]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 48WSXY245JzQlFk; Mon, 2 Mar 2020 18:57:33 +0100 (CET) Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-u-107.mailbox.org (Postfix) with ESMTPS id 48WSXY1ZG2zKmkd; Mon, 2 Mar 2020 18:57:33 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pmachata.org; s=MBO0001; t=1583171851; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ly331UmSRuFnyUT3f5xDX0sIPjxf59acPiLjIQfcUxA=; b=Qz6/hJ5v1x+ifhPUVdxgW5OtYqt6zn8MmDUeNHtyeUWbWe6bn87j51ZkvU5S/4sR3YRg3P HOROTcbYhC0GIbcatY1l7d0cvwrpMOjALcQXUnC5bpUWU+URn2KcjK5gf9cQbEKvOxxg6y cVOTdbQnRB62bEg/qdhD/3LpODA0sk0LrfwJ81rK6CLHkI5LqMknbiu1Z7IvZ0Jlg+1QcW V0qJHaenHyPBtGT4RL9GERvQYHeVehO0FxIby1hIZEJNgyd5fGBnuwL1KjTKZR4bbZJVrv 38dvsHtV4amss88WXs0UCr81WuhgrmFaPbvSIxKUanveS1AIopPTm8PFEf8mmA== Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.115]) (amavisd-new, port 10030) with ESMTP id EwO27NcyP0Oy; Mon, 2 Mar 2020 18:57:30 +0100 (CET) From: Petr Machata To: netdev@vger.kernel.org Cc: Ido Schimmel , Petr Machata , David Miller , Amit Cohen Subject: [PATCH net-next 3/4] selftests: forwarding: tc_common: Convert to use busywait Date: Mon, 2 Mar 2020 19:56:04 +0200 Message-Id: <69173a424aefde8eaef0f25aaf5c7c17790fc384.1583170249.git.petrm@mellanox.com> In-Reply-To: References: MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Petr Machata A function busywait() was recently added based on the logic in __tc_check_packets(). Convert the code in tc_common to use the new function. Signed-off-by: Petr Machata Reviewed-by: Amit Cohen --- .../selftests/net/forwarding/tc_common.sh | 32 +++---------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/tools/testing/selftests/net/forwarding/tc_common.sh b/tools/testing/selftests/net/forwarding/tc_common.sh index 64f652633585..0e18e8be6e2a 100644 --- a/tools/testing/selftests/net/forwarding/tc_common.sh +++ b/tools/testing/selftests/net/forwarding/tc_common.sh @@ -6,39 +6,14 @@ CHECK_TC="yes" # Can be overridden by the configuration file. See lib.sh TC_HIT_TIMEOUT=${TC_HIT_TIMEOUT:=1000} # ms -__tc_check_packets() -{ - local id=$1 - local handle=$2 - local count=$3 - local operator=$4 - - start_time="$(date -u +%s%3N)" - while true - do - cmd_jq "tc -j -s filter show $id" \ - ".[] | select(.options.handle == $handle) | \ - select(.options.actions[0].stats.packets $operator $count)" \ - &> /dev/null - ret=$? - if [[ $ret -eq 0 ]]; then - return $ret - fi - current_time="$(date -u +%s%3N)" - diff=$(expr $current_time - $start_time) - if [ "$diff" -gt "$TC_HIT_TIMEOUT" ]; then - return 1 - fi - done -} - tc_check_packets() { local id=$1 local handle=$2 local count=$3 - __tc_check_packets "$id" "$handle" "$count" "==" + busywait "$TC_HIT_TIMEOUT" until_counter_is "== $count" \ + tc_rule_handle_stats_get "$id" "$handle" > /dev/null } tc_check_packets_hitting() @@ -46,5 +21,6 @@ tc_check_packets_hitting() local id=$1 local handle=$2 - __tc_check_packets "$id" "$handle" 0 ">" + busywait "$TC_HIT_TIMEOUT" until_counter_is "> 0" \ + tc_rule_handle_stats_get "$id" "$handle" > /dev/null } From patchwork Mon Mar 2 17:56:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 1247779 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=pmachata.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=pmachata.org header.i=@pmachata.org header.a=rsa-sha256 header.s=MBO0001 header.b=o6xtyhOz; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 48WShH2ZnYz9sR4 for ; Tue, 3 Mar 2020 05:04:15 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727413AbgCBSEN (ORCPT ); Mon, 2 Mar 2020 13:04:13 -0500 Received: from mout-u-204.mailbox.org ([91.198.250.253]:65440 "EHLO mout-u-204.mailbox.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727196AbgCBSEN (ORCPT ); Mon, 2 Mar 2020 13:04:13 -0500 X-Greylist: delayed 402 seconds by postgrey-1.27 at vger.kernel.org; Mon, 02 Mar 2020 13:04:13 EST Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 48WSXZ0LGZzQlFm; Mon, 2 Mar 2020 18:57:34 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pmachata.org; s=MBO0001; t=1583171852; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gsM2JDR0/ipFVoiT0YeWl2IsNHIZLZXIv1ndATcIGmE=; b=o6xtyhOzZcI7S5AvBHzXOmXvt7oDqpXMvwGyx21kAbVaDSBOQASDrUDZDY2Vkkcs2iGGhR 3bd0hrCOUVlWvjzLK/2UHIWvLrM979yiq4tgNbKUMvVEA3IoDyCXAoADZrM0rCNmfSuGQ9 isNKfVFfVxZ+DFwLUrUm+MVBFiHSTdtKdN6WHWFSplEfE+naB9hN9LTihvLT5vUh8oDygw qodJiI3ZFpXYc0KzObaHFCXhHTchudAW1cuk8st8qXTiRTXRGPwkxi0y9ad78eMxM7fLD2 7hE5a9c7/Pl5+bLoME0qrqEW5Dhp87TJXBh7ZWUPba1Ks9gmwBIVRDyRJnRBaA== Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter03.heinlein-hosting.de (spamfilter03.heinlein-hosting.de [80.241.56.117]) (amavisd-new, port 10030) with ESMTP id qIo7RDY_wgjy; Mon, 2 Mar 2020 18:57:31 +0100 (CET) From: Petr Machata To: netdev@vger.kernel.org Cc: Ido Schimmel , Petr Machata , David Miller , Amit Cohen Subject: [PATCH net-next 4/4] selftests: mlxsw: qos_defprio: Use until_counter_is Date: Mon, 2 Mar 2020 19:56:05 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Petr Machata Instead of hand-coding the busywait() predicate, use the until_counter_is() introduced recently. Signed-off-by: Petr Machata Reviewed-by: Amit Cohen --- .../selftests/drivers/net/mlxsw/qos_defprio.sh | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests/drivers/net/mlxsw/qos_defprio.sh b/tools/testing/selftests/drivers/net/mlxsw/qos_defprio.sh index eff6393ce974..71066bc4b886 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/qos_defprio.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/qos_defprio.sh @@ -114,23 +114,12 @@ ping_ipv4() ping_test $h1 192.0.2.2 } -wait_for_packets() -{ - local t0=$1; shift - local prio_observe=$1; shift - - local t1=$(ethtool_stats_get $swp1 rx_frames_prio_$prio_observe) - local delta=$((t1 - t0)) - echo $delta - ((delta >= 10)) -} - __test_defprio() { local prio_install=$1; shift local prio_observe=$1; shift - local delta local key + local t1 local i RET=0 @@ -139,9 +128,10 @@ __test_defprio() local t0=$(ethtool_stats_get $swp1 rx_frames_prio_$prio_observe) mausezahn -q $h1 -d 100m -c 10 -t arp reply - delta=$(busywait "$HIT_TIMEOUT" wait_for_packets $t0 $prio_observe) + t1=$(busywait "$HIT_TIMEOUT" until_counter_is ">= $((t0 + 10))" \ + ethtool_stats_get $swp1 rx_frames_prio_$prio_observe) - check_err $? "Default priority $prio_install/$prio_observe: Expected to capture 10 packets, got $delta." + check_err $? "Default priority $prio_install/$prio_observe: Expected to capture 10 packets, got $((t1 - t0))." log_test "Default priority $prio_install/$prio_observe" defprio_uninstall $swp1 $prio_install