From patchwork Wed Jul 14 16:30:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Chu X-Patchwork-Id: 112031 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o6EGdF5b005202 for ; Wed, 14 Jul 2010 16:39:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752530Ab0GNQjU (ORCPT ); Wed, 14 Jul 2010 12:39:20 -0400 Received: from nspiron-1.llnl.gov ([128.115.41.81]:17976 "EHLO nspiron-1.llnl.gov" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751663Ab0GNQjU (ORCPT ); Wed, 14 Jul 2010 12:39:20 -0400 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 14 Jul 2010 16:39:21 +0000 (UTC) X-Greylist: delayed 566 seconds by postgrey-1.27 at vger.kernel.org; Wed, 14 Jul 2010 12:39:13 EDT X-Attachments: 0004-support-filterdownports-in-iblinkinfo.patch Received: from auk31.llnl.gov (HELO [134.9.93.159]) ([134.9.93.159]) by nspiron-1.llnl.gov with ESMTP; 14 Jul 2010 09:30:03 -0700 Subject: [infiniband-diags] [4/4] support --filterdownports in iblinkinfo [REPOST] From: Albert Chu To: Sasha Khapyorsky Cc: "linux-rdma@vger.kernel.org" Date: Wed, 14 Jul 2010 09:30:01 -0700 Message-Id: <1279125001.20914.216.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/iblinkinfo.8 b/infiniband-diags/man/iblinkinfo.8 index 65ea919..940d008 100644 --- a/infiniband-diags/man/iblinkinfo.8 +++ b/infiniband-diags/man/iblinkinfo.8 @@ -66,6 +66,15 @@ Comma separate multiple diff check key(s). The available diff checks are:\fIport\fR = port connections, \fIstate\fR = port state, \fIlid\fR = lids, \fInodedesc\fR = node descriptions. If \fIport\fR is specified alongside \fIlid\fR or \fInodedesc\fR, remote port lids and node descriptions will also be compared. +.TP +\fB\-\-filterdownports\fR +Filter downports indicated in a ibnetdiscover cache. If a port was previously +indicated as down in the specified cache, and is still down, do not output it in the +resulting output. This option may be particularly useful for environments +where switches are not fully populated, thus much of the default iblinkinfo +info is considered unuseful. See +.B ibnetdiscover +for information on caching ibnetdiscover output. .SH AUTHOR .TP diff --git a/infiniband-diags/src/iblinkinfo.c b/infiniband-diags/src/iblinkinfo.c index ae7bbf3..80837ec 100644 --- a/infiniband-diags/src/iblinkinfo.c +++ b/infiniband-diags/src/iblinkinfo.c @@ -65,6 +65,8 @@ static nn_map_t *node_name_map = NULL; static char *load_cache_file = NULL; static char *diff_cache_file = NULL; static unsigned diffcheck_flags = DIFF_FLAG_DEFAULT; +static char *filterdownports_cache_file = NULL; +static ibnd_fabric_t *filterdownports_fabric = NULL; static uint64_t guid = 0; static char *guid_str = NULL; @@ -116,6 +118,30 @@ void get_msg(char *width_msg, char *speed_msg, int msg_size, ibnd_port_t * port) buf, 64, &max_speed)); } +int filterdownport_check(ibnd_node_t * node, ibnd_port_t * port) +{ + ibnd_node_t *fsw; + ibnd_port_t *fport; + int fistate; + + fsw = ibnd_find_node_guid(filterdownports_fabric, node->guid); + + if (!fsw) + return 0; + + if (port->portnum > fsw->numports) + return 0; + + fport = fsw->ports[port->portnum]; + + if (!fport) + return 0; + + fistate = mad_get_field(fport->info, 0, IB_PORT_STATE_F); + + return (fistate == IB_LINK_DOWN) ? 1 : 0; +} + void print_port(ibnd_node_t * node, ibnd_port_t * port, char *out_prefix) { char width[64], speed[64], state[64], physstate[64]; @@ -142,6 +168,11 @@ void print_port(ibnd_node_t * node, ibnd_port_t * port, char *out_prefix) width_msg[0] = '\0'; speed_msg[0] = '\0'; + if (istate == IB_LINK_DOWN + && filterdownports_fabric + && filterdownport_check(node, port)) + return; + /* C14-24.2.1 states that a down port allows for invalid data to be * returned for all PortInfo components except PortState and * PortPhysicalState */ @@ -467,6 +498,9 @@ static int process_opt(void *context, int ch, char *optarg) p = strtok(NULL, ","); } break; + case 5: + filterdownports_cache_file = strdup(optarg); + break; case 'S': guid_str = optarg; guid = (uint64_t) strtoull(guid_str, 0, 0); @@ -539,6 +573,8 @@ int main(int argc, char **argv) "filename of ibnetdiscover cache to diff"}, {"diffcheck", 4, 1, "", "specify checks to execute for --diff"}, + {"filterdownports", 5, 1, "", + "filename of ibnetdiscover cache to filter downports"}, {"outstanding_smps", 'o', 1, NULL, "specify the number of outstanding SMP's which should be " "issued during the scan"}, @@ -593,6 +629,10 @@ int main(int argc, char **argv) !(diff_fabric = ibnd_load_fabric(diff_cache_file, 0))) IBERROR("loading cached fabric for diff failed\n"); + if (filterdownports_cache_file && + !(filterdownports_fabric = ibnd_load_fabric(filterdownports_cache_file, 0))) + IBERROR("loading cached fabric for filterdownports failed\n"); + if (load_cache_file) { if ((fabric = ibnd_load_fabric(load_cache_file, 0)) == NULL) { fprintf(stderr, "loading cached fabric failed\n");