Skip to content

Commit

Permalink
rt2x00: Use rt2x00 queue numbering
Browse files Browse the repository at this point in the history
Use the rt2x00 queue enumeration as much as possible,
removing the usage of the mac80211 queue numbering
wherever it is possible.

This makes it easier for mac80211 to change it queue
identification scheme without having to deal with
big changes in the rt2x00 code.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Ivo van Doorn authored and John W. Linville committed May 7, 2008
1 parent 62e70cf commit e58c6ac
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 116 deletions.
32 changes: 11 additions & 21 deletions drivers/net/wireless/rt2x00/rt2400pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1055,11 +1055,11 @@ static void rt2400pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
* TX data initialization
*/
static void rt2400pci_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
const unsigned int queue)
const enum data_queue_qid queue)
{
u32 reg;

if (queue == RT2X00_BCN_QUEUE_BEACON) {
if (queue == QID_BEACON) {
rt2x00pci_register_read(rt2x00dev, CSR14, &reg);
if (!rt2x00_get_field32(reg, CSR14_BEACON_GEN)) {
rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 1);
Expand All @@ -1071,12 +1071,9 @@ static void rt2400pci_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
}

rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg);
rt2x00_set_field32(&reg, TXCSR0_KICK_PRIO,
(queue == IEEE80211_TX_QUEUE_DATA0));
rt2x00_set_field32(&reg, TXCSR0_KICK_TX,
(queue == IEEE80211_TX_QUEUE_DATA1));
rt2x00_set_field32(&reg, TXCSR0_KICK_ATIM,
(queue == RT2X00_BCN_QUEUE_ATIM));
rt2x00_set_field32(&reg, TXCSR0_KICK_PRIO, (queue == QID_AC_BE));
rt2x00_set_field32(&reg, TXCSR0_KICK_TX, (queue == QID_AC_BK));
rt2x00_set_field32(&reg, TXCSR0_KICK_ATIM, (queue == QID_ATIM));
rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
}

Expand Down Expand Up @@ -1120,7 +1117,7 @@ static void rt2400pci_fill_rxdone(struct queue_entry *entry,
* Interrupt functions.
*/
static void rt2400pci_txdone(struct rt2x00_dev *rt2x00dev,
const enum ieee80211_tx_queue queue_idx)
const enum data_queue_qid queue_idx)
{
struct data_queue *queue = rt2x00queue_get_queue(rt2x00dev, queue_idx);
struct queue_entry_priv_pci_tx *priv_tx;
Expand Down Expand Up @@ -1187,19 +1184,19 @@ static irqreturn_t rt2400pci_interrupt(int irq, void *dev_instance)
* 3 - Atim ring transmit done interrupt.
*/
if (rt2x00_get_field32(reg, CSR7_TXDONE_ATIMRING))
rt2400pci_txdone(rt2x00dev, RT2X00_BCN_QUEUE_ATIM);
rt2400pci_txdone(rt2x00dev, QID_ATIM);

/*
* 4 - Priority ring transmit done interrupt.
*/
if (rt2x00_get_field32(reg, CSR7_TXDONE_PRIORING))
rt2400pci_txdone(rt2x00dev, IEEE80211_TX_QUEUE_DATA0);
rt2400pci_txdone(rt2x00dev, QID_AC_BE);

/*
* 5 - Tx ring transmit done interrupt.
*/
if (rt2x00_get_field32(reg, CSR7_TXDONE_TXRING))
rt2400pci_txdone(rt2x00dev, IEEE80211_TX_QUEUE_DATA1);
rt2400pci_txdone(rt2x00dev, QID_AC_BK);

return IRQ_HANDLED;
}
Expand Down Expand Up @@ -1520,21 +1517,14 @@ static int rt2400pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb,
rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
rt2x00pci_register_write(rt2x00dev, CSR14, reg);

/*
* mac80211 doesn't provide the control->queue variable
* for beacons. Set our own queue identification so
* it can be used during descriptor initialization.
*/
control->queue = RT2X00_BCN_QUEUE_BEACON;
rt2x00lib_write_tx_desc(rt2x00dev, skb, control);

