/*
* 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.
*/
/*
* This file implements the callback handler logic common to send and receive
* handling in IBMF.
*/
extern int ibmf_trace_level;
extern ibmf_state_t *ibmf_statep;
/*
* ibmf_ibt_async_handler():
* This function handles asynchronous events detected by the
* IBT framework.
*/
/* ARGSUSED */
void
{
IBMF_TNF_TRACE, "",
/*
* let ibmf_saa know events first hand
*/
/*
* call client callbacks and then fail if ANY client remains.
*/
if (code == IBT_HCA_DETACH_EVENT) {
break;
}
}
/*
* found the right ci, check
* if any clients are still registered
* (Note that if we found the ci, chances are that
* it was not released).
*/
IBMF_TNF_TRACE, "",
"%s, returning failure\n",
"ibmf_ibt_async_handler: Found "
"clients still registered.");
}
}
} else if (code == IBT_EVENT_SQD) {
/*
* An SQD event is received. We match the QP handle provided
* with all the alternate QP handles maintained on the lists
* of all the CI contexts. If a match is found, we wake
* up the thread waiting in ibmf_modify_qp().
*/
break;
}
}
if (found)
break;
}
if (!found)
"event for unknown QP received");
}
}
/*
* ibmf_i_callback_clients():
* Finds the ci given in parameter.
* Calls the client callbacks with the event given in parameter.
* Note that client callbacks are called with all ibmf mutexes unlocked.
*/
static void
{
int nclients = 0;
int iclient;
/* find ci */
break;
}
}
"ibmf_i_callback_clients: "
goto bail;
}
/* found the right ci, count clients */
/* empty counting loop */
;
"ibmf_i_callback_clients: found %d clients, "
/* no clients? bail */
if (nclients == 0) {
goto bail;
}
/* allocate callback, args, and client arrays */
nclients * sizeof (void*), KM_NOSLEEP);
client_array == NULL) {
"ibmf_i_callback_clients: %s\n",
"callback arrays");
goto bail;
}
/* build callback list */
}
/*
* All mutex unlocked, call back clients
*/
"ibmf_i_callback_clients: client %d"
", handle = %016" PRIx64
}
bail:
if (cb_args_array != NULL)
if (client_array != NULL)
}
/*
* ibmf_i_mad_completions():
* Check for a completion entry on the specified CQ and process it
*/
void
{
"ibmf_i_mad_completions() enter, cq_hdl = %p\n",
/*
* Pull a completion and process it
*/
for (;;) {
/*
* Check if the status is IBT_SUCCESS or IBT_CQ_EMPTY
* either which can return from ibt_poll_cq(). In other
* cases, log the status for the further investigation.
*/
if (status != IBT_SUCCESS) {
if (status != IBT_CQ_EMPTY) {
"an error status (0x%x) from ibt_poll_cq.",
status);
}
break;
}
/* process the completion */
}
/*
* Look for more completions just in case some came in before
* we were able to reenable CQ notification
*/
for (;;) {
/*
* Check if the status is IBT_SUCCESS or IBT_CQ_EMPTY
* either which can return from ibt_poll_cq(). In other
* cases, log the status for the further investigation.
*/
if (status != IBT_SUCCESS) {
if (status != IBT_CQ_EMPTY) {
"an error status (0x%x) from ibt_poll_cq.",
status);
}
break;
}
/* process the completion */
}
}
/*
* ibmf_i_process_completion():
* Process the send or receive completion
*/
static void
{
"ibmf_i_process_completion() enter, cip = %p, wcp = %p\n",
/* completion from a receive queue */
} else {
/* completion from a send queue */
}
}
#ifdef DEBUG
static int ibmf_i_dump_wcp_enable = 0;
/* ARGSUSED */
void
{
int i, j;
if (ibmf_i_dump_wcp_enable == 0)
return;
printf("wcp: sender lid %x port num %x path bits %x qp %x sl %x\n",
sizeof (ib_grh_t));
printf("mad:\n");
/* first print multiples of 16bytes */
}
}
/* print the rest */
if (i < 16) {
}
}
}
#endif /* DEBUG */