[ofa-general] [PATCH] opensm: skeleton for toroidal mesh analysis

Robert Pearson rpearson at systemfabricworks.com
Mon Nov 10 22:44:49 PST 2008


Sasha, 

Here is the first patch in a series to implement the algorithm described in
the file lash_changes.doc.

This patch
      - creates a new command line flag --do_mesh_analysis and a new Boolean
that is set if the flag is used.
      - adds code to main to implement the flag and option.
      - creates a new file osm_mesh.c to hold the algorithm code
      - moves declarations from osm_ucast_lash.c and osm_mesh.c into header
files
      - adds these files to Makefile.am
      - adds a stub do_mesh_analysis() that is called from lash_core.

Signed-off-by: Bob Pearson <rpearson at systemfabricworks.com>

-----

diff --git a/opensm/include/opensm/osm_mesh.h
b/opensm/include/opensm/osm_mesh.h
new file mode 100644
index 0000000..1467440
--- /dev/null
+++ b/opensm/include/opensm/osm_mesh.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2088      System Fabric Works, Inc.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ *      Declarations for mesh analysis
+ */
+
+#ifndef OSM_UCAST_MESH_H
+#define OSM_UCAST_MESH_H
+
+struct _lash;
+
+int do_mesh_analysis(struct _lash *p_lash);
+
+#endif
diff --git a/opensm/include/opensm/osm_subnet.h
b/opensm/include/opensm/osm_subnet.h
index 7259587..2abe36d 100644
--- a/opensm/include/opensm/osm_subnet.h
+++ b/opensm/include/opensm/osm_subnet.h
@@ -215,6 +215,7 @@ typedef struct osm_subn_opt {
 	char *node_name_map_name;
 	char *prefix_routes_file;
 	boolean_t consolidate_ipv6_snm_req;
+	boolean_t do_mesh_analysis;
 } osm_subn_opt_t;
 /*
 * FIELDS
diff --git a/opensm/include/opensm/osm_ucast_lash.h
b/opensm/include/opensm/osm_ucast_lash.h
new file mode 100644
index 0000000..646e9a3
--- /dev/null
+++ b/opensm/include/opensm/osm_ucast_lash.h
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2008      System Fabric Works, Inc.
+ * Copyright (c) 2004-2007 Voltaire, Inc. All rights reserved.
+ * Copyright (c) 2002-2006 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2007      Simula Research Laboratory. All rights reserved.
+ * Copyright (c) 2007      Silicon Graphics Inc. All rights reserved.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ *      Declarations for LASH algorithm
+ */
+
+#ifndef OSM_UCAST_LASH_H
+#define OSM_UCAST_LASH_H
+
+enum {
+	UNQUEUED,
+	Q_MEMBER,
+	MST_MEMBER,
+	MAX_INT = 9999,
+	NONE = MAX_INT
+};
+
+typedef struct _cdg_vertex {
+	int num_dependencies;
+	struct _cdg_vertex **dependency;
+	int from;
+	int to;
+	int seen;
+	int temp;
+	int visiting_number;
+	struct _cdg_vertex *next;
+	int num_temp_depend;
+	int num_using_vertex;
+	int *num_using_this_depend;
+} cdg_vertex_t;
+
+typedef struct _reachable_dest {
+	int switch_id;
+	struct _reachable_dest *next;
+} reachable_dest_t;
+
+typedef struct _switch {
+	osm_switch_t *p_sw;
+	int *dij_channels;
+	int id;
+	int used_channels;
+	int q_state;
+	struct routing_table {
+		unsigned out_link;
+		unsigned lane;
+	} *routing_table;
+	unsigned int num_connections;
+	int *virtual_physical_port_table;
+	int *phys_connections;
+} switch_t;
+
+typedef struct _lash {
+	osm_opensm_t *p_osm;
+	int num_switches;
+	uint8_t vl_min;
+	int balance_limit;
+	switch_t **switches;
+	cdg_vertex_t ****cdg_vertex_matrix;
+	int *num_mst_in_lane;
+	int ***virtual_location;
+} lash_t;
+
+#endif
diff --git a/opensm/opensm/Makefile.am b/opensm/opensm/Makefile.am
index 01573d2..7b9da18 100644
--- a/opensm/opensm/Makefile.am
+++ b/opensm/opensm/Makefile.am
@@ -31,7 +31,7 @@ opensm_SOURCES = main.c osm_console_io.c osm_console.c
osm_db_files.c \
 		 osm_inform.c osm_lid_mgr.c osm_lin_fwd_rcv.c \
 		 osm_link_mgr.c osm_mcast_fwd_rcv.c \
 		 osm_mcast_mgr.c osm_mcast_tbl.c osm_mcm_info.c \
-		 osm_mcm_port.c osm_mtree.c osm_multicast.c osm_node.c \
+		 osm_mcm_port.c osm_mesh.c osm_mtree.c osm_multicast.c
osm_node.c \
 		 osm_node_desc_rcv.c osm_node_info_rcv.c \
 		 osm_opensm.c osm_pkey.c osm_pkey_mgr.c osm_pkey_rcv.c \
 		 osm_port.c osm_port_info_rcv.c \
@@ -76,6 +76,7 @@ opensminclude_HEADERS = \
 	$(srcdir)/../include/opensm/osm_errors.h \
 	$(srcdir)/../include/opensm/osm_helper.h \
 	$(srcdir)/../include/opensm/osm_inform.h \
+	$(srcdir)/../include/opensm/osm_ucast_lash.h \
 	$(srcdir)/../include/opensm/osm_lid_mgr.h \
 	$(srcdir)/../include/opensm/osm_log.h \
 	$(srcdir)/../include/opensm/osm_mad_pool.h \
