GNU Linux-libre 4.14.266-gnu1
[releases.git] / drivers / staging / fsl-dpaa2 / ethernet / dpni.h
1 /* Copyright 2013-2016 Freescale Semiconductor Inc.
2  * Copyright 2016 NXP
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  * * Redistributions of source code must retain the above copyright
7  * notice, this list of conditions and the following disclaimer.
8  * * Redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution.
11  * * Neither the name of the above-listed copyright holders nor the
12  * names of any contributors may be used to endorse or promote products
13  * derived from this software without specific prior written permission.
14  *
15  *
16  * ALTERNATIVELY, this software may be distributed under the terms of the
17  * GNU General Public License ("GPL") as published by the Free Software
18  * Foundation, either version 2 of that License or (at your option) any
19  * later version.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 #ifndef __FSL_DPNI_H
34 #define __FSL_DPNI_H
35
36 #include "dpkg.h"
37
38 struct fsl_mc_io;
39
40 /**
41  * Data Path Network Interface API
42  * Contains initialization APIs and runtime control APIs for DPNI
43  */
44
45 /** General DPNI macros */
46
47 /**
48  * Maximum number of traffic classes
49  */
50 #define DPNI_MAX_TC                             8
51 /**
52  * Maximum number of buffer pools per DPNI
53  */
54 #define DPNI_MAX_DPBP                           8
55
56 /**
57  * All traffic classes considered; see dpni_set_queue()
58  */
59 #define DPNI_ALL_TCS                            (u8)(-1)
60 /**
61  * All flows within traffic class considered; see dpni_set_queue()
62  */
63 #define DPNI_ALL_TC_FLOWS                       (u16)(-1)
64 /**
65  * Generate new flow ID; see dpni_set_queue()
66  */
67 #define DPNI_NEW_FLOW_ID                        (u16)(-1)
68
69 /**
70  * Tx traffic is always released to a buffer pool on transmit, there are no
71  * resources allocated to have the frames confirmed back to the source after
72  * transmission.
73  */
74 #define DPNI_OPT_TX_FRM_RELEASE                 0x000001
75 /**
76  * Disables support for MAC address filtering for addresses other than primary
77  * MAC address. This affects both unicast and multicast. Promiscuous mode can
78  * still be enabled/disabled for both unicast and multicast. If promiscuous mode
79  * is disabled, only traffic matching the primary MAC address will be accepted.
80  */
81 #define DPNI_OPT_NO_MAC_FILTER                  0x000002
82 /**
83  * Allocate policers for this DPNI. They can be used to rate-limit traffic per
84  * traffic class (TC) basis.
85  */
86 #define DPNI_OPT_HAS_POLICING                   0x000004
87 /**
88  * Congestion can be managed in several ways, allowing the buffer pool to
89  * deplete on ingress, taildrop on each queue or use congestion groups for sets
90  * of queues. If set, it configures a single congestion groups across all TCs.
91  * If reset, a congestion group is allocated for each TC. Only relevant if the
92  * DPNI has multiple traffic classes.
93  */
94 #define DPNI_OPT_SHARED_CONGESTION              0x000008
95 /**
96  * Enables TCAM for Flow Steering and QoS look-ups. If not specified, all
97  * look-ups are exact match. Note that TCAM is not available on LS1088 and its
98  * variants. Setting this bit on these SoCs will trigger an error.
99  */
100 #define DPNI_OPT_HAS_KEY_MASKING                0x000010
101 /**
102  * Disables the flow steering table.
103  */
104 #define DPNI_OPT_NO_FS                          0x000020
105
106 int dpni_open(struct fsl_mc_io  *mc_io,
107               u32               cmd_flags,
108               int               dpni_id,
109               u16               *token);
110
111 int dpni_close(struct fsl_mc_io *mc_io,
112                u32              cmd_flags,
113                u16              token);
114
115 /**
116  * struct dpni_pools_cfg - Structure representing buffer pools configuration
117  * @num_dpbp: Number of DPBPs
118  * @pools: Array of buffer pools parameters; The number of valid entries
119  *      must match 'num_dpbp' value
120  */
121 struct dpni_pools_cfg {
122         u8              num_dpbp;
123         /**
124          * struct pools - Buffer pools parameters
125          * @dpbp_id: DPBP object ID
126          * @buffer_size: Buffer size
127          * @backup_pool: Backup pool
128          */
129         struct {
130                 int     dpbp_id;
131                 u16     buffer_size;
132                 int     backup_pool;
133         } pools[DPNI_MAX_DPBP];
134 };
135
136 int dpni_set_pools(struct fsl_mc_io             *mc_io,
137                    u32                          cmd_flags,
138                    u16                          token,
139                    const struct dpni_pools_cfg  *cfg);
140
141 int dpni_enable(struct fsl_mc_io        *mc_io,
142                 u32                     cmd_flags,
143                 u16                     token);
144
145 int dpni_disable(struct fsl_mc_io       *mc_io,
146                  u32                    cmd_flags,
147                  u16                    token);
148
149 int dpni_is_enabled(struct fsl_mc_io    *mc_io,
150                     u32                 cmd_flags,
151                     u16                 token,
152                     int                 *en);
153
154 int dpni_reset(struct fsl_mc_io *mc_io,
155                u32              cmd_flags,
156                u16              token);
157
158 /**
159  * DPNI IRQ Index and Events
160  */
161
162 /**
163  * IRQ index
164  */
165 #define DPNI_IRQ_INDEX                          0
166 /**
167  * IRQ event - indicates a change in link state
168  */
169 #define DPNI_IRQ_EVENT_LINK_CHANGED             0x00000001
170
171 int dpni_set_irq_enable(struct fsl_mc_io        *mc_io,
172                         u32                     cmd_flags,
173                         u16                     token,
174                         u8                      irq_index,
175                         u8                      en);
176
177 int dpni_get_irq_enable(struct fsl_mc_io        *mc_io,
178                         u32                     cmd_flags,
179                         u16                     token,
180                         u8                      irq_index,
181                         u8                      *en);
182
183 int dpni_set_irq_mask(struct fsl_mc_io  *mc_io,
184                       u32               cmd_flags,
185                       u16               token,
186                       u8                irq_index,
187                       u32               mask);
188
189 int dpni_get_irq_mask(struct fsl_mc_io  *mc_io,
190                       u32               cmd_flags,
191                       u16               token,
192                       u8                irq_index,
193                       u32               *mask);
194
195 int dpni_get_irq_status(struct fsl_mc_io        *mc_io,
196                         u32                     cmd_flags,
197                         u16                     token,
198                         u8                      irq_index,
199                         u32                     *status);
200
201 int dpni_clear_irq_status(struct fsl_mc_io      *mc_io,
202                           u32                   cmd_flags,
203                           u16                   token,
204                           u8                    irq_index,
205                           u32                   status);
206
207 /**
208  * struct dpni_attr - Structure representing DPNI attributes
209  * @options: Any combination of the following options:
210  *              DPNI_OPT_TX_FRM_RELEASE
211  *              DPNI_OPT_NO_MAC_FILTER
212  *              DPNI_OPT_HAS_POLICING
213  *              DPNI_OPT_SHARED_CONGESTION
214  *              DPNI_OPT_HAS_KEY_MASKING
215  *              DPNI_OPT_NO_FS
216  * @num_queues: Number of Tx and Rx queues used for traffic distribution.
217  * @num_tcs: Number of traffic classes (TCs), reserved for the DPNI.
218  * @mac_filter_entries: Number of entries in the MAC address filtering table.
219  * @vlan_filter_entries: Number of entries in the VLAN address filtering table.
220  * @qos_entries: Number of entries in the QoS classification table.
221  * @fs_entries: Number of entries in the flow steering table.
222  * @qos_key_size: Size, in bytes, of the QoS look-up key. Defining a key larger
223  *              than this when adding QoS entries will result in an error.
224  * @fs_key_size: Size, in bytes, of the flow steering look-up key. Defining a
225  *              key larger than this when composing the hash + FS key will
226  *              result in an error.
227  * @wriop_version: Version of WRIOP HW block. The 3 version values are stored
228  *              on 6, 5, 5 bits respectively.
229  */
230 struct dpni_attr {
231         u32 options;
232         u8 num_queues;
233         u8 num_tcs;
234         u8 mac_filter_entries;
235         u8 vlan_filter_entries;
236         u8 qos_entries;
237         u16 fs_entries;
238         u8 qos_key_size;
239         u8 fs_key_size;
240         u16 wriop_version;
241 };
242
243 int dpni_get_attributes(struct fsl_mc_io        *mc_io,
244                         u32                     cmd_flags,
245                         u16                     token,
246                         struct dpni_attr        *attr);
247
248 /**
249  * DPNI errors
250  */
251
252 /**
253  * Extract out of frame header error
254  */
255 #define DPNI_ERROR_EOFHE        0x00020000
256 /**
257  * Frame length error
258  */
259 #define DPNI_ERROR_FLE          0x00002000
260 /**
261  * Frame physical error
262  */
263 #define DPNI_ERROR_FPE          0x00001000
264 /**
265  * Parsing header error
266  */
267 #define DPNI_ERROR_PHE          0x00000020
268 /**
269  * Parser L3 checksum error
270  */
271 #define DPNI_ERROR_L3CE         0x00000004
272 /**
273  * Parser L3 checksum error
274  */
275 #define DPNI_ERROR_L4CE         0x00000001
276
277 /**
278  * enum dpni_error_action - Defines DPNI behavior for errors
279  * @DPNI_ERROR_ACTION_DISCARD: Discard the frame
280  * @DPNI_ERROR_ACTION_CONTINUE: Continue with the normal flow
281  * @DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE: Send the frame to the error queue
282  */
283 enum dpni_error_action {
284         DPNI_ERROR_ACTION_DISCARD = 0,
285         DPNI_ERROR_ACTION_CONTINUE = 1,
286         DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE = 2
287 };
288
289 /**
290  * struct dpni_error_cfg - Structure representing DPNI errors treatment
291  * @errors: Errors mask; use 'DPNI_ERROR__<X>
292  * @error_action: The desired action for the errors mask
293  * @set_frame_annotation: Set to '1' to mark the errors in frame annotation
294  *              status (FAS); relevant only for the non-discard action
295  */
296 struct dpni_error_cfg {
297         u32                     errors;
298         enum dpni_error_action  error_action;
299         int                     set_frame_annotation;
300 };
301
302 int dpni_set_errors_behavior(struct fsl_mc_io           *mc_io,
303                              u32                        cmd_flags,
304                              u16                        token,
305                              struct dpni_error_cfg      *cfg);
306
307 /**
308  * DPNI buffer layout modification options
309  */
310
311 /**
312  * Select to modify the time-stamp setting
313  */
314 #define DPNI_BUF_LAYOUT_OPT_TIMESTAMP           0x00000001
315 /**
316  * Select to modify the parser-result setting; not applicable for Tx
317  */
318 #define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT       0x00000002
319 /**
320  * Select to modify the frame-status setting
321  */
322 #define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS        0x00000004
323 /**
324  * Select to modify the private-data-size setting
325  */
326 #define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE   0x00000008
327 /**
328  * Select to modify the data-alignment setting
329  */
330 #define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN          0x00000010
331 /**
332  * Select to modify the data-head-room setting
333  */
334 #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM      0x00000020
335 /**
336  * Select to modify the data-tail-room setting
337  */
338 #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM      0x00000040
339
340 /**
341  * struct dpni_buffer_layout - Structure representing DPNI buffer layout
342  * @options: Flags representing the suggested modifications to the buffer
343  *              layout; Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
344  * @pass_timestamp: Pass timestamp value
345  * @pass_parser_result: Pass parser results
346  * @pass_frame_status: Pass frame status
347  * @private_data_size: Size kept for private data (in bytes)
348  * @data_align: Data alignment
349  * @data_head_room: Data head room
350  * @data_tail_room: Data tail room
351  */
352 struct dpni_buffer_layout {
353         u32     options;
354         int     pass_timestamp;
355         int     pass_parser_result;
356         int     pass_frame_status;
357         u16     private_data_size;
358         u16     data_align;
359         u16     data_head_room;
360         u16     data_tail_room;
361 };
362
363 /**
364  * enum dpni_queue_type - Identifies a type of queue targeted by the command
365  * @DPNI_QUEUE_RX: Rx queue
366  * @DPNI_QUEUE_TX: Tx queue
367  * @DPNI_QUEUE_TX_CONFIRM: Tx confirmation queue
368  * @DPNI_QUEUE_RX_ERR: Rx error queue
369  */enum dpni_queue_type {
370         DPNI_QUEUE_RX,
371         DPNI_QUEUE_TX,
372         DPNI_QUEUE_TX_CONFIRM,
373         DPNI_QUEUE_RX_ERR,
374 };
375
376 int dpni_get_buffer_layout(struct fsl_mc_io             *mc_io,
377                            u32                          cmd_flags,
378                            u16                          token,
379                            enum dpni_queue_type         qtype,
380                            struct dpni_buffer_layout    *layout);
381
382 int dpni_set_buffer_layout(struct fsl_mc_io                *mc_io,
383                            u32                             cmd_flags,
384                            u16                             token,
385                            enum dpni_queue_type            qtype,
386                            const struct dpni_buffer_layout *layout);
387
388 /**
389  * enum dpni_offload - Identifies a type of offload targeted by the command
390  * @DPNI_OFF_RX_L3_CSUM: Rx L3 checksum validation
391  * @DPNI_OFF_RX_L4_CSUM: Rx L4 checksum validation
392  * @DPNI_OFF_TX_L3_CSUM: Tx L3 checksum generation
393  * @DPNI_OFF_TX_L4_CSUM: Tx L4 checksum generation
394  */
395 enum dpni_offload {
396         DPNI_OFF_RX_L3_CSUM,
397         DPNI_OFF_RX_L4_CSUM,
398         DPNI_OFF_TX_L3_CSUM,
399         DPNI_OFF_TX_L4_CSUM,
400 };
401
402 int dpni_set_offload(struct fsl_mc_io   *mc_io,
403                      u32                cmd_flags,
404                      u16                token,
405                      enum dpni_offload  type,
406                      u32                config);
407
408 int dpni_get_offload(struct fsl_mc_io   *mc_io,
409                      u32                cmd_flags,
410                      u16                token,
411                      enum dpni_offload  type,
412                      u32                *config);
413
414 int dpni_get_qdid(struct fsl_mc_io      *mc_io,
415                   u32                   cmd_flags,
416                   u16                   token,
417                   enum dpni_queue_type  qtype,
418                   u16                   *qdid);
419
420 int dpni_get_tx_data_offset(struct fsl_mc_io    *mc_io,
421                             u32                 cmd_flags,
422                             u16                 token,
423                             u16                 *data_offset);
424
425 #define DPNI_STATISTICS_CNT             7
426
427 union dpni_statistics {
428         /**
429          * struct page_0 - Page_0 statistics structure
430          * @ingress_all_frames: Ingress frame count
431          * @ingress_all_bytes: Ingress byte count
432          * @ingress_multicast_frames: Ingress multicast frame count
433          * @ingress_multicast_bytes: Ingress multicast byte count
434          * @ingress_broadcast_frames: Ingress broadcast frame count
435          * @ingress_broadcast_bytes: Ingress broadcast byte count
436          */
437         struct {
438                 u64 ingress_all_frames;
439                 u64 ingress_all_bytes;
440                 u64 ingress_multicast_frames;
441                 u64 ingress_multicast_bytes;
442                 u64 ingress_broadcast_frames;
443                 u64 ingress_broadcast_bytes;
444         } page_0;
445         /**
446          * struct page_1 - Page_1 statistics structure
447          * @egress_all_frames: Egress frame count
448          * @egress_all_bytes: Egress byte count
449          * @egress_multicast_frames: Egress multicast frame count
450          * @egress_multicast_bytes: Egress multicast byte count
451          * @egress_broadcast_frames: Egress broadcast frame count
452          * @egress_broadcast_bytes: Egress broadcast byte count
453          */
454         struct {
455                 u64 egress_all_frames;
456                 u64 egress_all_bytes;
457                 u64 egress_multicast_frames;
458                 u64 egress_multicast_bytes;
459                 u64 egress_broadcast_frames;
460                 u64 egress_broadcast_bytes;
461         } page_1;
462         /**
463          * struct page_2 - Page_2 statistics structure
464          * @ingress_filtered_frames: Ingress filtered frame count
465          * @ingress_discarded_frames: Ingress discarded frame count
466          * @ingress_nobuffer_discards: Ingress discarded frame count
467          *                              due to lack of buffers
468          * @egress_discarded_frames: Egress discarded frame count
469          * @egress_confirmed_frames: Egress confirmed frame count
470          */
471         struct {
472                 u64 ingress_filtered_frames;
473                 u64 ingress_discarded_frames;
474                 u64 ingress_nobuffer_discards;
475                 u64 egress_discarded_frames;
476                 u64 egress_confirmed_frames;
477         } page_2;
478         /**
479          * struct raw - raw statistics structure
480          */
481         struct {
482                 u64 counter[DPNI_STATISTICS_CNT];
483         } raw;
484 };
485
486 int dpni_get_statistics(struct fsl_mc_io        *mc_io,
487                         u32                     cmd_flags,
488                         u16                     token,
489                         u8                      page,
490                         union dpni_statistics   *stat);
491
492 /**
493  * Enable auto-negotiation
494  */
495 #define DPNI_LINK_OPT_AUTONEG           0x0000000000000001ULL
496 /**
497  * Enable half-duplex mode
498  */
499 #define DPNI_LINK_OPT_HALF_DUPLEX       0x0000000000000002ULL
500 /**
501  * Enable pause frames
502  */
503 #define DPNI_LINK_OPT_PAUSE             0x0000000000000004ULL
504 /**
505  * Enable a-symmetric pause frames
506  */
507 #define DPNI_LINK_OPT_ASYM_PAUSE        0x0000000000000008ULL
508
509 /**
510  * struct - Structure representing DPNI link configuration
511  * @rate: Rate
512  * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
513  */
514 struct dpni_link_cfg {
515         u32 rate;
516         u64 options;
517 };
518
519 int dpni_set_link_cfg(struct fsl_mc_io                  *mc_io,
520                       u32                               cmd_flags,
521                       u16                               token,
522                       const struct dpni_link_cfg        *cfg);
523
524 /**
525  * struct dpni_link_state - Structure representing DPNI link state
526  * @rate: Rate
527  * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
528  * @up: Link state; '0' for down, '1' for up
529  */
530 struct dpni_link_state {
531         u32     rate;
532         u64     options;
533         int     up;
534 };
535
536 int dpni_get_link_state(struct fsl_mc_io        *mc_io,
537                         u32                     cmd_flags,
538                         u16                     token,
539                         struct dpni_link_state  *state);
540
541 int dpni_set_max_frame_length(struct fsl_mc_io  *mc_io,
542                               u32               cmd_flags,
543                               u16               token,
544                               u16               max_frame_length);
545
546 int dpni_get_max_frame_length(struct fsl_mc_io  *mc_io,
547                               u32               cmd_flags,
548                               u16               token,
549                               u16               *max_frame_length);
550
551 int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io,
552                                u32              cmd_flags,
553                                u16              token,
554                                int              en);
555
556 int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io,
557                                u32              cmd_flags,
558                                u16              token,
559                                int              *en);
560
561 int dpni_set_unicast_promisc(struct fsl_mc_io   *mc_io,
562                              u32                cmd_flags,
563                              u16                token,
564                              int                en);
565
566 int dpni_get_unicast_promisc(struct fsl_mc_io   *mc_io,
567                              u32                cmd_flags,
568                              u16                token,
569                              int                *en);
570
571 int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
572                               u32               cmd_flags,
573                               u16               token,
574                               const u8          mac_addr[6]);
575
576 int dpni_get_primary_mac_addr(struct fsl_mc_io  *mc_io,
577                               u32               cmd_flags,
578                               u16               token,
579                               u8                mac_addr[6]);
580
581 int dpni_get_port_mac_addr(struct fsl_mc_io     *mc_io,
582                            u32                  cm_flags,
583                            u16                  token,
584                            u8                   mac_addr[6]);
585
586 int dpni_add_mac_addr(struct fsl_mc_io  *mc_io,
587                       u32               cmd_flags,
588                       u16               token,
589                       const u8          mac_addr[6]);
590
591 int dpni_remove_mac_addr(struct fsl_mc_io       *mc_io,
592                          u32                    cmd_flags,
593                          u16                    token,
594                          const u8               mac_addr[6]);
595
596 int dpni_clear_mac_filters(struct fsl_mc_io     *mc_io,
597                            u32                  cmd_flags,
598                            u16                  token,
599                            int                  unicast,
600                            int                  multicast);
601
602 /**
603  * enum dpni_dist_mode - DPNI distribution mode
604  * @DPNI_DIST_MODE_NONE: No distribution
605  * @DPNI_DIST_MODE_HASH: Use hash distribution; only relevant if
606  *              the 'DPNI_OPT_DIST_HASH' option was set at DPNI creation
607  * @DPNI_DIST_MODE_FS:  Use explicit flow steering; only relevant if
608  *       the 'DPNI_OPT_DIST_FS' option was set at DPNI creation
609  */
610 enum dpni_dist_mode {
611         DPNI_DIST_MODE_NONE = 0,
612         DPNI_DIST_MODE_HASH = 1,
613         DPNI_DIST_MODE_FS = 2
614 };
615
616 /**
617  * enum dpni_fs_miss_action -   DPNI Flow Steering miss action
618  * @DPNI_FS_MISS_DROP: In case of no-match, drop the frame
619  * @DPNI_FS_MISS_EXPLICIT_FLOWID: In case of no-match, use explicit flow-id
620  * @DPNI_FS_MISS_HASH: In case of no-match, distribute using hash
621  */
622 enum dpni_fs_miss_action {
623         DPNI_FS_MISS_DROP = 0,
624         DPNI_FS_MISS_EXPLICIT_FLOWID = 1,
625         DPNI_FS_MISS_HASH = 2
626 };
627
628 /**
629  * struct dpni_fs_tbl_cfg - Flow Steering table configuration
630  * @miss_action: Miss action selection
631  * @default_flow_id: Used when 'miss_action = DPNI_FS_MISS_EXPLICIT_FLOWID'
632  */
633 struct dpni_fs_tbl_cfg {
634         enum dpni_fs_miss_action        miss_action;
635         u16                             default_flow_id;
636 };
637
638 int dpni_prepare_key_cfg(const struct dpkg_profile_cfg *cfg,
639                          u8 *key_cfg_buf);
640
641 /**
642  * struct dpni_rx_tc_dist_cfg - Rx traffic class distribution configuration
643  * @dist_size: Set the distribution size;
644  *      supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
645  *      112,128,192,224,256,384,448,512,768,896,1024
646  * @dist_mode: Distribution mode
647  * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
648  *              the extractions to be used for the distribution key by calling
649  *              dpni_prepare_key_cfg() relevant only when
650  *              'dist_mode != DPNI_DIST_MODE_NONE', otherwise it can be '0'
651  * @fs_cfg: Flow Steering table configuration; only relevant if
652  *              'dist_mode = DPNI_DIST_MODE_FS'
653  */
654 struct dpni_rx_tc_dist_cfg {
655         u16                     dist_size;
656         enum dpni_dist_mode     dist_mode;
657         u64                     key_cfg_iova;
658         struct dpni_fs_tbl_cfg  fs_cfg;
659 };
660
661 int dpni_set_rx_tc_dist(struct fsl_mc_io                        *mc_io,
662                         u32                                     cmd_flags,
663                         u16                                     token,
664                         u8                                      tc_id,
665                         const struct dpni_rx_tc_dist_cfg        *cfg);
666
667 /**
668  * enum dpni_dest - DPNI destination types
669  * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
670  *              does not generate FQDAN notifications; user is expected to
671  *              dequeue from the queue based on polling or other user-defined
672  *              method
673  * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
674  *              notifications to the specified DPIO; user is expected to dequeue
675  *              from the queue only after notification is received
676  * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
677  *              FQDAN notifications, but is connected to the specified DPCON
678  *              object; user is expected to dequeue from the DPCON channel
679  */
680 enum dpni_dest {
681         DPNI_DEST_NONE = 0,
682         DPNI_DEST_DPIO = 1,
683         DPNI_DEST_DPCON = 2
684 };
685
686 /**
687  * struct dpni_queue - Queue structure
688  * @user_context: User data, presented to the user along with any frames from
689  *              this queue. Not relevant for Tx queues.
690  */
691 struct dpni_queue {
692 /**
693  * struct destination - Destination structure
694  * @id: ID of the destination, only relevant if DEST_TYPE is > 0.
695  *              Identifies either a DPIO or a DPCON object. Not relevant for
696  *              Tx queues.
697  * @type: May be one of the following:
698  *      0 - No destination, queue can be manually queried, but will not
699  *              push traffic or notifications to a DPIO;
700  *      1 - The destination is a DPIO. When traffic becomes available in
701  *              the queue a FQDAN (FQ data available notification) will be
702  *              generated to selected DPIO;
703  *      2 - The destination is a DPCON. The queue is associated with a
704  *              DPCON object for the purpose of scheduling between multiple
705  *              queues. The DPCON may be independently configured to
706  *              generate notifications. Not relevant for Tx queues.
707  * @hold_active: Hold active, maintains a queue scheduled for longer
708  *              in a DPIO during dequeue to reduce spread of traffic.
709  *              Only relevant if queues are not affined to a single DPIO.
710  */
711         struct {
712                 u16 id;
713                 enum dpni_dest type;
714                 char hold_active;
715                 u8 priority;
716         } destination;
717         u64 user_context;
718         struct {
719                 u64 value;
720                 char stash_control;
721         } flc;
722 };
723
724 /**
725  * struct dpni_queue_id - Queue identification, used for enqueue commands
726  *                      or queue control
727  * @fqid: FQID used for enqueueing to and/or configuration of this specific FQ
728  * @qdbin: Queueing bin, used to enqueue using QDID, DQBIN, QPRI. Only relevant
729  *              for Tx queues.
730  */
731 struct dpni_queue_id {
732         u32 fqid;
733         u16 qdbin;
734 };
735
736 /**
737  * Set User Context
738  */
739 #define DPNI_QUEUE_OPT_USER_CTX         0x00000001
740 #define DPNI_QUEUE_OPT_DEST             0x00000002
741 #define DPNI_QUEUE_OPT_FLC              0x00000004
742 #define DPNI_QUEUE_OPT_HOLD_ACTIVE      0x00000008
743
744 int dpni_set_queue(struct fsl_mc_io     *mc_io,
745                    u32                  cmd_flags,
746                    u16                  token,
747                    enum dpni_queue_type qtype,
748                    u8                   tc,
749                    u8                   index,
750                    u8                   options,
751                    const struct dpni_queue *queue);
752
753 int dpni_get_queue(struct fsl_mc_io     *mc_io,
754                    u32                  cmd_flags,
755                    u16                  token,
756                    enum dpni_queue_type qtype,
757                    u8                   tc,
758                    u8                   index,
759                    struct dpni_queue    *queue,
760                    struct dpni_queue_id *qid);
761
762 /**
763  * enum dpni_congestion_unit - DPNI congestion units
764  * @DPNI_CONGESTION_UNIT_BYTES: bytes units
765  * @DPNI_CONGESTION_UNIT_FRAMES: frames units
766  */
767 enum dpni_congestion_unit {
768         DPNI_CONGESTION_UNIT_BYTES = 0,
769         DPNI_CONGESTION_UNIT_FRAMES
770 };
771
772 /**
773  * enum dpni_congestion_point - Structure representing congestion point
774  * @DPNI_CP_QUEUE: Set taildrop per queue, identified by QUEUE_TYPE, TC and
775  *              QUEUE_INDEX
776  * @DPNI_CP_GROUP: Set taildrop per queue group. Depending on options used to
777  *              define the DPNI this can be either per TC (default) or per
778  *              interface (DPNI_OPT_SHARED_CONGESTION set at DPNI create).
779  *              QUEUE_INDEX is ignored if this type is used.
780  */
781 enum dpni_congestion_point {
782         DPNI_CP_QUEUE,
783         DPNI_CP_GROUP,
784 };
785
786 /**
787  * struct dpni_taildrop - Structure representing the taildrop
788  * @enable:     Indicates whether the taildrop is active or not.
789  * @units:      Indicates the unit of THRESHOLD. Queue taildrop only supports
790  *              byte units, this field is ignored and assumed = 0 if
791  *              CONGESTION_POINT is 0.
792  * @threshold:  Threshold value, in units identified by UNITS field. Value 0
793  *              cannot be used as a valid taildrop threshold, THRESHOLD must
794  *              be > 0 if the taildrop is enabled.
795  */
796 struct dpni_taildrop {
797         char enable;
798         enum dpni_congestion_unit units;
799         u32 threshold;
800 };
801
802 int dpni_set_taildrop(struct fsl_mc_io *mc_io,
803                       u32 cmd_flags,
804                       u16 token,
805                       enum dpni_congestion_point cg_point,
806                       enum dpni_queue_type q_type,
807                       u8 tc,
808                       u8 q_index,
809                       struct dpni_taildrop *taildrop);
810
811 int dpni_get_taildrop(struct fsl_mc_io *mc_io,
812                       u32 cmd_flags,
813                       u16 token,
814                       enum dpni_congestion_point cg_point,
815                       enum dpni_queue_type q_type,
816                       u8 tc,
817                       u8 q_index,
818                       struct dpni_taildrop *taildrop);
819
820 /**
821  * struct dpni_rule_cfg - Rule configuration for table lookup
822  * @key_iova: I/O virtual address of the key (must be in DMA-able memory)
823  * @mask_iova: I/O virtual address of the mask (must be in DMA-able memory)
824  * @key_size: key and mask size (in bytes)
825  */
826 struct dpni_rule_cfg {
827         u64     key_iova;
828         u64     mask_iova;
829         u8      key_size;
830 };
831
832 #endif /* __FSL_DPNI_H */