Skip to contentSkip to conversation

opensm/osm_torus.c: Dump torus when OSM_LOG_ROUTING specified

PATCH In review Hal Rosenstock 1 participant 1 message Jan 7, 2013 InfiniBand

lore
Share & tools
lore
#0 lore raw

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

Useful feature for torus debug

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

---

opensm/osm_torus.c +30 -0
index 1d847b3..4e5688f 100644
@@ -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;

if (x_sz != ot->x_sz) {
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html