From 9b2d606dc14b1d8afe4c5249627e64c2fee2bfd7 Mon Sep 17 00:00:00 2001 From: ftillier Date: Fri, 10 Mar 2006 17:53:10 +0000 Subject: [PATCH] [IBAL, HCA] Provide HCA driver with UM CA handle for resource 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@237 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- trunk/core/al/al_cq.c | 2 +- trunk/core/al/al_pd.c | 2 +- trunk/core/al/al_verbs.h | 65 +++++++++++++++++++++++----- trunk/core/al/kernel/al_ci_ca.c | 6 +-- trunk/hw/mt23108/kernel/hca_data.h | 2 + trunk/hw/mt23108/kernel/hca_driver.c | 5 ++- trunk/hw/mt23108/kernel/hca_verbs.c | 33 ++++++++++++-- 7 files changed, 94 insertions(+), 21 deletions(-) diff --git a/trunk/core/al/al_cq.c b/trunk/core/al/al_cq.c index 7c527983..6505266b 100644 --- a/trunk/core/al/al_cq.c +++ b/trunk/core/al/al_cq.c @@ -134,7 +134,7 @@ create_cq( * the h_cq handle may be destroryed by the client's asynchronous event * callback routine before call to verbs returns. */ - status = verbs_create_cq( h_ca, p_cq_create, h_cq ); + status = verbs_create_cq( h_ca, p_cq_create, h_cq, p_umv_buf ); if( status != IB_SUCCESS ) { h_cq->obj.pfn_destroy( &h_cq->obj, NULL ); diff --git a/trunk/core/al/al_pd.c b/trunk/core/al/al_pd.c index 08508712..bce9adb1 100644 --- a/trunk/core/al/al_pd.c +++ b/trunk/core/al/al_pd.c @@ -125,7 +125,7 @@ alloc_pd( case IB_PDT_SQP: case IB_PDT_UD: /* Allocate the protection domain. */ - status = verbs_allocate_pd(h_ca, h_pd); + status = verbs_allocate_pd( h_ca, h_pd, p_umv_buf ); break; default: diff --git a/trunk/core/al/al_verbs.h b/trunk/core/al/al_verbs.h index f5ce6c0d..44690c7b 100644 --- a/trunk/core/al/al_verbs.h +++ b/trunk/core/al/al_verbs.h @@ -34,6 +34,7 @@ #define __AL_VERBS_H__ #include "al_ca.h" +#include "al_cq.h" #include "al_pd.h" #include "al_qp.h" @@ -70,9 +71,17 @@ h_ca->obj.p_ci_ca->verbs.modify_ca( h_ca->obj.p_ci_ca->h_ci_ca,\ port_num, ca_mod, p_port_attr_mod ) -#define verbs_create_cq(h_ca, p_cq_create, h_cq) \ - h_ca->obj.p_ci_ca->verbs.create_cq( h_ca->obj.p_ci_ca->h_ci_ca,\ - h_cq, &p_cq_create->size, &h_cq->h_ci_cq, p_umv_buf ) +static inline ib_api_status_t +verbs_create_cq( + IN const ib_ca_handle_t h_ca, + IN OUT ib_cq_create_t* const p_cq_create, + IN ib_cq_handle_t h_cq, + IN OUT ci_umv_buf_t* const p_umv_buf ) +{ + return h_ca->obj.p_ci_ca->verbs.create_cq( + (p_umv_buf) ? h_ca->h_um_ca : h_ca->obj.p_ci_ca->h_ci_ca, + h_cq, &p_cq_create->size, &h_cq->h_ci_cq, p_umv_buf ); +} #define verbs_check_cq(h_cq) ((h_cq)->h_ci_cq) #define verbs_destroy_cq(h_cq) \ @@ -168,9 +177,16 @@ h_qp->obj.p_ci_ca->verbs.bind_mw( h_mw->h_ci_mw,\ h_qp->h_ci_qp, p_mw_bind, p_rkey ) -#define verbs_allocate_pd(h_ca, h_pd) \ - h_ca->obj.p_ci_ca->verbs.allocate_pd(\ - h_ca->obj.p_ci_ca->h_ci_ca, h_pd->type, &h_pd->h_ci_pd, p_umv_buf ) +static inline ib_api_status_t +verbs_allocate_pd( + IN const ib_ca_handle_t h_ca, + IN ib_pd_handle_t h_pd, + IN OUT ci_umv_buf_t* const p_umv_buf ) +{ + return h_ca->obj.p_ci_ca->verbs.allocate_pd( + (p_umv_buf) ? h_ca->h_um_ca : h_ca->obj.p_ci_ca->h_ci_ca, + h_pd->type, &h_pd->h_ci_pd, p_umv_buf ); +} /* * Reference the hardware PD. @@ -304,6 +320,18 @@ verbs_create_qp( h_mcast->obj.p_ci_ca->verbs.detach_mcast( \ h_mcast->h_ci_mcast ) +static inline ib_api_status_t +verbs_ci_call( + IN ib_ca_handle_t h_ca, + IN const void* __ptr64 * const handle_array OPTIONAL, + IN uint32_t num_handles, + IN ib_ci_op_t* const p_ci_op, + IN ci_umv_buf_t* const p_umv_buf OPTIONAL ) +{ + return h_ca->obj.p_ci_ca->verbs.vendor_call( + p_umv_buf ? h_ca->h_um_ca : h_ca->obj.p_ci_ca->h_ci_ca, + handle_array, num_handles, p_ci_op, p_umv_buf ); +} #else @@ -338,9 +366,16 @@ verbs_create_qp( #define verbs_modify_ca(h_ca, port_num, ca_mod, p_port_attr_mod) \ ual_modify_ca(h_ca, port_num, ca_mod, p_port_attr_mod) -#define verbs_create_cq(h_ca, p_cq_create, h_cq) \ - ual_create_cq(h_ca->obj.p_ci_ca, p_cq_create, h_cq); \ - UNUSED_PARAM( p_umv_buf ) +static inline ib_api_status_t +verbs_create_cq( + IN const ib_ca_handle_t h_ca, + IN OUT ib_cq_create_t* const p_cq_create, + IN ib_cq_handle_t h_cq, + IN OUT ci_umv_buf_t* const p_umv_buf ) +{ + UNUSED_PARAM( p_umv_buf ); + return ual_create_cq( h_ca->obj.p_ci_ca, p_cq_create, h_cq ); +} #define verbs_check_cq(h_cq) ((h_cq)->h_ci_cq || (h_cq)->obj.hdl) @@ -432,9 +467,15 @@ verbs_create_qp( #define verbs_bind_mw(h_mw, h_qp, p_mw_bind, p_rkey) \ ual_bind_mw(h_mw, h_qp, p_mw_bind, p_rkey) -#define verbs_allocate_pd(h_ca, h_pd) \ - ual_allocate_pd(h_ca, h_pd->type, h_pd); \ - UNUSED_PARAM( p_umv_buf ) +static inline ib_api_status_t +verbs_allocate_pd( + IN const ib_ca_handle_t h_ca, + IN ib_pd_handle_t h_pd, + IN OUT ci_umv_buf_t* const p_umv_buf ) +{ + UNUSED_PARAM( p_umv_buf ); + return ual_allocate_pd( h_ca, h_pd->type, h_pd ); +} /* * Get an alias to the kernel's hardware PD. diff --git a/trunk/core/al/kernel/al_ci_ca.c b/trunk/core/al/kernel/al_ci_ca.c index dcac4afa..8a078d87 100644 --- a/trunk/core/al/kernel/al_ci_ca.c +++ b/trunk/core/al/kernel/al_ci_ca.c @@ -31,6 +31,7 @@ */ #include "al_ci_ca.h" +#include "al_verbs.h" #include "al_cq.h" #include "al_debug.h" #include "al_mad_pool.h" @@ -486,9 +487,8 @@ ci_call( if( h_ca->obj.p_ci_ca->verbs.vendor_call ) { - status = h_ca->obj.p_ci_ca->verbs.vendor_call( - h_ca->obj.p_ci_ca->h_ci_ca, p_handle_array, num_handles, - p_ci_op, p_umv_buf ); + status = verbs_ci_call( + h_ca, p_handle_array, num_handles, p_ci_op, p_umv_buf ); } else { diff --git a/trunk/hw/mt23108/kernel/hca_data.h b/trunk/hw/mt23108/kernel/hca_data.h index 15193593..89b2093c 100644 --- a/trunk/hw/mt23108/kernel/hca_data.h +++ b/trunk/hw/mt23108/kernel/hca_data.h @@ -210,6 +210,8 @@ typedef struct _ib_um_ca MDL *p_mdl; void *p_mapped_addr; HH_hca_hndl_t hh_hndl; + mlnx_hob_t *hob_p; + /* The next two fields must be grouped together as the are mapped to UM. */ HH_hca_dev_t dev_info; uint8_t ul_hca_res[1]; // Beginning of UL resource buffer. diff --git a/trunk/hw/mt23108/kernel/hca_driver.c b/trunk/hw/mt23108/kernel/hca_driver.c index 39fca4b8..519251cc 100644 --- a/trunk/hw/mt23108/kernel/hca_driver.c +++ b/trunk/hw/mt23108/kernel/hca_driver.c @@ -1310,7 +1310,10 @@ fw_access_ctrl( UNREFERENCED_PARAMETER(p_umv_buf); status = STATUS_SUCCESS; - p_hob = (mlnx_hob_t *)(const void *)p_context; + if( p_umv_buf ) + p_hob = ((mlnx_um_ca_t* __ptr64)p_context)->hob_p; + else + p_hob = (mlnx_hob_t *)(const void *)p_context; p_dev_obj = (DEVICE_OBJECT *)(const void *)p_hob->p_dev_obj; p_ci = p_ci_op; diff --git a/trunk/hw/mt23108/kernel/hca_verbs.c b/trunk/hw/mt23108/kernel/hca_verbs.c index 63625b22..ca9ce406 100644 --- a/trunk/hw/mt23108/kernel/hca_verbs.c +++ b/trunk/hw/mt23108/kernel/hca_verbs.c @@ -520,8 +520,20 @@ mlnx_um_open( if( !p_umv_buf->command ) { + p_um_ca = (mlnx_um_ca_t*)cl_zalloc( sizeof(mlnx_um_ca_t) ); + if( !p_um_ca ) + { + p_umv_buf->status = IB_INSUFFICIENT_MEMORY; + goto mlnx_um_open_err1; + } + /* Copy the dev info. */ + p_um_ca->dev_info = *hca_ul_info; + p_um_ca->hob_p = hob_p; + *ph_um_ca = (ib_ca_handle_t)p_um_ca; p_umv_buf->status = IB_SUCCESS; - goto mlnx_um_open_err1; + p_umv_buf->output_size = 0; + HCA_EXIT( MLNX_DBG_TRACE ); + return IB_SUCCESS; } /* @@ -582,6 +594,7 @@ mlnx_um_open( { /* Copy the dev info. */ p_um_ca->dev_info = *hca_ul_info; + p_um_ca->hob_p = hob_p; *ph_um_ca = (ib_ca_handle_t)p_um_ca; (*(void** __ptr64)p_umv_buf->p_inout_buf) = p_um_ca->p_mapped_addr; p_umv_buf->status = IB_SUCCESS; @@ -622,11 +635,15 @@ mlnx_um_close( if( !p_um_ca ) return; + if( !p_um_ca->p_mapped_addr ) + goto done; + THH_hob_free_ul_res( hh_hndl, p_um_ca->ul_hca_res ); mlnx_um_close_cleanup: MmUnmapLockedPages( p_um_ca->p_mapped_addr, p_um_ca->p_mdl ); IoFreeMdl( p_um_ca->p_mdl ); +done: cl_free( p_um_ca ); HCA_EXIT( MLNX_DBG_TRACE ); @@ -644,7 +661,7 @@ mlnx_allocate_pd ( OUT ib_pd_handle_t *ph_pd, IN OUT ci_umv_buf_t *p_umv_buf ) { - mlnx_hob_t *hob_p = (mlnx_hob_t *)h_ca; + mlnx_hob_t *hob_p; mlnx_hobul_t *hobul_p; HH_hca_dev_t *hca_ul_info; HHUL_pd_hndl_t hhul_pd_hndl = 0; @@ -655,6 +672,11 @@ mlnx_allocate_pd ( CL_ENTER(MLNX_DBG_TRACE, g_mlnx_dbg_lvl); + if( p_umv_buf ) + hob_p = ((mlnx_um_ca_t *)h_ca)->hob_p; + else + hob_p = (mlnx_hob_t *)h_ca; + hobul_p = mlnx_hobs_get_hobul(hob_p); if (NULL == hobul_p) { status = IB_INVALID_CA_HANDLE; @@ -1889,7 +1911,7 @@ mlnx_create_cq ( { ib_api_status_t status; - mlnx_hob_t *hob_p = (mlnx_hob_t *)h_ca; + mlnx_hob_t *hob_p; u_int32_t cq_idx; u_int32_t cq_num; u_int32_t cq_size = 0; @@ -1901,6 +1923,11 @@ mlnx_create_cq ( CL_ENTER(MLNX_DBG_TRACE, g_mlnx_dbg_lvl); + if( p_umv_buf ) + hob_p = ((mlnx_um_ca_t *)h_ca)->hob_p; + else + hob_p = (mlnx_hob_t *)h_ca; + hobul_p = mlnx_hobs_get_hobul(hob_p); if (NULL == hobul_p) { status = IB_INVALID_CA_HANDLE; -- 2.41.0