diff options
| author | Gal Pressman <galpress@amazon.com> | 2019-05-05 13:59:23 -0400 |
|---|---|---|
| committer | Jason Gunthorpe <jgg@mellanox.com> | 2019-05-06 14:18:17 -0400 |
| commit | 853f56523565c7d3526799d3e2dc503128c336ec (patch) | |
| tree | 95f672ab8020dca51d8c15ec7f76b9ab26e514e9 | |
| parent | 01edac3aa2b9002860f405f1af23536386d45db0 (diff) | |
RDMA/efa: Add the efa.h header file
Add EFA driver generic header file defining driver's device independent
internal data structures and definitions.
Signed-off-by: Gal Pressman <galpress@amazon.com>
Reviewed-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
| -rw-r--r-- | drivers/infiniband/hw/efa/efa.h | 163 |
1 files changed, 163 insertions, 0 deletions
diff --git a/drivers/infiniband/hw/efa/efa.h b/drivers/infiniband/hw/efa/efa.h new file mode 100644 index 000000000000..9e3cc3239c13 --- /dev/null +++ b/drivers/infiniband/hw/efa/efa.h | |||
| @@ -0,0 +1,163 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */ | ||
| 2 | /* | ||
| 3 | * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All rights reserved. | ||
| 4 | */ | ||
| 5 | |||
| 6 | #ifndef _EFA_H_ | ||
| 7 | #define _EFA_H_ | ||
| 8 | |||
| 9 | #include <linux/bitops.h> | ||
| 10 | #include <linux/idr.h> | ||
| 11 | #include <linux/interrupt.h> | ||
| 12 | #include <linux/pci.h> | ||
| 13 | #include <linux/sched.h> | ||
| 14 | |||
| 15 | #include <rdma/efa-abi.h> | ||
| 16 | #include <rdma/ib_verbs.h> | ||
| 17 | |||
| 18 | #include "efa_com_cmd.h" | ||
| 19 | |||
| 20 | #define DRV_MODULE_NAME "efa" | ||
| 21 | #define DEVICE_NAME "Elastic Fabric Adapter (EFA)" | ||
| 22 | |||
| 23 | #define EFA_IRQNAME_SIZE 40 | ||
| 24 | |||
| 25 | /* 1 for AENQ + ADMIN */ | ||
| 26 | #define EFA_NUM_MSIX_VEC 1 | ||
| 27 | #define EFA_MGMNT_MSIX_VEC_IDX 0 | ||
| 28 | |||
| 29 | struct efa_irq { | ||
| 30 | irq_handler_t handler; | ||
| 31 | void *data; | ||
| 32 | int cpu; | ||
| 33 | u32 vector; | ||
| 34 | cpumask_t affinity_hint_mask; | ||
| 35 | char name[EFA_IRQNAME_SIZE]; | ||
| 36 | }; | ||
| 37 | |||
| 38 | struct efa_sw_stats { | ||
| 39 | atomic64_t alloc_pd_err; | ||
| 40 | atomic64_t create_qp_err; | ||
| 41 | atomic64_t create_cq_err; | ||
| 42 | atomic64_t reg_mr_err; | ||
| 43 | atomic64_t alloc_ucontext_err; | ||
| 44 | atomic64_t create_ah_err; | ||
| 45 | }; | ||
| 46 | |||
| 47 | /* Don't use anything other than atomic64 */ | ||
| 48 | struct efa_stats { | ||
| 49 | struct efa_sw_stats sw_stats; | ||
| 50 | atomic64_t keep_alive_rcvd; | ||
| 51 | }; | ||
| 52 | |||
| 53 | struct efa_dev { | ||
| 54 | struct ib_device ibdev; | ||
| 55 | struct efa_com_dev edev; | ||
| 56 | struct pci_dev *pdev; | ||
| 57 | struct efa_com_get_device_attr_result dev_attr; | ||
| 58 | |||
| 59 | u64 reg_bar_addr; | ||
| 60 | u64 reg_bar_len; | ||
| 61 | u64 mem_bar_addr; | ||
| 62 | u64 mem_bar_len; | ||
| 63 | u64 db_bar_addr; | ||
| 64 | u64 db_bar_len; | ||
| 65 | u8 addr[EFA_GID_SIZE]; | ||
| 66 | u32 mtu; | ||
| 67 | |||
| 68 | int admin_msix_vector_idx; | ||
| 69 | struct efa_irq admin_irq; | ||
| 70 | |||
| 71 | struct efa_stats stats; | ||
| 72 | }; | ||
| 73 | |||
| 74 | struct efa_ucontext { | ||
| 75 | struct ib_ucontext ibucontext; | ||
| 76 | struct xarray mmap_xa; | ||
| 77 | u32 mmap_xa_page; | ||
| 78 | u16 uarn; | ||
| 79 | }; | ||
| 80 | |||
| 81 | struct efa_pd { | ||
| 82 | struct ib_pd ibpd; | ||
| 83 | u16 pdn; | ||
| 84 | }; | ||
| 85 | |||
| 86 | struct efa_mr { | ||
| 87 | struct ib_mr ibmr; | ||
| 88 | struct ib_umem *umem; | ||
| 89 | }; | ||
| 90 | |||
| 91 | struct efa_cq { | ||
| 92 | struct ib_cq ibcq; | ||
| 93 | struct efa_ucontext *ucontext; | ||
| 94 | dma_addr_t dma_addr; | ||
| 95 | void *cpu_addr; | ||
| 96 | size_t size; | ||
| 97 | u16 cq_idx; | ||
| 98 | }; | ||
| 99 | |||
| 100 | struct efa_qp { | ||
| 101 | struct ib_qp ibqp; | ||
| 102 | dma_addr_t rq_dma_addr; | ||
| 103 | void *rq_cpu_addr; | ||
| 104 | size_t rq_size; | ||
| 105 | enum ib_qp_state state; | ||
| 106 | u32 qp_handle; | ||
| 107 | u32 max_send_wr; | ||
| 108 | u32 max_recv_wr; | ||
| 109 | u32 max_send_sge; | ||
| 110 | u32 max_recv_sge; | ||
| 111 | u32 max_inline_data; | ||
| 112 | }; | ||
| 113 | |||
| 114 | struct efa_ah { | ||
| 115 | struct ib_ah ibah; | ||
| 116 | u16 ah; | ||
| 117 | /* dest_addr */ | ||
| 118 | u8 id[EFA_GID_SIZE]; | ||
| 119 | }; | ||
| 120 | |||
| 121 | int efa_query_device(struct ib_device *ibdev, | ||
| 122 | struct ib_device_attr *props, | ||
| 123 | struct ib_udata *udata); | ||
| 124 | int efa_query_port(struct ib_device *ibdev, u8 port, | ||
| 125 | struct ib_port_attr *props); | ||
| 126 | int efa_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, | ||
| 127 | int qp_attr_mask, | ||
| 128 | struct ib_qp_init_attr *qp_init_attr); | ||
| 129 | int efa_query_gid(struct ib_device *ibdev, u8 port, int index, | ||
| 130 | union ib_gid *gid); | ||
| 131 | int efa_query_pkey(struct ib_device *ibdev, u8 port, u16 index, | ||
| 132 | u16 *pkey); | ||
| 133 | int efa_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata); | ||
| 134 | void efa_dealloc_pd(struct ib_pd *ibpd, struct ib_udata *udata); | ||
| 135 | int efa_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata); | ||
| 136 | struct ib_qp *efa_create_qp(struct ib_pd *ibpd, | ||
| 137 | struct ib_qp_init_attr *init_attr, | ||
| 138 | struct ib_udata *udata); | ||
| 139 | int efa_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata); | ||
| 140 | struct ib_cq *efa_create_cq(struct ib_device *ibdev, | ||
| 141 | const struct ib_cq_init_attr *attr, | ||
| 142 | struct ib_udata *udata); | ||
| 143 | struct ib_mr *efa_reg_mr(struct ib_pd *ibpd, u64 start, u64 length, | ||
| 144 | u64 virt_addr, int access_flags, | ||
| 145 | struct ib_udata *udata); | ||
| 146 | int efa_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata); | ||
| 147 | int efa_get_port_immutable(struct ib_device *ibdev, u8 port_num, | ||
| 148 | struct ib_port_immutable *immutable); | ||
| 149 | int efa_alloc_ucontext(struct ib_ucontext *ibucontext, struct ib_udata *udata); | ||
| 150 | void efa_dealloc_ucontext(struct ib_ucontext *ibucontext); | ||
| 151 | int efa_mmap(struct ib_ucontext *ibucontext, | ||
| 152 | struct vm_area_struct *vma); | ||
| 153 | int efa_create_ah(struct ib_ah *ibah, | ||
| 154 | struct rdma_ah_attr *ah_attr, | ||
| 155 | u32 flags, | ||
| 156 | struct ib_udata *udata); | ||
| 157 | void efa_destroy_ah(struct ib_ah *ibah, u32 flags); | ||
| 158 | int efa_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr, | ||
| 159 | int qp_attr_mask, struct ib_udata *udata); | ||
| 160 | enum rdma_link_layer efa_port_link_layer(struct ib_device *ibdev, | ||
| 161 | u8 port_num); | ||
| 162 | |||
| 163 | #endif /* _EFA_H_ */ | ||
