root/drivers/net/ethernet/freescale/dpaa2/dpni.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
   2 /* Copyright 2013-2016 Freescale Semiconductor Inc.
   3  * Copyright 2016 NXP
   4  */
   5 #ifndef __FSL_DPNI_H
   6 #define __FSL_DPNI_H
   7 
   8 #include "dpkg.h"
   9 
  10 struct fsl_mc_io;
  11 
  12 /**
  13  * Data Path Network Interface API
  14  * Contains initialization APIs and runtime control APIs for DPNI
  15  */
  16 
  17 /** General DPNI macros */
  18 
  19 /**
  20  * Maximum number of traffic classes
  21  */
  22 #define DPNI_MAX_TC                             8
  23 /**
  24  * Maximum number of buffer pools per DPNI
  25  */
  26 #define DPNI_MAX_DPBP                           8
  27 
  28 /**
  29  * All traffic classes considered; see dpni_set_queue()
  30  */
  31 #define DPNI_ALL_TCS                            (u8)(-1)
  32 /**
  33  * All flows within traffic class considered; see dpni_set_queue()
  34  */
  35 #define DPNI_ALL_TC_FLOWS                       (u16)(-1)
  36 /**
  37  * Generate new flow ID; see dpni_set_queue()
  38  */
  39 #define DPNI_NEW_FLOW_ID                        (u16)(-1)
  40 
  41 /**
  42  * Tx traffic is always released to a buffer pool on transmit, there are no
  43  * resources allocated to have the frames confirmed back to the source after
  44  * transmission.
  45  */
  46 #define DPNI_OPT_TX_FRM_RELEASE                 0x000001
  47 /**
  48  * Disables support for MAC address filtering for addresses other than primary
  49  * MAC address. This affects both unicast and multicast. Promiscuous mode can
  50  * still be enabled/disabled for both unicast and multicast. If promiscuous mode
  51  * is disabled, only traffic matching the primary MAC address will be accepted.
  52  */
  53 #define DPNI_OPT_NO_MAC_FILTER                  0x000002
  54 /**
  55  * Allocate policers for this DPNI. They can be used to rate-limit traffic per
  56  * traffic class (TC) basis.
  57  */
  58 #define DPNI_OPT_HAS_POLICING                   0x000004
  59 /**
  60  * Congestion can be managed in several ways, allowing the buffer pool to
  61  * deplete on ingress, taildrop on each queue or use congestion groups for sets
  62  * of queues. If set, it configures a single congestion groups across all TCs.
  63  * If reset, a congestion group is allocated for each TC. Only relevant if the
  64  * DPNI has multiple traffic classes.
  65  */
  66 #define DPNI_OPT_SHARED_CONGESTION              0x000008
  67 /**
  68  * Enables TCAM for Flow Steering and QoS look-ups. If not specified, all
  69  * look-ups are exact match. Note that TCAM is not available on LS1088 and its
  70  * variants. Setting this bit on these SoCs will trigger an error.
  71  */
  72 #define DPNI_OPT_HAS_KEY_MASKING                0x000010
  73 /**
  74  * Disables the flow steering table.
  75  */
  76 #define DPNI_OPT_NO_FS                          0x000020
  77 
  78 int dpni_open(struct fsl_mc_io  *mc_io,
  79               u32               cmd_flags,
  80               int               dpni_id,
  81               u16               *token);
  82 
  83 int dpni_close(struct fsl_mc_io *mc_io,
  84                u32              cmd_flags,
  85                u16              token);
  86 
  87 /**
  88  * struct dpni_pools_cfg - Structure representing buffer pools configuration
  89  * @num_dpbp: Number of DPBPs
  90  * @pools: Array of buffer pools parameters; The number of valid entries
  91  *      must match 'num_dpbp' value
  92  * @pools.dpbp_id: DPBP object ID
  93  * @pools.buffer_size: Buffer size
  94  * @pools.backup_pool: Backup pool
  95  */
  96 struct dpni_pools_cfg {
  97         u8              num_dpbp;
  98         struct {
  99                 int     dpbp_id;
 100                 u16     buffer_size;
 101                 int     backup_pool;
 102         } pools[DPNI_MAX_DPBP];
 103 };
 104 
 105 int dpni_set_pools(struct fsl_mc_io             *mc_io,
 106                    u32                          cmd_flags,
 107                    u16                          token,
 108                    const struct dpni_pools_cfg  *cfg);
 109 
 110 int dpni_enable(struct fsl_mc_io        *mc_io,
 111                 u32                     cmd_flags,
 112                 u16                     token);
 113 
 114 int dpni_disable(struct fsl_mc_io       *mc_io,
 115                  u32                    cmd_flags,
 116                  u16                    token);
 117 
 118 int dpni_is_enabled(struct fsl_mc_io    *mc_io,
 119                     u32                 cmd_flags,
 120                     u16                 token,
 121                     int                 *en);
 122 
 123 int dpni_reset(struct fsl_mc_io *mc_io,
 124                u32              cmd_flags,
 125                u16              token);
 126 
 127 /**
 128  * DPNI IRQ Index and Events
 129  */
 130 
 131 /**
 132  * IRQ index
 133  */
 134 #define DPNI_IRQ_INDEX                          0
 135 /**
 136  * IRQ events:
 137  *       indicates a change in link state
 138  *       indicates a change in endpoint
 139  */
 140 #define DPNI_IRQ_EVENT_LINK_CHANGED             0x00000001
 141 #define DPNI_IRQ_EVENT_ENDPOINT_CHANGED         0x00000002
 142 
 143 int dpni_set_irq_enable(struct fsl_mc_io        *mc_io,
 144                         u32                     cmd_flags,
 145                         u16                     token,
 146                         u8                      irq_index,
 147                         u8                      en);
 148 
 149 int dpni_get_irq_enable(struct fsl_mc_io        *mc_io,
 150                         u32                     cmd_flags,
 151                         u16                     token,
 152                         u8                      irq_index,
 153                         u8                      *en);
 154 
 155 int dpni_set_irq_mask(struct fsl_mc_io  *mc_io,
 156                       u32               cmd_flags,
 157                       u16               token,
 158                       u8                irq_index,
 159                       u32               mask);
 160 
 161 int dpni_get_irq_mask(struct fsl_mc_io  *mc_io,
 162                       u32               cmd_flags,
 163                       u16               token,
 164                       u8                irq_index,
 165                       u32               *mask);
 166 
 167 int dpni_get_irq_status(struct fsl_mc_io        *mc_io,
 168                         u32                     cmd_flags,
 169                         u16                     token,
 170                         u8                      irq_index,
 171                         u32                     *status);
 172 
 173 int dpni_clear_irq_status(struct fsl_mc_io      *mc_io,
 174                           u32                   cmd_flags,
 175                           u16                   token,
 176                           u8                    irq_index,
 177                           u32                   status);
 178 
 179 /**
 180  * struct dpni_attr - Structure representing DPNI attributes
 181  * @options: Any combination of the following options:
 182  *              DPNI_OPT_TX_FRM_RELEASE
 183  *              DPNI_OPT_NO_MAC_FILTER
 184  *              DPNI_OPT_HAS_POLICING
 185  *              DPNI_OPT_SHARED_CONGESTION
 186  *              DPNI_OPT_HAS_KEY_MASKING
 187  *              DPNI_OPT_NO_FS
 188  * @num_queues: Number of Tx and Rx queues used for traffic distribution.
 189  * @num_tcs: Number of traffic classes (TCs), reserved for the DPNI.
 190  * @mac_filter_entries: Number of entries in the MAC address filtering table.
 191  * @vlan_filter_entries: Number of entries in the VLAN address filtering table.
 192  * @qos_entries: Number of entries in the QoS classification table.
 193  * @fs_entries: Number of entries in the flow steering table.
 194  * @qos_key_size: Size, in bytes, of the QoS look-up key. Defining a key larger
 195  *              than this when adding QoS entries will result in an error.
 196  * @fs_key_size: Size, in bytes, of the flow steering look-up key. Defining a
 197  *              key larger than this when composing the hash + FS key will
 198  *              result in an error.
 199  * @wriop_version: Version of WRIOP HW block. The 3 version values are stored
 200  *              on 6, 5, 5 bits respectively.
 201  */
 202 struct dpni_attr {
 203         u32 options;
 204         u8 num_queues;
 205         u8 num_tcs;
 206         u8 mac_filter_entries;
 207         u8 vlan_filter_entries;
 208         u8 qos_entries;
 209         u16 fs_entries;
 210         u8 qos_key_size;
 211         u8 fs_key_size;
 212         u16 wriop_version;
 213 };
 214 
 215 int dpni_get_attributes(struct fsl_mc_io        *mc_io,
 216                         u32                     cmd_flags,
 217                         u16                     token,
 218                         struct dpni_attr        *attr);
 219 
 220 /**
 221  * DPNI errors
 222  */
 223 
 224 /**
 225  * Extract out of frame header error
 226  */
 227 #define DPNI_ERROR_EOFHE        0x00020000
 228 /**
 229  * Frame length error
 230  */
 231 #define DPNI_ERROR_FLE          0x00002000
 232 /**
 233  * Frame physical error
 234  */
 235 #define DPNI_ERROR_FPE          0x00001000
 236 /**
 237  * Parsing header error
 238  */
 239 #define DPNI_ERROR_PHE          0x00000020
 240 /**
 241  * Parser L3 checksum error
 242  */
 243 #define DPNI_ERROR_L3CE         0x00000004
 244 /**
 245  * Parser L3 checksum error
 246  */
 247 #define DPNI_ERROR_L4CE         0x00000001
 248 
 249 /**
 250  * enum dpni_error_action - Defines DPNI behavior for errors
 251  * @DPNI_ERROR_ACTION_DISCARD: Discard the frame
 252  * @DPNI_ERROR_ACTION_CONTINUE: Continue with the normal flow
 253  * @DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE: Send the frame to the error queue
 254  */
 255 enum dpni_error_action {
 256         DPNI_ERROR_ACTION_DISCARD = 0,
 257         DPNI_ERROR_ACTION_CONTINUE = 1,
 258         DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE = 2
 259 };
 260 
 261 /**
 262  * struct dpni_error_cfg - Structure representing DPNI errors treatment
 263  * @errors: Errors mask; use 'DPNI_ERROR__<X>
 264  * @error_action: The desired action for the errors mask
 265  * @set_frame_annotation: Set to '1' to mark the errors in frame annotation
 266  *              status (FAS); relevant only for the non-discard action
 267  */
 268 struct dpni_error_cfg {
 269         u32                     errors;
 270         enum dpni_error_action  error_action;
 271         int                     set_frame_annotation;
 272 };
 273 
 274 int dpni_set_errors_behavior(struct fsl_mc_io           *mc_io,
 275                              u32                        cmd_flags,
 276                              u16                        token,
 277                              struct dpni_error_cfg      *cfg);
 278 
 279 /**
 280  * DPNI buffer layout modification options
 281  */
 282 
 283 /**
 284  * Select to modify the time-stamp setting
 285  */
 286 #define DPNI_BUF_LAYOUT_OPT_TIMESTAMP           0x00000001
 287 /**
 288  * Select to modify the parser-result setting; not applicable for Tx
 289  */
 290 #define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT       0x00000002
 291 /**
 292  * Select to modify the frame-status setting
 293  */
 294 #define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS        0x00000004
 295 /**
 296  * Select to modify the private-data-size setting
 297  */
 298 #define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE   0x00000008
 299 /**
 300  * Select to modify the data-alignment setting
 301  */
 302 #define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN          0x00000010
 303 /**
 304  * Select to modify the data-head-room setting
 305  */
 306 #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM      0x00000020
 307 /**
 308  * Select to modify the data-tail-room setting
 309  */
 310 #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM      0x00000040
 311 
 312 /**
 313  * struct dpni_buffer_layout - Structure representing DPNI buffer layout
 314  * @options: Flags representing the suggested modifications to the buffer
 315  *              layout; Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
 316  * @pass_timestamp: Pass timestamp value
 317  * @pass_parser_result: Pass parser results
 318  * @pass_frame_status: Pass frame status
 319  * @private_data_size: Size kept for private data (in bytes)
 320  * @data_align: Data alignment
 321  * @data_head_room: Data head room
 322  * @data_tail_room: Data tail room
 323  */
 324 struct dpni_buffer_layout {
 325         u32     options;
 326         int     pass_timestamp;
 327         int     pass_parser_result;
 328         int     pass_frame_status;
 329         u16     private_data_size;
 330         u16     data_align;
 331         u16     data_head_room;
 332         u16     data_tail_room;
 333 };
 334 
 335 /**
 336  * enum dpni_queue_type - Identifies a type of queue targeted by the command
 337  * @DPNI_QUEUE_RX: Rx queue
 338  * @DPNI_QUEUE_TX: Tx queue
 339  * @DPNI_QUEUE_TX_CONFIRM: Tx confirmation queue
 340  * @DPNI_QUEUE_RX_ERR: Rx error queue
 341  */enum dpni_queue_type {
 342         DPNI_QUEUE_RX,
 343         DPNI_QUEUE_TX,
 344         DPNI_QUEUE_TX_CONFIRM,
 345         DPNI_QUEUE_RX_ERR,
 346 };
 347 
 348 int dpni_get_buffer_layout(struct fsl_mc_io             *mc_io,
 349                            u32                          cmd_flags,
 350                            u16                          token,
 351                            enum dpni_queue_type         qtype,
 352                            struct dpni_buffer_layout    *layout);
 353 
 354 int dpni_set_buffer_layout(struct fsl_mc_io                *mc_io,
 355                            u32                             cmd_flags,
 356                            u16                             token,
 357                            enum dpni_queue_type            qtype,
 358                            const struct dpni_buffer_layout *layout);
 359 
 360 /**
 361  * enum dpni_offload - Identifies a type of offload targeted by the command
 362  * @DPNI_OFF_RX_L3_CSUM: Rx L3 checksum validation
 363  * @DPNI_OFF_RX_L4_CSUM: Rx L4 checksum validation
 364  * @DPNI_OFF_TX_L3_CSUM: Tx L3 checksum generation
 365  * @DPNI_OFF_TX_L4_CSUM: Tx L4 checksum generation
 366  */
 367 enum dpni_offload {
 368         DPNI_OFF_RX_L3_CSUM,
 369         DPNI_OFF_RX_L4_CSUM,
 370         DPNI_OFF_TX_L3_CSUM,
 371         DPNI_OFF_TX_L4_CSUM,
 372 };
 373 
 374 int dpni_set_offload(struct fsl_mc_io   *mc_io,
 375                      u32                cmd_flags,
 376                      u16                token,
 377                      enum dpni_offload  type,
 378                      u32                config);
 379 
 380 int dpni_get_offload(struct fsl_mc_io   *mc_io,
 381                      u32                cmd_flags,
 382                      u16                token,
 383                      enum dpni_offload  type,
 384                      u32                *config);
 385 
 386 int dpni_get_qdid(struct fsl_mc_io      *mc_io,
 387                   u32                   cmd_flags,
 388                   u16                   token,
 389                   enum dpni_queue_type  qtype,
 390                   u16                   *qdid);
 391 
 392 int dpni_get_tx_data_offset(struct fsl_mc_io    *mc_io,
 393                             u32                 cmd_flags,
 394                             u16                 token,
 395                             u16                 *data_offset);
 396 
 397 #define DPNI_STATISTICS_CNT             7
 398 
 399 /**
 400  * union dpni_statistics - Union describing the DPNI statistics
 401  * @page_0: Page_0 statistics structure
 402  * @page_0.ingress_all_frames: Ingress frame count
 403  * @page_0.ingress_all_bytes: Ingress byte count
 404  * @page_0.ingress_multicast_frames: Ingress multicast frame count
 405  * @page_0.ingress_multicast_bytes: Ingress multicast byte count
 406  * @page_0.ingress_broadcast_frames: Ingress broadcast frame count
 407  * @page_0.ingress_broadcast_bytes: Ingress broadcast byte count
 408  * @page_1: Page_1 statistics structure
 409  * @page_1.egress_all_frames: Egress frame count
 410  * @page_1.egress_all_bytes: Egress byte count
 411  * @page_1.egress_multicast_frames: Egress multicast frame count
 412  * @page_1.egress_multicast_bytes: Egress multicast byte count
 413  * @page_1.egress_broadcast_frames: Egress broadcast frame count
 414  * @page_1.egress_broadcast_bytes: Egress broadcast byte count
 415  * @page_2: Page_2 statistics structure
 416  * @page_2.ingress_filtered_frames: Ingress filtered frame count
 417  * @page_2.ingress_discarded_frames: Ingress discarded frame count
 418  * @page_2.ingress_nobuffer_discards: Ingress discarded frame count due to
 419  *      lack of buffers
 420  * @page_2.egress_discarded_frames: Egress discarded frame count
 421  * @page_2.egress_confirmed_frames: Egress confirmed frame count
 422  * @page3: Page_3 statistics structure
 423  * @page_3.egress_dequeue_bytes: Cumulative count of the number of bytes
 424  *      dequeued from egress FQs
 425  * @page_3.egress_dequeue_frames: Cumulative count of the number of frames
 426  *      dequeued from egress FQs
 427  * @page_3.egress_reject_bytes: Cumulative count of the number of bytes in
 428  *      egress frames whose enqueue was rejected
 429  * @page_3.egress_reject_frames: Cumulative count of the number of egress
 430  *      frames whose enqueue was rejected
 431  * @page_4: Page_4 statistics structure: congestion points
 432  * @page_4.cgr_reject_frames: number of rejected frames due to congestion point
 433  * @page_4.cgr_reject_bytes: number of rejected bytes due to congestion point
 434  * @page_5: Page_5 statistics structure: policer
 435  * @page_5.policer_cnt_red: NUmber of red colored frames
 436  * @page_5.policer_cnt_yellow: number of yellow colored frames
 437  * @page_5.policer_cnt_green: number of green colored frames
 438  * @page_5.policer_cnt_re_red: number of recolored red frames
 439  * @page_5.policer_cnt_re_yellow: number of recolored yellow frames
 440  * @page_6: Page_6 statistics structure
 441  * @page_6.tx_pending_frames: total number of frames pending in egress FQs
 442  * @raw: raw statistics structure, used to index counters
 443  */
 444 union dpni_statistics {
 445         struct {
 446                 u64 ingress_all_frames;
 447                 u64 ingress_all_bytes;
 448                 u64 ingress_multicast_frames;
 449                 u64 ingress_multicast_bytes;
 450                 u64 ingress_broadcast_frames;
 451                 u64 ingress_broadcast_bytes;
 452         } page_0;
 453         struct {
 454                 u64 egress_all_frames;
 455                 u64 egress_all_bytes;
 456                 u64 egress_multicast_frames;
 457                 u64 egress_multicast_bytes;
 458                 u64 egress_broadcast_frames;
 459                 u64 egress_broadcast_bytes;
 460         } page_1;
 461         struct {
 462                 u64 ingress_filtered_frames;
 463                 u64 ingress_discarded_frames;
 464                 u64 ingress_nobuffer_discards;
 465                 u64 egress_discarded_frames;
 466                 u64 egress_confirmed_frames;
 467         } page_2;
 468         struct {
 469                 u64 egress_dequeue_bytes;
 470                 u64 egress_dequeue_frames;
 471                 u64 egress_reject_bytes;
 472                 u64 egress_reject_frames;
 473         } page_3;
 474         struct {
 475                 u64 cgr_reject_frames;
 476                 u64 cgr_reject_bytes;
 477         } page_4;
 478         struct {
 479                 u64 policer_cnt_red;
 480                 u64 policer_cnt_yellow;
 481                 u64 policer_cnt_green;
 482                 u64 policer_cnt_re_red;
 483                 u64 policer_cnt_re_yellow;
 484         } page_5;
 485         struct {
 486                 u64 tx_pending_frames;
 487         } page_6;
 488         struct {
 489                 u64 counter[DPNI_STATISTICS_CNT];
 490         } raw;
 491 };
 492 
 493 int dpni_get_statistics(struct fsl_mc_io        *mc_io,
 494                         u32                     cmd_flags,
 495                         u16                     token,
 496                         u8                      page,
 497                         union dpni_statistics   *stat);
 498 
 499 /**
 500  * Enable auto-negotiation
 501  */
 502 #define DPNI_LINK_OPT_AUTONEG           0x0000000000000001ULL
 503 /**
 504  * Enable half-duplex mode
 505  */
 506 #define DPNI_LINK_OPT_HALF_DUPLEX       0x0000000000000002ULL
 507 /**
 508  * Enable pause frames
 509  */
 510 #define DPNI_LINK_OPT_PAUSE             0x0000000000000004ULL
 511 /**
 512  * Enable a-symmetric pause frames
 513  */
 514 #define DPNI_LINK_OPT_ASYM_PAUSE        0x0000000000000008ULL
 515 
 516 /**
 517  * struct - Structure representing DPNI link configuration
 518  * @rate: Rate
 519  * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
 520  */
 521 struct dpni_link_cfg {
 522         u32 rate;
 523         u64 options;
 524 };
 525 
 526 int dpni_set_link_cfg(struct fsl_mc_io                  *mc_io,
 527                       u32                               cmd_flags,
 528                       u16                               token,
 529                       const struct dpni_link_cfg        *cfg);
 530 
 531 int dpni_get_link_cfg(struct fsl_mc_io                  *mc_io,
 532                       u32                               cmd_flags,
 533                       u16                               token,
 534                       struct dpni_link_cfg              *cfg);
 535 
 536 /**
 537  * struct dpni_link_state - Structure representing DPNI link state
 538  * @rate: Rate
 539  * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
 540  * @up: Link state; '0' for down, '1' for up
 541  */
 542 struct dpni_link_state {
 543         u32     rate;
 544         u64     options;
 545         int     up;
 546 };
 547 
 548 int dpni_get_link_state(struct fsl_mc_io        *mc_io,
 549                         u32                     cmd_flags,
 550                         u16                     token,
 551                         struct dpni_link_state  *state);
 552 
 553 int dpni_set_max_frame_length(struct fsl_mc_io  *mc_io,
 554                               u32               cmd_flags,
 555                               u16               token,
 556                               u16               max_frame_length);
 557 
 558 int dpni_get_max_frame_length(struct fsl_mc_io  *mc_io,
 559                               u32               cmd_flags,
 560                               u16               token,
 561                               u16               *max_frame_length);
 562 
 563 int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io,
 564                                u32              cmd_flags,
 565                                u16              token,
 566                                int              en);
 567 
 568 int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io,
 569                                u32              cmd_flags,
 570                                u16              token,
 571                                int              *en);
 572 
 573 int dpni_set_unicast_promisc(struct fsl_mc_io   *mc_io,
 574                              u32                cmd_flags,
 575                              u16                token,
 576                              int                en);
 577 
 578 int dpni_get_unicast_promisc(struct fsl_mc_io   *mc_io,
 579                              u32                cmd_flags,
 580                              u16                token,
 581                              int                *en);
 582 
 583 int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
 584                               u32               cmd_flags,
 585                               u16               token,
 586                               const u8          mac_addr[6]);
 587 
 588 int dpni_get_primary_mac_addr(struct fsl_mc_io  *mc_io,
 589                               u32               cmd_flags,
 590                               u16               token,
 591                               u8                mac_addr[6]);
 592 
 593 int dpni_get_port_mac_addr(struct fsl_mc_io     *mc_io,
 594                            u32                  cm_flags,
 595                            u16                  token,
 596                            u8                   mac_addr[6]);
 597 
 598 int dpni_add_mac_addr(struct fsl_mc_io  *mc_io,
 599                       u32               cmd_flags,
 600                       u16               token,
 601                       const u8          mac_addr[6]);
 602 
 603 int dpni_remove_mac_addr(struct fsl_mc_io       *mc_io,
 604                          u32                    cmd_flags,
 605                          u16                    token,
 606                          const u8               mac_addr[6]);
 607 
 608 int dpni_clear_mac_filters(struct fsl_mc_io     *mc_io,
 609                            u32                  cmd_flags,
 610                            u16                  token,
 611                            int                  unicast,
 612                            int                  multicast);
 613 
 614 /**
 615  * enum dpni_dist_mode - DPNI distribution mode
 616  * @DPNI_DIST_MODE_NONE: No distribution
 617  * @DPNI_DIST_MODE_HASH: Use hash distribution; only relevant if
 618  *              the 'DPNI_OPT_DIST_HASH' option was set at DPNI creation
 619  * @DPNI_DIST_MODE_FS:  Use explicit flow steering; only relevant if
 620  *       the 'DPNI_OPT_DIST_FS' option was set at DPNI creation
 621  */
 622 enum dpni_dist_mode {
 623         DPNI_DIST_MODE_NONE = 0,
 624         DPNI_DIST_MODE_HASH = 1,
 625         DPNI_DIST_MODE_FS = 2
 626 };
 627 
 628 /**
 629  * enum dpni_fs_miss_action -   DPNI Flow Steering miss action
 630  * @DPNI_FS_MISS_DROP: In case of no-match, drop the frame
 631  * @DPNI_FS_MISS_EXPLICIT_FLOWID: In case of no-match, use explicit flow-id
 632  * @DPNI_FS_MISS_HASH: In case of no-match, distribute using hash
 633  */
 634 enum dpni_fs_miss_action {
 635         DPNI_FS_MISS_DROP = 0,
 636         DPNI_FS_MISS_EXPLICIT_FLOWID = 1,
 637         DPNI_FS_MISS_HASH = 2
 638 };
 639 
 640 /**
 641  * struct dpni_fs_tbl_cfg - Flow Steering table configuration
 642  * @miss_action: Miss action selection
 643  * @default_flow_id: Used when 'miss_action = DPNI_FS_MISS_EXPLICIT_FLOWID'
 644  */
 645 struct dpni_fs_tbl_cfg {
 646         enum dpni_fs_miss_action        miss_action;
 647         u16                             default_flow_id;
 648 };
 649 
 650 int dpni_prepare_key_cfg(const struct dpkg_profile_cfg *cfg,
 651                          u8 *key_cfg_buf);
 652 
 653 /**
 654  * struct dpni_rx_tc_dist_cfg - Rx traffic class distribution configuration
 655  * @dist_size: Set the distribution size;
 656  *      supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
 657  *      112,128,192,224,256,384,448,512,768,896,1024
 658  * @dist_mode: Distribution mode
 659  * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
 660  *              the extractions to be used for the distribution key by calling
 661  *              dpni_prepare_key_cfg() relevant only when
 662  *              'dist_mode != DPNI_DIST_MODE_NONE', otherwise it can be '0'
 663  * @fs_cfg: Flow Steering table configuration; only relevant if
 664  *              'dist_mode = DPNI_DIST_MODE_FS'
 665  */
 666 struct dpni_rx_tc_dist_cfg {
 667         u16                     dist_size;
 668         enum dpni_dist_mode     dist_mode;
 669         u64                     key_cfg_iova;
 670         struct dpni_fs_tbl_cfg  fs_cfg;
 671 };
 672 
 673 int dpni_set_rx_tc_dist(struct fsl_mc_io                        *mc_io,
 674                         u32                                     cmd_flags,
 675                         u16                                     token,
 676                         u8                                      tc_id,
 677                         const struct dpni_rx_tc_dist_cfg        *cfg);
 678 
 679 /**
 680  * When used for fs_miss_flow_id in function dpni_set_rx_dist,
 681  * will signal to dpni to drop all unclassified frames
 682  */
 683 #define DPNI_FS_MISS_DROP               ((uint16_t)-1)
 684 
 685 /**
 686  * struct dpni_rx_dist_cfg - Rx distribution configuration
 687  * @dist_size:  distribution size
 688  * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
 689  *              the extractions to be used for the distribution key by calling
 690  *              dpni_prepare_key_cfg(); relevant only when enable!=0 otherwise
 691  *              it can be '0'
 692  * @enable: enable/disable the distribution.
 693  * @tc: TC id for which distribution is set
 694  * @fs_miss_flow_id: when packet misses all rules from flow steering table and
 695  *              hash is disabled it will be put into this queue id; use
 696  *              DPNI_FS_MISS_DROP to drop frames. The value of this field is
 697  *              used only when flow steering distribution is enabled and hash
 698  *              distribution is disabled
 699  */
 700 struct dpni_rx_dist_cfg {
 701         u16 dist_size;
 702         u64 key_cfg_iova;
 703         u8 enable;
 704         u8 tc;
 705         u16 fs_miss_flow_id;
 706 };
 707 
 708 int dpni_set_rx_fs_dist(struct fsl_mc_io *mc_io,
 709                         u32 cmd_flags,
 710                         u16 token,
 711                         const struct dpni_rx_dist_cfg *cfg);
 712 
 713 int dpni_set_rx_hash_dist(struct fsl_mc_io *mc_io,
 714                           u32 cmd_flags,
 715                           u16 token,
 716                           const struct dpni_rx_dist_cfg *cfg);
 717 
 718 /**
 719  * enum dpni_dest - DPNI destination types
 720  * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
 721  *              does not generate FQDAN notifications; user is expected to
 722  *              dequeue from the queue based on polling or other user-defined
 723  *              method
 724  * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
 725  *              notifications to the specified DPIO; user is expected to dequeue
 726  *              from the queue only after notification is received
 727  * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
 728  *              FQDAN notifications, but is connected to the specified DPCON
 729  *              object; user is expected to dequeue from the DPCON channel
 730  */
 731 enum dpni_dest {
 732         DPNI_DEST_NONE = 0,
 733         DPNI_DEST_DPIO = 1,
 734         DPNI_DEST_DPCON = 2
 735 };
 736 
 737 /**
 738  * struct dpni_queue - Queue structure
 739  * @destination - Destination structure
 740  * @destination.id: ID of the destination, only relevant if DEST_TYPE is > 0.
 741  *      Identifies either a DPIO or a DPCON object.
 742  *      Not relevant for Tx queues.
 743  * @destination.type:   May be one of the following:
 744  *      0 - No destination, queue can be manually
 745  *              queried, but will not push traffic or
 746  *              notifications to a DPIO;
 747  *      1 - The destination is a DPIO. When traffic
 748  *              becomes available in the queue a FQDAN
 749  *              (FQ data available notification) will be
 750  *              generated to selected DPIO;
 751  *      2 - The destination is a DPCON. The queue is
 752  *              associated with a DPCON object for the
 753  *              purpose of scheduling between multiple
 754  *              queues. The DPCON may be independently
 755  *              configured to generate notifications.
 756  *              Not relevant for Tx queues.
 757  * @destination.hold_active: Hold active, maintains a queue scheduled for longer
 758  *      in a DPIO during dequeue to reduce spread of traffic.
 759  *      Only relevant if queues are
 760  *      not affined to a single DPIO.
 761  * @user_context: User data, presented to the user along with any frames
 762  *      from this queue. Not relevant for Tx queues.
 763  * @flc: FD FLow Context structure
 764  * @flc.value: Default FLC value for traffic dequeued from
 765  *      this queue.  Please check description of FD
 766  *      structure for more information.
 767  *      Note that FLC values set using dpni_add_fs_entry,
 768  *      if any, take precedence over values per queue.
 769  * @flc.stash_control: Boolean, indicates whether the 6 lowest
 770  *      - significant bits are used for stash control.
 771  *      significant bits are used for stash control.  If set, the 6
 772  *      least significant bits in value are interpreted as follows:
 773  *      - bits 0-1: indicates the number of 64 byte units of context
 774  *      that are stashed.  FLC value is interpreted as a memory address
 775  *      in this case, excluding the 6 LS bits.
 776  *      - bits 2-3: indicates the number of 64 byte units of frame
 777  *      annotation to be stashed.  Annotation is placed at FD[ADDR].
 778  *      - bits 4-5: indicates the number of 64 byte units of frame
 779  *      data to be stashed.  Frame data is placed at FD[ADDR] +
 780  *      FD[OFFSET].
 781  *      For more details check the Frame Descriptor section in the
 782  *      hardware documentation.
 783  */
 784 struct dpni_queue {
 785         struct {
 786                 u16 id;
 787                 enum dpni_dest type;
 788                 char hold_active;
 789                 u8 priority;
 790         } destination;
 791         u64 user_context;
 792         struct {
 793                 u64 value;
 794                 char stash_control;
 795         } flc;
 796 };
 797 
 798 /**
 799  * struct dpni_queue_id - Queue identification, used for enqueue commands
 800  *                      or queue control
 801  * @fqid: FQID used for enqueueing to and/or configuration of this specific FQ
 802  * @qdbin: Queueing bin, used to enqueue using QDID, DQBIN, QPRI. Only relevant
 803  *              for Tx queues.
 804  */
 805 struct dpni_queue_id {
 806         u32 fqid;
 807         u16 qdbin;
 808 };
 809 
 810 /**
 811  * Set User Context
 812  */
 813 #define DPNI_QUEUE_OPT_USER_CTX         0x00000001
 814 #define DPNI_QUEUE_OPT_DEST             0x00000002
 815 #define DPNI_QUEUE_OPT_FLC              0x00000004
 816 #define DPNI_QUEUE_OPT_HOLD_ACTIVE      0x00000008
 817 
 818 int dpni_set_queue(struct fsl_mc_io     *mc_io,
 819                    u32                  cmd_flags,
 820                    u16                  token,
 821                    enum dpni_queue_type qtype,
 822                    u8                   tc,
 823                    u8                   index,
 824                    u8                   options,
 825                    const struct dpni_queue *queue);
 826 
 827 int dpni_get_queue(struct fsl_mc_io     *mc_io,
 828                    u32                  cmd_flags,
 829                    u16                  token,
 830                    enum dpni_queue_type qtype,
 831                    u8                   tc,
 832                    u8                   index,
 833                    struct dpni_queue    *queue,
 834                    struct dpni_queue_id *qid);
 835 
 836 /**
 837  * enum dpni_congestion_unit - DPNI congestion units
 838  * @DPNI_CONGESTION_UNIT_BYTES: bytes units
 839  * @DPNI_CONGESTION_UNIT_FRAMES: frames units
 840  */
 841 enum dpni_congestion_unit {
 842         DPNI_CONGESTION_UNIT_BYTES = 0,
 843         DPNI_CONGESTION_UNIT_FRAMES
 844 };
 845 
 846 /**
 847  * enum dpni_congestion_point - Structure representing congestion point
 848  * @DPNI_CP_QUEUE: Set taildrop per queue, identified by QUEUE_TYPE, TC and
 849  *              QUEUE_INDEX
 850  * @DPNI_CP_GROUP: Set taildrop per queue group. Depending on options used to
 851  *              define the DPNI this can be either per TC (default) or per
 852  *              interface (DPNI_OPT_SHARED_CONGESTION set at DPNI create).
 853  *              QUEUE_INDEX is ignored if this type is used.
 854  */
 855 enum dpni_congestion_point {
 856         DPNI_CP_QUEUE,
 857         DPNI_CP_GROUP,
 858 };
 859 
 860 /**
 861  * struct dpni_taildrop - Structure representing the taildrop
 862  * @enable:     Indicates whether the taildrop is active or not.
 863  * @units:      Indicates the unit of THRESHOLD. Queue taildrop only supports
 864  *              byte units, this field is ignored and assumed = 0 if
 865  *              CONGESTION_POINT is 0.
 866  * @threshold:  Threshold value, in units identified by UNITS field. Value 0
 867  *              cannot be used as a valid taildrop threshold, THRESHOLD must
 868  *              be > 0 if the taildrop is enabled.
 869  */
 870 struct dpni_taildrop {
 871         char enable;
 872         enum dpni_congestion_unit units;
 873         u32 threshold;
 874 };
 875 
 876 int dpni_set_taildrop(struct fsl_mc_io *mc_io,
 877                       u32 cmd_flags,
 878                       u16 token,
 879                       enum dpni_congestion_point cg_point,
 880                       enum dpni_queue_type q_type,
 881                       u8 tc,
 882                       u8 q_index,
 883                       struct dpni_taildrop *taildrop);
 884 
 885 int dpni_get_taildrop(struct fsl_mc_io *mc_io,
 886                       u32 cmd_flags,
 887                       u16 token,
 888                       enum dpni_congestion_point cg_point,
 889                       enum dpni_queue_type q_type,
 890                       u8 tc,
 891                       u8 q_index,
 892                       struct dpni_taildrop *taildrop);
 893 
 894 /**
 895  * struct dpni_rule_cfg - Rule configuration for table lookup
 896  * @key_iova: I/O virtual address of the key (must be in DMA-able memory)
 897  * @mask_iova: I/O virtual address of the mask (must be in DMA-able memory)
 898  * @key_size: key and mask size (in bytes)
 899  */
 900 struct dpni_rule_cfg {
 901         u64     key_iova;
 902         u64     mask_iova;
 903         u8      key_size;
 904 };
 905 
 906 /**
 907  * Discard matching traffic. If set, this takes precedence over any other
 908  * configuration and matching traffic is always discarded.
 909  */
 910  #define DPNI_FS_OPT_DISCARD            0x1
 911 
 912 /**
 913  * Set FLC value. If set, flc member of struct dpni_fs_action_cfg is used to
 914  * override the FLC value set per queue.
 915  * For more details check the Frame Descriptor section in the hardware
 916  * documentation.
 917  */
 918 #define DPNI_FS_OPT_SET_FLC            0x2
 919 
 920 /**
 921  * Indicates whether the 6 lowest significant bits of FLC are used for stash
 922  * control. If set, the 6 least significant bits in value are interpreted as
 923  * follows:
 924  *     - bits 0-1: indicates the number of 64 byte units of context that are
 925  *     stashed. FLC value is interpreted as a memory address in this case,
 926  *     excluding the 6 LS bits.
 927  *     - bits 2-3: indicates the number of 64 byte units of frame annotation
 928  *     to be stashed. Annotation is placed at FD[ADDR].
 929  *     - bits 4-5: indicates the number of 64 byte units of frame data to be
 930  *     stashed. Frame data is placed at FD[ADDR] + FD[OFFSET].
 931  * This flag is ignored if DPNI_FS_OPT_SET_FLC is not specified.
 932  */
 933 #define DPNI_FS_OPT_SET_STASH_CONTROL  0x4
 934 
 935 /**
 936  * struct dpni_fs_action_cfg - Action configuration for table look-up
 937  * @flc:        FLC value for traffic matching this rule. Please check the
 938  *              Frame Descriptor section in the hardware documentation for
 939  *              more information.
 940  * @flow_id:    Identifies the Rx queue used for matching traffic. Supported
 941  *              values are in range 0 to num_queue-1.
 942  * @options:    Any combination of DPNI_FS_OPT_ values.
 943  */
 944 struct dpni_fs_action_cfg {
 945         u64 flc;
 946         u16 flow_id;
 947         u16 options;
 948 };
 949 
 950 int dpni_add_fs_entry(struct fsl_mc_io *mc_io,
 951                       u32 cmd_flags,
 952                       u16 token,
 953                       u8 tc_id,
 954                       u16 index,
 955                       const struct dpni_rule_cfg *cfg,
 956                       const struct dpni_fs_action_cfg *action);
 957 
 958 int dpni_remove_fs_entry(struct fsl_mc_io *mc_io,
 959                          u32 cmd_flags,
 960                          u16 token,
 961                          u8 tc_id,
 962                          const struct dpni_rule_cfg *cfg);
 963 
 964 int dpni_get_api_version(struct fsl_mc_io *mc_io,
 965                          u32 cmd_flags,
 966                          u16 *major_ver,
 967                          u16 *minor_ver);
 968 
 969 #endif /* __FSL_DPNI_H */

/* [<][>][^][v][top][bottom][index][help] */