From patchwork Sat Feb 6 12:55:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parav Pandit X-Patchwork-Id: 12072137 X-Patchwork-Delegate: kuba@kernel.org 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=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,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 371C9C433DB for ; Sat, 6 Feb 2021 12:58:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0189F64E36 for ; Sat, 6 Feb 2021 12:58:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230048AbhBFM57 (ORCPT ); Sat, 6 Feb 2021 07:57:59 -0500 Received: from hqnvemgate25.nvidia.com ([216.228.121.64]:8389 "EHLO hqnvemgate25.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230073AbhBFM5c (ORCPT ); Sat, 6 Feb 2021 07:57:32 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Sat, 06 Feb 2021 04:56:09 -0800 Received: from sw-mtx-036.mtx.labs.mlnx (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Sat, 6 Feb 2021 12:56:08 +0000 From: Parav Pandit To: , , CC: Parav Pandit Subject: [PATCH net-next 7/7] netdevsim: Add netdevsim port add test cases Date: Sat, 6 Feb 2021 14:55:51 +0200 Message-ID: <20210206125551.8616-8-parav@nvidia.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210206125551.8616-1-parav@nvidia.com> References: <20210206125551.8616-1-parav@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1612616169; bh=VvZLdEd022MJbdQm/lm5+cnNbRNFIM4w4Qy/Fevf7rg=; h=From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:Content-Type: X-Originating-IP:X-ClientProxiedBy; b=reXVV+XrvNotyWr4OHsmUBRlNxGfRrNIss/kC0Uh+5Objj+LbQVvbT/tNzOH0jzro PiBJhlkSdC7xoXa4FF6Z7KtWt2zjyvokl8MqOdrrWJh0/gKW+Gd6+dgpgq/+kUECPy LiqHmY2+wxT18A6YkPFS9YrnJzyrF60B2uAlytT89MLnP9OJgporcA8eYt1kVweMnp /1XoD8PyO2rPoPf+H0wX360Ymwd80jXn7diq0EZTfmMsWO3DA5p8ioXhRTHYtdtIOV lseGKwI6AqkiEz8QQxy82kepFT9dSu+Qm61lvwYCgQrrAIimtjPYuOa5aL/VoRmQdt gOeuUacGS9pbg== Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Add tests for PCI PF and SF port add, configure and delete using user specified port index and sfumber; and also using auto generated port index. Signed-off-by: Parav Pandit --- .../drivers/net/netdevsim/devlink.sh | 72 ++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/drivers/net/netdevsim/devlink.sh b/tools/testing/selftests/drivers/net/netdevsim/devlink.sh index 40909c254365..ba349909a37e 100755 --- a/tools/testing/selftests/drivers/net/netdevsim/devlink.sh +++ b/tools/testing/selftests/drivers/net/netdevsim/devlink.sh @@ -5,7 +5,7 @@ lib_dir=$(dirname $0)/../../../net/forwarding ALL_TESTS="fw_flash_test params_test regions_test reload_test \ netns_reload_test resource_test dev_info_test \ - empty_reporter_test dummy_reporter_test" + empty_reporter_test dummy_reporter_test devlink_port_add_test" NUM_NETIFS=0 source $lib_dir/lib.sh @@ -507,6 +507,76 @@ dummy_reporter_test() log_test "dummy reporter test" } +function_state_get() +{ + local name=$1 + + cmd_jq "devlink port show $DL_HANDLE/$USR_SF_PORT_INDEX -j" \ + " .[][].function.$1" +} + +devlink_port_add_test() +{ + RET=0 + USR_PF_PORT_INDEX=600 + USR_PFNUM_A=2 + USR_PFNUM_B=3 + USR_SF_PORT_INDEX=601 + USR_SFNUM_A=44 + USR_SFNUM_B=55 + + devlink port add $DL_HANDLE flavour pcipf pfnum $USR_PFNUM_A + check_err $? "Failed PF port addition" + + devlink port show + check_err $? "Failed PF port show" + + devlink port add $DL_HANDLE flavour pcisf pfnum $USR_PFNUM_A + check_err $? "Failed SF port addition" + + devlink port add $DL_HANDLE flavour pcisf pfnum $USR_PFNUM_A \ + sfnum $USR_SFNUM_A + check_err $? "Failed SF port addition" + + devlink port add $DL_HANDLE flavour pcipf pfnum $USR_PFNUM_B + check_err $? "Failed second PF port addition" + + devlink port add $DL_HANDLE/$USR_SF_PORT_INDEX flavour pcisf \ + pfnum $USR_PFNUM_B sfnum $USR_SFNUM_B + check_err $? "Failed SF port addition" + + devlink port show + check_err $? "Failed PF port show" + + state=$(function_state_get "state") + check_err $? "Failed to get function state" + [ "$state" == "inactive" ] + check_err $? "Unexpected function state $state" + + state=$(function_state_get "opstate") + check_err $? "Failed to get operational state" + [ "$state" == "detached" ] + check_err $? "Unexpected function opstate $opstate" + + devlink port function set $DL_HANDLE/$USR_SF_PORT_INDEX state active + check_err $? "Failed to set state" + + state=$(function_state_get "state") + check_err $? "Failed to get function state" + [ "$state" == "active" ] + check_err $? "Unexpected function state $state" + + state=$(function_state_get "opstate") + check_err $? "Failed to get operational state" + [ "$state" == "attached" ] + check_err $? "Unexpected function opstate $opstate" + + devlink port del $DL_HANDLE/$USR_SF_PORT_INDEX + check_err $? "Failed SF port deletion" + + log_test "port_add test" +} + setup_prepare() { modprobe netdevsim