From: ftillier Date: Thu, 6 Jul 2006 13:23:54 +0000 (+0000) Subject: [IBAL] Remove unused user-mode CM files. X-Git-Url: http://git.etherboot.org/mirror/winof/.git/commitdiff_plain/e4a7afd7ce63e42355b4d383de9314b51e51717c [IBAL] Remove unused user-mode CM files. git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@405 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- diff --git a/core/al/user/ual_cm.c b/core/al/user/ual_cm.c deleted file mode 100644 index 9292ecdc..00000000 --- a/core/al/user/ual_cm.c +++ /dev/null @@ -1,2006 +0,0 @@ -/* - * Copyright (c) 2005 SilverStorm Technologies. All rights reserved. - * Copyright (c) 1996-2003 Intel Corporation. All rights reserved. - * - * This software is available to you under the OpenIB.org BSD license - * below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * $Id$ - */ - -#include -#include "al.h" -#include "al_cm_shared.h" -#include "al_debug.h" - -#if defined(EVENT_TRACING) -#ifdef offsetof -#undef offsetof -#endif -#include "ual_cm.tmh" -#endif - -#include "al_dev.h" -#include "al_qp.h" -#include "ib_common.h" -#include "ual_cm.h" - - - -/* - * Attach the QP and connection object to each other. - */ -static void -__bind_qp_and_conn( - IN const ib_cm_handle_t h_conn, - IN const ib_qp_handle_t h_qp ) -{ - h_conn->h_qp = h_qp; - ((al_conn_qp_t*)h_qp)->p_conn = h_conn; -} - - -static void -__free_listen( - IN struct _al_obj *p_obj ) -{ - destroy_al_obj( p_obj ); - cl_free( p_obj ); -} - - - -static void -__destroying_conn( - IN struct _al_obj *p_obj ) -{ - ib_cm_handle_t h_conn; - - h_conn = (ib_cm_handle_t)p_obj; - - if( h_conn->h_al ) - { - if( h_conn->h_qp ) - { - /* Unbind the QP and connection from each other. */ - ((al_conn_qp_t*)h_conn->h_qp)->p_conn = NULL; - h_conn->h_qp = NULL; - } - - /* Remove the connection object from AL's list. */ - al_remove_conn( h_conn ); - } -} - - - -static void -__free_conn_req( - IN const ib_cm_handle_t h_conn ) -{ - if( !h_conn->p_conn_req ) - return; - - cl_free( h_conn->p_conn_req ); - h_conn->p_conn_req = NULL; -} - - - -static void -__free_conn( - IN struct _al_obj *p_obj ) -{ - ib_cm_handle_t h_conn; - - h_conn = (ib_cm_handle_t)p_obj; - - /* Release all memory used to store the connection information. */ - __free_conn_req( h_conn ); - destroy_al_obj( p_obj ); - cl_free( p_obj ); -} - - -static void -__ual_conn_reject( - IN al_conn_t* const p_conn, - IN const ib_rej_status_t reason ) -{ - ib_cm_rej_t rej = {0}; - - rej.rej_status = reason; - - ib_cm_rej( p_conn, &rej ); -} - - -/* - * Called by the QP upon destruction if still connected. - */ -void -cm_conn_destroy( - IN al_conn_qp_t * const p_conn_qp ) -{ - UNUSED_PARAM( p_conn_qp ); -} - - - -/* - * Called by AL to destroy connection objects that were not destroyed - * properly. In theory, this function should not be called, unless the - * application using AL is not written properly. - */ -void -cm_cleanup_conn( - IN const ib_cm_handle_t h_conn ) -{ - /* Just destroy the connection object. */ - ref_al_obj( &h_conn->obj ); - h_conn->obj.pfn_destroy( &h_conn->obj, NULL ); -} - - - -/* - * Allocate and initialize a structure to store CM information. - */ -static ib_listen_handle_t -__get_listen( - IN const ib_al_handle_t h_al ) -{ - ib_listen_handle_t h_listen; - ib_api_status_t status; - - /* Allocate the structure. */ - h_listen = cl_zalloc( sizeof( al_listen_t ) ); - if( !h_listen ) - return NULL; - - /* Initialize the al object portion. */ - construct_al_obj( &h_listen->obj, AL_OBJ_TYPE_H_LISTEN ); - status = init_al_obj( &h_listen->obj, h_listen, TRUE, - NULL, NULL, __free_listen ); - if( status != IB_SUCCESS ) - { - cl_free( h_listen ); - return NULL; - } - - /* The CM info structure is a child of AL. */ - attach_al_obj( &h_al->obj, &h_listen->obj ); - - return h_listen; -} - - - -static ib_cm_handle_t -__get_conn( - IN const ib_al_handle_t h_al ) -{ - ib_cm_handle_t h_conn; - ib_api_status_t status; - - /* Allocate the structure. */ - h_conn = cl_zalloc( sizeof( al_conn_t ) ); - if( !h_conn ) - return NULL; - - /* Allocate resources to establish the connection. */ - h_conn->p_conn_req = cl_zalloc( sizeof( conn_req_t ) ); - if( !h_conn->p_conn_req ) - { - __free_conn( &h_conn->obj ); - return NULL; - } - - /* Initialize the al object portion. */ - construct_al_obj( &h_conn->obj, AL_OBJ_TYPE_H_CONN ); - status = init_al_obj( &h_conn->obj, h_conn, TRUE, - __destroying_conn, NULL, __free_conn ); - if( status != IB_SUCCESS ) - { - __free_conn( &h_conn->obj ); - return NULL; - } - - al_insert_conn( h_al, h_conn ); - return h_conn; -} - - - -/* - * Reject a connection request. - */ -static void -__rej_conn( - IN const ib_cm_handle_t h_cm, - IN ib_rej_status_t rej_status ) -{ - ib_cm_rej_t cm_rej; - - cl_memclr( &cm_rej, sizeof( ib_cm_rej_t ) ); - cm_rej.rej_status = rej_status; - ib_cm_rej( h_cm, &cm_rej ); -} - - - -/* - * Initiate a listen for a connection request. - */ -ib_api_status_t -ib_cm_listen( - IN const ib_al_handle_t h_al, - IN const ib_cm_listen_t* const p_cm_listen, - IN const ib_pfn_listen_err_cb_t pfn_listen_err_cb, - IN const void* const listen_context, - OUT ib_listen_handle_t* const ph_cm_listen ) -{ - ual_cm_listen_ioctl_t *p_cm_ioctl; - size_t ioctl_buf_sz; - uintn_t bytes_ret; - ib_api_status_t status; - cl_status_t cl_status; - ib_listen_handle_t h_listen; - - AL_ENTER( AL_DBG_CM ); - - /* Validate input parameters. */ - if( AL_OBJ_INVALID_HANDLE( h_al, AL_OBJ_TYPE_H_AL ) ) - { - AL_PRINT_EXIT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR, ("Invalid AL handle.\n") ); - return IB_INVALID_AL_HANDLE; - } - if( !p_cm_listen || !ph_cm_listen ) - { - AL_PRINT_EXIT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR, ("NULL parameter.\n") ); - return IB_INVALID_PARAMETER; - } - - /* Get a listen structure. */ - h_listen = __get_listen( h_al ); - if( !h_listen ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("Failed to allocate listen structure.\n") ); - return IB_INSUFFICIENT_MEMORY; - } - - /* Save the user's information. */ - h_listen->pfn_cm_req_cb = p_cm_listen->pfn_cm_req_cb; - h_listen->pfn_cm_mra_cb = p_cm_listen->pfn_cm_mra_cb; - h_listen->pfn_cm_rej_cb = p_cm_listen->pfn_cm_rej_cb; - h_listen->pfn_listen_err_cb = pfn_listen_err_cb; - h_listen->obj.context = listen_context; - h_listen->sidr_context = p_cm_listen->sidr_context; - - ioctl_buf_sz = sizeof(p_cm_ioctl->in); - if( p_cm_listen->p_compare_buffer ) - ioctl_buf_sz += p_cm_listen->compare_length; - - p_cm_ioctl = (ual_cm_listen_ioctl_t*)cl_zalloc( ioctl_buf_sz ); - if( !p_cm_ioctl ) - { - h_listen->obj.pfn_destroy( &h_listen->obj, NULL ); - AL_PRINT_EXIT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR, ("Failed to allocate IOCTL buffer.\n") ); - return IB_INSUFFICIENT_MEMORY; - } - - /* Initialize the IOCTL. */ - p_cm_ioctl->in.context = h_listen; - p_cm_ioctl->in.cm_listen = *p_cm_listen; - /* Convert the user's information to ALs. */ - p_cm_ioctl->in.cm_listen.sidr_context = h_listen; - if( p_cm_listen->p_compare_buffer ) - { - cl_memcpy( (uint8_t*)((&p_cm_ioctl->in.cm_listen) + 1), - p_cm_listen->p_compare_buffer, p_cm_listen->compare_length ); - } - - /* Call the kernel CM to do the listen. */ - cl_status = do_al_dev_ioctl( UAL_CM_LISTEN, &p_cm_ioctl->in, ioctl_buf_sz, - &p_cm_ioctl->out, sizeof(p_cm_ioctl->out), &bytes_ret ); - - if( cl_status != CL_SUCCESS || bytes_ret != sizeof(p_cm_ioctl->out) ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("UAL_CM_LISTEN IOCTL returned %s\n", CL_STATUS_MSG(cl_status)) ); - status = IB_ERROR; - } - else - { - status = p_cm_ioctl->out.status; - } - - if( status != IB_SUCCESS ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("Failed to listen: %s.\n", ib_get_err_str(status) ) ); - h_listen->obj.pfn_destroy( &h_listen->obj, NULL ); - } - else - { - h_listen->obj.hdl = p_cm_ioctl->out.h_cm_listen; - *ph_cm_listen = h_listen; - - /* Release the reference taken in init_al_obj (__get_listen). */ - deref_al_obj( &h_listen->obj ); - } - - cl_free( p_cm_ioctl ); - AL_EXIT( AL_DBG_CM ); - return status; -} - - - -ib_api_status_t -ib_cm_cancel( - IN const ib_listen_handle_t h_cm_listen, - IN const ib_pfn_destroy_cb_t pfn_destroy_cb OPTIONAL ) -{ - ual_cm_cancel_ioctl_t cm_ioctl; - uintn_t bytes_ret; - ib_api_status_t status; - cl_status_t cl_status; - - AL_ENTER( AL_DBG_CM ); - - if( AL_OBJ_INVALID_HANDLE( h_cm_listen, AL_OBJ_TYPE_H_LISTEN ) ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , ("Invalid listen handle.\n") ); - return IB_INVALID_HANDLE; - } - - /* Take a reference on the listen until the IOCTL completes. */ - ref_al_obj( &h_cm_listen->obj ); - - /* Initialize the IOCTL. */ - cl_memclr( &cm_ioctl, sizeof( cm_ioctl ) ); - cm_ioctl.in.h_cm_listen = h_cm_listen->obj.hdl; - - /* Call the kernel CM to do the cancel. */ - cl_status = do_al_dev_ioctl( UAL_CM_CANCEL, &cm_ioctl.in, - sizeof(cm_ioctl.in), &cm_ioctl.out, sizeof(cm_ioctl.out), &bytes_ret ); - - if( cl_status != CL_SUCCESS || bytes_ret != sizeof(cm_ioctl.out) ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("UAL_CM_CANCEL IOCTL returned %s\n", CL_STATUS_MSG(cl_status)) ); - status = IB_ERROR; - } - else - { - status = cm_ioctl.out.status; - } - if( status != IB_SUCCESS ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("Failed to cancel: %s.\n", ib_get_err_str(status) ) ); - deref_al_obj( &h_cm_listen->obj ); - } - else - { - h_cm_listen->obj.pfn_destroy( &h_cm_listen->obj, pfn_destroy_cb ); - } - - AL_EXIT( AL_DBG_CM ); - return status; -} - - - -/* - * Initiate a connection request. - */ -ib_api_status_t -ib_cm_req( - IN const ib_cm_req_t* const p_cm_req ) -{ - ib_cm_handle_t h_conn; - ual_cm_req_ioctl_t *p_cm_ioctl; - size_t ioctl_buf_sz; - uint8_t *p_data; - uintn_t bytes_ret; - ib_api_status_t status; - cl_status_t cl_status; - - AL_ENTER( AL_DBG_CM ); - - /* Validate input parameters. */ - if( !p_cm_req || !p_cm_req->p_primary_path ) - { - AL_PRINT_EXIT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR, - ("NULL p_cm_req or primary path\n") ); - return IB_INVALID_PARAMETER; - } - - ioctl_buf_sz = sizeof(p_cm_ioctl->in); - if( p_cm_req->p_compare_buffer ) - ioctl_buf_sz += p_cm_req->compare_length; - if( p_cm_req->p_req_pdata ) - ioctl_buf_sz += p_cm_req->req_length; - if( p_cm_req->p_alt_path ) - ioctl_buf_sz += sizeof(ib_path_rec_t); - - p_cm_ioctl = (ual_cm_req_ioctl_t*)cl_zalloc( ioctl_buf_sz ); - if( !p_cm_ioctl ) - { - AL_PRINT_EXIT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR, - ("Failed to allocate IOCTL buf.\n") ); - return IB_INSUFFICIENT_MEMORY; - } - - /* - * Save the user's information and replace the handles with appropriate - * kernel handles. - */ - p_cm_ioctl->in.cm_req = *p_cm_req; - switch( p_cm_req->qp_type ) - { - case IB_QPT_RELIABLE_CONN: - case IB_QPT_UNRELIABLE_CONN: - if( AL_OBJ_INVALID_HANDLE( p_cm_req->h_qp, AL_OBJ_TYPE_H_QP ) || - (p_cm_req->h_qp->type != p_cm_req->qp_type) ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("IB_INVALID_QP_HANDLE\n") ); - status = IB_INVALID_QP_HANDLE; - goto cleanup; - } - - /* Update the QP destroy timeout = timeout x retries + 2 seconds. */ - set_al_obj_timeout( &p_cm_req->h_qp->obj, - p_cm_req->timeout_ms * p_cm_req->max_cm_retries + 2000 ); - - /* Get a connection structure. */ - h_conn = __get_conn( (ib_al_handle_t) - p_cm_req->h_qp->obj.p_parent_obj->p_parent_obj->p_parent_obj ); - if( !h_conn ) - { - AL_PRINT(TRACE_LEVEL_ERROR , AL_DBG_ERROR , - ("Failed to allocate connection structure.\n") ); - status = IB_INSUFFICIENT_MEMORY; - goto cleanup; - } - - __bind_qp_and_conn( h_conn, p_cm_req->h_qp ); - p_cm_ioctl->in.h_qp = p_cm_req->h_qp->obj.hdl; - - /* Record the connection information for QP transitions. */ - h_conn->p_conn_req->path_rec = *p_cm_req->p_primary_path; - if( p_cm_req->p_alt_path ) - h_conn->p_conn_req->alt_path_rec = *p_cm_req->p_alt_path; - - /* Transition the QP to the init state to allow posting receives. */ - status = cm_init_qp( h_conn->h_qp, &p_cm_req->p_primary_path->sgid, - p_cm_req->p_primary_path->pkey, - (IB_AC_RDMA_READ | IB_AC_RDMA_WRITE | IB_AC_LOCAL_WRITE | IB_AC_MW_BIND) ); - //h_conn->p_req_info->qp_mod_rts.state.rts.access_ctrl ); - if( status != IB_SUCCESS ) - { - h_conn->obj.pfn_destroy( &h_conn->obj, NULL ); - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("cm_init_qp returned %s\n", ib_get_err_str(status)) ); - goto cleanup; - } - break; - - case IB_QPT_UNRELIABLE_DGRM: - if( AL_OBJ_INVALID_HANDLE( p_cm_req->h_al, AL_OBJ_TYPE_H_AL ) ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("IB_INVALID_AL_HANDLE\n") ); - status = IB_INVALID_AL_HANDLE; - goto cleanup; - } - /* Get a connection structure. */ - h_conn = __get_conn( p_cm_req->h_al ); - if( !h_conn ) - { - AL_PRINT(TRACE_LEVEL_ERROR , AL_DBG_ERROR , - ("Failed to allocate connection structure.\n") ); - status = IB_INSUFFICIENT_MEMORY; - goto cleanup; - } - p_cm_ioctl->in.cm_req.h_al = NULL; - h_conn->sidr_context = p_cm_req->sidr_context; - p_cm_ioctl->in.cm_req.sidr_context = h_conn; - break; - - default: - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , ("Invalid qp_type.\n") ); - status = IB_INVALID_SETTING; - goto cleanup; - } - - h_conn->p_conn_req->pfn_cm_req_cb = p_cm_req->pfn_cm_req_cb; - h_conn->p_conn_req->pfn_cm_rep_cb = p_cm_req->pfn_cm_rep_cb; - h_conn->pfn_cm_mra_cb = p_cm_req->pfn_cm_mra_cb; - h_conn->pfn_cm_rej_cb = p_cm_req->pfn_cm_rej_cb; - - p_cm_ioctl->in.paths[0] = *p_cm_req->p_primary_path; - p_data = (uint8_t*)&p_cm_ioctl->in.paths[1]; - if( p_cm_req->p_alt_path ) - { - p_cm_ioctl->in.paths[1] = *p_cm_req->p_alt_path; - p_data += sizeof(ib_path_rec_t); - } - if( p_cm_req->req_length ) - { - cl_memcpy( p_data, p_cm_req->p_req_pdata, p_cm_req->req_length ); - p_data += p_cm_req->req_length; - } - if( p_cm_req->compare_length ) - { - cl_memcpy( p_data, p_cm_req->p_compare_buffer, - p_cm_req->compare_length ); - } - - cl_status = do_al_dev_ioctl( UAL_CM_REQ, &p_cm_ioctl->in, ioctl_buf_sz, - &p_cm_ioctl->out, sizeof(p_cm_ioctl->out), &bytes_ret ); - - if( cl_status != CL_SUCCESS || bytes_ret != sizeof(p_cm_ioctl->out) ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("UAL_CM_REQ IOCTL returned %s\n", CL_STATUS_MSG(cl_status)) ); - status = IB_ERROR; - } - else - { - status = p_cm_ioctl->out.status; - } - - if( status != IB_SUCCESS ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("Connection request ioctl failed with status (%s)\n", - ib_get_err_str(status) ) ); - h_conn->obj.pfn_destroy( &h_conn->obj, NULL ); - } - else - { - /* Release the reference taken in init_al_obj (__get_conn). */ - deref_al_obj( &h_conn->obj ); - } - -cleanup: - cl_free( p_cm_ioctl ); - AL_EXIT( AL_DBG_CM ); - return status; -} - - - -static ib_api_status_t -__save_user_rep( - IN const ib_cm_handle_t h_conn, - IN const ib_cm_rep_t* const p_cm_rep ) -{ - ib_port_attr_t *p_port_attr; - ib_qp_handle_t h_qp; - - AL_ENTER(AL_DBG_CM); - - __bind_qp_and_conn( h_conn, p_cm_rep->h_qp ); - h_qp = p_cm_rep->h_qp; - - /* Get the port attributes. */ - ci_ca_lock_attr( h_qp->obj.p_ci_ca ); - p_port_attr = get_port_attr( h_qp->obj.p_ci_ca->p_pnp_attr, - &h_conn->p_conn_req->path_rec.sgid ); - if( !p_port_attr ) - { - ci_ca_unlock_attr( h_qp->obj.p_ci_ca ); - AL_PRINT(TRACE_LEVEL_ERROR , AL_DBG_ERROR , ("invalid p_gid\n" ) ); - return IB_INVALID_GID; - } - - cm_save_rep_qp_attr( p_cm_rep, p_port_attr, &h_conn->p_conn_req->path_rec, - &h_conn->p_conn_req->alt_path_rec, &h_conn->p_conn_req->qp_mod_rtr, - &h_conn->p_conn_req->qp_mod_rts ); - ci_ca_unlock_attr( h_qp->obj.p_ci_ca ); - - AL_EXIT(AL_DBG_CM); - return IB_SUCCESS; -} - - - -ib_api_status_t -ib_cm_rep( - IN const ib_cm_handle_t h_cm_req, - IN const ib_cm_rep_t* const p_cm_rep ) -{ - ib_cm_handle_t h_conn; - ual_cm_rep_ioctl_t *p_cm_ioctl; - size_t ioctl_buf_sz; - uintn_t bytes_ret; - ib_api_status_t status; - cl_status_t cl_status; - - AL_ENTER(AL_DBG_CM); - - /* Validate input parameters. */ - h_conn = h_cm_req; - if( AL_OBJ_INVALID_HANDLE( h_conn, AL_OBJ_TYPE_H_CONN ) ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , ("Invalid REQ handle.\n") ); - return IB_INVALID_HANDLE; - } - if( !p_cm_rep ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , ("NULL p_cm_rep\n") ); - return IB_INVALID_PARAMETER; - } - - /* Save the user's information. */ - h_conn->p_conn_req->pfn_cm_rtu_cb = p_cm_rep->pfn_cm_rtu_cb; - h_conn->pfn_cm_lap_cb = p_cm_rep->pfn_cm_lap_cb; - h_conn->pfn_cm_dreq_cb = p_cm_rep->pfn_cm_dreq_cb; - - /* Calculate the size of the IOCTL buffer needed. */ - ioctl_buf_sz = sizeof(p_cm_ioctl->in); - if( p_cm_rep->p_rep_pdata ) - ioctl_buf_sz += p_cm_rep->rep_length; - - /* Allocate the IOCTL buffer. */ - p_cm_ioctl = (ual_cm_rep_ioctl_t*)cl_zalloc( ioctl_buf_sz ); - if( !p_cm_ioctl ) - { - AL_PRINT_EXIT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR, ("Failed to allocate IOCTL buffer.\n") ); - return IB_INSUFFICIENT_MEMORY; - } - - /* Replace the handles with appropriate kernel handles. */ - p_cm_ioctl->in.cm_rep = *p_cm_rep; - if( AL_OBJ_INVALID_HANDLE( p_cm_rep->h_qp, AL_OBJ_TYPE_H_QP ) || - p_cm_rep->h_qp->type != p_cm_rep->qp_type ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("Invalid QP handle.\n") ); - status = IB_INVALID_QP_HANDLE; - goto cleanup; - } - p_cm_ioctl->in.h_qp = p_cm_rep->h_qp->obj.hdl; - - /* Update the QP destruction timeout, use value provided by kernel CM. */ - set_al_obj_timeout( &p_cm_rep->h_qp->obj, h_conn->p_conn_req->timeout_ms ); - - status = __save_user_rep( h_conn, p_cm_rep ); - if( status != IB_SUCCESS ) - { - __ual_conn_reject( h_conn, IB_REJ_INSUF_QP ); - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("__save_user_rep returned %s\n", ib_get_err_str(status) ) ); - goto cleanup; - } - - /* Transition the QP to the init state to allow posting receives. */ - status = cm_init_qp( p_cm_rep->h_qp, &h_conn->p_conn_req->path_rec.sgid, - h_conn->p_conn_req->path_rec.pkey, p_cm_rep->access_ctrl ); - if( status != IB_SUCCESS ) - { - __ual_conn_reject( h_conn, IB_REJ_INSUF_QP ); - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("cm_init_qp returned %s\n", ib_get_err_str(status) ) ); - goto cleanup; - } - - /* Prepost receives. */ - if( p_cm_rep->p_recv_wr ) - { - status = ib_post_recv( p_cm_rep->h_qp, p_cm_rep->p_recv_wr, - p_cm_rep->pp_recv_failure ); - if( status != IB_SUCCESS ) - { - __ual_conn_reject( h_conn, IB_REJ_INSUF_QP ); - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("ib_post_recv returned %s.\n", ib_get_err_str(status)) ); - goto cleanup; - } - } - p_cm_ioctl->in.cm_rep.p_recv_wr = NULL; - - /* Transition the QP to the RTS state. */ - status = cm_rts_qp( h_conn->h_qp, &h_conn->p_conn_req->qp_mod_rtr, - &h_conn->p_conn_req->qp_mod_rts ); - if( status != IB_SUCCESS ) - { - __ual_conn_reject( h_conn, IB_REJ_INSUF_QP ); - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("cm_rts_qp with status (%s)\n", ib_get_err_str(status) ) ); - goto cleanup; - } - - p_cm_ioctl->in.h_cm_req = h_conn->obj.hdl; - /* Copy the private data. */ - if( p_cm_rep->p_rep_pdata ) - { - cl_memcpy( (&p_cm_ioctl->in.cm_rep) + 1, - p_cm_rep->p_rep_pdata, p_cm_rep->rep_length ); - } - - cl_status = do_al_dev_ioctl( UAL_CM_REP, - &p_cm_ioctl->in, ioctl_buf_sz, - &p_cm_ioctl->out, sizeof(p_cm_ioctl->out), - &bytes_ret ); - - if( cl_status != CL_SUCCESS || bytes_ret != sizeof(p_cm_ioctl->out) ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("UAL_CM_REP IOCTL returned %s\n", CL_STATUS_MSG(cl_status)) ); - status = IB_ERROR; - } - else - { - status = p_cm_ioctl->out.status; - } - - if( status != IB_SUCCESS ) - { - AL_PRINT(TRACE_LEVEL_ERROR , AL_DBG_ERROR , - ("Connection reply ioctl failed with status (%s)\n", - ib_get_err_str(status) ) ); - cm_reset_qp( h_conn->h_qp, 0 ); - ref_al_obj( &h_conn->obj ); - h_conn->obj.pfn_destroy( &h_conn->obj, NULL ); - } - -cleanup: - cl_free( p_cm_ioctl ); - AL_EXIT( AL_DBG_CM ); - return status; -} - - - -ib_api_status_t -ib_cm_rtu( - IN const ib_cm_handle_t h_cm_rep, - IN const ib_cm_rtu_t* const p_cm_rtu ) -{ - ib_cm_handle_t h_conn; - ual_cm_rtu_ioctl_t *p_cm_ioctl; - size_t ioctl_buf_sz; - uintn_t bytes_ret; - ib_api_status_t status; - cl_status_t cl_status; - - AL_ENTER(AL_DBG_CM); - - /* Validate input parameters. */ - h_conn = h_cm_rep; - if( AL_OBJ_INVALID_HANDLE( h_conn, AL_OBJ_TYPE_H_CONN ) ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , ("Invalid rep handle.\n") ); - return IB_INVALID_HANDLE; - } - if( !p_cm_rtu ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , ("NULL p_cm_rtu\n") ); - return IB_INVALID_PARAMETER; - } - - /* Save the user's information. */ - h_conn->pfn_cm_apr_cb = p_cm_rtu->pfn_cm_apr_cb; - h_conn->pfn_cm_dreq_cb = p_cm_rtu->pfn_cm_dreq_cb; - cm_save_rtu_qp_attr( p_cm_rtu, &h_conn->p_conn_req->qp_mod_rtr ); - - /* Transition the QP to the RTS state. */ - status = cm_rts_qp( h_conn->h_qp, &h_conn->p_conn_req->qp_mod_rtr, - &h_conn->p_conn_req->qp_mod_rts ); - if( status != IB_SUCCESS ) - { - __ual_conn_reject( h_conn, IB_REJ_INSUF_QP ); - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("cm_rts_qp with status (%s)\n", ib_get_err_str(status) ) ); - return status; - } - - /* - * We are done with this connection establishment. After we send the - * RTU, the user can disconnect the QP, destroy it, close AL, or do - * one of any number of difficult things to deal with, so we destroy - * the connection request structure here to avoid possible duplicate - * destructions. - */ - __free_conn_req( h_conn ); - - ioctl_buf_sz = sizeof(p_cm_ioctl->in); - if( p_cm_rtu->p_rtu_pdata ) - ioctl_buf_sz += p_cm_rtu->rtu_length; - - p_cm_ioctl = (ual_cm_rtu_ioctl_t*)cl_zalloc( ioctl_buf_sz ); - if( !p_cm_ioctl ) - { - AL_PRINT_EXIT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR, ("Failed to allocate IOCTL buffer\n") ); - return IB_INSUFFICIENT_MEMORY; - } - - p_cm_ioctl->in.h_cm_rep = h_conn->obj.hdl; - p_cm_ioctl->in.cm_rtu = *p_cm_rtu; - if( p_cm_rtu->p_rtu_pdata ) - { - cl_memcpy( (&p_cm_ioctl->in.cm_rtu) + 1, - p_cm_rtu->p_rtu_pdata, p_cm_rtu->rtu_length ); - } - - cl_status = do_al_dev_ioctl( UAL_CM_RTU, - &p_cm_ioctl->in, ioctl_buf_sz, - &p_cm_ioctl->out, sizeof(p_cm_ioctl->out), - &bytes_ret ); - - if( cl_status != CL_SUCCESS || bytes_ret != sizeof(p_cm_ioctl->out) ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("UAL_CM_RTU IOCTL returned %s\n", CL_STATUS_MSG(cl_status)) ); - status = IB_ERROR; - } - else - { - status = p_cm_ioctl->out.status; - } - - if( IB_SUCCESS != status ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("IOCTL status %s.\n", ib_get_err_str(status)) ); - ref_al_obj( &h_conn->obj ); - h_conn->obj.pfn_destroy( &h_conn->obj, NULL ); - } - - cl_free( p_cm_ioctl ); - AL_EXIT( AL_DBG_CM ); - return status; -} - - - -ib_api_status_t -ib_cm_handoff( - IN const ib_cm_handle_t h_cm_req, - IN const ib_net64_t svc_id ) -{ - ib_cm_handle_t h_conn; - ual_cm_handoff_ioctl_t cm_ioctl; - uintn_t bytes_ret; - cl_status_t cl_status; - - AL_ENTER( AL_DBG_CM ); - - /* Validate input parameters. */ - h_conn = h_cm_req; - if( AL_OBJ_INVALID_HANDLE( h_conn, AL_OBJ_TYPE_H_CONN ) ) - { - AL_PRINT_EXIT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR, ("Invalid REQ handle.\n") ); - return IB_INVALID_HANDLE; - } - if( !svc_id ) - { - AL_PRINT_EXIT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR, ("0 svc_id\n" ) ); - return IB_INVALID_PARAMETER; - } - - cl_memclr( &cm_ioctl, sizeof(ual_cm_rej_ioctl_t) ); - - cm_ioctl.in.h_cm = h_conn->obj.hdl; - CL_ASSERT( cm_ioctl.in.h_cm ); - cm_ioctl.in.sid = svc_id; - - cl_status = do_al_dev_ioctl( UAL_CM_HANDOFF, - &cm_ioctl.in, sizeof(cm_ioctl.in), &cm_ioctl.out, sizeof(cm_ioctl.out), - &bytes_ret ); - - if( cl_status != CL_SUCCESS || bytes_ret != sizeof(cm_ioctl.out) ) - { - AL_PRINT_EXIT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR, - ("UAL_CM_HANDOFF IOCTL returned %s\n", CL_STATUS_MSG(cl_status)) ); - return IB_ERROR; - } - else if( cm_ioctl.out.status != IB_SUCCESS ) - { - AL_PRINT_EXIT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR, - ("IOCTL status %s\n", ib_get_err_str(cm_ioctl.out.status)) ); - } - - /* Move the QP (if any) to the error state. */ - if( h_conn->h_qp ) - cm_reset_qp( h_conn->h_qp, 0 ); - - AL_EXIT( AL_DBG_CM ); - return cm_ioctl.out.status; -} - - - -ib_api_status_t -ib_cm_rej( - IN const ib_cm_handle_t h_cm, - IN const ib_cm_rej_t* const p_cm_rej ) -{ - ib_cm_handle_t h_conn; - ual_cm_rej_ioctl_t *p_cm_ioctl; - size_t ioctl_buf_sz; - uint8_t *p_data; - uintn_t bytes_ret; - ib_api_status_t status; - cl_status_t cl_status; - - AL_ENTER(AL_DBG_CM); - - /* Validate input parameters. */ - h_conn = h_cm; - if( AL_OBJ_INVALID_HANDLE( h_conn, AL_OBJ_TYPE_H_CONN ) ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , ("Invalid REJ handle.\n") ); - return IB_INVALID_HANDLE; - } - if( !p_cm_rej ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , ("NULL p_cm_rej\n") ); - return IB_INVALID_PARAMETER; - } - - ioctl_buf_sz = sizeof(p_cm_ioctl->in); - if( p_cm_rej->p_ari ) - ioctl_buf_sz += p_cm_rej->ari_length; - if( p_cm_rej->p_rej_pdata ) - ioctl_buf_sz += p_cm_rej->rej_length; - - p_cm_ioctl = (ual_cm_rej_ioctl_t*)cl_zalloc( ioctl_buf_sz ); - if( !p_cm_ioctl ) - { - AL_PRINT_EXIT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR, - ("Failed to allocate IOCTL buffer.\n") ); - return IB_INSUFFICIENT_MEMORY; - } - - p_cm_ioctl->in.h_cm = h_conn->obj.hdl; - CL_ASSERT( p_cm_ioctl->in.h_cm ); - p_cm_ioctl->in.cm_rej = *p_cm_rej; - p_data = (uint8_t*)((&p_cm_ioctl->in.cm_rej) + 1); - if( p_cm_rej->p_ari ) - { - cl_memcpy( p_data, p_cm_rej->p_ari, p_cm_rej->ari_length ); - p_data += p_cm_rej->ari_length; - } - if( p_cm_rej->p_rej_pdata ) - cl_memcpy( p_data, p_cm_rej->p_rej_pdata, p_cm_rej->rej_length ); - - cl_status = do_al_dev_ioctl( UAL_CM_REJ, - &p_cm_ioctl->in, ioctl_buf_sz, - &p_cm_ioctl->out, sizeof(p_cm_ioctl->out), - &bytes_ret ); - - if( cl_status != CL_SUCCESS || bytes_ret != sizeof(p_cm_ioctl->out) ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("UAL_CM_REJ IOCTL returned %s\n", CL_STATUS_MSG(cl_status)) ); - status = IB_ERROR; - } - else - { - status = p_cm_ioctl->out.status; - } - - if( h_conn->h_qp ) - cm_reset_qp( h_conn->h_qp, 0 ); - - if( IB_SUCCESS == status ) - { - /* Cleanup the connection request. */ - ref_al_obj( &h_conn->obj ); - h_conn->obj.pfn_destroy( &h_conn->obj, NULL ); - } - else - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("IOCTL status %s.\n", ib_get_err_str(status)) ); - } - - cl_free( p_cm_ioctl ); - AL_EXIT( AL_DBG_CM ); - return status; -} - - - -ib_api_status_t -ib_cm_mra( - IN const ib_cm_handle_t h_cm, - IN const ib_cm_mra_t* const p_cm_mra ) -{ - ib_cm_handle_t h_conn; - ual_cm_mra_ioctl_t *p_cm_ioctl; - size_t ioctl_buf_sz; - uintn_t bytes_ret; - ib_api_status_t status; - cl_status_t cl_status; - - AL_ENTER(AL_DBG_CM); - - /* Validate input parameters. */ - h_conn = h_cm; - if( AL_OBJ_INVALID_HANDLE( h_conn, AL_OBJ_TYPE_H_CONN ) ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , ("Invalid CM handle.\n") ); - return IB_INVALID_HANDLE; - } - if( !p_cm_mra ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , ("NULL p_cm_mra\n") ); - return IB_INVALID_PARAMETER; - } - - ioctl_buf_sz = sizeof(p_cm_ioctl->in); - if( p_cm_mra->p_mra_pdata ) - ioctl_buf_sz += p_cm_mra->mra_length; - - p_cm_ioctl = (ual_cm_mra_ioctl_t*)cl_zalloc( ioctl_buf_sz ); - if( !p_cm_ioctl ) - { - AL_PRINT_EXIT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR, - ("Failed to allocate IOCTL buffer\n") ); - return IB_INSUFFICIENT_MEMORY; - } - - p_cm_ioctl->in.h_cm = h_conn->obj.hdl; - CL_ASSERT( p_cm_ioctl->in.h_cm ); - p_cm_ioctl->in.cm_mra = *p_cm_mra; - if( p_cm_mra->p_mra_pdata ) - { - cl_memcpy( (uint8_t*)((&p_cm_ioctl->in.cm_mra) + 1), - p_cm_mra->p_mra_pdata, p_cm_mra->mra_length ); - } - - cl_status = do_al_dev_ioctl( UAL_CM_MRA, &p_cm_ioctl->in, ioctl_buf_sz, - &p_cm_ioctl->out, sizeof(p_cm_ioctl->out), &bytes_ret ); - - if( cl_status != CL_SUCCESS || bytes_ret != sizeof(p_cm_ioctl->out) ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("UAL_CM_MRA IOCTL returned %s\n", CL_STATUS_MSG(cl_status)) ); - status = IB_ERROR; - } - else - { - status = p_cm_ioctl->out.status; - if( status != IB_SUCCESS ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("IOCTL status %s.\n", ib_get_err_str(status)) ); - } - } - - cl_free( p_cm_ioctl ); - AL_EXIT(AL_DBG_CM); - return status; -} - - - -ib_api_status_t -ib_cm_lap( - IN const ib_cm_lap_t* const p_cm_lap ) -{ - ib_cm_handle_t h_conn; - ual_cm_lap_ioctl_t *p_cm_ioctl; - size_t ioctl_buf_sz; - uintn_t bytes_ret; - ib_api_status_t status; - cl_status_t cl_status; - - AL_ENTER(AL_DBG_CM); - - /* Validate input parameters. */ - if( !p_cm_lap || !p_cm_lap->p_alt_path ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , ("NULL p_cm_lap\n") ); - return IB_INVALID_PARAMETER; - } - - ioctl_buf_sz = sizeof(p_cm_ioctl->in); - if( p_cm_lap->p_lap_pdata ) - ioctl_buf_sz += p_cm_lap->lap_length; - - p_cm_ioctl = (ual_cm_lap_ioctl_t*)cl_zalloc( ioctl_buf_sz ); - if( !p_cm_ioctl ) - { - AL_PRINT_EXIT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR, ("Failed to allocate IOCTL buffer.\n") ); - return IB_INSUFFICIENT_MEMORY; - } - - /* Convert to the kernel-mode handles. */ - p_cm_ioctl->in.cm_lap = *p_cm_lap; - switch( p_cm_lap->qp_type ) - { - case IB_QPT_RELIABLE_CONN: - case IB_QPT_UNRELIABLE_CONN: - if( AL_OBJ_INVALID_HANDLE( p_cm_lap->h_qp, AL_OBJ_TYPE_H_QP ) || - (p_cm_lap->h_qp->type != p_cm_lap->qp_type) ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("IB_INVALID_QP_HANDLE\n") ); - status = IB_INVALID_QP_HANDLE; - goto cleanup; - } - p_cm_ioctl->in.h_qp = p_cm_lap->h_qp->obj.hdl; - h_conn = ((al_conn_qp_t*)p_cm_lap->h_qp)->p_conn; - break; - - default: - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , ("Invalid qp_type.\n") ); - status = IB_INVALID_SETTING; - goto cleanup; - } - - if( AL_OBJ_INVALID_HANDLE( h_conn, AL_OBJ_TYPE_H_CONN ) ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("No connection info!\n") ); - status = IB_INVALID_SETTING; - goto cleanup; - } - h_conn->pfn_cm_apr_cb = p_cm_lap->pfn_cm_apr_cb; - - /* Copy the path. */ - p_cm_ioctl->in.alt_path = *p_cm_lap->p_alt_path; - /* Copy the private data. */ - if( p_cm_lap->p_lap_pdata ) - { - cl_memcpy( (&p_cm_ioctl->in.alt_path) + 1, - p_cm_lap->p_lap_pdata, p_cm_lap->lap_length ); - } - - cl_status = do_al_dev_ioctl( UAL_CM_LAP, &p_cm_ioctl->in, ioctl_buf_sz, - &p_cm_ioctl->out, sizeof(p_cm_ioctl->out), &bytes_ret ); - - if( cl_status != CL_SUCCESS || bytes_ret != sizeof(p_cm_ioctl->out) ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("UAL_CM_LAP IOCTL returned %s\n", CL_STATUS_MSG(cl_status)) ); - status = IB_ERROR; - } - else - { - status = p_cm_ioctl->out.status; - if( status != IB_SUCCESS ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("IOCTL status %s.\n", ib_get_err_str(status)) ); - } - } - -cleanup: - cl_free( p_cm_ioctl ); - AL_EXIT(AL_DBG_CM); - return status; -} - - - -ib_api_status_t -ib_force_apm( - IN const ib_qp_handle_t h_qp ) -{ - ual_force_apm_ioctl_t cm_ioctl; - uintn_t bytes_ret; - ib_api_status_t status; - cl_status_t cl_status; - - AL_ENTER(AL_DBG_CM); - - /* Clear the apm_ioctl */ - cl_memclr( &cm_ioctl, sizeof( cm_ioctl ) ); - - /* Replace the handles with kernel handles appropriately */ - if( AL_OBJ_INVALID_HANDLE( h_qp, AL_OBJ_TYPE_H_QP ) ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , ("Invalid QP handle.\n") ); - return IB_INVALID_QP_HANDLE; - } - - cm_ioctl.in.h_qp = h_qp->obj.hdl; - - cl_status = do_al_dev_ioctl( UAL_CM_FORCE_APM, - &cm_ioctl.in, sizeof(cm_ioctl.in), &cm_ioctl.out, sizeof(cm_ioctl.out), - &bytes_ret ); - - if( cl_status != CL_SUCCESS || bytes_ret != sizeof(cm_ioctl.out) ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("UAL_CM_FORCE_APM IOCTL returned %s\n", - CL_STATUS_MSG(cl_status)) ); - status = IB_ERROR; - } - else - { - status = cm_ioctl.out.status; - if( status != IB_SUCCESS ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("IOCTL status %s.\n", ib_get_err_str(status)) ); - } - } - - AL_EXIT(AL_DBG_CM); - return status; -} - - - -ib_api_status_t -ib_cm_apr( - IN const ib_cm_handle_t h_cm_lap, - IN const ib_cm_apr_t* const p_cm_apr ) -{ - ib_cm_handle_t h_conn; - ual_cm_apr_ioctl_t *p_cm_ioctl; - size_t ioctl_buf_sz; - uintn_t bytes_ret; - ib_api_status_t status; - cl_status_t cl_status; - uint8_t *p_buf; - - AL_ENTER(AL_DBG_CM); - - /* Validate input parameters. */ - h_conn = h_cm_lap; - if( AL_OBJ_INVALID_HANDLE( h_conn, AL_OBJ_TYPE_H_CONN ) ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , ("Invalid lap handle.\n") ); - return IB_INVALID_HANDLE; - } - if( !p_cm_apr ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , ("NULL p_cm_apr\n") ); - return IB_INVALID_PARAMETER; - } - - ioctl_buf_sz = sizeof(p_cm_ioctl->in); - if( p_cm_apr->p_info ) - ioctl_buf_sz += p_cm_apr->info_length; - if( p_cm_apr->p_apr_pdata ) - ioctl_buf_sz += p_cm_apr->apr_length; - - p_cm_ioctl = (ual_cm_apr_ioctl_t*)cl_zalloc( ioctl_buf_sz ); - if( !p_cm_ioctl ) - { - AL_PRINT_EXIT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR, ("Failed to allocate IOCTL buffer.\n") ); - return IB_INSUFFICIENT_MEMORY; - } - - /* Replace the handles with kernel handles appropriately */ - p_cm_ioctl->in.h_cm_lap = h_conn->obj.hdl; - CL_ASSERT( p_cm_ioctl->in.h_cm_lap ); - - /* Convert to the kernel-mode handles. */ - p_cm_ioctl->in.cm_apr = *p_cm_apr; - switch( p_cm_apr->qp_type ) - { - case IB_QPT_RELIABLE_CONN: - case IB_QPT_UNRELIABLE_CONN: - if( AL_OBJ_INVALID_HANDLE( p_cm_apr->h_qp, AL_OBJ_TYPE_H_QP ) || - (p_cm_apr->h_qp->type != p_cm_apr->qp_type) ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("IB_INVALID_QP_HANDLE\n") ); - status = IB_INVALID_QP_HANDLE; - goto cleanup; - } - p_cm_ioctl->in.h_qp = p_cm_apr->h_qp->obj.hdl; - h_conn = ((al_conn_qp_t*)p_cm_apr->h_qp)->p_conn; - break; - - default: - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , ("Invalid qp_type.\n") ); - status = IB_INVALID_SETTING; - goto cleanup; - } - - if( AL_OBJ_INVALID_HANDLE( h_conn, AL_OBJ_TYPE_H_CONN ) ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("No connection info!\n") ); - status = IB_INVALID_SETTING; - goto cleanup; - } - - /* Copy the apr info and private data. */ - p_buf = (uint8_t*)((&p_cm_ioctl->in.cm_apr) + 1); - if( p_cm_apr->p_info ) - { - cl_memcpy( p_buf, p_cm_apr->p_info, p_cm_apr->info_length ); - p_buf += p_cm_apr->info_length; - } - if( p_cm_apr->p_apr_pdata ) - cl_memcpy( p_buf, p_cm_apr->p_apr_pdata, p_cm_apr->apr_length ); - - cl_status = do_al_dev_ioctl( UAL_CM_APR, - &p_cm_ioctl->in, ioctl_buf_sz, - &p_cm_ioctl->out, sizeof(p_cm_ioctl->out), - &bytes_ret ); - - if( cl_status != CL_SUCCESS || bytes_ret != sizeof(p_cm_ioctl->out) ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("UAL_CM_APR IOCTL returned %s.\n", CL_STATUS_MSG(cl_status)) ); - status = IB_ERROR; - } - else - { - status = p_cm_ioctl->out.status; - if( status != IB_SUCCESS ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("IOCTL status %s.\n", ib_get_err_str(status)) ); - } - } - - /* Release the reference taken when processing the callback. */ - deref_al_obj( &h_conn->obj ); - -cleanup: - cl_free( p_cm_ioctl ); - AL_EXIT(AL_DBG_CM); - return IB_SUCCESS; -} - - - -ib_api_status_t -ib_cm_dreq( - IN const ib_cm_dreq_t* const p_cm_dreq ) -{ - ib_cm_handle_t h_conn; - ual_cm_dreq_ioctl_t *p_cm_ioctl; - size_t ioctl_buf_sz; - uintn_t bytes_ret; - ib_api_status_t status; - cl_status_t cl_status; - - AL_ENTER(AL_DBG_CM); - - /* Validate input parameters. */ - if( !p_cm_dreq ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , ("NULL p_cm_dreq\n") ); - return IB_INVALID_PARAMETER; - } - - ioctl_buf_sz = sizeof(p_cm_ioctl->in); - if( p_cm_dreq->p_dreq_pdata ) - ioctl_buf_sz += p_cm_dreq->dreq_length; - - p_cm_ioctl = (ual_cm_dreq_ioctl_t*)cl_zalloc( ioctl_buf_sz ); - if( !p_cm_ioctl ) - { - AL_PRINT_EXIT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR, ("Failed to allocate IOCTL buffer.\n") ); - return IB_INSUFFICIENT_MEMORY; - } - - /* Convert to the kernel-mode handles. */ - p_cm_ioctl->in.cm_dreq = *p_cm_dreq; - switch( p_cm_dreq->qp_type ) - { - case IB_QPT_RELIABLE_CONN: - case IB_QPT_UNRELIABLE_CONN: - if( AL_OBJ_INVALID_HANDLE( p_cm_dreq->h_qp, AL_OBJ_TYPE_H_QP ) || - (p_cm_dreq->h_qp->type != p_cm_dreq->qp_type) ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("IB_INVALID_QP_HANDLE\n") ); - status = IB_INVALID_QP_HANDLE; - goto cleanup; - } - p_cm_ioctl->in.h_qp = p_cm_dreq->h_qp->obj.hdl; - h_conn = ((al_conn_qp_t*)p_cm_dreq->h_qp)->p_conn; - break; - - default: - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , ("Invalid qp_type.\n") ); - status = IB_INVALID_SETTING; - goto cleanup; - } - - if( AL_OBJ_INVALID_HANDLE( h_conn, AL_OBJ_TYPE_H_CONN ) ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("No connection info!\n") ); - status = IB_INVALID_SETTING; - goto cleanup; - } - h_conn->pfn_cm_drep_cb = p_cm_dreq->pfn_cm_drep_cb; - - /* Copy the private data. */ - if( p_cm_dreq->p_dreq_pdata ) - { - cl_memcpy( (&p_cm_ioctl->in.cm_dreq) + 1, - p_cm_dreq->p_dreq_pdata, p_cm_dreq->dreq_length ); - } - - cl_status = do_al_dev_ioctl( UAL_CM_DREQ, - &p_cm_ioctl->in, ioctl_buf_sz, - &p_cm_ioctl->out, sizeof(p_cm_ioctl->out), - &bytes_ret ); - - if( cl_status != CL_SUCCESS || bytes_ret != sizeof(p_cm_ioctl->out) ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("UAL_CM_DREQ IOCTL returned %s\n", CL_STATUS_MSG(cl_status)) ); - status = IB_ERROR; - } - else - { - status = p_cm_ioctl->out.status; - if( IB_SUCCESS != status ) - { - /* We can fail if we just received a DREQ, which is not an error. */ - AL_PRINT(TRACE_LEVEL_INFORMATION ,AL_DBG_CM , - ("IOCTL status %s\n", ib_get_err_str(status)) ); - } - } - -cleanup: - cl_free( p_cm_ioctl ); - AL_EXIT(AL_DBG_CM); - return status; -} - - - -ib_api_status_t -ib_cm_drep( - IN const ib_cm_handle_t h_cm_dreq, - IN const ib_cm_drep_t* const p_cm_drep ) -{ - ib_cm_handle_t h_conn; - ual_cm_drep_ioctl_t *p_cm_ioctl; - size_t ioctl_buf_sz; - uintn_t bytes_ret; - ib_api_status_t status; - cl_status_t cl_status; - - AL_ENTER(AL_DBG_CM); - - /* Validate input parameters. */ - h_conn = h_cm_dreq; - if( AL_OBJ_INVALID_HANDLE( h_conn, AL_OBJ_TYPE_H_CONN ) ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , ("Invalid DREP handle.\n") ); - return IB_INVALID_HANDLE; - } - if( !p_cm_drep ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , ("NULL p_cm_drep\n") ); - return IB_INVALID_PARAMETER; - } - - ioctl_buf_sz = sizeof(p_cm_ioctl->in); - if( p_cm_drep->p_drep_pdata ) - ioctl_buf_sz += p_cm_drep->drep_length; - - p_cm_ioctl = (ual_cm_drep_ioctl_t*)cl_zalloc( ioctl_buf_sz ); - if( !p_cm_ioctl ) - { - AL_PRINT_EXIT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR, - ("Failed to allocate IOCTL buffer.\n") ); - return IB_INSUFFICIENT_MEMORY; - } - - p_cm_ioctl->in.h_cm_dreq = h_conn->obj.hdl; - CL_ASSERT( p_cm_ioctl->in.h_cm_dreq ); - p_cm_ioctl->in.cm_drep = *p_cm_drep; - if( p_cm_drep->p_drep_pdata ) - { - cl_memcpy( (uint8_t*)((&p_cm_ioctl->in.cm_drep) + 1), - p_cm_drep->p_drep_pdata, p_cm_drep->drep_length ); - } - - cl_status = do_al_dev_ioctl( UAL_CM_DREP, - &p_cm_ioctl->in, ioctl_buf_sz, - &p_cm_ioctl->out, sizeof(p_cm_ioctl->out), - &bytes_ret ); - - if( cl_status != CL_SUCCESS || bytes_ret != sizeof(p_cm_ioctl->out) ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("UAL_CM_DREP IOCTL returned %s\n", CL_STATUS_MSG(cl_status)) ); - status = IB_ERROR; - } - else - { - status = p_cm_ioctl->out.status; - } - - if( IB_SUCCESS == status ) - { - cm_reset_qp( h_conn->h_qp, 0 ); - /* Cleanup the connection request. */ - h_conn->obj.pfn_destroy( &h_conn->obj, NULL ); - } - else - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("IOCTL status %s\n", ib_get_err_str(status)) ); - - /* Release the reference taken when processing the callback. */ - deref_al_obj( &h_conn->obj ); - } - - cl_free( p_cm_ioctl ); - AL_EXIT(AL_DBG_CM); - return status; -} - - - -void -ual_listen_err_cb( - IN ib_listen_err_rec_t *p_listen_err_rec ) -{ - ib_listen_handle_t h_listen; - - AL_ENTER(AL_DBG_CM); - - /* Get the listen object. */ - h_listen = p_listen_err_rec->listen_context; - if( AL_OBJ_INVALID_HANDLE( h_listen, AL_OBJ_TYPE_H_LISTEN ) ) - return; - - /* Convert to the user's handles and structures. */ - p_listen_err_rec->listen_context = (void*)h_listen->obj.context; - p_listen_err_rec->h_cm_listen = h_listen; - - /* Call the user's callback. */ - h_listen->pfn_listen_err_cb( p_listen_err_rec ); - - /* Destroy the listen request. */ - ref_al_obj( &h_listen->obj ); - h_listen->obj.pfn_destroy( &h_listen->obj, NULL ); - - AL_EXIT(AL_DBG_CM); -} - - - -void -ual_cm_req_cb( - IN ib_cm_req_rec_t* p_cm_req_rec, - IN ib_qp_mod_t* p_qp_rtr, - IN ib_qp_mod_t* p_qp_rts, - IN uint32_t timeout_ms ) -{ - ib_listen_handle_t h_listen; - ib_cm_handle_t h_conn; - ib_qp_handle_t h_qp; - - AL_ENTER(AL_DBG_CM); - - if( p_cm_req_rec->h_cm_listen ) - { - /* - * This was generated in response for a listen request. Store - * the kernel handle in the user mode handle in case the - * ib_cm_listen call has not returned yet. - */ - h_listen = (ib_listen_handle_t)p_cm_req_rec->context; - h_listen->obj.hdl = (uint64_t)p_cm_req_rec->h_cm_listen; - - /* - * Replace the listen handle with UAL handle and the context with - * the application's context. - */ - p_cm_req_rec->h_cm_listen = h_listen; - p_cm_req_rec->context = h_listen->obj.context; - p_cm_req_rec->sidr_context = h_listen->sidr_context; - - /* For a req callback as a result of a listen, there is no - * connection handle associated with the user mode yet. So - * create one that can be used in the reply. - */ - h_conn = __get_conn( (ib_al_handle_t)h_listen->obj.p_parent_obj ); - if( !h_conn ) - { - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , - ("__get_conn failed.\n") ); - __rej_conn( p_cm_req_rec->h_cm_req, IB_REJ_INSUF_RESOURCES ); - return; - } - - deref_al_obj( &h_conn->obj ); - - /* Copy the callbacks from the listen. */ - h_conn->p_conn_req->pfn_cm_req_cb = h_listen->pfn_cm_req_cb; - h_conn->pfn_cm_rej_cb = h_listen->pfn_cm_rej_cb; - h_conn->pfn_cm_mra_cb = h_listen->pfn_cm_mra_cb; - } - else - { - /* This callback was generated for peer-to-peer connections */ - h_qp = (ib_qp_handle_t)p_cm_req_rec->context; - p_cm_req_rec->context = h_qp->obj.context; - - /* Get the connection handle associated with this QP. */ - h_conn = ((al_conn_qp_t*)h_qp)->p_conn; - - /* - * Unbind this QP. This allows the user to use a different QP - * when replying to the connection. - */ - cm_unbind_qp( h_conn ); - deref_al_obj( &h_qp->obj ); - } - - /* Store & replace the kernel handle */ - h_conn->obj.hdl = (uint64_t)p_cm_req_rec->h_cm_req; - p_cm_req_rec->h_cm_req = h_conn; - - /* - * Copy the connection request information needed to properly configure - * the QP. - */ - h_conn->p_conn_req->path_rec = p_cm_req_rec->primary_path; - h_conn->p_conn_req->alt_path_rec = p_cm_req_rec->alt_path; - h_conn->p_conn_req->qp_mod_rtr = *p_qp_rtr; - h_conn->p_conn_req->qp_mod_rts = *p_qp_rts; - h_conn->p_conn_req->timeout_ms = timeout_ms; - - /* Invoke the user's callback. */ - h_conn->p_conn_req->pfn_cm_req_cb( p_cm_req_rec ); - - AL_EXIT(AL_DBG_CM); -} - - - -void -ual_cm_rep_cb( - IN ib_cm_rep_rec_t* p_cm_rep_rec, - IN ib_qp_mod_t* p_qp_rtr, - IN ib_qp_mod_t* p_qp_rts ) -{ - ib_cm_handle_t h_conn; - ib_qp_handle_t h_qp; - - AL_ENTER(AL_DBG_CM); - - /* Get the user's context. */ - switch( p_cm_rep_rec->qp_type ) - { - case IB_QPT_RELIABLE_CONN: - case IB_QPT_UNRELIABLE_CONN: - h_qp = (ib_qp_handle_t)p_cm_rep_rec->qp_context; - p_cm_rep_rec->qp_context = h_qp->obj.context; - - /* Get the connection handle associated with this QP. */ - h_conn = ((al_conn_qp_t*)h_qp)->p_conn; - - /* Store the kernel reply handle. */ - h_conn->obj.hdl = (uint64_t)p_cm_rep_rec->h_cm_rep; - p_cm_rep_rec->h_cm_rep = h_conn; - - /* - * Copy the connection request information needed to properly - * configure the QP. - */ - h_conn->p_conn_req->qp_mod_rtr = *p_qp_rtr; - h_conn->p_conn_req->qp_mod_rts = *p_qp_rts; - - /* Call the application callback */ - h_conn->p_conn_req->pfn_cm_rep_cb( p_cm_rep_rec ); - break; - - case IB_QPT_UNRELIABLE_DGRM: - /* Get the SIDR request handle associated with this request. */ - h_conn = (ib_cm_handle_t)p_cm_rep_rec->sidr_context; - p_cm_rep_rec->sidr_context = h_conn->sidr_context; - - /* Call the application callback */ - h_conn->p_conn_req->pfn_cm_rep_cb( p_cm_rep_rec ); - - /* Destroy the SIDR request. */ - ref_al_obj( &h_conn->obj ); - h_conn->obj.pfn_destroy( &h_conn->obj, NULL ); - break; - - default: - AL_PRINT(TRACE_LEVEL_ERROR , AL_DBG_ERROR , ("Invalid qp_type.\n") ); - break; - } - - AL_EXIT(AL_DBG_CM); -} - - - -void -ual_cm_rtu_cb( - IN ib_cm_rtu_rec_t* p_cm_rtu_rec ) -{ - ib_cm_handle_t h_conn; - ib_qp_handle_t h_qp; - ib_pfn_cm_rtu_cb_t pfn_cm_rtu_cb; - - AL_ENTER(AL_DBG_CM); - - h_qp = (ib_qp_handle_t)p_cm_rtu_rec->qp_context; - p_cm_rtu_rec->qp_context = h_qp->obj.context; - - /* Get the connection handle associated with this QP. */ - h_conn = ((al_conn_qp_t*)h_qp)->p_conn; - - /* - * We are done with this connection establishment. After we call the - * user back, they can disconnect the QP, destroy it, close AL, or do - * one of any number of difficult things to deal with, so we need to - * handle the case where the connection structure may be destroyed. - * Get a copy of the user's callback. - */ - pfn_cm_rtu_cb = h_conn->p_conn_req->pfn_cm_rtu_cb; - __free_conn_req( h_conn ); - - /* Invoke the user's callback. */ - pfn_cm_rtu_cb( p_cm_rtu_rec ); - - AL_EXIT(AL_DBG_CM); -} - - - -void -ual_cm_rej_cb( - IN ib_cm_rej_rec_t* p_cm_rej_rec ) -{ - ib_cm_handle_t h_conn; - ib_qp_handle_t h_qp; - ib_pfn_cm_rej_cb_t pfn_cm_rej_cb; - - AL_ENTER(AL_DBG_CM); - - h_qp = (ib_qp_handle_t)p_cm_rej_rec->qp_context; - p_cm_rej_rec->qp_context = h_qp->obj.context; - - /* Get the connection handle associated with this QP. */ - h_conn = ((al_conn_qp_t*)h_qp)->p_conn; - - if( !h_conn ) - { - AL_EXIT( AL_DBG_CM ); - return; - } - - /* Move the QP to the error state. Timewait is tracked in the kernel. */ - cm_reset_qp( h_qp, 0 ); - - /* - * Since user can reuse the QP associated with this connection after - * receiving the reject message, we need to disassociate this - * connection handle from the QP before calling the user back. - */ - if ( h_conn ) - { - pfn_cm_rej_cb = h_conn->pfn_cm_rej_cb; - ref_al_obj( &h_conn->obj ); - h_conn->obj.pfn_destroy( &h_conn->obj, NULL ); - - /* Invoke the user's callback. */ - if( pfn_cm_rej_cb ) - pfn_cm_rej_cb( p_cm_rej_rec ); - } - AL_EXIT(AL_DBG_CM); -} - - - -void -ual_cm_mra_cb( - IN ib_cm_mra_rec_t* p_cm_mra_rec ) -{ - ib_cm_handle_t h_conn; - ib_qp_handle_t h_qp; - - AL_ENTER(AL_DBG_CM); - - /* Convert the user's handles. */ - switch( p_cm_mra_rec->qp_type ) - { - case IB_QPT_RELIABLE_CONN: - case IB_QPT_UNRELIABLE_CONN: - h_qp = (ib_qp_handle_t)p_cm_mra_rec->qp_context; - p_cm_mra_rec->qp_context = h_qp->obj.context; - h_conn = ((al_conn_qp_t*)h_qp)->p_conn; - break; - - default: - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , ("Invalid qp_type.\n") ); - return; - } - - /* Call the application callback */ - h_conn->pfn_cm_mra_cb( p_cm_mra_rec ); - - AL_EXIT(AL_DBG_CM); -} - - - -void -ual_cm_lap_cb( - IN ib_cm_lap_rec_t* p_cm_lap_rec ) -{ - ib_cm_handle_t h_conn; - ib_qp_handle_t h_qp; - - AL_ENTER(AL_DBG_CM); - - /* Convert the user's handles. */ - switch( p_cm_lap_rec->qp_type ) - { - case IB_QPT_RELIABLE_CONN: - case IB_QPT_UNRELIABLE_CONN: - h_qp = (ib_qp_handle_t)p_cm_lap_rec->qp_context; - p_cm_lap_rec->qp_context = h_qp->obj.context; - h_conn = ((al_conn_qp_t*)h_qp)->p_conn; - break; - - default: - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , ("Invalid qp_type.\n") ); - return; - } - - /* Store & replace the kernel handle */ - h_conn->obj.hdl = (uint64_t)p_cm_lap_rec->h_cm_lap; - p_cm_lap_rec->h_cm_lap = h_conn; - - /* Reference the connection until the user calls ib_cm_apr. */ - ref_al_obj( &h_conn->obj ); - - /* Call the application callback */ - h_conn->pfn_cm_lap_cb( p_cm_lap_rec ); - - AL_EXIT(AL_DBG_CM); -} - - - -void -ual_cm_apr_cb( - IN ib_cm_apr_rec_t* p_cm_apr_rec ) -{ - ib_cm_handle_t h_conn; - ib_qp_handle_t h_qp; - - AL_ENTER(AL_DBG_CM); - - /* Convert the user's handles. */ - switch( p_cm_apr_rec->qp_type ) - { - case IB_QPT_RELIABLE_CONN: - case IB_QPT_UNRELIABLE_CONN: - h_qp = (ib_qp_handle_t)p_cm_apr_rec->qp_context; - p_cm_apr_rec->qp_context = h_qp->obj.context; - h_conn = ((al_conn_qp_t*)h_qp)->p_conn; - break; - - default: - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , ("Invalid qp_type.\n") ); - return; - } - - /* Call the application callback */ - h_conn->pfn_cm_apr_cb( p_cm_apr_rec ); - - AL_EXIT(AL_DBG_CM); -} - - - -void -ual_cm_dreq_cb( - IN ib_cm_dreq_rec_t* p_cm_dreq_rec ) -{ - ib_cm_handle_t h_conn; - ib_qp_handle_t h_qp; - - AL_ENTER(AL_DBG_CM); - - /* Convert the user's handles. */ - switch( p_cm_dreq_rec->qp_type ) - { - case IB_QPT_RELIABLE_CONN: - case IB_QPT_UNRELIABLE_CONN: - h_qp = (ib_qp_handle_t)p_cm_dreq_rec->qp_context; - p_cm_dreq_rec->qp_context = h_qp->obj.context; - h_conn = ((al_conn_qp_t*)h_qp)->p_conn; - break; - - default: - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , ("Invalid qp_type.\n") ); - return; - } - - /* Store the kernel reply handle. */ - h_conn->obj.hdl = (uint64_t)p_cm_dreq_rec->h_cm_dreq; - p_cm_dreq_rec->h_cm_dreq = h_conn; - - /* Reference the connection until the user calls ib_cm_drep. */ - ref_al_obj( &h_conn->obj ); - - /* Call the application callback */ - h_conn->pfn_cm_dreq_cb( p_cm_dreq_rec ); - AL_EXIT(AL_DBG_CM); -} - - - -void -ual_cm_drep_cb( - IN ib_cm_drep_rec_t* p_cm_drep_rec ) -{ - ib_cm_handle_t h_conn; - ib_qp_handle_t h_qp; - ib_pfn_cm_drep_cb_t pfn_cm_drep_cb; - - AL_ENTER(AL_DBG_CM); - - /* Convert the user's handles. */ - switch( p_cm_drep_rec->qp_type ) - { - case IB_QPT_RELIABLE_CONN: - case IB_QPT_UNRELIABLE_CONN: - h_qp = (ib_qp_handle_t)p_cm_drep_rec->qp_context; - p_cm_drep_rec->qp_context = h_qp->obj.context; - h_conn = ((al_conn_qp_t*)h_qp)->p_conn; - break; - - default: - AL_PRINT(TRACE_LEVEL_ERROR ,AL_DBG_ERROR , ("Invalid qp_type.\n") ); - return; - } - - /* TODO: Handle timewait. */ - cm_reset_qp( h_qp, 0 ); - - /* - * We are done with this connection. After we call the user back, - * they can close AL, or do one of any number of difficult things - * to deal with, so we need to handle the case where the connection - * structure may be destroyed. Get a copy of the user's callback. - */ - pfn_cm_drep_cb = h_conn->pfn_cm_drep_cb; - ref_al_obj( &h_conn->obj ); - h_conn->obj.pfn_destroy( &h_conn->obj, NULL ); - - /* Invoke the user's callback. */ - pfn_cm_drep_cb( p_cm_drep_rec ); - - AL_EXIT(AL_DBG_CM); -} diff --git a/core/al/user/ual_cm.h b/core/al/user/ual_cm.h deleted file mode 100644 index dc81a471..00000000 --- a/core/al/user/ual_cm.h +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2005 SilverStorm Technologies. All rights reserved. - * Copyright (c) 1996-2003 Intel Corporation. All rights reserved. - * - * This software is available to you under the OpenIB.org BSD license - * below: - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * $Id$ - */ - -#if !defined(__IB_UAL_CM_H__) -#define __IB_UAL_CM_H__ - -#include "al_common.h" - - - -/* - * Used to store user's callback and other connection information. - */ -typedef struct _al_listen -{ - /* CM info is stored as a child to AL. */ - al_obj_t obj; /* must be first */ - - /* Callback information. */ - ib_pfn_cm_req_cb_t pfn_cm_req_cb; - ib_pfn_cm_mra_cb_t pfn_cm_mra_cb; - ib_pfn_cm_rej_cb_t pfn_cm_rej_cb; - - ib_pfn_listen_err_cb_t pfn_listen_err_cb; - - /* valid for ud qp_type only */ - const void *sidr_context; - -} al_listen_t; - - - -/* - * Connection request information. Used only during connection - * establishment. - */ -typedef struct _conn_req_t -{ - /* Path information needed to transiton the QP when connecting. */ - ib_path_rec_t path_rec; - ib_path_rec_t alt_path_rec; - - /* QP modification parameters provided by the kernel CM. */ - ib_qp_mod_t qp_mod_rtr; - ib_qp_mod_t qp_mod_rts; - uint32_t timeout_ms; - - /* Callback information needed only when connecting. */ - ib_pfn_cm_req_cb_t pfn_cm_req_cb; - ib_pfn_cm_rep_cb_t pfn_cm_rep_cb; - ib_pfn_cm_rtu_cb_t pfn_cm_rtu_cb; - -} conn_req_t; - - - -/* - * Used to track connections. - */ -typedef struct _al_conn -{ - /* CM info is stored as a child to AL. */ - al_obj_t obj; /* must be first */ - - ib_al_handle_t h_al; - cl_list_item_t al_item; - ib_qp_handle_t h_qp; - - /* Information needed to establish the connection. */ - conn_req_t *p_conn_req; - - /* valid for ud qp_type only */ - const void *sidr_context; - - /* Callback information needed after sending the RTU. */ - ib_pfn_cm_rej_cb_t pfn_cm_rej_cb; - ib_pfn_cm_mra_cb_t pfn_cm_mra_cb; - - ib_pfn_cm_lap_cb_t pfn_cm_lap_cb; - ib_pfn_cm_apr_cb_t pfn_cm_apr_cb; - - ib_pfn_cm_dreq_cb_t pfn_cm_dreq_cb; - ib_pfn_cm_drep_cb_t pfn_cm_drep_cb; - -} al_conn_t; - - - -void -ual_cm_req_cb( - IN ib_cm_req_rec_t* p_cm_req_rec, - IN ib_qp_mod_t* p_qp_rtr, - IN ib_qp_mod_t* p_qp_rts, - IN uint32_t timeout_ms ); - -void -ual_cm_rep_cb( - IN ib_cm_rep_rec_t* p_cm_rep_rec, - IN ib_qp_mod_t* p_qp_rtr, - IN ib_qp_mod_t* p_qp_rts ); - -void -ual_cm_rtu_cb( - IN ib_cm_rtu_rec_t* p_cm_rtu_rec ); - -void -ual_cm_rej_cb( - IN ib_cm_rej_rec_t* p_cm_rej_rec ); - -void -ual_cm_mra_cb( - IN ib_cm_mra_rec_t* p_cm_mra_rec ); - -void -ual_cm_lap_cb( - IN ib_cm_lap_rec_t* p_cm_lap_rec ); - -void -ual_cm_apr_cb( - IN ib_cm_apr_rec_t* p_cm_apr_rec ); - -void -ual_cm_dreq_cb( - IN ib_cm_dreq_rec_t* p_cm_dreq_rec ); - -void -ual_cm_drep_cb( - IN ib_cm_drep_rec_t* p_cm_drep_rec ); - -void -ual_listen_err_cb( - IN ib_listen_err_rec_t *p_listen_err_rec ); - - -#endif /* __IB_UAL_CM_H__ */