From patchwork Wed Apr 7 17:06:32 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Chu X-Patchwork-Id: 91139 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o37HEHfj022247 for ; Wed, 7 Apr 2010 17:14:20 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932861Ab0DGROH (ORCPT ); Wed, 7 Apr 2010 13:14:07 -0400 Received: from nspiron-2.llnl.gov ([128.115.41.82]:7857 "EHLO nspiron-2.llnl.gov" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932874Ab0DGROA (ORCPT ); Wed, 7 Apr 2010 13:14:00 -0400 X-Attachments: 0002-support-diffcheck-in-ibnetdiscover.patch Received: from vpnb-user-128-15-245-215.llnl.gov (HELO [128.15.245.215]) ([128.15.245.215]) by nspiron-2.llnl.gov with ESMTP; 07 Apr 2010 10:04:21 -0700 Subject: [infiniband-diags] [2/3] support --diffcheck in ibnetdiscover From: Al Chu Reply-To: chu11@llnl.gov To: "sashak@voltaire.com" Cc: "linux-rdma@vger.kernel.org" Date: Wed, 07 Apr 2010 10:06:32 -0700 Message-Id: <1270659992.26381.40.camel@crazyclimber.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 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 07 Apr 2010 17:14:20 +0000 (UTC) diff --git a/infiniband-diags/man/ibnetdiscover.8 b/infiniband-diags/man/ibnetdiscover.8 index 975b999..e122736 100644 --- a/infiniband-diags/man/ibnetdiscover.8 +++ b/infiniband-diags/man/ibnetdiscover.8 @@ -64,6 +64,14 @@ output will be displayed showing differences between the old and current fabric. By default, the following are compared for differences: switches, channel adapters, routers, and port connections. .TP +\fB\-\-diffcheck\fR +Specify what diff checks should be done in the \fB\-\-diff\fR option above. +Comma separate multiple diff check key(s). The available diff checks +are: \fIsw\fR = switches, \fIca\fR = channel adapters, \fIrouter\fR = routers, +\fIport\fR = port connections descriptions. Note that \fIport\fR is +checked only for the node types that are specified (e.g. \fIsw\fR, +\fIca\fR, \fIrouter\fR). +.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 4da09ce..4435ade 100644 --- a/infiniband-diags/src/ibnetdiscover.c +++ b/infiniband-diags/src/ibnetdiscover.c @@ -57,10 +57,10 @@ #define LIST_SWITCH_NODE (1 << IB_NODE_SWITCH) #define LIST_ROUTER_NODE (1 << IB_NODE_ROUTER) -#define DIFF_FLAG_SWITCH 0x00000001 -#define DIFF_FLAG_CA 0x00000002 -#define DIFF_FLAG_ROUTER 0x00000004 -#define DIFF_FLAG_PORT_CONNECTION 0x00000008 +#define DIFF_FLAG_SWITCH 0x00000001 +#define DIFF_FLAG_CA 0x00000002 +#define DIFF_FLAG_ROUTER 0x00000004 +#define DIFF_FLAG_PORT_CONNECTION 0x00000008 #define DIFF_FLAG_DEFAULT (DIFF_FLAG_SWITCH \ | DIFF_FLAG_CA \ @@ -76,6 +76,7 @@ static nn_map_t *node_name_map = NULL; static char *cache_file = NULL; static char *load_cache_file = NULL; static char *diff_cache_file = NULL; +static uint32_t diffcheck_flags = DIFF_FLAG_DEFAULT; static int report_max_hops = 0; @@ -735,7 +736,9 @@ static int diff_common(ibnd_fabric_t * orig_fabric, * in new_fabric but not in orig_fabric. * * In this diff, we don't need to check port connections, - * since it has already been done before. + * lids, or node descriptions since it has already been + * done (i.e. checks are only done when guid exists on both + * orig and new). */ iter_diff_data.diff_flags = diff_flags & ~DIFF_FLAG_PORT_CONNECTION; iter_diff_data.fabric1 = new_fabric; @@ -752,29 +755,27 @@ static int diff_common(ibnd_fabric_t * orig_fabric, int diff(ibnd_fabric_t * orig_fabric, ibnd_fabric_t * new_fabric) { - uint32_t diff_flags = DIFF_FLAG_DEFAULT; - - if (diff_flags & DIFF_FLAG_SWITCH) + if (diffcheck_flags & DIFF_FLAG_SWITCH) diff_common(orig_fabric, new_fabric, IB_NODE_SWITCH, - diff_flags, + diffcheck_flags, out_switch, out_switch_port); - if (diff_flags & DIFF_FLAG_CA) + if (diffcheck_flags & DIFF_FLAG_CA) diff_common(orig_fabric, new_fabric, IB_NODE_CA, - diff_flags, + diffcheck_flags, out_ca, out_ca_port); - if (diff_flags & DIFF_FLAG_ROUTER) + if (diffcheck_flags & DIFF_FLAG_ROUTER) diff_common(orig_fabric, new_fabric, IB_NODE_ROUTER, - diff_flags, + diffcheck_flags, out_ca, out_ca_port); @@ -786,6 +787,8 @@ static int list, group, ports_report; static int process_opt(void *context, int ch, char *optarg) { + char *p; + switch (ch) { case 1: node_name_map_file = strdup(optarg); @@ -799,6 +802,25 @@ static int process_opt(void *context, int ch, char *optarg) case 4: diff_cache_file = strdup(optarg); break; + case 5: + diffcheck_flags = 0; + p = strtok(optarg, ","); + while (p) { + if (!strcasecmp(p, "sw")) + diffcheck_flags |= DIFF_FLAG_SWITCH; + else if (!strcasecmp(p, "ca")) + diffcheck_flags |= DIFF_FLAG_CA; + else if (!strcasecmp(p, "router")) + diffcheck_flags |= DIFF_FLAG_ROUTER; + else if (!strcasecmp(p, "port")) + diffcheck_flags |= DIFF_FLAG_PORT_CONNECTION; + else { + fprintf(stderr, "invalid diff check key: %s\n", p); + return -1; + } + p = strtok(NULL, ","); + } + break; case 's': ibnd_show_progress(1); break; @@ -852,6 +874,8 @@ int main(int argc, char **argv) "filename of ibnetdiscover cache to load"}, {"diff", 4, 1, "", "filename of ibnetdiscover cache to diff"}, + {"diffcheck", 5, 1, "", + "specify checks to execute for --diff"}, {"ports", 'p', 0, NULL, "obtain a ports report"}, {"max_hops", 'm', 0, NULL, "report max hops discovered by the library"},