diff options
author | Gertjan van Wingerde <gwingerde@gmail.com> | 2010-05-11 17:51:39 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-05-12 16:41:44 -0400 |
commit | e01f1ec35ff91c8a3f4a3e48a0c8ab476124b973 (patch) | |
tree | 495949f825157e5dc00694856e35eaa83afe0bb0 | |
parent | 6b97cb04f2766513c57b57f8ac4b44915296230f (diff) |
rt2x00: Re-order tx descriptor writing code in drivers.
Where possible, write the tx descriptor words from start to end, to
follow a logical ordering of words.
Where this is not possible (in rt2400pci, rt2500pci and rt61pci) add
a comment as to why word 0 needs to be written last.
Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2400pci.c | 5 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2500pci.c | 5 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2500usb.c | 36 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt61pci.c | 5 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt73usb.c | 52 |
5 files changed, 59 insertions, 44 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c index 4b3845152e1f..1eff6ec88457 100644 --- a/drivers/net/wireless/rt2x00/rt2400pci.c +++ b/drivers/net/wireless/rt2x00/rt2400pci.c | |||
@@ -1039,6 +1039,11 @@ static void rt2400pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, | |||
1039 | rt2x00_set_field32(&word, TXD_W3_PLCP_LENGTH_HIGH_BUSY, 1); | 1039 | rt2x00_set_field32(&word, TXD_W3_PLCP_LENGTH_HIGH_BUSY, 1); |
1040 | rt2x00_desc_write(txd, 4, word); | 1040 | rt2x00_desc_write(txd, 4, word); |
1041 | 1041 | ||
1042 | /* | ||
1043 | * Writing TXD word 0 must the last to prevent a race condition with | ||
1044 | * the device, whereby the device may take hold of the TXD before we | ||
1045 | * finished updating it. | ||
1046 | */ | ||
1042 | rt2x00_desc_read(txd, 0, &word); | 1047 | rt2x00_desc_read(txd, 0, &word); |
1043 | rt2x00_set_field32(&word, TXD_W0_OWNER_NIC, 1); | 1048 | rt2x00_set_field32(&word, TXD_W0_OWNER_NIC, 1); |
1044 | rt2x00_set_field32(&word, TXD_W0_VALID, 1); | 1049 | rt2x00_set_field32(&word, TXD_W0_VALID, 1); |
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c index d876c6d87591..8d3e95e0dcfe 100644 --- a/drivers/net/wireless/rt2x00/rt2500pci.c +++ b/drivers/net/wireless/rt2x00/rt2500pci.c | |||
@@ -1193,6 +1193,11 @@ static void rt2500pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, | |||
1193 | test_bit(ENTRY_TXD_RTS_FRAME, &txdesc->flags)); | 1193 | test_bit(ENTRY_TXD_RTS_FRAME, &txdesc->flags)); |
1194 | rt2x00_desc_write(txd, 10, word); | 1194 | rt2x00_desc_write(txd, 10, word); |
1195 | 1195 | ||
1196 | /* | ||
1197 | * Writing TXD word 0 must the last to prevent a race condition with | ||
1198 | * the device, whereby the device may take hold of the TXD before we | ||
1199 | * finished updating it. | ||
1200 | */ | ||
1196 | rt2x00_desc_read(txd, 0, &word); | 1201 | rt2x00_desc_read(txd, 0, &word); |
1197 | rt2x00_set_field32(&word, TXD_W0_OWNER_NIC, 1); | 1202 | rt2x00_set_field32(&word, TXD_W0_OWNER_NIC, 1); |
1198 | rt2x00_set_field32(&word, TXD_W0_VALID, 1); | 1203 | rt2x00_set_field32(&word, TXD_W0_VALID, 1); |
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c index 30c0544e8036..9a915be547b3 100644 --- a/drivers/net/wireless/rt2x00/rt2500usb.c +++ b/drivers/net/wireless/rt2x00/rt2500usb.c | |||
@@ -1039,6 +1039,24 @@ static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, | |||
1039 | /* | 1039 | /* |
1040 | * Start writing the descriptor words. | 1040 | * Start writing the descriptor words. |
1041 | */ | 1041 | */ |
1042 | rt2x00_desc_read(txd, 0, &word); | ||
1043 | rt2x00_set_field32(&word, TXD_W0_RETRY_LIMIT, txdesc->retry_limit); | ||
1044 | rt2x00_set_field32(&word, TXD_W0_MORE_FRAG, | ||
1045 | test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags)); | ||
1046 | rt2x00_set_field32(&word, TXD_W0_ACK, | ||
1047 | test_bit(ENTRY_TXD_ACK, &txdesc->flags)); | ||
1048 | rt2x00_set_field32(&word, TXD_W0_TIMESTAMP, | ||
1049 | test_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc->flags)); | ||
1050 | rt2x00_set_field32(&word, TXD_W0_OFDM, | ||
1051 | (txdesc->rate_mode == RATE_MODE_OFDM)); | ||
1052 | rt2x00_set_field32(&word, TXD_W0_NEW_SEQ, | ||
1053 | test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags)); | ||
1054 | rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs); | ||
1055 | rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, txdesc->length); | ||
1056 | rt2x00_set_field32(&word, TXD_W0_CIPHER, !!txdesc->cipher); | ||
1057 | rt2x00_set_field32(&word, TXD_W0_KEY_ID, txdesc->key_idx); | ||
1058 | rt2x00_desc_write(txd, 0, word); | ||
1059 | |||
1042 | rt2x00_desc_read(txd, 1, &word); | 1060 | rt2x00_desc_read(txd, 1, &word); |
1043 | rt2x00_set_field32(&word, TXD_W1_IV_OFFSET, txdesc->iv_offset); | 1061 | rt2x00_set_field32(&word, TXD_W1_IV_OFFSET, txdesc->iv_offset); |
1044 | rt2x00_set_field32(&word, TXD_W1_AIFS, txdesc->aifs); | 1062 | rt2x00_set_field32(&word, TXD_W1_AIFS, txdesc->aifs); |
@@ -1057,24 +1075,6 @@ static void rt2500usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, | |||
1057 | _rt2x00_desc_write(txd, 3, skbdesc->iv[0]); | 1075 | _rt2x00_desc_write(txd, 3, skbdesc->iv[0]); |
1058 | _rt2x00_desc_write(txd, 4, skbdesc->iv[1]); | 1076 | _rt2x00_desc_write(txd, 4, skbdesc->iv[1]); |
1059 | } | 1077 | } |
1060 | |||
1061 | rt2x00_desc_read(txd, 0, &word); | ||
1062 | rt2x00_set_field32(&word, TXD_W0_RETRY_LIMIT, txdesc->retry_limit); | ||
1063 | rt2x00_set_field32(&word, TXD_W0_MORE_FRAG, | ||
1064 | test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags)); | ||
1065 | rt2x00_set_field32(&word, TXD_W0_ACK, | ||
1066 | test_bit(ENTRY_TXD_ACK, &txdesc->flags)); | ||
1067 | rt2x00_set_field32(&word, TXD_W0_TIMESTAMP, | ||
1068 | test_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc->flags)); | ||
1069 | rt2x00_set_field32(&word, TXD_W0_OFDM, | ||
1070 | (txdesc->rate_mode == RATE_MODE_OFDM)); | ||
1071 | rt2x00_set_field32(&word, TXD_W0_NEW_SEQ, | ||
1072 | test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags)); | ||
1073 | rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs); | ||
1074 | rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, txdesc->length); | ||
1075 | rt2x00_set_field32(&word, TXD_W0_CIPHER, !!txdesc->cipher); | ||
1076 | rt2x00_set_field32(&word, TXD_W0_KEY_ID, txdesc->key_idx); | ||
1077 | rt2x00_desc_write(txd, 0, word); | ||
1078 | } | 1078 | } |
1079 | 1079 | ||
1080 | /* | 1080 | /* |
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c index 99c298100fb6..55aa010aeee2 100644 --- a/drivers/net/wireless/rt2x00/rt61pci.c +++ b/drivers/net/wireless/rt2x00/rt61pci.c | |||
@@ -1813,6 +1813,11 @@ static void rt61pci_write_tx_desc(struct rt2x00_dev *rt2x00dev, | |||
1813 | rt2x00_desc_write(txd, 11, word); | 1813 | rt2x00_desc_write(txd, 11, word); |
1814 | } | 1814 | } |
1815 | 1815 | ||
1816 | /* | ||
1817 | * Writing TXD word 0 must the last to prevent a race condition with | ||
1818 | * the device, whereby the device may take hold of the TXD before we | ||
1819 | * finished updating it. | ||
1820 | */ | ||
1816 | rt2x00_desc_read(txd, 0, &word); | 1821 | rt2x00_desc_read(txd, 0, &word); |
1817 | rt2x00_set_field32(&word, TXD_W0_OWNER_NIC, 1); | 1822 | rt2x00_set_field32(&word, TXD_W0_OWNER_NIC, 1); |
1818 | rt2x00_set_field32(&word, TXD_W0_VALID, 1); | 1823 | rt2x00_set_field32(&word, TXD_W0_VALID, 1); |
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c index 81f6db1b16f2..fa40d434e729 100644 --- a/drivers/net/wireless/rt2x00/rt73usb.c +++ b/drivers/net/wireless/rt2x00/rt73usb.c | |||
@@ -1446,6 +1446,32 @@ static void rt73usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, | |||
1446 | /* | 1446 | /* |
1447 | * Start writing the descriptor words. | 1447 | * Start writing the descriptor words. |
1448 | */ | 1448 | */ |
1449 | rt2x00_desc_read(txd, 0, &word); | ||
1450 | rt2x00_set_field32(&word, TXD_W0_BURST, | ||
1451 | test_bit(ENTRY_TXD_BURST, &txdesc->flags)); | ||
1452 | rt2x00_set_field32(&word, TXD_W0_VALID, 1); | ||
1453 | rt2x00_set_field32(&word, TXD_W0_MORE_FRAG, | ||
1454 | test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags)); | ||
1455 | rt2x00_set_field32(&word, TXD_W0_ACK, | ||
1456 | test_bit(ENTRY_TXD_ACK, &txdesc->flags)); | ||
1457 | rt2x00_set_field32(&word, TXD_W0_TIMESTAMP, | ||
1458 | test_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc->flags)); | ||
1459 | rt2x00_set_field32(&word, TXD_W0_OFDM, | ||
1460 | (txdesc->rate_mode == RATE_MODE_OFDM)); | ||
1461 | rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs); | ||
1462 | rt2x00_set_field32(&word, TXD_W0_RETRY_MODE, | ||
1463 | test_bit(ENTRY_TXD_RETRY_MODE, &txdesc->flags)); | ||
1464 | rt2x00_set_field32(&word, TXD_W0_TKIP_MIC, | ||
1465 | test_bit(ENTRY_TXD_ENCRYPT_MMIC, &txdesc->flags)); | ||
1466 | rt2x00_set_field32(&word, TXD_W0_KEY_TABLE, | ||
1467 | test_bit(ENTRY_TXD_ENCRYPT_PAIRWISE, &txdesc->flags)); | ||
1468 | rt2x00_set_field32(&word, TXD_W0_KEY_INDEX, txdesc->key_idx); | ||
1469 | rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, txdesc->length); | ||
1470 | rt2x00_set_field32(&word, TXD_W0_BURST2, | ||
1471 | test_bit(ENTRY_TXD_BURST, &txdesc->flags)); | ||
1472 | rt2x00_set_field32(&word, TXD_W0_CIPHER_ALG, txdesc->cipher); | ||
1473 | rt2x00_desc_write(txd, 0, word); | ||
1474 | |||
1449 | rt2x00_desc_read(txd, 1, &word); | 1475 | rt2x00_desc_read(txd, 1, &word); |
1450 | rt2x00_set_field32(&word, TXD_W1_HOST_Q_ID, txdesc->queue); | 1476 | rt2x00_set_field32(&word, TXD_W1_HOST_Q_ID, txdesc->queue); |
1451 | rt2x00_set_field32(&word, TXD_W1_AIFSN, txdesc->aifs); | 1477 | rt2x00_set_field32(&word, TXD_W1_AIFSN, txdesc->aifs); |
@@ -1473,32 +1499,6 @@ static void rt73usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, | |||
1473 | TXPOWER_TO_DEV(rt2x00dev->tx_power)); | 1499 | TXPOWER_TO_DEV(rt2x00dev->tx_power)); |
1474 | rt2x00_set_field32(&word, TXD_W5_WAITING_DMA_DONE_INT, 1); | 1500 | rt2x00_set_field32(&word, TXD_W5_WAITING_DMA_DONE_INT, 1); |
1475 | rt2x00_desc_write(txd, 5, word); | 1501 | rt2x00_desc_write(txd, 5, word); |
1476 | |||
1477 | rt2x00_desc_read(txd, 0, &word); | ||
1478 | rt2x00_set_field32(&word, TXD_W0_BURST, | ||
1479 | test_bit(ENTRY_TXD_BURST, &txdesc->flags)); | ||
1480 | rt2x00_set_field32(&word, TXD_W0_VALID, 1); | ||
1481 | rt2x00_set_field32(&word, TXD_W0_MORE_FRAG, | ||
1482 | test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags)); | ||
1483 | rt2x00_set_field32(&word, TXD_W0_ACK, | ||
1484 | test_bit(ENTRY_TXD_ACK, &txdesc->flags)); | ||
1485 | rt2x00_set_field32(&word, TXD_W0_TIMESTAMP, | ||
1486 | test_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc->flags)); | ||
1487 | rt2x00_set_field32(&word, TXD_W0_OFDM, | ||
1488 | (txdesc->rate_mode == RATE_MODE_OFDM)); | ||
1489 | rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs); | ||
1490 | rt2x00_set_field32(&word, TXD_W0_RETRY_MODE, | ||
1491 | test_bit(ENTRY_TXD_RETRY_MODE, &txdesc->flags)); | ||
1492 | rt2x00_set_field32(&word, TXD_W0_TKIP_MIC, | ||
1493 | test_bit(ENTRY_TXD_ENCRYPT_MMIC, &txdesc->flags)); | ||
1494 | rt2x00_set_field32(&word, TXD_W0_KEY_TABLE, | ||
1495 | test_bit(ENTRY_TXD_ENCRYPT_PAIRWISE, &txdesc->flags)); | ||
1496 | rt2x00_set_field32(&word, TXD_W0_KEY_INDEX, txdesc->key_idx); | ||
1497 | rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, txdesc->length); | ||
1498 | rt2x00_set_field32(&word, TXD_W0_BURST2, | ||
1499 | test_bit(ENTRY_TXD_BURST, &txdesc->flags)); | ||
1500 | rt2x00_set_field32(&word, TXD_W0_CIPHER_ALG, txdesc->cipher); | ||
1501 | rt2x00_desc_write(txd, 0, word); | ||
1502 | } | 1502 | } |
1503 | 1503 | ||
1504 | /* | 1504 | /* |