[ofa-general] [PATCH 4/6] Add switch-map support to OpenSM; using the "default" map.
Ira Weiny
weiny2 at llnl.gov
Thu Oct 25 11:43:36 PDT 2007
>From ba6cea679d745587bfe37e9be45d7491a5be9918 Mon Sep 17 00:00:00 2001
From: Ira K. Weiny <weiny2 at llnl.gov>
Date: Tue, 23 Oct 2007 16:04:46 -0700
Subject: [PATCH] Add switch-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 | 1 +
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, 25 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..76e82d8 100644
--- a/opensm/include/opensm/osm_opensm.h
+++ b/opensm/include/opensm/osm_opensm.h
@@ -168,6 +168,7 @@ typedef struct _osm_opensm_t {
struct osm_routing_engine routing_engine;
osm_stats_t stats;
osm_console_t console;
+ sw_map_t *switch_map;
} osm_opensm_t;
/*
* FIELDS
diff --git a/opensm/include/opensm/osm_subnet.h b/opensm/include/opensm/osm_subnet.h
index dada8bf..573d506 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 *switch_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..b050ae1 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 = lookup_switch_name(p_rcv->p_subn->p_osm->switch_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..53f4f8b 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);
+ free_switch_map(p_osm->switch_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->switch_map = create_switch_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: 0004-Add-switch-map-support-to-OpenSM-using-the-default.patch
Type: application/octet-stream
Size: 4572 bytes
Desc: not available
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20071025/abeea881/attachment.obj>
More information about the general
mailing list