Updated dat_rmr_bind API (added lmr_handle as input param)
delete dapl_hash.[h|c] files (not needed any more)
Integrate dapl_hca_util functions in ia/provider code
delete dapl_hca_util.[h|c] files

Signed-off-by: Itamar Rabenstein <[EMAIL PROTECTED]>
        
Index: test/dapltest/test/dapl_bpool.c
===================================================================
--- test/dapltest/test/dapl_bpool.c     (revision 2608)
+++ test/dapltest/test/dapl_bpool.c     (working copy)
@@ -236,6 +236,7 @@
                        bpool_ptr->reg_addr, bpool_ptr->reg_size));
     
        ret = dat_rmr_bind ( bpool_ptr->rmr_handle,
+                           bpool_ptr->lmr,
                            &iov,
                            mflags,
                            bpool_ptr->ep,
Index: test/dapltest/kdapl/kdapl_tdep_user.c
===================================================================
--- test/dapltest/kdapl/kdapl_tdep_user.c       (revision 2608)
+++ test/dapltest/kdapl/kdapl_tdep_user.c       (working copy)
@@ -76,7 +76,7 @@
     }
     if (params_ptr->test_type == TRANSACTION_TEST) {
         print_ioctl.cookie = ioctl (fd, KDAPL_IOCTL_GET_STAT_T, 
&Client_Stats_T);
-        
DT_print_transaction_stats(&Client_Stats_T,params_ptr->u.Transaction_Cmd.num_iterations,
+        
DT_print_transaction_stats(&Client_Stats_T,params_ptr->u.Transaction_Cmd.num_threads,
                                    
params_ptr->u.Transaction_Cmd.eps_per_thread);
     }
 
Index: dat-provider/dapl_hca_util.c
===================================================================
--- dat-provider/dapl_hca_util.c        (revision 2608)
+++ dat-provider/dapl_hca_util.c        (working copy)
@@ -1,150 +0,0 @@
-/*
- * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
- *
- * This Software is licensed under one of the following licenses:
- *
- * 1) under the terms of the "Common Public License 1.0" a copy of which is
- *    available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/cpl.php.
- *
- * 2) under the terms of the "The BSD License" a copy of which is
- *    available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/bsd-license.php.
- *
- * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
- *    copy of which is available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/gpl-license.php.
- *
- * Licensee has the right to choose one of the above licenses.
- *
- * Redistributions of source code must retain the above copyright
- * notice and one of the license notices.
- *
- * Redistributions in binary form must reproduce both the above copyright
- * notice, one of the license notices in the documentation
- * and/or other materials provided with the distribution.
- */
-
-/*
- * $Id$
- */
-
-#include "dapl.h"
-#include "dapl_openib_util.h"
-#include "dapl_provider.h"
-#include "dapl_hca_util.h"
-#include "dapl_hash.h"
-
-/*
- * dapl_hca_alloc
- *
- * alloc and initialize an HCA struct
- *
- * Input:
- *     name
- *      port
- *
- * Output:
- *     hca
- *
- * Returns:
- *     none
- *
- */
-struct dapl_hca *dapl_hca_alloc(char *name, struct ib_device *device, u8 port)
-{
-       struct dapl_hca *hca;
-
-       hca = kmalloc(sizeof *hca, GFP_ATOMIC);
-       if (hca) {
-               memset(hca, 0, sizeof *hca);
-
-               if (DAT_SUCCESS ==
-                   dapl_hash_create(DAPL_HASH_TABLE_DEFAULT_CAPACITY,
-                                    &hca->lmr_hash_table)) {
-                       spin_lock_init(&hca->lock);
-                       INIT_LIST_HEAD(&hca->ia_list);
-
-                       hca->name = dapl_os_strdup(name);
-                       hca->ib_hca_handle = device;
-                       hca->port_num = port;
-                       if (hca->name == NULL) {
-                               kfree(hca);
-                               hca = NULL;
-                       }
-               } else {
-                       kfree(hca);
-                       hca = NULL;
-               }
-       }
-
-       return hca;
-}
-
-/*
- * dapl_hca_free
- *
- * free an IA INFO struct
- *
- * Input:
- *     hca
- *
- * Output:
- *     none
- *
- * Returns:
- *     none
- *
- */
-void dapl_hca_free(struct dapl_hca *hca)
-{
-       (void)dapl_hash_free(hca->lmr_hash_table);
-       kfree(hca->name);
-       kfree(hca);
-}
-
-/*
- * dapl_hca_link_ia
- *
- * Add an ia to the HCA structure
- *
- * Input:
- *     hca
- *     ia_ptr
- *
- * Output:
- *     none
- *
- * Returns:
- *     none
- *
- */
-void dapl_hca_link_ia(struct dapl_hca *hca, struct dapl_ia *ia_ptr)
-{
-       spin_lock_irqsave(&hca->lock, hca->flags);
-       list_add(&ia_ptr->list, &hca->ia_list);
-       spin_unlock_irqrestore(&hca->lock, hca->flags);
-}
-
-/*
- * dapl_hca_unlink_ia
- *
- * Remove an ia from the hca info structure
- *
- * Input:
- *     hca
- *     ia_ptr
- *
- * Output:
- *     none
- *
- * Returns:
- *     none
- *
- */
-void dapl_hca_unlink_ia(struct dapl_hca *hca, struct dapl_ia *ia)
-{
-       spin_lock_irqsave(&hca->lock, hca->flags);
-       list_del(&ia->list);
-       spin_unlock_irqrestore(&hca->lock, hca->flags);
-}
Index: dat-provider/dapl_ia.c
===================================================================
--- dat-provider/dapl_ia.c      (revision 2608)
+++ dat-provider/dapl_ia.c      (working copy)
@@ -33,7 +33,6 @@
 #include "dapl_ia.h"
 #include "dapl_provider.h"
 #include "dapl_evd.h"
-#include "dapl_hca_util.h"
 #include "dapl_openib_util.h"
 #include "dapl_sp.h"
 #include "dapl_cr.h"
@@ -70,8 +69,9 @@
        INIT_LIST_HEAD(&ia->psp_list);
        INIT_LIST_HEAD(&ia->srq_list);
 
-       dapl_hca_link_ia(hca, ia);
-
+       spin_lock_irqsave(&hca->lock, hca->flags);
+       list_add(&ia->list, &hca->ia_list);
+       spin_unlock_irqrestore(&hca->lock, hca->flags);
        return ia;
 }
 
