Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
0002 /* Copyright 2013-2016 Freescale Semiconductor Inc.
0003  * Copyright 2016 NXP
0004  * Copyright 2020 NXP
0005  */
0006 #ifndef __FSL_DPNI_H
0007 #define __FSL_DPNI_H
0008 
0009 #include "dpkg.h"
0010 
0011 struct fsl_mc_io;
0012 
0013 /* Data Path Network Interface API
0014  * Contains initialization APIs and runtime control APIs for DPNI
0015  */
0016 
0017 /** General DPNI macros */
0018 
0019 /**
0020  * DPNI_MAX_TC - Maximum number of traffic classes
0021  */
0022 #define DPNI_MAX_TC             8
0023 /**
0024  * DPNI_MAX_DPBP - Maximum number of buffer pools per DPNI
0025  */
0026 #define DPNI_MAX_DPBP               8
0027 
0028 /**
0029  * DPNI_ALL_TCS - All traffic classes considered; see dpni_set_queue()
0030  */
0031 #define DPNI_ALL_TCS                (u8)(-1)
0032 /**
0033  * DPNI_ALL_TC_FLOWS - All flows within traffic class considered; see
0034  * dpni_set_queue()
0035  */
0036 #define DPNI_ALL_TC_FLOWS           (u16)(-1)
0037 /**
0038  * DPNI_NEW_FLOW_ID - Generate new flow ID; see dpni_set_queue()
0039  */
0040 #define DPNI_NEW_FLOW_ID            (u16)(-1)
0041 
0042 /**
0043  * DPNI_OPT_TX_FRM_RELEASE - Tx traffic is always released to a buffer pool on
0044  * transmit, there are no resources allocated to have the frames confirmed back
0045  * to the source after transmission.
0046  */
0047 #define DPNI_OPT_TX_FRM_RELEASE         0x000001
0048 /**
0049  * DPNI_OPT_NO_MAC_FILTER - Disables support for MAC address filtering for
0050  * addresses other than primary MAC address. This affects both unicast and
0051  * multicast. Promiscuous mode can still be enabled/disabled for both unicast
0052  * and multicast. If promiscuous mode is disabled, only traffic matching the
0053  * primary MAC address will be accepted.
0054  */
0055 #define DPNI_OPT_NO_MAC_FILTER          0x000002
0056 /**
0057  * DPNI_OPT_HAS_POLICING - Allocate policers for this DPNI. They can be used to
0058  * rate-limit traffic per traffic class (TC) basis.
0059  */
0060 #define DPNI_OPT_HAS_POLICING           0x000004
0061 /**
0062  * DPNI_OPT_SHARED_CONGESTION - Congestion can be managed in several ways,
0063  * allowing the buffer pool to deplete on ingress, taildrop on each queue or
0064  * use congestion groups for sets of queues. If set, it configures a single
0065  * congestion groups across all TCs.  If reset, a congestion group is allocated
0066  * for each TC. Only relevant if the DPNI has multiple traffic classes.
0067  */
0068 #define DPNI_OPT_SHARED_CONGESTION      0x000008
0069 /**
0070  * DPNI_OPT_HAS_KEY_MASKING - Enables TCAM for Flow Steering and QoS look-ups.
0071  * If not specified, all look-ups are exact match. Note that TCAM is not
0072  * available on LS1088 and its variants. Setting this bit on these SoCs will
0073  * trigger an error.
0074  */
0075 #define DPNI_OPT_HAS_KEY_MASKING        0x000010
0076 /**
0077  * DPNI_OPT_NO_FS - Disables the flow steering table.
0078  */
0079 #define DPNI_OPT_NO_FS              0x000020
0080 /**
0081  * DPNI_OPT_SHARED_FS - Flow steering table is shared between all traffic
0082  * classes
0083  */
0084 #define DPNI_OPT_SHARED_FS          0x001000
0085 
0086 int dpni_open(struct fsl_mc_io  *mc_io,
0087           u32       cmd_flags,
0088           int       dpni_id,
0089           u16       *token);
0090 
0091 int dpni_close(struct fsl_mc_io *mc_io,
0092            u32      cmd_flags,
0093            u16      token);
0094 
0095 /**
0096  * struct dpni_pools_cfg - Structure representing buffer pools configuration
0097  * @num_dpbp: Number of DPBPs
0098  * @pools: Array of buffer pools parameters; The number of valid entries
0099  *  must match 'num_dpbp' value
0100  * @pools.dpbp_id: DPBP object ID
0101  * @pools.buffer_size: Buffer size
0102  * @pools.backup_pool: Backup pool
0103  */
0104 struct dpni_pools_cfg {
0105     u8      num_dpbp;
0106     struct {
0107         int dpbp_id;
0108         u16 buffer_size;
0109         int backup_pool;
0110     } pools[DPNI_MAX_DPBP];
0111 };
0112 
0113 int dpni_set_pools(struct fsl_mc_io     *mc_io,
0114            u32              cmd_flags,
0115            u16              token,
0116            const struct dpni_pools_cfg  *cfg);
0117 
0118 int dpni_enable(struct fsl_mc_io    *mc_io,
0119         u32         cmd_flags,
0120         u16         token);
0121 
0122 int dpni_disable(struct fsl_mc_io   *mc_io,
0123          u32            cmd_flags,
0124          u16            token);
0125 
0126 int dpni_is_enabled(struct fsl_mc_io    *mc_io,
0127             u32         cmd_flags,
0128             u16         token,
0129             int         *en);
0130 
0131 int dpni_reset(struct fsl_mc_io *mc_io,
0132            u32      cmd_flags,
0133            u16      token);
0134 
0135 /* DPNI IRQ Index and Events */
0136 
0137 #define DPNI_IRQ_INDEX              0
0138 
0139 /* DPNI_IRQ_EVENT_LINK_CHANGED - indicates a change in link state */
0140 #define DPNI_IRQ_EVENT_LINK_CHANGED     0x00000001
0141 
0142 /* DPNI_IRQ_EVENT_ENDPOINT_CHANGED - indicates a change in endpoint */
0143 #define DPNI_IRQ_EVENT_ENDPOINT_CHANGED     0x00000002
0144 
0145 int dpni_set_irq_enable(struct fsl_mc_io    *mc_io,
0146             u32         cmd_flags,
0147             u16         token,
0148             u8          irq_index,
0149             u8          en);
0150 
0151 int dpni_get_irq_enable(struct fsl_mc_io    *mc_io,
0152             u32         cmd_flags,
0153             u16         token,
0154             u8          irq_index,
0155             u8          *en);
0156 
0157 int dpni_set_irq_mask(struct fsl_mc_io  *mc_io,
0158               u32       cmd_flags,
0159               u16       token,
0160               u8        irq_index,
0161               u32       mask);
0162 
0163 int dpni_get_irq_mask(struct fsl_mc_io  *mc_io,
0164               u32       cmd_flags,
0165               u16       token,
0166               u8        irq_index,
0167               u32       *mask);
0168 
0169 int dpni_get_irq_status(struct fsl_mc_io    *mc_io,
0170             u32         cmd_flags,
0171             u16         token,
0172             u8          irq_index,
0173             u32         *status);
0174 
0175 int dpni_clear_irq_status(struct fsl_mc_io  *mc_io,
0176               u32           cmd_flags,
0177               u16           token,
0178               u8            irq_index,
0179               u32           status);
0180 
0181 /**
0182  * struct dpni_attr - Structure representing DPNI attributes
0183  * @options: Any combination of the following options:
0184  *      DPNI_OPT_TX_FRM_RELEASE
0185  *      DPNI_OPT_NO_MAC_FILTER
0186  *      DPNI_OPT_HAS_POLICING
0187  *      DPNI_OPT_SHARED_CONGESTION
0188  *      DPNI_OPT_HAS_KEY_MASKING
0189  *      DPNI_OPT_NO_FS
0190  * @num_queues: Number of Tx and Rx queues used for traffic distribution.
0191  * @num_tcs: Number of traffic classes (TCs), reserved for the DPNI.
0192  * @mac_filter_entries: Number of entries in the MAC address filtering table.
0193  * @vlan_filter_entries: Number of entries in the VLAN address filtering table.
0194  * @qos_entries: Number of entries in the QoS classification table.
0195  * @fs_entries: Number of entries in the flow steering table.
0196  * @qos_key_size: Size, in bytes, of the QoS look-up key. Defining a key larger
0197  *      than this when adding QoS entries will result in an error.
0198  * @fs_key_size: Size, in bytes, of the flow steering look-up key. Defining a
0199  *      key larger than this when composing the hash + FS key will
0200  *      result in an error.
0201  * @wriop_version: Version of WRIOP HW block. The 3 version values are stored
0202  *      on 6, 5, 5 bits respectively.
0203  */
0204 struct dpni_attr {
0205     u32 options;
0206     u8 num_queues;
0207     u8 num_tcs;
0208     u8 mac_filter_entries;
0209     u8 vlan_filter_entries;
0210     u8 qos_entries;
0211     u16 fs_entries;
0212     u8 qos_key_size;
0213     u8 fs_key_size;
0214     u16 wriop_version;
0215 };
0216 
0217 int dpni_get_attributes(struct fsl_mc_io    *mc_io,
0218             u32         cmd_flags,
0219             u16         token,
0220             struct dpni_attr    *attr);
0221 
0222 /* DPNI errors */
0223 
0224 /**
0225  * DPNI_ERROR_EOFHE - Extract out of frame header error
0226  */
0227 #define DPNI_ERROR_EOFHE    0x00020000
0228 /**
0229  * DPNI_ERROR_FLE - Frame length error
0230  */
0231 #define DPNI_ERROR_FLE      0x00002000
0232 /**
0233  * DPNI_ERROR_FPE - Frame physical error
0234  */
0235 #define DPNI_ERROR_FPE      0x00001000
0236 /**
0237  * DPNI_ERROR_PHE - Parsing header error
0238  */
0239 #define DPNI_ERROR_PHE      0x00000020
0240 /**
0241  * DPNI_ERROR_L3CE - Parser L3 checksum error
0242  */
0243 #define DPNI_ERROR_L3CE     0x00000004
0244 /**
0245  * DPNI_ERROR_L4CE - Parser L3 checksum error
0246  */
0247 #define DPNI_ERROR_L4CE     0x00000001
0248 
0249 /**
0250  * enum dpni_error_action - Defines DPNI behavior for errors
0251  * @DPNI_ERROR_ACTION_DISCARD: Discard the frame
0252  * @DPNI_ERROR_ACTION_CONTINUE: Continue with the normal flow
0253  * @DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE: Send the frame to the error queue
0254  */
0255 enum dpni_error_action {
0256     DPNI_ERROR_ACTION_DISCARD = 0,
0257     DPNI_ERROR_ACTION_CONTINUE = 1,
0258     DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE = 2
0259 };
0260 
0261 /**
0262  * struct dpni_error_cfg - Structure representing DPNI errors treatment
0263  * @errors: Errors mask; use 'DPNI_ERROR__<X>
0264  * @error_action: The desired action for the errors mask
0265  * @set_frame_annotation: Set to '1' to mark the errors in frame annotation
0266  *      status (FAS); relevant only for the non-discard action
0267  */
0268 struct dpni_error_cfg {
0269     u32         errors;
0270     enum dpni_error_action  error_action;
0271     int         set_frame_annotation;
0272 };
0273 
0274 int dpni_set_errors_behavior(struct fsl_mc_io       *mc_io,
0275                  u32            cmd_flags,
0276                  u16            token,
0277                  struct dpni_error_cfg  *cfg);
0278 
0279 /* DPNI buffer layout modification options */
0280 
0281 /**
0282  * DPNI_BUF_LAYOUT_OPT_TIMESTAMP - Select to modify the time-stamp setting
0283  */
0284 #define DPNI_BUF_LAYOUT_OPT_TIMESTAMP       0x00000001
0285 /**
0286  * DPNI_BUF_LAYOUT_OPT_PARSER_RESULT - Select to modify the parser-result
0287  * setting; not applicable for Tx
0288  */
0289 #define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT   0x00000002
0290 /**
0291  * DPNI_BUF_LAYOUT_OPT_FRAME_STATUS - Select to modify the frame-status setting
0292  */
0293 #define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS    0x00000004
0294 /**
0295  * DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE - Select to modify the private-data-size setting
0296  */
0297 #define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE   0x00000008
0298 /**
0299  * DPNI_BUF_LAYOUT_OPT_DATA_ALIGN - Select to modify the data-alignment setting
0300  */
0301 #define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN      0x00000010
0302 /**
0303  * DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM - Select to modify the data-head-room setting
0304  */
0305 #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM  0x00000020
0306 /**
0307  * DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM - Select to modify the data-tail-room setting
0308  */
0309 #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM  0x00000040
0310 
0311 /**
0312  * struct dpni_buffer_layout - Structure representing DPNI buffer layout
0313  * @options: Flags representing the suggested modifications to the buffer
0314  *      layout; Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
0315  * @pass_timestamp: Pass timestamp value
0316  * @pass_parser_result: Pass parser results
0317  * @pass_frame_status: Pass frame status
0318  * @private_data_size: Size kept for private data (in bytes)
0319  * @data_align: Data alignment
0320  * @data_head_room: Data head room
0321  * @data_tail_room: Data tail room
0322  */
0323 struct dpni_buffer_layout {
0324     u32 options;
0325     int pass_timestamp;
0326     int pass_parser_result;
0327     int pass_frame_status;
0328     u16 private_data_size;
0329     u16 data_align;
0330     u16 data_head_room;
0331     u16 data_tail_room;
0332 };
0333 
0334 /**
0335  * enum dpni_queue_type - Identifies a type of queue targeted by the command
0336  * @DPNI_QUEUE_RX: Rx queue
0337  * @DPNI_QUEUE_TX: Tx queue
0338  * @DPNI_QUEUE_TX_CONFIRM: Tx confirmation queue
0339  * @DPNI_QUEUE_RX_ERR: Rx error queue
0340  */
0341 enum dpni_queue_type {
0342     DPNI_QUEUE_RX,
0343     DPNI_QUEUE_TX,
0344     DPNI_QUEUE_TX_CONFIRM,
0345     DPNI_QUEUE_RX_ERR,
0346 };
0347 
0348 int dpni_get_buffer_layout(struct fsl_mc_io     *mc_io,
0349                u32              cmd_flags,
0350                u16              token,
0351                enum dpni_queue_type     qtype,
0352                struct dpni_buffer_layout    *layout);
0353 
0354 int dpni_set_buffer_layout(struct fsl_mc_io        *mc_io,
0355                u32                 cmd_flags,
0356                u16                 token,
0357                enum dpni_queue_type        qtype,
0358                const struct dpni_buffer_layout *layout);
0359 
0360 /**
0361  * enum dpni_offload - Identifies a type of offload targeted by the command
0362  * @DPNI_OFF_RX_L3_CSUM: Rx L3 checksum validation
0363  * @DPNI_OFF_RX_L4_CSUM: Rx L4 checksum validation
0364  * @DPNI_OFF_TX_L3_CSUM: Tx L3 checksum generation
0365  * @DPNI_OFF_TX_L4_CSUM: Tx L4 checksum generation
0366  */
0367 enum dpni_offload {
0368     DPNI_OFF_RX_L3_CSUM,
0369     DPNI_OFF_RX_L4_CSUM,
0370     DPNI_OFF_TX_L3_CSUM,
0371     DPNI_OFF_TX_L4_CSUM,
0372 };
0373 
0374 int dpni_set_offload(struct fsl_mc_io   *mc_io,
0375              u32        cmd_flags,
0376              u16        token,
0377              enum dpni_offload  type,
0378              u32        config);
0379 
0380 int dpni_get_offload(struct fsl_mc_io   *mc_io,
0381              u32        cmd_flags,
0382              u16        token,
0383              enum dpni_offload  type,
0384              u32        *config);
0385 
0386 int dpni_get_qdid(struct fsl_mc_io  *mc_io,
0387           u32           cmd_flags,
0388           u16           token,
0389           enum dpni_queue_type  qtype,
0390           u16           *qdid);
0391 
0392 int dpni_get_tx_data_offset(struct fsl_mc_io    *mc_io,
0393                 u32         cmd_flags,
0394                 u16         token,
0395                 u16         *data_offset);
0396 
0397 #define DPNI_STATISTICS_CNT     7
0398 
0399 /**
0400  * union dpni_statistics - Union describing the DPNI statistics
0401  * @page_0: Page_0 statistics structure
0402  * @page_0.ingress_all_frames: Ingress frame count
0403  * @page_0.ingress_all_bytes: Ingress byte count
0404  * @page_0.ingress_multicast_frames: Ingress multicast frame count
0405  * @page_0.ingress_multicast_bytes: Ingress multicast byte count
0406  * @page_0.ingress_broadcast_frames: Ingress broadcast frame count
0407  * @page_0.ingress_broadcast_bytes: Ingress broadcast byte count
0408  * @page_1: Page_1 statistics structure
0409  * @page_1.egress_all_frames: Egress frame count
0410  * @page_1.egress_all_bytes: Egress byte count
0411  * @page_1.egress_multicast_frames: Egress multicast frame count
0412  * @page_1.egress_multicast_bytes: Egress multicast byte count
0413  * @page_1.egress_broadcast_frames: Egress broadcast frame count
0414  * @page_1.egress_broadcast_bytes: Egress broadcast byte count
0415  * @page_2: Page_2 statistics structure
0416  * @page_2.ingress_filtered_frames: Ingress filtered frame count
0417  * @page_2.ingress_discarded_frames: Ingress discarded frame count
0418  * @page_2.ingress_nobuffer_discards: Ingress discarded frame count due to
0419  *  lack of buffers
0420  * @page_2.egress_discarded_frames: Egress discarded frame count
0421  * @page_2.egress_confirmed_frames: Egress confirmed frame count
0422  * @page_3: Page_3 statistics structure
0423  * @page_3.egress_dequeue_bytes: Cumulative count of the number of bytes
0424  *  dequeued from egress FQs
0425  * @page_3.egress_dequeue_frames: Cumulative count of the number of frames
0426  *  dequeued from egress FQs
0427  * @page_3.egress_reject_bytes: Cumulative count of the number of bytes in
0428  *  egress frames whose enqueue was rejected
0429  * @page_3.egress_reject_frames: Cumulative count of the number of egress
0430  *  frames whose enqueue was rejected
0431  * @page_4: Page_4 statistics structure: congestion points
0432  * @page_4.cgr_reject_frames: number of rejected frames due to congestion point
0433  * @page_4.cgr_reject_bytes: number of rejected bytes due to congestion point
0434  * @page_5: Page_5 statistics structure: policer
0435  * @page_5.policer_cnt_red: NUmber of red colored frames
0436  * @page_5.policer_cnt_yellow: number of yellow colored frames
0437  * @page_5.policer_cnt_green: number of green colored frames
0438  * @page_5.policer_cnt_re_red: number of recolored red frames
0439  * @page_5.policer_cnt_re_yellow: number of recolored yellow frames
0440  * @page_6: Page_6 statistics structure
0441  * @page_6.tx_pending_frames: total number of frames pending in egress FQs
0442  * @raw: raw statistics structure, used to index counters
0443  */
0444 union dpni_statistics {
0445     struct {
0446         u64 ingress_all_frames;
0447         u64 ingress_all_bytes;
0448         u64 ingress_multicast_frames;
0449         u64 ingress_multicast_bytes;
0450         u64 ingress_broadcast_frames;
0451         u64 ingress_broadcast_bytes;
0452     } page_0;
0453     struct {
0454         u64 egress_all_frames;
0455         u64 egress_all_bytes;
0456         u64 egress_multicast_frames;
0457         u64 egress_multicast_bytes;
0458         u64 egress_broadcast_frames;
0459         u64 egress_broadcast_bytes;
0460     } page_1;
0461     struct {
0462         u64 ingress_filtered_frames;
0463         u64 ingress_discarded_frames;
0464         u64 ingress_nobuffer_discards;
0465         u64 egress_discarded_frames;
0466         u64 egress_confirmed_frames;
0467     } page_2;
0468     struct {
0469         u64 egress_dequeue_bytes;
0470         u64 egress_dequeue_frames;
0471         u64 egress_reject_bytes;
0472         u64 egress_reject_frames;
0473     } page_3;
0474     struct {
0475         u64 cgr_reject_frames;
0476         u64 cgr_reject_bytes;
0477     } page_4;
0478     struct {
0479         u64 policer_cnt_red;
0480         u64 policer_cnt_yellow;
0481         u64 policer_cnt_green;
0482         u64 policer_cnt_re_red;
0483         u64 policer_cnt_re_yellow;
0484     } page_5;
0485     struct {
0486         u64 tx_pending_frames;
0487     } page_6;
0488     struct {
0489         u64 counter[DPNI_STATISTICS_CNT];
0490     } raw;
0491 };
0492 
0493 int dpni_get_statistics(struct fsl_mc_io    *mc_io,
0494             u32         cmd_flags,
0495             u16         token,
0496             u8          page,
0497             union dpni_statistics   *stat);
0498 
0499 #define DPNI_LINK_OPT_AUTONEG       0x0000000000000001ULL
0500 #define DPNI_LINK_OPT_HALF_DUPLEX   0x0000000000000002ULL
0501 #define DPNI_LINK_OPT_PAUSE     0x0000000000000004ULL
0502 #define DPNI_LINK_OPT_ASYM_PAUSE    0x0000000000000008ULL
0503 #define DPNI_LINK_OPT_PFC_PAUSE     0x0000000000000010ULL
0504 
0505 /**
0506  * struct dpni_link_cfg - Structure representing DPNI link configuration
0507  * @rate: Rate
0508  * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
0509  */
0510 struct dpni_link_cfg {
0511     u32 rate;
0512     u64 options;
0513 };
0514 
0515 int dpni_set_link_cfg(struct fsl_mc_io          *mc_io,
0516               u32               cmd_flags,
0517               u16               token,
0518               const struct dpni_link_cfg    *cfg);
0519 
0520 int dpni_get_link_cfg(struct fsl_mc_io          *mc_io,
0521               u32               cmd_flags,
0522               u16               token,
0523               struct dpni_link_cfg      *cfg);
0524 
0525 /**
0526  * struct dpni_link_state - Structure representing DPNI link state
0527  * @rate: Rate
0528  * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
0529  * @up: Link state; '0' for down, '1' for up
0530  */
0531 struct dpni_link_state {
0532     u32 rate;
0533     u64 options;
0534     int up;
0535 };
0536 
0537 int dpni_get_link_state(struct fsl_mc_io    *mc_io,
0538             u32         cmd_flags,
0539             u16         token,
0540             struct dpni_link_state  *state);
0541 
0542 int dpni_set_max_frame_length(struct fsl_mc_io  *mc_io,
0543                   u32       cmd_flags,
0544                   u16       token,
0545                   u16       max_frame_length);
0546 
0547 int dpni_get_max_frame_length(struct fsl_mc_io  *mc_io,
0548                   u32       cmd_flags,
0549                   u16       token,
0550                   u16       *max_frame_length);
0551 
0552 int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io,
0553                    u32      cmd_flags,
0554                    u16      token,
0555                    int      en);
0556 
0557 int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io,
0558                    u32      cmd_flags,
0559                    u16      token,
0560                    int      *en);
0561 
0562 int dpni_set_unicast_promisc(struct fsl_mc_io   *mc_io,
0563                  u32        cmd_flags,
0564                  u16        token,
0565                  int        en);
0566 
0567 int dpni_get_unicast_promisc(struct fsl_mc_io   *mc_io,
0568                  u32        cmd_flags,
0569                  u16        token,
0570                  int        *en);
0571 
0572 int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
0573                   u32       cmd_flags,
0574                   u16       token,
0575                   const u8      mac_addr[6]);
0576 
0577 int dpni_get_primary_mac_addr(struct fsl_mc_io  *mc_io,
0578                   u32       cmd_flags,
0579                   u16       token,
0580                   u8        mac_addr[6]);
0581 
0582 int dpni_get_port_mac_addr(struct fsl_mc_io *mc_io,
0583                u32          cm_flags,
0584                u16          token,
0585                u8           mac_addr[6]);
0586 
0587 int dpni_add_mac_addr(struct fsl_mc_io  *mc_io,
0588               u32       cmd_flags,
0589               u16       token,
0590               const u8      mac_addr[6]);
0591 
0592 int dpni_remove_mac_addr(struct fsl_mc_io   *mc_io,
0593              u32            cmd_flags,
0594              u16            token,
0595              const u8       mac_addr[6]);
0596 
0597 int dpni_clear_mac_filters(struct fsl_mc_io *mc_io,
0598                u32          cmd_flags,
0599                u16          token,
0600                int          unicast,
0601                int          multicast);
0602 
0603 /**
0604  * enum dpni_dist_mode - DPNI distribution mode
0605  * @DPNI_DIST_MODE_NONE: No distribution
0606  * @DPNI_DIST_MODE_HASH: Use hash distribution; only relevant if
0607  *      the 'DPNI_OPT_DIST_HASH' option was set at DPNI creation
0608  * @DPNI_DIST_MODE_FS:  Use explicit flow steering; only relevant if
0609  *   the 'DPNI_OPT_DIST_FS' option was set at DPNI creation
0610  */
0611 enum dpni_dist_mode {
0612     DPNI_DIST_MODE_NONE = 0,
0613     DPNI_DIST_MODE_HASH = 1,
0614     DPNI_DIST_MODE_FS = 2
0615 };
0616 
0617 /**
0618  * enum dpni_fs_miss_action -   DPNI Flow Steering miss action
0619  * @DPNI_FS_MISS_DROP: In case of no-match, drop the frame
0620  * @DPNI_FS_MISS_EXPLICIT_FLOWID: In case of no-match, use explicit flow-id
0621  * @DPNI_FS_MISS_HASH: In case of no-match, distribute using hash
0622  */
0623 enum dpni_fs_miss_action {
0624     DPNI_FS_MISS_DROP = 0,
0625     DPNI_FS_MISS_EXPLICIT_FLOWID = 1,
0626     DPNI_FS_MISS_HASH = 2
0627 };
0628 
0629 /**
0630  * struct dpni_fs_tbl_cfg - Flow Steering table configuration
0631  * @miss_action: Miss action selection
0632  * @default_flow_id: Used when 'miss_action = DPNI_FS_MISS_EXPLICIT_FLOWID'
0633  */
0634 struct dpni_fs_tbl_cfg {
0635     enum dpni_fs_miss_action    miss_action;
0636     u16             default_flow_id;
0637 };
0638 
0639 int dpni_prepare_key_cfg(const struct dpkg_profile_cfg *cfg,
0640              u8 *key_cfg_buf);
0641 
0642 /**
0643  * struct dpni_rx_tc_dist_cfg - Rx traffic class distribution configuration
0644  * @dist_size: Set the distribution size;
0645  *  supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
0646  *  112,128,192,224,256,384,448,512,768,896,1024
0647  * @dist_mode: Distribution mode
0648  * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
0649  *      the extractions to be used for the distribution key by calling
0650  *      dpni_prepare_key_cfg() relevant only when
0651  *      'dist_mode != DPNI_DIST_MODE_NONE', otherwise it can be '0'
0652  * @fs_cfg: Flow Steering table configuration; only relevant if
0653  *      'dist_mode = DPNI_DIST_MODE_FS'
0654  */
0655 struct dpni_rx_tc_dist_cfg {
0656     u16         dist_size;
0657     enum dpni_dist_mode dist_mode;
0658     u64         key_cfg_iova;
0659     struct dpni_fs_tbl_cfg  fs_cfg;
0660 };
0661 
0662 int dpni_set_rx_tc_dist(struct fsl_mc_io            *mc_io,
0663             u32                 cmd_flags,
0664             u16                 token,
0665             u8                  tc_id,
0666             const struct dpni_rx_tc_dist_cfg    *cfg);
0667 
0668 /**
0669  * DPNI_FS_MISS_DROP - When used for fs_miss_flow_id in function
0670  * dpni_set_rx_dist, will signal to dpni to drop all unclassified frames
0671  */
0672 #define DPNI_FS_MISS_DROP       ((uint16_t)-1)
0673 
0674 /**
0675  * struct dpni_rx_dist_cfg - Rx distribution configuration
0676  * @dist_size:  distribution size
0677  * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
0678  *      the extractions to be used for the distribution key by calling
0679  *      dpni_prepare_key_cfg(); relevant only when enable!=0 otherwise
0680  *      it can be '0'
0681  * @enable: enable/disable the distribution.
0682  * @tc: TC id for which distribution is set
0683  * @fs_miss_flow_id: when packet misses all rules from flow steering table and
0684  *      hash is disabled it will be put into this queue id; use
0685  *      DPNI_FS_MISS_DROP to drop frames. The value of this field is
0686  *      used only when flow steering distribution is enabled and hash
0687  *      distribution is disabled
0688  */
0689 struct dpni_rx_dist_cfg {
0690     u16 dist_size;
0691     u64 key_cfg_iova;
0692     u8 enable;
0693     u8 tc;
0694     u16 fs_miss_flow_id;
0695 };
0696 
0697 int dpni_set_rx_fs_dist(struct fsl_mc_io *mc_io,
0698             u32 cmd_flags,
0699             u16 token,
0700             const struct dpni_rx_dist_cfg *cfg);
0701 
0702 int dpni_set_rx_hash_dist(struct fsl_mc_io *mc_io,
0703               u32 cmd_flags,
0704               u16 token,
0705               const struct dpni_rx_dist_cfg *cfg);
0706 
0707 /**
0708  * struct dpni_qos_tbl_cfg - Structure representing QOS table configuration
0709  * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
0710  *      key extractions to be used as the QoS criteria by calling
0711  *      dpkg_prepare_key_cfg()
0712  * @discard_on_miss: Set to '1' to discard frames in case of no match (miss);
0713  *      '0' to use the 'default_tc' in such cases
0714  * @default_tc: Used in case of no-match and 'discard_on_miss'= 0
0715  */
0716 struct dpni_qos_tbl_cfg {
0717     u64 key_cfg_iova;
0718     int discard_on_miss;
0719     u8 default_tc;
0720 };
0721 
0722 int dpni_set_qos_table(struct fsl_mc_io *mc_io,
0723                u32 cmd_flags,
0724                u16 token,
0725                const struct dpni_qos_tbl_cfg *cfg);
0726 
0727 /**
0728  * enum dpni_dest - DPNI destination types
0729  * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
0730  *      does not generate FQDAN notifications; user is expected to
0731  *      dequeue from the queue based on polling or other user-defined
0732  *      method
0733  * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
0734  *      notifications to the specified DPIO; user is expected to dequeue
0735  *      from the queue only after notification is received
0736  * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
0737  *      FQDAN notifications, but is connected to the specified DPCON
0738  *      object; user is expected to dequeue from the DPCON channel
0739  */
0740 enum dpni_dest {
0741     DPNI_DEST_NONE = 0,
0742     DPNI_DEST_DPIO = 1,
0743     DPNI_DEST_DPCON = 2
0744 };
0745 
0746 /**
0747  * struct dpni_queue - Queue structure
0748  * @destination: - Destination structure
0749  * @destination.id: ID of the destination, only relevant if DEST_TYPE is > 0.
0750  *  Identifies either a DPIO or a DPCON object.
0751  *  Not relevant for Tx queues.
0752  * @destination.type:   May be one of the following:
0753  *  0 - No destination, queue can be manually
0754  *      queried, but will not push traffic or
0755  *      notifications to a DPIO;
0756  *  1 - The destination is a DPIO. When traffic
0757  *      becomes available in the queue a FQDAN
0758  *      (FQ data available notification) will be
0759  *      generated to selected DPIO;
0760  *  2 - The destination is a DPCON. The queue is
0761  *      associated with a DPCON object for the
0762  *      purpose of scheduling between multiple
0763  *      queues. The DPCON may be independently
0764  *      configured to generate notifications.
0765  *      Not relevant for Tx queues.
0766  * @destination.hold_active: Hold active, maintains a queue scheduled for longer
0767  *  in a DPIO during dequeue to reduce spread of traffic.
0768  *  Only relevant if queues are
0769  *  not affined to a single DPIO.
0770  * @user_context: User data, presented to the user along with any frames
0771  *  from this queue. Not relevant for Tx queues.
0772  * @flc: FD FLow Context structure
0773  * @flc.value: Default FLC value for traffic dequeued from
0774  *      this queue.  Please check description of FD
0775  *      structure for more information.
0776  *      Note that FLC values set using dpni_add_fs_entry,
0777  *      if any, take precedence over values per queue.
0778  * @flc.stash_control: Boolean, indicates whether the 6 lowest
0779  *      - significant bits are used for stash control.
0780  *      significant bits are used for stash control.  If set, the 6
0781  *      least significant bits in value are interpreted as follows:
0782  *      - bits 0-1: indicates the number of 64 byte units of context
0783  *      that are stashed.  FLC value is interpreted as a memory address
0784  *      in this case, excluding the 6 LS bits.
0785  *      - bits 2-3: indicates the number of 64 byte units of frame
0786  *      annotation to be stashed.  Annotation is placed at FD[ADDR].
0787  *      - bits 4-5: indicates the number of 64 byte units of frame
0788  *      data to be stashed.  Frame data is placed at FD[ADDR] +
0789  *      FD[OFFSET].
0790  *      For more details check the Frame Descriptor section in the
0791  *      hardware documentation.
0792  */
0793 struct dpni_queue {
0794     struct {
0795         u16 id;
0796         enum dpni_dest type;
0797         char hold_active;
0798         u8 priority;
0799     } destination;
0800     u64 user_context;
0801     struct {
0802         u64 value;
0803         char stash_control;
0804     } flc;
0805 };
0806 
0807 /**
0808  * struct dpni_queue_id - Queue identification, used for enqueue commands
0809  *          or queue control
0810  * @fqid: FQID used for enqueueing to and/or configuration of this specific FQ
0811  * @qdbin: Queueing bin, used to enqueue using QDID, DQBIN, QPRI. Only relevant
0812  *      for Tx queues.
0813  */
0814 struct dpni_queue_id {
0815     u32 fqid;
0816     u16 qdbin;
0817 };
0818 
0819 /* Set User Context */
0820 #define DPNI_QUEUE_OPT_USER_CTX     0x00000001
0821 #define DPNI_QUEUE_OPT_DEST     0x00000002
0822 #define DPNI_QUEUE_OPT_FLC      0x00000004
0823 #define DPNI_QUEUE_OPT_HOLD_ACTIVE  0x00000008
0824 
0825 int dpni_set_queue(struct fsl_mc_io *mc_io,
0826            u32          cmd_flags,
0827            u16          token,
0828            enum dpni_queue_type qtype,
0829            u8           tc,
0830            u8           index,
0831            u8           options,
0832            const struct dpni_queue *queue);
0833 
0834 int dpni_get_queue(struct fsl_mc_io *mc_io,
0835            u32          cmd_flags,
0836            u16          token,
0837            enum dpni_queue_type qtype,
0838            u8           tc,
0839            u8           index,
0840            struct dpni_queue    *queue,
0841            struct dpni_queue_id *qid);
0842 
0843 /**
0844  * enum dpni_congestion_unit - DPNI congestion units
0845  * @DPNI_CONGESTION_UNIT_BYTES: bytes units
0846  * @DPNI_CONGESTION_UNIT_FRAMES: frames units
0847  */
0848 enum dpni_congestion_unit {
0849     DPNI_CONGESTION_UNIT_BYTES = 0,
0850     DPNI_CONGESTION_UNIT_FRAMES
0851 };
0852 
0853 /**
0854  * enum dpni_congestion_point - Structure representing congestion point
0855  * @DPNI_CP_QUEUE: Set taildrop per queue, identified by QUEUE_TYPE, TC and
0856  *      QUEUE_INDEX
0857  * @DPNI_CP_GROUP: Set taildrop per queue group. Depending on options used to
0858  *      define the DPNI this can be either per TC (default) or per
0859  *      interface (DPNI_OPT_SHARED_CONGESTION set at DPNI create).
0860  *      QUEUE_INDEX is ignored if this type is used.
0861  */
0862 enum dpni_congestion_point {
0863     DPNI_CP_QUEUE,
0864     DPNI_CP_GROUP,
0865 };
0866 
0867 /**
0868  * struct dpni_dest_cfg - Structure representing DPNI destination parameters
0869  * @dest_type:  Destination type
0870  * @dest_id:    Either DPIO ID or DPCON ID, depending on the destination type
0871  * @priority:   Priority selection within the DPIO or DPCON channel; valid
0872  *      values are 0-1 or 0-7, depending on the number of priorities
0873  *      in that channel; not relevant for 'DPNI_DEST_NONE' option
0874  */
0875 struct dpni_dest_cfg {
0876     enum dpni_dest dest_type;
0877     int dest_id;
0878     u8 priority;
0879 };
0880 
0881 /* DPNI congestion options */
0882 
0883 /**
0884  * DPNI_CONG_OPT_FLOW_CONTROL - This congestion will trigger flow control or
0885  * priority flow control.  This will have effect only if flow control is
0886  * enabled with dpni_set_link_cfg().
0887  */
0888 #define DPNI_CONG_OPT_FLOW_CONTROL      0x00000040
0889 
0890 /**
0891  * struct dpni_congestion_notification_cfg - congestion notification
0892  *                  configuration
0893  * @units: Units type
0894  * @threshold_entry: Above this threshold we enter a congestion state.
0895  *      set it to '0' to disable it
0896  * @threshold_exit: Below this threshold we exit the congestion state.
0897  * @message_ctx: The context that will be part of the CSCN message
0898  * @message_iova: I/O virtual address (must be in DMA-able memory),
0899  *      must be 16B aligned; valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>'
0900  *      is contained in 'options'
0901  * @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel
0902  * @notification_mode: Mask of available options; use 'DPNI_CONG_OPT_<X>' values
0903  */
0904 
0905 struct dpni_congestion_notification_cfg {
0906     enum dpni_congestion_unit units;
0907     u32 threshold_entry;
0908     u32 threshold_exit;
0909     u64 message_ctx;
0910     u64 message_iova;
0911     struct dpni_dest_cfg dest_cfg;
0912     u16 notification_mode;
0913 };
0914 
0915 int dpni_set_congestion_notification(
0916             struct fsl_mc_io *mc_io,
0917             u32 cmd_flags,
0918             u16 token,
0919             enum dpni_queue_type qtype,
0920             u8 tc_id,
0921             const struct dpni_congestion_notification_cfg *cfg);
0922 
0923 /**
0924  * struct dpni_taildrop - Structure representing the taildrop
0925  * @enable: Indicates whether the taildrop is active or not.
0926  * @units:  Indicates the unit of THRESHOLD. Queue taildrop only supports
0927  *      byte units, this field is ignored and assumed = 0 if
0928  *      CONGESTION_POINT is 0.
0929  * @threshold:  Threshold value, in units identified by UNITS field. Value 0
0930  *      cannot be used as a valid taildrop threshold, THRESHOLD must
0931  *      be > 0 if the taildrop is enabled.
0932  */
0933 struct dpni_taildrop {
0934     char enable;
0935     enum dpni_congestion_unit units;
0936     u32 threshold;
0937 };
0938 
0939 int dpni_set_taildrop(struct fsl_mc_io *mc_io,
0940               u32 cmd_flags,
0941               u16 token,
0942               enum dpni_congestion_point cg_point,
0943               enum dpni_queue_type q_type,
0944               u8 tc,
0945               u8 q_index,
0946               struct dpni_taildrop *taildrop);
0947 
0948 int dpni_get_taildrop(struct fsl_mc_io *mc_io,
0949               u32 cmd_flags,
0950               u16 token,
0951               enum dpni_congestion_point cg_point,
0952               enum dpni_queue_type q_type,
0953               u8 tc,
0954               u8 q_index,
0955               struct dpni_taildrop *taildrop);
0956 
0957 /**
0958  * struct dpni_rule_cfg - Rule configuration for table lookup
0959  * @key_iova: I/O virtual address of the key (must be in DMA-able memory)
0960  * @mask_iova: I/O virtual address of the mask (must be in DMA-able memory)
0961  * @key_size: key and mask size (in bytes)
0962  */
0963 struct dpni_rule_cfg {
0964     u64 key_iova;
0965     u64 mask_iova;
0966     u8  key_size;
0967 };
0968 
0969 /**
0970  * DPNI_FS_OPT_DISCARD - Discard matching traffic. If set, this takes
0971  * precedence over any other configuration and matching traffic is always
0972  * discarded.
0973  */
0974  #define DPNI_FS_OPT_DISCARD            0x1
0975 
0976 /**
0977  * DPNI_FS_OPT_SET_FLC - Set FLC value. If set, flc member of struct
0978  * dpni_fs_action_cfg is used to override the FLC value set per queue.
0979  * For more details check the Frame Descriptor section in the hardware
0980  * documentation.
0981  */
0982 #define DPNI_FS_OPT_SET_FLC            0x2
0983 
0984 /**
0985  * DPNI_FS_OPT_SET_STASH_CONTROL - Indicates whether the 6 lowest significant
0986  * bits of FLC are used for stash control. If set, the 6 least significant bits
0987  * in value are interpreted as follows:
0988  *     - bits 0-1: indicates the number of 64 byte units of context that are
0989  *     stashed. FLC value is interpreted as a memory address in this case,
0990  *     excluding the 6 LS bits.
0991  *     - bits 2-3: indicates the number of 64 byte units of frame annotation
0992  *     to be stashed. Annotation is placed at FD[ADDR].
0993  *     - bits 4-5: indicates the number of 64 byte units of frame data to be
0994  *     stashed. Frame data is placed at FD[ADDR] + FD[OFFSET].
0995  * This flag is ignored if DPNI_FS_OPT_SET_FLC is not specified.
0996  */
0997 #define DPNI_FS_OPT_SET_STASH_CONTROL  0x4
0998 
0999 /**
1000  * struct dpni_fs_action_cfg - Action configuration for table look-up
1001  * @flc:    FLC value for traffic matching this rule. Please check the
1002  *      Frame Descriptor section in the hardware documentation for
1003  *      more information.
1004  * @flow_id:    Identifies the Rx queue used for matching traffic. Supported
1005  *      values are in range 0 to num_queue-1.
1006  * @options:    Any combination of DPNI_FS_OPT_ values.
1007  */
1008 struct dpni_fs_action_cfg {
1009     u64 flc;
1010     u16 flow_id;
1011     u16 options;
1012 };
1013 
1014 int dpni_add_fs_entry(struct fsl_mc_io *mc_io,
1015               u32 cmd_flags,
1016               u16 token,
1017               u8 tc_id,
1018               u16 index,
1019               const struct dpni_rule_cfg *cfg,
1020               const struct dpni_fs_action_cfg *action);
1021 
1022 int dpni_remove_fs_entry(struct fsl_mc_io *mc_io,
1023              u32 cmd_flags,
1024              u16 token,
1025              u8 tc_id,
1026              const struct dpni_rule_cfg *cfg);
1027 
1028 int dpni_add_qos_entry(struct fsl_mc_io *mc_io,
1029                u32 cmd_flags,
1030                u16 token,
1031                const struct dpni_rule_cfg *cfg,
1032                u8 tc_id,
1033                u16 index);
1034 
1035 int dpni_remove_qos_entry(struct fsl_mc_io *mc_io,
1036               u32 cmd_flags,
1037               u16 token,
1038               const struct dpni_rule_cfg *cfg);
1039 
1040 int dpni_clear_qos_table(struct fsl_mc_io *mc_io,
1041              u32 cmd_flags,
1042              u16 token);
1043 
1044 int dpni_get_api_version(struct fsl_mc_io *mc_io,
1045              u32 cmd_flags,
1046              u16 *major_ver,
1047              u16 *minor_ver);
1048 /**
1049  * struct dpni_tx_shaping_cfg - Structure representing DPNI tx shaping configuration
1050  * @rate_limit:     Rate in Mbps
1051  * @max_burst_size: Burst size in bytes (up to 64KB)
1052  */
1053 struct dpni_tx_shaping_cfg {
1054     u32 rate_limit;
1055     u16 max_burst_size;
1056 };
1057 
1058 int dpni_set_tx_shaping(struct fsl_mc_io *mc_io,
1059             u32 cmd_flags,
1060             u16 token,
1061             const struct dpni_tx_shaping_cfg *tx_cr_shaper,
1062             const struct dpni_tx_shaping_cfg *tx_er_shaper,
1063             int coupled);
1064 
1065 /**
1066  * struct dpni_single_step_cfg - configure single step PTP (IEEE 1588)
1067  * @en:     enable single step PTP. When enabled the PTPv1 functionality
1068  *      will not work. If the field is zero, offset and ch_update
1069  *      parameters will be ignored
1070  * @offset: start offset from the beginning of the frame where
1071  *      timestamp field is found. The offset must respect all MAC
1072  *      headers, VLAN tags and other protocol headers
1073  * @ch_update:  when set UDP checksum will be updated inside packet
1074  * @peer_delay: For peer-to-peer transparent clocks add this value to the
1075  *      correction field in addition to the transient time update.
1076  *      The value expresses nanoseconds.
1077  * @ptp_onestep_reg_base: 1588 SINGLE_STEP register base address. This address
1078  *            is used to update directly the register contents.
1079  *            User has to create an address mapping for it.
1080  *
1081  *
1082  */
1083 struct dpni_single_step_cfg {
1084     u8  en;
1085     u8  ch_update;
1086     u16 offset;
1087     u32 peer_delay;
1088     u32 ptp_onestep_reg_base;
1089 };
1090 
1091 int dpni_set_single_step_cfg(struct fsl_mc_io *mc_io,
1092                  u32 cmd_flags,
1093                  u16 token,
1094                  struct dpni_single_step_cfg *ptp_cfg);
1095 
1096 int dpni_get_single_step_cfg(struct fsl_mc_io *mc_io,
1097                  u32 cmd_flags,
1098                  u16 token,
1099                  struct dpni_single_step_cfg *ptp_cfg);
1100 
1101 int dpni_enable_vlan_filter(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
1102                 u32 en);
1103 
1104 int dpni_add_vlan_id(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
1105              u16 vlan_id, u8 flags, u8 tc_id, u8 flow_id);
1106 
1107 int dpni_remove_vlan_id(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
1108             u16 vlan_id);
1109 
1110 #endif /* __FSL_DPNI_H */