[openib-general] [PATCH] optional functions, ib_mad update
Sean Hefty
mshefty at ichips.intel.com
Wed Sep 1 14:56:42 PDT 2004
On Wed, 1 Sep 2004 15:13:37 -0700
Grant Grundler <iod00d at hp.com> wrote:
> Why not leave this as an inline function?
Here's a patch that makes optional function inline.
- Sean
Index: ib_verbs.h
===================================================================
--- ib_verbs.h (revision 716)
+++ ib_verbs.h (working copy)
@@ -771,14 +771,26 @@
return device->query_pkey(device, port_num, index, pkey);
}
-int ib_modify_device(struct ib_device *device,
- int device_modify_mask,
- struct ib_device_modify *device_modify);
-
-int ib_modify_port(struct ib_device *device,
- u8 port_num,
- int port_modify_mask,
- struct ib_port_modify *port_modify);
+static inline int ib_modify_device(struct ib_device *device,
+ int device_modify_mask,
+ struct ib_device_modify *device_modify)
+{
+ return device->modify_device ?
+ device->modify_device(device, device_modify_mask,
+ device_modify) :
+ -ENOSYS;
+}
+
+static inline int ib_modify_port(struct ib_device *device,
+ u8 port_num,
+ int port_modify_mask,
+ struct ib_port_modify *port_modify)
+{
+ return device->modify_port ?
+ device->modify_port(device, port_num, port_modify_mask,
+ port_modify) :
+ -ENOSYS;
+}
struct ib_pd *ib_alloc_pd(struct ib_device *device);
@@ -787,11 +799,21 @@
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);
+static inline int ib_modify_ah(struct ib_ah *ah,
+ struct ib_ah_attr *ah_attr)
+{
+ return ah->device->modify_ah ?
+ ah->device->modify_ah(ah, ah_attr) :
+ -ENOSYS;
+}
-int ib_query_ah(struct ib_ah *ah,
- struct ib_ah_attr *ah_attr);
+static inline int ib_query_ah(struct ib_ah *ah,
+ struct ib_ah_attr *ah_attr)
+{
+ return ah->device->query_ah ?
+ ah->device->query_ah(ah, ah_attr) :
+ -ENOSYS;
+}
int ib_destroy_ah(struct ib_ah *ah);
@@ -807,10 +829,16 @@
return qp->device->modify_qp(qp, qp_attr, qp_attr_mask, 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);
+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->device->query_qp(qp, qp_attr, qp_attr_mask, qp_init_attr) :
+ -ENOSYS;
+
+}
int ib_destroy_qp(struct ib_qp *qp);
@@ -818,13 +846,24 @@
void *srq_context,
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);
+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->device->modify_srq(srq, pd, srq_attr, srq_attr_mask) :
+ -ENOSYS;
+}
+
+static inline int ib_query_srq(struct ib_srq *srq,
+ struct ib_srq_attr *srq_attr)
+{
+ return srq->device->query_srq ?
+ srq->device->query_srq(srq, srq_attr) :
+ -ENOSYS;
+}
-int ib_query_srq(struct ib_srq *srq,
- struct ib_srq_attr *srq_attr);
static inline int ib_post_srq(struct ib_srq *srq,
struct ib_recv_wr *recv_wr,
@@ -840,8 +879,13 @@
void *cq_context,
int cqe);
-int ib_resize_cq(struct ib_cq *cq,
- int cqe);
+static inline int ib_resize_cq(struct ib_cq *cq,
+ int cqe)
+{
+ return cq->device->resize_cq ?
+ cq->device->resize_cq(cq, cqe) :
+ -ENOSYS;
+}
int ib_destroy_cq(struct ib_cq *cq);
@@ -851,8 +895,13 @@
int mr_access_flags,
u64 *iova_start);
-int ib_query_mr(struct ib_mr *mr,
- struct ib_mr_attr *mr_attr);
+static inline int ib_query_mr(struct ib_mr *mr,
+ struct ib_mr_attr *mr_attr)
+{
+ return mr->device->query_mr ?
+ mr->device->query_mr(mr, mr_attr) :
+ -ENOSYS;
+}
int ib_dereg_mr(struct ib_mr *mr);
@@ -895,13 +944,21 @@
int ib_dealloc_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);
+static inline int ib_attach_mcast(struct ib_qp *qp,
+ union ib_gid *gid,
+ u16 lid)
+{
+ return qp->device->attach_mcast ?
+ qp->device->attach_mcast(qp, gid, lid) :
+ -ENOSYS;
+}
+
+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,
Index: ib_verbs.c
===================================================================
--- ib_verbs.c (revision 714)
+++ ib_verbs.c (working copy)
@@ -26,33 +26,6 @@
#include <linux/err.h>
#include <ib_verbs.h>
-/* Device */
-
-int ib_modify_device(struct ib_device *device,
- int device_modify_mask,
- struct ib_device_modify *device_modify)
-{
- if (!device->modify_device)
- return -ENOSYS;
-
- return device->modify_device(device, device_modify_mask,
- device_modify);
-}
-EXPORT_SYMBOL(ib_modify_device);
-
-int ib_modify_port(struct ib_device *device,
- u8 port_num,
- int port_modify_mask,
- struct ib_port_modify *port_modify)
-{
- if (!device->modify_port)
- return -ENOSYS;
-
- return device->modify_port(device, port_num, port_modify_mask,
- port_modify);
-}
-EXPORT_SYMBOL(ib_modify_port);
-
/* Protection domain */
struct ib_pd *ib_alloc_pd(struct ib_device *device)
@@ -98,26 +71,6 @@
}
EXPORT_SYMBOL(ib_create_ah);
-int ib_modify_ah(struct ib_ah *ah,
- struct ib_ah_attr *ah_attr)
-{
- if (!ah->device->modify_ah)
- return -ENOSYS;
-
- return ah->device->modify_ah(ah, ah_attr);
-}
-EXPORT_SYMBOL(ib_modify_ah);
-
-int ib_query_ah(struct ib_ah *ah,
- struct ib_ah_attr *ah_attr)
-{
- if (!ah->device->query_ah)
- return -ENOSYS;
-
- return ah->device->query_ah(ah, ah_attr);
-}
-EXPORT_SYMBOL(ib_query_ah);
-
int ib_destroy_ah(struct ib_ah *ah)
{
struct ib_pd *pd;
@@ -162,18 +115,6 @@
}
EXPORT_SYMBOL(ib_create_qp);
-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)
-{
- if (!qp->device->query_qp)
- return -ENOSYS;
-
- return qp->device->query_qp(qp, qp_attr, qp_attr_mask, qp_init_attr);
-}
-EXPORT_SYMBOL(ib_query_qp);
-
int ib_destroy_qp(struct ib_qp *qp)
{
struct ib_pd *pd;
@@ -224,28 +165,6 @@
}
EXPORT_SYMBOL(ib_create_srq);
-int ib_modify_srq(struct ib_srq *srq,
- struct ib_pd *pd,
- struct ib_srq_attr *srq_attr,
- int srq_attr_mask)
-{
- if (!srq->device->modify_srq)
- return -ENOSYS;
-
- return srq->device->modify_srq(srq, pd, srq_attr, srq_attr_mask);
-}
-EXPORT_SYMBOL(ib_modify_srq);
-
-int ib_query_srq(struct ib_srq *srq,
- struct ib_srq_attr *srq_attr)
-{
- if (!srq->device->query_srq)
- return -ENOSYS;
-
- return srq->device->query_srq(srq, srq_attr);
-}
-EXPORT_SYMBOL(ib_query_srq);
-
int ib_destroy_srq(struct ib_srq *srq)
{
struct ib_pd *pd;
@@ -286,16 +205,6 @@
}
EXPORT_SYMBOL(ib_create_cq);
-int ib_resize_cq(struct ib_cq *cq,
- int cqe)
-{
- if (!cq->device->resize_cq)
- return -ENOSYS;
-
- return cq->device->resize_cq(cq, cqe);
-}
-EXPORT_SYMBOL(ib_resize_cq);
-
int ib_destroy_cq(struct ib_cq *cq)
{
if (atomic_read(&cq->usecnt))
@@ -329,16 +238,6 @@
}
EXPORT_SYMBOL(ib_reg_phys_mr);
-int ib_query_mr(struct ib_mr *mr,
- struct ib_mr_attr *mr_attr)
-{
- if (!mr->device->query_mr)
- return -ENOSYS;
-
- return mr->device->query_mr(mr, mr_attr);
-}
-EXPORT_SYMBOL(ib_query_mr);
-
int ib_dereg_mr(struct ib_mr *mr)
{
struct ib_pd *pd;
@@ -461,22 +360,3 @@
return ret;
}
EXPORT_SYMBOL(ib_dealloc_fmr);
-
-/* Multicast */
-
-int ib_attach_mcast(struct ib_qp *qp,
- union ib_gid *gid,
- u16 lid)
-{
- if (!qp->device->attach_mcast)
- return -ENOSYS;
-
- return qp->device->attach_mcast(qp, gid, lid);
-}
-
-int ib_detach_mcast(struct ib_qp *qp,
- union ib_gid *gid,
- u16 lid)
-{
- return qp->device->detach_mcast(qp, gid, lid);
-}
More information about the general
mailing list