@@ -378,7 +378,9 @@
        dapl_os_assert(list_empty(&ia->psp_list));
        dapl_os_assert(list_empty(&ia->rsp_list));
 
-       dapl_hca_unlink_ia(ia->hca, ia);
+       spin_lock_irqsave(&ia->hca->lock, ia->hca->flags);
+       list_del(&ia->list);
+       spin_unlock_irqrestore(&ia->hca->lock, ia->hca->flags);
        /* no need to destroy ia->common.lock */
 
        kfree(ia);
Index: dat-provider/dapl_lmr.c
===================================================================
--- dat-provider/dapl_lmr.c     (revision 2608)
+++ dat-provider/dapl_lmr.c     (working copy)
@@ -31,7 +31,6 @@
 
 #include "dapl_openib_util.h"
 #include "dapl_ia.h"
-#include "dapl_hash.h"
 
 static struct dapl_lmr *dapl_lmr_alloc(struct dapl_ia *ia,
                                       enum dat_mem_type mem_type,
@@ -103,17 +102,6 @@
        if (DAT_SUCCESS != status)
                goto error2;
 
-       /* if the LMR context is already in the hash table */
-       status = dapl_hash_search(ia->hca->lmr_hash_table,
-                                 new_lmr->param.lmr_context, NULL);
-       if (status == DAT_SUCCESS)
-               goto error3;
-
-       status = dapl_hash_insert(ia->hca->lmr_hash_table,
-                                 new_lmr->param.lmr_context, lmr);
-       if (status != DAT_SUCCESS)
-               goto error3;
-
        atomic_inc(&pz->pz_ref_count);
 
        if (lmr)
@@ -129,8 +117,6 @@
 
        return DAT_SUCCESS;
        
-error3:
-       (void)dapl_ib_mr_deregister(new_lmr);
 error2:
        dapl_lmr_dealloc(new_lmr);      
 error1:
@@ -167,17 +153,6 @@
        if (DAT_SUCCESS != status)
                goto error2;
 
-       /* if the LMR context is already in the hash table */
-       status = dapl_hash_search(ia->hca->lmr_hash_table,
-                                 new_lmr->param.lmr_context, NULL);
-       if (status == DAT_SUCCESS)
-               goto error3;
-
-       status = dapl_hash_insert(ia->hca->lmr_hash_table,
-                                 new_lmr->param.lmr_context, lmr);
-       if (status != DAT_SUCCESS)
-               goto error3;
-
        atomic_inc(&pz->pz_ref_count);
 
        if (lmr)
@@ -193,8 +168,6 @@
 
        return DAT_SUCCESS;
 
-error3:
-       (void)dapl_ib_mr_deregister(new_lmr);
 error2:
        dapl_lmr_dealloc(new_lmr);
 error1:
@@ -215,12 +188,6 @@
        DAT_REGION_DESCRIPTION reg_desc;
        u32 status;
        
-       status = dapl_hash_search(ia->hca->lmr_hash_table,
-                                 original_lmr->param.lmr_context,
-                                 (DAPL_HASH_DATA *) &lmr);
-       if (status != DAT_SUCCESS)
-               goto error1;
-       
        reg_desc.for_lmr = (struct dat_lmr *) original_lmr;
        
        new_lmr = dapl_lmr_alloc(ia, DAT_MEM_TYPE_LMR, reg_desc, 0,
@@ -235,17 +202,6 @@
        if (DAT_SUCCESS != status)
                goto error2;
 
-       /* if the LMR context is already in the hash table */
-       status = dapl_hash_search(ia->hca->lmr_hash_table,
-                                 new_lmr->param.lmr_context, NULL);
-       if (status == DAT_SUCCESS)
-               goto error3;
-
-       status = dapl_hash_insert(ia->hca->lmr_hash_table,
-                                 new_lmr->param.lmr_context, lmr);
-       if (status != DAT_SUCCESS)
-               goto error3;
-
        atomic_inc(&pz->pz_ref_count);
 
        if (lmr)
@@ -262,8 +218,6 @@
 
        return DAT_SUCCESS;
 
-error3:
-       dapl_ib_mr_deregister(new_lmr);
 error2:
        dapl_lmr_dealloc(new_lmr);
 error1:
@@ -371,22 +325,12 @@
                if (0 != atomic_read(&dapl_lmr->lmr_ref_count))
                        return DAT_INVALID_STATE;
                
-               status = dapl_hash_remove(
-                       dapl_lmr->common.owner_ia->hca->lmr_hash_table,
-                       dapl_lmr->param.lmr_context, NULL);
-               if (status != DAT_SUCCESS)
-                       goto error;
-               
                status = dapl_ib_mr_deregister(dapl_lmr);
                if (status == DAT_SUCCESS) {
                        pz = (struct dapl_pz *)dapl_lmr->param.pz;
                        atomic_dec(&pz->pz_ref_count);
                        dapl_lmr_dealloc(dapl_lmr);
-               } else /* failure; put dapl_lmr back in hash table */
-                       dapl_hash_insert(dapl_lmr->common.owner_ia->
-                                        hca->lmr_hash_table,
-                                        dapl_lmr->param.lmr_context, dapl_lmr);
-               
+               }
                break;
        }
        case DAT_MEM_TYPE_PLATFORM:
