rdma_transport.c revision 16e76cdd6e3cfaac7d91c3b0644ee1bc6cf52347
/*
*/
/*
* This file contains code imported from the OFED rds source file
* rdma_transport.c * Oracle elects to have and use the contents of
* rdma_transport.c under and governed by the OpenIB.org BSD license
* (see below for full license text). However, the following notice
* accompanied the original version of this file:
*/
/*
* Copyright (c) 2009 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.
*
*/
int
struct rdma_cm_event *event)
{
/* this can be null in the listening path */
struct rdsv3_transport *trans;
int ret = 0;
RDSV3_DPRINTF2("rdsv3_rdma_cm_event_handler",
/*
* Prevent shutdown from tearing down the connection
* while we're executing.
*/
if (conn) {
/*
* If the connection is being shut down, bail out
* right away. We return 0 so cm_id doesn't get
* destroyed prematurely
*/
/*
* Reject incoming connections while we're tearing
* down an existing one.
*/
ret = 1;
RDSV3_DPRINTF2("rdsv3_rdma_cm_event_handler",
"conn %p id %p incoming event %u when "
goto out;
}
}
break;
/* XXX do we need to clean up if this fails? */
break;
/* XXX worry about racing with listen acceptance */
break;
break;
case RDMA_CM_EVENT_ADDR_ERROR:
case RDMA_CM_EVENT_REJECTED:
if (conn)
break;
RDSV3_DPRINTF2("rdsv3_rdma_cm_event_handler",
"cm_id: %p", cm_id);
if (conn) {
RDSV3_DPRINTF2("rdsv3_rdma_cm_event_handler",
}
break;
default:
/* things like device disconnect? */
RDSV3_DPRINTF2("rdsv3_rdma_cm_event_handler",
RDSV3_PANIC();
break;
}
out:
if (conn)
RDSV3_DPRINTF2("rdsv3_rdma_cm_event_handler",
return (ret);
}
static int
rdsv3_rdma_listen_init(void)
{
struct sockaddr_in sin;
struct rdma_cm_id *cm_id;
int ret;
RDSV3_DPRINTF2("rdsv3_rdma_listen_init",
"rdma_create_id() returned %d", ret);
goto out;
}
/*
* XXX I bet this binds the cm_id to a device. If we want to support
* fail-over we'll have to take this into consideration.
*/
if (ret) {
RDSV3_DPRINTF2("rdsv3_rdma_listen_init",
"rdma_bind_addr() returned %d", ret);
goto out;
}
if (ret) {
RDSV3_DPRINTF2("rdsv3_rdma_listen_init",
"rdma_listen() returned %d", ret);
goto out;
}
RDSV3_DPRINTF5("rdsv3_rdma_listen_init",
RDSV3_DPRINTF2("rdsv3_rdma_listen_init",
"Return: rdsv3_rdma_listen_id: %p", rdsv3_rdma_listen_id);
out:
if (cm_id)
return (ret);
}
static void rdsv3_rdma_listen_stop(void)
{
}
/*
* This function can be called via two routes.
* 1. During attach on a worker thread.
* 2. From rdsv3_create() for 1st socket.
*/
void
{
int ret;
if (rdsv3_rdma_listen_id != NULL) {
RDSV3_DPRINTF2("rdsv3_rdma_init",
"rdsv3_rdma_listen_id is already initialized: %p",
return;
}
if (ret) {
return;
}
ret = rdsv3_ib_init();
if (ret) {
}
}
/*ARGSUSED*/
void
rdsv3_rdma_exit(void *arg)
{
/* stop listening first to ensure no new connections are attempted */
if (rdsv3_rdma_listen_id) {
}
}