linux/drivers/infiniband/hw/efa/efa_com_cmd.h
<<
>>
Prefs
   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};
  51
  52struct efa_com_query_qp_params {
  53        u32 qp_handle;
  54};
  55
  56struct efa_com_query_qp_result {
  57        u32 qp_state;
  58        u32 qkey;
  59        u32 sq_draining;
  60        u32 sq_psn;
  61};
  62
  63struct efa_com_destroy_qp_params {
  64        u32 qp_handle;
  65};
  66
  67struct efa_com_create_cq_params {
  68        /* cq physical base address in OS memory */
  69        dma_addr_t dma_addr;
  70        /* completion queue depth in # of entries */
  71        u16 cq_depth;
  72        u16 num_sub_cqs;
  73        u16 uarn;
  74        u8 entry_size_in_bytes;
  75};
  76
  77struct efa_com_create_cq_result {
  78        /* cq identifier */
  79        u16 cq_idx;
  80        /* actual cq depth in # of entries */
  81        u16 actual_depth;
  82};
  83
  84struct efa_com_destroy_cq_params {
  85        u16 cq_idx;
  86};
  87
  88struct efa_com_create_ah_params {
  89        u16 pdn;
  90        /* Destination address in network byte order */
  91        u8 dest_addr[EFA_GID_SIZE];
  92};
  93
  94struct efa_com_create_ah_result {
  95        u16 ah;
  96};
  97
  98struct efa_com_destroy_ah_params {
  99        u16 ah;
 100        u16 pdn;
 101};
 102
 103struct efa_com_get_device_attr_result {
 104        u8 addr[EFA_GID_SIZE];
 105        u64 page_size_cap;
 106        u64 max_mr_pages;
 107        u32 mtu;
 108        u32 fw_version;
 109        u32 admin_api_version;
 110        u32 device_version;
 111        u32 supported_features;
 112        u32 phys_addr_width;
 113        u32 virt_addr_width;
 114        u32 max_qp;
 115        u32 max_sq_depth; /* wqes */
 116        u32 max_rq_depth; /* wqes */
 117        u32 max_cq;
 118        u32 max_cq_depth; /* cqes */
 119        u32 inline_buf_size;
 120        u32 max_mr;
 121        u32 max_pd;
 122        u32 max_ah;
 123        u32 max_llq_size;
 124        u32 max_rdma_size;
 125        u32 device_caps;
 126        u16 sub_cqs_per_cq;
 127        u16 max_sq_sge;
 128        u16 max_rq_sge;
 129        u16 max_wr_rdma_sge;
 130        u16 max_tx_batch;
 131        u16 min_sq_depth;
 132        u8 db_bar;
 133};
 134
 135struct efa_com_get_hw_hints_result {
 136        u16 mmio_read_timeout;
 137        u16 driver_watchdog_timeout;
 138        u16 admin_completion_timeout;
 139        u16 poll_interval;
 140        u32 reserved[4];
 141};
 142
 143struct efa_com_mem_addr {
 144        u32 mem_addr_low;
 145        u32 mem_addr_high;
 146};
 147
 148/* Used at indirect mode page list chunks for chaining */
 149struct efa_com_ctrl_buff_info {
 150        /* indicates length of the buffer pointed by control_buffer_address. */
 151        u32 length;
 152        /* points to control buffer (direct or indirect) */
 153        struct efa_com_mem_addr address;
 154};
 155
 156struct efa_com_reg_mr_params {
 157        /* Memory region length, in bytes. */
 158        u64 mr_length_in_bytes;
 159        /* IO Virtual Address associated with this MR. */
 160        u64 iova;
 161        /* words 8:15: Physical Buffer List, each element is page-aligned. */
 162        union {
 163                /*
 164                 * Inline array of physical addresses of app pages
 165                 * (optimization for short region reservations)
 166                 */
 167                u64 inline_pbl_array[4];
 168                /*
 169                 * Describes the next physically contiguous chunk of indirect
 170                 * page list. A page list contains physical addresses of command
 171                 * data pages. Data pages are 4KB; page list chunks are
 172                 * variable-sized.
 173                 */
 174                struct efa_com_ctrl_buff_info pbl;
 175        } pbl;
 176        /* number of pages in PBL (redundant, could be calculated) */
 177        u32 page_num;
 178        /* Protection Domain */
 179        u16 pd;
 180        /*
 181         * phys_page_size_shift - page size is (1 << phys_page_size_shift)
 182         * Page size is used for building the Virtual to Physical
 183         * address mapping
 184         */
 185        u8 page_shift;
 186        /* see permissions field of struct efa_admin_reg_mr_cmd */
 187        u8 permissions;
 188        u8 inline_pbl;
 189        u8 indirect;
 190};
 191
 192struct efa_com_reg_mr_result {
 193        /*
 194         * To be used in conjunction with local buffers references in SQ and
 195         * RQ WQE
 196         */
 197        u32 l_key;
 198        /*
 199         * To be used in incoming RDMA semantics messages to refer to remotely
 200         * accessed memory region
 201         */
 202        u32 r_key;
 203};
 204
 205struct efa_com_dereg_mr_params {
 206        u32 l_key;
 207};
 208
 209struct efa_com_alloc_pd_result {
 210        u16 pdn;
 211};
 212
 213struct efa_com_dealloc_pd_params {
 214        u16 pdn;
 215};
 216
 217struct efa_com_alloc_uar_result {
 218        u16 uarn;
 219};
 220
 221struct efa_com_dealloc_uar_params {
 222        u16 uarn;
 223};
 224
 225struct efa_com_get_stats_params {
 226        /* see enum efa_admin_get_stats_type */
 227        u8 type;
 228        /* see enum efa_admin_get_stats_scope */
 229        u8 scope;
 230        u16 scope_modifier;
 231};
 232
 233struct efa_com_basic_stats {
 234        u64 tx_bytes;
 235        u64 tx_pkts;
 236        u64 rx_bytes;
 237        u64 rx_pkts;
 238        u64 rx_drops;
 239};
 240
 241union efa_com_get_stats_result {
 242        struct efa_com_basic_stats basic_stats;
 243};
 244
 245void efa_com_set_dma_addr(dma_addr_t addr, u32 *addr_high, u32 *addr_low);
 246int efa_com_create_qp(struct efa_com_dev *edev,
 247                      struct efa_com_create_qp_params *params,
 248                      struct efa_com_create_qp_result *res);
 249int efa_com_modify_qp(struct efa_com_dev *edev,
 250                      struct efa_com_modify_qp_params *params);
 251int efa_com_query_qp(struct efa_com_dev *edev,
 252                     struct efa_com_query_qp_params *params,
 253                     struct efa_com_query_qp_result *result);
 254int efa_com_destroy_qp(struct efa_com_dev *edev,
 255                       struct efa_com_destroy_qp_params *params);
 256int efa_com_create_cq(struct efa_com_dev *edev,
 257                      struct efa_com_create_cq_params *params,
 258                      struct efa_com_create_cq_result *result);
 259int efa_com_destroy_cq(struct efa_com_dev *edev,
 260                       struct efa_com_destroy_cq_params *params);
 261int efa_com_register_mr(struct efa_com_dev *edev,
 262                        struct efa_com_reg_mr_params *params,
 263                        struct efa_com_reg_mr_result *result);
 264int efa_com_dereg_mr(struct efa_com_dev *edev,
 265                     struct efa_com_dereg_mr_params *params);
 266int efa_com_create_ah(struct efa_com_dev *edev,
 267                      struct efa_com_create_ah_params *params,
 268                      struct efa_com_create_ah_result *result);
 269int efa_com_destroy_ah(struct efa_com_dev *edev,
 270                       struct efa_com_destroy_ah_params *params);
 271int efa_com_get_device_attr(struct efa_com_dev *edev,
 272                            struct efa_com_get_device_attr_result *result);
 273int efa_com_get_hw_hints(struct efa_com_dev *edev,
 274                         struct efa_com_get_hw_hints_result *result);
 275bool
 276efa_com_check_supported_feature_id(struct efa_com_dev *edev,
 277                                   enum efa_admin_aq_feature_id feature_id);
 278int efa_com_set_feature_ex(struct efa_com_dev *edev,
 279                           struct efa_admin_set_feature_resp *set_resp,
 280                           struct efa_admin_set_feature_cmd *set_cmd,
 281                           enum efa_admin_aq_feature_id feature_id,
 282                           dma_addr_t control_buf_dma_addr,
 283                           u32 control_buff_size);
 284int efa_com_set_aenq_config(struct efa_com_dev *edev, u32 groups);
 285int efa_com_alloc_pd(struct efa_com_dev *edev,
 286                     struct efa_com_alloc_pd_result *result);
 287int efa_com_dealloc_pd(struct efa_com_dev *edev,
 288                       struct efa_com_dealloc_pd_params *params);
 289int efa_com_alloc_uar(struct efa_com_dev *edev,
 290                      struct efa_com_alloc_uar_result *result);
 291int efa_com_dealloc_uar(struct efa_com_dev *edev,
 292                        struct efa_com_dealloc_uar_params *params);
 293int efa_com_get_stats(struct efa_com_dev *edev,
 294                      struct efa_com_get_stats_params *params,
 295                      union efa_com_get_stats_result *result);
 296
 297#endif /* _EFA_COM_CMD_H_ */
 298