diff options
author | Ivo van Doorn <IvDoorn@gmail.com> | 2008-02-05 16:42:23 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-02-29 15:19:27 -0500 |
commit | 181d6902b6bad978d157e69479c95cc0ff213a76 (patch) | |
tree | 7a90b8a949a50bc8db6b7b5b2d76d5671fb9a89e /drivers/net/wireless/rt2x00/rt73usb.c | |
parent | 811aa9cad1bd927999888ab56ed9592519d2fef6 (diff) |
rt2x00: Queue handling overhaul
This introduces a big queue handling overhaul, this also
renames "ring" to "queues".
Move queue handling into rt2x00queue.c and the matching header,
use Kerneldoc to improve rt2x00 library documentation.
Access to the queues is now protected under a spinlock, this
to prevent race conditions which could corrupt the indexing
system of the queue.
Each queue entry allocates x bytes for driver/device specific data,
this cleans up the queue structure significantly and improves
code readability.
rt2500usb no longer needs 2 entries in the beacon queue to correctly
send out the guardian byte. This is now handled in the entry specific
structure.
rt61 and rt73 now use the correct descriptor size for beacon frames,
since this data is written into the registers not the entire TXD
descriptor was used but instead of a subset of it named TXINFO.
Finally this also fixes numerous other bugs related to incorrect
beacon handling or beacon related code.
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt73usb.c')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt73usb.c | 134 |
1 files changed, 88 insertions, 46 deletions
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c index 416e44943e71..4e6466b13af1 100644 --- a/drivers/net/wireless/rt2x00/rt73usb.c +++ b/drivers/net/wireless/rt2x00/rt73usb.c | |||
@@ -1234,10 +1234,10 @@ static int rt73usb_set_device_state(struct rt2x00_dev *rt2x00dev, | |||
1234 | */ | 1234 | */ |
1235 | static void rt73usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, | 1235 | static void rt73usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, |
1236 | struct sk_buff *skb, | 1236 | struct sk_buff *skb, |
1237 | struct txdata_entry_desc *desc, | 1237 | struct txentry_desc *txdesc, |
1238 | struct ieee80211_tx_control *control) | 1238 | struct ieee80211_tx_control *control) |
1239 | { | 1239 | { |
1240 | struct skb_desc *skbdesc = get_skb_desc(skb); | 1240 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); |
1241 | __le32 *txd = skbdesc->desc; | 1241 | __le32 *txd = skbdesc->desc; |
1242 | u32 word; | 1242 | u32 word; |
1243 | 1243 | ||
@@ -1245,19 +1245,19 @@ static void rt73usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, | |||
1245 | * Start writing the descriptor words. | 1245 | * Start writing the descriptor words. |
1246 | */ | 1246 | */ |
1247 | rt2x00_desc_read(txd, 1, &word); | 1247 | rt2x00_desc_read(txd, 1, &word); |
1248 | rt2x00_set_field32(&word, TXD_W1_HOST_Q_ID, desc->queue); | 1248 | rt2x00_set_field32(&word, TXD_W1_HOST_Q_ID, txdesc->queue); |
1249 | rt2x00_set_field32(&word, TXD_W1_AIFSN, desc->aifs); | 1249 | rt2x00_set_field32(&word, TXD_W1_AIFSN, txdesc->aifs); |
1250 | rt2x00_set_field32(&word, TXD_W1_CWMIN, desc->cw_min); | 1250 | rt2x00_set_field32(&word, TXD_W1_CWMIN, txdesc->cw_min); |
1251 | rt2x00_set_field32(&word, TXD_W1_CWMAX, desc->cw_max); | 1251 | rt2x00_set_field32(&word, TXD_W1_CWMAX, txdesc->cw_max); |
1252 | rt2x00_set_field32(&word, TXD_W1_IV_OFFSET, IEEE80211_HEADER); | 1252 | rt2x00_set_field32(&word, TXD_W1_IV_OFFSET, IEEE80211_HEADER); |
1253 | rt2x00_set_field32(&word, TXD_W1_HW_SEQUENCE, 1); | 1253 | rt2x00_set_field32(&word, TXD_W1_HW_SEQUENCE, 1); |
1254 | rt2x00_desc_write(txd, 1, word); | 1254 | rt2x00_desc_write(txd, 1, word); |
1255 | 1255 | ||
1256 | rt2x00_desc_read(txd, 2, &word); | 1256 | rt2x00_desc_read(txd, 2, &word); |
1257 | rt2x00_set_field32(&word, TXD_W2_PLCP_SIGNAL, desc->signal); | 1257 | rt2x00_set_field32(&word, TXD_W2_PLCP_SIGNAL, txdesc->signal); |
1258 | rt2x00_set_field32(&word, TXD_W2_PLCP_SERVICE, desc->service); | 1258 | rt2x00_set_field32(&word, TXD_W2_PLCP_SERVICE, txdesc->service); |
1259 | rt2x00_set_field32(&word, TXD_W2_PLCP_LENGTH_LOW, desc->length_low); | 1259 | rt2x00_set_field32(&word, TXD_W2_PLCP_LENGTH_LOW, txdesc->length_low); |
1260 | rt2x00_set_field32(&word, TXD_W2_PLCP_LENGTH_HIGH, desc->length_high); | 1260 | rt2x00_set_field32(&word, TXD_W2_PLCP_LENGTH_HIGH, txdesc->length_high); |
1261 | rt2x00_desc_write(txd, 2, word); | 1261 | rt2x00_desc_write(txd, 2, word); |
1262 | 1262 | ||
1263 | rt2x00_desc_read(txd, 5, &word); | 1263 | rt2x00_desc_read(txd, 5, &word); |
@@ -1268,24 +1268,24 @@ static void rt73usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, | |||
1268 | 1268 | ||
1269 | rt2x00_desc_read(txd, 0, &word); | 1269 | rt2x00_desc_read(txd, 0, &word); |
1270 | rt2x00_set_field32(&word, TXD_W0_BURST, | 1270 | rt2x00_set_field32(&word, TXD_W0_BURST, |
1271 | test_bit(ENTRY_TXD_BURST, &desc->flags)); | 1271 | test_bit(ENTRY_TXD_BURST, &txdesc->flags)); |
1272 | rt2x00_set_field32(&word, TXD_W0_VALID, 1); | 1272 | rt2x00_set_field32(&word, TXD_W0_VALID, 1); |
1273 | rt2x00_set_field32(&word, TXD_W0_MORE_FRAG, | 1273 | rt2x00_set_field32(&word, TXD_W0_MORE_FRAG, |
1274 | test_bit(ENTRY_TXD_MORE_FRAG, &desc->flags)); | 1274 | test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags)); |
1275 | rt2x00_set_field32(&word, TXD_W0_ACK, | 1275 | rt2x00_set_field32(&word, TXD_W0_ACK, |
1276 | test_bit(ENTRY_TXD_ACK, &desc->flags)); | 1276 | test_bit(ENTRY_TXD_ACK, &txdesc->flags)); |
1277 | rt2x00_set_field32(&word, TXD_W0_TIMESTAMP, | 1277 | rt2x00_set_field32(&word, TXD_W0_TIMESTAMP, |
1278 | test_bit(ENTRY_TXD_REQ_TIMESTAMP, &desc->flags)); | 1278 | test_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc->flags)); |
1279 | rt2x00_set_field32(&word, TXD_W0_OFDM, | 1279 | rt2x00_set_field32(&word, TXD_W0_OFDM, |
1280 | test_bit(ENTRY_TXD_OFDM_RATE, &desc->flags)); | 1280 | test_bit(ENTRY_TXD_OFDM_RATE, &txdesc->flags)); |
1281 | rt2x00_set_field32(&word, TXD_W0_IFS, desc->ifs); | 1281 | rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs); |
1282 | rt2x00_set_field32(&word, TXD_W0_RETRY_MODE, | 1282 | rt2x00_set_field32(&word, TXD_W0_RETRY_MODE, |
1283 | !!(control->flags & | 1283 | !!(control->flags & |
1284 | IEEE80211_TXCTL_LONG_RETRY_LIMIT)); | 1284 | IEEE80211_TXCTL_LONG_RETRY_LIMIT)); |
1285 | rt2x00_set_field32(&word, TXD_W0_TKIP_MIC, 0); | 1285 | rt2x00_set_field32(&word, TXD_W0_TKIP_MIC, 0); |
1286 | rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, skbdesc->data_len); | 1286 | rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, skbdesc->data_len); |
1287 | rt2x00_set_field32(&word, TXD_W0_BURST2, | 1287 | rt2x00_set_field32(&word, TXD_W0_BURST2, |
1288 | test_bit(ENTRY_TXD_BURST, &desc->flags)); | 1288 | test_bit(ENTRY_TXD_BURST, &txdesc->flags)); |
1289 | rt2x00_set_field32(&word, TXD_W0_CIPHER_ALG, CIPHER_NONE); | 1289 | rt2x00_set_field32(&word, TXD_W0_CIPHER_ALG, CIPHER_NONE); |
1290 | rt2x00_desc_write(txd, 0, word); | 1290 | rt2x00_desc_write(txd, 0, word); |
1291 | } | 1291 | } |
@@ -1377,37 +1377,57 @@ static int rt73usb_agc_to_rssi(struct rt2x00_dev *rt2x00dev, int rxd_w1) | |||
1377 | return rt2x00_get_field32(rxd_w1, RXD_W1_RSSI_AGC) * 2 - offset; | 1377 | return rt2x00_get_field32(rxd_w1, RXD_W1_RSSI_AGC) * 2 - offset; |
1378 | } | 1378 | } |
1379 | 1379 | ||
1380 | static void rt73usb_fill_rxdone(struct data_entry *entry, | 1380 | static void rt73usb_fill_rxdone(struct queue_entry *entry, |
1381 | struct rxdata_entry_desc *desc) | 1381 | struct rxdone_entry_desc *rxdesc) |
1382 | { | 1382 | { |
1383 | struct skb_desc *skbdesc = get_skb_desc(entry->skb); | 1383 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); |
1384 | __le32 *rxd = (__le32 *)entry->skb->data; | 1384 | __le32 *rxd = (__le32 *)entry->skb->data; |
1385 | struct ieee80211_hdr *hdr = | ||
1386 | (struct ieee80211_hdr *)entry->skb->data + entry->queue->desc_size; | ||
1387 | int header_size = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control)); | ||
1385 | u32 word0; | 1388 | u32 word0; |
1386 | u32 word1; | 1389 | u32 word1; |
1387 | 1390 | ||
1388 | rt2x00_desc_read(rxd, 0, &word0); | 1391 | rt2x00_desc_read(rxd, 0, &word0); |
1389 | rt2x00_desc_read(rxd, 1, &word1); | 1392 | rt2x00_desc_read(rxd, 1, &word1); |
1390 | 1393 | ||
1391 | desc->flags = 0; | 1394 | rxdesc->flags = 0; |
1392 | if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR)) | 1395 | if (rt2x00_get_field32(word0, RXD_W0_CRC_ERROR)) |
1393 | desc->flags |= RX_FLAG_FAILED_FCS_CRC; | 1396 | rxdesc->flags |= RX_FLAG_FAILED_FCS_CRC; |
1394 | 1397 | ||
1395 | /* | 1398 | /* |
1396 | * Obtain the status about this packet. | 1399 | * Obtain the status about this packet. |
1397 | */ | 1400 | */ |
1398 | desc->signal = rt2x00_get_field32(word1, RXD_W1_SIGNAL); | 1401 | rxdesc->signal = rt2x00_get_field32(word1, RXD_W1_SIGNAL); |
1399 | desc->rssi = rt73usb_agc_to_rssi(entry->ring->rt2x00dev, word1); | 1402 | rxdesc->rssi = rt73usb_agc_to_rssi(entry->queue->rt2x00dev, word1); |
1400 | desc->ofdm = rt2x00_get_field32(word0, RXD_W0_OFDM); | 1403 | rxdesc->ofdm = rt2x00_get_field32(word0, RXD_W0_OFDM); |
1401 | desc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT); | 1404 | rxdesc->size = rt2x00_get_field32(word0, RXD_W0_DATABYTE_COUNT); |
1402 | desc->my_bss = !!rt2x00_get_field32(word0, RXD_W0_MY_BSS); | 1405 | rxdesc->my_bss = !!rt2x00_get_field32(word0, RXD_W0_MY_BSS); |
1406 | |||
1407 | /* | ||
1408 | * The data behind the ieee80211 header must be | ||
1409 | * aligned on a 4 byte boundary. | ||
1410 | */ | ||
1411 | if (header_size % 4 == 0) { | ||
1412 | skb_push(entry->skb, 2); | ||
1413 | memmove(entry->skb->data, entry->skb->data + 2, | ||
1414 | entry->skb->len - 2); | ||
1415 | } | ||
1403 | 1416 | ||
1404 | /* | 1417 | /* |
1405 | * Set descriptor and data pointer. | 1418 | * Set descriptor and data pointer. |
1406 | */ | 1419 | */ |
1420 | skbdesc->data = entry->skb->data + entry->queue->desc_size; | ||
1421 | skbdesc->data_len = entry->queue->data_size; | ||
1407 | skbdesc->desc = entry->skb->data; | 1422 | skbdesc->desc = entry->skb->data; |
1408 | skbdesc->desc_len = entry->ring->desc_size; | 1423 | skbdesc->desc_len = entry->queue->desc_size; |
1409 | skbdesc->data = entry->skb->data + entry->ring->desc_size; | 1424 | |
1410 | skbdesc->data_len = desc->size; | 1425 | /* |
1426 | * Remove descriptor from skb buffer and trim the whole thing | ||
1427 | * down to only contain data. | ||
1428 | */ | ||
1429 | skb_pull(entry->skb, skbdesc->desc_len); | ||
1430 | skb_trim(entry->skb, rxdesc->size); | ||
1411 | } | 1431 | } |
1412 | 1432 | ||
1413 | /* | 1433 | /* |
@@ -1967,9 +1987,9 @@ static int rt73usb_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
1967 | struct ieee80211_tx_control *control) | 1987 | struct ieee80211_tx_control *control) |
1968 | { | 1988 | { |
1969 | struct rt2x00_dev *rt2x00dev = hw->priv; | 1989 | struct rt2x00_dev *rt2x00dev = hw->priv; |
1970 | struct skb_desc *desc; | 1990 | struct skb_frame_desc *skbdesc; |
1971 | struct data_ring *ring; | 1991 | struct data_queue *queue; |
1972 | struct data_entry *entry; | 1992 | struct queue_entry *entry; |
1973 | int timeout; | 1993 | int timeout; |
1974 | 1994 | ||
1975 | /* | 1995 | /* |
@@ -1978,25 +1998,25 @@ static int rt73usb_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb, | |||
1978 | * initialization. | 1998 | * initialization. |
1979 | */ | 1999 | */ |
1980 | control->queue = IEEE80211_TX_QUEUE_BEACON; | 2000 | control->queue = IEEE80211_TX_QUEUE_BEACON; |
1981 | ring = rt2x00lib_get_ring(rt2x00dev, control->queue); | 2001 | queue = rt2x00queue_get_queue(rt2x00dev, control->queue); |
1982 | entry = rt2x00_get_data_entry(ring); | 2002 | entry = rt2x00queue_get_entry(queue, Q_INDEX); |
1983 | 2003 | ||
1984 | /* | 2004 | /* |
1985 | * Add the descriptor in front of the skb. | 2005 | * Add the descriptor in front of the skb. |
1986 | */ | 2006 | */ |
1987 | skb_push(skb, ring->desc_size); | 2007 | skb_push(skb, queue->desc_size); |
1988 | memset(skb->data, 0, ring->desc_size); | 2008 | memset(skb->data, 0, queue->desc_size); |
1989 | 2009 | ||
1990 | /* | 2010 | /* |
1991 | * Fill in skb descriptor | 2011 | * Fill in skb descriptor |
1992 | */ | 2012 | */ |
1993 | desc = get_skb_desc(skb); | 2013 | skbdesc = get_skb_frame_desc(skb); |
1994 | desc->desc_len = ring->desc_size; | 2014 | memset(skbdesc, 0, sizeof(*skbdesc)); |
1995 | desc->data_len = skb->len - ring->desc_size; | 2015 | skbdesc->data = skb->data + queue->desc_size; |
1996 | desc->desc = skb->data; | 2016 | skbdesc->data_len = queue->data_size; |
1997 | desc->data = skb->data + ring->desc_size; | 2017 | skbdesc->desc = skb->data; |
1998 | desc->ring = ring; | 2018 | skbdesc->desc_len = queue->desc_size; |
1999 | desc->entry = entry; | 2019 | skbdesc->entry = entry; |
2000 | 2020 | ||
2001 | rt2x00lib_write_tx_desc(rt2x00dev, skb, control); | 2021 | rt2x00lib_write_tx_desc(rt2x00dev, skb, control); |
2002 | 2022 | ||
@@ -2057,12 +2077,34 @@ static const struct rt2x00lib_ops rt73usb_rt2x00_ops = { | |||
2057 | .config = rt73usb_config, | 2077 | .config = rt73usb_config, |
2058 | }; | 2078 | }; |
2059 | 2079 | ||
2080 | static const struct data_queue_desc rt73usb_queue_rx = { | ||
2081 | .entry_num = RX_ENTRIES, | ||
2082 | .data_size = DATA_FRAME_SIZE, | ||
2083 | .desc_size = RXD_DESC_SIZE, | ||
2084 | .priv_size = sizeof(struct queue_entry_priv_usb_rx), | ||
2085 | }; | ||
2086 | |||
2087 | static const struct data_queue_desc rt73usb_queue_tx = { | ||
2088 | .entry_num = TX_ENTRIES, | ||
2089 | .data_size = DATA_FRAME_SIZE, | ||
2090 | .desc_size = TXD_DESC_SIZE, | ||
2091 | .priv_size = sizeof(struct queue_entry_priv_usb_tx), | ||
2092 | }; | ||
2093 | |||
2094 | static const struct data_queue_desc rt73usb_queue_bcn = { | ||
2095 | .entry_num = BEACON_ENTRIES, | ||
2096 | .data_size = MGMT_FRAME_SIZE, | ||
2097 | .desc_size = TXINFO_SIZE, | ||
2098 | .priv_size = sizeof(struct queue_entry_priv_usb_tx), | ||
2099 | }; | ||
2100 | |||
2060 | static const struct rt2x00_ops rt73usb_ops = { | 2101 | static const struct rt2x00_ops rt73usb_ops = { |
2061 | .name = KBUILD_MODNAME, | 2102 | .name = KBUILD_MODNAME, |
2062 | .rxd_size = RXD_DESC_SIZE, | ||
2063 | .txd_size = TXD_DESC_SIZE, | ||
2064 | .eeprom_size = EEPROM_SIZE, | 2103 | .eeprom_size = EEPROM_SIZE, |
2065 | .rf_size = RF_SIZE, | 2104 | .rf_size = RF_SIZE, |
2105 | .rx = &rt73usb_queue_rx, | ||
2106 | .tx = &rt73usb_queue_tx, | ||
2107 | .bcn = &rt73usb_queue_bcn, | ||
2066 | .lib = &rt73usb_rt2x00_ops, | 2108 | .lib = &rt73usb_rt2x00_ops, |
2067 | .hw = &rt73usb_mac80211_ops, | 2109 | .hw = &rt73usb_mac80211_ops, |
2068 | #ifdef CONFIG_RT2X00_LIB_DEBUGFS | 2110 | #ifdef CONFIG_RT2X00_LIB_DEBUGFS |