#include "rt2x00lib.h"
struct data_queue *rt2x00queue_get_queue(struct rt2x00_dev *rt2x00dev,
- const unsigned int queue)
+ const enum data_queue_qid queue)
{
int atim = test_bit(DRIVER_REQUIRE_ATIM_QUEUE, &rt2x00dev->flags);
if (!rt2x00dev->bcn)
return NULL;
- if (queue == RT2X00_BCN_QUEUE_BEACON)
+ if (queue == QID_BEACON)
return &rt2x00dev->bcn[0];
- else if (queue == RT2X00_BCN_QUEUE_ATIM && atim)
+ else if (queue == QID_ATIM && atim)
return &rt2x00dev->bcn[1];
return NULL;
enum queue_index index)
{
struct queue_entry *entry;
+ unsigned long irqflags;
if (unlikely(index >= Q_INDEX_MAX)) {
ERROR(queue->rt2x00dev,
return NULL;
}
- spin_lock(&queue->lock);
+ spin_lock_irqsave(&queue->lock, irqflags);
entry = &queue->entries[queue->index[index]];
- spin_unlock(&queue->lock);
+ spin_unlock_irqrestore(&queue->lock, irqflags);
return entry;
}
void rt2x00queue_index_inc(struct data_queue *queue, enum queue_index index)
{
+ unsigned long irqflags;
+
if (unlikely(index >= Q_INDEX_MAX)) {
ERROR(queue->rt2x00dev,
"Index change on invalid index type (%d)\n", index);
return;
}
- spin_lock(&queue->lock);
+ spin_lock_irqsave(&queue->lock, irqflags);
queue->index[index]++;
if (queue->index[index] >= queue->limit)
queue->index[index] = 0;
- queue->length--;
- queue->count += (index == Q_INDEX_DONE);
+ if (index == Q_INDEX) {
+ queue->length++;
+ } else if (index == Q_INDEX_DONE) {
+ queue->length--;
+ queue->count ++;
+ }
- spin_unlock(&queue->lock);
+ spin_unlock_irqrestore(&queue->lock, irqflags);
}
EXPORT_SYMBOL_GPL(rt2x00queue_index_inc);
static void rt2x00queue_reset(struct data_queue *queue)
{
- spin_lock(&queue->lock);
+ unsigned long irqflags;
+
+ spin_lock_irqsave(&queue->lock, irqflags);
queue->count = 0;
queue->length = 0;
memset(queue->index, 0, sizeof(queue->index));
- spin_unlock(&queue->lock);
+ spin_unlock_irqrestore(&queue->lock, irqflags);
}
void rt2x00queue_init_rx(struct rt2x00_dev *rt2x00dev)
return -ENOMEM;
#define QUEUE_ENTRY_PRIV_OFFSET(__base, __index, __limit, __esize, __psize) \
- ( (__base) + ((__limit) * (__esize)) + ((__index) * (__psize)) )
+ ( ((char *)(__base)) + ((__limit) * (__esize)) + \
+ ((__index) * (__psize)) )
for (i = 0; i < queue->limit; i++) {
entries[i].flags = 0;
}
}
+static void rt2x00queue_init(struct rt2x00_dev *rt2x00dev,
+ struct data_queue *queue, enum data_queue_qid qid)
+{
+ spin_lock_init(&queue->lock);
+
+ queue->rt2x00dev = rt2x00dev;
+ queue->qid = qid;
+ queue->aifs = 2;
+ queue->cw_min = 5;
+ queue->cw_max = 10;
+}
+
int rt2x00queue_allocate(struct rt2x00_dev *rt2x00dev)
{
struct data_queue *queue;
* TX: cw_max: 2^10 = 1024.
* BCN & Atim: qid = QID_MGMT
*/
- qid = QID_AC_BE;
- queue_for_each(rt2x00dev, queue) {
- spin_lock_init(&queue->lock);
+ rt2x00queue_init(rt2x00dev, rt2x00dev->rx, QID_RX);
- queue->rt2x00dev = rt2x00dev;
- queue->qid = qid++;
- queue->aifs = 2;
- queue->cw_min = 5;
- queue->cw_max = 10;
- }
+ qid = QID_AC_BE;
+ tx_queue_for_each(rt2x00dev, queue)
+ rt2x00queue_init(rt2x00dev, queue, qid++);
- /*
- * Fix non-TX data qid's
- */
- rt2x00dev->rx->qid = QID_RX;
- rt2x00dev->bcn[0].qid = QID_MGMT;
+ rt2x00queue_init(rt2x00dev, &rt2x00dev->bcn[0], QID_MGMT);
if (req_atim)
- rt2x00dev->bcn[1].qid = QID_MGMT;
+ rt2x00queue_init(rt2x00dev, &rt2x00dev->bcn[1], QID_MGMT);
return 0;
}