Skip to content

Commit d341001

Browse files
Yufeng Modavem330
authored andcommitted
net: hns3: refactor the mailbox message between PF and VF
For making the code more readable, this adds several new structure to replace the msg field in structure hclge_mbx_vf_to_pf_cmd and hclge_mbx_pf_to_vf_cmd. Also uses macro to instead of some magic number. Signed-off-by: Yufeng Mo <[email protected]> Signed-off-by: Huazhong Tan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 027fd53 commit d341001

File tree

5 files changed

+291
-234
lines changed

5 files changed

+291
-234
lines changed

drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
#include <linux/mutex.h>
88
#include <linux/types.h>
99

10-
#define HCLGE_MBX_VF_MSG_DATA_NUM 16
11-
1210
enum HCLGE_MBX_OPCODE {
1311
HCLGE_MBX_RESET = 0x01, /* (VF -> PF) assert reset */
1412
HCLGE_MBX_ASSERTING_RESET, /* (PF -> VF) PF is asserting reset*/
@@ -72,10 +70,15 @@ enum hclge_mbx_vlan_cfg_subcode {
7270
HCLGE_MBX_GET_PORT_BASE_VLAN_STATE, /* get port based vlan state */
7371
};
7472

75-
#define HCLGE_MBX_MAX_MSG_SIZE 16
73+
#define HCLGE_MBX_MAX_MSG_SIZE 14
7674
#define HCLGE_MBX_MAX_RESP_DATA_SIZE 8U
77-
#define HCLGE_MBX_RING_MAP_BASIC_MSG_NUM 3
78-
#define HCLGE_MBX_RING_NODE_VARIABLE_NUM 3
75+
#define HCLGE_MBX_MAX_RING_CHAIN_PARAM_NUM 4
76+
77+
struct hclge_ring_chain_param {
78+
u8 ring_type;
79+
u8 tqp_index;
80+
u8 int_gl_index;
81+
};
7982

8083
struct hclgevf_mbx_resp_status {
8184
struct mutex mbx_mutex; /* protects against contending sync cmd resp */
@@ -85,14 +88,43 @@ struct hclgevf_mbx_resp_status {
8588
u8 additional_info[HCLGE_MBX_MAX_RESP_DATA_SIZE];
8689
};
8790

91+
struct hclge_vf_to_pf_msg {
92+
u8 code;
93+
union {
94+
struct {
95+
u8 subcode;
96+
u8 data[HCLGE_MBX_MAX_MSG_SIZE];
97+
};
98+
struct {
99+
u8 en_bc;
100+
u8 en_uc;
101+
u8 en_mc;
102+
};
103+
struct {
104+
u8 vector_id;
105+
u8 ring_num;
106+
struct hclge_ring_chain_param
107+
param[HCLGE_MBX_MAX_RING_CHAIN_PARAM_NUM];
108+
};
109+
};
110+
};
111+
112+
struct hclge_pf_to_vf_msg {
113+
u16 code;
114+
u16 vf_mbx_msg_code;
115+
u16 vf_mbx_msg_subcode;
116+
u16 resp_status;
117+
u8 resp_data[HCLGE_MBX_MAX_RESP_DATA_SIZE];
118+
};
119+
88120
struct hclge_mbx_vf_to_pf_cmd {
89121
u8 rsv;
90122
u8 mbx_src_vfid; /* Auto filled by IMP */
91123
u8 mbx_need_resp;
92124
u8 rsv1[1];
93125
u8 msg_len;
94126
u8 rsv2[3];
95-
u8 msg[HCLGE_MBX_MAX_MSG_SIZE];
127+
struct hclge_vf_to_pf_msg msg;
96128
};
97129

98130
#define HCLGE_MBX_NEED_RESP_BIT BIT(0)
@@ -102,7 +134,7 @@ struct hclge_mbx_pf_to_vf_cmd {
102134
u8 rsv[3];
103135
u8 msg_len;
104136
u8 rsv1[3];
105-
u16 msg[8];
137+
struct hclge_pf_to_vf_msg msg;
106138
};
107139

108140
struct hclge_vf_rst_cmd {

0 commit comments

Comments
 (0)