1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2016-2020 Intel Corporation
5 #ifndef __DLB2_RESOURCE_H
6 #define __DLB2_RESOURCE_H
9 #include "dlb2_osdep_types.h"
12 * dlb2_resource_init() - initialize the device
13 * @hw: pointer to struct dlb2_hw.
14 * @ver: device version.
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.
20 * The dlb2_hw struct must be unique per DLB 2.0 device and persist until the
24 * Returns 0 upon success, <0 otherwise.
26 int dlb2_resource_init(struct dlb2_hw *hw, enum dlb2_hw_ver ver);
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.
33 * Clearing the PMCSR must be done at initialization to make the device fully
36 void dlb2_clr_pmcsr_disable(struct dlb2_hw *hw, enum dlb2_hw_ver ver);
39 * dlb2_resource_free() - free device state memory
40 * @hw: dlb2_hw handle for a particular device.
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.
45 void dlb2_resource_free(struct dlb2_hw *hw);
48 * dlb2_resource_reset() - reset in-use resources to their initial state
49 * @hw: dlb2_hw handle for a particular device.
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.
54 void dlb2_resource_reset(struct dlb2_hw *hw);
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.
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.
68 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
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.
76 * resp->id contains a virtual ID if vdev_request is true.
79 * EINVAL - A requested resource is unavailable, or the requested domain name
81 * EFAULT - Internal error (resp->status not set).
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,
87 unsigned int vdev_id);
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.
98 * This function creates a load-balanced queue.
100 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
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.
108 * resp->id contains a virtual ID if vdev_request is true.
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
114 * EFAULT - Internal error (resp->status not set).
116 int dlb2_hw_create_ldb_queue(struct dlb2_hw *hw,
118 struct dlb2_create_ldb_queue_args *args,
119 struct dlb2_cmd_response *resp,
121 unsigned int vdev_id);
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.
132 * This function creates a directed queue.
134 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
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.
142 * resp->id contains a virtual ID if vdev_request is true.
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).
149 int dlb2_hw_create_dir_queue(struct dlb2_hw *hw,
151 struct dlb2_create_dir_queue_args *args,
152 struct dlb2_cmd_response *resp,
154 unsigned int vdev_id);
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.
166 * This function creates a directed port.
168 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
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.
176 * resp->id contains a virtual ID if vdev_request is true.
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).
184 int dlb2_hw_create_dir_port(struct dlb2_hw *hw,
186 struct dlb2_create_dir_port_args *args,
187 uintptr_t cq_dma_base,
188 struct dlb2_cmd_response *resp,
190 unsigned int vdev_id);
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.
202 * This function creates a load-balanced port.
204 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
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.
212 * resp->id contains a virtual ID if vdev_request is true.
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).
220 int dlb2_hw_create_ldb_port(struct dlb2_hw *hw,
222 struct dlb2_create_ldb_port_args *args,
223 uintptr_t cq_dma_base,
224 struct dlb2_cmd_response *resp,
226 unsigned int vdev_id);
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.
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).
241 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
245 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
246 * assigned a detailed error code from enum dlb2_error.
249 * EINVAL - the domain is not configured, or the domain is already started.
251 int dlb2_hw_start_domain(struct dlb2_hw *hw,
253 struct dlb2_start_domain_args *args,
254 struct dlb2_cmd_response *resp,
256 unsigned int vdev_id);
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.
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.
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.
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.
287 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
291 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
292 * assigned a detailed error code from enum dlb2_error.
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).
299 int dlb2_hw_map_qid(struct dlb2_hw *hw,
301 struct dlb2_map_qid_args *args,
302 struct dlb2_cmd_response *resp,
304 unsigned int vdev_id);
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.
315 * This function configures the DLB to stop scheduling QEs from the specified
316 * queue to the specified port.
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.
325 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
329 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
330 * assigned a detailed error code from enum dlb2_error.
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).
337 int dlb2_hw_unmap_qid(struct dlb2_hw *hw,
339 struct dlb2_unmap_qid_args *args,
340 struct dlb2_cmd_response *resp,
342 unsigned int vdev_id);
345 * dlb2_finish_unmap_qid_procedures() - finish any pending unmap procedures
346 * @hw: dlb2_hw handle for a particular device.
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.
353 * Returns the number of procedures that weren't completed.
355 unsigned int dlb2_finish_unmap_qid_procedures(struct dlb2_hw *hw);
358 * dlb2_finish_map_qid_procedures() - finish any pending map procedures
359 * @hw: dlb2_hw handle for a particular device.
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.
366 * Returns the number of procedures that weren't completed.
368 unsigned int dlb2_finish_map_qid_procedures(struct dlb2_hw *hw);
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.
379 * This function configures the DLB to schedule QEs to a load-balanced port.
380 * Ports are enabled by default.
382 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
386 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
387 * assigned a detailed error code from enum dlb2_error.
390 * EINVAL - The port ID is invalid or the domain is not configured.
391 * EFAULT - Internal error (resp->status not set).
393 int dlb2_hw_enable_ldb_port(struct dlb2_hw *hw,
395 struct dlb2_enable_ldb_port_args *args,
396 struct dlb2_cmd_response *resp,
398 unsigned int vdev_id);
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.
409 * This function configures the DLB to stop scheduling QEs to a load-balanced
410 * port. Ports are enabled by default.
412 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
416 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
417 * assigned a detailed error code from enum dlb2_error.
420 * EINVAL - The port ID is invalid or the domain is not configured.
421 * EFAULT - Internal error (resp->status not set).
423 int dlb2_hw_disable_ldb_port(struct dlb2_hw *hw,
425 struct dlb2_disable_ldb_port_args *args,
426 struct dlb2_cmd_response *resp,
428 unsigned int vdev_id);
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.
439 * This function configures the DLB to schedule QEs to a directed port.
440 * Ports are enabled by default.
442 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
446 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
447 * assigned a detailed error code from enum dlb2_error.
450 * EINVAL - The port ID is invalid or the domain is not configured.
451 * EFAULT - Internal error (resp->status not set).
453 int dlb2_hw_enable_dir_port(struct dlb2_hw *hw,
455 struct dlb2_enable_dir_port_args *args,
456 struct dlb2_cmd_response *resp,
458 unsigned int vdev_id);
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.
469 * This function configures the DLB to stop scheduling QEs to a directed port.
470 * Ports are enabled by default.
472 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
476 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
477 * assigned a detailed error code from enum dlb2_error.
480 * EINVAL - The port ID is invalid or the domain is not configured.
481 * EFAULT - Internal error (resp->status not set).
483 int dlb2_hw_disable_dir_port(struct dlb2_hw *hw,
485 struct dlb2_disable_dir_port_args *args,
486 struct dlb2_cmd_response *resp,
488 unsigned int vdev_id);
491 * dlb2_configure_ldb_cq_interrupt() - configure load-balanced CQ for
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
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.
509 * Returns 0 upon success, < 0 otherwise.
512 * EINVAL - The port ID is invalid.
514 int dlb2_configure_ldb_cq_interrupt(struct dlb2_hw *hw,
519 unsigned int owner_vf,
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
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.
540 * Returns 0 upon success, < 0 otherwise.
543 * EINVAL - The port ID is invalid.
545 int dlb2_configure_dir_cq_interrupt(struct dlb2_hw *hw,
550 unsigned int owner_vf,
554 * dlb2_enable_ingress_error_alarms() - enable ingress error alarm interrupts
555 * @hw: dlb2_hw handle for a particular device.
557 void dlb2_enable_ingress_error_alarms(struct dlb2_hw *hw);
560 * dlb2_disable_ingress_error_alarms() - disable ingress error alarm interrupts
561 * @hw: dlb2_hw handle for a particular device.
563 void dlb2_disable_ingress_error_alarms(struct dlb2_hw *hw);
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)
570 * This function configures the hardware to use either packed or compressed
571 * mode. This function should not be called if using MSI interrupts.
573 void dlb2_set_msix_mode(struct dlb2_hw *hw, int mode);
576 * dlb2_ack_msix_interrupt() - Ack an MSI-X interrupt
577 * @hw: dlb2_hw handle for a particular device.
578 * @vector: interrupt vector.
580 * Note: Only needed for PF service interrupts (vector 0). CQ interrupts are
581 * acked in dlb2_ack_compressed_cq_intr().
583 void dlb2_ack_msix_interrupt(struct dlb2_hw *hw, int vector);
586 * dlb2_arm_cq_interrupt() - arm a CQ's interrupt
587 * @hw: dlb2_hw handle for a particular device.
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.
593 * This function arms the CQ's interrupt. The CQ must be configured prior to
594 * calling this function.
596 * The function does no parameter validation; that is the caller's
599 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
602 * Return: returns 0 upon success, <0 otherwise.
604 * EINVAL - Invalid port ID.
606 int dlb2_arm_cq_interrupt(struct dlb2_hw *hw,
610 unsigned int vdev_id);
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
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().
623 void dlb2_read_compressed_cq_intr_status(struct dlb2_hw *hw,
625 u32 *dir_interrupts);
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
633 * This function ACKs compressed CQ interrupts. Its arguments should be the
634 * same ones passed to dlb2_read_compressed_cq_intr_status().
636 void dlb2_ack_compressed_cq_intr(struct dlb2_hw *hw,
638 u32 *dir_interrupts);
641 * dlb2_read_vf_intr_status() - read the VF interrupt status register
642 * @hw: dlb2_hw handle for a particular device.
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.
649 * Returns a bit vector indicating which interrupt vectors are active.
651 u32 dlb2_read_vf_intr_status(struct dlb2_hw *hw);
654 * dlb2_ack_vf_intr_status() - ack VF interrupts
655 * @hw: dlb2_hw handle for a particular device.
656 * @interrupts: 32-bit bitmap
658 * This function ACKs a VF's interrupts. Its interrupts argument should be the
659 * value returned by dlb2_read_vf_intr_status().
661 void dlb2_ack_vf_intr_status(struct dlb2_hw *hw, u32 interrupts);
664 * dlb2_ack_vf_msi_intr() - ack VF MSI interrupt
665 * @hw: dlb2_hw handle for a particular device.
666 * @interrupts: 32-bit bitmap
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.
672 void dlb2_ack_vf_msi_intr(struct dlb2_hw *hw, u32 interrupts);
675 * dlb2_ack_pf_mbox_int() - ack PF->VF mailbox interrupt
676 * @hw: dlb2_hw handle for a particular device.
678 * When done processing the PF mailbox request, this function unsets
679 * the PF's mailbox ISR register.
681 void dlb2_ack_pf_mbox_int(struct dlb2_hw *hw);
684 * dlb2_read_vdev_to_pf_int_bitvec() - return a bit vector of all requesting
686 * @hw: dlb2_hw handle for a particular device.
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
693 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
697 * Returns a bit vector indicating which VFs (0-15) have requested service.
699 u32 dlb2_read_vdev_to_pf_int_bitvec(struct dlb2_hw *hw);
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()
706 * When done processing all VF mailbox requests, this function unsets the VF's
707 * mailbox ISR register.
709 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
712 void dlb2_ack_vdev_mbox_int(struct dlb2_hw *hw, u32 bitvec);
715 * dlb2_read_vf_flr_int_bitvec() - return a bit vector of all VFs requesting
717 * @hw: dlb2_hw handle for a particular device.
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.
724 * Returns a bit vector indicating which VFs (0-15) have requested FLRs.
726 u32 dlb2_read_vf_flr_int_bitvec(struct dlb2_hw *hw);
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()
733 * When done processing all VF FLR requests, this function unsets the VF's FLR
736 void dlb2_ack_vf_flr_int(struct dlb2_hw *hw, u32 bitvec);
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()
744 * When done processing all VF requests, this function communicates to the
745 * hardware that processing is complete.
747 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
750 void dlb2_ack_vdev_to_pf_int(struct dlb2_hw *hw,
755 * dlb2_process_wdt_interrupt() - process watchdog timer interrupts
756 * @hw: dlb2_hw handle for a particular device.
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).
762 void dlb2_process_wdt_interrupt(struct dlb2_hw *hw);
765 * dlb2_process_alarm_interrupt() - process an alarm interrupt
766 * @hw: dlb2_hw handle for a particular device.
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.
772 void dlb2_process_alarm_interrupt(struct dlb2_hw *hw);
775 * dlb2_process_ingress_error_interrupt() - process ingress error interrupts
776 * @hw: dlb2_hw handle for a particular device.
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.
783 * Returns true if an ingress error interrupt occurred, false otherwise
785 bool dlb2_process_ingress_error_interrupt(struct dlb2_hw *hw);
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.
792 * This function returns the configured number of sequence numbers per queue
793 * for the specified group.
796 * Returns -EINVAL if group_id is invalid, else the group's SNs per queue.
798 int dlb2_get_group_sequence_numbers(struct dlb2_hw *hw,
799 unsigned int group_id);
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.
806 * This function returns the group's number of in-use slots (i.e. load-balanced
807 * queues using the specified group).
810 * Returns -EINVAL if group_id is invalid, else the group's SNs per queue.
812 int dlb2_get_group_sequence_number_occupancy(struct dlb2_hw *hw,
813 unsigned int group_id);
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.
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.
827 * Returns 0 upon success; -EINVAL if group_id or val is invalid, -EPERM if an
828 * ordered queue is configured.
830 int dlb2_set_group_sequence_numbers(struct dlb2_hw *hw,
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.
841 * This function resets and frees a DLB 2.0 scheduling domain and its associated
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.
848 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
852 * Returns 0 upon success, -1 otherwise.
854 * EINVAL - Invalid domain ID, or the domain is not configured.
855 * EFAULT - Internal error. (Possibly caused if software is the pre-condition
857 * ETIMEDOUT - Hardware component didn't reset in the expected time.
859 int dlb2_reset_domain(struct dlb2_hw *hw,
862 unsigned int vdev_id);
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.
872 * This function returns whether a load-balanced port is owned by a specified
875 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
879 * Returns 0 if false, 1 if true, <0 otherwise.
881 * EINVAL - Invalid domain or port ID, or the domain is not configured.
883 int dlb2_ldb_port_owned_by_domain(struct dlb2_hw *hw,
887 unsigned int vdev_id);
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.
897 * This function returns whether a directed port is owned by a specified
900 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
904 * Returns 0 if false, 1 if true, <0 otherwise.
906 * EINVAL - Invalid domain or port ID, or the domain is not configured.
908 int dlb2_dir_port_owned_by_domain(struct dlb2_hw *hw,
912 unsigned int vdev_id);
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.
921 * This function returns the number of available resources for the PF or for a
924 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
928 * Returns 0 upon success, -EINVAL if vdev_request is true and vdev_id is
931 int dlb2_hw_get_num_resources(struct dlb2_hw *hw,
932 struct dlb2_get_num_resources_args *arg,
934 unsigned int vdev_id);
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.
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
950 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
954 * Returns 0 upon success, -EINVAL if vdev_request is true and vdev_id is
957 int dlb2_hw_get_num_used_resources(struct dlb2_hw *hw,
958 struct dlb2_get_num_resources_args *arg,
960 unsigned int vdev_id);
963 * dlb2_send_async_vdev_to_pf_msg() - (vdev only) send a mailbox message to
965 * @hw: dlb2_hw handle for a particular device.
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.
972 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
975 void dlb2_send_async_vdev_to_pf_msg(struct dlb2_hw *hw);
978 * dlb2_vdev_to_pf_complete() - check the status of an asynchronous mailbox
980 * @hw: dlb2_hw handle for a particular device.
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().
986 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
989 bool dlb2_vdev_to_pf_complete(struct dlb2_hw *hw);
992 * dlb2_vf_flr_complete() - check the status of a VF FLR
993 * @hw: dlb2_hw handle for a particular device.
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
999 bool dlb2_vf_flr_complete(struct dlb2_hw *hw);
1002 * dlb2_send_async_pf_to_vdev_msg() - (PF only) send a mailbox message to a
1004 * @hw: dlb2_hw handle for a particular device.
1005 * @vdev_id: vdev ID.
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.
1012 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1015 void dlb2_send_async_pf_to_vdev_msg(struct dlb2_hw *hw, unsigned int vdev_id);
1018 * dlb2_pf_to_vdev_complete() - check the status of an asynchronous mailbox
1020 * @hw: dlb2_hw handle for a particular device.
1021 * @vdev_id: vdev ID.
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().
1027 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1030 bool dlb2_pf_to_vdev_complete(struct dlb2_hw *hw, unsigned int vdev_id);
1033 * dlb2_pf_read_vf_mbox_req() - (PF only) read a VF->PF mailbox request
1034 * @hw: dlb2_hw handle for a particular device.
1036 * @data: pointer to message data.
1037 * @len: size, in bytes, of the data array.
1039 * This function copies one of the PF's VF->PF mailboxes into the array pointed
1043 * Returns 0 upon success, <0 otherwise.
1045 * EINVAL - len >= DLB2_VF2PF_REQ_BYTES.
1047 int dlb2_pf_read_vf_mbox_req(struct dlb2_hw *hw,
1053 * dlb2_pf_read_vf_mbox_resp() - (PF only) read a VF->PF mailbox response
1054 * @hw: dlb2_hw handle for a particular device.
1056 * @data: pointer to message data.
1057 * @len: size, in bytes, of the data array.
1059 * This function copies one of the PF's VF->PF mailboxes into the array pointed
1063 * Returns 0 upon success, <0 otherwise.
1065 * EINVAL - len >= DLB2_VF2PF_RESP_BYTES.
1067 int dlb2_pf_read_vf_mbox_resp(struct dlb2_hw *hw,
1073 * dlb2_pf_write_vf_mbox_resp() - (PF only) write a PF->VF mailbox response
1074 * @hw: dlb2_hw handle for a particular device.
1076 * @data: pointer to message data.
1077 * @len: size, in bytes, of the data array.
1079 * This function copies the user-provided message data into of the PF's VF->PF
1083 * Returns 0 upon success, <0 otherwise.
1085 * EINVAL - len >= DLB2_PF2VF_RESP_BYTES.
1087 int dlb2_pf_write_vf_mbox_resp(struct dlb2_hw *hw,
1093 * dlb2_pf_write_vf_mbox_req() - (PF only) write a PF->VF mailbox request
1094 * @hw: dlb2_hw handle for a particular device.
1096 * @data: pointer to message data.
1097 * @len: size, in bytes, of the data array.
1099 * This function copies the user-provided message data into of the PF's VF->PF
1103 * Returns 0 upon success, <0 otherwise.
1105 * EINVAL - len >= DLB2_PF2VF_REQ_BYTES.
1107 int dlb2_pf_write_vf_mbox_req(struct dlb2_hw *hw,
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.
1118 * This function copies the VF's PF->VF mailbox into the array pointed to by
1122 * Returns 0 upon success, <0 otherwise.
1124 * EINVAL - len >= DLB2_PF2VF_RESP_BYTES.
1126 int dlb2_vf_read_pf_mbox_resp(struct dlb2_hw *hw, void *data, int len);
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.
1134 * This function copies the VF's PF->VF mailbox into the array pointed to by
1138 * Returns 0 upon success, <0 otherwise.
1140 * EINVAL - len >= DLB2_PF2VF_REQ_BYTES.
1142 int dlb2_vf_read_pf_mbox_req(struct dlb2_hw *hw, void *data, int len);
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.
1150 * This function copies the user-provided message data into of the VF's PF->VF
1154 * Returns 0 upon success, <0 otherwise.
1156 * EINVAL - len >= DLB2_VF2PF_REQ_BYTES.
1158 int dlb2_vf_write_pf_mbox_req(struct dlb2_hw *hw, void *data, int len);
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.
1166 * This function copies the user-provided message data into of the VF's PF->VF
1170 * Returns 0 upon success, <0 otherwise.
1172 * EINVAL - len >= DLB2_VF2PF_RESP_BYTES.
1174 int dlb2_vf_write_pf_mbox_resp(struct dlb2_hw *hw, void *data, int len);
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
1181 * This function resets the hardware owned by a vdev, by resetting the vdev's
1182 * domains one by one.
1184 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1187 int dlb2_reset_vdev(struct dlb2_hw *hw, unsigned int id);
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
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
1198 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1201 bool dlb2_vdev_is_locked(struct dlb2_hw *hw, unsigned int id);
1204 * dlb2_lock_vdev() - lock the vdev's resources
1205 * @hw: dlb2_hw handle for a particular device.
1206 * @id: virtual device ID
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.
1211 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1214 void dlb2_lock_vdev(struct dlb2_hw *hw, unsigned int id);
1217 * dlb2_unlock_vdev() - unlock the vdev's resources
1218 * @hw: dlb2_hw handle for a particular device.
1219 * @id: virtual device ID
1221 * This function unlocks the vdev's resource assignment, allowing it to be
1224 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1227 void dlb2_unlock_vdev(struct dlb2_hw *hw, unsigned int id);
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
1235 * This function assigns num scheduling domains to the specified vdev. If the
1236 * vdev already has domains assigned, this existing assignment is adjusted
1239 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1243 * Returns 0 upon success, <0 otherwise.
1246 * EINVAL - id is invalid, or the requested number of resources are
1248 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1250 int dlb2_update_vdev_sched_domains(struct dlb2_hw *hw, u32 id, u32 num);
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
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
1262 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1266 * Returns 0 upon success, <0 otherwise.
1269 * EINVAL - id is invalid, or the requested number of resources are
1271 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1273 int dlb2_update_vdev_ldb_queues(struct dlb2_hw *hw, u32 id, u32 num);
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
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
1285 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1289 * Returns 0 upon success, <0 otherwise.
1292 * EINVAL - id is invalid, or the requested number of resources are
1294 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1296 int dlb2_update_vdev_ldb_ports(struct dlb2_hw *hw, u32 id, u32 num);
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
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.
1309 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1313 * Returns 0 upon success, <0 otherwise.
1316 * EINVAL - id is invalid, or the requested number of resources are
1318 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1320 int dlb2_update_vdev_ldb_cos_ports(struct dlb2_hw *hw,
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
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
1335 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1339 * Returns 0 upon success, <0 otherwise.
1342 * EINVAL - id is invalid, or the requested number of resources are
1344 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1346 int dlb2_update_vdev_dir_ports(struct dlb2_hw *hw, u32 id, u32 num);
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
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.
1359 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1363 * Returns 0 upon success, <0 otherwise.
1366 * EINVAL - id is invalid, or the requested number of resources are
1368 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1370 int dlb2_update_vdev_ldb_credits(struct dlb2_hw *hw, u32 id, u32 num);
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
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.
1383 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1387 * Returns 0 upon success, <0 otherwise.
1390 * EINVAL - id is invalid, or the requested number of resources are
1392 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1394 int dlb2_update_vdev_dir_credits(struct dlb2_hw *hw, u32 id, u32 num);
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
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
1408 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1412 * Returns 0 upon success, <0 otherwise.
1415 * EINVAL - id is invalid, or the requested number of resources are
1417 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1419 int dlb2_update_vdev_hist_list_entries(struct dlb2_hw *hw, u32 id, u32 num);
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
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.
1432 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1436 * Returns 0 upon success, <0 otherwise.
1439 * EINVAL - id is invalid, or the requested number of resources are
1441 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1443 int dlb2_update_vdev_atomic_inflights(struct dlb2_hw *hw, u32 id, u32 num);
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
1450 * This function takes any resources currently assigned to the vdev and
1451 * reassigns them to the PF.
1453 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1457 * Returns 0 upon success, <0 otherwise.
1460 * EINVAL - id is invalid
1461 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1463 int dlb2_reset_vdev_resources(struct dlb2_hw *hw, unsigned int id);
1466 * dlb2_notify_vf() - send an alarm to a VF
1467 * @hw: dlb2_hw handle for a particular device.
1469 * @notification: notification
1471 * This function sends a notification (as defined in dlb2_mbox.h) to a VF.
1474 * Returns 0 upon success, <0 if the VF doesn't ACK the PF->VF interrupt.
1476 int dlb2_notify_vf(struct dlb2_hw *hw,
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
1485 * This function sends a mailbox request to the vdev to query whether the vdev
1488 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1492 * Returns 0 for false, 1 for true, and <0 if the mailbox request times out or
1493 * an internal error occurs.
1495 int dlb2_vdev_in_use(struct dlb2_hw *hw, unsigned int id);
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 */