@@ -83,6 +84,7 @@ opensminclude_HEADERS = \
 	$(srcdir)/../include/opensm/osm_mcast_tbl.h \
 	$(srcdir)/../include/opensm/osm_mcm_info.h \
 	$(srcdir)/../include/opensm/osm_mcm_port.h \
+	$(srcdir)/../include/opensm/osm_mesh.h \
 	$(srcdir)/../include/opensm/osm_mtree.h \
 	$(srcdir)/../include/opensm/osm_multicast.h \
 	$(srcdir)/../include/opensm/osm_msgdef.h \
diff --git a/opensm/opensm/main.c b/opensm/opensm/main.c
index 53648d6..63bd5a6 100644
--- a/opensm/opensm/main.c
+++ b/opensm/opensm/main.c
@@ -585,6 +585,7 @@ int main(int argc, char *argv[])
 #endif
 		{"prefix_routes_file", 1, NULL, 3},
 		{"consolidate_ipv6_snm_req", 0, NULL, 4},
+		{"do_mesh_analysis", 0, NULL, 5},
 		{NULL, 0, NULL, 0}	/* Required at the end of the array
*/
 	};
 
@@ -922,6 +923,9 @@ int main(int argc, char *argv[])
 		case 4:
 			opt.consolidate_ipv6_snm_req = TRUE;
 			break;
+		case 5:
+			opt.do_mesh_analysis = TRUE;
+			break;
 		case 'h':
 		case '?':
 		case ':':
diff --git a/opensm/opensm/osm_mesh.c b/opensm/opensm/osm_mesh.c
new file mode 100644
index 0000000..7943274
--- /dev/null
+++ b/opensm/opensm/osm_mesh.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2008      System Fabric Works, Inc.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Abstract:
+ *      routines to analyze certain meshes
+ */
+
+#if HAVE_CONFIG_H
+#  include <config.h>
+#endif				/* HAVE_CONFIG_H */
+
+#include <stdio.h>
+#include <opensm/osm_switch.h>
+#include <opensm/osm_opensm.h>
+#include <opensm/osm_log.h>
+#include <opensm/osm_mesh.h>
+#include <opensm/osm_ucast_lash.h>
+
+/*
+ * do_mesh_analysis
+ */
+int do_mesh_analysis(lash_t *p_lash)
+{
+	int ret = 0;
+	osm_log_t *p_log = &p_lash->p_osm->log;
+
+	OSM_LOG_ENTER(p_log);
+
+	printf("lash: do_mesh_analysis stub called\n");
+
+	OSM_LOG_EXIT(p_log);
+
+	return ret;
+}
diff --git a/opensm/opensm/osm_ucast_lash.c b/opensm/opensm/osm_ucast_lash.c
index c082798..e10371c 100644
--- a/opensm/opensm/osm_ucast_lash.c
+++ b/opensm/opensm/osm_ucast_lash.c
@@ -52,64 +52,13 @@
 #include <opensm/osm_switch.h>
 #include <opensm/osm_opensm.h>
 #include <opensm/osm_log.h>
+#include <opensm/osm_mesh.h>
+#include <opensm/osm_ucast_lash.h>
 
 /* //////////////////////////// */
 /*  Local types                 */
 /* //////////////////////////// */
 
-enum {
-	UNQUEUED,
-	Q_MEMBER,
-	MST_MEMBER,
-	MAX_INT = 9999,
-	NONE = MAX_INT
-};
-
-typedef struct _cdg_vertex {
-	int num_dependencies;
-	struct _cdg_vertex **dependency;
-	int from;
-	int to;
-	int seen;
-	int temp;
-	int visiting_number;
-	struct _cdg_vertex *next;
-	int num_temp_depend;
-	int num_using_vertex;
-	int *num_using_this_depend;
-} cdg_vertex_t;
-
-typedef struct _reachable_dest {
-	int switch_id;
-	struct _reachable_dest *next;
-} reachable_dest_t;
-
-typedef struct _switch {
-	osm_switch_t *p_sw;
-	int *dij_channels;
-	int id;
-	int used_channels;
-	int q_state;
-	struct routing_table {
-		unsigned out_link;
-		unsigned lane;
-	} *routing_table;
-	unsigned int num_connections;
-	int *virtual_physical_port_table;
-	int *phys_connections;
-} switch_t;
-
-typedef struct _lash {
-	osm_opensm_t *p_osm;
-	int num_switches;
-	uint8_t vl_min;
-	int balance_limit;
-	switch_t **switches;
-	cdg_vertex_t ****cdg_vertex_matrix;
-	int *num_mst_in_lane;
-	int ***virtual_location;
-} lash_t;
-
 static cdg_vertex_t *create_cdg_vertex(unsigned num_switches)
 {
 	cdg_vertex_t *cdg_vertex = (cdg_vertex_t *)
malloc(sizeof(cdg_vertex_t));
@@ -872,10 +821,15 @@ static int lash_core(lash_t * p_lash)
 	int output_link2, i_next_switch2;
 	int cycle_found2 = 0;
 	int status = 0;
-	int *switch_bitmap;	/* Bitmap to check if we have processed this
pair */
+	int *switch_bitmap = NULL;	/* Bitmap to check if we have
processed this pair */
 
 	OSM_LOG_ENTER(p_log);
 
+	if (p_lash->p_osm->subn.opt.do_mesh_analysis &&
do_mesh_analysis(p_lash)) {
+		OSM_LOG(p_log, OSM_LOG_ERROR, "Mesh analysis failed\n");
+		goto Exit;
+	}
+
 	for (i = 0; i < num_switches; i++) {
 
 		shortest_path(p_lash, i);



More information about the general mailing list