From patchwork Fri Jan 15 18:23:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Chu X-Patchwork-Id: 73201 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id o0FIWdvM001524 for ; Fri, 15 Jan 2010 18:32:39 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751899Ab0AOSci (ORCPT ); Fri, 15 Jan 2010 13:32:38 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754307Ab0AOSci (ORCPT ); Fri, 15 Jan 2010 13:32:38 -0500 Received: from nspiron-3.llnl.gov ([128.115.41.83]:52659 "EHLO smtp.llnl.gov" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751702Ab0AOSch (ORCPT ); Fri, 15 Jan 2010 13:32:37 -0500 X-Greylist: delayed 575 seconds by postgrey-1.27 at vger.kernel.org; Fri, 15 Jan 2010 13:32:37 EST 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 smtp.llnl.gov with ESMTP; 15 Jan 2010 10:23:16 -0800 Subject: [infiniband-diags] [UPDATED PATCH] [2/3] 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: Fri, 15 Jan 2010 10:23:16 -0800 Message-Id: <1263579796.15172.167.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);