Lines Matching defs:pool

47  * struct fc_exch_pool - Per cpu exchange pool
50 * @lock: Exch pool lock
57 * assigned range of exchanges to per cpu pool.
76 * @pool_max_index: Max exch array index in exch pool
77 * @pool: Per cpu exch pool
85 struct fc_exch_pool __percpu *pool;
204 * - If the EM pool lock and ex_lock must be taken at the same time, then the
205 * EM pool lock must be taken before the ex_lock.
405 * fc_exch_ptr_get() - Return an exchange from an exchange pool
406 * @pool: Exchange Pool to get an exchange from
407 * @index: Index of the exchange within the pool
409 * Use the index to get an exchange from within an exchange pool. exches
413 static inline struct fc_exch *fc_exch_ptr_get(struct fc_exch_pool *pool,
416 struct fc_exch **exches = (struct fc_exch **)(pool + 1);
421 * fc_exch_ptr_set() - Assign an exchange to a slot in an exchange pool
422 * @pool: The pool to assign the exchange to
423 * @index: The index in the pool where the exchange will be assigned
424 * @ep: The exchange to assign to the pool
426 static inline void fc_exch_ptr_set(struct fc_exch_pool *pool, u16 index,
429 ((struct fc_exch **)(pool + 1))[index] = ep;
438 struct fc_exch_pool *pool;
441 pool = ep->pool;
442 spin_lock_bh(&pool->lock);
443 WARN_ON(pool->total_exches <= 0);
444 pool->total_exches--;
449 if (pool->left == FC_XID_UNKNOWN)
450 pool->left = index;
451 else if (pool->right == FC_XID_UNKNOWN)
452 pool->right = index;
454 pool->next_index = index;
455 fc_exch_ptr_set(pool, index, NULL);
457 fc_exch_ptr_set(pool, index, &fc_quarantine_exch);
460 spin_unlock_bh(&pool->lock);
819 struct fc_exch_pool *pool;
830 pool = per_cpu_ptr(mp->pool, cpu);
831 spin_lock_bh(&pool->lock);
835 if (pool->left != FC_XID_UNKNOWN) {
836 if (!WARN_ON(fc_exch_ptr_get(pool, pool->left))) {
837 index = pool->left;
838 pool->left = FC_XID_UNKNOWN;
842 if (pool->right != FC_XID_UNKNOWN) {
843 if (!WARN_ON(fc_exch_ptr_get(pool, pool->right))) {
844 index = pool->right;
845 pool->right = FC_XID_UNKNOWN;
850 index = pool->next_index;
851 /* allocate new exch from pool */
852 while (fc_exch_ptr_get(pool, index)) {
854 if (index == pool->next_index)
857 pool->next_index = index == mp->pool_max_index ? 0 : index + 1;
868 fc_exch_ptr_set(pool, index, ep);
869 list_add_tail(&ep->ex_list, &pool->ex_list);
871 pool->total_exches++;
872 spin_unlock_bh(&pool->lock);
879 ep->pool = pool;
890 spin_unlock_bh(&pool->lock);
931 struct fc_exch_pool *pool;
945 pool = per_cpu_ptr(mp->pool, cpu);
946 spin_lock_bh(&pool->lock);
947 ep = fc_exch_ptr_get(pool, (xid - mp->min_xid) >> fc_cpu_order);
956 spin_unlock_bh(&pool->lock);
1925 * fc_exch_pool_reset() - Reset a per cpu exchange pool
1926 * @lport: The local port that the exchange pool is on
1927 * @pool: The exchange pool to be reset
1931 * Resets a per cpu exches pool, releasing all of its sequences
1937 struct fc_exch_pool *pool,
1943 spin_lock_bh(&pool->lock);
1945 list_for_each_entry_safe(ep, next, &pool->ex_list, ex_list) {
1950 spin_unlock_bh(&pool->lock);
1955 spin_lock_bh(&pool->lock);
1964 pool->next_index = 0;
1965 pool->left = FC_XID_UNKNOWN;
1966 pool->right = FC_XID_UNKNOWN;
1967 spin_unlock_bh(&pool->lock);
1989 per_cpu_ptr(ema->mp->pool, cpu),
2418 free_percpu(mp->pool);
2473 struct fc_exch_pool *pool;
2494 /* reduce range so per cpu pool fits into PCPU_MIN_UNIT_SIZE pool */
2495 pool_exch_range = (PCPU_MIN_UNIT_SIZE - sizeof(*pool)) /
2511 * Setup per cpu exch pool with entire exchange id range equally
2513 * allocated for exch range per pool.
2518 * Allocate and initialize per cpu exch pool
2520 pool_size = sizeof(*pool) + pool_exch_range * sizeof(struct fc_exch *);
2521 mp->pool = __alloc_percpu(pool_size, __alignof__(struct fc_exch_pool));
2522 if (!mp->pool)
2525 pool = per_cpu_ptr(mp->pool, cpu);
2526 pool->next_index = 0;
2527 pool->left = FC_XID_UNKNOWN;
2528 pool->right = FC_XID_UNKNOWN;
2529 spin_lock_init(&pool->lock);
2530 INIT_LIST_HEAD(&pool->ex_list);
2535 free_percpu(mp->pool);
2687 * in per cpu exch pool.