From patchwork Fri Oct 23 16:34:30 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Khapyorsky X-Patchwork-Id: 55586 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 n9NGWosS019914 for ; Fri, 23 Oct 2009 16:32:50 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752582AbZJWQc0 (ORCPT ); Fri, 23 Oct 2009 12:32:26 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752661AbZJWQc0 (ORCPT ); Fri, 23 Oct 2009 12:32:26 -0400 Received: from mail-bw0-f227.google.com ([209.85.218.227]:39508 "EHLO mail-bw0-f227.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752582AbZJWQcZ (ORCPT ); Fri, 23 Oct 2009 12:32:25 -0400 Received: by bwz27 with SMTP id 27so1012931bwz.21 for ; Fri, 23 Oct 2009 09:32:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:received:date:from:to :cc:subject:message-id:references:mime-version:content-type :content-disposition:in-reply-to:user-agent; bh=KFz0Nf+IyrHIDESybCJQSR3/LsKEkNLsAUcJI6J5zuw=; b=O8gNRChCx1dJyo2qQXI8tAhAMcqPBfz/on2NghLWG7lBAGcsP7pKvNDYz+TsguPHqz PlMaBWhUQhjQ4v67wl3ZuqEJ/3RyLKH+veD0uJ/RKmw0JZFvsuYa2P1h2eWsIH/TUOKc 1G4psvO/gdradQgF+ua4urgbZp9CbxjfYwrlk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=hul09Lu/hn4c860jm9Z9K2aRHZyKiKIzVarC1oJ0vY3sLNYkvVldALtQHqMGPmw/9Q /h29YujtTt2+hnczlTEMqS/hUIyDWw0GTVEW9Ktg3UdIs4IW+qQKbbowRQcM16/e4C3d WdrQnn23MySzd7/e4plaKRNVBKvuvr2BohDp0= Received: by 10.103.125.27 with SMTP id c27mr4776773mun.110.1256315548723; Fri, 23 Oct 2009 09:32:28 -0700 (PDT) Received: from me.localdomain (85.64.35.106.dynamic.barak-online.net [85.64.35.106]) by mx.google.com with ESMTPS id y6sm4825242mug.40.2009.10.23.09.32.27 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 23 Oct 2009 09:32:28 -0700 (PDT) Received: by me.localdomain (Postfix, from userid 1000) id D954211F05; Fri, 23 Oct 2009 18:34:30 +0200 (IST) Date: Fri, 23 Oct 2009 18:34:30 +0200 From: Sasha Khapyorsky To: Ira Weiny Cc: Hal Rosenstock , linux-rdma Subject: [PATCH] infiniband-diags/ibqueryerrors.c: use common node_name Message-ID: <20091023163430.GC718@me> References: <20090924235011.a9a16022.weiny2@llnl.gov> <20090925093358.f9f747d4.weiny2@llnl.gov> <20091023163337.GB718@me> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20091023163337.GB718@me> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org diff --git a/infiniband-diags/src/ibqueryerrors.c b/infiniband-diags/src/ibqueryerrors.c index fdd9246..0842eb3 100644 --- a/infiniband-diags/src/ibqueryerrors.c +++ b/infiniband-diags/src/ibqueryerrors.c @@ -113,7 +113,7 @@ static void get_msg(char *width_msg, char *speed_msg, int msg_size, buf, 64, &max_speed)); } -static void print_port_config(ibnd_node_t * node, int portnum) +static void print_port_config(char *node_name, ibnd_node_t * node, int portnum) { char width[64], speed[64], state[64], physstate[64]; char remote_str[256]; @@ -145,10 +145,6 @@ static void print_port_config(ibnd_node_t * node, int portnum) mad_dump_val(IB_PORT_PHYS_STATE_F, physstate, 64, &iphystate)); if (port->remoteport) { - char *remap = - remap_node_name(node_name_map, port->remoteport->node->guid, - port->remoteport->node->nodedesc); - if (port->remoteport->ext_portnum) snprintf(ext_port_str, 256, "%d", port->remoteport->ext_portnum); @@ -162,9 +158,8 @@ static void print_port_config(ibnd_node_t * node, int portnum) port->remoteport->node->guid, port->remoteport->base_lid ? port->remoteport-> base_lid : port->remoteport->node->smalid, - port->remoteport->portnum, ext_port_str, remap, + port->remoteport->portnum, ext_port_str, node_name, width_msg, speed_msg); - free(remap); } else snprintf(remote_str, 256, " [ ] \"\" ( )\n"); @@ -203,8 +198,8 @@ static void report_suppressed(void) } } -static void print_results(ibnd_node_t * node, uint8_t * pc, int portnum, - int *header_printed) +static void print_results(char *node_name, ibnd_node_t * node, uint8_t * pc, + int portnum, int *header_printed) { char buf[1024]; char *str = buf; @@ -245,23 +240,19 @@ static void print_results(ibnd_node_t * node, uint8_t * pc, int portnum, } if (!*header_printed) { - char *nodename = - remap_node_name(node_name_map, node->guid, - node->nodedesc); printf("Errors for 0x%" PRIx64 " \"%s\"\n", node->guid, - nodename); + node_name); *header_printed = 1; - free(nodename); } printf(" GUID 0x%" PRIx64 " port %d:%s\n", node->guid, portnum, str); if (port_config) - print_port_config(node, portnum); + print_port_config(node_name, node, portnum); } } -static int query_cap_mask(ib_portid_t *portid, ibnd_node_t * node, int portnum, +static int query_cap_mask(ib_portid_t *portid, char *node_name, int portnum, uint16_t * cap_mask) { uint8_t pc[1024]; @@ -271,9 +262,7 @@ static int query_cap_mask(ib_portid_t *portid, ibnd_node_t * node, int portnum, if (!pma_query_via(pc, portid, portnum, ibd_timeout, CLASS_PORT_INFO, ibmad_port)) { IBWARN("classportinfo query failed on %s, %s port %d", - remap_node_name(node_name_map, node->guid, - node->nodedesc), portid2str(portid), - portnum); + node_name, portid2str(portid), portnum); return -1; } @@ -284,30 +273,25 @@ static int query_cap_mask(ib_portid_t *portid, ibnd_node_t * node, int portnum, return 0; } -static void print_port(ib_portid_t * portid, uint16_t cap_mask, +static void print_port(ib_portid_t * portid, uint16_t cap_mask, char *node_name, ibnd_node_t * node, int portnum, int *header_printed) { uint8_t pc[1024]; - char *nodename = - remap_node_name(node_name_map, node->guid, node->nodedesc); memset(pc, 0, 1024); if (!pma_query_via(pc, portid, portnum, ibd_timeout, IB_GSI_PORT_COUNTERS, ibmad_port)) { IBWARN("IB_GSI_PORT_COUNTERS query failed on %s, %s port %d\n", - nodename, portid2str(portid), portnum); - goto cleanup; + node_name, portid2str(portid), portnum); + return; } if (!(cap_mask & 0x1000)) { /* if PortCounters:PortXmitWait not suppported clear this counter */ uint32_t foo = 0; mad_encode_field(pc, IB_PC_XMT_WAIT_F, &foo); } - print_results(node, pc, portnum, header_printed); - -cleanup: - free(nodename); + print_results(node_name, node, pc, portnum, header_printed); } static void clear_port(ib_portid_t * portid, uint16_t cap_mask, @@ -365,6 +349,8 @@ void print_node(ibnd_node_t * node, void *user_data) startport = 0; for (p = startport; p <= node->numports; p++) { + char *node_name = remap_node_name(node_name_map, node->guid, + node->nodedesc); if (node->ports[p]) { if (node->type == IB_NODE_SWITCH) ib_portid_set(&portid, node->smalid, 0, 0); @@ -372,16 +358,18 @@ void print_node(ibnd_node_t * node, void *user_data) ib_portid_set(&portid, node->ports[p]->base_lid, 0, 0); - if (query_cap_mask(&portid, node, p, &cap_mask) < 0) + if (query_cap_mask(&portid, node_name, p, &cap_mask) < 0) continue; if (cap_mask & 0x100) all_port_sup = 1; - print_port(&portid, cap_mask, node, p, &header_printed); + print_port(&portid, cap_mask, node_name, node, p, + &header_printed); if (!all_port_sup) clear_port(&portid, cap_mask, node, p); } + free(node_name); } if (all_port_sup)