Skip to contentSkip to conversation

opensm: Only log SM PORT "state" when it changes

PATCH In review Hal Rosenstock 3 participants 3 messages Sep 30, 2011 – Nov 2, 2011 1 message not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 opensm: Only log SM PORT "state" when it changes

rather than every sweep time
so don't spam syslog and opensm.log when port stays down

---

include/opensm/osm_subnet.h +5 -0
index 8bbce7c..2e88479 100644
@@ -548,6 +548,7 @@ typedef struct osm_subn {
 	ib_net16_t master_sm_base_lid;
 	ib_net16_t sm_base_lid;
 	ib_net64_t sm_port_guid;
+	uint8_t last_sm_port_state;
 	uint8_t sm_state;
 	osm_subn_opt_t opt;
 	struct osm_qos_policy *p_qos_policy;
@@ -607,6 +608,10 @@ typedef struct osm_subn {
 *	sm_port_guid
 *		This SM's own port GUID.
 *
+*	last_sm_port_state
+*		Last state of this SM's port.
+*		0 is down and 1 is up.
+*
 *	sm_state
 *		The high-level state of the SM.  This value is made available
 *		in the SMInfo attribute.
opensm/osm_state_mgr.c +13 -2
index dd308f2..b413709 100644
@@ -1198,8 +1198,12 @@ repeat_discovery:
 		return;
 
 	if (state_mgr_is_sm_port_down(sm) == TRUE) {
-		osm_log(sm->p_log, OSM_LOG_SYS, "SM port is down\n");
-		OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE, "SM PORT DOWN");
+		if (sm->p_subn->last_sm_port_state) {
+			sm->p_subn->last_sm_port_state = 0;
+			osm_log(sm->p_log, OSM_LOG_SYS, "SM port is down\n");
+			OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE,
+					"SM PORT DOWN");
+		}
 
 		/* Run the drop manager - we want to clear all records */
 		osm_drop_mgr_process(sm);
@@ -1210,6 +1214,13 @@ repeat_discovery:
 		osm_opensm_report_event(sm->p_subn->p_osm,
 				OSM_EVENT_ID_STATE_CHANGE, NULL);
 		return;
+	} else {
+		if (!sm->p_subn->last_sm_port_state) {
+			sm->p_subn->last_sm_port_state = 1;
+			osm_log(sm->p_log, OSM_LOG_SYS, "SM port is up\n");
+			OSM_LOG_MSG_BOX(sm->p_log, OSM_LOG_VERBOSE,
+					"SM PORT UP");
+		}
 	}
 
 	status = state_mgr_sweep_hop_1(sm);
opensm/osm_subnet.c +1 -0
index 8d636bc..11d7cf5 100644
@@ -563,6 +563,7 @@ ib_api_status_t osm_subn_init(IN osm_subn_t * p_subn, IN osm_opensm_t * p_osm,
 	/* we assume master by default - so we only need to set it true if STANDBY */
 	p_subn->coming_out_of_standby = FALSE;
 	p_subn->sweeping_enabled = TRUE;
+	p_subn->last_sm_port_state = 1;
 
 	return IB_SUCCESS;
 }

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 4E85E347.3030005-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org