Selvin Xavier | 1ac5a40 | 2017-02-10 03:19:33 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Broadcom NetXtreme-E RoCE driver. |
| 3 | * |
| 4 | * Copyright (c) 2016 - 2017, Broadcom. All rights reserved. The term |
| 5 | * Broadcom refers to Broadcom Limited and/or its subsidiaries. |
| 6 | * |
| 7 | * This software is available to you under a choice of one of two |
| 8 | * licenses. You may choose to be licensed under the terms of the GNU |
| 9 | * General Public License (GPL) Version 2, available from the file |
| 10 | * COPYING in the main directory of this source tree, or the |
| 11 | * BSD license below: |
| 12 | * |
| 13 | * Redistribution and use in source and binary forms, with or without |
| 14 | * modification, are permitted provided that the following conditions |
| 15 | * are met: |
| 16 | * |
| 17 | * 1. Redistributions of source code must retain the above copyright |
| 18 | * notice, this list of conditions and the following disclaimer. |
| 19 | * 2. Redistributions in binary form must reproduce the above copyright |
| 20 | * notice, this list of conditions and the following disclaimer in |
| 21 | * the documentation and/or other materials provided with the |
| 22 | * distribution. |
| 23 | * |
| 24 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' |
| 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 26 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 27 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS |
| 28 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 29 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 30 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 31 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 32 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 33 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 34 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 35 | * |
| 36 | * Description: IB Verbs interpreter (header) |
| 37 | */ |
| 38 | |
| 39 | #ifndef __BNXT_RE_IB_VERBS_H__ |
| 40 | #define __BNXT_RE_IB_VERBS_H__ |
| 41 | |
| 42 | struct bnxt_re_gid_ctx { |
| 43 | u32 idx; |
| 44 | u32 refcnt; |
| 45 | }; |
| 46 | |
Eddie Wai | 9152e0b | 2017-06-14 03:26:23 -0700 | [diff] [blame] | 47 | #define BNXT_RE_FENCE_BYTES 64 |
| 48 | struct bnxt_re_fence_data { |
| 49 | u32 size; |
| 50 | u8 va[BNXT_RE_FENCE_BYTES]; |
| 51 | dma_addr_t dma_addr; |
| 52 | struct bnxt_re_mr *mr; |
| 53 | struct ib_mw *mw; |
| 54 | struct bnxt_qplib_swqe bind_wqe; |
| 55 | u32 bind_rkey; |
| 56 | }; |
| 57 | |
Selvin Xavier | 1ac5a40 | 2017-02-10 03:19:33 -0800 | [diff] [blame] | 58 | struct bnxt_re_pd { |
| 59 | struct bnxt_re_dev *rdev; |
| 60 | struct ib_pd ib_pd; |
| 61 | struct bnxt_qplib_pd qplib_pd; |
| 62 | struct bnxt_qplib_dpi dpi; |
Eddie Wai | 9152e0b | 2017-06-14 03:26:23 -0700 | [diff] [blame] | 63 | struct bnxt_re_fence_data fence; |
Selvin Xavier | 1ac5a40 | 2017-02-10 03:19:33 -0800 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | struct bnxt_re_ah { |
| 67 | struct bnxt_re_dev *rdev; |
| 68 | struct ib_ah ib_ah; |
| 69 | struct bnxt_qplib_ah qplib_ah; |
| 70 | }; |
| 71 | |
| 72 | struct bnxt_re_qp { |
| 73 | struct list_head list; |
| 74 | struct bnxt_re_dev *rdev; |
| 75 | struct ib_qp ib_qp; |
| 76 | spinlock_t sq_lock; /* protect sq */ |
Devesh Sharma | 018cf59 | 2017-05-22 03:15:40 -0700 | [diff] [blame] | 77 | spinlock_t rq_lock; /* protect rq */ |
Selvin Xavier | 1ac5a40 | 2017-02-10 03:19:33 -0800 | [diff] [blame] | 78 | struct bnxt_qplib_qp qplib_qp; |
| 79 | struct ib_umem *sumem; |
| 80 | struct ib_umem *rumem; |
| 81 | /* QP1 */ |
| 82 | u32 send_psn; |
| 83 | struct ib_ud_header qp1_hdr; |
| 84 | }; |
| 85 | |
| 86 | struct bnxt_re_cq { |
| 87 | struct bnxt_re_dev *rdev; |
| 88 | spinlock_t cq_lock; /* protect cq */ |
| 89 | u16 cq_count; |
| 90 | u16 cq_period; |
| 91 | struct ib_cq ib_cq; |
| 92 | struct bnxt_qplib_cq qplib_cq; |
| 93 | struct bnxt_qplib_cqe *cql; |
| 94 | #define MAX_CQL_PER_POLL 1024 |
| 95 | u32 max_cql; |
| 96 | struct ib_umem *umem; |
| 97 | }; |
| 98 | |
| 99 | struct bnxt_re_mr { |
| 100 | struct bnxt_re_dev *rdev; |
| 101 | struct ib_mr ib_mr; |
| 102 | struct ib_umem *ib_umem; |
| 103 | struct bnxt_qplib_mrw qplib_mr; |
| 104 | u32 npages; |
| 105 | u64 *pages; |
| 106 | struct bnxt_qplib_frpl qplib_frpl; |
| 107 | }; |
| 108 | |
| 109 | struct bnxt_re_frpl { |
| 110 | struct bnxt_re_dev *rdev; |
| 111 | struct bnxt_qplib_frpl qplib_frpl; |
| 112 | u64 *page_list; |
| 113 | }; |
| 114 | |
| 115 | struct bnxt_re_fmr { |
| 116 | struct bnxt_re_dev *rdev; |
| 117 | struct ib_fmr ib_fmr; |
| 118 | struct bnxt_qplib_mrw qplib_fmr; |
| 119 | }; |
| 120 | |
| 121 | struct bnxt_re_mw { |
| 122 | struct bnxt_re_dev *rdev; |
| 123 | struct ib_mw ib_mw; |
| 124 | struct bnxt_qplib_mrw qplib_mw; |
| 125 | }; |
| 126 | |
| 127 | struct bnxt_re_ucontext { |
| 128 | struct bnxt_re_dev *rdev; |
| 129 | struct ib_ucontext ib_uctx; |
| 130 | struct bnxt_qplib_dpi *dpi; |
| 131 | void *shpg; |
| 132 | spinlock_t sh_lock; /* protect shpg */ |
| 133 | }; |
| 134 | |
| 135 | struct net_device *bnxt_re_get_netdev(struct ib_device *ibdev, u8 port_num); |
| 136 | |
| 137 | int bnxt_re_query_device(struct ib_device *ibdev, |
| 138 | struct ib_device_attr *ib_attr, |
| 139 | struct ib_udata *udata); |
| 140 | int bnxt_re_modify_device(struct ib_device *ibdev, |
| 141 | int device_modify_mask, |
| 142 | struct ib_device_modify *device_modify); |
| 143 | int bnxt_re_query_port(struct ib_device *ibdev, u8 port_num, |
| 144 | struct ib_port_attr *port_attr); |
| 145 | int bnxt_re_modify_port(struct ib_device *ibdev, u8 port_num, |
| 146 | int port_modify_mask, |
| 147 | struct ib_port_modify *port_modify); |
| 148 | int bnxt_re_get_port_immutable(struct ib_device *ibdev, u8 port_num, |
| 149 | struct ib_port_immutable *immutable); |
| 150 | int bnxt_re_query_pkey(struct ib_device *ibdev, u8 port_num, |
| 151 | u16 index, u16 *pkey); |
| 152 | int bnxt_re_del_gid(struct ib_device *ibdev, u8 port_num, |
| 153 | unsigned int index, void **context); |
| 154 | int bnxt_re_add_gid(struct ib_device *ibdev, u8 port_num, |
| 155 | unsigned int index, const union ib_gid *gid, |
| 156 | const struct ib_gid_attr *attr, void **context); |
| 157 | int bnxt_re_query_gid(struct ib_device *ibdev, u8 port_num, |
| 158 | int index, union ib_gid *gid); |
| 159 | enum rdma_link_layer bnxt_re_get_link_layer(struct ib_device *ibdev, |
| 160 | u8 port_num); |
| 161 | struct ib_pd *bnxt_re_alloc_pd(struct ib_device *ibdev, |
| 162 | struct ib_ucontext *context, |
| 163 | struct ib_udata *udata); |
| 164 | int bnxt_re_dealloc_pd(struct ib_pd *pd); |
| 165 | struct ib_ah *bnxt_re_create_ah(struct ib_pd *pd, |
Dasaratharaman Chandramouli | 9089885 | 2017-04-29 14:41:18 -0400 | [diff] [blame] | 166 | struct rdma_ah_attr *ah_attr, |
Selvin Xavier | 1ac5a40 | 2017-02-10 03:19:33 -0800 | [diff] [blame] | 167 | struct ib_udata *udata); |
Dasaratharaman Chandramouli | 9089885 | 2017-04-29 14:41:18 -0400 | [diff] [blame] | 168 | int bnxt_re_modify_ah(struct ib_ah *ah, struct rdma_ah_attr *ah_attr); |
| 169 | int bnxt_re_query_ah(struct ib_ah *ah, struct rdma_ah_attr *ah_attr); |
Selvin Xavier | 1ac5a40 | 2017-02-10 03:19:33 -0800 | [diff] [blame] | 170 | int bnxt_re_destroy_ah(struct ib_ah *ah); |
| 171 | struct ib_qp *bnxt_re_create_qp(struct ib_pd *pd, |
| 172 | struct ib_qp_init_attr *qp_init_attr, |
| 173 | struct ib_udata *udata); |
| 174 | int bnxt_re_modify_qp(struct ib_qp *qp, struct ib_qp_attr *qp_attr, |
| 175 | int qp_attr_mask, struct ib_udata *udata); |
| 176 | int bnxt_re_query_qp(struct ib_qp *qp, struct ib_qp_attr *qp_attr, |
| 177 | int qp_attr_mask, struct ib_qp_init_attr *qp_init_attr); |
| 178 | int bnxt_re_destroy_qp(struct ib_qp *qp); |
| 179 | int bnxt_re_post_send(struct ib_qp *qp, struct ib_send_wr *send_wr, |
| 180 | struct ib_send_wr **bad_send_wr); |
| 181 | int bnxt_re_post_recv(struct ib_qp *qp, struct ib_recv_wr *recv_wr, |
| 182 | struct ib_recv_wr **bad_recv_wr); |
| 183 | struct ib_cq *bnxt_re_create_cq(struct ib_device *ibdev, |
| 184 | const struct ib_cq_init_attr *attr, |
| 185 | struct ib_ucontext *context, |
| 186 | struct ib_udata *udata); |
| 187 | int bnxt_re_destroy_cq(struct ib_cq *cq); |
| 188 | int bnxt_re_poll_cq(struct ib_cq *cq, int num_entries, struct ib_wc *wc); |
| 189 | int bnxt_re_req_notify_cq(struct ib_cq *cq, enum ib_cq_notify_flags flags); |
| 190 | struct ib_mr *bnxt_re_get_dma_mr(struct ib_pd *pd, int mr_access_flags); |
| 191 | |
| 192 | int bnxt_re_map_mr_sg(struct ib_mr *ib_mr, struct scatterlist *sg, int sg_nents, |
| 193 | unsigned int *sg_offset); |
| 194 | struct ib_mr *bnxt_re_alloc_mr(struct ib_pd *ib_pd, enum ib_mr_type mr_type, |
| 195 | u32 max_num_sg); |
| 196 | int bnxt_re_dereg_mr(struct ib_mr *mr); |
Eddie Wai | 9152e0b | 2017-06-14 03:26:23 -0700 | [diff] [blame] | 197 | struct ib_mw *bnxt_re_alloc_mw(struct ib_pd *ib_pd, enum ib_mw_type type, |
| 198 | struct ib_udata *udata); |
| 199 | int bnxt_re_dealloc_mw(struct ib_mw *mw); |
Selvin Xavier | 1ac5a40 | 2017-02-10 03:19:33 -0800 | [diff] [blame] | 200 | struct ib_mr *bnxt_re_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, |
| 201 | u64 virt_addr, int mr_access_flags, |
| 202 | struct ib_udata *udata); |
| 203 | struct ib_ucontext *bnxt_re_alloc_ucontext(struct ib_device *ibdev, |
| 204 | struct ib_udata *udata); |
| 205 | int bnxt_re_dealloc_ucontext(struct ib_ucontext *context); |
| 206 | int bnxt_re_mmap(struct ib_ucontext *context, struct vm_area_struct *vma); |
| 207 | #endif /* __BNXT_RE_IB_VERBS_H__ */ |