1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2016-2020 Intel Corporation
8 #define DLB2_MAX_NAME_LEN 64
10 #include <linux/types.h>
15 DLB2_ST_DOMAIN_UNAVAILABLE,
16 DLB2_ST_LDB_PORTS_UNAVAILABLE,
17 DLB2_ST_DIR_PORTS_UNAVAILABLE,
18 DLB2_ST_LDB_QUEUES_UNAVAILABLE,
19 DLB2_ST_LDB_CREDITS_UNAVAILABLE,
20 DLB2_ST_DIR_CREDITS_UNAVAILABLE,
21 DLB2_ST_CREDITS_UNAVAILABLE,
22 DLB2_ST_SEQUENCE_NUMBERS_UNAVAILABLE,
23 DLB2_ST_INVALID_DOMAIN_ID,
24 DLB2_ST_INVALID_QID_INFLIGHT_ALLOCATION,
25 DLB2_ST_ATOMIC_INFLIGHTS_UNAVAILABLE,
26 DLB2_ST_HIST_LIST_ENTRIES_UNAVAILABLE,
27 DLB2_ST_INVALID_LDB_QUEUE_ID,
28 DLB2_ST_INVALID_CQ_DEPTH,
29 DLB2_ST_INVALID_CQ_VIRT_ADDR,
30 DLB2_ST_INVALID_PORT_ID,
32 DLB2_ST_INVALID_PRIORITY,
33 DLB2_ST_NO_QID_SLOTS_AVAILABLE,
34 DLB2_ST_INVALID_DIR_QUEUE_ID,
35 DLB2_ST_DIR_QUEUES_UNAVAILABLE,
36 DLB2_ST_DOMAIN_NOT_CONFIGURED,
37 DLB2_ST_INTERNAL_ERROR,
38 DLB2_ST_DOMAIN_IN_USE,
39 DLB2_ST_DOMAIN_NOT_FOUND,
40 DLB2_ST_QUEUE_NOT_FOUND,
41 DLB2_ST_DOMAIN_STARTED,
42 DLB2_ST_DOMAIN_NOT_STARTED,
43 DLB2_ST_LDB_PORT_REQUIRED_FOR_LDB_QUEUES,
44 DLB2_ST_DOMAIN_RESET_FAILED,
46 DLB2_ST_INVALID_HIST_LIST_DEPTH,
48 DLB2_ST_INVALID_LOCK_ID_COMP_LEVEL,
49 DLB2_ST_INVALID_COS_ID,
50 DLB2_ST_INVALID_CQ_WEIGHT_LIMIT,
51 DLB2_ST_FEATURE_UNAVAILABLE,
54 static const char dlb2_error_strings[][128] = {
56 "DLB2_ST_NAME_EXISTS",
57 "DLB2_ST_DOMAIN_UNAVAILABLE",
58 "DLB2_ST_LDB_PORTS_UNAVAILABLE",
59 "DLB2_ST_DIR_PORTS_UNAVAILABLE",
60 "DLB2_ST_LDB_QUEUES_UNAVAILABLE",
61 "DLB2_ST_LDB_CREDITS_UNAVAILABLE",
62 "DLB2_ST_DIR_CREDITS_UNAVAILABLE",
63 "DLB2_ST_CREDITS_UNAVAILABLE",
64 "DLB2_ST_SEQUENCE_NUMBERS_UNAVAILABLE",
65 "DLB2_ST_INVALID_DOMAIN_ID",
66 "DLB2_ST_INVALID_QID_INFLIGHT_ALLOCATION",
67 "DLB2_ST_ATOMIC_INFLIGHTS_UNAVAILABLE",
68 "DLB2_ST_HIST_LIST_ENTRIES_UNAVAILABLE",
69 "DLB2_ST_INVALID_LDB_QUEUE_ID",
70 "DLB2_ST_INVALID_CQ_DEPTH",
71 "DLB2_ST_INVALID_CQ_VIRT_ADDR",
72 "DLB2_ST_INVALID_PORT_ID",
73 "DLB2_ST_INVALID_QID",
74 "DLB2_ST_INVALID_PRIORITY",
75 "DLB2_ST_NO_QID_SLOTS_AVAILABLE",
76 "DLB2_ST_INVALID_DIR_QUEUE_ID",
77 "DLB2_ST_DIR_QUEUES_UNAVAILABLE",
78 "DLB2_ST_DOMAIN_NOT_CONFIGURED",
79 "DLB2_ST_INTERNAL_ERROR",
80 "DLB2_ST_DOMAIN_IN_USE",
81 "DLB2_ST_DOMAIN_NOT_FOUND",
82 "DLB2_ST_QUEUE_NOT_FOUND",
83 "DLB2_ST_DOMAIN_STARTED",
84 "DLB2_ST_DOMAIN_NOT_STARTED",
85 "DLB2_ST_LDB_PORT_REQUIRED_FOR_LDB_QUEUES",
86 "DLB2_ST_DOMAIN_RESET_FAILED",
88 "DLB2_ST_INVALID_HIST_LIST_DEPTH",
90 "DLB2_ST_INVALID_LOCK_ID_COMP_LEVEL",
91 "DLB2_ST_INVALID_COS_ID",
92 "DLB2_ST_INVALID_CQ_WEIGHT_LIMIT",
93 "DLB2_ST_FEATURE_UNAVAILABLE",
96 struct dlb2_cmd_response {
97 __u32 status; /* Interpret using enum dlb2_error */
101 /*******************/
102 /* 'dlb2' commands */
103 /*******************/
105 #define DLB2_DEVICE_VERSION(x) (((x) >> 8) & 0xFF)
106 #define DLB2_DEVICE_REVISION(x) ((x) & 0xFF)
108 enum dlb2_revisions {
113 * DLB2_CMD_GET_DEVICE_VERSION: Query the DLB device version.
115 * This ioctl interface is the same in all driver versions and is always
119 * - response.status: Detailed error code. In certain cases, such as if the
120 * ioctl request arg is invalid, the driver won't set status.
121 * - response.id[7:0]: Device revision.
122 * - response.id[15:8]: Device version.
125 struct dlb2_get_device_version_args {
126 /* Output parameters */
127 struct dlb2_cmd_response response;
131 * DLB2_CMD_CREATE_SCHED_DOMAIN: Create a DLB 2.0 scheduling domain and reserve
132 * its hardware resources. This command returns the newly created domain
133 * ID and a file descriptor for accessing the domain.
136 * - num_ldb_queues: Number of load-balanced queues.
137 * - num_ldb_ports: Number of load-balanced ports that can be allocated from
138 * any class-of-service with available ports.
139 * - num_cos_ldb_ports[4]: Number of load-balanced ports from
140 * classes-of-service 0-3.
141 * - num_dir_ports: Number of directed ports. A directed port has one directed
142 * queue, so no num_dir_queues argument is necessary.
143 * - num_atomic_inflights: This specifies the amount of temporary atomic QE
144 * storage for the domain. This storage is divided among the domain's
145 * load-balanced queues that are configured for atomic scheduling.
146 * - num_hist_list_entries: Amount of history list storage. This is divided
147 * among the domain's CQs.
148 * - num_ldb_credits: Amount of load-balanced QE storage (QED). QEs occupy this
149 * space until they are scheduled to a load-balanced CQ. One credit
150 * represents the storage for one QE.
151 * - num_dir_credits: Amount of directed QE storage (DQED). QEs occupy this
152 * space until they are scheduled to a directed CQ. One credit represents
153 * the storage for one QE.
154 * - cos_strict: If set, return an error if there are insufficient ports in
155 * class-of-service N to satisfy the num_ldb_ports_cosN argument. If
156 * unset, attempt to fulfill num_ldb_ports_cosN arguments from other
157 * classes-of-service if class N does not contain enough free ports.
158 * - padding1: Reserved for future use.
161 * - response.status: Detailed error code. In certain cases, such as if the
162 * ioctl request arg is invalid, the driver won't set status.
163 * - response.id: domain ID.
164 * - domain_fd: file descriptor for performing the domain's ioctl operations
165 * - padding0: Reserved for future use.
167 struct dlb2_create_sched_domain_args {
168 /* Output parameters */
169 struct dlb2_cmd_response response;
172 /* Input parameters */
173 __u32 num_ldb_queues;
175 __u32 num_cos_ldb_ports[4];
177 __u32 num_atomic_inflights;
178 __u32 num_hist_list_entries;
181 __u32 num_ldb_credits;
182 __u32 num_dir_credits;
193 * DLB2_CMD_GET_NUM_RESOURCES: Return the number of available resources
194 * (queues, ports, etc.) that this device owns.
197 * - num_domains: Number of available scheduling domains.
198 * - num_ldb_queues: Number of available load-balanced queues.
199 * - num_ldb_ports: Total number of available load-balanced ports.
200 * - num_cos_ldb_ports[4]: Number of available load-balanced ports from
201 * classes-of-service 0-3.
202 * - num_dir_ports: Number of available directed ports. There is one directed
203 * queue for every directed port.
204 * - num_atomic_inflights: Amount of available temporary atomic QE storage.
205 * - num_hist_list_entries: Amount of history list storage.
206 * - max_contiguous_hist_list_entries: History list storage is allocated in
207 * a contiguous chunk, and this return value is the longest available
208 * contiguous range of history list entries.
209 * - num_ldb_credits: Amount of available load-balanced QE storage.
210 * - num_dir_credits: Amount of available directed QE storage.
211 * - response.status: Detailed error code. In certain cases, such as if the
212 * ioctl request arg is invalid, the driver won't set status.
214 struct dlb2_get_num_resources_args {
215 /* Output parameters */
216 struct dlb2_cmd_response response;
217 __u32 num_sched_domains;
218 __u32 num_ldb_queues;
220 __u32 num_cos_ldb_ports[4];
222 __u32 num_atomic_inflights;
223 __u32 num_hist_list_entries;
224 __u32 max_contiguous_hist_list_entries;
227 __u32 num_ldb_credits;
228 __u32 num_dir_credits;
237 * DLB2_CMD_SET_SN_ALLOCATION: Configure a sequence number group (PF only)
240 * - group: Sequence number group ID.
241 * - num: Number of sequence numbers per queue.
244 * - response.status: Detailed error code. In certain cases, such as if the
245 * ioctl request arg is invalid, the driver won't set status.
247 struct dlb2_set_sn_allocation_args {
248 /* Output parameters */
249 struct dlb2_cmd_response response;
250 /* Input parameters */
256 * DLB2_CMD_GET_SN_ALLOCATION: Get a sequence number group's configuration
259 * - group: Sequence number group ID.
260 * - padding0: Reserved for future use.
263 * - response.status: Detailed error code. In certain cases, such as if the
264 * ioctl request arg is invalid, the driver won't set status.
265 * - response.id: Specified group's number of sequence numbers per queue.
267 struct dlb2_get_sn_allocation_args {
268 /* Output parameters */
269 struct dlb2_cmd_response response;
270 /* Input parameters */
276 * DLB2_CMD_SET_COS_BW: Set a bandwidth allocation percentage for a
277 * load-balanced port class-of-service (PF only).
280 * - cos_id: class-of-service ID, between 0 and 3 (inclusive).
281 * - bandwidth: class-of-service bandwidth percentage. Total bandwidth
282 * percentages across all 4 classes cannot exceed 100%.
285 * - response.status: Detailed error code. In certain cases, such as if the
286 * ioctl request arg is invalid, the driver won't set status.
288 struct dlb2_set_cos_bw_args {
289 /* Output parameters */
290 struct dlb2_cmd_response response;
291 /* Input parameters */
297 * DLB2_CMD_GET_COS_BW: Get the bandwidth allocation percentage for a
298 * load-balanced port class-of-service.
301 * - cos_id: class-of-service ID, between 0 and 3 (inclusive).
302 * - padding0: Reserved for future use.
305 * - response.status: Detailed error code. In certain cases, such as if the
306 * ioctl request arg is invalid, the driver won't set status.
307 * - response.id: Specified class's bandwidth percentage.
309 struct dlb2_get_cos_bw_args {
310 /* Output parameters */
311 struct dlb2_cmd_response response;
312 /* Input parameters */
318 * DLB2_CMD_GET_SN_OCCUPANCY: Get a sequence number group's occupancy
320 * Each sequence number group has one or more slots, depending on its
321 * configuration. I.e.:
322 * - If configured for 1024 sequence numbers per queue, the group has 1 slot
323 * - If configured for 512 sequence numbers per queue, the group has 2 slots
325 * - If configured for 32 sequence numbers per queue, the group has 32 slots
327 * This ioctl returns the group's number of in-use slots. If its occupancy is
328 * 0, the group's sequence number allocation can be reconfigured.
331 * - group: Sequence number group ID.
332 * - padding0: Reserved for future use.
335 * - response.status: Detailed error code. In certain cases, such as if the
336 * ioctl request arg is invalid, the driver won't set status.
337 * - response.id: Specified group's number of used slots.
339 struct dlb2_get_sn_occupancy_args {
340 /* Output parameters */
341 struct dlb2_cmd_response response;
342 /* Input parameters */
347 enum dlb2_cq_poll_modes {
348 DLB2_CQ_POLL_MODE_STD,
349 DLB2_CQ_POLL_MODE_SPARSE,
351 /* NUM_DLB2_CQ_POLL_MODE must be last */
352 NUM_DLB2_CQ_POLL_MODE,
356 * DLB2_CMD_QUERY_CQ_POLL_MODE: Query the CQ poll mode setting
359 * - response.status: Detailed error code. In certain cases, such as if the
360 * ioctl request arg is invalid, the driver won't set status.
361 * - response.id: CQ poll mode (see enum dlb2_cq_poll_modes).
363 struct dlb2_query_cq_poll_mode_args {
364 /* Output parameters */
365 struct dlb2_cmd_response response;
368 /********************************/
369 /* 'scheduling domain' commands */
370 /********************************/
373 * DLB2_DOMAIN_CMD_CREATE_LDB_QUEUE: Configure a load-balanced queue.
375 * - num_atomic_inflights: This specifies the amount of temporary atomic QE
376 * storage for this queue. If zero, the queue will not support atomic
378 * - num_sequence_numbers: This specifies the number of sequence numbers used
379 * by this queue. If zero, the queue will not support ordered scheduling.
380 * If non-zero, the queue will not support unordered scheduling.
381 * - num_qid_inflights: The maximum number of QEs that can be inflight
382 * (scheduled to a CQ but not completed) at any time. If
383 * num_sequence_numbers is non-zero, num_qid_inflights must be set equal
384 * to num_sequence_numbers.
385 * - lock_id_comp_level: Lock ID compression level. Specifies the number of
386 * unique lock IDs the queue should compress down to. Valid compression
387 * levels: 0, 64, 128, 256, 512, 1k, 2k, 4k, 64k. If lock_id_comp_level is
388 * 0, the queue won't compress its lock IDs.
389 * - depth_threshold: DLB sets two bits in the received QE to indicate the
390 * depth of the queue relative to the threshold before scheduling the
392 * - 2’b11: depth > threshold
393 * - 2’b10: threshold >= depth > 0.75 * threshold
394 * - 2’b01: 0.75 * threshold >= depth > 0.5 * threshold
395 * - 2’b00: depth <= 0.5 * threshold
396 * - padding0: Reserved for future use.
399 * - response.status: Detailed error code. In certain cases, such as if the
400 * ioctl request arg is invalid, the driver won't set status.
401 * - response.id: Queue ID.
403 struct dlb2_create_ldb_queue_args {
404 /* Output parameters */
405 struct dlb2_cmd_response response;
406 /* Input parameters */
407 __u32 num_sequence_numbers;
408 __u32 num_qid_inflights;
409 __u32 num_atomic_inflights;
410 __u32 lock_id_comp_level;
411 __u32 depth_threshold;
416 * DLB2_DOMAIN_CMD_CREATE_DIR_QUEUE: Configure a directed queue.
418 * - port_id: Port ID. If the corresponding directed port is already created,
419 * specify its ID here. Else this argument must be 0xFFFFFFFF to indicate
420 * that the queue is being created before the port.
421 * - depth_threshold: DLB sets two bits in the received QE to indicate the
422 * depth of the queue relative to the threshold before scheduling the
424 * - 2’b11: depth > threshold
425 * - 2’b10: threshold >= depth > 0.75 * threshold
426 * - 2’b01: 0.75 * threshold >= depth > 0.5 * threshold
427 * - 2’b00: depth <= 0.5 * threshold
430 * - response.status: Detailed error code. In certain cases, such as if the
431 * ioctl request arg is invalid, the driver won't set status.
432 * - response.id: Queue ID.
434 struct dlb2_create_dir_queue_args {
435 /* Output parameters */
436 struct dlb2_cmd_response response;
437 /* Input parameters */
439 __u32 depth_threshold;
443 * DLB2_DOMAIN_CMD_CREATE_LDB_PORT: Configure a load-balanced port.
445 * - cq_depth: Depth of the port's CQ. Must be a power-of-two between 8 and
447 * - cq_depth_threshold: CQ depth interrupt threshold. A value of N means that
448 * the CQ interrupt won't fire until there are N or more outstanding CQ
450 * - num_hist_list_entries: Number of history list entries. This must be
451 * greater than or equal cq_depth.
452 * - cos_id: class-of-service to allocate this port from. Must be between 0 and
454 * - cos_strict: If set, return an error if there are no available ports in the
455 * requested class-of-service. Else, allocate the port from a different
456 * class-of-service if the requested class has no available ports.
458 * - padding0: Reserved for future use.
461 * - response.status: Detailed error code. In certain cases, such as if the
462 * ioctl request arg is invalid, the driver won't set status.
463 * - response.id: port ID.
466 struct dlb2_create_ldb_port_args {
467 /* Output parameters */
468 struct dlb2_cmd_response response;
469 /* Input parameters */
471 __u16 cq_depth_threshold;
472 __u16 cq_history_list_size;
478 * DLB2_DOMAIN_CMD_CREATE_DIR_PORT: Configure a directed port.
480 * - cq_depth: Depth of the port's CQ. Must be a power-of-two between 8 and
482 * - cq_depth_threshold: CQ depth interrupt threshold. A value of N means that
483 * the CQ interrupt won't fire until there are N or more outstanding CQ
485 * - qid: Queue ID. If the corresponding directed queue is already created,
486 * specify its ID here. Else this argument must be 0xFFFFFFFF to indicate
487 * that the port is being created before the queue.
490 * - response.status: Detailed error code. In certain cases, such as if the
491 * ioctl request arg is invalid, the driver won't set status.
492 * - response.id: Port ID.
494 struct dlb2_create_dir_port_args {
495 /* Output parameters */
496 struct dlb2_cmd_response response;
497 /* Input parameters */
499 __u16 cq_depth_threshold;
504 * DLB2_DOMAIN_CMD_START_DOMAIN: Mark the end of the domain configuration. This
505 * must be called before passing QEs into the device, and no configuration
506 * ioctls can be issued once the domain has started. Sending QEs into the
507 * device before calling this ioctl will result in undefined behavior.
512 * - response.status: Detailed error code. In certain cases, such as if the
513 * ioctl request arg is invalid, the driver won't set status.
515 struct dlb2_start_domain_args {
516 /* Output parameters */
517 struct dlb2_cmd_response response;
521 * DLB2_DOMAIN_CMD_MAP_QID: Map a load-balanced queue to a load-balanced port.
523 * - port_id: Load-balanced port ID.
524 * - qid: Load-balanced queue ID.
525 * - priority: Queue->port service priority.
526 * - padding0: Reserved for future use.
529 * - response.status: Detailed error code. In certain cases, such as if the
530 * ioctl request arg is invalid, the driver won't set status.
532 struct dlb2_map_qid_args {
533 /* Output parameters */
534 struct dlb2_cmd_response response;
535 /* Input parameters */
543 * DLB2_DOMAIN_CMD_UNMAP_QID: Unmap a load-balanced queue to a load-balanced
546 * - port_id: Load-balanced port ID.
547 * - qid: Load-balanced queue ID.
550 * - response.status: Detailed error code. In certain cases, such as if the
551 * ioctl request arg is invalid, the driver won't set status.
553 struct dlb2_unmap_qid_args {
554 /* Output parameters */
555 struct dlb2_cmd_response response;
556 /* Input parameters */
562 * DLB2_DOMAIN_CMD_ENABLE_LDB_PORT: Enable scheduling to a load-balanced port.
564 * - port_id: Load-balanced port ID.
565 * - padding0: Reserved for future use.
568 * - response.status: Detailed error code. In certain cases, such as if the
569 * ioctl request arg is invalid, the driver won't set status.
571 struct dlb2_enable_ldb_port_args {
572 /* Output parameters */
573 struct dlb2_cmd_response response;
574 /* Input parameters */
580 * DLB2_DOMAIN_CMD_ENABLE_DIR_PORT: Enable scheduling to a directed port.
582 * - port_id: Directed port ID.
583 * - padding0: Reserved for future use.
586 * - response.status: Detailed error code. In certain cases, such as if the
587 * ioctl request arg is invalid, the driver won't set status.
589 struct dlb2_enable_dir_port_args {
590 /* Output parameters */
591 struct dlb2_cmd_response response;
592 /* Input parameters */
597 * DLB2_DOMAIN_CMD_DISABLE_LDB_PORT: Disable scheduling to a load-balanced
600 * - port_id: Load-balanced port ID.
601 * - padding0: Reserved for future use.
604 * - response.status: Detailed error code. In certain cases, such as if the
605 * ioctl request arg is invalid, the driver won't set status.
607 struct dlb2_disable_ldb_port_args {
608 /* Output parameters */
609 struct dlb2_cmd_response response;
610 /* Input parameters */
616 * DLB2_DOMAIN_CMD_DISABLE_DIR_PORT: Disable scheduling to a directed port.
618 * - port_id: Directed port ID.
619 * - padding0: Reserved for future use.
622 * - response.status: Detailed error code. In certain cases, such as if the
623 * ioctl request arg is invalid, the driver won't set status.
625 struct dlb2_disable_dir_port_args {
626 /* Output parameters */
627 struct dlb2_cmd_response response;
628 /* Input parameters */
634 * DLB2_DOMAIN_CMD_GET_LDB_QUEUE_DEPTH: Get a load-balanced queue's depth.
636 * - queue_id: The load-balanced queue ID.
637 * - padding0: Reserved for future use.
640 * - response.status: Detailed error code. In certain cases, such as if the
641 * ioctl request arg is invalid, the driver won't set status.
642 * - response.id: queue depth.
644 struct dlb2_get_ldb_queue_depth_args {
645 /* Output parameters */
646 struct dlb2_cmd_response response;
647 /* Input parameters */
653 * DLB2_DOMAIN_CMD_DIR_QUEUE_DEPTH: Get a directed queue's depth.
655 * - queue_id: The directed queue ID.
656 * - padding0: Reserved for future use.
659 * - response.status: Detailed error code. In certain cases, such as if the
660 * ioctl request arg is invalid, the driver won't set status.
661 * - response.id: queue depth.
663 struct dlb2_get_dir_queue_depth_args {
664 /* Output parameters */
665 struct dlb2_cmd_response response;
666 /* Input parameters */
672 * DLB2_DOMAIN_CMD_PENDING_PORT_UNMAPS: Get number of queue unmap operations in
673 * progress for a load-balanced port.
675 * Note: This is a snapshot; the number of unmap operations in progress
676 * is subject to change at any time.
679 * - port_id: Load-balanced port ID.
682 * - response.status: Detailed error code. In certain cases, such as if the
683 * ioctl request arg is invalid, the driver won't set status.
684 * - response.id: number of unmaps in progress.
686 struct dlb2_pending_port_unmaps_args {
687 /* Output parameters */
688 struct dlb2_cmd_response response;
689 /* Input parameters */
695 * DLB2_DOMAIN_CMD_ENABLE_CQ_WEIGHT: Enable QE-weight based scheduling on a
696 * load-balanced port's CQ and configures the CQ's weight limit.
698 * This must be called after creating the port but before starting the
699 * domain. The QE weight limit must be non-zero and cannot exceed the
703 * - port_id: Load-balanced port ID.
704 * - limit: QE weight limit.
707 * - response.status: Detailed error code. In certain cases, such as if the
708 * ioctl request arg is invalid, the driver won't set status.
709 * - response.id: number of unmaps in progress.
711 struct dlb2_enable_cq_weight_args {
712 /* Output parameters */
713 struct dlb2_cmd_response response;
714 /* Input parameters */
720 * Mapping sizes for memory mapping the consumer queue (CQ) memory space, and
721 * producer port (PP) MMIO space.
723 #define DLB2_CQ_SIZE 65536
724 #define DLB2_PP_SIZE 4096
727 #endif /* __DLB2_USER_H */