linux/drivers/net/ethernet/freescale/dpaa2/dpni.h
<<
>>
Prefs
   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
  10struct 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
  78int dpni_open(struct fsl_mc_io  *mc_io,
  79              u32               cmd_flags,
  80              int               dpni_id,
  81              u16               *token);
  82
  83int 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 */
  96struct 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
 105int dpni_set_pools(struct fsl_mc_io             *mc_io,
 106                   u32                          cmd_flags,
 107                   u16                          token,
 108                   const struct dpni_pools_cfg  *cfg);
 109
 110int dpni_enable(struct fsl_mc_io        *mc_io,
 111                u32                     cmd_flags,
 112                u16                     token);
 113
 114int dpni_disable(struct fsl_mc_io       *mc_io,
 115                 u32                    cmd_flags,
 116                 u16                    token);
 117
 118int dpni_is_enabled(struct fsl_mc_io    *mc_io,
 119                    u32                 cmd_flags,
 120                    u16                 token,
 121                    int                 *en);
 122
 123int 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
 143int 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
 149int 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
 155int 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
 161int 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
 167int 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
 173int 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 */
 202struct 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
 215int 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 */
 255enum 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 */
 268struct dpni_error_cfg {
 269        u32                     errors;
 270        enum dpni_error_action  error_action;
 271        int                     set_frame_annotation;
 272};
 273
 274int 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 */
 324struct 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
 348int 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
 354int 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 */
 367enum 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
 374int 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
 380int 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
 386int 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
 392int 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 */
 444union 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
 493int 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 * Enable priority flow control pause frames
 518 */
 519#define DPNI_LINK_OPT_PFC_PAUSE         0x0000000000000010ULL
 520
 521/**
 522 * struct - Structure representing DPNI link configuration
 523 * @rate: Rate
 524 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
 525 */
 526struct dpni_link_cfg {
 527        u32 rate;
 528        u64 options;
 529};
 530
 531int dpni_set_link_cfg(struct fsl_mc_io                  *mc_io,
 532                      u32                               cmd_flags,
 533                      u16                               token,
 534                      const struct dpni_link_cfg        *cfg);
 535
 536int dpni_get_link_cfg(struct fsl_mc_io                  *mc_io,
 537                      u32                               cmd_flags,
 538                      u16                               token,
 539                      struct dpni_link_cfg              *cfg);
 540
 541/**
 542 * struct dpni_link_state - Structure representing DPNI link state
 543 * @rate: Rate
 544 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
 545 * @up: Link state; '0' for down, '1' for up
 546 */
 547struct dpni_link_state {
 548        u32     rate;
 549        u64     options;
 550        int     up;
 551};
 552
 553int dpni_get_link_state(struct fsl_mc_io        *mc_io,
 554                        u32                     cmd_flags,
 555                        u16                     token,
 556                        struct dpni_link_state  *state);
 557
 558int dpni_set_max_frame_length(struct fsl_mc_io  *mc_io,
 559                              u32               cmd_flags,
 560                              u16               token,
 561                              u16               max_frame_length);
 562
 563int dpni_get_max_frame_length(struct fsl_mc_io  *mc_io,
 564                              u32               cmd_flags,
 565                              u16               token,
 566                              u16               *max_frame_length);
 567
 568int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io,
 569                               u32              cmd_flags,
 570                               u16              token,
 571                               int              en);
 572
 573int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io,
 574                               u32              cmd_flags,
 575                               u16              token,
 576                               int              *en);
 577
 578int dpni_set_unicast_promisc(struct fsl_mc_io   *mc_io,
 579                             u32                cmd_flags,
 580                             u16                token,
 581                             int                en);
 582
 583int dpni_get_unicast_promisc(struct fsl_mc_io   *mc_io,
 584                             u32                cmd_flags,
 585                             u16                token,
 586                             int                *en);
 587
 588int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
 589                              u32               cmd_flags,
 590                              u16               token,
 591                              const u8          mac_addr[6]);
 592
 593int dpni_get_primary_mac_addr(struct fsl_mc_io  *mc_io,
 594                              u32               cmd_flags,
 595                              u16               token,
 596                              u8                mac_addr[6]);
 597
 598int dpni_get_port_mac_addr(struct fsl_mc_io     *mc_io,
 599                           u32                  cm_flags,
 600                           u16                  token,
 601                           u8                   mac_addr[6]);
 602
 603int dpni_add_mac_addr(struct fsl_mc_io  *mc_io,
 604                      u32               cmd_flags,
 605                      u16               token,
 606                      const u8          mac_addr[6]);
 607
 608int dpni_remove_mac_addr(struct fsl_mc_io       *mc_io,
 609                         u32                    cmd_flags,
 610                         u16                    token,
 611                         const u8               mac_addr[6]);
 612
 613int dpni_clear_mac_filters(struct fsl_mc_io     *mc_io,
 614                           u32                  cmd_flags,
 615                           u16                  token,
 616                           int                  unicast,
 617                           int                  multicast);
 618
 619/**
 620 * enum dpni_dist_mode - DPNI distribution mode
 621 * @DPNI_DIST_MODE_NONE: No distribution
 622 * @DPNI_DIST_MODE_HASH: Use hash distribution; only relevant if
 623 *              the 'DPNI_OPT_DIST_HASH' option was set at DPNI creation
 624 * @DPNI_DIST_MODE_FS:  Use explicit flow steering; only relevant if
 625 *       the 'DPNI_OPT_DIST_FS' option was set at DPNI creation
 626 */
 627enum dpni_dist_mode {
 628        DPNI_DIST_MODE_NONE = 0,
 629        DPNI_DIST_MODE_HASH = 1,
 630        DPNI_DIST_MODE_FS = 2
 631};
 632
 633/**
 634 * enum dpni_fs_miss_action -   DPNI Flow Steering miss action
 635 * @DPNI_FS_MISS_DROP: In case of no-match, drop the frame
 636 * @DPNI_FS_MISS_EXPLICIT_FLOWID: In case of no-match, use explicit flow-id
 637 * @DPNI_FS_MISS_HASH: In case of no-match, distribute using hash
 638 */
 639enum dpni_fs_miss_action {
 640        DPNI_FS_MISS_DROP = 0,
 641        DPNI_FS_MISS_EXPLICIT_FLOWID = 1,
 642        DPNI_FS_MISS_HASH = 2
 643};
 644
 645/**
 646 * struct dpni_fs_tbl_cfg - Flow Steering table configuration
 647 * @miss_action: Miss action selection
 648 * @default_flow_id: Used when 'miss_action = DPNI_FS_MISS_EXPLICIT_FLOWID'
 649 */
 650struct dpni_fs_tbl_cfg {
 651        enum dpni_fs_miss_action        miss_action;
 652        u16                             default_flow_id;
 653};
 654
 655int dpni_prepare_key_cfg(const struct dpkg_profile_cfg *cfg,
 656                         u8 *key_cfg_buf);
 657
 658/**
 659 * struct dpni_rx_tc_dist_cfg - Rx traffic class distribution configuration
 660 * @dist_size: Set the distribution size;
 661 *      supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
 662 *      112,128,192,224,256,384,448,512,768,896,1024
 663 * @dist_mode: Distribution mode
 664 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
 665 *              the extractions to be used for the distribution key by calling
 666 *              dpni_prepare_key_cfg() relevant only when
 667 *              'dist_mode != DPNI_DIST_MODE_NONE', otherwise it can be '0'
 668 * @fs_cfg: Flow Steering table configuration; only relevant if
 669 *              'dist_mode = DPNI_DIST_MODE_FS'
 670 */
 671struct dpni_rx_tc_dist_cfg {
 672        u16                     dist_size;
 673        enum dpni_dist_mode     dist_mode;
 674        u64                     key_cfg_iova;
 675        struct dpni_fs_tbl_cfg  fs_cfg;
 676};
 677
 678int dpni_set_rx_tc_dist(struct fsl_mc_io                        *mc_io,
 679                        u32                                     cmd_flags,
 680                        u16                                     token,
 681                        u8                                      tc_id,
 682                        const struct dpni_rx_tc_dist_cfg        *cfg);
 683
 684/**
 685 * When used for fs_miss_flow_id in function dpni_set_rx_dist,
 686 * will signal to dpni to drop all unclassified frames
 687 */
 688#define DPNI_FS_MISS_DROP               ((uint16_t)-1)
 689
 690/**
 691 * struct dpni_rx_dist_cfg - Rx distribution configuration
 692 * @dist_size:  distribution size
 693 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
 694 *              the extractions to be used for the distribution key by calling
 695 *              dpni_prepare_key_cfg(); relevant only when enable!=0 otherwise
 696 *              it can be '0'
 697 * @enable: enable/disable the distribution.
 698 * @tc: TC id for which distribution is set
 699 * @fs_miss_flow_id: when packet misses all rules from flow steering table and
 700 *              hash is disabled it will be put into this queue id; use
 701 *              DPNI_FS_MISS_DROP to drop frames. The value of this field is
 702 *              used only when flow steering distribution is enabled and hash
 703 *              distribution is disabled
 704 */
 705struct dpni_rx_dist_cfg {
 706        u16 dist_size;
 707        u64 key_cfg_iova;
 708        u8 enable;
 709        u8 tc;
 710        u16 fs_miss_flow_id;
 711};
 712
 713int dpni_set_rx_fs_dist(struct fsl_mc_io *mc_io,
 714                        u32 cmd_flags,
 715                        u16 token,
 716                        const struct dpni_rx_dist_cfg *cfg);
 717
 718int dpni_set_rx_hash_dist(struct fsl_mc_io *mc_io,
 719                          u32 cmd_flags,
 720                          u16 token,
 721                          const struct dpni_rx_dist_cfg *cfg);
 722
 723/**
 724 * struct dpni_qos_tbl_cfg - Structure representing QOS table configuration
 725 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
 726 *              key extractions to be used as the QoS criteria by calling
 727 *              dpkg_prepare_key_cfg()
 728 * @discard_on_miss: Set to '1' to discard frames in case of no match (miss);
 729 *              '0' to use the 'default_tc' in such cases
 730 * @default_tc: Used in case of no-match and 'discard_on_miss'= 0
 731 */
 732struct dpni_qos_tbl_cfg {
 733        u64 key_cfg_iova;
 734        int discard_on_miss;
 735        u8 default_tc;
 736};
 737
 738int dpni_set_qos_table(struct fsl_mc_io *mc_io,
 739                       u32 cmd_flags,
 740                       u16 token,
 741                       const struct dpni_qos_tbl_cfg *cfg);
 742
 743/**
 744 * enum dpni_dest - DPNI destination types
 745 * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
 746 *              does not generate FQDAN notifications; user is expected to
 747 *              dequeue from the queue based on polling or other user-defined
 748 *              method
 749 * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
 750 *              notifications to the specified DPIO; user is expected to dequeue
 751 *              from the queue only after notification is received
 752 * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
 753 *              FQDAN notifications, but is connected to the specified DPCON
 754 *              object; user is expected to dequeue from the DPCON channel
 755 */
 756enum dpni_dest {
 757        DPNI_DEST_NONE = 0,
 758        DPNI_DEST_DPIO = 1,
 759        DPNI_DEST_DPCON = 2
 760};
 761
 762/**
 763 * struct dpni_queue - Queue structure
 764 * @destination - Destination structure
 765 * @destination.id: ID of the destination, only relevant if DEST_TYPE is > 0.
 766 *      Identifies either a DPIO or a DPCON object.
 767 *      Not relevant for Tx queues.
 768 * @destination.type:   May be one of the following:
 769 *      0 - No destination, queue can be manually
 770 *              queried, but will not push traffic or
 771 *              notifications to a DPIO;
 772 *      1 - The destination is a DPIO. When traffic
 773 *              becomes available in the queue a FQDAN
 774 *              (FQ data available notification) will be
 775 *              generated to selected DPIO;
 776 *      2 - The destination is a DPCON. The queue is
 777 *              associated with a DPCON object for the
 778 *              purpose of scheduling between multiple
 779 *              queues. The DPCON may be independently
 780 *              configured to generate notifications.
 781 *              Not relevant for Tx queues.
 782 * @destination.hold_active: Hold active, maintains a queue scheduled for longer
 783 *      in a DPIO during dequeue to reduce spread of traffic.
 784 *      Only relevant if queues are
 785 *      not affined to a single DPIO.
 786 * @user_context: User data, presented to the user along with any frames
 787 *      from this queue. Not relevant for Tx queues.
 788 * @flc: FD FLow Context structure
 789 * @flc.value: Default FLC value for traffic dequeued from
 790 *      this queue.  Please check description of FD
 791 *      structure for more information.
 792 *      Note that FLC values set using dpni_add_fs_entry,
 793 *      if any, take precedence over values per queue.
 794 * @flc.stash_control: Boolean, indicates whether the 6 lowest
 795 *      - significant bits are used for stash control.
 796 *      significant bits are used for stash control.  If set, the 6
 797 *      least significant bits in value are interpreted as follows:
 798 *      - bits 0-1: indicates the number of 64 byte units of context
 799 *      that are stashed.  FLC value is interpreted as a memory address
 800 *      in this case, excluding the 6 LS bits.
 801 *      - bits 2-3: indicates the number of 64 byte units of frame
 802 *      annotation to be stashed.  Annotation is placed at FD[ADDR].
 803 *      - bits 4-5: indicates the number of 64 byte units of frame
 804 *      data to be stashed.  Frame data is placed at FD[ADDR] +
 805 *      FD[OFFSET].
 806 *      For more details check the Frame Descriptor section in the
 807 *      hardware documentation.
 808 */
 809struct dpni_queue {
 810        struct {
 811                u16 id;
 812                enum dpni_dest type;
 813                char hold_active;
 814                u8 priority;
 815        } destination;
 816        u64 user_context;
 817        struct {
 818                u64 value;
 819                char stash_control;
 820        } flc;
 821};
 822
 823/**
 824 * struct dpni_queue_id - Queue identification, used for enqueue commands
 825 *                      or queue control
 826 * @fqid: FQID used for enqueueing to and/or configuration of this specific FQ
 827 * @qdbin: Queueing bin, used to enqueue using QDID, DQBIN, QPRI. Only relevant
 828 *              for Tx queues.
 829 */
 830struct dpni_queue_id {
 831        u32 fqid;
 832        u16 qdbin;
 833};
 834
 835/**
 836 * Set User Context
 837 */
 838#define DPNI_QUEUE_OPT_USER_CTX         0x00000001
 839#define DPNI_QUEUE_OPT_DEST             0x00000002
 840#define DPNI_QUEUE_OPT_FLC              0x00000004
 841#define DPNI_QUEUE_OPT_HOLD_ACTIVE      0x00000008
 842
 843int dpni_set_queue(struct fsl_mc_io     *mc_io,
 844                   u32                  cmd_flags,
 845                   u16                  token,
 846                   enum dpni_queue_type qtype,
 847                   u8                   tc,
 848                   u8                   index,
 849                   u8                   options,
 850                   const struct dpni_queue *queue);
 851
 852int dpni_get_queue(struct fsl_mc_io     *mc_io,
 853                   u32                  cmd_flags,
 854                   u16                  token,
 855                   enum dpni_queue_type qtype,
 856                   u8                   tc,
 857                   u8                   index,
 858                   struct dpni_queue    *queue,
 859                   struct dpni_queue_id *qid);
 860
 861/**
 862 * enum dpni_congestion_unit - DPNI congestion units
 863 * @DPNI_CONGESTION_UNIT_BYTES: bytes units
 864 * @DPNI_CONGESTION_UNIT_FRAMES: frames units
 865 */
 866enum dpni_congestion_unit {
 867        DPNI_CONGESTION_UNIT_BYTES = 0,
 868        DPNI_CONGESTION_UNIT_FRAMES
 869};
 870
 871/**
 872 * enum dpni_congestion_point - Structure representing congestion point
 873 * @DPNI_CP_QUEUE: Set taildrop per queue, identified by QUEUE_TYPE, TC and
 874 *              QUEUE_INDEX
 875 * @DPNI_CP_GROUP: Set taildrop per queue group. Depending on options used to
 876 *              define the DPNI this can be either per TC (default) or per
 877 *              interface (DPNI_OPT_SHARED_CONGESTION set at DPNI create).
 878 *              QUEUE_INDEX is ignored if this type is used.
 879 */
 880enum dpni_congestion_point {
 881        DPNI_CP_QUEUE,
 882        DPNI_CP_GROUP,
 883};
 884
 885/**
 886 * struct dpni_dest_cfg - Structure representing DPNI destination parameters
 887 * @dest_type:  Destination type
 888 * @dest_id:    Either DPIO ID or DPCON ID, depending on the destination type
 889 * @priority:   Priority selection within the DPIO or DPCON channel; valid
 890 *              values are 0-1 or 0-7, depending on the number of priorities
 891 *              in that channel; not relevant for 'DPNI_DEST_NONE' option
 892 */
 893struct dpni_dest_cfg {
 894        enum dpni_dest dest_type;
 895        int dest_id;
 896        u8 priority;
 897};
 898
 899/* DPNI congestion options */
 900
 901/**
 902 * This congestion will trigger flow control or priority flow control.
 903 * This will have effect only if flow control is enabled with
 904 * dpni_set_link_cfg().
 905 */
 906#define DPNI_CONG_OPT_FLOW_CONTROL              0x00000040
 907
 908/**
 909 * struct dpni_congestion_notification_cfg - congestion notification
 910 *                                      configuration
 911 * @units: Units type
 912 * @threshold_entry: Above this threshold we enter a congestion state.
 913 *              set it to '0' to disable it
 914 * @threshold_exit: Below this threshold we exit the congestion state.
 915 * @message_ctx: The context that will be part of the CSCN message
 916 * @message_iova: I/O virtual address (must be in DMA-able memory),
 917 *              must be 16B aligned; valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>'
 918 *              is contained in 'options'
 919 * @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel
 920 * @notification_mode: Mask of available options; use 'DPNI_CONG_OPT_<X>' values
 921 */
 922
 923struct dpni_congestion_notification_cfg {
 924        enum dpni_congestion_unit units;
 925        u32 threshold_entry;
 926        u32 threshold_exit;
 927        u64 message_ctx;
 928        u64 message_iova;
 929        struct dpni_dest_cfg dest_cfg;
 930        u16 notification_mode;
 931};
 932
 933int dpni_set_congestion_notification(
 934                        struct fsl_mc_io *mc_io,
 935                        u32 cmd_flags,
 936                        u16 token,
 937                        enum dpni_queue_type qtype,
 938                        u8 tc_id,
 939                        const struct dpni_congestion_notification_cfg *cfg);
 940
 941/**
 942 * struct dpni_taildrop - Structure representing the taildrop
 943 * @enable:     Indicates whether the taildrop is active or not.
 944 * @units:      Indicates the unit of THRESHOLD. Queue taildrop only supports
 945 *              byte units, this field is ignored and assumed = 0 if
 946 *              CONGESTION_POINT is 0.
 947 * @threshold:  Threshold value, in units identified by UNITS field. Value 0
 948 *              cannot be used as a valid taildrop threshold, THRESHOLD must
 949 *              be > 0 if the taildrop is enabled.
 950 */
 951struct dpni_taildrop {
 952        char enable;
 953        enum dpni_congestion_unit units;
 954        u32 threshold;
 955};
 956
 957int dpni_set_taildrop(struct fsl_mc_io *mc_io,
 958                      u32 cmd_flags,
 959                      u16 token,
 960                      enum dpni_congestion_point cg_point,
 961                      enum dpni_queue_type q_type,
 962                      u8 tc,
 963                      u8 q_index,
 964                      struct dpni_taildrop *taildrop);
 965
 966int dpni_get_taildrop(struct fsl_mc_io *mc_io,
 967                      u32 cmd_flags,
 968                      u16 token,
 969                      enum dpni_congestion_point cg_point,
 970                      enum dpni_queue_type q_type,
 971                      u8 tc,
 972                      u8 q_index,
 973                      struct dpni_taildrop *taildrop);
 974
 975/**
 976 * struct dpni_rule_cfg - Rule configuration for table lookup
 977 * @key_iova: I/O virtual address of the key (must be in DMA-able memory)
 978 * @mask_iova: I/O virtual address of the mask (must be in DMA-able memory)
 979 * @key_size: key and mask size (in bytes)
 980 */
 981struct dpni_rule_cfg {
 982        u64     key_iova;
 983        u64     mask_iova;
 984        u8      key_size;
 985};
 986
 987/**
 988 * Discard matching traffic. If set, this takes precedence over any other
 989 * configuration and matching traffic is always discarded.
 990 */
 991 #define DPNI_FS_OPT_DISCARD            0x1
 992
 993/**
 994 * Set FLC value. If set, flc member of struct dpni_fs_action_cfg is used to
 995 * override the FLC value set per queue.
 996 * For more details check the Frame Descriptor section in the hardware
 997 * documentation.
 998 */
 999#define DPNI_FS_OPT_SET_FLC            0x2
