From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B214A41D8D for ; Mon, 27 Feb 2023 08:15:58 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A7F35410DC; Mon, 27 Feb 2023 08:15:58 +0100 (CET) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2061.outbound.protection.outlook.com [40.107.237.61]) by mails.dpdk.org (Postfix) with ESMTP id C81AF40ED6 for ; Mon, 27 Feb 2023 08:15:57 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LS/3iBpAtbMcINwR89uV2NYewa+Y8RveHGebAtx2nNfcIwQ5P5/8QVZhUSV7CdCDkWuATfGKnkFvfw7pzjQHPZAvvq9N9wNaUFPMysNmC5DDq0kTBt5M0fFtAyD2joqJ/CEj6u/RcCmmoBt/3CxB0t+AyhM9tZOBY2xYF083NDSjOVTR9D09D0Oi/eO5NTvS1ckT7dynUKG9GrlPR1bfsEmA3oSRNLLryNRSgsTvQdgE/ncK4jPG/ilh4APO1b9HTT/MN/VrdsR8o23oH8f2ZNP5Yzx9VPRoG0I0fGX4xtI9J/bfN8Qnr70bm3ayVkQ74i7sMCx6QfX3NiV47Nh6rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=a4wYsNyEGDNH4BUhDu1+ZdbkvOPPLEjIn561GyYNIiY=; b=CtjfPo9awAgQmDOikZMd292DCaawDex1R8fOROaR/sgxfKKkL8Dirr7BBonWfdt/TsqU+mF/CJJHFEDICVaLzCOMVk7yLNr6cTPM35XZtNeixz2sjfWz96FvYxM8SrZyd6NSnYmTpjdDzWSaKB0Sk9FZTXlIphi6A68SgRE8eCWeYcry9jFOusxnebVhgkSwWLY26BExRJ68d8xIn0Toy2EuHqlrq0Wn0jub/8SIJFz6eGWcfGdLJF8/sgBp6WWs+9oOferlhW42MFYBEi+6j1Y52XfDa0vuk4a0a39a6NuNLEDx2lY60J6tAYeoWI/5OJmDtkD8RSGhQDPC4yZ+SQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=a4wYsNyEGDNH4BUhDu1+ZdbkvOPPLEjIn561GyYNIiY=; b=M0KRRs367juwH8cYMe1X5fPvy/i8+yExubXidVX2cg3lT81OWcS6IKnstfScQPulJIaPm+MnpM7vrOTPeN+IB9cF5MKRdUAhxczcKK0b5KyP7Qo3cASQlTrBbbbwIfASlF4P/Vsmd2XHHLiP5Ic4fgHxkI4i/0kCxQLUBFZ6YHk5DCzjXp6NMUIzIID8DXSDbduxCWrONc8yDKpw9vBepxqYxSqTvAp7sgmkW3nDsLMENCzpdMdV3vkjGWFcgw6Fjo+ig/ETkhNk+GGyL7FopiEbGz22Uvs7NtzrlC0MqrIkDAAnsXzbJtzqcDTuyZc5ra0LT5DPdYcfMazR3VtA3Q== Received: from BLAPR05CA0017.namprd05.prod.outlook.com (2603:10b6:208:36e::29) by BN9PR12MB5147.namprd12.prod.outlook.com (2603:10b6:408:118::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.27; Mon, 27 Feb 2023 07:15:55 +0000 Received: from BL02EPF00010209.namprd05.prod.outlook.com (2603:10b6:208:36e:cafe::38) by BLAPR05CA0017.outlook.office365.com (2603:10b6:208:36e::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.16 via Frontend Transport; Mon, 27 Feb 2023 07:15:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BL02EPF00010209.mail.protection.outlook.com (10.167.241.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.12 via Frontend Transport; Mon, 27 Feb 2023 07:15:55 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Sun, 26 Feb 2023 23:15:36 -0800 Received: from nvidia.com (10.126.230.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Sun, 26 Feb 2023 23:15:33 -0800 From: Xueming Li To: Mike Pattrick CC: Qi Zhang , dpdk stable Subject: patch 'net/iavf: add lock for VF commands' has been queued to stable release 22.11.2 Date: Mon, 27 Feb 2023 15:00:43 +0800 Message-ID: <20230227070107.15664-135-xuemingl@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230227070107.15664-1-xuemingl@nvidia.com> References: <20230227062349.13764-1-xuemingl@nvidia.com> <20230227070107.15664-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.37] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF00010209:EE_|BN9PR12MB5147:EE_ X-MS-Office365-Filtering-Correlation-Id: a1a88630-96da-4d37-6b3a-08db189277c4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yx2U3IqRSIJpVec64/Wh33AmN/NJgO7+78L+lk5lvhU4t2mlw/c2vcWAnyImmQS+ZPuM7zJzIO0E/gRIqgSoicc5BdxOoKB51Y4WCO4kBKBn/DwrLbGBg8s2oGbOVeQ7U7mwMcFKHlgBSzm9yARfLeFdrRWPbEGpu73gVW15rgWV18hqSgvDVldlDvV+Kg4L7sjQeh/rSq74Hv+RpufFSEnWH0vIHD+9iv5kGkmEgYVQ957IwVSyVn/ZQvZvpbPo4zqz4lMLTYsV3g9pLjUsJXc8CMlG3VVqZaCTd94FklH5NKdBwYT0EKbZU7MSCm9zNSSOfNTm0yIlmK+D4w+lLcUfxFu8EElqt3uQwOPHMkcJFct677YT85rZ8gN0TX9cLeoCxbxQwFkNvt+nZ6BtRR0bB5JrEe4kM3Lktr8HEmXu3qpJtdcKavRB4LIZ+THF+cb05Yz3NbGnfsisCUmXHU8GL4E5XJSwgx01I+sC8CHlda+ZjidTeRanaXh8m1EGe7R52tNwoVYXH2QGmI0WH7g1ALjLKlZ9DVbt/IpFiiqp4dY4JCWD+DZT3bfExkHooob9HI+Ubz370c7quQ02qpQowYeM9V24fL0bAyuhp1NWqDJASsYMAqvU3lruhq7LkEO8DPZkJ67K5M6UK9Chh/7ESRFhBkusWe0UPid59Nh+n4ojhGwJzTZkzDe9X08a82tiw+rBjUc8skP633MbIG5OrWBpjfpGMuovBY4WBVOGNbLvhLFmui6II2sfXljR7yTnS7GNgsSvFn0xlm+XtHGTc6UGhxWE7mSF5IWBuxQ= X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230025)(4636009)(376002)(396003)(39860400002)(346002)(136003)(451199018)(36840700001)(40470700004)(46966006)(53546011)(36860700001)(6286002)(186003)(26005)(16526019)(30864003)(70206006)(70586007)(4326008)(6916009)(8676002)(478600001)(356005)(40460700003)(7696005)(54906003)(86362001)(966005)(55016003)(316002)(40480700001)(8936002)(1076003)(5660300002)(36756003)(41300700001)(82740400003)(6666004)(7636003)(336012)(82310400005)(2906002)(47076005)(426003)(83380400001)(66899018)(2616005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Feb 2023 07:15:55.4676 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a1a88630-96da-4d37-6b3a-08db189277c4 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF00010209.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5147 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 22.11.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 03/01/23. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://git.dpdk.org/dpdk-stable/log/?h=22.11-staging This queued commit can be viewed at: https://git.dpdk.org/dpdk-stable/commit/?h=22.11-staging&id=5aacd2a62c110e4ec9820edb2fc9bc24e3e6e81d Thanks. Xueming Li --- >From 5aacd2a62c110e4ec9820edb2fc9bc24e3e6e81d Mon Sep 17 00:00:00 2001 From: Mike Pattrick Date: Wed, 28 Dec 2022 18:00:25 -0500 Subject: [PATCH] net/iavf: add lock for VF commands Cc: Xueming Li [ upstream commit 91bf37d250aacfc9512a33ce9ec6d4783766804e ] iavf admin queue commands aren't thread-safe. Bugs surrounding this issue can manifest in a variety of ways but frequently pend_cmd is over written. Simultaneously executing commands can result in a misconfigured device or DPDK sleeping in a thread for 2 second. Despite this limitation, vf commands may be executed from both iavf_dev_alarm_handler() in a control thread and the applications main thread. This is trivial to simulate in the testpmd application by creating a bond of vf's in active backup mode, and then turning the bond off and then on again repeatedly. Previously [1] was proposed as a potential solution, but this commit did not resolve all potential issues concerning the admin queue and has been reverted from the stable branch. I propose adding locks until a more complete solution is available. [1] commit cb5c1b91f76f ("net/iavf: add thread for event callbacks") Fixes: 48de41ca11f0 ("net/avf: enable link status update") Fixes: 84108425054a ("net/iavf: support asynchronous virtual channel message") Signed-off-by: Mike Pattrick Acked-by: Qi Zhang --- drivers/net/iavf/iavf.h | 1 + drivers/net/iavf/iavf_vchnl.c | 106 ++++++++++++++++++++-------------- 2 files changed, 63 insertions(+), 44 deletions(-) diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h index 1edebab8dc..aa18650ffa 100644 --- a/drivers/net/iavf/iavf.h +++ b/drivers/net/iavf/iavf.h @@ -262,6 +262,7 @@ struct iavf_info { struct iavf_qv_map *qv_map; /* queue vector mapping */ struct iavf_flow_list flow_list; rte_spinlock_t flow_ops_lock; + rte_spinlock_t aq_lock; struct iavf_parser_list rss_parser_list; struct iavf_parser_list dist_parser_list; struct iavf_parser_list ipsec_crypto_parser_list; diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c index f92daf97f2..9adaadb173 100644 --- a/drivers/net/iavf/iavf_vchnl.c +++ b/drivers/net/iavf/iavf_vchnl.c @@ -397,6 +397,20 @@ iavf_execute_vf_cmd(struct iavf_adapter *adapter, struct iavf_cmd_info *args, return err; } +static int +iavf_execute_vf_cmd_safe(struct iavf_adapter *adapter, + struct iavf_cmd_info *args, int async) +{ + struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter); + int ret; + + rte_spinlock_lock(&vf->aq_lock); + ret = iavf_execute_vf_cmd(adapter, args, async); + rte_spinlock_unlock(&vf->aq_lock); + + return ret; +} + static void iavf_handle_pf_event_msg(struct rte_eth_dev *dev, uint8_t *msg, uint16_t msglen) @@ -554,7 +568,7 @@ iavf_enable_vlan_strip(struct iavf_adapter *adapter) args.in_args_size = 0; args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - ret = iavf_execute_vf_cmd(adapter, &args, 0); + ret = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (ret) PMD_DRV_LOG(ERR, "Failed to execute command of" " OP_ENABLE_VLAN_STRIPPING"); @@ -575,7 +589,7 @@ iavf_disable_vlan_strip(struct iavf_adapter *adapter) args.in_args_size = 0; args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - ret = iavf_execute_vf_cmd(adapter, &args, 0); + ret = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (ret) PMD_DRV_LOG(ERR, "Failed to execute command of" " OP_DISABLE_VLAN_STRIPPING"); @@ -604,7 +618,7 @@ iavf_check_api_version(struct iavf_adapter *adapter) args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) { PMD_INIT_LOG(ERR, "Fail to execute command of OP_VERSION"); return err; @@ -665,7 +679,7 @@ iavf_get_vf_resource(struct iavf_adapter *adapter) args.in_args = (uint8_t *)∩︀ args.in_args_size = sizeof(caps); - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) { PMD_DRV_LOG(ERR, @@ -710,7 +724,7 @@ iavf_get_supported_rxdid(struct iavf_adapter *adapter) args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - ret = iavf_execute_vf_cmd(adapter, &args, 0); + ret = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (ret) { PMD_DRV_LOG(ERR, "Failed to execute command of OP_GET_SUPPORTED_RXDIDS"); @@ -754,7 +768,7 @@ iavf_config_vlan_strip_v2(struct iavf_adapter *adapter, bool enable) args.in_args_size = sizeof(vlan_strip); args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - ret = iavf_execute_vf_cmd(adapter, &args, 0); + ret = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (ret) PMD_DRV_LOG(ERR, "fail to execute command %s", enable ? "VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2" : @@ -794,7 +808,7 @@ iavf_config_vlan_insert_v2(struct iavf_adapter *adapter, bool enable) args.in_args_size = sizeof(vlan_insert); args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - ret = iavf_execute_vf_cmd(adapter, &args, 0); + ret = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (ret) PMD_DRV_LOG(ERR, "fail to execute command %s", enable ? "VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2" : @@ -837,7 +851,7 @@ iavf_add_del_vlan_v2(struct iavf_adapter *adapter, uint16_t vlanid, bool add) args.in_args_size = sizeof(vlan_filter); args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) PMD_DRV_LOG(ERR, "fail to execute command %s", add ? "OP_ADD_VLAN_V2" : "OP_DEL_VLAN_V2"); @@ -858,7 +872,7 @@ iavf_get_vlan_offload_caps_v2(struct iavf_adapter *adapter) args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - ret = iavf_execute_vf_cmd(adapter, &args, 0); + ret = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (ret) { PMD_DRV_LOG(ERR, "Failed to execute command of VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS"); @@ -889,7 +903,7 @@ iavf_enable_queues(struct iavf_adapter *adapter) args.in_args_size = sizeof(queue_select); args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) { PMD_DRV_LOG(ERR, "Failed to execute command of OP_ENABLE_QUEUES"); @@ -917,7 +931,7 @@ iavf_disable_queues(struct iavf_adapter *adapter) args.in_args_size = sizeof(queue_select); args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) { PMD_DRV_LOG(ERR, "Failed to execute command of OP_DISABLE_QUEUES"); @@ -953,7 +967,7 @@ iavf_switch_queue(struct iavf_adapter *adapter, uint16_t qid, args.in_args_size = sizeof(queue_select); args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) PMD_DRV_LOG(ERR, "Failed to execute command of %s", on ? "OP_ENABLE_QUEUES" : "OP_DISABLE_QUEUES"); @@ -995,7 +1009,7 @@ iavf_enable_queues_lv(struct iavf_adapter *adapter) args.in_args_size = len; args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) PMD_DRV_LOG(ERR, "Failed to execute command of OP_ENABLE_QUEUES_V2"); @@ -1039,7 +1053,7 @@ iavf_disable_queues_lv(struct iavf_adapter *adapter) args.in_args_size = len; args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) PMD_DRV_LOG(ERR, "Failed to execute command of OP_DISABLE_QUEUES_V2"); @@ -1085,7 +1099,7 @@ iavf_switch_queue_lv(struct iavf_adapter *adapter, uint16_t qid, args.in_args_size = len; args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) PMD_DRV_LOG(ERR, "Failed to execute command of %s", on ? "OP_ENABLE_QUEUES_V2" : "OP_DISABLE_QUEUES_V2"); @@ -1117,7 +1131,7 @@ iavf_configure_rss_lut(struct iavf_adapter *adapter) args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) PMD_DRV_LOG(ERR, "Failed to execute command of OP_CONFIG_RSS_LUT"); @@ -1149,7 +1163,7 @@ iavf_configure_rss_key(struct iavf_adapter *adapter) args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) PMD_DRV_LOG(ERR, "Failed to execute command of OP_CONFIG_RSS_KEY"); @@ -1247,7 +1261,7 @@ iavf_configure_queues(struct iavf_adapter *adapter, args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) PMD_DRV_LOG(ERR, "Failed to execute command of" " VIRTCHNL_OP_CONFIG_VSI_QUEUES"); @@ -1288,7 +1302,7 @@ iavf_config_irq_map(struct iavf_adapter *adapter) args.in_args_size = len; args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) PMD_DRV_LOG(ERR, "fail to execute command OP_CONFIG_IRQ_MAP"); @@ -1329,7 +1343,7 @@ iavf_config_irq_map_lv(struct iavf_adapter *adapter, uint16_t num, args.in_args_size = len; args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) PMD_DRV_LOG(ERR, "fail to execute command OP_MAP_QUEUE_VECTOR"); @@ -1389,7 +1403,7 @@ iavf_add_del_all_mac_addr(struct iavf_adapter *adapter, bool add) args.in_args_size = len; args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) PMD_DRV_LOG(ERR, "fail to execute command %s", add ? "OP_ADD_ETHER_ADDRESS" : @@ -1419,7 +1433,7 @@ iavf_query_stats(struct iavf_adapter *adapter, args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) { PMD_DRV_LOG(ERR, "fail to execute command OP_GET_STATS"); *pstats = NULL; @@ -1457,7 +1471,7 @@ iavf_config_promisc(struct iavf_adapter *adapter, args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) { PMD_DRV_LOG(ERR, @@ -1500,7 +1514,7 @@ iavf_add_del_eth_addr(struct iavf_adapter *adapter, struct rte_ether_addr *addr, args.in_args_size = sizeof(cmd_buffer); args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) PMD_DRV_LOG(ERR, "fail to execute command %s", add ? "OP_ADD_ETH_ADDR" : "OP_DEL_ETH_ADDR"); @@ -1527,7 +1541,7 @@ iavf_add_del_vlan(struct iavf_adapter *adapter, uint16_t vlanid, bool add) args.in_args_size = sizeof(cmd_buffer); args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) PMD_DRV_LOG(ERR, "fail to execute command %s", add ? "OP_ADD_VLAN" : "OP_DEL_VLAN"); @@ -1554,7 +1568,7 @@ iavf_fdir_add(struct iavf_adapter *adapter, args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) { PMD_DRV_LOG(ERR, "fail to execute command OP_ADD_FDIR_FILTER"); return err; @@ -1614,7 +1628,7 @@ iavf_fdir_del(struct iavf_adapter *adapter, args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) { PMD_DRV_LOG(ERR, "fail to execute command OP_DEL_FDIR_FILTER"); return err; @@ -1661,7 +1675,7 @@ iavf_fdir_check(struct iavf_adapter *adapter, args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) { PMD_DRV_LOG(ERR, "fail to check flow director rule"); return err; @@ -1704,7 +1718,7 @@ iavf_flow_sub(struct iavf_adapter *adapter, struct iavf_fsub_conf *filter) args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) { PMD_DRV_LOG(ERR, "Failed to execute command of " "OP_FLOW_SUBSCRIBE"); @@ -1755,7 +1769,7 @@ iavf_flow_unsub(struct iavf_adapter *adapter, struct iavf_fsub_conf *filter) args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) { PMD_DRV_LOG(ERR, "Failed to execute command of " "OP_FLOW_UNSUBSCRIBE"); @@ -1798,7 +1812,7 @@ iavf_flow_sub_check(struct iavf_adapter *adapter, args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) { PMD_DRV_LOG(ERR, "Failed to check flow subscription rule"); return err; @@ -1838,7 +1852,7 @@ iavf_add_del_rss_cfg(struct iavf_adapter *adapter, args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) PMD_DRV_LOG(ERR, "Failed to execute command of %s", @@ -1861,7 +1875,7 @@ iavf_get_hena_caps(struct iavf_adapter *adapter, uint64_t *caps) args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) { PMD_DRV_LOG(ERR, "Failed to execute command of OP_GET_RSS_HENA_CAPS"); @@ -1887,7 +1901,7 @@ iavf_set_hena(struct iavf_adapter *adapter, uint64_t hena) args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) PMD_DRV_LOG(ERR, "Failed to execute command of OP_SET_RSS_HENA"); @@ -1908,7 +1922,7 @@ iavf_get_qos_cap(struct iavf_adapter *adapter) args.in_args_size = 0; args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) { PMD_DRV_LOG(ERR, @@ -1941,7 +1955,7 @@ int iavf_set_q_tc_map(struct rte_eth_dev *dev, args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) PMD_DRV_LOG(ERR, "Failed to execute command of" " VIRTCHNL_OP_CONFIG_TC_MAP"); @@ -1964,7 +1978,7 @@ int iavf_set_q_bw(struct rte_eth_dev *dev, args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) PMD_DRV_LOG(ERR, "Failed to execute command of" " VIRTCHNL_OP_CONFIG_QUEUE_BW"); @@ -2009,7 +2023,7 @@ iavf_add_del_mc_addr_list(struct iavf_adapter *adapter, i * sizeof(struct virtchnl_ether_addr); args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) { PMD_DRV_LOG(ERR, "fail to execute command %s", @@ -2053,13 +2067,17 @@ iavf_request_queues(struct rte_eth_dev *dev, uint16_t num) if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_WB_ON_ITR) { /* disable interrupt to avoid the admin queue message to be read * before iavf_read_msg_from_pf. + * + * don't disable interrupt handler until ready to execute vf cmd. */ + rte_spinlock_lock(&vf->aq_lock); rte_intr_disable(pci_dev->intr_handle); err = iavf_execute_vf_cmd(adapter, &args, 0); rte_intr_enable(pci_dev->intr_handle); + rte_spinlock_unlock(&vf->aq_lock); } else { rte_eal_alarm_cancel(iavf_dev_alarm_handler, dev); - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); rte_eal_alarm_set(IAVF_ALARM_INTERVAL, iavf_dev_alarm_handler, dev); } @@ -2098,7 +2116,7 @@ iavf_get_max_rss_queue_region(struct iavf_adapter *adapter) args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) { PMD_DRV_LOG(ERR, "Failed to execute command of VIRTCHNL_OP_GET_MAX_RSS_QREGION"); return err; @@ -2129,7 +2147,7 @@ iavf_ipsec_crypto_request(struct iavf_adapter *adapter, args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 1); + err = iavf_execute_vf_cmd_safe(adapter, &args, 1); if (err) { PMD_DRV_LOG(ERR, "fail to execute command %s", "OP_INLINE_IPSEC_CRYPTO"); @@ -2163,7 +2181,7 @@ iavf_set_vf_quanta_size(struct iavf_adapter *adapter, u16 start_queue_id, u16 nu args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) { PMD_DRV_LOG(ERR, "Failed to execute command VIRTCHNL_OP_CONFIG_QUANTA"); return err; @@ -2189,7 +2207,7 @@ iavf_get_ptp_cap(struct iavf_adapter *adapter) args.out_buffer = vf->aq_resp; args.out_size = IAVF_AQ_BUF_SZ; - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) { PMD_DRV_LOG(ERR, "Failed to execute command of OP_1588_PTP_GET_CAPS"); @@ -2217,7 +2235,7 @@ iavf_get_phc_time(struct iavf_rx_queue *rxq) args.out_size = IAVF_AQ_BUF_SZ; rte_spinlock_lock(&vf->phc_time_aq_lock); - err = iavf_execute_vf_cmd(adapter, &args, 0); + err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) { PMD_DRV_LOG(ERR, "Failed to execute command of VIRTCHNL_OP_1588_PTP_GET_TIME"); -- 2.25.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-02-27 14:08:45.227471100 +0800 +++ 0136-net-iavf-add-lock-for-VF-commands.patch 2023-02-27 14:08:40.919237000 +0800 @@ -1 +1 @@ -From 91bf37d250aacfc9512a33ce9ec6d4783766804e Mon Sep 17 00:00:00 2001 +From 5aacd2a62c110e4ec9820edb2fc9bc24e3e6e81d Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit 91bf37d250aacfc9512a33ce9ec6d4783766804e ] @@ -26 +28,0 @@ -Cc: stable@dpdk.org