Index: dat-provider/Makefile
===================================================================
--- dat-provider/Makefile       (revision 2608)
+++ dat-provider/Makefile       (working copy)
@@ -20,8 +20,6 @@
         dapl_cr                        \
         dapl_ep                         \
         dapl_evd                        \
-        dapl_hash                      \
-        dapl_hca_util                  \
         dapl_ia                        \
         dapl_lmr                       \
         dapl_provider                  \
Index: dat-provider/dapl_hca_util.h
===================================================================
--- dat-provider/dapl_hca_util.h        (revision 2608)
+++ dat-provider/dapl_hca_util.h        (working copy)
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
- *
- * This Software is licensed under one of the following licenses:
- *
- * 1) under the terms of the "Common Public License 1.0" a copy of which is
- *    available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/cpl.php.
- *
- * 2) under the terms of the "The BSD License" a copy of which is
- *    available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/bsd-license.php.
- *
- * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
- *    copy of which is available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/gpl-license.php.
- *
- * Licensee has the right to choose one of the above licenses.
- *
- * Redistributions of source code must retain the above copyright
- * notice and one of the license notices.
- *
- * Redistributions in binary form must reproduce both the above copyright
- * notice, one of the license notices in the documentation
- * and/or other materials provided with the distribution.
- */
-
-/*
- * $Id$
- */
-
-#ifndef DAPL_HCA_UTIL_H
-#define DAPL_HCA_UTIL_H
-
-#include "dapl.h"
-
-struct dapl_hca *dapl_hca_alloc(char *name, struct ib_device *device, u8 port);
-
-void dapl_hca_free(struct dapl_hca *hca);
-
-void dapl_hca_link_ia(struct dapl_hca *hca, struct dapl_ia *ia);
-
-void dapl_hca_unlink_ia(struct dapl_hca *hca, struct dapl_ia *ia);
-
-#endif
Index: dat-provider/dapl_rmr.c
===================================================================
--- dat-provider/dapl_rmr.c     (revision 2608)
+++ dat-provider/dapl_rmr.c     (working copy)
@@ -32,7 +32,6 @@
 #include "dapl.h"
 #include "dapl_ep.h"
 #include "dapl_ia.h"
-#include "dapl_hash.h"
 #include "dapl_cookie.h"
 #include "dapl_openib_util.h"
 
@@ -148,26 +147,18 @@
 }
 
 static inline u32 dapl_rmr_bind_fuse(struct dapl_rmr *rmr,
-                                    const struct dat_lmr_triplet *lmr_triplet,
+                                    struct dapl_lmr *lmr,
+                                    const struct dat_lmr_triplet *lmr_triplet,
                                     enum dat_mem_priv_flags mem_priv,
                                     struct dapl_ep *ep_ptr,
                                     DAT_RMR_COOKIE user_cookie,
                                     enum dat_completion_flags completion_flags,
                                     DAT_RMR_CONTEXT *rmr_context)
 {
-       struct dapl_lmr *lmr;
        struct dapl_cookie *cookie;
        u32 status;
        boolean_t is_signaled;
 
-       status = dapl_hash_search(rmr->common.owner_ia->hca->lmr_hash_table,
-                                  lmr_triplet->lmr_context,
-                                  (DAPL_HASH_DATA *) &lmr);
-       if (DAT_SUCCESS != status) {
-               status = DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2);
-               goto bail;
-       }
-
        /*
         * if the ep in unconnected return an error. IB requires that the
         * QP be connected to change a memory window binding since:
@@ -352,6 +343,7 @@
  * Output:
  */
 u32 dapl_rmr_bind(struct dat_rmr *rmr_handle,
+                 struct dat_lmr *lmr_handle, 
                  const struct dat_lmr_triplet *lmr_triplet,
                  enum dat_mem_priv_flags mem_priv, struct dat_ep *ep,
                  DAT_RMR_COOKIE user_cookie,
@@ -359,20 +351,25 @@
                  DAT_RMR_CONTEXT *rmr_context)
 {
        struct dapl_rmr *rmr;
+       struct dapl_lmr *lmr; 
        struct dapl_ep *ep_ptr;
 
        if (!rmr_handle)
                return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_RMR);
 
