1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2016-2020 Intel Corporation 3 */ 4 5 #ifndef __DLB2_RESOURCE_H 6 #define __DLB2_RESOURCE_H 7 8 #include "dlb2_user.h" 9 #include "dlb2_osdep_types.h" 10 11 /** 12 * dlb2_resource_init() - initialize the device 13 * @hw: pointer to struct dlb2_hw. 14 * @ver: device version. 15 * 16 * This function initializes the device's software state (pointed to by the hw 17 * argument) and programs global scheduling QoS registers. This function should 18 * be called during driver initialization. 19 * 20 * The dlb2_hw struct must be unique per DLB 2.0 device and persist until the 21 * device is reset. 22 * 23 * Return: 24 * Returns 0 upon success, <0 otherwise. 25 */ 26 int dlb2_resource_init(struct dlb2_hw *hw, enum dlb2_hw_ver ver); 27 28 /** 29 * dlb2_clr_pmcsr_disable() - power on bulk of DLB 2.0 logic 30 * @hw: dlb2_hw handle for a particular device. 31 * @ver: device version. 32 * 33 * Clearing the PMCSR must be done at initialization to make the device fully 34 * operational. 35 */ 36 void dlb2_clr_pmcsr_disable(struct dlb2_hw *hw, enum dlb2_hw_ver ver); 37 38 /** 39 * dlb2_resource_free() - free device state memory 40 * @hw: dlb2_hw handle for a particular device. 41 * 42 * This function frees software state pointed to by dlb2_hw. This function 43 * should be called when resetting the device or unloading the driver. 44 */ 45 void dlb2_resource_free(struct dlb2_hw *hw); 46 47 /** 48 * dlb2_resource_reset() - reset in-use resources to their initial state 49 * @hw: dlb2_hw handle for a particular device. 50 * 51 * This function resets in-use resources, and makes them available for use. 52 * All resources go back to their owning function, whether a PF or a VF. 53 */ 54 void dlb2_resource_reset(struct dlb2_hw *hw); 55 56 /** 57 * dlb2_hw_create_sched_domain() - create a scheduling domain 58 * @hw: dlb2_hw handle for a particular device. 59 * @args: scheduling domain creation arguments. 60 * @resp: response structure. 61 * @vdev_request: indicates whether this request came from a vdev. 62 * @vdev_id: If vdev_request is true, this contains the vdev's ID. 63 * 64 * This function creates a scheduling domain containing the resources specified 65 * in args. The individual resources (queues, ports, credits) can be configured 66 * after creating a scheduling domain. 67 * 68 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 69 * device. 70 * 71 * Return: 72 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 73 * assigned a detailed error code from enum dlb2_error. If successful, resp->id 74 * contains the domain ID. 75 * 76 * resp->id contains a virtual ID if vdev_request is true. 77 * 78 * Errors: 79 * EINVAL - A requested resource is unavailable, or the requested domain name 80 * is already in use. 81 * EFAULT - Internal error (resp->status not set). 82 */ 83 int dlb2_hw_create_sched_domain(struct dlb2_hw *hw, 84 struct dlb2_create_sched_domain_args *args, 85 struct dlb2_cmd_response *resp, 86 bool vdev_request, 87 unsigned int vdev_id); 88 89 /** 90 * dlb2_hw_create_ldb_queue() - create a load-balanced queue 91 * @hw: dlb2_hw handle for a particular device. 92 * @domain_id: domain ID. 93 * @args: queue creation arguments. 94 * @resp: response structure. 95 * @vdev_request: indicates whether this request came from a vdev. 96 * @vdev_id: If vdev_request is true, this contains the vdev's ID. 97 * 98 * This function creates a load-balanced queue. 99 * 100 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 101 * device. 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 dlb2_error. If successful, resp->id 106 * contains the queue ID. 107 * 108 * resp->id contains a virtual ID if vdev_request is true. 109 * 110 * Errors: 111 * EINVAL - A requested resource is unavailable, the domain is not configured, 112 * the domain has already been started, or the requested queue name is 113 * already in use. 114 * EFAULT - Internal error (resp->status not set). 115 */ 116 int dlb2_hw_create_ldb_queue(struct dlb2_hw *hw, 117 u32 domain_id, 118 struct dlb2_create_ldb_queue_args *args, 119 struct dlb2_cmd_response *resp, 120 bool vdev_request, 121 unsigned int vdev_id); 122 123 /** 124 * dlb2_hw_create_dir_queue() - create a directed queue 125 * @hw: dlb2_hw handle for a particular device. 126 * @domain_id: domain ID. 127 * @args: queue creation arguments. 128 * @resp: response structure. 129 * @vdev_request: indicates whether this request came from a vdev. 130 * @vdev_id: If vdev_request is true, this contains the vdev's ID. 131 * 132 * This function creates a directed queue. 133 * 134 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 135 * device. 136 * 137 * Return: 138 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 139 * assigned a detailed error code from enum dlb2_error. If successful, resp->id 140 * contains the queue ID. 141 * 142 * resp->id contains a virtual ID if vdev_request is true. 143 * 144 * Errors: 145 * EINVAL - A requested resource is unavailable, the domain is not configured, 146 * or the domain has already been started. 147 * EFAULT - Internal error (resp->status not set). 148 */ 149 int dlb2_hw_create_dir_queue(struct dlb2_hw *hw, 150 u32 domain_id, 151 struct dlb2_create_dir_queue_args *args, 152 struct dlb2_cmd_response *resp, 153 bool vdev_request, 154 unsigned int vdev_id); 155 156 /** 157 * dlb2_hw_create_dir_port() - create a directed port 158 * @hw: dlb2_hw handle for a particular device. 159 * @domain_id: domain ID. 160 * @args: port creation arguments. 161 * @cq_dma_base: base address of the CQ memory. This can be a PA or an IOVA. 162 * @resp: response structure. 163 * @vdev_request: indicates whether this request came from a vdev. 164 * @vdev_id: If vdev_request is true, this contains the vdev's ID. 165 * 166 * This function creates a directed port. 167 * 168 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 169 * device. 170 * 171 * Return: 172 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 173 * assigned a detailed error code from enum dlb2_error. If successful, resp->id 174 * contains the port ID. 175 * 176 * resp->id contains a virtual ID if vdev_request is true. 177 * 178 * Errors: 179 * EINVAL - A requested resource is unavailable, a credit setting is invalid, a 180 * pointer address is not properly aligned, the domain is not 181 * configured, or the domain has already been started. 182 * EFAULT - Internal error (resp->status not set). 183 */ 184 int dlb2_hw_create_dir_port(struct dlb2_hw *hw, 185 u32 domain_id, 186 struct dlb2_create_dir_port_args *args, 187 uintptr_t cq_dma_base, 188 struct dlb2_cmd_response *resp, 189 bool vdev_request, 190 unsigned int vdev_id); 191 192 /** 193 * dlb2_hw_create_ldb_port() - create a load-balanced port 194 * @hw: dlb2_hw handle for a particular device. 195 * @domain_id: domain ID. 196 * @args: port creation arguments. 197 * @cq_dma_base: base address of the CQ memory. This can be a PA or an IOVA. 198 * @resp: response structure. 199 * @vdev_request: indicates whether this request came from a vdev. 200 * @vdev_id: If vdev_request is true, this contains the vdev's ID. 201 * 202 * This function creates a load-balanced port. 203 * 204 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 205 * device. 206 * 207 * Return: 208 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 209 * assigned a detailed error code from enum dlb2_error. If successful, resp->id 210 * contains the port ID. 211 * 212 * resp->id contains a virtual ID if vdev_request is true. 213 * 214 * Errors: 215 * EINVAL - A requested resource is unavailable, a credit setting is invalid, a 216 * pointer address is not properly aligned, the domain is not 217 * configured, or the domain has already been started. 218 * EFAULT - Internal error (resp->status not set). 219 */ 220 int dlb2_hw_create_ldb_port(struct dlb2_hw *hw, 221 u32 domain_id, 222 struct dlb2_create_ldb_port_args *args, 223 uintptr_t cq_dma_base, 224 struct dlb2_cmd_response *resp, 225 bool vdev_request, 226 unsigned int vdev_id); 227 228 /** 229 * dlb2_hw_start_domain() - start a scheduling domain 230 * @hw: dlb2_hw handle for a particular device. 231 * @domain_id: domain ID. 232 * @args: start domain arguments. 233 * @resp: response structure. 234 * @vdev_request: indicates whether this request came from a vdev. 235 * @vdev_id: If vdev_request is true, this contains the vdev's ID. 236 * 237 * This function starts a scheduling domain, which allows applications to send 238 * traffic through it. Once a domain is started, its resources can no longer be 239 * configured (besides QID remapping and port enable/disable). 240 * 241 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 242 * device. 243 * 244 * Return: 245 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 246 * assigned a detailed error code from enum dlb2_error. 247 * 248 * Errors: 249 * EINVAL - the domain is not configured, or the domain is already started. 250 */ 251 int dlb2_hw_start_domain(struct dlb2_hw *hw, 252 u32 domain_id, 253 struct dlb2_start_domain_args *args, 254 struct dlb2_cmd_response *resp, 255 bool vdev_request, 256 unsigned int vdev_id); 257 258 /** 259 * dlb2_hw_map_qid() - map a load-balanced queue to a load-balanced port 260 * @hw: dlb2_hw handle for a particular device. 261 * @domain_id: domain ID. 262 * @args: map QID arguments. 263 * @resp: response structure. 264 * @vdev_request: indicates whether this request came from a vdev. 265 * @vdev_id: If vdev_request is true, this contains the vdev's ID. 266 * 267 * This function configures the DLB to schedule QEs from the specified queue 268 * to the specified port. Each load-balanced port can be mapped to up to 8 269 * queues; each load-balanced queue can potentially map to all the 270 * load-balanced ports. 271 * 272 * A successful return does not necessarily mean the mapping was configured. If 273 * this function is unable to immediately map the queue to the port, it will 274 * add the requested operation to a per-port list of pending map/unmap 275 * operations, and (if it's not already running) launch a kernel thread that 276 * periodically attempts to process all pending operations. In a sense, this is 277 * an asynchronous function. 278 * 279 * This asynchronicity creates two views of the state of hardware: the actual 280 * hardware state and the requested state (as if every request completed 281 * immediately). If there are any pending map/unmap operations, the requested 282 * state will differ from the actual state. All validation is performed with 283 * respect to the pending state; for instance, if there are 8 pending map 284 * operations for port X, a request for a 9th will fail because a load-balanced 285 * port can only map up to 8 queues. 286 * 287 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 288 * device. 289 * 290 * Return: 291 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 292 * assigned a detailed error code from enum dlb2_error. 293 * 294 * Errors: 295 * EINVAL - A requested resource is unavailable, invalid port or queue ID, or 296 * the domain is not configured. 297 * EFAULT - Internal error (resp->status not set). 298 */ 299 int dlb2_hw_map_qid(struct dlb2_hw *hw, 300 u32 domain_id, 301 struct dlb2_map_qid_args *args, 302 struct dlb2_cmd_response *resp, 303 bool vdev_request, 304 unsigned int vdev_id); 305 306 /** 307 * dlb2_hw_unmap_qid() - Unmap a load-balanced queue from a load-balanced port 308 * @hw: dlb2_hw handle for a particular device. 309 * @domain_id: domain ID. 310 * @args: unmap QID arguments. 311 * @resp: response structure. 312 * @vdev_request: indicates whether this request came from a vdev. 313 * @vdev_id: If vdev_request is true, this contains the vdev's ID. 314 * 315 * This function configures the DLB to stop scheduling QEs from the specified 316 * queue to the specified port. 317 * 318 * A successful return does not necessarily mean the mapping was removed. If 319 * this function is unable to immediately unmap the queue from the port, it 320 * will add the requested operation to a per-port list of pending map/unmap 321 * operations, and (if it's not already running) launch a kernel thread that 322 * periodically attempts to process all pending operations. See 323 * dlb2_hw_map_qid() for more details. 324 * 325 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 326 * device. 327 * 328 * Return: 329 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 330 * assigned a detailed error code from enum dlb2_error. 331 * 332 * Errors: 333 * EINVAL - A requested resource is unavailable, invalid port or queue ID, or 334 * the domain is not configured. 335 * EFAULT - Internal error (resp->status not set). 336 */ 337 int dlb2_hw_unmap_qid(struct dlb2_hw *hw, 338 u32 domain_id, 339 struct dlb2_unmap_qid_args *args, 340 struct dlb2_cmd_response *resp, 341 bool vdev_request, 342 unsigned int vdev_id); 343 344 /** 345 * dlb2_finish_unmap_qid_procedures() - finish any pending unmap procedures 346 * @hw: dlb2_hw handle for a particular device. 347 * 348 * This function attempts to finish any outstanding unmap procedures. 349 * This function should be called by the kernel thread responsible for 350 * finishing map/unmap procedures. 351 * 352 * Return: 353 * Returns the number of procedures that weren't completed. 354 */ 355 unsigned int dlb2_finish_unmap_qid_procedures(struct dlb2_hw *hw); 356 357 /** 358 * dlb2_finish_map_qid_procedures() - finish any pending map procedures 359 * @hw: dlb2_hw handle for a particular device. 360 * 361 * This function attempts to finish any outstanding map procedures. 362 * This function should be called by the kernel thread responsible for 363 * finishing map/unmap procedures. 364 * 365 * Return: 366 * Returns the number of procedures that weren't completed. 367 */ 368 unsigned int dlb2_finish_map_qid_procedures(struct dlb2_hw *hw); 369 370 /** 371 * dlb2_hw_enable_ldb_port() - enable a load-balanced port for scheduling 372 * @hw: dlb2_hw handle for a particular device. 373 * @domain_id: domain ID. 374 * @args: port enable arguments. 375 * @resp: response structure. 376 * @vdev_request: indicates whether this request came from a vdev. 377 * @vdev_id: If vdev_request is true, this contains the vdev's ID. 378 * 379 * This function configures the DLB to schedule QEs to a load-balanced port. 380 * Ports are enabled by default. 381 * 382 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 383 * device. 384 * 385 * Return: 386 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 387 * assigned a detailed error code from enum dlb2_error. 388 * 389 * Errors: 390 * EINVAL - The port ID is invalid or the domain is not configured. 391 * EFAULT - Internal error (resp->status not set). 392 */ 393 int dlb2_hw_enable_ldb_port(struct dlb2_hw *hw, 394 u32 domain_id, 395 struct dlb2_enable_ldb_port_args *args, 396 struct dlb2_cmd_response *resp, 397 bool vdev_request, 398 unsigned int vdev_id); 399 400 /** 401 * dlb2_hw_disable_ldb_port() - disable a load-balanced port for scheduling 402 * @hw: dlb2_hw handle for a particular device. 403 * @domain_id: domain ID. 404 * @args: port disable arguments. 405 * @resp: response structure. 406 * @vdev_request: indicates whether this request came from a vdev. 407 * @vdev_id: If vdev_request is true, this contains the vdev's ID. 408 * 409 * This function configures the DLB to stop scheduling QEs to a load-balanced 410 * port. Ports are enabled by default. 411 * 412 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 413 * device. 414 * 415 * Return: 416 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 417 * assigned a detailed error code from enum dlb2_error. 418 * 419 * Errors: 420 * EINVAL - The port ID is invalid or the domain is not configured. 421 * EFAULT - Internal error (resp->status not set). 422 */ 423 int dlb2_hw_disable_ldb_port(struct dlb2_hw *hw, 424 u32 domain_id, 425 struct dlb2_disable_ldb_port_args *args, 426 struct dlb2_cmd_response *resp, 427 bool vdev_request, 428 unsigned int vdev_id); 429 430 /** 431 * dlb2_hw_enable_dir_port() - enable a directed port for scheduling 432 * @hw: dlb2_hw handle for a particular device. 433 * @domain_id: domain ID. 434 * @args: port enable arguments. 435 * @resp: response structure. 436 * @vdev_request: indicates whether this request came from a vdev. 437 * @vdev_id: If vdev_request is true, this contains the vdev's ID. 438 * 439 * This function configures the DLB to schedule QEs to a directed port. 440 * Ports are enabled by default. 441 * 442 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 443 * device. 444 * 445 * Return: 446 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 447 * assigned a detailed error code from enum dlb2_error. 448 * 449 * Errors: 450 * EINVAL - The port ID is invalid or the domain is not configured. 451 * EFAULT - Internal error (resp->status not set). 452 */ 453 int dlb2_hw_enable_dir_port(struct dlb2_hw *hw, 454 u32 domain_id, 455 struct dlb2_enable_dir_port_args *args, 456 struct dlb2_cmd_response *resp, 457 bool vdev_request, 458 unsigned int vdev_id); 459 460 /** 461 * dlb2_hw_disable_dir_port() - disable a directed port for scheduling 462 * @hw: dlb2_hw handle for a particular device. 463 * @domain_id: domain ID. 464 * @args: port disable arguments. 465 * @resp: response structure. 466 * @vdev_request: indicates whether this request came from a vdev. 467 * @vdev_id: If vdev_request is true, this contains the vdev's ID. 468 * 469 * This function configures the DLB to stop scheduling QEs to a directed port. 470 * Ports are enabled by default. 471 * 472 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 473 * device. 474 * 475 * Return: 476 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 477 * assigned a detailed error code from enum dlb2_error. 478 * 479 * Errors: 480 * EINVAL - The port ID is invalid or the domain is not configured. 481 * EFAULT - Internal error (resp->status not set). 482 */ 483 int dlb2_hw_disable_dir_port(struct dlb2_hw *hw, 484 u32 domain_id, 485 struct dlb2_disable_dir_port_args *args, 486 struct dlb2_cmd_response *resp, 487 bool vdev_request, 488 unsigned int vdev_id); 489 490 /** 491 * dlb2_configure_ldb_cq_interrupt() - configure load-balanced CQ for 492 * interrupts 493 * @hw: dlb2_hw handle for a particular device. 494 * @port_id: load-balanced port ID. 495 * @vector: interrupt vector ID. Should be 0 for MSI or compressed MSI-X mode, 496 * else a value up to 64. 497 * @mode: interrupt type (DLB2_CQ_ISR_MODE_MSI or DLB2_CQ_ISR_MODE_MSIX) 498 * @vf: If the port is VF-owned, the VF's ID. This is used for translating the 499 * virtual port ID to a physical port ID. Ignored if mode is not MSI. 500 * @owner_vf: the VF to route the interrupt to. Ignore if mode is not MSI. 501 * @threshold: the minimum CQ depth at which the interrupt can fire. Must be 502 * greater than 0. 503 * 504 * This function configures the DLB registers for load-balanced CQ's 505 * interrupts. This doesn't enable the CQ's interrupt; that can be done with 506 * dlb2_arm_cq_interrupt() or through an interrupt arm QE. 507 * 508 * Return: 509 * Returns 0 upon success, < 0 otherwise. 510 * 511 * Errors: 512 * EINVAL - The port ID is invalid. 513 */ 514 int dlb2_configure_ldb_cq_interrupt(struct dlb2_hw *hw, 515 int port_id, 516 int vector, 517 int mode, 518 unsigned int vf, 519 unsigned int owner_vf, 520 u16 threshold); 521 522 /** 523 * dlb2_configure_dir_cq_interrupt() - configure directed CQ for interrupts 524 * @hw: dlb2_hw handle for a particular device. 525 * @port_id: load-balanced port ID. 526 * @vector: interrupt vector ID. Should be 0 for MSI or compressed MSI-X mode, 527 * else a value up to 64. 528 * @mode: interrupt type (DLB2_CQ_ISR_MODE_MSI or DLB2_CQ_ISR_MODE_MSIX) 529 * @vf: If the port is VF-owned, the VF's ID. This is used for translating the 530 * virtual port ID to a physical port ID. Ignored if mode is not MSI. 531 * @owner_vf: the VF to route the interrupt to. Ignore if mode is not MSI. 532 * @threshold: the minimum CQ depth at which the interrupt can fire. Must be 533 * greater than 0. 534 * 535 * This function configures the DLB registers for directed CQ's interrupts. 536 * This doesn't enable the CQ's interrupt; that can be done with 537 * dlb2_arm_cq_interrupt() or through an interrupt arm QE. 538 * 539 * Return: 540 * Returns 0 upon success, < 0 otherwise. 541 * 542 * Errors: 543 * EINVAL - The port ID is invalid. 544 */ 545 int dlb2_configure_dir_cq_interrupt(struct dlb2_hw *hw, 546 int port_id, 547 int vector, 548 int mode, 549 unsigned int vf, 550 unsigned int owner_vf, 551 u16 threshold); 552 553 /** 554 * dlb2_enable_ingress_error_alarms() - enable ingress error alarm interrupts 555 * @hw: dlb2_hw handle for a particular device. 556 */ 557 void dlb2_enable_ingress_error_alarms(struct dlb2_hw *hw); 558 559 /** 560 * dlb2_disable_ingress_error_alarms() - disable ingress error alarm interrupts 561 * @hw: dlb2_hw handle for a particular device. 562 */ 563 void dlb2_disable_ingress_error_alarms(struct dlb2_hw *hw); 564 565 /** 566 * dlb2_set_msix_mode() - enable certain hardware alarm interrupts 567 * @hw: dlb2_hw handle for a particular device. 568 * @mode: MSI-X mode (DLB2_MSIX_MODE_PACKED or DLB2_MSIX_MODE_COMPRESSED) 569 * 570 * This function configures the hardware to use either packed or compressed 571 * mode. This function should not be called if using MSI interrupts. 572 */ 573 void dlb2_set_msix_mode(struct dlb2_hw *hw, int mode); 574 575 /** 576 * dlb2_ack_msix_interrupt() - Ack an MSI-X interrupt 577 * @hw: dlb2_hw handle for a particular device. 578 * @vector: interrupt vector. 579 * 580 * Note: Only needed for PF service interrupts (vector 0). CQ interrupts are 581 * acked in dlb2_ack_compressed_cq_intr(). 582 */ 583 void dlb2_ack_msix_interrupt(struct dlb2_hw *hw, int vector); 584 585 /** 586 * dlb2_arm_cq_interrupt() - arm a CQ's interrupt 587 * @hw: dlb2_hw handle for a particular device. 588 * @port_id: port ID 589 * @is_ldb: true for load-balanced port, false for a directed port 590 * @vdev_request: indicates whether this request came from a vdev. 591 * @vdev_id: If vdev_request is true, this contains the vdev's ID. 592 * 593 * This function arms the CQ's interrupt. The CQ must be configured prior to 594 * calling this function. 595 * 596 * The function does no parameter validation; that is the caller's 597 * responsibility. 598 * 599 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 600 * device. 601 * 602 * Return: returns 0 upon success, <0 otherwise. 603 * 604 * EINVAL - Invalid port ID. 605 */ 606 int dlb2_arm_cq_interrupt(struct dlb2_hw *hw, 607 int port_id, 608 bool is_ldb, 609 bool vdev_request, 610 unsigned int vdev_id); 611 612 /** 613 * dlb2_read_compressed_cq_intr_status() - read compressed CQ interrupt status 614 * @hw: dlb2_hw handle for a particular device. 615 * @ldb_interrupts: 2-entry array of u32 bitmaps 616 * @dir_interrupts: 4-entry array of u32 bitmaps 617 * 618 * This function can be called from a compressed CQ interrupt handler to 619 * determine which CQ interrupts have fired. The caller should take appropriate 620 * (such as waking threads blocked on a CQ's interrupt) then ack the interrupts 621 * with dlb2_ack_compressed_cq_intr(). 622 */ 623 void dlb2_read_compressed_cq_intr_status(struct dlb2_hw *hw, 624 u32 *ldb_interrupts, 625 u32 *dir_interrupts); 626 627 /** 628 * dlb2_ack_compressed_cq_intr_status() - ack compressed CQ interrupts 629 * @hw: dlb2_hw handle for a particular device. 630 * @ldb_interrupts: 2-entry array of u32 bitmaps 631 * @dir_interrupts: 4-entry array of u32 bitmaps 632 * 633 * This function ACKs compressed CQ interrupts. Its arguments should be the 634 * same ones passed to dlb2_read_compressed_cq_intr_status(). 635 */ 636 void dlb2_ack_compressed_cq_intr(struct dlb2_hw *hw, 637 u32 *ldb_interrupts, 638 u32 *dir_interrupts); 639 640 /** 641 * dlb2_read_vf_intr_status() - read the VF interrupt status register 642 * @hw: dlb2_hw handle for a particular device. 643 * 644 * This function can be called from a VF's interrupt handler to determine 645 * which interrupts have fired. The first 31 bits correspond to CQ interrupt 646 * vectors, and the final bit is for the PF->VF mailbox interrupt vector. 647 * 648 * Return: 649 * Returns a bit vector indicating which interrupt vectors are active. 650 */ 651 u32 dlb2_read_vf_intr_status(struct dlb2_hw *hw); 652 653 /** 654 * dlb2_ack_vf_intr_status() - ack VF interrupts 655 * @hw: dlb2_hw handle for a particular device. 656 * @interrupts: 32-bit bitmap 657 * 658 * This function ACKs a VF's interrupts. Its interrupts argument should be the 659 * value returned by dlb2_read_vf_intr_status(). 660 */ 661 void dlb2_ack_vf_intr_status(struct dlb2_hw *hw, u32 interrupts); 662 663 /** 664 * dlb2_ack_vf_msi_intr() - ack VF MSI interrupt 665 * @hw: dlb2_hw handle for a particular device. 666 * @interrupts: 32-bit bitmap 667 * 668 * This function clears the VF's MSI interrupt pending register. Its interrupts 669 * argument should be contain the MSI vectors to ACK. For example, if MSI MME 670 * is in mode 0, then one bit 0 should ever be set. 671 */ 672 void dlb2_ack_vf_msi_intr(struct dlb2_hw *hw, u32 interrupts); 673 674 /** 675 * dlb2_ack_pf_mbox_int() - ack PF->VF mailbox interrupt 676 * @hw: dlb2_hw handle for a particular device. 677 * 678 * When done processing the PF mailbox request, this function unsets 679 * the PF's mailbox ISR register. 680 */ 681 void dlb2_ack_pf_mbox_int(struct dlb2_hw *hw); 682 683 /** 684 * dlb2_read_vdev_to_pf_int_bitvec() - return a bit vector of all requesting 685 * vdevs 686 * @hw: dlb2_hw handle for a particular device. 687 * 688 * When the vdev->PF ISR fires, this function can be called to determine which 689 * vdev(s) are requesting service. This bitvector must be passed to 690 * dlb2_ack_vdev_to_pf_int() when processing is complete for all requesting 691 * vdevs. 692 * 693 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 694 * device. 695 * 696 * Return: 697 * Returns a bit vector indicating which VFs (0-15) have requested service. 698 */ 699 u32 dlb2_read_vdev_to_pf_int_bitvec(struct dlb2_hw *hw); 700 701 /** 702 * dlb2_ack_vdev_mbox_int() - ack processed vdev->PF mailbox interrupt 703 * @hw: dlb2_hw handle for a particular device. 704 * @bitvec: bit vector returned by dlb2_read_vdev_to_pf_int_bitvec() 705 * 706 * When done processing all VF mailbox requests, this function unsets the VF's 707 * mailbox ISR register. 708 * 709 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 710 * device. 711 */ 712 void dlb2_ack_vdev_mbox_int(struct dlb2_hw *hw, u32 bitvec); 713 714 /** 715 * dlb2_read_vf_flr_int_bitvec() - return a bit vector of all VFs requesting 716 * FLR 717 * @hw: dlb2_hw handle for a particular device. 718 * 719 * When the VF FLR ISR fires, this function can be called to determine which 720 * VF(s) are requesting FLRs. This bitvector must passed to 721 * dlb2_ack_vf_flr_int() when processing is complete for all requesting VFs. 722 * 723 * Return: 724 * Returns a bit vector indicating which VFs (0-15) have requested FLRs. 725 */ 726 u32 dlb2_read_vf_flr_int_bitvec(struct dlb2_hw *hw); 727 728 /** 729 * dlb2_ack_vf_flr_int() - ack processed VF<->PF interrupt(s) 730 * @hw: dlb2_hw handle for a particular device. 731 * @bitvec: bit vector returned by dlb2_read_vf_flr_int_bitvec() 732 * 733 * When done processing all VF FLR requests, this function unsets the VF's FLR 734 * ISR register. 735 */ 736 void dlb2_ack_vf_flr_int(struct dlb2_hw *hw, u32 bitvec); 737 738 /** 739 * dlb2_ack_vdev_to_pf_int() - ack processed VF mbox and FLR interrupt(s) 740 * @hw: dlb2_hw handle for a particular device. 741 * @mbox_bitvec: bit vector returned by dlb2_read_vdev_to_pf_int_bitvec() 742 * @flr_bitvec: bit vector returned by dlb2_read_vf_flr_int_bitvec() 743 * 744 * When done processing all VF requests, this function communicates to the 745 * hardware that processing is complete. 746 * 747 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 748 * device. 749 */ 750 void dlb2_ack_vdev_to_pf_int(struct dlb2_hw *hw, 751 u32 mbox_bitvec, 752 u32 flr_bitvec); 753 754 /** 755 * dlb2_process_wdt_interrupt() - process watchdog timer interrupts 756 * @hw: dlb2_hw handle for a particular device. 757 * 758 * This function reads the watchdog timer interrupt cause registers to 759 * determine which port(s) had a watchdog timeout, and notifies the 760 * application(s) that own the port(s). 761 */ 762 void dlb2_process_wdt_interrupt(struct dlb2_hw *hw); 763 764 /** 765 * dlb2_process_alarm_interrupt() - process an alarm interrupt 766 * @hw: dlb2_hw handle for a particular device. 767 * 768 * This function reads and logs the alarm syndrome, then acks the interrupt. 769 * This function should be called from the alarm interrupt handler when 770 * interrupt vector DLB2_INT_ALARM fires. 771 */ 772 void dlb2_process_alarm_interrupt(struct dlb2_hw *hw); 773 774 /** 775 * dlb2_process_ingress_error_interrupt() - process ingress error interrupts 776 * @hw: dlb2_hw handle for a particular device. 777 * 778 * This function reads the alarm syndrome, logs it, notifies user-space, and 779 * acks the interrupt. This function should be called from the alarm interrupt 780 * handler when interrupt vector DLB2_INT_INGRESS_ERROR fires. 781 * 782 * Return: 783 * Returns true if an ingress error interrupt occurred, false otherwise 784 */ 785 bool dlb2_process_ingress_error_interrupt(struct dlb2_hw *hw); 786 787 /** 788 * dlb2_get_group_sequence_numbers() - return a group's number of SNs per queue 789 * @hw: dlb2_hw handle for a particular device. 790 * @group_id: sequence number group ID. 791 * 792 * This function returns the configured number of sequence numbers per queue 793 * for the specified group. 794 * 795 * Return: 796 * Returns -EINVAL if group_id is invalid, else the group's SNs per queue. 797 */ 798 int dlb2_get_group_sequence_numbers(struct dlb2_hw *hw, 799 unsigned int group_id); 800 801 /** 802 * dlb2_get_group_sequence_number_occupancy() - return a group's in-use slots 803 * @hw: dlb2_hw handle for a particular device. 804 * @group_id: sequence number group ID. 805 * 806 * This function returns the group's number of in-use slots (i.e. load-balanced 807 * queues using the specified group). 808 * 809 * Return: 810 * Returns -EINVAL if group_id is invalid, else the group's SNs per queue. 811 */ 812 int dlb2_get_group_sequence_number_occupancy(struct dlb2_hw *hw, 813 unsigned int group_id); 814 815 /** 816 * dlb2_set_group_sequence_numbers() - assign a group's number of SNs per queue 817 * @hw: dlb2_hw handle for a particular device. 818 * @group_id: sequence number group ID. 819 * @val: requested amount of sequence numbers per queue. 820 * 821 * This function configures the group's number of sequence numbers per queue. 822 * val can be a power-of-two between 32 and 1024, inclusive. This setting can 823 * be configured until the first ordered load-balanced queue is configured, at 824 * which point the configuration is locked. 825 * 826 * Return: 827 * Returns 0 upon success; -EINVAL if group_id or val is invalid, -EPERM if an 828 * ordered queue is configured. 829 */ 830 int dlb2_set_group_sequence_numbers(struct dlb2_hw *hw, 831 u32 group_id, 832 u32 val); 833 834 /** 835 * dlb2_reset_domain() - reset a scheduling domain 836 * @hw: dlb2_hw handle for a particular device. 837 * @domain_id: domain ID. 838 * @vdev_request: indicates whether this request came from a vdev. 839 * @vdev_id: If vdev_request is true, this contains the vdev's ID. 840 * 841 * This function resets and frees a DLB 2.0 scheduling domain and its associated 842 * resources. 843 * 844 * Pre-condition: the driver must ensure software has stopped sending QEs 845 * through this domain's producer ports before invoking this function, or 846 * undefined behavior will result. 847 * 848 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 849 * device. 850 * 851 * Return: 852 * Returns 0 upon success, -1 otherwise. 853 * 854 * EINVAL - Invalid domain ID, or the domain is not configured. 855 * EFAULT - Internal error. (Possibly caused if software is the pre-condition 856 * is not met.) 857 * ETIMEDOUT - Hardware component didn't reset in the expected time. 858 */ 859 int dlb2_reset_domain(struct dlb2_hw *hw, 860 u32 domain_id, 861 bool vdev_request, 862 unsigned int vdev_id); 863 864 /** 865 * dlb2_ldb_port_owned_by_domain() - query whether a port is owned by a domain 866 * @hw: dlb2_hw handle for a particular device. 867 * @domain_id: domain ID. 868 * @port_id: indicates whether this request came from a VF. 869 * @vdev_request: indicates whether this request came from a vdev. 870 * @vdev_id: If vdev_request is true, this contains the vdev's ID. 871 * 872 * This function returns whether a load-balanced port is owned by a specified 873 * domain. 874 * 875 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 876 * device. 877 * 878 * Return: 879 * Returns 0 if false, 1 if true, <0 otherwise. 880 * 881 * EINVAL - Invalid domain or port ID, or the domain is not configured. 882 */ 883 int dlb2_ldb_port_owned_by_domain(struct dlb2_hw *hw, 884 u32 domain_id, 885 u32 port_id, 886 bool vdev_request, 887 unsigned int vdev_id); 888 889 /** 890 * dlb2_dir_port_owned_by_domain() - query whether a port is owned by a domain 891 * @hw: dlb2_hw handle for a particular device. 892 * @domain_id: domain ID. 893 * @port_id: indicates whether this request came from a VF. 894 * @vdev_request: indicates whether this request came from a vdev. 895 * @vdev_id: If vdev_request is true, this contains the vdev's ID. 896 * 897 * This function returns whether a directed port is owned by a specified 898 * domain. 899 * 900 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 901 * device. 902 * 903 * Return: 904 * Returns 0 if false, 1 if true, <0 otherwise. 905 * 906 * EINVAL - Invalid domain or port ID, or the domain is not configured. 907 */ 908 int dlb2_dir_port_owned_by_domain(struct dlb2_hw *hw, 909 u32 domain_id, 910 u32 port_id, 911 bool vdev_request, 912 unsigned int vdev_id); 913 914 /** 915 * dlb2_hw_get_num_resources() - query the PCI function's available resources 916 * @hw: dlb2_hw handle for a particular device. 917 * @arg: pointer to resource counts. 918 * @vdev_request: indicates whether this request came from a vdev. 919 * @vdev_id: If vdev_request is true, this contains the vdev's ID. 920 * 921 * This function returns the number of available resources for the PF or for a 922 * VF. 923 * 924 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 925 * device. 926 * 927 * Return: 928 * Returns 0 upon success, -EINVAL if vdev_request is true and vdev_id is 929 * invalid. 930 */ 931 int dlb2_hw_get_num_resources(struct dlb2_hw *hw, 932 struct dlb2_get_num_resources_args *arg, 933 bool vdev_request, 934 unsigned int vdev_id); 935 936 /** 937 * dlb2_hw_get_num_used_resources() - query the PCI function's used resources 938 * @hw: dlb2_hw handle for a particular device. 939 * @arg: pointer to resource counts. 940 * @vdev_request: indicates whether this request came from a vdev. 941 * @vdev_id: If vdev_request is true, this contains the vdev's ID. 942 * 943 * This function returns the number of resources in use by the PF or a VF. It 944 * fills in the fields that args points to, except the following: 945 * - max_contiguous_atomic_inflights 946 * - max_contiguous_hist_list_entries 947 * - max_contiguous_ldb_credits 948 * - max_contiguous_dir_credits 949 * 950 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 951 * device. 952 * 953 * Return: 954 * Returns 0 upon success, -EINVAL if vdev_request is true and vdev_id is 955 * invalid. 956 */ 957 int dlb2_hw_get_num_used_resources(struct dlb2_hw *hw, 958 struct dlb2_get_num_resources_args *arg, 959 bool vdev_request, 960 unsigned int vdev_id); 961 962 /** 963 * dlb2_send_async_vdev_to_pf_msg() - (vdev only) send a mailbox message to 964 * the PF 965 * @hw: dlb2_hw handle for a particular device. 966 * 967 * This function sends a VF->PF mailbox message. It is asynchronous, so it 968 * returns once the message is sent but potentially before the PF has processed 969 * the message. The caller must call dlb2_vdev_to_pf_complete() to determine 970 * when the PF has finished processing the request. 971 * 972 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 973 * device. 974 */ 975 void dlb2_send_async_vdev_to_pf_msg(struct dlb2_hw *hw); 976 977 /** 978 * dlb2_vdev_to_pf_complete() - check the status of an asynchronous mailbox 979 * request 980 * @hw: dlb2_hw handle for a particular device. 981 * 982 * This function returns a boolean indicating whether the PF has finished 983 * processing a VF->PF mailbox request. It should only be called after sending 984 * an asynchronous request with dlb2_send_async_vdev_to_pf_msg(). 985 * 986 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 987 * device. 988 */ 989 bool dlb2_vdev_to_pf_complete(struct dlb2_hw *hw); 990 991 /** 992 * dlb2_vf_flr_complete() - check the status of a VF FLR 993 * @hw: dlb2_hw handle for a particular device. 994 * 995 * This function returns a boolean indicating whether the PF has finished 996 * executing the VF FLR. It should only be called after setting the VF's FLR 997 * bit. 998 */ 999 bool dlb2_vf_flr_complete(struct dlb2_hw *hw); 1000 1001 /** 1002 * dlb2_send_async_pf_to_vdev_msg() - (PF only) send a mailbox message to a 1003 * vdev 1004 * @hw: dlb2_hw handle for a particular device. 1005 * @vdev_id: vdev ID. 1006 * 1007 * This function sends a PF->vdev mailbox message. It is asynchronous, so it 1008 * returns once the message is sent but potentially before the vdev has 1009 * processed the message. The caller must call dlb2_pf_to_vdev_complete() to 1010 * determine when the vdev has finished processing the request. 1011 * 1012 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 1013 * device. 1014 */ 1015 void dlb2_send_async_pf_to_vdev_msg(struct dlb2_hw *hw, unsigned int vdev_id); 1016 1017 /** 1018 * dlb2_pf_to_vdev_complete() - check the status of an asynchronous mailbox 1019 * request 1020 * @hw: dlb2_hw handle for a particular device. 1021 * @vdev_id: vdev ID. 1022 * 1023 * This function returns a boolean indicating whether the vdev has finished 1024 * processing a PF->vdev mailbox request. It should only be called after 1025 * sending an asynchronous request with dlb2_send_async_pf_to_vdev_msg(). 1026 * 1027 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 1028 * device. 1029 */ 1030 bool dlb2_pf_to_vdev_complete(struct dlb2_hw *hw, unsigned int vdev_id); 1031 1032 /** 1033 * dlb2_pf_read_vf_mbox_req() - (PF only) read a VF->PF mailbox request 1034 * @hw: dlb2_hw handle for a particular device. 1035 * @vf_id: VF ID. 1036 * @data: pointer to message data. 1037 * @len: size, in bytes, of the data array. 1038 * 1039 * This function copies one of the PF's VF->PF mailboxes into the array pointed 1040 * to by data. 1041 * 1042 * Return: 1043 * Returns 0 upon success, <0 otherwise. 1044 * 1045 * EINVAL - len >= DLB2_VF2PF_REQ_BYTES. 1046 */ 1047 int dlb2_pf_read_vf_mbox_req(struct dlb2_hw *hw, 1048 unsigned int vf_id, 1049 void *data, 1050 int len); 1051 1052 /** 1053 * dlb2_pf_read_vf_mbox_resp() - (PF only) read a VF->PF mailbox response 1054 * @hw: dlb2_hw handle for a particular device. 1055 * @vf_id: VF ID. 1056 * @data: pointer to message data. 1057 * @len: size, in bytes, of the data array. 1058 * 1059 * This function copies one of the PF's VF->PF mailboxes into the array pointed 1060 * to by data. 1061 * 1062 * Return: 1063 * Returns 0 upon success, <0 otherwise. 1064 * 1065 * EINVAL - len >= DLB2_VF2PF_RESP_BYTES. 1066 */ 1067 int dlb2_pf_read_vf_mbox_resp(struct dlb2_hw *hw, 1068 unsigned int vf_id, 1069 void *data, 1070 int len); 1071 1072 /** 1073 * dlb2_pf_write_vf_mbox_resp() - (PF only) write a PF->VF mailbox response 1074 * @hw: dlb2_hw handle for a particular device. 1075 * @vf_id: VF ID. 1076 * @data: pointer to message data. 1077 * @len: size, in bytes, of the data array. 1078 * 1079 * This function copies the user-provided message data into of the PF's VF->PF 1080 * mailboxes. 1081 * 1082 * Return: 1083 * Returns 0 upon success, <0 otherwise. 1084 * 1085 * EINVAL - len >= DLB2_PF2VF_RESP_BYTES. 1086 */ 1087 int dlb2_pf_write_vf_mbox_resp(struct dlb2_hw *hw, 1088 unsigned int vf_id, 1089 void *data, 1090 int len); 1091 1092 /** 1093 * dlb2_pf_write_vf_mbox_req() - (PF only) write a PF->VF mailbox request 1094 * @hw: dlb2_hw handle for a particular device. 1095 * @vf_id: VF ID. 1096 * @data: pointer to message data. 1097 * @len: size, in bytes, of the data array. 1098 * 1099 * This function copies the user-provided message data into of the PF's VF->PF 1100 * mailboxes. 1101 * 1102 * Return: 1103 * Returns 0 upon success, <0 otherwise. 1104 * 1105 * EINVAL - len >= DLB2_PF2VF_REQ_BYTES. 1106 */ 1107 int dlb2_pf_write_vf_mbox_req(struct dlb2_hw *hw, 1108 unsigned int vf_id, 1109 void *data, 1110 int len); 1111 1112 /** 1113 * dlb2_vf_read_pf_mbox_resp() - (VF only) read a PF->VF mailbox response 1114 * @hw: dlb2_hw handle for a particular device. 1115 * @data: pointer to message data. 1116 * @len: size, in bytes, of the data array. 1117 * 1118 * This function copies the VF's PF->VF mailbox into the array pointed to by 1119 * data. 1120 * 1121 * Return: 1122 * Returns 0 upon success, <0 otherwise. 1123 * 1124 * EINVAL - len >= DLB2_PF2VF_RESP_BYTES. 1125 */ 1126 int dlb2_vf_read_pf_mbox_resp(struct dlb2_hw *hw, void *data, int len); 1127 1128 /** 1129 * dlb2_vf_read_pf_mbox_req() - (VF only) read a PF->VF mailbox request 1130 * @hw: dlb2_hw handle for a particular device. 1131 * @data: pointer to message data. 1132 * @len: size, in bytes, of the data array. 1133 * 1134 * This function copies the VF's PF->VF mailbox into the array pointed to by 1135 * data. 1136 * 1137 * Return: 1138 * Returns 0 upon success, <0 otherwise. 1139 * 1140 * EINVAL - len >= DLB2_PF2VF_REQ_BYTES. 1141 */ 1142 int dlb2_vf_read_pf_mbox_req(struct dlb2_hw *hw, void *data, int len); 1143 1144 /** 1145 * dlb2_vf_write_pf_mbox_req() - (VF only) write a VF->PF mailbox request 1146 * @hw: dlb2_hw handle for a particular device. 1147 * @data: pointer to message data. 1148 * @len: size, in bytes, of the data array. 1149 * 1150 * This function copies the user-provided message data into of the VF's PF->VF 1151 * mailboxes. 1152 * 1153 * Return: 1154 * Returns 0 upon success, <0 otherwise. 1155 * 1156 * EINVAL - len >= DLB2_VF2PF_REQ_BYTES. 1157 */ 1158 int dlb2_vf_write_pf_mbox_req(struct dlb2_hw *hw, void *data, int len); 1159 1160 /** 1161 * dlb2_vf_write_pf_mbox_resp() - (VF only) write a VF->PF mailbox response 1162 * @hw: dlb2_hw handle for a particular device. 1163 * @data: pointer to message data. 1164 * @len: size, in bytes, of the data array. 1165 * 1166 * This function copies the user-provided message data into of the VF's PF->VF 1167 * mailboxes. 1168 * 1169 * Return: 1170 * Returns 0 upon success, <0 otherwise. 1171 * 1172 * EINVAL - len >= DLB2_VF2PF_RESP_BYTES. 1173 */ 1174 int dlb2_vf_write_pf_mbox_resp(struct dlb2_hw *hw, void *data, int len); 1175 1176 /** 1177 * dlb2_reset_vdev() - reset the hardware owned by a virtual device 1178 * @hw: dlb2_hw handle for a particular device. 1179 * @id: virtual device ID 1180 * 1181 * This function resets the hardware owned by a vdev, by resetting the vdev's 1182 * domains one by one. 1183 * 1184 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 1185 * device. 1186 */ 1187 int dlb2_reset_vdev(struct dlb2_hw *hw, unsigned int id); 1188 1189 /** 1190 * dlb2_vdev_is_locked() - check whether the vdev's resources are locked 1191 * @hw: dlb2_hw handle for a particular device. 1192 * @id: virtual device ID 1193 * 1194 * This function returns whether or not the vdev's resource assignments are 1195 * locked. If locked, no resources can be added to or subtracted from the 1196 * group. 1197 * 1198 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 1199 * device. 1200 */ 1201 bool dlb2_vdev_is_locked(struct dlb2_hw *hw, unsigned int id); 1202 1203 /** 1204 * dlb2_lock_vdev() - lock the vdev's resources 1205 * @hw: dlb2_hw handle for a particular device. 1206 * @id: virtual device ID 1207 * 1208 * This function sets a flag indicating that the vdev is using its resources. 1209 * When the vdev is locked, its resource assignment cannot be changed. 1210 * 1211 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 1212 * device. 1213 */ 1214 void dlb2_lock_vdev(struct dlb2_hw *hw, unsigned int id); 1215 1216 /** 1217 * dlb2_unlock_vdev() - unlock the vdev's resources 1218 * @hw: dlb2_hw handle for a particular device. 1219 * @id: virtual device ID 1220 * 1221 * This function unlocks the vdev's resource assignment, allowing it to be 1222 * modified. 1223 * 1224 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 1225 * device. 1226 */ 1227 void dlb2_unlock_vdev(struct dlb2_hw *hw, unsigned int id); 1228 1229 /** 1230 * dlb2_update_vdev_sched_domains() - update the domains assigned to a vdev 1231 * @hw: dlb2_hw handle for a particular device. 1232 * @id: virtual device ID 1233 * @num: number of scheduling domains to assign to this vdev 1234 * 1235 * This function assigns num scheduling domains to the specified vdev. If the 1236 * vdev already has domains assigned, this existing assignment is adjusted 1237 * accordingly. 1238 * 1239 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 1240 * device. 1241 * 1242 * Return: 1243 * Returns 0 upon success, <0 otherwise. 1244 * 1245 * Errors: 1246 * EINVAL - id is invalid, or the requested number of resources are 1247 * unavailable. 1248 * EPERM - The vdev's resource assignment is locked and cannot be changed. 1249 */ 1250 int dlb2_update_vdev_sched_domains(struct dlb2_hw *hw, u32 id, u32 num); 1251 1252 /** 1253 * dlb2_update_vdev_ldb_queues() - update the LDB queues assigned to a vdev 1254 * @hw: dlb2_hw handle for a particular device. 1255 * @id: virtual device ID 1256 * @num: number of LDB queues to assign to this vdev 1257 * 1258 * This function assigns num LDB queues to the specified vdev. If the vdev 1259 * already has LDB queues assigned, this existing assignment is adjusted 1260 * accordingly. 1261 * 1262 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 1263 * device. 1264 * 1265 * Return: 1266 * Returns 0 upon success, <0 otherwise. 1267 * 1268 * Errors: 1269 * EINVAL - id is invalid, or the requested number of resources are 1270 * unavailable. 1271 * EPERM - The vdev's resource assignment is locked and cannot be changed. 1272 */ 1273 int dlb2_update_vdev_ldb_queues(struct dlb2_hw *hw, u32 id, u32 num); 1274 1275 /** 1276 * dlb2_update_vdev_ldb_ports() - update the LDB ports assigned to a vdev 1277 * @hw: dlb2_hw handle for a particular device. 1278 * @id: virtual device ID 1279 * @num: number of LDB ports to assign to this vdev 1280 * 1281 * This function assigns num LDB ports to the specified vdev. If the vdev 1282 * already has LDB ports assigned, this existing assignment is adjusted 1283 * accordingly. 1284 * 1285 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 1286 * device. 1287 * 1288 * Return: 1289 * Returns 0 upon success, <0 otherwise. 1290 * 1291 * Errors: 1292 * EINVAL - id is invalid, or the requested number of resources are 1293 * unavailable. 1294 * EPERM - The vdev's resource assignment is locked and cannot be changed. 1295 */ 1296 int dlb2_update_vdev_ldb_ports(struct dlb2_hw *hw, u32 id, u32 num); 1297 1298 /** 1299 * dlb2_update_vdev_ldb_cos_ports() - update the LDB ports assigned to a vdev 1300 * @hw: dlb2_hw handle for a particular device. 1301 * @id: virtual device ID 1302 * @cos: class-of-service ID 1303 * @num: number of LDB ports to assign to this vdev 1304 * 1305 * This function assigns num LDB ports from class-of-service cos to the 1306 * specified vdev. If the vdev already has LDB ports from this class-of-service 1307 * assigned, this existing assignment is adjusted accordingly. 1308 * 1309 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 1310 * device. 1311 * 1312 * Return: 1313 * Returns 0 upon success, <0 otherwise. 1314 * 1315 * Errors: 1316 * EINVAL - id is invalid, or the requested number of resources are 1317 * unavailable. 1318 * EPERM - The vdev's resource assignment is locked and cannot be changed. 1319 */ 1320 int dlb2_update_vdev_ldb_cos_ports(struct dlb2_hw *hw, 1321 u32 id, 1322 u32 cos, 1323 u32 num); 1324 1325 /** 1326 * dlb2_update_vdev_dir_ports() - update the DIR ports assigned to a vdev 1327 * @hw: dlb2_hw handle for a particular device. 1328 * @id: virtual device ID 1329 * @num: number of DIR ports to assign to this vdev 1330 * 1331 * This function assigns num DIR ports to the specified vdev. If the vdev 1332 * already has DIR ports assigned, this existing assignment is adjusted 1333 * accordingly. 1334 * 1335 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 1336 * device. 1337 * 1338 * Return: 1339 * Returns 0 upon success, <0 otherwise. 1340 * 1341 * Errors: 1342 * EINVAL - id is invalid, or the requested number of resources are 1343 * unavailable. 1344 * EPERM - The vdev's resource assignment is locked and cannot be changed. 1345 */ 1346 int dlb2_update_vdev_dir_ports(struct dlb2_hw *hw, u32 id, u32 num); 1347 1348 /** 1349 * dlb2_update_vdev_ldb_credits() - update the vdev's assigned LDB credits 1350 * @hw: dlb2_hw handle for a particular device. 1351 * @id: virtual device ID 1352 * @num: number of LDB credit credits to assign to this vdev 1353 * 1354 * This function assigns num LDB credit to the specified vdev. If the vdev 1355 * already has LDB credits assigned, this existing assignment is adjusted 1356 * accordingly. vdevs are assigned a contiguous chunk of credits, so this 1357 * function may fail if a sufficiently large contiguous chunk is not available. 1358 * 1359 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 1360 * device. 1361 * 1362 * Return: 1363 * Returns 0 upon success, <0 otherwise. 1364 * 1365 * Errors: 1366 * EINVAL - id is invalid, or the requested number of resources are 1367 * unavailable. 1368 * EPERM - The vdev's resource assignment is locked and cannot be changed. 1369 */ 1370 int dlb2_update_vdev_ldb_credits(struct dlb2_hw *hw, u32 id, u32 num); 1371 1372 /** 1373 * dlb2_update_vdev_dir_credits() - update the vdev's assigned DIR credits 1374 * @hw: dlb2_hw handle for a particular device. 1375 * @id: virtual device ID 1376 * @num: number of DIR credits to assign to this vdev 1377 * 1378 * This function assigns num DIR credit to the specified vdev. If the vdev 1379 * already has DIR credits assigned, this existing assignment is adjusted 1380 * accordingly. vdevs are assigned a contiguous chunk of credits, so this 1381 * function may fail if a sufficiently large contiguous chunk is not available. 1382 * 1383 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 1384 * device. 1385 * 1386 * Return: 1387 * Returns 0 upon success, <0 otherwise. 1388 * 1389 * Errors: 1390 * EINVAL - id is invalid, or the requested number of resources are 1391 * unavailable. 1392 * EPERM - The vdev's resource assignment is locked and cannot be changed. 1393 */ 1394 int dlb2_update_vdev_dir_credits(struct dlb2_hw *hw, u32 id, u32 num); 1395 1396 /** 1397 * dlb2_update_vdev_hist_list_entries() - update the vdev's assigned HL entries 1398 * @hw: dlb2_hw handle for a particular device. 1399 * @id: virtual device ID 1400 * @num: number of history list entries to assign to this vdev 1401 * 1402 * This function assigns num history list entries to the specified vdev. If the 1403 * vdev already has history list entries assigned, this existing assignment is 1404 * adjusted accordingly. vdevs are assigned a contiguous chunk of entries, so 1405 * this function may fail if a sufficiently large contiguous chunk is not 1406 * available. 1407 * 1408 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 1409 * device. 1410 * 1411 * Return: 1412 * Returns 0 upon success, <0 otherwise. 1413 * 1414 * Errors: 1415 * EINVAL - id is invalid, or the requested number of resources are 1416 * unavailable. 1417 * EPERM - The vdev's resource assignment is locked and cannot be changed. 1418 */ 1419 int dlb2_update_vdev_hist_list_entries(struct dlb2_hw *hw, u32 id, u32 num); 1420 1421 /** 1422 * dlb2_update_vdev_atomic_inflights() - update the vdev's atomic inflights 1423 * @hw: dlb2_hw handle for a particular device. 1424 * @id: virtual device ID 1425 * @num: number of atomic inflights to assign to this vdev 1426 * 1427 * This function assigns num atomic inflights to the specified vdev. If the vdev 1428 * already has atomic inflights assigned, this existing assignment is adjusted 1429 * accordingly. vdevs are assigned a contiguous chunk of entries, so this 1430 * function may fail if a sufficiently large contiguous chunk is not available. 1431 * 1432 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 1433 * device. 1434 * 1435 * Return: 1436 * Returns 0 upon success, <0 otherwise. 1437 * 1438 * Errors: 1439 * EINVAL - id is invalid, or the requested number of resources are 1440 * unavailable. 1441 * EPERM - The vdev's resource assignment is locked and cannot be changed. 1442 */ 1443 int dlb2_update_vdev_atomic_inflights(struct dlb2_hw *hw, u32 id, u32 num); 1444 1445 /** 1446 * dlb2_reset_vdev_resources() - reassign the vdev's resources to the PF 1447 * @hw: dlb2_hw handle for a particular device. 1448 * @id: virtual device ID 1449 * 1450 * This function takes any resources currently assigned to the vdev and 1451 * reassigns them to the PF. 1452 * 1453 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 1454 * device. 1455 * 1456 * Return: 1457 * Returns 0 upon success, <0 otherwise. 1458 * 1459 * Errors: 1460 * EINVAL - id is invalid 1461 * EPERM - The vdev's resource assignment is locked and cannot be changed. 1462 */ 1463 int dlb2_reset_vdev_resources(struct dlb2_hw *hw, unsigned int id); 1464 1465 /** 1466 * dlb2_notify_vf() - send an alarm to a VF 1467 * @hw: dlb2_hw handle for a particular device. 1468 * @vf_id: VF ID 1469 * @notification: notification 1470 * 1471 * This function sends a notification (as defined in dlb2_mbox.h) to a VF. 1472 * 1473 * Return: 1474 * Returns 0 upon success, <0 if the VF doesn't ACK the PF->VF interrupt. 1475 */ 1476 int dlb2_notify_vf(struct dlb2_hw *hw, 1477 unsigned int vf_id, 1478 u32 notification); 1479 1480 /** 1481 * dlb2_vdev_in_use() - query whether a virtual device is in use 1482 * @hw: dlb2_hw handle for a particular device. 1483 * @id: virtual device ID 1484 * 1485 * This function sends a mailbox request to the vdev to query whether the vdev 1486 * is in use. 1487 * 1488 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 1489 * device. 1490 * 1491 * Return: 1492 * Returns 0 for false, 1 for true, and <0 if the mailbox request times out or 1493 * an internal error occurs. 1494 */ 1495 int dlb2_vdev_in_use(struct dlb2_hw *hw, unsigned int id); 1496 1497 /** 1498 * dlb2_hw_get_ldb_queue_depth() - returns the depth of a load-balanced queue 1499 * @hw: dlb2_hw handle for a particular device. 1500 * @domain_id: domain ID. 1501 * @args: queue depth args 1502 * @resp: response structure. 1503 * @vdev_request: indicates whether this request came from a vdev. 1504 * @vdev_id: If vdev_request is true, this contains the vdev's ID. 1505 * 1506 * This function returns the depth of a load-balanced queue. 1507 * 1508 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 1509 * device. 1510 * 1511 * Return: 1512 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 1513 * assigned a detailed error code from enum dlb2_error. If successful, resp->id 1514 * contains the depth. 1515 * 1516 * Errors: 1517 * EINVAL - Invalid domain ID or queue ID. 1518 */ 1519 int dlb2_hw_get_ldb_queue_depth(struct dlb2_hw *hw, 1520 u32 domain_id, 1521 struct dlb2_get_ldb_queue_depth_args *args, 1522 struct dlb2_cmd_response *resp, 1523 bool vdev_request, 1524 unsigned int vdev_id); 1525 1526 /** 1527 * dlb2_hw_get_dir_queue_depth() - returns the depth of a directed queue 1528 * @hw: dlb2_hw handle for a particular device. 1529 * @domain_id: domain ID. 1530 * @args: queue depth args 1531 * @resp: response structure. 1532 * @vdev_request: indicates whether this request came from a vdev. 1533 * @vdev_id: If vdev_request is true, this contains the vdev's ID. 1534 * 1535 * This function returns the depth of a directed queue. 1536 * 1537 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual 1538 * device. 1539 * 1540 * Return: 1541 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 1542 * assigned a detailed error code from enum dlb2_error. If successful, resp->id 1543 * contains the depth. 1544 * 1545 * Errors: 1546 * EINVAL - Invalid domain ID or queue ID. 1547 */ 1548 int dlb2_hw_get_dir_queue_depth(struct dlb2_hw *hw, 1549 u32 domain_id, 1550 struct dlb2_get_dir_queue_depth_args *args, 1551 struct dlb2_cmd_response *resp, 1552 bool vdev_request, 1553 unsigned int vdev_id); 1554 1555 enum dlb2_virt_mode { 1556 DLB2_VIRT_NONE, 1557 DLB2_VIRT_SRIOV, 1558 DLB2_VIRT_SIOV, 1559 1560 /* NUM_DLB2_VIRT_MODES must be last */ 1561 NUM_DLB2_VIRT_MODES, 1562 }; 1563 1564 /** 1565 * dlb2_hw_set_virt_mode() - set the device's virtualization mode 1566 * @hw: dlb2_hw handle for a particular device. 1567 * @mode: either none, SR-IOV, or Scalable IOV. 1568 * 1569 * This function sets the virtualization mode of the device. This controls 1570 * whether the device uses a software or hardware mailbox. 1571 * 1572 * This should be called by the PF driver when either SR-IOV or Scalable IOV is 1573 * selected as the virtualization mechanism, and by the VF/VDEV driver during 1574 * initialization after recognizing itself as an SR-IOV or Scalable IOV device. 1575 * 1576 * Errors: 1577 * EINVAL - Invalid mode. 1578 */ 1579 int dlb2_hw_set_virt_mode(struct dlb2_hw *hw, enum dlb2_virt_mode mode); 1580 1581 /** 1582 * dlb2_hw_get_virt_mode() - get the device's virtualization mode 1583 * @hw: dlb2_hw handle for a particular device. 1584 * 1585 * This function gets the virtualization mode of the device. 1586 */ 1587 enum dlb2_virt_mode dlb2_hw_get_virt_mode(struct dlb2_hw *hw); 1588 1589 /** 1590 * dlb2_hw_get_ldb_port_phys_id() - get a physical port ID from its virt ID 1591 * @hw: dlb2_hw handle for a particular device. 1592 * @id: virtual port ID. 1593 * @vdev_id: vdev ID. 1594 * 1595 * Return: 1596 * Returns >= 0 upon success, -1 otherwise. 1597 */ 1598 s32 dlb2_hw_get_ldb_port_phys_id(struct dlb2_hw *hw, 1599 u32 id, 1600 unsigned int vdev_id); 1601 1602 /** 1603 * dlb2_hw_get_dir_port_phys_id() - get a physical port ID from its virt ID 1604 * @hw: dlb2_hw handle for a particular device. 1605 * @id: virtual port ID. 1606 * @vdev_id: vdev ID. 1607 * 1608 * Return: 1609 * Returns >= 0 upon success, -1 otherwise. 1610 */ 1611 s32 dlb2_hw_get_dir_port_phys_id(struct dlb2_hw *hw, 1612 u32 id, 1613 unsigned int vdev_id); 1614 1615 /** 1616 * dlb2_hw_register_sw_mbox() - register a software mailbox 1617 * @hw: dlb2_hw handle for a particular device. 1618 * @vdev_id: vdev ID. 1619 * @vdev2pf_mbox: pointer to a 4KB memory page used for vdev->PF communication. 1620 * @pf2vdev_mbox: pointer to a 4KB memory page used for PF->vdev communication. 1621 * @pf2vdev_inject: callback function for injecting a PF->vdev interrupt. 1622 * @inject_arg: user argument for pf2vdev_inject callback. 1623 * 1624 * When Scalable IOV is enabled, the VDCM must register a software mailbox for 1625 * every virtual device during vdev creation. 1626 * 1627 * This function notifies the driver to use a software mailbox using the 1628 * provided pointers, instead of the device's hardware mailbox. When the driver 1629 * calls mailbox functions like dlb2_pf_write_vf_mbox_req(), the request will 1630 * go to the software mailbox instead of the hardware one. This is used in 1631 * Scalable IOV virtualization. 1632 */ 1633 void dlb2_hw_register_sw_mbox(struct dlb2_hw *hw, 1634 unsigned int vdev_id, 1635 u32 *vdev2pf_mbox, 1636 u32 *pf2vdev_mbox, 1637 void (*pf2vdev_inject)(void *), 1638 void *inject_arg); 1639 1640 /** 1641 * dlb2_hw_unregister_sw_mbox() - unregister a software mailbox 1642 * @hw: dlb2_hw handle for a particular device. 1643 * @vdev_id: vdev ID. 1644 * 1645 * This function notifies the driver to stop using a previously registered 1646 * software mailbox. 1647 */ 1648 void dlb2_hw_unregister_sw_mbox(struct dlb2_hw *hw, unsigned int vdev_id); 1649 1650 /** 1651 * dlb2_hw_setup_cq_ims_entry() - setup a CQ's IMS entry 1652 * @hw: dlb2_hw handle for a particular device. 1653 * @vdev_id: vdev ID. 1654 * @virt_cq_id: virtual CQ ID. 1655 * @is_ldb: CQ is load-balanced. 1656 * @addr_lo: least-significant 32 bits of address. 1657 * @data: 32 data bits. 1658 * 1659 * This sets up the CQ's IMS entry with the provided address and data values. 1660 * This function should only be called if the device is configured for Scalable 1661 * IOV virtualization. The upper 32 address bits are fixed in hardware and thus 1662 * not needed. 1663 */ 1664 void dlb2_hw_setup_cq_ims_entry(struct dlb2_hw *hw, 1665 unsigned int vdev_id, 1666 u32 virt_cq_id, 1667 bool is_ldb, 1668 u32 addr_lo, 1669 u32 data); 1670 1671 /** 1672 * dlb2_hw_clear_cq_ims_entry() - clear a CQ's IMS entry 1673 * @hw: dlb2_hw handle for a particular device. 1674 * @vdev_id: vdev ID. 1675 * @virt_cq_id: virtual CQ ID. 1676 * @is_ldb: CQ is load-balanced. 1677 * 1678 * This clears the CQ's IMS entry, reverting it to its reset state. 1679 */ 1680 void dlb2_hw_clear_cq_ims_entry(struct dlb2_hw *hw, 1681 unsigned int vdev_id, 1682 u32 virt_cq_id, 1683 bool is_ldb); 1684 1685 /** 1686 * dlb2_hw_register_pasid() - register a vdev's PASID 1687 * @hw: dlb2_hw handle for a particular device. 1688 * @vdev_id: vdev ID. 1689 * @pasid: the vdev's PASID. 1690 * 1691 * This function stores the user-supplied PASID, and uses it when configuring 1692 * the vdev's CQs. 1693 * 1694 * Return: 1695 * Returns >= 0 upon success, -1 otherwise. 1696 */ 1697 int dlb2_hw_register_pasid(struct dlb2_hw *hw, 1698 unsigned int vdev_id, 1699 unsigned int pasid); 1700 1701 /** 1702 * dlb2_hw_pending_port_unmaps() - returns the number of unmap operations in 1703 * progress. 1704 * @hw: dlb2_hw handle for a particular device. 1705 * @domain_id: domain ID. 1706 * @args: number of unmaps in progress args 1707 * @resp: response structure. 1708 * @vf_request: indicates whether this request came from a VF. 1709 * @vf_id: If vf_request is true, this contains the VF's ID. 1710 * 1711 * Return: 1712 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is 1713 * assigned a detailed error code from enum dlb2_error. If successful, resp->id 1714 * contains the number of unmaps in progress. 1715 * 1716 * Errors: 1717 * EINVAL - Invalid port ID. 1718 */ 1719 int dlb2_hw_pending_port_unmaps(struct dlb2_hw *hw, 1720 u32 domain_id, 1721 struct dlb2_pending_port_unmaps_args *args, 1722 struct dlb2_cmd_response *resp, 1723 bool vf_request, 1724 unsigned int vf_id); 1725 1726 /** 1727 * dlb2_hw_get_cos_bandwidth() - returns the percent of bandwidth allocated 1728 * to a port class-of-service. 1729 * @hw: dlb2_hw handle for a particular device. 1730 * @cos_id: class-of-service ID. 1731 * 1732 * Return: 1733 * Returns -EINVAL if cos_id is invalid, else the class' bandwidth allocation. 1734 */ 1735 int dlb2_hw_get_cos_bandwidth(struct dlb2_hw *hw, u32 cos_id); 1736 1737 /** 1738 * dlb2_hw_set_cos_bandwidth() - set a bandwidth allocation percentage for a 1739 * port class-of-service. 1740 * @hw: dlb2_hw handle for a particular device. 1741 * @cos_id: class-of-service ID. 1742 * @bandwidth: class-of-service bandwidth. 1743 * 1744 * Return: 1745 * Returns 0 upon success, < 0 otherwise. 1746 * 1747 * Errors: 1748 * EINVAL - Invalid cos ID, bandwidth is greater than 100, or bandwidth would 1749 * cause the total bandwidth across all classes of service to exceed 1750 * 100%. 1751 */ 1752 int dlb2_hw_set_cos_bandwidth(struct dlb2_hw *hw, u32 cos_id, u8 bandwidth); 1753 1754 enum dlb2_wd_tmo { 1755 /* 40s watchdog timeout */ 1756 DLB2_WD_TMO_40S, 1757 /* 10s watchdog timeout */ 1758 DLB2_WD_TMO_10S, 1759 /* 1s watchdog timeout */ 1760 DLB2_WD_TMO_1S, 1761 1762 /* Must be last */ 1763 NUM_DLB2_WD_TMOS, 1764 }; 1765 1766 /** 1767 * dlb2_hw_enable_wd_timer() - enable the CQ watchdog timers with a 1768 * caller-specified timeout. 1769 * @hw: dlb2_hw handle for a particular device. 1770 * @tmo: watchdog timeout. 1771 * 1772 * This function should be called during device initialization and after reset. 1773 * The watchdog timer interrupt must also be enabled per-CQ, using either 1774 * dlb2_hw_enable_dir_cq_wd_int() or dlb2_hw_enable_ldb_cq_wd_int(). 1775 * 1776 * Return: 1777 * Returns 0 upon success, < 0 otherwise. 1778 * 1779 * Errors: 1780 * EINVAL - Invalid timeout. 1781 */ 1782 int dlb2_hw_enable_wd_timer(struct dlb2_hw *hw, enum dlb2_wd_tmo tmo); 1783 1784 /** 1785 * dlb2_hw_enable_dir_cq_wd_int() - enable the CQ watchdog interrupt on an 1786 * individual CQ. 1787 * @hw: dlb2_hw handle for a particular device. 1788 * @id: port ID. 1789 * @vdev_req: indicates whether this request came from a vdev. 1790 * @vdev_id: If vdev_request is true, this contains the vdev's ID. 1791 * 1792 * Return: 1793 * Returns 0 upon success, < 0 otherwise. 1794 * 1795 * Errors: 1796 * EINVAL - Invalid directed port ID. 1797 */ 1798 int dlb2_hw_enable_dir_cq_wd_int(struct dlb2_hw *hw, 1799 u32 id, 1800 bool vdev_req, 1801 unsigned int vdev_id); 1802 1803 /** 1804 * dlb2_hw_enable_ldb_cq_wd_int() - enable the CQ watchdog interrupt on an 1805 * individual CQ. 1806 * @hw: dlb2_hw handle for a particular device. 1807 * @id: port ID. 1808 * @vdev_req: indicates whether this request came from a vdev. 1809 * @vdev_id: If vdev_request is true, this contains the vdev's ID. 1810 * 1811 * Return: 1812 * Returns 0 upon success, < 0 otherwise. 1813 * 1814 * Errors: 1815 * EINVAL - Invalid load-balanced port ID. 1816 */ 1817 int dlb2_hw_enable_ldb_cq_wd_int(struct dlb2_hw *hw, 1818 u32 id, 1819 bool vdev_req, 1820 unsigned int vdev_id); 1821 1822 /** 1823 * dlb2_hw_enable_sparse_ldb_cq_mode() - enable sparse mode for load-balanced 1824 * ports. 1825 * @hw: dlb2_hw handle for a particular device. 1826 * 1827 * This function must be called prior to configuring scheduling domains. 1828 */ 1829 void dlb2_hw_enable_sparse_ldb_cq_mode(struct dlb2_hw *hw); 1830 1831 /** 1832 * dlb2_hw_enable_sparse_dir_cq_mode() - enable sparse mode for directed ports. 1833 * @hw: dlb2_hw handle for a particular device. 1834 * 1835 * This function must be called prior to configuring scheduling domains. 1836 */ 1837 void dlb2_hw_enable_sparse_dir_cq_mode(struct dlb2_hw *hw); 1838 1839 /** 1840 * dlb2_hw_set_qe_arbiter_weights() - program QE arbiter weights 1841 * @hw: dlb2_hw handle for a particular device. 1842 * @weight: 8-entry array of arbiter weights. 1843 * 1844 * weight[N] programs priority N's weight. In cases where the 8 priorities are 1845 * reduced to 4 bins, the mapping is: 1846 * - weight[1] programs bin 0 1847 * - weight[3] programs bin 1 1848 * - weight[5] programs bin 2 1849 * - weight[7] programs bin 3 1850 */ 1851 void dlb2_hw_set_qe_arbiter_weights(struct dlb2_hw *hw, u8 weight[8]); 1852 1853 /** 1854 * dlb2_hw_set_qid_arbiter_weights() - program QID arbiter weights 1855 * @hw: dlb2_hw handle for a particular device. 1856 * @weight: 8-entry array of arbiter weights. 1857 * 1858 * weight[N] programs priority N's weight. In cases where the 8 priorities are 1859 * reduced to 4 bins, the mapping is: 1860 * - weight[1] programs bin 0 1861 * - weight[3] programs bin 1 1862 * - weight[5] programs bin 2 1863 * - weight[7] programs bin 3 1864 */ 1865 void dlb2_hw_set_qid_arbiter_weights(struct dlb2_hw *hw, u8 weight[8]); 1866 1867 /** 1868 * dlb2_hw_ldb_cq_interrupt_enabled() - Check if the interrupt is enabled 1869 * @hw: dlb2_hw handle for a particular device. 1870 * @port_id: physical load-balanced port ID. 1871 * 1872 * This function returns whether the load-balanced CQ interrupt is enabled. 1873 */ 1874 int dlb2_hw_ldb_cq_interrupt_enabled(struct dlb2_hw *hw, int port_id); 1875 1876 /** 1877 * dlb2_hw_ldb_cq_interrupt_set_mode() - Program the CQ interrupt mode 1878 * @hw: dlb2_hw handle for a particular device. 1879 * @port_id: physical load-balanced port ID. 1880 * @mode: interrupt type (DLB2_CQ_ISR_MODE_{DIS, MSI, MSIX, ADI}) 1881 * 1882 * This function can be used to disable (MODE_DIS) and re-enable the 1883 * load-balanced CQ's interrupt. It should only be called after the interrupt 1884 * has been configured with dlb2_configure_ldb_cq_interrupt(). 1885 */ 1886 void dlb2_hw_ldb_cq_interrupt_set_mode(struct dlb2_hw *hw, 1887 int port_id, 1888 int mode); 1889 1890 /** 1891 * dlb2_hw_dir_cq_interrupt_enabled() - Check if the interrupt is enabled 1892 * @hw: dlb2_hw handle for a particular device. 1893 * @port_id: physical load-balanced port ID. 1894 * 1895 * This function returns whether the load-balanced CQ interrupt is enabled. 1896 */ 1897 int dlb2_hw_dir_cq_interrupt_enabled(struct dlb2_hw *hw, int port_id); 1898 1899 /** 1900 * dlb2_hw_dir_cq_interrupt_set_mode() - Program the CQ interrupt mode 1901 * @hw: dlb2_hw handle for a particular device. 1902 * @port_id: physical directed port ID. 1903 * @mode: interrupt type (DLB2_CQ_ISR_MODE_{DIS, MSI, MSIX, ADI}) 1904 * 1905 * This function can be used to disable (MODE_DIS) and re-enable the 1906 * directed CQ's interrupt. It should only be called after the interrupt 1907 * has been configured with dlb2_configure_dir_cq_interrupt(). 1908 */ 1909 void dlb2_hw_dir_cq_interrupt_set_mode(struct dlb2_hw *hw, 1910 int port_id, 1911 int mode); 1912 1913 #endif /* __DLB2_RESOURCE_H */ 1914