1/* SPDX-License-Identifier: BSD-3-Clause */ 2/* Copyright(c) 2007-2022 Intel Corporation */ 3/***************************************************************************** 4 * @file icp_adf_transport.h 5 * 6 * @description 7 * File contains Public API Definitions for ADF transport. 8 * 9 *****************************************************************************/ 10#ifndef ICP_ADF_TRANSPORT_H 11#define ICP_ADF_TRANSPORT_H 12 13#include "cpa.h" 14 15/* 16 * Enumeration on Transport Types exposed 17 */ 18typedef enum icp_transport_type_e { 19 ICP_TRANS_TYPE_NONE = 0, 20 ICP_TRANS_TYPE_ETR, 21 ICP_TRANS_TYPE_DP_ETR, 22 ICP_TRANS_TYPE_ADMINREG, 23 ICP_TRANS_TYPE_DELIMIT 24} icp_transport_type; 25 26/* 27 * Enumeration on response delivery method 28 */ 29typedef enum icp_resp_deliv_method_e { 30 ICP_RESP_TYPE_NONE = 0, 31 ICP_RESP_TYPE_IRQ, 32 ICP_RESP_TYPE_POLL, 33 ICP_RESP_TYPE_DELIMIT 34} icp_resp_deliv_method; 35 36/* 37 * Unique identifier of a transport handle 38 */ 39typedef Cpa32U icp_trans_identifier; 40 41/* 42 * Opaque Transport Handle 43 */ 44typedef void *icp_comms_trans_handle; 45 46/* 47 * Function Pointer invoked when a set of messages is received for the given 48 * transport handle 49 */ 50typedef void (*icp_trans_callback)(void *pMsg); 51 52/* 53 * icp_adf_getDynInstance 54 * 55 * Description: 56 * Get an available instance from dynamic instance pool 57 * 58 * Returns: 59 * CPA_STATUS_SUCCESS on success 60 * CPA_STATUS_FAIL on failure 61 * 62 */ 63CpaStatus icp_adf_getDynInstance(icp_accel_dev_t *accel_dev, 64 adf_service_type_t stype, 65 Cpa32U *pinstance_id); 66 67/* 68 * icp_adf_putDynInstance 69 * 70 * Description: 71 * Put back an instance to dynamic instance pool 72 * 73 * Returns: 74 * CPA_STATUS_SUCCESS on success 75 * CPA_STATUS_FAIL on failure 76 * 77 */ 78CpaStatus icp_adf_putDynInstance(icp_accel_dev_t *accel_dev, 79 adf_service_type_t stype, 80 Cpa32U instance_id); 81 82/* 83 * icp_adf_getNumAvailDynInstance 84 * 85 * Description: 86 * Get the number of the available dynamic instances 87 * 88 * Returns: 89 * CPA_STATUS_SUCCESS on success 90 * CPA_STATUS_FAIL on failure 91 * 92 */ 93CpaStatus icp_adf_getNumAvailDynInstance(icp_accel_dev_t *accel_dev, 94 adf_service_type_t stype, 95 Cpa32U *num); 96 97/* 98 * icp_adf_transGetFdForHandle 99 * 100 * Description: 101 * Get a file descriptor for a particular transaction handle. 102 * If more than one transaction handler 103 * are ever present, this will need to be refactored to 104 * return the appropriate fd of the appropriate bank. 105 * 106 * Returns: 107 * CPA_STATUS_SUCCESS on success 108 * CPA_STATUS_FAIL on failure 109 * 110 * 111 */ 112CpaStatus icp_adf_transGetFdForHandle(icp_comms_trans_handle trans_hnd, 113 int *fd); 114 115/* 116 * icp_adf_transCreateHandle 117 * 118 * Description: 119 * Create a transport handle 120 * 121 * Returns: 122 * CPA_STATUS_SUCCESS on success 123 * CPA_STATUS_FAIL on failure 124 * 125 * The message size is variable: requests can be 64 or 128 bytes, responses 126 * can be 16, 32 or 64 bytes. 127 * Supported num_msgs: 128 * 32, 64, 128, 256, 512, 1024, 2048 number of messages. 129 * 130 */ 131CpaStatus icp_adf_transCreateHandle(icp_accel_dev_t *accel_dev, 132 icp_transport_type trans_type, 133 const char *section, 134 const Cpa32U accel_nr, 135 const Cpa32U bank_nr, 136 const char *service_name, 137 const icp_adf_ringInfoService_t info, 138 icp_trans_callback callback, 139 icp_resp_deliv_method resp, 140 const Cpa32U num_msgs, 141 const Cpa32U msg_size, 142 icp_comms_trans_handle *trans_handle); 143 144/* 145 * icp_adf_transReinitHandle 146 * 147 * Description: 148 * Reinitialize a transport handle 149 * 150 * Returns: 151 * CPA_STATUS_SUCCESS on success 152 * CPA_STATUS_FAIL on failure 153 * 154 * The message size is variable: requests can be 64 or 128 bytes, responses 155 * can be 16, 32 or 64 bytes. 156 * Supported num_msgs: 157 * 32, 64, 128, 256, 512, 1024, 2048 number of messages. 158 * 159 */ 160CpaStatus icp_adf_transReinitHandle(icp_accel_dev_t *accel_dev, 161 icp_transport_type trans_type, 162 const char *section, 163 const Cpa32U accel_nr, 164 const Cpa32U bank_nr, 165 const char *service_name, 166 const icp_adf_ringInfoService_t info, 167 icp_trans_callback callback, 168 icp_resp_deliv_method resp, 169 const Cpa32U num_msgs, 170 const Cpa32U msg_size, 171 icp_comms_trans_handle *trans_handle); 172 173/* 174 * icp_adf_transGetHandle 175 * 176 * Description: 177 * Gets a pointer to a previously created transport handle 178 * 179 * Returns: 180 * CPA_STATUS_SUCCESS on success 181 * CPA_STATUS_FAIL on failure 182 * 183 */ 184CpaStatus icp_adf_transGetHandle(icp_accel_dev_t *accel_dev, 185 icp_transport_type trans_type, 186 const char *section, 187 const Cpa32U accel_nr, 188 const Cpa32U bank_nr, 189 const char *service_name, 190 icp_comms_trans_handle *trans_handle); 191 192/* 193 * icp_adf_transReleaseHandle 194 * 195 * Description: 196 * Release a transport handle 197 * 198 * Returns: 199 * CPA_STATUS_SUCCESS on success 200 * CPA_STATUS_FAIL on failure 201 */ 202CpaStatus icp_adf_transReleaseHandle(icp_comms_trans_handle trans_handle); 203 204/* 205 * icp_adf_transResetHandle 206 * 207 * Description: 208 * Reset a transport handle 209 * 210 * Returns: 211 * CPA_STATUS_SUCCESS on success 212 * CPA_STATUS_FAIL on failure 213 */ 214CpaStatus icp_adf_transResetHandle(icp_comms_trans_handle trans_handle); 215 216/* 217 * icp_adf_transPutMsg 218 * 219 * Description: 220 * Put Message onto the transport handle 221 * 222 * Returns: 223 * CPA_STATUS_SUCCESS on success 224 * CPA_STATUS_FAIL on failure 225 */ 226CpaStatus icp_adf_transPutMsg(icp_comms_trans_handle trans_handle, 227 Cpa32U *inBufs, 228 Cpa32U bufLen); 229 230/* 231 * icp_adf_getInflightRequests 232 * 233 * Description: 234 * Retrieve in flight requests from the transport handle. 235 * 236 * Returns: 237 * CPA_STATUS_SUCCESS on success 238 * CPA_STATUS_FAIL on failure 239 */ 240CpaStatus icp_adf_getInflightRequests(icp_comms_trans_handle trans_handle, 241 Cpa32U *maxInflightRequests, 242 Cpa32U *numInflightRequests); 243 244/* 245 * icp_adf_transPutMsgSync 246 * 247 * Description: 248 * Put Message onto the transport handle and waits for a response. 249 * Note: Not all transports support method. 250 * 251 * Returns: 252 * CPA_STATUS_SUCCESS on success 253 * CPA_STATUS_FAIL on failure 254 */ 255CpaStatus icp_adf_transPutMsgSync(icp_comms_trans_handle trans_handle, 256 Cpa32U *inBuf, 257 Cpa32U *outBuf, 258 Cpa32U bufsLen); 259 260/* 261 * icp_adf_transGetRingNum 262 * 263 * Description: 264 * Function Returns ring number of the given trans_handle 265 * 266 * Returns: 267 * CPA_STATUS_SUCCESS on success 268 * CPA_STATUS_FAIL on failure 269 */ 270CpaStatus icp_adf_transGetRingNum(icp_comms_trans_handle trans_handle, 271 Cpa32U *ringNum); 272 273/* 274 * icp_adf_flush_requests 275 * 276 * Description: 277 * Function flushes the enqueued requests on the trans_handle 278 * 279 * Returns: 280 * CPA_STATUS_SUCCESS on success 281 * CPA_STATUS_FAIL on failure 282 */ 283CpaStatus icp_adf_flush_requests(icp_comms_trans_handle trans_handle); 284 285#endif /* ICP_ADF_TRANSPORT_H */ 286