+       if (!lmr_handle)
+               return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_LMR);
+
        if (!ep)
                return DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_EP);
 
        rmr = (struct dapl_rmr *)rmr_handle;
+       lmr = (struct dapl_lmr *)lmr_handle;
        ep_ptr = (struct dapl_ep *)ep;
 
        /* if the rmr should be bound */
        if (0 != lmr_triplet->segment_length)
-               return dapl_rmr_bind_fuse(rmr, lmr_triplet, mem_priv, ep_ptr,
+               return dapl_rmr_bind_fuse(rmr, lmr, lmr_triplet, mem_priv, 
ep_ptr,
                                          user_cookie, completion_flags, 
                                           rmr_context);
        else /* the rmr should be unbound */
Index: dat-provider/dapl_util.h
===================================================================
--- dat-provider/dapl_util.h    (revision 2608)
+++ dat-provider/dapl_util.h    (working copy)
@@ -40,7 +40,6 @@
 #include <asm/types.h>
 #include <asm/atomic.h>
 #include <linux/delay.h>
-#include <asm/div64.h>         /* needed by hash functions */
 
 #ifdef __ia64__
 #include <asm/atomic.h>
@@ -120,18 +119,6 @@
 }
 
 /*
- * String Functions
- */
-
-static inline char *dapl_os_strdup(const char *str)
-{
-       char *ns = kmalloc(strlen(str) + 1, GFP_KERNEL);
-       if (ns)
-               strcpy(ns, str);
-       return ns;
-}
-
-/*
  * *printf format helper. We use the C string constant concatenation
  * ability to define 64 bit formats, which unfortunatly are non standard
  * in the C compiler world. 
@@ -143,22 +130,6 @@
 #endif
 
 /*
- * dapl_os_mod64
- *
- * Returne the modulo of a 64 bit number. Given that this is running
- * on a 32 bit platform, we need to use the kernel macro to prevent
- * exceptions from killing the machine.
- */
-static inline long dapl_os_mod64(uint64_t key, unsigned long hashsize)
-{
-#ifdef __ia64__
-       return ((uint64_t) ((key) % (hashsize)))
-#else
-       return do_div(key, hashsize);
-#endif
-}
-
-/*
  *  Debug Functions
  */
 
