[ofw] [PATCH] add new fmap routines required by OpenSM 3.3.5 - 2 of 2

Smith, Stan stan.smith at intel.com
Wed May 12 11:28:24 PDT 2010


Add new fmap routines [cl_fmap_match,cl_fmap_get_next] for use by OpenSM 3.3.5.
Direct merge from OFED for Linux 3.3.5 management tree.

signed-off-by: stan smith <stan.smith at intel.com>

--- a/core/complib/cl_map.c     Wed May 12 11:21:41 2010
+++ b/core/complib/cl_map.c     Wed May 12 11:22:33 2010
@@ -1711,6 +1711,67 @@


 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;
+
+       CL_ASSERT(p_map);
+       CL_ASSERT(p_map->state == CL_INITIALIZED);
+
+       p_item = __cl_fmap_root(p_map);
+
+       while (p_item != &p_map->nil) {
+               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 */
+
+               if (cmp < 0)
+                       p_item = p_item->p_left;        /* too small */
+               else
+                       p_item = p_item->p_right;       /* too big */
+       }
+
+       return (p_item);
+}
+
+
+cl_fmap_item_t*
+cl_fmap_get_next(
+       IN const cl_fmap_t * const      p_map,
+       IN const void *const            p_key)
+{
+       cl_fmap_item_t *p_item;
+       cl_fmap_item_t *p_item_found;
+       int cmp;
+
+       CL_ASSERT(p_map);
+       CL_ASSERT(p_map->state == CL_INITIALIZED);
+
+       p_item = __cl_fmap_root(p_map);
+       p_item_found = (cl_fmap_item_t *) & p_map->nil;
+
+       while (p_item != &p_map->nil) {
+               cmp = p_map->pfn_compare(p_key, p_item->p_key);
+
+               if (cmp < 0) {
+                       p_item_found = p_item;
+                       p_item = p_item->p_left;        /* too small */
+               } else {
+                       p_item = p_item->p_right;       /* too big or match */
+               }
+       }
+
+       return (p_item_found);
+}
+
+
+cl_fmap_item_t*
 cl_fmap_get(
        IN      const cl_fmap_t* const  p_map,
        IN      const void* const               p_key )
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cl_map.c
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20100512/df063860/attachment.c>


More information about the ofw mailing list