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,
52 static const char dlb2_error_strings[][128] = {
54 "DLB2_ST_NAME_EXISTS",
55 "DLB2_ST_DOMAIN_UNAVAILABLE",
56 "DLB2_ST_LDB_PORTS_UNAVAILABLE",
57 "DLB2_ST_DIR_PORTS_UNAVAILABLE",
58 "DLB2_ST_LDB_QUEUES_UNAVAILABLE",
59 "DLB2_ST_LDB_CREDITS_UNAVAILABLE",
60 "DLB2_ST_DIR_CREDITS_UNAVAILABLE",
61 "DLB2_ST_CREDITS_UNAVAILABLE",
62 "DLB2_ST_SEQUENCE_NUMBERS_UNAVAILABLE",
63 "DLB2_ST_INVALID_DOMAIN_ID",
64 "DLB2_ST_INVALID_QID_INFLIGHT_ALLOCATION",
65 "DLB2_ST_ATOMIC_INFLIGHTS_UNAVAILABLE",
66 "DLB2_ST_HIST_LIST_ENTRIES_UNAVAILABLE",
67 "DLB2_ST_INVALID_LDB_QUEUE_ID",
68 "DLB2_ST_INVALID_CQ_DEPTH",
69 "DLB2_ST_INVALID_CQ_VIRT_ADDR",
70 "DLB2_ST_INVALID_PORT_ID",
71 "DLB2_ST_INVALID_QID",
72 "DLB2_ST_INVALID_PRIORITY",
73 "DLB2_ST_NO_QID_SLOTS_AVAILABLE",
74 "DLB2_ST_INVALID_DIR_QUEUE_ID",
75 "DLB2_ST_DIR_QUEUES_UNAVAILABLE",
76 "DLB2_ST_DOMAIN_NOT_CONFIGURED",
77 "DLB2_ST_INTERNAL_ERROR",
78 "DLB2_ST_DOMAIN_IN_USE",
79 "DLB2_ST_DOMAIN_NOT_FOUND",
80 "DLB2_ST_QUEUE_NOT_FOUND",
81 "DLB2_ST_DOMAIN_STARTED",
82 "DLB2_ST_DOMAIN_NOT_STARTED",
83 "DLB2_ST_LDB_PORT_REQUIRED_FOR_LDB_QUEUES",
84 "DLB2_ST_DOMAIN_RESET_FAILED",
86 "DLB2_ST_INVALID_HIST_LIST_DEPTH",
88 "DLB2_ST_INVALID_LOCK_ID_COMP_LEVEL",
89 "DLB2_ST_INVALID_COS_ID",
92 struct dlb2_cmd_response {
93 __u32 status; /* Interpret using enum dlb2_error */
101 #define DLB2_DEVICE_VERSION(x) (((x) >> 8) & 0xFF)
102 #define DLB2_DEVICE_REVISION(x) ((x) & 0xFF)
104 enum dlb2_revisions {
109 * DLB2_CMD_GET_DEVICE_VERSION: Query the DLB device version.
111 * This ioctl interface is the same in all driver versions and is always
115 * - response.status: Detailed error code. In certain cases, such as if the
116 * ioctl request arg is invalid, the driver won't set status.
117 * - response.id[7:0]: Device revision.
118 * - response.id[15:8]: Device version.
121 struct dlb2_get_device_version_args {
122 /* Output parameters */
123 struct dlb2_cmd_response response;
127 * DLB2_CMD_CREATE_SCHED_DOMAIN: Create a DLB 2.0 scheduling domain and reserve
128 * its hardware resources. This command returns the newly created domain
129 * ID and a file descriptor for accessing the domain.
132 * - num_ldb_queues: Number of load-balanced queues.
133 * - num_ldb_ports: Number of load-balanced ports that can be allocated from
134 * any class-of-service with available ports.
135 * - num_cos_ldb_ports[4]: Number of load-balanced ports from
136 * classes-of-service 0-3.
137 * - num_dir_ports: Number of directed ports. A directed port has one directed
138 * queue, so no num_dir_queues argument is necessary.
139 * - num_atomic_inflights: This specifies the amount of temporary atomic QE
140 * storage for the domain. This storage is divided among the domain's
141 * load-balanced queues that are configured for atomic scheduling.
142 * - num_hist_list_entries: Amount of history list storage. This is divided
143 * among the domain's CQs.
144 * - num_ldb_credits: Amount of load-balanced QE storage (QED). QEs occupy this
145 * space until they are scheduled to a load-balanced CQ. One credit
146 * represents the storage for one QE.
147 * - num_dir_credits: Amount of directed QE storage (DQED). QEs occupy this
148 * space until they are scheduled to a directed CQ. One credit represents
149 * the storage for one QE.
150 * - cos_strict: If set, return an error if there are insufficient ports in
151 * class-of-service N to satisfy the num_ldb_ports_cosN argument. If
152 * unset, attempt to fulfill num_ldb_ports_cosN arguments from other
153 * classes-of-service if class N does not contain enough free ports.
154 * - padding1: Reserved for future use.
157 * - response.status: Detailed error code. In certain cases, such as if the
158 * ioctl request arg is invalid, the driver won't set status.
159 * - response.id: domain ID.
160 * - domain_fd: file descriptor for performing the domain's ioctl operations
161 * - padding0: Reserved for future use.
163 struct dlb2_create_sched_domain_args {
164 /* Output parameters */
165 struct dlb2_cmd_response response;
168 /* Input parameters */
169 __u32 num_ldb_queues;
171 __u32 num_cos_ldb_ports[4];
173 __u32 num_atomic_inflights;
174 __u32 num_hist_list_entries;
177 __u32 num_ldb_credits;
178 __u32 num_dir_credits;
189 * DLB2_CMD_GET_NUM_RESOURCES: Return the number of available resources
190 * (queues, ports, etc.) that this device owns.
193 * - num_domains: Number of available scheduling domains.
194 * - num_ldb_queues: Number of available load-balanced queues.
195 * - num_ldb_ports: Total number of available load-balanced ports.
196 * - num_cos_ldb_ports[4]: Number of available load-balanced ports from
197 * classes-of-service 0-3.
198 * - num_dir_ports: Number of available directed ports. There is one directed
199 * queue for every directed port.
200 * - num_atomic_inflights: Amount of available temporary atomic QE storage.
201 * - num_hist_list_entries: Amount of history list storage.
202 * - max_contiguous_hist_list_entries: History list storage is allocated in
203 * a contiguous chunk, and this return value is the longest available
204 * contiguous range of history list entries.
205 * - num_ldb_credits: Amount of available load-balanced QE storage.
206 * - num_dir_credits: Amount of available directed QE storage.
207 * - response.status: Detailed error code. In certain cases, such as if the
208 * ioctl request arg is invalid, the driver won't set status.
210 struct dlb2_get_num_resources_args {
211 /* Output parameters */
212 struct dlb2_cmd_response response;
213 __u32 num_sched_domains;
214 __u32 num_ldb_queues;
216 __u32 num_cos_ldb_ports[4];
218 __u32 num_atomic_inflights;
219 __u32 num_hist_list_entries;
220 __u32 max_contiguous_hist_list_entries;
223 __u32 num_ldb_credits;
224 __u32 num_dir_credits;
233 * DLB2_CMD_SET_SN_ALLOCATION: Configure a sequence number group (PF only)
236 * - group: Sequence number group ID.
237 * - num: Number of sequence numbers per queue.
240 * - response.status: Detailed error code. In certain cases, such as if the
241 * ioctl request arg is invalid, the driver won't set status.
243 struct dlb2_set_sn_allocation_args {
244 /* Output parameters */
245 struct dlb2_cmd_response response;
246 /* Input parameters */
252 * DLB2_CMD_GET_SN_ALLOCATION: Get a sequence number group's configuration
255 * - group: Sequence number group ID.
256 * - padding0: Reserved for future use.
259 * - response.status: Detailed error code. In certain cases, such as if the
260 * ioctl request arg is invalid, the driver won't set status.
261 * - response.id: Specified group's number of sequence numbers per queue.
263 struct dlb2_get_sn_allocation_args {
264 /* Output parameters */
265 struct dlb2_cmd_response response;
266 /* Input parameters */
272 * DLB2_CMD_SET_COS_BW: Set a bandwidth allocation percentage for a
273 * load-balanced port class-of-service (PF only).
276 * - cos_id: class-of-service ID, between 0 and 3 (inclusive).
277 * - bandwidth: class-of-service bandwidth percentage. Total bandwidth
278 * percentages across all 4 classes cannot exceed 100%.
281 * - response.status: Detailed error code. In certain cases, such as if the
282 * ioctl request arg is invalid, the driver won't set status.
284 struct dlb2_set_cos_bw_args {
285 /* Output parameters */
286 struct dlb2_cmd_response response;
287 /* Input parameters */
293 * DLB2_CMD_GET_COS_BW: Get the bandwidth allocation percentage for a
294 * load-balanced port class-of-service.
297 * - cos_id: class-of-service ID, between 0 and 3 (inclusive).
298 * - padding0: Reserved for future use.
301 * - response.status: Detailed error code. In certain cases, such as if the
302 * ioctl request arg is invalid, the driver won't set status.
303 * - response.id: Specified class's bandwidth percentage.
305 struct dlb2_get_cos_bw_args {
306 /* Output parameters */
307 struct dlb2_cmd_response response;
308 /* Input parameters */
314 * DLB2_CMD_GET_SN_OCCUPANCY: Get a sequence number group's occupancy
316 * Each sequence number group has one or more slots, depending on its
317 * configuration. I.e.:
318 * - If configured for 1024 sequence numbers per queue, the group has 1 slot
319 * - If configured for 512 sequence numbers per queue, the group has 2 slots
321 * - If configured for 32 sequence numbers per queue, the group has 32 slots
323 * This ioctl returns the group's number of in-use slots. If its occupancy is
324 * 0, the group's sequence number allocation can be reconfigured.
327 * - group: Sequence number group ID.
328 * - padding0: Reserved for future use.
331 * - response.status: Detailed error code. In certain cases, such as if the
332 * ioctl request arg is invalid, the driver won't set status.
333 * - response.id: Specified group's number of used slots.
335 struct dlb2_get_sn_occupancy_args {
336 /* Output parameters */
337 struct dlb2_cmd_response response;
338 /* Input parameters */
343 enum dlb2_cq_poll_modes {
344 DLB2_CQ_POLL_MODE_STD,
345 DLB2_CQ_POLL_MODE_SPARSE,
347 /* NUM_DLB2_CQ_POLL_MODE must be last */
348 NUM_DLB2_CQ_POLL_MODE,
352 * DLB2_CMD_QUERY_CQ_POLL_MODE: Query the CQ poll mode setting
355 * - response.status: Detailed error code. In certain cases, such as if the
356 * ioctl request arg is invalid, the driver won't set status.
357 * - response.id: CQ poll mode (see enum dlb2_cq_poll_modes).
359 struct dlb2_query_cq_poll_mode_args {
360 /* Output parameters */
361 struct dlb2_cmd_response response;
364 /********************************/
365 /* 'scheduling domain' commands */
366 /********************************/
369 * DLB2_DOMAIN_CMD_CREATE_LDB_QUEUE: Configure a load-balanced queue.
371 * - num_atomic_inflights: This specifies the amount of temporary atomic QE
372 * storage for this queue. If zero, the queue will not support atomic
374 * - num_sequence_numbers: This specifies the number of sequence numbers used
375 * by this queue. If zero, the queue will not support ordered scheduling.
376 * If non-zero, the queue will not support unordered scheduling.
377 * - num_qid_inflights: The maximum number of QEs that can be inflight
378 * (scheduled to a CQ but not completed) at any time. If
379 * num_sequence_numbers is non-zero, num_qid_inflights must be set equal
380 * to num_sequence_numbers.
381 * - lock_id_comp_level: Lock ID compression level. Specifies the number of
382 * unique lock IDs the queue should compress down to. Valid compression
383 * levels: 0, 64, 128, 256, 512, 1k, 2k, 4k, 64k. If lock_id_comp_level is
384 * 0, the queue won't compress its lock IDs.
385 * - depth_threshold: DLB sets two bits in the received QE to indicate the
386 * depth of the queue relative to the threshold before scheduling the
388 * - 2’b11: depth > threshold
389 * - 2’b10: threshold >= depth > 0.75 * threshold
390 * - 2’b01: 0.75 * threshold >= depth > 0.5 * threshold
391 * - 2’b00: depth <= 0.5 * threshold
392 * - padding0: Reserved for future use.
395 * - response.status: Detailed error code. In certain cases, such as if the
396 * ioctl request arg is invalid, the driver won't set status.
397 * - response.id: Queue ID.
399 struct dlb2_create_ldb_queue_args {
400 /* Output parameters */
401 struct dlb2_cmd_response response;
402 /* Input parameters */
403 __u32 num_sequence_numbers;
404 __u32 num_qid_inflights;
405 __u32 num_atomic_inflights;
406 __u32 lock_id_comp_level;
407 __u32 depth_threshold;
412 * DLB2_DOMAIN_CMD_CREATE_DIR_QUEUE: Configure a directed queue.
414 * - port_id: Port ID. If the corresponding directed port is already created,
415 * specify its ID here. Else this argument must be 0xFFFFFFFF to indicate
416 * that the queue is being created before the port.
417 * - depth_threshold: DLB sets two bits in the received QE to indicate the
418 * depth of the queue relative to the threshold before scheduling the
420 * - 2’b11: depth > threshold
421 * - 2’b10: threshold >= depth > 0.75 * threshold
422 * - 2’b01: 0.75 * threshold >= depth > 0.5 * threshold
423 * - 2’b00: depth <= 0.5 * threshold
426 * - response.status: Detailed error code. In certain cases, such as if the
427 * ioctl request arg is invalid, the driver won't set status.
428 * - response.id: Queue ID.
430 struct dlb2_create_dir_queue_args {
431 /* Output parameters */
432 struct dlb2_cmd_response response;
433 /* Input parameters */
435 __u32 depth_threshold;
439 * DLB2_DOMAIN_CMD_CREATE_LDB_PORT: Configure a load-balanced port.
441 * - cq_depth: Depth of the port's CQ. Must be a power-of-two between 8 and
443 * - cq_depth_threshold: CQ depth interrupt threshold. A value of N means that
444 * the CQ interrupt won't fire until there are N or more outstanding CQ
446 * - num_hist_list_entries: Number of history list entries. This must be
447 * greater than or equal cq_depth.
448 * - cos_id: class-of-service to allocate this port from. Must be between 0 and
450 * - cos_strict: If set, return an error if there are no available ports in the
451 * requested class-of-service. Else, allocate the port from a different
452 * class-of-service if the requested class has no available ports.
454 * - padding0: Reserved for future use.
457 * - response.status: Detailed error code. In certain cases, such as if the
458 * ioctl request arg is invalid, the driver won't set status.
459 * - response.id: port ID.
462 struct dlb2_create_ldb_port_args {
463 /* Output parameters */
464 struct dlb2_cmd_response response;
465 /* Input parameters */
467 __u16 cq_depth_threshold;
468 __u16 cq_history_list_size;
474 * DLB2_DOMAIN_CMD_CREATE_DIR_PORT: Configure a directed port.
476 * - cq_depth: Depth of the port's CQ. Must be a power-of-two between 8 and
478 * - cq_depth_threshold: CQ depth interrupt threshold. A value of N means that
479 * the CQ interrupt won't fire until there are N or more outstanding CQ
481 * - qid: Queue ID. If the corresponding directed queue is already created,
482 * specify its ID here. Else this argument must be 0xFFFFFFFF to indicate
483 * that the port is being created before the queue.
486 * - response.status: Detailed error code. In certain cases, such as if the
487 * ioctl request arg is invalid, the driver won't set status.
488 * - response.id: Port ID.
490 struct dlb2_create_dir_port_args {
491 /* Output parameters */
492 struct dlb2_cmd_response response;
493 /* Input parameters */
495 __u16 cq_depth_threshold;
500 * DLB2_DOMAIN_CMD_START_DOMAIN: Mark the end of the domain configuration. This
501 * must be called before passing QEs into the device, and no configuration
502 * ioctls can be issued once the domain has started. Sending QEs into the
503 * device before calling this ioctl will result in undefined behavior.
508 * - response.status: Detailed error code. In certain cases, such as if the
509 * ioctl request arg is invalid, the driver won't set status.
511 struct dlb2_start_domain_args {
512 /* Output parameters */
513 struct dlb2_cmd_response response;
517 * DLB2_DOMAIN_CMD_MAP_QID: Map a load-balanced queue to a load-balanced port.
519 * - port_id: Load-balanced port ID.
520 * - qid: Load-balanced queue ID.
521 * - priority: Queue->port service priority.
522 * - padding0: Reserved for future use.
525 * - response.status: Detailed error code. In certain cases, such as if the
526 * ioctl request arg is invalid, the driver won't set status.
528 struct dlb2_map_qid_args {
529 /* Output parameters */
530 struct dlb2_cmd_response response;
531 /* Input parameters */
539 * DLB2_DOMAIN_CMD_UNMAP_QID: Unmap a load-balanced queue to a load-balanced
542 * - port_id: Load-balanced port ID.
543 * - qid: Load-balanced queue ID.
546 * - response.status: Detailed error code. In certain cases, such as if the
547 * ioctl request arg is invalid, the driver won't set status.
549 struct dlb2_unmap_qid_args {
550 /* Output parameters */
551 struct dlb2_cmd_response response;
552 /* Input parameters */
558 * DLB2_DOMAIN_CMD_ENABLE_LDB_PORT: Enable scheduling to a load-balanced port.
560 * - port_id: Load-balanced port ID.
561 * - padding0: Reserved for future use.
564 * - response.status: Detailed error code. In certain cases, such as if the
565 * ioctl request arg is invalid, the driver won't set status.
567 struct dlb2_enable_ldb_port_args {
568 /* Output parameters */
569 struct dlb2_cmd_response response;
570 /* Input parameters */
576 * DLB2_DOMAIN_CMD_ENABLE_DIR_PORT: Enable scheduling to a directed port.
578 * - port_id: Directed port ID.
579 * - padding0: Reserved for future use.
582 * - response.status: Detailed error code. In certain cases, such as if the
583 * ioctl request arg is invalid, the driver won't set status.
585 struct dlb2_enable_dir_port_args {
586 /* Output parameters */
587 struct dlb2_cmd_response response;
588 /* Input parameters */
593 * DLB2_DOMAIN_CMD_DISABLE_LDB_PORT: Disable scheduling to a load-balanced
596 * - port_id: Load-balanced port ID.
597 * - padding0: Reserved for future use.
600 * - response.status: Detailed error code. In certain cases, such as if the
601 * ioctl request arg is invalid, the driver won't set status.
603 struct dlb2_disable_ldb_port_args {
604 /* Output parameters */
605 struct dlb2_cmd_response response;
606 /* Input parameters */
612 * DLB2_DOMAIN_CMD_DISABLE_DIR_PORT: Disable scheduling to a directed port.
614 * - port_id: Directed port ID.
615 * - padding0: Reserved for future use.
618 * - response.status: Detailed error code. In certain cases, such as if the
619 * ioctl request arg is invalid, the driver won't set status.
621 struct dlb2_disable_dir_port_args {
622 /* Output parameters */
623 struct dlb2_cmd_response response;
624 /* Input parameters */
630 * DLB2_DOMAIN_CMD_GET_LDB_QUEUE_DEPTH: Get a load-balanced queue's depth.
632 * - queue_id: The load-balanced queue ID.
633 * - padding0: Reserved for future use.
636 * - response.status: Detailed error code. In certain cases, such as if the
637 * ioctl request arg is invalid, the driver won't set status.
638 * - response.id: queue depth.
640 struct dlb2_get_ldb_queue_depth_args {
641 /* Output parameters */
642 struct dlb2_cmd_response response;
643 /* Input parameters */
649 * DLB2_DOMAIN_CMD_DIR_QUEUE_DEPTH: Get a directed queue's depth.
651 * - queue_id: The directed queue ID.
652 * - padding0: Reserved for future use.
655 * - response.status: Detailed error code. In certain cases, such as if the
656 * ioctl request arg is invalid, the driver won't set status.
657 * - response.id: queue depth.
659 struct dlb2_get_dir_queue_depth_args {
660 /* Output parameters */
661 struct dlb2_cmd_response response;
662 /* Input parameters */
668 * DLB2_DOMAIN_CMD_PENDING_PORT_UNMAPS: Get number of queue unmap operations in
669 * progress for a load-balanced port.
671 * Note: This is a snapshot; the number of unmap operations in progress
672 * is subject to change at any time.
675 * - port_id: Load-balanced port ID.
678 * - response.status: Detailed error code. In certain cases, such as if the
679 * ioctl request arg is invalid, the driver won't set status.
680 * - response.id: number of unmaps in progress.
682 struct dlb2_pending_port_unmaps_args {
683 /* Output parameters */
684 struct dlb2_cmd_response response;
685 /* Input parameters */
691 * Mapping sizes for memory mapping the consumer queue (CQ) memory space, and
692 * producer port (PP) MMIO space.
694 #define DLB2_CQ_SIZE 65536
695 #define DLB2_PP_SIZE 4096
698 #endif /* __DLB2_USER_H */