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