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 36644433D8 for ; Mon, 11 Dec 2023 11:20:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2A53C42D78; Mon, 11 Dec 2023 11:20:16 +0100 (CET) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2059.outbound.protection.outlook.com [40.107.101.59]) by mails.dpdk.org (Postfix) with ESMTP id D3E1440E0F for ; Mon, 11 Dec 2023 11:20:13 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bIHXdOVL2z8P7N74RwN6G3Zp3NuNnMya9HksWHuXv+RU4i6OO004JJPgipv5V9iT5nSzby11JqSBjCLSvLbxswwy6VUKDuYKYnhUuDT2ezQQYOA8QaMRgICwypxm1BMdjLYPhxj/dtR3b7yXCrLcqbYKpmOCsKVzARxTtCNZ/UXfcRKQwXl0TBj90ccGH31U5Nx6OJv5pPFhtaPaHySxpPuEbegjyzLx1Yeb1SgbC9bvUvsS+qfpPPO+iwfr0APWYSjz8CI4ZKCJ+LJ6IZ40sr63SuWL7tQIiTlKOEhgAu6fN7YWkdxPLY3cxWYPlDvr0w78MPWWbI3iD7OT6ov8mA== 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=57im19OZfDSEggM8hQ/VcQpiTVvVNDUJ2Q2+W87kF8w=; b=hDdPnn+XClgggtBqFOT/AW81dH6215w+fx9ujSMt+UXh1nhggvKIOCmIhLmEv67EBLSv6OcWVhcFAvW8Zx80SJqGYgZ2oOTSSiVJjW/2QH1JpOZ59MZSSQWfvt9L7v4DFq1U2A6vTyC7YwNOOr/NBizktMyCaiyTiiXEN44s6+youQ7YtEHEEyLE1Gr2UwtueayiSGlarVypXaSy24rdbeKCPfxMu7oBucrCR/QZCGeQQayNyudUQ+PuXky2eMP9f5L/nsmoANbPdyXx+2Q9Q4+rm+epEWjFlv5ZtSnsc4lqhevR05CIDj0BQo4gvTRoD5Vme9VQ/jjyNNbFTzIjjQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=huawei.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 (0) 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=57im19OZfDSEggM8hQ/VcQpiTVvVNDUJ2Q2+W87kF8w=; b=mfCqdrP8uIjaV45CH40YqbnuAEFh1vsfck/jaq1H2JhzUdek3Z21PTTBqwCl0uHeD/Yna0IWi9B9zi95oLLvlNboe0HazKxkB5UKFmvs0uRuom3MdZ6uC4OqGGnft5ECv6mLK+peut7yVi1hRjva0Jf6ZVcjMz4jbFQrp7t80kpnf/2Aj2RVIEfjrzq3p3fnSg04KUvoFE6BpkVOS2cb82vQDA0+vbkl+8J6y0n3iV4IEgPsSKdzvrclqDpaGMzeQzQMvjZlEOuA1GallUvuv2rre5Lr3Auwx/3IQPwa7EugOYv6L027wd2XJ7ymUBy6jFyLBzBNzGtBPOgQ+RFGuQ== Received: from SA9PR13CA0090.namprd13.prod.outlook.com (2603:10b6:806:23::35) by CY8PR12MB7267.namprd12.prod.outlook.com (2603:10b6:930:55::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.32; Mon, 11 Dec 2023 10:20:11 +0000 Received: from SN1PEPF0002529E.namprd05.prod.outlook.com (2603:10b6:806:23:cafe::77) by SA9PR13CA0090.outlook.office365.com (2603:10b6:806:23::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.21 via Frontend Transport; Mon, 11 Dec 2023 10:20:11 +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 SN1PEPF0002529E.mail.protection.outlook.com (10.167.242.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.18 via Frontend Transport; Mon, 11 Dec 2023 10:20:10 +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.41; Mon, 11 Dec 2023 02:19:55 -0800 Received: from nvidia.com (10.126.231.35) 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.41; Mon, 11 Dec 2023 02:19:53 -0800 From: Xueming Li To: Dengdui Huang CC: Jie Hai , Huisong Li , "dpdk stable" Subject: patch 'net/hns3: fix mailbox sync' has been queued to stable release 22.11.4 Date: Mon, 11 Dec 2023 18:11:45 +0800 Message-ID: <20231211101226.2122-81-xuemingl@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231211101226.2122-1-xuemingl@nvidia.com> References: <20231022142250.10324-1-xuemingl@nvidia.com> <20231211101226.2122-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002529E:EE_|CY8PR12MB7267:EE_ X-MS-Office365-Filtering-Correlation-Id: 84bda295-2bcd-4bda-6089-08dbfa32c15b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vPOEyTTFHxPrdIg/rFqqZphN86rMCD/ka5HCCujN02kADsQQlkLYi+NdO2BJ0CDtiOKUy4hXETZfK4xl2C663GCvbUoqtg4UID+KkN7LLH7wlk1PE7amfa34tfifwwCTLnKFvLpsi0hKDMpHlt0u4ON7KylXkd1MTPjmGSa/N46trZCjWSDXwsUgD5xO5Vfs2QSPtLQrpxZ0ywi3/fuhvMQxxETj8+3GvSQa/nnXeoh1gal8TNmJ1z0ptkrjtbPopbs77my0B76Em1UIHK185c5rgtQaUpbS0nWMKj4H6rO4ayhj9JQNYIAwnUW43ifNysSZvhKCfG57oOGtWBIfHOX5Q6qpc5YdvW9s3wBSJo/60WdYMVyAWCXEbyj8EjDUEI4ioKrkgn5bUlwsb/K5v5g76+CxcyfVL4go0ZcAznZ3AU7JPZHghVKtAMMSlB2eIfxMjBAQaLY5r2zki/ZTou53EqJMXgW6P4014a52siqCS+8/GXZEEO/0i90HgcQeQU2PDHN0Kjbqz8cO6b++J04CCC2oNI62K5hEfeLNF0hOqO6vyrIUyfYsqb4277748xXGKjud3BWUXE9kXnCZRc+zurgbqHaG4TDuY5VkS/sp749+61LCF9fFdylGJMklAC7oJu+fPma1ONkk5DVkLp/X+W+kvaKpYvv4PNydjCAJ7H0Mrn8FMnfaZm0KVAoGP1BUDBZSqd4MF0graohwnCjMB60jmay1BQXsnuJxpvxESr5ex1dYLJhKgtgJaAHJtsJWFv/rq4Hi324wPykCJ/lQDZkpXDYcjdbNhzLKu3w= 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:(13230031)(4636009)(346002)(39860400002)(136003)(376002)(396003)(230922051799003)(64100799003)(82310400011)(186009)(451199024)(1800799012)(46966006)(40470700004)(36840700001)(55016003)(40480700001)(426003)(336012)(16526019)(6286002)(26005)(1076003)(2616005)(40460700003)(82740400003)(86362001)(36756003)(356005)(7636003)(83380400001)(5660300002)(15650500001)(6666004)(53546011)(7696005)(47076005)(36860700001)(8936002)(8676002)(70586007)(70206006)(966005)(54906003)(316002)(6916009)(2906002)(4001150100001)(41300700001)(478600001)(4326008); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2023 10:20:10.0951 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 84bda295-2bcd-4bda-6089-08dbfa32c15b 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: SN1PEPF0002529E.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7267 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.4 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 12/13/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=b3009db2e43e7733431ab469e878ca94d3f83cc7 Thanks. Xueming Li --- >From b3009db2e43e7733431ab469e878ca94d3f83cc7 Mon Sep 17 00:00:00 2001 From: Dengdui Huang Date: Sat, 11 Nov 2023 09:59:14 +0800 Subject: [PATCH] net/hns3: fix mailbox sync Cc: Xueming Li [ upstream commit be3590f54d0e415c23d4ed6ea55d967139c3ad10 ] Currently, hns3 VF driver uses the following points to match the response and request message for the mailbox synchronous message between VF and PF. 1. req_msg_data which is consist of message code and subcode, is used to match request and response. 2. head means the number of send success for VF. 3. tail means the number of receive success for VF. 4. lost means the number of send timeout for VF. And 'head', 'tail' and 'lost' are dynamically updated during the communication. Now there is a issue that all sync mailbox message will send failure forever at the flollowing case: 1. VF sends the message A then head=UINT32_MAX-1, tail=UINT32_MAX-3, lost=2. 2. VF sends the message B then head=UINT32_MAX, tail=UINT32_MAX-2, lost=2. 3. VF sends the message C, the message will be timeout because it can't get the response within 500ms. then head=0, tail=0, lost=2 note: tail is assigned to head if tail > head according to current code logic. From now on, all subsequent sync milbox messages fail to be sent. It's very complicated to use the fields 'lost','tail','head'. The code and subcode of the request sync mailbox are used as the matching code of the message, which is used to match the response message for receiving the synchronization response. This patch drops these fields and uses the following solution to solve this issue: In the handling response message process, using the req_msg_data of the request and response message to judge whether the sync mailbox message has been received. Fixes: 463e748964f5 ("net/hns3: support mailbox") Signed-off-by: Dengdui Huang Signed-off-by: Jie Hai Acked-by: Huisong Li --- drivers/net/hns3/hns3_cmd.c | 3 -- drivers/net/hns3/hns3_mbx.c | 81 ++++++------------------------------- drivers/net/hns3/hns3_mbx.h | 10 ----- 3 files changed, 13 insertions(+), 81 deletions(-) diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c index 1dd4b7a8fc..7bdf7740c1 100644 --- a/drivers/net/hns3/hns3_cmd.c +++ b/drivers/net/hns3/hns3_cmd.c @@ -699,9 +699,6 @@ hns3_cmd_init(struct hns3_hw *hw) hw->cmq.csq.next_to_use = 0; hw->cmq.crq.next_to_clean = 0; hw->cmq.crq.next_to_use = 0; - hw->mbx_resp.head = 0; - hw->mbx_resp.tail = 0; - hw->mbx_resp.lost = 0; hns3_cmd_init_regs(hw); rte_spinlock_unlock(&hw->cmq.crq.lock); diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c index 8e0a58aa02..f1743c195e 100644 --- a/drivers/net/hns3/hns3_mbx.c +++ b/drivers/net/hns3/hns3_mbx.c @@ -40,23 +40,6 @@ hns3_resp_to_errno(uint16_t resp_code) return -EIO; } -static void -hns3_mbx_proc_timeout(struct hns3_hw *hw, uint16_t code, uint16_t subcode) -{ - if (hw->mbx_resp.matching_scheme == - HNS3_MBX_RESP_MATCHING_SCHEME_OF_ORIGINAL) { - hw->mbx_resp.lost++; - hns3_err(hw, - "VF could not get mbx(%u,%u) head(%u) tail(%u) " - "lost(%u) from PF", - code, subcode, hw->mbx_resp.head, hw->mbx_resp.tail, - hw->mbx_resp.lost); - return; - } - - hns3_err(hw, "VF could not get mbx(%u,%u) from PF", code, subcode); -} - static int hns3_get_mbx_resp(struct hns3_hw *hw, uint16_t code, uint16_t subcode, uint8_t *resp_data, uint16_t resp_len) @@ -67,7 +50,6 @@ hns3_get_mbx_resp(struct hns3_hw *hw, uint16_t code, uint16_t subcode, struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); struct hns3_mbx_resp_status *mbx_resp; uint32_t wait_time = 0; - bool received; if (resp_len > HNS3_MBX_MAX_RESP_DATA_SIZE) { hns3_err(hw, "VF mbx response len(=%u) exceeds maximum(=%d)", @@ -93,20 +75,14 @@ hns3_get_mbx_resp(struct hns3_hw *hw, uint16_t code, uint16_t subcode, hns3_dev_handle_mbx_msg(hw); rte_delay_us(HNS3_WAIT_RESP_US); - if (hw->mbx_resp.matching_scheme == - HNS3_MBX_RESP_MATCHING_SCHEME_OF_ORIGINAL) - received = (hw->mbx_resp.head == - hw->mbx_resp.tail + hw->mbx_resp.lost); - else - received = hw->mbx_resp.received_match_resp; - if (received) + if (hw->mbx_resp.received_match_resp) break; wait_time += HNS3_WAIT_RESP_US; } hw->mbx_resp.req_msg_data = 0; if (wait_time >= mbx_time_limit) { - hns3_mbx_proc_timeout(hw, code, subcode); + hns3_err(hw, "VF could not get mbx(%u,%u) from PF", code, subcode); return -ETIME; } rte_io_rmb(); @@ -132,7 +108,6 @@ hns3_mbx_prepare_resp(struct hns3_hw *hw, uint16_t code, uint16_t subcode) * we get the exact scheme which is used. */ hw->mbx_resp.req_msg_data = (uint32_t)code << 16 | subcode; - hw->mbx_resp.head++; /* Update match_id and ensure the value of match_id is not zero */ hw->mbx_resp.match_id++; @@ -185,7 +160,6 @@ hns3_send_mbx_msg(struct hns3_hw *hw, uint16_t code, uint16_t subcode, req->match_id = hw->mbx_resp.match_id; ret = hns3_cmd_send(hw, &desc, 1); if (ret) { - hw->mbx_resp.head--; rte_spinlock_unlock(&hw->mbx_resp.lock); hns3_err(hw, "VF failed(=%d) to send mbx message to PF", ret); @@ -254,41 +228,10 @@ hns3_handle_asserting_reset(struct hns3_hw *hw, hns3_schedule_reset(HNS3_DEV_HW_TO_ADAPTER(hw)); } -/* - * Case1: receive response after timeout, req_msg_data - * is 0, not equal resp_msg, do lost-- - * Case2: receive last response during new send_mbx_msg, - * req_msg_data is different with resp_msg, let - * lost--, continue to wait for response. - */ -static void -hns3_update_resp_position(struct hns3_hw *hw, uint32_t resp_msg) -{ - struct hns3_mbx_resp_status *resp = &hw->mbx_resp; - uint32_t tail = resp->tail + 1; - - if (tail > resp->head) - tail = resp->head; - if (resp->req_msg_data != resp_msg) { - if (resp->lost) - resp->lost--; - hns3_warn(hw, "Received a mismatched response req_msg(%x) " - "resp_msg(%x) head(%u) tail(%u) lost(%u)", - resp->req_msg_data, resp_msg, resp->head, tail, - resp->lost); - } else if (tail + resp->lost > resp->head) { - resp->lost--; - hns3_warn(hw, "Received a new response again resp_msg(%x) " - "head(%u) tail(%u) lost(%u)", resp_msg, - resp->head, tail, resp->lost); - } - rte_io_wmb(); - resp->tail = tail; -} - static void hns3_handle_mbx_response(struct hns3_hw *hw, struct hns3_mbx_pf_to_vf_cmd *req) { +#define HNS3_MBX_RESP_CODE_OFFSET 16 struct hns3_mbx_resp_status *resp = &hw->mbx_resp; uint32_t msg_data; @@ -298,12 +241,6 @@ hns3_handle_mbx_response(struct hns3_hw *hw, struct hns3_mbx_pf_to_vf_cmd *req) * match_id to its response. So VF could use the match_id * to match the request. */ - if (resp->matching_scheme != - HNS3_MBX_RESP_MATCHING_SCHEME_OF_MATCH_ID) { - resp->matching_scheme = - HNS3_MBX_RESP_MATCHING_SCHEME_OF_MATCH_ID; - hns3_info(hw, "detect mailbox support match id!"); - } if (req->match_id == resp->match_id) { resp->resp_status = hns3_resp_to_errno(req->msg[3]); memcpy(resp->additional_info, &req->msg[4], @@ -319,11 +256,19 @@ hns3_handle_mbx_response(struct hns3_hw *hw, struct hns3_mbx_pf_to_vf_cmd *req) * support copy request's match_id to its response. So VF follows the * original scheme to process. */ + msg_data = (uint32_t)req->msg[1] << HNS3_MBX_RESP_CODE_OFFSET | req->msg[2]; + if (resp->req_msg_data != msg_data) { + hns3_warn(hw, + "received response tag (%u) is mismatched with requested tag (%u)", + msg_data, resp->req_msg_data); + return; + } + resp->resp_status = hns3_resp_to_errno(req->msg[3]); memcpy(resp->additional_info, &req->msg[4], HNS3_MBX_MAX_RESP_DATA_SIZE); - msg_data = (uint32_t)req->msg[1] << 16 | req->msg[2]; - hns3_update_resp_position(hw, msg_data); + rte_io_wmb(); + resp->received_match_resp = true; } static void diff --git a/drivers/net/hns3/hns3_mbx.h b/drivers/net/hns3/hns3_mbx.h index c378783c6c..4a328802b9 100644 --- a/drivers/net/hns3/hns3_mbx.h +++ b/drivers/net/hns3/hns3_mbx.h @@ -93,21 +93,11 @@ enum hns3_mbx_link_fail_subcode { #define HNS3_MBX_MAX_RESP_DATA_SIZE 8 #define HNS3_MBX_DEF_TIME_LIMIT_MS 500 -enum { - HNS3_MBX_RESP_MATCHING_SCHEME_OF_ORIGINAL = 0, - HNS3_MBX_RESP_MATCHING_SCHEME_OF_MATCH_ID -}; - struct hns3_mbx_resp_status { rte_spinlock_t lock; /* protects against contending sync cmd resp */ - uint8_t matching_scheme; - /* The following fields used in the matching scheme for original */ uint32_t req_msg_data; - uint32_t head; - uint32_t tail; - uint32_t lost; /* The following fields used in the matching scheme for match_id */ uint16_t match_id; -- 2.25.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-12-11 17:56:25.665769400 +0800 +++ 0080-net-hns3-fix-mailbox-sync.patch 2023-12-11 17:56:23.107652300 +0800 @@ -1 +1 @@ -From be3590f54d0e415c23d4ed6ea55d967139c3ad10 Mon Sep 17 00:00:00 2001 +From b3009db2e43e7733431ab469e878ca94d3f83cc7 Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit be3590f54d0e415c23d4ed6ea55d967139c3ad10 ] @@ -42 +44,0 @@ -Cc: stable@dpdk.org @@ -54 +56 @@ -index a5c4c11dc8..2c1664485b 100644 +index 1dd4b7a8fc..7bdf7740c1 100644 @@ -57 +59 @@ -@@ -731,9 +731,6 @@ hns3_cmd_init(struct hns3_hw *hw) +@@ -699,9 +699,6 @@ hns3_cmd_init(struct hns3_hw *hw)