Index: dat-provider/dapl_hash.c
===================================================================
--- dat-provider/dapl_hash.c    (revision 2608)
+++ dat-provider/dapl_hash.c    (working copy)
@@ -1,461 +0,0 @@
-/*
- * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
- *
- * This Software is licensed under one of the following licenses:
- *
- * 1) under the terms of the "Common Public License 1.0" a copy of which is
- *    available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/cpl.php.
- *
- * 2) under the terms of the "The BSD License" a copy of which is
- *    available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/bsd-license.php.
- *
- * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
- *    copy of which is available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/gpl-license.php.
- *
- * Licensee has the right to choose one of the above licenses.
- *
- * Redistributions of source code must retain the above copyright
- * notice and one of the license notices.
- *
- * Redistributions in binary form must reproduce both the above copyright
- * notice, one of the license notices in the documentation
- * and/or other materials provided with the distribution.
- */
-
-/*
- * Provides a generic hash table with chaining.
- *
- * $Id$
- */
-
-#include "dapl_hash.h"
-
-/*********************************************************************
- *                                                                   *
- * Structures                                                        *
- *                                                                   *
- *********************************************************************/
-
-/*
- * A hash table element
- */
-typedef struct DAPL_HASH_ELEM {
-       struct DAPL_HASH_ELEM *next_element;
-       DAPL_HASH_KEY key;
-       void *datum;
-} DAPL_HASH_ELEM;
-
-/*
- * The hash table
- */
-struct dapl_hash_table {
-       unsigned long num_entries;
-       unsigned long tbl_size;
-       DAPL_HASH_ELEM *table;
-       spinlock_t lock;
-       unsigned long flags;
-       /*
-        * statistics - we tally on insert operations, counting
-        * the number of entries in the whole hash table, as
-        * well as the length of chains we walk to insert.  This
-        * ignores empty buckets, giving us data on overall table
-        * occupancy, as well as max/average chain length for
-        * the buckets used.  If our hash function results in
-        * hot buckets, this will show it.
-        */
-       uint64_t hash_tbl_inserts;      /* total inserts ops    */
-       uint64_t hash_tbl_max;  /* max in entire table  */
-       uint64_t hash_tbl_total;        /* total in table       */
-       uint64_t hash_chn_max;  /* longest chain        */
-       uint64_t hash_chn_total;        /* total non-0 lenghts  */
-};
-
-/*********************************************************************
- *                                                                   *
- * Defines                                                           *
- *                                                                   *
- *********************************************************************/
-
-/* datum value in empty table slots  (use 0UL or ~0UL as appropriate) */
-#define NO_DATUM_VALUE          ((void *) 0UL)
-#define NO_DATUM(value)         ((value) == NO_DATUM_VALUE)
-
-/* Lookup macro (which falls back to function to rehash) */
-#define DAPL_HASHLOOKUP( p_table, in_key, out_datum, bucket_head) \
-    do { \
-        DAPL_HASH_KEY save_key = in_key; \
-        DAPL_HASH_ELEM *element = \
-            &((p_table)->table)[DAPL_DOHASH(in_key,(p_table)->tbl_size)]; \
-        in_key = save_key; \
-        if (NO_DATUM(element->datum)) { \
-            (bucket_head) = (void *)0; \
-        } else if (element->key == (DAPL_HASH_KEY) (in_key)) { \
-            (out_datum) = element->datum; \
-            (bucket_head) = (void *)element; \
-        } else if (element->next_element) { \
-            dapl_hash_rehash(element, \
-                            (in_key), \
-                            (void **)&(out_datum), \
-                            (DAPL_HASH_ELEM **)&(bucket_head)); \
-        } else { \
-            (bucket_head) = (void *)0; \
-        }\
-    } while (0)
-
-/*********************************************************************
- *                                                                   *
- * Internal Functions                                                *
- *                                                                   *
- *********************************************************************/
-
-/*
- * Rehash the key (used by add and lookup functions)
- * 
- * Inputs:  element    element to rehash key
- *         key, datum  datum for key head
- *         head        head for list
- */
-static void
-dapl_hash_rehash(DAPL_HASH_ELEM * element,
-                DAPL_HASH_KEY key, void **datum, DAPL_HASH_ELEM ** head)
-{
-       /*
-        * assume we looked at the contents of element already,
-        * and start with the next element.
-        */
-       dapl_os_assert(element->next_element);
-       dapl_os_assert(!NO_DATUM(element->datum));
-
-       *head = element;
-       while (1) {
-               element = element->next_element;
-               if (!element) {
-                       break;
-               }
-               if (element->key == key) {
-                       *datum = element->datum;
-                       return;
-               }
-       }
-       *head = NULL;
-}
-
-/*
- * Add a new key to the hash table
- * 
- * Inputs:
- *          table, key and datum to be added
- *          allow_dup   - TRUE if dups are allowed
- * Outputs: 
- *          report_dup  - should you care to know
- * Returns:
- *          TRUE on success     
- */
-static boolean_t
-dapl_hash_add(struct dapl_hash_table *table, DAPL_HASH_KEY key, void *datum,
-             boolean_t allow_dup, boolean_t *report_dup)
-{
-       void *olddatum;
-       DAPL_HASH_KEY hashValue, save_key = key;
-       DAPL_HASH_ELEM *found;
-       boolean_t status = FALSE;
-       unsigned int chain_len = 0;
-
-       if (report_dup) {
-               (*report_dup) = FALSE;
-       }
-
-       if (NO_DATUM(datum)) {
-               /*
-                * Reserved value used for datum
-                */
-               dapl_dbg_log(DAPL_DBG_TYPE_ERR,
-                            "dapl_hash_add() called with magic NO_DATA "
-                            "value (%p) used as datum!\n", datum);
-               return FALSE;
-       }
-
-       DAPL_HASHLOOKUP(table, key, olddatum, found);
-       if (found) {
-               /*
-                * key exists already
-                */
-               if (report_dup) {
-                       *report_dup = TRUE;
-               }
-
-               if (!allow_dup) {
-                       dapl_dbg_log(DAPL_DBG_TYPE_ERR,
-                                    "dapl_hash_add() called with duplicate "
-                                    "key (" F64x ")\n", key);
-                       return FALSE;
-               }
-       }
-
-       hashValue = DAPL_DOHASH(key, table->tbl_size);
-       key = save_key;
-       if (NO_DATUM(table->table[hashValue].datum)) {
-               /*
-                * Empty head - just fill it in
-                */
-               table->table[hashValue].key = key;
-               table->table[hashValue].datum = datum;
-               table->table[hashValue].next_element = NULL;
-               table->num_entries++;
-               status = TRUE;
-       } else {
-               DAPL_HASH_ELEM *newelement = kmalloc(sizeof *newelement,
-                                                    GFP_ATOMIC);
-               /*
-                * Add an element to the end of the chain
-                */
-               if (newelement) {
-                       DAPL_HASH_ELEM *lastelement;
-                       newelement->key = key;
-                       newelement->datum = datum;
-                       newelement->next_element = NULL;
-                       for (lastelement = &table->table[hashValue];
-                            lastelement->next_element;
-                            lastelement = lastelement->next_element) {
-                               /* Walk to the end of the chain */
-                               chain_len++;
-                       }
-                       lastelement->next_element = newelement;
-                       table->num_entries++;
-                       status = TRUE;
-               } else
-                       status = FALSE;
-       }
-
-       /*
-        * Tally up our counters. chain_len is one less than current chain
-        * length.
-        */
-       chain_len++;
-       table->hash_tbl_inserts++;
-       table->hash_tbl_total += table->num_entries;
-       table->hash_chn_total += chain_len;
-       if (table->num_entries > table->hash_tbl_max) {
-               table->hash_tbl_max = table->num_entries;
-       }
-       if (chain_len > table->hash_chn_max) {
-               table->hash_chn_max = chain_len;
-       }
-
-       return status;
-}
-
-/*
- * Remove element from hash bucket
- * 
- * Inputs:
- *          element, key        to be deleted
- * Returns:
- *          TRUE on success
- */
-static boolean_t
-dapl_hash_delete_element(DAPL_HASH_ELEM * element,
-                        DAPL_HASH_KEY key, DAPL_HASH_DATA * p_datum)
-{
-       DAPL_HASH_ELEM *curelement;
-       DAPL_HASH_ELEM *lastelement;
-
-       lastelement = NULL;
-       for (curelement = element;
-            curelement;
-            lastelement = curelement, curelement = curelement->next_element) {
-               if (curelement->key == key) {
-                       if (p_datum) {
-                               *p_datum = curelement->datum;
-                       }
-                       if (lastelement) {
-                               /*
-                                * curelement was malloc'd; free it
-                                */
-                               lastelement->next_element =
-                                   curelement->next_element;
-                               kfree(curelement);
-                       } else {
-                               /*
-                                * curelement is static list head
-                                */
-                               DAPL_HASH_ELEM *n = curelement->next_element;
-                               if (n) {
-                                       /*
-                                        * If there is a next element, copy its 
contents into the
-                                        * head and free the original next 
element.
-                                        */
-                                       curelement->key = n->key;
-                                       curelement->datum = n->datum;
-                                       curelement->next_element =
-                                           n->next_element;
-                                       kfree(n);
-                               } else {
-                                       curelement->datum = NO_DATUM_VALUE;
-                               }
-                       }
-                       break;
-               }
-       }
-
-       return (curelement != NULL ? TRUE : FALSE);
-}
-
-/*********************************************************************
- *                                                                   *
- * External Functions                                                *
- *                                                                   *
- *********************************************************************/
-
-/*
- * Create a new hash table with at least 'table_size' hash buckets.
- */
-u32 dapl_hash_create(int table_size, struct dapl_hash_table **pp_table)
-{
-       struct dapl_hash_table *p_table;
-       int table_length = table_size * sizeof (struct DAPL_HASH_ELEM);
-       u32 dat_status = DAT_SUCCESS;
-       int i;
-
-       dapl_os_assert(pp_table);
-
-       /* Allocate hash table */
-       p_table = kmalloc(sizeof *p_table, GFP_ATOMIC);
-       if (!p_table) {
-               dat_status =
-                   DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-               goto bail;
-       }
-
-       /* Init hash table, allocate and init and buckets */
-       memset(p_table, 0, sizeof *p_table);
-       p_table->tbl_size = table_size;
-       p_table->table = kmalloc(table_length, GFP_ATOMIC);
-       if (!p_table->table) {
-               kfree(p_table);
-               dat_status =
-                   DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-               goto bail;
-       }
-
-       spin_lock_init(&p_table->lock);
-       for (i = 0; i < table_size; i++) {
-               p_table->table[i].datum = NO_DATUM_VALUE;
-               p_table->table[i].key = 0;
-               p_table->table[i].next_element = NULL;
-       }
-
-       *pp_table = p_table;
-
-bail:
-       return DAT_SUCCESS;
-}
-
-/*
- * Destroy a hash table
- */
-u32 dapl_hash_free(struct dapl_hash_table *p_table)
-{
-       dapl_os_assert(p_table && p_table->table);
-
-       /* no need to destroy p_table->lock */
-       kfree(p_table->table);
-       kfree(p_table);
-
-       return DAT_SUCCESS;
-}
-
-/*
- * Returns the number of elements stored in the table
- */
-
-u32 dapl_hash_size(struct dapl_hash_table *p_table, int *p_size)
-{
-       dapl_os_assert(p_table && p_size);
-
-       *p_size = p_table->num_entries;
-
-       return DAT_SUCCESS;
-}
-
-/*
- * Inserts the specified data into the table with the given key.
- * Duplicates are not expected, and return in error, having done nothing.
- */
-
-u32 dapl_hash_insert(struct dapl_hash_table *p_table, DAPL_HASH_KEY key,
-                    DAPL_HASH_DATA data)
-{
-       u32 dat_status = DAT_SUCCESS;
-
-       dapl_os_assert(p_table);
-
-       spin_lock_irqsave(&p_table->lock, p_table->flags);
-       if (!dapl_hash_add(p_table, key, data, FALSE, NULL)) {
-               dat_status =
-                   DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
-       }
-       spin_unlock_irqrestore(&p_table->lock, p_table->flags);
-
-       return dat_status;
-}
-
-/*
- * Searches for the given key.  If found, 
- * DAT_SUCCESS is returned and the associated 
- * data is returned in the DAPL_HASH_DATA 
- * pointer if that pointer is not NULL.
- */
-u32 dapl_hash_search(struct dapl_hash_table *p_table, DAPL_HASH_KEY key,
-                    DAPL_HASH_DATA *p_data)
-{
-       u32 dat_status;
-       void *olddatum;
-       DAPL_HASH_ELEM *found;
-
-       dapl_os_assert(p_table);
-       dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, 0);
-
-       spin_lock_irqsave(&p_table->lock, p_table->flags);
-       DAPL_HASHLOOKUP(p_table, key, olddatum, found);
-       spin_unlock_irqrestore(&p_table->lock, p_table->flags);
-
-       if (found) {
-               if (p_data) {
-                       *p_data = olddatum;
-               }
-               dat_status = DAT_SUCCESS;
-       }
-
-       return dat_status;
-}
-
-u32 dapl_hash_remove(struct dapl_hash_table *p_table, DAPL_HASH_KEY key,
-                    DAPL_HASH_DATA *p_data)
-{
-       u32 dat_status;
-       DAPL_HASH_KEY hashValue, save_key = key;
-
-       dapl_os_assert(p_table);
-       dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, 0);
-
-       if (p_table->num_entries == 0) {
-               dapl_dbg_log(DAPL_DBG_TYPE_ERR,
-                            "dapl_hash_remove () called on empty hash 
table!\n");
-               return dat_status;
-       }
-
-       hashValue = DAPL_DOHASH(key, p_table->tbl_size);
-       key = save_key;
-       spin_lock_irqsave(&p_table->lock, p_table->flags);
-       if (dapl_hash_delete_element(&p_table->table[hashValue], key, p_data)) {
-               p_table->num_entries--;
-               dat_status = DAT_SUCCESS;
-       }
-       spin_unlock_irqrestore(&p_table->lock, p_table->flags);
-
-       return dat_status;
-}
Index: dat-provider/dapl.h
===================================================================
--- dat-provider/dapl.h (revision 2608)
+++ dat-provider/dapl.h (working copy)
@@ -83,9 +83,6 @@
 
 typedef void (*ib_async_handler_t) (struct ib_event *, void *);
 
