event/dlb2: add v2.5 HW init
[dpdk.git] / drivers / event / dlb2 / pf / base / dlb2_resource.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2016-2020 Intel Corporation
3  */
4
5 #ifndef __DLB2_RESOURCE_H
6 #define __DLB2_RESOURCE_H
7
8 #include "dlb2_user.h"
9 #include "dlb2_osdep_types.h"
10
11 /**
12  * dlb2_resource_reset() - reset in-use resources to their initial state
13  * @hw: dlb2_hw handle for a particular device.
14  *
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.
17  */
18 void dlb2_resource_reset(struct dlb2_hw *hw);
19
20 /**
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.
27  *
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.
31  *
32  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
33  * device.
34  *
35  * Return:
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.
39  *
40  * resp->id contains a virtual ID if vdev_request is true.
41  *
42  * Errors:
43  * EINVAL - A requested resource is unavailable, or the requested domain name
44  *          is already in use.
45  * EFAULT - Internal error (resp->status not set).
46  */
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,
50                                 bool vdev_request,
51                                 unsigned int vdev_id);
52
53 /**
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.
61  *
62  * This function creates a load-balanced queue.
63  *
64  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
65  * device.
66  *
67  * Return:
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.
71  *
72  * resp->id contains a virtual ID if vdev_request is true.
73  *
74  * Errors:
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
77  *          already in use.
78  * EFAULT - Internal error (resp->status not set).
79  */
80 int dlb2_hw_create_ldb_queue(struct dlb2_hw *hw,
81                              u32 domain_id,
82                              struct dlb2_create_ldb_queue_args *args,
83                              struct dlb2_cmd_response *resp,
84                              bool vdev_request,
85                              unsigned int vdev_id);
86
87 /**
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.
95  *
96  * This function creates a directed queue.
97  *
98  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
99  * device.
100  *
101  * Return:
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.
105  *
106  * resp->id contains a virtual ID if vdev_request is true.
107  *
108  * Errors:
109  * EINVAL - A requested resource is unavailable, the domain is not configured,
110  *          or the domain has already been started.
111  * EFAULT - Internal error (resp->status not set).
112  */
113 int dlb2_hw_create_dir_queue(struct dlb2_hw *hw,
114                              u32 domain_id,
115                              struct dlb2_create_dir_queue_args *args,
116                              struct dlb2_cmd_response *resp,
117                              bool vdev_request,
118                              unsigned int vdev_id);
119
120 /**
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.
129  *
130  * This function creates a directed port.
131  *
132  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
133  * device.
134  *
135  * Return:
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.
139  *
140  * resp->id contains a virtual ID if vdev_request is true.
141  *
142  * Errors:
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).
147  */
148 int dlb2_hw_create_dir_port(struct dlb2_hw *hw,
149                             u32 domain_id,
150                             struct dlb2_create_dir_port_args *args,
151                             uintptr_t cq_dma_base,
152                             struct dlb2_cmd_response *resp,
153                             bool vdev_request,
154                             unsigned int vdev_id);
155
156 /**
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.
165  *
166  * This function creates a load-balanced port.
167  *
168  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
169  * device.
170  *
171  * Return:
172  * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
173  * assigned a detailed error code from enum dlb2_error. If successful, resp->id
174  * contains the port ID.
175  *
176  * resp->id contains a virtual ID if vdev_request is true.
177  *
178  * Errors:
179  * EINVAL - A requested resource is unavailable, a credit setting is invalid, a
180  *          pointer address is not properly aligned, the domain is not
181  *          configured, or the domain has already been started.
182  * EFAULT - Internal error (resp->status not set).
183  */
184 int dlb2_hw_create_ldb_port(struct dlb2_hw *hw,
185                             u32 domain_id,
186                             struct dlb2_create_ldb_port_args *args,
187                             uintptr_t cq_dma_base,
188                             struct dlb2_cmd_response *resp,
189                             bool vdev_request,
190                             unsigned int vdev_id);
191
192 /**
193  * dlb2_hw_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.
200  *
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).
204  *
205  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
206  * device.
207  *
208  * Return:
209  * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
210  * assigned a detailed error code from enum dlb2_error.
211  *
212  * Errors:
213  * EINVAL - the domain is not configured, or the domain is already started.
214  */
215 int dlb2_hw_start_domain(struct dlb2_hw *hw,
216                          u32 domain_id,
217                          struct dlb2_start_domain_args *args,
218                          struct dlb2_cmd_response *resp,
219                          bool vdev_request,
220                          unsigned int vdev_id);
221
222 /**
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.
230  *
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.
235  *
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.
242  *
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.
250  *
251  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
252  * device.
253  *
254  * Return:
255  * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
256  * assigned a detailed error code from enum dlb2_error.
257  *
258  * Errors:
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).
262  */
263 int dlb2_hw_map_qid(struct dlb2_hw *hw,
264                     u32 domain_id,
265                     struct dlb2_map_qid_args *args,
266                     struct dlb2_cmd_response *resp,
267                     bool vdev_request,
268                     unsigned int vdev_id);
269
270 /**
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.
278  *
279  * This function configures the DLB to stop scheduling QEs from the specified
280  * queue to the specified port.
281  *
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.
288  *
289  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
290  * device.
291  *
292  * Return:
293  * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
294  * assigned a detailed error code from enum dlb2_error.
295  *
296  * Errors:
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).
300  */
301 int dlb2_hw_unmap_qid(struct dlb2_hw *hw,
302                       u32 domain_id,
303                       struct dlb2_unmap_qid_args *args,
304                       struct dlb2_cmd_response *resp,
305                       bool vdev_request,
306                       unsigned int vdev_id);
307
308 /**
309  * dlb2_finish_unmap_qid_procedures() - finish any pending unmap procedures
310  * @hw: dlb2_hw handle for a particular device.
311  *
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.
315  *
316  * Return:
317  * Returns the number of procedures that weren't completed.
318  */
319 unsigned int dlb2_finish_unmap_qid_procedures(struct dlb2_hw *hw);
320
321 /**
322  * dlb2_finish_map_qid_procedures() - finish any pending map procedures
323  * @hw: dlb2_hw handle for a particular device.
324  *
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.
328  *
329  * Return:
330  * Returns the number of procedures that weren't completed.
331  */
332 unsigned int dlb2_finish_map_qid_procedures(struct dlb2_hw *hw);
333
334 /**
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.
342  *
343  * This function configures the DLB to schedule QEs to a load-balanced port.
344  * Ports are enabled by default.
345  *
346  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
347  * device.
348  *
349  * Return:
350  * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
351  * assigned a detailed error code from enum dlb2_error.
352  *
353  * Errors:
354  * EINVAL - The port ID is invalid or the domain is not configured.
355  * EFAULT - Internal error (resp->status not set).
356  */
357 int dlb2_hw_enable_ldb_port(struct dlb2_hw *hw,
358                             u32 domain_id,
359                             struct dlb2_enable_ldb_port_args *args,
360                             struct dlb2_cmd_response *resp,
361                             bool vdev_request,
362                             unsigned int vdev_id);
363
364 /**
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.
372  *
373  * This function configures the DLB to stop scheduling QEs to a load-balanced
374  * port. Ports are enabled by default.
375  *
376  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
377  * device.
378  *
379  * Return:
380  * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
381  * assigned a detailed error code from enum dlb2_error.
382  *
383  * Errors:
384  * EINVAL - The port ID is invalid or the domain is not configured.
385  * EFAULT - Internal error (resp->status not set).
386  */
387 int dlb2_hw_disable_ldb_port(struct dlb2_hw *hw,
388                              u32 domain_id,
389                              struct dlb2_disable_ldb_port_args *args,
390                              struct dlb2_cmd_response *resp,
391                              bool vdev_request,
392                              unsigned int vdev_id);
393
394 /**
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.
402  *
403  * This function configures the DLB to schedule QEs to a directed port.
404  * Ports are enabled by default.
405  *
406  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
407  * device.
408  *
409  * Return:
410  * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
411  * assigned a detailed error code from enum dlb2_error.
412  *
413  * Errors:
414  * EINVAL - The port ID is invalid or the domain is not configured.
415  * EFAULT - Internal error (resp->status not set).
416  */
417 int dlb2_hw_enable_dir_port(struct dlb2_hw *hw,
418                             u32 domain_id,
419                             struct dlb2_enable_dir_port_args *args,
420                             struct dlb2_cmd_response *resp,
421                             bool vdev_request,
422                             unsigned int vdev_id);
423
424 /**
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.
432  *
433  * This function configures the DLB to stop scheduling QEs to a directed port.
434  * Ports are enabled by default.
435  *
436  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
437  * device.
438  *
439  * Return:
440  * Returns 0 upon success, < 0 otherwise. If an error occurs, resp->status is
441  * assigned a detailed error code from enum dlb2_error.
442  *
443  * Errors:
444  * EINVAL - The port ID is invalid or the domain is not configured.
445  * EFAULT - Internal error (resp->status not set).
446  */
447 int dlb2_hw_disable_dir_port(struct dlb2_hw *hw,
448                              u32 domain_id,
449                              struct dlb2_disable_dir_port_args *args,
450                              struct dlb2_cmd_response *resp,
451                              bool vdev_request,
452                              unsigned int vdev_id);
453
454 /**
455  * dlb2_configure_ldb_cq_interrupt() - configure load-balanced CQ for
456  *                                      interrupts
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
466  *      greater than 0.
467  *
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.
471  *
472  * Return:
473  * Returns 0 upon success, < 0 otherwise.
474  *
475  * Errors:
476  * EINVAL - The port ID is invalid.
477  */
478 int dlb2_configure_ldb_cq_interrupt(struct dlb2_hw *hw,
479                                     int port_id,
480                                     int vector,
481                                     int mode,
482                                     unsigned int vf,
483                                     unsigned int owner_vf,
484                                     u16 threshold);
485
486 /**
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
497  *      greater than 0.
498  *
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.
502  *
503  * Return:
504  * Returns 0 upon success, < 0 otherwise.
505  *
506  * Errors:
507  * EINVAL - The port ID is invalid.
508  */
509 int dlb2_configure_dir_cq_interrupt(struct dlb2_hw *hw,
510                                     int port_id,
511                                     int vector,
512                                     int mode,
513                                     unsigned int vf,
514                                     unsigned int owner_vf,
515                                     u16 threshold);
516
517 /**
518  * dlb2_enable_ingress_error_alarms() - enable ingress error alarm interrupts
519  * @hw: dlb2_hw handle for a particular device.
520  */
521 void dlb2_enable_ingress_error_alarms(struct dlb2_hw *hw);
522
523 /**
524  * dlb2_disable_ingress_error_alarms() - disable ingress error alarm interrupts
525  * @hw: dlb2_hw handle for a particular device.
526  */
527 void dlb2_disable_ingress_error_alarms(struct dlb2_hw *hw);
528
529 /**
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)
533  *
534  * This function configures the hardware to use either packed or compressed
535  * mode. This function should not be called if using MSI interrupts.
536  */
537 void dlb2_set_msix_mode(struct dlb2_hw *hw, int mode);
538
539 /**
540  * dlb2_ack_msix_interrupt() - Ack an MSI-X interrupt
541  * @hw: dlb2_hw handle for a particular device.
542  * @vector: interrupt vector.
543  *
544  * Note: Only needed for PF service interrupts (vector 0). CQ interrupts are
545  * acked in dlb2_ack_compressed_cq_intr().
546  */
547 void dlb2_ack_msix_interrupt(struct dlb2_hw *hw, int vector);
548
549 /**
550  * dlb2_arm_cq_interrupt() - arm a CQ's interrupt
551  * @hw: dlb2_hw handle for a particular device.
552  * @port_id: port ID
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.
556  *
557  * This function arms the CQ's interrupt. The CQ must be configured prior to
558  * calling this function.
559  *
560  * The function does no parameter validation; that is the caller's
561  * responsibility.
562  *
563  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
564  * device.
565  *
566  * Return: returns 0 upon success, <0 otherwise.
567  *
568  * EINVAL - Invalid port ID.
569  */
570 int dlb2_arm_cq_interrupt(struct dlb2_hw *hw,
571                           int port_id,
572                           bool is_ldb,
573                           bool vdev_request,
574                           unsigned int vdev_id);
575
576 /**
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
581  *
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().
586  */
587 void dlb2_read_compressed_cq_intr_status(struct dlb2_hw *hw,
588                                          u32 *ldb_interrupts,
589                                          u32 *dir_interrupts);
590
591 /**
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
596  *
597  * This function ACKs compressed CQ interrupts. Its arguments should be the
598  * same ones passed to dlb2_read_compressed_cq_intr_status().
599  */
600 void dlb2_ack_compressed_cq_intr(struct dlb2_hw *hw,
601                                  u32 *ldb_interrupts,
602                                  u32 *dir_interrupts);
603
604 /**
605  * dlb2_read_vf_intr_status() - read the VF interrupt status register
606  * @hw: dlb2_hw handle for a particular device.
607  *
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.
611  *
612  * Return:
613  * Returns a bit vector indicating which interrupt vectors are active.
614  */
615 u32 dlb2_read_vf_intr_status(struct dlb2_hw *hw);
616
617 /**
618  * dlb2_ack_vf_intr_status() - ack VF interrupts
619  * @hw: dlb2_hw handle for a particular device.
620  * @interrupts: 32-bit bitmap
621  *
622  * This function ACKs a VF's interrupts. Its interrupts argument should be the
623  * value returned by dlb2_read_vf_intr_status().
624  */
625 void dlb2_ack_vf_intr_status(struct dlb2_hw *hw, u32 interrupts);
626
627 /**
628  * dlb2_ack_vf_msi_intr() - ack VF MSI interrupt
629  * @hw: dlb2_hw handle for a particular device.
630  * @interrupts: 32-bit bitmap
631  *
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.
635  */
636 void dlb2_ack_vf_msi_intr(struct dlb2_hw *hw, u32 interrupts);
637
638 /**
639  * dlb2_ack_pf_mbox_int() - ack PF->VF mailbox interrupt
640  * @hw: dlb2_hw handle for a particular device.
641  *
642  * When done processing the PF mailbox request, this function unsets
643  * the PF's mailbox ISR register.
644  */
645 void dlb2_ack_pf_mbox_int(struct dlb2_hw *hw);
646
647 /**
648  * dlb2_read_vdev_to_pf_int_bitvec() - return a bit vector of all requesting
649  *                                      vdevs
650  * @hw: dlb2_hw handle for a particular device.
651  *
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
655  * vdevs.
656  *
657  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
658  * device.
659  *
660  * Return:
661  * Returns a bit vector indicating which VFs (0-15) have requested service.
662  */
663 u32 dlb2_read_vdev_to_pf_int_bitvec(struct dlb2_hw *hw);
664
665 /**
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()
669  *
670  * When done processing all VF mailbox requests, this function unsets the VF's
671  * mailbox ISR register.
672  *
673  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
674  * device.
675  */
676 void dlb2_ack_vdev_mbox_int(struct dlb2_hw *hw, u32 bitvec);
677
678 /**
679  * dlb2_read_vf_flr_int_bitvec() - return a bit vector of all VFs requesting
680  *                                  FLR
681  * @hw: dlb2_hw handle for a particular device.
682  *
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.
686  *
687  * Return:
688  * Returns a bit vector indicating which VFs (0-15) have requested FLRs.
689  */
690 u32 dlb2_read_vf_flr_int_bitvec(struct dlb2_hw *hw);
691
692 /**
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()
696  *
697  * When done processing all VF FLR requests, this function unsets the VF's FLR
698  * ISR register.
699  */
700 void dlb2_ack_vf_flr_int(struct dlb2_hw *hw, u32 bitvec);
701
702 /**
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()
707  *
708  * When done processing all VF requests, this function communicates to the
709  * hardware that processing is complete.
710  *
711  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
712  * device.
713  */
714 void dlb2_ack_vdev_to_pf_int(struct dlb2_hw *hw,
715                              u32 mbox_bitvec,
716                              u32 flr_bitvec);
717
718 /**
719  * dlb2_process_wdt_interrupt() - process watchdog timer interrupts
720  * @hw: dlb2_hw handle for a particular device.
721  *
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).
725  */
726 void dlb2_process_wdt_interrupt(struct dlb2_hw *hw);
727
728 /**
729  * dlb2_process_alarm_interrupt() - process an alarm interrupt
730  * @hw: dlb2_hw handle for a particular device.
731  *
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.
735  */
736 void dlb2_process_alarm_interrupt(struct dlb2_hw *hw);
737
738 /**
739  * dlb2_process_ingress_error_interrupt() - process ingress error interrupts
740  * @hw: dlb2_hw handle for a particular device.
741  *
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.
745  *
746  * Return:
747  * Returns true if an ingress error interrupt occurred, false otherwise
748  */
749 bool dlb2_process_ingress_error_interrupt(struct dlb2_hw *hw);
750
751 /**
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.
755  *
756  * This function returns the configured number of sequence numbers per queue
757  * for the specified group.
758  *
759  * Return:
760  * Returns -EINVAL if group_id is invalid, else the group's SNs per queue.
761  */
762 int dlb2_get_group_sequence_numbers(struct dlb2_hw *hw,
763                                     unsigned int group_id);
764
765 /**
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.
769  *
770  * This function returns the group's number of in-use slots (i.e. load-balanced
771  * queues using the specified group).
772  *
773  * Return:
774  * Returns -EINVAL if group_id is invalid, else the group's SNs per queue.
775  */
776 int dlb2_get_group_sequence_number_occupancy(struct dlb2_hw *hw,
777                                              unsigned int group_id);
778
779 /**
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.
784  *
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.
789  *
790  * Return:
791  * Returns 0 upon success; -EINVAL if group_id or val is invalid, -EPERM if an
792  * ordered queue is configured.
793  */
794 int dlb2_set_group_sequence_numbers(struct dlb2_hw *hw,
795                                     unsigned int group_id,
796                                     unsigned long val);
797
798 /**
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.
804  *
805  * This function resets and frees a DLB 2.0 scheduling domain and its associated
806  * resources.
807  *
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.
811  *
812  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
813  * device.
814  *
815  * Return:
816  * Returns 0 upon success, -1 otherwise.
817  *
818  * EINVAL - Invalid domain ID, or the domain is not configured.
819  * EFAULT - Internal error. (Possibly caused if software is the pre-condition
820  *          is not met.)
821  * ETIMEDOUT - Hardware component didn't reset in the expected time.
822  */
823 int dlb2_reset_domain(struct dlb2_hw *hw,
824                       u32 domain_id,
825                       bool vdev_request,
826                       unsigned int vdev_id);
827
828 /**
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.
835  *
836  * This function returns whether a load-balanced port is owned by a specified
837  * domain.
838  *
839  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
840  * device.
841  *
842  * Return:
843  * Returns 0 if false, 1 if true, <0 otherwise.
844  *
845  * EINVAL - Invalid domain or port ID, or the domain is not configured.
846  */
847 int dlb2_ldb_port_owned_by_domain(struct dlb2_hw *hw,
848                                   u32 domain_id,
849                                   u32 port_id,
850                                   bool vdev_request,
851                                   unsigned int vdev_id);
852
853 /**
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.
860  *
861  * This function returns whether a directed port is owned by a specified
862  * domain.
863  *
864  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
865  * device.
866  *
867  * Return:
868  * Returns 0 if false, 1 if true, <0 otherwise.
869  *
870  * EINVAL - Invalid domain or port ID, or the domain is not configured.
871  */
872 int dlb2_dir_port_owned_by_domain(struct dlb2_hw *hw,
873                                   u32 domain_id,
874                                   u32 port_id,
875                                   bool vdev_request,
876                                   unsigned int vdev_id);
877
878 /**
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.
884  *
885  * This function returns the number of available resources for the PF or for a
886  * VF.
887  *
888  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
889  * device.
890  *
891  * Return:
892  * Returns 0 upon success, -EINVAL if vdev_request is true and vdev_id is
893  * invalid.
894  */
895 int dlb2_hw_get_num_resources(struct dlb2_hw *hw,
896                               struct dlb2_get_num_resources_args *arg,
897                               bool vdev_request,
898                               unsigned int vdev_id);
899
900 /**
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.
906  *
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
913  *
914  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
915  * device.
916  *
917  * Return:
918  * Returns 0 upon success, -EINVAL if vdev_request is true and vdev_id is
919  * invalid.
920  */
921 int dlb2_hw_get_num_used_resources(struct dlb2_hw *hw,
922                                    struct dlb2_get_num_resources_args *arg,
923                                    bool vdev_request,
924                                    unsigned int vdev_id);
925
926 /**
927  * dlb2_send_async_vdev_to_pf_msg() - (vdev only) send a mailbox message to
928  *                                     the PF
929  * @hw: dlb2_hw handle for a particular device.
930  *
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.
935  *
936  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
937  * device.
938  */
939 void dlb2_send_async_vdev_to_pf_msg(struct dlb2_hw *hw);
940
941 /**
942  * dlb2_vdev_to_pf_complete() - check the status of an asynchronous mailbox
943  *                               request
944  * @hw: dlb2_hw handle for a particular device.
945  *
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().
949  *
950  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
951  * device.
952  */
953 bool dlb2_vdev_to_pf_complete(struct dlb2_hw *hw);
954
955 /**
956  * dlb2_vf_flr_complete() - check the status of a VF FLR
957  * @hw: dlb2_hw handle for a particular device.
958  *
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
961  * bit.
962  */
963 bool dlb2_vf_flr_complete(struct dlb2_hw *hw);
964
965 /**
966  * dlb2_send_async_pf_to_vdev_msg() - (PF only) send a mailbox message to a
967  *                                      vdev
968  * @hw: dlb2_hw handle for a particular device.
969  * @vdev_id: vdev ID.
970  *
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.
975  *
976  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
977  * device.
978  */
979 void dlb2_send_async_pf_to_vdev_msg(struct dlb2_hw *hw, unsigned int vdev_id);
980
981 /**
982  * dlb2_pf_to_vdev_complete() - check the status of an asynchronous mailbox
983  *                             request
984  * @hw: dlb2_hw handle for a particular device.
985  * @vdev_id: vdev ID.
986  *
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().
990  *
991  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
992  * device.
993  */
994 bool dlb2_pf_to_vdev_complete(struct dlb2_hw *hw, unsigned int vdev_id);
995
996 /**
997  * dlb2_pf_read_vf_mbox_req() - (PF only) read a VF->PF mailbox request
998  * @hw: dlb2_hw handle for a particular device.
999  * @vf_id: VF ID.
1000  * @data: pointer to message data.
1001  * @len: size, in bytes, of the data array.
1002  *
1003  * This function copies one of the PF's VF->PF mailboxes into the array pointed
1004  * to by data.
1005  *
1006  * Return:
1007  * Returns 0 upon success, <0 otherwise.
1008  *
1009  * EINVAL - len >= DLB2_VF2PF_REQ_BYTES.
1010  */
1011 int dlb2_pf_read_vf_mbox_req(struct dlb2_hw *hw,
1012                              unsigned int vf_id,
1013                              void *data,
1014                              int len);
1015
1016 /**
1017  * dlb2_pf_read_vf_mbox_resp() - (PF only) read a VF->PF mailbox response
1018  * @hw: dlb2_hw handle for a particular device.
1019  * @vf_id: VF ID.
1020  * @data: pointer to message data.
1021  * @len: size, in bytes, of the data array.
1022  *
1023  * This function copies one of the PF's VF->PF mailboxes into the array pointed
1024  * to by data.
1025  *
1026  * Return:
1027  * Returns 0 upon success, <0 otherwise.
1028  *
1029  * EINVAL - len >= DLB2_VF2PF_RESP_BYTES.
1030  */
1031 int dlb2_pf_read_vf_mbox_resp(struct dlb2_hw *hw,
1032                               unsigned int vf_id,
1033                               void *data,
1034                               int len);
1035
1036 /**
1037  * dlb2_pf_write_vf_mbox_resp() - (PF only) write a PF->VF mailbox response
1038  * @hw: dlb2_hw handle for a particular device.
1039  * @vf_id: VF ID.
1040  * @data: pointer to message data.
1041  * @len: size, in bytes, of the data array.
1042  *
1043  * This function copies the user-provided message data into of the PF's VF->PF
1044  * mailboxes.
1045  *
1046  * Return:
1047  * Returns 0 upon success, <0 otherwise.
1048  *
1049  * EINVAL - len >= DLB2_PF2VF_RESP_BYTES.
1050  */
1051 int dlb2_pf_write_vf_mbox_resp(struct dlb2_hw *hw,
1052                                unsigned int vf_id,
1053                                void *data,
1054                                int len);
1055
1056 /**
1057  * dlb2_pf_write_vf_mbox_req() - (PF only) write a PF->VF mailbox request
1058  * @hw: dlb2_hw handle for a particular device.
1059  * @vf_id: VF ID.
1060  * @data: pointer to message data.
1061  * @len: size, in bytes, of the data array.
1062  *
1063  * This function copies the user-provided message data into of the PF's VF->PF
1064  * mailboxes.
1065  *
1066  * Return:
1067  * Returns 0 upon success, <0 otherwise.
1068  *
1069  * EINVAL - len >= DLB2_PF2VF_REQ_BYTES.
1070  */
1071 int dlb2_pf_write_vf_mbox_req(struct dlb2_hw *hw,
1072                               unsigned int vf_id,
1073                               void *data,
1074                               int len);
1075
1076 /**
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.
1081  *
1082  * This function copies the VF's PF->VF mailbox into the array pointed to by
1083  * data.
1084  *
1085  * Return:
1086  * Returns 0 upon success, <0 otherwise.
1087  *
1088  * EINVAL - len >= DLB2_PF2VF_RESP_BYTES.
1089  */
1090 int dlb2_vf_read_pf_mbox_resp(struct dlb2_hw *hw, void *data, int len);
1091
1092 /**
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.
1097  *
1098  * This function copies the VF's PF->VF mailbox into the array pointed to by
1099  * data.
1100  *
1101  * Return:
1102  * Returns 0 upon success, <0 otherwise.
1103  *
1104  * EINVAL - len >= DLB2_PF2VF_REQ_BYTES.
1105  */
1106 int dlb2_vf_read_pf_mbox_req(struct dlb2_hw *hw, void *data, int len);
1107
1108 /**
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.
1113  *
1114  * This function copies the user-provided message data into of the VF's PF->VF
1115  * mailboxes.
1116  *
1117  * Return:
1118  * Returns 0 upon success, <0 otherwise.
1119  *
1120  * EINVAL - len >= DLB2_VF2PF_REQ_BYTES.
1121  */
1122 int dlb2_vf_write_pf_mbox_req(struct dlb2_hw *hw, void *data, int len);
1123
1124 /**
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.
1129  *
1130  * This function copies the user-provided message data into of the VF's PF->VF
1131  * mailboxes.
1132  *
1133  * Return:
1134  * Returns 0 upon success, <0 otherwise.
1135  *
1136  * EINVAL - len >= DLB2_VF2PF_RESP_BYTES.
1137  */
1138 int dlb2_vf_write_pf_mbox_resp(struct dlb2_hw *hw, void *data, int len);
1139
1140 /**
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
1144  *
1145  * This function resets the hardware owned by a vdev, by resetting the vdev's
1146  * domains one by one.
1147  *
1148  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1149  * device.
1150  */
1151 int dlb2_reset_vdev(struct dlb2_hw *hw, unsigned int id);
1152
1153 /**
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
1157  *
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
1160  * group.
1161  *
1162  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1163  * device.
1164  */
1165 bool dlb2_vdev_is_locked(struct dlb2_hw *hw, unsigned int id);
1166
1167 /**
1168  * dlb2_lock_vdev() - lock the vdev's resources
1169  * @hw: dlb2_hw handle for a particular device.
1170  * @id: virtual device ID
1171  *
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.
1174  *
1175  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1176  * device.
1177  */
1178 void dlb2_lock_vdev(struct dlb2_hw *hw, unsigned int id);
1179
1180 /**
1181  * dlb2_unlock_vdev() - unlock the vdev's resources
1182  * @hw: dlb2_hw handle for a particular device.
1183  * @id: virtual device ID
1184  *
1185  * This function unlocks the vdev's resource assignment, allowing it to be
1186  * modified.
1187  *
1188  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1189  * device.
1190  */
1191 void dlb2_unlock_vdev(struct dlb2_hw *hw, unsigned int id);
1192
1193 /**
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
1198  *
1199  * This function assigns num scheduling domains to the specified vdev. If the
1200  * vdev already has domains assigned, this existing assignment is adjusted
1201  * accordingly.
1202  *
1203  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1204  * device.
1205  *
1206  * Return:
1207  * Returns 0 upon success, <0 otherwise.
1208  *
1209  * Errors:
1210  * EINVAL - id is invalid, or the requested number of resources are
1211  *          unavailable.
1212  * EPERM  - The vdev's resource assignment is locked and cannot be changed.
1213  */
1214 int dlb2_update_vdev_sched_domains(struct dlb2_hw *hw, u32 id, u32 num);
1215
1216 /**
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
1221  *
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
1224  * accordingly.
1225  *
1226  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1227  * device.
1228  *
1229  * Return:
1230  * Returns 0 upon success, <0 otherwise.
1231  *
1232  * Errors:
1233  * EINVAL - id is invalid, or the requested number of resources are
1234  *          unavailable.
1235  * EPERM  - The vdev's resource assignment is locked and cannot be changed.
1236  */
1237 int dlb2_update_vdev_ldb_queues(struct dlb2_hw *hw, u32 id, u32 num);
1238
1239 /**
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
1244  *
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
1247  * accordingly.
1248  *
1249  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1250  * device.
1251  *
1252  * Return:
1253  * Returns 0 upon success, <0 otherwise.
1254  *
1255  * Errors:
1256  * EINVAL - id is invalid, or the requested number of resources are
1257  *          unavailable.
1258  * EPERM  - The vdev's resource assignment is locked and cannot be changed.
1259  */
1260 int dlb2_update_vdev_ldb_ports(struct dlb2_hw *hw, u32 id, u32 num);
1261
1262 /**
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
1268  *
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.
1272  *
1273  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1274  * device.
1275  *
1276  * Return:
1277  * Returns 0 upon success, <0 otherwise.
1278  *
1279  * Errors:
1280  * EINVAL - id is invalid, or the requested number of resources are
1281  *          unavailable.
1282  * EPERM  - The vdev's resource assignment is locked and cannot be changed.
1283  */
1284 int dlb2_update_vdev_ldb_cos_ports(struct dlb2_hw *hw,
1285                                    u32 id,
1286                                    u32 cos,
1287                                    u32 num);
1288
1289 /**
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
1294  *
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
1297  * accordingly.
1298  *
1299  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1300  * device.
1301  *
1302  * Return:
1303  * Returns 0 upon success, <0 otherwise.
1304  *
1305  * Errors:
1306  * EINVAL - id is invalid, or the requested number of resources are
1307  *          unavailable.
1308  * EPERM  - The vdev's resource assignment is locked and cannot be changed.
1309  */
1310 int dlb2_update_vdev_dir_ports(struct dlb2_hw *hw, u32 id, u32 num);
1311
1312 /**
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
1317  *
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.
1322  *
1323  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1324  * device.
1325  *
1326  * Return:
1327  * Returns 0 upon success, <0 otherwise.
1328  *
1329  * Errors:
1330  * EINVAL - id is invalid, or the requested number of resources are
1331  *          unavailable.
1332  * EPERM  - The vdev's resource assignment is locked and cannot be changed.
1333  */
1334 int dlb2_update_vdev_ldb_credits(struct dlb2_hw *hw, u32 id, u32 num);
1335
1336 /**
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
1341  *
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.
1346  *
1347  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1348  * device.
1349  *
1350  * Return:
1351  * Returns 0 upon success, <0 otherwise.
1352  *
1353  * Errors:
1354  * EINVAL - id is invalid, or the requested number of resources are
1355  *          unavailable.
1356  * EPERM  - The vdev's resource assignment is locked and cannot be changed.
1357  */
1358 int dlb2_update_vdev_dir_credits(struct dlb2_hw *hw, u32 id, u32 num);
1359
1360 /**
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
1365  *
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
1370  * available.
1371  *
1372  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1373  * device.
1374  *
1375  * Return:
1376  * Returns 0 upon success, <0 otherwise.
1377  *
1378  * Errors:
1379  * EINVAL - id is invalid, or the requested number of resources are
1380  *          unavailable.
1381  * EPERM  - The vdev's resource assignment is locked and cannot be changed.
1382  */
1383 int dlb2_update_vdev_hist_list_entries(struct dlb2_hw *hw, u32 id, u32 num);
1384
1385 /**
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
1390  *
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.
1395  *
1396  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1397  * device.
1398  *
1399  * Return:
1400  * Returns 0 upon success, <0 otherwise.
1401  *
1402  * Errors:
1403  * EINVAL - id is invalid, or the requested number of resources are
1404  *          unavailable.
1405  * EPERM  - The vdev's resource assignment is locked and cannot be changed.
1406  */
1407 int dlb2_update_vdev_atomic_inflights(struct dlb2_hw *hw, u32 id, u32 num);
1408
1409 /**
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
1413  *
1414  * This function takes any resources currently assigned to the vdev and
1415  * reassigns them to the PF.
1416  *
1417  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1418  * device.
1419  *
1420  * Return:
1421  * Returns 0 upon success, <0 otherwise.
1422  *
1423  * Errors:
1424  * EINVAL - id is invalid
1425  * EPERM  - The vdev's resource assignment is locked and cannot be changed.
1426  */
1427 int dlb2_reset_vdev_resources(struct dlb2_hw *hw, unsigned int id);
1428
1429 /**
1430  * dlb2_notify_vf() - send an alarm to a VF
1431  * @hw: dlb2_hw handle for a particular device.
1432  * @vf_id: VF ID
1433  * @notification: notification
1434  *
1435  * This function sends a notification (as defined in dlb2_mbox.h) to a VF.
1436  *
1437  * Return:
1438  * Returns 0 upon success, <0 if the VF doesn't ACK the PF->VF interrupt.
1439  */
1440 int dlb2_notify_vf(struct dlb2_hw *hw,
1441                    unsigned int vf_id,
1442                    u32 notification);
1443
1444 /**
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
1448  *
1449  * This function sends a mailbox request to the vdev to query whether the vdev
1450  * is in use.
1451  *
1452  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1453  * device.
1454  *
1455  * Return:
1456  * Returns 0 for false, 1 for true, and <0 if the mailbox request times out or
1457  * an internal error occurs.
1458  */
1459 int dlb2_vdev_in_use(struct dlb2_hw *hw, unsigned int id);
1460
1461 /**
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.
1469  *
1470  * This function returns the depth of a load-balanced queue.
1471  *
1472  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1473  * device.
1474  *
1475  * Return:
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.
1479  *
1480  * Errors:
1481  * EINVAL - Invalid domain ID or queue ID.
1482  */
1483 int dlb2_hw_get_ldb_queue_depth(struct dlb2_hw *hw,
1484                                 u32 domain_id,
1485                                 struct dlb2_get_ldb_queue_depth_args *args,
1486                                 struct dlb2_cmd_response *resp,
1487                                 bool vdev_request,
1488                                 unsigned int vdev_id);
1489
1490 /**
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.
1498  *
1499  * This function returns the depth of a directed queue.
1500  *
1501  * A vdev can be either an SR-IOV virtual function or a Scalable IOV virtual
1502  * device.
1503  *
1504  * Return:
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.
1508  *
1509  * Errors:
1510  * EINVAL - Invalid domain ID or queue ID.
1511  */
1512 int dlb2_hw_get_dir_queue_depth(struct dlb2_hw *hw,
1513                                 u32 domain_id,
1514                                 struct dlb2_get_dir_queue_depth_args *args,
1515                                 struct dlb2_cmd_response *resp,
1516                                 bool vdev_request,
1517                                 unsigned int vdev_id);
1518
1519 enum dlb2_virt_mode {
1520         DLB2_VIRT_NONE,
1521         DLB2_VIRT_SRIOV,
1522         DLB2_VIRT_SIOV,
1523
1524         /* NUM_DLB2_VIRT_MODES must be last */
1525         NUM_DLB2_VIRT_MODES,
1526 };
1527
1528 /**
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.
1532  *
1533  * This function sets the virtualization mode of the device. This controls
1534  * whether the device uses a software or hardware mailbox.
1535  *
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.
1539  *
1540  * Errors:
1541  * EINVAL - Invalid mode.
1542  */
1543 int dlb2_hw_set_virt_mode(struct dlb2_hw *hw, enum dlb2_virt_mode mode);
1544
1545 /**
1546  * dlb2_hw_get_virt_mode() - get the device's virtualization mode
1547  * @hw: dlb2_hw handle for a particular device.
1548  *
1549  * This function gets the virtualization mode of the device.
1550  */
1551 enum dlb2_virt_mode dlb2_hw_get_virt_mode(struct dlb2_hw *hw);
1552
1553 /**
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.
1558  *
1559  * Return:
1560  * Returns >= 0 upon success, -1 otherwise.
1561  */
1562 s32 dlb2_hw_get_ldb_port_phys_id(struct dlb2_hw *hw,
1563                                  u32 id,
1564                                  unsigned int vdev_id);
1565
1566 /**
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.
1571  *
1572  * Return:
1573  * Returns >= 0 upon success, -1 otherwise.
1574  */
1575 s32 dlb2_hw_get_dir_port_phys_id(struct dlb2_hw *hw,
1576                                  u32 id,
1577                                  unsigned int vdev_id);
1578
1579 /**
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.
1587  *
1588  * When Scalable IOV is enabled, the VDCM must register a software mailbox for
1589  * every virtual device during vdev creation.
1590  *
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.
1596  */
1597 void dlb2_hw_register_sw_mbox(struct dlb2_hw *hw,
1598                               unsigned int vdev_id,
1599                               u32 *vdev2pf_mbox,
1600                               u32 *pf2vdev_mbox,
1601                               void (*pf2vdev_inject)(void *),
1602                               void *inject_arg);
1603
1604 /**
1605  * dlb2_hw_unregister_sw_mbox() - unregister a software mailbox
1606  * @hw: dlb2_hw handle for a particular device.
1607  * @vdev_id: vdev ID.
1608  *
1609  * This function notifies the driver to stop using a previously registered
1610  * software mailbox.
1611  */
1612 void dlb2_hw_unregister_sw_mbox(struct dlb2_hw *hw, unsigned int vdev_id);
1613
1614 /**
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.
1622  *
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
1626  * not needed.
1627  */
1628 void dlb2_hw_setup_cq_ims_entry(struct dlb2_hw *hw,
1629                                 unsigned int vdev_id,
1630                                 u32 virt_cq_id,
1631                                 bool is_ldb,
1632                                 u32 addr_lo,
1633                                 u32 data);
1634
1635 /**
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.
1641  *
1642  * This clears the CQ's IMS entry, reverting it to its reset state.
1643  */
1644 void dlb2_hw_clear_cq_ims_entry(struct dlb2_hw *hw,
1645                                 unsigned int vdev_id,
1646                                 u32 virt_cq_id,
1647                                 bool is_ldb);
1648
1649 /**
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.
1654  *
1655  * This function stores the user-supplied PASID, and uses it when configuring
1656  * the vdev's CQs.
1657  *
1658  * Return:
1659  * Returns >= 0 upon success, -1 otherwise.
1660  */
1661 int dlb2_hw_register_pasid(struct dlb2_hw *hw,
1662                            unsigned int vdev_id,
1663                            unsigned int pasid);
1664
1665 /**
1666  * dlb2_hw_pending_port_unmaps() - returns the number of unmap operations in
1667  *      progress.
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.
1674  *
1675  * Return:
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.
1679  *
1680  * Errors:
1681  * EINVAL - Invalid port ID.
1682  */
1683 int dlb2_hw_pending_port_unmaps(struct dlb2_hw *hw,
1684                                 u32 domain_id,
1685                                 struct dlb2_pending_port_unmaps_args *args,
1686                                 struct dlb2_cmd_response *resp,
1687                                 bool vf_request,
1688                                 unsigned int vf_id);
1689
1690 /**
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.
1695  *
1696  * Return:
1697  * Returns -EINVAL if cos_id is invalid, else the class' bandwidth allocation.
1698  */
1699 int dlb2_hw_get_cos_bandwidth(struct dlb2_hw *hw, u32 cos_id);
1700
1701 /**
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.
1707  *
1708  * Return:
1709  * Returns 0 upon success, < 0 otherwise.
1710  *
1711  * Errors:
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
1714  *          100%.
1715  */
1716 int dlb2_hw_set_cos_bandwidth(struct dlb2_hw *hw, u32 cos_id, u8 bandwidth);
1717
1718 enum dlb2_wd_tmo {
1719         /* 40s watchdog timeout */
1720         DLB2_WD_TMO_40S,
1721         /* 10s watchdog timeout */
1722         DLB2_WD_TMO_10S,
1723         /* 1s watchdog timeout */
1724         DLB2_WD_TMO_1S,
1725
1726         /* Must be last */
1727         NUM_DLB2_WD_TMOS,
1728 };
1729
1730 /**
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.
1735  *
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().
1739  *
1740  * Return:
1741  * Returns 0 upon success, < 0 otherwise.
1742  *
1743  * Errors:
1744  * EINVAL - Invalid timeout.
1745  */
1746 int dlb2_hw_enable_wd_timer(struct dlb2_hw *hw, enum dlb2_wd_tmo tmo);
1747
1748 /**
1749  * dlb2_hw_enable_dir_cq_wd_int() - enable the CQ watchdog interrupt on an
1750  *      individual CQ.
1751  * @hw: dlb2_hw handle for a particular device.
1752  * @id: port ID.
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.
1755  *
1756  * Return:
1757  * Returns 0 upon success, < 0 otherwise.
1758  *
1759  * Errors:
1760  * EINVAL - Invalid directed port ID.
1761  */
1762 int dlb2_hw_enable_dir_cq_wd_int(struct dlb2_hw *hw,
1763                                  u32 id,
1764                                  bool vdev_req,
1765                                  unsigned int vdev_id);
1766
1767 /**
1768  * dlb2_hw_enable_ldb_cq_wd_int() - enable the CQ watchdog interrupt on an
1769  *      individual CQ.
1770  * @hw: dlb2_hw handle for a particular device.
1771  * @id: port ID.
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.
1774  *
1775  * Return:
1776  * Returns 0 upon success, < 0 otherwise.
1777  *
1778  * Errors:
1779  * EINVAL - Invalid load-balanced port ID.
1780  */
1781 int dlb2_hw_enable_ldb_cq_wd_int(struct dlb2_hw *hw,
1782                                  u32 id,
1783                                  bool vdev_req,
1784                                  unsigned int vdev_id);
1785
1786 /**
1787  * dlb2_hw_enable_sparse_ldb_cq_mode() - enable sparse mode for load-balanced
1788  *      ports.
1789  * @hw: dlb2_hw handle for a particular device.
1790  *
1791  * This function must be called prior to configuring scheduling domains.
1792  */
1793 void dlb2_hw_enable_sparse_ldb_cq_mode(struct dlb2_hw *hw);
1794
1795 /**
1796  * dlb2_hw_enable_sparse_dir_cq_mode() - enable sparse mode for directed ports.
1797  * @hw: dlb2_hw handle for a particular device.
1798  *
1799  * This function must be called prior to configuring scheduling domains.
1800  */
1801 void dlb2_hw_enable_sparse_dir_cq_mode(struct dlb2_hw *hw);
1802
1803 /**
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.
1807  *
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
1814  */
1815 void dlb2_hw_set_qe_arbiter_weights(struct dlb2_hw *hw, u8 weight[8]);
1816
1817 /**
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.
1821  *
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
1828  */
1829 void dlb2_hw_set_qid_arbiter_weights(struct dlb2_hw *hw, u8 weight[8]);
1830
1831 /**
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.
1835  *
1836  * This function returns whether the load-balanced CQ interrupt is enabled.
1837  */
1838 int dlb2_hw_ldb_cq_interrupt_enabled(struct dlb2_hw *hw, int port_id);
1839
1840 /**
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})
1845  *
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().
1849  */
1850 void dlb2_hw_ldb_cq_interrupt_set_mode(struct dlb2_hw *hw,
1851                                        int port_id,
1852                                        int mode);
1853
1854 /**
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.
1858  *
1859  * This function returns whether the load-balanced CQ interrupt is enabled.
1860  */
1861 int dlb2_hw_dir_cq_interrupt_enabled(struct dlb2_hw *hw, int port_id);
1862
1863 /**
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})
1868  *
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().
1872  */
1873 void dlb2_hw_dir_cq_interrupt_set_mode(struct dlb2_hw *hw,
1874                                        int port_id,
1875                                        int mode);
1876
1877 #endif /* __DLB2_RESOURCE_H */