Lines Matching refs:cache

216 static int tx_policy_find(struct tx_policy_cache *cache,  in tx_policy_find()  argument
225 list_for_each_entry(it, &cache->used, link) { in tx_policy_find()
227 return it - cache->cache; in tx_policy_find()
230 list_for_each_entry(it, &cache->free, link) { in tx_policy_find()
232 return it - cache->cache; in tx_policy_find()
237 static inline void tx_policy_use(struct tx_policy_cache *cache, in tx_policy_use() argument
241 list_move(&entry->link, &cache->used); in tx_policy_use()
244 static inline int tx_policy_release(struct tx_policy_cache *cache, in tx_policy_release() argument
249 list_move(&entry->link, &cache->free); in tx_policy_release()
256 struct tx_policy_cache *cache = &priv->tx_policy_cache; in tx_policy_clean() local
260 spin_lock_bh(&cache->lock); in tx_policy_clean()
261 locked = list_empty(&cache->free); in tx_policy_clean()
264 entry = &cache->cache[idx]; in tx_policy_clean()
270 list_move(&entry->link, &cache->free); in tx_policy_clean()
278 spin_unlock_bh(&cache->lock); in tx_policy_clean()
286 struct tx_policy_cache *cache = &priv->tx_policy_cache; in tx_policy_init() local
289 memset(cache, 0, sizeof(*cache)); in tx_policy_init()
291 spin_lock_init(&cache->lock); in tx_policy_init()
292 INIT_LIST_HEAD(&cache->used); in tx_policy_init()
293 INIT_LIST_HEAD(&cache->free); in tx_policy_init()
296 list_add(&cache->cache[i].link, &cache->free); in tx_policy_init()
304 struct tx_policy_cache *cache = &priv->tx_policy_cache; in tx_policy_get() local
309 spin_lock_bh(&cache->lock); in tx_policy_get()
310 if (WARN_ON_ONCE(list_empty(&cache->free))) { in tx_policy_get()
311 spin_unlock_bh(&cache->lock); in tx_policy_get()
314 idx = tx_policy_find(cache, &wanted); in tx_policy_get()
324 entry = list_entry(cache->free.prev, in tx_policy_get()
327 idx = entry - cache->cache; in tx_policy_get()
331 tx_policy_use(cache, &cache->cache[idx]); in tx_policy_get()
332 if (list_empty(&cache->free)) { in tx_policy_get()
336 spin_unlock_bh(&cache->lock); in tx_policy_get()
343 struct tx_policy_cache *cache = &priv->tx_policy_cache; in tx_policy_put() local
345 spin_lock_bh(&cache->lock); in tx_policy_put()
346 locked = list_empty(&cache->free); in tx_policy_put()
347 usage = tx_policy_release(cache, &cache->cache[idx]); in tx_policy_put()
352 spin_unlock_bh(&cache->lock); in tx_policy_put()
357 struct tx_policy_cache *cache = &priv->tx_policy_cache; in tx_policy_upload() local
362 spin_lock_bh(&cache->lock); in tx_policy_upload()
366 struct tx_policy *src = &cache->cache[i].policy; in tx_policy_upload()
382 spin_unlock_bh(&cache->lock); in tx_policy_upload()