From patchwork Fri Nov 13 20:38:56 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Khapyorsky X-Patchwork-Id: 59950 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 nADKagr9031872 for ; Fri, 13 Nov 2009 20:36:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757392AbZKMUgf (ORCPT ); Fri, 13 Nov 2009 15:36:35 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757418AbZKMUgf (ORCPT ); Fri, 13 Nov 2009 15:36:35 -0500 Received: from mail-bw0-f227.google.com ([209.85.218.227]:39456 "EHLO mail-bw0-f227.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757392AbZKMUge (ORCPT ); Fri, 13 Nov 2009 15:36:34 -0500 Received: by bwz27 with SMTP id 27so3868382bwz.21 for ; Fri, 13 Nov 2009 12:36:39 -0800 (PST) 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=cZ8W7JYHx7l06h2hGEwdiCFR4nn3ZkZXowQudELiITM=; b=hxmba+bADkZAYAXQOlTNhWGe0ZRcPcscJJwMNa64/1KdIjedV+djpRX8aU8xdnVG9p aHCzyaFqI/a1s+/uh2IUxxsYk32GS1Mnct28Y1LDfCZAuWTmyD0FeCBioHx9eqenv98r ViVSPCZidGyDRc5ynLknIwKSP684lm2oCSUHM= 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=GFOBXpk5XiW98mlN9ulEdnktpp2fkOvB/7sCxAQefkvQ42sTfGi3zAjKPXgsX2KXMD Lf0oHa5mj3Cq1fYTv6iCOFi0OjqRAV9Mi6qhllor1GdiydXmbwmx0pk9LJo8LFvl9NdD IpxjuCnfFcPaC+Pda5ekPCXi429el5GgvXG/Y= Received: by 10.204.5.75 with SMTP id 11mr1608980bku.20.1258144598896; Fri, 13 Nov 2009 12:36:38 -0800 (PST) Received: from me.localdomain (85.64.35.106.dynamic.barak-online.net [85.64.35.106]) by mx.google.com with ESMTPS id 16sm1414824fxm.4.2009.11.13.12.36.37 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 13 Nov 2009 12:36:38 -0800 (PST) Received: by me.localdomain (Postfix, from userid 1000) id 9EA031209B; Fri, 13 Nov 2009 22:38:56 +0200 (IST) Date: Fri, 13 Nov 2009 22:38:56 +0200 From: Sasha Khapyorsky To: linux-rdma Cc: Eli Dorfman , Slava Strebkov , Ira Weiny , Hal Rosenstock Subject: [PATCH] complib/cl_fleximap: add cl_fmap_match() function Message-ID: <20091113203856.GT7192@me> References: <20091113061948.GJ7192@me> <20091113062104.GK7192@me> <20091113201144.GS7192@me> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20091113201144.GS7192@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/opensm/complib/cl_map.c b/opensm/complib/cl_map.c index d851bf8..f5fb1f3 100644 --- a/opensm/complib/cl_map.c +++ b/opensm/complib/cl_map.c @@ -1144,8 +1144,9 @@ void cl_fmap_init(IN cl_fmap_t * const p_map, IN cl_pfn_fmap_cmp_t pfn_compare) cl_fmap_remove_all(p_map); } -cl_fmap_item_t *cl_fmap_get(IN const cl_fmap_t * const p_map, - IN const void *const p_key) +cl_fmap_item_t *cl_fmap_match(IN const cl_fmap_t * const p_map, + IN const void *const p_key, + IN cl_pfn_fmap_cmp_t pfn_compare) { cl_fmap_item_t *p_item; int cmp; @@ -1156,7 +1157,8 @@ cl_fmap_item_t *cl_fmap_get(IN const cl_fmap_t * const p_map, p_item = __cl_fmap_root(p_map); while (p_item != &p_map->nil) { - cmp = p_map->pfn_compare(p_key, p_item->p_key); + cmp = pfn_compare ? pfn_compare(p_key, p_item->p_key) : + p_map->pfn_compare(p_key, p_item->p_key); if (!cmp) break; /* just right */ @@ -1170,6 +1172,12 @@ cl_fmap_item_t *cl_fmap_get(IN const cl_fmap_t * const p_map, return (p_item); } +cl_fmap_item_t *cl_fmap_get(IN const cl_fmap_t * const p_map, + IN const void *const p_key) +{ + return cl_fmap_match(p_map, p_key, p_map->pfn_compare); +} + cl_fmap_item_t *cl_fmap_get_next(IN const cl_fmap_t * const p_map, IN const void *const p_key) { diff --git a/opensm/complib/libosmcomp.map b/opensm/complib/libosmcomp.map index 788eb2a..52410cc 100644 --- a/opensm/complib/libosmcomp.map +++ b/opensm/complib/libosmcomp.map @@ -66,6 +66,7 @@ OSMCOMP_2.3 { cl_map_merge; cl_map_delta; cl_fmap_init; + cl_fmap_match; cl_fmap_get; cl_fmap_get_next; cl_fmap_apply_func; diff --git a/opensm/include/complib/cl_fleximap.h b/opensm/include/complib/cl_fleximap.h index ec008cf..b74040f 100644 --- a/opensm/include/complib/cl_fleximap.h +++ b/opensm/include/complib/cl_fleximap.h @@ -619,6 +619,42 @@ cl_fmap_item_t *cl_fmap_insert(IN cl_fmap_t * const p_map, * Flexi Map, cl_fmap_remove, cl_fmap_item_t *********/ +/****f* Component Library: Flexi Map/cl_fmap_match +* NAME +* cl_fmap_get +* +* DESCRIPTION +* The cl_fmap_match function returns the map item matching a key. +* +* SYNOPSIS +*/ +cl_fmap_item_t *cl_fmap_match(IN const cl_fmap_t * const p_map, + IN const void *const p_key, + IN cl_pfn_fmap_cmp_t pfn_compare); +/* +* PARAMETERS +* p_map +* [in] Pointer to a cl_fmap_t structure from which to retrieve the +* item with the specified key. +* +* p_key +* [in] Pointer to a key value used to search for the desired map item. +* +* pfn_compare +* [in] Pointer to a compare function to invoke to compare the +* keys of items in the map. Passing NULL here makes such call +* to be equivalent to using cl_fmap_get(). +* +* RETURN VALUES +* Pointer to the map item matching the desired key value. +* +* Pointer to the map end if there was no item matching the desired key +* value stored in the flexi map. +* +* SEE ALSO +* Flexi Map, cl_fmap_remove, cl_fmap_get +*********/ + /****f* Component Library: Flexi Map/cl_fmap_get * NAME * cl_fmap_get