net/bnxt: fix Rx configuration
[dpdk.git] / drivers / net / dpaa2 / mc / fsl_dpni.h
1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
2  *
3  * Copyright 2013-2016 Freescale Semiconductor Inc.
4  * Copyright 2016-2021 NXP
5  *
6  */
7 #ifndef __FSL_DPNI_H
8 #define __FSL_DPNI_H
9
10 #include <fsl_dpkg.h>
11 #include <fsl_dpopr.h>
12
13 struct fsl_mc_io;
14
15 /**
16  * Data Path Network Interface API
17  * Contains initialization APIs and runtime control APIs for DPNI
18  */
19
20 /** General DPNI macros */
21
22 /**
23  * Maximum size of a key
24  */
25 #define DPNI_MAX_KEY_SIZE               56
26
27 /**
28  * Maximum number of traffic classes
29  */
30 #define DPNI_MAX_TC                             8
31 /**
32  * Maximum number of buffer pools per DPNI
33  */
34 #define DPNI_MAX_DPBP                           8
35 /**
36  * Maximum number of storage-profiles per DPNI
37  */
38 #define DPNI_MAX_SP                             2
39 /**
40  * Maximum number of Tx channels per DPNI
41  */
42 #define DPNI_MAX_CHANNELS               16
43
44 /**
45  * All traffic classes considered; see dpni_set_queue()
46  */
47 #define DPNI_ALL_TCS                            (uint8_t)(-1)
48 /**
49  * All flows within traffic class considered; see dpni_set_queue()
50  */
51 #define DPNI_ALL_TC_FLOWS                       (uint16_t)(-1)
52
53 /**
54  * Tx traffic is always released to a buffer pool on transmit, there are no
55  * resources allocated to have the frames confirmed back to the source after
56  * transmission.
57  */
58 #define DPNI_OPT_TX_FRM_RELEASE                 0x000001
59 /**
60  * Disables support for MAC address filtering for addresses other than primary
61  * MAC address. This affects both unicast and multicast. Promiscuous mode can
62  * still be enabled/disabled for both unicast and multicast. If promiscuous mode
63  * is disabled, only traffic matching the primary MAC address will be accepted.
64  */
65 #define DPNI_OPT_NO_MAC_FILTER                  0x000002
66 /**
67  * Allocate policers for this DPNI. They can be used to rate-limit traffic per
68  * traffic class (TC) basis.
69  */
70 #define DPNI_OPT_HAS_POLICING                   0x000004
71 /**
72  * Congestion can be managed in several ways, allowing the buffer pool to
73  * deplete on ingress, taildrop on each queue or use congestion groups for sets
74  * of queues. If set, it configures a single congestion groups across all TCs.
75  * If reset, a congestion group is allocated for each TC. Only relevant if the
76  * DPNI has multiple traffic classes.
77  */
78 #define DPNI_OPT_SHARED_CONGESTION              0x000008
79 /**
80  * Enables TCAM for Flow Steering and QoS look-ups. If not specified, all
81  * look-ups are exact match. Note that TCAM is not available on LS1088 and its
82  * variants. Setting this bit on these SoCs will trigger an error.
83  */
84 #define DPNI_OPT_HAS_KEY_MASKING                0x000010
85 /**
86  * Disables the flow steering table.
87  */
88 #define DPNI_OPT_NO_FS                          0x000020
89
90 /**
91  * Enable the Order Restoration support
92  */
93 #define DPNI_OPT_HAS_OPR                                0x000040
94
95 /**
96  * Order Point Records are shared for the entire TC
97  */
98 #define DPNI_OPT_OPR_PER_TC                             0x000080
99 /**
100  * All Tx traffic classes will use a single sender (ignore num_queues for tx)
101  */
102 #define DPNI_OPT_SINGLE_SENDER                  0x000100
103 /**
104  * Define a custom number of congestion groups
105  */
106 #define DPNI_OPT_CUSTOM_CG                              0x000200
107 /**
108  * Define a custom number of order point records
109  */
110 #define DPNI_OPT_CUSTOM_OPR                             0x000400
111 /**
112  * Hash key is shared between all traffic classes
113  */
114 #define DPNI_OPT_SHARED_HASH_KEY                0x000800
115 /**
116  * Flow steering table is shared between all traffic classes
117  */
118 #define DPNI_OPT_SHARED_FS                              0x001000
119 /**
120  * Software sequence maximum layout size
121  */
122 #define DPNI_SW_SEQUENCE_LAYOUT_SIZE 33
123
124 /**
125  * Build a parameter from dpni channel and trafiic class. This parameter
126  * will be used to configure / query information from dpni objects created
127  * to support multiple channels.
128  */
129 #define DPNI_BUILD_PARAM(channel, tc_id)        (((channel) << 8) | (tc_id))
130
131 int dpni_open(struct fsl_mc_io *mc_io,
132               uint32_t cmd_flags,
133               int dpni_id,
134               uint16_t *token);
135
136 int dpni_close(struct fsl_mc_io *mc_io,
137                uint32_t cmd_flags,
138                uint16_t token);
139
140 /**
141  * struct dpni_cfg - Structure representing DPNI configuration
142  * @options: Any combination of the following options:
143  *              DPNI_OPT_TX_FRM_RELEASE
144  *              DPNI_OPT_NO_MAC_FILTER
145  *              DPNI_OPT_HAS_POLICING
146  *              DPNI_OPT_SHARED_CONGESTION
147  *              DPNI_OPT_HAS_KEY_MASKING
148  *              DPNI_OPT_NO_FS
149  *              DPNI_OPT_SINGLE_SENDER
150  * @fs_entries: Number of entries in the flow steering table.
151  *              This table is used to select the ingress queue for
152  *              ingress traffic, targeting a GPP core or another.
153  *              In addition it can be used to discard traffic that
154  *              matches the set rule. It is either an exact match table
155  *              or a TCAM table, depending on DPNI_OPT_ HAS_KEY_MASKING
156  *              bit in OPTIONS field. This field is ignored if
157  *              DPNI_OPT_NO_FS bit is set in OPTIONS field. Otherwise,
158  *              value 0 defaults to 64. Maximum supported value is 1024.
159  *              Note that the total number of entries is limited on the
160  *              SoC to as low as 512 entries if TCAM is used.
161  * @vlan_filter_entries: Number of entries in the VLAN address filtering
162  *              table. This is an exact match table used to filter
163  *              ingress traffic based on VLAN IDs. Value 0 disables VLAN
164  *              filtering. Maximum supported value is 16.
165  * @mac_filter_entries: Number of entries in the MAC address filtering
166  *              table. This is an exact match table and allows both
167  *              unicast and multicast entries. The primary MAC address
168  *              of the network interface is not part of this table,
169  *              this contains only entries in addition to it. This
170  *              field is ignored if DPNI_OPT_ NO_MAC_FILTER is set in
171  *              OPTIONS field. Otherwise, value 0 defaults to 80.
172  *              Maximum supported value is 80.
173  * @num_queues: Number of Tx and Rx queues used for traffic
174  *              distribution. This is orthogonal to QoS and is only
175  *              used to distribute traffic to multiple GPP cores.
176  *              This configuration affects the number of Tx queues
177  *              (logical FQs, all associated with a single CEETM queue),
178  *              Rx queues and Tx confirmation queues, if applicable.
179  *              Value 0 defaults to one queue. Maximum supported value
180  *              is 8.
181  * @num_tcs: Number of traffic classes (TCs), reserved for the DPNI.
182  *              TCs can have different priority levels for the purpose
183  *              of Tx scheduling (see DPNI_SET_TX_PRIORITIES), different
184  *              BPs (DPNI_ SET_POOLS), policers. There are dedicated QM
185  *              queues for traffic classes (including class queues on
186  *              Tx). Value 0 defaults to one TC. Maximum supported value
187  *              is 16. There are maximum 16 TCs for Tx and 8 TCs for Rx.
188  *              When num_tcs>8 Tx will use this value but Rx will have
189  *              only 8 traffic classes.
190  * @num_rx_tcs: if set to other value than zero represents number
191  *              of TCs used for Rx. Maximum value is 8. If set to zero the
192  *              number of Rx TCs will be initialized with the value provided
193  *              in num_tcs parameter.
194  * @qos_entries: Number of entries in the QoS classification table. This
195  *              table is used to select the TC for ingress traffic. It
196  *              is either an exact match or a TCAM table, depending on
197  *              DPNI_OPT_ HAS_KEY_MASKING bit in OPTIONS field. This
198  *              field is ignored if the DPNI has a single TC. Otherwise,
199  *              a value of 0 defaults to 64. Maximum supported value
200  *              is 64.
201  * @num_channels: Number of egress channels used by this dpni object. If
202  *              set to zero the dpni object will use a single CEETM channel.
203  */
204 struct dpni_cfg {
205         uint32_t options;
206         uint16_t fs_entries;
207         uint8_t  vlan_filter_entries;
208         uint8_t  mac_filter_entries;
209         uint8_t  num_queues;
210         uint8_t  num_tcs;
211         uint8_t  num_rx_tcs;
212         uint8_t  qos_entries;
213         uint8_t  num_cgs;
214         uint16_t num_opr;
215         uint8_t  dist_key_size;
216         uint8_t  num_channels;
217 };
218
219 int dpni_create(struct fsl_mc_io *mc_io,
220                 uint16_t dprc_token,
221                 uint32_t cmd_flags,
222                 const struct dpni_cfg *cfg,
223                 uint32_t *obj_id);
224
225 int dpni_destroy(struct fsl_mc_io *mc_io,
226                  uint16_t dprc_token,
227                  uint32_t cmd_flags,
228                  uint32_t object_id);
229
230 /**
231  * struct dpni_pools_cfg - Structure representing buffer pools configuration
232  * @num_dpbp:   Number of DPBPs
233  * @pool_options: Buffer assignment options
234  *                This field is a combination of DPNI_POOL_ASSOC_flags
235  * @pools:      Array of buffer pools parameters; The number of valid entries
236  *              must match 'num_dpbp' value
237  * @pools.dpbp_id:     DPBP object ID
238  * @pools.priority:    Priority mask that indicates TC's used with this buffer.
239  *                     I set to 0x00 MC will assume value 0xff.
240  * @pools.buffer_size: Buffer size
241  * @pools.backup_pool: Backup pool
242  */
243
244 #define DPNI_POOL_ASSOC_QPRI    0
245 #define DPNI_POOL_ASSOC_QDBIN   1
246
247 struct dpni_pools_cfg {
248         uint8_t num_dpbp;
249         uint8_t pool_options;
250         struct {
251                 int             dpbp_id;
252                 uint8_t         priority_mask;
253                 uint16_t        buffer_size;
254                 int             backup_pool;
255         } pools[DPNI_MAX_DPBP];
256 };
257
258 int dpni_set_pools(struct fsl_mc_io *mc_io,
259                    uint32_t cmd_flags,
260                    uint16_t token,
261                    const struct dpni_pools_cfg *cfg);
262
263 int dpni_enable(struct fsl_mc_io *mc_io,
264                 uint32_t cmd_flags,
265                 uint16_t token);
266
267 int dpni_disable(struct fsl_mc_io *mc_io,
268                  uint32_t cmd_flags,
269                  uint16_t token);
270
271 int dpni_is_enabled(struct fsl_mc_io *mc_io,
272                     uint32_t cmd_flags,
273                     uint16_t token,
274                     int *en);
275
276 int dpni_reset(struct fsl_mc_io *mc_io,
277                uint32_t cmd_flags,
278                uint16_t token);
279
280 /**
281  * DPNI IRQ Index and Events
282  */
283
284 /**
285  * IRQ index
286  */
287 #define DPNI_IRQ_INDEX                          0
288 /**
289  * IRQ event - indicates a change in link state
290  */
291 #define DPNI_IRQ_EVENT_LINK_CHANGED             0x00000001
292
293 int dpni_set_irq_enable(struct fsl_mc_io *mc_io,
294                         uint32_t cmd_flags,
295                         uint16_t token,
296                         uint8_t irq_index,
297                         uint8_t en);
298
299 int dpni_get_irq_enable(struct fsl_mc_io *mc_io,
300                         uint32_t cmd_flags,
301                         uint16_t token,
302                         uint8_t irq_index,
303                         uint8_t *en);
304
305 int dpni_set_irq_mask(struct fsl_mc_io *mc_io,
306                       uint32_t cmd_flags,
307                       uint16_t token,
308                       uint8_t irq_index,
309                       uint32_t mask);
310
311 int dpni_get_irq_mask(struct fsl_mc_io *mc_io,
312                       uint32_t cmd_flags,
313                       uint16_t token,
314                       uint8_t irq_index,
315                       uint32_t *mask);
316
317 int dpni_get_irq_status(struct fsl_mc_io *mc_io,
318                         uint32_t cmd_flags,
319                         uint16_t token,
320                         uint8_t irq_index,
321                         uint32_t *status);
322
323 int dpni_clear_irq_status(struct fsl_mc_io *mc_io,
324                           uint32_t cmd_flags,
325                           uint16_t token,
326                           uint8_t irq_index,
327                           uint32_t status);
328
329 /**
330  * struct dpni_attr - Structure representing DPNI attributes
331  * @options: Any combination of the following options:
332  *              DPNI_OPT_TX_FRM_RELEASE
333  *              DPNI_OPT_NO_MAC_FILTER
334  *              DPNI_OPT_HAS_POLICING
335  *              DPNI_OPT_SHARED_CONGESTION
336  *              DPNI_OPT_HAS_KEY_MASKING
337  *              DPNI_OPT_NO_FS
338  * @num_queues: Number of Tx and Rx queues used for traffic distribution.
339  * @num_rx_tcs: Number of RX traffic classes (TCs), reserved for the DPNI.
340  * @num_tx_tcs: Number of TX traffic classes (TCs), reserved for the DPNI.
341  * @mac_filter_entries: Number of entries in the MAC address filtering
342  *              table.
343  * @vlan_filter_entries: Number of entries in the VLAN address filtering
344  *              table.
345  * @qos_entries: Number of entries in the QoS classification table.
346  * @fs_entries: Number of entries in the flow steering table.
347  * @qos_key_size: Size, in bytes, of the QoS look-up key. Defining a key larger
348  *                      than this when adding QoS entries will result
349  *                      in an error.
350  * @fs_key_size: Size, in bytes, of the flow steering look-up key. Defining a
351  *                      key larger than this when composing the hash + FS key
352  *                      will result in an error.
353  * @wriop_version: Version of WRIOP HW block.
354  *                      The 3 version values are stored on 6, 5, 5 bits
355  *                      respectively.
356  *                      Values returned:
357  *                      - 0x400 - WRIOP version 1.0.0, used on LS2080 and
358  *                      variants,
359  *                      - 0x421 - WRIOP version 1.1.1, used on LS2088 and
360  *                      variants,
361  *                      - 0x422 - WRIOP version 1.1.2, used on LS1088 and
362  *                      variants.
363  *                      - 0xC00 - WRIOP version 3.0.0, used on LX2160 and
364  *                      variants.
365  */
366 struct dpni_attr {
367         uint32_t options;
368         uint8_t  num_queues;
369         uint8_t  num_rx_tcs;
370         uint8_t  num_tx_tcs;
371         uint8_t  mac_filter_entries;
372         uint8_t  vlan_filter_entries;
373         uint8_t  qos_entries;
374         uint16_t fs_entries;
375         uint16_t num_opr;
376         uint8_t  qos_key_size;
377         uint8_t  fs_key_size;
378         uint16_t wriop_version;
379         uint8_t  num_cgs;
380         uint8_t  num_channels;
381 };
382
383 int dpni_get_attributes(struct fsl_mc_io *mc_io,
384                         uint32_t cmd_flags,
385                         uint16_t token,
386                         struct dpni_attr *attr);
387
388 /**
389  * DPNI errors
390  */
391
392 /**
393  * Discard error. When set all discarded frames in wriop will be enqueued to
394  * error queue. To be used in dpni_set_errors_behavior() only if error_action
395  * parameter is set to DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE.
396  */
397 #define DPNI_ERROR_DISC         0x80000000
398
399 /**
400  * Extract out of frame header error
401  */
402 #define DPNI_ERROR_MS                   0x40000000
403 #define DPNI_ERROR_PTP                  0x08000000
404 /* Ethernet multicast frame */
405 #define DPNI_ERROR_MC                   0x04000000
406 /* Ethernet broadcast frame */
407 #define DPNI_ERROR_BC                   0x02000000
408 #define DPNI_ERROR_KSE                  0x00040000
409 #define DPNI_ERROR_EOFHE                0x00020000
410 #define DPNI_ERROR_MNLE                 0x00010000
411 #define DPNI_ERROR_TIDE                 0x00008000
412 #define DPNI_ERROR_PIEE                 0x00004000
413 /**
414  * Frame length error
415  */
416 #define DPNI_ERROR_FLE                  0x00002000
417 /**
418  * Frame physical error
419  */
420 #define DPNI_ERROR_FPE                  0x00001000
421 #define DPNI_ERROR_PTE                  0x00000080
422 #define DPNI_ERROR_ISP                  0x00000040
423 /**
424  * Parsing header error
425  */
426 #define DPNI_ERROR_PHE                  0x00000020
427
428 #define DPNI_ERROR_BLE                  0x00000010
429 /**
430  * Parser L3 checksum error
431  */
432 #define DPNI_ERROR_L3CV                 0x00000008
433
434 #define DPNI_ERROR_L3CE                 0x00000004
435 /**
436  * Parser L4 checksum error
437  */
438 #define DPNI_ERROR_L4CV                 0x00000002
439
440 #define DPNI_ERROR_L4CE                 0x00000001
441 /**
442  * enum dpni_error_action - Defines DPNI behavior for errors
443  * @DPNI_ERROR_ACTION_DISCARD: Discard the frame
444  * @DPNI_ERROR_ACTION_CONTINUE: Continue with the normal flow
445  * @DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE: Send the frame to the error queue
446  */
447 enum dpni_error_action {
448         DPNI_ERROR_ACTION_DISCARD = 0,
449         DPNI_ERROR_ACTION_CONTINUE = 1,
450         DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE = 2
451 };
452
453 /**
454  * struct dpni_error_cfg - Structure representing DPNI errors treatment
455  * @errors:                     Errors mask; use 'DPNI_ERROR__<X>
456  * @error_action:               The desired action for the errors mask
457  * @set_frame_annotation:       Set to '1' to mark the errors in frame
458  *                              annotation status (FAS); relevant only
459  *                              for the non-discard action
460  */
461 struct dpni_error_cfg {
462         uint32_t errors;
463         enum dpni_error_action error_action;
464         int set_frame_annotation;
465 };
466
467 int dpni_set_errors_behavior(struct fsl_mc_io *mc_io,
468                              uint32_t cmd_flags,
469                              uint16_t token,
470                              struct dpni_error_cfg *cfg);
471
472 /**
473  * DPNI buffer layout modification options
474  */
475
476 /**
477  * Select to modify the time-stamp setting
478  */
479 #define DPNI_BUF_LAYOUT_OPT_TIMESTAMP           0x00000001
480 /**
481  * Select to modify the parser-result setting; not applicable for Tx
482  */
483 #define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT       0x00000002
484 /**
485  * Select to modify the frame-status setting
486  */
487 #define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS        0x00000004
488 /**
489  * Select to modify the private-data-size setting
490  */
491 #define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE   0x00000008
492 /**
493  * Select to modify the data-alignment setting
494  */
495 #define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN          0x00000010
496 /**
497  * Select to modify the data-head-room setting
498  */
499 #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM      0x00000020
500 /**
501  * Select to modify the data-tail-room setting
502  */
503 #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM      0x00000040
504 /**
505  * Select to modify the sw-opaque value setting
506  */
507 #define DPNI_BUF_LAYOUT_OPT_SW_OPAQUE           0x00000080
508 /**
509  * Select to disable Scatter Gather and use single buffer
510  */
511 #define DPNI_BUF_LAYOUT_OPT_NO_SG               0x00000100
512
513 /**
514  * struct dpni_buffer_layout - Structure representing DPNI buffer layout
515  * @options:            Flags representing the suggested modifications to the
516  *                      buffer layout;
517  *                      Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
518  * @pass_timestamp:     Pass timestamp value
519  * @pass_parser_result: Pass parser results
520  * @pass_frame_status:  Pass frame status
521  * @private_data_size:  Size kept for private data (in bytes)
522  * @data_align:         Data alignment
523  * @data_head_room:     Data head room
524  * @data_tail_room:     Data tail room
525  */
526 struct dpni_buffer_layout {
527         uint32_t options;
528         int pass_timestamp;
529         int pass_parser_result;
530         int pass_frame_status;
531         int pass_sw_opaque;
532         uint16_t private_data_size;
533         uint16_t data_align;
534         uint16_t data_head_room;
535         uint16_t data_tail_room;
536 };
537
538 /**
539  * enum dpni_queue_type - Identifies a type of queue targeted by the command
540  * @DPNI_QUEUE_RX: Rx queue
541  * @DPNI_QUEUE_TX: Tx queue
542  * @DPNI_QUEUE_TX_CONFIRM: Tx confirmation queue
543  * @DPNI_QUEUE_RX_ERR: Rx error queue
544  */
545 enum dpni_queue_type {
546         DPNI_QUEUE_RX,
547         DPNI_QUEUE_TX,
548         DPNI_QUEUE_TX_CONFIRM,
549         DPNI_QUEUE_RX_ERR,
550 };
551
552 int dpni_get_buffer_layout(struct fsl_mc_io *mc_io,
553                            uint32_t cmd_flags,
554                            uint16_t token,
555                            enum dpni_queue_type qtype,
556                            struct dpni_buffer_layout *layout);
557
558 int dpni_set_buffer_layout(struct fsl_mc_io *mc_io,
559                            uint32_t cmd_flags,
560                            uint16_t token,
561                            enum dpni_queue_type qtype,
562                            const struct dpni_buffer_layout *layout);
563
564 /**
565  * enum dpni_offload - Identifies a type of offload targeted by the command
566  * @DPNI_OFF_RX_L3_CSUM: Rx L3 checksum validation
567  * @DPNI_OFF_RX_L4_CSUM: Rx L4 checksum validation
568  * @DPNI_OFF_TX_L3_CSUM: Tx L3 checksum generation
569  * @DPNI_OFF_TX_L4_CSUM: Tx L4 checksum generation
570  * @DPNI_OPT_FLCTYPE_HASH: flow context will be generated by WRIOP for AIOP or
571  *                         for CPU
572  */
573 enum dpni_offload {
574         DPNI_OFF_RX_L3_CSUM,
575         DPNI_OFF_RX_L4_CSUM,
576         DPNI_OFF_TX_L3_CSUM,
577         DPNI_OFF_TX_L4_CSUM,
578         DPNI_FLCTYPE_HASH,
579 };
580
581 int dpni_set_offload(struct fsl_mc_io *mc_io,
582                      uint32_t cmd_flags,
583                      uint16_t token,
584                      enum dpni_offload type,
585                      uint32_t config);
586
587 int dpni_get_offload(struct fsl_mc_io *mc_io,
588                      uint32_t cmd_flags,
589                      uint16_t token,
590                      enum dpni_offload type,
591                      uint32_t *config);
592
593 int dpni_get_qdid(struct fsl_mc_io *mc_io,
594                   uint32_t cmd_flags,
595                   uint16_t token,
596                   enum dpni_queue_type qtype,
597                   uint16_t *qdid);
598
599 int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io,
600                             uint32_t cmd_flags,
601                             uint16_t token,
602                             uint16_t *data_offset);
603
604 #define DPNI_STATISTICS_CNT             7
605
606 /**
607  * union dpni_statistics - Union describing the DPNI statistics
608  * @page_0: Page_0 statistics structure
609  * @page_0.ingress_all_frames: Ingress frame count
610  * @page_0.ingress_all_bytes: Ingress byte count
611  * @page_0.ingress_multicast_frames: Ingress multicast frame count
612  * @page_0.ingress_multicast_bytes: Ingress multicast byte count
613  * @page_0.ingress_broadcast_frames: Ingress broadcast frame count
614  * @page_0.ingress_broadcast_bytes: Ingress broadcast byte count
615  * @page_1: Page_1 statistics structure
616  * @page_1.egress_all_frames: Egress frame count
617  * @page_1.egress_all_bytes: Egress byte count
618  * @page_1.egress_multicast_frames: Egress multicast frame count
619  * @page_1.egress_multicast_bytes: Egress multicast byte count
620  * @page_1.egress_broadcast_frames: Egress broadcast frame count
621  * @page_1.egress_broadcast_bytes: Egress broadcast byte count
622  * @page_2: Page_2 statistics structure
623  * @page_2.ingress_filtered_frames: Ingress filtered frame count
624  * @page_2.ingress_discarded_frames: Ingress discarded frame count
625  * @page_2.ingress_nobuffer_discards: Ingress discarded frame count due to
626  *      lack of buffers
627  * @page_2.egress_discarded_frames: Egress discarded frame count
628  * @page_2.egress_confirmed_frames: Egress confirmed frame count
629  * @page_3: Page_3 statistics structure with values for the selected TC
630  * @page_3.ceetm_dequeue_bytes: Cumulative count of the number of bytes dequeued
631  * @page_3.ceetm_dequeue_frames: Cumulative count of the number of frames
632  *      dequeued
633  * @page_3.ceetm_reject_bytes: Cumulative count of the number of bytes in all
634  *      frames whose enqueue was rejected
635  * @page_3.ceetm_reject_frames: Cumulative count of all frame enqueues rejected
636  * @page_4: congestion point drops for selected TC
637  * @page_4.cgr_reject_frames: number of rejected frames due to congestion point
638  * @page_4.cgr_reject_bytes: number of rejected bytes due to congestion point
639  * @page_5: policer statistics per TC
640  * @page_5.policer_cnt_red: NUmber of red colored frames
641  * @page_5.policer_cnt_yellow: number of yellow colored frames
642  * @page_5.policer_cnt_green: number of green colored frames
643  * @page_5.policer_cnt_re_red: number of recolored red frames
644  * @page_5.policer_cnt_re_yellow: number of recolored yellow frames
645  * @page_6.tx_pending_frames_cnt: total number of frames pending in Tx queues
646  * @raw: raw statistics structure, used to index counters
647  */
648 union dpni_statistics {
649         struct {
650                 uint64_t ingress_all_frames;
651                 uint64_t ingress_all_bytes;
652                 uint64_t ingress_multicast_frames;
653                 uint64_t ingress_multicast_bytes;
654                 uint64_t ingress_broadcast_frames;
655                 uint64_t ingress_broadcast_bytes;
656         } page_0;
657         struct {
658                 uint64_t egress_all_frames;
659                 uint64_t egress_all_bytes;
660                 uint64_t egress_multicast_frames;
661                 uint64_t egress_multicast_bytes;
662                 uint64_t egress_broadcast_frames;
663                 uint64_t egress_broadcast_bytes;
664         } page_1;
665         struct {
666                 uint64_t ingress_filtered_frames;
667                 uint64_t ingress_discarded_frames;
668                 uint64_t ingress_nobuffer_discards;
669                 uint64_t egress_discarded_frames;
670                 uint64_t egress_confirmed_frames;
671         } page_2;
672         struct {
673                 uint64_t ceetm_dequeue_bytes;
674                 uint64_t ceetm_dequeue_frames;
675                 uint64_t ceetm_reject_bytes;
676                 uint64_t ceetm_reject_frames;
677         } page_3;
678         struct {
679                 uint64_t cgr_reject_frames;
680                 uint64_t cgr_reject_bytes;
681         } page_4;
682         struct {
683                 uint64_t policer_cnt_red;
684                 uint64_t policer_cnt_yellow;
685                 uint64_t policer_cnt_green;
686                 uint64_t policer_cnt_re_red;
687                 uint64_t policer_cnt_re_yellow;
688         } page_5;
689         struct {
690                 uint64_t tx_pending_frames_cnt;
691         } page_6;
692         struct {
693                 uint64_t counter[DPNI_STATISTICS_CNT];
694         } raw;
695 };
696
697 /**
698  * Enable auto-negotiation
699  */
700 #define DPNI_LINK_OPT_AUTONEG           0x0000000000000001ULL
701 /**
702  * Enable half-duplex mode
703  */
704 #define DPNI_LINK_OPT_HALF_DUPLEX       0x0000000000000002ULL
705 /**
706  * Enable pause frames
707  */
708 #define DPNI_LINK_OPT_PAUSE             0x0000000000000004ULL
709 /**
710  * Enable a-symmetric pause frames
711  */
712 #define DPNI_LINK_OPT_ASYM_PAUSE        0x0000000000000008ULL
713 /**
714  * Enable priority flow control pause frames
715  */
716 #define DPNI_LINK_OPT_PFC_PAUSE 0x0000000000000010ULL
717
718 /**
719  * Advertise 10MB full duplex
720  */
721 #define DPNI_ADVERTISED_10BASET_FULL           0x0000000000000001ULL
722 /**
723  * Advertise 100MB full duplex
724  */
725 #define DPNI_ADVERTISED_100BASET_FULL          0x0000000000000002ULL
726 /**
727  * Advertise 1GB full duplex
728  */
729 #define DPNI_ADVERTISED_1000BASET_FULL         0x0000000000000004ULL
730 /**
731  * Advertise auto-negotiation enable
732  */
733 #define DPNI_ADVERTISED_AUTONEG                0x0000000000000008ULL
734 /**
735  * Advertise 10GB full duplex
736  */
737 #define DPNI_ADVERTISED_10000BASET_FULL        0x0000000000000010ULL
738 /**
739  * Advertise 2.5GB full duplex
740  */
741 #define DPNI_ADVERTISED_2500BASEX_FULL         0x0000000000000020ULL
742 /**
743  * Advertise 5GB full duplex
744  */
745 #define DPNI_ADVERTISED_5000BASET_FULL         0x0000000000000040ULL
746
747
748 /**
749  * struct - Structure representing DPNI link configuration
750  * @rate: Rate
751  * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
752  * @advertising: Speeds that are advertised for autoneg (bitmap)
753  */
754 struct dpni_link_cfg {
755         uint32_t rate;
756         uint64_t options;
757         uint64_t advertising;
758 };
759
760 int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
761                       uint32_t cmd_flags,
762                       uint16_t token,
763                       const struct dpni_link_cfg *cfg);
764
765 int dpni_get_link_cfg(struct fsl_mc_io *mc_io,
766                       uint32_t cmd_flags,
767                       uint16_t token,
768                       struct dpni_link_cfg *cfg);
769
770 /**
771  * struct dpni_link_state - Structure representing DPNI link state
772  * @rate:       Rate
773  * @options:    Mask of available options; use 'DPNI_LINK_OPT_<X>' values
774  * @up:         Link state; '0' for down, '1' for up
775  * @state_valid: Ignore/Update the state of the link
776  * @supported: Speeds capability of the phy (bitmap)
777  * @advertising: Speeds that are advertised for autoneg (bitmap)
778  */
779 struct dpni_link_state {
780         uint32_t rate;
781         uint64_t options;
782         int up;
783         int state_valid;
784         uint64_t supported;
785         uint64_t advertising;
786 };
787
788 int dpni_get_link_state(struct fsl_mc_io *mc_io,
789                         uint32_t cmd_flags,
790                         uint16_t token,
791                         struct dpni_link_state *state);
792
793 /**
794  * struct dpni_tx_shaping - Structure representing DPNI tx shaping configuration
795  * @rate_limit:         Rate in Mbits/s
796  * @max_burst_size:     Burst size in bytes (up to 64KB)
797  */
798 struct dpni_tx_shaping_cfg {
799         uint32_t rate_limit;
800         uint16_t max_burst_size;
801 };
802
803 /**
804  * Build the parameter for dpni_set_tx_shaping() call
805  * @oal:                Overhead accounting length. 11bit value added to the size of
806  *                      each frame. Used only for LNI shaping. If set to zero, will use default
807  *                      value of 24. Ignored if shaping_lni is set to zero.
808  * @shaping_lni:        1 for LNI shaping (configure whole throughput of the dpni object)
809  *                      0 for channel shaping (configure shaping for individual channels)
810  *                      Set to one only if dpni is connected to a dpmac object.
811  * @channel_id:         Channel to be configured. Ignored shaping_lni is set to 1
812  * @coupled:            Committed and excess rates are coupled
813  */
814 #define DPNI_TX_SHAPING_PARAM(oal, shaping_lni, channel_id, coupled)    ( \
815                 ((uint32_t)(((oal) & 0x7ff) << 16)) | \
816                 ((uint32_t)((channel_id) & 0xff) << 8) | \
817                 ((uint32_t)(!!shaping_lni) << 1) | \
818                 ((uint32_t)!!coupled))
819
820 int dpni_set_tx_shaping(struct fsl_mc_io *mc_io,
821                         uint32_t cmd_flags,
822                         uint16_t token,
823                         const struct dpni_tx_shaping_cfg *tx_cr_shaper,
824                         const struct dpni_tx_shaping_cfg *tx_er_shaper,
825                         uint32_t param);
826
827 int dpni_set_max_frame_length(struct fsl_mc_io *mc_io,
828                               uint32_t cmd_flags,
829                               uint16_t token,
830                               uint16_t max_frame_length);
831
832 int dpni_get_max_frame_length(struct fsl_mc_io *mc_io,
833                               uint32_t cmd_flags,
834                               uint16_t token,
835                               uint16_t *max_frame_length);
836
837 int dpni_set_mtu(struct fsl_mc_io *mc_io,
838                  uint32_t cmd_flags,
839                  uint16_t token,
840                  uint16_t mtu);
841
842 int dpni_get_mtu(struct fsl_mc_io *mc_io,
843                  uint32_t cmd_flags,
844                  uint16_t token,
845                  uint16_t *mtu);
846
847 int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io,
848                                uint32_t cmd_flags,
849                                uint16_t token,
850                                int en);
851
852 int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io,
853                                uint32_t cmd_flags,
854                                uint16_t token,
855                                int *en);
856
857 int dpni_set_unicast_promisc(struct fsl_mc_io *mc_io,
858                              uint32_t cmd_flags,
859                              uint16_t token,
860                              int en);
861
862 int dpni_get_unicast_promisc(struct fsl_mc_io *mc_io,
863                              uint32_t cmd_flags,
864                              uint16_t token,
865                              int *en);
866
867 int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
868                               uint32_t cmd_flags,
869                               uint16_t token,
870                               const uint8_t mac_addr[6]);
871
872 int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io,
873                               uint32_t cmd_flags,
874                               uint16_t token,
875                               uint8_t mac_addr[6]);
876
877 /**
878  * Set mac addr queue action
879  */
880 #define DPNI_MAC_SET_QUEUE_ACTION 1
881
882 int dpni_add_mac_addr(struct fsl_mc_io *mc_io,
883                       uint32_t cmd_flags,
884                       uint16_t token,
885                       const uint8_t mac_addr[6],
886                           uint8_t flags,
887                           uint8_t tc_id,
888                           uint8_t flow_id);
889
890 int dpni_remove_mac_addr(struct fsl_mc_io *mc_io,
891                          uint32_t cmd_flags,
892                          uint16_t token,
893                          const uint8_t mac_addr[6]);
894
895 int dpni_clear_mac_filters(struct fsl_mc_io *mc_io,
896                            uint32_t cmd_flags,
897                            uint16_t token,
898                            int unicast,
899                            int multicast);
900
901 int dpni_get_port_mac_addr(struct fsl_mc_io *mc_io,
902                            uint32_t cmd_flags,
903                            uint16_t token,
904                            uint8_t mac_addr[6]);
905
906 int dpni_enable_vlan_filter(struct fsl_mc_io *mc_io,
907                             uint32_t cmd_flags,
908                             uint16_t token,
909                             int en);
910
911 /**
912  * Set vlan filter queue action
913  */
914 #define DPNI_VLAN_SET_QUEUE_ACTION 1
915
916 int dpni_add_vlan_id(struct fsl_mc_io *mc_io,
917                      uint32_t cmd_flags,
918                      uint16_t token,
919                      uint16_t vlan_id,
920                          uint8_t flags,
921                          uint8_t tc_id,
922                          uint8_t flow_id);
923
924 int dpni_remove_vlan_id(struct fsl_mc_io *mc_io,
925                         uint32_t cmd_flags,
926                         uint16_t token,
927                         uint16_t vlan_id);
928
929 int dpni_clear_vlan_filters(struct fsl_mc_io *mc_io,
930                             uint32_t cmd_flags,
931                             uint16_t token);
932
933 /**
934  * enum dpni_tx_schedule_mode - DPNI Tx scheduling mode
935  * @DPNI_TX_SCHED_STRICT_PRIORITY: strict priority
936  * @DPNI_TX_SCHED_WEIGHTED_A: weighted based scheduling in group A
937  * @DPNI_TX_SCHED_WEIGHTED_B: weighted based scheduling in group B
938  */
939 enum dpni_tx_schedule_mode {
940         DPNI_TX_SCHED_STRICT_PRIORITY = 0,
941         DPNI_TX_SCHED_WEIGHTED_A,
942         DPNI_TX_SCHED_WEIGHTED_B,
943 };
944
945 /**
946  * struct dpni_tx_schedule_cfg - Structure representing Tx scheduling conf
947  * @mode:               Scheduling mode
948  * @delta_bandwidth:    Bandwidth represented in weights from 100 to 10000;
949  *      not applicable for 'strict-priority' mode;
950  */
951 struct dpni_tx_schedule_cfg {
952         enum dpni_tx_schedule_mode      mode;
953         uint16_t                        delta_bandwidth;
954 };
955
956 /**
957  * struct dpni_tx_priorities_cfg - Structure representing transmission
958  *                                      priorities for DPNI TCs
959  * @channel_idx: channel to perform the configuration
960  * @tc_sched:   An array of traffic-classes
961  * @prio_group_A: Priority of group A
962  * @prio_group_B: Priority of group B
963  * @separate_groups: Treat A and B groups as separate
964  */
965 struct dpni_tx_priorities_cfg {
966         uint8_t channel_idx;
967         struct dpni_tx_schedule_cfg tc_sched[DPNI_MAX_TC];
968         uint32_t prio_group_A;
969         uint32_t prio_group_B;
970         uint8_t separate_groups;
971 };
972
973 int dpni_set_tx_priorities(struct fsl_mc_io                     *mc_io,
974                            uint32_t                             cmd_flags,
975                            uint16_t                             token,
976                            const struct dpni_tx_priorities_cfg  *cfg);
977
978 /**
979  * enum dpni_dist_mode - DPNI distribution mode
980  * @DPNI_DIST_MODE_NONE: No distribution
981  * @DPNI_DIST_MODE_HASH: Use hash distribution; only relevant if
982  *              the 'DPNI_OPT_DIST_HASH' option was set at DPNI creation
983  * @DPNI_DIST_MODE_FS:  Use explicit flow steering; only relevant if
984  *       the 'DPNI_OPT_DIST_FS' option was set at DPNI creation
985  */
986 enum dpni_dist_mode {
987         DPNI_DIST_MODE_NONE = 0,
988         DPNI_DIST_MODE_HASH = 1,
989         DPNI_DIST_MODE_FS = 2
990 };
991
992 /**
993  * enum dpni_fs_miss_action -   DPNI Flow Steering miss action
994  * @DPNI_FS_MISS_DROP: In case of no-match, drop the frame
995  * @DPNI_FS_MISS_EXPLICIT_FLOWID: In case of no-match, use explicit flow-id
996  * @DPNI_FS_MISS_HASH: In case of no-match, distribute using hash
997  */
998 enum dpni_fs_miss_action {
999         DPNI_FS_MISS_DROP = 0,
1000         DPNI_FS_MISS_EXPLICIT_FLOWID = 1,
1001         DPNI_FS_MISS_HASH = 2
1002 };
1003
1004 /**
1005  * struct dpni_fs_tbl_cfg - Flow Steering table configuration
1006  * @miss_action:        Miss action selection
1007  * @default_flow_id:    Used when 'miss_action = DPNI_FS_MISS_EXPLICIT_FLOWID'
1008  * @keep_hash_key: used only when miss_action is set to DPNI_FS_MISS_HASH. When
1009  *      set to one unclassified frames will be distributed according to previous
1010  *      used hash key. If set to zero hash key will be replaced with the key
1011  *      provided for flow steering.
1012  * @keep_entries: if set to one command will not delete the entries that already
1013  *      exist into FS table. Use this option with caution: if the table
1014  *      entries are not compatible with the distribution key the packets
1015  *      will not be classified properly.
1016  */
1017 struct dpni_fs_tbl_cfg {
1018         enum dpni_fs_miss_action miss_action;
1019         uint16_t default_flow_id;
1020         char keep_hash_key;
1021         uint8_t keep_entries;
1022 };
1023
1024 /**
1025  * struct dpni_rx_tc_dist_cfg - Rx traffic class distribution configuration
1026  * @dist_size: Set the distribution size;
1027  *      supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
1028  *      112,128,192,224,256,384,448,512,768,896,1024
1029  * @dist_mode: Distribution mode
1030  * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
1031  *              the extractions to be used for the distribution key by calling
1032  *              dpkg_prepare_key_cfg() relevant only when
1033  *              'dist_mode != DPNI_DIST_MODE_NONE', otherwise it can be '0'
1034  * @fs_cfg: Flow Steering table configuration; only relevant if
1035  *              'dist_mode = DPNI_DIST_MODE_FS'
1036  */
1037 struct dpni_rx_tc_dist_cfg {
1038         uint16_t dist_size;
1039         enum dpni_dist_mode dist_mode;
1040         uint64_t key_cfg_iova;
1041         struct dpni_fs_tbl_cfg fs_cfg;
1042 };
1043
1044 int dpni_set_rx_tc_dist(struct fsl_mc_io *mc_io,
1045                         uint32_t cmd_flags,
1046                         uint16_t token,
1047                         uint8_t tc_id,
1048                         const struct dpni_rx_tc_dist_cfg *cfg);
1049
1050 /**
1051  * Set to select color aware mode (otherwise - color blind)
1052  */
1053 #define DPNI_POLICER_OPT_COLOR_AWARE    0x00000001
1054 /**
1055  * Set to discard frame with RED color
1056  */
1057 #define DPNI_POLICER_OPT_DISCARD_RED    0x00000002
1058
1059 /**
1060  * enum dpni_policer_mode - selecting the policer mode
1061  * @DPNI_POLICER_MODE_NONE: Policer is disabled
1062  * @DPNI_POLICER_MODE_PASS_THROUGH: Policer pass through
1063  * @DPNI_POLICER_MODE_RFC_2698: Policer algorithm RFC 2698
1064  * @DPNI_POLICER_MODE_RFC_4115: Policer algorithm RFC 4115
1065  */
1066 enum dpni_policer_mode {
1067         DPNI_POLICER_MODE_NONE = 0,
1068         DPNI_POLICER_MODE_PASS_THROUGH,
1069         DPNI_POLICER_MODE_RFC_2698,
1070         DPNI_POLICER_MODE_RFC_4115
1071 };
1072
1073 /**
1074  * enum dpni_policer_unit - DPNI policer units
1075  * @DPNI_POLICER_UNIT_BYTES: bytes units
1076  * @DPNI_POLICER_UNIT_FRAMES: frames units
1077  */
1078 enum dpni_policer_unit {
1079         DPNI_POLICER_UNIT_BYTES = 0,
1080         DPNI_POLICER_UNIT_FRAMES
1081 };
1082
1083 /**
1084  * enum dpni_policer_color - selecting the policer color
1085  * @DPNI_POLICER_COLOR_GREEN: Green color
1086  * @DPNI_POLICER_COLOR_YELLOW: Yellow color
1087  * @DPNI_POLICER_COLOR_RED: Red color
1088  */
1089 enum dpni_policer_color {
1090         DPNI_POLICER_COLOR_GREEN = 0,
1091         DPNI_POLICER_COLOR_YELLOW,
1092         DPNI_POLICER_COLOR_RED
1093 };
1094
1095 /**
1096  * struct dpni_rx_tc_policing_cfg - Policer configuration
1097  * @options: Mask of available options; use 'DPNI_POLICER_OPT_<X>' values
1098  * @mode: policer mode
1099  * @default_color: For pass-through mode the policer re-colors with this
1100  *      color any incoming packets. For Color aware non-pass-through mode:
1101  *      policer re-colors with this color all packets with FD[DROPP]>2.
1102  * @units: Bytes or Packets
1103  * @cir: Committed information rate (CIR) in Kbps or packets/second
1104  * @cbs: Committed burst size (CBS) in bytes or packets
1105  * @eir: Peak information rate (PIR, rfc2698) in Kbps or packets/second
1106  *       Excess information rate (EIR, rfc4115) in Kbps or packets/second
1107  * @ebs: Peak burst size (PBS, rfc2698) in bytes or packets
1108  *       Excess burst size (EBS, rfc4115) in bytes or packets
1109  */
1110 struct dpni_rx_tc_policing_cfg {
1111         uint32_t options;
1112         enum dpni_policer_mode mode;
1113         enum dpni_policer_unit units;
1114         enum dpni_policer_color default_color;
1115         uint32_t cir;
1116         uint32_t cbs;
1117         uint32_t eir;
1118         uint32_t ebs;
1119 };
1120
1121
1122 int dpni_set_rx_tc_policing(struct fsl_mc_io *mc_io,
1123                             uint32_t cmd_flags,
1124                             uint16_t token,
1125                             uint8_t tc_id,
1126                             const struct dpni_rx_tc_policing_cfg *cfg);
1127
1128 int dpni_get_rx_tc_policing(struct fsl_mc_io *mc_io,
1129                             uint32_t cmd_flags,
1130                             uint16_t token,
1131                             uint8_t tc_id,
1132                             struct dpni_rx_tc_policing_cfg *cfg);
1133
1134 /**
1135  * enum dpni_congestion_unit - DPNI congestion units
1136  * @DPNI_CONGESTION_UNIT_BYTES: bytes units
1137  * @DPNI_CONGESTION_UNIT_FRAMES: frames units
1138  */
1139 enum dpni_congestion_unit {
1140         DPNI_CONGESTION_UNIT_BYTES = 0,
1141         DPNI_CONGESTION_UNIT_FRAMES
1142 };
1143
1144 /**
1145  * enum dpni_early_drop_mode - DPNI early drop mode
1146  * @DPNI_EARLY_DROP_MODE_NONE: early drop is disabled
1147  * @DPNI_EARLY_DROP_MODE_TAIL: early drop in taildrop mode
1148  * @DPNI_EARLY_DROP_MODE_WRED: early drop in WRED mode
1149  */
1150 enum dpni_early_drop_mode {
1151         DPNI_EARLY_DROP_MODE_NONE = 0,
1152         DPNI_EARLY_DROP_MODE_TAIL,
1153         DPNI_EARLY_DROP_MODE_WRED
1154 };
1155
1156 /**
1157  * struct dpni_wred_cfg - WRED configuration
1158  * @max_threshold: maximum threshold that packets may be discarded. Above this
1159  *        threshold all packets are discarded; must be less than 2^39;
1160  *        approximated to be expressed as (x+256)*2^(y-1) due to HW
1161  *        implementation.
1162  * @min_threshold: minimum threshold that packets may be discarded at
1163  * @drop_probability: probability that a packet will be discarded (1-100,
1164  *                      associated with the max_threshold).
1165  */
1166 struct dpni_wred_cfg {
1167         uint64_t max_threshold;
1168         uint64_t min_threshold;
1169         uint8_t drop_probability;
1170 };
1171
1172 /**
1173  * struct dpni_early_drop_cfg - early-drop configuration
1174  * @enable: drop enable
1175  * @units: units type
1176  * @green: WRED - 'green' configuration
1177  * @yellow: WRED - 'yellow' configuration
1178  * @red: WRED - 'red' configuration
1179  */
1180 struct dpni_early_drop_cfg {
1181         uint8_t enable;
1182         enum dpni_congestion_unit units;
1183         struct dpni_wred_cfg green;
1184         struct dpni_wred_cfg yellow;
1185         struct dpni_wred_cfg red;
1186 };
1187
1188 void dpni_prepare_early_drop(const struct dpni_early_drop_cfg *cfg,
1189                              uint8_t *early_drop_buf);
1190
1191 void dpni_extract_early_drop(struct dpni_early_drop_cfg *cfg,
1192                              const uint8_t *early_drop_buf);
1193
1194 int dpni_set_early_drop(struct fsl_mc_io *mc_io,
1195                         uint32_t cmd_flags,
1196                         uint16_t token,
1197                         enum dpni_queue_type qtype,
1198                         uint16_t param,
1199                         uint64_t early_drop_iova);
1200
1201 int dpni_get_early_drop(struct fsl_mc_io *mc_io,
1202                         uint32_t cmd_flags,
1203                         uint16_t token,
1204                         enum dpni_queue_type qtype,
1205                         uint16_t param,
1206                         uint64_t early_drop_iova);
1207
1208 /**
1209  * enum dpni_dest - DPNI destination types
1210  * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
1211  *              does not generate FQDAN notifications; user is expected to
1212  *              dequeue from the queue based on polling or other user-defined
1213  *              method
1214  * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
1215  *              notifications to the specified DPIO; user is expected to dequeue
1216  *              from the queue only after notification is received
1217  * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
1218  *              FQDAN notifications, but is connected to the specified DPCON
1219  *              object; user is expected to dequeue from the DPCON channel
1220  */
1221 enum dpni_dest {
1222         DPNI_DEST_NONE = 0,
1223         DPNI_DEST_DPIO = 1,
1224         DPNI_DEST_DPCON = 2
1225 };
1226
1227 /**
1228  * struct dpni_dest_cfg - Structure representing DPNI destination parameters
1229  * @dest_type: Destination type
1230  * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
1231  * @priority: Priority selection within the DPIO or DPCON channel; valid values
1232  *              are 0-1 or 0-7, depending on the number of priorities in that
1233  *              channel; not relevant for 'DPNI_DEST_NONE' option
1234  */
1235 struct dpni_dest_cfg {
1236         enum dpni_dest dest_type;
1237         int dest_id;
1238         uint8_t priority;
1239 };
1240
1241 /* DPNI congestion options */
1242
1243 /**
1244  * CSCN message is written to message_iova once entering a
1245  * congestion state (see 'threshold_entry')
1246  */
1247 #define DPNI_CONG_OPT_WRITE_MEM_ON_ENTER        0x00000001
1248 /**
1249  * CSCN message is written to message_iova once exiting a
1250  * congestion state (see 'threshold_exit')
1251  */
1252 #define DPNI_CONG_OPT_WRITE_MEM_ON_EXIT         0x00000002
1253 /**
1254  * CSCN write will attempt to allocate into a cache (coherent write);
1255  * valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>' is selected
1256  */
1257 #define DPNI_CONG_OPT_COHERENT_WRITE            0x00000004
1258 /**
1259  * if 'dest_cfg.dest_type != DPNI_DEST_NONE' CSCN message is sent to
1260  * DPIO/DPCON's WQ channel once entering a congestion state
1261  * (see 'threshold_entry')
1262  */
1263 #define DPNI_CONG_OPT_NOTIFY_DEST_ON_ENTER      0x00000008
1264 /**
1265  * if 'dest_cfg.dest_type != DPNI_DEST_NONE' CSCN message is sent to
1266  * DPIO/DPCON's WQ channel once exiting a congestion state
1267  * (see 'threshold_exit')
1268  */
1269 #define DPNI_CONG_OPT_NOTIFY_DEST_ON_EXIT       0x00000010
1270 /**
1271  * if 'dest_cfg.dest_type != DPNI_DEST_NONE' when the CSCN is written to the
1272  * sw-portal's DQRR, the DQRI interrupt is asserted immediately (if enabled)
1273  */
1274 #define DPNI_CONG_OPT_INTR_COALESCING_DISABLED  0x00000020
1275 /**
1276  * This congestion will trigger flow control or priority flow control. This
1277  * will have effect only if flow control is enabled with dpni_set_link_cfg()
1278  */
1279 #define DPNI_CONG_OPT_FLOW_CONTROL      0x00000040
1280
1281 /**
1282  * enum dpni_congestion_point - Structure representing congestion point
1283  * @DPNI_CP_QUEUE:      Set congestion per queue, identified by QUEUE_TYPE, TC
1284  *                      and QUEUE_INDEX
1285  * @DPNI_CP_GROUP:      Set congestion per queue group. Depending on options
1286  *                      used to define the DPNI this can be either per
1287  *                      TC (default) or per interface
1288  *                      (DPNI_OPT_SHARED_CONGESTION set at DPNI create).
1289  *                      QUEUE_INDEX is ignored if this type is used.
1290  * @DPNI_CP_CONGESTION_GROUP: Set per congestion group id. This will work
1291  *              only if the DPNI is created with  DPNI_OPT_CUSTOM_CG option
1292  */
1293
1294 enum dpni_congestion_point {
1295         DPNI_CP_QUEUE,
1296         DPNI_CP_GROUP,
1297         DPNI_CP_CONGESTION_GROUP,
1298 };
1299
1300 /**
1301  * struct dpni_congestion_notification_cfg - congestion notification
1302  *              configuration
1303  * @units: units type
1304  * @threshold_entry: above this threshold we enter a congestion state.
1305  *      set it to '0' to disable it
1306  * @threshold_exit: below this threshold we exit the congestion state.
1307  * @message_ctx: The context that will be part of the CSCN message
1308  * @message_iova: I/O virtual address (must be in DMA-able memory),
1309  *      must be 16B aligned; valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>' is
1310  *      contained in 'options'
1311  * @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel
1312  * @notification_mode: Mask of available options; use 'DPNI_CONG_OPT_<X>' values
1313  * @cg_point: Congestion point settings
1314  * @cgid: id of the congestion group. The index is relative to dpni.
1315  */
1316
1317 struct dpni_congestion_notification_cfg {
1318         enum dpni_congestion_unit units;
1319         uint32_t threshold_entry;
1320         uint32_t threshold_exit;
1321         uint64_t message_ctx;
1322         uint64_t message_iova;
1323         struct dpni_dest_cfg dest_cfg;
1324         uint16_t notification_mode;
1325         enum dpni_congestion_point cg_point;
1326         int cgid;
1327 };
1328
1329 int dpni_set_congestion_notification(struct fsl_mc_io *mc_io,
1330                                      uint32_t cmd_flags,
1331                                      uint16_t token,
1332                                      enum dpni_queue_type qtype,
1333                                      uint16_t param,
1334                                      const struct dpni_congestion_notification_cfg *cfg);
1335
1336 int dpni_get_congestion_notification(struct fsl_mc_io *mc_io,
1337                                      uint32_t cmd_flags,
1338                                      uint16_t token,
1339                                      enum dpni_queue_type qtype,
1340                                      uint16_t param,
1341                                      struct dpni_congestion_notification_cfg *cfg);
1342
1343 /* DPNI FLC stash options */
1344
1345 /**
1346  * stashes the whole annotation area (up to 192 bytes)
1347  */
1348 #define DPNI_FLC_STASH_FRAME_ANNOTATION 0x00000001
1349
1350 /**
1351  * struct dpni_queue - Queue structure
1352  * @destination - Destination structure
1353  * @destination.id: ID of the destination, only relevant if DEST_TYPE is > 0.
1354  *      Identifies either a DPIO or a DPCON object.
1355  *      Not relevant for Tx queues.
1356  * @destination.type:   May be one of the following:
1357  *      0 - No destination, queue can be manually
1358  *              queried, but will not push traffic or
1359  *              notifications to a DPIO;
1360  *      1 - The destination is a DPIO. When traffic
1361  *              becomes available in the queue a FQDAN
1362  *              (FQ data available notification) will be
1363  *              generated to selected DPIO;
1364  *      2 - The destination is a DPCON. The queue is
1365  *              associated with a DPCON object for the
1366  *              purpose of scheduling between multiple
1367  *              queues. The DPCON may be independently
1368  *              configured to generate notifications.
1369  *              Not relevant for Tx queues.
1370  * @destination.hold_active: Hold active, maintains a queue scheduled for longer
1371  *      in a DPIO during dequeue to reduce spread of traffic.
1372  *      Only relevant if queues are
1373  *      not affined to a single DPIO.
1374  * @user_context: User data, presented to the user along with any frames
1375  *      from this queue. Not relevant for Tx queues.
1376  * @flc: FD FLow Context structure
1377  * @flc.value: Default FLC value for traffic dequeued from
1378  *      this queue.  Please check description of FD
1379  *      structure for more information.
1380  *      Note that FLC values set using dpni_add_fs_entry,
1381  *      if any, take precedence over values per queue.
1382  * @flc.stash_control: Boolean, indicates whether the 6 lowest
1383  *      - significant bits are used for stash control.
1384  *      significant bits are used for stash control.  If set, the 6
1385  *      least significant bits in value are interpreted as follows:
1386  *      - bits 0-1: indicates the number of 64 byte units of context
1387  *      that are stashed.  FLC value is interpreted as a memory address
1388  *      in this case, excluding the 6 LS bits.
1389  *      - bits 2-3: indicates the number of 64 byte units of frame
1390  *      annotation to be stashed.  Annotation is placed at FD[ADDR].
1391  *      - bits 4-5: indicates the number of 64 byte units of frame
1392  *      data to be stashed.  Frame data is placed at FD[ADDR] +
1393  *      FD[OFFSET].
1394  *      For more details check the Frame Descriptor section in the
1395  *      hardware documentation.
1396  *@cgid :indicate the cgid to set relative to dpni
1397  */
1398 struct dpni_queue {
1399         struct {
1400                 uint16_t id;
1401                 enum dpni_dest type;
1402                 char hold_active;
1403                 uint8_t priority;
1404         } destination;
1405         uint64_t user_context;
1406         struct {
1407                 uint64_t value;
1408                 char stash_control;
1409         } flc;
1410         int cgid;
1411 };
1412
1413 /**
1414  * struct dpni_queue_id - Queue identification, used for enqueue commands
1415  *                              or queue control
1416  * @fqid:       FQID used for enqueueing to and/or configuration of this
1417  *                      specific FQ
1418  * @qdbin:      Queueing bin, used to enqueue using QDID, DQBIN, QPRI.
1419  *                      Only relevant for Tx queues.
1420  */
1421 struct dpni_queue_id {
1422         uint32_t fqid;
1423         uint16_t qdbin;
1424 };
1425
1426 /**
1427  * enum dpni_confirmation_mode - Defines DPNI options supported for Tx
1428  * confirmation
1429  * @DPNI_CONF_AFFINE: For each Tx queue set associated with a sender there is
1430  * an affine Tx Confirmation queue
1431  * @DPNI_CONF_SINGLE: All Tx queues are associated with a single Tx
1432  * confirmation queue
1433  * @DPNI_CONF_DISABLE: Tx frames are not confirmed.  This must be associated
1434  * with proper FD set-up to have buffers release to a Buffer Pool, otherwise
1435  * buffers will be leaked
1436  */
1437 enum dpni_confirmation_mode {
1438         DPNI_CONF_AFFINE,
1439         DPNI_CONF_SINGLE,
1440         DPNI_CONF_DISABLE,
1441 };
1442
1443 int dpni_set_tx_confirmation_mode(struct fsl_mc_io *mc_io,
1444                                   uint32_t cmd_flags,
1445                                   uint16_t token,
1446                                   enum dpni_confirmation_mode mode);
1447
1448 int dpni_get_tx_confirmation_mode(struct fsl_mc_io *mc_io,
1449                                   uint32_t cmd_flags,
1450                                   uint16_t token,
1451                                   enum dpni_confirmation_mode *mode);
1452
1453 /**
1454  * struct dpni_qos_tbl_cfg - Structure representing QOS table configuration
1455  * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
1456  *              key extractions to be used as the QoS criteria by calling
1457  *              dpkg_prepare_key_cfg()
1458  * @discard_on_miss: Set to '1' to discard frames in case of no match (miss);
1459  *              '0' to use the 'default_tc' in such cases
1460  * @keep_entries: if set to one will not delete existing table entries. This
1461  *              option will work properly only for dpni objects created with
1462  *              DPNI_OPT_HAS_KEY_MASKING option. All previous QoS entries must
1463  *              be compatible with new key composition rule.
1464  *              It is the caller's job to delete incompatible entries before
1465  *              executing this function.
1466  * @default_tc: Used in case of no-match and 'discard_on_miss'= 0
1467  */
1468 struct dpni_qos_tbl_cfg {
1469         uint64_t key_cfg_iova;
1470         int discard_on_miss;
1471         int keep_entries;
1472         uint8_t default_tc;
1473 };
1474
1475 int dpni_set_qos_table(struct fsl_mc_io *mc_io,
1476                        uint32_t cmd_flags,
1477                        uint16_t token,
1478                        const struct dpni_qos_tbl_cfg *cfg);
1479
1480 /**
1481  * struct dpni_rule_cfg - Rule configuration for table lookup
1482  * @key_iova: I/O virtual address of the key (must be in DMA-able memory)
1483  * @mask_iova: I/O virtual address of the mask (must be in DMA-able memory)
1484  * @key_size: key and mask size (in bytes)
1485  */
1486 struct dpni_rule_cfg {
1487         uint64_t key_iova;
1488         uint64_t mask_iova;
1489         uint8_t key_size;
1490 };
1491
1492 int dpni_add_qos_entry(struct fsl_mc_io *mc_io,
1493                        uint32_t cmd_flags,
1494                        uint16_t token,
1495                        const struct dpni_rule_cfg *cfg,
1496                        uint8_t tc_id,
1497                        uint16_t index,
1498                            uint8_t flags,
1499                            uint8_t flow_id);
1500
1501 int dpni_remove_qos_entry(struct fsl_mc_io *mc_io,
1502                           uint32_t cmd_flags,
1503                           uint16_t token,
1504                           const struct dpni_rule_cfg *cfg);
1505
1506 int dpni_clear_qos_table(struct fsl_mc_io *mc_io,
1507                          uint32_t cmd_flags,
1508                          uint16_t token);
1509
1510 /**
1511  * Discard matching traffic.  If set, this takes precedence over any other
1512  * configuration and matching traffic is always discarded.
1513  */
1514  #define DPNI_FS_OPT_DISCARD            0x1
1515
1516 /**
1517  * Set FLC value.  If set, flc member of truct dpni_fs_action_cfg is used to
1518  * override the FLC value set per queue.
1519  * For more details check the Frame Descriptor section in the hardware
1520  * documentation.
1521  */
1522 #define DPNI_FS_OPT_SET_FLC            0x2
1523
1524 /*
1525  * Indicates whether the 6 lowest significant bits of FLC are used for stash
1526  * control.  If set, the 6 least significant bits in value are interpreted as
1527  * follows:
1528  *     - bits 0-1: indicates the number of 64 byte units of context that are
1529  *     stashed.  FLC value is interpreted as a memory address in this case,
1530  *     excluding the 6 LS bits.
1531  *     - bits 2-3: indicates the number of 64 byte units of frame annotation
1532  *     to be stashed.  Annotation is placed at FD[ADDR].
1533  *     - bits 4-5: indicates the number of 64 byte units of frame data to be
1534  *     stashed.  Frame data is placed at FD[ADDR] + FD[OFFSET].
1535  * This flag is ignored if DPNI_FS_OPT_SET_FLC is not specified.
1536  */
1537 #define DPNI_FS_OPT_SET_STASH_CONTROL  0x4
1538
1539 /**
1540  * Redirect matching traffic to Rx part of another dpni object. The frame
1541  * will be classified according to new qos and flow steering rules from
1542  * target dpni object.
1543  */
1544 #define DPNI_FS_OPT_REDIRECT_TO_DPNI_RX         0x08
1545
1546 /**
1547  * Redirect matching traffic into Tx queue of another dpni object. The
1548  * frame will be transmitted directly
1549  */
1550 #define DPNI_FS_OPT_REDIRECT_TO_DPNI_TX         0x10
1551
1552 /**
1553  * struct dpni_fs_action_cfg - Action configuration for table look-up
1554  * @flc: FLC value for traffic matching this rule.  Please check the Frame
1555  * Descriptor section in the hardware documentation for more information.
1556  * @flow_id: Identifies the Rx queue used for matching traffic.  Supported
1557  *     values are in range 0 to num_queue-1.
1558  * @redirect_obj_token: token that identifies the object where frame is
1559  * redirected when this rule is hit. This parameter is used only when one of the
1560  * flags DPNI_FS_OPT_REDIRECT_TO_DPNI_RX or DPNI_FS_OPT_REDIRECT_TO_DPNI_TX is
1561  * set.
1562  * The token is obtained using dpni_open() API call. The object must stay
1563  * open during the operation to ensure the fact that application has access
1564  * on it. If the object is destroyed of closed next actions will take place:
1565  * - if DPNI_FS_OPT_DISCARD is set the frame will be discarded by current dpni
1566  * - if DPNI_FS_OPT_DISCARD is cleared the frame will be enqueued in queue with
1567  *   index provided in flow_id parameter.
1568  * @options: Any combination of DPNI_FS_OPT_ values.
1569  */
1570 struct dpni_fs_action_cfg {
1571         uint64_t flc;
1572         uint16_t flow_id;
1573         uint16_t redirect_obj_token;
1574         uint16_t options;
1575 };
1576
1577 int dpni_add_fs_entry(struct fsl_mc_io *mc_io,
1578                       uint32_t cmd_flags,
1579                       uint16_t token,
1580                       uint8_t tc_id,
1581                       uint16_t index,
1582                       const struct dpni_rule_cfg *cfg,
1583                       const struct dpni_fs_action_cfg *action);
1584
1585 int dpni_remove_fs_entry(struct fsl_mc_io *mc_io,
1586                          uint32_t cmd_flags,
1587                          uint16_t token,
1588                          uint8_t tc_id,
1589                          const struct dpni_rule_cfg *cfg);
1590
1591 int dpni_clear_fs_entries(struct fsl_mc_io *mc_io,
1592                           uint32_t cmd_flags,
1593                           uint16_t token,
1594                           uint8_t tc_id);
1595
1596 int dpni_get_api_version(struct fsl_mc_io *mc_io,
1597                          uint32_t cmd_flags,
1598                          uint16_t *major_ver,
1599                          uint16_t *minor_ver);
1600
1601 /**
1602  * Set User Context
1603  */
1604 #define DPNI_QUEUE_OPT_USER_CTX         0x00000001
1605
1606 /**
1607  * Set queue destination configuration
1608  */
1609 #define DPNI_QUEUE_OPT_DEST             0x00000002
1610
1611 /**
1612  * Set FD[FLC] configuration for traffic on this queue.  Note that FLC values
1613  * set with dpni_add_fs_entry, if any, take precedence over values per queue.
1614  */
1615 #define DPNI_QUEUE_OPT_FLC              0x00000004
1616
1617 /**
1618  * Set the queue to hold active mode.  This prevents the queue from being
1619  * rescheduled between DPIOs while it carries traffic and is active on one
1620  * DPNI.  Can help reduce reordering when servicing one queue on multiple
1621  * CPUs, but the queue is also less likely to push data to multiple CPUs
1622  * especially when congested.
1623  */
1624 #define DPNI_QUEUE_OPT_HOLD_ACTIVE      0x00000008
1625
1626 #define DPNI_QUEUE_OPT_SET_CGID                         0x00000040
1627 #define DPNI_QUEUE_OPT_CLEAR_CGID                       0x00000080
1628
1629 int dpni_set_queue(struct fsl_mc_io *mc_io,
1630                    uint32_t cmd_flags,
1631                    uint16_t token,
1632                    enum dpni_queue_type qtype,
1633                    uint16_t param,
1634                    uint8_t index,
1635                    uint8_t options,
1636                    const struct dpni_queue *queue);
1637
1638 int dpni_get_queue(struct fsl_mc_io *mc_io,
1639                    uint32_t cmd_flags,
1640                    uint16_t token,
1641                    enum dpni_queue_type qtype,
1642                    uint16_t param,
1643                    uint8_t index,
1644                    struct dpni_queue *queue,
1645                    struct dpni_queue_id *qid);
1646
1647 int dpni_get_statistics(struct fsl_mc_io *mc_io,
1648                         uint32_t cmd_flags,
1649                         uint16_t token,
1650                         uint8_t page,
1651                         uint16_t param,
1652                         union dpni_statistics *stat);
1653
1654 int dpni_reset_statistics(struct fsl_mc_io *mc_io,
1655                           uint32_t cmd_flags,
1656                           uint16_t token);
1657
1658 /**
1659  * struct dpni_taildrop - Structure representing the taildrop
1660  * @enable:     Indicates whether the taildrop is active or not.
1661  * @units:      Indicates the unit of THRESHOLD. Queue taildrop only
1662  *              supports byte units, this field is ignored and
1663  *              assumed = 0 if CONGESTION_POINT is 0.
1664  * @threshold:  Threshold value, in units identified by UNITS field. Value 0
1665  *              cannot be used as a valid taildrop threshold,
1666  *              THRESHOLD must be > 0 if the taildrop is
1667  *              enabled.
1668  * @oal :       Overhead Accounting Length, a 12-bit, 2's complement value
1669  *              with range (-2048 to +2047) representing a fixed per-frame
1670  *              overhead to be added to the actual length of a frame when
1671  *              performing WRED and tail drop calculations and threshold
1672  *              comparisons.
1673  */
1674 struct dpni_taildrop {
1675         char enable;
1676         enum dpni_congestion_unit units;
1677         uint32_t threshold;
1678         int16_t oal;
1679 };
1680
1681 int dpni_set_taildrop(struct fsl_mc_io *mc_io,
1682                       uint32_t cmd_flags,
1683                       uint16_t token,
1684                       enum dpni_congestion_point cg_point,
1685                       enum dpni_queue_type q_type,
1686                       uint16_t param,
1687                       uint8_t q_index,
1688                       struct dpni_taildrop *taildrop);
1689
1690 int dpni_get_taildrop(struct fsl_mc_io *mc_io,
1691                       uint32_t cmd_flags,
1692                       uint16_t token,
1693                       enum dpni_congestion_point cg_point,
1694                       enum dpni_queue_type q_type,
1695                       uint8_t tc,
1696                       uint8_t q_index,
1697                       struct dpni_taildrop *taildrop);
1698
1699 int dpni_set_opr(struct fsl_mc_io *mc_io,
1700                  uint32_t cmd_flags,
1701                  uint16_t token,
1702                  uint8_t tc,
1703                  uint8_t index,
1704                  uint8_t options,
1705                  struct opr_cfg *cfg,
1706                  uint8_t opr_id);
1707
1708 int dpni_get_opr(struct fsl_mc_io *mc_io,
1709                  uint32_t cmd_flags,
1710                  uint16_t token,
1711                  uint8_t tc,
1712                  uint8_t index,
1713                  struct opr_cfg *cfg,
1714                  struct opr_qry *qry,
1715                  uint8_t flags,
1716                  uint8_t opr_id);
1717
1718 /**
1719  * enum dpni_soft_sequence_dest - Enumeration of WRIOP software sequence
1720  *                              destinations
1721  * @DPNI_SS_INGRESS: Ingress parser
1722  * @DPNI_SS_EGRESS: Egress parser
1723  */
1724 enum dpni_soft_sequence_dest {
1725         DPNI_SS_INGRESS = 0,
1726         DPNI_SS_EGRESS = 1,
1727 };
1728
1729 /**
1730  * struct dpni_load_ss_cfg - Structure for Software Sequence load configuration
1731  * @dest:       Destination of the Software Sequence: ingress or egress parser
1732  * @ss_size: Size of the Software Sequence
1733  * @ss_offset:  The offset where to load the Software Sequence (0x20-0x7FD)
1734  * @ss_iova: I/O virtual address of the Software Sequence
1735  */
1736 struct dpni_load_ss_cfg {
1737         enum dpni_soft_sequence_dest dest;
1738         uint16_t ss_size;
1739         uint16_t ss_offset;
1740         uint64_t ss_iova;
1741 };
1742
1743 /**
1744  * struct dpni_enable_ss_cfg - Structure for software sequence enable
1745  *                              configuration
1746  * @dest:       Destination of the Software Sequence: ingress or egress parser
1747  * @hxs: HXS to attach the software sequence to
1748  * @set_start: If the Software Sequence or HDR it is attached to is set as
1749  *              parser start
1750  *              If hxs=DUMMY_LAST_HXS the ss_offset is set directly as parser
1751  *                      start else the hdr index code is set as parser start
1752  * @ss_offset: The offset of the Software Sequence to enable or set as parse
1753  *              start
1754  * @param_size: Size of the software sequence parameters
1755  * @param_offset: Offset in the parameter zone for the software sequence
1756  *                      parameters
1757  * @param_iova: I/O virtual address of the parameters
1758  */
1759 struct dpni_enable_ss_cfg {
1760         enum dpni_soft_sequence_dest dest;
1761         uint16_t hxs;
1762         uint8_t set_start;
1763         uint16_t ss_offset;
1764         uint8_t param_size;
1765         uint8_t param_offset;
1766         uint64_t param_iova;
1767 };
1768
1769 /**
1770  * dpni_load_sw_sequence() - Loads a software sequence in parser memory.
1771  * @mc_io:      Pointer to MC portal's I/O object
1772  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
1773  * @token:      Token of DPNI object
1774  * @cfg:        Software sequence load configuration
1775  * Return:      '0' on Success; Error code otherwise.
1776  */
1777 int dpni_load_sw_sequence(struct fsl_mc_io *mc_io,
1778               uint32_t cmd_flags,
1779               uint16_t token,
1780                   struct dpni_load_ss_cfg *cfg);
1781
1782 /**
1783  * dpni_enable_sw_sequence() - Enables a software sequence in the parser
1784  *                              profile
1785  * corresponding to the ingress or egress of the DPNI.
1786  * @mc_io:      Pointer to MC portal's I/O object
1787  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
1788  * @token:      Token of DPNI object
1789  * @cfg:        Software sequence enable configuration
1790  * Return:      '0' on Success; Error code otherwise.
1791  */
1792 int dpni_enable_sw_sequence(struct fsl_mc_io *mc_io,
1793                             uint32_t cmd_flags,
1794                             uint16_t token,
1795                             struct dpni_enable_ss_cfg *cfg);
1796
1797 /**
1798  * struct dpni_sw_sequence_layout - Structure for software sequence enable
1799  *                              configuration
1800  * @num_ss:     Number of software sequences returned
1801  * @ss: Array of software sequence entries. The number of valid entries
1802  *                      must match 'num_ss' value
1803  */
1804 struct dpni_sw_sequence_layout {
1805         uint8_t num_ss;
1806         struct {
1807                 uint16_t ss_offset;
1808                 uint16_t ss_size;
1809                 uint8_t param_offset;
1810                 uint8_t param_size;
1811         } ss[DPNI_SW_SEQUENCE_LAYOUT_SIZE];
1812 };
1813
1814 /**
1815  * dpni_get_sw_sequence_layout() - Get the soft sequence layout
1816  * @mc_io:      Pointer to MC portal's I/O object
1817  * @cmd_flags:  Command flags; one or more of 'MC_CMD_FLAG_'
1818  * @token:      Token of DPNI object
1819  * @src:        Source of the layout (WRIOP Rx or Tx)
1820  * @ss_layout_iova:  I/O virtual address of 264 bytes DMA-able memory
1821  *
1822  * warning: After calling this function, call dpni_extract_sw_sequence_layout()
1823  *              to get the layout
1824  *
1825  * Return:      '0' on Success; error code otherwise.
1826  */
1827 int dpni_get_sw_sequence_layout(struct fsl_mc_io *mc_io,
1828                                 uint32_t cmd_flags,
1829                                 uint16_t token,
1830                                 enum dpni_soft_sequence_dest src,
1831                                 uint64_t ss_layout_iova);
1832
1833 /**
1834  * dpni_extract_sw_sequence_layout() - extract the software sequence layout
1835  * @layout:     software sequence layout
1836  * @sw_sequence_layout_buf:Zeroed 264 bytes of memory before mapping it to DMA
1837  *
1838  * This function has to be called after dpni_get_sw_sequence_layout
1839  */
1840 void dpni_extract_sw_sequence_layout(struct dpni_sw_sequence_layout *layout,
1841                                      const uint8_t *sw_sequence_layout_buf);
1842
1843 /**
1844  * struct dpni_ptp_cfg - configure single step PTP (IEEE 1588)
1845  *      @en: enable single step PTP. When enabled the PTPv1 functionality will
1846  *              not work. If the field is zero, offset and ch_update parameters
1847  *              will be ignored
1848  *      @offset: start offset from the beginning of the frame where timestamp
1849  *              field is found. The offset must respect all MAC headers, VLAN
1850  *      tags and other protocol headers
1851  *      @ch_update: when set UDP checksum will be updated inside packet
1852  *      @peer_delay: For peer-to-peer transparent clocks add this value to the
1853  *              correction field in addition to the transient time update. The
1854  *              value expresses nanoseconds.
1855  */
1856 struct dpni_single_step_cfg {
1857         uint8_t en;
1858         uint8_t ch_update;
1859         uint16_t offset;
1860         uint32_t peer_delay;
1861 };
1862
1863 int dpni_set_single_step_cfg(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1864                 uint16_t token, struct dpni_single_step_cfg *ptp_cfg);
1865
1866 int dpni_get_single_step_cfg(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1867                 uint16_t token, struct dpni_single_step_cfg *ptp_cfg);
1868
1869 /**
1870  * loopback_en field is valid when calling function dpni_set_port_cfg
1871  */
1872 #define DPNI_PORT_CFG_LOOPBACK          0x01
1873
1874 /**
1875  * struct dpni_port_cfg - custom configuration for dpni physical port
1876  *      @loopback_en: port loopback enabled
1877  */
1878 struct dpni_port_cfg {
1879         int loopback_en;
1880 };
1881
1882 int dpni_set_port_cfg(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1883                 uint16_t token, uint32_t flags, struct dpni_port_cfg *port_cfg);
1884
1885 int dpni_get_port_cfg(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1886                 uint16_t token, struct dpni_port_cfg *port_cfg);
1887
1888 /**
1889  * When used for queue_idx in function dpni_set_rx_dist_default_queue will
1890  * signal to dpni to drop all unclassified frames
1891  */
1892 #define DPNI_FS_MISS_DROP               ((uint16_t)-1)
1893
1894 /**
1895  * struct dpni_rx_dist_cfg - distribution configuration
1896  * @dist_size:  distribution size; supported values: 1,2,3,4,6,7,8,
1897  *              12,14,16,24,28,32,48,56,64,96,112,128,192,224,256,384,448,
1898  *              512,768,896,1024
1899  * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
1900  *              the extractions to be used for the distribution key by calling
1901  *              dpkg_prepare_key_cfg() relevant only when enable!=0 otherwise
1902  *              it can be '0'
1903  * @enable: enable/disable the distribution.
1904  * @tc: TC id for which distribution is set
1905  * @fs_miss_flow_id: when packet misses all rules from flow steering table and
1906  *              hash is disabled it will be put into this queue id; use
1907  *              DPNI_FS_MISS_DROP to drop frames. The value of this field is
1908  *              used only when flow steering distribution is enabled and hash
1909  *              distribution is disabled
1910  */
1911 struct dpni_rx_dist_cfg {
1912         uint16_t dist_size;
1913         uint64_t key_cfg_iova;
1914         uint8_t enable;
1915         uint8_t tc;
1916         uint16_t fs_miss_flow_id;
1917 };
1918
1919 int dpni_set_rx_fs_dist(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1920                 uint16_t token, const struct dpni_rx_dist_cfg *cfg);
1921
1922 int dpni_set_rx_hash_dist(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1923                 uint16_t token, const struct dpni_rx_dist_cfg *cfg);
1924
1925 int dpni_add_custom_tpid(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1926                 uint16_t token, uint16_t tpid);
1927
1928 int dpni_remove_custom_tpid(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1929                 uint16_t token, uint16_t tpid);
1930
1931 /**
1932  * struct dpni_custom_tpid_cfg - custom TPID configuration. Contains custom TPID
1933  *      values used in current dpni object to detect 802.1q frames.
1934  *      @tpid1: first tag. Not used if zero.
1935  *      @tpid2: second tag. Not used if zero.
1936  */
1937 struct dpni_custom_tpid_cfg {
1938         uint16_t tpid1;
1939         uint16_t tpid2;
1940 };
1941
1942 int dpni_get_custom_tpid(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1943                 uint16_t token, struct dpni_custom_tpid_cfg *tpid);
1944
1945 #endif /* __FSL_DPNI_H */