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