diff options
author | Tomas Winkler <tomas.winkler@intel.com> | 2008-03-06 20:36:53 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-03-07 16:03:01 -0500 |
commit | c54b679ddcd91604fd0d144cd793a0ddbd0ae03d (patch) | |
tree | 3ebbedc13d2a64a1c6491ac29c5c3a18e934bc6b /drivers/net/wireless/iwlwifi/iwl3945-base.c | |
parent | 34cf6ff6dd42cbc61fd652f893dcf71eed6052a5 (diff) |
iwlwifi: queue functions cleanup
This patch moves
1. iwl_queue_inc_wrap and int iwl_queue_dec_wrap
into iwl-helpers.h these two functions are identical to common
for both iwl3956 and iwl4965
2. renames x2_queue_used to iwl3945_x2_queue_used
3. exports iwl3945_queue_space out of iwl3964-base.c
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl3945-base.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl3945-base.c | 45 |
1 files changed, 13 insertions, 32 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c index 4aaced0b9f26..39fd5440a248 100644 --- a/drivers/net/wireless/iwlwifi/iwl3945-base.c +++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c | |||
@@ -183,7 +183,7 @@ static const char *iwl3945_escape_essid(const char *essid, u8 essid_len) | |||
183 | * (#0-3) for data tx via EDCA. An additional 2 HCCA queues are unused. | 183 | * (#0-3) for data tx via EDCA. An additional 2 HCCA queues are unused. |
184 | ***************************************************/ | 184 | ***************************************************/ |
185 | 185 | ||
186 | static int iwl3945_queue_space(const struct iwl3945_queue *q) | 186 | int iwl3945_queue_space(const struct iwl3945_queue *q) |
187 | { | 187 | { |
188 | int s = q->read_ptr - q->write_ptr; | 188 | int s = q->read_ptr - q->write_ptr; |
189 | 189 | ||
@@ -199,33 +199,14 @@ static int iwl3945_queue_space(const struct iwl3945_queue *q) | |||
199 | return s; | 199 | return s; |
200 | } | 200 | } |
201 | 201 | ||
202 | /** | 202 | int iwl3945_x2_queue_used(const struct iwl3945_queue *q, int i) |
203 | * iwl3945_queue_inc_wrap - increment queue index, wrap back to beginning | ||
204 | * @index -- current index | ||
205 | * @n_bd -- total number of entries in queue (must be power of 2) | ||
206 | */ | ||
207 | static inline int iwl3945_queue_inc_wrap(int index, int n_bd) | ||
208 | { | ||
209 | return ++index & (n_bd - 1); | ||
210 | } | ||
211 | |||
212 | /** | ||
213 | * iwl3945_queue_dec_wrap - increment queue index, wrap back to end | ||
214 | * @index -- current index | ||
215 | * @n_bd -- total number of entries in queue (must be power of 2) | ||
216 | */ | ||
217 | static inline int iwl3945_queue_dec_wrap(int index, int n_bd) | ||
218 | { | ||
219 | return --index & (n_bd - 1); | ||
220 | } | ||
221 | |||
222 | static inline int x2_queue_used(const struct iwl3945_queue *q, int i) | ||
223 | { | 203 | { |
224 | return q->write_ptr > q->read_ptr ? | 204 | return q->write_ptr > q->read_ptr ? |
225 | (i >= q->read_ptr && i < q->write_ptr) : | 205 | (i >= q->read_ptr && i < q->write_ptr) : |
226 | !(i < q->read_ptr && i >= q->write_ptr); | 206 | !(i < q->read_ptr && i >= q->write_ptr); |
227 | } | 207 | } |
228 | 208 | ||
209 | |||
229 | static inline u8 get_cmd_index(struct iwl3945_queue *q, u32 index, int is_huge) | 210 | static inline u8 get_cmd_index(struct iwl3945_queue *q, u32 index, int is_huge) |
230 | { | 211 | { |
231 | /* This is for scan command, the big buffer at end of command array */ | 212 | /* This is for scan command, the big buffer at end of command array */ |
@@ -246,8 +227,8 @@ static int iwl3945_queue_init(struct iwl3945_priv *priv, struct iwl3945_queue *q | |||
246 | q->n_window = slots_num; | 227 | q->n_window = slots_num; |
247 | q->id = id; | 228 | q->id = id; |
248 | 229 | ||
249 | /* count must be power-of-two size, otherwise iwl3945_queue_inc_wrap | 230 | /* count must be power-of-two size, otherwise iwl_queue_inc_wrap |
250 | * and iwl3945_queue_dec_wrap are broken. */ | 231 | * and iwl_queue_dec_wrap are broken. */ |
251 | BUG_ON(!is_power_of_2(count)); | 232 | BUG_ON(!is_power_of_2(count)); |
252 | 233 | ||
253 | /* slots_num must be power-of-two size, otherwise | 234 | /* slots_num must be power-of-two size, otherwise |
@@ -347,7 +328,7 @@ int iwl3945_tx_queue_init(struct iwl3945_priv *priv, | |||
347 | txq->need_update = 0; | 328 | txq->need_update = 0; |
348 | 329 | ||
349 | /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise | 330 | /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise |
350 | * iwl3945_queue_inc_wrap and iwl3945_queue_dec_wrap are broken. */ | 331 | * iwl_queue_inc_wrap and iwl_queue_dec_wrap are broken. */ |
351 | BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); | 332 | BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); |
352 | 333 | ||
353 | /* Initialize queue high/low-water, head/tail indexes */ | 334 | /* Initialize queue high/low-water, head/tail indexes */ |
@@ -378,7 +359,7 @@ void iwl3945_tx_queue_free(struct iwl3945_priv *priv, struct iwl3945_tx_queue *t | |||
378 | 359 | ||
379 | /* first, empty all BD's */ | 360 | /* first, empty all BD's */ |
380 | for (; q->write_ptr != q->read_ptr; | 361 | for (; q->write_ptr != q->read_ptr; |
381 | q->read_ptr = iwl3945_queue_inc_wrap(q->read_ptr, q->n_bd)) | 362 | q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) |
382 | iwl3945_hw_txq_free_tfd(priv, txq); | 363 | iwl3945_hw_txq_free_tfd(priv, txq); |
383 | 364 | ||
384 | len = sizeof(struct iwl3945_cmd) * q->n_window; | 365 | len = sizeof(struct iwl3945_cmd) * q->n_window; |
@@ -717,7 +698,7 @@ static int iwl3945_enqueue_hcmd(struct iwl3945_priv *priv, struct iwl3945_host_c | |||
717 | txq->need_update = 1; | 698 | txq->need_update = 1; |
718 | 699 | ||
719 | /* Increment and update queue's write index */ | 700 | /* Increment and update queue's write index */ |
720 | q->write_ptr = iwl3945_queue_inc_wrap(q->write_ptr, q->n_bd); | 701 | q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd); |
721 | ret = iwl3945_tx_queue_update_write_ptr(priv, txq); | 702 | ret = iwl3945_tx_queue_update_write_ptr(priv, txq); |
722 | 703 | ||
723 | spin_unlock_irqrestore(&priv->hcmd_lock, flags); | 704 | spin_unlock_irqrestore(&priv->hcmd_lock, flags); |
@@ -2797,7 +2778,7 @@ static int iwl3945_tx_skb(struct iwl3945_priv *priv, | |||
2797 | ieee80211_get_hdrlen(fc)); | 2778 | ieee80211_get_hdrlen(fc)); |
2798 | 2779 | ||
2799 | /* Tell device the write index *just past* this latest filled TFD */ | 2780 | /* Tell device the write index *just past* this latest filled TFD */ |
2800 | q->write_ptr = iwl3945_queue_inc_wrap(q->write_ptr, q->n_bd); | 2781 | q->write_ptr = iwl_queue_inc_wrap(q->write_ptr, q->n_bd); |
2801 | rc = iwl3945_tx_queue_update_write_ptr(priv, txq); | 2782 | rc = iwl3945_tx_queue_update_write_ptr(priv, txq); |
2802 | spin_unlock_irqrestore(&priv->lock, flags); | 2783 | spin_unlock_irqrestore(&priv->lock, flags); |
2803 | 2784 | ||
@@ -3189,16 +3170,16 @@ static int iwl3945_tx_queue_reclaim(struct iwl3945_priv *priv, int txq_id, int i | |||
3189 | struct iwl3945_queue *q = &txq->q; | 3170 | struct iwl3945_queue *q = &txq->q; |
3190 | int nfreed = 0; | 3171 | int nfreed = 0; |
3191 | 3172 | ||
3192 | if ((index >= q->n_bd) || (x2_queue_used(q, index) == 0)) { | 3173 | if ((index >= q->n_bd) || (iwl3945_x2_queue_used(q, index) == 0)) { |
3193 | IWL_ERROR("Read index for DMA queue txq id (%d), index %d, " | 3174 | IWL_ERROR("Read index for DMA queue txq id (%d), index %d, " |
3194 | "is out of range [0-%d] %d %d.\n", txq_id, | 3175 | "is out of range [0-%d] %d %d.\n", txq_id, |
3195 | index, q->n_bd, q->write_ptr, q->read_ptr); | 3176 | index, q->n_bd, q->write_ptr, q->read_ptr); |
3196 | return 0; | 3177 | return 0; |
3197 | } | 3178 | } |
3198 | 3179 | ||
3199 | for (index = iwl3945_queue_inc_wrap(index, q->n_bd); | 3180 | for (index = iwl_queue_inc_wrap(index, q->n_bd); |
3200 | q->read_ptr != index; | 3181 | q->read_ptr != index; |
3201 | q->read_ptr = iwl3945_queue_inc_wrap(q->read_ptr, q->n_bd)) { | 3182 | q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) { |
3202 | if (txq_id != IWL_CMD_QUEUE_NUM) { | 3183 | if (txq_id != IWL_CMD_QUEUE_NUM) { |
3203 | iwl3945_txstatus_to_ieee(priv, | 3184 | iwl3945_txstatus_to_ieee(priv, |
3204 | &(txq->txb[txq->q.read_ptr])); | 3185 | &(txq->txb[txq->q.read_ptr])); |
@@ -3245,7 +3226,7 @@ static void iwl3945_rx_reply_tx(struct iwl3945_priv *priv, | |||
3245 | struct iwl3945_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; | 3226 | struct iwl3945_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; |
3246 | u32 status = le32_to_cpu(tx_resp->status); | 3227 | u32 status = le32_to_cpu(tx_resp->status); |
3247 | 3228 | ||
3248 | if ((index >= txq->q.n_bd) || (x2_queue_used(&txq->q, index) == 0)) { | 3229 | if ((index >= txq->q.n_bd) || (iwl3945_x2_queue_used(&txq->q, index) == 0)) { |
3249 | IWL_ERROR("Read index for DMA queue txq_id (%d) index %d " | 3230 | IWL_ERROR("Read index for DMA queue txq_id (%d) index %d " |
3250 | "is out of range [0-%d] %d %d\n", txq_id, | 3231 | "is out of range [0-%d] %d %d\n", txq_id, |
3251 | index, txq->q.n_bd, txq->q.write_ptr, | 3232 | index, txq->q.n_bd, txq->q.write_ptr, |