net: hns3: refine the definition for struct hclge_pf_to_vf_msg
authorJian Shen <shenjian15@huawei.com>
Tue, 19 Apr 2022 03:27:03 +0000 (11:27 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 20 Apr 2022 09:45:50 +0000 (10:45 +0100)
The struct hclge_pf_to_vf_msg is used for mailbox message from
PF to VF, including both response and request. But its definition
can only indicate respone, which makes the message data copy in
function hclge_send_mbx_msg() unreadable. So refine it by edding
a general message definition into it.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c

index b668df6193be4ede325b6baf9101cdea4f95f160..8c7fadf2b734c7abfb9b469be4f16eacbae5545c 100644 (file)
@@ -135,10 +135,19 @@ struct hclge_vf_to_pf_msg {
 
 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];
+       union {
+               /* used for mbx response */
+               struct {
+                       u16 vf_mbx_msg_code;
+                       u16 vf_mbx_msg_subcode;
+                       u16 resp_status;
+                       u8 resp_data[HCLGE_MBX_MAX_RESP_DATA_SIZE];
+               };
+               /* used for general mbx */
+               struct {
+                       u8 msg_data[HCLGE_MBX_MAX_MSG_SIZE];
+               };
+       };
 };
 
 struct hclge_mbx_vf_to_pf_cmd {
index 6799d16de34b9490f60fe67c94a2619e329e0ca4..76d0f17d6be374f9b9c094f3fdae99b7dc924aee 100644 (file)
@@ -102,7 +102,7 @@ static int hclge_send_mbx_msg(struct hclge_vport *vport, u8 *msg, u16 msg_len,
        resp_pf_to_vf->msg_len = msg_len;
        resp_pf_to_vf->msg.code = mbx_opcode;
 
-       memcpy(&resp_pf_to_vf->msg.vf_mbx_msg_code, msg, msg_len);
+       memcpy(resp_pf_to_vf->msg.msg_data, msg, msg_len);
 
        trace_hclge_pf_mbx_send(hdev, resp_pf_to_vf);