• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * queue operations for XRadio drivers
3  *
4  * Copyright (c) 2013
5  * Xradio Technology Co., Ltd. <www.xradiotech.com>
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 
13 #ifndef XRADIO_QUEUE_H_INCLUDED
14 #define XRADIO_QUEUE_H_INCLUDED
15 
16 
17 /* extern */ struct sk_buff;
18 /* extern */ struct wsm_tx;
19 /* extern */ struct xradio_common;
20 /* extern */ struct xradio_vif;
21 /* extern */ struct ieee80211_tx_queue_stats;
22 
23 /* forward */ struct xradio_queue_stats;
24 
25 struct xradio_txpriv {
26 	u8 link_id;
27 	u8 raw_link_id;
28 	u8 tid;
29 	u8 rate_id;
30 	u8 offset;
31 	u8 if_id;
32 #ifndef P2P_MULTIVIF
33 	u8 offchannel_if_id;
34 #else
35 	u8 raw_if_id;
36 #endif
37 	u8 use_bg_rate;
38 #ifdef AP_ARP_COMPAT_FIX
39 	u8 iv_len;
40 #endif
41 };
42 
43 struct xradio_queue_item {
44 	struct list_head	head;
45 	struct sk_buff		*skb;
46 	u32			packetID;
47 	unsigned long		queue_timestamp;
48 	unsigned long		xmit_timestamp;
49 #ifdef CONFIG_XRADIO_TESTMODE
50 	unsigned long		mdelay_timestamp;
51 	unsigned long		qdelay_timestamp;
52 #endif /*CONFIG_XRADIO_TESTMODE*/
53 	struct xradio_txpriv	txpriv;
54 	u8			generation;
55 	u8			pack_stk_wr;
56 #if BH_PROC_TX
57 	u8			xmit_to_fw;
58 #endif
59 };
60 
61 typedef void (*xradio_queue_skb_dtor_t)(struct xradio_common *priv,
62 					struct sk_buff *skb,
63 					const struct xradio_txpriv *txpriv);
64 
65 struct xradio_queue {
66 	struct                    xradio_queue_stats *stats;
67 	size_t                    capacity;
68 	size_t                    num_queued;
69 	size_t                    num_queued_vif[XRWL_MAX_VIFS];
70 	size_t                    num_pending;
71 	size_t                    num_pending_vif[XRWL_MAX_VIFS];
72 	size_t                    num_sent;
73 	struct xradio_queue_item *pool;
74 	struct list_head          queue;
75 	struct list_head          free_pool;
76 	struct list_head          pending;
77 	int                       tx_locked_cnt;
78 	int                      *link_map_cache[XRWL_MAX_VIFS];
79 	bool                      overfull;
80 	spinlock_t                lock;
81 	u8                        queue_id;
82 #ifdef QUEUE_GEN_IF_TABLE
83 	u8			  generation[XRWL_MAX_VIFS];
84 #else
85 	u8			  generation;
86 #endif
87 
88 	struct timer_list	        gc;
89 	unsigned long             ttl;
90 };
91 
92 struct xradio_queue_stats {
93 	spinlock_t              lock;
94 	int                    *link_map_cache[XRWL_MAX_VIFS];
95 	int                     num_queued[XRWL_MAX_VIFS];
96 	size_t                  map_capacity;
97 	wait_queue_head_t       wait_link_id_empty;
98 	struct list_head        gc_list;
99 	struct work_struct      gc_work;
100 	xradio_queue_skb_dtor_t skb_dtor;
101 	struct xradio_common   *hw_priv;
102 };
103 
104 int xradio_queue_stats_init(struct xradio_queue_stats *stats,
105 			    size_t map_capacity,
106 			    xradio_queue_skb_dtor_t skb_dtor,
107 			    struct xradio_common *priv);
108 int xradio_queue_init(struct xradio_queue *queue,
109 		      struct xradio_queue_stats *stats,
110 		      u8 queue_id,
111 		      size_t capacity,
112 		      unsigned long ttl);
113 int xradio_queue_clear(struct xradio_queue *queue, int if_id);
114 void xradio_queue_stats_deinit(struct xradio_queue_stats *stats);
115 void xradio_queue_deinit(struct xradio_queue *queue);
116 
117 size_t xradio_queue_get_num_queued(struct xradio_vif *priv,
118 				   struct xradio_queue *queue,
119 				   u32 link_id_map);
120 int xradio_queue_put(struct xradio_queue *queue,
121 		     struct sk_buff *skb, struct xradio_txpriv *txpriv);
122 void xradio_skb_post_gc(struct xradio_common *hw_priv,
123 		     struct sk_buff *skb,
124 		     const struct xradio_txpriv *txpriv);
125 
126 #if BH_PROC_TX
127 int xradio_queue_get(struct xradio_queue *queue,
128 		     int if_id, u32 link_id_map,
129 		     struct wsm_tx **tx,
130 		     struct ieee80211_tx_info **tx_info,
131 		     struct xradio_txpriv **txpriv, u8 **data);
132 #else
133 int xradio_queue_get(struct xradio_queue *queue,
134 		     int if_id, u32 link_id_map,
135 		     struct wsm_tx **tx,
136 		     struct ieee80211_tx_info **tx_info,
137 		     struct xradio_txpriv **txpriv);
138 #endif
139 
140 #ifdef CONFIG_XRADIO_TESTMODE
141 int xradio_queue_requeue(struct xradio_common *hw_priv,
142 			 struct xradio_queue *queue,
143 			 u32 packetID, bool check);
144 #else
145 int xradio_queue_requeue(struct xradio_queue *queue, u32 packetID, bool check);
146 #endif
147 int xradio_queue_requeue_all(struct xradio_queue *queue);
148 #ifdef CONFIG_XRADIO_TESTMODE
149 int xradio_queue_remove(struct xradio_common *hw_priv,
150 			struct xradio_queue *queue,
151 			u32 packetID);
152 #else
153 int xradio_queue_remove(struct xradio_queue *queue,
154 			u32 packetID);
155 #endif /*CONFIG_XRADIO_TESTMODE*/
156 int xradio_queue_get_skb(struct xradio_queue *queue, u32 packetID,
157 			 struct sk_buff **skb,
158 			 const struct xradio_txpriv **txpriv);
159 void xradio_queue_lock(struct xradio_queue *queue);
160 void xradio_queue_unlock(struct xradio_queue *queue);
161 bool xradio_queue_get_xmit_timestamp(struct xradio_queue *queue,
162 				     unsigned long *timestamp, int if_id,
163 				     u32 pending_frameID, u32 *Old_frame_ID);
164 bool xradio_query_txpkt_timeout(struct xradio_common *hw_priv, int if_id,
165 				u32 pending_pkt_id, long *timeout);
166 
167 
168 bool xradio_queue_stats_is_empty(struct xradio_queue_stats *stats,
169 				 u32 link_id_map, int if_id);
170 
xradio_queue_get_queue_id(u32 packetID)171 static inline u8 xradio_queue_get_queue_id(u32 packetID)
172 {
173 	return (packetID >> 16) & 0xF;
174 }
175 
xradio_queue_get_if_id(u32 packetID)176 static inline u8 xradio_queue_get_if_id(u32 packetID)
177 {
178 	return (packetID >> 20) & 0xF;
179 }
180 
xradio_queue_get_link_id(u32 packetID)181 static inline u8 xradio_queue_get_link_id(u32 packetID)
182 {
183 	return (packetID >> 24) & 0xF;
184 }
185 
xradio_queue_get_generation(u32 packetID)186 static inline u8 xradio_queue_get_generation(u32 packetID)
187 {
188 	return (packetID >>  8) & 0xFF;
189 }
190 
191 #endif /* XRADIO_QUEUE_H_INCLUDED */
192