18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause */
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ci/* Authors: Bernard Metzler <bmt@zurich.ibm.com> */
48c2ecf20Sopenharmony_ci/* Copyright (c) 2008-2019, IBM Corporation */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#ifndef _SIW_VERBS_H
78c2ecf20Sopenharmony_ci#define _SIW_VERBS_H
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <linux/errno.h>
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include <rdma/iw_cm.h>
128c2ecf20Sopenharmony_ci#include <rdma/ib_verbs.h>
138c2ecf20Sopenharmony_ci#include <rdma/ib_user_verbs.h>
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#include "siw.h"
168c2ecf20Sopenharmony_ci#include "siw_cm.h"
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci/*
198c2ecf20Sopenharmony_ci * siw_copy_sgl()
208c2ecf20Sopenharmony_ci *
218c2ecf20Sopenharmony_ci * Copy SGL from RDMA core representation to local
228c2ecf20Sopenharmony_ci * representation.
238c2ecf20Sopenharmony_ci */
248c2ecf20Sopenharmony_cistatic inline void siw_copy_sgl(struct ib_sge *sge, struct siw_sge *siw_sge,
258c2ecf20Sopenharmony_ci				int num_sge)
268c2ecf20Sopenharmony_ci{
278c2ecf20Sopenharmony_ci	while (num_sge--) {
288c2ecf20Sopenharmony_ci		siw_sge->laddr = sge->addr;
298c2ecf20Sopenharmony_ci		siw_sge->length = sge->length;
308c2ecf20Sopenharmony_ci		siw_sge->lkey = sge->lkey;
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci		siw_sge++;
338c2ecf20Sopenharmony_ci		sge++;
348c2ecf20Sopenharmony_ci	}
358c2ecf20Sopenharmony_ci}
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ciint siw_alloc_ucontext(struct ib_ucontext *base_ctx, struct ib_udata *udata);
388c2ecf20Sopenharmony_civoid siw_dealloc_ucontext(struct ib_ucontext *base_ctx);
398c2ecf20Sopenharmony_ciint siw_query_port(struct ib_device *base_dev, u8 port,
408c2ecf20Sopenharmony_ci		   struct ib_port_attr *attr);
418c2ecf20Sopenharmony_ciint siw_get_port_immutable(struct ib_device *base_dev, u8 port,
428c2ecf20Sopenharmony_ci			   struct ib_port_immutable *port_immutable);
438c2ecf20Sopenharmony_ciint siw_query_device(struct ib_device *base_dev, struct ib_device_attr *attr,
448c2ecf20Sopenharmony_ci		     struct ib_udata *udata);
458c2ecf20Sopenharmony_ciint siw_create_cq(struct ib_cq *base_cq, const struct ib_cq_init_attr *attr,
468c2ecf20Sopenharmony_ci		  struct ib_udata *udata);
478c2ecf20Sopenharmony_ciint siw_query_port(struct ib_device *base_dev, u8 port,
488c2ecf20Sopenharmony_ci		   struct ib_port_attr *attr);
498c2ecf20Sopenharmony_ciint siw_query_gid(struct ib_device *base_dev, u8 port, int idx,
508c2ecf20Sopenharmony_ci		  union ib_gid *gid);
518c2ecf20Sopenharmony_ciint siw_alloc_pd(struct ib_pd *base_pd, struct ib_udata *udata);
528c2ecf20Sopenharmony_ciint siw_dealloc_pd(struct ib_pd *base_pd, struct ib_udata *udata);
538c2ecf20Sopenharmony_cistruct ib_qp *siw_create_qp(struct ib_pd *base_pd,
548c2ecf20Sopenharmony_ci			    struct ib_qp_init_attr *attr,
558c2ecf20Sopenharmony_ci			    struct ib_udata *udata);
568c2ecf20Sopenharmony_ciint siw_query_qp(struct ib_qp *base_qp, struct ib_qp_attr *qp_attr,
578c2ecf20Sopenharmony_ci		 int qp_attr_mask, struct ib_qp_init_attr *qp_init_attr);
588c2ecf20Sopenharmony_ciint siw_verbs_modify_qp(struct ib_qp *base_qp, struct ib_qp_attr *attr,
598c2ecf20Sopenharmony_ci			int attr_mask, struct ib_udata *udata);
608c2ecf20Sopenharmony_ciint siw_destroy_qp(struct ib_qp *base_qp, struct ib_udata *udata);
618c2ecf20Sopenharmony_ciint siw_post_send(struct ib_qp *base_qp, const struct ib_send_wr *wr,
628c2ecf20Sopenharmony_ci		  const struct ib_send_wr **bad_wr);
638c2ecf20Sopenharmony_ciint siw_post_receive(struct ib_qp *base_qp, const struct ib_recv_wr *wr,
648c2ecf20Sopenharmony_ci		     const struct ib_recv_wr **bad_wr);
658c2ecf20Sopenharmony_ciint siw_destroy_cq(struct ib_cq *base_cq, struct ib_udata *udata);
668c2ecf20Sopenharmony_ciint siw_poll_cq(struct ib_cq *base_cq, int num_entries, struct ib_wc *wc);
678c2ecf20Sopenharmony_ciint siw_req_notify_cq(struct ib_cq *base_cq, enum ib_cq_notify_flags flags);
688c2ecf20Sopenharmony_cistruct ib_mr *siw_reg_user_mr(struct ib_pd *base_pd, u64 start, u64 len,
698c2ecf20Sopenharmony_ci			      u64 rnic_va, int rights, struct ib_udata *udata);
708c2ecf20Sopenharmony_cistruct ib_mr *siw_alloc_mr(struct ib_pd *base_pd, enum ib_mr_type mr_type,
718c2ecf20Sopenharmony_ci			   u32 max_sge);
728c2ecf20Sopenharmony_cistruct ib_mr *siw_get_dma_mr(struct ib_pd *base_pd, int rights);
738c2ecf20Sopenharmony_ciint siw_map_mr_sg(struct ib_mr *base_mr, struct scatterlist *sl, int num_sle,
748c2ecf20Sopenharmony_ci		  unsigned int *sg_off);
758c2ecf20Sopenharmony_ciint siw_dereg_mr(struct ib_mr *base_mr, struct ib_udata *udata);
768c2ecf20Sopenharmony_ciint siw_create_srq(struct ib_srq *base_srq, struct ib_srq_init_attr *attr,
778c2ecf20Sopenharmony_ci		   struct ib_udata *udata);
788c2ecf20Sopenharmony_ciint siw_modify_srq(struct ib_srq *base_srq, struct ib_srq_attr *attr,
798c2ecf20Sopenharmony_ci		   enum ib_srq_attr_mask mask, struct ib_udata *udata);
808c2ecf20Sopenharmony_ciint siw_query_srq(struct ib_srq *base_srq, struct ib_srq_attr *attr);
818c2ecf20Sopenharmony_ciint siw_destroy_srq(struct ib_srq *base_srq, struct ib_udata *udata);
828c2ecf20Sopenharmony_ciint siw_post_srq_recv(struct ib_srq *base_srq, const struct ib_recv_wr *wr,
838c2ecf20Sopenharmony_ci		      const struct ib_recv_wr **bad_wr);
848c2ecf20Sopenharmony_ciint siw_mmap(struct ib_ucontext *ctx, struct vm_area_struct *vma);
858c2ecf20Sopenharmony_civoid siw_mmap_free(struct rdma_user_mmap_entry *rdma_entry);
868c2ecf20Sopenharmony_civoid siw_qp_event(struct siw_qp *qp, enum ib_event_type type);
878c2ecf20Sopenharmony_civoid siw_cq_event(struct siw_cq *cq, enum ib_event_type type);
888c2ecf20Sopenharmony_civoid siw_srq_event(struct siw_srq *srq, enum ib_event_type type);
898c2ecf20Sopenharmony_civoid siw_port_event(struct siw_device *dev, u8 port, enum ib_event_type type);
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci#endif
92