1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * O(1) TX queue with built-in allocator for ST-Ericsson CW1200 drivers
5 * Copyright (c) 2010, ST-Ericsson
6 * Author: Dmitry Tarnyagin <dmitry.tarnyagin@lockless.no>
9 #ifndef CW1200_QUEUE_H_INCLUDED
10 #define CW1200_QUEUE_H_INCLUDED
12 /* private */ struct cw1200_queue_item
;
14 /* extern */ struct sk_buff
;
15 /* extern */ struct wsm_tx
;
16 /* extern */ struct cw1200_common
;
17 /* extern */ struct ieee80211_tx_queue_stats
;
18 /* extern */ struct cw1200_txpriv
;
20 /* forward */ struct cw1200_queue_stats
;
22 typedef void (*cw1200_queue_skb_dtor_t
)(struct cw1200_common
*priv
,
24 const struct cw1200_txpriv
*txpriv
);
27 struct cw1200_queue_stats
*stats
;
32 struct cw1200_queue_item
*pool
;
33 struct list_head queue
;
34 struct list_head free_pool
;
35 struct list_head pending
;
39 spinlock_t lock
; /* Protect queue entry */
46 struct cw1200_queue_stats
{
47 spinlock_t lock
; /* Protect stats entry */
51 wait_queue_head_t wait_link_id_empty
;
52 cw1200_queue_skb_dtor_t skb_dtor
;
53 struct cw1200_common
*priv
;
56 struct cw1200_txpriv
{
64 int cw1200_queue_stats_init(struct cw1200_queue_stats
*stats
,
66 cw1200_queue_skb_dtor_t skb_dtor
,
67 struct cw1200_common
*priv
);
68 int cw1200_queue_init(struct cw1200_queue
*queue
,
69 struct cw1200_queue_stats
*stats
,
73 int cw1200_queue_clear(struct cw1200_queue
*queue
);
74 void cw1200_queue_stats_deinit(struct cw1200_queue_stats
*stats
);
75 void cw1200_queue_deinit(struct cw1200_queue
*queue
);
77 size_t cw1200_queue_get_num_queued(struct cw1200_queue
*queue
,
79 int cw1200_queue_put(struct cw1200_queue
*queue
,
81 struct cw1200_txpriv
*txpriv
);
82 int cw1200_queue_get(struct cw1200_queue
*queue
,
85 struct ieee80211_tx_info
**tx_info
,
86 const struct cw1200_txpriv
**txpriv
);
87 int cw1200_queue_requeue(struct cw1200_queue
*queue
, u32 packet_id
);
88 int cw1200_queue_requeue_all(struct cw1200_queue
*queue
);
89 int cw1200_queue_remove(struct cw1200_queue
*queue
,
91 int cw1200_queue_get_skb(struct cw1200_queue
*queue
, u32 packet_id
,
93 const struct cw1200_txpriv
**txpriv
);
94 void cw1200_queue_lock(struct cw1200_queue
*queue
);
95 void cw1200_queue_unlock(struct cw1200_queue
*queue
);
96 bool cw1200_queue_get_xmit_timestamp(struct cw1200_queue
*queue
,
97 unsigned long *timestamp
,
98 u32 pending_frame_id
);
100 bool cw1200_queue_stats_is_empty(struct cw1200_queue_stats
*stats
,
103 static inline u8
cw1200_queue_get_queue_id(u32 packet_id
)
105 return (packet_id
>> 16) & 0xFF;
108 static inline u8
cw1200_queue_get_generation(u32 packet_id
)
110 return (packet_id
>> 8) & 0xFF;
113 #endif /* CW1200_QUEUE_H_INCLUDED */