1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /* Copyright (c) 2021, Microsoft Corporation. */
7 #define DEFAULT_LOG2_THROTTLING_FOR_ERROR_EQ 4
9 #define HW_CHANNEL_MAX_REQUEST_SIZE 0x1000
10 #define HW_CHANNEL_MAX_RESPONSE_SIZE 0x1000
12 #define HW_CHANNEL_VF_BOOTSTRAP_QUEUE_DEPTH 1
14 #define HWC_INIT_DATA_CQID 1
15 #define HWC_INIT_DATA_RQID 2
16 #define HWC_INIT_DATA_SQID 3
17 #define HWC_INIT_DATA_QUEUE_DEPTH 4
18 #define HWC_INIT_DATA_MAX_REQUEST 5
19 #define HWC_INIT_DATA_MAX_RESPONSE 6
20 #define HWC_INIT_DATA_MAX_NUM_CQS 7
21 #define HWC_INIT_DATA_PDID 8
22 #define HWC_INIT_DATA_GPA_MKEY 9
24 /* Structures labeled with "HW DATA" are exchanged with the hardware. All of
25 * them are naturally aligned and hence don't need __packed.
28 union hwc_init_eq_id_db {
37 union hwc_init_type_data {
65 u32 client_data_unit : 14;
70 u32 chunk_offset : 21;
95 struct hwc_work_request {
101 struct gdma_wqe_request wqe_req;
102 struct hwc_tx_oob tx_oob;
107 /* hwc_dma_buf represents the array of in-flight WQEs.
108 * mem_info as know as the GDMA mapped memory is partitioned and used by
110 * The number of WQEs is determined by the number of in-flight messages.
113 struct gdma_mem_info mem_info;
118 struct hwc_work_request reqs[];
121 typedef void hwc_rx_event_handler_t(void *ctx, u32 gdma_rxq_id,
122 const struct hwc_rx_oob *rx_oob);
124 typedef void hwc_tx_event_handler_t(void *ctx, u32 gdma_txq_id,
125 const struct hwc_rx_oob *rx_oob);
128 struct hw_channel_context *hwc;
130 struct gdma_queue *gdma_cq;
131 struct gdma_queue *gdma_eq;
132 struct gdma_comp *comp_buf;
135 hwc_rx_event_handler_t *rx_event_handler;
138 hwc_tx_event_handler_t *tx_event_handler;
143 struct hw_channel_context *hwc;
145 struct gdma_queue *gdma_wq;
146 struct hwc_dma_buf *msg_buf;
149 struct hwc_cq *hwc_cq;
152 struct hwc_caller_ctx {
153 struct completion comp_event;
157 u32 error; /* Linux error code */
161 struct hw_channel_context {
162 struct gdma_dev *gdma_dev;
165 u16 num_inflight_msg;
166 u32 max_req_msg_size;
168 u16 hwc_init_q_depth_max;
169 u32 hwc_init_max_req_msg_size;
170 u32 hwc_init_max_resp_msg_size;
172 struct completion hwc_init_eqe_comp;
178 struct semaphore sema;
179 struct gdma_resource inflight_msg_res;
181 struct hwc_caller_ctx *caller_ctx;
184 int mana_hwc_create_channel(struct gdma_context *gc);
185 void mana_hwc_destroy_channel(struct gdma_context *gc);
187 int mana_hwc_send_request(struct hw_channel_context *hwc, u32 req_len,
188 const void *req, u32 resp_len, void *resp);
190 #endif /* _HW_CHANNEL_H */