[ofa-general] [PATCH] opensm: kill osm_state_mgr object

Sasha Khapyorsky sashak at voltaire.com
Thu Feb 7 20:02:14 PST 2008


Remove not used anymore sm's osm_state_mgr sub-object.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 opensm/include/opensm/osm_sm.h        |   46 +++-
 opensm/include/opensm/osm_state_mgr.h |   51 ---
 opensm/opensm/osm_console.c           |    2 +-
 opensm/opensm/osm_perfmgr.c           |    8 +-
 opensm/opensm/osm_sm.c                |   12 +-
 opensm/opensm/osm_state_mgr.c         |  567 ++++++++++++++-------------------
 6 files changed, 298 insertions(+), 388 deletions(-)

diff --git a/opensm/include/opensm/osm_sm.h b/opensm/include/opensm/osm_sm.h
index 2cdbdd0..83bd4da 100644
--- a/opensm/include/opensm/osm_sm.h
+++ b/opensm/include/opensm/osm_sm.h
@@ -70,7 +70,6 @@
 #include <opensm/osm_port.h>
 #include <opensm/osm_mcast_mgr.h>
 #include <opensm/osm_db.h>
-#include <opensm/osm_state_mgr.h>
 
 #ifdef __cplusplus
 #  define BEGIN_C_DECLS extern "C" {
