[ofa-general] [PATCH] opensm: cleanup IB_SMINFO_STATE_INIT

Sasha Khapyorsky sashak at voltaire.com
Thu Feb 7 20:11:21 PST 2008


This state is not defined by IBTA and really not useful in OpenSM.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 opensm/include/iba/ib_types.h    |   12 ------------
 opensm/include/opensm/osm_base.h |    2 +-
 opensm/opensm/osm_console.c      |    2 --
 opensm/opensm/osm_helper.c       |   13 +++++++------
 opensm/opensm/osm_sm_state_mgr.c |   35 +++--------------------------------
 opensm/opensm/osm_state_mgr.c    |    8 --------
 6 files changed, 11 insertions(+), 61 deletions(-)

diff --git a/opensm/include/iba/ib_types.h b/opensm/include/iba/ib_types.h
index 672184b..649ef1c 100644
--- a/opensm/include/iba/ib_types.h
+++ b/opensm/include/iba/ib_types.h
@@ -10588,18 +10588,6 @@ typedef uint32_t ib_mr_mod_t;
 *		The access rights the memory region are being modified.
 *****/
 
-/****d* IBA Base: Constants/IB_SMINFO_STATE_INIT
-* NAME
-*	IB_SMINFO_STATE_INIT
-*
-* DESCRIPTION
-*	Encoded state value used in the SMInfo attribute.
-*
-* SOURCE
-*/
-#define IB_SMINFO_STATE_INIT					4
-/**********/
-
 /****d* IBA Base: Constants/IB_SMINFO_ATTR_MOD_HANDOVER
 * NAME
 *	IB_SMINFO_ATTR_MOD_HANDOVER
diff --git a/opensm/include/opensm/osm_base.h b/opensm/include/opensm/osm_base.h
index 6f784ca..d5e3c27 100644
--- a/opensm/include/opensm/osm_base.h
+++ b/opensm/include/opensm/osm_base.h
@@ -794,7 +794,7 @@ typedef uintn_t osm_signal_t;
 * SYNOPSIS
 */
 typedef enum _osm_sm_signal {
-	OSM_SM_SIGNAL_INIT = 0,
+	OSM_SM_SIGNAL_NONE = 0,
 	OSM_SM_SIGNAL_DISCOVERY_COMPLETED,
 	OSM_SM_SIGNAL_POLLING_TIMEOUT,
 	OSM_SM_SIGNAL_DISCOVER,
diff --git a/opensm/opensm/osm_console.c b/opensm/opensm/osm_console.c
index 1a6208f..9459b03 100644
--- a/opensm/opensm/osm_console.c
+++ b/opensm/opensm/osm_console.c
@@ -266,8 +266,6 @@ static void priority_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
 static char *sm_state_str(int state)
 {
 	switch (state) {
-	case IB_SMINFO_STATE_INIT:
-		return ("Init");
 	case IB_SMINFO_STATE_DISCOVERING:
 		return ("Discovering");
 	case IB_SMINFO_STATE_STANDBY:
diff --git a/opensm/opensm/osm_helper.c b/opensm/opensm/osm_helper.c
index bd345bc..de4ba33 100644
--- a/opensm/opensm/osm_helper.c
+++ b/opensm/opensm/osm_helper.c
@@ -57,6 +57,8 @@
 
 #define LINE_LENGTH 256
 
+#define ARR_SIZE(a) (sizeof(a)/sizeof((a)[0]))
+
 /* we use two tables - one for queries and one for responses */
 const char *const __ib_sa_method_str[] = {
 	"RESERVED",		/* 0 */
@@ -2320,7 +2322,7 @@ const char *osm_get_lsa_str(IN uint8_t const lsa)
  **********************************************************************/
 
 const char *const __osm_sm_mgr_signal_str[] = {
-	"OSM_SM_SIGNAL_INIT",	/* 0 */
+	"OSM_SM_SIGNAL_NONE",	/* 0 */
 	"OSM_SM_SIGNAL_DISCOVERY_COMPLETED",	/* 2 */
 	"OSM_SM_SIGNAL_POLLING_TIMEOUT",	/* 3 */
 	"OSM_SM_SIGNAL_DISCOVER",	/* 4 */
@@ -2348,13 +2350,12 @@ const char *const __osm_sm_mgr_state_str[] = {
 	"IB_SMINFO_STATE_DISCOVERING",	/* 1 */
 	"IB_SMINFO_STATE_STANDBY",	/* 2 */
 	"IB_SMINFO_STATE_MASTER",	/* 3 */
-	"IB_SMINFO_STATE_INIT",	/* 4 */
-	"UNKNOWN STATE!!"	/* 5 */
+	"UNKNOWN STATE!!"	/* 4 */
 };
 
 const char *osm_get_sm_mgr_state_str(IN uint16_t state)
 {
-	if (state > IB_SMINFO_STATE_INIT)
-		state = IB_SMINFO_STATE_INIT + 1;
-	return (__osm_sm_mgr_state_str[state]);
+	return state < ARR_SIZE(__osm_sm_mgr_state_str) ?
+		__osm_sm_mgr_state_str[state] :
+		__osm_sm_mgr_state_str[ARR_SIZE(__osm_sm_mgr_state_str) - 1];
 }
diff --git a/opensm/opensm/osm_sm_state_mgr.c b/opensm/opensm/osm_sm_state_mgr.c
index 27d7536..73d39fa 100644
--- a/opensm/opensm/osm_sm_state_mgr.c
+++ b/opensm/opensm/osm_sm_state_mgr.c
@@ -378,8 +378,9 @@ osm_sm_state_mgr_init(IN osm_sm_state_mgr_t * const p_sm_mgr, IN osm_sm_t * sm)
 		p_sm_mgr->p_subn->sm_state = IB_SMINFO_STATE_NOTACTIVE;
 		__osm_sm_state_mgr_notactive_msg(p_sm_mgr);
 	} else {
-		/* init the state of the SM to init */
-		p_sm_mgr->p_subn->sm_state = IB_SMINFO_STATE_INIT;
+		 /* init the state of the SM to discovering */
+		p_sm_mgr->p_subn->sm_state = IB_SMINFO_STATE_DISCOVERING;
+		__osm_sm_state_mgr_discovering_msg(p_sm_mgr);
 	}
 
 	status = cl_spinlock_init(&p_sm_mgr->state_lock);
@@ -452,24 +453,6 @@ osm_sm_state_mgr_process(IN osm_sm_state_mgr_t * const p_sm_mgr,
 	}
 
 	switch (p_sm_mgr->p_subn->sm_state) {
-	case IB_SMINFO_STATE_INIT:
-		switch (signal) {
-		case OSM_SM_SIGNAL_INIT:
-			/*
-			 * Update the state of the SM to DISCOVERING
-			 */
-			__osm_sm_state_mgr_discovering_msg(p_sm_mgr);
-			p_sm_mgr->p_subn->sm_state =
-			    IB_SMINFO_STATE_DISCOVERING;
-			break;
-
-		default:
-			__osm_sm_state_mgr_signal_error(p_sm_mgr, signal);
-			status = IB_INVALID_PARAMETER;
-			break;
-		}
-		break;
-
 	case IB_SMINFO_STATE_DISCOVERING:
 		switch (signal) {
 		case OSM_SM_SIGNAL_DISCOVERY_COMPLETED:
@@ -706,18 +689,6 @@ osm_sm_state_mgr_check_legality(IN osm_sm_state_mgr_t * const p_sm_mgr,
 	}
 
 	switch (p_sm_mgr->p_subn->sm_state) {
-	case IB_SMINFO_STATE_INIT:
-		switch (signal) {
-		case OSM_SM_SIGNAL_INIT:
-			status = IB_SUCCESS;
-			break;
-		default:
-			__osm_sm_state_mgr_signal_error(p_sm_mgr, signal);
-			status = IB_INVALID_PARAMETER;
-			break;
-		}
-		break;
-
 	case IB_SMINFO_STATE_DISCOVERING:
 		switch (signal) {
 		case OSM_SM_SIGNAL_DISCOVERY_COMPLETED:
diff --git a/opensm/opensm/osm_state_mgr.c b/opensm/opensm/osm_state_mgr.c
index 54f56c0..20883e4 100644
--- a/opensm/opensm/osm_state_mgr.c
+++ b/opensm/opensm/osm_state_mgr.c
@@ -1338,14 +1338,6 @@ void osm_state_mgr_process(IN osm_sm_t *sm, IN osm_signal_t signal)
 				break;
 			}
 
-			/*
-			 * If the osm_sm_state_mgr is in INIT state - signal
-			 * it with a INIT signal to move it to DISCOVERY state.
-			 */
-			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(sm);
 			break;
 
-- 
1.5.4.rc5




More information about the general mailing list