• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500-V1.0.1.40_1.0.68/src/linux/linux-2.6/net/irda/

Lines Matching refs:hashbin

53  * Notes on the concurrent access to hashbin and other SMP issues
59 * management of concurrent access to the hashbin and how to guarantee the
63 * 1) Protect user data (content pointed by the hashbin)
64 * 2) Protect hashbin structure itself (linked list in each bin)
76 * B) No protection for the hashbin struct global data
89 * hashbin :
93 * As the data is still in the hashbin, it may be changed or free'd
95 * be done within the hashbin, but must include use of the data within
108 * hashbin locking :
110 * 2) hashbin->hb_spinlock
111 * 3) New hashbin usage policy
117 * of the hashbin. As it is a single spinlock, it can protect the global
118 * data of the hashbin and not only the bins themselves.
119 * HB_LOCK can only protect some of the hashbin calls, so it only lock
121 * HB_LOCK in theory is slower than HB_GLOBAL, but as the hashbin
125 * hashbin->hb_spinlock :
132 * spin_lock_irqsave(&hashbin->hb_spinlock, flags);
134 * spin_unlock_irqrestore(&hashbin->hb_spinlock, flags);
147 * The following calls only protect the hashbin itself :
160 * If the hashbin is used only in a single thread of execution
165 * In all other cases, you need to use HB_LOCK and lock the hashbin
172 * hashbin_get_first() and hashbin_get_next() use the hashbin to
174 * As long as the hashbin remains locked, this is safe. If you unlock
175 * the hashbin, the current position may change if anybody else modify
176 * or enumerate the hashbin.
180 * be slower, is more complex to use and doesn't protect the hashbin
188 * Don't believe that because hashbin are now (somewhat) SMP safe
349 * Create hashbin!
354 hashbin_t* hashbin;
357 * Allocate new hashbin
359 hashbin = kzalloc(sizeof(*hashbin), GFP_ATOMIC);
360 if (!hashbin)
366 hashbin->hb_type = type;
367 hashbin->magic = HB_MAGIC;
368 //hashbin->hb_current = NULL;
371 if ( hashbin->hb_type & HB_LOCK ) {
372 spin_lock_init(&hashbin->hb_spinlock);
375 return hashbin;
381 * Function hashbin_delete (hashbin, free_func)
383 * Destroy hashbin, the free_func can be a user supplied special routine
390 int hashbin_delete( hashbin_t* hashbin, FREE_FUNC free_func)
396 IRDA_ASSERT(hashbin != NULL, return -1;);
397 IRDA_ASSERT(hashbin->magic == HB_MAGIC, return -1;);
400 if ( hashbin->hb_type & HB_LOCK ) {
401 spin_lock_irqsave_nested(&hashbin->hb_spinlock, flags,
406 * Free the entries in the hashbin, TODO: use hashbin_clear when
410 queue = dequeue_first((irda_queue_t**) &hashbin->hb_queue[i]);
415 (irda_queue_t**) &hashbin->hb_queue[i]);
420 hashbin->hb_current = NULL;
421 hashbin->magic = ~HB_MAGIC;
424 if ( hashbin->hb_type & HB_LOCK) {
425 spin_unlock_irqrestore(&hashbin->hb_spinlock, flags);
432 * Free the hashbin structure
434 kfree(hashbin);
443 * Function hashbin_insert (hashbin, entry, name)
445 * Insert an entry into the hashbin
448 void hashbin_insert(hashbin_t* hashbin, irda_queue_t* entry, long hashv,
456 IRDA_ASSERT( hashbin != NULL, return;);
457 IRDA_ASSERT( hashbin->magic == HB_MAGIC, return;);
460 * Locate hashbin
467 if ( hashbin->hb_type & HB_LOCK ) {
468 spin_lock_irqsave(&hashbin->hb_spinlock, flags);
481 enqueue_first( (irda_queue_t**) &hashbin->hb_queue[ bin ],
483 hashbin->hb_size++;
486 if ( hashbin->hb_type & HB_LOCK ) {
487 spin_unlock_irqrestore(&hashbin->hb_spinlock, flags);
493 * Function hashbin_remove_first (hashbin)
495 * Remove first entry of the hashbin
501 void *hashbin_remove_first( hashbin_t *hashbin)
507 if ( hashbin->hb_type & HB_LOCK ) {
508 spin_lock_irqsave(&hashbin->hb_spinlock, flags);
511 entry = hashbin_get_first( hashbin);
516 * Locate hashbin
524 dequeue_general( (irda_queue_t**) &hashbin->hb_queue[ bin ],
526 hashbin->hb_size--;
534 if ( entry == hashbin->hb_current)
535 hashbin->hb_current = NULL;
539 if ( hashbin->hb_type & HB_LOCK ) {
540 spin_unlock_irqrestore(&hashbin->hb_spinlock, flags);
548 * Function hashbin_remove (hashbin, hashv, name)
561 void* hashbin_remove( hashbin_t* hashbin, long hashv, const char* name)
569 IRDA_ASSERT( hashbin != NULL, return NULL;);
570 IRDA_ASSERT( hashbin->magic == HB_MAGIC, return NULL;);
573 * Locate hashbin
580 if ( hashbin->hb_type & HB_LOCK ) {
581 spin_lock_irqsave(&hashbin->hb_spinlock, flags);
587 entry = hashbin->hb_queue[ bin ];
609 } while ( entry != hashbin->hb_queue[ bin ] );
616 dequeue_general( (irda_queue_t**) &hashbin->hb_queue[ bin ],
618 hashbin->hb_size--;
624 if ( entry == hashbin->hb_current)
625 hashbin->hb_current = NULL;
629 if ( hashbin->hb_type & HB_LOCK ) {
630 spin_unlock_irqrestore(&hashbin->hb_spinlock, flags);
644 * Function hashbin_remove_this (hashbin, entry)
648 * In some cases, the user of hashbin can't guarantee the unicity
654 void* hashbin_remove_this( hashbin_t* hashbin, irda_queue_t* entry)
662 IRDA_ASSERT( hashbin != NULL, return NULL;);
663 IRDA_ASSERT( hashbin->magic == HB_MAGIC, return NULL;);
667 if ( hashbin->hb_type & HB_LOCK ) {
668 spin_lock_irqsave(&hashbin->hb_spinlock, flags);
678 * Locate hashbin
686 dequeue_general( (irda_queue_t**) &hashbin->hb_queue[ bin ],
688 hashbin->hb_size--;
696 if ( entry == hashbin->hb_current)
697 hashbin->hb_current = NULL;
700 if ( hashbin->hb_type & HB_LOCK ) {
701 spin_unlock_irqrestore(&hashbin->hb_spinlock, flags);
711 * Function hashbin_common_find (hashbin, hashv, name)
716 void* hashbin_find( hashbin_t* hashbin, long hashv, const char* name )
723 IRDA_ASSERT( hashbin != NULL, return NULL;);
724 IRDA_ASSERT( hashbin->magic == HB_MAGIC, return NULL;);
727 * Locate hashbin
736 entry = hashbin->hb_queue[ bin];
755 } while ( entry != hashbin->hb_queue[ bin ] );
763 * Function hashbin_lock_find (hashbin, hashv, name)
768 * I call it safe, but it's only safe with respect to the hashbin, not its
771 void* hashbin_lock_find( hashbin_t* hashbin, long hashv, const char* name )
777 spin_lock_irqsave(&hashbin->hb_spinlock, flags);
782 entry = (irda_queue_t* ) hashbin_find( hashbin, hashv, name );
785 spin_unlock_irqrestore(&hashbin->hb_spinlock, flags);
792 * Function hashbin_find (hashbin, hashv, name, pnext)
801 void* hashbin_find_next( hashbin_t* hashbin, long hashv, const char* name,
808 spin_lock_irqsave(&hashbin->hb_spinlock, flags);
813 * hashbin or has been removed.
815 entry = (irda_queue_t* ) hashbin_find( hashbin, hashv, name );
821 hashbin->hb_current = entry;
822 *pnext = hashbin_get_next( hashbin );
827 spin_unlock_irqrestore(&hashbin->hb_spinlock, flags);
833 * Function hashbin_get_first (hashbin)
835 * Get a pointer to first element in hashbin, this function must be
839 irda_queue_t *hashbin_get_first( hashbin_t* hashbin)
844 IRDA_ASSERT( hashbin != NULL, return NULL;);
845 IRDA_ASSERT( hashbin->magic == HB_MAGIC, return NULL;);
847 if ( hashbin == NULL)
851 entry = hashbin->hb_queue[ i];
853 hashbin->hb_current = entry;
858 * Did not find any item in hashbin
865 * Function hashbin_get_next (hashbin)
867 * Get next item in hashbin. A series of hashbin_get_next() calls must
871 * The context of the search is stored within the hashbin, so you must
874 irda_queue_t *hashbin_get_next( hashbin_t *hashbin)
880 IRDA_ASSERT( hashbin != NULL, return NULL;);
881 IRDA_ASSERT( hashbin->magic == HB_MAGIC, return NULL;);
883 if ( hashbin->hb_current == NULL) {
884 IRDA_ASSERT( hashbin->hb_current != NULL, return NULL;);
887 entry = hashbin->hb_current->q_next;
894 if ( entry != hashbin->hb_queue[ bin ]) {
895 hashbin->hb_current = entry;
901 * Check that this is not the last queue in hashbin
907 * Move to next queue in hashbin
911 entry = hashbin->hb_queue[ i];
913 hashbin->hb_current = entry;