[IBAL, HCA] Provide HCA driver with UM CA handle for resource
authorftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Fri, 10 Mar 2006 17:53:10 +0000 (17:53 +0000)
committerftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Fri, 10 Mar 2006 17:53:10 +0000 (17:53 +0000)
allocation verbs that take a CA handle.

Initially submitted by Leonid Keller (leonid@mellanox.co.il)

git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@237 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

core/al/al_cq.c
core/al/al_pd.c
core/al/al_verbs.h
core/al/kernel/al_ci_ca.c
hw/mt23108/kernel/hca_data.h
hw/mt23108/kernel/hca_driver.c
hw/mt23108/kernel/hca_verbs.c

index 7c52798..6505266 100644 (file)
@@ -134,7 +134,7 @@ create_cq(
         * the h_cq handle may be destroryed by the client's asynchronous event\r
         * callback routine before call to verbs returns.\r
         */\r
-       status = verbs_create_cq( h_ca, p_cq_create, h_cq );\r
+       status = verbs_create_cq( h_ca, p_cq_create, h_cq, p_umv_buf );\r
        if( status != IB_SUCCESS )\r
        {\r
                h_cq->obj.pfn_destroy( &h_cq->obj, NULL );\r
index 0850871..bce9adb 100644 (file)
@@ -125,7 +125,7 @@ alloc_pd(
        case IB_PDT_SQP:\r
        case IB_PDT_UD:\r
                /* Allocate the protection domain. */\r
-               status = verbs_allocate_pd(h_ca, h_pd);\r
+               status = verbs_allocate_pd( h_ca, h_pd, p_umv_buf );\r
                break;\r
 \r
        default:\r
index f5ce6c0..44690c7 100644 (file)
@@ -34,6 +34,7 @@
 #define __AL_VERBS_H__\r
 \r
 #include "al_ca.h"\r
+#include "al_cq.h"\r
 #include "al_pd.h"\r
 #include "al_qp.h"\r
 \r
        h_ca->obj.p_ci_ca->verbs.modify_ca( h_ca->obj.p_ci_ca->h_ci_ca,\\r
                port_num, ca_mod, p_port_attr_mod )\r
 \r
-#define verbs_create_cq(h_ca, p_cq_create, h_cq) \\r
-       h_ca->obj.p_ci_ca->verbs.create_cq( h_ca->obj.p_ci_ca->h_ci_ca,\\r
-       h_cq, &p_cq_create->size, &h_cq->h_ci_cq, p_umv_buf )\r
+static inline ib_api_status_t\r
+verbs_create_cq(\r
+       IN              const   ib_ca_handle_t                          h_ca,\r
+       IN      OUT                     ib_cq_create_t* const           p_cq_create,\r
+       IN                              ib_cq_handle_t                          h_cq,\r
+       IN      OUT                     ci_umv_buf_t* const                     p_umv_buf )\r
+{\r
+       return h_ca->obj.p_ci_ca->verbs.create_cq(\r
+               (p_umv_buf) ? h_ca->h_um_ca : h_ca->obj.p_ci_ca->h_ci_ca,\r
+               h_cq, &p_cq_create->size, &h_cq->h_ci_cq, p_umv_buf );\r
+}\r
 \r
 #define verbs_check_cq(h_cq)   ((h_cq)->h_ci_cq)\r
 #define verbs_destroy_cq(h_cq) \\r
        h_qp->obj.p_ci_ca->verbs.bind_mw( h_mw->h_ci_mw,\\r
                h_qp->h_ci_qp, p_mw_bind, p_rkey )\r
 \r
-#define verbs_allocate_pd(h_ca, h_pd) \\r
-       h_ca->obj.p_ci_ca->verbs.allocate_pd(\\r
-                               h_ca->obj.p_ci_ca->h_ci_ca, h_pd->type, &h_pd->h_ci_pd, p_umv_buf )\r
+static inline ib_api_status_t\r
+verbs_allocate_pd(\r
+       IN              const   ib_ca_handle_t                          h_ca,\r
+       IN                              ib_pd_handle_t                          h_pd,\r
+       IN      OUT                     ci_umv_buf_t* const                     p_umv_buf )\r
+{\r
+       return h_ca->obj.p_ci_ca->verbs.allocate_pd(\r
+               (p_umv_buf) ? h_ca->h_um_ca : h_ca->obj.p_ci_ca->h_ci_ca,\r
+               h_pd->type, &h_pd->h_ci_pd, p_umv_buf );\r
+}\r
 \r
 /*\r
  * Reference the hardware PD.\r
@@ -304,6 +320,18 @@ verbs_create_qp(
                h_mcast->obj.p_ci_ca->verbs.detach_mcast( \\r
                        h_mcast->h_ci_mcast )\r
 \r
+static inline ib_api_status_t\r
+verbs_ci_call(\r
+       IN                              ib_ca_handle_t                          h_ca,\r
+       IN              const   void* __ptr64 *         const   handle_array    OPTIONAL,\r
+       IN                              uint32_t                                        num_handles,\r
+       IN                              ib_ci_op_t*                     const   p_ci_op,\r
+       IN                              ci_umv_buf_t*           const   p_umv_buf OPTIONAL )\r
+{\r
+       return h_ca->obj.p_ci_ca->verbs.vendor_call(\r
+               p_umv_buf ? h_ca->h_um_ca : h_ca->obj.p_ci_ca->h_ci_ca,\r
+               handle_array, num_handles, p_ci_op, p_umv_buf );\r
+}\r
 \r
 \r
 #else\r
@@ -338,9 +366,16 @@ verbs_create_qp(
 #define verbs_modify_ca(h_ca, port_num, ca_mod, p_port_attr_mod) \\r
        ual_modify_ca(h_ca, port_num, ca_mod, p_port_attr_mod)\r
 \r
-#define verbs_create_cq(h_ca, p_cq_create, h_cq) \\r
-       ual_create_cq(h_ca->obj.p_ci_ca, p_cq_create, h_cq); \\r
-       UNUSED_PARAM( p_umv_buf )\r
+static inline ib_api_status_t\r
+verbs_create_cq(\r
+       IN              const   ib_ca_handle_t                          h_ca,\r
+       IN      OUT                     ib_cq_create_t* const           p_cq_create,\r
+       IN                              ib_cq_handle_t                          h_cq,\r
+       IN      OUT                     ci_umv_buf_t* const                     p_umv_buf )\r
+{\r
+       UNUSED_PARAM( p_umv_buf );\r
+       return ual_create_cq( h_ca->obj.p_ci_ca, p_cq_create, h_cq );\r
+}\r
 \r
 \r
 #define verbs_check_cq(h_cq)   ((h_cq)->h_ci_cq || (h_cq)->obj.hdl)\r
@@ -432,9 +467,15 @@ verbs_create_qp(
 #define verbs_bind_mw(h_mw, h_qp, p_mw_bind, p_rkey) \\r
        ual_bind_mw(h_mw, h_qp, p_mw_bind, p_rkey)\r
 \r
-#define verbs_allocate_pd(h_ca, h_pd) \\r
-       ual_allocate_pd(h_ca, h_pd->type, h_pd); \\r
-       UNUSED_PARAM( p_umv_buf )\r
+static inline ib_api_status_t\r
+verbs_allocate_pd(\r
+       IN              const   ib_ca_handle_t                          h_ca,\r
+       IN                              ib_pd_handle_t                          h_pd,\r
+       IN      OUT                     ci_umv_buf_t* const                     p_umv_buf )\r
+{\r
+       UNUSED_PARAM( p_umv_buf );\r
+       return ual_allocate_pd( h_ca, h_pd->type, h_pd );\r
+}\r
 \r
 /*\r
  * Get an alias to the kernel's hardware PD.\r
index dcac4af..8a078d8 100644 (file)
@@ -31,6 +31,7 @@
  */\r
 \r
 #include "al_ci_ca.h"\r
+#include "al_verbs.h"\r
 #include "al_cq.h"\r
 #include "al_debug.h"\r
 #include "al_mad_pool.h"\r
@@ -486,9 +487,8 @@ ci_call(
 \r
        if( h_ca->obj.p_ci_ca->verbs.vendor_call )\r
        {\r
-               status = h_ca->obj.p_ci_ca->verbs.vendor_call(\r
-                       h_ca->obj.p_ci_ca->h_ci_ca, p_handle_array, num_handles,\r
-                       p_ci_op, p_umv_buf );\r
+               status = verbs_ci_call(\r
+                       h_ca, p_handle_array, num_handles, p_ci_op, p_umv_buf );\r
        }\r
        else\r
        {\r
index 1519359..89b2093 100644 (file)
@@ -210,6 +210,8 @@ typedef struct _ib_um_ca
        MDL                                     *p_mdl;\r
        void                            *p_mapped_addr;\r
        HH_hca_hndl_t           hh_hndl;\r
+       mlnx_hob_t                      *hob_p;\r
+       /* The next two fields must be grouped together as the are mapped to UM. */\r
        HH_hca_dev_t            dev_info;\r
        uint8_t                         ul_hca_res[1];  // Beginning of UL resource buffer.\r
 \r
index 39fca4b..519251c 100644 (file)
@@ -1310,7 +1310,10 @@ fw_access_ctrl(
        UNREFERENCED_PARAMETER(p_umv_buf);\r
 \r
        status =  STATUS_SUCCESS;\r
-       p_hob = (mlnx_hob_t *)(const void *)p_context;\r
+       if( p_umv_buf )\r
+               p_hob = ((mlnx_um_ca_t* __ptr64)p_context)->hob_p;\r
+       else\r
+               p_hob = (mlnx_hob_t *)(const void *)p_context;\r
 \r
        p_dev_obj = (DEVICE_OBJECT *)(const void *)p_hob->p_dev_obj;\r
        p_ci =  p_ci_op;\r
index 63625b2..ca9ce40 100644 (file)
@@ -520,8 +520,20 @@ mlnx_um_open(
 \r
        if( !p_umv_buf->command )\r
        {\r
+               p_um_ca = (mlnx_um_ca_t*)cl_zalloc( sizeof(mlnx_um_ca_t) );\r
+               if( !p_um_ca )\r
+               {\r
+                       p_umv_buf->status = IB_INSUFFICIENT_MEMORY;\r
+                       goto mlnx_um_open_err1;\r
+               }\r
+               /* Copy the dev info. */\r
+               p_um_ca->dev_info = *hca_ul_info;\r
+               p_um_ca->hob_p = hob_p;\r
+               *ph_um_ca = (ib_ca_handle_t)p_um_ca;\r
                p_umv_buf->status = IB_SUCCESS;\r
-               goto mlnx_um_open_err1;\r
+               p_umv_buf->output_size = 0;\r
+               HCA_EXIT( MLNX_DBG_TRACE );\r
+               return IB_SUCCESS;\r
        }\r
 \r
        /*\r
@@ -582,6 +594,7 @@ mlnx_um_open(
        {\r
                /* Copy the dev info. */\r
                p_um_ca->dev_info = *hca_ul_info;\r
+               p_um_ca->hob_p = hob_p;\r
                *ph_um_ca = (ib_ca_handle_t)p_um_ca;\r
                (*(void** __ptr64)p_umv_buf->p_inout_buf) = p_um_ca->p_mapped_addr;\r
                p_umv_buf->status = IB_SUCCESS;\r
@@ -622,11 +635,15 @@ mlnx_um_close(
        if( !p_um_ca )\r
                return;\r
 \r
+       if( !p_um_ca->p_mapped_addr )\r
+               goto done;\r
+\r
        THH_hob_free_ul_res( hh_hndl, p_um_ca->ul_hca_res );\r
 \r
 mlnx_um_close_cleanup:\r
        MmUnmapLockedPages( p_um_ca->p_mapped_addr, p_um_ca->p_mdl );\r
        IoFreeMdl( p_um_ca->p_mdl );\r
+done:\r
        cl_free( p_um_ca );\r
 \r
        HCA_EXIT( MLNX_DBG_TRACE );\r
@@ -644,7 +661,7 @@ mlnx_allocate_pd (
                OUT                     ib_pd_handle_t                          *ph_pd,\r
        IN      OUT                     ci_umv_buf_t                            *p_umv_buf )\r
 {\r
-       mlnx_hob_t                              *hob_p = (mlnx_hob_t *)h_ca;\r
+       mlnx_hob_t                              *hob_p;\r
        mlnx_hobul_t                    *hobul_p;\r
        HH_hca_dev_t                    *hca_ul_info;\r
        HHUL_pd_hndl_t                  hhul_pd_hndl = 0;\r
@@ -655,6 +672,11 @@ mlnx_allocate_pd (
 \r
        CL_ENTER(MLNX_DBG_TRACE, g_mlnx_dbg_lvl);\r
 \r
+       if( p_umv_buf )\r
+               hob_p = ((mlnx_um_ca_t *)h_ca)->hob_p;\r
+       else\r
+               hob_p = (mlnx_hob_t *)h_ca;\r
+       \r
        hobul_p = mlnx_hobs_get_hobul(hob_p);\r
        if (NULL == hobul_p) {\r
                status = IB_INVALID_CA_HANDLE;\r
@@ -1889,7 +1911,7 @@ mlnx_create_cq (
 {\r
        ib_api_status_t                 status;\r
 \r
-       mlnx_hob_t                              *hob_p = (mlnx_hob_t *)h_ca;\r
+       mlnx_hob_t                              *hob_p;\r
        u_int32_t                               cq_idx;\r
        u_int32_t                               cq_num;\r
        u_int32_t                               cq_size = 0;\r
@@ -1901,6 +1923,11 @@ mlnx_create_cq (
 \r
        CL_ENTER(MLNX_DBG_TRACE, g_mlnx_dbg_lvl);\r
 \r
+       if( p_umv_buf )\r
+               hob_p = ((mlnx_um_ca_t *)h_ca)->hob_p;\r
+       else\r
+               hob_p = (mlnx_hob_t *)h_ca;\r
+\r
        hobul_p = mlnx_hobs_get_hobul(hob_p);\r
        if (NULL == hobul_p) {\r
                status = IB_INVALID_CA_HANDLE;\r