[openib-general] Re: [PATCH][kdapl] Remove dapl_hash (there is no need for the hash)

James Lentini jlentini at netapp.com
Wed Jun 22 09:53:49 PDT 2005


Committed in revision 2675.

On Mon, 20 Jun 2005, Itamar Rabenstein wrote:

itamar> Remove dapl_hash (there is no need for the hash)
itamar> 
itamar> Signed-off-by: Itamar Rabenstein <itamar at mellanox.co.il>
itamar> 
itamar> diff -Nurp -X dontdiff dat-provider_bind/Makefile dat-provider/Makefile
itamar> --- dat-provider_bind/Makefile	Sun Jun 19 15:17:54 2005
itamar> +++ dat-provider/Makefile	Sun Jun 19 15:24:03 2005
itamar> @@ -20,7 +20,6 @@ PROVIDER_MODULES := \
itamar>          dapl_cr                  	\
itamar>          dapl_ep                         \
itamar>          dapl_evd                        \
itamar> -        dapl_hash                     	\
itamar>          dapl_hca_util                 	\
itamar>          dapl_ia                  	\
itamar>          dapl_lmr                 	\
itamar> diff -Nurp -X dontdiff dat-provider_bind/dapl.h dat-provider/dapl.h
itamar> --- dat-provider_bind/dapl.h	Sun Jun 19 15:17:54 2005
itamar> +++ dat-provider/dapl.h	Sun Jun 19 15:24:06 2005
itamar> @@ -84,9 +84,6 @@ typedef enum dapl_evd_completion {
itamar>  
itamar>  typedef void (*ib_async_handler_t) (struct ib_event *, void *);
itamar>  
itamar> -typedef u64 DAPL_HASH_KEY;
itamar> -typedef void *DAPL_HASH_DATA;
itamar> -
itamar>  /*********************************************************************
itamar>   *                                                                   *
itamar>   * Structures                                                        *
itamar> @@ -125,8 +122,6 @@ struct dapl_hca {
itamar>          u8 port_num;
itamar>  	struct ib_device *ib_hca_handle;
itamar>  	struct ib_cq *null_cq; 	/* CQ with 0 entries */
itamar> -	/* Memory Subsystem Support */
itamar> -	struct dapl_hash_table *lmr_hash_table;
itamar>  	/* Limits & useful HCA attributes */
itamar>  	struct dat_ia_attr ia_attr;
itamar>  	struct dat_ep_attr ep_attr;
itamar> diff -Nurp -X dontdiff dat-provider_bind/dapl_hash.c dat-provider/dapl_hash.c
itamar> --- dat-provider_bind/dapl_hash.c	Sun Jun 19 15:17:54 2005
itamar> +++ dat-provider/dapl_hash.c	Thu Jan  1 02:00:00 1970
itamar> @@ -1,462 +0,0 @@
itamar> -/*
itamar> - * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
itamar> - * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
itamar> - *
itamar> - * This Software is licensed under one of the following licenses:
itamar> - *
itamar> - * 1) under the terms of the "Common Public License 1.0" a copy of which is
itamar> - *    available from the Open Source Initiative, see
itamar> - *    http://www.opensource.org/licenses/cpl.php.
itamar> - *
itamar> - * 2) under the terms of the "The BSD License" a copy of which is
itamar> - *    available from the Open Source Initiative, see
itamar> - *    http://www.opensource.org/licenses/bsd-license.php.
itamar> - *
itamar> - * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
itamar> - *    copy of which is available from the Open Source Initiative, see
itamar> - *    http://www.opensource.org/licenses/gpl-license.php.
itamar> - *
itamar> - * Licensee has the right to choose one of the above licenses.
itamar> - *
itamar> - * Redistributions of source code must retain the above copyright
itamar> - * notice and one of the license notices.
itamar> - *
itamar> - * Redistributions in binary form must reproduce both the above copyright
itamar> - * notice, one of the license notices in the documentation
itamar> - * and/or other materials provided with the distribution.
itamar> - */
itamar> -
itamar> -/*
itamar> - * Provides a generic hash table with chaining.
itamar> - *
itamar> - * $Id: dapl_hash.c 2640 2005-06-16 16:22:46Z jlentini $
itamar> - */
itamar> -
itamar> -#include "dapl_hash.h"
itamar> -
itamar> -/*********************************************************************
itamar> - *                                                                   *
itamar> - * Structures                                                        *
itamar> - *                                                                   *
itamar> - *********************************************************************/
itamar> -
itamar> -/*
itamar> - * A hash table element
itamar> - */
itamar> -typedef struct DAPL_HASH_ELEM {
itamar> -	struct DAPL_HASH_ELEM *next_element;
itamar> -	DAPL_HASH_KEY key;
itamar> -	void *datum;
itamar> -} DAPL_HASH_ELEM;
itamar> -
itamar> -/*
itamar> - * The hash table
itamar> - */
itamar> -struct dapl_hash_table {
itamar> -	unsigned long num_entries;
itamar> -	unsigned long tbl_size;
itamar> -	DAPL_HASH_ELEM *table;
itamar> -	spinlock_t lock;
itamar> -	unsigned long flags;
itamar> -	/*
itamar> -	 * statistics - we tally on insert operations, counting
itamar> -	 * the number of entries in the whole hash table, as
itamar> -	 * well as the length of chains we walk to insert.  This
itamar> -	 * ignores empty buckets, giving us data on overall table
itamar> -	 * occupancy, as well as max/average chain length for
itamar> -	 * the buckets used.  If our hash function results in
itamar> -	 * hot buckets, this will show it.
itamar> -	 */
itamar> -	uint64_t hash_tbl_inserts;	/* total inserts ops    */
itamar> -	uint64_t hash_tbl_max;	/* max in entire table  */
itamar> -	uint64_t hash_tbl_total;	/* total in table       */
itamar> -	uint64_t hash_chn_max;	/* longest chain        */
itamar> -	uint64_t hash_chn_total;	/* total non-0 lenghts  */
itamar> -};
itamar> -
itamar> -/*********************************************************************
itamar> - *                                                                   *
itamar> - * Defines                                                           *
itamar> - *                                                                   *
itamar> - *********************************************************************/
itamar> -
itamar> -/* datum value in empty table slots  (use 0UL or ~0UL as appropriate) */
itamar> -#define NO_DATUM_VALUE          ((void *) 0UL)
itamar> -#define NO_DATUM(value)         ((value) == NO_DATUM_VALUE)
itamar> -
itamar> -/* Lookup macro (which falls back to function to rehash) */
itamar> -#define DAPL_HASHLOOKUP( p_table, in_key, out_datum, bucket_head) \
itamar> -    do { \
itamar> -        DAPL_HASH_KEY save_key = in_key; \
itamar> -        DAPL_HASH_ELEM *element = \
itamar> -            &((p_table)->table)[DAPL_DOHASH(in_key,(p_table)->tbl_size)]; \
itamar> -        in_key = save_key; \
itamar> -        if (NO_DATUM(element->datum)) { \
itamar> -            (bucket_head) = (void *)0; \
itamar> -        } else if (element->key == (DAPL_HASH_KEY) (in_key)) { \
itamar> -            (out_datum) = element->datum; \
itamar> -            (bucket_head) = (void *)element; \
itamar> -        } else if (element->next_element) { \
itamar> -            dapl_hash_rehash(element, \
itamar> -                            (in_key), \
itamar> -                            (void **)&(out_datum), \
itamar> -                            (DAPL_HASH_ELEM **)&(bucket_head)); \
itamar> -        } else { \
itamar> -            (bucket_head) = (void *)0; \
itamar> -        }\
itamar> -    } while (0)
itamar> -
itamar> -/*********************************************************************
itamar> - *                                                                   *
itamar> - * Internal Functions                                                *
itamar> - *                                                                   *
itamar> - *********************************************************************/
itamar> -
itamar> -/*
itamar> - * Rehash the key (used by add and lookup functions)
itamar> - * 
itamar> - * Inputs:  element	element to rehash key
itamar> - *	    key, datum	datum for key head
itamar> - *	    head	head for list
itamar> - */
itamar> -static void
itamar> -dapl_hash_rehash(DAPL_HASH_ELEM * element,
itamar> -		 DAPL_HASH_KEY key, void **datum, DAPL_HASH_ELEM ** head)
itamar> -{
itamar> -	/*
itamar> -	 * assume we looked at the contents of element already,
itamar> -	 * and start with the next element.
itamar> -	 */
itamar> -	dapl_os_assert(element->next_element);
itamar> -	dapl_os_assert(!NO_DATUM(element->datum));
itamar> -
itamar> -	*head = element;
itamar> -	while (1) {
itamar> -		element = element->next_element;
itamar> -		if (!element) {
itamar> -			break;
itamar> -		}
itamar> -		if (element->key == key) {
itamar> -			*datum = element->datum;
itamar> -			return;
itamar> -		}
itamar> -	}
itamar> -	*head = NULL;
itamar> -}
itamar> -
itamar> -/*
itamar> - * Add a new key to the hash table
itamar> - * 
itamar> - * Inputs:
itamar> - *          table, key and datum to be added
itamar> - *          allow_dup   - TRUE if dups are allowed
itamar> - * Outputs: 
itamar> - *          report_dup  - should you care to know
itamar> - * Returns:
itamar> - *          TRUE on success     
itamar> - */
itamar> -static boolean_t
itamar> -dapl_hash_add(struct dapl_hash_table *table, DAPL_HASH_KEY key, void *datum,
itamar> -	      boolean_t allow_dup, boolean_t *report_dup)
itamar> -{
itamar> -	void *olddatum;
itamar> -	DAPL_HASH_KEY hashValue, save_key = key;
itamar> -	DAPL_HASH_ELEM *found;
itamar> -	boolean_t status = FALSE;
itamar> -	unsigned int chain_len = 0;
itamar> -
itamar> -	if (report_dup) {
itamar> -		(*report_dup) = FALSE;
itamar> -	}
itamar> -
itamar> -	if (NO_DATUM(datum)) {
itamar> -		/*
itamar> -		 * Reserved value used for datum
itamar> -		 */
itamar> -		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
itamar> -			     "dapl_hash_add() called with magic NO_DATA "
itamar> -			     "value (%p) used as datum!\n", datum);
itamar> -		return FALSE;
itamar> -	}
itamar> -
itamar> -	DAPL_HASHLOOKUP(table, key, olddatum, found);
itamar> -	if (found) {
itamar> -		/*
itamar> -		 * key exists already
itamar> -		 */
itamar> -		if (report_dup) {
itamar> -			*report_dup = TRUE;
itamar> -		}
itamar> -
itamar> -		if (!allow_dup) {
itamar> -			dapl_dbg_log(DAPL_DBG_TYPE_ERR,
itamar> -				     "dapl_hash_add() called with duplicate "
itamar> -				     "key (" F64x ")\n", key);
itamar> -			return FALSE;
itamar> -		}
itamar> -	}
itamar> -
itamar> -	hashValue = DAPL_DOHASH(key, table->tbl_size);
itamar> -	key = save_key;
itamar> -	if (NO_DATUM(table->table[hashValue].datum)) {
itamar> -		/*
itamar> -		 * Empty head - just fill it in
itamar> -		 */
itamar> -		table->table[hashValue].key = key;
itamar> -		table->table[hashValue].datum = datum;
itamar> -		table->table[hashValue].next_element = NULL;
itamar> -		table->num_entries++;
itamar> -		status = TRUE;
itamar> -	} else {
itamar> -		DAPL_HASH_ELEM *newelement = kmalloc(sizeof *newelement,
itamar> -						     GFP_ATOMIC);
itamar> -		/*
itamar> -		 * Add an element to the end of the chain
itamar> -		 */
itamar> -		if (newelement) {
itamar> -			DAPL_HASH_ELEM *lastelement;
itamar> -			newelement->key = key;
itamar> -			newelement->datum = datum;
itamar> -			newelement->next_element = NULL;
itamar> -			for (lastelement = &table->table[hashValue];
itamar> -			     lastelement->next_element;
itamar> -			     lastelement = lastelement->next_element) {
itamar> -				/* Walk to the end of the chain */
itamar> -				chain_len++;
itamar> -			}
itamar> -			lastelement->next_element = newelement;
itamar> -			table->num_entries++;
itamar> -			status = TRUE;
itamar> -		} else
itamar> -			status = FALSE;
itamar> -	}
itamar> -
itamar> -	/*
itamar> -	 * Tally up our counters. chain_len is one less than current chain
itamar> -	 * length.
itamar> -	 */
itamar> -	chain_len++;
itamar> -	table->hash_tbl_inserts++;
itamar> -	table->hash_tbl_total += table->num_entries;
itamar> -	table->hash_chn_total += chain_len;
itamar> -	if (table->num_entries > table->hash_tbl_max) {
itamar> -		table->hash_tbl_max = table->num_entries;
itamar> -	}
itamar> -	if (chain_len > table->hash_chn_max) {
itamar> -		table->hash_chn_max = chain_len;
itamar> -	}
itamar> -
itamar> -	return status;
itamar> -}
itamar> -
itamar> -/*
itamar> - * Remove element from hash bucket
itamar> - * 
itamar> - * Inputs:
itamar> - *          element, key        to be deleted
itamar> - * Returns:
itamar> - *          TRUE on success
itamar> - */
itamar> -static boolean_t
itamar> -dapl_hash_delete_element(DAPL_HASH_ELEM * element,
itamar> -			 DAPL_HASH_KEY key, DAPL_HASH_DATA * p_datum)
itamar> -{
itamar> -	DAPL_HASH_ELEM *curelement;
itamar> -	DAPL_HASH_ELEM *lastelement;
itamar> -
itamar> -	lastelement = NULL;
itamar> -	for (curelement = element;
itamar> -	     curelement;
itamar> -	     lastelement = curelement, curelement = curelement->next_element) {
itamar> -		if (curelement->key == key) {
itamar> -			if (p_datum) {
itamar> -				*p_datum = curelement->datum;
itamar> -			}
itamar> -			if (lastelement) {
itamar> -				/*
itamar> -				 * curelement was malloc'd; free it
itamar> -				 */
itamar> -				lastelement->next_element =
itamar> -				    curelement->next_element;
itamar> -				kfree(curelement);
itamar> -			} else {
itamar> -				/*
itamar> -				 * curelement is static list head
itamar> -				 */
itamar> -				DAPL_HASH_ELEM *n = curelement->next_element;
itamar> -				if (n) {
itamar> -					/*
itamar> -					 * If there is a next element, copy its contents into the
itamar> -					 * head and free the original next element.
itamar> -					 */
itamar> -					curelement->key = n->key;
itamar> -					curelement->datum = n->datum;
itamar> -					curelement->next_element =
itamar> -					    n->next_element;
itamar> -					kfree(n);
itamar> -				} else {
itamar> -					curelement->datum = NO_DATUM_VALUE;
itamar> -				}
itamar> -			}
itamar> -			break;
itamar> -		}
itamar> -	}
itamar> -
itamar> -	return (curelement != NULL ? TRUE : FALSE);
itamar> -}
itamar> -
itamar> -/*********************************************************************
itamar> - *                                                                   *
itamar> - * External Functions                                                *
itamar> - *                                                                   *
itamar> - *********************************************************************/
itamar> -
itamar> -/*
itamar> - * Create a new hash table with at least 'table_size' hash buckets.
itamar> - */
itamar> -u32 dapl_hash_create(int table_size, struct dapl_hash_table **pp_table)
itamar> -{
itamar> -	struct dapl_hash_table *p_table;
itamar> -	int table_length = table_size * sizeof (struct DAPL_HASH_ELEM);
itamar> -	u32 dat_status = DAT_SUCCESS;
itamar> -	int i;
itamar> -
itamar> -	dapl_os_assert(pp_table);
itamar> -
itamar> -	/* Allocate hash table */
itamar> -	p_table = kmalloc(sizeof *p_table, GFP_ATOMIC);
itamar> -	if (!p_table) {
itamar> -		dat_status =
itamar> -		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
itamar> -		goto bail;
itamar> -	}
itamar> -
itamar> -	/* Init hash table, allocate and init and buckets */
itamar> -	memset(p_table, 0, sizeof *p_table);
itamar> -	p_table->tbl_size = table_size;
itamar> -	p_table->table = kmalloc(table_length, GFP_ATOMIC);
itamar> -	if (!p_table->table) {
itamar> -		kfree(p_table);
itamar> -		dat_status =
itamar> -		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
itamar> -		goto bail;
itamar> -	}
itamar> -
itamar> -	spin_lock_init(&p_table->lock);
itamar> -	for (i = 0; i < table_size; i++) {
itamar> -		p_table->table[i].datum = NO_DATUM_VALUE;
itamar> -		p_table->table[i].key = 0;
itamar> -		p_table->table[i].next_element = NULL;
itamar> -	}
itamar> -
itamar> -	*pp_table = p_table;
itamar> -
itamar> -bail:
itamar> -	return DAT_SUCCESS;
itamar> -}
itamar> -
itamar> -/*
itamar> - * Destroy a hash table
itamar> - */
itamar> -u32 dapl_hash_free(struct dapl_hash_table *p_table)
itamar> -{
itamar> -	dapl_os_assert(p_table && p_table->table);
itamar> -
itamar> -	/* no need to destroy p_table->lock */
itamar> -	kfree(p_table->table);
itamar> -	kfree(p_table);
itamar> -
itamar> -	return DAT_SUCCESS;
itamar> -}
itamar> -
itamar> -/*
itamar> - * Returns the number of elements stored in the table
itamar> - */
itamar> -
itamar> -u32 dapl_hash_size(struct dapl_hash_table *p_table, int *p_size)
itamar> -{
itamar> -	dapl_os_assert(p_table && p_size);
itamar> -
itamar> -	*p_size = p_table->num_entries;
itamar> -
itamar> -	return DAT_SUCCESS;
itamar> -}
itamar> -
itamar> -/*
itamar> - * Inserts the specified data into the table with the given key.
itamar> - * Duplicates are not expected, and return in error, having done nothing.
itamar> - */
itamar> -
itamar> -u32 dapl_hash_insert(struct dapl_hash_table *p_table, DAPL_HASH_KEY key,
itamar> -		     DAPL_HASH_DATA data)
itamar> -{
itamar> -	u32 dat_status = DAT_SUCCESS;
itamar> -
itamar> -	dapl_os_assert(p_table);
itamar> -
itamar> -	spin_lock_irqsave(&p_table->lock, p_table->flags);
itamar> -	if (!dapl_hash_add(p_table, key, data, FALSE, NULL)) {
itamar> -		dat_status =
itamar> -		    DAT_ERROR(DAT_INSUFFICIENT_RESOURCES, DAT_RESOURCE_MEMORY);
itamar> -	}
itamar> -	spin_unlock_irqrestore(&p_table->lock, p_table->flags);
itamar> -
itamar> -	return dat_status;
itamar> -}
itamar> -
itamar> -/*
itamar> - * Searches for the given key.  If found, 
itamar> - * DAT_SUCCESS is returned and the associated 
itamar> - * data is returned in the DAPL_HASH_DATA 
itamar> - * pointer if that pointer is not NULL.
itamar> - */
itamar> -u32 dapl_hash_search(struct dapl_hash_table *p_table, DAPL_HASH_KEY key,
itamar> -		     DAPL_HASH_DATA *p_data)
itamar> -{
itamar> -	u32 dat_status;
itamar> -	void *olddatum;
itamar> -	DAPL_HASH_ELEM *found;
itamar> -
itamar> -	dapl_os_assert(p_table);
itamar> -	dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, 0);
itamar> -
itamar> -	spin_lock_irqsave(&p_table->lock, p_table->flags);
itamar> -	DAPL_HASHLOOKUP(p_table, key, olddatum, found);
itamar> -	spin_unlock_irqrestore(&p_table->lock, p_table->flags);
itamar> -
itamar> -	if (found) {
itamar> -		if (p_data) {
itamar> -			*p_data = olddatum;
itamar> -		}
itamar> -		dat_status = DAT_SUCCESS;
itamar> -	}
itamar> -
itamar> -	return dat_status;
itamar> -}
itamar> -
itamar> -u32 dapl_hash_remove(struct dapl_hash_table *p_table, DAPL_HASH_KEY key,
itamar> -		     DAPL_HASH_DATA *p_data)
itamar> -{
itamar> -	u32 dat_status;
itamar> -	DAPL_HASH_KEY hashValue, save_key = key;
itamar> -
itamar> -	dapl_os_assert(p_table);
itamar> -	dat_status = DAT_ERROR(DAT_INVALID_PARAMETER, 0);
itamar> -
itamar> -	if (p_table->num_entries == 0) {
itamar> -		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
itamar> -			     "dapl_hash_remove () called on empty hash table!\n");
itamar> -		return dat_status;
itamar> -	}
itamar> -
itamar> -	hashValue = DAPL_DOHASH(key, p_table->tbl_size);
itamar> -	key = save_key;
itamar> -	spin_lock_irqsave(&p_table->lock, p_table->flags);
itamar> -	if (dapl_hash_delete_element(&p_table->table[hashValue], key, p_data)) {
itamar> -		p_table->num_entries--;
itamar> -		dat_status = DAT_SUCCESS;
itamar> -	}
itamar> -	spin_unlock_irqrestore(&p_table->lock, p_table->flags);
itamar> -
itamar> -	return dat_status;
itamar> -}
itamar> diff -Nurp -X dontdiff dat-provider_bind/dapl_hash.h dat-provider/dapl_hash.h
itamar> --- dat-provider_bind/dapl_hash.h	Sun Jun 19 15:17:54 2005
itamar> +++ dat-provider/dapl_hash.h	Thu Jan  1 02:00:00 1970
itamar> @@ -1,81 +0,0 @@
itamar> -/*
itamar> - * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
itamar> - * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
itamar> - *
itamar> - * This Software is licensed under one of the following licenses:
itamar> - *
itamar> - * 1) under the terms of the "Common Public License 1.0" a copy of which is
itamar> - *    available from the Open Source Initiative, see
itamar> - *    http://www.opensource.org/licenses/cpl.php.
itamar> - *
itamar> - * 2) under the terms of the "The BSD License" a copy of which is
itamar> - *    available from the Open Source Initiative, see
itamar> - *    http://www.opensource.org/licenses/bsd-license.php.
itamar> - *
itamar> - * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
itamar> - *    copy of which is available from the Open Source Initiative, see
itamar> - *    http://www.opensource.org/licenses/gpl-license.php.
itamar> - *
itamar> - * Licensee has the right to choose one of the above licenses.
itamar> - *
itamar> - * Redistributions of source code must retain the above copyright
itamar> - * notice and one of the license notices.
itamar> - *
itamar> - * Redistributions in binary form must reproduce both the above copyright
itamar> - * notice, one of the license notices in the documentation
itamar> - * and/or other materials provided with the distribution.
itamar> - */
itamar> -
itamar> -/*
itamar> - * $Id: dapl_hash.h 2640 2005-06-16 16:22:46Z jlentini $
itamar> - */
itamar> -
itamar> -#ifndef DAPL_HASH_H
itamar> -#define DAPL_HASH_H
itamar> -
itamar> -#include "dapl.h"
itamar> -
itamar> -/*********************************************************************
itamar> - *                                                                   *
itamar> - * Defines                                                           *
itamar> - *                                                                   *
itamar> - *********************************************************************/
itamar> -
itamar> -/*
itamar> - * Hash table size.
itamar> - *
itamar> - * Default is small; use the larger sample values for hash tables
itamar> - * known to be heavily used.  The sample values chosen are the
itamar> - * largest primes below 2^8, 2^9, and 2^10.
itamar> - */
itamar> -#define DAPL_DEF_HASHSIZE               251
itamar> -#define DAPL_MED_HASHSIZE               509
itamar> -#define DAPL_LRG_HASHSIZE               1021
itamar> -
itamar> -#define DAPL_HASH_TABLE_DEFAULT_CAPACITY DAPL_DEF_HASHSIZE
itamar> -
itamar> -/* The hash function */
itamar> -#define DAPL_DOHASH(key,hashsize) dapl_os_mod64(key,hashsize)
itamar> -
itamar> -/*********************************************************************
itamar> - *                                                                   *
itamar> - * Function Prototypes                                               *
itamar> - *                                                                   *
itamar> - *********************************************************************/
itamar> -
itamar> -extern u32 dapl_hash_create(int capacity, struct dapl_hash_table **pp_table);
itamar> -
itamar> -extern u32 dapl_hash_free(struct dapl_hash_table *p_table);
itamar> -
itamar> -extern u32 dapl_hash_size(struct dapl_hash_table *p_table, int *p_size);
itamar> -
itamar> -extern u32 dapl_hash_insert(struct dapl_hash_table *p_table, DAPL_HASH_KEY key,
itamar> -			    DAPL_HASH_DATA data);
itamar> -
itamar> -extern u32 dapl_hash_search(struct dapl_hash_table *p_table, DAPL_HASH_KEY key,
itamar> -			    DAPL_HASH_DATA *p_data);
itamar> -
itamar> -extern u32 dapl_hash_remove(struct dapl_hash_table *p_table, DAPL_HASH_KEY key,
itamar> -			    DAPL_HASH_DATA *p_data);
itamar> -
itamar> -#endif				/* DAPL_HASH_H */
itamar> diff -Nurp -X dontdiff dat-provider_bind/dapl_hca_util.c dat-provider/dapl_hca_util.c
itamar> --- dat-provider_bind/dapl_hca_util.c	Sun Jun 19 15:17:54 2005
itamar> +++ dat-provider/dapl_hca_util.c	Sun Jun 19 15:24:06 2005
itamar> @@ -34,7 +34,6 @@
itamar>  #include "dapl_openib_util.h"
itamar>  #include "dapl_provider.h"
itamar>  #include "dapl_hca_util.h"
itamar> -#include "dapl_hash.h"
itamar>  
itamar>  /*
itamar>   * dapl_hca_alloc
itamar> @@ -60,20 +59,13 @@ struct dapl_hca *dapl_hca_alloc(char *na
itamar>  	if (hca) {
itamar>  		memset(hca, 0, sizeof *hca);
itamar>  
itamar> -		if (DAT_SUCCESS ==
itamar> -		    dapl_hash_create(DAPL_HASH_TABLE_DEFAULT_CAPACITY,
itamar> -				     &hca->lmr_hash_table)) {
itamar> -			spin_lock_init(&hca->lock);
itamar> -			INIT_LIST_HEAD(&hca->ia_list);
itamar> -
itamar> -			hca->name = dapl_os_strdup(name);
itamar> -			hca->ib_hca_handle = device;
itamar> -			hca->port_num = port;
itamar> -			if (hca->name == NULL) {
itamar> -				kfree(hca);
itamar> -				hca = NULL;
itamar> -			}
itamar> -		} else {
itamar> +		spin_lock_init(&hca->lock);
itamar> +		INIT_LIST_HEAD(&hca->ia_list);
itamar> +
itamar> +		hca->name = dapl_os_strdup(name);
itamar> +		hca->ib_hca_handle = device;
itamar> +		hca->port_num = port;
itamar> +		if (hca->name == NULL) {
itamar>  			kfree(hca);
itamar>  			hca = NULL;
itamar>  		}
itamar> @@ -99,7 +91,6 @@ struct dapl_hca *dapl_hca_alloc(char *na
itamar>   */
itamar>  void dapl_hca_free(struct dapl_hca *hca)
itamar>  {
itamar> -	(void)dapl_hash_free(hca->lmr_hash_table);
itamar>  	kfree(hca->name);
itamar>  	kfree(hca);
itamar>  }
itamar> diff -Nurp -X dontdiff dat-provider_bind/dapl_lmr.c dat-provider/dapl_lmr.c
itamar> --- dat-provider_bind/dapl_lmr.c	Sun Jun 19 15:17:54 2005
itamar> +++ dat-provider/dapl_lmr.c	Sun Jun 19 15:24:06 2005
itamar> @@ -32,7 +32,6 @@
itamar>  
itamar>  #include "dapl_openib_util.h"
itamar>  #include "dapl_ia.h"
itamar> -#include "dapl_hash.h"
itamar>  
itamar>  static struct dapl_lmr *dapl_lmr_alloc(struct dapl_ia *ia,
itamar>  				       enum dat_mem_type mem_type,
itamar> @@ -104,17 +103,6 @@ static inline u32 dapl_lmr_create_virtua
itamar>  	if (DAT_SUCCESS != status)
itamar>  		goto error2;
itamar>  
itamar> -	/* if the LMR context is already in the hash table */
itamar> -	status = dapl_hash_search(ia->hca->lmr_hash_table,
itamar> -				  new_lmr->param.lmr_context, NULL);
itamar> -	if (status == DAT_SUCCESS)
itamar> -		goto error3;
itamar> -
itamar> -	status = dapl_hash_insert(ia->hca->lmr_hash_table,
itamar> -				  new_lmr->param.lmr_context, lmr);
itamar> -	if (status != DAT_SUCCESS)
itamar> -		goto error3;
itamar> -
itamar>  	atomic_inc(&pz->pz_ref_count);
itamar>  
itamar>  	if (lmr)
itamar> @@ -130,8 +118,6 @@ static inline u32 dapl_lmr_create_virtua
itamar>  
itamar>  	return DAT_SUCCESS;
itamar>  	
itamar> -error3:
itamar> -	(void)dapl_ib_mr_deregister(new_lmr);
itamar>  error2:
itamar>  	dapl_lmr_dealloc(new_lmr);	
itamar>  error1:
itamar> @@ -168,17 +154,6 @@ static inline u32 dapl_lmr_create_physic
itamar>  	if (DAT_SUCCESS != status)
itamar>  		goto error2;
itamar>  
itamar> -	/* if the LMR context is already in the hash table */
itamar> -	status = dapl_hash_search(ia->hca->lmr_hash_table,
itamar> -				  new_lmr->param.lmr_context, NULL);
itamar> -	if (status == DAT_SUCCESS)
itamar> -		goto error3;
itamar> -
itamar> -	status = dapl_hash_insert(ia->hca->lmr_hash_table,
itamar> -				  new_lmr->param.lmr_context, lmr);
itamar> -	if (status != DAT_SUCCESS)
itamar> -		goto error3;
itamar> -
itamar>  	atomic_inc(&pz->pz_ref_count);
itamar>  
itamar>  	if (lmr)
itamar> @@ -194,8 +169,6 @@ static inline u32 dapl_lmr_create_physic
itamar>  
itamar>  	return DAT_SUCCESS;
itamar>  
itamar> -error3:
itamar> -	(void)dapl_ib_mr_deregister(new_lmr);
itamar>  error2:
itamar>  	dapl_lmr_dealloc(new_lmr);
itamar>  error1:
itamar> @@ -216,12 +189,6 @@ static inline u32 dapl_lmr_create_lmr(st
itamar>  	DAT_REGION_DESCRIPTION reg_desc;
itamar>  	u32 status;
itamar>  	
itamar> -	status = dapl_hash_search(ia->hca->lmr_hash_table,
itamar> -				  original_lmr->param.lmr_context,
itamar> -				  (DAPL_HASH_DATA *) &lmr);
itamar> -	if (status != DAT_SUCCESS)
itamar> -		goto error1;
itamar> -	
itamar>  	reg_desc.for_lmr = (struct dat_lmr *) original_lmr;
itamar>  	
itamar>  	new_lmr = dapl_lmr_alloc(ia, DAT_MEM_TYPE_LMR, reg_desc, 0,
itamar> @@ -236,17 +203,6 @@ static inline u32 dapl_lmr_create_lmr(st
itamar>  	if (DAT_SUCCESS != status)
itamar>  		goto error2;
itamar>  
itamar> -	/* if the LMR context is already in the hash table */
itamar> -	status = dapl_hash_search(ia->hca->lmr_hash_table,
itamar> -				  new_lmr->param.lmr_context, NULL);
itamar> -	if (status == DAT_SUCCESS)
itamar> -		goto error3;
itamar> -
itamar> -	status = dapl_hash_insert(ia->hca->lmr_hash_table,
itamar> -				  new_lmr->param.lmr_context, lmr);
itamar> -	if (status != DAT_SUCCESS)
itamar> -		goto error3;
itamar> -
itamar>  	atomic_inc(&pz->pz_ref_count);
itamar>  
itamar>  	if (lmr)
itamar> @@ -263,8 +219,6 @@ static inline u32 dapl_lmr_create_lmr(st
itamar>  
itamar>  	return DAT_SUCCESS;
itamar>  
itamar> -error3:
itamar> -	dapl_ib_mr_deregister(new_lmr);
itamar>  error2:
itamar>  	dapl_lmr_dealloc(new_lmr);
itamar>  error1:
itamar> @@ -372,22 +326,12 @@ u32 dapl_lmr_free(struct dat_lmr *lmr)
itamar>  		if (0 != atomic_read(&dapl_lmr->lmr_ref_count))
itamar>  			return DAT_INVALID_STATE;
itamar>  		
itamar> -		status = dapl_hash_remove(
itamar> -			dapl_lmr->common.owner_ia->hca->lmr_hash_table,
itamar> -			dapl_lmr->param.lmr_context, NULL);
itamar> -		if (status != DAT_SUCCESS)
itamar> -			goto error;
itamar> -		
itamar>  		status = dapl_ib_mr_deregister(dapl_lmr);
itamar>  		if (status == DAT_SUCCESS) {
itamar>  			pz = (struct dapl_pz *)dapl_lmr->param.pz;
itamar>  			atomic_dec(&pz->pz_ref_count);
itamar>  			dapl_lmr_dealloc(dapl_lmr);
itamar> -		} else /* failure; put dapl_lmr back in hash table */
itamar> -			dapl_hash_insert(dapl_lmr->common.owner_ia->
itamar> -					 hca->lmr_hash_table,
itamar> -					 dapl_lmr->param.lmr_context, dapl_lmr);
itamar> -		
itamar> +		}
itamar>  		break;
itamar>  	}
itamar>  	case DAT_MEM_TYPE_PLATFORM:
itamar> diff -Nurp -X dontdiff dat-provider_bind/dapl_rmr.c dat-provider/dapl_rmr.c
itamar> --- dat-provider_bind/dapl_rmr.c	Sun Jun 19 15:17:54 2005
itamar> +++ dat-provider/dapl_rmr.c	Sun Jun 19 15:24:06 2005
itamar> @@ -33,7 +33,6 @@
itamar>  #include "dapl.h"
itamar>  #include "dapl_ep.h"
itamar>  #include "dapl_ia.h"
itamar> -#include "dapl_hash.h"
itamar>  #include "dapl_cookie.h"
itamar>  #include "dapl_openib_util.h"
itamar>  
itamar> diff -Nurp -X dontdiff dat-provider_bind/dapl_util.h dat-provider/dapl_util.h
itamar> --- dat-provider_bind/dapl_util.h	Sun Jun 19 15:17:54 2005
itamar> +++ dat-provider/dapl_util.h	Sun Jun 19 15:24:30 2005
itamar> @@ -144,22 +144,6 @@ static inline char *dapl_os_strdup(const
itamar>  #endif
itamar>  
itamar>  /*
itamar> - * dapl_os_mod64
itamar> - *
itamar> - * Returne the modulo of a 64 bit number. Given that this is running
itamar> - * on a 32 bit platform, we need to use the kernel macro to prevent
itamar> - * exceptions from killing the machine.
itamar> - */
itamar> -static inline long dapl_os_mod64(uint64_t key, unsigned long hashsize)
itamar> -{
itamar> -#ifdef __ia64__
itamar> -	return ((uint64_t) ((key) % (hashsize)))
itamar> -#else
itamar> -	return do_div(key, hashsize);
itamar> -#endif
itamar> -}
itamar> -
itamar> -/*
itamar>   *  Debug Functions
itamar>   */
itamar>  
itamar> -- 
itamar> Itamar
itamar> 



More information about the general mailing list