-typedef u64 DAPL_HASH_KEY;
-typedef void *DAPL_HASH_DATA;
-
 /*********************************************************************
  *                                                                   *
  * Structures                                                        *
@@ -124,8 +121,6 @@
         u8 port_num;
        struct ib_device *ib_hca_handle;
        struct ib_cq *null_cq;  /* CQ with 0 entries */
-       /* Memory Subsystem Support */
-       struct dapl_hash_table *lmr_hash_table;
        /* Limits & useful HCA attributes */
        struct dat_ia_attr ia_attr;
        struct dat_ep_attr ep_attr;
@@ -542,6 +537,7 @@
                          struct dat_rmr_param *rmr_args);
 
 extern u32 dapl_rmr_bind(struct dat_rmr *rmr,
+                        struct dat_lmr *lmr, 
                         const struct dat_lmr_triplet *lmr_triplet,
                         enum dat_mem_priv_flags mem_priv,
                         struct dat_ep *ep,
Index: dat-provider/dapl_hash.h
===================================================================
--- dat-provider/dapl_hash.h    (revision 2608)
+++ dat-provider/dapl_hash.h    (working copy)
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
- *
- * This Software is licensed under one of the following licenses:
- *
- * 1) under the terms of the "Common Public License 1.0" a copy of which is
- *    available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/cpl.php.
- *
- * 2) under the terms of the "The BSD License" a copy of which is
- *    available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/bsd-license.php.
- *
- * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
- *    copy of which is available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/gpl-license.php.
- *
- * Licensee has the right to choose one of the above licenses.
- *
- * Redistributions of source code must retain the above copyright
- * notice and one of the license notices.
- *
- * Redistributions in binary form must reproduce both the above copyright
- * notice, one of the license notices in the documentation
- * and/or other materials provided with the distribution.
- */
-
-/*
- * $Id$
- */
-
-#ifndef DAPL_HASH_H
-#define DAPL_HASH_H
-
-#include "dapl.h"
-
-/*********************************************************************
- *                                                                   *
- * Defines                                                           *
- *                                                                   *
- *********************************************************************/
-
-/*
- * Hash table size.
- *
- * Default is small; use the larger sample values for hash tables
- * known to be heavily used.  The sample values chosen are the
- * largest primes below 2^8, 2^9, and 2^10.
- */
-#define DAPL_DEF_HASHSIZE               251
-#define DAPL_MED_HASHSIZE               509
-#define DAPL_LRG_HASHSIZE               1021
-
-#define DAPL_HASH_TABLE_DEFAULT_CAPACITY DAPL_DEF_HASHSIZE
-
-/* The hash function */
-#define DAPL_DOHASH(key,hashsize) dapl_os_mod64(key,hashsize)
-
-/*********************************************************************
- *                                                                   *
- * Function Prototypes                                               *
- *                                                                   *
- *********************************************************************/
-
-extern u32 dapl_hash_create(int capacity, struct dapl_hash_table **pp_table);
-
-extern u32 dapl_hash_free(struct dapl_hash_table *p_table);
-
-extern u32 dapl_hash_size(struct dapl_hash_table *p_table, int *p_size);
-
-extern u32 dapl_hash_insert(struct dapl_hash_table *p_table, DAPL_HASH_KEY key,
-                           DAPL_HASH_DATA data);
-
-extern u32 dapl_hash_search(struct dapl_hash_table *p_table, DAPL_HASH_KEY key,
-                           DAPL_HASH_DATA *p_data);
-
-extern u32 dapl_hash_remove(struct dapl_hash_table *p_table, DAPL_HASH_KEY key,
-                           DAPL_HASH_DATA *p_data);
-
-#endif                         /* DAPL_HASH_H */
Index: dat-provider/dapl_provider.c
===================================================================
--- dat-provider/dapl_provider.c        (revision 2608)
+++ dat-provider/dapl_provider.c        (working copy)
@@ -34,7 +34,6 @@
 #include <dat.h>
 
 #include "dapl.h"
