2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A#include <strings.h>
2N/A
2N/A#include <dapl.h>
2N/A#include <dapl_adapter_util.h>
2N/A#include <dapl_evd_util.h>
2N/A#include <dapl_cr_util.h>
2N/A#include <dapl_lmr_util.h>
2N/A#include <dapl_rmr_util.h>
2N/A#include <dapl_cookie.h>
2N/A#include <dapl_name_service.h>
2N/A#include <dapl_tavor_ibtf_impl.h>
2N/A
2N/A/* Function prototypes */
2N/Aextern DAT_RETURN dapls_tavor_wrid_init(ib_qp_handle_t);
2N/Aextern void dapls_tavor_wrid_cleanup(DAPL_EP *, ib_qp_handle_t);
2N/A
2N/Aint g_dapl_loopback_connection = 0;
2N/A
2N/A/*
2N/A * dapls_ib_connect
2N/A *
2N/A * Initiate a connection with the passive listener on another node
2N/A *
2N/A * Input:
2N/A * ep_handle,
2N/A * remote_ia_address,
2N/A * remote_conn_qual,
2N/A * prd_size size of private data and structure
2N/A * prd_prt pointer to private data structure
2N/A *
2N/A * Output:
2N/A * none
2N/A *
2N/A * Returns:
2N/A * DAT_SUCCESS
2N/A * DAT_INSUFFICIENT_RESOURCES
2N/A * DAT_INVALID_PARAMETER
2N/A *
2N/A */
2N/A
2N/ADAT_RETURN
2N/Adapls_ib_connect(IN DAT_EP_HANDLE ep_handle,
2N/A IN DAT_IA_ADDRESS_PTR remote_ia_address, IN DAT_CONN_QUAL remote_conn_qual,
2N/A IN DAT_COUNT prd_size, IN DAPL_PRIVATE *prd_ptr, IN DAT_TIMEOUT timeout)
2N/A{
2N/A dapl_ep_connect_t args;
2N/A DAPL_EP *ep_p = (DAPL_EP *)ep_handle;
2N/A struct sockaddr *s;
2N/A char addr_buf[64];
2N/A ib_gid_t dgid;
2N/A int retval;
2N/A struct sockaddr_in6 *v6addr;
2N/A struct sockaddr_in *v4addr;
2N/A dapl_ia_addr_t *sap;
2N/A
2N/A s = (struct sockaddr *)remote_ia_address;
2N/A dapl_dbg_log(DAPL_DBG_TYPE_CM,
2N/A "dapls_ib_connect: ep 0x%p\n"
2N/A " addr %s, conn_qual %016llu, ep_hkey %016llx\n"
2N/A " prd_size %d, timeout 0x%x\n",
2N/A ep_p, dapls_inet_ntop(s, addr_buf, 64), remote_conn_qual,
2N/A ep_p->qp_handle->ep_hkey, prd_size, timeout);
2N/A if (ep_p->qp_handle == NULL) {
2N/A dapl_dbg_log(DAPL_DBG_TYPE_ERR,
2N/A "dapls_ib_connect: ep 0x%p, addr %s, conn_qual %016llu, "
2N/A "qp_handle == NULL\n", ep_p, dapls_inet_ntop(s,
2N/A addr_buf, 64), remote_conn_qual);
2N/A return (DAT_INVALID_PARAMETER);
2N/A }
2N/A if (timeout == DAT_TIMEOUT_INFINITE) {
2N/A args.epc_timeout = 0;
2N/A } else {
2N/A args.epc_timeout = timeout;
2N/A }
2N/A /* resolve remote address to dgid */
2N/A retval = dapls_ns_lookup_address(ep_p->header.owner_ia,
2N/A remote_ia_address, timeout, &dgid);
2N/A if (retval == DAT_SUCCESS) {
2N/A args.epc_dgid = dgid;
2N/A } else if ((retval & DAT_SUBTYPE_MASK) ==
2N/A DAT_INVALID_ADDRESS_UNREACHABLE) {
2N/A /* let the kernel driver look up the dgid from ATS */
2N/A args.epc_dgid.gid_guid = 0ULL;
2N/A args.epc_dgid.gid_prefix = 0ULL;
2N/A } else {
2N/A return (retval);
2N/A }
2N/A args.epc_sid = remote_conn_qual;
2N/A args.epc_hkey = ep_p->qp_handle->ep_hkey;
2N/A sap = (dapl_ia_addr_t *)&args.epc_raddr_sadata;
2N/A /*
2N/A * filled in the remote_ia_address for consistent though
2N/A * not necessary when dapls_ns_lookup_address has resolved the dgid
2N/A */
2N/A switch (s->sa_family) {
2N/A case AF_INET:
2N/A /* LINTED: E_BAD_PTR_CAST_ALIGN */
2N/A v4addr = (struct sockaddr_in *)s;
2N/A sap->iad_v4pad[0] = 0;
2N/A sap->iad_v4pad[1] = 0;
2N/A sap->iad_v4pad[2] = 0;
2N/A sap->iad_v4 = v4addr->sin_addr;
2N/A break;
2N/A case AF_INET6:
2N/A /* LINTED: E_BAD_PTR_CAST_ALIGN */
2N/A v6addr = (struct sockaddr_in6 *)s;
2N/A sap->iad_v6 = v6addr->sin6_addr;
2N/A break;
2N/A }
2N/A
2N/A /* establish the hello message */
2N/A (void) dapl_os_memzero((void *)&prd_ptr->hello_msg,
2N/A sizeof (DAPL_HELLO_MSG));
2N/A /* on ATS leave the msg blank to avoid confusion to 3rd parties */
2N/A if ((args.epc_dgid.gid_guid | args.epc_dgid.gid_prefix)) {
2N/A prd_ptr->hello_msg.hi_checksum = DAPL_CHECKSUM;
2N/A prd_ptr->hello_msg.hi_clen = prd_size;
2N/A prd_ptr->hello_msg.hi_mid = 0;
2N/A prd_ptr->hello_msg.hi_vers = DAPL_HELLO_MSG_VERS;
2N/A
2N/A /* fill in local address */
2N/A s = (struct sockaddr *)
2N/A &ep_p->header.owner_ia->hca_ptr->hca_address;
2N/A prd_ptr->hello_msg.hi_ipv = (uint8_t)s->sa_family;
2N/A switch (s->sa_family) {
2N/A case AF_INET:
2N/A /* LINTED: E_BAD_PTR_CAST_ALIGN */
2N/A v4addr = (struct sockaddr_in *)s;
2N/A prd_ptr->hello_msg.hi_port = v4addr->sin_port;
2N/A prd_ptr->hello_msg.hi_v4ipaddr = v4addr->sin_addr;
2N/A break;
2N/A case AF_INET6:
2N/A /* LINTED: E_BAD_PTR_CAST_ALIGN */
2N/A v6addr = (struct sockaddr_in6 *)s;
2N/A prd_ptr->hello_msg.hi_port = v6addr->sin6_port;
2N/A prd_ptr->hello_msg.hi_v6ipaddr = v6addr->sin6_addr;
2N/A break;
2N/A default:
2N/A break; /* fall through */
2N/A }
2N/A }
2N/A if (prd_size > 0) {
2N/A (void) dapl_os_memcpy((void *)&args.epc_priv[0],
2N/A (void *)prd_ptr, sizeof (DAPL_PRIVATE));
2N/A } else {
2N/A (void) dapl_os_memcpy((void *)
2N/A &args.epc_priv[DAPL_CONSUMER_MAX_PRIVATE_DATA_SIZE],
2N/A (void *)&prd_ptr->hello_msg, sizeof (DAPL_HELLO_MSG));
2N/A }
2N/A args.epc_priv_sz = sizeof (DAPL_PRIVATE);
2N/A
2N/A retval = ioctl(ep_p->header.owner_ia->hca_ptr->ib_hca_handle->ia_fd,
2N/A DAPL_EP_CONNECT, &args);
2N/A if (retval != 0) {
2N/A dapl_dbg_log(DAPL_DBG_TYPE_ERR,
2N/A "dapls_ib_connect: connect failed %s, retval %d\n\n",
2N/A strerror(errno), retval);
2N/A return (dapls_convert_error(errno, retval));
2N/A }
2N/A
2N/A dapl_dbg_log(DAPL_DBG_TYPE_CM,
2N/A "dapls_ib_connect: connected to %s\n\n",
2N/A dapls_inet_ntop(s, addr_buf, 64));
2N/A return (DAT_SUCCESS);
2N/A}
2N/A
2N/A/*
2N/A * dapls_ib_disconnect
2N/A *
2N/A * Disconnect an EP
2N/A *
2N/A * Input:
2N/A * ep_handle,
2N/A * disconnect_flags
2N/A *
2N/A * Output:
2N/A * none
2N/A *
2N/A * Returns:
2N/A * DAT_SUCCESS
2N/A * DAT_INSUFFICIENT_RESOURCES
2N/A * DAT_INVALID_PARAMETER
2N/A *
2N/A */
2N/A/* ARGSUSED */
2N/ADAT_RETURN
2N/Adapls_ib_disconnect(IN DAPL_EP *ep_ptr,
2N/A IN DAT_CLOSE_FLAGS close_flags)
2N/A{
2N/A dapl_ep_disconnect_t args;
2N/A struct sockaddr *s;
2N/A char addr_buf[64];
2N/A int retval;
2N/A
2N/A if (ep_ptr->qp_handle == NULL) {
2N/A dapl_dbg_log(DAPL_DBG_TYPE_ERR,
2N/A "dapls_ib_disconnect: qp_handle == NULL\n");
2N/A return (DAT_INVALID_PARAMETER);
2N/A }
2N/A args.epd_hkey = ep_ptr->qp_handle->ep_hkey;
2N/A
2N/A retval = ioctl(ep_ptr->header.owner_ia->hca_ptr->ib_hca_handle->ia_fd,
2N/A DAPL_EP_DISCONNECT, &args);
2N/A /* no reason for disconnect to fail so transition the state */
2N/A ep_ptr->qp_state = IBT_STATE_ERROR;
2N/A
2N/A if (retval != 0) {
2N/A dapl_dbg_log(DAPL_DBG_TYPE_ERR,
2N/A "dapls_ib_disconnect: disconnect failed %s\n",
2N/A strerror(errno));
2N/A return (dapls_convert_error(errno, retval));
2N/A }
2N/A s = (struct sockaddr *)ep_ptr->param.remote_ia_address_ptr;
2N/A dapl_dbg_log(DAPL_DBG_TYPE_CM,
2N/A "dapls_ib_disconnect: disconnected from %s, conn_qual %016llu\n",
2N/A dapls_inet_ntop(s, addr_buf, 64), ep_ptr->param.remote_port_qual);
2N/A return (DAT_SUCCESS);
2N/A}
2N/A
2N/A
2N/A/*
2N/A * dapls_ib_connected
2N/A *
2N/A * transition qp_state to IBT_STATE_RTS
2N/A *
2N/A */
2N/Avoid
2N/Adapls_ib_connected(IN DAPL_EP *ep_ptr)
2N/A{
2N/A ep_ptr->qp_state = IBT_STATE_RTS;
2N/A}
2N/A
2N/A
2N/A/*
2N/A * dapls_ib_disconnect_clean
2N/A *
2N/A * transition qp_state to IBT_STATE_ERROR.
2N/A * abort connection if necessary.
2N/A *
2N/A * Input:
2N/A * ep_ptr DAPL_EP
2N/A *
2N/A * Output:
2N/A * none
2N/A *
2N/A * Returns:
2N/A * void
2N/A *
2N/A */
2N/A/* ARGSUSED */
2N/Avoid
2N/Adapls_ib_disconnect_clean(IN DAPL_EP *ep_ptr, IN DAT_BOOLEAN active,
2N/A IN const ib_cm_events_t ib_cm_event)
2N/A{
2N/A switch (ib_cm_event) {
2N/A case IB_CME_CONNECTED:
2N/A case IB_CME_CONNECTION_REQUEST_PENDING:
2N/A case IB_CME_CONNECTION_REQUEST_PENDING_PRIVATE_DATA:
2N/A (void) dapls_ib_disconnect(ep_ptr, DAT_CLOSE_ABRUPT_FLAG);
2N/A /* FALLTHROUGH */
2N/A case IB_CME_DESTINATION_REJECT:
2N/A case IB_CME_DESTINATION_REJECT_PRIVATE_DATA:
2N/A case IB_CME_DESTINATION_UNREACHABLE:
2N/A case IB_CME_TOO_MANY_CONNECTION_REQUESTS:
2N/A case IB_CME_LOCAL_FAILURE:
2N/A case IB_CME_TIMED_OUT:
2N/A case IB_CME_DISCONNECTED_ON_LINK_DOWN:
2N/A ep_ptr->qp_state = IBT_STATE_ERROR;
2N/A }
2N/A}
2N/A
2N/A
2N/A/*
2N/A * dapls_ib_reinit_ep
2N/A *
2N/A * Move the QP to INIT state again.
2N/A *
2N/A * Input:
2N/A * ep_ptr DAPL_EP
2N/A *
2N/A * Output:
2N/A * none
2N/A *
2N/A * Returns:
2N/A * void
2N/A *
2N/A */
2N/Avoid
2N/Adapls_ib_reinit_ep(IN DAPL_EP *ep_ptr)
2N/A{
2N/A dapl_ep_reinit_t reinit_args;
2N/A ib_hca_handle_t hca_hndl;
2N/A ib_qp_handle_t qp_p;
2N/A char addr_buf[64];
2N/A int retval;
2N/A
2N/A hca_hndl = ep_ptr->header.owner_ia->hca_ptr->ib_hca_handle;
2N/A qp_p = ep_ptr->qp_handle;
2N/A
2N/A if (qp_p == NULL) {
2N/A dapl_dbg_log(DAPL_DBG_TYPE_ERR,
2N/A "dapls_ib_reinit: qp_handle == NULL\n");
2N/A return;
2N/A }
2N/A /*
2N/A * Do all the work request cleanup processing right away
2N/A * no one should really be doing any operation on this
2N/A * qp (we are not threadsafe)...
2N/A */
2N/A dapls_tavor_wrid_cleanup(ep_ptr, qp_p);
2N/A
2N/A reinit_args.epri_hkey = qp_p->ep_hkey;
2N/A if (ioctl(hca_hndl->ia_fd, DAPL_EP_REINIT, &reinit_args) != 0) {
2N/A dapl_dbg_log(DAPL_DBG_TYPE_ERR,
2N/A "dapls_ib_reinit: reinit failed %s\n",
2N/A strerror(errno));
2N/A return;
2N/A }
2N/A
2N/A qp_p->qp_sq_lastwqeaddr = NULL;
2N/A qp_p->qp_rq_lastwqeaddr = NULL;
2N/A
2N/A /*
2N/A * Setup data structure for work request processing
2N/A */
2N/A retval = dapls_tavor_wrid_init(qp_p);
2N/A if (retval != DAT_SUCCESS) {
2N/A /*
2N/A * we failed to create data structures for work request
2N/A * processing. Lets unmap and leave, the qp will get
2N/A * cleaned when ep gets destroyed - the ep is unusable
2N/A * in this state.
2N/A */
2N/A if (munmap((void *)qp_p->qp_addr, qp_p->qp_map_len) < 0) {
2N/A dapl_dbg_log(DAPL_DBG_TYPE_ERR,
2N/A "qp_free: munmap failed(%d)\n", errno);
2N/A }
2N/A qp_p->qp_addr = NULL;
2N/A dapl_dbg_log(DAPL_DBG_TYPE_CM,
2N/A "dapls_ib_reinit: wrid_init failed %d\n", retval);
2N/A return;
2N/A }
2N/A
2N/A /* we have a new ep and it is in the init state */
2N/A ep_ptr->qp_state = IBT_STATE_INIT;
2N/A
2N/A dapl_dbg_log(DAPL_DBG_TYPE_CM,
2N/A "dapls_ib_reinit: successful, ia_address %s, conn_qual %016llu\n",
2N/A dapls_inet_ntop((struct sockaddr *)ep_ptr->param.
2N/A remote_ia_address_ptr, addr_buf, 64),
2N/A ep_ptr->param.remote_port_qual);
2N/A}
2N/A
2N/A
2N/A/*
2N/A * dapl_ib_setup_conn_listener
2N/A *
2N/A * Have the CM set up a connection listener.
2N/A *
2N/A * Input:
2N/A * ibm_hca_handle HCA handle
2N/A * qp_handle QP handle
2N/A *
2N/A * Output:
2N/A * none
2N/A *
2N/A * Returns:
2N/A * DAT_SUCCESS
2N/A * DAT_INSUFFICIENT_RESOURCES
2N/A * DAT_INVALID_PARAMETER
2N/A *
2N/A */
2N/ADAT_RETURN
2N/Adapls_ib_setup_conn_listener(IN DAPL_IA *ia_ptr,
2N/A IN DAT_UINT64 ServiceID, IN DAPL_SP *sp_ptr)
2N/A{
2N/A ib_hca_handle_t hca_hdl = ia_ptr->hca_ptr->ib_hca_handle;
2N/A struct dapls_ib_cm_srvc_handle *srvc_hdl;
2N/A dapl_service_register_t args;
2N/A struct sockaddr *s;
2N/A char addr_buf[64];
2N/A DAPL_EVD *evd_p = (DAPL_EVD *)sp_ptr->evd_handle;
2N/A int retval;
2N/A
2N/A if (hca_hdl == NULL) {
2N/A dapl_dbg_log(DAPL_DBG_TYPE_ERR,
2N/A "setup_conn_listener: hca_handle == NULL\n");
2N/A return (DAT_INVALID_PARAMETER);
2N/A }
2N/A if (evd_p == NULL) {
2N/A dapl_dbg_log(DAPL_DBG_TYPE_ERR,
2N/A "setup_conn_listener: evd_p == NULL\n");
2N/A return (DAT_INVALID_PARAMETER);
2N/A }
2N/A srvc_hdl = (struct dapls_ib_cm_srvc_handle *)
2N/A dapl_os_alloc(sizeof (*srvc_hdl));
2N/A if (srvc_hdl == NULL) {
2N/A dapl_dbg_log(DAPL_DBG_TYPE_ERR,
2N/A "setup_conn_listener: srvc_handle == NULL\n");
2N/A return (DAT_INSUFFICIENT_RESOURCES);
2N/A }
2N/A
2N/A args.sr_sid = ServiceID;
2N/A args.sr_evd_hkey = evd_p->ib_cq_handle->evd_hkey;
2N/A args.sr_sp_cookie = (uintptr_t)sp_ptr;
2N/A
2N/A retval = ioctl(hca_hdl->ia_fd, DAPL_SERVICE_REGISTER, &args);
2N/A if (retval != 0) {
2N/A dapl_dbg_log(DAPL_DBG_TYPE_ERR,
2N/A "setup_conn_listener: register failed %s\n",
2N/A strerror(errno));
2N/A dapl_os_free(srvc_hdl, sizeof (*srvc_hdl));
2N/A return (dapls_convert_error(errno, retval));
2N/A }
2N/A srvc_hdl->sv_sp_hkey = args.sr_sp_hkey;
2N/A sp_ptr->cm_srvc_handle = srvc_hdl;
2N/A sp_ptr->conn_qual = args.sr_retsid;
2N/A
2N/A s = (struct sockaddr *)&ia_ptr->hca_ptr->hca_address;
2N/A dapl_dbg_log(DAPL_DBG_TYPE_CM,
2N/A "setup_conn_listener: listening on ia_address %s, "
2N/A "conn_qual %016llu\n\n", dapls_inet_ntop(s, addr_buf, 64),
2N/A sp_ptr->conn_qual);
2N/A return (DAT_SUCCESS);
2N/A}
2N/A
2N/A/*
2N/A * dapl_ib_remove_conn_listener
2N/A *
2N/A * Have the CM remove a connection listener.
2N/A *
2N/A * Input:
2N/A * ia_handle IA handle
2N/A * ServiceID IB Channel Service ID
2N/A *
2N/A * Output:
2N/A * none
2N/A *
2N/A * Returns:
2N/A * DAT_SUCCESS
2N/A * DAT_INVALID_PARAMETER
2N/A *
2N/A */
2N/ADAT_RETURN
2N/Adapls_ib_remove_conn_listener(IN DAPL_IA *ia_ptr, IN DAPL_SP *sp_ptr)
2N/A{
2N/A ib_hca_handle_t hca_hdl = ia_ptr->hca_ptr->ib_hca_handle;
2N/A struct dapls_ib_cm_srvc_handle *srvc_hdl;
2N/A dapl_service_deregister_t args;
2N/A struct sockaddr *s;
2N/A char addr_buf[64];
2N/A int retval;
2N/A
2N/A if (hca_hdl == NULL) {
2N/A dapl_dbg_log(DAPL_DBG_TYPE_ERR,
2N/A "remove_conn_listener: hca_handle == NULL\n");
2N/A return (DAT_INVALID_PARAMETER);
2N/A }
2N/A srvc_hdl = (struct dapls_ib_cm_srvc_handle *)sp_ptr->
2N/A cm_srvc_handle;
2N/A
2N/A args.sdr_sp_hkey = srvc_hdl->sv_sp_hkey;
2N/A retval = ioctl(hca_hdl->ia_fd, DAPL_SERVICE_DEREGISTER, &args);
2N/A if (retval != 0) {
2N/A dapl_dbg_log(DAPL_DBG_TYPE_ERR,
2N/A "remove_conn_listener: deregister failed %s\n",
2N/A strerror(errno));
2N/A return (dapls_convert_error(errno, retval));
2N/A }
2N/A dapl_os_free(srvc_hdl, sizeof (*srvc_hdl));
2N/A sp_ptr->cm_srvc_handle = NULL;
2N/A
2N/A s = (struct sockaddr *)&ia_ptr->hca_ptr->hca_address;
2N/A dapl_dbg_log(DAPL_DBG_TYPE_CM,
2N/A "remove_conn_listener: successful, ia_address %s, "
2N/A "conn_qual %016llu\n\n", dapls_inet_ntop(s, addr_buf, 64),
2N/A sp_ptr->conn_qual);
2N/A return (DAT_SUCCESS);
2N/A}
2N/A
2N/A/*
2N/A * dapls_ib_reject_connection
2N/A *
2N/A * Perform necessary steps to reject a connection
2N/A *
2N/A * Input:
2N/A * cr_handle
2N/A *
2N/A * Output:
2N/A * none
2N/A *
2N/A * Returns:
2N/A * DAT_SUCCESS
2N/A * DAT_INSUFFICIENT_RESOURCES
2N/A * DAT_INVALID_PARAMETER
2N/A *
2N/A */
2N/ADAT_RETURN
2N/Adapls_ib_reject_connection(IN ib_cm_handle_t cm_handle,
2N/A IN int reject_reason, IN DAPL_SP *sp_ptr)
2N/A{
2N/A dapl_cr_reject_t args;
2N/A int retval;
2N/A
2N/A args.crr_reason = reject_reason;
2N/A args.crr_bkl_cookie = (uint64_t)cm_handle;
2N/A args.crr_sp_hkey = sp_ptr->cm_srvc_handle->sv_sp_hkey;
2N/A
2N/A dapl_dbg_log(DAPL_DBG_TYPE_CM,
2N/A "dapls_ib_reject: fd %d, sp_hkey %016llx, bkl_index 0x%llx\n",
2N/A sp_ptr->header.owner_ia->hca_ptr->ib_hca_handle->ia_fd,
2N/A args.crr_sp_hkey, args.crr_bkl_cookie);
2N/A
2N/A retval = ioctl(sp_ptr->header.owner_ia->hca_ptr->ib_hca_handle->ia_fd,
2N/A DAPL_CR_REJECT, &args);
2N/A if (retval != 0) {
2N/A dapl_dbg_log(DAPL_DBG_TYPE_ERR,
2N/A "dapls_ib_reject: reject failed %s\n",
2N/A strerror(errno));
2N/A return (dapls_convert_error(errno, retval));
2N/A }
2N/A return (DAT_SUCCESS);
2N/A}
2N/A
2N/A
2N/A/*
2N/A * dapls_ib_accept_connection
2N/A *
2N/A * Perform necessary steps to accept a connection
2N/A *
2N/A * Input:
2N/A * cr_handle
2N/A * ep_handle
2N/A * private_data_size
2N/A * private_data
2N/A *
2N/A * Output:
2N/A * none
2N/A *
2N/A * Returns:
2N/A * DAT_SUCCESS
2N/A * DAT_INSUFFICIENT_RESOURCES
2N/A * DAT_INVALID_PARAMETER
2N/A *
2N/A */
2N/ADAT_RETURN
2N/Adapls_ib_accept_connection(IN DAT_CR_HANDLE cr_handle,
2N/A IN DAT_EP_HANDLE ep_handle, IN DAPL_PRIVATE *prd_ptr)
2N/A{
2N/A DAPL_EP *ep_p = (DAPL_EP *)ep_handle;
2N/A DAPL_CR *cr_p = (DAPL_CR *)cr_handle;
2N/A dapl_cr_accept_t args;
2N/A int retval;
2N/A
2N/A /* check if ep is valid */
2N/A if (ep_p->qp_handle == NULL) {
2N/A dapl_dbg_log(DAPL_DBG_TYPE_ERR,
2N/A "dapls_ib_accept: qp_handle == NULL\n");
2N/A return (DAT_INVALID_PARAMETER);
2N/A }
2N/A
2N/A dapl_dbg_log(DAPL_DBG_TYPE_CM,
2N/A "dapls_ib_accept: fd %d, sp_hkey %016llx, "
2N/A "bkl_index 0x%llx, ep_hkey %016llx\n",
2N/A cr_p->header.owner_ia->hca_ptr->ib_hca_handle->ia_fd,
2N/A cr_p->sp_ptr->cm_srvc_handle->sv_sp_hkey,
2N/A (uint64_t)cr_p->ib_cm_handle, ep_p->qp_handle->ep_hkey);
2N/A
2N/A args.cra_bkl_cookie = (uint64_t)cr_p->ib_cm_handle;
2N/A args.cra_sp_hkey = cr_p->sp_ptr->cm_srvc_handle->sv_sp_hkey;
2N/A args.cra_ep_hkey = ep_p->qp_handle->ep_hkey;
2N/A
2N/A args.cra_priv_sz = IB_MAX_REP_PDATA_SIZE;
2N/A bcopy(prd_ptr, args.cra_priv, IB_MAX_REP_PDATA_SIZE);
2N/A
2N/A retval = ioctl(cr_p->header.owner_ia->hca_ptr->ib_hca_handle->ia_fd,
2N/A DAPL_CR_ACCEPT, &args);
2N/A if (retval != 0) {
2N/A ep_p->qp_state = IBT_STATE_ERROR;
2N/A dapl_dbg_log(DAPL_DBG_TYPE_ERR,
2N/A "dapls_ib_accept: accept failed %s\n",
2N/A strerror(errno));
2N/A return (dapls_convert_error(errno, retval));
2N/A }
2N/A return (DAT_SUCCESS);
2N/A}
2N/A/*
2N/A * dapls_ib_cm_remote_addr
2N/A *
2N/A * Obtain the remote IP address given a connection
2N/A *
2N/A * Input:
2N/A * cr_handle
2N/A * private data structure handle (only for IBHOSTS_NAMING)
2N/A *
2N/A * Output:
2N/A * remote_ia_address: where to place the remote address
2N/A *
2N/A * Returns:
2N/A * DAT_SUCCESS
2N/A * DAT_INSUFFICIENT_RESOURCES
2N/A * DAT_INVALID_PARAMETER
2N/A *
2N/A */
2N/A/* ARGSUSED */
2N/ADAT_RETURN
2N/Adapls_ib_cm_remote_addr(
2N/A IN DAT_HANDLE dat_handle,
2N/A IN DAPL_PRIVATE *prd_ptr,
2N/A OUT DAT_SOCK_ADDR6 *remote_ia_address)
2N/A{
2N/A return (DAT_SUCCESS);
2N/A}
2N/A
2N/A
2N/A/*
2N/A * dapls_ib_handoff_connection
2N/A *
2N/A * handoff connection to a different qualifier
2N/A *
2N/A * Input:
2N/A * cr_ptr
2N/A * cr_handoff
2N/A *
2N/A * Output:
2N/A * none
2N/A *
2N/A * Returns:
2N/A * DAT_SUCCESS
2N/A * DAT_INSUFFICIENT_RESOURCES
2N/A * DAT_INVALID_PARAMETER
2N/A *
2N/A */
2N/ADAT_RETURN
2N/Adapls_ib_handoff_connection(IN DAPL_CR *cr_ptr, IN DAT_CONN_QUAL cr_handoff)
2N/A{
2N/A dapl_cr_handoff_t args;
2N/A int retval;
2N/A
2N/A dapl_dbg_log(DAPL_DBG_TYPE_CM,
2N/A "dapls_ib_handoff: fd %d, sp_hkey %016llx, "
2N/A "bkl_index 0x%llx conn_qual %llu\n",
2N/A cr_ptr->header.owner_ia->hca_ptr->ib_hca_handle->ia_fd,
2N/A cr_ptr->sp_ptr->cm_srvc_handle->sv_sp_hkey,
2N/A (uint64_t)cr_ptr->ib_cm_handle, cr_handoff);
2N/A
2N/A args.crh_bkl_cookie = (uint64_t)cr_ptr->ib_cm_handle;
2N/A args.crh_sp_hkey = cr_ptr->sp_ptr->cm_srvc_handle->sv_sp_hkey;
2N/A args.crh_conn_qual = cr_handoff;
2N/A
2N/A retval = ioctl(cr_ptr->header.owner_ia->hca_ptr->ib_hca_handle->ia_fd,
2N/A DAPL_CR_HANDOFF, &args);
2N/A if (retval != 0) {
2N/A dapl_dbg_log(DAPL_DBG_TYPE_ERR,
2N/A "dapls_ib_handoff: failed %s\n", strerror(errno));
2N/A return (dapls_convert_error(errno, retval));
2N/A }
2N/A return (DAT_SUCCESS);
2N/A}