/*
* Enable beacon generation.
* Write entire beacon with descriptor to register,
* and kick the beacon generator.
*/
rt2x00lib_write_tx_desc(rt2x00dev, skb, control);
memcpy(priv_tx->data, skb->data, skb->len);
rt2x00dev->ops->lib->kick_tx_queue(rt2x00dev, control->queue);
rt2x00dev->ops->lib->kick_tx_queue(rt2x00dev, QID_BEACON);

return 0;
}
Expand Down
35 changes: 12 additions & 23 deletions drivers/net/wireless/rt2x00/rt2500pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,7 @@ static void rt2500pci_config_intf(struct rt2x00_dev *rt2x00dev,
struct rt2x00intf_conf *conf,
const unsigned int flags)
{
struct data_queue *queue =
rt2x00queue_get_queue(rt2x00dev, RT2X00_BCN_QUEUE_BEACON);
struct data_queue *queue = rt2x00queue_get_queue(rt2x00dev, QID_BEACON);
unsigned int bcn_preload;
u32 reg;

Expand Down Expand Up @@ -1210,11 +1209,11 @@ static void rt2500pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
* TX data initialization
*/
static void rt2500pci_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
const unsigned int queue)
const enum data_queue_qid queue)
{
u32 reg;

if (queue == RT2X00_BCN_QUEUE_BEACON) {
if (queue == QID_BEACON) {
rt2x00pci_register_read(rt2x00dev, CSR14, &reg);
if (!rt2x00_get_field32(reg, CSR14_BEACON_GEN)) {
rt2x00_set_field32(&reg, CSR14_TSF_COUNT, 1);
Expand All @@ -1226,12 +1225,9 @@ static void rt2500pci_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
}

rt2x00pci_register_read(rt2x00dev, TXCSR0, &reg);
rt2x00_set_field32(&reg, TXCSR0_KICK_PRIO,
(queue == IEEE80211_TX_QUEUE_DATA0));
rt2x00_set_field32(&reg, TXCSR0_KICK_TX,
(queue == IEEE80211_TX_QUEUE_DATA1));
rt2x00_set_field32(&reg, TXCSR0_KICK_ATIM,
(queue == RT2X00_BCN_QUEUE_ATIM));
rt2x00_set_field32(&reg, TXCSR0_KICK_PRIO, (queue == QID_AC_BE));
rt2x00_set_field32(&reg, TXCSR0_KICK_TX, (queue == QID_AC_BK));
rt2x00_set_field32(&reg, TXCSR0_KICK_ATIM, (queue == QID_ATIM));
rt2x00pci_register_write(rt2x00dev, TXCSR0, reg);
}

Expand Down Expand Up @@ -1276,7 +1272,7 @@ static void rt2500pci_fill_rxdone(struct queue_entry *entry,
* Interrupt functions.
*/
static void rt2500pci_txdone(struct rt2x00_dev *rt2x00dev,
const enum ieee80211_tx_queue queue_idx)
const enum data_queue_qid queue_idx)
{
struct data_queue *queue = rt2x00queue_get_queue(rt2x00dev, queue_idx);
struct queue_entry_priv_pci_tx *priv_tx;
Expand Down Expand Up @@ -1343,19 +1339,19 @@ static irqreturn_t rt2500pci_interrupt(int irq, void *dev_instance)
* 3 - Atim ring transmit done interrupt.
*/
if (rt2x00_get_field32(reg, CSR7_TXDONE_ATIMRING))
rt2500pci_txdone(rt2x00dev, RT2X00_BCN_QUEUE_ATIM);
rt2500pci_txdone(rt2x00dev, QID_ATIM);

/*
* 4 - Priority ring transmit done interrupt.
*/
if (rt2x00_get_field32(reg, CSR7_TXDONE_PRIORING))
rt2500pci_txdone(rt2x00dev, IEEE80211_TX_QUEUE_DATA0);
rt2500pci_txdone(rt2x00dev, QID_AC_BE);

/*
* 5 - Tx ring transmit done interrupt.
*/
if (rt2x00_get_field32(reg, CSR7_TXDONE_TXRING))
rt2500pci_txdone(rt2x00dev, IEEE80211_TX_QUEUE_DATA1);
rt2500pci_txdone(rt2x00dev, QID_AC_BK);

return IRQ_HANDLED;
}
Expand Down Expand Up @@ -1833,21 +1829,14 @@ static int rt2500pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb,
rt2x00_set_field32(&reg, CSR14_BEACON_GEN, 0);
rt2x00pci_register_write(rt2x00dev, CSR14, reg);

/*
* mac80211 doesn't provide the control->queue variable
* for beacons. Set our own queue identification so
* it can be used during descriptor initialization.
*/
control->queue = RT2X00_BCN_QUEUE_BEACON;
rt2x00lib_write_tx_desc(rt2x00dev, skb, control);

/*
* Enable beacon generation.
* Write entire beacon with descriptor to register,
* and kick the beacon generator.
*/
rt2x00lib_write_tx_desc(rt2x00dev, skb, control);
memcpy(priv_tx->data, skb->data, skb->len);
rt2x00dev->ops->lib->kick_tx_queue(rt2x00dev, control->queue);
rt2x00dev->ops->lib->kick_tx_queue(rt2x00dev, QID_BEACON);

return 0;
}
Expand Down
12 changes: 3 additions & 9 deletions drivers/net/wireless/rt2x00/rt2500usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1094,11 +1094,11 @@ static int rt2500usb_get_tx_data_len(struct rt2x00_dev *rt2x00dev,
* TX data initialization
*/
static void rt2500usb_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
const unsigned int queue)
const enum data_queue_qid queue)
{
u16 reg;

if (queue != RT2X00_BCN_QUEUE_BEACON)
if (queue != QID_BEACON)
return;

rt2500usb_register_read(rt2x00dev, TXRX_CSR19, &reg);
Expand Down Expand Up @@ -1720,12 +1720,6 @@ static int rt2500usb_beacon_update(struct ieee80211_hw *hw,
rt2x00_set_field16(&reg, TXRX_CSR19_BEACON_GEN, 0);
rt2500usb_register_write(rt2x00dev, TXRX_CSR19, reg);

/*
* mac80211 doesn't provide the control->queue variable
* for beacons. Set our own queue identification so
* it can be used during descriptor initialization.
*/
control->queue = RT2X00_BCN_QUEUE_BEACON;
rt2x00lib_write_tx_desc(rt2x00dev, skb, control);

/*
Expand Down Expand Up @@ -1757,7 +1751,7 @@ static int rt2500usb_beacon_update(struct ieee80211_hw *hw,
/*
* Enable beacon generation.
*/
rt2500usb_kick_tx_queue(rt2x00dev, control->queue);
rt2500usb_kick_tx_queue(rt2x00dev, QID_BEACON);

return 0;
}
Expand Down
9 changes: 4 additions & 5 deletions drivers/net/wireless/rt2x00/rt2x00.h
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ struct rt2x00lib_ops {
int (*get_tx_data_len) (struct rt2x00_dev *rt2x00dev,
struct sk_buff *skb);
void (*kick_tx_queue) (struct rt2x00_dev *rt2x00dev,
const unsigned int queue);
const enum data_queue_qid queue);

/*
* RX control handlers
Expand Down Expand Up @@ -927,13 +927,12 @@ static inline u16 get_duration_res(const unsigned int size, const u8 rate)
}

/**
* rt2x00queue_get_queue - Convert mac80211 queue index to rt2x00 queue
* rt2x00queue_get_queue - Convert queue index to queue pointer
* @rt2x00dev: Pointer to &struct rt2x00_dev.
* @queue: mac80211/rt2x00 queue index
* (see &enum ieee80211_tx_queue and &enum rt2x00_bcn_queue).
* @queue: rt2x00 queue index (see &enum data_queue_qid).
*/
struct data_queue *rt2x00queue_get_queue(struct rt2x00_dev *rt2x00dev,
const unsigned int queue);
const enum data_queue_qid queue);

