drivers/net/wireless/st/cw1200/queue.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/st/cw1200/queue.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/st/cw1200/queue.c- Extension
.c- Size
- 13944 bytes
- Lines
- 550
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
net/mac80211.hlinux/sched.hlinux/jiffies.hqueue.hcw1200.hdebug.h
Detected Declarations
function __cw1200_queue_lockfunction __cw1200_queue_unlockfunction cw1200_queue_parse_idfunction cw1200_queue_mk_packet_idfunction cw1200_queue_post_gcfunction list_for_each_entry_safefunction cw1200_queue_register_post_gcfunction __cw1200_queue_gcfunction list_for_each_entry_safefunction cw1200_queue_gcfunction cw1200_queue_stats_initfunction cw1200_queue_initfunction cw1200_queue_clearfunction cw1200_queue_stats_deinitfunction cw1200_queue_deinitfunction cw1200_queue_get_num_queuedfunction cw1200_queue_putfunction cw1200_queue_getfunction cw1200_queue_requeuefunction cw1200_queue_removefunction cw1200_queue_get_skbfunction cw1200_queue_lockfunction cw1200_queue_unlockfunction cw1200_queue_get_xmit_timestampfunction list_for_each_entryfunction cw1200_queue_stats_is_empty
Annotated Snippet
if (time_is_after_jiffies(iter->queue_timestamp + queue->ttl)) {
item = iter;
break;
}
--queue->num_queued;
--queue->link_map_cache[iter->txpriv.link_id];
spin_lock_bh(&stats->lock);
--stats->num_queued;
if (!--stats->link_map_cache[iter->txpriv.link_id])
wakeup_stats = true;
spin_unlock_bh(&stats->lock);
cw1200_debug_tx_ttl(stats->priv);
cw1200_queue_register_post_gc(head, iter);
iter->skb = NULL;
list_move_tail(&iter->head, &queue->free_pool);
}
if (wakeup_stats)
wake_up(&stats->wait_link_id_empty);
if (queue->overfull) {
if (queue->num_queued <= (queue->capacity >> 1)) {
queue->overfull = false;
if (unlock)
__cw1200_queue_unlock(queue);
} else if (item) {
unsigned long tmo = item->queue_timestamp + queue->ttl;
mod_timer(&queue->gc, tmo);
cw1200_pm_stay_awake(&stats->priv->pm_state,
tmo - jiffies);
}
}
}
static void cw1200_queue_gc(struct timer_list *t)
{
LIST_HEAD(list);
struct cw1200_queue *queue =
timer_container_of(queue, t, gc);
spin_lock_bh(&queue->lock);
__cw1200_queue_gc(queue, &list, true);
spin_unlock_bh(&queue->lock);
cw1200_queue_post_gc(queue->stats, &list);
}
int cw1200_queue_stats_init(struct cw1200_queue_stats *stats,
size_t map_capacity,
cw1200_queue_skb_dtor_t skb_dtor,
struct cw1200_common *priv)
{
memset(stats, 0, sizeof(*stats));
stats->map_capacity = map_capacity;
stats->skb_dtor = skb_dtor;
stats->priv = priv;
spin_lock_init(&stats->lock);
init_waitqueue_head(&stats->wait_link_id_empty);
stats->link_map_cache = kzalloc_objs(int, map_capacity);
if (!stats->link_map_cache)
return -ENOMEM;
return 0;
}
int cw1200_queue_init(struct cw1200_queue *queue,
struct cw1200_queue_stats *stats,
u8 queue_id,
size_t capacity,
unsigned long ttl)
{
size_t i;
memset(queue, 0, sizeof(*queue));
queue->stats = stats;
queue->capacity = capacity;
queue->queue_id = queue_id;
queue->ttl = ttl;
INIT_LIST_HEAD(&queue->queue);
INIT_LIST_HEAD(&queue->pending);
INIT_LIST_HEAD(&queue->free_pool);
spin_lock_init(&queue->lock);
timer_setup(&queue->gc, cw1200_queue_gc, 0);
queue->pool = kzalloc_objs(struct cw1200_queue_item, capacity);
if (!queue->pool)
return -ENOMEM;
queue->link_map_cache = kzalloc_objs(int, stats->map_capacity);
if (!queue->link_map_cache) {
Annotation
- Immediate include surface: `net/mac80211.h`, `linux/sched.h`, `linux/jiffies.h`, `queue.h`, `cw1200.h`, `debug.h`.
- Detected declarations: `function __cw1200_queue_lock`, `function __cw1200_queue_unlock`, `function cw1200_queue_parse_id`, `function cw1200_queue_mk_packet_id`, `function cw1200_queue_post_gc`, `function list_for_each_entry_safe`, `function cw1200_queue_register_post_gc`, `function __cw1200_queue_gc`, `function list_for_each_entry_safe`, `function cw1200_queue_gc`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.