dapl_tavor_ibtf_cm.c revision 2
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <strings.h>
#include <dapl.h>
#include <dapl_adapter_util.h>
#include <dapl_evd_util.h>
#include <dapl_cr_util.h>
#include <dapl_lmr_util.h>
#include <dapl_rmr_util.h>
#include <dapl_cookie.h>
#include <dapl_name_service.h>
#include <dapl_tavor_ibtf_impl.h>
/* Function prototypes */
int g_dapl_loopback_connection = 0;
/*
* dapls_ib_connect
*
* Initiate a connection with the passive listener on another node
*
* Input:
* ep_handle,
* remote_ia_address,
* remote_conn_qual,
* prd_size size of private data and structure
* prd_prt pointer to private data structure
*
* Output:
* none
*
* Returns:
* DAT_SUCCESS
* DAT_INSUFFICIENT_RESOURCES
* DAT_INVALID_PARAMETER
*
*/
{
struct sockaddr *s;
char addr_buf[64];
int retval;
struct sockaddr_in6 *v6addr;
struct sockaddr_in *v4addr;
s = (struct sockaddr *)remote_ia_address;
"dapls_ib_connect: ep 0x%p\n"
" addr %s, conn_qual %016llu, ep_hkey %016llx\n"
" prd_size %d, timeout 0x%x\n",
"dapls_ib_connect: ep 0x%p, addr %s, conn_qual %016llu, "
return (DAT_INVALID_PARAMETER);
}
if (timeout == DAT_TIMEOUT_INFINITE) {
args.epc_timeout = 0;
} else {
}
/* resolve remote address to dgid */
if (retval == DAT_SUCCESS) {
} else if ((retval & DAT_SUBTYPE_MASK) ==
/* let the kernel driver look up the dgid from ATS */
} else {
return (retval);
}
/*
* filled in the remote_ia_address for consistent though
* not necessary when dapls_ns_lookup_address has resolved the dgid
*/
switch (s->sa_family) {
case AF_INET:
/* LINTED: E_BAD_PTR_CAST_ALIGN */
v4addr = (struct sockaddr_in *)s;
break;
case AF_INET6:
/* LINTED: E_BAD_PTR_CAST_ALIGN */
v6addr = (struct sockaddr_in6 *)s;
break;
}
/* establish the hello message */
sizeof (DAPL_HELLO_MSG));
/* on ATS leave the msg blank to avoid confusion to 3rd parties */
/* fill in local address */
s = (struct sockaddr *)
switch (s->sa_family) {
case AF_INET:
/* LINTED: E_BAD_PTR_CAST_ALIGN */
v4addr = (struct sockaddr_in *)s;
break;
case AF_INET6:
/* LINTED: E_BAD_PTR_CAST_ALIGN */
v6addr = (struct sockaddr_in6 *)s;
break;
default:
break; /* fall through */
}
}
if (prd_size > 0) {
(void *)prd_ptr, sizeof (DAPL_PRIVATE));
} else {
(void) dapl_os_memcpy((void *)
}
DAPL_EP_CONNECT, &args);
if (retval != 0) {
"dapls_ib_connect: connect failed %s, retval %d\n\n",
}
"dapls_ib_connect: connected to %s\n\n",
return (DAT_SUCCESS);
}
/*
* dapls_ib_disconnect
*
* Disconnect an EP
*
* Input:
* ep_handle,
* disconnect_flags
*
* Output:
* none
*
* Returns:
* DAT_SUCCESS
* DAT_INSUFFICIENT_RESOURCES
* DAT_INVALID_PARAMETER
*
*/
/* ARGSUSED */
{
struct sockaddr *s;
char addr_buf[64];
int retval;
"dapls_ib_disconnect: qp_handle == NULL\n");
return (DAT_INVALID_PARAMETER);
}
/* no reason for disconnect to fail so transition the state */
if (retval != 0) {
"dapls_ib_disconnect: disconnect failed %s\n",
}
"dapls_ib_disconnect: disconnected from %s, conn_qual %016llu\n",
return (DAT_SUCCESS);
}
/*
* dapls_ib_connected
*
* transition qp_state to IBT_STATE_RTS
*
*/
void
{
}
/*
* dapls_ib_disconnect_clean
*
* transition qp_state to IBT_STATE_ERROR.
* abort connection if necessary.
*
* Input:
* ep_ptr DAPL_EP
*
* Output:
* none
*
* Returns:
* void
*
*/
/* ARGSUSED */
void
{
switch (ib_cm_event) {
case IB_CME_CONNECTED:
/* FALLTHROUGH */
case IB_CME_LOCAL_FAILURE:
case IB_CME_TIMED_OUT:
}
}
/*
* dapls_ib_reinit_ep
*
* Move the QP to INIT state again.
*
* Input:
* ep_ptr DAPL_EP
*
* Output:
* none
*
* Returns:
* void
*
*/
void
{
char addr_buf[64];
int retval;
"dapls_ib_reinit: qp_handle == NULL\n");
return;
}
/*
* Do all the work request cleanup processing right away
* no one should really be doing any operation on this
* qp (we are not threadsafe)...
*/
"dapls_ib_reinit: reinit failed %s\n",
return;
}
/*
* Setup data structure for work request processing
*/
if (retval != DAT_SUCCESS) {
/*
* we failed to create data structures for work request
* processing. Lets unmap and leave, the qp will get
* cleaned when ep gets destroyed - the ep is unusable
* in this state.
*/
"qp_free: munmap failed(%d)\n", errno);
}
"dapls_ib_reinit: wrid_init failed %d\n", retval);
return;
}
/* we have a new ep and it is in the init state */
"dapls_ib_reinit: successful, ia_address %s, conn_qual %016llu\n",
}
/*
* dapl_ib_setup_conn_listener
*
* Have the CM set up a connection listener.
*
* Input:
* ibm_hca_handle HCA handle
* qp_handle QP handle
*
* Output:
* none
*
* Returns:
* DAT_SUCCESS
* DAT_INSUFFICIENT_RESOURCES
* DAT_INVALID_PARAMETER
*
*/
{
struct dapls_ib_cm_srvc_handle *srvc_hdl;
struct sockaddr *s;
char addr_buf[64];
int retval;
"setup_conn_listener: hca_handle == NULL\n");
return (DAT_INVALID_PARAMETER);
}
"setup_conn_listener: evd_p == NULL\n");
return (DAT_INVALID_PARAMETER);
}
srvc_hdl = (struct dapls_ib_cm_srvc_handle *)
dapl_os_alloc(sizeof (*srvc_hdl));
"setup_conn_listener: srvc_handle == NULL\n");
return (DAT_INSUFFICIENT_RESOURCES);
}
if (retval != 0) {
"setup_conn_listener: register failed %s\n",
}
"setup_conn_listener: listening on ia_address %s, "
return (DAT_SUCCESS);
}
/*
* dapl_ib_remove_conn_listener
*
* Have the CM remove a connection listener.
*
* Input:
* ia_handle IA handle
* ServiceID IB Channel Service ID
*
* Output:
* none
*
* Returns:
* DAT_SUCCESS
* DAT_INVALID_PARAMETER
*
*/
{
struct dapls_ib_cm_srvc_handle *srvc_hdl;
struct sockaddr *s;
char addr_buf[64];
int retval;
"remove_conn_listener: hca_handle == NULL\n");
return (DAT_INVALID_PARAMETER);
}
if (retval != 0) {
"remove_conn_listener: deregister failed %s\n",
}
"remove_conn_listener: successful, ia_address %s, "
return (DAT_SUCCESS);
}
/*
* dapls_ib_reject_connection
*
* Perform necessary steps to reject a connection
*
* Input:
* cr_handle
*
* Output:
* none
*
* Returns:
* DAT_SUCCESS
* DAT_INSUFFICIENT_RESOURCES
* DAT_INVALID_PARAMETER
*
*/
{
int retval;
"dapls_ib_reject: fd %d, sp_hkey %016llx, bkl_index 0x%llx\n",
DAPL_CR_REJECT, &args);
if (retval != 0) {
"dapls_ib_reject: reject failed %s\n",
}
return (DAT_SUCCESS);
}
/*
* dapls_ib_accept_connection
*
* Perform necessary steps to accept a connection
*
* Input:
* cr_handle
* ep_handle
* private_data_size
* private_data
*
* Output:
* none
*
* Returns:
* DAT_SUCCESS
* DAT_INSUFFICIENT_RESOURCES
* DAT_INVALID_PARAMETER
*
*/
{
int retval;
/* check if ep is valid */
"dapls_ib_accept: qp_handle == NULL\n");
return (DAT_INVALID_PARAMETER);
}
"dapls_ib_accept: fd %d, sp_hkey %016llx, "
"bkl_index 0x%llx, ep_hkey %016llx\n",
DAPL_CR_ACCEPT, &args);
if (retval != 0) {
"dapls_ib_accept: accept failed %s\n",
}
return (DAT_SUCCESS);
}
/*
* dapls_ib_cm_remote_addr
*
* Obtain the remote IP address given a connection
*
* Input:
* cr_handle
* private data structure handle (only for IBHOSTS_NAMING)
*
* Output:
* remote_ia_address: where to place the remote address
*
* Returns:
* DAT_SUCCESS
* DAT_INSUFFICIENT_RESOURCES
* DAT_INVALID_PARAMETER
*
*/
/* ARGSUSED */
{
return (DAT_SUCCESS);
}
/*
* dapls_ib_handoff_connection
*
* handoff connection to a different qualifier
*
* Input:
* cr_ptr
* cr_handoff
*
* Output:
* none
*
* Returns:
* DAT_SUCCESS
* DAT_INSUFFICIENT_RESOURCES
* DAT_INVALID_PARAMETER
*
*/
{
int retval;
"dapls_ib_handoff: fd %d, sp_hkey %016llx, "
"bkl_index 0x%llx conn_qual %llu\n",
DAPL_CR_HANDOFF, &args);
if (retval != 0) {
}
return (DAT_SUCCESS);
}