2 * O(1) TX queue with built-in allocator for ST-Ericsson CW1200 drivers
4 * Copyright (c) 2010, ST-Ericsson
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.
12 #ifndef CW1200_QUEUE_H_INCLUDED
13 #define CW1200_QUEUE_H_INCLUDED
15 /* private */ struct cw1200_queue_item;
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;
23 /* forward */ struct cw1200_queue_stats;
25 typedef void (*cw1200_queue_skb_dtor_t)(struct cw1200_common *priv,
27 const struct cw1200_txpriv *txpriv);
30 struct cw1200_queue_stats *stats;
35 struct cw1200_queue_item *pool;
36 struct list_head queue;
37 struct list_head free_pool;
38 struct list_head pending;
42 spinlock_t lock; /* Protect queue entry */
49 struct cw1200_queue_stats {
50 spinlock_t lock; /* Protect stats entry */
54 wait_queue_head_t wait_link_id_empty;
55 cw1200_queue_skb_dtor_t skb_dtor;
56 struct cw1200_common *priv;
59 struct cw1200_txpriv {
67 int cw1200_queue_stats_init(struct cw1200_queue_stats *stats,
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,
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);
80 size_t cw1200_queue_get_num_queued(struct cw1200_queue *queue,
82 int cw1200_queue_put(struct cw1200_queue *queue,
84 struct cw1200_txpriv *txpriv);
85 int cw1200_queue_get(struct cw1200_queue *queue,
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,
94 int cw1200_queue_get_skb(struct cw1200_queue *queue, u32 packet_id,
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);
103 bool cw1200_queue_stats_is_empty(struct cw1200_queue_stats *stats,
106 static inline u8 cw1200_queue_get_queue_id(u32 packet_id)
108 return (packet_id >> 16) & 0xFF;
111 static inline u8 cw1200_queue_get_generation(u32 packet_id)
113 return (packet_id >> 8) & 0xFF;
116 #endif /* CW1200_QUEUE_H_INCLUDED */