-#include "dapl_hca_util.h"
 #include "dapl_provider.h"
 #include "dapl_util.h"
 #include "dapl_openib_util.h"
@@ -247,6 +246,23 @@
        provider_info->is_thread_safe = DAPL_THREADSAFE;
 }
 
+struct dapl_hca *dapl_hca_alloc(char *name, struct ib_device *device, u8 port)
+{
+       struct dapl_hca *hca;
+       int malloc_size = sizeof *hca + strlen(name) + 1;
+       hca = kmalloc(malloc_size, GFP_ATOMIC);
+       if (hca) {
+               memset(hca, 0, malloc_size);
+        spin_lock_init(&hca->lock);
+               INIT_LIST_HEAD(&hca->ia_list);
+        hca->name = (char *)hca + sizeof *hca;
+               strcpy(hca->name, name);
+               hca->ib_hca_handle = device;
+               hca->port_num = port;
+       }
+    return hca;
+}
+
 static void dapl_add_port(struct ib_device *device, u8 port)
 {
        struct dat_provider_info provider_info;
@@ -306,7 +322,7 @@
                        (void)dapl_provider_list_remove(provider_info.ia_name);
 
                if (NULL != hca)
-                       dapl_hca_free(hca);
+                       kfree(hca);
        }
 }
 
