diff mbox

[3/3] opensm/osm_torus.c: Dump torus when OSM_LOG_ROUTING specified

Message ID 50EB2712.2050206@dev.mellanox.co.il (mailing list archive)
State Accepted
Delegated to: Alex Netes
Headers show

Commit Message

Hal Rosenstock Jan. 7, 2013, 7:50 p.m. UTC
Useful feature for torus debug

Also, in report_torus_changes, no need for NULL pointer check on nt

Reviewed-by: Jim Schutt <jaschut@sandia.gov>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
---
 	if (x_sz != ot->x_sz) {
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/opensm/osm_torus.c b/opensm/osm_torus.c
index 1d847b3..4e5688f 100644
--- a/opensm/osm_torus.c
+++ b/opensm/osm_torus.c
@@ -7518,6 +7535,36 @@  out:
 }
 
 static
+void dump_torus(struct torus *t)
+{
+	unsigned i, j, k;
+	unsigned x_sz = t->x_sz;
+	unsigned y_sz = t->y_sz;
+	unsigned z_sz = t->z_sz;
+	char path[1024];
+	FILE *file;
+
+	snprintf(path, sizeof(path), "%s/%s", t->osm->subn.opt.dump_files_dir,
+		 "opensm-torus.dump");
+	file = fopen(path, "w");
+	if (!file) {
+		OSM_LOG(&t->osm->log, OSM_LOG_ERROR,
+			"ERR 4E47: cannot create file \'%s\'\n", path);
+		return;
+	}
+
+	for (k = 0; k < z_sz; k++)
+		for (j = 0; j < y_sz; j++)
+			for (i = 0; i < x_sz; i++)
+				fprintf(file, "switch %u,%u,%u GUID 0x%04"
+					PRIx64 " (%s)\n",
+					i, j, k,
+					cl_ntoh64(t->sw[i][j][k]->n_id),
+					t->sw[i][j][k]->osm_switch->p_node->print_desc);
+	fclose(file);
+}
+
+static
 void report_torus_changes(struct torus *nt, struct torus *ot)
 {
 	unsigned cnt = 0;
@@ -7525,7 +7572,10 @@  void report_torus_changes(struct torus *nt, struct torus *ot)
 	unsigned y_sz = nt->y_sz;
 	unsigned z_sz = nt->z_sz;
	unsigned max_changes = nt->max_changes;

+	if (OSM_LOG_IS_ACTIVE_V2(&nt->osm->log, OSM_LOG_ROUTING))
+		dump_torus(nt);
+ 
-	if (!(nt && ot))
+	if (!ot)
 		return;