1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2016-2020 Intel Corporation
5 #ifndef __DLB2_RESOURCE_H
6 #define __DLB2_RESOURCE_H
10 #include "dlb2_hw_types.h"
11 #include "dlb2_osdep_types.h"
14 * dlb2_resource_init() - initialize the device
15 * @hw: pointer to struct dlb2_hw.
17 * This function initializes the device's software state (pointed to by the hw
18 * argument) and programs global scheduling QoS registers. This function should
19 * be called during driver initialization.
21 * The dlb2_hw struct must be unique per DLB 2.0 device and persist until the
25 * Returns 0 upon success, <0 otherwise.
27 int dlb2_resource_init(struct dlb2_hw *hw);
30 * dlb2_resource_free() - free device state memory
31 * @hw: dlb2_hw handle for a particular device.
33 * This function frees software state pointed to by dlb2_hw. This function
34 * should be called when resetting the device or unloading the driver.
36 void dlb2_resource_free(struct dlb2_hw *hw);
39 * dlb2_resource_reset() - reset in-use resources to their initial state
40 * @hw: dlb2_hw handle for a particular device.
42 * This function resets in-use resources, and makes them available for use.
43 * All resources go back to their owning function, whether a PF or a VF.
45 void dlb2_resource_reset(struct dlb2_hw *hw);
48 * dlb2_hw_create_sched_domain() - create a scheduling domain
49 * @hw: dlb2_hw handle for a particular device.
50 * @args: scheduling domain creation arguments.
51 * @resp: response structure.
52 * @vdev_request: indicates whether this request came from a vdev.
53 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
55 * This function creates a scheduling domain containing the resources specified
56 * in args. The individual resources (queues, ports, credits) can be configured
57 * after creating a scheduling domain.
59 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
63 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
64 * assigned a detailed error code from enum dlb2_error. If successful, resp->id
65 * contains the domain ID.
67 * resp->id contains a virtual ID if vdev_request is true.
70 * EINVAL - A requested resource is unavailable, or the requested domain name
72 * EFAULT - Internal error (resp->status not set).
74 int dlb2_hw_create_sched_domain(struct dlb2_hw *hw,
75 struct dlb2_create_sched_domain_args *args,
76 struct dlb2_cmd_response *resp,
78 unsigned int vdev_id);
81 * dlb2_hw_create_ldb_queue() - create a load-balanced queue
82 * @hw: dlb2_hw handle for a particular device.
83 * @domain_id: domain ID.
84 * @args: queue creation arguments.
85 * @resp: response structure.
86 * @vdev_request: indicates whether this request came from a vdev.
87 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
89 * This function creates a load-balanced queue.
91 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
95 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
96 * assigned a detailed error code from enum dlb2_error. If successful, resp->id
97 * contains the queue ID.
99 * resp->id contains a virtual ID if vdev_request is true.
102 * EINVAL - A requested resource is unavailable, the domain is not configured,
103 * the domain has already been started, or the requested queue name is
105 * EFAULT - Internal error (resp->status not set).
107 int dlb2_hw_create_ldb_queue(struct dlb2_hw *hw,
109 struct dlb2_create_ldb_queue_args *args,
110 struct dlb2_cmd_response *resp,
112 unsigned int vdev_id);
115 * dlb2_hw_create_dir_queue() - create a directed queue
116 * @hw: dlb2_hw handle for a particular device.
117 * @domain_id: domain ID.
118 * @args: queue creation arguments.
119 * @resp: response structure.
120 * @vdev_request: indicates whether this request came from a vdev.
121 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
123 * This function creates a directed queue.
125 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
129 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
130 * assigned a detailed error code from enum dlb2_error. If successful, resp->id
131 * contains the queue ID.
133 * resp->id contains a virtual ID if vdev_request is true.
136 * EINVAL - A requested resource is unavailable, the domain is not configured,
137 * or the domain has already been started.
138 * EFAULT - Internal error (resp->status not set).
140 int dlb2_hw_create_dir_queue(struct dlb2_hw *hw,
142 struct dlb2_create_dir_queue_args *args,
143 struct dlb2_cmd_response *resp,
145 unsigned int vdev_id);
148 * dlb2_hw_create_dir_port() - create a directed port
149 * @hw: dlb2_hw handle for a particular device.
150 * @domain_id: domain ID.
151 * @args: port creation arguments.
152 * @cq_dma_base: base address of the CQ memory. This can be a PA or an IOVA.
153 * @resp: response structure.
154 * @vdev_request: indicates whether this request came from a vdev.
155 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
157 * This function creates a directed port.
159 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
163 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
164 * assigned a detailed error code from enum dlb2_error. If successful, resp->id
165 * contains the port ID.
167 * resp->id contains a virtual ID if vdev_request is true.
170 * EINVAL - A requested resource is unavailable, a credit setting is invalid, a
171 * pointer address is not properly aligned, the domain is not
172 * configured, or the domain has already been started.
173 * EFAULT - Internal error (resp->status not set).
175 int dlb2_hw_create_dir_port(struct dlb2_hw *hw,
177 struct dlb2_create_dir_port_args *args,
178 uintptr_t cq_dma_base,
179 struct dlb2_cmd_response *resp,
181 unsigned int vdev_id);
184 * dlb2_hw_create_ldb_port() - create a load-balanced port
185 * @hw: dlb2_hw handle for a particular device.
186 * @domain_id: domain ID.
187 * @args: port creation arguments.
188 * @cq_dma_base: base address of the CQ memory. This can be a PA or an IOVA.
189 * @resp: response structure.
190 * @vdev_request: indicates whether this request came from a vdev.
191 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
193 * This function creates a load-balanced port.
195 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
199 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
200 * assigned a detailed error code from enum dlb2_error. If successful, resp->id
201 * contains the port ID.
203 * resp->id contains a virtual ID if vdev_request is true.
206 * EINVAL - A requested resource is unavailable, a credit setting is invalid, a
207 * pointer address is not properly aligned, the domain is not
208 * configured, or the domain has already been started.
209 * EFAULT - Internal error (resp->status not set).
211 int dlb2_hw_create_ldb_port(struct dlb2_hw *hw,
213 struct dlb2_create_ldb_port_args *args,
214 uintptr_t cq_dma_base,
215 struct dlb2_cmd_response *resp,
217 unsigned int vdev_id);
220 * dlb2_hw_start_domain() - start a scheduling domain
221 * @hw: dlb2_hw handle for a particular device.
222 * @domain_id: domain ID.
223 * @args: start domain arguments.
224 * @resp: response structure.
225 * @vdev_request: indicates whether this request came from a vdev.
226 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
228 * This function starts a scheduling domain, which allows applications to send
229 * traffic through it. Once a domain is started, its resources can no longer be
230 * configured (besides QID remapping and port enable/disable).
232 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
236 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
237 * assigned a detailed error code from enum dlb2_error.
240 * EINVAL - the domain is not configured, or the domain is already started.
242 int dlb2_hw_start_domain(struct dlb2_hw *hw,
244 struct dlb2_start_domain_args *args,
245 struct dlb2_cmd_response *resp,
247 unsigned int vdev_id);
250 * dlb2_hw_map_qid() - map a load-balanced queue to a load-balanced port
251 * @hw: dlb2_hw handle for a particular device.
252 * @domain_id: domain ID.
253 * @args: map QID arguments.
254 * @resp: response structure.
255 * @vdev_request: indicates whether this request came from a vdev.
256 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
258 * This function configures the DLB to schedule QEs from the specified queue
259 * to the specified port. Each load-balanced port can be mapped to up to 8
260 * queues; each load-balanced queue can potentially map to all the
261 * load-balanced ports.
263 * A successful return does not necessarily mean the mapping was configured. If
264 * this function is unable to immediately map the queue to the port, it will
265 * add the requested operation to a per-port list of pending map/unmap
266 * operations, and (if it's not already running) launch a kernel thread that
267 * periodically attempts to process all pending operations. In a sense, this is
268 * an asynchronous function.
270 * This asynchronicity creates two views of the state of hardware: the actual
271 * hardware state and the requested state (as if every request completed
272 * immediately). If there are any pending map/unmap operations, the requested
273 * state will differ from the actual state. All validation is performed with
274 * respect to the pending state; for instance, if there are 8 pending map
275 * operations for port X, a request for a 9th will fail because a load-balanced
276 * port can only map up to 8 queues.
278 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
282 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
283 * assigned a detailed error code from enum dlb2_error.
286 * EINVAL - A requested resource is unavailable, invalid port or queue ID, or
287 * the domain is not configured.
288 * EFAULT - Internal error (resp->status not set).
290 int dlb2_hw_map_qid(struct dlb2_hw *hw,
292 struct dlb2_map_qid_args *args,
293 struct dlb2_cmd_response *resp,
295 unsigned int vdev_id);
298 * dlb2_hw_unmap_qid() - Unmap a load-balanced queue from a load-balanced port
299 * @hw: dlb2_hw handle for a particular device.
300 * @domain_id: domain ID.
301 * @args: unmap QID arguments.
302 * @resp: response structure.
303 * @vdev_request: indicates whether this request came from a vdev.
304 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
306 * This function configures the DLB to stop scheduling QEs from the specified
307 * queue to the specified port.
309 * A successful return does not necessarily mean the mapping was removed. If
310 * this function is unable to immediately unmap the queue from the port, it
311 * will add the requested operation to a per-port list of pending map/unmap
312 * operations, and (if it's not already running) launch a kernel thread that
313 * periodically attempts to process all pending operations. See
314 * dlb2_hw_map_qid() for more details.
316 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
320 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
321 * assigned a detailed error code from enum dlb2_error.
324 * EINVAL - A requested resource is unavailable, invalid port or queue ID, or
325 * the domain is not configured.
326 * EFAULT - Internal error (resp->status not set).
328 int dlb2_hw_unmap_qid(struct dlb2_hw *hw,
330 struct dlb2_unmap_qid_args *args,
331 struct dlb2_cmd_response *resp,
333 unsigned int vdev_id);
336 * dlb2_finish_unmap_qid_procedures() - finish any pending unmap procedures
337 * @hw: dlb2_hw handle for a particular device.
339 * This function attempts to finish any outstanding unmap procedures.
340 * This function should be called by the kernel thread responsible for
341 * finishing map/unmap procedures.
344 * Returns the number of procedures that weren't completed.
346 unsigned int dlb2_finish_unmap_qid_procedures(struct dlb2_hw *hw);
349 * dlb2_finish_map_qid_procedures() - finish any pending map procedures
350 * @hw: dlb2_hw handle for a particular device.
352 * This function attempts to finish any outstanding map procedures.
353 * This function should be called by the kernel thread responsible for
354 * finishing map/unmap procedures.
357 * Returns the number of procedures that weren't completed.
359 unsigned int dlb2_finish_map_qid_procedures(struct dlb2_hw *hw);
362 * dlb2_hw_enable_ldb_port() - enable a load-balanced port for scheduling
363 * @hw: dlb2_hw handle for a particular device.
364 * @domain_id: domain ID.
365 * @args: port enable arguments.
366 * @resp: response structure.
367 * @vdev_request: indicates whether this request came from a vdev.
368 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
370 * This function configures the DLB to schedule QEs to a load-balanced port.
371 * Ports are enabled by default.
373 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
377 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
378 * assigned a detailed error code from enum dlb2_error.
381 * EINVAL - The port ID is invalid or the domain is not configured.
382 * EFAULT - Internal error (resp->status not set).
384 int dlb2_hw_enable_ldb_port(struct dlb2_hw *hw,
386 struct dlb2_enable_ldb_port_args *args,
387 struct dlb2_cmd_response *resp,
389 unsigned int vdev_id);
392 * dlb2_hw_disable_ldb_port() - disable a load-balanced port for scheduling
393 * @hw: dlb2_hw handle for a particular device.
394 * @domain_id: domain ID.
395 * @args: port disable arguments.
396 * @resp: response structure.
397 * @vdev_request: indicates whether this request came from a vdev.
398 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
400 * This function configures the DLB to stop scheduling QEs to a load-balanced
401 * port. Ports are enabled by default.
403 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
407 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
408 * assigned a detailed error code from enum dlb2_error.
411 * EINVAL - The port ID is invalid or the domain is not configured.
412 * EFAULT - Internal error (resp->status not set).
414 int dlb2_hw_disable_ldb_port(struct dlb2_hw *hw,
416 struct dlb2_disable_ldb_port_args *args,
417 struct dlb2_cmd_response *resp,
419 unsigned int vdev_id);
422 * dlb2_hw_enable_dir_port() - enable a directed port for scheduling
423 * @hw: dlb2_hw handle for a particular device.
424 * @domain_id: domain ID.
425 * @args: port enable arguments.
426 * @resp: response structure.
427 * @vdev_request: indicates whether this request came from a vdev.
428 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
430 * This function configures the DLB to schedule QEs to a directed port.
431 * Ports are enabled by default.
433 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
437 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
438 * assigned a detailed error code from enum dlb2_error.
441 * EINVAL - The port ID is invalid or the domain is not configured.
442 * EFAULT - Internal error (resp->status not set).
444 int dlb2_hw_enable_dir_port(struct dlb2_hw *hw,
446 struct dlb2_enable_dir_port_args *args,
447 struct dlb2_cmd_response *resp,
449 unsigned int vdev_id);
452 * dlb2_hw_disable_dir_port() - disable a directed port for scheduling
453 * @hw: dlb2_hw handle for a particular device.
454 * @domain_id: domain ID.
455 * @args: port disable arguments.
456 * @resp: response structure.
457 * @vdev_request: indicates whether this request came from a vdev.
458 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
460 * This function configures the DLB to stop scheduling QEs to a directed port.
461 * Ports are enabled by default.
463 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
467 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
468 * assigned a detailed error code from enum dlb2_error.
471 * EINVAL - The port ID is invalid or the domain is not configured.
472 * EFAULT - Internal error (resp->status not set).
474 int dlb2_hw_disable_dir_port(struct dlb2_hw *hw,
476 struct dlb2_disable_dir_port_args *args,
477 struct dlb2_cmd_response *resp,
479 unsigned int vdev_id);
482 * dlb2_configure_ldb_cq_interrupt() - configure load-balanced CQ for
484 * @hw: dlb2_hw handle for a particular device.
485 * @port_id: load-balanced port ID.
486 * @vector: interrupt vector ID. Should be 0 for MSI or compressed MSI-X mode,
487 * else a value up to 64.
488 * @mode: interrupt type (DLB2_CQ_ISR_MODE_MSI or DLB2_CQ_ISR_MODE_MSIX)
489 * @vf: If the port is VF-owned, the VF's ID. This is used for translating the
490 * virtual port ID to a physical port ID. Ignored if mode is not MSI.
491 * @owner_vf: the VF to route the interrupt to. Ignore if mode is not MSI.
492 * @threshold: the minimum CQ depth at which the interrupt can fire. Must be
495 * This function configures the DLB registers for load-balanced CQ's
496 * interrupts. This doesn't enable the CQ's interrupt; that can be done with
497 * dlb2_arm_cq_interrupt() or through an interrupt arm QE.
500 * Returns 0 upon success, < 0 otherwise.
503 * EINVAL - The port ID is invalid.
505 int dlb2_configure_ldb_cq_interrupt(struct dlb2_hw *hw,
510 unsigned int owner_vf,
514 * dlb2_configure_dir_cq_interrupt() - configure directed CQ for interrupts
515 * @hw: dlb2_hw handle for a particular device.
516 * @port_id: load-balanced port ID.
517 * @vector: interrupt vector ID. Should be 0 for MSI or compressed MSI-X mode,
518 * else a value up to 64.
519 * @mode: interrupt type (DLB2_CQ_ISR_MODE_MSI or DLB2_CQ_ISR_MODE_MSIX)
520 * @vf: If the port is VF-owned, the VF's ID. This is used for translating the
521 * virtual port ID to a physical port ID. Ignored if mode is not MSI.
522 * @owner_vf: the VF to route the interrupt to. Ignore if mode is not MSI.
523 * @threshold: the minimum CQ depth at which the interrupt can fire. Must be
526 * This function configures the DLB registers for directed CQ's interrupts.
527 * This doesn't enable the CQ's interrupt; that can be done with
528 * dlb2_arm_cq_interrupt() or through an interrupt arm QE.
531 * Returns 0 upon success, < 0 otherwise.
534 * EINVAL - The port ID is invalid.
536 int dlb2_configure_dir_cq_interrupt(struct dlb2_hw *hw,
541 unsigned int owner_vf,
545 * dlb2_enable_ingress_error_alarms() - enable ingress error alarm interrupts
546 * @hw: dlb2_hw handle for a particular device.
548 void dlb2_enable_ingress_error_alarms(struct dlb2_hw *hw);
551 * dlb2_disable_ingress_error_alarms() - disable ingress error alarm interrupts
552 * @hw: dlb2_hw handle for a particular device.
554 void dlb2_disable_ingress_error_alarms(struct dlb2_hw *hw);
557 * dlb2_set_msix_mode() - enable certain hardware alarm interrupts
558 * @hw: dlb2_hw handle for a particular device.
559 * @mode: MSI-X mode (DLB2_MSIX_MODE_PACKED or DLB2_MSIX_MODE_COMPRESSED)
561 * This function configures the hardware to use either packed or compressed
562 * mode. This function should not be called if using MSI interrupts.
564 void dlb2_set_msix_mode(struct dlb2_hw *hw, int mode);
567 * dlb2_ack_msix_interrupt() - Ack an MSI-X interrupt
568 * @hw: dlb2_hw handle for a particular device.
569 * @vector: interrupt vector.
571 * Note: Only needed for PF service interrupts (vector 0). CQ interrupts are
572 * acked in dlb2_ack_compressed_cq_intr().
574 void dlb2_ack_msix_interrupt(struct dlb2_hw *hw, int vector);
577 * dlb2_arm_cq_interrupt() - arm a CQ's interrupt
578 * @hw: dlb2_hw handle for a particular device.
580 * @is_ldb: true for load-balanced port, false for a directed port
581 * @vdev_request: indicates whether this request came from a vdev.
582 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
584 * This function arms the CQ's interrupt. The CQ must be configured prior to
585 * calling this function.
587 * The function does no parameter validation; that is the caller's
590 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
593 * Return: returns 0 upon success, <0 otherwise.
595 * EINVAL - Invalid port ID.
597 int dlb2_arm_cq_interrupt(struct dlb2_hw *hw,
601 unsigned int vdev_id);
604 * dlb2_read_compressed_cq_intr_status() - read compressed CQ interrupt status
605 * @hw: dlb2_hw handle for a particular device.
606 * @ldb_interrupts: 2-entry array of u32 bitmaps
607 * @dir_interrupts: 4-entry array of u32 bitmaps
609 * This function can be called from a compressed CQ interrupt handler to
610 * determine which CQ interrupts have fired. The caller should take appropriate
611 * (such as waking threads blocked on a CQ's interrupt) then ack the interrupts
612 * with dlb2_ack_compressed_cq_intr().
614 void dlb2_read_compressed_cq_intr_status(struct dlb2_hw *hw,
616 u32 *dir_interrupts);
619 * dlb2_ack_compressed_cq_intr_status() - ack compressed CQ interrupts
620 * @hw: dlb2_hw handle for a particular device.
621 * @ldb_interrupts: 2-entry array of u32 bitmaps
622 * @dir_interrupts: 4-entry array of u32 bitmaps
624 * This function ACKs compressed CQ interrupts. Its arguments should be the
625 * same ones passed to dlb2_read_compressed_cq_intr_status().
627 void dlb2_ack_compressed_cq_intr(struct dlb2_hw *hw,
629 u32 *dir_interrupts);
632 * dlb2_read_vf_intr_status() - read the VF interrupt status register
633 * @hw: dlb2_hw handle for a particular device.
635 * This function can be called from a VF's interrupt handler to determine
636 * which interrupts have fired. The first 31 bits correspond to CQ interrupt
637 * vectors, and the final bit is for the PF->VF mailbox interrupt vector.
640 * Returns a bit vector indicating which interrupt vectors are active.
642 u32 dlb2_read_vf_intr_status(struct dlb2_hw *hw);
645 * dlb2_ack_vf_intr_status() - ack VF interrupts
646 * @hw: dlb2_hw handle for a particular device.
647 * @interrupts: 32-bit bitmap
649 * This function ACKs a VF's interrupts. Its interrupts argument should be the
650 * value returned by dlb2_read_vf_intr_status().
652 void dlb2_ack_vf_intr_status(struct dlb2_hw *hw, u32 interrupts);
655 * dlb2_ack_vf_msi_intr() - ack VF MSI interrupt
656 * @hw: dlb2_hw handle for a particular device.
657 * @interrupts: 32-bit bitmap
659 * This function clears the VF's MSI interrupt pending register. Its interrupts
660 * argument should be contain the MSI vectors to ACK. For example, if MSI MME
661 * is in mode 0, then one bit 0 should ever be set.
663 void dlb2_ack_vf_msi_intr(struct dlb2_hw *hw, u32 interrupts);
666 * dlb2_ack_pf_mbox_int() - ack PF->VF mailbox interrupt
667 * @hw: dlb2_hw handle for a particular device.
669 * When done processing the PF mailbox request, this function unsets
670 * the PF's mailbox ISR register.
672 void dlb2_ack_pf_mbox_int(struct dlb2_hw *hw);
675 * dlb2_read_vdev_to_pf_int_bitvec() - return a bit vector of all requesting
677 * @hw: dlb2_hw handle for a particular device.
679 * When the vdev->PF ISR fires, this function can be called to determine which
680 * vdev(s) are requesting service. This bitvector must be passed to
681 * dlb2_ack_vdev_to_pf_int() when processing is complete for all requesting
684 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
688 * Returns a bit vector indicating which VFs (0-15) have requested service.
690 u32 dlb2_read_vdev_to_pf_int_bitvec(struct dlb2_hw *hw);
693 * dlb2_ack_vdev_mbox_int() - ack processed vdev->PF mailbox interrupt
694 * @hw: dlb2_hw handle for a particular device.
695 * @bitvec: bit vector returned by dlb2_read_vdev_to_pf_int_bitvec()
697 * When done processing all VF mailbox requests, this function unsets the VF's
698 * mailbox ISR register.
700 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
703 void dlb2_ack_vdev_mbox_int(struct dlb2_hw *hw, u32 bitvec);
706 * dlb2_read_vf_flr_int_bitvec() - return a bit vector of all VFs requesting
708 * @hw: dlb2_hw handle for a particular device.
710 * When the VF FLR ISR fires, this function can be called to determine which
711 * VF(s) are requesting FLRs. This bitvector must passed to
712 * dlb2_ack_vf_flr_int() when processing is complete for all requesting VFs.
715 * Returns a bit vector indicating which VFs (0-15) have requested FLRs.
717 u32 dlb2_read_vf_flr_int_bitvec(struct dlb2_hw *hw);
720 * dlb2_ack_vf_flr_int() - ack processed VF<->PF interrupt(s)
721 * @hw: dlb2_hw handle for a particular device.
722 * @bitvec: bit vector returned by dlb2_read_vf_flr_int_bitvec()
724 * When done processing all VF FLR requests, this function unsets the VF's FLR
727 void dlb2_ack_vf_flr_int(struct dlb2_hw *hw, u32 bitvec);
730 * dlb2_ack_vdev_to_pf_int() - ack processed VF mbox and FLR interrupt(s)
731 * @hw: dlb2_hw handle for a particular device.
732 * @mbox_bitvec: bit vector returned by dlb2_read_vdev_to_pf_int_bitvec()
733 * @flr_bitvec: bit vector returned by dlb2_read_vf_flr_int_bitvec()
735 * When done processing all VF requests, this function communicates to the
736 * hardware that processing is complete.
738 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
741 void dlb2_ack_vdev_to_pf_int(struct dlb2_hw *hw,
746 * dlb2_process_wdt_interrupt() - process watchdog timer interrupts
747 * @hw: dlb2_hw handle for a particular device.
749 * This function reads the watchdog timer interrupt cause registers to
750 * determine which port(s) had a watchdog timeout, and notifies the
751 * application(s) that own the port(s).
753 void dlb2_process_wdt_interrupt(struct dlb2_hw *hw);
756 * dlb2_process_alarm_interrupt() - process an alarm interrupt
757 * @hw: dlb2_hw handle for a particular device.
759 * This function reads and logs the alarm syndrome, then acks the interrupt.
760 * This function should be called from the alarm interrupt handler when
761 * interrupt vector DLB2_INT_ALARM fires.
763 void dlb2_process_alarm_interrupt(struct dlb2_hw *hw);
766 * dlb2_process_ingress_error_interrupt() - process ingress error interrupts
767 * @hw: dlb2_hw handle for a particular device.
769 * This function reads the alarm syndrome, logs it, notifies user-space, and
770 * acks the interrupt. This function should be called from the alarm interrupt
771 * handler when interrupt vector DLB2_INT_INGRESS_ERROR fires.
774 * Returns true if an ingress error interrupt occurred, false otherwise
776 bool dlb2_process_ingress_error_interrupt(struct dlb2_hw *hw);
779 * dlb2_get_group_sequence_numbers() - return a group's number of SNs per queue
780 * @hw: dlb2_hw handle for a particular device.
781 * @group_id: sequence number group ID.
783 * This function returns the configured number of sequence numbers per queue
784 * for the specified group.
787 * Returns -EINVAL if group_id is invalid, else the group's SNs per queue.
789 int dlb2_get_group_sequence_numbers(struct dlb2_hw *hw,
790 unsigned int group_id);
793 * dlb2_get_group_sequence_number_occupancy() - return a group's in-use slots
794 * @hw: dlb2_hw handle for a particular device.
795 * @group_id: sequence number group ID.
797 * This function returns the group's number of in-use slots (i.e. load-balanced
798 * queues using the specified group).
801 * Returns -EINVAL if group_id is invalid, else the group's SNs per queue.
803 int dlb2_get_group_sequence_number_occupancy(struct dlb2_hw *hw,
804 unsigned int group_id);
807 * dlb2_set_group_sequence_numbers() - assign a group's number of SNs per queue
808 * @hw: dlb2_hw handle for a particular device.
809 * @group_id: sequence number group ID.
810 * @val: requested amount of sequence numbers per queue.
812 * This function configures the group's number of sequence numbers per queue.
813 * val can be a power-of-two between 32 and 1024, inclusive. This setting can
814 * be configured until the first ordered load-balanced queue is configured, at
815 * which point the configuration is locked.
818 * Returns 0 upon success; -EINVAL if group_id or val is invalid, -EPERM if an
819 * ordered queue is configured.
821 int dlb2_set_group_sequence_numbers(struct dlb2_hw *hw,
822 unsigned int group_id,
826 * dlb2_reset_domain() - reset a scheduling domain
827 * @hw: dlb2_hw handle for a particular device.
828 * @domain_id: domain ID.
829 * @vdev_request: indicates whether this request came from a vdev.
830 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
832 * This function resets and frees a DLB 2.0 scheduling domain and its associated
835 * Pre-condition: the driver must ensure software has stopped sending QEs
836 * through this domain's producer ports before invoking this function, or
837 * undefined behavior will result.
839 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
843 * Returns 0 upon success, -1 otherwise.
845 * EINVAL - Invalid domain ID, or the domain is not configured.
846 * EFAULT - Internal error. (Possibly caused if software is the pre-condition
848 * ETIMEDOUT - Hardware component didn't reset in the expected time.
850 int dlb2_reset_domain(struct dlb2_hw *hw,
853 unsigned int vdev_id);
856 * dlb2_ldb_port_owned_by_domain() - query whether a port is owned by a domain
857 * @hw: dlb2_hw handle for a particular device.
858 * @domain_id: domain ID.
859 * @port_id: indicates whether this request came from a VF.
860 * @vdev_request: indicates whether this request came from a vdev.
861 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
863 * This function returns whether a load-balanced port is owned by a specified
866 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
870 * Returns 0 if false, 1 if true, <0 otherwise.
872 * EINVAL - Invalid domain or port ID, or the domain is not configured.
874 int dlb2_ldb_port_owned_by_domain(struct dlb2_hw *hw,
878 unsigned int vdev_id);
881 * dlb2_dir_port_owned_by_domain() - query whether a port is owned by a domain
882 * @hw: dlb2_hw handle for a particular device.
883 * @domain_id: domain ID.
884 * @port_id: indicates whether this request came from a VF.
885 * @vdev_request: indicates whether this request came from a vdev.
886 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
888 * This function returns whether a directed port is owned by a specified
891 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
895 * Returns 0 if false, 1 if true, <0 otherwise.
897 * EINVAL - Invalid domain or port ID, or the domain is not configured.
899 int dlb2_dir_port_owned_by_domain(struct dlb2_hw *hw,
903 unsigned int vdev_id);
906 * dlb2_hw_get_num_resources() - query the PCI function's available resources
907 * @hw: dlb2_hw handle for a particular device.
908 * @arg: pointer to resource counts.
909 * @vdev_request: indicates whether this request came from a vdev.
910 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
912 * This function returns the number of available resources for the PF or for a
915 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
919 * Returns 0 upon success, -EINVAL if vdev_request is true and vdev_id is
922 int dlb2_hw_get_num_resources(struct dlb2_hw *hw,
923 struct dlb2_get_num_resources_args *arg,
925 unsigned int vdev_id);
928 * dlb2_hw_get_num_used_resources() - query the PCI function's used resources
929 * @hw: dlb2_hw handle for a particular device.
930 * @arg: pointer to resource counts.
931 * @vdev_request: indicates whether this request came from a vdev.
932 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
934 * This function returns the number of resources in use by the PF or a VF. It
935 * fills in the fields that args points to, except the following:
936 * - max_contiguous_atomic_inflights
937 * - max_contiguous_hist_list_entries
938 * - max_contiguous_ldb_credits
939 * - max_contiguous_dir_credits
941 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
945 * Returns 0 upon success, -EINVAL if vdev_request is true and vdev_id is
948 int dlb2_hw_get_num_used_resources(struct dlb2_hw *hw,
949 struct dlb2_get_num_resources_args *arg,
951 unsigned int vdev_id);
954 * dlb2_send_async_vdev_to_pf_msg() - (vdev only) send a mailbox message to
956 * @hw: dlb2_hw handle for a particular device.
958 * This function sends a VF->PF mailbox message. It is asynchronous, so it
959 * returns once the message is sent but potentially before the PF has processed
960 * the message. The caller must call dlb2_vdev_to_pf_complete() to determine
961 * when the PF has finished processing the request.
963 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
966 void dlb2_send_async_vdev_to_pf_msg(struct dlb2_hw *hw);
969 * dlb2_vdev_to_pf_complete() - check the status of an asynchronous mailbox
971 * @hw: dlb2_hw handle for a particular device.
973 * This function returns a boolean indicating whether the PF has finished
974 * processing a VF->PF mailbox request. It should only be called after sending
975 * an asynchronous request with dlb2_send_async_vdev_to_pf_msg().
977 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
980 bool dlb2_vdev_to_pf_complete(struct dlb2_hw *hw);
983 * dlb2_vf_flr_complete() - check the status of a VF FLR
984 * @hw: dlb2_hw handle for a particular device.
986 * This function returns a boolean indicating whether the PF has finished
987 * executing the VF FLR. It should only be called after setting the VF's FLR
990 bool dlb2_vf_flr_complete(struct dlb2_hw *hw);
993 * dlb2_send_async_pf_to_vdev_msg() - (PF only) send a mailbox message to a
995 * @hw: dlb2_hw handle for a particular device.
998 * This function sends a PF->vdev mailbox message. It is asynchronous, so it
999 * returns once the message is sent but potentially before the vdev has
1000 * processed the message. The caller must call dlb2_pf_to_vdev_complete() to
1001 * determine when the vdev has finished processing the request.
1003 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1006 void dlb2_send_async_pf_to_vdev_msg(struct dlb2_hw *hw, unsigned int vdev_id);
1009 * dlb2_pf_to_vdev_complete() - check the status of an asynchronous mailbox
1011 * @hw: dlb2_hw handle for a particular device.
1012 * @vdev_id: vdev ID.
1014 * This function returns a boolean indicating whether the vdev has finished
1015 * processing a PF->vdev mailbox request. It should only be called after
1016 * sending an asynchronous request with dlb2_send_async_pf_to_vdev_msg().
1018 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1021 bool dlb2_pf_to_vdev_complete(struct dlb2_hw *hw, unsigned int vdev_id);
1024 * dlb2_pf_read_vf_mbox_req() - (PF only) read a VF->PF mailbox request
1025 * @hw: dlb2_hw handle for a particular device.
1027 * @data: pointer to message data.
1028 * @len: size, in bytes, of the data array.
1030 * This function copies one of the PF's VF->PF mailboxes into the array pointed
1034 * Returns 0 upon success, <0 otherwise.
1036 * EINVAL - len >= DLB2_VF2PF_REQ_BYTES.
1038 int dlb2_pf_read_vf_mbox_req(struct dlb2_hw *hw,
1044 * dlb2_pf_read_vf_mbox_resp() - (PF only) read a VF->PF mailbox response
1045 * @hw: dlb2_hw handle for a particular device.
1047 * @data: pointer to message data.
1048 * @len: size, in bytes, of the data array.
1050 * This function copies one of the PF's VF->PF mailboxes into the array pointed
1054 * Returns 0 upon success, <0 otherwise.
1056 * EINVAL - len >= DLB2_VF2PF_RESP_BYTES.
1058 int dlb2_pf_read_vf_mbox_resp(struct dlb2_hw *hw,
1064 * dlb2_pf_write_vf_mbox_resp() - (PF only) write a PF->VF mailbox response
1065 * @hw: dlb2_hw handle for a particular device.
1067 * @data: pointer to message data.
1068 * @len: size, in bytes, of the data array.
1070 * This function copies the user-provided message data into of the PF's VF->PF
1074 * Returns 0 upon success, <0 otherwise.
1076 * EINVAL - len >= DLB2_PF2VF_RESP_BYTES.
1078 int dlb2_pf_write_vf_mbox_resp(struct dlb2_hw *hw,
1084 * dlb2_pf_write_vf_mbox_req() - (PF only) write a PF->VF mailbox request
1085 * @hw: dlb2_hw handle for a particular device.
1087 * @data: pointer to message data.
1088 * @len: size, in bytes, of the data array.
1090 * This function copies the user-provided message data into of the PF's VF->PF
1094 * Returns 0 upon success, <0 otherwise.
1096 * EINVAL - len >= DLB2_PF2VF_REQ_BYTES.
1098 int dlb2_pf_write_vf_mbox_req(struct dlb2_hw *hw,
1104 * dlb2_vf_read_pf_mbox_resp() - (VF only) read a PF->VF mailbox response
1105 * @hw: dlb2_hw handle for a particular device.
1106 * @data: pointer to message data.
1107 * @len: size, in bytes, of the data array.
1109 * This function copies the VF's PF->VF mailbox into the array pointed to by
1113 * Returns 0 upon success, <0 otherwise.
1115 * EINVAL - len >= DLB2_PF2VF_RESP_BYTES.
1117 int dlb2_vf_read_pf_mbox_resp(struct dlb2_hw *hw, void *data, int len);
1120 * dlb2_vf_read_pf_mbox_req() - (VF only) read a PF->VF mailbox request
1121 * @hw: dlb2_hw handle for a particular device.
1122 * @data: pointer to message data.
1123 * @len: size, in bytes, of the data array.
1125 * This function copies the VF's PF->VF mailbox into the array pointed to by
1129 * Returns 0 upon success, <0 otherwise.
1131 * EINVAL - len >= DLB2_PF2VF_REQ_BYTES.
1133 int dlb2_vf_read_pf_mbox_req(struct dlb2_hw *hw, void *data, int len);
1136 * dlb2_vf_write_pf_mbox_req() - (VF only) write a VF->PF mailbox request
1137 * @hw: dlb2_hw handle for a particular device.
1138 * @data: pointer to message data.
1139 * @len: size, in bytes, of the data array.
1141 * This function copies the user-provided message data into of the VF's PF->VF
1145 * Returns 0 upon success, <0 otherwise.
1147 * EINVAL - len >= DLB2_VF2PF_REQ_BYTES.
1149 int dlb2_vf_write_pf_mbox_req(struct dlb2_hw *hw, void *data, int len);
1152 * dlb2_vf_write_pf_mbox_resp() - (VF only) write a VF->PF mailbox response
1153 * @hw: dlb2_hw handle for a particular device.
1154 * @data: pointer to message data.
1155 * @len: size, in bytes, of the data array.
1157 * This function copies the user-provided message data into of the VF's PF->VF
1161 * Returns 0 upon success, <0 otherwise.
1163 * EINVAL - len >= DLB2_VF2PF_RESP_BYTES.
1165 int dlb2_vf_write_pf_mbox_resp(struct dlb2_hw *hw, void *data, int len);
1168 * dlb2_reset_vdev() - reset the hardware owned by a virtual device
1169 * @hw: dlb2_hw handle for a particular device.
1170 * @id: virtual device ID
1172 * This function resets the hardware owned by a vdev, by resetting the vdev's
1173 * domains one by one.
1175 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1178 int dlb2_reset_vdev(struct dlb2_hw *hw, unsigned int id);
1181 * dlb2_vdev_is_locked() - check whether the vdev's resources are locked
1182 * @hw: dlb2_hw handle for a particular device.
1183 * @id: virtual device ID
1185 * This function returns whether or not the vdev's resource assignments are
1186 * locked. If locked, no resources can be added to or subtracted from the
1189 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1192 bool dlb2_vdev_is_locked(struct dlb2_hw *hw, unsigned int id);
1195 * dlb2_lock_vdev() - lock the vdev's resources
1196 * @hw: dlb2_hw handle for a particular device.
1197 * @id: virtual device ID
1199 * This function sets a flag indicating that the vdev is using its resources.
1200 * When the vdev is locked, its resource assignment cannot be changed.
1202 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1205 void dlb2_lock_vdev(struct dlb2_hw *hw, unsigned int id);
1208 * dlb2_unlock_vdev() - unlock the vdev's resources
1209 * @hw: dlb2_hw handle for a particular device.
1210 * @id: virtual device ID
1212 * This function unlocks the vdev's resource assignment, allowing it to be
1215 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1218 void dlb2_unlock_vdev(struct dlb2_hw *hw, unsigned int id);
1221 * dlb2_update_vdev_sched_domains() - update the domains assigned to a vdev
1222 * @hw: dlb2_hw handle for a particular device.
1223 * @id: virtual device ID
1224 * @num: number of scheduling domains to assign to this vdev
1226 * This function assigns num scheduling domains to the specified vdev. If the
1227 * vdev already has domains assigned, this existing assignment is adjusted
1230 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1234 * Returns 0 upon success, <0 otherwise.
1237 * EINVAL - id is invalid, or the requested number of resources are
1239 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1241 int dlb2_update_vdev_sched_domains(struct dlb2_hw *hw, u32 id, u32 num);
1244 * dlb2_update_vdev_ldb_queues() - update the LDB queues assigned to a vdev
1245 * @hw: dlb2_hw handle for a particular device.
1246 * @id: virtual device ID
1247 * @num: number of LDB queues to assign to this vdev
1249 * This function assigns num LDB queues to the specified vdev. If the vdev
1250 * already has LDB queues assigned, this existing assignment is adjusted
1253 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1257 * Returns 0 upon success, <0 otherwise.
1260 * EINVAL - id is invalid, or the requested number of resources are
1262 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1264 int dlb2_update_vdev_ldb_queues(struct dlb2_hw *hw, u32 id, u32 num);
1267 * dlb2_update_vdev_ldb_ports() - update the LDB ports assigned to a vdev
1268 * @hw: dlb2_hw handle for a particular device.
1269 * @id: virtual device ID
1270 * @num: number of LDB ports to assign to this vdev
1272 * This function assigns num LDB ports to the specified vdev. If the vdev
1273 * already has LDB ports assigned, this existing assignment is adjusted
1276 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1280 * Returns 0 upon success, <0 otherwise.
1283 * EINVAL - id is invalid, or the requested number of resources are
1285 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1287 int dlb2_update_vdev_ldb_ports(struct dlb2_hw *hw, u32 id, u32 num);
1290 * dlb2_update_vdev_ldb_cos_ports() - update the LDB ports assigned to a vdev
1291 * @hw: dlb2_hw handle for a particular device.
1292 * @id: virtual device ID
1293 * @cos: class-of-service ID
1294 * @num: number of LDB ports to assign to this vdev
1296 * This function assigns num LDB ports from class-of-service cos to the
1297 * specified vdev. If the vdev already has LDB ports from this class-of-service
1298 * assigned, this existing assignment is adjusted accordingly.
1300 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1304 * Returns 0 upon success, <0 otherwise.
1307 * EINVAL - id is invalid, or the requested number of resources are
1309 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1311 int dlb2_update_vdev_ldb_cos_ports(struct dlb2_hw *hw,
1317 * dlb2_update_vdev_dir_ports() - update the DIR ports assigned to a vdev
1318 * @hw: dlb2_hw handle for a particular device.
1319 * @id: virtual device ID
1320 * @num: number of DIR ports to assign to this vdev
1322 * This function assigns num DIR ports to the specified vdev. If the vdev
1323 * already has DIR ports assigned, this existing assignment is adjusted
1326 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1330 * Returns 0 upon success, <0 otherwise.
1333 * EINVAL - id is invalid, or the requested number of resources are
1335 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1337 int dlb2_update_vdev_dir_ports(struct dlb2_hw *hw, u32 id, u32 num);
1340 * dlb2_update_vdev_ldb_credits() - update the vdev's assigned LDB credits
1341 * @hw: dlb2_hw handle for a particular device.
1342 * @id: virtual device ID
1343 * @num: number of LDB credit credits to assign to this vdev
1345 * This function assigns num LDB credit to the specified vdev. If the vdev
1346 * already has LDB credits assigned, this existing assignment is adjusted
1347 * accordingly. vdevs are assigned a contiguous chunk of credits, so this
1348 * function may fail if a sufficiently large contiguous chunk is not available.
1350 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1354 * Returns 0 upon success, <0 otherwise.
1357 * EINVAL - id is invalid, or the requested number of resources are
1359 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1361 int dlb2_update_vdev_ldb_credits(struct dlb2_hw *hw, u32 id, u32 num);
1364 * dlb2_update_vdev_dir_credits() - update the vdev's assigned DIR credits
1365 * @hw: dlb2_hw handle for a particular device.
1366 * @id: virtual device ID
1367 * @num: number of DIR credits to assign to this vdev
1369 * This function assigns num DIR credit to the specified vdev. If the vdev
1370 * already has DIR credits assigned, this existing assignment is adjusted
1371 * accordingly. vdevs are assigned a contiguous chunk of credits, so this
1372 * function may fail if a sufficiently large contiguous chunk is not available.
1374 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1378 * Returns 0 upon success, <0 otherwise.
1381 * EINVAL - id is invalid, or the requested number of resources are
1383 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1385 int dlb2_update_vdev_dir_credits(struct dlb2_hw *hw, u32 id, u32 num);
1388 * dlb2_update_vdev_hist_list_entries() - update the vdev's assigned HL entries
1389 * @hw: dlb2_hw handle for a particular device.
1390 * @id: virtual device ID
1391 * @num: number of history list entries to assign to this vdev
1393 * This function assigns num history list entries to the specified vdev. If the
1394 * vdev already has history list entries assigned, this existing assignment is
1395 * adjusted accordingly. vdevs are assigned a contiguous chunk of entries, so
1396 * this function may fail if a sufficiently large contiguous chunk is not
1399 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1403 * Returns 0 upon success, <0 otherwise.
1406 * EINVAL - id is invalid, or the requested number of resources are
1408 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1410 int dlb2_update_vdev_hist_list_entries(struct dlb2_hw *hw, u32 id, u32 num);
1413 * dlb2_update_vdev_atomic_inflights() - update the vdev's atomic inflights
1414 * @hw: dlb2_hw handle for a particular device.
1415 * @id: virtual device ID
1416 * @num: number of atomic inflights to assign to this vdev
1418 * This function assigns num atomic inflights to the specified vdev. If the vdev
1419 * already has atomic inflights assigned, this existing assignment is adjusted
1420 * accordingly. vdevs are assigned a contiguous chunk of entries, so this
1421 * function may fail if a sufficiently large contiguous chunk is not available.
1423 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1427 * Returns 0 upon success, <0 otherwise.
1430 * EINVAL - id is invalid, or the requested number of resources are
1432 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1434 int dlb2_update_vdev_atomic_inflights(struct dlb2_hw *hw, u32 id, u32 num);
1437 * dlb2_reset_vdev_resources() - reassign the vdev's resources to the PF
1438 * @hw: dlb2_hw handle for a particular device.
1439 * @id: virtual device ID
1441 * This function takes any resources currently assigned to the vdev and
1442 * reassigns them to the PF.
1444 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1448 * Returns 0 upon success, <0 otherwise.
1451 * EINVAL - id is invalid
1452 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1454 int dlb2_reset_vdev_resources(struct dlb2_hw *hw, unsigned int id);
1457 * dlb2_notify_vf() - send an alarm to a VF
1458 * @hw: dlb2_hw handle for a particular device.
1460 * @notification: notification
1462 * This function sends a notification (as defined in dlb2_mbox.h) to a VF.
1465 * Returns 0 upon success, <0 if the VF doesn't ACK the PF->VF interrupt.
1467 int dlb2_notify_vf(struct dlb2_hw *hw,
1472 * dlb2_vdev_in_use() - query whether a virtual device is in use
1473 * @hw: dlb2_hw handle for a particular device.
1474 * @id: virtual device ID
1476 * This function sends a mailbox request to the vdev to query whether the vdev
1479 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1483 * Returns 0 for false, 1 for true, and <0 if the mailbox request times out or
1484 * an internal error occurs.
1486 int dlb2_vdev_in_use(struct dlb2_hw *hw, unsigned int id);
1489 * dlb2_clr_pmcsr_disable() - power on bulk of DLB 2.0 logic
1490 * @hw: dlb2_hw handle for a particular device.
1492 * Clearing the PMCSR must be done at initialization to make the device fully
1495 void dlb2_clr_pmcsr_disable(struct dlb2_hw *hw);
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.
1506 * This function returns the depth of a load-balanced queue.
1508 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
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.
1517 * EINVAL - Invalid domain ID or queue ID.
1519 int dlb2_hw_get_ldb_queue_depth(struct dlb2_hw *hw,
1521 struct dlb2_get_ldb_queue_depth_args *args,
1522 struct dlb2_cmd_response *resp,
1524 unsigned int vdev_id);
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.
1535 * This function returns the depth of a directed queue.
1537 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
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.
1546 * EINVAL - Invalid domain ID or queue ID.
1548 int dlb2_hw_get_dir_queue_depth(struct dlb2_hw *hw,
1550 struct dlb2_get_dir_queue_depth_args *args,
1551 struct dlb2_cmd_response *resp,
1553 unsigned int vdev_id);
1555 enum dlb2_virt_mode {
1560 /* NUM_DLB2_VIRT_MODES must be last */
1561 NUM_DLB2_VIRT_MODES,
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.
1569 * This function sets the virtualization mode of the device. This controls
1570 * whether the device uses a software or hardware mailbox.
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.
1577 * EINVAL - Invalid mode.
1579 int dlb2_hw_set_virt_mode(struct dlb2_hw *hw, enum dlb2_virt_mode mode);
1582 * dlb2_hw_get_virt_mode() - get the device's virtualization mode
1583 * @hw: dlb2_hw handle for a particular device.
1585 * This function gets the virtualization mode of the device.
1587 enum dlb2_virt_mode dlb2_hw_get_virt_mode(struct dlb2_hw *hw);
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.
1596 * Returns >= 0 upon success, -1 otherwise.
1598 s32 dlb2_hw_get_ldb_port_phys_id(struct dlb2_hw *hw,
1600 unsigned int vdev_id);
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.
1609 * Returns >= 0 upon success, -1 otherwise.
1611 s32 dlb2_hw_get_dir_port_phys_id(struct dlb2_hw *hw,
1613 unsigned int vdev_id);
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.
1624 * When Scalable IOV is enabled, the VDCM must register a software mailbox for
1625 * every virtual device during vdev creation.
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.
1633 void dlb2_hw_register_sw_mbox(struct dlb2_hw *hw,
1634 unsigned int vdev_id,
1637 void (*pf2vdev_inject)(void *),
1641 * dlb2_hw_unregister_sw_mbox() - unregister a software mailbox
1642 * @hw: dlb2_hw handle for a particular device.
1643 * @vdev_id: vdev ID.
1645 * This function notifies the driver to stop using a previously registered
1648 void dlb2_hw_unregister_sw_mbox(struct dlb2_hw *hw, unsigned int vdev_id);
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.
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
1664 void dlb2_hw_setup_cq_ims_entry(struct dlb2_hw *hw,
1665 unsigned int vdev_id,
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.
1678 * This clears the CQ's IMS entry, reverting it to its reset state.
1680 void dlb2_hw_clear_cq_ims_entry(struct dlb2_hw *hw,
1681 unsigned int vdev_id,
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.
1691 * This function stores the user-supplied PASID, and uses it when configuring
1695 * Returns >= 0 upon success, -1 otherwise.
1697 int dlb2_hw_register_pasid(struct dlb2_hw *hw,
1698 unsigned int vdev_id,
1699 unsigned int pasid);
1702 * dlb2_hw_pending_port_unmaps() - returns the number of unmap operations in
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.
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.
1717 * EINVAL - Invalid port ID.
1719 int dlb2_hw_pending_port_unmaps(struct dlb2_hw *hw,
1721 struct dlb2_pending_port_unmaps_args *args,
1722 struct dlb2_cmd_response *resp,
1724 unsigned int vf_id);
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.
1733 * Returns -EINVAL if cos_id is invalid, else the class' bandwidth allocation.
1735 int dlb2_hw_get_cos_bandwidth(struct dlb2_hw *hw, u32 cos_id);
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.
1745 * Returns 0 upon success, < 0 otherwise.
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
1752 int dlb2_hw_set_cos_bandwidth(struct dlb2_hw *hw, u32 cos_id, u8 bandwidth);
1755 /* 40s watchdog timeout */
1757 /* 10s watchdog timeout */
1759 /* 1s watchdog timeout */
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.
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().
1777 * Returns 0 upon success, < 0 otherwise.
1780 * EINVAL - Invalid timeout.
1782 int dlb2_hw_enable_wd_timer(struct dlb2_hw *hw, enum dlb2_wd_tmo tmo);
1785 * dlb2_hw_enable_dir_cq_wd_int() - enable the CQ watchdog interrupt on an
1787 * @hw: dlb2_hw handle for a particular device.
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.
1793 * Returns 0 upon success, < 0 otherwise.
1796 * EINVAL - Invalid directed port ID.
1798 int dlb2_hw_enable_dir_cq_wd_int(struct dlb2_hw *hw,
1801 unsigned int vdev_id);
1804 * dlb2_hw_enable_ldb_cq_wd_int() - enable the CQ watchdog interrupt on an
1806 * @hw: dlb2_hw handle for a particular device.
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.
1812 * Returns 0 upon success, < 0 otherwise.
1815 * EINVAL - Invalid load-balanced port ID.
1817 int dlb2_hw_enable_ldb_cq_wd_int(struct dlb2_hw *hw,
1820 unsigned int vdev_id);
1823 * dlb2_hw_enable_sparse_ldb_cq_mode() - enable sparse mode for load-balanced
1825 * @hw: dlb2_hw handle for a particular device.
1827 * This function must be called prior to configuring scheduling domains.
1829 void dlb2_hw_enable_sparse_ldb_cq_mode(struct dlb2_hw *hw);
1832 * dlb2_hw_enable_sparse_dir_cq_mode() - enable sparse mode for directed ports.
1833 * @hw: dlb2_hw handle for a particular device.
1835 * This function must be called prior to configuring scheduling domains.
1837 void dlb2_hw_enable_sparse_dir_cq_mode(struct dlb2_hw *hw);
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.
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
1851 void dlb2_hw_set_qe_arbiter_weights(struct dlb2_hw *hw, u8 weight[8]);
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.
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
1865 void dlb2_hw_set_qid_arbiter_weights(struct dlb2_hw *hw, u8 weight[8]);
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.
1872 * This function returns whether the load-balanced CQ interrupt is enabled.
1874 int dlb2_hw_ldb_cq_interrupt_enabled(struct dlb2_hw *hw, int port_id);
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})
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().
1886 void dlb2_hw_ldb_cq_interrupt_set_mode(struct dlb2_hw *hw,
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.
1895 * This function returns whether the load-balanced CQ interrupt is enabled.
1897 int dlb2_hw_dir_cq_interrupt_enabled(struct dlb2_hw *hw, int port_id);
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})
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().
1909 void dlb2_hw_dir_cq_interrupt_set_mode(struct dlb2_hw *hw,
1913 #endif /* __DLB2_RESOURCE_H */