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