wrsm_session.c revision a83cadce5d3331b64803bfc641036cec23602c74
* 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 * See the License for the specific language governing permissions * and limitations under the License. * When distributing Covered Code, include this CDDL HEADER in each * 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] * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. #
pragma ident "%Z%%M% %I% %E% SMI" * Session management module of the Wildcat RSM driver. This module sets * up sessions with remote drivers. If communication is lost, it notifies * interested registered modules so they can invalidate any existing * The following macros define a DPRINTF macro which can be used to enable * or disable various levels of logging for this module. * Local function prototypes /* Distributes callbacks to all clients */ /* Initializes node structure */ /* Cleans up node structure */ * Changes state of node, performing callback if required. * NOTE: Releases the node->mutex lock during callbacks. "node_new_state(ctrl=%u, cnode=%u, state=%s, sess_id=%u)",
"node %d dereferences_needed %d\n",
/* Unmap remote barrier page */ /* Map remote barrier page */ * Node is claiming it exports an ncslice it doesn't! * Something must be wrong with connection. "bad ncslice %d from node %d\n",
/* Re-enter the node->mutex lock */ * Message related functions /* Regiseters message handling functions */ /* Removes message handling functions */ /* Handles session start message */ DTRC(
"msg_session_start");
/* If we have lower cnodeid, ignore them */ /* If they have lower cnodeid, then they win */ /* New session request. Go down then back up */ /* Only send response if this is not loopback */ DTRC(
"msg_session_start_rsp");
"sess_start_rsp from cnode %u to ctlr %u:" /* LINTED: E_NOP_ELSE_STMT */ "unexpected sess_start_rsp from cnode %u to ctlr %u: " "result %d, wrong state %s",
/* Add session structure to the net structure. */ /* Initialize client callback structure to all NULL */ /* Initialize cnode-specific structures */ /* Tell transport about our message handlers */ /* Remove our transport message handlers */ /* Clean-up per node session structures */ /* Informs session that a new cnode is reachable */ /* First, allocate a cmmu entry */ * Fix up the ncslice in the tuple to use the ncslice the /* Allocate enough memory to create an aligned page */ /* Find page-aligned address */ /* Start the process of establishing a new session */ /* Informs session that a cnode is no longer reachable */ /* Set CMMU to invalid */ /* Free barrier page memory */ * Functions for client use. /* Establishes a session with a remote cnode, if enabled. */ /* If the session is currently down or being established... */ /* Queue an event to the event thread, if necessary */ /* Wait for session to be established, or timeout */ /* If the session came up, return the session id */ /* Establishes a session with a remote cnode, if enabled. */ /* Deal with disabled nodes */ /* Get a new session id and set state to establishing */ /* Create and send session start message */ /* Wait for msg_session_start_rsp */ /* Don't care why cv was signaled, just check state... */ /* Asynchronously tears down a session to a cnode. */ DTRC(
"wrsm_sess_teardown");
/* Returns the current session. */ * We don't need node->mutex here, because reading one int * is atomic. Also, since the session_is is set to INVALID * any time the session is not in the UP state, we don't need * to check which state we're in now. /* Allows user to register for callbacks. */ DTRC(
"wrsm_sess_register");
/* Removes a user callback registration. */ DTRC(
"wrsm_sess_unregister");
* Functions for use by some session control software entitiy. /* Enables communication with a cnode. */ * A sess disable is in progress. Wait for it to complete * or fail before enabling. /* Disables communication with a cnode. May cause a teardown. */ /* timed out waiting for dereferences - fail */ /* Returns a cnode bitmask indicating which cnodes have valid sessions */ DTRC(
"wrsm_sess_get_cnodes");
* Clients call this when all references to node with invalid session "wrsm_sess_unreferenced dereferences needed now %d\n",
"wrsm_sess_touch_node(cnode=%d,stripes=0x%X)",
WARN(
"wrsm_sess_touch_node: session not up");
WARN(
"wrsm_sess_touch_node: NULL barrier_page pointer");
buf[0] =
pattern;
/* Seed first part of buffer with pattern */ buf[
4] = ~
pattern;
/* Seed second half of buffer */ /* If multiple stripes, get all the writes going in parallel... */ /* Now read back. If we get an error, data will be 0. */ WARN(
"wrsm_sess_touch_node: pattern mismatch");