/*
* 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 (c) 2002-2003, Network Appliance, Inc. All rights reserved.
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
*
* MODULE: dapl_ep_connect.c
*
* PURPOSE: Endpoint management
* Description: Interfaces in this file are completely described in
* the DAPL 1.1 API, Chapter 6, section 5
*
* $Id: dapl_ep_connect.c,v 1.23 2003/07/31 13:55:18 hobie16 Exp $
*/
#include "dapl.h"
#include "dapl_ep_util.h"
#include "dapl_adapter_util.h"
#include "dapl_evd_util.h"
/*
* dapl_ep_connect
*
* DAPL Requirements Version xxx, 6.5.7
*
* Request a connection be established between the local Endpoint
* side of a connection
*
* Input:
* ep_handle
* remote_ia_address
* remote_conn_qual
* timeout
* private_data_size
* privaet_data
* qos
* connect_flags
*
* Output:
* None
*
* Returns:
* DAT_SUCCESS
* DAT_INSUFFICIENT_RESOUCRES
* DAT_INVALID_PARAMETER
* DAT_MODLE_NOT_SUPPORTED
*/
{
"dapl_ep_connect (%p, {%u.%u.%u.%u}, %X, %d, %d, %p, %x, %x)\n",
qos,
/*
* Verify parameter & state. The connection handle must be good
* at this point.
*/
goto bail;
}
goto bail;
}
/*
* If the endpoint needs a QP, associated the QP with it.
* This needs to be done carefully, in order to:
* * Avoid allocating under a lock.
* * Not step on data structures being altered by
* routines with which we are racing.
* So we:
* * Confirm that a new QP is needed and is not forbidden by the
* current state.
* * Allocate it into a separate EP.
* * Take the EP lock.
* * Reconfirm that the EP is in a state where it needs a QP.
* * Assign the QP and release the lock.
*/
goto bail;
}
if (dat_status != DAT_SUCCESS) {
goto bail;
}
/*
* PZ shouldn't have changed since we're only racing with
* dapl_cr_accept()
*/
/* Bail, cleaning up. */
&alloc_ep);
if (dat_status != DAT_SUCCESS) {
"ep_connect: ib_qp_free failed with %x\n",
}
goto bail;
}
}
/*
* We do state checks and transitions under lock.
* The only code we're racing against is dapl_cr_accept.
*/
/*
* Verify the attributes of the EP handle before we connect it. Test
* all of the handles to make sure they are currently valid.
* Specifically:
* pz_handle required
* recv_evd_handle optional, but must be valid
* request_evd_handle optional, but must be valid
* connect_evd_handle required
*/
DAPL_MAGIC_EVD) ||
DAPL_MAGIC_EVD))) ||
DAPL_MAGIC_EVD)))) {
goto bail;
}
/*
* Check both the EP state and the QP state: if we don't have a QP
* we need to attach one now.
*/
if (dat_status != DAT_SUCCESS) {
goto bail;
}
}
goto bail;
}
if (qos != DAT_QOS_BEST_EFFORT ||
/*
* At this point we only support one QOS level
*/
goto bail;
}
/*
* Verify the private data size doesn't exceed the max
*/
goto bail;
}
/*
* transition the state before requesting a connection to avoid
* race conditions
*/
/*
* At this point we're committed, and done with the endpoint
* except for the connect, so we can drop the lock.
*/
/*
* fill in the private data
*/
if (private_data_size > 0)
/* Copy the connection qualifiers */
remote_ia_address, sizeof (DAT_SOCK_ADDR6));
if (dat_status != DAT_SUCCESS) {
/* Unreachable IP address */
(DAT_HANDLE) ep_ptr, 0, 0);
}
/* Non-existant connection qualifier */
(DAT_HANDLE) ep_ptr, 0, 0);
}
} else {
}
}
bail:
"dapl_ep_connect () returns 0x%x\n", dat_status);
return (dat_status);
}