/**
* rt2x00queue_get_entry - Get queue entry where the given index points to.
Expand Down
3 changes: 1 addition & 2 deletions drivers/net/wireless/rt2x00/rt2x00dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -687,8 +687,7 @@ void rt2x00lib_write_tx_desc(struct rt2x00_dev *rt2x00dev,
* Beacons and probe responses require the tsf timestamp
* to be inserted into the frame.
*/
if (control->queue == RT2X00_BCN_QUEUE_BEACON ||
is_probe_resp(frame_control))
if (txdesc.queue == QID_BEACON || is_probe_resp(frame_control))
__set_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc.flags);

/*
Expand Down
13 changes: 6 additions & 7 deletions drivers/net/wireless/rt2x00/rt2x00mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ int rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb,
{
struct rt2x00_dev *rt2x00dev = hw->priv;
struct ieee80211_hdr *ieee80211hdr = (struct ieee80211_hdr *)skb->data;
enum data_queue_qid qid = mac80211_queue_to_qid(control->queue);
struct data_queue *queue;
struct skb_frame_desc *skbdesc;
u16 frame_control;
Expand All @@ -101,14 +102,13 @@ int rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb,
*/
if (control->flags & IEEE80211_TXCTL_SEND_AFTER_DTIM &&
test_bit(DRIVER_REQUIRE_ATIM_QUEUE, &rt2x00dev->flags))
queue = rt2x00queue_get_queue(rt2x00dev, RT2X00_BCN_QUEUE_ATIM);
queue = rt2x00queue_get_queue(rt2x00dev, QID_ATIM);
else
queue = rt2x00queue_get_queue(rt2x00dev, control->queue);
queue = rt2x00queue_get_queue(rt2x00dev, qid);
if (unlikely(!queue)) {
ERROR(rt2x00dev,
"Attempt to send packet over invalid queue %d.\n"
"Please file bug report to %s.\n",
control->queue, DRV_PROJECT);
"Please file bug report to %s.\n", qid, DRV_PROJECT);
dev_kfree_skb_any(skb);
return NETDEV_TX_OK;
}
Expand Down Expand Up @@ -154,7 +154,7 @@ int rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb,
ieee80211_stop_queue(rt2x00dev->hw, control->queue);

