Merge remote-tracking branches 'asoc/fix/fsl-dma', 'asoc/fix/fsl-spdif', 'asoc/fix...
[linux-2.6-microblaze.git] / drivers / net / ethernet / broadcom / bnx2x / bnx2x_vfpf.h
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_ATTEMPTS       5 /* crc failures before throwing towel */
69 #define BULLETIN_CRC_SEED       0
70
71 enum {
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) */
81 struct 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  */
89 struct 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 */
95 struct pfvf_tlv {
96         struct channel_tlv tl;
97         u8 status;
98         u8 padding[3];
99 };
100
101 /* response tlv used for most tlvs */
102 struct pfvf_general_resp_tlv {
103         struct pfvf_tlv hdr;
104 };
105
106 /* used to terminate and pad a tlv list */
107 struct channel_list_end_tlv {
108         struct channel_tlv tl;
109         u8 padding[4];
110 };
111
112 /* Acquire */
113 struct 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
128 /* simple operation request on queue */
129 struct vfpf_q_op_tlv {
130         struct vfpf_first_tlv   first_tlv;
131         u8 vf_qid;
132         u8 padding[3];
133 };
134
135 /* receive side scaling tlv */
136 struct 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
156 /* acquire response tlv - carries the allocated resources */
157 struct 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 #define PFVF_CAP_TPA_UPDATE     0x00000008
166                 char fw_ver[32];
167                 u16 db_size;
168                 u8  indices_per_sb;
169                 u8  padding;
170         } pfdev_info;
171         struct pf_vf_resc {
172                 /* in case of status NO_RESOURCE in message hdr, pf will fill
173                  * this struct with suggested amount of resources for next
174                  * acquire request
175                  */
176 #define PFVF_MAX_QUEUES_PER_VF         16
177 #define PFVF_MAX_SBS_PER_VF            16
178                 struct hw_sb_info hw_sbs[PFVF_MAX_SBS_PER_VF];
179                 u8      hw_qid[PFVF_MAX_QUEUES_PER_VF];
180                 u8      num_rxqs;
181                 u8      num_txqs;
182                 u8      num_sbs;
183                 u8      num_mac_filters;
184                 u8      num_vlan_filters;
185                 u8      num_mc_filters;
186                 u8      permanent_mac_addr[ETH_ALEN];
187                 u8      current_mac_addr[ETH_ALEN];
188                 u8      padding[2];
189         } resc;
190 };
191
192 struct vfpf_port_phys_id_resp_tlv {
193         struct channel_tlv tl;
194         u8 id[ETH_ALEN];
195         u8 padding[2];
196 };
197
198 #define VFPF_INIT_FLG_STATS_COALESCE    (1 << 0) /* when set the VFs queues
199                                                   * stats will be coalesced on
200                                                   * the leading RSS queue
201                                                   */
202
203 /* Init VF */
204 struct vfpf_init_tlv {
205         struct vfpf_first_tlv first_tlv;
206         aligned_u64 sb_addr[PFVF_MAX_SBS_PER_VF]; /* vf_sb based */
207         aligned_u64 spq_addr;
208         aligned_u64 stats_addr;
209         u16 stats_stride;
210         u32 flags;
211         u32 padding[2];
212 };
213
214 /* Setup Queue */
215 struct vfpf_setup_q_tlv {
216         struct vfpf_first_tlv first_tlv;
217
218         struct vf_pf_rxq_params {
219                 /* physical addresses */
220                 aligned_u64 rcq_addr;
221                 aligned_u64 rcq_np_addr;
222                 aligned_u64 rxq_addr;
223                 aligned_u64 sge_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                 /* rx buffer info */
231                 u16 mtu;
232                 u16 buf_sz;
233                 u16 flags;              /* VFPF_QUEUE_FLG_X flags */
234                 u16 stat_id;            /* valid iff VFPF_QUEUE_FLG_STATS */
235
236                 /* valid iff VFPF_QUEUE_FLG_TPA */
237                 u16 sge_buf_sz;
238                 u16 tpa_agg_sz;
239                 u8 max_sge_pkt;
240
241                 u8 drop_flags;          /* VFPF_QUEUE_DROP_X, for Linux VMs
242                                          * all the flags are turned off
243                                          */
244
245                 u8 cache_line_log;      /* VFPF_QUEUE_FLG_CACHE_ALIGN */
246                 u8 padding;
247         } rxq;
248
249         struct vf_pf_txq_params {
250                 /* physical addresses */
251                 aligned_u64 txq_addr;
252
253                 /* sb + hc info */
254                 u8  vf_sb;              /* index in hw_sbs[] */
255                 u8  sb_index;           /* Index in the SB */
256                 u16 hc_rate;            /* desired interrupts per sec. */
257                                         /* valid iff VFPF_QUEUE_FLG_HC */
258                 u32 flags;              /* VFPF_QUEUE_FLG_X flags */
259                 u16 stat_id;            /* valid iff VFPF_QUEUE_FLG_STATS */
260                 u8  traffic_type;       /* see in setup_context() */
261                 u8  padding;
262         } txq;
263
264         u8 vf_qid;                      /* index in hw_qid[] */
265         u8 param_valid;
266 #define VFPF_RXQ_VALID          0x01
267 #define VFPF_TXQ_VALID          0x02
268         u8 padding[2];
269 };
270
271 /* Set Queue Filters */
272 struct vfpf_q_mac_vlan_filter {
273         u32 flags;
274 #define VFPF_Q_FILTER_DEST_MAC_VALID    0x01
275 #define VFPF_Q_FILTER_VLAN_TAG_VALID    0x02
276 #define VFPF_Q_FILTER_SET_MAC           0x100   /* set/clear */
277         u8  mac[ETH_ALEN];
278         u16 vlan_tag;
279 };
280
281 /* configure queue filters */
282 struct vfpf_set_q_filters_tlv {
283         struct vfpf_first_tlv first_tlv;
284
285         u32 flags;
286 #define VFPF_SET_Q_FILTERS_MAC_VLAN_CHANGED     0x01
287 #define VFPF_SET_Q_FILTERS_MULTICAST_CHANGED    0x02
288 #define VFPF_SET_Q_FILTERS_RX_MASK_CHANGED      0x04
289
290         u8 vf_qid;                      /* index in hw_qid[] */
291         u8 n_mac_vlan_filters;
292         u8 n_multicast;
293         u8 padding;
294
295 #define PFVF_MAX_MAC_FILTERS                   16
296 #define PFVF_MAX_VLAN_FILTERS                  16
297 #define PFVF_MAX_FILTERS               (PFVF_MAX_MAC_FILTERS +\
298                                          PFVF_MAX_VLAN_FILTERS)
299         struct vfpf_q_mac_vlan_filter filters[PFVF_MAX_FILTERS];
300
301 #define PFVF_MAX_MULTICAST_PER_VF              32
302         u8  multicast[PFVF_MAX_MULTICAST_PER_VF][ETH_ALEN];
303
304         u32 rx_mask;    /* see mask constants at the top of the file */
305 };
306
307 struct vfpf_tpa_tlv {
308         struct vfpf_first_tlv   first_tlv;
309
310         struct vf_pf_tpa_client_info {
311                 aligned_u64 sge_addr[PFVF_MAX_QUEUES_PER_VF];
312                 u8 update_ipv4;
313                 u8 update_ipv6;
314                 u8 max_tpa_queues;
315                 u8 max_sges_for_packet;
316                 u8 complete_on_both_clients;
317                 u8 dont_verify_thr;
318                 u8 tpa_mode;
319                 u16 sge_buff_size;
320                 u16 max_agg_size;
321                 u16 sge_pause_thr_low;
322                 u16 sge_pause_thr_high;
323         } tpa_client_info;
324 };
325
326 /* close VF (disable VF) */
327 struct vfpf_close_tlv {
328         struct vfpf_first_tlv   first_tlv;
329         u16                     vf_id;  /* for debug */
330         u8 padding[2];
331 };
332
333 /* release the VF's acquired resources */
334 struct vfpf_release_tlv {
335         struct vfpf_first_tlv   first_tlv;
336         u16                     vf_id;
337         u8 padding[2];
338 };
339
340 struct tlv_buffer_size {
341         u8 tlv_buffer[TLV_BUFFER_SIZE];
342 };
343
344 union vfpf_tlvs {
345         struct vfpf_first_tlv           first_tlv;
346         struct vfpf_acquire_tlv         acquire;
347         struct vfpf_init_tlv            init;
348         struct vfpf_close_tlv           close;
349         struct vfpf_q_op_tlv            q_op;
350         struct vfpf_setup_q_tlv         setup_q;
351         struct vfpf_set_q_filters_tlv   set_q_filters;
352         struct vfpf_release_tlv         release;
353         struct vfpf_rss_tlv             update_rss;
354         struct vfpf_tpa_tlv             update_tpa;
355         struct channel_list_end_tlv     list_end;
356         struct tlv_buffer_size          tlv_buf_size;
357 };
358
359 union pfvf_tlvs {
360         struct pfvf_general_resp_tlv    general_resp;
361         struct pfvf_acquire_resp_tlv    acquire_resp;
362         struct channel_list_end_tlv     list_end;
363         struct tlv_buffer_size          tlv_buf_size;
364 };
365
366 /* This is a structure which is allocated in the VF, which the PF may update
367  * when it deems it necessary to do so. The bulletin board is sampled
368  * periodically by the VF. A copy per VF is maintained in the PF (to prevent
369  * loss of data upon multiple updates (or the need for read modify write)).
370  */
371 struct pf_vf_bulletin_size {
372         u8 size[PF_VF_BULLETIN_SIZE];
373 };
374
375 struct pf_vf_bulletin_content {
376         u32 crc;                        /* crc of structure to ensure is not in
377                                          * mid-update
378                                          */
379         u16 version;
380         u16 length;
381
382         aligned_u64 valid_bitmap;       /* bitmap indicating which fields
383                                          * hold valid values
384                                          */
385
386 #define MAC_ADDR_VALID          0       /* alert the vf that a new mac address
387                                          * is available for it
388                                          */
389 #define VLAN_VALID              1       /* when set, the vf should not access
390                                          * the vfpf channel
391                                          */
392 #define CHANNEL_DOWN            2       /* vfpf channel is disabled. VFs are not
393                                          * to attempt to send messages on the
394                                          * channel after this bit is set
395                                          */
396         u8 mac[ETH_ALEN];
397         u8 mac_padding[2];
398
399         u16 vlan;
400         u8 vlan_padding[6];
401 };
402
403 union pf_vf_bulletin {
404         struct pf_vf_bulletin_content content;
405         struct pf_vf_bulletin_size size;
406 };
407
408 #define MAX_TLVS_IN_LIST 50
409
410 enum channel_tlvs {
411         CHANNEL_TLV_NONE,
412         CHANNEL_TLV_ACQUIRE,
413         CHANNEL_TLV_INIT,
414         CHANNEL_TLV_SETUP_Q,
415         CHANNEL_TLV_SET_Q_FILTERS,
416         CHANNEL_TLV_ACTIVATE_Q,
417         CHANNEL_TLV_DEACTIVATE_Q,
418         CHANNEL_TLV_TEARDOWN_Q,
419         CHANNEL_TLV_CLOSE,
420         CHANNEL_TLV_RELEASE,
421         CHANNEL_TLV_UPDATE_RSS_DEPRECATED,
422         CHANNEL_TLV_PF_RELEASE_VF,
423         CHANNEL_TLV_LIST_END,
424         CHANNEL_TLV_FLR,
425         CHANNEL_TLV_PF_SET_MAC,
426         CHANNEL_TLV_PF_SET_VLAN,
427         CHANNEL_TLV_UPDATE_RSS,
428         CHANNEL_TLV_PHYS_PORT_ID,
429         CHANNEL_TLV_UPDATE_TPA,
430         CHANNEL_TLV_MAX
431 };
432
433 #endif /* CONFIG_BNX2X_SRIOV */
434 #endif /* VF_PF_IF_H */