Commit | Line | Data |
---|---|---|
a910e4a9 SP |
1 | /* |
2 | * O(1) TX queue with built-in allocator for ST-Ericsson CW1200 drivers | |
3 | * | |
4 | * Copyright (c) 2010, ST-Ericsson | |
5 | * Author: Dmitry Tarnyagin <dmitry.tarnyagin@lockless.no> | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License version 2 as | |
9 | * published by the Free Software Foundation. | |
10 | */ | |
11 | ||
12 | #ifndef CW1200_QUEUE_H_INCLUDED | |
13 | #define CW1200_QUEUE_H_INCLUDED | |
14 | ||
15 | /* private */ struct cw1200_queue_item; | |
16 | ||
17 | /* extern */ struct sk_buff; | |
18 | /* extern */ struct wsm_tx; | |
19 | /* extern */ struct cw1200_common; | |
20 | /* extern */ struct ieee80211_tx_queue_stats; | |
21 | /* extern */ struct cw1200_txpriv; | |
22 | ||
23 | /* forward */ struct cw1200_queue_stats; | |
24 | ||
25 | typedef void (*cw1200_queue_skb_dtor_t)(struct cw1200_common *priv, | |
26 | struct sk_buff *skb, | |
27 | const struct cw1200_txpriv *txpriv); | |
28 | ||
29 | struct cw1200_queue { | |
30 | struct cw1200_queue_stats *stats; | |
31 | size_t capacity; | |
32 | size_t num_queued; | |
33 | size_t num_pending; | |
34 | size_t num_sent; | |
35 | struct cw1200_queue_item *pool; | |
36 | struct list_head queue; | |
37 | struct list_head free_pool; | |
38 | struct list_head pending; | |
39 | int tx_locked_cnt; | |
40 | int *link_map_cache; | |
41 | bool overfull; | |
42 | spinlock_t lock; /* Protect queue entry */ | |
43 | u8 queue_id; | |
44 | u8 generation; | |
45 | struct timer_list gc; | |
46 | unsigned long ttl; | |
47 | }; | |
48 | ||
49 | struct cw1200_queue_stats { | |
50 | spinlock_t lock; /* Protect stats entry */ | |
51 | int *link_map_cache; | |
52 | int num_queued; | |
53 | size_t map_capacity; | |
54 | wait_queue_head_t wait_link_id_empty; | |
55 | cw1200_queue_skb_dtor_t skb_dtor; | |
56 | struct cw1200_common *priv; | |
57 | }; | |
58 | ||
59 | struct cw1200_txpriv { | |
60 | u8 link_id; | |
61 | u8 raw_link_id; | |
62 | u8 tid; | |
63 | u8 rate_id; | |
64 | u8 offset; | |
65 | }; | |
66 | ||
67 | int cw1200_queue_stats_init(struct cw1200_queue_stats *stats, | |
68 | size_t map_capacity, | |
69 | cw1200_queue_skb_dtor_t skb_dtor, | |
70 | struct cw1200_common *priv); | |
71 | int cw1200_queue_init(struct cw1200_queue *queue, | |
72 | struct cw1200_queue_stats *stats, | |
73 | u8 queue_id, | |
74 | size_t capacity, | |
75 | unsigned long ttl); | |
76 | int cw1200_queue_clear(struct cw1200_queue *queue); | |
77 | void cw1200_queue_stats_deinit(struct cw1200_queue_stats *stats); | |
78 | void cw1200_queue_deinit(struct cw1200_queue *queue); | |
79 | ||
80 | size_t cw1200_queue_get_num_queued(struct cw1200_queue *queue, | |
81 | u32 link_id_map); | |
82 | int cw1200_queue_put(struct cw1200_queue *queue, | |
83 | struct sk_buff *skb, | |
84 | struct cw1200_txpriv *txpriv); | |
85 | int cw1200_queue_get(struct cw1200_queue *queue, | |
86 | u32 link_id_map, | |
87 | struct wsm_tx **tx, | |
88 | struct ieee80211_tx_info **tx_info, | |
89 | const struct cw1200_txpriv **txpriv); | |
90 | int cw1200_queue_requeue(struct cw1200_queue *queue, u32 packet_id); | |
91 | int cw1200_queue_requeue_all(struct cw1200_queue *queue); | |
92 | int cw1200_queue_remove(struct cw1200_queue *queue, | |
93 | u32 packet_id); | |
94 | int cw1200_queue_get_skb(struct cw1200_queue *queue, u32 packet_id, | |
95 | struct sk_buff **skb, | |
96 | const struct cw1200_txpriv **txpriv); | |
97 | void cw1200_queue_lock(struct cw1200_queue *queue); | |
98 | void cw1200_queue_unlock(struct cw1200_queue *queue); | |
99 | bool cw1200_queue_get_xmit_timestamp(struct cw1200_queue *queue, | |
100 | unsigned long *timestamp, | |
101 | u32 pending_frame_id); | |
102 | ||
103 | bool cw1200_queue_stats_is_empty(struct cw1200_queue_stats *stats, | |
104 | u32 link_id_map); | |
105 | ||
106 | static inline u8 cw1200_queue_get_queue_id(u32 packet_id) | |
107 | { | |
108 | return (packet_id >> 16) & 0xFF; | |
109 | } | |
110 | ||
111 | static inline u8 cw1200_queue_get_generation(u32 packet_id) | |
112 | { | |
113 | return (packet_id >> 8) & 0xFF; | |
114 | } | |
115 | ||
116 | #endif /* CW1200_QUEUE_H_INCLUDED */ |