[ofa-general] [PATCH] opensm: kill osm_sm_state_mgr sub-object

Sasha Khapyorsky sashak at voltaire.com
Sun Feb 10 05:40:45 PST 2008


Remove redundant osm_sm_state_mgr SM's sub-object.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 opensm/include/opensm/osm_sm.h           |   92 +++++++-
 opensm/include/opensm/osm_sm_state_mgr.h |  108 ---------
 opensm/opensm/osm_sm.c                   |   25 ++-
 opensm/opensm/osm_sm_state_mgr.c         |  385 +++++++++++-------------------
 opensm/opensm/osm_sminfo_rcv.c           |   28 +--
 opensm/opensm/osm_state_mgr.c            |   17 +-
 6 files changed, 271 insertions(+), 384 deletions(-)

diff --git a/opensm/include/opensm/osm_sm.h b/opensm/include/opensm/osm_sm.h
index 83bd4da..25d0983 100644
--- a/opensm/include/opensm/osm_sm.h
+++ b/opensm/include/opensm/osm_sm.h
@@ -66,10 +66,10 @@
 #include <opensm/osm_link_mgr.h>
 #include <opensm/osm_drop_mgr.h>
 #include <opensm/osm_sweep_fail_ctrl.h>
-#include <opensm/osm_sm_state_mgr.h>
 #include <opensm/osm_port.h>
 #include <opensm/osm_mcast_mgr.h>
 #include <opensm/osm_db.h>
+#include <opensm/osm_remote_sm.h>
 
 #ifdef __cplusplus
 #  define BEGIN_C_DECLS extern "C" {
