1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2016-2020 Intel Corporation
5 #ifndef __DLB2_BASE_DLB2_MBOX_H
6 #define __DLB2_BASE_DLB2_MBOX_H
8 #include "dlb2_osdep_types.h"
11 #define DLB2_MBOX_INTERFACE_VERSION 1
14 * The PF uses its PF->VF mailbox to send responses to VF requests, as well as
15 * to send requests of its own (e.g. notifying a VF of an impending FLR).
16 * To avoid communication race conditions, e.g. the PF sends a response and then
17 * sends a request before the VF reads the response, the PF->VF mailbox is
18 * divided into two sections:
19 * - Bytes 0-47: PF responses
20 * - Bytes 48-63: PF requests
22 * Partitioning the PF->VF mailbox allows responses and requests to occupy the
23 * mailbox simultaneously.
25 #define DLB2_PF2VF_RESP_BYTES 48
26 #define DLB2_PF2VF_RESP_BASE 0
27 #define DLB2_PF2VF_RESP_BASE_WORD (DLB2_PF2VF_RESP_BASE / 4)
29 #define DLB2_PF2VF_REQ_BYTES 16
30 #define DLB2_PF2VF_REQ_BASE (DLB2_PF2VF_RESP_BASE + DLB2_PF2VF_RESP_BYTES)
31 #define DLB2_PF2VF_REQ_BASE_WORD (DLB2_PF2VF_REQ_BASE / 4)
34 * Similarly, the VF->PF mailbox is divided into two sections:
35 * - Bytes 0-239: VF requests
36 * -- (Bytes 0-3 are unused due to a hardware errata)
37 * - Bytes 240-255: VF responses
39 #define DLB2_VF2PF_REQ_BYTES 236
40 #define DLB2_VF2PF_REQ_BASE 4
41 #define DLB2_VF2PF_REQ_BASE_WORD (DLB2_VF2PF_REQ_BASE / 4)
43 #define DLB2_VF2PF_RESP_BYTES 16
44 #define DLB2_VF2PF_RESP_BASE (DLB2_VF2PF_REQ_BASE + DLB2_VF2PF_REQ_BYTES)
45 #define DLB2_VF2PF_RESP_BASE_WORD (DLB2_VF2PF_RESP_BASE / 4)
47 /* VF-initiated commands */
48 enum dlb2_mbox_cmd_type {
49 DLB2_MBOX_CMD_REGISTER,
50 DLB2_MBOX_CMD_UNREGISTER,
51 DLB2_MBOX_CMD_GET_NUM_RESOURCES,
52 DLB2_MBOX_CMD_CREATE_SCHED_DOMAIN,
53 DLB2_MBOX_CMD_RESET_SCHED_DOMAIN,
54 DLB2_MBOX_CMD_CREATE_LDB_QUEUE,
55 DLB2_MBOX_CMD_CREATE_DIR_QUEUE,
56 DLB2_MBOX_CMD_CREATE_LDB_PORT,
57 DLB2_MBOX_CMD_CREATE_DIR_PORT,
58 DLB2_MBOX_CMD_ENABLE_LDB_PORT,
59 DLB2_MBOX_CMD_DISABLE_LDB_PORT,
60 DLB2_MBOX_CMD_ENABLE_DIR_PORT,
61 DLB2_MBOX_CMD_DISABLE_DIR_PORT,
62 DLB2_MBOX_CMD_LDB_PORT_OWNED_BY_DOMAIN,
63 DLB2_MBOX_CMD_DIR_PORT_OWNED_BY_DOMAIN,
64 DLB2_MBOX_CMD_MAP_QID,
65 DLB2_MBOX_CMD_UNMAP_QID,
66 DLB2_MBOX_CMD_START_DOMAIN,
67 DLB2_MBOX_CMD_ENABLE_LDB_PORT_INTR,
68 DLB2_MBOX_CMD_ENABLE_DIR_PORT_INTR,
69 DLB2_MBOX_CMD_ARM_CQ_INTR,
70 DLB2_MBOX_CMD_GET_NUM_USED_RESOURCES,
71 DLB2_MBOX_CMD_GET_SN_ALLOCATION,
72 DLB2_MBOX_CMD_GET_LDB_QUEUE_DEPTH,
73 DLB2_MBOX_CMD_GET_DIR_QUEUE_DEPTH,
74 DLB2_MBOX_CMD_PENDING_PORT_UNMAPS,
75 DLB2_MBOX_CMD_GET_COS_BW,
76 DLB2_MBOX_CMD_GET_SN_OCCUPANCY,
77 DLB2_MBOX_CMD_QUERY_CQ_POLL_MODE,
79 /* NUM_QE_CMD_TYPES must be last */
80 NUM_DLB2_MBOX_CMD_TYPES,
83 static const char dlb2_mbox_cmd_type_strings[][128] = {
84 "DLB2_MBOX_CMD_REGISTER",
85 "DLB2_MBOX_CMD_UNREGISTER",
86 "DLB2_MBOX_CMD_GET_NUM_RESOURCES",
87 "DLB2_MBOX_CMD_CREATE_SCHED_DOMAIN",
88 "DLB2_MBOX_CMD_RESET_SCHED_DOMAIN",
89 "DLB2_MBOX_CMD_CREATE_LDB_QUEUE",
90 "DLB2_MBOX_CMD_CREATE_DIR_QUEUE",
91 "DLB2_MBOX_CMD_CREATE_LDB_PORT",
92 "DLB2_MBOX_CMD_CREATE_DIR_PORT",
93 "DLB2_MBOX_CMD_ENABLE_LDB_PORT",
94 "DLB2_MBOX_CMD_DISABLE_LDB_PORT",
95 "DLB2_MBOX_CMD_ENABLE_DIR_PORT",
96 "DLB2_MBOX_CMD_DISABLE_DIR_PORT",
97 "DLB2_MBOX_CMD_LDB_PORT_OWNED_BY_DOMAIN",
98 "DLB2_MBOX_CMD_DIR_PORT_OWNED_BY_DOMAIN",
99 "DLB2_MBOX_CMD_MAP_QID",
100 "DLB2_MBOX_CMD_UNMAP_QID",
101 "DLB2_MBOX_CMD_START_DOMAIN",
102 "DLB2_MBOX_CMD_ENABLE_LDB_PORT_INTR",
103 "DLB2_MBOX_CMD_ENABLE_DIR_PORT_INTR",
104 "DLB2_MBOX_CMD_ARM_CQ_INTR",
105 "DLB2_MBOX_CMD_GET_NUM_USED_RESOURCES",
106 "DLB2_MBOX_CMD_GET_SN_ALLOCATION",
107 "DLB2_MBOX_CMD_GET_LDB_QUEUE_DEPTH",
108 "DLB2_MBOX_CMD_GET_DIR_QUEUE_DEPTH",
109 "DLB2_MBOX_CMD_PENDING_PORT_UNMAPS",
110 "DLB2_MBOX_CMD_GET_COS_BW",
111 "DLB2_MBOX_CMD_GET_SN_OCCUPANCY",
112 "DLB2_MBOX_CMD_QUERY_CQ_POLL_MODE",
115 /* PF-initiated commands */
116 enum dlb2_mbox_vf_cmd_type {
117 DLB2_MBOX_VF_CMD_DOMAIN_ALERT,
118 DLB2_MBOX_VF_CMD_NOTIFICATION,
119 DLB2_MBOX_VF_CMD_IN_USE,
121 /* NUM_DLB2_MBOX_VF_CMD_TYPES must be last */
122 NUM_DLB2_MBOX_VF_CMD_TYPES,
125 static const char dlb2_mbox_vf_cmd_type_strings[][128] = {
126 "DLB2_MBOX_VF_CMD_DOMAIN_ALERT",
127 "DLB2_MBOX_VF_CMD_NOTIFICATION",
128 "DLB2_MBOX_VF_CMD_IN_USE",
131 #define DLB2_MBOX_CMD_TYPE(hdr) \
132 (((struct dlb2_mbox_req_hdr *)hdr)->type)
133 #define DLB2_MBOX_CMD_STRING(hdr) \
134 dlb2_mbox_cmd_type_strings[DLB2_MBOX_CMD_TYPE(hdr)]
136 enum dlb2_mbox_status_type {
137 DLB2_MBOX_ST_SUCCESS,
138 DLB2_MBOX_ST_INVALID_CMD_TYPE,
139 DLB2_MBOX_ST_VERSION_MISMATCH,
140 DLB2_MBOX_ST_INVALID_OWNER_VF,
143 static const char dlb2_mbox_status_type_strings[][128] = {
144 "DLB2_MBOX_ST_SUCCESS",
145 "DLB2_MBOX_ST_INVALID_CMD_TYPE",
146 "DLB2_MBOX_ST_VERSION_MISMATCH",
147 "DLB2_MBOX_ST_INVALID_OWNER_VF",
150 #define DLB2_MBOX_ST_TYPE(hdr) \
151 (((struct dlb2_mbox_resp_hdr *)hdr)->status)
152 #define DLB2_MBOX_ST_STRING(hdr) \
153 dlb2_mbox_status_type_strings[DLB2_MBOX_ST_TYPE(hdr)]
155 /* This structure is always the first field in a request structure */
156 struct dlb2_mbox_req_hdr {
160 /* This structure is always the first field in a response structure */
161 struct dlb2_mbox_resp_hdr {
165 struct dlb2_mbox_register_cmd_req {
166 struct dlb2_mbox_req_hdr hdr;
167 u16 min_interface_version;
168 u16 max_interface_version;
171 struct dlb2_mbox_register_cmd_resp {
172 struct dlb2_mbox_resp_hdr hdr;
173 u32 interface_version;
181 struct dlb2_mbox_unregister_cmd_req {
182 struct dlb2_mbox_req_hdr hdr;
186 struct dlb2_mbox_unregister_cmd_resp {
187 struct dlb2_mbox_resp_hdr hdr;
191 struct dlb2_mbox_get_num_resources_cmd_req {
192 struct dlb2_mbox_req_hdr hdr;
196 struct dlb2_mbox_get_num_resources_cmd_resp {
197 struct dlb2_mbox_resp_hdr hdr;
199 u16 num_sched_domains;
202 u16 num_cos_ldb_ports[4];
204 u32 num_atomic_inflights;
205 u32 num_hist_list_entries;
206 u32 max_contiguous_hist_list_entries;
211 struct dlb2_mbox_create_sched_domain_cmd_req {
212 struct dlb2_mbox_req_hdr hdr;
215 u32 num_cos_ldb_ports[4];
217 u32 num_atomic_inflights;
218 u32 num_hist_list_entries;
226 struct dlb2_mbox_create_sched_domain_cmd_resp {
227 struct dlb2_mbox_resp_hdr hdr;
233 struct dlb2_mbox_reset_sched_domain_cmd_req {
234 struct dlb2_mbox_req_hdr hdr;
238 struct dlb2_mbox_reset_sched_domain_cmd_resp {
239 struct dlb2_mbox_resp_hdr hdr;
243 struct dlb2_mbox_create_ldb_queue_cmd_req {
244 struct dlb2_mbox_req_hdr hdr;
246 u32 num_sequence_numbers;
247 u32 num_qid_inflights;
248 u32 num_atomic_inflights;
249 u32 lock_id_comp_level;
254 struct dlb2_mbox_create_ldb_queue_cmd_resp {
255 struct dlb2_mbox_resp_hdr hdr;
261 struct dlb2_mbox_create_dir_queue_cmd_req {
262 struct dlb2_mbox_req_hdr hdr;
268 struct dlb2_mbox_create_dir_queue_cmd_resp {
269 struct dlb2_mbox_resp_hdr hdr;
275 struct dlb2_mbox_create_ldb_port_cmd_req {
276 struct dlb2_mbox_req_hdr hdr;
279 u16 cq_history_list_size;
286 struct dlb2_mbox_create_ldb_port_cmd_resp {
287 struct dlb2_mbox_resp_hdr hdr;
293 struct dlb2_mbox_create_dir_port_cmd_req {
294 struct dlb2_mbox_req_hdr hdr;
302 struct dlb2_mbox_create_dir_port_cmd_resp {
303 struct dlb2_mbox_resp_hdr hdr;
309 struct dlb2_mbox_enable_ldb_port_cmd_req {
310 struct dlb2_mbox_req_hdr hdr;
316 struct dlb2_mbox_enable_ldb_port_cmd_resp {
317 struct dlb2_mbox_resp_hdr hdr;
323 struct dlb2_mbox_disable_ldb_port_cmd_req {
324 struct dlb2_mbox_req_hdr hdr;
330 struct dlb2_mbox_disable_ldb_port_cmd_resp {
331 struct dlb2_mbox_resp_hdr hdr;
337 struct dlb2_mbox_enable_dir_port_cmd_req {
338 struct dlb2_mbox_req_hdr hdr;
344 struct dlb2_mbox_enable_dir_port_cmd_resp {
345 struct dlb2_mbox_resp_hdr hdr;
351 struct dlb2_mbox_disable_dir_port_cmd_req {
352 struct dlb2_mbox_req_hdr hdr;
358 struct dlb2_mbox_disable_dir_port_cmd_resp {
359 struct dlb2_mbox_resp_hdr hdr;
365 struct dlb2_mbox_ldb_port_owned_by_domain_cmd_req {
366 struct dlb2_mbox_req_hdr hdr;
372 struct dlb2_mbox_ldb_port_owned_by_domain_cmd_resp {
373 struct dlb2_mbox_resp_hdr hdr;
377 struct dlb2_mbox_dir_port_owned_by_domain_cmd_req {
378 struct dlb2_mbox_req_hdr hdr;
384 struct dlb2_mbox_dir_port_owned_by_domain_cmd_resp {
385 struct dlb2_mbox_resp_hdr hdr;
389 struct dlb2_mbox_map_qid_cmd_req {
390 struct dlb2_mbox_req_hdr hdr;
398 struct dlb2_mbox_map_qid_cmd_resp {
399 struct dlb2_mbox_resp_hdr hdr;
405 struct dlb2_mbox_unmap_qid_cmd_req {
406 struct dlb2_mbox_req_hdr hdr;
412 struct dlb2_mbox_unmap_qid_cmd_resp {
413 struct dlb2_mbox_resp_hdr hdr;
419 struct dlb2_mbox_start_domain_cmd_req {
420 struct dlb2_mbox_req_hdr hdr;
424 struct dlb2_mbox_start_domain_cmd_resp {
425 struct dlb2_mbox_resp_hdr hdr;
431 struct dlb2_mbox_enable_ldb_port_intr_cmd_req {
432 struct dlb2_mbox_req_hdr hdr;
440 struct dlb2_mbox_enable_ldb_port_intr_cmd_resp {
441 struct dlb2_mbox_resp_hdr hdr;
447 struct dlb2_mbox_enable_dir_port_intr_cmd_req {
448 struct dlb2_mbox_req_hdr hdr;
456 struct dlb2_mbox_enable_dir_port_intr_cmd_resp {
457 struct dlb2_mbox_resp_hdr hdr;
463 struct dlb2_mbox_arm_cq_intr_cmd_req {
464 struct dlb2_mbox_req_hdr hdr;
470 struct dlb2_mbox_arm_cq_intr_cmd_resp {
471 struct dlb2_mbox_resp_hdr hdr;
478 * The alert_id and aux_alert_data follows the format of the alerts defined in
479 * dlb2_types.h. The alert id contains an enum dlb2_domain_alert_id value, and
480 * the aux_alert_data value varies depending on the alert.
482 struct dlb2_mbox_vf_alert_cmd_req {
483 struct dlb2_mbox_req_hdr hdr;
489 enum dlb2_mbox_vf_notification_type {
490 DLB2_MBOX_VF_NOTIFICATION_PRE_RESET,
491 DLB2_MBOX_VF_NOTIFICATION_POST_RESET,
493 /* NUM_DLB2_MBOX_VF_NOTIFICATION_TYPES must be last */
494 NUM_DLB2_MBOX_VF_NOTIFICATION_TYPES,
497 struct dlb2_mbox_vf_notification_cmd_req {
498 struct dlb2_mbox_req_hdr hdr;
502 struct dlb2_mbox_vf_in_use_cmd_req {
503 struct dlb2_mbox_req_hdr hdr;
507 struct dlb2_mbox_vf_in_use_cmd_resp {
508 struct dlb2_mbox_resp_hdr hdr;
512 struct dlb2_mbox_get_sn_allocation_cmd_req {
513 struct dlb2_mbox_req_hdr hdr;
517 struct dlb2_mbox_get_sn_allocation_cmd_resp {
518 struct dlb2_mbox_resp_hdr hdr;
522 struct dlb2_mbox_get_ldb_queue_depth_cmd_req {
523 struct dlb2_mbox_req_hdr hdr;
529 struct dlb2_mbox_get_ldb_queue_depth_cmd_resp {
530 struct dlb2_mbox_resp_hdr hdr;
536 struct dlb2_mbox_get_dir_queue_depth_cmd_req {
537 struct dlb2_mbox_req_hdr hdr;
543 struct dlb2_mbox_get_dir_queue_depth_cmd_resp {
544 struct dlb2_mbox_resp_hdr hdr;
550 struct dlb2_mbox_pending_port_unmaps_cmd_req {
551 struct dlb2_mbox_req_hdr hdr;
557 struct dlb2_mbox_pending_port_unmaps_cmd_resp {
558 struct dlb2_mbox_resp_hdr hdr;
564 struct dlb2_mbox_get_cos_bw_cmd_req {
565 struct dlb2_mbox_req_hdr hdr;
569 struct dlb2_mbox_get_cos_bw_cmd_resp {
570 struct dlb2_mbox_resp_hdr hdr;
574 struct dlb2_mbox_get_sn_occupancy_cmd_req {
575 struct dlb2_mbox_req_hdr hdr;
579 struct dlb2_mbox_get_sn_occupancy_cmd_resp {
580 struct dlb2_mbox_resp_hdr hdr;
584 struct dlb2_mbox_query_cq_poll_mode_cmd_req {
585 struct dlb2_mbox_req_hdr hdr;
589 struct dlb2_mbox_query_cq_poll_mode_cmd_resp {
590 struct dlb2_mbox_resp_hdr hdr;
596 #endif /* __DLB2_BASE_DLB2_MBOX_H */