[ofa-general] [PATCH 6/7] Add node-name-map support to OpenSM; using the "default" map.

Ira Weiny weiny2 at llnl.gov
Thu Nov 1 20:15:24 PDT 2007


>From 35280cfd5229ccc8d91b6fd98e0f4b58193d0d03 Mon Sep 17 00:00:00 2001
From: Ira K. Weiny <weiny2 at llnl.gov>
Date: Thu, 1 Nov 2007 19:41:37 -0700
Subject: [PATCH] Add node-name-map support to OpenSM; using the "default" map.

Signed-off-by: Ira K. Weiny <weiny2 at llnl.gov>
---
 opensm/include/opensm/osm_node.h   |    2 +-
 opensm/include/opensm/osm_opensm.h |    2 ++
 opensm/include/opensm/osm_subnet.h |    1 +
 opensm/opensm/osm_node.c           |    6 ++++++
 opensm/opensm/osm_node_desc_rcv.c  |   14 ++++++++++++--
 opensm/opensm/osm_opensm.c         |    4 ++++
 6 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/opensm/include/opensm/osm_node.h b/opensm/include/opensm/osm_node.h
index f87e81d..8af5418 100644
--- a/opensm/include/opensm/osm_node.h
+++ b/opensm/include/opensm/osm_node.h
@@ -106,7 +106,7 @@ typedef struct _osm_node {
 	ib_node_desc_t node_desc;
 	uint32_t discovery_count;
 	uint32_t physp_tbl_size;
-	char print_desc[IB_NODE_DESCRIPTION_SIZE + 1];
+	char *print_desc;
 	osm_physp_t physp_table[1];
 } osm_node_t;
 /*
diff --git a/opensm/include/opensm/osm_opensm.h b/opensm/include/opensm/osm_opensm.h
index 1ea1ec2..1b5edb8 100644
--- a/opensm/include/opensm/osm_opensm.h
+++ b/opensm/include/opensm/osm_opensm.h
@@ -52,6 +52,7 @@
 #include <complib/cl_dispatcher.h>
 #include <complib/cl_passivelock.h>
 #include <complib/cl_atomic.h>
+#include <complib/cl_nodenamemap.h>
 #include <opensm/osm_stats.h>
 #include <opensm/osm_log.h>
 #include <opensm/osm_sm.h>
@@ -168,6 +169,7 @@ typedef struct _osm_opensm_t {
 	struct osm_routing_engine routing_engine;
 	osm_stats_t stats;
 	osm_console_t console;
+	nn_map_t *node_name_map;
 } osm_opensm_t;
 /*
 * FIELDS
diff --git a/opensm/include/opensm/osm_subnet.h b/opensm/include/opensm/osm_subnet.h
index dada8bf..452098b 100644
--- a/opensm/include/opensm/osm_subnet.h
+++ b/opensm/include/opensm/osm_subnet.h
@@ -297,6 +297,7 @@ typedef struct _osm_subn_opt {
 	char *event_db_dump_file;
 #endif				/* ENABLE_OSM_PERF_MGR */
 	char *event_plugin_name;
+	char *node_name_map_name;
 } osm_subn_opt_t;
 /*
 * FIELDS
diff --git a/opensm/opensm/osm_node.c b/opensm/opensm/osm_node.c
index 645daa9..f34da1f 100644
--- a/opensm/opensm/osm_node.c
+++ b/opensm/opensm/osm_node.c
@@ -131,6 +131,7 @@ osm_node_t *osm_node_new(IN const osm_madw_t * const p_madw)
 
 		osm_node_init_physp(p_node, p_madw);
 	}
+	p_node->print_desc = "<unknown>";
 
 	return (p_node);
 }
@@ -146,6 +147,11 @@ static void osm_node_destroy(IN osm_node_t * p_node)
 	 */
 	for (i = 0; i < p_node->physp_tbl_size; i++)
 		osm_physp_destroy(&p_node->physp_table[i]);
+
+	/* cleanup printable node_desc field */
+	if (p_node->print_desc) {
+		free(p_node->print_desc);
+	}
 }
 
 /**********************************************************************
diff --git a/opensm/opensm/osm_node_desc_rcv.c b/opensm/opensm/osm_node_desc_rcv.c
index d50883c..f758d5a 100644
--- a/opensm/opensm/osm_node_desc_rcv.c
+++ b/opensm/opensm/osm_node_desc_rcv.c
@@ -58,6 +58,7 @@
 #include <opensm/osm_madw.h>
 #include <opensm/osm_log.h>
 #include <opensm/osm_node.h>
+#include <opensm/osm_opensm.h>
 #include <opensm/osm_subnet.h>
 
 /**********************************************************************
@@ -67,13 +68,22 @@ __osm_nd_rcv_process_nd(IN const osm_nd_rcv_t * const p_rcv,
 			IN osm_node_t * const p_node,
 			IN const ib_node_desc_t * const p_nd)
 {
+	char *tmp_desc;
+	char print_desc[IB_NODE_DESCRIPTION_SIZE + 1];
+
 	OSM_LOG_ENTER(p_rcv->p_log, __osm_nd_rcv_process_nd);
 
 	memcpy(&p_node->node_desc.description, p_nd, sizeof(*p_nd));
 
 	/* also set up a printable version */
-	memcpy(&p_node->print_desc, p_nd, sizeof(*p_nd));
-	p_node->print_desc[IB_NODE_DESCRIPTION_SIZE] = '\0';
+	memcpy(print_desc, p_nd, sizeof(*p_nd));
+	print_desc[IB_NODE_DESCRIPTION_SIZE] = '\0';
+	tmp_desc = remap_node_name(p_rcv->p_subn->p_osm->node_name_map,
+			cl_ntoh64(osm_node_get_node_guid(p_node)),
+			print_desc);
+
+	/* make a copy for this node to "own" */
+	p_node->print_desc = strdup(tmp_desc);
 
 	if (osm_log_is_active(p_rcv->p_log, OSM_LOG_VERBOSE)) {
 		osm_log(p_rcv->p_log, OSM_LOG_VERBOSE,
diff --git a/opensm/opensm/osm_opensm.c b/opensm/opensm/osm_opensm.c
index 5b45401..9841c75 100644
--- a/opensm/opensm/osm_opensm.c
+++ b/opensm/opensm/osm_opensm.c
@@ -183,6 +183,8 @@ void osm_opensm_destroy(IN osm_opensm_t * const p_osm)
 	osm_subn_destroy(&p_osm->subn);
 	cl_disp_destroy(&p_osm->disp);
 
+	close_node_name_map(p_osm->node_name_map);
+
 	cl_plock_destroy(&p_osm->lock);
 
 	osm_log_destroy(&p_osm->log);
@@ -310,6 +312,8 @@ osm_opensm_init(IN osm_opensm_t * const p_osm,
 		goto Exit;
 	}
 
+	p_osm->node_name_map = open_node_name_map(NULL);
+
       Exit:
 	osm_log(&p_osm->log, OSM_LOG_FUNCS, "osm_opensm_init: ]\n");	/* Format Waived */
 	return (status);
-- 
1.5.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0006-Add-node-name-map-support-to-OpenSM-using-the-defa.patch
Type: application/octet-stream
Size: 4839 bytes
Desc: not available
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20071101/4dc35094/attachment.obj>


More information about the general mailing list