bnx2x_vfpf.h revision 4c133c39ae1bc541b3db5903a680da738a0c57e3
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: Eilon Greenstein <eilong@broadcom.com>
16 * Written by: Ariel Elior <ariele@broadcom.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 */
24struct 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
33struct 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
55#define VFPF_QUEUE_DROP_IP_CS_ERR	(1 << 0)
56#define VFPF_QUEUE_DROP_TCP_CS_ERR	(1 << 1)
57#define VFPF_QUEUE_DROP_TTL0		(1 << 2)
58#define VFPF_QUEUE_DROP_UDP_CS_ERR	(1 << 3)
59
60#define VFPF_RX_MASK_ACCEPT_NONE		0x00000000
61#define VFPF_RX_MASK_ACCEPT_MATCHED_UNICAST	0x00000001
62#define VFPF_RX_MASK_ACCEPT_MATCHED_MULTICAST	0x00000002
63#define VFPF_RX_MASK_ACCEPT_ALL_UNICAST		0x00000004
64#define VFPF_RX_MASK_ACCEPT_ALL_MULTICAST	0x00000008
65#define VFPF_RX_MASK_ACCEPT_BROADCAST		0x00000010
66#define BULLETIN_CONTENT_SIZE		(sizeof(struct pf_vf_bulletin_content))
67#define BULLETIN_ATTEMPTS	5 /* crc failures before throwing towel */
68#define BULLETIN_CRC_SEED	0
69
70enum {
71	PFVF_STATUS_WAITING = 0,
72	PFVF_STATUS_SUCCESS,
73	PFVF_STATUS_FAILURE,
74	PFVF_STATUS_NOT_SUPPORTED,
75	PFVF_STATUS_NO_RESOURCE
76};
77
78/* vf pf channel tlvs */
79/* general tlv header (used for both vf->pf request and pf->vf response) */
80struct channel_tlv {
81	u16 type;
82	u16 length;
83};
84
85/* header of first vf->pf tlv carries the offset used to calculate response
86 * buffer address
87 */
88struct vfpf_first_tlv {
89	struct channel_tlv tl;
90	u32 resp_msg_offset;
91};
92
93/* header of pf->vf tlvs, carries the status of handling the request */
94struct pfvf_tlv {
95	struct channel_tlv tl;
96	u8 status;
97	u8 padding[3];
98};
99
100/* response tlv used for most tlvs */
101struct pfvf_general_resp_tlv {
102	struct pfvf_tlv hdr;
103};
104
105/* used to terminate and pad a tlv list */
106struct channel_list_end_tlv {
107	struct channel_tlv tl;
108	u8 padding[4];
109};
110
111/* Acquire */
112struct vfpf_acquire_tlv {
113	struct vfpf_first_tlv first_tlv;
114
115	struct vf_pf_vfdev_info {
116		/* the following fields are for debug purposes */
117		u8  vf_id;		/* ME register value */
118		u8  vf_os;		/* e.g. Linux, W2K8 */
119		u8 padding[2];
120	} vfdev_info;
121
122	struct vf_pf_resc_request resc_request;
123
124	aligned_u64 bulletin_addr;
125};
126
127/* simple operation request on queue */
128struct vfpf_q_op_tlv {
129	struct vfpf_first_tlv	first_tlv;
130	u8 vf_qid;
131	u8 padding[3];
132};
133
134/* acquire response tlv - carries the allocated resources */
135struct pfvf_acquire_resp_tlv {
136	struct pfvf_tlv hdr;
137	struct pf_vf_pfdev_info {
138		u32 chip_num;
139		u32 pf_cap;
140#define PFVF_CAP_RSS		0x00000001
141#define PFVF_CAP_DHC		0x00000002
142#define PFVF_CAP_TPA		0x00000004
143		char fw_ver[32];
144		u16 db_size;
145		u8  indices_per_sb;
146		u8  padding;
147	} pfdev_info;
148	struct pf_vf_resc {
149		/* in case of status NO_RESOURCE in message hdr, pf will fill
150		 * this struct with suggested amount of resources for next
151		 * acquire request
152		 */
153#define PFVF_MAX_QUEUES_PER_VF         16
154#define PFVF_MAX_SBS_PER_VF            16
155		struct hw_sb_info hw_sbs[PFVF_MAX_SBS_PER_VF];
156		u8	hw_qid[PFVF_MAX_QUEUES_PER_VF];
157		u8	num_rxqs;
158		u8	num_txqs;
159		u8	num_sbs;
160		u8	num_mac_filters;
161		u8	num_vlan_filters;
162		u8	num_mc_filters;
163		u8	permanent_mac_addr[ETH_ALEN];
164		u8	current_mac_addr[ETH_ALEN];
165		u8	padding[2];
166	} resc;
167};
168
169/* Init VF */
170struct vfpf_init_tlv {
171	struct vfpf_first_tlv first_tlv;
172	aligned_u64 sb_addr[PFVF_MAX_SBS_PER_VF]; /* vf_sb based */
173	aligned_u64 spq_addr;
174	aligned_u64 stats_addr;
175};
176
177/* Setup Queue */
178struct vfpf_setup_q_tlv {
179	struct vfpf_first_tlv first_tlv;
180
181	struct vf_pf_rxq_params {
182		/* physical addresses */
183		aligned_u64 rcq_addr;
184		aligned_u64 rcq_np_addr;
185		aligned_u64 rxq_addr;
186		aligned_u64 sge_addr;
187
188		/* sb + hc info */
189		u8  vf_sb;		/* index in hw_sbs[] */
190		u8  sb_index;		/* Index in the SB */
191		u16 hc_rate;		/* desired interrupts per sec. */
192					/* valid iff VFPF_QUEUE_FLG_HC */
193		/* rx buffer info */
194		u16 mtu;
195		u16 buf_sz;
196		u16 flags;		/* VFPF_QUEUE_FLG_X flags */
197		u16 stat_id;		/* valid iff VFPF_QUEUE_FLG_STATS */
198
199		/* valid iff VFPF_QUEUE_FLG_TPA */
200		u16 sge_buf_sz;
201		u16 tpa_agg_sz;
202		u8 max_sge_pkt;
203
204		u8 drop_flags;		/* VFPF_QUEUE_DROP_X, for Linux VMs
205					 * all the flags are turned off
206					 */
207
208		u8 cache_line_log;	/* VFPF_QUEUE_FLG_CACHE_ALIGN */
209		u8 padding;
210	} rxq;
211
212	struct vf_pf_txq_params {
213		/* physical addresses */
214		aligned_u64 txq_addr;
215
216		/* sb + hc info */
217		u8  vf_sb;		/* index in hw_sbs[] */
218		u8  sb_index;		/* Index in the SB */
219		u16 hc_rate;		/* desired interrupts per sec. */
220					/* valid iff VFPF_QUEUE_FLG_HC */
221		u32 flags;		/* VFPF_QUEUE_FLG_X flags */
222		u16 stat_id;		/* valid iff VFPF_QUEUE_FLG_STATS */
223		u8  traffic_type;	/* see in setup_context() */
224		u8  padding;
225	} txq;
226
227	u8 vf_qid;			/* index in hw_qid[] */
228	u8 param_valid;
229#define VFPF_RXQ_VALID		0x01
230#define VFPF_TXQ_VALID		0x02
231	u8 padding[2];
232};
233
234/* Set Queue Filters */
235struct vfpf_q_mac_vlan_filter {
236	u32 flags;
237#define VFPF_Q_FILTER_DEST_MAC_VALID	0x01
238#define VFPF_Q_FILTER_VLAN_TAG_VALID	0x02
239#define VFPF_Q_FILTER_SET_MAC		0x100	/* set/clear */
240	u8  mac[ETH_ALEN];
241	u16 vlan_tag;
242};
243
244/* configure queue filters */
245struct vfpf_set_q_filters_tlv {
246	struct vfpf_first_tlv first_tlv;
247
248	u32 flags;
249#define VFPF_SET_Q_FILTERS_MAC_VLAN_CHANGED	0x01
250#define VFPF_SET_Q_FILTERS_MULTICAST_CHANGED	0x02
251#define VFPF_SET_Q_FILTERS_RX_MASK_CHANGED	0x04
252
253	u8 vf_qid;			/* index in hw_qid[] */
254	u8 n_mac_vlan_filters;
255	u8 n_multicast;
256	u8 padding;
257
258#define PFVF_MAX_MAC_FILTERS                   16
259#define PFVF_MAX_VLAN_FILTERS                  16
260#define PFVF_MAX_FILTERS               (PFVF_MAX_MAC_FILTERS +\
261					 PFVF_MAX_VLAN_FILTERS)
262	struct vfpf_q_mac_vlan_filter filters[PFVF_MAX_FILTERS];
263
264#define PFVF_MAX_MULTICAST_PER_VF              32
265	u8  multicast[PFVF_MAX_MULTICAST_PER_VF][ETH_ALEN];
266
267	u32 rx_mask;	/* see mask constants at the top of the file */
268};
269
270/* close VF (disable VF) */
271struct vfpf_close_tlv {
272	struct vfpf_first_tlv   first_tlv;
273	u16			vf_id;  /* for debug */
274	u8 padding[2];
275};
276
277/* release the VF's acquired resources */
278struct vfpf_release_tlv {
279	struct vfpf_first_tlv	first_tlv;
280	u16			vf_id;
281	u8 padding[2];
282};
283
284struct tlv_buffer_size {
285	u8 tlv_buffer[TLV_BUFFER_SIZE];
286};
287
288union vfpf_tlvs {
289	struct vfpf_first_tlv		first_tlv;
290	struct vfpf_acquire_tlv		acquire;
291	struct vfpf_init_tlv		init;
292	struct vfpf_close_tlv		close;
293	struct vfpf_q_op_tlv		q_op;
294	struct vfpf_setup_q_tlv		setup_q;
295	struct vfpf_set_q_filters_tlv	set_q_filters;
296	struct vfpf_release_tlv         release;
297	struct channel_list_end_tlv     list_end;
298	struct tlv_buffer_size		tlv_buf_size;
299};
300
301union pfvf_tlvs {
302	struct pfvf_general_resp_tlv    general_resp;
303	struct pfvf_acquire_resp_tlv	acquire_resp;
304	struct channel_list_end_tlv	list_end;
305	struct tlv_buffer_size		tlv_buf_size;
306};
307
308/* This is a structure which is allocated in the VF, which the PF may update
309 * when it deems it necessary to do so. The bulletin board is sampled
310 * periodically by the VF. A copy per VF is maintained in the PF (to prevent
311 * loss of data upon multiple updates (or the need for read modify write)).
312 */
313struct pf_vf_bulletin_size {
314	u8 size[PF_VF_BULLETIN_SIZE];
315};
316
317struct pf_vf_bulletin_content {
318	u32 crc;			/* crc of structure to ensure is not in
319					 * mid-update
320					 */
321	u16 version;
322	u16 length;
323
324	aligned_u64 valid_bitmap;	/* bitmap indicating which fields
325					 * hold valid values
326					 */
327
328#define MAC_ADDR_VALID		0	/* alert the vf that a new mac address
329					 * is available for it
330					 */
331
332	u8 mac[ETH_ALEN];
333	u8 padding[2];
334};
335
336union pf_vf_bulletin {
337	struct pf_vf_bulletin_content content;
338	struct pf_vf_bulletin_size size;
339};
340
341#define MAX_TLVS_IN_LIST 50
342
343enum channel_tlvs {
344	CHANNEL_TLV_NONE,
345	CHANNEL_TLV_ACQUIRE,
346	CHANNEL_TLV_INIT,
347	CHANNEL_TLV_SETUP_Q,
348	CHANNEL_TLV_SET_Q_FILTERS,
349	CHANNEL_TLV_TEARDOWN_Q,
350	CHANNEL_TLV_CLOSE,
351	CHANNEL_TLV_RELEASE,
352	CHANNEL_TLV_PF_RELEASE_VF,
353	CHANNEL_TLV_LIST_END,
354	CHANNEL_TLV_FLR,
355	CHANNEL_TLV_PF_SET_MAC,
356	CHANNEL_TLV_MAX
357};
358
359#endif /* CONFIG_BNX2X_SRIOV */
360#endif /* VF_PF_IF_H */
361