@@ -115,12 +115,17 @@ typedef struct osm_sm {
 	osm_sm_state_t state;
 	unsigned signal_mask;
 	cl_spinlock_t signal_lock;
+	cl_spinlock_t state_lock;
 	cl_event_t signal_event;
 	cl_event_t subnet_up_event;
 	cl_timer_t sweep_timer;
+	cl_timer_t polling_timer;
 	cl_event_wheel_t trap_aging_tracker;
 	cl_thread_t sweeper;
 	unsigned master_sm_found;
+	uint32_t retry_number;
+	ib_net64_t master_sm_guid;
+	osm_remote_sm_t *p_polling_sm;
 	osm_subn_t *p_subn;
 	osm_db_t *p_db;
 	osm_vendor_t *p_vendor;
@@ -138,7 +143,6 @@ typedef struct osm_sm {
 	osm_link_mgr_t link_mgr;
 	osm_drop_mgr_t drop_mgr;
 	osm_sweep_fail_ctrl_t sweep_fail_ctrl;
-	osm_sm_state_mgr_t sm_state_mgr;
 	osm_mcast_mgr_t mcast_mgr;
 	cl_disp_reg_handle_t ni_disp_h;
 	cl_disp_reg_handle_t pi_disp_h;
@@ -697,5 +701,89 @@ osm_sm_is_greater_than(IN const uint8_t l_priority,
 *	State Manager
 *********/
 
+/****f* OpenSM: SM State Manager/osm_sm_state_mgr_process
+* NAME
+*	osm_sm_state_mgr_process
+*
+* DESCRIPTION
+*	Processes and maintains the states of the SM.
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_sm_state_mgr_process(IN osm_sm_t *sm,
+					 IN osm_sm_signal_t signal);
+/*
+* PARAMETERS
+*	sm
+*		[in] Pointer to an osm_sm_t object.
+*
+*	signal
+*		[in] Signal to the state SM engine.
+*
+* RETURN VALUES
+*	None.
+*
+* NOTES
+*
+* SEE ALSO
+*	State Manager
+*********/
+
+/****f* OpenSM: SM State Manager/osm_sm_state_mgr_signal_master_is_alive
+* NAME
+*	osm_sm_state_mgr_signal_master_is_alive
+*
+* DESCRIPTION
+*	Signals that the remote Master SM is alive.
+*	Need to clear the retry_number variable.
+*
+* SYNOPSIS
+*/
+void osm_sm_state_mgr_signal_master_is_alive(IN osm_sm_t *sm);
+/*
+* PARAMETERS
+*	sm
+*		[in] Pointer to an osm_sm_t object.
+*
+* RETURN VALUES
+*	None.
+*
+* NOTES
+*
+* SEE ALSO
+*	State Manager
+*********/
+
+/****f* OpenSM: SM State Manager/osm_sm_state_mgr_check_legality
+* NAME
+*	osm_sm_state_mgr_check_legality
+*
+* DESCRIPTION
+*	Checks the legality of the signal received, according to the
+*  current state of the SM state machine.
+*
+* SYNOPSIS
+*/
+ib_api_status_t osm_sm_state_mgr_check_legality(IN osm_sm_t *sm,
+						IN osm_sm_signal_t signal);
+/*
+* PARAMETERS
+*	sm
+*		[in] Pointer to an osm_sm_t object.
+*
+*	signal
+*		[in] Signal to the state SM engine.
+*
+* RETURN VALUES
+*	None.
+*
+* NOTES
+*
+* SEE ALSO
+*	State Manager
+*********/
+
+void osm_report_sm_state(osm_sm_t *sm);
+
 END_C_DECLS
 #endif				/* _OSM_SM_H_ */
diff --git a/opensm/include/opensm/osm_sm_state_mgr.h b/opensm/include/opensm/osm_sm_state_mgr.h
index 3007554..bdc0078 100644
--- a/opensm/include/opensm/osm_sm_state_mgr.h
+++ b/opensm/include/opensm/osm_sm_state_mgr.h
@@ -102,13 +102,8 @@ struct osm_sm;
 */
 typedef struct _osm_sm_state_mgr {
 	struct osm_sm *sm;
-	cl_spinlock_t state_lock;
-	cl_timer_t polling_timer;
-	uint32_t retry_number;
-	ib_net64_t master_guid;
 	osm_subn_t *p_subn;
 	osm_log_t *p_log;
-	osm_remote_sm_t *p_polling_sm;
 } osm_sm_state_mgr_t;
 
 /*
@@ -116,30 +111,12 @@ typedef struct _osm_sm_state_mgr {
 *	sm
 *		Pointer to the SM object.
 *
-*	state_lock
-*		Spinlock guarding the state and processes.
-*
-*	polling_timer
-*		Timer for polling.
-*
-*	retry_number
-*		Used in Standby state - to count the number of retries
-*		of queries to the master SM.
-*
-*	master_guid
-*		Port GUID of master SM.
-*
 *	p_subn
 *		Pointer to the Subnet object for this subnet.
 *
 *	p_log
 *		Pointer to the log object.
 *
-*	p_polling_sm
-*		Pointer to a osm_remote_sm_t object. When our SM needs
-*		to poll on a remote sm, this will be the pointer of the
-*		polled SM.
-*
 * SEE ALSO
 *	SM State Manager object
 *********/
@@ -237,90 +214,5 @@ osm_sm_state_mgr_init(IN osm_sm_state_mgr_t * const p_sm_mgr,
 *	osm_sm_state_mgr_destroy
 *********/
 
-/****f* OpenSM: SM State Manager/osm_sm_state_mgr_process
-* NAME
-*	osm_sm_state_mgr_process
-*
-* DESCRIPTION
-*	Processes and maintains the states of the SM.
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_sm_state_mgr_process(IN osm_sm_state_mgr_t * const p_sm_mgr,
-			 IN osm_sm_signal_t signal);
-/*
-* PARAMETERS
-*	p_sm_mgr
-*		[in] Pointer to an osm_sm_state_mgr_t object.
-*
-*	signal
-*		[in] Signal to the state SM engine.
-*
-* RETURN VALUES
-*	None.
-*
-* NOTES
-*
-* SEE ALSO
-*	State Manager
-*********/
-
-/****f* OpenSM: SM State Manager/osm_sm_state_mgr_signal_master_is_alive
-* NAME
-*	osm_sm_state_mgr_signal_master_is_alive
-*
-* DESCRIPTION
-*	Signals that the remote Master SM is alive.
-*	Need to clear the retry_number variable.
-*
-* SYNOPSIS
-*/
-void
-osm_sm_state_mgr_signal_master_is_alive(IN osm_sm_state_mgr_t * const p_sm_mgr);
-/*
-* PARAMETERS
-*	p_sm_mgr
-*		[in] Pointer to an osm_sm_state_mgr_t object.
-*
-* RETURN VALUES
-*	None.
-*
-* NOTES
-*
-* SEE ALSO
-*	State Manager
-*********/
-
-/****f* OpenSM: SM State Manager/osm_sm_state_mgr_check_legality
-* NAME
-*	osm_sm_state_mgr_check_legality
-*
-* DESCRIPTION
-*	Checks the legality of the signal received, according to the
-*  current state of the SM state machine.
-*
-* SYNOPSIS
-*/
-ib_api_status_t
-osm_sm_state_mgr_check_legality(IN osm_sm_state_mgr_t * const p_sm_mgr,
-				IN osm_sm_signal_t signal);
-/*
-* PARAMETERS
-*	p_sm_mgr
-*		[in] Pointer to an osm_sm_state_mgr_t object.
-*
-*	signal
-*		[in] Signal to the state SM engine.
-*
-* RETURN VALUES
-*	None.
-*
-* NOTES
-*
-* SEE ALSO
-*	State Manager
-*********/
-
 END_C_DECLS
 #endif				/* _OSM_SM_STATE_MGR_H_ */
diff --git a/opensm/opensm/osm_sm.c b/opensm/opensm/osm_sm.c
index 37dae43..f2cc550 100644
--- a/opensm/opensm/osm_sm.c
+++ b/opensm/opensm/osm_sm.c
@@ -81,6 +81,7 @@ 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);
+extern void osm_sm_state_mgr_polling_callback(IN void *context);
 
 /**********************************************************************
  **********************************************************************/
@@ -159,6 +160,8 @@ void osm_sm_construct(IN osm_sm_t * const p_sm)
 	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_spinlock_construct(&p_sm->state_lock);
+	cl_timer_construct(&p_sm->polling_timer);
 	cl_event_construct(&p_sm->signal_event);
 	cl_event_construct(&p_sm->subnet_up_event);
 	cl_event_wheel_construct(&p_sm->trap_aging_tracker);
@@ -170,7 +173,6 @@ void osm_sm_construct(IN osm_sm_t * const p_sm)
 	osm_link_mgr_construct(&p_sm->link_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);
 	osm_mcast_mgr_construct(&p_sm->mcast_mgr);
 }
 
@@ -197,6 +199,7 @@ void osm_sm_shutdown(IN osm_sm_t * const p_sm)
 	if (signal_event)
 		cl_event_signal(&p_sm->signal_event);
 
+	cl_timer_stop(&p_sm->polling_timer);
 	cl_timer_stop(&p_sm->sweep_timer);
 	cl_thread_destroy(&p_sm->sweeper);
 
@@ -231,14 +234,15 @@ 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_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);
 	cl_timer_destroy(&p_sm->sweep_timer);
+	cl_timer_destroy(&p_sm->polling_timer);
 	cl_event_destroy(&p_sm->signal_event);
 	cl_event_destroy(&p_sm->subnet_up_event);
 	cl_spinlock_destroy(&p_sm->signal_lock);
 	cl_spinlock_destroy(&p_sm->mgrp_lock);
+	cl_spinlock_destroy(&p_sm->state_lock);
 
 	osm_log(p_sm->p_log, OSM_LOG_SYS, "Exiting SM\n");	/* Format Waived */
 	OSM_LOG_EXIT(p_sm->p_log);
@@ -274,6 +278,10 @@ osm_sm_init(IN osm_sm_t * const p_sm,
 	if (status != CL_SUCCESS)
 		goto Exit;
 
+	status = cl_spinlock_init(&p_sm->state_lock);
+	if (status != CL_SUCCESS)
+		goto Exit;
+
 	status = cl_event_init(&p_sm->signal_event, FALSE);
 	if (status != CL_SUCCESS)
 		goto Exit;
@@ -286,6 +294,11 @@ osm_sm_init(IN osm_sm_t * const p_sm,
 	if (status != CL_SUCCESS)
 		goto Exit;
 
+	status = cl_timer_init(&p_sm->polling_timer,
+			       osm_sm_state_mgr_polling_callback, p_sm);
+	if (status != CL_SUCCESS)
+		goto Exit;
+
 	cl_qlist_init(&p_sm->mgrp_list);
 
 	status = cl_spinlock_init(&p_sm->mgrp_lock);
@@ -325,10 +338,6 @@ osm_sm_init(IN osm_sm_t * const p_sm,
 	if (status != IB_SUCCESS)
 		goto Exit;
 
-	status = osm_sm_state_mgr_init(&p_sm->sm_state_mgr, p_sm);
-	if (status != IB_SUCCESS)
-		goto Exit;
-
 	status = osm_mcast_mgr_init(&p_sm->mcast_mgr, p_sm);
 	if (status != IB_SUCCESS)
 		goto Exit;
@@ -388,6 +397,10 @@ osm_sm_init(IN osm_sm_t * const p_sm,
 	if (p_sm->pkey_disp_h == CL_DISP_INVALID_HANDLE)
 		goto Exit;
 
+	p_subn->sm_state = p_subn->opt.sm_inactive ?
+		IB_SMINFO_STATE_NOTACTIVE : IB_SMINFO_STATE_DISCOVERING;
+	osm_report_sm_state(p_sm);
+
 	/*
 	 * Now that the component objects are initialized, start
 	 * the sweeper thread if the user wants sweeping.
diff --git a/opensm/opensm/osm_sm_state_mgr.c b/opensm/opensm/osm_sm_state_mgr.c
index 4f0bf72..fab90bf 100644
--- a/opensm/opensm/osm_sm_state_mgr.c
+++ b/opensm/opensm/osm_sm_state_mgr.c
@@ -63,43 +63,40 @@
 #include <opensm/osm_node.h>
 #include <opensm/osm_port.h>
 #include <vendor/osm_vendor_api.h>
-#include <opensm/osm_sm_state_mgr.h>
 #include <opensm/osm_helper.h>
 #include <opensm/osm_opensm.h>
 
 /**********************************************************************
  **********************************************************************/
-static void __osm_report_sm_state(IN const osm_sm_state_mgr_t * p_sm_mgr)
+void osm_report_sm_state(osm_sm_t *sm)
 {
 	char buf[64];
-	const char *state_str = osm_get_sm_mgr_state_str(p_sm_mgr->p_subn->sm_state);
+	const char *state_str = osm_get_sm_mgr_state_str(sm->p_subn->sm_state);
 
-	osm_log(p_sm_mgr->p_log, OSM_LOG_SYS, "Entering %s state\n", state_str);
+	osm_log(sm->p_log, OSM_LOG_SYS, "Entering %s state\n", state_str);
 	snprintf(buf, sizeof(buf), "ENTERING SM %s STATE", state_str);
-	osm_log_msg_box(p_sm_mgr->p_log, OSM_LOG_VERBOSE, __FUNCTION__, buf);
+	osm_log_msg_box(sm->p_log, OSM_LOG_VERBOSE, __FUNCTION__, buf);
 }
 
 #if 0
 /**********************************************************************
  **********************************************************************/
-static void
-__osm_sm_state_mgr_send_local_port_info_req(IN osm_sm_state_mgr_t * p_sm_mgr)
+static void __osm_sm_state_mgr_send_local_port_info_req(osm_sm_t *sm)
 {
 	osm_madw_context_t context;
 	osm_port_t *p_port;
-	ib_net64_t port_guid = p_sm_mgr->p_subn->sm_port_guid;
+	ib_net64_t port_guid = sm->p_subn->sm_port_guid;
 	ib_api_status_t status;
 
-	OSM_LOG_ENTER(p_sm_mgr->p_log,
-		      __osm_sm_state_mgr_send_local_port_info_req);
+	OSM_LOG_ENTER(sm->p_log, __osm_sm_state_mgr_send_local_port_info_req);
 	/*
 	 * Send a query of SubnGet(PortInfo) to our own port, in order to
 	 * update the master_sm_base_lid of the subnet.
 	 */
 	memset(&context, 0, sizeof(context));
-	p_port = osm_get_port_by_guid(p_sm_mgr->p_subn, port_guid);
+	p_port = osm_get_port_by_guid(sm->p_subn, port_guid);
 	if (!p_port) {
-		osm_log(p_sm_mgr->p_log, OSM_LOG_ERROR,
+		osm_log(sm->p_log, OSM_LOG_ERROR,
 			"__osm_sm_state_mgr_send_local_port_info_req: ERR 3205: "
 			"No port object for port 0x%016" PRIx64 "\n",
 			cl_ntoh64(port_guid));
@@ -109,135 +106,121 @@ __osm_sm_state_mgr_send_local_port_info_req(IN osm_sm_state_mgr_t * p_sm_mgr)
 	context.pi_context.port_guid = port_guid;
 	context.pi_context.node_guid = p_port->p_node->node_info.node_guid;
 	context.pi_context.set_method = FALSE;
-	context.pi_context.ignore_errors = FALSE;
 	/* mark the update_master_sm_base_lid with TRUE - we want to update it */
 	/* with the new master lid value. */
 	context.pi_context.update_master_sm_base_lid = TRUE;
 	context.pi_context.light_sweep = FALSE;
 	context.pi_context.active_transition = FALSE;
 
-	status = osm_req_get(p_sm_mgr->p_req,
-			     osm_physp_get_dr_path_ptr
-			     (p_port->p_physp),
+	status = osm_req_get(sm, osm_physp_get_dr_path_ptr(p_port->p_physp),
 			     IB_MAD_ATTR_PORT_INFO,
 			     cl_hton32(p_port->p_physp->port_num),
 			     CL_DISP_MSGID_NONE, &context);
 
-	if (status != IB_SUCCESS) {
-		osm_log(p_sm_mgr->p_log, OSM_LOG_ERROR,
+	if (status != IB_SUCCESS)
+		osm_log(sm->p_log, OSM_LOG_ERROR,
 			"__osm_sm_state_mgr_send_local_port_info_req: ERR 3202: "
 			"Failure requesting PortInfo (%s)\n",
 			ib_get_err_str(status));
-	}
 
       Exit:
-	OSM_LOG_EXIT(p_sm_mgr->p_log);
+	OSM_LOG_EXIT(sm->p_log);
 }
 #endif
 
 /**********************************************************************
  **********************************************************************/
-static void
-__osm_sm_state_mgr_send_master_sm_info_req(IN osm_sm_state_mgr_t * p_sm_mgr)
+static void __osm_sm_state_mgr_send_master_sm_info_req(osm_sm_t *sm)
 {
 	osm_madw_context_t context;
 	const osm_port_t *p_port;
 	ib_api_status_t status;
 
-	OSM_LOG_ENTER(p_sm_mgr->p_log,
-		      __osm_sm_state_mgr_send_master_sm_info_req);
+	OSM_LOG_ENTER(sm->p_log, __osm_sm_state_mgr_send_master_sm_info_req);
 
 	memset(&context, 0, sizeof(context));
-	if (p_sm_mgr->p_subn->sm_state == IB_SMINFO_STATE_STANDBY) {
+	if (sm->p_subn->sm_state == IB_SMINFO_STATE_STANDBY) {
 		/*
 		 * We are in STANDBY state - this means we need to poll on the master
 		 * SM (according to master_guid)
 		 * Send a query of SubnGet(SMInfo) to the subn master_sm_base_lid object.
 		 */
-		p_port =
-		    osm_get_port_by_guid(p_sm_mgr->p_subn,
-					 p_sm_mgr->master_guid);
+		p_port = osm_get_port_by_guid(sm->p_subn, sm->master_sm_guid);
 	} else {
 		/*
 		 * We are not in STANDBY - this means we are in MASTER state - so we need
-		 * to poll on the SM that is saved in p_polling_sm under p_sm_mgr.
+		 * to poll on the SM that is saved in p_polling_sm under sm.
 		 * Send a query of SubnGet(SMInfo) to that SM.
 		 */
-		p_port = p_sm_mgr->p_polling_sm->p_port;
+		p_port = sm->p_polling_sm->p_port;
 	}
 	if (p_port == NULL) {
-		osm_log(p_sm_mgr->p_log, OSM_LOG_ERROR,
+		osm_log(sm->p_log, OSM_LOG_ERROR,
 			"__osm_sm_state_mgr_send_master_sm_info_req: ERR 3203: "
 			"No port object for GUID 0x%016" PRIx64 "\n",
-			cl_ntoh64(p_sm_mgr->master_guid));
+			cl_ntoh64(sm->master_sm_guid));
 		goto Exit;
 	}
 
 	context.smi_context.port_guid = p_port->guid;
 	context.smi_context.set_method = FALSE;
 
-	status = osm_req_get(p_sm_mgr->sm,
-			     osm_physp_get_dr_path_ptr(p_port->p_physp),
+	status = osm_req_get(sm, osm_physp_get_dr_path_ptr(p_port->p_physp),
 			     IB_MAD_ATTR_SM_INFO, 0, CL_DISP_MSGID_NONE,
 			     &context);
 
-	if (status != IB_SUCCESS) {
-		osm_log(p_sm_mgr->p_log, OSM_LOG_ERROR,
+	if (status != IB_SUCCESS)
+		osm_log(sm->p_log, OSM_LOG_ERROR,
 			"__osm_sm_state_mgr_send_master_sm_info_req: ERR 3204: "
 			"Failure requesting SMInfo (%s)\n",
 			ib_get_err_str(status));
-	}
 
       Exit:
-	OSM_LOG_EXIT(p_sm_mgr->p_log);
+	OSM_LOG_EXIT(sm->p_log);
 }
 
 /**********************************************************************
  **********************************************************************/
-static void __osm_sm_state_mgr_start_polling(IN osm_sm_state_mgr_t * p_sm_mgr)
+static void __osm_sm_state_mgr_start_polling(osm_sm_t *sm)
 {
-	uint32_t sminfo_polling_timeout =
-	    p_sm_mgr->p_subn->opt.sminfo_polling_timeout;
+	uint32_t timeout = sm->p_subn->opt.sminfo_polling_timeout;
 	cl_status_t cl_status;
 
-	OSM_LOG_ENTER(p_sm_mgr->p_log, __osm_sm_state_mgr_start_polling);
+	OSM_LOG_ENTER(sm->p_log, __osm_sm_state_mgr_start_polling);
 
 	/*
 	 * Init the retry_number back to zero - need to restart counting
 	 */
-	p_sm_mgr->retry_number = 0;
+	sm->retry_number = 0;
 
 	/*
 	 * Send a SubnGet(SMInfo) query to the current (or new) master found.
 	 */
-	__osm_sm_state_mgr_send_master_sm_info_req(p_sm_mgr);
+	__osm_sm_state_mgr_send_master_sm_info_req(sm);
 
 	/*
 	 * Start a timer that will wake up every sminfo_polling_timeout milliseconds.
 	 * The callback of the timer will send a SubnGet(SMInfo) to the Master SM
 	 * and restart the timer
 	 */
-	cl_status = cl_timer_start(&p_sm_mgr->polling_timer,
-				   sminfo_polling_timeout);
-	if (cl_status != CL_SUCCESS) {
-		osm_log(p_sm_mgr->p_log, OSM_LOG_ERROR,
+	cl_status = cl_timer_start(&sm->polling_timer, timeout);
+	if (cl_status != CL_SUCCESS)
+		osm_log(sm->p_log, OSM_LOG_ERROR,
 			"__osm_sm_state_mgr_start_polling: ERR 3210: "
 			"Failed to start timer\n");
-	}
 
-	OSM_LOG_EXIT(p_sm_mgr->p_log);
+	OSM_LOG_EXIT(sm->p_log);
 }
 
 /**********************************************************************
  **********************************************************************/
-static void __osm_sm_state_mgr_polling_callback(IN void *context)
+void osm_sm_state_mgr_polling_callback(IN void *context)
 {
-	osm_sm_state_mgr_t *p_sm_mgr = (osm_sm_state_mgr_t *) context;
-	uint32_t sminfo_polling_timeout =
-	    p_sm_mgr->p_subn->opt.sminfo_polling_timeout;
+	osm_sm_t *sm = context;
+	uint32_t timeout = sm->p_subn->opt.sminfo_polling_timeout;
 	cl_status_t cl_status;
 
-	OSM_LOG_ENTER(p_sm_mgr->p_log, __osm_sm_state_mgr_polling_callback);
+	OSM_LOG_ENTER(sm->p_log, osm_sm_state_mgr_polling_callback);
 
 	/*
 	 * We can be here in one of two cases:
@@ -245,25 +228,23 @@ static void __osm_sm_state_mgr_polling_callback(IN void *context)
 	 * 2. We are a MASTER sm, waiting for a handover from a remote master sm.
 	 * If we are not in one of these cases - don't need to restart the poller.
 	 */
-	if (!((p_sm_mgr->p_subn->sm_state == IB_SMINFO_STATE_MASTER &&
-	       p_sm_mgr->p_polling_sm != NULL) ||
-	      (p_sm_mgr->p_subn->sm_state == IB_SMINFO_STATE_STANDBY))) {
+	if (!((sm->p_subn->sm_state == IB_SMINFO_STATE_MASTER &&
+	       sm->p_polling_sm != NULL) ||
+	      (sm->p_subn->sm_state == IB_SMINFO_STATE_STANDBY)))
 		goto Exit;
-	}
 
 	/*
-	 * If we are a STANDBY sm and the osm_exit_flag is 1, then let's signal
-	 * the subnet_up. This is relevant for the case of running only once. In that
-	 * case - the program is stuck until this signal is received. In other
-	 * cases - it is not relevant whether or not the signal is on - since we are
-	 * currently in exit flow
+	 * If we are a STANDBY sm and the osm_exit_flag is set, then let's
+	 * signal the subnet_up. This is relevant for the case of running only
+	 * once. In that case - the program is stuck until this signal is
+	 * received. In other cases - it is not relevant whether or not the
+	 * signal is on - since we are currently in exit flow
 	 */
-	if (p_sm_mgr->p_subn->sm_state == IB_SMINFO_STATE_STANDBY &&
-	    osm_exit_flag == 1) {
-		osm_log(p_sm_mgr->p_log, OSM_LOG_VERBOSE,
-			"__osm_sm_state_mgr_polling_callback: "
+	if (sm->p_subn->sm_state == IB_SMINFO_STATE_STANDBY && osm_exit_flag) {
+		osm_log(sm->p_log, OSM_LOG_VERBOSE,
+			"osm_sm_state_mgr_polling_callback: "
 			"Signalling subnet_up_event\n");
-		cl_event_signal(&p_sm_mgr->p_subn->p_osm->sm.subnet_up_event);
+		cl_event_signal(&sm->subnet_up_event);
 		goto Exit;
 	}
 
@@ -272,152 +253,81 @@ static void __osm_sm_state_mgr_polling_callback(IN void *context)
 	 * If it reached the max_retry_number in the subnet opt - call
 	 * osm_sm_state_mgr_process with signal OSM_SM_SIGNAL_POLLING_TIMEOUT
 	 */
-	p_sm_mgr->retry_number++;
-	osm_log(p_sm_mgr->p_log, OSM_LOG_VERBOSE,
+	sm->retry_number++;
+	osm_log(sm->p_log, OSM_LOG_VERBOSE,
 		"__osm_sm_state_mgr_polling_callback: "
-		"Retry number:%d\n", p_sm_mgr->retry_number);
+		"Retry number:%d\n", sm->retry_number);
 
-	if (p_sm_mgr->retry_number >=
-	    p_sm_mgr->p_subn->opt.polling_retry_number) {
-		osm_log(p_sm_mgr->p_log, OSM_LOG_DEBUG,
+	if (sm->retry_number >= sm->p_subn->opt.polling_retry_number) {
+		osm_log(sm->p_log, OSM_LOG_DEBUG,
 			"__osm_sm_state_mgr_polling_callback: "
 			"Reached polling_retry_number value in retry_number. "
 			"Go to DISCOVERY state\n");
-		osm_sm_state_mgr_process(p_sm_mgr,
-					 OSM_SM_SIGNAL_POLLING_TIMEOUT);
+		osm_sm_state_mgr_process(sm, OSM_SM_SIGNAL_POLLING_TIMEOUT);
 		goto Exit;
 	}
 
 	/* Send a SubnGet(SMInfo) request to the remote sm (depends on our state) */
-	__osm_sm_state_mgr_send_master_sm_info_req(p_sm_mgr);
+	__osm_sm_state_mgr_send_master_sm_info_req(sm);
 
 	/* restart the timer */
-	cl_status = cl_timer_start(&p_sm_mgr->polling_timer,
-				   sminfo_polling_timeout);
-	if (cl_status != CL_SUCCESS) {
-		osm_log(p_sm_mgr->p_log, OSM_LOG_ERROR,
+	cl_status = cl_timer_start(&sm->polling_timer, timeout);
+	if (cl_status != CL_SUCCESS)
+		osm_log(sm->p_log, OSM_LOG_ERROR,
 			"__osm_sm_state_mgr_polling_callback: ERR 3211: "
 			"Failed to restart timer\n");
-	}
 
       Exit:
-	OSM_LOG_EXIT(p_sm_mgr->p_log);
+	OSM_LOG_EXIT(sm->p_log);
 	return;
 }
 
 /**********************************************************************
  **********************************************************************/
-void osm_sm_state_mgr_construct(IN osm_sm_state_mgr_t * const p_sm_mgr)
-{
-	memset(p_sm_mgr, 0, sizeof(*p_sm_mgr));
-	cl_spinlock_construct(&p_sm_mgr->state_lock);
-	cl_timer_construct(&p_sm_mgr->polling_timer);
-}
-
-/**********************************************************************
- **********************************************************************/
-void osm_sm_state_mgr_destroy(IN osm_sm_state_mgr_t * const p_sm_mgr)
-{
-	CL_ASSERT(p_sm_mgr);
-
-	OSM_LOG_ENTER(p_sm_mgr->p_log, osm_sm_state_mgr_destroy);
-
-	cl_spinlock_destroy(&p_sm_mgr->state_lock);
-	cl_timer_destroy(&p_sm_mgr->polling_timer);
-
-	OSM_LOG_EXIT(p_sm_mgr->p_log);
-}
-
-/**********************************************************************
- **********************************************************************/
-ib_api_status_t
-osm_sm_state_mgr_init(IN osm_sm_state_mgr_t * const p_sm_mgr, IN osm_sm_t * sm)
+static void __osm_sm_state_mgr_signal_error(osm_sm_t *sm,
+					    IN const osm_sm_signal_t signal)
 {
-	cl_status_t status;
-
-	OSM_LOG_ENTER(sm->p_log, osm_sm_state_mgr_init);
-
-	osm_sm_state_mgr_construct(p_sm_mgr);
-
-	p_sm_mgr->sm = sm;
-	p_sm_mgr->p_log = sm->p_log;
-	p_sm_mgr->p_subn = sm->p_subn;
-
-	p_sm_mgr->p_subn->sm_state = p_sm_mgr->p_subn->opt.sm_inactive ?
-		IB_SMINFO_STATE_NOTACTIVE : IB_SMINFO_STATE_DISCOVERING;
-
-	__osm_report_sm_state(p_sm_mgr);
-
-	status = cl_spinlock_init(&p_sm_mgr->state_lock);
-	if (status != CL_SUCCESS) {
-		osm_log(p_sm_mgr->p_log, OSM_LOG_ERROR,
-			"osm_sm_state_mgr_init: ERR 3201: "
-			"Spinlock init failed (%s)\n", CL_STATUS_MSG(status));
-	}
-
-	status = cl_timer_init(&p_sm_mgr->polling_timer,
-			       __osm_sm_state_mgr_polling_callback, p_sm_mgr);
-
-	if (status != CL_SUCCESS) {
-		osm_log(p_sm_mgr->p_log, OSM_LOG_ERROR,
-			"osm_sm_state_mgr_init: ERR 3206: "
-			"Timer init failed (%s)\n", CL_STATUS_MSG(status));
-	}
-
-	OSM_LOG_EXIT(p_sm_mgr->p_log);
-	return (status);
-}
-
-/**********************************************************************
- **********************************************************************/
-static void
-__osm_sm_state_mgr_signal_error(IN const osm_sm_state_mgr_t * const p_sm_mgr,
-				IN const osm_sm_signal_t signal)
-{
-	osm_log(p_sm_mgr->p_log, OSM_LOG_ERROR,
+	osm_log(sm->p_log, OSM_LOG_ERROR,
 		"__osm_sm_state_mgr_signal_error: ERR 3207: "
 		"Invalid signal %s in state %s\n",
 		osm_get_sm_mgr_signal_str(signal),
-		osm_get_sm_mgr_state_str(p_sm_mgr->p_subn->sm_state));
+		osm_get_sm_mgr_state_str(sm->p_subn->sm_state));
 }
 
 /**********************************************************************
  **********************************************************************/
-void
-osm_sm_state_mgr_signal_master_is_alive(IN osm_sm_state_mgr_t * const p_sm_mgr)
+void osm_sm_state_mgr_signal_master_is_alive(osm_sm_t *sm)
 {
-	OSM_LOG_ENTER(p_sm_mgr->p_log, osm_sm_state_mgr_signal_master_is_alive);
-	p_sm_mgr->retry_number = 0;
-	OSM_LOG_EXIT(p_sm_mgr->p_log);
+	OSM_LOG_ENTER(sm->p_log, osm_sm_state_mgr_signal_master_is_alive);
+	sm->retry_number = 0;
+	OSM_LOG_EXIT(sm->p_log);
 }
 
 /**********************************************************************
  **********************************************************************/
-ib_api_status_t
-osm_sm_state_mgr_process(IN osm_sm_state_mgr_t * const p_sm_mgr,
-			 IN osm_sm_signal_t signal)
+ib_api_status_t osm_sm_state_mgr_process(osm_sm_t *sm,
+					 IN osm_sm_signal_t signal)
 {
 	ib_api_status_t status = IB_SUCCESS;
 
-	CL_ASSERT(p_sm_mgr);
+	CL_ASSERT(sm);
 
-	OSM_LOG_ENTER(p_sm_mgr->p_log, osm_sm_state_mgr_process);
+	OSM_LOG_ENTER(sm->p_log, osm_sm_state_mgr_process);
 
 	/*
 	 * The state lock prevents many race conditions from screwing
 	 * up the state transition process.
 	 */
-	cl_spinlock_acquire(&p_sm_mgr->state_lock);
+	cl_spinlock_acquire(&sm->state_lock);
 
-	if (osm_log_is_active(p_sm_mgr->p_log, OSM_LOG_DEBUG)) {
-		osm_log(p_sm_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_sm_state_mgr_process: "
 			"Received signal %s in state %s\n",
 			osm_get_sm_mgr_signal_str(signal),
-			osm_get_sm_mgr_state_str(p_sm_mgr->p_subn->sm_state));
-	}
+			osm_get_sm_mgr_state_str(sm->p_subn->sm_state));
 
-	switch (p_sm_mgr->p_subn->sm_state) {
+	switch (sm->p_subn->sm_state) {
 	case IB_SMINFO_STATE_DISCOVERING:
 		switch (signal) {
 		case OSM_SM_SIGNAL_DISCOVERY_COMPLETED:
@@ -425,34 +335,33 @@ osm_sm_state_mgr_process(IN osm_sm_state_mgr_t * const p_sm_mgr,
 			 * Update the state of the SM to MASTER
 			 */
 			/* Turn on the moved_to_master_state flag */
-			p_sm_mgr->p_subn->moved_to_master_state = TRUE;
+			sm->p_subn->moved_to_master_state = TRUE;
 			/* Turn on the first_time_master_sweep flag */
-			if (p_sm_mgr->p_subn->first_time_master_sweep == FALSE)
-				p_sm_mgr->p_subn->first_time_master_sweep =
-				    TRUE;
-			p_sm_mgr->p_subn->sm_state = IB_SMINFO_STATE_MASTER;
-			__osm_report_sm_state(p_sm_mgr);
+			if (sm->p_subn->first_time_master_sweep == FALSE)
+				sm->p_subn->first_time_master_sweep = TRUE;
+			sm->p_subn->sm_state = IB_SMINFO_STATE_MASTER;
+			osm_report_sm_state(sm);
 			/*
 			 * Make sure to set the subnet master_sm_base_lid
 			 * to the sm_base_lid value
 			 */
-			p_sm_mgr->p_subn->master_sm_base_lid =
-			    p_sm_mgr->p_subn->sm_base_lid;
+			sm->p_subn->master_sm_base_lid =
+			    sm->p_subn->sm_base_lid;
 			break;
 		case OSM_SM_SIGNAL_MASTER_OR_HIGHER_SM_DETECTED_DONE:
 			/*
 			 * Finished all discovery actions - move to STANDBY
 			 * start the polling
 			 */
-			p_sm_mgr->p_subn->sm_state = IB_SMINFO_STATE_STANDBY;
-			__osm_report_sm_state(p_sm_mgr);
+			sm->p_subn->sm_state = IB_SMINFO_STATE_STANDBY;
+			osm_report_sm_state(sm);
 			/*
 			 * Since another SM is doing the LFT config - we should not
 			 * ignore the results of it
 			 */
-			p_sm_mgr->p_subn->ignore_existing_lfts = FALSE;
+			sm->p_subn->ignore_existing_lfts = FALSE;
 
-			__osm_sm_state_mgr_start_polling(p_sm_mgr);
+			__osm_sm_state_mgr_start_polling(sm);
 			break;
 		case OSM_SM_SIGNAL_HANDOVER:
 			/*
@@ -463,7 +372,7 @@ osm_sm_state_mgr_process(IN osm_sm_state_mgr_t * const p_sm_mgr,
 			 */
 			break;
 		default:
-			__osm_sm_state_mgr_signal_error(p_sm_mgr, signal);
+			__osm_sm_state_mgr_signal_error(sm, signal);
 			status = IB_INVALID_PARAMETER;
 			break;
 		}
@@ -479,19 +388,17 @@ osm_sm_state_mgr_process(IN osm_sm_state_mgr_t * const p_sm_mgr,
 			 * case 2: Got a signal to move to DISCOVERING
 			 * Move to DISCOVERING state and start sweeping
 			 */
-			p_sm_mgr->p_subn->sm_state =
-			    IB_SMINFO_STATE_DISCOVERING;
-			__osm_report_sm_state(p_sm_mgr);
-			p_sm_mgr->p_subn->coming_out_of_standby = TRUE;
-			osm_sm_signal(&p_sm_mgr->p_subn->p_osm->sm,
-				      OSM_SIGNAL_EXIT_STBY);
+			sm->p_subn->sm_state = IB_SMINFO_STATE_DISCOVERING;
+			osm_report_sm_state(sm);
+			sm->p_subn->coming_out_of_standby = TRUE;
+			osm_sm_signal(sm, OSM_SIGNAL_EXIT_STBY);
 			break;
 		case OSM_SM_SIGNAL_DISABLE:
 			/*
 			 * Update the state to NOT_ACTIVE
 			 */
-			p_sm_mgr->p_subn->sm_state = IB_SMINFO_STATE_NOTACTIVE;
-			__osm_report_sm_state(p_sm_mgr);
+			sm->p_subn->sm_state = IB_SMINFO_STATE_NOTACTIVE;
+			osm_report_sm_state(sm);
 			break;
 		case OSM_SM_SIGNAL_HANDOVER:
 			/*
@@ -499,26 +406,24 @@ osm_sm_state_mgr_process(IN osm_sm_state_mgr_t * const p_sm_mgr,
 			 * OPTIONAL: send ACKNOWLEDGE
 			 */
 			/* Turn on the moved_to_master_state flag */
-			p_sm_mgr->p_subn->moved_to_master_state = TRUE;
+			sm->p_subn->moved_to_master_state = TRUE;
 			/* Turn on the first_time_master_sweep flag */
-			if (p_sm_mgr->p_subn->first_time_master_sweep == FALSE)
-				p_sm_mgr->p_subn->first_time_master_sweep =
-				    TRUE;
+			if (sm->p_subn->first_time_master_sweep == FALSE)
+				sm->p_subn->first_time_master_sweep = TRUE;
 			/* Turn on the force_heavy_sweep - we want a
 			 * heavy sweep to occur on the first sweep of this SM. */
-			p_sm_mgr->p_subn->force_heavy_sweep = TRUE;
+			sm->p_subn->force_heavy_sweep = TRUE;
 
-			p_sm_mgr->p_subn->sm_state = IB_SMINFO_STATE_MASTER;
-			__osm_report_sm_state(p_sm_mgr);
+			sm->p_subn->sm_state = IB_SMINFO_STATE_MASTER;
+			osm_report_sm_state(sm);
 			/*
 			 * Make sure to set the subnet master_sm_base_lid
 			 * to the sm_base_lid value
 			 */
-			p_sm_mgr->p_subn->master_sm_base_lid =
-			    p_sm_mgr->p_subn->sm_base_lid;
-			p_sm_mgr->p_subn->coming_out_of_standby = TRUE;
-			osm_sm_signal(&p_sm_mgr->p_subn->p_osm->sm,
-				      OSM_SIGNAL_EXIT_STBY);
+			sm->p_subn->master_sm_base_lid =
+			    sm->p_subn->sm_base_lid;
+			sm->p_subn->coming_out_of_standby = TRUE;
+			osm_sm_signal(sm, OSM_SIGNAL_EXIT_STBY);
 			break;
 		case OSM_SM_SIGNAL_ACKNOWLEDGE:
 			/*
@@ -526,7 +431,7 @@ osm_sm_state_mgr_process(IN osm_sm_state_mgr_t * const p_sm_mgr,
 			 */
 			break;
 		default:
-			__osm_sm_state_mgr_signal_error(p_sm_mgr, signal);
+			__osm_sm_state_mgr_signal_error(sm, signal);
 			status = IB_INVALID_PARAMETER;
 			break;
 		}
@@ -539,12 +444,12 @@ osm_sm_state_mgr_process(IN osm_sm_state_mgr_t * const p_sm_mgr,
 			 * Update the state to STANDBY
 			 * start the polling
 			 */
-			p_sm_mgr->p_subn->sm_state = IB_SMINFO_STATE_STANDBY;
-			__osm_report_sm_state(p_sm_mgr);
-			__osm_sm_state_mgr_start_polling(p_sm_mgr);
+			sm->p_subn->sm_state = IB_SMINFO_STATE_STANDBY;
+			osm_report_sm_state(sm);
+			__osm_sm_state_mgr_start_polling(sm);
 			break;
 		default:
-			__osm_sm_state_mgr_signal_error(p_sm_mgr, signal);
+			__osm_sm_state_mgr_signal_error(sm, signal);
 			status = IB_INVALID_PARAMETER;
 			break;
 		}
@@ -573,23 +478,22 @@ osm_sm_state_mgr_process(IN osm_sm_state_mgr_t * const p_sm_mgr,
 			 * We also want to clear the p_polling_sm object - since we are
 			 * done polling on that remote sm - we got a handover from it.
 			 */
-			osm_log(p_sm_mgr->p_log, OSM_LOG_VERBOSE,
+			osm_log(sm->p_log, OSM_LOG_VERBOSE,
 				"osm_sm_state_mgr_process: "
 				"Forcing heavy sweep. "
 				"Received OSM_SM_SIGNAL_HANDOVER or OSM_SM_SIGNAL_POLLING_TIMEOUT\n");
-			p_sm_mgr->p_polling_sm = NULL;
-			p_sm_mgr->p_subn->force_heavy_sweep = TRUE;
-			osm_sm_signal(&p_sm_mgr->p_subn->p_osm->sm,
-				      OSM_SIGNAL_SWEEP);
+			sm->p_polling_sm = NULL;
+			sm->p_subn->force_heavy_sweep = TRUE;
+			osm_sm_signal(sm, OSM_SIGNAL_SWEEP);
 			break;
 		case OSM_SM_SIGNAL_HANDOVER_SENT:
 			/*
 			 * Just sent a HANDOVER signal - move to STANDBY
 			 * start the polling
 			 */
-			p_sm_mgr->p_subn->sm_state = IB_SMINFO_STATE_STANDBY;
-			__osm_report_sm_state(p_sm_mgr);
-			__osm_sm_state_mgr_start_polling(p_sm_mgr);
+			sm->p_subn->sm_state = IB_SMINFO_STATE_STANDBY;
+			osm_report_sm_state(sm);
+			__osm_sm_state_mgr_start_polling(sm);
 			break;
 		case OSM_SM_SIGNAL_WAIT_FOR_HANDOVER:
 			/*
@@ -599,61 +503,58 @@ osm_sm_state_mgr_process(IN osm_sm_state_mgr_t * const p_sm_mgr,
 			 * we should move back to discovering, since something must
 			 * have happened to it.
 			 */
-			__osm_sm_state_mgr_start_polling(p_sm_mgr);
+			__osm_sm_state_mgr_start_polling(sm);
 			break;
 		case OSM_SM_SIGNAL_DISCOVER:
-			p_sm_mgr->p_subn->sm_state =
-			    IB_SMINFO_STATE_DISCOVERING;
-			__osm_report_sm_state(p_sm_mgr);
+			sm->p_subn->sm_state = IB_SMINFO_STATE_DISCOVERING;
+			osm_report_sm_state(sm);
 			break;
 		default:
-			__osm_sm_state_mgr_signal_error(p_sm_mgr, signal);
+			__osm_sm_state_mgr_signal_error(sm, signal);
 			status = IB_INVALID_PARAMETER;
 			break;
 		}
 		break;
 
 	default:
-		osm_log(p_sm_mgr->p_log, OSM_LOG_ERROR,
+		osm_log(sm->p_log, OSM_LOG_ERROR,
 			"osm_sm_state_mgr_process: ERR 3208: "
 			"Invalid state %s\n",
-			osm_get_sm_mgr_state_str(p_sm_mgr->p_subn->sm_state));
+			osm_get_sm_mgr_state_str(sm->p_subn->sm_state));
 
 	}
 
-	cl_spinlock_release(&p_sm_mgr->state_lock);
+	cl_spinlock_release(&sm->state_lock);
 
-	OSM_LOG_EXIT(p_sm_mgr->p_log);
+	OSM_LOG_EXIT(sm->p_log);
 	return (status);
 }
 
 /**********************************************************************
  **********************************************************************/
-ib_api_status_t
-osm_sm_state_mgr_check_legality(IN osm_sm_state_mgr_t * const p_sm_mgr,
-				IN osm_sm_signal_t signal)
+ib_api_status_t osm_sm_state_mgr_check_legality(osm_sm_t *sm,
+						IN osm_sm_signal_t signal)
 {
 	ib_api_status_t status = IB_SUCCESS;
 
-	CL_ASSERT(p_sm_mgr);
+	CL_ASSERT(sm);
 
-	OSM_LOG_ENTER(p_sm_mgr->p_log, osm_sm_state_mgr_check_legality);
+	OSM_LOG_ENTER(sm->p_log, osm_sm_state_mgr_check_legality);
 
 	/*
 	 * The state lock prevents many race conditions from screwing
 	 * up the state transition process.
 	 */
-	cl_spinlock_acquire(&p_sm_mgr->state_lock);
+	cl_spinlock_acquire(&sm->state_lock);
 
-	if (osm_log_is_active(p_sm_mgr->p_log, OSM_LOG_DEBUG)) {
-		osm_log(p_sm_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_sm_state_mgr_check_legality: "
 			"Received signal %s in state %s\n",
 			osm_get_sm_mgr_signal_str(signal),
-			osm_get_sm_mgr_state_str(p_sm_mgr->p_subn->sm_state));
-	}
+			osm_get_sm_mgr_state_str(sm->p_subn->sm_state));
 
-	switch (p_sm_mgr->p_subn->sm_state) {
+	switch (sm->p_subn->sm_state) {
 	case IB_SMINFO_STATE_DISCOVERING:
 		switch (signal) {
 		case OSM_SM_SIGNAL_DISCOVERY_COMPLETED:
@@ -662,7 +563,7 @@ osm_sm_state_mgr_check_legality(IN osm_sm_state_mgr_t * const p_sm_mgr,
 			status = IB_SUCCESS;
 			break;
 		default:
-			__osm_sm_state_mgr_signal_error(p_sm_mgr, signal);
+			__osm_sm_state_mgr_signal_error(sm, signal);
 			status = IB_INVALID_PARAMETER;
 			break;
 		}
@@ -678,7 +579,7 @@ osm_sm_state_mgr_check_legality(IN osm_sm_state_mgr_t * const p_sm_mgr,
 			status = IB_SUCCESS;
 			break;
 		default:
-			__osm_sm_state_mgr_signal_error(p_sm_mgr, signal);
+			__osm_sm_state_mgr_signal_error(sm, signal);
 			status = IB_INVALID_PARAMETER;
 			break;
 		}
@@ -690,7 +591,7 @@ osm_sm_state_mgr_check_legality(IN osm_sm_state_mgr_t * const p_sm_mgr,
 			status = IB_SUCCESS;
 			break;
 		default:
-			__osm_sm_state_mgr_signal_error(p_sm_mgr, signal);
+			__osm_sm_state_mgr_signal_error(sm, signal);
 			status = IB_INVALID_PARAMETER;
 			break;
 		}
@@ -703,23 +604,23 @@ osm_sm_state_mgr_check_legality(IN osm_sm_state_mgr_t * const p_sm_mgr,
 			status = IB_SUCCESS;
 			break;
 		default:
-			__osm_sm_state_mgr_signal_error(p_sm_mgr, signal);
+			__osm_sm_state_mgr_signal_error(sm, signal);
 			status = IB_INVALID_PARAMETER;
 			break;
 		}
 		break;
 
 	default:
-		osm_log(p_sm_mgr->p_log, OSM_LOG_ERROR,
+		osm_log(sm->p_log, OSM_LOG_ERROR,
 			"osm_sm_state_mgr_check_legality: ERR 3209: "
 			"Invalid state %s\n",
-			osm_get_sm_mgr_state_str(p_sm_mgr->p_subn->sm_state));
+			osm_get_sm_mgr_state_str(sm->p_subn->sm_state));
 		status = IB_INVALID_PARAMETER;
 
 	}
 
-	cl_spinlock_release(&p_sm_mgr->state_lock);
+	cl_spinlock_release(&sm->state_lock);
 
-	OSM_LOG_EXIT(p_sm_mgr->p_log);
+	OSM_LOG_EXIT(sm->p_log);
 	return (status);
 }
diff --git a/opensm/opensm/osm_sminfo_rcv.c b/opensm/opensm/osm_sminfo_rcv.c
index 1e9e5cf..e179385 100644
--- a/opensm/opensm/osm_sminfo_rcv.c
+++ b/opensm/opensm/osm_sminfo_rcv.c
@@ -60,7 +60,7 @@
 #include <opensm/osm_node.h>
 #include <opensm/osm_helper.h>
 #include <opensm/osm_subnet.h>
-#include <opensm/osm_sm_state_mgr.h>
+#include <opensm/osm_sm.h>
 #include <opensm/osm_opensm.h>
 
 /**********************************************************************
@@ -280,8 +280,7 @@ __osm_sminfo_rcv_process_set_request(IN osm_sm_t * sm,
 	}
 
 	/* check legality of the needed transition in the SM state machine */
-	status = osm_sm_state_mgr_check_legality(&sm->sm_state_mgr,
-						 sm_signal);
+	status = osm_sm_state_mgr_check_legality(sm, sm_signal);
 	if (status != IB_SUCCESS) {
 		osm_log(sm->p_log, OSM_LOG_ERROR,
 			"__osm_sminfo_rcv_process_set_request: ERR 2F07: "
@@ -318,12 +317,12 @@ __osm_sminfo_rcv_process_set_request(IN osm_sm_t * sm,
 			"Received a STANDBY signal. Updating "
 			"sm_state_mgr master_guid: 0x%016" PRIx64 "\n",
 			cl_ntoh64(sm_smi->guid));
-		sm->sm_state_mgr.master_guid = sm_smi->guid;
+		sm->master_sm_guid = sm_smi->guid;
 	}
 
 	/* call osm_sm_state_mgr_process with the received signal. */
 	CL_PLOCK_RELEASE(sm->p_lock);
-	status = osm_sm_state_mgr_process(&sm->sm_state_mgr, sm_signal);
+	status = osm_sm_state_mgr_process(sm, sm_signal);
 
 	if (status != IB_SUCCESS)
 		osm_log(sm->p_log, OSM_LOG_ERROR,
@@ -371,7 +370,7 @@ __osm_sminfo_rcv_process_get_sm(IN osm_sm_t * sm,
 				"__osm_sminfo_rcv_process_get_sm: "
 				"Found master SM. Updating sm_state_mgr master_guid: 0x%016"
 				PRIx64 "\n", cl_ntoh64(p_sm->p_port->guid));
-			sm->sm_state_mgr.master_guid = p_sm->p_port->guid;
+			sm->master_sm_guid = p_sm->p_port->guid;
 			break;
 		case IB_SMINFO_STATE_DISCOVERING:
 		case IB_SMINFO_STATE_STANDBY:
@@ -386,8 +385,7 @@ __osm_sminfo_rcv_process_get_sm(IN osm_sm_t * sm,
 					"Found higher SM. Updating sm_state_mgr master_guid:"
 					" 0x%016" PRIx64 "\n",
 					cl_ntoh64(p_sm->p_port->guid));
-				sm->sm_state_mgr.master_guid =
-				    p_sm->p_port->guid;
+				sm->master_sm_guid = p_sm->p_port->guid;
 			}
 			break;
 		default:
@@ -402,20 +400,19 @@ __osm_sminfo_rcv_process_get_sm(IN osm_sm_t * sm,
 		case IB_SMINFO_STATE_MASTER:
 			/* This means the master is alive */
 			/* Signal that to the SM state mgr */
-			osm_sm_state_mgr_signal_master_is_alive(&sm->sm_state_mgr);
+			osm_sm_state_mgr_signal_master_is_alive(sm);
 			break;
 		case IB_SMINFO_STATE_STANDBY:
 			/* This should be the response from the sm we are polling. */
 			/* If it is - then signal master is alive */
-			if (sm->sm_state_mgr.master_guid == p_sm->p_port->guid) {
+			if (sm->master_sm_guid == p_sm->p_port->guid) {
 				/* Make sure that it is an SM with higher priority than us.
 				   If we started polling it when it was master, and it moved
 				   to standby - then it might be with a lower priority than
 				   us - and then we don't want to continue polling it. */
 				if (__osm_sminfo_rcv_remote_sm_is_higher
 				    (sm, p_smi) == TRUE)
-					osm_sm_state_mgr_signal_master_is_alive
-					    (&sm->sm_state_mgr);
+					osm_sm_state_mgr_signal_master_is_alive(sm);
 			}
 			break;
 		default:
@@ -430,10 +427,9 @@ __osm_sminfo_rcv_process_get_sm(IN osm_sm_t * sm,
 			/* If this is a response due to our polling, this means that we are
 			   waiting for a handover from this SM, and it is still alive -
 			   signal that. */
-			if (sm->sm_state_mgr.p_polling_sm != NULL) {
-				osm_sm_state_mgr_signal_master_is_alive(&sm->
-									sm_state_mgr);
-			} else {
+			if (sm->p_polling_sm)
+				osm_sm_state_mgr_signal_master_is_alive(sm);
+			else {
 				/* This is a response we got while sweeping the subnet.
 				   We will handle a case of handover needed later on, when the sweep
 				   is done and all SMs are recongnized. */
diff --git a/opensm/opensm/osm_state_mgr.c b/opensm/opensm/osm_state_mgr.c
index 20883e4..c53ed45 100644
--- a/opensm/opensm/osm_state_mgr.c
+++ b/opensm/opensm/osm_state_mgr.c
@@ -65,7 +65,6 @@
 #include <opensm/osm_port.h>
 #include <opensm/osm_pkey_mgr.h>
 #include <vendor/osm_vendor_api.h>
-#include <opensm/osm_sm_state_mgr.h>
 #include <opensm/osm_inform.h>
 #include <opensm/osm_opensm.h>
 
@@ -790,7 +789,7 @@ __osm_state_mgr_send_handover(IN osm_sm_t * const sm,
 		"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");
-	sm->sm_state_mgr.master_guid = p_port->guid;
+	sm->master_sm_guid = p_port->guid;
 
 	context.smi_context.port_guid = p_port->guid;
 	context.smi_context.set_method = TRUE;
@@ -1106,8 +1105,7 @@ _repeat_discovery:
 		osm_drop_mgr_process(&sm->drop_mgr);
 
 		/* Move to DISCOVERING state */
-		osm_sm_state_mgr_process(&sm->sm_state_mgr,
-					 OSM_SM_SIGNAL_DISCOVER);
+		osm_sm_state_mgr_process(sm, OSM_SM_SIGNAL_DISCOVER);
 		return;
 	}
 
@@ -1123,7 +1121,7 @@ _repeat_discovery:
 		 * Call the sm_state_mgr with signal
 		 * MASTER_OR_HIGHER_SM_DETECTED_DONE
 		 */
-		osm_sm_state_mgr_process(&sm->sm_state_mgr,
+		osm_sm_state_mgr_process(sm,
 					 OSM_SM_SIGNAL_MASTER_OR_HIGHER_SM_DETECTED_DONE);
 		osm_log_msg_box(sm->p_log, OSM_LOG_VERBOSE, __FUNCTION__,
 				"ENTERING STANDBY STATE");
@@ -1149,7 +1147,7 @@ _repeat_discovery:
 			/* need to handover the mastership
 			 * to the remote sm, and move to standby */
 			__osm_state_mgr_send_handover(sm, p_remote_sm);
-			osm_sm_state_mgr_process(&sm->sm_state_mgr,
+			osm_sm_state_mgr_process(sm,
 						 OSM_SM_SIGNAL_HANDOVER_SENT);
 			sm->state = OSM_SM_STATE_STANDBY;
 			return;
@@ -1163,8 +1161,8 @@ _repeat_discovery:
 				 * need to wait for that SM to relinquish control
 				 * of its portion of the subnet. C14-60.2.1.
 				 * Also - need to start polling on that SM. */
-				sm->sm_state_mgr.p_polling_sm = p_remote_sm;
-				osm_sm_state_mgr_process(&sm->sm_state_mgr,
+				sm->p_polling_sm = p_remote_sm;
+				osm_sm_state_mgr_process(sm,
 				     OSM_SM_SIGNAL_WAIT_FOR_HANDOVER);
 				return;
 			}
@@ -1180,8 +1178,7 @@ _repeat_discovery:
 	 * DISCOVERY_COMPLETED
 	 */
 	if (sm->p_subn->sm_state == IB_SMINFO_STATE_DISCOVERING)
-		osm_sm_state_mgr_process(&sm->sm_state_mgr,
-					 OSM_SM_SIGNAL_DISCOVERY_COMPLETED);
+		osm_sm_state_mgr_process(sm, OSM_SM_SIGNAL_DISCOVERY_COMPLETED);
 
 	osm_pkey_mgr_process(sm->p_subn->p_osm);
 
-- 
1.5.4.rc5




More information about the general mailing list