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_reset() - reset in-use resources to their initial state
13 * @hw: dlb2_hw handle for a particular device.
15 * This function resets in-use resources, and makes them available for use.
16 * All resources go back to their owning function, whether a PF or a VF.
18 void dlb2_resource_reset(struct dlb2_hw *hw);
21 * dlb2_hw_create_sched_domain() - create a scheduling domain
22 * @hw: dlb2_hw handle for a particular device.
23 * @args: scheduling domain creation arguments.
24 * @resp: response structure.
25 * @vdev_request: indicates whether this request came from a vdev.
26 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
28 * This function creates a scheduling domain containing the resources specified
29 * in args. The individual resources (queues, ports, credits) can be configured
30 * after creating a scheduling domain.
32 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
36 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
37 * assigned a detailed error code from enum dlb2_error. If successful, resp->id
38 * contains the domain ID.
40 * resp->id contains a virtual ID if vdev_request is true.
43 * EINVAL - A requested resource is unavailable, or the requested domain name
45 * EFAULT - Internal error (resp->status not set).
47 int dlb2_hw_create_sched_domain(struct dlb2_hw *hw,
48 struct dlb2_create_sched_domain_args *args,
49 struct dlb2_cmd_response *resp,
51 unsigned int vdev_id);
54 * dlb2_hw_create_ldb_queue() - create a load-balanced queue
55 * @hw: dlb2_hw handle for a particular device.
56 * @domain_id: domain ID.
57 * @args: queue creation arguments.
58 * @resp: response structure.
59 * @vdev_request: indicates whether this request came from a vdev.
60 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
62 * This function creates a load-balanced queue.
64 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
68 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
69 * assigned a detailed error code from enum dlb2_error. If successful, resp->id
70 * contains the queue ID.
72 * resp->id contains a virtual ID if vdev_request is true.
75 * EINVAL - A requested resource is unavailable, the domain is not configured,
76 * the domain has already been started, or the requested queue name is
78 * EFAULT - Internal error (resp->status not set).
80 int dlb2_hw_create_ldb_queue(struct dlb2_hw *hw,
82 struct dlb2_create_ldb_queue_args *args,
83 struct dlb2_cmd_response *resp,
85 unsigned int vdev_id);
88 * dlb2_hw_create_dir_queue() - create a directed queue
89 * @hw: dlb2_hw handle for a particular device.
90 * @domain_id: domain ID.
91 * @args: queue creation arguments.
92 * @resp: response structure.
93 * @vdev_request: indicates whether this request came from a vdev.
94 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
96 * This function creates a directed queue.
98 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
102 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
103 * assigned a detailed error code from enum dlb2_error. If successful, resp->id
104 * contains the queue ID.
106 * resp->id contains a virtual ID if vdev_request is true.
109 * EINVAL - A requested resource is unavailable, the domain is not configured,
110 * or the domain has already been started.
111 * EFAULT - Internal error (resp->status not set).
113 int dlb2_hw_create_dir_queue(struct dlb2_hw *hw,
115 struct dlb2_create_dir_queue_args *args,
116 struct dlb2_cmd_response *resp,
118 unsigned int vdev_id);
121 * dlb2_hw_create_dir_port() - create a directed port
122 * @hw: dlb2_hw handle for a particular device.
123 * @domain_id: domain ID.
124 * @args: port creation arguments.
125 * @cq_dma_base: base address of the CQ memory. This can be a PA or an IOVA.
126 * @resp: response structure.
127 * @vdev_request: indicates whether this request came from a vdev.
128 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
130 * This function creates a directed port.
132 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
136 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
137 * assigned a detailed error code from enum dlb2_error. If successful, resp->id
138 * contains the port ID.
140 * resp->id contains a virtual ID if vdev_request is true.
143 * EINVAL - A requested resource is unavailable, a credit setting is invalid, a
144 * pointer address is not properly aligned, the domain is not
145 * configured, or the domain has already been started.
146 * EFAULT - Internal error (resp->status not set).
148 int dlb2_hw_create_dir_port(struct dlb2_hw *hw,
150 struct dlb2_create_dir_port_args *args,
151 uintptr_t cq_dma_base,
152 struct dlb2_cmd_response *resp,
154 unsigned int vdev_id);
157 * dlb2_hw_create_ldb_port() - create a load-balanced 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 load-balanced 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_ldb_port(struct dlb2_hw *hw,
186 struct dlb2_create_ldb_port_args *args,
187 uintptr_t cq_dma_base,
188 struct dlb2_cmd_response *resp,
190 unsigned int vdev_id);
193 * dlb2_hw_start_domain() - start a scheduling domain
194 * @hw: dlb2_hw handle for a particular device.
195 * @domain_id: domain ID.
196 * @args: start domain arguments.
197 * @resp: response structure.
198 * @vdev_request: indicates whether this request came from a vdev.
199 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
201 * This function starts a scheduling domain, which allows applications to send
202 * traffic through it. Once a domain is started, its resources can no longer be
203 * configured (besides QID remapping and port enable/disable).
205 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
209 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
210 * assigned a detailed error code from enum dlb2_error.
213 * EINVAL - the domain is not configured, or the domain is already started.
215 int dlb2_hw_start_domain(struct dlb2_hw *hw,
217 struct dlb2_start_domain_args *args,
218 struct dlb2_cmd_response *resp,
220 unsigned int vdev_id);
223 * dlb2_hw_map_qid() - map a load-balanced queue to a load-balanced port
224 * @hw: dlb2_hw handle for a particular device.
225 * @domain_id: domain ID.
226 * @args: map QID arguments.
227 * @resp: response structure.
228 * @vdev_request: indicates whether this request came from a vdev.
229 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
231 * This function configures the DLB to schedule QEs from the specified queue
232 * to the specified port. Each load-balanced port can be mapped to up to 8
233 * queues; each load-balanced queue can potentially map to all the
234 * load-balanced ports.
236 * A successful return does not necessarily mean the mapping was configured. If
237 * this function is unable to immediately map the queue to the port, it will
238 * add the requested operation to a per-port list of pending map/unmap
239 * operations, and (if it's not already running) launch a kernel thread that
240 * periodically attempts to process all pending operations. In a sense, this is
241 * an asynchronous function.
243 * This asynchronicity creates two views of the state of hardware: the actual
244 * hardware state and the requested state (as if every request completed
245 * immediately). If there are any pending map/unmap operations, the requested
246 * state will differ from the actual state. All validation is performed with
247 * respect to the pending state; for instance, if there are 8 pending map
248 * operations for port X, a request for a 9th will fail because a load-balanced
249 * port can only map up to 8 queues.
251 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
255 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
256 * assigned a detailed error code from enum dlb2_error.
259 * EINVAL - A requested resource is unavailable, invalid port or queue ID, or
260 * the domain is not configured.
261 * EFAULT - Internal error (resp->status not set).
263 int dlb2_hw_map_qid(struct dlb2_hw *hw,
265 struct dlb2_map_qid_args *args,
266 struct dlb2_cmd_response *resp,
268 unsigned int vdev_id);
271 * dlb2_hw_unmap_qid() - Unmap a load-balanced queue from a load-balanced port
272 * @hw: dlb2_hw handle for a particular device.
273 * @domain_id: domain ID.
274 * @args: unmap QID arguments.
275 * @resp: response structure.
276 * @vdev_request: indicates whether this request came from a vdev.
277 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
279 * This function configures the DLB to stop scheduling QEs from the specified
280 * queue to the specified port.
282 * A successful return does not necessarily mean the mapping was removed. If
283 * this function is unable to immediately unmap the queue from the port, it
284 * will add the requested operation to a per-port list of pending map/unmap
285 * operations, and (if it's not already running) launch a kernel thread that
286 * periodically attempts to process all pending operations. See
287 * dlb2_hw_map_qid() for more details.
289 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
293 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
294 * assigned a detailed error code from enum dlb2_error.
297 * EINVAL - A requested resource is unavailable, invalid port or queue ID, or
298 * the domain is not configured.
299 * EFAULT - Internal error (resp->status not set).
301 int dlb2_hw_unmap_qid(struct dlb2_hw *hw,
303 struct dlb2_unmap_qid_args *args,
304 struct dlb2_cmd_response *resp,
306 unsigned int vdev_id);
309 * dlb2_finish_unmap_qid_procedures() - finish any pending unmap procedures
310 * @hw: dlb2_hw handle for a particular device.
312 * This function attempts to finish any outstanding unmap procedures.
313 * This function should be called by the kernel thread responsible for
314 * finishing map/unmap procedures.
317 * Returns the number of procedures that weren't completed.
319 unsigned int dlb2_finish_unmap_qid_procedures(struct dlb2_hw *hw);
322 * dlb2_finish_map_qid_procedures() - finish any pending map procedures
323 * @hw: dlb2_hw handle for a particular device.
325 * This function attempts to finish any outstanding map procedures.
326 * This function should be called by the kernel thread responsible for
327 * finishing map/unmap procedures.
330 * Returns the number of procedures that weren't completed.
332 unsigned int dlb2_finish_map_qid_procedures(struct dlb2_hw *hw);
335 * dlb2_hw_enable_ldb_port() - enable a load-balanced port for scheduling
336 * @hw: dlb2_hw handle for a particular device.
337 * @domain_id: domain ID.
338 * @args: port enable arguments.
339 * @resp: response structure.
340 * @vdev_request: indicates whether this request came from a vdev.
341 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
343 * This function configures the DLB to schedule QEs to a load-balanced port.
344 * Ports are enabled by default.
346 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
350 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
351 * assigned a detailed error code from enum dlb2_error.
354 * EINVAL - The port ID is invalid or the domain is not configured.
355 * EFAULT - Internal error (resp->status not set).
357 int dlb2_hw_enable_ldb_port(struct dlb2_hw *hw,
359 struct dlb2_enable_ldb_port_args *args,
360 struct dlb2_cmd_response *resp,
362 unsigned int vdev_id);
365 * dlb2_hw_disable_ldb_port() - disable a load-balanced port for scheduling
366 * @hw: dlb2_hw handle for a particular device.
367 * @domain_id: domain ID.
368 * @args: port disable arguments.
369 * @resp: response structure.
370 * @vdev_request: indicates whether this request came from a vdev.
371 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
373 * This function configures the DLB to stop scheduling QEs to a load-balanced
374 * port. Ports are enabled by default.
376 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
380 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
381 * assigned a detailed error code from enum dlb2_error.
384 * EINVAL - The port ID is invalid or the domain is not configured.
385 * EFAULT - Internal error (resp->status not set).
387 int dlb2_hw_disable_ldb_port(struct dlb2_hw *hw,
389 struct dlb2_disable_ldb_port_args *args,
390 struct dlb2_cmd_response *resp,
392 unsigned int vdev_id);
395 * dlb2_hw_enable_dir_port() - enable a directed port for scheduling
396 * @hw: dlb2_hw handle for a particular device.
397 * @domain_id: domain ID.
398 * @args: port enable arguments.
399 * @resp: response structure.
400 * @vdev_request: indicates whether this request came from a vdev.
401 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
403 * This function configures the DLB to schedule QEs to a directed port.
404 * Ports are enabled by default.
406 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
410 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
411 * assigned a detailed error code from enum dlb2_error.
414 * EINVAL - The port ID is invalid or the domain is not configured.
415 * EFAULT - Internal error (resp->status not set).
417 int dlb2_hw_enable_dir_port(struct dlb2_hw *hw,
419 struct dlb2_enable_dir_port_args *args,
420 struct dlb2_cmd_response *resp,
422 unsigned int vdev_id);
425 * dlb2_hw_disable_dir_port() - disable a directed port for scheduling
426 * @hw: dlb2_hw handle for a particular device.
427 * @domain_id: domain ID.
428 * @args: port disable arguments.
429 * @resp: response structure.
430 * @vdev_request: indicates whether this request came from a vdev.
431 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
433 * This function configures the DLB to stop scheduling QEs to a directed port.
434 * Ports are enabled by default.
436 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
440 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
441 * assigned a detailed error code from enum dlb2_error.
444 * EINVAL - The port ID is invalid or the domain is not configured.
445 * EFAULT - Internal error (resp->status not set).
447 int dlb2_hw_disable_dir_port(struct dlb2_hw *hw,
449 struct dlb2_disable_dir_port_args *args,
450 struct dlb2_cmd_response *resp,
452 unsigned int vdev_id);
455 * dlb2_configure_ldb_cq_interrupt() - configure load-balanced CQ for
457 * @hw: dlb2_hw handle for a particular device.
458 * @port_id: load-balanced port ID.
459 * @vector: interrupt vector ID. Should be 0 for MSI or compressed MSI-X mode,
460 * else a value up to 64.
461 * @mode: interrupt type (DLB2_CQ_ISR_MODE_MSI or DLB2_CQ_ISR_MODE_MSIX)
462 * @vf: If the port is VF-owned, the VF's ID. This is used for translating the
463 * virtual port ID to a physical port ID. Ignored if mode is not MSI.
464 * @owner_vf: the VF to route the interrupt to. Ignore if mode is not MSI.
465 * @threshold: the minimum CQ depth at which the interrupt can fire. Must be
468 * This function configures the DLB registers for load-balanced CQ's
469 * interrupts. This doesn't enable the CQ's interrupt; that can be done with
470 * dlb2_arm_cq_interrupt() or through an interrupt arm QE.
473 * Returns 0 upon success, < 0 otherwise.
476 * EINVAL - The port ID is invalid.
478 int dlb2_configure_ldb_cq_interrupt(struct dlb2_hw *hw,
483 unsigned int owner_vf,
487 * dlb2_configure_dir_cq_interrupt() - configure directed CQ for interrupts
488 * @hw: dlb2_hw handle for a particular device.
489 * @port_id: load-balanced port ID.
490 * @vector: interrupt vector ID. Should be 0 for MSI or compressed MSI-X mode,
491 * else a value up to 64.
492 * @mode: interrupt type (DLB2_CQ_ISR_MODE_MSI or DLB2_CQ_ISR_MODE_MSIX)
493 * @vf: If the port is VF-owned, the VF's ID. This is used for translating the
494 * virtual port ID to a physical port ID. Ignored if mode is not MSI.
495 * @owner_vf: the VF to route the interrupt to. Ignore if mode is not MSI.
496 * @threshold: the minimum CQ depth at which the interrupt can fire. Must be
499 * This function configures the DLB registers for directed CQ's interrupts.
500 * This doesn't enable the CQ's interrupt; that can be done with
501 * dlb2_arm_cq_interrupt() or through an interrupt arm QE.
504 * Returns 0 upon success, < 0 otherwise.
507 * EINVAL - The port ID is invalid.
509 int dlb2_configure_dir_cq_interrupt(struct dlb2_hw *hw,
514 unsigned int owner_vf,
518 * dlb2_enable_ingress_error_alarms() - enable ingress error alarm interrupts
519 * @hw: dlb2_hw handle for a particular device.
521 void dlb2_enable_ingress_error_alarms(struct dlb2_hw *hw);
524 * dlb2_disable_ingress_error_alarms() - disable ingress error alarm interrupts
525 * @hw: dlb2_hw handle for a particular device.
527 void dlb2_disable_ingress_error_alarms(struct dlb2_hw *hw);
530 * dlb2_set_msix_mode() - enable certain hardware alarm interrupts
531 * @hw: dlb2_hw handle for a particular device.
532 * @mode: MSI-X mode (DLB2_MSIX_MODE_PACKED or DLB2_MSIX_MODE_COMPRESSED)
534 * This function configures the hardware to use either packed or compressed
535 * mode. This function should not be called if using MSI interrupts.
537 void dlb2_set_msix_mode(struct dlb2_hw *hw, int mode);
540 * dlb2_ack_msix_interrupt() - Ack an MSI-X interrupt
541 * @hw: dlb2_hw handle for a particular device.
542 * @vector: interrupt vector.
544 * Note: Only needed for PF service interrupts (vector 0). CQ interrupts are
545 * acked in dlb2_ack_compressed_cq_intr().
547 void dlb2_ack_msix_interrupt(struct dlb2_hw *hw, int vector);
550 * dlb2_arm_cq_interrupt() - arm a CQ's interrupt
551 * @hw: dlb2_hw handle for a particular device.
553 * @is_ldb: true for load-balanced port, false for a directed port
554 * @vdev_request: indicates whether this request came from a vdev.
555 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
557 * This function arms the CQ's interrupt. The CQ must be configured prior to
558 * calling this function.
560 * The function does no parameter validation; that is the caller's
563 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
566 * Return: returns 0 upon success, <0 otherwise.
568 * EINVAL - Invalid port ID.
570 int dlb2_arm_cq_interrupt(struct dlb2_hw *hw,
574 unsigned int vdev_id);
577 * dlb2_read_compressed_cq_intr_status() - read compressed CQ interrupt status
578 * @hw: dlb2_hw handle for a particular device.
579 * @ldb_interrupts: 2-entry array of u32 bitmaps
580 * @dir_interrupts: 4-entry array of u32 bitmaps
582 * This function can be called from a compressed CQ interrupt handler to
583 * determine which CQ interrupts have fired. The caller should take appropriate
584 * (such as waking threads blocked on a CQ's interrupt) then ack the interrupts
585 * with dlb2_ack_compressed_cq_intr().
587 void dlb2_read_compressed_cq_intr_status(struct dlb2_hw *hw,
589 u32 *dir_interrupts);
592 * dlb2_ack_compressed_cq_intr_status() - ack compressed CQ interrupts
593 * @hw: dlb2_hw handle for a particular device.
594 * @ldb_interrupts: 2-entry array of u32 bitmaps
595 * @dir_interrupts: 4-entry array of u32 bitmaps
597 * This function ACKs compressed CQ interrupts. Its arguments should be the
598 * same ones passed to dlb2_read_compressed_cq_intr_status().
600 void dlb2_ack_compressed_cq_intr(struct dlb2_hw *hw,
602 u32 *dir_interrupts);
605 * dlb2_read_vf_intr_status() - read the VF interrupt status register
606 * @hw: dlb2_hw handle for a particular device.
608 * This function can be called from a VF's interrupt handler to determine
609 * which interrupts have fired. The first 31 bits correspond to CQ interrupt
610 * vectors, and the final bit is for the PF->VF mailbox interrupt vector.
613 * Returns a bit vector indicating which interrupt vectors are active.
615 u32 dlb2_read_vf_intr_status(struct dlb2_hw *hw);
618 * dlb2_ack_vf_intr_status() - ack VF interrupts
619 * @hw: dlb2_hw handle for a particular device.
620 * @interrupts: 32-bit bitmap
622 * This function ACKs a VF's interrupts. Its interrupts argument should be the
623 * value returned by dlb2_read_vf_intr_status().
625 void dlb2_ack_vf_intr_status(struct dlb2_hw *hw, u32 interrupts);
628 * dlb2_ack_vf_msi_intr() - ack VF MSI interrupt
629 * @hw: dlb2_hw handle for a particular device.
630 * @interrupts: 32-bit bitmap
632 * This function clears the VF's MSI interrupt pending register. Its interrupts
633 * argument should be contain the MSI vectors to ACK. For example, if MSI MME
634 * is in mode 0, then one bit 0 should ever be set.
636 void dlb2_ack_vf_msi_intr(struct dlb2_hw *hw, u32 interrupts);
639 * dlb2_ack_pf_mbox_int() - ack PF->VF mailbox interrupt
640 * @hw: dlb2_hw handle for a particular device.
642 * When done processing the PF mailbox request, this function unsets
643 * the PF's mailbox ISR register.
645 void dlb2_ack_pf_mbox_int(struct dlb2_hw *hw);
648 * dlb2_read_vdev_to_pf_int_bitvec() - return a bit vector of all requesting
650 * @hw: dlb2_hw handle for a particular device.
652 * When the vdev->PF ISR fires, this function can be called to determine which
653 * vdev(s) are requesting service. This bitvector must be passed to
654 * dlb2_ack_vdev_to_pf_int() when processing is complete for all requesting
657 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
661 * Returns a bit vector indicating which VFs (0-15) have requested service.
663 u32 dlb2_read_vdev_to_pf_int_bitvec(struct dlb2_hw *hw);
666 * dlb2_ack_vdev_mbox_int() - ack processed vdev->PF mailbox interrupt
667 * @hw: dlb2_hw handle for a particular device.
668 * @bitvec: bit vector returned by dlb2_read_vdev_to_pf_int_bitvec()
670 * When done processing all VF mailbox requests, this function unsets the VF's
671 * mailbox ISR register.
673 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
676 void dlb2_ack_vdev_mbox_int(struct dlb2_hw *hw, u32 bitvec);
679 * dlb2_read_vf_flr_int_bitvec() - return a bit vector of all VFs requesting
681 * @hw: dlb2_hw handle for a particular device.
683 * When the VF FLR ISR fires, this function can be called to determine which
684 * VF(s) are requesting FLRs. This bitvector must passed to
685 * dlb2_ack_vf_flr_int() when processing is complete for all requesting VFs.
688 * Returns a bit vector indicating which VFs (0-15) have requested FLRs.
690 u32 dlb2_read_vf_flr_int_bitvec(struct dlb2_hw *hw);
693 * dlb2_ack_vf_flr_int() - ack processed VF<->PF interrupt(s)
694 * @hw: dlb2_hw handle for a particular device.
695 * @bitvec: bit vector returned by dlb2_read_vf_flr_int_bitvec()
697 * When done processing all VF FLR requests, this function unsets the VF's FLR
700 void dlb2_ack_vf_flr_int(struct dlb2_hw *hw, u32 bitvec);
703 * dlb2_ack_vdev_to_pf_int() - ack processed VF mbox and FLR interrupt(s)
704 * @hw: dlb2_hw handle for a particular device.
705 * @mbox_bitvec: bit vector returned by dlb2_read_vdev_to_pf_int_bitvec()
706 * @flr_bitvec: bit vector returned by dlb2_read_vf_flr_int_bitvec()
708 * When done processing all VF requests, this function communicates to the
709 * hardware that processing is complete.
711 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
714 void dlb2_ack_vdev_to_pf_int(struct dlb2_hw *hw,
719 * dlb2_process_wdt_interrupt() - process watchdog timer interrupts
720 * @hw: dlb2_hw handle for a particular device.
722 * This function reads the watchdog timer interrupt cause registers to
723 * determine which port(s) had a watchdog timeout, and notifies the
724 * application(s) that own the port(s).
726 void dlb2_process_wdt_interrupt(struct dlb2_hw *hw);
729 * dlb2_process_alarm_interrupt() - process an alarm interrupt
730 * @hw: dlb2_hw handle for a particular device.
732 * This function reads and logs the alarm syndrome, then acks the interrupt.
733 * This function should be called from the alarm interrupt handler when
734 * interrupt vector DLB2_INT_ALARM fires.
736 void dlb2_process_alarm_interrupt(struct dlb2_hw *hw);
739 * dlb2_process_ingress_error_interrupt() - process ingress error interrupts
740 * @hw: dlb2_hw handle for a particular device.
742 * This function reads the alarm syndrome, logs it, notifies user-space, and
743 * acks the interrupt. This function should be called from the alarm interrupt
744 * handler when interrupt vector DLB2_INT_INGRESS_ERROR fires.
747 * Returns true if an ingress error interrupt occurred, false otherwise
749 bool dlb2_process_ingress_error_interrupt(struct dlb2_hw *hw);
752 * dlb2_get_group_sequence_numbers() - return a group's number of SNs per queue
753 * @hw: dlb2_hw handle for a particular device.
754 * @group_id: sequence number group ID.
756 * This function returns the configured number of sequence numbers per queue
757 * for the specified group.
760 * Returns -EINVAL if group_id is invalid, else the group's SNs per queue.
762 int dlb2_get_group_sequence_numbers(struct dlb2_hw *hw,
763 unsigned int group_id);
766 * dlb2_get_group_sequence_number_occupancy() - return a group's in-use slots
767 * @hw: dlb2_hw handle for a particular device.
768 * @group_id: sequence number group ID.
770 * This function returns the group's number of in-use slots (i.e. load-balanced
771 * queues using the specified group).
774 * Returns -EINVAL if group_id is invalid, else the group's SNs per queue.
776 int dlb2_get_group_sequence_number_occupancy(struct dlb2_hw *hw,
777 unsigned int group_id);
780 * dlb2_set_group_sequence_numbers() - assign a group's number of SNs per queue
781 * @hw: dlb2_hw handle for a particular device.
782 * @group_id: sequence number group ID.
783 * @val: requested amount of sequence numbers per queue.
785 * This function configures the group's number of sequence numbers per queue.
786 * val can be a power-of-two between 32 and 1024, inclusive. This setting can
787 * be configured until the first ordered load-balanced queue is configured, at
788 * which point the configuration is locked.
791 * Returns 0 upon success; -EINVAL if group_id or val is invalid, -EPERM if an
792 * ordered queue is configured.
794 int dlb2_set_group_sequence_numbers(struct dlb2_hw *hw,
795 unsigned int group_id,
799 * dlb2_reset_domain() - reset a scheduling domain
800 * @hw: dlb2_hw handle for a particular device.
801 * @domain_id: domain ID.
802 * @vdev_request: indicates whether this request came from a vdev.
803 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
805 * This function resets and frees a DLB 2.0 scheduling domain and its associated
808 * Pre-condition: the driver must ensure software has stopped sending QEs
809 * through this domain's producer ports before invoking this function, or
810 * undefined behavior will result.
812 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
816 * Returns 0 upon success, -1 otherwise.
818 * EINVAL - Invalid domain ID, or the domain is not configured.
819 * EFAULT - Internal error. (Possibly caused if software is the pre-condition
821 * ETIMEDOUT - Hardware component didn't reset in the expected time.
823 int dlb2_reset_domain(struct dlb2_hw *hw,
826 unsigned int vdev_id);
829 * dlb2_ldb_port_owned_by_domain() - query whether a port is owned by a domain
830 * @hw: dlb2_hw handle for a particular device.
831 * @domain_id: domain ID.
832 * @port_id: indicates whether this request came from a VF.
833 * @vdev_request: indicates whether this request came from a vdev.
834 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
836 * This function returns whether a load-balanced port is owned by a specified
839 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
843 * Returns 0 if false, 1 if true, <0 otherwise.
845 * EINVAL - Invalid domain or port ID, or the domain is not configured.
847 int dlb2_ldb_port_owned_by_domain(struct dlb2_hw *hw,
851 unsigned int vdev_id);
854 * dlb2_dir_port_owned_by_domain() - query whether a port is owned by a domain
855 * @hw: dlb2_hw handle for a particular device.
856 * @domain_id: domain ID.
857 * @port_id: indicates whether this request came from a VF.
858 * @vdev_request: indicates whether this request came from a vdev.
859 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
861 * This function returns whether a directed port is owned by a specified
864 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
868 * Returns 0 if false, 1 if true, <0 otherwise.
870 * EINVAL - Invalid domain or port ID, or the domain is not configured.
872 int dlb2_dir_port_owned_by_domain(struct dlb2_hw *hw,
876 unsigned int vdev_id);
879 * dlb2_hw_get_num_resources() - query the PCI function's available resources
880 * @hw: dlb2_hw handle for a particular device.
881 * @arg: pointer to resource counts.
882 * @vdev_request: indicates whether this request came from a vdev.
883 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
885 * This function returns the number of available resources for the PF or for a
888 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
892 * Returns 0 upon success, -EINVAL if vdev_request is true and vdev_id is
895 int dlb2_hw_get_num_resources(struct dlb2_hw *hw,
896 struct dlb2_get_num_resources_args *arg,
898 unsigned int vdev_id);
901 * dlb2_hw_get_num_used_resources() - query the PCI function's used resources
902 * @hw: dlb2_hw handle for a particular device.
903 * @arg: pointer to resource counts.
904 * @vdev_request: indicates whether this request came from a vdev.
905 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
907 * This function returns the number of resources in use by the PF or a VF. It
908 * fills in the fields that args points to, except the following:
909 * - max_contiguous_atomic_inflights
910 * - max_contiguous_hist_list_entries
911 * - max_contiguous_ldb_credits
912 * - max_contiguous_dir_credits
914 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
918 * Returns 0 upon success, -EINVAL if vdev_request is true and vdev_id is
921 int dlb2_hw_get_num_used_resources(struct dlb2_hw *hw,
922 struct dlb2_get_num_resources_args *arg,
924 unsigned int vdev_id);
927 * dlb2_send_async_vdev_to_pf_msg() - (vdev only) send a mailbox message to
929 * @hw: dlb2_hw handle for a particular device.
931 * This function sends a VF->PF mailbox message. It is asynchronous, so it
932 * returns once the message is sent but potentially before the PF has processed
933 * the message. The caller must call dlb2_vdev_to_pf_complete() to determine
934 * when the PF has finished processing the request.
936 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
939 void dlb2_send_async_vdev_to_pf_msg(struct dlb2_hw *hw);
942 * dlb2_vdev_to_pf_complete() - check the status of an asynchronous mailbox
944 * @hw: dlb2_hw handle for a particular device.
946 * This function returns a boolean indicating whether the PF has finished
947 * processing a VF->PF mailbox request. It should only be called after sending
948 * an asynchronous request with dlb2_send_async_vdev_to_pf_msg().
950 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
953 bool dlb2_vdev_to_pf_complete(struct dlb2_hw *hw);
956 * dlb2_vf_flr_complete() - check the status of a VF FLR
957 * @hw: dlb2_hw handle for a particular device.
959 * This function returns a boolean indicating whether the PF has finished
960 * executing the VF FLR. It should only be called after setting the VF's FLR
963 bool dlb2_vf_flr_complete(struct dlb2_hw *hw);
966 * dlb2_send_async_pf_to_vdev_msg() - (PF only) send a mailbox message to a
968 * @hw: dlb2_hw handle for a particular device.
971 * This function sends a PF->vdev mailbox message. It is asynchronous, so it
972 * returns once the message is sent but potentially before the vdev has
973 * processed the message. The caller must call dlb2_pf_to_vdev_complete() to
974 * determine when the vdev has finished processing the request.
976 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
979 void dlb2_send_async_pf_to_vdev_msg(struct dlb2_hw *hw, unsigned int vdev_id);
982 * dlb2_pf_to_vdev_complete() - check the status of an asynchronous mailbox
984 * @hw: dlb2_hw handle for a particular device.
987 * This function returns a boolean indicating whether the vdev has finished
988 * processing a PF->vdev mailbox request. It should only be called after
989 * sending an asynchronous request with dlb2_send_async_pf_to_vdev_msg().
991 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
994 bool dlb2_pf_to_vdev_complete(struct dlb2_hw *hw, unsigned int vdev_id);
997 * dlb2_pf_read_vf_mbox_req() - (PF only) read a VF->PF mailbox request
998 * @hw: dlb2_hw handle for a particular device.
1000 * @data: pointer to message data.
1001 * @len: size, in bytes, of the data array.
1003 * This function copies one of the PF's VF->PF mailboxes into the array pointed
1007 * Returns 0 upon success, <0 otherwise.
1009 * EINVAL - len >= DLB2_VF2PF_REQ_BYTES.
1011 int dlb2_pf_read_vf_mbox_req(struct dlb2_hw *hw,
1017 * dlb2_pf_read_vf_mbox_resp() - (PF only) read a VF->PF mailbox response
1018 * @hw: dlb2_hw handle for a particular device.
1020 * @data: pointer to message data.
1021 * @len: size, in bytes, of the data array.
1023 * This function copies one of the PF's VF->PF mailboxes into the array pointed
1027 * Returns 0 upon success, <0 otherwise.
1029 * EINVAL - len >= DLB2_VF2PF_RESP_BYTES.
1031 int dlb2_pf_read_vf_mbox_resp(struct dlb2_hw *hw,
1037 * dlb2_pf_write_vf_mbox_resp() - (PF only) write a PF->VF mailbox response
1038 * @hw: dlb2_hw handle for a particular device.
1040 * @data: pointer to message data.
1041 * @len: size, in bytes, of the data array.
1043 * This function copies the user-provided message data into of the PF's VF->PF
1047 * Returns 0 upon success, <0 otherwise.
1049 * EINVAL - len >= DLB2_PF2VF_RESP_BYTES.
1051 int dlb2_pf_write_vf_mbox_resp(struct dlb2_hw *hw,
1057 * dlb2_pf_write_vf_mbox_req() - (PF only) write a PF->VF mailbox request
1058 * @hw: dlb2_hw handle for a particular device.
1060 * @data: pointer to message data.
1061 * @len: size, in bytes, of the data array.
1063 * This function copies the user-provided message data into of the PF's VF->PF
1067 * Returns 0 upon success, <0 otherwise.
1069 * EINVAL - len >= DLB2_PF2VF_REQ_BYTES.
1071 int dlb2_pf_write_vf_mbox_req(struct dlb2_hw *hw,
1077 * dlb2_vf_read_pf_mbox_resp() - (VF only) read a PF->VF mailbox response
1078 * @hw: dlb2_hw handle for a particular device.
1079 * @data: pointer to message data.
1080 * @len: size, in bytes, of the data array.
1082 * This function copies the VF's PF->VF mailbox into the array pointed to by
1086 * Returns 0 upon success, <0 otherwise.
1088 * EINVAL - len >= DLB2_PF2VF_RESP_BYTES.
1090 int dlb2_vf_read_pf_mbox_resp(struct dlb2_hw *hw, void *data, int len);
1093 * dlb2_vf_read_pf_mbox_req() - (VF only) read a PF->VF mailbox request
1094 * @hw: dlb2_hw handle for a particular device.
1095 * @data: pointer to message data.
1096 * @len: size, in bytes, of the data array.
1098 * This function copies the VF's PF->VF mailbox into the array pointed to by
1102 * Returns 0 upon success, <0 otherwise.
1104 * EINVAL - len >= DLB2_PF2VF_REQ_BYTES.
1106 int dlb2_vf_read_pf_mbox_req(struct dlb2_hw *hw, void *data, int len);
1109 * dlb2_vf_write_pf_mbox_req() - (VF only) write a VF->PF mailbox request
1110 * @hw: dlb2_hw handle for a particular device.
1111 * @data: pointer to message data.
1112 * @len: size, in bytes, of the data array.
1114 * This function copies the user-provided message data into of the VF's PF->VF
1118 * Returns 0 upon success, <0 otherwise.
1120 * EINVAL - len >= DLB2_VF2PF_REQ_BYTES.
1122 int dlb2_vf_write_pf_mbox_req(struct dlb2_hw *hw, void *data, int len);
1125 * dlb2_vf_write_pf_mbox_resp() - (VF only) write a VF->PF mailbox response
1126 * @hw: dlb2_hw handle for a particular device.
1127 * @data: pointer to message data.
1128 * @len: size, in bytes, of the data array.
1130 * This function copies the user-provided message data into of the VF's PF->VF
1134 * Returns 0 upon success, <0 otherwise.
1136 * EINVAL - len >= DLB2_VF2PF_RESP_BYTES.
1138 int dlb2_vf_write_pf_mbox_resp(struct dlb2_hw *hw, void *data, int len);
1141 * dlb2_reset_vdev() - reset the hardware owned by a virtual device
1142 * @hw: dlb2_hw handle for a particular device.
1143 * @id: virtual device ID
1145 * This function resets the hardware owned by a vdev, by resetting the vdev's
1146 * domains one by one.
1148 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1151 int dlb2_reset_vdev(struct dlb2_hw *hw, unsigned int id);
1154 * dlb2_vdev_is_locked() - check whether the vdev's resources are locked
1155 * @hw: dlb2_hw handle for a particular device.
1156 * @id: virtual device ID
1158 * This function returns whether or not the vdev's resource assignments are
1159 * locked. If locked, no resources can be added to or subtracted from the
1162 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1165 bool dlb2_vdev_is_locked(struct dlb2_hw *hw, unsigned int id);
1168 * dlb2_lock_vdev() - lock the vdev's resources
1169 * @hw: dlb2_hw handle for a particular device.
1170 * @id: virtual device ID
1172 * This function sets a flag indicating that the vdev is using its resources.
1173 * When the vdev is locked, its resource assignment cannot be changed.
1175 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1178 void dlb2_lock_vdev(struct dlb2_hw *hw, unsigned int id);
1181 * dlb2_unlock_vdev() - unlock the vdev's resources
1182 * @hw: dlb2_hw handle for a particular device.
1183 * @id: virtual device ID
1185 * This function unlocks the vdev's resource assignment, allowing it to be
1188 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1191 void dlb2_unlock_vdev(struct dlb2_hw *hw, unsigned int id);
1194 * dlb2_update_vdev_sched_domains() - update the domains assigned to a vdev
1195 * @hw: dlb2_hw handle for a particular device.
1196 * @id: virtual device ID
1197 * @num: number of scheduling domains to assign to this vdev
1199 * This function assigns num scheduling domains to the specified vdev. If the
1200 * vdev already has domains assigned, this existing assignment is adjusted
1203 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1207 * Returns 0 upon success, <0 otherwise.
1210 * EINVAL - id is invalid, or the requested number of resources are
1212 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1214 int dlb2_update_vdev_sched_domains(struct dlb2_hw *hw, u32 id, u32 num);
1217 * dlb2_update_vdev_ldb_queues() - update the LDB queues assigned to a vdev
1218 * @hw: dlb2_hw handle for a particular device.
1219 * @id: virtual device ID
1220 * @num: number of LDB queues to assign to this vdev
1222 * This function assigns num LDB queues to the specified vdev. If the vdev
1223 * already has LDB queues assigned, this existing assignment is adjusted
1226 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1230 * Returns 0 upon success, <0 otherwise.
1233 * EINVAL - id is invalid, or the requested number of resources are
1235 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1237 int dlb2_update_vdev_ldb_queues(struct dlb2_hw *hw, u32 id, u32 num);
1240 * dlb2_update_vdev_ldb_ports() - update the LDB ports assigned to a vdev
1241 * @hw: dlb2_hw handle for a particular device.
1242 * @id: virtual device ID
1243 * @num: number of LDB ports to assign to this vdev
1245 * This function assigns num LDB ports to the specified vdev. If the vdev
1246 * already has LDB ports assigned, this existing assignment is adjusted
1249 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1253 * Returns 0 upon success, <0 otherwise.
1256 * EINVAL - id is invalid, or the requested number of resources are
1258 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1260 int dlb2_update_vdev_ldb_ports(struct dlb2_hw *hw, u32 id, u32 num);
1263 * dlb2_update_vdev_ldb_cos_ports() - update the LDB ports assigned to a vdev
1264 * @hw: dlb2_hw handle for a particular device.
1265 * @id: virtual device ID
1266 * @cos: class-of-service ID
1267 * @num: number of LDB ports to assign to this vdev
1269 * This function assigns num LDB ports from class-of-service cos to the
1270 * specified vdev. If the vdev already has LDB ports from this class-of-service
1271 * assigned, this existing assignment is adjusted accordingly.
1273 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1277 * Returns 0 upon success, <0 otherwise.
1280 * EINVAL - id is invalid, or the requested number of resources are
1282 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1284 int dlb2_update_vdev_ldb_cos_ports(struct dlb2_hw *hw,
1290 * dlb2_update_vdev_dir_ports() - update the DIR ports assigned to a vdev
1291 * @hw: dlb2_hw handle for a particular device.
1292 * @id: virtual device ID
1293 * @num: number of DIR ports to assign to this vdev
1295 * This function assigns num DIR ports to the specified vdev. If the vdev
1296 * already has DIR ports assigned, this existing assignment is adjusted
1299 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1303 * Returns 0 upon success, <0 otherwise.
1306 * EINVAL - id is invalid, or the requested number of resources are
1308 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1310 int dlb2_update_vdev_dir_ports(struct dlb2_hw *hw, u32 id, u32 num);
1313 * dlb2_update_vdev_ldb_credits() - update the vdev's assigned LDB credits
1314 * @hw: dlb2_hw handle for a particular device.
1315 * @id: virtual device ID
1316 * @num: number of LDB credit credits to assign to this vdev
1318 * This function assigns num LDB credit to the specified vdev. If the vdev
1319 * already has LDB credits assigned, this existing assignment is adjusted
1320 * accordingly. vdevs are assigned a contiguous chunk of credits, so this
1321 * function may fail if a sufficiently large contiguous chunk is not available.
1323 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1327 * Returns 0 upon success, <0 otherwise.
1330 * EINVAL - id is invalid, or the requested number of resources are
1332 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1334 int dlb2_update_vdev_ldb_credits(struct dlb2_hw *hw, u32 id, u32 num);
1337 * dlb2_update_vdev_dir_credits() - update the vdev's assigned DIR credits
1338 * @hw: dlb2_hw handle for a particular device.
1339 * @id: virtual device ID
1340 * @num: number of DIR credits to assign to this vdev
1342 * This function assigns num DIR credit to the specified vdev. If the vdev
1343 * already has DIR credits assigned, this existing assignment is adjusted
1344 * accordingly. vdevs are assigned a contiguous chunk of credits, so this
1345 * function may fail if a sufficiently large contiguous chunk is not available.
1347 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1351 * Returns 0 upon success, <0 otherwise.
1354 * EINVAL - id is invalid, or the requested number of resources are
1356 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1358 int dlb2_update_vdev_dir_credits(struct dlb2_hw *hw, u32 id, u32 num);
1361 * dlb2_update_vdev_hist_list_entries() - update the vdev's assigned HL entries
1362 * @hw: dlb2_hw handle for a particular device.
1363 * @id: virtual device ID
1364 * @num: number of history list entries to assign to this vdev
1366 * This function assigns num history list entries to the specified vdev. If the
1367 * vdev already has history list entries assigned, this existing assignment is
1368 * adjusted accordingly. vdevs are assigned a contiguous chunk of entries, so
1369 * this function may fail if a sufficiently large contiguous chunk is not
1372 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1376 * Returns 0 upon success, <0 otherwise.
1379 * EINVAL - id is invalid, or the requested number of resources are
1381 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1383 int dlb2_update_vdev_hist_list_entries(struct dlb2_hw *hw, u32 id, u32 num);
1386 * dlb2_update_vdev_atomic_inflights() - update the vdev's atomic inflights
1387 * @hw: dlb2_hw handle for a particular device.
1388 * @id: virtual device ID
1389 * @num: number of atomic inflights to assign to this vdev
1391 * This function assigns num atomic inflights to the specified vdev. If the vdev
1392 * already has atomic inflights assigned, this existing assignment is adjusted
1393 * accordingly. vdevs are assigned a contiguous chunk of entries, so this
1394 * function may fail if a sufficiently large contiguous chunk is not available.
1396 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1400 * Returns 0 upon success, <0 otherwise.
1403 * EINVAL - id is invalid, or the requested number of resources are
1405 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1407 int dlb2_update_vdev_atomic_inflights(struct dlb2_hw *hw, u32 id, u32 num);
1410 * dlb2_reset_vdev_resources() - reassign the vdev's resources to the PF
1411 * @hw: dlb2_hw handle for a particular device.
1412 * @id: virtual device ID
1414 * This function takes any resources currently assigned to the vdev and
1415 * reassigns them to the PF.
1417 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1421 * Returns 0 upon success, <0 otherwise.
1424 * EINVAL - id is invalid
1425 * EPERM - The vdev's resource assignment is locked and cannot be changed.
1427 int dlb2_reset_vdev_resources(struct dlb2_hw *hw, unsigned int id);
1430 * dlb2_notify_vf() - send an alarm to a VF
1431 * @hw: dlb2_hw handle for a particular device.
1433 * @notification: notification
1435 * This function sends a notification (as defined in dlb2_mbox.h) to a VF.
1438 * Returns 0 upon success, <0 if the VF doesn't ACK the PF->VF interrupt.
1440 int dlb2_notify_vf(struct dlb2_hw *hw,
1445 * dlb2_vdev_in_use() - query whether a virtual device is in use
1446 * @hw: dlb2_hw handle for a particular device.
1447 * @id: virtual device ID
1449 * This function sends a mailbox request to the vdev to query whether the vdev
1452 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1456 * Returns 0 for false, 1 for true, and <0 if the mailbox request times out or
1457 * an internal error occurs.
1459 int dlb2_vdev_in_use(struct dlb2_hw *hw, unsigned int id);
1462 * dlb2_hw_get_ldb_queue_depth() - returns the depth of a load-balanced queue
1463 * @hw: dlb2_hw handle for a particular device.
1464 * @domain_id: domain ID.
1465 * @args: queue depth args
1466 * @resp: response structure.
1467 * @vdev_request: indicates whether this request came from a vdev.
1468 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
1470 * This function returns the depth of a load-balanced queue.
1472 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1476 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
1477 * assigned a detailed error code from enum dlb2_error. If successful, resp->id
1478 * contains the depth.
1481 * EINVAL - Invalid domain ID or queue ID.
1483 int dlb2_hw_get_ldb_queue_depth(struct dlb2_hw *hw,
1485 struct dlb2_get_ldb_queue_depth_args *args,
1486 struct dlb2_cmd_response *resp,
1488 unsigned int vdev_id);
1491 * dlb2_hw_get_dir_queue_depth() - returns the depth of a directed queue
1492 * @hw: dlb2_hw handle for a particular device.
1493 * @domain_id: domain ID.
1494 * @args: queue depth args
1495 * @resp: response structure.
1496 * @vdev_request: indicates whether this request came from a vdev.
1497 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
1499 * This function returns the depth of a directed queue.
1501 * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1505 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
1506 * assigned a detailed error code from enum dlb2_error. If successful, resp->id
1507 * contains the depth.
1510 * EINVAL - Invalid domain ID or queue ID.
1512 int dlb2_hw_get_dir_queue_depth(struct dlb2_hw *hw,
1514 struct dlb2_get_dir_queue_depth_args *args,
1515 struct dlb2_cmd_response *resp,
1517 unsigned int vdev_id);
1519 enum dlb2_virt_mode {
1524 /* NUM_DLB2_VIRT_MODES must be last */
1525 NUM_DLB2_VIRT_MODES,
1529 * dlb2_hw_set_virt_mode() - set the device's virtualization mode
1530 * @hw: dlb2_hw handle for a particular device.
1531 * @mode: either none, SR-IOV, or Scalable IOV.
1533 * This function sets the virtualization mode of the device. This controls
1534 * whether the device uses a software or hardware mailbox.
1536 * This should be called by the PF driver when either SR-IOV or Scalable IOV is
1537 * selected as the virtualization mechanism, and by the VF/VDEV driver during
1538 * initialization after recognizing itself as an SR-IOV or Scalable IOV device.
1541 * EINVAL - Invalid mode.
1543 int dlb2_hw_set_virt_mode(struct dlb2_hw *hw, enum dlb2_virt_mode mode);
1546 * dlb2_hw_get_virt_mode() - get the device's virtualization mode
1547 * @hw: dlb2_hw handle for a particular device.
1549 * This function gets the virtualization mode of the device.
1551 enum dlb2_virt_mode dlb2_hw_get_virt_mode(struct dlb2_hw *hw);
1554 * dlb2_hw_get_ldb_port_phys_id() - get a physical port ID from its virt ID
1555 * @hw: dlb2_hw handle for a particular device.
1556 * @id: virtual port ID.
1557 * @vdev_id: vdev ID.
1560 * Returns >= 0 upon success, -1 otherwise.
1562 s32 dlb2_hw_get_ldb_port_phys_id(struct dlb2_hw *hw,
1564 unsigned int vdev_id);
1567 * dlb2_hw_get_dir_port_phys_id() - get a physical port ID from its virt ID
1568 * @hw: dlb2_hw handle for a particular device.
1569 * @id: virtual port ID.
1570 * @vdev_id: vdev ID.
1573 * Returns >= 0 upon success, -1 otherwise.
1575 s32 dlb2_hw_get_dir_port_phys_id(struct dlb2_hw *hw,
1577 unsigned int vdev_id);
1580 * dlb2_hw_register_sw_mbox() - register a software mailbox
1581 * @hw: dlb2_hw handle for a particular device.
1582 * @vdev_id: vdev ID.
1583 * @vdev2pf_mbox: pointer to a 4KB memory page used for vdev->PF communication.
1584 * @pf2vdev_mbox: pointer to a 4KB memory page used for PF->vdev communication.
1585 * @pf2vdev_inject: callback function for injecting a PF->vdev interrupt.
1586 * @inject_arg: user argument for pf2vdev_inject callback.
1588 * When Scalable IOV is enabled, the VDCM must register a software mailbox for
1589 * every virtual device during vdev creation.
1591 * This function notifies the driver to use a software mailbox using the
1592 * provided pointers, instead of the device's hardware mailbox. When the driver
1593 * calls mailbox functions like dlb2_pf_write_vf_mbox_req(), the request will
1594 * go to the software mailbox instead of the hardware one. This is used in
1595 * Scalable IOV virtualization.
1597 void dlb2_hw_register_sw_mbox(struct dlb2_hw *hw,
1598 unsigned int vdev_id,
1601 void (*pf2vdev_inject)(void *),
1605 * dlb2_hw_unregister_sw_mbox() - unregister a software mailbox
1606 * @hw: dlb2_hw handle for a particular device.
1607 * @vdev_id: vdev ID.
1609 * This function notifies the driver to stop using a previously registered
1612 void dlb2_hw_unregister_sw_mbox(struct dlb2_hw *hw, unsigned int vdev_id);
1615 * dlb2_hw_setup_cq_ims_entry() - setup a CQ's IMS entry
1616 * @hw: dlb2_hw handle for a particular device.
1617 * @vdev_id: vdev ID.
1618 * @virt_cq_id: virtual CQ ID.
1619 * @is_ldb: CQ is load-balanced.
1620 * @addr_lo: least-significant 32 bits of address.
1621 * @data: 32 data bits.
1623 * This sets up the CQ's IMS entry with the provided address and data values.
1624 * This function should only be called if the device is configured for Scalable
1625 * IOV virtualization. The upper 32 address bits are fixed in hardware and thus
1628 void dlb2_hw_setup_cq_ims_entry(struct dlb2_hw *hw,
1629 unsigned int vdev_id,
1636 * dlb2_hw_clear_cq_ims_entry() - clear a CQ's IMS entry
1637 * @hw: dlb2_hw handle for a particular device.
1638 * @vdev_id: vdev ID.
1639 * @virt_cq_id: virtual CQ ID.
1640 * @is_ldb: CQ is load-balanced.
1642 * This clears the CQ's IMS entry, reverting it to its reset state.
1644 void dlb2_hw_clear_cq_ims_entry(struct dlb2_hw *hw,
1645 unsigned int vdev_id,
1650 * dlb2_hw_register_pasid() - register a vdev's PASID
1651 * @hw: dlb2_hw handle for a particular device.
1652 * @vdev_id: vdev ID.
1653 * @pasid: the vdev's PASID.
1655 * This function stores the user-supplied PASID, and uses it when configuring
1659 * Returns >= 0 upon success, -1 otherwise.
1661 int dlb2_hw_register_pasid(struct dlb2_hw *hw,
1662 unsigned int vdev_id,
1663 unsigned int pasid);
1666 * dlb2_hw_pending_port_unmaps() - returns the number of unmap operations in
1668 * @hw: dlb2_hw handle for a particular device.
1669 * @domain_id: domain ID.
1670 * @args: number of unmaps in progress args
1671 * @resp: response structure.
1672 * @vf_request: indicates whether this request came from a VF.
1673 * @vf_id: If vf_request is true, this contains the VF's ID.
1676 * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
1677 * assigned a detailed error code from enum dlb2_error. If successful, resp->id
1678 * contains the number of unmaps in progress.
1681 * EINVAL - Invalid port ID.
1683 int dlb2_hw_pending_port_unmaps(struct dlb2_hw *hw,
1685 struct dlb2_pending_port_unmaps_args *args,
1686 struct dlb2_cmd_response *resp,
1688 unsigned int vf_id);
1691 * dlb2_hw_get_cos_bandwidth() - returns the percent of bandwidth allocated
1692 * to a port class-of-service.
1693 * @hw: dlb2_hw handle for a particular device.
1694 * @cos_id: class-of-service ID.
1697 * Returns -EINVAL if cos_id is invalid, else the class' bandwidth allocation.
1699 int dlb2_hw_get_cos_bandwidth(struct dlb2_hw *hw, u32 cos_id);
1702 * dlb2_hw_set_cos_bandwidth() - set a bandwidth allocation percentage for a
1703 * port class-of-service.
1704 * @hw: dlb2_hw handle for a particular device.
1705 * @cos_id: class-of-service ID.
1706 * @bandwidth: class-of-service bandwidth.
1709 * Returns 0 upon success, < 0 otherwise.
1712 * EINVAL - Invalid cos ID, bandwidth is greater than 100, or bandwidth would
1713 * cause the total bandwidth across all classes of service to exceed
1716 int dlb2_hw_set_cos_bandwidth(struct dlb2_hw *hw, u32 cos_id, u8 bandwidth);
1719 /* 40s watchdog timeout */
1721 /* 10s watchdog timeout */
1723 /* 1s watchdog timeout */
1731 * dlb2_hw_enable_wd_timer() - enable the CQ watchdog timers with a
1732 * caller-specified timeout.
1733 * @hw: dlb2_hw handle for a particular device.
1734 * @tmo: watchdog timeout.
1736 * This function should be called during device initialization and after reset.
1737 * The watchdog timer interrupt must also be enabled per-CQ, using either
1738 * dlb2_hw_enable_dir_cq_wd_int() or dlb2_hw_enable_ldb_cq_wd_int().
1741 * Returns 0 upon success, < 0 otherwise.
1744 * EINVAL - Invalid timeout.
1746 int dlb2_hw_enable_wd_timer(struct dlb2_hw *hw, enum dlb2_wd_tmo tmo);
1749 * dlb2_hw_enable_dir_cq_wd_int() - enable the CQ watchdog interrupt on an
1751 * @hw: dlb2_hw handle for a particular device.
1753 * @vdev_req: indicates whether this request came from a vdev.
1754 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
1757 * Returns 0 upon success, < 0 otherwise.
1760 * EINVAL - Invalid directed port ID.
1762 int dlb2_hw_enable_dir_cq_wd_int(struct dlb2_hw *hw,
1765 unsigned int vdev_id);
1768 * dlb2_hw_enable_ldb_cq_wd_int() - enable the CQ watchdog interrupt on an
1770 * @hw: dlb2_hw handle for a particular device.
1772 * @vdev_req: indicates whether this request came from a vdev.
1773 * @vdev_id: If vdev_request is true, this contains the vdev's ID.
1776 * Returns 0 upon success, < 0 otherwise.
1779 * EINVAL - Invalid load-balanced port ID.
1781 int dlb2_hw_enable_ldb_cq_wd_int(struct dlb2_hw *hw,
1784 unsigned int vdev_id);
1787 * dlb2_hw_enable_sparse_ldb_cq_mode() - enable sparse mode for load-balanced
1789 * @hw: dlb2_hw handle for a particular device.
1791 * This function must be called prior to configuring scheduling domains.
1793 void dlb2_hw_enable_sparse_ldb_cq_mode(struct dlb2_hw *hw);
1796 * dlb2_hw_enable_sparse_dir_cq_mode() - enable sparse mode for directed ports.
1797 * @hw: dlb2_hw handle for a particular device.
1799 * This function must be called prior to configuring scheduling domains.
1801 void dlb2_hw_enable_sparse_dir_cq_mode(struct dlb2_hw *hw);
1804 * dlb2_hw_set_qe_arbiter_weights() - program QE arbiter weights
1805 * @hw: dlb2_hw handle for a particular device.
1806 * @weight: 8-entry array of arbiter weights.
1808 * weight[N] programs priority N's weight. In cases where the 8 priorities are
1809 * reduced to 4 bins, the mapping is:
1810 * - weight[1] programs bin 0
1811 * - weight[3] programs bin 1
1812 * - weight[5] programs bin 2
1813 * - weight[7] programs bin 3
1815 void dlb2_hw_set_qe_arbiter_weights(struct dlb2_hw *hw, u8 weight[8]);
1818 * dlb2_hw_set_qid_arbiter_weights() - program QID arbiter weights
1819 * @hw: dlb2_hw handle for a particular device.
1820 * @weight: 8-entry array of arbiter weights.
1822 * weight[N] programs priority N's weight. In cases where the 8 priorities are
1823 * reduced to 4 bins, the mapping is:
1824 * - weight[1] programs bin 0
1825 * - weight[3] programs bin 1
1826 * - weight[5] programs bin 2
1827 * - weight[7] programs bin 3
1829 void dlb2_hw_set_qid_arbiter_weights(struct dlb2_hw *hw, u8 weight[8]);
1832 * dlb2_hw_ldb_cq_interrupt_enabled() - Check if the interrupt is enabled
1833 * @hw: dlb2_hw handle for a particular device.
1834 * @port_id: physical load-balanced port ID.
1836 * This function returns whether the load-balanced CQ interrupt is enabled.
1838 int dlb2_hw_ldb_cq_interrupt_enabled(struct dlb2_hw *hw, int port_id);
1841 * dlb2_hw_ldb_cq_interrupt_set_mode() - Program the CQ interrupt mode
1842 * @hw: dlb2_hw handle for a particular device.
1843 * @port_id: physical load-balanced port ID.
1844 * @mode: interrupt type (DLB2_CQ_ISR_MODE_{DIS, MSI, MSIX, ADI})
1846 * This function can be used to disable (MODE_DIS) and re-enable the
1847 * load-balanced CQ's interrupt. It should only be called after the interrupt
1848 * has been configured with dlb2_configure_ldb_cq_interrupt().
1850 void dlb2_hw_ldb_cq_interrupt_set_mode(struct dlb2_hw *hw,
1855 * dlb2_hw_dir_cq_interrupt_enabled() - Check if the interrupt is enabled
1856 * @hw: dlb2_hw handle for a particular device.
1857 * @port_id: physical load-balanced port ID.
1859 * This function returns whether the load-balanced CQ interrupt is enabled.
1861 int dlb2_hw_dir_cq_interrupt_enabled(struct dlb2_hw *hw, int port_id);
1864 * dlb2_hw_dir_cq_interrupt_set_mode() - Program the CQ interrupt mode
1865 * @hw: dlb2_hw handle for a particular device.
1866 * @port_id: physical directed port ID.
1867 * @mode: interrupt type (DLB2_CQ_ISR_MODE_{DIS, MSI, MSIX, ADI})
1869 * This function can be used to disable (MODE_DIS) and re-enable the
1870 * directed CQ's interrupt. It should only be called after the interrupt
1871 * has been configured with dlb2_configure_dir_cq_interrupt().
1873 void dlb2_hw_dir_cq_interrupt_set_mode(struct dlb2_hw *hw,
1877 #endif /* __DLB2_RESOURCE_H */