net/qede/base: read per queue coalescing from HW
[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 /* @@@ TBD MichalK this should be HSI? */
13 #define T_ETH_INDIRECTION_TABLE_SIZE 128
14 #define T_ETH_RSS_KEY_SIZE 10 /* @@@ TBD this should be HSI? */
15
16 /***********************************************
17  *
18  * Common definitions for all HVs
19  *
20  **/
21 struct vf_pf_resc_request {
22         u8 num_rxqs;
23         u8 num_txqs;
24         u8 num_sbs;
25         u8 num_mac_filters;
26         u8 num_vlan_filters;
27         u8 num_mc_filters; /* No limit  so superfluous */
28         u8 num_cids;
29         u8 padding;
30 };
31
32 struct hw_sb_info {
33         u16 hw_sb_id;    /* aka absolute igu id, used to ack the sb */
34         u8 sb_qid;      /* used to update DHC for sb */
35         u8 padding[5];
36 };
37
38 /***********************************************
39  *
40  * HW VF-PF channel definitions
41  *
42  * A.K.A VF-PF mailbox
43  *
44  **/
45 #define TLV_BUFFER_SIZE         1024
46
47 /* vf pf channel tlvs */
48 /* general tlv header (used for both vf->pf request and pf->vf response) */
49 struct channel_tlv {
50         u16 type;
51         u16 length;
52 };
53
54 /* header of first vf->pf tlv carries the offset used to calculate response
55  * buffer address
56  */
57 struct vfpf_first_tlv {
58         struct channel_tlv tl;
59         u32 padding;
60         u64 reply_address;
61 };
62
63 /* header of pf->vf tlvs, carries the status of handling the request */
64 struct pfvf_tlv {
65         struct channel_tlv tl;
66         u8 status;
67         u8 padding[3];
68 };
69
70 /* response tlv used for most tlvs */
71 struct pfvf_def_resp_tlv {
72         struct pfvf_tlv hdr;
73 };
74
75 /* used to terminate and pad a tlv list */
76 struct channel_list_end_tlv {
77         struct channel_tlv tl;
78         u8 padding[4];
79 };
80
81 /* Acquire */
82 struct vfpf_acquire_tlv {
83         struct vfpf_first_tlv first_tlv;
84
85         struct vf_pf_vfdev_info {
86 #ifndef LINUX_REMOVE
87         /* First bit was used on 8.7.x and 8.8.x versions, which had different
88          * FWs used but with the same faspath HSI. As this was prior to the
89          * fastpath versioning, wanted to have ability to override fw matching
90          * and allow them to interact.
91          */
92 #endif
93 /* VF pre-FP hsi version */
94 #define VFPF_ACQUIRE_CAP_PRE_FP_HSI     (1 << 0)
95 #define VFPF_ACQUIRE_CAP_100G           (1 << 1) /* VF can support 100g */
96
97         /* A requirement for supporting multi-Tx queues on a single queue-zone,
98          * VF would pass qids as additional information whenever passing queue
99          * references.
100          * TODO - due to the CID limitations in Bar0, VFs currently don't pass
101          * this, and use the legacy CID scheme.
102          */
103 #define VFPF_ACQUIRE_CAP_QUEUE_QIDS     (1 << 2)
104                 u64 capabilities;
105                 u8 fw_major;
106                 u8 fw_minor;
107                 u8 fw_revision;
108                 u8 fw_engineering;
109                 u32 driver_version;
110                 u16 opaque_fid; /* ME register value */
111                 u8 os_type; /* VFPF_ACQUIRE_OS_* value */
112                 u8 eth_fp_hsi_major;
113                 u8 eth_fp_hsi_minor;
114                 u8 padding[3];
115         } vfdev_info;
116
117         struct vf_pf_resc_request resc_request;
118
119         u64 bulletin_addr;
120         u32 bulletin_size;
121         u32 padding;
122 };
123
124 /* receive side scaling tlv */
125 struct vfpf_vport_update_rss_tlv {
126         struct channel_tlv      tl;
127
128         u8 update_rss_flags;
129         #define VFPF_UPDATE_RSS_CONFIG_FLAG       (1 << 0)
130         #define VFPF_UPDATE_RSS_CAPS_FLAG         (1 << 1)
131         #define VFPF_UPDATE_RSS_IND_TABLE_FLAG    (1 << 2)
132         #define VFPF_UPDATE_RSS_KEY_FLAG          (1 << 3)
133
134         u8 rss_enable;
135         u8 rss_caps;
136         u8 rss_table_size_log; /* The table size is 2 ^ rss_table_size_log */
137         u16 rss_ind_table[T_ETH_INDIRECTION_TABLE_SIZE];
138         u32 rss_key[T_ETH_RSS_KEY_SIZE];
139 };
140
141 struct pfvf_storm_stats {
142         u32 address;
143         u32 len;
144 };
145
146 struct pfvf_stats_info {
147         struct pfvf_storm_stats mstats;
148         struct pfvf_storm_stats pstats;
149         struct pfvf_storm_stats tstats;
150         struct pfvf_storm_stats ustats;
151 };
152
153 /* acquire response tlv - carries the allocated resources */
154 struct pfvf_acquire_resp_tlv {
155         struct pfvf_tlv hdr;
156
157         struct pf_vf_pfdev_info {
158                 u32 chip_num;
159                 u32 mfw_ver;
160
161                 u16 fw_major;
162                 u16 fw_minor;
163                 u16 fw_rev;
164                 u16 fw_eng;
165
166                 u64 capabilities;
167 #define PFVF_ACQUIRE_CAP_DEFAULT_UNTAGGED       (1 << 0)
168 #define PFVF_ACQUIRE_CAP_100G                   (1 << 1) /* If set, 100g PF */
169 /* There are old PF versions where the PF might mistakenly override the sanity
170  * mechanism [version-based] and allow a VF that can't be supported to pass
171  * the acquisition phase.
172  * To overcome this, PFs now indicate that they're past that point and the new
173  * VFs would fail probe on the older PFs that fail to do so.
174  */
175 #ifndef LINUX_REMOVE
176 /* Said bug was in quest/serpens; Can't be certain no official release included
177  * the bug since the fix arrived very late in the programs.
178  */
179 #endif
180 #define PFVF_ACQUIRE_CAP_POST_FW_OVERRIDE       (1 << 2)
181
182         /* PF expects queues to be received with additional qids */
183 #define PFVF_ACQUIRE_CAP_QUEUE_QIDS             (1 << 3)
184
185                 u16 db_size;
186                 u8  indices_per_sb;
187                 u8 os_type;
188
189                 /* These should match the PF's ecore_dev values */
190                 u16 chip_rev;
191                 u8 dev_type;
192
193                 u8 padding;
194
195                 struct pfvf_stats_info stats_info;
196
197                 u8 port_mac[ETH_ALEN];
198
199                 /* It's possible PF had to configure an older fastpath HSI
200                  * [in case VF is newer than PF]. This is communicated back
201                  * to the VF. It can also be used in case of error due to
202                  * non-matching versions to shed light in VF about failure.
203                  */
204                 u8 major_fp_hsi;
205                 u8 minor_fp_hsi;
206         } pfdev_info;
207
208         struct pf_vf_resc {
209                 /* in case of status NO_RESOURCE in message hdr, pf will fill
210                  * this struct with suggested amount of resources for next
211                  * acquire request
212                  */
213                 #define PFVF_MAX_QUEUES_PER_VF         16
214                 #define PFVF_MAX_SBS_PER_VF            16
215                 struct hw_sb_info hw_sbs[PFVF_MAX_SBS_PER_VF];
216                 u8      hw_qid[PFVF_MAX_QUEUES_PER_VF];
217                 u8      cid[PFVF_MAX_QUEUES_PER_VF];
218
219                 u8      num_rxqs;
220                 u8      num_txqs;
221                 u8      num_sbs;
222                 u8      num_mac_filters;
223                 u8      num_vlan_filters;
224                 u8      num_mc_filters;
225                 u8      num_cids;
226                 u8      padding;
227         } resc;
228
229         u32 bulletin_size;
230         u32 padding;
231 };
232
233 struct pfvf_start_queue_resp_tlv {
234         struct pfvf_tlv hdr;
235         u32 offset; /* offset to consumer/producer of queue */
236         u8 padding[4];
237 };
238
239 /* Extended queue information - additional index for reference inside qzone.
240  * If commmunicated between VF/PF, each TLV relating to queues should be
241  * extended by one such [or have a future base TLV that already contains info].
242  */
243 struct vfpf_qid_tlv {
244         struct channel_tlv      tl;
245         u8                      qid;
246         u8                      padding[3];
247 };
248
249 /* Setup Queue */
250 struct vfpf_start_rxq_tlv {
251         struct vfpf_first_tlv   first_tlv;
252
253         /* physical addresses */
254         u64             rxq_addr;
255         u64             deprecated_sge_addr;
256         u64             cqe_pbl_addr;
257
258         u16                     cqe_pbl_size;
259         u16                     hw_sb;
260         u16                     rx_qid;
261         u16                     hc_rate; /* desired interrupts per sec. */
262
263         u16                     bd_max_bytes;
264         u16                     stat_id;
265         u8                      sb_index;
266         u8                      padding[3];
267
268 };
269
270 struct vfpf_start_txq_tlv {
271         struct vfpf_first_tlv   first_tlv;
272
273         /* physical addresses */
274         u64             pbl_addr;
275         u16                     pbl_size;
276         u16                     stat_id;
277         u16                     tx_qid;
278         u16                     hw_sb;
279
280         u32                     flags; /* VFPF_QUEUE_FLG_X flags */
281         u16                     hc_rate; /* desired interrupts per sec. */
282         u8                      sb_index;
283         u8                      padding[3];
284 };
285
286 /* Stop RX Queue */
287 struct vfpf_stop_rxqs_tlv {
288         struct vfpf_first_tlv   first_tlv;
289
290         u16                     rx_qid;
291
292         /* While the API supports multiple Rx-queues on a single TLV
293          * message, in practice older VFs always used it as one [ecore].
294          * And there are PFs [starting with the CHANNEL_TLV_QID] which
295          * would start assuming this is always a '1'. So in practice this
296          * field should be considered deprecated and *Always* set to '1'.
297          */
298         u8                      num_rxqs;
299
300         u8                      cqe_completion;
301         u8                      padding[4];
302 };
303
304 /* Stop TX Queues */
305 struct vfpf_stop_txqs_tlv {
306         struct vfpf_first_tlv   first_tlv;
307
308         u16                     tx_qid;
309
310         /* While the API supports multiple Tx-queues on a single TLV
311          * message, in practice older VFs always used it as one [ecore].
312          * And there are PFs [starting with the CHANNEL_TLV_QID] which
313          * would start assuming this is always a '1'. So in practice this
314          * field should be considered deprecated and *Always* set to '1'.
315          */
316         u8                      num_txqs;
317         u8                      padding[5];
318 };
319
320 struct vfpf_update_rxq_tlv {
321         struct vfpf_first_tlv   first_tlv;
322
323         u64             deprecated_sge_addr[PFVF_MAX_QUEUES_PER_VF];
324
325         u16                     rx_qid;
326         u8                      num_rxqs;
327         u8                      flags;
328         #define VFPF_RXQ_UPD_INIT_SGE_DEPRECATE_FLAG    (1 << 0)
329         #define VFPF_RXQ_UPD_COMPLETE_CQE_FLAG          (1 << 1)
330         #define VFPF_RXQ_UPD_COMPLETE_EVENT_FLAG        (1 << 2)
331
332         u8                      padding[4];
333 };
334
335 /* Set Queue Filters */
336 struct vfpf_q_mac_vlan_filter {
337         u32 flags;
338         #define VFPF_Q_FILTER_DEST_MAC_VALID    0x01
339         #define VFPF_Q_FILTER_VLAN_TAG_VALID    0x02
340         #define VFPF_Q_FILTER_SET_MAC           0x100   /* set/clear */
341
342         u8  mac[ETH_ALEN];
343         u16 vlan_tag;
344
345         u8      padding[4];
346 };
347
348 /* Start a vport */
349 struct vfpf_vport_start_tlv {
350         struct vfpf_first_tlv   first_tlv;
351
352         u64             sb_addr[PFVF_MAX_SBS_PER_VF];
353
354         u32                     tpa_mode;
355         u16                     dep1;
356         u16                     mtu;
357
358         u8                      vport_id;
359         u8                      inner_vlan_removal;
360
361         u8                      only_untagged;
362         u8                      max_buffers_per_cqe;
363
364         u8                      padding[4];
365 };
366
367 /* Extended tlvs - need to add rss, mcast, accept mode tlvs */
368 struct vfpf_vport_update_activate_tlv {
369         struct channel_tlv      tl;
370         u8                      update_rx;
371         u8                      update_tx;
372         u8                      active_rx;
373         u8                      active_tx;
374 };
375
376 struct vfpf_vport_update_tx_switch_tlv {
377         struct channel_tlv      tl;
378         u8                      tx_switching;
379         u8                      padding[3];
380 };
381
382 struct vfpf_vport_update_vlan_strip_tlv {
383         struct channel_tlv      tl;
384         u8                      remove_vlan;
385         u8                      padding[3];
386 };
387
388 struct vfpf_vport_update_mcast_bin_tlv {
389         struct channel_tlv      tl;
390         u8                      padding[4];
391
392         u64             bins[8];
393 };
394
395 struct vfpf_vport_update_accept_param_tlv {
396         struct channel_tlv tl;
397         u8      update_rx_mode;
398         u8      update_tx_mode;
399         u8      rx_accept_filter;
400         u8      tx_accept_filter;
401 };
402
403 struct vfpf_vport_update_accept_any_vlan_tlv {
404         struct channel_tlv tl;
405         u8 update_accept_any_vlan_flg;
406         u8 accept_any_vlan;
407
408         u8 padding[2];
409 };
410
411 struct vfpf_vport_update_sge_tpa_tlv {
412         struct channel_tlv      tl;
413
414         u16                     sge_tpa_flags;
415         #define VFPF_TPA_IPV4_EN_FLAG        (1 << 0)
416         #define VFPF_TPA_IPV6_EN_FLAG        (1 << 1)
417         #define VFPF_TPA_PKT_SPLIT_FLAG      (1 << 2)
418         #define VFPF_TPA_HDR_DATA_SPLIT_FLAG (1 << 3)
419         #define VFPF_TPA_GRO_CONSIST_FLAG    (1 << 4)
420
421         u8                      update_sge_tpa_flags;
422         #define VFPF_UPDATE_SGE_DEPRECATED_FLAG    (1 << 0)
423         #define VFPF_UPDATE_TPA_EN_FLAG    (1 << 1)
424         #define VFPF_UPDATE_TPA_PARAM_FLAG (1 << 2)
425
426         u8                      max_buffers_per_cqe;
427
428         u16                     deprecated_sge_buff_size;
429         u16                     tpa_max_size;
430         u16                     tpa_min_size_to_start;
431         u16                     tpa_min_size_to_cont;
432
433         u8                      tpa_max_aggs_num;
434         u8                      padding[7];
435
436 };
437
438 /* Primary tlv as a header for various extended tlvs for
439  * various functionalities in vport update ramrod.
440  */
441 struct vfpf_vport_update_tlv {
442         struct vfpf_first_tlv first_tlv;
443 };
444
445 struct vfpf_ucast_filter_tlv {
446         struct vfpf_first_tlv   first_tlv;
447
448         u8                      opcode;
449         u8                      type;
450
451         u8                      mac[ETH_ALEN];
452
453         u16                     vlan;
454         u16                     padding[3];
455 };
456
457 /* tunnel update param tlv */
458 struct vfpf_update_tunn_param_tlv {
459         struct vfpf_first_tlv   first_tlv;
460
461         u8                      tun_mode_update_mask;
462         u8                      tunn_mode;
463         u8                      update_tun_cls;
464         u8                      vxlan_clss;
465         u8                      l2gre_clss;
466         u8                      ipgre_clss;
467         u8                      l2geneve_clss;
468         u8                      ipgeneve_clss;
469         u8                      update_geneve_port;
470         u8                      update_vxlan_port;
471         u16                     geneve_port;
472         u16                     vxlan_port;
473         u8                      padding[2];
474 };
475
476 struct pfvf_update_tunn_param_tlv {
477         struct pfvf_tlv hdr;
478
479         u16                     tunn_feature_mask;
480         u8                      vxlan_mode;
481         u8                      l2geneve_mode;
482         u8                      ipgeneve_mode;
483         u8                      l2gre_mode;
484         u8                      ipgre_mode;
485         u8                      vxlan_clss;
486         u8                      l2gre_clss;
487         u8                      ipgre_clss;
488         u8                      l2geneve_clss;
489         u8                      ipgeneve_clss;
490         u16                     vxlan_udp_port;
491         u16                     geneve_udp_port;
492 };
493
494 struct tlv_buffer_size {
495         u8 tlv_buffer[TLV_BUFFER_SIZE];
496 };
497
498 struct vfpf_update_coalesce {
499         struct vfpf_first_tlv first_tlv;
500         u16 rx_coal;
501         u16 tx_coal;
502         u16 qid;
503         u8 padding[2];
504 };
505
506 struct vfpf_read_coal_req_tlv {
507         struct vfpf_first_tlv first_tlv;
508         u16 qid;
509         u8 is_rx;
510         u8 padding[5];
511 };
512
513 struct pfvf_read_coal_resp_tlv {
514         struct pfvf_tlv hdr;
515         u16 coal;
516         u8 padding[6];
517 };
518
519 union vfpf_tlvs {
520         struct vfpf_first_tlv                   first_tlv;
521         struct vfpf_acquire_tlv                 acquire;
522         struct vfpf_start_rxq_tlv               start_rxq;
523         struct vfpf_start_txq_tlv               start_txq;
524         struct vfpf_stop_rxqs_tlv               stop_rxqs;
525         struct vfpf_stop_txqs_tlv               stop_txqs;
526         struct vfpf_update_rxq_tlv              update_rxq;
527         struct vfpf_vport_start_tlv             start_vport;
528         struct vfpf_vport_update_tlv            vport_update;
529         struct vfpf_ucast_filter_tlv            ucast_filter;
530         struct vfpf_update_tunn_param_tlv       tunn_param_update;
531         struct vfpf_update_coalesce             update_coalesce;
532         struct vfpf_read_coal_req_tlv           read_coal_req;
533         struct tlv_buffer_size                  tlv_buf_size;
534 };
535
536 union pfvf_tlvs {
537         struct pfvf_def_resp_tlv                default_resp;
538         struct pfvf_acquire_resp_tlv            acquire_resp;
539         struct tlv_buffer_size                  tlv_buf_size;
540         struct pfvf_start_queue_resp_tlv        queue_start;
541         struct pfvf_update_tunn_param_tlv       tunn_param_resp;
542         struct pfvf_read_coal_resp_tlv          read_coal_resp;
543 };
544
545 /* This is a structure which is allocated in the VF, which the PF may update
546  * when it deems it necessary to do so. The bulletin board is sampled
547  * periodically by the VF. A copy per VF is maintained in the PF (to prevent
548  * loss of data upon multiple updates (or the need for read modify write)).
549  */
550 enum ecore_bulletin_bit {
551         /* Alert the VF that a forced MAC was set by the PF */
552         MAC_ADDR_FORCED = 0,
553
554         /* The VF should not access the vfpf channel */
555         VFPF_CHANNEL_INVALID = 1,
556
557         /* Alert the VF that a forced VLAN was set by the PF */
558         VLAN_ADDR_FORCED = 2,
559
560         /* Indicate that `default_only_untagged' contains actual data */
561         VFPF_BULLETIN_UNTAGGED_DEFAULT = 3,
562         VFPF_BULLETIN_UNTAGGED_DEFAULT_FORCED = 4,
563
564         /* Alert the VF that suggested mac was sent by the PF.
565          * MAC_ADDR will be disabled in case MAC_ADDR_FORCED is set
566          */
567         VFPF_BULLETIN_MAC_ADDR = 5
568 };
569
570 struct ecore_bulletin_content {
571         /* crc of structure to ensure is not in mid-update */
572         u32 crc;
573
574         u32 version;
575
576         /* bitmap indicating which fields hold valid values */
577         u64 valid_bitmap;
578
579         /* used for MAC_ADDR or MAC_ADDR_FORCED */
580         u8 mac[ETH_ALEN];
581
582         /* If valid, 1 => only untagged Rx if no vlan is configured */
583         u8 default_only_untagged;
584         u8 padding;
585
586         /* The following is a 'copy' of ecore_mcp_link_state,
587          * ecore_mcp_link_params and ecore_mcp_link_capabilities. Since it's
588          * possible the structs will increase further along the road we cannot
589          * have it here; Instead we need to have all of its fields.
590          */
591         u8 req_autoneg;
592         u8 req_autoneg_pause;
593         u8 req_forced_rx;
594         u8 req_forced_tx;
595         u8 padding2[4];
596
597         u32 req_adv_speed;
598         u32 req_forced_speed;
599         u32 req_loopback;
600         u32 padding3;
601
602         u8 link_up;
603         u8 full_duplex;
604         u8 autoneg;
605         u8 autoneg_complete;
606         u8 parallel_detection;
607         u8 pfc_enabled;
608         u8 partner_tx_flow_ctrl_en;
609         u8 partner_rx_flow_ctrl_en;
610
611         u8 partner_adv_pause;
612         u8 sfp_tx_fault;
613         u16 vxlan_udp_port;
614         u16 geneve_udp_port;
615         u8 padding4[2];
616
617         u32 speed;
618         u32 partner_adv_speed;
619
620         u32 capability_speed;
621
622         /* Forced vlan */
623         u16 pvid;
624         u16 padding5;
625 };
626
627 struct ecore_bulletin {
628         dma_addr_t phys;
629         struct ecore_bulletin_content *p_virt;
630         u32 size;
631 };
632
633 enum {
634 /*!!!!! Make sure to update STRINGS structure accordingly !!!!!*/
635
636         CHANNEL_TLV_NONE, /* ends tlv sequence */
637         CHANNEL_TLV_ACQUIRE,
638         CHANNEL_TLV_VPORT_START,
639         CHANNEL_TLV_VPORT_UPDATE,
640         CHANNEL_TLV_VPORT_TEARDOWN,
641         CHANNEL_TLV_START_RXQ,
642         CHANNEL_TLV_START_TXQ,
643         CHANNEL_TLV_STOP_RXQS,
644         CHANNEL_TLV_STOP_TXQS,
645         CHANNEL_TLV_UPDATE_RXQ,
646         CHANNEL_TLV_INT_CLEANUP,
647         CHANNEL_TLV_CLOSE,
648         CHANNEL_TLV_RELEASE,
649         CHANNEL_TLV_LIST_END,
650         CHANNEL_TLV_UCAST_FILTER,
651         CHANNEL_TLV_VPORT_UPDATE_ACTIVATE,
652         CHANNEL_TLV_VPORT_UPDATE_TX_SWITCH,
653         CHANNEL_TLV_VPORT_UPDATE_VLAN_STRIP,
654         CHANNEL_TLV_VPORT_UPDATE_MCAST,
655         CHANNEL_TLV_VPORT_UPDATE_ACCEPT_PARAM,
656         CHANNEL_TLV_VPORT_UPDATE_RSS,
657         CHANNEL_TLV_VPORT_UPDATE_ACCEPT_ANY_VLAN,
658         CHANNEL_TLV_VPORT_UPDATE_SGE_TPA,
659         CHANNEL_TLV_UPDATE_TUNN_PARAM,
660         CHANNEL_TLV_COALESCE_UPDATE,
661         CHANNEL_TLV_QID,
662         CHANNEL_TLV_COALESCE_READ,
663         CHANNEL_TLV_MAX,
664
665         /* Required for iterating over vport-update tlvs.
666          * Will break in case non-sequential vport-update tlvs.
667          */
668         CHANNEL_TLV_VPORT_UPDATE_MAX = CHANNEL_TLV_VPORT_UPDATE_SGE_TPA + 1,
669
670 /*!!!!! Make sure to update STRINGS structure accordingly !!!!!*/
671 };
672 extern const char *ecore_channel_tlvs_string[];
673
674 #endif /* __ECORE_VF_PF_IF_H__ */