Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Broadcom NetXtreme-E RoCE driver.
0003  *
0004  * Copyright (c) 2016 - 2017, Broadcom. All rights reserved.  The term
0005  * Broadcom refers to Broadcom Limited and/or its subsidiaries.
0006  *
0007  * This software is available to you under a choice of one of two
0008  * licenses.  You may choose to be licensed under the terms of the GNU
0009  * General Public License (GPL) Version 2, available from the file
0010  * COPYING in the main directory of this source tree, or the
0011  * BSD license below:
0012  *
0013  * Redistribution and use in source and binary forms, with or without
0014  * modification, are permitted provided that the following conditions
0015  * are met:
0016  *
0017  * 1. Redistributions of source code must retain the above copyright
0018  *    notice, this list of conditions and the following disclaimer.
0019  * 2. Redistributions in binary form must reproduce the above copyright
0020  *    notice, this list of conditions and the following disclaimer in
0021  *    the documentation and/or other materials provided with the
0022  *    distribution.
0023  *
0024  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
0025  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
0026  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
0027  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
0028  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0029  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0030  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
0031  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
0032  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
0033  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
0034  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0035  *
0036  * Description: IB Verbs interpreter (header)
0037  */
0038 
0039 #ifndef __BNXT_RE_IB_VERBS_H__
0040 #define __BNXT_RE_IB_VERBS_H__
0041 
0042 struct bnxt_re_gid_ctx {
0043     u32         idx;
0044     u32         refcnt;
0045 };
0046 
0047 #define BNXT_RE_FENCE_BYTES 64
0048 struct bnxt_re_fence_data {
0049     u32 size;
0050     u8 va[BNXT_RE_FENCE_BYTES];
0051     dma_addr_t dma_addr;
0052     struct bnxt_re_mr *mr;
0053     struct ib_mw *mw;
0054     struct bnxt_qplib_swqe bind_wqe;
0055     u32 bind_rkey;
0056 };
0057 
0058 struct bnxt_re_pd {
0059     struct ib_pd            ib_pd;
0060     struct bnxt_re_dev  *rdev;
0061     struct bnxt_qplib_pd    qplib_pd;
0062     struct bnxt_re_fence_data fence;
0063 };
0064 
0065 struct bnxt_re_ah {
0066     struct ib_ah        ib_ah;
0067     struct bnxt_re_dev  *rdev;
0068     struct bnxt_qplib_ah    qplib_ah;
0069 };
0070 
0071 struct bnxt_re_srq {
0072     struct ib_srq       ib_srq;
0073     struct bnxt_re_dev  *rdev;
0074     u32         srq_limit;
0075     struct bnxt_qplib_srq   qplib_srq;
0076     struct ib_umem      *umem;
0077     spinlock_t      lock;       /* protect srq */
0078 };
0079 
0080 struct bnxt_re_qp {
0081     struct ib_qp        ib_qp;
0082     struct list_head    list;
0083     struct bnxt_re_dev  *rdev;
0084     spinlock_t      sq_lock;    /* protect sq */
0085     spinlock_t      rq_lock;    /* protect rq */
0086     struct bnxt_qplib_qp    qplib_qp;
0087     struct ib_umem      *sumem;
0088     struct ib_umem      *rumem;
0089     /* QP1 */
0090     u32         send_psn;
0091     struct ib_ud_header qp1_hdr;
0092     struct bnxt_re_cq   *scq;
0093     struct bnxt_re_cq   *rcq;
0094 };
0095 
0096 struct bnxt_re_cq {
0097     struct ib_cq        ib_cq;
0098     struct bnxt_re_dev  *rdev;
0099     spinlock_t              cq_lock;    /* protect cq */
0100     u16         cq_count;
0101     u16         cq_period;
0102     struct bnxt_qplib_cq    qplib_cq;
0103     struct bnxt_qplib_cqe   *cql;
0104 #define MAX_CQL_PER_POLL    1024
0105     u32         max_cql;
0106     struct ib_umem      *umem;
0107 };
0108 
0109 struct bnxt_re_mr {
0110     struct bnxt_re_dev  *rdev;
0111     struct ib_mr        ib_mr;
0112     struct ib_umem      *ib_umem;
0113     struct bnxt_qplib_mrw   qplib_mr;
0114     u32         npages;
0115     u64         *pages;
0116     struct bnxt_qplib_frpl  qplib_frpl;
0117 };
0118 
0119 struct bnxt_re_frpl {
0120     struct bnxt_re_dev      *rdev;
0121     struct bnxt_qplib_frpl      qplib_frpl;
0122     u64             *page_list;
0123 };
0124 
0125 struct bnxt_re_mw {
0126     struct bnxt_re_dev  *rdev;
0127     struct ib_mw        ib_mw;
0128     struct bnxt_qplib_mrw   qplib_mw;
0129 };
0130 
0131 struct bnxt_re_ucontext {
0132     struct ib_ucontext      ib_uctx;
0133     struct bnxt_re_dev  *rdev;
0134     struct bnxt_qplib_dpi   dpi;
0135     void            *shpg;
0136     spinlock_t      sh_lock;    /* protect shpg */
0137 };
0138 
0139 static inline u16 bnxt_re_get_swqe_size(int nsge)
0140 {
0141     return sizeof(struct sq_send_hdr) + nsge * sizeof(struct sq_sge);
0142 }
0143 
0144 static inline u16 bnxt_re_get_rwqe_size(int nsge)
0145 {
0146     return sizeof(struct rq_wqe_hdr) + (nsge * sizeof(struct sq_sge));
0147 }
0148 
0149 int bnxt_re_query_device(struct ib_device *ibdev,
0150              struct ib_device_attr *ib_attr,
0151              struct ib_udata *udata);
0152 int bnxt_re_query_port(struct ib_device *ibdev, u32 port_num,
0153                struct ib_port_attr *port_attr);
0154 int bnxt_re_get_port_immutable(struct ib_device *ibdev, u32 port_num,
0155                    struct ib_port_immutable *immutable);
0156 void bnxt_re_query_fw_str(struct ib_device *ibdev, char *str);
0157 int bnxt_re_query_pkey(struct ib_device *ibdev, u32 port_num,
0158                u16 index, u16 *pkey);
0159 int bnxt_re_del_gid(const struct ib_gid_attr *attr, void **context);
0160 int bnxt_re_add_gid(const struct ib_gid_attr *attr, void **context);
0161 int bnxt_re_query_gid(struct ib_device *ibdev, u32 port_num,
0162               int index, union ib_gid *gid);
0163 enum rdma_link_layer bnxt_re_get_link_layer(struct ib_device *ibdev,
0164                         u32 port_num);
0165 int bnxt_re_alloc_pd(struct ib_pd *pd, struct ib_udata *udata);
0166 int bnxt_re_dealloc_pd(struct ib_pd *pd, struct ib_udata *udata);
0167 int bnxt_re_create_ah(struct ib_ah *ah, struct rdma_ah_init_attr *init_attr,
0168               struct ib_udata *udata);
0169 int bnxt_re_query_ah(struct ib_ah *ah, struct rdma_ah_attr *ah_attr);
0170 int bnxt_re_destroy_ah(struct ib_ah *ah, u32 flags);
0171 int bnxt_re_create_srq(struct ib_srq *srq,
0172                struct ib_srq_init_attr *srq_init_attr,
0173                struct ib_udata *udata);
0174 int bnxt_re_modify_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr,
0175                enum ib_srq_attr_mask srq_attr_mask,
0176                struct ib_udata *udata);
0177 int bnxt_re_query_srq(struct ib_srq *srq, struct ib_srq_attr *srq_attr);
0178 int bnxt_re_destroy_srq(struct ib_srq *srq, struct ib_udata *udata);
0179 int bnxt_re_post_srq_recv(struct ib_srq *srq, const struct ib_recv_wr *recv_wr,
0180               const struct ib_recv_wr **bad_recv_wr);
0181 int bnxt_re_create_qp(struct ib_qp *qp, struct ib_qp_init_attr *qp_init_attr,
0182               struct ib_udata *udata);
0183 int bnxt_re_modify_qp(struct ib_qp *qp, struct ib_qp_attr *qp_attr,
0184               int qp_attr_mask, struct ib_udata *udata);
0185 int bnxt_re_query_qp(struct ib_qp *qp, struct ib_qp_attr *qp_attr,
0186              int qp_attr_mask, struct ib_qp_init_attr *qp_init_attr);
0187 int bnxt_re_destroy_qp(struct ib_qp *qp, struct ib_udata *udata);
0188 int bnxt_re_post_send(struct ib_qp *qp, const struct ib_send_wr *send_wr,
0189               const struct ib_send_wr **bad_send_wr);
0190 int bnxt_re_post_recv(struct ib_qp *qp, const struct ib_recv_wr *recv_wr,
0191               const struct ib_recv_wr **bad_recv_wr);
0192 int bnxt_re_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
0193               struct ib_udata *udata);
0194 int bnxt_re_destroy_cq(struct ib_cq *cq, struct ib_udata *udata);
0195 int bnxt_re_poll_cq(struct ib_cq *cq, int num_entries, struct ib_wc *wc);
0196 int bnxt_re_req_notify_cq(struct ib_cq *cq, enum ib_cq_notify_flags flags);
0197 struct ib_mr *bnxt_re_get_dma_mr(struct ib_pd *pd, int mr_access_flags);
0198 
0199 int bnxt_re_map_mr_sg(struct ib_mr *ib_mr, struct scatterlist *sg, int sg_nents,
0200               unsigned int *sg_offset);
0201 struct ib_mr *bnxt_re_alloc_mr(struct ib_pd *ib_pd, enum ib_mr_type mr_type,
0202                    u32 max_num_sg);
0203 int bnxt_re_dereg_mr(struct ib_mr *mr, struct ib_udata *udata);
0204 struct ib_mw *bnxt_re_alloc_mw(struct ib_pd *ib_pd, enum ib_mw_type type,
0205                    struct ib_udata *udata);
0206 int bnxt_re_dealloc_mw(struct ib_mw *mw);
0207 struct ib_mr *bnxt_re_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
0208                   u64 virt_addr, int mr_access_flags,
0209                   struct ib_udata *udata);
0210 int bnxt_re_alloc_ucontext(struct ib_ucontext *ctx, struct ib_udata *udata);
0211 void bnxt_re_dealloc_ucontext(struct ib_ucontext *context);
0212 int bnxt_re_mmap(struct ib_ucontext *context, struct vm_area_struct *vma);
0213 
0214 unsigned long bnxt_re_lock_cqs(struct bnxt_re_qp *qp);
0215 void bnxt_re_unlock_cqs(struct bnxt_re_qp *qp, unsigned long flags);
0216 #endif /* __BNXT_RE_IB_VERBS_H__ */