xref: /titanic_51/usr/src/uts/common/io/bnxe/577xx/drivers/common/include/vm/vfpf_if.h (revision d14abf155341d55053c76eeec58b787a456b753b)
1 #ifndef VF_PF_SW_IF_H
2 #define VF_PF_SW_IF_H
3 
4 
5 /*
6  * common flags - right now it duplicates the #defines in the PF code -
7  * TODO: put in another common header file
8  */
9 #define SW_VFPF_QUEUE_FLG_TPA   		0x0001
10 #define SW_VFPF_QUEUE_FLG_CACHE_ALIGN   	0x0002
11 #define SW_VFPF_QUEUE_FLG_STATS		0x0004
12 #define SW_VFPF_QUEUE_FLG_OV    		0x0008
13 #define SW_VFPF_QUEUE_FLG_VLAN  		0x0010
14 #define SW_VFPF_QUEUE_FLG_COS   		0x0020
15 #define SW_VFPF_QUEUE_FLG_HC		0x0040
16 #define SW_VFPF_QUEUE_FLG_DHC		0x0080
17 
18 #define SW_VFPF_QUEUE_DROP_IP_CS_ERR	(1 << 0)
19 #define SW_VFPF_QUEUE_DROP_TCP_CS_ERR	(1 << 1)
20 #define SW_VFPF_QUEUE_DROP_TTL0		(1 << 2)
21 #define SW_VFPF_QUEUE_DROP_UDP_CS_ERR	(1 << 3)
22 
23 #define SW_VFPF_VFDEF_INFO_AUX_DIRECT_DQ   0x01
24 
25 enum {
26 	SW_PFVF_STATUS_WAITING = 0,
27 	SW_PFVF_STATUS_SUCCESS,
28 	SW_PFVF_STATUS_FAILURE,
29 	SW_PFVF_STATUS_NOT_SUPPORTED,
30     SW_PFVF_STATUS_MISMATCH_PF_VF_VERSION,
31     SW_PFVF_STATUS_NO_RESOURCE,
32     SW_PFVF_STATUS_MISMATCH_FW_HSI
33 };
34 
35 /*  Headers */
36 struct vf_pf_msg_hdr {
37 	u16 opcode;
38 
39 #define PFVF_IF_VERSION     	   1
40 	u8  if_ver;
41 	u8  opcode_ver;
42 	u32 resp_msg_offset;
43 };
44 
45 struct pf_vf_msg_hdr {
46 	u8 status;
47 	u8 opcode_ver;
48 	u16 opcode;
49 };
50 
51 /* simple response */
52 struct pf_vf_msg_resp {
53 	struct pf_vf_msg_hdr    hdr;
54 };
55 
56 
57 /* Acquire */
58 struct vf_pf_msg_acquire {
59 	struct vf_pf_msg_hdr hdr;
60 
61 	struct sw_vf_pf_vfdev_info
62 	{
63 		/* the following fields are for debug purposes */
64 		u8  vf_id;      	/* ME register value */
65 		u8  vf_os;      	/* e.g. Linux, W2K8 */
66         u8  vf_aux;
67         u8  fp_hsi_ver;
68         u32 vf_fw_hsi_version;  /* e.g. 6.0.12 */
69 	} vfdev_info;
70 
71 	struct sw_vf_pf_resc_request
72 	{
73 		u8  num_rxqs;
74 		u8  num_txqs;
75 		u8  num_sbs;
76 		u8  num_mac_filters;
77 		u8  num_vlan_filters;
78 		u8  num_mc_filters;
79         u8  reserved1;
80         u8  reserved2;
81 
82 	/* TODO: future:
83 		statistics resc?, other resc?   */
84 	} resc_request;
85 };
86 
87 
88 /* simple operation request on queue */
89 struct vf_pf_msg_q_op {
90 	struct vf_pf_msg_hdr    hdr;
91 	u8      		vf_qid;
92 	u8			padding[3];
93 };
94 
95 struct vf_pf_msg_rss {
96 	struct vf_pf_msg_hdr    hdr;
97 	u32   					rss_flags;
98 
99 	/* Number hash bits to take into an account */
100 	u8  					rss_result_mask;
101 
102 	u8						ind_table_size;
103 	u8						rss_key_size;
104 
105 	/* Indirection table */
106 	u8  					ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
107 
108 	/* RSS hash values */
109 	u32 					rss_key[10];
110 };
111 
112 struct vf_pf_msg_rsc {
113     struct vf_pf_msg_hdr    hdr;
114     u32                     rsc_ipv4_state;
115     u32                     rsc_ipv6_state;
116 };
117 
118 struct sw_hw_sb_info {
119 	u8 hw_sb_id;	/* aka absolute igu id, used to ack the sb */
120 	u8 sb_qid;	/* used to update DHC for sb */
121 };
122 
123 struct pf_vf_msg_acquire_resp {
124 	struct pf_vf_msg_hdr hdr;
125 
126 	struct sw_pf_vf_pfdev_info
127 	{
128 		u32 chip_num;
129 
130 		u32 pf_cap;
131 		#define PFVF_CAP_RSS        0x00000001
132 		#define PFVF_CAP_DHC        0x00000002
133 		#define PFVF_CAP_TPA        0x00000004
134                 #define PFVF_DEBUG          0x80000000
135 
136 		u16 db_size;
137 		u8  indices_per_sb;
138 		u8  padding;
139 	} pfdev_info;
140 
141 	struct sw_pf_vf_resc
142 	{
143 		/*
144 		 * in case of status NO_RESOURCE in message hdr, pf will fill
145 		 * this struct with suggested amount of resources for next
146 		 * acquire request
147 		 */
148 
149 		#define PFVF_MAX_QUEUES_PER_VF         16
150 		#define PFVF_MAX_SBS_PER_VF            16
151 		struct sw_hw_sb_info hw_sbs[PFVF_MAX_SBS_PER_VF];
152 		u8	hw_qid[PFVF_MAX_QUEUES_PER_VF];
153 		u8	num_rxqs;
154 		u8	num_txqs;
155 		u8	num_sbs;
156 		u8	num_mac_filters;
157 		u8	num_vlan_filters;
158 		u8	num_mc_filters;
159 		u8  igu_test_cnt;
160 		u8  igu_cnt;
161 		u8 	permanent_mac_addr[8];
162 		u8 	current_mac_addr[8];
163 	/* TODO: stats resc? cid for the ramrod? stats_id? spq prod id? */
164 	} resc;
165 };
166 
167 /* Init VF */
168 struct vf_pf_msg_init_vf {
169 	struct vf_pf_msg_hdr hdr;
170 
171 	u64 sb_addr[PFVF_MAX_SBS_PER_VF]; /* vf_sb based */
172 	u64 spq_addr;
173 	u64 stats_addr;
174 };
175 
176 /* Setup Queue */
177 struct vf_pf_msg_setup_q {
178 	struct vf_pf_msg_hdr hdr;
179 	u8 vf_qid;			/* index in hw_qid[] */
180 
181 	u8 param_valid;
182 	#define VFPF_RXQ_VALID		0x01
183 	#define VFPF_TXQ_VALID		0x02
184 
185 	u16 padding;
186 
187 	struct sw_vf_pf_rxq_params {
188 		/* physical addresses */
189 		u64 rcq_addr;
190 		u64 rcq_np_addr;
191 		u64 rxq_addr;
192 		u64 sge_addr;
193 
194 		/* sb + hc info */
195 		u8  vf_sb;		/* index in hw_sbs[] */
196 		u8  sb_index;           /* Index in the SB */
197 		u16 hc_rate;		/* desired interrupts per sec. */
198 					/* valid iff VFPF_QUEUE_FLG_HC */
199 		/* rx buffer info */
200 		u16 mtu;
201 		u16 buf_sz;
202 		u16 flags;              /* VFPF_QUEUE_FLG_X flags */
203 		u16 stat_id;		/* valid iff VFPF_QUEUE_FLG_STATS */
204 
205 		/* valid iff VFPF_QUEUE_FLG_TPA */
206 		u16 sge_buf_sz;
207 		u16 tpa_agg_sz;
208 		u8 max_sge_pkt;
209 
210 		u8 drop_flags;		/* VFPF_QUEUE_DROP_X, for Linux all should
211 					 * be turned off, see setup_rx_queue()
212 					 * for reference
213 					 */
214 
215 		u8 cache_line_log;	/* VFPF_QUEUE_FLG_CACHE_ALIGN
216 					 * see init_rx_queue()
217 					 */
218 		u8 padding;
219 	} rxq;
220 
221 	struct sw_vf_pf_txq_params {
222 		/* physical addresses */
223 		u64 txq_addr;
224 
225 		/* sb + hc info */
226 		u8  vf_sb;		/* index in hw_sbs[] */
227 		u8  sb_index;		/* Index in the SB */
228 		u16 hc_rate;		/* desired interrupts per sec. */
229 					/* valid iff VFPF_QUEUE_FLG_HC */
230 		u32 flags;		/* VFPF_QUEUE_FLG_X flags */
231 		u16 stat_id;		/* valid iff VFPF_QUEUE_FLG_STATS */
232 		u8  traffic_type;	/* see in setup_context() */
233 		u8  padding;
234 	} txq;
235 };
236 
237 
238 /* Set Queue Filters */
239 struct vf_pf_q_mac_vlan_filter {
240 	u32 flags;
241 	#define VFPF_Q_FILTER_DEST_MAC_PRESENT 	0x01
242 	#define VFPF_Q_FILTER_VLAN_TAG_PRESENT	0x02
243 
244 	#define VFPF_Q_FILTER_SET_MAC			0x100
245 
246 	u8  dest_mac[6];
247 	u16 vlan_tag;
248 };
249 
250 struct vf_pf_msg_set_q_filters {
251 	struct vf_pf_msg_hdr hdr;
252 
253 	u32 flags;
254 	#define VFPF_SET_Q_FILTERS_MAC_VLAN_CHANGED 	0x01
255 	#define VFPF_SET_Q_FILTERS_MULTICAST_CHANGED	0x02
256 	#define VFPF_SET_Q_FILTERS_RX_MASK_CHANGED  	0x04
257 
258 	u8 vf_qid;			/* index in hw_qid[] */
259 	u8 n_mac_vlan_filters;
260 	u8 n_multicast;
261 	u8 padding;
262 
263 	#define PFVF_MAX_MAC_FILTERS			16
264 	#define PFVF_MAX_VLAN_FILTERS       		16
265 //	#define PFVF_MAX_MAC_FILTERS			1
266 //	#define PFVF_MAX_VLAN_FILTERS       		1
267 	#define PFVF_MAX_FILTERS 			(PFVF_MAX_MAC_FILTERS +\
268 							 PFVF_MAX_VLAN_FILTERS)
269 	struct vf_pf_q_mac_vlan_filter filters[PFVF_MAX_FILTERS];
270 
271 	#define PFVF_MAX_MULTICAST_PER_VF   		32
272 //	#define PFVF_MAX_MULTICAST_PER_VF   		1
273 	u8  multicast[PFVF_MAX_MULTICAST_PER_VF][6];
274 
275 	u32 rx_mask;
276 	#define VFPF_RX_MASK_ACCEPT_NONE		0x00000000
277 	#define VFPF_RX_MASK_ACCEPT_MATCHED_UNICAST	0x00000001
278 	#define VFPF_RX_MASK_ACCEPT_MATCHED_MULTICAST	0x00000002
279 	#define VFPF_RX_MASK_ACCEPT_ALL_UNICAST		0x00000004
280 	#define VFPF_RX_MASK_ACCEPT_ALL_MULTICAST	0x00000008
281 	#define VFPF_RX_MASK_ACCEPT_BROADCAST		0x00000010
282 	/* TODO: #define VFPF_RX_MASK_ACCEPT_ANY_VLAN	0x00000020 */
283 };
284 
285 
286 /* close VF (disable VF) */
287 struct vf_pf_msg_close_vf {
288 	struct vf_pf_msg_hdr	hdr;
289 	u16			vf_id;  /* for debug */
290 	u16			padding;
291 };
292 
293 /* rlease the VF's acquired resources */
294 struct vf_pf_msg_release_vf {
295 	struct vf_pf_msg_hdr	hdr;
296 	u16			vf_id;  /* for debug */
297 	u16			padding;
298 };
299 
300 
301 union vf_pf_msg {
302 	struct vf_pf_msg_hdr		hdr;
303 	struct vf_pf_msg_acquire	acquire;
304 	struct vf_pf_msg_init_vf	init_vf;
305 	struct vf_pf_msg_close_vf	close_vf;
306 	struct vf_pf_msg_q_op		q_op;
307 	struct vf_pf_msg_setup_q	setup_q;
308 	struct vf_pf_msg_set_q_filters	set_q_filters;
309 	struct vf_pf_msg_release_vf	release_vf;
310 	struct vf_pf_msg_rss		update_rss;
311     struct vf_pf_msg_rsc        update_rsc;
312 };
313 
314 
315 union pf_vf_msg {
316 	struct pf_vf_msg_resp		resp;
317 	struct pf_vf_msg_acquire_resp	acquire_resp;
318 };
319 
320 typedef struct {
321 	u32 req_sz;
322 	u32 resp_sz;
323 } msg_sz_t;
324 
325 #define PFVF_OP_VER_MAX(op_arry)  (sizeof(op_arry)/sizeof(*op_arry) - 1)
326 
327 static const msg_sz_t acquire_req_sz[] = {
328 	/* sizeof(vf_pf_msg_acquire) - offsetof(struct vf_pf_msg_acquire, fieldX), */
329 	{sizeof(struct vf_pf_msg_acquire),
330 	sizeof(struct pf_vf_msg_acquire_resp)}
331 };
332 #define PFVF_ACQUIRE_VER  PFVF_OP_VER_MAX(acquire_req_sz)
333 
334 static const msg_sz_t init_vf_req_sz[] = {
335 	{sizeof(struct vf_pf_msg_init_vf), sizeof(struct pf_vf_msg_resp)}
336 };
337 #define PFVF_INIT_VF_VER  PFVF_OP_VER_MAX(init_vf_req_sz)
338 
339 static const msg_sz_t setup_q_req_sz[] = {
340 	{sizeof(struct vf_pf_msg_setup_q), sizeof(struct pf_vf_msg_resp)}
341 };
342 #define PFVF_SETUP_Q_VER  PFVF_OP_VER_MAX(setup_q_req_sz)
343 
344 static const msg_sz_t set_q_filters_req_sz[] = {
345 	{sizeof(struct vf_pf_msg_set_q_filters), sizeof(struct pf_vf_msg_resp)}
346 };
347 #define PFVF_SET_Q_FILTERS_VER  PFVF_OP_VER_MAX(set_q_filters_req_sz)
348 
349 static const msg_sz_t activate_q_req_sz[] = {
350 	{sizeof(struct vf_pf_msg_q_op), sizeof(struct pf_vf_msg_resp)}
351 };
352 #define PFVF_ACTIVATE_Q_VER  PFVF_OP_VER_MAX(activate_q_req_sz)
353 
354 static const msg_sz_t deactivate_q_req_sz[] = {
355 	{sizeof(struct vf_pf_msg_q_op), sizeof(struct pf_vf_msg_resp)}
356 };
357 #define PFVF_DEACTIVATE_Q_VER  PFVF_OP_VER_MAX(deactivate_q_req_sz)
358 
359 static const msg_sz_t teardown_q_req_sz[] = {
360 	{sizeof(struct vf_pf_msg_q_op), sizeof(struct pf_vf_msg_resp)}
361 };
362 #define PFVF_TEARDOWN_Q_VER  PFVF_OP_VER_MAX(teardown_q_req_sz)
363 
364 static const msg_sz_t close_vf_req_sz[] = {
365 	{sizeof(struct vf_pf_msg_close_vf), sizeof(struct pf_vf_msg_resp)}
366 };
367 #define PFVF_CLOSE_VF_VER  PFVF_OP_VER_MAX(close_vf_req_sz)
368 
369 static const msg_sz_t release_vf_req_sz[] = {
370 	{sizeof(struct vf_pf_msg_release_vf), sizeof(struct pf_vf_msg_resp)}
371 };
372 #define PFVF_RELEASE_VF_VER  PFVF_OP_VER_MAX(release_vf_req_sz)
373 
374 static const msg_sz_t update_rss_req_sz[] = {
375 	{sizeof(struct vf_pf_msg_rss), sizeof(struct pf_vf_msg_resp)}
376 };
377 #define PFVF_UPDATE_RSS_VER  PFVF_OP_VER_MAX(update_rss_req_sz)
378 
379 static const msg_sz_t update_rsc_req_sz[] = {
380     {sizeof(struct vf_pf_msg_rsc), sizeof(struct pf_vf_msg_resp)}
381 };
382 #define PFVF_UPDATE_RSC_VER  PFVF_OP_VER_MAX(update_rsc_req_sz)
383 
384 enum {
385 	PFVF_OP_ACQUIRE = 0,
386 	PFVF_OP_INIT_VF,
387 	PFVF_OP_SETUP_Q,
388 	PFVF_OP_SET_Q_FILTERS,
389 	PFVF_OP_ACTIVATE_Q,
390 	PFVF_OP_DEACTIVATE_Q,
391 	PFVF_OP_TEARDOWN_Q,
392 	PFVF_OP_CLOSE_VF,
393 	PFVF_OP_RELEASE_VF,
394 	PFVF_OP_UPDATE_RSS,
395     PFVF_OP_UPDATE_RSC,
396 	PFVF_OP_MAX
397 };
398 
399 
400 /** To get size of message of the type X(request or response)
401  *  for the op_code Y of the version Z one should use
402  *
403  *  op_code_req_sz[Y][Z].req_sz/resp_sz
404  ******************************************************************/
405 /* const msg_sz_t* op_codes_req_sz[] = {
406 	(const msg_sz_t*)acquire_req_sz,
407 	(const msg_sz_t*)init_vf_req_sz,
408 	(const msg_sz_t*)setup_q_req_sz,
409 	(const msg_sz_t*)set_q_filters_req_sz,
410 	(const msg_sz_t*)activate_q_req_sz,
411 	(const msg_sz_t*)deactivate_q_req_sz,
412 	(const msg_sz_t*)teardown_q_req_sz,
413 	(const msg_sz_t*)close_vf_req_sz,
414 	(const msg_sz_t*)release_vf_req_sz
415 }; */
416 
417 #endif /* VF_PF_SW_IF_H */
418