From patchwork Mon Jan 7 19:50:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 1942391 X-Patchwork-Delegate: alexne@voltaire.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 339D03FED4 for ; Mon, 7 Jan 2013 19:50:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755436Ab3AGTu1 (ORCPT ); Mon, 7 Jan 2013 14:50:27 -0500 Received: from mail-ob0-f175.google.com ([209.85.214.175]:55911 "EHLO mail-ob0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751581Ab3AGTuY (ORCPT ); Mon, 7 Jan 2013 14:50:24 -0500 Received: by mail-ob0-f175.google.com with SMTP id vb8so18196264obc.34 for ; Mon, 07 Jan 2013 11:50:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:cc :subject:content-type:content-transfer-encoding:x-gm-message-state; bh=tr3nDpt8lNy3aYp3o11zx9fWwJVk2/NfnJlhZjUnOes=; b=nF8T7tcNGAwlSHc0bJpHnckYTL6JeyZHjFDOpVxeGPeIjqJPheUbAuyGggv2IEirj0 DonUJKnplRlBqmyrD7hZXFYb9e91l1cgSrIO25YO+XCd6IivQGNOqaAUKWzGiRxPv6zY t+0GXOQcpSzaUOMhL4FJPSOJUx7hxk4wg8oSx2ruDxJbEOKfgMtWoi+y12z6S3siWXgM JZ/TKGz2oAMT145nHiv05npjCPmdXr9DkZfsAI5EurLoD4xdBgdAY9J0OgeO4sT3dQvy 6v8kKGCKHisxhSNBZ84bLqJh46ZJ66kZ4HD4DvdEASFpHOONSW9egSycuu9aFRKNzQpO B5sQ== X-Received: by 10.182.124.102 with SMTP id mh6mr43161108obb.48.1357588223374; Mon, 07 Jan 2013 11:50:23 -0800 (PST) Received: from [192.168.1.102] (c-71-234-225-85.hsd1.ct.comcast.net. [71.234.225.85]) by mx.google.com with ESMTPS id m3sm33040551obm.21.2013.01.07.11.50.21 (version=SSLv3 cipher=OTHER); Mon, 07 Jan 2013 11:50:22 -0800 (PST) Message-ID: <50EB2712.2050206@dev.mellanox.co.il> Date: Mon, 07 Jan 2013 14:50:42 -0500 From: Hal Rosenstock User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 MIME-Version: 1.0 To: Alex Netes CC: "linux-rdma (linux-rdma@vger.kernel.org)" , Jim Schutt Subject: [PATCH 3/3] opensm/osm_torus.c: Dump torus when OSM_LOG_ROUTING specified X-Gm-Message-State: ALoCoQmAEczJ/sJcXclOJeiSAVIb1OfVh19FVw7jVV6r+3xqjgpnWuyfXue9tU6GuvXKsAvxD5QB Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Useful feature for torus debug Also, in report_torus_changes, no need for NULL pointer check on nt Reviewed-by: Jim Schutt Signed-off-by: Hal Rosenstock --- 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 --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;