Commit fe1f4fc1 authored by David S. Miller's avatar David S. Miller

Merge branch 'net-hns3-add-three-optimizations-for-mailbox-handling'

Huazhong Tan says:

====================
net: hns3: add three optimizations for mailbox handling

This patchset includes three code optimizations for mailbox handling.

[patch 1] adds a response code conversion.
[patch 2] refactors some structure definitions about PF and
VF mailbox.
[patch 3] refactors the condition whether PF responds VF's mailbox.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 09984483 bb5790b7
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/types.h> #include <linux/types.h>
#define HCLGE_MBX_VF_MSG_DATA_NUM 16
enum HCLGE_MBX_OPCODE { enum HCLGE_MBX_OPCODE {
HCLGE_MBX_RESET = 0x01, /* (VF -> PF) assert reset */ HCLGE_MBX_RESET = 0x01, /* (VF -> PF) assert reset */
HCLGE_MBX_ASSERTING_RESET, /* (PF -> VF) PF is asserting reset*/ HCLGE_MBX_ASSERTING_RESET, /* (PF -> VF) PF is asserting reset*/
...@@ -72,10 +70,15 @@ enum hclge_mbx_vlan_cfg_subcode { ...@@ -72,10 +70,15 @@ enum hclge_mbx_vlan_cfg_subcode {
HCLGE_MBX_GET_PORT_BASE_VLAN_STATE, /* get port based vlan state */ HCLGE_MBX_GET_PORT_BASE_VLAN_STATE, /* get port based vlan state */
}; };
#define HCLGE_MBX_MAX_MSG_SIZE 16 #define HCLGE_MBX_MAX_MSG_SIZE 14
#define HCLGE_MBX_MAX_RESP_DATA_SIZE 8U #define HCLGE_MBX_MAX_RESP_DATA_SIZE 8U
#define HCLGE_MBX_RING_MAP_BASIC_MSG_NUM 3 #define HCLGE_MBX_MAX_RING_CHAIN_PARAM_NUM 4
#define HCLGE_MBX_RING_NODE_VARIABLE_NUM 3
struct hclge_ring_chain_param {
u8 ring_type;
u8 tqp_index;
u8 int_gl_index;
};
struct hclgevf_mbx_resp_status { struct hclgevf_mbx_resp_status {
struct mutex mbx_mutex; /* protects against contending sync cmd resp */ struct mutex mbx_mutex; /* protects against contending sync cmd resp */
...@@ -85,6 +88,41 @@ struct hclgevf_mbx_resp_status { ...@@ -85,6 +88,41 @@ struct hclgevf_mbx_resp_status {
u8 additional_info[HCLGE_MBX_MAX_RESP_DATA_SIZE]; u8 additional_info[HCLGE_MBX_MAX_RESP_DATA_SIZE];
}; };
struct hclge_respond_to_vf_msg {
int status;
u8 data[HCLGE_MBX_MAX_RESP_DATA_SIZE];
u16 len;
};
struct hclge_vf_to_pf_msg {
u8 code;
union {
struct {
u8 subcode;
u8 data[HCLGE_MBX_MAX_MSG_SIZE];
};
struct {
u8 en_bc;
u8 en_uc;
u8 en_mc;
};
struct {
u8 vector_id;
u8 ring_num;
struct hclge_ring_chain_param
param[HCLGE_MBX_MAX_RING_CHAIN_PARAM_NUM];
};
};
};
struct hclge_pf_to_vf_msg {
u16 code;
u16 vf_mbx_msg_code;
u16 vf_mbx_msg_subcode;
u16 resp_status;
u8 resp_data[HCLGE_MBX_MAX_RESP_DATA_SIZE];
};
struct hclge_mbx_vf_to_pf_cmd { struct hclge_mbx_vf_to_pf_cmd {
u8 rsv; u8 rsv;
u8 mbx_src_vfid; /* Auto filled by IMP */ u8 mbx_src_vfid; /* Auto filled by IMP */
...@@ -92,17 +130,17 @@ struct hclge_mbx_vf_to_pf_cmd { ...@@ -92,17 +130,17 @@ struct hclge_mbx_vf_to_pf_cmd {
u8 rsv1[1]; u8 rsv1[1];
u8 msg_len; u8 msg_len;
u8 rsv2[3]; u8 rsv2[3];
u8 msg[HCLGE_MBX_MAX_MSG_SIZE]; struct hclge_vf_to_pf_msg msg;
}; };
#define HCLGE_MBX_NEED_RESP_BIT BIT(0) #define HCLGE_MBX_NEED_RESP_B 0
struct hclge_mbx_pf_to_vf_cmd { struct hclge_mbx_pf_to_vf_cmd {
u8 dest_vfid; u8 dest_vfid;
u8 rsv[3]; u8 rsv[3];
u8 msg_len; u8 msg_len;
u8 rsv1[3]; u8 rsv1[3];
u16 msg[8]; struct hclge_pf_to_vf_msg msg;
}; };
struct hclge_vf_rst_cmd { struct hclge_vf_rst_cmd {
......
...@@ -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
...@@ -14,25 +19,25 @@ ...@@ -14,25 +19,25 @@
*/ */
static int hclge_gen_resp_to_vf(struct hclge_vport *vport, static int hclge_gen_resp_to_vf(struct hclge_vport *vport,
struct hclge_mbx_vf_to_pf_cmd *vf_to_pf_req, struct hclge_mbx_vf_to_pf_cmd *vf_to_pf_req,
int resp_status, struct hclge_respond_to_vf_msg *resp_msg)
u8 *resp_data, u16 resp_data_len)
{ {
struct hclge_mbx_pf_to_vf_cmd *resp_pf_to_vf; struct hclge_mbx_pf_to_vf_cmd *resp_pf_to_vf;
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;
if (resp_data_len > HCLGE_MBX_MAX_RESP_DATA_SIZE) { if (resp_msg->len > HCLGE_MBX_MAX_RESP_DATA_SIZE) {
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
"PF fail to gen resp to VF len %u exceeds max len %u\n", "PF fail to gen resp to VF len %u exceeds max len %u\n",
resp_data_len, resp_msg->len,
HCLGE_MBX_MAX_RESP_DATA_SIZE); HCLGE_MBX_MAX_RESP_DATA_SIZE);
/* If resp_data_len is too long, set the value to max length /* If resp_msg->len is too long, set the value to max length
* and return the msg to VF * and return the msg to VF
*/ */
resp_data_len = HCLGE_MBX_MAX_RESP_DATA_SIZE; resp_msg->len = HCLGE_MBX_MAX_RESP_DATA_SIZE;
} }
hclge_cmd_setup_basic_desc(&desc, HCLGEVF_OPC_MBX_PF_TO_VF, false); hclge_cmd_setup_basic_desc(&desc, HCLGEVF_OPC_MBX_PF_TO_VF, false);
...@@ -40,18 +45,29 @@ static int hclge_gen_resp_to_vf(struct hclge_vport *vport, ...@@ -40,18 +45,29 @@ 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->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->msg_len = vf_to_pf_req->msg_len;
resp_pf_to_vf->msg[0] = HCLGE_MBX_PF_VF_RESP; resp_pf_to_vf->msg.code = HCLGE_MBX_PF_VF_RESP;
resp_pf_to_vf->msg[1] = vf_to_pf_req->msg[0]; resp_pf_to_vf->msg.vf_mbx_msg_code = vf_to_pf_req->msg.code;
resp_pf_to_vf->msg[2] = vf_to_pf_req->msg[1]; resp_pf_to_vf->msg.vf_mbx_msg_subcode = vf_to_pf_req->msg.subcode;
resp_pf_to_vf->msg[3] = (resp_status == 0) ? 0 : 1; resp = hclge_errno_to_resp(resp_msg->status);
if (resp < SHRT_MAX) {
resp_pf_to_vf->msg.resp_status = 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.resp_status = EIO;
}
if (resp_data && resp_data_len > 0) if (resp_msg->len > 0)
memcpy(&resp_pf_to_vf->msg[4], resp_data, resp_data_len); memcpy(resp_pf_to_vf->msg.resp_data, resp_msg->data,
resp_msg->len);
status = hclge_cmd_send(&hdev->hw, &desc, 1); status = hclge_cmd_send(&hdev->hw, &desc, 1);
if (status) if (status)
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
"PF failed(=%d) to send response to VF\n", status); "failed to send response to VF, status: %d, vfid: %u, code: %u, subcode: %u.\n",
status, vf_to_pf_req->mbx_src_vfid,
vf_to_pf_req->msg.code, vf_to_pf_req->msg.subcode);
return status; return status;
} }
...@@ -70,15 +86,15 @@ static int hclge_send_mbx_msg(struct hclge_vport *vport, u8 *msg, u16 msg_len, ...@@ -70,15 +86,15 @@ static int hclge_send_mbx_msg(struct hclge_vport *vport, u8 *msg, u16 msg_len,
resp_pf_to_vf->dest_vfid = dest_vfid; resp_pf_to_vf->dest_vfid = dest_vfid;
resp_pf_to_vf->msg_len = msg_len; resp_pf_to_vf->msg_len = msg_len;
resp_pf_to_vf->msg[0] = mbx_opcode; resp_pf_to_vf->msg.code = mbx_opcode;
memcpy(&resp_pf_to_vf->msg[1], msg, msg_len); memcpy(&resp_pf_to_vf->msg.vf_mbx_msg_code, msg, msg_len);
status = hclge_cmd_send(&hdev->hw, &desc, 1); status = hclge_cmd_send(&hdev->hw, &desc, 1);
if (status) if (status)
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
"PF failed(=%d) to send mailbox message to VF\n", "failed to send mailbox to VF, status: %d, vfid: %u, opcode: %u\n",
status); status, dest_vfid, mbx_opcode);
return status; return status;
} }
...@@ -138,21 +154,20 @@ static int hclge_get_ring_chain_from_mbx( ...@@ -138,21 +154,20 @@ static int hclge_get_ring_chain_from_mbx(
{ {
struct hnae3_ring_chain_node *cur_chain, *new_chain; struct hnae3_ring_chain_node *cur_chain, *new_chain;
int ring_num; int ring_num;
int i; int i = 0;
ring_num = req->msg[2]; ring_num = req->msg.ring_num;
if (ring_num > ((HCLGE_MBX_VF_MSG_DATA_NUM - if (ring_num > HCLGE_MBX_MAX_RING_CHAIN_PARAM_NUM)
HCLGE_MBX_RING_MAP_BASIC_MSG_NUM) /
HCLGE_MBX_RING_NODE_VARIABLE_NUM))
return -ENOMEM; return -ENOMEM;
hnae3_set_bit(ring_chain->flag, HNAE3_RING_TYPE_B, req->msg[3]); hnae3_set_bit(ring_chain->flag, HNAE3_RING_TYPE_B,
req->msg.param[i].ring_type);
ring_chain->tqp_index = ring_chain->tqp_index =
hclge_get_queue_id(vport->nic.kinfo.tqp[req->msg[4]]); hclge_get_queue_id(vport->nic.kinfo.tqp
[req->msg.param[i].tqp_index]);
hnae3_set_field(ring_chain->int_gl_idx, HNAE3_RING_GL_IDX_M, hnae3_set_field(ring_chain->int_gl_idx, HNAE3_RING_GL_IDX_M,
HNAE3_RING_GL_IDX_S, HNAE3_RING_GL_IDX_S, req->msg.param[i].int_gl_index);
req->msg[5]);
cur_chain = ring_chain; cur_chain = ring_chain;
...@@ -162,18 +177,15 @@ static int hclge_get_ring_chain_from_mbx( ...@@ -162,18 +177,15 @@ static int hclge_get_ring_chain_from_mbx(
goto err; goto err;
hnae3_set_bit(new_chain->flag, HNAE3_RING_TYPE_B, hnae3_set_bit(new_chain->flag, HNAE3_RING_TYPE_B,
req->msg[HCLGE_MBX_RING_NODE_VARIABLE_NUM * i + req->msg.param[i].ring_type);
HCLGE_MBX_RING_MAP_BASIC_MSG_NUM]);
new_chain->tqp_index = new_chain->tqp_index =
hclge_get_queue_id(vport->nic.kinfo.tqp hclge_get_queue_id(vport->nic.kinfo.tqp
[req->msg[HCLGE_MBX_RING_NODE_VARIABLE_NUM * i + [req->msg.param[i].tqp_index]);
HCLGE_MBX_RING_MAP_BASIC_MSG_NUM + 1]]);
hnae3_set_field(new_chain->int_gl_idx, HNAE3_RING_GL_IDX_M, hnae3_set_field(new_chain->int_gl_idx, HNAE3_RING_GL_IDX_M,
HNAE3_RING_GL_IDX_S, HNAE3_RING_GL_IDX_S,
req->msg[HCLGE_MBX_RING_NODE_VARIABLE_NUM * i + req->msg.param[i].int_gl_index);
HCLGE_MBX_RING_MAP_BASIC_MSG_NUM + 2]);
cur_chain->next = new_chain; cur_chain->next = new_chain;
cur_chain = new_chain; cur_chain = new_chain;
...@@ -189,7 +201,7 @@ static int hclge_map_unmap_ring_to_vf_vector(struct hclge_vport *vport, bool en, ...@@ -189,7 +201,7 @@ static int hclge_map_unmap_ring_to_vf_vector(struct hclge_vport *vport, bool en,
struct hclge_mbx_vf_to_pf_cmd *req) struct hclge_mbx_vf_to_pf_cmd *req)
{ {
struct hnae3_ring_chain_node ring_chain; struct hnae3_ring_chain_node ring_chain;
int vector_id = req->msg[1]; int vector_id = req->msg.vector_id;
int ret; int ret;
memset(&ring_chain, 0, sizeof(ring_chain)); memset(&ring_chain, 0, sizeof(ring_chain));
...@@ -207,13 +219,9 @@ static int hclge_map_unmap_ring_to_vf_vector(struct hclge_vport *vport, bool en, ...@@ -207,13 +219,9 @@ static int hclge_map_unmap_ring_to_vf_vector(struct hclge_vport *vport, bool en,
static int hclge_set_vf_promisc_mode(struct hclge_vport *vport, static int hclge_set_vf_promisc_mode(struct hclge_vport *vport,
struct hclge_mbx_vf_to_pf_cmd *req) struct hclge_mbx_vf_to_pf_cmd *req)
{ {
#define HCLGE_MBX_BC_INDEX 1 bool en_bc = req->msg.en_bc ? true : false;
#define HCLGE_MBX_UC_INDEX 2 bool en_uc = req->msg.en_uc ? true : false;
#define HCLGE_MBX_MC_INDEX 3 bool en_mc = req->msg.en_mc ? true : false;
bool en_bc = req->msg[HCLGE_MBX_BC_INDEX] ? true : false;
bool en_uc = req->msg[HCLGE_MBX_UC_INDEX] ? true : false;
bool en_mc = req->msg[HCLGE_MBX_MC_INDEX] ? true : false;
int ret; int ret;
if (!vport->vf_info.trusted) { if (!vport->vf_info.trusted) {
...@@ -222,8 +230,6 @@ static int hclge_set_vf_promisc_mode(struct hclge_vport *vport, ...@@ -222,8 +230,6 @@ static int hclge_set_vf_promisc_mode(struct hclge_vport *vport,
} }
ret = hclge_set_vport_promisc_mode(vport, en_uc, en_mc, en_bc); ret = hclge_set_vport_promisc_mode(vport, en_uc, en_mc, en_bc);
if (req->mbx_need_resp)
hclge_gen_resp_to_vf(vport, req, ret, NULL, 0);
vport->vf_info.promisc_enable = (en_uc || en_mc) ? 1 : 0; vport->vf_info.promisc_enable = (en_uc || en_mc) ? 1 : 0;
...@@ -244,26 +250,25 @@ void hclge_inform_vf_promisc_info(struct hclge_vport *vport) ...@@ -244,26 +250,25 @@ void hclge_inform_vf_promisc_info(struct hclge_vport *vport)
static int hclge_set_vf_uc_mac_addr(struct hclge_vport *vport, static int hclge_set_vf_uc_mac_addr(struct hclge_vport *vport,
struct hclge_mbx_vf_to_pf_cmd *mbx_req) struct hclge_mbx_vf_to_pf_cmd *mbx_req)
{ {
const u8 *mac_addr = (const u8 *)(&mbx_req->msg[2]); #define HCLGE_MBX_VF_OLD_MAC_ADDR_OFFSET 6
const u8 *mac_addr = (const u8 *)(mbx_req->msg.data);
struct hclge_dev *hdev = vport->back; struct hclge_dev *hdev = vport->back;
int status; int status;
if (mbx_req->msg[1] == HCLGE_MBX_MAC_VLAN_UC_MODIFY) { if (mbx_req->msg.subcode == HCLGE_MBX_MAC_VLAN_UC_MODIFY) {
const u8 *old_addr = (const u8 *)(&mbx_req->msg[8]); const u8 *old_addr = (const u8 *)
(&mbx_req->msg.data[HCLGE_MBX_VF_OLD_MAC_ADDR_OFFSET]);
/* If VF MAC has been configured by the host then it /* If VF MAC has been configured by the host then it
* cannot be overridden by the MAC specified by the VM. * cannot be overridden by the MAC specified by the VM.
*/ */
if (!is_zero_ether_addr(vport->vf_info.mac) && if (!is_zero_ether_addr(vport->vf_info.mac) &&
!ether_addr_equal(mac_addr, vport->vf_info.mac)) { !ether_addr_equal(mac_addr, vport->vf_info.mac))
status = -EPERM; return -EPERM;
goto out;
}
if (!is_valid_ether_addr(mac_addr)) { if (!is_valid_ether_addr(mac_addr))
status = -EINVAL; return -EINVAL;
goto out;
}
hclge_rm_uc_addr_common(vport, old_addr); hclge_rm_uc_addr_common(vport, old_addr);
status = hclge_add_uc_addr_common(vport, mac_addr); status = hclge_add_uc_addr_common(vport, mac_addr);
...@@ -275,12 +280,12 @@ static int hclge_set_vf_uc_mac_addr(struct hclge_vport *vport, ...@@ -275,12 +280,12 @@ static int hclge_set_vf_uc_mac_addr(struct hclge_vport *vport,
hclge_add_vport_mac_table(vport, mac_addr, hclge_add_vport_mac_table(vport, mac_addr,
HCLGE_MAC_ADDR_UC); HCLGE_MAC_ADDR_UC);
} }
} else if (mbx_req->msg[1] == HCLGE_MBX_MAC_VLAN_UC_ADD) { } else if (mbx_req->msg.subcode == HCLGE_MBX_MAC_VLAN_UC_ADD) {
status = hclge_add_uc_addr_common(vport, mac_addr); status = hclge_add_uc_addr_common(vport, mac_addr);
if (!status) if (!status)
hclge_add_vport_mac_table(vport, mac_addr, hclge_add_vport_mac_table(vport, mac_addr,
HCLGE_MAC_ADDR_UC); HCLGE_MAC_ADDR_UC);
} else if (mbx_req->msg[1] == HCLGE_MBX_MAC_VLAN_UC_REMOVE) { } else if (mbx_req->msg.subcode == HCLGE_MBX_MAC_VLAN_UC_REMOVE) {
status = hclge_rm_uc_addr_common(vport, mac_addr); status = hclge_rm_uc_addr_common(vport, mac_addr);
if (!status) if (!status)
hclge_rm_vport_mac_table(vport, mac_addr, hclge_rm_vport_mac_table(vport, mac_addr,
...@@ -288,33 +293,26 @@ static int hclge_set_vf_uc_mac_addr(struct hclge_vport *vport, ...@@ -288,33 +293,26 @@ static int hclge_set_vf_uc_mac_addr(struct hclge_vport *vport,
} else { } else {
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
"failed to set unicast mac addr, unknown subcode %u\n", "failed to set unicast mac addr, unknown subcode %u\n",
mbx_req->msg[1]); mbx_req->msg.subcode);
return -EIO; return -EIO;
} }
out: return status;
if (mbx_req->mbx_need_resp & HCLGE_MBX_NEED_RESP_BIT)
hclge_gen_resp_to_vf(vport, mbx_req, status, NULL, 0);
return 0;
} }
static int hclge_set_vf_mc_mac_addr(struct hclge_vport *vport, static int hclge_set_vf_mc_mac_addr(struct hclge_vport *vport,
struct hclge_mbx_vf_to_pf_cmd *mbx_req, struct hclge_mbx_vf_to_pf_cmd *mbx_req)
bool gen_resp)
{ {
const u8 *mac_addr = (const u8 *)(&mbx_req->msg[2]); const u8 *mac_addr = (const u8 *)(mbx_req->msg.data);
struct hclge_dev *hdev = vport->back; struct hclge_dev *hdev = vport->back;
u8 resp_len = 0;
u8 resp_data;
int status; int status;
if (mbx_req->msg[1] == HCLGE_MBX_MAC_VLAN_MC_ADD) { if (mbx_req->msg.subcode == HCLGE_MBX_MAC_VLAN_MC_ADD) {
status = hclge_add_mc_addr_common(vport, mac_addr); status = hclge_add_mc_addr_common(vport, mac_addr);
if (!status) if (!status)
hclge_add_vport_mac_table(vport, mac_addr, hclge_add_vport_mac_table(vport, mac_addr,
HCLGE_MAC_ADDR_MC); HCLGE_MAC_ADDR_MC);
} else if (mbx_req->msg[1] == HCLGE_MBX_MAC_VLAN_MC_REMOVE) { } else if (mbx_req->msg.subcode == HCLGE_MBX_MAC_VLAN_MC_REMOVE) {
status = hclge_rm_mc_addr_common(vport, mac_addr); status = hclge_rm_mc_addr_common(vport, mac_addr);
if (!status) if (!status)
hclge_rm_vport_mac_table(vport, mac_addr, hclge_rm_vport_mac_table(vport, mac_addr,
...@@ -322,15 +320,11 @@ static int hclge_set_vf_mc_mac_addr(struct hclge_vport *vport, ...@@ -322,15 +320,11 @@ static int hclge_set_vf_mc_mac_addr(struct hclge_vport *vport,
} else { } else {
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
"failed to set mcast mac addr, unknown subcode %u\n", "failed to set mcast mac addr, unknown subcode %u\n",
mbx_req->msg[1]); mbx_req->msg.subcode);
return -EIO; return -EIO;
} }
if (gen_resp) return status;
hclge_gen_resp_to_vf(vport, mbx_req, status,
&resp_data, resp_len);
return 0;
} }
int hclge_push_vf_port_base_vlan_info(struct hclge_vport *vport, u8 vfid, int hclge_push_vf_port_base_vlan_info(struct hclge_vport *vport, u8 vfid,
...@@ -351,12 +345,16 @@ int hclge_push_vf_port_base_vlan_info(struct hclge_vport *vport, u8 vfid, ...@@ -351,12 +345,16 @@ int hclge_push_vf_port_base_vlan_info(struct hclge_vport *vport, u8 vfid,
} }
static int hclge_set_vf_vlan_cfg(struct hclge_vport *vport, static int hclge_set_vf_vlan_cfg(struct hclge_vport *vport,
struct hclge_mbx_vf_to_pf_cmd *mbx_req) struct hclge_mbx_vf_to_pf_cmd *mbx_req,
struct hclge_respond_to_vf_msg *resp_msg)
{ {
#define HCLGE_MBX_VLAN_STATE_OFFSET 0
#define HCLGE_MBX_VLAN_INFO_OFFSET 2
struct hclge_vf_vlan_cfg *msg_cmd; struct hclge_vf_vlan_cfg *msg_cmd;
int status = 0; int status = 0;
msg_cmd = (struct hclge_vf_vlan_cfg *)mbx_req->msg; msg_cmd = (struct hclge_vf_vlan_cfg *)&mbx_req->msg;
if (msg_cmd->subcode == HCLGE_MBX_VLAN_FILTER) { if (msg_cmd->subcode == HCLGE_MBX_VLAN_FILTER) {
struct hnae3_handle *handle = &vport->nic; struct hnae3_handle *handle = &vport->nic;
u16 vlan, proto; u16 vlan, proto;
...@@ -367,38 +365,32 @@ static int hclge_set_vf_vlan_cfg(struct hclge_vport *vport, ...@@ -367,38 +365,32 @@ static int hclge_set_vf_vlan_cfg(struct hclge_vport *vport,
proto = msg_cmd->proto; proto = msg_cmd->proto;
status = hclge_set_vlan_filter(handle, cpu_to_be16(proto), status = hclge_set_vlan_filter(handle, cpu_to_be16(proto),
vlan, is_kill); vlan, is_kill);
if (mbx_req->mbx_need_resp)
return hclge_gen_resp_to_vf(vport, mbx_req, status,
NULL, 0);
} else if (msg_cmd->subcode == HCLGE_MBX_VLAN_RX_OFF_CFG) { } else if (msg_cmd->subcode == HCLGE_MBX_VLAN_RX_OFF_CFG) {
struct hnae3_handle *handle = &vport->nic; struct hnae3_handle *handle = &vport->nic;
bool en = msg_cmd->is_kill ? true : false; bool en = msg_cmd->is_kill ? true : false;
status = hclge_en_hw_strip_rxvtag(handle, en); status = hclge_en_hw_strip_rxvtag(handle, en);
} else if (mbx_req->msg[1] == HCLGE_MBX_PORT_BASE_VLAN_CFG) { } else if (msg_cmd->subcode == HCLGE_MBX_PORT_BASE_VLAN_CFG) {
struct hclge_vlan_info *vlan_info; struct hclge_vlan_info *vlan_info;
u16 *state; u16 *state;
state = (u16 *)&mbx_req->msg[2]; state = (u16 *)&mbx_req->msg.data[HCLGE_MBX_VLAN_STATE_OFFSET];
vlan_info = (struct hclge_vlan_info *)&mbx_req->msg[4]; vlan_info = (struct hclge_vlan_info *)
&mbx_req->msg.data[HCLGE_MBX_VLAN_INFO_OFFSET];
status = hclge_update_port_base_vlan_cfg(vport, *state, status = hclge_update_port_base_vlan_cfg(vport, *state,
vlan_info); vlan_info);
} else if (mbx_req->msg[1] == HCLGE_MBX_GET_PORT_BASE_VLAN_STATE) { } else if (msg_cmd->subcode == HCLGE_MBX_GET_PORT_BASE_VLAN_STATE) {
u8 state; resp_msg->data[0] = vport->port_base_vlan_cfg.state;
resp_msg->len = sizeof(u8);
state = vport->port_base_vlan_cfg.state;
status = hclge_gen_resp_to_vf(vport, mbx_req, 0, &state,
sizeof(u8));
} }
return status; return status;
} }
static int hclge_set_vf_alive(struct hclge_vport *vport, static int hclge_set_vf_alive(struct hclge_vport *vport,
struct hclge_mbx_vf_to_pf_cmd *mbx_req, struct hclge_mbx_vf_to_pf_cmd *mbx_req)
bool gen_resp)
{ {
bool alive = !!mbx_req->msg[2]; bool alive = !!mbx_req->msg.data[0];
int ret = 0; int ret = 0;
if (alive) if (alive)
...@@ -409,73 +401,76 @@ static int hclge_set_vf_alive(struct hclge_vport *vport, ...@@ -409,73 +401,76 @@ static int hclge_set_vf_alive(struct hclge_vport *vport,
return ret; return ret;
} }
static int hclge_get_vf_tcinfo(struct hclge_vport *vport, static void hclge_get_vf_tcinfo(struct hclge_vport *vport,
struct hclge_mbx_vf_to_pf_cmd *mbx_req, struct hclge_respond_to_vf_msg *resp_msg)
bool gen_resp)
{ {
struct hnae3_knic_private_info *kinfo = &vport->nic.kinfo; struct hnae3_knic_private_info *kinfo = &vport->nic.kinfo;
u8 vf_tc_map = 0;
unsigned int i; unsigned int i;
int ret;
for (i = 0; i < kinfo->num_tc; i++) for (i = 0; i < kinfo->num_tc; i++)
vf_tc_map |= BIT(i); resp_msg->data[0] |= BIT(i);
ret = hclge_gen_resp_to_vf(vport, mbx_req, 0, &vf_tc_map,
sizeof(vf_tc_map));
return ret; resp_msg->len = sizeof(u8);
} }
static int hclge_get_vf_queue_info(struct hclge_vport *vport, static void hclge_get_vf_queue_info(struct hclge_vport *vport,
struct hclge_mbx_vf_to_pf_cmd *mbx_req, struct hclge_respond_to_vf_msg *resp_msg)
bool gen_resp)
{ {
#define HCLGE_TQPS_RSS_INFO_LEN 6 #define HCLGE_TQPS_RSS_INFO_LEN 6
u8 resp_data[HCLGE_TQPS_RSS_INFO_LEN]; #define HCLGE_TQPS_ALLOC_OFFSET 0
#define HCLGE_TQPS_RSS_SIZE_OFFSET 2
#define HCLGE_TQPS_RX_BUFFER_LEN_OFFSET 4
struct hclge_dev *hdev = vport->back; struct hclge_dev *hdev = vport->back;
/* get the queue related info */ /* get the queue related info */
memcpy(&resp_data[0], &vport->alloc_tqps, sizeof(u16)); memcpy(&resp_msg->data[HCLGE_TQPS_ALLOC_OFFSET],
memcpy(&resp_data[2], &vport->nic.kinfo.rss_size, sizeof(u16)); &vport->alloc_tqps, sizeof(u16));
memcpy(&resp_data[4], &hdev->rx_buf_len, sizeof(u16)); memcpy(&resp_msg->data[HCLGE_TQPS_RSS_SIZE_OFFSET],
&vport->nic.kinfo.rss_size, sizeof(u16));
return hclge_gen_resp_to_vf(vport, mbx_req, 0, resp_data, memcpy(&resp_msg->data[HCLGE_TQPS_RX_BUFFER_LEN_OFFSET],
HCLGE_TQPS_RSS_INFO_LEN); &hdev->rx_buf_len, sizeof(u16));
resp_msg->len = HCLGE_TQPS_RSS_INFO_LEN;
} }
static int hclge_get_vf_mac_addr(struct hclge_vport *vport, static void hclge_get_vf_mac_addr(struct hclge_vport *vport,
struct hclge_mbx_vf_to_pf_cmd *mbx_req) struct hclge_respond_to_vf_msg *resp_msg)
{ {
return hclge_gen_resp_to_vf(vport, mbx_req, 0, vport->vf_info.mac, ether_addr_copy(resp_msg->data, vport->vf_info.mac);
ETH_ALEN); resp_msg->len = ETH_ALEN;
} }
static int hclge_get_vf_queue_depth(struct hclge_vport *vport, static void hclge_get_vf_queue_depth(struct hclge_vport *vport,
struct hclge_mbx_vf_to_pf_cmd *mbx_req, struct hclge_respond_to_vf_msg *resp_msg)
bool gen_resp)
{ {
#define HCLGE_TQPS_DEPTH_INFO_LEN 4 #define HCLGE_TQPS_DEPTH_INFO_LEN 4
u8 resp_data[HCLGE_TQPS_DEPTH_INFO_LEN]; #define HCLGE_TQPS_NUM_TX_DESC_OFFSET 0
#define HCLGE_TQPS_NUM_RX_DESC_OFFSET 2
struct hclge_dev *hdev = vport->back; struct hclge_dev *hdev = vport->back;
/* get the queue depth info */ /* get the queue depth info */
memcpy(&resp_data[0], &hdev->num_tx_desc, sizeof(u16)); memcpy(&resp_msg->data[HCLGE_TQPS_NUM_TX_DESC_OFFSET],
memcpy(&resp_data[2], &hdev->num_rx_desc, sizeof(u16)); &hdev->num_tx_desc, sizeof(u16));
return hclge_gen_resp_to_vf(vport, mbx_req, 0, resp_data, memcpy(&resp_msg->data[HCLGE_TQPS_NUM_RX_DESC_OFFSET],
HCLGE_TQPS_DEPTH_INFO_LEN); &hdev->num_rx_desc, sizeof(u16));
resp_msg->len = HCLGE_TQPS_DEPTH_INFO_LEN;
} }
static int hclge_get_vf_media_type(struct hclge_vport *vport, static void hclge_get_vf_media_type(struct hclge_vport *vport,
struct hclge_mbx_vf_to_pf_cmd *mbx_req) struct hclge_respond_to_vf_msg *resp_msg)
{ {
#define HCLGE_VF_MEDIA_TYPE_OFFSET 0
#define HCLGE_VF_MODULE_TYPE_OFFSET 1
#define HCLGE_VF_MEDIA_TYPE_LENGTH 2
struct hclge_dev *hdev = vport->back; struct hclge_dev *hdev = vport->back;
u8 resp_data[2];
resp_data[0] = hdev->hw.mac.media_type; resp_msg->data[HCLGE_VF_MEDIA_TYPE_OFFSET] =
resp_data[1] = hdev->hw.mac.module_type; hdev->hw.mac.media_type;
return hclge_gen_resp_to_vf(vport, mbx_req, 0, resp_data, resp_msg->data[HCLGE_VF_MODULE_TYPE_OFFSET] =
sizeof(resp_data)); hdev->hw.mac.module_type;
resp_msg->len = HCLGE_VF_MEDIA_TYPE_LENGTH;
} }
static int hclge_get_link_info(struct hclge_vport *vport, static int hclge_get_link_info(struct hclge_vport *vport,
...@@ -529,7 +524,7 @@ static void hclge_get_link_mode(struct hclge_vport *vport, ...@@ -529,7 +524,7 @@ static void hclge_get_link_mode(struct hclge_vport *vport,
advertising = hdev->hw.mac.advertising[0]; advertising = hdev->hw.mac.advertising[0];
supported = hdev->hw.mac.supported[0]; supported = hdev->hw.mac.supported[0];
dest_vfid = mbx_req->mbx_src_vfid; dest_vfid = mbx_req->mbx_src_vfid;
msg_data[0] = mbx_req->msg[2]; msg_data[0] = mbx_req->msg.data[0];
send_data = msg_data[0] == HCLGE_SUPPORTED ? supported : advertising; send_data = msg_data[0] == HCLGE_SUPPORTED ? supported : advertising;
...@@ -543,29 +538,22 @@ static void hclge_mbx_reset_vf_queue(struct hclge_vport *vport, ...@@ -543,29 +538,22 @@ static void hclge_mbx_reset_vf_queue(struct hclge_vport *vport,
{ {
u16 queue_id; u16 queue_id;
memcpy(&queue_id, &mbx_req->msg[2], sizeof(queue_id)); memcpy(&queue_id, mbx_req->msg.data, sizeof(queue_id));
hclge_reset_vf_queue(vport, queue_id); hclge_reset_vf_queue(vport, queue_id);
/* send response msg to VF after queue reset complete */
hclge_gen_resp_to_vf(vport, mbx_req, 0, NULL, 0);
} }
static void hclge_reset_vf(struct hclge_vport *vport, static int hclge_reset_vf(struct hclge_vport *vport)
struct hclge_mbx_vf_to_pf_cmd *mbx_req)
{ {
struct hclge_dev *hdev = vport->back; struct hclge_dev *hdev = vport->back;
int ret;
dev_warn(&hdev->pdev->dev, "PF received VF reset request from VF %u!", dev_warn(&hdev->pdev->dev, "PF received VF reset request from VF %u!",
vport->vport_id); vport->vport_id);
ret = hclge_func_reset_cmd(hdev, vport->vport_id); return hclge_func_reset_cmd(hdev, vport->vport_id);
hclge_gen_resp_to_vf(vport, mbx_req, ret, NULL, 0);
} }
static void hclge_vf_keep_alive(struct hclge_vport *vport, static void hclge_vf_keep_alive(struct hclge_vport *vport)
struct hclge_mbx_vf_to_pf_cmd *mbx_req)
{ {
vport->last_active_jiffies = jiffies; vport->last_active_jiffies = jiffies;
} }
...@@ -573,45 +561,39 @@ static void hclge_vf_keep_alive(struct hclge_vport *vport, ...@@ -573,45 +561,39 @@ static void hclge_vf_keep_alive(struct hclge_vport *vport,
static int hclge_set_vf_mtu(struct hclge_vport *vport, static int hclge_set_vf_mtu(struct hclge_vport *vport,
struct hclge_mbx_vf_to_pf_cmd *mbx_req) struct hclge_mbx_vf_to_pf_cmd *mbx_req)
{ {
int ret;
u32 mtu; u32 mtu;
memcpy(&mtu, &mbx_req->msg[2], sizeof(mtu)); memcpy(&mtu, mbx_req->msg.data, sizeof(mtu));
ret = hclge_set_vport_mtu(vport, mtu);
return hclge_gen_resp_to_vf(vport, mbx_req, ret, NULL, 0); return hclge_set_vport_mtu(vport, mtu);
} }
static int hclge_get_queue_id_in_pf(struct hclge_vport *vport, static void hclge_get_queue_id_in_pf(struct hclge_vport *vport,
struct hclge_mbx_vf_to_pf_cmd *mbx_req) struct hclge_mbx_vf_to_pf_cmd *mbx_req,
struct hclge_respond_to_vf_msg *resp_msg)
{ {
u16 queue_id, qid_in_pf; u16 queue_id, qid_in_pf;
u8 resp_data[2];
memcpy(&queue_id, &mbx_req->msg[2], sizeof(queue_id)); memcpy(&queue_id, mbx_req->msg.data, sizeof(queue_id));
qid_in_pf = hclge_covert_handle_qid_global(&vport->nic, queue_id); qid_in_pf = hclge_covert_handle_qid_global(&vport->nic, queue_id);
memcpy(resp_data, &qid_in_pf, sizeof(qid_in_pf)); memcpy(resp_msg->data, &qid_in_pf, sizeof(qid_in_pf));
resp_msg->len = sizeof(qid_in_pf);
return hclge_gen_resp_to_vf(vport, mbx_req, 0, resp_data,
sizeof(resp_data));
} }
static int hclge_get_rss_key(struct hclge_vport *vport, static void hclge_get_rss_key(struct hclge_vport *vport,
struct hclge_mbx_vf_to_pf_cmd *mbx_req) struct hclge_mbx_vf_to_pf_cmd *mbx_req,
struct hclge_respond_to_vf_msg *resp_msg)
{ {
#define HCLGE_RSS_MBX_RESP_LEN 8 #define HCLGE_RSS_MBX_RESP_LEN 8
u8 resp_data[HCLGE_RSS_MBX_RESP_LEN];
struct hclge_dev *hdev = vport->back; struct hclge_dev *hdev = vport->back;
u8 index; u8 index;
index = mbx_req->msg[2]; index = mbx_req->msg.data[0];
memcpy(&resp_data[0], memcpy(resp_msg->data,
&hdev->vport[0].rss_hash_key[index * HCLGE_RSS_MBX_RESP_LEN], &hdev->vport[0].rss_hash_key[index * HCLGE_RSS_MBX_RESP_LEN],
HCLGE_RSS_MBX_RESP_LEN); HCLGE_RSS_MBX_RESP_LEN);
resp_msg->len = HCLGE_RSS_MBX_RESP_LEN;
return hclge_gen_resp_to_vf(vport, mbx_req, 0, resp_data,
HCLGE_RSS_MBX_RESP_LEN);
} }
static void hclge_link_fail_parse(struct hclge_dev *hdev, u8 link_fail_code) static void hclge_link_fail_parse(struct hclge_dev *hdev, u8 link_fail_code)
...@@ -634,13 +616,10 @@ static void hclge_link_fail_parse(struct hclge_dev *hdev, u8 link_fail_code) ...@@ -634,13 +616,10 @@ static void hclge_link_fail_parse(struct hclge_dev *hdev, u8 link_fail_code)
static void hclge_handle_link_change_event(struct hclge_dev *hdev, static void hclge_handle_link_change_event(struct hclge_dev *hdev,
struct hclge_mbx_vf_to_pf_cmd *req) struct hclge_mbx_vf_to_pf_cmd *req)
{ {
#define LINK_STATUS_OFFSET 1
#define LINK_FAIL_CODE_OFFSET 2
hclge_task_schedule(hdev, 0); hclge_task_schedule(hdev, 0);
if (!req->msg[LINK_STATUS_OFFSET]) if (!req->msg.subcode)
hclge_link_fail_parse(hdev, req->msg[LINK_FAIL_CODE_OFFSET]); hclge_link_fail_parse(hdev, req->msg.data[0]);
} }
static bool hclge_cmd_crq_empty(struct hclge_hw *hw) static bool hclge_cmd_crq_empty(struct hclge_hw *hw)
...@@ -662,12 +641,14 @@ static void hclge_handle_ncsi_error(struct hclge_dev *hdev) ...@@ -662,12 +641,14 @@ static void hclge_handle_ncsi_error(struct hclge_dev *hdev)
void hclge_mbx_handler(struct hclge_dev *hdev) void hclge_mbx_handler(struct hclge_dev *hdev)
{ {
struct hclge_cmq_ring *crq = &hdev->hw.cmq.crq; struct hclge_cmq_ring *crq = &hdev->hw.cmq.crq;
struct hclge_respond_to_vf_msg resp_msg;
struct hclge_mbx_vf_to_pf_cmd *req; struct hclge_mbx_vf_to_pf_cmd *req;
struct hclge_vport *vport; struct hclge_vport *vport;
struct hclge_desc *desc; struct hclge_desc *desc;
unsigned int flag; unsigned int flag;
int ret; int ret = 0;
memset(&resp_msg, 0, sizeof(resp_msg));
/* handle all the mailbox requests in the queue */ /* handle all the mailbox requests in the queue */
while (!hclge_cmd_crq_empty(&hdev->hw)) { while (!hclge_cmd_crq_empty(&hdev->hw)) {
if (test_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state)) { if (test_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state)) {
...@@ -683,7 +664,7 @@ void hclge_mbx_handler(struct hclge_dev *hdev) ...@@ -683,7 +664,7 @@ void hclge_mbx_handler(struct hclge_dev *hdev)
if (unlikely(!hnae3_get_bit(flag, HCLGE_CMDQ_RX_OUTVLD_B))) { if (unlikely(!hnae3_get_bit(flag, HCLGE_CMDQ_RX_OUTVLD_B))) {
dev_warn(&hdev->pdev->dev, dev_warn(&hdev->pdev->dev,
"dropped invalid mailbox message, code = %u\n", "dropped invalid mailbox message, code = %u\n",
req->msg[0]); req->msg.code);
/* dropping/not processing this invalid message */ /* dropping/not processing this invalid message */
crq->desc[crq->next_to_use].flag = 0; crq->desc[crq->next_to_use].flag = 0;
...@@ -693,7 +674,7 @@ void hclge_mbx_handler(struct hclge_dev *hdev) ...@@ -693,7 +674,7 @@ void hclge_mbx_handler(struct hclge_dev *hdev)
vport = &hdev->vport[req->mbx_src_vfid]; vport = &hdev->vport[req->mbx_src_vfid];
switch (req->msg[0]) { switch (req->msg.code) {
case HCLGE_MBX_MAP_RING_TO_VECTOR: case HCLGE_MBX_MAP_RING_TO_VECTOR:
ret = hclge_map_unmap_ring_to_vf_vector(vport, true, ret = hclge_map_unmap_ring_to_vf_vector(vport, true,
req); req);
...@@ -717,47 +698,34 @@ void hclge_mbx_handler(struct hclge_dev *hdev) ...@@ -717,47 +698,34 @@ void hclge_mbx_handler(struct hclge_dev *hdev)
ret); ret);
break; break;
case HCLGE_MBX_SET_MULTICAST: case HCLGE_MBX_SET_MULTICAST:
ret = hclge_set_vf_mc_mac_addr(vport, req, false); ret = hclge_set_vf_mc_mac_addr(vport, req);
if (ret) if (ret)
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
"PF fail(%d) to set VF MC MAC Addr\n", "PF fail(%d) to set VF MC MAC Addr\n",
ret); ret);
break; break;
case HCLGE_MBX_SET_VLAN: case HCLGE_MBX_SET_VLAN:
ret = hclge_set_vf_vlan_cfg(vport, req); ret = hclge_set_vf_vlan_cfg(vport, req, &resp_msg);
if (ret) if (ret)
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
"PF failed(%d) to config VF's VLAN\n", "PF failed(%d) to config VF's VLAN\n",
ret); ret);
break; break;
case HCLGE_MBX_SET_ALIVE: case HCLGE_MBX_SET_ALIVE:
ret = hclge_set_vf_alive(vport, req, false); ret = hclge_set_vf_alive(vport, req);
if (ret) if (ret)
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
"PF failed(%d) to set VF's ALIVE\n", "PF failed(%d) to set VF's ALIVE\n",
ret); ret);
break; break;
case HCLGE_MBX_GET_QINFO: case HCLGE_MBX_GET_QINFO:
ret = hclge_get_vf_queue_info(vport, req, true); hclge_get_vf_queue_info(vport, &resp_msg);
if (ret)
dev_err(&hdev->pdev->dev,
"PF failed(%d) to get Q info for VF\n",
ret);
break; break;
case HCLGE_MBX_GET_QDEPTH: case HCLGE_MBX_GET_QDEPTH:
ret = hclge_get_vf_queue_depth(vport, req, true); hclge_get_vf_queue_depth(vport, &resp_msg);
if (ret)
dev_err(&hdev->pdev->dev,
"PF failed(%d) to get Q depth for VF\n",
ret);
break; break;
case HCLGE_MBX_GET_TCINFO: case HCLGE_MBX_GET_TCINFO:
ret = hclge_get_vf_tcinfo(vport, req, true); hclge_get_vf_tcinfo(vport, &resp_msg);
if (ret)
dev_err(&hdev->pdev->dev,
"PF failed(%d) to get TC info for VF\n",
ret);
break; break;
case HCLGE_MBX_GET_LINK_STATUS: case HCLGE_MBX_GET_LINK_STATUS:
ret = hclge_get_link_info(vport, req); ret = hclge_get_link_info(vport, req);
...@@ -770,10 +738,10 @@ void hclge_mbx_handler(struct hclge_dev *hdev) ...@@ -770,10 +738,10 @@ void hclge_mbx_handler(struct hclge_dev *hdev)
hclge_mbx_reset_vf_queue(vport, req); hclge_mbx_reset_vf_queue(vport, req);
break; break;
case HCLGE_MBX_RESET: case HCLGE_MBX_RESET:
hclge_reset_vf(vport, req); ret = hclge_reset_vf(vport);
break; break;
case HCLGE_MBX_KEEP_ALIVE: case HCLGE_MBX_KEEP_ALIVE:
hclge_vf_keep_alive(vport, req); hclge_vf_keep_alive(vport);
break; break;
case HCLGE_MBX_SET_MTU: case HCLGE_MBX_SET_MTU:
ret = hclge_set_vf_mtu(vport, req); ret = hclge_set_vf_mtu(vport, req);
...@@ -782,18 +750,10 @@ void hclge_mbx_handler(struct hclge_dev *hdev) ...@@ -782,18 +750,10 @@ void hclge_mbx_handler(struct hclge_dev *hdev)
"VF fail(%d) to set mtu\n", ret); "VF fail(%d) to set mtu\n", ret);
break; break;
case HCLGE_MBX_GET_QID_IN_PF: case HCLGE_MBX_GET_QID_IN_PF:
ret = hclge_get_queue_id_in_pf(vport, req); hclge_get_queue_id_in_pf(vport, req, &resp_msg);
if (ret)
dev_err(&hdev->pdev->dev,
"PF failed(%d) to get qid for VF\n",
ret);
break; break;
case HCLGE_MBX_GET_RSS_KEY: case HCLGE_MBX_GET_RSS_KEY:
ret = hclge_get_rss_key(vport, req); hclge_get_rss_key(vport, req, &resp_msg);
if (ret)
dev_err(&hdev->pdev->dev,
"PF fail(%d) to get rss key for VF\n",
ret);
break; break;
case HCLGE_MBX_GET_LINK_MODE: case HCLGE_MBX_GET_LINK_MODE:
hclge_get_link_mode(vport, req); hclge_get_link_mode(vport, req);
...@@ -807,21 +767,13 @@ void hclge_mbx_handler(struct hclge_dev *hdev) ...@@ -807,21 +767,13 @@ void hclge_mbx_handler(struct hclge_dev *hdev)
hclge_rm_vport_all_vlan_table(vport, true); hclge_rm_vport_all_vlan_table(vport, true);
break; break;
case HCLGE_MBX_GET_MEDIA_TYPE: case HCLGE_MBX_GET_MEDIA_TYPE:
ret = hclge_get_vf_media_type(vport, req); hclge_get_vf_media_type(vport, &resp_msg);
if (ret)
dev_err(&hdev->pdev->dev,
"PF fail(%d) to media type for VF\n",
ret);
break; break;
case HCLGE_MBX_PUSH_LINK_STATUS: case HCLGE_MBX_PUSH_LINK_STATUS:
hclge_handle_link_change_event(hdev, req); hclge_handle_link_change_event(hdev, req);
break; break;
case HCLGE_MBX_GET_MAC_ADDR: case HCLGE_MBX_GET_MAC_ADDR:
ret = hclge_get_vf_mac_addr(vport, req); hclge_get_vf_mac_addr(vport, &resp_msg);
if (ret)
dev_err(&hdev->pdev->dev,
"PF failed(%d) to get MAC for VF\n",
ret);
break; break;
case HCLGE_MBX_NCSI_ERROR: case HCLGE_MBX_NCSI_ERROR:
hclge_handle_ncsi_error(hdev); hclge_handle_ncsi_error(hdev);
...@@ -829,11 +781,22 @@ void hclge_mbx_handler(struct hclge_dev *hdev) ...@@ -829,11 +781,22 @@ void hclge_mbx_handler(struct hclge_dev *hdev)
default: default:
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
"un-supported mailbox message, code = %u\n", "un-supported mailbox message, code = %u\n",
req->msg[0]); req->msg.code);
break; break;
} }
/* PF driver should not reply IMP */
if (hnae3_get_bit(req->mbx_need_resp, HCLGE_MBX_NEED_RESP_B) &&
req->msg.code < HCLGE_MBX_GET_VF_FLR_STATUS) {
resp_msg.status = ret;
hclge_gen_resp_to_vf(vport, req, &resp_msg);
}
crq->desc[crq->next_to_use].flag = 0; crq->desc[crq->next_to_use].flag = 0;
hclge_mbx_ring_ptr_move_crq(crq); hclge_mbx_ring_ptr_move_crq(crq);
/* reinitialize ret after complete the mbx message processing */
ret = 0;
} }
/* Write back CMDQ_RQ header pointer, M7 need this pointer */ /* Write back CMDQ_RQ header pointer, M7 need this pointer */
......
...@@ -229,13 +229,25 @@ static void hclgevf_get_stats(struct hnae3_handle *handle, u64 *data) ...@@ -229,13 +229,25 @@ static void hclgevf_get_stats(struct hnae3_handle *handle, u64 *data)
hclgevf_tqps_get_stats(handle, data); hclgevf_tqps_get_stats(handle, data);
} }
static void hclgevf_build_send_msg(struct hclge_vf_to_pf_msg *msg, u8 code,
u8 subcode)
{
if (msg) {
memset(msg, 0, sizeof(struct hclge_vf_to_pf_msg));
msg->code = code;
msg->subcode = subcode;
}
}
static int hclgevf_get_tc_info(struct hclgevf_dev *hdev) static int hclgevf_get_tc_info(struct hclgevf_dev *hdev)
{ {
struct hclge_vf_to_pf_msg send_msg;
u8 resp_msg; u8 resp_msg;
int status; int status;
status = hclgevf_send_mbx_msg(hdev, HCLGE_MBX_GET_TCINFO, 0, NULL, 0, hclgevf_build_send_msg(&send_msg, HCLGE_MBX_GET_TCINFO, 0);
true, &resp_msg, sizeof(resp_msg)); status = hclgevf_send_mbx_msg(hdev, &send_msg, true, &resp_msg,
sizeof(resp_msg));
if (status) { if (status) {
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
"VF request to get TC info from PF failed %d", "VF request to get TC info from PF failed %d",
...@@ -251,12 +263,14 @@ static int hclgevf_get_tc_info(struct hclgevf_dev *hdev) ...@@ -251,12 +263,14 @@ static int hclgevf_get_tc_info(struct hclgevf_dev *hdev)
static int hclgevf_get_port_base_vlan_filter_state(struct hclgevf_dev *hdev) static int hclgevf_get_port_base_vlan_filter_state(struct hclgevf_dev *hdev)
{ {
struct hnae3_handle *nic = &hdev->nic; struct hnae3_handle *nic = &hdev->nic;
struct hclge_vf_to_pf_msg send_msg;
u8 resp_msg; u8 resp_msg;
int ret; int ret;
ret = hclgevf_send_mbx_msg(hdev, HCLGE_MBX_SET_VLAN, hclgevf_build_send_msg(&send_msg, HCLGE_MBX_SET_VLAN,
HCLGE_MBX_GET_PORT_BASE_VLAN_STATE, HCLGE_MBX_GET_PORT_BASE_VLAN_STATE);
NULL, 0, true, &resp_msg, sizeof(u8)); ret = hclgevf_send_mbx_msg(hdev, &send_msg, true, &resp_msg,
sizeof(u8));
if (ret) { if (ret) {
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
"VF request to get port based vlan state failed %d", "VF request to get port based vlan state failed %d",
...@@ -272,11 +286,16 @@ static int hclgevf_get_port_base_vlan_filter_state(struct hclgevf_dev *hdev) ...@@ -272,11 +286,16 @@ static int hclgevf_get_port_base_vlan_filter_state(struct hclgevf_dev *hdev)
static int hclgevf_get_queue_info(struct hclgevf_dev *hdev) static int hclgevf_get_queue_info(struct hclgevf_dev *hdev)
{ {
#define HCLGEVF_TQPS_RSS_INFO_LEN 6 #define HCLGEVF_TQPS_RSS_INFO_LEN 6
#define HCLGEVF_TQPS_ALLOC_OFFSET 0
#define HCLGEVF_TQPS_RSS_SIZE_OFFSET 2
#define HCLGEVF_TQPS_RX_BUFFER_LEN_OFFSET 4
u8 resp_msg[HCLGEVF_TQPS_RSS_INFO_LEN]; u8 resp_msg[HCLGEVF_TQPS_RSS_INFO_LEN];
struct hclge_vf_to_pf_msg send_msg;
int status; int status;
status = hclgevf_send_mbx_msg(hdev, HCLGE_MBX_GET_QINFO, 0, NULL, 0, hclgevf_build_send_msg(&send_msg, HCLGE_MBX_GET_QINFO, 0);
true, resp_msg, status = hclgevf_send_mbx_msg(hdev, &send_msg, true, resp_msg,
HCLGEVF_TQPS_RSS_INFO_LEN); HCLGEVF_TQPS_RSS_INFO_LEN);
if (status) { if (status) {
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
...@@ -285,9 +304,12 @@ static int hclgevf_get_queue_info(struct hclgevf_dev *hdev) ...@@ -285,9 +304,12 @@ static int hclgevf_get_queue_info(struct hclgevf_dev *hdev)
return status; return status;
} }
memcpy(&hdev->num_tqps, &resp_msg[0], sizeof(u16)); memcpy(&hdev->num_tqps, &resp_msg[HCLGEVF_TQPS_ALLOC_OFFSET],
memcpy(&hdev->rss_size_max, &resp_msg[2], sizeof(u16)); sizeof(u16));
memcpy(&hdev->rx_buf_len, &resp_msg[4], sizeof(u16)); memcpy(&hdev->rss_size_max, &resp_msg[HCLGEVF_TQPS_RSS_SIZE_OFFSET],
sizeof(u16));
memcpy(&hdev->rx_buf_len, &resp_msg[HCLGEVF_TQPS_RX_BUFFER_LEN_OFFSET],
sizeof(u16));
return 0; return 0;
} }
...@@ -295,11 +317,15 @@ static int hclgevf_get_queue_info(struct hclgevf_dev *hdev) ...@@ -295,11 +317,15 @@ static int hclgevf_get_queue_info(struct hclgevf_dev *hdev)
static int hclgevf_get_queue_depth(struct hclgevf_dev *hdev) static int hclgevf_get_queue_depth(struct hclgevf_dev *hdev)
{ {
#define HCLGEVF_TQPS_DEPTH_INFO_LEN 4 #define HCLGEVF_TQPS_DEPTH_INFO_LEN 4
#define HCLGEVF_TQPS_NUM_TX_DESC_OFFSET 0
#define HCLGEVF_TQPS_NUM_RX_DESC_OFFSET 2
u8 resp_msg[HCLGEVF_TQPS_DEPTH_INFO_LEN]; u8 resp_msg[HCLGEVF_TQPS_DEPTH_INFO_LEN];
struct hclge_vf_to_pf_msg send_msg;
int ret; int ret;
ret = hclgevf_send_mbx_msg(hdev, HCLGE_MBX_GET_QDEPTH, 0, NULL, 0, hclgevf_build_send_msg(&send_msg, HCLGE_MBX_GET_QDEPTH, 0);
true, resp_msg, ret = hclgevf_send_mbx_msg(hdev, &send_msg, true, resp_msg,
HCLGEVF_TQPS_DEPTH_INFO_LEN); HCLGEVF_TQPS_DEPTH_INFO_LEN);
if (ret) { if (ret) {
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
...@@ -308,8 +334,10 @@ static int hclgevf_get_queue_depth(struct hclgevf_dev *hdev) ...@@ -308,8 +334,10 @@ static int hclgevf_get_queue_depth(struct hclgevf_dev *hdev)
return ret; return ret;
} }
memcpy(&hdev->num_tx_desc, &resp_msg[0], sizeof(u16)); memcpy(&hdev->num_tx_desc, &resp_msg[HCLGEVF_TQPS_NUM_TX_DESC_OFFSET],
memcpy(&hdev->num_rx_desc, &resp_msg[2], sizeof(u16)); sizeof(u16));
memcpy(&hdev->num_rx_desc, &resp_msg[HCLGEVF_TQPS_NUM_RX_DESC_OFFSET],
sizeof(u16));
return 0; return 0;
} }
...@@ -317,14 +345,14 @@ static int hclgevf_get_queue_depth(struct hclgevf_dev *hdev) ...@@ -317,14 +345,14 @@ static int hclgevf_get_queue_depth(struct hclgevf_dev *hdev)
static u16 hclgevf_get_qid_global(struct hnae3_handle *handle, u16 queue_id) static u16 hclgevf_get_qid_global(struct hnae3_handle *handle, u16 queue_id)
{ {
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
u8 msg_data[2], resp_data[2]; struct hclge_vf_to_pf_msg send_msg;
u16 qid_in_pf = 0; u16 qid_in_pf = 0;
u8 resp_data[2];
int ret; int ret;
memcpy(&msg_data[0], &queue_id, sizeof(queue_id)); hclgevf_build_send_msg(&send_msg, HCLGE_MBX_GET_QID_IN_PF, 0);
memcpy(send_msg.data, &queue_id, sizeof(queue_id));
ret = hclgevf_send_mbx_msg(hdev, HCLGE_MBX_GET_QID_IN_PF, 0, msg_data, ret = hclgevf_send_mbx_msg(hdev, &send_msg, true, resp_data,
sizeof(msg_data), true, resp_data,
sizeof(resp_data)); sizeof(resp_data));
if (!ret) if (!ret)
qid_in_pf = *(u16 *)resp_data; qid_in_pf = *(u16 *)resp_data;
...@@ -334,11 +362,13 @@ static u16 hclgevf_get_qid_global(struct hnae3_handle *handle, u16 queue_id) ...@@ -334,11 +362,13 @@ static u16 hclgevf_get_qid_global(struct hnae3_handle *handle, u16 queue_id)
static int hclgevf_get_pf_media_type(struct hclgevf_dev *hdev) static int hclgevf_get_pf_media_type(struct hclgevf_dev *hdev)
{ {
struct hclge_vf_to_pf_msg send_msg;
u8 resp_msg[2]; u8 resp_msg[2];
int ret; int ret;
ret = hclgevf_send_mbx_msg(hdev, HCLGE_MBX_GET_MEDIA_TYPE, 0, NULL, 0, hclgevf_build_send_msg(&send_msg, HCLGE_MBX_GET_MEDIA_TYPE, 0);
true, resp_msg, sizeof(resp_msg)); ret = hclgevf_send_mbx_msg(hdev, &send_msg, true, resp_msg,
sizeof(resp_msg));
if (ret) { if (ret) {
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
"VF request to get the pf port media type failed %d", "VF request to get the pf port media type failed %d",
...@@ -425,11 +455,11 @@ static int hclgevf_knic_setup(struct hclgevf_dev *hdev) ...@@ -425,11 +455,11 @@ static int hclgevf_knic_setup(struct hclgevf_dev *hdev)
static void hclgevf_request_link_info(struct hclgevf_dev *hdev) static void hclgevf_request_link_info(struct hclgevf_dev *hdev)
{ {
struct hclge_vf_to_pf_msg send_msg;
int status; int status;
u8 resp_msg;
status = hclgevf_send_mbx_msg(hdev, HCLGE_MBX_GET_LINK_STATUS, 0, NULL, hclgevf_build_send_msg(&send_msg, HCLGE_MBX_GET_LINK_STATUS, 0);
0, false, &resp_msg, sizeof(resp_msg)); status = hclgevf_send_mbx_msg(hdev, &send_msg, false, NULL, 0);
if (status) if (status)
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
"VF failed to fetch link status(%d) from PF", status); "VF failed to fetch link status(%d) from PF", status);
...@@ -463,19 +493,16 @@ void hclgevf_update_link_status(struct hclgevf_dev *hdev, int link_state) ...@@ -463,19 +493,16 @@ void hclgevf_update_link_status(struct hclgevf_dev *hdev, int link_state)
static void hclgevf_update_link_mode(struct hclgevf_dev *hdev) static void hclgevf_update_link_mode(struct hclgevf_dev *hdev)
{ {
#define HCLGEVF_ADVERTISING 0 #define HCLGEVF_ADVERTISING 0
#define HCLGEVF_SUPPORTED 1 #define HCLGEVF_SUPPORTED 1
u8 send_msg;
u8 resp_msg; struct hclge_vf_to_pf_msg send_msg;
send_msg = HCLGEVF_ADVERTISING; hclgevf_build_send_msg(&send_msg, HCLGE_MBX_GET_LINK_MODE, 0);
hclgevf_send_mbx_msg(hdev, HCLGE_MBX_GET_LINK_MODE, 0, send_msg.data[0] = HCLGEVF_ADVERTISING;
&send_msg, sizeof(send_msg), false, hclgevf_send_mbx_msg(hdev, &send_msg, false, NULL, 0);
&resp_msg, sizeof(resp_msg)); send_msg.data[0] = HCLGEVF_SUPPORTED;
send_msg = HCLGEVF_SUPPORTED; hclgevf_send_mbx_msg(hdev, &send_msg, false, NULL, 0);
hclgevf_send_mbx_msg(hdev, HCLGE_MBX_GET_LINK_MODE, 0,
&send_msg, sizeof(send_msg), false,
&resp_msg, sizeof(resp_msg));
} }
static int hclgevf_set_handle_info(struct hclgevf_dev *hdev) static int hclgevf_set_handle_info(struct hclgevf_dev *hdev)
...@@ -677,19 +704,19 @@ static int hclgevf_set_rss_tc_mode(struct hclgevf_dev *hdev, u16 rss_size) ...@@ -677,19 +704,19 @@ static int hclgevf_set_rss_tc_mode(struct hclgevf_dev *hdev, u16 rss_size)
static int hclgevf_get_rss_hash_key(struct hclgevf_dev *hdev) static int hclgevf_get_rss_hash_key(struct hclgevf_dev *hdev)
{ {
#define HCLGEVF_RSS_MBX_RESP_LEN 8 #define HCLGEVF_RSS_MBX_RESP_LEN 8
struct hclgevf_rss_cfg *rss_cfg = &hdev->rss_cfg; struct hclgevf_rss_cfg *rss_cfg = &hdev->rss_cfg;
u8 resp_msg[HCLGEVF_RSS_MBX_RESP_LEN]; u8 resp_msg[HCLGEVF_RSS_MBX_RESP_LEN];
struct hclge_vf_to_pf_msg send_msg;
u16 msg_num, hash_key_index; u16 msg_num, hash_key_index;
u8 index; u8 index;
int ret; int ret;
hclgevf_build_send_msg(&send_msg, HCLGE_MBX_GET_RSS_KEY, 0);
msg_num = (HCLGEVF_RSS_KEY_SIZE + HCLGEVF_RSS_MBX_RESP_LEN - 1) / msg_num = (HCLGEVF_RSS_KEY_SIZE + HCLGEVF_RSS_MBX_RESP_LEN - 1) /
HCLGEVF_RSS_MBX_RESP_LEN; HCLGEVF_RSS_MBX_RESP_LEN;
for (index = 0; index < msg_num; index++) { for (index = 0; index < msg_num; index++) {
ret = hclgevf_send_mbx_msg(hdev, HCLGE_MBX_GET_RSS_KEY, 0, send_msg.data[0] = index;
&index, sizeof(index), ret = hclgevf_send_mbx_msg(hdev, &send_msg, true, resp_msg,
true, resp_msg,
HCLGEVF_RSS_MBX_RESP_LEN); HCLGEVF_RSS_MBX_RESP_LEN);
if (ret) { if (ret) {
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
...@@ -1001,44 +1028,32 @@ static int hclgevf_bind_ring_to_vector(struct hnae3_handle *handle, bool en, ...@@ -1001,44 +1028,32 @@ static int hclgevf_bind_ring_to_vector(struct hnae3_handle *handle, bool en,
struct hnae3_ring_chain_node *ring_chain) struct hnae3_ring_chain_node *ring_chain)
{ {
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
struct hclge_vf_to_pf_msg send_msg;
struct hnae3_ring_chain_node *node; struct hnae3_ring_chain_node *node;
struct hclge_mbx_vf_to_pf_cmd *req;
struct hclgevf_desc desc;
int i = 0;
int status; int status;
u8 type; int i = 0;
req = (struct hclge_mbx_vf_to_pf_cmd *)desc.data; memset(&send_msg, 0, sizeof(send_msg));
type = en ? HCLGE_MBX_MAP_RING_TO_VECTOR : send_msg.code = en ? HCLGE_MBX_MAP_RING_TO_VECTOR :
HCLGE_MBX_UNMAP_RING_TO_VECTOR; HCLGE_MBX_UNMAP_RING_TO_VECTOR;
send_msg.vector_id = vector_id;
for (node = ring_chain; node; node = node->next) { for (node = ring_chain; node; node = node->next) {
int idx_offset = HCLGE_MBX_RING_MAP_BASIC_MSG_NUM + send_msg.param[i].ring_type =
HCLGE_MBX_RING_NODE_VARIABLE_NUM * i;
if (i == 0) {
hclgevf_cmd_setup_basic_desc(&desc,
HCLGEVF_OPC_MBX_VF_TO_PF,
false);
req->msg[0] = type;
req->msg[1] = vector_id;
}
req->msg[idx_offset] =
hnae3_get_bit(node->flag, HNAE3_RING_TYPE_B); hnae3_get_bit(node->flag, HNAE3_RING_TYPE_B);
req->msg[idx_offset + 1] = node->tqp_index;
req->msg[idx_offset + 2] = hnae3_get_field(node->int_gl_idx, send_msg.param[i].tqp_index = node->tqp_index;
HNAE3_RING_GL_IDX_M, send_msg.param[i].int_gl_index =
HNAE3_RING_GL_IDX_S); hnae3_get_field(node->int_gl_idx,
HNAE3_RING_GL_IDX_M,
HNAE3_RING_GL_IDX_S);
i++; i++;
if ((i == (HCLGE_MBX_VF_MSG_DATA_NUM - if (i == HCLGE_MBX_MAX_RING_CHAIN_PARAM_NUM || !node->next) {
HCLGE_MBX_RING_MAP_BASIC_MSG_NUM) / send_msg.ring_num = i;
HCLGE_MBX_RING_NODE_VARIABLE_NUM) ||
!node->next) {
req->msg[2] = i;
status = hclgevf_cmd_send(&hdev->hw, &desc, 1); status = hclgevf_send_mbx_msg(hdev, &send_msg, false,
NULL, 0);
if (status) { if (status) {
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
"Map TQP fail, status is %d.\n", "Map TQP fail, status is %d.\n",
...@@ -1046,11 +1061,6 @@ static int hclgevf_bind_ring_to_vector(struct hnae3_handle *handle, bool en, ...@@ -1046,11 +1061,6 @@ static int hclgevf_bind_ring_to_vector(struct hnae3_handle *handle, bool en,
return status; return status;
} }
i = 0; i = 0;
hclgevf_cmd_setup_basic_desc(&desc,
HCLGEVF_OPC_MBX_VF_TO_PF,
false);
req->msg[0] = type;
req->msg[1] = vector_id;
} }
} }
...@@ -1123,18 +1133,17 @@ static int hclgevf_cmd_set_promisc_mode(struct hclgevf_dev *hdev, ...@@ -1123,18 +1133,17 @@ static int hclgevf_cmd_set_promisc_mode(struct hclgevf_dev *hdev,
bool en_uc_pmc, bool en_mc_pmc, bool en_uc_pmc, bool en_mc_pmc,
bool en_bc_pmc) bool en_bc_pmc)
{ {
struct hclge_mbx_vf_to_pf_cmd *req; struct hclge_vf_to_pf_msg send_msg;
struct hclgevf_desc desc;
int ret; int ret;
req = (struct hclge_mbx_vf_to_pf_cmd *)desc.data; memset(&send_msg, 0, sizeof(send_msg));
hclgevf_cmd_setup_basic_desc(&desc, HCLGEVF_OPC_MBX_VF_TO_PF, false); send_msg.code = HCLGE_MBX_SET_PROMISC_MODE;
req->msg[0] = HCLGE_MBX_SET_PROMISC_MODE; send_msg.en_bc = en_bc_pmc ? 1 : 0;
req->msg[1] = en_bc_pmc ? 1 : 0; send_msg.en_uc = en_uc_pmc ? 1 : 0;
req->msg[2] = en_uc_pmc ? 1 : 0; send_msg.en_mc = en_mc_pmc ? 1 : 0;
req->msg[3] = en_mc_pmc ? 1 : 0;
ret = hclgevf_send_mbx_msg(hdev, &send_msg, false, NULL, 0);
ret = hclgevf_cmd_send(&hdev->hw, &desc, 1);
if (ret) if (ret)
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
"Set promisc mode fail, status is %d.\n", ret); "Set promisc mode fail, status is %d.\n", ret);
...@@ -1193,11 +1202,13 @@ static void hclgevf_reset_tqp_stats(struct hnae3_handle *handle) ...@@ -1193,11 +1202,13 @@ static void hclgevf_reset_tqp_stats(struct hnae3_handle *handle)
static int hclgevf_get_host_mac_addr(struct hclgevf_dev *hdev, u8 *p) static int hclgevf_get_host_mac_addr(struct hclgevf_dev *hdev, u8 *p)
{ {
struct hclge_vf_to_pf_msg send_msg;
u8 host_mac[ETH_ALEN]; u8 host_mac[ETH_ALEN];
int status; int status;
status = hclgevf_send_mbx_msg(hdev, HCLGE_MBX_GET_MAC_ADDR, 0, NULL, 0, hclgevf_build_send_msg(&send_msg, HCLGE_MBX_GET_MAC_ADDR, 0);
true, host_mac, ETH_ALEN); status = hclgevf_send_mbx_msg(hdev, &send_msg, true, host_mac,
ETH_ALEN);
if (status) { if (status) {
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
"fail to get VF MAC from host %d", status); "fail to get VF MAC from host %d", status);
...@@ -1229,20 +1240,16 @@ static int hclgevf_set_mac_addr(struct hnae3_handle *handle, void *p, ...@@ -1229,20 +1240,16 @@ static int hclgevf_set_mac_addr(struct hnae3_handle *handle, void *p,
{ {
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
u8 *old_mac_addr = (u8 *)hdev->hw.mac.mac_addr; u8 *old_mac_addr = (u8 *)hdev->hw.mac.mac_addr;
struct hclge_vf_to_pf_msg send_msg;
u8 *new_mac_addr = (u8 *)p; u8 *new_mac_addr = (u8 *)p;
u8 msg_data[ETH_ALEN * 2];
u16 subcode;
int status; int status;
ether_addr_copy(msg_data, new_mac_addr); hclgevf_build_send_msg(&send_msg, HCLGE_MBX_SET_UNICAST, 0);
ether_addr_copy(&msg_data[ETH_ALEN], old_mac_addr); send_msg.subcode = is_first ? HCLGE_MBX_MAC_VLAN_UC_ADD :
subcode = is_first ? HCLGE_MBX_MAC_VLAN_UC_ADD :
HCLGE_MBX_MAC_VLAN_UC_MODIFY; HCLGE_MBX_MAC_VLAN_UC_MODIFY;
ether_addr_copy(send_msg.data, new_mac_addr);
status = hclgevf_send_mbx_msg(hdev, HCLGE_MBX_SET_UNICAST, ether_addr_copy(&send_msg.data[ETH_ALEN], old_mac_addr);
subcode, msg_data, sizeof(msg_data), status = hclgevf_send_mbx_msg(hdev, &send_msg, true, NULL, 0);
true, NULL, 0);
if (!status) if (!status)
ether_addr_copy(hdev->hw.mac.mac_addr, new_mac_addr); ether_addr_copy(hdev->hw.mac.mac_addr, new_mac_addr);
...@@ -1253,49 +1260,60 @@ static int hclgevf_add_uc_addr(struct hnae3_handle *handle, ...@@ -1253,49 +1260,60 @@ static int hclgevf_add_uc_addr(struct hnae3_handle *handle,
const unsigned char *addr) const unsigned char *addr)
{ {
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
struct hclge_vf_to_pf_msg send_msg;
return hclgevf_send_mbx_msg(hdev, HCLGE_MBX_SET_UNICAST, hclgevf_build_send_msg(&send_msg, HCLGE_MBX_SET_UNICAST,
HCLGE_MBX_MAC_VLAN_UC_ADD, HCLGE_MBX_MAC_VLAN_UC_ADD);
addr, ETH_ALEN, false, NULL, 0); ether_addr_copy(send_msg.data, addr);
return hclgevf_send_mbx_msg(hdev, &send_msg, false, NULL, 0);
} }
static int hclgevf_rm_uc_addr(struct hnae3_handle *handle, static int hclgevf_rm_uc_addr(struct hnae3_handle *handle,
const unsigned char *addr) const unsigned char *addr)
{ {
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
struct hclge_vf_to_pf_msg send_msg;
return hclgevf_send_mbx_msg(hdev, HCLGE_MBX_SET_UNICAST, hclgevf_build_send_msg(&send_msg, HCLGE_MBX_SET_UNICAST,
HCLGE_MBX_MAC_VLAN_UC_REMOVE, HCLGE_MBX_MAC_VLAN_UC_REMOVE);
addr, ETH_ALEN, false, NULL, 0); ether_addr_copy(send_msg.data, addr);
return hclgevf_send_mbx_msg(hdev, &send_msg, false, NULL, 0);
} }
static int hclgevf_add_mc_addr(struct hnae3_handle *handle, static int hclgevf_add_mc_addr(struct hnae3_handle *handle,
const unsigned char *addr) const unsigned char *addr)
{ {
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
struct hclge_vf_to_pf_msg send_msg;
return hclgevf_send_mbx_msg(hdev, HCLGE_MBX_SET_MULTICAST, hclgevf_build_send_msg(&send_msg, HCLGE_MBX_SET_MULTICAST,
HCLGE_MBX_MAC_VLAN_MC_ADD, HCLGE_MBX_MAC_VLAN_MC_ADD);
addr, ETH_ALEN, false, NULL, 0); ether_addr_copy(send_msg.data, addr);
return hclgevf_send_mbx_msg(hdev, &send_msg, false, NULL, 0);
} }
static int hclgevf_rm_mc_addr(struct hnae3_handle *handle, static int hclgevf_rm_mc_addr(struct hnae3_handle *handle,
const unsigned char *addr) const unsigned char *addr)
{ {
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
struct hclge_vf_to_pf_msg send_msg;
return hclgevf_send_mbx_msg(hdev, HCLGE_MBX_SET_MULTICAST, hclgevf_build_send_msg(&send_msg, HCLGE_MBX_SET_MULTICAST,
HCLGE_MBX_MAC_VLAN_MC_REMOVE, HCLGE_MBX_MAC_VLAN_MC_REMOVE);
addr, ETH_ALEN, false, NULL, 0); ether_addr_copy(send_msg.data, addr);
return hclgevf_send_mbx_msg(hdev, &send_msg, false, NULL, 0);
} }
static int hclgevf_set_vlan_filter(struct hnae3_handle *handle, static int hclgevf_set_vlan_filter(struct hnae3_handle *handle,
__be16 proto, u16 vlan_id, __be16 proto, u16 vlan_id,
bool is_kill) bool is_kill)
{ {
#define HCLGEVF_VLAN_MBX_MSG_LEN 5 #define HCLGEVF_VLAN_MBX_IS_KILL_OFFSET 0
#define HCLGEVF_VLAN_MBX_VLAN_ID_OFFSET 1
#define HCLGEVF_VLAN_MBX_PROTO_OFFSET 3
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
u8 msg_data[HCLGEVF_VLAN_MBX_MSG_LEN]; struct hclge_vf_to_pf_msg send_msg;
int ret; int ret;
if (vlan_id > HCLGEVF_MAX_VLAN_ID) if (vlan_id > HCLGEVF_MAX_VLAN_ID)
...@@ -1313,16 +1331,18 @@ static int hclgevf_set_vlan_filter(struct hnae3_handle *handle, ...@@ -1313,16 +1331,18 @@ static int hclgevf_set_vlan_filter(struct hnae3_handle *handle,
return -EBUSY; return -EBUSY;
} }
msg_data[0] = is_kill; hclgevf_build_send_msg(&send_msg, HCLGE_MBX_SET_VLAN,
memcpy(&msg_data[1], &vlan_id, sizeof(vlan_id)); HCLGE_MBX_VLAN_FILTER);
memcpy(&msg_data[3], &proto, sizeof(proto)); send_msg.data[HCLGEVF_VLAN_MBX_IS_KILL_OFFSET] = is_kill;
memcpy(&send_msg.data[HCLGEVF_VLAN_MBX_VLAN_ID_OFFSET], &vlan_id,
sizeof(vlan_id));
memcpy(&send_msg.data[HCLGEVF_VLAN_MBX_PROTO_OFFSET], &proto,
sizeof(proto));
/* when remove hw vlan filter failed, record the vlan id, /* when remove hw vlan filter failed, record the vlan id,
* and try to remove it from hw later, to be consistence * and try to remove it from hw later, to be consistence
* with stack. * with stack.
*/ */
ret = hclgevf_send_mbx_msg(hdev, HCLGE_MBX_SET_VLAN, ret = hclgevf_send_mbx_msg(hdev, &send_msg, true, NULL, 0);
HCLGE_MBX_VLAN_FILTER, msg_data,
HCLGEVF_VLAN_MBX_MSG_LEN, true, NULL, 0);
if (is_kill && ret) if (is_kill && ret)
set_bit(vlan_id, hdev->vlan_del_fail_bmap); set_bit(vlan_id, hdev->vlan_del_fail_bmap);
...@@ -1355,37 +1375,38 @@ static void hclgevf_sync_vlan_filter(struct hclgevf_dev *hdev) ...@@ -1355,37 +1375,38 @@ static void hclgevf_sync_vlan_filter(struct hclgevf_dev *hdev)
static int hclgevf_en_hw_strip_rxvtag(struct hnae3_handle *handle, bool enable) static int hclgevf_en_hw_strip_rxvtag(struct hnae3_handle *handle, bool enable)
{ {
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
u8 msg_data; struct hclge_vf_to_pf_msg send_msg;
msg_data = enable ? 1 : 0; hclgevf_build_send_msg(&send_msg, HCLGE_MBX_SET_VLAN,
return hclgevf_send_mbx_msg(hdev, HCLGE_MBX_SET_VLAN, HCLGE_MBX_VLAN_RX_OFF_CFG);
HCLGE_MBX_VLAN_RX_OFF_CFG, &msg_data, send_msg.data[0] = enable ? 1 : 0;
1, false, NULL, 0); return hclgevf_send_mbx_msg(hdev, &send_msg, false, NULL, 0);
} }
static int hclgevf_reset_tqp(struct hnae3_handle *handle, u16 queue_id) static int hclgevf_reset_tqp(struct hnae3_handle *handle, u16 queue_id)
{ {
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
u8 msg_data[2]; struct hclge_vf_to_pf_msg send_msg;
int ret; int ret;
memcpy(msg_data, &queue_id, sizeof(queue_id));
/* disable vf queue before send queue reset msg to PF */ /* disable vf queue before send queue reset msg to PF */
ret = hclgevf_tqp_enable(hdev, queue_id, 0, false); ret = hclgevf_tqp_enable(hdev, queue_id, 0, false);
if (ret) if (ret)
return ret; return ret;
return hclgevf_send_mbx_msg(hdev, HCLGE_MBX_QUEUE_RESET, 0, msg_data, hclgevf_build_send_msg(&send_msg, HCLGE_MBX_QUEUE_RESET, 0);
sizeof(msg_data), true, NULL, 0); memcpy(send_msg.data, &queue_id, sizeof(queue_id));
return hclgevf_send_mbx_msg(hdev, &send_msg, true, NULL, 0);
} }
static int hclgevf_set_mtu(struct hnae3_handle *handle, int new_mtu) static int hclgevf_set_mtu(struct hnae3_handle *handle, int new_mtu)
{ {
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
struct hclge_vf_to_pf_msg send_msg;
return hclgevf_send_mbx_msg(hdev, HCLGE_MBX_SET_MTU, 0, (u8 *)&new_mtu, hclgevf_build_send_msg(&send_msg, HCLGE_MBX_SET_MTU, 0);
sizeof(new_mtu), true, NULL, 0); memcpy(send_msg.data, &new_mtu, sizeof(new_mtu));
return hclgevf_send_mbx_msg(hdev, &send_msg, true, NULL, 0);
} }
static int hclgevf_notify_client(struct hclgevf_dev *hdev, static int hclgevf_notify_client(struct hclgevf_dev *hdev,
...@@ -1500,11 +1521,12 @@ static int hclgevf_reset_prepare_wait(struct hclgevf_dev *hdev) ...@@ -1500,11 +1521,12 @@ static int hclgevf_reset_prepare_wait(struct hclgevf_dev *hdev)
{ {
#define HCLGEVF_RESET_SYNC_TIME 100 #define HCLGEVF_RESET_SYNC_TIME 100
struct hclge_vf_to_pf_msg send_msg;
int ret = 0; int ret = 0;
if (hdev->reset_type == HNAE3_VF_FUNC_RESET) { if (hdev->reset_type == HNAE3_VF_FUNC_RESET) {
ret = hclgevf_send_mbx_msg(hdev, HCLGE_MBX_RESET, 0, NULL, hclgevf_build_send_msg(&send_msg, HCLGE_MBX_RESET, 0);
0, true, NULL, sizeof(u8)); ret = hclgevf_send_mbx_msg(hdev, &send_msg, true, NULL, 0);
hdev->rst_stats.vf_func_rst_cnt++; hdev->rst_stats.vf_func_rst_cnt++;
} }
...@@ -1881,14 +1903,14 @@ static void hclgevf_mailbox_service_task(struct hclgevf_dev *hdev) ...@@ -1881,14 +1903,14 @@ static void hclgevf_mailbox_service_task(struct hclgevf_dev *hdev)
static void hclgevf_keep_alive(struct hclgevf_dev *hdev) static void hclgevf_keep_alive(struct hclgevf_dev *hdev)
{ {
u8 respmsg; struct hclge_vf_to_pf_msg send_msg;
int ret; int ret;
if (test_bit(HCLGEVF_STATE_CMD_DISABLE, &hdev->state)) if (test_bit(HCLGEVF_STATE_CMD_DISABLE, &hdev->state))
return; return;
ret = hclgevf_send_mbx_msg(hdev, HCLGE_MBX_KEEP_ALIVE, 0, NULL, hclgevf_build_send_msg(&send_msg, HCLGE_MBX_KEEP_ALIVE, 0);
0, false, &respmsg, sizeof(respmsg)); ret = hclgevf_send_mbx_msg(hdev, &send_msg, false, NULL, 0);
if (ret) if (ret)
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
"VF sends keep alive cmd failed(=%d)\n", ret); "VF sends keep alive cmd failed(=%d)\n", ret);
...@@ -2245,12 +2267,16 @@ static void hclgevf_ae_stop(struct hnae3_handle *handle) ...@@ -2245,12 +2267,16 @@ static void hclgevf_ae_stop(struct hnae3_handle *handle)
static int hclgevf_set_alive(struct hnae3_handle *handle, bool alive) static int hclgevf_set_alive(struct hnae3_handle *handle, bool alive)
{ {
#define HCLGEVF_STATE_ALIVE 1
#define HCLGEVF_STATE_NOT_ALIVE 0
struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle);
u8 msg_data; struct hclge_vf_to_pf_msg send_msg;
msg_data = alive ? 1 : 0; hclgevf_build_send_msg(&send_msg, HCLGE_MBX_SET_ALIVE, 0);
return hclgevf_send_mbx_msg(hdev, HCLGE_MBX_SET_ALIVE, send_msg.data[0] = alive ? HCLGEVF_STATE_ALIVE :
0, &msg_data, 1, false, NULL, 0); HCLGEVF_STATE_NOT_ALIVE;
return hclgevf_send_mbx_msg(hdev, &send_msg, false, NULL, 0);
} }
static int hclgevf_client_start(struct hnae3_handle *handle) static int hclgevf_client_start(struct hnae3_handle *handle)
...@@ -2804,10 +2830,12 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev) ...@@ -2804,10 +2830,12 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev)
static void hclgevf_uninit_hdev(struct hclgevf_dev *hdev) static void hclgevf_uninit_hdev(struct hclgevf_dev *hdev)
{ {
struct hclge_vf_to_pf_msg send_msg;
hclgevf_state_uninit(hdev); hclgevf_state_uninit(hdev);
hclgevf_send_mbx_msg(hdev, HCLGE_MBX_VF_UNINIT, 0, NULL, 0, hclgevf_build_send_msg(&send_msg, HCLGE_MBX_VF_UNINIT, 0);
false, NULL, 0); hclgevf_send_mbx_msg(hdev, &send_msg, false, NULL, 0);
if (test_bit(HCLGEVF_STATE_IRQ_INITED, &hdev->state)) { if (test_bit(HCLGEVF_STATE_IRQ_INITED, &hdev->state)) {
hclgevf_misc_irq_uninit(hdev); hclgevf_misc_irq_uninit(hdev);
...@@ -3104,16 +3132,17 @@ void hclgevf_update_port_base_vlan_info(struct hclgevf_dev *hdev, u16 state, ...@@ -3104,16 +3132,17 @@ void hclgevf_update_port_base_vlan_info(struct hclgevf_dev *hdev, u16 state,
u8 *port_base_vlan_info, u8 data_size) u8 *port_base_vlan_info, u8 data_size)
{ {
struct hnae3_handle *nic = &hdev->nic; struct hnae3_handle *nic = &hdev->nic;
struct hclge_vf_to_pf_msg send_msg;
rtnl_lock(); rtnl_lock();
hclgevf_notify_client(hdev, HNAE3_DOWN_CLIENT); hclgevf_notify_client(hdev, HNAE3_DOWN_CLIENT);
rtnl_unlock(); rtnl_unlock();
/* send msg to PF and wait update port based vlan info */ /* send msg to PF and wait update port based vlan info */
hclgevf_send_mbx_msg(hdev, HCLGE_MBX_SET_VLAN, hclgevf_build_send_msg(&send_msg, HCLGE_MBX_SET_VLAN,
HCLGE_MBX_PORT_BASE_VLAN_CFG, HCLGE_MBX_PORT_BASE_VLAN_CFG);
port_base_vlan_info, data_size, memcpy(send_msg.data, port_base_vlan_info, data_size);
false, NULL, 0); hclgevf_send_mbx_msg(hdev, &send_msg, false, NULL, 0);
if (state == HNAE3_PORT_BASE_VLAN_DISABLE) if (state == HNAE3_PORT_BASE_VLAN_DISABLE)
nic->port_base_vlan_state = HNAE3_PORT_BASE_VLAN_DISABLE; nic->port_base_vlan_state = HNAE3_PORT_BASE_VLAN_DISABLE;
......
...@@ -305,8 +305,8 @@ static inline bool hclgevf_is_reset_pending(struct hclgevf_dev *hdev) ...@@ -305,8 +305,8 @@ static inline bool hclgevf_is_reset_pending(struct hclgevf_dev *hdev)
return !!hdev->reset_pending; return !!hdev->reset_pending;
} }
int hclgevf_send_mbx_msg(struct hclgevf_dev *hdev, u16 code, u16 subcode, int hclgevf_send_mbx_msg(struct hclgevf_dev *hdev,
const u8 *msg_data, u8 msg_len, bool need_resp, struct hclge_vf_to_pf_msg *send_msg, bool need_resp,
u8 *resp_data, u16 resp_len); u8 *resp_data, u16 resp_len);
void hclgevf_mbx_handler(struct hclgevf_dev *hdev); void hclgevf_mbx_handler(struct hclgevf_dev *hdev);
void hclgevf_mbx_async_handler(struct hclgevf_dev *hdev); void hclgevf_mbx_async_handler(struct hclgevf_dev *hdev);
......
...@@ -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
...@@ -79,8 +84,8 @@ static int hclgevf_get_mbx_resp(struct hclgevf_dev *hdev, u16 code0, u16 code1, ...@@ -79,8 +84,8 @@ static int hclgevf_get_mbx_resp(struct hclgevf_dev *hdev, u16 code0, u16 code1,
return 0; return 0;
} }
int hclgevf_send_mbx_msg(struct hclgevf_dev *hdev, u16 code, u16 subcode, int hclgevf_send_mbx_msg(struct hclgevf_dev *hdev,
const u8 *msg_data, u8 msg_len, bool need_resp, struct hclge_vf_to_pf_msg *send_msg, bool need_resp,
u8 *resp_data, u16 resp_len) u8 *resp_data, u16 resp_len)
{ {
struct hclge_mbx_vf_to_pf_cmd *req; struct hclge_mbx_vf_to_pf_cmd *req;
...@@ -89,21 +94,17 @@ int hclgevf_send_mbx_msg(struct hclgevf_dev *hdev, u16 code, u16 subcode, ...@@ -89,21 +94,17 @@ int hclgevf_send_mbx_msg(struct hclgevf_dev *hdev, u16 code, u16 subcode,
req = (struct hclge_mbx_vf_to_pf_cmd *)desc.data; req = (struct hclge_mbx_vf_to_pf_cmd *)desc.data;
/* first two bytes are reserved for code & subcode */ if (!send_msg) {
if (msg_len > (HCLGE_MBX_MAX_MSG_SIZE - 2)) {
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
"VF send mbx msg fail, msg len %d exceeds max len %d\n", "failed to send mbx, msg is NULL\n");
msg_len, HCLGE_MBX_MAX_MSG_SIZE);
return -EINVAL; return -EINVAL;
} }
hclgevf_cmd_setup_basic_desc(&desc, HCLGEVF_OPC_MBX_VF_TO_PF, false); hclgevf_cmd_setup_basic_desc(&desc, HCLGEVF_OPC_MBX_VF_TO_PF, false);
req->mbx_need_resp |= need_resp ? HCLGE_MBX_NEED_RESP_BIT : if (need_resp)
~HCLGE_MBX_NEED_RESP_BIT; hnae3_set_bit(req->mbx_need_resp, HCLGE_MBX_NEED_RESP_B, 1);
req->msg[0] = code;
req->msg[1] = subcode; memcpy(&req->msg, send_msg, sizeof(struct hclge_vf_to_pf_msg));
if (msg_data)
memcpy(&req->msg[2], msg_data, msg_len);
/* synchronous send */ /* synchronous send */
if (need_resp) { if (need_resp) {
...@@ -118,7 +119,8 @@ int hclgevf_send_mbx_msg(struct hclgevf_dev *hdev, u16 code, u16 subcode, ...@@ -118,7 +119,8 @@ int hclgevf_send_mbx_msg(struct hclgevf_dev *hdev, u16 code, u16 subcode,
return status; return status;
} }
status = hclgevf_get_mbx_resp(hdev, code, subcode, resp_data, status = hclgevf_get_mbx_resp(hdev, send_msg->code,
send_msg->subcode, resp_data,
resp_len); resp_len);
mutex_unlock(&hdev->mbx_resp.mbx_mutex); mutex_unlock(&hdev->mbx_resp.mbx_mutex);
} else { } else {
...@@ -169,7 +171,7 @@ void hclgevf_mbx_handler(struct hclgevf_dev *hdev) ...@@ -169,7 +171,7 @@ void hclgevf_mbx_handler(struct hclgevf_dev *hdev)
if (unlikely(!hnae3_get_bit(flag, HCLGEVF_CMDQ_RX_OUTVLD_B))) { if (unlikely(!hnae3_get_bit(flag, HCLGEVF_CMDQ_RX_OUTVLD_B))) {
dev_warn(&hdev->pdev->dev, dev_warn(&hdev->pdev->dev,
"dropped invalid mailbox message, code = %u\n", "dropped invalid mailbox message, code = %u\n",
req->msg[0]); req->msg.code);
/* dropping/not processing this invalid message */ /* dropping/not processing this invalid message */
crq->desc[crq->next_to_use].flag = 0; crq->desc[crq->next_to_use].flag = 0;
...@@ -183,19 +185,21 @@ void hclgevf_mbx_handler(struct hclgevf_dev *hdev) ...@@ -183,19 +185,21 @@ void hclgevf_mbx_handler(struct hclgevf_dev *hdev)
* timeout and simultaneously queue the async messages for later * timeout and simultaneously queue the async messages for later
* prcessing in context of mailbox task i.e. the slow path. * prcessing in context of mailbox task i.e. the slow path.
*/ */
switch (req->msg[0]) { switch (req->msg.code) {
case HCLGE_MBX_PF_VF_RESP: case HCLGE_MBX_PF_VF_RESP:
if (resp->received_resp) if (resp->received_resp)
dev_warn(&hdev->pdev->dev, dev_warn(&hdev->pdev->dev,
"VF mbx resp flag not clear(%u)\n", "VF mbx resp flag not clear(%u)\n",
req->msg[1]); req->msg.vf_mbx_msg_code);
resp->received_resp = true; resp->received_resp = true;
resp->origin_mbx_msg = (req->msg[1] << 16); resp->origin_mbx_msg =
resp->origin_mbx_msg |= req->msg[2]; (req->msg.vf_mbx_msg_code << 16);
resp->resp_status = req->msg[3]; resp->origin_mbx_msg |= req->msg.vf_mbx_msg_subcode;
resp->resp_status =
hclgevf_resp_to_errno(req->msg.resp_status);
temp = (u8 *)&req->msg[4]; temp = (u8 *)req->msg.resp_data;
for (i = 0; i < HCLGE_MBX_MAX_RESP_DATA_SIZE; i++) { for (i = 0; i < HCLGE_MBX_MAX_RESP_DATA_SIZE; i++) {
resp->additional_info[i] = *temp; resp->additional_info[i] = *temp;
temp++; temp++;
...@@ -220,13 +224,13 @@ void hclgevf_mbx_handler(struct hclgevf_dev *hdev) ...@@ -220,13 +224,13 @@ void hclgevf_mbx_handler(struct hclgevf_dev *hdev)
HCLGE_MBX_MAX_ARQ_MSG_NUM) { HCLGE_MBX_MAX_ARQ_MSG_NUM) {
dev_warn(&hdev->pdev->dev, dev_warn(&hdev->pdev->dev,
"Async Q full, dropping msg(%u)\n", "Async Q full, dropping msg(%u)\n",
req->msg[1]); req->msg.code);
break; break;
} }
/* tail the async message in arq */ /* tail the async message in arq */
msg_q = hdev->arq.msg_q[hdev->arq.tail]; msg_q = hdev->arq.msg_q[hdev->arq.tail];
memcpy(&msg_q[0], req->msg, memcpy(&msg_q[0], &req->msg,
HCLGE_MBX_MAX_ARQ_MSG_SIZE * sizeof(u16)); HCLGE_MBX_MAX_ARQ_MSG_SIZE * sizeof(u16));
hclge_mbx_tail_ptr_move_arq(hdev->arq); hclge_mbx_tail_ptr_move_arq(hdev->arq);
atomic_inc(&hdev->arq.count); atomic_inc(&hdev->arq.count);
...@@ -237,7 +241,7 @@ void hclgevf_mbx_handler(struct hclgevf_dev *hdev) ...@@ -237,7 +241,7 @@ void hclgevf_mbx_handler(struct hclgevf_dev *hdev)
default: default:
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
"VF received unsupported(%u) mbx msg from PF\n", "VF received unsupported(%u) mbx msg from PF\n",
req->msg[0]); req->msg.code);
break; break;
} }
crq->desc[crq->next_to_use].flag = 0; crq->desc[crq->next_to_use].flag = 0;
......
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