From: Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>
To: linux-rdma <linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Cc: Eli Dorfman <elid-smomgflXvOZWk0Htik3J/w@public.gmane.org>,
Slava Strebkov <slavas-smomgflXvOZWk0Htik3J/w@public.gmane.org>,
Ira Weiny <weiny2-i2BcT+NCU+M@public.gmane.org>,
Hal Rosenstock
<hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: [PATCH] complib/cl_fleximap: add cl_fmap_match() function
Date: Fri, 13 Nov 2009 22:38:56 +0200 [thread overview]
Message-ID: <20091113203856.GT7192@me> (raw)
In-Reply-To: <20091113201144.GS7192@me>
Add cl_fmap_match() function - it is similar for cl_fmap_get() (getting
fleximap item by key) with difference that instead of using the map's
default comparison routine custom compare function can be passed there
as a parameter.
This can be useful for matching map item by a key pattern.
Signed-off-by: Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>
---
This function is used in IPv6 SNM MGID compression patch.
opensm/complib/cl_map.c | 14 ++++++++++--
opensm/complib/libosmcomp.map | 1 +
opensm/include/complib/cl_fleximap.h | 36 ++++++++++++++++++++++++++++++++++
3 files changed, 48 insertions(+), 3 deletions(-)
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
--
1.6.5.2
--
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
next prev parent reply other threads:[~2009-11-13 20:38 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-13 6:19 [PATCH] opensm/osm_sa_mcmember_record.c: move mgid allocation code Sasha Khapyorsky
2009-11-13 6:21 ` [PATCH] opensm/osm_sa_member_record.c: mlid independent MGID generator Sasha Khapyorsky
2009-11-13 20:11 ` [PATCH] osm_sa_mcmember_record.c: pass MCM Record data to mlid allocator Sasha Khapyorsky
2009-11-13 20:38 ` Sasha Khapyorsky [this message]
2009-11-13 20:40 ` [PATCH RFC] opensm: compress IPV6 SNM groups to use a single MLID Sasha Khapyorsky
2009-11-16 15:35 ` Hal Rosenstock
[not found] ` <f0e08f230911160735i69ad3671m9a2667900b933e13-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-11-26 16:36 ` Sasha Khapyorsky
2009-11-26 16:37 ` [PATCH] opensm: IPv6 SNM update for man page and usage Sasha Khapyorsky
2009-11-30 19:48 ` [PATCH RFC] opensm: compress IPV6 SNM groups to use a single MLID Hal Rosenstock
[not found] ` <f0e08f230911301148t8d573c7lf1f67972b5438b72-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-12-01 14:58 ` Sasha Khapyorsky
2009-12-01 16:00 ` Hal Rosenstock
2009-11-16 15:30 ` [PATCH] complib/cl_fleximap: add cl_fmap_match() function Hal Rosenstock
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=20091113203856.GT7192@me \
--to=sashak-smomgflxvozwk0htik3j/w@public.gmane.org \
--cc=elid-smomgflXvOZWk0Htik3J/w@public.gmane.org \
--cc=hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=slavas-smomgflXvOZWk0Htik3J/w@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.