xref: /titanic_41/usr/src/uts/common/io/bnxe/577xx/drivers/common/include/vm/hw_channel.h (revision f391a51a4e9639750045473dba1cc2831267c93e)
1 /* QLogic Everest network driver.
2  *
3  * CDDL HEADER START
4  *
5  * The contents of this file are subject to the terms of the
6  * Common Development and Distribution License (the "License").
7  * You may not use this file except in compliance with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  *
22  * Copyright 2014 QLogic Corporation
23  * The contents of this file are subject to the terms of the
24  * QLogic End User License (the "License").
25  * You may not use this file except in compliance with the License.
26  *
27  * You can obtain a copy of the License at
28  * http://www.qlogic.com/Resources/Documents/DriverDownloadHelp/
29  * QLogic_End_User_Software_License.txt
30  * See the License for the specific language governing permissions
31  * and limitations under the License.
32  *
33  *
34  * Maintained by: Ariel Elior <ariel.elior@qlogic.com>
35  *
36  */
37 
38 #ifndef VF_PF_IF_H
39 #define VF_PF_IF_H
40 
41 /***********************************************
42  *
43  * Common definitions for all HVs
44  *
45  **/
46 struct vf_pf_resc_request {
47 	u8  num_rxqs;
48 	u8  num_txqs;
49 	u8  num_sbs;
50 	u8  num_mac_filters;
51 	u8  num_vlan_filters;
52 	u8  num_mc_filters; /* No limit  so superfluous */
53 };
54 
55 struct hw_sb_info {
56 	u8 hw_sb_id;	/* aka absolute igu id, used to ack the sb */
57 	u8 sb_qid;	/* used to update DHC for sb */
58 };
59 
60 /***********************************************
61  *
62  * HW VF-PF channel definitions
63  *
64  * A.K.A VF-PF mailbox
65  *
66  **/
67 #define TLV_BUFFER_SIZE			1024
68 #ifndef BNX2X_UPSTREAM /* ! BNX2X_UPSTREAM */
69 #define TLV_ALIGN			sizeof(u64)
70 #endif
71 #define PF_VF_BULLETIN_SIZE		512
72 
73 #define VFPF_QUEUE_FLG_TPA		0x0001
74 #define VFPF_QUEUE_FLG_TPA_IPV6		0x0002
75 #define VFPF_QUEUE_FLG_TPA_GRO		0x0004
76 #define VFPF_QUEUE_FLG_CACHE_ALIGN	0x0008
77 #define VFPF_QUEUE_FLG_STATS		0x0010
78 #define VFPF_QUEUE_FLG_OV		0x0020
79 #define VFPF_QUEUE_FLG_VLAN		0x0040
80 #define VFPF_QUEUE_FLG_COS		0x0080
81 #define VFPF_QUEUE_FLG_HC		0x0100
82 #define VFPF_QUEUE_FLG_DHC		0x0200
83 #define VFPF_QUEUE_FLG_LEADING_RSS	0x0400
84 
85 #define VFPF_QUEUE_DROP_IP_CS_ERR	(1 << 0)
86 #define VFPF_QUEUE_DROP_TCP_CS_ERR	(1 << 1)
87 #define VFPF_QUEUE_DROP_TTL0		(1 << 2)
88 #define VFPF_QUEUE_DROP_UDP_CS_ERR	(1 << 3)
89 
90 #define VFPF_RX_MASK_ACCEPT_NONE		0x00000000
91 #define VFPF_RX_MASK_ACCEPT_MATCHED_UNICAST	0x00000001
92 #define VFPF_RX_MASK_ACCEPT_MATCHED_MULTICAST	0x00000002
93 #define VFPF_RX_MASK_ACCEPT_ALL_UNICAST		0x00000004
94 #define VFPF_RX_MASK_ACCEPT_ALL_MULTICAST	0x00000008
95 #define VFPF_RX_MASK_ACCEPT_BROADCAST		0x00000010
96 /* TODO: #define VFPF_RX_MASK_ACCEPT_ANY_VLAN	0x00000020 */
97 
98 #define BULLETIN_CONTENT_SIZE		(sizeof(struct pf_vf_bulletin_content))
99 #define BULLETIN_CONTENT_LEGACY_SIZE	(32)
100 #define BULLETIN_ATTEMPTS	5 /* crc failures before throwing towel */
101 #define BULLETIN_CRC_SEED	0
102 
103 enum {
104 	PFVF_STATUS_WAITING = 0,
105 	PFVF_STATUS_SUCCESS,
106 	PFVF_STATUS_FAILURE,
107 	PFVF_STATUS_NOT_SUPPORTED,
108 	PFVF_STATUS_NO_RESOURCE
109 };
110 
111 /* vf pf channel tlvs */
112 /* general tlv header (used for both vf->pf request and pf->vf response) */
113 struct channel_tlv {
114 	u16 type;
115 	u16 length;
116 };
117 
118 /* header of first vf->pf tlv carries the offset used to calculate reponse
119  * buffer address
120  */
121 struct vfpf_first_tlv {
122 	struct channel_tlv tl;
123 	u32 resp_msg_offset;
124 };
125 
126 /* header of pf->vf tlvs, carries the status of handling the request */
127 struct pfvf_tlv {
128 	struct channel_tlv tl;
129 	u8 status;
130 	u8 padding[3];
131 };
132 
133 /* response tlv used for most tlvs */
134 struct pfvf_general_resp_tlv {
135 	struct pfvf_tlv hdr;
136 };
137 
138 /* used to terminate and pad a tlv list */
139 struct channel_list_end_tlv {
140 	struct channel_tlv tl;
141 	u8 padding[4];
142 };
143 
144 /* Acquire */
145 struct vfpf_acquire_tlv {
146 	struct vfpf_first_tlv first_tlv;
147 
148 	struct vf_pf_vfdev_info {
149 		/* the following fields are for debug purposes */
150 		u8 vf_id;      	/* ME register value */
151 		u8 vf_os;      	/* e.g. Linux, W2K8 */
152 #define VF_OS_SUBVERSION_MASK	(0x1f)
153 #define VF_OS_MASK		(0xe0)
154 #define VF_OS_SHIFT		(5)
155 #define VF_OS_UNDEFINED		(0 << VF_OS_SHIFT)
156 #define VF_OS_WINDOWS		(1 << VF_OS_SHIFT)
157 
158 		u8 fp_hsi_ver;
159 		u8 caps;
160 #define VF_CAP_SUPPORT_EXT_BULLETIN	(1 << 0)
161 	} vfdev_info;
162 
163 	struct vf_pf_resc_request resc_request;
164 
165 	aligned_u64 bulletin_addr;
166 };
167 
168 /* simple operation request on queue */
169 struct vfpf_q_op_tlv {
170 	struct vfpf_first_tlv	first_tlv;
171 	u8 vf_qid;
172 	u8 padding[3];
173 };
174 
175 /* receive side scaling tlv */
176 struct vfpf_rss_tlv {
177 	struct vfpf_first_tlv	first_tlv;
178 	u32			rss_flags;
179 #define VFPF_RSS_MODE_DISABLED	(1 << 0)
180 #define VFPF_RSS_MODE_REGULAR	(1 << 1)
181 #define VFPF_RSS_SET_SRCH 	(1 << 2)
182 #define VFPF_RSS_IPV4		(1 << 3)
183 #define VFPF_RSS_IPV4_TCP	(1 << 4)
184 #define VFPF_RSS_IPV4_UDP	(1 << 5)
185 #define VFPF_RSS_IPV6		(1 << 6)
186 #define VFPF_RSS_IPV6_TCP	(1 << 7)
187 #define VFPF_RSS_IPV6_UDP	(1 << 8)
188 	u8			rss_result_mask;
189 	u8			ind_table_size;
190 	u8			rss_key_size;
191 	u8			padding;
192 	u8			ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
193 	u32			rss_key[T_ETH_RSS_KEY];	/* hash values */
194 };
195 
196 /* acquire response tlv - carries the allocated resources */
197 struct pfvf_acquire_resp_tlv {
198 	struct pfvf_tlv hdr;
199 	struct pf_vf_pfdev_info {
200 		u32 chip_num;
201 		u32 pf_cap;
202 		#define PFVF_CAP_RSS        0x00000001
203 		#define PFVF_CAP_DHC        0x00000002
204 		#define PFVF_CAP_TPA        0x00000004
205 		#define PFVF_CAP_TPA_UPDATE 0x00000008
206 
207 #ifndef BNX2X_UPSTREAM /* ! BNX2X_UPSTREAM */
208 		/* bit set only by ESX hypervisor. This means that a VF *may* be
209 		 * able to configure its own mac even if the hypervisor has
210 		 * already set one for it. In linux this is never allowed, but
211 		 * in ESX it may be allowed. Capabilities such as this which
212 		 * don't exist in linux will consume bits from the bitmap from
213 		 * starting from msb
214 		 */
215 		#define PFVF_CAP_ALLOW_MAC  0x80000000
216 #endif
217 
218 		char fw_ver[32];
219 		u16 db_size;
220 		u8  indices_per_sb;
221 		u8  padding;
222 	} pfdev_info;
223 	struct pf_vf_resc {
224 		/* in case of status NO_RESOURCE in message hdr, pf will fill
225 		 * this struct with suggested amount of resources for next
226 		 * acquire request
227 		 */
228 		#define PFVF_MAX_QUEUES_PER_VF         16
229 		#define PFVF_MAX_SBS_PER_VF            16
230 		struct hw_sb_info hw_sbs[PFVF_MAX_SBS_PER_VF];
231 		u8	hw_qid[PFVF_MAX_QUEUES_PER_VF];
232 		u8	num_rxqs;
233 		u8	num_txqs;
234 		u8	num_sbs;
235 		u8	num_mac_filters;
236 		u8	num_vlan_filters;
237 		u8	num_mc_filters;
238 		u8	permanent_mac_addr[ETH_ALEN];
239 		u8	current_mac_addr[ETH_ALEN];
240 		u16	pf_link_speed;
241 		u32	pf_link_supported;
242 	} resc;
243 };
244 
245 struct vfpf_port_phys_id_resp_tlv {
246 	struct channel_tlv tl;
247 	u8 id[ETH_ALEN];
248 	u8 padding[2];
249 };
250 
251 #define VFPF_INIT_FLG_STATS_COALESCE	(1 << 0) /* when set the VFs queues
252 						  * stats will be coalesced on
253 						  * the leading RSS queue
254 						  */
255 
256 /* Init VF */
257 struct vfpf_init_tlv {
258 	struct vfpf_first_tlv first_tlv;
259 	aligned_u64 sb_addr[PFVF_MAX_SBS_PER_VF]; /* vf_sb based */
260 	aligned_u64 spq_addr;
261 	aligned_u64 stats_addr;
262 	u16 stats_stride;
263 	u32 flags;
264 	u32 padding [2];
265 };
266 
267 /* Setup Queue */
268 struct vfpf_setup_q_tlv {
269 	struct vfpf_first_tlv first_tlv;
270 
271 	struct vf_pf_rxq_params {
272 		/* physical addresses */
273 		aligned_u64 rcq_addr;
274 		aligned_u64 rcq_np_addr;
275 		aligned_u64 rxq_addr;
276 		aligned_u64 sge_addr;
277 
278 		/* sb + hc info */
279 		u8  vf_sb;		/* index in hw_sbs[] */
280 		u8  sb_index;           /* Index in the SB */
281 		u16 hc_rate;		/* desired interrupts per sec. */
282 					/* valid iff VFPF_QUEUE_FLG_HC */
283 		/* rx buffer info */
284 		u16 mtu;
285 		u16 buf_sz;
286 		u16 flags;              /* VFPF_QUEUE_FLG_X flags */
287 		u16 stat_id;		/* valid iff VFPF_QUEUE_FLG_STATS */
288 
289 		/* valid iff VFPF_QUEUE_FLG_TPA */
290 		u16 sge_buf_sz;
291 		u16 tpa_agg_sz;
292 		u8 max_sge_pkt;
293 
294 		u8 drop_flags;		/* VFPF_QUEUE_DROP_X, for Linux VMs
295 					 * all the flags are turned off
296 					 */
297 
298 		u8 cache_line_log;	/* VFPF_QUEUE_FLG_CACHE_ALIGN */
299 		u8 padding;
300 	} rxq;
301 
302 	struct vf_pf_txq_params {
303 		/* physical addresses */
304 		aligned_u64 txq_addr;
305 
306 		/* sb + hc info */
307 		u8  vf_sb;		/* index in hw_sbs[] */
308 		u8  sb_index;		/* Index in the SB */
309 		u16 hc_rate;		/* desired interrupts per sec. */
310 					/* valid iff VFPF_QUEUE_FLG_HC */
311 		u32 flags;		/* VFPF_QUEUE_FLG_X flags */
312 		u16 stat_id;		/* valid iff VFPF_QUEUE_FLG_STATS */
313 		u8  traffic_type;	/* see in setup_context() */
314 		u8  padding;
315 	} txq;
316 
317 	u8 vf_qid;			/* index in hw_qid[] */
318 	u8 param_valid;
319 	#define VFPF_RXQ_VALID		0x01
320 	#define VFPF_TXQ_VALID		0x02
321 	u8 padding[2];
322 };
323 
324 /* Set Queue Filters */
325 struct vfpf_q_mac_vlan_filter {
326 	u32 flags;
327 	#define VFPF_Q_FILTER_DEST_MAC_VALID	0x01
328 	#define VFPF_Q_FILTER_VLAN_TAG_VALID	0x02
329 	#define VFPF_Q_FILTER_SET_MAC		0x100	/* set/clear */
330 	u8  mac[ETH_ALEN];
331 	u16 vlan_tag;
332 };
333 
334 #ifndef BNX2X_UPSTREAM /* ! BNX2X_UPSTREAM */
335 #define _UP_ETH_ALEN	(6)
336 #endif
337 
338 /* configure queue filters */
339 struct vfpf_set_q_filters_tlv {
340 	struct vfpf_first_tlv first_tlv;
341 
342 	u32 flags;
343 	#define VFPF_SET_Q_FILTERS_MAC_VLAN_CHANGED 	0x01
344 	#define VFPF_SET_Q_FILTERS_MULTICAST_CHANGED	0x02
345 	#define VFPF_SET_Q_FILTERS_RX_MASK_CHANGED  	0x04
346 
347 	u8 vf_qid;			/* index in hw_qid[] */
348 	u8 n_mac_vlan_filters;
349 	u8 n_multicast;
350 	u8 padding;
351 
352 	#define PFVF_MAX_MAC_FILTERS			16
353 	#define PFVF_MAX_VLAN_FILTERS       		16
354 	#define PFVF_MAX_FILTERS 			(PFVF_MAX_MAC_FILTERS +\
355 							 PFVF_MAX_VLAN_FILTERS)
356 	struct vfpf_q_mac_vlan_filter filters[PFVF_MAX_FILTERS];
357 
358 	#define PFVF_MAX_MULTICAST_PER_VF   		32
359 	u8  multicast[PFVF_MAX_MULTICAST_PER_VF][_UP_ETH_ALEN];
360 
361 	u32 rx_mask;	/* see mask constants at the top of the file */
362 };
363 
364 struct vfpf_tpa_tlv {
365 	struct vfpf_first_tlv	first_tlv;
366 
367 	struct vf_pf_tpa_client_info {
368 		aligned_u64 sge_addr[PFVF_MAX_QUEUES_PER_VF];
369 		u8 update_ipv4;
370 		u8 update_ipv6;
371 		u8 max_tpa_queues;
372 		u8 max_sges_for_packet;
373 		u8 complete_on_both_clients;
374 		u8 dont_verify_thr;
375 		u8 tpa_mode;
376 		u16 sge_buff_size;
377 		u16 max_agg_size;
378 		u16 sge_pause_thr_low;
379 		u16 sge_pause_thr_high;
380 	} tpa_client_info;
381 };
382 
383 /* close VF (disable VF) */
384 struct vfpf_close_tlv {
385 	struct vfpf_first_tlv	first_tlv;
386 	u16			vf_id;  /* for debug */
387 	u8 padding[2];
388 };
389 
390 /* rlease the VF's acquired resources */
391 struct vfpf_release_tlv {
392 	struct vfpf_first_tlv   first_tlv;
393 	u16			vf_id;  /* for debug */
394 	u8 padding[2];
395 };
396 
397 struct tlv_buffer_size {
398 	u8 tlv_buffer[TLV_BUFFER_SIZE];
399 };
400 
401 union vfpf_tlvs {
402 	struct vfpf_first_tlv		first_tlv;
403 	struct vfpf_acquire_tlv		acquire;
404 	struct vfpf_init_tlv		init;
405 	struct vfpf_close_tlv		close;
406 	struct vfpf_q_op_tlv		q_op;
407 	struct vfpf_setup_q_tlv		setup_q;
408 	struct vfpf_set_q_filters_tlv	set_q_filters;
409 	struct vfpf_release_tlv		release;
410 	struct vfpf_rss_tlv		update_rss;
411 	struct vfpf_tpa_tlv		update_tpa;
412 	struct channel_list_end_tlv     list_end;
413 	struct tlv_buffer_size		tlv_buf_size;
414 };
415 
416 union pfvf_tlvs {
417 	struct pfvf_general_resp_tlv	general_resp;
418 	struct pfvf_acquire_resp_tlv	acquire_resp;
419 	struct channel_list_end_tlv	list_end;
420 	struct tlv_buffer_size		tlv_buf_size;
421 };
422 
423 /* This is a structure which is allocated in the VF, which the PF may update
424  * when it deems it necessary to do so. The bulletin board is sampled
425  * periodically by the VF. A copy per VF is maintained in the PF (to prevent
426  * loss of data upon multiple updates (or the need for read modify write)).
427  */
428 struct pf_vf_bulletin_size {
429 	u8 size [PF_VF_BULLETIN_SIZE];
430 };
431 
432 struct pf_vf_bulletin_content {
433 	u32 crc;			/* crc of structure to ensure is not in
434 					 * mid-update
435 					 */
436 	u16 version;
437 	u16 length;
438 
439 	aligned_u64 valid_bitmap;	/* bitmap indicating wich fields
440 					 * hold valid values
441 					 */
442 
443 #define MAC_ADDR_VALID		0	/* alert the vf that a new mac address
444 					 * is available for it
445 					 */
446 #define VLAN_VALID		1	/* when set, the vf should no access the
447 					 * vfpf channel
448 					 */
449 #define CHANNEL_DOWN		2	/* vfpf channel is disabled. VFs are not
450 					 * to attempt to send messages on the
451 					 * channel after this bit is set
452 					 */
453 #define LINK_VALID		3	/* alert the VF thet a new link status
454 					 * update is available for it
455 					 */
456 	u8 mac[ETH_ALEN];
457 	u8 mac_padding[2];
458 
459 	u16 vlan;
460 	u8 vlan_padding[6];
461 
462 	u16 link_speed;			 /* Effective line speed */
463 	u8 link_speed_padding[6];
464 	u32 link_flags;			 /* VFPF_LINK_REPORT_XXX flags */
465 #define VFPF_LINK_REPORT_LINK_DOWN	 (1 << 0)
466 #define VFPF_LINK_REPORT_FULL_DUPLEX	 (1 << 1)
467 #define VFPF_LINK_REPORT_RX_FC_ON	 (1 << 2)
468 #define VFPF_LINK_REPORT_TX_FC_ON	 (1 << 3)
469 	u8 link_flags_padding[4];
470 };
471 
472 union pf_vf_bulletin {
473 	struct pf_vf_bulletin_content content;
474 	struct pf_vf_bulletin_size size;
475 };
476 #define MAX_TLVS_IN_LIST 50
477 #ifndef print_enum /* BNX2X_UPSTREAM */
478 enum channel_tlvs {
479 #else
480 print_enum (channel_tlvs,
481 #endif
482 	CHANNEL_TLV_NONE, /* ends tlv sequence */
483 	CHANNEL_TLV_ACQUIRE,
484 	CHANNEL_TLV_INIT,
485 	CHANNEL_TLV_SETUP_Q,
486 	CHANNEL_TLV_SET_Q_FILTERS,
487 	CHANNEL_TLV_ACTIVATE_Q,
488 	CHANNEL_TLV_DEACTIVATE_Q,
489 	CHANNEL_TLV_TEARDOWN_Q,
490 	CHANNEL_TLV_CLOSE,
491 	CHANNEL_TLV_RELEASE,
492 	CHANNEL_TLV_UPDATE_RSS_DEPRECATED,
493 	CHANNEL_TLV_PF_RELEASE_VF,
494 	CHANNEL_TLV_LIST_END,
495 	CHANNEL_TLV_FLR,
496 	CHANNEL_TLV_PF_SET_MAC,
497 	CHANNEL_TLV_PF_SET_VLAN,
498 	CHANNEL_TLV_UPDATE_RSS,
499 	CHANNEL_TLV_PHYS_PORT_ID,
500 	CHANNEL_TLV_UPDATE_TPA,
501 	CHANNEL_TLV_MAX
502 #ifndef print_enum /* BNX2X_UPSTREAM */
503 };
504 #else
505 );
506 #endif
507 
508 #endif /* VF_PF_IF_H */
509