Lines Matching refs:pool
95 struct fc_exch_pool __percpu *pool; member
418 static inline struct fc_exch *fc_exch_ptr_get(struct fc_exch_pool *pool, in fc_exch_ptr_get() argument
421 struct fc_exch **exches = (struct fc_exch **)(pool + 1); in fc_exch_ptr_get()
431 static inline void fc_exch_ptr_set(struct fc_exch_pool *pool, u16 index, in fc_exch_ptr_set() argument
434 ((struct fc_exch **)(pool + 1))[index] = ep; in fc_exch_ptr_set()
443 struct fc_exch_pool *pool; in fc_exch_delete() local
446 pool = ep->pool; in fc_exch_delete()
447 spin_lock_bh(&pool->lock); in fc_exch_delete()
448 WARN_ON(pool->total_exches <= 0); in fc_exch_delete()
449 pool->total_exches--; in fc_exch_delete()
453 if (pool->left == FC_XID_UNKNOWN) in fc_exch_delete()
454 pool->left = index; in fc_exch_delete()
455 else if (pool->right == FC_XID_UNKNOWN) in fc_exch_delete()
456 pool->right = index; in fc_exch_delete()
458 pool->next_index = index; in fc_exch_delete()
460 fc_exch_ptr_set(pool, index, NULL); in fc_exch_delete()
462 spin_unlock_bh(&pool->lock); in fc_exch_delete()
807 struct fc_exch_pool *pool; in fc_exch_em_alloc() local
818 pool = per_cpu_ptr(mp->pool, cpu); in fc_exch_em_alloc()
819 spin_lock_bh(&pool->lock); in fc_exch_em_alloc()
823 if (pool->left != FC_XID_UNKNOWN) { in fc_exch_em_alloc()
824 index = pool->left; in fc_exch_em_alloc()
825 pool->left = FC_XID_UNKNOWN; in fc_exch_em_alloc()
828 if (pool->right != FC_XID_UNKNOWN) { in fc_exch_em_alloc()
829 index = pool->right; in fc_exch_em_alloc()
830 pool->right = FC_XID_UNKNOWN; in fc_exch_em_alloc()
834 index = pool->next_index; in fc_exch_em_alloc()
836 while (fc_exch_ptr_get(pool, index)) { in fc_exch_em_alloc()
838 if (index == pool->next_index) in fc_exch_em_alloc()
841 pool->next_index = index == mp->pool_max_index ? 0 : index + 1; in fc_exch_em_alloc()
852 fc_exch_ptr_set(pool, index, ep); in fc_exch_em_alloc()
853 list_add_tail(&ep->ex_list, &pool->ex_list); in fc_exch_em_alloc()
855 pool->total_exches++; in fc_exch_em_alloc()
856 spin_unlock_bh(&pool->lock); in fc_exch_em_alloc()
863 ep->pool = pool; in fc_exch_em_alloc()
874 spin_unlock_bh(&pool->lock); in fc_exch_em_alloc()
909 struct fc_exch_pool *pool; in fc_exch_find() local
913 pool = per_cpu_ptr(mp->pool, xid & fc_cpu_mask); in fc_exch_find()
914 spin_lock_bh(&pool->lock); in fc_exch_find()
915 ep = fc_exch_ptr_get(pool, (xid - mp->min_xid) >> fc_cpu_order); in fc_exch_find()
920 spin_unlock_bh(&pool->lock); in fc_exch_find()
1865 struct fc_exch_pool *pool, in fc_exch_pool_reset() argument
1871 spin_lock_bh(&pool->lock); in fc_exch_pool_reset()
1873 list_for_each_entry_safe(ep, next, &pool->ex_list, ex_list) { in fc_exch_pool_reset()
1878 spin_unlock_bh(&pool->lock); in fc_exch_pool_reset()
1883 spin_lock_bh(&pool->lock); in fc_exch_pool_reset()
1892 pool->next_index = 0; in fc_exch_pool_reset()
1893 pool->left = FC_XID_UNKNOWN; in fc_exch_pool_reset()
1894 pool->right = FC_XID_UNKNOWN; in fc_exch_pool_reset()
1895 spin_unlock_bh(&pool->lock); in fc_exch_pool_reset()
1917 per_cpu_ptr(ema->mp->pool, cpu), in fc_exch_mgr_reset()
2309 free_percpu(mp->pool); in fc_exch_mgr_destroy()
2364 struct fc_exch_pool *pool; in fc_exch_mgr_alloc() local
2385 pool_exch_range = (PCPU_MIN_UNIT_SIZE - sizeof(*pool)) / in fc_exch_mgr_alloc()
2410 pool_size = sizeof(*pool) + pool_exch_range * sizeof(struct fc_exch *); in fc_exch_mgr_alloc()
2411 mp->pool = __alloc_percpu(pool_size, __alignof__(struct fc_exch_pool)); in fc_exch_mgr_alloc()
2412 if (!mp->pool) in fc_exch_mgr_alloc()
2415 pool = per_cpu_ptr(mp->pool, cpu); in fc_exch_mgr_alloc()
2416 pool->next_index = 0; in fc_exch_mgr_alloc()
2417 pool->left = FC_XID_UNKNOWN; in fc_exch_mgr_alloc()
2418 pool->right = FC_XID_UNKNOWN; in fc_exch_mgr_alloc()
2419 spin_lock_init(&pool->lock); in fc_exch_mgr_alloc()
2420 INIT_LIST_HEAD(&pool->ex_list); in fc_exch_mgr_alloc()
2425 free_percpu(mp->pool); in fc_exch_mgr_alloc()