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_SEQUENCE_NUMBERS_UNAVAILABLE,
22 DLB2_ST_INVALID_DOMAIN_ID,
23 DLB2_ST_INVALID_QID_INFLIGHT_ALLOCATION,
24 DLB2_ST_ATOMIC_INFLIGHTS_UNAVAILABLE,
25 DLB2_ST_HIST_LIST_ENTRIES_UNAVAILABLE,
26 DLB2_ST_INVALID_LDB_QUEUE_ID,
27 DLB2_ST_INVALID_CQ_DEPTH,
28 DLB2_ST_INVALID_CQ_VIRT_ADDR,
29 DLB2_ST_INVALID_PORT_ID,
31 DLB2_ST_INVALID_PRIORITY,
32 DLB2_ST_NO_QID_SLOTS_AVAILABLE,
33 DLB2_ST_INVALID_DIR_QUEUE_ID,
34 DLB2_ST_DIR_QUEUES_UNAVAILABLE,
35 DLB2_ST_DOMAIN_NOT_CONFIGURED,
36 DLB2_ST_INTERNAL_ERROR,
37 DLB2_ST_DOMAIN_IN_USE,
38 DLB2_ST_DOMAIN_NOT_FOUND,
39 DLB2_ST_QUEUE_NOT_FOUND,
40 DLB2_ST_DOMAIN_STARTED,
41 DLB2_ST_DOMAIN_NOT_STARTED,
42 DLB2_ST_LDB_PORT_REQUIRED_FOR_LDB_QUEUES,
43 DLB2_ST_DOMAIN_RESET_FAILED,
45 DLB2_ST_INVALID_HIST_LIST_DEPTH,
47 DLB2_ST_INVALID_LOCK_ID_COMP_LEVEL,
48 DLB2_ST_INVALID_COS_ID,
51 static const char dlb2_error_strings[][128] = {
53 "DLB2_ST_NAME_EXISTS",
54 "DLB2_ST_DOMAIN_UNAVAILABLE",
55 "DLB2_ST_LDB_PORTS_UNAVAILABLE",
56 "DLB2_ST_DIR_PORTS_UNAVAILABLE",
57 "DLB2_ST_LDB_QUEUES_UNAVAILABLE",
58 "DLB2_ST_LDB_CREDITS_UNAVAILABLE",
59 "DLB2_ST_DIR_CREDITS_UNAVAILABLE",
60 "DLB2_ST_SEQUENCE_NUMBERS_UNAVAILABLE",
61 "DLB2_ST_INVALID_DOMAIN_ID",
62 "DLB2_ST_INVALID_QID_INFLIGHT_ALLOCATION",
63 "DLB2_ST_ATOMIC_INFLIGHTS_UNAVAILABLE",
64 "DLB2_ST_HIST_LIST_ENTRIES_UNAVAILABLE",
65 "DLB2_ST_INVALID_LDB_QUEUE_ID",
66 "DLB2_ST_INVALID_CQ_DEPTH",
67 "DLB2_ST_INVALID_CQ_VIRT_ADDR",
68 "DLB2_ST_INVALID_PORT_ID",
69 "DLB2_ST_INVALID_QID",
70 "DLB2_ST_INVALID_PRIORITY",
71 "DLB2_ST_NO_QID_SLOTS_AVAILABLE",
72 "DLB2_ST_INVALID_DIR_QUEUE_ID",
73 "DLB2_ST_DIR_QUEUES_UNAVAILABLE",
74 "DLB2_ST_DOMAIN_NOT_CONFIGURED",
75 "DLB2_ST_INTERNAL_ERROR",
76 "DLB2_ST_DOMAIN_IN_USE",
77 "DLB2_ST_DOMAIN_NOT_FOUND",
78 "DLB2_ST_QUEUE_NOT_FOUND",
79 "DLB2_ST_DOMAIN_STARTED",
80 "DLB2_ST_DOMAIN_NOT_STARTED",
81 "DLB2_ST_LDB_PORT_REQUIRED_FOR_LDB_QUEUES",
82 "DLB2_ST_DOMAIN_RESET_FAILED",
84 "DLB2_ST_INVALID_HIST_LIST_DEPTH",
86 "DLB2_ST_INVALID_LOCK_ID_COMP_LEVEL",
87 "DLB2_ST_INVALID_COS_ID",
90 struct dlb2_cmd_response {
91 __u32 status; /* Interpret using enum dlb2_error */
99 #define DLB2_DEVICE_VERSION(x) (((x) >> 8) & 0xFF)
100 #define DLB2_DEVICE_REVISION(x) ((x) & 0xFF)
102 enum dlb2_revisions {
107 * DLB2_CMD_GET_DEVICE_VERSION: Query the DLB device version.
109 * This ioctl interface is the same in all driver versions and is always
113 * - response.status: Detailed error code. In certain cases, such as if the
114 * ioctl request arg is invalid, the driver won't set status.
115 * - response.id[7:0]: Device revision.
116 * - response.id[15:8]: Device version.
119 struct dlb2_get_device_version_args {
120 /* Output parameters */
121 struct dlb2_cmd_response response;
125 * DLB2_CMD_CREATE_SCHED_DOMAIN: Create a DLB 2.0 scheduling domain and reserve
126 * its hardware resources. This command returns the newly created domain
127 * ID and a file descriptor for accessing the domain.
130 * - num_ldb_queues: Number of load-balanced queues.
131 * - num_ldb_ports: Number of load-balanced ports that can be allocated from
132 * any class-of-service with available ports.
133 * - num_cos_ldb_ports[4]: Number of load-balanced ports from
134 * classes-of-service 0-3.
135 * - num_dir_ports: Number of directed ports. A directed port has one directed
136 * queue, so no num_dir_queues argument is necessary.
137 * - num_atomic_inflights: This specifies the amount of temporary atomic QE
138 * storage for the domain. This storage is divided among the domain's
139 * load-balanced queues that are configured for atomic scheduling.
140 * - num_hist_list_entries: Amount of history list storage. This is divided
141 * among the domain's CQs.
142 * - num_ldb_credits: Amount of load-balanced QE storage (QED). QEs occupy this
143 * space until they are scheduled to a load-balanced CQ. One credit
144 * represents the storage for one QE.
145 * - num_dir_credits: Amount of directed QE storage (DQED). QEs occupy this
146 * space until they are scheduled to a directed CQ. One credit represents
147 * the storage for one QE.
148 * - cos_strict: If set, return an error if there are insufficient ports in
149 * class-of-service N to satisfy the num_ldb_ports_cosN argument. If
150 * unset, attempt to fulfill num_ldb_ports_cosN arguments from other
151 * classes-of-service if class N does not contain enough free ports.
152 * - padding1: Reserved for future use.
155 * - response.status: Detailed error code. In certain cases, such as if the
156 * ioctl request arg is invalid, the driver won't set status.
157 * - response.id: domain ID.
158 * - domain_fd: file descriptor for performing the domain's ioctl operations
159 * - padding0: Reserved for future use.
161 struct dlb2_create_sched_domain_args {
162 /* Output parameters */
163 struct dlb2_cmd_response response;
166 /* Input parameters */
167 __u32 num_ldb_queues;
169 __u32 num_cos_ldb_ports[4];
171 __u32 num_atomic_inflights;
172 __u32 num_hist_list_entries;
173 __u32 num_ldb_credits;
174 __u32 num_dir_credits;
180 * DLB2_CMD_GET_NUM_RESOURCES: Return the number of available resources
181 * (queues, ports, etc.) that this device owns.
184 * - num_domains: Number of available scheduling domains.
185 * - num_ldb_queues: Number of available load-balanced queues.
186 * - num_ldb_ports: Total number of available load-balanced ports.
187 * - num_cos_ldb_ports[4]: Number of available load-balanced ports from
188 * classes-of-service 0-3.
189 * - num_dir_ports: Number of available directed ports. There is one directed
190 * queue for every directed port.
191 * - num_atomic_inflights: Amount of available temporary atomic QE storage.
192 * - num_hist_list_entries: Amount of history list storage.
193 * - max_contiguous_hist_list_entries: History list storage is allocated in
194 * a contiguous chunk, and this return value is the longest available
195 * contiguous range of history list entries.
196 * - num_ldb_credits: Amount of available load-balanced QE storage.
197 * - num_dir_credits: Amount of available directed QE storage.
199 struct dlb2_get_num_resources_args {
200 /* Output parameters */
201 __u32 num_sched_domains;
202 __u32 num_ldb_queues;
204 __u32 num_cos_ldb_ports[4];
206 __u32 num_atomic_inflights;
207 __u32 num_hist_list_entries;
208 __u32 max_contiguous_hist_list_entries;
209 __u32 num_ldb_credits;
210 __u32 num_dir_credits;
214 * DLB2_CMD_SET_SN_ALLOCATION: Configure a sequence number group (PF only)
217 * - group: Sequence number group ID.
218 * - num: Number of sequence numbers per queue.
221 * - response.status: Detailed error code. In certain cases, such as if the
222 * ioctl request arg is invalid, the driver won't set status.
224 struct dlb2_set_sn_allocation_args {
225 /* Output parameters */
226 struct dlb2_cmd_response response;
227 /* Input parameters */
233 * DLB2_CMD_GET_SN_ALLOCATION: Get a sequence number group's configuration
236 * - group: Sequence number group ID.
237 * - padding0: Reserved for future use.
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.
242 * - response.id: Specified group's number of sequence numbers per queue.
244 struct dlb2_get_sn_allocation_args {
245 /* Output parameters */
246 struct dlb2_cmd_response response;
247 /* Input parameters */
253 * DLB2_CMD_SET_COS_BW: Set a bandwidth allocation percentage for a
254 * load-balanced port class-of-service (PF only).
257 * - cos_id: class-of-service ID, between 0 and 3 (inclusive).
258 * - bandwidth: class-of-service bandwidth percentage. Total bandwidth
259 * percentages across all 4 classes cannot exceed 100%.
262 * - response.status: Detailed error code. In certain cases, such as if the
263 * ioctl request arg is invalid, the driver won't set status.
265 struct dlb2_set_cos_bw_args {
266 /* Output parameters */
267 struct dlb2_cmd_response response;
268 /* Input parameters */
274 * DLB2_CMD_GET_COS_BW: Get the bandwidth allocation percentage for a
275 * load-balanced port class-of-service.
278 * - cos_id: class-of-service ID, between 0 and 3 (inclusive).
279 * - padding0: Reserved for future use.
282 * - response.status: Detailed error code. In certain cases, such as if the
283 * ioctl request arg is invalid, the driver won't set status.
284 * - response.id: Specified class's bandwidth percentage.
286 struct dlb2_get_cos_bw_args {
287 /* Output parameters */
288 struct dlb2_cmd_response response;
289 /* Input parameters */
295 * DLB2_CMD_GET_SN_OCCUPANCY: Get a sequence number group's occupancy
297 * Each sequence number group has one or more slots, depending on its
298 * configuration. I.e.:
299 * - If configured for 1024 sequence numbers per queue, the group has 1 slot
300 * - If configured for 512 sequence numbers per queue, the group has 2 slots
302 * - If configured for 32 sequence numbers per queue, the group has 32 slots
304 * This ioctl returns the group's number of in-use slots. If its occupancy is
305 * 0, the group's sequence number allocation can be reconfigured.
308 * - group: Sequence number group ID.
309 * - padding0: Reserved for future use.
312 * - response.status: Detailed error code. In certain cases, such as if the
313 * ioctl request arg is invalid, the driver won't set status.
314 * - response.id: Specified group's number of used slots.
316 struct dlb2_get_sn_occupancy_args {
317 /* Output parameters */
318 struct dlb2_cmd_response response;
319 /* Input parameters */
324 enum dlb2_cq_poll_modes {
325 DLB2_CQ_POLL_MODE_STD,
326 DLB2_CQ_POLL_MODE_SPARSE,
328 /* NUM_DLB2_CQ_POLL_MODE must be last */
329 NUM_DLB2_CQ_POLL_MODE,
333 * DLB2_CMD_QUERY_CQ_POLL_MODE: Query the CQ poll mode setting
336 * - response.status: Detailed error code. In certain cases, such as if the
337 * ioctl request arg is invalid, the driver won't set status.
338 * - response.id: CQ poll mode (see enum dlb2_cq_poll_modes).
340 struct dlb2_query_cq_poll_mode_args {
341 /* Output parameters */
342 struct dlb2_cmd_response response;
345 /********************************/
346 /* 'scheduling domain' commands */
347 /********************************/
350 * DLB2_DOMAIN_CMD_CREATE_LDB_QUEUE: Configure a load-balanced queue.
352 * - num_atomic_inflights: This specifies the amount of temporary atomic QE
353 * storage for this queue. If zero, the queue will not support atomic
355 * - num_sequence_numbers: This specifies the number of sequence numbers used
356 * by this queue. If zero, the queue will not support ordered scheduling.
357 * If non-zero, the queue will not support unordered scheduling.
358 * - num_qid_inflights: The maximum number of QEs that can be inflight
359 * (scheduled to a CQ but not completed) at any time. If
360 * num_sequence_numbers is non-zero, num_qid_inflights must be set equal
361 * to num_sequence_numbers.
362 * - lock_id_comp_level: Lock ID compression level. Specifies the number of
363 * unique lock IDs the queue should compress down to. Valid compression
364 * levels: 0, 64, 128, 256, 512, 1k, 2k, 4k, 64k. If lock_id_comp_level is
365 * 0, the queue won't compress its lock IDs.
366 * - depth_threshold: DLB sets two bits in the received QE to indicate the
367 * depth of the queue relative to the threshold before scheduling the
369 * - 2’b11: depth > threshold
370 * - 2’b10: threshold >= depth > 0.75 * threshold
371 * - 2’b01: 0.75 * threshold >= depth > 0.5 * threshold
372 * - 2’b00: depth <= 0.5 * threshold
373 * - padding0: Reserved for future use.
376 * - response.status: Detailed error code. In certain cases, such as if the
377 * ioctl request arg is invalid, the driver won't set status.
378 * - response.id: Queue ID.
380 struct dlb2_create_ldb_queue_args {
381 /* Output parameters */
382 struct dlb2_cmd_response response;
383 /* Input parameters */
384 __u32 num_sequence_numbers;
385 __u32 num_qid_inflights;
386 __u32 num_atomic_inflights;
387 __u32 lock_id_comp_level;
388 __u32 depth_threshold;
393 * DLB2_DOMAIN_CMD_CREATE_DIR_QUEUE: Configure a directed queue.
395 * - port_id: Port ID. If the corresponding directed port is already created,
396 * specify its ID here. Else this argument must be 0xFFFFFFFF to indicate
397 * that the queue is being created before the port.
398 * - depth_threshold: DLB sets two bits in the received QE to indicate the
399 * depth of the queue relative to the threshold before scheduling the
401 * - 2’b11: depth > threshold
402 * - 2’b10: threshold >= depth > 0.75 * threshold
403 * - 2’b01: 0.75 * threshold >= depth > 0.5 * threshold
404 * - 2’b00: depth <= 0.5 * threshold
407 * - response.status: Detailed error code. In certain cases, such as if the
408 * ioctl request arg is invalid, the driver won't set status.
409 * - response.id: Queue ID.
411 struct dlb2_create_dir_queue_args {
412 /* Output parameters */
413 struct dlb2_cmd_response response;
414 /* Input parameters */
416 __u32 depth_threshold;
420 * DLB2_DOMAIN_CMD_CREATE_LDB_PORT: Configure a load-balanced port.
422 * - cq_depth: Depth of the port's CQ. Must be a power-of-two between 8 and
424 * - cq_depth_threshold: CQ depth interrupt threshold. A value of N means that
425 * the CQ interrupt won't fire until there are N or more outstanding CQ
427 * - num_hist_list_entries: Number of history list entries. This must be
428 * greater than or equal cq_depth.
429 * - cos_id: class-of-service to allocate this port from. Must be between 0 and
431 * - cos_strict: If set, return an error if there are no available ports in the
432 * requested class-of-service. Else, allocate the port from a different
433 * class-of-service if the requested class has no available ports.
435 * - padding0: Reserved for future use.
438 * - response.status: Detailed error code. In certain cases, such as if the
439 * ioctl request arg is invalid, the driver won't set status.
440 * - response.id: port ID.
443 struct dlb2_create_ldb_port_args {
444 /* Output parameters */
445 struct dlb2_cmd_response response;
446 /* Input parameters */
448 __u16 cq_depth_threshold;
449 __u16 cq_history_list_size;
455 * DLB2_DOMAIN_CMD_CREATE_DIR_PORT: Configure a directed port.
457 * - cq_depth: Depth of the port's CQ. Must be a power-of-two between 8 and
459 * - cq_depth_threshold: CQ depth interrupt threshold. A value of N means that
460 * the CQ interrupt won't fire until there are N or more outstanding CQ
462 * - qid: Queue ID. If the corresponding directed queue is already created,
463 * specify its ID here. Else this argument must be 0xFFFFFFFF to indicate
464 * that the port is being created before the queue.
467 * - response.status: Detailed error code. In certain cases, such as if the
468 * ioctl request arg is invalid, the driver won't set status.
469 * - response.id: Port ID.
471 struct dlb2_create_dir_port_args {
472 /* Output parameters */
473 struct dlb2_cmd_response response;
474 /* Input parameters */
476 __u16 cq_depth_threshold;
481 * DLB2_DOMAIN_CMD_START_DOMAIN: Mark the end of the domain configuration. This
482 * must be called before passing QEs into the device, and no configuration
483 * ioctls can be issued once the domain has started. Sending QEs into the
484 * device before calling this ioctl will result in undefined behavior.
489 * - response.status: Detailed error code. In certain cases, such as if the
490 * ioctl request arg is invalid, the driver won't set status.
492 struct dlb2_start_domain_args {
493 /* Output parameters */
494 struct dlb2_cmd_response response;
498 * DLB2_DOMAIN_CMD_MAP_QID: Map a load-balanced queue to a load-balanced port.
500 * - port_id: Load-balanced port ID.
501 * - qid: Load-balanced queue ID.
502 * - priority: Queue->port service priority.
503 * - padding0: Reserved for future use.
506 * - response.status: Detailed error code. In certain cases, such as if the
507 * ioctl request arg is invalid, the driver won't set status.
509 struct dlb2_map_qid_args {
510 /* Output parameters */
511 struct dlb2_cmd_response response;
512 /* Input parameters */
520 * DLB2_DOMAIN_CMD_UNMAP_QID: Unmap a load-balanced queue to a load-balanced
523 * - port_id: Load-balanced port ID.
524 * - qid: Load-balanced queue ID.
527 * - response.status: Detailed error code. In certain cases, such as if the
528 * ioctl request arg is invalid, the driver won't set status.
530 struct dlb2_unmap_qid_args {
531 /* Output parameters */
532 struct dlb2_cmd_response response;
533 /* Input parameters */
539 * DLB2_DOMAIN_CMD_ENABLE_LDB_PORT: Enable scheduling to a load-balanced port.
541 * - port_id: Load-balanced port ID.
542 * - padding0: Reserved for future use.
545 * - response.status: Detailed error code. In certain cases, such as if the
546 * ioctl request arg is invalid, the driver won't set status.
548 struct dlb2_enable_ldb_port_args {
549 /* Output parameters */
550 struct dlb2_cmd_response response;
551 /* Input parameters */
557 * DLB2_DOMAIN_CMD_ENABLE_DIR_PORT: Enable scheduling to a directed port.
559 * - port_id: Directed port ID.
560 * - padding0: Reserved for future use.
563 * - response.status: Detailed error code. In certain cases, such as if the
564 * ioctl request arg is invalid, the driver won't set status.
566 struct dlb2_enable_dir_port_args {
567 /* Output parameters */
568 struct dlb2_cmd_response response;
569 /* Input parameters */
574 * DLB2_DOMAIN_CMD_DISABLE_LDB_PORT: Disable scheduling to a load-balanced
577 * - port_id: Load-balanced port ID.
578 * - padding0: Reserved for future use.
581 * - response.status: Detailed error code. In certain cases, such as if the
582 * ioctl request arg is invalid, the driver won't set status.
584 struct dlb2_disable_ldb_port_args {
585 /* Output parameters */
586 struct dlb2_cmd_response response;
587 /* Input parameters */
593 * DLB2_DOMAIN_CMD_DISABLE_DIR_PORT: Disable scheduling to a directed port.
595 * - port_id: Directed port ID.
596 * - padding0: Reserved for future use.
599 * - response.status: Detailed error code. In certain cases, such as if the
600 * ioctl request arg is invalid, the driver won't set status.
602 struct dlb2_disable_dir_port_args {
603 /* Output parameters */
604 struct dlb2_cmd_response response;
605 /* Input parameters */
611 * DLB2_DOMAIN_CMD_GET_LDB_QUEUE_DEPTH: Get a load-balanced queue's depth.
613 * - queue_id: The load-balanced queue ID.
614 * - padding0: Reserved for future use.
617 * - response.status: Detailed error code. In certain cases, such as if the
618 * ioctl request arg is invalid, the driver won't set status.
619 * - response.id: queue depth.
621 struct dlb2_get_ldb_queue_depth_args {
622 /* Output parameters */
623 struct dlb2_cmd_response response;
624 /* Input parameters */
630 * DLB2_DOMAIN_CMD_DIR_QUEUE_DEPTH: Get a directed queue's depth.
632 * - queue_id: The directed 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_dir_queue_depth_args {
641 /* Output parameters */
642 struct dlb2_cmd_response response;
643 /* Input parameters */
649 * DLB2_DOMAIN_CMD_PENDING_PORT_UNMAPS: Get number of queue unmap operations in
650 * progress for a load-balanced port.
652 * Note: This is a snapshot; the number of unmap operations in progress
653 * is subject to change at any time.
656 * - port_id: Load-balanced port ID.
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: number of unmaps in progress.
663 struct dlb2_pending_port_unmaps_args {
664 /* Output parameters */
665 struct dlb2_cmd_response response;
666 /* Input parameters */
672 * Mapping sizes for memory mapping the consumer queue (CQ) memory space, and
673 * producer port (PP) MMIO space.
675 #define DLB2_CQ_SIZE 65536
676 #define DLB2_PP_SIZE 4096
679 #endif /* __DLB2_USER_H */