[openib-general] Update from merging in Roland's changes...
Sean Hefty
mshefty at ichips.intel.com
Fri Jul 30 15:17:13 PDT 2004
I've updated ib_verbs based on changes that Roland had in his copy of the file. Specifically, I've updated the ib_xxx structures to include pointers to referenced items, added a usecnt field, and converted the functions from prototypes into static inline routines. The patch for this update is listed below.
- Sean
Index: ib_verbs.h
===================================================================
--- ib_verbs.h (revision 547)
+++ ib_verbs.h (working copy)
@@ -26,6 +26,11 @@
#if !defined( IB_VERBS_H )
#define IB_VERBS_H
+#include <linux/types.h>
+#include <asm/atomic.h>
+
+struct ib_device;
+
enum ib_event_type {
IB_EVENT_CQ_ERR,
IB_EVENT_QP_FATAL,
@@ -60,39 +65,56 @@
struct ib_pd {
struct ib_device *device;
+ atomic_t usecnt;
};
struct ib_ah {
struct ib_device *device;
+ struct ib_pd *pd;
+ atomic_t usecnt;
};
struct ib_cq {
struct ib_device *device;
ib_comp_handler comp_handler;
void *cq_context;
+ int cqe;
+ atomic_t usecnt;
};
struct ib_srq {
struct ib_device *device;
+ struct ib_pd *pd;
void *srq_context;
+ atomic_t usecnt;
};
struct ib_qp {
struct ib_device *device;
+ struct ib_pd *pd;
+ struct ib_cq *send_cq;
+ struct ib_cq *recv_cq;
void *qp_context;
u32 qp_num;
+ atomic_t usecnt;
};
struct ib_mr {
struct ib_device *device;
+ struct ib_pd *pd;
+ atomic_t usecnt;
};
struct ib_mw {
struct ib_device *device;
+ struct ib_pd *pd;
+ atomic_t usecnt;
};
struct ib_fmr {
struct ib_device *device;
+ struct ib_pd *pd;
+ atomic_t usecnt;
};
enum ib_device_cap_flags {
@@ -212,6 +234,7 @@
struct ib_port {
enum ib_port_state state;
enum ib_mtu max_mtu;
+ enum ib_mtu active_mtu;
int port_cap_flags;
int gid_tbl_len;
u32 max_msg_sz;
@@ -374,7 +397,6 @@
};
struct ib_srq_attr {
- void *srq_context;
int max_wr;
int max_sge;
int srq_limit;
@@ -394,7 +416,6 @@
};
struct ib_mr_attr {
- struct ib_pd *pd;
u64 device_virt_addr;
u64 size;
int mr_access_flags;
@@ -462,7 +483,7 @@
struct ib_ah *ah;
u32 remote_qpn;
u32 remote_qkey;
- u16 pkey_index;
+ u16 pkey_index; /* valid for GSI only */
} ud;
} wr;
};
@@ -534,184 +555,338 @@
IB_CQ_NEXT_COMP
};
-int ib_query_hca_cap(struct ib_device *device,
- struct ib_device_cap *device_cap);
-
-int ib_query_hca_port_prop(struct ib_device *device,
- u8 port_num,
- struct ib_port *port);
-
-int ib_query_hca_gid_tbl(struct ib_device *device,
- u8 port_num,
- int tbl_len_in,
- int *tbl_len_out,
- union ib_gid *gid_tbl);
-
-int ib_query_hca_pkey_tbl(struct ib_device *device,
- u8 port_num,
- int tbl_len_in,
- int *tbl_len_out,
- u16 *pkey_tbl);
-
-int ib_modify_hca_attr(struct ib_device *device,
- u8 port_num,
- int device_attr_flags);
-
-struct ib_pd *ib_alloc_pd(struct ib_device *device);
-
-int ib_dealloc_pd(struct ib_pd *pd);
-
-struct ib_ah *ib_create_ah(struct ib_pd *pd,
- struct ib_ah_attr *ah_attr);
-
-int ib_modify_ah(struct ib_ah *ah,
- struct ib_ah_attr *ah_attr);
-
-int ib_query_ah(struct ib_ah *ah,
- struct ib_ah_attr *ah_attr);
-
-int ib_destroy_ah(struct ib_ah *ah);
-
-struct ib_qp *ib_create_qp(struct ib_pd *pd,
- struct ib_qp_init_attr *qp_init_attr,
- struct ib_qp_cap *qp_cap);
-
-int ib_modify_qp(struct ib_qp *qp,
- struct ib_qp_attr *qp_attr,
- int qp_attr_mask,
- struct ib_qp_cap *qp_cap );
-
-int ib_query_qp(struct ib_qp *qp,
- struct ib_qp_attr *qp_attr,
- int qp_attr_mask,
- struct ib_qp_init_attr *qp_init_attr);
-
-int ib_destroy_qp(struct ib_qp *qp);
-
-struct ib_qp *ib_get_special_qp(struct ib_pd *pd,
- u8 port_num,
- enum ib_qp_type qp_type,
- struct ib_qp_init_attr *qp_init_attr,
- struct ib_qp_cap *qp_cap);
-
-struct ib_srq *ib_create_srq(struct ib_pd *pd,
- struct ib_srq_attr *srq_attr);
-
-int ib_query_srq(struct ib_srq *srq,
- struct ib_pd **pd,
- struct ib_srq_attr *srq_attr);
-
-int ib_modify_srq(struct ib_srq *srq,
- struct ib_pd *pd,
- struct ib_srq_attr *srq_attr,
- int srq_attr_mask);
-
-int ib_destroy_srq(struct ib_srq *srq);
-
-int ib_post_srq(struct ib_srq *srq,
- struct ib_recv_wr *recv_wr,
- struct ib_recv_wr **bad_recv_wr);
-
-struct ib_cq *ib_create_cq(struct ib_device *device,
- ib_comp_handler comp_handler,
- void *cq_context,
- int *cqe);
-
-int ib_query_cq(struct ib_cq *cq,
- void *cq_context,
- int *cqe);
-
-int ib_resize_cq(struct ib_cq *cq,
- int *cqe);
-
-int ib_destroy_cq(struct ib_cq *cq);
+static inline int ib_query_device(struct ib_device *device,
+ struct ib_device_cap *device_cap)
+{
+ return device->query_device(device, device_cap);
+}
+
+static inline int ib_query_port(struct ib_device *device,
+ u8 port_num,
+ struct ib_port *port)
+{
+ return device->query_port(device, port_num, port);
+}
+
+static inline int ib_query_gid(struct ib_device *device,
+ u8 port_num,
+ int index,
+ union ib_gid *gid)
+{
+ return device->query_gid(device, port_num, index, gid);
+}
+
+static inline int ib_query_pkey(struct ib_device *device,
+ u8 port_num,
+ u16 index,
+ u16 *pkey)
+{
+ return device->query_pkey(device, port_num, index, pkey);
+}
+
+static inline int ib_modify_device(struct ib_device *device,
+ u8 port_num,
+ int device_attr_flags)
+{
+ return device->modify_device(device, port_num, device_attr_flags);
+}
+
+static inline struct ib_pd *ib_alloc_pd(struct ib_device *device)
+{
+ return device->alloc_pd(device);
+}
+
+static inline int ib_dealloc_pd(struct ib_pd *pd)
+{
+ return pd->device->dealloc_pd(pd);
+}
+
+static inline struct ib_ah *ib_create_ah(struct ib_pd *pd,
+ struct ib_ah_attr *ah_attr)
+{
+ return pd->device->create_ah(pd, ah_attr);
+}
+
+static inline int ib_modify_ah(struct ib_ah *ah,
+ struct ib_ah_attr *ah_attr)
+{
+ return ah->device->modify_ah(ah, ah_attr);
+}
+
+static inline int ib_query_ah(struct ib_ah *ah,
+ struct ib_ah_attr *ah_attr)
+{
+ return ah->device->query_ah(ah, ah_attr);
+}
+
+static inline int ib_destroy_ah(struct ib_ah *ah)
+{
+ return ah->device->destroy_ah(ah);
+}
+
+static inline struct ib_qp *ib_create_qp(struct ib_pd *pd,
+ struct ib_qp_init_attr *qp_init_attr,
+ struct ib_qp_cap *qp_cap)
+{
+ return pd->device->create_qp(pd, qp_init_attr, qp_cap);
+}
+
+static inline int ib_modify_qp(struct ib_qp *qp,
+ struct ib_qp_attr *qp_attr,
+ int qp_attr_mask,
+ struct ib_qp_cap *qp_cap )
+{
+ return qp->device->modify_qp(qp, qp_attr, qp_attr_mask, qp_cap);
+}
+
+static inline int ib_query_qp(struct ib_qp *qp,
+ struct ib_qp_attr *qp_attr,
+ int qp_attr_mask,
+ struct ib_qp_init_attr *qp_init_attr)
+{
+ return qp->device->query_qp(qp, qp_attr, qp_attr_mask, qp_init_attr);
+}
+
+static inline int ib_destroy_qp(struct ib_qp *qp)
+{
+ return qp->device->destroy_qp(qp);
+}
+
+static inline struct ib_qp *ib_get_special_qp(struct ib_pd *pd,
+ u8 port_num,
+ enum ib_qp_type qp_type,
+ struct ib_qp_init_attr *qp_init_attr,
+ struct ib_qp_cap *qp_cap)
+{
+ return pd->device->get_special_qp(pd, port_num, qp_type,
+ qp_init_attr, qp_cap);
+}
+
+static inline struct ib_srq *ib_create_srq(struct ib_pd *pd,
+ void *srq_context;
+ struct ib_srq_attr *srq_attr)
+{
+ return pd->device->create_srq(pd, srq_attr);
+}
+
+static inline int ib_query_srq(struct ib_srq *srq,
+ struct ib_srq_attr *srq_attr)
+{
+ return srq->device->query_srq(srq, srq_attr);
+}
+
+static inline int ib_modify_srq(struct ib_srq *srq,
+ struct ib_pd *pd,
+ struct ib_srq_attr *srq_attr,
+ int srq_attr_mask)
+{
+ return srq->device->modify_srq(srq, pd, srq_attr, srq_attr_mask);
+}
+
+static inline int ib_destroy_srq(struct ib_srq *srq)
+{
+ return srq->device->destroy_srq(srq);
+}
+
+static inline int ib_post_srq(struct ib_srq *srq,
+ struct ib_recv_wr *recv_wr,
+ struct ib_recv_wr **bad_recv_wr)
+{
+ return srq->device->post_srq(srq, recv_wr, bad_recv_wr);
+}
+
+static inline struct ib_cq *ib_create_cq(struct ib_device *device,
+ ib_comp_handler comp_handler,
+ void *cq_context,
+ int *cqe)
+{
+ return device->create_cq(device, comp_handler, cq_context, cqe);
+}
+
+static inline int ib_resize_cq(struct ib_cq *cq,
+ int *cqe)
+{
+ return cq->device->resize_cq(cq, cqe);
+}
+
+static inline int ib_destroy_cq(struct ib_cq *cq)
+{
+ return cq->device->destroy_cq(cq);
+}
/* in functions below iova_start is in/out parameter */
-struct ib_mr *ib_reg_phys_mr(struct ib_pd *pd,
- struct ib_phys_buf *phys_buf_array,
- int num_phys_buf,
- int mr_access_flags,
- u64 *iova_start,
+static inline struct ib_mr *ib_reg_phys_mr(struct ib_pd *pd,
+ struct ib_phys_buf *phys_buf_array,
+ int num_phys_buf,
+ int mr_access_flags,
+ u64 *iova_start,
+ u32 *lkey,
+ u32 *rkey)
+{
+ return pd->device->reg_phys_mr(pd, phys_buf_array, num_phys_buf,
+ mr_access_flags, iova_start, lkey, rkey);
+}
+
+static inline int ib_query_mr(struct ib_mr *mr,
+ struct ib_mr_attr *mr_attr)
+{
+ return mr->device->query_mr(mr, mr_attr);
+}
+
+static inline int ib_dereg_mr(struct ib_mr *mr)
+{
+ return mr->device->dereg_mr(mr);
+}
+
+static inline int ib_rereg_phys_mr(struct ib_mr *mr,
+ int mr_rereg_mask,
+ struct ib_pd *pd,
+ struct ib_phys_buf *phys_buf_array,
+ int num_phys_buf,
+ int mr_access_flags,
+ u64 *iova_start,
+ u32 *lkey,
+ u32 *rkey)
+{
+ return mr->device->rereg_phys_mr(mr, mr_rereg_mask, pd, phys_buf_array,
+ num_phys_buf, mr_access_flags,
+ iova_start, lkey, rkey);
+}
+
+static inline struct ib_mw *ib_alloc_mw(struct ib_pd *pd,
+ u32 *rkey)
+{
+ return pd->device->allow_mw(pd, rkey);
+}
+
+static inline int ib_query_mw(struct ib_mw *mw,
+ u32 *rkey,
+ struct ib_pd **pd)
+{
+ return mw->device->query_mw(mw, rkey, pd);
+}
+
+static inline int ib_bind_mw(struct ib_qp *qp,
+ struct ib_mw *mw,
+ struct ib_mw_bind *mw_bind,
+ u32 *rkey)
+{
+ return mw->device->bind_mw(qp, mw, mw_bind, rkey);
+}
+
+static inline int ib_dealloc_mw(struct ib_mw *mw)
+{
+ return mw->device->dealloc_mw(mw);
+}
+
+static inline struct ib_fmr *ib_alloc_fmr(struct ib_pd *pd,
+ int mr_access_flags,
+ struct ib_fmr_attr *fmr_attr)
+{
+ return pd->device->alloc_fmr(pd, mr_access_flags, fmr_attr);
+}
+
+static inline int ib_map_fmr(struct ib_fmr *fmr,
+ void *addr,
+ u64 size,
u32 *lkey,
- u32 *rkey);
-
-int ib_query_mr(struct ib_mr *mr,
- struct ib_mr_attr *mr_attr);
-
-int ib_dereg_mr(struct ib_mr *mr);
-
-int ib_rereg_phys_mr(struct ib_mr *mr,
- int mr_rereg_mask,
- struct ib_pd *pd,
- struct ib_phys_buf *phys_buf_array,
- int num_phys_buf,
- int mr_access_flags,
- u64 *iova_start,
- u32 *lkey,
- u32 *rkey);
-
-struct ib_mw *ib_alloc_mw(struct ib_pd *pd,
- u32 *rkey);
-
-int ib_query_mw(struct ib_mw *mw,
- u32 *rkey,
- struct ib_pd **pd);
-
-int ib_bind_mw(struct ib_qp *qp,
- struct ib_mw *mw,
- struct ib_mw_bind *mw_bind,
- u32 *rkey);
-
-int ib_dealloc_mw(struct ib_mw *mw);
-
-struct ib_fmr *ib_alloc_fmr(struct ib_pd *pd,
- int mr_access_flags,
- struct ib_fmr_attr *fmr_attr);
-
-int ib_map_fmr(struct ib_fmr *fmr,
- void *addr,
- u64 size,
- u32 *lkey,
- u32 *rkey);
-
-int ib_map_phys_fmr(struct ib_fmr *fmr,
- struct ib_phys_buf *phys_buf_array,
- int num_phys_buf,
- u32 *lkey,
- u32 *rkey);
-
-int ib_unmap_fmr(struct ib_fmr **fmr_array,
- int fmr_cnt);
-
-int ib_free_fmr(struct ib_fmr *fmr);
-
-int ib_attach_mcast(struct ib_qp *qp,
- union ib_gid *gid,
- u16 lid);
-
-int ib_detach_mcast(struct ib_qp *qp,
- union ib_gid *gid,
- u16 lid);
-
-int ib_post_send(struct ib_qp *qp,
- struct ib_send_wr *send_wr,
- struct ib_send_wr **bad_send_wr);
-
-int ib_post_recv(struct ib_qp *qp,
- struct ib_recv_wr *recv_wr,
- struct ib_recv_wr **bad_recv_wr);
-
-int ib_poll_cq(struct ib_cq *cq,
- int num_entries,
- struct ib_wc *wc_array);
-
-int ib_peek_cq(struct ib_cq *cq,
- int wc_cnt);
-
-int ib_req_notify_cq(struct ib_cq *cq,
- enum ib_cq_notify cq_notify);
-
-int ib_req_n_notify_cq(struct ib_cq *cq,
- int wc_cnt);
+ u32 *rkey)
+{
+ return fmr->device->map_fmr(fmr, addr, size, lkey, rkey);
+}
+
+static inline int ib_map_phys_fmr(struct ib_fmr *fmr,
+ struct ib_phys_buf *phys_buf_array,
+ int num_phys_buf,
+ u32 *lkey,
+ u32 *rkey)
+{
+ return fmr->device->map_phys_fmr(fmr, phys_buf_array, num_phys_buf,
+ lkey, rkey);
+}
+
+/* Need to discuss this... */
+static inline int ib_unmap_fmr(struct ib_fmr **fmr_array,
+ int fmr_cnt)
+{
+ /* Requires all FMRs to come from same device. */
+ return fmr_array[0]->device->unmap_fmr(fmr_array, fmr_cnt);
+}
+
+static inline int ib_free_fmr(struct ib_fmr *fmr)
+{
+ return fmr->device->free_fmr(fmr);
+}
+
+static inline int ib_attach_mcast(struct ib_qp *qp,
+ union ib_gid *gid,
+ u16 lid)
+{
+ return qp->device->attach_mcast(qp, gid, lid);
+}
+
+static inline int ib_detach_mcast(struct ib_qp *qp,
+ union ib_gid *gid,
+ u16 lid)
+{
+ return qp->device->detach_mcast(qp, gid, lid);
+}
+
+static inline int ib_post_send(struct ib_qp *qp,
+ struct ib_send_wr *send_wr,
+ struct ib_send_wr **bad_send_wr)
+{
+ return qp->device->post_send(qp, send_wr, bad_send_wr);
+}
+
+static inline int ib_post_recv(struct ib_qp *qp,
+ struct ib_recv_wr *recv_wr,
+ struct ib_recv_wr **bad_recv_wr)
+{
+ return qp->device->post_recv(qp, recv_wr, bad_recv_wr);
+}
+
+/**
+ * ib_poll_cq - poll a CQ for completion(s)
+ * @cq:the CQ being polled
+ * @num_entries:maximum number of completions to return
+ * @wc:array of at least @num_entries &struct ib_wc where completions
+ * will be returned
+ *
+ * Poll a CQ for (possibly multiple) completions. If the return value
+ * is < 0, an error occurred. If the return value is >= 0, it is the
+ * number of completions returned. If the return value is
+ * non-negative and < num_entries, then the CQ was emptied.
+ */
+static inline int ib_poll_cq(struct ib_cq *cq,
+ int num_entries,
+ struct ib_wc *wc_array)
+{
+ return cq->device->poll_cq(cq, num_entries, wc);
+}
+
+static inline int ib_peek_cq(struct ib_cq *cq,
+ int wc_cnt)
+{
+ return cq->device->peek_cq(cq, wc_cnt);
+}
+
+/**
+ * ib_req_notify_cq - request completion notification
+ * @cq:the CQ to generate an event for
+ * @cq_notify:%IB_CQ_SOLICITED for next solicited event,
+ * %IB_CQ_NEXT_COMP for any completion.
+ */
+static inline int ib_req_notify_cq(struct ib_cq *cq,
+ enum ib_cq_notify cq_notify)
+{
+ return cq->device->req_notify_cq(cq, cq_notify);
+}
+
+static inline int ib_req_n_notify_cq(struct ib_cq *cq,
+ int wc_cnt)
+{
+ return cq->device->req_n_notify_cq(cq, wc_cnt);
+}
#endif /* IB_VERBS_H */
More information about the general
mailing list