From patchwork Wed Dec 9 23:42:24 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Chu X-Patchwork-Id: 66135 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nB9NgSMl032754 for ; Wed, 9 Dec 2009 23:42:29 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758753AbZLIXmU (ORCPT ); Wed, 9 Dec 2009 18:42:20 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1758777AbZLIXmU (ORCPT ); Wed, 9 Dec 2009 18:42:20 -0500 Received: from nspiron-2.llnl.gov ([128.115.41.82]:24580 "EHLO nspiron-2.llnl.gov" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758753AbZLIXmS (ORCPT ); Wed, 9 Dec 2009 18:42:18 -0500 X-Attachments: 0002-support-cache-and-load-cache-options-in-ibnetdis.patch Received: from auk31.llnl.gov (HELO [134.9.93.159]) ([134.9.93.159]) by nspiron-2.llnl.gov with ESMTP; 09 Dec 2009 15:42:25 -0800 Subject: [infiniband-diags] [PATCH] [2/2] support --cache and --load-cache options in ibnetdiscover From: Al Chu Reply-To: chu11@llnl.gov To: sashak@voltaire.com Cc: linux-rdma@vger.kernel.org Date: Wed, 09 Dec 2009 15:42:24 -0800 Message-Id: <1260402144.4557.68.camel@auk31.llnl.gov> Mime-Version: 1.0 X-Mailer: Evolution 2.12.3 (2.12.3-19.el5) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org diff --git a/infiniband-diags/man/ibnetdiscover.8 b/infiniband-diags/man/ibnetdiscover.8 index abf3588..082a8e4 100644 --- a/infiniband-diags/man/ibnetdiscover.8 +++ b/infiniband-diags/man/ibnetdiscover.8 @@ -8,7 +8,8 @@ ibnetdiscover \- discover InfiniBand topology [\-d(ebug)] [\-e(rr_show)] [\-v(erbose)] [\-s(how)] [\-l(ist)] [\-g(rouping)] [\-H(ca_list)] [\-S(witch_list)] [\-R(outer_list)] [\-C ca_name] [\-P ca_port] [\-t(imeout) timeout_ms] [\-V(ersion)] -[\--node-name-map ] [\-p(orts)] [\-m(ax_hops)] +[\--node-name-map ] [\-\-cache ] +[\-\-load\-cache ] [\-p(orts)] [\-m(ax_hops)] [\-h(elp)] [] .SH DESCRIPTION @@ -47,6 +48,15 @@ Show progress information during discovery. Specify a node name map. The node name map file maps GUIDs to more user friendly names. See file format below. .TP +\fB\-\-cache\fR +Cache the ibnetdiscover network data in the specified filename. This +cache may be used by other tools for later analysis. +.TP +\fB\-\-load\-cache\fR +Load and use the cached ibnetdiscover data stored in the specified +filename. May be useful for outputting and learning about other +fabrics or a previous state of a fabric. +.TP \fB\-p\fR, \fB\-\-ports\fR Obtain a ports report which is a list of connected ports with relevant information (like LID, portnum, diff --git a/infiniband-diags/src/ibnetdiscover.c b/infiniband-diags/src/ibnetdiscover.c index e081a36..e87f42e 100644 --- a/infiniband-diags/src/ibnetdiscover.c +++ b/infiniband-diags/src/ibnetdiscover.c @@ -63,6 +63,8 @@ static FILE *f; static char *node_name_map_file = NULL; static nn_map_t *node_name_map = NULL; +static char *cache_file = NULL; +static char *load_cache_file = NULL; static int report_max_hops = 0; @@ -616,6 +618,12 @@ static int process_opt(void *context, int ch, char *optarg) case 1: node_name_map_file = strdup(optarg); break; + case 2: + cache_file = strdup(optarg); + break; + case 3: + load_cache_file = strdup(optarg); + break; case 's': ibnd_show_progress(1); break; @@ -662,6 +670,8 @@ int main(int argc, char **argv) {"Switch_list", 'S', 0, NULL, "list of connected switches"}, {"Router_list", 'R', 0, NULL, "list of connected routers"}, {"node-name-map", 1, 1, "", "node name map file"}, + {"cache", 2, 1, "", "filename to cache ibnetdiscover data to"}, + {"load-cache", 3, 1, "", "filename of ibnetdiscover cache to load"}, {"ports", 'p', 0, NULL, "obtain a ports report"}, {"max_hops", 'm', 0, NULL, "report max hops discovered by the library"}, @@ -692,8 +702,14 @@ int main(int argc, char **argv) node_name_map = open_node_name_map(node_name_map_file); - if ((fabric = ibnd_discover_fabric(ibmad_port, NULL, -1)) == NULL) - IBERROR("discover failed\n"); + if (load_cache_file) { + if ((fabric = ibnd_load_fabric(load_cache_file, 0)) == NULL) + IBERROR("loading cached fabric failed\n"); + } + else { + if ((fabric = ibnd_discover_fabric(ibmad_port, NULL, -1)) == NULL) + IBERROR("discover failed\n"); + } if (ports_report) ibnd_iter_nodes(fabric, dump_ports_report, NULL); @@ -702,6 +718,12 @@ int main(int argc, char **argv) else dump_topology(group, fabric); + if (cache_file) + if (ibnd_cache_fabric(fabric, + cache_file, + 0) < 0) + IBERROR("caching ibnetdiscover data failed\n"); + ibnd_destroy_fabric(fabric); close_node_name_map(node_name_map); mad_rpc_close_port(ibmad_port);