[ofa-general] [PATCHv2] opensm/PerfMgr: Primarily fix enhanced switch port 0 perf manager operation

Hal Rosenstock halr at obsidianresearch.com
Wed Feb 4 14:06:06 PST 2009


Sasha,

Attached is a revised patch superceeding any outstanding perfmgr
patches. This version fixes esp0 perfmgr operation. It determines ESP0
for the monitored node and subsequently copies this into the db node.
Also, it fixes redirection table size and port number validation.

-- Hal

-------------- next part --------------

opensm/PerfMgr: Primarily fix enhanced switch port 0 perf manager operation 

Determine ESP0 for monitored node and copy into db node
Also, fix redirection table size and port number validation

Signed-off-by: Hal Rosenstock <hal.rosenstock at gmail.com>
---
diff --git a/opensm/include/opensm/osm_perfmgr.h b/opensm/include/opensm/osm_perfmgr.h
index c8a4add..87fae37 100644
--- a/opensm/include/opensm/osm_perfmgr.h
+++ b/opensm/include/opensm/osm_perfmgr.h
@@ -100,6 +100,7 @@ typedef struct _monitored_node {
 	cl_map_item_t map_item;
 	struct _monitored_node *next;
 	uint64_t guid;
+	boolean_t esp0;
 	char *name;
 	uint32_t redir_tbl_size;
 	redir_t redir_port[1];	/* redirection on a per port basis */
diff --git a/opensm/include/opensm/osm_perfmgr_db.h b/opensm/include/opensm/osm_perfmgr_db.h
index 5c96378..cb5c40a 100644
--- a/opensm/include/opensm/osm_perfmgr_db.h
+++ b/opensm/include/opensm/osm_perfmgr_db.h
@@ -134,6 +134,7 @@ typedef struct _db_port {
 typedef struct _db_node {
 	cl_map_item_t map_item;	/* must be first */
 	uint64_t node_guid;
+	boolean_t esp0;
 	_db_port_t *ports;
 	uint8_t num_ports;
 	char node_name[NODE_NAME_SIZE];
@@ -155,7 +156,8 @@ perfmgr_db_t *perfmgr_db_construct(struct osm_perfmgr *perfmgr);
 void perfmgr_db_destroy(perfmgr_db_t * db);
 
 perfmgr_db_err_t perfmgr_db_create_entry(perfmgr_db_t * db, uint64_t guid,
-					 uint8_t num_ports, char *node_name);
+					 boolean_t esp0, uint8_t num_ports,
+					 char *node_name);
 
 perfmgr_db_err_t perfmgr_db_add_err_reading(perfmgr_db_t * db, uint64_t guid,
 					    uint8_t port,
diff --git a/opensm/opensm/osm_perfmgr.c b/opensm/opensm/osm_perfmgr.c
index a2ce50f..b01d612 100644
--- a/opensm/opensm/osm_perfmgr.c
+++ b/opensm/opensm/osm_perfmgr.c
@@ -438,7 +438,7 @@ static void __collect_guids(cl_map_item_t * const p_map_item, void *context)
 	if (cl_qmap_get(&pm->monitored_map, node_guid)
 	    == cl_qmap_end(&pm->monitored_map)) {
 		/* if not already in our map add it */
-		size = node->node_info.num_ports;
+		size = osm_node_get_num_physp(node);
 		mon_node = malloc(sizeof(*mon_node) + sizeof(redir_t) * size);
 		if (!mon_node) {
 			OSM_LOG(pm->log, OSM_LOG_ERROR, "PerfMgr: ERR 4C06: "
@@ -449,7 +449,15 @@ static void __collect_guids(cl_map_item_t * const p_map_item, void *context)
 		memset(mon_node, 0, sizeof(*mon_node) + sizeof(redir_t) * size);
 		mon_node->guid = node_guid;
 		mon_node->name = strdup(node->print_desc);
-		mon_node->redir_tbl_size = size + 1;
+		mon_node->redir_tbl_size = size;
+		/* check for enhanced switch port 0 */
+		if (node && osm_node_get_type(node) == IB_NODE_TYPE_SWITCH &&
+		    node->sw &&
+		    ib_switch_info_is_enhanced_port0(&node->sw->switch_info))
+			mon_node->esp0 = TRUE;
+		else
+			mon_node->esp0 = FALSE;
+
 		cl_qmap_insert(&(pm->monitored_map), node_guid,
 			       (cl_map_item_t *) mon_node);
 	}
@@ -491,8 +499,8 @@ __osm_perfmgr_query_counters(cl_map_item_t * const p_map_item, void *context)
 	node_guid = cl_ntoh64(node->node_info.node_guid);
 
 	/* make sure we have a database object ready to store this information */
-	if (perfmgr_db_create_entry(pm->db, node_guid, num_ports,
-				    node->print_desc) !=
+	if (perfmgr_db_create_entry(pm->db, node_guid, mon_node->esp0,
+				    num_ports, node->print_desc) !=
 	    PERFMGR_EVENT_DB_SUCCESS) {
 		OSM_LOG(pm->log, OSM_LOG_ERROR,
 			"ERR 4C08: DB create entry failed for 0x%"
@@ -501,10 +509,8 @@ __osm_perfmgr_query_counters(cl_map_item_t * const p_map_item, void *context)
 		goto Exit;
 	}
 
-	/* if switch, check for enhanced port 0 */
-	if (osm_node_get_type(node) == IB_NODE_TYPE_SWITCH &&
-	    node->sw &&
-	    ib_switch_info_is_enhanced_port0(&node->sw->switch_info))
+	/* check for switch enhanced port 0 */
+	if (mon_node->esp0)
 		startport = 0;
 
 	/* issue the query for each port */
@@ -1136,7 +1142,7 @@ static void osm_pc_rcv_process(void *context, void *data)
 		/* LID redirection support (easier than GID redirection) */
 		cl_plock_acquire(pm->lock);
 		/* Now, validate port number */
-		if (port > p_mon_node->redir_tbl_size) {
+		if (port >= p_mon_node->redir_tbl_size) {
 			cl_plock_release(pm->lock);
 			OSM_LOG(pm->log, OSM_LOG_ERROR, "ERR 4C13: "
 				"Invalid port num %d for GUID 0x%016"
diff --git a/opensm/opensm/osm_perfmgr_db.c b/opensm/opensm/osm_perfmgr_db.c
index bff9a0f..ef47ce3 100644
--- a/opensm/opensm/osm_perfmgr_db.c
+++ b/opensm/opensm/osm_perfmgr_db.c
@@ -90,14 +90,15 @@ static inline perfmgr_db_err_t bad_node_port(_db_node_t * node, uint8_t port)
 {
 	if (!node)
 		return (PERFMGR_EVENT_DB_GUIDNOTFOUND);
-	if (port == 0 || port >= node->num_ports)
+	if (port >= node->num_ports || (!node->esp0 && port == 0))
 		return (PERFMGR_EVENT_DB_PORTNOTFOUND);
 	return (PERFMGR_EVENT_DB_SUCCESS);
 }
 
 /** =========================================================================
  */
-static _db_node_t *__malloc_node(uint64_t guid, uint8_t num_ports, char *name)
+static _db_node_t *__malloc_node(uint64_t guid, boolean_t esp0,
+				 uint8_t num_ports, char *name)
 {
 	int i = 0;
 	time_t cur_time = 0;
@@ -110,6 +111,7 @@ static _db_node_t *__malloc_node(uint64_t guid, uint8_t num_ports, char *name)
 		goto free_rc;
 	rc->num_ports = num_ports;
 	rc->node_guid = guid;
+	rc->esp0 = esp0;
 
 	cur_time = time(NULL);
 	for (i = 0; i < num_ports; i++) {
@@ -151,14 +153,15 @@ static perfmgr_db_err_t __insert(perfmgr_db_t * db, _db_node_t * node)
 /**********************************************************************
  **********************************************************************/
 perfmgr_db_err_t
-perfmgr_db_create_entry(perfmgr_db_t * db, uint64_t guid,
+perfmgr_db_create_entry(perfmgr_db_t * db, uint64_t guid, boolean_t esp0,
 			uint8_t num_ports, char *name)
 {
 	perfmgr_db_err_t rc = PERFMGR_EVENT_DB_SUCCESS;
 
 	cl_plock_excl_acquire(&db->lock);
 	if (!_get(db, guid)) {
-		_db_node_t *pc_node = __malloc_node(guid, num_ports, name);
+		_db_node_t *pc_node = __malloc_node(guid, esp0, num_ports,
+						    name);
 		if (!pc_node) {
 			rc = PERFMGR_EVENT_DB_NOMEM;
 			goto Exit;


More information about the general mailing list