if (rt2x00dev->ops->lib->kick_tx_queue)
rt2x00dev->ops->lib->kick_tx_queue(rt2x00dev, control->queue);
rt2x00dev->ops->lib->kick_tx_queue(rt2x00dev, qid);

return NETDEV_TX_OK;
}
Expand Down Expand Up @@ -187,8 +187,7 @@ int rt2x00mac_add_interface(struct ieee80211_hw *hw,
{
struct rt2x00_dev *rt2x00dev = hw->priv;
struct rt2x00_intf *intf = vif_to_intf(conf->vif);
struct data_queue *queue =
rt2x00queue_get_queue(rt2x00dev, RT2X00_BCN_QUEUE_BEACON);
struct data_queue *queue = rt2x00queue_get_queue(rt2x00dev, QID_BEACON);
struct queue_entry *entry = NULL;
unsigned int i;

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/rt2x00/rt2x00pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int rt2x00pci_write_tx_data(struct rt2x00_dev *rt2x00dev,
ERROR(rt2x00dev,
"Arrived at non-free entry in the non-full queue %d.\n"
"Please file bug report to %s.\n",
control->queue, DRV_PROJECT);
entry->queue->qid, DRV_PROJECT);
return -EINVAL;
}

Expand Down
6 changes: 3 additions & 3 deletions drivers/net/wireless/rt2x00/rt2x00queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#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);

Expand All @@ -40,9 +40,9 @@ struct data_queue *rt2x00queue_get_queue(struct rt2x00_dev *rt2x00dev,
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;
Expand Down
Loading

0 comments on commit e58c6ac

Please sign in to comment.