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
23 #define HWC_INIT_DATA_PF_DEST_RQ_ID 10
24 #define HWC_INIT_DATA_PF_DEST_CQ_ID 11
26 #define HWC_DATA_CFG_HWC_TIMEOUT 1
28 #define HW_CHANNEL_WAIT_RESOURCE_TIMEOUT_MS 30000
30 /* Structures labeled with "HW DATA" are exchanged with the hardware. All of
31 * them are naturally aligned and hence don't need __packed.
34 union hwc_init_eq_id_db {
43 union hwc_init_type_data {
71 u32 client_data_unit : 14;
76 u32 chunk_offset : 21;
101 struct hwc_work_request {
107 struct gdma_wqe_request wqe_req;
108 struct hwc_tx_oob tx_oob;
113 /* hwc_dma_buf represents the array of in-flight WQEs.
114 * mem_info as know as the GDMA mapped memory is partitioned and used by
116 * The number of WQEs is determined by the number of in-flight messages.
119 struct gdma_mem_info mem_info;
124 struct hwc_work_request reqs[] __counted_by(num_reqs);
127 typedef void hwc_rx_event_handler_t(void *ctx, u32 gdma_rxq_id,
128 const struct hwc_rx_oob *rx_oob);
130 typedef void hwc_tx_event_handler_t(void *ctx, u32 gdma_txq_id,
131 const struct hwc_rx_oob *rx_oob);
134 struct hw_channel_context *hwc;
136 struct gdma_queue *gdma_cq;
137 struct gdma_queue *gdma_eq;
138 struct gdma_comp *comp_buf;
141 hwc_rx_event_handler_t *rx_event_handler;
144 hwc_tx_event_handler_t *tx_event_handler;
149 struct hw_channel_context *hwc;
151 struct gdma_queue *gdma_wq;
152 struct hwc_dma_buf *msg_buf;
155 struct hwc_cq *hwc_cq;
158 struct hwc_caller_ctx {
159 struct completion comp_event;
163 u32 error; /* Linux error code */
167 struct hw_channel_context {
168 struct gdma_dev *gdma_dev;
171 u16 num_inflight_msg;
172 u32 max_req_msg_size;
174 u16 hwc_init_q_depth_max;
175 u32 hwc_init_max_req_msg_size;
176 u32 hwc_init_max_resp_msg_size;
178 struct completion hwc_init_eqe_comp;
184 struct semaphore sema;
185 struct gdma_resource inflight_msg_res;
191 struct hwc_caller_ctx *caller_ctx;
194 int mana_hwc_create_channel(struct gdma_context *gc);
195 void mana_hwc_destroy_channel(struct gdma_context *gc);
197 int mana_hwc_send_request(struct hw_channel_context *hwc, u32 req_len,
198 const void *req, u32 resp_len, void *resp);
200 #endif /* _HW_CHANNEL_H */