blob: 1179fe06d0c7ff010b7a06102a68b601c747bf9c [file] [log] [blame]
Ariel Elior1ab44342013-01-01 05:22:23 +00001/* bnx2x_vfpf.h: Broadcom Everest network driver.
2 *
Yuval Mintz247fa822013-01-14 05:11:50 +00003 * Copyright (c) 2011-2013 Broadcom Corporation
Ariel Elior1ab44342013-01-01 05:22:23 +00004 *
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
Ariel Elior64112802013-01-07 00:50:23 +000021#ifdef CONFIG_BNX2X_SRIOV
22
Ariel Eliorbe1f1ffa2013-01-01 05:22:24 +000023/* 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
Ariel Elior1ab44342013-01-01 05:22:23 +000038/* HW VF-PF channel definitions
39 * A.K.A VF-PF mailbox
40 */
41#define TLV_BUFFER_SIZE 1024
Ariel Eliorabc5a022013-01-01 05:22:43 +000042#define PF_VF_BULLETIN_SIZE 512
Ariel Elior1ab44342013-01-01 05:22:23 +000043
Ariel Elior8d9ac292013-01-01 05:22:27 +000044#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
Ariel Eliorb9871bc2013-09-04 14:09:21 +030054#define VFPF_QUEUE_FLG_LEADING_RSS 0x0400
Ariel Elior8d9ac292013-01-01 05:22:27 +000055
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
Ariel Elior381ac162013-01-01 05:22:29 +000061#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
Ariel Eliorabc5a022013-01-01 05:22:43 +000067#define BULLETIN_CONTENT_SIZE (sizeof(struct pf_vf_bulletin_content))
68#define BULLETIN_ATTEMPTS 5 /* crc failures before throwing towel */
69#define BULLETIN_CRC_SEED 0
Ariel Elior381ac162013-01-01 05:22:29 +000070
Ariel Eliorbe1f1ffa2013-01-01 05:22:24 +000071enum {
72 PFVF_STATUS_WAITING = 0,
73 PFVF_STATUS_SUCCESS,
74 PFVF_STATUS_FAILURE,
75 PFVF_STATUS_NOT_SUPPORTED,
76 PFVF_STATUS_NO_RESOURCE
77};
78
79/* vf pf channel tlvs */
80/* general tlv header (used for both vf->pf request and pf->vf response) */
81struct channel_tlv {
82 u16 type;
83 u16 length;
84};
85
86/* header of first vf->pf tlv carries the offset used to calculate response
87 * buffer address
88 */
89struct vfpf_first_tlv {
90 struct channel_tlv tl;
91 u32 resp_msg_offset;
92};
93
94/* header of pf->vf tlvs, carries the status of handling the request */
95struct pfvf_tlv {
96 struct channel_tlv tl;
97 u8 status;
98 u8 padding[3];
99};
100
Ariel Elior4513f922013-01-01 05:22:25 +0000101/* response tlv used for most tlvs */
102struct pfvf_general_resp_tlv {
103 struct pfvf_tlv hdr;
104};
105
Ariel Eliorbe1f1ffa2013-01-01 05:22:24 +0000106/* used to terminate and pad a tlv list */
107struct channel_list_end_tlv {
108 struct channel_tlv tl;
109 u8 padding[4];
110};
111
112/* Acquire */
113struct vfpf_acquire_tlv {
114 struct vfpf_first_tlv first_tlv;
115
116 struct vf_pf_vfdev_info {
117 /* the following fields are for debug purposes */
118 u8 vf_id; /* ME register value */
119 u8 vf_os; /* e.g. Linux, W2K8 */
120 u8 padding[2];
121 } vfdev_info;
122
123 struct vf_pf_resc_request resc_request;
124
125 aligned_u64 bulletin_addr;
126};
127
Ariel Elior9b176b62013-01-01 05:22:28 +0000128/* simple operation request on queue */
129struct vfpf_q_op_tlv {
130 struct vfpf_first_tlv first_tlv;
131 u8 vf_qid;
132 u8 padding[3];
133};
134
Ariel Eliorb9871bc2013-09-04 14:09:21 +0300135/* receive side scaling tlv */
136struct vfpf_rss_tlv {
137 struct vfpf_first_tlv first_tlv;
138 u32 rss_flags;
139#define VFPF_RSS_MODE_DISABLED (1 << 0)
140#define VFPF_RSS_MODE_REGULAR (1 << 1)
141#define VFPF_RSS_SET_SRCH (1 << 2)
142#define VFPF_RSS_IPV4 (1 << 3)
143#define VFPF_RSS_IPV4_TCP (1 << 4)
144#define VFPF_RSS_IPV4_UDP (1 << 5)
145#define VFPF_RSS_IPV6 (1 << 6)
146#define VFPF_RSS_IPV6_TCP (1 << 7)
147#define VFPF_RSS_IPV6_UDP (1 << 8)
148 u8 rss_result_mask;
149 u8 ind_table_size;
150 u8 rss_key_size;
151 u8 padding;
152 u8 ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
153 u32 rss_key[T_ETH_RSS_KEY]; /* hash values */
154};
155
Ariel Eliorbe1f1ffa2013-01-01 05:22:24 +0000156/* acquire response tlv - carries the allocated resources */
157struct pfvf_acquire_resp_tlv {
158 struct pfvf_tlv hdr;
159 struct pf_vf_pfdev_info {
160 u32 chip_num;
161 u32 pf_cap;
162#define PFVF_CAP_RSS 0x00000001
163#define PFVF_CAP_DHC 0x00000002
164#define PFVF_CAP_TPA 0x00000004
165 char fw_ver[32];
166 u16 db_size;
167 u8 indices_per_sb;
168 u8 padding;
169 } pfdev_info;
170 struct pf_vf_resc {
171 /* in case of status NO_RESOURCE in message hdr, pf will fill
172 * this struct with suggested amount of resources for next
173 * acquire request
174 */
175#define PFVF_MAX_QUEUES_PER_VF 16
176#define PFVF_MAX_SBS_PER_VF 16
177 struct hw_sb_info hw_sbs[PFVF_MAX_SBS_PER_VF];
178 u8 hw_qid[PFVF_MAX_QUEUES_PER_VF];
179 u8 num_rxqs;
180 u8 num_txqs;
181 u8 num_sbs;
182 u8 num_mac_filters;
183 u8 num_vlan_filters;
184 u8 num_mc_filters;
185 u8 permanent_mac_addr[ETH_ALEN];
186 u8 current_mac_addr[ETH_ALEN];
187 u8 padding[2];
188 } resc;
189};
190
Ariel Eliorb9871bc2013-09-04 14:09:21 +0300191#define VFPF_INIT_FLG_STATS_COALESCE (1 << 0) /* when set the VFs queues
192 * stats will be coalesced on
193 * the leading RSS queue
194 */
195
Ariel Elior8d9ac292013-01-01 05:22:27 +0000196/* Init VF */
197struct vfpf_init_tlv {
198 struct vfpf_first_tlv first_tlv;
199 aligned_u64 sb_addr[PFVF_MAX_SBS_PER_VF]; /* vf_sb based */
200 aligned_u64 spq_addr;
201 aligned_u64 stats_addr;
Ariel Eliorb9871bc2013-09-04 14:09:21 +0300202 u16 stats_stride;
203 u32 flags;
204 u32 padding[2];
Ariel Elior8d9ac292013-01-01 05:22:27 +0000205};
206
207/* Setup Queue */
208struct vfpf_setup_q_tlv {
209 struct vfpf_first_tlv first_tlv;
210
211 struct vf_pf_rxq_params {
212 /* physical addresses */
213 aligned_u64 rcq_addr;
214 aligned_u64 rcq_np_addr;
215 aligned_u64 rxq_addr;
216 aligned_u64 sge_addr;
217
218 /* sb + hc info */
219 u8 vf_sb; /* index in hw_sbs[] */
220 u8 sb_index; /* Index in the SB */
221 u16 hc_rate; /* desired interrupts per sec. */
222 /* valid iff VFPF_QUEUE_FLG_HC */
223 /* rx buffer info */
224 u16 mtu;
225 u16 buf_sz;
226 u16 flags; /* VFPF_QUEUE_FLG_X flags */
227 u16 stat_id; /* valid iff VFPF_QUEUE_FLG_STATS */
228
229 /* valid iff VFPF_QUEUE_FLG_TPA */
230 u16 sge_buf_sz;
231 u16 tpa_agg_sz;
232 u8 max_sge_pkt;
233
234 u8 drop_flags; /* VFPF_QUEUE_DROP_X, for Linux VMs
235 * all the flags are turned off
236 */
237
238 u8 cache_line_log; /* VFPF_QUEUE_FLG_CACHE_ALIGN */
239 u8 padding;
240 } rxq;
241
242 struct vf_pf_txq_params {
243 /* physical addresses */
244 aligned_u64 txq_addr;
245
246 /* sb + hc info */
247 u8 vf_sb; /* index in hw_sbs[] */
248 u8 sb_index; /* Index in the SB */
249 u16 hc_rate; /* desired interrupts per sec. */
250 /* valid iff VFPF_QUEUE_FLG_HC */
251 u32 flags; /* VFPF_QUEUE_FLG_X flags */
252 u16 stat_id; /* valid iff VFPF_QUEUE_FLG_STATS */
253 u8 traffic_type; /* see in setup_context() */
254 u8 padding;
255 } txq;
256
257 u8 vf_qid; /* index in hw_qid[] */
258 u8 param_valid;
259#define VFPF_RXQ_VALID 0x01
260#define VFPF_TXQ_VALID 0x02
261 u8 padding[2];
262};
263
264/* Set Queue Filters */
265struct vfpf_q_mac_vlan_filter {
266 u32 flags;
267#define VFPF_Q_FILTER_DEST_MAC_VALID 0x01
268#define VFPF_Q_FILTER_VLAN_TAG_VALID 0x02
269#define VFPF_Q_FILTER_SET_MAC 0x100 /* set/clear */
270 u8 mac[ETH_ALEN];
271 u16 vlan_tag;
272};
273
274/* configure queue filters */
275struct vfpf_set_q_filters_tlv {
276 struct vfpf_first_tlv first_tlv;
277
278 u32 flags;
279#define VFPF_SET_Q_FILTERS_MAC_VLAN_CHANGED 0x01
280#define VFPF_SET_Q_FILTERS_MULTICAST_CHANGED 0x02
281#define VFPF_SET_Q_FILTERS_RX_MASK_CHANGED 0x04
282
283 u8 vf_qid; /* index in hw_qid[] */
284 u8 n_mac_vlan_filters;
285 u8 n_multicast;
286 u8 padding;
287
288#define PFVF_MAX_MAC_FILTERS 16
289#define PFVF_MAX_VLAN_FILTERS 16
290#define PFVF_MAX_FILTERS (PFVF_MAX_MAC_FILTERS +\
291 PFVF_MAX_VLAN_FILTERS)
292 struct vfpf_q_mac_vlan_filter filters[PFVF_MAX_FILTERS];
293
294#define PFVF_MAX_MULTICAST_PER_VF 32
295 u8 multicast[PFVF_MAX_MULTICAST_PER_VF][ETH_ALEN];
296
297 u32 rx_mask; /* see mask constants at the top of the file */
298};
299
Ariel Elior9b176b62013-01-01 05:22:28 +0000300/* close VF (disable VF) */
301struct vfpf_close_tlv {
302 struct vfpf_first_tlv first_tlv;
303 u16 vf_id; /* for debug */
304 u8 padding[2];
305};
306
Ariel Elior4513f922013-01-01 05:22:25 +0000307/* release the VF's acquired resources */
308struct vfpf_release_tlv {
309 struct vfpf_first_tlv first_tlv;
310 u16 vf_id;
311 u8 padding[2];
312};
313
Ariel Elior1ab44342013-01-01 05:22:23 +0000314struct tlv_buffer_size {
315 u8 tlv_buffer[TLV_BUFFER_SIZE];
316};
317
318union vfpf_tlvs {
Ariel Eliorbe1f1ffa2013-01-01 05:22:24 +0000319 struct vfpf_first_tlv first_tlv;
320 struct vfpf_acquire_tlv acquire;
Ariel Elior8d9ac292013-01-01 05:22:27 +0000321 struct vfpf_init_tlv init;
Ariel Elior9b176b62013-01-01 05:22:28 +0000322 struct vfpf_close_tlv close;
323 struct vfpf_q_op_tlv q_op;
Ariel Elior8d9ac292013-01-01 05:22:27 +0000324 struct vfpf_setup_q_tlv setup_q;
325 struct vfpf_set_q_filters_tlv set_q_filters;
Ariel Eliorb9871bc2013-09-04 14:09:21 +0300326 struct vfpf_release_tlv release;
327 struct vfpf_rss_tlv update_rss;
328 struct channel_list_end_tlv list_end;
Ariel Elior1ab44342013-01-01 05:22:23 +0000329 struct tlv_buffer_size tlv_buf_size;
330};
331
332union pfvf_tlvs {
Ariel Eliorb9871bc2013-09-04 14:09:21 +0300333 struct pfvf_general_resp_tlv general_resp;
Ariel Eliorbe1f1ffa2013-01-01 05:22:24 +0000334 struct pfvf_acquire_resp_tlv acquire_resp;
335 struct channel_list_end_tlv list_end;
Ariel Elior1ab44342013-01-01 05:22:23 +0000336 struct tlv_buffer_size tlv_buf_size;
337};
Ariel Eliorbe1f1ffa2013-01-01 05:22:24 +0000338
Ariel Eliorabc5a022013-01-01 05:22:43 +0000339/* This is a structure which is allocated in the VF, which the PF may update
340 * when it deems it necessary to do so. The bulletin board is sampled
341 * periodically by the VF. A copy per VF is maintained in the PF (to prevent
342 * loss of data upon multiple updates (or the need for read modify write)).
343 */
344struct pf_vf_bulletin_size {
345 u8 size[PF_VF_BULLETIN_SIZE];
346};
347
348struct pf_vf_bulletin_content {
349 u32 crc; /* crc of structure to ensure is not in
350 * mid-update
351 */
Ariel Elior4c133c32013-01-23 03:21:54 +0000352 u16 version;
353 u16 length;
Ariel Eliorabc5a022013-01-01 05:22:43 +0000354
355 aligned_u64 valid_bitmap; /* bitmap indicating which fields
356 * hold valid values
357 */
358
359#define MAC_ADDR_VALID 0 /* alert the vf that a new mac address
360 * is available for it
361 */
Ariel Elior3ec9f9c2013-03-11 05:17:45 +0000362#define VLAN_VALID 1 /* when set, the vf should not access
363 * the vfpf channel
364 */
Ariel Elior78c3bcc2013-06-20 17:39:08 +0300365#define CHANNEL_DOWN 2 /* vfpf channel is disabled. VFs are not
366 * to attempt to send messages on the
367 * channel after this bit is set
368 */
Ariel Eliorabc5a022013-01-01 05:22:43 +0000369 u8 mac[ETH_ALEN];
Ariel Elior3ec9f9c2013-03-11 05:17:45 +0000370 u8 mac_padding[2];
371
372 u16 vlan;
373 u8 vlan_padding[6];
Ariel Eliorabc5a022013-01-01 05:22:43 +0000374};
375
376union pf_vf_bulletin {
377 struct pf_vf_bulletin_content content;
378 struct pf_vf_bulletin_size size;
379};
380
Ariel Eliorbe1f1ffa2013-01-01 05:22:24 +0000381#define MAX_TLVS_IN_LIST 50
382
383enum channel_tlvs {
384 CHANNEL_TLV_NONE,
385 CHANNEL_TLV_ACQUIRE,
Ariel Elior8d9ac292013-01-01 05:22:27 +0000386 CHANNEL_TLV_INIT,
387 CHANNEL_TLV_SETUP_Q,
388 CHANNEL_TLV_SET_Q_FILTERS,
Ariel Eliorb9871bc2013-09-04 14:09:21 +0300389 CHANNEL_TLV_ACTIVATE_Q,
390 CHANNEL_TLV_DEACTIVATE_Q,
Ariel Elior9b176b62013-01-01 05:22:28 +0000391 CHANNEL_TLV_TEARDOWN_Q,
392 CHANNEL_TLV_CLOSE,
Ariel Elior4513f922013-01-01 05:22:25 +0000393 CHANNEL_TLV_RELEASE,
Ariel Eliorb9871bc2013-09-04 14:09:21 +0300394 CHANNEL_TLV_UPDATE_RSS_DEPRECATED,
Ariel Eliorf1929b02013-01-01 05:22:41 +0000395 CHANNEL_TLV_PF_RELEASE_VF,
Ariel Eliorbe1f1ffa2013-01-01 05:22:24 +0000396 CHANNEL_TLV_LIST_END,
Ariel Eliord16132c2013-01-01 05:22:42 +0000397 CHANNEL_TLV_FLR,
Ariel Eliorabc5a022013-01-01 05:22:43 +0000398 CHANNEL_TLV_PF_SET_MAC,
Ariel Elior3ec9f9c2013-03-11 05:17:45 +0000399 CHANNEL_TLV_PF_SET_VLAN,
Ariel Eliorb9871bc2013-09-04 14:09:21 +0300400 CHANNEL_TLV_UPDATE_RSS,
Ariel Eliorbe1f1ffa2013-01-01 05:22:24 +0000401 CHANNEL_TLV_MAX
402};
403
Ariel Elior64112802013-01-07 00:50:23 +0000404#endif /* CONFIG_BNX2X_SRIOV */
Ariel Elior1ab44342013-01-01 05:22:23 +0000405#endif /* VF_PF_IF_H */