All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>
To: Ira Weiny <weiny2-i2BcT+NCU+M@public.gmane.org>
Cc: Hal Rosenstock
	<hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	linux-rdma <linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: [PATCH] infiniband-diags/ibqueryerrors.c: use common portid in query_cap_mask()
Date: Fri, 23 Oct 2009 18:33:37 +0200	[thread overview]
Message-ID: <20091023163337.GB718@me> (raw)
In-Reply-To: <20090925093358.f9f747d4.weiny2-i2BcT+NCU+M@public.gmane.org>


Use common portid in query_cap_mask() function instead of generating
this again in this function.

Signed-off-by: Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>
---
 infiniband-diags/src/ibqueryerrors.c |   25 ++++++++++---------------
 1 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/infiniband-diags/src/ibqueryerrors.c b/infiniband-diags/src/ibqueryerrors.c
index 697afd1..fdd9246 100644
--- a/infiniband-diags/src/ibqueryerrors.c
+++ b/infiniband-diags/src/ibqueryerrors.c
@@ -261,23 +261,18 @@ static void print_results(ibnd_node_t * node, uint8_t * pc, int portnum,
 	}
 }
 
-static int query_cap_mask(ibnd_node_t * node, int portnum, uint16_t * cap_mask)
+static int query_cap_mask(ib_portid_t *portid, ibnd_node_t * node, int portnum,
+			  uint16_t * cap_mask)
 {
 	uint8_t pc[1024];
 	uint16_t rc_cap_mask;
-	ib_portid_t portid = { 0 };
-
-	if (node->type == IB_NODE_SWITCH)
-		ib_portid_set(&portid, node->smalid, 0, 0);
-	else
-		ib_portid_set(&portid, node->ports[portnum]->base_lid, 0, 0);
 
 	/* PerfMgt ClassPortInfo is a required attribute */
-	if (!pma_query_via(pc, &portid, portnum, ibd_timeout, CLASS_PORT_INFO,
+	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),
+				       node->nodedesc), portid2str(portid),
 		       portnum);
 		return -1;
 	}
@@ -371,18 +366,18 @@ void print_node(ibnd_node_t * node, void *user_data)
 
 	for (p = startport; p <= node->numports; p++) {
 		if (node->ports[p]) {
-			if (query_cap_mask(node, p, &cap_mask) < 0)
-				continue;
-
-			if (cap_mask & 0x100)
-				all_port_sup = 1;
-
 			if (node->type == IB_NODE_SWITCH)
 				ib_portid_set(&portid, node->smalid, 0, 0);
 			else
 				ib_portid_set(&portid, node->ports[p]->base_lid,
 					      0, 0);
 
+			if (query_cap_mask(&portid, node, p, &cap_mask) < 0)
+				continue;
+
+			if (cap_mask & 0x100)
+				all_port_sup = 1;
+
 			print_port(&portid, cap_mask, node, p, &header_printed);
 			if (!all_port_sup)
 				clear_port(&portid, cap_mask, node, p);
-- 
1.6.5.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

       reply	other threads:[~2009-10-23 16:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20090924235011.a9a16022.weiny2@llnl.gov>
     [not found] ` <f0e08f230909250707t36c1ebc4od5df33e36f6cd38a@mail.gmail.com>
     [not found]   ` <20090925093358.f9f747d4.weiny2@llnl.gov>
     [not found]     ` <20090925093358.f9f747d4.weiny2-i2BcT+NCU+M@public.gmane.org>
2009-10-23 16:33       ` Sasha Khapyorsky [this message]
2009-10-23 16:34         ` [PATCH] infiniband-diags/ibqueryerrors.c: use common node_name Sasha Khapyorsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091023163337.GB718@me \
    --to=sashak-smomgflxvozwk0htik3j/w@public.gmane.org \
    --cc=hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=weiny2-i2BcT+NCU+M@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.