[openib-general] [PATCH 1/2] OpenSM: Add a printable node description to osm_node_t
Hal Rosenstock
halr at voltaire.com
Tue Feb 6 07:52:50 PST 2007
OpenSM: Add a printable node description to osm_node_t
Also, convert memcpy's to use this rather than temporary one
Signed-off-by: Ira K. Weiny <weiny2 at llnl.gov>
Signed-off-by: Hal Rosenstock <halr at voltaire.com>
diff --git a/osm/include/opensm/osm_node.h b/osm/include/opensm/osm_node.h
index 8417f10..6f95d5d 100644
--- a/osm/include/opensm/osm_node.h
+++ b/osm/include/opensm/osm_node.h
@@ -107,6 +107,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];
osm_physp_t physp_table[1];
} osm_node_t;
/*
@@ -135,6 +136,9 @@ typedef struct _osm_node
* than the number of ports in the node, since port numbers
* start with 1 for some bizzare reason.
*
+* print_desc
+* A printable version of the node description.
+*
* phsyp_table
* Array of physical port objects belonging to this node.
* Index is contiguous by local port number.
diff --git a/osm/opensm/osm_drop_mgr.c b/osm/opensm/osm_drop_mgr.c
index 6c5939e..0d08ff6 100644
--- a/osm/opensm/osm_drop_mgr.c
+++ b/osm/opensm/osm_drop_mgr.c
@@ -367,19 +367,12 @@ __osm_drop_mgr_remove_port(
if (osm_log_is_active( p_mgr->p_log, OSM_LOG_INFO ))
{
- char desc[IB_NODE_DESCRIPTION_SIZE + 1];
-
- if (p_node)
- {
- memcpy(desc, p_node->node_desc.description, IB_NODE_DESCRIPTION_SIZE);
- desc[IB_NODE_DESCRIPTION_SIZE] = '\0';
- }
osm_log( p_mgr->p_log, OSM_LOG_INFO,
"__osm_drop_mgr_remove_port: "
"Removed port with GUID:0x%016" PRIx64
" LID range [0x%X,0x%X] of node:%s\n",
cl_ntoh64( port_gid.unicast.interface_id ),
- min_lid_ho, max_lid_ho, p_node ? desc : "UNKNOWN" );
+ min_lid_ho, max_lid_ho, p_node ? p_node->print_desc : "UNKNOWN" );
}
Exit:
diff --git a/osm/opensm/osm_node_desc_rcv.c b/osm/opensm/osm_node_desc_rcv.c
index 13c5a93..fc96c12 100644
--- a/osm/opensm/osm_node_desc_rcv.c
+++ b/osm/opensm/osm_node_desc_rcv.c
@@ -69,23 +69,23 @@ __osm_nd_rcv_process_nd(
IN osm_node_t* const p_node,
IN const ib_node_desc_t* const p_nd )
{
- char 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';
+
if( osm_log_is_active( p_rcv->p_log, OSM_LOG_VERBOSE ) )
{
- memcpy( desc, p_nd, sizeof(*p_nd) );
- /* Guarantee null termination before printing. */
- desc[IB_NODE_DESCRIPTION_SIZE] = '\0';
-
osm_log( p_rcv->p_log, OSM_LOG_VERBOSE,
"__osm_nd_rcv_process_nd: "
"Node 0x%" PRIx64 "\n\t\t\t\tDescription = %s\n",
- cl_ntoh64( osm_node_get_node_guid( p_node )), desc );
+ cl_ntoh64( osm_node_get_node_guid( p_node )),
+ p_node->print_desc);
}
- memcpy( &p_node->node_desc.description, p_nd, sizeof(*p_nd) );
-
OSM_LOG_EXIT( p_rcv->p_log );
}
diff --git a/osm/opensm/osm_state_mgr.c b/osm/opensm/osm_state_mgr.c
index 16297c9..2905857 100644
--- a/osm/opensm/osm_state_mgr.c
+++ b/osm/opensm/osm_state_mgr.c
@@ -1076,7 +1076,6 @@ __osm_topology_file_create(
const osm_node_t *p_node;
char *file_name;
FILE *rc;
- char desc[IB_NODE_DESCRIPTION_SIZE + 1];
OSM_LOG_ENTER( p_mgr->p_log, __osm_topology_file_create );
@@ -1139,10 +1138,6 @@ __osm_topology_file_create(
p_default_physp = p_physp;
}
- memcpy(desc, p_node->node_desc.description,
- IB_NODE_DESCRIPTION_SIZE);
- desc[IB_NODE_DESCRIPTION_SIZE] = '\0';
-
fprintf( rc, "{ %s%s Ports:%02X"
" SystemGUID:%016" PRIx64
" NodeGUID:%016" PRIx64
@@ -1165,7 +1160,7 @@ __osm_topology_file_create(
( &p_node->node_info ) ),
cl_ntoh16( p_node->node_info.device_id ),
cl_ntoh32( p_node->node_info.revision ),
- desc,
+ p_node->print_desc,
cl_ntoh16( p_default_physp->port_info.base_lid ),
cPort );
@@ -1180,10 +1175,6 @@ __osm_topology_file_create(
p_default_physp = p_rphysp;
}
- memcpy(desc, p_nbnode->node_desc.description,
- IB_NODE_DESCRIPTION_SIZE);
- desc[IB_NODE_DESCRIPTION_SIZE] = '\0';
-
fprintf( rc, "{ %s%s Ports:%02X"
" SystemGUID:%016" PRIx64
" NodeGUID:%016" PRIx64
@@ -1206,7 +1197,7 @@ __osm_topology_file_create(
( &p_nbnode->node_info ) ),
cl_ntoh32( p_nbnode->node_info.device_id ),
cl_ntoh32( p_nbnode->node_info.revision ),
- desc,
+ p_nbnode->print_desc,
cl_ntoh16( p_default_physp->port_info.base_lid ),
p_rphysp->port_num );
@@ -1662,7 +1653,6 @@ __osm_state_mgr_report_new_ports(
ib_net64_t port_guid;
uint16_t min_lid_ho;
uint16_t max_lid_ho;
- char desc[IB_NODE_DESCRIPTION_SIZE + 1];
OSM_LOG_ENTER( p_mgr->p_log, __osm_state_mgr_report_new_ports );
@@ -1704,19 +1694,13 @@ __osm_state_mgr_report_new_ports(
ib_get_err_str( status ) );
}
osm_port_get_lid_range_ho( p_port, &min_lid_ho, &max_lid_ho );
- if (p_port->p_node)
- {
- memcpy(desc, p_port->p_node->node_desc.description,
- IB_NODE_DESCRIPTION_SIZE);
- desc[IB_NODE_DESCRIPTION_SIZE] = '\0';
- }
osm_log( p_mgr->p_log, OSM_LOG_INFO,
"__osm_state_mgr_report_new_ports: "
"Discovered new port with GUID:0x%016" PRIx64
" LID range [0x%X,0x%X] of node:%s\n",
cl_ntoh64( port_gid.unicast.interface_id ),
min_lid_ho, max_lid_ho,
- p_port->p_node ? desc : "UNKNOWN" );
+ p_port->p_node ? p_port->p_node->print_desc : "UNKNOWN" );
p_port =
( osm_port_t
diff --git a/osm/opensm/osm_ucast_ftree.c b/osm/opensm/osm_ucast_ftree.c
index cb40ab6..21aa4a8 100644
--- a/osm/opensm/osm_ucast_ftree.c
+++ b/osm/opensm/osm_ucast_ftree.c
@@ -1251,7 +1251,6 @@ __osm_ftree_fabric_dump_hca_ordering(
uint32_t i;
uint32_t j;
- char desc[IB_NODE_DESCRIPTION_SIZE + 1];
char path[1024];
FILE * p_hca_ordering_file;
char * filename = "osm-ftree-ca-order.dump";
@@ -1278,11 +1277,10 @@ __osm_ftree_fabric_dump_hca_ordering(
{
p_group = p_sw->down_port_groups[j];
p_hca = p_group->remote_hca_or_sw.remote_hca;
- memcpy(desc,p_hca->p_osm_node->node_desc.description,IB_NODE_DESCRIPTION_SIZE);
- desc[IB_NODE_DESCRIPTION_SIZE] = '\0';
fprintf(p_hca_ordering_file,"0x%x\t%s\n",
- cl_ntoh16(p_group->remote_base_lid), desc);
+ cl_ntoh16(p_group->remote_base_lid),
+ p_hca->p_osm_node->print_desc);
}
/* now print dummy HCAs */
diff --git a/osm/opensm/osm_ucast_mgr.c b/osm/opensm/osm_ucast_mgr.c
index ded3880..3564ba7 100644
--- a/osm/opensm/osm_ucast_mgr.c
+++ b/osm/opensm/osm_ucast_mgr.c
@@ -361,14 +361,12 @@ ucast_mgr_dump_lfts(cl_map_item_t *p_map
unsigned max_port = osm_switch_get_num_ports(p_sw);
uint16_t lid;
uint8_t port;
- char desc[IB_NODE_DESCRIPTION_SIZE + 1];
- memcpy(desc, p_node->node_desc.description, IB_NODE_DESCRIPTION_SIZE);
- desc[IB_NODE_DESCRIPTION_SIZE] = '\0';
fprintf(file, "Unicast lids [0x0-0x%x] of switch Lid %u guid 0x%016"
PRIx64 " (\'%s\'):\n",
max_lid, osm_node_get_base_lid(p_node, 0),
- cl_ntoh64(osm_node_get_node_guid(p_node)), desc);
+ cl_ntoh64(osm_node_get_node_guid(p_node)),
+ p_node->print_desc);
for (lid = 0; lid <= max_lid; lid++) {
osm_port_t *p_port;
port = osm_switch_get_port_by_lid(p_sw, lid);
@@ -381,12 +379,10 @@ ucast_mgr_dump_lfts(cl_map_item_t *p_map
p_port = cl_ptr_vector_get(&p_mgr->p_subn->port_lid_tbl, lid);
if (p_port) {
p_node = osm_port_get_parent_node(p_port);
- memcpy(desc, p_node->node_desc.description,
- IB_NODE_DESCRIPTION_SIZE);
- desc[IB_NODE_DESCRIPTION_SIZE] = '\0';
fprintf(file, "%s portguid 0x016%" PRIx64 ": \'%s\'",
ib_get_node_type_str(osm_node_get_type(p_node)),
- cl_ntoh64(osm_port_get_guid(p_port)), desc);
+ cl_ntoh64(osm_port_get_guid(p_port)),
+ p_node->print_desc);
}
else
fprintf(file, "unknown node and type");
More information about the general
mailing list