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