rdma_subr.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <rpc/rpc_rdma.h>
/*
* RDMA chunk size
*/
#define RDMA_MINCHUNK 1024
/*
* 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);
}
/*
* Creates a new chunk list entry, and
* adds it to the end of a chunk list.
*/
void
{
/* Find the end of the list */
if (shandle)
if (dhandle)
}
int
{
struct clist *c;
int status;
if (src) {
&c->c_smemhandle, (void **)&c->c_ssynchandle);
} else {
&c->c_dmemhandle, (void **)&c->c_dsynchandle);
}
if (status != RDMA_SUCCESS) {
return (status);
}
}
return (RDMA_SUCCESS);
}
int
{
struct clist *c;
if (src) {
if (c->c_smemhandle.mrc_rmr != 0) {
(void) RDMA_DEREGMEMSYNC(conn,
c->c_smemhandle,
(void *)(uintptr_t)c->c_ssynchandle);
c->c_smemhandle.mrc_rmr = 0;
c->c_ssynchandle = NULL;
}
} else {
if (c->c_dmemhandle.mrc_rmr != 0) {
(void) RDMA_DEREGMEMSYNC(conn,
c->c_dmemhandle,
(void *)(uintptr_t)c->c_dsynchandle);
c->c_dmemhandle.mrc_rmr = 0;
c->c_dsynchandle = NULL;
}
}
}
return (RDMA_SUCCESS);
}
/*
* Frees up entries in chunk list
*/
void
{
while (c != NULL) {
c = cl;
}
}
{
} else {
clist_free(cl);
}
return (retval);
}
{
} else {
clist_free(cl);
}
return (retval);
}
{
struct clist *c;
c = cl;
if (src) {
while (c != NULL) {
(void *)(uintptr_t)c->c_ssynchandle,
if (status != RDMA_SUCCESS)
return (status);
c = c->c_next;
}
} else {
while (c != NULL) {
(void *)(uintptr_t)c->c_dsynchandle,
if (status != RDMA_SUCCESS)
return (status);
c = c->c_next;
}
}
return (RDMA_SUCCESS);
}
void
{
return;
}
/* pool buffer */
} else {
}
}
/*
* 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) {
}
}