iser_resource.c revision 30e7468f8f41aa30ada067b2c1d5d284046514da
/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/sysmacros.h>
/*
* Routines for allocating resources for iSER
*/
/*
* iser_init_hca_caches()
* Invoked per HCA instance initialization, to establish HCA-wide
* message and buffer kmem caches. Note we'll uniquify cache names
* with the lower 32-bits of the HCA GUID.
*/
void
{
char name[ISER_CACHE_NAMELEN];
}
/*
* iser_fini_hca_caches()
* Invoked per HCA instance teardown, this routine cleans up the
* message and buffer handle caches.
*/
void
{
}
/*
* Allocate and initialize an iSER WR handle
*/
{
}
return (iser_wr);
}
/*
* Free an iSER WR handle back to the global cache
*/
void
{
}
/*
* iser_msg_cache_constructor()
* Allocate and register memory for an iSER Control-type PDU message.
* The cached objects will retain this memory registration in the HCA,
* and thus provide a cache of pre-allocated and registered messages
* for use in iSER.
*/
/* ARGSUSED */
int
{
int status;
"failed to allocate backing memory");
return (DDI_FAILURE);
}
/* Fill in iser_mr for the memory we just allocated */
if (status != IDM_STATUS_SUCCESS) {
"couldn't find mr for %p", memp);
return (DDI_FAILURE);
}
/* Set a backpointer to this cache to save a lookup on free */
return (DDI_SUCCESS);
}
/*
* Deregister and free registered memory from an iser_msg_t handle.
*/
void
{
}
/*
* Pull a msg handle off of hca's msg cache. If no object is available
* on the cache, a new message buffer will be allocated and registered
* with the HCA. Once freed, this message will not be unregistered, thus
* building up a cache of pre-allocated and registered message buffers
* over time.
*/
{
int i;
/*
* Pull num number of message handles off the cache, linking
* them if more than one have been requested.
*/
for (i = 0; i < num; i++) {
"requested (%d) allocated (%d)", num, i);
break;
}
}
*ret = i;
}
return (msg);
}
/*
* Free this msg back to its cache, leaving the memory contained by
* it registered for later re-use.
*/
void
{
}
/*
* iser_buf_cache_constructor()
* Allocate and register memory for an iSER RDMA operation. The cached
* objects will retain this memory registration in the HCA, and thus
* provide a cache of pre-allocated and registered messages for use in
* iSER.
*/
/* ARGSUSED */
int
{
/* Allocate an iser_mr handle for this buffer */
"failed to allocate memory for iser_mr handle");
return (DDI_FAILURE);
}
return (DDI_FAILURE);
}
/* Fill in iser_mr for the memory we just allocated */
if (status != IDM_STATUS_SUCCESS) {
return (DDI_FAILURE);
}
/* Set buf pointer and len for later manipulation (if necessary) */
/* Populate the SGE Vaddr and L_key for the xfer operation later */
/* Set a backpointer to this cache to save a lookup on free */
return (DDI_SUCCESS);
}
/*
* Deregister and free registered memory from an iser_buf_t handle.
*/
void
{
}
/*
* Registration for initiator buffers
*/
int
{
"memory for idm_buf_t");
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
void
{
}
{
return (result);
}
void
{
chunk = next_chunk) {
}
}
void *
{
void *result;
/*
* Don't go over the pool size limit. We can allocate
* partial chunks so it's not always the case that
* current_size + chunk_size == max_total_size
*/
if (vmr_pool->ivmp_total_size >=
return (NULL);
} else {
}
}
if (next_chunk != NULL) {
/* Free the chunk we just allocated */
} else {
}
}
}
return (result);
}
void
{
}
{
&where);
if (nearest_chunk == NULL) {
if (nearest_chunk == NULL) {
return (IDM_STATUS_FAIL);
}
}
/* See if this chunk contains the specified address range */
/* Yes, this chunk contains the address range */
return (IDM_STATUS_SUCCESS);
}
return (IDM_STATUS_FAIL);
}
static iser_mr_t *
{
int km_flags = 0;
if (mr_flags & IBT_MR_NOSLEEP)
km_flags |= KM_NOSLEEP;
"chunk alloc of %d failed, trying %d",
chunksize /= 2;
} else {
}
}
"Chunk registration failed");
}
}
return (result);
}
static void
{
}
{
int km_flags = 0;
if (mr_flags & IBT_MR_NOSLEEP)
mr_flags |= KM_NOSLEEP;
"memory for iser_mr handle");
return (NULL);
}
if (status != IBT_SUCCESS) {
"failure (%d)", status);
return (NULL);
}
return (result);
}
void
{
}
static int
{
/* Sort memory chunks by their virtual address */
return (-1);
return (1);
return (0);
}