1000
1001/**
1002 * Indicates whether the 6 lowest significant bits of FLC are used for stash
1003 * control. If set, the 6 least significant bits in value are interpreted as
1004 * follows:
1005 *     - bits 0-1: indicates the number of 64 byte units of context that are
1006 *     stashed. FLC value is interpreted as a memory address in this case,
1007 *     excluding the 6 LS bits.
1008 *     - bits 2-3: indicates the number of 64 byte units of frame annotation
1009 *     to be stashed. Annotation is placed at FD[ADDR].
1010 *     - bits 4-5: indicates the number of 64 byte units of frame data to be
1011 *     stashed. Frame data is placed at FD[ADDR] + FD[OFFSET].
1012 * This flag is ignored if DPNI_FS_OPT_SET_FLC is not specified.
1013 */
1014#define DPNI_FS_OPT_SET_STASH_CONTROL  0x4
1015
1016/**
1017 * struct dpni_fs_action_cfg - Action configuration for table look-up
1018 * @flc:        FLC value for traffic matching this rule. Please check the
1019 *              Frame Descriptor section in the hardware documentation for
1020 *              more information.
1021 * @flow_id:    Identifies the Rx queue used for matching traffic. Supported
1022 *              values are in range 0 to num_queue-1.
1023 * @options:    Any combination of DPNI_FS_OPT_ values.
1024 */
1025struct dpni_fs_action_cfg {
1026        u64 flc;
1027        u16 flow_id;
1028        u16 options;
1029};
1030
1031int dpni_add_fs_entry(struct fsl_mc_io *mc_io,
1032                      u32 cmd_flags,
1033                      u16 token,
1034                      u8 tc_id,
1035                      u16 index,
1036                      const struct dpni_rule_cfg *cfg,
1037                      const struct dpni_fs_action_cfg *action);
1038
1039int dpni_remove_fs_entry(struct fsl_mc_io *mc_io,
1040                         u32 cmd_flags,
1041                         u16 token,
1042                         u8 tc_id,
1043                         const struct dpni_rule_cfg *cfg);
1044
1045int dpni_add_qos_entry(struct fsl_mc_io *mc_io,
1046                       u32 cmd_flags,
1047                       u16 token,
1048                       const struct dpni_rule_cfg *cfg,
1049                       u8 tc_id,
1050                       u16 index);
1051
1052int dpni_remove_qos_entry(struct fsl_mc_io *mc_io,
1053                          u32 cmd_flags,
1054                          u16 token,
1055                          const struct dpni_rule_cfg *cfg);
1056
1057int dpni_clear_qos_table(struct fsl_mc_io *mc_io,
1058                         u32 cmd_flags,
1059                         u16 token);
1060
1061int dpni_get_api_version(struct fsl_mc_io *mc_io,
1062                         u32 cmd_flags,
1063                         u16 *major_ver,
1064                         u16 *minor_ver);
1065
1066#endif /* __FSL_DPNI_H */
1067