1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2016-2020 Intel Corporation 3 */ 4 5 #ifndef __DLB_RESOURCE_H 6 #define __DLB_RESOURCE_H 7 8 #include "dlb_hw_types.h" 9 #include "dlb_osdep_types.h" 10 11 /** 12 * dlb_resource_init() - initialize the device 13 * @hw: pointer to struct dlb_hw. 14 * 15 * This function initializes the device's software state (pointed to by the hw 16 * argument) and programs global scheduling QoS registers. This function should 17 * be called during driver initialization. 18 * 19 * The dlb_hw struct must be unique per DLB device and persist until the device 20 * is reset. 21 * 22 * Return: 23 * Returns 0 upon success, -1 otherwise. 24 */ 25 int dlb_resource_init(struct dlb_hw *hw); 26 27 /** 28 * dlb_resource_free() - free device state memory 29 * @hw: dlb_hw handle for a particular device. 30 * 31 * This function frees software state pointed to by dlb_hw. This function 32 * should be called when resetting the device or unloading the driver. 33 */ 34 void dlb_resource_free(struct dlb_hw *hw); 35 36 /** 37 * dlb_resource_reset() - reset in-use resources to their initial state 38 * @hw: dlb_hw handle for a particular device. 39 * 40 * This function resets in-use resources, and makes them available for use. 41 */ 42 void dlb_resource_reset(struct dlb_hw *hw); 43 44 /** 45 * dlb_hw_create_sched_domain() - create a scheduling domain 46 * @hw: dlb_hw handle for a particular device. 47 * @args: scheduling domain creation arguments. 48 * @resp: response structure. 49 * 50 * This function creates a scheduling domain containing the resources specified 51 * in args. The individual resources (queues, ports, credit pools) can be 52 * configured after creating a scheduling domain. 53 * 54 * Return: 55 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 56 * assigned a detailed error code from enum dlb_error. If successful, resp->id 57 * contains the domain ID. 58 * 59 * Errors: 60 * EINVAL - A requested resource is unavailable, or the requested domain name 61 * is already in use. 62 * EFAULT - Internal error (resp->status not set). 63 */ 64 int dlb_hw_create_sched_domain(struct dlb_hw *hw, 65 struct dlb_create_sched_domain_args *args, 66 struct dlb_cmd_response *resp); 67 68 /** 69 * dlb_hw_create_ldb_pool() - create a load-balanced credit pool 70 * @hw: dlb_hw handle for a particular device. 71 * @domain_id: domain ID. 72 * @args: credit pool creation arguments. 73 * @resp: response structure. 74 * 75 * This function creates a load-balanced credit pool containing the number of 76 * requested credits. 77 * 78 * Return: 79 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 80 * assigned a detailed error code from enum dlb_error. If successful, resp->id 81 * contains the pool ID. 82 * 83 * Errors: 84 * EINVAL - A requested resource is unavailable, the domain is not configured, 85 * or the domain has already been started. 86 * EFAULT - Internal error (resp->status not set). 87 */ 88 int dlb_hw_create_ldb_pool(struct dlb_hw *hw, 89 u32 domain_id, 90 struct dlb_create_ldb_pool_args *args, 91 struct dlb_cmd_response *resp); 92 93 /** 94 * dlb_hw_create_dir_pool() - create a directed credit pool 95 * @hw: dlb_hw handle for a particular device. 96 * @domain_id: domain ID. 97 * @args: credit pool creation arguments. 98 * @resp: response structure. 99 * 100 * This function creates a directed credit pool containing the number of 101 * requested credits. 102 * 103 * Return: 104 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 105 * assigned a detailed error code from enum dlb_error. If successful, resp->id 106 * contains the pool ID. 107 * 108 * Errors: 109 * EINVAL - A requested resource is unavailable, the domain is not configured, 110 * or the domain has already been started. 111 * EFAULT - Internal error (resp->status not set). 112 */ 113 int dlb_hw_create_dir_pool(struct dlb_hw *hw, 114 u32 domain_id, 115 struct dlb_create_dir_pool_args *args, 116 struct dlb_cmd_response *resp); 117 118 /** 119 * dlb_hw_create_ldb_queue() - create a load-balanced queue 120 * @hw: dlb_hw handle for a particular device. 121 * @domain_id: domain ID. 122 * @args: queue creation arguments. 123 * @resp: response structure. 124 * 125 * This function creates a load-balanced queue. 126 * 127 * Return: 128 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 129 * assigned a detailed error code from enum dlb_error. If successful, resp->id 130 * contains the queue ID. 131 * 132 * Errors: 133 * EINVAL - A requested resource is unavailable, the domain is not configured, 134 * the domain has already been started, or the requested queue name is 135 * already in use. 136 * EFAULT - Internal error (resp->status not set). 137 */ 138 int dlb_hw_create_ldb_queue(struct dlb_hw *hw, 139 u32 domain_id, 140 struct dlb_create_ldb_queue_args *args, 141 struct dlb_cmd_response *resp); 142 143 /** 144 * dlb_hw_create_dir_queue() - create a directed queue 145 * @hw: dlb_hw handle for a particular device. 146 * @domain_id: domain ID. 147 * @args: queue creation arguments. 148 * @resp: response structure. 149 * 150 * This function creates a directed queue. 151 * 152 * Return: 153 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 154 * assigned a detailed error code from enum dlb_error. If successful, resp->id 155 * contains the queue ID. 156 * 157 * Errors: 158 * EINVAL - A requested resource is unavailable, the domain is not configured, 159 * or the domain has already been started. 160 * EFAULT - Internal error (resp->status not set). 161 */ 162 int dlb_hw_create_dir_queue(struct dlb_hw *hw, 163 u32 domain_id, 164 struct dlb_create_dir_queue_args *args, 165 struct dlb_cmd_response *resp); 166 167 /** 168 * dlb_hw_create_dir_port() - create a directed port 169 * @hw: dlb_hw handle for a particular device. 170 * @domain_id: domain ID. 171 * @args: port creation arguments. 172 * @pop_count_dma_base: base address of the pop count memory. This can be 173 * a PA or an IOVA. 174 * @cq_dma_base: base address of the CQ memory. This can be a PA or an IOVA. 175 * @resp: response structure. 176 * 177 * This function creates a directed port. 178 * 179 * Return: 180 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 181 * assigned a detailed error code from enum dlb_error. If successful, resp->id 182 * contains the port ID. 183 * 184 * Errors: 185 * EINVAL - A requested resource is unavailable, a credit setting is invalid, a 186 * pool ID is invalid, a pointer address is not properly aligned, the 187 * domain is not configured, or the domain has already been started. 188 * EFAULT - Internal error (resp->status not set). 189 */ 190 int dlb_hw_create_dir_port(struct dlb_hw *hw, 191 u32 domain_id, 192 struct dlb_create_dir_port_args *args, 193 u64 pop_count_dma_base, 194 u64 cq_dma_base, 195 struct dlb_cmd_response *resp); 196 197 /** 198 * dlb_hw_create_ldb_port() - create a load-balanced port 199 * @hw: dlb_hw handle for a particular device. 200 * @domain_id: domain ID. 201 * @args: port creation arguments. 202 * @pop_count_dma_base: base address of the pop count memory. This can be 203 * a PA or an IOVA. 204 * @cq_dma_base: base address of the CQ memory. This can be a PA or an IOVA. 205 * @resp: response structure. 206 * 207 * This function creates a load-balanced port. 208 * 209 * Return: 210 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 211 * assigned a detailed error code from enum dlb_error. If successful, resp->id 212 * contains the port ID. 213 * 214 * Errors: 215 * EINVAL - A requested resource is unavailable, a credit setting is invalid, a 216 * pool ID is invalid, a pointer address is not properly aligned, the 217 * domain is not configured, or the domain has already been started. 218 * EFAULT - Internal error (resp->status not set). 219 */ 220 int dlb_hw_create_ldb_port(struct dlb_hw *hw, 221 u32 domain_id, 222 struct dlb_create_ldb_port_args *args, 223 u64 pop_count_dma_base, 224 u64 cq_dma_base, 225 struct dlb_cmd_response *resp); 226 227 /** 228 * dlb_hw_start_domain() - start a scheduling domain 229 * @hw: dlb_hw handle for a particular device. 230 * @domain_id: domain ID. 231 * @args: start domain arguments. 232 * @resp: response structure. 233 * 234 * This function starts a scheduling domain, which allows applications to send 235 * traffic through it. Once a domain is started, its resources can no longer be 236 * configured (besides QID remapping and port enable/disable). 237 * 238 * Return: 239 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 240 * assigned a detailed error code from enum dlb_error. 241 * 242 * Errors: 243 * EINVAL - the domain is not configured, or the domain is already started. 244 */ 245 int dlb_hw_start_domain(struct dlb_hw *hw, 246 u32 domain_id, 247 struct dlb_start_domain_args *args, 248 struct dlb_cmd_response *resp); 249 250 /** 251 * dlb_hw_map_qid() - map a load-balanced queue to a load-balanced port 252 * @hw: dlb_hw handle for a particular device. 253 * @domain_id: domain ID. 254 * @args: map QID arguments. 255 * @resp: response structure. 256 * 257 * This function configures the DLB to schedule QEs from the specified queue to 258 * the specified port. Each load-balanced port can be mapped to up to 8 queues; 259 * each load-balanced queue can potentially map to all the load-balanced ports. 260 * 261 * A successful return does not necessarily mean the mapping was configured. If 262 * this function is unable to immediately map the queue to the port, it will 263 * add the requested operation to a per-port list of pending map/unmap 264 * operations, and (if it's not already running) launch a kernel thread that 265 * periodically attempts to process all pending operations. In a sense, this is 266 * an asynchronous function. 267 * 268 * This asynchronicity creates two views of the state of hardware: the actual 269 * hardware state and the requested state (as if every request completed 270 * immediately). If there are any pending map/unmap operations, the requested 271 * state will differ from the actual state. All validation is performed with 272 * respect to the pending state; for instance, if there are 8 pending map 273 * operations for port X, a request for a 9th will fail because a load-balanced 274 * port can only map up to 8 queues. 275 * 276 * Return: 277 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 278 * assigned a detailed error code from enum dlb_error. 279 * 280 * Errors: 281 * EINVAL - A requested resource is unavailable, invalid port or queue ID, or 282 * the domain is not configured. 283 * EFAULT - Internal error (resp->status not set). 284 */ 285 int dlb_hw_map_qid(struct dlb_hw *hw, 286 u32 domain_id, 287 struct dlb_map_qid_args *args, 288 struct dlb_cmd_response *resp); 289 290 /** 291 * dlb_hw_unmap_qid() - Unmap a load-balanced queue from a load-balanced port 292 * @hw: dlb_hw handle for a particular device. 293 * @domain_id: domain ID. 294 * @args: unmap QID arguments. 295 * @resp: response structure. 296 * 297 * This function configures the DLB to stop scheduling QEs from the specified 298 * queue to the specified port. 299 * 300 * A successful return does not necessarily mean the mapping was removed. If 301 * this function is unable to immediately unmap the queue from the port, it 302 * will add the requested operation to a per-port list of pending map/unmap 303 * operations, and (if it's not already running) launch a kernel thread that 304 * periodically attempts to process all pending operations. See 305 * dlb_hw_map_qid() for more details. 306 * 307 * Return: 308 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 309 * assigned a detailed error code from enum dlb_error. 310 * 311 * Errors: 312 * EINVAL - A requested resource is unavailable, invalid port or queue ID, or 313 * the domain is not configured. 314 * EFAULT - Internal error (resp->status not set). 315 */ 316 int dlb_hw_unmap_qid(struct dlb_hw *hw, 317 u32 domain_id, 318 struct dlb_unmap_qid_args *args, 319 struct dlb_cmd_response *resp); 320 321 /** 322 * dlb_finish_unmap_qid_procedures() - finish any pending unmap procedures 323 * @hw: dlb_hw handle for a particular device. 324 * 325 * This function attempts to finish any outstanding unmap procedures. 326 * This function should be called by the kernel thread responsible for 327 * finishing map/unmap procedures. 328 * 329 * Return: 330 * Returns the number of procedures that weren't completed. 331 */ 332 unsigned int dlb_finish_unmap_qid_procedures(struct dlb_hw *hw); 333 334 /** 335 * dlb_finish_map_qid_procedures() - finish any pending map procedures 336 * @hw: dlb_hw handle for a particular device. 337 * 338 * This function attempts to finish any outstanding map procedures. 339 * This function should be called by the kernel thread responsible for 340 * finishing map/unmap procedures. 341 * 342 * Return: 343 * Returns the number of procedures that weren't completed. 344 */ 345 unsigned int dlb_finish_map_qid_procedures(struct dlb_hw *hw); 346 347 /** 348 * dlb_hw_enable_ldb_port() - enable a load-balanced port for scheduling 349 * @hw: dlb_hw handle for a particular device. 350 * @domain_id: domain ID. 351 * @args: port enable arguments. 352 * @resp: response structure. 353 * 354 * This function configures the DLB to schedule QEs to a load-balanced port. 355 * Ports are enabled by default. 356 * 357 * Return: 358 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 359 * assigned a detailed error code from enum dlb_error. 360 * 361 * Errors: 362 * EINVAL - The port ID is invalid or the domain is not configured. 363 * EFAULT - Internal error (resp->status not set). 364 */ 365 int dlb_hw_enable_ldb_port(struct dlb_hw *hw, 366 u32 domain_id, 367 struct dlb_enable_ldb_port_args *args, 368 struct dlb_cmd_response *resp); 369 370 /** 371 * dlb_hw_disable_ldb_port() - disable a load-balanced port for scheduling 372 * @hw: dlb_hw handle for a particular device. 373 * @domain_id: domain ID. 374 * @args: port disable arguments. 375 * @resp: response structure. 376 * 377 * This function configures the DLB to stop scheduling QEs to a load-balanced 378 * port. Ports are enabled by default. 379 * 380 * Return: 381 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 382 * assigned a detailed error code from enum dlb_error. 383 * 384 * Errors: 385 * EINVAL - The port ID is invalid or the domain is not configured. 386 * EFAULT - Internal error (resp->status not set). 387 */ 388 int dlb_hw_disable_ldb_port(struct dlb_hw *hw, 389 u32 domain_id, 390 struct dlb_disable_ldb_port_args *args, 391 struct dlb_cmd_response *resp); 392 393 /** 394 * dlb_hw_enable_dir_port() - enable a directed port for scheduling 395 * @hw: dlb_hw handle for a particular device. 396 * @domain_id: domain ID. 397 * @args: port enable arguments. 398 * @resp: response structure. 399 * 400 * This function configures the DLB to schedule QEs to a directed port. 401 * Ports are enabled by default. 402 * 403 * Return: 404 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 405 * assigned a detailed error code from enum dlb_error. 406 * 407 * Errors: 408 * EINVAL - The port ID is invalid or the domain is not configured. 409 * EFAULT - Internal error (resp->status not set). 410 */ 411 int dlb_hw_enable_dir_port(struct dlb_hw *hw, 412 u32 domain_id, 413 struct dlb_enable_dir_port_args *args, 414 struct dlb_cmd_response *resp); 415 416 /** 417 * dlb_hw_disable_dir_port() - disable a directed port for scheduling 418 * @hw: dlb_hw handle for a particular device. 419 * @domain_id: domain ID. 420 * @args: port disable arguments. 421 * @resp: response structure. 422 * 423 * This function configures the DLB to stop scheduling QEs to a directed port. 424 * Ports are enabled by default. 425 * 426 * Return: 427 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 428 * assigned a detailed error code from enum dlb_error. 429 * 430 * Errors: 431 * EINVAL - The port ID is invalid or the domain is not configured. 432 * EFAULT - Internal error (resp->status not set). 433 */ 434 int dlb_hw_disable_dir_port(struct dlb_hw *hw, 435 u32 domain_id, 436 struct dlb_disable_dir_port_args *args, 437 struct dlb_cmd_response *resp); 438 439 /** 440 * dlb_configure_ldb_cq_interrupt() - configure load-balanced CQ for interrupts 441 * @hw: dlb_hw handle for a particular device. 442 * @port_id: load-balancd port ID. 443 * @vector: interrupt vector ID. Should be 0 for MSI or compressed MSI-X mode, 444 * else a value up to 64. 445 * @mode: interrupt type (DLB_CQ_ISR_MODE_MSI or DLB_CQ_ISR_MODE_MSIX) 446 * @threshold: the minimum CQ depth at which the interrupt can fire. Must be 447 * greater than 0. 448 * 449 * This function configures the DLB registers for load-balanced CQ's interrupts. 450 * This doesn't enable the CQ's interrupt; that can be done with 451 * dlb_arm_cq_interrupt() or through an interrupt arm QE. 452 * 453 * Return: 454 * Returns 0 upon success, < 0 otherwise. 455 * 456 * Errors: 457 * EINVAL - The port ID is invalid. 458 */ 459 int dlb_configure_ldb_cq_interrupt(struct dlb_hw *hw, 460 int port_id, 461 int vector, 462 int mode, 463 u16 threshold); 464 465 /** 466 * dlb_configure_dir_cq_interrupt() - configure directed CQ for interrupts 467 * @hw: dlb_hw handle for a particular device. 468 * @port_id: load-balancd port ID. 469 * @vector: interrupt vector ID. Should be 0 for MSI or compressed MSI-X mode, 470 * else a value up to 64. 471 * @mode: interrupt type (DLB_CQ_ISR_MODE_MSI or DLB_CQ_ISR_MODE_MSIX) 472 * @threshold: the minimum CQ depth at which the interrupt can fire. Must be 473 * greater than 0. 474 * 475 * This function configures the DLB registers for directed CQ's interrupts. 476 * This doesn't enable the CQ's interrupt; that can be done with 477 * dlb_arm_cq_interrupt() or through an interrupt arm QE. 478 * 479 * Return: 480 * Returns 0 upon success, < 0 otherwise. 481 * 482 * Errors: 483 * EINVAL - The port ID is invalid. 484 */ 485 int dlb_configure_dir_cq_interrupt(struct dlb_hw *hw, 486 int port_id, 487 int vector, 488 int mode, 489 u16 threshold); 490 491 /** 492 * dlb_enable_alarm_interrupts() - enable certain hardware alarm interrupts 493 * @hw: dlb_hw handle for a particular device. 494 * 495 * This function configures the ingress error alarm. (Other alarms are enabled 496 * by default.) 497 */ 498 void dlb_enable_alarm_interrupts(struct dlb_hw *hw); 499 500 /** 501 * dlb_disable_alarm_interrupts() - disable certain hardware alarm interrupts 502 * @hw: dlb_hw handle for a particular device. 503 * 504 * This function configures the ingress error alarm. (Other alarms are disabled 505 * by default.) 506 */ 507 void dlb_disable_alarm_interrupts(struct dlb_hw *hw); 508 509 /** 510 * dlb_set_msix_mode() - enable certain hardware alarm interrupts 511 * @hw: dlb_hw handle for a particular device. 512 * @mode: MSI-X mode (DLB_MSIX_MODE_PACKED or DLB_MSIX_MODE_COMPRESSED) 513 * 514 * This function configures the hardware to use either packed or compressed 515 * mode. This function should not be called if using MSI interrupts. 516 */ 517 void dlb_set_msix_mode(struct dlb_hw *hw, int mode); 518 519 /** 520 * dlb_arm_cq_interrupt() - arm a CQ's interrupt 521 * @hw: dlb_hw handle for a particular device. 522 * @port_id: port ID 523 * @is_ldb: true for load-balanced port, false for a directed port 524 * 525 * This function arms the CQ's interrupt. The CQ must be configured prior to 526 * calling this function. 527 * 528 * The function does no parameter validation; that is the caller's 529 * responsibility. 530 * 531 * Return: returns 0 upon success, <0 otherwise. 532 * 533 * EINVAL - Invalid port ID. 534 */ 535 int dlb_arm_cq_interrupt(struct dlb_hw *hw, int port_id, bool is_ldb); 536 537 /** 538 * dlb_read_compressed_cq_intr_status() - read compressed CQ interrupt status 539 * @hw: dlb_hw handle for a particular device. 540 * @ldb_interrupts: 2-entry array of u32 bitmaps 541 * @dir_interrupts: 4-entry array of u32 bitmaps 542 * 543 * This function can be called from a compressed CQ interrupt handler to 544 * determine which CQ interrupts have fired. The caller should take appropriate 545 * (such as waking threads blocked on a CQ's interrupt) then ack the interrupts 546 * with dlb_ack_compressed_cq_intr(). 547 */ 548 void dlb_read_compressed_cq_intr_status(struct dlb_hw *hw, 549 u32 *ldb_interrupts, 550 u32 *dir_interrupts); 551 552 /** 553 * dlb_ack_compressed_cq_intr_status() - ack compressed CQ interrupts 554 * @hw: dlb_hw handle for a particular device. 555 * @ldb_interrupts: 2-entry array of u32 bitmaps 556 * @dir_interrupts: 4-entry array of u32 bitmaps 557 * 558 * This function ACKs compressed CQ interrupts. Its arguments should be the 559 * same ones passed to dlb_read_compressed_cq_intr_status(). 560 */ 561 void dlb_ack_compressed_cq_intr(struct dlb_hw *hw, 562 u32 *ldb_interrupts, 563 u32 *dir_interrupts); 564 565 /** 566 * dlb_process_alarm_interrupt() - process an alarm interrupt 567 * @hw: dlb_hw handle for a particular device. 568 * 569 * This function reads the alarm syndrome, logs its, and acks the interrupt. 570 * This function should be called from the alarm interrupt handler when 571 * interrupt vector DLB_INT_ALARM fires. 572 */ 573 void dlb_process_alarm_interrupt(struct dlb_hw *hw); 574 575 /** 576 * dlb_process_ingress_error_interrupt() - process ingress error interrupts 577 * @hw: dlb_hw handle for a particular device. 578 * 579 * This function reads the alarm syndrome, logs it, notifies user-space, and 580 * acks the interrupt. This function should be called from the alarm interrupt 581 * handler when interrupt vector DLB_INT_INGRESS_ERROR fires. 582 */ 583 void dlb_process_ingress_error_interrupt(struct dlb_hw *hw); 584 585 /** 586 * dlb_get_group_sequence_numbers() - return a group's number of SNs per queue 587 * @hw: dlb_hw handle for a particular device. 588 * @group_id: sequence number group ID. 589 * 590 * This function returns the configured number of sequence numbers per queue 591 * for the specified group. 592 * 593 * Return: 594 * Returns -EINVAL if group_id is invalid, else the group's SNs per queue. 595 */ 596 int dlb_get_group_sequence_numbers(struct dlb_hw *hw, unsigned int group_id); 597 598 /** 599 * dlb_get_group_sequence_number_occupancy() - return a group's in-use slots 600 * @hw: dlb_hw handle for a particular device. 601 * @group_id: sequence number group ID. 602 * 603 * This function returns the group's number of in-use slots (i.e. load-balanced 604 * queues using the specified group). 605 * 606 * Return: 607 * Returns -EINVAL if group_id is invalid, else the group's occupancy. 608 */ 609 int dlb_get_group_sequence_number_occupancy(struct dlb_hw *hw, 610 unsigned int group_id); 611 612 /** 613 * dlb_set_group_sequence_numbers() - assign a group's number of SNs per queue 614 * @hw: dlb_hw handle for a particular device. 615 * @group_id: sequence number group ID. 616 * @val: requested amount of sequence numbers per queue. 617 * 618 * This function configures the group's number of sequence numbers per queue. 619 * val can be a power-of-two between 32 and 1024, inclusive. This setting can 620 * be configured until the first ordered load-balanced queue is configured, at 621 * which point the configuration is locked. 622 * 623 * Return: 624 * Returns 0 upon success; -EINVAL if group_id or val is invalid, -EPERM if an 625 * ordered queue is configured. 626 */ 627 int dlb_set_group_sequence_numbers(struct dlb_hw *hw, 628 unsigned int group_id, 629 unsigned long val); 630 631 /** 632 * dlb_reset_domain() - reset a scheduling domain 633 * @hw: dlb_hw handle for a particular device. 634 * @domain_id: domain ID. 635 * 636 * This function resets and frees a DLB scheduling domain and its associated 637 * resources. 638 * 639 * Pre-condition: the driver must ensure software has stopped sending QEs 640 * through this domain's producer ports before invoking this function, or 641 * undefined behavior will result. 642 * 643 * Return: 644 * Returns 0 upon success, -1 otherwise. 645 * 646 * EINVAL - Invalid domain ID, or the domain is not configured. 647 * EFAULT - Internal error. (Possibly caused if software is the pre-condition 648 * is not met.) 649 * ETIMEDOUT - Hardware component didn't reset in the expected time. 650 */ 651 int dlb_reset_domain(struct dlb_hw *hw, u32 domain_id); 652 653 /** 654 * dlb_ldb_port_owned_by_domain() - query whether a port is owned by a domain 655 * @hw: dlb_hw handle for a particular device. 656 * @domain_id: domain ID. 657 * @port_id: port ID. 658 * 659 * This function returns whether a load-balanced port is owned by a specified 660 * domain. 661 * 662 * Return: 663 * Returns 0 if false, 1 if true, <0 otherwise. 664 * 665 * EINVAL - Invalid domain or port ID, or the domain is not configured. 666 */ 667 int dlb_ldb_port_owned_by_domain(struct dlb_hw *hw, 668 u32 domain_id, 669 u32 port_id); 670 671 /** 672 * dlb_dir_port_owned_by_domain() - query whether a port is owned by a domain 673 * @hw: dlb_hw handle for a particular device. 674 * @domain_id: domain ID. 675 * @port_id: port ID. 676 * 677 * This function returns whether a directed port is owned by a specified 678 * domain. 679 * 680 * Return: 681 * Returns 0 if false, 1 if true, <0 otherwise. 682 * 683 * EINVAL - Invalid domain or port ID, or the domain is not configured. 684 */ 685 int dlb_dir_port_owned_by_domain(struct dlb_hw *hw, 686 u32 domain_id, 687 u32 port_id); 688 689 /** 690 * dlb_hw_get_num_resources() - query the PCI function's available resources 691 * @arg: pointer to resource counts. 692 * 693 * This function returns the number of available resources for the PF. 694 */ 695 void dlb_hw_get_num_resources(struct dlb_hw *hw, 696 struct dlb_get_num_resources_args *arg); 697 698 /** 699 * dlb_hw_get_num_used_resources() - query the PCI function's used resources 700 * @arg: pointer to resource counts. 701 * 702 * This function returns the number of resources in use by the PF. It fills in 703 * the fields that args points to, except the following: 704 * - max_contiguous_atomic_inflights 705 * - max_contiguous_hist_list_entries 706 * - max_contiguous_ldb_credits 707 * - max_contiguous_dir_credits 708 */ 709 void dlb_hw_get_num_used_resources(struct dlb_hw *hw, 710 struct dlb_get_num_resources_args *arg); 711 712 /** 713 * dlb_disable_dp_vasr_feature() - disable directed pipe VAS reset hardware 714 * @hw: dlb_hw handle for a particular device. 715 * 716 * This function disables certain hardware in the directed pipe, 717 * necessary to workaround a DLB VAS reset issue. 718 */ 719 void dlb_disable_dp_vasr_feature(struct dlb_hw *hw); 720 721 /** 722 * dlb_enable_excess_tokens_alarm() - enable interrupts for the excess token 723 * pop alarm 724 * @hw: dlb_hw handle for a particular device. 725 * 726 * This function enables the PF ingress error alarm interrupt to fire when an 727 * excess token pop occurs. 728 */ 729 void dlb_enable_excess_tokens_alarm(struct dlb_hw *hw); 730 731 /** 732 * dlb_disable_excess_tokens_alarm() - disable interrupts for the excess token 733 * pop alarm 734 * @hw: dlb_hw handle for a particular device. 735 * 736 * This function disables the PF ingress error alarm interrupt to fire when an 737 * excess token pop occurs. 738 */ 739 void dlb_disable_excess_tokens_alarm(struct dlb_hw *hw); 740 741 /** 742 * dlb_hw_get_ldb_queue_depth() - returns the depth of a load-balanced queue 743 * @hw: dlb_hw handle for a particular device. 744 * @domain_id: domain ID. 745 * @args: queue depth args 746 * 747 * This function returns the depth of a load-balanced queue. 748 * 749 * Return: 750 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 751 * assigned a detailed error code from enum dlb_error. If successful, resp->id 752 * contains the depth. 753 * 754 * Errors: 755 * EINVAL - Invalid domain ID or queue ID. 756 */ 757 int dlb_hw_get_ldb_queue_depth(struct dlb_hw *hw, 758 u32 domain_id, 759 struct dlb_get_ldb_queue_depth_args *args, 760 struct dlb_cmd_response *resp); 761 762 /** 763 * dlb_hw_get_dir_queue_depth() - returns the depth of a directed queue 764 * @hw: dlb_hw handle for a particular device. 765 * @domain_id: domain ID. 766 * @args: queue depth args 767 * 768 * This function returns the depth of a directed queue. 769 * 770 * Return: 771 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 772 * assigned a detailed error code from enum dlb_error. If successful, resp->id 773 * contains the depth. 774 * 775 * Errors: 776 * EINVAL - Invalid domain ID or queue ID. 777 */ 778 int dlb_hw_get_dir_queue_depth(struct dlb_hw *hw, 779 u32 domain_id, 780 struct dlb_get_dir_queue_depth_args *args, 781 struct dlb_cmd_response *resp); 782 783 /** 784 * dlb_hw_pending_port_unmaps() - returns the number of unmap operations in 785 * progress for a load-balanced port. 786 * @hw: dlb_hw handle for a particular device. 787 * @domain_id: domain ID. 788 * @args: number of unmaps in progress args 789 * 790 * Return: 791 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 792 * assigned a detailed error code from enum dlb_error. If successful, resp->id 793 * contains the number of unmaps in progress. 794 * 795 * Errors: 796 * EINVAL - Invalid port ID. 797 */ 798 int dlb_hw_pending_port_unmaps(struct dlb_hw *hw, 799 u32 domain_id, 800 struct dlb_pending_port_unmaps_args *args, 801 struct dlb_cmd_response *resp); 802 803 /** 804 * dlb_hw_enable_sparse_ldb_cq_mode() - enable sparse mode for load-balanced 805 * ports. 806 * @hw: dlb_hw handle for a particular device. 807 * 808 * This function must be called prior to configuring scheduling domains. 809 */ 810 void dlb_hw_enable_sparse_ldb_cq_mode(struct dlb_hw *hw); 811 812 /** 813 * dlb_hw_enable_sparse_dir_cq_mode() - enable sparse mode for directed ports 814 * @hw: dlb_hw handle for a particular device. 815 * 816 * This function must be called prior to configuring scheduling domains. 817 */ 818 void dlb_hw_enable_sparse_dir_cq_mode(struct dlb_hw *hw); 819 820 /** 821 * dlb_hw_set_qe_arbiter_weights() - program QE arbiter weights 822 * @hw: dlb_hw handle for a particular device. 823 * @weight: 8-entry array of arbiter weights. 824 * 825 * weight[N] programs priority N's weight. In cases where the 8 priorities are 826 * reduced to 4 bins, the mapping is: 827 * - weight[1] programs bin 0 828 * - weight[3] programs bin 1 829 * - weight[5] programs bin 2 830 * - weight[7] programs bin 3 831 */ 832 void dlb_hw_set_qe_arbiter_weights(struct dlb_hw *hw, u8 weight[8]); 833 834 /** 835 * dlb_hw_set_qid_arbiter_weights() - program QID arbiter weights 836 * @hw: dlb_hw handle for a particular device. 837 * @weight: 8-entry array of arbiter weights. 838 * 839 * weight[N] programs priority N's weight. In cases where the 8 priorities are 840 * reduced to 4 bins, the mapping is: 841 * - weight[1] programs bin 0 842 * - weight[3] programs bin 1 843 * - weight[5] programs bin 2 844 * - weight[7] programs bin 3 845 */ 846 void dlb_hw_set_qid_arbiter_weights(struct dlb_hw *hw, u8 weight[8]); 847 848 /** 849 * dlb_hw_enable_pp_sw_alarms() - enable out-of-credit alarm for all producer 850 * ports 851 * @hw: dlb_hw handle for a particular device. 852 */ 853 void dlb_hw_enable_pp_sw_alarms(struct dlb_hw *hw); 854 855 /** 856 * dlb_hw_disable_pp_sw_alarms() - disable out-of-credit alarm for all producer 857 * ports 858 * @hw: dlb_hw handle for a particular device. 859 */ 860 void dlb_hw_disable_pp_sw_alarms(struct dlb_hw *hw); 861 862 /** 863 * dlb_hw_disable_pf_to_vf_isr_pend_err() - disable alarm triggered by PF 864 * access to VF's ISR pending register 865 * @hw: dlb_hw handle for a particular device. 866 */ 867 void dlb_hw_disable_pf_to_vf_isr_pend_err(struct dlb_hw *hw); 868 869 /** 870 * dlb_hw_disable_vf_to_pf_isr_pend_err() - disable alarm triggered by VF 871 * access to PF's ISR pending register 872 * @hw: dlb_hw handle for a particular device. 873 */ 874 void dlb_hw_disable_vf_to_pf_isr_pend_err(struct dlb_hw *hw); 875 876 #endif /* __DLB_RESOURCE_H */ 877