1
2
3
4
5#ifndef __THUNDERX_NICVF_MBOX__
6#define __THUNDERX_NICVF_MBOX__
7
8#include <stdint.h>
9
10#include "nicvf_plat.h"
11#include "../nicvf_struct.h"
12
13
14
15
16
17
18
19#define NIC_PF_VF_MAILBOX_SIZE 2
20#define NIC_MBOX_MSG_TIMEOUT 2000
21
22
23#define NIC_MBOX_MSG_INVALID 0x00
24#define NIC_MBOX_MSG_READY 0x01
25#define NIC_MBOX_MSG_ACK 0x02
26#define NIC_MBOX_MSG_NACK 0x03
27#define NIC_MBOX_MSG_QS_CFG 0x04
28#define NIC_MBOX_MSG_RQ_CFG 0x05
29#define NIC_MBOX_MSG_SQ_CFG 0x06
30#define NIC_MBOX_MSG_RQ_DROP_CFG 0x07
31#define NIC_MBOX_MSG_SET_MAC 0x08
32#define NIC_MBOX_MSG_SET_MAX_FRS 0x09
33#define NIC_MBOX_MSG_CPI_CFG 0x0A
34#define NIC_MBOX_MSG_RSS_SIZE 0x0B
35#define NIC_MBOX_MSG_RSS_CFG 0x0C
36#define NIC_MBOX_MSG_RSS_CFG_CONT 0x0D
37#define NIC_MBOX_MSG_RQ_BP_CFG 0x0E
38#define NIC_MBOX_MSG_RQ_SW_SYNC 0x0F
39#define NIC_MBOX_MSG_BGX_LINK_CHANGE 0x11
40#define NIC_MBOX_MSG_ALLOC_SQS 0x12
41#define NIC_MBOX_MSG_LOOPBACK 0x16
42#define NIC_MBOX_MSG_RESET_STAT_COUNTER 0x17
43#define NIC_MBOX_MSG_SET_LINK 0x21
44#define NIC_MBOX_MSG_CHANGE_MODE 0x22
45#define NIC_MBOX_MSG_CFG_DONE 0xF0
46#define NIC_MBOX_MSG_SHUTDOWN 0xF1
47#define NIC_MBOX_MSG_RESET_XCAST 0xF2
48#define NIC_MBOX_MSG_MAX 0x100
49
50
51struct nic_cfg_msg {
52 uint8_t msg;
53 uint8_t vf_id;
54 uint8_t node_id;
55 bool tns_mode:1;
56 bool sqs_mode:1;
57 bool loopback_supported:1;
58 uint8_t mac_addr[NICVF_MAC_ADDR_SIZE];
59};
60
61
62struct qs_cfg_msg {
63 uint8_t msg;
64 uint8_t num;
65 uint8_t sqs_count;
66 uint64_t cfg;
67};
68
69
70struct rq_cfg_msg {
71 uint8_t msg;
72 uint8_t qs_num;
73 uint8_t rq_num;
74 uint64_t cfg;
75};
76
77
78struct sq_cfg_msg {
79 uint8_t msg;
80 uint8_t qs_num;
81 uint8_t sq_num;
82 bool sqs_mode;
83 uint64_t cfg;
84};
85
86
87struct set_mac_msg {
88 uint8_t msg;
89 uint8_t vf_id;
90 uint8_t mac_addr[NICVF_MAC_ADDR_SIZE];
91};
92
93
94struct set_frs_msg {
95 uint8_t msg;
96 uint8_t vf_id;
97 uint16_t max_frs;
98};
99
100
101struct cpi_cfg_msg {
102 uint8_t msg;
103 uint8_t vf_id;
104 uint8_t rq_cnt;
105 uint8_t cpi_alg;
106};
107
108
109struct rss_sz_msg {
110 uint8_t msg;
111 uint8_t vf_id;
112 uint16_t ind_tbl_size;
113};
114
115
116struct rss_cfg_msg {
117 uint8_t msg;
118 uint8_t vf_id;
119 uint8_t hash_bits;
120 uint8_t tbl_len;
121 uint8_t tbl_offset;
122#define RSS_IND_TBL_LEN_PER_MBX_MSG 8
123 uint8_t ind_tbl[RSS_IND_TBL_LEN_PER_MBX_MSG];
124};
125
126
127struct bgx_link_status {
128 uint8_t msg;
129 uint8_t mac_type;
130 uint8_t link_up;
131 uint8_t duplex;
132 uint32_t speed;
133};
134
135
136struct sqs_alloc {
137 uint8_t msg;
138 uint8_t spec;
139 uint8_t qs_count;
140 uint8_t svf[MAX_SQS_PER_VF];
141};
142
143
144struct set_loopback {
145 uint8_t msg;
146 uint8_t vf_id;
147 bool enable;
148};
149
150
151struct reset_stat_cfg {
152 uint8_t msg;
153
154 uint16_t rx_stat_mask;
155
156 uint8_t tx_stat_mask;
157
158
159
160
161
162
163
164 uint16_t rq_stat_mask;
165
166
167
168
169
170
171
172 uint16_t sq_stat_mask;
173};
174
175
176struct set_link_state {
177 uint8_t msg;
178 uint8_t vf_id;
179 bool enable;
180};
181
182
183struct change_link_mode_msg {
184 uint8_t msg;
185 uint8_t vf_id;
186 uint8_t qlm_mode;
187 bool autoneg;
188 uint8_t duplex;
189 uint32_t speed;
190
191};
192
193struct nic_mbx {
194
195union {
196 struct { uint8_t msg; } msg;
197 struct nic_cfg_msg nic_cfg;
198 struct qs_cfg_msg qs;
199 struct rq_cfg_msg rq;
200 struct sq_cfg_msg sq;
201 struct set_mac_msg mac;
202 struct set_frs_msg frs;
203 struct cpi_cfg_msg cpi_cfg;
204 struct rss_sz_msg rss_size;
205 struct rss_cfg_msg rss_cfg;
206 struct bgx_link_status link_status;
207 struct sqs_alloc sqs_alloc;
208 struct set_loopback lbk;
209 struct reset_stat_cfg reset_stat;
210 struct set_link_state set_link;
211 struct change_link_mode_msg mode;
212};
213};
214
215NICVF_STATIC_ASSERT(sizeof(struct nic_mbx) <= 16);
216
217int nicvf_handle_mbx_intr(struct nicvf *nic);
218int nicvf_mbox_check_pf_ready(struct nicvf *nic);
219int nicvf_mbox_qset_config(struct nicvf *nic, struct pf_qs_cfg *qs_cfg);
220int nicvf_mbox_request_sqs(struct nicvf *nic);
221int nicvf_mbox_rq_config(struct nicvf *nic, uint16_t qidx,
222 struct pf_rq_cfg *pf_rq_cfg);
223int nicvf_mbox_sq_config(struct nicvf *nic, uint16_t qidx);
224int nicvf_mbox_rq_drop_config(struct nicvf *nic, uint16_t qidx, bool enable);
225int nicvf_mbox_rq_bp_config(struct nicvf *nic, uint16_t qidx, bool enable);
226int nicvf_mbox_set_mac_addr(struct nicvf *nic,
227 const uint8_t mac[NICVF_MAC_ADDR_SIZE]);
228int nicvf_mbox_config_cpi(struct nicvf *nic, uint32_t qcnt);
229int nicvf_mbox_get_rss_size(struct nicvf *nic);
230int nicvf_mbox_config_rss(struct nicvf *nic);
231int nicvf_mbox_update_hw_max_frs(struct nicvf *nic, uint16_t mtu);
232int nicvf_mbox_rq_sync(struct nicvf *nic);
233int nicvf_mbox_loopback_config(struct nicvf *nic, bool enable);
234int nicvf_mbox_reset_stat_counters(struct nicvf *nic, uint16_t rx_stat_mask,
235 uint8_t tx_stat_mask, uint16_t rq_stat_mask, uint16_t sq_stat_mask);
236int nicvf_mbox_set_link_up_down(struct nicvf *nic, bool enable);
237void nicvf_mbox_shutdown(struct nicvf *nic);
238void nicvf_mbox_cfg_done(struct nicvf *nic);
239void nicvf_mbox_link_change(struct nicvf *nic);
240void nicvf_mbox_reset_xcast(struct nicvf *nic);
241int nicvf_mbox_change_mode(struct nicvf *nic, struct change_link_mode *cfg);
242
243#endif
244