Imported Upstream version 16.07-rc1
[deb_dpdk.git] / drivers / net / qede / base / ecore_vfpf_if.h
1 /*
2  * Copyright (c) 2016 QLogic Corporation.
3  * All rights reserved.
4  * www.qlogic.com
5  *
6  * See LICENSE.qede_pmd for copyright and licensing details.
7  */
8
9 #ifndef __ECORE_VF_PF_IF_H__
10 #define __ECORE_VF_PF_IF_H__
11
12 #define T_ETH_INDIRECTION_TABLE_SIZE 128
13 #define T_ETH_RSS_KEY_SIZE 10
14 #ifndef aligned_u64
15 #define aligned_u64 u64
16 #endif
17
18 /***********************************************
19  *
20  * Common definitions for all HVs
21  *
22  **/
23 struct vf_pf_resc_request {
24         u8 num_rxqs;
25         u8 num_txqs;
26         u8 num_sbs;
27         u8 num_mac_filters;
28         u8 num_vlan_filters;
29         u8 num_mc_filters;      /* No limit  so superfluous */
30         u16 padding;
31 };
32
33 struct hw_sb_info {
34         u16 hw_sb_id;           /* aka absolute igu id, used to ack the sb */
35         u8 sb_qid;              /* used to update DHC for sb */
36         u8 padding[5];
37 };
38
39 /***********************************************
40  *
41  * HW VF-PF channel definitions
42  *
43  * A.K.A VF-PF mailbox
44  *
45  **/
46 #define TLV_BUFFER_SIZE         1024
47 #define TLV_ALIGN               sizeof(u64)
48 #define PF_VF_BULLETIN_SIZE     512
49
50 #define VFPF_RX_MASK_ACCEPT_NONE                0x00000000
51 #define VFPF_RX_MASK_ACCEPT_MATCHED_UNICAST     0x00000001
52 #define VFPF_RX_MASK_ACCEPT_MATCHED_MULTICAST   0x00000002
53 #define VFPF_RX_MASK_ACCEPT_ALL_UNICAST 0x00000004
54 #define VFPF_RX_MASK_ACCEPT_ALL_MULTICAST       0x00000008
55 #define VFPF_RX_MASK_ACCEPT_BROADCAST   0x00000010
56 /* TODO: #define VFPF_RX_MASK_ACCEPT_ANY_VLAN   0x00000020 */
57
58 #define BULLETIN_CONTENT_SIZE   (sizeof(struct pf_vf_bulletin_content))
59 #define BULLETIN_ATTEMPTS       5       /* crc failures before throwing towel */
60 #define BULLETIN_CRC_SEED       0
61
62 enum {
63         PFVF_STATUS_WAITING = 0,
64         PFVF_STATUS_SUCCESS,
65         PFVF_STATUS_FAILURE,
66         PFVF_STATUS_NOT_SUPPORTED,
67         PFVF_STATUS_NO_RESOURCE,
68         PFVF_STATUS_FORCED,
69 };
70
71 /* vf pf channel tlvs */
72 /* general tlv header (used for both vf->pf request and pf->vf response) */
73 struct channel_tlv {
74         u16 type;
75         u16 length;
76 };
77
78 /* header of first vf->pf tlv carries the offset used to calculate response
79  * buffer address
80  */
81 struct vfpf_first_tlv {
82         struct channel_tlv tl;
83         u32 padding;
84         aligned_u64 reply_address;
85 };
86
87 /* header of pf->vf tlvs, carries the status of handling the request */
88 struct pfvf_tlv {
89         struct channel_tlv tl;
90         u8 status;
91         u8 padding[3];
92 };
93
94 /* response tlv used for most tlvs */
95 struct pfvf_def_resp_tlv {
96         struct pfvf_tlv hdr;
97 };
98
99 /* used to terminate and pad a tlv list */
100 struct channel_list_end_tlv {
101         struct channel_tlv tl;
102         u8 padding[4];
103 };
104
105 /* Acquire */
106 struct vfpf_acquire_tlv {
107         struct vfpf_first_tlv first_tlv;
108
109         struct vf_pf_vfdev_info {
110 #define VFPF_ACQUIRE_CAP_OVERRIDE_FW_VER                (1 << 0)
111                 aligned_u64 capabilties;
112                 u8 fw_major;
113                 u8 fw_minor;
114                 u8 fw_revision;
115                 u8 fw_engineering;
116                 u32 driver_version;
117                 u16 opaque_fid; /* ME register value */
118                 u8 os_type;     /* VFPF_ACQUIRE_OS_* value */
119                 u8 padding[5];
120         } vfdev_info;
121
122         struct vf_pf_resc_request resc_request;
123
124         aligned_u64 bulletin_addr;
125         u32 bulletin_size;
126         u32 padding;
127 };
128
129 /* receive side scaling tlv */
130 struct vfpf_vport_update_rss_tlv {
131         struct channel_tlv tl;
132
133         u8 update_rss_flags;
134 #define VFPF_UPDATE_RSS_CONFIG_FLAG       (1 << 0)
135 #define VFPF_UPDATE_RSS_CAPS_FLAG         (1 << 1)
136 #define VFPF_UPDATE_RSS_IND_TABLE_FLAG    (1 << 2)
137 #define VFPF_UPDATE_RSS_KEY_FLAG          (1 << 3)
138
139         u8 rss_enable;
140         u8 rss_caps;
141         u8 rss_table_size_log;  /* The table size is 2 ^ rss_table_size_log */
142         u16 rss_ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
143         u32 rss_key[T_ETH_RSS_KEY_SIZE];
144 };
145
146 struct pfvf_storm_stats {
147         u32 address;
148         u32 len;
149 };
150
151 struct pfvf_stats_info {
152         struct pfvf_storm_stats mstats;
153         struct pfvf_storm_stats pstats;
154         struct pfvf_storm_stats tstats;
155         struct pfvf_storm_stats ustats;
156 };
157
158 /* acquire response tlv - carries the allocated resources */
159 struct pfvf_acquire_resp_tlv {
160         struct pfvf_tlv hdr;
161
162         struct pf_vf_pfdev_info {
163                 u32 chip_num;
164                 u32 mfw_ver;
165
166                 u16 fw_major;
167                 u16 fw_minor;
168                 u16 fw_rev;
169                 u16 fw_eng;
170
171                 aligned_u64 capabilities;
172 #define PFVF_ACQUIRE_CAP_DEFAULT_UNTAGGED       (1 << 0)
173
174                 u16 db_size;
175                 u8 indices_per_sb;
176                 u8 os_type;
177
178                 /* Thesee should match the PF's ecore_dev values */
179                 u16 chip_rev;
180                 u8 dev_type;
181
182                 u8 padding;
183
184                 struct pfvf_stats_info stats_info;
185
186                 u8 port_mac[ETH_ALEN];
187                 u8 padding2[2];
188         } pfdev_info;
189
190         struct pf_vf_resc {
191                 /* in case of status NO_RESOURCE in message hdr, pf will fill
192                  * this struct with suggested amount of resources for next
193                  * acquire request
194                  */
195 #define PFVF_MAX_QUEUES_PER_VF         16
196 #define PFVF_MAX_SBS_PER_VF            16
197                 struct hw_sb_info hw_sbs[PFVF_MAX_SBS_PER_VF];
198                 u8 hw_qid[PFVF_MAX_QUEUES_PER_VF];
199                 u8 cid[PFVF_MAX_QUEUES_PER_VF];
200
201                 u8 num_rxqs;
202                 u8 num_txqs;
203                 u8 num_sbs;
204                 u8 num_mac_filters;
205                 u8 num_vlan_filters;
206                 u8 num_mc_filters;
207                 u8 padding[2];
208         } resc;
209
210         u32 bulletin_size;
211         u32 padding;
212 };
213
214 /* Init VF */
215 struct vfpf_init_tlv {
216         struct vfpf_first_tlv first_tlv;
217         aligned_u64 stats_addr;
218
219         u16 rx_mask;
220         u16 tx_mask;
221         u8 drop_ttl0_flg;
222         u8 padding[3];
223
224 };
225
226 /* Setup Queue */
227 struct vfpf_start_rxq_tlv {
228         struct vfpf_first_tlv first_tlv;
229
230         /* physical addresses */
231         aligned_u64 rxq_addr;
232         aligned_u64 deprecated_sge_addr;
233         aligned_u64 cqe_pbl_addr;
234
235         u16 cqe_pbl_size;
236         u16 hw_sb;
237         u16 rx_qid;
238         u16 hc_rate;            /* desired interrupts per sec. */
239
240         u16 bd_max_bytes;
241         u16 stat_id;
242         u8 sb_index;
243         u8 padding[3];
244
245 };
246
247 struct vfpf_start_txq_tlv {
248         struct vfpf_first_tlv first_tlv;
249
250         /* physical addresses */
251         aligned_u64 pbl_addr;
252         u16 pbl_size;
253         u16 stat_id;
254         u16 tx_qid;
255         u16 hw_sb;
256
257         u32 flags;              /* VFPF_QUEUE_FLG_X flags */
258         u16 hc_rate;            /* desired interrupts per sec. */
259         u8 sb_index;
260         u8 padding[3];
261 };
262
263 /* Stop RX Queue */
264 struct vfpf_stop_rxqs_tlv {
265         struct vfpf_first_tlv first_tlv;
266
267         u16 rx_qid;
268         u8 num_rxqs;
269         u8 cqe_completion;
270         u8 padding[4];
271 };
272
273 /* Stop TX Queues */
274 struct vfpf_stop_txqs_tlv {
275         struct vfpf_first_tlv first_tlv;
276
277         u16 tx_qid;
278         u8 num_txqs;
279         u8 padding[5];
280 };
281
282 struct vfpf_update_rxq_tlv {
283         struct vfpf_first_tlv first_tlv;
284
285         aligned_u64 deprecated_sge_addr[PFVF_MAX_QUEUES_PER_VF];
286
287         u16 rx_qid;
288         u8 num_rxqs;
289         u8 flags;
290 #define VFPF_RXQ_UPD_INIT_SGE_DEPRECATE_FLAG    (1 << 0)
291 #define VFPF_RXQ_UPD_COMPLETE_CQE_FLAG          (1 << 1)
292 #define VFPF_RXQ_UPD_COMPLETE_EVENT_FLAG        (1 << 2)
293
294         u8 padding[4];
295 };
296
297 /* Set Queue Filters */
298 struct vfpf_q_mac_vlan_filter {
299         u32 flags;
300 #define VFPF_Q_FILTER_DEST_MAC_VALID    0x01
301 #define VFPF_Q_FILTER_VLAN_TAG_VALID    0x02
302 #define VFPF_Q_FILTER_SET_MAC   0x100   /* set/clear */
303
304         u8 mac[ETH_ALEN];
305         u16 vlan_tag;
306
307         u8 padding[4];
308 };
309
310 /* Start a vport */
311 struct vfpf_vport_start_tlv {
312         struct vfpf_first_tlv first_tlv;
313
314         aligned_u64 sb_addr[PFVF_MAX_SBS_PER_VF];
315
316         u32 tpa_mode;
317         u16 dep1;
318         u16 mtu;
319
320         u8 vport_id;
321         u8 inner_vlan_removal;
322
323         u8 only_untagged;
324         u8 max_buffers_per_cqe;
325
326         u8 padding[4];
327 };
328
329 /* Extended tlvs - need to add rss, mcast, accept mode tlvs */
330 struct vfpf_vport_update_activate_tlv {
331         struct channel_tlv tl;
332         u8 update_rx;
333         u8 update_tx;
334         u8 active_rx;
335         u8 active_tx;
336 };
337
338 struct vfpf_vport_update_tx_switch_tlv {
339         struct channel_tlv tl;
340         u8 tx_switching;
341         u8 padding[3];
342 };
343
344 struct vfpf_vport_update_vlan_strip_tlv {
345         struct channel_tlv tl;
346         u8 remove_vlan;
347         u8 padding[3];
348 };
349
350 struct vfpf_vport_update_mcast_bin_tlv {
351         struct channel_tlv tl;
352         u8 padding[4];
353
354         aligned_u64 bins[8];
355 };
356
357 struct vfpf_vport_update_accept_param_tlv {
358         struct channel_tlv tl;
359         u8 update_rx_mode;
360         u8 update_tx_mode;
361         u8 rx_accept_filter;
362         u8 tx_accept_filter;
363 };
364
365 struct vfpf_vport_update_accept_any_vlan_tlv {
366         struct channel_tlv tl;
367         u8 update_accept_any_vlan_flg;
368         u8 accept_any_vlan;
369
370         u8 padding[2];
371 };
372
373 struct vfpf_vport_update_sge_tpa_tlv {
374         struct channel_tlv tl;
375
376         u16 sge_tpa_flags;
377 #define VFPF_TPA_IPV4_EN_FLAG        (1 << 0)
378 #define VFPF_TPA_IPV6_EN_FLAG        (1 << 1)
379 #define VFPF_TPA_PKT_SPLIT_FLAG      (1 << 2)
380 #define VFPF_TPA_HDR_DATA_SPLIT_FLAG (1 << 3)
381 #define VFPF_TPA_GRO_CONSIST_FLAG    (1 << 4)
382
383         u8 update_sge_tpa_flags;
384 #define VFPF_UPDATE_SGE_DEPRECATED_FLAG    (1 << 0)
385 #define VFPF_UPDATE_TPA_EN_FLAG    (1 << 1)
386 #define VFPF_UPDATE_TPA_PARAM_FLAG (1 << 2)
387
388         u8 max_buffers_per_cqe;
389
390         u16 deprecated_sge_buff_size;
391         u16 tpa_max_size;
392         u16 tpa_min_size_to_start;
393         u16 tpa_min_size_to_cont;
394
395         u8 tpa_max_aggs_num;
396         u8 padding[7];
397
398 };
399
400 /* Primary tlv as a header for various extended tlvs for
401  * various functionalities in vport update ramrod.
402  */
403 struct vfpf_vport_update_tlv {
404         struct vfpf_first_tlv first_tlv;
405 };
406
407 struct vfpf_ucast_filter_tlv {
408         struct vfpf_first_tlv first_tlv;
409
410         u8 opcode;
411         u8 type;
412
413         u8 mac[ETH_ALEN];
414
415         u16 vlan;
416         u16 padding[3];
417 };
418
419 struct tlv_buffer_size {
420         u8 tlv_buffer[TLV_BUFFER_SIZE];
421 };
422
423 union vfpf_tlvs {
424         struct vfpf_first_tlv first_tlv;
425         struct vfpf_acquire_tlv acquire;
426         struct vfpf_init_tlv init;
427         struct vfpf_start_rxq_tlv start_rxq;
428         struct vfpf_start_txq_tlv start_txq;
429         struct vfpf_stop_rxqs_tlv stop_rxqs;
430         struct vfpf_stop_txqs_tlv stop_txqs;
431         struct vfpf_update_rxq_tlv update_rxq;
432         struct vfpf_vport_start_tlv start_vport;
433         struct vfpf_vport_update_tlv vport_update;
434         struct vfpf_ucast_filter_tlv ucast_filter;
435         struct channel_list_end_tlv list_end;
436         struct tlv_buffer_size tlv_buf_size;
437 };
438
439 union pfvf_tlvs {
440         struct pfvf_def_resp_tlv default_resp;
441         struct pfvf_acquire_resp_tlv acquire_resp;
442         struct channel_list_end_tlv list_end;
443         struct tlv_buffer_size tlv_buf_size;
444 };
445
446 /* This is a structure which is allocated in the VF, which the PF may update
447  * when it deems it necessary to do so. The bulletin board is sampled
448  * periodically by the VF. A copy per VF is maintained in the PF (to prevent
449  * loss of data upon multiple updates (or the need for read modify write)).
450  */
451 enum ecore_bulletin_bit {
452         /* Alert the VF that a forced MAC was set by the PF */
453         MAC_ADDR_FORCED = 0,
454
455         /* The VF should not access the vfpf channel */
456         VFPF_CHANNEL_INVALID = 1,
457
458         /* Alert the VF that a forced VLAN was set by the PF */
459         VLAN_ADDR_FORCED = 2,
460
461         /* Indicate that `default_only_untagged' contains actual data */
462         VFPF_BULLETIN_UNTAGGED_DEFAULT = 3,
463         VFPF_BULLETIN_UNTAGGED_DEFAULT_FORCED = 4,
464
465         /* Alert the VF that suggested mac was sent by the PF.
466          * MAC_ADDR will be disabled in case MAC_ADDR_FORCED is set
467          */
468         VFPF_BULLETIN_MAC_ADDR = 5
469 };
470
471 struct ecore_bulletin_content {
472         u32 crc;                /* crc of structure to ensure is not in
473                                  * mid-update
474                                  */
475         u32 version;
476
477         aligned_u64 valid_bitmap;       /* bitmap indicating wich fields
478                                          * hold valid values
479                                          */
480
481         u8 mac[ETH_ALEN];       /* used for MAC_ADDR or MAC_ADDR_FORCED */
482
483         u8 default_only_untagged;       /* If valid, 1 => only untagged Rx
484                                          * if no vlan filter is configured.
485                                          */
486         u8 padding;
487
488         /* The following is a 'copy' of ecore_mcp_link_state,
489          * ecore_mcp_link_params and ecore_mcp_link_capabilities. Since it's
490          * possible the structs will increase further along the road we cannot
491          * have it here; Instead we need to have all of its fields.
492          */
493         u8 req_autoneg;
494         u8 req_autoneg_pause;
495         u8 req_forced_rx;
496         u8 req_forced_tx;
497         u8 padding2[4];
498
499         u32 req_adv_speed;
500         u32 req_forced_speed;
501         u32 req_loopback;
502         u32 padding3;
503
504         u8 link_up;
505         u8 full_duplex;
506         u8 autoneg;
507         u8 autoneg_complete;
508         u8 parallel_detection;
509         u8 pfc_enabled;
510         u8 partner_tx_flow_ctrl_en;
511         u8 partner_rx_flow_ctrl_en;
512         u8 partner_adv_pause;
513         u8 sfp_tx_fault;
514         u8 padding4[6];
515
516         u32 speed;
517         u32 partner_adv_speed;
518
519         u32 capability_speed;
520
521         /* Forced vlan */
522         u16 pvid;
523         u16 padding5;
524 };
525
526 struct ecore_bulletin {
527         dma_addr_t phys;
528         struct ecore_bulletin_content *p_virt;
529         u32 size;
530 };
531
532 #ifndef print_enum
533 enum {
534 /*!!!!! Make sure to update STRINGS structure accordingly !!!!!*/
535
536         CHANNEL_TLV_NONE,       /* ends tlv sequence */
537         CHANNEL_TLV_ACQUIRE,
538         CHANNEL_TLV_VPORT_START,
539         CHANNEL_TLV_VPORT_UPDATE,
540         CHANNEL_TLV_VPORT_TEARDOWN,
541         CHANNEL_TLV_START_RXQ,
542         CHANNEL_TLV_START_TXQ,
543         CHANNEL_TLV_STOP_RXQS,
544         CHANNEL_TLV_STOP_TXQS,
545         CHANNEL_TLV_UPDATE_RXQ,
546         CHANNEL_TLV_INT_CLEANUP,
547         CHANNEL_TLV_CLOSE,
548         CHANNEL_TLV_RELEASE,
549         CHANNEL_TLV_LIST_END,
550         CHANNEL_TLV_UCAST_FILTER,
551         CHANNEL_TLV_VPORT_UPDATE_ACTIVATE,
552         CHANNEL_TLV_VPORT_UPDATE_TX_SWITCH,
553         CHANNEL_TLV_VPORT_UPDATE_VLAN_STRIP,
554         CHANNEL_TLV_VPORT_UPDATE_MCAST,
555         CHANNEL_TLV_VPORT_UPDATE_ACCEPT_PARAM,
556         CHANNEL_TLV_VPORT_UPDATE_RSS,
557         CHANNEL_TLV_VPORT_UPDATE_ACCEPT_ANY_VLAN,
558         CHANNEL_TLV_VPORT_UPDATE_SGE_TPA,
559         CHANNEL_TLV_MAX
560 /*!!!!! Make sure to update STRINGS structure accordingly !!!!!*/
561 };
562 extern const char *ecore_channel_tlvs_string[];
563
564 #else
565 print_enum(channel_tlvs, CHANNEL_TLV_NONE,      /* ends tlv sequence */
566            CHANNEL_TLV_ACQUIRE,
567            CHANNEL_TLV_VPORT_START,
568            CHANNEL_TLV_VPORT_UPDATE,
569            CHANNEL_TLV_VPORT_TEARDOWN,
570            CHANNEL_TLV_SETUP_RXQ,
571            CHANNEL_TLV_SETUP_TXQ,
572            CHANNEL_TLV_STOP_RXQS,
573            CHANNEL_TLV_STOP_TXQS,
574            CHANNEL_TLV_UPDATE_RXQ,
575            CHANNEL_TLV_INT_CLEANUP,
576            CHANNEL_TLV_CLOSE,
577            CHANNEL_TLV_RELEASE,
578            CHANNEL_TLV_LIST_END,
579            CHANNEL_TLV_UCAST_FILTER,
580            CHANNEL_TLV_VPORT_UPDATE_ACTIVATE,
581            CHANNEL_TLV_VPORT_UPDATE_TX_SWITCH,
582            CHANNEL_TLV_VPORT_UPDATE_VLAN_STRIP,
583            CHANNEL_TLV_VPORT_UPDATE_MCAST,
584            CHANNEL_TLV_VPORT_UPDATE_ACCEPT_PARAM,
585            CHANNEL_TLV_VPORT_UPDATE_RSS,
586            CHANNEL_TLV_VPORT_UPDATE_ACCEPT_ANY_VLAN,
587            CHANNEL_TLV_VPORT_UPDATE_SGE_TPA, CHANNEL_TLV_MAX);
588 #endif
589
590 #endif /* __ECORE_VF_PF_IF_H__ */