Lines Matching refs:cache

44 /* TX policy cache implementation */
73 static int wfx_tx_policy_find(struct wfx_tx_policy_cache *cache, struct wfx_tx_policy *wanted)
77 list_for_each_entry(it, &cache->used, link)
79 return it - cache->cache;
80 list_for_each_entry(it, &cache->free, link)
82 return it - cache->cache;
86 static void wfx_tx_policy_use(struct wfx_tx_policy_cache *cache, struct wfx_tx_policy *entry)
89 list_move(&entry->link, &cache->used);
92 static int wfx_tx_policy_release(struct wfx_tx_policy_cache *cache, struct wfx_tx_policy *entry)
97 list_move(&entry->link, &cache->free);
104 struct wfx_tx_policy_cache *cache = &wvif->tx_policy_cache;
110 spin_lock_bh(&cache->lock);
111 if (list_empty(&cache->free)) {
113 spin_unlock_bh(&cache->lock);
116 idx = wfx_tx_policy_find(cache, &wanted);
122 entry = list_entry(cache->free.prev, struct wfx_tx_policy, link);
126 idx = entry - cache->cache;
128 wfx_tx_policy_use(cache, &cache->cache[idx]);
129 if (list_empty(&cache->free))
131 spin_unlock_bh(&cache->lock);
138 struct wfx_tx_policy_cache *cache = &wvif->tx_policy_cache;
142 spin_lock_bh(&cache->lock);
143 locked = list_empty(&cache->free);
144 usage = wfx_tx_policy_release(cache, &cache->cache[idx]);
147 spin_unlock_bh(&cache->lock);
152 struct wfx_tx_policy *policies = wvif->tx_policy_cache.cache;
158 for (i = 0; i < ARRAY_SIZE(wvif->tx_policy_cache.cache); ++i) {
163 if (i < ARRAY_SIZE(wvif->tx_policy_cache.cache)) {
171 } while (i < ARRAY_SIZE(wvif->tx_policy_cache.cache));
185 struct wfx_tx_policy_cache *cache = &wvif->tx_policy_cache;
188 memset(cache, 0, sizeof(*cache));
190 spin_lock_init(&cache->lock);
191 INIT_LIST_HEAD(&cache->used);
192 INIT_LIST_HEAD(&cache->free);
194 for (i = 0; i < ARRAY_SIZE(cache->cache); ++i)
195 list_add(&cache->cache[i].link, &cache->free);