connection.c revision b27516f55237249607f754e6e42e865f12456675
/*
* 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) 2006 Oracle. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or 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
* 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.
*
*/
/* converting this to RCU is a chore for another day.. */
static krwlock_t rdsv3_conn_lock;
static unsigned long rdsv3_conn_count;
struct avl_tree rdsv3_conn_hash;
if (test) \
} while (0)
static inline int
{
int ret = 0;
ret = 1;
else
return (ret);
}
static struct rdsv3_connection *
{
struct rdsv3_connection *conn;
struct rdsv3_conn_info_s conn_info;
avl_index_t place = 0;
RDSV3_DPRINTF5("rdsv3_conn_lookup",
"returning conn %p for %u.%u.%u.%u -> %u.%u.%u.%u",
return (conn);
}
/*
* This is called by transports as they're bringing down a connection.
* It clears partial message state so that the transport can start sending
* and receiving over this connection again in the future. It is up to
* the transport to have serialized this call with its send and recv.
*/
void
{
RDSV3_DPRINTF2("rdsv3_conn_reset",
"connection %u.%u.%u.%u to %u.%u.%u.%u reset",
/*
* Do not clear next_rx_seq here, else we cannot distinguish
* retransmitted packets from new packets, and will hand all
* of them to the application. That is not consistent with the
* reliability guarantees of RDS.
*/
}
/*
* There is only every one 'conn' for a given pair of addresses in the
* system at a time. They contain messages to be retransmitted and so
* span the lifetime of the actual underlying transport connections.
*
* For now they are not garbage collected once they're created. They
* are torn down as the module is removed, if ever.
*/
static struct rdsv3_connection *
int is_outgoing)
{
int ret;
if (conn &&
conn->c_loopback &&
!is_outgoing) {
/*
* This is a looped back IB connection, and we're
* called by the code handling the incoming connect.
* We need a second connection object into which we
* can stick the other QP.
*/
}
if (conn)
goto out;
goto out;
}
/* see rdsv3_conn_constructor */
if (ret) {
goto out;
}
/*
* This is where a connection becomes loopback. If *any* RDS sockets
* can bind to the destination address then we'd rather the messages
* flow through loopback rather than either transport.
*/
if (rdsv3_trans_get_preferred(faddr)) {
/*
* "outgoing" connection - and the transport
* says it wants the connection handled by the
* loopback transport. This is what TCP does.
*/
}
}
if (ret) {
goto out;
}
conn->c_reconnect_jiffies = 0;
RDSV3_DPRINTF2("__rdsv3_conn_create",
"allocated conn %p for %u.%u.%u.%u -> %u.%u.%u.%u over %s %s",
/*
* Since we ran without holding the conn lock, someone could
* have created the same conn (either normal or passive) in the
* interim. We check while holding the lock. If we won, we complete
* init and return our conn. If we lost, we rollback and return the
* other one.
*/
if (parent) {
/* Creating passive conn */
} else {
}
} else {
/* Creating normal conn */
struct rdsv3_connection *found;
if (found) {
} else {
}
}
out:
return (conn);
}
struct rdsv3_connection *
{
}
struct rdsv3_connection *
{
}
void
{
RDSV3_DPRINTF4("rdsv3_conn_destroy",
"freeing conn %p for %u.%u.%u.%u -> %u.%u.%u.%u",
/* wait for the rds thread to shut it down */
/* tear down queued messages */
&conn->c_send_queue,
m_conn_item) {
}
/*
* The congestion maps aren't freed up here. They're
* freed by rdsv3_cong_exit() after all the connections
* have been freed.
*/
}
/* ARGSUSED */
static void
struct rdsv3_info_iterator *iter,
struct rdsv3_info_lengths *lens,
int want_send)
{
struct rdsv3_connection *conn;
struct rdsv3_message *rm;
unsigned int total = 0;
len /= sizeof (struct rdsv3_info_message);
if (avl_is_empty(&rdsv3_conn_hash)) {
/* no connections */
return;
}
do {
if (want_send)
else
/* XXX too lazy to maintain counts.. */
total++;
}
}
static void
struct rdsv3_info_iterator *iter,
struct rdsv3_info_lengths *lens)
{
}
static void
unsigned int len,
struct rdsv3_info_iterator *iter,
struct rdsv3_info_lengths *lens)
{
}
/* ARGSUSED */
void
struct rdsv3_info_iterator *iter,
struct rdsv3_info_lengths *lens,
int (*visitor)(struct rdsv3_connection *, void *),
{
struct rdsv3_connection *conn;
if (avl_is_empty(&rdsv3_conn_hash)) {
/* no connections */
return;
}
/* allocate a little extra as this can get cast to a uint64_t */
do {
/* XXX no c_lock usage.. */
/*
* We copy as much as we can fit in the buffer,
* but we count all items so that the caller
* can resize the buffer.
*/
RDSV3_DPRINTF4("rdsv3_for_each_conn_info",
"buffer: %p iter: %p bytes: %d", buffer,
}
}
}
static int
{
/* XXX Future: return the state rather than these funky bits */
return (1);
}
static void
{
rdsv3_conn_info_visitor, sizeof (struct rdsv3_info_connection));
}
int
{
sizeof (struct rdsv3_connection), 0, rdsv3_conn_constructor,
if (rdsv3_conn_slab == NULL) {
RDSV3_DPRINTF2("rdsv3_conn_init",
"kmem_cache_create(rdsv3_conn_slab) failed");
return (-1);
}
c_hash_node));
return (0);
}
void
{
}
/*
* Force a disconnect
*/
void
{
}