Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */
0002 /*
0003  * Copyright 2018-2021 Amazon.com, Inc. or its affiliates. All rights reserved.
0004  */
0005 
0006 #ifndef _EFA_COM_CMD_H_
0007 #define _EFA_COM_CMD_H_
0008 
0009 #include "efa_com.h"
0010 
0011 #define EFA_GID_SIZE 16
0012 
0013 struct efa_com_create_qp_params {
0014     u64 rq_base_addr;
0015     u32 send_cq_idx;
0016     u32 recv_cq_idx;
0017     /*
0018      * Send descriptor ring size in bytes,
0019      * sufficient for user-provided number of WQEs and SGL size
0020      */
0021     u32 sq_ring_size_in_bytes;
0022     /* Max number of WQEs that will be posted on send queue */
0023     u32 sq_depth;
0024     /* Recv descriptor ring size in bytes */
0025     u32 rq_ring_size_in_bytes;
0026     u32 rq_depth;
0027     u16 pd;
0028     u16 uarn;
0029     u8 qp_type;
0030 };
0031 
0032 struct efa_com_create_qp_result {
0033     u32 qp_handle;
0034     u32 qp_num;
0035     u32 sq_db_offset;
0036     u32 rq_db_offset;
0037     u32 llq_descriptors_offset;
0038     u16 send_sub_cq_idx;
0039     u16 recv_sub_cq_idx;
0040 };
0041 
0042 struct efa_com_modify_qp_params {
0043     u32 modify_mask;
0044     u32 qp_handle;
0045     u32 qp_state;
0046     u32 cur_qp_state;
0047     u32 qkey;
0048     u32 sq_psn;
0049     u8 sq_drained_async_notify;
0050     u8 rnr_retry;
0051 };
0052 
0053 struct efa_com_query_qp_params {
0054     u32 qp_handle;
0055 };
0056 
0057 struct efa_com_query_qp_result {
0058     u32 qp_state;
0059     u32 qkey;
0060     u32 sq_draining;
0061     u32 sq_psn;
0062     u8 rnr_retry;
0063 };
0064 
0065 struct efa_com_destroy_qp_params {
0066     u32 qp_handle;
0067 };
0068 
0069 struct efa_com_create_cq_params {
0070     /* cq physical base address in OS memory */
0071     dma_addr_t dma_addr;
0072     /* completion queue depth in # of entries */
0073     u16 cq_depth;
0074     u16 num_sub_cqs;
0075     u16 uarn;
0076     u16 eqn;
0077     u8 entry_size_in_bytes;
0078     bool interrupt_mode_enabled;
0079 };
0080 
0081 struct efa_com_create_cq_result {
0082     /* cq identifier */
0083     u16 cq_idx;
0084     /* actual cq depth in # of entries */
0085     u16 actual_depth;
0086     u32 db_off;
0087     bool db_valid;
0088 };
0089 
0090 struct efa_com_destroy_cq_params {
0091     u16 cq_idx;
0092 };
0093 
0094 struct efa_com_create_ah_params {
0095     u16 pdn;
0096     /* Destination address in network byte order */
0097     u8 dest_addr[EFA_GID_SIZE];
0098 };
0099 
0100 struct efa_com_create_ah_result {
0101     u16 ah;
0102 };
0103 
0104 struct efa_com_destroy_ah_params {
0105     u16 ah;
0106     u16 pdn;
0107 };
0108 
0109 struct efa_com_get_device_attr_result {
0110     u8 addr[EFA_GID_SIZE];
0111     u64 page_size_cap;
0112     u64 max_mr_pages;
0113     u32 mtu;
0114     u32 fw_version;
0115     u32 admin_api_version;
0116     u32 device_version;
0117     u32 supported_features;
0118     u32 phys_addr_width;
0119     u32 virt_addr_width;
0120     u32 max_qp;
0121     u32 max_sq_depth; /* wqes */
0122     u32 max_rq_depth; /* wqes */
0123     u32 max_cq;
0124     u32 max_cq_depth; /* cqes */
0125     u32 inline_buf_size;
0126     u32 max_mr;
0127     u32 max_pd;
0128     u32 max_ah;
0129     u32 max_llq_size;
0130     u32 max_rdma_size;
0131     u32 device_caps;
0132     u32 max_eq;
0133     u32 max_eq_depth;
0134     u32 event_bitmask; /* EQ events bitmask */
0135     u16 sub_cqs_per_cq;
0136     u16 max_sq_sge;
0137     u16 max_rq_sge;
0138     u16 max_wr_rdma_sge;
0139     u16 max_tx_batch;
0140     u16 min_sq_depth;
0141     u8 db_bar;
0142 };
0143 
0144 struct efa_com_get_hw_hints_result {
0145     u16 mmio_read_timeout;
0146     u16 driver_watchdog_timeout;
0147     u16 admin_completion_timeout;
0148     u16 poll_interval;
0149     u32 reserved[4];
0150 };
0151 
0152 struct efa_com_mem_addr {
0153     u32 mem_addr_low;
0154     u32 mem_addr_high;
0155 };
0156 
0157 /* Used at indirect mode page list chunks for chaining */
0158 struct efa_com_ctrl_buff_info {
0159     /* indicates length of the buffer pointed by control_buffer_address. */
0160     u32 length;
0161     /* points to control buffer (direct or indirect) */
0162     struct efa_com_mem_addr address;
0163 };
0164 
0165 struct efa_com_reg_mr_params {
0166     /* Memory region length, in bytes. */
0167     u64 mr_length_in_bytes;
0168     /* IO Virtual Address associated with this MR. */
0169     u64 iova;
0170     /* words 8:15: Physical Buffer List, each element is page-aligned. */
0171     union {
0172         /*
0173          * Inline array of physical addresses of app pages
0174          * (optimization for short region reservations)
0175          */
0176         u64 inline_pbl_array[4];
0177         /*
0178          * Describes the next physically contiguous chunk of indirect
0179          * page list. A page list contains physical addresses of command
0180          * data pages. Data pages are 4KB; page list chunks are
0181          * variable-sized.
0182          */
0183         struct efa_com_ctrl_buff_info pbl;
0184     } pbl;
0185     /* number of pages in PBL (redundant, could be calculated) */
0186     u32 page_num;
0187     /* Protection Domain */
0188     u16 pd;
0189     /*
0190      * phys_page_size_shift - page size is (1 << phys_page_size_shift)
0191      * Page size is used for building the Virtual to Physical
0192      * address mapping
0193      */
0194     u8 page_shift;
0195     /* see permissions field of struct efa_admin_reg_mr_cmd */
0196     u8 permissions;
0197     u8 inline_pbl;
0198     u8 indirect;
0199 };
0200 
0201 struct efa_com_reg_mr_result {
0202     /*
0203      * To be used in conjunction with local buffers references in SQ and
0204      * RQ WQE
0205      */
0206     u32 l_key;
0207     /*
0208      * To be used in incoming RDMA semantics messages to refer to remotely
0209      * accessed memory region
0210      */
0211     u32 r_key;
0212 };
0213 
0214 struct efa_com_dereg_mr_params {
0215     u32 l_key;
0216 };
0217 
0218 struct efa_com_alloc_pd_result {
0219     u16 pdn;
0220 };
0221 
0222 struct efa_com_dealloc_pd_params {
0223     u16 pdn;
0224 };
0225 
0226 struct efa_com_alloc_uar_result {
0227     u16 uarn;
0228 };
0229 
0230 struct efa_com_dealloc_uar_params {
0231     u16 uarn;
0232 };
0233 
0234 struct efa_com_get_stats_params {
0235     /* see enum efa_admin_get_stats_type */
0236     u8 type;
0237     /* see enum efa_admin_get_stats_scope */
0238     u8 scope;
0239     u16 scope_modifier;
0240 };
0241 
0242 struct efa_com_basic_stats {
0243     u64 tx_bytes;
0244     u64 tx_pkts;
0245     u64 rx_bytes;
0246     u64 rx_pkts;
0247     u64 rx_drops;
0248 };
0249 
0250 struct efa_com_messages_stats {
0251     u64 send_bytes;
0252     u64 send_wrs;
0253     u64 recv_bytes;
0254     u64 recv_wrs;
0255 };
0256 
0257 struct efa_com_rdma_read_stats {
0258     u64 read_wrs;
0259     u64 read_bytes;
0260     u64 read_wr_err;
0261     u64 read_resp_bytes;
0262 };
0263 
0264 union efa_com_get_stats_result {
0265     struct efa_com_basic_stats basic_stats;
0266     struct efa_com_messages_stats messages_stats;
0267     struct efa_com_rdma_read_stats rdma_read_stats;
0268 };
0269 
0270 int efa_com_create_qp(struct efa_com_dev *edev,
0271               struct efa_com_create_qp_params *params,
0272               struct efa_com_create_qp_result *res);
0273 int efa_com_modify_qp(struct efa_com_dev *edev,
0274               struct efa_com_modify_qp_params *params);
0275 int efa_com_query_qp(struct efa_com_dev *edev,
0276              struct efa_com_query_qp_params *params,
0277              struct efa_com_query_qp_result *result);
0278 int efa_com_destroy_qp(struct efa_com_dev *edev,
0279                struct efa_com_destroy_qp_params *params);
0280 int efa_com_create_cq(struct efa_com_dev *edev,
0281               struct efa_com_create_cq_params *params,
0282               struct efa_com_create_cq_result *result);
0283 int efa_com_destroy_cq(struct efa_com_dev *edev,
0284                struct efa_com_destroy_cq_params *params);
0285 int efa_com_register_mr(struct efa_com_dev *edev,
0286             struct efa_com_reg_mr_params *params,
0287             struct efa_com_reg_mr_result *result);
0288 int efa_com_dereg_mr(struct efa_com_dev *edev,
0289              struct efa_com_dereg_mr_params *params);
0290 int efa_com_create_ah(struct efa_com_dev *edev,
0291               struct efa_com_create_ah_params *params,
0292               struct efa_com_create_ah_result *result);
0293 int efa_com_destroy_ah(struct efa_com_dev *edev,
0294                struct efa_com_destroy_ah_params *params);
0295 int efa_com_get_device_attr(struct efa_com_dev *edev,
0296                 struct efa_com_get_device_attr_result *result);
0297 int efa_com_get_hw_hints(struct efa_com_dev *edev,
0298              struct efa_com_get_hw_hints_result *result);
0299 bool
0300 efa_com_check_supported_feature_id(struct efa_com_dev *edev,
0301                    enum efa_admin_aq_feature_id feature_id);
0302 int efa_com_set_feature_ex(struct efa_com_dev *edev,
0303                struct efa_admin_set_feature_resp *set_resp,
0304                struct efa_admin_set_feature_cmd *set_cmd,
0305                enum efa_admin_aq_feature_id feature_id,
0306                dma_addr_t control_buf_dma_addr,
0307                u32 control_buff_size);
0308 int efa_com_set_aenq_config(struct efa_com_dev *edev, u32 groups);
0309 int efa_com_alloc_pd(struct efa_com_dev *edev,
0310              struct efa_com_alloc_pd_result *result);
0311 int efa_com_dealloc_pd(struct efa_com_dev *edev,
0312                struct efa_com_dealloc_pd_params *params);
0313 int efa_com_alloc_uar(struct efa_com_dev *edev,
0314               struct efa_com_alloc_uar_result *result);
0315 int efa_com_dealloc_uar(struct efa_com_dev *edev,
0316             struct efa_com_dealloc_uar_params *params);
0317 int efa_com_get_stats(struct efa_com_dev *edev,
0318               struct efa_com_get_stats_params *params,
0319               union efa_com_get_stats_result *result);
0320 
0321 #endif /* _EFA_COM_CMD_H_ */