rdma_subr.c revision 0a701b1ec2b55bddc48b62124df936152ff820f7
/*
* 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.
*/
/*
* Copyright (c) 2007, The Ohio State University. All rights reserved.
*
* Portions of this source code is developed by the team members of
* The Ohio State University's Network-Based Computing Laboratory (NBCL),
* headed by Professor Dhabaleswar K. (DK) Panda.
*
* Acknowledgements to contributions from developors:
* Ranjit Noronha: noronha@cse.ohio-state.edu
* Lei Chai : chail@cse.ohio-state.edu
* Weikuan Yu : yuw@cse.ohio-state.edu
*
*/
#include <rpc/rpc_rdma.h>
/*
* Globals
*/
int rdma_modloaded = 0; /* flag to load RDMA plugin modules */
int rdma_dev_available = 0; /* if any RDMA device is loaded */
/*
* Statics
*/
/*
* Externs
*/
extern kstat_named_t *rdmarcstat_ptr;
extern uint_t rdmarcstat_ndata;
extern kstat_named_t *rdmarsstat_ptr;
extern uint_t rdmarsstat_ndata;
void rdma_kstat_init();
/*
* RDMATF module registration routine.
* This routine is expected to be called by the init routine in
* the plugin modules.
*/
{
rdma_registry_t **mp, *m;
return (RDMA_BADVERS);
}
/*
* Ensure not already registered
*/
mp = &rdma_mod_head;
KNC_STRSIZE) == 0) {
return (RDMA_REG_EXIST);
}
}
/*
* New one, create and add to registry
*/
*mp = m;
return (RDMA_SUCCESS);
}
/*
* RDMATF module unregistration routine.
* This routine is expected to be called by the fini routine in
* the plugin modules.
*/
{
m = &rdma_mod_head;
while (*m != NULL) {
KNC_STRSIZE) != 0) {
m = &((*m)->r_next);
continue;
}
/*
* Check if any device attached, if so return error
*/
if ((*m)->r_mod->rdma_count != 0) {
return (RDMA_FAILED);
}
/*
* Found entry. Now remove it.
*/
mmod = *m;
*m = (*m)->r_next;
return (RDMA_SUCCESS);
}
/*
* Not found.
*/
return (RDMA_FAILED);
}
struct clist *
clist_alloc(void)
{
return (clp);
}
/*
* Creates a new chunk list entry, and
* adds it to the end of a chunk list.
*/
void
{
/* Find the end of the list */
cl = clist_alloc();
if (shandle)
if (dhandle)
}
{
struct clist *c;
int status;
if (c->c_len <= 0)
continue;
switch (dstsrc) {
case CLIST_REG_SOURCE:
&c->c_smemhandle, (void **)&c->c_ssynchandle,
(void *)c->rb_longbuf.rb_private);
break;
case CLIST_REG_DST:
&c->c_dmemhandle, (void **)&c->c_dsynchandle,
(void *)c->rb_longbuf.rb_private);
break;
default:
return (RDMA_INVAL);
}
if (status != RDMA_SUCCESS) {
return (status);
}
}
return (RDMA_SUCCESS);
}
{
struct clist *c;
switch (dstsrc) {
case CLIST_REG_SOURCE:
if (c->c_smemhandle.mrc_rmr != 0) {
(void) RDMA_DEREGMEMSYNC(conn,
c->c_smemhandle,
(void *)(uintptr_t)c->c_ssynchandle,
(void *)c->rb_longbuf.rb_private);
c->c_smemhandle.mrc_rmr = 0;
c->c_ssynchandle = NULL;
}
break;
case CLIST_REG_DST:
if (c->c_dmemhandle.mrc_rmr != 0) {
(void) RDMA_DEREGMEMSYNC(conn,
c->c_dmemhandle,
(void *)(uintptr_t)c->c_dsynchandle,
(void *)c->rb_longbuf.rb_private);
c->c_dmemhandle.mrc_rmr = 0;
c->c_dsynchandle = NULL;
}
break;
default:
return (RDMA_INVAL);
}
}
return (RDMA_SUCCESS);
}
{
struct clist *c;
c = cl;
switch (dstsrc) {
case CLIST_REG_SOURCE:
while (c != NULL) {
if (c->c_ssynchandle) {
(void *)(uintptr_t)c->c_ssynchandle,
c->c_len, 0);
if (status != RDMA_SUCCESS)
return (status);
}
c = c->c_next;
}
break;
case CLIST_REG_DST:
while (c != NULL) {
if (c->c_ssynchandle) {
(void *)(uintptr_t)c->c_dsynchandle,
c->c_len, 1);
if (status != RDMA_SUCCESS)
return (status);
}
c = c->c_next;
}
break;
default:
return (RDMA_INVAL);
}
return (RDMA_SUCCESS);
}
/*
* Frees up entries in chunk list
*/
void
{
while (c != NULL) {
c = cl;
}
}
{
rdma_buf_t rbuf = {0};
return (RDMA_NORESOURCE);
}
clist_free(cl);
return (retval);
}
{
}
{
rdma_buf_t rbuf = {0};
} else {
clist_free(cl);
}
return (retval);
}
{
}
void
{
return;
}
}
/*
* Caller is holding rdma_modload_lock mutex
*/
int
{
int status;
/*
* Load all available RDMA plugins which right now is only IB plugin.
* If no IB hardware is present, then quit right away.
* ENODEV -- For no device on the system
* EPROTONOSUPPORT -- For module not avilable either due to failure to
* load or some other reason.
*/
rdma_modloaded = 1;
if (ibt_hw_is_present() == 0) {
rdma_dev_available = 0;
return (ENODEV);
}
rdma_dev_available = 1;
return (EPROTONOSUPPORT);
if (status != 0)
return (EPROTONOSUPPORT);
/* success */
return (0);
}
void
rdma_kstat_init(void)
{
/*
* The RDMA framework doesn't know how to deal with Zones, and is
* only available in the global zone.
*/
if (ksp) {
}
if (ksp) {
}
}