1
2
3
4#ifndef __HCLGE_MBX_H
5#define __HCLGE_MBX_H
6#include <linux/init.h>
7#include <linux/mutex.h>
8#include <linux/types.h>
9
10enum HCLGE_MBX_OPCODE {
11 HCLGE_MBX_RESET = 0x01,
12 HCLGE_MBX_ASSERTING_RESET,
13 HCLGE_MBX_SET_UNICAST,
14 HCLGE_MBX_SET_MULTICAST,
15 HCLGE_MBX_SET_VLAN,
16 HCLGE_MBX_MAP_RING_TO_VECTOR,
17 HCLGE_MBX_UNMAP_RING_TO_VECTOR,
18 HCLGE_MBX_SET_PROMISC_MODE,
19 HCLGE_MBX_SET_MACVLAN,
20 HCLGE_MBX_API_NEGOTIATE,
21 HCLGE_MBX_GET_QINFO,
22 HCLGE_MBX_GET_QDEPTH,
23 HCLGE_MBX_GET_BASIC_INFO,
24 HCLGE_MBX_GET_RETA,
25 HCLGE_MBX_GET_RSS_KEY,
26 HCLGE_MBX_GET_MAC_ADDR,
27 HCLGE_MBX_PF_VF_RESP,
28 HCLGE_MBX_GET_BDNUM,
29 HCLGE_MBX_GET_BUFSIZE,
30 HCLGE_MBX_GET_STREAMID,
31 HCLGE_MBX_SET_AESTART,
32 HCLGE_MBX_SET_TSOSTATS,
33 HCLGE_MBX_LINK_STAT_CHANGE,
34 HCLGE_MBX_GET_BASE_CONFIG,
35 HCLGE_MBX_BIND_FUNC_QUEUE,
36 HCLGE_MBX_GET_LINK_STATUS,
37 HCLGE_MBX_QUEUE_RESET,
38 HCLGE_MBX_KEEP_ALIVE,
39 HCLGE_MBX_SET_ALIVE,
40 HCLGE_MBX_SET_MTU,
41 HCLGE_MBX_GET_QID_IN_PF,
42 HCLGE_MBX_LINK_STAT_MODE,
43 HCLGE_MBX_GET_LINK_MODE,
44 HCLGE_MBX_PUSH_VLAN_INFO,
45 HCLGE_MBX_GET_MEDIA_TYPE,
46 HCLGE_MBX_PUSH_PROMISC_INFO,
47 HCLGE_MBX_VF_UNINIT,
48 HCLGE_MBX_HANDLE_VF_TBL,
49
50 HCLGE_MBX_GET_VF_FLR_STATUS = 200,
51 HCLGE_MBX_PUSH_LINK_STATUS,
52 HCLGE_MBX_NCSI_ERROR,
53};
54
55
56enum hclge_mbx_mac_vlan_subcode {
57 HCLGE_MBX_MAC_VLAN_UC_MODIFY = 0,
58 HCLGE_MBX_MAC_VLAN_UC_ADD,
59 HCLGE_MBX_MAC_VLAN_UC_REMOVE,
60 HCLGE_MBX_MAC_VLAN_MC_MODIFY,
61 HCLGE_MBX_MAC_VLAN_MC_ADD,
62 HCLGE_MBX_MAC_VLAN_MC_REMOVE,
63};
64
65
66enum hclge_mbx_vlan_cfg_subcode {
67 HCLGE_MBX_VLAN_FILTER = 0,
68 HCLGE_MBX_VLAN_TX_OFF_CFG,
69 HCLGE_MBX_VLAN_RX_OFF_CFG,
70 HCLGE_MBX_PORT_BASE_VLAN_CFG,
71 HCLGE_MBX_GET_PORT_BASE_VLAN_STATE,
72 HCLGE_MBX_ENABLE_VLAN_FILTER,
73};
74
75enum hclge_mbx_tbl_cfg_subcode {
76 HCLGE_MBX_VPORT_LIST_CLEAR,
77};
78
79#define HCLGE_MBX_MAX_MSG_SIZE 14
80#define HCLGE_MBX_MAX_RESP_DATA_SIZE 8U
81#define HCLGE_MBX_MAX_RING_CHAIN_PARAM_NUM 4
82
83struct hclge_ring_chain_param {
84 u8 ring_type;
85 u8 tqp_index;
86 u8 int_gl_index;
87};
88
89struct hclge_basic_info {
90 u8 hw_tc_map;
91 u8 rsv;
92 u16 mbx_api_version;
93 u32 pf_caps;
94};
95
96struct hclgevf_mbx_resp_status {
97 struct mutex mbx_mutex;
98 u32 origin_mbx_msg;
99 bool received_resp;
100 int resp_status;
101 u16 match_id;
102 u8 additional_info[HCLGE_MBX_MAX_RESP_DATA_SIZE];
103};
104
105struct hclge_respond_to_vf_msg {
106 int status;
107 u8 data[HCLGE_MBX_MAX_RESP_DATA_SIZE];
108 u16 len;
109};
110
111struct hclge_vf_to_pf_msg {
112 u8 code;
113 union {
114 struct {
115 u8 subcode;
116 u8 data[HCLGE_MBX_MAX_MSG_SIZE];
117 };
118 struct {
119 u8 en_bc;
120 u8 en_uc;
121 u8 en_mc;
122 u8 en_limit_promisc;
123 };
124 struct {
125 u8 vector_id;
126 u8 ring_num;
127 struct hclge_ring_chain_param
128 param[HCLGE_MBX_MAX_RING_CHAIN_PARAM_NUM];
129 };
130 };
131};
132
133struct hclge_pf_to_vf_msg {
134 u16 code;
135 u16 vf_mbx_msg_code;
136 u16 vf_mbx_msg_subcode;
137 u16 resp_status;
138 u8 resp_data[HCLGE_MBX_MAX_RESP_DATA_SIZE];
139};
140
141struct hclge_mbx_vf_to_pf_cmd {
142 u8 rsv;
143 u8 mbx_src_vfid;
144 u8 mbx_need_resp;
145 u8 rsv1[1];
146 u8 msg_len;
147 u8 rsv2;
148 u16 match_id;
149 struct hclge_vf_to_pf_msg msg;
150};
151
152#define HCLGE_MBX_NEED_RESP_B 0
153
154struct hclge_mbx_pf_to_vf_cmd {
155 u8 dest_vfid;
156 u8 rsv[3];
157 u8 msg_len;
158 u8 rsv1;
159 u16 match_id;
160 struct hclge_pf_to_vf_msg msg;
161};
162
163struct hclge_vf_rst_cmd {
164 u8 dest_vfid;
165 u8 vf_rst;
166 u8 rsv[22];
167};
168
169
170struct hclgevf_mbx_arq_ring {
171#define HCLGE_MBX_MAX_ARQ_MSG_SIZE 8
172#define HCLGE_MBX_MAX_ARQ_MSG_NUM 1024
173 struct hclgevf_dev *hdev;
174 u32 head;
175 u32 tail;
176 atomic_t count;
177 u16 msg_q[HCLGE_MBX_MAX_ARQ_MSG_NUM][HCLGE_MBX_MAX_ARQ_MSG_SIZE];
178};
179
180#define hclge_mbx_ring_ptr_move_crq(crq) \
181 (crq->next_to_use = (crq->next_to_use + 1) % crq->desc_num)
182#define hclge_mbx_tail_ptr_move_arq(arq) \
183 (arq.tail = (arq.tail + 1) % HCLGE_MBX_MAX_ARQ_MSG_NUM)
184#define hclge_mbx_head_ptr_move_arq(arq) \
185 (arq.head = (arq.head + 1) % HCLGE_MBX_MAX_ARQ_MSG_NUM)
186
187
188#define HCLGE_MBX_PUSH_LINK_STATUS_EN BIT(0)
189#endif
190