@@ -339,7 +355,7 @@
                             provider_info.ia_name);
        }
 
-       dapl_hca_free(provider->extension);
+       kfree(provider->extension);
 
        dapl_provider_list_remove(provider_info.ia_name);
 }
Index: dat/dat.h
===================================================================
--- dat/dat.h   (revision 2608)
+++ dat/dat.h   (working copy)
@@ -1153,7 +1153,8 @@
 
 typedef u32 (*DAT_RMR_QUERY_FUNC)(struct dat_rmr *, struct dat_rmr_param *);
 
-typedef u32 (*DAT_RMR_BIND_FUNC)(struct dat_rmr *, const struct 
dat_lmr_triplet *,
+typedef u32 (*DAT_RMR_BIND_FUNC)(struct dat_rmr *, struct dat_lmr *,
+                                const struct dat_lmr_triplet *,
                                 enum dat_mem_priv_flags, struct dat_ep *,
                                 DAT_RMR_COOKIE, enum dat_completion_flags,
                                 DAT_RMR_CONTEXT *);
@@ -1638,14 +1639,15 @@
 }
 
 static inline u32 dat_rmr_bind(struct dat_rmr * rmr,
-                              const struct dat_lmr_triplet *iov,
+                              struct dat_lmr *lmr, 
+                              const struct dat_lmr_triplet *iov,
                               enum dat_mem_priv_flags mem_flags,
                               struct dat_ep *ep, DAT_RMR_COOKIE cookie,
                               enum dat_completion_flags comp_flags,
                               DAT_RMR_CONTEXT *context)
 {
-        return DAT_CALL_PROVIDER_FUNC(rmr_bind_func, rmr, iov, mem_flags, ep, 
-                                      cookie, comp_flags, context);
+        return DAT_CALL_PROVIDER_FUNC(rmr_bind_func, rmr, lmr, iov, mem_flags, 
+                                      ep, cookie, comp_flags, context);
 }
 
 static inline u32 dat_rmr_free(struct dat_rmr * rmr)

-- 
Itamar
_______________________________________________
openib-general mailing list
openib-general@openib.org
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to