From patchwork Tue Sep 29 11:03:08 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Khapyorsky X-Patchwork-Id: 50534 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 n8TB1Ljv029051 for ; Tue, 29 Sep 2009 11:01:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753810AbZI2LBQ (ORCPT ); Tue, 29 Sep 2009 07:01:16 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753817AbZI2LBQ (ORCPT ); Tue, 29 Sep 2009 07:01:16 -0400 Received: from mail-bw0-f210.google.com ([209.85.218.210]:56517 "EHLO mail-bw0-f210.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753810AbZI2LBQ (ORCPT ); Tue, 29 Sep 2009 07:01:16 -0400 Received: by mail-bw0-f210.google.com with SMTP id 6so1896712bwz.37 for ; Tue, 29 Sep 2009 04:01:19 -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=z2qpxocFXKoGalcwCzjJHYUOzb1K0JBUvjXtAEvFy8g=; b=gZEzw8jW1fPM0/qytoLTwvckO58x4jV5RnbeByZ/608H9hopdXoNsHcxfSQUCAJtZU 5veulrH2sSdgmeSQpSz2TchkprYMOG0CR2NO8cpmBZfpst9oC/d9EIpqaAz6wbgr70lr 1Dq/ML1vRGyMz0VCD4KpJMIuuQK/0QmyJ+fHw= 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=kt/oJhEiLu83qMWz0RsEZNWO68+w8TF8drnSYbccdpzqoMJIkPQ0nI5ZpCIS+3lo4p sxjZ8v/GsDaa3r9S8Rrg7Qt83uYgKdAY9n379HG+4ZChw5KK1ybuD80KepIXhHvnfZ6y XPOvHSeruOhJckhBJzc7+QAbeyUltI+p3kbys= Received: by 10.204.32.146 with SMTP id c18mr4114459bkd.88.1254222079796; Tue, 29 Sep 2009 04:01:19 -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 k29sm5829259fkk.57.2009.09.29.04.01.18 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 29 Sep 2009 04:01:19 -0700 (PDT) Received: by me.localdomain (Postfix, from userid 1000) id 9EBE4418E8; Tue, 29 Sep 2009 13:03:08 +0200 (IST) Date: Tue, 29 Sep 2009 13:03:08 +0200 From: Sasha Khapyorsky To: OpenIB , linux-rdma Cc: Hal Rosenstock Subject: [PATCH] opensm/osm_get_port_by_lid(): don't bother with lmc Message-ID: <20090929110308.GM26931@me> References: <20090929110215.GK26931@me> <20090929110244.GL26931@me> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20090929110244.GL26931@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 Since subn->port_lid_tbl vector is filled for all port's LIDs in accordance with its LMC value, so we don't need to bother with LMC tracking and instead can just return a pointer indexed by requested lid. Obviously it speeds this helper up significantly. Signed-off-by: Sasha Khapyorsky --- opensm/opensm/osm_subnet.c | 21 ++------------------- 1 files changed, 2 insertions(+), 19 deletions(-) diff --git a/opensm/opensm/osm_subnet.c b/opensm/opensm/osm_subnet.c index 30f8af5..97b62c2 100644 --- a/opensm/opensm/osm_subnet.c +++ b/opensm/opensm/osm_subnet.c @@ -645,26 +645,9 @@ osm_port_t *osm_get_port_by_guid(IN osm_subn_t const *p_subn, IN ib_net64_t guid **********************************************************************/ osm_port_t *osm_get_port_by_lid(IN osm_subn_t const * subn, IN ib_net16_t lid) { - osm_port_t *port = NULL; - uint16_t base_lid; - uint8_t lmc; - lid = cl_ntoh16(lid); - if (lid >= cl_ptr_vector_get_size(&subn->port_lid_tbl)) - return NULL; - - /* Loop on lmc from 0 up through max LMC possible */ - for (lmc = 0; lmc <= IB_PORT_LMC_MAX; lmc++) { - /* Calculate a base LID assuming this is the real LMC */ - base_lid = lid & ~((1 << lmc) - 1); - - port = cl_ptr_vector_get(&subn->port_lid_tbl, base_lid); - /* Determine if base LID "tested" is the real base LID */ - /* This is true if the LMC "tested" is the port's actual LMC */ - if (port && lmc <= osm_port_get_lmc(port)) - return port; - } - + if (lid < cl_ptr_vector_get_size(&subn->port_lid_tbl)) + return cl_ptr_vector_get(&subn->port_lid_tbl, lid); return NULL; }