Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1457829ybh; Fri, 13 Mar 2020 01:26:14 -0700 (PDT) X-Google-Smtp-Source: ADFU+vumSTlWFA5rKoLB52fuk6N/whAMVfnjRGA+jUQTXZd8PTD5/O/dGdoZ2J9mnD+J6zEyVwwg X-Received: by 2002:a9d:6e90:: with SMTP id a16mr9881170otr.72.1584087974234; Fri, 13 Mar 2020 01:26:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584087974; cv=none; d=google.com; s=arc-20160816; b=Zlo7+aGIv/c+G/yus6HovT8RBijkJpiLcD6QitgTYk+Qo6l+0e8bijmr6VQ6G9AN1L YSFZfg0qzprL8WR01wKugyHc4jnTmEt74ItjROJWm1RTHMam+YuRqRjJUfFyXf5XzMsR Xgj/5GOKEWTAC1dX1zZp9PWTc2IUiOEHGLl+yiGZ56usOtrsl9PUT7onel+PB+N80E5B K/1+LctFaSN9whib01+JXiW2/dQgt2QIDGDbHQK8p8N6iLCsx4zmblIUJ544r/zWi+kD G/lhKn1mcr6seiWmgFIqzeymxqQ6/7T0JNg1TxqXbLu2YYr5PgNyjWdLVbZvEDLfLTHl 9upQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=Qd0zhKYHw+E2pDeKZPJQhL0TD9rpAYqvEIhb9jZXy0M=; b=qjTXK03iqn8tWKH5l9t4i6DpjQQFSBCUUzXdZXq9wJfNmhycetA8bUMnaynb96Zk9w pXFkEGGgWsO1MeDhCnN3CSYvINmXKO9m7nuSd6FBxatLQcbTe0l3jg563gJOtdnyACe6 Wkq5/2TgEXidd9J6/AM74sRc7Wth4g2GqqeSgdM4tKODphFah7YTpeD+UhIMh8ERjbHr N0GvzYd953dNrB+UyNSXkHiYCPykFObkrybX15OkL028z3CFJ/l2+l0EcsrFnS/eRthH Edvvp6f3IL4PJS8fD9PpBX7mFj77M3i1i7gj1DH6fNet54lV7H0tMUPsw7p1sO4XF4z4 urNQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z78si4156126oia.200.2020.03.13.01.26.01; Fri, 13 Mar 2020 01:26:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726533AbgCMIY3 (ORCPT + 99 others); Fri, 13 Mar 2020 04:24:29 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:38218 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726406AbgCMIY2 (ORCPT ); Fri, 13 Mar 2020 04:24:28 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id BF70989F9F3AB0862FD1; Fri, 13 Mar 2020 16:24:22 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Fri, 13 Mar 2020 16:24:15 +0800 From: Huazhong Tan To: CC: , , , , , , Jian Shen , Huazhong Tan Subject: [PATCH net-next 1/2] net: hns3: add a conversion for mailbox's response code Date: Fri, 13 Mar 2020 16:23:42 +0800 Message-ID: <1584087823-61800-2-git-send-email-tanhuazhong@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1584087823-61800-1-git-send-email-tanhuazhong@huawei.com> References: <1584087823-61800-1-git-send-email-tanhuazhong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jian Shen Currently, when mailbox handling fails, the PF driver just responds 1 to the VF driver. It is not sufficient for the VF driver to find out why its mailbox fails. So the error should be responded to VF, but the error is type int and the response field in struct hclge_mbx_pf_to_vf_cmd is type u16, a conversion is needed. Signed-off-by: Jian Shen Signed-off-by: Huazhong Tan --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 16 +++++++++++++++- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c | 7 ++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c index 3d850f6..b5dcbc6 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c @@ -5,6 +5,11 @@ #include "hclge_mbx.h" #include "hnae3.h" +static u16 hclge_errno_to_resp(int errno) +{ + return abs(errno); +} + /* hclge_gen_resp_to_vf: used to generate a synchronous response to VF when PF * receives a mailbox message from VF. * @vport: pointer to struct hclge_vport @@ -21,6 +26,7 @@ static int hclge_gen_resp_to_vf(struct hclge_vport *vport, struct hclge_dev *hdev = vport->back; enum hclge_cmd_status status; struct hclge_desc desc; + u16 resp; resp_pf_to_vf = (struct hclge_mbx_pf_to_vf_cmd *)desc.data; @@ -43,7 +49,15 @@ static int hclge_gen_resp_to_vf(struct hclge_vport *vport, resp_pf_to_vf->msg[0] = HCLGE_MBX_PF_VF_RESP; resp_pf_to_vf->msg[1] = vf_to_pf_req->msg[0]; resp_pf_to_vf->msg[2] = vf_to_pf_req->msg[1]; - resp_pf_to_vf->msg[3] = (resp_status == 0) ? 0 : 1; + resp = hclge_errno_to_resp(resp_status); + if (resp < SHRT_MAX) { + resp_pf_to_vf->msg[3] = resp; + } else { + dev_err(&hdev->pdev->dev, + "failed to send response to VF, response status %d is out-of-bound\n", + resp); + return -EINVAL; + } if (resp_data && resp_data_len > 0) memcpy(&resp_pf_to_vf->msg[4], resp_data, resp_data_len); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c index 7cbd715..5b481f9 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c @@ -5,6 +5,11 @@ #include "hclgevf_main.h" #include "hnae3.h" +static int hclgevf_resp_to_errno(u16 resp_code) +{ + return resp_code ? -resp_code : 0; +} + static void hclgevf_reset_mbx_resp_status(struct hclgevf_dev *hdev) { /* this function should be called with mbx_resp.mbx_mutex held @@ -193,7 +198,7 @@ void hclgevf_mbx_handler(struct hclgevf_dev *hdev) resp->origin_mbx_msg = (req->msg[1] << 16); resp->origin_mbx_msg |= req->msg[2]; - resp->resp_status = req->msg[3]; + resp->resp_status = hclgevf_resp_to_errno(req->msg[3]); temp = (u8 *)&req->msg[4]; for (i = 0; i < HCLGE_MBX_MAX_RESP_DATA_SIZE; i++) { -- 2.7.4