/*
* 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"
/*
* Should we maintain base lid for each port in ibmf_ci?
*/
/*
* This file implements the UD destination resource management in IBMF.
*/
extern int ibmf_trace_level;
extern ibmf_state_t *ibmf_statep;
/*
* ibmf_i_init_ud_dest():
* Initialize a cache of UD destination structure used to send UD traffic.
* Also create a list of pre-allocated UD destination structures to
* satisfy requests for a UD destination structure and its associated
* address handle, from a thread in interrupt context. Threads in interrupt
* context are not allowed to allocated their own address handles.
*/
void
{
/* initialize the UD dest list mutex */
/* populate the UD dest list if possible */
}
/*
* ibmf_i_fini_ud_dest():
* Free up the UD destination cache and the linked list.
*/
void
{
/* clean up the UD dest list */
}
/*
* ibmf_i_get_ud_dest():
* Get a UD destination structure from the list
*/
{
if (ibmf_ud_dest != NULL) {
}
return (ibmf_ud_dest);
}
/*
* ibmf_i_put_ud_dest():
* Add a UD destination structure to the list
*/
void
{
}
/*
* ibmf_i_populate_ud_dest_list():
* Maintain a list of IBMF UD destination structures to
* satisfy requests for a UD destination structure and its associated
* address handle, from a thread in interrupt context. Threads in interrupt
* context are not allowed to allocate their own address handles.
* Add to this list only if the number of entries in the list falls below
* IBMF_UD_DEST_LO_WATER_MARK. When adding to the list, add entries upto
* IBMF_UD_DEST_HI_WATER_MARK.
*/
static void
{
"ibmf_i_populate_ud_dest_list() enter, cip = %p, kmflag = %d \n",
/* do not allow a population operation if non-blocking */
if (kmflag == KM_NOSLEEP) {
"Skipping, called with non-blocking flag\n");
"ibmf_i_populate_ud_dest_list() exit\n");
/*
* Don't return a failure code here.
* If ibmf_i_ud_dest_alloc() returns NULL, the
* the resource allocation will fail
*/
return;
}
/* nothing to do if count is above the low water mark */
if (count > IBMF_UD_DEST_LO_WATER_MARK) {
"Count not below low water mark\n");
"ibmf_i_populate_ud_dest_list() exit\n");
return;
}
/* populate the pool upto the high water mark */
while (count < IBMF_UD_DEST_HI_WATER_MARK) {
/* Call IBTF to allocate an address handle */
if (status != IBT_SUCCESS) {
"ibmf_i_populate_ud_dest_list(): %s, status = %d\n",
"ibmf_i_populate_ud_dest_list() exit\n");
return;
}
/* Add the ud_dest to the list */
else
/*
* Get the latest count since other threads may have
* added to the list as well.
*/
}
}
/*
* ibmf_i_clean_ud_dest_list():
* Free up entries from the linked list of IBMF UD destination structures.
* If the "all" argument is B_TRUE, free up all the entries in the list.
* If the "all" argument is B_FALSE, free up entries to bring the total
* down to IBMF_UD_DEST_HI_WATER_MARK.
*/
void
{
/* Determine the number of UD destination resources to free */
} else
count = 0;
while (count) {
if (ibmf_ud_dest != NULL) {
/* Remove ibmf_ud_dest from the list */
if (status != IBT_SUCCESS) {
"", "ibmf_i_clean_ud_dest_list(): %s, "
status);
"", "ibmf_i_clean_ud_dest_list() exit\n");
return;
}
/* Free the ud_dest context */
}
/* Determine the number of UD destination resources to free */
} else if (cip->ci_ud_dest_list_count >
} else
count = 0;
}
}
/*
* ibmf_i_alloc_ud_dest():
* Allocate and set up a UD destination context
*/
/*ARGSUSED*/
int
{
"clientp = %p, msg = %p, ud_destp = %p, block = %d\n",
/*
* Dispatch a taskq to replenish the UD destination handle cache.
*/
if (ret == 0) {
"taskq dispatch of ud_dest population thread "
"failed");
}
}
/* fill in the grh stuff as expected by ibt */
} else {
}
} else {
}
/* common address vector initialization */
/* Get the port's base LID */
(void) ibt_get_port_state_byguid(
&clientp->ic_base_lid);
if (clientp->ic_base_lid == 0) {
"base_lid is not defined, i.e., port is down");
"ibmf_i_alloc_ud_dest_list() exit\n");
return (IBMF_BAD_PORT_STATE);
}
}
/* If an IBT UD destination structure has not been allocated, do so */
/* Get a UD destination resource from the list */
if (ibmf_ud_dest == NULL) {
"ibmf_i_alloc_ud_dest(): %s\n",
"ibmf_i_alloc_ud_dest_list() exit\n");
return (IBMF_NO_RESOURCES);
}
} else {
}
/* modify the address handle with the address vector information */
if (status != IBT_SUCCESS)
"ibmf_i_alloc_ud_dest(): %s, status = %d\n",
ibt_status, status);
if (ibmf_status == IBMF_SUCCESS) {
}
return (ibmf_status);
}
/*
* ibmf_i_free_ud_dest():
* Free up the UD destination context
*/
void
{
/* Clear the UD dest pointers so a new UD dest may be allocated */
}
/*
* ibmf_i_pop_ud_dest_thread()
*
* Wrapper function to call ibmf_i_populate_ud_dest_list() with
* the KM_SLEEP flag.
*/
void
{
}
/*
* ibmf_ud_dest_tq_disp()
*
* Wrapper for taskq dispatch of the function that populates
* the UD destination handle cache.
*/
int
{
}