@@ -113,6 +112,7 @@ BEGIN_C_DECLS
 */
 typedef struct osm_sm {
 	osm_thread_state_t thread_state;
+	osm_sm_state_t state;
 	unsigned signal_mask;
 	cl_spinlock_t signal_lock;
 	cl_event_t signal_event;
@@ -136,7 +136,6 @@ typedef struct osm_sm {
 	osm_lid_mgr_t lid_mgr;
 	osm_ucast_mgr_t ucast_mgr;
 	osm_link_mgr_t link_mgr;
-	osm_state_mgr_t state_mgr;
 	osm_drop_mgr_t drop_mgr;
 	osm_sweep_fail_ctrl_t sweep_fail_ctrl;
 	osm_sm_state_mgr_t sm_state_mgr;
@@ -655,5 +654,48 @@ osm_sm_wait_for_subnet_up(IN osm_sm_t * const p_sm,
 * SEE ALSO
 *********/
 
+/****f* OpenSM: State Manager/osm_sm_is_greater_than
+* NAME
+*	osm_sm_is_greater_than
+*
+* DESCRIPTION
+*	Compares two SM's (14.4.1.2)
+*
+* SYNOPSIS
+*/
+static inline boolean_t
+osm_sm_is_greater_than(IN const uint8_t l_priority,
+		       IN const ib_net64_t l_guid,
+		       IN const uint8_t r_priority, IN const ib_net64_t r_guid)
+{
+	return (l_priority > r_priority
+		|| (l_priority == r_priority
+		    && cl_ntoh64(l_guid) < cl_ntoh64(r_guid)));
+}
+
+/*
+* PARAMETERS
+*	l_priority
+*		[in] Priority of the SM on the "left"
+*
+*	l_guid
+*		[in] GUID of the SM on the "left"
+*
+*	r_priority
+*		[in] Priority of the SM on the "right"
+*
+*	r_guid
+*		[in] GUID of the SM on the "right"
+*
+* RETURN VALUES
+*	Return TRUE if an sm with l_priority and l_guid is higher than an sm
+*	with r_priority and r_guid, return FALSE otherwise.
+*
+* NOTES
+*
+* SEE ALSO
+*	State Manager
+*********/
+
 END_C_DECLS
 #endif				/* _OSM_SM_H_ */
diff --git a/opensm/include/opensm/osm_state_mgr.h b/opensm/include/opensm/osm_state_mgr.h
index f3886ec..1173981 100644
--- a/opensm/include/opensm/osm_state_mgr.h
+++ b/opensm/include/opensm/osm_state_mgr.h
@@ -254,57 +254,6 @@ osm_state_mgr_init(IN osm_state_mgr_t * const p_mgr, struct osm_sm * sm);
 *	osm_state_mgr_destroy
 *********/
 
-/****f* OpenSM: State Manager/osm_sm_is_greater_than
-* NAME
-*	osm_sm_is_greater_than
-*
-* DESCRIPTION
-*  Compares two SM's (14.4.1.2)
-*
-* SYNOPSIS
-*/
-static inline boolean_t
-osm_sm_is_greater_than(IN const uint8_t l_priority,
-		       IN const ib_net64_t l_guid,
-		       IN const uint8_t r_priority, IN const ib_net64_t r_guid)
-{
-	if (l_priority > r_priority) {
-		return (TRUE);
-	} else {
-		if (l_priority == r_priority) {
-			if (cl_ntoh64(l_guid) < cl_ntoh64(r_guid)) {
-				return (TRUE);
-			}
-		}
-	}
-	return (FALSE);
-}
-
-/*
-* PARAMETERS
-*	l_priority
-*		[in] Priority of the SM on the "left"
-*
-*	l_guid
-*		[in] GUID of the SM on the "left"
-*
-*	r_priority
-*		[in] Priority of the SM on the "right"
-*
-*	r_guid
-*		[in] GUID of the SM on the "right"
-*
-* RETURN VALUES
-*  Return TRUE if an sm with l_priority and l_guid is higher than an sm
-*  with r_priority and r_guid,
-*  return FALSE otherwise.
-*
-* NOTES
-*
-* SEE ALSO
-*	State Manager
-*********/
-
 /****f* OpenSM: State Manager/osm_state_mgr_process
 * NAME
 *	osm_state_mgr_process
diff --git a/opensm/opensm/osm_console.c b/opensm/opensm/osm_console.c
index 8b6642e..1a6208f 100644
--- a/opensm/opensm/osm_console.c
+++ b/opensm/opensm/osm_console.c
@@ -314,7 +314,7 @@ static void print_status(osm_opensm_t * p_osm, FILE * out)
 		fprintf(out, "   OpenSM Version     : %s\n", OSM_VERSION);
 		fprintf(out, "   SM State/Mgr State : %s/%s\n",
 			sm_state_str(p_osm->subn.sm_state),
-			sm_state_mgr_str(p_osm->sm.state_mgr.state));
+			sm_state_mgr_str(p_osm->sm.state));
 		fprintf(out, "   SA State           : %s\n",
 			sa_state_str(p_osm->sa.state));
 		fprintf(out, "   Routing Engine     : %s\n",
diff --git a/opensm/opensm/osm_perfmgr.c b/opensm/opensm/osm_perfmgr.c
index 9480ad7..1099445 100644
--- a/opensm/opensm/osm_perfmgr.c
+++ b/opensm/opensm/osm_perfmgr.c
@@ -790,12 +790,12 @@ void osm_perfmgr_process(osm_perfmgr_t * pm)
 	if (pm->state != PERFMGR_STATE_ENABLED)
 		return;
 
-	if (pm->sm->state_mgr.state != OSM_SM_STATE_IDLE &&
-	    pm->sm->state_mgr.state != OSM_SM_STATE_STANDBY)
+	if (pm->sm->state != OSM_SM_STATE_IDLE &&
+	    pm->sm->state != OSM_SM_STATE_STANDBY)
 		return;
 
-	if (pm->sm->state_mgr.state == OSM_SM_STATE_STANDBY ||
-	    (pm->sm->state_mgr.state == OSM_SM_STATE_IDLE &&
+	if (pm->sm->state == OSM_SM_STATE_STANDBY ||
+	    (pm->sm->state == OSM_SM_STATE_IDLE &&
 	     pm->subn->sm_state == IB_SMINFO_STATE_NOTACTIVE))
 		perfmgr_discovery(pm->subn->p_osm);
 
diff --git a/opensm/opensm/osm_sm.c b/opensm/opensm/osm_sm.c
index 019fa51..37dae43 100644
--- a/opensm/opensm/osm_sm.c
+++ b/opensm/opensm/osm_sm.c
@@ -80,6 +80,8 @@ extern void osm_si_rcv_process(IN void *context, IN void *data);
 extern void osm_trap_rcv_process(IN void *context, IN void *data);
 extern void osm_vla_rcv_process(IN void *context, IN void *data);
 
+extern void osm_state_mgr_process(IN osm_sm_t *sm, IN osm_signal_t signal);
+
 /**********************************************************************
  **********************************************************************/
 static void osm_sm_process(osm_sm_t * sm, osm_signal_t signal)
@@ -89,7 +91,7 @@ static void osm_sm_process(osm_sm_t * sm, osm_signal_t signal)
 		osm_perfmgr_process(&sm->p_subn->p_osm->perfmgr);
 	else
 #endif
-		osm_state_mgr_process(&sm->state_mgr, signal);
+		osm_state_mgr_process(sm, signal);
 }
 
 static void __osm_sm_sweeper(IN void *p_ptr)
@@ -154,6 +156,7 @@ void osm_sm_construct(IN osm_sm_t * const p_sm)
 {
 	memset(p_sm, 0, sizeof(*p_sm));
 	p_sm->thread_state = OSM_THREAD_STATE_NONE;
+	p_sm->state = OSM_SM_STATE_INIT;
 	p_sm->sm_trans_id = OSM_SM_INITIAL_TID_VALUE;
 	cl_spinlock_construct(&p_sm->signal_lock);
 	cl_event_construct(&p_sm->signal_event);
@@ -165,7 +168,6 @@ void osm_sm_construct(IN osm_sm_t * const p_sm)
 	osm_lid_mgr_construct(&p_sm->lid_mgr);
 	osm_ucast_mgr_construct(&p_sm->ucast_mgr);
 	osm_link_mgr_construct(&p_sm->link_mgr);
-	osm_state_mgr_construct(&p_sm->state_mgr);
 	osm_drop_mgr_construct(&p_sm->drop_mgr);
 	osm_sweep_fail_ctrl_construct(&p_sm->sweep_fail_ctrl);
 	osm_sm_state_mgr_construct(&p_sm->sm_state_mgr);
@@ -229,7 +231,6 @@ void osm_sm_destroy(IN osm_sm_t * const p_sm)
 	osm_ucast_mgr_destroy(&p_sm->ucast_mgr);
 	osm_link_mgr_destroy(&p_sm->link_mgr);
 	osm_drop_mgr_destroy(&p_sm->drop_mgr);
-	osm_state_mgr_destroy(&p_sm->state_mgr);
 	osm_sm_state_mgr_destroy(&p_sm->sm_state_mgr);
 	osm_mcast_mgr_destroy(&p_sm->mcast_mgr);
 	cl_event_wheel_destroy(&p_sm->trap_aging_tracker);
@@ -316,10 +317,6 @@ osm_sm_init(IN osm_sm_t * const p_sm,
 	if (status != IB_SUCCESS)
 		goto Exit;
 
-	status = osm_state_mgr_init(&p_sm->state_mgr, p_sm);
-	if (status != IB_SUCCESS)
-		goto Exit;
-
 	status = osm_drop_mgr_init(&p_sm->drop_mgr, p_sm);
 	if (status != IB_SUCCESS)
 		goto Exit;
@@ -396,6 +393,7 @@ osm_sm_init(IN osm_sm_t * const p_sm,
 	 * the sweeper thread if the user wants sweeping.
 	 */
 	p_sm->thread_state = OSM_THREAD_STATE_RUN;
+	p_sm->state = OSM_SM_STATE_IDLE;
 	status = cl_thread_init(&p_sm->sweeper, __osm_sm_sweeper, p_sm,
 				"opensm sweeper");
 	if (status != IB_SUCCESS)
diff --git a/opensm/opensm/osm_state_mgr.c b/opensm/opensm/osm_state_mgr.c
index 4dcb584..674ccf7 100644
--- a/opensm/opensm/osm_state_mgr.c
+++ b/opensm/opensm/osm_state_mgr.c
@@ -54,7 +54,6 @@
 #include <iba/ib_types.h>
 #include <complib/cl_passivelock.h>
 #include <complib/cl_debug.h>
-#include <opensm/osm_state_mgr.h>
 #include <opensm/osm_sm.h>
 #include <opensm/osm_madw.h>
 #include <opensm/osm_switch.h>
@@ -74,54 +73,7 @@ osm_signal_t osm_qos_setup(IN osm_opensm_t * p_osm);
 
 /**********************************************************************
  **********************************************************************/
-void osm_state_mgr_construct(IN osm_state_mgr_t * const p_mgr)
-{
-	memset(p_mgr, 0, sizeof(*p_mgr));
-	p_mgr->state = OSM_SM_STATE_INIT;
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_state_mgr_destroy(IN osm_state_mgr_t * const p_mgr)
-{
-	CL_ASSERT(p_mgr);
-
-	OSM_LOG_ENTER(p_mgr->p_log, osm_state_mgr_destroy);
-
-	OSM_LOG_EXIT(p_mgr->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_state_mgr_init(IN osm_state_mgr_t * const p_mgr, IN osm_sm_t * sm)
-{
-	OSM_LOG_ENTER(sm->p_log, osm_state_mgr_init);
-
-	osm_state_mgr_construct(p_mgr);
-
-	p_mgr->sm = sm;
-	p_mgr->p_log = sm->p_log;
-	p_mgr->p_subn = sm->p_subn;
-	p_mgr->p_lid_mgr = &sm->lid_mgr;
-	p_mgr->p_ucast_mgr = &sm->ucast_mgr;
-	p_mgr->p_mcast_mgr = &sm->mcast_mgr;
-	p_mgr->p_link_mgr = &sm->link_mgr;
-	p_mgr->p_drop_mgr = &sm->drop_mgr;
-	p_mgr->p_mad_ctrl = &sm->mad_ctrl;
-	p_mgr->p_stats = &sm->p_subn->p_osm->stats;
-	p_mgr->p_sm_state_mgr = &sm->sm_state_mgr;
-	p_mgr->state = OSM_SM_STATE_IDLE;
-	p_mgr->p_lock = sm->p_lock;
-	p_mgr->p_subnet_up_event = &sm->subnet_up_event;
-
-	OSM_LOG_EXIT(p_mgr->p_log);
-	return IB_SUCCESS;
-}
-
-/**********************************************************************
- **********************************************************************/
-static void __osm_state_mgr_up_msg(IN const osm_state_mgr_t * p_mgr)
+static void __osm_state_mgr_up_msg(IN const osm_sm_t *sm)
 {
 	/*
 	 * This message should be written only once - when the
@@ -129,16 +81,15 @@ static void __osm_state_mgr_up_msg(IN const osm_state_mgr_t * p_mgr)
 	 * the first time. The change of state is marked with
 	 * the subnet flag moved_to_master_state
 	 */
-	if (p_mgr->p_subn->moved_to_master_state == TRUE) {
-		osm_log(p_mgr->p_log, OSM_LOG_SYS, "SUBNET UP\n");	/* Format Waived */
+	if (sm->p_subn->moved_to_master_state == TRUE) {
+		osm_log(sm->p_log, OSM_LOG_SYS, "SUBNET UP\n");	/* Format Waived */
 		/* clear the signal */
-		p_mgr->p_subn->moved_to_master_state = FALSE;
-	} else {
-		osm_log(p_mgr->p_log, OSM_LOG_INFO, "SUBNET UP\n");	/* Format Waived */
-	}
+		sm->p_subn->moved_to_master_state = FALSE;
+	} else
+		osm_log(sm->p_log, OSM_LOG_INFO, "SUBNET UP\n");	/* Format Waived */
 
-	if (p_mgr->p_subn->opt.sweep_interval) {
-		osm_log(p_mgr->p_log, OSM_LOG_VERBOSE,
+	if (sm->p_subn->opt.sweep_interval)
+		osm_log(sm->p_log, OSM_LOG_VERBOSE,
 			"__osm_state_mgr_up_msg: "
 			"\n\n\n********************************"
 			"**********************************\n"
@@ -146,8 +97,8 @@ static void __osm_state_mgr_up_msg(IN const osm_state_mgr_t * p_mgr)
 			"***************************\n"
 			"**************************************"
 			"****************************\n\n\n");
-	} else {
-		osm_log(p_mgr->p_log, OSM_LOG_VERBOSE,
+	else
+		osm_log(sm->p_log, OSM_LOG_VERBOSE,
 			"__osm_state_mgr_up_msg: "
 			"\n\n\n********************************"
 			"**********************************\n"
@@ -155,16 +106,15 @@ static void __osm_state_mgr_up_msg(IN const osm_state_mgr_t * p_mgr)
 			"(sweep disabled) *******************\n"
 			"**************************************"
 			"****************************\n\n\n");
-	}
 }
 
 /**********************************************************************
  **********************************************************************/
-static void __osm_state_mgr_init_errors_msg(IN const osm_state_mgr_t * p_mgr)
+static void __osm_state_mgr_init_errors_msg(IN osm_log_t *log)
 {
-	osm_log(p_mgr->p_log, OSM_LOG_SYS, "Errors during initialization\n");	/* Format Waived */
+	osm_log(log, OSM_LOG_SYS, "Errors during initialization\n");	/* Format Waived */
 
-	osm_log(p_mgr->p_log, OSM_LOG_ERROR,
+	osm_log(log, OSM_LOG_ERROR,
 		"__osm_state_mgr_init_errors_msg: "
 		"\n\n\n********************************"
 		"**********************************\n"
@@ -176,11 +126,10 @@ static void __osm_state_mgr_init_errors_msg(IN const osm_state_mgr_t * p_mgr)
 
 /**********************************************************************
  **********************************************************************/
-static void __osm_state_mgr_light_sweep_done_msg(IN const osm_state_mgr_t *
-						 p_mgr)
+static void __osm_state_mgr_light_sweep_done_msg(IN osm_log_t *log)
 {
-	if (osm_log_is_active(p_mgr->p_log, OSM_LOG_VERBOSE)) {
-		osm_log(p_mgr->p_log, OSM_LOG_VERBOSE,
+	if (osm_log_is_active(log, OSM_LOG_VERBOSE))
+		osm_log(log, OSM_LOG_VERBOSE,
 			"__osm_state_mgr_light_sweep_done_msg: "
 			"\n\n\n********************************"
 			"**********************************\n"
@@ -188,15 +137,14 @@ static void __osm_state_mgr_light_sweep_done_msg(IN const osm_state_mgr_t *
 			"COMPLETE **********************\n"
 			"**************************************"
 			"****************************\n\n\n");
-	}
 }
 
 /**********************************************************************
  **********************************************************************/
-static void __osm_state_mgr_standby_msg(IN const osm_state_mgr_t * p_mgr)
+static void __osm_state_mgr_standby_msg(IN osm_log_t *log)
 {
-	if (osm_log_is_active(p_mgr->p_log, OSM_LOG_VERBOSE)) {
-		osm_log(p_mgr->p_log, OSM_LOG_VERBOSE,
+	if (osm_log_is_active(log, OSM_LOG_VERBOSE))
+		osm_log(log, OSM_LOG_VERBOSE,
 			"__osm_state_mgr_standby_msg: "
 			"\n\n\n********************************"
 			"**********************************\n"
@@ -204,17 +152,16 @@ static void __osm_state_mgr_standby_msg(IN const osm_state_mgr_t * p_mgr)
 			" STATE **********************\n"
 			"**************************************"
 			"****************************\n\n\n");
-	}
 }
 
 /**********************************************************************
  **********************************************************************/
-static void __osm_state_mgr_sm_port_down_msg(IN const osm_state_mgr_t * p_mgr)
+static void __osm_state_mgr_sm_port_down_msg(IN osm_log_t *log)
 {
-	osm_log(p_mgr->p_log, OSM_LOG_SYS, "SM port is down\n");	/* Format Waived */
+	osm_log(log, OSM_LOG_SYS, "SM port is down\n");	/* Format Waived */
 
-	if (osm_log_is_active(p_mgr->p_log, OSM_LOG_VERBOSE)) {
-		osm_log(p_mgr->p_log, OSM_LOG_VERBOSE,
+	if (osm_log_is_active(log, OSM_LOG_VERBOSE))
+		osm_log(log, OSM_LOG_VERBOSE,
 			"__osm_state_mgr_sm_port_down_msg: "
 			"\n\n\n********************************"
 			"**********************************\n"
@@ -222,15 +169,14 @@ static void __osm_state_mgr_sm_port_down_msg(IN const osm_state_mgr_t * p_mgr)
 			"**************************\n"
 			"**************************************"
 			"****************************\n\n\n");
-	}
 }
 
 /**********************************************************************
  **********************************************************************/
-static void __osm_state_mgr_lid_assign_msg(IN const osm_state_mgr_t * p_mgr)
+static void __osm_state_mgr_lid_assign_msg(IN osm_log_t *log)
 {
-	if (osm_log_is_active(p_mgr->p_log, OSM_LOG_VERBOSE)) {
-		osm_log(p_mgr->p_log, OSM_LOG_VERBOSE,
+	if (osm_log_is_active(log, OSM_LOG_VERBOSE))
+		osm_log(log, OSM_LOG_VERBOSE,
 			"__osm_state_mgr_lid_assign_msg: "
 			"\n\n\n**************************************"
 			"****************************\n"
@@ -238,16 +184,14 @@ static void __osm_state_mgr_lid_assign_msg(IN const osm_state_mgr_t * p_mgr)
 			"H TABLE CONFIG *****\n"
 			"*********************************************"
 			"*********************\n\n\n");
-	}
 }
 
 /**********************************************************************
  **********************************************************************/
-static void __osm_state_mgr_set_sm_lid_done_msg(IN const osm_state_mgr_t *
-						p_mgr)
+static void __osm_state_mgr_set_sm_lid_done_msg(IN osm_log_t *log)
 {
-	if (osm_log_is_active(p_mgr->p_log, OSM_LOG_VERBOSE)) {
-		osm_log(p_mgr->p_log, OSM_LOG_VERBOSE,
+	if (osm_log_is_active(log, OSM_LOG_VERBOSE))
+		osm_log(log, OSM_LOG_VERBOSE,
 			"__osm_state_mgr_set_sm_lid_done_msg: "
 			"\n\n\n**************************************"
 			"****************************\n"
@@ -255,15 +199,14 @@ static void __osm_state_mgr_set_sm_lid_done_msg(IN const osm_state_mgr_t *
 			"ET LID CONFIG *****\n"
 			"*********************************************"
 			"*********************\n\n\n");
-	}
 }
 
 /**********************************************************************
  **********************************************************************/
-static void __osm_state_mgr_switch_config_msg(IN const osm_state_mgr_t * p_mgr)
+static void __osm_state_mgr_switch_config_msg(IN osm_log_t *log)
 {
-	if (osm_log_is_active(p_mgr->p_log, OSM_LOG_VERBOSE)) {
-		osm_log(p_mgr->p_log, OSM_LOG_VERBOSE,
+	if (osm_log_is_active(log, OSM_LOG_VERBOSE))
+		osm_log(log, OSM_LOG_VERBOSE,
 			"__osm_state_mgr_switch_config_msg: "
 			"\n\n\n**************************************"
 			"****************************\n"
@@ -271,16 +214,14 @@ static void __osm_state_mgr_switch_config_msg(IN const osm_state_mgr_t * p_mgr)
 			"****************\n"
 			"*********************************************"
 			"*********************\n\n\n");
-	}
 }
 
 /**********************************************************************
  **********************************************************************/
-static void __osm_state_mgr_multicast_config_msg(IN const osm_state_mgr_t *
-						 p_mgr)
+static void __osm_state_mgr_multicast_config_msg(IN osm_log_t *log)
 {
-	if (osm_log_is_active(p_mgr->p_log, OSM_LOG_VERBOSE)) {
-		osm_log(p_mgr->p_log, OSM_LOG_VERBOSE,
+	if (osm_log_is_active(log, OSM_LOG_VERBOSE))
+		osm_log(log, OSM_LOG_VERBOSE,
 			"__osm_state_mgr_multicast_config_msg: "
 			"\n\n\n**************************************"
 			"****************************\n"
@@ -288,15 +229,14 @@ static void __osm_state_mgr_multicast_config_msg(IN const osm_state_mgr_t *
 			"***************\n"
 			"*********************************************"
 			"*********************\n\n\n");
-	}
 }
 
 /**********************************************************************
  **********************************************************************/
-static void __osm_state_mgr_links_ports_msg(IN const osm_state_mgr_t * p_mgr)
+static void __osm_state_mgr_links_ports_msg(IN osm_log_t *log)
 {
-	if (osm_log_is_active(p_mgr->p_log, OSM_LOG_VERBOSE)) {
-		osm_log(p_mgr->p_log, OSM_LOG_VERBOSE,
+	if (osm_log_is_active(log, OSM_LOG_VERBOSE))
+		osm_log(log, OSM_LOG_VERBOSE,
 			"__osm_state_mgr_links_ports_msg: "
 			"\n\n\n**************************************"
 			"****************************\n"
@@ -304,15 +244,14 @@ static void __osm_state_mgr_links_ports_msg(IN const osm_state_mgr_t * p_mgr)
 			"STATE ********\n"
 			"*********************************************"
 			"*********************\n\n\n");
-	}
 }
 
 /**********************************************************************
  **********************************************************************/
-static void __osm_state_mgr_links_armed_msg(IN const osm_state_mgr_t * p_mgr)
+static void __osm_state_mgr_links_armed_msg(IN osm_log_t *log)
 {
-	if (osm_log_is_active(p_mgr->p_log, OSM_LOG_VERBOSE)) {
-		osm_log(p_mgr->p_log, OSM_LOG_VERBOSE,
+	if (osm_log_is_active(log, OSM_LOG_VERBOSE))
+		osm_log(log, OSM_LOG_VERBOSE,
 			"__osm_state_mgr_links_armed_msg: "
 			"\n\n\n**************************************"
 			"****************************\n"
@@ -320,15 +259,14 @@ static void __osm_state_mgr_links_armed_msg(IN const osm_state_mgr_t * p_mgr)
 			"STATE ************\n"
 			"*********************************************"
 			"*********************\n\n\n");
-	}
 }
 
 /**********************************************************************
  **********************************************************************/
-static void __osm_state_mgr_sweep_heavy_msg(IN const osm_state_mgr_t * p_mgr)
+static void __osm_state_mgr_sweep_heavy_msg(IN osm_log_t *log)
 {
-	if (osm_log_is_active(p_mgr->p_log, OSM_LOG_VERBOSE)) {
-		osm_log(p_mgr->p_log, OSM_LOG_VERBOSE,
+	if (osm_log_is_active(log, OSM_LOG_VERBOSE))
+		osm_log(log, OSM_LOG_VERBOSE,
 			"__osm_state_mgr_sweep_heavy_msg: "
 			"\n\n\n**************************************"
 			"****************************\n"
@@ -336,16 +274,14 @@ static void __osm_state_mgr_sweep_heavy_msg(IN const osm_state_mgr_t * p_mgr)
 			"**********************\n"
 			"*********************************************"
 			"*********************\n\n\n");
-	}
 }
 
 /**********************************************************************
  **********************************************************************/
-static void __osm_state_mgr_sweep_heavy_done_msg(IN const osm_state_mgr_t *
-						 p_mgr)
+static void __osm_state_mgr_sweep_heavy_done_msg(IN osm_log_t *log)
 {
-	if (osm_log_is_active(p_mgr->p_log, OSM_LOG_VERBOSE)) {
-		osm_log(p_mgr->p_log, OSM_LOG_VERBOSE,
+	if (osm_log_is_active(log, OSM_LOG_VERBOSE))
+		osm_log(log, OSM_LOG_VERBOSE,
 			"__osm_state_mgr_sweep_heavy_done_msg: "
 			"\n\n\n**************************************"
 			"****************************\n"
@@ -353,15 +289,14 @@ static void __osm_state_mgr_sweep_heavy_done_msg(IN const osm_state_mgr_t *
 			"***********************\n"
 			"*********************************************"
 			"*********************\n\n\n");
-	}
 }
 
 /**********************************************************************
  **********************************************************************/
-static void __osm_state_mgr_sweep_light_msg(IN const osm_state_mgr_t * p_mgr)
+static void __osm_state_mgr_sweep_light_msg(IN osm_log_t *log)
 {
-	if (osm_log_is_active(p_mgr->p_log, OSM_LOG_VERBOSE)) {
-		osm_log(p_mgr->p_log, OSM_LOG_VERBOSE,
+	if (osm_log_is_active(log, OSM_LOG_VERBOSE))
+		osm_log(log, OSM_LOG_VERBOSE,
 			"__osm_state_mgr_sweep_light_msg: "
 			"\n\n\n**************************************"
 			"****************************\n"
@@ -369,38 +304,37 @@ static void __osm_state_mgr_sweep_light_msg(IN const osm_state_mgr_t * p_mgr)
 			"**********************\n"
 			"*********************************************"
 			"*********************\n\n\n");
-	}
 }
 
 /**********************************************************************
  **********************************************************************/
 static void
-__osm_state_mgr_signal_warning(IN const osm_state_mgr_t * const p_mgr,
+__osm_state_mgr_signal_warning(IN osm_sm_t *sm,
 			       IN const osm_signal_t signal)
 {
-	osm_log(p_mgr->p_log, OSM_LOG_VERBOSE,
+	osm_log(sm->p_log, OSM_LOG_VERBOSE,
 		"__osm_state_mgr_signal_warning: "
 		"Invalid signal %s(%lu) in state %s\n",
 		osm_get_sm_signal_str(signal), signal,
-		osm_get_sm_state_str(p_mgr->state));
+		osm_get_sm_state_str(sm->state));
 }
 
 /**********************************************************************
  **********************************************************************/
 static void
-__osm_state_mgr_signal_error(IN const osm_state_mgr_t * const p_mgr,
+__osm_state_mgr_signal_error(IN osm_sm_t *sm,
 			     IN const osm_signal_t signal)
 {
 	/* the Request for IDLE processing can come async to the state so it
 	 * really is just verbose ... */
 	if (signal == OSM_SIGNAL_IDLE_TIME_PROCESS_REQUEST)
-		__osm_state_mgr_signal_warning(p_mgr, signal);
+		__osm_state_mgr_signal_warning(sm, signal);
 	else
-		osm_log(p_mgr->p_log, OSM_LOG_ERROR,
+		osm_log(sm->p_log, OSM_LOG_ERROR,
 			"__osm_state_mgr_signal_error: ERR 3303: "
 			"Invalid signal %s(%lu) in state %s\n",
 			osm_get_sm_signal_str(signal), signal,
-			osm_get_sm_state_str(p_mgr->state));
+			osm_get_sm_state_str(sm->state));
 }
 
 /**********************************************************************
@@ -409,10 +343,10 @@ static void __osm_state_mgr_reset_node_count(IN cl_map_item_t *
 					     const p_map_item, IN void *context)
 {
 	osm_node_t *p_node = (osm_node_t *) p_map_item;
-	osm_state_mgr_t *const p_mgr = (osm_state_mgr_t *) context;
+	osm_sm_t *sm = context;
 
-	if (osm_log_is_active(p_mgr->p_log, OSM_LOG_DEBUG)) {
-		osm_log(p_mgr->p_log, OSM_LOG_DEBUG,
+	if (osm_log_is_active(sm->p_log, OSM_LOG_DEBUG)) {
+		osm_log(sm->p_log, OSM_LOG_DEBUG,
 			"__osm_state_mgr_reset_node_count: "
 			"Resetting discovery count for node 0x%" PRIx64 "(%s)\n",
 			cl_ntoh64(osm_node_get_node_guid(p_node)),
@@ -428,10 +362,10 @@ static void __osm_state_mgr_reset_port_count(IN cl_map_item_t *
 					     const p_map_item, IN void *context)
 {
 	osm_port_t *p_port = (osm_port_t *) p_map_item;
-	osm_state_mgr_t *const p_mgr = (osm_state_mgr_t *) context;
+	osm_sm_t *sm = context;
 
-	if (osm_log_is_active(p_mgr->p_log, OSM_LOG_DEBUG)) {
-		osm_log(p_mgr->p_log, OSM_LOG_DEBUG,
+	if (osm_log_is_active(sm->p_log, OSM_LOG_DEBUG)) {
+		osm_log(sm->p_log, OSM_LOG_DEBUG,
 			"__osm_state_mgr_reset_port_count: "
 			"Resetting discovery count for port 0x%" PRIx64 "(node %s)\n",
 			cl_ntoh64(osm_port_get_guid(p_port)),
@@ -448,10 +382,10 @@ __osm_state_mgr_reset_switch_count(IN cl_map_item_t * const p_map_item,
 				   IN void *context)
 {
 	osm_switch_t *p_sw = (osm_switch_t *) p_map_item;
-	osm_state_mgr_t *const p_mgr = (osm_state_mgr_t *) context;
+	osm_sm_t *sm = context;
 
-	if (osm_log_is_active(p_mgr->p_log, OSM_LOG_DEBUG)) {
-		osm_log(p_mgr->p_log, OSM_LOG_DEBUG,
+	if (osm_log_is_active(sm->p_log, OSM_LOG_DEBUG)) {
+		osm_log(sm->p_log, OSM_LOG_DEBUG,
 			"__osm_state_mgr_reset_switch_count: "
 			"Resetting discovery count for switch 0x%" PRIx64 " (%s)\n",
 			cl_ntoh64(osm_node_get_node_guid(p_sw->p_node)),
@@ -471,10 +405,10 @@ static void __osm_state_mgr_get_sw_info(IN cl_map_item_t * const p_object,
 	osm_dr_path_t *p_dr_path;
 	osm_madw_context_t mad_context;
 	osm_switch_t *const p_sw = (osm_switch_t *) p_object;
-	osm_state_mgr_t *const p_mgr = (osm_state_mgr_t *) context;
+	osm_sm_t *sm = context;
 	ib_api_status_t status;
 
-	OSM_LOG_ENTER(p_mgr->p_log, __osm_state_mgr_get_sw_info);
+	OSM_LOG_ENTER(sm->p_log, __osm_state_mgr_get_sw_info);
 
 	p_node = p_sw->p_node;
 	p_dr_path = osm_node_get_any_dr_path_ptr(p_node);
@@ -485,23 +419,23 @@ static void __osm_state_mgr_get_sw_info(IN cl_map_item_t * const p_object,
 	mad_context.si_context.set_method = FALSE;
 	mad_context.si_context.light_sweep = TRUE;
 
-	status = osm_req_get(p_mgr->sm, p_dr_path, IB_MAD_ATTR_SWITCH_INFO, 0,
+	status = osm_req_get(sm, p_dr_path, IB_MAD_ATTR_SWITCH_INFO, 0,
 			     OSM_MSG_LIGHT_SWEEP_FAIL, &mad_context);
 
 	if (status != IB_SUCCESS) {
-		osm_log(p_mgr->p_log, OSM_LOG_ERROR,
+		osm_log(sm->p_log, OSM_LOG_ERROR,
 			"__osm_state_mgr_get_sw_info: ERR 3304: "
 			"Request for SwitchInfo failed\n");
 	}
 
-	OSM_LOG_EXIT(p_mgr->p_log);
+	OSM_LOG_EXIT(sm->p_log);
 }
 
 /**********************************************************************
  Initiate a remote port info request for the given physical port
  **********************************************************************/
 static void
-__osm_state_mgr_get_remote_port_info(IN osm_state_mgr_t * const p_mgr,
+__osm_state_mgr_get_remote_port_info(IN osm_sm_t *sm,
 				     IN osm_physp_t * const p_physp)
 {
 	osm_dr_path_t *p_dr_path;
@@ -509,7 +443,7 @@ __osm_state_mgr_get_remote_port_info(IN osm_state_mgr_t * const p_mgr,
 	osm_madw_context_t mad_context;
 	ib_api_status_t status;
 
-	OSM_LOG_ENTER(p_mgr->p_log, __osm_state_mgr_get_remote_port_info);
+	OSM_LOG_ENTER(sm->p_log, __osm_state_mgr_get_remote_port_info);
 
 	/* generate a dr path leaving on the physp to the remote node */
 	p_dr_path = osm_physp_get_dr_path_ptr(p_physp);
@@ -529,56 +463,55 @@ __osm_state_mgr_get_remote_port_info(IN osm_state_mgr_t * const p_mgr,
 
 	/* note that with some negative logic - if the query failed it means that
 	 * there is no point in going to heavy sweep */
-	status = osm_req_get(p_mgr->sm, &rem_node_dr_path,
+	status = osm_req_get(sm, &rem_node_dr_path,
 			     IB_MAD_ATTR_PORT_INFO, 0, CL_DISP_MSGID_NONE,
 			     &mad_context);
 
 	if (status != IB_SUCCESS) {
-		osm_log(p_mgr->p_log, OSM_LOG_ERROR,
+		osm_log(sm->p_log, OSM_LOG_ERROR,
 			"__osm_state_mgr_get_remote_port_info: ERR 332E: "
 			"Request for PortInfo failed\n");
 	}
 
-	OSM_LOG_EXIT(p_mgr->p_log);
+	OSM_LOG_EXIT(sm->p_log);
 }
 
 /**********************************************************************
  Initiates a thorough sweep of the subnet.
  Used when there is suspicion that something on the subnet has changed.
 **********************************************************************/
-static ib_api_status_t __osm_state_mgr_sweep_hop_0(IN osm_state_mgr_t *
-						   const p_mgr)
+static ib_api_status_t __osm_state_mgr_sweep_hop_0(IN osm_sm_t *sm)
 {
 	ib_api_status_t status;
 	osm_dr_path_t dr_path;
 	osm_bind_handle_t h_bind;
 	uint8_t path_array[IB_SUBNET_PATH_HOPS_MAX];
 
-	OSM_LOG_ENTER(p_mgr->p_log, __osm_state_mgr_sweep_hop_0);
+	OSM_LOG_ENTER(sm->p_log, __osm_state_mgr_sweep_hop_0);
 
 	memset(path_array, 0, sizeof(path_array));
 
 	/*
 	 * First, get the bind handle.
 	 */
-	h_bind = osm_sm_mad_ctrl_get_bind_handle(p_mgr->p_mad_ctrl);
+	h_bind = osm_sm_mad_ctrl_get_bind_handle(&sm->mad_ctrl);
 	if (h_bind != OSM_BIND_INVALID_HANDLE) {
-		__osm_state_mgr_sweep_heavy_msg(p_mgr);
+		__osm_state_mgr_sweep_heavy_msg(sm->p_log);
 
 		/*
 		 * Start the sweep by clearing the port counts, then
 		 * get our own NodeInfo at 0 hops.
 		 */
-		CL_PLOCK_ACQUIRE(p_mgr->p_lock);
+		CL_PLOCK_ACQUIRE(sm->p_lock);
 
-		cl_qmap_apply_func(&p_mgr->p_subn->node_guid_tbl,
-				   __osm_state_mgr_reset_node_count, p_mgr);
+		cl_qmap_apply_func(&sm->p_subn->node_guid_tbl,
+				   __osm_state_mgr_reset_node_count, sm);
 
-		cl_qmap_apply_func(&p_mgr->p_subn->port_guid_tbl,
-				   __osm_state_mgr_reset_port_count, p_mgr);
+		cl_qmap_apply_func(&sm->p_subn->port_guid_tbl,
+				   __osm_state_mgr_reset_port_count, sm);
 
-		cl_qmap_apply_func(&p_mgr->p_subn->sw_guid_tbl,
-				   __osm_state_mgr_reset_switch_count, p_mgr);
+		cl_qmap_apply_func(&sm->p_subn->sw_guid_tbl,
+				   __osm_state_mgr_reset_switch_count, sm);
 
 		/* Set the in_sweep_hop_0 flag in subn to be TRUE.
 		 * This will indicate the sweeping not to continue beyond the
@@ -586,52 +519,51 @@ static ib_api_status_t __osm_state_mgr_sweep_hop_0(IN osm_state_mgr_t *
 		 * This is relevant for the case of SM on switch, since in the
 		 * switch info we need to signal somehow not to continue
 		 * the sweeping. */
-		p_mgr->p_subn->in_sweep_hop_0 = TRUE;
+		sm->p_subn->in_sweep_hop_0 = TRUE;
 
-		CL_PLOCK_RELEASE(p_mgr->p_lock);
+		CL_PLOCK_RELEASE(sm->p_lock);
 
 		osm_dr_path_init(&dr_path, h_bind, 0, path_array);
-		status = osm_req_get(p_mgr->sm,
+		status = osm_req_get(sm,
 				     &dr_path, IB_MAD_ATTR_NODE_INFO, 0,
 				     CL_DISP_MSGID_NONE, NULL);
 
 		if (status != IB_SUCCESS) {
-			osm_log(p_mgr->p_log, OSM_LOG_ERROR,
+			osm_log(sm->p_log, OSM_LOG_ERROR,
 				"__osm_state_mgr_sweep_hop_0: ERR 3305: "
 				"Request for NodeInfo failed\n");
 		}
 	} else {
-		osm_log(p_mgr->p_log, OSM_LOG_DEBUG,
+		osm_log(sm->p_log, OSM_LOG_DEBUG,
 			"__osm_state_mgr_sweep_hop_0: "
 			"No bound ports. Deferring sweep...\n");
 		status = IB_INVALID_STATE;
 	}
 
-	OSM_LOG_EXIT(p_mgr->p_log);
+	OSM_LOG_EXIT(sm->p_log);
 	return (status);
 }
 
 /**********************************************************************
  Clear out all existing port lid assignments
 **********************************************************************/
-static ib_api_status_t __osm_state_mgr_clean_known_lids(IN osm_state_mgr_t *
-							const p_mgr)
+static ib_api_status_t __osm_state_mgr_clean_known_lids(IN osm_sm_t *sm)
 {
 	ib_api_status_t status = IB_SUCCESS;
-	cl_ptr_vector_t *p_vec = &(p_mgr->p_subn->port_lid_tbl);
+	cl_ptr_vector_t *p_vec = &(sm->p_subn->port_lid_tbl);
 	uint32_t i;
 
-	OSM_LOG_ENTER(p_mgr->p_log, __osm_state_mgr_clean_known_lids);
+	OSM_LOG_ENTER(sm->p_log, __osm_state_mgr_clean_known_lids);
 
 	/* we need a lock here! */
-	CL_PLOCK_ACQUIRE(p_mgr->p_lock);
+	CL_PLOCK_ACQUIRE(sm->p_lock);
 
 	for (i = 0; i < cl_ptr_vector_get_size(p_vec); i++)
 		cl_ptr_vector_set(p_vec, i, NULL);
 
-	CL_PLOCK_RELEASE(p_mgr->p_lock);
+	CL_PLOCK_RELEASE(sm->p_lock);
 
-	OSM_LOG_EXIT(p_mgr->p_log);
+	OSM_LOG_EXIT(sm->p_log);
 	return (status);
 }
 
@@ -639,20 +571,19 @@ static ib_api_status_t __osm_state_mgr_clean_known_lids(IN osm_state_mgr_t *
  Notifies the transport layer that the local LID has changed,
  which give it a chance to update address vectors, etc..
 **********************************************************************/
-static ib_api_status_t __osm_state_mgr_notify_lid_change(IN osm_state_mgr_t *
-							 const p_mgr)
+static ib_api_status_t __osm_state_mgr_notify_lid_change(IN osm_sm_t *sm)
 {
 	ib_api_status_t status;
 	osm_bind_handle_t h_bind;
 
-	OSM_LOG_ENTER(p_mgr->p_log, __osm_state_mgr_notify_lid_change);
+	OSM_LOG_ENTER(sm->p_log, __osm_state_mgr_notify_lid_change);
 
 	/*
 	 * First, get the bind handle.
 	 */
-	h_bind = osm_sm_mad_ctrl_get_bind_handle(p_mgr->p_mad_ctrl);
+	h_bind = osm_sm_mad_ctrl_get_bind_handle(&sm->mad_ctrl);
 	if (h_bind == OSM_BIND_INVALID_HANDLE) {
-		osm_log(p_mgr->p_log, OSM_LOG_ERROR,
+		osm_log(sm->p_log, OSM_LOG_ERROR,
 			"__osm_state_mgr_notify_lid_change: ERR 3306: "
 			"No bound ports\n");
 		status = IB_ERROR;
@@ -664,14 +595,14 @@ static ib_api_status_t __osm_state_mgr_notify_lid_change(IN osm_state_mgr_t *
 	 */
 	status = osm_vendor_local_lid_change(h_bind);
 	if (status != IB_SUCCESS) {
-		osm_log(p_mgr->p_log, OSM_LOG_ERROR,
+		osm_log(sm->p_log, OSM_LOG_ERROR,
 			"__osm_state_mgr_notify_lid_change: ERR 3307: "
 			"Vendor LID update failed (%s)\n",
 			ib_get_err_str(status));
 	}
 
       Exit:
-	OSM_LOG_EXIT(p_mgr->p_log);
+	OSM_LOG_EXIT(sm->p_log);
 	return (status);
 }
 
@@ -679,23 +610,22 @@ static ib_api_status_t __osm_state_mgr_notify_lid_change(IN osm_state_mgr_t *
  Returns true if the SM port is down.
  The SM's port object must exist in the port_guid table.
 **********************************************************************/
-static boolean_t __osm_state_mgr_is_sm_port_down(IN osm_state_mgr_t *
-						 const p_mgr)
+static boolean_t __osm_state_mgr_is_sm_port_down(IN osm_sm_t *sm)
 {
 	ib_net64_t port_guid;
 	osm_port_t *p_port;
 	osm_physp_t *p_physp;
 	uint8_t state;
 
-	OSM_LOG_ENTER(p_mgr->p_log, __osm_state_mgr_is_sm_port_down);
+	OSM_LOG_ENTER(sm->p_log, __osm_state_mgr_is_sm_port_down);
 
-	port_guid = p_mgr->p_subn->sm_port_guid;
+	port_guid = sm->p_subn->sm_port_guid;
 
 	/*
 	 * If we don't know our own port guid yet, assume the port is down.
 	 */
 	if (port_guid == 0) {
-		osm_log(p_mgr->p_log, OSM_LOG_ERROR,
+		osm_log(sm->p_log, OSM_LOG_ERROR,
 			"__osm_state_mgr_is_sm_port_down: ERR 3308: "
 			"SM port GUID unknown\n");
 		state = IB_LINK_DOWN;
@@ -704,16 +634,16 @@ static boolean_t __osm_state_mgr_is_sm_port_down(IN osm_state_mgr_t *
 
 	CL_ASSERT(port_guid);
 
-	CL_PLOCK_ACQUIRE(p_mgr->p_lock);
-	p_port = osm_get_port_by_guid(p_mgr->p_subn, port_guid);
+	CL_PLOCK_ACQUIRE(sm->p_lock);
+	p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
 	if (!p_port) {
-		osm_log(p_mgr->p_log, OSM_LOG_ERROR,
+		osm_log(sm->p_log, OSM_LOG_ERROR,
 			"__osm_state_mgr_is_sm_port_down: ERR 3309: "
 			"SM port with GUID:%016" PRIx64 " (%s) is unknown\n",
 			cl_ntoh64(port_guid),
 			p_port->p_node ? p_port->p_node->print_desc : "UNKNOWN");
 		state = IB_LINK_DOWN;
-		CL_PLOCK_RELEASE(p_mgr->p_lock);
+		CL_PLOCK_RELEASE(sm->p_lock);
 		goto Exit;
 	}
 
@@ -722,10 +652,10 @@ static boolean_t __osm_state_mgr_is_sm_port_down(IN osm_state_mgr_t *
 	CL_ASSERT(p_physp);
 
 	state = osm_physp_get_port_state(p_physp);
-	CL_PLOCK_RELEASE(p_mgr->p_lock);
+	CL_PLOCK_RELEASE(sm->p_lock);
 
       Exit:
-	OSM_LOG_EXIT(p_mgr->p_log);
+	OSM_LOG_EXIT(sm->p_log);
 	return (state == IB_LINK_DOWN);
 }
 
@@ -734,8 +664,7 @@ static boolean_t __osm_state_mgr_is_sm_port_down(IN osm_state_mgr_t *
  This sets off a "chain reaction" that causes discovery of the subnet.
  Used when there is suspicion that something on the subnet has changed.
 **********************************************************************/
-static ib_api_status_t __osm_state_mgr_sweep_hop_1(IN osm_state_mgr_t *
-						   const p_mgr)
+static ib_api_status_t __osm_state_mgr_sweep_hop_1(IN osm_sm_t *sm)
 {
 	ib_api_status_t status = IB_SUCCESS;
 	osm_bind_handle_t h_bind;
@@ -751,12 +680,12 @@ static ib_api_status_t __osm_state_mgr_sweep_hop_1(IN osm_state_mgr_t *
 	uint8_t num_ports;
 	osm_physp_t *p_ext_physp;
 
-	OSM_LOG_ENTER(p_mgr->p_log, __osm_state_mgr_sweep_hop_1);
+	OSM_LOG_ENTER(sm->p_log, __osm_state_mgr_sweep_hop_1);
 
 	/*
 	 * First, get our own port and node objects.
 	 */
-	port_guid = p_mgr->p_subn->sm_port_guid;
+	port_guid = sm->p_subn->sm_port_guid;
 
 	CL_ASSERT(port_guid);
 
@@ -766,11 +695,11 @@ static ib_api_status_t __osm_state_mgr_sweep_hop_1(IN osm_state_mgr_t *
 	 * This is relevant for the case of SM on switch, since in the
 	 * switch info we need to signal that the sweeping should
 	 * continue through the switch. */
-	p_mgr->p_subn->in_sweep_hop_0 = FALSE;
+	sm->p_subn->in_sweep_hop_0 = FALSE;
 
-	p_port = osm_get_port_by_guid(p_mgr->p_subn, port_guid);
+	p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
 	if (!p_port) {
-		osm_log(p_mgr->p_log, OSM_LOG_ERROR,
+		osm_log(sm->p_log, OSM_LOG_ERROR,
 			"__osm_state_mgr_sweep_hop_1: ERR 3310: "
 			"No SM port object\n");
 		status = IB_ERROR;
@@ -782,7 +711,7 @@ static ib_api_status_t __osm_state_mgr_sweep_hop_1(IN osm_state_mgr_t *
 
 	port_num = ib_node_info_get_local_port_num(&p_node->node_info);
 
-	osm_log(p_mgr->p_log, OSM_LOG_DEBUG,
+	osm_log(sm->p_log, OSM_LOG_DEBUG,
 		"__osm_state_mgr_sweep_hop_1: "
 		"Probing hop 1 on local port %u\n", port_num);
 
@@ -808,12 +737,12 @@ static ib_api_status_t __osm_state_mgr_sweep_hop_1(IN osm_state_mgr_t *
 		path_array[1] = port_num;
 
 		osm_dr_path_init(&hop_1_path, h_bind, 1, path_array);
-		status = osm_req_get(p_mgr->sm, &hop_1_path,
+		status = osm_req_get(sm, &hop_1_path,
 				     IB_MAD_ATTR_NODE_INFO, 0,
 				     CL_DISP_MSGID_NONE, &context);
 
 		if (status != IB_SUCCESS) {
-			osm_log(p_mgr->p_log, OSM_LOG_ERROR,
+			osm_log(sm->p_log, OSM_LOG_ERROR,
 				"__osm_state_mgr_sweep_hop_1: ERR 3311: "
 				"Request for NodeInfo failed\n");
 		}
@@ -843,12 +772,12 @@ static ib_api_status_t __osm_state_mgr_sweep_hop_1(IN osm_state_mgr_t *
 				osm_dr_path_init(&hop_1_path, h_bind, 1,
 						 path_array);
 				status =
-				    osm_req_get(p_mgr->sm, &hop_1_path,
+				    osm_req_get(sm, &hop_1_path,
 						IB_MAD_ATTR_NODE_INFO, 0,
 						CL_DISP_MSGID_NONE, &context);
 
 				if (status != IB_SUCCESS) {
-					osm_log(p_mgr->p_log, OSM_LOG_ERROR,
+					osm_log(sm->p_log, OSM_LOG_ERROR,
 						"__osm_state_mgr_sweep_hop_1: ERR 3312: "
 						"Request for NodeInfo failed\n");
 				}
@@ -857,14 +786,14 @@ static ib_api_status_t __osm_state_mgr_sweep_hop_1(IN osm_state_mgr_t *
 		break;
 
 	default:
-		osm_log(p_mgr->p_log, OSM_LOG_ERROR,
+		osm_log(sm->p_log, OSM_LOG_ERROR,
 			"__osm_state_mgr_sweep_hop_1: ERR 3313: Unknown node type %d (%s)\n",
 			osm_node_get_type(p_node),
 			p_node->print_desc);
 	}
 
       Exit:
-	OSM_LOG_EXIT(p_mgr->p_log);
+	OSM_LOG_EXIT(sm->p_log);
 	return (status);
 }
 
@@ -872,8 +801,7 @@ static ib_api_status_t __osm_state_mgr_sweep_hop_1(IN osm_state_mgr_t *
  Initiates a lightweight sweep of the subnet.
  Used during normal sweeps after the subnet is up.
 **********************************************************************/
-static ib_api_status_t __osm_state_mgr_light_sweep_start(IN osm_state_mgr_t *
-							 const p_mgr)
+static ib_api_status_t __osm_state_mgr_light_sweep_start(IN osm_sm_t *sm)
 {
 	ib_api_status_t status = IB_SUCCESS;
 	osm_bind_handle_t h_bind;
@@ -883,25 +811,24 @@ static ib_api_status_t __osm_state_mgr_light_sweep_start(IN osm_state_mgr_t *
 	osm_physp_t *p_physp;
 	uint8_t port_num;
 
-	OSM_LOG_ENTER(p_mgr->p_log, __osm_state_mgr_light_sweep_start);
+	OSM_LOG_ENTER(sm->p_log, __osm_state_mgr_light_sweep_start);
 
-	p_sw_tbl = &p_mgr->p_subn->sw_guid_tbl;
+	p_sw_tbl = &sm->p_subn->sw_guid_tbl;
 
 	/*
 	 * First, get the bind handle.
 	 */
-	h_bind = osm_sm_mad_ctrl_get_bind_handle(p_mgr->p_mad_ctrl);
+	h_bind = osm_sm_mad_ctrl_get_bind_handle(&sm->mad_ctrl);
 	if (h_bind != OSM_BIND_INVALID_HANDLE) {
-		__osm_state_mgr_sweep_light_msg(p_mgr);
-		CL_PLOCK_ACQUIRE(p_mgr->p_lock);
-		cl_qmap_apply_func(p_sw_tbl, __osm_state_mgr_get_sw_info,
-				   p_mgr);
-		CL_PLOCK_RELEASE(p_mgr->p_lock);
+		__osm_state_mgr_sweep_light_msg(sm->p_log);
+		CL_PLOCK_ACQUIRE(sm->p_lock);
+		cl_qmap_apply_func(p_sw_tbl, __osm_state_mgr_get_sw_info, sm);
+		CL_PLOCK_RELEASE(sm->p_lock);
 
 		/* now scan the list of physical ports that were not down but have no remote port */
-		CL_PLOCK_ACQUIRE(p_mgr->p_lock);
-		p_next = cl_qmap_head(&p_mgr->p_subn->node_guid_tbl);
-		while (p_next != cl_qmap_end(&p_mgr->p_subn->node_guid_tbl)) {
+		CL_PLOCK_ACQUIRE(sm->p_lock);
+		p_next = cl_qmap_head(&sm->p_subn->node_guid_tbl);
+		while (p_next != cl_qmap_end(&sm->p_subn->node_guid_tbl)) {
 			p_node = (osm_node_t *) p_next;
 			p_next = cl_qmap_next(p_next);
 
@@ -914,7 +841,7 @@ static ib_api_status_t __osm_state_mgr_light_sweep_start(IN osm_state_mgr_t *
 				    && (osm_physp_get_port_state(p_physp) !=
 					IB_LINK_DOWN)
 				    && !osm_physp_get_remote(p_physp)) {
-					osm_log(p_mgr->p_log, OSM_LOG_ERROR,
+					osm_log(sm->p_log, OSM_LOG_ERROR,
 						"__osm_state_mgr_light_sweep_start: ERR 0108: "
 						"Unknown remote side for node 0x%016"
 						PRIx64
@@ -922,25 +849,25 @@ static ib_api_status_t __osm_state_mgr_light_sweep_start(IN osm_state_mgr_t *
 						cl_ntoh64(osm_node_get_node_guid
 							  (p_node)), p_node->print_desc, port_num);
 
-					osm_dump_dr_path(p_mgr->p_log,
+					osm_dump_dr_path(sm->p_log,
 							 osm_physp_get_dr_path_ptr
 							 (p_physp),
 							 OSM_LOG_ERROR);
 
 					__osm_state_mgr_get_remote_port_info
-					    (p_mgr, p_physp);
+					    (sm, p_physp);
 				}
 			}
 		}
-		CL_PLOCK_RELEASE(p_mgr->p_lock);
+		CL_PLOCK_RELEASE(sm->p_lock);
 	} else {
-		osm_log(p_mgr->p_log, OSM_LOG_DEBUG,
+		osm_log(sm->p_log, OSM_LOG_DEBUG,
 			"__osm_state_mgr_light_sweep_start: "
 			"No bound ports. Deferring sweep...\n");
 		status = IB_INVALID_STATE;
 	}
 
-	OSM_LOG_EXIT(p_mgr->p_log);
+	OSM_LOG_EXIT(sm->p_log);
 	return (status);
 }
 
@@ -950,17 +877,15 @@ static ib_api_status_t __osm_state_mgr_light_sweep_start(IN osm_state_mgr_t *
  * If there is a remote master SM - return a pointer to it,
  * else - return NULL.
  **********************************************************************/
-static osm_remote_sm_t *__osm_state_mgr_exists_other_master_sm(IN
-							       osm_state_mgr_t *
-							       const p_mgr)
+static osm_remote_sm_t *__osm_state_mgr_exists_other_master_sm(IN osm_sm_t *sm)
 {
 	cl_qmap_t *p_sm_tbl;
 	osm_remote_sm_t *p_sm;
 	osm_remote_sm_t *p_sm_res = NULL;
 
-	OSM_LOG_ENTER(p_mgr->p_log, __osm_state_mgr_exists_other_master_sm);
+	OSM_LOG_ENTER(sm->p_log, __osm_state_mgr_exists_other_master_sm);
 
-	p_sm_tbl = &p_mgr->p_subn->sm_guid_tbl;
+	p_sm_tbl = &sm->p_subn->sm_guid_tbl;
 
 	/* go over all the remote SMs */
 	for (p_sm = (osm_remote_sm_t *) cl_qmap_head(p_sm_tbl);
@@ -968,7 +893,7 @@ static osm_remote_sm_t *__osm_state_mgr_exists_other_master_sm(IN
 	     p_sm = (osm_remote_sm_t *) cl_qmap_next(&p_sm->map_item)) {
 		/* If the sm is in MASTER state - return a pointer to it */
 		if (ib_sminfo_get_state(&p_sm->smi) == IB_SMINFO_STATE_MASTER) {
-			osm_log(p_mgr->p_log, OSM_LOG_VERBOSE,
+			osm_log(sm->p_log, OSM_LOG_VERBOSE,
 				"__osm_state_mgr_exists_other_master_sm: "
 				"Found remote master SM with guid:0x%016" PRIx64
 				" (node %s)\n", cl_ntoh64(p_sm->smi.guid),
@@ -979,7 +904,7 @@ static osm_remote_sm_t *__osm_state_mgr_exists_other_master_sm(IN
 	}
 
       Exit:
-	OSM_LOG_EXIT(p_mgr->p_log);
+	OSM_LOG_EXIT(sm->p_log);
 	return (p_sm_res);
 }
 
@@ -989,8 +914,7 @@ static osm_remote_sm_t *__osm_state_mgr_exists_other_master_sm(IN
  * Compare this SM to the local SM. If the local SM is higher -
  * return NULL, if the remote SM is higher - return a pointer to it.
  **********************************************************************/
-static osm_remote_sm_t *__osm_state_mgr_get_highest_sm(IN osm_state_mgr_t *
-						       const p_mgr)
+static osm_remote_sm_t *__osm_state_mgr_get_highest_sm(IN osm_sm_t *sm)
 {
 	cl_qmap_t *p_sm_tbl;
 	osm_remote_sm_t *p_sm = NULL;
@@ -998,14 +922,14 @@ static osm_remote_sm_t *__osm_state_mgr_get_highest_sm(IN osm_state_mgr_t *
 	uint8_t highest_sm_priority;
 	ib_net64_t highest_sm_guid;
 
-	OSM_LOG_ENTER(p_mgr->p_log, __osm_state_mgr_get_highest_sm);
+	OSM_LOG_ENTER(sm->p_log, __osm_state_mgr_get_highest_sm);
 
-	p_sm_tbl = &p_mgr->p_subn->sm_guid_tbl;
+	p_sm_tbl = &sm->p_subn->sm_guid_tbl;
 
 	/* Start with the local sm as the standard */
 	p_highest_sm = NULL;
-	highest_sm_priority = p_mgr->p_subn->opt.sm_priority;
-	highest_sm_guid = p_mgr->p_subn->sm_port_guid;
+	highest_sm_priority = sm->p_subn->opt.sm_priority;
+	highest_sm_guid = sm->p_subn->sm_port_guid;
 
 	/* go over all the remote SMs */
 	for (p_sm = (osm_remote_sm_t *) cl_qmap_head(p_sm_tbl);
@@ -1030,7 +954,7 @@ static osm_remote_sm_t *__osm_state_mgr_get_highest_sm(IN osm_state_mgr_t *
 	}
 
 	if (p_highest_sm != NULL) {
-		osm_log(p_mgr->p_log, OSM_LOG_DEBUG,
+		osm_log(sm->p_log, OSM_LOG_DEBUG,
 			"__osm_state_mgr_get_highest_sm: "
 			"Found higher SM with guid: %016" PRIx64 " (node %s)\n",
 			cl_ntoh64(p_highest_sm->smi.guid),
@@ -1038,7 +962,7 @@ static osm_remote_sm_t *__osm_state_mgr_get_highest_sm(IN osm_state_mgr_t *
 			p_highest_sm->p_port->p_node->print_desc : "UNKNOWN");
 	}
 
-	OSM_LOG_EXIT(p_mgr->p_log);
+	OSM_LOG_EXIT(sm->p_log);
 	return (p_highest_sm);
 }
 
@@ -1047,7 +971,7 @@ static osm_remote_sm_t *__osm_state_mgr_get_highest_sm(IN osm_state_mgr_t *
  * remote_sm indicated.
  **********************************************************************/
 static void
-__osm_state_mgr_send_handover(IN osm_state_mgr_t * const p_mgr,
+__osm_state_mgr_send_handover(IN osm_sm_t * const sm,
 			      IN osm_remote_sm_t * const p_sm)
 {
 	uint8_t payload[IB_SMP_DATA_SIZE];
@@ -1056,7 +980,7 @@ __osm_state_mgr_send_handover(IN osm_state_mgr_t * const p_mgr,
 	const osm_port_t *p_port;
 	ib_api_status_t status;
 
-	OSM_LOG_ENTER(p_mgr->p_log, __osm_state_mgr_send_handover);
+	OSM_LOG_ENTER(sm->p_log, __osm_state_mgr_send_handover);
 
 	/*
 	 * Send a query of SubnSet(SMInfo) HANDOVER to the remote sm given.
@@ -1065,66 +989,66 @@ __osm_state_mgr_send_handover(IN osm_state_mgr_t * const p_mgr,
 	memset(&context, 0, sizeof(context));
 	p_port = p_sm->p_port;
 	if (p_port == NULL) {
-		osm_log(p_mgr->p_log, OSM_LOG_ERROR,
+		osm_log(sm->p_log, OSM_LOG_ERROR,
 			"__osm_state_mgr_send_handover: ERR 3316: "
 			"No port object on given remote_sm object\n");
 		goto Exit;
 	}
 
-	/* update the master_guid in the p_sm_state_mgr object according to */
+	/* update the master_guid in the sm_state_mgr object according to */
 	/* the guid of the port where the new Master SM should reside. */
-	osm_log(p_mgr->p_log, OSM_LOG_VERBOSE,
+	osm_log(sm->p_log, OSM_LOG_VERBOSE,
 		"__osm_state_mgr_send_handover: "
 		"Handing over mastership. Updating sm_state_mgr master_guid: %016"
 		PRIx64 " (node %s)\n", cl_ntoh64(p_port->guid),
 		p_port->p_node ? p_port->p_node->print_desc : "UNKNOWN");
-	p_mgr->p_sm_state_mgr->master_guid = p_port->guid;
+	sm->sm_state_mgr.master_guid = p_port->guid;
 
 	context.smi_context.port_guid = p_port->guid;
 	context.smi_context.set_method = TRUE;
 
-	p_smi->guid = p_mgr->p_subn->sm_port_guid;
-	p_smi->act_count = cl_hton32(p_mgr->p_stats->qp0_mads_sent);
-	p_smi->pri_state = (uint8_t) (p_mgr->p_subn->sm_state |
-				      p_mgr->p_subn->opt.sm_priority << 4);
+	p_smi->guid = sm->p_subn->sm_port_guid;
+	p_smi->act_count = cl_hton32(sm->p_subn->p_osm->stats.qp0_mads_sent);
+	p_smi->pri_state = (uint8_t) (sm->p_subn->sm_state |
+				      sm->p_subn->opt.sm_priority << 4);
 	/*
 	 * Return 0 for the SM key unless we authenticate the requester
 	 * as the master SM.
 	 */
 	if (ib_sminfo_get_state(&p_sm->smi) == IB_SMINFO_STATE_MASTER) {
-		osm_log(p_mgr->p_log, OSM_LOG_DEBUG,
+		osm_log(sm->p_log, OSM_LOG_DEBUG,
 			"__osm_state_mgr_send_handover: "
 			"Responding to master SM with real sm_key\n");
-		p_smi->sm_key = p_mgr->p_subn->opt.sm_key;
+		p_smi->sm_key = sm->p_subn->opt.sm_key;
 	} else {
 		/* The requester is not authenticated as master - set sm_key to zero */
-		osm_log(p_mgr->p_log, OSM_LOG_DEBUG,
+		osm_log(sm->p_log, OSM_LOG_DEBUG,
 			"__osm_state_mgr_send_handover: "
 			"Responding to SM not master with zero sm_key\n");
 		p_smi->sm_key = 0;
 	}
 
-	status = osm_req_set(p_mgr->sm,
+	status = osm_req_set(sm,
 			     osm_physp_get_dr_path_ptr(p_port->p_physp),
 			     payload, sizeof(payload),
 			     IB_MAD_ATTR_SM_INFO, IB_SMINFO_ATTR_MOD_HANDOVER,
 			     CL_DISP_MSGID_NONE, &context);
 
 	if (status != IB_SUCCESS) {
-		osm_log(p_mgr->p_log, OSM_LOG_ERROR,
+		osm_log(sm->p_log, OSM_LOG_ERROR,
 			"__osm_state_mgr_send_handover: ERR 3317: "
 			"Failure requesting SMInfo (%s)\n",
 			ib_get_err_str(status));
 	}
 
       Exit:
-	OSM_LOG_EXIT(p_mgr->p_log);
+	OSM_LOG_EXIT(sm->p_log);
 }
 
 /**********************************************************************
  * Send Trap 64 on all new ports.
  **********************************************************************/
-static void __osm_state_mgr_report_new_ports(IN osm_state_mgr_t * const p_mgr)
+static void __osm_state_mgr_report_new_ports(IN osm_sm_t *sm)
 {
 	ib_gid_t port_gid;
 	ib_mad_notice_attr_t notice;
@@ -1135,11 +1059,11 @@ static void __osm_state_mgr_report_new_ports(IN osm_state_mgr_t * const p_mgr)
 	uint16_t min_lid_ho;
 	uint16_t max_lid_ho;
 
-	OSM_LOG_ENTER(p_mgr->p_log, __osm_state_mgr_report_new_ports);
+	OSM_LOG_ENTER(sm->p_log, __osm_state_mgr_report_new_ports);
 
-	CL_PLOCK_ACQUIRE(p_mgr->p_lock);
-	p_next = cl_qmap_head(&p_mgr->p_subn->port_guid_tbl);
-	while (p_next != cl_qmap_end(&p_mgr->p_subn->port_guid_tbl)) {
+	CL_PLOCK_ACQUIRE(sm->p_lock);
+	p_next = cl_qmap_head(&sm->p_subn->port_guid_tbl);
+	while (p_next != cl_qmap_end(&sm->p_subn->port_guid_tbl)) {
 		p_port = (osm_port_t *) p_next;
 		p_next = cl_qmap_next(p_next);
 
@@ -1155,10 +1079,10 @@ static void __osm_state_mgr_report_new_ports(IN osm_state_mgr_t * const p_mgr)
 		/* endport becomes to be reachable */
 		notice.g_or_v.generic.trap_num = CL_HTON16(64);
 		/* The sm_base_lid is saved in network order already. */
-		notice.issuer_lid = p_mgr->p_subn->sm_base_lid;
+		notice.issuer_lid = sm->p_subn->sm_base_lid;
 		/* following C14-72.1.1 and table 119 p739 */
 		/* we need to provide the GID */
-		port_gid.unicast.prefix = p_mgr->p_subn->opt.subnet_prefix;
+		port_gid.unicast.prefix = sm->p_subn->opt.subnet_prefix;
 		port_gid.unicast.interface_id = port_guid;
 		memcpy(&(notice.data_details.ntc_64_67.gid), &(port_gid),
 		       sizeof(ib_gid_t));
@@ -1166,21 +1090,20 @@ static void __osm_state_mgr_report_new_ports(IN osm_state_mgr_t * const p_mgr)
 		/* According to page 653 - the issuer gid in this case of trap
 		 * is the SM gid, since the SM is the initiator of this trap. */
 		notice.issuer_gid.unicast.prefix =
-		    p_mgr->p_subn->opt.subnet_prefix;
+		    sm->p_subn->opt.subnet_prefix;
 		notice.issuer_gid.unicast.interface_id =
-		    p_mgr->p_subn->sm_port_guid;
+		    sm->p_subn->sm_port_guid;
 
-		status =
-		    osm_report_notice(p_mgr->p_log, p_mgr->p_subn, &notice);
+		status = osm_report_notice(sm->p_log, sm->p_subn, &notice);
 		if (status != IB_SUCCESS) {
-			osm_log(p_mgr->p_log, OSM_LOG_ERROR,
+			osm_log(sm->p_log, OSM_LOG_ERROR,
 				"__osm_state_mgr_report_new_ports: ERR 3318: "
 				"Error sending trap reports on GUID:0x%016"
 				PRIx64 " (%s)\n", port_gid.unicast.interface_id,
 				ib_get_err_str(status));
 		}
 		osm_port_get_lid_range_ho(p_port, &min_lid_ho, &max_lid_ho);
-		osm_log(p_mgr->p_log, OSM_LOG_INFO,
+		osm_log(sm->p_log, OSM_LOG_INFO,
 			"__osm_state_mgr_report_new_ports: "
 			"Discovered new port with GUID:0x%016" PRIx64
 			" LID range [0x%X,0x%X] of node:%s\n",
@@ -1191,9 +1114,9 @@ static void __osm_state_mgr_report_new_ports(IN osm_state_mgr_t * const p_mgr)
 
 		p_port->is_new = 0;
 	}
-	CL_PLOCK_RELEASE(p_mgr->p_lock);
+	CL_PLOCK_RELEASE(sm->p_lock);
 
-	OSM_LOG_EXIT(p_mgr->p_log);
+	OSM_LOG_EXIT(sm->p_log);
 }
 
 /**********************************************************************
@@ -1206,8 +1129,7 @@ static void __osm_state_mgr_report_new_ports(IN osm_state_mgr_t * const p_mgr)
  * initialization), but here we'll clean the database from incorrect
  * information.
  **********************************************************************/
-static void __osm_state_mgr_check_tbl_consistency(IN osm_state_mgr_t *
-						  const p_mgr)
+static void __osm_state_mgr_check_tbl_consistency(IN osm_sm_t *sm)
 {
 	cl_qmap_t *p_port_guid_tbl;
 	osm_port_t *p_port;
@@ -1220,14 +1142,14 @@ static void __osm_state_mgr_check_tbl_consistency(IN osm_state_mgr_t *
 	uint16_t max_lid_ho;
 	uint16_t lid_ho;
 
-	OSM_LOG_ENTER(p_mgr->p_log, __osm_state_mgr_check_tbl_consistency);
+	OSM_LOG_ENTER(sm->p_log, __osm_state_mgr_check_tbl_consistency);
 
 	cl_ptr_vector_construct(&ref_port_lid_tbl);
 	cl_ptr_vector_init(&ref_port_lid_tbl,
-			   cl_ptr_vector_get_size(&p_mgr->p_subn->port_lid_tbl),
+			   cl_ptr_vector_get_size(&sm->p_subn->port_lid_tbl),
 			   OSM_SUBNET_VECTOR_GROW_SIZE);
 
-	p_port_guid_tbl = &p_mgr->p_subn->port_guid_tbl;
+	p_port_guid_tbl = &sm->p_subn->port_guid_tbl;
 
 	/* Let's go over all the ports according to port_guid_tbl,
 	 * and add the port to a reference port_lid_tbl. */
@@ -1242,7 +1164,7 @@ static void __osm_state_mgr_check_tbl_consistency(IN osm_state_mgr_t *
 			cl_ptr_vector_set(&ref_port_lid_tbl, lid_ho, p_port);
 	}
 
-	p_port_lid_tbl = &p_mgr->p_subn->port_lid_tbl;
+	p_port_lid_tbl = &sm->p_subn->port_lid_tbl;
 
 	ref_size = cl_ptr_vector_get_size(&ref_port_lid_tbl);
 	curr_size = cl_ptr_vector_get_size(p_port_lid_tbl);
@@ -1268,7 +1190,7 @@ static void __osm_state_mgr_check_tbl_consistency(IN osm_state_mgr_t *
 			 * didn't get the PortInfo Set request. Due to this, the port
 			 * is updated with its original lid in our database, but with the
 			 * new lid we wanted to give it in our port_lid_tbl. */
-			osm_log(p_mgr->p_log, OSM_LOG_ERROR,
+			osm_log(sm->p_log, OSM_LOG_ERROR,
 				"__osm_state_mgr_check_tbl_consistency: ERR 3322: "
 				"lid 0x%zX is wrongly assigned to port 0x%016"
 				PRIx64 " in port_lid_tbl\n", lid,
@@ -1278,7 +1200,7 @@ static void __osm_state_mgr_check_tbl_consistency(IN osm_state_mgr_t *
 				/* There is an object in the new database, but no object in our subnet
 				 * database. This is the matching case of the prior check - the port
 				 * still has its original lid. */
-				osm_log(p_mgr->p_log, OSM_LOG_ERROR,
+				osm_log(sm->p_log, OSM_LOG_ERROR,
 					"__osm_state_mgr_check_tbl_consistency: ERR 3323: "
 					"port 0x%016" PRIx64
 					" exists in new port_lid_tbl under "
@@ -1290,7 +1212,7 @@ static void __osm_state_mgr_check_tbl_consistency(IN osm_state_mgr_t *
 				/* if we reached here then p_port_stored != p_port_ref.
 				 * We were trying to set a lid to p_port_stored, but it didn't reach it,
 				 * and p_port_ref also didn't get the lid update. */
-				osm_log(p_mgr->p_log, OSM_LOG_ERROR,
+				osm_log(sm->p_log, OSM_LOG_ERROR,
 					"__osm_state_mgr_check_tbl_consistency: ERR 3324: "
 					"lid 0x%zX has port 0x%016" PRIx64
 					" in new port_lid_tbl db, "
@@ -1305,11 +1227,11 @@ static void __osm_state_mgr_check_tbl_consistency(IN osm_state_mgr_t *
 		/* In any of these cases we want to set NULL in the port_lid_tbl, since this
 		 * entry is invalid. Also, make sure we'll do another heavy sweep. */
 		cl_ptr_vector_set(p_port_lid_tbl, lid, NULL);
-		p_mgr->p_subn->subnet_initialization_error = TRUE;
+		sm->p_subn->subnet_initialization_error = TRUE;
 	}
 
 	cl_ptr_vector_destroy(&ref_port_lid_tbl);
-	OSM_LOG_EXIT(p_mgr->p_log);
+	OSM_LOG_EXIT(sm->p_log);
 }
 
 /**********************************************************************
@@ -1355,11 +1277,11 @@ static void do_sweep(osm_sm_t * sm)
 	    && sm->p_subn->opt.force_heavy_sweep == FALSE
 	    && sm->p_subn->force_heavy_sweep == FALSE
 	    && sm->p_subn->subnet_initialization_error == FALSE
-	    && (__osm_state_mgr_light_sweep_start(&sm->state_mgr) == IB_SUCCESS)) {
+	    && (__osm_state_mgr_light_sweep_start(sm) == IB_SUCCESS)) {
 		if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
 			return;
 		if (!sm->p_subn->force_heavy_sweep) {
-			__osm_state_mgr_light_sweep_done_msg(&sm->state_mgr);
+			__osm_state_mgr_light_sweep_done_msg(sm->p_log);
 			return;
 		}
 	}
@@ -1375,19 +1297,19 @@ _repeat_discovery:
 	status = osm_subn_rescan_conf_files(sm->p_subn);
 	if (status != IB_SUCCESS)
 		osm_log(sm->p_log, OSM_LOG_ERROR,
-			"osm_state_mgr_process: ERR 331A: "
+			"do_sweep: ERR 331A: "
 			"osm_subn_rescan_conf_file failed\n");
 
 	if (sm->p_subn->sm_state != IB_SMINFO_STATE_MASTER)
 		sm->p_subn->need_update = 1;
 
-	status = __osm_state_mgr_sweep_hop_0(&sm->state_mgr);
+	status = __osm_state_mgr_sweep_hop_0(sm);
 	if (status != IB_SUCCESS ||
 	    wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
 		return;
 
-	if (__osm_state_mgr_is_sm_port_down(&sm->state_mgr) == TRUE) {
-		__osm_state_mgr_sm_port_down_msg(&sm->state_mgr);
+	if (__osm_state_mgr_is_sm_port_down(sm) == TRUE) {
+		__osm_state_mgr_sm_port_down_msg(sm->p_log);
 
 		/* Run the drop manager - we want to clear all records */
 		osm_drop_mgr_process(&sm->drop_mgr);
@@ -1398,21 +1320,21 @@ _repeat_discovery:
 		return;
 	}
 
-	status = __osm_state_mgr_sweep_hop_1(&sm->state_mgr);
+	status = __osm_state_mgr_sweep_hop_1(sm);
 	if (status != IB_SUCCESS ||
 	    wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
 		return;
 
 	/* discovery completed - check other sm presense */
 	if (sm->master_sm_found) {
-		sm->state_mgr.state = OSM_SM_STATE_STANDBY;
+		sm->state = OSM_SM_STATE_STANDBY;
 		/*
 		 * Call the sm_state_mgr with signal
 		 * MASTER_OR_HIGHER_SM_DETECTED_DONE
 		 */
 		osm_sm_state_mgr_process(&sm->sm_state_mgr,
 					 OSM_SM_SIGNAL_MASTER_OR_HIGHER_SM_DETECTED_DONE);
-		__osm_state_mgr_standby_msg(&sm->state_mgr);
+		__osm_state_mgr_standby_msg(sm->p_log);
 		return;
 	}
 
@@ -1420,29 +1342,29 @@ _repeat_discovery:
 	if (sm->p_subn->force_heavy_sweep)
 		goto _repeat_discovery;
 
-	__osm_state_mgr_sweep_heavy_done_msg(&sm->state_mgr);
+	__osm_state_mgr_sweep_heavy_done_msg(sm->p_log);
 
 	/* If we are MASTER - get the highest remote_sm, and
 	 * see if it is higher than our local sm.
 	 */
 	if (sm->p_subn->sm_state == IB_SMINFO_STATE_MASTER) {
-		p_remote_sm = __osm_state_mgr_get_highest_sm(&sm->state_mgr);
+		p_remote_sm = __osm_state_mgr_get_highest_sm(sm);
 		if (p_remote_sm != NULL) {
 			/* report new ports (trap 64) before leaving MASTER */
-			__osm_state_mgr_report_new_ports(&sm->state_mgr);
+			__osm_state_mgr_report_new_ports(sm);
 
 			/* need to handover the mastership
 			 * to the remote sm, and move to standby */
-			__osm_state_mgr_send_handover(&sm->state_mgr, p_remote_sm);
+			__osm_state_mgr_send_handover(sm, p_remote_sm);
 			osm_sm_state_mgr_process(&sm->sm_state_mgr,
 						 OSM_SM_SIGNAL_HANDOVER_SENT);
-			sm->state_mgr.state = OSM_SM_STATE_STANDBY;
+			sm->state = OSM_SM_STATE_STANDBY;
 			return;
 		} else {
 			/* We are the highest sm - check to see if there is
 			 * a remote SM that is in master state. */
 			p_remote_sm =
-			    __osm_state_mgr_exists_other_master_sm(&sm->state_mgr);
+			    __osm_state_mgr_exists_other_master_sm(sm);
 			if (p_remote_sm != NULL) {
 				/* There is a remote SM that is master.
 				 * need to wait for that SM to relinquish control
@@ -1484,8 +1406,8 @@ _repeat_discovery:
 	if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
 		return;
 
-	__osm_state_mgr_set_sm_lid_done_msg(&sm->state_mgr);
-	__osm_state_mgr_notify_lid_change(&sm->state_mgr);
+	__osm_state_mgr_set_sm_lid_done_msg(sm->p_log);
+	__osm_state_mgr_notify_lid_change(sm);
 
 	osm_lid_mgr_process_subnet(&sm->lid_mgr);
 	if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
@@ -1495,15 +1417,15 @@ _repeat_discovery:
 	 * the port_lid_tbl under the subnet. There might be
 	 * errors in it if PortInfo Set reqeusts didn't reach
 	 * their destination. */
-	__osm_state_mgr_check_tbl_consistency(&sm->state_mgr);
+	__osm_state_mgr_check_tbl_consistency(sm);
 
-	__osm_state_mgr_lid_assign_msg(&sm->state_mgr);
+	__osm_state_mgr_lid_assign_msg(sm->p_log);
 
 	/*
 	 * Proceed with unicast forwarding table configuration.
 	 * First - send trap 64 on newly discovered endports
 	 */
-	__osm_state_mgr_report_new_ports(&sm->state_mgr);
+	__osm_state_mgr_report_new_ports(sm);
 
 	osm_ucast_mgr_process(&sm->ucast_mgr);
 	if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
@@ -1514,13 +1436,13 @@ _repeat_discovery:
 	 * take into account these lfts. */
 	sm->p_subn->ignore_existing_lfts = FALSE;
 
-	__osm_state_mgr_switch_config_msg(&sm->state_mgr);
+	__osm_state_mgr_switch_config_msg(sm->p_log);
 
 	if (!sm->p_subn->opt.disable_multicast) {
 		osm_mcast_mgr_process(&sm->mcast_mgr);
 		if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
 			return;
-		__osm_state_mgr_multicast_config_msg(&sm->state_mgr);
+		__osm_state_mgr_multicast_config_msg(sm->p_log);
 	}
 
 	/*
@@ -1535,13 +1457,13 @@ _repeat_discovery:
 	if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
 		return;
 
-	__osm_state_mgr_links_ports_msg(&sm->state_mgr);
+	__osm_state_mgr_links_ports_msg(sm->p_log);
 
 	osm_link_mgr_process(&sm->link_mgr, IB_LINK_ARMED);
 	if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
 		return;
 
-	__osm_state_mgr_links_armed_msg(&sm->state_mgr);
+	__osm_state_mgr_links_armed_msg(sm->p_log);
 
 	osm_link_mgr_process(&sm->link_mgr, IB_LINK_ACTIVE);
 	if (wait_for_pending_transactions(&sm->p_subn->p_osm->stats))
@@ -1556,7 +1478,7 @@ _repeat_discovery:
 
 	/* If there were errors - then the subnet is not really up */
 	if (sm->p_subn->subnet_initialization_error == TRUE)
-		__osm_state_mgr_init_errors_msg(&sm->state_mgr);
+		__osm_state_mgr_init_errors_msg(sm->p_log);
 	else {
 		/* The subnet is up correctly - set the first_time_master_sweep
 		 * flag (if it is on) to FALSE. */
@@ -1565,7 +1487,7 @@ _repeat_discovery:
 			sm->p_subn->need_update = 0;
 
 		osm_dump_all(sm->p_subn->p_osm);
-		__osm_state_mgr_up_msg(&sm->state_mgr);
+		__osm_state_mgr_up_msg(sm);
 
 		if (osm_log_is_active(sm->p_log, OSM_LOG_VERBOSE))
 			osm_sa_db_file_dump(sm->p_subn->p_osm);
@@ -1589,21 +1511,20 @@ static void do_process_mgrp_queue(osm_sm_t * sm)
 	wait_for_pending_transactions(&sm->p_subn->p_osm->stats);
 }
 
-void osm_state_mgr_process(IN osm_state_mgr_t * const p_mgr,
-			   IN osm_signal_t signal)
+void osm_state_mgr_process(IN osm_sm_t *sm, IN osm_signal_t signal)
 {
-	CL_ASSERT(p_mgr);
+	CL_ASSERT(sm);
 
-	OSM_LOG_ENTER(p_mgr->p_log, osm_state_mgr_process);
+	OSM_LOG_ENTER(sm->p_log, osm_state_mgr_process);
 
-	if (osm_log_is_active(p_mgr->p_log, OSM_LOG_DEBUG))
-		osm_log(p_mgr->p_log, OSM_LOG_DEBUG,
+	if (osm_log_is_active(sm->p_log, OSM_LOG_DEBUG))
+		osm_log(sm->p_log, OSM_LOG_DEBUG,
 			"osm_state_mgr_process: "
 			"Received signal %s in state %s\n",
 			osm_get_sm_signal_str(signal),
-			osm_get_sm_state_str(p_mgr->state));
+			osm_get_sm_state_str(sm->state));
 
-	switch (p_mgr->state) {
+	switch (sm->state) {
 	case OSM_SM_STATE_IDLE:
 		switch (signal) {
 		case OSM_SIGNAL_SWEEP:
@@ -1611,8 +1532,8 @@ void osm_state_mgr_process(IN osm_state_mgr_t * const p_mgr,
 			 * If the osm_sm_state_mgr is in NOT-ACTIVE state -
 			 * stay in IDLE
 			 */
-			if (p_mgr->p_subn->sm_state == IB_SMINFO_STATE_NOTACTIVE) {
-				osm_vendor_set_sm(p_mgr->p_mad_ctrl->h_bind, FALSE);
+			if (sm->p_subn->sm_state == IB_SMINFO_STATE_NOTACTIVE) {
+				osm_vendor_set_sm(sm->mad_ctrl.h_bind, FALSE);
 				break;
 			}
 
@@ -1620,19 +1541,19 @@ void osm_state_mgr_process(IN osm_state_mgr_t * const p_mgr,
 			 * If the osm_sm_state_mgr is in INIT state - signal
 			 * it with a INIT signal to move it to DISCOVERY state.
 			 */
-			if (p_mgr->p_subn->sm_state == IB_SMINFO_STATE_INIT)
-				osm_sm_state_mgr_process(p_mgr->p_sm_state_mgr,
+			if (sm->p_subn->sm_state == IB_SMINFO_STATE_INIT)
+				osm_sm_state_mgr_process(&sm->sm_state_mgr,
 							 OSM_SM_SIGNAL_INIT);
 
-			do_sweep(p_mgr->sm);
+			do_sweep(sm);
 			break;
 
 		case OSM_SIGNAL_IDLE_TIME_PROCESS_REQUEST:
-			do_process_mgrp_queue(p_mgr->sm);
+			do_process_mgrp_queue(sm);
 			break;
 
 		default:
-			__osm_state_mgr_signal_error(p_mgr, signal);
+			__osm_state_mgr_signal_error(sm, signal);
 			break;
 		}
 		break;
@@ -1645,12 +1566,12 @@ void osm_state_mgr_process(IN osm_state_mgr_t * const p_mgr,
 			 * to do that we want all the ports to be considered
 			 * foriegn
 			 */
-			__osm_state_mgr_clean_known_lids(p_mgr);
-			p_mgr->state = OSM_SM_STATE_IDLE;
-			osm_sm_signal(p_mgr->sm, OSM_SIGNAL_SWEEP);
+			__osm_state_mgr_clean_known_lids(sm);
+			sm->state = OSM_SM_STATE_IDLE;
+			osm_sm_signal(sm, OSM_SIGNAL_SWEEP);
 			break;
 		default:
-			__osm_state_mgr_signal_error(p_mgr, signal);
+			__osm_state_mgr_signal_error(sm, signal);
 			break;
 		}
 		/* stay with the same signal - so we can start the sweep */
@@ -1658,11 +1579,11 @@ void osm_state_mgr_process(IN osm_state_mgr_t * const p_mgr,
 
 	default:
 		CL_ASSERT(FALSE);
-		osm_log(p_mgr->p_log, OSM_LOG_ERROR,
+		osm_log(sm->p_log, OSM_LOG_ERROR,
 			"osm_state_mgr_process: ERR 3320: "
-			"Invalid SM state %u\n", p_mgr->state);
+			"Invalid SM state %u\n", sm->state);
 		break;
 	}
 
-	OSM_LOG_EXIT(p_mgr->p_log);
+	OSM_LOG_EXIT(sm->p_log);
 }
-- 
1.5.4.rc5




More information about the general mailing list