]> Git Repo - linux.git/blob - drivers/infiniband/hw/efa/efa.h
Merge tag 'cxl-for-6.0' of git://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl
[linux.git] / drivers / infiniband / hw / efa / efa.h
1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */
2 /*
3  * Copyright 2018-2021 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/interrupt.h>
11 #include <linux/pci.h>
12
13 #include <rdma/efa-abi.h>
14 #include <rdma/ib_verbs.h>
15
16 #include "efa_com_cmd.h"
17
18 #define DRV_MODULE_NAME         "efa"
19 #define DEVICE_NAME             "Elastic Fabric Adapter (EFA)"
20
21 #define EFA_IRQNAME_SIZE        40
22
23 #define EFA_MGMNT_MSIX_VEC_IDX            0
24 #define EFA_COMP_EQS_VEC_BASE             1
25
26 struct efa_irq {
27         irq_handler_t handler;
28         void *data;
29         u32 irqn;
30         u32 vector;
31         cpumask_t affinity_hint_mask;
32         char name[EFA_IRQNAME_SIZE];
33 };
34
35 /* Don't use anything other than atomic64 */
36 struct efa_stats {
37         atomic64_t alloc_pd_err;
38         atomic64_t create_qp_err;
39         atomic64_t create_cq_err;
40         atomic64_t reg_mr_err;
41         atomic64_t alloc_ucontext_err;
42         atomic64_t create_ah_err;
43         atomic64_t mmap_err;
44         atomic64_t keep_alive_rcvd;
45 };
46
47 struct efa_dev {
48         struct ib_device ibdev;
49         struct efa_com_dev edev;
50         struct pci_dev *pdev;
51         struct efa_com_get_device_attr_result dev_attr;
52
53         u64 reg_bar_addr;
54         u64 reg_bar_len;
55         u64 mem_bar_addr;
56         u64 mem_bar_len;
57         u64 db_bar_addr;
58         u64 db_bar_len;
59
60         int admin_msix_vector_idx;
61         struct efa_irq admin_irq;
62
63         struct efa_stats stats;
64
65         /* Array of completion EQs */
66         struct efa_eq *eqs;
67         unsigned int neqs;
68
69         /* Only stores CQs with interrupts enabled */
70         struct xarray cqs_xa;
71 };
72
73 struct efa_ucontext {
74         struct ib_ucontext ibucontext;
75         u16 uarn;
76 };
77
78 struct efa_pd {
79         struct ib_pd ibpd;
80         u16 pdn;
81 };
82
83 struct efa_mr {
84         struct ib_mr ibmr;
85         struct ib_umem *umem;
86 };
87
88 struct efa_cq {
89         struct ib_cq ibcq;
90         struct efa_ucontext *ucontext;
91         dma_addr_t dma_addr;
92         void *cpu_addr;
93         struct rdma_user_mmap_entry *mmap_entry;
94         struct rdma_user_mmap_entry *db_mmap_entry;
95         size_t size;
96         u16 cq_idx;
97         /* NULL when no interrupts requested */
98         struct efa_eq *eq;
99 };
100
101 struct efa_qp {
102         struct ib_qp ibqp;
103         dma_addr_t rq_dma_addr;
104         void *rq_cpu_addr;
105         size_t rq_size;
106         enum ib_qp_state state;
107
108         /* Used for saving mmap_xa entries */
109         struct rdma_user_mmap_entry *sq_db_mmap_entry;
110         struct rdma_user_mmap_entry *llq_desc_mmap_entry;
111         struct rdma_user_mmap_entry *rq_db_mmap_entry;
112         struct rdma_user_mmap_entry *rq_mmap_entry;
113
114         u32 qp_handle;
115         u32 max_send_wr;
116         u32 max_recv_wr;
117         u32 max_send_sge;
118         u32 max_recv_sge;
119         u32 max_inline_data;
120 };
121
122 struct efa_ah {
123         struct ib_ah ibah;
124         u16 ah;
125         /* dest_addr */
126         u8 id[EFA_GID_SIZE];
127 };
128
129 struct efa_eq {
130         struct efa_com_eq eeq;
131         struct efa_irq irq;
132 };
133
134 int efa_query_device(struct ib_device *ibdev,
135                      struct ib_device_attr *props,
136                      struct ib_udata *udata);
137 int efa_query_port(struct ib_device *ibdev, u32 port,
138                    struct ib_port_attr *props);
139 int efa_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
140                  int qp_attr_mask,
141                  struct ib_qp_init_attr *qp_init_attr);
142 int efa_query_gid(struct ib_device *ibdev, u32 port, int index,
143                   union ib_gid *gid);
144 int efa_query_pkey(struct ib_device *ibdev, u32 port, u16 index,
145                    u16 *pkey);
146 int efa_alloc_pd(struct ib_pd *ibpd, struct ib_udata *udata);
147 int efa_dealloc_pd(struct ib_pd *ibpd, struct ib_udata *udata);
148 int efa_destroy_qp(struct ib_qp *ibqp, struct ib_udata *udata);
149 int efa_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *init_attr,
150                   struct ib_udata *udata);
151 int efa_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata);
152 int efa_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
153                   struct ib_udata *udata);
154 struct ib_mr *efa_reg_mr(struct ib_pd *ibpd, u64 start, u64 length,
155                          u64 virt_addr, int access_flags,
156                          struct ib_udata *udata);
157 struct ib_mr *efa_reg_user_mr_dmabuf(struct ib_pd *ibpd, u64 start,
158                                      u64 length, u64 virt_addr,
159                                      int fd, int access_flags,
160                                      struct ib_udata *udata);
161 int efa_dereg_mr(struct ib_mr *ibmr, struct ib_udata *udata);
162 int efa_get_port_immutable(struct ib_device *ibdev, u32 port_num,
163                            struct ib_port_immutable *immutable);
164 int efa_alloc_ucontext(struct ib_ucontext *ibucontext, struct ib_udata *udata);
165 void efa_dealloc_ucontext(struct ib_ucontext *ibucontext);
166 int efa_mmap(struct ib_ucontext *ibucontext,
167              struct vm_area_struct *vma);
168 void efa_mmap_free(struct rdma_user_mmap_entry *rdma_entry);
169 int efa_create_ah(struct ib_ah *ibah,
170                   struct rdma_ah_init_attr *init_attr,
171                   struct ib_udata *udata);
172 int efa_destroy_ah(struct ib_ah *ibah, u32 flags);
173 int efa_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
174                   int qp_attr_mask, struct ib_udata *udata);
175 enum rdma_link_layer efa_port_link_layer(struct ib_device *ibdev,
176                                          u32 port_num);
177 struct rdma_hw_stats *efa_alloc_hw_port_stats(struct ib_device *ibdev, u32 port_num);
178 struct rdma_hw_stats *efa_alloc_hw_device_stats(struct ib_device *ibdev);
179 int efa_get_hw_stats(struct ib_device *ibdev, struct rdma_hw_stats *stats,
180                      u32 port_num, int index);
181
182 #endif /* _EFA_H_ */
This page took 0.051731 seconds and 4 git commands to generate.