Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3524881pxv; Mon, 19 Jul 2021 02:18:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyAb1W5UYFdXUzp7Qd3XSHZJKt7d4HUiG3udb8yUr1jbhfYa4Jgpcna9YOhR61ciUN4m5w X-Received: by 2002:a92:d8cf:: with SMTP id l15mr16265930ilo.227.1626686280548; Mon, 19 Jul 2021 02:18:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626686280; cv=none; d=google.com; s=arc-20160816; b=zPhpDzSJHu9+95//tc18uLOgilKFCLQupFVZApdFLqdxPZ3c407XHSaBvM4Ht4BqUy kH6uQsWI9VqUS7T0HfE79y3VAywjiSF+/hqx2YGkzqaWYaJ4DCUJcctqKVjDcKI/u+Js Of6T9oONMtVOZ17IPNE2zgwZDHXlP1C3vwOB8XOfVCERYNByqC7yvRkX513BmbaFhPEp QGsknQM4p97cEX7N9MWGR+aydgmHrC7cKSueVIfMlz9haW2XZlYzir/lpgIOp/rrTsxS FycrnjGubOmJAZv6kndLRsEAYfDR65FIGuRl+vtoWIxVXEdg8mxBm9CZ0i2IWiIrIRaA lN4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=70fdunNz1ARVw2JahxKz59KN2vOc1CQ+Hc1XJr6sqWo=; b=AdE21X6QUZwiJK3q3PVWWVbFaJS13Xo3oZOQb6f+iCtHiz0BY5WGBiSjHV4ka5UGAe iVXKdDhkJxuugpeJcT9Xo8tU+/YekinrFCrIFj8+3b8ZKH5dmZP63xFNxi2FEn6i8ip/ fx/Vnev4yD49sdoVIcwmwS1s91js26E2hLXe36uCn8zoHezZvFzabcmXjuI1/y+VtHga r72ZsEqDFJ5AC/I+DSbp23uMlmSuv7YlI1dUtBgNMKfdFUFIMPYmOBAjmfg3ELvHWDGd SQSL96sI/ZPIuMXAG9S9cKPDGjgtvl0tk1SjEev35WfOlI+IaQM8HmJUjOxYdUzqpUG9 XWfg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u12si18313521iot.101.2021.07.19.02.17.49; Mon, 19 Jul 2021 02:18:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236029AbhGSIgK (ORCPT + 99 others); Mon, 19 Jul 2021 04:36:10 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:15039 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235404AbhGSIgA (ORCPT ); Mon, 19 Jul 2021 04:36:00 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4GSx314lNkzZqp1; Mon, 19 Jul 2021 17:13:17 +0800 (CST) Received: from dggemi759-chm.china.huawei.com (10.1.198.145) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Mon, 19 Jul 2021 17:16:38 +0800 Received: from localhost.localdomain (10.67.165.24) by dggemi759-chm.china.huawei.com (10.1.198.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Mon, 19 Jul 2021 17:16:38 +0800 From: Guangbin Huang To: , , CC: , , , , Subject: [PATCH net 1/4] net: hns3: fix possible mismatches resp of mailbox Date: Mon, 19 Jul 2021 17:13:05 +0800 Message-ID: <1626685988-25869-2-git-send-email-huangguangbin2@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1626685988-25869-1-git-send-email-huangguangbin2@huawei.com> References: <1626685988-25869-1-git-send-email-huangguangbin2@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.165.24] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggemi759-chm.china.huawei.com (10.1.198.145) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chengwen Feng Currently, the mailbox synchronous communication between VF and PF use the following fields to maintain communication: 1. Origin_mbx_msg which was combined by message code and subcode, used to match request and response. 2. Received_resp which means whether received response. There may possible mismatches of the following situation: 1. VF sends message A with code=1 subcode=1. 2. PF was blocked about 500ms when processing the message A. 3. VF will detect message A timeout because it can't get the response within 500ms. 4. VF sends message B with code=1 subcode=1 which equal message A. 5. PF processes the first message A and send the response message to VF. 6. VF will identify the response matched the message B because the code/subcode is the same. This will lead to mismatch of request and response. To fix the above bug, we use the following scheme: 1. The message sent from VF was labelled with match_id which was a unique 16-bit non-zero value. 2. The response sent from PF will label with match_id which got from the request. 3. The VF uses the match_id to match request and response message. As for PF driver, it only needs to copy the match_id from request to response. Fixes: dde1a86e93ca ("net: hns3: Add mailbox support to PF driver") Signed-off-by: Chengwen Feng Signed-off-by: Guangbin Huang --- drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h | 6 ++++-- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h b/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h index 0a6cda309b24..56b573e47072 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h +++ b/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h @@ -143,7 +143,8 @@ struct hclge_mbx_vf_to_pf_cmd { u8 mbx_need_resp; u8 rsv1[1]; u8 msg_len; - u8 rsv2[3]; + u8 rsv2; + u16 match_id; struct hclge_vf_to_pf_msg msg; }; @@ -153,7 +154,8 @@ struct hclge_mbx_pf_to_vf_cmd { u8 dest_vfid; u8 rsv[3]; u8 msg_len; - u8 rsv1[3]; + u8 rsv1; + u16 match_id; struct hclge_pf_to_vf_msg msg; }; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c index e10a2c36b706..c0a478ae9583 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c @@ -47,6 +47,7 @@ static int hclge_gen_resp_to_vf(struct hclge_vport *vport, resp_pf_to_vf->dest_vfid = vf_to_pf_req->mbx_src_vfid; resp_pf_to_vf->msg_len = vf_to_pf_req->msg_len; + resp_pf_to_vf->match_id = vf_to_pf_req->match_id; resp_pf_to_vf->msg.code = HCLGE_MBX_PF_VF_RESP; resp_pf_to_vf->msg.vf_mbx_msg_code = vf_to_pf_req->msg.code; -- 2.8.1