RDMA: Globally allocate and release QP memory
[linux-2.6-microblaze.git] / include / rdma / ib_verbs.h
index 371df1c..6737582 100644 (file)
@@ -2268,8 +2268,13 @@ struct iw_cm_conn_param;
                         !__same_type(((struct drv_struct *)NULL)->member,     \
                                      struct ib_struct)))
 
-#define rdma_zalloc_drv_obj_gfp(ib_dev, ib_type, gfp)                         \
-       ((struct ib_type *)kzalloc(ib_dev->ops.size_##ib_type, gfp))
+#define rdma_zalloc_drv_obj_gfp(ib_dev, ib_type, gfp)                          \
+       ((struct ib_type *)rdma_zalloc_obj(ib_dev, ib_dev->ops.size_##ib_type, \
+                                          gfp, false))
+
+#define rdma_zalloc_drv_obj_numa(ib_dev, ib_type)                              \
+       ((struct ib_type *)rdma_zalloc_obj(ib_dev, ib_dev->ops.size_##ib_type, \
+                                          GFP_KERNEL, true))
 
 #define rdma_zalloc_drv_obj(ib_dev, ib_type)                                   \
        rdma_zalloc_drv_obj_gfp(ib_dev, ib_type, GFP_KERNEL)
@@ -2435,9 +2440,8 @@ struct ib_device_ops {
                          struct ib_udata *udata);
        int (*query_srq)(struct ib_srq *srq, struct ib_srq_attr *srq_attr);
        int (*destroy_srq)(struct ib_srq *srq, struct ib_udata *udata);
-       struct ib_qp *(*create_qp)(struct ib_pd *pd,
-                                  struct ib_qp_init_attr *qp_init_attr,
-                                  struct ib_udata *udata);
+       int (*create_qp)(struct ib_qp *qp, struct ib_qp_init_attr *qp_init_attr,
+                        struct ib_udata *udata);
        int (*modify_qp)(struct ib_qp *qp, struct ib_qp_attr *qp_attr,
                         int qp_attr_mask, struct ib_udata *udata);
        int (*query_qp)(struct ib_qp *qp, struct ib_qp_attr *qp_attr,
@@ -2635,11 +2639,18 @@ struct ib_device_ops {
        int (*query_ucontext)(struct ib_ucontext *context,
                              struct uverbs_attr_bundle *attrs);
 
+       /*
+        * Provide NUMA node. This API exists for rdmavt/hfi1 only.
+        * Everyone else relies on Linux memory management model.
+        */
+       int (*get_numa_node)(struct ib_device *dev);
+
        DECLARE_RDMA_OBJ_SIZE(ib_ah);
        DECLARE_RDMA_OBJ_SIZE(ib_counters);
        DECLARE_RDMA_OBJ_SIZE(ib_cq);
        DECLARE_RDMA_OBJ_SIZE(ib_mw);
        DECLARE_RDMA_OBJ_SIZE(ib_pd);
+       DECLARE_RDMA_OBJ_SIZE(ib_qp);
        DECLARE_RDMA_OBJ_SIZE(ib_rwq_ind_table);
        DECLARE_RDMA_OBJ_SIZE(ib_srq);
        DECLARE_RDMA_OBJ_SIZE(ib_ucontext);
@@ -2746,6 +2757,15 @@ struct ib_device {
        u32 lag_flags;
 };
 
+static inline void *rdma_zalloc_obj(struct ib_device *dev, size_t size,
+                                   gfp_t gfp, bool is_numa_aware)
+{
+       if (is_numa_aware && dev->ops.get_numa_node)
+               return kzalloc_node(size, gfp, dev->ops.get_numa_node(dev));
+
+       return kzalloc(size, gfp);
+}
+
 struct ib_client_nl_info;
 struct ib_client {
        const char *name;