1/* SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */ 2/* 3 * Copyright 2018-2020 Amazon.com, Inc. or its affiliates. All rights reserved. 4 */ 5 6#ifndef _EFA_COM_CMD_H_ 7#define _EFA_COM_CMD_H_ 8 9#include "efa_com.h" 10 11#define EFA_GID_SIZE 16 12 13struct efa_com_create_qp_params { 14 u64 rq_base_addr; 15 u32 send_cq_idx; 16 u32 recv_cq_idx; 17 /* 18 * Send descriptor ring size in bytes, 19 * sufficient for user-provided number of WQEs and SGL size 20 */ 21 u32 sq_ring_size_in_bytes; 22 /* Max number of WQEs that will be posted on send queue */ 23 u32 sq_depth; 24 /* Recv descriptor ring size in bytes */ 25 u32 rq_ring_size_in_bytes; 26 u32 rq_depth; 27 u16 pd; 28 u16 uarn; 29 u8 qp_type; 30}; 31 32struct efa_com_create_qp_result { 33 u32 qp_handle; 34 u32 qp_num; 35 u32 sq_db_offset; 36 u32 rq_db_offset; 37 u32 llq_descriptors_offset; 38 u16 send_sub_cq_idx; 39 u16 recv_sub_cq_idx; 40}; 41 42struct efa_com_modify_qp_params { 43 u32 modify_mask; 44 u32 qp_handle; 45 u32 qp_state; 46 u32 cur_qp_state; 47 u32 qkey; 48 u32 sq_psn; 49 u8 sq_drained_async_notify; 50 u8 rnr_retry; 51}; 52 53struct efa_com_query_qp_params { 54 u32 qp_handle; 55}; 56 57struct efa_com_query_qp_result { 58 u32 qp_state; 59 u32 qkey; 60 u32 sq_draining; 61 u32 sq_psn; 62 u8 rnr_retry; 63}; 64 65struct efa_com_destroy_qp_params { 66 u32 qp_handle; 67}; 68 69struct efa_com_create_cq_params { 70 /* cq physical base address in OS memory */ 71 dma_addr_t dma_addr; 72 /* completion queue depth in # of entries */ 73 u16 cq_depth; 74 u16 num_sub_cqs; 75 u16 uarn; 76 u8 entry_size_in_bytes; 77}; 78 79struct efa_com_create_cq_result { 80 /* cq identifier */ 81 u16 cq_idx; 82 /* actual cq depth in # of entries */ 83 u16 actual_depth; 84}; 85 86struct efa_com_destroy_cq_params { 87 u16 cq_idx; 88}; 89 90struct efa_com_create_ah_params { 91 u16 pdn; 92 /* Destination address in network byte order */ 93 u8 dest_addr[EFA_GID_SIZE]; 94}; 95 96struct efa_com_create_ah_result { 97 u16 ah; 98}; 99 100struct efa_com_destroy_ah_params { 101 u16 ah; 102 u16 pdn; 103}; 104 105struct efa_com_get_device_attr_result { 106 u8 addr[EFA_GID_SIZE]; 107 u64 page_size_cap; 108 u64 max_mr_pages; 109 u32 mtu; 110 u32 fw_version; 111 u32 admin_api_version; 112 u32 device_version; 113 u32 supported_features; 114 u32 phys_addr_width; 115 u32 virt_addr_width; 116 u32 max_qp; 117 u32 max_sq_depth; /* wqes */ 118 u32 max_rq_depth; /* wqes */ 119 u32 max_cq; 120 u32 max_cq_depth; /* cqes */ 121 u32 inline_buf_size; 122 u32 max_mr; 123 u32 max_pd; 124 u32 max_ah; 125 u32 max_llq_size; 126 u32 max_rdma_size; 127 u32 device_caps; 128 u16 sub_cqs_per_cq; 129 u16 max_sq_sge; 130 u16 max_rq_sge; 131 u16 max_wr_rdma_sge; 132 u16 max_tx_batch; 133 u16 min_sq_depth; 134 u8 db_bar; 135}; 136 137struct efa_com_get_hw_hints_result { 138 u16 mmio_read_timeout; 139 u16 driver_watchdog_timeout; 140 u16 admin_completion_timeout; 141 u16 poll_interval; 142 u32 reserved[4]; 143}; 144 145struct efa_com_mem_addr { 146 u32 mem_addr_low; 147 u32 mem_addr_high; 148}; 149 150/* Used at indirect mode page list chunks for chaining */ 151struct efa_com_ctrl_buff_info { 152 /* indicates length of the buffer pointed by control_buffer_address. */ 153 u32 length; 154 /* points to control buffer (direct or indirect) */ 155 struct efa_com_mem_addr address; 156}; 157 158struct efa_com_reg_mr_params { 159 /* Memory region length, in bytes. */ 160 u64 mr_length_in_bytes; 161 /* IO Virtual Address associated with this MR. */ 162 u64 iova; 163 /* words 8:15: Physical Buffer List, each element is page-aligned. */ 164 union { 165 /* 166 * Inline array of physical addresses of app pages 167 * (optimization for short region reservations) 168 */ 169 u64 inline_pbl_array[4]; 170 /* 171 * Describes the next physically contiguous chunk of indirect 172 * page list. A page list contains physical addresses of command 173 * data pages. Data pages are 4KB; page list chunks are 174 * variable-sized. 175 */ 176 struct efa_com_ctrl_buff_info pbl; 177 } pbl; 178 /* number of pages in PBL (redundant, could be calculated) */ 179 u32 page_num; 180 /* Protection Domain */ 181 u16 pd; 182 /* 183 * phys_page_size_shift - page size is (1 << phys_page_size_shift) 184 * Page size is used for building the Virtual to Physical 185 * address mapping 186 */ 187 u8 page_shift; 188 /* see permissions field of struct efa_admin_reg_mr_cmd */ 189 u8 permissions; 190 u8 inline_pbl; 191 u8 indirect; 192}; 193 194struct efa_com_reg_mr_result { 195 /* 196 * To be used in conjunction with local buffers references in SQ and 197 * RQ WQE 198 */ 199 u32 l_key; 200 /* 201 * To be used in incoming RDMA semantics messages to refer to remotely 202 * accessed memory region 203 */ 204 u32 r_key; 205}; 206 207struct efa_com_dereg_mr_params { 208 u32 l_key; 209}; 210 211struct efa_com_alloc_pd_result { 212 u16 pdn; 213}; 214 215struct efa_com_dealloc_pd_params { 216 u16 pdn; 217}; 218 219struct efa_com_alloc_uar_result { 220 u16 uarn; 221}; 222 223struct efa_com_dealloc_uar_params { 224 u16 uarn; 225}; 226 227struct efa_com_get_stats_params { 228 /* see enum efa_admin_get_stats_type */ 229 u8 type; 230 /* see enum efa_admin_get_stats_scope */ 231 u8 scope; 232 u16 scope_modifier; 233}; 234 235struct efa_com_basic_stats { 236 u64 tx_bytes; 237 u64 tx_pkts; 238 u64 rx_bytes; 239 u64 rx_pkts; 240 u64 rx_drops; 241}; 242 243struct efa_com_messages_stats { 244 u64 send_bytes; 245 u64 send_wrs; 246 u64 recv_bytes; 247 u64 recv_wrs; 248}; 249 250struct efa_com_rdma_read_stats { 251 u64 read_wrs; 252 u64 read_bytes; 253 u64 read_wr_err; 254 u64 read_resp_bytes; 255}; 256 257union efa_com_get_stats_result { 258 struct efa_com_basic_stats basic_stats; 259 struct efa_com_messages_stats messages_stats; 260 struct efa_com_rdma_read_stats rdma_read_stats; 261}; 262 263void efa_com_set_dma_addr(dma_addr_t addr, u32 *addr_high, u32 *addr_low); 264int efa_com_create_qp(struct efa_com_dev *edev, 265 struct efa_com_create_qp_params *params, 266 struct efa_com_create_qp_result *res); 267int efa_com_modify_qp(struct efa_com_dev *edev, 268 struct efa_com_modify_qp_params *params); 269int efa_com_query_qp(struct efa_com_dev *edev, 270 struct efa_com_query_qp_params *params, 271 struct efa_com_query_qp_result *result); 272int efa_com_destroy_qp(struct efa_com_dev *edev, 273 struct efa_com_destroy_qp_params *params); 274int efa_com_create_cq(struct efa_com_dev *edev, 275 struct efa_com_create_cq_params *params, 276 struct efa_com_create_cq_result *result); 277int efa_com_destroy_cq(struct efa_com_dev *edev, 278 struct efa_com_destroy_cq_params *params); 279int efa_com_register_mr(struct efa_com_dev *edev, 280 struct efa_com_reg_mr_params *params, 281 struct efa_com_reg_mr_result *result); 282int efa_com_dereg_mr(struct efa_com_dev *edev, 283 struct efa_com_dereg_mr_params *params); 284int efa_com_create_ah(struct efa_com_dev *edev, 285 struct efa_com_create_ah_params *params, 286 struct efa_com_create_ah_result *result); 287int efa_com_destroy_ah(struct efa_com_dev *edev, 288 struct efa_com_destroy_ah_params *params); 289int efa_com_get_device_attr(struct efa_com_dev *edev, 290 struct efa_com_get_device_attr_result *result); 291int efa_com_get_hw_hints(struct efa_com_dev *edev, 292 struct efa_com_get_hw_hints_result *result); 293bool 294efa_com_check_supported_feature_id(struct efa_com_dev *edev, 295 enum efa_admin_aq_feature_id feature_id); 296int efa_com_set_feature_ex(struct efa_com_dev *edev, 297 struct efa_admin_set_feature_resp *set_resp, 298 struct efa_admin_set_feature_cmd *set_cmd, 299 enum efa_admin_aq_feature_id feature_id, 300 dma_addr_t control_buf_dma_addr, 301 u32 control_buff_size); 302int efa_com_set_aenq_config(struct efa_com_dev *edev, u32 groups); 303int efa_com_alloc_pd(struct efa_com_dev *edev, 304 struct efa_com_alloc_pd_result *result); 305int efa_com_dealloc_pd(struct efa_com_dev *edev, 306 struct efa_com_dealloc_pd_params *params); 307int efa_com_alloc_uar(struct efa_com_dev *edev, 308 struct efa_com_alloc_uar_result *result); 309int efa_com_dealloc_uar(struct efa_com_dev *edev, 310 struct efa_com_dealloc_uar_params *params); 311int efa_com_get_stats(struct efa_com_dev *edev, 312 struct efa_com_get_stats_params *params, 313 union efa_com_get_stats_result *result); 314 315#endif /* _EFA_COM_CMD_H_ */ 316