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