Commit 027fd531 authored by Jian Shen's avatar Jian Shen Committed by David S. Miller

net: hns3: add a conversion for mailbox's response code

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: default avatarJian Shen <shenjian15@huawei.com>
Signed-off-by: default avatarHuazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 09984483
...@@ -5,6 +5,11 @@ ...@@ -5,6 +5,11 @@
#include "hclge_mbx.h" #include "hclge_mbx.h"
#include "hnae3.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 /* hclge_gen_resp_to_vf: used to generate a synchronous response to VF when PF
* receives a mailbox message from VF. * receives a mailbox message from VF.
* @vport: pointer to struct hclge_vport * @vport: pointer to struct hclge_vport
...@@ -21,6 +26,7 @@ static int hclge_gen_resp_to_vf(struct hclge_vport *vport, ...@@ -21,6 +26,7 @@ static int hclge_gen_resp_to_vf(struct hclge_vport *vport,
struct hclge_dev *hdev = vport->back; struct hclge_dev *hdev = vport->back;
enum hclge_cmd_status status; enum hclge_cmd_status status;
struct hclge_desc desc; struct hclge_desc desc;
u16 resp;
resp_pf_to_vf = (struct hclge_mbx_pf_to_vf_cmd *)desc.data; 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, ...@@ -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[0] = HCLGE_MBX_PF_VF_RESP;
resp_pf_to_vf->msg[1] = vf_to_pf_req->msg[0]; 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[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_warn(&hdev->pdev->dev,
"failed to send response to VF, response status %d is out-of-bound\n",
resp);
resp_pf_to_vf->msg[3] = EIO;
}
if (resp_data && resp_data_len > 0) if (resp_data && resp_data_len > 0)
memcpy(&resp_pf_to_vf->msg[4], resp_data, resp_data_len); memcpy(&resp_pf_to_vf->msg[4], resp_data, resp_data_len);
......
...@@ -5,6 +5,11 @@ ...@@ -5,6 +5,11 @@
#include "hclgevf_main.h" #include "hclgevf_main.h"
#include "hnae3.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) static void hclgevf_reset_mbx_resp_status(struct hclgevf_dev *hdev)
{ {
/* this function should be called with mbx_resp.mbx_mutex held /* this function should be called with mbx_resp.mbx_mutex held
...@@ -193,7 +198,7 @@ void hclgevf_mbx_handler(struct hclgevf_dev *hdev) ...@@ -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[1] << 16);
resp->origin_mbx_msg |= req->msg[2]; 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]; temp = (u8 *)&req->msg[4];
for (i = 0; i < HCLGE_MBX_MAX_RESP_DATA_SIZE; i++) { for (i = 0; i < HCLGE_MBX_MAX_RESP_DATA_SIZE; i++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment